Ethereal-dev: [Ethereal-dev] New name resolving flags (please comment)
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Thu, 3 May 2001 04:08:56 +0200
Hello List, this is a preliminary patch to implement a finer grained name resolution. The idea was triggered by a discussion on the tcpdump-workers list. The problem: ip name resolving are not available, but I still want portnames and manufacturer ids to be resolved. The solution: Add an option -N resolving-flags which overrides -n if present. In this patch I've implemented just 3 flags: m (mac), n (network) and t (transport). In order to resolve everything but ip, you'd type -N mt. What I'm wondering about is whether it would be more helpful to actually do this by protocol (see comment in prefs.h). Also, the current implementation only handles thethereal. ethereal may (or may not) work as before with this patch, at least it compiles. 2do: Decide which approach would be best (if any) and ethereal/gtk support. If you like the patch, is someone willing to do the graphics stuff? The diff also changes the handling of the -R option. Correct or not? Ciao Jörg -- Joerg Mayer <jmayer@xxxxxxxxx> I found out that "pro" means "instead of" (as in proconsul). Now I know what proactive means.
Index: ethereal/prefs.c =================================================================== RCS file: /cvsroot/ethereal/prefs.c,v retrieving revision 1.50 diff -u -u -r1.50 prefs.c --- prefs.c 2001/04/15 03:37:13 1.50 +++ prefs.c 2001/05/03 02:03:23 @@ -615,7 +615,7 @@ prefs.capture_prom_mode = 0; prefs.capture_real_time = 0; prefs.capture_auto_scroll = 0; - prefs.name_resolve= 1; + prefs.name_resolve= PREFS_RESOLV_ALL; } @@ -1011,7 +1011,7 @@ } else if (strcmp(pref_name, PRS_NAME_RESOLVE) == 0 || strcmp(pref_name, PRS_CAP_NAME_RESOLVE) == 0) { - prefs.name_resolve = ((strcmp(value, "TRUE") == 0)?TRUE:FALSE); + prefs.name_resolve = ((strcmp(value, "TRUE") == 0)?PREFS_RESOLV_ALL:PREFS_RESOLV_NONE); } else { /* To which module does this preference belong? */ @@ -1339,7 +1339,7 @@ fprintf(pf, "\n# Resolve addresses to names? TRUE/FALSE\n"); fprintf(pf, PRS_NAME_RESOLVE ": %s\n", - prefs.name_resolve == TRUE ? "TRUE" : "FALSE"); + prefs.name_resolve == PREFS_RESOLV_ALL ? "TRUE" : "FALSE"); /* write the capture options */ fprintf(pf, "\n# Capture in promiscuous mode? TRUE/FALSE\n"); Index: ethereal/prefs.h =================================================================== RCS file: /cvsroot/ethereal/prefs.h,v retrieving revision 1.29 diff -u -u -r1.29 prefs.h --- prefs.h 2001/04/15 03:37:13 1.29 +++ prefs.h 2001/05/03 02:03:23 @@ -33,6 +33,15 @@ #define PR_DEST_CMD 0 #define PR_DEST_FILE 1 +/* 31 types are sufficient (as are 640k of RAM) */ +/* FIXME: Maybe MANUF/m, IP/i, IP6/6, IPX/x, UDP+TCP/t etc would be + more useful/consistent */ +#define PREFS_RESOLV_NONE 0x0 +#define PREFS_RESOLV_MAC 0x1 +#define PREFS_RESOLV_NETWORK 0x2 +#define PREFS_RESOLV_TRANSPORT 0x4 +#define PREFS_RESOLV_ALL 0xFFFFFFFF + typedef struct _e_prefs { gint pr_format; gint pr_dest; @@ -50,7 +59,7 @@ gchar *gui_font_name; color_t gui_marked_fg; color_t gui_marked_bg; - gboolean name_resolve; + gint name_resolve; gboolean capture_prom_mode; gboolean capture_real_time; gboolean capture_auto_scroll; Index: ethereal/tethereal.c =================================================================== RCS file: /cvsroot/ethereal/tethereal.c,v retrieving revision 1.82 diff -u -u -r1.82 tethereal.c --- tethereal.c 2001/04/20 21:50:06 1.82 +++ tethereal.c 2001/05/03 02:03:25 @@ -336,7 +336,7 @@ #endif /* Now get our args */ - while ((opt = getopt(argc, argv, "c:Df:F:hi:lno:pr:R:s:t:vw:Vx")) != EOF) { + while ((opt = getopt(argc, argv, "c:Df:F:hi:lnN:o:pr:R:s:t:vw:Vx")) != EOF) { switch (opt) { case 'c': /* Capture xxx packets */ #ifdef HAVE_LIBPCAP @@ -417,8 +417,30 @@ line_buffered = TRUE; break; case 'n': /* No name resolution */ - prefs->name_resolve = 0; + prefs->name_resolve = PREFS_RESOLV_NONE; break; + case 'N': /* No name resolution */ + if (prefs->name_resolve == PREFS_RESOLV_ALL) { + prefs->name_resolve = PREFS_RESOLV_NONE; + } + for (; *optarg; optarg++) { + switch (*optarg) { + case 'm': + prefs->name_resolve |= PREFS_RESOLV_MAC; + break; + case 'n': + prefs->name_resolve |= PREFS_RESOLV_NETWORK; + break; + case 't': + prefs->name_resolve |= PREFS_RESOLV_TRANSPORT; + break; + default: + fprintf(stderr, "tethereal: -N specifies unknown resolving option '%c', valid are: m,n,t\n", + *optarg); + exit(1); + } + } + break; case 'o': /* Override preference from command line */ switch (prefs_set_pref(optarg)) { @@ -446,7 +468,7 @@ cf_name = g_strdup(optarg); break; case 'R': /* Read file filter */ - rfilter = optarg; + rfilter = g_strdup(optarg); break; case 's': /* Set the snapshot (capture) length */ #ifdef HAVE_LIBPCAP Index: ethereal/doc/tethereal.pod.template =================================================================== RCS file: /cvsroot/ethereal/doc/tethereal.pod.template,v retrieving revision 1.27 diff -u -u -r1.27 tethereal.pod.template --- tethereal.pod.template 2001/03/27 06:16:11 1.27 +++ tethereal.pod.template 2001/05/03 02:03:25 @@ -14,6 +14,7 @@ S<[ B<-i> interface ]> S<[ B<-l> ]> S<[ B<-n> ]> +S<[ B<-N> resolving flags ] ...> S<[ B<-o> preference setting ] ...> S<[ B<-p> ]> S<[ B<-r> infile ]> @@ -162,6 +163,12 @@ Disables network object name resolution (such as hostname, TCP and UDP port names). + +=item -N + +Flags to turn on specific name resolving for MAC B<m>, network B<n> and +transport B<t> layer addresses. This overrides -n if both -N and -n are +present. =item -o Index: ethereal/epan/resolv.c =================================================================== RCS file: /cvsroot/ethereal/epan/resolv.c,v retrieving revision 1.9 diff -u -u -r1.9 resolv.c --- resolv.c 2001/04/15 03:37:15 1.9 +++ resolv.c 2001/05/03 02:03:26 @@ -220,7 +220,7 @@ tp->addr = port; tp->next = NULL; - if (!prefs.name_resolve || + if (!(prefs.name_resolve & PREFS_RESOLV_TRANSPORT) || (servp = getservbyport(htons(port), serv_proto)) == NULL) { /* unknown port */ sprintf(tp->name, "%d", port); @@ -279,7 +279,7 @@ tp->addr = addr; tp->next = NULL; - if (prefs.name_resolve) { + if (prefs.name_resolve & PREFS_RESOLV_NETWORK) { #ifdef AVOID_DNS_TIMEOUT /* Quick hack to avoid DNS/YP timeout */ @@ -319,7 +319,7 @@ #ifdef INET6 struct hostent *hostp; - if (prefs.name_resolve) { + if (prefs.name_resolve & PREFS_RESOLV_NETWORK) { #ifdef AVOID_DNS_TIMEOUT /* Quick hack to avoid DNS/YP timeout */ @@ -1036,7 +1036,7 @@ { gboolean found; - if (!prefs.name_resolve) + if (!(prefs.name_resolve & PREFS_RESOLV_NETWORK)) return ip_to_str((guint8 *)&addr); return host_name_lookup(addr, &found); @@ -1047,7 +1047,7 @@ gboolean found; #ifdef INET6 - if (!prefs.name_resolve) + if (!(prefs.name_resolve & PREFS_RESOLV_NETWORK)) return ip6_to_str(addr); if (IN6_IS_ADDR_LINKLOCAL(addr) || IN6_IS_ADDR_MULTICAST(addr)) return ip6_to_str(addr); @@ -1100,7 +1100,7 @@ static gchar str[3][MAXNAMELEN]; static gchar *cur; - if (!prefs.name_resolve) { + if (!(prefs.name_resolve & PREFS_RESOLV_TRANSPORT)) { if (cur == &str[0][0]) { cur = &str[1][0]; } else if (cur == &str[1][0]) { @@ -1121,7 +1121,7 @@ static gchar str[3][MAXNAMELEN]; static gchar *cur; - if (!prefs.name_resolve) { + if (!(prefs.name_resolve & PREFS_RESOLV_TRANSPORT)) { if (cur == &str[0][0]) { cur = &str[1][0]; } else if (cur == &str[1][0]) { @@ -1142,7 +1142,7 @@ static gchar str[3][MAXNAMELEN]; static gchar *cur; - if (!prefs.name_resolve) { + if (!(prefs.name_resolve & PREFS_RESOLV_TRANSPORT)) { if (cur == &str[0][0]) { cur = &str[1][0]; } else if (cur == &str[1][0]) { @@ -1160,7 +1160,7 @@ extern guchar *get_ether_name(const guint8 *addr) { - if (!prefs.name_resolve) + if (!(prefs.name_resolve & PREFS_RESOLV_MAC)) return ether_to_str((guint8 *)addr); if (!eth_resolution_initialized) { @@ -1184,7 +1184,7 @@ /* Initialize ether structs if we're the first * ether-related function called */ - if (!prefs.name_resolve) + if (!(prefs.name_resolve & PREFS_RESOLV_MAC)) return NULL; if (!eth_resolution_initialized) { @@ -1268,7 +1268,7 @@ extern const guchar *get_ipxnet_name(const guint32 addr) { - if (!prefs.name_resolve) { + if (!(prefs.name_resolve & PREFS_RESOLV_NETWORK)) { return ipxnet_to_str_punct(addr, '\0'); } @@ -1306,12 +1306,12 @@ static gchar *cur; hashmanuf_t *manufp; - if (prefs.name_resolve && !eth_resolution_initialized) { + if ((prefs.name_resolve & PREFS_RESOLV_MAC) && !eth_resolution_initialized) { initialize_ethers(); eth_resolution_initialized = 1; } - if (!prefs.name_resolve || ((manufp = manuf_name_lookup(addr)) == NULL)) { + if (!(prefs.name_resolve & PREFS_RESOLV_MAC) || ((manufp = manuf_name_lookup(addr)) == NULL)) { if (cur == &str[0][0]) { cur = &str[1][0]; } else if (cur == &str[1][0]) { Index: ethereal/gtk/capture_dlg.c =================================================================== RCS file: /cvsroot/ethereal/gtk/capture_dlg.c,v retrieving revision 1.41 diff -u -u -r1.41 capture_dlg.c --- capture_dlg.c 2001/04/15 03:37:16 1.41 +++ capture_dlg.c 2001/05/03 02:03:27 @@ -502,7 +502,7 @@ prefs.capture_auto_scroll = GTK_TOGGLE_BUTTON (auto_scroll_cb)->active; - prefs.name_resolve = GTK_TOGGLE_BUTTON (resolv_cb)->active; + prefs.name_resolve = (GTK_TOGGLE_BUTTON (resolv_cb)->active ? PREFS_RESOLV_ALL : PREFS_RESOLV_NONE); gtk_widget_destroy(GTK_WIDGET(parent_w)); Index: ethereal/gtk/display_opts.c =================================================================== RCS file: /cvsroot/ethereal/gtk/display_opts.c,v retrieving revision 1.20 diff -u -u -r1.20 display_opts.c --- display_opts.c 2001/04/15 03:37:16 1.20 +++ display_opts.c 2001/05/03 02:03:27 @@ -269,7 +269,7 @@ button = (GtkWidget *) gtk_object_get_data(GTK_OBJECT(parent_w), E_DISPLAY_NAME_RESOLUTION_KEY); - prefs.name_resolve = (GTK_TOGGLE_BUTTON (button)->active); + prefs.name_resolve = (GTK_TOGGLE_BUTTON (button)->active ? PREFS_RESOLV_ALL : PREFS_RESOLV_NONE); } Index: ethereal/gtk/main.c =================================================================== RCS file: /cvsroot/ethereal/gtk/main.c,v retrieving revision 1.198 diff -u -u -r1.198 main.c --- main.c 2001/05/01 00:41:46 1.198 +++ main.c 2001/05/03 02:03:29 @@ -539,8 +539,8 @@ void resolve_name_cb(GtkWidget *widget, gpointer data) { if (cfile.protocol_tree) { - int tmp = prefs.name_resolve; - prefs.name_resolve = 1; + gint tmp = prefs.name_resolve; + prefs.name_resolve = PREFS_RESOLV_ALL; gtk_clist_clear ( GTK_CLIST(tree_view) ); proto_tree_draw(cfile.protocol_tree, tree_view); prefs.name_resolve = tmp; @@ -1035,7 +1035,7 @@ prefs->gui_font_name = g_strdup(optarg); break; case 'n': /* No name resolution */ - prefs->name_resolve = 0; + prefs->name_resolve = PREFS_RESOLV_NONE; break; case 'o': /* Override preference from command line */ switch (prefs_set_pref(optarg)) { @@ -1079,7 +1079,7 @@ cf_name = g_strdup(optarg); break; case 'R': /* Read file filter */ - rfilter = optarg; + rfilter = g_strdup(optarg); break; case 's': /* Set the snapshot (capture) length */ #ifdef HAVE_LIBPCAP
- Prev by Date: Re: [Ethereal-dev] Updates for wtls
- Next by Date: [Ethereal-dev] bootp used uint8_t
- Previous by thread: Re: [Ethereal-dev] Updates for wtls
- Next by thread: [Ethereal-dev] bootp used uint8_t
- Index(es):