From 19a52c592d5a31736edfac1bfbef2a0b1fab5d52 Mon Sep 17 00:00:00 2001 From: Archie Cobbs Date: Fri, 19 Nov 1999 04:27:53 +0000 Subject: Remove the address and control field compression functionality of this node type. ACF is device independent and therefore belongs in ng_ppp.c (which already implements it). --- sys/netgraph/ng_async.c | 48 ++++++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'sys/netgraph/ng_async.c') diff --git a/sys/netgraph/ng_async.c b/sys/netgraph/ng_async.c index 397e7e757681..ca96dbe72f14 100644 --- a/sys/netgraph/ng_async.c +++ b/sys/netgraph/ng_async.c @@ -64,16 +64,13 @@ #include -/* LCP protocol number */ -#define PROTO_LCP 0xc021 - /* Async decode state */ #define MODE_HUNT 0 #define MODE_NORMAL 1 #define MODE_ESC 2 /* Private data structure */ -struct private { +struct ng_async_private { node_p node; /* Our node */ hook_p async; /* Asynchronous side */ hook_p sync; /* Synchronous side */ @@ -86,7 +83,7 @@ struct private { struct ng_async_cfg cfg; /* Configuration */ struct ng_async_stat stats; /* Statistics */ }; -typedef struct private *sc_p; +typedef struct ng_async_private *sc_p; /* Useful macros */ #define ASYNC_BUF_SIZE(smru) (2 * (smru) + 10) @@ -238,7 +235,6 @@ nga_rcvmsg(node_p node, struct ng_mesg *msg, || cfg->smru > NG_ASYNC_MAX_MRU) ERROUT(EINVAL); cfg->enabled = !!cfg->enabled; /* normalize */ - cfg->acfcomp = !!cfg->acfcomp; /* normalize */ if (cfg->smru > sc->cfg.smru) { /* reallocate buffer */ MALLOC(buf, u_char *, ASYNC_BUF_SIZE(cfg->smru), M_NETGRAPH, M_NOWAIT); @@ -358,7 +354,7 @@ static int nga_rcv_sync(const sc_p sc, struct mbuf *m, meta_p meta) { struct ifnet *const rcvif = m->m_pkthdr.rcvif; - int acfcomp, alen, error = 0; + int alen, error = 0; struct timeval time; u_int16_t fcs, fcs0; u_int32_t accm; @@ -371,28 +367,20 @@ nga_rcv_sync(const sc_p sc, struct mbuf *m, meta_p meta) return (error); } - /* Defaults for ACF compression and ACCM */ + /* Get ACCM; special case LCP frames, which use full ACCM */ accm = sc->cfg.accm; - acfcomp = sc->cfg.acfcomp; - - /* Special case LCP frames: disable ACF and enable ACCM */ - { - struct mbuf *n = m; - int off, proto; - - for (proto = off = 0; (proto & 1) == 0; off++) { - while (n != NULL && off >= n->m_len) { - n = n->m_next; - off = 0; - } - if (n == NULL) - break; - proto = (proto << 8) | mtod(n, u_char *)[off]; - } - if (proto == PROTO_LCP) { + if (m->m_pkthdr.len >= 4) { + static const u_char lcphdr[4] = { + PPP_ALLSTATIONS, + PPP_UI, + (u_char)(PPP_LCP >> 8), + (u_char)(PPP_LCP & 0xff) + }; + u_char buf[4]; + + m_copydata(m, 0, 4, (caddr_t)buf); + if (bcmp(buf, &lcphdr, 4) == 0) accm = ~0; - acfcomp = 0; - } } /* Check for overflow */ @@ -417,11 +405,7 @@ nga_rcv_sync(const sc_p sc, struct mbuf *m, meta_p meta) sc->lasttime = time.tv_sec; } - /* Add option address and control fields, then packet payload */ - if (!acfcomp) { - ADD_BYTE(PPP_ALLSTATIONS); - ADD_BYTE(PPP_UI); - } + /* Add packet payload */ while (m != NULL) { struct mbuf *n; -- cgit v1.2.3