Add control message ASCII conversion for this node type.

This commit is contained in:
Archie Cobbs 2000-01-27 01:32:53 +00:00
parent 7881bb5d5f
commit 5c63f81fd4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56658
2 changed files with 62 additions and 4 deletions

View File

@ -57,6 +57,7 @@
#include <sys/mbuf.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_parse.h>
#include <netgraph/ng_tee.h>
/* Per hook info */
@ -83,8 +84,43 @@ static ng_newhook_t ngt_newhook;
static ng_rcvdata_t ngt_rcvdata;
static ng_disconnect_t ngt_disconnect;
/* Parse type for struct ng_tee_hookstat */
static const struct ng_parse_struct_info
ng_tee_hookstat_type_info = NG_TEE_HOOKSTAT_INFO;
static const struct ng_parse_type ng_tee_hookstat_type = {
&ng_parse_struct_type,
&ng_tee_hookstat_type_info,
};
/* Parse type for struct ng_tee_stats */
static const struct ng_parse_struct_info
ng_tee_stats_type_info = NG_TEE_STATS_INFO(&ng_tee_hookstat_type);
static const struct ng_parse_type ng_tee_stats_type = {
&ng_parse_struct_type,
&ng_tee_stats_type_info,
};
/* List of commands and how to convert arguments to/from ASCII */
static const struct ng_cmdlist ng_tee_cmds[] = {
{
NGM_TEE_COOKIE,
NGM_TEE_GET_STATS,
"getstats",
NULL,
&ng_tee_stats_type
},
{
NGM_TEE_COOKIE,
NGM_TEE_CLR_STATS,
"clrstats",
NULL,
NULL
},
{ 0 }
};
/* Netgraph type descriptor */
static struct ng_type typestruct = {
static struct ng_type ng_tee_typestruct = {
NG_VERSION,
NG_TEE_NODE_TYPE,
NULL,
@ -97,9 +133,9 @@ static struct ng_type typestruct = {
ngt_rcvdata,
ngt_rcvdata,
ngt_disconnect,
NULL
ng_tee_cmds
};
NETGRAPH_INIT(tee, &typestruct);
NETGRAPH_INIT(tee, &ng_tee_typestruct);
/*
* Node constructor
@ -115,7 +151,7 @@ ngt_constructor(node_p *nodep)
return (ENOMEM);
bzero(privdata, sizeof(*privdata));
if ((error = ng_make_node_common(&typestruct, nodep))) {
if ((error = ng_make_node_common(&ng_tee_typestruct, nodep))) {
FREE(privdata, M_NETGRAPH);
return (error);
}

View File

@ -61,6 +61,17 @@ struct ng_tee_hookstat {
u_int64_t outFrames;
};
/* Keep this in sync with the above structure definition */
#define NG_TEE_HOOKSTAT_INFO { \
{ \
{ "inOctets", &ng_parse_int64_type }, \
{ "inFrames", &ng_parse_int64_type }, \
{ "outOctets", &ng_parse_int64_type }, \
{ "outFrames", &ng_parse_int64_type }, \
{ NULL }, \
} \
}
/* Statistics structure returned by NGM_TEE_GET_STATS */
struct ng_tee_stats {
struct ng_tee_hookstat right;
@ -69,6 +80,17 @@ struct ng_tee_stats {
struct ng_tee_hookstat left2right;
};
/* Keep this in sync with the above structure definition */
#define NG_TEE_STATS_INFO(hstype) { \
{ \
{ "right", (hstype) }, \
{ "left", (hstype) }, \
{ "right2left", (hstype) }, \
{ "left2right", (hstype) }, \
{ NULL }, \
} \
}
/* Netgraph commands */
enum {
NGM_TEE_GET_STATS = 1, /* get stats */