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=""
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}
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
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)
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;
}
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;
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:
* 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) {
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;
/* 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;
}
if (!mysql_real_connect(mi->dbh, server, user, pass, db, port, NULL, 0))
return -1;
-
+
return 0;
}
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);