ftypes: Make accessor functions type safe

This commit is contained in:
João Valverde 2022-06-19 00:31:30 +01:00 committed by A Wireshark GitLab Utility
parent 0cadfff04a
commit 0615ba6317
16 changed files with 151 additions and 99 deletions

View File

@ -42,7 +42,7 @@ string_walk(GSList *args, guint32 arg_count, GSList **retval, gchar(*conv_func)(
arg_fvalue = (fvalue_t *)arg1->data;
/* XXX - it would be nice to handle FT_TVBUFF, too */
if (IS_FT_STRING(fvalue_type_ftenum(arg_fvalue))) {
s = (char *)wmem_strdup(NULL, (gchar *)fvalue_get(arg_fvalue));
s = wmem_strdup(NULL, fvalue_get_string(arg_fvalue));
for (c = s; *c; c++) {
*c = conv_func(*c);
}

View File

@ -6051,7 +6051,7 @@ static gchar *sip_follow_conv_filter(epan_dissect_t *edt, packet_info *pinfo _U_
int hfid = proto_registrar_get_id_byname("sip.Call-ID");
GPtrArray *gp = proto_find_first_finfo(edt->tree, hfid);
if (gp != NULL && gp->len != 0) {
filter = ws_strdup_printf("sip.Call-ID == \"%s\"", (gchar *)fvalue_get(&((field_info *)gp->pdata[0])->value));
filter = ws_strdup_printf("sip.Call-ID == \"%s\"", fvalue_get_string(&((field_info *)gp->pdata[0])->value));
}
g_ptr_array_free(gp, TRUE);
} else {

View File

@ -154,8 +154,8 @@ system_id_fvalue_set(fvalue_t *fv, GByteArray *value)
fv->value.bytes = value;
}
static gpointer
value_get(fvalue_t *fv)
static const guint8 *
bytes_fvalue_get(fvalue_t *fv)
{
return fv->value.bytes->data;
}
@ -626,7 +626,7 @@ ftype_register_bytes(void)
bytes_to_repr, /* val_to_string_repr */
{ .set_value_byte_array = bytes_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_bytes = bytes_fvalue_get }, /* union get_value */
cmp_order,
cmp_contains,
@ -659,7 +659,7 @@ ftype_register_bytes(void)
bytes_to_repr, /* val_to_string_repr */
{ .set_value_byte_array = bytes_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_bytes = bytes_fvalue_get }, /* union get_value */
cmp_order,
cmp_contains,
@ -692,7 +692,7 @@ ftype_register_bytes(void)
bytes_to_repr, /* val_to_string_repr */
{ .set_value_bytes = ax25_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_bytes = bytes_fvalue_get }, /* union get_value */
cmp_order,
cmp_contains,
@ -725,7 +725,7 @@ ftype_register_bytes(void)
bytes_to_repr, /* val_to_string_repr */
{ .set_value_bytes = vines_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_bytes = bytes_fvalue_get }, /* union get_value */
cmp_order,
cmp_contains,
@ -758,7 +758,7 @@ ftype_register_bytes(void)
bytes_to_repr, /* val_to_string_repr */
{ .set_value_bytes = ether_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_bytes = bytes_fvalue_get }, /* union get_value */
cmp_order,
cmp_contains,
@ -791,7 +791,7 @@ ftype_register_bytes(void)
oid_to_repr, /* val_to_string_repr */
{ .set_value_byte_array = oid_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_bytes = bytes_fvalue_get }, /* union get_value */
cmp_order,
cmp_contains,
@ -824,7 +824,7 @@ ftype_register_bytes(void)
rel_oid_to_repr, /* val_to_string_repr */
{ .set_value_byte_array = oid_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_bytes = bytes_fvalue_get }, /* union get_value */
cmp_order,
cmp_contains,
@ -857,7 +857,7 @@ ftype_register_bytes(void)
system_id_to_repr, /* val_to_string_repr */
{ .set_value_byte_array = system_id_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_bytes = bytes_fvalue_get }, /* union get_value */
cmp_order,
cmp_contains,
@ -890,7 +890,7 @@ ftype_register_bytes(void)
bytes_to_repr, /* val_to_string_repr */
{ .set_value_bytes = fcwwn_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_bytes = bytes_fvalue_get }, /* union get_value */
cmp_order,
cmp_contains,

View File

@ -21,7 +21,7 @@ guid_fvalue_set_guid(fvalue_t *fv, const e_guid_t *value)
fv->value.guid = *value;
}
static gpointer
static const e_guid_t *
value_get(fvalue_t *fv)
{
return &(fv->value.guid);
@ -111,7 +111,7 @@ ftype_register_guid(void)
guid_to_repr, /* val_to_string_repr */
{ .set_value_guid = guid_fvalue_set_guid }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_guid = value_get }, /* union get_value */
cmp_order,
NULL,

View File

@ -85,7 +85,7 @@ ipv6_to_repr(wmem_allocator_t *scope, const fvalue_t *fv, ftrepr_t rtype _U_, in
return ip6_to_str(scope, &(fv->value.ipv6.addr));
}
static gpointer
static const guint8 *
value_get(fvalue_t *fv)
{
return fv->value.ipv6.addr.bytes;
@ -186,7 +186,7 @@ ftype_register_ipv6(void)
ipv6_to_repr, /* val_to_string_repr */
{ .set_value_bytes = ipv6_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_bytes = value_get }, /* union get_value */
cmp_order,
NULL, /* XXX, cmp_contains, needed? ipv4 doesn't support it */

View File

@ -190,7 +190,7 @@ val_to_repr(wmem_allocator_t *scope, const fvalue_t *fv, ftrepr_t rtype _U_, int
return buf;
}
static gpointer
static tvbuff_t *
value_get(fvalue_t *fv)
{
if (fv->value.protocol.length < 0)
@ -365,7 +365,7 @@ ftype_register_tvbuff(void)
val_to_repr, /* val_to_string_repr */
{ .set_value_protocol = value_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_protocol = value_get }, /* union get_value */
cmp_order,
cmp_contains,

View File

@ -57,7 +57,7 @@ string_to_repr(wmem_allocator_t *scope, const fvalue_t *fv, ftrepr_t rtype, int
}
static gpointer
static const char *
value_get(fvalue_t *fv)
{
return fv->value.string;
@ -183,7 +183,7 @@ ftype_register_string(void)
string_to_repr, /* val_to_string_repr */
{ .set_value_string = string_fvalue_set_string }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_string = value_get }, /* union get_value */
cmp_order,
cmp_contains,
@ -215,7 +215,7 @@ ftype_register_string(void)
string_to_repr, /* val_to_string_repr */
{ .set_value_string = string_fvalue_set_string }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_string = value_get }, /* union get_value */
cmp_order,
cmp_contains, /* cmp_contains */
@ -247,7 +247,7 @@ ftype_register_string(void)
string_to_repr, /* val_to_string_repr */
{ .set_value_string = string_fvalue_set_string }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_string = value_get }, /* union get_value */
cmp_order,
cmp_contains, /* cmp_contains */
@ -279,7 +279,7 @@ ftype_register_string(void)
string_to_repr, /* val_to_string_repr */
{ .set_value_string = string_fvalue_set_string }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_string = value_get }, /* union get_value */
cmp_order,
cmp_contains, /* cmp_contains */
@ -311,7 +311,7 @@ ftype_register_string(void)
string_to_repr, /* val_to_string_repr */
{ .set_value_string = string_fvalue_set_string }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_string = value_get }, /* union get_value */
cmp_order,
cmp_contains, /* cmp_contains */

View File

@ -332,7 +332,7 @@ time_fvalue_set(fvalue_t *fv, const nstime_t *value)
fv->value.time = *value;
}
static gpointer
static const nstime_t *
value_get(fvalue_t *fv)
{
return &(fv->value.time);
@ -463,7 +463,7 @@ ftype_register_time(void)
absolute_val_to_repr, /* val_to_string_repr */
{ .set_value_time = time_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_time = value_get }, /* union get_value */
cmp_order,
NULL, /* cmp_contains */
@ -495,7 +495,7 @@ ftype_register_time(void)
relative_val_to_repr, /* val_to_string_repr */
{ .set_value_time = time_fvalue_set }, /* union set_value */
{ .get_value_ptr = value_get }, /* union get_value */
{ .get_value_time = value_get }, /* union get_value */
cmp_order,
NULL, /* cmp_contains */

View File

@ -48,7 +48,11 @@ typedef void (*FvalueSetUnsignedInteger64Func)(fvalue_t*, guint64);
typedef void (*FvalueSetSignedInteger64Func)(fvalue_t*, gint64);
typedef void (*FvalueSetFloatingFunc)(fvalue_t*, gdouble);
typedef gpointer (*FvalueGetFunc)(fvalue_t*);
typedef const guint8 *(*FvalueGetBytesFunc)(fvalue_t*);
typedef const e_guid_t *(*FvalueGetGuidFunc)(fvalue_t*);
typedef const nstime_t *(*FvalueGetTimeFunc)(fvalue_t*);
typedef const gchar *(*FvalueGetStringFunc)(fvalue_t*);
typedef tvbuff_t *(*FvalueGetProtocolFunc)(fvalue_t*);
typedef guint32 (*FvalueGetUnsignedIntegerFunc)(fvalue_t*);
typedef gint32 (*FvalueGetSignedIntegerFunc)(fvalue_t*);
typedef guint64 (*FvalueGetUnsignedInteger64Func)(fvalue_t*);
@ -79,26 +83,30 @@ struct _ftype_t {
FvalueToStringRepr val_to_string_repr;
union {
FvalueSetByteArrayFunc set_value_byte_array;
FvalueSetBytesFunc set_value_bytes;
FvalueSetGuidFunc set_value_guid;
FvalueSetTimeFunc set_value_time;
FvalueSetStringFunc set_value_string;
FvalueSetProtocolFunc set_value_protocol;
FvalueSetByteArrayFunc set_value_byte_array;
FvalueSetBytesFunc set_value_bytes;
FvalueSetGuidFunc set_value_guid;
FvalueSetTimeFunc set_value_time;
FvalueSetStringFunc set_value_string;
FvalueSetProtocolFunc set_value_protocol;
FvalueSetUnsignedIntegerFunc set_value_uinteger;
FvalueSetSignedIntegerFunc set_value_sinteger;
FvalueSetUnsignedInteger64Func set_value_uinteger64;
FvalueSetSignedInteger64Func set_value_sinteger64;
FvalueSetFloatingFunc set_value_floating;
FvalueSetFloatingFunc set_value_floating;
} set_value;
union {
FvalueGetFunc get_value_ptr;
FvalueGetBytesFunc get_value_bytes;
FvalueGetGuidFunc get_value_guid;
FvalueGetTimeFunc get_value_time;
FvalueGetStringFunc get_value_string;
FvalueGetProtocolFunc get_value_protocol;
FvalueGetUnsignedIntegerFunc get_value_uinteger;
FvalueGetSignedIntegerFunc get_value_sinteger;
FvalueGetUnsignedInteger64Func get_value_uinteger64;
FvalueGetSignedInteger64Func get_value_sinteger64;
FvalueGetFloatingFunc get_value_floating;
FvalueGetFloatingFunc get_value_floating;
} get_value;
FvalueCmp cmp_order;

View File

@ -704,9 +704,8 @@ fvalue_set_floating(fvalue_t *fv, gdouble value)
fv->ftype->set_value.set_value_floating(fv, value);
}
gpointer
fvalue_get(fvalue_t *fv)
const guint8 *
fvalue_get_bytes(fvalue_t *fv)
{
ws_assert(fv->ftype->ftype == FT_BYTES ||
fv->ftype->ftype == FT_UINT_BYTES ||
@ -717,14 +716,42 @@ fvalue_get(fvalue_t *fv)
fv->ftype->ftype == FT_REL_OID ||
fv->ftype->ftype == FT_SYSTEM_ID ||
fv->ftype->ftype == FT_FCWWN ||
fv->ftype->ftype == FT_GUID ||
fv->ftype->ftype == FT_IPv6 ||
fv->ftype->ftype == FT_PROTOCOL ||
IS_FT_STRING(fv->ftype->ftype) ||
fv->ftype->ftype == FT_UINT_STRING ||
IS_FT_TIME(fv->ftype->ftype));
ws_assert(fv->ftype->get_value.get_value_ptr);
return fv->ftype->get_value.get_value_ptr(fv);
fv->ftype->ftype == FT_IPv6);
ws_assert(fv->ftype->get_value.get_value_bytes);
return fv->ftype->get_value.get_value_bytes(fv);
}
const e_guid_t *
fvalue_get_guid(fvalue_t *fv)
{
ws_assert(fv->ftype->ftype == FT_GUID);
ws_assert(fv->ftype->get_value.get_value_guid);
return fv->ftype->get_value.get_value_guid(fv);
}
const nstime_t *
fvalue_get_time(fvalue_t *fv)
{
ws_assert(IS_FT_TIME(fv->ftype->ftype));
ws_assert(fv->ftype->get_value.get_value_time);
return fv->ftype->get_value.get_value_time(fv);
}
const char *
fvalue_get_string(fvalue_t *fv)
{
ws_assert(IS_FT_STRING(fv->ftype->ftype) ||
fv->ftype->ftype == FT_UINT_STRING);
ws_assert(fv->ftype->get_value.get_value_string);
return fv->ftype->get_value.get_value_string(fv);
}
tvbuff_t *
fvalue_get_protocol(fvalue_t *fv)
{
ws_assert(fv->ftype->ftype == FT_PROTOCOL);
ws_assert(fv->ftype->get_value.get_value_protocol);
return fv->ftype->get_value.get_value_protocol(fv);
}
guint32

View File

@ -338,8 +338,24 @@ void
fvalue_set_floating(fvalue_t *fv, gdouble value);
WS_DLL_PUBLIC
gpointer
fvalue_get(fvalue_t *fv);
const guint8 *
fvalue_get_bytes(fvalue_t *fv);
WS_DLL_PUBLIC
const e_guid_t *
fvalue_get_guid(fvalue_t *fv);
WS_DLL_PUBLIC
const nstime_t *
fvalue_get_time(fvalue_t *fv);
WS_DLL_PUBLIC
const char *
fvalue_get_string(fvalue_t *fv);
WS_DLL_PUBLIC
tvbuff_t *
fvalue_get_protocol(fvalue_t *fv);
WS_DLL_PUBLIC guint32
fvalue_get_uinteger(fvalue_t *fv);

View File

@ -1339,7 +1339,7 @@ ek_write_field_value(field_info *fi, write_json_data* pdata)
json_dumper_value_anyf(pdata->dumper, "false");
break;
case FT_ABSOLUTE_TIME:
t = (const nstime_t *)fvalue_get(&fi->value);
t = fvalue_get_time(&fi->value);
#ifdef _WIN32
/*
* Do not use gmtime_s(), as it will call and
@ -2683,7 +2683,7 @@ gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt)
case FT_BYTES:
{
gchar *ret;
guint8 *bytes = (guint8 *)fvalue_get(&fi->value);
const guint8 *bytes = fvalue_get_bytes(&fi->value);
if (bytes) {
dfilter_string = (gchar *)wmem_alloc(NULL, 3*fvalue_length(&fi->value));
switch (fi->hfinfo->display) {

View File

@ -6447,7 +6447,8 @@ proto_item_fill_display_label(field_info *finfo, gchar *display_label_str, const
header_field_info *hfinfo = finfo->hfinfo;
int label_len = 0;
char *tmp_str;
guint8 *bytes;
const char *str;
const guint8 *bytes;
guint32 number;
guint64 number64;
const true_false_string *tfstring;
@ -6456,7 +6457,6 @@ proto_item_fill_display_label(field_info *finfo, gchar *display_label_str, const
const char *number_out;
address addr;
ws_in4_addr ipv4;
ws_in6_addr *ipv6;
switch (hfinfo->type) {
@ -6468,20 +6468,20 @@ proto_item_fill_display_label(field_info *finfo, gchar *display_label_str, const
case FT_BYTES:
tmp_str = hfinfo_format_bytes(NULL,
hfinfo,
(guint8 *)fvalue_get(&finfo->value),
fvalue_get_bytes(&finfo->value),
fvalue_length(&finfo->value));
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
break;
case FT_ABSOLUTE_TIME:
tmp_str = abs_time_to_str(NULL, (const nstime_t *)fvalue_get(&finfo->value), hfinfo->display, TRUE);
tmp_str = abs_time_to_str(NULL, fvalue_get_time(&finfo->value), hfinfo->display, TRUE);
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
break;
case FT_RELATIVE_TIME:
tmp_str = rel_time_to_secs_str(NULL, (const nstime_t *)fvalue_get(&finfo->value));
tmp_str = rel_time_to_secs_str(NULL, fvalue_get_time(&finfo->value));
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
break;
@ -6629,46 +6629,46 @@ proto_item_fill_display_label(field_info *finfo, gchar *display_label_str, const
break;
case FT_IPv6:
ipv6 = (ws_in6_addr *)fvalue_get(&finfo->value);
set_address (&addr, AT_IPv6, sizeof(ws_in6_addr), ipv6);
bytes = fvalue_get_bytes(&finfo->value);
set_address (&addr, AT_IPv6, sizeof(ws_in6_addr), bytes);
address_to_str_buf(&addr, display_label_str, label_str_size);
label_len = (int)strlen(display_label_str);
break;
case FT_FCWWN:
set_address (&addr, AT_FCWWN, FCWWN_ADDR_LEN, fvalue_get(&finfo->value));
set_address (&addr, AT_FCWWN, FCWWN_ADDR_LEN, fvalue_get_bytes(&finfo->value));
address_to_str_buf(&addr, display_label_str, label_str_size);
label_len = (int)strlen(display_label_str);
break;
case FT_ETHER:
set_address (&addr, AT_ETHER, FT_ETHER_LEN, fvalue_get(&finfo->value));
set_address (&addr, AT_ETHER, FT_ETHER_LEN, fvalue_get_bytes(&finfo->value));
address_to_str_buf(&addr, display_label_str, label_str_size);
label_len = (int)strlen(display_label_str);
break;
case FT_GUID:
tmp_str = guid_to_str(NULL, (e_guid_t *)fvalue_get(&finfo->value));
tmp_str = guid_to_str(NULL, fvalue_get_guid(&finfo->value));
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
break;
case FT_REL_OID:
bytes = (guint8 *)fvalue_get(&finfo->value);
bytes = fvalue_get_bytes(&finfo->value);
tmp_str = rel_oid_resolved_from_encoded(NULL, bytes, fvalue_length(&finfo->value));
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
break;
case FT_OID:
bytes = (guint8 *)fvalue_get(&finfo->value);
bytes = fvalue_get_bytes(&finfo->value);
tmp_str = oid_resolved_from_encoded(NULL, bytes, fvalue_length(&finfo->value));
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
break;
case FT_SYSTEM_ID:
bytes = (guint8 *)fvalue_get(&finfo->value);
bytes = fvalue_get_bytes(&finfo->value);
tmp_str = print_system_id(NULL, bytes, fvalue_length(&finfo->value));
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
@ -6705,8 +6705,8 @@ proto_item_fill_display_label(field_info *finfo, gchar *display_label_str, const
case FT_UINT_STRING:
case FT_STRINGZPAD:
case FT_STRINGZTRUNC:
bytes = (guint8 *)fvalue_get(&finfo->value);
tmp_str = hfinfo_format_text(NULL, hfinfo, bytes);
str = fvalue_get_string(&finfo->value);
tmp_str = hfinfo_format_text(NULL, hfinfo, str);
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
wmem_free(NULL, tmp_str);
break;
@ -6716,7 +6716,7 @@ proto_item_fill_display_label(field_info *finfo, gchar *display_label_str, const
tmp_str = fvalue_to_string_repr(NULL, &finfo->value, FTREPR_DISPLAY, hfinfo->display);
if (!tmp_str) {
/* Default to show as bytes */
bytes = (guint8 *)fvalue_get(&finfo->value);
bytes = fvalue_get_bytes(&finfo->value);
tmp_str = bytes_to_str(NULL, bytes, fvalue_length(&finfo->value));
}
label_len = protoo_strlcpy(display_label_str, tmp_str, label_str_size);
@ -6733,7 +6733,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
{
guint32 number;
guint64 number64;
guint8 *bytes;
const guint8 *bytes;
int len, prev_len, last, i, offset_r = 0, offset_e = 0, label_len;
GPtrArray *finfos;
@ -6917,7 +6917,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
case FT_REL_OID:
offset_r += proto_item_fill_display_label(finfo, result+offset_r, size-offset_r);
bytes = (guint8 *)fvalue_get(&finfo->value);
bytes = fvalue_get_bytes(&finfo->value);
str = rel_oid_encoded2string(NULL, bytes, fvalue_length(&finfo->value));
offset_e += protoo_strlcpy(expr+offset_e, str, size-offset_e);
wmem_free(NULL, str);
@ -6926,7 +6926,7 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
case FT_OID:
offset_r += proto_item_fill_display_label(finfo, result+offset_r, size-offset_r);
bytes = (guint8 *)fvalue_get(&finfo->value);
bytes = fvalue_get_bytes(&finfo->value);
str = oid_encoded2string(NULL, bytes, fvalue_length(&finfo->value));
offset_e += protoo_strlcpy(expr+offset_e, str, size-offset_e);
wmem_free(NULL, str);
@ -9086,11 +9086,12 @@ void
proto_item_fill_label(field_info *fi, gchar *label_str)
{
header_field_info *hfinfo;
guint8 *bytes;
const char *str;
const guint8 *bytes;
guint32 integer;
guint64 integer64;
ws_in4_addr ipv4;
e_guid_t *guid;
const e_guid_t *guid;
gchar *name;
address addr;
char *addr_str;
@ -9122,7 +9123,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_BYTES:
case FT_UINT_BYTES:
tmp = hfinfo_format_bytes(NULL, hfinfo,
(guint8 *)fvalue_get(&fi->value),
fvalue_get_bytes(&fi->value),
fvalue_length(&fi->value));
label_fill(label_str, 0, hfinfo, tmp);
wmem_free(NULL, tmp);
@ -9223,13 +9224,13 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
}
case FT_ABSOLUTE_TIME:
tmp = abs_time_to_str(NULL, (const nstime_t *)fvalue_get(&fi->value), hfinfo->display, TRUE);
tmp = abs_time_to_str(NULL, fvalue_get_time(&fi->value), hfinfo->display, TRUE);
label_fill(label_str, 0, hfinfo, tmp);
wmem_free(NULL, tmp);
break;
case FT_RELATIVE_TIME:
tmp = rel_time_to_secs_str(NULL, (const nstime_t *)fvalue_get(&fi->value));
tmp = rel_time_to_secs_str(NULL, fvalue_get_time(&fi->value));
snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s seconds", hfinfo->name, tmp);
wmem_free(NULL, tmp);
@ -9247,7 +9248,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_AX25:
addr.type = AT_AX25;
addr.len = AX25_ADDR_LEN;
addr.data = (guint8 *)fvalue_get(&fi->value);
addr.data = fvalue_get_bytes(&fi->value);
addr_str = (char*)address_to_str(NULL, &addr);
snprintf(label_str, ITEM_LABEL_LENGTH,
@ -9258,7 +9259,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_VINES:
addr.type = AT_VINES;
addr.len = VINES_ADDR_LEN;
addr.data = (guint8 *)fvalue_get(&fi->value);
addr.data = fvalue_get_bytes(&fi->value);
addr_str = (char*)address_to_str(NULL, &addr);
snprintf(label_str, ITEM_LABEL_LENGTH,
@ -9267,7 +9268,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
break;
case FT_ETHER:
bytes = (guint8 *)fvalue_get(&fi->value);
bytes = fvalue_get_bytes(&fi->value);
addr.type = AT_ETHER;
addr.len = 6;
@ -9297,7 +9298,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
break;
case FT_IPv6:
bytes = (guint8 *)fvalue_get(&fi->value);
bytes = fvalue_get_bytes(&fi->value);
addr.type = AT_IPv6;
addr.len = 16;
@ -9312,7 +9313,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_FCWWN:
addr.type = AT_FCWWN;
addr.len = FCWWN_ADDR_LEN;
addr.data = (guint8 *)fvalue_get(&fi->value);
addr.data = fvalue_get_bytes(&fi->value);
addr_str = (char*)address_with_resolution_to_str(NULL, &addr);
snprintf(label_str, ITEM_LABEL_LENGTH,
@ -9321,14 +9322,14 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
break;
case FT_GUID:
guid = (e_guid_t *)fvalue_get(&fi->value);
guid = fvalue_get_guid(&fi->value);
tmp = guid_to_str(NULL, guid);
label_fill(label_str, 0, hfinfo, tmp);
wmem_free(NULL, tmp);
break;
case FT_OID:
bytes = (guint8 *)fvalue_get(&fi->value);
bytes = fvalue_get_bytes(&fi->value);
name = oid_resolved_from_encoded(NULL, bytes, fvalue_length(&fi->value));
tmp = oid_encoded2string(NULL, bytes, fvalue_length(&fi->value));
if (name) {
@ -9341,7 +9342,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
break;
case FT_REL_OID:
bytes = (guint8 *)fvalue_get(&fi->value);
bytes = fvalue_get_bytes(&fi->value);
name = rel_oid_resolved_from_encoded(NULL, bytes, fvalue_length(&fi->value));
tmp = rel_oid_encoded2string(NULL, bytes, fvalue_length(&fi->value));
if (name) {
@ -9354,7 +9355,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
break;
case FT_SYSTEM_ID:
bytes = (guint8 *)fvalue_get(&fi->value);
bytes = fvalue_get_bytes(&fi->value);
tmp = print_system_id(NULL, bytes, fvalue_length(&fi->value));
label_fill(label_str, 0, hfinfo, tmp);
wmem_free(NULL, tmp);
@ -9373,8 +9374,8 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
case FT_UINT_STRING:
case FT_STRINGZPAD:
case FT_STRINGZTRUNC:
bytes = (guint8 *)fvalue_get(&fi->value);
tmp = hfinfo_format_text(NULL, hfinfo, bytes);
str = fvalue_get_string(&fi->value);
tmp = hfinfo_format_text(NULL, hfinfo, str);
label_fill(label_str, 0, hfinfo, tmp);
wmem_free(NULL, tmp);
break;

View File

@ -144,7 +144,7 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
case FT_ABSOLUTE_TIME:
case FT_RELATIVE_TIME: {
NSTime nstime = (NSTime)g_malloc(sizeof(nstime_t));
*nstime = *(NSTime)fvalue_get(&(fi->ws_fi->value));
*nstime = *fvalue_get_time(&(fi->ws_fi->value));
pushNSTime(L,nstime);
return 1;
}
@ -177,7 +177,7 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
case FT_OID:
{
ByteArray ba = g_byte_array_new();
g_byte_array_append(ba, (const guint8 *) fvalue_get(&fi->ws_fi->value),
g_byte_array_append(ba, fvalue_get_bytes(&fi->ws_fi->value),
fvalue_length(&fi->ws_fi->value));
pushByteArray(L,ba);
return 1;
@ -185,7 +185,7 @@ WSLUA_METAMETHOD FieldInfo__call(lua_State* L) {
case FT_PROTOCOL:
{
ByteArray ba = g_byte_array_new();
tvbuff_t* tvb = (tvbuff_t *) fvalue_get(&fi->ws_fi->value);
tvbuff_t* tvb = fvalue_get_protocol(&fi->ws_fi->value);
guint8* raw;
if (tvb != NULL) {
raw = (guint8 *)tvb_memdup(NULL, tvb, 0, tvb_captured_length(tvb));

View File

@ -86,7 +86,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
io_stat_item_t *mit;
io_stat_item_t *it;
guint64 relative_time, rt;
nstime_t *new_time;
const nstime_t *new_time;
GPtrArray *gp;
guint i;
int ftype;
@ -187,7 +187,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
it->double_counter += fvalue_get_floating(&((field_info *)gp->pdata[i])->value);
break;
case FT_RELATIVE_TIME:
new_time = (nstime_t *)fvalue_get(&((field_info *)gp->pdata[i])->value);
new_time = fvalue_get_time(&((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs * NANOSECS_PER_SEC) + (guint64)new_time->nsecs;
it->counter += val;
break;
@ -261,7 +261,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
}
break;
case FT_RELATIVE_TIME:
new_time = (nstime_t *)fvalue_get(&((field_info *)gp->pdata[i])->value);
new_time = fvalue_get_time(&((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs * NANOSECS_PER_SEC) + (guint64)new_time->nsecs;
if ((it->frames == 1 && i == 0) || (val < it->counter)) {
it->counter = val;
@ -331,7 +331,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
it->double_counter = double_val;
break;
case FT_RELATIVE_TIME:
new_time = (nstime_t *)fvalue_get(&((field_info *)gp->pdata[i])->value);
new_time = fvalue_get_time(&((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs * NANOSECS_PER_SEC) + (guint64)new_time->nsecs;
if (val > it->counter)
it->counter = val;
@ -391,7 +391,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
it->double_counter += fvalue_get_floating(&((field_info *)gp->pdata[i])->value);
break;
case FT_RELATIVE_TIME:
new_time = (nstime_t *)fvalue_get(&((field_info *)gp->pdata[i])->value);
new_time = fvalue_get_time(&((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs * NANOSECS_PER_SEC) + (guint64)new_time->nsecs;
it->counter += val;
break;
@ -420,7 +420,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
int tival;
io_stat_item_t *pit;
new_time = (nstime_t *)fvalue_get(&((field_info *)gp->pdata[i])->value);
new_time = fvalue_get_time(&((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs*G_GUINT64_CONSTANT(1000000)) + (guint64)(new_time->nsecs/1000);
tival = (int)(val % parent->interval);
it->counter += tival;

View File

@ -168,7 +168,7 @@ update_io_graph_item(io_graph_item_t *items, int idx, packet_info *pinfo, epan_d
guint64 new_uint64;
float new_float;
double new_double;
nstime_t *new_time;
const nstime_t *new_time;
switch (proto_registrar_get_ftype(hf_index)) {
case FT_UINT8:
@ -299,7 +299,7 @@ update_io_graph_item(io_graph_item_t *items, int idx, packet_info *pinfo, epan_d
item->fields++;
break;
case FT_RELATIVE_TIME:
new_time = (nstime_t *)fvalue_get(&((field_info *)gp->pdata[i])->value);
new_time = fvalue_get_time(&((field_info *)gp->pdata[i])->value);
switch (item_unit) {
case IOG_ITEM_UNIT_CALC_LOAD: