summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-02-03 11:24:07 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-02-03 11:24:07 +0000
commitbbf77c173d5a8a49d867875351f887b05cf190a6 (patch)
tree28b7676e228e202bb010860d36aa4ee3e89f8fe6 /util
parent2af9730138c2bc3298a41a8155b28bcc7381c895 (diff)
From: Eric leblond <eric@inl.fr>
This patch clarifies code which will be modified in next patch.
Diffstat (limited to 'util')
-rw-r--r--util/db.c2
-rw-r--r--util/printflow.c43
2 files changed, 29 insertions, 16 deletions
diff --git a/util/db.c b/util/db.c
index 1702acc..f72ce79 100644
--- a/util/db.c
+++ b/util/db.c
@@ -90,7 +90,7 @@ static int sql_createstmt(struct ulogd_pluginstance *upi)
return -ENOMEM;
}
- sprintf(mi->stmt, "CALL %s(", procedure);
+ sprintf(mi->stmt, "SELECT %s(", procedure);
mi->stmt_val = mi->stmt + strlen(mi->stmt);
diff --git a/util/printflow.c b/util/printflow.c
index aa354d4..1d0b9e9 100644
--- a/util/printflow.c
+++ b/util/printflow.c
@@ -28,6 +28,19 @@
#include <ulogd/ulogd.h>
#include <ulogd/printflow.h>
+enum printflow_fields {
+ PRINTFLOW_IP_SADDR = 0,
+ PRINTFLOW_IP_DADDR,
+ PRINTFLOW_IP_PROTOCOL,
+ PRINTFLOW_L4_SPORT,
+ PRINTFLOW_L4_DPORT,
+ PRINTFLOW_RAW_PKTLEN,
+ PRINTFLOW_RAW_PKTCOUNT,
+ PRINTFLOW_ICMP_CODE,
+ PRINTFLOW_ICMP_TYPE,
+ PRINTFLOW_DIR,
+};
+
struct ulogd_key printflow_keys[] = {
{
.type = ULOGD_RET_IPADDR,
@@ -94,38 +107,38 @@ int printflow_print(struct ulogd_key *res, char *buf)
{
char *buf_cur = buf;
- if (pp_is_valid(res, 9))
+ if (pp_is_valid(res, PRINTFLOW_DIR))
buf_cur += sprintf(buf_cur, "DIR=%s ",
- GET_VALUE(res, 9).b ? "REPLY" : "ORIG ");
+ GET_VALUE(res, PRINTFLOW_DIR).b ? "REPLY" : "ORIG ");
- if (pp_is_valid(res, 0))
+ if (pp_is_valid(res, PRINTFLOW_IP_SADDR))
buf_cur += sprintf(buf_cur, "SRC=%s ", inet_ntoa(
(struct in_addr) {htonl(GET_VALUE(res, 0).ui32)}));
- if (pp_is_valid(res, 1))
+ if (pp_is_valid(res, PRINTFLOW_IP_DADDR))
buf_cur += sprintf(buf_cur, "DST=%s ", inet_ntoa(
(struct in_addr) {htonl(GET_VALUE(res, 1).ui32)}));
- if (!pp_is_valid(res, 2))
+ if (!pp_is_valid(res, PRINTFLOW_IP_PROTOCOL))
goto out;
- switch (GET_VALUE(res, 2).ui8) {
+ switch (GET_VALUE(res, PRINTFLOW_IP_PROTOCOL).ui8) {
case IPPROTO_TCP:
buf_cur += sprintf(buf_cur, "PROTO=TCP ");
- pp_print(buf_cur, "SPT", res, 3, ui16);
- pp_print(buf_cur, "DPT", res, 4, ui16);
+ pp_print(buf_cur, "SPT", res, PRINTFLOW_L4_SPORT, ui16);
+ pp_print(buf_cur, "DPT", res, PRINTFLOW_L4_DPORT, ui16);
break;
case IPPROTO_UDP:
buf_cur += sprintf(buf_cur, "PROTO=UDP ");
- pp_print(buf_cur, "SPT", res, 3, ui16);
- pp_print(buf_cur, "DPT", res, 4, ui16);
+ pp_print(buf_cur, "SPT", res, PRINTFLOW_L4_SPORT, ui16);
+ pp_print(buf_cur, "DPT", res, PRINTFLOW_L4_DPORT, ui16);
break;
case IPPROTO_ICMP:
buf_cur += sprintf(buf_cur, "PROTO=ICMP ");
- pp_print(buf_cur, "TYPE", res, 7, ui8);
- pp_print(buf_cur, "CODE", res, 8, ui8);
+ pp_print(buf_cur, "TYPE", res, PRINTFLOW_ICMP_CODE, ui8);
+ pp_print(buf_cur, "CODE", res, PRINTFLOW_ICMP_TYPE, ui8);
break;
case IPPROTO_ESP:
@@ -137,13 +150,13 @@ int printflow_print(struct ulogd_key *res, char *buf)
break;
default:
- pp_print(buf_cur, "PROTO", res, 2, ui8);
+ pp_print(buf_cur, "PROTO", res, PRINTFLOW_IP_PROTOCOL, ui8);
break;
}
out:
- pp_print(buf_cur, "PKTS", res, 6, ui32);
- pp_print(buf_cur, "BYTES", res, 5, ui32);
+ pp_print(buf_cur, "PKTS", res, PRINTFLOW_RAW_PKTCOUNT, ui32);
+ pp_print(buf_cur, "BYTES", res, PRINTFLOW_RAW_PKTLEN, ui32);
strcat(buf_cur, "\n");
return 0;