add details for doxygen
[obnox/wireshark/wip.git] / packet-teimanagement.c
1 /* packet-teimanagement.c
2  * Routines for LAPD TEI Management frame disassembly
3  * Rolf Fiedler <rolf.fiedler@innoventif.com>
4  * based on code by Gilbert Ramirez <gram@alumni.rice.edu>
5  *
6  * $Id: packet-teimanagement.c,v 1.1 2004/01/26 20:48:38 guy Exp $
7  *
8  * Ethereal - Network traffic analyzer
9  * By Gerald Combs <gerald@ethereal.com>
10  * Copyright 1998
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <stdio.h>
32 #include <glib.h>
33 #include <string.h>
34 #include <epan/packet.h>
35 #include "lapd_sapi.h"
36
37 /* ISDN/LAPD references:
38  *
39  * http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/isdn.htm
40  * http://www.ece.wpi.edu/courses/ee535/hwk11cd95/agrebe/agrebe.html
41  * http://www.acacia-net.com/Clarinet/Protocol/q9213o84.htm
42  */
43
44 static int proto_tei=-1;
45
46 static int lm_entity_id=-1;
47 static int lm_reference=-1;
48 static int lm_message=-1;
49 static int lm_action=-1;
50 static int lm_extend =-1;
51 static gint lm_subtree=-1;
52
53 #define TEI_ID_REQUEST    0x01
54 #define TEI_ID_ASSIGNED   0x02
55 #define TEI_ID_DENIED     0x03
56 #define TEI_ID_CHECK_REQ  0x04
57 #define TEI_ID_CHECK_RESP 0x05
58 #define TEI_ID_REMOVE     0x06
59 #define TEI_ID_VERIFY     0x07
60
61 static const value_string tei_msg_vals[]={
62     { TEI_ID_REQUEST,    "Identity Request"},
63     { TEI_ID_ASSIGNED,   "Identity Assigned"},
64     { TEI_ID_DENIED,     "Identity Denied"},
65     { TEI_ID_CHECK_REQ,  "Identity Check Request"},
66     { TEI_ID_CHECK_RESP, "Identity Check Response"},
67     { TEI_ID_REMOVE,     "Identity Remove"},
68     { TEI_ID_VERIFY,     "Identity Verify"},
69     { 0, NULL}
70 };
71
72 static void
73 dissect_teimanagement(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
74 {
75     proto_tree *tei_tree = NULL;
76     proto_item *tei_ti;
77     guint8 message;
78     
79     if(check_col(pinfo->cinfo, COL_PROTOCOL)) 
80         col_set_str(pinfo->cinfo, COL_PROTOCOL, "TEI");
81     if (check_col(pinfo->cinfo, COL_INFO))
82         col_clear(pinfo->cinfo, COL_INFO);
83     
84     if (tree) {
85         tei_ti = proto_tree_add_item(tree, proto_tei, tvb, 0, 5, FALSE);
86         tei_tree = proto_item_add_subtree(tei_ti, lm_subtree);
87         
88         proto_tree_add_item(tei_tree, lm_entity_id, tvb, 0, 1, FALSE);
89         proto_tree_add_item(tei_tree, lm_reference,  tvb, 1, 2, FALSE);
90     }
91
92     message = tvb_get_guint8(tvb, 3);
93     if (check_col(pinfo->cinfo, COL_INFO))
94         col_set_str(pinfo->cinfo, COL_INFO,
95             val_to_str(message, tei_msg_vals, "Unknown message type (0x%04x)"));
96     if (tree) {
97         proto_tree_add_uint(tei_tree, lm_message, tvb, 3, 1, message);
98         proto_tree_add_item(tei_tree, lm_action, tvb, 4, 1, FALSE);
99         proto_tree_add_item(tei_tree, lm_extend, tvb, 4, 1, FALSE);
100     }
101 }
102
103 void
104 proto_register_teimanagement(void)
105 {
106     static gint *subtree[]={
107         &lm_subtree
108     };
109     
110     static hf_register_info hf[] = {
111         { &lm_entity_id,
112           { "Entity", "tei.entity", FT_UINT8, BASE_HEX, NULL, 0x0,
113                 "Layer Management Entity Identifier", HFILL }},
114
115         { &lm_reference,
116           { "Reference", "tei.reference", FT_UINT16, BASE_DEC, NULL, 0x0,
117                 "Reference Number", HFILL }},
118
119         { &lm_message,
120           { "Msg", "tei.msg", FT_UINT8, BASE_DEC, VALS(tei_msg_vals), 0x0,
121                 "Message Type", HFILL }},
122
123         { &lm_action,
124           { "Action", "tei.action", FT_UINT8, BASE_DEC, NULL, 0xfe,
125                 "Action Indicator", HFILL }},
126
127         { &lm_extend,
128           { "Extend", "tei.extend", FT_UINT8, BASE_DEC, NULL, 0x01,
129                 "Extension Indicator", HFILL }}
130     };
131
132     proto_tei = proto_register_protocol("TEI Management Procedure, Channel D (LAPD)",
133                                          "TEI_MANAGEMENT", "tei_management");
134     proto_register_field_array (proto_tei, hf, array_length(hf));
135     proto_register_subtree_array(subtree, array_length(subtree));
136 }
137
138 void
139 proto_reg_handoff_teimanagement(void)
140 {
141     dissector_handle_t teimanagement_handle;
142
143     teimanagement_handle = create_dissector_handle(dissect_teimanagement,
144         proto_tei);
145     dissector_add("lapd.sapi", LAPD_SAPI_L2, teimanagement_handle);
146 }