summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
Diffstat (limited to 'nest')
-rw-r--r--nest/config.Y13
-rw-r--r--nest/iface.c31
-rw-r--r--nest/iface.h6
-rw-r--r--nest/neighbor.c2
-rw-r--r--nest/rt-dev.c4
5 files changed, 24 insertions, 32 deletions
diff --git a/nest/config.Y b/nest/config.Y
index 4353db79..537a363c 100644
--- a/nest/config.Y
+++ b/nest/config.Y
@@ -30,7 +30,7 @@ iface_patt_check(void)
struct iface_patt_node *pn;
WALK_LIST(pn, this_ipatt->ipn_list)
- if (!pn->pattern || pn->pxlen)
+ if (!pn->pattern || pn->prefix.pxlen) /* XXXX */
cf_error("Interface name/mask expected, not IP prefix");
}
@@ -284,9 +284,8 @@ iface_patt_node_init:
;
iface_patt_node_body:
- TEXT { this_ipn->pattern = $1; this_ipn->prefix = IPA_NONE; this_ipn->pxlen = 0; }
- | prefix_or_ipa { this_ipn->pattern = NULL; this_ipn->prefix = $1.addr; this_ipn->pxlen = $1.len; }
- | TEXT prefix_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2.addr; this_ipn->pxlen = $2.len; }
+ TEXT { this_ipn->pattern = $1; net_fill_ip6(&this_ipn->prefix, IP6_NONE, 0); /* XXXX */ }
+ | opttext net_or_ipa { this_ipn->pattern = $1; this_ipn->prefix = $2.n; }
;
iface_negate:
@@ -479,11 +478,11 @@ r_args:
$$->prefix = $2.addr;
$$->pxlen = $2.len;
}
- | r_args FOR prefix_or_ipa {
+ | r_args FOR net_or_ipa {
$$ = $1;
if ($$->pxlen != 256) cf_error("Only one prefix expected");
- $$->prefix = $3.addr;
- $$->pxlen = $3.len;
+ $$->prefix = IPA_NONE; /* XXXX */
+ $$->pxlen = 0; /* XXXX */
$$->show_for = 1;
}
| r_args TABLE SYM {
diff --git a/nest/iface.c b/nest/iface.c
index 4d73c2a4..5d3c0e60 100644
--- a/nest/iface.c
+++ b/nest/iface.c
@@ -46,7 +46,7 @@ list iface_list;
void
ifa_dump(struct ifa *a)
{
- debug("\t%I, net %I/%-2d bc %I -> %I%s%s%s\n", a->ip, a->prefix, a->pxlen, a->brd, a->opposite,
+ debug("\t%I, net %N bc %I -> %I%s%s%s\n", a->ip, &a->prefix, a->brd, a->opposite,
(a->flags & IF_UP) ? "" : " DOWN",
(a->flags & IA_PRIMARY) ? "" : " SEC",
(a->flags & IA_PEER) ? "PEER" : "");
@@ -141,10 +141,9 @@ ifa_send_notify(struct proto *p, unsigned c, struct ifa *a)
if (p->ifa_notify)
{
if (p->debug & D_IFACES)
- log(L_TRACE "%s < %s address %I/%d on interface %s %s",
+ log(L_TRACE "%s < %s address %N on interface %s %s",
p->name, (a->flags & IA_PRIMARY) ? "primary" : "secondary",
- a->prefix, a->pxlen, a->iface->name,
- (c & IF_CHANGE_UP) ? "added" : "removed");
+ &a->prefix, a->iface->name, (c & IF_CHANGE_UP) ? "added" : "removed");
p->ifa_notify(p, c, a);
}
}
@@ -500,8 +499,7 @@ ifa_recalc_all_primary_addresses(void)
static inline int
ifa_same(struct ifa *a, struct ifa *b)
{
- return ipa_equal(a->ip, b->ip) && ipa_equal(a->prefix, b->prefix) &&
- a->pxlen == b->pxlen;
+ return ipa_equal(a->ip, b->ip) && net_equal(&a->prefix, &b->prefix);
}
@@ -586,7 +584,6 @@ ifa_delete(struct ifa *a)
u32
if_choose_router_id(struct iface_patt *mask, u32 old_id)
{
-#ifndef IPV6
struct iface *i;
struct ifa *a, *b;
@@ -599,6 +596,9 @@ if_choose_router_id(struct iface_patt *mask, u32 old_id)
WALK_LIST(a, i->addrs)
{
+ if (a->prefix.type != NET_IP4)
+ continue;
+
if (a->flags & IA_SECONDARY)
continue;
@@ -623,10 +623,6 @@ if_choose_router_id(struct iface_patt *mask, u32 old_id)
log(L_INFO "Chosen router ID %R according to interface %s", id, b->iface->name);
return id;
-
-#else
- return 0;
-#endif
}
/**
@@ -669,17 +665,17 @@ iface_patt_match(struct iface_patt *ifp, struct iface *i, struct ifa *a)
continue;
}
- if (p->pxlen == 0)
+ if (p->prefix.pxlen == 0)
return pos;
if (!a)
continue;
- if (ipa_in_net(a->ip, p->prefix, p->pxlen))
+ if (ipa_in_netX(a->ip, &p->prefix))
return pos;
if ((a->flags & IA_PEER) &&
- ipa_in_net(a->opposite, p->prefix, p->pxlen))
+ ipa_in_netX(a->opposite, &p->prefix))
return pos;
continue;
@@ -713,8 +709,7 @@ iface_plists_equal(struct iface_patt *pa, struct iface_patt *pb)
(!x->pattern && y->pattern) || /* This nasty lines where written by me... :-( Feela */
(!y->pattern && x->pattern) ||
((x->pattern != y->pattern) && strcmp(x->pattern, y->pattern)) ||
- !ipa_equal(x->prefix, y->prefix) ||
- (x->pxlen != y->pxlen))
+ !net_equal(&x->prefix, &y->prefix))
return 0;
x = (void *) x->n.next;
y = (void *) y->n.next;
@@ -754,7 +749,7 @@ if_show_addr(struct ifa *a)
else
opp[0] = 0;
cli_msg(-1003, "\t%I/%d (%s%s, scope %s)",
- a->ip, a->pxlen,
+ a->ip, a->prefix.pxlen,
(a->flags & IA_PRIMARY) ? "Primary" : (a->flags & IA_SECONDARY) ? "Secondary" : "Unselected",
opp, ip_scope_text(a->scope));
}
@@ -804,7 +799,7 @@ if_show_summary(void)
WALK_LIST(i, iface_list)
{
if (i->addr)
- bsprintf(addr, "%I/%d", i->addr->ip, i->addr->pxlen);
+ bsprintf(addr, "%I/%d", i->addr->ip, i->addr->prefix.pxlen);
else
addr[0] = 0;
cli_msg(-1005, "%-9s %-5s %s", i->name, (i->flags & IF_UP) ? "up" : "DOWN", addr);
diff --git a/nest/iface.h b/nest/iface.h
index 56710e4a..c4f414ec 100644
--- a/nest/iface.h
+++ b/nest/iface.h
@@ -19,9 +19,8 @@ struct pool;
struct ifa { /* Interface address */
node n;
struct iface *iface; /* Interface this address belongs to */
+ net_addr prefix; /* Network prefix */
ip_addr ip; /* IP address of this host */
- ip_addr prefix; /* Network prefix */
- unsigned pxlen; /* Prefix length */
ip_addr brd; /* Broadcast address */
ip_addr opposite; /* Opposite end of a point-to-point link */
unsigned scope; /* Interface address scope */
@@ -148,8 +147,7 @@ struct iface_patt_node {
node n;
int positive;
byte *pattern;
- ip_addr prefix;
- int pxlen;
+ net_addr prefix;
};
struct iface_patt {
diff --git a/nest/neighbor.c b/nest/neighbor.c
index 1685d67e..b8832f2f 100644
--- a/nest/neighbor.c
+++ b/nest/neighbor.c
@@ -79,7 +79,7 @@ if_connected(ip_addr *a, struct iface *i, struct ifa **ap)
}
else
{
- if (ipa_in_net(*a, b->prefix, b->pxlen))
+ if (ipa_in_netX(*a, &b->prefix))
{
#ifndef IPV6
if ((b->pxlen < (BITS_PER_IP_ADDRESS - 1)) &&
diff --git a/nest/rt-dev.c b/nest/rt-dev.c
index e8408116..f94933d5 100644
--- a/nest/rt-dev.c
+++ b/nest/rt-dev.c
@@ -45,7 +45,7 @@ dev_ifa_notify(struct proto *p, unsigned c, struct ifa *ad)
net *n;
DBG("dev_if_notify: %s:%I going down\n", ad->iface->name, ad->ip);
- n = net_find_ipa(p->table, ad->prefix, ad->pxlen);
+ n = net_find(p->table, &ad->prefix);
if (!n)
{
DBG("dev_if_notify: device shutdown: prefix not found\n");
@@ -77,7 +77,7 @@ dev_ifa_notify(struct proto *p, unsigned c, struct ifa *ad)
};
a = rta_lookup(&a0);
- n = net_get_ipa(p->table, ad->prefix, ad->pxlen);
+ n = net_get(p->table, &ad->prefix);
e = rte_get_temp(a);
e->net = n;
e->pflags = 0;