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;
}
struct prefix *);
extern struct connected *connected_delete_by_prefix (struct interface *,
struct prefix *);
-extern struct connected *connected_lookup_address (struct interface *,
- struct in_addr);
+extern struct connected *connected_lookup_prefix (struct interface *,
+ struct prefix *);
extern struct nbr_connected *nbr_connected_new (void);
extern void nbr_connected_free (struct nbr_connected *);
struct nbr_connected *nbr_connected_check (struct interface *, struct prefix *);
struct interface *ifp;
struct connected *ifc;
struct rip_interface *ri;
+ struct prefix p;
/* Fetch socket then register myself. */
sock = THREAD_FD (t);
inet_ntoa(from.sin_addr), ntohs (from.sin_port));
return -1;
}
-
- ifc = connected_lookup_address (ifp, from.sin_addr);
+
+ p.family = AF_INET;
+ p.u.prefix4 = from.sin_addr;
+ p.prefixlen = IPV4_MAX_BITLEN;
+
+ ifc = connected_lookup_prefix (ifp, &p);
if (ifc == NULL)
{
struct rip_interface *ri;
struct route_node *rp;
struct sockaddr_in to;
- struct prefix_ipv4 *p;
+ struct prefix *p;
/* Send RIP update to each interface. */
for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
for (rp = route_top (rip->neighbor); rp; rp = route_next (rp))
if (rp->info != NULL)
{
- p = (struct prefix_ipv4 *) &rp->p;
+ p = &rp->p;
- ifp = if_lookup_address ((void *)&p->prefix, AF_INET);
+ ifp = if_lookup_prefix (p);
if (! ifp)
{
zlog_warn ("Neighbor %s doesnt have connected interface!",
- inet_ntoa (p->prefix));
+ inet_ntoa (p->u.prefix4));
continue;
}
- if ( (connected = connected_lookup_address (ifp, p->prefix)) == NULL)
+ if ( (connected = connected_lookup_prefix (ifp, p)) == NULL)
{
zlog_warn ("Neighbor %s doesnt have connected network",
- inet_ntoa (p->prefix));
+ inet_ntoa (p->u.prefix4));
continue;
}
/* Set destination address and port */
memset (&to, 0, sizeof (struct sockaddr_in));
- to.sin_addr = p->prefix;
+ to.sin_addr = p->u.prefix4;
to.sin_port = htons (RIP_PORT_DEFAULT);
/* RIP version is rip's configuration. */