forked from osmocom/wireshark
From Michael Mann:
Generic preferences implementation - Printing and Name Resolution. svn path=/trunk/; revision=43579daniel/osmux
parent
4c647041d4
commit
c19583b72c
142
capinfos.c
142
capinfos.c
|
@ -154,6 +154,100 @@ static gboolean cap_order = TRUE; /* Report if packets are in chronolo
|
|||
static gboolean cap_file_hashes = TRUE; /* Calculate file hashes */
|
||||
#endif
|
||||
|
||||
#define USE_GOPTION = 1
|
||||
#ifdef USE_GOPTION
|
||||
static gboolean cap_help = FALSE;
|
||||
static gboolean table_report = FALSE;
|
||||
|
||||
static GOptionEntry general_entries[] =
|
||||
{
|
||||
/* General */
|
||||
{ "type", 't', 0, G_OPTION_ARG_NONE, &cap_file_type,
|
||||
"display the capture file type", NULL },
|
||||
{ "Encapsulation", 'E', 0, G_OPTION_ARG_NONE, &cap_file_encap,
|
||||
"display the capture file encapsulation", NULL },
|
||||
#ifdef HAVE_LIBGCRYPT
|
||||
{ "Hash", 'H', 0, G_OPTION_ARG_NONE, &cap_file_hashes,
|
||||
"display the SHA1, RMD160, and MD5 hashes of the file", NULL },
|
||||
#endif /* HAVE_LIBGCRYPT */
|
||||
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
|
||||
};
|
||||
static GOptionEntry size_entries[] =
|
||||
{
|
||||
/* Size */
|
||||
{ "packets", 'c', 0, G_OPTION_ARG_NONE, &cap_packet_count,
|
||||
"display the number of packets", NULL },
|
||||
{ "size", 's', 0, G_OPTION_ARG_NONE, &cap_file_size,
|
||||
"display the size of the file (in bytes)", NULL },
|
||||
{ "tot-len-of-pkts", 'd', 0, G_OPTION_ARG_NONE, &cap_data_size,
|
||||
"display the total length of all packets (in bytes)", NULL },
|
||||
{ "snap", 'l', 0, G_OPTION_ARG_NONE, &cap_snaplen,
|
||||
"display the packet size limit (snapshot length)", NULL },
|
||||
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
|
||||
};
|
||||
static GOptionEntry time_entries[] =
|
||||
{
|
||||
/* Time */
|
||||
{ "duration", 'u', 0, G_OPTION_ARG_NONE, &cap_duration,
|
||||
"display the capture duration (in seconds)", NULL },
|
||||
{ "start", 'a', 0, G_OPTION_ARG_NONE, &cap_start_time,
|
||||
"display the capture start time", NULL },
|
||||
{ "end", 'e', 0, G_OPTION_ARG_NONE, &cap_end_time,
|
||||
"display the capture end time", NULL },
|
||||
{ "cron", 'o', 0, G_OPTION_ARG_NONE, &cap_order,
|
||||
"display the capture file chronological status (True/False)", NULL },
|
||||
{ "start-end-time-sec", 'S', 0, G_OPTION_ARG_NONE, &time_as_secs,
|
||||
"display start and end times as seconds", NULL },
|
||||
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
|
||||
};
|
||||
|
||||
static GOptionEntry stats_entries[] =
|
||||
{
|
||||
/* Statistics */
|
||||
{ "bytes", 'y', 0, G_OPTION_ARG_NONE, &cap_data_rate_byte,
|
||||
"display average data rate (in bytes/s)", NULL },
|
||||
{ "bits", 'i', 0, G_OPTION_ARG_NONE, &cap_data_rate_bit,
|
||||
"display average data rate (in bits/s)", NULL },
|
||||
{ "packet-bytes", 'z', 0, G_OPTION_ARG_NONE, &cap_packet_size,
|
||||
"display average packet size (in bytes)", NULL },
|
||||
{ "packets", 'x', 0, G_OPTION_ARG_NONE, &cap_packet_rate,
|
||||
"display average packet rate (in packets/s)", NULL },
|
||||
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
|
||||
};
|
||||
|
||||
static GOptionEntry output_format_entries[] =
|
||||
{
|
||||
/* Output format */
|
||||
{ "long", 'L', 0, G_OPTION_ARG_NONE, &long_report,
|
||||
"generate long report (default)", NULL },
|
||||
{ "Table", 'T', 0, G_OPTION_ARG_NONE, &table_report,
|
||||
"generate table report", NULL },
|
||||
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
|
||||
};
|
||||
|
||||
static GOptionEntry table_report_entries[] =
|
||||
{
|
||||
/* Table report */
|
||||
{ "header-rec", 'R', 0, G_OPTION_ARG_NONE, &table_report_header,
|
||||
"generate header record (default)", NULL },
|
||||
{ "no-table", 'r', 0, G_OPTION_ARG_NONE, &table_report_header,
|
||||
"do not generate header record", NULL },
|
||||
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
|
||||
};
|
||||
|
||||
static GOptionEntry misc_entries[] =
|
||||
{
|
||||
{ "helpcompat", 'h', 0, G_OPTION_ARG_NONE, &cap_help,
|
||||
"display help", NULL },
|
||||
{ NULL,'\0',0,G_OPTION_ARG_NONE,NULL,NULL,NULL }
|
||||
};
|
||||
|
||||
GOptionContext *ctx;
|
||||
GOptionGroup *general_grp, *size_grp, *time_grp, *stats_grp, *output_grp, *table_report_grp;
|
||||
GError *parse_err = NULL;
|
||||
|
||||
#endif /* USE_GOPTION */
|
||||
|
||||
#ifdef HAVE_LIBGCRYPT
|
||||
#define HASH_SIZE_SHA1 20
|
||||
#define HASH_SIZE_RMD160 20
|
||||
|
@ -217,6 +311,7 @@ typedef struct _capture_info {
|
|||
int *encap_counts; /* array of per_packet encap counts; array has one entry per wtap_encap type */
|
||||
} capture_info;
|
||||
|
||||
|
||||
static void
|
||||
enable_all_infos(void)
|
||||
{
|
||||
|
@ -950,7 +1045,54 @@ main(int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
/* Process the options */
|
||||
#ifdef USE_GOPTION
|
||||
ctx = g_option_context_new(" <infile> ... - print information about capture file(s)");
|
||||
general_grp = g_option_group_new("gen", "General infos:",
|
||||
"Show general options", NULL, NULL);
|
||||
size_grp = g_option_group_new("size", "Size infos:",
|
||||
"Show size options", NULL, NULL);
|
||||
time_grp = g_option_group_new("time", "Time infos:",
|
||||
"Show time options", NULL, NULL);
|
||||
stats_grp = g_option_group_new("stats", "Statistics infos:",
|
||||
"Show statistics options", NULL, NULL);
|
||||
output_grp = g_option_group_new("output", "Output format:",
|
||||
"Show output format options", NULL, NULL);
|
||||
table_report_grp = g_option_group_new("table", "Table report options:",
|
||||
"Show table report options", NULL, NULL);
|
||||
g_option_group_add_entries(general_grp, general_entries);
|
||||
g_option_group_add_entries(size_grp, size_entries);
|
||||
g_option_group_add_entries(time_grp, time_entries);
|
||||
g_option_group_add_entries(stats_grp, stats_entries);
|
||||
g_option_group_add_entries(output_grp, output_format_entries);
|
||||
g_option_group_add_entries(table_report_grp, table_report_entries);
|
||||
g_option_context_add_main_entries(ctx, misc_entries, NULL);
|
||||
g_option_context_add_group(ctx, general_grp);
|
||||
g_option_context_add_group(ctx, size_grp);
|
||||
g_option_context_add_group(ctx, time_grp);
|
||||
g_option_context_add_group(ctx, stats_grp);
|
||||
g_option_context_add_group(ctx, output_grp);
|
||||
g_option_context_add_group(ctx, table_report_grp);
|
||||
/* There's probably a better way to do this, but this works for now.
|
||||
GOptions displays the name in argv[0] as the name of the
|
||||
application. This is reasonable, but because we actually have a
|
||||
script wrapper that calls the executable. The name that gets
|
||||
displayed is not exactly the same as the command the user used
|
||||
ran.
|
||||
*/
|
||||
argv[0] = "capinfos";
|
||||
;
|
||||
if( !g_option_context_parse(ctx, &argc, &argv, &parse_err) ) {
|
||||
if(parse_err) g_print ("option parsing failed: %s\n", parse_err->message);
|
||||
g_print("%s", g_option_context_get_help (ctx, TRUE, NULL));
|
||||
exit(1);
|
||||
}
|
||||
if( cap_help || (argc < 2) ) {
|
||||
g_print("%s", g_option_context_get_help (ctx, FALSE, NULL));
|
||||
exit(0);
|
||||
}
|
||||
g_option_context_free(ctx);
|
||||
|
||||
#endif /* USE_GOPTION */
|
||||
while ((opt = getopt(argc, argv, "tEcs" FILE_HASH_OPT "dluaeyizvhxoCALTRrSNqQBmb")) !=-1) {
|
||||
|
||||
switch (opt) {
|
||||
|
|
|
@ -104,7 +104,7 @@ PROCESSOR_ARCHITECTURE=amd64
|
|||
|
||||
# "Microsoft Visual Studio 2010"
|
||||
# Visual C++ 10.0, _MSC_VER 1600, msvcr100.dll
|
||||
#MSVC_VARIANT=MSVC2010
|
||||
MSVC_VARIANT=MSVC2010
|
||||
|
||||
# "Microsoft Visual C++ 2010 Express Edition"
|
||||
# Visual C++ 10.0, _MSC_VER 1600, msvcr100.dll
|
||||
|
|
|
@ -286,7 +286,8 @@ static void add_serv_port_cb(const guint32 port);
|
|||
/*
|
||||
* Flag controlling what names to resolve.
|
||||
*/
|
||||
guint32 gbl_resolv_flags;
|
||||
e_addr_resolve gbl_resolv_flags = {TRUE, FALSE, TRUE, TRUE};
|
||||
static guint name_resolve_concurrency = 500;
|
||||
|
||||
/*
|
||||
* Global variables (can be changed in GUI sections)
|
||||
|
@ -362,7 +363,7 @@ typedef struct _async_dns_queue_msg
|
|||
#endif /* HAVE_C_ARES */
|
||||
#ifdef ASYNC_DNS
|
||||
static gboolean async_dns_initialized = FALSE;
|
||||
static int async_dns_in_flight = 0;
|
||||
static guint async_dns_in_flight = 0;
|
||||
static GList *async_dns_queue_head = NULL;
|
||||
|
||||
/* push a dns request */
|
||||
|
@ -656,7 +657,7 @@ static gchar
|
|||
tp->port = port;
|
||||
tp->next = NULL;
|
||||
|
||||
if (!(gbl_resolv_flags & RESOLV_TRANSPORT) ||
|
||||
if ((!gbl_resolv_flags.transport_name) ||
|
||||
(servp = getservbyport(g_htons(port), serv_proto)) == NULL) {
|
||||
/* unknown port */
|
||||
guint32_to_str_buf(port, tp->name, MAXNAMELEN);
|
||||
|
@ -799,8 +800,8 @@ host_lookup(const guint addr, const gboolean resolve, gboolean *found)
|
|||
if (resolve) {
|
||||
tp->resolve = TRUE;
|
||||
#ifdef ASYNC_DNS
|
||||
if ((gbl_resolv_flags & RESOLV_CONCURRENT) &&
|
||||
prefs.name_resolve_concurrency > 0 &&
|
||||
if (gbl_resolv_flags.concurrent_dns &&
|
||||
name_resolve_concurrency > 0 &&
|
||||
async_dns_initialized) {
|
||||
add_async_dns_ipv4(AF_INET, addr);
|
||||
/* XXX found is set to TRUE, which seems a bit odd, but I'm not
|
||||
|
@ -817,7 +818,7 @@ host_lookup(const guint addr, const gboolean resolve, gboolean *found)
|
|||
* botch, we don't try to translate an all-zero IP address to a host
|
||||
* name.
|
||||
*/
|
||||
if (addr != 0 && (gbl_resolv_flags & RESOLV_NETWORK)) {
|
||||
if (addr != 0 && gbl_resolv_flags.network_name) {
|
||||
/* Use async DNS if possible, else fall back to timeouts,
|
||||
* else call gethostbyaddr and hope for the best
|
||||
*/
|
||||
|
@ -908,8 +909,8 @@ host_lookup6(const struct e_in6_addr *addr, const gboolean resolve, gboolean *fo
|
|||
#ifdef INET6
|
||||
|
||||
#ifdef HAVE_C_ARES
|
||||
if ((gbl_resolv_flags & RESOLV_CONCURRENT) &&
|
||||
prefs.name_resolve_concurrency > 0 &&
|
||||
if ((gbl_resolv_flags.concurrent_dns) &&
|
||||
name_resolve_concurrency > 0 &&
|
||||
async_dns_initialized) {
|
||||
caqm = g_malloc(sizeof(async_dns_queue_msg_t));
|
||||
caqm->family = AF_INET6;
|
||||
|
@ -2377,6 +2378,42 @@ subnet_name_lookup_init(void)
|
|||
* External Functions
|
||||
*/
|
||||
|
||||
void
|
||||
addr_resolve_pref_init(module_t *nameres)
|
||||
{
|
||||
prefs_register_bool_preference(nameres, "mac_name",
|
||||
"Enable MAC name resolution",
|
||||
"e.g. Ethernet address to manufacturer name",
|
||||
&gbl_resolv_flags.mac_name);
|
||||
|
||||
prefs_register_bool_preference(nameres, "network_name",
|
||||
"Enable network name resolution",
|
||||
"e.g. IP address to DNS name (hostname)",
|
||||
&gbl_resolv_flags.network_name);
|
||||
|
||||
prefs_register_bool_preference(nameres, "transport_name",
|
||||
"Enable transport name resolution",
|
||||
"e.g. TCP/UDP port to service name",
|
||||
&gbl_resolv_flags.transport_name);
|
||||
|
||||
#if defined(HAVE_C_ARES) || defined(HAVE_GNU_ADNS)
|
||||
prefs_register_bool_preference(nameres, "concurrent_dns",
|
||||
"Enable concurrent DNS name resolution",
|
||||
"be sure to enable network name resolution",
|
||||
&gbl_resolv_flags.concurrent_dns);
|
||||
|
||||
prefs_register_uint_preference(nameres, "name_resolve_concurrency",
|
||||
"Maximum concurrent requests",
|
||||
"maximum parallel running DNS requests",
|
||||
10,
|
||||
&name_resolve_concurrency);
|
||||
#else
|
||||
prefs_register_static_text_preference(nameres, "no_concurrent_dns",
|
||||
"Enable concurrent DNS name resolution: N/A",
|
||||
"Support for this feature was not compiled into this version of Wireshark");
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
host_name_lookup_init(void) {
|
||||
char *hostspath;
|
||||
|
@ -2492,7 +2529,7 @@ host_name_lookup_process(gpointer data _U_) {
|
|||
|
||||
async_dns_queue_head = g_list_first(async_dns_queue_head);
|
||||
|
||||
while (async_dns_queue_head != NULL && async_dns_in_flight <= prefs.name_resolve_concurrency) {
|
||||
while (async_dns_queue_head != NULL && async_dns_in_flight <= name_resolve_concurrency) {
|
||||
caqm = (async_dns_queue_msg_t *) async_dns_queue_head->data;
|
||||
async_dns_queue_head = g_list_remove(async_dns_queue_head, (void *) caqm);
|
||||
if (caqm->family == AF_INET) {
|
||||
|
@ -2636,7 +2673,7 @@ const gchar *
|
|||
get_hostname(const guint addr)
|
||||
{
|
||||
gboolean found;
|
||||
gboolean resolve = gbl_resolv_flags & RESOLV_NETWORK;
|
||||
gboolean resolve = gbl_resolv_flags.network_name;
|
||||
hashipv4_t *tp = host_lookup(addr, resolve, &found);
|
||||
|
||||
if (!resolve)
|
||||
|
@ -2651,7 +2688,7 @@ const gchar *
|
|||
get_hostname6(const struct e_in6_addr *addr)
|
||||
{
|
||||
gboolean found;
|
||||
gboolean resolve = gbl_resolv_flags & RESOLV_NETWORK;
|
||||
gboolean resolve = gbl_resolv_flags.network_name;
|
||||
hashipv6_t *tp = host_lookup6(addr, resolve, &found);
|
||||
|
||||
if (!resolve)
|
||||
|
@ -2794,7 +2831,7 @@ gchar *
|
|||
get_udp_port(guint port)
|
||||
{
|
||||
|
||||
if (!(gbl_resolv_flags & RESOLV_TRANSPORT)) {
|
||||
if (!gbl_resolv_flags.transport_name) {
|
||||
return ep_utoa(port);
|
||||
}
|
||||
|
||||
|
@ -2806,7 +2843,7 @@ gchar *
|
|||
get_dccp_port(guint port)
|
||||
{
|
||||
|
||||
if (!(gbl_resolv_flags & RESOLV_TRANSPORT)) {
|
||||
if (!gbl_resolv_flags.transport_name) {
|
||||
return ep_utoa(port);
|
||||
}
|
||||
|
||||
|
@ -2819,7 +2856,7 @@ gchar *
|
|||
get_tcp_port(guint port)
|
||||
{
|
||||
|
||||
if (!(gbl_resolv_flags & RESOLV_TRANSPORT)) {
|
||||
if (!gbl_resolv_flags.transport_name) {
|
||||
return ep_utoa(port);
|
||||
}
|
||||
|
||||
|
@ -2831,7 +2868,7 @@ gchar *
|
|||
get_sctp_port(guint port)
|
||||
{
|
||||
|
||||
if (!(gbl_resolv_flags & RESOLV_TRANSPORT)) {
|
||||
if (!gbl_resolv_flags.transport_name) {
|
||||
return ep_utoa(port);
|
||||
}
|
||||
|
||||
|
@ -2894,7 +2931,7 @@ gchar *
|
|||
get_ether_name(const guint8 *addr)
|
||||
{
|
||||
hashether_t *tp;
|
||||
gboolean resolve = (gbl_resolv_flags & RESOLV_MAC) != 0;
|
||||
gboolean resolve = gbl_resolv_flags.mac_name;
|
||||
|
||||
if (resolve && !eth_resolution_initialized) {
|
||||
initialize_ethers();
|
||||
|
@ -2917,7 +2954,7 @@ get_ether_name_if_known(const guint8 *addr)
|
|||
|
||||
/* Initialize ether structs if we're the first
|
||||
* ether-related function called */
|
||||
if (!(gbl_resolv_flags & RESOLV_MAC))
|
||||
if (!gbl_resolv_flags.mac_name)
|
||||
return NULL;
|
||||
|
||||
if (!eth_resolution_initialized) {
|
||||
|
@ -2962,7 +2999,7 @@ add_ether_byip(const guint ip, const guint8 *eth)
|
|||
gboolean found;
|
||||
|
||||
/* first check that IP address can be resolved */
|
||||
if (!(gbl_resolv_flags & RESOLV_NETWORK))
|
||||
if (!gbl_resolv_flags.network_name)
|
||||
return;
|
||||
|
||||
if ((host = host_name_lookup(ip, &found)) == NULL)
|
||||
|
@ -2979,7 +3016,7 @@ const gchar *
|
|||
get_ipxnet_name(const guint32 addr)
|
||||
{
|
||||
|
||||
if (!(gbl_resolv_flags & RESOLV_NETWORK)) {
|
||||
if (!gbl_resolv_flags.network_name) {
|
||||
return ipxnet_to_str_punct(addr, '\0');
|
||||
}
|
||||
|
||||
|
@ -3018,12 +3055,12 @@ get_manuf_name(const guint8 *addr)
|
|||
gchar *cur;
|
||||
hashmanuf_t *mtp;
|
||||
|
||||
if ((gbl_resolv_flags & RESOLV_MAC) && !eth_resolution_initialized) {
|
||||
if (gbl_resolv_flags.mac_name && !eth_resolution_initialized) {
|
||||
initialize_ethers();
|
||||
eth_resolution_initialized = TRUE;
|
||||
}
|
||||
|
||||
if (!(gbl_resolv_flags & RESOLV_MAC) || ((mtp = manuf_name_lookup(addr)) == NULL)) {
|
||||
if (!gbl_resolv_flags.mac_name || ((mtp = manuf_name_lookup(addr)) == NULL)) {
|
||||
cur=ep_strdup_printf("%02x:%02x:%02x", addr[0], addr[1], addr[2]);
|
||||
return cur;
|
||||
}
|
||||
|
@ -3094,12 +3131,12 @@ get_eui64_name(const guint64 addr_eui64)
|
|||
/* Copy and convert the address to network byte order. */
|
||||
*(guint64 *)(void *)(addr) = pntoh64(&(addr_eui64));
|
||||
|
||||
if ((gbl_resolv_flags & RESOLV_MAC) && !eth_resolution_initialized) {
|
||||
if (gbl_resolv_flags.mac_name && !eth_resolution_initialized) {
|
||||
initialize_ethers();
|
||||
eth_resolution_initialized = TRUE;
|
||||
}
|
||||
|
||||
if (!(gbl_resolv_flags & RESOLV_MAC) || ((mtp = manuf_name_lookup(addr)) == NULL)) {
|
||||
if (!gbl_resolv_flags.mac_name || ((mtp = manuf_name_lookup(addr)) == NULL)) {
|
||||
cur=ep_strdup_printf("%02x:%02x:%02x%02x:%02x:%02x%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5], addr[6], addr[7]);
|
||||
return cur;
|
||||
}
|
||||
|
@ -3177,14 +3214,14 @@ get_host_ipaddr(const char *host, guint32 *addrp)
|
|||
* less-than-4 octet notation.
|
||||
*/
|
||||
if (!inet_aton(host, &ipaddr)) {
|
||||
if (! (gbl_resolv_flags & RESOLV_NETWORK)) {
|
||||
if (!gbl_resolv_flags.network_name) {
|
||||
return FALSE;
|
||||
}
|
||||
/* It's not a valid dotted-quad IP address; is it a valid
|
||||
* host name? */
|
||||
#ifdef HAVE_C_ARES
|
||||
if (! (gbl_resolv_flags & RESOLV_CONCURRENT) ||
|
||||
prefs.name_resolve_concurrency < 1 ||
|
||||
if (! (gbl_resolv_flags.concurrent_dns) ||
|
||||
name_resolve_concurrency < 1 ||
|
||||
! async_dns_initialized) {
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -3253,14 +3290,14 @@ get_host_ipaddr6(const char *host, struct e_in6_addr *addrp)
|
|||
if (inet_pton(AF_INET6, host, addrp) == 1)
|
||||
return TRUE;
|
||||
|
||||
if (! (gbl_resolv_flags & RESOLV_NETWORK)) {
|
||||
if (!gbl_resolv_flags.network_name) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* try FQDN */
|
||||
#ifdef HAVE_C_ARES
|
||||
if (! (gbl_resolv_flags & RESOLV_CONCURRENT) ||
|
||||
prefs.name_resolve_concurrency < 1 ||
|
||||
if (! (gbl_resolv_flags.concurrent_dns) ||
|
||||
name_resolve_concurrency < 1 ||
|
||||
! async_dns_initialized) {
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -45,22 +45,17 @@ extern "C" {
|
|||
#define MAXNAMELEN 64 /* max name length (hostname and port name) */
|
||||
#endif
|
||||
|
||||
typedef struct _e_addr_resolve {
|
||||
gboolean mac_name;
|
||||
gboolean network_name;
|
||||
gboolean transport_name;
|
||||
gboolean concurrent_dns;
|
||||
} e_addr_resolve;
|
||||
|
||||
/*
|
||||
* Flag controlling what names to resolve.
|
||||
*/
|
||||
WS_VAR_IMPORT guint32 gbl_resolv_flags;
|
||||
|
||||
/* 32 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 RESOLV_NONE 0x0
|
||||
#define RESOLV_MAC 0x1
|
||||
#define RESOLV_NETWORK 0x2
|
||||
#define RESOLV_TRANSPORT 0x4
|
||||
#define RESOLV_CONCURRENT 0x8
|
||||
|
||||
#define RESOLV_ALL_ADDRS (RESOLV_MAC|RESOLV_NETWORK|RESOLV_TRANSPORT)
|
||||
#define RESOLV_ALL 0xFFFFFFFF
|
||||
WS_VAR_IMPORT e_addr_resolve gbl_resolv_flags;
|
||||
|
||||
/* global variables */
|
||||
|
||||
|
@ -69,10 +64,7 @@ extern gchar *g_ipxnets_path;
|
|||
extern gchar *g_pethers_path;
|
||||
extern gchar *g_pipxnets_path;
|
||||
|
||||
/* Functions in resolv.c */
|
||||
|
||||
/* Set the flags controlling what names to resolve */
|
||||
extern void resolv_set_flags(guint32 flags);
|
||||
/* Functions in addr_resolv.c */
|
||||
|
||||
/*
|
||||
* get_udp_port() returns the port name corresponding to that UDP port,
|
||||
|
@ -122,6 +114,10 @@ void get_addr_name_buf(const address *addr, gchar *buf, gsize size);
|
|||
* Asynchronous host name lookup initialization, processing, and cleanup
|
||||
*/
|
||||
|
||||
/* Setup name resolution preferences */
|
||||
typedef struct pref_module module_t;
|
||||
extern void addr_resolve_pref_init(module_t *nameres);
|
||||
|
||||
/* host_name_lookup_init fires up an ADNS socket if we're using ADNS */
|
||||
extern void host_name_lookup_init(void);
|
||||
|
||||
|
|
|
@ -140,16 +140,13 @@ static void geoip_db_path_free_cb(void* p) {
|
|||
/**
|
||||
* Initialize GeoIP lookups
|
||||
*/
|
||||
void
|
||||
geoip_db_init(void) {
|
||||
guint i;
|
||||
void
|
||||
geoip_db_pref_init(module_t *nameres)
|
||||
{
|
||||
static uat_field_t geoip_db_paths_fields[] = {
|
||||
UAT_FLD_DIRECTORYNAME(geoip_mod, path, "GeoIP Database Directory", "The GeoIP database directory path"),
|
||||
UAT_END_FIELDS
|
||||
};
|
||||
char* geoip_load_error = NULL;
|
||||
|
||||
geoip_dat_arr = g_array_new(FALSE, FALSE, sizeof(GeoIP *));
|
||||
|
||||
geoip_db_paths_uat = uat_new("GeoIP Database Paths",
|
||||
sizeof(geoip_db_path_t),
|
||||
|
@ -165,12 +162,22 @@ geoip_db_init(void) {
|
|||
NULL,
|
||||
geoip_db_paths_fields);
|
||||
|
||||
uat_load(geoip_db_paths_uat, &geoip_load_error);
|
||||
prefs_register_uat_preference(nameres,
|
||||
"geoip_db_paths",
|
||||
"GeoIP database directories",
|
||||
"Search paths for GeoIP address mapping databases.\n"
|
||||
"Wireshark will look in each directory for files beginning\n"
|
||||
"with \"Geo\" and ending with \".dat\".\n"
|
||||
"You must restart Wireshark for these changes to take\n"
|
||||
"effect.",
|
||||
geoip_db_paths_uat);
|
||||
}
|
||||
|
||||
if (geoip_load_error) {
|
||||
report_failure("Error loading GeoIP database path table: %s", geoip_load_error);
|
||||
return;
|
||||
}
|
||||
void
|
||||
geoip_db_init(void) {
|
||||
guint i;
|
||||
|
||||
geoip_dat_arr = g_array_new(FALSE, FALSE, sizeof(GeoIP *));
|
||||
|
||||
for (i = 0; i < num_geoip_db_paths; i++) {
|
||||
if (geoip_db_paths[i].path) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#define __GEOIP_DB_H__
|
||||
|
||||
#include <epan/ipv6-utils.h>
|
||||
#include <epan/prefs.h>
|
||||
|
||||
/* Fake databases to make lat/lon values available */
|
||||
/* XXX - find a better way to interface */
|
||||
|
@ -39,6 +40,7 @@
|
|||
* Init function called from epan.h
|
||||
*/
|
||||
extern void geoip_db_init(void);
|
||||
extern void geoip_db_pref_init(module_t *nameres);
|
||||
|
||||
/**
|
||||
* Number of databases we have loaded
|
||||
|
|
148
epan/oids.c
148
epan/oids.c
|
@ -46,6 +46,8 @@
|
|||
#include <smi.h>
|
||||
|
||||
static gboolean oids_init_done = FALSE;
|
||||
static gboolean load_smi_modules = FALSE;
|
||||
static gboolean suppress_smi_errors = FALSE;
|
||||
#endif
|
||||
|
||||
#define D(level,args) do if (debuglevel >= level) { printf args; printf("\n"); fflush(stdout); } while(0)
|
||||
|
@ -514,61 +516,9 @@ static void register_mibs(void) {
|
|||
int proto_mibs = -1;
|
||||
GArray* hfa = g_array_new(FALSE,TRUE,sizeof(hf_register_info));
|
||||
GArray* etta = g_array_new(FALSE,TRUE,sizeof(gint*));
|
||||
static uat_field_t smi_fields[] = {
|
||||
UAT_FLD_CSTRING(smi_mod,name,"Module name","The module's name"),
|
||||
UAT_END_FIELDS
|
||||
};
|
||||
static uat_field_t smi_paths_fields[] = {
|
||||
UAT_FLD_DIRECTORYNAME(smi_mod,name,"Directory path","The directory name"),
|
||||
UAT_END_FIELDS
|
||||
};
|
||||
char* smi_load_error = NULL;
|
||||
gchar* path_str;
|
||||
|
||||
smi_modules_uat = uat_new("SMI Modules",
|
||||
sizeof(smi_module_t),
|
||||
"smi_modules",
|
||||
FALSE,
|
||||
(void*)&smi_modules,
|
||||
&num_smi_modules,
|
||||
UAT_CAT_GENERAL,
|
||||
"ChSNMPSMIModules",
|
||||
smi_mod_copy_cb,
|
||||
NULL,
|
||||
smi_mod_free_cb,
|
||||
restart_needed_warning,
|
||||
smi_fields);
|
||||
|
||||
smi_paths_uat = uat_new("SMI Paths",
|
||||
sizeof(smi_module_t),
|
||||
"smi_paths",
|
||||
FALSE,
|
||||
(void*)&smi_paths,
|
||||
&num_smi_paths,
|
||||
UAT_CAT_GENERAL,
|
||||
"ChSNMPSMIPaths",
|
||||
smi_mod_copy_cb,
|
||||
NULL,
|
||||
smi_mod_free_cb,
|
||||
restart_needed_warning,
|
||||
smi_paths_fields);
|
||||
|
||||
|
||||
uat_load(smi_modules_uat, &smi_load_error);
|
||||
|
||||
if (smi_load_error) {
|
||||
report_failure("Error Loading SMI Modules Table: %s",smi_load_error);
|
||||
return;
|
||||
}
|
||||
|
||||
uat_load(smi_paths_uat, &smi_load_error);
|
||||
|
||||
if (smi_load_error) {
|
||||
report_failure("Error Loading SMI Paths Table: %s",smi_load_error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!prefs.load_smi_modules) {
|
||||
if (!load_smi_modules) {
|
||||
D(1,("OID resolution not enabled"));
|
||||
return;
|
||||
}
|
||||
|
@ -607,7 +557,7 @@ static void register_mibs(void) {
|
|||
}
|
||||
|
||||
if (smi_errors->len) {
|
||||
if (!prefs.suppress_smi_errors) {
|
||||
if (!suppress_smi_errors) {
|
||||
report_failure("The following errors were found while loading the MIBS:\n%s\n\n"
|
||||
"The Current Path is: %s\n\nYou can avoid this error message "
|
||||
"by removing the missing MIB modules at Edit -> Preferences"
|
||||
|
@ -631,7 +581,7 @@ static void register_mibs(void) {
|
|||
* Currently there is no such version. :-(
|
||||
*/
|
||||
if (smiModule->conformance == 1) {
|
||||
if (!prefs.suppress_smi_errors) {
|
||||
if (!suppress_smi_errors) {
|
||||
report_failure("Stopped processing module %s due to "
|
||||
"error(s) to prevent potential crash in libsmi.\n"
|
||||
"Module's conformance level: %d.\n"
|
||||
|
@ -768,21 +718,103 @@ static void register_mibs(void) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void oid_pref_init(module_t *nameres)
|
||||
{
|
||||
static uat_field_t smi_fields[] = {
|
||||
UAT_FLD_CSTRING(smi_mod,name,"Module name","The module's name"),
|
||||
UAT_END_FIELDS
|
||||
};
|
||||
static uat_field_t smi_paths_fields[] = {
|
||||
UAT_FLD_DIRECTORYNAME(smi_mod,name,"Directory path","The directory name"),
|
||||
UAT_END_FIELDS
|
||||
};
|
||||
|
||||
#ifdef HAVE_LIBSMI
|
||||
prefs_register_bool_preference(nameres, "load_smi_modules",
|
||||
"Enable OID resolution",
|
||||
"You must restart Wireshark for this change to take effect",
|
||||
&load_smi_modules);
|
||||
|
||||
prefs_register_bool_preference(nameres, "suppress_smi_errors",
|
||||
"Suppress SMI errors",
|
||||
"Some errors can be ignored. If unsure, set to false.",
|
||||
&suppress_smi_errors);
|
||||
|
||||
smi_paths_uat = uat_new("SMI Paths",
|
||||
sizeof(smi_module_t),
|
||||
"smi_paths",
|
||||
FALSE,
|
||||
(void*)&smi_paths,
|
||||
&num_smi_paths,
|
||||
UAT_CAT_GENERAL,
|
||||
"ChSNMPSMIPaths",
|
||||
smi_mod_copy_cb,
|
||||
NULL,
|
||||
smi_mod_free_cb,
|
||||
restart_needed_warning,
|
||||
smi_paths_fields);
|
||||
|
||||
prefs_register_uat_preference(nameres,
|
||||
"smi_paths",
|
||||
"SMI (MIB and PIB) paths",
|
||||
"Search paths for SMI (MIB and PIB) modules. You must\n"
|
||||
"restart Wireshark for these changes to take effect.",
|
||||
smi_paths_uat);
|
||||
|
||||
smi_modules_uat = uat_new("SMI Modules",
|
||||
sizeof(smi_module_t),
|
||||
"smi_modules",
|
||||
FALSE,
|
||||
(void*)&smi_modules,
|
||||
&num_smi_modules,
|
||||
UAT_CAT_GENERAL,
|
||||
"ChSNMPSMIModules",
|
||||
smi_mod_copy_cb,
|
||||
NULL,
|
||||
smi_mod_free_cb,
|
||||
restart_needed_warning,
|
||||
smi_fields);
|
||||
|
||||
prefs_register_uat_preference(nameres,
|
||||
"smi_modules",
|
||||
"SMI (MIB and PIB) modules",
|
||||
"List of enabled SMI (MIB and PIB) modules. You must\n"
|
||||
"restart Wireshark for these changes to take effect.",
|
||||
smi_modules_uat);
|
||||
|
||||
#else
|
||||
prefs_register_static_text_preference(nameres, "load_smi_modules_static",
|
||||
"Enable OID resolution: N/A",
|
||||
"Support for this feature was not compiled into this version of Wireshark");
|
||||
|
||||
prefs_register_static_text_preference(nameres, "suppress_smi_errors_static",
|
||||
"Suppress SMI errors: N/A",
|
||||
"Support for this feature was not compiled into this version of Wireshark");
|
||||
|
||||
prefs_register_static_text_preference(nameres, "smi_module_path",
|
||||
"SMI (MIB and PIB) modules and paths: N/A",
|
||||
"Support for this feature was not compiled into this version of Wireshark");
|
||||
#endif
|
||||
}
|
||||
|
||||
void oids_init(void) {
|
||||
if (load_smi_modules) {
|
||||
#ifdef HAVE_LIBSMI
|
||||
register_mibs();
|
||||
#else
|
||||
D(1,("libsmi disabled oid resolution not enabled"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void oids_cleanup(void) {
|
||||
if (load_smi_modules) {
|
||||
#ifdef HAVE_LIBSMI
|
||||
unregister_mibs();
|
||||
unregister_mibs();
|
||||
#else
|
||||
D(1,("libsmi disabled oid resolution not enabled"));
|
||||
D(1,("libsmi disabled oid resolution not enabled"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
const char* oid_subid2string(guint32* subids, guint len) {
|
||||
|
@ -1123,7 +1155,7 @@ oid_get_default_mib_path(void) {
|
|||
|
||||
path_str = g_string_new("");
|
||||
|
||||
if (!prefs.load_smi_modules) {
|
||||
if (!load_smi_modules) {
|
||||
D(1,("OID resolution not enabled"));
|
||||
return path_str->str;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#define __OIDS_H__
|
||||
|
||||
#include <epan/ftypes/ftypes.h>
|
||||
#include <epan/prefs.h>
|
||||
/**
|
||||
*@file
|
||||
*/
|
||||
|
@ -106,6 +107,7 @@ typedef struct _oid_info_t {
|
|||
|
||||
/** init funcion called from epan.h */
|
||||
extern void oids_init(void);
|
||||
extern void oid_pref_init(module_t *nameres);
|
||||
|
||||
/** init funcion called from epan.h */
|
||||
extern void oids_cleanup(void);
|
||||
|
|
268
epan/prefs.c
268
epan/prefs.c
|
@ -42,6 +42,7 @@
|
|||
#include <epan/address.h>
|
||||
#include <epan/addr_resolv.h>
|
||||
#include <epan/oids.h>
|
||||
#include <epan/geoip_db.h>
|
||||
#include <epan/packet.h>
|
||||
#include <epan/prefs.h>
|
||||
#include <epan/proto.h>
|
||||
|
@ -315,7 +316,8 @@ prefs_register_module_or_subtree(module_t *parent, const char *name,
|
|||
/*
|
||||
* Register that a protocol has preferences.
|
||||
*/
|
||||
module_t *protocols_module;
|
||||
module_t *protocols_module = NULL;
|
||||
module_t *stats_module = NULL;
|
||||
|
||||
module_t *
|
||||
prefs_register_protocol(int id, void (*apply_cb)(void))
|
||||
|
@ -339,7 +341,6 @@ prefs_register_protocol(int id, void (*apply_cb)(void))
|
|||
proto_get_protocol_name(id), apply_cb);
|
||||
}
|
||||
|
||||
|
||||
module_t *
|
||||
prefs_register_protocol_subtree(const char *subtree, int id, void (*apply_cb)(void))
|
||||
{
|
||||
|
@ -931,6 +932,23 @@ prefs_pref_foreach(module_t *module, pref_cb callback, gpointer user_data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const enum_val_t print_format_vals[] = {
|
||||
{ "text", "Plain Text", PR_FMT_TEXT },
|
||||
{ "postscript", "Postscript", PR_FMT_PS },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static const enum_val_t print_dest_vals[] = {
|
||||
#ifdef _WIN32
|
||||
/* "PR_DEST_CMD" means "to printer" on Windows */
|
||||
{ "command", "Printer", PR_DEST_CMD },
|
||||
#else
|
||||
{ "command", "Command", PR_DEST_CMD },
|
||||
#endif
|
||||
{ "file", "File", PR_DEST_FILE },
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
|
||||
static void stats_callback(void)
|
||||
{
|
||||
/* Test for a sane tap update interval */
|
||||
|
@ -952,30 +970,61 @@ static void stats_callback(void)
|
|||
void
|
||||
prefs_register_modules(void)
|
||||
{
|
||||
module_t* stats;
|
||||
module_t *printing, *nameres_module;
|
||||
|
||||
if (protocols_module != NULL) {
|
||||
/* Already setup preferences */
|
||||
return;
|
||||
}
|
||||
|
||||
stats = prefs_register_module(NULL, "statistics", "Statistics",
|
||||
/* Name Resolution */
|
||||
nameres_module = prefs_register_module(NULL, "nameres", "Name Resolution",
|
||||
"Name Resolution", NULL);
|
||||
addr_resolve_pref_init(nameres_module);
|
||||
oid_pref_init(nameres_module);
|
||||
geoip_db_pref_init(nameres_module);
|
||||
|
||||
/* Printing */
|
||||
printing = prefs_register_module(NULL, "print", "Printing",
|
||||
"Printing", NULL);
|
||||
|
||||
prefs_register_enum_preference(printing, "format",
|
||||
"Format", "Can be one of \"text\" or \"postscript\"",
|
||||
&prefs.pr_format, print_format_vals, TRUE);
|
||||
|
||||
prefs_register_enum_preference(printing, "destination",
|
||||
"Print to", "Can be one of \"command\" or \"file\"",
|
||||
&prefs.pr_dest, print_dest_vals, TRUE);
|
||||
|
||||
#ifndef _WIN32
|
||||
prefs_register_string_preference(printing, "command", "Command",
|
||||
"Output gets piped to this command when the destination is set to \"command\"", &prefs.pr_cmd);
|
||||
#endif
|
||||
|
||||
prefs_register_filename_preference(printing, "file", "File",
|
||||
"This is the file that gets written to when the destination is set to \"file\"", &prefs.pr_file);
|
||||
|
||||
|
||||
/* Statistics */
|
||||
stats_module = prefs_register_module(NULL, "statistics", "Statistics",
|
||||
"Statistics", &stats_callback);
|
||||
|
||||
prefs_register_uint_preference(stats, "update_interval",
|
||||
prefs_register_uint_preference(stats_module, "update_interval",
|
||||
"Tap update interval in ms",
|
||||
"Determines time between tap updates",
|
||||
10,
|
||||
&prefs.tap_update_interval);
|
||||
|
||||
#ifdef HAVE_LIBPORTAUDIO
|
||||
prefs_register_uint_preference(stats, "rtp_player_max_visible",
|
||||
prefs_register_uint_preference(stats_module, "rtp_player_max_visible",
|
||||
"Max visible channels in RTP Player",
|
||||
"Determines maximum height of RTP Player window",
|
||||
10,
|
||||
&prefs.rtp_player_max_visible);
|
||||
#endif
|
||||
|
||||
|
||||
/* Protocols */
|
||||
protocols_module = prefs_register_module(NULL, "protocols", "Protocols",
|
||||
"Protocols", NULL);
|
||||
|
||||
|
@ -1456,12 +1505,6 @@ init_prefs(void)
|
|||
prefs.capture_auto_scroll = TRUE;
|
||||
prefs.capture_show_info = FALSE;
|
||||
|
||||
/* set the default values for the name resolution dialog box */
|
||||
prefs.name_resolve = RESOLV_ALL ^ RESOLV_NETWORK;
|
||||
prefs.name_resolve_concurrency = 500;
|
||||
prefs.load_smi_modules = FALSE;
|
||||
prefs.suppress_smi_errors = FALSE;
|
||||
|
||||
/* set the default values for the tap/statistics dialog box */
|
||||
prefs.tap_update_interval = TAP_UPDATE_DEFAULT_INTERVAL;
|
||||
prefs.rtp_player_max_visible = RTP_PLAYER_DEFAULT_VISIBLE;
|
||||
|
@ -1616,9 +1659,7 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
|
|||
FILE *pf;
|
||||
|
||||
/* clean up libsmi structures before reading prefs */
|
||||
if (prefs.load_smi_modules) {
|
||||
oids_cleanup();
|
||||
}
|
||||
oids_cleanup();
|
||||
|
||||
init_prefs();
|
||||
|
||||
|
@ -1719,10 +1760,8 @@ read_prefs(int *gpf_errno_return, int *gpf_read_errno_return,
|
|||
}
|
||||
|
||||
/* load SMI modules if needed */
|
||||
if (prefs.load_smi_modules) {
|
||||
oids_init();
|
||||
}
|
||||
|
||||
oids_init();
|
||||
|
||||
return &prefs;
|
||||
}
|
||||
|
||||
|
@ -2081,10 +2120,6 @@ prefs_capture_device_monitor_mode(const char *name)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
#define PRS_PRINT_FMT "print.format"
|
||||
#define PRS_PRINT_DEST "print.destination"
|
||||
#define PRS_PRINT_FILE "print.file"
|
||||
#define PRS_PRINT_CMD "print.command"
|
||||
#define PRS_COL_HIDDEN "column.hidden"
|
||||
#define PRS_COL_FMT "column.format"
|
||||
#define PRS_STREAM_CL_FG "stream.client.fg"
|
||||
|
@ -2139,7 +2174,7 @@ prefs_capture_device_monitor_mode(const char *name)
|
|||
#define PRS_GUI_LAYOUT_CONTENT_1 "gui.layout_content_1"
|
||||
#define PRS_GUI_LAYOUT_CONTENT_2 "gui.layout_content_2"
|
||||
#define PRS_GUI_LAYOUT_CONTENT_3 "gui.layout_content_3"
|
||||
#define PRS_CONSOLE_LOG_LEVEL "console.log.level"
|
||||
#define PRS_CONSOLE_LOG_LEVEL "console.log.level"
|
||||
#define PRS_GUI_FILTER_LABEL "gui.filter_expressions.label"
|
||||
#define PRS_GUI_FILTER_EXPR "gui.filter_expressions.expr"
|
||||
#define PRS_GUI_FILTER_ENABLED "gui.filter_expressions.enabled"
|
||||
|
@ -2179,67 +2214,37 @@ prefs_capture_device_monitor_mode(const char *name)
|
|||
static const gchar *pr_formats[] = { "text", "postscript" };
|
||||
static const gchar *pr_dests[] = { "command", "file" };
|
||||
|
||||
typedef struct {
|
||||
char letter;
|
||||
guint32 value;
|
||||
} name_resolve_opt_t;
|
||||
|
||||
static name_resolve_opt_t name_resolve_opt[] = {
|
||||
{ 'm', RESOLV_MAC },
|
||||
{ 'n', RESOLV_NETWORK },
|
||||
{ 't', RESOLV_TRANSPORT },
|
||||
{ 'C', RESOLV_CONCURRENT },
|
||||
};
|
||||
|
||||
#define N_NAME_RESOLVE_OPT (sizeof name_resolve_opt / sizeof name_resolve_opt[0])
|
||||
|
||||
static const char *
|
||||
name_resolve_to_string(guint32 name_resolve)
|
||||
{
|
||||
static char string[N_NAME_RESOLVE_OPT+1];
|
||||
char *p;
|
||||
unsigned int i;
|
||||
gboolean all_opts_set = TRUE;
|
||||
|
||||
if (name_resolve == RESOLV_NONE)
|
||||
return "FALSE";
|
||||
p = &string[0];
|
||||
for (i = 0; i < N_NAME_RESOLVE_OPT; i++) {
|
||||
if (name_resolve & name_resolve_opt[i].value)
|
||||
*p++ = name_resolve_opt[i].letter;
|
||||
else
|
||||
all_opts_set = FALSE;
|
||||
}
|
||||
*p = '\0';
|
||||
if (all_opts_set)
|
||||
return "TRUE";
|
||||
return string;
|
||||
}
|
||||
|
||||
char
|
||||
string_to_name_resolve(char *string, guint32 *name_resolve)
|
||||
string_to_name_resolve(char *string, e_addr_resolve *name_resolve)
|
||||
{
|
||||
char c;
|
||||
unsigned int i;
|
||||
|
||||
*name_resolve = 0;
|
||||
memset(name_resolve, 0, sizeof(e_addr_resolve));
|
||||
while ((c = *string++) != '\0') {
|
||||
for (i = 0; i < N_NAME_RESOLVE_OPT; i++) {
|
||||
if (c == name_resolve_opt[i].letter) {
|
||||
*name_resolve |= name_resolve_opt[i].value;
|
||||
break;
|
||||
switch (c) {
|
||||
case 'm':
|
||||
name_resolve->mac_name = TRUE;
|
||||
break;
|
||||
case 'n':
|
||||
name_resolve->network_name = TRUE;
|
||||
break;
|
||||
case 't':
|
||||
name_resolve->transport_name = TRUE;
|
||||
break;
|
||||
case 'C':
|
||||
name_resolve->concurrent_dns = TRUE;
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
* Unrecognized letter.
|
||||
*/
|
||||
return c;
|
||||
}
|
||||
}
|
||||
if (i == N_NAME_RESOLVE_OPT) {
|
||||
/*
|
||||
* Unrecognized letter.
|
||||
*/
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return '\0';
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
try_convert_to_custom_column(gpointer *el_data)
|
||||
{
|
||||
|
@ -2303,29 +2308,7 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_,
|
|||
pref_t *pref;
|
||||
gboolean had_a_dot;
|
||||
|
||||
if (strcmp(pref_name, PRS_PRINT_FMT) == 0) {
|
||||
if (strcmp(value, pr_formats[PR_FMT_TEXT]) == 0) {
|
||||
prefs.pr_format = PR_FMT_TEXT;
|
||||
} else if (strcmp(value, pr_formats[PR_FMT_PS]) == 0) {
|
||||
prefs.pr_format = PR_FMT_PS;
|
||||
} else {
|
||||
return PREFS_SET_SYNTAX_ERR;
|
||||
}
|
||||
} else if (strcmp(pref_name, PRS_PRINT_DEST) == 0) {
|
||||
if (strcmp(value, pr_dests[PR_DEST_CMD]) == 0) {
|
||||
prefs.pr_dest = PR_DEST_CMD;
|
||||
} else if (strcmp(value, pr_dests[PR_DEST_FILE]) == 0) {
|
||||
prefs.pr_dest = PR_DEST_FILE;
|
||||
} else {
|
||||
return PREFS_SET_SYNTAX_ERR;
|
||||
}
|
||||
} else if (strcmp(pref_name, PRS_PRINT_FILE) == 0) {
|
||||
g_free(prefs.pr_file);
|
||||
prefs.pr_file = g_strdup(value);
|
||||
} else if (strcmp(pref_name, PRS_PRINT_CMD) == 0) {
|
||||
g_free(prefs.pr_cmd);
|
||||
prefs.pr_cmd = g_strdup(value);
|
||||
} else if (strcmp(pref_name, PRS_COL_HIDDEN) == 0) {
|
||||
if (strcmp(pref_name, PRS_COL_HIDDEN) == 0) {
|
||||
g_free(cols_hidden_list);
|
||||
cols_hidden_list = g_strdup(value);
|
||||
/*
|
||||
|
@ -2681,30 +2664,6 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_,
|
|||
} else if (strcmp(pref_name, PRS_CAP_SYNTAX_CHECK_FILTER) == 0) {
|
||||
/* Obsolete preference. */
|
||||
;
|
||||
/* handle the global options */
|
||||
} else if (strcmp(pref_name, PRS_NAME_RESOLVE) == 0 ||
|
||||
strcmp(pref_name, PRS_CAP_NAME_RESOLVE) == 0) {
|
||||
/*
|
||||
* "TRUE" and "FALSE", for backwards compatibility, are synonyms for
|
||||
* RESOLV_ALL and RESOLV_NONE.
|
||||
*
|
||||
* Otherwise, we treat it as a list of name types we want to resolve.
|
||||
*/
|
||||
if (g_ascii_strcasecmp(value, "true") == 0)
|
||||
prefs.name_resolve = RESOLV_ALL;
|
||||
else if (g_ascii_strcasecmp(value, "false") == 0)
|
||||
prefs.name_resolve = RESOLV_NONE;
|
||||
else {
|
||||
prefs.name_resolve = RESOLV_NONE; /* start out with none set */
|
||||
if (string_to_name_resolve(value, &prefs.name_resolve) != '\0')
|
||||
return PREFS_SET_SYNTAX_ERR;
|
||||
}
|
||||
} else if (strcmp(pref_name, PRS_NAME_RESOLVE_CONCURRENCY) == 0) {
|
||||
prefs.name_resolve_concurrency = strtol(value, NULL, 10);
|
||||
} else if (strcmp(pref_name, PRS_NAME_RESOLVE_LOAD_SMI_MODULES) == 0) {
|
||||
prefs.load_smi_modules = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
|
||||
} else if (strcmp(pref_name, PRS_NAME_RESOLVE_SUPPRESS_SMI_ERRORS) == 0) {
|
||||
prefs.suppress_smi_errors = ((g_ascii_strcasecmp(value, "true") == 0)?TRUE:FALSE);
|
||||
} else {
|
||||
/* To which module does this preference belong? */
|
||||
module = NULL;
|
||||
|
@ -3739,63 +3698,13 @@ write_prefs(char **pf_path_return)
|
|||
fprintf(pf, PRS_CAP_SHOW_INFO ": %s\n",
|
||||
prefs.capture_show_info == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
fprintf (pf, "\n######## Printing ########\n");
|
||||
|
||||
fprintf (pf, "\n# Can be one of \"text\" or \"postscript\".\n");
|
||||
if (prefs.pr_format == default_prefs.pr_format)
|
||||
fprintf(pf, "#");
|
||||
fprintf (pf, "print.format: %s\n", pr_formats[prefs.pr_format]);
|
||||
|
||||
fprintf (pf, "\n# Can be one of \"command\" or \"file\".\n");
|
||||
if (prefs.pr_dest == default_prefs.pr_dest)
|
||||
fprintf(pf, "#");
|
||||
fprintf (pf, "print.destination: %s\n", pr_dests[prefs.pr_dest]);
|
||||
|
||||
fprintf (pf, "\n# This is the file that gets written to when the "
|
||||
"destination is set to \"file\"\n");
|
||||
if (strcmp(prefs.pr_file, default_prefs.pr_file) == 0)
|
||||
fprintf(pf, "#");
|
||||
fprintf (pf, "%s: %s\n", PRS_PRINT_FILE, prefs.pr_file);
|
||||
|
||||
fprintf (pf, "\n# Output gets piped to this command when the destination "
|
||||
"is set to \"command\"\n");
|
||||
if (strcmp(prefs.pr_cmd, default_prefs.pr_cmd) == 0)
|
||||
fprintf(pf, "#");
|
||||
fprintf (pf, "%s: %s\n", PRS_PRINT_CMD, prefs.pr_cmd);
|
||||
|
||||
fprintf(pf, "\n####### Name Resolution ########\n");
|
||||
|
||||
fprintf(pf, "\n# Resolve addresses to names?\n");
|
||||
fprintf(pf, "# TRUE or FALSE (case-insensitive), or a list of address types to resolve.\n");
|
||||
if (prefs.name_resolve == default_prefs.name_resolve)
|
||||
fprintf(pf, "#");
|
||||
fprintf(pf, PRS_NAME_RESOLVE ": %s\n",
|
||||
name_resolve_to_string(prefs.name_resolve));
|
||||
|
||||
fprintf(pf, "\n# Name resolution concurrency.\n");
|
||||
fprintf(pf, "# A decimal number.\n");
|
||||
if (prefs.name_resolve_concurrency == default_prefs.name_resolve_concurrency)
|
||||
fprintf(pf, "#");
|
||||
fprintf(pf, PRS_NAME_RESOLVE_CONCURRENCY ": %d\n",
|
||||
prefs.name_resolve_concurrency);
|
||||
|
||||
fprintf(pf, "\n# Load SMI modules?\n");
|
||||
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
|
||||
if (prefs.load_smi_modules == default_prefs.load_smi_modules)
|
||||
fprintf(pf, "#");
|
||||
fprintf(pf, PRS_NAME_RESOLVE_LOAD_SMI_MODULES ": %s\n",
|
||||
prefs.load_smi_modules == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
fprintf(pf, "\n# Suppress SMI errors?\n");
|
||||
fprintf(pf, "# TRUE or FALSE (case-insensitive).\n");
|
||||
if (prefs.suppress_smi_errors == default_prefs.suppress_smi_errors)
|
||||
fprintf(pf, "#");
|
||||
fprintf(pf, PRS_NAME_RESOLVE_SUPPRESS_SMI_ERRORS ": %s\n",
|
||||
prefs.suppress_smi_errors == TRUE ? "TRUE" : "FALSE");
|
||||
|
||||
/*
|
||||
* XXX - The following members are intentionally not written here because
|
||||
* they are handled within the 'generic' preference handling:
|
||||
* pr_format
|
||||
* pr_dest
|
||||
* pr_file
|
||||
* pr_cmd
|
||||
* tap_update_interval
|
||||
* rtp_player_max_visible
|
||||
*/
|
||||
|
@ -3842,8 +3751,6 @@ copy_prefs(e_prefs *dest, e_prefs *src)
|
|||
fmt_data *src_cfmt, *dest_cfmt;
|
||||
GList *entry;
|
||||
|
||||
dest->pr_format = src->pr_format;
|
||||
dest->pr_dest = src->pr_dest;
|
||||
dest->pr_file = g_strdup(src->pr_file);
|
||||
dest->pr_cmd = g_strdup(src->pr_cmd);
|
||||
dest->col_list = NULL;
|
||||
|
@ -3917,11 +3824,12 @@ copy_prefs(e_prefs *dest, e_prefs *src)
|
|||
dest->capture_real_time = src->capture_real_time;
|
||||
dest->capture_auto_scroll = src->capture_auto_scroll;
|
||||
dest->capture_show_info = src->capture_show_info;
|
||||
dest->name_resolve = src->name_resolve;
|
||||
dest->name_resolve_concurrency = src->name_resolve_concurrency;
|
||||
|
||||
/*
|
||||
* XXX - The following members are intentionally not copied because they
|
||||
* are handled within the 'generic' preference handling:
|
||||
* pr_format
|
||||
* pr_dest
|
||||
* tap_update_interval
|
||||
* rtp_player_max_visible
|
||||
* display_hidden_proto_items
|
||||
|
|
|
@ -35,6 +35,7 @@ extern "C" {
|
|||
|
||||
#include <epan/params.h>
|
||||
#include <epan/range.h>
|
||||
#include <epan/addr_resolv.h>
|
||||
|
||||
#define PR_DEST_CMD 0
|
||||
#define PR_DEST_FILE 1
|
||||
|
@ -54,7 +55,7 @@ extern "C" {
|
|||
* Set "*name_resolve" to the bitmask, and return '\0', on success;
|
||||
* return the bad character in the string on error.
|
||||
*/
|
||||
char string_to_name_resolve(char *string, guint32 *name_resolve);
|
||||
char string_to_name_resolve(char *string, e_addr_resolve *name_resolve);
|
||||
|
||||
/*
|
||||
* Modes for the starting directory in File Open dialogs.
|
||||
|
@ -153,10 +154,6 @@ typedef struct _e_prefs {
|
|||
layout_pane_content_e gui_layout_content_2;
|
||||
layout_pane_content_e gui_layout_content_3;
|
||||
gint console_log_level;
|
||||
guint32 name_resolve;
|
||||
gint name_resolve_concurrency;
|
||||
gboolean load_smi_modules;
|
||||
gboolean suppress_smi_errors;
|
||||
gchar *capture_device;
|
||||
gchar *capture_devices_linktypes;
|
||||
gchar *capture_devices_descr;
|
||||
|
|
10
rawshark.c
10
rawshark.c
|
@ -542,9 +542,6 @@ main(int argc, char *argv[])
|
|||
pf_path = NULL;
|
||||
}
|
||||
|
||||
/* Set the name resolution code's flags from the preferences. */
|
||||
gbl_resolv_flags = prefs_p->name_resolve;
|
||||
|
||||
/* Read the disabled protocols file. */
|
||||
read_disabled_protos_list(&gdp_path, &gdp_open_errno, &gdp_read_errno,
|
||||
&dp_path, &dp_open_errno, &dp_read_errno);
|
||||
|
@ -619,11 +616,12 @@ main(int argc, char *argv[])
|
|||
line_buffered = TRUE;
|
||||
break;
|
||||
case 'n': /* No name resolution */
|
||||
gbl_resolv_flags = RESOLV_NONE;
|
||||
gbl_resolv_flags.mac_name = FALSE;
|
||||
gbl_resolv_flags.network_name = FALSE;
|
||||
gbl_resolv_flags.transport_name = FALSE;
|
||||
gbl_resolv_flags.concurrent_dns = FALSE;
|
||||
break;
|
||||
case 'N': /* Select what types of addresses/port #s to resolve */
|
||||
if (gbl_resolv_flags == RESOLV_ALL)
|
||||
gbl_resolv_flags = RESOLV_NONE;
|
||||
badopt = string_to_name_resolve(optarg, &gbl_resolv_flags);
|
||||
if (badopt != '\0') {
|
||||
cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'",
|
||||
|
|
19
tshark.c
19
tshark.c
|
@ -1045,9 +1045,6 @@ main(int argc, char *argv[])
|
|||
pf_path = NULL;
|
||||
}
|
||||
|
||||
/* Set the name resolution code's flags from the preferences. */
|
||||
gbl_resolv_flags = prefs_p->name_resolve;
|
||||
|
||||
/* Read the disabled protocols file. */
|
||||
read_disabled_protos_list(&gdp_path, &gdp_open_errno, &gdp_read_errno,
|
||||
&dp_path, &dp_open_errno, &dp_read_errno);
|
||||
|
@ -1215,11 +1212,12 @@ main(int argc, char *argv[])
|
|||
#endif
|
||||
break;
|
||||
case 'n': /* No name resolution */
|
||||
gbl_resolv_flags = RESOLV_NONE;
|
||||
gbl_resolv_flags.mac_name = FALSE;
|
||||
gbl_resolv_flags.network_name = FALSE;
|
||||
gbl_resolv_flags.transport_name = FALSE;
|
||||
gbl_resolv_flags.concurrent_dns = FALSE;
|
||||
break;
|
||||
case 'N': /* Select what types of addresses/port #s to resolve */
|
||||
if (gbl_resolv_flags == RESOLV_ALL)
|
||||
gbl_resolv_flags = RESOLV_NONE;
|
||||
badopt = string_to_name_resolve(optarg, &gbl_resolv_flags);
|
||||
if (badopt != '\0') {
|
||||
cmdarg_err("-N specifies unknown resolving option '%c';",
|
||||
|