diff options
author | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2015-09-05 05:33:20 +0000 |
---|---|---|
committer | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2015-09-05 05:33:20 +0000 |
commit | 441f9243df9fe7f000ca473f6464fa3dda1b0b50 (patch) | |
tree | 88d1ada658609b8fa03977ad48c442d675ce2006 | |
parent | 39993974aa62283706a60de25120a50b36975854 (diff) | |
download | src-441f9243df9fe7f000ca473f6464fa3dda1b0b50.tar.gz src-441f9243df9fe7f000ca473f6464fa3dda1b0b50.zip |
Notes
-rw-r--r-- | sys/net/if.c | 34 | ||||
-rw-r--r-- | sys/net/if_dl.h | 1 | ||||
-rw-r--r-- | sys/net/if_var.h | 17 | ||||
-rw-r--r-- | sys/net/route.c | 2 | ||||
-rw-r--r-- | sys/net/route.h | 4 |
5 files changed, 30 insertions, 28 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 9997692dd936..27fdbd9d3187 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1624,18 +1624,18 @@ ifa_switch_loopback_route(struct ifaddr *ifa, struct sockaddr *sa, int fib) */ #define sa_dl_equal(a1, a2) \ - ((((struct sockaddr_dl *)(a1))->sdl_len == \ - ((struct sockaddr_dl *)(a2))->sdl_len) && \ - (bcmp(LLADDR((struct sockaddr_dl *)(a1)), \ - LLADDR((struct sockaddr_dl *)(a2)), \ - ((struct sockaddr_dl *)(a1))->sdl_alen) == 0)) + ((((const struct sockaddr_dl *)(a1))->sdl_len == \ + ((const struct sockaddr_dl *)(a2))->sdl_len) && \ + (bcmp(CLLADDR((const struct sockaddr_dl *)(a1)), \ + CLLADDR((const struct sockaddr_dl *)(a2)), \ + ((const struct sockaddr_dl *)(a1))->sdl_alen) == 0)) /* * Locate an interface based on a complete address. */ /*ARGSUSED*/ static struct ifaddr * -ifa_ifwithaddr_internal(struct sockaddr *addr, int getref) +ifa_ifwithaddr_internal(const struct sockaddr *addr, int getref) { struct ifnet *ifp; struct ifaddr *ifa; @@ -1672,14 +1672,14 @@ done: } struct ifaddr * -ifa_ifwithaddr(struct sockaddr *addr) +ifa_ifwithaddr(const struct sockaddr *addr) { return (ifa_ifwithaddr_internal(addr, 1)); } int -ifa_ifwithaddr_check(struct sockaddr *addr) +ifa_ifwithaddr_check(const struct sockaddr *addr) { return (ifa_ifwithaddr_internal(addr, 0) != NULL); @@ -1690,7 +1690,7 @@ ifa_ifwithaddr_check(struct sockaddr *addr) */ /* ARGSUSED */ struct ifaddr * -ifa_ifwithbroadaddr(struct sockaddr *addr, int fibnum) +ifa_ifwithbroadaddr(const struct sockaddr *addr, int fibnum) { struct ifnet *ifp; struct ifaddr *ifa; @@ -1725,7 +1725,7 @@ done: */ /*ARGSUSED*/ struct ifaddr * -ifa_ifwithdstaddr(struct sockaddr *addr, int fibnum) +ifa_ifwithdstaddr(const struct sockaddr *addr, int fibnum) { struct ifnet *ifp; struct ifaddr *ifa; @@ -1760,20 +1760,20 @@ done: * is most specific found. */ struct ifaddr * -ifa_ifwithnet(struct sockaddr *addr, int ignore_ptp, int fibnum) +ifa_ifwithnet(const struct sockaddr *addr, int ignore_ptp, int fibnum) { struct ifnet *ifp; struct ifaddr *ifa; struct ifaddr *ifa_maybe = NULL; u_int af = addr->sa_family; - char *addr_data = addr->sa_data, *cplim; + const char *addr_data = addr->sa_data, *cplim; /* * AF_LINK addresses can be looked up directly by their index number, * so do that if we can. */ if (af == AF_LINK) { - struct sockaddr_dl *sdl = (struct sockaddr_dl *)addr; + const struct sockaddr_dl *sdl = (const struct sockaddr_dl *)addr; if (sdl->sdl_index && sdl->sdl_index <= V_if_index) return (ifaddr_byindex(sdl->sdl_index)); } @@ -1790,7 +1790,7 @@ ifa_ifwithnet(struct sockaddr *addr, int ignore_ptp, int fibnum) continue; IF_ADDR_RLOCK(ifp); TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { - char *cp, *cp2, *cp3; + const char *cp, *cp2, *cp3; if (ifa->ifa_addr->sa_family != af) next: continue; @@ -1863,10 +1863,10 @@ done: * a given address. */ struct ifaddr * -ifaof_ifpforaddr(struct sockaddr *addr, struct ifnet *ifp) +ifaof_ifpforaddr(const struct sockaddr *addr, struct ifnet *ifp) { struct ifaddr *ifa; - char *cp, *cp2, *cp3; + const char *cp, *cp2, *cp3; char *cplim; struct ifaddr *ifa_maybe = NULL; u_int af = addr->sa_family; @@ -2924,7 +2924,7 @@ if_allmulti(struct ifnet *ifp, int onswitch) } struct ifmultiaddr * -if_findmulti(struct ifnet *ifp, struct sockaddr *sa) +if_findmulti(struct ifnet *ifp, const struct sockaddr *sa) { struct ifmultiaddr *ifma; diff --git a/sys/net/if_dl.h b/sys/net/if_dl.h index 8b4e00790eb6..f53bc5e447dc 100644 --- a/sys/net/if_dl.h +++ b/sys/net/if_dl.h @@ -67,6 +67,7 @@ struct sockaddr_dl { }; #define LLADDR(s) ((caddr_t)((s)->sdl_data + (s)->sdl_nlen)) +#define CLLADDR(s) ((c_caddr_t)((s)->sdl_data + (s)->sdl_nlen)) #define LLINDEX(s) ((s)->sdl_index) diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 4af6b521ec51..572e413a64cc 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -487,7 +487,7 @@ void if_purgeaddrs(struct ifnet *); void if_delallmulti(struct ifnet *); void if_down(struct ifnet *); struct ifmultiaddr * - if_findmulti(struct ifnet *, struct sockaddr *); + if_findmulti(struct ifnet *, const struct sockaddr *); void if_free(struct ifnet *); void if_initname(struct ifnet *, const char *, int); void if_link_state_change(struct ifnet *, int); @@ -505,13 +505,14 @@ int ifa_add_loopback_route(struct ifaddr *, struct sockaddr *); int ifa_del_loopback_route(struct ifaddr *, struct sockaddr *); int ifa_switch_loopback_route(struct ifaddr *, struct sockaddr *, int fib); -struct ifaddr *ifa_ifwithaddr(struct sockaddr *); -int ifa_ifwithaddr_check(struct sockaddr *); -struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *, int); -struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *, int); -struct ifaddr *ifa_ifwithnet(struct sockaddr *, int, int); -struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *, u_int); -struct ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *); +struct ifaddr *ifa_ifwithaddr(const struct sockaddr *); +int ifa_ifwithaddr_check(const struct sockaddr *); +struct ifaddr *ifa_ifwithbroadaddr(const struct sockaddr *, int); +struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *, int); +struct ifaddr *ifa_ifwithnet(const struct sockaddr *, int, int); +struct ifaddr *ifa_ifwithroute(int, const struct sockaddr *, struct sockaddr *, + u_int); +struct ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *); int ifa_preferred(struct ifaddr *, struct ifaddr *); int if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen); diff --git a/sys/net/route.c b/sys/net/route.c index d61c79775cbc..1517dca1e22c 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -704,7 +704,7 @@ rtioctl_fib(u_long req, caddr_t data, u_int fibnum) } struct ifaddr * -ifa_ifwithroute(int flags, struct sockaddr *dst, struct sockaddr *gateway, +ifa_ifwithroute(int flags, const struct sockaddr *dst, struct sockaddr *gateway, u_int fibnum) { struct ifaddr *ifa; diff --git a/sys/net/route.h b/sys/net/route.h index 196df9bafbb3..c363032ea233 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -282,8 +282,8 @@ struct rt_addrinfo { 1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) ) #define sa_equal(a, b) ( \ - (((struct sockaddr *)(a))->sa_len == ((struct sockaddr *)(b))->sa_len) && \ - (bcmp((a), (b), ((struct sockaddr *)(b))->sa_len) == 0)) + (((const struct sockaddr *)(a))->sa_len == ((const struct sockaddr *)(b))->sa_len) && \ + (bcmp((a), (b), ((const struct sockaddr *)(b))->sa_len) == 0)) #ifdef _KERNEL |