summaryrefslogtreecommitdiffstats
path: root/src/expect/snprintf_default.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2010-10-07 17:43:50 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2010-10-07 17:43:50 +0200
commit92e66d4e07d20e73606e2110144199b81663dc35 (patch)
tree7e0ef1425480c079e9de53745830bd9d2cdf62e3 /src/expect/snprintf_default.c
parentb24f4ac006dcc3f2c6a904af2f3eb02bd4d16ea2 (diff)
expect: add support for CTA_EXPECT_FLAGS
This patch allows to set the expectation flags from user-space. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expect/snprintf_default.c')
-rw-r--r--src/expect/snprintf_default.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/expect/snprintf_default.c b/src/expect/snprintf_default.c
index e780bf1..7b088e7 100644
--- a/src/expect/snprintf_default.c
+++ b/src/expect/snprintf_default.c
@@ -23,6 +23,7 @@ int __snprintf_expect_default(char *buf,
unsigned int flags)
{
int ret = 0, size = 0, offset = 0;
+ char *delim = "";
switch(msg_type) {
case NFCT_T_NEW:
@@ -48,8 +49,24 @@ int __snprintf_expect_default(char *buf,
BUFFER_SIZE(ret, size, len, offset);
}
- /* Delete the last blank space */
- size--;
+ if (exp->flags & NF_CT_EXPECT_PERMANENT) {
+ ret = snprintf(buf+offset, len, "PERMANENT");
+ BUFFER_SIZE(ret, size, len, offset);
+ delim = ",";
+ }
+ if (exp->flags & NF_CT_EXPECT_INACTIVE) {
+ ret = snprintf(buf+offset, len, "%sINACTIVE", delim);
+ BUFFER_SIZE(ret, size, len, offset);
+ delim = ",";
+ }
+ if (exp->flags & NF_CT_EXPECT_USERSPACE) {
+ ret = snprintf(buf+offset, len, "%sUSERSPACE", delim);
+ BUFFER_SIZE(ret, size, len, offset);
+ }
+
+ /* Delete the last blank space if needed */
+ if (len > 0 && buf[size-1] == ' ')
+ size--;
return size;
}