diff options
Diffstat (limited to 'writecap')
-rw-r--r-- | writecap/pcapio.c | 21 | ||||
-rw-r--r-- | writecap/pcapio.h | 4 |
2 files changed, 17 insertions, 8 deletions
diff --git a/writecap/pcapio.c b/writecap/pcapio.c index 14e4d7f31b..124531de9c 100644 --- a/writecap/pcapio.c +++ b/writecap/pcapio.c @@ -307,7 +307,7 @@ pcapng_write_block(FILE* pfile, gboolean pcapng_write_section_header_block(FILE* pfile, - const char *comment, + GPtrArray *comments, const char *hw, const char *os, const char *appname, @@ -324,13 +324,17 @@ pcapng_write_section_header_block(FILE* pfile, block_total_length = sizeof(struct shb) + sizeof(guint32); options_length = 0; - options_length += pcapng_count_string_option(comment); + if (comments != NULL) { + for (guint i = 0; i < comments->len; i++) { + options_length += pcapng_count_string_option((char *)g_ptr_array_index(comments, i)); + } + } options_length += pcapng_count_string_option(hw); options_length += pcapng_count_string_option(os); options_length += pcapng_count_string_option(appname); /* If we have options add size of end-of-options */ if (options_length != 0) { - options_length += (guint32)sizeof(struct option); + options_length += (guint32)sizeof(struct option); } block_total_length += options_length; @@ -345,9 +349,14 @@ pcapng_write_section_header_block(FILE* pfile, if (!write_to_file(pfile, (const guint8*)&shb, sizeof(struct shb), bytes_written, err)) return FALSE; - if (!pcapng_write_string_option(pfile, OPT_COMMENT, comment, - bytes_written, err)) - return FALSE; + if (comments != NULL) { + for (guint i = 0; i < comments->len; i++) { + if (!pcapng_write_string_option(pfile, OPT_COMMENT, + (char *)g_ptr_array_index(comments, i), + bytes_written, err)) + return FALSE; + } + } if (!pcapng_write_string_option(pfile, SHB_HARDWARE, hw, bytes_written, err)) return FALSE; diff --git a/writecap/pcapio.h b/writecap/pcapio.h index 065e04877b..72df645a76 100644 --- a/writecap/pcapio.h +++ b/writecap/pcapio.h @@ -44,8 +44,8 @@ pcapng_write_block(FILE* pfile, */ extern gboolean pcapng_write_section_header_block(FILE* pfile, /**< Write information */ - const char *comment, /**< Comment on the section, Optinon 1 opt_comment - * A UTF-8 string containing a comment that is associated to the current block. + GPtrArray *comments, /**< Comments on the section, Optinon 1 opt_comment + * UTF-8 strings containing comments that areassociated to the current block. */ const char *hw, /**< HW, Optinon 2 shb_hardware * An UTF-8 string containing the description of the hardware used to create this section. |