2 * Routines for the disassembly of the "Meraki Discovery Protocol (MDP)"
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include <epan/packet.h>
14 #define MDP_TLV_TYPE 0
15 #define MDP_TLV_LENGTH 1
16 #define MDP_TLV_DEVICE_INFO 2
17 #define MDP_TLV_NETWORK_INFO 3
18 #define MDP_TLV_LONGITUDE 4
19 #define MDP_TLV_LATITUDE 5
20 #define MDP_TLV_TYPE_SIX 6
21 #define MDP_TLV_TYPE_SEVEN 7
22 #define MDP_TLV_END 255
24 void proto_register_mdp(void);
25 void proto_reg_handoff_mdp(void);
28 static int hf_mdp_preamble_data
;
29 static int hf_mdp_device_info
;
30 static int hf_mdp_network_info
;
31 static int hf_mdp_type
;
32 static int hf_mdp_length
;
33 static int hf_mdp_longitude
;
34 static int hf_mdp_latitude
;
35 static int hf_mdp_type_six
;
36 static int hf_mdp_type_seven
;
37 static int hf_mdp_data
;
40 static int ett_mdp_tlv
;
42 static dissector_handle_t mdp_handle
;
44 /* Format Identifier */
45 static const value_string type_vals
[] = {
46 { MDP_TLV_DEVICE_INFO
, "Device Info" },
47 { MDP_TLV_NETWORK_INFO
, "Network Info" },
48 { MDP_TLV_LONGITUDE
, "Longitude" },
49 { MDP_TLV_LATITUDE
, "Latitude" },
50 { MDP_TLV_TYPE_SIX
, "Type 6 UID" },
51 { MDP_TLV_TYPE_SEVEN
, "Type 7 UID" },
52 { MDP_TLV_END
, "End" },
57 dissect_mdp(tvbuff_t
*mdp_tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
59 proto_tree
*mdp_tree
, *tlv_tree
;
60 proto_item
*mdp_item
, *tlv_item
;
61 uint32_t mdp_type
, mdp_length
;
64 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MDP");
65 col_set_str(pinfo
->cinfo
, COL_INFO
, "MDP");
67 mdp_item
= proto_tree_add_item(tree
, proto_mdp
, mdp_tvb
, 0, -1, ENC_NA
);
68 mdp_tree
= proto_item_add_subtree(mdp_item
, ett_mdp
);
70 proto_tree_add_item(mdp_tree
, hf_mdp_preamble_data
, mdp_tvb
, 0, 28, ENC_NA
);
73 while(tvb_reported_length_remaining(mdp_tvb
, offset
) != 0){
74 tlv_tree
= proto_tree_add_subtree(mdp_tree
, mdp_tvb
, offset
+ MDP_TLV_TYPE
, -1, ett_mdp_tlv
, &tlv_item
, "");
75 proto_tree_add_item_ret_uint(tlv_tree
, hf_mdp_type
, mdp_tvb
, offset
+ MDP_TLV_TYPE
, 1, ENC_BIG_ENDIAN
, &mdp_type
);
76 proto_item_set_text(tlv_tree
, "%s", val_to_str_const(mdp_type
, type_vals
, "Unknown type"));
77 proto_tree_add_item_ret_uint(tlv_tree
, hf_mdp_length
, mdp_tvb
, offset
+ MDP_TLV_LENGTH
, 1, ENC_BIG_ENDIAN
, &mdp_length
);
82 case MDP_TLV_DEVICE_INFO
:
83 proto_tree_add_item(tlv_tree
, hf_mdp_device_info
, mdp_tvb
, offset
, mdp_length
, ENC_UTF_8
| ENC_NA
);
85 case MDP_TLV_NETWORK_INFO
:
86 proto_tree_add_item(tlv_tree
, hf_mdp_network_info
, mdp_tvb
, offset
, mdp_length
, ENC_UTF_8
| ENC_NA
);
88 case MDP_TLV_LONGITUDE
:
89 proto_tree_add_item(tlv_tree
, hf_mdp_longitude
, mdp_tvb
, offset
, mdp_length
, ENC_UTF_8
| ENC_NA
);
91 case MDP_TLV_LATITUDE
:
92 proto_tree_add_item(tlv_tree
, hf_mdp_latitude
, mdp_tvb
, offset
, mdp_length
, ENC_UTF_8
| ENC_NA
);
94 case MDP_TLV_TYPE_SIX
:
95 proto_tree_add_item(tlv_tree
, hf_mdp_type_six
, mdp_tvb
, offset
, mdp_length
, ENC_UTF_8
| ENC_NA
);
97 case MDP_TLV_TYPE_SEVEN
:
98 proto_tree_add_item(tlv_tree
, hf_mdp_type_seven
, mdp_tvb
, offset
, mdp_length
, ENC_UTF_8
| ENC_NA
);
103 proto_tree_add_item(mdp_tree
, hf_mdp_data
, mdp_tvb
, offset
, mdp_length
, ENC_NA
);
106 proto_item_set_len(tlv_item
, mdp_length
+ 2);
107 offset
+= mdp_length
;
109 return tvb_captured_length(mdp_tvb
);
113 proto_register_mdp(void)
116 static hf_register_info hf
[] = {
117 { &hf_mdp_preamble_data
, {"Preamble Data","mdp.preamble_data", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
118 { &hf_mdp_device_info
, {"Device Info", "mdp.device_info", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
119 { &hf_mdp_network_info
, {"Network Info", "mdp.network_info", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
120 { &hf_mdp_longitude
, {"Longitude", "mdp.longitude", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
121 { &hf_mdp_latitude
, {"Latitude", "mdp.latitude", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
122 { &hf_mdp_type
, {"Type", "mdp.type", FT_UINT8
, BASE_DEC
, VALS(type_vals
), 0x0, NULL
, HFILL
}},
123 { &hf_mdp_type_six
, {"Type 6 UID", "mdp.type_six", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
124 { &hf_mdp_type_seven
, {"Type 7 UID", "mdp.type_seven", FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
125 { &hf_mdp_length
, {"Length", "mdp.length", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
126 { &hf_mdp_data
, {"Unknown Data", "mdp.data", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}}
129 static int *ett
[] = {
134 proto_mdp
= proto_register_protocol("Meraki Discovery Protocol", "MDP", "mdp");
135 proto_register_field_array(proto_mdp
, hf
, array_length(hf
));
136 proto_register_subtree_array(ett
, array_length(ett
));
138 mdp_handle
= register_dissector("mdp", dissect_mdp
, proto_mdp
);
142 proto_reg_handoff_mdp(void)
144 dissector_add_uint("ethertype", 0x0712, mdp_handle
);
145 dissector_add_uint("ethertype", 0x0713, mdp_handle
);
149 * Editor modelines - https://www.wireshark.org/tools/modelines.html
154 * indent-tabs-mode: nil
157 * vi: set shiftwidth=4 tabstop=8 expandtab:
158 * :indentSize=4:tabSize=8:noTabs=true: