FreeBSD kernel netgraph code
ng_source.c File Reference
#include <sys/cdefs.h>
#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/socket.h>
#include <sys/syslog.h>
#include <net/if.h>
#include <net/if_var.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
#include <netgraph/ng_ether.h>
#include <netgraph/ng_source.h>
Include dependency graph for ng_source.c:

Go to the source code of this file.

Data Structures

struct  privdata
 

Macros

#define NG_SOURCE_INTR_TICKS   1
 
#define NG_SOURCE_DRIVER_IFQ_MAXLEN   (4*1024)
 
#define mtod_off(m, off, t)   ((t)(mtod((m),caddr_t)+(off)))
 
#define NG_SOURCE_ACTIVE   (NGF_TYPE1)
 

Typedefs

typedef struct privdatasc_p
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void ng_source_intr (node_p, hook_p, void *, int)
 
static void ng_source_clr_data (sc_p)
 
static int ng_source_start (sc_p, uint64_t)
 
static void ng_source_stop (sc_p)
 
static int ng_source_send (sc_p, int, int *)
 
static int ng_source_store_output_ifp (sc_p, char *)
 
static void ng_source_packet_mod (sc_p, struct mbuf *, int, int, caddr_t, int)
 
static void ng_source_mod_counter (sc_p sc, struct ng_source_embed_cnt_info *cnt, struct mbuf *m, int increment)
 
static int ng_source_dup_mod (sc_p, struct mbuf *, struct mbuf **)
 
 NETGRAPH_INIT (source, &ng_source_typestruct)
 
static int ng_source_set_autosrc (sc_p, uint32_t)
 
static int ng_source_constructor (node_p node)
 
static int ng_source_newhook (node_p node, hook_p hook, const char *name)
 
static int ng_source_connect (hook_p hook)
 
static int ng_source_rcvmsg (node_p node, item_p item, hook_p lasthook)
 
static int ng_source_rcvdata (hook_p hook, item_p item)
 
static int ng_source_rmnode (node_p node)
 
static int ng_source_disconnect (hook_p hook)
 

Variables

static ng_constructor_t ng_source_constructor
 
static ng_rcvmsg_t ng_source_rcvmsg
 
static ng_shutdown_t ng_source_rmnode
 
static ng_newhook_t ng_source_newhook
 
static ng_connect_t ng_source_connect
 
static ng_rcvdata_t ng_source_rcvdata
 
static ng_disconnect_t ng_source_disconnect
 
static const struct ng_parse_struct_field ng_source_timeval_type_fields []
 
const struct ng_parse_type ng_source_timeval_type
 
static const struct ng_parse_struct_field ng_source_stats_type_fields [] = NG_SOURCE_STATS_TYPE_INFO
 
static const struct ng_parse_type ng_source_stats_type
 
static const struct ng_parse_struct_field ng_source_embed_type_fields []
 
static const struct ng_parse_type ng_source_embed_type
 
static const struct ng_parse_struct_field ng_source_embed_cnt_type_fields []
 
static const struct ng_parse_type ng_source_embed_cnt_type
 
static const struct ng_cmdlist ng_source_cmds []
 
static struct ng_type ng_source_typestruct
 

Macro Definition Documentation

◆ mtod_off

#define mtod_off (   m,
  off,
 
)    ((t)(mtod((m),caddr_t)+(off)))

Definition at line 80 of file ng_source.c.

◆ NG_SOURCE_ACTIVE

#define NG_SOURCE_ACTIVE   (NGF_TYPE1)

Definition at line 100 of file ng_source.c.

◆ NG_SOURCE_DRIVER_IFQ_MAXLEN

#define NG_SOURCE_DRIVER_IFQ_MAXLEN   (4*1024)

Definition at line 78 of file ng_source.c.

◆ NG_SOURCE_INTR_TICKS

#define NG_SOURCE_INTR_TICKS   1

Definition at line 77 of file ng_source.c.

Typedef Documentation

◆ sc_p

typedef struct privdata* sc_p

Definition at line 97 of file ng_source.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ NETGRAPH_INIT()

NETGRAPH_INIT ( source  ,
ng_source_typestruct 
)

◆ ng_source_clr_data()

static void ng_source_clr_data ( sc_p  sc)
static

Definition at line 669 of file ng_source.c.

References NG_FREE_M.

Referenced by ng_source_rcvmsg(), and ng_source_rmnode().

Here is the caller graph for this function:

◆ ng_source_connect()

static int ng_source_connect ( hook_p  hook)
static

◆ ng_source_constructor()

static int ng_source_constructor ( node_p  node)
static

Definition at line 279 of file ng_source.c.

References ng_callout_init, NG_NODE_SET_PRIVATE, and ng_async_private::node.

◆ ng_source_disconnect()

static int ng_source_disconnect ( hook_p  hook)
static

Definition at line 603 of file ng_source.c.

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

Here is the call graph for this function:

◆ ng_source_dup_mod()

static int ng_source_dup_mod ( sc_p  sc,
struct mbuf *  m0,
struct mbuf **  m_ptr 
)
static

◆ ng_source_intr()

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

Definition at line 729 of file ng_source.c.

References ng_node::nd_flags, ng_callout(), NG_SOURCE_ACTIVE, ng_source_intr(), NG_SOURCE_INTR_TICKS, ng_source_send(), ng_source_stop(), ng_async_private::node, packets, and ng_async_private::stats.

Referenced by ng_source_intr(), and ng_source_start().

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

◆ ng_source_mod_counter()

static void ng_source_mod_counter ( sc_p  sc,
struct ng_source_embed_cnt_info cnt,
struct mbuf *  m,
int  increment 
)
static

◆ ng_source_newhook()

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

◆ ng_source_packet_mod()

static void ng_source_packet_mod ( sc_p  sc,
struct mbuf *  m,
int  offset,
int  len,
caddr_t  cp,
int  flags 
)
static

Definition at line 834 of file ng_source.c.

References mtod_off.

Referenced by ng_source_dup_mod(), and ng_source_mod_counter().

Here is the caller graph for this function:

◆ ng_source_rcvdata()

static int ng_source_rcvdata ( hook_p  hook,
item_p  item 
)
static

Definition at line 553 of file ng_source.c.

References NG_FREE_ITEM, NG_FREE_M, NG_HOOK_NODE, NG_NODE_PRIVATE, and NGI_GET_M.

◆ ng_source_rcvmsg()

◆ ng_source_rmnode()

static int ng_source_rmnode ( node_p  node)
static

Definition at line 586 of file ng_source.c.

References NG_NODE_PRIVATE, NG_NODE_SET_PRIVATE, NG_NODE_UNREF, ng_source_clr_data(), and ng_source_stop().

Here is the call graph for this function:

◆ ng_source_send()

static int ng_source_send ( sc_p  sc,
int  tosend,
int *  sent_p 
)
static

Definition at line 776 of file ng_source.c.

References ng_node::nd_flags, NG_SEND_DATA_ONLY, NG_SOURCE_ACTIVE, ng_source_dup_mod(), ng_async_private::node, and ng_async_private::stats.

Referenced by ng_source_intr().

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

◆ ng_source_set_autosrc()

static int ng_source_set_autosrc ( sc_p  sc,
uint32_t  flag 
)
static

Definition at line 650 of file ng_source.c.

References ng_mesg::data, NG_MKMESSAGE, NG_SEND_MSG_HOOK, NGM_ETHER_COOKIE, NGM_ETHER_SET_AUTOSRC, and ng_async_private::node.

Referenced by ng_source_rcvmsg().

Here is the caller graph for this function:

◆ ng_source_start()

static int ng_source_start ( sc_p  sc,
uint64_t  packets 
)
static

Definition at line 687 of file ng_source.c.

References ng_node::nd_flags, ng_callout(), NG_SOURCE_ACTIVE, ng_source_intr(), ng_async_private::node, packets, and ng_async_private::stats.

Referenced by ng_source_rcvmsg().

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

◆ ng_source_stop()

static void ng_source_stop ( sc_p  sc)
static

Definition at line 714 of file ng_source.c.

References ng_node::nd_flags, ng_uncallout(), ng_async_private::node, and ng_async_private::stats.

Referenced by ng_source_intr(), ng_source_rcvmsg(), and ng_source_rmnode().

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

◆ ng_source_store_output_ifp()

static int ng_source_store_output_ifp ( sc_p  sc,
char *  ifname 
)
static

Definition at line 619 of file ng_source.c.

References NG_SOURCE_DRIVER_IFQ_MAXLEN.

Referenced by ng_source_rcvmsg().

Here is the caller graph for this function:

Variable Documentation

◆ ng_source_cmds

const struct ng_cmdlist ng_source_cmds[]
static

Definition at line 170 of file ng_source.c.

◆ ng_source_connect

ng_connect_t ng_source_connect
static

Definition at line 107 of file ng_source.c.

◆ ng_source_constructor

ng_constructor_t ng_source_constructor
static

Definition at line 103 of file ng_source.c.

◆ ng_source_disconnect

ng_disconnect_t ng_source_disconnect
static

Definition at line 109 of file ng_source.c.

◆ ng_source_embed_cnt_type

const struct ng_parse_type ng_source_embed_cnt_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_source_embed_cnt_type_fields[]
Definition: ng_source.c:162

Definition at line 164 of file ng_source.c.

◆ ng_source_embed_cnt_type_fields

const struct ng_parse_struct_field ng_source_embed_cnt_type_fields[]
static
Initial value:
=
#define NG_SOURCE_EMBED_CNT_TYPE_INFO
Definition: ng_source.h:111

Definition at line 162 of file ng_source.c.

◆ ng_source_embed_type

const struct ng_parse_type ng_source_embed_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_source_embed_type_fields[]
Definition: ng_source.c:154

Definition at line 156 of file ng_source.c.

◆ ng_source_embed_type_fields

const struct ng_parse_struct_field ng_source_embed_type_fields[]
static
Initial value:
=
#define NG_SOURCE_EMBED_TYPE_INFO
Definition: ng_source.h:91

Definition at line 154 of file ng_source.c.

◆ ng_source_newhook

ng_newhook_t ng_source_newhook
static

Definition at line 106 of file ng_source.c.

◆ ng_source_rcvdata

ng_rcvdata_t ng_source_rcvdata
static

Definition at line 108 of file ng_source.c.

◆ ng_source_rcvmsg

ng_rcvmsg_t ng_source_rcvmsg
static

Definition at line 104 of file ng_source.c.

◆ ng_source_rmnode

ng_shutdown_t ng_source_rmnode
static

Definition at line 105 of file ng_source.c.

◆ ng_source_stats_type

const struct ng_parse_type ng_source_stats_type
static
Initial value:
= {
}
static const struct ng_parse_struct_field ng_source_stats_type_fields[]
Definition: ng_source.c:147

Definition at line 148 of file ng_source.c.

◆ ng_source_stats_type_fields

const struct ng_parse_struct_field ng_source_stats_type_fields[] = NG_SOURCE_STATS_TYPE_INFO
static

Definition at line 146 of file ng_source.c.

◆ ng_source_timeval_type

const struct ng_parse_type ng_source_timeval_type
Initial value:
= {
}
static const struct ng_parse_struct_field ng_source_timeval_type_fields[]
Definition: ng_source.c:127

Definition at line 140 of file ng_source.c.

◆ ng_source_timeval_type_fields

const struct ng_parse_struct_field ng_source_timeval_type_fields[]
static
Initial value:
= {
{ "tv_sec", &ng_parse_int64_type },
{ "tv_usec", &ng_parse_int32_type },
{ NULL }
}
const struct ng_parse_type ng_parse_int32_type
Definition: ng_parse.c:598
const struct ng_parse_type ng_parse_int64_type
Definition: ng_parse.c:693

Definition at line 127 of file ng_source.c.

◆ ng_source_typestruct

struct ng_type ng_source_typestruct
static
Initial value:
= {
.version = NG_ABI_VERSION,
.constructor = ng_source_constructor,
.rcvmsg = ng_source_rcvmsg,
.shutdown = ng_source_rmnode,
.newhook = ng_source_newhook,
.connect = ng_source_connect,
.rcvdata = ng_source_rcvdata,
.disconnect = ng_source_disconnect,
.cmdlist = ng_source_cmds,
}
#define NG_ABI_VERSION
Definition: netgraph.h:77
static ng_rcvdata_t ng_source_rcvdata
Definition: ng_source.c:108
static ng_newhook_t ng_source_newhook
Definition: ng_source.c:106
static const struct ng_cmdlist ng_source_cmds[]
Definition: ng_source.c:170
static ng_constructor_t ng_source_constructor
Definition: ng_source.c:103
static ng_disconnect_t ng_source_disconnect
Definition: ng_source.c:109
static ng_rcvmsg_t ng_source_rcvmsg
Definition: ng_source.c:104
static ng_connect_t ng_source_connect
Definition: ng_source.c:107
static ng_shutdown_t ng_source_rmnode
Definition: ng_source.c:105
#define NG_SOURCE_NODE_TYPE
Definition: ng_source.h:46

Definition at line 259 of file ng_source.c.