diff options
author | paul <paul> | 2002-12-13 20:50:29 +0000 |
---|---|---|
committer | paul <paul> | 2002-12-13 20:50:29 +0000 |
commit | c48156e4cc9f760de5b9248fc9f5154fca13e0bc (patch) | |
tree | 5b6325d71cb52d381873ba430ea8e29fc10ec80f /lib/if.c | |
parent | 6bbcdcc38c625a1abcb9030b1de9c0e2b00edcd1 (diff) | |
download | quagga-patch.z15769.ripv1.tar.bz2 quagga-patch.z15769.ripv1.tar.xz |
Added RIPv1 patch - bug fixes and improved/more interoperable classfulpatch.z15769.ripv1
subnet handling
Diffstat (limited to 'lib/if.c')
-rw-r--r-- | lib/if.c | 59 |
1 files changed, 59 insertions, 0 deletions
@@ -553,6 +553,65 @@ connected_delete_by_prefix (struct interface *ifp, struct prefix *p) return NULL; } +/* Find the IPv4 address on our side that will be used when packets + are sent to dst. */ +struct connected * +connected_lookup_address (struct interface *ifp, struct in_addr dst) +{ + struct prefix addr; + struct prefix best; + listnode cnode; + struct prefix *p; + struct connected *c; + struct connected *match; + + /* Zero structures - get rid of rubbish from stack */ + memset(&addr, 0, sizeof(addr)); + memset(&best, 0, sizeof(best)); + + addr.family = AF_INET; + addr.u.prefix4 = dst; + addr.prefixlen = IPV4_MAX_BITLEN; + + match = NULL; + + for (cnode = listhead (ifp->connected); cnode; nextnode (cnode)) + { + c = getdata (cnode); + + if (if_is_pointopoint (ifp)) + { + p = c->address; + + if (p && p->family == AF_INET) + { +#ifdef OLD_RIB /* PTP links are conventionally identified + by the address of the far end - MAG */ + if (IPV4_ADDR_SAME (&p->u.prefix4, &dst)) + return c; +#endif + p = c->destination; + if (p && IPV4_ADDR_SAME (&p->u.prefix4, &dst)) + return c; + } + } + else + { + p = c->address; + + if (p->family == AF_INET) + { + if (prefix_match (p, &addr) && p->prefixlen > best.prefixlen) + { + best = *p; + match = c; + } + } + } + } + return match; +} + /* Check the connected information is PtP style or not. */ int ifc_pointopoint (struct connected *ifc) |