Ethereal-dev: [Ethereal-dev] SQL patch
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Daniel <dragonheart@xxxxxxxxxx>
Date: Wed, 29 Oct 2003 09:24:22 +0930
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Devs, On the DSD web page I found there is a product called FLAG http://www.dsd.gov.au/library/software/flag/index.html. Inside this (and attached) there is a patch for SQL decoding against ethereal 0.9.13. I haven't tried but I'm hoping you know about it. Cheers and well done on a great product. Daniel - -- Proudly a Gentoo User. GnuPG/PGP signed and encrypted email preferred http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x32A64DC8 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/nwGxTDSbtjKmTcgRAgHMAJwOQL4YHEtLxiqEaCloKbYU0uaU8gCfS4yr kMn3Bcd+bT5ulZ5y5yqC7yI= =vsml -----END PGP SIGNATURE-----
diff -C2 -P -r /var/tmp/ethereal-0.9.13/epan/proto.c flag_ethereal-0.9.13/epan/proto.c *** /var/tmp/ethereal-0.9.13/epan/proto.c Thu Jun 12 09:53:41 2003 --- flag_ethereal-0.9.13/epan/proto.c Sun Jul 6 02:20:53 2003 *************** *** 1692,1695 **** --- 1692,1696 ---- case FT_INT24: case FT_INT32: + case FT_FRAMENUM: pi = proto_tree_add_pi(tree, hfindex, tvb, start, &length, &new_fi); *************** *** 2122,2125 **** --- 2123,2133 ---- } + /* Register the protocol as one that will be output in SQL */ + void proto_register_sql_protocol(int id) + { + header_field_info *hfinfo=proto_registrar_get_nth(id); + if(hfinfo) hfinfo->sql=2; + }; + int proto_register_protocol(char *name, char *short_name, char *filter_name) *************** *** 2139,2142 **** --- 2147,2152 ---- g_assert(g_list_find_custom(protocols, filter_name, proto_match_filter_name) == NULL); + // printf("Registered protocol %s or %s -> %s\n",name,short_name,filter_name); + /* Add this protocol to the list of known protocols; the list is sorted by protocol short name. */ *************** *** 2339,2342 **** --- 2349,2355 ---- proto_register_field_init(header_field_info *hfinfo, int parent) { + + // printf("Field name %s or %s\n",hfinfo->name,hfinfo->abbrev); + /* These types of fields are allowed to have value_strings or true_false_strings */ g_assert((hfinfo->strings == NULL) || ( *************** *** 2418,2421 **** --- 2431,2570 ---- } + + /* Fills in the SQL labels, based in proto_item_fill_label */ + void + proto_item_fill_sql_label (field_info *fi, gchar *label_str) + { + header_field_info *hfinfo = fi->hfinfo; + + guint8 *bytes; + guint32 integer; + ipv4_addr *ipv4; + guint32 n_addr; /* network-order IPv4 address */ + + switch(hfinfo->type) { + case FT_NONE: + case FT_PROTOCOL: + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s", hfinfo->name); + break; + + case FT_BOOLEAN: + fill_label_boolean(fi, label_str); + break; + + case FT_BYTES: + case FT_UINT_BYTES: + bytes = fvalue_get(fi->value); + if (bytes) { + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s: %s", hfinfo->name, + bytes_to_str(bytes, fvalue_length(fi->value))); + } + else { + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s: <MISSING>", hfinfo->name); + } + break; + + /* Four types of integers to take care of: + * Bitfield, with val_string + * Bitfield, w/o val_string + * Non-bitfield, with val_string + * Non-bitfield, w/o val_string + */ + case FT_UINT8: + case FT_UINT16: + case FT_UINT24: + case FT_UINT32: + case FT_FRAMENUM: + snprintf(label_str, ITEM_LABEL_LENGTH, "%lu",(long unsigned int) fvalue_get_integer(fi->value)); + break; + + case FT_UINT64: + fill_label_uint64(fi, label_str); + break; + + case FT_INT8: + case FT_INT16: + case FT_INT24: + case FT_INT32: + g_assert(!hfinfo->bitmask); + snprintf(label_str, ITEM_LABEL_LENGTH, "%d",fvalue_get_integer(fi->value)); + break; + + case FT_INT64: + fill_label_int64(fi, label_str); + break; + + case FT_FLOAT: + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s: %.9g", hfinfo->name, fvalue_get_floating(fi->value)); + break; + + case FT_DOUBLE: + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s: %.14g", hfinfo->name, fvalue_get_floating(fi->value)); + break; + + case FT_ABSOLUTE_TIME: + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s",abs_time_to_sql(fvalue_get(fi->value))); + break; + + case FT_RELATIVE_TIME: + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s", rel_time_to_secs_str(fvalue_get(fi->value))); + break; + + case FT_IPXNET: + integer = fvalue_get_integer(fi->value); + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s: 0x%08X (%s)", hfinfo->name, + integer, get_ipxnet_name(integer)); + break; + + case FT_ETHER: + bytes = fvalue_get(fi->value); + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s", ether_to_str(bytes)); + break; + + case FT_IPv4: + /* + ipv4 = fvalue_get(fi->value); + n_addr = ipv4_get_net_order_addr(ipv4); + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s", ip_to_str((guint8*)&n_addr)); + */ + snprintf(label_str,ITEM_LABEL_LENGTH,"%lu",ipv4_get_host_order_addr(fvalue_get(fi->value))); + break; + + case FT_IPv6: + bytes = fvalue_get(fi->value); + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s: %s (%s)", hfinfo->name, + get_hostname6((struct e_in6_addr *)bytes), + ip6_to_str((struct e_in6_addr*)bytes)); + break; + + case FT_STRING: + case FT_STRINGZ: + case FT_UINT_STRING: + bytes = fvalue_get(fi->value); + snprintf(label_str, ITEM_LABEL_LENGTH, + "%s: %s", hfinfo->name, + format_text(bytes, strlen(bytes))); + break; + + default: + g_error("hfinfo->type %d (%s) not handled\n", + hfinfo->type, + ftype_name(hfinfo->type)); + g_assert_not_reached(); + break; + } + } + void proto_item_fill_label(field_info *fi, gchar *label_str) *************** *** 3319,3322 **** --- 3468,3638 ---- } } + } + + /* Dumps SQL create statements to stdout, based on proto_registrar_dump_fields */ + GString *create_sql=NULL; + GString *enumerated_sql=NULL; + + void + proto_registrar_dump_sql(int creation) + { + header_field_info *hfinfo, *parent_hfinfo; + int i, len; + const char *enum_name; + + + if(creation) { + printf("create table dns_data (key_id int, name varchar(100), type varchar(10), class varchar(10),data text,key key_id(key_id)); create table data (key_id int, length int, data blob,key key_id(key_id));\ncreate table enum (name varchar(50),value int,string varchar(50));\n"); + + len = gpa_hfinfo->len; + for (i = 0; i < len ; i++) { + hfinfo = proto_registrar_get_nth(i); + if (strlen(hfinfo->name) == 0 || strlen(hfinfo->abbrev) == 0) + continue; + + /* format for protocols */ + if (proto_registrar_is_protocol(i)) { + if(hfinfo->sql==2) { + if(create_sql) { + printf("%skey_id INT );\n",create_sql->str); + g_string_free(create_sql,1); + create_sql=g_string_new(""); + } else { + create_sql=g_string_new(""); + }; + + if(enumerated_sql) { + printf("%s",enumerated_sql->str); + g_string_free(enumerated_sql,1); + enumerated_sql=NULL; + }; + + create_sql=g_string_new(""); + g_string_sprintfa(create_sql,"insert into meta set property=\"tcpdump_table\", value= \"%s\";\nCreate table `%s` (\n",hfinfo->abbrev,hfinfo->abbrev); + }; + } + /* format for header fields */ + else { + char *type; + if (hfinfo->same_name_prev != NULL) + continue; + + parent_hfinfo = proto_registrar_get_nth(hfinfo->parent); + g_assert(parent_hfinfo); + + enum_name = ftype_name(hfinfo->type); + switch(hfinfo->type) { + case FT_UINT8: + type="TINYINT UNSIGNED"; + break; + case FT_UINT16: + type="SMALLINT UNSIGNED"; + break; + case FT_UINT24: + type="MEDIUMINT UNSIGNED"; + break; + case FT_UINT32: + type="INT UNSIGNED"; + break; + case FT_UINT64: + type="BIGINT UNSIGNED"; + break; + case FT_INT8: + type="TINYINT"; + break; + case FT_INT16: + type="SMALLINT"; + break; + case FT_INT24: + type="MEDIUMINT"; + break; + case FT_INT32: + type="INT"; + break; + case FT_INT64: + type="BIGINT"; + break; + case FT_FLOAT: + type="FLOAT"; + break; + case FT_DOUBLE: + type="DOUBLE"; + break; + case FT_STRING: + case FT_STRINGZ: + case FT_UINT_STRING: + type="TEXT"; + break; + case FT_IPv4: + type="BIGINT"; + break; + case FT_BYTES: + type="BLOB"; + break; + case FT_ETHER: + type="VARCHAR(50)"; + break; + case FT_BOOLEAN: + type="BOOL"; + break; + case FT_ABSOLUTE_TIME: + type="DATETIME"; + break; + default: + type="TEXT"; + }; + + //Enumerated types can be dumped off here + if(hfinfo->sql==2) { + char *new_name = strdup(hfinfo->abbrev); + char *name=new_name+strlen(new_name); + value_string *cur; + int i; + + /* we replace . with _ in the column names */ + while(name > new_name) { + if(*name=='.') *name='_'; + name--; + }; + + //Enumerated types can be dumped off here + if(hfinfo->strings) { + if(!enumerated_sql) enumerated_sql=g_string_new(""); + cur= (value_string*) hfinfo->strings; + for(i=1; cur->strptr; cur = &(((value_string*) hfinfo->strings)[i++])) { + g_string_sprintfa(enumerated_sql,"insert into enum set name = \"%s\", value=\"%d\", string = \"%s\";\n",new_name,cur->value,cur->strptr); + }; + }; + + + // printf("Field \t%s\t%s\t%s\t%s\t%s\n", hfinfo->name, hfinfo->abbrev,enum_name,parent_hfinfo->abbrev, hfinfo->blurb); + g_string_sprintfa(create_sql,"/* %s : %s */\n%s %s,\n", hfinfo->name,hfinfo->blurb,new_name,type); + free(new_name); + }; + } + } + + if(create_sql) { + printf("%skey_id INT );\n",create_sql->str); + g_string_free(create_sql,1); + } + } else { + printf("drop table data;\n drop table enum;\n"); + + len = gpa_hfinfo->len; + for (i = 0; i < len ; i++) { + hfinfo = proto_registrar_get_nth(i); + if (strlen(hfinfo->name) == 0 || strlen(hfinfo->abbrev) == 0) + continue; + + /* format for protocols */ + if (proto_registrar_is_protocol(i)) { + if(hfinfo->sql==2) { + printf("drop table `%s`;\n",hfinfo->abbrev); + }; + }; + + }; + }; } diff -C2 -P -r /var/tmp/ethereal-0.9.13/epan/proto.h flag_ethereal-0.9.13/epan/proto.h *** /var/tmp/ethereal-0.9.13/epan/proto.h Sun May 4 12:24:55 2003 --- flag_ethereal-0.9.13/epan/proto.h Sun Jul 6 01:39:09 2003 *************** *** 84,87 **** --- 84,88 ---- header_field_info *same_name_next; /* Link to next hfinfo with same abbrev*/ header_field_info *same_name_prev; /* Link to previous hfinfo with same abbrev*/ + char sql; /* Do we include this one in the SQL dumps */ }; *************** *** 91,95 **** * be changed as necessary. */ ! #define HFILL 0, 0, 0, NULL, NULL /* Used when registering many fields at once */ --- 92,97 ---- * be changed as necessary. */ ! #define HFILL 0, 0, 0, NULL, NULL,0 ! #define SQLFILL 0, 0, 0, NULL, NULL,2 /* Used when registering many fields at once */ diff -C2 -P -r /var/tmp/ethereal-0.9.13/epan/to_str.c flag_ethereal-0.9.13/epan/to_str.c *** /var/tmp/ethereal-0.9.13/epan/to_str.c Mon Feb 17 08:13:43 2003 --- flag_ethereal-0.9.13/epan/to_str.c Sat Jul 5 23:06:03 2003 *************** *** 412,415 **** --- 412,447 ---- }; + /* For SQL engine */ + gchar * + abs_time_to_sql(nstime_t *abs_time) + { + struct tm *tmp; + static gchar *cur; + static char str[3][3+1+2+2+4+1+2+1+2+1+2+1+6+1 + 5 /* extra */]; + + if (cur == &str[0][0]) { + cur = &str[1][0]; + } else if (cur == &str[1][0]) { + cur = &str[2][0]; + } else { + cur = &str[0][0]; + } + + tmp = localtime(&abs_time->secs); + if (tmp) { + sprintf(cur, "%d/%d/%d %02d:%02d:%02d", + tmp->tm_year + 1900, + tmp->tm_mon, + tmp->tm_mday, + tmp->tm_hour, + tmp->tm_min, + tmp->tm_sec + ); + } else { + strncpy(cur, "Not representable", sizeof(str[0])); + } + return cur; + }; + gchar * abs_time_to_str(nstime_t *abs_time) diff -C2 -P -r /var/tmp/ethereal-0.9.13/epan/to_str.h flag_ethereal-0.9.13/epan/to_str.h *** /var/tmp/ethereal-0.9.13/epan/to_str.h Mon Feb 17 08:13:43 2003 --- flag_ethereal-0.9.13/epan/to_str.h Sun Jul 6 02:10:45 2003 *************** *** 59,62 **** --- 59,63 ---- extern gchar* time_msecs_to_str(guint32); extern gchar* abs_time_to_str(nstime_t*); + extern gchar* abs_time_to_sql(nstime_t*); extern gchar* abs_time_secs_to_str(time_t); extern void display_signed_time(gchar *, int, gint32, gint32, time_res_t); diff -C2 -P -r /var/tmp/ethereal-0.9.13/gtk/main.c flag_ethereal-0.9.13/gtk/main.c *** /var/tmp/ethereal-0.9.13/gtk/main.c Tue Jun 10 09:28:44 2003 --- flag_ethereal-0.9.13/gtk/main.c Sat Jul 5 23:06:03 2003 *************** *** 1550,1556 **** if (strcmp(argv[2], "fields") == 0) proto_registrar_dump_fields(); ! else if (strcmp(argv[2], "protocols") == 0) proto_registrar_dump_protocols(); ! else { fprintf(stderr, "ethereal: Invalid \"%s\" option for -G flag\n", argv[2]); --- 1550,1560 ---- if (strcmp(argv[2], "fields") == 0) proto_registrar_dump_fields(); ! else if (strcmp(argv[2], "protocols") == 0) { proto_registrar_dump_protocols(); ! } else if(!strcmp(argv[2],"sql")) { ! proto_registrar_dump_sql(1); ! } else if(!strcmp(argv[2],"drop")) { ! proto_registrar_dump_sql(0); ! } else { fprintf(stderr, "ethereal: Invalid \"%s\" option for -G flag\n", argv[2]); diff -C2 -P -r /var/tmp/ethereal-0.9.13/ipproto.c flag_ethereal-0.9.13/ipproto.c *** /var/tmp/ethereal-0.9.13/ipproto.c Wed Feb 5 14:02:03 2003 --- flag_ethereal-0.9.13/ipproto.c Sat Jul 5 23:51:45 2003 *************** *** 42,92 **** #endif - static const value_string ipproto_val[] = { - { IP_PROTO_ICMP, "ICMP" }, - { IP_PROTO_IGMP, "IGMP" }, - { IP_PROTO_EIGRP, "EIGRP" }, - { IP_PROTO_IGRP, "IGRP" }, - { IP_PROTO_TCP, "TCP" }, - { IP_PROTO_UDP, "UDP" }, - { IP_PROTO_OSPF, "OSPF" }, - #if 0 - { IP_PROTO_IP, "IPv4" }, - #endif - { IP_PROTO_HOPOPTS, "IPv6 hop-by-hop option" }, - { IP_PROTO_ICMP, "ICMP" }, - { IP_PROTO_IGMP, "IGMP" }, - { IP_PROTO_GGP, "GGP" }, - { IP_PROTO_IPIP, "IPIP" }, - #if 0 - { IP_PROTO_IPV4, "IPv4" }, - #endif - { IP_PROTO_EGP, "EGP" }, - { IP_PROTO_PUP, "PUP" }, - { IP_PROTO_UDP, "UDP" }, - { IP_PROTO_IDP, "IDP" }, - { IP_PROTO_TP, "TP" }, - { IP_PROTO_IPV6, "IPv6" }, - { IP_PROTO_ROUTING, "IPv6 routing" }, - { IP_PROTO_FRAGMENT,"IPv6 fragment" }, - { IP_PROTO_RSVP, "RSVP" }, - { IP_PROTO_GRE, "GRE" }, - { IP_PROTO_ESP, "ESP" }, - { IP_PROTO_AH, "AH" }, - { IP_PROTO_ICMPV6, "ICMPv6" }, - { IP_PROTO_NONE, "IPv6 no next header" }, - { IP_PROTO_DSTOPTS, "IPv6 destination option" }, - { IP_PROTO_MIPV6, "Mobile IPv6" }, - { IP_PROTO_EON, "EON" }, - { IP_PROTO_OSPF, "OSPF" }, - { IP_PROTO_ENCAP, "ENCAP" }, - { IP_PROTO_PIM, "PIM" }, - { IP_PROTO_IPCOMP, "IPComp" }, - { IP_PROTO_VRRP, "VRRP" }, - { IP_PROTO_VINES, "VINES" }, - { IP_PROTO_PGM, "PGM" }, - { IP_PROTO_SCTP, "SCTP" }, - { 0, NULL }, - }; - const char *ipprotostr(int proto) { static char buf[128]; --- 42,45 ---- diff -C2 -P -r /var/tmp/ethereal-0.9.13/ipproto.h flag_ethereal-0.9.13/ipproto.h *** /var/tmp/ethereal-0.9.13/ipproto.h Sat Mar 8 13:40:29 2003 --- flag_ethereal-0.9.13/ipproto.h Sat Jul 5 23:51:54 2003 *************** *** 67,71 **** --- 67,120 ---- #define IP_PROTO_SCTP 132 /* Stream Control Transmission Protocol */ + #include "epan/value_string.h" + extern const char *ipprotostr(int proto); + + static const value_string ipproto_val[] = { + { IP_PROTO_ICMP, "ICMP" }, + { IP_PROTO_IGMP, "IGMP" }, + { IP_PROTO_EIGRP, "EIGRP" }, + { IP_PROTO_IGRP, "IGRP" }, + { IP_PROTO_TCP, "TCP" }, + { IP_PROTO_UDP, "UDP" }, + { IP_PROTO_OSPF, "OSPF" }, + #if 0 + { IP_PROTO_IP, "IPv4" }, + #endif + { IP_PROTO_HOPOPTS, "IPv6 hop-by-hop option" }, + { IP_PROTO_ICMP, "ICMP" }, + { IP_PROTO_IGMP, "IGMP" }, + { IP_PROTO_GGP, "GGP" }, + { IP_PROTO_IPIP, "IPIP" }, + #if 0 + { IP_PROTO_IPV4, "IPv4" }, + #endif + { IP_PROTO_EGP, "EGP" }, + { IP_PROTO_PUP, "PUP" }, + { IP_PROTO_UDP, "UDP" }, + { IP_PROTO_IDP, "IDP" }, + { IP_PROTO_TP, "TP" }, + { IP_PROTO_IPV6, "IPv6" }, + { IP_PROTO_ROUTING, "IPv6 routing" }, + { IP_PROTO_FRAGMENT,"IPv6 fragment" }, + { IP_PROTO_RSVP, "RSVP" }, + { IP_PROTO_GRE, "GRE" }, + { IP_PROTO_ESP, "ESP" }, + { IP_PROTO_AH, "AH" }, + { IP_PROTO_ICMPV6, "ICMPv6" }, + { IP_PROTO_NONE, "IPv6 no next header" }, + { IP_PROTO_DSTOPTS, "IPv6 destination option" }, + { IP_PROTO_MIPV6, "Mobile IPv6" }, + { IP_PROTO_EON, "EON" }, + { IP_PROTO_OSPF, "OSPF" }, + { IP_PROTO_ENCAP, "ENCAP" }, + { IP_PROTO_PIM, "PIM" }, + { IP_PROTO_IPCOMP, "IPComp" }, + { IP_PROTO_VRRP, "VRRP" }, + { IP_PROTO_VINES, "VINES" }, + { IP_PROTO_PGM, "PGM" }, + { IP_PROTO_SCTP, "SCTP" }, + { 0, NULL }, + }; #endif /* ipproto.h */ diff -C2 -P -r /var/tmp/ethereal-0.9.13/packet-dns.c flag_ethereal-0.9.13/packet-dns.c *** /var/tmp/ethereal-0.9.13/packet-dns.c Sun May 25 07:05:36 2003 --- flag_ethereal-0.9.13/packet-dns.c Sat Jul 5 23:06:03 2003 *************** *** 43,46 **** --- 43,49 ---- #include "prefs.h" + extern int frame_no; + extern GString* additional_sql; + static int proto_dns = -1; static int hf_dns_length = -1; *************** *** 773,782 **** proto_tree_add_text(q_tree, tvb, offset, name_len, "Name: %s", name); offset += name_len; - proto_tree_add_text(q_tree, tvb, offset, 2, "Type: %s", long_type_name); offset += 2; - proto_tree_add_text(q_tree, tvb, offset, 2, "Class: %s", class_name); offset += 2; } --- 776,785 ---- proto_tree_add_text(q_tree, tvb, offset, name_len, "Name: %s", name); offset += name_len; proto_tree_add_text(q_tree, tvb, offset, 2, "Type: %s", long_type_name); offset += 2; proto_tree_add_text(q_tree, tvb, offset, 2, "Class: %s", class_name); offset += 2; + + g_string_sprintfa(additional_sql,"insert into dns_data set key_id=\"%d\",name=\"%s\",type=\"%s\",class=\"%s\";",frame_no+1,name,type_name,class_name); } *************** *** 946,949 **** --- 949,953 ---- proto_tree_add_text(rr_tree, tvb, cur_offset, 4, "Addr: %s", ip_to_str(addr)); + g_string_sprintfa(additional_sql,"insert into dns_data set key_id=\"%d\",name=\"%s\",type=\"%s\",class=\"%s\",data=\"%s\";",frame_no+1,name,type_name,class_name,ip_to_str(addr)); } if ((class & 0x7f) == C_IN) { *************** *** 966,969 **** --- 970,974 ---- proto_tree_add_text(rr_tree, tvb, cur_offset, ns_name_len, "Name server: %s", ns_name); + g_string_sprintfa(additional_sql,"insert into dns_data set key_id=\"%d\",name=\"%s\",type=\"%s\",class=\"%s\",data=\"%s\";",frame_no+1,name,type_name,class_name,ns_name); } } *************** *** 982,985 **** --- 987,992 ---- proto_tree_add_text(rr_tree, tvb, cur_offset, cname_len, "Primary name: %s", cname); + g_string_sprintfa(additional_sql,"insert into dns_data set key_id=\"%d\",name=\"%s\",type=\"%s\",class=\"%s\",data=\"%s\";",frame_no+1,name,type_name,class_name,cname); + } } *************** *** 1051,1054 **** --- 1058,1063 ---- proto_tree_add_text(rr_tree, tvb, cur_offset, pname_len, "Domain name: %s", pname); + g_string_sprintfa(additional_sql,"insert into dns_data set key_id=\"%d\",name=\"%s\",type=\"%s\",class=\"%s\",data=\"%s\";",frame_no+1,name,type_name,class_name,pname); + } break; *************** *** 1171,1174 **** --- 1180,1185 ---- proto_tree_add_text(rr_tree, tvb, cur_offset + 2, mx_name_len, "Mail exchange: %s", mx_name); + g_string_sprintfa(additional_sql,"insert into dns_data set key_id=\"%d\",name=\"%s\",type=\"%s\",class=\"%s\",data=\"%s\";",frame_no+1,name,type_name,class_name,mx_name); + } } *************** *** 1187,1190 **** --- 1198,1204 ---- proto_tree_add_text(rr_tree, tvb, txt_offset, 1 + txt_len, "Text: %.*s", txt_len, tvb_get_ptr(tvb, txt_offset + 1, txt_len)); + + g_string_sprintfa(additional_sql,"insert into dns_data set key_id=\"%d\",name=\"%s\",type=\"%s\",class=\"%s\",data=\"%s\";",frame_no+1,name,type_name,class_name,tvb_get_ptr(tvb, txt_offset + 1, txt_len)); + txt_offset += 1 + txt_len; rr_len -= 1 + txt_len; *************** *** 1856,1860 **** } break; ! /* TODO: parse more record types */ --- 1870,1874 ---- } break; ! /* TODO: parse more record types */ *************** *** 2139,2147 **** { "Length", "dns.length", FT_UINT16, BASE_DEC, NULL, 0x0, ! "Length of DNS-over-TCP request or response", HFILL }}, { &hf_dns_flags, { "Flags", "dns.flags", FT_UINT16, BASE_HEX, NULL, 0x0, ! "", HFILL }}, { &hf_dns_flags_response, { "Response", "dns.flags.response", --- 2153,2161 ---- { "Length", "dns.length", FT_UINT16, BASE_DEC, NULL, 0x0, ! "Length of DNS-over-TCP request or response", SQLFILL }}, { &hf_dns_flags, { "Flags", "dns.flags", FT_UINT16, BASE_HEX, NULL, 0x0, ! "", SQLFILL }}, { &hf_dns_flags_response, { "Response", "dns.flags.response", *************** *** 2187,2207 **** { "Transaction ID", "dns.id", FT_UINT16, BASE_HEX, NULL, 0x0, ! "Identification of transaction", HFILL }}, { &hf_dns_count_questions, { "Questions", "dns.count.queries", FT_UINT16, BASE_DEC, NULL, 0x0, ! "Number of queries in packet", HFILL }}, { &hf_dns_count_answers, { "Answer RRs", "dns.count.answers", FT_UINT16, BASE_DEC, NULL, 0x0, ! "Number of answers in packet", HFILL }}, { &hf_dns_count_auth_rr, { "Authority RRs", "dns.count.auth_rr", FT_UINT16, BASE_DEC, NULL, 0x0, ! "Number of authoritative records in packet", HFILL }}, { &hf_dns_count_add_rr, { "Additional RRs", "dns.count.add_rr", FT_UINT16, BASE_DEC, NULL, 0x0, ! "Number of additional records in packet", HFILL }} }; static gint *ett[] = { --- 2201,2221 ---- { "Transaction ID", "dns.id", FT_UINT16, BASE_HEX, NULL, 0x0, ! "Identification of transaction", SQLFILL }}, { &hf_dns_count_questions, { "Questions", "dns.count.queries", FT_UINT16, BASE_DEC, NULL, 0x0, ! "Number of queries in packet", SQLFILL }}, { &hf_dns_count_answers, { "Answer RRs", "dns.count.answers", FT_UINT16, BASE_DEC, NULL, 0x0, ! "Number of answers in packet", SQLFILL }}, { &hf_dns_count_auth_rr, { "Authority RRs", "dns.count.auth_rr", FT_UINT16, BASE_DEC, NULL, 0x0, ! "Number of authoritative records in packet", SQLFILL }}, { &hf_dns_count_add_rr, { "Additional RRs", "dns.count.add_rr", FT_UINT16, BASE_DEC, NULL, 0x0, ! "Number of additional records in packet", SQLFILL }} }; static gint *ett[] = { *************** *** 2218,2221 **** --- 2232,2236 ---- proto_dns = proto_register_protocol("Domain Name Service", "DNS", "dns"); + proto_register_sql_protocol(proto_dns); proto_register_field_array(proto_dns, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); diff -C2 -P -r /var/tmp/ethereal-0.9.13/packet-eth.c flag_ethereal-0.9.13/packet-eth.c *** /var/tmp/ethereal-0.9.13/packet-eth.c Thu Jan 23 13:45:55 2003 --- flag_ethereal-0.9.13/packet-eth.c Sat Jul 5 23:06:03 2003 *************** *** 282,299 **** { &hf_eth_dst, { "Destination", "eth.dst", FT_ETHER, BASE_NONE, NULL, 0x0, ! "Destination Hardware Address", HFILL }}, { &hf_eth_src, { "Source", "eth.src", FT_ETHER, BASE_NONE, NULL, 0x0, ! "Source Hardware Address", HFILL }}, { &hf_eth_len, { "Length", "eth.len", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", HFILL }}, /* registered here but handled in ethertype.c */ { &hf_eth_type, { "Type", "eth.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, ! "", HFILL }}, { &hf_eth_addr, { "Source or Destination Address", "eth.addr", FT_ETHER, BASE_NONE, NULL, 0x0, --- 282,299 ---- { &hf_eth_dst, { "Destination", "eth.dst", FT_ETHER, BASE_NONE, NULL, 0x0, ! "Destination Hardware Address", SQLFILL }}, { &hf_eth_src, { "Source", "eth.src", FT_ETHER, BASE_NONE, NULL, 0x0, ! "Source Hardware Address", SQLFILL }}, { &hf_eth_len, { "Length", "eth.len", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, /* registered here but handled in ethertype.c */ { &hf_eth_type, { "Type", "eth.type", FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0, ! "", SQLFILL }}, { &hf_eth_addr, { "Source or Destination Address", "eth.addr", FT_ETHER, BASE_NONE, NULL, 0x0, *************** *** 312,315 **** --- 312,316 ---- proto_eth = proto_register_protocol("Ethernet", "Ethernet", "eth"); + proto_register_sql_protocol(proto_eth); proto_register_field_array(proto_eth, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); diff -C2 -P -r /var/tmp/ethereal-0.9.13/packet-frame.c flag_ethereal-0.9.13/packet-frame.c *** /var/tmp/ethereal-0.9.13/packet-frame.c Tue Mar 4 13:53:31 2003 --- flag_ethereal-0.9.13/packet-frame.c Sat Jul 5 23:06:03 2003 *************** *** 236,240 **** { &hf_frame_arrival_time, { "Arrival Time", "frame.time", FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0, ! "", HFILL }}, { &hf_frame_time_delta, --- 236,240 ---- { &hf_frame_arrival_time, { "Arrival Time", "frame.time", FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0, ! "", SQLFILL }}, { &hf_frame_time_delta, *************** *** 254,262 **** { &hf_frame_packet_len, { "Total Frame Length", "frame.pkt_len", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_frame_capture_len, { "Capture Frame Length", "frame.cap_len", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_frame_p2p_dir, --- 254,262 ---- { &hf_frame_packet_len, { "Total Frame Length", "frame.pkt_len", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_frame_capture_len, { "Capture Frame Length", "frame.cap_len", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_frame_p2p_dir, *************** *** 281,284 **** --- 281,285 ---- proto_frame = proto_register_protocol("Frame", "Frame", "frame"); + proto_register_sql_protocol(proto_frame); proto_register_field_array(proto_frame, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); diff -C2 -P -r /var/tmp/ethereal-0.9.13/packet-ip.c flag_ethereal-0.9.13/packet-ip.c *** /var/tmp/ethereal-0.9.13/packet-ip.c Tue Jun 10 09:28:42 2003 --- flag_ethereal-0.9.13/packet-ip.c Sat Jul 5 23:51:34 2003 *************** *** 37,41 **** #include <epan/packet.h> #include <epan/resolv.h> - #include "ipproto.h" #include "prefs.h" #include "reassemble.h" --- 37,40 ---- *************** *** 49,52 **** --- 48,53 ---- #include "packet-ipsec.h" #include "in_cksum.h" + //#include "ipproto.c" + #include "ipproto.h" #include "nlpid.h" #include "tap.h" *************** *** 1566,1570 **** { &hf_ip_hdr_len, { "Header Length", "ip.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_ip_dsfield, --- 1567,1571 ---- { &hf_ip_hdr_len, { "Header Length", "ip.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_ip_dsfield, *************** *** 1618,1634 **** { &hf_ip_len, { "Total Length", "ip.len", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_ip_id, { "Identification", "ip.id", FT_UINT16, BASE_HEX, NULL, 0x0, ! "", HFILL }}, { &hf_ip_dst, { "Destination", "ip.dst", FT_IPv4, BASE_NONE, NULL, 0x0, ! "", HFILL }}, { &hf_ip_src, { "Source", "ip.src", FT_IPv4, BASE_NONE, NULL, 0x0, ! "", HFILL }}, { &hf_ip_addr, --- 1619,1635 ---- { &hf_ip_len, { "Total Length", "ip.len", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_ip_id, { "Identification", "ip.id", FT_UINT16, BASE_HEX, NULL, 0x0, ! "", SQLFILL }}, { &hf_ip_dst, { "Destination", "ip.dst", FT_IPv4, BASE_NONE, NULL, 0x0, ! "", SQLFILL }}, { &hf_ip_src, { "Source", "ip.src", FT_IPv4, BASE_NONE, NULL, 0x0, ! "", SQLFILL }}, { &hf_ip_addr, *************** *** 1638,1642 **** { &hf_ip_flags, { "Flags", "ip.flags", FT_UINT8, BASE_HEX, NULL, 0x0, ! "", HFILL }}, { &hf_ip_flags_df, --- 1639,1643 ---- { &hf_ip_flags, { "Flags", "ip.flags", FT_UINT8, BASE_HEX, NULL, 0x0, ! "", SQLFILL }}, { &hf_ip_flags_df, *************** *** 1650,1682 **** { &hf_ip_frag_offset, { "Fragment offset", "ip.frag_offset", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_ip_ttl, { "Time to live", "ip.ttl", FT_UINT8, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_ip_proto, ! { "Protocol", "ip.proto", FT_UINT8, BASE_HEX, NULL, 0x0, ! "", HFILL }}, { &hf_ip_checksum, { "Header checksum", "ip.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, ! "", HFILL }}, { &hf_ip_checksum_bad, { "Bad Header checksum", "ip.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "", HFILL }}, { &hf_ip_fragment_overlap, { "Fragment overlap", "ip.fragment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "Fragment overlaps with other fragments", HFILL }}, { &hf_ip_fragment_overlap_conflict, { "Conflicting data in fragment overlap", "ip.fragment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "Overlapping fragments contained conflicting data", HFILL }}, { &hf_ip_fragment_multiple_tails, { "Multiple tail fragments found", "ip.fragment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "Several tails were found when defragmenting the packet", HFILL }}, { &hf_ip_fragment_too_long_fragment, --- 1651,1683 ---- { &hf_ip_frag_offset, { "Fragment offset", "ip.frag_offset", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_ip_ttl, { "Time to live", "ip.ttl", FT_UINT8, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_ip_proto, ! { "Protocol", "ip.proto", FT_UINT8, BASE_HEX, VALS(ipproto_val), 0x0, ! "", SQLFILL }}, { &hf_ip_checksum, { "Header checksum", "ip.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, ! "", SQLFILL }}, { &hf_ip_checksum_bad, { "Bad Header checksum", "ip.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "", SQLFILL }}, { &hf_ip_fragment_overlap, { "Fragment overlap", "ip.fragment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "Fragment overlaps with other fragments", SQLFILL }}, { &hf_ip_fragment_overlap_conflict, { "Conflicting data in fragment overlap", "ip.fragment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "Overlapping fragments contained conflicting data", SQLFILL }}, { &hf_ip_fragment_multiple_tails, { "Multiple tail fragments found", "ip.fragment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "Several tails were found when defragmenting the packet", SQLFILL }}, { &hf_ip_fragment_too_long_fragment, *************** *** 1686,1690 **** { &hf_ip_fragment_error, { "Defragmentation error", "ip.fragment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0, ! "Defragmentation error due to illegal fragments", HFILL }}, { &hf_ip_fragment, --- 1687,1691 ---- { &hf_ip_fragment_error, { "Defragmentation error", "ip.fragment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0, ! "Defragmentation error due to illegal fragments", SQLFILL }}, { &hf_ip_fragment, *************** *** 1715,1718 **** --- 1716,1720 ---- proto_ip = proto_register_protocol("Internet Protocol", "IP", "ip"); + proto_register_sql_protocol(proto_ip); proto_register_field_array(proto_ip, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); *************** *** 1771,1779 **** { &hf_icmp_type, { "Type", "icmp.type", FT_UINT8, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_icmp_code, { "Code", "icmp.code", FT_UINT8, BASE_HEX, NULL, 0x0, ! "", HFILL }}, { &hf_icmp_checksum, --- 1773,1781 ---- { &hf_icmp_type, { "Type", "icmp.type", FT_UINT8, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_icmp_code, { "Code", "icmp.code", FT_UINT8, BASE_HEX, NULL, 0x0, ! "", SQLFILL }}, { &hf_icmp_checksum, *************** *** 1861,1864 **** --- 1863,1867 ---- proto_icmp = proto_register_protocol("Internet Control Message Protocol", "ICMP", "icmp"); + proto_register_sql_protocol(proto_icmp); proto_register_field_array(proto_icmp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); diff -C2 -P -r /var/tmp/ethereal-0.9.13/packet-tcp.c flag_ethereal-0.9.13/packet-tcp.c *** /var/tmp/ethereal-0.9.13/packet-tcp.c Thu Jun 5 13:19:29 2003 --- flag_ethereal-0.9.13/packet-tcp.c Sat Jul 5 23:06:03 2003 *************** *** 2477,2485 **** { &hf_tcp_srcport, { "Source Port", "tcp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_dstport, { "Destination Port", "tcp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_port, --- 2477,2485 ---- { &hf_tcp_srcport, { "Source Port", "tcp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_dstport, { "Destination Port", "tcp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_port, *************** *** 2489,2509 **** { &hf_tcp_seq, { "Sequence number", "tcp.seq", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_nxtseq, { "Next sequence number", "tcp.nxtseq", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_ack, { "Acknowledgement number", "tcp.ack", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_hdr_len, { "Header Length", "tcp.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_flags, { "Flags", "tcp.flags", FT_UINT8, BASE_HEX, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_flags_cwr, --- 2489,2509 ---- { &hf_tcp_seq, { "Sequence number", "tcp.seq", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_nxtseq, { "Next sequence number", "tcp.nxtseq", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_ack, { "Acknowledgement number", "tcp.ack", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_hdr_len, { "Header Length", "tcp.hdr_len", FT_UINT8, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_flags, { "Flags", "tcp.flags", FT_UINT8, BASE_HEX, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_flags_cwr, *************** *** 2541,2553 **** { &hf_tcp_window_size, { "Window size", "tcp.window_size", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_checksum, { "Checksum", "tcp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_checksum_bad, { "Bad Checksum", "tcp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_analysis_flags, --- 2541,2553 ---- { &hf_tcp_window_size, { "Window size", "tcp.window_size", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_checksum, { "Checksum", "tcp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_checksum_bad, { "Bad Checksum", "tcp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_analysis_flags, *************** *** 2597,2601 **** { &hf_tcp_len, { "TCP Segment Len", "tcp.len", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", HFILL}}, { &hf_tcp_analysis_acks_frame, --- 2597,2601 ---- { &hf_tcp_len, { "TCP Segment Len", "tcp.len", FT_UINT32, BASE_DEC, NULL, 0x0, ! "", SQLFILL}}, { &hf_tcp_analysis_acks_frame, *************** *** 2609,2613 **** { &hf_tcp_urgent_pointer, { "Urgent pointer", "tcp.urgent_pointer", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_tcp_segment_overlap, --- 2609,2613 ---- { &hf_tcp_urgent_pointer, { "Urgent pointer", "tcp.urgent_pointer", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_tcp_segment_overlap, *************** *** 2703,2706 **** --- 2703,2707 ---- proto_tcp = proto_register_protocol("Transmission Control Protocol", "TCP", "tcp"); + proto_register_sql_protocol(proto_tcp); proto_register_field_array(proto_tcp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); diff -C2 -P -r /var/tmp/ethereal-0.9.13/packet-udp.c flag_ethereal-0.9.13/packet-udp.c *** /var/tmp/ethereal-0.9.13/packet-udp.c Thu Jun 5 13:19:29 2003 --- flag_ethereal-0.9.13/packet-udp.c Sat Jul 5 23:06:03 2003 *************** *** 266,274 **** { &hf_udp_srcport, { "Source Port", "udp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_udp_dstport, { "Destination Port", "udp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_udp_port, --- 266,274 ---- { &hf_udp_srcport, { "Source Port", "udp.srcport", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_udp_dstport, { "Destination Port", "udp.dstport", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_udp_port, *************** *** 278,290 **** { &hf_udp_length, { "Length", "udp.length", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", HFILL }}, { &hf_udp_checksum_bad, { "Bad Checksum", "udp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "", HFILL }}, { &hf_udp_checksum, { "Checksum", "udp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, ! "", HFILL }}, }; static gint *ett[] = { --- 278,290 ---- { &hf_udp_length, { "Length", "udp.length", FT_UINT16, BASE_DEC, NULL, 0x0, ! "", SQLFILL }}, { &hf_udp_checksum_bad, { "Bad Checksum", "udp.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0, ! "", SQLFILL }}, { &hf_udp_checksum, { "Checksum", "udp.checksum", FT_UINT16, BASE_HEX, NULL, 0x0, ! "", SQLFILL }}, }; static gint *ett[] = { *************** *** 294,297 **** --- 294,298 ---- proto_udp = proto_register_protocol("User Datagram Protocol", "UDP", "udp"); + proto_register_sql_protocol(proto_udp); proto_register_field_array(proto_udp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); diff -C2 -P -r /var/tmp/ethereal-0.9.13/print.c flag_ethereal-0.9.13/print.c *** /var/tmp/ethereal-0.9.13/print.c Thu Aug 29 10:40:05 2002 --- flag_ethereal-0.9.13/print.c Sun Jul 6 01:51:37 2003 *************** *** 42,45 **** --- 42,50 ---- #include "packet-data.h" + gchar post[ITEM_LABEL_LENGTH]=""; + int frame_no=0; + // This string is used to append additional SQL statements to each insert. This is used for inserting special tables which do not follow the mold well. Note that the schema for these tables must also be placed in epan/proto.c + GString *additional_sql = NULL; + static void proto_tree_print_node(GNode *node, gpointer data); static void print_hex_data_buffer(FILE *fh, register const guchar *cp, *************** *** 84,88 **** { print_data data; ! /* Create the output */ data.level = 0; --- 89,93 ---- { print_data data; ! /* Create the output */ data.level = 0; *************** *** 144,156 **** /* was a free format label produced? */ ! if (fi->representation) { ! label_ptr = fi->representation; ! } ! else { /* no, make a generic label */ label_ptr = label_str; ! proto_item_fill_label(fi, label_str); ! } ! print_line(pdata->fh, pdata->level, pdata->format, label_ptr); /* If it's uninterpreted data, dump it (unless our caller will --- 149,198 ---- /* was a free format label produced? */ ! // if (fi->representation) { ! // label_ptr = fi->representation; ! // } ! // else { /* no, make a generic label */ label_ptr = label_str; ! proto_item_fill_sql_label(fi, label_str); ! // } ! ! /* SQL stuff */ ! if(fi->hfinfo->sql==2) { ! if(fi->hfinfo->type == FT_PROTOCOL) { ! if(!strcasecmp(fi->hfinfo->abbrev,"frame")) frame_no++; ! printf("%s",post); ! ! if(additional_sql) { ! printf("%s",additional_sql->str); ! g_string_free(additional_sql,1); ! additional_sql=g_string_new(""); ! } else additional_sql=g_string_new(""); ! ! printf("INSERT into `%s` set \n",fi->hfinfo->abbrev ); ! snprintf(post,ITEM_LABEL_LENGTH-1,"key_id = %u;\n",frame_no); ! // } else if(fi->representation) { ! // printf("/* representation %s */\n",fi->representation); ! } else { ! char *new_name = strdup(fi->hfinfo->abbrev); ! char *name=new_name+strlen(new_name); ! ! char *label; ! /* we replace . with _ in the column names */ ! while(name > new_name) { ! if(*name=='.') *name='_'; ! name--; ! }; ! ! /* Now we sanitise label_str to ensure there are no " in it */ ! for(label = label_str; *label; label+=strcspn(label,"\"")) { ! if((*label) == "\"") *label=' '; ! }; ! ! printf("%s = \"%s\",\n",new_name,label_str); ! free(new_name); ! }; ! }; ! // print_line(pdata->fh, pdata->level, pdata->format, label_ptr); /* If it's uninterpreted data, dump it (unless our caller will *************** *** 180,183 **** --- 222,256 ---- } + void print_sql_data(FILE *fh, gint format, epan_dissect_t *edt) { + tvbuff_t *tvb=edt->tvb; + int length= tvb_length(tvb); + int i=0; + const char *ptr=tvb_get_ptr(tvb, 0, length); + + printf("key_id=%u; \n INSERT into data set length = \"%u\", data=\"",frame_no, length); + for(i=0;i<length;i++) { + switch(*(ptr+i)) { + case 0: + printf("\\0"); + break; + case '\'': + printf("\\'"); + break; + case '\"': + printf("\\\""); + break; + case '\n': + printf("\\n"); + break; + case '\\': + printf("\\\\"); + break; + default: + printf("%c",*(ptr+i)); + }; + }; + printf("\","); + }; + void print_hex_data(FILE *fh, gint format, epan_dissect_t *edt) { *************** *** 191,194 **** --- 264,268 ---- guint length; + printf("Printing hex data\n"); /* * Set "multiple_sources" iff this frame has more than one diff -C2 -P -r /var/tmp/ethereal-0.9.13/tethereal.c flag_ethereal-0.9.13/tethereal.c *** /var/tmp/ethereal-0.9.13/tethereal.c Tue Jun 10 09:28:43 2003 --- flag_ethereal-0.9.13/tethereal.c Sun Jul 6 00:04:40 2003 *************** *** 115,118 **** --- 115,119 ---- static gboolean verbose; static gboolean print_hex; + static gboolean print_sql; static gboolean line_buffered; *************** *** 715,721 **** if (strcmp(argv[2], "fields") == 0) proto_registrar_dump_fields(); ! else if (strcmp(argv[2], "protocols") == 0) proto_registrar_dump_protocols(); ! else { fprintf(stderr, "tethereal: Invalid \"%s\" option for -G flag\n", argv[2]); --- 716,726 ---- if (strcmp(argv[2], "fields") == 0) proto_registrar_dump_fields(); ! else if (strcmp(argv[2], "protocols") == 0) { proto_registrar_dump_protocols(); ! } else if(!strcmp(argv[2],"sql")) { ! proto_registrar_dump_sql(1); ! } else if(!strcmp(argv[2],"drop")) { ! proto_registrar_dump_sql(0); ! } else { fprintf(stderr, "tethereal: Invalid \"%s\" option for -G flag\n", argv[2]); *************** *** 760,764 **** /* Now get our args */ ! while ((opt = getopt(argc, argv, "a:b:c:d:Df:F:hi:lnN:o:pqr:R:s:St:vw:Vxz:")) != -1) { switch (opt) { case 'a': /* autostop criteria */ --- 765,769 ---- /* Now get our args */ ! while ((opt = getopt(argc, argv, "a:b:c:d:Df:F:hi:lnN:o:pqr:R:s:St:vw:VQxz:")) != -1) { switch (opt) { case 'a': /* autostop criteria */ *************** *** 958,961 **** --- 963,970 ---- print_hex = TRUE; break; + /* Prints SQL insert statements instead */ + case 'Q': + print_sql = TRUE; + break; case 'z': for(tli=tap_list;tli;tli=tli->next){ *************** *** 2338,2342 **** putchar('\n'); } ! if (print_hex) { print_hex_data(stdout, print_args.format, edt); putchar('\n'); --- 2347,2354 ---- putchar('\n'); } ! if (print_hex && print_sql) { ! print_sql_data(stdout, print_args.format, edt); ! putchar('\n'); ! } else if(print_hex ){ print_hex_data(stdout, print_args.format, edt); putchar('\n');
- Follow-Ups:
- Re: [Ethereal-dev] SQL patch
- From: Guy Harris
- Re: [Ethereal-dev] SQL patch
- Prev by Date: Re: [Ethereal-dev] ASN.1 dissector.
- Next by Date: RE: [Ethereal-dev] proto_tree_append_string() - now fixed
- Previous by thread: Re: [Ethereal-dev] Patches for packet-ansi_map.c packet-ansi_a.c packet-bssap.c
- Next by thread: Re: [Ethereal-dev] SQL patch
- Index(es):