From e3b919c7542da069ed1a124367901da61aee2f6c Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 21 Apr 2004 04:17:28 +0000 Subject: [PATCH] Constify if.c radix.c and route.c (and fix related fallout). --- sys/net/if.c | 61 +++++++++++++++------------- sys/net/if.h | 16 ++++---- sys/net/radix.c | 95 ++++++++++++++++++++++++-------------------- sys/net/radix.h | 44 ++++++++++---------- sys/net/route.c | 30 +++++++------- sys/net/route.h | 24 ++++++----- sys/net/rtsock.c | 10 ++--- sys/netinet/if_arp.c | 8 ++-- sys/netiso/if_eon.c | 6 +-- 9 files changed, 155 insertions(+), 139 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 3db97fe1963a..bcf72d917126 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.139 2004/03/24 15:34:54 atatat Exp $ */ +/* $NetBSD: if.c,v 1.140 2004/04/21 04:17:28 matt Exp $ */ /*- * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.139 2004/03/24 15:34:54 atatat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.140 2004/04/21 04:17:28 matt Exp $"); #include "opt_inet.h" @@ -904,7 +904,7 @@ if_clone_list(ifcr) /*ARGSUSED*/ struct ifaddr * ifa_ifwithaddr(addr) - struct sockaddr *addr; + const struct sockaddr *addr; { struct ifnet *ifp; struct ifaddr *ifa; @@ -939,7 +939,7 @@ ifa_ifwithaddr(addr) /*ARGSUSED*/ struct ifaddr * ifa_ifwithdstaddr(addr) - struct sockaddr *addr; + const struct sockaddr *addr; { struct ifnet *ifp; struct ifaddr *ifa; @@ -969,11 +969,11 @@ ifa_ifwithdstaddr(addr) */ struct ifaddr * ifa_ifwithnet(addr) - struct sockaddr *addr; + const struct sockaddr *addr; { struct ifnet *ifp; struct ifaddr *ifa; - struct sockaddr_dl *sdl; + const struct sockaddr_dl *sdl; struct ifaddr *ifa_maybe = 0; u_int af = addr->sa_family; char *addr_data = addr->sa_data, *cplim; @@ -987,7 +987,7 @@ ifa_ifwithnet(addr) } #ifdef NETATALK if (af == AF_APPLETALK) { - struct sockaddr_at *sat, *sat2; + const struct sockaddr_at *sat, *sat2; sat = (struct sockaddr_at *)addr; for (ifp = TAILQ_FIRST(&ifnet); ifp != NULL; ifp = TAILQ_NEXT(ifp, if_list)) { @@ -1043,7 +1043,7 @@ ifa_ifwithnet(addr) */ struct ifaddr * ifa_ifwithladdr(addr) - struct sockaddr *addr; + const struct sockaddr *addr; { struct ifaddr *ia; @@ -1082,12 +1082,12 @@ ifa_ifwithaf(af) */ struct ifaddr * ifaof_ifpforaddr(addr, ifp) - struct sockaddr *addr; + const struct sockaddr *addr; struct ifnet *ifp; { struct ifaddr *ifa; - char *cp, *cp2, *cp3; - char *cplim; + const char *cp, *cp2, *cp3; + const char *cplim; struct ifaddr *ifa_maybe = 0; u_int af = addr->sa_family; @@ -1331,6 +1331,12 @@ ifioctl(so, cmd, data, p) struct ifdatareq *ifdr; int s, error = 0; short oif_flags; + int prived_error; + + if (p) + prived_error = suser(p->p_ucred, &p->p_acflag); + else + prived_error = 0; switch (cmd) { @@ -1345,8 +1351,8 @@ ifioctl(so, cmd, data, p) switch (cmd) { case SIOCIFCREATE: case SIOCIFDESTROY: - if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) - return (error); + if (prived_error) + return (prived_error); return ((cmd == SIOCIFCREATE) ? if_clone_create(ifr->ifr_name) : if_clone_destroy(ifr->ifr_name)); @@ -1378,8 +1384,8 @@ ifioctl(so, cmd, data, p) break; case SIOCSIFFLAGS: - if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) - return (error); + if (prived_error != 0) + return (prived_error); if (ifp->if_flags & IFF_UP && (ifr->ifr_flags & IFF_UP) == 0) { s = splnet(); if_down(ifp); @@ -1402,8 +1408,8 @@ ifioctl(so, cmd, data, p) break; case SIOCSIFCAP: - if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) - return (error); + if (prived_error != 0) + return (prived_error); if ((ifcr->ifcr_capenable & ~ifp->if_capabilities) != 0) return (EINVAL); if (ifp->if_ioctl == NULL) @@ -1460,8 +1466,8 @@ ifioctl(so, cmd, data, p) break; case SIOCSIFMETRIC: - if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) - return (error); + if (prived_error != 0) + return (prived_error); ifp->if_metric = ifr->ifr_metric; break; @@ -1470,8 +1476,8 @@ ifioctl(so, cmd, data, p) break; case SIOCZIFDATA: - if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) - return (error); + if (prived_error != 0) + return (prived_error); ifdr->ifdr_data = ifp->if_data; /* * Assumes that the volatile counters that can be @@ -1485,9 +1491,8 @@ ifioctl(so, cmd, data, p) { u_long oldmtu = ifp->if_mtu; - error = suser(p->p_ucred, &p->p_acflag); - if (error) - return (error); + if (prived_error) + return (prived_error); if (ifp->if_ioctl == NULL) return (EOPNOTSUPP); error = (*ifp->if_ioctl)(ifp, cmd, data); @@ -1511,8 +1516,8 @@ ifioctl(so, cmd, data, p) case SIOCADDMULTI: case SIOCDELMULTI: case SIOCSIFMEDIA: - if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) - return (error); + if (prived_error != 0) + return (prived_error); /* FALLTHROUGH */ case SIOCGIFPSRCADDR: case SIOCGIFPDSTADDR: @@ -1530,8 +1535,8 @@ ifioctl(so, cmd, data, p) case SIOCS80211BSSID: case SIOCS80211CHANNEL: /* XXX: need to pass proc pointer through to driver... */ - if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) - return (error); + if (prived_error != 0) + return (prived_error); /* FALLTHROUGH */ default: if (so->so_proto == 0) diff --git a/sys/net/if.h b/sys/net/if.h index 44c0182202de..e1b51a33038a 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $NetBSD: if.h,v 1.95 2003/12/10 11:46:33 itojun Exp $ */ +/* $NetBSD: if.h,v 1.96 2004/04/21 04:17:28 matt Exp $ */ /*- * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc. @@ -756,14 +756,14 @@ int ifioctl __P((struct socket *, u_long, caddr_t, struct proc *)); int ifpromisc __P((struct ifnet *, int)); struct ifnet *ifunit __P((const char *)); -struct ifaddr *ifa_ifwithaddr __P((struct sockaddr *)); +struct ifaddr *ifa_ifwithaddr __P((const struct sockaddr *)); struct ifaddr *ifa_ifwithaf __P((int)); -struct ifaddr *ifa_ifwithdstaddr __P((struct sockaddr *)); -struct ifaddr *ifa_ifwithnet __P((struct sockaddr *)); -struct ifaddr *ifa_ifwithladdr __P((struct sockaddr *)); -struct ifaddr *ifa_ifwithroute __P((int, struct sockaddr *, - struct sockaddr *)); -struct ifaddr *ifaof_ifpforaddr __P((struct sockaddr *, struct ifnet *)); +struct ifaddr *ifa_ifwithdstaddr __P((const struct sockaddr *)); +struct ifaddr *ifa_ifwithnet __P((const struct sockaddr *)); +struct ifaddr *ifa_ifwithladdr __P((const struct sockaddr *)); +struct ifaddr *ifa_ifwithroute __P((int, const struct sockaddr *, + const struct sockaddr *)); +struct ifaddr *ifaof_ifpforaddr __P((const struct sockaddr *, struct ifnet *)); void ifafree __P((struct ifaddr *)); void link_rtrequest __P((int, struct rtentry *, struct rt_addrinfo *)); diff --git a/sys/net/radix.c b/sys/net/radix.c index 46c0fab8db9e..d8390e39d957 100644 --- a/sys/net/radix.c +++ b/sys/net/radix.c @@ -1,4 +1,4 @@ -/* $NetBSD: radix.c,v 1.20 2003/08/07 16:32:56 agc Exp $ */ +/* $NetBSD: radix.c,v 1.21 2004/04/21 04:17:28 matt Exp $ */ /* * Copyright (c) 1988, 1989, 1993 @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: radix.c,v 1.20 2003/08/07 16:32:56 agc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: radix.c,v 1.21 2004/04/21 04:17:28 matt Exp $"); #ifndef _NET_RADIX_H_ #include @@ -56,15 +56,16 @@ int max_keylen; struct radix_mask *rn_mkfreelist; struct radix_node_head *mask_rnhead; static char *addmask_key; -static char normal_chars[] = {0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, -1}; +static const char normal_chars[] = + {0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, -1}; static char *rn_zeros, *rn_ones; #define rn_masktop (mask_rnhead->rnh_treetop) #undef Bcmp #define Bcmp(a, b, l) (l == 0 ? 0 : bcmp((caddr_t)(a), (caddr_t)(b), (u_long)l)) -static int rn_satisfies_leaf __P((char *, struct radix_node *, int)); -static int rn_lexobetter __P((void *, void *)); +static int rn_satisfies_leaf __P((const char *, struct radix_node *, int)); +static int rn_lexobetter __P((const void *, const void *)); static struct radix_mask *rn_new_radix_mask __P((struct radix_node *, struct radix_mask *)); @@ -104,13 +105,13 @@ static struct radix_mask *rn_new_radix_mask __P((struct radix_node *, struct radix_node * rn_search(v_arg, head) - void *v_arg; + const void *v_arg; struct radix_node *head; { + const u_char * const v = v_arg; struct radix_node *x; - caddr_t v; - for (x = head, v = v_arg; x->rn_b >= 0;) { + for (x = head; x->rn_b >= 0;) { if (x->rn_bmask & v[x->rn_off]) x = x->rn_r; else @@ -122,10 +123,11 @@ rn_search(v_arg, head) struct radix_node * rn_search_m(v_arg, head, m_arg) struct radix_node *head; - void *v_arg, *m_arg; + const void *v_arg, *m_arg; { struct radix_node *x; - caddr_t v = v_arg, m = m_arg; + const u_char * const v = v_arg; + const u_char * const m = m_arg; for (x = head; x->rn_b >= 0;) { if ((x->rn_bmask & m[x->rn_off]) && @@ -139,10 +141,12 @@ rn_search_m(v_arg, head, m_arg) int rn_refines(m_arg, n_arg) - void *m_arg, *n_arg; + const void *m_arg, *n_arg; { - caddr_t m = m_arg, n = n_arg; - caddr_t lim, lim2 = lim = n + *(u_char *)n; + const char *m = m_arg; + const char *n = n_arg; + const char *lim = n + *(u_char *)n; + const char *lim2 = lim; int longer = (*(u_char *)n++) - (int)(*(u_char *)m++); int masks_are_equal = 1; @@ -166,11 +170,11 @@ rn_refines(m_arg, n_arg) struct radix_node * rn_lookup(v_arg, m_arg, head) - void *v_arg, *m_arg; + const void *v_arg, *m_arg; struct radix_node_head *head; { struct radix_node *x; - caddr_t netmask = 0; + const char *netmask = NULL; if (m_arg) { if ((x = rn_addmask(m_arg, 1, head->rnh_treetop->rn_off)) == 0) @@ -187,12 +191,12 @@ rn_lookup(v_arg, m_arg, head) static int rn_satisfies_leaf(trial, leaf, skip) - char *trial; + const char *trial; struct radix_node *leaf; int skip; { - char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask; - char *cplim; + const char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask; + const char *cplim; int length = min(*(u_char *)cp, *(u_char *)cp2); if (cp3 == 0) @@ -208,13 +212,14 @@ rn_satisfies_leaf(trial, leaf, skip) struct radix_node * rn_match(v_arg, head) - void *v_arg; + const void *v_arg; struct radix_node_head *head; { - caddr_t v = v_arg; + const char * const v = v_arg; struct radix_node *t = head->rnh_treetop, *x; - caddr_t cp = v, cp2; - caddr_t cplim; + const char *cp = v; + const char *cp2; + const char *cplim; struct radix_node *saved_t, *top = t; int off = t->rn_off, vlen = *(u_char *)cp, matched_off; int test, b, rn_b; @@ -317,14 +322,14 @@ int rn_debug = 1; struct radix_node * rn_newpair(v, b, nodes) - void *v; + const void *v; int b; struct radix_node nodes[2]; { struct radix_node *tt = nodes, *t = tt + 1; t->rn_b = b; t->rn_bmask = 0x80 >> (b & 7); t->rn_l = tt; t->rn_off = b >> 3; - tt->rn_b = -1; tt->rn_key = (caddr_t)v; tt->rn_p = t; + tt->rn_b = -1; tt->rn_key = v; tt->rn_p = t; tt->rn_flags = t->rn_flags = RNF_ACTIVE; #ifdef RN_DEBUG tt->rn_info = rn_nodenum++; t->rn_info = rn_nodenum++; @@ -335,25 +340,26 @@ rn_newpair(v, b, nodes) struct radix_node * rn_insert(v_arg, head, dupentry, nodes) - void *v_arg; + const void *v_arg; struct radix_node_head *head; int *dupentry; struct radix_node nodes[2]; { - caddr_t v = v_arg; + const char *v = v_arg; struct radix_node *top = head->rnh_treetop; - int head_off = top->rn_off, vlen = (int)*((u_char *)v); struct radix_node *t = rn_search(v_arg, top); - caddr_t cp = v + head_off; + int head_off = top->rn_off; + int vlen = *((u_char *)v); + const char *cp = v + head_off; int b; struct radix_node *tt; /* * Find first bit at which v and t->rn_key differ */ { - caddr_t cp2 = t->rn_key + head_off; + const char *cp2 = t->rn_key + head_off; + const char *cplim = v + vlen; int cmp_res; - caddr_t cplim = v + vlen; while (cp < cplim) if (*cp2++ != *cp++) @@ -401,11 +407,12 @@ on1: struct radix_node * rn_addmask(n_arg, search, skip) int search, skip; - void *n_arg; + const void *n_arg; { - caddr_t netmask = (caddr_t)n_arg; + const char *netmask = n_arg; struct radix_node *x; - caddr_t cp, cplim; + const char *cp; + const char *cplim; int b = 0, mlen, j; int maskduplicated, m0, isnormal; struct radix_node *saved_x; @@ -444,8 +451,8 @@ rn_addmask(n_arg, search, skip) if ((saved_x = x) == 0) return (0); Bzero(x, max_keylen + 2 * sizeof (*x)); - netmask = cp = (caddr_t)(x + 2); - Bcopy(addmask_key, cp, mlen); + netmask = (caddr_t)(x + 2); + Bcopy(addmask_key, (caddr_t)(x + 2), mlen); x = rn_insert(cp, mask_rnhead, &maskduplicated, x); if (maskduplicated) { log(LOG_ERR, "rn_addmask: mask impossibly already in tree\n"); @@ -473,9 +480,9 @@ rn_addmask(n_arg, search, skip) static int /* XXX: arbitrary ordering for non-contiguous masks */ rn_lexobetter(m_arg, n_arg) - void *m_arg, *n_arg; + const void *m_arg, *n_arg; { - u_char *mp = m_arg, *np = n_arg, *lim; + const u_char *mp = m_arg, *np = n_arg, *lim; if (*mp > *np) return 1; /* not really, but need to check longer one first */ @@ -512,16 +519,17 @@ rn_new_radix_mask(tt, next) struct radix_node * rn_addroute(v_arg, n_arg, head, treenodes) - void *v_arg, *n_arg; + const void *v_arg, *n_arg; struct radix_node_head *head; struct radix_node treenodes[2]; { - caddr_t v = (caddr_t)v_arg, netmask = (caddr_t)n_arg; + const char *v = v_arg; + const char *netmask = n_arg; struct radix_node *t, *x = 0, *tt; struct radix_node *saved_tt, *top = head->rnh_treetop; short b = 0, b_leaf = 0; int keyduplicated; - caddr_t mmask; + const char *mmask; struct radix_mask *m, **mp; /* @@ -663,17 +671,16 @@ on2: struct radix_node * rn_delete(v_arg, netmask_arg, head) - void *v_arg, *netmask_arg; + const void *v_arg, *netmask_arg; struct radix_node_head *head; { struct radix_node *t, *p, *x, *tt; struct radix_mask *m, *saved_m, **mp; struct radix_node *dupedkey, *saved_tt, *top; - caddr_t v, netmask; + const char *v = v_arg; + const char *netmask = netmask_arg; int b, head_off, vlen; - v = v_arg; - netmask = netmask_arg; x = head->rnh_treetop; tt = rn_search(v, x); head_off = x->rn_off; diff --git a/sys/net/radix.h b/sys/net/radix.h index 23c5619477d1..7258333a7ff9 100644 --- a/sys/net/radix.h +++ b/sys/net/radix.h @@ -1,4 +1,4 @@ -/* $NetBSD: radix.h,v 1.12 2003/08/07 16:32:56 agc Exp $ */ +/* $NetBSD: radix.h,v 1.13 2004/04/21 04:17:28 matt Exp $ */ /* * Copyright (c) 1988, 1989, 1993 @@ -49,8 +49,8 @@ struct radix_node { #define RNF_ACTIVE 4 /* This node is alive (for rtfree) */ union { struct { /* leaf only data: */ - caddr_t rn_Key; /* object of search */ - caddr_t rn_Mask; /* netmask, if present */ + const char *rn_Key; /* object of search */ + const char *rn_Mask; /* netmask, if present */ struct radix_node *rn_Dupedkey; } rn_leaf; struct { /* node only data: */ @@ -83,7 +83,7 @@ extern struct radix_mask { u_char rm_flags; /* cf. rn_flags */ struct radix_mask *rm_mklist; /* more masks to try */ union { - caddr_t rmu_mask; /* the mask */ + const char *rmu_mask; /* the mask */ struct radix_node *rmu_leaf; /* for normal routes */ } rm_rmu; int rm_refs; /* # of references to this struct */ @@ -106,21 +106,21 @@ struct radix_node_head { int rnh_addrsize; /* permit, but not require fixed keys */ int rnh_pktsize; /* permit, but not require fixed keys */ struct radix_node *(*rnh_addaddr) /* add based on sockaddr */ - __P((void *v, void *mask, + __P((const void *v, const void *mask, struct radix_node_head *head, struct radix_node nodes[])); struct radix_node *(*rnh_addpkt) /* add based on packet hdr */ - __P((void *v, void *mask, + __P((const void *v, const void *mask, struct radix_node_head *head, struct radix_node nodes[])); struct radix_node *(*rnh_deladdr) /* remove based on sockaddr */ - __P((void *v, void *mask, struct radix_node_head *head)); + __P((const void *v, const void *mask, struct radix_node_head *head)); struct radix_node *(*rnh_delpkt) /* remove based on packet hdr */ - __P((void *v, void *mask, struct radix_node_head *head)); + __P((const void *v, const void *mask, struct radix_node_head *head)); struct radix_node *(*rnh_matchaddr) /* locate based on sockaddr */ - __P((void *v, struct radix_node_head *head)); + __P((const void *v, struct radix_node_head *head)); struct radix_node *(*rnh_lookup) /* locate based on sockaddr */ - __P((void *v, void *mask, struct radix_node_head *head)); + __P((const void *v, const void *mask, struct radix_node_head *head)); struct radix_node *(*rnh_matchpkt) /* locate based on packet hdr */ - __P((void *v, struct radix_node_head *head)); + __P((const void *v, struct radix_node_head *head)); int (*rnh_walktree) /* traverse tree */ __P((struct radix_node_head *, int (*)(struct radix_node *, void *), void *)); @@ -132,27 +132,27 @@ struct radix_node_head { #define Bcmp(a, b, n) bcmp(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n)) #define Bcopy(a, b, n) bcopy(((caddr_t)(a)), ((caddr_t)(b)), (unsigned)(n)) #define Bzero(p, n) bzero((caddr_t)(p), (unsigned)(n)); -#define R_Malloc(p, t, n) (p = (t) malloc((unsigned long)(n), M_RTABLE, M_DONTWAIT)) +#define R_Malloc(p, t, n) (p = (t) malloc((size_t)(n), M_RTABLE, M_NOWAIT)) #define Free(p) free((caddr_t)p, M_RTABLE); #endif /*_KERNEL*/ void rn_init __P((void)); int rn_inithead __P((void **, int)); int rn_inithead0 __P((struct radix_node_head *, int)); -int rn_refines __P((void *, void *)); +int rn_refines __P((const void *, const void *)); int rn_walktree __P((struct radix_node_head *, int (*)(struct radix_node *, void *), void *)); struct radix_node - *rn_addmask __P((void *, int, int)), - *rn_addroute __P((void *, void *, struct radix_node_head *, + *rn_addmask __P((const void *, int, int)), + *rn_addroute __P((const void *, const void *, struct radix_node_head *, struct radix_node [2])), - *rn_delete __P((void *, void *, struct radix_node_head *)), - *rn_insert __P((void *, struct radix_node_head *, int *, + *rn_delete __P((const void *, const void *, struct radix_node_head *)), + *rn_insert __P((const void *, struct radix_node_head *, int *, struct radix_node [2])), - *rn_lookup __P((void *, void *, struct radix_node_head *)), - *rn_match __P((void *, struct radix_node_head *)), - *rn_newpair __P((void *, int, struct radix_node[2])), - *rn_search __P((void *, struct radix_node *)), - *rn_search_m __P((void *, struct radix_node *, void *)); + *rn_lookup __P((const void *, const void *, struct radix_node_head *)), + *rn_match __P((const void *, struct radix_node_head *)), + *rn_newpair __P((const void *, int, struct radix_node[2])), + *rn_search __P((const void *, struct radix_node *)), + *rn_search_m __P((const void *, struct radix_node *, const void *)); #endif /* _NET_RADIX_H_ */ diff --git a/sys/net/route.c b/sys/net/route.c index 521180879144..6c3baa89ba16 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.58 2003/08/07 16:32:57 agc Exp $ */ +/* $NetBSD: route.c,v 1.59 2004/04/21 04:17:28 matt Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -98,7 +98,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.58 2003/08/07 16:32:57 agc Exp $"); +__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.59 2004/04/21 04:17:28 matt Exp $"); #include "opt_ns.h" @@ -180,7 +180,7 @@ rtalloc(ro) struct rtentry * rtalloc1(dst, report) - struct sockaddr *dst; + const struct sockaddr *dst; int report; { struct radix_node_head *rnh = rt_tables[dst->sa_family]; @@ -282,7 +282,7 @@ ifafree(ifa) */ void rtredirect(dst, gateway, netmask, flags, src, rtp) - struct sockaddr *dst, *gateway, *netmask, *src; + const struct sockaddr *dst, *gateway, *netmask, *src; int flags; struct rtentry **rtp; { @@ -454,7 +454,7 @@ rtioctl(req, data, p) struct ifaddr * ifa_ifwithroute(flags, dst, gateway) int flags; - struct sockaddr *dst, *gateway; + const struct sockaddr *dst, *gateway; { struct ifaddr *ifa; if ((flags & RTF_GATEWAY) == 0) { @@ -502,7 +502,7 @@ ifa_ifwithroute(flags, dst, gateway) int rtrequest(req, dst, gateway, netmask, flags, ret_nrt) int req, flags; - struct sockaddr *dst, *gateway, *netmask; + const struct sockaddr *dst, *gateway, *netmask; struct rtentry **ret_nrt; { struct rt_addrinfo info; @@ -539,12 +539,12 @@ rt_getifa(info) */ if (info->rti_ifp == NULL && ifpaddr != NULL && ifpaddr->sa_family == AF_LINK && - (ifa = ifa_ifwithnet((struct sockaddr *)ifpaddr)) != NULL) + (ifa = ifa_ifwithnet((const struct sockaddr *)ifpaddr)) != NULL) info->rti_ifp = ifa->ifa_ifp; if (info->rti_ifa == NULL && ifaaddr != NULL) info->rti_ifa = ifa_ifwithaddr(ifaaddr); if (info->rti_ifa == NULL) { - struct sockaddr *sa; + const struct sockaddr *sa; sa = ifaaddr != NULL ? ifaaddr : (gateway != NULL ? gateway : dst); @@ -704,9 +704,9 @@ bad: int rt_setgate(rt0, dst, gate) struct rtentry *rt0; - struct sockaddr *dst, *gate; + const struct sockaddr *dst, *gate; { - caddr_t new, old; + char *new, *old; u_int dlen = ROUNDUP(dst->sa_len), glen = ROUNDUP(gate->sa_len); struct rtentry *rt = rt0; @@ -718,7 +718,7 @@ rt_setgate(rt0, dst, gate) Bzero(new, dlen + glen); rt->rt_nodes->rn_key = new; } else { - new = rt->rt_nodes->rn_key; + new = (void *)rt->rt_nodes->rn_key; old = 0; } Bcopy(gate, (rt->rt_gateway = (struct sockaddr *)(new + dlen)), glen); @@ -751,11 +751,13 @@ rt_setgate(rt0, dst, gate) void rt_maskedcopy(src, dst, netmask) - struct sockaddr *src, *dst, *netmask; + const struct sockaddr *src; + struct sockaddr *dst; + const struct sockaddr *netmask; { - u_char *cp1 = (u_char *)src; + const u_char *cp1 = (u_char *)src; u_char *cp2 = (u_char *)dst; - u_char *cp3 = (u_char *)netmask; + const u_char *cp3 = (u_char *)netmask; u_char *cplim = cp2 + *cp3; u_char *cplim2 = cp2 + *cp1; diff --git a/sys/net/route.h b/sys/net/route.h index 1cc3e493f24b..b785df1ebc80 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $NetBSD: route.h,v 1.36 2003/08/07 16:32:57 agc Exp $ */ +/* $NetBSD: route.h,v 1.37 2004/04/21 04:17:28 matt Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -100,7 +100,7 @@ struct rtentry { u_long rt_use; /* raw # packets forwarded */ struct ifnet *rt_ifp; /* the answer: interface to use */ struct ifaddr *rt_ifa; /* the answer: interface to use */ - struct sockaddr *rt_genmask; /* for generation of cloned routes */ + const struct sockaddr *rt_genmask; /* for generation of cloned routes */ caddr_t rt_llinfo; /* pointer to link level info cache */ struct rt_metrics rt_rmx; /* metrics used by rx'ing protocols */ struct rtentry *rt_gwroute; /* implied entry for gatewayed routes */ @@ -223,7 +223,7 @@ struct rt_msghdr { struct rt_addrinfo { int rti_addrs; - struct sockaddr *rti_info[RTAX_MAX]; + const struct sockaddr *rti_info[RTAX_MAX]; int rti_flags; struct ifaddr *rti_ifa; struct ifnet *rti_ifp; @@ -284,12 +284,12 @@ int route_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *)); void rt_ifannouncemsg __P((struct ifnet *, int)); void rt_ifmsg __P((struct ifnet *)); -void rt_maskedcopy __P((struct sockaddr *, - struct sockaddr *, struct sockaddr *)); +void rt_maskedcopy __P((const struct sockaddr *, + struct sockaddr *, const struct sockaddr *)); void rt_missmsg __P((int, struct rt_addrinfo *, int, int)); void rt_newaddrmsg __P((int, struct ifaddr *, int, struct rtentry *)); int rt_setgate __P((struct rtentry *, - struct sockaddr *, struct sockaddr *)); + const struct sockaddr *, const struct sockaddr *)); void rt_setmetrics __P((u_long, struct rt_metrics *, struct rt_metrics *)); int rt_timer_add __P((struct rtentry *, void(*)(struct rtentry *, struct rttimer *), @@ -306,15 +306,17 @@ void rt_timer_timer __P((void *)); void rtable_init __P((void **)); void rtalloc __P((struct route *)); struct rtentry * - rtalloc1 __P((struct sockaddr *, int)); + rtalloc1 __P((const struct sockaddr *, int)); void rtfree __P((struct rtentry *)); int rt_getifa __P((struct rt_addrinfo *)); int rtinit __P((struct ifaddr *, int, int)); int rtioctl __P((u_long, caddr_t, struct proc *)); -void rtredirect __P((struct sockaddr *, struct sockaddr *, - struct sockaddr *, int, struct sockaddr *, struct rtentry **)); -int rtrequest __P((int, struct sockaddr *, - struct sockaddr *, struct sockaddr *, int, struct rtentry **)); +void rtredirect __P((const struct sockaddr *, const struct sockaddr *, + const struct sockaddr *, int, const struct sockaddr *, + struct rtentry **)); +int rtrequest __P((int, const struct sockaddr *, + const struct sockaddr *, const struct sockaddr *, int, + struct rtentry **)); int rtrequest1 __P((int, struct rt_addrinfo *, struct rtentry **)); #endif /* _KERNEL */ #endif /* _NET_ROUTE_H_ */ diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 98b35abf8366..a2b29c17198a 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $NetBSD: rtsock.c,v 1.67 2004/03/24 15:34:54 atatat Exp $ */ +/* $NetBSD: rtsock.c,v 1.68 2004/04/21 04:17:28 matt Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.67 2004/03/24 15:34:54 atatat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.68 2004/04/21 04:17:28 matt Exp $"); #include "opt_inet.h" @@ -526,7 +526,7 @@ rt_msg1(type, rtinfo, data, datalen) struct rt_msghdr *rtm; struct mbuf *m; int i; - struct sockaddr *sa; + const struct sockaddr *sa; int len, dlen; m = m_gethdr(M_DONTWAIT, MT_DATA); @@ -642,7 +642,7 @@ again: if ((cp0 = cp) != NULL) cp += len; for (i = 0; i < RTAX_MAX; i++) { - struct sockaddr *sa; + const struct sockaddr *sa; if ((sa = rtinfo->rti_info[i]) == 0) continue; @@ -702,7 +702,7 @@ rt_missmsg(type, rtinfo, flags, error) { struct rt_msghdr rtm; struct mbuf *m; - struct sockaddr *sa = rtinfo->rti_info[RTAX_DST]; + const struct sockaddr *sa = rtinfo->rti_info[RTAX_DST]; if (route_cb.any_count == 0) return; diff --git a/sys/netinet/if_arp.c b/sys/netinet/if_arp.c index f07dfbf6c97f..a4d77f9267f4 100644 --- a/sys/netinet/if_arp.c +++ b/sys/netinet/if_arp.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_arp.c,v 1.94 2003/09/24 06:52:47 itojun Exp $ */ +/* $NetBSD: if_arp.c,v 1.95 2004/04/21 04:17:29 matt Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.94 2003/09/24 06:52:47 itojun Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.95 2004/04/21 04:17:29 matt Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -170,7 +170,7 @@ static int revarp_in_progress = 0; static struct ifnet *myip_ifp = NULL; #ifdef DDB -static void db_print_sa __P((struct sockaddr *)); +static void db_print_sa __P((const struct sockaddr *)); static void db_print_ifa __P((struct ifaddr *)); static void db_print_llinfo __P((caddr_t)); static int db_show_radix_node __P((struct radix_node *, void *)); @@ -1381,7 +1381,7 @@ revarpwhoarewe(ifp, serv_in, clnt_in) #include static void db_print_sa(sa) - struct sockaddr *sa; + const struct sockaddr *sa; { int len; u_char *p; diff --git a/sys/netiso/if_eon.c b/sys/netiso/if_eon.c index c499e41ffd59..0982f36e3308 100644 --- a/sys/netiso/if_eon.c +++ b/sys/netiso/if_eon.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_eon.c,v 1.43 2004/04/19 05:16:45 matt Exp $ */ +/* $NetBSD: if_eon.c,v 1.44 2004/04/21 04:17:29 matt Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -67,7 +67,7 @@ SOFTWARE. */ #include -__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.43 2004/04/19 05:16:45 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_eon.c,v 1.44 2004/04/21 04:17:29 matt Exp $"); #include "opt_eon.h" @@ -276,7 +276,7 @@ eonrtrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info) unsigned long zerodst = 0; caddr_t ipaddrloc = (caddr_t) & zerodst; struct eon_llinfo *el = (struct eon_llinfo *) rt->rt_llinfo; - struct sockaddr *gate; + const struct sockaddr *gate; /* * Common Housekeeping