$(ETHEREAL_COMMON_SRC) \
alert_box.c \
capture.c \
+ capture_info.c \
+ capture_loop.c \
capture_opts.c \
capture_sync.c \
- capture_loop.c \
color_filters.c \
file.c \
fileset.c \
ethereal_INCLUDES = \
alert_box.h \
capture.h \
+ capture_info.h \
+ capture_loop.h \
capture_opts.h \
capture_sync.h \
- capture_loop.h \
color_filters.h \
filters.h \
g711.h \
version_info.c \
capture_opts.c \
capture_loop.c \
+ capture_info.c \
dumpcap.c
--- /dev/null
+/* capture_info.c
+ * capture info functions
+ *
+ * $Id$
+ *
+ * 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
+
+#ifdef HAVE_LIBPCAP
+
+#include <glib.h>
+
+#include <epan/packet.h>
+/* XXX - try to remove this later */
+#include <epan/prefs.h>
+/* XXX - try to remove this later */
+
+#include "capture_info.h"
+
+#include <epan/dissectors/packet-ap1394.h>
+#include <epan/dissectors/packet-atalk.h>
+#include <epan/dissectors/packet-atm.h>
+#include <epan/dissectors/packet-clip.h>
+#include <epan/dissectors/packet-eth.h>
+#include <epan/dissectors/packet-fddi.h>
+#include <epan/dissectors/packet-fr.h>
+#include <epan/dissectors/packet-null.h>
+#include <epan/dissectors/packet-ppp.h>
+#include <epan/dissectors/packet-raw.h>
+#include <epan/dissectors/packet-sll.h>
+#include <epan/dissectors/packet-tr.h>
+#include <epan/dissectors/packet-ieee80211.h>
+#include <epan/dissectors/packet-chdlc.h>
+#include <epan/dissectors/packet-prism.h>
+#include <epan/dissectors/packet-ipfc.h>
+#include <epan/dissectors/packet-arcnet.h>
+
+
+void
+capture_info_init(packet_counts *counts)
+{
+ counts->total = 0;
+ counts->sctp = 0;
+ counts->tcp = 0;
+ counts->udp = 0;
+ counts->icmp = 0;
+ counts->ospf = 0;
+ counts->gre = 0;
+ counts->ipx = 0;
+ counts->netbios = 0;
+ counts->vines = 0;
+ counts->other = 0;
+ counts->arp = 0;
+}
+
+
+void
+capture_info_packet(packet_counts *counts, gint wtap_linktype, const u_char *pd, guint32 caplen, union wtap_pseudo_header pseudo_header)
+{
+ counts->total++;
+ switch (wtap_linktype) {
+ case WTAP_ENCAP_ETHERNET:
+ capture_eth(pd, 0, caplen, counts);
+ break;
+ case WTAP_ENCAP_FDDI:
+ case WTAP_ENCAP_FDDI_BITSWAPPED:
+ capture_fddi(pd, caplen, counts);
+ break;
+ case WTAP_ENCAP_PRISM_HEADER:
+ capture_prism(pd, 0, caplen, counts);
+ break;
+ case WTAP_ENCAP_TOKEN_RING:
+ capture_tr(pd, 0, caplen, counts);
+ break;
+ case WTAP_ENCAP_NULL:
+ capture_null(pd, caplen, counts);
+ break;
+ case WTAP_ENCAP_PPP:
+ capture_ppp_hdlc(pd, 0, caplen, counts);
+ break;
+ case WTAP_ENCAP_RAW_IP:
+ capture_raw(pd, caplen, counts);
+ break;
+ case WTAP_ENCAP_SLL:
+ capture_sll(pd, caplen, counts);
+ break;
+ case WTAP_ENCAP_LINUX_ATM_CLIP:
+ capture_clip(pd, caplen, counts);
+ break;
+ case WTAP_ENCAP_IEEE_802_11:
+ case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
+ capture_ieee80211(pd, 0, caplen, counts);
+ break;
+ case WTAP_ENCAP_CHDLC:
+ capture_chdlc(pd, 0, caplen, counts);
+ break;
+ case WTAP_ENCAP_LOCALTALK:
+ capture_llap(counts);
+ break;
+ case WTAP_ENCAP_ATM_PDUS:
+ capture_atm(&pseudo_header, pd, caplen, counts);
+ break;
+ case WTAP_ENCAP_IP_OVER_FC:
+ capture_ipfc(pd, caplen, counts);
+ break;
+ case WTAP_ENCAP_ARCNET:
+ capture_arcnet(pd, caplen, counts, FALSE, TRUE);
+ break;
+ case WTAP_ENCAP_ARCNET_LINUX:
+ capture_arcnet(pd, caplen, counts, TRUE, FALSE);
+ break;
+ case WTAP_ENCAP_APPLE_IP_OVER_IEEE1394:
+ capture_ap1394(pd, 0, caplen, counts);
+ break;
+ case WTAP_ENCAP_FRELAY:
+ case WTAP_ENCAP_FRELAY_WITH_PHDR:
+ capture_fr(pd, 0, caplen, counts);
+ break;
+ /* XXX - some ATM drivers on FreeBSD might prepend a 4-byte ATM
+ pseudo-header to DLT_ATM_RFC1483, with LLC header following;
+ we might have to implement that at some point. */
+ }
+}
+
+
+#endif /* HAVE_LIBPCAP */
--- /dev/null
+/* capture_info.h
+ * capture info functions
+ *
+ * $Id$
+ *
+ * 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.
+ */
+
+
+/** @file
+ *
+ * capture info functions
+ *
+ */
+
+#ifndef __CAPTURE_INFO_H__
+#define __CAPTURE_INFO_H__
+
+
+extern void capture_info_init(packet_counts *counts);
+
+extern void capture_info_packet(
+packet_counts *counts, gint wtap_linktype, const u_char *pd, guint32 caplen, union wtap_pseudo_header pseudo_header);
+
+
+/** Current Capture info. */
+typedef struct {
+ /* handle */
+ gpointer ui; /**< user interface handle */
+
+ /* capture info */
+ packet_counts *counts; /**< protocol specific counters */
+ time_t running_time; /**< running time since last update */
+ gint new_packets; /**< packets since last update */
+} capture_info;
+
+
+/** Create the capture info dialog */
+extern void capture_info_ui_create(
+capture_info *cinfo,
+gchar *iface);
+
+/** Update the capture info counters in the dialog */
+extern void capture_info_ui_update(
+capture_info *cinfo);
+
+/** Destroy the capture info dialog again */
+extern void capture_info_ui_destroy(
+capture_info *cinfo);
+
+
+#endif /* capture_info.h */
#include <epan/packet.h>
#include "capture.h"
#include "capture_loop.h"
+#include "capture_info.h"
#include "capture_sync.h"
#include "pcap-util.h"
#include "wiretap/wtap.h"
#include "wiretap/wtap-capture.h"
-#include <epan/prefs.h>
/* XXX - try to remove this later */
+#include <epan/prefs.h>
#include "ui_util.h"
/* XXX - try to remove this later */
#include "util.h"
#include "file_util.h"
-#include <epan/dissectors/packet-ap1394.h>
-#include <epan/dissectors/packet-atalk.h>
-#include <epan/dissectors/packet-atm.h>
-#include <epan/dissectors/packet-clip.h>
-#include <epan/dissectors/packet-eth.h>
-#include <epan/dissectors/packet-fddi.h>
-#include <epan/dissectors/packet-fr.h>
-#include <epan/dissectors/packet-null.h>
-#include <epan/dissectors/packet-ppp.h>
-#include <epan/dissectors/packet-raw.h>
-#include <epan/dissectors/packet-sll.h>
-#include <epan/dissectors/packet-tr.h>
-#include <epan/dissectors/packet-ieee80211.h>
-#include <epan/dissectors/packet-chdlc.h>
-#include <epan/dissectors/packet-prism.h>
-#include <epan/dissectors/packet-ipfc.h>
-#include <epan/dissectors/packet-arcnet.h>
-
/*
/* common */
gboolean go; /* TRUE as long as we're supposed to keep capturing */
int err; /* if non-zero, error seen while capturing */
+ gint packets_curr; /* Number of packets we have already captured */
gint packets_max; /* Number of packets we're supposed to capture - 0 means infinite */
gint packets_sync_pipe; /* packets not already send out to the sync_pipe */
packet_counts counts; /* several packet type counters */
cap_pipe_adjust_header(ld, hdr, &rechdr->hdr);
if (rechdr->hdr.incl_len > WTAP_MAX_PACKET_SIZE) {
g_snprintf(errmsg, errmsgl, "Frame %u too long (%d bytes)",
- ld->counts.total+1, rechdr->hdr.incl_len);
+ ld->packets_curr+1, rechdr->hdr.incl_len);
break;
}
ld->cap_pipe_state = STATE_EXPECT_DATA;
/* init the loop data */
ld.go = TRUE;
+ ld.packets_curr = 0;
if (capture_opts->has_autostop_packets)
ld.packets_max = capture_opts->autostop_packets;
else
ld.pcap_err = FALSE;
ld.from_cap_pipe = FALSE;
ld.packets_sync_pipe = 0;
- ld.counts.total = 0;
- ld.counts.sctp = 0;
- ld.counts.tcp = 0;
- ld.counts.udp = 0;
- ld.counts.icmp = 0;
- ld.counts.ospf = 0;
- ld.counts.gre = 0;
- ld.counts.ipx = 0;
- ld.counts.netbios = 0;
- ld.counts.vines = 0;
- ld.counts.other = 0;
- ld.counts.arp = 0;
ld.wtap_pdh = NULL;
#ifndef _WIN32
ld.cap_pipe_fd = -1;
/* start capture info dialog */
if(capture_opts->show_info) {
- capture_ui.callback_data = &ld;
- capture_ui.counts = &ld.counts;
- capture_info_create(&capture_ui, capture_opts->iface);
+ capture_info_init(&ld.counts);
+ capture_ui.counts = &ld.counts;
+ capture_info_ui_create(&capture_ui, capture_opts->iface);
}
/* init the time values */
} /* cnd_autostop_size */
} /* inpkts */
- /* Only update once a second so as not to overload slow displays */
+ /* Only update once a second (Win32: 500ms) so as not to overload slow displays */
cur_time = TIME_GET();
#ifdef _WIN32
if ( (cur_time - upd_time) > 500) {
capture_ui.running_time = cur_time;
#endif
capture_ui.new_packets = ld.packets_sync_pipe;
- capture_info_update(&capture_ui);
+ capture_info_ui_update(&capture_ui);
}
/* Let the parent process know. */
/* close capture info dialog */
if(capture_opts->show_info) {
- capture_info_destroy(&capture_ui);
+ capture_info_ui_destroy(&capture_ui);
}
/* delete stop conditions */
int err;
/* if the user told us to stop after x packets, do we have enough? */
- ld->counts.total++;
- if ((ld->packets_max > 0) && (ld->counts.total >= ld->packets_max))
+ ld->packets_curr++;
+ if ((ld->packets_max > 0) && (ld->packets_curr >= ld->packets_max))
{
ld->go = FALSE;
}
return;
}
- switch (ld->wtap_linktype) {
- case WTAP_ENCAP_ETHERNET:
- capture_eth(pd, 0, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_FDDI:
- case WTAP_ENCAP_FDDI_BITSWAPPED:
- capture_fddi(pd, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_PRISM_HEADER:
- capture_prism(pd, 0, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_TOKEN_RING:
- capture_tr(pd, 0, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_NULL:
- capture_null(pd, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_PPP:
- capture_ppp_hdlc(pd, 0, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_RAW_IP:
- capture_raw(pd, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_SLL:
- capture_sll(pd, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_LINUX_ATM_CLIP:
- capture_clip(pd, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_IEEE_802_11:
- case WTAP_ENCAP_IEEE_802_11_WITH_RADIO:
- capture_ieee80211(pd, 0, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_CHDLC:
- capture_chdlc(pd, 0, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_LOCALTALK:
- capture_llap(&ld->counts);
- break;
- case WTAP_ENCAP_ATM_PDUS:
- capture_atm(&pseudo_header, pd, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_IP_OVER_FC:
- capture_ipfc(pd, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_ARCNET:
- capture_arcnet(pd, whdr.caplen, &ld->counts, FALSE, TRUE);
- break;
- case WTAP_ENCAP_ARCNET_LINUX:
- capture_arcnet(pd, whdr.caplen, &ld->counts, TRUE, FALSE);
- break;
- case WTAP_ENCAP_APPLE_IP_OVER_IEEE1394:
- capture_ap1394(pd, 0, whdr.caplen, &ld->counts);
- break;
- case WTAP_ENCAP_FRELAY:
- case WTAP_ENCAP_FRELAY_WITH_PHDR:
- capture_fr(pd, 0, whdr.caplen, &ld->counts);
- break;
- /* XXX - some ATM drivers on FreeBSD might prepend a 4-byte ATM
- pseudo-header to DLT_ATM_RFC1483, with LLC header following;
- we might have to implement that at some point. */
- }
+ capture_info_packet(&ld->counts, ld->wtap_linktype, pd, whdr.caplen, pseudo_header);
#endif
}
extern void capture_loop_stop(void);
-
-/** Current Capture info. */
-typedef struct {
- /* handles */
- gpointer callback_data; /**< capture callback handle */
- gpointer ui; /**< user interfaces own handle */
-
- /* capture info */
- packet_counts *counts; /**< protocol specific counters */
- time_t running_time; /**< running time since last update */
- gint new_packets; /**< packets since last update */
-} capture_info;
-
-
-/** Create the capture info dialog */
-extern void capture_info_create(
-capture_info *cinfo,
-gchar *iface);
-
-/** Update the capture info counters in the dialog */
-extern void capture_info_update(
-capture_info *cinfo);
-
-/** Destroy the capture info dialog again */
-extern void capture_info_destroy(
-capture_info *cinfo);
-
-
#endif /* capture_loop.h */
#include "capture.h"
#include "capture_loop.h"
+#include "capture_info.h"
#ifdef _WIN32
#include "capture-wpcap.h"
-void capture_info_create(capture_info *cinfo, gchar *iface) {}
+void capture_info_ui_create(capture_info *cinfo, gchar *iface) {}
-void capture_info_update(capture_info *cinfo) {
+void capture_info_ui_update(capture_info *cinfo) {
printf("Packets: %u\r", cinfo->counts->total);
}
-void capture_info_destroy(capture_info *cinfo) {}
+void capture_info_ui_destroy(capture_info *cinfo) {}
static gpointer *
#include <epan/packet.h>
#include "capture.h"
#include "capture_loop.h"
+#include "capture_info.h"
#include "globals.h"
#include "capture_ui_utils.h"
#include "dlg_utils.h"
/* create the capture info dialog */
/* will keep pointers to the fields in the counts parameter */
-void capture_info_create(
+void capture_info_ui_create(
capture_info *cinfo,
gchar *iface)
{
/* update the capture info dialog */
/* As this function is a bit time critical while capturing, */
-/* prepare everything possible in the capture_info_create() function above! */
-void capture_info_update(
+/* prepare everything possible in the capture_info_ui_create() function above! */
+void capture_info_ui_update(
capture_info *cinfo)
{
unsigned int i;
/* destroy the capture info dialog again */
-void capture_info_destroy(
+void capture_info_ui_destroy(
capture_info *cinfo)
{
capture_info_ui_t *info = cinfo->ui;
*
* - "About" about_ethereal_cb()
* - "Capture Options" capture_prep()
- * - "Capture" capture_info_create()
+ * - "Capture" capture_info_ui_create()
* - "Interface Options" ifopts_edit_cb()
* - "Coloring Rules" colorize_dialog_new()
* - "Edit Color Filter" edit_color_filter_dialog_new()