diff options
| author | Archie Cobbs <archie@FreeBSD.org> | 2002-07-02 22:17:18 +0000 |
|---|---|---|
| committer | Archie Cobbs <archie@FreeBSD.org> | 2002-07-02 22:17:18 +0000 |
| commit | ae7cb07148b953178abc8f46647e2fb2844b107f (patch) | |
| tree | e65aca9d7d24a9f5ab7665548513c712e86a29f6 /sys | |
| parent | 1a03d47f380b1d360edd5e2779b91842b95adcc8 (diff) | |
Notes
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/netgraph/ng_lmi.c | 12 | ||||
| -rw-r--r-- | sys/netgraph/ng_pppoe.c | 64 | ||||
| -rw-r--r-- | sys/netgraph/ng_pptpgre.c | 17 | ||||
| -rw-r--r-- | sys/netgraph/ng_rfc1490.c | 7 | ||||
| -rw-r--r-- | sys/netgraph/ng_socket.c | 2 |
5 files changed, 53 insertions, 49 deletions
diff --git a/sys/netgraph/ng_lmi.c b/sys/netgraph/ng_lmi.c index 108e0d531f6f..b8463997172b 100644 --- a/sys/netgraph/ng_lmi.c +++ b/sys/netgraph/ng_lmi.c @@ -562,7 +562,7 @@ static int nglmi_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) { sc_p sc = hook->node->private; - u_char *data; + const u_char *data; unsigned short dlci; u_short packetlen; int resptype_seen = 0; @@ -588,7 +588,7 @@ nglmi_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) return (0); /* pass the first 4 bytes (already checked in the nglmi_checkdata()) */ - data = mtod(m, u_char *); + data = mtod(m, const u_char *); STEPBY(4); /* Now check if there is a 'locking shift'. This is only seen in @@ -745,7 +745,7 @@ static int nglmi_checkdata(hook_p hook, struct mbuf *m, meta_p meta) { sc_p sc = hook->node->private; - u_char *data; + const u_char *data; u_short packetlen; unsigned short dlci; u_char type; @@ -755,7 +755,7 @@ nglmi_checkdata(hook_p hook, struct mbuf *m, meta_p meta) int highest_dlci = 0; packetlen = m->m_hdr.mh_len; - data = mtod(m, u_char *); + data = mtod(m, const u_char *); if (*data != 0x03) { log(LOG_WARNING, "nglmi: unexpected value in LMI(%d)\n", 1); goto reject; @@ -998,7 +998,7 @@ print: int i, j, k, pos; char buf[100]; int loc; - u_char *bp = mtod(m, u_char *); + const u_char *bp = mtod(m, const u_char *); k = i = 0; loc = (m->m_hdr.mh_len - packetlen); @@ -1025,7 +1025,7 @@ reject: int i, j, k, pos; char buf[100]; int loc; - u_char *bp = mtod(m, u_char *); + const u_char *bp = mtod(m, const u_char *); k = i = 0; loc = (m->m_hdr.mh_len - packetlen); diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c index 775919655997..7cc61bd2d8ef 100644 --- a/sys/netgraph/ng_pppoe.c +++ b/sys/netgraph/ng_pppoe.c @@ -123,7 +123,7 @@ struct sess_neg { struct callout_handle timeout_handle; /* see timeout(9) */ u_int timeout; /* 0,1,2,4,8,16 etc. seconds */ u_int numtags; - struct pppoe_tag *tags[NUMTAGS]; + const struct pppoe_tag *tags[NUMTAGS]; u_int service_len; u_int ac_name_len; @@ -198,7 +198,8 @@ union uniq { static void pppoe_start(sessp sp); static void sendpacket(sessp sp); static void pppoe_ticker(void *arg); -static struct pppoe_tag* scan_tags(sessp sp, struct pppoe_hdr* ph); +static const struct pppoe_tag *scan_tags(sessp sp, + const struct pppoe_hdr* ph); static int pppoe_send_event(sessp sp, enum cmd cmdid); /************************************************************************* @@ -249,10 +250,11 @@ restart: /* * Return the location where the next tag can be put */ -static __inline struct pppoe_tag* -next_tag(struct pppoe_hdr* ph) +static __inline const struct pppoe_tag* +next_tag(const struct pppoe_hdr* ph) { - return (struct pppoe_tag*)(((char*)&ph->tag[0]) + ntohs(ph->length)); + return (const struct pppoe_tag*)(((const char*)&ph->tag[0]) + + ntohs(ph->length)); } /* @@ -260,28 +262,28 @@ next_tag(struct pppoe_hdr* ph) * Don't trust any length the other end says. * but assume we already sanity checked ph->length. */ -static struct pppoe_tag* -get_tag(struct pppoe_hdr* ph, u_int16_t idx) +static const struct pppoe_tag* +get_tag(const struct pppoe_hdr* ph, u_int16_t idx) { - char *end = (char *)next_tag(ph); - char *ptn; - struct pppoe_tag *pt = &ph->tag[0]; + const char *const end = (const char *)next_tag(ph); + const char *ptn; + const struct pppoe_tag *pt = &ph->tag[0]; /* * Keep processing tags while a tag header will still fit. */ AAA - while((char*)(pt + 1) <= end) { + while((const char*)(pt + 1) <= end) { /* * If the tag data would go past the end of the packet, abort. */ - ptn = (((char *)(pt + 1)) + ntohs(pt->tag_len)); + ptn = (((const char *)(pt + 1)) + ntohs(pt->tag_len)); if(ptn > end) return NULL; if(pt->tag_type == idx) return pt; - pt = (struct pppoe_tag*)ptn; + pt = (const struct pppoe_tag*)ptn; } return NULL; } @@ -304,7 +306,7 @@ AAA } static void -insert_tag(sessp sp, struct pppoe_tag *tp) +insert_tag(sessp sp, const struct pppoe_tag *tp) { int i; negp neg; @@ -333,7 +335,7 @@ AAA static void make_packet(sessp sp) { struct pppoe_full_hdr *wh = &sp->neg->pkt->pkt_header; - struct pppoe_tag **tag; + const struct pppoe_tag **tag; char *dp; int count; int tlen; @@ -353,7 +355,7 @@ AAA sp->neg->numtags = count; break; /* XXX chop off what's too long */ } - bcopy((char *)*tag, (char *)dp, tlen); + bcopy(*tag, (char *)dp, tlen); length += tlen; dp += tlen; } @@ -377,7 +379,7 @@ AAA #define NG_MATCH_ANY 2 static hook_p -pppoe_match_svc(node_p node, char *svc_name, int svc_len, int match) +pppoe_match_svc(node_p node, const char *svc_name, int svc_len, int match) { sessp sp = NULL; negp neg = NULL; @@ -424,7 +426,7 @@ AAA * Routine to find a particular session that matches an incoming packet * **************************************************************************/ static hook_p -pppoe_findsession(node_p node, struct pppoe_full_hdr *wh) +pppoe_findsession(node_p node, const struct pppoe_full_hdr *wh) { sessp sp = NULL; hook_p hook = NULL; @@ -455,7 +457,7 @@ AAA } static hook_p -pppoe_finduniq(node_p node, struct pppoe_tag *tag) +pppoe_finduniq(node_p node, const struct pppoe_tag *tag) { hook_p hook = NULL; priv_p privp = node->private; @@ -819,7 +821,7 @@ AAA } static int -send_acname(sessp sp, struct pppoe_tag *tag) +send_acname(sessp sp, const struct pppoe_tag *tag) { int error, tlen; struct ng_mesg *msg; @@ -867,13 +869,13 @@ ng_pppoe_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) node_p node = hook->node; const priv_p privp = node->private; sessp sp = hook->private; - struct pppoe_full_hdr *wh; - struct pppoe_hdr *ph; + const struct pppoe_full_hdr *wh; + const struct pppoe_hdr *ph; int error = 0; u_int16_t session; u_int16_t length; u_int8_t code; - struct pppoe_tag *utag = NULL, *tag = NULL; + const struct pppoe_tag *utag = NULL, *tag = NULL; hook_p sendhook; struct { struct pppoe_tag hdr; @@ -1598,21 +1600,21 @@ AAA * output packet. Don't do any tags that have been handled in the main * state machine. */ -static struct pppoe_tag* -scan_tags(sessp sp, struct pppoe_hdr* ph) +static const struct pppoe_tag* +scan_tags(sessp sp, const struct pppoe_hdr* ph) { - char *end = (char *)next_tag(ph); - char *ptn; - struct pppoe_tag *pt = &ph->tag[0]; + const char *const end = (const char *)next_tag(ph); + const char *ptn; + const struct pppoe_tag *pt = &ph->tag[0]; /* * Keep processing tags while a tag header will still fit. */ AAA - while((char*)(pt + 1) <= end) { + while((const char*)(pt + 1) <= end) { /* * If the tag data would go past the end of the packet, abort. */ - ptn = (((char *)(pt + 1)) + ntohs(pt->tag_len)); + ptn = (((const char *)(pt + 1)) + ntohs(pt->tag_len)); if(ptn > end) return NULL; @@ -1632,7 +1634,7 @@ AAA case PTT_GEN_ERR: break; } - pt = (struct pppoe_tag*)ptn; + pt = (const struct pppoe_tag*)ptn; } return NULL; } diff --git a/sys/netgraph/ng_pptpgre.c b/sys/netgraph/ng_pptpgre.c index 81a8b317003e..0ce31d972727 100644 --- a/sys/netgraph/ng_pptpgre.c +++ b/sys/netgraph/ng_pptpgre.c @@ -568,8 +568,8 @@ ng_pptpgre_recv(node_p node, struct mbuf *m, meta_p meta) { const priv_p priv = node->private; int iphlen, grelen, extralen; - struct greheader *gre; - struct ip *ip; + const struct greheader *gre; + const struct ip *ip; int error = 0; /* Update stats */ @@ -591,7 +591,7 @@ bad: NG_FREE_META(meta); return (ENOBUFS); } - ip = mtod(m, struct ip *); + ip = mtod(m, const struct ip *); iphlen = ip->ip_hl << 2; if (m->m_len < iphlen + sizeof(*gre)) { if ((m = m_pullup(m, iphlen + sizeof(*gre))) == NULL) { @@ -599,9 +599,9 @@ bad: NG_FREE_META(meta); return (ENOBUFS); } - ip = mtod(m, struct ip *); + ip = mtod(m, const struct ip *); } - gre = (struct greheader *)((u_char *)ip + iphlen); + gre = (const struct greheader *)((const u_char *)ip + iphlen); grelen = sizeof(*gre) + sizeof(u_int32_t) * (gre->hasSeq + gre->hasAck); if (m->m_pkthdr.len < iphlen + grelen) { priv->stats.recvRunts++; @@ -613,8 +613,8 @@ bad: NG_FREE_META(meta); return (ENOBUFS); } - ip = mtod(m, struct ip *); - gre = (struct greheader *)((u_char *)ip + iphlen); + ip = mtod(m, const struct ip *); + gre = (const struct greheader *)((const u_char *)ip + iphlen); } /* Sanity check packet length and GRE header bits */ @@ -624,7 +624,8 @@ bad: priv->stats.recvBadGRE++; goto bad; } - if ((ntohl(*((u_int32_t *)gre)) & PPTP_INIT_MASK) != PPTP_INIT_VALUE) { + if ((ntohl(*((const u_int32_t *)gre)) & PPTP_INIT_MASK) + != PPTP_INIT_VALUE) { priv->stats.recvBadGRE++; goto bad; } diff --git a/sys/netgraph/ng_rfc1490.c b/sys/netgraph/ng_rfc1490.c index 6c5c7b568be6..90833daa263c 100644 --- a/sys/netgraph/ng_rfc1490.c +++ b/sys/netgraph/ng_rfc1490.c @@ -222,12 +222,13 @@ ng_rfc1490_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) int error = 0; if (hook == priv->downlink) { - u_char *start, *ptr; + const u_char *start; + const u_char *ptr; if (!m || (m->m_len < MAX_ENCAPS_HDR && !(m = m_pullup(m, MAX_ENCAPS_HDR)))) ERROUT(ENOBUFS); - ptr = start = mtod(m, u_char *); + ptr = start = mtod(m, const u_char *); /* Must be UI frame */ if (*ptr++ != HDLC_UI) @@ -244,7 +245,7 @@ ng_rfc1490_rcvdata(hook_p hook, struct mbuf *m, meta_p meta) u_int16_t etype; ptr += 3; - etype = ntohs(*((u_int16_t *) ptr)); + etype = ntohs(*((const u_int16_t *)ptr)); ptr += 2; m_adj(m, ptr - start); switch (etype) { diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c index b942fcd8e374..d8aa1a1a6fa5 100644 --- a/sys/netgraph/ng_socket.c +++ b/sys/netgraph/ng_socket.c @@ -543,7 +543,7 @@ static int ng_internalize(struct mbuf *control, struct proc *p) { struct filedesc *fdp = p->p_fd; - struct cmsghdr *cm = mtod(control, struct cmsghdr *); + const struct cmsghdr *cm = mtod(control, const struct cmsghdr *); struct file *fp; struct vnode *vn; int oldfds; |
