summaryrefslogtreecommitdiff
path: root/proto/radv
diff options
context:
space:
mode:
Diffstat (limited to 'proto/radv')
-rw-r--r--proto/radv/config.Y10
-rw-r--r--proto/radv/packets.c25
-rw-r--r--proto/radv/radv.c2
-rw-r--r--proto/radv/radv.h5
4 files changed, 20 insertions, 22 deletions
diff --git a/proto/radv/config.Y b/proto/radv/config.Y
index da300667..efb474a6 100644
--- a/proto/radv/config.Y
+++ b/proto/radv/config.Y
@@ -53,9 +53,8 @@ radv_proto_item:
| PREFIX radv_prefix { add_tail(&RADV_CFG->pref_list, NODE this_radv_prefix); }
| RDNSS { init_list(&radv_dns_list); } radv_rdnss { add_tail_list(&RADV_CFG->rdnss_list, &radv_dns_list); }
| DNSSL { init_list(&radv_dns_list); } radv_dnssl { add_tail_list(&RADV_CFG->dnssl_list, &radv_dns_list); }
- | TRIGGER prefix {
- RADV_CFG->trigger_prefix = $2.addr;
- RADV_CFG->trigger_pxlen = $2.len;
+ | TRIGGER net_any {
+ RADV_CFG->trigger = $2;
RADV_CFG->trigger_valid = 1;
}
;
@@ -148,11 +147,10 @@ radv_iface:
radv_iface_start iface_patt_list_nopx radv_iface_opt_list radv_iface_finish;
-radv_prefix_start: prefix
+radv_prefix_start: net_ip6
{
this_radv_prefix = cfg_allocz(sizeof(struct radv_prefix_config));
- RADV_PREFIX->prefix = $1.addr;
- RADV_PREFIX->pxlen = $1.len;
+ RADV_PREFIX->prefix = $1.ip6;
RADV_PREFIX->onlink = 1;
RADV_PREFIX->autonomous = 1;
diff --git a/proto/radv/packets.c b/proto/radv/packets.c
index 3862af8d..a38b58b2 100644
--- a/proto/radv/packets.c
+++ b/proto/radv/packets.c
@@ -38,7 +38,7 @@ struct radv_opt_prefix
u32 valid_lifetime;
u32 preferred_lifetime;
u32 reserved;
- ip_addr prefix;
+ ip6_addr prefix;
};
#define OPT_PX_ONLINK 0x80
@@ -58,7 +58,7 @@ struct radv_opt_rdnss
u8 length;
u16 reserved;
u32 lifetime;
- ip_addr servers[];
+ ip6_addr servers[];
};
struct radv_opt_dnssl
@@ -90,11 +90,11 @@ radv_prefix_match(struct radv_iface *ifa, struct ifa *a)
return NULL;
WALK_LIST(pc, ifa->cf->pref_list)
- if ((a->pxlen >= pc->pxlen) && ipa_in_net(a->prefix, pc->prefix, pc->pxlen))
+ if (net_in_netX(&a->prefix, (net_addr *) &pc->prefix))
return pc;
WALK_LIST(pc, cf->pref_list)
- if ((a->pxlen >= pc->pxlen) && ipa_in_net(a->prefix, pc->prefix, pc->pxlen))
+ if (net_in_netX(&a->prefix, (net_addr *) &pc->prefix))
return pc;
return &default_prefix;
@@ -109,7 +109,7 @@ radv_prepare_rdnss(struct radv_iface *ifa, list *rdnss_list, char **buf, char *b
{
struct radv_rdnss_config *rcf_base = rcf;
struct radv_opt_rdnss *op = (void *) *buf;
- int max_i = (bufend - *buf - sizeof(struct radv_opt_rdnss)) / sizeof(ip_addr);
+ int max_i = (bufend - *buf - sizeof(struct radv_opt_rdnss)) / sizeof(ip6_addr);
int i = 0;
if (max_i < 1)
@@ -123,20 +123,19 @@ radv_prepare_rdnss(struct radv_iface *ifa, list *rdnss_list, char **buf, char *b
else
op->lifetime = htonl(rcf->lifetime);
- while(NODE_VALID(rcf) &&
+ while(NODE_VALID(rcf) &&
(rcf->lifetime == rcf_base->lifetime) &&
(rcf->lifetime_mult == rcf_base->lifetime_mult))
{
if (i >= max_i)
goto too_much;
- op->servers[i] = rcf->server;
- ipa_hton(op->servers[i]);
+ op->servers[i] = ip6_hton(rcf->server);
i++;
rcf = NODE_NEXT(rcf);
}
-
+
op->length = 1+2*i;
*buf += 8 * op->length;
}
@@ -273,6 +272,9 @@ radv_prepare_ra(struct radv_iface *ifa)
struct ifa *addr;
WALK_LIST(addr, ifa->iface->addrs)
{
+ if (addr->prefix.type != NET_IP6)
+ continue;
+
struct radv_prefix_config *pc;
pc = radv_prefix_match(ifa, addr);
@@ -288,7 +290,7 @@ radv_prepare_ra(struct radv_iface *ifa)
struct radv_opt_prefix *op = (void *) buf;
op->type = OPT_PREFIX;
op->length = 4;
- op->pxlen = addr->pxlen;
+ op->pxlen = net6_pxlen(&addr->prefix);
op->flags = (pc->onlink ? OPT_PX_ONLINK : 0) |
(pc->autonomous ? OPT_PX_AUTONOMOUS : 0);
op->valid_lifetime = (ra->active || !pc->valid_lifetime_sensitive) ?
@@ -296,8 +298,7 @@ radv_prepare_ra(struct radv_iface *ifa)
op->preferred_lifetime = (ra->active || !pc->preferred_lifetime_sensitive) ?
htonl(pc->preferred_lifetime) : 0;
op->reserved = 0;
- op->prefix = addr->prefix;
- ipa_hton(op->prefix);
+ op->prefix = ip6_hton(net6_prefix(&addr->prefix));
buf += sizeof(*op);
}
diff --git a/proto/radv/radv.c b/proto/radv/radv.c
index 2de89991..97713b95 100644
--- a/proto/radv/radv.c
+++ b/proto/radv/radv.c
@@ -143,7 +143,7 @@ find_lladdr(struct iface *iface)
{
struct ifa *a;
WALK_LIST(a, iface->addrs)
- if (a->scope == SCOPE_LINK)
+ if ((a->prefix.type == NET_IP6) && (a->scope == SCOPE_LINK))
return a;
return NULL;
diff --git a/proto/radv/radv.h b/proto/radv/radv.h
index aede6a67..755009d4 100644
--- a/proto/radv/radv.h
+++ b/proto/radv/radv.h
@@ -82,8 +82,7 @@ struct radv_iface_config
struct radv_prefix_config
{
node n;
- ip_addr prefix;
- int pxlen;
+ net_addr_ip6 prefix;
u8 skip; /* Do not include this prefix to RA */
u8 onlink; /* Standard options from RFC 4261 */
@@ -99,7 +98,7 @@ struct radv_rdnss_config
node n;
u32 lifetime; /* Valid if lifetime_mult is 0 */
u16 lifetime_mult; /* Lifetime specified as multiple of max_ra_int */
- ip_addr server; /* IP address of recursive DNS server */
+ ip6_addr server; /* IP address of recursive DNS server */
};
struct radv_dnssl_config