[netfilter-cvslog] r6285 - in branches/ulog/ulogd2: . input/flow input/packet libipulog output/mysql

laforge at netfilter.org laforge at netfilter.org
Tue Nov 29 09:43:53 CET 2005


Author: laforge at netfilter.org
Date: 2005-11-29 09:43:51 +0100 (Tue, 29 Nov 2005)
New Revision: 6285

Modified:
   branches/ulog/ulogd2/configure.in
   branches/ulog/ulogd2/input/flow/Makefile.am
   branches/ulog/ulogd2/input/packet/Makefile.am
   branches/ulog/ulogd2/input/packet/ulogd_inppkt_NFLOG.c
   branches/ulog/ulogd2/libipulog/Makefile.am
   branches/ulog/ulogd2/output/mysql/Makefile.am
   branches/ulog/ulogd2/output/mysql/ulogd_output_MYSQL.c
Log:
fixes


Modified: branches/ulog/ulogd2/configure.in
===================================================================
--- branches/ulog/ulogd2/configure.in	2005-11-26 23:54:59 UTC (rev 6284)
+++ branches/ulog/ulogd2/configure.in	2005-11-29 08:43:51 UTC (rev 6285)
@@ -31,6 +31,9 @@
 AC_CHECK_HEADER([libnetfilter_log/linux_nfnetlink_log.h], [AC_MSG_RESULT([found])],
 		[AC_MSG_ERROR([libnetfilter_log Version 0.0.11 or later needed])])
 
+AC_CHECK_HEADER([libnetfilter_conntrack/libnetfilter_conntrack.h], [AC_MSG_RESULT([found])],
+		[AC_MSG_ERROR([libnetfilter_conntrack Version 0.0.11 or later needed])])
+
 DATABASE_DIR=""
 DATABASE_LIB=""
 DATABASE_LIB_DIR=""
@@ -71,7 +74,7 @@
 then
         AC_MSG_WARN(MySQL backend not used)
 else
-        AC_DEFINE(HAVE_MYSQL)
+        AC_DEFINE([HAVE_MYSQL], [], [Description])
         MYSQLINCLUDES=${mysqldir}/include${mysqldir_suffix}
         MYSQLLIBS=${mysqldir}/lib${mysqldir_suffix}
 
@@ -165,7 +168,7 @@
 then
         AC_MSG_WARN(PGSQL backend not used)
 else
-        AC_DEFINE(HAVE_PGSQL)
+        AC_DEFINE([HAVE_PGSQL], [], [Description])
 	for i in include include/postgresql include/pgsql
 	do
 		if test -f ${pgsqldir}/$i/libpq-fe.h
@@ -216,4 +219,4 @@
 AM_CONDITIONAL(HAVE_MYSQL, test x$mysqldir != x)
 AM_CONDITIONAL(HAVE_PGSQL, test x$pgsqldir != x)
 
-AC_OUTPUT(doc/Makefile conffile/Makefile libipulog/Makefile input/Makefile input/packet/Makefile input/flow/Makefile filter/Makefile filter/raw2packet/Makefile filter/packet2flow/Makefile output/Makefile output/pcap/Makefile output/mysql/Makefile output/pgsql/Makefile src/Makefile Makefile Rules.make)
+AC_OUTPUT(doc/Makefile libipulog/Makefile input/Makefile input/packet/Makefile input/flow/Makefile filter/Makefile filter/raw2packet/Makefile filter/packet2flow/Makefile output/Makefile output/pcap/Makefile output/mysql/Makefile output/pgsql/Makefile src/Makefile Makefile Rules.make)

Modified: branches/ulog/ulogd2/input/flow/Makefile.am
===================================================================
--- branches/ulog/ulogd2/input/flow/Makefile.am	2005-11-26 23:54:59 UTC (rev 6284)
+++ branches/ulog/ulogd2/input/flow/Makefile.am	2005-11-29 08:43:51 UTC (rev 6285)
@@ -1,6 +1,6 @@
 
 INCLUDES = $(all_includes) -I$(top_srcdir)/include
-CFLAGS=-fPIC -Wall
+AM_CFLAGS=-fPIC -Wall
 
 pkglib_LTLIBRARIES = ulogd_inpflow_NFCT.la # ulogd_inpflow_IPFIX.la
 

Modified: branches/ulog/ulogd2/input/packet/Makefile.am
===================================================================
--- branches/ulog/ulogd2/input/packet/Makefile.am	2005-11-26 23:54:59 UTC (rev 6284)
+++ branches/ulog/ulogd2/input/packet/Makefile.am	2005-11-29 08:43:51 UTC (rev 6285)
@@ -1,6 +1,6 @@
 
 INCLUDES = $(all_includes) -I$(top_srcdir)/include
-CFLAGS=-fPIC -Wall
+AM_CFLAGS=-fPIC -Wall
 LIBS=
 
 pkglib_LTLIBRARIES = ulogd_inppkt_NFLOG.la ulogd_inppkt_ULOG.la

Modified: branches/ulog/ulogd2/input/packet/ulogd_inppkt_NFLOG.c
===================================================================
--- branches/ulog/ulogd2/input/packet/ulogd_inppkt_NFLOG.c	2005-11-26 23:54:59 UTC (rev 6284)
+++ branches/ulog/ulogd2/input/packet/ulogd_inppkt_NFLOG.c	2005-11-29 08:43:51 UTC (rev 6285)
@@ -191,7 +191,7 @@
 	struct nfulnl_msg_packet_hdr *ph = nflog_get_msg_packet_hdr(ldata);
 	struct nfulnl_msg_packet_hw *hw = nflog_get_packet_hw(ldata);
 	void *payload;
-	int payload_len = nflog_get_payload(ldata, payload);
+	int payload_len = nflog_get_payload(ldata, &payload);
 	char *prefix = nflog_get_prefix(ldata);
 	struct timeval ts;
 	u_int32_t mark = nflog_get_nfmark(ldata);

Modified: branches/ulog/ulogd2/libipulog/Makefile.am
===================================================================
--- branches/ulog/ulogd2/libipulog/Makefile.am	2005-11-26 23:54:59 UTC (rev 6284)
+++ branches/ulog/ulogd2/libipulog/Makefile.am	2005-11-29 08:43:51 UTC (rev 6285)
@@ -1,5 +1,5 @@
 
-CFLAGS=-fPIC
+AM_CFLAGS=-fPIC
 
 noinst_LIBRARIES = libipulog.a
 

Modified: branches/ulog/ulogd2/output/mysql/Makefile.am
===================================================================
--- branches/ulog/ulogd2/output/mysql/Makefile.am	2005-11-26 23:54:59 UTC (rev 6284)
+++ branches/ulog/ulogd2/output/mysql/Makefile.am	2005-11-29 08:43:51 UTC (rev 6285)
@@ -1,6 +1,6 @@
 
 INCLUDES = $(all_includes) -I$(top_srcdir)/include
-LIBS=
+LIBS=-lmysqlclient_r
 
 pkglib_LTLIBRARIES = ulogd_output_MYSQL.la
 

Modified: branches/ulog/ulogd2/output/mysql/ulogd_output_MYSQL.c
===================================================================
--- branches/ulog/ulogd2/output/mysql/ulogd_output_MYSQL.c	2005-11-26 23:54:59 UTC (rev 6284)
+++ branches/ulog/ulogd2/output/mysql/ulogd_output_MYSQL.c	2005-11-29 08:43:51 UTC (rev 6285)
@@ -157,8 +157,7 @@
 			
 		if (!res || !IS_VALID(*res)) {
 			/* no result, we have to fake something */
-			sprintf(mi->stmt_ins, "NULL,");
-			mi->stmt_ins = mi->stmt + strlen(mi->stmt);
+			mi->stmt_ins += sprintf(mi->stmt_ins, "NULL,");
 			continue;
 		}
 		
@@ -187,14 +186,14 @@
 				addr.s_addr = ntohl(res->u.value.ui32);
 				*(mi->stmt_ins++) = '\'';
 				tmpstr = inet_ntoa(addr);
-#ifdef OLD_MYSQL
+			#ifdef OLD_MYSQL
 				mysql_escape_string(mi->stmt_ins, tmpstr,
 						    strlen(tmpstr));
-#else
+			#else
 				mysql_real_escape_string(mi->dbh, mi->stmt_ins,
 							 tmpstr,
 						 	strlen(tmpstr));
-#endif /* OLD_MYSQL */
+			#endif /* OLD_MYSQL */
                                 mi->stmt_ins = mi->stmt + strlen(mi->stmt);
 				sprintf(mi->stmt_ins, "',");
 				break;
@@ -211,14 +210,18 @@
 			break;
 		case ULOGD_RET_STRING:
 			*(mi->stmt_ins++) = '\'';
-#ifdef OLD_MYSQL
-			mysql_escape_string(mi->stmt_ins, res->u.value.ptr,
-				strlen(res->u.value.ptr));
-#else
-			mysql_real_escape_string(mi->dbh, mi->stmt_ins,
-				res->u.value.ptr, strlen(res->u.value.ptr));
-#endif
-			mi->stmt_ins = mi->stmt + strlen(mi->stmt);
+			if (res->u.value.ptr) {
+			#ifdef OLD_MYSQL
+				mi->stmt_ins += mysql_escape_string(mi->stmt_ins, 
+							res->u.value.ptr,
+							strlen(res->u.value.ptr));
+			#else
+				mi->stmt_ins += mysql_real_escape_string(
+							mi->dbh, mi->stmt_ins, 
+							res->u.value.ptr, 
+							strlen(res->u.value.ptr));
+			#endif
+			}
 			sprintf(mi->stmt_ins, "',");
 			break;
 		case ULOGD_RET_RAW:
@@ -334,13 +337,10 @@
 	 * never free()s the memory we allocate here.  FIXME. */
 
 	/* Cleanup before reconnect */
-	if (upi->input.keys) {
+	if (upi->input.keys)
 		free(upi->input.keys);
-		upi->input.keys = NULL;
-		upi->input.num_keys = 0;
-	}
 
-	upi->input.num_keys = mysql_field_count(mi->dbh);
+	upi->input.num_keys = mysql_num_fields(result);
 	upi->input.keys = malloc(sizeof(struct ulogd_key) * 
 						upi->input.num_keys);
 	if (!upi->input.keys) {
@@ -351,8 +351,7 @@
 	memset(upi->input.keys, 0, sizeof(struct ulogd_key) *
 						upi->input.num_keys);
 
-	i = 0;
-	while ((field = mysql_fetch_field(result))) {
+	for (i = 0; field = mysql_fetch_field(result); i++) {
 		char buf[ULOGD_MAX_KEYLEN+1];
 		char *underscore;
 		int id;
@@ -366,9 +365,10 @@
 
 		/* add it u list of input keys */
 		strncpy(upi->input.keys[i].name, buf, ULOGD_MAX_KEYLEN);
-		i++;
 	}
-
+	/* MySQL Auto increment ... ID :) */
+	upi->input.keys[0].flags |= ULOGD_KEYF_INACTIVE;
+	
 	mysql_free_result(result);
 	return 0;
 }
@@ -390,7 +390,7 @@
 
 	if (!mysql_real_connect(mi->dbh, server, user, pass, db, port, NULL, 0))
 		return -1;
-
+		
 	return 0;
 }
 
@@ -472,7 +472,7 @@
 		      db_ce(upi->config_kset).u.string);
 	if (ret < 0)
 		return ret;
-	
+
 	/* Third: Determine required input keys for given table */
 	ret = mysql_get_columns(upi);
 	




More information about the netfilter-cvslog mailing list