diff options
43 files changed, 1029 insertions, 1918 deletions
diff --git a/epan/conversation_table.c b/epan/conversation_table.c index 61ec310a19..b3c90e5b7a 100644 --- a/epan/conversation_table.c +++ b/epan/conversation_table.c @@ -38,8 +38,11 @@ GList *cmd_string_list_ = NULL; struct register_ct { gboolean hide_ports; /* hide TCP / UDP port columns */ int proto_id; /* protocol id (0-indexed) */ - tap_packet_cb packet_func; /* function to be called for new incoming packets */ - conv_gui_init_cb gui_init_cb; /* GUI specific function to initialize conversation */ + tap_packet_cb conv_func; /* function to be called for new incoming packets for conversation*/ + tap_packet_cb host_func; /* function to be called for new incoming packets for hostlist */ + host_tap_prefix prefix_func; /* function to provide prefix if different than default (host) */ + conv_gui_init_cb conv_gui_init; /* GUI specific function to initialize conversation */ + host_gui_init_cb host_gui_init; /* GUI specific function to initialize hostlist */ }; gboolean get_conversation_hide_ports(register_ct_t* ct) @@ -57,9 +60,20 @@ int get_conversation_proto_id(register_ct_t* ct) tap_packet_cb get_conversation_packet_func(register_ct_t* ct) { - return ct->packet_func; + return ct->conv_func; } +tap_packet_cb get_hostlist_packet_func(register_ct_t* ct) +{ + return ct->host_func; +} + +host_tap_prefix get_hostlist_prefix_func(register_ct_t* ct) +{ + return ct->prefix_func; +} + + static GSList *registered_ct_tables = NULL; void @@ -77,10 +91,29 @@ dissector_conversation_init(const char *opt_arg, void* userdata) } g_string_free(cmd_str, TRUE); - if (table->gui_init_cb) - table->gui_init_cb(table, filter); + if (table->conv_gui_init) + table->conv_gui_init(table, filter); } +void +dissector_hostlist_init(const char *opt_arg, void* userdata) +{ + register_ct_t *table = (register_ct_t*)userdata; + GString *cmd_str = g_string_new(""); + const char *filter=NULL; + + g_string_printf(cmd_str, "%s,%s,", (table->prefix_func != NULL) ? table->prefix_func() : "host", proto_get_protocol_filter_name(table->proto_id)); + if(!strncmp(opt_arg, cmd_str->str, cmd_str->len)){ + filter=opt_arg+cmd_str->len; + } else { + filter=NULL; + } + + g_string_free(cmd_str, TRUE); + + if (table->host_gui_init) + table->host_gui_init(table, filter); +} /** get conversation from protocol ID * * @param proto_id protocol ID @@ -110,37 +143,58 @@ insert_sorted_by_table_name(gconstpointer aparam, gconstpointer bparam) } void -register_conversation_table(const int proto_id, gboolean hide_ports, tap_packet_cb packet_func) +register_conversation_table(const int proto_id, gboolean hide_ports, tap_packet_cb conv_packet_func, tap_packet_cb hostlist_func, host_tap_prefix prefix_func) { register_ct_t *table; - GString *cmd_str = g_string_new("conv,"); + GString *conv_cmd_str = g_string_new("conv,"); + GString *host_cmd_str = g_string_new(""); table = g_new(register_ct_t,1); - table->hide_ports = hide_ports; - table->proto_id = proto_id; - table->packet_func = packet_func; - table->gui_init_cb = NULL; + table->hide_ports = hide_ports; + table->proto_id = proto_id; + table->conv_func = conv_packet_func; + table->host_func = hostlist_func; + table->conv_gui_init = NULL; + table->host_gui_init = NULL; + table->prefix_func = prefix_func; registered_ct_tables = g_slist_insert_sorted(registered_ct_tables, table, insert_sorted_by_table_name); - g_string_append(cmd_str, proto_get_protocol_filter_name(table->proto_id)); - cmd_string_list_ = g_list_append(cmd_string_list_, cmd_str->str); - register_stat_cmd_arg(cmd_str->str, dissector_conversation_init, table); - g_string_free(cmd_str, FALSE); + g_string_append(conv_cmd_str, proto_get_protocol_filter_name(table->proto_id)); + cmd_string_list_ = g_list_append(cmd_string_list_, conv_cmd_str->str); + register_stat_cmd_arg(conv_cmd_str->str, dissector_conversation_init, table); + g_string_free(conv_cmd_str, FALSE); + + g_string_printf(host_cmd_str, "%s,%s", (get_hostlist_prefix_func(table) != NULL) ? get_hostlist_prefix_func(table)() : "host", + proto_get_protocol_filter_name(table->proto_id)); + register_stat_cmd_arg(host_cmd_str->str, dissector_hostlist_init, table); + g_string_free(host_cmd_str, FALSE); } /* Set GUI fields for register_ct list */ static void -set_gui_data(gpointer data, gpointer user_data) +set_conv_gui_data(gpointer data, gpointer user_data) { register_ct_t *table = (register_ct_t*)data; - table->gui_init_cb = (conv_gui_init_cb)user_data; + table->conv_gui_init = (conv_gui_init_cb)user_data; } void conversation_table_set_gui_info(conv_gui_init_cb init_cb) { - g_slist_foreach(registered_ct_tables, set_gui_data, init_cb); + g_slist_foreach(registered_ct_tables, set_conv_gui_data, init_cb); +} + +static void +set_host_gui_data(gpointer data, gpointer user_data) +{ + register_ct_t *table = (register_ct_t*)data; + table->host_gui_init = (host_gui_init_cb)user_data; +} + +void hostlist_table_set_gui_info(host_gui_init_cb init_cb) +{ + g_slist_foreach(registered_ct_tables, set_host_gui_data, init_cb); } void conversation_table_iterate_tables(GFunc func, gpointer user_data) @@ -243,6 +297,30 @@ reset_conversation_table_data(conv_hash_t *ch) ch->hashtable=NULL; } +void reset_hostlist_table_data(conv_hash_t *ch) +{ + if (!ch) { + return; + } + + if (ch->conv_array != NULL) { + guint i; + for(i = 0; i < ch->conv_array->len; i++){ + hostlist_talker_t *host = &g_array_index(ch->conv_array, hostlist_talker_t, i); + g_free((gpointer)host->myaddress.data); + } + + g_array_free(ch->conv_array, TRUE); + } + + if (ch->hashtable != NULL) { + g_hash_table_destroy(ch->hashtable); + } + + ch->conv_array=NULL; + ch->hashtable=NULL; +} + const char *get_conversation_address(address *addr, gboolean resolve_names) { if (resolve_names) { @@ -288,6 +366,17 @@ conversation_get_filter_name(conv_item_t *conv_item, conv_filter_type_e filter_t return conv_item->dissector_info->get_filter_type(conv_item, filter_type); } +static const char * +hostlist_get_filter_name(hostlist_talker_t *host, conv_filter_type_e filter_type) +{ + + if ((host == NULL) || (host->dissector_info == NULL) || (host->dissector_info->get_filter_type == NULL)) { + return CONV_FILTER_INVALID; + } + + return host->dissector_info->get_filter_type(host, filter_type); +} + /* Convert a port number into a string or NULL */ static char * ct_port_to_str(port_type ptype, guint32 port) @@ -438,6 +527,24 @@ const char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e dir return str; } +const char *get_hostlist_filter(hostlist_talker_t *host) +{ + char *sport; + const char *str; + + sport=ct_port_to_str(host->ptype, host->port); + + str = g_strdup_printf("%s==%s%s%s%s%s", + hostlist_get_filter_name(host, CONV_FT_ANY_ADDRESS), + ep_address_to_str(&host->myaddress), + sport?" && ":"", + sport?hostlist_get_filter_name(host, CONV_FT_ANY_PORT):"", + sport?"==":"", + sport?sport:""); + + return str; +} + void add_conversation_table_data(conv_hash_t *ch, const address *src, const address *dst, guint32 src_port, guint32 dst_port, int num_frames, int num_bytes, nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info, port_type ptype) @@ -573,6 +680,109 @@ add_conversation_table_data_with_conv_id( } /* + * Compute the hash value for a given address/port pairs if the match + * is to be exact. + */ +static guint +host_hash(gconstpointer v) +{ + const host_key_t *key = (const host_key_t *)v; + guint hash_val; + + hash_val = 0; + ADD_ADDRESS_TO_HASH(hash_val, &key->myaddress); + hash_val += key->port; + return hash_val; +} + +/* + * Compare two host keys for an exact match. + */ +static gint +host_match(gconstpointer v, gconstpointer w) +{ + const host_key_t *v1 = (const host_key_t *)v; + const host_key_t *v2 = (const host_key_t *)w; + + if (v1->port == v2->port && + ADDRESSES_EQUAL(&v1->myaddress, &v2->myaddress)) { + return 1; + } + /* + * The addresses or the ports don't match. + */ + return 0; +} + +void +add_hostlist_table_data(conv_hash_t *ch, const address *addr, guint32 port, gboolean sender, int num_frames, int num_bytes, hostlist_dissector_info_t *host_info, port_type port_type_val) +{ + hostlist_talker_t *talker=NULL; + int talker_idx=0; + + /* XXX should be optimized to allocate n extra entries at a time + instead of just one */ + /* if we dont have any entries at all yet */ + if(ch->conv_array==NULL){ + ch->conv_array=g_array_sized_new(FALSE, FALSE, sizeof(hostlist_talker_t), 10000); + ch->hashtable = g_hash_table_new_full(host_hash, + host_match, /* key_equal_func */ + g_free, /* key_destroy_func */ + NULL); /* value_destroy_func */ + } + else { + /* try to find it among the existing known conversations */ + host_key_t existing_key; + + existing_key.myaddress = *addr; + existing_key.port = port; + + if (g_hash_table_lookup_extended(ch->hashtable, &existing_key, NULL, (gpointer *) &talker_idx)) { + talker = &g_array_index(ch->conv_array, hostlist_talker_t, talker_idx); + } + } + + /* if we still dont know what talker this is it has to be a new one + and we have to allocate it and append it to the end of the list */ + if(talker==NULL){ + host_key_t *new_key; + hostlist_talker_t host; + + COPY_ADDRESS(&host.myaddress, addr); + host.dissector_info = host_info; + host.ptype=port_type_val; + host.port=port; + host.rx_frames=0; + host.tx_frames=0; + host.rx_bytes=0; + host.tx_bytes=0; + host.modified = TRUE; + + g_array_append_val(ch->conv_array, host); + talker_idx= ch->conv_array->len - 1; + talker=&g_array_index(ch->conv_array, hostlist_talker_t, talker_idx); + + /* hl->hosts address is not a constant but address.data is */ + new_key = g_new(host_key_t,1); + SET_ADDRESS(&new_key->myaddress, talker->myaddress.type, talker->myaddress.len, talker->myaddress.data); + new_key->port = port; + g_hash_table_insert(ch->hashtable, new_key, GUINT_TO_POINTER(talker_idx)); + } + + /* if this is a new talker we need to initialize the struct */ + talker->modified = TRUE; + + /* update the talker struct */ + if( sender ){ + talker->tx_frames+=num_frames; + talker->tx_bytes+=num_bytes; + } else { + talker->rx_frames+=num_frames; + talker->rx_bytes+=num_bytes; + } +} + +/* * Editor modelines * * Local Variables: diff --git a/epan/conversation_table.h b/epan/conversation_table.h index 4349ac96a1..8814f54ec5 100644 --- a/epan/conversation_table.h +++ b/epan/conversation_table.h @@ -75,22 +75,34 @@ typedef struct _conversation_key_t { conv_id_t conv_id; } conv_key_t; +typedef struct { + address myaddress; + guint32 port; +} host_key_t; + struct _conversation_item_t; typedef const char* (*conv_get_filter_type)(struct _conversation_item_t* item, conv_filter_type_e filter); -typedef const char* (*conv_get_conversation_filter_type)(struct _conversation_item_t* item, conv_direction_e direction); - - typedef struct _ct_dissector_info { conv_get_filter_type get_filter_type; } ct_dissector_info_t; +struct _hostlist_talker_t; +typedef const char* (*host_get_filter_type)(struct _hostlist_talker_t* item, conv_filter_type_e filter_type); + +typedef struct _hostlist_dissector_info { + host_get_filter_type get_filter_type; +} hostlist_dissector_info_t; + #define CONV_FILTER_INVALID "INVALID" struct register_ct; typedef void (*conv_gui_init_cb)(struct register_ct* ct, const char *filter); +typedef void (*host_gui_init_cb)(struct register_ct* host, const char *filter); +typedef const char* (*host_tap_prefix)(void); + /** Structure for information about a registered conversation */ typedef struct register_ct register_ct_t; @@ -116,14 +128,31 @@ typedef struct _conversation_item_t { gboolean modified; /**< new to redraw the row (only used in GTK+) */ } conv_item_t; +/** Hostlist information */ +typedef struct _hostlist_talker_t { + hostlist_dissector_info_t *dissector_info; /**< conversation information provided by dissector */ + address myaddress; /**< address */ + port_type ptype; /**< port_type (e.g. PT_TCP) */ + guint32 port; /**< port */ + + guint64 rx_frames; /**< number of received packets */ + guint64 tx_frames; /**< number of transmitted packets */ + guint64 rx_bytes; /**< number of received bytes */ + guint64 tx_bytes; /**< number of transmitted bytes */ + + gboolean modified; /**< new to redraw the row */ + +} hostlist_talker_t; + /** Register the conversation table for the multiple conversation window. * + * @param proto_id is the protocol with conversation * @param hide_ports hide the port columns - * @param table_name the table name to be displayed - * @param tap_name the registered tap name - * @param packet_func the function to be called for each incoming packet + * @param conv_packet_func the registered conversation tap name + * @param hostlist_func the registered hostlist tap name + * @param prefix_func the function if hostlist tap has diffent name than default ("host") */ -extern void register_conversation_table(const int proto_id, gboolean hide_ports, tap_packet_cb packet_func); +extern void register_conversation_table(const int proto_id, gboolean hide_ports, tap_packet_cb conv_packet_func, tap_packet_cb hostlist_func, host_tap_prefix prefix_func); /** Should port columns be hidden? * @@ -146,6 +175,20 @@ WS_DLL_PUBLIC int get_conversation_proto_id(register_ct_t* ct); */ WS_DLL_PUBLIC tap_packet_cb get_conversation_packet_func(register_ct_t* ct); +/** Get tap function handler from hostlist + * + * @param ct Registered conversation + * @return tap function handler of conversation + */ +WS_DLL_PUBLIC tap_packet_cb get_hostlist_packet_func(register_ct_t* ct); + +/** Get tap function handler from hostlist + * + * @param ct Registered conversation + * @return tap function handler of conversation + */ +WS_DLL_PUBLIC host_tap_prefix get_hostlist_prefix_func(register_ct_t* ct); + /** get conversation from protocol ID * * @param proto_id protocol ID @@ -161,6 +204,14 @@ WS_DLL_PUBLIC register_ct_t* get_conversation_by_proto_id(int proto_id); */ WS_DLL_PUBLIC void conversation_table_set_gui_info(conv_gui_init_cb init_cb); +/** Register "initialization function" used by the GUI to create hostlist + * table display in GUI + * + * @param init_cb callback function that will be called when hostlist "display" + * is instantiated in GUI + */ +WS_DLL_PUBLIC void hostlist_table_set_gui_info(host_gui_init_cb init_cb); + /** Interator to walk converation tables and execute func * a GUI menu (only used in GTK) * @@ -187,13 +238,26 @@ WS_DLL_PUBLIC register_ct_t* get_conversation_table_by_num(guint table_num); */ WS_DLL_PUBLIC void reset_conversation_table_data(conv_hash_t *ch); -/** Initialize dissector converation for stats and (possibly) GUI. +/** Remove all entries from the hostlist table. + * + * @param ch the table to reset + */ +WS_DLL_PUBLIC void reset_hostlist_table_data(conv_hash_t *ch); + +/** Initialize dissector conversation for stats and (possibly) GUI. * * @param opt_arg filter string to compare with dissector * @param userdata register_ct_t* for dissector conversation */ WS_DLL_PUBLIC void dissector_conversation_init(const char *opt_arg, void* userdata); +/** Initialize dissector hostlist for stats and (possibly) GUI. + * + * @param opt_arg filter string to compare with dissector + * @param userdata register_ct_t* for dissector conversation + */ +WS_DLL_PUBLIC void dissector_hostlist_init(const char *opt_arg, void* userdata); + /** Get the string representation of an address. * * @param addr The address. @@ -219,6 +283,14 @@ WS_DLL_PUBLIC const char *get_conversation_port(guint32 port, port_type ptype, g */ WS_DLL_PUBLIC const char *get_conversation_filter(conv_item_t *conv_item, conv_direction_e direction); +/** Get a display filter for the given hostlist and direction. + * + * @param host The hostlist. + * @param direction The desired direction. + * @return An ep_allocated string representing the conversation. + */ +WS_DLL_PUBLIC const char *get_hostlist_filter(hostlist_talker_t *host); + /** Add some data to the conversation table. * * @param ch the table to add the data to @@ -255,19 +327,23 @@ extern void add_conversation_table_data(conv_hash_t *ch, const address *src, con * @param conv_id a value to help differentiate the conversation in case the address and port quadruple is not sufficiently unique */ extern void -add_conversation_table_data_with_conv_id( - conv_hash_t *ch, - const address *src, - const address *dst, - guint32 src_port, - guint32 dst_port, - conv_id_t conv_id, - int num_frames, - int num_bytes, - nstime_t *ts, - nstime_t *abs_ts, - ct_dissector_info_t *ct_info, - port_type ptype); +add_conversation_table_data_with_conv_id(conv_hash_t *ch, const address *src, const address *dst, guint32 src_port, + guint32 dst_port, conv_id_t conv_id, int num_frames, int num_bytes, + nstime_t *ts, nstime_t *abs_ts, ct_dissector_info_t *ct_info, port_type ptype); + +/** Add some data to the table. + * + * @param hl the table to add the data to + * @param addr address + * @param port port + * @param sender TRUE, if this is a sender + * @param num_frames number of packets + * @param num_bytes number of bytes + * @param sat address type + * @param port_type the port type (e.g. PT_TCP) + */ +void add_hostlist_table_data(conv_hash_t *ch, const address *addr, + guint32 port, gboolean sender, int num_frames, int num_bytes, hostlist_dissector_info_t *host_info, port_type port_type_val); #ifdef __cplusplus } diff --git a/epan/dissectors/packet-eth.c b/epan/dissectors/packet-eth.c index 4c3e040781..7e75a503ec 100644 --- a/epan/dissectors/packet-eth.c +++ b/epan/dissectors/packet-eth.c @@ -135,6 +135,34 @@ eth_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* eth_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_ETHER)) + return "eth.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t eth_host_dissector_info = {ð_host_get_filter_type}; + +static int +eth_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const eth_hdr *ehdr=(const eth_hdr *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &ehdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, ð_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &ehdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, ð_host_dissector_info, PT_NONE); + + return 1; +} + + + + /* These are the Netware-ish names for the different Ethernet frame types. EthernetII: The ethernet with a Type field instead of a length field Ethernet802.2: An 802.3 header followed by an 802.2 header @@ -971,7 +999,7 @@ proto_register_eth(void) register_dissector("eth", dissect_eth_maybefcs, proto_eth); eth_tap = register_tap("eth"); - register_conversation_table(proto_eth, TRUE, eth_conversation_packet); + register_conversation_table(proto_eth, TRUE, eth_conversation_packet, eth_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c index 82a5bd69dc..e4a5b512be 100644 --- a/epan/dissectors/packet-fc.c +++ b/epan/dissectors/packet-fc.c @@ -233,6 +233,31 @@ fc_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, c return 1; } +static const char* fc_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_FC)) + return "fc.id"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t fc_host_dissector_info = {&fc_host_get_filter_type}; + +static int +fc_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const fc_hdr *fchdr=(const fc_hdr *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &fchdr->s_id, 0, TRUE, 1, pinfo->fd->pkt_len, &fc_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &fchdr->d_id, 0, FALSE, 1, pinfo->fd->pkt_len, &fc_host_dissector_info, PT_NONE); + + return 1; +} + const value_string fc_fc4_val[] = { {FC_TYPE_BLS, "Basic Link Svc"}, {FC_TYPE_ELS, "Ext Link Svc"}, @@ -1607,7 +1632,7 @@ proto_register_fc(void) fcsof_handle = register_dissector("fcsof", dissect_fcsof, proto_fcsof); - register_conversation_table(proto_fc, TRUE, fc_conversation_packet); + register_conversation_table(proto_fc, TRUE, fc_conversation_packet, fc_hostlist_packet, NULL); } diff --git a/epan/dissectors/packet-fddi.c b/epan/dissectors/packet-fddi.c index e14f1bad1a..bf4652738d 100644 --- a/epan/dissectors/packet-fddi.c +++ b/epan/dissectors/packet-fddi.c @@ -170,6 +170,31 @@ fddi_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* fddi_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_ETHER)) + return "fddi.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t fddi_host_dissector_info = {&fddi_host_get_filter_type}; + +static int +fddi_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const fddi_hdr *ehdr=(const fddi_hdr *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &ehdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, &fddi_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &ehdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, &fddi_host_dissector_info, PT_NONE); + + return 1; +} + void capture_fddi(const guchar *pd, int len, packet_counts *ld) { @@ -505,7 +530,7 @@ proto_register_fddi(void) &fddi_padding); fddi_tap = register_tap("fddi"); - register_conversation_table(proto_fddi, TRUE, fddi_conversation_packet); + register_conversation_table(proto_fddi, TRUE, fddi_conversation_packet, fddi_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index defb9920d0..3d14a159de 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -5266,6 +5266,30 @@ wlan_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* wlan_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_ETHER)) + return "wlan.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t wlan_host_dissector_info = {&wlan_host_get_filter_type}; + +static int +wlan_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const wlan_hdr *whdr=(const wlan_hdr *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &whdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, &wlan_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &whdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, &wlan_host_dissector_info, PT_NONE); + + return 1; +} static void beacon_interval_base_custom(gchar *result, guint32 beacon_interval) { @@ -26211,7 +26235,7 @@ proto_register_ieee80211 (void) register_init_routine(ieee80211_gas_reassembly_init); wlan_tap = register_tap("wlan"); - register_conversation_table(proto_wlan, TRUE, wlan_conversation_packet); + register_conversation_table(proto_wlan, TRUE, wlan_conversation_packet, wlan_hostlist_packet, NULL); /* Register configuration options */ wlan_module = prefs_register_protocol(proto_wlan, init_wepkeys); diff --git a/epan/dissectors/packet-ip.c b/epan/dissectors/packet-ip.c index ed0b8991f6..5fedb0b4cb 100644 --- a/epan/dissectors/packet-ip.c +++ b/epan/dissectors/packet-ip.c @@ -501,6 +501,30 @@ ip_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, c return 1; } +static const char* ip_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_IPv4)) + return "ip.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t ip_host_dissector_info = {&ip_host_get_filter_type}; + +static int +ip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const ws_ip *iph=(const ws_ip *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &iph->ip_src, 0, TRUE, 1, pinfo->fd->pkt_len, &ip_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &iph->ip_dst, 0, FALSE, 1, pinfo->fd->pkt_len, &ip_host_dissector_info, PT_NONE); + return 1; +} + /* * defragmentation of IPv4 */ @@ -3067,7 +3091,7 @@ proto_register_ip(void) ip_tap = register_tap("ip"); register_decode_as(&ip_da); - register_conversation_table(proto_ip, TRUE, ip_conversation_packet); + register_conversation_table(proto_ip, TRUE, ip_conversation_packet, ip_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-ipv6.c b/epan/dissectors/packet-ipv6.c index f4b67084cf..3857f465b5 100644 --- a/epan/dissectors/packet-ipv6.c +++ b/epan/dissectors/packet-ipv6.c @@ -383,6 +383,34 @@ ipv6_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* ipv6_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_IPv6)) + return "ipv6.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t ipv6_host_dissector_info = {&ipv6_host_get_filter_type}; + +static int +ipv6_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const struct ip6_hdr *ip6h = (const struct ip6_hdr *)vip; + address src; + address dst; + + /* Addresses aren't implemented as 'address' type in struct ip6_hdr */ + SET_ADDRESS(&src, AT_IPv6, sizeof(struct e_in6_addr), &ip6h->ip6_src); + SET_ADDRESS(&dst, AT_IPv6, sizeof(struct e_in6_addr), &ip6h->ip6_dst); + + add_hostlist_table_data(hash, &src, 0, TRUE, 1, pinfo->fd->pkt_len, &ipv6_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &dst, 0, FALSE, 1, pinfo->fd->pkt_len, &ipv6_host_dissector_info, PT_NONE); + + return 1; +} + static const fragment_items ipv6_frag_items = { &ett_ipv6_fragment, &ett_ipv6_fragments, @@ -2944,7 +2972,7 @@ proto_register_ipv6(void) register_decode_as(&ipv6_da); register_decode_as(&ipv6_next_header_da); - register_conversation_table(proto_ipv6, TRUE, ipv6_conversation_packet); + register_conversation_table(proto_ipv6, TRUE, ipv6_conversation_packet, ipv6_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c index f632d8d0a8..4ce7fc211f 100644 --- a/epan/dissectors/packet-ipx.c +++ b/epan/dissectors/packet-ipx.c @@ -174,6 +174,31 @@ ipx_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* ipx_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_IPX)) + return "ipx.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t ipx_host_dissector_info = {&ipx_host_get_filter_type}; + +static int +ipx_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const ipxhdr_t *ipxh=(const ipxhdr_t *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &ipxh->ipx_src, 0, TRUE, 1, pinfo->fd->pkt_len, &ipx_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &ipxh->ipx_dst, 0, FALSE, 1, pinfo->fd->pkt_len, &ipx_host_dissector_info, PT_NONE); + + return 1; +} + /* ================================================================= */ /* IPX */ /* ================================================================= */ @@ -1568,7 +1593,7 @@ proto_register_ipx(void) register_postseq_cleanup_routine(&spx_postseq_cleanup); ipx_tap=register_tap("ipx"); - register_conversation_table(proto_ipx, TRUE, ipx_conversation_packet); + register_conversation_table(proto_ipx, TRUE, ipx_conversation_packet, ipx_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-jxta.c b/epan/dissectors/packet-jxta.c index 3cefa18000..c89ba42bcc 100644 --- a/epan/dissectors/packet-jxta.c +++ b/epan/dissectors/packet-jxta.c @@ -223,6 +223,30 @@ jxta_conversation_packet(void *pct, packet_info *pinfo _U_, epan_dissect_t *edt return 1; } +static const char* jxta_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_URI)) + return "jxta.message.address"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t jxta_host_dissector_info = {&jxta_host_get_filter_type}; + +static int +jxta_hostlist_packet(void *pit, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const jxta_tap_header *jxtahdr = (const jxta_tap_header *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &jxtahdr->src_address, 0, TRUE, 1, jxtahdr->size, &jxta_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &jxtahdr->dest_address, 0, FALSE, 1, jxtahdr->size, &jxta_host_dissector_info, PT_NONE); + return 1; +} + /** * Prototypes **/ @@ -2352,7 +2376,7 @@ void proto_register_jxta(void) prefs_register_bool_preference(jxta_module, "sctp.heuristic", "Try to discover JXTA in SCTP connections", "Enable to inspect SCTP connections for JXTA conversations.", &gSCTP_HEUR); - register_conversation_table(proto_jxta, TRUE, jxta_conversation_packet); + register_conversation_table(proto_jxta, TRUE, jxta_conversation_packet, jxta_hostlist_packet, NULL); } diff --git a/epan/dissectors/packet-ncp.c b/epan/dissectors/packet-ncp.c index f1695ef86c..503262fd10 100644 --- a/epan/dissectors/packet-ncp.c +++ b/epan/dissectors/packet-ncp.c @@ -321,6 +321,28 @@ ncp_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* ncp_host_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + return ncp_conv_get_filter_type(NULL, filter); +} + +static hostlist_dissector_info_t ncp_host_dissector_info = {&ncp_host_get_filter_type}; + +static int +ncp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip _U_) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + /*const ncp_common_header *ncphdr=vip;*/ + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &pinfo->src, 0, TRUE, 1, pinfo->fd->pkt_len, &ncp_host_dissector_info, PT_NCP); + add_hostlist_table_data(hash, &pinfo->dst, 0, FALSE, 1, pinfo->fd->pkt_len, &ncp_host_dissector_info, PT_NCP); + + return 1; +} + /* * Burst packet system flags. */ @@ -1127,7 +1149,7 @@ proto_register_ncp(void) ncp_tap.hdr=register_tap("ncp"); register_postseq_cleanup_routine(&mncp_postseq_cleanup); - register_conversation_table(proto_ncp, FALSE, ncp_conversation_packet); + register_conversation_table(proto_ncp, FALSE, ncp_conversation_packet, ncp_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-rsvp.c b/epan/dissectors/packet-rsvp.c index 8917691c4a..95dbf6d4da 100644 --- a/epan/dissectors/packet-rsvp.c +++ b/epan/dissectors/packet-rsvp.c @@ -1892,6 +1892,29 @@ rsvp_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* rsvp_host_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + return rsvp_conv_get_filter_type(NULL, filter); +} + +static hostlist_dissector_info_t rsvp_host_dissector_info = {&rsvp_host_get_filter_type}; + +static int +rsvp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const rsvp_conversation_info *rsvph = (const rsvp_conversation_info *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures + * that all packets are counted properly (even if address is sending to + * itself). XXX - this could probably be done more efficiently inside + * hostlist_table + */ + add_hostlist_table_data(hash, &rsvph->source, 0, TRUE, 1, pinfo->fd->pkt_len, &rsvp_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &rsvph->destination, 0, FALSE, 1, pinfo->fd->pkt_len, &rsvp_host_dissector_info, PT_NONE); + return 1; +} + static inline int rsvp_class_to_filter_num(int classnum) { @@ -9177,7 +9200,7 @@ proto_register_rsvp(void) /* Initialization routine for RSVP conversations */ register_init_routine(&rsvp_init_protocol); - register_conversation_table(proto_rsvp, TRUE, rsvp_conversation_packet); + register_conversation_table(proto_rsvp, TRUE, rsvp_conversation_packet, rsvp_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c index dd7d32e378..743b1b6b9b 100644 --- a/epan/dissectors/packet-sctp.c +++ b/epan/dissectors/packet-sctp.c @@ -825,6 +825,28 @@ sctp_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* sctp_host_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + return sctp_conv_get_filter_type(NULL, filter); +} + +static hostlist_dissector_info_t sctp_host_dissector_info = {&sctp_host_get_filter_type}; + +static int +sctp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const struct _sctp_info *sctphdr=(const struct _sctp_info *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &sctphdr->ip_src, sctphdr->sport, TRUE, 1, pinfo->fd->pkt_len, &sctp_host_dissector_info, PT_SCTP); + add_hostlist_table_data(hash, &sctphdr->ip_dst, sctphdr->dport, FALSE, 1, pinfo->fd->pkt_len, &sctp_host_dissector_info, PT_SCTP); + + return 1; +} + static unsigned int sctp_adler32(tvbuff_t *tvb, unsigned int len) { @@ -4887,7 +4909,7 @@ proto_register_sctp(void) register_decode_as(&sctp_da_port); register_decode_as(&sctp_da_ppi); - register_conversation_table(proto_sctp, FALSE, sctp_conversation_packet); + register_conversation_table(proto_sctp, FALSE, sctp_conversation_packet, sctp_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-tcp.c b/epan/dissectors/packet-tcp.c index 47cef7aa2d..1c993b9ba3 100644 --- a/epan/dissectors/packet-tcp.c +++ b/epan/dissectors/packet-tcp.c @@ -574,6 +574,34 @@ tcpip_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_ return 1; } +static const char* tcp_host_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + return tcp_conv_get_filter_type(NULL, filter); +} + +static hostlist_dissector_info_t tcp_host_dissector_info = {&tcp_host_get_filter_type}; + +static int +tcpip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const struct tcpheader *tcphdr=(const struct tcpheader *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &tcphdr->ip_src, tcphdr->th_sport, TRUE, 1, pinfo->fd->pkt_len, &tcp_host_dissector_info, PT_TCP); + add_hostlist_table_data(hash, &tcphdr->ip_dst, tcphdr->th_dport, FALSE, 1, pinfo->fd->pkt_len, &tcp_host_dissector_info, PT_TCP); + + return 1; +} + +static const char* +tcpip_hostlist_prefix(void) +{ + return "endpoints"; +} + /* TCP structs and definitions */ /* ************************************************************************** @@ -5874,7 +5902,7 @@ proto_register_tcp(void) register_decode_as(&tcp_da); - register_conversation_table(proto_tcp, FALSE, tcpip_conversation_packet); + register_conversation_table(proto_tcp, FALSE, tcpip_conversation_packet, tcpip_hostlist_packet, tcpip_hostlist_prefix); } void diff --git a/epan/dissectors/packet-tr.c b/epan/dissectors/packet-tr.c index 5ca24efa6b..5a491af82c 100644 --- a/epan/dissectors/packet-tr.c +++ b/epan/dissectors/packet-tr.c @@ -147,7 +147,7 @@ static ct_dissector_info_t tr_ct_dissector_info = {&tr_conv_get_filter_type}; static int tr_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) { - conv_hash_t *hash = (conv_hash_t*) pct; + conv_hash_t *hash = (conv_hash_t*) pct; const tr_hdr *trhdr=(const tr_hdr *)vip; add_conversation_table_data(hash, &trhdr->src, &trhdr->dst, 0, 0, 1, pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->fd->abs_ts, &tr_ct_dissector_info, PT_NONE); @@ -155,6 +155,31 @@ tr_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, c return 1; } +static const char* tr_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_ETHER)) + return "tr.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t tr_host_dissector_info = {&tr_host_get_filter_type}; + +static int +tr_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const tr_hdr *trhdr=(const tr_hdr *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &trhdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, &tr_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &trhdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, &tr_host_dissector_info, PT_NONE); + + return 1; +} + /* * DODGY LINUX HACK DODGY LINUX HACK * Linux 2.0.x always passes frames to the Token Ring driver for transmission with @@ -763,7 +788,7 @@ proto_register_tr(void) register_dissector("tr", dissect_tr, proto_tr); tr_tap=register_tap("tr"); - register_conversation_table(proto_tr, TRUE, tr_conversation_packet); + register_conversation_table(proto_tr, TRUE, tr_conversation_packet, tr_hostlist_packet, NULL); } void diff --git a/epan/dissectors/packet-udp.c b/epan/dissectors/packet-udp.c index 5730403cc6..cacd5d9b1e 100644 --- a/epan/dissectors/packet-udp.c +++ b/epan/dissectors/packet-udp.c @@ -321,12 +321,40 @@ static ct_dissector_info_t udp_ct_dissector_info = {&udp_conv_get_filter_type}; static int udpip_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) { - conv_hash_t *hash = (conv_hash_t*) pct; - const e_udphdr *udphdr=(const e_udphdr *)vip; + conv_hash_t *hash = (conv_hash_t*) pct; + const e_udphdr *udphdr=(const e_udphdr *)vip; add_conversation_table_data(hash, &udphdr->ip_src, &udphdr->ip_dst, udphdr->uh_sport, udphdr->uh_dport, 1, pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->fd->abs_ts, &udp_ct_dissector_info, PT_UDP); - return 1; + return 1; +} + +static const char* udp_host_get_filter_type(hostlist_talker_t* host _U_, conv_filter_type_e filter) +{ + return udp_conv_get_filter_type(NULL, filter); +} + +static hostlist_dissector_info_t udp_host_dissector_info = {&udp_host_get_filter_type}; + +static int +udpip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + const e_udphdr *udphdr=(const e_udphdr *)vip; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &udphdr->ip_src, udphdr->uh_sport, TRUE, 1, pinfo->fd->pkt_len, &udp_host_dissector_info, PT_UDP); + add_hostlist_table_data(hash, &udphdr->ip_dst, udphdr->uh_dport, FALSE, 1, pinfo->fd->pkt_len, &udp_host_dissector_info, PT_UDP); + + return 1; +} + +static const char* +udpip_hostlist_prefix(void) +{ + return "endpoints"; } /* Attach process info to a flow */ @@ -936,7 +964,7 @@ proto_register_udp(void) &udplite_check_checksum); register_decode_as(&udp_da); - register_conversation_table(proto_udp, FALSE, udpip_conversation_packet); + register_conversation_table(proto_udp, FALSE, udpip_conversation_packet, udpip_hostlist_packet, udpip_hostlist_prefix); register_init_routine(udp_init); diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c index b993793120..6ab86bec49 100644 --- a/epan/dissectors/packet-usb.c +++ b/epan/dissectors/packet-usb.c @@ -1135,6 +1135,30 @@ usb_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, return 1; } +static const char* usb_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter) +{ + if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_USB)) + return "usb.addr"; + + return CONV_FILTER_INVALID; +} + +static hostlist_dissector_info_t usb_host_dissector_info = {&usb_host_get_filter_type}; + +static int +usb_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip _U_) +{ + conv_hash_t *hash = (conv_hash_t*) pit; + + /* Take two "add" passes per packet, adding for each direction, ensures that all + packets are counted properly (even if address is sending to itself) + XXX - this could probably be done more efficiently inside hostlist_table */ + add_hostlist_table_data(hash, &pinfo->src, 0, TRUE, 1, pinfo->fd->pkt_len, &usb_host_dissector_info, PT_NONE); + add_hostlist_table_data(hash, &pinfo->dst, 0, FALSE, 1, pinfo->fd->pkt_len, &usb_host_dissector_info, PT_NONE); + + return 1; +} + /* SETUP dissectors */ @@ -4189,7 +4213,7 @@ proto_register_usb(void) register_decode_as(&usb_product_da); register_decode_as(&usb_device_da); - register_conversation_table(proto_usb, TRUE, usb_conversation_packet); + register_conversation_table(proto_usb, TRUE, usb_conversation_packet, usb_hostlist_packet, NULL); } void @@ -972,7 +972,6 @@ main(int argc, char *argv[]) register_all_plugin_tap_listeners(); #endif register_all_tap_listeners(); - conversation_table_set_gui_info(NULL); * XXX - TODO: Provide GUI function for tfshark * */ /* If invoked with the "-G" flag, we dump out information based on @@ -1201,6 +1201,7 @@ main(int argc, char *argv[]) #endif register_all_tap_listeners(); conversation_table_set_gui_info(init_iousers); + hostlist_table_set_gui_info(NULL); /* XXX - TODO: Provide "GUI" function for TShark */ /* If invoked with the "-G" flag, we dump out information based on the argument to the "-G" flag; if no argument is specified, diff --git a/ui/conversation_ui.h b/ui/conversation_ui.h index b0e02a08d9..fff938cf75 100644 --- a/ui/conversation_ui.h +++ b/ui/conversation_ui.h @@ -49,7 +49,7 @@ typedef enum { CONV_COLUMN_BPS_BA, CONV_NUM_COLUMNS, CONV_INDEX_COLUMN = CONV_NUM_COLUMNS -} column_type_e; +} conversation_column_type_e; extern const char *column_titles[CONV_NUM_COLUMNS]; diff --git a/ui/gtk/CMakeLists.txt b/ui/gtk/CMakeLists.txt index 6f1b9f6079..a97a72e893 100644 --- a/ui/gtk/CMakeLists.txt +++ b/ui/gtk/CMakeLists.txt @@ -142,21 +142,6 @@ set(WIRESHARK_TAP_SRC gtp_stat.c h225_counter.c h225_ras_srt.c - hostlist_eth.c - hostlist_fc.c - hostlist_fddi.c - hostlist_ip.c - hostlist_ipv6.c - hostlist_ipx.c - hostlist_jxta.c - hostlist_ncp.c - hostlist_rsvp.c - hostlist_sctp.c - hostlist_tcpip.c - hostlist_tr.c - hostlist_udpip.c - hostlist_usb.c - hostlist_wlan.c iax2_analysis.c io_stat.c lbm_stream_dlg.c diff --git a/ui/gtk/Makefile.common b/ui/gtk/Makefile.common index 2d644d9009..405ae13c9a 100644 --- a/ui/gtk/Makefile.common +++ b/ui/gtk/Makefile.common @@ -167,21 +167,6 @@ WIRESHARK_TAP_SRC = \ gtp_stat.c \ h225_counter.c \ h225_ras_srt.c \ - hostlist_eth.c \ - hostlist_fc.c \ - hostlist_fddi.c \ - hostlist_ip.c \ - hostlist_ipv6.c \ - hostlist_ipx.c \ - hostlist_jxta.c \ - hostlist_ncp.c \ - hostlist_rsvp.c \ - hostlist_sctp.c \ - hostlist_tcpip.c \ - hostlist_tr.c \ - hostlist_udpip.c \ - hostlist_usb.c \ - hostlist_wlan.c \ iax2_analysis.c \ io_stat.c \ lbm_stream_dlg.c \ diff --git a/ui/gtk/conversations_table.h b/ui/gtk/conversations_table.h index e4062b5327..d1e2ec3fe9 100644 --- a/ui/gtk/conversations_table.h +++ b/ui/gtk/conversations_table.h @@ -55,8 +55,8 @@ typedef struct _conversations_table { /** Init the conversation table for the single conversation window. * + * @param ct the registered conversation * @param filter the optional filter name or NULL - * @param packet_func the function to be called for each incoming packet */ extern void init_conversation_table(struct register_ct* ct, const char *filter); diff --git a/ui/gtk/hostlist_eth.c b/ui/gtk/hostlist_eth.c deleted file mode 100644 index 3785753415..0000000000 --- a/ui/gtk/hostlist_eth.c +++ /dev/null @@ -1,85 +0,0 @@ -/* hostlist_eth.c 2004 Ian Schorr - * modified from endpoint_talkers_eth.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-eth.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_eth_hostlist(void); - -static int -eth_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const eth_hdr *ehdr=(const eth_hdr *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &ehdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_ETHERNET, PT_NONE); - add_hostlist_table_data(hosts, &ehdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_ETHERNET, PT_NONE); - - return 1; -} - - - -static void -gtk_eth_hostlist_init(const char *opt_arg, - void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,eth,",10)){ - filter=opt_arg+10; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "Ethernet", "eth", filter, eth_hostlist_packet); - -} - -void -gtk_eth_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_eth_hostlist_init("hosts,eth",NULL); -} - -void -register_tap_listener_eth_hostlist(void) -{ - register_stat_cmd_arg("hosts,eth", gtk_eth_hostlist_init,NULL); - register_hostlist_table(TRUE, "Ethernet", "eth", NULL /*filter*/, eth_hostlist_packet); -} diff --git a/ui/gtk/hostlist_fc.c b/ui/gtk/hostlist_fc.c deleted file mode 100644 index 401681b57c..0000000000 --- a/ui/gtk/hostlist_fc.c +++ /dev/null @@ -1,85 +0,0 @@ -/* hostlist_fc.c 2004 Ian Schorr - * modified from endpoint_talkers_fc.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/conversation.h> -#include <epan/dissectors/packet-fc.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_fc_hostlist(void); - -static int -fc_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const fc_hdr *fchdr=(const fc_hdr *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &fchdr->s_id, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_FIBRE_CHANNEL, PT_NONE); - add_hostlist_table_data(hosts, &fchdr->d_id, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_FIBRE_CHANNEL, PT_NONE); - - return 1; -} - - - -static void -gtk_fc_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,fc,",9)){ - filter=opt_arg+9; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "Fibre Channel", "fc", filter, fc_hostlist_packet); - -} - -void -gtk_fc_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_fc_hostlist_init("hosts,fc",NULL); -} - -void -register_tap_listener_fc_hostlist(void) -{ - register_stat_cmd_arg("hosts,fc", gtk_fc_hostlist_init,NULL); - register_hostlist_table(TRUE, "Fibre Channel", "fc", NULL /*filter*/, fc_hostlist_packet); -} diff --git a/ui/gtk/hostlist_fddi.c b/ui/gtk/hostlist_fddi.c deleted file mode 100644 index f93c9881c5..0000000000 --- a/ui/gtk/hostlist_fddi.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hostlist_fddi.c 2004 Ian Schorr - * modified from endpoint_talkers_fddi.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-fddi.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_fddi_hostlist(void); - -static int -fddi_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const fddi_hdr *ehdr=(const fddi_hdr *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &ehdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_FDDI, PT_NONE); - add_hostlist_table_data(hosts, &ehdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_FDDI, PT_NONE); - - return 1; -} - - - -static void -gtk_fddi_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,fddi,",11)){ - filter=opt_arg+11; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "FDDI", "fddi", filter, fddi_hostlist_packet); - -} - -void -gtk_fddi_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_fddi_hostlist_init("hosts,fddi",NULL); -} - -void -register_tap_listener_fddi_hostlist(void) -{ - register_stat_cmd_arg("hosts,fddi", gtk_fddi_hostlist_init,NULL); - register_hostlist_table(TRUE, "FDDI", "fddi", NULL /*filter*/, fddi_hostlist_packet); -} diff --git a/ui/gtk/hostlist_ip.c b/ui/gtk/hostlist_ip.c deleted file mode 100644 index 2b2ac5ee55..0000000000 --- a/ui/gtk/hostlist_ip.c +++ /dev/null @@ -1,83 +0,0 @@ -/* hostlist_ip.c 2004 Ian Schorr - * modified from endpoint_talkers_ip.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-ip.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_ip_hostlist(void); - -static int -ip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const ws_ip *iph=(const ws_ip *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &iph->ip_src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPV4, PT_NONE); - add_hostlist_table_data(hosts, &iph->ip_dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPV4, PT_NONE); - return 1; -} - -static void -gtk_ip_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,ip,",9)){ - filter=opt_arg+9; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "IPv4", "ip", filter, ip_hostlist_packet); - -} - -void -gtk_ip_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_ip_hostlist_init("hosts,ip",NULL); -} - -void -register_tap_listener_ip_hostlist(void) -{ - register_stat_cmd_arg("hosts,ip", gtk_ip_hostlist_init,NULL); - register_hostlist_table(TRUE, "IPv4", "ip", NULL /*filter*/, ip_hostlist_packet); -} diff --git a/ui/gtk/hostlist_ipv6.c b/ui/gtk/hostlist_ipv6.c deleted file mode 100644 index b292479f98..0000000000 --- a/ui/gtk/hostlist_ipv6.c +++ /dev/null @@ -1,88 +0,0 @@ -/* hostlist_ipv6.c 2009 Clif Bratcher - * Modified from hostlist_ip.c 2004 Ian Schorr - * modified from endpoint_talkers_ip.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-ipv6.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_ipv6_hostlist(void); - -static int -ipv6_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts = (hostlist_table *)pit; - const struct ip6_hdr *ip6h = (const struct ip6_hdr *)vip; - address src; - address dst; - - /* Addresses aren't implemented as 'address' type in struct ip6_hdr */ - SET_ADDRESS(&src, AT_IPv6, sizeof(struct e_in6_addr), &ip6h->ip6_src); - SET_ADDRESS(&dst, AT_IPv6, sizeof(struct e_in6_addr), &ip6h->ip6_dst); - - add_hostlist_table_data(hosts, &src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPV6, PT_NONE); - add_hostlist_table_data(hosts, &dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPV6, PT_NONE); - - return 1; -} - - -static void -gtk_ipv6_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,ipv6,",10)){ - filter = opt_arg + 10; - } else { - filter = NULL; - } - - init_hostlist_table(TRUE, "IPv6", "ipv6", filter, ipv6_hostlist_packet); -} - -void -gtk_ipv6_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_ipv6_hostlist_init("hosts,ipv6", NULL); -} - -void -register_tap_listener_ipv6_hostlist(void) -{ - register_stat_cmd_arg("hosts,ipv6", gtk_ipv6_hostlist_init, NULL); - register_hostlist_table(TRUE, "IPv6", "ipv6", NULL /*filter*/, ipv6_hostlist_packet); -} diff --git a/ui/gtk/hostlist_ipx.c b/ui/gtk/hostlist_ipx.c deleted file mode 100644 index d93acc8510..0000000000 --- a/ui/gtk/hostlist_ipx.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hostlist_ipx.c 2004 Ian Schorr - * modified from endpoint_talkers_ipx.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-ipx.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_ipx_hostlist(void); - -static int -ipx_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const ipxhdr_t *ipxh=(const ipxhdr_t *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &ipxh->ipx_src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPX, PT_NONE); - add_hostlist_table_data(hosts, &ipxh->ipx_dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_IPX, PT_NONE); - - return 1; -} - - - -static void -gtk_ipx_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,ipx,",10)){ - filter=opt_arg+10; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "IPX", "ipx", filter, ipx_hostlist_packet); - -} - -void -gtk_ipx_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_ipx_hostlist_init("hosts,ipx",NULL); -} - -void -register_tap_listener_ipx_hostlist(void) -{ - register_stat_cmd_arg("hosts,ipx", gtk_ipx_hostlist_init,NULL); - register_hostlist_table(TRUE, "IPX", "ipx", NULL /*filter*/, ipx_hostlist_packet); -} diff --git a/ui/gtk/hostlist_jxta.c b/ui/gtk/hostlist_jxta.c deleted file mode 100644 index c3876d95fb..0000000000 --- a/ui/gtk/hostlist_jxta.c +++ /dev/null @@ -1,81 +0,0 @@ -/* hostlist_jxta.c 2005 Mike Duigou - * modified from hostlist_eth.c 2004 Ian Schorr - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-jxta.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_jxta_hostlist(void); - -static int -jxta_hostlist_packet(void *pit, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts = (hostlist_table *) pit; - const jxta_tap_header *jxtahdr = (const jxta_tap_header *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &jxtahdr->src_address, 0, TRUE, 1, jxtahdr->size, CONV_TYPE_JXTA, PT_NONE); - add_hostlist_table_data(hosts, &jxtahdr->dest_address, 0, FALSE, 1, jxtahdr->size, CONV_TYPE_JXTA, PT_NONE); - return 1; -} - -static void -gtk_jxta_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,jxta,",11)){ - filter=opt_arg+11; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "JXTA", "jxta", filter, jxta_hostlist_packet); - -} - -void -gtk_jxta_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_jxta_hostlist_init("hosts,jxta",NULL); -} - -void -register_tap_listener_jxta_hostlist(void) -{ - register_stat_cmd_arg("hosts,jxta", gtk_jxta_hostlist_init,NULL); - register_hostlist_table(TRUE, "JXTA", "jxta", NULL /*filter*/, jxta_hostlist_packet); -} diff --git a/ui/gtk/hostlist_ncp.c b/ui/gtk/hostlist_ncp.c deleted file mode 100644 index 9889890c37..0000000000 --- a/ui/gtk/hostlist_ncp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* hostlist_ncp.c 2006 Greg Morris - * modified from endpoint_talkers_eth.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -/*#include <epan/dissectors/packet-ncp-int.h>*/ - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_ncp_hostlist(void); - -static int -ncp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip _U_) -{ - hostlist_table *hosts=(hostlist_table *)pit; - /*const ncp_common_header *ncphdr=vip;*/ - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &pinfo->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_ETHERNET, PT_NCP); - add_hostlist_table_data(hosts, &pinfo->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_ETHERNET, PT_NCP); - - return 1; -} - -static void -gtk_ncp_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,ncp,",10)){ - filter=opt_arg+10; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "NCP", "ncp", filter, ncp_hostlist_packet); - -} - -void -gtk_ncp_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_ncp_hostlist_init("hosts,ncp",NULL); -} - -void -register_tap_listener_ncp_hostlist(void) -{ - register_stat_cmd_arg("hosts,ncp", gtk_ncp_hostlist_init,NULL); - register_hostlist_table(TRUE, "NCP", "ncp", NULL /*filter*/, ncp_hostlist_packet); -} diff --git a/ui/gtk/hostlist_rsvp.c b/ui/gtk/hostlist_rsvp.c deleted file mode 100644 index d6986a9abb..0000000000 --- a/ui/gtk/hostlist_rsvp.c +++ /dev/null @@ -1,88 +0,0 @@ -/* hostlist_rsvp.c - * hostlist_rsvp.c August 2005, Manu Pathak <mapathak@cisco.com> - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-rsvp.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_rsvp_hostlist(void); - -static int -rsvp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const rsvp_conversation_info *rsvph = (const rsvp_conversation_info *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures - * that all packets are counted properly (even if address is sending to - * itself). XXX - this could probably be done more efficiently inside - * hostlist_table - */ - add_hostlist_table_data(hosts, &rsvph->source, 0, TRUE, 1, - pinfo->fd->pkt_len, CONV_TYPE_RSVP, PT_NONE); - add_hostlist_table_data(hosts, &rsvph->destination, 0, FALSE, 1, - pinfo->fd->pkt_len, CONV_TYPE_RSVP, PT_NONE); - return 1; -} - -static void -gtk_rsvp_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,rsvp,",11)){ - filter=opt_arg+11; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "RSVP", "rsvp", filter, - rsvp_hostlist_packet); - -} - -void -gtk_rsvp_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_rsvp_hostlist_init("hosts,rsvp",NULL); -} - -void -register_tap_listener_rsvp_hostlist(void) -{ - register_stat_cmd_arg("hosts,rsvp", gtk_rsvp_hostlist_init,NULL); - register_hostlist_table(TRUE, "RSVP", "rsvp", NULL /*filter*/, - rsvp_hostlist_packet); -} diff --git a/ui/gtk/hostlist_sctp.c b/ui/gtk/hostlist_sctp.c deleted file mode 100644 index 09ddfbe808..0000000000 --- a/ui/gtk/hostlist_sctp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* hostlist_sctp.c 2008 Stig Bjorlykke - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-sctp.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_sctp_hostlist(void); - -static int -sctp_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const struct _sctp_info *sctphdr=(const struct _sctp_info *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &sctphdr->ip_src, sctphdr->sport, TRUE, 1, - pinfo->fd->pkt_len, CONV_TYPE_SCTP, PT_SCTP); - add_hostlist_table_data(hosts, &sctphdr->ip_dst, sctphdr->dport, FALSE, 1, - pinfo->fd->pkt_len, CONV_TYPE_SCTP, PT_SCTP); - - return 1; -} - -static void -gtk_sctp_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,sctp,",11)){ - filter=opt_arg+11; - } else { - filter=NULL; - } - - init_hostlist_table(FALSE, "SCTP", "sctp", filter, sctp_hostlist_packet); -} - -void -gtk_sctp_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_sctp_hostlist_init("hosts,sctp",NULL); -} - -void -register_tap_listener_sctp_hostlist(void) -{ - register_stat_cmd_arg("hosts,sctp", gtk_sctp_hostlist_init,NULL); - register_hostlist_table(FALSE, "SCTP", "sctp", NULL /*filter*/, sctp_hostlist_packet); -} diff --git a/ui/gtk/hostlist_table.c b/ui/gtk/hostlist_table.c index 3f5a65adfe..b8dfa4424e 100644 --- a/ui/gtk/hostlist_table.c +++ b/ui/gtk/hostlist_table.c @@ -79,105 +79,9 @@ #define COL_STR_LEN 32 -/* convert a port number into a string */ -static char * -hostlist_port_to_str(int port_type_val, guint32 port) -{ - static int i=0; - static gchar *strp, str[4][12]; - gchar *bp; - - switch(port_type_val){ - case PT_TCP: - case PT_UDP: - case PT_SCTP: - i = (i+1)%4; - strp=str[i]; - bp = &strp[11]; - - *bp = 0; - do { - *--bp = (port % 10) +'0'; - } while ((port /= 10) != 0 && bp > strp); - return bp; - } - return NULL; -} - - -#define FN_ANY_ADDRESS 0 -#define FN_ANY_PORT 1 - -/* Given an address (to distinguish between ipv4 and ipv6 for tcp/udp, - a port_type and a name_type (FN_...) - return a string for the filter name. - - Some addresses, like AT_ETHER may actually be any of multiple types - of protocols, either ethernet, tokenring, fddi etc so we must be more - specific there; that's why we need specific_addr_type. -*/ -static const char * -hostlist_get_filter_name(address *addr, int specific_addr_type_val, int port_type_val, int name_type_val) -{ - switch(name_type_val){ - case FN_ANY_ADDRESS: - switch(addr->type){ - case AT_ETHER: - switch(specific_addr_type_val){ - case CONV_TYPE_ETHERNET: - return "eth.addr"; - case CONV_TYPE_WLAN: - return "wlan.addr"; - case CONV_TYPE_FDDI: - return "fddi.addr"; - case CONV_TYPE_TOKEN_RING: - return "tr.addr"; - default: - break; - } - break; - case AT_IPv4: - return "ip.addr"; - case AT_IPv6: - return "ipv6.addr"; - case AT_IPX: - return "ipx.addr"; - case AT_FC: - return "fc.id"; - case AT_URI: - switch(specific_addr_type_val){ - case CONV_TYPE_JXTA: - return "jxta.message.address"; - default: - break; - } - break; - case AT_USB: - return "usb.addr"; - default: - break; - } - break; - case FN_ANY_PORT: - switch(port_type_val){ - case PT_TCP: - return "tcp.port"; - case PT_UDP: - return "udp.port"; - case PT_SCTP: - return "sctp.port"; - } - break; - } - - g_assert_not_reached(); - return NULL; -} - static void -reset_hostlist_table_data(hostlist_table *hosts) +reset_host_table_data(hostlist_table *hosts) { - guint32 i; char *display_name; char title[256]; GString *error_string; @@ -228,26 +132,15 @@ reset_hostlist_table_data(hostlist_table *hosts) gtk_list_store_clear(store); /* delete all hosts */ - for(i=0;i<hosts->num_hosts;i++){ - hostlist_talker_t *host = &g_array_index(hosts->hosts, hostlist_talker_t, i); - g_free((gpointer)host->myaddress.data); - } - - if (hosts->hosts) - g_array_free(hosts->hosts, TRUE); - - if (hosts->hashtable != NULL) - g_hash_table_destroy(hosts->hashtable); - - hosts->hosts=NULL; - hosts->hashtable=NULL; - hosts->num_hosts=0; + reset_hostlist_table_data(&hosts->hash); } static void reset_hostlist_table_data_cb(void *arg) { - reset_hostlist_table_data((hostlist_table *)arg); + conv_hash_t *hash = (conv_hash_t*)arg; + + reset_host_table_data((hostlist_table *)hash->user_data); } static void @@ -255,41 +148,12 @@ hostlist_win_destroy_cb(GtkWindow *win _U_, gpointer data) { hostlist_table *hosts=(hostlist_table *)data; - remove_tap_listener(hosts); + remove_tap_listener(&hosts->hash); - reset_hostlist_table_data(hosts); + reset_host_table_data(hosts); g_free(hosts); } -enum -{ - ADR_COLUMN, - PORT_COLUMN, - PACKETS_COLUMN, - BYTES_COLUMN, - PKT_AB_COLUMN, - BYTES_AB_COLUMN, - PKT_BA_COLUMN, - BYTES_BA_COLUMN, -#ifdef HAVE_GEOIP - GEOIP1_COLUMN, - GEOIP2_COLUMN, - GEOIP3_COLUMN, - GEOIP4_COLUMN, - GEOIP5_COLUMN, - GEOIP6_COLUMN, - GEOIP7_COLUMN, - GEOIP8_COLUMN, - GEOIP9_COLUMN, - GEOIP10_COLUMN, - GEOIP11_COLUMN, - GEOIP12_COLUMN, - GEOIP13_COLUMN, -#endif - INDEX_COLUMN, - N_COLUMNS -}; - static gint hostlist_sort_column(GtkTreeModel *model, GtkTreeIter *a, @@ -303,19 +167,19 @@ hostlist_sort_column(GtkTreeModel *model, hostlist_talker_t *host1 = NULL; hostlist_talker_t *host2 = NULL; - gtk_tree_model_get(model, a, INDEX_COLUMN, &idx1, -1); - gtk_tree_model_get(model, b, INDEX_COLUMN, &idx2, -1); + gtk_tree_model_get(model, a, HOST_INDEX_COLUMN, &idx1, -1); + gtk_tree_model_get(model, b, HOST_INDEX_COLUMN, &idx2, -1); - if (!hl || idx1 >= hl->num_hosts || idx2 >= hl->num_hosts) + if (!hl || idx1 >= hl->hash.conv_array->len || idx2 >= hl->hash.conv_array->len) return 0; - host1 = &g_array_index(hl->hosts, hostlist_talker_t, idx1); - host2 = &g_array_index(hl->hosts, hostlist_talker_t, idx2); + host1 = &g_array_index(hl->hash.conv_array, hostlist_talker_t, idx1); + host2 = &g_array_index(hl->hash.conv_array, hostlist_talker_t, idx2); switch(data_column){ - case 0: /* Address */ + case HOST_ADR_COLUMN: /* Address */ return(CMP_ADDRESS(&host1->myaddress, &host2->myaddress)); - case 1: /* (Port) */ + case HOST_PORT_COLUMN: /* (Port) */ CMP_INT(host1->port, host2->port); #ifdef HAVE_GEOIP default: @@ -349,36 +213,27 @@ hostlist_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint c { guint idx; hostlist_table *hl=(hostlist_table *)callback_data; - char *str = NULL; - char *sport; + char *str; GtkTreeIter iter; GtkTreeModel *model; GtkTreeSelection *sel; - hostlist_talker_t *host = NULL; + hostlist_talker_t *host; sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(hl->table)); if (!gtk_tree_selection_get_selected(sel, &model, &iter)) return; gtk_tree_model_get (model, &iter, - INDEX_COLUMN, &idx, + HOST_INDEX_COLUMN, &idx, -1); - if(idx>= hl->num_hosts){ + if(idx>= hl->hash.conv_array->len){ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "No hostlist selected"); return; } - host = &g_array_index(hl->hosts, hostlist_talker_t, idx); - - sport=hostlist_port_to_str(host->port_type, host->port); + host = &g_array_index(hl->hash.conv_array, hostlist_talker_t, idx); - str = g_strdup_printf("%s==%s%s%s%s%s", - hostlist_get_filter_name(&host->myaddress, host->sat, host->port_type, FN_ANY_ADDRESS), - ep_address_to_str(&host->myaddress), - sport?" && ":"", - sport?hostlist_get_filter_name(&host->myaddress, host->sat, host->port_type, FN_ANY_PORT):"", - sport?"==":"", - sport?sport:""); + str = (char*)get_hostlist_filter(host); apply_selected_filter (callback_action, str); @@ -614,56 +469,32 @@ hostlist_create_popup_menu(hostlist_table *hl) g_signal_connect(hl->table, "button_press_event", G_CALLBACK(hostlist_show_popup_menu_cb), hl); } - -/* Draw/refresh the address field of a single entry at the specified index */ -static void -get_hostlist_table_address(hostlist_table *hl, hostlist_talker_t *host, const char **entries) -{ - char *port; - guint32 pt; - - if (!hl->resolve_names) - entries[0] = ep_address_to_str(&host->myaddress); - else - entries[0] = (char *)ep_address_to_display(&host->myaddress); - - pt = host->port_type; - if(!hl->resolve_names) pt = PT_NONE; - switch(pt) { - case(PT_TCP): - entries[1] = ep_tcp_port_to_display(host->port); - break; - case(PT_UDP): - entries[1] = ep_udp_port_to_display(host->port); - break; - case(PT_SCTP): - entries[1] = ep_sctp_port_to_display(host->port); - break; - default: - port=hostlist_port_to_str(host->port_type, host->port); - entries[1] = port?port:""; - } -} - /* Refresh the address fields of all entries in the list */ static void draw_hostlist_table_addresses(hostlist_table *hl) { - guint32 i; - const char *entries[2]; + guint idx; GtkListStore *store; + GtkTreeIter iter; + gboolean iter_valid; store = GTK_LIST_STORE(gtk_tree_view_get_model(hl->table)); g_object_ref(store); gtk_tree_view_set_model(GTK_TREE_VIEW(hl->table), NULL); + iter_valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); + + while (iter_valid) { + hostlist_talker_t *host; + + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, HOST_INDEX_COLUMN, &idx, -1); + host = &g_array_index(hl->hash.conv_array, hostlist_talker_t, idx); - for(i=0;i<hl->num_hosts;i++){ - hostlist_talker_t *host = &g_array_index(hl->hosts, hostlist_talker_t, i); - get_hostlist_table_address(hl, host, entries); - gtk_list_store_set (store, &host->iter, - ADR_COLUMN, entries[0], - PORT_COLUMN, entries[1], + gtk_list_store_set (store, &iter, + HOST_ADR_COLUMN, get_conversation_address(&host->myaddress, hl->resolve_names), + HOST_PORT_COLUMN, get_conversation_port(host->port, host->ptype, hl->resolve_names), -1); + + iter_valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); } gtk_tree_view_set_model(GTK_TREE_VIEW(hl->table), GTK_TREE_MODEL(store)); g_object_unref(store); @@ -673,22 +504,24 @@ draw_hostlist_table_addresses(hostlist_table *hl) static void draw_hostlist_table_data(hostlist_table *hl) { - guint32 i; + guint idx, new_idx; char title[256]; GtkListStore *store; + GtkTreeIter iter; + gboolean iter_valid; gboolean first = TRUE; if (hl->page_lb) { - if(hl->num_hosts) { - g_snprintf(title, sizeof(title), "%s: %u", hl->name, hl->num_hosts); + if(hl->hash.conv_array && hl->hash.conv_array->len) { + g_snprintf(title, sizeof(title), "%s: %u", hl->name, hl->hash.conv_array->len); } else { g_snprintf(title, sizeof(title), "%s", hl->name); } gtk_label_set_text(GTK_LABEL(hl->page_lb), title); - gtk_widget_set_sensitive(hl->page_lb, hl->num_hosts); + gtk_widget_set_sensitive(hl->page_lb, hl->hash.conv_array && hl->hash.conv_array->len); } else { - if(hl->num_hosts) { - g_snprintf(title, sizeof(title), "%s Endpoints: %u", hl->name, hl->num_hosts); + if(hl->hash.conv_array && hl->hash.conv_array->len) { + g_snprintf(title, sizeof(title), "%s Endpoints: %u", hl->name, hl->hash.conv_array->len); } else { g_snprintf(title, sizeof(title), "%s Endpoints", hl->name); } @@ -696,11 +529,24 @@ draw_hostlist_table_data(hostlist_table *hl) } store = GTK_LIST_STORE(gtk_tree_view_get_model(hl->table)); - for(i=0;i<hl->num_hosts;i++){ - hostlist_talker_t *host = &g_array_index(hl->hosts, hostlist_talker_t, i); + iter_valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); + new_idx = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); + + while (iter_valid || (hl->hash.conv_array && new_idx < hl->hash.conv_array->len)) { + hostlist_talker_t *host; + + if (iter_valid) { + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, HOST_INDEX_COLUMN, &idx, -1); + } else { + idx = new_idx; + new_idx++; + } + host = &g_array_index(hl->hash.conv_array, hostlist_talker_t, idx); - if (!host->modified) + if (!host->modified) { + iter_valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); continue; + } if (first) { g_object_ref(store); @@ -709,8 +555,7 @@ draw_hostlist_table_data(hostlist_table *hl) first = FALSE; } host->modified = FALSE; - if (!host->iter_valid) { - const char *entries[2]; + if (!iter_valid) { #ifdef HAVE_GEOIP char *geoip[NUM_GEOIP_COLS]; guint j; @@ -727,7 +572,7 @@ draw_hostlist_table_data(hostlist_table *hl) column = (GtkTreeViewColumn *)columns->data; title_p = gtk_tree_view_column_get_title(column); id = gtk_tree_view_column_get_sort_column_id(column); - if (title_p[0] != 0 && id >= GEOIP1_COLUMN) { + if (title_p[0] != 0 && id >= HOST_GEOIP1_COLUMN) { gtk_tree_view_column_set_visible(column, TRUE); } columns = g_list_next(columns); @@ -753,33 +598,31 @@ draw_hostlist_table_data(hostlist_table *hl) } #endif /* HAVE_GEOIP */ - get_hostlist_table_address(hl, host, entries); - host->iter_valid = TRUE; - gtk_list_store_insert_with_values( store , &host->iter, G_MAXINT, - ADR_COLUMN, entries[0], - PORT_COLUMN, entries[1], - PACKETS_COLUMN, host->tx_frames+host->rx_frames, - BYTES_COLUMN, host->tx_bytes+host->rx_bytes, - PKT_AB_COLUMN, host->tx_frames, - BYTES_AB_COLUMN, host->tx_bytes, - PKT_BA_COLUMN, host->rx_frames, - BYTES_BA_COLUMN, host->rx_bytes, + gtk_list_store_insert_with_values( store, &iter, G_MAXINT, + HOST_ADR_COLUMN, get_conversation_address(&host->myaddress, hl->resolve_names), + HOST_PORT_COLUMN, get_conversation_port(host->port, host->ptype, hl->resolve_names), + HOST_PACKETS_COLUMN, host->tx_frames+host->rx_frames, + HOST_BYTES_COLUMN, host->tx_bytes+host->rx_bytes, + HOST_PKT_AB_COLUMN, host->tx_frames, + HOST_BYTES_AB_COLUMN, host->tx_bytes, + HOST_PKT_BA_COLUMN, host->rx_frames, + HOST_BYTES_BA_COLUMN, host->rx_bytes, #ifdef HAVE_GEOIP - GEOIP1_COLUMN, geoip[0], - GEOIP2_COLUMN, geoip[1], - GEOIP3_COLUMN, geoip[2], - GEOIP4_COLUMN, geoip[3], - GEOIP5_COLUMN, geoip[4], - GEOIP6_COLUMN, geoip[5], - GEOIP7_COLUMN, geoip[6], - GEOIP8_COLUMN, geoip[7], - GEOIP9_COLUMN, geoip[8], - GEOIP10_COLUMN, geoip[9], - GEOIP11_COLUMN, geoip[10], - GEOIP12_COLUMN, geoip[11], - GEOIP13_COLUMN, geoip[12], + HOST_GEOIP1_COLUMN, geoip[0], + HOST_GEOIP2_COLUMN, geoip[1], + HOST_GEOIP3_COLUMN, geoip[2], + HOST_GEOIP4_COLUMN, geoip[3], + HOST_GEOIP5_COLUMN, geoip[4], + HOST_GEOIP6_COLUMN, geoip[5], + HOST_GEOIP7_COLUMN, geoip[6], + HOST_GEOIP8_COLUMN, geoip[7], + HOST_GEOIP9_COLUMN, geoip[8], + HOST_GEOIP10_COLUMN, geoip[9], + HOST_GEOIP11_COLUMN, geoip[10], + HOST_GEOIP12_COLUMN, geoip[11], + HOST_GEOIP13_COLUMN, geoip[12], #endif - INDEX_COLUMN, i, + HOST_INDEX_COLUMN, idx, -1); #ifdef HAVE_GEOIP @@ -788,18 +631,20 @@ draw_hostlist_table_data(hostlist_table *hl) #endif /* HAVE_GEOIP */ } else { - gtk_list_store_set (store, &host->iter, - PACKETS_COLUMN, host->tx_frames+host->rx_frames, - BYTES_COLUMN, host->tx_bytes+host->rx_bytes, - PKT_AB_COLUMN, host->tx_frames, - BYTES_AB_COLUMN, host->tx_bytes, - PKT_BA_COLUMN, host->rx_frames, - BYTES_BA_COLUMN, host->rx_bytes, + gtk_list_store_set (store, &iter, + HOST_PACKETS_COLUMN, host->tx_frames+host->rx_frames, + HOST_BYTES_COLUMN, host->tx_bytes+host->rx_bytes, + HOST_PKT_AB_COLUMN, host->tx_frames, + HOST_BYTES_AB_COLUMN, host->tx_bytes, + HOST_PKT_BA_COLUMN, host->rx_frames, + HOST_BYTES_BA_COLUMN, host->rx_bytes, -1); } + + iter_valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); } if (!first) { - if (!hl->fixed_col && hl->num_hosts >= 1000) { + if (!hl->fixed_col && hl->hash.conv_array && hl->hash.conv_array->len >= 1000) { /* finding the right size for a column isn't easy * let it run in autosize a little (1000 is arbitrary) * and then switch to fixed width. @@ -816,12 +661,14 @@ draw_hostlist_table_data(hostlist_table *hl) static void draw_hostlist_table_data_cb(void *arg) { - draw_hostlist_table_data((hostlist_table *)arg); + conv_hash_t *hash = (conv_hash_t*)arg; + + draw_hostlist_table_data((hostlist_table *)hash->user_data); } typedef struct { int nb_cols; - gint columns_order[N_COLUMNS]; + gint columns_order[HOST_NUM_COLUMNS]; GString *CSV_str; hostlist_table *talkers; } csv_t; @@ -837,27 +684,27 @@ csv_handle(GtkTreeModel *model, GtkTreePath *path _U_, GtkTreeIter *iter, guint idx; guint64 value; - gtk_tree_model_get(model, iter, INDEX_COLUMN, &idx, -1); + gtk_tree_model_get(model, iter, HOST_INDEX_COLUMN, &idx, -1); for (i=0; i< csv->nb_cols; i++) { if (i) g_string_append(csv->CSV_str, ","); switch(csv->columns_order[i]) { - case ADR_COLUMN: - case PORT_COLUMN: + case HOST_ADR_COLUMN: + case HOST_PORT_COLUMN: gtk_tree_model_get(model, iter, csv->columns_order[i], &table_text, -1); if (table_text) { g_string_append_printf(csv->CSV_str, "\"%s\"", table_text); g_free(table_text); } break; - case PACKETS_COLUMN: - case BYTES_COLUMN: - case PKT_AB_COLUMN: - case BYTES_AB_COLUMN: - case PKT_BA_COLUMN: - case BYTES_BA_COLUMN: + case HOST_PACKETS_COLUMN: + case HOST_BYTES_COLUMN: + case HOST_PKT_AB_COLUMN: + case HOST_BYTES_AB_COLUMN: + case HOST_PKT_BA_COLUMN: + case HOST_BYTES_BA_COLUMN: gtk_tree_model_get(model, iter, csv->columns_order[i], &value, -1); g_string_append_printf(csv->CSV_str, "\"%" G_GINT64_MODIFIER "u\"", value); break; @@ -1176,34 +1023,34 @@ open_as_map_cb(GtkWindow *copy_bt, gpointer data _U_) } #endif /* HAVE_GEOIP */ -static gint default_col_size[N_COLUMNS]; +static gint default_col_size[HOST_NUM_COLUMNS]; static void init_default_col_size(GtkWidget *view) { - default_col_size[ADR_COLUMN] = get_default_col_size(view, "00000000.000000000000"); - default_col_size[PORT_COLUMN] = get_default_col_size(view, "000000"); - default_col_size[PACKETS_COLUMN] = get_default_col_size(view, "00 000 000"); - default_col_size[BYTES_COLUMN] = get_default_col_size(view, "0 000 000 000"); - default_col_size[PKT_AB_COLUMN] = default_col_size[PACKETS_COLUMN]; - default_col_size[PKT_BA_COLUMN] = default_col_size[PACKETS_COLUMN]; - default_col_size[BYTES_AB_COLUMN] = default_col_size[BYTES_COLUMN]; - default_col_size[BYTES_BA_COLUMN] = default_col_size[BYTES_COLUMN]; + default_col_size[HOST_ADR_COLUMN] = get_default_col_size(view, "00000000.000000000000"); + default_col_size[HOST_PORT_COLUMN] = get_default_col_size(view, "000000"); + default_col_size[HOST_PACKETS_COLUMN] = get_default_col_size(view, "00 000 000"); + default_col_size[HOST_BYTES_COLUMN] = get_default_col_size(view, "0 000 000 000"); + default_col_size[HOST_PKT_AB_COLUMN] = default_col_size[HOST_PACKETS_COLUMN]; + default_col_size[HOST_PKT_BA_COLUMN] = default_col_size[HOST_PACKETS_COLUMN]; + default_col_size[HOST_BYTES_AB_COLUMN] = default_col_size[HOST_BYTES_COLUMN]; + default_col_size[HOST_BYTES_BA_COLUMN] = default_col_size[HOST_BYTES_COLUMN]; #ifdef HAVE_GEOIP - default_col_size[GEOIP1_COLUMN] = default_col_size[ADR_COLUMN]; - default_col_size[GEOIP2_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP3_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP4_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP5_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP6_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP7_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP8_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP9_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP10_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP11_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP12_COLUMN] = default_col_size[GEOIP1_COLUMN]; - default_col_size[GEOIP13_COLUMN] = default_col_size[GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP1_COLUMN] = default_col_size[HOST_ADR_COLUMN]; + default_col_size[HOST_GEOIP2_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP3_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP4_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP5_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP6_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP7_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP8_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP9_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP10_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP11_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP12_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; + default_col_size[HOST_GEOIP13_COLUMN] = default_col_size[HOST_GEOIP1_COLUMN]; #endif } @@ -1247,7 +1094,6 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi } hosttable->has_ports=!hide_ports; - hosttable->num_hosts = 0; hosttable->resolve_names=TRUE; hosttable->page_lb = NULL; hosttable->fixed_col = FALSE; @@ -1258,7 +1104,7 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi gtk_box_pack_start(GTK_BOX(vbox), hosttable->name_lb, FALSE, FALSE, 0); /* Create the store */ - store = gtk_list_store_new (N_COLUMNS, /* Total number of columns */ + store = gtk_list_store_new (HOST_NUM_COLUMNS + 1, /* Total number of columns */ G_TYPE_STRING, /* Address */ G_TYPE_STRING, /* Port */ G_TYPE_UINT64, /* Packets */ @@ -1286,6 +1132,7 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi hosttable->scrolled_window=scrolled_window_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(vbox), hosttable->scrolled_window, TRUE, TRUE, 0); + tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); hosttable->table = GTK_TREE_VIEW(tree); sortable = GTK_TREE_SORTABLE(store); @@ -1299,26 +1146,26 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi g_object_set_data(G_OBJECT(store), HOST_PTR_KEY, hosttable); g_object_set_data(G_OBJECT(hosttable->table), HOST_PTR_KEY, hosttable); - for (i = 0; i < N_COLUMNS -1; i++) { + for (i = 0; i < HOST_NUM_COLUMNS; i++) { renderer = gtk_cell_renderer_text_new (); g_object_set(renderer, "ypad", 0, NULL); switch(i) { - case 0: /* address and port */ - case 1: + case HOST_ADR_COLUMN: /* address and port */ + case HOST_PORT_COLUMN: column = gtk_tree_view_column_new_with_attributes (hosttable->default_titles[i], renderer, "text", i, NULL); - if(hide_ports && i == 1){ + if(hide_ports && i == HOST_PORT_COLUMN){ /* hide srcport and dstport if we don't use ports */ gtk_tree_view_column_set_visible(column, FALSE); } gtk_tree_sortable_set_sort_func(sortable, i, hostlist_sort_column, GINT_TO_POINTER(i), NULL); break; - case 2: /* counts */ - case 3: - case 4: - case 5: - case 6: - case 7: /* right align numbers */ + case HOST_PACKETS_COLUMN: /* counts */ + case HOST_BYTES_COLUMN: + case HOST_PKT_AB_COLUMN: + case HOST_BYTES_AB_COLUMN: + case HOST_PKT_BA_COLUMN: + case HOST_BYTES_BA_COLUMN: /* right align numbers */ g_object_set(G_OBJECT(renderer), "xalign", 1.0, NULL); column = gtk_tree_view_column_new_with_attributes (hosttable->default_titles[i], renderer, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, u64_data_func, GINT_TO_POINTER(i), NULL); @@ -1354,15 +1201,14 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi } gtk_container_add(GTK_CONTAINER(hosttable->scrolled_window), (GtkWidget *)hosttable->table); - - hosttable->num_hosts=0; - hosttable->hosts=NULL; - hosttable->hashtable=NULL; - gtk_tree_view_set_rules_hint(hosttable->table, TRUE); gtk_tree_view_set_headers_clickable(hosttable->table, TRUE); gtk_tree_view_set_reorderable (hosttable->table, TRUE); + hosttable->hash.conv_array = NULL; + hosttable->hash.hashtable = NULL; + hosttable->hash.user_data = hosttable; + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(hosttable->table)); gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); @@ -1370,7 +1216,7 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi hostlist_create_popup_menu(hosttable); /* register the tap and rerun the taps on the packet list */ - error_string=register_tap_listener(tap_name, hosttable, filter, 0, reset_hostlist_table_data_cb, packet_func, draw_hostlist_table_data_cb); + error_string=register_tap_listener(tap_name, &hosttable->hash, filter, 0, reset_hostlist_table_data_cb, packet_func, draw_hostlist_table_data_cb); if(error_string){ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); g_string_free(error_string, TRUE); @@ -1382,7 +1228,7 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi void -init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, tap_packet_cb packet_func) +init_hostlist_table(struct register_ct* ct, const char *filter) { hostlist_table *hosttable; char *display_name; @@ -1397,13 +1243,13 @@ init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap #endif window_geometry_t tl_geom; - hosttable=g_new(hostlist_table,1); + hosttable=g_new0(hostlist_table,1); - hosttable->name=table_name; + hosttable->name=proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(ct))); hosttable->filter=filter; hosttable->use_dfilter=FALSE; display_name = cf_get_display_name(&cfile); - g_snprintf(title, sizeof(title), "%s Endpoints: %s", table_name, display_name); + g_snprintf(title, sizeof(title), "%s Endpoints: %s", hosttable->name, display_name); g_free(display_name); hosttable->win = dlg_window_new(title); /* transient_for top_level */ gtk_window_set_destroy_with_parent (GTK_WINDOW(hosttable->win), TRUE); @@ -1415,7 +1261,8 @@ init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap gtk_container_add(GTK_CONTAINER(hosttable->win), vbox); gtk_container_set_border_width(GTK_CONTAINER(vbox), DLG_OUTER_MARGIN); - ret = init_hostlist_table_page(hosttable, vbox, hide_ports, table_name, tap_name, filter, packet_func); + ret = init_hostlist_table_page(hosttable, vbox, get_conversation_hide_ports(ct), hosttable->name, + proto_get_protocol_filter_name(get_conversation_proto_id(ct)), filter, get_hostlist_packet_func(ct)); if(ret == FALSE) { g_free(hosttable); return; @@ -1425,7 +1272,7 @@ init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap /* XXX - maybe we want to have a "Copy as CSV" stock button here? */ /*copy_bt = gtk_button_new_with_label ("Copy content to clipboard as CSV");*/ #ifdef HAVE_GEOIP - if( strstr(table_name, "IPv4") || strstr(table_name, "IPv6") ) { + if( strstr(hosttable->name, "IPv4") || strstr(hosttable->name, "IPv6") ) { bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_COPY, WIRESHARK_STOCK_MAP, GTK_STOCK_HELP, NULL); } else { bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_COPY, GTK_STOCK_HELP, NULL); @@ -1519,15 +1366,14 @@ hostlist_win_destroy_notebook_cb(GtkWindow *win _U_, gpointer data) static hostlist_table * -init_hostlist_notebook_page_cb(gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, - tap_packet_cb packet_func) +init_hostlist_notebook_page_cb(register_ct_t *table, const char *filter) { gboolean ret; GtkWidget *page_vbox; hostlist_table *hosttable; - hosttable=g_new(hostlist_table,1); - hosttable->name=table_name; + hosttable=g_new0(hostlist_table,1); + hosttable->name=proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(table))); hosttable->filter=filter; hosttable->use_dfilter=FALSE; @@ -1535,7 +1381,8 @@ init_hostlist_notebook_page_cb(gboolean hide_ports, const char *table_name, cons hosttable->win = page_vbox; gtk_container_set_border_width(GTK_CONTAINER(page_vbox), 6); - ret = init_hostlist_table_page(hosttable, page_vbox, hide_ports, table_name, tap_name, filter, packet_func); + ret = init_hostlist_table_page(hosttable, page_vbox, get_conversation_hide_ports(table), hosttable->name, + proto_get_protocol_filter_name(get_conversation_proto_id(table)), filter, get_hostlist_packet_func(table)); if(ret == FALSE) { g_free(hosttable); return NULL; @@ -1544,35 +1391,6 @@ init_hostlist_notebook_page_cb(gboolean hide_ports, const char *table_name, cons return hosttable; } - -typedef struct { - gboolean hide_ports; /* hide TCP / UDP port columns */ - const char *table_name; /* GUI output name */ - const char *tap_name; /* internal name */ - const char *filter; /* display filter string (unused) */ - tap_packet_cb packet_func; /* function to be called for new incoming packets */ -} register_hostlist_t; - - -static GSList *registered_hostlist_tables = NULL; - -void -register_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, tap_packet_cb packet_func) -{ - register_hostlist_t *table; - - table = g_new(register_hostlist_t,1); - - table->hide_ports = hide_ports; - table->table_name = table_name; - table->tap_name = tap_name; - table->filter = filter; - table->packet_func = packet_func; - - registered_hostlist_tables = g_slist_append(registered_hostlist_tables, table); -} - - static void hostlist_resolve_toggle_dest(GtkWidget *widget, gpointer data) { @@ -1605,7 +1423,7 @@ hostlist_filter_toggle_dest(GtkWidget *widget, gpointer data) for (page=1; page<=GPOINTER_TO_INT(pages[0]); page++) { hosttable = (hostlist_table *)pages[page]; hosttable->use_dfilter = use_filter; - reset_hostlist_table_data(hosttable); + reset_host_table_data(hosttable); } cf_retap_packets(&cfile); @@ -1614,11 +1432,36 @@ hostlist_filter_toggle_dest(GtkWidget *widget, gpointer data) } } +typedef struct _init_host_page_data { + int page; + void ** pages; + GtkWidget *nb; + GtkWidget *win; +} init_host_page_data; + +static void +init_host_page(gpointer data, gpointer user_data) +{ + register_ct_t *table = (register_ct_t*)data; + init_host_page_data* host_page_data = (init_host_page_data*)user_data; + + hostlist_table *hosttable; + GtkWidget *page_lb; + + hosttable = init_hostlist_notebook_page_cb(table, NULL /*filter*/); + if (hosttable) { + g_object_set_data(G_OBJECT(hosttable->win), HOST_PTR_KEY, hosttable); + page_lb = gtk_label_new(""); + gtk_notebook_append_page(GTK_NOTEBOOK(host_page_data->nb), hosttable->win, page_lb); + hosttable->win = host_page_data->win; + hosttable->page_lb = page_lb; + host_page_data->pages[++host_page_data->page] = hosttable; + } +} void init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_) { - hostlist_table *hosttable; char *display_name; char title[256]; GtkWidget *vbox; @@ -1628,19 +1471,16 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_) GtkWidget *win; GtkWidget *resolv_cb; GtkWidget *filter_cb; - int page; void ** pages; GtkWidget *nb; - GtkWidget *page_lb; - GSList *current_table; - register_hostlist_t *registered; GtkWidget *copy_bt; #ifdef HAVE_GEOIP GtkWidget *map_bt; #endif window_geometry_t tl_geom; + init_host_page_data host_page_iter_data; - pages = (void **)g_malloc(sizeof(void *) * (g_slist_length(registered_hostlist_tables) + 1)); + pages = (void **)g_malloc(sizeof(void *) * (conversation_table_get_num() + 1)); win = dlg_window_new("hostlist"); /* transient_for top_level */ gtk_window_set_destroy_with_parent (GTK_WINDOW(win), TRUE); @@ -1661,25 +1501,14 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_) gtk_box_pack_start(GTK_BOX(vbox), nb, TRUE, TRUE, 0); g_object_set_data(G_OBJECT(nb), NB_PAGES_KEY, pages); - page = 0; + host_page_iter_data.page = 0; + host_page_iter_data.pages = pages; + host_page_iter_data.nb = nb; + host_page_iter_data.win = win; - current_table = registered_hostlist_tables; - while(current_table) { - registered = (register_hostlist_t *)current_table->data; - page_lb = gtk_label_new(""); - hosttable = init_hostlist_notebook_page_cb(registered->hide_ports, registered->table_name, registered->tap_name, - registered->filter, registered->packet_func); - g_object_set_data(G_OBJECT(hosttable->win), HOST_PTR_KEY, hosttable); - gtk_notebook_append_page(GTK_NOTEBOOK(nb), hosttable->win, page_lb); - hosttable->win = win; - hosttable->page_lb = page_lb; - pages[++page] = hosttable; - - current_table = g_slist_next(current_table); - } - - pages[0] = GINT_TO_POINTER(page); + conversation_table_iterate_tables(init_host_page, &host_page_iter_data); + pages[0] = GINT_TO_POINTER(host_page_iter_data.page); hbox = ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DLG_UNRELATED_SPACING, FALSE); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); @@ -1706,18 +1535,20 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_) #endif gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); + /* Close */ close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); window_set_cancel_button(win, close_bt, window_cancel_button_cb); + /* Copy */ copy_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_COPY); gtk_widget_set_tooltip_text(copy_bt, "Copy all statistical values of this page to the clipboard in CSV (Comma Separated Values) format."); g_signal_connect(copy_bt, "clicked", G_CALLBACK(copy_as_csv_cb), NULL); - g_object_set_data(G_OBJECT(copy_bt), HOST_PTR_KEY, pages[page]); + g_object_set_data(G_OBJECT(copy_bt), HOST_PTR_KEY, pages[host_page_iter_data.page]); #ifdef HAVE_GEOIP map_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_MAP); gtk_widget_set_tooltip_text(map_bt, "Show a map of the IP addresses (internet connection required)."); - g_object_set_data(G_OBJECT(map_bt), HOST_PTR_KEY, pages[page]); + g_object_set_data(G_OBJECT(map_bt), HOST_PTR_KEY, pages[host_page_iter_data.page]); g_signal_connect(map_bt, "clicked", G_CALLBACK(open_as_map_cb), NULL); g_signal_connect(nb, "switch-page", G_CALLBACK(ct_nb_map_switch_page_cb), map_bt); gtk_widget_set_sensitive(map_bt, FALSE); @@ -1738,115 +1569,14 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_) gdk_window_raise(gtk_widget_get_window(win)); } -/* - * Compute the hash value for a given address/port pairs if the match - * is to be exact. - */ -typedef struct { - address myaddress; - guint32 port; -} host_key_t; - -static guint -host_hash(gconstpointer v) +void hostlist_endpoint_cb(register_ct_t* table) { - const host_key_t *key = (const host_key_t *)v; - guint hash_val; - - hash_val = 0; - ADD_ADDRESS_TO_HASH(hash_val, &key->myaddress); - hash_val += key->port; - return hash_val; -} + char cmd_str[50]; -/* - * Compare two host keys for an exact match. - */ -static gint -host_match(gconstpointer v, gconstpointer w) -{ - const host_key_t *v1 = (const host_key_t *)v; - const host_key_t *v2 = (const host_key_t *)w; + g_snprintf(cmd_str, 50, "%s,%s", (get_hostlist_prefix_func(table) != NULL) ? get_hostlist_prefix_func(table)() : "host", + proto_get_protocol_filter_name(get_conversation_proto_id(table))); - if (v1->port == v2->port && - ADDRESSES_EQUAL(&v1->myaddress, &v2->myaddress)) { - return 1; - } - /* - * The addresses or the ports don't match. - */ - return 0; -} - -void -add_hostlist_table_data(hostlist_table *hl, const address *addr, guint32 port, gboolean sender, int num_frames, int num_bytes, conversation_type_e conv_type, int port_type_val) -{ - hostlist_talker_t *talker=NULL; - int talker_idx=0; - - /* XXX should be optimized to allocate n extra entries at a time - instead of just one */ - /* if we dont have any entries at all yet */ - if(hl->hosts==NULL){ - hl->hosts=g_array_sized_new(FALSE, FALSE, sizeof(hostlist_talker_t), 10000); - hl->hashtable = g_hash_table_new_full(host_hash, - host_match, /* key_equal_func */ - g_free, /* key_destroy_func */ - NULL); /* value_destroy_func */ - } - else { - /* try to find it among the existing known conversations */ - host_key_t existing_key; - - existing_key.myaddress = *addr; - existing_key.port = port; - talker_idx = GPOINTER_TO_UINT(g_hash_table_lookup(hl->hashtable, &existing_key)); - if (talker_idx) { - talker_idx--; - talker=&g_array_index(hl->hosts, hostlist_talker_t, talker_idx); - } - } - - /* if we still dont know what talker this is it has to be a new one - and we have to allocate it and append it to the end of the list */ - if(talker==NULL){ - host_key_t *new_key; - hostlist_talker_t host; - - COPY_ADDRESS(&host.myaddress, addr); - host.sat=conv_type; - host.port_type=port_type_val; - host.port=port; - host.rx_frames=0; - host.tx_frames=0; - host.rx_bytes=0; - host.tx_bytes=0; - host.iter_valid = FALSE; - host.modified = TRUE; - - g_array_append_val(hl->hosts, host); - talker_idx= hl->num_hosts; - talker=&g_array_index(hl->hosts, hostlist_talker_t, talker_idx); - - /* hl->hosts address is not a constant but address.data is */ - new_key = g_new(host_key_t,1); - SET_ADDRESS(&new_key->myaddress, talker->myaddress.type, talker->myaddress.len, talker->myaddress.data); - new_key->port = port; - g_hash_table_insert(hl->hashtable, new_key, GUINT_TO_POINTER(talker_idx +1)); - hl->num_hosts++; - } - - /* if this is a new talker we need to initialize the struct */ - talker->modified = TRUE; - - /* update the talker struct */ - if( sender ){ - talker->tx_frames+=num_frames; - talker->tx_bytes+=num_bytes; - } else { - talker->rx_frames+=num_frames; - talker->rx_bytes+=num_bytes; - } + dissector_hostlist_init(cmd_str, table); } /* diff --git a/ui/gtk/hostlist_table.h b/ui/gtk/hostlist_table.h index eb1f157662..e7742b8be1 100644 --- a/ui/gtk/hostlist_table.h +++ b/ui/gtk/hostlist_table.h @@ -24,51 +24,42 @@ #ifndef __HOSTLIST_TABLE_H__ #define __HOSTLIST_TABLE_H__ -#include <ui/conversation_ui.h> +#include <epan/conversation_table.h> /** @file * Hostlist definitions. */ -/** Conversation types */ -/* Sort alphabetically by title */ -typedef enum { - CONV_TYPE_ETHERNET, - CONV_TYPE_FIBRE_CHANNEL, - CONV_TYPE_FDDI, - CONV_TYPE_IPV4, - CONV_TYPE_IPV6, - CONV_TYPE_IPX, - CONV_TYPE_JXTA, - CONV_TYPE_NCP, - CONV_TYPE_RSVP, - CONV_TYPE_SCTP, - CONV_TYPE_TCP, - CONV_TYPE_TOKEN_RING, - CONV_TYPE_UDP, - CONV_TYPE_USB, - CONV_TYPE_WLAN, - N_CONV_TYPES -} conversation_type_e; - - -/** Hostlist information */ -typedef struct _hostlist_talker_t { - address myaddress; /**< address */ - conversation_type_e sat; /**< address type */ - guint32 port_type; /**< port_type (e.g. PT_TCP) */ - guint32 port; /**< port */ - - guint64 rx_frames; /**< number of received packets */ - guint64 tx_frames; /**< number of transmitted packets */ - guint64 rx_bytes; /**< number of received bytes */ - guint64 tx_bytes; /**< number of transmitted bytes */ +typedef enum +{ + HOST_ADR_COLUMN, + HOST_PORT_COLUMN, + HOST_PACKETS_COLUMN, + HOST_BYTES_COLUMN, + HOST_PKT_AB_COLUMN, + HOST_BYTES_AB_COLUMN, + HOST_PKT_BA_COLUMN, + HOST_BYTES_BA_COLUMN, +#ifdef HAVE_GEOIP + HOST_GEOIP1_COLUMN, + HOST_GEOIP2_COLUMN, + HOST_GEOIP3_COLUMN, + HOST_GEOIP4_COLUMN, + HOST_GEOIP5_COLUMN, + HOST_GEOIP6_COLUMN, + HOST_GEOIP7_COLUMN, + HOST_GEOIP8_COLUMN, + HOST_GEOIP9_COLUMN, + HOST_GEOIP10_COLUMN, + HOST_GEOIP11_COLUMN, + HOST_GEOIP12_COLUMN, + HOST_GEOIP13_COLUMN, +#endif + HOST_NUM_COLUMNS, + HOST_INDEX_COLUMN = HOST_NUM_COLUMNS +} hostlist_column_type_e; - gboolean modified; /**< new to redraw the row */ - GtkTreeIter iter; - gboolean iter_valid; /**< not a new row */ -} hostlist_talker_t; #define NUM_BUILTIN_COLS 8 #ifdef HAVE_GEOIP @@ -91,33 +82,18 @@ typedef struct _hostlist_table { const char *default_titles[NUM_HOSTLIST_COLS]; /**< Column headers */ GtkWidget *menu; /**< context menu */ gboolean has_ports; /**< table has ports */ - guint32 num_hosts; /**< number of hosts (0 or 1) */ - GArray *hosts; /**< array of host values */ - GHashTable *hashtable; /**< conversations hash table */ - gboolean fixed_col; /**< if switched to fixed column */ + conv_hash_t hash; /**< hostlist hash table */ + gboolean fixed_col; /**< if switched to fixed column */ gboolean resolve_names; /**< resolve address names? */ gboolean geoip_visible; /**< if geoip columns are visible */ } hostlist_table; -/** Register the hostlist table for the multiple hostlist window. - * - * @param hide_ports hide the port columns - * @param table_name the table name to be displayed - * @param tap_name the registered tap name - * @param filter the optional filter name or NULL - * @param packet_func the function to be called for each incoming packet - */ -extern void register_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, tap_packet_cb packet_func); - /** Init the hostlist table for the single hostlist window. * - * @param hide_ports hide the port columns - * @param table_name the table name to be displayed - * @param tap_name the registered tap name + * @param ct the registered hostlist (conversation) * @param filter the optional filter name or NULL - * @param packet_func the function to be called for each incoming packet */ -extern void init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap_name, const char *filter, tap_packet_cb packet_func); +extern void init_hostlist_table(struct register_ct* ct, const char *filter); /** Callback for "Endpoints" statistics item. * @@ -126,18 +102,10 @@ extern void init_hostlist_table(gboolean hide_ports, const char *table_name, con */ extern void init_hostlist_notebook_cb(GtkWidget *w, gpointer d); -/** Add some data to the table. +/** Function called to instantiate the "GTK hostlist display" * - * @param hl the table to add the data to - * @param addr address - * @param port port - * @param sender TRUE, if this is a sender - * @param num_frames number of packets - * @param num_bytes number of bytes - * @param sat address type - * @param port_type the port type (e.g. PT_TCP) + * @param table conversation table to be created */ -void add_hostlist_table_data(hostlist_table *hl, const address *addr, - guint32 port, gboolean sender, int num_frames, int num_bytes, conversation_type_e sat, int port_type); +extern void hostlist_endpoint_cb(register_ct_t* table); #endif /* __HOSTLIST_TABLE_H__ */ diff --git a/ui/gtk/hostlist_tcpip.c b/ui/gtk/hostlist_tcpip.c deleted file mode 100644 index 8f9657b143..0000000000 --- a/ui/gtk/hostlist_tcpip.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hostlist_tcpip.c 2004 Ian Schorr - * modified from endpoint_talkers_tcpip.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-tcp.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_tcpip_hostlist(void); - -static int -tcpip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const struct tcpheader *tcphdr=(const struct tcpheader *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &tcphdr->ip_src, tcphdr->th_sport, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_TCP, PT_TCP); - add_hostlist_table_data(hosts, &tcphdr->ip_dst, tcphdr->th_dport, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_TCP, PT_TCP); - - return 1; -} - - - -static void -gtk_tcpip_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"endpoints,tcp,",14)){ - filter=opt_arg+14; - } else { - filter=NULL; - } - - init_hostlist_table(FALSE, "TCP", "tcp", filter, tcpip_hostlist_packet); - -} - -void -gtk_tcpip_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_tcpip_hostlist_init("endpoints,tcp",NULL); -} - -void -register_tap_listener_tcpip_hostlist(void) -{ - register_stat_cmd_arg("endpoints,tcp", gtk_tcpip_hostlist_init,NULL); - register_hostlist_table(FALSE, "TCP", "tcp", NULL /*filter*/, tcpip_hostlist_packet); -} diff --git a/ui/gtk/hostlist_tr.c b/ui/gtk/hostlist_tr.c deleted file mode 100644 index a42ecdf355..0000000000 --- a/ui/gtk/hostlist_tr.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hostlist_tr.c 2004 Ian Schorr - * modified from endpoint_talkers_tr.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-tr.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_tr_hostlist(void); - -static int -tr_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const tr_hdr *trhdr=(const tr_hdr *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &trhdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_TOKEN_RING, PT_NONE); - add_hostlist_table_data(hosts, &trhdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_TOKEN_RING, PT_NONE); - - return 1; -} - - - -static void -gtk_tr_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,tr,",9)){ - filter=opt_arg+9; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "Token Ring", "tr", filter, tr_hostlist_packet); - -} - -void -gtk_tr_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_tr_hostlist_init("hosts,tr",NULL); -} - -void -register_tap_listener_tr_hostlist(void) -{ - register_stat_cmd_arg("hosts,tr", gtk_tr_hostlist_init,NULL); - register_hostlist_table(TRUE, "Token Ring", "tr", NULL /*filter*/, tr_hostlist_packet); -} diff --git a/ui/gtk/hostlist_udpip.c b/ui/gtk/hostlist_udpip.c deleted file mode 100644 index de72c18904..0000000000 --- a/ui/gtk/hostlist_udpip.c +++ /dev/null @@ -1,84 +0,0 @@ -/* hostlist_udpip.c 2004 Ian Schorr - * modified from endpoint_talkers_udpip.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-udp.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_udpip_hostlist(void); - -static int -udpip_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const e_udphdr *udphdr=(const e_udphdr *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &udphdr->ip_src, udphdr->uh_sport, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_UDP, PT_UDP); - add_hostlist_table_data(hosts, &udphdr->ip_dst, udphdr->uh_dport, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_UDP, PT_UDP); - - return 1; -} - - - -static void -gtk_udpip_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"endpoints,udp,",14)){ - filter=opt_arg+14; - } else { - filter=NULL; - } - - init_hostlist_table(FALSE, "UDP", "udp", filter, udpip_hostlist_packet); - -} - -void -gtk_udpip_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_udpip_hostlist_init("endpoints,udp",NULL); -} - -void -register_tap_listener_udpip_hostlist(void) -{ - register_stat_cmd_arg("endpoints,udp", gtk_udpip_hostlist_init,NULL); - register_hostlist_table(FALSE, "UDP", "udp", NULL /*filter*/, udpip_hostlist_packet); -} diff --git a/ui/gtk/hostlist_usb.c b/ui/gtk/hostlist_usb.c deleted file mode 100644 index abecdb0b18..0000000000 --- a/ui/gtk/hostlist_usb.c +++ /dev/null @@ -1,81 +0,0 @@ -/* hostlist_usb.c 2007 Jon Smirl - * modified from endpoint_talkers_eth.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-usb.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_usb_hostlist(void); - -static int -usb_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip _U_) -{ - hostlist_table *hosts=(hostlist_table *)pit; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &pinfo->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_USB, PT_NONE); - add_hostlist_table_data(hosts, &pinfo->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_USB, PT_NONE); - - return 1; -} - -static void -gtk_usb_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if (!strncmp(opt_arg, "hosts,usb," ,10)) { - filter = opt_arg + 10; - } else { - filter = NULL; - } - - init_hostlist_table(TRUE, "USB", "usb", filter, usb_hostlist_packet); - -} - -void -gtk_usb_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_usb_hostlist_init("hosts,usb", NULL); -} - -void -register_tap_listener_usb_hostlist(void) -{ - register_stat_cmd_arg("hosts,usb", gtk_usb_hostlist_init, NULL); - register_hostlist_table(TRUE, "USB", "usb", NULL /*filter*/, usb_hostlist_packet); -} diff --git a/ui/gtk/hostlist_wlan.c b/ui/gtk/hostlist_wlan.c deleted file mode 100644 index b83b1966f7..0000000000 --- a/ui/gtk/hostlist_wlan.c +++ /dev/null @@ -1,82 +0,0 @@ -/* hostlist_wlan.c 2004 Giles Scott - * modified from endpoint_talkers_eth.c 2003 Ronnie Sahlberg - * - * Wireshark - Network traffic analyzer - * By Gerald Combs <gerald@wireshark.org> - * Copyright 1998 Gerald Combs - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include "epan/packet.h" -#include <epan/stat_cmd_args.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-ieee80211.h> - -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_stat_menu.h" -#include "ui/gtk/hostlist_table.h" - -void register_tap_listener_wlan_hostlist(void); - -static int -wlan_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip) -{ - hostlist_table *hosts=(hostlist_table *)pit; - const wlan_hdr *whdr=(const wlan_hdr *)vip; - - /* Take two "add" passes per packet, adding for each direction, ensures that all - packets are counted properly (even if address is sending to itself) - XXX - this could probably be done more efficiently inside hostlist_table */ - add_hostlist_table_data(hosts, &whdr->src, 0, TRUE, 1, pinfo->fd->pkt_len, CONV_TYPE_WLAN, PT_NONE); - add_hostlist_table_data(hosts, &whdr->dst, 0, FALSE, 1, pinfo->fd->pkt_len, CONV_TYPE_WLAN, PT_NONE); - - return 1; -} - -static void -gtk_wlan_hostlist_init(const char *opt_arg, void* userdata _U_) -{ - const char *filter=NULL; - - if(!strncmp(opt_arg,"hosts,wlan,",11)){ - filter=opt_arg+11; - } else { - filter=NULL; - } - - init_hostlist_table(TRUE, "WLAN", "wlan", filter, wlan_hostlist_packet); - -} - -void -gtk_wlan_hostlist_cb(GtkAction *action _U_, gpointer user_data _U_) -{ - gtk_wlan_hostlist_init("hosts,wlan",NULL); -} - -void -register_tap_listener_wlan_hostlist(void) -{ - register_stat_cmd_arg("hosts,wlan", gtk_wlan_hostlist_init,NULL); - register_hostlist_table(TRUE, "WLAN", "wlan", NULL /*filter*/, wlan_hostlist_packet); -} diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 00facabdff..a057ca7022 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -191,6 +191,7 @@ #include "ui/gtk/packet_list.h" #include "ui/gtk/filter_expression_save_dlg.h" #include "ui/gtk/conversations_table.h" +#include "ui/gtk/hostlist_table.h" #include "ui/gtk/old-gtk-compat.h" @@ -2578,6 +2579,7 @@ main(int argc, char *argv[]) register_all_tap_listeners(); conversation_table_set_gui_info(init_conversation_table); + hostlist_table_set_gui_info(init_hostlist_table); splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win); diff --git a/ui/gtk/main_menubar.c b/ui/gtk/main_menubar.c index d36bc7c51f..fa6cab1bc4 100644 --- a/ui/gtk/main_menubar.c +++ b/ui/gtk/main_menubar.c @@ -1190,21 +1190,7 @@ static const char *ui_desc_menubar = " <placeholder name='Conversations'/>\n" " </menu>\n" " <menu name= 'EndpointListMenu' action='/Statistics/EndpointList'>\n" -" <menuitem name='Ethernet' action='/Statistics/EndpointList/Ethernet'/>\n" -" <menuitem name='FibreChannel' action='/Statistics/EndpointList/FibreChannel'/>\n" -" <menuitem name='FDDI' action='/Statistics/EndpointList/FDDI'/>\n" -" <menuitem name='IP' action='/Statistics/EndpointList/IP'/>\n" -" <menuitem name='IPv6' action='/Statistics/EndpointList/IPv6'/>\n" -" <menuitem name='IPX' action='/Statistics/EndpointList/IPX'/>\n" -" <menuitem name='JXTA' action='/Statistics/EndpointList/JXTA'/>\n" -" <menuitem name='NCP' action='/Statistics/EndpointList/NCP'/>\n" -" <menuitem name='RSVP' action='/Statistics/EndpointList/RSVP'/>\n" -" <menuitem name='SCTP' action='/Statistics/EndpointList/SCTP'/>\n" -" <menuitem name='TCPIP' action='/Statistics/EndpointList/TCPIP'/>\n" -" <menuitem name='TR' action='/Statistics/EndpointList/TR'/>\n" -" <menuitem name='UDPIP' action='/Statistics/EndpointList/UDPIP'/>\n" -" <menuitem name='USB' action='/Statistics/EndpointList/USB'/>\n" -" <menuitem name='WLAN' action='/Statistics/EndpointList/WLAN'/>\n" +" <placeholder name='Endpoints'/>\n" " </menu>\n" " <menu name='ServiceResponseTimeMenu' action='/Statistics/ServiceResponseTime'>\n" " <menuitem name='DCE-RPC' action='/Statistics/ServiceResponseTime/DCE-RPC'/>\n" @@ -1642,21 +1628,6 @@ static const GtkActionEntry main_menu_bar_entries[] = { { "/Statistics/ConversationList", NULL, "_Conversation List", NULL, NULL, NULL }, { "/Statistics/EndpointList", NULL, "_Endpoint List", NULL, NULL, NULL }, - { "/Statistics/EndpointList/Ethernet", WIRESHARK_STOCK_ENDPOINTS, "Ethernet", NULL, NULL, G_CALLBACK(gtk_eth_hostlist_cb) }, - { "/Statistics/EndpointList/FibreChannel", WIRESHARK_STOCK_ENDPOINTS, "Fibre Channel", NULL, NULL, G_CALLBACK(gtk_fc_hostlist_cb) }, - { "/Statistics/EndpointList/FDDI", WIRESHARK_STOCK_ENDPOINTS, "FDDI", NULL, NULL, G_CALLBACK(gtk_fddi_hostlist_cb) }, - { "/Statistics/EndpointList/IP", WIRESHARK_STOCK_ENDPOINTS, "IPv4", NULL, NULL, G_CALLBACK(gtk_ip_hostlist_cb) }, - { "/Statistics/EndpointList/IPv6", WIRESHARK_STOCK_ENDPOINTS, "IPv6", NULL, NULL, G_CALLBACK(gtk_ipv6_hostlist_cb) }, - { "/Statistics/EndpointList/IPX", WIRESHARK_STOCK_ENDPOINTS, "IPX", NULL, NULL, G_CALLBACK(gtk_ipx_hostlist_cb) }, - { "/Statistics/EndpointList/JXTA", WIRESHARK_STOCK_ENDPOINTS, "JXTA", NULL, NULL, G_CALLBACK(gtk_jxta_hostlist_cb) }, - { "/Statistics/EndpointList/NCP", WIRESHARK_STOCK_ENDPOINTS, "NCP", NULL, NULL, G_CALLBACK(gtk_ncp_hostlist_cb) }, - { "/Statistics/EndpointList/RSVP", WIRESHARK_STOCK_ENDPOINTS, "RSVP", NULL, NULL, G_CALLBACK(gtk_rsvp_hostlist_cb) }, - { "/Statistics/EndpointList/SCTP", WIRESHARK_STOCK_ENDPOINTS, "SCTP", NULL, NULL, G_CALLBACK(gtk_sctp_hostlist_cb) }, - { "/Statistics/EndpointList/TCPIP", WIRESHARK_STOCK_ENDPOINTS, "TCP (IPv4 & IPv6)", NULL, NULL, G_CALLBACK(gtk_tcpip_hostlist_cb) }, - { "/Statistics/EndpointList/TR", WIRESHARK_STOCK_ENDPOINTS, "Token Ring", NULL, NULL, G_CALLBACK(gtk_tr_hostlist_cb) }, - { "/Statistics/EndpointList/UDPIP", WIRESHARK_STOCK_ENDPOINTS, "UDP (IPv4 & IPv6)", NULL, NULL, G_CALLBACK(gtk_udpip_hostlist_cb) }, - { "/Statistics/EndpointList/USB", WIRESHARK_STOCK_ENDPOINTS, "USB", NULL, NULL, G_CALLBACK(gtk_usb_hostlist_cb) }, - { "/Statistics/EndpointList/WLAN", WIRESHARK_STOCK_ENDPOINTS, "WLAN", NULL, NULL, G_CALLBACK(gtk_wlan_hostlist_cb) }, { "/Statistics/ServiceResponseTime", NULL, "Service _Response Time", NULL, NULL, NULL }, { "/Statistics/ServiceResponseTime/DCE-RPC", WIRESHARK_STOCK_TIME, "DCE-RPC...", NULL, NULL, G_CALLBACK(gtk_dcerpcstat_cb) }, @@ -3406,6 +3377,70 @@ menu_conversation_list(capture_file *cf) } static void +menu_hostlist_cb(GtkAction *action _U_, gpointer user_data) +{ + register_ct_t *table = (register_ct_t*)user_data; + + hostlist_endpoint_cb(table); +} + +static void +add_hostlist_menuitem(gpointer data, gpointer user_data) +{ + register_ct_t *table = (register_ct_t*)data; + conv_menu_t *conv = (conv_menu_t*)user_data; + gchar *action_name; + GtkAction *action; + + action_name = g_strdup_printf ("hostlist-%u", conv->counter); + /*g_warning("action_name %s, filter_entry->name %s",action_name,filter_entry->name);*/ + action = (GtkAction *)g_object_new (GTK_TYPE_ACTION, + "name", action_name, + "label", proto_get_protocol_short_name(find_protocol_by_id(get_conversation_proto_id(table))), + "sensitive", TRUE, + NULL); + g_signal_connect (action, "activate", + G_CALLBACK (menu_hostlist_cb), table); + gtk_action_group_add_action (conv->action_group, action); + g_object_unref (action); + + gtk_ui_manager_add_ui (ui_manager_main_menubar, conv->merge_id, + "/Menubar/StatisticsMenu/EndpointListMenu/Endpoints", + action_name, + action_name, + GTK_UI_MANAGER_MENUITEM, + FALSE); + g_free(action_name); + conv->counter++; +} + +static void +menu_hostlist_list(capture_file *cf) +{ + GtkWidget *submenu_hostlist; + conv_menu_t conv_data; + + conv_data.merge_id = gtk_ui_manager_new_merge_id (ui_manager_main_menubar); + + conv_data.action_group = gtk_action_group_new ("endpoint-list-group"); + + submenu_hostlist = gtk_ui_manager_get_widget(ui_manager_main_menubar, "/Menubar/StatisticsMenu/EndpointListMenu"); + if(!submenu_hostlist){ + g_warning("add_recent_items: No submenu_conversation_list found, path= /Menubar/StatisticsMenu/EndpointListMenu"); + } + + gtk_ui_manager_insert_action_group (ui_manager_main_menubar, conv_data.action_group, 0); + g_object_set_data (G_OBJECT (ui_manager_main_menubar), + "endpoint-list-merge-id", GUINT_TO_POINTER (conv_data.merge_id)); + + conv_data.cf = cf; + conv_data.counter = 0; + conversation_table_iterate_tables(add_hostlist_menuitem, &conv_data); +} + + + +static void menus_init(void) { GtkActionGroup *packet_list_heading_action_group, *packet_list_action_group, @@ -3669,6 +3704,7 @@ menus_init(void) menu_dissector_filter(&cfile); menu_conversation_list(&cfile); + menu_hostlist_list(&cfile); merge_menu_items(merge_menu_items_list); /* Add external menus and items */ diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index d121b13693..4507920fc2 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -911,6 +911,7 @@ int main(int argc, char *argv[]) register_all_tap_listeners(); conversation_table_set_gui_info(init_conversation_table); + hostlist_table_set_gui_info(NULL); /* XXX - TODO: Provide "GUI" function for Qt */ if (ex_opt_count("read_format") > 0) { in_file_type = open_info_name_to_type(ex_opt_get_next("read_format")); |