summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/conntrack/api.c5
-rw-r--r--src/conntrack/snprintf_xml.c40
2 files changed, 43 insertions, 2 deletions
diff --git a/src/conntrack/api.c b/src/conntrack/api.c
index d020869..f2f3cb5 100644
--- a/src/conntrack/api.c
+++ b/src/conntrack/api.c
@@ -607,8 +607,9 @@ int nfct_catch(struct nfct_handle *h)
* - NFCT_O_XML: XML output
*
* The output flags are:
- * - NFCT_O_LAYER: include layer 3 information in the output, this is
- * *only* required by NFCT_O_DEFAULT.
+ * - NFCT_OF_SHOW_LAYER3: include layer 3 information in the output,
+ * this is *only* required by NFCT_O_DEFAULT.
+ * - NFCT_OF_TIME: display time.
*
* This function returns the size of the information that _would_ have been
* written to the buffer, even if there was no room for it. Thus, the
diff --git a/src/conntrack/snprintf_xml.c b/src/conntrack/snprintf_xml.c
index 1415e0d..9f7f388 100644
--- a/src/conntrack/snprintf_xml.c
+++ b/src/conntrack/snprintf_xml.c
@@ -341,6 +341,46 @@ int __snprintf_conntrack_xml(char *buf,
BUFFER_SIZE(ret, size, len, offset);
}
+ if (flags & NFCT_OF_TIME) {
+ time_t t;
+ struct tm tm;
+
+ t = time(NULL);
+ if (localtime_r(&t, &tm) == NULL)
+ goto err_out;
+
+ ret = snprintf(buf+offset, len, "<when>");
+ BUFFER_SIZE(ret, size, len, offset);
+
+ ret = snprintf(buf+offset, len, "<hour>%d</hour>", tm.tm_hour);
+ BUFFER_SIZE(ret, size, len, offset);
+
+ ret = snprintf(buf+offset, len, "<min>%02d</min>", tm.tm_min);
+ BUFFER_SIZE(ret, size, len, offset);
+
+ ret = snprintf(buf+offset, len, "<sec>%02d</sec>", tm.tm_sec);
+ BUFFER_SIZE(ret, size, len, offset);
+
+ ret = snprintf(buf+offset, len, "<wday>%d</wday>",
+ tm.tm_wday + 1);
+ BUFFER_SIZE(ret, size, len, offset);
+
+ ret = snprintf(buf+offset, len, "<day>%d</day>", tm.tm_mday);
+ BUFFER_SIZE(ret, size, len, offset);
+
+ ret = snprintf(buf+offset, len, "<month>%d</month>",
+ tm.tm_mon + 1);
+ BUFFER_SIZE(ret, size, len, offset);
+
+ ret = snprintf(buf+offset, len, "<year>%d</year>",
+ 1900 + tm.tm_year);
+ BUFFER_SIZE(ret, size, len, offset);
+
+ ret = snprintf(buf+offset, len, "</when>");
+ BUFFER_SIZE(ret, size, len, offset);
+ }
+
+err_out:
ret = snprintf(buf+offset, len, "</flow>");
BUFFER_SIZE(ret, size, len, offset);