Add data structures necessary to support multiple Section Header blocks.

This doesn't try to use any data from multiple Section Header blocks, it
just converts single Section Header block usage into a GArray, so the
potential is there to then use/support multiple Section Header blocks
within a file format (like pcapng)

Change-Id: I6ad1f7b8daf4b1ad7ba0eb1ecf2e170421505486
Reviewed-on: https://code.wireshark.org/review/15636
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Michael Mann 2016-05-30 23:42:41 -04:00
parent bd932bb2e1
commit 6fa77a6acb
19 changed files with 182 additions and 145 deletions

View File

@ -905,7 +905,7 @@ failure_message(const char *msg_format _U_, va_list ap _U_)
static wtap_dumper *
editcap_dump_open(const char *filename, guint32 snaplen,
wtap_optionblock_t shb_hdr,
GArray* shb_hdrs,
wtapng_iface_descriptions_t *idb_inf,
wtap_optionblock_t nrb_hdr, int *write_err)
{
@ -915,13 +915,11 @@ editcap_dump_open(const char *filename, guint32 snaplen,
/* Write to the standard output. */
pdh = wtap_dump_open_stdout_ng(out_file_type_subtype, out_frame_type,
snaplen, FALSE /* compressed */,
shb_hdr, idb_inf, nrb_hdr,
write_err);
shb_hdrs, idb_inf, nrb_hdr, write_err);
} else {
pdh = wtap_dump_open_ng(filename, out_file_type_subtype, out_frame_type,
snaplen, FALSE /* compressed */,
shb_hdr, idb_inf, nrb_hdr,
write_err);
shb_hdrs, idb_inf, nrb_hdr, write_err);
}
return pdh;
}
@ -967,7 +965,7 @@ main(int argc, char *argv[])
const struct wtap_pkthdr *phdr;
struct wtap_pkthdr temp_phdr;
wtapng_iface_descriptions_t *idb_inf = NULL;
wtap_optionblock_t shb_hdr = NULL;
GArray *shb_hdrs = NULL;
wtap_optionblock_t nrb_hdr = NULL;
char *shb_user_appl;
@ -1330,7 +1328,7 @@ main(int argc, char *argv[])
wtap_file_type_subtype_string(wtap_file_type_subtype(wth)));
}
shb_hdr = wtap_file_get_shb_for_new_file(wth);
shb_hdrs = wtap_file_get_shb_for_new_file(wth);
idb_inf = wtap_file_get_idb_info(wth);
nrb_hdr = wtap_file_get_nrb_for_new_file(wth);
@ -1380,14 +1378,14 @@ main(int argc, char *argv[])
g_assert(filename);
/* If we don't have an application name add Editcap */
wtap_optionblock_get_option_string(shb_hdr, OPT_SHB_USERAPPL, &shb_user_appl);
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) {
wtap_optionblock_set_option_string_format(shb_hdr, OPT_SHB_USERAPPL, "Editcap " VERSION);
wtap_optionblock_set_option_string_format(g_array_index(shb_hdrs, wtap_optionblock_t, 0), OPT_SHB_USERAPPL, "Editcap " VERSION);
}
pdh = editcap_dump_open(filename,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
shb_hdr, idb_inf, nrb_hdr, &write_err);
shb_hdrs, idb_inf, nrb_hdr, &write_err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
@ -1428,7 +1426,7 @@ main(int argc, char *argv[])
pdh = editcap_dump_open(filename,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
shb_hdr, idb_inf, nrb_hdr, &write_err);
shb_hdrs, idb_inf, nrb_hdr, &write_err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
@ -1457,7 +1455,7 @@ main(int argc, char *argv[])
pdh = editcap_dump_open(filename,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)) : wtap_snapshot_length(wth),
shb_hdr, idb_inf, nrb_hdr, &write_err);
shb_hdrs, idb_inf, nrb_hdr, &write_err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(write_err));
@ -1828,7 +1826,7 @@ main(int argc, char *argv[])
pdh = editcap_dump_open(filename,
snaplen ? MIN(snaplen, wtap_snapshot_length(wth)): wtap_snapshot_length(wth),
shb_hdr, idb_inf, nrb_hdr, &write_err);
shb_hdrs, idb_inf, nrb_hdr, &write_err);
if (pdh == NULL) {
fprintf(stderr, "editcap: Can't open or create %s: %s\n",
filename, wtap_strerror(write_err));
@ -1844,8 +1842,8 @@ main(int argc, char *argv[])
wtap_strerror(write_err));
goto error_on_exit;
}
wtap_optionblock_free(shb_hdr);
shb_hdr = NULL;
wtap_optionblock_array_free(shb_hdrs);
shb_hdrs = NULL;
wtap_optionblock_free(nrb_hdr);
nrb_hdr = NULL;
g_free(filename);
@ -1870,7 +1868,7 @@ main(int argc, char *argv[])
return 0;
error_on_exit:
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_optionblock_free(nrb_hdr);
g_free(idb_inf);
exit(2);

View File

@ -557,8 +557,10 @@ extern int wslua_set__index(lua_State *L);
#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(C,name,member,option) \
WSLUA_ATTRIBUTE_GET(C,name, { \
char* str; \
wtap_optionblock_get_option_string(obj->member, option, &str); \
lua_pushstring(L,str); /* this pushes nil if obj->member is null */ \
if ((obj->member) && (obj->member->len > 0)) { \
wtap_optionblock_get_option_string(g_array_index(obj->member, wtap_optionblock_t, 0), option, &str); \
lua_pushstring(L,str); /* this pushes nil if obj->member is null */ \
} \
})
#define WSLUA_ATTRIBUTE_SET(C,name,block) \
@ -618,7 +620,9 @@ extern int wslua_set__index(lua_State *L);
} else { \
return luaL_error(L, "%s's attribute `%s' must be a string or nil", #C , #field ); \
} \
wtap_optionblock_set_option_string(obj->member, option, s, strlen(s)); \
if ((obj->member) && (obj->member->len > 0)) { \
wtap_optionblock_set_option_string(g_array_index(obj->member, wtap_optionblock_t, 0), option, s, strlen(s)); \
} \
g_free(s); \
return 0; \
} \

View File

@ -112,23 +112,23 @@ WSLUA_ATTRIBUTE_NAMED_NUMBER_SETTER(CaptureInfo,snapshot_length,wth->snapshot_le
/* WSLUA_ATTRIBUTE CaptureInfo_comment RW A string comment for the whole capture file,
or nil if there is no `comment`. */
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,comment,wth->shb_hdr,OPT_COMMENT);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,comment,wth->shb_hdr,OPT_COMMENT);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,comment,wth->shb_hdrs,OPT_COMMENT);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,comment,wth->shb_hdrs,OPT_COMMENT);
/* WSLUA_ATTRIBUTE CaptureInfo_hardware RW A string containing the description of
the hardware used to create the capture, or nil if there is no `hardware` string. */
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,hardware,wth->shb_hdr,OPT_SHB_HARDWARE);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,hardware,wth->shb_hdr,OPT_SHB_HARDWARE);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,hardware,wth->shb_hdrs,OPT_SHB_HARDWARE);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,hardware,wth->shb_hdrs,OPT_SHB_HARDWARE);
/* WSLUA_ATTRIBUTE CaptureInfo_os RW A string containing the name of
the operating system used to create the capture, or nil if there is no `os` string. */
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,os,wth->shb_hdr,OPT_SHB_OS);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,os,wth->shb_hdr,OPT_SHB_OS);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,os,wth->shb_hdrs,OPT_SHB_OS);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,os,wth->shb_hdrs,OPT_SHB_OS);
/* WSLUA_ATTRIBUTE CaptureInfo_user_app RW A string containing the name of
the application used to create the capture, or nil if there is no `user_app` string. */
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,user_app,wth->shb_hdr,OPT_SHB_USERAPPL);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,user_app,wth->shb_hdr,OPT_SHB_USERAPPL);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfo,user_app,wth->shb_hdrs,OPT_SHB_USERAPPL);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,user_app,wth->shb_hdrs,OPT_SHB_USERAPPL);
/* WSLUA_ATTRIBUTE CaptureInfo_hosts WO Sets resolved ip-to-hostname information.
@ -355,19 +355,19 @@ WSLUA_ATTRIBUTE_NAMED_NUMBER_GETTER(CaptureInfoConst,encap,wdh->encap);
/* WSLUA_ATTRIBUTE CaptureInfoConst_comment RW A comment for the whole capture file, if the
`wtap_presence_flags.COMMENTS` was set in the presence flags; nil if there is no comment. */
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,comment,wth->shb_hdr,OPT_COMMENT);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,comment,wth->shb_hdrs,OPT_COMMENT);
/* WSLUA_ATTRIBUTE CaptureInfoConst_hardware RO A string containing the description of
the hardware used to create the capture, or nil if there is no hardware string. */
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,hardware,wth->shb_hdr,OPT_SHB_HARDWARE);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,hardware,wth->shb_hdrs,OPT_SHB_HARDWARE);
/* WSLUA_ATTRIBUTE CaptureInfoConst_os RO A string containing the name of
the operating system used to create the capture, or nil if there is no os string. */
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,os,wth->shb_hdr,OPT_SHB_OS);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,os,wth->shb_hdrs,OPT_SHB_OS);
/* WSLUA_ATTRIBUTE CaptureInfoConst_user_app RO A string containing the name of
the application used to create the capture, or nil if there is no user_app string. */
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,user_app,wth->shb_hdr,OPT_SHB_USERAPPL);
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_GETTER(CaptureInfoConst,user_app,wth->shb_hdrs,OPT_SHB_USERAPPL);
/* WSLUA_ATTRIBUTE CaptureInfoConst_hosts RO A ip-to-hostname Lua table of two key-ed names: `ipv4_addresses` and `ipv6_addresses`.
The value of each of these names are themselves array tables, of key-ed tables, such that the inner table has a key

16
file.c
View File

@ -4489,13 +4489,13 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
or moving the capture file, we have to do it by writing the packets
out in Wiretap. */
wtap_optionblock_t shb_hdr = NULL;
GArray *shb_hdrs = NULL;
wtapng_iface_descriptions_t *idb_inf = NULL;
wtap_optionblock_t nrb_hdr = NULL;
int encap;
/* XXX: what free's this shb_hdr? */
shb_hdr = wtap_file_get_shb_for_new_file(cf->wth);
shb_hdrs = wtap_file_get_shb_for_new_file(cf->wth);
idb_inf = wtap_file_get_idb_info(cf->wth);
nrb_hdr = wtap_file_get_nrb_for_new_file(cf->wth);
@ -4512,10 +4512,10 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format,
from which we're reading the packets that we're writing!) */
fname_new = g_strdup_printf("%s~", fname);
pdh = wtap_dump_open_ng(fname_new, save_format, encap, cf->snap,
compressed, shb_hdr, idb_inf, nrb_hdr, &err);
compressed, shb_hdrs, idb_inf, nrb_hdr, &err);
} else {
pdh = wtap_dump_open_ng(fname, save_format, encap, cf->snap,
compressed, shb_hdr, idb_inf, nrb_hdr, &err);
compressed, shb_hdrs, idb_inf, nrb_hdr, &err);
}
g_free(idb_inf);
idb_inf = NULL;
@ -4712,7 +4712,7 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
int err;
wtap_dumper *pdh;
save_callback_args_t callback_args;
wtap_optionblock_t shb_hdr = NULL;
GArray *shb_hdrs = NULL;
wtapng_iface_descriptions_t *idb_inf = NULL;
wtap_optionblock_t nrb_hdr = NULL;
int encap;
@ -4727,7 +4727,7 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
and then write it out if it's one of the specified ones. */
/* XXX: what free's this shb_hdr? */
shb_hdr = wtap_file_get_shb_for_new_file(cf->wth);
shb_hdrs = wtap_file_get_shb_for_new_file(cf->wth);
idb_inf = wtap_file_get_idb_info(cf->wth);
nrb_hdr = wtap_file_get_nrb_for_new_file(cf->wth);
@ -4744,10 +4744,10 @@ cf_export_specified_packets(capture_file *cf, const char *fname,
from which we're reading the packets that we're writing!) */
fname_new = g_strdup_printf("%s~", fname);
pdh = wtap_dump_open_ng(fname_new, save_format, encap, cf->snap,
compressed, shb_hdr, idb_inf, nrb_hdr, &err);
compressed, shb_hdrs, idb_inf, nrb_hdr, &err);
} else {
pdh = wtap_dump_open_ng(fname, save_format, encap, cf->snap,
compressed, shb_hdr, idb_inf, nrb_hdr, &err);
compressed, shb_hdrs, idb_inf, nrb_hdr, &err);
}
g_free(idb_inf);
idb_inf = NULL;

View File

@ -178,7 +178,7 @@ main(int argc, char *argv[])
guint wrong_order_count = 0;
gboolean write_output_regardless = TRUE;
guint i;
wtap_optionblock_t shb_hdr = NULL;
GArray *shb_hdrs = NULL;
wtapng_iface_descriptions_t *idb_inf = NULL;
wtap_optionblock_t nrb_hdr = NULL;
@ -289,18 +289,18 @@ main(int argc, char *argv[])
}
DEBUG_PRINT("file_type_subtype is %d\n", wtap_file_type_subtype(wth));
shb_hdr = wtap_file_get_shb_for_new_file(wth);
shb_hdrs = wtap_file_get_shb_for_new_file(wth);
idb_inf = wtap_file_get_idb_info(wth);
nrb_hdr = wtap_file_get_nrb_for_new_file(wth);
/* Open outfile (same filetype/encap as input file) */
if (strcmp(outfile, "-") == 0) {
pdh = wtap_dump_open_stdout_ng(wtap_file_type_subtype(wth), wtap_file_encap(wth),
65535, FALSE, shb_hdr, idb_inf, nrb_hdr, &err);
65535, FALSE, shb_hdrs, idb_inf, nrb_hdr, &err);
outfile = "standard output";
} else {
pdh = wtap_dump_open_ng(outfile, wtap_file_type_subtype(wth), wtap_file_encap(wth),
65535, FALSE, shb_hdr, idb_inf, nrb_hdr, &err);
65535, FALSE, shb_hdrs, idb_inf, nrb_hdr, &err);
}
g_free(idb_inf);
idb_inf = NULL;
@ -308,7 +308,7 @@ main(int argc, char *argv[])
if (pdh == NULL) {
fprintf(stderr, "reordercap: Failed to open output file: (%s) - error %s\n",
outfile, wtap_strerror(err));
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_optionblock_free(nrb_hdr);
exit(1);
}
@ -382,11 +382,11 @@ main(int argc, char *argv[])
if (!wtap_dump_close(pdh, &err)) {
fprintf(stderr, "reordercap: Error closing %s: %s\n", outfile,
wtap_strerror(err));
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_optionblock_free(nrb_hdr);
exit(1);
}
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_optionblock_free(nrb_hdr);
/* Finally, close infile */

View File

@ -3233,7 +3233,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
char *save_file_string = NULL;
gboolean filtering_tap_listeners;
guint tap_flags;
wtap_optionblock_t shb_hdr = NULL;
GArray *shb_hdrs = NULL;
wtapng_iface_descriptions_t *idb_inf = NULL;
wtap_optionblock_t nrb_hdr = NULL;
struct wtap_pkthdr phdr;
@ -3265,14 +3265,14 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
}
tshark_debug("tshark: snapshot_length = %d", snapshot_length);
shb_hdr = wtap_file_get_shb_for_new_file(cf->wth);
shb_hdrs = wtap_file_get_shb_for_new_file(cf->wth);
nrb_hdr = wtap_file_get_nrb_for_new_file(cf->wth);
/* If we don't have an application name add Tshark */
wtap_optionblock_get_option_string(shb_hdr, OPT_SHB_USERAPPL, &shb_user_appl);
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(shb_hdr, OPT_SHB_USERAPPL, "TShark (Wireshark) %s", get_ws_vcs_version_info());
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 (linktype != WTAP_ENCAP_PER_PACKET &&
@ -3292,10 +3292,10 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
if (strcmp(save_file, "-") == 0) {
/* Write to the standard output. */
pdh = wtap_dump_open_stdout_ng(out_file_type, linktype,
snapshot_length, FALSE /* compressed */, shb_hdr, idb_inf, nrb_hdr, &err);
snapshot_length, FALSE /* compressed */, shb_hdrs, idb_inf, nrb_hdr, &err);
} else {
pdh = wtap_dump_open_ng(save_file, out_file_type, linktype,
snapshot_length, FALSE /* compressed */, shb_hdr, idb_inf, nrb_hdr, &err);
snapshot_length, FALSE /* compressed */, shb_hdrs, idb_inf, nrb_hdr, &err);
}
}
@ -3513,7 +3513,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
break;
}
wtap_dump_close(pdh, &err);
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_optionblock_free(nrb_hdr);
exit(2);
}
@ -3628,7 +3628,7 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
break;
}
wtap_dump_close(pdh, &err);
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_optionblock_free(nrb_hdr);
exit(2);
}
@ -3745,7 +3745,7 @@ out:
cf->wth = NULL;
g_free(save_file_string);
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_optionblock_free(nrb_hdr);
return err;

View File

@ -459,6 +459,7 @@ file_import_open(text_import_info_t *info)
/* pcapng defs */
wtap_optionblock_t shb_hdr;
GArray *shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
wtapng_iface_descriptions_t *idb_inf;
wtap_optionblock_t int_data;
wtapng_if_descr_mandatory_t *int_data_mand;
@ -500,13 +501,14 @@ file_import_open(text_import_info_t *info)
wtap_optionblock_set_option_string(int_data, OPT_IDB_NAME, "Fake IF File->Import", strlen("Fake IF File->Import"));
g_array_append_val(idb_inf->interface_data, int_data);
g_array_append_val(shb_hdrs, shb_hdr);
/* Use a random name for the temporary import buffer */
info->wdh = wtap_dump_open_tempfile_ng(&tmpname, "import",
WTAP_FILE_TYPE_SUBTYPE_PCAPNG,
info->encapsulation,
info->max_frame_length, FALSE,
shb_hdr, idb_inf, NULL, &err);
shb_hdrs, idb_inf, NULL, &err);
capfile_name = g_strdup(tmpname);
if (info->wdh == NULL) {
open_failure_alert_box(tmpname ? tmpname : "temporary file", err, TRUE);
@ -555,7 +557,7 @@ end:
g_free(info->date_timestamp_format);
g_free(info);
g_free(capfile_name);
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_free_idb_info(idb_inf);
window_destroy(file_import_dlg_w);
}

View File

@ -103,6 +103,7 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
/* pcapng defs */
wtap_optionblock_t shb_hdr;
GArray *shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
wtapng_iface_descriptions_t *idb_inf;
wtap_optionblock_t int_data;
wtapng_if_descr_mandatory_t *int_data_mand;
@ -148,9 +149,11 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
g_array_append_val(idb_inf->interface_data, int_data);
g_array_append_val(shb_hdrs, shb_hdr);
/* Use a random name for the temporary import buffer */
exp_pdu_tap_data->wdh = wtap_dump_fdopen_ng(fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, WTAP_ENCAP_WIRESHARK_UPPER_PDU, WTAP_MAX_PACKET_SIZE, FALSE,
shb_hdr, idb_inf, NULL, &err);
shb_hdrs, idb_inf, NULL, &err);
if (exp_pdu_tap_data->wdh == NULL) {
g_assert(err != 0);
return err;

View File

@ -1259,11 +1259,12 @@ static int populate_capture_host_info(erf_t *erf_priv, wtap *wth, union wtap_pse
gchar* modelcpu = NULL;
guint32 tagtotallength;
if (!wth || !state || !wth->shb_hdr)
if (!wth || !state || !wth->shb_hdrs || (wth->shb_hdrs->len == 0))
return -1;
/* XXX: wth->shb_hdr is already created by different layer, using directly for now. */
shb_hdr = wth->shb_hdr;
/* XXX: Only one section header is supported at this time */
shb_hdr = g_array_index(wth->shb_hdrs, wtap_optionblock_t, 0);
while ((tagtotallength = erf_meta_read_tag(&tag, state->tag_ptr, state->remaining_len)) && !ERF_META_IS_SECTION(tag.type)) {
switch (state->sectiontype) {

View File

@ -714,6 +714,7 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
unsigned int i;
gboolean use_stdin = FALSE;
gchar *extension;
wtap_optionblock_t shb;
*err = 0;
*err_info = NULL;
@ -833,7 +834,10 @@ wtap_open_offline(const char *filename, unsigned int type, int *err, char **err_
wth->file_tsprec = WTAP_TSPREC_USEC;
wth->priv = NULL;
wth->wslua_data = NULL;
wth->shb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
wth->shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
shb = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
if (shb)
g_array_append_val(wth->shb_hdrs, shb);
/* Initialize the array containing a list of interfaces. pcapng_open and
* erf_open needs this (and libpcap_open for ERF encapsulation types).
@ -2158,7 +2162,7 @@ static int wtap_dump_file_close(wtap_dumper *wdh);
static wtap_dumper *
wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean compressed,
wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
wtap_optionblock_t nrb_hdr, int *err)
{
wtap_dumper *wdh;
@ -2176,7 +2180,7 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co
return NULL; /* couldn't allocate it */
/* Set Section Header Block data */
wdh->shb_hdr = shb_hdr;
wdh->shb_hdrs = shb_hdrs;
/* Set Name Resolution Block data */
wdh->nrb_hdr = nrb_hdr;
/* Set Interface Description Block data */
@ -2224,7 +2228,7 @@ wtap_dump_open(const char *filename, int file_type_subtype, int encap,
wtap_dumper *
wtap_dump_open_ng(const char *filename, int file_type_subtype, int encap,
int snaplen, gboolean compressed, wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
int snaplen, gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
wtap_optionblock_t nrb_hdr, int *err)
{
wtap_dumper *wdh;
@ -2232,7 +2236,7 @@ wtap_dump_open_ng(const char *filename, int file_type_subtype, int encap,
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
shb_hdr, idb_inf, nrb_hdr, err);
shb_hdrs, idb_inf, nrb_hdr, err);
if (wdh == NULL)
return NULL;
@ -2270,7 +2274,7 @@ wtap_dumper *
wtap_dump_open_tempfile_ng(char **filenamep, const char *pfx,
int file_type_subtype, int encap,
int snaplen, gboolean compressed,
wtap_optionblock_t shb_hdr,
GArray* shb_hdrs,
wtapng_iface_descriptions_t *idb_inf,
wtap_optionblock_t nrb_hdr, int *err)
{
@ -2284,7 +2288,7 @@ wtap_dump_open_tempfile_ng(char **filenamep, const char *pfx,
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
shb_hdr, idb_inf, nrb_hdr, err);
shb_hdrs, idb_inf, nrb_hdr, err);
if (wdh == NULL)
return NULL;
@ -2329,7 +2333,7 @@ wtap_dump_fdopen(int fd, int file_type_subtype, int encap, int snaplen,
wtap_dumper *
wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int snaplen,
gboolean compressed, wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
wtap_optionblock_t nrb_hdr, int *err)
{
wtap_dumper *wdh;
@ -2337,7 +2341,7 @@ wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int snaplen,
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
shb_hdr, idb_inf, nrb_hdr, err);
shb_hdrs, idb_inf, nrb_hdr, err);
if (wdh == NULL)
return NULL;
@ -2369,7 +2373,7 @@ wtap_dump_open_stdout(int file_type_subtype, int encap, int snaplen,
wtap_dumper *
wtap_dump_open_stdout_ng(int file_type_subtype, int encap, int snaplen,
gboolean compressed, wtap_optionblock_t shb_hdr,
gboolean compressed, GArray* shb_hdrs,
wtapng_iface_descriptions_t *idb_inf,
wtap_optionblock_t nrb_hdr, int *err)
{
@ -2378,7 +2382,7 @@ wtap_dump_open_stdout_ng(int file_type_subtype, int encap, int snaplen,
/* Allocate and initialize a data structure for the output stream. */
wdh = wtap_dump_init_dumper(file_type_subtype, encap, snaplen, compressed,
shb_hdr, idb_inf, nrb_hdr, err);
shb_hdrs, idb_inf, nrb_hdr, err);
if (wdh == NULL)
return NULL;

View File

@ -330,7 +330,7 @@ wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info)
g_free(comment);
return WTAP_OPEN_NOT_MINE;
}
wtap_optionblock_set_option_string(wth->shb_hdr, OPT_COMMENT, comment, record_length);
wtap_optionblock_set_option_string(g_array_index(wth->shb_hdrs, wtap_optionblock_t, 0), OPT_COMMENT, comment, record_length);
g_free(comment);
}

View File

@ -360,10 +360,11 @@ merge_append_read_packet(int in_file_count, merge_in_file_t in_files[],
/* creates a section header block for the new output file */
static wtap_optionblock_t
static GArray*
create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
const gchar *app_name)
{
GArray *shb_hdrs;
wtap_optionblock_t shb_hdr;
GString *comment_gstr;
GString *os_info_str;
@ -372,7 +373,8 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
wtapng_mandatory_section_t* shb_data;
gsize opt_len;
shb_hdr = wtap_file_get_shb_for_new_file(in_files[0].wth);
shb_hdrs = wtap_file_get_shb_for_new_file(in_files[0].wth);
shb_hdr = g_array_index(shb_hdrs, wtap_optionblock_t, 0);
comment_gstr = g_string_new("");
@ -408,7 +410,7 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_USERAPPL, (char*)app_name, app_name ? strlen(app_name): 0 ); /* NULL if not available, UTF-8 string containing the name */
/* of the application used to create this section. */
return shb_hdr;
return shb_hdrs;
}
static gboolean
@ -885,7 +887,7 @@ merge_files(int out_fd, const gchar* out_filename, const int file_type,
struct wtap_pkthdr *phdr, snap_phdr;
int count = 0;
gboolean stop_flag = FALSE;
wtap_optionblock_t shb_hdr = NULL;
GArray *shb_hdrs = NULL;
wtapng_iface_descriptions_t *idb_inf = NULL;
g_assert(out_fd > 0);
@ -930,14 +932,14 @@ merge_files(int out_fd, const gchar* out_filename, const int file_type,
/* prepare the outfile */
if (file_type == WTAP_FILE_TYPE_SUBTYPE_PCAPNG) {
shb_hdr = create_shb_header(in_files, in_file_count, app_name);
shb_hdrs = create_shb_header(in_files, in_file_count, app_name);
merge_debug("merge_files: SHB created");
idb_inf = generate_merged_idb(in_files, in_file_count, mode);
merge_debug("merge_files: IDB merge operation complete, got %u IDBs", idb_inf ? idb_inf->interface_data->len : 0);
pdh = wtap_dump_fdopen_ng(out_fd, file_type, frame_type, snaplen,
FALSE /* compressed */, shb_hdr, idb_inf,
FALSE /* compressed */, shb_hdrs, idb_inf,
NULL, err);
}
else {
@ -947,7 +949,7 @@ merge_files(int out_fd, const gchar* out_filename, const int file_type,
if (pdh == NULL) {
merge_close_in_files(in_file_count, in_files);
g_free(in_files);
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_free_idb_info(idb_inf);
return MERGE_ERR_CANT_OPEN_OUTFILE;
}
@ -1069,7 +1071,7 @@ merge_files(int out_fd, const gchar* out_filename, const int file_type,
}
g_free(in_files);
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_free_idb_info(idb_inf);
return status;

View File

@ -213,12 +213,6 @@ nettrace_close(wtap *wth)
wtap_close(file_info->wth_tmp_file);
/*Clear the shb info, it's been freed by wtap_close*/
wtap_optionblock_set_option_string(wth->shb_hdr, OPT_COMMENT, NULL, 0);
wtap_optionblock_set_option_string(wth->shb_hdr, OPT_SHB_HARDWARE, NULL, 0);
wtap_optionblock_set_option_string(wth->shb_hdr, OPT_SHB_OS, NULL, 0);
wtap_optionblock_set_option_string(wth->shb_hdr, OPT_SHB_USERAPPL, NULL, 0);
/* delete the temp file */
ws_unlink(file_info->tmpname);
@ -715,7 +709,8 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
wtap_open_return_val result = WTAP_OPEN_MINE;
/* pcapng defs */
wtap_optionblock_t shb_hdr = NULL;
GArray *shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
wtap_optionblock_t shb_hdr;
wtapng_iface_descriptions_t *idb_inf = NULL;
wtap_optionblock_t int_data;
wtapng_if_descr_mandatory_t *int_data_mand;
@ -760,20 +755,24 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
shb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
/* options */
wtap_optionblock_set_option_string(wth->shb_hdr, OPT_COMMENT, "File converted to Exported PDU format during opening",
wtap_optionblock_set_option_string(shb_hdr, OPT_COMMENT, "File converted to Exported PDU format during opening",
strlen("File converted to Exported PDU format during opening"));
/*
* UTF-8 string containing the name of the operating system used to create
* this section.
*/
opt_len = os_info_str->len;
wtap_optionblock_set_option_string(wth->shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE), opt_len);
wtap_optionblock_set_option_string(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(wth->shb_hdr, OPT_SHB_USERAPPL, "Wireshark %s", get_ws_vcs_version_info());
wtap_optionblock_set_option_string_format(shb_hdr, OPT_SHB_USERAPPL, "Wireshark %s", get_ws_vcs_version_info());
/* Add header to the array */
g_array_append_val(shb_hdrs, shb_hdr);
/* Create fake IDB info */
idb_inf = g_new(wtapng_iface_descriptions_t, 1);
@ -793,7 +792,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
g_array_append_val(idb_inf->interface_data, int_data);
wdh_exp_pdu = wtap_dump_fdopen_ng(import_file_fd, WTAP_FILE_TYPE_SUBTYPE_PCAPNG, WTAP_ENCAP_WIRESHARK_UPPER_PDU,
WTAP_MAX_PACKET_SIZE, FALSE, shb_hdr, idb_inf, NULL, &exp_pdu_file_err);
WTAP_MAX_PACKET_SIZE, FALSE, shb_hdrs, idb_inf, NULL, &exp_pdu_file_err);
if (wdh_exp_pdu == NULL) {
result = WTAP_OPEN_ERROR;
goto end;
@ -1072,7 +1071,7 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_
end:
g_free(wrt_err_info);
g_free(packet_buf);
wtap_optionblock_free(shb_hdr);
wtap_optionblock_array_free(shb_hdrs);
wtap_free_idb_info(idb_inf);
return result;
@ -1131,7 +1130,7 @@ nettrace_3gpp_32_423_file_open(wtap *wth, int *err, gchar **err_info)
return WTAP_OPEN_ERROR;
/* Copy data from the temp file wth */
wtap_optionblock_copy_options(wth->shb_hdr, file_info->wth_tmp_file->shb_hdr);
wtap_optionblock_copy_options(g_array_index(wth->shb_hdrs, wtap_optionblock_t, 0), g_array_index(file_info->wth_tmp_file->shb_hdrs, wtap_optionblock_t, 0));
wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_NETTRACE_3GPP_32_423;
wth->file_encap = file_info->wth_tmp_file->file_encap;

View File

@ -2487,7 +2487,7 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
* some other type of file, so we can't return WTAP_OPEN_NOT_MINE
* past this point.
*/
wtap_optionblock_copy_options(wth->shb_hdr, wblock.block);
wtap_optionblock_copy_options(g_array_index(wth->shb_hdrs, wtap_optionblock_t, 0), wblock.block);
wth->file_encap = WTAP_ENCAP_UNKNOWN;
wth->snapshot_length = 0;
@ -2841,14 +2841,19 @@ pcapng_write_section_header_block(wtap_dumper *wdh, int *err)
pcapng_section_header_block_t shb;
pcapng_optionblock_size_t block_size;
struct pcapng_option_header option_hdr;
wtap_optionblock_t wdh_shb = NULL;
if (wdh->shb_hdrs && (wdh->shb_hdrs->len > 0)) {
wdh_shb = g_array_index(wdh->shb_hdrs, wtap_optionblock_t, 0);
}
block_size.size = 0;
bh.block_total_length = (guint32)(sizeof(bh) + sizeof(shb) + 4);
if (wdh->shb_hdr) {
if (wdh_shb) {
pcapng_debug("pcapng_write_section_header_block: Have shb_hdr");
/* Compute block size */
wtap_optionblock_foreach_option(wdh->shb_hdr, compute_shb_option_size, &block_size);
wtap_optionblock_foreach_option(wdh_shb, compute_shb_option_size, &block_size);
if (block_size.size > 0) {
/* End-of-options tag */
@ -2871,8 +2876,8 @@ pcapng_write_section_header_block(wtap_dumper *wdh, int *err)
shb.magic = 0x1A2B3C4D;
shb.version_major = 1;
shb.version_minor = 0;
if (wdh->shb_hdr) {
wtapng_mandatory_section_t* section_data = (wtapng_mandatory_section_t*)wtap_optionblock_get_mandatory_data(wdh->shb_hdr);
if (wdh_shb) {
wtapng_mandatory_section_t* section_data = (wtapng_mandatory_section_t*)wtap_optionblock_get_mandatory_data(wdh_shb);
shb.section_length = section_data->section_length;
} else {
shb.section_length = -1;
@ -2882,7 +2887,7 @@ pcapng_write_section_header_block(wtap_dumper *wdh, int *err)
return FALSE;
wdh->bytes_dumped += sizeof shb;
if (wdh->shb_hdr) {
if (wdh_shb) {
pcapng_write_block_t block_data;
if (block_size.size > 0) {
@ -2890,7 +2895,7 @@ pcapng_write_section_header_block(wtap_dumper *wdh, int *err)
block_data.wdh = wdh;
block_data.err = err;
block_data.success = TRUE;
wtap_optionblock_foreach_option(wdh->shb_hdr, write_wtap_shb_block, &block_data);
wtap_optionblock_foreach_option(wdh_shb, write_wtap_shb_block, &block_data);
if (!block_data.success)
return FALSE;

View File

@ -51,7 +51,7 @@ struct wtap {
guint snapshot_length;
struct Buffer *frame_buffer;
struct wtap_pkthdr phdr;
wtap_optionblock_t shb_hdr;
GArray *shb_hdrs;
GArray *interface_data; /**< An array holding the interface data from pcapng IDB:s or equivalent(?)*/
wtap_optionblock_t nrb_hdr; /**< holds the Name Res Block's comment/custom_opts, or NULL */
@ -114,7 +114,7 @@ struct wtap_dumper {
* e.g. WTAP_TSPREC_USEC
*/
addrinfo_lists_t *addrinfo_lists; /**< Struct containing lists of resolved addresses */
wtap_optionblock_t shb_hdr;
GArray *shb_hdrs;
wtap_optionblock_t nrb_hdr; /**< name resolution comment/custom_opt, or NULL */
GArray *interface_data; /**< An array holding the interface data from pcapng IDB:s or equivalent(?) NULL if not present.*/
};

View File

@ -165,32 +165,42 @@ const gchar *
wtap_file_get_shb_comment(wtap *wth)
{
char* opt_comment;
if (wth == NULL)
if ((wth == NULL) || (wth->shb_hdrs == NULL) || (wth->shb_hdrs->len == 0))
return NULL;
wtap_optionblock_get_option_string(wth->shb_hdr, OPT_COMMENT, &opt_comment);
wtap_optionblock_get_option_string(g_array_index(wth->shb_hdrs, wtap_optionblock_t, 0), OPT_COMMENT, &opt_comment);
return opt_comment;
}
wtap_optionblock_t
wtap_file_get_shb(wtap *wth)
{
return wth ? wth->shb_hdr : NULL;
}
wtap_optionblock_t
wtap_file_get_shb_for_new_file(wtap *wth)
{
wtap_optionblock_t shb_hdr;
if (wth == NULL)
if ((wth == NULL) || (wth->shb_hdrs == NULL) || (wth->shb_hdrs->len == 0))
return NULL;
shb_hdr = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
return g_array_index(wth->shb_hdrs, wtap_optionblock_t, 0);
}
/* options */
wtap_optionblock_copy_options(shb_hdr, wth->shb_hdr);
return shb_hdr;
GArray*
wtap_file_get_shb_for_new_file(wtap *wth)
{
guint shb_count;
wtap_optionblock_t shb_hdr_src, shb_hdr_dest;
GArray* shb_hdrs;
if ((wth == NULL) || (wth->shb_hdrs == NULL) || (wth->shb_hdrs->len == 0))
return NULL;
shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
for (shb_count = 0; shb_count < wth->shb_hdrs->len; shb_count++) {
shb_hdr_src = g_array_index(wth->shb_hdrs, wtap_optionblock_t, shb_count);
shb_hdr_dest = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
wtap_optionblock_copy_options(shb_hdr_dest, shb_hdr_src);
g_array_append_val(shb_hdrs, shb_hdr_dest);
}
return shb_hdrs;
}
const gchar*
@ -224,7 +234,9 @@ wtap_write_nrb_comment(wtap *wth, gchar *comment)
void
wtap_write_shb_comment(wtap *wth, gchar *comment)
{
wtap_optionblock_set_option_string(wth->shb_hdr, OPT_COMMENT, comment, (gsize)(comment ? strlen(comment) : 0));
if ((wth != NULL) && (wth->shb_hdrs != NULL) && (wth->shb_hdrs->len > 0)) {
wtap_optionblock_set_option_string(g_array_index(wth->shb_hdrs, wtap_optionblock_t, 0), OPT_COMMENT, comment, (gsize)(comment ? strlen(comment) : 0));
}
}
wtapng_iface_descriptions_t *
@ -246,15 +258,7 @@ wtap_free_idb_info(wtapng_iface_descriptions_t *idb_info)
if (idb_info == NULL)
return;
if (idb_info->interface_data) {
guint i;
for (i = 0; i < idb_info->interface_data->len; i++) {
wtap_optionblock_t idb = g_array_index(idb_info->interface_data, wtap_optionblock_t, i);
wtap_optionblock_free(idb);
}
g_array_free(idb_info->interface_data, TRUE);
}
wtap_optionblock_array_free(idb_info->interface_data);
g_free(idb_info);
}
@ -1176,9 +1180,6 @@ wtap_fdclose(wtap *wth)
void
wtap_close(wtap *wth)
{
guint i;
wtap_optionblock_t wtapng_if_descr;
wtap_sequential_close(wth);
if (wth->subtype_close != NULL)
@ -1195,13 +1196,9 @@ wtap_close(wtap *wth)
g_ptr_array_free(wth->fast_seek, TRUE);
}
wtap_optionblock_free(wth->shb_hdr);
wtap_optionblock_array_free(wth->shb_hdrs);
wtap_optionblock_array_free(wth->interface_data);
for(i = 0; i < wth->interface_data->len; i++) {
wtapng_if_descr = g_array_index(wth->interface_data, wtap_optionblock_t, i);
wtap_optionblock_free(wtapng_if_descr);
}
g_array_free(wth->interface_data, TRUE);
g_free(wth);
}

View File

@ -1608,7 +1608,7 @@ wtap_optionblock_t wtap_file_get_shb(wtap *wth);
* @return The new section header, which must be wtap_free_shb'd.
*/
WS_DLL_PUBLIC
wtap_optionblock_t wtap_file_get_shb_for_new_file(wtap *wth);
GArray* wtap_file_get_shb_for_new_file(wtap *wth);
/**
* @brief Gets the section header comment string.
@ -1776,7 +1776,7 @@ wtap_dumper* wtap_dump_open(const char *filename, int file_type_subtype, int enc
* @param encap The WTAP_ENCAP_XXX encapsulation type (WTAP_ENCAP_PER_PACKET for multi)
* @param snaplen The maximum packet capture length.
* @param compressed True if file should be compressed.
* @param shb_hdr The section header block information, or NULL.
* @param shb_hdrs The section header block(s) information, or NULL.
* @param idb_inf The interface description information, or NULL.
* @param nrb_hdr The name resolution comment/custom_opts information, or NULL.
* @param[out] err Will be set to an error code on failure.
@ -1784,7 +1784,7 @@ wtap_dumper* wtap_dump_open(const char *filename, int file_type_subtype, int enc
*/
WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open_ng(const char *filename, int file_type_subtype, int encap,
int snaplen, gboolean compressed, wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
int snaplen, gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
wtap_optionblock_t nrb_hdr, int *err);
WS_DLL_PUBLIC
@ -1806,7 +1806,7 @@ wtap_dumper* wtap_dump_open_tempfile(char **filenamep, const char *pfx,
* @param encap The WTAP_ENCAP_XXX encapsulation type (WTAP_ENCAP_PER_PACKET for multi)
* @param snaplen The maximum packet capture length.
* @param compressed True if file should be compressed.
* @param shb_hdr The section header block information, or NULL.
* @param shb_hdrs The section header block(s) information, or NULL.
* @param idb_inf The interface description information, or NULL.
* @param nrb_hdr The name resolution comment/custom_opts information, or NULL.
* @param[out] err Will be set to an error code on failure.
@ -1815,7 +1815,7 @@ wtap_dumper* wtap_dump_open_tempfile(char **filenamep, const char *pfx,
WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open_tempfile_ng(char **filenamep, const char *pfx,
int file_type_subtype, int encap, int snaplen, gboolean compressed,
wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
wtap_optionblock_t nrb_hdr, int *err);
WS_DLL_PUBLIC
@ -1834,7 +1834,7 @@ wtap_dumper* wtap_dump_fdopen(int fd, int file_type_subtype, int encap, int snap
* @param encap The WTAP_ENCAP_XXX encapsulation type (WTAP_ENCAP_PER_PACKET for multi)
* @param snaplen The maximum packet capture length.
* @param compressed True if file should be compressed.
* @param shb_hdr The section header block information, or NULL.
* @param shb_hdrs The section header block(s) information, or NULL.
* @param idb_inf The interface description information, or NULL.
* @param nrb_hdr The name resolution comment/custom_opts information, or NULL.
* @param[out] err Will be set to an error code on failure.
@ -1842,7 +1842,7 @@ wtap_dumper* wtap_dump_fdopen(int fd, int file_type_subtype, int encap, int snap
*/
WS_DLL_PUBLIC
wtap_dumper* wtap_dump_fdopen_ng(int fd, int file_type_subtype, int encap, int snaplen,
gboolean compressed, wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
wtap_optionblock_t nrb_hdr, int *err);
WS_DLL_PUBLIC
@ -1860,7 +1860,7 @@ wtap_dumper* wtap_dump_open_stdout(int file_type_subtype, int encap, int snaplen
* @param encap The WTAP_ENCAP_XXX encapsulation type (WTAP_ENCAP_PER_PACKET for multi)
* @param snaplen The maximum packet capture length.
* @param compressed True if file should be compressed.
* @param shb_hdr The section header block information, or NULL.
* @param shb_hdrs The section header block(s) information, or NULL.
* @param idb_inf The interface description information, or NULL.
* @param nrb_hdr The name resolution comment/custom_opts information, or NULL.
* @param[out] err Will be set to an error code on failure.
@ -1868,7 +1868,7 @@ wtap_dumper* wtap_dump_open_stdout(int file_type_subtype, int encap, int snaplen
*/
WS_DLL_PUBLIC
wtap_dumper* wtap_dump_open_stdout_ng(int file_type_subtype, int encap, int snaplen,
gboolean compressed, wtap_optionblock_t shb_hdr, wtapng_iface_descriptions_t *idb_inf,
gboolean compressed, GArray* shb_hdrs, wtapng_iface_descriptions_t *idb_inf,
wtap_optionblock_t nrb_hdr, int *err);
WS_DLL_PUBLIC

View File

@ -196,6 +196,18 @@ void wtap_optionblock_free(wtap_optionblock_t block)
}
}
void wtap_optionblock_array_free(GArray* block_array)
{
guint block;
if (block_array == NULL)
return;
for (block = 0; block < block_array->len; block++) {
wtap_optionblock_free(g_array_index(block_array, wtap_optionblock_t, block));
}
g_array_free(block_array, TRUE);
}
void wtap_optionblock_copy_options(wtap_optionblock_t dest_block, wtap_optionblock_t src_block)
{
guint i;

View File

@ -106,6 +106,16 @@ WS_DLL_PUBLIC wtap_optionblock_t wtap_optionblock_create(int block_type);
*/
WS_DLL_PUBLIC void wtap_optionblock_free(wtap_optionblock_t block);
/** Free an array of option blocks
*
* Needs to be called to clean up option blocks allocated
* through GArray (for multiple blocks of same type)
* Includes freeing the GArray
*
* @param[in] block_array Array of blocks to be freed
*/
WS_DLL_PUBLIC void wtap_optionblock_array_free(GArray* block_array);
/** Provide mandatory data of an option block
*
* @param[in] block Block from which to retrieve mandatory data