# Automake file for the EPAN library
# (Ethereal Protocol ANalyzer Library)
#
-# $Id: Makefile.am,v 1.27 2001/09/14 07:33:04 guy Exp $
+# $Id: Makefile.am,v 1.28 2001/11/21 23:16:23 gram Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
osi-utils.h \
packet.c \
packet.h \
- packet_info.c \
packet_info.h \
pint.h \
plugins.c \
ipv4.obj \
osi-utils.obj \
packet.obj \
- packet_info.obj \
plugins.obj \
proto.obj \
resolv.obj \
/* column-utils.c
* Routines for column utilities.
*
- * $Id: column-utils.c,v 1.6 2001/09/14 07:23:33 guy Exp $
+ * $Id: column-utils.c,v 1.7 2001/11/21 23:16:23 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
}
void
-fill_in_columns(frame_data *fd)
+fill_in_columns(frame_data *fd, packet_info *pinfo)
{
int i;
case COL_DEF_SRC:
case COL_RES_SRC: /* COL_DEF_SRC is currently just like COL_RES_SRC */
- col_set_addr(fd, i, &pi.src, TRUE);
+ col_set_addr(fd, i, &pinfo->src, TRUE);
break;
case COL_UNRES_SRC:
- col_set_addr(fd, i, &pi.src, FALSE);
+ col_set_addr(fd, i, &pinfo->src, FALSE);
break;
case COL_DEF_DL_SRC:
case COL_RES_DL_SRC:
- col_set_addr(fd, i, &pi.dl_src, TRUE);
+ col_set_addr(fd, i, &pinfo->dl_src, TRUE);
break;
case COL_UNRES_DL_SRC:
- col_set_addr(fd, i, &pi.dl_src, FALSE);
+ col_set_addr(fd, i, &pinfo->dl_src, FALSE);
break;
case COL_DEF_NET_SRC:
case COL_RES_NET_SRC:
- col_set_addr(fd, i, &pi.net_src, TRUE);
+ col_set_addr(fd, i, &pinfo->net_src, TRUE);
break;
case COL_UNRES_NET_SRC:
- col_set_addr(fd, i, &pi.net_src, FALSE);
+ col_set_addr(fd, i, &pinfo->net_src, FALSE);
break;
case COL_DEF_DST:
case COL_RES_DST: /* COL_DEF_DST is currently just like COL_RES_DST */
- col_set_addr(fd, i, &pi.dst, TRUE);
+ col_set_addr(fd, i, &pinfo->dst, TRUE);
break;
case COL_UNRES_DST:
- col_set_addr(fd, i, &pi.dst, FALSE);
+ col_set_addr(fd, i, &pinfo->dst, FALSE);
break;
case COL_DEF_DL_DST:
case COL_RES_DL_DST:
- col_set_addr(fd, i, &pi.dl_dst, TRUE);
+ col_set_addr(fd, i, &pinfo->dl_dst, TRUE);
break;
case COL_UNRES_DL_DST:
- col_set_addr(fd, i, &pi.dl_dst, FALSE);
+ col_set_addr(fd, i, &pinfo->dl_dst, FALSE);
break;
case COL_DEF_NET_DST:
case COL_RES_NET_DST:
- col_set_addr(fd, i, &pi.net_dst, TRUE);
+ col_set_addr(fd, i, &pinfo->net_dst, TRUE);
break;
case COL_UNRES_NET_DST:
- col_set_addr(fd, i, &pi.net_dst, FALSE);
+ col_set_addr(fd, i, &pinfo->net_dst, FALSE);
break;
case COL_DEF_SRC_PORT:
case COL_RES_SRC_PORT: /* COL_DEF_SRC_PORT is currently just like COL_RES_SRC_PORT */
- col_set_port(fd, i, pi.ptype, pi.srcport, TRUE);
+ col_set_port(fd, i, pinfo->ptype, pinfo->srcport, TRUE);
break;
case COL_UNRES_SRC_PORT:
- col_set_port(fd, i, pi.ptype, pi.srcport, FALSE);
+ col_set_port(fd, i, pinfo->ptype, pinfo->srcport, FALSE);
break;
case COL_DEF_DST_PORT:
case COL_RES_DST_PORT: /* COL_DEF_DST_PORT is currently just like COL_RES_DST_PORT */
- col_set_port(fd, i, pi.ptype, pi.destport, TRUE);
+ col_set_port(fd, i, pinfo->ptype, pinfo->destport, TRUE);
break;
case COL_UNRES_DST_PORT:
- col_set_port(fd, i, pi.ptype, pi.destport, FALSE);
+ col_set_port(fd, i, pinfo->ptype, pinfo->destport, FALSE);
break;
case COL_PROTOCOL: /* currently done by dissectors */
/* column-utils.h
* Definitions for column utility structures and routines
*
- * $Id: column-utils.h,v 1.3 2001/10/31 07:47:26 guy Exp $
+ * $Id: column-utils.h,v 1.4 2001/11/21 23:16:23 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
#include "column_info.h"
#include "frame_data.h"
+#include "packet_info.h"
/* Allocate all the data structures for constructing column data, given
the number of columns. */
extern void col_add_str(frame_data *, gint, const gchar *);
extern void col_append_str(frame_data *, gint, gchar *);
extern void col_set_cls_time(frame_data *, int);
-extern void fill_in_columns(frame_data *);
+extern void fill_in_columns(frame_data *, packet_info *);
#endif /* __COLUMN_UTILS_H__ */
/* epan.h
*
- * $Id: epan.c,v 1.10 2001/04/02 00:38:34 hagbard Exp $
+ * $Id: epan.c,v 1.11 2001/11/21 23:16:23 gram Exp $
*
* Ethereal Protocol Analyzer Library
*
/* XXX - init tree */
edt->tree = tree;
- dissect_packet(&edt->tvb, pseudo_header, data, fd, tree);
+ dissect_packet(edt, pseudo_header, data, fd);
return edt;
}
/* epan.h
*
- * $Id: epan.h,v 1.7 2001/10/21 21:47:58 guy Exp $
+ * $Id: epan.h,v 1.8 2001/11/21 23:16:23 gram Exp $
*
* Ethereal Protocol Analyzer Library
*
#include <glib.h>
+struct _epan_dissect_t;
+
/* XXX - for now */
#include "packet.h"
+#include "packet_info.h"
void epan_init(const char * plugindir, void (register_all_protocols)(void),
void (register_all_handoffs)(void));
* as the structures that the epan_dissect_t contains might have pointers
* to addresses in your byte array.
*/
-typedef struct {
+typedef struct _epan_dissect_t {
tvbuff_t *tvb;
proto_tree *tree;
+ packet_info pi;
} epan_dissect_t;
epan_dissect_t*
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.40 2001/11/21 01:00:37 guy Exp $
+ * $Id: packet.c,v 1.41 2001/11/21 23:16:23 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
/* Creates the top-most tvbuff and calls dissect_frame() */
void
-dissect_packet(tvbuff_t **p_tvb, union wtap_pseudo_header *pseudo_header,
- const u_char *pd, frame_data *fd, proto_tree *tree)
-{
- blank_packetinfo();
-
- pi.fd = fd;
- pi.pseudo_header = pseudo_header;
+dissect_packet(epan_dissect_t *edt, union wtap_pseudo_header *pseudo_header,
+ const u_char *pd, frame_data *fd)
+{
+ edt->pi.dl_src.type = AT_NONE;
+ edt->pi.dl_dst.type = AT_NONE;
+ edt->pi.net_src.type = AT_NONE;
+ edt->pi.net_dst.type = AT_NONE;
+ edt->pi.src.type = AT_NONE;
+ edt->pi.dst.type = AT_NONE;
+ edt->pi.ethertype = 0;
+ edt->pi.ipproto = 0;
+ edt->pi.ipxptype = 0;
+ edt->pi.in_error_pkt = FALSE;
+ edt->pi.ptype = PT_NONE;
+ edt->pi.srcport = 0;
+ edt->pi.destport = 0;
+ edt->pi.current_proto = "<Missing Protocol Name>";
+ edt->pi.p2p_dir = P2P_DIR_UNKNOWN;
+ edt->pi.private_data = NULL;
+
+ edt->pi.fd = fd;
+ edt->pi.pseudo_header = pseudo_header;
col_set_writable(fd, TRUE);
TRY {
- *p_tvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len, "Frame");
+ edt->tvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len, "Frame");
/* Add this tvbuffer into the data_src list */
- fd->data_src = g_slist_append( fd->data_src, *p_tvb);
+ fd->data_src = g_slist_append( fd->data_src, edt->tvb);
}
CATCH(BoundsError) {
g_assert_not_reached();
}
CATCH(ReportedBoundsError) {
if(proto_malformed != -1){
- proto_tree_add_protocol_format(tree, proto_malformed, *p_tvb, 0, 0,
+ proto_tree_add_protocol_format(edt->tree, proto_malformed, edt->tvb, 0, 0,
"[Malformed Frame: Packet Length]" );
}
else {
ENDTRY;
if(frame_handle != NULL)
- call_dissector(frame_handle, *p_tvb, &pi, tree);
+ call_dissector(frame_handle, edt->tvb, &edt->pi, edt->tree);
fd->flags.visited = 1;
}
/* packet.h
* Definitions for packet disassembly structures and routines
*
- * $Id: packet.h,v 1.39 2001/11/20 21:59:18 guy Exp $
+ * $Id: packet.h,v 1.40 2001/11/21 23:16:23 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
#include "frame_data.h"
#include "packet_info.h"
#include "column-utils.h"
+#include "epan.h"
#define hi_nibble(b) (((b) & 0xf0) >> 4)
#define lo_nibble(b) ((b) & 0x0f)
/*
* Dissectors should never modify the packet data.
*/
-extern void dissect_packet(tvbuff_t **p_tvb,
+extern void dissect_packet(struct _epan_dissect_t *edt,
union wtap_pseudo_header *pseudo_header, const u_char *pd,
- frame_data *fd, proto_tree *tree);
+ frame_data *fd);
extern void dissect_data(tvbuff_t *tvb, int, packet_info *pinfo,
proto_tree *tree);
+++ /dev/null
-/* packet_info.c
- * Routines for handling packet information
- *
- * $Id: packet_info.c,v 1.4 2001/11/03 00:58:52 guy 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 <glib.h>
-
-#include "packet_info.h"
-
-void blank_packetinfo(void)
-{
- pi.dl_src.type = AT_NONE;
- pi.dl_dst.type = AT_NONE;
- pi.net_src.type = AT_NONE;
- pi.net_dst.type = AT_NONE;
- pi.src.type = AT_NONE;
- pi.dst.type = AT_NONE;
- pi.ethertype = 0;
- pi.ipproto = 0;
- pi.ipxptype = 0;
- pi.in_error_pkt = FALSE;
- pi.ptype = PT_NONE;
- pi.srcport = 0;
- pi.destport = 0;
- pi.current_proto = "<Missing Protocol Name>";
- pi.p2p_dir = P2P_DIR_UNKNOWN;
- pi.private_data = NULL;
-}
-
-
/* packet_info.h
* Definitions for packet info structures and routines
*
- * $Id: packet_info.h,v 1.10 2001/11/20 22:29:07 guy Exp $
+ * $Id: packet_info.h,v 1.11 2001/11/21 23:16:23 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
void *private_data; /* pointer to data passed from one dissector to another */
} packet_info;
-void blank_packetinfo(void);
-
-extern packet_info pi;
-
#endif /* __PACKET_INFO_H__ */
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.247 2001/11/20 10:37:14 guy Exp $
+ * $Id: file.c,v 1.248 2001/11/21 23:16:21 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
if (protocol_tree != NULL)
proto_tree_free(protocol_tree);
- epan_dissect_free(edt);
if (fdata->flags.passed_dfilter) {
/* This frame passed the display filter, so add it to the clist. */
prevsec = fdata->abs_secs;
prevusec = fdata->abs_usecs;
- fill_in_columns(fdata);
+ fill_in_columns(fdata, &edt->pi);
/* If we haven't yet seen the first frame, this is it.
to the clist, and thus has no row. */
row = -1;
}
+ epan_dissect_free(edt);
fdata->cinfo = NULL;
return row;
}
fdata->cinfo->col_data[i] = fdata->cinfo->col_buf[i];
}
edt = epan_dissect_new(&cf->pseudo_header, cf->pd, fdata, NULL);
- fill_in_columns(fdata);
+ fill_in_columns(fdata, &edt->pi);
cp = &line_buf[0];
line_len = 0;
for (i = 0; i < cf->cinfo.num_cols; i++) {
/* decode_as_dlg.c
*
- * $Id: decode_as_dlg.c,v 1.12 2001/11/04 04:12:03 guy Exp $
+ * $Id: decode_as_dlg.c,v 1.13 2001/11/21 23:16:25 gram Exp $
*
* Routines to modify dissector tables on the fly.
*
if (requested_tcpudp != E_DECODE_UDP) {
if (requested_srcdst != E_DECODE_DPORT)
- decode_change_one_dissector("tcp.port", pi.srcport, clist);
+ decode_change_one_dissector("tcp.port", cfile.edt->pi.srcport, clist);
if (requested_srcdst != E_DECODE_SPORT)
- decode_change_one_dissector("tcp.port", pi.destport, clist);
+ decode_change_one_dissector("tcp.port", cfile.edt->pi.destport, clist);
}
if (requested_tcpudp != E_DECODE_TCP) {
if (requested_srcdst != E_DECODE_DPORT)
- decode_change_one_dissector("udp.port", pi.srcport, clist);
+ decode_change_one_dissector("udp.port", cfile.edt->pi.srcport, clist);
if (requested_srcdst != E_DECODE_SPORT)
- decode_change_one_dissector("udp.port", pi.destport, clist);
+ decode_change_one_dissector("udp.port", cfile.edt->pi.destport, clist);
}
}
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem); /* gtk_widget_show_all() doesn't show this */
- requested_tcpudp = (pi.ipproto == IP_PROTO_TCP) ? E_DECODE_TCP : E_DECODE_UDP;
+ requested_tcpudp = (cfile.edt->pi.ipproto == IP_PROTO_TCP) ? E_DECODE_TCP : E_DECODE_UDP;
gtk_menu_set_active(GTK_MENU(menu), requested_tcpudp == E_DECODE_UDP);
gtk_object_set_data(GTK_OBJECT(page), E_MENU_TCPUDP, menu);
gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu);
optmenu = gtk_option_menu_new();
menu = gtk_menu_new();
- sprintf(tmp, "source (%u)", pi.srcport);
+ sprintf(tmp, "source (%u)", cfile.edt->pi.srcport);
menuitem = gtk_menu_item_new_with_label(tmp);
gtk_object_set_user_data(GTK_OBJECT(menuitem),
GINT_TO_POINTER(E_DECODE_SPORT));
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem); /* gtk_widget_show_all() doesn't show this */
- sprintf(tmp, "destination (%u)", pi.destport);
+ sprintf(tmp, "destination (%u)", cfile.edt->pi.destport);
menuitem = gtk_menu_item_new_with_label(tmp);
gtk_object_set_user_data(GTK_OBJECT(menuitem),
GINT_TO_POINTER(E_DECODE_DPORT));
gtk_object_set_data(GTK_OBJECT(decode_w), E_NOTEBOOK, notebook);
/* Add link level selection page */
- if (pi.ethertype) {
- sprintf(buffer, "Ethertype 0x%04x", pi.ethertype);
- page = decode_add_simple_page(buffer, "Link", "ethertype", pi.ethertype);
+ if (cfile.edt->pi.ethertype) {
+ sprintf(buffer, "Ethertype 0x%04x", cfile.edt->pi.ethertype);
+ page = decode_add_simple_page(buffer, "Link", "ethertype", cfile.edt->pi.ethertype);
label = gtk_label_new("Link");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label);
}
/* Add network selection page */
- if (pi.ipproto) {
- sprintf(buffer, "IP protocol %u", pi.ipproto);
- page = decode_add_simple_page(buffer, "Network", "ip.proto", pi.ipproto);
+ if (cfile.edt->pi.ipproto) {
+ sprintf(buffer, "IP protocol %u", cfile.edt->pi.ipproto);
+ page = decode_add_simple_page(buffer, "Network", "ip.proto", cfile.edt->pi.ipproto);
gtk_object_set_data(GTK_OBJECT(page), E_PAGE_ACTION, decode_network);
label = gtk_label_new("Network");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label);
}
/* Add transport selection page */
- if (decode_as_transport_ok(pi.ipproto)) {
+ if (decode_as_transport_ok(cfile.edt->pi.ipproto)) {
page = decode_add_tcpudp_page();
label = gtk_label_new("Transport");
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), page, label);
gboolean
decode_as_ok(void)
{
- return pi.ethertype || pi.ipproto || decode_as_transport_ok(pi.ipproto);
+ return cfile.edt->pi.ethertype || cfile.edt->pi.ipproto || decode_as_transport_ok(cfile.edt->pi.ipproto);
}
/* follow_dlg.c
*
- * $Id: follow_dlg.c,v 1.13 2001/04/10 12:07:39 gram Exp $
+ * $Id: follow_dlg.c,v 1.14 2001/11/21 23:16:26 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
follow_info_t *follow_info;
/* we got tcp so we can follow */
- if (pi.ipproto != 6) {
+ if (cfile.edt->pi.ipproto != 6) {
simple_dialog(ESD_TYPE_CRIT, NULL,
"Error following stream. Please make\n"
"sure you have a TCP packet selected.");
/* Create a new filter that matches all packets in the TCP stream,
and set the display filter entry accordingly */
reset_tcp_reassembly();
- follow_filter = build_follow_filter(&pi);
+ follow_filter = build_follow_filter(&cfile.edt->pi);
/* Set the display filter entry accordingly */
filter_te = gtk_object_get_data(GTK_OBJECT(w), E_DFILTER_TE_KEY);
/* main.c
*
- * $Id: main.c,v 1.211 2001/11/20 09:07:33 guy Exp $
+ * $Id: main.c,v 1.212 2001/11/21 23:16:26 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
GtkWidget *descend_pm;
} column_arrows;
-packet_info pi;
capture_file cfile;
GtkWidget *top_level, *packet_list, *tree_view, *byte_nb_ptr,
*tv_scrollw, *pkt_scrollw;
static void
packet_list_select_cb(GtkWidget *w, gint row, gint col, gpointer evt) {
- blank_packetinfo();
-
/* Remove the hex display tabbed pages */
while( (gtk_notebook_get_nth_page( GTK_NOTEBOOK(byte_nb_ptr), 0)))
gtk_notebook_remove_page( GTK_NOTEBOOK(byte_nb_ptr), 0);
/* main.h
* Global defines, etc.
*
- * $Id: main.h,v 1.23 2001/10/22 22:59:26 guy Exp $
+ * $Id: main.h,v 1.24 2001/11/21 23:16:26 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
extern GtkStyle *item_style;
void about_ethereal( GtkWidget *, gpointer);
-void blank_packetinfo();
void match_selected_cb( GtkWidget *, gpointer);
void file_quit_cmd_cb(GtkWidget *, gpointer);
void file_print_cmd_cb(GtkWidget *, gpointer);
/* menu.c
* Menu routines
*
- * $Id: menu.c,v 1.55 2001/07/17 05:44:58 hagbard Exp $
+ * $Id: menu.c,v 1.56 2001/11/21 23:16:26 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
set_menu_sensitivity("/Display/Expand All", have_selected_packet);
set_menu_sensitivity("/Display/Show Packet In New Window", have_selected_packet);
set_menu_sensitivity("/Tools/Follow TCP Stream",
- have_selected_packet ? (pi.ipproto == 6) : FALSE);
+ have_selected_packet ? (cfile.edt->pi.ipproto == 6) : FALSE);
set_menu_sensitivity("/Tools/Decode As...",
have_selected_packet && decode_as_ok());
set_menu_sensitivity("/Resolve Name",
* Routines for socks versions 4 &5 packet dissection
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
*
- * $Id: packet-socks.c,v 1.27 2001/10/31 05:59:18 guy Exp $
+ * $Id: packet-socks.c,v 1.28 2001/11/21 23:16:21 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
*ptr = hash_info->udp_remote_port;
- decode_udp_ports( tvb, offset, &pi, tree, pinfo->srcport, pinfo->destport);
+ decode_udp_ports( tvb, offset, pinfo, tree, pinfo->srcport, pinfo->destport);
*ptr = hash_info->udp_port;
/* tethereal.c
*
- * $Id: tethereal.c,v 1.98 2001/11/13 23:55:30 gram Exp $
+ * $Id: tethereal.c,v 1.99 2001/11/21 23:16:21 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
static void wtap_dispatch_cb_print(u_char *, const struct wtap_pkthdr *, long,
union wtap_pseudo_header *, const u_char *);
-packet_info pi;
capture_file cfile;
FILE *data_out_file = NULL;
ts_type timestamp_type = RELATIVE;
}
} else {
/* Just fill in the columns. */
- fill_in_columns(&fdata);
+ fill_in_columns(&fdata, &edt->pi);
/* Now print them. */
for (i = 0; i < cf->cinfo.num_cols; i++) {