Make many items filterable for Vines dissectors.

Add support for FT_VINES type.

svn path=/trunk/; revision=50962
This commit is contained in:
Michael Mann 2013-07-28 00:07:49 +00:00
parent b9870c0969
commit a87f47c02c
6 changed files with 453 additions and 492 deletions

View File

@ -82,8 +82,9 @@ compatible_ftypes(ftenum_t a, ftenum_t b)
case FT_GUID:
case FT_OID:
case FT_AX25:
case FT_VINES:
return (b == FT_ETHER || b == FT_BYTES || b == FT_UINT_BYTES || b == FT_GUID || b == FT_OID || b == FT_AX25);
return (b == FT_ETHER || b == FT_BYTES || b == FT_UINT_BYTES || b == FT_GUID || b == FT_OID || b == FT_AX25 || b == FT_VINES);
case FT_BOOLEAN:
case FT_FRAMENUM:
@ -177,6 +178,7 @@ mk_fvalue_from_val_string(header_field_info *hfinfo, char *s)
case FT_IPv6:
case FT_IPXNET:
case FT_AX25:
case FT_VINES:
case FT_ETHER:
case FT_BYTES:
case FT_UINT_BYTES:
@ -287,6 +289,7 @@ is_bytes_type(enum ftenum type)
{
switch(type) {
case FT_AX25:
case FT_VINES:
case FT_ETHER:
case FT_BYTES:
case FT_UINT_BYTES:

File diff suppressed because it is too large Load Diff

View File

@ -148,6 +148,13 @@ ax25_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
common_fvalue_set(fv, (guint8 *)value, FT_AX25_ADDR_LEN);
}
static void
vines_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
{
g_assert(!already_copied);
common_fvalue_set(fv, (guint8 *)value, FT_VINES_ADDR_LEN);
}
static void
ether_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
{
@ -272,6 +279,35 @@ ax25_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value, LogFunc
return FALSE;
}
static gboolean
vines_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value, LogFunc logfunc)
{
/*
* Don't log a message if this fails; we'll try looking it
* up as another way if it does, and if that fails,
* we'll log a message.
*/
if (bytes_from_unparsed(fv, s, TRUE, NULL)) {
if (fv->value.bytes->len > FT_VINES_ADDR_LEN) {
logfunc("\"%s\" contains too many bytes to be a valid Vines address.",
s);
return FALSE;
}
else if (fv->value.bytes->len < FT_VINES_ADDR_LEN && !allow_partial_value) {
logfunc("\"%s\" contains too few bytes to be a valid Vines address.",
s);
return FALSE;
}
return TRUE;
}
/* XXX - need better validation of Vines address */
logfunc("\"%s\" is not a valid Vines address.", s);
return FALSE;
}
static gboolean
ether_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value, LogFunc logfunc)
{
@ -661,6 +697,44 @@ ftype_register_bytes(void)
slice,
};
static ftype_t vines_type = {
FT_VINES, /* ftype */
"FT_VINES", /* name */
"VINES address", /* pretty_name */
FT_VINES_ADDR_LEN, /* wire_size */
bytes_fvalue_new, /* new_value */
bytes_fvalue_free, /* free_value */
vines_from_unparsed, /* val_from_unparsed */
NULL, /* val_from_string */
bytes_to_repr, /* val_to_string_repr */
bytes_repr_len, /* len_string_repr */
vines_fvalue_set, /* set_value */
NULL, /* set_value_uinteger */
NULL, /* set_value_integer */
NULL, /* set_value_integer64 */
NULL, /* set_value_floating */
value_get, /* get_value */
NULL, /* set_value_uinteger */
NULL, /* get_value_integer */
NULL, /* get_value_integer64 */
NULL, /* get_value_floating */
cmp_eq,
cmp_ne,
cmp_gt,
cmp_ge,
cmp_lt,
cmp_le,
cmp_bitwise_and,
cmp_contains,
CMP_MATCHES,
len,
slice,
};
static ftype_t ether_type = {
FT_ETHER, /* ftype */
"FT_ETHER", /* name */
@ -740,6 +814,7 @@ ftype_register_bytes(void)
ftype_register(FT_BYTES, &bytes_type);
ftype_register(FT_UINT_BYTES, &uint_bytes_type);
ftype_register(FT_AX25, &ax25_type);
ftype_register(FT_VINES, &vines_type);
ftype_register(FT_ETHER, &ether_type);
ftype_register(FT_OID, &oid_type);
}

View File

@ -69,6 +69,7 @@ enum ftenum {
FT_OID, /* OBJECT IDENTIFIER */
FT_EUI64,
FT_AX25,
FT_VINES,
FT_NUM_TYPES /* last item number plus one */
};
@ -85,6 +86,7 @@ enum ftenum {
#define FT_IPXNET_LEN 4
#define FT_EUI64_LEN 8
#define FT_AX25_ADDR_LEN 7
#define FT_VINES_ADDR_LEN 6
typedef enum ftenum ftenum_t;
typedef struct _ftype_t ftype_t;

View File

@ -190,6 +190,10 @@ proto_tree_set_ax25(field_info *fi, const guint8* value);
static void
proto_tree_set_ax25_tvb(field_info *fi, tvbuff_t *tvb, gint start);
static void
proto_tree_set_vines(field_info *fi, const guint8* value);
static void
proto_tree_set_vines_tvb(field_info *fi, tvbuff_t *tvb, gint start);
static void
proto_tree_set_ether(field_info *fi, const guint8* value);
static void
proto_tree_set_ether_tvb(field_info *fi, tvbuff_t *tvb, gint start);
@ -1354,6 +1358,14 @@ proto_tree_new_item(field_info *new_fi, proto_tree *tree,
proto_tree_set_ax25_tvb(new_fi, tvb, start);
break;
case FT_VINES:
if (length != VINES_ADDR_LEN) {
length_error = length < VINES_ADDR_LEN ? TRUE : FALSE;
report_type_length_mismatch(tree, "a Vines address", length, length_error);
}
proto_tree_set_vines_tvb(new_fi, tvb, start);
break;
case FT_ETHER:
if (length != FT_ETHER_LEN) {
length_error = length < FT_ETHER_LEN ? TRUE : FALSE;
@ -2647,6 +2659,18 @@ proto_tree_set_ax25_tvb(field_info *fi, tvbuff_t *tvb, gint start)
proto_tree_set_ax25(fi, tvb_get_ptr(tvb, start, 7));
}
/* Set the FT_VINES value */
static void
proto_tree_set_vines(field_info *fi, const guint8* value)
{
fvalue_set(&fi->value, (gpointer) value, FALSE);
}
static void
proto_tree_set_vines_tvb(field_info *fi, tvbuff_t *tvb, gint start)
{
proto_tree_set_vines(fi, tvb_get_ptr(tvb, start, FT_VINES_ADDR_LEN));
}
/* Add a FT_ETHER to a proto_tree */
proto_item *
@ -5179,6 +5203,7 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
e_guid_t *guid;
guint32 n_addr; /* network-order IPv4 address */
const gchar *name;
addres addr;
if (!fi) {
if (label_str)
@ -5281,6 +5306,16 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
ax25_to_str(bytes));
break;
case FT_VINES:
addr.type = AT_VINES;
addr.len = VINES_ADDR_LEN;
addr.data = (guint8 *)fvalue_get(&fi->value);
g_snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name,
address_to_str( &addr ));
break;
case FT_ETHER:
bytes = (guint8 *)fvalue_get(&fi->value);
label_fill_descr(label_str, 0, hfinfo,

View File

@ -84,7 +84,7 @@ my %FIELD_TYPE = ('FT_NONE' => "FT_NONE", 'FT_PROTOCOL' => "FT_PROTOCOL", 'FT_BO
'FT_ABSOLUTE_TIME' => "FT_ABSOLUTE_TIME", 'FT_RELATIVE_TIME' => "FT_RELATIVE_TIME",
'FT_STRING' => "FT_STRING", 'FT_STRINGZ' => "FT_STRINGZ", 'FT_UINT_STRING' => "FT_UINT_STRING",
'FT_ETHER' => "FT_ETHER", 'FT_BYTES' => "FT_BYTES", 'FT_UINT_BYTES' => "FT_UINT_BYTES",
'FT_IPv4' => "FT_IPv4", 'FT_IPv6' => "FT_IPv6", 'FT_IPXNET' => "FT_IPXNET", 'FT_AX25' => "FT_AX25",
'FT_IPv4' => "FT_IPv4", 'FT_IPv6' => "FT_IPv6", 'FT_IPXNET' => "FT_IPXNET", 'FT_AX25' => "FT_AX25", 'FT_VINES' => "FT_VINES",
'FT_FRAMENUM' => "FT_FRAMENUM", 'FT_PCRE' => "FT_PCRE", 'FT_GUID' => "FT_GUID", 'FT_OID' => "FT_OID", 'FT_EUI64' => "FT_EUI64");
my %EXPERT_SEVERITY = ('PI_COMMENT' => "PI_COMMENT",
@ -370,7 +370,8 @@ sub generate_hfs {
if (($proto_tree_item[6] eq "1") ||
($args[5] =~ /tvb_get_guint8/) ||
($args[5] =~ /tvb_bytes_to_str/) ||
($args[5] =~ /tvb_ether_to_str/)) {
($args[5] =~ /tvb_ether_to_str/) ||
($args[5] =~ /tvb_vines_addr_to_str/)) {
$proto_tree_item[7] = "ENC_NA";
} elsif ($args[5] =~ /tvb_get_ntoh/) {
$proto_tree_item[7] = "ENC_BIG_ENDIAN";
@ -461,7 +462,9 @@ sub generate_hfs {
$proto_tree_item[9] = "FT_BYTES";
} elsif ($args[5] =~ /tvb_ether_to_str/) {
$proto_tree_item[9] = "FT_ETHER";
}
} elsif ($args[5] =~ /tvb_vines_addr_to_str/) {
$proto_tree_item[9] = "FT_VINES";
}
}
#display base