Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-lmi.c
blob065542d6212c6a421f21583b242db00b60e140a1
1 /* packet-lmi.c
2 * Routines for Frame Relay Local Management Interface (LMI) disassembly
3 * Copyright 2001, Jeffrey C. Foster <jfoste@woodward.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998
9 * SPDX-License-Identifier: GPL-2.0-or-later
11 * ToDo:
13 * References:
15 * http://www.techfest.com/networking/wan/frrel.htm
16 * https://www.broadband-forum.org/technical/download/FRF.1.2/frf1_2.pdf
17 * http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/frame.htm#xtocid18
18 * http://www.net.aapt.com.au/techref/lmimess.htm
19 * http://www.raleigh.ibm.com:80/cgi-bin/bookmgr/BOOKS/EZ305800/1.2.4.4
23 #include "config.h"
25 #include <epan/packet.h>
26 #include <epan/nlpid.h>
28 void proto_register_lmi(void);
29 void proto_reg_handoff_lmi(void);
31 static dissector_handle_t lmi_handle;
33 static int proto_lmi;
34 static int hf_lmi_call_ref;
35 static int hf_lmi_msg_type;
36 static int hf_lmi_inf_ele;
37 static int hf_lmi_inf_len;
39 static int hf_lmi_rcd_type;
40 static int hf_lmi_send_seq;
41 static int hf_lmi_recv_seq;
42 static int hf_lmi_dlci_high;
43 static int hf_lmi_dlci_low;
44 static int hf_lmi_new;
45 static int hf_lmi_act;
47 static int ett_lmi;
48 static int ett_lmi_ele;
50 #ifdef _OLD_
52 * Bits in the address field.
54 #define LMI_CMD 0xf000 /* LMI Command */
55 #define LMI_SEQ 0x0fff /* LMI Sequence number */
57 #endif
59 static const value_string msg_type_str[] = {
60 {0x75, "Status Enquiry"},
61 {0x7D, "Status"},
62 { 0, NULL }
65 static const value_string element_type_str[] = {
67 /*** These are the ANSI values ***/
68 {0x01, "Report"},
69 {0x03, "Keep Alive"},
70 {0x07, "PVC Status"},
72 /*** These are the ITU values ***/
73 {0x51, "Report"},
74 {0x53, "Keep Alive"},
75 //{0x07, "PVC Status"},
77 {0, NULL }
80 static const value_string record_type_str[] = {
81 {0x00, "Full Status"},
82 {0x01, "Link Integrity Verification Only"},
83 {0x02, "Single PVC"},
84 {0, NULL }
87 static const value_string pvc_status_new_str[] = {
88 {0x00, "PVC already present"},
89 {0x01, "PVC is new"},
90 {0, NULL }
93 static const value_string pvc_status_act_str[] = {
94 {0x00, "PVC is Inactive"},
95 {0x01, "PVC is Active"},
96 {0, NULL }
99 static void
100 dissect_lmi_report_type(tvbuff_t *tvb, int offset, proto_tree *tree)
102 proto_tree_add_item(tree, hf_lmi_rcd_type, tvb, offset, 1, ENC_NA);
105 static void
106 dissect_lmi_link_int(tvbuff_t *tvb, int offset, proto_tree *tree)
108 proto_tree_add_item(tree, hf_lmi_send_seq, tvb, offset, 1, ENC_NA);
109 ++offset;
110 proto_tree_add_item(tree, hf_lmi_recv_seq, tvb, offset, 1, ENC_NA);
114 static void
115 dissect_lmi_pvc_status(tvbuff_t *tvb, int offset, proto_tree *tree)
117 proto_tree_add_item(tree, hf_lmi_dlci_high, tvb, offset, 1, ENC_NA);
118 ++offset;
119 proto_tree_add_item(tree, hf_lmi_dlci_low, tvb, offset, 1, ENC_NA);
120 ++offset;
121 proto_tree_add_item(tree, hf_lmi_new, tvb, offset, 1, ENC_NA);
122 proto_tree_add_item(tree, hf_lmi_act, tvb, offset, 1, ENC_NA);
125 static int
126 dissect_lmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
128 proto_tree *lmi_tree, *lmi_subtree;
129 proto_item *ti;
130 int offset = 2, len;
131 uint8_t msg_type;
132 uint8_t ele_id;
134 col_set_str(pinfo->cinfo, COL_PROTOCOL, "LMI");
135 col_clear(pinfo->cinfo, COL_INFO);
137 ti = proto_tree_add_item(tree, proto_lmi, tvb, 0, 3, ENC_NA);
138 lmi_tree = proto_item_add_subtree(ti, ett_lmi_ele);
140 proto_tree_add_item(lmi_tree, hf_lmi_call_ref, tvb, 0, 1, ENC_BIG_ENDIAN);
142 msg_type = tvb_get_uint8( tvb, 1);
143 col_add_str(pinfo->cinfo, COL_INFO,
144 val_to_str(msg_type, msg_type_str, "Unknown message type (0x%02x)"));
146 proto_tree_add_uint(lmi_tree, hf_lmi_msg_type, tvb, 1, 1, msg_type);
148 /* Display the LMI elements */
149 while (tvb_reported_length_remaining(tvb, offset) > 0) {
150 ele_id = tvb_get_uint8( tvb, offset);
151 len = tvb_get_uint8( tvb, offset + 1);
153 lmi_subtree = proto_tree_add_subtree_format(lmi_tree, tvb, offset, len + 2,
154 ett_lmi_ele, NULL, "Information Element: %s",
155 val_to_str(ele_id, element_type_str, "Unknown (%u)"));
157 proto_tree_add_uint(lmi_subtree, hf_lmi_inf_ele, tvb, offset, 1,
158 ele_id);
159 ++offset;
160 proto_tree_add_uint(lmi_subtree, hf_lmi_inf_len, tvb, offset, 1, len);
161 ++offset;
162 if (( ele_id == 1) || (ele_id == 51))
163 dissect_lmi_report_type( tvb, offset, lmi_subtree);
164 else if (( ele_id == 3) || (ele_id == 53))
165 dissect_lmi_link_int( tvb, offset, lmi_subtree);
166 else if (( ele_id == 7) || (ele_id == 57))
167 dissect_lmi_pvc_status( tvb, offset, lmi_subtree);
168 offset += len;
170 return tvb_captured_length(tvb);
174 void
175 proto_register_lmi(void)
177 static hf_register_info hf[] = {
178 { &hf_lmi_call_ref,
179 { "Call reference", "lmi.cmd", FT_UINT8, BASE_HEX, NULL, 0,
180 NULL, HFILL }},
182 { &hf_lmi_msg_type,
183 { "Message Type", "lmi.msg_type", FT_UINT8, BASE_HEX, VALS(msg_type_str), 0,
184 NULL, HFILL }},
186 { &hf_lmi_inf_ele,
187 { "Type", "lmi.inf_ele_type", FT_UINT8, BASE_DEC, VALS(element_type_str), 0,
188 "Information Element Type", HFILL }},
189 { &hf_lmi_inf_len,
190 { "Length", "lmi.inf_ele_len", FT_UINT8, BASE_DEC, NULL, 0,
191 "Information Element Length", HFILL }},
193 { &hf_lmi_rcd_type,
194 { "Record Type", "lmi.ele_rcd_type", FT_UINT8, BASE_DEC, VALS(record_type_str), 0,
195 NULL, HFILL }},
196 { &hf_lmi_send_seq,
197 { "Send Seq", "lmi.send_seq", FT_UINT8, BASE_DEC, NULL, 0,
198 "Send Sequence", HFILL }},
199 { &hf_lmi_recv_seq,
200 { "Recv Seq", "lmi.recv_seq", FT_UINT8, BASE_DEC, NULL, 0,
201 "Receive Sequence", HFILL }},
202 { &hf_lmi_dlci_high,
203 { "DLCI High", "lmi.dlci_hi", FT_UINT8, BASE_DEC, NULL, 0x3f,
204 "DLCI High bits", HFILL }},
205 { &hf_lmi_dlci_low,
206 { "DLCI Low", "lmi.dlci_low", FT_UINT8, BASE_DEC, NULL, 0x78,
207 "DLCI Low bits", HFILL }},
208 { &hf_lmi_new,
209 { "DLCI New", "lmi.dlci_new", FT_UINT8, BASE_DEC, VALS(pvc_status_new_str), 0x08,
210 "DLCI New Flag", HFILL }},
211 { &hf_lmi_act,
212 { "DLCI Active","lmi.dlci_act", FT_UINT8, BASE_DEC, VALS(pvc_status_act_str), 0x02,
213 "DLCI Active Flag", HFILL }},
215 static int *ett[] = {
216 &ett_lmi,
217 &ett_lmi_ele,
219 proto_lmi = proto_register_protocol ("Local Management Interface", "LMI", "lmi");
220 proto_register_field_array (proto_lmi, hf, array_length(hf));
221 proto_register_subtree_array(ett, array_length(ett));
223 lmi_handle = register_dissector("lmi", dissect_lmi, proto_lmi);
226 void
227 proto_reg_handoff_lmi(void)
229 dissector_add_uint("fr.nlpid", NLPID_LMI, lmi_handle);
234 * Editor modelines - https://www.wireshark.org/tools/modelines.html
236 * Local variables:
237 * c-basic-offset: 4
238 * tab-width: 8
239 * indent-tabs-mode: nil
240 * End:
242 * vi: set shiftwidth=4 tabstop=8 expandtab:
243 * :indentSize=4:tabSize=8:noTabs=true: