Lines 106-112
Link Here
|
106 |
int ftxfield_tocflow(u_int64 xfields, u_int32 *cfmask); |
106 |
int ftxfield_tocflow(u_int64 xfields, u_int32 *cfmask); |
107 |
|
107 |
|
108 |
int fmt_xfields_val(char *fmt_buf, char *rec, struct fts3rec_offsets *fo, |
108 |
int fmt_xfields_val(char *fmt_buf, char *rec, struct fts3rec_offsets *fo, |
109 |
u_int64 xfields, int quote); |
109 |
u_int64 xfields, int quote, int ipv4form); |
110 |
int fmt_xfields_type(char *buf, u_int64 xfield); |
110 |
int fmt_xfields_type(char *buf, u_int64 xfield); |
111 |
|
111 |
|
112 |
void usage(void); |
112 |
void usage(void); |
Lines 664-670
Link Here
|
664 |
|
664 |
|
665 |
while ((rec = ftio_read(ftio))) { |
665 |
while ((rec = ftio_read(ftio))) { |
666 |
|
666 |
|
667 |
len = fmt_xfields_val(fmt_buf, rec, &fo, opt->ft_mask, 0); |
667 |
len = fmt_xfields_val(fmt_buf, rec, &fo, opt->ft_mask, 0, 0); |
668 |
|
668 |
|
669 |
if (len) |
669 |
if (len) |
670 |
printf("%s\n", fmt_buf); |
670 |
printf("%s\n", fmt_buf); |
Lines 747-753
Link Here
|
747 |
/* foreach flow */ |
747 |
/* foreach flow */ |
748 |
while ((rec = ftio_read(ftio))) { |
748 |
while ((rec = ftio_read(ftio))) { |
749 |
|
749 |
|
750 |
len = fmt_xfields_val(values, rec, &fo, opt->ft_mask, 1); |
750 |
bzero(values,sizeof(values)); |
|
|
751 |
len = fmt_xfields_val(values, rec, &fo, opt->ft_mask, 1, 1); |
751 |
|
752 |
|
752 |
/* form SQL query and execute it */ |
753 |
/* form SQL query and execute it */ |
753 |
if (len) { |
754 |
if (len) { |
Lines 918-924
Link Here
|
918 |
/* foreach flow */ |
919 |
/* foreach flow */ |
919 |
while ((rec = ftio_read(ftio))) { |
920 |
while ((rec = ftio_read(ftio))) { |
920 |
|
921 |
|
921 |
len = fmt_xfields_val(values, rec, &fo, opt->ft_mask, 1); |
922 |
len = fmt_xfields_val(values, rec, &fo, opt->ft_mask, 1, 1); |
922 |
|
923 |
|
923 |
/* form SQL query and execute it */ |
924 |
/* form SQL query and execute it */ |
924 |
if (len) { |
925 |
if (len) { |
Lines 1169-1175
Link Here
|
1169 |
|
1170 |
|
1170 |
|
1171 |
|
1171 |
int fmt_xfields_val(char *fmt_buf, char *rec, struct fts3rec_offsets *fo, |
1172 |
int fmt_xfields_val(char *fmt_buf, char *rec, struct fts3rec_offsets *fo, |
1172 |
u_int64 xfields, int quote) |
1173 |
u_int64 xfields, int quote, int ipv4form) |
1173 |
{ |
1174 |
{ |
1174 |
int comma, len; |
1175 |
int comma, len; |
1175 |
|
1176 |
|
Lines 1200-1209
Link Here
|
1200 |
|
1201 |
|
1201 |
if (xfields & FT_XFIELD_EXADDR) { |
1202 |
if (xfields & FT_XFIELD_EXADDR) { |
1202 |
if (comma) fmt_buf[len++] = ','; |
1203 |
if (comma) fmt_buf[len++] = ','; |
1203 |
if (quote) fmt_buf[len++] = '"'; |
1204 |
if (ipv4form) |
1204 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->exaddr)), |
1205 |
len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->exaddr)), |
1205 |
FMT_JUST_LEFT); |
1206 |
FMT_JUST_LEFT); |
1206 |
if (quote) fmt_buf[len++] = '"'; |
1207 |
else { |
|
|
1208 |
if (quote) fmt_buf[len++] = '"'; |
1209 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->exaddr)), |
1210 |
FMT_JUST_LEFT); |
1211 |
if (quote) fmt_buf[len++] = '"'; |
1212 |
} |
1207 |
comma = 1; |
1213 |
comma = 1; |
1208 |
} |
1214 |
} |
1209 |
|
1215 |
|
Lines 1258-1285
Link Here
|
1258 |
|
1264 |
|
1259 |
if (xfields & FT_XFIELD_SRCADDR) { |
1265 |
if (xfields & FT_XFIELD_SRCADDR) { |
1260 |
if (comma) fmt_buf[len++] = ','; |
1266 |
if (comma) fmt_buf[len++] = ','; |
1261 |
if (quote) fmt_buf[len++] = '"'; |
1267 |
if (ipv4form) |
1262 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->srcaddr)), |
1268 |
len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->srcaddr)), |
1263 |
FMT_JUST_LEFT); |
1269 |
FMT_JUST_LEFT); |
1264 |
if (quote) fmt_buf[len++] = '"'; |
1270 |
else { |
|
|
1271 |
if (quote) fmt_buf[len++] = '"'; |
1272 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->srcaddr)), |
1273 |
FMT_JUST_LEFT); |
1274 |
if (quote) fmt_buf[len++] = '"'; |
1275 |
} |
1265 |
comma = 1; |
1276 |
comma = 1; |
1266 |
} |
1277 |
} |
1267 |
|
1278 |
|
1268 |
if (xfields & FT_XFIELD_DSTADDR) { |
1279 |
if (xfields & FT_XFIELD_DSTADDR) { |
1269 |
if (comma) fmt_buf[len++] = ','; |
1280 |
if (comma) fmt_buf[len++] = ','; |
1270 |
if (quote) fmt_buf[len++] = '"'; |
1281 |
if (ipv4form) |
1271 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->dstaddr)), |
1282 |
len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->dstaddr)), |
1272 |
FMT_JUST_LEFT); |
1283 |
FMT_JUST_LEFT); |
1273 |
if (quote) fmt_buf[len++] = '"'; |
1284 |
else { |
|
|
1285 |
if (quote) fmt_buf[len++] = '"'; |
1286 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->dstaddr)), |
1287 |
FMT_JUST_LEFT); |
1288 |
if (quote) fmt_buf[len++] = '"'; |
1289 |
} |
1274 |
comma = 1; |
1290 |
comma = 1; |
1275 |
} |
1291 |
} |
1276 |
|
1292 |
|
1277 |
if (xfields & FT_XFIELD_NEXTHOP) { |
1293 |
if (xfields & FT_XFIELD_NEXTHOP) { |
1278 |
if (comma) fmt_buf[len++] = ','; |
1294 |
if (comma) fmt_buf[len++] = ','; |
1279 |
if (quote) fmt_buf[len++] = '"'; |
1295 |
if (ipv4form) |
1280 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->nexthop)), |
1296 |
len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->nexthop)), |
1281 |
FMT_JUST_LEFT); |
1297 |
FMT_JUST_LEFT); |
1282 |
if (quote) fmt_buf[len++] = '"'; |
1298 |
else { |
|
|
1299 |
if (quote) fmt_buf[len++] = '"'; |
1300 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->nexthop)), |
1301 |
FMT_JUST_LEFT); |
1302 |
if (quote) fmt_buf[len++] = '"'; |
1303 |
} |
1283 |
comma = 1; |
1304 |
comma = 1; |
1284 |
} |
1305 |
} |
1285 |
|
1306 |
|
Lines 1376-1394
Link Here
|
1376 |
|
1397 |
|
1377 |
if (xfields & FT_XFIELD_PEER_NEXTHOP) { |
1398 |
if (xfields & FT_XFIELD_PEER_NEXTHOP) { |
1378 |
if (comma) fmt_buf[len++] = ','; |
1399 |
if (comma) fmt_buf[len++] = ','; |
1379 |
if (quote) fmt_buf[len++] = '"'; |
1400 |
if (ipv4form) |
1380 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->peer_nexthop)), |
1401 |
len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->peer_nexthop)), |
1381 |
FMT_JUST_LEFT); |
1402 |
FMT_JUST_LEFT); |
1382 |
if (quote) fmt_buf[len++] = '"'; |
1403 |
else { |
|
|
1404 |
if (quote) fmt_buf[len++] = '"'; |
1405 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->peer_nexthop)), |
1406 |
FMT_JUST_LEFT); |
1407 |
if (quote) fmt_buf[len++] = '"'; |
1408 |
} |
1383 |
comma = 1; |
1409 |
comma = 1; |
1384 |
} |
1410 |
} |
1385 |
|
1411 |
|
1386 |
if (xfields & FT_XFIELD_ROUTER_SC) { |
1412 |
if (xfields & FT_XFIELD_ROUTER_SC) { |
1387 |
if (comma) fmt_buf[len++] = ','; |
1413 |
if (comma) fmt_buf[len++] = ','; |
1388 |
if (quote) fmt_buf[len++] = '"'; |
1414 |
if (ipv4form) |
1389 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->router_sc)), |
1415 |
len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->router_sc)), |
1390 |
FMT_JUST_LEFT); |
1416 |
FMT_JUST_LEFT); |
1391 |
if (quote) fmt_buf[len++] = '"'; |
1417 |
else { |
|
|
1418 |
if (quote) fmt_buf[len++] = '"'; |
1419 |
len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->router_sc)), |
1420 |
FMT_JUST_LEFT); |
1421 |
if (quote) fmt_buf[len++] = '"'; |
1422 |
} |
1392 |
comma = 1; |
1423 |
comma = 1; |
1393 |
} |
1424 |
} |
1394 |
|
1425 |
|