diff options
author | paul <paul> | 2004-10-22 10:27:28 +0000 |
---|---|---|
committer | paul <paul> | 2004-10-22 10:27:28 +0000 |
commit | c49ad8f1b0775c1b35ea9bf75f44f3eca105d786 (patch) | |
tree | 6ec708b6c39ca83707395d656e74a52c2eed7ade /ripd/rip_interface.c | |
parent | 6b6942f93625c073db645a5546fbaaf7e7b2c628 (diff) |
2004-10-22 Paul Jakma <paul@dishone.st>
* ripd.c: Collapse redundant passing of various address structs,
struct interface and struct connected as arguments to functions
down to two key arguments, namely struct connected and, possibly,
address of source/destination. Testing for RIPv1 would be useful.
(rip_read) lookup struct connected for the received packet, pass
it on.
* rip_interface.c: With previous changes, we no longer have to tread
carefully with struct connected, as it will always be there and
valid.
Diffstat (limited to 'ripd/rip_interface.c')
-rw-r--r-- | ripd/rip_interface.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c index 19f6f114..c1c0a45a 100644 --- a/ripd/rip_interface.c +++ b/ripd/rip_interface.c @@ -145,19 +145,15 @@ rip_interface_multicast_set (int sock, struct connected *connected) struct sockaddr_in from; struct in_addr addr; struct prefix_ipv4 *p; - - if (connected != NULL) - { - if (if_is_pointopoint(connected->ifp) && CONNECTED_DEST_HOST(connected)) - p = (struct prefix_ipv4 *) connected->destination; - else - p = (struct prefix_ipv4 *) connected->address; - addr = p->prefix; - } - else - { - addr.s_addr = INADDR_ANY; - } + + assert (connected != NULL); + + if (if_is_pointopoint(connected->ifp) && CONNECTED_DEST_HOST(connected)) + p = (struct prefix_ipv4 *) connected->destination; + else + p = (struct prefix_ipv4 *) connected->address; + + addr = p->prefix; if (setsockopt_multicast_ipv4 (sock, IP_MULTICAST_IF, addr, 0, connected->ifp->ifindex) < 0) @@ -165,7 +161,7 @@ rip_interface_multicast_set (int sock, struct connected *connected) zlog_warn ("Can't setsockopt IP_MULTICAST_IF on fd %d to " "source address %s for interface %s", sock, inet_ntoa(addr), - (connected ? connected->ifp->name : "(unknown)")); + connected->ifp->name); return; } @@ -181,9 +177,7 @@ rip_interface_multicast_set (int sock, struct connected *connected) /* Address should be any address. */ from.sin_family = AF_INET; - if (connected) - addr = ((struct prefix_ipv4 *) connected->address)->prefix; - from.sin_addr = addr; + from.sin_addr = connected->address->u.prefix4; #ifdef HAVE_SIN_LEN from.sin_len = sizeof (struct sockaddr_in); #endif /* HAVE_SIN_LEN */ @@ -198,7 +192,7 @@ rip_interface_multicast_set (int sock, struct connected *connected) "interface %s: %s", sock,inet_ntoa(from.sin_addr), (int)ntohs(from.sin_port), - (connected ? connected->ifp->name : "(unknown)"), + connected->ifp->name, strerror (errno)); } |