summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>2000-01-27 01:32:53 +0000
committerarchie <archie@FreeBSD.org>2000-01-27 01:32:53 +0000
commitf966bf838fefe9e13d03b6f794e5675c7397ca6e (patch)
treef1e9e2528e8515d1fb67a4f1ef8bc85f095ce023
parentb5a8876127f3499504e4a34767e403fcf4145da7 (diff)
downloadFreeBSD-src-f966bf838fefe9e13d03b6f794e5675c7397ca6e.zip
FreeBSD-src-f966bf838fefe9e13d03b6f794e5675c7397ca6e.tar.gz
Add control message ASCII conversion for this node type.
-rw-r--r--sys/netgraph/ng_tee.c44
-rw-r--r--sys/netgraph/ng_tee.h22
2 files changed, 62 insertions, 4 deletions
diff --git a/sys/netgraph/ng_tee.c b/sys/netgraph/ng_tee.c
index 575c870..ec774f2 100644
--- a/sys/netgraph/ng_tee.c
+++ b/sys/netgraph/ng_tee.c
@@ -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);
}
diff --git a/sys/netgraph/ng_tee.h b/sys/netgraph/ng_tee.h
index 2c1959a..f70b9f3 100644
--- a/sys/netgraph/ng_tee.h
+++ b/sys/netgraph/ng_tee.h
@@ -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 */
OpenPOWER on IntegriCloud