summaryrefslogtreecommitdiffstats
path: root/src/expect
diff options
context:
space:
mode:
Diffstat (limited to 'src/expect')
-rw-r--r--src/expect/build.c9
-rw-r--r--src/expect/compare.c9
-rw-r--r--src/expect/getter.c6
-rw-r--r--src/expect/parse.c5
-rw-r--r--src/expect/setter.c6
-rw-r--r--src/expect/snprintf_default.c13
-rw-r--r--src/expect/snprintf_xml.c5
7 files changed, 53 insertions, 0 deletions
diff --git a/src/expect/build.c b/src/expect/build.c
index 7fefd5f..ffc7b84 100644
--- a/src/expect/build.c
+++ b/src/expect/build.c
@@ -28,6 +28,13 @@ static void __build_flags(struct nfnlhdr *req,
nfnl_addattr32(&req->nlh, size, CTA_EXPECT_FLAGS,htonl(exp->flags));
}
+static void __build_class(struct nfnlhdr *req,
+ size_t size,
+ const struct nf_expect *exp)
+{
+ nfnl_addattr32(&req->nlh, size, CTA_EXPECT_CLASS, htonl(exp->class));
+}
+
static void __build_helper_name(struct nfnlhdr *req, size_t size,
const struct nf_expect *exp)
{
@@ -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_CLASS, exp->set))
+ __build_class(req, size, exp);
if (test_bit(ATTR_EXP_HELPER_NAME, exp->set))
__build_helper_name(req, size, exp);
diff --git a/src/expect/compare.c b/src/expect/compare.c
index 65ec9c2..c1bb50f 100644
--- a/src/expect/compare.c
+++ b/src/expect/compare.c
@@ -36,6 +36,13 @@ cmp_exp_flags(const struct nf_expect *exp1, const struct nf_expect *exp,
return (exp->flags == exp->flags);
}
+static int
+cmp_exp_class(const struct nf_expect *exp1, const struct nf_expect *exp,
+ unsigned int flags)
+{
+ return (exp->class == exp->class);
+}
+
int __cmp_expect(const struct nf_expect *exp1,
const struct nf_expect *exp2,
unsigned int flags)
@@ -54,6 +61,8 @@ int __cmp_expect(const struct nf_expect *exp1,
}
if (!exp_cmp(ATTR_EXP_FLAGS, exp1, exp2, flags, cmp_exp_flags))
return 0;
+ if (!exp_cmp(ATTR_EXP_CLASS, exp1, exp2, flags, cmp_exp_class))
+ return 0;
return 1;
}
diff --git a/src/expect/getter.c b/src/expect/getter.c
index 2f8df76..06c3bca 100644
--- a/src/expect/getter.c
+++ b/src/expect/getter.c
@@ -39,6 +39,11 @@ static const void *get_exp_attr_flags(const struct nf_expect *exp)
return &exp->flags;
}
+static const void *get_exp_attr_class(const struct nf_expect *exp)
+{
+ return &exp->class;
+}
+
static const void *get_exp_attr_helper_name(const struct nf_expect *exp)
{
return exp->helper_name;
@@ -52,4 +57,5 @@ const get_exp_attr get_exp_attr_array[ATTR_EXP_MAX] = {
[ATTR_EXP_ZONE] = get_exp_attr_zone,
[ATTR_EXP_FLAGS] = get_exp_attr_flags,
[ATTR_EXP_HELPER_NAME] = get_exp_attr_helper_name,
+ [ATTR_EXP_CLASS] = get_exp_attr_class,
};
diff --git a/src/expect/parse.c b/src/expect/parse.c
index bee755d..8b6dd5f 100644
--- a/src/expect/parse.c
+++ b/src/expect/parse.c
@@ -84,4 +84,9 @@ void __parse_expect(const struct nlmsghdr *nlh,
NFA_PAYLOAD(cda[CTA_EXPECT_HELP_NAME-1]));
set_bit(ATTR_EXP_HELPER_NAME, exp->set);
}
+ if (cda[CTA_EXPECT_CLASS-1]) {
+ exp->class =
+ ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_CLASS-1]));
+ set_bit(ATTR_EXP_CLASS, exp->set);
+ }
}
diff --git a/src/expect/setter.c b/src/expect/setter.c
index 89a3157..b78f4f6 100644
--- a/src/expect/setter.c
+++ b/src/expect/setter.c
@@ -39,6 +39,11 @@ static void set_exp_attr_flags(struct nf_expect *exp, const void *value)
exp->flags = *((u_int32_t *) value);
}
+static void set_exp_attr_class(struct nf_expect *exp, const void *value)
+{
+ exp->class = *((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_NAME_MAX);
@@ -53,4 +58,5 @@ const set_exp_attr set_exp_attr_array[ATTR_EXP_MAX] = {
[ATTR_EXP_ZONE] = set_exp_attr_zone,
[ATTR_EXP_FLAGS] = set_exp_attr_flags,
[ATTR_EXP_HELPER_NAME] = set_exp_attr_helper_name,
+ [ATTR_EXP_CLASS] = set_exp_attr_class,
};
diff --git a/src/expect/snprintf_default.c b/src/expect/snprintf_default.c
index 77f9c3b..44b7719 100644
--- a/src/expect/snprintf_default.c
+++ b/src/expect/snprintf_default.c
@@ -19,6 +19,16 @@ __snprintf_expect_timeout(char *buf, unsigned int len,
return 0;
}
+static int
+__snprintf_expect_class(char *buf, unsigned int len,
+ const struct nf_expect *exp)
+{
+ if (test_bit(ATTR_EXP_CLASS, exp->set))
+ return snprintf(buf, len, "class=%u ", exp->class);
+
+ return 0;
+}
+
static int __snprintf_expect_proto(char *buf,
unsigned int len,
const struct nf_expect *exp)
@@ -101,6 +111,9 @@ int __snprintf_expect_default(char *buf,
BUFFER_SIZE(ret, size, len, offset);
}
+ ret = __snprintf_expect_class(buf+offset, len, exp);
+ 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);
diff --git a/src/expect/snprintf_xml.c b/src/expect/snprintf_xml.c
index 9f11c59..1e6027f 100644
--- a/src/expect/snprintf_xml.c
+++ b/src/expect/snprintf_xml.c
@@ -70,6 +70,11 @@ snprintf_expect_meta_xml(char *buf, size_t len,
exp->timeout);
BUFFER_SIZE(ret, size, len, offset);
}
+ if (test_bit(ATTR_EXP_CLASS, exp->set)) {
+ ret = snprintf(buf+offset, len, "<class>%u</class>",
+ exp->class);
+ BUFFER_SIZE(ret, size, len, offset);
+ }
if (test_bit(ATTR_EXP_ZONE, exp->set)) {
ret = snprintf(buf+offset, len, "<zone>%u</zone>", exp->zone);
BUFFER_SIZE(ret, size, len, offset);