diff options
author | Gaurav Sinha <gaurav.sinha@vyatta.com> | 2012-01-18 12:05:50 -0800 |
---|---|---|
committer | Gaurav Sinha <gaurav.sinha@vyatta.com> | 2012-01-18 12:05:50 -0800 |
commit | e72ca98329a25414108e2af350c4014de9e8f736 (patch) | |
tree | dfd32da0647916edf9a055e44d9d59596a3721a8 /src/log.c | |
parent | fa0e506210775233cb34513d45878991ef50aae6 (diff) | |
parent | ca37a710d526d17490ebdc3af760bfddd316426d (diff) | |
download | conntrack-tools-e72ca98329a25414108e2af350c4014de9e8f736.tar.gz conntrack-tools-e72ca98329a25414108e2af350c4014de9e8f736.zip |
Creating development branch expect-sync, has merged content from oxnard and upstreamexpect-sync
Diffstat (limited to 'src/log.c')
-rw-r--r-- | src/log.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -145,6 +145,43 @@ void dlog_ct(FILE *fd, struct nf_conntrack *ct, unsigned int type) } } +void dlog_exp(FILE *fd, struct nf_expect *exp, unsigned int type) +{ + time_t t; + char buf[1024]; + char *tmp; + unsigned int flags = 0; + + buf[0]='\0'; + + switch(type) { + case NFCT_O_PLAIN: + t = time(NULL); + ctime_r(&t, buf); + tmp = buf + strlen(buf); + buf[strlen(buf)-1]='\t'; + break; + default: + return; + } + nfexp_snprintf(buf+strlen(buf), 1024-strlen(buf), exp, 0, type, flags); + + if (fd) { + snprintf(buf+strlen(buf), 1024-strlen(buf), "\n"); + fputs(buf, fd); + } + + if (fd == STATE(log)) { + /* error reporting */ + if (CONFIG(syslog_facility) != -1) + syslog(LOG_ERR, "%s", tmp); + } else if (fd == STATE(stats_log)) { + /* connection logging */ + if (CONFIG(stats).syslog_facility != -1) + syslog(LOG_INFO, "%s", tmp); + } +} + void close_log(void) { if (STATE(log) != NULL) |