From 6dbf51a41b12e983bfcae621ced0802c1850cf2e Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sun, 8 Apr 2012 21:19:02 +0200 Subject: [PATCH] IPXrouted(8): Re-indent some code to make the outer for() better visible. --- usr.sbin/IPXrouted/output.c | 156 +++++++++++++++++--------------- usr.sbin/IPXrouted/sap_output.c | 128 +++++++++++++------------- 2 files changed, 149 insertions(+), 135 deletions(-) diff --git a/usr.sbin/IPXrouted/output.c b/usr.sbin/IPXrouted/output.c index 7d7d32f99d..f119a4b8a1 100644 --- a/usr.sbin/IPXrouted/output.c +++ b/usr.sbin/IPXrouted/output.c @@ -36,7 +36,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/usr.sbin/IPXrouted/output.c,v 1.8 1999/08/28 01:15:03 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/output.c,v 1.3 2004/03/11 09:38:59 hmp Exp $ * * @(#)output.c 8.1 (Berkeley) 6/5/93 */ @@ -134,89 +133,100 @@ supply(struct sockaddr *dst, int flags, struct interface *ifp, sipx->sipx_port = htons(IPXPORT_RIP); msg->rip_cmd = ntohs(RIPCMD_RESPONSE); - for (rh = nethash; rh < &nethash[ROUTEHASHSIZ]; rh++) - for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; rt = rt->rt_forw) { - size = (char *)n - (char *)msg; - if (size >= ((MAXRIPNETS * sizeof (struct netinfo)) + + for (rh = nethash; rh < &nethash[ROUTEHASHSIZ]; rh++) { + for (rt = rh->rt_forw; rt != (struct rt_entry *)rh; + rt = rt->rt_forw) { + size = (char *)n - (char *)msg; + if (size >= ((MAXRIPNETS * sizeof (struct netinfo)) + sizeof (msg->rip_cmd))) { - (*output)(ripsock, flags, dst, size); - TRACE_OUTPUT(ifp, dst, size); - n = msg->rip_nets; - delay++; - if(delay == 2) { - usleep(50000); - delay = 0; + (*output)(ripsock, flags, dst, size); + TRACE_OUTPUT(ifp, dst, size); + n = msg->rip_nets; + delay++; + if(delay == 2) { + usleep(50000); + delay = 0; + } } - } - if (changesonly && !(rt->rt_state & RTS_CHANGED)) - continue; + if (changesonly && !(rt->rt_state & RTS_CHANGED)) + continue; - /* - * This should do rule one and two of the split horizon - * algorithm. - */ - if (rt->rt_ifp == ifp) - continue; + /* + * This should do rule one and two of the split horizon + * algorithm. + */ + if (rt->rt_ifp == ifp) + continue; - /* - * Rule 3. - * Look if we have clones (different routes to the same - * place with exactly the same cost). - * - * We should not publish on any of the clone interfaces. - */ - crt = rt->rt_clone; - while (crt) { - if (crt->rt_ifp == ifp) - goto next; - crt = crt->rt_clone; - } + /* + * Rule 3. + * Look if we have clones (different routes to the same + * place with exactly the same cost). + * + * We should not publish on any of the clone + * interfaces. + */ + crt = rt->rt_clone; + while (crt) { + if (crt->rt_ifp == ifp) + goto next; + crt = crt->rt_clone; + } - sipx = (struct sockaddr_ipx *)&rt->rt_dst; - if ((rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) == RTF_HOST) - sipx = (struct sockaddr_ipx *)&rt->rt_router; - if (rt->rt_metric == HOPCNT_INFINITY) - metric = HOPCNT_INFINITY; - else { - metric = rt->rt_metric + 1; + sipx = (struct sockaddr_ipx *)&rt->rt_dst; + if ((rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) == + RTF_HOST) + sipx = (struct sockaddr_ipx *)&rt->rt_router; + if (rt->rt_metric == HOPCNT_INFINITY) + metric = HOPCNT_INFINITY; + else { + metric = rt->rt_metric + 1; + /* + * We don't advertize routes with more than + * 15 hops. + */ + if (metric >= HOPCNT_INFINITY) + continue; + } /* - * We don't advertize routes with more than 15 hops. + * XXX One day we should cater for slow interfaces + * also. */ - if (metric >= HOPCNT_INFINITY) - continue; - } - /* XXX One day we should cater for slow interfaces also. */ - ticks = rt->rt_ticks + 1; - net = sipx->sipx_addr.x_net; + ticks = rt->rt_ticks + 1; + net = sipx->sipx_addr.x_net; - /* - * Make sure that we don't put out a two net entries - * for a pt to pt link (one for the G route, one for the if) - * This is a kludge, and won't work if there are lots of nets. - */ - for (nn = msg->rip_nets; nn < n; nn++) { - if (ipx_neteqnn(net, nn->rip_dst)) { - if (ticks < ntohs(nn->rip_ticks)) { - nn->rip_metric = htons(metric); - nn->rip_ticks = htons(ticks); - } else if ((ticks == ntohs(nn->rip_ticks)) && - (metric < ntohs(nn->rip_metric))) { - nn->rip_metric = htons(metric); - nn->rip_ticks = htons(ticks); + /* + * Make sure that we don't put out a two net entries + * for a pt to pt link (one for the G route, one for + * the if) + * This is a kludge, and won't work if there are lots + * of nets. + */ + for (nn = msg->rip_nets; nn < n; nn++) { + if (ipx_neteqnn(net, nn->rip_dst)) { + if (ticks < ntohs(nn->rip_ticks)) { + nn->rip_metric = htons(metric); + nn->rip_ticks = htons(ticks); + } else if ((ticks == ntohs(nn->rip_ticks)) && + (metric < ntohs(nn->rip_metric))) { + nn->rip_metric = htons(metric); + nn->rip_ticks = htons(ticks); + } + goto next; } - goto next; } + n->rip_dst = net; + n->rip_metric = htons(metric); + n->rip_ticks = htons(ticks); + n++; +next: + ; + } + if (n != msg->rip_nets) { + size = (char *)n - (char *)msg; + (*output)(ripsock, flags, dst, size); + TRACE_OUTPUT(ifp, dst, size); } - n->rip_dst = net; - n->rip_metric = htons(metric); - n->rip_ticks = htons(ticks); - n++; - next:; - } - if (n != msg->rip_nets) { - size = (char *)n - (char *)msg; - (*output)(ripsock, flags, dst, size); - TRACE_OUTPUT(ifp, dst, size); } } diff --git a/usr.sbin/IPXrouted/sap_output.c b/usr.sbin/IPXrouted/sap_output.c index 1e780ab415..93b3b74551 100644 --- a/usr.sbin/IPXrouted/sap_output.c +++ b/usr.sbin/IPXrouted/sap_output.c @@ -29,7 +29,6 @@ * SUCH DAMAGE. * * $FreeBSD: src/usr.sbin/IPXrouted/sap_output.c,v 1.9 1999/08/28 01:15:04 peter Exp $ - * $DragonFly: src/usr.sbin/IPXrouted/sap_output.c,v 1.4 2004/06/19 20:38:22 joerg Exp $ */ /* @@ -121,71 +120,76 @@ sap_supply(struct sockaddr *dst, int flags, struct interface *ifp, sap_msg->sap_cmd = ntohs(SAP_RESP); - for (sh = base; sh < &base[SAPHASHSIZ]; sh++) - for (sap = sh->forw; sap != (struct sap_entry *)sh; sap = sap->forw) { - size = (char *)n - (char *)sap_msg; - if (size >= ((MAXSAPENTRIES * sizeof (struct sap_info)) + - sizeof (sap_msg->sap_cmd))) { - (*output)(sapsock, flags, dst, size); - TRACE_SAP_OUTPUT(ifp, dst, size); - n = sap_msg->sap; - delay++; - if(delay == 2) { - usleep(50000); - delay = 0; + for (sh = base; sh < &base[SAPHASHSIZ]; sh++) { + for (sap = sh->forw; sap != (struct sap_entry *)sh; + sap = sap->forw) { + size = (char *)n - (char *)sap_msg; + if (size >= + ((MAXSAPENTRIES * sizeof (struct sap_info)) + + sizeof (sap_msg->sap_cmd))) { + (*output)(sapsock, flags, dst, size); + TRACE_SAP_OUTPUT(ifp, dst, size); + n = sap_msg->sap; + delay++; + if(delay == 2) { + usleep(50000); + delay = 0; + } } - } - - if (changesonly && !(sap->state & RTS_CHANGED)) - continue; - - /* - * Check for the servicetype except if the ServType is - * a wildcard (0xFFFF). - */ - if ((ServType != SAP_WILDCARD) && - (ServType != sap->sap.ServType)) - continue; - - /* - * This should do rule one and two of the split horizon - * algorithm. - */ - if (sap->ifp == ifp) - continue; - /* - * Rule 2. - * Look if we have clones (different routes to the same - * place with exactly the same cost). - * - * We should not publish on any of the clone interfaces. - */ - csap = sap->clone; - while (csap) { - if (csap->ifp == ifp) - goto next; - csap = csap->clone; - } - - /* - * Don't advertise services with more than 15 hops. It - * will be confused with a service that has gone down. - */ - if (ntohs(sap->sap.hops) == (HOPCNT_INFINITY - 1)) - continue; - metric = min(ntohs(sap->sap.hops) + 1, HOPCNT_INFINITY); + if (changesonly && !(sap->state & RTS_CHANGED)) + continue; + + /* + * Check for the servicetype except if the ServType is + * a wildcard (0xFFFF). + */ + if ((ServType != SAP_WILDCARD) && + (ServType != sap->sap.ServType)) + continue; + + /* + * This should do rule one and two of the split horizon + * algorithm. + */ + if (sap->ifp == ifp) + continue; + + /* + * Rule 2. + * Look if we have clones (different routes to the same + * place with exactly the same cost). + * + * We should not publish on any of the clone + * interfaces. + */ + csap = sap->clone; + while (csap) { + if (csap->ifp == ifp) + goto next; + csap = csap->clone; + } - *n = sap->sap; - n->hops = htons(metric); - n++; + /* + * Don't advertise services with more than 15 hops. It + * will be confused with a service that has gone down. + */ + if (ntohs(sap->sap.hops) == (HOPCNT_INFINITY - 1)) + continue; + metric = min(ntohs(sap->sap.hops) + 1, + HOPCNT_INFINITY); + + *n = sap->sap; + n->hops = htons(metric); + n++; next: - ; - } - if (n != sap_msg->sap) { - size = (char *)n - (char *)sap_msg; - (*output)(sapsock, flags, dst, size); - TRACE_SAP_OUTPUT(ifp, dst, size); + ; + } + if (n != sap_msg->sap) { + size = (char *)n - (char *)sap_msg; + (*output)(sapsock, flags, dst, size); + TRACE_SAP_OUTPUT(ifp, dst, size); + } } } -- 2.41.0