ALT Linux Bugzilla
– Attachment 871 Details for
Bug 6790
wrong ip-address format in flow-export
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
flow-export-o.67-ipaddress-patch
flow-export.c.patch (text/plain), 5.15 KB, created by
Mike Lykov
on 2005-05-06 11:07:12 MSD
(
hide
)
Description:
flow-export-o.67-ipaddress-patch
Filename:
MIME Type:
Creator:
Mike Lykov
Created:
2005-05-06 11:07:12 MSD
Size:
5.15 KB
patch
obsolete
>--- flow-export.c 2003-12-04 09:55:31 +0400 >+++ flow-export.c.new 2005-05-05 18:26:12 +0500 >@@ -106,7 +106,7 @@ > int ftxfield_tocflow(u_int64 xfields, u_int32 *cfmask); > > int fmt_xfields_val(char *fmt_buf, char *rec, struct fts3rec_offsets *fo, >- u_int64 xfields, int quote); >+ u_int64 xfields, int quote, int ipv4form); > int fmt_xfields_type(char *buf, u_int64 xfield); > > void usage(void); >@@ -663,8 +663,7 @@ > > while ((rec = ftio_read(ftio))) { > >- len = fmt_xfields_val(fmt_buf, rec, &fo, opt->ft_mask, 0); >- >+ len = fmt_xfields_val(fmt_buf, rec, &fo, opt->ft_mask, 0, 0); > if (len) > printf("%s\n", fmt_buf); > >@@ -691,6 +690,7 @@ > char *db_host, *db_name, *db_table, *db_user, *db_pwd, *db_tmp, *tmp; > int db_port; > int len; >+ int debug; > > MYSQL mysql; > >@@ -746,8 +746,9 @@ > /* foreach flow */ > while ((rec = ftio_read(ftio))) { > >- len = fmt_xfields_val(values, rec, &fo, opt->ft_mask, 1); >- >+ bzero(values,sizeof(values)); >+ len = fmt_xfields_val(values, rec, &fo, opt->ft_mask, 1,1); >+ > /* form SQL query and execute it */ > if (len) { > strcpy (query, "INSERT INTO "); >@@ -759,9 +760,8 @@ > strcat (query, ")"); > > if (debug) >- fprintf(stderr, "field=%s\n val=%s\n query=%s\n", fields, values, >- query); >- >+ fprintf(stderr, "field=%s\n val=%s\n query=%s\n", fields, values, query); >+ > if (mysql_real_query(&mysql, query, strlen(query)) != 0) > fterr_warnx("mysql_real_query(): %s", mysql_error(&mysql)); > >@@ -1168,7 +1168,7 @@ > > > int fmt_xfields_val(char *fmt_buf, char *rec, struct fts3rec_offsets *fo, >- u_int64 xfields, int quote) >+ u_int64 xfields, int quote, int ipv4form) > { > int comma, len; > >@@ -1199,10 +1199,15 @@ > > if (xfields & FT_XFIELD_EXADDR) { > if (comma) fmt_buf[len++] = ','; >- if (quote) fmt_buf[len++] = '"'; >- len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->exaddr)), >- FMT_JUST_LEFT); >- if (quote) fmt_buf[len++] = '"'; >+ if (ipv4form) >+ len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->exaddr)), >+ FMT_JUST_LEFT); >+ else { >+ if (quote) fmt_buf[len++] = '"'; >+ len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->exaddr)), >+ FMT_JUST_LEFT); >+ if (quote) fmt_buf[len++] = '"'; >+ } > comma = 1; > } > >@@ -1257,28 +1262,43 @@ > > if (xfields & FT_XFIELD_SRCADDR) { > if (comma) fmt_buf[len++] = ','; >- if (quote) fmt_buf[len++] = '"'; >- len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->srcaddr)), >- FMT_JUST_LEFT); >- if (quote) fmt_buf[len++] = '"'; >+ if (ipv4form) >+ len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->srcaddr)), >+ FMT_JUST_LEFT); >+ else { >+ if (quote) fmt_buf[len++] = '"'; >+ len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->srcaddr)), >+ FMT_JUST_LEFT); >+ if (quote) fmt_buf[len++] = '"'; >+ } > comma = 1; > } > > if (xfields & FT_XFIELD_DSTADDR) { > if (comma) fmt_buf[len++] = ','; >- if (quote) fmt_buf[len++] = '"'; >- len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->dstaddr)), >- FMT_JUST_LEFT); >- if (quote) fmt_buf[len++] = '"'; >+ if (ipv4form) >+ len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->dstaddr)), >+ FMT_JUST_LEFT); >+ else { >+ if (quote) fmt_buf[len++] = '"'; >+ len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->dstaddr)), >+ FMT_JUST_LEFT); >+ if (quote) fmt_buf[len++] = '"'; >+ } > comma = 1; > } > > if (xfields & FT_XFIELD_NEXTHOP) { > if (comma) fmt_buf[len++] = ','; >- if (quote) fmt_buf[len++] = '"'; >- len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->nexthop)), >- FMT_JUST_LEFT); >- if (quote) fmt_buf[len++] = '"'; >+ if (ipv4form) >+ len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->nexthop)), >+ FMT_JUST_LEFT); >+ else { >+ if (quote) fmt_buf[len++] = '"'; >+ len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->nexthop)), >+ FMT_JUST_LEFT); >+ if (quote) fmt_buf[len++] = '"'; >+ } > comma = 1; > } > >@@ -1375,19 +1395,29 @@ > > if (xfields & FT_XFIELD_PEER_NEXTHOP) { > if (comma) fmt_buf[len++] = ','; >- if (quote) fmt_buf[len++] = '"'; >- len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->peer_nexthop)), >- FMT_JUST_LEFT); >- if (quote) fmt_buf[len++] = '"'; >+ if (ipv4form) >+ len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->peer_nexthop)), >+ FMT_JUST_LEFT); >+ else { >+ if (quote) fmt_buf[len++] = '"'; >+ len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->peer_nexthop)), >+ FMT_JUST_LEFT); >+ if (quote) fmt_buf[len++] = '"'; >+ } > comma = 1; > } > > if (xfields & FT_XFIELD_ROUTER_SC) { > if (comma) fmt_buf[len++] = ','; >- if (quote) fmt_buf[len++] = '"'; >- len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->router_sc)), >- FMT_JUST_LEFT); >- if (quote) fmt_buf[len++] = '"'; >+ if (ipv4form) >+ len += fmt_uint32(fmt_buf+len, *((u_int32*)(rec+fo->router_sc)), >+ FMT_JUST_LEFT); >+ else { >+ if (quote) fmt_buf[len++] = '"'; >+ len += fmt_ipv4(fmt_buf+len, *((u_int32*)(rec+fo->router_sc)), >+ FMT_JUST_LEFT); >+ if (quote) fmt_buf[len++] = '"'; >+ } > comma = 1; > } > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 6790
: 871