summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2011-12-24 15:07:58 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2011-12-24 15:19:21 +0100
commit6a05d293fed594f89ad05625e43dec6a81da487d (patch)
treedbbf06572d0477df43c053ebe996133b144dae87
parent7843632196fd959f3f8f16f3d533c72d315a7e08 (diff)
expect: support CTA_EXPECT_HELP_NAME
This patch adds support for CTA_EXPECT_HELP_NAME. We now have the ATTR_EXP_HELPER_NAME attribute. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--include/internal/object.h1
-rw-r--r--include/libnetfilter_conntrack/libnetfilter_conntrack.h1
-rw-r--r--src/expect/build.c9
-rw-r--r--src/expect/getter.c6
-rw-r--r--src/expect/parse.c5
-rw-r--r--src/expect/setter.c7
-rw-r--r--src/expect/snprintf_default.c5
7 files changed, 34 insertions, 0 deletions
diff --git a/include/internal/object.h b/include/internal/object.h
index 5dce9d0..19d77b4 100644
--- a/include/internal/object.h
+++ b/include/internal/object.h
@@ -269,6 +269,7 @@ struct nf_expect {
u_int32_t id;
u_int16_t zone;
u_int32_t flags;
+ char helper_name[__NFCT_HELPER_NAMELEN];
u_int32_t set[1];
};
diff --git a/include/libnetfilter_conntrack/libnetfilter_conntrack.h b/include/libnetfilter_conntrack/libnetfilter_conntrack.h
index 94e34be..09e7920 100644
--- a/include/libnetfilter_conntrack/libnetfilter_conntrack.h
+++ b/include/libnetfilter_conntrack/libnetfilter_conntrack.h
@@ -507,6 +507,7 @@ enum nf_expect_attr {
ATTR_EXP_TIMEOUT, /* u32 bits */
ATTR_EXP_ZONE, /* u16 bits */
ATTR_EXP_FLAGS, /* u32 bits */
+ ATTR_EXP_HELPER_NAME, /* string (16 bytes max) */
ATTR_EXP_MAX
};
diff --git a/src/expect/build.c b/src/expect/build.c
index c1a5a1d..82aa852 100644
--- a/src/expect/build.c
+++ b/src/expect/build.c
@@ -26,6 +26,13 @@ static void __build_flags(struct nfnlhdr *req,
nfnl_addattr32(&req->nlh, size, CTA_EXPECT_FLAGS,htonl(exp->flags));
}
+static void __build_helper_name(struct nfnlhdr *req, size_t size,
+ const struct nf_expect *exp)
+{
+ nfnl_addattr_l(&req->nlh, size, CTA_EXPECT_HELP_NAME,
+ exp->helper_name, strlen(exp->helper_name));
+}
+
int __build_expect(struct nfnl_subsys_handle *ssh,
struct nfnlhdr *req,
size_t size,
@@ -73,6 +80,8 @@ int __build_expect(struct nfnl_subsys_handle *ssh,
__build_flags(req, size, exp);
if (test_bit(ATTR_EXP_ZONE, exp->set))
__build_zone(req, size, exp);
+ if (test_bit(ATTR_EXP_HELPER_NAME, exp->set))
+ __build_helper_name(req, size, exp);
return 0;
}
diff --git a/src/expect/getter.c b/src/expect/getter.c
index 9cb6ede..69453c5 100644
--- a/src/expect/getter.c
+++ b/src/expect/getter.c
@@ -37,6 +37,11 @@ static const void *get_exp_attr_flags(const struct nf_expect *exp)
return &exp->flags;
}
+static const void *get_exp_attr_helper_name(const struct nf_expect *exp)
+{
+ return exp->helper_name;
+}
+
const get_exp_attr get_exp_attr_array[ATTR_EXP_MAX] = {
[ATTR_EXP_MASTER] = get_exp_attr_master,
[ATTR_EXP_EXPECTED] = get_exp_attr_expected,
@@ -44,4 +49,5 @@ const get_exp_attr get_exp_attr_array[ATTR_EXP_MAX] = {
[ATTR_EXP_TIMEOUT] = get_exp_attr_timeout,
[ATTR_EXP_ZONE] = get_exp_attr_zone,
[ATTR_EXP_FLAGS] = get_exp_attr_flags,
+ [ATTR_EXP_HELPER_NAME] = get_exp_attr_helper_name,
};
diff --git a/src/expect/parse.c b/src/expect/parse.c
index 0581aca..4d9852d 100644
--- a/src/expect/parse.c
+++ b/src/expect/parse.c
@@ -77,4 +77,9 @@ void __parse_expect(const struct nlmsghdr *nlh,
ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_FLAGS-1]));
set_bit(ATTR_EXP_FLAGS, exp->set);
}
+ if (cda[CTA_EXPECT_HELP_NAME-1]) {
+ strncpy(exp->helper_name, NFA_DATA(cda[CTA_EXPECT_HELP_NAME-1]),
+ NFA_PAYLOAD(cda[CTA_EXPECT_HELP_NAME-1]));
+ set_bit(ATTR_EXP_HELPER_NAME, exp->set);
+ }
}
diff --git a/src/expect/setter.c b/src/expect/setter.c
index 040b958..3cde4b0 100644
--- a/src/expect/setter.c
+++ b/src/expect/setter.c
@@ -37,6 +37,12 @@ static void set_exp_attr_flags(struct nf_expect *exp, const void *value)
exp->flags = *((u_int32_t *) value);
}
+static void set_exp_attr_helper_name(struct nf_expect *exp, const void *value)
+{
+ strncpy(exp->helper_name, value, __NFCT_HELPER_NAMELEN);
+ exp->helper_name[__NFCT_HELPER_NAMELEN-1] = '\0';
+}
+
const set_exp_attr set_exp_attr_array[ATTR_EXP_MAX] = {
[ATTR_EXP_MASTER] = set_exp_attr_master,
[ATTR_EXP_EXPECTED] = set_exp_attr_expected,
@@ -44,4 +50,5 @@ const set_exp_attr set_exp_attr_array[ATTR_EXP_MAX] = {
[ATTR_EXP_TIMEOUT] = set_exp_attr_timeout,
[ATTR_EXP_ZONE] = set_exp_attr_zone,
[ATTR_EXP_FLAGS] = set_exp_attr_flags,
+ [ATTR_EXP_HELPER_NAME] = set_exp_attr_helper_name,
};
diff --git a/src/expect/snprintf_default.c b/src/expect/snprintf_default.c
index c4a19fa..bda39cc 100644
--- a/src/expect/snprintf_default.c
+++ b/src/expect/snprintf_default.c
@@ -102,6 +102,11 @@ int __snprintf_expect_default(char *buf,
&exp->master.tuple[__DIR_ORIG]);
BUFFER_SIZE(ret, size, len, offset);
+ if (test_bit(ATTR_EXP_HELPER_NAME, exp->set)) {
+ ret = snprintf(buf+offset, len, "helper=%s", exp->helper_name);
+ BUFFER_SIZE(ret, size, len, offset);
+ }
+
/* Delete the last blank space if needed */
if (len > 0 && buf[size-1] == ' ')
size--;