ripd: reduce excessive indentation in a few places

Make the code a bit easier to read. No binary changes.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
This commit is contained in:
Renato Westphal 2018-07-02 15:51:15 -03:00
parent 1dde2fbf78
commit 2e37ad7fd2

View File

@ -158,22 +158,21 @@ static void rip_request_interface_send(struct interface *ifp, uint8_t version)
for (ALL_LIST_ELEMENTS(ifp->connected, cnode, cnnode, for (ALL_LIST_ELEMENTS(ifp->connected, cnode, cnnode,
connected)) { connected)) {
if (connected->address->family == AF_INET) { if (connected->address->family != AF_INET)
continue;
memset(&to, 0, sizeof(struct sockaddr_in)); memset(&to, 0, sizeof(struct sockaddr_in));
to.sin_port = htons(RIP_PORT_DEFAULT); to.sin_port = htons(RIP_PORT_DEFAULT);
if (connected->destination) if (connected->destination)
/* use specified broadcast or peer /* use specified broadcast or peer
* destination addr */ * destination addr */
to.sin_addr = connected->destination->u to.sin_addr = connected->destination->u.prefix4;
.prefix4;
else if (connected->address->prefixlen else if (connected->address->prefixlen
< IPV4_MAX_PREFIXLEN) < IPV4_MAX_PREFIXLEN)
/* calculate the appropriate broadcast /* calculate the appropriate broadcast
* address */ * address */
to.sin_addr to.sin_addr.s_addr = ipv4_broadcast_addr(
.s_addr = ipv4_broadcast_addr( connected->address->u.prefix4.s_addr,
connected->address->u.prefix4
.s_addr,
connected->address->prefixlen); connected->address->prefixlen);
else else
/* do not know where to send the packet /* do not know where to send the packet
@ -187,13 +186,13 @@ static void rip_request_interface_send(struct interface *ifp, uint8_t version)
rip_request_send(&to, ifp, version, connected); rip_request_send(&to, ifp, version, connected);
} }
} }
}
} }
/* This will be executed when interface goes up. */ /* This will be executed when interface goes up. */
static void rip_request_interface(struct interface *ifp) static void rip_request_interface(struct interface *ifp)
{ {
struct rip_interface *ri; struct rip_interface *ri;
int vsend;
/* In default ripd doesn't send RIP_REQUEST to the loopback interface. /* In default ripd doesn't send RIP_REQUEST to the loopback interface.
*/ */
@ -209,14 +208,12 @@ static void rip_request_interface(struct interface *ifp)
/* If there is no version configuration in the interface, /* If there is no version configuration in the interface,
use rip's version setting. */ use rip's version setting. */
{ vsend = ((ri->ri_send == RI_RIP_UNSPEC) ? rip->version_send
int vsend = ((ri->ri_send == RI_RIP_UNSPEC) ? rip->version_send
: ri->ri_send); : ri->ri_send);
if (vsend & RIPv1) if (vsend & RIPv1)
rip_request_interface_send(ifp, RIPv1); rip_request_interface_send(ifp, RIPv1);
if (vsend & RIPv2) if (vsend & RIPv2)
rip_request_interface_send(ifp, RIPv2); rip_request_interface_send(ifp, RIPv2);
}
} }
#if 0 #if 0
@ -957,7 +954,6 @@ void rip_enable_apply(struct interface *ifp)
/* Update running status of the interface. */ /* Update running status of the interface. */
if (ri->enable_network || ri->enable_interface) { if (ri->enable_network || ri->enable_interface) {
{
if (IS_RIP_DEBUG_EVENT) if (IS_RIP_DEBUG_EVENT)
zlog_debug("turn on %s", ifp->name); zlog_debug("turn on %s", ifp->name);
@ -965,9 +961,7 @@ void rip_enable_apply(struct interface *ifp)
thread_add_timer(master, rip_interface_wakeup, ifp, 1, thread_add_timer(master, rip_interface_wakeup, ifp, 1,
&ri->t_wakeup); &ri->t_wakeup);
rip_connect_set(ifp, 1); rip_connect_set(ifp, 1);
} } else if (ri->running) {
} else {
if (ri->running) {
/* Might as well clean up the route table as well /* Might as well clean up the route table as well
* rip_if_down sets to 0 ri->running, and displays "turn * rip_if_down sets to 0 ri->running, and displays "turn
*off %s" *off %s"
@ -976,7 +970,6 @@ void rip_enable_apply(struct interface *ifp)
rip_connect_set(ifp, 0); rip_connect_set(ifp, 0);
} }
}
} }
/* Apply network configuration to all interface. */ /* Apply network configuration to all interface. */