diff options
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/ethernet.h | 4 | ||||
-rw-r--r-- | sys/net/if.c | 2 | ||||
-rw-r--r-- | sys/net/if_arc.h | 2 | ||||
-rw-r--r-- | sys/net/if_arcsubr.c | 13 | ||||
-rw-r--r-- | sys/net/if_atm.h | 2 | ||||
-rw-r--r-- | sys/net/if_atmsubr.c | 6 | ||||
-rw-r--r-- | sys/net/if_dead.c | 2 | ||||
-rw-r--r-- | sys/net/if_disc.c | 15 | ||||
-rw-r--r-- | sys/net/if_ef.c | 8 | ||||
-rw-r--r-- | sys/net/if_enc.c | 4 | ||||
-rw-r--r-- | sys/net/if_ethersubr.c | 21 | ||||
-rw-r--r-- | sys/net/if_faith.c | 23 | ||||
-rw-r--r-- | sys/net/if_fddisubr.c | 31 | ||||
-rw-r--r-- | sys/net/if_fwsubr.c | 2 | ||||
-rw-r--r-- | sys/net/if_gif.c | 14 | ||||
-rw-r--r-- | sys/net/if_gif.h | 2 | ||||
-rw-r--r-- | sys/net/if_gre.c | 20 | ||||
-rw-r--r-- | sys/net/if_iso88025subr.c | 18 | ||||
-rw-r--r-- | sys/net/if_lagg.c | 4 | ||||
-rw-r--r-- | sys/net/if_lagg.h | 4 | ||||
-rw-r--r-- | sys/net/if_loop.c | 16 | ||||
-rw-r--r-- | sys/net/if_spppsubr.c | 6 | ||||
-rw-r--r-- | sys/net/if_stf.c | 29 | ||||
-rw-r--r-- | sys/net/if_tun.c | 20 | ||||
-rw-r--r-- | sys/net/if_var.h | 2 | ||||
-rw-r--r-- | sys/net/iso88025.h | 4 |
26 files changed, 124 insertions, 150 deletions
diff --git a/sys/net/ethernet.h b/sys/net/ethernet.h index ae7341e..10abf64 100644 --- a/sys/net/ethernet.h +++ b/sys/net/ethernet.h @@ -375,8 +375,8 @@ extern void ether_demux(struct ifnet *, struct mbuf *); extern void ether_ifattach(struct ifnet *, const u_int8_t *); extern void ether_ifdetach(struct ifnet *); extern int ether_ioctl(struct ifnet *, u_long, caddr_t); -extern int ether_output(struct ifnet *, - struct mbuf *, struct sockaddr *, struct route *); +extern int ether_output(struct ifnet *, struct mbuf *, + const struct sockaddr *, struct route *); extern int ether_output_frame(struct ifnet *, struct mbuf *); extern char *ether_sprintf(const u_int8_t *); void ether_vlan_mtap(struct bpf_if *, struct mbuf *, diff --git a/sys/net/if.c b/sys/net/if.c index 712cd13..39dc941 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -134,7 +134,7 @@ int (*carp_master_p)(struct ifaddr *); #if defined(INET) || defined(INET6) int (*carp_forus_p)(struct ifnet *ifp, u_char *dhost); int (*carp_output_p)(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *sa); + const struct sockaddr *sa); int (*carp_ioctl_p)(struct ifreq *, u_long, struct thread *); int (*carp_attach_p)(struct ifaddr *, int); void (*carp_detach_p)(struct ifaddr *); diff --git a/sys/net/if_arc.h b/sys/net/if_arc.h index 88a7240..23139aa 100644 --- a/sys/net/if_arc.h +++ b/sys/net/if_arc.h @@ -133,7 +133,7 @@ void arc_storelladdr(struct ifnet *, u_int8_t); int arc_isphds(u_int8_t); void arc_input(struct ifnet *, struct mbuf *); int arc_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct route *); + const struct sockaddr *, struct route *); int arc_ioctl(struct ifnet *, u_long, caddr_t); void arc_frag_init(struct ifnet *); diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index 0371df7..2f94785 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -92,8 +92,8 @@ u_int8_t arcbroadcastaddr = 0; #define ARC_LLADDR(ifp) (*(u_int8_t *)IF_LLADDR(ifp)) #define senderr(e) { error = (e); goto bad;} -#define SIN(s) ((struct sockaddr_in *)s) -#define SIPX(s) ((struct sockaddr_ipx *)s) +#define SIN(s) ((const struct sockaddr_in *)(s)) +#define SIPX(s) ((const struct sockaddr_ipx *)(s)) /* * ARCnet output routine. @@ -101,7 +101,7 @@ u_int8_t arcbroadcastaddr = 0; * Assumes that ifp is actually pointer to arccom structure. */ int -arc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, +arc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro) { struct arc_header *ah; @@ -186,8 +186,11 @@ arc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, #endif case AF_UNSPEC: + { + const struct arc_header *ah; + loop_copy = -1; - ah = (struct arc_header *)dst->sa_data; + ah = (const struct arc_header *)dst->sa_data; adst = ah->arc_dhost; atype = ah->arc_type; @@ -207,7 +210,7 @@ arc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, #endif } break; - + } default: if_printf(ifp, "can't handle af%d\n", dst->sa_family); senderr(EAFNOSUPPORT); diff --git a/sys/net/if_atm.h b/sys/net/if_atm.h index e8f69da..c669c3d 100644 --- a/sys/net/if_atm.h +++ b/sys/net/if_atm.h @@ -292,7 +292,7 @@ void atm_ifattach(struct ifnet *); void atm_ifdetach(struct ifnet *); void atm_input(struct ifnet *, struct atm_pseudohdr *, struct mbuf *, void *); -int atm_output(struct ifnet *, struct mbuf *, struct sockaddr *, +int atm_output(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); struct atmio_vcctable *atm_getvccs(struct atmio_vcc **, u_int, u_int, struct mtx *, int); diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index fdb8931..d6190ec 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -121,7 +121,7 @@ static MALLOC_DEFINE(M_IFATM, "ifatm", "atm interface internals"); * ro->ro_rt must also be NULL. */ int -atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, +atm_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, struct route *ro) { u_int16_t etype = 0; /* if using LLC/SNAP */ @@ -129,7 +129,7 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, struct atm_pseudohdr atmdst, *ad; struct mbuf *m = m0; struct atmllc *atmllc; - struct atmllc *llc_hdr = NULL; + const struct atmllc *llc_hdr = NULL; u_int32_t atm_flags; #ifdef MAC @@ -173,7 +173,7 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, * (atm pseudo header (4) + LLC/SNAP (8)) */ bcopy(dst->sa_data, &atmdst, sizeof(atmdst)); - llc_hdr = (struct atmllc *)(dst->sa_data + + llc_hdr = (const struct atmllc *)(dst->sa_data + sizeof(atmdst)); break; diff --git a/sys/net/if_dead.c b/sys/net/if_dead.c index 7c941d8..cd6dff3 100644 --- a/sys/net/if_dead.c +++ b/sys/net/if_dead.c @@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$"); #include <net/if_var.h> static int -ifdead_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *sa, +ifdead_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *sa, struct route *ro) { diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c index f2f902e..16a1e7b 100644 --- a/sys/net/if_disc.c +++ b/sys/net/if_disc.c @@ -64,7 +64,7 @@ struct disc_softc { }; static int discoutput(struct ifnet *, struct mbuf *, - struct sockaddr *, struct route *); + const struct sockaddr *, struct route *); static void discrtrequest(int, struct rtentry *, struct rt_addrinfo *); static int discioctl(struct ifnet *, u_long, caddr_t); static int disc_clone_create(struct if_clone *, int, caddr_t); @@ -155,7 +155,7 @@ static moduledata_t disc_mod = { DECLARE_MODULE(if_disc, disc_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); static int -discoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, +discoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro) { u_int32_t af; @@ -163,15 +163,14 @@ discoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, M_ASSERTPKTHDR(m); /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) { + if (dst->sa_family == AF_UNSPEC) bcopy(dst->sa_data, &af, sizeof(af)); - dst->sa_family = af; - } + else + af = dst->sa_family; - if (bpf_peers_present(ifp->if_bpf)) { - u_int af = dst->sa_family; + if (bpf_peers_present(ifp->if_bpf)) bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m); - } + m->m_pkthdr.rcvif = ifp; ifp->if_opackets++; diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c index 9433793..fc6402c 100644 --- a/sys/net/if_ef.c +++ b/sys/net/if_ef.c @@ -102,7 +102,7 @@ static int efcount; extern int (*ef_inputp)(struct ifnet*, struct ether_header *eh, struct mbuf *m); extern int (*ef_outputp)(struct ifnet *ifp, struct mbuf **mp, - struct sockaddr *dst, short *tp, int *hlen); + const struct sockaddr *dst, short *tp, int *hlen); /* static void ef_reset (struct ifnet *); @@ -114,7 +114,7 @@ static int ef_ioctl(struct ifnet *, u_long, caddr_t); static void ef_start(struct ifnet *); static int ef_input(struct ifnet*, struct ether_header *, struct mbuf *); static int ef_output(struct ifnet *ifp, struct mbuf **mp, - struct sockaddr *dst, short *tp, int *hlen); + const struct sockaddr *dst, short *tp, int *hlen); static int ef_load(void); static int ef_unload(void); @@ -386,8 +386,8 @@ ef_input(struct ifnet *ifp, struct ether_header *eh, struct mbuf *m) } static int -ef_output(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst, short *tp, - int *hlen) +ef_output(struct ifnet *ifp, struct mbuf **mp, const struct sockaddr *dst, + short *tp, int *hlen) { struct efnet *sc = (struct efnet*)ifp->if_softc; struct mbuf *m = *mp; diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c index ecc2415..e49f40c 100644 --- a/sys/net/if_enc.c +++ b/sys/net/if_enc.c @@ -88,7 +88,7 @@ struct enc_softc { static int enc_ioctl(struct ifnet *, u_long, caddr_t); static int enc_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct route *ro); + const struct sockaddr *dst, struct route *ro); static int enc_clone_create(struct if_clone *, int, caddr_t); static void enc_clone_destroy(struct ifnet *); static struct if_clone *enc_cloner; @@ -188,7 +188,7 @@ static moduledata_t enc_mod = { DECLARE_MODULE(if_enc, enc_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); static int -enc_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, +enc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro) { m_freem(m); diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index bb4029e..6a42214 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -83,7 +83,7 @@ int (*ef_inputp)(struct ifnet*, struct ether_header *eh, struct mbuf *m); int (*ef_outputp)(struct ifnet *ifp, struct mbuf **mp, - struct sockaddr *dst, short *tp, int *hlen); + const struct sockaddr *dst, short *tp, int *hlen); #ifdef NETATALK #include <netatalk/at.h> @@ -149,7 +149,7 @@ static MALLOC_DEFINE(M_ARPCOM, "arpcom", "802.* interface internals"); */ int ether_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct route *ro) + const struct sockaddr *dst, struct route *ro) { short type; int error = 0, hdrcmplt = 0; @@ -238,8 +238,8 @@ ether_output(struct ifnet *ifp, struct mbuf *m, goto bad; } else type = htons(ETHERTYPE_IPX); - bcopy((caddr_t)&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host), - (caddr_t)edst, sizeof (edst)); + bcopy(&((const struct sockaddr_ipx *)dst)->sipx_addr.x_host, + edst, sizeof (edst)); break; #endif #ifdef NETATALK @@ -247,9 +247,9 @@ ether_output(struct ifnet *ifp, struct mbuf *m, { struct at_ifaddr *aa; - if ((aa = at_ifawithnet((struct sockaddr_at *)dst)) == NULL) + if ((aa = at_ifawithnet((const struct sockaddr_at *)dst)) == NULL) senderr(EHOSTUNREACH); /* XXX */ - if (!aarpresolve(ifp, m, (struct sockaddr_at *)dst, edst)) { + if (!aarpresolve(ifp, m, (const struct sockaddr_at *)dst, edst)) { ifa_free(&aa->aa_ifa); return (0); } @@ -279,18 +279,21 @@ ether_output(struct ifnet *ifp, struct mbuf *m, #endif /* NETATALK */ case pseudo_AF_HDRCMPLT: + { + const struct ether_header *eh; + hdrcmplt = 1; - eh = (struct ether_header *)dst->sa_data; + eh = (const struct ether_header *)dst->sa_data; (void)memcpy(esrc, eh->ether_shost, sizeof (esrc)); /* FALLTHROUGH */ case AF_UNSPEC: loop_copy = 0; /* if this is for us, don't do it */ - eh = (struct ether_header *)dst->sa_data; + eh = (const struct ether_header *)dst->sa_data; (void)memcpy(edst, eh->ether_dhost, sizeof (edst)); type = eh->ether_type; break; - + } default: if_printf(ifp, "can't handle af%d\n", dst->sa_family); senderr(EAFNOSUPPORT); diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c index 907dcce..37a53bb 100644 --- a/sys/net/if_faith.c +++ b/sys/net/if_faith.c @@ -84,7 +84,7 @@ struct faith_softc { }; static int faithioctl(struct ifnet *, u_long, caddr_t); -int faithoutput(struct ifnet *, struct mbuf *, struct sockaddr *, +static int faithoutput(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); static void faithrtrequest(int, struct rtentry *, struct rt_addrinfo *); #ifdef INET6 @@ -184,12 +184,9 @@ faith_clone_destroy(ifp) free(sc, M_FAITH); } -int -faithoutput(ifp, m, dst, ro) - struct ifnet *ifp; - struct mbuf *m; - struct sockaddr *dst; - struct route *ro; +static int +faithoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, + struct route *ro) { int isr; u_int32_t af; @@ -200,15 +197,13 @@ faithoutput(ifp, m, dst, ro) if (ro != NULL) rt = ro->ro_rt; /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) { + if (dst->sa_family == AF_UNSPEC) bcopy(dst->sa_data, &af, sizeof(af)); - dst->sa_family = af; - } - - if (bpf_peers_present(ifp->if_bpf)) { + else af = dst->sa_family; + + if (bpf_peers_present(ifp->if_bpf)) bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m); - } if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { m_freem(m); @@ -217,7 +212,7 @@ faithoutput(ifp, m, dst, ro) } ifp->if_opackets++; ifp->if_obytes += m->m_pkthdr.len; - switch (dst->sa_family) { + switch (af) { #ifdef INET case AF_INET: isr = NETISR_IP; diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 57fb27d..5e7dbe6 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -96,7 +96,7 @@ static const u_char fddibroadcastaddr[FDDI_ADDR_LEN] = static int fddi_resolvemulti(struct ifnet *, struct sockaddr **, struct sockaddr *); -static int fddi_output(struct ifnet *, struct mbuf *, struct sockaddr *, +static int fddi_output(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); static void fddi_input(struct ifnet *ifp, struct mbuf *m); @@ -110,11 +110,8 @@ static void fddi_input(struct ifnet *ifp, struct mbuf *m); * Assumes that ifp is actually pointer to arpcom structure. */ static int -fddi_output(ifp, m, dst, ro) - struct ifnet *ifp; - struct mbuf *m; - struct sockaddr *dst; - struct route *ro; +fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, + struct route *ro) { u_int16_t type; int loop_copy = 0, error = 0, hdrcmplt = 0; @@ -189,19 +186,19 @@ fddi_output(ifp, m, dst, ro) #ifdef IPX case AF_IPX: type = htons(ETHERTYPE_IPX); - bcopy((caddr_t)&(((struct sockaddr_ipx *)dst)->sipx_addr.x_host), - (caddr_t)edst, FDDI_ADDR_LEN); + bcopy(&((const struct sockaddr_ipx *)dst)->sipx_addr.x_host, + edst, FDDI_ADDR_LEN); break; #endif /* IPX */ #ifdef NETATALK case AF_APPLETALK: { struct at_ifaddr *aa; - if (!aarpresolve(ifp, m, (struct sockaddr_at *)dst, edst)) + if (!aarpresolve(ifp, m, (const struct sockaddr_at *)dst, edst)) return (0); /* * ifaddr is the first thing in at_ifaddr */ - if ((aa = at_ifawithnet( (struct sockaddr_at *)dst)) == 0) + if ((aa = at_ifawithnet((const struct sockaddr_at *)dst)) == 0) goto bad; /* @@ -229,19 +226,21 @@ fddi_output(ifp, m, dst, ro) case pseudo_AF_HDRCMPLT: { - struct ether_header *eh; + const struct ether_header *eh; + hdrcmplt = 1; - eh = (struct ether_header *)dst->sa_data; - bcopy((caddr_t)eh->ether_shost, (caddr_t)esrc, FDDI_ADDR_LEN); + eh = (const struct ether_header *)dst->sa_data; + bcopy(eh->ether_shost, esrc, FDDI_ADDR_LEN); /* FALLTHROUGH */ } case AF_UNSPEC: { - struct ether_header *eh; + const struct ether_header *eh; + loop_copy = -1; - eh = (struct ether_header *)dst->sa_data; - bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, FDDI_ADDR_LEN); + eh = (const struct ether_header *)dst->sa_data; + bcopy(eh->ether_dhost, edst, FDDI_ADDR_LEN); if (*edst & 1) m->m_flags |= (M_BCAST|M_MCAST); type = eh->ether_type; diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c index e1d5c01..31fc2a9 100644 --- a/sys/net/if_fwsubr.c +++ b/sys/net/if_fwsubr.c @@ -75,7 +75,7 @@ struct fw_hwaddr firewire_broadcastaddr = { }; static int -firewire_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, +firewire_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro) { struct fw_com *fc = IFP2FWC(ifp); diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index 9fef6c7..2a6f890 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -422,11 +422,8 @@ gif_start(struct ifnet *ifp) } int -gif_output(ifp, m, dst, ro) - struct ifnet *ifp; - struct mbuf *m; - struct sockaddr *dst; - struct route *ro; +gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, + struct route *ro) { struct gif_softc *sc = ifp->if_softc; struct m_tag *mtag; @@ -482,11 +479,10 @@ gif_output(ifp, m, dst, ro) m->m_flags &= ~(M_BCAST|M_MCAST); /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) { + if (dst->sa_family == AF_UNSPEC) bcopy(dst->sa_data, &af, sizeof(af)); - dst->sa_family = af; - } - af = dst->sa_family; + else + af = dst->sa_family; /* * Now save the af in the inbound pkt csum * data, this is a cheat since we are using diff --git a/sys/net/if_gif.h b/sys/net/if_gif.h index 5d0db6d..d6e58f5 100644 --- a/sys/net/if_gif.h +++ b/sys/net/if_gif.h @@ -112,7 +112,7 @@ struct etherip_header { /* Prototypes */ void gif_input(struct mbuf *, int, struct ifnet *); -int gif_output(struct ifnet *, struct mbuf *, struct sockaddr *, +int gif_output(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); int gif_ioctl(struct ifnet *, u_long, caddr_t); int gif_set_tunnel(struct ifnet *, struct sockaddr *, struct sockaddr *); diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 48255b0..3d33766 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -113,8 +113,8 @@ static void gre_clone_destroy(struct ifnet *); static struct if_clone *gre_cloner; static int gre_ioctl(struct ifnet *, u_long, caddr_t); -static int gre_output(struct ifnet *, struct mbuf *, struct sockaddr *, - struct route *ro); +static int gre_output(struct ifnet *, struct mbuf *, + const struct sockaddr *, struct route *); static int gre_compute_route(struct gre_softc *sc); @@ -241,7 +241,7 @@ gre_clone_destroy(ifp) * given by sc->g_proto. See also RFC 1701 and RFC 2004 */ static int -gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, +gre_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro) { int error = 0; @@ -333,20 +333,18 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, ip = NULL; /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) { + if (dst->sa_family == AF_UNSPEC) bcopy(dst->sa_data, &af, sizeof(af)); - dst->sa_family = af; - } - - if (bpf_peers_present(ifp->if_bpf)) { + else af = dst->sa_family; + + if (bpf_peers_present(ifp->if_bpf)) bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m); - } m->m_flags &= ~(M_BCAST|M_MCAST); if (sc->g_proto == IPPROTO_MOBILE) { - if (dst->sa_family == AF_INET) { + if (af == AF_INET) { struct mbuf *m0; int msiz; @@ -417,7 +415,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, goto end; } } else if (sc->g_proto == IPPROTO_GRE) { - switch (dst->sa_family) { + switch (af) { case AF_INET: ip = mtod(m, struct ip *); gre_ip_tos = ip->ip_tos; diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c index 7f9e8bd..63b2107 100644 --- a/sys/net/if_iso88025subr.c +++ b/sys/net/if_iso88025subr.c @@ -231,11 +231,8 @@ iso88025_ioctl(struct ifnet *ifp, u_long command, caddr_t data) * ISO88025 encapsulation */ int -iso88025_output(ifp, m, dst, ro) - struct ifnet *ifp; - struct mbuf *m; - struct sockaddr *dst; - struct route *ro; +iso88025_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, + struct route *ro) { u_int16_t snap_type = 0; int loop_copy = 0, error = 0, rif_len = 0; @@ -351,7 +348,7 @@ iso88025_output(ifp, m, dst, ro) #endif /* IPX */ case AF_UNSPEC: { - struct iso88025_sockaddr_data *sd; + const struct iso88025_sockaddr_data *sd; /* * For AF_UNSPEC sockaddr.sa_data must contain all of the * mac information needed to send the packet. This allows @@ -361,13 +358,12 @@ iso88025_output(ifp, m, dst, ro) * should be an iso88025_sockaddr_data structure see iso88025.h */ loop_copy = -1; - sd = (struct iso88025_sockaddr_data *)dst->sa_data; + sd = (const struct iso88025_sockaddr_data *)dst->sa_data; gen_th.ac = sd->ac; gen_th.fc = sd->fc; - (void)memcpy((caddr_t)edst, (caddr_t)sd->ether_dhost, - ISO88025_ADDR_LEN); - (void)memcpy((caddr_t)gen_th.iso88025_shost, - (caddr_t)sd->ether_shost, ISO88025_ADDR_LEN); + (void)memcpy(edst, sd->ether_dhost, ISO88025_ADDR_LEN); + (void)memcpy(gen_th.iso88025_shost, sd->ether_shost, + ISO88025_ADDR_LEN); rif_len = 0; break; } diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 0f5ca0d..5688b76 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -99,7 +99,7 @@ static void lagg_linkstate(struct lagg_softc *); static void lagg_port_state(struct ifnet *, int); static int lagg_port_ioctl(struct ifnet *, u_long, caddr_t); static int lagg_port_output(struct ifnet *, struct mbuf *, - struct sockaddr *, struct route *); + const struct sockaddr *, struct route *); static void lagg_port_ifdetach(void *arg __unused, struct ifnet *); #ifdef LAGG_PORT_STACKING static int lagg_port_checkstacking(struct lagg_softc *); @@ -787,7 +787,7 @@ fallback: */ static int lagg_port_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct route *ro) + const struct sockaddr *dst, struct route *ro) { struct lagg_port *lp = ifp->if_lagg; diff --git a/sys/net/if_lagg.h b/sys/net/if_lagg.h index 7170128..fe3365b 100644 --- a/sys/net/if_lagg.h +++ b/sys/net/if_lagg.h @@ -245,8 +245,8 @@ struct lagg_port { /* Redirected callbacks */ int (*lp_ioctl)(struct ifnet *, u_long, caddr_t); - int (*lp_output)(struct ifnet *, struct mbuf *, struct sockaddr *, - struct route *); + int (*lp_output)(struct ifnet *, struct mbuf *, + const struct sockaddr *, struct route *); SLIST_ENTRY(lagg_port) lp_entries; }; diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index acf8012..499cd2c 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -101,7 +101,7 @@ int loioctl(struct ifnet *, u_long, caddr_t); static void lortrequest(int, struct rtentry *, struct rt_addrinfo *); int looutput(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct route *ro); + const struct sockaddr *dst, struct route *ro); static int lo_clone_create(struct if_clone *, int, caddr_t); static void lo_clone_destroy(struct ifnet *); @@ -210,7 +210,7 @@ static moduledata_t loop_mod = { DECLARE_MODULE(if_lo, loop_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); int -looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, +looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro) { u_int32_t af; @@ -241,13 +241,13 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, ifp->if_obytes += m->m_pkthdr.len; /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) { + if (dst->sa_family == AF_UNSPEC) bcopy(dst->sa_data, &af, sizeof(af)); - dst->sa_family = af; - } + else + af = dst->sa_family; #if 1 /* XXX */ - switch (dst->sa_family) { + switch (af) { case AF_INET: if (ifp->if_capenable & IFCAP_RXCSUM) { m->m_pkthdr.csum_data = 0xffff; @@ -276,12 +276,12 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, case AF_APPLETALK: break; default: - printf("looutput: af=%d unexpected\n", dst->sa_family); + printf("looutput: af=%d unexpected\n", af); m_freem(m); return (EAFNOSUPPORT); } #endif - return (if_simloop(ifp, m, dst->sa_family, 0)); + return (if_simloop(ifp, m, af, 0)); } /* diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index 2385109..1c6399f 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -262,7 +262,7 @@ static const u_short interactive_ports[8] = { int debug = ifp->if_flags & IFF_DEBUG static int sppp_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct route *ro); + const struct sockaddr *dst, struct route *ro); static void sppp_cisco_send(struct sppp *sp, int type, long par1, long par2); static void sppp_cisco_input(struct sppp *sp, struct mbuf *m); @@ -785,8 +785,8 @@ sppp_ifstart(struct ifnet *ifp) * Enqueue transmit packet. */ static int -sppp_output(struct ifnet *ifp, struct mbuf *m, - struct sockaddr *dst, struct route *ro) +sppp_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, + struct route *ro) { struct sppp *sp = IFP2SP(ifp); struct ppp_header *h; diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c index c8f2ec8..2c34739 100644 --- a/sys/net/if_stf.c +++ b/sys/net/if_stf.c @@ -140,7 +140,7 @@ SYSCTL_INT(_net_link_stf, OID_AUTO, permit_rfc1918, CTLFLAG_RW | CTLFLAG_TUN, * XXX: Return a pointer with 16-bit aligned. Don't cast it to * struct in_addr *; use bcopy() instead. */ -#define GET_V4(x) ((caddr_t)(&(x)->s6_addr16[1])) +#define GET_V4(x) (&(x)->s6_addr16[1]) struct stf_softc { struct ifnet *sc_ifp; @@ -181,7 +181,7 @@ static char *stfnames[] = {"stf0", "stf", "6to4", NULL}; static int stfmodevent(module_t, int, void *); static int stf_encapcheck(const struct mbuf *, int, int, void *); static struct in6_ifaddr *stf_getsrcifa6(struct ifnet *); -static int stf_output(struct ifnet *, struct mbuf *, struct sockaddr *, +static int stf_output(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); static int isrfc1918addr(struct in_addr *); static int stf_checkaddr4(struct stf_softc *, struct in_addr *, @@ -413,23 +413,19 @@ stf_getsrcifa6(ifp) } static int -stf_output(ifp, m, dst, ro) - struct ifnet *ifp; - struct mbuf *m; - struct sockaddr *dst; - struct route *ro; +stf_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, + struct route *ro) { struct stf_softc *sc; - struct sockaddr_in6 *dst6; + const struct sockaddr_in6 *dst6; struct route *cached_route; struct in_addr in4; - caddr_t ptr; + const void *ptr; struct sockaddr_in *dst4; u_int8_t tos; struct ip *ip; struct ip6_hdr *ip6; struct in6_ifaddr *ia6; - u_int32_t af; int error; #ifdef MAC @@ -441,7 +437,7 @@ stf_output(ifp, m, dst, ro) #endif sc = ifp->if_softc; - dst6 = (struct sockaddr_in6 *)dst; + dst6 = (const struct sockaddr_in6 *)dst; /* just in case */ if ((ifp->if_flags & IFF_UP) == 0) { @@ -474,15 +470,6 @@ stf_output(ifp, m, dst, ro) tos = (ntohl(ip6->ip6_flow) >> 20) & 0xff; /* - * BPF writes need to be handled specially. - * This is a null operation, nothing here checks dst->sa_family. - */ - if (dst->sa_family == AF_UNSPEC) { - bcopy(dst->sa_data, &af, sizeof(af)); - dst->sa_family = af; - } - - /* * Pickup the right outer dst addr from the list of candidates. * ip6_dst has priority as it may be able to give us shorter IPv4 hops. */ @@ -507,7 +494,7 @@ stf_output(ifp, m, dst, ro) * will only read from the mbuf (i.e., it won't * try to free it or keep a pointer a to it). */ - af = AF_INET6; + u_int af = AF_INET6; bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m); } diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 3630732..d885024 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -128,8 +128,8 @@ static void tuncreate(const char *name, struct cdev *dev); static int tunifioctl(struct ifnet *, u_long, caddr_t); static void tuninit(struct ifnet *); static int tunmodevent(module_t, int, void *); -static int tunoutput(struct ifnet *, struct mbuf *, struct sockaddr *, - struct route *ro); +static int tunoutput(struct ifnet *, struct mbuf *, + const struct sockaddr *, struct route *ro); static void tunstart(struct ifnet *); static int tun_clone_create(struct if_clone *, int, caddr_t); @@ -575,7 +575,7 @@ tunifioctl(struct ifnet *ifp, u_long cmd, caddr_t data) * tunoutput - queue packets from higher level ready to put out. */ static int -tunoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, +tunoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, struct route *ro) { struct tun_softc *tp = ifp->if_softc; @@ -609,15 +609,13 @@ tunoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, } /* BPF writes need to be handled specially. */ - if (dst->sa_family == AF_UNSPEC) { + if (dst->sa_family == AF_UNSPEC) bcopy(dst->sa_data, &af, sizeof(af)); - dst->sa_family = af; - } - - if (bpf_peers_present(ifp->if_bpf)) { + else af = dst->sa_family; + + if (bpf_peers_present(ifp->if_bpf)) bpf_mtap2(ifp->if_bpf, &af, sizeof(af), m0); - } /* prepend sockaddr? this may abort if the mbuf allocation fails */ if (cached_tun_flags & TUN_LMODE) { @@ -644,10 +642,10 @@ tunoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, ifp->if_oerrors++; return (ENOBUFS); } else - *(u_int32_t *)m0->m_data = htonl(dst->sa_family); + *(u_int32_t *)m0->m_data = htonl(af); } else { #ifdef INET - if (dst->sa_family != AF_INET) + if (af != AF_INET) #endif { m_freem(m0); diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 6b3a468..41ac056 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -158,7 +158,7 @@ struct ifnet { int if_amcount; /* number of all-multicast requests */ /* procedure handles */ int (*if_output) /* output routine (enqueue) */ - (struct ifnet *, struct mbuf *, struct sockaddr *, + (struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); void (*if_input) /* input routine (from h/w driver) */ (struct ifnet *, struct mbuf *); diff --git a/sys/net/iso88025.h b/sys/net/iso88025.h index 6edd2e0..2faab84 100644 --- a/sys/net/iso88025.h +++ b/sys/net/iso88025.h @@ -165,8 +165,8 @@ struct iso88025_addr { void iso88025_ifattach (struct ifnet *, const u_int8_t *, int); void iso88025_ifdetach (struct ifnet *, int); int iso88025_ioctl (struct ifnet *, u_long, caddr_t ); -int iso88025_output (struct ifnet *, struct mbuf *, struct sockaddr *, - struct route *); +int iso88025_output (struct ifnet *, struct mbuf *, + const struct sockaddr *, struct route *); void iso88025_input (struct ifnet *, struct mbuf *); #endif |