diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-07-14 16:01:57 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-07-14 23:02:39 +0000 |
commit | 1f8999bb96018446e48529e75e56bf17dd3c77cf (patch) | |
tree | 0103d875702fa1a7c64816e21e079d7ceee190c2 /summary.c | |
parent | 42e72d529cdbab62d52a26332985ecf28b997a87 (diff) |
Redo the block options APIs.
A block can have zero or more instances of a given option. We
distinguish between "one instance only" options, where a block can have
zero or one instance, and "multiple instances allowed" options, where a
block can have zero or more instances.
For "one instance only" options:
"add" routines add an instance if there isn't one already
and fail if there is;
"set" routines add an instance if there isn't one already
and change the value of the existing instance if there is one;
"set nth" routines fail;
"get" routines return the value of the instance if there is one
and fail if there isn't;
"get nth" routines fail.
For "multiple instances allowed" options:
"add" routines add an instance;
"set" routines fail;
"set nth" routines set the value of the nth instance if there is
one and fail otherwise;
"get" routines fail;
"get nth" routines get the value if the nth instance if there is
one and fail otherwise.
Rename "optionblock" to just "block"; it describes the contents of a
block, including both mandatory items and options.
Add some support for NRB options, including IPv4 and IPv6 option types.
Change-Id: Iad184f668626c3d1498b2ed00c7f1672e4abf52e
Reviewed-on: https://code.wireshark.org/review/16444
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'summary.c')
-rw-r--r-- | summary.c | 39 |
1 files changed, 25 insertions, 14 deletions
@@ -110,9 +110,9 @@ summary_fill_in(capture_file *cf, summary_tally *st) iface_options iface; guint i; wtapng_iface_descriptions_t* idb_info; - wtap_optionblock_t wtapng_if_descr; + wtap_block_t wtapng_if_descr; wtapng_if_descr_mandatory_t *wtapng_if_descr_mand; - wtap_optionblock_t if_stats; + wtap_block_t if_stats; guint64 isb_ifdrop; char* if_string; wtapng_if_descr_filter_t* if_filter; @@ -163,14 +163,23 @@ summary_fill_in(capture_file *cf, summary_tally *st) st->ifaces = g_array_new(FALSE, FALSE, sizeof(iface_options)); idb_info = wtap_file_get_idb_info(cf->wth); for (i = 0; i < idb_info->interface_data->len; i++) { - wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_optionblock_t, i); - wtapng_if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(wtapng_if_descr); - wtap_optionblock_get_option_custom(wtapng_if_descr, OPT_IDB_FILTER, (void**)&if_filter); - iface.cfilter = g_strdup(if_filter->if_filter_str); - wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_NAME, &if_string); - iface.name = g_strdup(if_string); - wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_DESCR, &if_string); - iface.descr = g_strdup(if_string); + wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_block_t, i); + wtapng_if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(wtapng_if_descr); + if (wtap_block_get_custom_option_value(wtapng_if_descr, OPT_IDB_FILTER, (void**)&if_filter) == WTAP_OPTTYPE_SUCCESS) { + iface.cfilter = g_strdup(if_filter->if_filter_str); + } else { + iface.cfilter = NULL; + } + if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_NAME, &if_string) == WTAP_OPTTYPE_SUCCESS) { + iface.name = g_strdup(if_string); + } else { + iface.name = NULL; + } + if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_DESCR, &if_string) == WTAP_OPTTYPE_SUCCESS) { + iface.descr = g_strdup(if_string); + } else { + iface.descr = NULL; + } iface.drops_known = FALSE; iface.drops = 0; iface.snap = wtapng_if_descr_mand->snap_len; @@ -179,14 +188,16 @@ summary_fill_in(capture_file *cf, summary_tally *st) iface.isb_comment = NULL; if(wtapng_if_descr_mand->num_stat_entries == 1){ /* dumpcap only writes one ISB, only handle that for now */ - if_stats = g_array_index(wtapng_if_descr_mand->interface_statistics, wtap_optionblock_t, 0); - wtap_optionblock_get_option_uint64(if_stats, OPT_ISB_IFDROP, &isb_ifdrop); - if (isb_ifdrop != G_GUINT64_CONSTANT(0xFFFFFFFFFFFFFFFF)) { + if_stats = g_array_index(wtapng_if_descr_mand->interface_statistics, wtap_block_t, 0); + if (wtap_block_get_uint64_option_value(if_stats, OPT_ISB_IFDROP, &isb_ifdrop) == WTAP_OPTTYPE_SUCCESS) { iface.drops_known = TRUE; iface.drops = isb_ifdrop; } /* XXX: this doesn't get used, and might need to be g_strdup'ed when it does */ - wtap_optionblock_get_option_string(if_stats, OPT_COMMENT, &iface.isb_comment); + /* XXX - support multiple comments */ + if (wtap_block_get_nth_string_option_value(if_stats, OPT_COMMENT, 0, &iface.isb_comment) != WTAP_OPTTYPE_SUCCESS) { + iface.isb_comment = NULL; + } } g_array_append_val(st->ifaces, iface); } |