aboutsummaryrefslogtreecommitdiffstats
path: root/tshark.c
diff options
context:
space:
mode:
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 /tshark.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 'tshark.c')
-rw-r--r--tshark.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/tshark.c b/tshark.c
index 58f1765028..8fac691195 100644
--- a/tshark.c
+++ b/tshark.c
@@ -2877,10 +2877,10 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
nrb_hdrs = wtap_file_get_nrb_for_new_file(cf->wth);
/* If we don't have an application name add Tshark */
- wtap_optionblock_get_option_string(g_array_index(shb_hdrs, wtap_optionblock_t, 0), OPT_SHB_USERAPPL, &shb_user_appl);
- if (shb_user_appl == NULL) {
- /* this is free'd by wtap_optionblock_free() later */
- wtap_optionblock_set_option_string_format(g_array_index(shb_hdrs, wtap_optionblock_t, 0), OPT_SHB_USERAPPL, "TShark (Wireshark) %s", get_ws_vcs_version_info());
+ if (wtap_block_get_string_option_value(g_array_index(shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, &shb_user_appl) != WTAP_OPTTYPE_SUCCESS ||
+ shb_user_appl == NULL) {
+ /* this is free'd by wtap_block_free() later */
+ wtap_block_add_string_option_format(g_array_index(shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, "TShark (Wireshark) %s", get_ws_vcs_version_info());
}
if (linktype != WTAP_ENCAP_PER_PACKET &&
@@ -3121,8 +3121,8 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
break;
}
wtap_dump_close(pdh, &err);
- wtap_optionblock_array_free(shb_hdrs);
- wtap_optionblock_array_free(nrb_hdrs);
+ wtap_block_array_free(shb_hdrs);
+ wtap_block_array_free(nrb_hdrs);
exit(2);
}
}
@@ -3236,8 +3236,8 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
break;
}
wtap_dump_close(pdh, &err);
- wtap_optionblock_array_free(shb_hdrs);
- wtap_optionblock_array_free(nrb_hdrs);
+ wtap_block_array_free(shb_hdrs);
+ wtap_block_array_free(nrb_hdrs);
exit(2);
}
}
@@ -3353,8 +3353,8 @@ out:
cf->wth = NULL;
g_free(save_file_string);
- wtap_optionblock_array_free(shb_hdrs);
- wtap_optionblock_array_free(nrb_hdrs);
+ wtap_block_array_free(shb_hdrs);
+ wtap_block_array_free(nrb_hdrs);
return err;
}