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

Go to the source code of this file.

Data Structures

struct  nglmi_softc
 

Macros

#define NAME_ANNEXA   NG_LMI_HOOK_ANNEXA
 
#define NAME_ANNEXD   NG_LMI_HOOK_ANNEXD
 
#define NAME_GROUP4   NG_LMI_HOOK_GROUPOF4
 
#define NAME_NONE   "None"
 
#define MAX_DLCIS   128
 
#define MAXDLCI   1023
 
#define DLCI_NULL   0
 
#define DLCI_UP   1
 
#define DLCI_DOWN   2
 
#define LMI_MIN_LENGTH   8 /* XXX verify */
 
#define SCF_CONNECTED   0x01 /* connected to something */
 
#define SCF_AUTO   0x02 /* we are auto-detecting */
 
#define SCF_FIXED   0x04 /* we are fixed from the start */
 
#define SCF_LMITYPE   0x18 /* mask for determining Annex mode */
 
#define SCF_NOLMI   0x00 /* no LMI type selected yet */
 
#define SCF_ANNEX_A   0x08 /* running annex A mode */
 
#define SCF_ANNEX_D   0x10 /* running annex D mode */
 
#define SCF_GROUP4   0x18 /* running group of 4 */
 
#define SETLMITYPE(sc, annex)
 
#define NOPROTO(sc)   (((sc)->flags & SCF_LMITYPE) == SCF_NOLMI)
 
#define ANNEXA(sc)   (((sc)->flags & SCF_LMITYPE) == SCF_ANNEX_A)
 
#define ANNEXD(sc)   (((sc)->flags & SCF_LMITYPE) == SCF_ANNEX_D)
 
#define GROUP4(sc)   (((sc)->flags & SCF_LMITYPE) == SCF_GROUP4)
 
#define LMIPOLLSIZE   3
 
#define LMI_PATIENCE   8 /* declare all DLCI DOWN after N LMI failures */
 
#define STEPBY(stepsize)
 

Typedefs

typedef struct nglmi_softcsc_p
 

Functions

static int nglmi_checkdata (hook_p hook, struct mbuf *m)
 
 NETGRAPH_INIT (lmi, &typestruct)
 
static void LMI_ticker (node_p node, hook_p hook, void *arg1, int arg2)
 
static void nglmi_startup_fixed (sc_p sc, hook_p hook)
 
static void nglmi_startup_auto (sc_p sc)
 
static void nglmi_startup (sc_p sc)
 
static void nglmi_inquire (sc_p sc, int full)
 
static void ngauto_state_machine (sc_p sc)
 
static int nglmi_constructor (node_p node)
 
static int nglmi_newhook (node_p node, hook_p hook, const char *name)
 
static int nglmi_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static int nglmi_rcvdata (hook_p hook, item_p item)
 
static int nglmi_shutdown (node_p node)
 
static int nglmi_disconnect (hook_p hook)
 

Variables

static ng_constructor_t nglmi_constructor
 
static ng_rcvmsg_t nglmi_rcvmsg
 
static ng_shutdown_t nglmi_shutdown
 
static ng_newhook_t nglmi_newhook
 
static ng_rcvdata_t nglmi_rcvdata
 
static ng_disconnect_t nglmi_disconnect
 
static struct ng_type typestruct
 

Macro Definition Documentation

◆ ANNEXA

#define ANNEXA (   sc)    (((sc)->flags & SCF_LMITYPE) == SCF_ANNEX_A)

Definition at line 173 of file ng_lmi.c.

◆ ANNEXD

#define ANNEXD (   sc)    (((sc)->flags & SCF_LMITYPE) == SCF_ANNEX_D)

Definition at line 174 of file ng_lmi.c.

◆ DLCI_DOWN

#define DLCI_DOWN   2

Definition at line 83 of file ng_lmi.c.

◆ DLCI_NULL

#define DLCI_NULL   0

Definition at line 81 of file ng_lmi.c.

◆ DLCI_UP

#define DLCI_UP   1

Definition at line 82 of file ng_lmi.c.

◆ GROUP4

#define GROUP4 (   sc)    (((sc)->flags & SCF_LMITYPE) == SCF_GROUP4)

Definition at line 175 of file ng_lmi.c.

◆ LMI_MIN_LENGTH

#define LMI_MIN_LENGTH   8 /* XXX verify */

Definition at line 88 of file ng_lmi.c.

◆ LMI_PATIENCE

#define LMI_PATIENCE   8 /* declare all DLCI DOWN after N LMI failures */

Definition at line 178 of file ng_lmi.c.

◆ LMIPOLLSIZE

#define LMIPOLLSIZE   3

Definition at line 177 of file ng_lmi.c.

◆ MAX_DLCIS

#define MAX_DLCIS   128

Definition at line 75 of file ng_lmi.c.

◆ MAXDLCI

#define MAXDLCI   1023

Definition at line 76 of file ng_lmi.c.

◆ NAME_ANNEXA

#define NAME_ANNEXA   NG_LMI_HOOK_ANNEXA

Definition at line 70 of file ng_lmi.c.

◆ NAME_ANNEXD

#define NAME_ANNEXD   NG_LMI_HOOK_ANNEXD

Definition at line 71 of file ng_lmi.c.

◆ NAME_GROUP4

#define NAME_GROUP4   NG_LMI_HOOK_GROUPOF4

Definition at line 72 of file ng_lmi.c.

◆ NAME_NONE

#define NAME_NONE   "None"

Definition at line 73 of file ng_lmi.c.

◆ NOPROTO

#define NOPROTO (   sc)    (((sc)->flags & SCF_LMITYPE) == SCF_NOLMI)

Definition at line 172 of file ng_lmi.c.

◆ SCF_ANNEX_A

#define SCF_ANNEX_A   0x08 /* running annex A mode */

Definition at line 162 of file ng_lmi.c.

◆ SCF_ANNEX_D

#define SCF_ANNEX_D   0x10 /* running annex D mode */

Definition at line 163 of file ng_lmi.c.

◆ SCF_AUTO

#define SCF_AUTO   0x02 /* we are auto-detecting */

Definition at line 157 of file ng_lmi.c.

◆ SCF_CONNECTED

#define SCF_CONNECTED   0x01 /* connected to something */

Definition at line 156 of file ng_lmi.c.

◆ SCF_FIXED

#define SCF_FIXED   0x04 /* we are fixed from the start */

Definition at line 158 of file ng_lmi.c.

◆ SCF_GROUP4

#define SCF_GROUP4   0x18 /* running group of 4 */

Definition at line 164 of file ng_lmi.c.

◆ SCF_LMITYPE

#define SCF_LMITYPE   0x18 /* mask for determining Annex mode */

Definition at line 160 of file ng_lmi.c.

◆ SCF_NOLMI

#define SCF_NOLMI   0x00 /* no LMI type selected yet */

Definition at line 161 of file ng_lmi.c.

◆ SETLMITYPE

#define SETLMITYPE (   sc,
  annex 
)
Value:
do { \
(sc)->flags &= ~SCF_LMITYPE; \
(sc)->flags |= (annex); \
} while (0)
uint8_t flags
Definition: netflow.h:14
#define SCF_LMITYPE
Definition: ng_lmi.c:160

Definition at line 166 of file ng_lmi.c.

◆ STEPBY

#define STEPBY (   stepsize)
Value:
do { \
packetlen -= (stepsize); \
data += (stepsize); \
} while (0)

Definition at line 542 of file ng_lmi.c.

Typedef Documentation

◆ sc_p

typedef struct nglmi_softc* sc_p

Definition at line 140 of file ng_lmi.c.

Function Documentation

◆ LMI_ticker()

static void LMI_ticker ( node_p  node,
hook_p  hook,
void *  arg1,
int  arg2 
)
static

Definition at line 262 of file ng_lmi.c.

References LMI_ticker(), ng_callout(), NG_LMI_POLL_RATE, NG_NODE_PRIVATE, ngauto_state_machine(), nglmi_inquire(), nglmi_softc::node, and SCF_AUTO.

Referenced by LMI_ticker(), and nglmi_startup().

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

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( lmi  ,
typestruct 
)

◆ ngauto_state_machine()

static void ngauto_state_machine ( sc_p  sc)
static

Definition at line 393 of file ng_lmi.c.

References LMIPOLLSIZE, nglmi_inquire(), SCF_ANNEX_A, SCF_ANNEX_D, SCF_GROUP4, and SETLMITYPE.

Referenced by LMI_ticker().

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

◆ nglmi_checkdata()

static int nglmi_checkdata ( hook_p  hook,
struct mbuf *  m 
)
static

Definition at line 735 of file ng_lmi.c.

References ANNEXD, data, dlci, GROUP4, NG_FREE_M, NG_HOOK_NODE, NG_NODE_PRIVATE, SCF_ANNEX_A, SCF_ANNEX_D, SCF_AUTO, SCF_GROUP4, SCF_NOLMI, SETLMITYPE, STEPBY, and type.

Referenced by nglmi_rcvdata().

Here is the caller graph for this function:

◆ nglmi_constructor()

static int nglmi_constructor ( node_p  node)
static

◆ nglmi_disconnect()

static int nglmi_disconnect ( hook_p  hook)
static

Definition at line 1063 of file ng_lmi.c.

References NG_HOOK_NODE, NG_HOOK_PRIVATE, NG_NODE_IS_VALID, NG_NODE_PRIVATE, ng_rmnode_self(), ng_uncallout(), ng_async_private::node, and SCF_CONNECTED.

Here is the call graph for this function:

◆ nglmi_inquire()

static void nglmi_inquire ( sc_p  sc,
int  full 
)
static

◆ nglmi_newhook()

◆ nglmi_rcvdata()

static int nglmi_rcvdata ( hook_p  hook,
item_p  item 
)
static

◆ nglmi_rcvmsg()

◆ nglmi_shutdown()

static int nglmi_shutdown ( node_p  node)
static

Definition at line 1048 of file ng_lmi.c.

References NG_NODE_PRIVATE, NG_NODE_SET_PRIVATE, NG_NODE_UNREF, and ng_async_private::node.

◆ nglmi_startup()

static void nglmi_startup ( sc_p  sc)
static

Definition at line 300 of file ng_lmi.c.

References LMI_ticker(), ng_callout(), and ng_async_private::node.

Referenced by nglmi_startup_auto(), and nglmi_startup_fixed().

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

◆ nglmi_startup_auto()

static void nglmi_startup_auto ( sc_p  sc)
static

Definition at line 291 of file ng_lmi.c.

References nglmi_startup(), SCF_AUTO, and SCF_CONNECTED.

Referenced by nglmi_newhook().

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

◆ nglmi_startup_fixed()

static void nglmi_startup_fixed ( sc_p  sc,
hook_p  hook 
)
static

Definition at line 283 of file ng_lmi.c.

References nglmi_startup(), SCF_CONNECTED, and SCF_FIXED.

Referenced by nglmi_newhook().

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

Variable Documentation

◆ nglmi_constructor

ng_constructor_t nglmi_constructor
static

Definition at line 93 of file ng_lmi.c.

◆ nglmi_disconnect

ng_disconnect_t nglmi_disconnect
static

Definition at line 98 of file ng_lmi.c.

◆ nglmi_newhook

ng_newhook_t nglmi_newhook
static

Definition at line 96 of file ng_lmi.c.

◆ nglmi_rcvdata

ng_rcvdata_t nglmi_rcvdata
static

Definition at line 97 of file ng_lmi.c.

◆ nglmi_rcvmsg

ng_rcvmsg_t nglmi_rcvmsg
static

Definition at line 94 of file ng_lmi.c.

◆ nglmi_shutdown

ng_shutdown_t nglmi_shutdown
static

Definition at line 95 of file ng_lmi.c.

◆ typestruct

struct ng_type typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.constructor = nglmi_constructor,
.rcvmsg = nglmi_rcvmsg,
.shutdown = nglmi_shutdown,
.newhook = nglmi_newhook,
.rcvdata = nglmi_rcvdata,
.disconnect = nglmi_disconnect,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_disconnect_t nglmi_disconnect
Definition: ng_lmi.c:98
static ng_shutdown_t nglmi_shutdown
Definition: ng_lmi.c:95
static ng_newhook_t nglmi_newhook
Definition: ng_lmi.c:96
static ng_rcvmsg_t nglmi_rcvmsg
Definition: ng_lmi.c:94
static ng_constructor_t nglmi_constructor
Definition: ng_lmi.c:93
static ng_rcvdata_t nglmi_rcvdata
Definition: ng_lmi.c:97
#define NG_LMI_NODE_TYPE
Definition: ng_lmi.h:48

Definition at line 101 of file ng_lmi.c.