FreeBSD kernel netgraph code
|
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/time.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
#include <sys/endian.h>
#include <sys/errno.h>
#include <sys/sysctl.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
#include <netgraph/ng_pptpgre.h>
Go to the source code of this file.
Data Structures | |
struct | greheader |
struct | ng_pptpgre_roq |
struct | ng_pptpgre_sess |
struct | ng_pptpgre_private |
Macros | |
#define | PPTP_GRE_PROTO 0x880b |
#define | PPTP_INIT_VALUE ((0x2001 << 16) | PPTP_GRE_PROTO) |
#define | PPTP_INIT_MASK 0xef7fffff |
#define | PPTP_MAX_PAYLOAD (0xffff - sizeof(struct greheader) - 8) |
#define | PPTP_TIME_SCALE 1024 /* milliseconds */ |
#define | PPTP_XMIT_WIN 16 /* max xmit window */ |
#define | PPTP_MIN_TIMEOUT (PPTP_TIME_SCALE / 83) /* 12 milliseconds */ |
#define | PPTP_MAX_TIMEOUT (3 * PPTP_TIME_SCALE) /* 3 seconds */ |
#define | PPTP_REORDER_TIMEOUT 1 |
#define | PPTP_MIN_ACK_DELAY (PPTP_TIME_SCALE / 500) /* 2 milliseconds */ |
#define | PPTP_MAX_ACK_DELAY (PPTP_TIME_SCALE / 2) /* 500 milliseconds */ |
#define | PPTP_ACK_ALPHA(x) (((x) + 4) >> 3) /* alpha = 0.125 */ |
#define | PPTP_ACK_BETA(x) (((x) + 2) >> 2) /* beta = 0.25 */ |
#define | PPTP_ACK_CHI(x) ((x) << 2) /* chi = 4 */ |
#define | PPTP_ACK_DELTA(x) ((x) << 1) /* delta = 2 */ |
#define | PPTP_SEQ_DIFF(x, y) ((int32_t)(x) - (int32_t)(y)) |
#define | SESSHASHSIZE 0x0020 |
#define | SESSHASH(x) (((x) ^ ((x) >> 8)) & (SESSHASHSIZE - 1)) |
#define | ERROUT(x) do { error = (x); goto done; } while (0) |
#define | INIT_SENDQ(t) |
Typedefs | |
typedef u_int64_t | pptptime_t |
typedef struct ng_pptpgre_roq_head | roqh |
typedef struct ng_pptpgre_sess * | hpriv_p |
typedef struct ng_pptpgre_private * | priv_p |
Functions | |
SYSCTL_NODE (_net_graph, OID_AUTO, pptpgre, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "PPTPGRE") | |
SYSCTL_UINT (_net_graph_pptpgre, OID_AUTO, reorder_max, CTLFLAG_RWTUN, &reorder_max, 0, "Reorder queue maximum length") | |
SYSCTL_UINT (_net_graph_pptpgre, OID_AUTO, reorder_timeout, CTLFLAG_RWTUN, &reorder_timeout, 0, "Reorder timeout is milliseconds") | |
SLIST_HEAD (ng_pptpgre_roq_head, ng_pptpgre_roq) | |
static int | ng_pptpgre_xmit (hpriv_p hpriv, item_p item) |
static void | ng_pptpgre_start_send_ack_timer (hpriv_p hpriv) |
static void | ng_pptpgre_start_recv_ack_timer (hpriv_p hpriv) |
static void | ng_pptpgre_start_reorder_timer (hpriv_p hpriv) |
static void | ng_pptpgre_recv_ack_timeout (node_p node, hook_p hook, void *arg1, int arg2) |
static void | ng_pptpgre_send_ack_timeout (node_p node, hook_p hook, void *arg1, int arg2) |
static void | ng_pptpgre_reorder_timeout (node_p node, hook_p hook, void *arg1, int arg2) |
static hpriv_p | ng_pptpgre_find_session (priv_p privp, u_int16_t cid) |
static void | ng_pptpgre_reset (hpriv_p hpriv) |
static pptptime_t | ng_pptpgre_time (void) |
static void | ng_pptpgre_ack (const hpriv_p hpriv) |
static int | ng_pptpgre_sendq (const hpriv_p hpriv, roqh *q, const struct ng_pptpgre_roq *st) |
NETGRAPH_INIT (pptpgre, &ng_pptpgre_typestruct) | |
static int | ng_pptpgre_constructor (node_p node) |
static int | ng_pptpgre_newhook (node_p node, hook_p hook, const char *name) |
static int | ng_pptpgre_rcvmsg (node_p node, item_p item, hook_p lasthook) |
static int | ng_pptpgre_rcvdata (hook_p hook, item_p item) |
static int | ng_pptpgre_disconnect (hook_p hook) |
static int | ng_pptpgre_shutdown (node_p node) |
static int | ng_pptpgre_rcvdata_lower (hook_p hook, item_p item) |
Variables | |
static int | reorder_max = 1 |
static int | reorder_timeout = PPTP_REORDER_TIMEOUT |
static ng_constructor_t | ng_pptpgre_constructor |
static ng_rcvmsg_t | ng_pptpgre_rcvmsg |
static ng_shutdown_t | ng_pptpgre_shutdown |
static ng_newhook_t | ng_pptpgre_newhook |
static ng_rcvdata_t | ng_pptpgre_rcvdata |
static ng_rcvdata_t | ng_pptpgre_rcvdata_lower |
static ng_disconnect_t | ng_pptpgre_disconnect |
static const struct ng_parse_struct_field | ng_pptpgre_conf_type_fields [] = NG_PPTPGRE_CONF_TYPE_INFO |
static const struct ng_parse_type | ng_pptpgre_conf_type |
static const struct ng_parse_struct_field | ng_pptpgre_stats_type_fields [] = NG_PPTPGRE_STATS_TYPE_INFO |
static const struct ng_parse_type | ng_pptp_stats_type |
static const struct ng_cmdlist | ng_pptpgre_cmdlist [] |
static struct ng_type | ng_pptpgre_typestruct |
#define ERROUT | ( | x | ) | do { error = (x); goto done; } while (0) |
Definition at line 309 of file ng_pptpgre.c.
#define INIT_SENDQ | ( | t | ) |
#define PPTP_ACK_ALPHA | ( | x | ) | (((x) + 4) >> 3) /* alpha = 0.125 */ |
Definition at line 138 of file ng_pptpgre.c.
#define PPTP_ACK_BETA | ( | x | ) | (((x) + 2) >> 2) /* beta = 0.25 */ |
Definition at line 139 of file ng_pptpgre.c.
#define PPTP_ACK_CHI | ( | x | ) | ((x) << 2) /* chi = 4 */ |
Definition at line 140 of file ng_pptpgre.c.
#define PPTP_ACK_DELTA | ( | x | ) | ((x) << 1) /* delta = 2 */ |
Definition at line 141 of file ng_pptpgre.c.
#define PPTP_GRE_PROTO 0x880b |
Definition at line 110 of file ng_pptpgre.c.
#define PPTP_INIT_MASK 0xef7fffff |
Definition at line 114 of file ng_pptpgre.c.
#define PPTP_INIT_VALUE ((0x2001 << 16) | PPTP_GRE_PROTO) |
Definition at line 113 of file ng_pptpgre.c.
#define PPTP_MAX_ACK_DELAY (PPTP_TIME_SCALE / 2) /* 500 milliseconds */ |
Definition at line 135 of file ng_pptpgre.c.
#define PPTP_MAX_PAYLOAD (0xffff - sizeof(struct greheader) - 8) |
Definition at line 117 of file ng_pptpgre.c.
#define PPTP_MAX_TIMEOUT (3 * PPTP_TIME_SCALE) /* 3 seconds */ |
Definition at line 126 of file ng_pptpgre.c.
#define PPTP_MIN_ACK_DELAY (PPTP_TIME_SCALE / 500) /* 2 milliseconds */ |
Definition at line 134 of file ng_pptpgre.c.
#define PPTP_MIN_TIMEOUT (PPTP_TIME_SCALE / 83) /* 12 milliseconds */ |
Definition at line 125 of file ng_pptpgre.c.
#define PPTP_REORDER_TIMEOUT 1 |
Definition at line 128 of file ng_pptpgre.c.
#define PPTP_SEQ_DIFF | ( | x, | |
y | |||
) | ((int32_t)(x) - (int32_t)(y)) |
Definition at line 143 of file ng_pptpgre.c.
#define PPTP_TIME_SCALE 1024 /* milliseconds */ |
Definition at line 120 of file ng_pptpgre.c.
#define PPTP_XMIT_WIN 16 /* max xmit window */ |
Definition at line 124 of file ng_pptpgre.c.
#define SESSHASH | ( | x | ) | (((x) ^ ((x) >> 8)) & (SESSHASHSIZE - 1)) |
Definition at line 146 of file ng_pptpgre.c.
#define SESSHASHSIZE 0x0020 |
Definition at line 145 of file ng_pptpgre.c.
typedef struct ng_pptpgre_sess* hpriv_p |
Definition at line 200 of file ng_pptpgre.c.
typedef u_int64_t pptptime_t |
Definition at line 121 of file ng_pptpgre.c.
typedef struct ng_pptpgre_private* priv_p |
Definition at line 210 of file ng_pptpgre.c.
typedef struct ng_pptpgre_roq_head roqh |
Definition at line 175 of file ng_pptpgre.c.
NETGRAPH_INIT | ( | pptpgre | , |
& | ng_pptpgre_typestruct | ||
) |
|
static |
Definition at line 699 of file ng_pptpgre.c.
References ng_pptpgre_start_send_ack_timer(), and ng_pptpgre_xmit().
Referenced by ng_pptpgre_rcvdata_lower(), and ng_pptpgre_reorder_timeout().
|
static |
Definition at line 319 of file ng_pptpgre.c.
References ng_callout_init, NG_NODE_SET_PRIVATE, and SESSHASHSIZE.
|
static |
Definition at line 529 of file ng_pptpgre.c.
References priv::lower, NG_HOOK_NODE, NG_HOOK_PRIVATE, NG_NODE_IS_VALID, NG_NODE_NUMHOOKS, NG_NODE_PRIVATE, ng_pptpgre_reset(), ng_rmnode_self(), and priv::upper.
Definition at line 1218 of file ng_pptpgre.c.
References SESSHASH.
Referenced by ng_pptpgre_rcvdata_lower(), and ng_pptpgre_rcvmsg().
Definition at line 352 of file ng_pptpgre.c.
References priv::lower, name, ng_callout_init, NG_HOOK_SET_PRIVATE, NG_HOOK_SET_RCVDATA, NG_NODE_PRIVATE, NG_PPTPGRE_HOOK_LOWER, NG_PPTPGRE_HOOK_SESSION_P, NG_PPTPGRE_HOOK_UPPER, ng_pptpgre_rcvdata_lower, SESSHASH, and priv::upper.
Definition at line 505 of file ng_pptpgre.c.
References NG_FREE_ITEM, NG_HOOK_PRIVATE, and ng_pptpgre_xmit().
Definition at line 745 of file ng_pptpgre.c.
References _NGI_M, greheader::cid, greheader::data, ERROUT, greheader::hasAck, greheader::hasSeq, INIT_SENDQ, last, greheader::length, NG_FREE_ITEM, NG_FWD_NEW_DATA, NG_HOOK_NODE, NG_NODE_PRIVATE, ng_pptpgre_ack(), ng_pptpgre_find_session(), ng_pptpgre_sendq(), ng_pptpgre_start_recv_ack_timer(), ng_pptpgre_start_reorder_timer(), ng_pptpgre_time(), ng_uncallout(), NGI_M, PPTP_ACK_ALPHA, PPTP_ACK_BETA, PPTP_ACK_CHI, PPTP_INIT_MASK, PPTP_INIT_VALUE, PPTP_MAX_TIMEOUT, PPTP_MIN_TIMEOUT, PPTP_SEQ_DIFF, PPTP_XMIT_WIN, reorder_max, and priv::stats.
Definition at line 414 of file ng_pptpgre.c.
References ng_mesg::ng_msghdr::arglen, ng_pptpgre_conf::cid, ng_mesg::ng_msghdr::cmd, ng_mesg::data, ERROUT, ng_mesg::header, NG_FREE_MSG, NG_MKRESPONSE, NG_NODE_PRIVATE, ng_pptpgre_find_session(), ng_pptpgre_reset(), NG_RESPOND_MSG, NGI_GET_MSG, NGM_PPTPGRE_CLR_STATS, NGM_PPTPGRE_COOKIE, NGM_PPTPGRE_GET_CONFIG, NGM_PPTPGRE_GET_STATS, NGM_PPTPGRE_GETCLR_STATS, NGM_PPTPGRE_SET_CONFIG, SESSHASH, priv::stats, and ng_mesg::ng_msghdr::typecookie.
Definition at line 1089 of file ng_pptpgre.c.
References NG_NODE_PRIVATE, PPTP_ACK_CHI, PPTP_ACK_DELTA, PPTP_MAX_TIMEOUT, PPTP_MIN_TIMEOUT, and priv::stats.
Referenced by ng_pptpgre_start_recv_ack_timer().
Definition at line 1168 of file ng_pptpgre.c.
References last, NG_NODE_PRIVATE, ng_pptpgre_ack(), ng_pptpgre_sendq(), ng_pptpgre_start_reorder_timer(), PPTP_SEQ_DIFF, and priv::stats.
Referenced by ng_pptpgre_start_reorder_timer().
|
static |
Definition at line 1235 of file ng_pptpgre.c.
References NG_FREE_ITEM, ng_uncallout(), PPTP_MAX_TIMEOUT, PPTP_TIME_SCALE, and PPTP_XMIT_WIN.
Referenced by ng_pptpgre_disconnect(), ng_pptpgre_rcvmsg(), and ng_pptpgre_shutdown().
Definition at line 1138 of file ng_pptpgre.c.
References ng_pptpgre_xmit().
Referenced by ng_pptpgre_start_send_ack_timer().
|
static |
Definition at line 723 of file ng_pptpgre.c.
References NG_FWD_NEW_DATA, and NGI_GET_M.
Referenced by ng_pptpgre_rcvdata_lower(), and ng_pptpgre_reorder_timeout().
|
static |
Definition at line 561 of file ng_pptpgre.c.
References NG_NODE_PRIVATE, NG_NODE_UNREF, and ng_pptpgre_reset().
|
static |
Definition at line 1067 of file ng_pptpgre.c.
References ng_callout(), ng_pptpgre_recv_ack_timeout(), ng_pptpgre_time(), and PPTP_TIME_SCALE.
Referenced by ng_pptpgre_rcvdata_lower(), and ng_pptpgre_xmit().
|
static |
Definition at line 1153 of file ng_pptpgre.c.
References ng_callout(), ng_pptpgre_reorder_timeout(), and reorder_timeout.
Referenced by ng_pptpgre_rcvdata_lower(), and ng_pptpgre_reorder_timeout().
|
static |
Definition at line 1114 of file ng_pptpgre.c.
References ng_callout(), ng_pptpgre_send_ack_timeout(), PPTP_MAX_ACK_DELAY, PPTP_MIN_ACK_DELAY, and PPTP_TIME_SCALE.
Referenced by ng_pptpgre_ack().
|
static |
Definition at line 1277 of file ng_pptpgre.c.
References PPTP_TIME_SCALE.
Referenced by ng_pptpgre_rcvdata_lower(), ng_pptpgre_start_recv_ack_timer(), and ng_pptpgre_xmit().
Definition at line 586 of file ng_pptpgre.c.
References greheader::cid, greheader::data, ERROUT, greheader::hasAck, greheader::hasSeq, greheader::length, priv::lower, NG_FREE_ITEM, NG_FREE_M, NG_FWD_NEW_DATA, NG_NODE_PRIVATE, ng_pptpgre_start_recv_ack_timer(), ng_pptpgre_time(), NG_SEND_DATA_ONLY, ng_uncallout(), NGI_GET_M, PPTP_INIT_VALUE, PPTP_MAX_PAYLOAD, PPTP_SEQ_DIFF, and priv::stats.
Referenced by ng_pptpgre_ack(), ng_pptpgre_rcvdata(), and ng_pptpgre_send_ack_timeout().
SLIST_HEAD | ( | ng_pptpgre_roq_head | , |
ng_pptpgre_roq | |||
) |
SYSCTL_NODE | ( | _net_graph | , |
OID_AUTO | , | ||
pptpgre | , | ||
CTLFLAG_RW| | CTLFLAG_MPSAFE, | ||
0 | , | ||
"PPTPGRE" | |||
) |
SYSCTL_UINT | ( | _net_graph_pptpgre | , |
OID_AUTO | , | ||
reorder_max | , | ||
CTLFLAG_RWTUN | , | ||
& | reorder_max, | ||
0 | , | ||
"Reorder queue maximum length" | |||
) |
SYSCTL_UINT | ( | _net_graph_pptpgre | , |
OID_AUTO | , | ||
reorder_timeout | , | ||
CTLFLAG_RWTUN | , | ||
& | reorder_timeout, | ||
0 | , | ||
"Reorder timeout is milliseconds" | |||
) |
|
static |
Definition at line 250 of file ng_pptpgre.c.
|
static |
Definition at line 256 of file ng_pptpgre.c.
|
static |
Definition at line 242 of file ng_pptpgre.c.
|
static |
Definition at line 240 of file ng_pptpgre.c.
|
static |
Definition at line 213 of file ng_pptpgre.c.
|
static |
Definition at line 219 of file ng_pptpgre.c.
|
static |
Definition at line 216 of file ng_pptpgre.c.
|
static |
Definition at line 217 of file ng_pptpgre.c.
|
static |
Definition at line 218 of file ng_pptpgre.c.
Referenced by ng_pptpgre_newhook().
|
static |
Definition at line 214 of file ng_pptpgre.c.
|
static |
Definition at line 215 of file ng_pptpgre.c.
|
static |
Definition at line 248 of file ng_pptpgre.c.
|
static |
Definition at line 296 of file ng_pptpgre.c.
|
static |
Definition at line 160 of file ng_pptpgre.c.
Referenced by ng_pptpgre_rcvdata_lower().
|
static |
Definition at line 164 of file ng_pptpgre.c.
Referenced by ng_pptpgre_start_reorder_timer().