aboutsummaryrefslogtreecommitdiff
path: root/sys/netgraph/ng_pppoe.c
diff options
context:
space:
mode:
authorArchie Cobbs <archie@FreeBSD.org>2002-06-05 23:35:31 +0000
committerArchie Cobbs <archie@FreeBSD.org>2002-06-05 23:35:31 +0000
commit816b834f1422775bca3e40de0fe8343ed6dfd1cf (patch)
tree79c438e42f33c8b1d1266d5cc137cdd578828f7e /sys/netgraph/ng_pppoe.c
parent7b9f235f4ce76e419a6f6500fb70033b92b48b63 (diff)
downloadsrc-816b834f1422775bca3e40de0fe8343ed6dfd1cf.tar.gz
src-816b834f1422775bca3e40de0fe8343ed6dfd1cf.zip
Const'ify variables to make it clear we're not writing to the mbuf data.
Reviewed by: julian, brian MFC after: 1 week
Notes
Notes: svn path=/head/; revision=97897
Diffstat (limited to 'sys/netgraph/ng_pppoe.c')
-rw-r--r--sys/netgraph/ng_pppoe.c64
1 files changed, 33 insertions, 31 deletions
diff --git a/sys/netgraph/ng_pppoe.c b/sys/netgraph/ng_pppoe.c
index 7c26cdc7a0e8..3832d84c8f21 100644
--- a/sys/netgraph/ng_pppoe.c
+++ b/sys/netgraph/ng_pppoe.c
@@ -202,7 +202,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;
@@ -277,7 +277,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);
/*************************************************************************
@@ -328,10 +329,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));
}
/*
@@ -339,28 +341,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;
}
@@ -383,7 +385,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;
@@ -412,7 +414,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;
@@ -432,7 +434,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;
}
@@ -456,7 +458,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;
@@ -503,7 +505,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;
@@ -534,7 +536,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 = NG_NODE_PRIVATE(node);
@@ -889,7 +891,7 @@ AAA
}
static int
-send_acname(sessp sp, struct pppoe_tag *tag)
+send_acname(sessp sp, const struct pppoe_tag *tag)
{
int error;
struct ng_mesg *msg;
@@ -936,13 +938,13 @@ ng_pppoe_rcvdata(hook_p hook, item_p item)
node_p node = NG_HOOK_NODE(hook);
const priv_p privp = NG_NODE_PRIVATE(node);
sessp sp = NG_HOOK_PRIVATE(hook);
- 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;
@@ -1681,21 +1683,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;
@@ -1715,7 +1717,7 @@ AAA
case PTT_GEN_ERR:
break;
}
- pt = (struct pppoe_tag*)ptn;
+ pt = (const struct pppoe_tag*)ptn;
}
return NULL;
}