FreeBSD kernel netgraph code
ng_frame_relay.c File Reference
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/errno.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/syslog.h>
#include <sys/ctype.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_frame_relay.h>
Include dependency graph for ng_frame_relay.c:

Go to the source code of this file.

Data Structures

struct  ctxinfo
 
struct  frmrel_softc
 
struct  segment
 

Macros

#define CHAN_VALID   0x01 /* assigned to a channel */
 
#define CHAN_ACTIVE   0x02 /* bottom level active */
 
#define MAX_CT   16 /* # of dlci's active at a time (POWER OF 2!) */
 
#define CTX_VALID   0x8000 /* this bit means it's a valid CTX */
 
#define CTX_VALUE   (MAX_CT - 1) /* mask for context part */
 
#define BYTEX_EA   0x01 /* End Address. Always 0 on byte1 */
 
#define BYTE1_C_R   0x02
 
#define BYTE2_FECN   0x08 /* forwards congestion notification */
 
#define BYTE2_BECN   0x04 /* Backward congestion notification */
 
#define BYTE2_DE   0x02 /* Discard elligability */
 
#define LASTBYTE_D_C   0x02 /* last byte is dl_core or dlci info */
 
#define SHIFTIN(segment, byte, dlci)
 
#define SHIFTOUT(segment, byte, dlci)
 
#define ERROUT(x)   do { error = (x); goto done; } while (0)
 

Typedefs

typedef struct frmrel_softcsc_p
 

Functions

static int ngfrm_decode (node_p node, item_p item)
 
static int ngfrm_addrlen (char *hdr)
 
static int ngfrm_allocate_CTX (sc_p sc, int dlci)
 
 NETGRAPH_INIT (framerelay, &typestruct)
 
static int ngfrm_constructor (node_p node)
 
static int ngfrm_newhook (node_p node, hook_p hook, const char *name)
 
static int ngfrm_rcvdata (hook_p hook, item_p item)
 
static int ngfrm_shutdown (node_p node)
 
static int ngfrm_disconnect (hook_p hook)
 

Variables

static const struct segment makeup []
 
static ng_constructor_t ngfrm_constructor
 
static ng_shutdown_t ngfrm_shutdown
 
static ng_newhook_t ngfrm_newhook
 
static ng_rcvdata_t ngfrm_rcvdata
 
static ng_disconnect_t ngfrm_disconnect
 
static struct ng_type typestruct
 

Macro Definition Documentation

◆ BYTE1_C_R

#define BYTE1_C_R   0x02

Definition at line 96 of file ng_frame_relay.c.

◆ BYTE2_BECN

#define BYTE2_BECN   0x04 /* Backward congestion notification */

Definition at line 98 of file ng_frame_relay.c.

◆ BYTE2_DE

#define BYTE2_DE   0x02 /* Discard elligability */

Definition at line 99 of file ng_frame_relay.c.

◆ BYTE2_FECN

#define BYTE2_FECN   0x08 /* forwards congestion notification */

Definition at line 97 of file ng_frame_relay.c.

◆ BYTEX_EA

#define BYTEX_EA   0x01 /* End Address. Always 0 on byte1 */

Definition at line 95 of file ng_frame_relay.c.

◆ CHAN_ACTIVE

#define CHAN_ACTIVE   0x02 /* bottom level active */

Definition at line 72 of file ng_frame_relay.c.

◆ CHAN_VALID

#define CHAN_VALID   0x01 /* assigned to a channel */

Definition at line 71 of file ng_frame_relay.c.

◆ CTX_VALID

#define CTX_VALID   0x8000 /* this bit means it's a valid CTX */

Definition at line 88 of file ng_frame_relay.c.

◆ CTX_VALUE

#define CTX_VALUE   (MAX_CT - 1) /* mask for context part */

Definition at line 89 of file ng_frame_relay.c.

◆ ERROUT

#define ERROUT (   x)    do { error = (x); goto done; } while (0)

Definition at line 151 of file ng_frame_relay.c.

◆ LASTBYTE_D_C

#define LASTBYTE_D_C   0x02 /* last byte is dl_core or dlci info */

Definition at line 100 of file ng_frame_relay.c.

◆ MAX_CT

#define MAX_CT   16 /* # of dlci's active at a time (POWER OF 2!) */

Definition at line 77 of file ng_frame_relay.c.

◆ SHIFTIN

#define SHIFTIN (   segment,
  byte,
  dlci 
)
Value:
{ \
(dlci) <<= (segment)->width; \
(dlci) |= \
(((byte) & (segment)->mask) >> (segment)->shift); \
}
u_int8_t dlci

Definition at line 114 of file ng_frame_relay.c.

◆ SHIFTOUT

#define SHIFTOUT (   segment,
  byte,
  dlci 
)
Value:
{ \
(byte) |= (((dlci) << (segment)->shift) & (segment)->mask); \
(dlci) >>= (segment)->width; \
}

Definition at line 121 of file ng_frame_relay.c.

Typedef Documentation

◆ sc_p

typedef struct frmrel_softc* sc_p

Definition at line 93 of file ng_frame_relay.c.

Function Documentation

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( framerelay  ,
typestruct 
)

◆ ngfrm_addrlen()

int ngfrm_addrlen ( char *  hdr)
static

Definition at line 311 of file ng_frame_relay.c.

References BYTEX_EA.

Referenced by ngfrm_decode().

Here is the caller graph for this function:

◆ ngfrm_allocate_CTX()

static int ngfrm_allocate_CTX ( sc_p  sc,
int  dlci 
)
static

Definition at line 158 of file ng_frame_relay.c.

References CHAN_VALID, CTX_VALID, CTX_VALUE, dlci, and MAX_CT.

Referenced by ngfrm_newhook().

Here is the caller graph for this function:

◆ ngfrm_constructor()

static int ngfrm_constructor ( node_p  node)
static

Definition at line 213 of file ng_frame_relay.c.

References NG_NODE_SET_PRIVATE, and ng_async_private::node.

◆ ngfrm_decode()

static int ngfrm_decode ( node_p  node,
item_p  item 
)
static

Definition at line 409 of file ng_frame_relay.c.

References CTX_VALID, CTX_VALUE, data, dlci, ERROUT, makeup, NG_FREE_ITEM, NG_FREE_M, NG_FWD_NEW_DATA, NG_NODE_PRIVATE, ngfrm_addrlen(), NGI_GET_M, and SHIFTIN.

Referenced by ngfrm_rcvdata().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ngfrm_disconnect()

static int ngfrm_disconnect ( hook_p  hook)
static

Definition at line 484 of file ng_frame_relay.c.

References dlci, ctxinfo::dlci, ctxinfo::flags, ctxinfo::hook, NG_HOOK_NODE, NG_HOOK_PRIVATE, NG_NODE_IS_VALID, NG_NODE_NUMHOOKS, NG_NODE_PRIVATE, and ng_rmnode_self().

Here is the call graph for this function:

◆ ngfrm_newhook()

static int ngfrm_newhook ( node_p  node,
hook_p  hook,
const char *  name 
)
static

◆ ngfrm_rcvdata()

static int ngfrm_rcvdata ( hook_p  hook,
item_p  item 
)
static

◆ ngfrm_shutdown()

static int ngfrm_shutdown ( node_p  node)
static

Definition at line 467 of file ng_frame_relay.c.

References NG_NODE_PRIVATE, NG_NODE_SET_PRIVATE, and NG_NODE_UNREF.

Variable Documentation

◆ makeup

const struct segment makeup[]
static
Initial value:
= {
{ 0xfc, 2, 6 },
{ 0xf0, 4, 4 },
{ 0xfe, 1, 7 },
{ 0xfc, 2, 6 }
}

Referenced by ngfrm_decode(), and ngfrm_rcvdata().

◆ ngfrm_constructor

ng_constructor_t ngfrm_constructor
static

Definition at line 128 of file ng_frame_relay.c.

◆ ngfrm_disconnect

ng_disconnect_t ngfrm_disconnect
static

Definition at line 132 of file ng_frame_relay.c.

◆ ngfrm_newhook

ng_newhook_t ngfrm_newhook
static

Definition at line 130 of file ng_frame_relay.c.

◆ ngfrm_rcvdata

ng_rcvdata_t ngfrm_rcvdata
static

Definition at line 131 of file ng_frame_relay.c.

◆ ngfrm_shutdown

ng_shutdown_t ngfrm_shutdown
static

Definition at line 129 of file ng_frame_relay.c.

◆ typestruct

struct ng_type typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.constructor = ngfrm_constructor,
.shutdown = ngfrm_shutdown,
.newhook = ngfrm_newhook,
.rcvdata = ngfrm_rcvdata,
.disconnect = ngfrm_disconnect,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_shutdown_t ngfrm_shutdown
static ng_newhook_t ngfrm_newhook
static ng_constructor_t ngfrm_constructor
static ng_disconnect_t ngfrm_disconnect
static ng_rcvdata_t ngfrm_rcvdata
#define NG_FRAMERELAY_NODE_TYPE

Definition at line 140 of file ng_frame_relay.c.