c25081c26a706351df5904cd452529bbc8e9319c
[gd/wireshark/.git] / epan / dissectors / packet-sprt.c
1 /* packet-sprt.h
2  *
3  * Routines for SPRT dissection
4  * SPRT = Simple Packet Relay Transport
5  *
6  * Written by Jamison Adcock <jamison.adcock@cobham.com>
7  * for Sparta Inc., dba Cobham Analytic Solutions
8  * This code is largely based on the RTP parsing code
9  *
10  * Wireshark - Network traffic analyzer
11  * By Gerald Combs <gerald@wireshark.org>
12  * Copyright 1998 Gerald Combs
13  *
14  * SPDX-License-Identifier: GPL-2.0-or-later
15  */
16
17 /* TODO:
18  *    - work on conversations
19  *
20  */
21
22 #include "config.h"
23
24 #include <epan/packet.h>
25 #include <epan/prefs.h>
26 #include <epan/conversation.h>
27 #include <epan/expert.h>
28 #include "packet-sprt.h"
29
30 void proto_register_sprt(void);
31 void proto_reg_handoff_sprt(void);
32
33 /* for some "range_string"s, there's only one value in the range  */
34 #define SPRT_VALUE_RANGE(a) a,a
35
36 /* TODO - conversation states */
37 #define SPRT_STATE_XXX_TODO 0
38
39 #define SPRT_CONV_MAX_SETUP_METHOD_SIZE 12
40
41 /* is DLCI field present in I_OCTET message?  See "DLCI enabled" in CONNECT message */
42 typedef enum {
43     DLCI_UNKNOWN,
44     DLCI_PRESENT,
45     DLCI_ABSENT
46 } i_octet_dlci_status_t;
47
48
49 /* Keep conversation info for one side of an SPRT conversation
50  * TODO - this needs to be bidirectional
51  */
52 struct _sprt_conversation_info
53 {
54     gchar    method[SPRT_CONV_MAX_SETUP_METHOD_SIZE + 1];
55     gboolean stream_started;
56     guint32  frame_number;         /* the frame where this conversation is started */
57
58     /* sequence numbers for each channel: */
59     guint32 seqnum[4];
60
61     /* are we using the DLCI field in I_OCTET messages?  See CONNECT message ("DLCI enabled") */
62     i_octet_dlci_status_t i_octet_dlci_status;
63     guint32 connect_frame_number; /* the CONNECT frame that tells us if the DLCI is enabled */
64
65     /* TODO - maintain state */
66
67 };
68
69 /* SPRT Message IDs: */
70 #define SPRT_MODEM_RELAY_MSG_ID_NULL              0
71 #define SPRT_MODEM_RELAY_MSG_ID_INIT              1
72 #define SPRT_MODEM_RELAY_MSG_ID_XID_XCHG          2
73 #define SPRT_MODEM_RELAY_MSG_ID_JM_INFO           3
74 #define SPRT_MODEM_RELAY_MSG_ID_START_JM          4
75 #define SPRT_MODEM_RELAY_MSG_ID_CONNECT           5
76 #define SPRT_MODEM_RELAY_MSG_ID_BREAK             6
77 #define SPRT_MODEM_RELAY_MSG_ID_BREAK_ACK         7
78 #define SPRT_MODEM_RELAY_MSG_ID_MR_EVENT          8
79 #define SPRT_MODEM_RELAY_MSG_ID_CLEARDOWN         9
80 #define SPRT_MODEM_RELAY_MSG_ID_PROF_XCHG        10
81 /* 11 -15 Reserved */
82 #define SPRT_MODEM_RELAY_MSG_ID_RESERVED1_START  11
83 #define SPRT_MODEM_RELAY_MSG_ID_RESERVED1_END    15
84 /* Data */
85 #define SPRT_MODEM_RELAY_MSG_ID_I_RAW_OCTET      16
86 #define SPRT_MODEM_RELAY_MSG_ID_I_RAW_BIT        17
87 #define SPRT_MODEM_RELAY_MSG_ID_I_OCTET          18
88 #define SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT      19
89 #define SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN       20
90 #define SPRT_MODEM_RELAY_MSG_ID_I_FRAME          21
91 #define SPRT_MODEM_RELAY_MSG_ID_I_OCTET_CS       22
92 #define SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT_CS   23
93 #define SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN_CS    24
94 /* 25 - 99 Reserved */
95 #define SPRT_MODEM_RELAY_MSG_ID_RESERVED2_START  25
96 #define SPRT_MODEM_RELAY_MSG_ID_RESERVED2_END    99
97 /* 100 - 127 Vendor-specific */
98 #define SPRT_MODEM_RELAY_MSG_ID_VENDOR_START    100
99 #define SPRT_MODEM_RELAY_MSG_ID_VENDOR_END      127
100
101
102 /* error correcting protocol in XID_XCHG message: */
103 #define SPRT_ECP_NO_LINK_LAYER_PROTO     0
104 #define SPRT_ECP_V42_LAPM                1
105 #define SPRT_ECP_ANNEX_AV42_1996         2
106 /* 3 - 25 Reserved for ITU-T */
107 #define SPRT_ECP_RESERVED_START          3
108 #define SPRT_ECP_RESERVED_END           25
109
110
111 /* category ID used in JM_INFO message: */
112 #define SPRT_JM_INFO_CAT_ID_CALL_FUNCT          0x8
113 #define SPRT_JM_INFO_CAT_ID_MOD_MODES           0xA
114 #define SPRT_JM_INFO_CAT_ID_PROTOCOLS           0x5
115 #define SPRT_JM_INFO_CAT_ID_PSTN_ACCESS         0xB
116 #define SPRT_JM_INFO_CAT_ID_PCM_MODEM_AVAIL     0xE
117 #define SPRT_JM_INFO_CAT_ID_CATEGORY_EXTENSION  0x0
118
119
120 #define SPRT_JMINFO_TBC_CALL_FUNCT_PSTN_MULTIMEDIA_TERM     0x4
121 #define SPRT_JMINFO_TBC_CALL_FUNCT_TEXTPHONE_ITU_T_REC_V18  0x2
122 #define SPRT_JMINFO_TBC_CALL_FUNCT_VIDEOTEXT_ITU_T_REC_T101 0x6
123 #define SPRT_JMINFO_TBC_CALL_FUNCT_TRANS_FAX_ITU_T_REC_T30  0x1
124 #define SPRT_JMINFO_TBC_CALL_FUNCT_RECV_FAX_ITU_T_REC_T30   0x5
125 #define SPRT_JMINFO_TBC_CALL_FUNCT_DATA_V_SERIES_MODEM_REC  0x3
126
127
128 #define SPRT_JMINFO_TBC_PROTOCOL_LAPM_ITU_T_REC_V42     0x4
129
130
131 /* selected modulations in CONNECT message: */
132 #define SPRT_SELMOD_NULL             0
133 #define SPRT_SELMOD_V92              1
134 #define SPRT_SELMOD_V91              2
135 #define SPRT_SELMOD_V90              3
136 #define SPRT_SELMOD_V34              4
137 #define SPRT_SELMOD_V32_BIS          5
138 #define SPRT_SELMOD_V32              6
139 #define SPRT_SELMOD_V22_BIS          7
140 #define SPRT_SELMOD_V22              8
141 #define SPRT_SELMOD_V17              9
142 #define SPRT_SELMOD_V29             10
143 #define SPRT_SELMOD_V27_TER         11
144 #define SPRT_SELMOD_V26_TER         12
145 #define SPRT_SELMOD_V26_BIS         13
146 #define SPRT_SELMOD_V23             14
147 #define SPRT_SELMOD_V21             15
148 #define SPRT_SELMOD_BELL_212        16
149 #define SPRT_SELMOD_BELL_103        17
150 /* 18 - 30 Vendor-specific modulations */
151 #define SPRT_SELMOD_VENDOR_START    18
152 #define SPRT_SELMOD_VENDOR_END      30
153 /* 31 - 63 Reserved for ITU-T */
154 #define SPRT_SELMOD_RESERVED_START  31
155 #define SPRT_SELMOD_RESERVED_END    63
156
157
158 /* Compression direction in CONNECT message: */
159 #define SPRT_COMPR_DIR_NO_COMPRESSION   0
160 #define SPRT_COMPR_DIR_TRANSMIT         1
161 #define SPRT_COMPR_DIR_RECEIVE          2
162 #define SPRT_COMPR_DIR_BIDIRECTIONAL    3
163
164
165 /* Selected compression modes in CONNECT message: */
166 #define SPRT_SELECTED_COMPR_NONE             0
167 #define SPRT_SELECTED_COMPR_V42_BIS          1
168 #define SPRT_SELECTED_COMPR_V44              2
169 #define SPRT_SELECTED_COMPR_MNP5             3
170 /* 4 - 15 Reserved by ITU-T */
171 #define SPRT_SELECTED_COMPR_RESERVED_START   4
172 #define SPRT_SELECTED_COMPR_RESERVED_END    15
173
174
175 /* Selected error correction modes in CONNECT message: */
176 #define SPRT_SELECTED_ERR_CORR_V14_OR_NONE       0
177 #define SPRT_SELECTED_ERR_CORR_V42_LAPM          1
178 #define SPRT_SELECTED_ERR_CORR_ANNEX_AV42        2
179 /* 3 - 15 Reserved for ITU-T */
180 #define SPRT_SELECTED_ERR_CORR_RESERVED_START    3
181 #define SPRT_SELECTED_ERR_CORR_RESERVED_END     15
182
183
184 /* Break source protocol in BREAK message: */
185 #define SPRT_BREAK_SRC_PROTO_V42_LAPM            0
186 #define SPRT_BREAK_SRC_PROTO_ANNEX_AV42_1996     1
187 #define SPRT_BREAK_SRC_PROTO_V14                 2
188 /* 3 - 15 Reserved for ITU-T */
189 #define SPRT_BREAK_SRC_PROTO_RESERVED_START      3
190 #define SPRT_BREAK_SRC_PROTO_RESERVED_END       15
191
192
193 #define SPRT_BREAK_TYPE_NOT_APPLICABLE                   0
194 #define SPRT_BREAK_TYPE_DESTRUCTIVE_AND_EXPEDITED        1
195 #define SPRT_BREAK_TYPE_NONDESTRUCTIVE_AND_EXPEDITED     2
196 #define SPRT_BREAK_TYPE_NONDESTRUCTIVE_AND_NONEXPEDITED  3
197 /* 4 - 15 Reserved for ITU-T */
198 #define SPRT_BREAK_TYPE_RESERVED_START                   4
199 #define SPRT_BREAK_TYPE_RESERVED_END                    15
200
201
202 /* Modem relay info in MR_EVENT messages: */
203 #define SPRT_MREVT_EVENT_ID_NULL                  0
204 #define SPRT_MREVT_EVENT_ID_RATE_RENEGOTIATION    1
205 #define SPRT_MREVT_EVENT_ID_RETRAIN               2
206 #define SPRT_MREVT_EVENT_ID_PHYSUP                3
207 /* 4 - 255 Reserved for ITU-T */
208 #define SPRT_MREVT_EVENT_ID_RESERVED_START        4
209 #define SPRT_MREVT_EVENT_ID_RESERVED_END        255
210
211
212 #define SPRT_MREVT_REASON_CODE_NULL               0
213 #define SPRT_MREVT_REASON_CODE_INIT               1
214 #define SPRT_MREVT_REASON_CODE_RESPONDING         2
215 /* 3 - 255 Undefined */
216 #define SPRT_MREVT_REASON_CODE_RESERVED_START     3
217 #define SPRT_MREVT_REASON_CODE_RESERVED_END     255
218
219
220 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_NULL                0
221 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_600                 1
222 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_1200                2
223 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_1600                3
224 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_2400                4
225 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_2743                5
226 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3000                6
227 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3200                7
228 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3429                8
229 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_8000                9
230 /* 10 - 254 Reserved for ITU-T */
231 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_RESERVED_START     10
232 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_RESERVED_END      254
233 #define SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_UNSPECIFIED       255
234
235
236 /* Cleardown reason codes: */
237 #define SPRT_CLEARDOWN_RIC_UNKNOWN                     0
238 #define SPRT_CLEARDOWN_RIC_PHYSICAL_LAYER_RELEASE      1
239 #define SPRT_CLEARDOWN_RIC_LINK_LAYER_DISCONNECT       2
240 #define SPRT_CLEARDOWN_RIC_DATA_COMPRESSION_DISCONNECT 3
241 #define SPRT_CLEARDOWN_RIC_ABORT                       4
242 #define SPRT_CLEARDOWN_RIC_ON_HOOK                     5
243 #define SPRT_CLEARDOWN_RIC_NETWORK_LAYER_TERMINATION   6
244 #define SPRT_CLEARDOWN_RIC_ADMINISTRATIVE              7
245
246
247 /* PROF_XCHG messages (XID profile exchange for MR1): */
248 #define SPRT_PROF_XCHG_SUPPORT_NO       0
249 #define SPRT_PROF_XCHG_SUPPORT_YES      1
250 #define SPRT_PROF_XCHG_SUPPORT_UNKNOWN  2
251
252
253 /* DLCI field in I_OCTET: */
254 #define SPRT_PAYLOAD_DLCI1_DTE2DTE                0
255 #define SPRT_PAYLOAD_DLCI1_RESERVED_START         1
256 #define SPRT_PAYLOAD_DLCI1_RESERVED_END          31
257 #define SPRT_PAYLOAD_DLCI1_NOT_RESERVED_START    32
258 #define SPRT_PAYLOAD_DLCI1_NOT_RESERVED_END      62
259 #define SPRT_PAYLOAD_DLCI1_CTRLFN2CTRLFN         63
260
261 #define SPRT_PAYLOAD_DLCI2_START                  0
262 #define SPRT_PAYLOAD_DLCI2_END                  127
263
264 /* Payload fields for I_CHAR_STAT_CS, etc.: */
265 /* # of data bits */
266 #define SPRT_PAYLOAD_D_0        0
267 #define SPRT_PAYLOAD_D_1        1
268 #define SPRT_PAYLOAD_D_2        2
269 #define SPRT_PAYLOAD_D_3        3
270
271
272 /* parity */
273 #define SPRT_PAYLOAD_P_0    0
274 #define SPRT_PAYLOAD_P_1    1
275 #define SPRT_PAYLOAD_P_2    2
276 #define SPRT_PAYLOAD_P_3    3
277 #define SPRT_PAYLOAD_P_4    4
278 #define SPRT_PAYLOAD_P_5    5
279 #define SPRT_PAYLOAD_P_6    6
280 #define SPRT_PAYLOAD_P_7    7
281
282
283 /* # of stop bits */
284 #define SPRT_PAYLOAD_S_0    0
285 #define SPRT_PAYLOAD_S_1    1
286 #define SPRT_PAYLOAD_S_2    2
287 #define SPRT_PAYLOAD_S_3    3
288
289
290 /* data frame state */
291 #define SPRT_PAYLOAD_FR_0   0
292 #define SPRT_PAYLOAD_FR_1   1
293 #define SPRT_PAYLOAD_FR_2   2
294 #define SPRT_PAYLOAD_FR_3   3
295
296
297 /* Initialize the protocol & registered fields */
298 static int proto_sprt =                         -1;
299
300 static int hf_sprt_setup =                      -1;
301 static int hf_sprt_setup_frame =                -1;
302 static int hf_sprt_setup_method =               -1;
303
304 static int hf_sprt_header_extension_bit =       -1;
305 static int hf_sprt_subsession_id =              -1;
306 static int hf_sprt_reserved_bit =               -1;
307 static int hf_sprt_payload_type =               -1;
308 static int hf_sprt_transport_channel_id =       -1;
309 static int hf_sprt_sequence_number =            -1;
310 static int hf_sprt_number_of_ack_fields =       -1;
311 static int hf_sprt_base_sequence_number =       -1;
312 static int hf_sprt_ack_field_items =            -1;
313 static int hf_sprt_transport_channel_item =     -1;
314 static int hf_sprt_sequence_item =              -1;
315
316 static int hf_sprt_payload_length =             -1;
317 static int hf_sprt_payload_no_data =            -1;
318 static int hf_sprt_payload_reserved_bit =       -1;
319 static int hf_sprt_payload_message_id =         -1;
320
321 static int hf_sprt_payload_data =               -1; /* stuff after msgid */
322 /* INIT msg: */
323 static int hf_sprt_payload_msg_init_all_fields =                    -1;
324 static int hf_sprt_payload_msg_init_necrxch =                       -1;
325 static int hf_sprt_payload_msg_init_ecrxch =                        -1;
326 static int hf_sprt_payload_msg_init_xid_prof_exch =                 -1;
327 static int hf_sprt_payload_msg_init_assym_data_types =              -1;
328 static int hf_sprt_payload_msg_init_opt_moip_types_i_raw_bit =      -1;
329 static int hf_sprt_payload_msg_init_opt_moip_types_i_frame =        -1;
330 static int hf_sprt_payload_msg_init_opt_moip_types_i_char_stat =    -1;
331 static int hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn =     -1;
332 static int hf_sprt_payload_msg_init_opt_moip_types_i_octet_cs =     -1;
333 static int hf_sprt_payload_msg_init_opt_moip_types_i_char_stat_cs = -1;
334 static int hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn_cs =  -1;
335 static int hf_sprt_payload_msg_init_opt_moip_types_reserved =       -1;
336 /* XID_XCHG message: */
337 static int hf_sprt_payload_msg_xidxchg_ecp =                                    -1;
338 static int hf_sprt_payload_msg_xidxchg_xidlr1_v42bis =                          -1;
339 static int hf_sprt_payload_msg_xidxchg_xidlr1_v44 =                             -1;
340 static int hf_sprt_payload_msg_xidxchg_xidlr1_mnp5 =                            -1;
341 static int hf_sprt_payload_msg_xidxchg_xidlr1_reserved =                        -1;
342 static int hf_sprt_payload_msg_xidxchg_xidlr2_v42bis_compr_req =                -1;
343 static int hf_sprt_payload_msg_xidxchg_xidlr3and4_v42bis_num_codewords =        -1;
344 static int hf_sprt_payload_msg_xidxchg_xidlr5_v42bis_max_strlen =               -1;
345 static int hf_sprt_payload_msg_xidxchg_xidlr6_v44_capability =                  -1;
346 static int hf_sprt_payload_msg_xidxchg_xidlr7_v44_compr_req =                   -1;
347 static int hf_sprt_payload_msg_xidxchg_xidlr8and9_v44_num_codewords_trans =     -1;
348 static int hf_sprt_payload_msg_xidxchg_xidlr10and11_v44_num_codewords_recv =    -1;
349 static int hf_sprt_payload_msg_xidxchg_xidlr12_v44_max_strlen_trans =           -1;
350 static int hf_sprt_payload_msg_xidxchg_xidlr13_v44_max_strlen_recv =            -1;
351 static int hf_sprt_payload_msg_xidxchg_xidlr14and15_v44_history_len_trans =     -1;
352 static int hf_sprt_payload_msg_xidxchg_xidlr16and17_v44_history_len_recv =      -1;
353 /* V.8 JM_INFO msg: */
354 static int hf_sprt_payload_msg_jminfo_category_data =           -1;
355 static int hf_sprt_payload_msg_jminfo_category_id =             -1;
356 static int hf_sprt_payload_msg_jminfo_category_ext_info =       -1;
357 static int hf_sprt_payload_msg_jminfo_unk_category_info =       -1;
358 static int hf_sprt_payload_msg_jminfo_category_leftover_bits =  -1;
359 static int hf_sprt_payload_msg_jminfo_call_function =           -1;
360 static int hf_sprt_payload_msg_jminfo_mod_v34_duplex =          -1;
361 static int hf_sprt_payload_msg_jminfo_mod_v34_half_duplex =     -1;
362 static int hf_sprt_payload_msg_jminfo_mod_v32bis_v32 =          -1;
363 static int hf_sprt_payload_msg_jminfo_mod_v22bis_v22 =          -1;
364 static int hf_sprt_payload_msg_jminfo_mod_v17 =                 -1;
365 static int hf_sprt_payload_msg_jminfo_mod_v29_half_duplex =     -1;
366 static int hf_sprt_payload_msg_jminfo_mod_v27ter =              -1;
367 static int hf_sprt_payload_msg_jminfo_mod_v26ter =              -1;
368 static int hf_sprt_payload_msg_jminfo_mod_v26bis =              -1;
369 static int hf_sprt_payload_msg_jminfo_mod_v23_duplex =          -1;
370 static int hf_sprt_payload_msg_jminfo_mod_v23_half_duplex =     -1;
371 static int hf_sprt_payload_msg_jminfo_mod_v21 =                 -1;
372 static int hf_sprt_payload_msg_jminfo_protocols =               -1;
373 static int hf_sprt_payload_msg_jminfo_pstn_access_call_dce_cell =       -1;
374 static int hf_sprt_payload_msg_jminfo_pstn_access_answ_dce_cell =       -1;
375 static int hf_sprt_payload_msg_jminfo_pstn_access_dce_on_digital_net =  -1;
376 static int hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_analog =  -1;
377 static int hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_digital = -1;
378 static int hf_sprt_payload_msg_jminfo_pcm_modem_avail_v91 =             -1;
379 /* CONNECT msg: */
380 static int hf_sprt_payload_msg_connect_selmod =                         -1;
381 static int hf_sprt_payload_msg_connect_compr_dir =                      -1;
382 static int hf_sprt_payload_msg_connect_selected_compr =                 -1;
383 static int hf_sprt_payload_msg_connect_selected_err_corr =              -1;
384 static int hf_sprt_payload_msg_connect_tdsr =                           -1;
385 static int hf_sprt_payload_msg_connect_rdsr =                           -1;
386 static int hf_sprt_payload_msg_connect_dlci_enabled =                   -1;
387 static int hf_sprt_payload_msg_connect_avail_data_types =               -1;
388 static int hf_sprt_payload_msg_connect_adt_octet_no_format_no_dlci =    -1;
389 static int hf_sprt_payload_msg_connect_adt_i_raw_bit =                  -1;
390 static int hf_sprt_payload_msg_connect_adt_i_frame =                    -1;
391 static int hf_sprt_payload_msg_connect_adt_i_char_stat =                -1;
392 static int hf_sprt_payload_msg_connect_adt_i_char_dyn =                 -1;
393 static int hf_sprt_payload_msg_connect_adt_i_octet_cs =                 -1;
394 static int hf_sprt_payload_msg_connect_adt_i_char_stat_cs =             -1;
395 static int hf_sprt_payload_msg_connect_adt_i_char_dyn_cs =              -1;
396 static int hf_sprt_payload_msg_connect_adt_reserved =                   -1;
397 static int hf_sprt_payload_msg_connect_compr_trans_dict_sz =            -1;
398 static int hf_sprt_payload_msg_connect_compr_recv_dict_sz =             -1;
399 static int hf_sprt_payload_msg_connect_compr_trans_str_len =            -1;
400 static int hf_sprt_payload_msg_connect_compr_recv_str_len =             -1;
401 static int hf_sprt_payload_msg_connect_compr_trans_hist_sz =            -1;
402 static int hf_sprt_payload_msg_connect_compr_recv_hist_sz =             -1;
403 /* BREAK msg: */
404 static int hf_sprt_payload_msg_break_source_proto =     -1;
405 static int hf_sprt_payload_msg_break_type =             -1;
406 static int hf_sprt_payload_msg_break_length =           -1;
407 /* MR_EVENT msg: */
408 static int hf_sprt_payload_msg_mr_event_id =            -1;
409 static int hf_sprt_payload_msg_mr_evt_reason_code =     -1;
410 static int hf_sprt_payload_msg_mr_evt_selmod =          -1;
411 static int hf_sprt_payload_msg_mr_evt_txsen =           -1;
412 static int hf_sprt_payload_msg_mr_evt_rxsen =           -1;
413 static int hf_sprt_payload_msg_mr_evt_tdsr =            -1;
414 static int hf_sprt_payload_msg_mr_evt_rdsr =            -1;
415 static int hf_sprt_payload_msg_mr_evt_txsr =            -1;
416 static int hf_sprt_payload_msg_mr_evt_rxsr =            -1;
417 /* CLEARDOWN msg: */
418 static int hf_sprt_payload_msg_cleardown_reason_code =  -1;
419 static int hf_sprt_payload_msg_cleardown_vendor_tag =   -1;
420 static int hf_sprt_payload_msg_cleardown_vendor_info =  -1;
421 /* PROF_XCHG msg: */
422 static int hf_sprt_payload_msg_profxchg_v42_lapm =                              -1;
423 static int hf_sprt_payload_msg_profxchg_annex_av42 =                            -1;
424 static int hf_sprt_payload_msg_profxchg_v44_compr =                             -1;
425 static int hf_sprt_payload_msg_profxchg_v42bis_compr =                          -1;
426 static int hf_sprt_payload_msg_profxchg_mnp5_compr =                            -1;
427 static int hf_sprt_payload_msg_profxchg_reserved =                              -1;
428 static int hf_sprt_payload_msg_profxchg_xidlr2_v42bis_compr_req =               -1;
429 static int hf_sprt_payload_msg_profxchg_xidlr3and4_v42bis_num_codewords =       -1;
430 static int hf_sprt_payload_msg_profxchg_xidlr5_v42bis_max_strlen =              -1;
431 static int hf_sprt_payload_msg_profxchg_xidlr6_v44_capability =                 -1;
432 static int hf_sprt_payload_msg_profxchg_xidlr7_v44_compr_req =                  -1;
433 static int hf_sprt_payload_msg_profxchg_xidlr8and9_v44_num_codewords_trans =    -1;
434 static int hf_sprt_payload_msg_profxchg_xidlr10and11_v44_num_codewords_recv =   -1;
435 static int hf_sprt_payload_msg_profxchg_xidlr12_v44_max_strlen_trans =          -1;
436 static int hf_sprt_payload_msg_profxchg_xidlr13_v44_max_strlen_recv =           -1;
437 static int hf_sprt_payload_msg_profxchg_xidlr14and15_v44_history_len_trans =    -1;
438 static int hf_sprt_payload_msg_profxchg_xidlr16and17_v44_history_len_recv =     -1;
439 /* I_OCTET */
440 static int hf_sprt_payload_i_octet_no_dlci =                                    -1;
441 static int hf_sprt_payload_i_octet_dlci_presence_unknown =                      -1;
442 static int hf_sprt_payload_i_octet_dlci1 =                                      -1;
443 static int hf_sprt_payload_i_octet_cr =                                         -1;
444 static int hf_sprt_payload_i_octet_ea =                                         -1;
445 static int hf_sprt_payload_i_octet_dlci2 =                                      -1;
446 static int hf_sprt_payload_i_octet_dlci_setup_by_connect_frame =                -1;
447
448 /* I_OCTET_CS, I_CHAR_STAT_CS, I_CHAR_DYN_CS msgs: */
449 static int hf_sprt_payload_data_cs =                                            -1;
450 static int hf_sprt_payload_data_reserved_bit =                                  -1;
451 static int hf_sprt_payload_data_num_data_bits =                                 -1;
452 static int hf_sprt_payload_data_parity_type =                                   -1;
453 static int hf_sprt_payload_num_stop_bits =                                      -1;
454 static int hf_sprt_payload_frame_reserved_bits =                                -1;
455 static int hf_sprt_payload_frame_state =                                        -1;
456 static int hf_sprt_payload_rawoctet_n_field_present =                           -1;
457 static int hf_sprt_payload_rawoctet_l =                                         -1;
458 static int hf_sprt_payload_rawoctet_n =                                         -1;
459 static int hf_sprt_payload_rawbit_included_fields_l =                           -1;
460 static int hf_sprt_payload_rawbit_included_fields_lp =                          -1;
461 static int hf_sprt_payload_rawbit_included_fields_lpn =                         -1;
462 static int hf_sprt_payload_rawbit_len_a =                                       -1;
463 static int hf_sprt_payload_rawbit_len_b =                                       -1;
464 static int hf_sprt_payload_rawbit_len_c =                                       -1;
465 static int hf_sprt_payload_rawbit_p =                                           -1;
466 static int hf_sprt_payload_rawbit_n =                                           -1;
467
468 /* Preferences  */
469 static gboolean global_sprt_show_setup_info = TRUE; /* show how this SPRT stream got started */
470 static gboolean global_sprt_show_dlci_info  = TRUE; /* show DLCI in I_OCTET messages, including setup frame (if we can) */
471
472
473 /* dissector handle */
474 static dissector_handle_t sprt_handle;
475
476
477 /* initialize the subtree pointers */
478 static gint ett_sprt =                  -1;
479 static gint ett_sprt_setup =            -1;
480 static gint ett_sprt_ack_fields =       -1;
481 static gint ett_payload =               -1;
482 static gint ett_init_msg_all_fields =   -1;
483 static gint ett_jminfo_msg_cat_data =   -1;
484 static gint ett_connect_msg_adt =       -1;
485
486 static expert_field ei_sprt_sequence_number_0 = EI_INIT;
487
488 /* value strings & range strings */
489 static const value_string sprt_transport_channel_characteristics[] = {
490     { 0, "Unreliable, unsequenced" },
491     { 1, "Reliable, sequenced" },
492     { 2, "Expedited, reliable, sequenced" },
493     { 3, "Unreliable, sequenced" },
494     { 0, NULL}
495 };
496
497 static const range_string sprt_modem_relay_msg_id_name[] = {
498     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_NULL),                                 "NULL reserved for ITU-T" },
499     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_INIT),                                 "INIT" },
500     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_XID_XCHG),                             "XID_XCHG" },
501     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_JM_INFO),                              "JM_INFO" },
502     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_START_JM),                             "START_JM" },
503     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_CONNECT),                              "CONNECT" },
504     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_BREAK),                                "BREAK" },
505     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_BREAK_ACK),                            "BREAK_ACK" },
506     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_MR_EVENT),                             "MR_EVENT" },
507     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_CLEARDOWN),                            "CLEARDOWN" },
508     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_PROF_XCHG),                            "PROF_XCHG" },
509     { SPRT_MODEM_RELAY_MSG_ID_RESERVED1_START, SPRT_MODEM_RELAY_MSG_ID_RESERVED1_END, "Reserved for ITU-T" },
510     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_RAW_OCTET),                          "I_RAW-OCTET" },
511     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_RAW_BIT),                            "I_RAW-BIT" },
512     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_OCTET),                              "I_OCTET" },
513     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT),                          "I_CHAR-STAT" },
514     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN),                           "I_CHAR-DYN" },
515     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_FRAME),                              "I_FRAME" },
516     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_OCTET_CS),                           "I_OCTET-CS" },
517     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT_CS),                       "I_CHAR-STAT-CS" },
518     { SPRT_VALUE_RANGE(SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN_CS),                        "I_CHAR-DYN-CS" },
519     { SPRT_MODEM_RELAY_MSG_ID_RESERVED2_START, SPRT_MODEM_RELAY_MSG_ID_RESERVED2_END, "Reserved for ITU-T" },
520     { SPRT_MODEM_RELAY_MSG_ID_VENDOR_START, SPRT_MODEM_RELAY_MSG_ID_VENDOR_END,       "Vendor-specific message" },
521     { 0, 0, NULL }
522 };
523
524 static const range_string sprt_ecp_name[] = {
525     { SPRT_VALUE_RANGE(SPRT_ECP_NO_LINK_LAYER_PROTO),   "No link layer protocol" },
526     { SPRT_VALUE_RANGE(SPRT_ECP_V42_LAPM),              "V.42/LAPM" },
527     { SPRT_VALUE_RANGE(SPRT_ECP_ANNEX_AV42_1996),       "Annex A/V.42(1996)" },
528     { SPRT_ECP_RESERVED_START, SPRT_ECP_RESERVED_END,   "Reserved for ITU-T" },
529     { 0, 0, NULL }
530 };
531
532 static const value_string sprt_jm_info_cat_id_name[] = {
533     { SPRT_JM_INFO_CAT_ID_CALL_FUNCT,           "Call function" },
534     { SPRT_JM_INFO_CAT_ID_MOD_MODES,            "Modulation modes" },
535     { SPRT_JM_INFO_CAT_ID_PROTOCOLS,            "Protocols" },
536     { SPRT_JM_INFO_CAT_ID_PSTN_ACCESS,          "PSTN access" },
537     { SPRT_JM_INFO_CAT_ID_PCM_MODEM_AVAIL,      "PCM modem availability" },
538     { SPRT_JM_INFO_CAT_ID_CATEGORY_EXTENSION,   "Extension of current category" },
539     { 0, NULL }
540 };
541
542 static const value_string sprt_jminfo_tbc_call_funct_name[] = {
543     { SPRT_JMINFO_TBC_CALL_FUNCT_PSTN_MULTIMEDIA_TERM,      "PSTN Multimedia terminal (ITU-T Rec. H.324)" },
544     { SPRT_JMINFO_TBC_CALL_FUNCT_TEXTPHONE_ITU_T_REC_V18,   "Textphone (ITU-T Rec. V.18)" },
545     { SPRT_JMINFO_TBC_CALL_FUNCT_VIDEOTEXT_ITU_T_REC_T101,  "Videotext (ITU-T Rec. T.101)" },
546     { SPRT_JMINFO_TBC_CALL_FUNCT_TRANS_FAX_ITU_T_REC_T30,   "Transmit facsimile from call terminal (ITU-T Rec. T.30)" },
547     { SPRT_JMINFO_TBC_CALL_FUNCT_RECV_FAX_ITU_T_REC_T30,    "Receive facsimile at call terminal (ITU-T Rec. T.30)" },
548     { SPRT_JMINFO_TBC_CALL_FUNCT_DATA_V_SERIES_MODEM_REC,   "Data (V-series modem Recommendations)" },
549     { 0, NULL }
550 };
551
552 static const range_string sprt_jminfo_tbc_protocol_name[] = {
553     { SPRT_VALUE_RANGE(SPRT_JMINFO_TBC_PROTOCOL_LAPM_ITU_T_REC_V42),    "LAPM protocol according to ITU-T Rec. V.42" },
554     { 0, 0, NULL }
555 };
556
557 static const range_string sprt_selmod_name[] = {
558     { SPRT_VALUE_RANGE(SPRT_SELMOD_NULL),                   "NULL" },
559     { SPRT_VALUE_RANGE(SPRT_SELMOD_V92),                    "V.92" },
560     { SPRT_VALUE_RANGE(SPRT_SELMOD_V91),                    "V.91" },
561     { SPRT_VALUE_RANGE(SPRT_SELMOD_V90),                    "V.90" },
562     { SPRT_VALUE_RANGE(SPRT_SELMOD_V34),                    "V.34" },
563     { SPRT_VALUE_RANGE(SPRT_SELMOD_V32_BIS),                "V.32bis" },
564     { SPRT_VALUE_RANGE(SPRT_SELMOD_V32),                    "V.32" },
565     { SPRT_VALUE_RANGE(SPRT_SELMOD_V22_BIS),                "V.22bis" },
566     { SPRT_VALUE_RANGE(SPRT_SELMOD_V22),                    "V.22" },
567     { SPRT_VALUE_RANGE(SPRT_SELMOD_V17),                    "V.17" },
568     { SPRT_VALUE_RANGE(SPRT_SELMOD_V29),                    "V.29" },
569     { SPRT_VALUE_RANGE(SPRT_SELMOD_V27_TER),                "V.27ter" },
570     { SPRT_VALUE_RANGE(SPRT_SELMOD_V26_TER),                "V.26ter" },
571     { SPRT_VALUE_RANGE(SPRT_SELMOD_V26_BIS),                "V.26bis" },
572     { SPRT_VALUE_RANGE(SPRT_SELMOD_V23),                    "V.23" },
573     { SPRT_VALUE_RANGE(SPRT_SELMOD_V21),                    "V.21" },
574     { SPRT_VALUE_RANGE(SPRT_SELMOD_BELL_212),               "Bell 212" },
575     { SPRT_VALUE_RANGE(SPRT_SELMOD_BELL_103),               "Bell 103" },
576     { SPRT_SELMOD_VENDOR_START, SPRT_SELMOD_VENDOR_END,     "Vendor-specific modulation" },
577     { SPRT_SELMOD_RESERVED_START, SPRT_SELMOD_RESERVED_END, "Reserved for ITU-T" },
578     { 0, 0, NULL }
579 };
580
581 static const value_string sprt_comp_direction[] = {
582     { SPRT_COMPR_DIR_NO_COMPRESSION,    "None" },
583     { SPRT_COMPR_DIR_TRANSMIT,          "Transmit" },
584     { SPRT_COMPR_DIR_RECEIVE,           "Receive" },
585     { SPRT_COMPR_DIR_BIDIRECTIONAL,     "Bidirectional" },
586     { 0, NULL }
587 };
588
589 static const range_string sprt_selected_compr_name[] = {
590     { SPRT_VALUE_RANGE(SPRT_SELECTED_COMPR_NONE),       "None" },
591     { SPRT_VALUE_RANGE(SPRT_SELECTED_COMPR_V42_BIS),    "V.42bis" },
592     { SPRT_VALUE_RANGE(SPRT_SELECTED_COMPR_V44),        "V.44" },
593     { SPRT_VALUE_RANGE(SPRT_SELECTED_COMPR_MNP5),       "MNP5" },
594     { SPRT_SELECTED_COMPR_RESERVED_START, SPRT_SELECTED_COMPR_RESERVED_END, "Reserved by ITU-T" },
595     { 0, 0, NULL }
596 };
597
598 static const range_string sprt_selected_err_corr_name[] = {
599     { SPRT_VALUE_RANGE(SPRT_SELECTED_ERR_CORR_V14_OR_NONE),     "V.14 or no error correction protocol" },
600     { SPRT_VALUE_RANGE(SPRT_SELECTED_ERR_CORR_V42_LAPM),        "V.42/LAPM" },
601     { SPRT_VALUE_RANGE(SPRT_SELECTED_ERR_CORR_ANNEX_AV42),      "Annex A/V.42" },
602     { SPRT_SELECTED_ERR_CORR_RESERVED_START, SPRT_SELECTED_ERR_CORR_RESERVED_END,   "Reserved for ITU-T" },
603     { 0, 0, NULL }
604 };
605
606 static const range_string sprt_break_src_proto_name[] = {
607     { SPRT_VALUE_RANGE(SPRT_BREAK_SRC_PROTO_V42_LAPM),          "V.42/LAPM" },
608     { SPRT_VALUE_RANGE(SPRT_BREAK_SRC_PROTO_ANNEX_AV42_1996),   "Annex A/V.42(1996)" },
609     { SPRT_VALUE_RANGE(SPRT_BREAK_SRC_PROTO_V14),               "V.14" },
610     { SPRT_BREAK_SRC_PROTO_RESERVED_START, SPRT_BREAK_SRC_PROTO_RESERVED_END,   "Reserved for ITU-T" },
611     { 0, 0, NULL }
612 };
613
614 static const range_string sprt_break_type_name[] = {
615     { SPRT_VALUE_RANGE(SPRT_BREAK_TYPE_NOT_APPLICABLE),                     "Not applicable" },
616     { SPRT_VALUE_RANGE(SPRT_BREAK_TYPE_DESTRUCTIVE_AND_EXPEDITED),          "Destructive and expedited" },
617     { SPRT_VALUE_RANGE(SPRT_BREAK_TYPE_NONDESTRUCTIVE_AND_EXPEDITED),       "Non-destructive and expedited" },
618     { SPRT_VALUE_RANGE(SPRT_BREAK_TYPE_NONDESTRUCTIVE_AND_NONEXPEDITED),    "Non-destructive and non-expedited" },
619     { SPRT_BREAK_TYPE_RESERVED_START, SPRT_BREAK_TYPE_RESERVED_END,         "Reserved for ITU-T" },
620     { 0, 0, NULL }
621 };
622
623 static const range_string sprt_mrevent_id_name[] = {
624     { SPRT_VALUE_RANGE(SPRT_MREVT_EVENT_ID_NULL),               "NULL" },
625     { SPRT_VALUE_RANGE(SPRT_MREVT_EVENT_ID_RATE_RENEGOTIATION), "Rate renegotiation" },
626     { SPRT_VALUE_RANGE(SPRT_MREVT_EVENT_ID_RETRAIN),            "Retrain" },
627     { SPRT_VALUE_RANGE(SPRT_MREVT_EVENT_ID_PHYSUP),             "Physical layer ready" }, /* reason code should be 0 */
628     { SPRT_MREVT_EVENT_ID_RESERVED_START, SPRT_MREVT_EVENT_ID_RESERVED_END, "Reserved for ITU-T" },
629     { 0, 0, NULL }
630 };
631
632 static const range_string sprt_mrevent_reason_code_name[] = {
633     { SPRT_VALUE_RANGE(SPRT_MREVT_REASON_CODE_NULL),                "Null/not applicable" }, /* for eventid = PHYSUP */
634     { SPRT_VALUE_RANGE(SPRT_MREVT_REASON_CODE_INIT),                "Initiation" },
635     { SPRT_VALUE_RANGE(SPRT_MREVT_REASON_CODE_RESPONDING),          "Responding" },
636     { SPRT_MREVT_REASON_CODE_RESERVED_START, SPRT_MREVT_REASON_CODE_RESERVED_END,   "Reserved for ITU-T" },
637     { 0, 0, NULL }
638 };
639
640 static const range_string sprt_mrevent_phys_layer_symbol_rate[] = {
641     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_NULL),             "Null/not applicable" },
642     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_600),              "600" },
643     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_1200),             "1200" },
644     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_1600),             "1600" },
645     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_2400),             "2400" },
646     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_2743),             "2743" },
647     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3000),             "3000" },
648     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3200),             "3200" },
649     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_3429),             "3249" },
650     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_8000),             "8000" },
651     { SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_RESERVED_START, SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_RESERVED_END, "Reserved for ITU-T" },
652     { SPRT_VALUE_RANGE(SPRT_MREVT_PHYS_LAYER_SYMBOL_RATE_UNSPECIFIED),  "Unspecified" },
653     { 0, 0, NULL }
654 };
655
656 static const value_string sprt_cleardown_reason[] = {
657     { SPRT_CLEARDOWN_RIC_UNKNOWN,                     "Unknown/unspecified" },
658     { SPRT_CLEARDOWN_RIC_PHYSICAL_LAYER_RELEASE,      "Physical layer release" },
659     { SPRT_CLEARDOWN_RIC_LINK_LAYER_DISCONNECT,       "Link layer disconnect" },
660     { SPRT_CLEARDOWN_RIC_DATA_COMPRESSION_DISCONNECT, "Data compression disconnect" },
661     { SPRT_CLEARDOWN_RIC_ABORT,                       "Abort" },
662     { SPRT_CLEARDOWN_RIC_ON_HOOK,                     "On hook" },
663     { SPRT_CLEARDOWN_RIC_NETWORK_LAYER_TERMINATION,   "Network layer termination" },
664     { SPRT_CLEARDOWN_RIC_ADMINISTRATIVE,              "Administrative" },
665     { 0, NULL }
666 };
667
668 static const value_string sprt_prof_xchg_support[] = {
669     { SPRT_PROF_XCHG_SUPPORT_NO,        "No" },
670     { SPRT_PROF_XCHG_SUPPORT_YES,       "Yes" },
671     { SPRT_PROF_XCHG_SUPPORT_UNKNOWN,   "Unknown" },
672     { 0, NULL }
673 };
674
675 static const range_string sprt_payload_dlci1[] = {
676     { SPRT_VALUE_RANGE(SPRT_PAYLOAD_DLCI1_DTE2DTE),                               "DTE-to-DTE (V.24 interfaces) data" },
677     { SPRT_PAYLOAD_DLCI1_RESERVED_START,     SPRT_PAYLOAD_DLCI1_RESERVED_END,     "Reserved for for ITU-T" },
678     { SPRT_PAYLOAD_DLCI1_NOT_RESERVED_START, SPRT_PAYLOAD_DLCI1_NOT_RESERVED_END, "Not reserved for for ITU-T" },
679     { SPRT_VALUE_RANGE(SPRT_PAYLOAD_DLCI1_CTRLFN2CTRLFN),                         "Control-function to control-function information" },
680     { 0, 0, NULL }
681 };
682
683 static const true_false_string sprt_payload_ea_bit = {
684     "Last octet of address field", "Another octet of address field follows"
685 };
686
687 static const range_string sprt_payload_dlci2[] = {
688     { SPRT_PAYLOAD_DLCI2_START, SPRT_PAYLOAD_DLCI2_END,     "Reserved by ITU-T for further study" },
689     { 0, 0, NULL }
690 };
691
692 static const value_string sprt_payload_data_bits[] = {
693     { SPRT_PAYLOAD_D_0,     "5 bits" },
694     { SPRT_PAYLOAD_D_1,     "6 bits" },
695     { SPRT_PAYLOAD_D_2,     "7 bits" },
696     { SPRT_PAYLOAD_D_3,     "8 bits" },
697     { 0, NULL }
698 };
699
700 static const value_string sprt_payload_parity[] = {
701     { SPRT_PAYLOAD_P_0,     "Unknown" },
702     { SPRT_PAYLOAD_P_1,     "None" },
703     { SPRT_PAYLOAD_P_2,     "Even parity" },
704     { SPRT_PAYLOAD_P_3,     "Odd parity" },
705     { SPRT_PAYLOAD_P_4,     "Space parity" },
706     { SPRT_PAYLOAD_P_5,     "Mark parity" },
707     { SPRT_PAYLOAD_P_6,     "Reserved" },
708     { SPRT_PAYLOAD_P_7,     "Reserved" },
709     { 0, NULL }
710 };
711
712 static const value_string sprt_payload_stop_bits[] = {
713     { SPRT_PAYLOAD_S_0,     "1 stop bit" },
714     { SPRT_PAYLOAD_S_1,     "2 stop bits" },
715     { SPRT_PAYLOAD_S_2,     "Reserved" },
716     { SPRT_PAYLOAD_S_3,     "Reserved" },
717     { 0, NULL }
718 };
719
720 static const value_string sprt_payload_frame_state[] = {
721     { SPRT_PAYLOAD_FR_0,    "Data frame without termination" },
722     { SPRT_PAYLOAD_FR_1,    "Data frame with termination" },
723     { SPRT_PAYLOAD_FR_2,    "Data frame with abort termination" },
724     { SPRT_PAYLOAD_FR_3,    "Undefined" },
725     { 0, NULL }
726 };
727
728
729
730 /* look for a conversation & return the associated data */
731 static struct _sprt_conversation_info* find_sprt_conversation_data(packet_info *pinfo)
732 {
733     conversation_t *p_conv = NULL;
734     struct _sprt_conversation_info *p_conv_data = NULL;
735     /* Use existing packet info if available */
736     p_conv = find_conversation_pinfo(pinfo, NO_ADDR_B|NO_PORT_B);
737     if (p_conv)
738     {
739         p_conv_data = (struct _sprt_conversation_info*)conversation_get_proto_data(p_conv, proto_sprt);
740     }
741     return p_conv_data;
742 }
743
744
745
746 /* set up SPRT conversation */
747 void sprt_add_address(packet_info *pinfo,
748                       address *addr, int port,
749                       int other_port,
750                       const gchar *setup_method,
751                       guint32 setup_frame_number)
752 {
753     address null_addr;
754     conversation_t* p_conv;
755     struct _sprt_conversation_info *p_conv_data = NULL;
756
757     /*
758      * If this isn't the first time this packet has been processed,
759      * we've already done this work, so we don't need to do it
760      * again.
761      */
762     if (pinfo->fd->flags.visited)
763     {
764         return;
765     }
766
767     clear_address(&null_addr);
768
769     /*
770      * Check if the ip address and port combination is not
771      * already registered as a conversation.
772      */
773     p_conv = find_conversation(setup_frame_number, addr, &null_addr, ENDPOINT_UDP, port, other_port,
774                                 NO_ADDR_B | (!other_port ? NO_PORT_B : 0));
775
776     /*
777      * If not, create a new conversation.
778      */
779     if (!p_conv || p_conv->setup_frame != setup_frame_number) {
780         p_conv = conversation_new(setup_frame_number, addr, &null_addr, ENDPOINT_UDP,
781                                     (guint32)port, (guint32)other_port,
782                                     NO_ADDR2 | (!other_port ? NO_PORT2 : 0));
783     }
784
785     /* Set dissector */
786     conversation_set_dissector(p_conv, sprt_handle);
787
788     /*
789      * Check if the conversation has data associated with it.
790      */
791     p_conv_data = (struct _sprt_conversation_info *)conversation_get_proto_data(p_conv, proto_sprt);
792
793     /*
794      * If not, add a new data item.
795      */
796     if (!p_conv_data) {
797         /* Create conversation data */
798         p_conv_data = wmem_new(wmem_file_scope(), struct _sprt_conversation_info);
799         p_conv_data->stream_started = FALSE;
800         p_conv_data->seqnum[0] = 0;
801         p_conv_data->seqnum[1] = 0;
802         p_conv_data->seqnum[2] = 0;
803         p_conv_data->seqnum[3] = 0;
804         p_conv_data->i_octet_dlci_status = DLCI_UNKNOWN;
805         p_conv_data->connect_frame_number = 0;
806         conversation_add_proto_data(p_conv, proto_sprt, p_conv_data);
807     }
808
809     /* Update the conversation data. */
810     g_strlcpy(p_conv_data->method, setup_method, SPRT_CONV_MAX_SETUP_METHOD_SIZE);
811     p_conv_data->frame_number = setup_frame_number;
812 }
813
814
815
816 /* Display setup info */
817 static void show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
818 {
819     struct _sprt_conversation_info *p_conv_data;
820     proto_tree *sprt_setup_tree;
821     proto_item *ti;
822
823     /* look up the conversation & get the data */
824     p_conv_data = find_sprt_conversation_data(pinfo);
825
826     if (!p_conv_data)
827     {
828         proto_tree_add_string_format(tree, hf_sprt_setup, tvb, 0, 0, "", "No setup info found");
829         return;
830     }
831
832     /* Create setup info subtree with summary info. */
833     ti =  proto_tree_add_string_format(tree, hf_sprt_setup, tvb, 0, 0,
834                                         "",
835                                         "Stream setup by %s (frame %u)",
836                                         p_conv_data->method,
837                                         p_conv_data->frame_number);
838     PROTO_ITEM_SET_GENERATED(ti);
839     sprt_setup_tree = proto_item_add_subtree(ti, ett_sprt_setup);
840     if (sprt_setup_tree)
841     {
842         /* Add details into subtree */
843         proto_item* item = proto_tree_add_uint(sprt_setup_tree, hf_sprt_setup_frame,
844                                                 tvb, 0, 0, p_conv_data->frame_number);
845         PROTO_ITEM_SET_GENERATED(item);
846         item = proto_tree_add_string(sprt_setup_tree, hf_sprt_setup_method,
847                                         tvb, 0, 0, p_conv_data->method);
848         PROTO_ITEM_SET_GENERATED(item);
849     }
850 }
851
852
853 /* code to actually dissect the packet payload data */
854 static int
855 dissect_sprt_data(tvbuff_t *tvb,
856                   packet_info *pinfo,
857                   struct _sprt_conversation_info *p_conv_data,
858                   proto_tree *sprt_tree,
859                   unsigned int offset,
860                   guint payload_length)
861 {
862     proto_item *ti;
863     proto_tree *sprt_payload_tree, *field_subtree;
864     guint8 octet, payload_msgid, category_id;
865     guint8 selcompr, mr_event_id;
866     guint16 word, category_count;
867
868     if (payload_length > 0)
869     {
870         ti = proto_tree_add_uint(sprt_tree, hf_sprt_payload_length, tvb, offset, 1, payload_length);
871         proto_item_set_len(ti, payload_length);
872
873         sprt_payload_tree = proto_item_add_subtree(ti, ett_payload);
874
875         payload_msgid = tvb_get_guint8(tvb, offset) & 0x7F;
876
877         proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
878         proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_message_id, tvb, offset, 1, ENC_BIG_ENDIAN);
879         offset++;
880         payload_length--;
881
882         /* what kind of message is this? */
883         col_append_fstr(pinfo->cinfo, COL_INFO, ", %s(%d)", rval_to_str(payload_msgid, sprt_modem_relay_msg_id_name, "Unknown"), payload_msgid);
884
885         /* now parse payload stuff after ext. bit & msgid */
886         switch(payload_msgid)
887         {
888         case SPRT_MODEM_RELAY_MSG_ID_INIT:
889             /* make subtree */
890             ti = proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_init_all_fields, tvb, offset, 2, ENC_BIG_ENDIAN);
891             field_subtree = proto_item_add_subtree(ti, ett_init_msg_all_fields);
892             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_necrxch, tvb, offset, 2, ENC_BIG_ENDIAN);
893             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_ecrxch, tvb, offset, 2, ENC_BIG_ENDIAN);
894             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_xid_prof_exch, tvb, offset, 2, ENC_BIG_ENDIAN);
895             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_assym_data_types, tvb, offset, 2, ENC_BIG_ENDIAN);
896             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_raw_bit, tvb, offset, 2, ENC_BIG_ENDIAN);
897             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_frame, tvb, offset, 2, ENC_BIG_ENDIAN);
898             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_char_stat, tvb, offset, 2, ENC_BIG_ENDIAN);
899             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn, tvb, offset, 2, ENC_BIG_ENDIAN);
900             /* from V.150.1 amendment 2 (5-2006): */
901             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_octet_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
902             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_char_stat_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
903             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
904             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_init_opt_moip_types_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
905             offset += 2;
906             break;
907         case SPRT_MODEM_RELAY_MSG_ID_XID_XCHG:
908             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_ecp, tvb, offset, 1, ENC_BIG_ENDIAN);
909             offset++;
910             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr1_v42bis, tvb, offset, 1, ENC_BIG_ENDIAN);
911             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr1_v44, tvb, offset, 1, ENC_BIG_ENDIAN);
912             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr1_mnp5, tvb, offset, 1, ENC_BIG_ENDIAN);
913             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr1_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
914             offset++;
915             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr2_v42bis_compr_req, tvb, offset, 1, ENC_BIG_ENDIAN);
916             offset++;
917             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr3and4_v42bis_num_codewords, tvb, offset, 2, ENC_BIG_ENDIAN);
918             offset += 2;
919             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr5_v42bis_max_strlen, tvb, offset, 1, ENC_BIG_ENDIAN);
920             offset++;
921             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr6_v44_capability, tvb, offset, 1, ENC_BIG_ENDIAN);
922             offset++;
923             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr7_v44_compr_req, tvb, offset, 1, ENC_BIG_ENDIAN);
924             offset++;
925             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr8and9_v44_num_codewords_trans, tvb, offset, 2, ENC_BIG_ENDIAN);
926             offset += 2;
927             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr10and11_v44_num_codewords_recv, tvb, offset, 2, ENC_BIG_ENDIAN);
928             offset += 2;
929             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr12_v44_max_strlen_trans, tvb, offset, 1, ENC_BIG_ENDIAN);
930             offset++;
931             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr13_v44_max_strlen_recv, tvb, offset, 1, ENC_BIG_ENDIAN);
932             offset++;
933             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr14and15_v44_history_len_trans, tvb, offset, 2, ENC_BIG_ENDIAN);
934             offset += 2;
935             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_xidxchg_xidlr16and17_v44_history_len_recv, tvb, offset, 2, ENC_BIG_ENDIAN);
936             offset += 2;
937             break;
938         case SPRT_MODEM_RELAY_MSG_ID_JM_INFO:
939             category_count = 1;
940             do /* there may be multiple categories */
941             {
942                 word = tvb_get_ntohs(tvb, offset);
943                 category_id = (word >> 12);
944
945                 ti = proto_tree_add_uint_format_value(sprt_payload_tree, hf_sprt_payload_msg_jminfo_category_data, tvb, offset, 2, word,
946                     "Item #%d: %s (0x%04x)", category_count, val_to_str_const(category_id, sprt_jm_info_cat_id_name, "Unknown"), category_id);
947                 category_count++;
948                 field_subtree = proto_item_add_subtree(ti, ett_jminfo_msg_cat_data);
949                 proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_id, tvb, offset, 2, ENC_BIG_ENDIAN);
950
951                 switch(category_id)
952                 {
953                 case SPRT_JM_INFO_CAT_ID_CALL_FUNCT: /* 0x8 */
954                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_call_function, tvb, offset, 2, ENC_BIG_ENDIAN);
955                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_leftover_bits, tvb, offset, 2, ENC_BIG_ENDIAN);
956                     break;
957                 case SPRT_JM_INFO_CAT_ID_MOD_MODES: /* 0xA */
958                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v34_duplex, tvb, offset, 2, ENC_BIG_ENDIAN);
959                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v34_half_duplex, tvb, offset, 2, ENC_BIG_ENDIAN);
960                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v32bis_v32, tvb, offset, 2, ENC_BIG_ENDIAN);
961                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v22bis_v22, tvb, offset, 2, ENC_BIG_ENDIAN);
962                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v17, tvb, offset, 2, ENC_BIG_ENDIAN);
963                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v29_half_duplex, tvb, offset, 2, ENC_BIG_ENDIAN);
964                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v27ter, tvb, offset, 2, ENC_BIG_ENDIAN);
965                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v26ter, tvb, offset, 2, ENC_BIG_ENDIAN);
966                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v26bis, tvb, offset, 2, ENC_BIG_ENDIAN);
967                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v23_duplex, tvb, offset, 2, ENC_BIG_ENDIAN);
968                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v23_half_duplex, tvb, offset, 2, ENC_BIG_ENDIAN);
969                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_mod_v21, tvb, offset, 2, ENC_BIG_ENDIAN);
970                     break;
971                 case SPRT_JM_INFO_CAT_ID_PROTOCOLS: /* 0x5 */
972                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_protocols, tvb, offset, 2, ENC_BIG_ENDIAN);
973                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_leftover_bits, tvb, offset, 2, ENC_BIG_ENDIAN);
974                     break;
975                 case SPRT_JM_INFO_CAT_ID_PSTN_ACCESS: /* 0xB */
976                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pstn_access_call_dce_cell, tvb, offset, 2, ENC_BIG_ENDIAN);
977                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pstn_access_answ_dce_cell, tvb, offset, 2, ENC_BIG_ENDIAN);
978                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pstn_access_dce_on_digital_net, tvb, offset, 2, ENC_BIG_ENDIAN);
979                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_leftover_bits, tvb, offset, 2, ENC_BIG_ENDIAN);
980                     break;
981                 case SPRT_JM_INFO_CAT_ID_PCM_MODEM_AVAIL: /* 0xE */
982                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_analog, tvb, offset, 2, ENC_BIG_ENDIAN);
983                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_digital, tvb, offset, 2, ENC_BIG_ENDIAN);
984                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_pcm_modem_avail_v91, tvb, offset, 2, ENC_BIG_ENDIAN);
985                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_leftover_bits, tvb, offset, 2, ENC_BIG_ENDIAN);
986                     break;
987                 case SPRT_JM_INFO_CAT_ID_CATEGORY_EXTENSION: /* 0x0 */
988                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_category_ext_info, tvb, offset, 2, ENC_BIG_ENDIAN);
989                     break;
990                 default: /* unknown category ID */
991                     proto_tree_add_item(field_subtree, hf_sprt_payload_msg_jminfo_unk_category_info, tvb, offset, 2, ENC_BIG_ENDIAN);
992                     break;
993                 }
994                 offset += 2;
995             } while (tvb_reported_length_remaining(tvb, offset) >= 2);
996             break;
997         case SPRT_MODEM_RELAY_MSG_ID_START_JM:
998             /* No additional content */
999             break;
1000         case SPRT_MODEM_RELAY_MSG_ID_CONNECT: /***/
1001             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_selmod, tvb, offset, 1, ENC_BIG_ENDIAN);
1002             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_dir, tvb, offset, 1, ENC_BIG_ENDIAN);
1003             offset++;
1004             selcompr = (tvb_get_guint8(tvb, offset) & 0xF0) >> 4;
1005             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_selected_compr, tvb, offset, 1, ENC_BIG_ENDIAN);
1006             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_selected_err_corr, tvb, offset, 1, ENC_BIG_ENDIAN);
1007             offset++;
1008             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_tdsr, tvb, offset, 2, ENC_BIG_ENDIAN);
1009             offset += 2;
1010             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_rdsr, tvb, offset, 2, ENC_BIG_ENDIAN);
1011             offset += 2;
1012             word = tvb_get_ntohs(tvb, offset);
1013             /* is DLCI enabled (used w/I_OCTET messages)? */
1014             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_dlci_enabled, tvb, offset, 2, ENC_BIG_ENDIAN);
1015             /* have we previously seen a CONNECT msg in this conversation (i.e., do we know if DLCI is used w/I_OCTET?) */
1016             if (p_conv_data->connect_frame_number == 0)
1017             {
1018                 p_conv_data->connect_frame_number = pinfo->num;
1019                 if (word & 0x8000)
1020                 {
1021                     p_conv_data->i_octet_dlci_status = DLCI_PRESENT;
1022                 } else {
1023                     p_conv_data->i_octet_dlci_status = DLCI_ABSENT;
1024                 }
1025             }
1026
1027             /* do subtree for available data types */
1028             ti = proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_avail_data_types, tvb, offset, 2, ENC_BIG_ENDIAN);
1029             field_subtree = proto_item_add_subtree(ti, ett_connect_msg_adt);
1030             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_octet_no_format_no_dlci, tvb, offset, 2, ENC_BIG_ENDIAN);
1031             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_raw_bit, tvb, offset, 2, ENC_BIG_ENDIAN);
1032             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_frame, tvb, offset, 2, ENC_BIG_ENDIAN);
1033             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_char_stat, tvb, offset, 2, ENC_BIG_ENDIAN);
1034             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_char_dyn, tvb, offset, 2, ENC_BIG_ENDIAN);
1035             /* from V.150.1 amendment 2 (5-2006): */
1036             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_octet_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
1037             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_char_stat_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
1038             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_i_char_dyn_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
1039             proto_tree_add_item(field_subtree, hf_sprt_payload_msg_connect_adt_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
1040             offset += 2;
1041             if (selcompr != SPRT_SELECTED_COMPR_NONE &&
1042                selcompr != SPRT_SELECTED_COMPR_MNP5)
1043             {
1044                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_trans_dict_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
1045                 offset += 2;
1046                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_recv_dict_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
1047                 offset += 2;
1048                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_trans_str_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1049                 offset++;
1050                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_recv_str_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1051                 offset++;
1052             }
1053             if (selcompr != SPRT_SELECTED_COMPR_NONE &&
1054                selcompr != SPRT_SELECTED_COMPR_MNP5 &&
1055                selcompr != SPRT_SELECTED_COMPR_V42_BIS)
1056             {
1057                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_trans_hist_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
1058                 offset += 2;
1059                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_connect_compr_recv_hist_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
1060                 offset += 2;
1061             }
1062             break;
1063         case SPRT_MODEM_RELAY_MSG_ID_BREAK: /* no additional info */
1064             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_break_source_proto, tvb, offset, 1, ENC_BIG_ENDIAN);
1065             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_break_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1066             offset++;
1067             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_break_length, tvb, offset, 1, ENC_BIG_ENDIAN);
1068             offset++;
1069             break;
1070         case SPRT_MODEM_RELAY_MSG_ID_BREAK_ACK:
1071             /* No additional content */
1072             break;
1073         case SPRT_MODEM_RELAY_MSG_ID_MR_EVENT:
1074             mr_event_id = tvb_get_guint8(tvb, offset);
1075             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_event_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1076             offset++;
1077             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_reason_code, tvb, offset, 1, ENC_BIG_ENDIAN);
1078             offset++;
1079             if (mr_event_id == SPRT_MREVT_EVENT_ID_PHYSUP)
1080             {
1081                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_selmod, tvb, offset, 1, ENC_BIG_ENDIAN);
1082                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_txsen, tvb, offset, 1, ENC_BIG_ENDIAN);
1083                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_rxsen, tvb, offset, 1, ENC_BIG_ENDIAN);
1084                 offset++;
1085                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_tdsr, tvb, offset, 2, ENC_BIG_ENDIAN);
1086                 offset += 2;
1087                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_rdsr, tvb, offset, 2, ENC_BIG_ENDIAN);
1088                 offset += 2;
1089                 /* The next two fields are "optional"
1090                  * they should only appear w/PHYSUP (MR_EVENT id = 3) messages, when TxSR and RxSR are true
1091                  */
1092                 if (tvb_reported_length_remaining(tvb, offset) >= 2)
1093                 {
1094                     proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_txsr, tvb, offset, 1, ENC_BIG_ENDIAN);
1095                     offset++;
1096                     proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_mr_evt_rxsr, tvb, offset, 1, ENC_BIG_ENDIAN);
1097                     offset++;
1098                 }
1099             }
1100             break;
1101         case SPRT_MODEM_RELAY_MSG_ID_CLEARDOWN:
1102             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_cleardown_reason_code, tvb, offset, 1, ENC_BIG_ENDIAN);
1103             offset++;
1104             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_cleardown_vendor_tag, tvb, offset, 1, ENC_BIG_ENDIAN);
1105             offset++;
1106             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_cleardown_vendor_info, tvb, offset, 1, ENC_BIG_ENDIAN);
1107             offset++;
1108             break;
1109         case SPRT_MODEM_RELAY_MSG_ID_PROF_XCHG:
1110             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_v42_lapm, tvb, offset, 1, ENC_BIG_ENDIAN);
1111             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_annex_av42, tvb, offset, 1, ENC_BIG_ENDIAN);
1112             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_v44_compr, tvb, offset, 1, ENC_BIG_ENDIAN);
1113             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_v42bis_compr, tvb, offset, 1, ENC_BIG_ENDIAN);
1114             offset++;
1115             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_mnp5_compr, tvb, offset, 1, ENC_BIG_ENDIAN);
1116             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
1117             offset++;
1118             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr2_v42bis_compr_req, tvb, offset, 1, ENC_BIG_ENDIAN);
1119             offset++;
1120             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr3and4_v42bis_num_codewords, tvb, offset, 2, ENC_BIG_ENDIAN);
1121             offset += 2;
1122             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr5_v42bis_max_strlen, tvb, offset, 1, ENC_BIG_ENDIAN);
1123             offset++;
1124             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr6_v44_capability, tvb, offset, 1, ENC_BIG_ENDIAN);
1125             offset++;
1126             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr7_v44_compr_req, tvb, offset, 1, ENC_BIG_ENDIAN);
1127             offset++;
1128             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr8and9_v44_num_codewords_trans, tvb, offset, 2, ENC_BIG_ENDIAN);
1129             offset += 2;
1130             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr10and11_v44_num_codewords_recv, tvb, offset, 2, ENC_BIG_ENDIAN);
1131             offset += 2;
1132             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr12_v44_max_strlen_trans, tvb, offset, 1, ENC_BIG_ENDIAN);
1133             offset++;
1134             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr13_v44_max_strlen_recv, tvb, offset, 1, ENC_BIG_ENDIAN);
1135             offset++;
1136             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr14and15_v44_history_len_trans, tvb, offset, 2, ENC_BIG_ENDIAN);
1137             offset += 2;
1138             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_msg_profxchg_xidlr16and17_v44_history_len_recv, tvb, offset, 2, ENC_BIG_ENDIAN);
1139             offset += 2;
1140             break;
1141         case SPRT_MODEM_RELAY_MSG_ID_I_RAW_OCTET: /* data */
1142             octet = tvb_get_guint8(tvb, offset);
1143             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawoctet_n_field_present, tvb, offset, 1, ENC_BIG_ENDIAN);
1144             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawoctet_l, tvb, offset, 1, ENC_BIG_ENDIAN);
1145             if (octet & 0x80) /* is N field present? */
1146             {
1147                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawoctet_n, tvb, offset, 1, ENC_BIG_ENDIAN);
1148             }
1149             offset++;
1150             payload_length--;
1151             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
1152             break;
1153         case SPRT_MODEM_RELAY_MSG_ID_I_RAW_BIT: /* data */
1154             /*
1155              * L, P, N fields need to be parsed
1156              */
1157             switch((tvb_get_guint8(tvb, offset) & 0xC0) >> 6)
1158             {
1159             case 0x0: /* 00: get L (6 bits) */
1160                 /* display leading "00" bits, followed by L */
1161                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_included_fields_l, tvb, offset, 1, ENC_BIG_ENDIAN);
1162                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_len_a, tvb, offset, 1, ENC_BIG_ENDIAN);
1163                 offset++;
1164                 payload_length--;
1165                 break;
1166             case 0x1: /* 01: get L (3 bits) & P (3 bits) */
1167                 /* display leading "01" bits, followed by L,P */
1168                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_included_fields_lp, tvb, offset, 1, ENC_BIG_ENDIAN);
1169                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_len_b, tvb, offset, 1, ENC_BIG_ENDIAN);
1170                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_p, tvb, offset, 1, ENC_BIG_ENDIAN);
1171                 offset++;
1172                 payload_length--;
1173                 break;
1174             default: /* 10, 11: get L (4 bits), P (3 bits), N (8 bits) */
1175                 /* display leading "1" bit, followed by L,P,N */
1176                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_included_fields_lpn, tvb, offset, 1, ENC_BIG_ENDIAN);
1177                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_len_c, tvb, offset, 1, ENC_BIG_ENDIAN);
1178                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_p, tvb, offset, 1, ENC_BIG_ENDIAN);
1179                 offset++;
1180                 payload_length--;
1181                 proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_rawbit_n, tvb, offset, 1, ENC_BIG_ENDIAN);
1182                 offset++;
1183                 payload_length--;
1184                 break;
1185             }
1186             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
1187             break;
1188         case SPRT_MODEM_RELAY_MSG_ID_I_OCTET: /* data */
1189             if (global_sprt_show_dlci_info)
1190             {
1191                 /* DLCI field may be 0, 1, or 2 bytes, depending on CONNECT message (see "DLCI enabled")...
1192                  * or UNKNOWN if we don't see the CONNECT message
1193                  */
1194                 switch(p_conv_data->i_octet_dlci_status)
1195                 {
1196                 case DLCI_PRESENT:
1197                     octet = tvb_get_guint8(tvb, offset);
1198                     proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_dlci1, tvb, offset, 1, ENC_BIG_ENDIAN);
1199                     proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_cr, tvb, offset, 1, ENC_BIG_ENDIAN);
1200                     proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_ea, tvb, offset, 1, ENC_BIG_ENDIAN);
1201                     offset++;
1202                     payload_length--;
1203                     /* check address extension... if ea bit == 0, then DLCI has another octet (see ITU-T V42 spec for more info) */
1204                     if (!(octet & 0x01))
1205                     {
1206                         proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_dlci2, tvb, offset, 1, ENC_BIG_ENDIAN);
1207                         proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_ea, tvb, offset, 1, ENC_BIG_ENDIAN);
1208                         offset++;
1209                         payload_length--;
1210                     }
1211                     ti = proto_tree_add_uint(sprt_payload_tree, hf_sprt_payload_i_octet_dlci_setup_by_connect_frame, tvb, 0, 0, p_conv_data->connect_frame_number);
1212                     PROTO_ITEM_SET_GENERATED(ti);
1213                     break;
1214                 case DLCI_ABSENT:
1215                     ti = proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_no_dlci, tvb, 0, 0, ENC_NA);
1216                     PROTO_ITEM_SET_GENERATED(ti);
1217                     ti = proto_tree_add_uint(sprt_payload_tree, hf_sprt_payload_i_octet_dlci_setup_by_connect_frame, tvb, 0, 0, p_conv_data->connect_frame_number);
1218                     PROTO_ITEM_SET_GENERATED(ti);
1219                     break;
1220                 case DLCI_UNKNOWN: /* e.g., we didn't see the CONNECT msg so we don't know if there is a DLCI */
1221                 default:
1222                     ti = proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_i_octet_dlci_presence_unknown, tvb, 0, 0, ENC_NA);
1223                     PROTO_ITEM_SET_GENERATED(ti);
1224                     break;
1225                 }
1226             }
1227             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
1228             break;
1229         case SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT: /* data */
1230             /* r: 1-bit reserved */
1231             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1232             /* D: 2-bit field indicating # of data bits */
1233             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_num_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1234             /* P: 3-bit field for parity type */
1235             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_parity_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1236             /* S: 2-bit field indicating # of stop bits */
1237             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_num_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1238             offset++;
1239             payload_length--;
1240             /* octets */
1241             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
1242             break;
1243         case SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN: /* data */
1244             /* r: 1-bit reserved */
1245             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1246             /* D: 2-bit field indicating # of data bits */
1247             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_num_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1248             /* P: 3-bit field for parity type */
1249             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_parity_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1250             /* S: 2-bit field indicating # of stop bits */
1251             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_num_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1252             offset++;
1253             payload_length--;
1254             /* octets */
1255             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
1256             break;
1257         case SPRT_MODEM_RELAY_MSG_ID_I_FRAME: /* data */
1258             /* R: 6 reserved bits */
1259             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_frame_reserved_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1260             /* Fr: data frame state */
1261             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_frame_state, tvb, offset, 1, ENC_BIG_ENDIAN);
1262             offset++;
1263             payload_length--;
1264             /* octets */
1265             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
1266             break;
1267         case SPRT_MODEM_RELAY_MSG_ID_I_OCTET_CS: /* data */
1268             /* CS: 2-byte character sequence number */
1269             /* TODO - does this msg type ever have a DLCI? */
1270             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
1271             offset += 2;
1272             payload_length -= 2;
1273             /* octets */
1274             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
1275             break;
1276         case SPRT_MODEM_RELAY_MSG_ID_I_CHAR_STAT_CS: /* data */
1277             /* r: 1-bit reserved */
1278             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1279             /* D: 2-bit field indicating # of data bits */
1280             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_num_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1281             /* P: 3-bit field for parity type */
1282             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_parity_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1283             /* S: 2-bit field indicating # of stop bits */
1284             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_num_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1285             offset++;
1286             payload_length--;
1287             /* CS: 2-byte character sequence number */
1288             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
1289             offset += 2;
1290             payload_length -= 2;
1291             /* octets */
1292             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
1293             break;
1294         case SPRT_MODEM_RELAY_MSG_ID_I_CHAR_DYN_CS: /* data */
1295             /* r: 1-bit reserved */
1296             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1297             /* D: 2-bit field indicating # of data bits */
1298             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_num_data_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1299             /* P: 3-bit field for parity type */
1300             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_parity_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1301             /* S: 2-bit field indicating # of stop bits */
1302             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_num_stop_bits, tvb, offset, 1, ENC_BIG_ENDIAN);
1303             offset++;
1304             payload_length--;
1305             /* CS: 2-byte character sequence number */
1306             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data_cs, tvb, offset, 2, ENC_BIG_ENDIAN);
1307             offset += 2;
1308             payload_length -= 2;
1309             /* octets */
1310             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
1311             break;
1312         default:
1313             proto_tree_add_item(sprt_payload_tree, hf_sprt_payload_data, tvb, offset, payload_length, ENC_NA);
1314             break;
1315         }
1316     } else {
1317         proto_tree_add_item(sprt_tree, hf_sprt_payload_no_data, tvb, offset, 0, ENC_NA);
1318         col_append_str(pinfo->cinfo, COL_INFO, ", No Payload");
1319     }
1320
1321     return offset;
1322 }
1323
1324 static int
1325 dissect_sprt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1326 {
1327     /* Set up structures needed to add the protocol subtree and manage it */
1328     proto_item *ti;
1329     proto_tree *sprt_tree = NULL;
1330     proto_tree *sprt_ack_field_tree;
1331     guint16 word1;
1332     unsigned int offset = 0;
1333     guint payload_length;
1334     struct _sprt_conversation_info *p_conv_data = NULL;
1335     int i;
1336
1337     guint16 tc;
1338     guint16 seqnum; /* 0 if TC = 0 or if no payload */
1339     guint16 noa;
1340     /* ack fields */
1341     /*guint16 tcn;*/
1342     /*guint16 sqn;*/
1343
1344     /* Make entries in Protocol column and Info column on summary display */
1345     col_set_str(pinfo->cinfo, COL_PROTOCOL, "SPRT");
1346     col_clear(pinfo->cinfo, COL_INFO);
1347
1348     if (tree)
1349     {
1350         /* create the trees */
1351         ti = proto_tree_add_item(tree, proto_sprt, tvb, 0, -1, ENC_NA);
1352         sprt_tree = proto_item_add_subtree(ti, ett_sprt);
1353
1354         /* show conversation setup info */
1355         if (global_sprt_show_setup_info)
1356         {
1357             show_setup_info(tvb, pinfo, sprt_tree);
1358         }
1359     }
1360
1361     /*SPRT header packet format
1362     +------+-------+-------+-------+-------+-------+---------+-------+
1363     |0     |1      |2      |3      |4      |5      |6          |7    |
1364     +------+-------+-------+-------+-------+-------+---------+-------+
1365     | X    |             SSID                                        |
1366     +----------------------------------------------------------------+
1367     | R    |             PT                                          |
1368     +--------------+-------------------------------------------------+
1369     | TC           |   Sequence Number                               |
1370     +--------------+-------------------------------------------------+
1371     |            Sequence Number                                     |
1372     +----------------------------------------------------------------+
1373     | NOA          |   Base Sequence Number                          |
1374     +--------------+-------------------------------------------------+
1375     |            Base Sequence Number                                |
1376     +----------------------------------------------------------------+
1377     | TCN          |   SQN                                           |
1378     +--------------+-------------------------------------------------+
1379     |            SQN                                                 |
1380     +----------------------------------------------------------------+
1381     | TCN          |   SQN                                           |
1382     +--------------+-------------------------------------------------+
1383     |            SQN                                                 |
1384     +----------------------------------------------------------------+
1385     | TCN          |   SQN                                           |
1386     +--------------+-------------------------------------------------+
1387     |            SQN                                                 |
1388     +----------------------------------------------------------------+
1389     */
1390
1391     /* Get fields needed for further dissection */
1392     word1 = tvb_get_ntohs(tvb, offset + 2);
1393     tc = (word1 & 0xC000) >> 14;
1394     seqnum = word1 & 0x3FFF;
1395
1396     noa = (tvb_get_ntohs(tvb, offset + 4) & 0xC000) >> 14;
1397
1398     /* Get conversation data, or create it if not found */
1399     p_conv_data = find_sprt_conversation_data(pinfo);
1400     if (!p_conv_data)
1401     {
1402         sprt_add_address(pinfo,
1403             &pinfo->src, pinfo->srcport,
1404             0,
1405             "SPRT stream",
1406             pinfo->num);
1407         p_conv_data = find_sprt_conversation_data(pinfo);
1408     }
1409
1410     proto_tree_add_item(sprt_tree, hf_sprt_header_extension_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1411     proto_tree_add_item(sprt_tree, hf_sprt_subsession_id, tvb, offset, 1, ENC_BIG_ENDIAN);
1412     offset++;
1413
1414     proto_tree_add_item(sprt_tree, hf_sprt_reserved_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1415     proto_tree_add_item(sprt_tree, hf_sprt_payload_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1416     offset++;
1417
1418     proto_tree_add_item(sprt_tree, hf_sprt_transport_channel_id, tvb, offset, 2, ENC_BIG_ENDIAN);
1419     ti = proto_tree_add_item(sprt_tree, hf_sprt_sequence_number, tvb, offset, 2, ENC_BIG_ENDIAN);
1420     if (tc == 0 && seqnum != 0)
1421         expert_add_info(pinfo, ti, &ei_sprt_sequence_number_0);
1422
1423     p_conv_data->seqnum[tc] = seqnum; /* keep track of seqnum values */
1424     offset+=2;
1425
1426     proto_tree_add_item(sprt_tree, hf_sprt_number_of_ack_fields, tvb, offset, 2, ENC_BIG_ENDIAN);
1427     proto_tree_add_item(sprt_tree, hf_sprt_base_sequence_number, tvb, offset, 2, ENC_BIG_ENDIAN);
1428     offset+=2;
1429
1430     if (noa) /* parse ack fields? There can be 0 - 3 */
1431     {
1432         ti = proto_tree_add_item(sprt_tree, hf_sprt_ack_field_items, tvb, offset, 2, ENC_BIG_ENDIAN);
1433         sprt_ack_field_tree = proto_item_add_subtree(ti, ett_sprt_ack_fields);
1434
1435         for(i = 0; i < noa; i++)
1436         {
1437             proto_tree_add_item(sprt_ack_field_tree, hf_sprt_transport_channel_item, tvb, offset, 2, ENC_BIG_ENDIAN);
1438             proto_tree_add_item(sprt_ack_field_tree, hf_sprt_sequence_item, tvb, offset, 2, ENC_BIG_ENDIAN);
1439             offset += 2;
1440         }
1441     }
1442
1443     /* put details in the info column */
1444     col_append_fstr(pinfo->cinfo, COL_INFO, "TC=%u", tc);
1445     if (tc != 0)
1446         col_append_fstr(pinfo->cinfo, COL_INFO, ", Seq=%u", seqnum);
1447
1448     /* dissect the payload, if any */
1449     payload_length = tvb_captured_length(tvb) - (6 + noa * 2); /* total sprt length - header stuff */
1450     dissect_sprt_data(tvb, pinfo, p_conv_data, sprt_tree, offset, payload_length);
1451
1452     if (noa)
1453         col_append_str(pinfo->cinfo, COL_INFO, " (ACK fields present)");
1454
1455     return tvb_captured_length(tvb);
1456 }
1457
1458 /* heuristic dissector */
1459 static gboolean
1460 dissect_sprt_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
1461 {
1462     guint8 octet, extension_bit, reserved_bit, payload_type;
1463     guint16 word, tc, seqnum;
1464     unsigned int offset = 0;
1465
1466     /* This is a heuristic dissector, which means we get all the UDP
1467      * traffic not sent to a known dissector and not claimed by
1468      * a heuristic dissector called before us!
1469      */
1470
1471     if (tvb_captured_length(tvb) < 6)
1472         return FALSE; /* packet is waay to short */
1473
1474     /* Get the fields in the first two octets */
1475     extension_bit = tvb_get_guint8(tvb, offset) & 0x7F;
1476     if (extension_bit != 0) /* must be 0 */
1477         return FALSE;
1478
1479     octet = tvb_get_guint8(tvb, offset + 1);
1480     reserved_bit = octet & 80;
1481     payload_type = octet & 0x7F;
1482     if (reserved_bit != 0) /* must be 0 */
1483         return FALSE;
1484     if (payload_type < 96 || payload_type > 128) /* value within RTP dynamic payload type range */
1485         return FALSE;
1486
1487     word = tvb_get_ntohs(tvb, offset + 2);
1488     tc = word >> 14;
1489     seqnum = word & 0x3F;
1490     if ((tc == 0 || tc == 3) && (seqnum != 0)) /* seqnum only applies if tc is 1 or 2 */
1491         return FALSE;
1492
1493     dissect_sprt(tvb, pinfo, tree, NULL);
1494     return TRUE;
1495 }
1496
1497 /* register the protocol with Wireshark */
1498 void
1499 proto_register_sprt(void)
1500 {
1501     module_t *sprt_module;
1502     expert_module_t* expert_sprt;
1503
1504     static hf_register_info hf[] =
1505     {
1506         /* set up fields */
1507         {
1508             &hf_sprt_setup,
1509             {
1510                 "Stream setup",
1511                 "sprt.setup",
1512                 FT_STRING,
1513                 BASE_NONE,
1514                 NULL,
1515                 0x0,
1516                 "Stream setup, method and frame number", HFILL
1517             }
1518         },
1519         {
1520             &hf_sprt_setup_frame,
1521             {
1522                 "Setup frame",
1523                 "sprt.setup-frame",
1524                 FT_FRAMENUM,
1525                 BASE_NONE,
1526                 NULL,
1527                 0x0,
1528                 "Frame that set up this stream", HFILL
1529             }
1530         },
1531         {
1532             &hf_sprt_setup_method,
1533             {
1534                 "Setup Method",
1535                 "sprt.setup-method",
1536                 FT_STRING,
1537                 BASE_NONE,
1538                 NULL,
1539                 0x0,
1540                 "Method used to set up this stream", HFILL
1541             }
1542         },
1543         /* SPRT header fields: */
1544         {
1545             &hf_sprt_header_extension_bit,
1546             {
1547                 "Header extension bit",
1548                 "sprt.x",
1549                 FT_BOOLEAN,
1550                 8,
1551                 TFS(&tfs_set_notset),
1552                 0x80,
1553                 NULL, HFILL
1554             }
1555         },
1556         {
1557             &hf_sprt_subsession_id,
1558             {
1559                 "Sub session ID",
1560                 "sprt.ssid",
1561                 FT_UINT8,
1562                 BASE_DEC,
1563                 NULL,
1564                 0x7F,
1565                 NULL, HFILL
1566             }
1567         },
1568         {
1569             &hf_sprt_reserved_bit,
1570             {
1571                 "Reserved bit",
1572                 "sprt.reserved",
1573                 FT_BOOLEAN,
1574                 8,
1575                 TFS(&tfs_set_notset),
1576                 0x80,
1577                 NULL, HFILL
1578             }
1579         },
1580         {
1581             &hf_sprt_payload_type,
1582             {
1583                 "Payload type",
1584                 "sprt.pt",
1585                 FT_UINT8,
1586                 BASE_DEC,
1587                 NULL,
1588                 0x7F,
1589                 NULL, HFILL
1590             }
1591         },
1592         {
1593             &hf_sprt_transport_channel_id,
1594             {
1595                 "Transport channel ID",
1596                 "sprt.tc",
1597                 FT_UINT16,
1598                 BASE_DEC,
1599                 VALS(sprt_transport_channel_characteristics),
1600                 0xC000,
1601                 NULL, HFILL
1602             }
1603         },
1604         {
1605             &hf_sprt_sequence_number,
1606             {
1607                 "Sequence number",
1608                 "sprt.seq",
1609                 FT_UINT16,
1610                 BASE_DEC,
1611                 NULL,
1612                 0x3FFF,
1613                 NULL, HFILL
1614             }
1615         },
1616         {
1617             &hf_sprt_number_of_ack_fields,
1618             {
1619                 "Number of ACK fields",
1620                 "sprt.noa",
1621                 FT_UINT16,
1622                 BASE_DEC,
1623                 NULL,
1624                 0xC000,
1625                 NULL, HFILL
1626             }
1627         },
1628         {
1629             &hf_sprt_base_sequence_number,
1630             {
1631                 "Base sequence number",
1632                 "sprt.bsqn",
1633                 FT_UINT16,
1634                 BASE_DEC,
1635                 NULL,
1636                 0x3FFF,
1637                 NULL, HFILL
1638             }
1639         },
1640         /* ACK fields, if any: */
1641         {
1642             &hf_sprt_ack_field_items, /* 0 to 3 items (TCN + SQN) */
1643             {
1644                 "ACK fields",
1645                 "sprt.ack.field",
1646                 FT_UINT16,
1647                 BASE_DEC,
1648                 NULL,
1649                 0xC000,
1650                 NULL, HFILL
1651             }
1652         },
1653         {
1654             &hf_sprt_transport_channel_item,
1655             {
1656                 "Transport control channel",
1657                 "sprt.tcn",
1658                 FT_UINT16,
1659                 BASE_DEC,
1660                 NULL,
1661                 0xC000,
1662                 NULL, HFILL
1663             }
1664         },
1665         {
1666             &hf_sprt_sequence_item,
1667             {
1668                 "Sequence number",
1669                 "sprt.sqn",
1670                 FT_UINT16,
1671                 BASE_DEC,
1672                 NULL,
1673                 0x3FFF,
1674                 NULL, HFILL
1675             }
1676         },
1677         /* SPRT payload, if any: */
1678         {
1679             &hf_sprt_payload_length,
1680             {
1681                 "Payload (in bytes)",
1682                 "sprt.payload.length",
1683                 FT_UINT32,
1684                 BASE_DEC,
1685                 NULL,
1686                 0x0,
1687                 NULL, HFILL
1688             }
1689         },
1690         {
1691             &hf_sprt_payload_no_data,
1692             {
1693                 "No payload",
1694                 "sprt.payload",
1695                 FT_NONE,
1696                 BASE_NONE,
1697                 NULL,
1698                 0x0,
1699                 NULL, HFILL
1700             }
1701         },
1702         {
1703             &hf_sprt_payload_reserved_bit,
1704             {
1705                 "Reserved bit",
1706                 "sprt.payload.reserved_bit",
1707                 FT_BOOLEAN,
1708                 8,
1709                 TFS(&tfs_set_notset),
1710                 0x80,
1711                 NULL, HFILL
1712             }
1713         },
1714         {
1715             &hf_sprt_payload_message_id,
1716             {
1717                 "Payload message ID",
1718                 "sprt.payload.msgid",
1719                 FT_UINT8,
1720                 BASE_DEC | BASE_RANGE_STRING,
1721                 RVALS(sprt_modem_relay_msg_id_name),
1722                 0x7F,
1723                 NULL, HFILL
1724             }
1725         },
1726         /* SPRT payload fields, if any (depend on payload msgid): */
1727         /* INIT message */
1728         {
1729             &hf_sprt_payload_msg_init_all_fields,
1730             {
1731                 "Init message fields",
1732                 "sprt.payload.msg_init.all_fields",
1733                 FT_UINT16,
1734                 BASE_HEX,
1735                 NULL,
1736                 0xFFFF, /* 0x0 */
1737                 NULL, HFILL
1738             }
1739         },
1740         {
1741             &hf_sprt_payload_msg_init_necrxch,
1742             {
1743                 "NECRxCH",
1744                 "sprt.payload.msg_init.NECRxCH",
1745                 FT_BOOLEAN,
1746                 16,
1747                 NULL,
1748                 0x8000,
1749                 NULL, HFILL
1750             }
1751         },
1752         {
1753             &hf_sprt_payload_msg_init_ecrxch,
1754             {
1755                 "ECRxCH",
1756                 "sprt.payload.msg_init.ECRxCH",
1757                 FT_BOOLEAN,
1758                 16,
1759                 NULL,
1760                 0x4000,
1761                 NULL, HFILL
1762             }
1763         },
1764         {
1765             &hf_sprt_payload_msg_init_xid_prof_exch,
1766             {
1767                 "XID profile exchange",
1768                 "sprt.payload.msg_init.XID_profile_exch",
1769                 FT_BOOLEAN,
1770                 16,
1771                 TFS(&tfs_supported_not_supported),
1772                 0x2000,
1773                 NULL, HFILL
1774             }
1775         },
1776         {
1777             &hf_sprt_payload_msg_init_assym_data_types,
1778             {
1779                 "Asymmetrical data types",
1780                 "sprt.payload.msg_init.assym_data_types",
1781                 FT_BOOLEAN,
1782                 16,
1783                 TFS(&tfs_supported_not_supported),
1784                 0x1000,
1785                 NULL, HFILL
1786             }
1787         },
1788         {
1789             &hf_sprt_payload_msg_init_opt_moip_types_i_raw_bit,
1790             {
1791                 "I_RAW-BIT",
1792                 "sprt.payload.msg_init.opt_moip_types_i_raw_bit",
1793                 FT_BOOLEAN,
1794                 16,
1795                 TFS(&tfs_supported_not_supported),
1796                 0x0800,
1797                 NULL, HFILL
1798             }
1799         },
1800         {
1801             &hf_sprt_payload_msg_init_opt_moip_types_i_frame,
1802             {
1803                 "I_FRAME",
1804                 "sprt.payload.msg_init.opt_moip_types_i_frame",
1805                 FT_BOOLEAN,
1806                 16,
1807                 TFS(&tfs_supported_not_supported),
1808                 0x0400,
1809                 NULL, HFILL
1810             }
1811         },
1812         {
1813             &hf_sprt_payload_msg_init_opt_moip_types_i_char_stat,
1814             {
1815                 "I_CHAR-STAT",
1816                 "sprt.payload.msg_init.opt_moip_types_i_char_stat",
1817                 FT_BOOLEAN,
1818                 16,
1819                 TFS(&tfs_supported_not_supported),
1820                 0x0200,
1821                 NULL, HFILL
1822             }
1823         },
1824         {
1825             &hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn,
1826             {
1827                 "I_CHAR-DYN",
1828                 "sprt.payload.msg_init.opt_moip_types_i_char_dyn",
1829                 FT_BOOLEAN,
1830                 16,
1831                 TFS(&tfs_supported_not_supported),
1832                 0x0100,
1833                 NULL, HFILL
1834             }
1835         },
1836         {
1837             &hf_sprt_payload_msg_init_opt_moip_types_i_octet_cs,
1838             {
1839                 "I_OCTET-CS",
1840                 "sprt.payload.msg_init.opt_moip_types_i_octet_cs",
1841                 FT_BOOLEAN,
1842                 16,
1843                 TFS(&tfs_supported_not_supported),
1844                 0x0080,
1845                 NULL, HFILL
1846             }
1847         },
1848         {
1849             &hf_sprt_payload_msg_init_opt_moip_types_i_char_stat_cs,
1850             {
1851                 "I_CHAR-STAT-CS",
1852                 "sprt.payload.msg_init.opt_moip_types_i_char_stat_cs",
1853                 FT_BOOLEAN,
1854                 16,
1855                 TFS(&tfs_supported_not_supported),
1856                 0x0040,
1857                 NULL, HFILL
1858             }
1859         },
1860         {
1861             &hf_sprt_payload_msg_init_opt_moip_types_i_char_dyn_cs,
1862             {
1863                 "I_CHAR-DYN-CS",
1864                 "sprt.payload.msg_init.opt_moip_types_i_char_dyn_cs",
1865                 FT_BOOLEAN,
1866                 16,
1867                 TFS(&tfs_supported_not_supported),
1868                 0x0020,
1869                 NULL, HFILL
1870             }
1871         },
1872         {
1873             &hf_sprt_payload_msg_init_opt_moip_types_reserved,
1874             {
1875                 "Reserved for ITU-T",
1876                 "sprt.payload.msg_init.opt_moip_types_reserved",
1877                 FT_UINT16,
1878                 BASE_HEX,
1879                 NULL,
1880                 0x001F,
1881                 NULL, HFILL
1882             }
1883         },
1884         /* XID_XCHG message */
1885         {
1886             &hf_sprt_payload_msg_xidxchg_ecp,
1887             {
1888                 "Error correcting protocol",
1889                 "sprt.payload.msg_xidxchg.ecp",
1890                 FT_UINT8,
1891                 BASE_DEC | BASE_RANGE_STRING,
1892                 RVALS(sprt_ecp_name),
1893                 0x0,
1894                 NULL, HFILL
1895             }
1896         },
1897         {
1898             &hf_sprt_payload_msg_xidxchg_xidlr1_v42bis,
1899             {
1900                 "V.42 bis",
1901                 "sprt.payload.msg_xidxchg.xidlr1_v42bis",
1902                 FT_BOOLEAN,
1903                 8,
1904                 TFS(&tfs_supported_not_supported),
1905                 0x80,
1906                 NULL, HFILL
1907             }
1908         },
1909         {
1910             &hf_sprt_payload_msg_xidxchg_xidlr1_v44,
1911             {
1912                 "V.44",
1913                 "sprt.payload.msg_xidxchg.xidlr1_v44",
1914                 FT_BOOLEAN,
1915                 8,
1916                 TFS(&tfs_supported_not_supported),
1917                 0x40,
1918                 NULL, HFILL
1919             }
1920         },
1921         {
1922             &hf_sprt_payload_msg_xidxchg_xidlr1_mnp5,
1923             {
1924                 "MNP5",
1925                 "sprt.payload.msg_xidxchg.xidlr1_mnp5",
1926                 FT_BOOLEAN,
1927                 8,
1928                 TFS(&tfs_supported_not_supported),
1929                 0x20,
1930                 NULL, HFILL
1931             }
1932         },
1933         {
1934             &hf_sprt_payload_msg_xidxchg_xidlr1_reserved,
1935             {
1936                 "Reserved for ITU-T",
1937                 "sprt.payload.msg_xidxchg.xidlr1_reserved",
1938                 FT_UINT8,
1939                 BASE_HEX,
1940                 NULL,
1941                 0x1F,
1942                 NULL, HFILL
1943             }
1944         },
1945         {
1946             &hf_sprt_payload_msg_xidxchg_xidlr2_v42bis_compr_req,
1947             {
1948                 "V.42bis data compression request",
1949                 "sprt.payload.msg_xidxchg.xidlr2_v42bis_compr_req",
1950                 FT_UINT8,
1951                 BASE_DEC,
1952                 NULL,
1953                 0x0,
1954                 NULL, HFILL
1955             }
1956         },
1957         {
1958             &hf_sprt_payload_msg_xidxchg_xidlr3and4_v42bis_num_codewords,
1959             {
1960                 "V.42bis number of codewords",
1961                 "sprt.payload.msg_xidxchg.xidlr3and4_v42bis_num_codewords",
1962                 FT_UINT16,
1963                 BASE_DEC,
1964                 NULL,
1965                 0x0,
1966                 NULL, HFILL
1967             }
1968         },
1969         {
1970             &hf_sprt_payload_msg_xidxchg_xidlr5_v42bis_max_strlen,
1971             {
1972                 "V.42bis maximum string length",
1973                 "sprt.payload.msg_xidxchg.xidlr5_v42bis_max_strlen",
1974                 FT_UINT8,
1975                 BASE_DEC,
1976                 NULL,
1977                 0x0,
1978                 NULL, HFILL
1979             }
1980         },
1981         {
1982             &hf_sprt_payload_msg_xidxchg_xidlr6_v44_capability,
1983             {
1984                 "V.44 capability",
1985                 "sprt.payload.msg_xidxchg.xidlr6_v44_capability",
1986                 FT_UINT8,
1987                 BASE_DEC,
1988                 NULL,
1989                 0x0,
1990                 NULL, HFILL
1991             }
1992         },
1993         {
1994             &hf_sprt_payload_msg_xidxchg_xidlr7_v44_compr_req,
1995             {
1996                 "V.44 data compression request",
1997                 "sprt.payload.msg_xidxchg.xidlr7_v44_compr_req",
1998                 FT_UINT8,
1999                 BASE_DEC,
2000                 NULL,
2001                 0x0,
2002                 NULL, HFILL
2003             }
2004         },
2005         {
2006             &hf_sprt_payload_msg_xidxchg_xidlr8and9_v44_num_codewords_trans,
2007             {
2008                 "V.44 number of codewords in transmit direction",
2009                 "sprt.payload.msg_xidxchg.xidlr8and9_v44_num_codewords_trans",
2010                 FT_UINT16,
2011                 BASE_DEC,
2012                 NULL,
2013                 0x0,
2014                 NULL, HFILL
2015             }
2016         },
2017         {
2018             &hf_sprt_payload_msg_xidxchg_xidlr10and11_v44_num_codewords_recv,
2019             {
2020                 "V.44 number of codewords in receive direction",
2021                 "sprt.payload.msg_xidxchg.xidlr10and11_v44_num_codewords_recv",
2022                 FT_UINT16,
2023                 BASE_DEC,
2024                 NULL,
2025                 0x0,
2026                 NULL, HFILL
2027             }
2028         },
2029         {
2030             &hf_sprt_payload_msg_xidxchg_xidlr12_v44_max_strlen_trans,
2031             {
2032                 "V.44 maximum string length in transmit direction",
2033                 "sprt.payload.msg_xidxchg.xidlr12_v44_max_strlen_trans",
2034                 FT_UINT8,
2035                 BASE_DEC,
2036                 NULL,
2037                 0x0,
2038                 NULL, HFILL
2039             }
2040         },
2041         {
2042             &hf_sprt_payload_msg_xidxchg_xidlr13_v44_max_strlen_recv,
2043             {
2044                 "V.44 maximum string length in receive direction",
2045                 "sprt.payload.msg_xidxchg.xidlr13_v44_max_strlen_recv",
2046                 FT_UINT8,
2047                 BASE_DEC,
2048                 NULL,
2049                 0x0,
2050                 NULL, HFILL
2051             }
2052         },
2053         {
2054             &hf_sprt_payload_msg_xidxchg_xidlr14and15_v44_history_len_trans,
2055             {
2056                 "V.44 length of history in transmit direction",
2057                 "sprt.payload.msg_xidxchg.xidlr14and15_v44_history_len_trans",
2058                 FT_UINT16,
2059                 BASE_DEC,
2060                 NULL,
2061                 0x0,
2062                 NULL, HFILL
2063             }
2064         },
2065         {
2066             &hf_sprt_payload_msg_xidxchg_xidlr16and17_v44_history_len_recv,
2067             {
2068                 "V.44 length of history in receive direction",
2069                 "sprt.payload.msg_xidxchg.xidlr16and17_v44_history_len_recv",
2070                 FT_UINT16,
2071                 BASE_DEC,
2072                 NULL,
2073                 0x0,
2074                 NULL, HFILL
2075             }
2076         },
2077         /* JM_INFO message */
2078         {
2079             &hf_sprt_payload_msg_jminfo_category_data,
2080             {
2081                 "Category data",
2082                 "sprt.payload.msg_jminfo.category_data",
2083                 FT_UINT16,
2084                 BASE_DEC,
2085                 NULL,
2086                 0xFFFF,
2087                 NULL, HFILL
2088             }
2089         },
2090         {
2091             &hf_sprt_payload_msg_jminfo_category_id,
2092             {
2093                 "Category ID",
2094                 "sprt.payload.msg_jminfo.category_id",
2095                 FT_UINT16,
2096                 BASE_HEX,
2097                 VALS(sprt_jm_info_cat_id_name),
2098                 0xF000,
2099                 NULL, HFILL
2100             }
2101         },
2102         {
2103             &hf_sprt_payload_msg_jminfo_category_ext_info,
2104             {
2105                 "Unrecognized category data",
2106                 "sprt.payload.msg_jminfo.category_ext_info",
2107                 FT_UINT16,
2108                 BASE_DEC,
2109                 NULL,
2110                 0x0FFF,
2111                 NULL, HFILL
2112             }
2113         },
2114         {
2115             &hf_sprt_payload_msg_jminfo_unk_category_info,
2116             {
2117                 "Category extension data",
2118                 "sprt.payload.msg_jminfo.unk_category_info",
2119                 FT_UINT16,
2120                 BASE_DEC,
2121                 NULL,
2122                 0x0FFF,
2123                 NULL, HFILL
2124             }
2125         },
2126         {
2127             &hf_sprt_payload_msg_jminfo_category_leftover_bits,
2128             {
2129                 "Leftover bits", /* "Category info leftover bits", */
2130                 "sprt.payload.msg_jminfo.category_leftover_bits",
2131                 FT_UINT16,
2132                 BASE_HEX,
2133                 NULL,
2134                 0x01FF,
2135                 NULL, HFILL
2136             }
2137         },
2138         {
2139             &hf_sprt_payload_msg_jminfo_call_function,
2140             {
2141                 "Call function",
2142                 "sprt.payload.msg_jminfo.call_function",
2143                 FT_UINT16,
2144                 BASE_DEC,
2145                 VALS(sprt_jminfo_tbc_call_funct_name),
2146                 0x0E00,
2147                 NULL, HFILL
2148             }
2149         },
2150         {
2151             &hf_sprt_payload_msg_jminfo_mod_v34_duplex,
2152             {
2153                 "V.34 duplex",
2154                 "sprt.payload.msg_jminfo.mod_v34_duplex",
2155                 FT_BOOLEAN,
2156                 16,
2157                 TFS(&tfs_available_not_available),
2158                 0x0800,
2159                 NULL, HFILL
2160             }
2161         },
2162         {
2163             &hf_sprt_payload_msg_jminfo_mod_v34_half_duplex,
2164             {
2165                 "V.34 half-duplex",
2166                 "sprt.payload.msg_jminfo.mod_v34_half_duplex",
2167                 FT_BOOLEAN,
2168                 16,
2169                 TFS(&tfs_available_not_available),
2170                 0x0400,
2171                 NULL, HFILL
2172             }
2173         },
2174         {
2175             &hf_sprt_payload_msg_jminfo_mod_v32bis_v32,
2176             {
2177                 "V.32bis/V.32",
2178                 "sprt.payload.msg_jminfo.mod_v32bis_v32",
2179                 FT_BOOLEAN,
2180                 16,
2181                 TFS(&tfs_available_not_available),
2182                 0x0200,
2183                 NULL, HFILL
2184             }
2185         },
2186         {
2187             &hf_sprt_payload_msg_jminfo_mod_v22bis_v22,
2188             {
2189                 "V.22bis/V.22",
2190                 "sprt.payload.msg_jminfo.mod_v22bis_v22",
2191                 FT_BOOLEAN,
2192                 16,
2193                 TFS(&tfs_available_not_available),
2194                 0x0100,
2195                 NULL, HFILL
2196             }
2197         },
2198         {
2199             &hf_sprt_payload_msg_jminfo_mod_v17,
2200             {
2201                 "V.17",
2202                 "sprt.payload.msg_jminfo.mod_v17",
2203                 FT_BOOLEAN,
2204                 16,
2205                 TFS(&tfs_available_not_available),
2206                 0x0080,
2207                 NULL, HFILL
2208             }
2209         },
2210         {
2211             &hf_sprt_payload_msg_jminfo_mod_v29_half_duplex,
2212             {
2213                 "V.29 half-duplex",
2214                 "sprt.payload.msg_jminfo.mod_v29_half_duplex",
2215                 FT_BOOLEAN,
2216                 16,
2217                 TFS(&tfs_available_not_available),
2218                 0x0040,
2219                 NULL, HFILL
2220             }
2221         },
2222         {
2223             &hf_sprt_payload_msg_jminfo_mod_v27ter,
2224             {
2225                 "V.27ter",
2226                 "sprt.payload.msg_jminfo.mod_v27ter",
2227                 FT_BOOLEAN,
2228                 16,
2229                 TFS(&tfs_available_not_available),
2230                 0x0020,
2231                 NULL, HFILL
2232             }
2233         },
2234         {
2235             &hf_sprt_payload_msg_jminfo_mod_v26ter,
2236             {
2237                 "V.26ter",
2238                 "sprt.payload.msg_jminfo.mod_v26ter",
2239                 FT_BOOLEAN,
2240                 16,
2241                 TFS(&tfs_available_not_available),
2242                 0x0010,
2243                 NULL, HFILL
2244             }
2245         },
2246         {
2247             &hf_sprt_payload_msg_jminfo_mod_v26bis,
2248             {
2249                 "V.26bis",
2250                 "sprt.payload.msg_jminfo.mod_v16bis",
2251                 FT_BOOLEAN,
2252                 16,
2253                 TFS(&tfs_available_not_available),
2254                 0x0008,
2255                 NULL, HFILL
2256             }
2257         },
2258         {
2259             &hf_sprt_payload_msg_jminfo_mod_v23_duplex,
2260             {
2261                 "V.23 duplex",
2262                 "sprt.payload.msg_jminfo.mod_v23_duplex",
2263                 FT_BOOLEAN,
2264                 16,
2265                 TFS(&tfs_available_not_available),
2266                 0x0004,
2267                 NULL, HFILL
2268             }
2269         },
2270         {
2271             &hf_sprt_payload_msg_jminfo_mod_v23_half_duplex,
2272             {
2273                 "V.23 half-duplex",
2274                 "sprt.payload.msg_jminfo.mod_v23_half_duplex",
2275                 FT_BOOLEAN,
2276                 16,
2277                 TFS(&tfs_available_not_available),
2278                 0x0002,
2279                 NULL, HFILL
2280             }
2281         },
2282         {
2283             &hf_sprt_payload_msg_jminfo_mod_v21,
2284             {
2285                 "V.21",
2286                 "sprt.payload.msg_jminfo.mod_v21",
2287                 FT_BOOLEAN,
2288                 16,
2289                 TFS(&tfs_available_not_available),
2290                 0x0001,
2291                 NULL, HFILL
2292             }
2293         },
2294         {
2295             &hf_sprt_payload_msg_jminfo_protocols,
2296             {
2297                 "Protocols",
2298                 "sprt.payload.msg_jminfo.protocols",
2299                 FT_UINT16,
2300                 BASE_DEC | BASE_RANGE_STRING,
2301                 RVALS(sprt_jminfo_tbc_protocol_name),
2302                 0x0E00,
2303                 NULL, HFILL
2304             }
2305         },
2306         {
2307             &hf_sprt_payload_msg_jminfo_pstn_access_call_dce_cell,
2308             {
2309                 "Call DCE is on a cellular connection",
2310                 "sprt.payload.msg_jminfo.pstn_access_call_dce_cell",
2311                 FT_BOOLEAN,
2312                 16,
2313                 NULL,
2314                 0x0800,
2315                 NULL, HFILL
2316             }
2317         },
2318         {
2319             &hf_sprt_payload_msg_jminfo_pstn_access_answ_dce_cell,
2320             {
2321                 "Answer DCE is on a cellular connection",
2322                 "sprt.payload.msg_jminfo.pstn_access_answ_dce_cell",
2323                 FT_BOOLEAN,
2324                 16,
2325                 NULL,
2326                 0x0400,
2327                 NULL, HFILL
2328             }
2329         },
2330         {
2331             &hf_sprt_payload_msg_jminfo_pstn_access_dce_on_digital_net,
2332             {
2333                 "DCE is on a digital network connection",
2334                 "sprt.payload.msg_jminfo.pstn_access_dce_on_digital_net",
2335                 FT_BOOLEAN,
2336                 16,
2337                 NULL,
2338                 0x0200,
2339                 NULL, HFILL
2340             }
2341         },
2342         {
2343             &hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_analog,
2344             {
2345                 "V.90 or V.92 analog modem availability",
2346                 "sprt.payload.msg_jminfo.pcm_modem_avail_v90_v92_analog",
2347                 FT_BOOLEAN,
2348                 16,
2349                 TFS(&tfs_available_not_available),
2350                 0x0800,
2351                 NULL, HFILL
2352             }
2353         },
2354         {
2355             &hf_sprt_payload_msg_jminfo_pcm_modem_avail_v90_v92_digital,
2356             {
2357                 "V.90 or V.92 digital modem availability",
2358                 "sprt.payload.msg_jminfo.pcm_modem_avail_v90_v92_digital",
2359                 FT_BOOLEAN,
2360                 16,
2361                 TFS(&tfs_available_not_available),
2362                 0x0400,
2363                 NULL, HFILL
2364             }
2365         },
2366         {
2367             &hf_sprt_payload_msg_jminfo_pcm_modem_avail_v91,
2368             {
2369                 "V.91 modem availability",
2370                 "sprt.payload.msg_jminfo.pcm_modem_avail_v91",
2371                 FT_BOOLEAN,
2372                 16,
2373                 TFS(&tfs_available_not_available),
2374                 0x0200,
2375                 NULL, HFILL
2376             }
2377         },
2378         /* START_JM message has no additional fields */
2379         /* CONNECT message */
2380         {
2381             &hf_sprt_payload_msg_connect_selmod,
2382             {
2383                 "Selected modulation",
2384                 "sprt.payload.msg_connect.selmod",
2385                 FT_UINT8,
2386                 BASE_DEC | BASE_RANGE_STRING,
2387                 RVALS(sprt_selmod_name),
2388                 0xFC,
2389                 NULL, HFILL
2390             }
2391         },
2392         {
2393             &hf_sprt_payload_msg_connect_compr_dir,
2394             {
2395                 "Compression direction",
2396                 "sprt.payload.msg_connect.compr_dir",
2397                 FT_UINT8,
2398                 BASE_DEC,
2399                 VALS(sprt_comp_direction),
2400                 0x03,
2401                 NULL, HFILL
2402             }
2403         },
2404         {
2405             &hf_sprt_payload_msg_connect_selected_compr,
2406             {
2407                 "Selected compression",
2408                 "sprt.payload.msg_connect.selected_compr",
2409                 FT_UINT8,
2410                 BASE_DEC | BASE_RANGE_STRING,
2411                 RVALS(sprt_selected_compr_name),
2412                 0xF0,
2413                 NULL, HFILL
2414             }
2415         },
2416         {
2417             &hf_sprt_payload_msg_connect_selected_err_corr,
2418             {
2419                 "Selected error correction",
2420                 "sprt.payload.msg_connect.selected_err_corr",
2421                 FT_UINT8,
2422                 BASE_DEC | BASE_RANGE_STRING,
2423                 RVALS(sprt_selected_err_corr_name),
2424                 0x0F,
2425                 NULL, HFILL
2426             }
2427         },
2428         {
2429             &hf_sprt_payload_msg_connect_tdsr,
2430             {
2431                 "Transmit data signalling rate (bits/sec)",
2432                 "sprt.payload.msg_connect.tdsr",
2433                 FT_UINT16,
2434                 BASE_DEC,
2435                 NULL,
2436                 0x0,
2437                 NULL, HFILL
2438             }
2439         },
2440         {
2441             &hf_sprt_payload_msg_connect_rdsr,
2442             {
2443                 "Receive data signalling rate (bits/sec)",
2444                 "sprt.payload.msg_connect.rdsr",
2445                 FT_UINT16,
2446                 BASE_DEC,
2447                 NULL,
2448                 0x0,
2449                 NULL, HFILL
2450             }
2451         },
2452         {
2453             &hf_sprt_payload_msg_connect_dlci_enabled,
2454             {
2455                 "DLCI",
2456                 "sprt.payload.msg_connect.dlci_enabled",
2457                 FT_BOOLEAN,
2458                 16,
2459                 TFS(&tfs_enabled_disabled),
2460                 0x8000,
2461                 NULL, HFILL
2462             }
2463         },
2464         {
2465             &hf_sprt_payload_msg_connect_avail_data_types,
2466             {
2467                 "Available data types",
2468                 "sprt.payload.msg_connect.avail_data_types",
2469                 FT_UINT16,
2470                 BASE_HEX,
2471                 NULL,
2472                 0x7FFF,
2473                 NULL, HFILL
2474             }
2475         },
2476         {
2477             &hf_sprt_payload_msg_connect_adt_octet_no_format_no_dlci,
2478             {
2479                 "Octet w/o formatting with no DLCI",
2480                 "sprt.payload.msg_connect.adt_octet_no_format_no_dlci",
2481                 FT_BOOLEAN,
2482                 16,
2483                 TFS(&tfs_available_not_available),
2484                 0x4000,
2485                 NULL, HFILL
2486             }
2487         },
2488         {
2489             &hf_sprt_payload_msg_connect_adt_i_raw_bit,
2490             {
2491                 "I_RAW-BIT",
2492                 "sprt.payload.msg_connect.adt_i_raw_bit",
2493                 FT_BOOLEAN,
2494                 16,
2495                 TFS(&tfs_available_not_available),
2496                 0x2000,
2497                 NULL, HFILL
2498             }
2499         },
2500         {
2501             &hf_sprt_payload_msg_connect_adt_i_frame,
2502             {
2503                 "I_FRAME",
2504                 "sprt.payload.msg_connect.adt_i_frame",
2505                 FT_BOOLEAN,
2506                 16,
2507                 TFS(&tfs_available_not_available),
2508                 0x1000,
2509                 NULL, HFILL
2510             }
2511         },
2512         {
2513             &hf_sprt_payload_msg_connect_adt_i_char_stat,
2514             {
2515                 "I_CHAR-STAT",
2516                 "sprt.payload.msg_connect.adt_i_char_stat",
2517                 FT_BOOLEAN,
2518                 16,
2519                 TFS(&tfs_available_not_available),
2520                 0x0800,
2521                 NULL, HFILL
2522             }
2523         },
2524         {
2525             &hf_sprt_payload_msg_connect_adt_i_char_dyn,
2526             {
2527                 "I_CHAR-DYN",
2528                 "sprt.payload.msg_connect.adt_i_char_dyn",
2529                 FT_BOOLEAN,
2530                 16,
2531                 TFS(&tfs_available_not_available),
2532                 0x0400,
2533                 NULL, HFILL
2534             }
2535         },
2536         { /* from V.150.1 amendment 2 (5-2006): */
2537             &hf_sprt_payload_msg_connect_adt_i_octet_cs,
2538             {
2539                 "I_OCTET-CS",
2540                 "sprt.payload.msg_connect.adt_i_octet_cs",
2541                 FT_BOOLEAN,
2542                 16,
2543                 TFS(&tfs_available_not_available),
2544                 0x0200,
2545                 NULL, HFILL
2546             }
2547         },
2548         { /* from V.150.1 amendment 2 (5-2006): */
2549             &hf_sprt_payload_msg_connect_adt_i_char_stat_cs,
2550             {
2551                 "I_CHAR-STAT-CS",
2552                 "sprt.payload.msg_connect.adt_i_char_stat_cs",
2553                 FT_BOOLEAN,
2554                 16,
2555                 TFS(&tfs_available_not_available),
2556                 0x0100,
2557                 NULL, HFILL
2558             }
2559         },
2560         { /* from V.150.1 amendment 2 (5-2006): */
2561             &hf_sprt_payload_msg_connect_adt_i_char_dyn_cs,
2562             {
2563                 "I_CHAR-DYN-CS",
2564                 "sprt.payload.msg_connect.adt_i_char_dyn_cs",
2565                 FT_BOOLEAN,
2566                 16,
2567                 TFS(&tfs_available_not_available),
2568                 0x0080,
2569                 NULL, HFILL
2570             }
2571         },
2572         {
2573             &hf_sprt_payload_msg_connect_adt_reserved,
2574             {
2575                 "Reserved for ITU-T",
2576                 "sprt.payload.msg_connect.adt_reserved",
2577                 FT_UINT16,
2578                 BASE_HEX,
2579                 NULL,
2580                 0x007F,
2581                 NULL, HFILL
2582             }
2583         },
2584         {
2585             &hf_sprt_payload_msg_connect_compr_trans_dict_sz,
2586             {
2587                 "Compression transmit dictionary size",
2588                 "sprt.payload.msg_connect.compr_trans_dict_sz",
2589                 FT_UINT16,
2590                 BASE_DEC,
2591                 NULL,
2592                 0x0,
2593                 NULL, HFILL
2594             }
2595         },
2596         {
2597             &hf_sprt_payload_msg_connect_compr_recv_dict_sz,
2598             {
2599                 "Compression receive dictionary size",
2600                 "sprt.payload.msg_connect.compr_recv_dict_sz",
2601                 FT_UINT16,
2602                 BASE_DEC,
2603                 NULL,
2604                 0x0,
2605                 NULL, HFILL
2606             }
2607         },
2608         {
2609             &hf_sprt_payload_msg_connect_compr_trans_str_len,
2610             {
2611                 "Compression transmit string length",
2612                 "sprt.payload.msg_connect.compr_trans_str_len",
2613                 FT_UINT8,
2614                 BASE_DEC,
2615                 NULL,
2616                 0x0,
2617                 NULL, HFILL
2618             }
2619         },
2620         {
2621             &hf_sprt_payload_msg_connect_compr_recv_str_len,
2622             {
2623                 "Compression receive string length",
2624                 "sprt.payload.msg_connect.compr_recv_str_len",
2625                 FT_UINT8,
2626                 BASE_DEC,
2627                 NULL,
2628                 0x0,
2629                 NULL, HFILL
2630             }
2631         },
2632         {
2633             &hf_sprt_payload_msg_connect_compr_trans_hist_sz,
2634             {
2635                 "Compression transmit history size",
2636                 "sprt.payload.msg_connect.compr_trans_hist_sz",
2637                 FT_UINT16,
2638                 BASE_DEC,
2639                 NULL,
2640                 0x0,
2641                 NULL, HFILL
2642             }
2643         },
2644         {
2645             &hf_sprt_payload_msg_connect_compr_recv_hist_sz,
2646             {
2647                 "Compression receive history size",
2648                 "sprt.payload.msg_connect.compr_recv_hist_sz",
2649                 FT_UINT16,
2650                 BASE_DEC,
2651                 NULL,
2652                 0x0,
2653                 NULL, HFILL
2654             }
2655         },
2656         /* BREAK message */
2657         {
2658             &hf_sprt_payload_msg_break_source_proto,
2659             {
2660                 "Break source protocol",
2661                 "sprt.payload.msg_break.source_proto",
2662                 FT_UINT8,
2663                 BASE_DEC | BASE_RANGE_STRING,
2664                 RVALS(sprt_break_src_proto_name),
2665                 0xF0,
2666                 NULL, HFILL
2667             }
2668         },
2669         {
2670             &hf_sprt_payload_msg_break_type,
2671             {
2672                 "Break type",
2673                 "sprt.payload.msg_break.type",
2674                 FT_UINT8,
2675                 BASE_DEC | BASE_RANGE_STRING,
2676                 RVALS(sprt_break_type_name),
2677                 0x0F,
2678                 NULL, HFILL
2679             }
2680         },
2681         {
2682             &hf_sprt_payload_msg_break_length,
2683             {
2684                 "Break length (x10 msec)",
2685                 "sprt.payload.msg_break.length",
2686                 FT_UINT8,
2687                 BASE_DEC,
2688                 NULL,
2689                 0x0,
2690                 NULL, HFILL
2691             }
2692         },
2693         /* BREAK_ACK message has no additional fields */
2694         /* MR_EVENT message */
2695         {
2696             &hf_sprt_payload_msg_mr_event_id,
2697             {
2698                 "Modem relay event ID",
2699                 "sprt.payload.msg_mr_event.id",
2700                 FT_UINT8,
2701                 BASE_DEC | BASE_RANGE_STRING,
2702                 RVALS(sprt_mrevent_id_name),
2703                 0x0,
2704                 NULL, HFILL
2705             }
2706         },
2707         {
2708             &hf_sprt_payload_msg_mr_evt_reason_code,
2709             {
2710                 "Reason code",
2711                 "sprt.payload.msg_mr_event.reason_code",
2712                 FT_UINT8,
2713                 BASE_DEC | BASE_RANGE_STRING,
2714                 RVALS(sprt_mrevent_reason_code_name),
2715                 0x0,
2716                 NULL, HFILL
2717             }
2718         },
2719         {
2720             &hf_sprt_payload_msg_mr_evt_selmod,
2721             {
2722                 "Selected modulation",
2723                 "sprt.payload.msg_mr_event.selmod",
2724                 FT_UINT8,
2725                 BASE_DEC | BASE_RANGE_STRING,
2726                 RVALS(sprt_selmod_name),
2727                 0xFC,
2728                 NULL, HFILL
2729             }
2730         },
2731         {
2732             &hf_sprt_payload_msg_mr_evt_txsen,
2733             {
2734                 "TxSEN",
2735                 "sprt.payload.msg_mr_event.txsen",
2736                 FT_BOOLEAN,
2737                 8,
2738                 TFS(&tfs_enabled_disabled),
2739                 0x02,
2740                 NULL, HFILL
2741             }
2742         },
2743         {
2744             &hf_sprt_payload_msg_mr_evt_rxsen,
2745             {
2746                 "RxSEN",
2747                 "sprt.payload.msg_mr_event.rxsen",
2748                 FT_BOOLEAN,
2749                 8,
2750                 TFS(&tfs_enabled_disabled),
2751                 0x01,
2752                 NULL, HFILL
2753             }
2754         },
2755         {
2756             &hf_sprt_payload_msg_mr_evt_tdsr,
2757             {
2758                 "Transmit data signalling rate (bits/sec)",
2759                 "sprt.payload.msg_mr_event.tdsr",
2760                 FT_UINT16,
2761                 BASE_DEC,
2762                 NULL,
2763                 0x0,
2764                 NULL, HFILL
2765             }
2766         },
2767         {
2768             &hf_sprt_payload_msg_mr_evt_rdsr,
2769             {
2770                 "Receive data signalling rate (bits/sec)",
2771                 "sprt.payload.msg_mr_event.rdsr",
2772                 FT_UINT16,
2773                 BASE_DEC,
2774                 NULL,
2775                 0x0,
2776                 NULL, HFILL
2777             }
2778         },
2779         {
2780             &hf_sprt_payload_msg_mr_evt_txsr,
2781             {
2782                 "Physical layer transmitter symbol rate (TxSR)",
2783                 "sprt.payload.msg_mr_event.txsr",
2784                 FT_UINT8,
2785                 BASE_DEC | BASE_RANGE_STRING,
2786                 RVALS(sprt_mrevent_phys_layer_symbol_rate),
2787                 0x0,
2788                 NULL, HFILL
2789             }
2790         },
2791         {
2792             &hf_sprt_payload_msg_mr_evt_rxsr,
2793             {
2794                 "Physical layer receiver symbol rate (RxSR)",
2795                 "sprt.payload.msg_mr_event.rxsr",
2796                 FT_UINT8,
2797                 BASE_DEC | BASE_RANGE_STRING,
2798                 RVALS(sprt_mrevent_phys_layer_symbol_rate),
2799                 0x0,
2800                 NULL, HFILL
2801             }
2802         },
2803         /* CLEARDOWN message */
2804         {
2805             &hf_sprt_payload_msg_cleardown_reason_code,
2806             {
2807                 "Reason code",
2808                 "sprt.payload.msg_cleardown.reason_code",
2809                 FT_UINT8,
2810                 BASE_DEC,
2811                 VALS(sprt_cleardown_reason),
2812                 0x0,
2813                 NULL, HFILL
2814             }
2815         },
2816         {
2817             &hf_sprt_payload_msg_cleardown_vendor_tag,
2818             {
2819                 "Vendor tag",
2820                 "sprt.payload.msg_cleardown.vendor_tag",
2821                 FT_UINT8,
2822                 BASE_DEC,
2823                 NULL,
2824                 0x0,
2825                 NULL, HFILL
2826             }
2827         },
2828         {
2829             &hf_sprt_payload_msg_cleardown_vendor_info,
2830             {
2831                 "Vendor info",
2832                 "sprt.payload.msg_cleardown.vendor_info",
2833                 FT_UINT8,
2834                 BASE_DEC,
2835                 NULL,
2836                 0x0,
2837                 NULL, HFILL
2838             }
2839         },
2840         /* PROF_XCHG message */
2841         {
2842             &hf_sprt_payload_msg_profxchg_v42_lapm,
2843             {
2844                 "V.42/LAPM protocol support",
2845                 "sprt.payload.msg_profxchg.v42_lapm",
2846                 FT_UINT8,
2847                 BASE_DEC,
2848                 VALS(sprt_prof_xchg_support),
2849                 0xC0,
2850                 NULL, HFILL
2851             }
2852         },
2853         {
2854             &hf_sprt_payload_msg_profxchg_annex_av42,
2855             {
2856                 "Annex A/V.42(1996) protocol support",
2857                 "sprt.payload.msg_profxchg.annex_av42",
2858                 FT_UINT8,
2859                 BASE_DEC,
2860                 VALS(sprt_prof_xchg_support),
2861                 0x30,
2862                 NULL, HFILL
2863             }
2864         },
2865         {
2866             &hf_sprt_payload_msg_profxchg_v44_compr,
2867             {
2868                 "V.44 compression support",
2869                 "sprt.payload.msg_profxchg.v44_compr",
2870                 FT_UINT8,
2871                 BASE_DEC,
2872                 VALS(sprt_prof_xchg_support),
2873                 0x0C,
2874                 NULL, HFILL
2875             }
2876         },
2877         {
2878             &hf_sprt_payload_msg_profxchg_v42bis_compr,
2879             {
2880                 "V.42bis compression support",
2881                 "sprt.payload.msg_profxchg.v42bis_compr",
2882                 FT_UINT8,
2883                 BASE_DEC,
2884                 VALS(sprt_prof_xchg_support),
2885                 0x03,
2886                 NULL, HFILL
2887             }
2888         },
2889         {
2890             &hf_sprt_payload_msg_profxchg_mnp5_compr,
2891             {
2892                 "MNP5 compression support",
2893                 "sprt.payload.msg_profxchg.mnp5_compr",
2894                 FT_UINT8,
2895                 BASE_DEC,
2896                 VALS(sprt_prof_xchg_support),
2897                 0xC0,
2898                 NULL, HFILL
2899             }
2900         },
2901         {
2902             &hf_sprt_payload_msg_profxchg_reserved,
2903             {
2904                 "Reserved for ITU-T",
2905                 "sprt.payload.msg_profxchg.reserved",
2906                 FT_UINT8,
2907                 BASE_HEX,
2908                 NULL,
2909                 0x3F,
2910                 NULL, HFILL
2911             }
2912         },
2913         {
2914             &hf_sprt_payload_msg_profxchg_xidlr2_v42bis_compr_req,
2915             {
2916                 "V.42bis data compression request",
2917                 "sprt.payload.msg_profxchg.xidlr2_v42bis_compr_req",
2918                 FT_UINT8,
2919                 BASE_DEC,
2920                 NULL,
2921                 0x0,
2922                 NULL, HFILL
2923             }
2924         },
2925         {
2926             &hf_sprt_payload_msg_profxchg_xidlr3and4_v42bis_num_codewords,
2927             {
2928                 "V.42bis number of codewords",
2929                 "sprt.payload.msg_profxchg.xidlr3and4_v42bis_num_codewords",
2930                 FT_UINT16,
2931                 BASE_DEC,
2932                 NULL,
2933                 0x0,
2934                 NULL, HFILL
2935             }
2936         },
2937         {
2938             &hf_sprt_payload_msg_profxchg_xidlr5_v42bis_max_strlen,
2939             {
2940                 "V.42bis maximum string length",
2941                 "sprt.payload.msg_profxchg.xidlr5_v42bis_max_strlen",
2942                 FT_UINT8,
2943                 BASE_DEC,
2944                 NULL,
2945                 0x0,
2946                 NULL, HFILL
2947             }
2948         },
2949         {
2950             &hf_sprt_payload_msg_profxchg_xidlr6_v44_capability,
2951             {
2952                 "V.44 capability",
2953                 "sprt.payload.msg_profxchg.xidlr6_v44_capability",
2954                 FT_UINT8,
2955                 BASE_DEC,
2956                 NULL,
2957                 0x0,
2958                 NULL, HFILL
2959             }
2960         },
2961         {
2962             &hf_sprt_payload_msg_profxchg_xidlr7_v44_compr_req,
2963             {
2964                 "V.44 data compression request",
2965                 "sprt.payload.msg_profxchg.xidlr7_v44_compr_req",
2966                 FT_UINT8,
2967                 BASE_DEC,
2968                 NULL,
2969                 0x0,
2970                 NULL, HFILL
2971             }
2972         },
2973         {
2974             &hf_sprt_payload_msg_profxchg_xidlr8and9_v44_num_codewords_trans,
2975             {
2976                 "V.44 number of codewords in transmit direction",
2977                 "sprt.payload.msg_profxchg.xidlr8and9_v44_num_codewords_trans",
2978                 FT_UINT16,
2979                 BASE_DEC,
2980                 NULL,
2981                 0x0,
2982                 NULL, HFILL
2983             }
2984         },
2985         {
2986             &hf_sprt_payload_msg_profxchg_xidlr10and11_v44_num_codewords_recv,
2987             {
2988                 "V.44 number of codewords in receive direction",
2989                 "sprt.payload.msg_profxchg.xidlr10and11_v44_num_codewords_recv",
2990                 FT_UINT16,
2991                 BASE_DEC,
2992                 NULL,
2993                 0x0,
2994                 NULL, HFILL
2995             }
2996         },
2997         {
2998             &hf_sprt_payload_msg_profxchg_xidlr12_v44_max_strlen_trans,
2999             {
3000                 "V.44 maximum string length in transmit direction",
3001                 "sprt.payload.msg_profxchg.xidlr12_v44_max_strlen_trans",
3002                 FT_UINT8,
3003                 BASE_DEC,
3004                 NULL,
3005                 0x0,
3006                 NULL, HFILL
3007             }
3008         },
3009         {
3010             &hf_sprt_payload_msg_profxchg_xidlr13_v44_max_strlen_recv,
3011             {
3012                 "V.44 maximum string length in receive direction",
3013                 "sprt.payload.msg_profxchg.xidlr13_v44_max_strlen_recv",
3014                 FT_UINT8,
3015                 BASE_DEC,
3016                 NULL,
3017                 0x0,
3018                 NULL, HFILL
3019             }
3020         },
3021         {
3022             &hf_sprt_payload_msg_profxchg_xidlr14and15_v44_history_len_trans,
3023             {
3024                 "V.44 length of history in transmit direction",
3025                 "sprt.payload.msg_profxchg.xidlr14and15_v44_history_len_trans",
3026                 FT_UINT16,
3027                 BASE_DEC,
3028                 NULL,
3029                 0x0,
3030                 NULL, HFILL
3031             }
3032         },
3033         {
3034             &hf_sprt_payload_msg_profxchg_xidlr16and17_v44_history_len_recv,
3035             {
3036                 "V.44 length of history in receive direction",
3037                 "sprt.payload.msg_profxchg.xidlr16and17_v44_history_len_recv",
3038                 FT_UINT16,
3039                 BASE_DEC,
3040                 NULL,
3041                 0x0,
3042                 NULL, HFILL
3043             }
3044         },
3045         /* User data messages... */
3046         /* I_OCTET message: need to use DLCI field (8 or 16 bits) if indicated by CONNECT message */
3047         {
3048             &hf_sprt_payload_i_octet_no_dlci,
3049             {
3050                 "No DLCI field",
3051                 "sprt.payload.i_octet_no_dlci",
3052                 FT_NONE,
3053                 BASE_NONE,
3054                 NULL,
3055                 0x0,
3056                 NULL, HFILL
3057             }
3058         },
3059         {
3060             &hf_sprt_payload_i_octet_dlci_presence_unknown,
3061             {
3062                 "Not known if DLCI field is present",
3063                 "sprt.payload.i_octet_dlci_presence_unknown",
3064                 FT_NONE,
3065                 BASE_NONE,
3066                 NULL,
3067                 0x0,
3068                 NULL, HFILL
3069             }
3070         },
3071         {
3072             &hf_sprt_payload_i_octet_dlci1,
3073             {
3074                 "DLCI #1",
3075                 "sprt.payload.i_octet_dlci1",
3076                 FT_UINT8,
3077                 BASE_DEC | BASE_RANGE_STRING,
3078                 RVALS(sprt_payload_dlci1),
3079                 0xFC,
3080                 NULL, HFILL
3081             }
3082         },
3083         {
3084             &hf_sprt_payload_i_octet_cr,
3085             {
3086                 "Command/response bit",
3087                 "sprt.payload.i_octet_cr",
3088                 FT_BOOLEAN,
3089                 8,
3090                 NULL,
3091                 0x02,
3092                 NULL, HFILL
3093             }
3094         },
3095         {
3096             &hf_sprt_payload_i_octet_ea,
3097             {
3098                 "Address field extension bit",
3099                 "sprt.payload.i_octet_ea",
3100                 FT_BOOLEAN,
3101                 8,
3102                 TFS(&sprt_payload_ea_bit),
3103                 0x01,
3104                 NULL, HFILL
3105             }
3106         },
3107         {
3108             &hf_sprt_payload_i_octet_dlci2,
3109             {
3110                 "DLCI #2",
3111                 "sprt.payload.i_octet_dlci2",
3112                 FT_UINT8,
3113                 BASE_DEC | BASE_RANGE_STRING,
3114                 RVALS(sprt_payload_dlci2),
3115                 0xFE,
3116                 NULL, HFILL
3117             }
3118         },
3119         {
3120             &hf_sprt_payload_i_octet_dlci_setup_by_connect_frame,
3121             {
3122                 "DLCI setup by CONNECT message at frame",
3123                 "sprt.payload.i_octet_dlci_setup_by_connect_frame",
3124                 FT_FRAMENUM,
3125                 BASE_NONE,
3126                 NULL,
3127                 0x0,
3128                 NULL, HFILL
3129             }
3130         },
3131         /* fields for I_RAW_OCTET message (L; L,N) */
3132         {
3133             &hf_sprt_payload_rawoctet_n_field_present,
3134             {
3135                 "N field",
3136                 "sprt.payload.rawoctet_n_field_present",
3137                 FT_BOOLEAN,
3138                 8,
3139                 TFS(&tfs_present_absent),
3140                 0x80,
3141                 NULL, HFILL
3142             }
3143         },
3144         {
3145             &hf_sprt_payload_rawoctet_l,
3146             {
3147                 "L: # of octets in segment minus one",
3148                 "sprt.payload.rawoctet_l",
3149                 FT_UINT8,
3150                 BASE_DEC,
3151                 NULL,
3152                 0x7F,
3153                 NULL, HFILL
3154             }
3155         },
3156         {
3157             &hf_sprt_payload_rawoctet_n,
3158             {
3159                 "N: # of times octets appear in data minus 2",
3160                 "sprt.payload.rawoctet_n",
3161                 FT_UINT8,
3162                 BASE_DEC,
3163                 NULL,
3164                 0xFF,
3165                 NULL, HFILL
3166             }
3167         },
3168         /* fields for I_RAW_BIT (L; L,P; L,P,N) */
3169         {
3170             &hf_sprt_payload_rawbit_included_fields_l,
3171             {
3172                 "Include field L only",
3173                 "sprt.payload.rawbit_included_fields_l",
3174                 FT_UINT8,
3175                 BASE_DEC,
3176                 NULL,
3177                 0xC0, /* top two bits: 00 */
3178                 NULL, HFILL
3179             }
3180         },
3181         {
3182             &hf_sprt_payload_rawbit_included_fields_lp,
3183             {
3184                 "Include fields L, P",
3185                 "sprt.payload.rawbit_field_format_lp",
3186                 FT_UINT8,
3187                 BASE_DEC,
3188                 NULL,
3189                 0xC0, /* top two bits: 01 */
3190                 NULL, HFILL
3191             }
3192         },
3193         {
3194             &hf_sprt_payload_rawbit_included_fields_lpn,
3195             {
3196                 "Include fields L, P, N",
3197                 "sprt.payload.rawbit_included_fields_lpn",
3198                 FT_UINT8,
3199                 BASE_DEC,
3200                 NULL,
3201                 0x80, /* top bit: 1 */
3202                 NULL, HFILL
3203             }
3204         },
3205         {
3206             &hf_sprt_payload_rawbit_len_a,
3207             {
3208                 "L: # of octets in segment",
3209                 "sprt.payload.rawbit_len_a",
3210                 FT_UINT8,
3211                 BASE_DEC,
3212                 NULL,
3213                 0x3F, /* six bits */
3214                 NULL, HFILL
3215             }
3216         },
3217         {
3218             &hf_sprt_payload_rawbit_len_b,
3219             {
3220                 "L: # of octets in segment",
3221                 "sprt.payload.rawbit_len_b",
3222                 FT_UINT8,
3223                 BASE_DEC,
3224                 NULL,
3225                 0x38, /* three bits */
3226                 NULL, HFILL
3227             }
3228         },
3229         {
3230             &hf_sprt_payload_rawbit_len_c,
3231             {
3232                 "L: # of octets in segment",
3233                 "sprt.payload.rawbit_len_c",
3234                 FT_UINT8,
3235                 BASE_DEC,
3236                 NULL,
3237                 0x78, /* four bits */
3238                 NULL, HFILL
3239             }
3240         },
3241         {
3242             &hf_sprt_payload_rawbit_p,
3243             {
3244                 "P: # of low-order bits in last octet that are not in segment",
3245                 "sprt.payload.rawbit_p",
3246                 FT_UINT8,
3247                 BASE_DEC,
3248                 NULL,
3249                 0x7, /* three bits */
3250                 NULL, HFILL
3251             }
3252         },
3253         {
3254             &hf_sprt_payload_rawbit_n,
3255             {
3256                 "N: # of times octets appear in data minus 2",
3257                 "sprt.payload.rawbit_n",
3258                 FT_UINT8,
3259                 BASE_DEC,
3260                 NULL,
3261                 0xFF, /* eight bits */
3262                 NULL, HFILL
3263             }
3264         },
3265         /* fields in I_CHAR_STAT & I_CHAR_DYN messages */
3266         {
3267             &hf_sprt_payload_data_reserved_bit,
3268             {
3269                 "Reserved bit",
3270                 "sprt.payload.reserved_bit",
3271                 FT_BOOLEAN,
3272                 8,
3273                 TFS(&tfs_set_notset),
3274                 0x80,
3275                 NULL, HFILL
3276             }
3277         },
3278         {
3279             &hf_sprt_payload_data_num_data_bits,
3280             {
3281                 "D: Number of data bits",
3282                 "sprt.payload.num_data_bits",
3283                 FT_UINT8,
3284                 BASE_DEC,
3285                 VALS(sprt_payload_data_bits),
3286                 0x60,
3287                 NULL, HFILL
3288             }
3289         },
3290         {
3291             &hf_sprt_payload_data_parity_type,
3292             {
3293                 "P: Parity type",
3294                 "sprt.payload.parity_type",
3295                 FT_UINT8,
3296                 BASE_DEC,
3297                 VALS(sprt_payload_parity),
3298                 0x1C,
3299                 NULL, HFILL
3300             }
3301         },
3302         {
3303             &hf_sprt_payload_num_stop_bits,
3304             {
3305                 "S: Number stop bits",
3306                 "sprt.payload.num_stop_bits",
3307                 FT_UINT8,
3308                 BASE_DEC,
3309                 VALS(sprt_payload_stop_bits),
3310                 0x03,
3311                 NULL, HFILL
3312             }
3313         },
3314         /* sequence field in I_OCTET_CS, I_CHAR_STAT_CS, & I_CHAR_DYN_CS messages */
3315         {
3316             &hf_sprt_payload_data_cs,
3317             {
3318                 "Character sequence number",
3319                 "sprt.payload.cs",
3320                 FT_UINT16,
3321                 BASE_DEC,
3322                 NULL,
3323                 0x0,
3324                 NULL, HFILL
3325             }
3326         },
3327         /* fields for I_FRAME: */
3328         {
3329             &hf_sprt_payload_frame_reserved_bits,
3330             {
3331                 "Reserved bits",
3332                 "sprt.payload.frame_reserved_bits",
3333                 FT_UINT8,
3334                 BASE_HEX,
3335                 NULL,
3336                 0xFC,
3337                 NULL, HFILL
3338             }
3339         },
3340         {
3341             &hf_sprt_payload_frame_state,
3342             {
3343                 "Frame state",
3344                 "sprt.payload.frame_state",
3345                 FT_UINT8,
3346                 BASE_DEC,
3347                 VALS(sprt_payload_frame_state),
3348                 0x03,
3349                 NULL, HFILL
3350             }
3351         },
3352         /* just dump remaining payload data: */
3353         {
3354             &hf_sprt_payload_data,
3355             {
3356                 "Payload data",
3357                 "sprt.payload.data",
3358                 FT_BYTES,
3359                 BASE_NONE,
3360                 NULL,
3361                 0x0,
3362                 NULL, HFILL
3363             }
3364         },
3365     }; /* hf_register_info hf[] */
3366
3367     /* setup protocol subtree array */
3368     static gint *ett[] = {
3369         &ett_sprt,
3370         &ett_sprt_setup,
3371         &ett_sprt_ack_fields,
3372         &ett_payload,
3373         &ett_init_msg_all_fields,
3374         &ett_jminfo_msg_cat_data,
3375         &ett_connect_msg_adt
3376     };
3377
3378     static ei_register_info ei[] = {
3379         { &ei_sprt_sequence_number_0, { "sprt.sequence_number_0", PI_PROTOCOL, PI_WARN, "Should be 0 for transport channel 0", EXPFILL }},
3380     };
3381
3382     /* register protocol name & description */
3383     proto_sprt = proto_register_protocol("Simple Packet Relay Transport", "SPRT", "sprt");
3384
3385     /* required function calls to register the header fields and subtrees used */
3386     proto_register_field_array(proto_sprt, hf, array_length(hf));
3387     proto_register_subtree_array(ett, array_length(ett));
3388     expert_sprt = expert_register_protocol(proto_sprt);
3389     expert_register_field_array(expert_sprt, ei, array_length(ei));
3390
3391     /* register the dissector */
3392     sprt_handle = register_dissector("sprt", dissect_sprt, proto_sprt);
3393
3394     sprt_module = prefs_register_protocol(proto_sprt, NULL);
3395
3396     /* preferences */
3397     prefs_register_bool_preference(sprt_module, "show_setup_info",
3398                                     "Show stream setup information",
3399                                     "Where available, show which protocol and frame caused "
3400                                     "this SPRT stream to be created",
3401                                     &global_sprt_show_setup_info);
3402     prefs_register_bool_preference(sprt_module, "show_dlci_info",
3403                                     "Show DLCI in I_OCTET messages",
3404                                     "Show the DLCI field in I_OCTET messages as well as the frame that "
3405                                     "enabled/disabled the DLCI",
3406                                     &global_sprt_show_dlci_info);
3407
3408 }
3409
3410 void
3411 proto_reg_handoff_sprt(void)
3412 {
3413     dissector_add_for_decode_as_with_preference("udp.port", sprt_handle);
3414
3415     heur_dissector_add( "udp", dissect_sprt_heur, "SPRT over UDP", "sprt_udp", proto_sprt, HEURISTIC_ENABLE);
3416 }
3417
3418 /*
3419  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
3420  *
3421  * Local variables:
3422  * c-basic-offset: 4
3423  * tab-width: 8
3424  * indent-tabs-mode: nil
3425  * End:
3426  *
3427  * vi: set shiftwidth=4 tabstop=8 expandtab:
3428  * :indentSize=4:tabSize=8:noTabs=true:
3429  */