From 5821bfd478c66c04c8393e4964184d5444d5eab7 Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Fri, 8 Dec 2006 15:48:34 +0000 Subject: Cosmetics from FreeBSD. --- cpukit/libnetworking/net/route.c | 92 ++++++++++++++++----------------- cpukit/libnetworking/netinet/ip_input.c | 32 +++++------- cpukit/libnetworking/sys/domain.h | 12 ++--- 3 files changed, 62 insertions(+), 74 deletions(-) (limited to 'cpukit') diff --git a/cpukit/libnetworking/net/route.c b/cpukit/libnetworking/net/route.c index d80d659aeb..f6d2e23519 100644 --- a/cpukit/libnetworking/net/route.c +++ b/cpukit/libnetworking/net/route.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -64,14 +60,15 @@ struct radix_node_head *rt_tables[AF_MAX+1]; static int rttrash; /* routes not in table but not freed */ -static void rt_maskedcopy __P((struct sockaddr *, - struct sockaddr *, struct sockaddr *)); -static void rtable_init __P((struct radix_node_head **)); +static void rt_maskedcopy(struct sockaddr *, + struct sockaddr *, struct sockaddr *); +static void rtable_init(struct radix_node_head **); + +/* compare two sockaddr structures */ +#define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0) static void -rtable_init( - struct radix_node_head **table -) +rtable_init(struct radix_node_head **table) { struct domain *dom; for (dom = domains; dom; dom = dom->dom_next) @@ -81,7 +78,7 @@ rtable_init( } void -route_init() +route_init(void) { rn_init(); /* initialize all zeroes, all ones, mask table */ rtable_init(rt_tables); @@ -91,8 +88,7 @@ route_init() * Packet routing routines. */ void -rtalloc(ro) - register struct route *ro; +rtalloc(struct route *ro) { if (ro->ro_rt && ro->ro_rt->rt_ifp && (ro->ro_rt->rt_flags & RTF_UP)) return; /* XXX */ @@ -100,9 +96,7 @@ rtalloc(ro) } void -rtalloc_ign(ro, ignore) - register struct route *ro; - u_long ignore; +rtalloc_ign(struct route *ro, u_long ignore) { if (ro->ro_rt && ro->ro_rt->rt_ifp && (ro->ro_rt->rt_flags & RTF_UP)) return; /* XXX */ @@ -114,20 +108,19 @@ rtalloc_ign(ro, ignore) * Or, at least try.. Create a cloned route if needed. */ struct rtentry * -rtalloc1(dst, report, ignflags) - register struct sockaddr *dst; - int report; - u_long ignflags; +rtalloc1(struct sockaddr *dst, int report, u_long ignflags) { - register struct radix_node_head *rnh = rt_tables[dst->sa_family]; - register struct rtentry *rt; - register struct radix_node *rn; - struct rtentry *newrt = 0; + struct radix_node_head *rnh = rt_tables[dst->sa_family]; + struct rtentry *rt; + struct radix_node *rn; + struct rtentry *newrt; struct rt_addrinfo info; u_long nflags; - int s = splnet(), err = 0, msgtype = RTM_MISS; + int s = splnet(); + int err = 0, msgtype = RTM_MISS; - /* + newrt = NULL; + /* * Look up the address in the table for that Address Family */ if (rnh && (rn = rnh->rnh_matchaddr((caddr_t)dst, rnh)) && @@ -178,7 +171,7 @@ rtalloc1(dst, report, ignflags) * Authorities. * For a delete, this is not an error. (report == 0) */ - bzero((caddr_t)&info, sizeof(info)); + bzero(&info, sizeof(info)); info.rti_info[RTAX_DST] = dst; rt_missmsg(msgtype, &info, 0, err); } @@ -187,9 +180,12 @@ rtalloc1(dst, report, ignflags) return (newrt); } +/* + * Remove a reference count from an rtentry. + * If the count gets low enough, take it out of the routing table + */ void -rtfree(rt) - register struct rtentry *rt; +rtfree(struct rtentry *rt) { register struct radix_node_head *rnh = rt_tables[rt_key(rt)->sa_family]; @@ -241,19 +237,21 @@ ifafree(ifa) * */ void -rtredirect(dst, gateway, netmask, flags, src, rtp) - struct sockaddr *dst, *gateway, *netmask, *src; - int flags; - struct rtentry **rtp; +rtredirect(struct sockaddr *dst, + struct sockaddr *gateway, + struct sockaddr *netmask, + int flags, + struct sockaddr *src, + struct rtentry **rtp) { - register struct rtentry *rt; + struct rtentry *rt; int error = 0; - short *stat = 0; + short *stat = NULL; struct rt_addrinfo info; struct ifaddr *ifa; /* verify the gateway is directly reachable */ - if ((ifa = ifa_ifwithnet(gateway)) == 0) { + if ((ifa = ifa_ifwithnet(gateway)) == NULL) { error = ENETUNREACH; goto out; } @@ -320,7 +318,7 @@ out: rtstat.rts_badredirect++; else if (stat != NULL) (*stat)++; - bzero((caddr_t)&info, sizeof(info)); + bzero(&info, sizeof(info)); info.rti_info[RTAX_DST] = dst; info.rti_info[RTAX_GATEWAY] = gateway; info.rti_info[RTAX_NETMASK] = netmask; @@ -350,9 +348,7 @@ rtioctl(req, data, p) } struct ifaddr * -ifa_ifwithroute(flags, dst, gateway) - int flags; - struct sockaddr *dst, *gateway; +ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway) { register struct ifaddr *ifa; if ((flags & RTF_GATEWAY) == 0) { @@ -363,11 +359,11 @@ ifa_ifwithroute(flags, dst, gateway) * as our clue to the interface. Otherwise * we can use the local address. */ - ifa = 0; + ifa = NULL; if (flags & RTF_HOST) { ifa = ifa_ifwithdstaddr(dst); } - if (ifa == 0) + if (ifa == NULL) ifa = ifa_ifwithaddr(gateway); } else { /* @@ -411,10 +407,12 @@ struct rtfc_arg { * all the bits of info needed */ int -rtrequest(req, dst, gateway, netmask, flags, ret_nrt) - int req, flags; - struct sockaddr *dst, *gateway, *netmask; - struct rtentry **ret_nrt; +rtrequest(int req, + struct sockaddr *dst, + struct sockaddr *gateway, + struct sockaddr *netmask, + int flags, + struct rtentry **ret_nrt) { int s = splnet(); int error = 0; register struct rtentry *rt; @@ -809,7 +807,7 @@ rt_maskedcopy(src, dst, netmask) while (cp2 < cplim) *cp2++ = *cp1++ & *cp3++; if (cp2 < cplim2) - bzero((caddr_t)cp2, (unsigned)(cplim2 - cp2)); + bzero(cp2, (unsigned)(cplim2 - cp2)); } /* diff --git a/cpukit/libnetworking/netinet/ip_input.c b/cpukit/libnetworking/netinet/ip_input.c index f915fb7106..b6f95f7dc8 100644 --- a/cpukit/libnetworking/netinet/ip_input.c +++ b/cpukit/libnetworking/netinet/ip_input.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -230,9 +226,9 @@ static struct route ipforward_rt; void ip_input(struct mbuf *m) { - struct ip *ip; + struct ip *ip = NULL; struct ipq *fp; - struct in_ifaddr *ia; + struct in_ifaddr *ia = NULL; int i, hlen; u_short sum; @@ -257,7 +253,7 @@ ip_input(struct mbuf *m) #endif if (m->m_len < sizeof (struct ip) && - (m = m_pullup(m, sizeof (struct ip))) == 0) { + (m = m_pullup(m, sizeof (struct ip))) == NULL) { ipstat.ips_toosmall++; return; } @@ -274,7 +270,7 @@ ip_input(struct mbuf *m) goto bad; } if (hlen > m->m_len) { - if ((m = m_pullup(m, hlen)) == 0) { + if ((m = m_pullup(m, hlen)) == NULL) { ipstat.ips_badhlen++; return; } @@ -419,7 +415,7 @@ tooshort: ip->ip_id = ntohs(ip->ip_id); /* - * The process-level routing demon needs to receive + * The process-level routing daemon needs to receive * all multicast IGMP packets, whether or not this * host belongs to their destination groups. */ @@ -450,8 +446,9 @@ tooshort: if (ipforwarding == 0) { ipstat.ips_cantforward++; m_freem(m); - } else + } else { ip_forward(m, 0); + } return; ours: @@ -746,9 +743,8 @@ insert: #endif /* - * Create header for new ip packet by - * modifying header of first packet; - * dequeue and discard fragment reassembly header. + * Create header for new ip packet by modifying header of first + * packet; dequeue and discard fragment reassembly header. * Make header visible. */ ip = fp->ipq_next; @@ -1254,11 +1250,9 @@ u_char inetctlerrmap[PRC_NCMDS] = { * via a source route. */ static void -ip_forward(m, srcrt) - struct mbuf *m; - int srcrt; +ip_forward(struct mbuf *m, int srcrt) { - register struct ip *ip = mtod(m, struct ip *); + struct ip *ip = mtod(m, struct ip *); register struct sockaddr_in *sin; register struct rtentry *rt; int error, type = 0, code = 0; @@ -1454,10 +1448,10 @@ ip_rsvp_init(struct socket *so) { if (so->so_type != SOCK_RAW || so->so_proto->pr_protocol != IPPROTO_RSVP) - return EOPNOTSUPP; + return EOPNOTSUPP; if (ip_rsvpd != NULL) - return EADDRINUSE; + return EADDRINUSE; ip_rsvpd = so; /* diff --git a/cpukit/libnetworking/sys/domain.h b/cpukit/libnetworking/sys/domain.h index 54622018b2..d03ac2c269 100644 --- a/cpukit/libnetworking/sys/domain.h +++ b/cpukit/libnetworking/sys/domain.h @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -46,19 +42,19 @@ */ struct mbuf; -struct domain { +struct domain { int dom_family; /* AF_xxx */ char *dom_name; void (*dom_init) /* initialize domain data structures */ - __P((void)); + (void); int (*dom_externalize) /* externalize access rights */ __P((struct mbuf *)); void (*dom_dispose) /* dispose of internalized rights */ - __P((struct mbuf *)); + (struct mbuf *); struct protosw *dom_protosw, *dom_protoswNPROTOSW; struct domain *dom_next; int (*dom_rtattach) /* initialize routing table */ - __P((void **, int)); + (void **, int); int dom_rtoffset; /* an arg to rtattach, in bits */ int dom_maxrtkey; /* for routing layer */ }; -- cgit v1.2.3