forked from osmocom/wireshark
dfilter: Add fvalue duplicate method
This commit is contained in:
parent
19c0e83d8b
commit
9ab2837637
|
@ -22,6 +22,14 @@ bytes_fvalue_new(fvalue_t *fv)
|
|||
fv->value.bytes = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
bytes_fvalue_copy(fvalue_t *dst, const fvalue_t *src)
|
||||
{
|
||||
dst->value.bytes = g_byte_array_new();
|
||||
dst->value.bytes->data = g_memdup2(src->value.bytes->data, src->value.bytes->len);
|
||||
dst->value.bytes->len = src->value.bytes->len;
|
||||
}
|
||||
|
||||
static void
|
||||
bytes_fvalue_free(fvalue_t *fv)
|
||||
{
|
||||
|
@ -588,6 +596,7 @@ ftype_register_bytes(void)
|
|||
"Sequence of bytes", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
bytes_fvalue_new, /* new_value */
|
||||
bytes_fvalue_copy, /* copy_value */
|
||||
bytes_fvalue_free, /* free_value */
|
||||
bytes_from_literal, /* val_from_literal */
|
||||
bytes_from_string, /* val_from_string */
|
||||
|
@ -614,6 +623,7 @@ ftype_register_bytes(void)
|
|||
"Sequence of bytes", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
bytes_fvalue_new, /* new_value */
|
||||
bytes_fvalue_copy, /* copy_value */
|
||||
bytes_fvalue_free, /* free_value */
|
||||
bytes_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -640,6 +650,7 @@ ftype_register_bytes(void)
|
|||
"AX.25 address", /* pretty_name */
|
||||
FT_AX25_ADDR_LEN, /* wire_size */
|
||||
bytes_fvalue_new, /* new_value */
|
||||
bytes_fvalue_copy, /* copy_value */
|
||||
bytes_fvalue_free, /* free_value */
|
||||
ax25_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -666,6 +677,7 @@ ftype_register_bytes(void)
|
|||
"VINES address", /* pretty_name */
|
||||
FT_VINES_ADDR_LEN, /* wire_size */
|
||||
bytes_fvalue_new, /* new_value */
|
||||
bytes_fvalue_copy, /* copy_value */
|
||||
bytes_fvalue_free, /* free_value */
|
||||
vines_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -692,6 +704,7 @@ ftype_register_bytes(void)
|
|||
"Ethernet or other MAC address",/* pretty_name */
|
||||
FT_ETHER_LEN, /* wire_size */
|
||||
bytes_fvalue_new, /* new_value */
|
||||
bytes_fvalue_copy, /* copy_value */
|
||||
bytes_fvalue_free, /* free_value */
|
||||
ether_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -718,6 +731,7 @@ ftype_register_bytes(void)
|
|||
"ASN.1 object identifier", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
bytes_fvalue_new, /* new_value */
|
||||
bytes_fvalue_copy, /* copy_value */
|
||||
bytes_fvalue_free, /* free_value */
|
||||
oid_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -744,6 +758,7 @@ ftype_register_bytes(void)
|
|||
"ASN.1 relative object identifier", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
bytes_fvalue_new, /* new_value */
|
||||
bytes_fvalue_copy, /* copy_value */
|
||||
bytes_fvalue_free, /* free_value */
|
||||
rel_oid_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -770,6 +785,7 @@ ftype_register_bytes(void)
|
|||
"OSI System-ID", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
bytes_fvalue_new, /* new_value */
|
||||
bytes_fvalue_copy, /* copy_value */
|
||||
bytes_fvalue_free, /* free_value */
|
||||
system_id_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -796,6 +812,7 @@ ftype_register_bytes(void)
|
|||
"Fibre Channel WWN", /* pretty_name */
|
||||
FT_FCWWN_LEN, /* wire_size */
|
||||
bytes_fvalue_new, /* new_value */
|
||||
bytes_fvalue_copy, /* copy_value */
|
||||
bytes_fvalue_free, /* free_value */
|
||||
fcwwn_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
|
|
@ -112,6 +112,7 @@ ftype_register_double(void)
|
|||
"Floating point (single-precision)", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
double_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
val_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -138,6 +139,7 @@ ftype_register_double(void)
|
|||
"Floating point (double-precision)", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
double_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
val_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
|
|
@ -103,6 +103,7 @@ ftype_register_guid(void)
|
|||
"Globally Unique Identifier", /* pretty_name */
|
||||
GUID_LEN, /* wire_size */
|
||||
NULL, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
guid_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
|
|
@ -904,6 +904,7 @@ Example: 114 is 0x0072
|
|||
2, /* wire_size */
|
||||
|
||||
sfloat_ieee_11073_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
sfloat_ieee_11073_val_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -957,6 +958,7 @@ Example: 36.4 is 0xFF00016C
|
|||
4, /* wire_size */
|
||||
|
||||
float_ieee_11073_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
float_ieee_11073_val_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
|
|
@ -868,6 +868,7 @@ ftype_register_integers(void)
|
|||
"Character, 1 byte", /* pretty name */
|
||||
1, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
uint8_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -893,6 +894,7 @@ ftype_register_integers(void)
|
|||
"Unsigned integer, 1 byte", /* pretty name */
|
||||
1, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
uint8_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -918,6 +920,7 @@ ftype_register_integers(void)
|
|||
"Unsigned integer, 2 bytes", /* pretty_name */
|
||||
2, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
uint16_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -943,6 +946,7 @@ ftype_register_integers(void)
|
|||
"Unsigned integer, 3 bytes", /* pretty_name */
|
||||
3, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
uint24_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -968,6 +972,7 @@ ftype_register_integers(void)
|
|||
"Unsigned integer, 4 bytes", /* pretty_name */
|
||||
4, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
uint32_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -993,6 +998,7 @@ ftype_register_integers(void)
|
|||
"Unsigned integer, 5 bytes", /* pretty_name */
|
||||
5, /* wire_size */
|
||||
int64_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
uint40_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1018,6 +1024,7 @@ ftype_register_integers(void)
|
|||
"Unsigned integer, 6 bytes", /* pretty_name */
|
||||
6, /* wire_size */
|
||||
int64_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
uint48_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1043,6 +1050,7 @@ ftype_register_integers(void)
|
|||
"Unsigned integer, 7 bytes", /* pretty_name */
|
||||
7, /* wire_size */
|
||||
int64_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
uint56_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1068,6 +1076,7 @@ ftype_register_integers(void)
|
|||
"Unsigned integer, 8 bytes", /* pretty_name */
|
||||
8, /* wire_size */
|
||||
int64_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
uint64_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1093,6 +1102,7 @@ ftype_register_integers(void)
|
|||
"Signed integer, 1 byte", /* pretty_name */
|
||||
1, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
sint8_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1118,6 +1128,7 @@ ftype_register_integers(void)
|
|||
"Signed integer, 2 bytes", /* pretty_name */
|
||||
2, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
sint16_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1143,6 +1154,7 @@ ftype_register_integers(void)
|
|||
"Signed integer, 3 bytes", /* pretty_name */
|
||||
3, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
sint24_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1168,6 +1180,7 @@ ftype_register_integers(void)
|
|||
"Signed integer, 4 bytes", /* pretty_name */
|
||||
4, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
sint32_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1193,6 +1206,7 @@ ftype_register_integers(void)
|
|||
"Signed integer, 5 bytes", /* pretty_name */
|
||||
5, /* wire_size */
|
||||
int64_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
sint40_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1218,6 +1232,7 @@ ftype_register_integers(void)
|
|||
"Signed integer, 6 bytes", /* pretty_name */
|
||||
6, /* wire_size */
|
||||
int64_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
sint48_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1243,6 +1258,7 @@ ftype_register_integers(void)
|
|||
"Signed integer, 7 bytes", /* pretty_name */
|
||||
7, /* wire_size */
|
||||
int64_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
sint56_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1268,6 +1284,7 @@ ftype_register_integers(void)
|
|||
"Signed integer, 8 bytes", /* pretty_name */
|
||||
8, /* wire_size */
|
||||
int64_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
sint64_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1293,6 +1310,7 @@ ftype_register_integers(void)
|
|||
"Boolean", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
boolean_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1319,6 +1337,7 @@ ftype_register_integers(void)
|
|||
"IPX network number", /* pretty_name */
|
||||
4, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
ipxnet_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1345,6 +1364,7 @@ ftype_register_integers(void)
|
|||
"Frame number", /* pretty_name */
|
||||
4, /* wire_size */
|
||||
int_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
uint32_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
@ -1371,6 +1391,7 @@ ftype_register_integers(void)
|
|||
"EUI64 address", /* pretty_name */
|
||||
FT_EUI64_LEN, /* wire_size */
|
||||
int64_fvalue_new, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
eui64_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
|
|
@ -155,6 +155,7 @@ ftype_register_ipv4(void)
|
|||
"IPv4 address", /* pretty_name */
|
||||
4, /* wire_size */
|
||||
NULL, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
val_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
|
|
@ -178,6 +178,7 @@ ftype_register_ipv6(void)
|
|||
"IPv6 address", /* pretty_name */
|
||||
FT_IPv6_LEN, /* wire_size */
|
||||
NULL, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
ipv6_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
|
|
@ -21,6 +21,7 @@ ftype_register_none(void)
|
|||
"Label", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
NULL, /* new_value */
|
||||
NULL, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
NULL, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
|
|
@ -25,6 +25,14 @@ value_new(fvalue_t *fv)
|
|||
fv->value.protocol.tvb_is_private = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
value_copy(fvalue_t *dst, const fvalue_t *src)
|
||||
{
|
||||
dst->value.protocol.tvb = tvb_clone(src->value.protocol.tvb);
|
||||
dst->value.protocol.proto_string = g_strdup(src->value.protocol.proto_string);
|
||||
dst->value.protocol.tvb_is_private = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
value_free(fvalue_t *fv)
|
||||
{
|
||||
|
@ -316,6 +324,7 @@ ftype_register_tvbuff(void)
|
|||
"Protocol", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
value_new, /* new_value */
|
||||
value_copy, /* copy_value */
|
||||
value_free, /* free_value */
|
||||
val_from_literal, /* val_from_literal */
|
||||
val_from_string, /* val_from_string */
|
||||
|
|
|
@ -21,6 +21,12 @@ string_fvalue_new(fvalue_t *fv)
|
|||
fv->value.string = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
string_fvalue_copy(fvalue_t *dst, const fvalue_t *src)
|
||||
{
|
||||
dst->value.string = g_strdup(src->value.string);
|
||||
}
|
||||
|
||||
static void
|
||||
string_fvalue_free(fvalue_t *fv)
|
||||
{
|
||||
|
@ -169,6 +175,7 @@ ftype_register_string(void)
|
|||
"Character string", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
string_fvalue_new, /* new_value */
|
||||
string_fvalue_copy, /* copy_value */
|
||||
string_fvalue_free, /* free_value */
|
||||
val_from_literal, /* val_from_literal */
|
||||
val_from_string, /* val_from_string */
|
||||
|
@ -194,6 +201,7 @@ ftype_register_string(void)
|
|||
"Character string", /* pretty name */
|
||||
0, /* wire_size */
|
||||
string_fvalue_new, /* new_value */
|
||||
string_fvalue_copy, /* copy_value */
|
||||
string_fvalue_free, /* free_value */
|
||||
val_from_literal, /* val_from_literal */
|
||||
val_from_string, /* val_from_string */
|
||||
|
@ -219,6 +227,7 @@ ftype_register_string(void)
|
|||
"Character string", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
string_fvalue_new, /* new_value */
|
||||
string_fvalue_copy, /* copy_value */
|
||||
string_fvalue_free, /* free_value */
|
||||
val_from_literal, /* val_from_literal */
|
||||
val_from_string, /* val_from_string */
|
||||
|
@ -244,6 +253,7 @@ ftype_register_string(void)
|
|||
"Character string", /* pretty name */
|
||||
0, /* wire_size */
|
||||
string_fvalue_new, /* new_value */
|
||||
string_fvalue_copy, /* copy_value */
|
||||
string_fvalue_free, /* free_value */
|
||||
val_from_literal, /* val_from_literal */
|
||||
val_from_string, /* val_from_string */
|
||||
|
@ -269,6 +279,7 @@ ftype_register_string(void)
|
|||
"Character string", /* pretty name */
|
||||
0, /* wire_size */
|
||||
string_fvalue_new, /* new_value */
|
||||
string_fvalue_copy, /* copy_value */
|
||||
string_fvalue_free, /* free_value */
|
||||
val_from_literal, /* val_from_literal */
|
||||
val_from_string, /* val_from_string */
|
||||
|
|
|
@ -320,6 +320,12 @@ time_fvalue_new(fvalue_t *fv)
|
|||
fv->value.time.nsecs = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
time_fvalue_copy(fvalue_t *dst, const fvalue_t *src)
|
||||
{
|
||||
nstime_copy(&dst->value.time, &src->value.time);
|
||||
}
|
||||
|
||||
static void
|
||||
time_fvalue_set(fvalue_t *fv, const nstime_t *value)
|
||||
{
|
||||
|
@ -429,6 +435,7 @@ ftype_register_time(void)
|
|||
"Date and time", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
time_fvalue_new, /* new_value */
|
||||
time_fvalue_copy, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
absolute_val_from_literal, /* val_from_literal */
|
||||
absolute_val_from_string, /* val_from_string */
|
||||
|
@ -454,6 +461,7 @@ ftype_register_time(void)
|
|||
"Time offset", /* pretty_name */
|
||||
0, /* wire_size */
|
||||
time_fvalue_new, /* new_value */
|
||||
time_fvalue_copy, /* copy_value */
|
||||
NULL, /* free_value */
|
||||
relative_val_from_literal, /* val_from_literal */
|
||||
NULL, /* val_from_string */
|
||||
|
|
|
@ -28,6 +28,7 @@ enum ft_result {
|
|||
};
|
||||
|
||||
typedef void (*FvalueNewFunc)(fvalue_t*);
|
||||
typedef void (*FvalueCopyFunc)(fvalue_t*, const fvalue_t*);
|
||||
typedef void (*FvalueFreeFunc)(fvalue_t*);
|
||||
|
||||
typedef gboolean (*FvalueFromLiteral)(fvalue_t*, const char*, gboolean, gchar **);
|
||||
|
@ -70,6 +71,7 @@ struct _ftype_t {
|
|||
const char *pretty_name;
|
||||
int wire_size;
|
||||
FvalueNewFunc new_value;
|
||||
FvalueCopyFunc copy_value;
|
||||
FvalueFreeFunc free_value;
|
||||
FvalueFromLiteral val_from_literal;
|
||||
FvalueFromString val_from_string;
|
||||
|
|
|
@ -268,6 +268,27 @@ fvalue_new(ftenum_t ftype)
|
|||
return fv;
|
||||
}
|
||||
|
||||
fvalue_t*
|
||||
fvalue_dup(const fvalue_t *fv_orig)
|
||||
{
|
||||
fvalue_t *fv_new;
|
||||
FvalueCopyFunc copy_value;
|
||||
|
||||
fv_new = g_slice_new(fvalue_t);
|
||||
fv_new->ftype = fv_orig->ftype;
|
||||
copy_value = fv_new->ftype->copy_value;
|
||||
if (copy_value != NULL) {
|
||||
/* deep copy */
|
||||
copy_value(fv_new, fv_orig);
|
||||
}
|
||||
else {
|
||||
/* shallow copy */
|
||||
memcpy(&fv_new->value, &fv_orig->value, sizeof(fv_orig->value));
|
||||
}
|
||||
|
||||
return fv_new;
|
||||
}
|
||||
|
||||
void
|
||||
fvalue_init(fvalue_t *fv, ftenum_t ftype)
|
||||
{
|
||||
|
|
|
@ -242,6 +242,9 @@ typedef struct _fvalue_t {
|
|||
fvalue_t*
|
||||
fvalue_new(ftenum_t ftype);
|
||||
|
||||
fvalue_t*
|
||||
fvalue_dup(const fvalue_t *fv);
|
||||
|
||||
void
|
||||
fvalue_init(fvalue_t *fv, ftenum_t ftype);
|
||||
|
||||
|
|
Loading…
Reference in New Issue