path: root/ui/tap_export_pdu.c
diff options
authorGuy Harris <guy@alum.mit.edu>2016-07-14 16:01:57 -0700
committerGuy Harris <guy@alum.mit.edu>2016-07-14 23:02:39 +0000
commit1f8999bb96018446e48529e75e56bf17dd3c77cf (patch)
tree0103d875702fa1a7c64816e21e079d7ceee190c2 /ui/tap_export_pdu.c
parent42e72d529cdbab62d52a26332985ecf28b997a87 (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 'ui/tap_export_pdu.c')
1 files changed, 12 insertions, 12 deletions
diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c
index a151e72567..02cd3df33f 100644
--- a/ui/tap_export_pdu.c
+++ b/ui/tap_export_pdu.c
@@ -102,10 +102,10 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
int err;
/* pcapng defs */
- wtap_optionblock_t shb_hdr;
- GArray *shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
+ wtap_block_t shb_hdr;
+ GArray *shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
wtapng_iface_descriptions_t *idb_inf;
- wtap_optionblock_t int_data;
+ wtap_block_t int_data;
wtapng_if_descr_mandatory_t *int_data_mand;
GString *os_info_str;
gsize opt_len;
@@ -114,10 +114,10 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
os_info_str = g_string_new("");
- shb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
+ shb_hdr = wtap_block_create(WTAP_BLOCK_NG_SECTION);
/* options */
- wtap_optionblock_set_option_string(shb_hdr, OPT_COMMENT, comment, strlen(comment));
+ wtap_block_add_string_option(shb_hdr, OPT_COMMENT, comment, strlen(comment));
@@ -125,27 +125,27 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
* this section.
opt_len = os_info_str->len;
- wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE), opt_len);
+ wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE), opt_len);
* UTF-8 string containing the name of the application used to create
* this section.
- wtap_optionblock_set_option_string_format(shb_hdr, OPT_SHB_USERAPPL, "Wireshark %s", get_ws_vcs_version_info());
+ wtap_block_add_string_option_format(shb_hdr, OPT_SHB_USERAPPL, "Wireshark %s", get_ws_vcs_version_info());
/* Create fake IDB info */
idb_inf = g_new(wtapng_iface_descriptions_t,1);
- idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
+ idb_inf->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
/* create the fake interface data */
- int_data = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
- int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(int_data);
+ int_data = wtap_block_create(WTAP_BLOCK_IF_DESCR);
+ int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
int_data_mand->wtap_encap = WTAP_ENCAP_WIRESHARK_UPPER_PDU;
int_data_mand->time_units_per_second = 1000000000; /* default nanosecond resolution */
int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(WTAP_ENCAP_WIRESHARK_UPPER_PDU);
int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE;
- wtap_optionblock_set_option_string(int_data, OPT_IDB_NAME, "Fake IF, PDU->Export", strlen("Fake IF, PDU->Export"));
- wtap_optionblock_set_option_uint8(int_data, OPT_IDB_TSRESOL, 9);
+ wtap_block_add_string_option(int_data, OPT_IDB_NAME, "Fake IF, PDU->Export", strlen("Fake IF, PDU->Export"));
+ wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 9);
g_array_append_val(idb_inf->interface_data, int_data);