summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-ospf.c
diff options
context:
space:
mode:
authorJoerg Mayer <jmayer@loplof.de>2015-08-22 08:11:45 +0400
committerJörg Mayer <jmayer@loplof.de>2015-08-22 04:18:37 +0000
commitc4fe7129d802752aa4cc89a66d2d5d5f2698e020 (patch)
tree2c11176b6133833f89c4f0bcb764264bdbbe97ba /epan/dissectors/packet-ospf.c
parentee80be6dac02979bc10b7c1ccc8735525a983f63 (diff)
downloadwireshark-c4fe7129d802752aa4cc89a66d2d5d5f2698e020.tar.gz
Small cleanups and improvements
Show the LSA type and length in the summary line Improve a message to make it clear when we are talking about a LLS TLV Add an expert item for LLS bit set but data block missing PI_MALFORMED is an error not a warning. Change-Id: I516c2a2f0c27fcf101671527d4e4f018e17d3025 Reviewed-on: https://code.wireshark.org/review/10189 Reviewed-by: Jörg Mayer <jmayer@loplof.de>
Diffstat (limited to 'epan/dissectors/packet-ospf.c')
-rw-r--r--epan/dissectors/packet-ospf.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/epan/dissectors/packet-ospf.c b/epan/dissectors/packet-ospf.c
index 84ae8ba204..6dc9a499bb 100644
--- a/epan/dissectors/packet-ospf.c
+++ b/epan/dissectors/packet-ospf.c
@@ -972,7 +972,7 @@ static void dissect_ospf_ls_req(tvbuff_t*, packet_info*, int, proto_tree*, guint
static void dissect_ospf_ls_upd(tvbuff_t*, packet_info*, int, proto_tree*, guint8, guint16, guint8);
static void dissect_ospf_ls_ack(tvbuff_t*, packet_info*, int, proto_tree*, guint8, guint16, guint8);
static int dissect_ospf_authentication_trailer(tvbuff_t*, int, proto_tree*);
-static void dissect_ospf_lls_data_block(tvbuff_t*, int, proto_tree*, guint8);
+static void dissect_ospf_lls_data_block(tvbuff_t*, packet_info*, int, proto_tree*, guint8);
/* dissect_ospf_v[23]lsa returns the offset of the next LSA
* if disassemble_body is set to FALSE (e.g. in LSA ACK
@@ -1267,7 +1267,7 @@ dissect_ospf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* take care of the LLS data block */
if (ospf_has_lls_block(tvb, ospf_header_length, packet_type, version)) {
- dissect_ospf_lls_data_block(tvb, ospflen + crypto_len, ospf_tree,
+ dissect_ospf_lls_data_block(tvb, pinfo, ospflen + crypto_len, ospf_tree,
version);
}
@@ -1289,7 +1289,7 @@ dissect_ospfv2_lls_tlv(tvbuff_t *tvb, int offset, proto_tree *tree)
length = tvb_get_ntohs(tvb, offset + 2);
ospf_lls_tlv_tree = proto_tree_add_subtree(tree, tvb, offset, length + 4, ett_ospf_lls_tlv,
- NULL, val_to_str_const(type, lls_tlv_type_vals, "Unknown TLV"));
+ NULL, val_to_str_const(type, lls_tlv_type_vals, "Unknown LLS TLV"));
proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_tlv_type, tvb, offset, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(ospf_lls_tlv_tree, hf_ospf_tlv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
@@ -1351,7 +1351,7 @@ dissect_ospfv3_lls_tlv(tvbuff_t *tvb, int offset, proto_tree *tree)
break;
default:
ospf_lls_tlv_tree = proto_tree_add_subtree_format(tree, tvb, offset, length + 4, ett_ospf_lls_tlv, NULL,
- "%s", val_to_str_const(type, lls_v3_tlv_type_vals, "Unknown TLV"));
+ "%s", val_to_str_const(type, lls_v3_tlv_type_vals, "Unknown LLS TLV"));
}
if (ti != NULL)
@@ -1429,12 +1429,20 @@ dissect_ospfv3_lls_tlv(tvbuff_t *tvb, int offset, proto_tree *tree)
static void
-dissect_ospf_lls_data_block(tvbuff_t *tvb, int offset, proto_tree *tree,
+dissect_ospf_lls_data_block(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
guint8 version)
{
proto_tree *ospf_lls_data_block_tree;
int ospf_lls_len;
int orig_offset = offset;
+ guint length_remaining;
+
+ length_remaining = tvb_reported_length_remaining(tvb, offset);
+ if (length_remaining < 4) {
+ proto_tree_add_expert_format(tree, pinfo, &ei_ospf_lsa_bad_length,
+ tvb, offset, length_remaining, "LLS option bit set but data block missing");
+ return;
+ }
ospf_lls_len = tvb_get_ntohs(tvb, offset + 2) * 4;
ospf_lls_data_block_tree = proto_tree_add_subtree(tree, tvb, offset, -1, ett_ospf_lls_data_block, NULL, "OSPF LLS Data Block");
@@ -2441,14 +2449,10 @@ dissect_ospf_v2_lsa(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *t
ls_length = tvb_get_ntohs(tvb, offset + 18);
end_offset = offset + ls_length;
- if (disassemble_body) {
- ospf_lsa_tree = proto_tree_add_subtree_format(tree, tvb, offset, ls_length,
- ett_ospf_lsa, &lsa_ti, "%s",
- val_to_str(ls_type, ls_type_vals, "Unknown (%d)"));
- } else {
- ospf_lsa_tree = proto_tree_add_subtree(tree, tvb, offset, OSPF_LSA_HEADER_LENGTH,
- ett_ospf_lsa, &lsa_ti, "LSA Header");
- }
+ ospf_lsa_tree = proto_tree_add_subtree_format(tree, tvb, offset, ls_length,
+ ett_ospf_lsa, &lsa_ti, "LSA-type %d (%s), len %d",
+ ls_type, val_to_str(ls_type, ls_type_vals, "Unknown (%d)"),
+ ls_length);
proto_tree_add_item(ospf_lsa_tree, hf_ospf_ls_age, tvb,
offset, 2, ENC_BIG_ENDIAN);
@@ -3764,7 +3768,7 @@ proto_register_ospf(void)
static ei_register_info ei[] = {
{ &ei_ospf_header_reserved, { "ospf.reserved.not_zero", PI_PROTOCOL, PI_WARN, "incorrect, should be 0", EXPFILL }},
- { &ei_ospf_lsa_bad_length, { "ospf.lsa.invalid_length", PI_MALFORMED, PI_WARN, "Invalid length", EXPFILL }},
+ { &ei_ospf_lsa_bad_length, { "ospf.lsa.invalid_length", PI_MALFORMED, PI_ERROR, "Invalid length", EXPFILL }},
{ &ei_ospf_lsa_constraint_missing, { "ospf.lsa.tos_missing", PI_MALFORMED, PI_WARN, "Blocks missing", EXPFILL }},
{ &ei_ospf_lsa_bc_error, { "ospf.lsa.bc_error", PI_PROTOCOL, PI_WARN, "BC error", EXPFILL }},
{ &ei_ospf_lsa_unknown_type, { "ospf.lsa.unknown_type", PI_PROTOCOL, PI_WARN, "Unknown LSA Type", EXPFILL }},