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>
9 * SPDX-License-Identifier: GPL-2.0-or-later
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
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
;
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
;
48 static int ett_lmi_ele
;
52 * Bits in the address field.
54 #define LMI_CMD 0xf000 /* LMI Command */
55 #define LMI_SEQ 0x0fff /* LMI Sequence number */
59 static const value_string msg_type_str
[] = {
60 {0x75, "Status Enquiry"},
65 static const value_string element_type_str
[] = {
67 /*** These are the ANSI values ***/
72 /*** These are the ITU values ***/
75 //{0x07, "PVC Status"},
80 static const value_string record_type_str
[] = {
81 {0x00, "Full Status"},
82 {0x01, "Link Integrity Verification Only"},
87 static const value_string pvc_status_new_str
[] = {
88 {0x00, "PVC already present"},
93 static const value_string pvc_status_act_str
[] = {
94 {0x00, "PVC is Inactive"},
95 {0x01, "PVC is Active"},
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
);
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
);
110 proto_tree_add_item(tree
, hf_lmi_recv_seq
, tvb
, offset
, 1, ENC_NA
);
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
);
119 proto_tree_add_item(tree
, hf_lmi_dlci_low
, tvb
, offset
, 1, ENC_NA
);
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
);
126 dissect_lmi(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
128 proto_tree
*lmi_tree
, *lmi_subtree
;
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,
160 proto_tree_add_uint(lmi_subtree
, hf_lmi_inf_len
, tvb
, offset
, 1, len
);
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
);
170 return tvb_captured_length(tvb
);
175 proto_register_lmi(void)
177 static hf_register_info hf
[] = {
179 { "Call reference", "lmi.cmd", FT_UINT8
, BASE_HEX
, NULL
, 0,
183 { "Message Type", "lmi.msg_type", FT_UINT8
, BASE_HEX
, VALS(msg_type_str
), 0,
187 { "Type", "lmi.inf_ele_type", FT_UINT8
, BASE_DEC
, VALS(element_type_str
), 0,
188 "Information Element Type", HFILL
}},
190 { "Length", "lmi.inf_ele_len", FT_UINT8
, BASE_DEC
, NULL
, 0,
191 "Information Element Length", HFILL
}},
194 { "Record Type", "lmi.ele_rcd_type", FT_UINT8
, BASE_DEC
, VALS(record_type_str
), 0,
197 { "Send Seq", "lmi.send_seq", FT_UINT8
, BASE_DEC
, NULL
, 0,
198 "Send Sequence", HFILL
}},
200 { "Recv Seq", "lmi.recv_seq", FT_UINT8
, BASE_DEC
, NULL
, 0,
201 "Receive Sequence", HFILL
}},
203 { "DLCI High", "lmi.dlci_hi", FT_UINT8
, BASE_DEC
, NULL
, 0x3f,
204 "DLCI High bits", HFILL
}},
206 { "DLCI Low", "lmi.dlci_low", FT_UINT8
, BASE_DEC
, NULL
, 0x78,
207 "DLCI Low bits", HFILL
}},
209 { "DLCI New", "lmi.dlci_new", FT_UINT8
, BASE_DEC
, VALS(pvc_status_new_str
), 0x08,
210 "DLCI New Flag", HFILL
}},
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
[] = {
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
);
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
239 * indent-tabs-mode: nil
242 * vi: set shiftwidth=4 tabstop=8 expandtab:
243 * :indentSize=4:tabSize=8:noTabs=true: