summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpaul <paul>2002-12-13 21:07:36 +0000
committerpaul <paul>2002-12-13 21:07:36 +0000
commit210b4dce34b39d96d68990c6461c9981e2d17630 (patch)
tree608a97278a06831ccbc1f9ce582f1bf4a27e6b39 /lib
parentb1189ba0a31d9b4bf4d446d44b22e590d92d5e89 (diff)
downloadquagga-patch.z14631.ptp.rfc3021.tar.bz2
quagga-patch.z14631.ptp.rfc3021.tar.xz
[zebra 14631] Generic PtP and RFC3021 interface addressing supportpatch.z14631.ptp.rfc3021
Diffstat (limited to 'lib')
-rw-r--r--lib/if.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/lib/if.c b/lib/if.c
index ce3595d3..e1a18393 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -189,11 +189,13 @@ if_lookup_address (struct in_addr src)
listnode node;
struct prefix addr;
struct prefix best;
+ struct prefix peer;
listnode cnode;
struct interface *ifp;
struct prefix *p;
struct connected *c;
struct interface *match;
+ int prefixlen;
/* Zero structures - get rid of rubbish from stack */
memset(&addr, 0, sizeof(addr));
@@ -212,34 +214,24 @@ if_lookup_address (struct in_addr src)
for (cnode = listhead (ifp->connected); cnode; nextnode (cnode))
{
c = getdata (cnode);
+ p = c->address;
- if (if_is_pointopoint (ifp))
+ if (p->family == AF_INET)
{
- p = c->address;
+ prefixlen = p->prefixlen;
- if (p && p->family == AF_INET)
+ if (if_is_pointopoint (ifp) ||
+ prefixlen >= IPV4_MAX_PREFIXLEN - 1)
{
-#ifdef OLD_RIB /* PTP links are conventionally identified
- by the address of the far end - MAG */
- if (IPV4_ADDR_SAME (&p->u.prefix4, &src))
- return ifp;
-#endif
- p = c->destination;
- if (p && IPV4_ADDR_SAME (&p->u.prefix4, &src))
- return ifp;
+ peer = *c->destination;
+ peer.prefixlen = prefixlen;
+ p = &peer;
}
- }
- else
- {
- p = c->address;
- if (p->family == AF_INET)
+ if (prefix_match (p, &addr) && prefixlen > best.prefixlen)
{
- if (prefix_match (p, &addr) && p->prefixlen > best.prefixlen)
- {
- best = *p;
- match = ifp;
- }
+ best = *p;
+ match = ifp;
}
}
}