summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Rules.make.in2
-rw-r--r--configure.in15
-rw-r--r--extensions/ulogd_BASE.c39
-rw-r--r--pgsql/ulogd_PGSQL.c43
4 files changed, 45 insertions, 54 deletions
diff --git a/Rules.make.in b/Rules.make.in
index 428b81f..e5339f3 100644
--- a/Rules.make.in
+++ b/Rules.make.in
@@ -36,5 +36,5 @@ MYSQL_LDFLAGS=@DATABASE_LIB_DIR@ @DATABASE_LIB@
# postgreSQL output support
#ULOGD_SL+=PGSQL
-PGSQL_CFLAGS=-I@PGSQLINCLUDES@
+PGSQL_CFLAGS=-I@PGSQLINCLUDES@ @EXTRA_PGSQL_DEF@
PGSQL_LDFLAGS=@DATABASE_LIB_DIR@ @DATABASE_LIB@
diff --git a/configure.in b/configure.in
index 4a749eb..bf4645f 100644
--- a/configure.in
+++ b/configure.in
@@ -175,11 +175,26 @@ else
fi
])
+dnl
+dnl Check whether the user wants to log IP-addresses as strings rather
+dnl than integers to his pgsql-database.
+dnl
+
+AC_ARG_WITH(pgsql-log-ip-as-string,
+ --with-pgsql-log-ip-as-string log IPs as string rather than as interger
+,[
+ EXTRA_PGSQL_DEF="-DIP_AS_STRING=1"
+])
+
+
+
+
AC_SUBST(DATABASE_DIR)
AC_SUBST(DATABASE_LIB)
AC_SUBST(DATABASE_LIB_DIR)
AC_SUBST(DB_DEF)
AC_SUBST(EXTRA_MYSQL_DEF)
+AC_SUBST(EXTRA_PGSQL_DEF)
AC_SUBST(DATABASE_DRIVERS)
AC_SUBST(HAVE_PCAP_H)
diff --git a/extensions/ulogd_BASE.c b/extensions/ulogd_BASE.c
index b383f8c..180370b 100644
--- a/extensions/ulogd_BASE.c
+++ b/extensions/ulogd_BASE.c
@@ -1,4 +1,4 @@
-/* ulogd_MAC.c, Version $Revision: 1.12 $
+/* ulogd_MAC.c, Version $Revision: 1.13 $
*
* ulogd interpreter plugin for
* o MAC addresses
@@ -26,7 +26,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * $Id: ulogd_BASE.c,v 1.12 2002/06/13 12:55:21 laforge Exp $
+ * $Id: ulogd_BASE.c,v 1.13 2002/08/25 15:43:51 laforge Exp $
*
*/
@@ -232,32 +232,23 @@ static ulog_iret_t *_interp_tcphdr(struct ulog_interpreter *ip,
ret[3].flags |= ULOGD_RETF_VALID;
ret[4].value.ui16 = ntohs(tcph->window);
ret[4].flags |= ULOGD_RETF_VALID;
+
+ ret[5].value.b = tcph->urg;
+ ret[5].flags |= ULOGD_RETF_VALID;
if (tcph->urg) {
- ret[5].value.b = tcph->urg;
- ret[5].flags |= ULOGD_RETF_VALID;
ret[6].value.ui16 = ntohs(tcph->urg_ptr);
ret[6].flags |= ULOGD_RETF_VALID;
}
- if (tcph->ack) {
- ret[7].value.b = tcph->ack;
- ret[7].flags |= ULOGD_RETF_VALID;
- }
- if (tcph->psh) {
- ret[8].value.b = tcph->psh;
- ret[8].flags |= ULOGD_RETF_VALID;
- }
- if (tcph->rst) {
- ret[9].value.b = tcph->rst;
- ret[9].flags |= ULOGD_RETF_VALID;
- }
- if (tcph->syn) {
- ret[10].value.b = tcph->syn;
- ret[10].flags |= ULOGD_RETF_VALID;
- }
- if (tcph->fin) {
- ret[11].value.b = tcph->fin;
- ret[11].flags |= ULOGD_RETF_VALID;
- }
+ ret[7].value.b = tcph->ack;
+ ret[7].flags |= ULOGD_RETF_VALID;
+ ret[8].value.b = tcph->psh;
+ ret[8].flags |= ULOGD_RETF_VALID;
+ ret[9].value.b = tcph->rst;
+ ret[9].flags |= ULOGD_RETF_VALID;
+ ret[10].value.b = tcph->syn;
+ ret[10].flags |= ULOGD_RETF_VALID;
+ ret[11].value.b = tcph->fin;
+ ret[11].flags |= ULOGD_RETF_VALID;
return ret;
}
diff --git a/pgsql/ulogd_PGSQL.c b/pgsql/ulogd_PGSQL.c
index a54a5ed..01c7b92 100644
--- a/pgsql/ulogd_PGSQL.c
+++ b/pgsql/ulogd_PGSQL.c
@@ -17,7 +17,8 @@
#include "ulogd.h"
#include "conffile.h"
-#ifdef DEBUG_PQSQL
+
+#ifdef DEBUG_PGSQL
#define DEBUGP(x, args...) fprintf(stderr, x, ## args)
#else
#define DEBUGP(x, args...)
@@ -123,21 +124,13 @@ static int _pgsql_output(ulog_iret_t *result)
sprintf(stmt_ins, "%u,", res->value.ui16);
break;
case ULOGD_RET_IPADDR:
-/* #ifdef IP_AS_STRING
+#ifdef IP_AS_STRING
*stmt_ins++ = '\'';
- tmpstr = inet_ntoa(ntohl(res->value.ui32));
-#ifdef OLD_PGSQL
- pgsql_escape_string(stmt_ins, tmpstr,
- strlen(tmpstr));
-#else
- pgsql_real_escape_string(dbh, stmt_ins,
- tmpstr,
- strlen(tmpstr));
-#endif /* OLD_PGSQL */
-/*
- stmt_ins = stmt + strlen(stmt);
- sprintf(stmt_ins, "',");
- break;
+ tmpstr = (char *)inet_ntoa(ntohl(res->value.ui32));
+ PQescapeString(stmt_ins,tmpstr,strlen(tmpstr));
+ stmt_ins = stmt + strlen(stmt);
+ sprintf(stmt_ins, "',");
+ break;
#endif /* IP_AS_STRING */
/* EVIL: fallthrough when logging IP as
* u_int32_t */
@@ -149,25 +142,17 @@ static int _pgsql_output(ulog_iret_t *result)
sprintf(stmt_ins, "%lu,", res->value.ui64);
break;
case ULOGD_RET_BOOL:
- sprintf(stmt_ins, "1,");
+ sprintf(stmt_ins, "'%d',", res->value.b);
break;
case ULOGD_RET_STRING:
*stmt_ins++ = '\'';
-/* Change by Jaki
-#ifdef OLD_PGSQL
- pgsql_escape_string(stmt_ins, res->value.ptr,
- strlen(res->value.ptr));
-#else
- pgsql_real_escape_string(dbh, stmt_ins,
- res->value.ptr, strlen(res->value.ptr));
-#endif
-*End Change by Jaki
-*/
- strcpy(stmt_ins,"\'");
- strcpy(stmt_ins,res->value.ptr); /* Added by Jaki */
+ PQescapeString(stmt_ins,res->value.ptr,strlen(res->value.ptr));
stmt_ins = stmt + strlen(stmt);
sprintf(stmt_ins, "',");
- /* sprintf(stmt_ins, "'%s',", res->value.ptr); */
+ break;
+ case ULOGD_RET_RAW:
+ ulogd_log(ULOGD_NOTICE,"%s: pgsql doesn't support type RAW\n",res->key);
+ sprintf(stmt_ins, "NULL,");
break;
default:
ulogd_log(ULOGD_NOTICE,