netlink: use indicated encoding for attributes

In netlink the general format of attributes includes a network byte order
indication flag in the header. When set this has to be passed to the
attribute value dissector function as the byte ordering fo the attribute
value. Otherwise the heuristically determined capture host byte order has
to be passed to the attribute value dissector function.
With the removal of all copies of 'encoding' this can now be achieved
through setting of the encoding in nl_data.

Change-Id: Iec0c1b2c2958734a469ff6f75db4626846cb30c9
Reviewed-on: https://code.wireshark.org/review/35831
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Jaap Keuter 2020-01-15 22:41:11 +01:00 committed by Anders Broman
parent 3e072f1bc9
commit 4ee88f3e34
1 changed files with 14 additions and 1 deletions

View File

@ -308,9 +308,22 @@ dissect_netlink_attributes_common(tvbuff_t *tvb, header_field_info *hfi_type, in
}
}
/* The callback needs to be passed the netlink_attr_type_net_byteorder as dissected,
* to properly dissect the attribute value, which byte order may differ from the
* capture host native byte order, as heuristically established in 'encoding'.
* We pass in the encoding through nl_data, so we temporarily modify it to match
* the NLA_F_NET_BYTEORDER flag.
*/
if (rta_type & NLA_F_NET_BYTEORDER)
nl_data->encoding = ENC_BIG_ENDIAN;
if (!cb(tvb, data, nl_data, attr_tree, rta_type, offset, rta_len - 4)) {
proto_tree_add_item(attr_tree, &hfi_netlink_attr_data, tvb, offset, rta_len - 4, encoding);
proto_tree_add_item(attr_tree, &hfi_netlink_attr_data, tvb, offset, rta_len - 4, ENC_NA);
}
/* Restore the originaly established encoding. */
if (rta_type & NLA_F_NET_BYTEORDER)
nl_data->encoding = encoding;
} else {
/*
* Nested attributes, constructing an array (list of