Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 50926 | Differences between
and this patch

Collapse All | Expand All

(-)flow-tools-0.67.orig/configure (-2 / +2 lines)
Lines 3279-3285 Link Here
3279
fi
3279
fi
3280
3280
3281
if test "x$WHERE_PGSQL" != "x"; then
3281
if test "x$WHERE_PGSQL" != "x"; then
3282
  LIBS="-L$WHERE_PGSQL/lib/pgsql"
3282
  LIBS="-L$WHERE_PGSQL/lib"
3283
  echo "$as_me:$LINENO: checking for PQsetdbLogin in -lpq" >&5
3283
  echo "$as_me:$LINENO: checking for PQsetdbLogin in -lpq" >&5
3284
echo $ECHO_N "checking for PQsetdbLogin in -lpq... $ECHO_C" >&6
3284
echo $ECHO_N "checking for PQsetdbLogin in -lpq... $ECHO_C" >&6
3285
if test "${ac_cv_lib_pq_PQsetdbLogin+set}" = set; then
3285
if test "${ac_cv_lib_pq_PQsetdbLogin+set}" = set; then
Lines 3336-3342 Link Here
3336
echo "${ECHO_T}$ac_cv_lib_pq_PQsetdbLogin" >&6
3336
echo "${ECHO_T}$ac_cv_lib_pq_PQsetdbLogin" >&6
3337
if test $ac_cv_lib_pq_PQsetdbLogin = yes; then
3337
if test $ac_cv_lib_pq_PQsetdbLogin = yes; then
3338
3338
3339
      PGSQLCFLAGS="-L$WHERE_PGSQL/lib -I$WHERE_PGSQL/include/pgsql"
3339
      PGSQLCFLAGS="-L$WHERE_PGSQL/lib -I$WHERE_PGSQL/include"
3340
      PGSQLLIB="-lpq"
3340
      PGSQLLIB="-lpq"
3341
      cat >>confdefs.h <<\_ACEOF
3341
      cat >>confdefs.h <<\_ACEOF
3342
#define HAVE_PGSQL 1
3342
#define HAVE_PGSQL 1
(-)flow-tools-0.67.orig/src/flow-export.c (-23 / +38 lines)
Lines 67-73 Link Here
67
#define DB_DEFAULT_DBHOST "localhost"
67
#define DB_DEFAULT_DBHOST "localhost"
68
#define DB_DEFAULT_DBNAME "netflow"
68
#define DB_DEFAULT_DBNAME "netflow"
69
#define DB_DEFAULT_DBPORT "5432"
69
#define DB_DEFAULT_DBPORT "5432"
70
#define DB_DEFAULT_DBTABLE "raw"
70
#define DB_DEFAULT_DBTABLE "netflow"
71
#define DB_DEFAULT_DBUSER "netflow"
71
#define DB_DEFAULT_DBUSER "netflow"
72
#define DB_DEFAULT_DBPWD "netflow"
72
#define DB_DEFAULT_DBPWD "netflow"
73
73
Lines 115-127 Link Here
115
struct jump format[] = {{format0}, {format1}, {format2}, {format3},
115
struct jump format[] = {{format0}, {format1}, {format2}, {format3},
116
                        {format4}, {format5}};
116
                        {format4}, {format5}};
117
117
118
int debug;
119
118
int main(int argc, char **argv)
120
int main(int argc, char **argv)
119
{
121
{
120
  int i, format_index, ret, ascii_mask;
122
  int i, format_index, ret, ascii_mask;
121
  struct ftio ftio;
123
  struct ftio ftio;
122
  struct ftprof ftp;
124
  struct ftprof ftp;
123
  struct options opt;
125
  struct options opt;
124
  int debug;
125
126
126
  /* init fterr */
127
  /* init fterr */
127
  fterr_setid(argv[0]);
128
  fterr_setid(argv[0]);
Lines 758-770 Link Here
758
      strcat (query, values);
759
      strcat (query, values);
759
      strcat (query, ")");
760
      strcat (query, ")");
760
761
761
      if (debug)
762
/*      if (debug)
762
        fprintf(stderr, "field=%s\n val=%s\n query=%s\n", fields, values,
763
        fprintf(stderr, "field=%s\n val=%s\n query=%s\n", fields, values,
763
          query);
764
          query);
764
765
765
      if (mysql_real_query(&mysql, query, strlen(query)) != 0) 
766
      if (mysql_real_query(&mysql, query, strlen(query)) != 0) 
766
        fterr_warnx("mysql_real_query(): %s", mysql_error(&mysql));
767
        fterr_warnx("mysql_real_query(): %s", mysql_error(&mysql));
767
768
*/
768
    }
769
    }
769
770
770
    ++opt->records;
771
    ++opt->records;
Lines 868-873 Link Here
868
  char *db_port;
869
  char *db_port;
869
  int len;
870
  int len;
870
871
872
  static char connstring[100];
871
  PGconn     *conn;
873
  PGconn     *conn;
872
  PGresult   *res;
874
  PGresult   *res;
873
875
Lines 887-925 Link Here
887
    db_user = strsep(&tmp, ":");
889
    db_user = strsep(&tmp, ":");
888
    db_pwd = strsep(&tmp, ":");
890
    db_pwd = strsep(&tmp, ":");
889
    db_host = strsep(&tmp, ":");
891
    db_host = strsep(&tmp, ":");
890
    db_port = strsep(&tmp, ":");
892
    db_tmp = strsep(&tmp, ":");
891
    db_name = strsep(&tmp, ":");
893
    db_name = strsep(&tmp, ":");
892
    db_table = strsep(&tmp, ":");
894
    db_table = strsep(&tmp, ":");
895
    db_port = atoi(db_tmp); 
893
896
894
    if (!db_user || !db_pwd || !db_host || !db_tmp || !db_name || !db_table) {
897
    if (!db_user || !db_pwd || !db_host || !db_tmp || !db_name || !db_table) {
898
 
895
      fterr_warnx("Missing field in dbaseURI, expecting user:pwd:host:port:name:table.");
899
      fterr_warnx("Missing field in dbaseURI, expecting user:pwd:host:port:name:table.");
896
      return -1;
900
901
    return -1;
897
    }
902
    }
898
903
899
  } /* dbaseURI */
904
  } /* dbaseURI */
900
905
906
901
  ftio_get_ver(ftio, &ftv);
907
  ftio_get_ver(ftio, &ftv);
902
908
903
  fts3rec_compute_offsets(&fo, &ftv);
909
  fts3rec_compute_offsets(&fo, &ftv);
904
910
 
905
  /* remove invalid fields */
911
  /* remove invalid fields */
906
  opt->ft_mask &= ftrec_xfield(&ftv);
912
  opt->ft_mask &= ftrec_xfield(&ftv);
907
913
908
  /* generate the field names once */
914
  /* generate the field names once */
909
  fmt_xfields_type(fields, opt->ft_mask);
915
  fmt_xfields_type(fields, opt->ft_mask);
916
   
917
  if (strlen(db_user)) { strcat(connstring,"user="); strcat(connstring,db_user); strcat(connstring," "); } 
918
  if (strlen(db_pwd))  { strcat(connstring,"password="); strcat(connstring,db_pwd); strcat(connstring," "); }
919
  if (strlen(db_name)) { strcat(connstring,"dbname="); strcat(connstring,db_name); strcat(connstring," "); }
920
  if (strlen(db_host)) { strcat(connstring,"host="); strcat(connstring,db_host); strcat(connstring," "); }
921
  if (strlen(db_tmp)) { strcat(connstring,"port="); strcat(connstring,db_tmp); strcat(connstring," "); }
910
922
911
  /* open PostgreSQL database */
923
  conn = PQconnectdb(connstring);
912
  conn = PQsetdbLogin(db_host, db_port, (char *) NULL, (char *) NULL, db_name, db_user, db_pwd);
913
924
914
  if (PQstatus(conn) == CONNECTION_BAD) 
925
  if (PQstatus(conn) == CONNECTION_BAD) 
915
    fterr_errx(1,"PQsetdbLogin(): %s\n", PQerrorMessage(conn));
926
    fterr_errx(1,"PQsetdbLogin(): %s\n", PQerrorMessage(conn));
916
927
917
  /* foreach flow */
928
  /* foreach flow */
929
918
  while ((rec = ftio_read(ftio))) {
930
  while ((rec = ftio_read(ftio))) {
919
931
920
    len = fmt_xfields_val(values, rec, &fo, opt->ft_mask, 1);
932
    len = fmt_xfields_val(values, rec, &fo, opt->ft_mask, 1);
921
933
922
    /* form SQL query and execute it */
934
    /* form SQL query and execute it */
935
923
    if (len) {
936
    if (len) {
924
      strcpy (query, "INSERT INTO ");
937
      strcpy (query, "INSERT INTO ");
925
      strcat (query, db_table);
938
      strcat (query, db_table);
Lines 929-942 Link Here
929
      strcat (query, values);
942
      strcat (query, values);
930
      strcat (query, ")");
943
      strcat (query, ")");
931
944
932
      if (debug)
945
/*      if (debug)
933
        fprintf(stderr, "field=%s\n val=%s\n query=%s\n", fields, values,
946
        fprintf(stderr, "field=%s\n val=%s\n query=%s\n", fields, values,
934
          query);
947
          query);
935
948
*/
936
      res = PQexec(conn, query);
949
      res = PQexec(conn, query);
937
      if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) {
950
      if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) {
938
        PQclear(res);
951
        PQclear(res);
939
        fterr_errx(1,"PQexec(): %s\n", PQerrorMessage(conn));
952
        fterr_errx(1,"PQexec(): %s\n", PQerrorMessage(conn));
953
	} else if (res) {
954
	PQclear(res);
940
      }
955
      }
941
956
942
    }
957
    }
Lines 1199-1208 Link Here
1199
1214
1200
  if (xfields & FT_XFIELD_EXADDR) {
1215
  if (xfields & FT_XFIELD_EXADDR) {
1201
    if (comma) fmt_buf[len++] = ',';
1216
    if (comma) fmt_buf[len++] = ',';
1202
    if (quote) fmt_buf[len++] = '"';
1217
    if (quote) fmt_buf[len++] = '\'';
1203
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->exaddr)),
1218
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->exaddr)),
1204
      FMT_JUST_LEFT);
1219
      FMT_JUST_LEFT);
1205
    if (quote) fmt_buf[len++] = '"';
1220
    if (quote) fmt_buf[len++] = '\'';
1206
    comma = 1;
1221
    comma = 1;
1207
  }
1222
  }
1208
1223
Lines 1257-1284 Link Here
1257
1272
1258
  if (xfields & FT_XFIELD_SRCADDR) {
1273
  if (xfields & FT_XFIELD_SRCADDR) {
1259
    if (comma) fmt_buf[len++] = ',';
1274
    if (comma) fmt_buf[len++] = ',';
1260
    if (quote) fmt_buf[len++] = '"';
1275
    if (quote) fmt_buf[len++] = '\'';
1261
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->srcaddr)),
1276
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->srcaddr)),
1262
      FMT_JUST_LEFT);
1277
      FMT_JUST_LEFT);
1263
    if (quote) fmt_buf[len++] = '"';
1278
    if (quote) fmt_buf[len++] = '\'';
1264
    comma = 1;
1279
    comma = 1;
1265
  }
1280
  }
1266
1281
1267
  if (xfields & FT_XFIELD_DSTADDR) {
1282
  if (xfields & FT_XFIELD_DSTADDR) {
1268
    if (comma) fmt_buf[len++] = ',';
1283
    if (comma) fmt_buf[len++] = ',';
1269
    if (quote) fmt_buf[len++] = '"';
1284
    if (quote) fmt_buf[len++] = '\'';
1270
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->dstaddr)),
1285
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->dstaddr)),
1271
      FMT_JUST_LEFT);
1286
      FMT_JUST_LEFT);
1272
    if (quote) fmt_buf[len++] = '"';
1287
    if (quote) fmt_buf[len++] = '\'';
1273
    comma = 1;
1288
    comma = 1;
1274
  }
1289
  }
1275
1290
1276
  if (xfields & FT_XFIELD_NEXTHOP) {
1291
  if (xfields & FT_XFIELD_NEXTHOP) {
1277
    if (comma) fmt_buf[len++] = ',';
1292
    if (comma) fmt_buf[len++] = ',';
1278
    if (quote) fmt_buf[len++] = '"';
1293
    if (quote) fmt_buf[len++] = '\'';
1279
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->nexthop)),
1294
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->nexthop)),
1280
      FMT_JUST_LEFT);
1295
      FMT_JUST_LEFT);
1281
    if (quote) fmt_buf[len++] = '"';
1296
    if (quote) fmt_buf[len++] = '\'';
1282
    comma = 1;
1297
    comma = 1;
1283
  }
1298
  }
1284
1299
Lines 1375-1393 Link Here
1375
1390
1376
  if (xfields & FT_XFIELD_PEER_NEXTHOP) {
1391
  if (xfields & FT_XFIELD_PEER_NEXTHOP) {
1377
    if (comma) fmt_buf[len++] = ',';
1392
    if (comma) fmt_buf[len++] = ',';
1378
    if (quote) fmt_buf[len++] = '"';
1393
    if (quote) fmt_buf[len++] = '\'';
1379
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->peer_nexthop)),
1394
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->peer_nexthop)),
1380
      FMT_JUST_LEFT);
1395
      FMT_JUST_LEFT);
1381
    if (quote) fmt_buf[len++] = '"';
1396
    if (quote) fmt_buf[len++] = '\'';
1382
    comma = 1;
1397
    comma = 1;
1383
  }
1398
  }
1384
1399
1385
  if (xfields & FT_XFIELD_ROUTER_SC) {
1400
  if (xfields & FT_XFIELD_ROUTER_SC) {
1386
    if (comma) fmt_buf[len++] = ',';
1401
    if (comma) fmt_buf[len++] = ',';
1387
    if (quote) fmt_buf[len++] = '"';
1402
    if (quote) fmt_buf[len++] = '\'';
1388
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->router_sc)),
1403
    len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->router_sc)),
1389
      FMT_JUST_LEFT);
1404
      FMT_JUST_LEFT);
1390
    if (quote) fmt_buf[len++] = '"';
1405
    if (quote) fmt_buf[len++] = '\'';
1391
    comma = 1;
1406
    comma = 1;
1392
  }
1407
  }
1393
1408

Return to bug 50926