From 92e66d4e07d20e73606e2110144199b81663dc35 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 7 Oct 2010 17:43:50 +0200 Subject: expect: add support for CTA_EXPECT_FLAGS This patch allows to set the expectation flags from user-space. Signed-off-by: Pablo Neira Ayuso --- src/expect/snprintf_default.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/expect/snprintf_default.c') 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; } -- cgit v1.2.3