FreeBSD kernel netgraph code
ng_deflate.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/syslog.h>
#include <contrib/zlib/zlib.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
#include <netgraph/ng_deflate.h>
#include "opt_netgraph.h"
Include dependency graph for ng_deflate.c:

Go to the source code of this file.

Data Structures

struct  ng_deflate_private
 

Macros

#define DEFLATE_HDRLEN   2
 
#define PROT_COMPD   0x00fd
 
#define DEFLATE_BUF_SIZE   4096
 
#define ERROUT(x)   do { error = (x); goto done; } while (0)
 

Typedefs

typedef struct ng_deflate_privatepriv_p
 

Functions

static MALLOC_DEFINE (M_NETGRAPH_DEFLATE, "netgraph_deflate", "netgraph deflate node")
 
static int ng_deflate_compress (node_p, struct mbuf *, struct mbuf **)
 
static int ng_deflate_decompress (node_p, struct mbuf *, struct mbuf **)
 
static void ng_deflate_reset_req (node_p)
 
 NETGRAPH_INIT (deflate, &ng_deflate_typestruct)
 
 MODULE_DEPEND (ng_deflate, zlib, 1, 1, 1)
 
static int ng_deflate_constructor (node_p node)
 
static int ng_deflate_newhook (node_p node, hook_p hook, const char *name)
 
static int ng_deflate_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static int ng_deflate_rcvdata (hook_p hook, item_p item)
 
static int ng_deflate_shutdown (node_p node)
 
static int ng_deflate_disconnect (hook_p hook)
 

Variables

static ng_constructor_t ng_deflate_constructor
 
static ng_rcvmsg_t ng_deflate_rcvmsg
 
static ng_shutdown_t ng_deflate_shutdown
 
static ng_newhook_t ng_deflate_newhook
 
static ng_rcvdata_t ng_deflate_rcvdata
 
static ng_disconnect_t ng_deflate_disconnect
 
static const struct ng_parse_struct_field ng_deflate_config_type_fields [] = NG_DEFLATE_CONFIG_INFO
 
static const struct ng_parse_type ng_deflate_config_type
 
static const struct ng_parse_struct_field ng_deflate_stats_type_fields [] = NG_DEFLATE_STATS_INFO
 
static const struct ng_parse_type ng_deflate_stat_type
 
static const struct ng_cmdlist ng_deflate_cmds []
 
static struct ng_type ng_deflate_typestruct
 

Macro Definition Documentation

◆ DEFLATE_BUF_SIZE

#define DEFLATE_BUF_SIZE   4096

Definition at line 61 of file ng_deflate.c.

◆ DEFLATE_HDRLEN

#define DEFLATE_HDRLEN   2

Definition at line 57 of file ng_deflate.c.

◆ ERROUT

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

Definition at line 162 of file ng_deflate.c.

◆ PROT_COMPD

#define PROT_COMPD   0x00fd

Definition at line 59 of file ng_deflate.c.

Typedef Documentation

◆ priv_p

typedef struct ng_deflate_private* priv_p

Definition at line 74 of file ng_deflate.c.

Function Documentation

◆ MALLOC_DEFINE()

static MALLOC_DEFINE ( M_NETGRAPH_DEFLATE  ,
"netgraph_deflate"  ,
"netgraph deflate node"   
)
static

◆ MODULE_DEPEND()

MODULE_DEPEND ( ng_deflate  ,
zlib  ,
,
,
 
)

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( deflate  ,
ng_deflate_typestruct 
)

◆ ng_deflate_compress()

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

Definition at line 420 of file ng_deflate.c.

References DEFLATE_BUF_SIZE, DEFLATE_HDRLEN, NG_FREE_M, NG_NODE_PRIVATE, PROT_COMPD, and priv::stats.

Referenced by ng_deflate_rcvdata().

Here is the caller graph for this function:

◆ ng_deflate_constructor()

static int ng_deflate_constructor ( node_p  node)
static

Definition at line 172 of file ng_deflate.c.

References NG_NODE_FORCE_WRITER, and NG_NODE_SET_PRIVATE.

◆ ng_deflate_decompress()

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

Definition at line 526 of file ng_deflate.c.

References DEFLATE_BUF_SIZE, NG_FREE_M, NG_NODE_PRIVATE, PROT_COMPD, and priv::stats.

Referenced by ng_deflate_rcvdata().

Here is the caller graph for this function:

◆ ng_deflate_disconnect()

static int ng_deflate_disconnect ( hook_p  hook)
static

Definition at line 392 of file ng_deflate.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_deflate_newhook()

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

◆ ng_deflate_rcvdata()

static int ng_deflate_rcvdata ( hook_p  hook,
item_p  item 
)
static

◆ ng_deflate_rcvmsg()

◆ ng_deflate_reset_req()

static void ng_deflate_reset_req ( node_p  node)
static

Definition at line 707 of file ng_deflate.c.

References NG_NODE_PRIVATE.

Referenced by ng_deflate_rcvmsg().

Here is the caller graph for this function:

◆ ng_deflate_shutdown()

static int ng_deflate_shutdown ( node_p  node)
static

Definition at line 370 of file ng_deflate.c.

References NG_NODE_PRIVATE, NG_NODE_SET_PRIVATE, and NG_NODE_UNREF.

Variable Documentation

◆ ng_deflate_cmds

const struct ng_cmdlist ng_deflate_cmds[]
static

Definition at line 106 of file ng_deflate.c.

◆ ng_deflate_config_type

const struct ng_parse_type ng_deflate_config_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_deflate_config_type_fields[]
Definition: ng_deflate.c:91
const struct ng_parse_type ng_parse_struct_type
Definition: ng_parse.c:222

Definition at line 92 of file ng_deflate.c.

◆ ng_deflate_config_type_fields

const struct ng_parse_struct_field ng_deflate_config_type_fields[] = NG_DEFLATE_CONFIG_INFO
static

Definition at line 90 of file ng_deflate.c.

◆ ng_deflate_constructor

ng_constructor_t ng_deflate_constructor
static

Definition at line 77 of file ng_deflate.c.

◆ ng_deflate_disconnect

ng_disconnect_t ng_deflate_disconnect
static

Definition at line 82 of file ng_deflate.c.

◆ ng_deflate_newhook

ng_newhook_t ng_deflate_newhook
static

Definition at line 80 of file ng_deflate.c.

◆ ng_deflate_rcvdata

ng_rcvdata_t ng_deflate_rcvdata
static

Definition at line 81 of file ng_deflate.c.

◆ ng_deflate_rcvmsg

ng_rcvmsg_t ng_deflate_rcvmsg
static

Definition at line 78 of file ng_deflate.c.

◆ ng_deflate_shutdown

ng_shutdown_t ng_deflate_shutdown
static

Definition at line 79 of file ng_deflate.c.

◆ ng_deflate_stat_type

const struct ng_parse_type ng_deflate_stat_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_deflate_stats_type_fields[]
Definition: ng_deflate.c:99

Definition at line 100 of file ng_deflate.c.

◆ ng_deflate_stats_type_fields

const struct ng_parse_struct_field ng_deflate_stats_type_fields[] = NG_DEFLATE_STATS_INFO
static

Definition at line 98 of file ng_deflate.c.

◆ ng_deflate_typestruct

struct ng_type ng_deflate_typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.constructor = ng_deflate_constructor,
.rcvmsg = ng_deflate_rcvmsg,
.shutdown = ng_deflate_shutdown,
.newhook = ng_deflate_newhook,
.rcvdata = ng_deflate_rcvdata,
.disconnect = ng_deflate_disconnect,
.cmdlist = ng_deflate_cmds,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_rcvdata_t ng_deflate_rcvdata
Definition: ng_deflate.c:81
static ng_disconnect_t ng_deflate_disconnect
Definition: ng_deflate.c:82
static ng_shutdown_t ng_deflate_shutdown
Definition: ng_deflate.c:79
static const struct ng_cmdlist ng_deflate_cmds[]
Definition: ng_deflate.c:106
static ng_constructor_t ng_deflate_constructor
Definition: ng_deflate.c:77
static ng_newhook_t ng_deflate_newhook
Definition: ng_deflate.c:80
static ng_rcvmsg_t ng_deflate_rcvmsg
Definition: ng_deflate.c:78
#define NG_DEFLATE_NODE_TYPE
Definition: ng_deflate.h:36

Definition at line 146 of file ng_deflate.c.