55#include <sys/kernel.h>
57#include <sys/malloc.h>
59#include <sys/syslog.h>
71#define CHAN_VALID 0x01
72#define CHAN_ACTIVE 0x02
88#define CTX_VALID 0x8000
89#define CTX_VALUE (MAX_CT - 1)
97#define BYTE2_FECN 0x08
98#define BYTE2_BECN 0x04
100#define LASTBYTE_D_C 0x02
114#define SHIFTIN(segment, byte, dlci) \
116 (dlci) <<= (segment)->width; \
118 (((byte) & (segment)->mask) >> (segment)->shift); \
121#define SHIFTOUT(segment, byte, dlci) \
123 (byte) |= (((dlci) << (segment)->shift) & (segment)->mask); \
124 (dlci) >>= (segment)->width; \
151#define ERROUT(x) do { error = (x); goto done; } while (0)
161 volatile struct ctxinfo *CTXp = NULL;
170 CTXp = sc->channel + ctxnum;
182 for (ctxnum = 0; ctxnum <
MAX_CT; ctxnum++) {
186 if ((sc->channel[ctxnum].flags &
CHAN_VALID) == 0) {
187 bzero(sc->channel + ctxnum,
189 CTXp = sc->channel + ctxnum;
191 sc->channel[ctxnum].dlci =
dlci;
203 log(LOG_ERR,
"No CTX available for dlci %d\n",
dlci);
217 sc = malloc(
sizeof(*sc), M_NETGRAPH, M_WAITOK | M_ZERO);
260 if (sc->downstream.hook)
265 sc->downstream.hook =
hook;
266 sc->downstream.dlci = -1;
274 if (!isdigit(*cp) || (cp[0] ==
'0' && cp[1] !=
'\0'))
276 dlci = (int)strtoul(cp, &eptr, 10);
277 if (*eptr !=
'\0' || dlci < 0 || dlci > 1023)
294 if (sc->channel[ctxnum].hook != NULL)
302 sc->channel[ctxnum].hook =
hook;
331 struct mbuf *m = NULL;
352 if ((sc->downstream.hook == NULL)
360 M_PREPEND(m, alen, M_NOWAIT);
363 data = mtod(m,
char *);
392 panic(
"%s", __func__);
420 if (m->m_len < 4 && (m = m_pullup(m, 4)) == NULL)
422 data = mtod(m,
char *);
423 if ((alen = sc->addrlen) == 0) {
448 ctxnum = sc->ALT[
dlci];
472 free(sc, M_NETGRAPH);
#define NG_HOOK_NODE(hook)
int ng_disconnect_t(hook_p hook)
#define NG_NODE_SET_PRIVATE(node, val)
#define NG_NODE_IS_VALID(node)
#define NG_NODE_UNREF(node)
#define NG_HOOK_SET_PRIVATE(hook, val)
int ng_rmnode_self(node_p here)
#define NG_FWD_NEW_DATA(error, item, hook, m)
int ng_rcvdata_t(hook_p hook, item_p item)
int ng_shutdown_t(node_p node)
#define NG_FREE_ITEM(item)
int ng_constructor_t(node_p node)
#define NG_NODE_NUMHOOKS(node)
#define NG_NODE_PRIVATE(node)
int ng_newhook_t(node_p node, hook_p hook, const char *name)
#define NG_HOOK_PRIVATE(hook)
static const struct segment makeup[]
static int ngfrm_decode(node_p node, item_p item)
static int ngfrm_addrlen(char *hdr)
static ng_shutdown_t ngfrm_shutdown
#define SHIFTIN(segment, byte, dlci)
static int ngfrm_allocate_CTX(sc_p sc, int dlci)
#define SHIFTOUT(segment, byte, dlci)
static struct ng_type typestruct
static ng_newhook_t ngfrm_newhook
static ng_constructor_t ngfrm_constructor
static ng_disconnect_t ngfrm_disconnect
struct frmrel_softc * sc_p
static ng_rcvdata_t ngfrm_rcvdata
NETGRAPH_INIT(framerelay, &typestruct)
#define NG_FRAMERELAY_NODE_TYPE
#define NG_FRAMERELAY_HOOK_DOWNSTREAM
#define NG_FRAMERELAY_HOOK_DEBUG
#define NG_FRAMERELAY_HOOK_DLCI
struct ctxinfo downstream
struct ctxinfo channel[MAX_CT]