FreeBSD kernel netgraph code
ng_mppc.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/endian.h>
#include <sys/errno.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_mppc.h>
#include "opt_netgraph.h"
#include <crypto/sha1.h>
Include dependency graph for ng_mppc.c:

Go to the source code of this file.

Data Structures

struct  ng_mppc_dir
 
struct  ng_mppc_private
 

Macros

#define M_NETGRAPH_MPPC   M_NETGRAPH
 
#define MPPC_DECOMP_BUFSIZE   8092 /* allocate buffer this big */
 
#define MPPC_DECOMP_SAFETY   100 /* plus this much margin */
 
#define MPPC_HDRLEN   2
 
#define KEYLEN(b)   (((b) & MPPE_128) ? 16 : 8)
 
#define MPPE_MAX_REKEY   1000
 
#define MPPC_FLAG_FLUSHED   0x8000 /* xmitter reset state */
 
#define MPPC_FLAG_RESTART   0x4000 /* compress history restart */
 
#define MPPC_FLAG_COMPRESSED   0x2000 /* packet is compresed */
 
#define MPPC_FLAG_ENCRYPTED   0x1000 /* packet is encrypted */
 
#define MPPC_CCOUNT_MASK   0x0fff /* sequence number mask */
 
#define MPPC_CCOUNT_INC(d)   ((d) = (((d) + 1) & MPPC_CCOUNT_MASK))
 
#define MPPE_UPDATE_MASK   0xff /* coherency count when we're */
 
#define MPPE_UPDATE_FLAG   0xff /* supposed to update key */
 
#define MPPC_COMP_OK   0x05
 
#define MPPC_DECOMP_OK   0x05
 
#define ERROUT(x)   do { error = (x); goto done; } while (0)
 

Typedefs

typedef struct ng_mppc_privatepriv_p
 

Functions

 SYSCTL_NODE (_net_graph, OID_AUTO, mppe, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "MPPE")
 
 SYSCTL_INT (_net_graph_mppe, OID_AUTO, block_on_max_rekey, CTLFLAG_RWTUN, &mppe_block_on_max_rekey, 0, "Block node on max MPPE key re-calculations")
 
 SYSCTL_INT (_net_graph_mppe, OID_AUTO, log_max_rekey, CTLFLAG_RWTUN, &mppe_log_max_rekey, 0, "Log max MPPE key re-calculations event")
 
 SYSCTL_INT (_net_graph_mppe, OID_AUTO, max_rekey, CTLFLAG_RWTUN, &mppe_max_rekey, 0, "Maximum number of MPPE key re-calculations")
 
static int ng_mppc_compress (node_p node, struct mbuf **datap)
 
static int ng_mppc_decompress (node_p node, struct mbuf **datap)
 
static void ng_mppc_reset_req (node_p node)
 
 NETGRAPH_INIT (mppc, &ng_mppc_typestruct)
 
static int ng_mppc_constructor (node_p node)
 
static int ng_mppc_newhook (node_p node, hook_p hook, const char *name)
 
static int ng_mppc_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static int ng_mppc_rcvdata (hook_p hook, item_p item)
 
static int ng_mppc_shutdown (node_p node)
 
static int ng_mppc_disconnect (hook_p hook)
 

Variables

static int mppe_block_on_max_rekey = 0
 
static int mppe_log_max_rekey = 1
 
static int mppe_max_rekey = MPPE_MAX_REKEY
 
static ng_constructor_t ng_mppc_constructor
 
static ng_rcvmsg_t ng_mppc_rcvmsg
 
static ng_shutdown_t ng_mppc_shutdown
 
static ng_newhook_t ng_mppc_newhook
 
static ng_rcvdata_t ng_mppc_rcvdata
 
static ng_disconnect_t ng_mppc_disconnect
 
static struct ng_type ng_mppc_typestruct
 
static const u_char ng_mppe_weakenkey [3] = { 0xd1, 0x26, 0x9e }
 

Macro Definition Documentation

◆ ERROUT

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

Definition at line 204 of file ng_mppc.c.

◆ KEYLEN

#define KEYLEN (   b)    (((b) & MPPE_128) ? 16 : 8)

Definition at line 99 of file ng_mppc.c.

◆ M_NETGRAPH_MPPC

#define M_NETGRAPH_MPPC   M_NETGRAPH

Definition at line 80 of file ng_mppc.c.

◆ MPPC_CCOUNT_INC

#define MPPC_CCOUNT_INC (   d)    ((d) = (((d) + 1) & MPPC_CCOUNT_MASK))

Definition at line 132 of file ng_mppc.c.

◆ MPPC_CCOUNT_MASK

#define MPPC_CCOUNT_MASK   0x0fff /* sequence number mask */

Definition at line 130 of file ng_mppc.c.

◆ MPPC_COMP_OK

#define MPPC_COMP_OK   0x05

Definition at line 137 of file ng_mppc.c.

◆ MPPC_DECOMP_BUFSIZE

#define MPPC_DECOMP_BUFSIZE   8092 /* allocate buffer this big */

Definition at line 92 of file ng_mppc.c.

◆ MPPC_DECOMP_OK

#define MPPC_DECOMP_OK   0x05

Definition at line 138 of file ng_mppc.c.

◆ MPPC_DECOMP_SAFETY

#define MPPC_DECOMP_SAFETY   100 /* plus this much margin */

Definition at line 93 of file ng_mppc.c.

◆ MPPC_FLAG_COMPRESSED

#define MPPC_FLAG_COMPRESSED   0x2000 /* packet is compresed */

Definition at line 128 of file ng_mppc.c.

◆ MPPC_FLAG_ENCRYPTED

#define MPPC_FLAG_ENCRYPTED   0x1000 /* packet is encrypted */

Definition at line 129 of file ng_mppc.c.

◆ MPPC_FLAG_FLUSHED

#define MPPC_FLAG_FLUSHED   0x8000 /* xmitter reset state */

Definition at line 126 of file ng_mppc.c.

◆ MPPC_FLAG_RESTART

#define MPPC_FLAG_RESTART   0x4000 /* compress history restart */

Definition at line 127 of file ng_mppc.c.

◆ MPPC_HDRLEN

#define MPPC_HDRLEN   2

Definition at line 96 of file ng_mppc.c.

◆ MPPE_MAX_REKEY

#define MPPE_MAX_REKEY   1000

Definition at line 108 of file ng_mppc.c.

◆ MPPE_UPDATE_FLAG

#define MPPE_UPDATE_FLAG   0xff /* supposed to update key */

Definition at line 135 of file ng_mppc.c.

◆ MPPE_UPDATE_MASK

#define MPPE_UPDATE_MASK   0xff /* coherency count when we're */

Definition at line 134 of file ng_mppc.c.

Typedef Documentation

◆ priv_p

typedef struct ng_mppc_private* priv_p

Definition at line 161 of file ng_mppc.c.

Function Documentation

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( mppc  ,
ng_mppc_typestruct 
)

◆ ng_mppc_compress()

◆ ng_mppc_constructor()

static int ng_mppc_constructor ( node_p  node)
static

Definition at line 214 of file ng_mppc.c.

References M_NETGRAPH_MPPC, NG_NODE_FORCE_WRITER, and NG_NODE_SET_PRIVATE.

◆ ng_mppc_decompress()

◆ ng_mppc_disconnect()

static int ng_mppc_disconnect ( hook_p  hook)
static

Definition at line 450 of file ng_mppc.c.

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

Here is the call graph for this function:

◆ ng_mppc_newhook()

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

Definition at line 234 of file ng_mppc.c.

References name, NG_MPPC_HOOK_COMP, NG_MPPC_HOOK_DECOMP, and NG_NODE_PRIVATE.

◆ ng_mppc_rcvdata()

static int ng_mppc_rcvdata ( hook_p  hook,
item_p  item 
)
static

◆ ng_mppc_rcvmsg()

◆ ng_mppc_reset_req()

static void ng_mppc_reset_req ( node_p  node)
static

Definition at line 842 of file ng_mppc.c.

References ng_mppc_config::bits, ng_mppc_dir::cfg, ng_mppc_dir::flushed, KEYLEN, MPPE_STATELESS, and NG_NODE_PRIVATE.

Referenced by ng_mppc_rcvmsg().

Here is the caller graph for this function:

◆ ng_mppc_shutdown()

static int ng_mppc_shutdown ( node_p  node)
static

Definition at line 428 of file ng_mppc.c.

References M_NETGRAPH_MPPC, NG_NODE_PRIVATE, NG_NODE_SET_PRIVATE, and NG_NODE_UNREF.

◆ SYSCTL_INT() [1/3]

SYSCTL_INT ( _net_graph_mppe  ,
OID_AUTO  ,
block_on_max_rekey  ,
CTLFLAG_RWTUN  ,
mppe_block_on_max_rekey,
,
"Block node on max MPPE key re-calculations"   
)

◆ SYSCTL_INT() [2/3]

SYSCTL_INT ( _net_graph_mppe  ,
OID_AUTO  ,
log_max_rekey  ,
CTLFLAG_RWTUN  ,
mppe_log_max_rekey,
,
"Log max MPPE key re-calculations event  
)

◆ SYSCTL_INT() [3/3]

SYSCTL_INT ( _net_graph_mppe  ,
OID_AUTO  ,
max_rekey  ,
CTLFLAG_RWTUN  ,
mppe_max_rekey,
,
"Maximum number of MPPE key re-calculations"   
)

◆ SYSCTL_NODE()

SYSCTL_NODE ( _net_graph  ,
OID_AUTO  ,
mppe  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
"MPPE"   
)

Variable Documentation

◆ mppe_block_on_max_rekey

int mppe_block_on_max_rekey = 0
static

Definition at line 113 of file ng_mppc.c.

Referenced by ng_mppc_decompress().

◆ mppe_log_max_rekey

int mppe_log_max_rekey = 1
static

Definition at line 117 of file ng_mppc.c.

Referenced by ng_mppc_decompress().

◆ mppe_max_rekey

int mppe_max_rekey = MPPE_MAX_REKEY
static

Definition at line 121 of file ng_mppc.c.

Referenced by ng_mppc_decompress().

◆ ng_mppc_constructor

ng_constructor_t ng_mppc_constructor
static

Definition at line 164 of file ng_mppc.c.

◆ ng_mppc_disconnect

ng_disconnect_t ng_mppc_disconnect
static

Definition at line 169 of file ng_mppc.c.

◆ ng_mppc_newhook

ng_newhook_t ng_mppc_newhook
static

Definition at line 167 of file ng_mppc.c.

◆ ng_mppc_rcvdata

ng_rcvdata_t ng_mppc_rcvdata
static

Definition at line 168 of file ng_mppc.c.

◆ ng_mppc_rcvmsg

ng_rcvmsg_t ng_mppc_rcvmsg
static

Definition at line 165 of file ng_mppc.c.

◆ ng_mppc_shutdown

ng_shutdown_t ng_mppc_shutdown
static

Definition at line 166 of file ng_mppc.c.

◆ ng_mppc_typestruct

struct ng_type ng_mppc_typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.constructor = ng_mppc_constructor,
.rcvmsg = ng_mppc_rcvmsg,
.shutdown = ng_mppc_shutdown,
.newhook = ng_mppc_newhook,
.rcvdata = ng_mppc_rcvdata,
.disconnect = ng_mppc_disconnect,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_rcvmsg_t ng_mppc_rcvmsg
Definition: ng_mppc.c:165
static ng_shutdown_t ng_mppc_shutdown
Definition: ng_mppc.c:166
static ng_constructor_t ng_mppc_constructor
Definition: ng_mppc.c:164
static ng_disconnect_t ng_mppc_disconnect
Definition: ng_mppc.c:169
static ng_newhook_t ng_mppc_newhook
Definition: ng_mppc.c:167
static ng_rcvdata_t ng_mppc_rcvdata
Definition: ng_mppc.c:168
#define NG_MPPC_NODE_TYPE
Definition: ng_mppc.h:48

Definition at line 184 of file ng_mppc.c.

◆ ng_mppe_weakenkey

const u_char ng_mppe_weakenkey[3] = { 0xd1, 0x26, 0x9e }
static

Definition at line 202 of file ng_mppc.c.

Referenced by ng_mppc_rcvmsg().