diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-05-11 18:52:30 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-05-12 10:03:44 -0400 |
| commit | bd40c341ee28aa73ffc1eee576a209366cf16271 (patch) | |
| tree | b990f22cfbb54baa1c0cf8761d1d74adde9d5dbb /lib/if.c | |
| parent | de69c4445d5bbce1ef0efa72437c2460dae02287 (diff) | |
lib: refactor connected_lookup_prefix
The connected_lookup_address function should really
be a connected_lookup_prefix function. Refactor
the code to use it.
Ticket: CM-10890
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Daniel Walton <dwalton@cumulusnetworks.com>
Diffstat (limited to 'lib/if.c')
| -rw-r--r-- | lib/if.c | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -1103,26 +1103,21 @@ 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 +/* Find the 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) +connected_lookup_prefix (struct interface *ifp, struct prefix *addr) { - struct prefix addr; struct listnode *cnode; struct connected *c; struct connected *match; - addr.family = AF_INET; - addr.u.prefix4 = dst; - addr.prefixlen = IPV4_MAX_BITLEN; - match = NULL; for (ALL_LIST_ELEMENTS_RO (ifp->connected, cnode, c)) { - if (c->address && (c->address->family == AF_INET) && - prefix_match(CONNECTED_PREFIX(c), &addr) && + if (c->address && (c->address->family == addr->family) && + prefix_match(CONNECTED_PREFIX(c), addr) && (!match || (c->address->prefixlen > match->address->prefixlen))) match = c; } |
