summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/ng_nat.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2013-03-21 08:36:15 +0000
committerglebius <glebius@FreeBSD.org>2013-03-21 08:36:15 +0000
commitbe285699ff1a25c9a2ddfb84572dd11234c2f71f (patch)
treea4cbdc9310fa718c7fbf251e9aa2e34680ae2ef2 /sys/netgraph/ng_nat.c
parent9382f70781f175347620eab8b665f052267b44d8 (diff)
downloadFreeBSD-src-be285699ff1a25c9a2ddfb84572dd11234c2f71f.zip
FreeBSD-src-be285699ff1a25c9a2ddfb84572dd11234c2f71f.tar.gz
Add NGM_NAT_LIBALIAS_INFO command, that reports internal stats
of libalias instance. To be used in the mpd5 daemon. Submitted by: Dmitry Luhtionov <dmitryluhtionov gmail.com>
Diffstat (limited to 'sys/netgraph/ng_nat.c')
-rw-r--r--sys/netgraph/ng_nat.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/sys/netgraph/ng_nat.c b/sys/netgraph/ng_nat.c
index fc39e3e..71419d6 100644
--- a/sys/netgraph/ng_nat.c
+++ b/sys/netgraph/ng_nat.c
@@ -145,6 +145,14 @@ static const struct ng_parse_type ng_nat_list_redirects_type = {
&ng_nat_list_redirects_fields
};
+/* Parse type for struct ng_nat_libalias_info. */
+static const struct ng_parse_struct_field ng_nat_libalias_info_fields[]
+ = NG_NAT_LIBALIAS_INFO;
+static const struct ng_parse_type ng_nat_libalias_info_type = {
+ &ng_parse_struct_type,
+ &ng_nat_libalias_info_fields
+};
+
/* List of commands and how to convert arguments to/from ASCII. */
static const struct ng_cmdlist ng_nat_cmdlist[] = {
{
@@ -224,6 +232,13 @@ static const struct ng_cmdlist ng_nat_cmdlist[] = {
&ng_parse_string_type,
NULL
},
+ {
+ NGM_NAT_COOKIE,
+ NGM_NAT_LIBALIAS_INFO,
+ "libaliasinfo",
+ NULL,
+ &ng_nat_libalias_info_type
+ },
{ 0 }
};
@@ -647,6 +662,36 @@ ng_nat_rcvmsg(node_p node, item_p item, hook_p lasthook)
error = ENOMEM;
}
break;
+ case NGM_NAT_LIBALIAS_INFO:
+ {
+ struct ng_nat_libalias_info *i;
+
+ NG_MKRESPONSE(resp, msg,
+ sizeof(struct ng_nat_libalias_info), M_NOWAIT);
+ if (resp == NULL) {
+ error = ENOMEM;
+ break;
+ }
+ i = (struct ng_nat_libalias_info *)resp->data;
+#define COPY(F) do { \
+ if (priv->lib->F >= 0 && priv->lib->F < UINT32_MAX) \
+ i->F = priv->lib->F; \
+ else \
+ i->F = UINT32_MAX; \
+} while (0)
+
+ COPY(icmpLinkCount);
+ COPY(udpLinkCount);
+ COPY(tcpLinkCount);
+ COPY(pptpLinkCount);
+ COPY(sctpLinkCount);
+ COPY(protoLinkCount);
+ COPY(fragmentIdLinkCount);
+ COPY(fragmentPtrLinkCount);
+ COPY(sockCount);
+#undef COPY
+ }
+ break;
default:
error = EINVAL; /* unknown command */
break;
OpenPOWER on IntegriCloud