From 1fe3ed4940f7e4016871d88993722f347c48ad0f Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 19 Jun 2021 15:30:21 -0700 Subject: [PATCH] erf: fix a comment to match reality. It's not that Wireshark only supports one copy of some block options, it's that *the pcapng specification* only supports one instance of some block options, and it's not that wtap_block_set_*_value() fails on non-string values, it's that the set_XXX_option_value routines currently only support changing the value of an existing option, not adding a new instance of an option - the latter requires the add_XXX_option_value routine. --- wiretap/erf.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/wiretap/erf.c b/wiretap/erf.c index c9114e81fe..9c7f23b819 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -3274,10 +3274,31 @@ static int populate_summary_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo_h * Since wireshark doesn't have a concept of different summary metadata * over time, skip the record if metadata is older than what we already have. */ - /* TODO: This doesn't work very well for some tags that wireshark only - * supports one copy of, we'll only end up with the first one. - * wtap_block_set_*_value() currently fails on WTAP_OPTTYPE_NOT_FOUND - * for everything except strings. + /* TODO: This doesn't work very well for some tags that map to + * pcapng options where the pcapng specification only allows one + * instance per block, which is the case for most options. The + * only current exxceptions are: + * + * comments; + * IPv4 and IPv6 addresses for an interface; + * hash values for a packet; + * custom options. + * + * For options where only one instance is allowed per block, + * wtap_block_add_XXX_option() is currently used to add a new + * instance of an option to a block that has no instance (it + * fails if there's already an instance), and + * wtap_block_set_XXX_optin() is currently used to change the + * value of an option in a block that has one instance (it fails + * if there isn't already an instance). + * + * For options where more than one instance is allowed per block, + * wtap_block_add_XXX_option() is used to add a new instance to + * a block, no matter how many instances it currently has, and + * wtap_block_set_nth_XXX_option() is used to change the value + * of the Nth instance of an option in a block (the block must + * *have* an Nth instance). + * * Currently we only particularly care about updating the capture comment * and a few counters anyway. */