summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2010-10-07 17:43:41 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2010-10-07 17:43:41 +0200
commitb24f4ac006dcc3f2c6a904af2f3eb02bd4d16ea2 (patch)
treeb119f39119116ae8f61ecc34bc136f3c5d0f2809 /src
parentf0d7dcfeaafa01126d086e61b97d5330c73b8536 (diff)
expect: add CTA_EXPECT_ZONE support
We also remove the reference to CTA_EXPECT_QUEUENR with was not ever pushed into Linux kernel mainline. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/expect/build.c9
-rw-r--r--src/expect/getter.c8
-rw-r--r--src/expect/parse.c6
-rw-r--r--src/expect/setter.c8
-rw-r--r--src/expect/snprintf_default.c5
5 files changed, 34 insertions, 2 deletions
diff --git a/src/expect/build.c b/src/expect/build.c
index cb9071d..e7f547f 100644
--- a/src/expect/build.c
+++ b/src/expect/build.c
@@ -14,6 +14,12 @@ static void __build_timeout(struct nfnlhdr *req,
nfnl_addattr32(&req->nlh, size, CTA_EXPECT_TIMEOUT,htonl(exp->timeout));
}
+static void __build_zone(struct nfnlhdr *req, size_t size,
+ const struct nf_expect *exp)
+{
+ nfnl_addattr16(&req->nlh, size, CTA_EXPECT_ZONE, htons(exp->zone));
+}
+
int __build_expect(struct nfnl_subsys_handle *ssh,
struct nfnlhdr *req,
size_t size,
@@ -58,5 +64,8 @@ int __build_expect(struct nfnl_subsys_handle *ssh,
if (test_bit(ATTR_EXP_TIMEOUT, exp->set))
__build_timeout(req, size, exp);
+ if (test_bit(ATTR_EXP_ZONE, exp->set))
+ __build_zone(req, size, exp);
+
return 0;
}
diff --git a/src/expect/getter.c b/src/expect/getter.c
index 2a622af..d655c92 100644
--- a/src/expect/getter.c
+++ b/src/expect/getter.c
@@ -27,9 +27,15 @@ static const void *get_exp_attr_timeout(const struct nf_expect *exp)
return &exp->timeout;
}
-get_exp_attr get_exp_attr_array[] = {
+static const void *get_exp_attr_zone(const struct nf_expect *exp)
+{
+ return &exp->zone;
+}
+
+get_exp_attr get_exp_attr_array[ATTR_EXP_MAX] = {
[ATTR_EXP_MASTER] = get_exp_attr_master,
[ATTR_EXP_EXPECTED] = get_exp_attr_expected,
[ATTR_EXP_MASK] = get_exp_attr_mask,
[ATTR_EXP_TIMEOUT] = get_exp_attr_timeout,
+ [ATTR_EXP_ZONE] = get_exp_attr_zone,
};
diff --git a/src/expect/parse.c b/src/expect/parse.c
index fb7a021..f274497 100644
--- a/src/expect/parse.c
+++ b/src/expect/parse.c
@@ -54,4 +54,10 @@ void __parse_expect(const struct nlmsghdr *nlh,
ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_TIMEOUT-1]));
set_bit(ATTR_EXP_TIMEOUT, exp->set);
}
+
+ if (cda[CTA_EXPECT_ZONE-1]) {
+ exp->zone =
+ ntohs(*(u_int16_t *)NFA_DATA(cda[CTA_EXPECT_ZONE-1]));
+ set_bit(ATTR_EXP_ZONE, exp->set);
+ }
}
diff --git a/src/expect/setter.c b/src/expect/setter.c
index c962bb5..dbdad0b 100644
--- a/src/expect/setter.c
+++ b/src/expect/setter.c
@@ -27,9 +27,15 @@ static void set_exp_attr_timeout(struct nf_expect *exp, const void *value)
exp->timeout = *((u_int32_t *) value);
}
-set_exp_attr set_exp_attr_array[] = {
+static void set_exp_attr_zone(struct nf_expect *exp, const void *value)
+{
+ exp->zone = *((u_int16_t *) value);
+}
+
+set_exp_attr set_exp_attr_array[ATTR_EXP_MAX] = {
[ATTR_EXP_MASTER] = set_exp_attr_master,
[ATTR_EXP_EXPECTED] = set_exp_attr_expected,
[ATTR_EXP_MASK] = set_exp_attr_mask,
[ATTR_EXP_TIMEOUT] = set_exp_attr_timeout,
+ [ATTR_EXP_ZONE] = set_exp_attr_zone,
};
diff --git a/src/expect/snprintf_default.c b/src/expect/snprintf_default.c
index fec1586..e780bf1 100644
--- a/src/expect/snprintf_default.c
+++ b/src/expect/snprintf_default.c
@@ -43,6 +43,11 @@ int __snprintf_expect_default(char *buf,
ret = __snprintf_proto(buf+offset, len, &exp->expected.tuple[__DIR_ORIG]);
BUFFER_SIZE(ret, size, len, offset);
+ if (test_bit(ATTR_EXP_ZONE, exp->set)) {
+ ret = snprintf(buf+offset, len, "zone=%u ", exp->zone);
+ BUFFER_SIZE(ret, size, len, offset);
+ }
+
/* Delete the last blank space */
size--;