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

Go to the source code of this file.

Data Structures

struct  ng_pred1_private
 

Macros

#define PRED1_HDRLEN   2
 
#define PRED1_TABLE_SIZE   0x10000
 
#define PRED1_BUF_SIZE   4096
 
#define PPP_INITFCS   0xffff /* Initial FCS value */
 
#define PPP_GOODFCS   0xf0b8 /* Good final FCS value */
 
#define HASH(x)   priv->Hash = (priv->Hash << 4) ^ (x)
 
#define ERROUT(x)   do { error = (x); goto done; } while (0)
 

Typedefs

typedef struct ng_pred1_privatepriv_p
 

Functions

static MALLOC_DEFINE (M_NETGRAPH_PRED1, "netgraph_pred1", "netgraph pred1 node")
 
static int ng_pred1_compress (node_p node, struct mbuf *m, struct mbuf **resultp)
 
static int ng_pred1_decompress (node_p node, struct mbuf *m, struct mbuf **resultp)
 
static void Pred1Init (node_p node)
 
static int Pred1Compress (node_p node, u_char *source, u_char *dest, int len)
 
static int Pred1Decompress (node_p node, u_char *source, u_char *dest, int slen, int dlen)
 
static void Pred1SyncTable (node_p node, u_char *source, int len)
 
static uint16_t Crc16 (uint16_t fcs, u_char *cp, int len)
 
 NETGRAPH_INIT (pred1, &ng_pred1_typestruct)
 
static int ng_pred1_constructor (node_p node)
 
static int ng_pred1_newhook (node_p node, hook_p hook, const char *name)
 
static int ng_pred1_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static int ng_pred1_rcvdata (hook_p hook, item_p item)
 
static int ng_pred1_shutdown (node_p node)
 
static int ng_pred1_disconnect (hook_p hook)
 

Variables

static ng_constructor_t ng_pred1_constructor
 
static ng_rcvmsg_t ng_pred1_rcvmsg
 
static ng_shutdown_t ng_pred1_shutdown
 
static ng_newhook_t ng_pred1_newhook
 
static ng_rcvdata_t ng_pred1_rcvdata
 
static ng_disconnect_t ng_pred1_disconnect
 
static const uint16_t Crc16Table []
 
static const struct ng_parse_struct_field ng_pred1_config_type_fields [] = NG_PRED1_CONFIG_INFO
 
static const struct ng_parse_type ng_pred1_config_type
 
static const struct ng_parse_struct_field ng_pred1_stats_type_fields [] = NG_PRED1_STATS_INFO
 
static const struct ng_parse_type ng_pred1_stat_type
 
static const struct ng_cmdlist ng_pred1_cmds []
 
static struct ng_type ng_pred1_typestruct
 

Macro Definition Documentation

◆ ERROUT

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

Definition at line 178 of file ng_pred1.c.

◆ HASH

#define HASH (   x)    priv->Hash = (priv->Hash << 4) ^ (x)

Definition at line 69 of file ng_pred1.c.

◆ PPP_GOODFCS

#define PPP_GOODFCS   0xf0b8 /* Good final FCS value */

Definition at line 59 of file ng_pred1.c.

◆ PPP_INITFCS

#define PPP_INITFCS   0xffff /* Initial FCS value */

Definition at line 58 of file ng_pred1.c.

◆ PRED1_BUF_SIZE

#define PRED1_BUF_SIZE   4096

Definition at line 57 of file ng_pred1.c.

◆ PRED1_HDRLEN

#define PRED1_HDRLEN   2

Definition at line 54 of file ng_pred1.c.

◆ PRED1_TABLE_SIZE

#define PRED1_TABLE_SIZE   0x10000

Definition at line 56 of file ng_pred1.c.

Typedef Documentation

◆ priv_p

typedef struct ng_pred1_private* priv_p

Definition at line 83 of file ng_pred1.c.

Function Documentation

◆ Crc16()

static uint16_t Crc16 ( uint16_t  fcs,
u_char *  cp,
int  len 
)
static

Definition at line 676 of file ng_pred1.c.

References Crc16Table.

Referenced by ng_pred1_compress(), and ng_pred1_decompress().

Here is the caller graph for this function:

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_NETGRAPH_PRED1  ,
"netgraph_pred1"  ,
"netgraph pred1 node"   
)
static

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( pred1  ,
ng_pred1_typestruct 
)

◆ ng_pred1_compress()

static int ng_pred1_compress ( node_p  node,
struct mbuf *  m,
struct mbuf **  resultp 
)
static

Definition at line 382 of file ng_pred1.c.

References Crc16(), fcs, NG_FREE_M, NG_NODE_PRIVATE, PPP_INITFCS, PRED1_BUF_SIZE, Pred1Compress(), and priv::stats.

Referenced by ng_pred1_rcvdata().

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

◆ ng_pred1_constructor()

static int ng_pred1_constructor ( node_p  node)
static

Definition at line 188 of file ng_pred1.c.

References NG_NODE_FORCE_WRITER, and NG_NODE_SET_PRIVATE.

◆ ng_pred1_decompress()

static int ng_pred1_decompress ( node_p  node,
struct mbuf *  m,
struct mbuf **  resultp 
)
static

Definition at line 465 of file ng_pred1.c.

References Crc16(), fcs, NG_FREE_M, NG_NODE_PRIVATE, PPP_GOODFCS, PPP_INITFCS, PRED1_BUF_SIZE, Pred1Decompress(), Pred1SyncTable(), and priv::stats.

Referenced by ng_pred1_rcvdata().

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

◆ ng_pred1_disconnect()

static int ng_pred1_disconnect ( hook_p  hook)
static

Definition at line 361 of file ng_pred1.c.

References NG_HOOK_NODE, NG_NODE_IS_VALID, NG_NODE_NUMHOOKS, ng_rmnode_self(), and Pred1Init().

Here is the call graph for this function:

◆ ng_pred1_newhook()

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

◆ ng_pred1_rcvdata()

static int ng_pred1_rcvdata ( hook_p  hook,
item_p  item 
)
static

◆ ng_pred1_rcvmsg()

◆ ng_pred1_shutdown()

static int ng_pred1_shutdown ( node_p  node)
static

Definition at line 347 of file ng_pred1.c.

References NG_NODE_PRIVATE, NG_NODE_SET_PRIVATE, and NG_NODE_UNREF.

◆ Pred1Compress()

static int Pred1Compress ( node_p  node,
u_char *  source,
u_char *  dest,
int  len 
)
static

Definition at line 584 of file ng_pred1.c.

References flags, HASH, and NG_NODE_PRIVATE.

Referenced by ng_pred1_compress().

Here is the caller graph for this function:

◆ Pred1Decompress()

static int Pred1Decompress ( node_p  node,
u_char *  source,
u_char *  dest,
int  slen,
int  dlen 
)
static

Definition at line 619 of file ng_pred1.c.

References flags, HASH, and NG_NODE_PRIVATE.

Referenced by ng_pred1_decompress().

Here is the caller graph for this function:

◆ Pred1Init()

static void Pred1Init ( node_p  node)
static

Definition at line 571 of file ng_pred1.c.

References NG_NODE_PRIVATE, and PRED1_TABLE_SIZE.

Referenced by ng_pred1_disconnect(), and ng_pred1_rcvmsg().

Here is the caller graph for this function:

◆ Pred1SyncTable()

static void Pred1SyncTable ( node_p  node,
u_char *  source,
int  len 
)
static

Definition at line 658 of file ng_pred1.c.

References HASH, and NG_NODE_PRIVATE.

Referenced by ng_pred1_decompress().

Here is the caller graph for this function:

Variable Documentation

◆ Crc16Table

static const uint16_t Crc16Table
static

Definition at line 106 of file ng_pred1.c.

Referenced by Crc16().

◆ ng_pred1_cmds

const struct ng_cmdlist ng_pred1_cmds[]
static

Definition at line 125 of file ng_pred1.c.

◆ ng_pred1_config_type

const struct ng_parse_type ng_pred1_config_type
static
Initial value:
= {
}
const struct ng_parse_type ng_parse_struct_type
Definition: ng_parse.c:222
static const struct ng_parse_struct_field ng_pred1_config_type_fields[]
Definition: ng_pred1.c:110

Definition at line 111 of file ng_pred1.c.

◆ ng_pred1_config_type_fields

const struct ng_parse_struct_field ng_pred1_config_type_fields[] = NG_PRED1_CONFIG_INFO
static

Definition at line 109 of file ng_pred1.c.

◆ ng_pred1_constructor

ng_constructor_t ng_pred1_constructor
static

Definition at line 86 of file ng_pred1.c.

◆ ng_pred1_disconnect

ng_disconnect_t ng_pred1_disconnect
static

Definition at line 91 of file ng_pred1.c.

◆ ng_pred1_newhook

ng_newhook_t ng_pred1_newhook
static

Definition at line 89 of file ng_pred1.c.

◆ ng_pred1_rcvdata

ng_rcvdata_t ng_pred1_rcvdata
static

Definition at line 90 of file ng_pred1.c.

◆ ng_pred1_rcvmsg

ng_rcvmsg_t ng_pred1_rcvmsg
static

Definition at line 87 of file ng_pred1.c.

◆ ng_pred1_shutdown

ng_shutdown_t ng_pred1_shutdown
static

Definition at line 88 of file ng_pred1.c.

◆ ng_pred1_stat_type

const struct ng_parse_type ng_pred1_stat_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_pred1_stats_type_fields[]
Definition: ng_pred1.c:118

Definition at line 119 of file ng_pred1.c.

◆ ng_pred1_stats_type_fields

const struct ng_parse_struct_field ng_pred1_stats_type_fields[] = NG_PRED1_STATS_INFO
static

Definition at line 117 of file ng_pred1.c.

◆ ng_pred1_typestruct

struct ng_type ng_pred1_typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.constructor = ng_pred1_constructor,
.rcvmsg = ng_pred1_rcvmsg,
.shutdown = ng_pred1_shutdown,
.newhook = ng_pred1_newhook,
.rcvdata = ng_pred1_rcvdata,
.disconnect = ng_pred1_disconnect,
.cmdlist = ng_pred1_cmds,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_rcvdata_t ng_pred1_rcvdata
Definition: ng_pred1.c:90
static ng_disconnect_t ng_pred1_disconnect
Definition: ng_pred1.c:91
static ng_constructor_t ng_pred1_constructor
Definition: ng_pred1.c:86
static ng_rcvmsg_t ng_pred1_rcvmsg
Definition: ng_pred1.c:87
static const struct ng_cmdlist ng_pred1_cmds[]
Definition: ng_pred1.c:125
static ng_shutdown_t ng_pred1_shutdown
Definition: ng_pred1.c:88
static ng_newhook_t ng_pred1_newhook
Definition: ng_pred1.c:89
#define NG_PRED1_NODE_TYPE
Definition: ng_pred1.h:36

Definition at line 165 of file ng_pred1.c.