X-Git-Url: http://git.samba.org/samba.git/?a=blobdiff_plain;f=tap-sctpchunkstat.c;h=eb2b5e6fb6e01bac1c6b283fbf3c81c0ce93e08c;hb=412a1581bf1e3db77a48b165af500a0d7d8ecfd1;hp=9fb7d114aea8b06325f7063a07b7e6bc57bc34f3;hpb=f13dfe879ee91521554b70b7afb07a3bc0bd0ab8;p=obnox%2Fwireshark%2Fwip.git diff --git a/tap-sctpchunkstat.c b/tap-sctpchunkstat.c index 9fb7d114ae..eb2b5e6fb6 100644 --- a/tap-sctpchunkstat.c +++ b/tap-sctpchunkstat.c @@ -1,11 +1,11 @@ /* tap_sctpchunkstat.c - * SCTP chunk counter for ethereal + * SCTP chunk counter for wireshark * Copyright 2005 Oleg Terletsky * * $Id$ * - * Ethereal - Network traffic analyzer - * By Gerald Combs + * Wireshark - Network traffic analyzer + * By Gerald Combs * Copyright 1998 Gerald Combs * * This program is free software; you can redistribute it and/or @@ -37,10 +37,11 @@ #include "epan/packet_info.h" #include "epan/addr_resolv.h" #include +#include #include "epan/value_string.h" -#include "stat.h" #include "register.h" #include +#include typedef struct sctp_ep { struct sctp_ep* next; @@ -85,10 +86,6 @@ typedef struct _sctpstat_t { #define CHUNK_TYPE_OFFSET 0 #define CHUNK_TYPE(x)(tvb_get_guint8((x), CHUNK_TYPE_OFFSET)) - -extern gchar* address_to_str(const address *); - - static void sctpstat_reset(void *phs) { @@ -96,7 +93,7 @@ sctpstat_reset(void *phs) sctp_ep_t* list = (sctp_ep_t*)sctp_stat->ep_list; sctp_ep_t* tmp = NULL; guint16 chunk_type; - + if(!list) return; @@ -108,7 +105,8 @@ sctpstat_reset(void *phs) } -sctp_ep_t* alloc_sctp_ep(struct _sctp_info *si) +static sctp_ep_t* +alloc_sctp_ep(struct _sctp_info *si) { sctp_ep_t* ep; guint16 chunk_type; @@ -118,7 +116,7 @@ sctp_ep_t* alloc_sctp_ep(struct _sctp_info *si) if (!(ep = g_malloc(sizeof(sctp_ep_t)))) return NULL; - + COPY_ADDRESS(&ep->src,&si->ip_src); COPY_ADDRESS(&ep->dst,&si->ip_dst); ep->sport = si->sport; @@ -130,7 +128,7 @@ sctp_ep_t* alloc_sctp_ep(struct _sctp_info *si) } - + static int sctpstat_packet(void *phs, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *phi) @@ -141,12 +139,12 @@ sctpstat_packet(void *phs, packet_info *pinfo _U_, epan_dissect_t *edt _U_, cons struct _sctp_info *si = (struct _sctp_info *) phi; guint32 tvb_number; guint8 chunk_type; - + if (!hs) return (0); - + hs->number_of_packets++; - + if(!hs->ep_list) { hs->ep_list = alloc_sctp_ep(si); te = hs->ep_list; @@ -173,7 +171,7 @@ sctpstat_packet(void *phs, packet_info *pinfo _U_, epan_dissect_t *edt _U_, cons if(!te) return (0); - + if (si->number_of_tvbs > 0) { chunk_type = CHUNK_TYPE(si->tvb[0]); if ((chunk_type == SCTP_INIT_CHUNK_ID) || @@ -199,11 +197,11 @@ sctpstat_draw(void *phs) printf("---------------------------------------------------------------------------------------------------------------------------------------\n"); printf("| Source IP |PortA| Dest. IP |PortB| DATA | SACK | HBEAT |HBEATACK| INIT | INITACK| COOKIE |COOKIACK| ABORT | ERROR |\n"); printf("---------------------------------------------------------------------------------------------------------------------------------------\n"); - + for(tmp = list ; tmp ; tmp=tmp->next) { printf("|%15s|%5u|%15s|%5u|%8u|%8u|%8u|%8u|%8u|%8u|%8u|%8u|%8u|%8u|\n", - address_to_str(&tmp->src),tmp->sport, - address_to_str(&tmp->dst),tmp->dport, + ep_address_to_str(&tmp->src),tmp->sport, + ep_address_to_str(&tmp->dst),tmp->dport, tmp->chunk_count[SCTP_DATA_CHUNK_ID], tmp->chunk_count[SCTP_SACK_CHUNK_ID], tmp->chunk_count[SCTP_HEARTBEAT_CHUNK_ID], @@ -220,33 +218,29 @@ sctpstat_draw(void *phs) static void -sctpstat_init(const char *optarg) +sctpstat_init(const char *optarg, void* userdata _U_) { sctpstat_t *hs; - const char *filter=NULL; GString *error_string; + hs = g_malloc(sizeof(sctpstat_t)); if(!strncmp(optarg,"sctp,stat,",11)){ - filter=optarg+11; + hs->filter=g_strdup(optarg+11); } else { - filter=""; + hs->filter=NULL; } - - hs = g_malloc(sizeof(sctpstat_t)); - hs->filter=g_malloc(strlen(filter)+1); hs->ep_list = NULL; hs->number_of_packets = 0; - strcpy(hs->filter, filter); sctpstat_reset(hs); - error_string=register_tap_listener("sctp", hs, filter, NULL, sctpstat_packet, sctpstat_draw); + error_string=register_tap_listener("sctp", hs, hs->filter, 0, NULL, sctpstat_packet, sctpstat_draw); if(error_string){ /* error, we failed to attach to the tap. clean up */ g_free(hs->filter); g_free(hs); - fprintf(stderr, "tethereal: Couldn't register sctp,stat tap: %s\n", + fprintf(stderr, "tshark: Couldn't register sctp,stat tap: %s\n", error_string->str); g_string_free(error_string, TRUE); exit(1); @@ -257,5 +251,5 @@ sctpstat_init(const char *optarg) void register_tap_listener_sctpstat(void) { - register_stat_cmd_arg("sctp,stat", sctpstat_init); + register_stat_cmd_arg("sctp,stat", sctpstat_init,NULL); }