forked from osmocom/wireshark
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>pespin/osmux-stats
parent
42e72d529c
commit
1f8999bb96
44
capinfos.c
44
capinfos.c
|
@ -194,7 +194,7 @@ typedef struct _capture_info {
|
|||
int file_encap;
|
||||
int file_tsprec;
|
||||
gint64 filesize;
|
||||
wtap_optionblock_t shb;
|
||||
wtap_block_t shb;
|
||||
guint64 packet_bytes;
|
||||
gboolean times_known;
|
||||
nstime_t start_time;
|
||||
|
@ -712,24 +712,22 @@ print_stats(const gchar *filename, capture_info *cf_info)
|
|||
|
||||
if (cf_info->shb != NULL) {
|
||||
if (cap_comment) {
|
||||
GArray *opts;
|
||||
unsigned int i;
|
||||
char *str;
|
||||
|
||||
wtap_optionblock_get_string_options(cf_info->shb, OPT_COMMENT, &opts);
|
||||
for (i = 0; i < opts->len; i++) {
|
||||
show_option_string("Capture comment: ", g_array_index(opts, char *, i));
|
||||
for (i = 0; wtap_block_get_nth_string_option_value(cf_info->shb, OPT_COMMENT, i, &str) == WTAP_OPTTYPE_SUCCESS; i++) {
|
||||
show_option_string("Capture comment: ", str);
|
||||
}
|
||||
g_array_free(opts, TRUE);
|
||||
}
|
||||
if (cap_file_more_info) {
|
||||
char *str;
|
||||
|
||||
wtap_optionblock_get_option_string(cf_info->shb, OPT_SHB_HARDWARE, &str);
|
||||
show_option_string("Capture hardware: ", str);
|
||||
wtap_optionblock_get_option_string(cf_info->shb, OPT_SHB_OS, &str);
|
||||
show_option_string("Capture oper-sys: ", str);
|
||||
wtap_optionblock_get_option_string(cf_info->shb, OPT_SHB_USERAPPL, &str);
|
||||
show_option_string("Capture application: ", str);
|
||||
if (wtap_block_get_string_option_value(cf_info->shb, OPT_SHB_HARDWARE, &str) == WTAP_OPTTYPE_SUCCESS)
|
||||
show_option_string("Capture hardware: ", str);
|
||||
if (wtap_block_get_string_option_value(cf_info->shb, OPT_SHB_OS, &str) == WTAP_OPTTYPE_SUCCESS)
|
||||
show_option_string("Capture oper-sys: ", str);
|
||||
if (wtap_block_get_string_option_value(cf_info->shb, OPT_SHB_USERAPPL, &str) == WTAP_OPTTYPE_SUCCESS)
|
||||
show_option_string("Capture application: ", str);
|
||||
}
|
||||
|
||||
if (cap_file_idb && cf_info->num_interfaces != 0) {
|
||||
|
@ -991,13 +989,10 @@ print_stats_table(const gchar *filename, capture_info *cf_info)
|
|||
* of options
|
||||
*/
|
||||
if (cap_comment) {
|
||||
GArray *opts;
|
||||
unsigned int i;
|
||||
char *opt_comment;
|
||||
|
||||
wtap_optionblock_get_string_options(cf_info->shb, OPT_COMMENT, &opts);
|
||||
for (i = 0; i < opts->len; i++) {
|
||||
const char *opt_comment = g_array_index(opts, char *, i);
|
||||
|
||||
for (i = 0; wtap_block_get_nth_string_option_value(cf_info->shb, OPT_COMMENT, i, &opt_comment) == WTAP_OPTTYPE_SUCCESS; i++) {
|
||||
if (opt_comment != NULL) {
|
||||
putsep();
|
||||
putquote();
|
||||
|
@ -1005,28 +1000,27 @@ print_stats_table(const gchar *filename, capture_info *cf_info)
|
|||
putquote();
|
||||
}
|
||||
}
|
||||
g_array_free(opts, TRUE);
|
||||
}
|
||||
|
||||
if (cap_file_more_info) {
|
||||
char *str;
|
||||
|
||||
wtap_optionblock_get_option_string(cf_info->shb, OPT_SHB_HARDWARE, &str);
|
||||
if (str != NULL) {
|
||||
if (wtap_block_get_string_option_value(cf_info->shb, OPT_SHB_HARDWARE, &str) == WTAP_OPTTYPE_SUCCESS &&
|
||||
str != NULL) {
|
||||
putsep();
|
||||
putquote();
|
||||
printf("%s", str);
|
||||
putquote();
|
||||
}
|
||||
wtap_optionblock_get_option_string(cf_info->shb, OPT_SHB_OS, &str);
|
||||
if (str != NULL) {
|
||||
if (wtap_block_get_string_option_value(cf_info->shb, OPT_SHB_OS, &str) == WTAP_OPTTYPE_SUCCESS &&
|
||||
str != NULL) {
|
||||
putsep();
|
||||
putquote();
|
||||
printf("%s", str);
|
||||
putquote();
|
||||
}
|
||||
wtap_optionblock_get_option_string(cf_info->shb, OPT_SHB_USERAPPL, &str);
|
||||
if (str != NULL) {
|
||||
if (wtap_block_get_string_option_value(cf_info->shb, OPT_SHB_USERAPPL, &str) == WTAP_OPTTYPE_SUCCESS &&
|
||||
str != NULL) {
|
||||
putsep();
|
||||
putquote();
|
||||
printf("%s", str);
|
||||
|
@ -1213,7 +1207,7 @@ process_cap_file(wtap *wth, const char *filename)
|
|||
cf_info.idb_info_strings = g_array_sized_new(FALSE, FALSE, sizeof(gchar*), cf_info.num_interfaces);
|
||||
cf_info.num_interfaces = idb_info->interface_data->len;
|
||||
for (i = 0; i < cf_info.num_interfaces; i++) {
|
||||
const wtap_optionblock_t if_descr = g_array_index(idb_info->interface_data, wtap_optionblock_t, i);
|
||||
const wtap_block_t if_descr = g_array_index(idb_info->interface_data, wtap_block_t, i);
|
||||
gchar *s = wtap_get_debug_if_descr(if_descr, 21, "\n");
|
||||
g_array_append_val(cf_info.idb_info_strings, s);
|
||||
}
|
||||
|
|
12
cfile.c
12
cfile.c
|
@ -35,22 +35,22 @@ cap_file_get_interface_name(void *data, guint32 interface_id)
|
|||
{
|
||||
capture_file *cf = (capture_file *) data;
|
||||
wtapng_iface_descriptions_t *idb_info;
|
||||
wtap_optionblock_t wtapng_if_descr = NULL;
|
||||
wtap_block_t wtapng_if_descr = NULL;
|
||||
char* interface_name;
|
||||
|
||||
idb_info = wtap_file_get_idb_info(cf->wth);
|
||||
|
||||
if (interface_id < idb_info->interface_data->len)
|
||||
wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_optionblock_t, interface_id);
|
||||
wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_block_t, interface_id);
|
||||
|
||||
g_free(idb_info);
|
||||
|
||||
if (wtapng_if_descr) {
|
||||
wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_NAME, &interface_name);
|
||||
if (interface_name)
|
||||
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_NAME, &interface_name) == WTAP_OPTTYPE_SUCCESS &&
|
||||
interface_name)
|
||||
return interface_name;
|
||||
wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_DESCR, &interface_name);
|
||||
if (interface_name)
|
||||
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_DESCR, &interface_name) == WTAP_OPTTYPE_SUCCESS &&
|
||||
interface_name)
|
||||
return interface_name;
|
||||
}
|
||||
return "unknown";
|
||||
|
|
14
editcap.c
14
editcap.c
|
@ -1378,9 +1378,9 @@ main(int argc, char *argv[])
|
|||
g_assert(filename);
|
||||
|
||||
/* If we don't have an application name add Editcap */
|
||||
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(g_array_index(shb_hdrs, wtap_optionblock_t, 0), OPT_SHB_USERAPPL, "Editcap " VERSION);
|
||||
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) {
|
||||
wtap_block_add_string_option_format(g_array_index(shb_hdrs, wtap_block_t, 0), OPT_SHB_USERAPPL, "Editcap " VERSION);
|
||||
}
|
||||
|
||||
pdh = editcap_dump_open(filename,
|
||||
|
@ -1842,9 +1842,9 @@ main(int argc, char *argv[])
|
|||
wtap_strerror(write_err));
|
||||
goto error_on_exit;
|
||||
}
|
||||
wtap_optionblock_array_free(shb_hdrs);
|
||||
wtap_block_array_free(shb_hdrs);
|
||||
shb_hdrs = NULL;
|
||||
wtap_optionblock_array_free(nrb_hdrs);
|
||||
wtap_block_array_free(nrb_hdrs);
|
||||
nrb_hdrs = NULL;
|
||||
g_free(filename);
|
||||
|
||||
|
@ -1868,8 +1868,8 @@ main(int argc, char *argv[])
|
|||
return 0;
|
||||
|
||||
error_on_exit:
|
||||
wtap_optionblock_array_free(shb_hdrs);
|
||||
wtap_optionblock_array_free(nrb_hdrs);
|
||||
wtap_block_array_free(shb_hdrs);
|
||||
wtap_block_array_free(nrb_hdrs);
|
||||
g_free(idb_inf);
|
||||
exit(2);
|
||||
}
|
||||
|
|
|
@ -557,8 +557,23 @@ extern int wslua_set__index(lua_State *L);
|
|||
WSLUA_ATTRIBUTE_GET(C,name, { \
|
||||
char* str; \
|
||||
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 */ \
|
||||
if (wtap_block_get_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, &str) == WTAP_OPTTYPE_SUCCESS) { \
|
||||
lua_pushstring(L,str); /* this pushes nil if obj->member is null */ \
|
||||
} \
|
||||
} \
|
||||
})
|
||||
|
||||
/*
|
||||
* XXX - we need to support Lua programs getting instances of a "multiple
|
||||
* allowed" option other than the first option.
|
||||
*/
|
||||
#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_GETTER(C,name,member,option) \
|
||||
WSLUA_ATTRIBUTE_GET(C,name, { \
|
||||
char* str; \
|
||||
if ((obj->member) && (obj->member->len > 0)) { \
|
||||
if (wtap_block_get_nth_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, 0, &str) == WTAP_OPTTYPE_SUCCESS) { \
|
||||
lua_pushstring(L,str); /* this pushes nil if obj->member is null */ \
|
||||
} \
|
||||
} \
|
||||
})
|
||||
|
||||
|
@ -620,7 +635,25 @@ extern int wslua_set__index(lua_State *L);
|
|||
return luaL_error(L, "%s's attribute `%s' must be a string or nil", #C , #field ); \
|
||||
} \
|
||||
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)); \
|
||||
wtap_block_set_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, s, strlen(s)); \
|
||||
} \
|
||||
g_free(s); \
|
||||
return 0; \
|
||||
} \
|
||||
/* silly little trick so we can add a semicolon after this macro */ \
|
||||
typedef void __dummy##C##_set_##field
|
||||
|
||||
#define WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_SETTER(C,field,member,option) \
|
||||
static int C##_set_##field (lua_State* L) { \
|
||||
C obj = check##C (L,1); \
|
||||
gchar* s = NULL; \
|
||||
if (lua_isstring(L,-1) || lua_isnil(L,-1)) { \
|
||||
s = g_strdup(lua_tostring(L,-1)); \
|
||||
} else { \
|
||||
return luaL_error(L, "%s's attribute `%s' must be a string or nil", #C , #field ); \
|
||||
} \
|
||||
if ((obj->member) && (obj->member->len > 0)) { \
|
||||
wtap_block_set_nth_string_option_value(g_array_index(obj->member, wtap_block_t, 0), option, 0, s, strlen(s)); \
|
||||
} \
|
||||
g_free(s); \
|
||||
return 0; \
|
||||
|
|
|
@ -119,8 +119,8 @@ 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_hdrs,OPT_COMMENT);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_STRING_SETTER(CaptureInfo,comment,wth->shb_hdrs,OPT_COMMENT);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_STRING_GETTER(CaptureInfo,comment,wth->shb_hdrs,OPT_COMMENT);
|
||||
WSLUA_ATTRIBUTE_NAMED_OPT_BLOCK_NTH_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. */
|
||||
|
|
45
file.c
45
file.c
|
@ -3839,28 +3839,47 @@ cf_unignore_frame(capture_file *cf, frame_data *frame)
|
|||
const gchar *
|
||||
cf_read_shb_comment(capture_file *cf)
|
||||
{
|
||||
/* Get info from SHB */
|
||||
return wtap_file_get_shb_comment(cf->wth);
|
||||
wtap_block_t shb_inf;
|
||||
char *shb_comment;
|
||||
|
||||
/* Get the SHB. */
|
||||
/* XXX - support multiple SHBs */
|
||||
shb_inf = wtap_file_get_shb(cf->wth);
|
||||
|
||||
/* Get the first comment from the SHB. */
|
||||
/* XXX - support multiple comments */
|
||||
if (wtap_block_get_nth_string_option_value(shb_inf, OPT_COMMENT, 0, &shb_comment) != WTAP_OPTTYPE_SUCCESS)
|
||||
return NULL;
|
||||
return shb_comment;
|
||||
}
|
||||
|
||||
void
|
||||
cf_update_capture_comment(capture_file *cf, gchar *comment)
|
||||
{
|
||||
const gchar *shb_comment;
|
||||
wtap_block_t shb_inf;
|
||||
gchar *shb_comment;
|
||||
|
||||
/* Get info from SHB */
|
||||
shb_comment = wtap_file_get_shb_comment(cf->wth);
|
||||
/* Get the SHB. */
|
||||
/* XXX - support multiple SHBs */
|
||||
shb_inf = wtap_file_get_shb(cf->wth);
|
||||
|
||||
/* See if the comment has changed or not */
|
||||
if (shb_comment) {
|
||||
if (strcmp(shb_comment, comment) == 0) {
|
||||
g_free(comment);
|
||||
return;
|
||||
/* Get the first comment from the SHB. */
|
||||
/* XXX - support multiple comments */
|
||||
if (wtap_block_get_nth_string_option_value(shb_inf, OPT_COMMENT, 0, &shb_comment) != WTAP_OPTTYPE_SUCCESS) {
|
||||
/* There's no comment - add one. */
|
||||
wtap_block_add_string_option(shb_inf, OPT_COMMENT, comment, strlen(comment));
|
||||
} else {
|
||||
/* See if the comment has changed or not */
|
||||
if (shb_comment) {
|
||||
if (strcmp(shb_comment, comment) == 0) {
|
||||
g_free(comment);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The comment has changed, let's update it */
|
||||
wtap_write_shb_comment(cf->wth, comment);
|
||||
/* The comment has changed, let's update it */
|
||||
wtap_block_set_nth_string_option_value(shb_inf, OPT_COMMENT, 0, comment, strlen(comment));
|
||||
}
|
||||
/* Mark the file as having unsaved changes */
|
||||
cf->unsaved_changes = TRUE;
|
||||
}
|
||||
|
|
12
reordercap.c
12
reordercap.c
|
@ -308,8 +308,8 @@ 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_array_free(shb_hdrs);
|
||||
wtap_optionblock_array_free(nrb_hdrs);
|
||||
wtap_block_array_free(shb_hdrs);
|
||||
wtap_block_array_free(nrb_hdrs);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -382,12 +382,12 @@ 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_array_free(shb_hdrs);
|
||||
wtap_optionblock_array_free(nrb_hdrs);
|
||||
wtap_block_array_free(shb_hdrs);
|
||||
wtap_block_array_free(nrb_hdrs);
|
||||
exit(1);
|
||||
}
|
||||
wtap_optionblock_array_free(shb_hdrs);
|
||||
wtap_optionblock_array_free(nrb_hdrs);
|
||||
wtap_block_array_free(shb_hdrs);
|
||||
wtap_block_array_free(nrb_hdrs);
|
||||
|
||||
/* Finally, close infile */
|
||||
wtap_fdclose(wth);
|
||||
|
|
39
summary.c
39
summary.c
|
@ -110,9 +110,9 @@ summary_fill_in(capture_file *cf, summary_tally *st)
|
|||
iface_options iface;
|
||||
guint i;
|
||||
wtapng_iface_descriptions_t* idb_info;
|
||||
wtap_optionblock_t wtapng_if_descr;
|
||||
wtap_block_t wtapng_if_descr;
|
||||
wtapng_if_descr_mandatory_t *wtapng_if_descr_mand;
|
||||
wtap_optionblock_t if_stats;
|
||||
wtap_block_t if_stats;
|
||||
guint64 isb_ifdrop;
|
||||
char* if_string;
|
||||
wtapng_if_descr_filter_t* if_filter;
|
||||
|
@ -163,14 +163,23 @@ summary_fill_in(capture_file *cf, summary_tally *st)
|
|||
st->ifaces = g_array_new(FALSE, FALSE, sizeof(iface_options));
|
||||
idb_info = wtap_file_get_idb_info(cf->wth);
|
||||
for (i = 0; i < idb_info->interface_data->len; i++) {
|
||||
wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_optionblock_t, i);
|
||||
wtapng_if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(wtapng_if_descr);
|
||||
wtap_optionblock_get_option_custom(wtapng_if_descr, OPT_IDB_FILTER, (void**)&if_filter);
|
||||
iface.cfilter = g_strdup(if_filter->if_filter_str);
|
||||
wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_NAME, &if_string);
|
||||
iface.name = g_strdup(if_string);
|
||||
wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_DESCR, &if_string);
|
||||
iface.descr = g_strdup(if_string);
|
||||
wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_block_t, i);
|
||||
wtapng_if_descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(wtapng_if_descr);
|
||||
if (wtap_block_get_custom_option_value(wtapng_if_descr, OPT_IDB_FILTER, (void**)&if_filter) == WTAP_OPTTYPE_SUCCESS) {
|
||||
iface.cfilter = g_strdup(if_filter->if_filter_str);
|
||||
} else {
|
||||
iface.cfilter = NULL;
|
||||
}
|
||||
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_NAME, &if_string) == WTAP_OPTTYPE_SUCCESS) {
|
||||
iface.name = g_strdup(if_string);
|
||||
} else {
|
||||
iface.name = NULL;
|
||||
}
|
||||
if (wtap_block_get_string_option_value(wtapng_if_descr, OPT_IDB_DESCR, &if_string) == WTAP_OPTTYPE_SUCCESS) {
|
||||
iface.descr = g_strdup(if_string);
|
||||
} else {
|
||||
iface.descr = NULL;
|
||||
}
|
||||
iface.drops_known = FALSE;
|
||||
iface.drops = 0;
|
||||
iface.snap = wtapng_if_descr_mand->snap_len;
|
||||
|
@ -179,14 +188,16 @@ summary_fill_in(capture_file *cf, summary_tally *st)
|
|||
iface.isb_comment = NULL;
|
||||
if(wtapng_if_descr_mand->num_stat_entries == 1){
|
||||
/* dumpcap only writes one ISB, only handle that for now */
|
||||
if_stats = g_array_index(wtapng_if_descr_mand->interface_statistics, wtap_optionblock_t, 0);
|
||||
wtap_optionblock_get_option_uint64(if_stats, OPT_ISB_IFDROP, &isb_ifdrop);
|
||||
if (isb_ifdrop != G_GUINT64_CONSTANT(0xFFFFFFFFFFFFFFFF)) {
|
||||
if_stats = g_array_index(wtapng_if_descr_mand->interface_statistics, wtap_block_t, 0);
|
||||
if (wtap_block_get_uint64_option_value(if_stats, OPT_ISB_IFDROP, &isb_ifdrop) == WTAP_OPTTYPE_SUCCESS) {
|
||||
iface.drops_known = TRUE;
|
||||
iface.drops = isb_ifdrop;
|
||||
}
|
||||
/* XXX: this doesn't get used, and might need to be g_strdup'ed when it does */
|
||||
wtap_optionblock_get_option_string(if_stats, OPT_COMMENT, &iface.isb_comment);
|
||||
/* XXX - support multiple comments */
|
||||
if (wtap_block_get_nth_string_option_value(if_stats, OPT_COMMENT, 0, &iface.isb_comment) != WTAP_OPTTYPE_SUCCESS) {
|
||||
iface.isb_comment = NULL;
|
||||
}
|
||||
}
|
||||
g_array_append_val(st->ifaces, iface);
|
||||
}
|
||||
|
|
20
tshark.c
20
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;
|
||||
}
|
||||
|
|
|
@ -458,10 +458,10 @@ file_import_open(text_import_info_t *info)
|
|||
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;
|
||||
|
@ -470,35 +470,35 @@ file_import_open(text_import_info_t *info)
|
|||
os_info_str = g_string_new("");
|
||||
get_os_version_info(os_info_str);
|
||||
|
||||
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_format(shb_hdr, OPT_COMMENT, "File created by File->Import of file %s", info->import_text_filename);
|
||||
wtap_block_add_string_option_format(shb_hdr, OPT_COMMENT, "File created by File->Import of file %s", info->import_text_filename);
|
||||
|
||||
/*
|
||||
* 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(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 = info->encapsulation;
|
||||
int_data_mand->time_units_per_second = 1000000; /* default microsecond resolution */
|
||||
int_data_mand->link_type = wtap_wtap_encap_to_pcap_encap(info->encapsulation);
|
||||
int_data_mand->snap_len = WTAP_MAX_PACKET_SIZE;
|
||||
wtap_optionblock_set_option_string(int_data, OPT_IDB_NAME, "Fake IF File->Import", strlen("Fake IF File->Import"));
|
||||
wtap_block_add_string_option(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);
|
||||
|
@ -557,7 +557,7 @@ end:
|
|||
g_free(info->date_timestamp_format);
|
||||
g_free(info);
|
||||
g_free(capfile_name);
|
||||
wtap_optionblock_array_free(shb_hdrs);
|
||||
wtap_block_array_free(shb_hdrs);
|
||||
wtap_free_idb_info(idb_inf);
|
||||
window_destroy(file_import_dlg_w);
|
||||
}
|
||||
|
|
|
@ -188,9 +188,8 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
|
||||
unsigned int elapsed_time;
|
||||
iface_options iface;
|
||||
wtap_optionblock_t shb_inf;
|
||||
wtap_block_t shb_inf;
|
||||
unsigned int i;
|
||||
GArray *opts;
|
||||
|
||||
if (summary_dlg != NULL) {
|
||||
/* There's already a Summary dialog box; reactivate it. */
|
||||
|
@ -293,14 +292,13 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (comment_view));
|
||||
gtk_text_buffer_set_text (buffer, "", -1);
|
||||
if (shb_inf != NULL) {
|
||||
wtap_optionblock_get_string_options(shb_inf, OPT_COMMENT, &opts);
|
||||
for (i = 0; i < opts->len; i++) {
|
||||
/* XXX - this only shows the last comment */
|
||||
char *opt_comment = g_array_index(opts, char *, i);
|
||||
char *opt_comment;
|
||||
|
||||
/* XXX - this only shows the last comment */
|
||||
for (i = 0; wtap_block_get_nth_string_option_value(shb_inf, OPT_COMMENT, i, &opt_comment) == WTAP_OPTTYPE_SUCCESS; i++) {
|
||||
if (opt_comment != NULL && opt_comment[0] != '\0')
|
||||
gtk_text_buffer_set_text (buffer, opt_comment, -1);
|
||||
}
|
||||
g_array_free(opts, TRUE);
|
||||
}
|
||||
gtk_box_pack_start(GTK_BOX(comment_vbox), comment_view, TRUE, TRUE, 0);
|
||||
gtk_widget_show (comment_view);
|
||||
|
@ -350,21 +348,21 @@ summary_open_cb(GtkWidget *w _U_, gpointer d _U_)
|
|||
if (shb_inf != NULL) {
|
||||
char *str;
|
||||
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_HARDWARE, &str);
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_HARDWARE, &str) == WTAP_OPTTYPE_SUCCESS &&
|
||||
str != NULL && str[0] != '\0') {
|
||||
g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s", str);
|
||||
add_string_to_grid(grid, &row, "Capture HW:",string_buff);
|
||||
}
|
||||
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_OS, &str);
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_OS, &str) == WTAP_OPTTYPE_SUCCESS &&
|
||||
str != NULL && str[0] != '\0') {
|
||||
/* truncate the strings to a reasonable length */
|
||||
g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s", str);
|
||||
add_string_to_grid(grid, &row, "OS:", string_buff);
|
||||
}
|
||||
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_USERAPPL, &str);
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_USERAPPL, &str) == WTAP_OPTTYPE_SUCCESS &&
|
||||
str != NULL && str[0] != '\0') {
|
||||
/* truncate the strings to a reasonable length */
|
||||
g_snprintf(string_buff, SHB_STR_SNIP_LEN, "%s", str);
|
||||
add_string_to_grid(grid, &row, "Capture application:", string_buff);
|
||||
|
@ -664,8 +662,7 @@ summary_to_texbuff(GtkTextBuffer *buffer)
|
|||
summary_tally summary;
|
||||
gchar string_buff[SUM_STR_MAX];
|
||||
gchar tmp_buff[SUM_STR_MAX];
|
||||
wtap_optionblock_t shb_inf;
|
||||
GArray *opts;
|
||||
wtap_block_t shb_inf;
|
||||
unsigned int i;
|
||||
unsigned int elapsed_time;
|
||||
iface_options iface;
|
||||
|
@ -768,20 +765,20 @@ summary_to_texbuff(GtkTextBuffer *buffer)
|
|||
if (shb_inf != NULL) {
|
||||
char *str;
|
||||
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_HARDWARE, &str);
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_HARDWARE, &str) == WTAP_OPTTYPE_SUCCESS &&
|
||||
str != NULL && str[0] != '\0') {
|
||||
/* truncate the string to a reasonable length */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Capture HW: %s\n", str);
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
}
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_OS, &str);
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_OS, &str) == WTAP_OPTTYPE_SUCCESS &&
|
||||
str != NULL && str[0] != '\0') {
|
||||
/* truncate the strings to a reasonable length */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, INDENT "OS: %s\n", str);
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
}
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_USERAPPL, &str);
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_USERAPPL, &str) == WTAP_OPTTYPE_SUCCESS &&
|
||||
str != NULL && str[0] != '\0') {
|
||||
/* truncate the string to a reasonable length */
|
||||
g_snprintf(string_buff, SUM_STR_MAX, INDENT "Capture application: %s\n", str);
|
||||
gtk_text_buffer_insert_at_cursor (buffer, string_buff, -1);
|
||||
|
@ -901,10 +898,10 @@ summary_to_texbuff(GtkTextBuffer *buffer)
|
|||
/* Trace file comments from SHB */
|
||||
shb_inf = wtap_file_get_shb(cfile.wth);
|
||||
if (shb_inf != NULL) {
|
||||
wtap_optionblock_get_string_options(shb_inf, OPT_COMMENT, &opts);
|
||||
for (i = 0; i < opts->len; i++) {
|
||||
char *opt_comment;
|
||||
|
||||
for (i = 0; wtap_block_get_nth_string_option_value(shb_inf, OPT_COMMENT, i, &opt_comment) == WTAP_OPTTYPE_SUCCESS; i++) {
|
||||
/* XXX - separator between comments? */
|
||||
char *opt_comment = g_array_index(opts, char *, i);
|
||||
if (opt_comment != NULL && opt_comment[0] != '\0')
|
||||
gtk_text_buffer_insert_at_cursor(buffer, opt_comment, -1);
|
||||
}
|
||||
|
|
|
@ -242,14 +242,15 @@ QString CaptureFilePropertiesDialog::summaryToHtml()
|
|||
out << section_tmpl_.arg(tr("Capture"));
|
||||
out << table_begin;
|
||||
|
||||
wtap_optionblock_t shb_inf = wtap_file_get_shb(cap_file_.capFile()->wth);
|
||||
wtap_block_t shb_inf = wtap_file_get_shb(cap_file_.capFile()->wth);
|
||||
char *str;
|
||||
|
||||
if (shb_inf != NULL) {
|
||||
QString capture_hardware(unknown);
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_HARDWARE, &str);
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
capture_hardware = str;
|
||||
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_HARDWARE, &str) == WTAP_OPTTYPE_SUCCESS) {
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
capture_hardware = str;
|
||||
}
|
||||
}
|
||||
// capture HW
|
||||
out << table_row_begin
|
||||
|
@ -258,9 +259,10 @@ QString CaptureFilePropertiesDialog::summaryToHtml()
|
|||
<< table_row_end;
|
||||
|
||||
QString capture_os(unknown);
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_OS, &str);
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
capture_os = str;
|
||||
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_OS, &str) == WTAP_OPTTYPE_SUCCESS) {
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
capture_os = str;
|
||||
}
|
||||
}
|
||||
out << table_row_begin
|
||||
<< table_vheader_tmpl.arg(tr("OS"))
|
||||
|
@ -268,9 +270,10 @@ QString CaptureFilePropertiesDialog::summaryToHtml()
|
|||
<< table_row_end;
|
||||
|
||||
QString capture_app(unknown);
|
||||
wtap_optionblock_get_option_string(shb_inf, OPT_SHB_USERAPPL, &str);
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
capture_app = str;
|
||||
if (wtap_block_get_string_option_value(shb_inf, OPT_SHB_USERAPPL, &str) == WTAP_OPTTYPE_SUCCESS) {
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
capture_app = str;
|
||||
}
|
||||
}
|
||||
out << table_row_begin
|
||||
<< table_vheader_tmpl.arg(tr("Application"))
|
||||
|
|
|
@ -197,7 +197,22 @@ ResolvedAddressesDialog::ResolvedAddressesDialog(QWidget *parent, CaptureFile *c
|
|||
wtap* wth = capture_file->capFile()->wth;
|
||||
if (wth) {
|
||||
// might return null
|
||||
comment_ = wtap_get_nrb_comment(wth);
|
||||
wtap_block_t nrb_hdr;
|
||||
|
||||
/*
|
||||
* XXX - support multiple NRBs.
|
||||
*/
|
||||
nrb_hdr = wtap_file_get_nrb(wth);
|
||||
if (nrb_hdr != NULL) {
|
||||
char *str;
|
||||
|
||||
/*
|
||||
* XXX - support multiple comments.
|
||||
*/
|
||||
if (wtap_block_get_nth_string_option_value(nrb_hdr, OPT_COMMENT, 0, &str) == WTAP_OPTTYPE_SUCCESS) {
|
||||
comment_ = str;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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("");
|
||||
get_os_version_info(os_info_str);
|
||||
|
||||
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));
|
||||
g_free(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);
|
||||
|
||||
|
|
|
@ -946,7 +946,7 @@ int erf_dump_open(wtap_dumper *wdh, int *err)
|
|||
*/
|
||||
int erf_populate_interfaces(wtap *wth)
|
||||
{
|
||||
wtap_optionblock_t int_data;
|
||||
wtap_block_t int_data;
|
||||
wtapng_if_descr_mandatory_t* int_data_mand;
|
||||
int i;
|
||||
|
||||
|
@ -956,8 +956,8 @@ int erf_populate_interfaces(wtap *wth)
|
|||
/* Preemptively create interface entries for 4 interfaces, since this is the max number in ERF */
|
||||
for (i=0; i<4; i++) {
|
||||
|
||||
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_ERF;
|
||||
/* int_data.time_units_per_second = (1LL<<32); ERF format resolution is 2^-32, capture resolution is unknown */
|
||||
|
@ -969,9 +969,9 @@ int erf_populate_interfaces(wtap *wth)
|
|||
/* XXX: if_IPv6addr opt 5 Interface network address and prefix length (stored in the last byte).*/
|
||||
/* XXX: if_MACaddr opt 6 Interface Hardware MAC address (48 bits).*/
|
||||
/* XXX: if_EUIaddr opt 7 Interface Hardware EUI address (64 bits)*/
|
||||
wtap_optionblock_set_option_uint64(int_data, OPT_IDB_SPEED, 0); /* Unknown - XXX should be left at default? */
|
||||
/* XXX: if_speed opt 8 Interface speed (in bits per second)*/
|
||||
/* int_data.if_tsresol = 0xa0; ERF format resolution is 2^-32 = 0xa0, capture resolution is unknown */
|
||||
wtap_optionblock_set_option_uint8(int_data, OPT_IDB_TSRESOL, 0x09); /* XXX Since Wireshark only supports down to nanosecond resolution we have to dilute to this */
|
||||
wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 0x09); /* XXX Since Wireshark only supports down to nanosecond resolution we have to dilute to this */
|
||||
|
||||
/* XXX: if_tzone 10 Time zone for GMT support (TODO: specify better). */
|
||||
|
||||
|
@ -980,8 +980,8 @@ int erf_populate_interfaces(wtap *wth)
|
|||
int_data_mand->num_stat_entries = 0;
|
||||
int_data_mand->interface_statistics = NULL;
|
||||
|
||||
wtap_optionblock_set_option_string_format(int_data, OPT_IDB_NAME, "Port %c", 'A'+i);
|
||||
wtap_optionblock_set_option_string_format(int_data, OPT_IDB_DESCR, "ERF Interface Id %d (Port %c)", i, 'A'+i);
|
||||
wtap_block_add_string_option_format(int_data, OPT_IDB_NAME, "Port %c", 'A'+i);
|
||||
wtap_block_add_string_option_format(int_data, OPT_IDB_DESCR, "ERF Interface Id %d (Port %c)", i, 'A'+i);
|
||||
|
||||
g_array_append_val(wth->interface_data, int_data);
|
||||
}
|
||||
|
@ -1065,7 +1065,7 @@ static struct erf_if_mapping* erf_find_interface_mapping(erf_t *erf_priv, guint6
|
|||
return (struct erf_if_mapping*) g_hash_table_lookup(erf_priv->if_map, &if_map_lookup);
|
||||
}
|
||||
|
||||
static void erf_set_interface_descr(wtap_optionblock_t block, guint option_id, guint64 host_id, guint8 source_id, guint8 if_num, const gchar *descr)
|
||||
static void erf_set_interface_descr(wtap_block_t block, guint option_id, guint64 host_id, guint8 source_id, guint8 if_num, const gchar *descr)
|
||||
{
|
||||
/* Source XXX,*/
|
||||
char sourceid_buf[16];
|
||||
|
@ -1084,9 +1084,9 @@ static void erf_set_interface_descr(wtap_optionblock_t block, guint option_id, g
|
|||
}
|
||||
|
||||
if (descr) {
|
||||
wtap_optionblock_set_option_string_format(block, option_id, "%s (ERF%s%s Interface %d)", descr, hostid_buf, sourceid_buf, if_num);
|
||||
wtap_block_set_string_option_value_format(block, option_id, "%s (ERF%s%s Interface %d)", descr, hostid_buf, sourceid_buf, if_num);
|
||||
} else {
|
||||
wtap_optionblock_set_option_string_format(block, option_id, "Port %c (ERF%s%s Interface %d)", 'A'+if_num, hostid_buf, sourceid_buf, if_num);
|
||||
wtap_block_set_string_option_value_format(block, option_id, "Port %c (ERF%s%s Interface %d)", 'A'+if_num, hostid_buf, sourceid_buf, if_num);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1096,7 +1096,7 @@ static int erf_update_implicit_host_id(erf_t *erf_priv, wtap *wth, guint64 impli
|
|||
gpointer iter_value;
|
||||
GList* implicit_list = NULL;
|
||||
GList* item = NULL;
|
||||
wtap_optionblock_t int_data;
|
||||
wtap_block_t int_data;
|
||||
struct erf_if_mapping* if_map = NULL;
|
||||
int i;
|
||||
|
||||
|
@ -1128,7 +1128,7 @@ static int erf_update_implicit_host_id(erf_t *erf_priv, wtap *wth, guint64 impli
|
|||
for (i = 0; i < 4; i++) {
|
||||
if (if_map->interfaces[i].if_index >= 0) {
|
||||
/* XXX: this is a pointer! */
|
||||
int_data = g_array_index(wth->interface_data, wtap_optionblock_t, if_map->interfaces[i].if_index);
|
||||
int_data = g_array_index(wth->interface_data, wtap_block_t, if_map->interfaces[i].if_index);
|
||||
erf_set_interface_descr(int_data, OPT_IDB_NAME, implicit_host_id, if_map->source_id, (guint8) i, if_map->interfaces[i].name);
|
||||
erf_set_interface_descr(int_data, OPT_IDB_DESCR, implicit_host_id, if_map->source_id, (guint8) i, if_map->interfaces[i].descr);
|
||||
}
|
||||
|
@ -1147,7 +1147,7 @@ static int erf_update_implicit_host_id(erf_t *erf_priv, wtap *wth, guint64 impli
|
|||
|
||||
int erf_populate_interface(erf_t *erf_priv, wtap *wth, union wtap_pseudo_header *pseudo_header, guint64 host_id, guint8 source_id, guint8 if_num)
|
||||
{
|
||||
wtap_optionblock_t int_data;
|
||||
wtap_block_t int_data;
|
||||
wtapng_if_descr_mandatory_t* int_data_mand;
|
||||
struct erf_if_mapping* if_map = NULL;
|
||||
|
||||
|
@ -1184,8 +1184,8 @@ int erf_populate_interface(erf_t *erf_priv, wtap *wth, union wtap_pseudo_header
|
|||
return if_map->interfaces[if_num].if_index;
|
||||
}
|
||||
|
||||
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_ERF;
|
||||
/* int_data.time_units_per_second = (1LL<<32); ERF format resolution is 2^-32, capture resolution is unknown */
|
||||
|
@ -1197,9 +1197,9 @@ int erf_populate_interface(erf_t *erf_priv, wtap *wth, union wtap_pseudo_header
|
|||
/* XXX: if_IPv6addr opt 5 Interface network address and prefix length (stored in the last byte).*/
|
||||
/* XXX: if_MACaddr opt 6 Interface Hardware MAC address (48 bits).*/
|
||||
/* XXX: if_EUIaddr opt 7 Interface Hardware EUI address (64 bits)*/
|
||||
wtap_optionblock_set_option_uint64(int_data, OPT_IDB_SPEED, 0); /* Unknown - XXX should be left at default? */
|
||||
/* XXX: if_speed opt 8 Interface speed (in bits per second)*/
|
||||
/* int_data.if_tsresol = 0xa0; ERF format resolution is 2^-32 = 0xa0, capture resolution is unknown */
|
||||
wtap_optionblock_set_option_uint8(int_data, OPT_IDB_TSRESOL, 0x09); /* XXX Since Wireshark only supports down to nanosecond resolution we have to dilute to this */
|
||||
wtap_block_add_uint8_option(int_data, OPT_IDB_TSRESOL, 0x09); /* XXX Since Wireshark only supports down to nanosecond resolution we have to dilute to this */
|
||||
/* XXX: if_tzone 10 Time zone for GMT support (TODO: specify better). */
|
||||
/* XXX if_tsoffset; opt 14 A 64 bits integer value that specifies an offset (in seconds)...*/
|
||||
/* Interface statistics */
|
||||
|
@ -1247,7 +1247,7 @@ static int populate_capture_host_info(erf_t *erf_priv, wtap *wth, union wtap_pse
|
|||
{
|
||||
struct erf_meta_tag tag = {0, 0, NULL};
|
||||
|
||||
wtap_optionblock_t shb_hdr;
|
||||
wtap_block_t shb_hdr;
|
||||
char* tmp;
|
||||
gchar* app_name = NULL;
|
||||
gchar* app_version = NULL;
|
||||
|
@ -1262,7 +1262,7 @@ static int populate_capture_host_info(erf_t *erf_priv, wtap *wth, union wtap_pse
|
|||
|
||||
/* XXX: wth->shb_hdr is already created by different layer, using directly for now. */
|
||||
/* XXX: Only one section header is supported at this time */
|
||||
shb_hdr = g_array_index(wth->shb_hdrs, wtap_optionblock_t, 0);
|
||||
shb_hdr = g_array_index(wth->shb_hdrs, wtap_block_t, 0);
|
||||
|
||||
while ((tagtotallength = erf_meta_read_tag(&tag, state->tag_ptr, state->remaining_len)) && !ERF_META_IS_SECTION(tag.type)) {
|
||||
switch (state->sectiontype) {
|
||||
|
@ -1274,7 +1274,7 @@ static int populate_capture_host_info(erf_t *erf_priv, wtap *wth, union wtap_pse
|
|||
|
||||
switch (tag.type) {
|
||||
case ERF_META_TAG_comment:
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_COMMENT, tag.value, tag.length);
|
||||
wtap_block_add_string_option(shb_hdr, OPT_COMMENT, tag.value, tag.length);
|
||||
break;
|
||||
}
|
||||
/* Fall through */
|
||||
|
@ -1299,7 +1299,7 @@ static int populate_capture_host_info(erf_t *erf_priv, wtap *wth, union wtap_pse
|
|||
descr = g_strndup((gchar*) tag.value, tag.length);
|
||||
break;
|
||||
case ERF_META_TAG_os:
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_OS, tag.value, tag.length);
|
||||
wtap_block_set_string_option_value(shb_hdr, OPT_SHB_OS, tag.value, tag.length);
|
||||
break;
|
||||
case ERF_META_TAG_app_name:
|
||||
g_free(app_name);
|
||||
|
@ -1328,7 +1328,7 @@ static int populate_capture_host_info(erf_t *erf_priv, wtap *wth, union wtap_pse
|
|||
/* If no app_version will just use app_name */
|
||||
|
||||
tmp = g_strjoin(" ", app_name, app_version, NULL);
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_USERAPPL, tmp, strlen(tmp));
|
||||
wtap_block_set_string_option_value(shb_hdr, OPT_SHB_USERAPPL, tmp, strlen(tmp));
|
||||
g_free(tmp);
|
||||
|
||||
g_free(app_name);
|
||||
|
@ -1357,13 +1357,13 @@ static int populate_capture_host_info(erf_t *erf_priv, wtap *wth, union wtap_pse
|
|||
/* Combine into "Description (Model; CPU)" */
|
||||
if (state->sectiontype == ERF_META_SECTION_HOST && descr) {
|
||||
if (modelcpu) {
|
||||
wtap_optionblock_set_option_string_format(shb_hdr, OPT_SHB_HARDWARE, "%s (%s)", descr, modelcpu);
|
||||
wtap_block_set_string_option_value_format(shb_hdr, OPT_SHB_HARDWARE, "%s (%s)", descr, modelcpu);
|
||||
} else {
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_HARDWARE, descr, strlen(descr));
|
||||
wtap_block_set_string_option_value(shb_hdr, OPT_SHB_HARDWARE, descr, strlen(descr));
|
||||
/*descr = NULL;*/
|
||||
}
|
||||
} else if (modelcpu) {
|
||||
wtap_optionblock_set_option_string(shb_hdr, OPT_SHB_HARDWARE, modelcpu, strlen(modelcpu));
|
||||
wtap_block_set_string_option_value(shb_hdr, OPT_SHB_HARDWARE, modelcpu, strlen(modelcpu));
|
||||
/*modelcpu = NULL;*/
|
||||
}
|
||||
|
||||
|
@ -1428,7 +1428,7 @@ static int populate_interface_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo
|
|||
struct erf_meta_tag tag = {0, 0, NULL};
|
||||
guint32 tagtotallength;
|
||||
int interface_index = -1;
|
||||
wtap_optionblock_t int_data = NULL;
|
||||
wtap_block_t int_data = NULL;
|
||||
wtapng_if_descr_mandatory_t* int_data_mand = NULL;
|
||||
wtapng_if_descr_filter_t if_filter;
|
||||
guint32 if_num = 0;
|
||||
|
@ -1487,8 +1487,8 @@ static int populate_interface_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo
|
|||
|
||||
/* Get the wiretap interface metadata */
|
||||
if (interface_index >= 0) {
|
||||
int_data = g_array_index(wth->interface_data, wtap_optionblock_t, interface_index);
|
||||
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(int_data);
|
||||
int_data = g_array_index(wth->interface_data, wtap_block_t, interface_index);
|
||||
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
|
||||
} else if (interface_index == -2) {
|
||||
/* timing/unknown port */
|
||||
return 0;
|
||||
|
@ -1532,7 +1532,7 @@ static int populate_interface_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo
|
|||
break;
|
||||
case ERF_META_TAG_if_speed:
|
||||
if (tag.length >= 8)
|
||||
wtap_optionblock_set_option_uint64(int_data, OPT_IDB_SPEED, pntoh64(tag.value));
|
||||
wtap_block_add_uint64_option(int_data, OPT_IDB_SPEED, pntoh64(tag.value));
|
||||
break;
|
||||
case ERF_META_TAG_if_num:
|
||||
/*
|
||||
|
@ -1544,7 +1544,7 @@ static int populate_interface_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo
|
|||
break;
|
||||
case ERF_META_TAG_fcs_len:
|
||||
if (tag.length >= 4) {
|
||||
wtap_optionblock_set_option_uint8(int_data, OPT_IDB_FCSLEN, (guint8) pntoh32(tag.value));
|
||||
wtap_block_add_uint8_option(int_data, OPT_IDB_FCSLEN, (guint8) pntoh32(tag.value));
|
||||
if_info->set_flags.fcs_len = 1;
|
||||
}
|
||||
break;
|
||||
|
@ -1556,11 +1556,11 @@ static int populate_interface_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo
|
|||
}
|
||||
break;
|
||||
case ERF_META_TAG_comment:
|
||||
wtap_optionblock_set_option_string(int_data, OPT_COMMENT, tag.value, tag.length);
|
||||
wtap_block_add_string_option(int_data, OPT_COMMENT, tag.value, tag.length);
|
||||
break;
|
||||
case ERF_META_TAG_filter:
|
||||
if_filter.if_filter_str = g_strndup((gchar*) tag.value, tag.length);
|
||||
wtap_optionblock_set_option_custom(int_data, OPT_IDB_FILTER, &if_filter);
|
||||
wtap_block_add_custom_option(int_data, OPT_IDB_FILTER, &if_filter, sizeof if_filter);
|
||||
if_info->set_flags.filter = 1;
|
||||
break;
|
||||
default:
|
||||
|
@ -1584,7 +1584,7 @@ static int populate_interface_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo
|
|||
if (state->if_map->module_filter_str && !if_info->set_flags.filter) {
|
||||
/* Duplicate because might use with multiple interfaces */
|
||||
if_filter.if_filter_str = g_strdup(state->if_map->module_filter_str);
|
||||
wtap_optionblock_set_option_custom(int_data, OPT_IDB_FILTER, &if_filter);
|
||||
wtap_block_add_custom_option(int_data, OPT_IDB_FILTER, &if_filter, sizeof if_filter);
|
||||
/*
|
||||
* Don't set flag because stream is more specific than module. Interface
|
||||
* metadata bit is set so we don't look at the filter again regardless.
|
||||
|
@ -1592,7 +1592,7 @@ static int populate_interface_info(erf_t *erf_priv, wtap *wth, union wtap_pseudo
|
|||
}
|
||||
|
||||
if (state->if_map->module_fcs_len != -1 && !if_info->set_flags.fcs_len) {
|
||||
wtap_optionblock_set_option_uint8(int_data, OPT_IDB_FCSLEN, (guint8) state->if_map->module_fcs_len);
|
||||
wtap_block_add_uint8_option(int_data, OPT_IDB_FCSLEN, (guint8) state->if_map->module_fcs_len);
|
||||
if_info->set_flags.fcs_len = 1;
|
||||
}
|
||||
|
||||
|
@ -1611,7 +1611,7 @@ static int populate_stream_info(erf_t *erf_priv _U_, wtap *wth, union wtap_pseud
|
|||
struct erf_meta_tag tag = {0, 0, NULL};
|
||||
guint32 tagtotallength;
|
||||
int interface_index = -1;
|
||||
wtap_optionblock_t int_data = NULL;
|
||||
wtap_block_t int_data = NULL;
|
||||
wtapng_if_descr_mandatory_t* int_data_mand = NULL;
|
||||
wtapng_if_descr_filter_t if_filter;
|
||||
guint32 if_num = 0;
|
||||
|
@ -1673,8 +1673,8 @@ static int populate_stream_info(erf_t *erf_priv _U_, wtap *wth, union wtap_pseud
|
|||
interface_index = if_info->if_index;
|
||||
/* Get the wiretap interface metadata */
|
||||
if (interface_index >= 0) {
|
||||
int_data = g_array_index(wth->interface_data, wtap_optionblock_t, interface_index);
|
||||
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(int_data);
|
||||
int_data = g_array_index(wth->interface_data, wtap_block_t, interface_index);
|
||||
int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(int_data);
|
||||
}
|
||||
|
||||
if (!int_data) {
|
||||
|
@ -1689,10 +1689,25 @@ static int populate_stream_info(erf_t *erf_priv _U_, wtap *wth, union wtap_pseud
|
|||
gint8 fcs_len = (gint8) pntoh32(tag.value);
|
||||
guint8 old_fcs_len = 0;
|
||||
|
||||
wtap_optionblock_get_option_uint8(int_data, OPT_IDB_FCSLEN, &old_fcs_len);
|
||||
if (fcs_len > old_fcs_len || !if_info->set_flags.fcs_len) {
|
||||
wtap_optionblock_set_option_uint8(int_data, OPT_IDB_FCSLEN, (guint8) pntoh32(tag.value));
|
||||
if_info->set_flags.fcs_len = 1;
|
||||
switch (wtap_block_get_uint8_option_value(int_data, OPT_IDB_FCSLEN, &old_fcs_len)) {
|
||||
|
||||
case WTAP_OPTTYPE_SUCCESS:
|
||||
/* We already have an FCS length option; update it. */
|
||||
if (fcs_len > old_fcs_len || !if_info->set_flags.fcs_len) {
|
||||
wtap_block_set_uint8_option_value(int_data, OPT_IDB_FCSLEN, (guint8) pntoh32(tag.value));
|
||||
if_info->set_flags.fcs_len = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case WTAP_OPTTYPE_NOT_FOUND:
|
||||
/* We don't have an FCS length option; add it. */
|
||||
wtap_block_add_uint8_option(int_data, OPT_IDB_FCSLEN, (guint8) pntoh32(tag.value));
|
||||
if_info->set_flags.fcs_len = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
/* "shouldn't happen" */
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1711,7 +1726,7 @@ static int populate_stream_info(erf_t *erf_priv _U_, wtap *wth, union wtap_pseud
|
|||
/* Override only if not set */
|
||||
if (!if_info->set_flags.filter) {
|
||||
if_filter.if_filter_str = g_strndup((gchar*) tag.value, tag.length);
|
||||
wtap_optionblock_set_option_custom(int_data, OPT_IDB_FILTER, &if_filter);
|
||||
wtap_block_add_custom_option(int_data, OPT_IDB_FILTER, &if_filter, sizeof if_filter);
|
||||
if_info->set_flags.filter = 1;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -714,7 +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;
|
||||
wtap_block_t shb;
|
||||
|
||||
*err = 0;
|
||||
*err_info = NULL;
|
||||
|
@ -834,15 +834,15 @@ 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_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
|
||||
shb = wtap_optionblock_create(WTAP_OPTION_BLOCK_NG_SECTION);
|
||||
wth->shb_hdrs = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
|
||||
shb = wtap_block_create(WTAP_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).
|
||||
* Always initing it here saves checking for a NULL ptr later. */
|
||||
wth->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
|
||||
wth->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
|
||||
|
||||
if (wth->random_fh) {
|
||||
wth->fast_seek = g_ptr_array_new();
|
||||
|
@ -1103,17 +1103,17 @@ success:
|
|||
if ((wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP) ||
|
||||
(wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC)) {
|
||||
|
||||
wtap_optionblock_t descr = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
|
||||
wtapng_if_descr_mandatory_t* descr_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(descr);
|
||||
wtap_block_t descr = wtap_block_create(WTAP_BLOCK_IF_DESCR);
|
||||
wtapng_if_descr_mandatory_t* descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(descr);
|
||||
|
||||
descr_mand->wtap_encap = wth->file_encap;
|
||||
if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_PCAP_NSEC) {
|
||||
descr_mand->time_units_per_second = 1000000000; /* nanosecond resolution */
|
||||
wtap_optionblock_set_option_uint8(descr, OPT_IDB_TSRESOL, 9);
|
||||
wtap_block_add_uint8_option(descr, OPT_IDB_TSRESOL, 9);
|
||||
descr_mand->tsprecision = WTAP_TSPREC_NSEC;
|
||||
} else {
|
||||
descr_mand->time_units_per_second = 1000000; /* default microsecond resolution */
|
||||
wtap_optionblock_set_option_uint8(descr, OPT_IDB_TSRESOL, 6);
|
||||
/* No need to add an option, this is the default */
|
||||
descr_mand->tsprecision = WTAP_TSPREC_USEC;
|
||||
}
|
||||
descr_mand->link_type = wtap_wtap_encap_to_pcap_encap(wth->file_encap);
|
||||
|
@ -2166,7 +2166,7 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co
|
|||
GArray* nrb_hdrs, int *err)
|
||||
{
|
||||
wtap_dumper *wdh;
|
||||
wtap_optionblock_t descr, file_int_data;
|
||||
wtap_block_t descr, file_int_data;
|
||||
wtapng_if_descr_mandatory_t *descr_mand, *file_int_data_mand;
|
||||
|
||||
/* Check whether we can open a capture file with that file type
|
||||
|
@ -2188,32 +2188,29 @@ wtap_dump_init_dumper(int file_type_subtype, int encap, int snaplen, gboolean co
|
|||
guint itf_count;
|
||||
|
||||
/* XXX: what free's this stuff? */
|
||||
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
|
||||
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
|
||||
for (itf_count = 0; itf_count < idb_inf->interface_data->len; itf_count++) {
|
||||
file_int_data = g_array_index(idb_inf->interface_data, wtap_optionblock_t, itf_count);
|
||||
file_int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(file_int_data);
|
||||
descr = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
|
||||
wtap_optionblock_copy_options(descr, file_int_data);
|
||||
file_int_data = g_array_index(idb_inf->interface_data, wtap_block_t, itf_count);
|
||||
file_int_data_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(file_int_data);
|
||||
descr = wtap_block_create(WTAP_BLOCK_IF_DESCR);
|
||||
wtap_block_copy(descr, file_int_data);
|
||||
if ((encap != WTAP_ENCAP_PER_PACKET) && (encap != file_int_data_mand->wtap_encap)) {
|
||||
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(descr);
|
||||
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(descr);
|
||||
descr_mand->wtap_encap = encap;
|
||||
descr_mand->link_type = wtap_wtap_encap_to_pcap_encap(encap);
|
||||
}
|
||||
g_array_append_val(wdh->interface_data, descr);
|
||||
}
|
||||
} else {
|
||||
descr = wtap_optionblock_create(WTAP_OPTION_BLOCK_IF_DESCR);
|
||||
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_optionblock_get_mandatory_data(descr);
|
||||
descr = wtap_block_create(WTAP_BLOCK_IF_DESCR);
|
||||
descr_mand = (wtapng_if_descr_mandatory_t*)wtap_block_get_mandatory_data(descr);
|
||||
descr_mand->wtap_encap = encap;
|
||||
descr_mand->time_units_per_second = 1000000; /* default microsecond resolution */
|
||||
descr_mand->link_type = wtap_wtap_encap_to_pcap_encap(encap);
|
||||
descr_mand->snap_len = snaplen;
|
||||
wtap_optionblock_set_option_string(descr, OPT_IDB_NAME, "Unknown/not available in original file format(libpcap)",
|
||||
strlen("Unknown/not available in original file format(libpcap)"));
|
||||
|
||||
descr_mand->num_stat_entries = 0; /* Number of ISB:s */
|
||||
descr_mand->interface_statistics = NULL;
|
||||
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_optionblock_t));
|
||||
wdh->interface_data = g_array_new(FALSE, FALSE, sizeof(wtap_block_t));
|
||||
g_array_append_val(wdh->interface_data, descr);
|
||||
}
|
||||
return wdh;
|
||||
|
|