2 * Routines for Frame Relay Local Management Interface (LMI) disassembly
3 * Copyright 2001, Jeffrey C. Foster <jfoste@woodward.com>
5 * $Id: packet-lmi.c,v 1.12 2003/01/11 07:01:59 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 * http://www.techfest.com/networking/wan/frrel.htm
30 * http://www.frforum.com/5000/frf1_2.pdf
31 * http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/frame.htm#xtocid125314
32 * http://www.net.aapt.com.au/techref/lmimess.htm
33 * http://www.raleigh.ibm.com:80/cgi-bin/bookmgr/BOOKS/EZ305800/1.2.4.4
44 #include <epan/packet.h>
47 static int proto_lmi = -1;
48 static int hf_lmi_call_ref = -1;
49 static int hf_lmi_msg_type = -1;
50 static int hf_lmi_inf_ele = -1;
51 static int hf_lmi_inf_len = -1;
53 static int hf_lmi_rcd_type = -1;
54 static int hf_lmi_send_seq = -1;
55 static int hf_lmi_recv_seq = -1;
56 static int hf_lmi_dlci_high = -1;
57 static int hf_lmi_dlci_low = -1;
58 static int hf_lmi_new = -1;
59 static int hf_lmi_act = -1;
61 static gint ett_lmi = -1;
62 static gint ett_lmi_ele = -1;
66 * Bits in the address field.
68 #define LMI_CMD 0xf000 /* LMI Command */
69 #define LMI_SEQ 0x0fff /* LMI Sequence number */
73 static const value_string msg_type_str[] = {
74 {0x75, "Status Enquiry"},
79 static const value_string element_type_str[] = {
81 /*** These are the ANSI values ***/
86 /*** These are the ITU values ***/
94 static const value_string record_type_str[] = {
95 {0x00, "Full Status"},
96 {0x01, "Link Integrity Verification Only"},
101 static const value_string pvc_status_new_str[] = {
102 {0x00, "PVC already present"},
103 {0x01, "PVC is new"},
107 static const value_string pvc_status_act_str[] = {
108 {0x00, "PVC is Inactive"},
109 {0x01, "PVC is Active"},
114 dissect_lmi_report_type(tvbuff_t *tvb, int offset, proto_tree *tree)
116 proto_tree_add_uint(tree, hf_lmi_rcd_type, tvb, offset, 1, tvb_get_guint8( tvb, offset));
120 dissect_lmi_link_int(tvbuff_t *tvb, int offset, proto_tree *tree)
122 proto_tree_add_uint(tree, hf_lmi_send_seq, tvb, offset, 1, tvb_get_guint8( tvb, offset));
124 proto_tree_add_uint(tree, hf_lmi_recv_seq, tvb, offset, 1, tvb_get_guint8( tvb, offset));
129 dissect_lmi_pvc_status(tvbuff_t *tvb, int offset, proto_tree *tree)
131 proto_tree_add_uint(tree, hf_lmi_dlci_high, tvb, offset, 1, tvb_get_guint8( tvb, offset));
133 proto_tree_add_uint(tree, hf_lmi_dlci_low, tvb, offset, 1, tvb_get_guint8( tvb, offset));
135 proto_tree_add_uint(tree, hf_lmi_new, tvb, offset, 1, tvb_get_guint8( tvb, offset));
136 proto_tree_add_uint(tree, hf_lmi_act, tvb, offset, 1, tvb_get_guint8( tvb, offset));
140 dissect_lmi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
142 proto_tree *lmi_tree = NULL, *lmi_subtree;
148 if (check_col(pinfo->cinfo, COL_PROTOCOL))
149 col_set_str(pinfo->cinfo, COL_PROTOCOL, "LMI");
150 if (check_col(pinfo->cinfo, COL_INFO))
151 col_clear(pinfo->cinfo, COL_INFO);
154 ti = proto_tree_add_item(tree, proto_lmi, tvb, 0, 3, FALSE);
155 lmi_tree = proto_item_add_subtree(ti, ett_lmi_ele);
157 proto_tree_add_item(lmi_tree, hf_lmi_call_ref, tvb, 0, 1, FALSE);
159 msg_type = tvb_get_guint8( tvb, 1);
160 if (check_col(pinfo->cinfo, COL_INFO)) {
161 col_add_str(pinfo->cinfo, COL_INFO,
162 val_to_str(msg_type, msg_type_str, "Unknown message type (0x%02x)"));
165 proto_tree_add_uint(lmi_tree, hf_lmi_msg_type, tvb, 1, 1, msg_type);
167 /* Display the LMI elements */
168 while (tvb_reported_length_remaining(tvb, offset) > 0) {
169 ele_id = tvb_get_guint8( tvb, offset);
170 len = tvb_get_guint8( tvb, offset + 1);
172 ti = proto_tree_add_uint(lmi_tree, hf_lmi_inf_ele, tvb, offset, len + 2,
173 tvb_get_guint8( tvb, offset));
175 lmi_subtree = proto_item_add_subtree(ti, ett_lmi_ele);
177 proto_tree_add_uint(lmi_subtree, hf_lmi_inf_ele, tvb, offset, 1,
178 tvb_get_guint8( tvb, offset));
180 len = tvb_get_guint8( tvb, offset);
181 proto_tree_add_uint(lmi_subtree, hf_lmi_inf_len, tvb, offset, 1, len);
183 if (( ele_id == 1) || (ele_id == 51))
184 dissect_lmi_report_type( tvb, offset, lmi_subtree);
185 else if (( ele_id == 3) || (ele_id == 53))
186 dissect_lmi_link_int( tvb, offset, lmi_subtree);
187 else if (( ele_id == 7) || (ele_id == 57))
188 dissect_lmi_pvc_status( tvb, offset, lmi_subtree);
199 proto_register_lmi(void)
201 static hf_register_info hf[] = {
203 { "Call reference", "lmi.cmd", FT_UINT8, BASE_HEX, NULL, 0,
204 "Call Reference", HFILL }},
207 { "Message Type", "lmi.msg_type", FT_UINT8, BASE_HEX, VALS(msg_type_str), 0,
208 "Message Type", HFILL }},
211 { "Information Element", "lmi.inf_ele", FT_UINT8, BASE_DEC, VALS(element_type_str), 0,
212 "Information Element", HFILL }},
214 { "Type", "lmi.inf_ele_type", FT_UINT8, BASE_DEC, VALS(element_type_str), 0,
215 "Information Element Type", HFILL }},
217 { "Length", "lmi.inf_ele_len", FT_UINT8, BASE_DEC, NULL, 0,
218 "Information Element Length", HFILL }},
221 { "Record Type", "lmi.ele_rcd_type", FT_UINT8, BASE_DEC, VALS(record_type_str), 0,
222 "Record Type", HFILL }},
224 { "Send Seq", "lmi.send_seq", FT_UINT8, BASE_DEC, NULL, 0,
225 "Send Sequence", HFILL }},
227 { "Recv Seq", "lmi.recv_seq", FT_UINT8, BASE_DEC, NULL, 0,
228 "Receive Sequence", HFILL }},
230 { "DLCI High", "lmi.dlci_hi", FT_UINT8, BASE_DEC, NULL, 0x3f,
231 "DLCI High bits", HFILL }},
233 { "DLCI Low", "lmi.dlci_low", FT_UINT8, BASE_DEC, NULL, 0x78,
234 "DLCI Low bits", HFILL }},
236 { "DLCI New", "lmi.dlci_new", FT_UINT8, BASE_DEC, VALS(pvc_status_new_str), 0x08,
237 "DLCI New Flag", HFILL }},
239 { "DLCI Active","lmi.dlci_act", FT_UINT8, BASE_DEC, VALS(pvc_status_act_str), 0x02,
240 "DLCI Active Flag", HFILL }},
242 static gint *ett[] = {
246 proto_lmi = proto_register_protocol ("Local Management Interface", "LMI", "lmi");
247 proto_register_field_array (proto_lmi, hf, array_length(hf));
248 proto_register_subtree_array(ett, array_length(ett));
253 proto_reg_handoff_lmi(void)
255 dissector_handle_t lmi_handle;
257 lmi_handle = create_dissector_handle(dissect_lmi, proto_lmi);
258 dissector_add("fr.ietf", NLPID_LMI, lmi_handle);