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).
This commit is contained in:
Archie Cobbs 1999-11-19 04:27:53 +00:00
parent 3a58352eb0
commit 19a52c592d
2 changed files with 16 additions and 33 deletions

View File

@ -64,16 +64,13 @@
#include <net/ppp_defs.h>
/* 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;
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];
/* 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) {
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;

View File

@ -45,7 +45,7 @@
/* Type name and cookie */
#define NG_ASYNC_NODE_TYPE "async"
#define NGM_ASYNC_COOKIE 886473716
#define NGM_ASYNC_COOKIE 886473717
/* Hook names */
#define NG_ASYNC_HOOK_SYNC "sync" /* Sync frames */
@ -71,7 +71,6 @@ struct ng_async_stat {
/* Configuration for this node */
struct ng_async_cfg {
u_char enabled; /* Turn encoding on/off */
u_char acfcomp; /* Address/control field compression */
u_int16_t amru; /* Max receive async frame length */
u_int16_t smru; /* Max receive sync frame length */
u_int32_t accm; /* ACCM encoding */