diff options
author | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-12-07 19:26:47 +0000 |
---|---|---|
committer | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-12-07 19:26:47 +0000 |
commit | 999ce751ab929fe87f281d53968ebe214dcadb44 (patch) | |
tree | 8b5da0ca76f239bd4f5dd79aa5835c63e30f5172 /sys | |
parent | 566b90e5c8adffb551e4fb0cd2311984853bed60 (diff) |
KNF
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if.c | 49 | ||||
-rw-r--r-- | sys/net/if.h | 10 | ||||
-rw-r--r-- | sys/net/if_ethersubr.c | 55 |
3 files changed, 61 insertions, 53 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 19fd69a9994..b939426d910 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.95 2004/12/04 16:16:45 markus Exp $ */ +/* $OpenBSD: if.c,v 1.96 2004/12/07 19:26:46 mcbride Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -210,7 +210,7 @@ if_attachsetup(ifp) if (ifnet_addrs == 0 || ifindex2ifnet == 0 || if_index >= if_indexlim) { size_t m, n, oldlim; caddr_t q; - + oldlim = if_indexlim; if (if_indexlim == 0) if_indexlim = 8; @@ -393,7 +393,8 @@ if_attachhead(ifp) TAILQ_INIT(&ifg_head); } TAILQ_INIT(&ifp->if_addrlist); - ifp->if_addrhooks = malloc(sizeof(*ifp->if_addrhooks), M_TEMP, M_NOWAIT); + ifp->if_addrhooks = malloc(sizeof(*ifp->if_addrhooks), + M_TEMP, M_NOWAIT); if (ifp->if_addrhooks == NULL) panic("if_attachhead: malloc"); TAILQ_INIT(ifp->if_addrhooks); @@ -410,7 +411,8 @@ if_attach(ifp) TAILQ_INIT(&ifg_head); } TAILQ_INIT(&ifp->if_addrlist); - ifp->if_addrhooks = malloc(sizeof(*ifp->if_addrhooks), M_TEMP, M_NOWAIT); + ifp->if_addrhooks = malloc(sizeof(*ifp->if_addrhooks), + M_TEMP, M_NOWAIT); if (ifp->if_addrhooks == NULL) panic("if_attach: malloc"); TAILQ_INIT(ifp->if_addrhooks); @@ -647,7 +649,7 @@ if_detach_queues(ifp, q) m_freem(m); IF_DROP(q); } -} +} /* * Create a clone network interface. @@ -842,8 +844,9 @@ ifa_ifwithaddr(addr) struct ifnet *ifp; struct ifaddr *ifa; -#define equal(a1, a2) \ - (bcmp((caddr_t)(a1), (caddr_t)(a2), ((struct sockaddr *)(a1))->sa_len) == 0) +#define equal(a1, a2) \ + (bcmp((caddr_t)(a1), (caddr_t)(a2), \ + ((struct sockaddr *)(a1))->sa_len) == 0) TAILQ_FOREACH(ifp, &ifnet, if_list) { TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != addr->sa_family) @@ -872,7 +875,7 @@ ifa_ifwithdstaddr(addr) TAILQ_FOREACH(ifp, &ifnet, if_list) { if (ifp->if_flags & IFF_POINTOPOINT) - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != addr->sa_family || ifa->ifa_dstaddr == NULL) continue; @@ -1372,7 +1375,7 @@ ifioctl(so, cmd, data, p) splx(s); } #endif - } + } return (error); } @@ -1401,16 +1404,17 @@ ifconf(cmd, data) if (TAILQ_EMPTY(&ifp->if_addrlist)) space += sizeof (ifr); - else - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + else + TAILQ_FOREACH(ifa, + &ifp->if_addrlist, ifa_list) { sa = ifa->ifa_addr; #if defined(COMPAT_43) || defined(COMPAT_LINUX) || defined(COMPAT_SVR4) if (cmd != OSIOCGIFCONF) #endif if (sa->sa_len > sizeof(*sa)) space += sa->sa_len - - sizeof (*sa); - space += sizeof (ifr); + sizeof(*sa); + space += sizeof(ifr); } } ifc->ifc_len = space; @@ -1428,7 +1432,7 @@ ifconf(cmd, data) if (error) break; space -= sizeof (ifr), ifrp++; - } else + } else for (ifa = TAILQ_FIRST(&ifp->if_addrlist); space >= sizeof (ifr) && ifa != TAILQ_END(&ifp->if_addrlist); @@ -1440,22 +1444,23 @@ ifconf(cmd, data) (struct osockaddr *)&ifr.ifr_addr; ifr.ifr_addr = *sa; osa->sa_family = sa->sa_family; - error = copyout((caddr_t)&ifr, (caddr_t)ifrp, - sizeof (ifr)); + error = copyout((caddr_t)&ifr, + (caddr_t)ifrp, sizeof (ifr)); ifrp++; } else #endif if (sa->sa_len <= sizeof(*sa)) { ifr.ifr_addr = *sa; - error = copyout((caddr_t)&ifr, (caddr_t)ifrp, - sizeof (ifr)); + error = copyout((caddr_t)&ifr, + (caddr_t)ifrp, sizeof (ifr)); ifrp++; } else { space -= sa->sa_len - sizeof(*sa); if (space < sizeof (ifr)) break; - error = copyout((caddr_t)&ifr, (caddr_t)ifrp, - sizeof (ifr.ifr_name)); + error = copyout((caddr_t)&ifr, + (caddr_t)ifrp, + sizeof(ifr.ifr_name)); if (error == 0) error = copyout((caddr_t)sa, (caddr_t)&ifrp->ifr_addr, @@ -1599,7 +1604,7 @@ if_getgroup(caddr_t data, struct ifnet *ifp) return (EINVAL); strlcpy(ifgrq.ifgrq_group, ifgl->ifgl_group->ifg_group, sizeof(ifgrq.ifgrq_group)); - if ((error = copyout((caddr_t)&ifgrq, (caddr_t)ifgp, + if ((error = copyout((caddr_t)&ifgrq, (caddr_t)ifgp, sizeof(struct ifg_req)))) return (error); len -= sizeof(ifgrq); @@ -1609,7 +1614,7 @@ if_getgroup(caddr_t data, struct ifnet *ifp) return (0); } - + /* * Set/clear promiscuous mode on interface ifp based on the truth value * of pswitch. The calls are reference counted so that only the first diff --git a/sys/net/if.h b/sys/net/if.h index 8336e13e3c4..7c777339863 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.60 2004/12/03 17:31:03 henning Exp $ */ +/* $OpenBSD: if.h,v 1.61 2004/12/07 19:26:46 mcbride Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -519,13 +519,13 @@ struct if_laddrreq { struct if_nameindex { unsigned int if_index; - char *if_name; + char *if_name; }; #ifndef _KERNEL __BEGIN_DECLS unsigned int if_nametoindex(const char *); -char *if_indextoname(unsigned int, char *); +char *if_indextoname(unsigned int, char *); struct if_nameindex *if_nameindex(void); __END_DECLS #define if_freenameindex(x) free(x) @@ -649,7 +649,7 @@ int ether_ioctl(struct ifnet *, struct arpcom *, u_long, caddr_t); void ether_input_mbuf(struct ifnet *, struct mbuf *); void ether_input(struct ifnet *, struct ether_header *, struct mbuf *); int ether_output(struct ifnet *, - struct mbuf *, struct sockaddr *, struct rtentry *); + struct mbuf *, struct sockaddr *, struct rtentry *); char *ether_sprintf(u_char *); void if_alloc_sadl(struct ifnet *); @@ -693,7 +693,7 @@ void if_congestion(struct ifqueue *); int loioctl(struct ifnet *, u_long, caddr_t); void loopattach(int); int looutput(struct ifnet *, - struct mbuf *, struct sockaddr *, struct rtentry *); + struct mbuf *, struct sockaddr *, struct rtentry *); void lortrequest(int, struct rtentry *, struct rt_addrinfo *); #endif /* _KERNEL */ #endif /* _NET_IF_H_ */ diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index fa4feeaeef6..a10d0467d29 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.81 2004/11/28 23:39:45 canacar Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.82 2004/12/07 19:26:46 mcbride Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -164,7 +164,8 @@ extern u_char aarp_org_code[ 3 ]; #include <sys/socketvar.h> #endif -u_char etherbroadcastaddr[ETHER_ADDR_LEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; +u_char etherbroadcastaddr[ETHER_ADDR_LEN] = + { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; #define senderr(e) { error = (e); goto bad;} @@ -246,7 +247,7 @@ ether_output(ifp, m0, dst, rt0) { u_int16_t etype; int s, len, error = 0, hdrcmplt = 0; - u_char edst[ETHER_ADDR_LEN], esrc[ETHER_ADDR_LEN]; + u_char edst[ETHER_ADDR_LEN], esrc[ETHER_ADDR_LEN]; struct mbuf *m = m0; struct rtentry *rt; struct mbuf *mcopy = (struct mbuf *)0; @@ -302,8 +303,8 @@ ether_output(ifp, m0, dst, rt0) #ifdef NS case AF_NS: etype = htons(ETHERTYPE_NS); - bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host), - (caddr_t)edst, sizeof (edst)); + bcopy((caddr_t)&(((struct sockaddr_ns *)dst)->sns_addr.x_host), + (caddr_t)edst, sizeof(edst)); if (!bcmp((caddr_t)edst, (caddr_t)&ns_thishost, sizeof(edst))) return (looutput(ifp, m, dst, rt)); /* If broadcasting on a simplex interface, loopback a copy */ @@ -314,8 +315,8 @@ ether_output(ifp, m0, dst, rt0) #ifdef IPX case AF_IPX: etype = htons(ETHERTYPE_IPX); - bcopy((caddr_t)&satosipx(dst)->sipx_addr.ipx_host, - (caddr_t)edst, sizeof (edst)); + bcopy((caddr_t)&satosipx(dst)->sipx_addr.ipx_host, + (caddr_t)edst, sizeof(edst)); /* If broadcasting on a simplex interface, loopback a copy */ if ((m->m_flags & M_BCAST) && (ifp->if_flags & IFF_SIMPLEX)) mcopy = m_copy(m, 0, (int)M_COPYALL); @@ -333,7 +334,8 @@ ether_output(ifp, m0, dst, rt0) * If multicast dest., then use IPv6 -> Ethernet * mcast mapping. Really simple. */ - ETHER_MAP_IPV6_MULTICAST(&((struct sockaddr_in6 *)dst)->sin6_addr, + ETHER_MAP_IPV6_MULTICAST( + &((struct sockaddr_in6 *)dst)->sin6_addr, edst); } else { /* Do unicast neighbor discovery stuff. */ @@ -405,12 +407,12 @@ ether_output(ifp, m0, dst, rt0) } else goto bad; /* Not a link interface ? Funny ... */ if ((ifp->if_flags & IFF_SIMPLEX) && (*edst & 1) && (mcopy = m_copy(m, 0, (int)M_COPYALL))) { - M_PREPEND(mcopy, sizeof (*eh), M_DONTWAIT); + M_PREPEND(mcopy, sizeof(*eh), M_DONTWAIT); if (mcopy) { eh = mtod(mcopy, struct ether_header *); - bcopy(edst, eh->ether_dhost, sizeof (edst)); + bcopy(edst, eh->ether_dhost, sizeof(edst)); bcopy(ac->ac_enaddr, eh->ether_shost, - sizeof (edst)); + sizeof(edst)); } } etype = htons(m->m_pkthdr.len); @@ -423,8 +425,8 @@ ether_output(ifp, m0, dst, rt0) for (i=0; i < ETHER_ADDR_LEN; i++) printf("%x ", edst[i] & 0xff); printf(" len 0x%x dsap 0x%x ssap 0x%x control 0x%x\n", - m->m_pkthdr.len, l->llc_dsap & 0xff, l->llc_ssap &0xff, - l->llc_control & 0xff); + m->m_pkthdr.len, l->llc_dsap & 0xff, + l->llc_ssap &0xff, l->llc_control & 0xff); } #endif /* LLC_DEBUG */ @@ -433,12 +435,12 @@ ether_output(ifp, m0, dst, rt0) case pseudo_AF_HDRCMPLT: hdrcmplt = 1; eh = (struct ether_header *)dst->sa_data; - bcopy((caddr_t)eh->ether_shost, (caddr_t)esrc, sizeof (esrc)); + bcopy((caddr_t)eh->ether_shost, (caddr_t)esrc, sizeof(esrc)); /* FALLTHROUGH */ case AF_UNSPEC: eh = (struct ether_header *)dst->sa_data; - bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, sizeof (edst)); + bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, sizeof(edst)); /* AF_UNSPEC doesn't swap the byte order of the ether_type. */ etype = eh->ether_type; break; @@ -463,12 +465,12 @@ ether_output(ifp, m0, dst, rt0) eh = mtod(m, struct ether_header *); bcopy((caddr_t)&etype,(caddr_t)&eh->ether_type, sizeof(eh->ether_type)); - bcopy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof (edst)); + bcopy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof(edst)); if (hdrcmplt) - bcopy((caddr_t)esrc, (caddr_t)eh->ether_shost, + bcopy((caddr_t)esrc, (caddr_t)eh->ether_shost, sizeof(eh->ether_shost)); else - bcopy((caddr_t)ac->ac_enaddr, (caddr_t)eh->ether_shost, + bcopy((caddr_t)ac->ac_enaddr, (caddr_t)eh->ether_shost, sizeof(eh->ether_shost)); #if NBRIDGE > 0 @@ -594,7 +596,8 @@ ether_input(ifp, eh, m) struct sockaddr_dl *sdl = NULL; TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { - if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) && + if ((sdl = + (struct sockaddr_dl *)ifa->ifa_addr) && sdl->sdl_family == AF_LINK) break; } @@ -617,7 +620,7 @@ ether_input(ifp, eh, m) ifp->if_imcasts++; } - ifp->if_ibytes += m->m_pkthdr.len + sizeof (*eh); + ifp->if_ibytes += m->m_pkthdr.len + sizeof(*eh); etype = ntohs(eh->ether_type); @@ -646,7 +649,7 @@ ether_input(ifp, eh, m) if (vlan_input(eh, m) < 0) ifp->if_noproto++; return; - } + } #endif /* NVLAN > 0 */ #if NCARP > 0 @@ -744,11 +747,11 @@ decapsulate: M_PREPEND(m, sizeof(*eh), M_DONTWAIT); if (m == NULL) return; - + eh_tmp = mtod(m, struct ether_header *); bcopy(eh, eh_tmp, sizeof(struct ether_header)); - - if (etype == ETHERTYPE_PPPOEDISC) + + if (etype == ETHERTYPE_PPPOEDISC) inq = &ppoediscinq; else inq = &ppoeinq; @@ -802,7 +805,7 @@ decapsulate: m->m_data += 6; /* XXX */ m->m_len -= 6; /* XXX */ m->m_pkthdr.len -= 6; /* XXX */ - M_PREPEND(m, sizeof *eh, M_DONTWAIT); + M_PREPEND(m, sizeof(*eh), M_DONTWAIT); if (m == 0) return; *mtod(m, struct ether_header *) = *eh; @@ -886,7 +889,7 @@ ether_ifattach(ifp) */ ((struct arpcom *)ifp)->ac_enaddr[5] = (u_char)random() & 0xff; } - + ifp->if_type = IFT_ETHER; ifp->if_addrlen = ETHER_ADDR_LEN; ifp->if_hdrlen = ETHER_HDR_LEN; |