aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-11-28 20:51:27 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-11-28 20:51:27 +0000
commit61dc6ad226685f4a056e0d89e6835e74b87bcdfb (patch)
tree80db8a6f740f279a3d1553e7f199661336ac05fe
parent3e92ea7c1f0ac4b2b822d9c2d7f02fcac3510beb (diff)
dumpcap.c doesn't need to link with file.c!
this fortunately removes *a lot* of dependencies and make the resulting binary a lot smaller (and hopefully faster to load :-) some more cleanup (like replacing // by /**/) svn path=/trunk/; revision=16620
-rw-r--r--Makefile.common10
-rw-r--r--capture_loop.c9
-rw-r--r--dumpcap.c111
3 files changed, 35 insertions, 95 deletions
diff --git a/Makefile.common b/Makefile.common
index 9ce0b684ec..e89592ee02 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -204,26 +204,16 @@ randpkt_SOURCES = \
# dumpcap specifics
dumpcap_SOURCES = \
$(PLATFORM_SRC) \
- capture_errs.c \
capture_stop_conditions.c \
- capture_ui_utils.c \
- cfile.c \
clopts_common.c \
conditions.c \
- packet-range.c \
pcap-util.c \
- print.c \
- ps.c \
ringbuffer.c \
util.c \
version_info.c \
- alert_box.c \
capture_opts.c \
capture_loop.c \
dumpcap.c \
- file.c \
- fileset.c \
- merge.c
# this target needed for distribution only
diff --git a/capture_loop.c b/capture_loop.c
index a8e2945b20..2ef66b06d2 100644
--- a/capture_loop.c
+++ b/capture_loop.c
@@ -765,6 +765,7 @@ static int capture_loop_init_filter(loop_data *ld, const gchar * iface, gchar *
pcap_geterr(ld->pcap_h));
/* filter string invalid, did the user tried a display filter? */
+#ifndef DUMPCAP
if (dfilter_compile(cfilter, &rfcode) && rfcode != NULL) {
g_snprintf(errmsg, errmsg_len,
"%sInvalid capture filter: \"%s\"!%s\n"
@@ -779,7 +780,9 @@ static int capture_loop_init_filter(loop_data *ld, const gchar * iface, gchar *
simple_dialog_primary_start(), safe_cfilter,
simple_dialog_primary_end(), safe_cfilter_error_msg);
dfilter_free(rfcode);
- } else {
+ } else
+#endif
+ {
g_snprintf(errmsg, errmsg_len,
"%sInvalid capture filter: \"%s\"!%s\n"
"\n"
@@ -1312,7 +1315,9 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
if(!result || avail > 0) {
/* XXX - doesn't work with dumpcap as a command line tool */
/* as we have no input pipe, need to find a way to circumvent this */
+#ifndef DUMPCAP
ld.go = FALSE;
+#endif
/*g_warning("loop closing");*/
}
}
@@ -1653,6 +1658,7 @@ capture_loop_packet_cb(u_char *user, const struct pcap_pkthdr *phdr,
}
}
+#ifndef DUMPCAP
switch (ld->wtap_linktype) {
case WTAP_ENCAP_ETHERNET:
capture_eth(pd, 0, whdr.caplen, &ld->counts);
@@ -1715,6 +1721,7 @@ capture_loop_packet_cb(u_char *user, const struct pcap_pkthdr *phdr,
pseudo-header to DLT_ATM_RFC1483, with LLC header following;
we might have to implement that at some point. */
}
+#endif
}
#endif /* HAVE_LIBPCAP */
diff --git a/dumpcap.c b/dumpcap.c
index ca515da4f5..3fe2d67743 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -34,29 +34,16 @@
#include <unistd.h>
#endif
-#ifdef NEED_STRERROR_H
-#include "strerror.h"
-#endif
-
#ifdef NEED_GETOPT_H
#include "getopt.h"
#endif
#ifdef _WIN32 /* Needed for console I/O */
-#include <fcntl.h>
#include <conio.h>
#endif
-#include <epan/packet.h>
-#include <epan/strutil.h>
-
-#include "file.h"
-#include "summary.h"
-#include "filters.h"
-#include "color.h"
#include "simple_dialog.h"
#include "ringbuffer.h"
-#include "../ui_util.h"
#include "util.h"
#include "clopts_common.h"
#include "cmdarg_err.h"
@@ -65,6 +52,8 @@
#include <pcap.h>
#include "pcap-util.h"
+#include "capture.h"
+
#ifdef _WIN32
#include "capture-wpcap.h"
#include "capture_wpcap_packet.h"
@@ -75,7 +64,6 @@
-capture_file cfile;
GString *comp_info_str, *runtime_info_str;
gchar *ethereal_path = NULL;
@@ -176,7 +164,7 @@ cmdarg_err_cont(const char *fmt, ...)
#ifdef _WIN32
BOOL WINAPI ConsoleCtrlHandlerRoutine(DWORD dwCtrlType)
{
- //printf("Event: %u", dwCtrlType);
+ /*printf("Event: %u", dwCtrlType);*/
capture_loop_stop();
return TRUE;
@@ -282,13 +270,11 @@ main(int argc, char *argv[])
/* Set the initial values in the capture_opts. This might be overwritten
by preference settings and then again by the command line parameters. */
- capture_opts_init(capture_opts, &cfile);
+ capture_opts_init(capture_opts, NULL);
capture_opts->snaplen = MIN_PACKET_SIZE;
capture_opts->has_ring_num_files = TRUE;
- init_cap_file(&cfile);
-
/* Now get our args */
while ((opt = getopt(argc, argv, optstring)) != -1) {
switch (opt) {
@@ -571,9 +557,9 @@ console_log_handler(const char *log_domain, GLogLevelFlags log_level,
today = localtime(&curr);
#ifdef _WIN32
-// if (prefs.gui_console_open != console_open_never) {
+/* if (prefs.gui_console_open != console_open_never) {*/
create_console();
-// }
+/* }*/
if (has_console) {
/* For some unknown reason, the above doesn't appear to actually cause
anything to be sent to the standard output, so we'll just splat the
@@ -642,7 +628,7 @@ sync_pipe_packet_count_to_parent(int packet_count)
g_snprintf(tmp, sizeof(tmp), "%d", packet_count);
- //g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "sync_pipe_packet_count_to_parent: %s", tmp);
+ /*g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "sync_pipe_packet_count_to_parent: %s", tmp);*/
pipe_write_block(1, SP_PACKET_COUNT, strlen(tmp)+1, tmp);
}
@@ -679,34 +665,12 @@ sync_pipe_drops_to_parent(int drops)
/****************************************************************************************************************/
-/* link dummies */
+/* link "dummies" */
-void main_window_update(void) {}
-
-/* exit the main window */
-void main_window_exit(void)
-{
-// gtk_exit(0);
-}
-/* quit a nested main window */
-void main_window_nested_quit(void)
-{
-// if (gtk_main_level() > 0)
- // gtk_main_quit();
-}
+void main_window_update(void) {}
-/* quit the main window */
-void main_window_quit(void)
-{
- //gtk_main_quit();
-}
-void pipe_input_set_handler(gint source, gpointer user_data, int *child_process, pipe_input_cb_t input_cb)
-{
- /* we don't use a pipe input for */
-assert(0);
-}
void capture_info_create(capture_info *cinfo, gchar *iface) {}
@@ -803,43 +767,22 @@ simple_dialog_format_message(const char *msg)
}
-
-#include "fileset.h"
-
-void fileset_file_opened(const char *fname) {}
-void fileset_file_closed(void) {}
-void fileset_dlg_add_file(fileset_entry *entry) {}
-
-void packet_list_thaw(void) {}
-void packet_list_clear(void) {}
-void packet_list_freeze(void) {}
-void packet_list_select_row(gint row) {}
-void packet_list_moveto_end(void) {}
-gint packet_list_find_row_from_data(gpointer data) { return 1; }
-void packet_list_set_text(gint row, gint column, const gchar *text) {}
-void packet_list_set_cls_time_width(gint column) {}
-void packet_list_set_selected_row(gint row) {}
-gint packet_list_append(const gchar *text[], gpointer data) { return 1; }
-gint packet_list_get_sort_column(void) { return 1; }
-gpointer packet_list_get_row_data(gint row) { return NULL; }
-void packet_list_set_colors(gint row, color_t *fg, color_t *bg) {}
-
-
-#include "progress_dlg.h"
-
-void destroy_progress_dlg(progdlg_t *dlg) {}
-void update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status) {}
-progdlg_t *
-delayed_create_progress_dlg(const gchar *task_title, const gchar *item_title,
- gboolean terminate_is_stop, gboolean *stop_flag,
- const GTimeVal *start_time, gfloat progress) { return NULL; }
-
-void tap_dfilter_dlg_update (void) {}
-
-
-#include "color_filters.h"
-
-color_filter_t * color_filters_colorize_packet(gint row, epan_dissect_t *edt) { return NULL; }
-void color_filters_prime_edt(epan_dissect_t *edt) {}
-gboolean color_filters_used(void) { return FALSE; }
+/*
+ * Find out whether a hostname resolves to an ip or ipv6 address
+ * Return "ip6" if it is IPv6, "ip" otherwise (including the case
+ * that we don't know)
+ */
+const char* host_ip_af(const char *host
+#ifndef HAVE_GETHOSTBYNAME2
+_U_
+#endif
+)
+{
+#ifdef HAVE_GETHOSTBYNAME2
+ struct hostent *h;
+ return (h = gethostbyname2(host, AF_INET6)) && h->h_addrtype == AF_INET6 ? "ip6" : "ip";
+#else
+ return "ip";
+#endif
+}