Add endpoint talkers support for FDDI to ethereal and tethereal

Welcome FDDI into the endpoint talkers family.

Nobody gets left behind!

svn path=/trunk/; revision=8310
This commit is contained in:
Ronnie Sahlberg 2003-08-29 10:59:12 +00:00
parent 19a99f8a34
commit 4135309cbd
8 changed files with 290 additions and 19 deletions

View File

@ -386,12 +386,13 @@ capture. I<type> specifies for which type of conversation we want to
generate the statistics; currently the supported ones are
"eth" Ethernet
"fc" Fibre Channel addresses
"fddi" FDDI addresses
"ip" IP addresses
"ipx" IPX addresses
"tcp" TCP/IP socket pairs Both IPv4 and IPv6 are supported
"tr" TokenRing
"udp" UDP/IP socket pairs Both IPv4 and IPv6 are supported
"fc" Fibre Channel addresses
If the optional filter string is specified, only those packets that match the
filter will be used in the calculations.

View File

@ -452,6 +452,7 @@ I<type> specifies which type of conversation we want to generate the
statistics for, currently the supported ones are
"eth" Ethernet
"fc" Fibre Channel
"fddi" FDDI
"ip" IP addresses
"ipx" IPX addresses
"tcp" TCP/IP socketpairs Both IPv4 and IPv6 are supported

View File

@ -1,7 +1,7 @@
# Makefile.am
# Automake file for the GTK interface routines for Ethereal
#
# $Id: Makefile.am,v 1.64 2003/08/24 05:38:22 sahlberg Exp $
# $Id: Makefile.am,v 1.65 2003/08/29 10:59:12 sahlberg Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@ -31,6 +31,7 @@ ETHEREAL_TAP_SRC = \
dcerpc_stat.c \
endpoint_talkers_eth.c \
endpoint_talkers_fc.c \
endpoint_talkers_fddi.c \
endpoint_talkers_ip.c \
endpoint_talkers_ipx.c \
endpoint_talkers_tcpip.c \

View File

@ -1,7 +1,7 @@
## Makefile for building ethereal.exe with Microsoft C and nmake
## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
#
# $Id: Makefile.nmake,v 1.49 2003/08/24 05:38:23 sahlberg Exp $
# $Id: Makefile.nmake,v 1.50 2003/08/29 10:59:12 sahlberg Exp $
include ..\config.nmake
@ -23,6 +23,7 @@ ETHEREAL_TAP_SRC = \
dcerpc_stat.c \
endpoint_talkers_eth.c \
endpoint_talkers_fc.c \
endpoint_talkers_fddi.c \
endpoint_talkers_ip.c \
endpoint_talkers_ipx.c \
endpoint_talkers_tcpip.c \

186
gtk/endpoint_talkers_fddi.c Normal file
View File

@ -0,0 +1,186 @@
/* endpoint_talkers_fddi.c
* endpoint_talkers_fddi 2003 Ronnie Sahlberg
*
* $Id: endpoint_talkers_fddi.c,v 1.1 2003/08/29 10:59:12 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#include <gtk/gtk.h>
#include <string.h>
#include "menu.h"
#include "../epan/packet_info.h"
#include "../tap.h"
#include "../register.h"
#include "compat_macros.h"
#include "../simple_dialog.h"
#include "../file.h"
#include "../globals.h"
#include "endpoint_talkers_table.h"
#include "packet-fddi.h"
/* used to keep track of the statistics for one instance of the stats */
typedef struct _fddi_talkers_t {
GtkWidget *win;
endpoints_table talkers;
} fddi_talkers_t;
void protect_thread_critical_region(void);
void unprotect_thread_critical_region(void);
static void
win_destroy_cb(GtkWindow *win _U_, gpointer data)
{
fddi_talkers_t *fddi_talkers=(fddi_talkers_t *)data;
protect_thread_critical_region();
remove_tap_listener(fddi_talkers);
unprotect_thread_critical_region();
reset_ett_table_data(&fddi_talkers->talkers);
g_free(fddi_talkers);
}
static void
fddi_talkers_reset(void *pit)
{
char title[256];
fddi_talkers_t *fddi_talkers=(fddi_talkers_t *)pit;
reset_ett_table_data(&fddi_talkers->talkers);
snprintf(title, 255, "FDDI Talkers: %s", cfile.filename);
gtk_window_set_title(GTK_WINDOW(fddi_talkers->win), title);
}
static void
fddi_talkers_draw(void *pit)
{
fddi_talkers_t *fddi_talkers=(fddi_talkers_t *)pit;
draw_ett_table_data(&fddi_talkers->talkers);
}
static int
fddi_talkers_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, void *vip)
{
fddi_talkers_t *fddi_talkers=(fddi_talkers_t *)pit;
fddi_hdr *ehdr=vip;
add_ett_table_data(&fddi_talkers->talkers, &ehdr->src, &ehdr->dst, 0, 0, 1, pinfo->fd->pkt_len);
return 1;
}
static void
gtk_fddi_talkers_init(char *optarg)
{
char *filter=NULL;
fddi_talkers_t *fddi_talkers;
GtkWidget *vbox;
GtkWidget *label;
GString *error_string;
char title[256];
static char *filter_names[] = {
"fddi.addr",
"fddi.src",
"fddi.dst",
NULL,
NULL,
NULL
};
if(!strncmp(optarg,"talkers,fddi,",13)){
filter=optarg+13;
} else {
filter=NULL;
}
fddi_talkers=g_malloc(sizeof(fddi_talkers_t));
fddi_talkers->win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(fddi_talkers->win), 750, 400);
snprintf(title, 255, "FDDI Talkers: %s", cfile.filename);
gtk_window_set_title(GTK_WINDOW(fddi_talkers->win), title);
SIGNAL_CONNECT(fddi_talkers->win, "destroy", win_destroy_cb, fddi_talkers);
vbox=gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(fddi_talkers->win), vbox);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
gtk_widget_show(vbox);
label=gtk_label_new("FDDI Talkers");
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_widget_show(label);
/* We must display TOP LEVEL Widget before calling init_ett_table() */
gtk_widget_show(fddi_talkers->win);
init_ett_table(&fddi_talkers->talkers, vbox, NULL, filter_names);
error_string=register_tap_listener("fddi", fddi_talkers, filter, fddi_talkers_reset, fddi_talkers_packet, fddi_talkers_draw);
if(error_string){
simple_dialog(ESD_TYPE_WARN, NULL, error_string->str);
g_string_free(error_string, TRUE);
g_free(fddi_talkers);
return;
}
gtk_widget_show_all(fddi_talkers->win);
redissect_packets(&cfile);
}
static void
gtk_fddi_endpoints_cb(GtkWidget *w _U_, gpointer d _U_)
{
gtk_fddi_talkers_init("talkers,fddi");
}
void
register_tap_menu_fddi_talkers(void)
{
register_tap_menu_item("Endpoint Talkers/FDDI", gtk_fddi_endpoints_cb);
}
void
register_tap_listener_fddi_talkers(void)
{
register_ethereal_tap("talkers,fddi", gtk_fddi_talkers_init);
}

View File

@ -3,7 +3,7 @@
*
* Laurent Deniel <laurent.deniel@free.fr>
*
* $Id: packet-fddi.c,v 1.61 2003/06/10 19:34:36 deniel Exp $
* $Id: packet-fddi.c,v 1.62 2003/08/29 10:59:09 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -36,6 +36,7 @@
#include "prefs.h"
#include "packet-fddi.h"
#include "packet-llc.h"
#include "tap.h"
#include <epan/resolv.h>
@ -52,6 +53,8 @@ static int hf_fddi_addr = -1;
static gint ett_fddi = -1;
static gint ett_fddi_fc = -1;
static int fddi_tap = -1;
static gboolean fddi_padding = FALSE;
#define FDDI_PADDING ((fddi_padding) ? 3 : 0)
@ -260,7 +263,6 @@ static void
dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gboolean bitswapped)
{
int fc;
proto_tree *fh_tree = NULL;
proto_item *ti;
gchar *fc_str;
@ -268,12 +270,21 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
static guchar src[6], dst[6];
guchar src_swapped[6], dst_swapped[6];
tvbuff_t *next_tvb;
static fddi_hdr fddihdrs[4];
static int fddihdr_num=0;
fddi_hdr *fddihdr;
fddihdr_num++;
if(fddihdr_num>=4){
fddihdr_num=0;
}
fddihdr=&fddihdrs[fddihdr_num];
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "FDDI");
fc = (int) tvb_get_guint8(tvb, FDDI_P_FC + FDDI_PADDING);
fc_str = fddifc_to_str(fc);
fddihdr->fc = tvb_get_guint8(tvb, FDDI_P_FC + FDDI_PADDING);
fc_str = fddifc_to_str(fddihdr->fc);
if (check_col(pinfo->cinfo, COL_INFO))
col_add_str(pinfo->cinfo, COL_INFO, fc_str);
@ -282,24 +293,24 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
ti = proto_tree_add_protocol_format(tree, proto_fddi, tvb, 0, FDDI_HEADER_SIZE+FDDI_PADDING,
"Fiber Distributed Data Interface, %s", fc_str);
fh_tree = proto_item_add_subtree(ti, ett_fddi);
ti = proto_tree_add_uint_format(fh_tree, hf_fddi_fc, tvb, FDDI_P_FC + FDDI_PADDING, 1, fc,
"Frame Control: 0x%02x (%s)", fc, fc_str);
ti = proto_tree_add_uint_format(fh_tree, hf_fddi_fc, tvb, FDDI_P_FC + FDDI_PADDING, 1, fddihdr->fc,
"Frame Control: 0x%02x (%s)", fddihdr->fc, fc_str);
fc_tree = proto_item_add_subtree(ti, ett_fddi_fc);
proto_tree_add_uint(fc_tree, hf_fddi_fc_clf, tvb, FDDI_P_FC + FDDI_PADDING, 1, fc);
switch (fc & FDDI_FC_CLFF) {
proto_tree_add_uint(fc_tree, hf_fddi_fc_clf, tvb, FDDI_P_FC + FDDI_PADDING, 1, fddihdr->fc);
switch ((fddihdr->fc) & FDDI_FC_CLFF) {
case FDDI_FC_SMT:
proto_tree_add_uint(fc_tree, hf_fddi_fc_smt_subtype, tvb, FDDI_P_FC + FDDI_PADDING, 1, fc);
proto_tree_add_uint(fc_tree, hf_fddi_fc_smt_subtype, tvb, FDDI_P_FC + FDDI_PADDING, 1, fddihdr->fc);
break;
case FDDI_FC_MAC:
if (fc != FDDI_FC_RT)
proto_tree_add_uint(fc_tree, hf_fddi_fc_mac_subtype, tvb, FDDI_P_FC + FDDI_PADDING, 1, fc);
if (fddihdr->fc != FDDI_FC_RT)
proto_tree_add_uint(fc_tree, hf_fddi_fc_mac_subtype, tvb, FDDI_P_FC + FDDI_PADDING, 1, fddihdr->fc);
break;
case FDDI_FC_LLC_ASYNC:
if (!(fc & FDDI_FC_ASYNC_R))
proto_tree_add_uint(fc_tree, hf_fddi_fc_prio, tvb, FDDI_P_FC + FDDI_PADDING, 1, fc);
if (!((fddihdr->fc) & FDDI_FC_ASYNC_R))
proto_tree_add_uint(fc_tree, hf_fddi_fc_prio, tvb, FDDI_P_FC + FDDI_PADDING, 1, fddihdr->fc);
break;
}
}
@ -315,6 +326,7 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
just making "dst" static? */
SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, &dst[0]);
SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, &dst[0]);
SET_ADDRESS(&fddihdr->dst, AT_ETHER, 6, &dst[0]);
if (fh_tree) {
proto_tree_add_ether(fh_tree, hf_fddi_dst, tvb, FDDI_P_DHOST + FDDI_PADDING, 6, dst);
@ -336,6 +348,7 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
just making "src" static? */
SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, &src[0]);
SET_ADDRESS(&pinfo->src, AT_ETHER, 6, &src[0]);
SET_ADDRESS(&fddihdr->src, AT_ETHER, 6, &src[0]);
if (fh_tree) {
proto_tree_add_ether(fh_tree, hf_fddi_src, tvb, FDDI_P_SHOST + FDDI_PADDING, 6, src);
@ -348,7 +361,10 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
next_tvb = tvb_new_subset(tvb, FDDI_HEADER_SIZE + FDDI_PADDING, -1, -1);
switch (fc) {
tap_queue_packet(fddi_tap, pinfo, fddihdr);
switch (fddihdr->fc) {
/* From now, only 802.2 SNAP (Async. LCC frame) is supported */
@ -459,6 +475,7 @@ proto_register_fddi(void)
"captured FDDI packets (useful with e.g. Tru64 UNIX tcpdump)",
&fddi_padding);
fddi_tap = register_tap("fddi");
}
void

View File

@ -1,6 +1,6 @@
/* packet-fddi.h
*
* $Id: packet-fddi.h,v 1.7 2002/08/28 21:00:13 jmayer Exp $
* $Id: packet-fddi.h,v 1.8 2003/08/29 10:59:10 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -24,6 +24,12 @@
#ifndef __PACKET_FDDI_H__
#define __PACKET_FDDI_H__
typedef struct _fddi_hdr {
guint8 fc;
address dst;
address src;
} fddi_hdr;
void capture_fddi(const guchar *, int, packet_counts *);
#endif

View File

@ -1,7 +1,7 @@
/* tap-iousers.c
* iostat 2003 Ronnie Sahlberg
*
* $Id: tap-iousers.c,v 1.12 2003/08/25 00:44:20 guy Exp $
* $Id: tap-iousers.c,v 1.13 2003/08/29 10:59:10 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@ -45,6 +45,7 @@
#include "packet-eth.h"
#include "packet-tr.h"
#include "packet-fc.h"
#include "packet-fddi.h"
#include <string.h>
typedef struct _io_users_t {
@ -354,6 +355,53 @@ iousers_eth_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_,
return 1;
}
static int
iousers_fddi_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_, void *veth)
{
fddi_hdr *ehdr=veth;
address *addr1, *addr2;
io_users_item_t *iui;
if(CMP_ADDRESS(&ehdr->src, &ehdr->dst)<0){
addr1=&ehdr->src;
addr2=&ehdr->dst;
} else {
addr2=&ehdr->src;
addr1=&ehdr->dst;
}
for(iui=iu->items;iui;iui=iui->next){
if((!CMP_ADDRESS(&iui->addr1, addr1))
&&(!CMP_ADDRESS(&iui->addr2, addr2)) ){
break;
}
}
if(!iui){
iui=g_malloc(sizeof(io_users_item_t));
iui->next=iu->items;
iu->items=iui;
COPY_ADDRESS(&iui->addr1, addr1);
iui->name1=strdup(address_to_str(addr1));
COPY_ADDRESS(&iui->addr2, addr2);
iui->name2=strdup(address_to_str(addr2));
iui->frames1=0;
iui->frames2=0;
iui->bytes1=0;
iui->bytes2=0;
}
if(!CMP_ADDRESS(&ehdr->dst,&iui->addr1)){
iui->frames1++;
iui->bytes1+=pinfo->fd->pkt_len;
} else {
iui->frames2++;
iui->bytes2+=pinfo->fd->pkt_len;
}
return 1;
}
static int
iousers_tr_packet(io_users_t *iu, packet_info *pinfo, epan_dissect_t *edt _U_, void *vtr)
{
@ -470,6 +518,15 @@ iousers_init(char *optarg)
tap_type="fc";
tap_type_name="Fibre Channel";
packet_func=iousers_fc_packet;
} else if(!strncmp(optarg,"talkers,fddi",12)){
if(optarg[12]==','){
filter=optarg+13;
} else {
filter=NULL;
}
tap_type="fddi";
tap_type_name="FDDI";
packet_func=iousers_fddi_packet;
} else if(!strncmp(optarg,"talkers,tcp",11)){
if(optarg[11]==','){
filter=optarg+12;
@ -520,6 +577,7 @@ iousers_init(char *optarg)
fprintf(stderr," <type> must be one of\n");
fprintf(stderr," \"eth\"\n");
fprintf(stderr," \"fc\"\n");
fprintf(stderr," \"fddi\"\n");
fprintf(stderr," \"ip\"\n");
fprintf(stderr," \"ipx\"\n");
fprintf(stderr," \"tcp\"\n");