Revert "Fixup: tvb_* -> tvb_captured"
[metze/wireshark/wip.git] / epan / dissectors / packet-v150fw.c
1 /* packet-v150fw.c
2  *
3  * v150fw = v.150.1 SSE messages, contained in RTP packets
4  *
5  * Written by Jamison Adcock <jamison.adcock@cobham.com>
6  * for Sparta Inc., dba Cobham Analytic Solutions
7  * This code is largely based on the RTP parsing code
8  *
9  * Wireshark - Network traffic analyzer
10  * By Gerald Combs <gerald@wireshark.org>
11  * Copyright 1998 Gerald Combs
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26  */
27
28
29 #include "config.h"
30
31 #include <glib.h>
32
33 #include <epan/packet.h>
34
35 void proto_register_v150fw(void);
36
37 /* Initialize the protocol & registered fields
38  * Look familiar?  This is in the same format as an NTE (named telephone event) from RFC 2833:
39  */
40 static int proto_v150fw =                   -1;
41
42 static int hf_v150fw_event_id =             -1; /* 6 bits */
43 static int hf_v150fw_force_response_bit =   -1;
44 static int hf_v150fw_extension_bit =        -1;
45
46 static int hf_v150fw_reason_id_code =                       -1; /* value & string */
47
48 static int hf_v150fw_reason_id_code_info =                  -1; /* 16 bits */
49
50 static int hf_v150fw_ric_info_mod_avail =                   -1; /* ric = 1,2 */
51 static int hf_v150fw_cm_jm_mod_avail_pcm_mode =             -1;
52 static int hf_v150fw_cm_jm_mod_avail_v34_duplex =           -1;
53 static int hf_v150fw_cm_jm_mod_avail_v34_half_duplex =      -1;
54 static int hf_v150fw_cm_jm_mod_avail_v32_v32bis =           -1;
55 static int hf_v150fw_cm_jm_mod_avail_v22_v22bis =           -1;
56 static int hf_v150fw_cm_jm_mod_avail_v17 =                  -1;
57 static int hf_v150fw_cm_jm_mod_avail_v29_half_duplex =      -1;
58 static int hf_v150fw_cm_jm_mod_avail_v27ter =               -1;
59 static int hf_v150fw_cm_jm_mod_avail_v26ter =               -1;
60 static int hf_v150fw_cm_jm_mod_avail_v26bis =               -1;
61 static int hf_v150fw_cm_jm_mod_avail_v23_duplex =           -1;
62 static int hf_v150fw_cm_jm_mod_avail_v23_half_duplex =      -1;
63 static int hf_v150fw_cm_jm_mod_avail_v21 =                  -1;
64 static int hf_v150fw_cm_jm_mod_avail_v90_or_v92_analog =    -1;
65 static int hf_v150fw_cm_jm_mod_avail_v90_or_v92_digital =   -1;
66 static int hf_v150fw_cm_jm_mod_avail_v91 =                  -1;
67
68 static int hf_v150fw_ric_info_timeout =                     -1; /* ric= 18 */
69 static int hf_v150fw_ric_info_timeout_vendor =              -1;
70
71 static int hf_v150fw_ric_info_cleardown =                   -1; /* ric = 20 */
72 static int hf_v150fw_ric_info_cleardown_reserved =          -1;
73 static int hf_v150fw_ric_info_cleardown_vendor_tag =        -1; /* extension fields */
74 static int hf_v150fw_ric_info_cleardown_vendor_info =       -1;
75
76 static int hf_v150fw_reserved =             -1; /* 5 bits */
77 static int hf_v150fw_extension_len =        -1; /* 11 bits */
78 static int hf_v150fw_remainder =            -1;
79
80 /* initialize the subtree pointers */
81 static gint ett_v150fw = -1;
82 static gint ett_available_modulations = -1;
83
84 /* for some "range_string"s, there's only one value in the range  */
85 #define V150FW_VALUE_RANGE(a) a,a
86
87
88 /* V.150.1 State Signalling Events (SSE): */
89 #define V150FW_EVENT_RESERVED1          0
90 #define V150FW_EVENT_INITIAL_AUDIO      1
91 #define V150FW_EVENT_VOICEBAND_DATA     2
92 #define V150FW_EVENT_MODEM_RELAY        3
93 #define V150FW_EVENT_FAX_RELAY          4
94 #define V150FW_EVENT_TEXT_RELAY         5
95 #define V150FW_EVENT_TEXT_PROBE         6 /* new in ITU-T Rec. V.150.1 (2003)/Amd.2 (05/2006) */
96 /* 7 - 31 reserved for future use */
97 #define V150FW_EVENT_RESERVED2_START    7
98 #define V150FW_EVENT_RESERVED2_END      31
99 /* 32 - 63 vendor-defined */
100 #define V150FW_EVENT_VENDOR_START       32
101 #define V150FW_EVENT_VENDOR_END         63
102
103
104 /* V.150.1 SSE reason ID codes: */
105 #define V150FW_RIC_NULL                     0
106 #define V150FW_RIC_CM                       1
107 #define V150FW_RIC_JM                       2
108 #define V150FW_RIC_AA                       3
109 #define V150FW_RIC_AC                       4
110 #define V150FW_RIC_USB1                     5
111 #define V150FW_RIC_SB1                      6
112 #define V150FW_RIC_S1                       7
113 #define V150FW_RIC_V21_CH2                  8
114 #define V150FW_RIC_V21_CH1                  9
115 #define V150FW_RIC_V23_HIGH_CHANNEL         10
116 #define V150FW_RIC_V23_LOW_CHANNEL          11
117 #define V150FW_RIC_TONE_2225_HZ             12
118 #define V150FW_RIC_V21_CH2_HDLC_FLAGS       13
119 #define V150FW_RIC_INDETERMINATE_SIGNAL     14
120 #define V150FW_RIC_SILENCE                  15
121 #define V150FW_RIC_CNG                      16
122 #define V150FW_RIC_VOICE                    17
123 #define V150FW_RIC_TIMEOUT                  18
124 #define V150FW_RIC_P_STATE_TRANS            19
125 #define V150FW_RIC_CLEARDOWN                20
126 #define V150FW_RIC_ANS_CED_2100_HZ          21
127 #define V150FW_RIC_ANSAM                    22
128 #define V150FW_RIC_SLASH_ANS                23
129 #define V150FW_RIC_SLASH_ANSAM              24
130 #define V150FW_RIC_QC1A                     25
131 #define V150FW_RIC_QC1D                     26
132 #define V150FW_RIC_QC2A                     27
133 #define V150FW_RIC_QC2D                     28
134 #define V150FW_RIC_CRE                      29
135 #define V150FW_RIC_CRD                      30
136 /* new from ITU-T V.150.1 Amendment 1: */
137 #define V150FW_RIC_TIA_825A_45              31
138 #define V150FW_RIC_TIA_825A_50              32
139 #define V150FW_RIC_EDT                      33
140 #define V150FW_RIC_BELL_103_MODEM           34
141 #define V150FW_RIC_V21_TEXT_PHONE_T50       35
142 #define V150FW_RIC_V23_TEXT_MINITEL         36
143 #define V150FW_RIC_V18_TEXT_PHONE_T140      37
144 #define V150FW_RIC_DTMF_BASED_TEXT_RELAY    38
145 #define V150FW_RIC_CTM                      39
146 /* 40 - 127 reserved */
147 #define V150FW_RIC_RESERVED_START           40
148 #define V150FW_RIC_RESERVED_END             127
149 /* 128 - 255 for vendor use */
150 #define V150FW_RIC_VENDOR_START             128
151 #define V150FW_RIC_VENDOR_END               255
152
153
154 /* Timeout (V150FW_RIC_TIMEOUT) reason info: */
155 #define V150FW_RIC_INFO_TIMEOUT_NULL                            0
156 #define V150FW_RIC_INFO_TIMEOUT_CALL_DISCRIMINATION_TIMEOUT     1
157 #define V150FW_RIC_INFO_TIMEOUT_IP_TLP_TIMEOUT                  2
158 #define V150FW_RIC_INFO_TIMEOUT_SSE_EXPLICIT_ACK_TIMEOUT        3
159
160
161 /* Cleardown (V150FW_RIC_CLEARDOWN) reason info: */
162 #define V150FW_RIC_INFO_CLEARDOWN_UNKNOWN                       0
163 #define V150FW_RIC_INFO_CLEARDOWN_PHYSICAL_LAYER_RELEASE        1
164 #define V150FW_RIC_INFO_CLEARDOWN_LINK_LAYER_DISCONNECT         2
165 #define V150FW_RIC_INFO_CLEARDOWN_DATA_COMPRESSION_DISCONNECT   3
166 #define V150FW_RIC_INFO_CLEARDOWN_ABORT                         4
167 #define V150FW_RIC_INFO_CLEARDOWN_ON_HOOK                       5
168 #define V150FW_RIC_INFO_CLEARDOWN_NETWORK_LAYER_TERMINATION     6
169 #define V150FW_RIC_INFO_CLEARDOWN_ADMINISTRATIVE                7
170
171 /* value strings & range strings */
172 static const range_string v150fw_event_id_name[] = {
173     { V150FW_VALUE_RANGE(V150FW_EVENT_RESERVED1),               "Event ID reserved" },
174     { V150FW_VALUE_RANGE(V150FW_EVENT_INITIAL_AUDIO),           "Initial audio" },
175     { V150FW_VALUE_RANGE(V150FW_EVENT_VOICEBAND_DATA),          "Voice band data" },
176     { V150FW_VALUE_RANGE(V150FW_EVENT_MODEM_RELAY),             "Modem relay" },
177     { V150FW_VALUE_RANGE(V150FW_EVENT_FAX_RELAY),               "Fax relay" },
178     { V150FW_VALUE_RANGE(V150FW_EVENT_TEXT_RELAY),              "Text relay" },
179     { V150FW_VALUE_RANGE(V150FW_EVENT_TEXT_PROBE),              "Text probe" },
180     { V150FW_EVENT_RESERVED2_START, V150FW_EVENT_RESERVED2_END, "Reserved for ITU_T" },
181     { V150FW_EVENT_VENDOR_START, V150FW_EVENT_VENDOR_END,       "Vendor-defined event" },
182     { 0, 0, NULL }
183 };
184
185 static const range_string v150fw_ric_name[] = {
186     { V150FW_VALUE_RANGE(V150FW_RIC_NULL),                  "None" },
187     { V150FW_VALUE_RANGE(V150FW_RIC_CM),                    "CM" },
188     { V150FW_VALUE_RANGE(V150FW_RIC_JM),                    "JM" },
189     { V150FW_VALUE_RANGE(V150FW_RIC_AA),                    "AA" },
190     { V150FW_VALUE_RANGE(V150FW_RIC_AC),                    "AC" },
191     { V150FW_VALUE_RANGE(V150FW_RIC_USB1),                  "USB1" },
192     { V150FW_VALUE_RANGE(V150FW_RIC_SB1),                   "SB1" },
193     { V150FW_VALUE_RANGE(V150FW_RIC_S1),                    "S1" },
194     { V150FW_VALUE_RANGE(V150FW_RIC_V21_CH2),               "V.21 Ch2" },
195     { V150FW_VALUE_RANGE(V150FW_RIC_V21_CH1),               "V.21 Ch1" },
196     { V150FW_VALUE_RANGE(V150FW_RIC_V23_HIGH_CHANNEL),      "V.23 High Channel" },
197     { V150FW_VALUE_RANGE(V150FW_RIC_V23_LOW_CHANNEL),       "V.23 Low Channel" },
198     { V150FW_VALUE_RANGE(V150FW_RIC_TONE_2225_HZ),          "Tone (2225 Hz)" },
199     { V150FW_VALUE_RANGE(V150FW_RIC_V21_CH2_HDLC_FLAGS),    "V.21 Ch2 HDLC Flags" },
200     { V150FW_VALUE_RANGE(V150FW_RIC_INDETERMINATE_SIGNAL),  "Indeterminate signal" },
201     { V150FW_VALUE_RANGE(V150FW_RIC_SILENCE),               "Silence" },
202     { V150FW_VALUE_RANGE(V150FW_RIC_CNG),                   "CNG" },
203     { V150FW_VALUE_RANGE(V150FW_RIC_VOICE),                 "Voice" },
204     { V150FW_VALUE_RANGE(V150FW_RIC_TIMEOUT),               "Timeout" },
205     { V150FW_VALUE_RANGE(V150FW_RIC_P_STATE_TRANS),         "p' State Transition" },
206     { V150FW_VALUE_RANGE(V150FW_RIC_CLEARDOWN),             "Cleardown" },
207     { V150FW_VALUE_RANGE(V150FW_RIC_ANS_CED_2100_HZ),       "ANS/CED (2100Hz)" },
208     { V150FW_VALUE_RANGE(V150FW_RIC_ANSAM),                 "ANSam" },
209     { V150FW_VALUE_RANGE(V150FW_RIC_SLASH_ANS),             "/ANS" },
210     { V150FW_VALUE_RANGE(V150FW_RIC_SLASH_ANSAM),           "/ANSam" },
211     { V150FW_VALUE_RANGE(V150FW_RIC_QC1A),                  "QC1a" },
212     { V150FW_VALUE_RANGE(V150FW_RIC_QC1D),                  "QC1d" },
213     { V150FW_VALUE_RANGE(V150FW_RIC_QC2A),                  "QC2a" },
214     { V150FW_VALUE_RANGE(V150FW_RIC_QC2D),                  "QC2d" },
215     { V150FW_VALUE_RANGE(V150FW_RIC_CRE),                   "Cre" },
216     { V150FW_VALUE_RANGE(V150FW_RIC_CRD),                   "CRd" },
217     { V150FW_VALUE_RANGE(V150FW_RIC_TIA_825A_45),           "TIA-825A (45.45 bit/s)" },
218     { V150FW_VALUE_RANGE(V150FW_RIC_TIA_825A_50),           "TIA-825A (50 bit/s)" },
219     { V150FW_VALUE_RANGE(V150FW_RIC_EDT),                   "EDT (European Deaf Telephone)" },
220     { V150FW_VALUE_RANGE(V150FW_RIC_BELL_103_MODEM),        "Bell 103 Modem" },
221     { V150FW_VALUE_RANGE(V150FW_RIC_V21_TEXT_PHONE_T50),    "V.21 text telephone, T-50 encoding" },
222     { V150FW_VALUE_RANGE(V150FW_RIC_V23_TEXT_MINITEL),      "V.23 text (Minitel)" },
223     { V150FW_VALUE_RANGE(V150FW_RIC_V18_TEXT_PHONE_T140),   "V.18 text telephone, T-140 encoding" },
224     { V150FW_VALUE_RANGE(V150FW_RIC_DTMF_BASED_TEXT_RELAY), "DTMF based Text Relay (Annex B/V.18)" },
225     { V150FW_VALUE_RANGE(V150FW_RIC_CTM),                   "CTM" },
226     { V150FW_RIC_RESERVED_START, V150FW_RIC_RESERVED_END,   "Reserved for use by ITU-T" },
227     { V150FW_RIC_VENDOR_START, V150FW_RIC_VENDOR_END,       "For use by vendor" },
228     { 0, 0, NULL }
229 };
230
231 static const value_string v150fw_ric_info_timeout_type[] = {
232     { V150FW_RIC_INFO_TIMEOUT_NULL,                         "Null" },
233     { V150FW_RIC_INFO_TIMEOUT_CALL_DISCRIMINATION_TIMEOUT,  "Call discrimination timeout" },
234     { V150FW_RIC_INFO_TIMEOUT_IP_TLP_TIMEOUT,               "IP TLP timeout" },
235     { V150FW_RIC_INFO_TIMEOUT_SSE_EXPLICIT_ACK_TIMEOUT,     "Explicit acknowledgement timeout" },
236     { 0, NULL }
237 };
238
239 static const value_string v150fw_ric_info_cleardown_type[] = {
240     { V150FW_RIC_INFO_CLEARDOWN_UNKNOWN,                     "Unknown/unspecified" },
241     { V150FW_RIC_INFO_CLEARDOWN_PHYSICAL_LAYER_RELEASE,      "Physical layer release" },
242     { V150FW_RIC_INFO_CLEARDOWN_LINK_LAYER_DISCONNECT,       "Link layer disconnect" },
243     { V150FW_RIC_INFO_CLEARDOWN_DATA_COMPRESSION_DISCONNECT, "Data compression disconnect" },
244     { V150FW_RIC_INFO_CLEARDOWN_ABORT,                       "Abort" },
245     { V150FW_RIC_INFO_CLEARDOWN_ON_HOOK,                     "On hook" },
246     { V150FW_RIC_INFO_CLEARDOWN_NETWORK_LAYER_TERMINATION,   "Network layer termination" },
247     { V150FW_RIC_INFO_CLEARDOWN_ADMINISTRATIVE,              "Administrative" },
248     { 0, NULL }
249 };
250
251
252 #if 0 /* XXX: The following doesn't actually dissect anything. Is dissect_v150fw() supposed to be called ? */
253 static gboolean
254 dissect_v150fw_heur(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_)
255 {
256     guint8 octet1;
257     guint8 extb, ric;
258     guint16 ric_info;
259     gint payload_length = tvb_length(tvb);
260     unsigned int offset = 0;
261
262     /* see appendix C (State Signalling Events) in ITU-T Rec. V.150.1 for details */
263
264     /* Get the fields */
265     octet1 = tvb_get_guint8(tvb, offset);
266     extb = octet1 & 0x01;
267     ric = tvb_get_guint8(tvb, offset + 1) & 0xFF;
268
269     ric_info = tvb_get_ntohs(tvb, offset + 2);
270
271     /* minimum lengths */
272     if(!extb && payload_length <= 4) /* extb is not set, so minimum length is 4 bytes */
273         return FALSE;
274     if(extb && payload_length <= 6) /* ext bit is set, but no extension found? */
275         return FALSE;
276
277     if(ric == 0 || (ric >= 6 && ric <= 31)) /* values reserved for future use */
278         return FALSE;
279
280     switch(ric)
281     {
282         case 0:
283             if(ric_info != 0) /* ric_info must be NULL if ric is NULL */
284                 return FALSE;
285         case V150FW_RIC_CM:
286         case V150FW_RIC_JM:
287             if(!extb && payload_length > 4) /* payload too long */
288                 return FALSE;
289             break;
290         case V150FW_RIC_TIMEOUT:
291         case V150FW_RIC_CLEARDOWN:
292             break;
293         default:
294             if(ric < 31 && ric_info != 0) /* ric_info is zero unless ric is CM, JM, TIMEOUT ro CLEARDOWN */
295                 return FALSE;
296             if(ric >= 31 && ric <= 127) /* 31 - 127 are reserved for future use */
297                 return FALSE;
298             /* 128 - 255 are vendor-specific */
299             break;
300     }
301
302     return TRUE;
303 }
304 #endif
305
306 static int
307 dissect_v150fw(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void *data _U_)
308 {
309     /* Set up structures needed to add the protocol subtree and manage it */
310     proto_item *ti;
311     proto_tree *v150fw_tree, *field_tree;
312     guint8 extb, ric;
313     guint16 ext_len = 0;
314     gint payload_length;
315     unsigned int offset = 0;
316
317     if(tree)
318     {
319         /* create the trees */
320         ti = proto_tree_add_item(tree, proto_v150fw, tvb, 0, -1, ENC_NA);
321         v150fw_tree = proto_item_add_subtree(ti, ett_v150fw);
322
323         payload_length = tvb_length(tvb);
324
325         /* Get fields needed for further dissection */
326         extb = tvb_get_guint8(tvb, offset) & 0x01; /* extension bit */
327         ric = tvb_get_guint8(tvb, offset + 1);
328
329         if(extb && payload_length >= 6) /* get optional extension fields */
330             ext_len = tvb_get_ntohs(tvb, offset + 4) & 0x07FF;
331
332         proto_tree_add_item(v150fw_tree, hf_v150fw_event_id, tvb, offset, 1, ENC_BIG_ENDIAN);
333         proto_tree_add_item(v150fw_tree, hf_v150fw_force_response_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
334         proto_tree_add_item(v150fw_tree, hf_v150fw_extension_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
335         offset++;
336
337         proto_tree_add_item(v150fw_tree, hf_v150fw_reason_id_code, tvb, offset, 1, ENC_BIG_ENDIAN);
338         offset++;
339
340         /* reason identifier code information */
341         switch(ric)
342         {
343         case V150FW_RIC_CM:
344         case V150FW_RIC_JM:
345             ti = proto_tree_add_item(v150fw_tree, hf_v150fw_ric_info_mod_avail, tvb, offset, 2, ENC_BIG_ENDIAN);
346             field_tree = proto_item_add_subtree(ti, ett_available_modulations);
347             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_pcm_mode,           tvb, offset, 2, ENC_BIG_ENDIAN);
348             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v34_duplex,         tvb, offset, 2, ENC_BIG_ENDIAN);
349             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v34_half_duplex,    tvb, offset, 2, ENC_BIG_ENDIAN);
350             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v32_v32bis,         tvb, offset, 2, ENC_BIG_ENDIAN);
351             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v22_v22bis,         tvb, offset, 2, ENC_BIG_ENDIAN);
352             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v17,                tvb, offset, 2, ENC_BIG_ENDIAN);
353             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v29_half_duplex,    tvb, offset, 2, ENC_BIG_ENDIAN);
354             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v27ter,             tvb, offset, 2, ENC_BIG_ENDIAN);
355             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v26ter,             tvb, offset, 2, ENC_BIG_ENDIAN);
356             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v26bis,             tvb, offset, 2, ENC_BIG_ENDIAN);
357             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v23_duplex,         tvb, offset, 2, ENC_BIG_ENDIAN);
358             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v23_half_duplex,    tvb, offset, 2, ENC_BIG_ENDIAN);
359             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v21,                tvb, offset, 2, ENC_BIG_ENDIAN);
360             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v90_or_v92_analog,  tvb, offset, 2, ENC_BIG_ENDIAN);
361             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v90_or_v92_digital, tvb, offset, 2, ENC_BIG_ENDIAN);
362             proto_tree_add_item(field_tree, hf_v150fw_cm_jm_mod_avail_v91,                tvb, offset, 2, ENC_BIG_ENDIAN);
363             break;
364         case V150FW_RIC_TIMEOUT:
365             proto_tree_add_item(v150fw_tree, hf_v150fw_ric_info_timeout,                  tvb, offset,     1, ENC_BIG_ENDIAN);
366             proto_tree_add_item(v150fw_tree, hf_v150fw_ric_info_timeout_vendor,           tvb, offset + 1, 1, ENC_BIG_ENDIAN);
367             break;
368         case V150FW_RIC_CLEARDOWN:
369             proto_tree_add_item(v150fw_tree, hf_v150fw_ric_info_cleardown,                tvb, offset,     1, ENC_BIG_ENDIAN);
370             proto_tree_add_item(v150fw_tree, hf_v150fw_ric_info_cleardown_reserved,       tvb, offset + 1, 1, ENC_BIG_ENDIAN);
371             break;
372         default:
373             proto_tree_add_item(v150fw_tree, hf_v150fw_reason_id_code_info,               tvb, offset,     2, ENC_BIG_ENDIAN);
374             break;
375         } /* switch(ric) */
376         offset += 2;
377
378         if(extb && payload_length >= 6) /* display optional extension fields */
379         {
380             proto_tree_add_item(v150fw_tree, hf_v150fw_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
381             if(ext_len != (payload_length - 6))
382             {
383                 /* TODO - ext field len doesn't match actual len... that isn't illegal, but is perhaps worth noting */
384                 proto_tree_add_item(v150fw_tree, hf_v150fw_extension_len, tvb, offset, 2, ENC_BIG_ENDIAN);
385             } else {
386                 proto_tree_add_item(v150fw_tree, hf_v150fw_extension_len, tvb, offset, 2, ENC_BIG_ENDIAN);
387             }
388             offset += 2;
389
390             /* display optional extension fields */
391             switch(ric) {
392             case V150FW_RIC_CLEARDOWN: /* show vendor tag & vendor-specific info */
393                 proto_tree_add_item(v150fw_tree, hf_v150fw_ric_info_cleardown_vendor_tag,  tvb, offset, 1, ENC_BIG_ENDIAN);
394                 proto_tree_add_item(v150fw_tree, hf_v150fw_ric_info_cleardown_vendor_info, tvb, offset+1, 1, ENC_BIG_ENDIAN);
395                 break;
396             default:
397                 /* just dump the bytes for now */
398                 proto_tree_add_item(v150fw_tree, hf_v150fw_remainder, tvb, offset, (payload_length - 6), ENC_NA);
399                 break;
400             }
401         }
402     }
403
404     return tvb_length(tvb);
405 }
406
407 void
408 proto_register_v150fw(void)
409 {
410     /* set up header fields */
411     static hf_register_info hf[] =
412     {
413         {
414             &hf_v150fw_event_id,
415             {
416                 "Event ID",
417                 "v150fw.event",
418                 FT_UINT8,
419                 BASE_DEC | BASE_RANGE_STRING,
420                 RVALS(v150fw_event_id_name),
421                 0xFC,
422                 NULL, HFILL
423             }
424         },
425         {
426             &hf_v150fw_force_response_bit,
427             {
428                 "Force response",
429                 "v150fw.frb",
430                 FT_BOOLEAN,
431                 8,
432                 TFS(&tfs_yes_no),
433                 0x02,
434                 NULL, HFILL
435             }
436         },
437         {
438             &hf_v150fw_extension_bit,
439             {
440                 "Payload extension",
441                 "v150fw.extb",
442                 FT_BOOLEAN,
443                 8,
444                 TFS(&tfs_present_absent),
445                 0x01,
446                 NULL, HFILL
447             }
448         },
449         {
450             &hf_v150fw_reason_id_code, /* ric value + string */
451             {
452                 "Reason ID",
453                 "v150fw.ric",
454                 FT_UINT8,
455                 BASE_DEC | BASE_RANGE_STRING,
456                 RVALS(v150fw_ric_name),
457                 0xFF,
458                 NULL, HFILL
459             }
460         },
461         {
462             &hf_v150fw_reason_id_code_info,
463             {
464                 "Info",
465                 "v150fw.ricinfo",
466                 FT_UINT16,
467                 BASE_HEX,
468                 NULL,
469                 0xFFFF,
470                 NULL, HFILL
471             }
472         },
473         {
474             &hf_v150fw_ric_info_timeout,
475             {
476                 "Timeout type",
477                 "v150fw.ricinfo.timeout",
478                 FT_UINT16,
479                 BASE_HEX,
480                 VALS(v150fw_ric_info_timeout_type),
481                 0xFF00,
482                 NULL, HFILL
483             }
484         },
485         {
486             &hf_v150fw_ric_info_timeout_vendor,
487             {
488                 "Vendor-specific timeout info",
489                 "v150fw.ricinfo.timeout_vendor",
490                 FT_UINT16,
491                 BASE_HEX,
492                 NULL,
493                 0x00FF,
494                 NULL, HFILL
495             }
496         },
497         {
498             &hf_v150fw_ric_info_cleardown,
499             {
500                 "Cleardown type",
501                 "v150fw.ricinfo.cleardown",
502                 FT_UINT16,
503                 BASE_HEX,
504                 VALS(v150fw_ric_info_cleardown_type),
505                 0xFF00,
506                 NULL, HFILL
507             }
508         },
509         {
510             &hf_v150fw_ric_info_cleardown_reserved,
511             {
512                 "Reserved for use by the ITU-T",
513                 "v150fw.ricinfo.cleardown_reserved",
514                 FT_UINT16,
515                 BASE_HEX,
516                 NULL,
517                 0x00FF,
518                 NULL, HFILL
519             }
520         },
521         {
522             &hf_v150fw_ric_info_cleardown_vendor_tag,
523             {
524                 "Vendor tag",
525                 "v150fw.cleardown_vendor_tag",
526                 FT_UINT8,
527                 BASE_HEX,
528                 NULL,
529                 0xFF,
530                 NULL, HFILL
531             }
532         },
533         {
534             &hf_v150fw_ric_info_cleardown_vendor_info,
535             {
536                 "Vendor-specific info",
537                 "v150fw.cleardown_vendor_info",
538                 FT_UINT8,
539                 BASE_HEX,
540                 NULL,
541                 0xFF,
542                 NULL, HFILL
543             }
544         },
545         {
546             &hf_v150fw_ric_info_mod_avail,
547             {
548                 "Modulation availability",
549                 "v150fw.rinfo.mod_avail",
550                 FT_UINT16,
551                 BASE_HEX,
552                 NULL,
553                 0xFFFF,
554                 NULL, HFILL
555             }
556         },
557         {
558             &hf_v150fw_cm_jm_mod_avail_pcm_mode,
559             {
560                 "PCM mode",
561                 "v150fw.rinfo.mod_avail.pcm_mode",
562                 FT_BOOLEAN,
563                 16,
564                 TFS(&tfs_available_not_available),
565                 0x8000,
566                 NULL, HFILL
567             }
568         },
569         {
570             &hf_v150fw_cm_jm_mod_avail_v34_duplex,
571             {
572                 "V.34 duplex",
573                 "v150fw.rinfo.mod_avail.v34_duplex",
574                 FT_BOOLEAN,
575                 16,
576                 TFS(&tfs_available_not_available),
577                 0x4000,
578                 NULL, HFILL
579             }
580         },
581         {
582             &hf_v150fw_cm_jm_mod_avail_v34_half_duplex,
583             {
584                 "V.34 half-duplex",
585                 "v150fw.rinfo.mod_avail.v34_half_duplex",
586                 FT_BOOLEAN,
587                 16,
588                 TFS(&tfs_available_not_available),
589                 0x2000,
590                 NULL, HFILL
591             }
592         },
593         {
594             &hf_v150fw_cm_jm_mod_avail_v32_v32bis,
595             {
596                 "V.32/V.32bis",
597                 "v150fw.rinfo.mod_avail.v32_v32bis",
598                 FT_BOOLEAN,
599                 16,
600                 TFS(&tfs_available_not_available),
601                 0x1000,
602                 NULL, HFILL
603             }
604         },
605         {
606             &hf_v150fw_cm_jm_mod_avail_v22_v22bis,
607             {
608                 "V.22/V.22bis",
609                 "v150fw.rinfo.mod_avail.v22_v22bis",
610                 FT_BOOLEAN,
611                 16,
612                 TFS(&tfs_available_not_available),
613                 0x0800,
614                 NULL, HFILL
615             }
616         },
617         {
618             &hf_v150fw_cm_jm_mod_avail_v17,
619             {
620                 "V.17",
621                 "v150fw.rinfo.mod_avail.v17",
622                 FT_BOOLEAN,
623                 16,
624                 TFS(&tfs_available_not_available),
625                 0x0400,
626                 NULL, HFILL
627             }
628         },
629         {
630             &hf_v150fw_cm_jm_mod_avail_v29_half_duplex,
631             {
632                 "V.29 half-duplex",
633                 "v150fw.rinfo.mod_avail.v29_half_duplex",
634                 FT_BOOLEAN,
635                 16,
636                 TFS(&tfs_available_not_available),
637                 0x0200,
638                 NULL, HFILL
639             }
640         },
641         {
642             &hf_v150fw_cm_jm_mod_avail_v27ter,
643             {
644                 "V.27ter",
645                 "v150fw.rinfo.mod_avail.v27ter",
646                 FT_BOOLEAN,
647                 16,
648                 TFS(&tfs_available_not_available),
649                 0x0100,
650                 NULL, HFILL
651             }
652         },
653         {
654             &hf_v150fw_cm_jm_mod_avail_v26ter,
655             {
656                 "V.26ter",
657                 "v150fw.rinfo.mod_avail.v26ter",
658                 FT_BOOLEAN,
659                 16,
660                 TFS(&tfs_available_not_available),
661                 0x0080,
662                 NULL, HFILL
663             }
664         },
665         {
666             &hf_v150fw_cm_jm_mod_avail_v26bis,
667             {
668                 "V.26bis",
669                 "v150fw.rinfo.mod_avail.v26bis",
670                 FT_BOOLEAN,
671                 16,
672                 TFS(&tfs_available_not_available),
673                 0x0040,
674                 NULL, HFILL
675             }
676         },
677         {
678             &hf_v150fw_cm_jm_mod_avail_v23_duplex,
679             {
680                 "V.23 duplex",
681                 "v150fw.rinfo.mod_avail.v23_duplex",
682                 FT_BOOLEAN,
683                 16,
684                 TFS(&tfs_available_not_available),
685                 0x0020,
686                 NULL, HFILL
687             }
688         },
689         {
690             &hf_v150fw_cm_jm_mod_avail_v23_half_duplex,
691             {
692                 "V.23 half-duplex",
693                 "v150fw.rinfo.mod_avail.half_duplex",
694                 FT_BOOLEAN,
695                 16,
696                 TFS(&tfs_available_not_available),
697                 0x0010,
698                 NULL, HFILL
699             }
700         },
701         {
702             &hf_v150fw_cm_jm_mod_avail_v21,
703             {
704                 "V.21",
705                 "v150fw.rinfo.mod_avail.v21",
706                 FT_BOOLEAN,
707                 16,
708                 TFS(&tfs_available_not_available),
709                 0x0008,
710                 NULL, HFILL
711             }
712         },
713         {
714             &hf_v150fw_cm_jm_mod_avail_v90_or_v92_analog,
715             {
716                 "V.90 or V.92 analog",
717                 "v150fw.rinfo.mod_avail.v90_or_v92_analog",
718                 FT_BOOLEAN,
719                 16,
720                 TFS(&tfs_available_not_available),
721                 0x0004,
722                 NULL, HFILL
723             }
724         },
725         {
726             &hf_v150fw_cm_jm_mod_avail_v90_or_v92_digital,
727             {
728                 "V.90 or V.92 digital",
729                 "v150fw.rinfo.mod_avail.v90_or_v92_digital",
730                 FT_BOOLEAN,
731                 16,
732                 TFS(&tfs_available_not_available),
733                 0x0002,
734                 NULL, HFILL
735             }
736         },
737         {
738             &hf_v150fw_cm_jm_mod_avail_v91,
739             {
740                 "V.91",
741                 "v150fw.rinfo.mod_avail.v91",
742                 FT_BOOLEAN,
743                 16,
744                 TFS(&tfs_available_not_available),
745                 0x0001,
746                 NULL, HFILL
747             }
748         },
749         {
750             &hf_v150fw_reserved,
751             {
752                 "Reserved",
753                 "v150fw.reserved",
754                 FT_UINT16,
755                 BASE_HEX,
756                 NULL,
757                 0xF800,
758                 NULL, HFILL
759             }
760         },
761         {
762             &hf_v150fw_extension_len,
763             {
764                 "Extension field length",
765                 "v150fw.eflen",
766                 FT_UINT16,
767                 BASE_DEC,
768                 NULL,
769                 0x07FF,
770                 NULL, HFILL
771             }
772         },
773         /* dump remaining bytes: */
774         {
775             &hf_v150fw_remainder,
776             {
777                 "Remaining bytes",
778                 "v150fw.remainder",
779                 FT_BYTES,
780                 BASE_NONE,
781                 NULL,
782                 0x0,
783                 NULL, HFILL
784             }
785         }
786     }; /* hf_register_info hf[] */
787
788     /* setup protocol subtree array */
789     static gint *ett[] = {
790         &ett_v150fw,
791         &ett_available_modulations
792     };
793
794     /* register protocol name & description */
795     proto_v150fw = proto_register_protocol("v150fw State Signaling Event", "v150fw", "v150fw");
796
797     /* required function calls to register the header fields and subtrees used */
798     proto_register_field_array(proto_v150fw, hf, array_length(hf));
799     proto_register_subtree_array(ett, array_length(ett));
800
801     /* register the dissector */
802     new_register_dissector("v150fw", dissect_v150fw, proto_v150fw);
803 }
804