From 0aa4359be6f083f5dd0b496a3eaa324db4d989e4 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 16 Jan 2016 17:01:07 +0100 Subject: [PATCH] [sll] add LINUX_SLL_P_NETLINK remove some unnecessary if(tree) checks while at it Change-Id: I2ed7153a25a96f9fa08476176980655117aae26e Reviewed-on: https://code.wireshark.org/review/13334 Reviewed-by: Martin Kaiser --- epan/dissectors/packet-sll.c | 20 +++++++++----------- epan/dissectors/packet-sll.h | 1 + 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/epan/dissectors/packet-sll.c b/epan/dissectors/packet-sll.c index f2c1cab08d..a36ead52d6 100644 --- a/epan/dissectors/packet-sll.c +++ b/epan/dissectors/packet-sll.c @@ -72,6 +72,7 @@ static const value_string ltype_vals[] = { { LINUX_SLL_P_IRDA_LAP, "IrDA LAP" }, { LINUX_SLL_P_ISI, "ISI" }, { LINUX_SLL_P_IEEE802154, "IEEE 802.15.4" }, + { LINUX_SLL_P_NETLINK, "Netlink" }, { 0, NULL } }; @@ -166,7 +167,7 @@ dissect_sll(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) guint16 hatype, halen; proto_item *ti; tvbuff_t *next_tvb; - proto_tree *fh_tree = NULL; + proto_tree *fh_tree; ethertype_data_t ethertype_data; col_set_str(pinfo->cinfo, COL_PROTOCOL, "SLL"); @@ -194,12 +195,10 @@ dissect_sll(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) col_add_str(pinfo->cinfo, COL_INFO, val_to_str(pkttype, packet_type_vals, "Unknown (%u)")); - if (tree) { - ti = proto_tree_add_protocol_format(tree, hfi_sll->id, tvb, 0, - SLL_HEADER_SIZE, "Linux cooked capture"); - fh_tree = proto_item_add_subtree(ti, ett_sll); - proto_tree_add_item(fh_tree, &hfi_sll_pkttype, tvb, 0, 2, ENC_BIG_ENDIAN); - } + ti = proto_tree_add_protocol_format(tree, hfi_sll->id, tvb, 0, + SLL_HEADER_SIZE, "Linux cooked capture"); + fh_tree = proto_item_add_subtree(ti, ett_sll); + proto_tree_add_item(fh_tree, &hfi_sll_pkttype, tvb, 0, 2, ENC_BIG_ENDIAN); /* * XXX - check the link-layer address type value? @@ -207,10 +206,9 @@ dissect_sll(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) */ hatype = tvb_get_ntohs(tvb, 2); halen = tvb_get_ntohs(tvb, 4); - if (tree) { - proto_tree_add_uint(fh_tree, &hfi_sll_hatype, tvb, 2, 2, hatype); - proto_tree_add_uint(fh_tree, &hfi_sll_halen, tvb, 4, 2, halen); - } + proto_tree_add_uint(fh_tree, &hfi_sll_hatype, tvb, 2, 2, hatype); + proto_tree_add_uint(fh_tree, &hfi_sll_halen, tvb, 4, 2, halen); + switch (halen) { case 4: set_address_tvb(&pinfo->dl_src, AT_IPv4, 4, tvb, 6); diff --git a/epan/dissectors/packet-sll.h b/epan/dissectors/packet-sll.h index 6489b6e7b6..4b95d9c20c 100644 --- a/epan/dissectors/packet-sll.h +++ b/epan/dissectors/packet-sll.h @@ -35,5 +35,6 @@ #define LINUX_SLL_P_IRDA_LAP 0x0017 /* IrDA Link Access Protocol */ #define LINUX_SLL_P_ISI 0x00F5 /* Intelligent Service Interface */ #define LINUX_SLL_P_IEEE802154 0x00f6 /* 802.15.4 on monitor inteface */ +#define LINUX_SLL_P_NETLINK 0x0338 /* Netlink */ #endif