Update Free Software Foundation address.
[metze/wireshark/wip.git] / epan / dissectors / packet-sna.c
1 /* packet-sna.c
2  * Routines for SNA
3  * Gilbert Ramirez <gram@alumni.rice.edu>
4  * Jochen Friedrich <jochen@scram.de>
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <glib.h>
32 #include <epan/packet.h>
33 #include <epan/llcsaps.h>
34 #include <epan/ppptypes.h>
35 #include <epan/sna-utils.h>
36 #include <epan/charsets.h>
37 #include <epan/prefs.h>
38 #include <epan/reassemble.h>
39
40 /*
41  * http://www.wanresources.com/snacell.html
42  * ftp://ftp.software.ibm.com/networking/pub/standards/aiw/formats/
43  *
44  */
45
46 static int proto_sna = -1;
47 static int proto_sna_xid = -1;
48 static int hf_sna_th = -1;
49 static int hf_sna_th_0 = -1;
50 static int hf_sna_th_fid = -1;
51 static int hf_sna_th_mpf = -1;
52 static int hf_sna_th_odai = -1;
53 static int hf_sna_th_efi = -1;
54 static int hf_sna_th_daf = -1;
55 static int hf_sna_th_oaf = -1;
56 static int hf_sna_th_snf = -1;
57 static int hf_sna_th_dcf = -1;
58 static int hf_sna_th_lsid = -1;
59 static int hf_sna_th_tg_sweep = -1;
60 static int hf_sna_th_er_vr_supp_ind = -1;
61 static int hf_sna_th_vr_pac_cnt_ind = -1;
62 static int hf_sna_th_ntwk_prty = -1;
63 static int hf_sna_th_tgsf = -1;
64 static int hf_sna_th_mft = -1;
65 static int hf_sna_th_piubf = -1;
66 static int hf_sna_th_iern = -1;
67 static int hf_sna_th_nlpoi = -1;
68 static int hf_sna_th_nlp_cp = -1;
69 static int hf_sna_th_ern = -1;
70 static int hf_sna_th_vrn = -1;
71 static int hf_sna_th_tpf = -1;
72 static int hf_sna_th_vr_cwi = -1;
73 static int hf_sna_th_tg_nonfifo_ind = -1;
74 static int hf_sna_th_vr_sqti = -1;
75 static int hf_sna_th_tg_snf = -1;
76 static int hf_sna_th_vrprq = -1;
77 static int hf_sna_th_vrprs = -1;
78 static int hf_sna_th_vr_cwri = -1;
79 static int hf_sna_th_vr_rwi = -1;
80 static int hf_sna_th_vr_snf_send = -1;
81 static int hf_sna_th_dsaf = -1;
82 static int hf_sna_th_osaf = -1;
83 static int hf_sna_th_snai = -1;
84 static int hf_sna_th_def = -1;
85 static int hf_sna_th_oef = -1;
86 static int hf_sna_th_sa = -1;
87 static int hf_sna_th_cmd_fmt = -1;
88 static int hf_sna_th_cmd_type = -1;
89 static int hf_sna_th_cmd_sn = -1;
90
91 static int hf_sna_nlp_nhdr = -1;
92 static int hf_sna_nlp_nhdr_0 = -1;
93 static int hf_sna_nlp_sm = -1;
94 static int hf_sna_nlp_tpf = -1;
95 static int hf_sna_nlp_nhdr_1 = -1;
96 static int hf_sna_nlp_ft = -1;
97 static int hf_sna_nlp_tspi = -1;
98 static int hf_sna_nlp_slowdn1 = -1;
99 static int hf_sna_nlp_slowdn2 = -1;
100 static int hf_sna_nlp_fra = -1;
101 static int hf_sna_nlp_anr = -1;
102 static int hf_sna_nlp_frh = -1;
103 static int hf_sna_nlp_thdr = -1;
104 static int hf_sna_nlp_tcid = -1;
105 static int hf_sna_nlp_thdr_8 = -1;
106 static int hf_sna_nlp_setupi = -1;
107 static int hf_sna_nlp_somi = -1;
108 static int hf_sna_nlp_eomi = -1;
109 static int hf_sna_nlp_sri = -1;
110 static int hf_sna_nlp_rasapi = -1;
111 static int hf_sna_nlp_retryi = -1;
112 static int hf_sna_nlp_thdr_9 = -1;
113 static int hf_sna_nlp_lmi = -1;
114 static int hf_sna_nlp_cqfi = -1;
115 static int hf_sna_nlp_osi = -1;
116 static int hf_sna_nlp_offset = -1;
117 static int hf_sna_nlp_dlf = -1;
118 static int hf_sna_nlp_bsn = -1;
119 static int hf_sna_nlp_opti_len = -1;
120 static int hf_sna_nlp_opti_type = -1;
121 static int hf_sna_nlp_opti_0d_version = -1;
122 static int hf_sna_nlp_opti_0d_4 = -1;
123 static int hf_sna_nlp_opti_0d_target = -1;
124 static int hf_sna_nlp_opti_0d_arb = -1;
125 static int hf_sna_nlp_opti_0d_reliable = -1;
126 static int hf_sna_nlp_opti_0d_dedicated = -1;
127 static int hf_sna_nlp_opti_0e_stat = -1;
128 static int hf_sna_nlp_opti_0e_gap = -1;
129 static int hf_sna_nlp_opti_0e_idle = -1;
130 static int hf_sna_nlp_opti_0e_nabsp = -1;
131 static int hf_sna_nlp_opti_0e_sync = -1;
132 static int hf_sna_nlp_opti_0e_echo = -1;
133 static int hf_sna_nlp_opti_0e_rseq = -1;
134 static int hf_sna_nlp_opti_0e_abspbeg = -1;
135 static int hf_sna_nlp_opti_0e_abspend = -1;
136 static int hf_sna_nlp_opti_0f_bits = -1;
137 static int hf_sna_nlp_opti_10_tcid = -1;
138 static int hf_sna_nlp_opti_12_sense = -1;
139 static int hf_sna_nlp_opti_14_si_len = -1;
140 static int hf_sna_nlp_opti_14_si_key = -1;
141 static int hf_sna_nlp_opti_14_si_2 = -1;
142 static int hf_sna_nlp_opti_14_si_refifo = -1;
143 static int hf_sna_nlp_opti_14_si_mobility = -1;
144 static int hf_sna_nlp_opti_14_si_dirsearch = -1;
145 static int hf_sna_nlp_opti_14_si_limitres = -1;
146 static int hf_sna_nlp_opti_14_si_ncescope = -1;
147 static int hf_sna_nlp_opti_14_si_mnpsrscv = -1;
148 static int hf_sna_nlp_opti_14_si_maxpsize = -1;
149 static int hf_sna_nlp_opti_14_si_switch = -1;
150 static int hf_sna_nlp_opti_14_si_alive = -1;
151 static int hf_sna_nlp_opti_14_rr_len = -1;
152 static int hf_sna_nlp_opti_14_rr_key = -1;
153 static int hf_sna_nlp_opti_14_rr_2 = -1;
154 static int hf_sna_nlp_opti_14_rr_bfe = -1;
155 static int hf_sna_nlp_opti_14_rr_num = -1;
156 static int hf_sna_nlp_opti_22_2 = -1;
157 static int hf_sna_nlp_opti_22_type = -1;
158 static int hf_sna_nlp_opti_22_raa = -1;
159 static int hf_sna_nlp_opti_22_parity = -1;
160 static int hf_sna_nlp_opti_22_arb = -1;
161 static int hf_sna_nlp_opti_22_3 = -1;
162 static int hf_sna_nlp_opti_22_ratereq = -1;
163 static int hf_sna_nlp_opti_22_raterep = -1;
164 static int hf_sna_nlp_opti_22_field1 = -1;
165 static int hf_sna_nlp_opti_22_field2 = -1;
166 static int hf_sna_nlp_opti_22_field3 = -1;
167 static int hf_sna_nlp_opti_22_field4 = -1;
168
169 static int hf_sna_rh = -1;
170 static int hf_sna_rh_0 = -1;
171 static int hf_sna_rh_1 = -1;
172 static int hf_sna_rh_2 = -1;
173 static int hf_sna_rh_rri = -1;
174 static int hf_sna_rh_ru_category = -1;
175 static int hf_sna_rh_fi = -1;
176 static int hf_sna_rh_sdi = -1;
177 static int hf_sna_rh_bci = -1;
178 static int hf_sna_rh_eci = -1;
179 static int hf_sna_rh_dr1 = -1;
180 static int hf_sna_rh_lcci = -1;
181 static int hf_sna_rh_dr2 = -1;
182 static int hf_sna_rh_eri = -1;
183 static int hf_sna_rh_rti = -1;
184 static int hf_sna_rh_rlwi = -1;
185 static int hf_sna_rh_qri = -1;
186 static int hf_sna_rh_pi = -1;
187 static int hf_sna_rh_bbi = -1;
188 static int hf_sna_rh_ebi = -1;
189 static int hf_sna_rh_cdi = -1;
190 static int hf_sna_rh_csi = -1;
191 static int hf_sna_rh_edi = -1;
192 static int hf_sna_rh_pdi = -1;
193 static int hf_sna_rh_cebi = -1;
194 /*static int hf_sna_ru = -1;*/
195
196 static int hf_sna_gds = -1;
197 static int hf_sna_gds_len = -1;
198 static int hf_sna_gds_type = -1;
199 static int hf_sna_gds_cont = -1;
200
201 static int hf_sna_xid = -1;
202 static int hf_sna_xid_0 = -1;
203 static int hf_sna_xid_id = -1;
204 static int hf_sna_xid_format = -1;
205 static int hf_sna_xid_type = -1;
206 static int hf_sna_xid_len = -1;
207 static int hf_sna_xid_idblock = -1;
208 static int hf_sna_xid_idnum = -1;
209 static int hf_sna_xid_3_8 = -1;
210 static int hf_sna_xid_3_init_self = -1;
211 static int hf_sna_xid_3_stand_bind = -1;
212 static int hf_sna_xid_3_gener_bind = -1;
213 static int hf_sna_xid_3_recve_bind = -1;
214 static int hf_sna_xid_3_actpu = -1;
215 static int hf_sna_xid_3_nwnode = -1;
216 static int hf_sna_xid_3_cp = -1;
217 static int hf_sna_xid_3_cpcp = -1;
218 static int hf_sna_xid_3_state = -1;
219 static int hf_sna_xid_3_nonact = -1;
220 static int hf_sna_xid_3_cpchange = -1;
221 static int hf_sna_xid_3_10 = -1;
222 static int hf_sna_xid_3_asend_bind = -1;
223 static int hf_sna_xid_3_arecv_bind = -1;
224 static int hf_sna_xid_3_quiesce = -1;
225 static int hf_sna_xid_3_pucap = -1;
226 static int hf_sna_xid_3_pbn = -1;
227 static int hf_sna_xid_3_pacing = -1;
228 static int hf_sna_xid_3_11 = -1;
229 static int hf_sna_xid_3_tgshare = -1;
230 static int hf_sna_xid_3_dedsvc = -1;
231 static int hf_sna_xid_3_12 = -1;
232 static int hf_sna_xid_3_negcsup = -1;
233 static int hf_sna_xid_3_negcomp = -1;
234 static int hf_sna_xid_3_15 = -1;
235 static int hf_sna_xid_3_partg = -1;
236 static int hf_sna_xid_3_dlur = -1;
237 static int hf_sna_xid_3_dlus = -1;
238 static int hf_sna_xid_3_exbn = -1;
239 static int hf_sna_xid_3_genodai = -1;
240 static int hf_sna_xid_3_branch = -1;
241 static int hf_sna_xid_3_brnn = -1;
242 static int hf_sna_xid_3_tg = -1;
243 static int hf_sna_xid_3_dlc = -1;
244 static int hf_sna_xid_3_dlen = -1;
245
246 static int hf_sna_control_len = -1;
247 static int hf_sna_control_key = -1;
248 static int hf_sna_control_hprkey = -1;
249 static int hf_sna_control_05_delay = -1;
250 static int hf_sna_control_05_type = -1;
251 static int hf_sna_control_05_ptp = -1;
252 static int hf_sna_control_0e_type = -1;
253 static int hf_sna_control_0e_value = -1;
254
255 static gint ett_sna = -1;
256 static gint ett_sna_th = -1;
257 static gint ett_sna_th_fid = -1;
258 static gint ett_sna_nlp_nhdr = -1;
259 static gint ett_sna_nlp_nhdr_0 = -1;
260 static gint ett_sna_nlp_nhdr_1 = -1;
261 static gint ett_sna_nlp_thdr = -1;
262 static gint ett_sna_nlp_thdr_8 = -1;
263 static gint ett_sna_nlp_thdr_9 = -1;
264 static gint ett_sna_nlp_opti_un = -1;
265 static gint ett_sna_nlp_opti_0d = -1;
266 static gint ett_sna_nlp_opti_0d_4 = -1;
267 static gint ett_sna_nlp_opti_0e = -1;
268 static gint ett_sna_nlp_opti_0e_stat = -1;
269 static gint ett_sna_nlp_opti_0e_absp = -1;
270 static gint ett_sna_nlp_opti_0f = -1;
271 static gint ett_sna_nlp_opti_10 = -1;
272 static gint ett_sna_nlp_opti_12 = -1;
273 static gint ett_sna_nlp_opti_14 = -1;
274 static gint ett_sna_nlp_opti_14_si = -1;
275 static gint ett_sna_nlp_opti_14_si_2 = -1;
276 static gint ett_sna_nlp_opti_14_rr = -1;
277 static gint ett_sna_nlp_opti_14_rr_2 = -1;
278 static gint ett_sna_nlp_opti_22 = -1;
279 static gint ett_sna_nlp_opti_22_2 = -1;
280 static gint ett_sna_nlp_opti_22_3 = -1;
281 static gint ett_sna_rh = -1;
282 static gint ett_sna_rh_0 = -1;
283 static gint ett_sna_rh_1 = -1;
284 static gint ett_sna_rh_2 = -1;
285 static gint ett_sna_gds = -1;
286 static gint ett_sna_xid_0 = -1;
287 static gint ett_sna_xid_id = -1;
288 static gint ett_sna_xid_3_8 = -1;
289 static gint ett_sna_xid_3_10 = -1;
290 static gint ett_sna_xid_3_11 = -1;
291 static gint ett_sna_xid_3_12 = -1;
292 static gint ett_sna_xid_3_15 = -1;
293 static gint ett_sna_control_un = -1;
294 static gint ett_sna_control_05 = -1;
295 static gint ett_sna_control_05hpr = -1;
296 static gint ett_sna_control_05hpr_type = -1;
297 static gint ett_sna_control_0e = -1;
298
299 static dissector_handle_t data_handle;
300
301 /* Defragment fragmented SNA BIUs*/
302 static gboolean sna_defragment = TRUE;
303 static GHashTable *sna_fragment_table = NULL;
304
305 /* Format Identifier */
306 static const value_string sna_th_fid_vals[] = {
307         { 0x0,  "SNA device <--> Non-SNA Device" },
308         { 0x1,  "Subarea Nodes, without ER or VR" },
309         { 0x2,  "Subarea Node <--> PU2" },
310         { 0x3,  "Subarea Node or SNA host <--> Subarea Node" },
311         { 0x4,  "Subarea Nodes, supporting ER and VR" },
312         { 0x5,  "HPR RTP endpoint nodes" },
313         { 0xa,  "HPR NLP Frame Routing" },
314         { 0xb,  "HPR NLP Frame Routing" },
315         { 0xc,  "HPR NLP Automatic Network Routing" },
316         { 0xd,  "HPR NLP Automatic Network Routing" },
317         { 0xf,  "Adjacent Subarea Nodes, supporting ER and VR" },
318         { 0x0,  NULL }
319 };
320
321 /* Mapping Field */
322 #define MPF_MIDDLE_SEGMENT  0
323 #define MPF_LAST_SEGMENT    1
324 #define MPF_FIRST_SEGMENT   2
325 #define MPF_WHOLE_BIU       3
326
327 static const value_string sna_th_mpf_vals[] = {
328         { MPF_MIDDLE_SEGMENT,   "Middle segment of a BIU" },
329         { MPF_LAST_SEGMENT,     "Last segment of a BIU" },
330         { MPF_FIRST_SEGMENT,    "First segment of a BIU" },
331         { MPF_WHOLE_BIU,        "Whole BIU" },
332         { 0,   NULL }
333 };
334
335 /* Expedited Flow Indicator */
336 static const value_string sna_th_efi_vals[] = {
337         { 0, "Normal Flow" },
338         { 1, "Expedited Flow" },
339         { 0x0,  NULL }
340 };
341
342 /* Request/Response Indicator */
343 static const value_string sna_rh_rri_vals[] = {
344         { 0, "Request" },
345         { 1, "Response" },
346         { 0x0,  NULL }
347 };
348
349 /* Request/Response Unit Category */
350 static const value_string sna_rh_ru_category_vals[] = {
351         { 0, "Function Management Data (FMD)" },
352         { 1, "Network Control (NC)" },
353         { 2, "Data Flow Control (DFC)" },
354         { 3, "Session Control (SC)" },
355         { 0x0,  NULL }
356 };
357
358 /* Format Indicator */
359 static const true_false_string sna_rh_fi_truth =
360         { "FM Header", "No FM Header" };
361
362 /* Sense Data Included */
363 static const true_false_string sna_rh_sdi_truth =
364         { "Included", "Not Included" };
365
366 /* Begin Chain Indicator */
367 static const true_false_string sna_rh_bci_truth =
368         { "First in Chain", "Not First in Chain" };
369
370 /* End Chain Indicator */
371 static const true_false_string sna_rh_eci_truth =
372         { "Last in Chain", "Not Last in Chain" };
373
374 /* Lengith-Checked Compression Indicator */
375 static const true_false_string sna_rh_lcci_truth =
376         { "Compressed", "Not Compressed" };
377
378 /* Response Type Indicator */
379 static const true_false_string sna_rh_rti_truth =
380         { "Negative", "Positive" };
381
382 /* Queued Response Indicator */
383 static const true_false_string sna_rh_qri_truth =
384         { "Enqueue response in TC queues", "Response bypasses TC queues" };
385
386 /* Code Selection Indicator */
387 static const value_string sna_rh_csi_vals[] = {
388         { 0, "EBCDIC" },
389         { 1, "ASCII" },
390         { 0x0,  NULL }
391 };
392
393 /* TG Sweep */
394 static const value_string sna_th_tg_sweep_vals[] = {
395         { 0, "This PIU may overtake any PU ahead of it." },
396         { 1, "This PIU does not overtake any PIU ahead of it." },
397         { 0x0,  NULL }
398 };
399
400 /* ER_VR_SUPP_IND */
401 static const value_string sna_th_er_vr_supp_ind_vals[] = {
402         { 0, "Each node supports ER and VR protocols" },
403         { 1, "Includes at least one node that does not support ER and VR"
404             " protocols"  },
405         { 0x0,  NULL }
406 };
407
408 /* VR_PAC_CNT_IND */
409 static const value_string sna_th_vr_pac_cnt_ind_vals[] = {
410         { 0, "Pacing count on the VR has not reached 0" },
411         { 1, "Pacing count on the VR has reached 0" },
412         { 0x0,  NULL }
413 };
414
415 /* NTWK_PRTY */
416 static const value_string sna_th_ntwk_prty_vals[] = {
417         { 0, "PIU flows at a lower priority" },
418         { 1, "PIU flows at network priority (highest transmission priority)" },
419         { 0x0,  NULL }
420 };
421
422 /* TGSF */
423 static const value_string sna_th_tgsf_vals[] = {
424         { 0, "Not segmented" },
425         { 1, "Last segment" },
426         { 2, "First segment" },
427         { 3, "Middle segment" },
428         { 0x0,  NULL }
429 };
430
431 /* PIUBF */
432 static const value_string sna_th_piubf_vals[] = {
433         { 0, "Single PIU frame" },
434         { 1, "Last PIU of a multiple PIU frame" },
435         { 2, "First PIU of a multiple PIU frame" },
436         { 3, "Middle PIU of a multiple PIU frame" },
437         { 0x0,  NULL }
438 };
439
440 /* NLPOI */
441 static const value_string sna_th_nlpoi_vals[] = {
442         { 0, "NLP starts within this FID4 TH" },
443         { 1, "NLP byte 0 starts after RH byte 0 following NLP C/P pad" },
444         { 0x0,  NULL }
445 };
446
447 /* TPF */
448 static const value_string sna_th_tpf_vals[] = {
449         { 0, "Low Priority" },
450         { 1, "Medium Priority" },
451         { 2, "High Priority" },
452         { 3, "Network Priority" },
453         { 0x0,  NULL }
454 };
455
456 /* VR_CWI */
457 static const value_string sna_th_vr_cwi_vals[] = {
458         { 0, "Increment window size" },
459         { 1, "Decrement window size" },
460         { 0x0,  NULL }
461 };
462
463 /* TG_NONFIFO_IND */
464 static const true_false_string sna_th_tg_nonfifo_ind_truth =
465         { "TG FIFO is not required", "TG FIFO is required" };
466
467 /* VR_SQTI */
468 static const value_string sna_th_vr_sqti_vals[] = {
469         { 0, "Non-sequenced, Non-supervisory" },
470         { 1, "Non-sequenced, Supervisory" },
471         { 2, "Singly-sequenced" },
472         { 0x0,  NULL }
473 };
474
475 /* VRPRQ */
476 static const true_false_string sna_th_vrprq_truth = {
477         "VR pacing request is sent asking for a VR pacing response",
478         "No VR pacing response is requested",
479 };
480
481 /* VRPRS */
482 static const true_false_string sna_th_vrprs_truth = {
483         "VR pacing response is sent in response to a VRPRQ bit set",
484         "No pacing response sent",
485 };
486
487 /* VR_CWRI */
488 static const value_string sna_th_vr_cwri_vals[] = {
489         { 0, "Increment window size by 1" },
490         { 1, "Decrement window size by 1" },
491         { 0x0,  NULL }
492 };
493
494 /* VR_RWI */
495 static const true_false_string sna_th_vr_rwi_truth = {
496         "Reset window size to the minimum specified in NC_ACTVR",
497         "Do not reset window size",
498 };
499
500 /* Switching Mode */
501 static const value_string sna_nlp_sm_vals[] = {
502         { 5, "Function routing" },
503         { 6, "Automatic network routing" },
504         { 0x0,  NULL }
505 };
506
507 static const true_false_string sna_nlp_tspi_truth =
508         { "Time sensitive", "Not time sensitive" };
509
510 static const true_false_string sna_nlp_slowdn1_truth =
511         { "Minor congestion", "No minor congestion" };
512
513 static const true_false_string sna_nlp_slowdn2_truth =
514         { "Major congestion", "No major congestion" };
515
516 /* Function Type */
517 static const value_string sna_nlp_ft_vals[] = {
518         { 0x10, "LDLC" },
519         { 0x0,  NULL }
520 };
521
522 static const value_string sna_nlp_frh_vals[] = {
523         { 0x03, "XID complete request" },
524         { 0x04, "XID complete response" },
525         { 0x0,  NULL }
526 };
527
528 static const true_false_string sna_nlp_setupi_truth =
529         { "Connection setup segment present", "Connection setup segment not"
530             " present" };
531
532 static const true_false_string sna_nlp_somi_truth =
533         { "Start of message", "Not start of message" };
534
535 static const true_false_string sna_nlp_eomi_truth =
536         { "End of message", "Not end of message" };
537
538 static const true_false_string sna_nlp_sri_truth =
539         { "Status requested", "No status requested" };
540
541 static const true_false_string sna_nlp_rasapi_truth =
542         { "Reply as soon as possible", "No need to reply as soon as possible" };
543
544 static const true_false_string sna_nlp_retryi_truth =
545         { "Undefined", "Sender will retransmit" };
546
547 static const true_false_string sna_nlp_lmi_truth =
548         { "Last message", "Not last message" };
549
550 static const true_false_string sna_nlp_cqfi_truth =
551         { "CQFI included", "CQFI not included" };
552
553 static const true_false_string sna_nlp_osi_truth =
554         { "Optional segments present", "No optional segments present" };
555
556 static const value_string sna_xid_3_state_vals[] = {
557         { 0x00, "Exchange state indicators not supported" },
558         { 0x01, "Negotiation-proceeding exchange" },
559         { 0x02, "Prenegotiation exchange" },
560         { 0x03, "Nonactivation exchange" },
561         { 0x0, NULL }
562 };
563
564 static const value_string sna_xid_3_branch_vals[] = {
565         { 0x00, "Sender does not support branch extender" },
566         { 0x01, "TG is branch uplink" },
567         { 0x02, "TG is branch downlink" },
568         { 0x03, "TG is neither uplink nor downlink" },
569         { 0x0, NULL }
570 };
571
572 static const value_string sna_xid_type_vals[] = {
573         { 0x01, "T1 node" },
574         { 0x02, "T2.0 or T2.1 node" },
575         { 0x03, "Reserved" },
576         { 0x04, "T4 or T5 node" },
577         { 0x0, NULL }
578 };
579
580 static const value_string sna_nlp_opti_vals[] = {
581         { 0x0d, "Connection Setup Segment" },
582         { 0x0e, "Status Segment" },
583         { 0x0f, "Client Out Of Band Bits Segment" },
584         { 0x10, "Connection Identifier Exchange Segment" },
585         { 0x12, "Connection Fault Segment" },
586         { 0x14, "Switching Information Segment" },
587         { 0x22, "Adaptive Rate-Based Segment" },
588         { 0x0, NULL }
589 };
590
591 static const value_string sna_nlp_opti_0d_version_vals[] = {
592         { 0x0101, "Version 1.1" },
593         { 0x0, NULL }
594 };
595
596 static const value_string sna_nlp_opti_0f_bits_vals[] = {
597         { 0x0001, "Request Deactivation" },
598         { 0x8000, "Reply - OK" },
599         { 0x8004, "Reply - Reject" },
600         { 0x0, NULL }
601 };
602
603 static const value_string sna_nlp_opti_22_type_vals[] = {
604         { 0x00, "Setup" },
605         { 0x01, "Rate Reply" },
606         { 0x02, "Rate Request" },
607         { 0x03, "Rate Request/Rate Reply" },
608         { 0x0, NULL }
609 };
610
611 static const value_string sna_nlp_opti_22_raa_vals[] = {
612         { 0x00, "Normal" },
613         { 0x01, "Restraint" },
614         { 0x02, "Slowdown1" },
615         { 0x03, "Slowdown2" },
616         { 0x04, "Critical" },
617         { 0x0, NULL }
618 };
619
620 static const value_string sna_nlp_opti_22_arb_vals[] = {
621         { 0x00, "Base Mode ARB" },
622         { 0x01, "Responsive Mode ARB" },
623         { 0x0, NULL }
624 };
625
626 /* GDS Variable Type */
627 static const value_string sna_gds_var_vals[] = {
628         { 0x1210, "Change Number Of Sessions" },
629         { 0x1211, "Exchange Log Name" },
630         { 0x1212, "Control Point Management Services Unit" },
631         { 0x1213, "Compare States" },
632         { 0x1214, "LU Names Position" },
633         { 0x1215, "LU Name" },
634         { 0x1217, "Do Know" },
635         { 0x1218, "Partner Restart" },
636         { 0x1219, "Don't Know" },
637         { 0x1220, "Sign-Off" },
638         { 0x1221, "Sign-On" },
639         { 0x1222, "SNMP-over-SNA" },
640         { 0x1223, "Node Address Service" },
641         { 0x12C1, "CP Capabilities" },
642         { 0x12C2, "Topology Database Update" },
643         { 0x12C3, "Register Resource" },
644         { 0x12C4, "Locate" },
645         { 0x12C5, "Cross-Domain Initiate" },
646         { 0x12C9, "Delete Resource" },
647         { 0x12CA, "Find Resource" },
648         { 0x12CB, "Found Resource" },
649         { 0x12CC, "Notify" },
650         { 0x12CD, "Initiate-Other Cross-Domain" },
651         { 0x12CE, "Route Setup" },
652         { 0x12E1, "Error Log" },
653         { 0x12F1, "Null Data" },
654         { 0x12F2, "User Control Date" },
655         { 0x12F3, "Map Name" },
656         { 0x12F4, "Error Data" },
657         { 0x12F6, "Authentication Token Data" },
658         { 0x12F8, "Service Flow Authentication Token Data" },
659         { 0x12FF, "Application Data" },
660         { 0x1310, "MDS Message Unit" },
661         { 0x1311, "MDS Routing Information" },
662         { 0x1500, "FID2 Encapsulation" },
663         { 0x0,    NULL }
664 };
665
666 /* Control Vector Type */
667 static const value_string sna_control_vals[] = {
668         { 0x00,   "SSCP-LU Session Capabilities Control Vector" },
669         { 0x01,   "Date-Time Control Vector" },
670         { 0x02,   "Subarea Routing Control Vector" },
671         { 0x03,   "SDLC Secondary Station Control Vector" },
672         { 0x04,   "LU Control Vector" },
673         { 0x05,   "Channel Control Vector" },
674         { 0x06,   "Cross-Domain Resource Manager (CDRM) Control Vector" },
675         { 0x07,   "PU FMD-RU-Usage Control Vector" },
676         { 0x08,   "Intensive Mode Control Vector" },
677         { 0x09,   "Activation Request / Response Sequence Identifier Control"
678             " Vector" },
679         { 0x0a,   "User Request Correlator Control Vector" },
680         { 0x0b,   "SSCP-PU Session Capabilities Control Vector" },
681         { 0x0c,   "LU-LU Session Capabilities Control Vector" },
682         { 0x0d,   "Mode / Class-of-Service / Virtual-Route-Identifier List"
683             " Control Vector" },
684         { 0x0e,   "Network Name Control Vector" },
685         { 0x0f,   "Link Capabilities and Status Control Vector" },
686         { 0x10,   "Product Set ID Control Vector" },
687         { 0x11,   "Load Module Correlation Control Vector" },
688         { 0x12,   "Network Identifier Control Vector" },
689         { 0x13,   "Gateway Support Capabilities Control Vector" },
690         { 0x14,   "Session Initiation Control Vector" },
691         { 0x15,   "Network-Qualified Address Pair Control Vector" },
692         { 0x16,   "Names Substitution Control Vector" },
693         { 0x17,   "SSCP Identifier Control Vector" },
694         { 0x18,   "SSCP Name Control Vector" },
695         { 0x19,   "Resource Identifier Control Vector" },
696         { 0x1a,   "NAU Address Control Vector" },
697         { 0x1b,   "VRID List Control Vector" },
698         { 0x1c,   "Network-Qualified Name Pair Control Vector" },
699         { 0x1e,   "VR-ER Mapping Data Control Vector" },
700         { 0x1f,   "ER Configuration Control Vector" },
701         { 0x23,   "Local-Form Session Identifier Control Vector" },
702         { 0x24,   "IPL Load Module Request Control Vector" },
703         { 0x25,   "Security ID Control Control Vector" },
704         { 0x26,   "Network Connection Endpoint Identifier Control Vector" },
705         { 0x27,   "XRF Session Activation Control Vector" },
706         { 0x28,   "Related Session Identifier Control Vector" },
707         { 0x29,   "Session State Data Control Vector" },
708         { 0x2a,   "Session Information Control Vector" },
709         { 0x2b,   "Route Selection Control Vector" },
710         { 0x2c,   "COS/TPF Control Vector" },
711         { 0x2d,   "Mode Control Vector" },
712         { 0x2f,   "LU Definition Control Vector" },
713         { 0x30,   "Assign LU Characteristics Control Vector" },
714         { 0x31,   "BIND Image Control Vector" },
715         { 0x32,   "Short-Hold Mode Control Vector" },
716         { 0x33,   "ENCP Search Control Control Vector" },
717         { 0x34,   "LU Definition Override Control Vector" },
718         { 0x35,   "Extended Sense Data Control Vector" },
719         { 0x36,   "Directory Error Control Vector" },
720         { 0x37,   "Directory Entry Correlator Control Vector" },
721         { 0x38,   "Short-Hold Mode Emulation Control Vector" },
722         { 0x39,   "Network Connection Endpoint (NCE) Instance Identifier"
723             " Control Vector" },
724         { 0x3a,   "Route Status Data Control Vector" },
725         { 0x3b,   "VR Congestion Data Control Vector" },
726         { 0x3c,   "Associated Resource Entry Control Vector" },
727         { 0x3d,   "Directory Entry Control Vector" },
728         { 0x3e,   "Directory Entry Characteristic Control Vector" },
729         { 0x3f,   "SSCP (SLU) Capabilities Control Vector" },
730         { 0x40,   "Real Associated Resource Control Vector" },
731         { 0x41,   "Station Parameters Control Vector" },
732         { 0x42,   "Dynamic Path Update Data Control Vector" },
733         { 0x43,   "Extended SDLC Station Control Vector" },
734         { 0x44,   "Node Descriptor Control Vector" },
735         { 0x45,   "Node Characteristics Control Vector" },
736         { 0x46,   "TG Descriptor Control Vector" },
737         { 0x47,   "TG Characteristics Control Vector" },
738         { 0x48,   "Topology Resource Descriptor Control Vector" },
739         { 0x49,   "Multinode Persistent Sessions (MNPS) LU Names Control"
740             " Vector" },
741         { 0x4a,   "Real Owning Control Point Control Vector" },
742         { 0x4b,   "RTP Transport Connection Identifier Control Vector" },
743         { 0x51,   "DLUR/S Capabilities Control Vector" },
744         { 0x52,   "Primary Send Pacing Window Size Control Vector" },
745         { 0x56,   "Call Security Verification Control Vector" },
746         { 0x57,   "DLC Connection Data Control Vector" },
747         { 0x59,   "Installation-Defined CDINIT Data Control Vector" },
748         { 0x5a,   "Session Services Extension Support Control Vector" },
749         { 0x5b,   "Interchange Node Support Control Vector" },
750         { 0x5c,   "APPN Message Transport Control Vector" },
751         { 0x5d,   "Subarea Message Transport Control Vector" },
752         { 0x5e,   "Related Request Control Vector" },
753         { 0x5f,   "Extended Fully Qualified PCID Control Vector" },
754         { 0x60,   "Fully Qualified PCID Control Vector" },
755         { 0x61,   "HPR Capabilities Control Vector" },
756         { 0x62,   "Session Address Control Vector" },
757         { 0x63,   "Cryptographic Key Distribution Control Vector" },
758         { 0x64,   "TCP/IP Information Control Vector" },
759         { 0x65,   "Device Characteristics Control Vector" },
760         { 0x66,   "Length-Checked Compression Control Vector" },
761         { 0x67,   "Automatic Network Routing (ANR) Path Control Vector" },
762         { 0x68,   "XRF/Session Cryptography Control Vector" },
763         { 0x69,   "Switched Parameters Control Vector" },
764         { 0x6a,   "ER Congestion Data Control Vector" },
765         { 0x71,   "Triple DES Cryptography Key Continuation Control Vector" },
766         { 0xfe,   "Control Vector Keys Not Recognized" },
767         { 0x0,    NULL }
768 };
769
770 static const value_string sna_control_hpr_vals[] = {
771         { 0x00,   "Node Identifier Control Vector" },
772         { 0x03,   "Network ID Control Vector" },
773         { 0x05,   "Network Address Control Vector" },
774         { 0x0,    NULL }
775 };
776
777 static const value_string sna_control_0e_type_vals[] = {
778         { 0xF1,   "PU Name" },
779         { 0xF3,   "LU Name" },
780         { 0xF4,   "CP Name" },
781         { 0xF5,   "SSCP Name" },
782         { 0xF6,   "NNCP Name" },
783         { 0xF7,   "Link Station Name" },
784         { 0xF8,   "CP Name of CP(PLU)" },
785         { 0xF9,   "CP Name of CP(SLU)" },
786         { 0xFA,   "Generic Name" },
787         { 0x0,    NULL }
788 };
789
790 /* Values to direct the top-most dissector what to dissect
791  * after the TH. */
792 enum next_dissection_enum {
793     stop_here,
794     rh_only,
795     everything
796 };
797
798 enum parse {
799     LT,
800     KL
801 };
802
803 typedef enum next_dissection_enum next_dissection_t;
804
805 static void dissect_xid (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
806 static void dissect_fid (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
807 static void dissect_nlp (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
808 static void dissect_gds (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
809 static void dissect_rh (tvbuff_t*, int, proto_tree*);
810 static void dissect_control(tvbuff_t*, int, int, proto_tree*, int, enum parse);
811
812 /* --------------------------------------------------------------------
813  * Chapter 2 High-Performance Routing (HPR) Headers
814  * --------------------------------------------------------------------
815  */
816
817 static void
818 dissect_optional_0d(tvbuff_t *tvb, proto_tree *tree)
819 {
820         int             bits, offset, len, pad;
821         proto_tree      *sub_tree;
822         proto_item      *sub_ti = NULL;
823
824         if (!tree)
825                 return;
826
827         proto_tree_add_item(tree, hf_sna_nlp_opti_0d_version, tvb, 2, 2, ENC_BIG_ENDIAN);
828         bits = tvb_get_guint8(tvb, 4);
829
830         sub_ti = proto_tree_add_uint(tree, hf_sna_nlp_opti_0d_4,
831             tvb, 4, 1, bits);
832         sub_tree = proto_item_add_subtree(sub_ti,
833             ett_sna_nlp_opti_0d_4);
834
835         proto_tree_add_boolean(sub_tree, hf_sna_nlp_opti_0d_target,
836             tvb, 4, 1, bits);
837         proto_tree_add_boolean(sub_tree, hf_sna_nlp_opti_0d_arb,
838             tvb, 4, 1, bits);
839         proto_tree_add_boolean(sub_tree, hf_sna_nlp_opti_0d_reliable,
840             tvb, 4, 1, bits);
841         proto_tree_add_boolean(sub_tree, hf_sna_nlp_opti_0d_dedicated,
842             tvb, 4, 1, bits);
843
844         proto_tree_add_text(tree, tvb, 5, 3, "Reserved");
845
846         offset = 8;
847
848         while (tvb_offset_exists(tvb, offset)) {
849                 len = tvb_get_guint8(tvb, offset+0);
850                 if (len) {
851                         dissect_control(tvb, offset, len, tree, 1, LT);
852                         pad = (len+3) & 0xfffc;
853                         if (pad > len)
854                                 proto_tree_add_text(tree, tvb, offset+len,
855                                     pad-len, "Padding");
856                         offset += pad;
857                 } else {
858                         /* Avoid endless loop */
859                         return;
860                 }
861         }
862 }
863
864 static void
865 dissect_optional_0e(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
866 {
867         int             bits, offset;
868         proto_tree      *sub_tree;
869         proto_item      *sub_ti = NULL;
870
871         bits = tvb_get_guint8(tvb, 2);
872         offset = 20;
873
874         if (tree) {
875                 sub_ti = proto_tree_add_item(tree, hf_sna_nlp_opti_0e_stat,
876                     tvb, 2, 1, ENC_BIG_ENDIAN);
877                 sub_tree = proto_item_add_subtree(sub_ti,
878                     ett_sna_nlp_opti_0e_stat);
879
880                 proto_tree_add_boolean(sub_tree, hf_sna_nlp_opti_0e_gap,
881                     tvb, 2, 1, bits);
882                 proto_tree_add_boolean(sub_tree, hf_sna_nlp_opti_0e_idle,
883                     tvb, 2, 1, bits);
884                 proto_tree_add_item(tree, hf_sna_nlp_opti_0e_nabsp,
885                     tvb, 3, 1, ENC_BIG_ENDIAN);
886                 proto_tree_add_item(tree, hf_sna_nlp_opti_0e_sync,
887                     tvb, 4, 2, ENC_BIG_ENDIAN);
888                 proto_tree_add_item(tree, hf_sna_nlp_opti_0e_echo,
889                     tvb, 6, 2, ENC_BIG_ENDIAN);
890                 proto_tree_add_item(tree, hf_sna_nlp_opti_0e_rseq,
891                     tvb, 8, 4, ENC_BIG_ENDIAN);
892                 proto_tree_add_text(tree, tvb, 12, 8, "Reserved");
893
894                 if (tvb_offset_exists(tvb, offset))
895                         call_dissector(data_handle,
896                             tvb_new_subset_remaining(tvb, 4), pinfo, tree);
897         }
898         if (bits & 0x40) {
899                 col_set_str(pinfo->cinfo, COL_INFO, "HPR Idle Message");
900         } else {
901                 col_set_str(pinfo->cinfo, COL_INFO, "HPR Status Message");
902         }
903 }
904
905 static void
906 dissect_optional_0f(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
907 {
908         if (!tree)
909                 return;
910
911         proto_tree_add_item(tree, hf_sna_nlp_opti_0f_bits, tvb, 2, 2, ENC_BIG_ENDIAN);
912         if (tvb_offset_exists(tvb, 4))
913                 call_dissector(data_handle,
914                     tvb_new_subset_remaining(tvb, 4), pinfo, tree);
915 }
916
917 static void
918 dissect_optional_10(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
919 {
920         if (!tree)
921                 return;
922
923         proto_tree_add_text(tree, tvb, 2, 2, "Reserved");
924         proto_tree_add_item(tree, hf_sna_nlp_opti_10_tcid, tvb, 4, 8, ENC_NA);
925         if (tvb_offset_exists(tvb, 12))
926                 call_dissector(data_handle,
927                     tvb_new_subset_remaining(tvb, 12), pinfo, tree);
928 }
929
930 static void
931 dissect_optional_12(tvbuff_t *tvb, proto_tree *tree)
932 {
933         if (!tree)
934                 return;
935
936         proto_tree_add_text(tree, tvb, 2, 2, "Reserved");
937         proto_tree_add_item(tree, hf_sna_nlp_opti_12_sense, tvb, 4, -1, ENC_NA);
938 }
939
940 static void
941 dissect_optional_14(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
942 {
943         proto_tree      *sub_tree, *bf_tree;
944         proto_item      *sub_item, *bf_item;
945         int             len, pad, type, bits, offset, num, sublen;
946
947         if (!tree)
948                 return;
949
950         proto_tree_add_text(tree, tvb, 2, 2, "Reserved");
951
952         offset = 4;
953
954         len = tvb_get_guint8(tvb, offset);
955         type = tvb_get_guint8(tvb, offset+1);
956
957         if ((type != 0x83) || (len <= 16)) {
958                 /* Invalid */
959                 call_dissector(data_handle,
960                     tvb_new_subset_remaining(tvb, offset), pinfo, tree);
961                 return;
962         }
963         sub_item = proto_tree_add_text(tree, tvb, offset, len,
964             "Switching Information Control Vector");
965         sub_tree = proto_item_add_subtree(sub_item, ett_sna_nlp_opti_14_si);
966
967         proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_si_len,
968             tvb, offset, 1, len);
969         proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_si_key,
970             tvb, offset+1, 1, type);
971
972         bits = tvb_get_guint8(tvb, offset+2);
973         bf_item = proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_si_2,
974             tvb, offset+2, 1, bits);
975         bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_opti_14_si_2);
976
977         proto_tree_add_boolean(bf_tree, hf_sna_nlp_opti_14_si_refifo,
978             tvb, offset+2, 1, bits);
979         proto_tree_add_boolean(bf_tree, hf_sna_nlp_opti_14_si_mobility,
980             tvb, offset+2, 1, bits);
981         proto_tree_add_boolean(bf_tree, hf_sna_nlp_opti_14_si_dirsearch,
982             tvb, offset+2, 1, bits);
983         proto_tree_add_boolean(bf_tree, hf_sna_nlp_opti_14_si_limitres,
984             tvb, offset+2, 1, bits);
985         proto_tree_add_boolean(bf_tree, hf_sna_nlp_opti_14_si_ncescope,
986             tvb, offset+2, 1, bits);
987         proto_tree_add_boolean(bf_tree, hf_sna_nlp_opti_14_si_mnpsrscv,
988             tvb, offset+2, 1, bits);
989
990         proto_tree_add_text(sub_tree, tvb, offset+3, 1, "Reserved");
991         proto_tree_add_item(sub_tree, hf_sna_nlp_opti_14_si_maxpsize,
992             tvb, offset+4, 4, ENC_BIG_ENDIAN);
993         proto_tree_add_item(sub_tree, hf_sna_nlp_opti_14_si_switch,
994             tvb, offset+8, 4, ENC_BIG_ENDIAN);
995         proto_tree_add_item(sub_tree, hf_sna_nlp_opti_14_si_alive,
996             tvb, offset+12, 4, ENC_BIG_ENDIAN);
997
998         dissect_control(tvb, offset+16, len-16, sub_tree, 1, LT);
999
1000         pad = (len+3) & 0xfffc;
1001         if (pad > len)
1002                 proto_tree_add_text(sub_tree, tvb, offset+len, pad-len,
1003                     "Padding");
1004         offset += pad;
1005
1006         len = tvb_get_guint8(tvb, offset);
1007         type = tvb_get_guint8(tvb, offset+1);
1008
1009         if ((type != 0x85) || ( len < 4))  {
1010                 /* Invalid */
1011                 call_dissector(data_handle,
1012                     tvb_new_subset_remaining(tvb, offset), pinfo, tree);
1013                 return;
1014         }
1015         sub_item = proto_tree_add_text(tree, tvb, offset, len,
1016             "Return Route TG Descriptor Control Vector");
1017         sub_tree = proto_item_add_subtree(sub_item, ett_sna_nlp_opti_14_rr);
1018
1019         proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_rr_len,
1020             tvb, offset, 1, len);
1021         proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_rr_key,
1022             tvb, offset+1, 1, type);
1023
1024         bits = tvb_get_guint8(tvb, offset+2);
1025         bf_item = proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_rr_2,
1026             tvb, offset+2, 1, bits);
1027         bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_opti_14_rr_2);
1028
1029         proto_tree_add_boolean(bf_tree, hf_sna_nlp_opti_14_rr_bfe,
1030             tvb, offset+2, 1, bits);
1031
1032         num = tvb_get_guint8(tvb, offset+3);
1033
1034         proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_14_rr_num,
1035             tvb, offset+3, 1, num);
1036
1037         offset += 4;
1038
1039         while (num) {
1040                 sublen = tvb_get_guint8(tvb, offset);
1041                 if (sublen) {
1042                         dissect_control(tvb, offset, sublen, sub_tree, 1, LT);
1043                 } else {
1044                         /* Invalid */
1045                         call_dissector(data_handle,
1046                             tvb_new_subset_remaining(tvb, offset), pinfo, tree);
1047                         return;
1048                 }
1049                 /* No padding here */
1050                 offset += sublen;
1051                 num--;
1052         }
1053 }
1054
1055 static void
1056 dissect_optional_22(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1057 {
1058         proto_tree      *bf_tree;
1059         proto_item      *bf_item;
1060         int             bits, type;
1061
1062         if (!tree)
1063                 return;
1064
1065         bits = tvb_get_guint8(tvb, 2);
1066         type = (bits & 0xc0) >> 6;
1067
1068         bf_item = proto_tree_add_uint(tree, hf_sna_nlp_opti_22_2,
1069             tvb, 2, 1, bits);
1070         bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_opti_22_2);
1071
1072         proto_tree_add_uint(bf_tree, hf_sna_nlp_opti_22_type,
1073             tvb, 2, 1, bits);
1074         proto_tree_add_uint(bf_tree, hf_sna_nlp_opti_22_raa,
1075             tvb, 2, 1, bits);
1076         proto_tree_add_boolean(bf_tree, hf_sna_nlp_opti_22_parity,
1077             tvb, 2, 1, bits);
1078         proto_tree_add_uint(bf_tree, hf_sna_nlp_opti_22_arb,
1079             tvb, 2, 1, bits);
1080
1081         bits = tvb_get_guint8(tvb, 3);
1082
1083         bf_item = proto_tree_add_uint(tree, hf_sna_nlp_opti_22_3,
1084             tvb, 3, 1, bits);
1085         bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_opti_22_3);
1086
1087         proto_tree_add_uint(bf_tree, hf_sna_nlp_opti_22_ratereq,
1088             tvb, 3, 1, bits);
1089         proto_tree_add_uint(bf_tree, hf_sna_nlp_opti_22_raterep,
1090             tvb, 3, 1, bits);
1091
1092         proto_tree_add_item(tree, hf_sna_nlp_opti_22_field1,
1093             tvb, 4, 4, ENC_BIG_ENDIAN);
1094         proto_tree_add_item(tree, hf_sna_nlp_opti_22_field2,
1095             tvb, 8, 4, ENC_BIG_ENDIAN);
1096
1097         if (type == 0) {
1098                 proto_tree_add_item(tree, hf_sna_nlp_opti_22_field3,
1099                     tvb, 12, 4, ENC_BIG_ENDIAN);
1100                 proto_tree_add_item(tree, hf_sna_nlp_opti_22_field4,
1101                     tvb, 16, 4, ENC_BIG_ENDIAN);
1102
1103                 if (tvb_offset_exists(tvb, 20))
1104                         call_dissector(data_handle,
1105                             tvb_new_subset_remaining(tvb, 20), pinfo, tree);
1106         } else {
1107                 if (tvb_offset_exists(tvb, 12))
1108                         call_dissector(data_handle,
1109                             tvb_new_subset_remaining(tvb, 12), pinfo, tree);
1110         }
1111 }
1112
1113 static void
1114 dissect_optional(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1115 {
1116         proto_tree      *sub_tree;
1117         proto_item      *sub_item;
1118         int             offset, type, len;
1119         gint            ett;
1120
1121         sub_tree = NULL;
1122
1123         offset = 0;
1124
1125         while (tvb_offset_exists(tvb, offset)) {
1126                 len = tvb_get_guint8(tvb, offset);
1127                 type = tvb_get_guint8(tvb, offset+1);
1128
1129                 /* Prevent loop for invalid crap in packet */
1130                 if (len == 0) {
1131                         if (tree)
1132                                 call_dissector(data_handle,
1133                                     tvb_new_subset_remaining(tvb, offset), pinfo, tree);
1134                         return;
1135                 }
1136
1137                 ett = ett_sna_nlp_opti_un;
1138                 if(type == 0x0d) ett = ett_sna_nlp_opti_0d;
1139                 if(type == 0x0e) ett = ett_sna_nlp_opti_0e;
1140                 if(type == 0x0f) ett = ett_sna_nlp_opti_0f;
1141                 if(type == 0x10) ett = ett_sna_nlp_opti_10;
1142                 if(type == 0x12) ett = ett_sna_nlp_opti_12;
1143                 if(type == 0x14) ett = ett_sna_nlp_opti_14;
1144                 if(type == 0x22) ett = ett_sna_nlp_opti_22;
1145                 if (tree) {
1146                         sub_item = proto_tree_add_text(tree, tvb,
1147                             offset, len << 2, "%s",
1148                             val_to_str(type, sna_nlp_opti_vals,
1149                             "Unknown Segment Type"));
1150                         sub_tree = proto_item_add_subtree(sub_item, ett);
1151                         proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_len,
1152                             tvb, offset, 1, len);
1153                         proto_tree_add_uint(sub_tree, hf_sna_nlp_opti_type,
1154                             tvb, offset+1, 1, type);
1155                 }
1156                 switch(type) {
1157                         case 0x0d:
1158                                 dissect_optional_0d(tvb_new_subset(tvb, offset,
1159                                     len << 2, -1), sub_tree);
1160                                 break;
1161                         case 0x0e:
1162                                 dissect_optional_0e(tvb_new_subset(tvb, offset,
1163                                     len << 2, -1), pinfo, sub_tree);
1164                                 break;
1165                         case 0x0f:
1166                                 dissect_optional_0f(tvb_new_subset(tvb, offset,
1167                                     len << 2, -1), pinfo, sub_tree);
1168                                 break;
1169                         case 0x10:
1170                                 dissect_optional_10(tvb_new_subset(tvb, offset,
1171                                     len << 2, -1), pinfo, sub_tree);
1172                                 break;
1173                         case 0x12:
1174                                 dissect_optional_12(tvb_new_subset(tvb, offset,
1175                                     len << 2, -1), sub_tree);
1176                                 break;
1177                         case 0x14:
1178                                 dissect_optional_14(tvb_new_subset(tvb, offset,
1179                                     len << 2, -1), pinfo, sub_tree);
1180                                 break;
1181                         case 0x22:
1182                                 dissect_optional_22(tvb_new_subset(tvb, offset,
1183                                     len << 2, -1), pinfo, sub_tree);
1184                                 break;
1185                         default:
1186                                 call_dissector(data_handle,
1187                                     tvb_new_subset(tvb, offset,
1188                                     len << 2, -1), pinfo, sub_tree);
1189                 }
1190                 offset += (len << 2);
1191         }
1192 }
1193
1194 static void
1195 dissect_nlp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1196     proto_tree *parent_tree)
1197 {
1198         proto_tree      *nlp_tree, *bf_tree;
1199         proto_item      *nlp_item, *bf_item;
1200         guint8          nhdr_0, nhdr_1, nhdr_x, thdr_8, thdr_9, fid;
1201         guint32         thdr_len, thdr_dlf;
1202         guint16         subindex;
1203
1204         int index = 0, counter = 0;
1205
1206         nlp_tree = NULL;
1207         nlp_item = NULL;
1208
1209         nhdr_0 = tvb_get_guint8(tvb, index);
1210         nhdr_1 = tvb_get_guint8(tvb, index+1);
1211
1212         col_set_str(pinfo->cinfo, COL_INFO, "HPR NLP Packet");
1213
1214         if (tree) {
1215                 /* Don't bother setting length. We'll set it later after we
1216                  * find the lengths of NHDR */
1217                 nlp_item = proto_tree_add_item(tree, hf_sna_nlp_nhdr, tvb,
1218                     index, -1, ENC_NA);
1219                 nlp_tree = proto_item_add_subtree(nlp_item, ett_sna_nlp_nhdr);
1220
1221                 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_nhdr_0, tvb,
1222                     index, 1, nhdr_0);
1223                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_nhdr_0);
1224
1225                 proto_tree_add_uint(bf_tree, hf_sna_nlp_sm, tvb, index, 1,
1226                     nhdr_0);
1227                 proto_tree_add_uint(bf_tree, hf_sna_nlp_tpf, tvb, index, 1,
1228                     nhdr_0);
1229
1230                 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_nhdr_1, tvb,
1231                     index+1, 1, nhdr_1);
1232                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_nhdr_1);
1233
1234                 proto_tree_add_uint(bf_tree, hf_sna_nlp_ft, tvb,
1235                     index+1, 1, nhdr_1);
1236                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_tspi, tvb,
1237                     index+1, 1, nhdr_1);
1238                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_slowdn1, tvb,
1239                     index+1, 1, nhdr_1);
1240                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_slowdn2, tvb,
1241                     index+1, 1, nhdr_1);
1242         }
1243         /* ANR or FR lists */
1244
1245         index += 2;
1246         counter = 0;
1247
1248         if ((nhdr_0 & 0xe0) == 0xa0) {
1249                 do {
1250                         nhdr_x = tvb_get_guint8(tvb, index + counter);
1251                         counter ++;
1252                 } while (nhdr_x != 0xff);
1253                 if (tree)
1254                         proto_tree_add_item(nlp_tree,
1255                             hf_sna_nlp_fra, tvb, index, counter, ENC_NA);
1256                 index += counter;
1257                 if (tree)
1258                         proto_tree_add_text(nlp_tree, tvb, index, 1,
1259                             "Reserved");
1260                 index++;
1261
1262                 if (tree)
1263                         proto_item_set_len(nlp_item, index);
1264
1265                 if ((nhdr_1 & 0xf0) == 0x10) {
1266                         nhdr_x = tvb_get_guint8(tvb, index);
1267                         if (tree)
1268                                 proto_tree_add_uint(tree, hf_sna_nlp_frh,
1269                                     tvb, index, 1, nhdr_x);
1270                         index ++;
1271
1272                         if (tvb_offset_exists(tvb, index))
1273                                 call_dissector(data_handle,
1274                                         tvb_new_subset_remaining(tvb, index),
1275                                         pinfo, parent_tree);
1276                         return;
1277                 }
1278         }
1279         if ((nhdr_0 & 0xe0) == 0xc0) {
1280                 do {
1281                         nhdr_x = tvb_get_guint8(tvb, index + counter);
1282                         counter ++;
1283                 } while (nhdr_x != 0xff);
1284                 if (tree)
1285                         proto_tree_add_item(nlp_tree, hf_sna_nlp_anr,
1286                             tvb, index, counter, ENC_NA);
1287                 index += counter;
1288
1289                 if (tree)
1290                         proto_tree_add_text(nlp_tree, tvb, index, 1,
1291                             "Reserved");
1292                 index++;
1293
1294                 if (tree)
1295                         proto_item_set_len(nlp_item, index);
1296         }
1297
1298         thdr_8 = tvb_get_guint8(tvb, index+8);
1299         thdr_9 = tvb_get_guint8(tvb, index+9);
1300         thdr_len = tvb_get_ntohs(tvb, index+10);
1301         thdr_dlf = tvb_get_ntohl(tvb, index+12);
1302
1303         if (tree) {
1304                 nlp_item = proto_tree_add_item(tree, hf_sna_nlp_thdr, tvb,
1305                     index, thdr_len << 2, ENC_NA);
1306                 nlp_tree = proto_item_add_subtree(nlp_item, ett_sna_nlp_thdr);
1307
1308                 proto_tree_add_item(nlp_tree, hf_sna_nlp_tcid, tvb,
1309                     index, 8, ENC_NA);
1310                 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_thdr_8, tvb,
1311                     index+8, 1, thdr_8);
1312                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_thdr_8);
1313
1314                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_setupi, tvb,
1315                     index+8, 1, thdr_8);
1316                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_somi, tvb, index+8,
1317                     1, thdr_8);
1318                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_eomi, tvb, index+8,
1319                     1, thdr_8);
1320                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_sri, tvb, index+8,
1321                     1, thdr_8);
1322                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_rasapi, tvb,
1323                     index+8, 1, thdr_8);
1324                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_retryi, tvb,
1325                     index+8, 1, thdr_8);
1326
1327                 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_thdr_9, tvb,
1328                     index+9, 1, thdr_9);
1329                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_thdr_9);
1330
1331                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_lmi, tvb, index+9,
1332                     1, thdr_9);
1333                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_cqfi, tvb, index+9,
1334                     1, thdr_9);
1335                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_osi, tvb, index+9,
1336                     1, thdr_9);
1337
1338                 proto_tree_add_uint(nlp_tree, hf_sna_nlp_offset, tvb, index+10,
1339                     2, thdr_len);
1340                 proto_tree_add_uint(nlp_tree, hf_sna_nlp_dlf, tvb, index+12,
1341                     4, thdr_dlf);
1342                 proto_tree_add_item(nlp_tree, hf_sna_nlp_bsn, tvb, index+16,
1343                     4, ENC_BIG_ENDIAN);
1344         }
1345         subindex = 20;
1346
1347         if (((thdr_9 & 0x18) == 0x08) && ((thdr_len << 2) > subindex)) {
1348                 counter = tvb_get_guint8(tvb, index + subindex);
1349                 if (tvb_get_guint8(tvb, index+subindex+1) == 5)
1350                         dissect_control(tvb, index + subindex, counter+2, nlp_tree, 1, LT);
1351                 else
1352                         call_dissector(data_handle,
1353                             tvb_new_subset(tvb, index + subindex, counter+2,
1354                             -1), pinfo, nlp_tree);
1355
1356                 subindex += (counter+2);
1357         }
1358         if ((thdr_9 & 0x04) && ((thdr_len << 2) > subindex))
1359                 dissect_optional(
1360                     tvb_new_subset(tvb, index + subindex,
1361                     (thdr_len << 2) - subindex, -1),
1362                     pinfo, nlp_tree);
1363
1364         index += (thdr_len << 2);
1365         if (((thdr_8 & 0x20) == 0) && thdr_dlf) {
1366                 col_set_str(pinfo->cinfo, COL_INFO, "HPR Fragment");
1367                 if (tvb_offset_exists(tvb, index)) {
1368                         call_dissector(data_handle,
1369                             tvb_new_subset_remaining(tvb, index), pinfo,
1370                             parent_tree);
1371                 }
1372                 return;
1373         }
1374         if (tvb_offset_exists(tvb, index)) {
1375                 /* Transmission Header Format Identifier */
1376                 fid = hi_nibble(tvb_get_guint8(tvb, index));
1377                 if (fid == 5) /* Only FID5 allowed for HPR */
1378                         dissect_fid(tvb_new_subset_remaining(tvb, index), pinfo,
1379                             tree, parent_tree);
1380                 else {
1381                         if (tvb_get_ntohs(tvb, index+2) == 0x12ce) {
1382                                 /* Route Setup */
1383                                 col_set_str(pinfo->cinfo, COL_INFO, "HPR Route Setup");
1384                                 dissect_gds(tvb_new_subset_remaining(tvb, index),
1385                                     pinfo, tree, parent_tree);
1386                         } else
1387                                 call_dissector(data_handle,
1388                                     tvb_new_subset_remaining(tvb, index),
1389                                     pinfo, parent_tree);
1390                 }
1391         }
1392 }
1393
1394 /* --------------------------------------------------------------------
1395  * Chapter 3 Exchange Identification (XID) Information Fields
1396  * --------------------------------------------------------------------
1397  */
1398
1399 static void
1400 dissect_xid1(tvbuff_t *tvb, proto_tree *tree)
1401 {
1402         if (!tree)
1403                 return;
1404
1405         proto_tree_add_text(tree, tvb, 0, 2, "Reserved");
1406
1407 }
1408
1409 static void
1410 dissect_xid2(tvbuff_t *tvb, proto_tree *tree)
1411 {
1412         guint           dlen, offset;
1413
1414         if (!tree)
1415                 return;
1416
1417         dlen = tvb_get_guint8(tvb, 0);
1418
1419         offset = dlen;
1420
1421         while (tvb_offset_exists(tvb, offset)) {
1422                 dlen = tvb_get_guint8(tvb, offset+1);
1423                 dissect_control(tvb, offset, dlen+2, tree, 0, KL);
1424                 offset += (dlen + 2);
1425         }
1426 }
1427
1428 static void
1429 dissect_xid3(tvbuff_t *tvb, proto_tree *tree)
1430 {
1431         proto_tree      *sub_tree;
1432         proto_item      *sub_ti = NULL;
1433         guint           val, dlen, offset;
1434
1435         if (!tree)
1436                 return;
1437
1438         proto_tree_add_text(tree, tvb, 0, 2, "Reserved");
1439
1440         val = tvb_get_ntohs(tvb, 2);
1441
1442         sub_ti = proto_tree_add_uint(tree, hf_sna_xid_3_8, tvb,
1443             2, 2, val);
1444         sub_tree = proto_item_add_subtree(sub_ti, ett_sna_xid_3_8);
1445
1446         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_init_self, tvb, 2, 2,
1447             val);
1448         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_stand_bind, tvb, 2, 2,
1449             val);
1450         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_gener_bind, tvb, 2, 2,
1451             val);
1452         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_recve_bind, tvb, 2, 2,
1453             val);
1454         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_actpu, tvb, 2, 2, val);
1455         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_nwnode, tvb, 2, 2, val);
1456         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_cp, tvb, 2, 2, val);
1457         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_cpcp, tvb, 2, 2, val);
1458         proto_tree_add_uint(sub_tree, hf_sna_xid_3_state, tvb, 2, 2, val);
1459         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_nonact, tvb, 2, 2, val);
1460         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_cpchange, tvb, 2, 2,
1461             val);
1462
1463         val = tvb_get_guint8(tvb, 4);
1464
1465         sub_ti = proto_tree_add_uint(tree, hf_sna_xid_3_10, tvb,
1466             4, 1, val);
1467         sub_tree = proto_item_add_subtree(sub_ti, ett_sna_xid_3_10);
1468
1469         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_asend_bind, tvb, 4, 1,
1470             val);
1471         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_arecv_bind, tvb, 4, 1,
1472             val);
1473         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_quiesce, tvb, 4, 1, val);
1474         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_pucap, tvb, 4, 1, val);
1475         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_pbn, tvb, 4, 1, val);
1476         proto_tree_add_uint(sub_tree, hf_sna_xid_3_pacing, tvb, 4, 1, val);
1477
1478         val = tvb_get_guint8(tvb, 5);
1479
1480         sub_ti = proto_tree_add_uint(tree, hf_sna_xid_3_11, tvb,
1481             5, 1, val);
1482         sub_tree = proto_item_add_subtree(sub_ti, ett_sna_xid_3_11);
1483
1484         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_tgshare, tvb, 5, 1, val);
1485         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_dedsvc, tvb, 5, 1, val);
1486
1487         val = tvb_get_guint8(tvb, 6);
1488
1489         sub_ti = proto_tree_add_item(tree, hf_sna_xid_3_12, tvb,
1490             6, 1, ENC_BIG_ENDIAN);
1491         sub_tree = proto_item_add_subtree(sub_ti, ett_sna_xid_3_12);
1492
1493         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_negcsup, tvb, 6, 1, val);
1494         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_negcomp, tvb, 6, 1, val);
1495
1496         proto_tree_add_text(tree, tvb, 7, 2, "Reserved");
1497
1498         val = tvb_get_guint8(tvb, 9);
1499
1500         sub_ti = proto_tree_add_item(tree, hf_sna_xid_3_15, tvb,
1501             9, 1, ENC_BIG_ENDIAN);
1502         sub_tree = proto_item_add_subtree(sub_ti, ett_sna_xid_3_15);
1503
1504         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_partg, tvb, 9, 1, val);
1505         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_dlur, tvb, 9, 1, val);
1506         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_dlus, tvb, 9, 1, val);
1507         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_exbn, tvb, 9, 1, val);
1508         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_genodai, tvb, 9, 1, val);
1509         proto_tree_add_uint(sub_tree, hf_sna_xid_3_branch, tvb, 9, 1, val);
1510         proto_tree_add_boolean(sub_tree, hf_sna_xid_3_brnn, tvb, 9, 1, val);
1511
1512         proto_tree_add_item(tree, hf_sna_xid_3_tg, tvb, 10, 1, ENC_BIG_ENDIAN);
1513         proto_tree_add_item(tree, hf_sna_xid_3_dlc, tvb, 11, 1, ENC_BIG_ENDIAN);
1514
1515         dlen = tvb_get_guint8(tvb, 12);
1516
1517         proto_tree_add_uint(tree, hf_sna_xid_3_dlen, tvb, 12, 1, dlen);
1518
1519         /* FIXME: DLC Dependent Data Go Here */
1520
1521         offset = 12 + dlen;
1522
1523         while (tvb_offset_exists(tvb, offset)) {
1524                 dlen = tvb_get_guint8(tvb, offset+1);
1525                 dissect_control(tvb, offset, dlen+2, tree, 0, KL);
1526                 offset += (dlen+2);
1527         }
1528 }
1529
1530 static void
1531 dissect_xid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1532     proto_tree *parent_tree)
1533 {
1534         proto_tree      *sub_tree;
1535         proto_item      *sub_ti = NULL;
1536         int             format, type, len;
1537         guint32         id;
1538
1539         len = tvb_get_guint8(tvb, 1);
1540         type = tvb_get_guint8(tvb, 0);
1541         id = tvb_get_ntohl(tvb, 2);
1542         format = hi_nibble(type);
1543
1544         /* Summary information */
1545         if (check_col(pinfo->cinfo, COL_INFO))
1546                 col_add_fstr(pinfo->cinfo, COL_INFO,
1547                     "SNA XID Format:%d Type:%s", format,
1548                     val_to_str(lo_nibble(type), sna_xid_type_vals,
1549                     "Unknown Type"));
1550
1551         if (tree) {
1552                 sub_ti = proto_tree_add_item(tree, hf_sna_xid_0, tvb,
1553                     0, 1, ENC_BIG_ENDIAN);
1554                 sub_tree = proto_item_add_subtree(sub_ti, ett_sna_xid_0);
1555
1556                 proto_tree_add_uint(sub_tree, hf_sna_xid_format, tvb, 0, 1,
1557                     type);
1558                 proto_tree_add_uint(sub_tree, hf_sna_xid_type, tvb, 0, 1,
1559                     type);
1560
1561                 proto_tree_add_uint(tree, hf_sna_xid_len, tvb, 1, 1, len);
1562
1563                 sub_ti = proto_tree_add_item(tree, hf_sna_xid_id, tvb,
1564                     2, 4, ENC_BIG_ENDIAN);
1565                 sub_tree = proto_item_add_subtree(sub_ti, ett_sna_xid_id);
1566
1567                 proto_tree_add_uint(sub_tree, hf_sna_xid_idblock, tvb, 2, 4,
1568                     id);
1569                 proto_tree_add_uint(sub_tree, hf_sna_xid_idnum, tvb, 2, 4,
1570                     id);
1571
1572                 switch(format) {
1573                         case 0:
1574                                 break;
1575                         case 1:
1576                                 dissect_xid1(tvb_new_subset(tvb, 6, len-6, -1),
1577                                     tree);
1578                                 break;
1579                         case 2:
1580                                 dissect_xid2(tvb_new_subset(tvb, 6, len-6, -1),
1581                                     tree);
1582                                 break;
1583                         case 3:
1584                                 dissect_xid3(tvb_new_subset(tvb, 6, len-6, -1),
1585                                     tree);
1586                                 break;
1587                         default:
1588                                 /* external standards organizations */
1589                                 call_dissector(data_handle,
1590                                     tvb_new_subset(tvb, 6, len-6, -1),
1591                                     pinfo, tree);
1592                 }
1593         }
1594
1595         if (format == 0)
1596                 len = 6;
1597
1598         if (tvb_offset_exists(tvb, len))
1599                 call_dissector(data_handle,
1600                     tvb_new_subset_remaining(tvb, len), pinfo, parent_tree);
1601 }
1602
1603 /* --------------------------------------------------------------------
1604  * Chapter 4 Transmission Headers (THs)
1605  * --------------------------------------------------------------------
1606  */
1607
1608 #define RH_LEN  3
1609
1610 static unsigned int
1611 mpf_value(guint8 th_byte)
1612 {
1613         return (th_byte & 0x0c) >> 2;
1614 }
1615
1616 #define FIRST_FRAG_NUMBER       0
1617 #define MIDDLE_FRAG_NUMBER      1
1618 #define LAST_FRAG_NUMBER        2
1619
1620 /* FID2 is defragged by sequence. The weird thing is that we have neither
1621  * absolute sequence numbers, nor byte offets. Other FIDs have byte offsets
1622  * (the DCF field), but not FID2. The only thing we have to go with is "FIRST",
1623  * "MIDDLE", or "LAST". If the BIU is split into 3 frames, then everything is
1624  * fine, * "FIRST", "MIDDLE", and "LAST" map nicely onto frag-number 0, 1,
1625  * and 2. However, if the BIU is split into 2 frames, then we only have
1626  * "FIRST" and "LAST", and the mapping *should* be frag-number 0 and 1,
1627  * *NOT* 0 and 2.
1628  *
1629  * The SNA docs say "FID2 PIUs cannot be blocked because there is no DCF in the
1630  * TH format for deblocking" (note on Figure 4-2 in the IBM SNA documention,
1631  * see the FTP URL in the comment near the top of this file). I *think*
1632  * this means that the fragmented frames cannot arrive out of order.
1633  * Well, I *want* it to mean this, because w/o this limitation, if you
1634  * get a "FIRST" frame and a "LAST" frame, how long should you wait to
1635  * see if a "MIDDLE" frame every arrives????? Thus, if frames *have* to
1636  * arrive in order, then we're saved.
1637  *
1638  * The problem then boils down to figuring out if "LAST" means frag-number 1
1639  * (in the case of a BIU split into 2 frames) or frag-number 2
1640  * (in the case of a BIU split into 3 frames).
1641  *
1642  * Assuming fragmented FID2 BIU frames *do* arrive in order, the obvious
1643  * way to handle the mapping of "LAST" to either frag-number 1 or
1644  * frag-number 2 is to keep a hash which tracks the frames seen, etc.
1645  * This consumes resources. A trickier way, but a way which works, is to
1646  * always map the "LAST" BIU segment to frag-number 2. Here's the trickery:
1647  * if we add frag-number 2, which we know to be the "LAST" BIU segment,
1648  * and the reassembly code tells us that the the BIU is still not reassmebled,
1649  * then, owing to the, ahem, /fact/, that fragmented BIU segments arrive
1650  * in order :), we know that 1) "FIRST" did come, and 2) there's no "MIDDLE",
1651  * because this BIU was fragmented into 2 frames, not 3. So, we'll be
1652  * tricky and add a zero-length "MIDDLE" BIU frame (i.e, frag-number 1)
1653  * to complete the reassembly.
1654  */
1655 static tvbuff_t*
1656 defragment_by_sequence(packet_info *pinfo, tvbuff_t *tvb, int offset, int mpf,
1657     int id)
1658 {
1659         fragment_data *fd_head;
1660         int frag_number = -1;
1661         int more_frags = TRUE;
1662         tvbuff_t *rh_tvb = NULL;
1663         gint frag_len;
1664
1665         /* Determine frag_number and more_frags */
1666         switch(mpf) {
1667                 case MPF_WHOLE_BIU:
1668                         /* nothing */
1669                         break;
1670                 case MPF_FIRST_SEGMENT:
1671                         frag_number = FIRST_FRAG_NUMBER;
1672                         break;
1673                 case MPF_MIDDLE_SEGMENT:
1674                         frag_number = MIDDLE_FRAG_NUMBER;
1675                         break;
1676                 case MPF_LAST_SEGMENT:
1677                         frag_number = LAST_FRAG_NUMBER;
1678                         more_frags = FALSE;
1679                         break;
1680                 default:
1681                         DISSECTOR_ASSERT_NOT_REACHED();
1682         }
1683
1684         /* If sna_defragment is on, and this is a fragment.. */
1685         if (frag_number > -1) {
1686                 /* XXX - check length ??? */
1687                 frag_len = tvb_reported_length_remaining(tvb, offset);
1688                 if (tvb_bytes_exist(tvb, offset, frag_len)) {
1689                         fd_head = fragment_add_seq(tvb, offset, pinfo, id,
1690                             sna_fragment_table, frag_number, frag_len,
1691                             more_frags);
1692
1693                         /* We added the LAST segment and reassembly didn't
1694                          * complete. Insert a zero-length MIDDLE segment to
1695                          * turn a 2-frame BIU-fragmentation into a 3-frame
1696                          * BIU-fragmentation (empty middle frag).
1697                          * See above long comment about this trickery. */
1698
1699                         if (mpf == MPF_LAST_SEGMENT && !fd_head) {
1700                                 fd_head = fragment_add_seq(tvb, offset, pinfo,
1701                                     id, sna_fragment_table,
1702                                     MIDDLE_FRAG_NUMBER, 0, TRUE);
1703                         }
1704
1705                         if (fd_head != NULL) {
1706                                 /* We have the complete reassembled payload. */
1707                                 rh_tvb = tvb_new_child_real_data(tvb, fd_head->data,
1708                                     fd_head->len, fd_head->len);
1709
1710                                 /* Add the defragmented data to the data
1711                                  * source list. */
1712                                 add_new_data_source(pinfo, rh_tvb,
1713                                     "Reassembled SNA BIU");
1714                         }
1715                 }
1716         }
1717         return rh_tvb;
1718 }
1719
1720 #define SNA_FID01_ADDR_LEN      2
1721
1722 /* FID Types 0 and 1 */
1723 static int
1724 dissect_fid0_1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1725 {
1726         proto_tree      *bf_tree;
1727         proto_item      *bf_item;
1728         guint8          th_0;
1729         const guint8    *ptr;
1730
1731         const int bytes_in_header = 10;
1732
1733         if (tree) {
1734                 /* Byte 0 */
1735                 th_0 = tvb_get_guint8(tvb, 0);
1736                 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1,
1737                     th_0);
1738                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1739
1740                 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
1741                 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
1742                 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
1743
1744                 /* Byte 1 */
1745                 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
1746
1747                 /* Bytes 2-3 */
1748                 proto_tree_add_item(tree, hf_sna_th_daf, tvb, 2, 2, ENC_BIG_ENDIAN);
1749         }
1750
1751         /* Set DST addr */
1752         ptr = tvb_get_ptr(tvb, 2, SNA_FID01_ADDR_LEN);
1753         SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
1754         SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
1755
1756         if (tree)
1757                 proto_tree_add_item(tree, hf_sna_th_oaf, tvb, 4, 2, ENC_BIG_ENDIAN);
1758
1759         /* Set SRC addr */
1760         ptr = tvb_get_ptr(tvb, 4, SNA_FID01_ADDR_LEN);
1761         SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
1762         SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
1763
1764         /* If we're not filling a proto_tree, return now */
1765         if (tree)
1766                 return bytes_in_header;
1767
1768         proto_tree_add_item(tree, hf_sna_th_snf, tvb, 6, 2, ENC_BIG_ENDIAN);
1769         proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 8, 2, ENC_BIG_ENDIAN);
1770
1771         return bytes_in_header;
1772 }
1773
1774 #define SNA_FID2_ADDR_LEN       1
1775
1776 /* FID Type 2 */
1777 static int
1778 dissect_fid2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1779         tvbuff_t **rh_tvb_ptr, next_dissection_t *continue_dissecting)
1780 {
1781         proto_tree      *bf_tree;
1782         proto_item      *bf_item;
1783         guint8          th_0=0, daf=0, oaf=0;
1784         const guint8    *ptr;
1785         unsigned int    mpf, id;
1786
1787         const int bytes_in_header = 6;
1788
1789         th_0 = tvb_get_guint8(tvb, 0);
1790         mpf = mpf_value(th_0);
1791
1792         if (tree) {
1793                 daf = tvb_get_guint8(tvb, 2);
1794                 oaf = tvb_get_guint8(tvb, 3);
1795
1796                 /* Byte 0 */
1797                 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1,
1798                     th_0);
1799                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1800
1801                 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
1802                 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
1803                 proto_tree_add_uint(bf_tree, hf_sna_th_odai,tvb, 0, 1, th_0);
1804                 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
1805
1806
1807                 /* Byte 1 */
1808                 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
1809
1810                 /* Byte 2 */
1811                 proto_tree_add_uint_format(tree, hf_sna_th_daf, tvb, 2, 1, daf,
1812                     "Destination Address Field: 0x%02x", daf);
1813         }
1814
1815         /* Set DST addr */
1816         ptr = tvb_get_ptr(tvb, 2, SNA_FID2_ADDR_LEN);
1817         SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
1818         SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
1819
1820         if (tree) {
1821                 /* Byte 3 */
1822                 proto_tree_add_uint_format(tree, hf_sna_th_oaf, tvb, 3, 1, oaf,
1823                     "Origin Address Field: 0x%02x", oaf);
1824         }
1825
1826         /* Set SRC addr */
1827         ptr = tvb_get_ptr(tvb, 3, SNA_FID2_ADDR_LEN);
1828         SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
1829         SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
1830
1831         id = tvb_get_ntohs(tvb, 4);
1832         if (tree)
1833                 proto_tree_add_uint(tree, hf_sna_th_snf, tvb, 4, 2, id);
1834
1835         if (mpf != MPF_WHOLE_BIU && !sna_defragment) {
1836                 if (mpf == MPF_FIRST_SEGMENT) {
1837                         *continue_dissecting = rh_only;
1838                 } else {
1839                         *continue_dissecting = stop_here;
1840                 }
1841
1842         }
1843         else if (sna_defragment) {
1844                 *rh_tvb_ptr = defragment_by_sequence(pinfo, tvb,
1845                     bytes_in_header, mpf, id);
1846         }
1847
1848         return bytes_in_header;
1849 }
1850
1851 /* FID Type 3 */
1852 static int
1853 dissect_fid3(tvbuff_t *tvb, proto_tree *tree)
1854 {
1855         proto_tree      *bf_tree;
1856         proto_item      *bf_item;
1857         guint8          th_0;
1858
1859         const int bytes_in_header = 2;
1860
1861         /* If we're not filling a proto_tree, return now */
1862         if (!tree)
1863                 return bytes_in_header;
1864
1865         th_0 = tvb_get_guint8(tvb, 0);
1866
1867         /* Create the bitfield tree */
1868         bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
1869         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1870
1871         proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
1872         proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
1873         proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
1874
1875         proto_tree_add_item(tree, hf_sna_th_lsid, tvb, 1, 1, ENC_BIG_ENDIAN);
1876
1877         return bytes_in_header;
1878 }
1879
1880 static int
1881 dissect_fid4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1882 {
1883         proto_tree      *bf_tree;
1884         proto_item      *bf_item;
1885         int             offset = 0;
1886         guint8          th_byte, mft;
1887         guint16         th_word;
1888         guint16         def, oef;
1889         guint32         dsaf, osaf;
1890         static struct sna_fid_type_4_addr src, dst;
1891
1892         const int bytes_in_header = 26;
1893
1894         /* If we're not filling a proto_tree, return now */
1895         if (!tree)
1896                 return bytes_in_header;
1897
1898         th_byte = tvb_get_guint8(tvb, offset);
1899
1900         /* Create the bitfield tree */
1901         bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, offset,
1902             1, th_byte);
1903         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1904
1905         /* Byte 0 */
1906         proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb,
1907             offset, 1, th_byte);
1908         proto_tree_add_uint(bf_tree, hf_sna_th_tg_sweep, tvb,
1909             offset, 1, th_byte);
1910         proto_tree_add_uint(bf_tree, hf_sna_th_er_vr_supp_ind, tvb,
1911             offset, 1, th_byte);
1912         proto_tree_add_uint(bf_tree, hf_sna_th_vr_pac_cnt_ind, tvb,
1913             offset, 1, th_byte);
1914         proto_tree_add_uint(bf_tree, hf_sna_th_ntwk_prty, tvb,
1915             offset, 1, th_byte);
1916
1917         offset += 1;
1918         th_byte = tvb_get_guint8(tvb, offset);
1919
1920         /* Create the bitfield tree */
1921         bf_item = proto_tree_add_text(tree, tvb, offset, 1,
1922             "Transmission Header Byte 1");
1923         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1924
1925         /* Byte 1 */
1926         proto_tree_add_uint(bf_tree, hf_sna_th_tgsf, tvb, offset, 1,
1927             th_byte);
1928         proto_tree_add_boolean(bf_tree, hf_sna_th_mft, tvb, offset, 1,
1929             th_byte);
1930         proto_tree_add_uint(bf_tree, hf_sna_th_piubf, tvb, offset, 1,
1931             th_byte);
1932
1933         mft = th_byte & 0x04;
1934         offset += 1;
1935         th_byte = tvb_get_guint8(tvb, offset);
1936
1937         /* Create the bitfield tree */
1938         bf_item = proto_tree_add_text(tree, tvb, offset, 1,
1939             "Transmission Header Byte 2");
1940         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1941
1942         /* Byte 2 */
1943         if (mft) {
1944                 proto_tree_add_uint(bf_tree, hf_sna_th_nlpoi, tvb,
1945                     offset, 1, th_byte);
1946                 proto_tree_add_uint(bf_tree, hf_sna_th_nlp_cp, tvb,
1947                     offset, 1, th_byte);
1948         } else {
1949                 proto_tree_add_uint(bf_tree, hf_sna_th_iern, tvb,
1950                     offset, 1, th_byte);
1951         }
1952         proto_tree_add_uint(bf_tree, hf_sna_th_ern, tvb, offset, 1,
1953             th_byte);
1954
1955         offset += 1;
1956         th_byte = tvb_get_guint8(tvb, offset);
1957
1958         /* Create the bitfield tree */
1959         bf_item = proto_tree_add_text(tree, tvb, offset, 1,
1960             "Transmission Header Byte 3");
1961         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1962
1963         /* Byte 3 */
1964         proto_tree_add_uint(bf_tree, hf_sna_th_vrn, tvb, offset, 1,
1965             th_byte);
1966         proto_tree_add_uint(bf_tree, hf_sna_th_tpf, tvb, offset, 1,
1967             th_byte);
1968
1969         offset += 1;
1970         th_word = tvb_get_ntohs(tvb, offset);
1971
1972         /* Create the bitfield tree */
1973         bf_item = proto_tree_add_text(tree, tvb, offset, 2,
1974             "Transmission Header Bytes 4-5");
1975         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1976
1977         /* Bytes 4-5 */
1978         proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwi, tvb,
1979             offset, 2, th_word);
1980         proto_tree_add_boolean(bf_tree, hf_sna_th_tg_nonfifo_ind, tvb,
1981             offset, 2, th_word);
1982         proto_tree_add_uint(bf_tree, hf_sna_th_vr_sqti, tvb,
1983             offset, 2, th_word);
1984
1985         /* I'm not sure about byte-order on this one... */
1986         proto_tree_add_uint(bf_tree, hf_sna_th_tg_snf, tvb,
1987             offset, 2, th_word);
1988
1989         offset += 2;
1990         th_word = tvb_get_ntohs(tvb, offset);
1991
1992         /* Create the bitfield tree */
1993         bf_item = proto_tree_add_text(tree, tvb, offset, 2,
1994             "Transmission Header Bytes 6-7");
1995         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1996
1997         /* Bytes 6-7 */
1998         proto_tree_add_boolean(bf_tree, hf_sna_th_vrprq, tvb, offset,
1999             2, th_word);
2000         proto_tree_add_boolean(bf_tree, hf_sna_th_vrprs, tvb, offset,
2001             2, th_word);
2002         proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwri, tvb, offset,
2003             2, th_word);
2004         proto_tree_add_boolean(bf_tree, hf_sna_th_vr_rwi, tvb, offset,
2005             2, th_word);
2006
2007         /* I'm not sure about byte-order on this one... */
2008         proto_tree_add_uint(bf_tree, hf_sna_th_vr_snf_send, tvb,
2009             offset, 2, th_word);
2010
2011         offset += 2;
2012
2013         dsaf = tvb_get_ntohl(tvb, 8);
2014         /* Bytes 8-11 */
2015         proto_tree_add_uint(tree, hf_sna_th_dsaf, tvb, offset, 4, dsaf);
2016
2017         offset += 4;
2018
2019         osaf = tvb_get_ntohl(tvb, 12);
2020         /* Bytes 12-15 */
2021         proto_tree_add_uint(tree, hf_sna_th_osaf, tvb, offset, 4, osaf);
2022
2023         offset += 4;
2024         th_byte = tvb_get_guint8(tvb, offset);
2025
2026         /* Create the bitfield tree */
2027         bf_item = proto_tree_add_text(tree, tvb, offset, 2,
2028             "Transmission Header Byte 16");
2029         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
2030
2031         /* Byte 16 */
2032         proto_tree_add_boolean(bf_tree, hf_sna_th_snai, tvb, offset, 1, th_byte);
2033
2034         /* We luck out here because in their infinite wisdom the SNA
2035          * architects placed the MPF and EFI fields in the same bitfield
2036          * locations, even though for FID4 they're not in byte 0.
2037          * Thank you IBM! */
2038         proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, offset, 1, th_byte);
2039         proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, offset, 1, th_byte);
2040
2041         offset += 2;
2042         /* 1 for byte 16, 1 for byte 17 which is reserved */
2043
2044         def = tvb_get_ntohs(tvb, 18);
2045         /* Bytes 18-25 */
2046         proto_tree_add_uint(tree, hf_sna_th_def, tvb, offset, 2, def);
2047
2048         /* Addresses in FID 4 are discontiguous, sigh */
2049         dst.saf = dsaf;
2050         dst.ef = def;
2051         SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
2052             (guint8* )&dst);
2053         SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
2054             (guint8 *)&dst);
2055
2056         oef = tvb_get_ntohs(tvb, 20);
2057         proto_tree_add_uint(tree, hf_sna_th_oef, tvb, offset+2, 2, oef);
2058
2059         /* Addresses in FID 4 are discontiguous, sigh */
2060         src.saf = osaf;
2061         src.ef = oef;
2062         SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
2063             (guint8 *)&src);
2064         SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
2065             (guint8 *)&src);
2066
2067         proto_tree_add_item(tree, hf_sna_th_snf, tvb, offset+4, 2, ENC_BIG_ENDIAN);
2068         proto_tree_add_item(tree, hf_sna_th_dcf, tvb, offset+6, 2, ENC_BIG_ENDIAN);
2069
2070         return bytes_in_header;
2071 }
2072
2073 /* FID Type 5 */
2074 static int
2075 dissect_fid5(tvbuff_t *tvb, proto_tree *tree)
2076 {
2077         proto_tree      *bf_tree;
2078         proto_item      *bf_item;
2079         guint8          th_0;
2080
2081         const int bytes_in_header = 12;
2082
2083         /* If we're not filling a proto_tree, return now */
2084         if (!tree)
2085                 return bytes_in_header;
2086
2087         th_0 = tvb_get_guint8(tvb, 0);
2088
2089         /* Create the bitfield tree */
2090         bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
2091         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
2092
2093         proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
2094         proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
2095         proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
2096
2097         proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
2098         proto_tree_add_item(tree, hf_sna_th_snf, tvb, 2, 2, ENC_BIG_ENDIAN);
2099
2100         proto_tree_add_item(tree, hf_sna_th_sa, tvb, 4, 8, ENC_NA);
2101
2102         return bytes_in_header;
2103
2104 }
2105
2106 /* FID Type f */
2107 static int
2108 dissect_fidf(tvbuff_t *tvb, proto_tree *tree)
2109 {
2110         proto_tree      *bf_tree;
2111         proto_item      *bf_item;
2112         guint8          th_0;
2113
2114         const int bytes_in_header = 26;
2115
2116         /* If we're not filling a proto_tree, return now */
2117         if (!tree)
2118                 return bytes_in_header;
2119
2120         th_0 = tvb_get_guint8(tvb, 0);
2121
2122         /* Create the bitfield tree */
2123         bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
2124         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
2125
2126         proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
2127         proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
2128
2129         proto_tree_add_item(tree, hf_sna_th_cmd_fmt, tvb,  2, 1, ENC_BIG_ENDIAN);
2130         proto_tree_add_item(tree, hf_sna_th_cmd_type, tvb, 3, 1, ENC_BIG_ENDIAN);
2131         proto_tree_add_item(tree, hf_sna_th_cmd_sn, tvb,   4, 2, ENC_BIG_ENDIAN);
2132
2133         /* Yup, bytes 6-23 are reserved! */
2134         proto_tree_add_text(tree, tvb, 6, 18, "Reserved");
2135
2136         proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 24, 2, ENC_BIG_ENDIAN);
2137
2138         return bytes_in_header;
2139 }
2140
2141 static void
2142 dissect_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2143     proto_tree *parent_tree)
2144 {
2145
2146         proto_tree      *th_tree = NULL, *rh_tree = NULL;
2147         proto_item      *th_ti = NULL, *rh_ti = NULL;
2148         guint8          th_fid;
2149         int             th_header_len = 0;
2150         int             offset, rh_offset;
2151         tvbuff_t        *rh_tvb = NULL;
2152         next_dissection_t continue_dissecting = everything;
2153
2154         /* Transmission Header Format Identifier */
2155         th_fid = hi_nibble(tvb_get_guint8(tvb, 0));
2156
2157         /* Summary information */
2158         if (check_col(pinfo->cinfo, COL_INFO))
2159                 col_add_str(pinfo->cinfo, COL_INFO,
2160                     val_to_str(th_fid, sna_th_fid_vals, "Unknown FID: %01x"));
2161
2162         if (tree) {
2163                 /* --- TH --- */
2164                 /* Don't bother setting length. We'll set it later after we
2165                  * find the length of TH */
2166                 th_ti = proto_tree_add_item(tree, hf_sna_th, tvb,  0, -1,
2167                     ENC_NA);
2168                 th_tree = proto_item_add_subtree(th_ti, ett_sna_th);
2169         }
2170
2171         /* Get size of TH */
2172         switch(th_fid) {
2173                 case 0x0:
2174                 case 0x1:
2175                         th_header_len = dissect_fid0_1(tvb, pinfo, th_tree);
2176                         break;
2177                 case 0x2:
2178                         th_header_len = dissect_fid2(tvb, pinfo, th_tree,
2179                             &rh_tvb, &continue_dissecting);
2180                         break;
2181                 case 0x3:
2182                         th_header_len = dissect_fid3(tvb, th_tree);
2183                         break;
2184                 case 0x4:
2185                         th_header_len = dissect_fid4(tvb, pinfo, th_tree);
2186                         break;
2187                 case 0x5:
2188                         th_header_len = dissect_fid5(tvb, th_tree);
2189                         break;
2190                 case 0xf:
2191                         th_header_len = dissect_fidf(tvb, th_tree);
2192                         break;
2193                 default:
2194                         call_dissector(data_handle,
2195                             tvb_new_subset_remaining(tvb, 1), pinfo, parent_tree);
2196                         return;
2197         }
2198
2199         offset = th_header_len;
2200
2201         /* Short-circuit ? */
2202         if (continue_dissecting == stop_here) {
2203                 if (tree) {
2204                         proto_tree_add_text(tree, tvb, offset, -1,
2205                             "BIU segment data");
2206                 }
2207                 return;
2208         }
2209
2210         /* If the FID dissector function didn't create an rh_tvb, then we just
2211          * use the rest of our tvbuff as the rh_tvb. */
2212         if (!rh_tvb)
2213                 rh_tvb = tvb_new_subset_remaining(tvb, offset);
2214         rh_offset = 0;
2215
2216         /* Process the rest of the SNA packet, starting with RH */
2217         if (tree) {
2218                 proto_item_set_len(th_ti, th_header_len);
2219
2220                 /* --- RH --- */
2221                 rh_ti = proto_tree_add_item(tree, hf_sna_rh, rh_tvb, rh_offset,
2222                     RH_LEN, ENC_NA);
2223                 rh_tree = proto_item_add_subtree(rh_ti, ett_sna_rh);
2224                 dissect_rh(rh_tvb, rh_offset, rh_tree);
2225         }
2226
2227         rh_offset += RH_LEN;
2228
2229         if (tvb_offset_exists(rh_tvb, rh_offset)) {
2230                 /* Short-circuit ? */
2231                 if (continue_dissecting == rh_only) {
2232                         if (tree)
2233                                 proto_tree_add_text(tree, rh_tvb, rh_offset, -1,
2234                                     "BIU segment data");
2235                         return;
2236                 }
2237
2238                 call_dissector(data_handle,
2239                     tvb_new_subset_remaining(rh_tvb, rh_offset),
2240                     pinfo, parent_tree);
2241         }
2242 }
2243
2244 /* --------------------------------------------------------------------
2245  * Chapter 5 Request/Response Headers (RHs)
2246  * --------------------------------------------------------------------
2247  */
2248
2249 static void
2250 dissect_rh(tvbuff_t *tvb, int offset, proto_tree *tree)
2251 {
2252         proto_tree      *bf_tree;
2253         proto_item      *bf_item;
2254         gboolean        is_response;
2255         guint8          rh_0, rh_1, rh_2;
2256
2257         if (!tree)
2258                 return;
2259
2260         /* Create the bitfield tree for byte 0*/
2261         rh_0 = tvb_get_guint8(tvb, offset);
2262         is_response = (rh_0 & 0x80);
2263
2264         bf_item = proto_tree_add_uint(tree, hf_sna_rh_0, tvb, offset, 1, rh_0);
2265         bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_0);
2266
2267         proto_tree_add_uint(bf_tree, hf_sna_rh_rri, tvb, offset, 1, rh_0);
2268         proto_tree_add_uint(bf_tree, hf_sna_rh_ru_category, tvb, offset, 1,
2269             rh_0);
2270         proto_tree_add_boolean(bf_tree, hf_sna_rh_fi, tvb, offset, 1, rh_0);
2271         proto_tree_add_boolean(bf_tree, hf_sna_rh_sdi, tvb, offset, 1, rh_0);
2272         proto_tree_add_boolean(bf_tree, hf_sna_rh_bci, tvb, offset, 1, rh_0);
2273         proto_tree_add_boolean(bf_tree, hf_sna_rh_eci, tvb, offset, 1, rh_0);
2274
2275         offset += 1;
2276         rh_1 = tvb_get_guint8(tvb, offset);
2277
2278         /* Create the bitfield tree for byte 1*/
2279         bf_item = proto_tree_add_uint(tree, hf_sna_rh_1, tvb, offset, 1, rh_1);
2280         bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_1);
2281
2282         proto_tree_add_boolean(bf_tree, hf_sna_rh_dr1, tvb,  offset, 1, rh_1);
2283
2284         if (!is_response)
2285                 proto_tree_add_boolean(bf_tree, hf_sna_rh_lcci, tvb, offset, 1,
2286                     rh_1);
2287
2288         proto_tree_add_boolean(bf_tree, hf_sna_rh_dr2, tvb,  offset, 1, rh_1);
2289
2290         if (is_response) {
2291                 proto_tree_add_boolean(bf_tree, hf_sna_rh_rti, tvb,  offset, 1,
2292                     rh_1);
2293         } else {
2294                 proto_tree_add_boolean(bf_tree, hf_sna_rh_eri, tvb,  offset, 1,
2295                     rh_1);
2296                 proto_tree_add_boolean(bf_tree, hf_sna_rh_rlwi, tvb, offset, 1,
2297                     rh_1);
2298         }
2299
2300         proto_tree_add_boolean(bf_tree, hf_sna_rh_qri, tvb, offset, 1, rh_1);
2301         proto_tree_add_boolean(bf_tree, hf_sna_rh_pi, tvb,  offset, 1, rh_1);
2302
2303         offset += 1;
2304         rh_2 = tvb_get_guint8(tvb, offset);
2305
2306         /* Create the bitfield tree for byte 2*/
2307         bf_item = proto_tree_add_uint(tree, hf_sna_rh_2, tvb, offset, 1, rh_2);
2308
2309         if (!is_response) {
2310                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_2);
2311
2312                 proto_tree_add_boolean(bf_tree, hf_sna_rh_bbi, tvb,  offset, 1,
2313                     rh_2);
2314                 proto_tree_add_boolean(bf_tree, hf_sna_rh_ebi, tvb,  offset, 1,
2315                     rh_2);
2316                 proto_tree_add_boolean(bf_tree, hf_sna_rh_cdi, tvb,  offset, 1,
2317                     rh_2);
2318                 proto_tree_add_uint(bf_tree, hf_sna_rh_csi, tvb,  offset, 1,
2319                     rh_2);
2320                 proto_tree_add_boolean(bf_tree, hf_sna_rh_edi, tvb,  offset, 1,
2321                     rh_2);
2322                 proto_tree_add_boolean(bf_tree, hf_sna_rh_pdi, tvb,  offset, 1,
2323                     rh_2);
2324                 proto_tree_add_boolean(bf_tree, hf_sna_rh_cebi, tvb, offset, 1,
2325                     rh_2);
2326         }
2327
2328         /* XXX - check for sdi. If TRUE, the next 4 bytes will be sense data */
2329 }
2330
2331 /* --------------------------------------------------------------------
2332  * Chapter 6 Request/Response Units (RUs)
2333  * --------------------------------------------------------------------
2334  */
2335
2336 /* --------------------------------------------------------------------
2337  * Chapter 9 Common Fields
2338  * --------------------------------------------------------------------
2339  */
2340
2341 static void
2342 dissect_control_05hpr(tvbuff_t *tvb, proto_tree *tree, int hpr,
2343     enum parse parse)
2344 {
2345         proto_tree      *bf_tree;
2346         proto_item      *bf_item;
2347         guint8          type;
2348         guint16         offset, len, pad;
2349
2350         if (!tree)
2351                 return;
2352
2353         type = tvb_get_guint8(tvb, 2);
2354
2355         bf_item = proto_tree_add_uint(tree, hf_sna_control_05_type, tvb,
2356             2, 1, type);
2357         bf_tree = proto_item_add_subtree(bf_item, ett_sna_control_05hpr_type);
2358
2359         proto_tree_add_boolean(bf_tree, hf_sna_control_05_ptp, tvb, 2, 1, type);
2360         proto_tree_add_text(tree, tvb, 3, 1, "Reserved");
2361
2362         offset = 4;
2363
2364         while (tvb_offset_exists(tvb, offset)) {
2365                 if (parse == LT) {
2366                         len = tvb_get_guint8(tvb, offset+0);
2367                 } else {
2368                         len = tvb_get_guint8(tvb, offset+1);
2369                 }
2370                 if (len) {
2371                         dissect_control(tvb, offset, len, tree, hpr, parse);
2372                         pad = (len+3) & 0xfffc;
2373             if (pad > len) {
2374                 /* XXX - fix this, ensure tvb is large enough for pad */
2375                 tvb_ensure_bytes_exist(tvb, offset+len, pad-len);
2376                                 proto_tree_add_text(tree, tvb, offset+len,
2377                                     pad-len, "Padding");
2378             }
2379                         offset += pad;
2380                 } else {
2381                         return;
2382                 }
2383         }
2384 }
2385
2386 static void
2387 dissect_control_05(tvbuff_t *tvb, proto_tree *tree)
2388 {
2389         if(!tree)
2390                 return;
2391
2392         proto_tree_add_item(tree, hf_sna_control_05_delay, tvb, 2, 2, ENC_BIG_ENDIAN);
2393 }
2394
2395 static void
2396 dissect_control_0e(tvbuff_t *tvb, proto_tree *tree)
2397 {
2398         gint    len;
2399         guint8  *buf;
2400
2401         if (!tree)
2402                 return;
2403
2404         proto_tree_add_item(tree, hf_sna_control_0e_type, tvb, 2, 1, ENC_BIG_ENDIAN);
2405
2406         len = tvb_reported_length_remaining(tvb, 3);
2407         if (len <= 0)
2408                 return;
2409
2410         buf = tvb_get_ephemeral_string(tvb, 3, len);
2411         EBCDIC_to_ASCII(buf, len);
2412         proto_tree_add_string(tree, hf_sna_control_0e_value, tvb, 3, len, (char *)buf);
2413 }
2414
2415 static void
2416 dissect_control(tvbuff_t *parent_tvb, int offset, int control_len,
2417     proto_tree *tree, int hpr, enum parse parse)
2418 {
2419         tvbuff_t        *tvb;
2420         gint            length, reported_length;
2421         proto_tree      *sub_tree;
2422         proto_item      *sub_item;
2423         int             len, key;
2424         gint            ett;
2425
2426         length = tvb_length_remaining(parent_tvb, offset);
2427         reported_length = tvb_reported_length_remaining(parent_tvb, offset);
2428         if (control_len < length)
2429                 length = control_len;
2430         if (control_len < reported_length)
2431                 reported_length = control_len;
2432         tvb = tvb_new_subset(parent_tvb, offset, length, reported_length);
2433
2434         sub_tree = NULL;
2435
2436         if (parse == LT) {
2437                 len = tvb_get_guint8(tvb, 0);
2438                 key = tvb_get_guint8(tvb, 1);
2439         } else {
2440                 key = tvb_get_guint8(tvb, 0);
2441                 len = tvb_get_guint8(tvb, 1);
2442         }
2443         ett = ett_sna_control_un;
2444
2445         if (tree) {
2446                 if (key == 5) {
2447                          if (hpr) ett = ett_sna_control_05hpr;
2448                          else ett = ett_sna_control_05;
2449                 }
2450                 if (key == 0x0e) ett = ett_sna_control_0e;
2451
2452                 if (((key == 0) || (key == 3) || (key == 5)) && hpr)
2453                         sub_item = proto_tree_add_text(tree, tvb, 0, -1, "%s",
2454                             val_to_str(key, sna_control_hpr_vals,
2455                             "Unknown Control Vector"));
2456                 else
2457                         sub_item = proto_tree_add_text(tree, tvb, 0, -1, "%s",
2458                             val_to_str(key, sna_control_vals,
2459                             "Unknown Control Vector"));
2460                 sub_tree = proto_item_add_subtree(sub_item, ett);
2461                 if (parse == LT) {
2462                         proto_tree_add_uint(sub_tree, hf_sna_control_len,
2463                             tvb, 0, 1, len);
2464                         if (((key == 0) || (key == 3) || (key == 5)) && hpr)
2465                                 proto_tree_add_uint(sub_tree,
2466                                     hf_sna_control_hprkey, tvb, 1, 1, key);
2467                         else
2468                                 proto_tree_add_uint(sub_tree,
2469                                     hf_sna_control_key, tvb, 1, 1, key);
2470                 } else {
2471                         if (((key == 0) || (key == 3) || (key == 5)) && hpr)
2472                                 proto_tree_add_uint(sub_tree,
2473                                     hf_sna_control_hprkey, tvb, 0, 1, key);
2474                         else
2475                                 proto_tree_add_uint(sub_tree,
2476                                     hf_sna_control_key, tvb, 0, 1, key);
2477                         proto_tree_add_uint(sub_tree, hf_sna_control_len,
2478                             tvb, 1, 1, len);
2479                 }
2480         }
2481         switch(key) {
2482                 case 0x05:
2483                         if (hpr)
2484                                 dissect_control_05hpr(tvb, sub_tree, hpr,
2485                                     parse);
2486                         else
2487                                 dissect_control_05(tvb, sub_tree);
2488                         break;
2489                 case 0x0e:
2490                         dissect_control_0e(tvb, sub_tree);
2491                         break;
2492         }
2493 }
2494
2495 /* --------------------------------------------------------------------
2496  * Chapter 11 Function Management (FM) Headers
2497  * --------------------------------------------------------------------
2498  */
2499
2500 /* --------------------------------------------------------------------
2501  * Chapter 12 Presentation Services (PS) Headers
2502  * --------------------------------------------------------------------
2503  */
2504
2505 /* --------------------------------------------------------------------
2506  * Chapter 13 GDS Variables
2507  * --------------------------------------------------------------------
2508  */
2509
2510 static void
2511 dissect_gds(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
2512     proto_tree *parent_tree)
2513 {
2514         guint16         length;
2515         guint16         type;
2516         int             cont;
2517         int             offset;
2518         proto_tree      *gds_tree;
2519         proto_item      *gds_item;
2520
2521         offset = 0;
2522         cont   = 1;
2523         type   = tvb_get_ntohs(tvb, offset+2);
2524
2525         while (cont) {
2526                 length = tvb_get_ntohs(tvb, offset) & 0x7fff;
2527                 cont   = (tvb_get_ntohs(tvb, offset) & 0x8000) ? 1 : 0;
2528                 type   = tvb_get_ntohs(tvb, offset+2);
2529
2530                 if (length < 2 ) /* escape sequence ? */
2531                         return;
2532                 if (tree) {
2533                         gds_item = proto_tree_add_item(tree, hf_sna_gds, tvb,
2534                             offset, length, ENC_NA);
2535                         gds_tree = proto_item_add_subtree(gds_item,
2536                             ett_sna_gds);
2537
2538                         proto_tree_add_uint(gds_tree, hf_sna_gds_len, tvb,
2539                             offset, 2, length);
2540                         proto_tree_add_boolean(gds_tree, hf_sna_gds_cont, tvb,
2541                             offset, 2, cont);
2542                         proto_tree_add_uint(gds_tree, hf_sna_gds_type, tvb,
2543                             offset+2, 2, type);
2544                 }
2545                 offset += length;
2546         }
2547         if (tvb_offset_exists(tvb, offset))
2548                 call_dissector(data_handle,
2549                     tvb_new_subset_remaining(tvb, offset), pinfo, parent_tree);
2550 }
2551
2552 /* --------------------------------------------------------------------
2553  * General stuff
2554  * --------------------------------------------------------------------
2555  */
2556
2557 static void
2558 dissect_sna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2559 {
2560         guint8          fid;
2561         proto_tree      *sna_tree = NULL;
2562         proto_item      *sna_ti = NULL;
2563
2564         col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNA");
2565         col_clear(pinfo->cinfo, COL_INFO);
2566
2567         /* SNA data should be printed in EBCDIC, not ASCII */
2568         pinfo->fd->flags.encoding = PACKET_CHAR_ENC_CHAR_EBCDIC;
2569
2570         if (tree) {
2571
2572                 /* Don't bother setting length. We'll set it later after we find
2573                  * the lengths of TH/RH/RU */
2574                 sna_ti = proto_tree_add_item(tree, proto_sna, tvb, 0, -1,
2575                     ENC_NA);
2576                 sna_tree = proto_item_add_subtree(sna_ti, ett_sna);
2577         }
2578
2579         /* Transmission Header Format Identifier */
2580         fid = hi_nibble(tvb_get_guint8(tvb, 0));
2581         switch(fid) {
2582                 case 0xa:       /* HPR Network Layer Packet */
2583                 case 0xb:
2584                 case 0xc:
2585                 case 0xd:
2586                         dissect_nlp(tvb, pinfo, sna_tree, tree);
2587                         break;
2588                 default:
2589                         dissect_fid(tvb, pinfo, sna_tree, tree);
2590         }
2591 }
2592
2593 static void
2594 dissect_sna_xid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2595 {
2596         proto_tree      *sna_tree = NULL;
2597         proto_item      *sna_ti = NULL;
2598
2599         col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNA");
2600         col_clear(pinfo->cinfo, COL_INFO);
2601
2602         /* SNA data should be printed in EBCDIC, not ASCII */
2603         pinfo->fd->flags.encoding = PACKET_CHAR_ENC_CHAR_EBCDIC;
2604
2605         if (tree) {
2606
2607                 /* Don't bother setting length. We'll set it later after we find
2608                  * the lengths of XID */
2609                 sna_ti = proto_tree_add_item(tree, proto_sna_xid, tvb, 0, -1,
2610                     ENC_NA);
2611                 sna_tree = proto_item_add_subtree(sna_ti, ett_sna);
2612         }
2613         dissect_xid(tvb, pinfo, sna_tree, tree);
2614 }
2615
2616 static void
2617 sna_init(void)
2618 {
2619         fragment_table_init(&sna_fragment_table);
2620 }
2621
2622
2623 void
2624 proto_register_sna(void)
2625 {
2626         static hf_register_info hf[] = {
2627                 { &hf_sna_th,
2628                 { "Transmission Header", "sna.th", FT_NONE, BASE_NONE,
2629                      NULL, 0x0, NULL, HFILL }},
2630
2631                 { &hf_sna_th_0,
2632                 { "Transmission Header Byte 0", "sna.th.0", FT_UINT8, BASE_HEX,
2633                     NULL, 0x0,
2634                     "TH Byte 0", HFILL }},
2635
2636                 { &hf_sna_th_fid,
2637                 { "Format Identifier", "sna.th.fid", FT_UINT8, BASE_HEX,
2638                     VALS(sna_th_fid_vals), 0xf0, NULL, HFILL }},
2639
2640                 { &hf_sna_th_mpf,
2641                 { "Mapping Field", "sna.th.mpf", FT_UINT8,
2642                     BASE_DEC, VALS(sna_th_mpf_vals), 0x0c, NULL, HFILL }},
2643
2644                 { &hf_sna_th_odai,
2645                 { "ODAI Assignment Indicator", "sna.th.odai", FT_UINT8,
2646                     BASE_DEC, NULL, 0x02, NULL, HFILL }},
2647
2648                 { &hf_sna_th_efi,
2649                 { "Expedited Flow Indicator", "sna.th.efi", FT_UINT8,
2650                     BASE_DEC, VALS(sna_th_efi_vals), 0x01, NULL, HFILL }},
2651
2652                 { &hf_sna_th_daf,
2653                 { "Destination Address Field", "sna.th.daf", FT_UINT16,
2654                     BASE_HEX, NULL, 0x0, NULL, HFILL }},
2655
2656                 { &hf_sna_th_oaf,
2657                 { "Origin Address Field", "sna.th.oaf", FT_UINT16, BASE_HEX,
2658                     NULL, 0x0, NULL, HFILL }},
2659
2660                 { &hf_sna_th_snf,
2661                 { "Sequence Number Field", "sna.th.snf", FT_UINT16, BASE_DEC,
2662                     NULL, 0x0, NULL, HFILL }},
2663
2664                 { &hf_sna_th_dcf,
2665                 { "Data Count Field", "sna.th.dcf", FT_UINT16, BASE_DEC,
2666                     NULL, 0x0, NULL, HFILL }},
2667
2668                 { &hf_sna_th_lsid,
2669                 { "Local Session Identification", "sna.th.lsid", FT_UINT8,
2670                     BASE_HEX, NULL, 0x0, NULL, HFILL }},
2671
2672                 { &hf_sna_th_tg_sweep,
2673                 { "Transmission Group Sweep", "sna.th.tg_sweep", FT_UINT8,
2674                     BASE_DEC, VALS(sna_th_tg_sweep_vals), 0x08, NULL, HFILL }},
2675
2676                 { &hf_sna_th_er_vr_supp_ind,
2677                 { "ER and VR Support Indicator", "sna.th.er_vr_supp_ind",
2678                     FT_UINT8, BASE_DEC, VALS(sna_th_er_vr_supp_ind_vals),
2679                     0x04, NULL, HFILL }},
2680
2681                 { &hf_sna_th_vr_pac_cnt_ind,
2682                 { "Virtual Route Pacing Count Indicator",
2683                     "sna.th.vr_pac_cnt_ind", FT_UINT8, BASE_DEC,
2684                     VALS(sna_th_vr_pac_cnt_ind_vals), 0x02, NULL, HFILL }},
2685
2686                 { &hf_sna_th_ntwk_prty,
2687                 { "Network Priority", "sna.th.ntwk_prty", FT_UINT8, BASE_DEC,
2688                     VALS(sna_th_ntwk_prty_vals), 0x01, NULL, HFILL }},
2689
2690                 { &hf_sna_th_tgsf,
2691                 { "Transmission Group Segmenting Field", "sna.th.tgsf",
2692                     FT_UINT8, BASE_HEX, VALS(sna_th_tgsf_vals), 0xc0,
2693                     NULL, HFILL }},
2694
2695                 { &hf_sna_th_mft,
2696                 { "MPR FID4 Type", "sna.th.mft", FT_BOOLEAN, 8,
2697                     NULL, 0x04, NULL, HFILL }},
2698
2699                 { &hf_sna_th_piubf,
2700                 { "PIU Blocking Field", "sna.th.piubf", FT_UINT8, BASE_HEX,
2701                     VALS(sna_th_piubf_vals), 0x03, NULL, HFILL }},
2702
2703                 { &hf_sna_th_iern,
2704                 { "Initial Explicit Route Number", "sna.th.iern", FT_UINT8,
2705                     BASE_DEC, NULL, 0xf0, NULL, HFILL }},
2706
2707                 { &hf_sna_th_nlpoi,
2708                 { "NLP Offset Indicator", "sna.th.nlpoi", FT_UINT8, BASE_DEC,
2709                     VALS(sna_th_nlpoi_vals), 0x80, NULL, HFILL }},
2710
2711                 { &hf_sna_th_nlp_cp,
2712                 { "NLP Count or Padding", "sna.th.nlp_cp", FT_UINT8, BASE_DEC,
2713                     NULL, 0x70, NULL, HFILL }},
2714
2715                 { &hf_sna_th_ern,
2716                 { "Explicit Route Number", "sna.th.ern", FT_UINT8, BASE_DEC,
2717                     NULL, 0x0f, NULL, HFILL }},
2718
2719                 { &hf_sna_th_vrn,
2720                 { "Virtual Route Number", "sna.th.vrn", FT_UINT8, BASE_DEC,
2721                     NULL, 0xf0, NULL, HFILL }},
2722
2723                 { &hf_sna_th_tpf,
2724                 { "Transmission Priority Field", "sna.th.tpf", FT_UINT8,
2725                     BASE_HEX, VALS(sna_th_tpf_vals), 0x03, NULL, HFILL }},
2726
2727                 { &hf_sna_th_vr_cwi,
2728                 { "Virtual Route Change Window Indicator", "sna.th.vr_cwi",
2729                     FT_UINT16, BASE_DEC, VALS(sna_th_vr_cwi_vals), 0x8000,
2730                     "Change Window Indicator", HFILL }},
2731
2732                 { &hf_sna_th_tg_nonfifo_ind,
2733                 { "Transmission Group Non-FIFO Indicator",
2734                     "sna.th.tg_nonfifo_ind", FT_BOOLEAN, 16,
2735                     TFS(&sna_th_tg_nonfifo_ind_truth), 0x4000, NULL, HFILL }},
2736
2737                 { &hf_sna_th_vr_sqti,
2738                 { "Virtual Route Sequence and Type Indicator", "sna.th.vr_sqti",
2739                     FT_UINT16, BASE_HEX, VALS(sna_th_vr_sqti_vals), 0x3000,
2740                     "Route Sequence and Type", HFILL }},
2741
2742                 { &hf_sna_th_tg_snf,
2743                 { "Transmission Group Sequence Number Field", "sna.th.tg_snf",
2744                     FT_UINT16, BASE_DEC, NULL, 0x0fff, NULL, HFILL }},
2745
2746                 { &hf_sna_th_vrprq,
2747                 { "Virtual Route Pacing Request", "sna.th.vrprq", FT_BOOLEAN,
2748                     16, TFS(&sna_th_vrprq_truth), 0x8000, NULL, HFILL }},
2749
2750                 { &hf_sna_th_vrprs,
2751                 { "Virtual Route Pacing Response", "sna.th.vrprs", FT_BOOLEAN,
2752                     16, TFS(&sna_th_vrprs_truth), 0x4000, NULL, HFILL }},
2753
2754                 { &hf_sna_th_vr_cwri,
2755                 { "Virtual Route Change Window Reply Indicator",
2756                     "sna.th.vr_cwri", FT_UINT16, BASE_DEC,
2757                     VALS(sna_th_vr_cwri_vals), 0x2000, NULL, HFILL }},
2758
2759                 { &hf_sna_th_vr_rwi,
2760                 { "Virtual Route Reset Window Indicator", "sna.th.vr_rwi",
2761                     FT_BOOLEAN, 16, TFS(&sna_th_vr_rwi_truth), 0x1000,
2762                     NULL, HFILL }},
2763
2764                 { &hf_sna_th_vr_snf_send,
2765                 { "Virtual Route Send Sequence Number Field",
2766                     "sna.th.vr_snf_send", FT_UINT16, BASE_DEC, NULL, 0x0fff,
2767                     "Send Sequence Number Field", HFILL }},
2768
2769                 { &hf_sna_th_dsaf,
2770                 { "Destination Subarea Address Field", "sna.th.dsaf",
2771                     FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2772
2773                 { &hf_sna_th_osaf,
2774                 { "Origin Subarea Address Field", "sna.th.osaf", FT_UINT32,
2775                     BASE_HEX, NULL, 0x0, NULL, HFILL }},
2776
2777                 { &hf_sna_th_snai,
2778                 { "SNA Indicator", "sna.th.snai", FT_BOOLEAN, 8, NULL, 0x10,
2779                     "Used to identify whether the PIU originated or is destined for an SNA or non-SNA device.", HFILL }},
2780
2781                 { &hf_sna_th_def,
2782                 { "Destination Element Field", "sna.th.def", FT_UINT16,
2783                     BASE_HEX, NULL, 0x0, NULL, HFILL }},
2784
2785                 { &hf_sna_th_oef,
2786                 { "Origin Element Field", "sna.th.oef", FT_UINT16, BASE_HEX,
2787                     NULL, 0x0, NULL, HFILL }},
2788
2789                 { &hf_sna_th_sa,
2790                 { "Session Address", "sna.th.sa", FT_BYTES, BASE_NONE,
2791                     NULL, 0x0, NULL, HFILL }},
2792
2793                 { &hf_sna_th_cmd_fmt,
2794                 { "Command Format", "sna.th.cmd_fmt", FT_UINT8, BASE_HEX,
2795                     NULL, 0x0, NULL, HFILL }},
2796
2797                 { &hf_sna_th_cmd_type,
2798                 { "Command Type", "sna.th.cmd_type", FT_UINT8, BASE_HEX,
2799                     NULL, 0x0, NULL, HFILL }},
2800
2801                 { &hf_sna_th_cmd_sn,
2802                 { "Command Sequence Number", "sna.th.cmd_sn", FT_UINT16,
2803                     BASE_DEC, NULL, 0x0, NULL, HFILL }},
2804
2805                 { &hf_sna_nlp_nhdr,
2806                 { "Network Layer Packet Header", "sna.nlp.nhdr", FT_NONE,
2807                     BASE_NONE, NULL, 0x0, "NHDR", HFILL }},
2808
2809                 { &hf_sna_nlp_nhdr_0,
2810                 { "Network Layer Packet Header Byte 0", "sna.nlp.nhdr.0",
2811                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2812
2813                 { &hf_sna_nlp_nhdr_1,
2814                 { "Network Layer Packet Header Byte 1", "sna.nlp.nhdr.1",
2815                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2816
2817                 { &hf_sna_nlp_sm,
2818                 { "Switching Mode Field", "sna.nlp.nhdr.sm", FT_UINT8,
2819                     BASE_HEX, VALS(sna_nlp_sm_vals), 0xe0, NULL, HFILL }},
2820
2821                 { &hf_sna_nlp_tpf,
2822                 { "Transmission Priority Field", "sna.nlp.nhdr.tpf", FT_UINT8,
2823                     BASE_HEX, VALS(sna_th_tpf_vals), 0x06, NULL, HFILL }},
2824
2825                 { &hf_sna_nlp_ft,
2826                 { "Function Type", "sna.nlp.nhdr.ft", FT_UINT8, BASE_HEX,
2827                     VALS(sna_nlp_ft_vals), 0xF0, NULL, HFILL }},
2828
2829                 { &hf_sna_nlp_tspi,
2830                 { "Time Sensitive Packet Indicator", "sna.nlp.nhdr.tspi",
2831                     FT_BOOLEAN, 8, TFS(&sna_nlp_tspi_truth), 0x08, NULL, HFILL }},
2832
2833                 { &hf_sna_nlp_slowdn1,
2834                 { "Slowdown 1", "sna.nlp.nhdr.slowdn1", FT_BOOLEAN, 8,
2835                     TFS(&sna_nlp_slowdn1_truth), 0x04, NULL, HFILL }},
2836
2837                 { &hf_sna_nlp_slowdn2,
2838                 { "Slowdown 2", "sna.nlp.nhdr.slowdn2", FT_BOOLEAN, 8,
2839                     TFS(&sna_nlp_slowdn2_truth), 0x02, NULL, HFILL }},
2840
2841                 { &hf_sna_nlp_fra,
2842                 { "Function Routing Address Entry", "sna.nlp.nhdr.fra",
2843                     FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
2844
2845                 { &hf_sna_nlp_anr,
2846                 { "Automatic Network Routing Entry", "sna.nlp.nhdr.anr",
2847                     FT_BYTES, BASE_NONE, NULL, 0, NULL, HFILL }},
2848
2849                 { &hf_sna_nlp_frh,
2850                 { "Transmission Priority Field", "sna.nlp.frh", FT_UINT8,
2851                     BASE_HEX, VALS(sna_nlp_frh_vals), 0, NULL, HFILL }},
2852
2853                 { &hf_sna_nlp_thdr,
2854                 { "RTP Transport Header", "sna.nlp.thdr", FT_NONE, BASE_NONE,
2855                     NULL, 0x0, "THDR", HFILL }},
2856
2857                 { &hf_sna_nlp_tcid,
2858                 { "Transport Connection Identifier", "sna.nlp.thdr.tcid",
2859                     FT_BYTES, BASE_NONE, NULL, 0x0, "TCID", HFILL }},
2860
2861                 { &hf_sna_nlp_thdr_8,
2862                 { "RTP Transport Packet Header Byte 8", "sna.nlp.thdr.8",
2863                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2864
2865                 { &hf_sna_nlp_setupi,
2866                 { "Setup Indicator", "sna.nlp.thdr.setupi", FT_BOOLEAN, 8,
2867                     TFS(&sna_nlp_setupi_truth), 0x40, NULL, HFILL }},
2868
2869                 { &hf_sna_nlp_somi,
2870                 { "Start Of Message Indicator", "sna.nlp.thdr.somi",
2871                     FT_BOOLEAN, 8, TFS(&sna_nlp_somi_truth), 0x20, NULL, HFILL }},
2872
2873                 { &hf_sna_nlp_eomi,
2874                 { "End Of Message Indicator", "sna.nlp.thdr.eomi", FT_BOOLEAN,
2875                     8, TFS(&sna_nlp_eomi_truth), 0x10, NULL, HFILL }},
2876
2877                 { &hf_sna_nlp_sri,
2878                 { "Session Request Indicator", "sna.nlp.thdr.sri", FT_BOOLEAN,
2879                     8, TFS(&sna_nlp_sri_truth), 0x08, NULL, HFILL }},
2880
2881                 { &hf_sna_nlp_rasapi,
2882                 { "Reply ASAP Indicator", "sna.nlp.thdr.rasapi", FT_BOOLEAN,
2883                     8, TFS(&sna_nlp_rasapi_truth), 0x04, NULL, HFILL }},
2884
2885                 { &hf_sna_nlp_retryi,
2886                 { "Retry Indicator", "sna.nlp.thdr.retryi", FT_BOOLEAN,
2887                     8, TFS(&sna_nlp_retryi_truth), 0x02, NULL, HFILL }},
2888
2889                 { &hf_sna_nlp_thdr_9,
2890                 { "RTP Transport Packet Header Byte 9", "sna.nlp.thdr.9",
2891                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2892
2893                 { &hf_sna_nlp_lmi,
2894                 { "Last Message Indicator", "sna.nlp.thdr.lmi", FT_BOOLEAN,
2895                     8, TFS(&sna_nlp_lmi_truth), 0x80, NULL, HFILL }},
2896
2897                 { &hf_sna_nlp_cqfi,
2898                 { "Connection Qualifier Field Indicator", "sna.nlp.thdr.cqfi",
2899                     FT_BOOLEAN, 8, TFS(&sna_nlp_cqfi_truth), 0x08, NULL, HFILL }},
2900
2901                 { &hf_sna_nlp_osi,
2902                 { "Optional Segments Present Indicator", "sna.nlp.thdr.osi",
2903                     FT_BOOLEAN, 8, TFS(&sna_nlp_osi_truth), 0x04, NULL, HFILL }},
2904
2905                 { &hf_sna_nlp_offset,
2906                 { "Data Offset/4", "sna.nlp.thdr.offset", FT_UINT16, BASE_HEX,
2907                     NULL, 0x0, "Data Offset in Words", HFILL }},
2908
2909                 { &hf_sna_nlp_dlf,
2910                 { "Data Length Field", "sna.nlp.thdr.dlf", FT_UINT32, BASE_HEX,
2911                     NULL, 0x0, NULL, HFILL }},
2912
2913                 { &hf_sna_nlp_bsn,
2914                 { "Byte Sequence Number", "sna.nlp.thdr.bsn", FT_UINT32,
2915                     BASE_HEX, NULL, 0x0, NULL, HFILL }},
2916
2917                 { &hf_sna_nlp_opti_len,
2918                 { "Optional Segment Length/4", "sna.nlp.thdr.optional.len",
2919                     FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2920
2921                 { &hf_sna_nlp_opti_type,
2922                 { "Optional Segment Type", "sna.nlp.thdr.optional.type",
2923                     FT_UINT8, BASE_HEX, VALS(sna_nlp_opti_vals), 0x0, NULL,
2924                     HFILL }},
2925
2926                 { &hf_sna_nlp_opti_0d_version,
2927                 { "Version", "sna.nlp.thdr.optional.0d.version",
2928                     FT_UINT16, BASE_HEX, VALS(sna_nlp_opti_0d_version_vals),
2929                     0, NULL, HFILL }},
2930
2931                 { &hf_sna_nlp_opti_0d_4,
2932                 { "Connection Setup Byte 4", "sna.nlp.thdr.optional.0e.4",
2933                     FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
2934
2935                 { &hf_sna_nlp_opti_0d_target,
2936                 { "Target Resource ID Present",
2937                     "sna.nlp.thdr.optional.0d.target",
2938                     FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
2939
2940                 { &hf_sna_nlp_opti_0d_arb,
2941                 { "ARB Flow Control", "sna.nlp.thdr.optional.0d.arb",
2942                     FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
2943
2944                 { &hf_sna_nlp_opti_0d_reliable,
2945                 { "Reliable Connection", "sna.nlp.thdr.optional.0d.reliable",
2946                     FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
2947
2948                 { &hf_sna_nlp_opti_0d_dedicated,
2949                 { "Dedicated RTP Connection",
2950                     "sna.nlp.thdr.optional.0d.dedicated",
2951                     FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
2952
2953                 { &hf_sna_nlp_opti_0e_stat,
2954                 { "Status", "sna.nlp.thdr.optional.0e.stat",
2955                     FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL }},
2956
2957                 { &hf_sna_nlp_opti_0e_gap,
2958                 { "Gap Detected", "sna.nlp.thdr.optional.0e.gap",
2959                     FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
2960
2961                 { &hf_sna_nlp_opti_0e_idle,
2962                 { "RTP Idle Packet", "sna.nlp.thdr.optional.0e.idle",
2963                     FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
2964
2965                 { &hf_sna_nlp_opti_0e_nabsp,
2966                 { "Number Of ABSP", "sna.nlp.thdr.optional.0e.nabsp",
2967                     FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
2968
2969                 { &hf_sna_nlp_opti_0e_sync,
2970                 { "Status Report Number", "sna.nlp.thdr.optional.0e.sync",
2971                     FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2972
2973                 { &hf_sna_nlp_opti_0e_echo,
2974                 { "Status Acknowledge Number", "sna.nlp.thdr.optional.0e.echo",
2975                     FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2976
2977                 { &hf_sna_nlp_opti_0e_rseq,
2978                 { "Received Sequence Number", "sna.nlp.thdr.optional.0e.rseq",
2979                     FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2980
2981                 { &hf_sna_nlp_opti_0e_abspbeg,
2982                 { "ABSP Begin", "sna.nlp.thdr.optional.0e.abspbeg",
2983                     FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2984
2985                 { &hf_sna_nlp_opti_0e_abspend,
2986                 { "ABSP End", "sna.nlp.thdr.optional.0e.abspend",
2987                     FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL }},
2988
2989                 { &hf_sna_nlp_opti_0f_bits,
2990                 { "Client Bits", "sna.nlp.thdr.optional.0f.bits",
2991                     FT_UINT8, BASE_HEX, VALS(sna_nlp_opti_0f_bits_vals),
2992                     0x0, NULL, HFILL }},
2993
2994                 { &hf_sna_nlp_opti_10_tcid,
2995                 { "Transport Connection Identifier",
2996                     "sna.nlp.thdr.optional.10.tcid",
2997                     FT_BYTES, BASE_NONE, NULL, 0x0, "TCID", HFILL }},
2998
2999                 { &hf_sna_nlp_opti_12_sense,
3000                 { "Sense Data", "sna.nlp.thdr.optional.12.sense",
3001                     FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }},
3002
3003                 { &hf_sna_nlp_opti_14_si_len,
3004                 { "Length", "sna.nlp.thdr.optional.14.si.len",
3005                     FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3006
3007                 { &hf_sna_nlp_opti_14_si_key,
3008                 { "Key", "sna.nlp.thdr.optional.14.si.key",
3009                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3010
3011                 { &hf_sna_nlp_opti_14_si_2,
3012                 { "Switching Information Byte 2",
3013                     "sna.nlp.thdr.optional.14.si.2",
3014                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3015
3016                 { &hf_sna_nlp_opti_14_si_refifo,
3017                 { "Resequencing (REFIFO) Indicator",
3018                     "sna.nlp.thdr.optional.14.si.refifo",
3019                     FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
3020
3021                 { &hf_sna_nlp_opti_14_si_mobility,
3022                 { "Mobility Indicator",
3023                     "sna.nlp.thdr.optional.14.si.mobility",
3024                     FT_BOOLEAN, 8, NULL, 0x40, NULL, HFILL }},
3025
3026                 { &hf_sna_nlp_opti_14_si_dirsearch,
3027                 { "Directory Search Required on Path Switch Indicator",
3028                     "sna.nlp.thdr.optional.14.si.dirsearch",
3029                     FT_BOOLEAN, 8, NULL, 0x20, NULL, HFILL }},
3030
3031                 { &hf_sna_nlp_opti_14_si_limitres,
3032                 { "Limited Resource Link Indicator",
3033                     "sna.nlp.thdr.optional.14.si.limitres",
3034                     FT_BOOLEAN, 8, NULL, 0x10, NULL, HFILL }},
3035
3036                 { &hf_sna_nlp_opti_14_si_ncescope,
3037                 { "NCE Scope Indicator",
3038                     "sna.nlp.thdr.optional.14.si.ncescope",
3039                     FT_BOOLEAN, 8, NULL, 0x08, NULL, HFILL }},
3040
3041                 { &hf_sna_nlp_opti_14_si_mnpsrscv,
3042                 { "MNPS RSCV Retention Indicator",
3043                     "sna.nlp.thdr.optional.14.si.mnpsrscv",
3044                     FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
3045
3046                 { &hf_sna_nlp_opti_14_si_maxpsize,
3047                 { "Maximum Packet Size On Return Path",
3048                     "sna.nlp.thdr.optional.14.si.maxpsize",
3049                     FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3050
3051                 { &hf_sna_nlp_opti_14_si_switch,
3052                 { "Path Switch Time", "sna.nlp.thdr.optional.14.si.switch",
3053                     FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3054
3055                 { &hf_sna_nlp_opti_14_si_alive,
3056                 { "RTP Alive Timer", "sna.nlp.thdr.optional.14.si.alive",
3057                     FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3058
3059                 { &hf_sna_nlp_opti_14_rr_len,
3060                 { "Length", "sna.nlp.thdr.optional.14.rr.len",
3061                     FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3062
3063                 { &hf_sna_nlp_opti_14_rr_key,
3064                 { "Key", "sna.nlp.thdr.optional.14.rr.key",
3065                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3066
3067                 { &hf_sna_nlp_opti_14_rr_2,
3068                 { "Return Route TG Descriptor Byte 2",
3069                     "sna.nlp.thdr.optional.14.rr.2",
3070                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3071
3072                 { &hf_sna_nlp_opti_14_rr_bfe,
3073                 { "BF Entry Indicator",
3074                     "sna.nlp.thdr.optional.14.rr.bfe",
3075                     FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
3076
3077                 { &hf_sna_nlp_opti_14_rr_num,
3078                 { "Number Of TG Control Vectors",
3079                     "sna.nlp.thdr.optional.14.rr.num",
3080                     FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3081
3082                 { &hf_sna_nlp_opti_22_2,
3083                 { "Adaptive Rate Based Segment Byte 2",
3084                     "sna.nlp.thdr.optional.22.2",
3085                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3086
3087                 { &hf_sna_nlp_opti_22_type,
3088                 { "Message Type",
3089                     "sna.nlp.thdr.optional.22.type",
3090                     FT_UINT8, BASE_HEX,
3091                     VALS(sna_nlp_opti_22_type_vals), 0xc0, NULL, HFILL }},
3092
3093                 { &hf_sna_nlp_opti_22_raa,
3094                 { "Rate Adjustment Action",
3095                     "sna.nlp.thdr.optional.22.raa",
3096                     FT_UINT8, BASE_HEX,
3097                     VALS(sna_nlp_opti_22_raa_vals), 0x38, NULL, HFILL }},
3098
3099                 { &hf_sna_nlp_opti_22_parity,
3100                 { "Parity Indicator",
3101                     "sna.nlp.thdr.optional.22.parity",
3102                     FT_BOOLEAN, 8, NULL, 0x04, NULL, HFILL }},
3103
3104                 { &hf_sna_nlp_opti_22_arb,
3105                 { "ARB Mode",
3106                     "sna.nlp.thdr.optional.22.arb",
3107                     FT_UINT8, BASE_HEX,
3108                     VALS(sna_nlp_opti_22_arb_vals), 0x03, NULL, HFILL }},
3109
3110                 { &hf_sna_nlp_opti_22_3,
3111                 { "Adaptive Rate Based Segment Byte 3",
3112                     "sna.nlp.thdr.optional.22.3",
3113                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3114
3115                 { &hf_sna_nlp_opti_22_ratereq,
3116                 { "Rate Request Correlator",
3117                     "sna.nlp.thdr.optional.22.ratereq",
3118                     FT_UINT8, BASE_DEC, NULL, 0xf0, NULL, HFILL }},
3119
3120                 { &hf_sna_nlp_opti_22_raterep,
3121                 { "Rate Reply Correlator",
3122                     "sna.nlp.thdr.optional.22.raterep",
3123                     FT_UINT8, BASE_DEC, NULL, 0x0f, NULL, HFILL }},
3124
3125                 { &hf_sna_nlp_opti_22_field1,
3126                 { "Field 1", "sna.nlp.thdr.optional.22.field1",
3127                     FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3128
3129                 { &hf_sna_nlp_opti_22_field2,
3130                 { "Field 2", "sna.nlp.thdr.optional.22.field2",
3131                     FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3132
3133                 { &hf_sna_nlp_opti_22_field3,
3134                 { "Field 3", "sna.nlp.thdr.optional.22.field3",
3135                     FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3136
3137                 { &hf_sna_nlp_opti_22_field4,
3138                 { "Field 4", "sna.nlp.thdr.optional.22.field4",
3139                     FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3140
3141                 { &hf_sna_rh,
3142                 { "Request/Response Header", "sna.rh", FT_NONE, BASE_NONE,
3143                     NULL, 0x0, NULL, HFILL }},
3144
3145                 { &hf_sna_rh_0,
3146                 { "Request/Response Header Byte 0", "sna.rh.0", FT_UINT8,
3147                     BASE_HEX, NULL, 0x0, NULL, HFILL }},
3148
3149                 { &hf_sna_rh_1,
3150                 { "Request/Response Header Byte 1", "sna.rh.1", FT_UINT8,
3151                     BASE_HEX, NULL, 0x0, NULL, HFILL }},
3152
3153                 { &hf_sna_rh_2,
3154                 { "Request/Response Header Byte 2", "sna.rh.2", FT_UINT8,
3155                     BASE_HEX, NULL, 0x0, NULL, HFILL }},
3156
3157                 { &hf_sna_rh_rri,
3158                 { "Request/Response Indicator", "sna.rh.rri", FT_UINT8,
3159                     BASE_DEC, VALS(sna_rh_rri_vals), 0x80, NULL, HFILL }},
3160
3161                 { &hf_sna_rh_ru_category,
3162                 { "Request/Response Unit Category", "sna.rh.ru_category",
3163                     FT_UINT8, BASE_HEX, VALS(sna_rh_ru_category_vals), 0x60,
3164                     NULL, HFILL }},
3165
3166                 { &hf_sna_rh_fi,
3167                 { "Format Indicator", "sna.rh.fi", FT_BOOLEAN, 8,
3168                     TFS(&sna_rh_fi_truth), 0x08, NULL, HFILL }},
3169
3170                 { &hf_sna_rh_sdi,
3171                 { "Sense Data Included", "sna.rh.sdi", FT_BOOLEAN, 8,
3172                     TFS(&sna_rh_sdi_truth), 0x04, NULL, HFILL }},
3173
3174                 { &hf_sna_rh_bci,
3175                 { "Begin Chain Indicator", "sna.rh.bci", FT_BOOLEAN, 8,
3176                     TFS(&sna_rh_bci_truth), 0x02, NULL, HFILL }},
3177
3178                 { &hf_sna_rh_eci,
3179                 { "End Chain Indicator", "sna.rh.eci", FT_BOOLEAN, 8,
3180                     TFS(&sna_rh_eci_truth), 0x01, NULL, HFILL }},
3181
3182                 { &hf_sna_rh_dr1,
3183                 { "Definite Response 1 Indicator", "sna.rh.dr1", FT_BOOLEAN,
3184                     8, NULL, 0x80, NULL, HFILL }},
3185
3186                 { &hf_sna_rh_lcci,
3187                 { "Length-Checked Compression Indicator", "sna.rh.lcci",
3188                     FT_BOOLEAN, 8, TFS(&sna_rh_lcci_truth), 0x40, NULL, HFILL }},
3189
3190                 { &hf_sna_rh_dr2,
3191                 { "Definite Response 2 Indicator", "sna.rh.dr2", FT_BOOLEAN,
3192                     8, NULL, 0x20, NULL, HFILL }},
3193
3194                 { &hf_sna_rh_eri,
3195                 { "Exception Response Indicator", "sna.rh.eri", FT_BOOLEAN,
3196                     8, NULL, 0x10, NULL, HFILL }},
3197
3198                 { &hf_sna_rh_rti,
3199                 { "Response Type Indicator", "sna.rh.rti", FT_BOOLEAN,
3200                     8, TFS(&sna_rh_rti_truth), 0x10, NULL, HFILL }},
3201
3202                 { &hf_sna_rh_rlwi,
3203                 { "Request Larger Window Indicator", "sna.rh.rlwi", FT_BOOLEAN,
3204                     8, NULL, 0x04, NULL, HFILL }},
3205
3206                 { &hf_sna_rh_qri,
3207                 { "Queued Response Indicator", "sna.rh.qri", FT_BOOLEAN,
3208                     8, TFS(&sna_rh_qri_truth), 0x02, NULL, HFILL }},
3209
3210                 { &hf_sna_rh_pi,
3211                 { "Pacing Indicator", "sna.rh.pi", FT_BOOLEAN,
3212                     8, NULL, 0x01, NULL, HFILL }},
3213
3214                 { &hf_sna_rh_bbi,
3215                 { "Begin Bracket Indicator", "sna.rh.bbi", FT_BOOLEAN,
3216                     8, NULL, 0x80, NULL, HFILL }},
3217
3218                 { &hf_sna_rh_ebi,
3219                 { "End Bracket Indicator", "sna.rh.ebi", FT_BOOLEAN,
3220                     8, NULL, 0x40, NULL, HFILL }},
3221
3222                 { &hf_sna_rh_cdi,
3223                 { "Change Direction Indicator", "sna.rh.cdi", FT_BOOLEAN,
3224                     8, NULL, 0x20, NULL, HFILL }},
3225
3226                 { &hf_sna_rh_csi,
3227                 { "Code Selection Indicator", "sna.rh.csi", FT_UINT8, BASE_DEC,
3228                     VALS(sna_rh_csi_vals), 0x08, NULL, HFILL }},
3229
3230                 { &hf_sna_rh_edi,
3231                 { "Enciphered Data Indicator", "sna.rh.edi", FT_BOOLEAN, 8,
3232                     NULL, 0x04, NULL, HFILL }},
3233
3234                 { &hf_sna_rh_pdi,
3235                 { "Padded Data Indicator", "sna.rh.pdi", FT_BOOLEAN, 8, NULL,
3236                     0x02, NULL, HFILL }},
3237
3238                 { &hf_sna_rh_cebi,
3239                 { "Conditional End Bracket Indicator", "sna.rh.cebi",
3240                     FT_BOOLEAN, 8, NULL, 0x01, NULL, HFILL }},
3241
3242 /*              { &hf_sna_ru,
3243                 { "Request/Response Unit", "sna.ru", FT_NONE, BASE_NONE,
3244                     NULL, 0x0, NULL, HFILL }},*/
3245
3246                 { &hf_sna_gds,
3247                 { "GDS Variable", "sna.gds", FT_NONE, BASE_NONE, NULL, 0x0,
3248                     NULL, HFILL }},
3249
3250                 { &hf_sna_gds_len,
3251                 { "GDS Variable Length", "sna.gds.len", FT_UINT16, BASE_DEC,
3252                     NULL, 0x7fff, NULL, HFILL }},
3253
3254                 { &hf_sna_gds_cont,
3255                 { "Continuation Flag", "sna.gds.cont", FT_BOOLEAN, 16, NULL,
3256                     0x8000, NULL, HFILL }},
3257
3258                 { &hf_sna_gds_type,
3259                 { "Type of Variable", "sna.gds.type", FT_UINT16, BASE_HEX,
3260                     VALS(sna_gds_var_vals), 0x0, NULL, HFILL }},
3261
3262                 { &hf_sna_xid,
3263                 { "XID", "sna.xid", FT_NONE, BASE_NONE, NULL, 0x0,
3264                     "XID Frame", HFILL }},
3265
3266                 { &hf_sna_xid_0,
3267                 { "XID Byte 0", "sna.xid.0", FT_UINT8, BASE_HEX, NULL, 0x0,
3268                     NULL, HFILL }},
3269
3270                 { &hf_sna_xid_format,
3271                 { "XID Format", "sna.xid.format", FT_UINT8, BASE_DEC, NULL,
3272                     0xf0, NULL, HFILL }},
3273
3274                 { &hf_sna_xid_type,
3275                 { "XID Type", "sna.xid.type", FT_UINT8, BASE_DEC,
3276                     VALS(sna_xid_type_vals), 0x0f, NULL, HFILL }},
3277
3278                 { &hf_sna_xid_len,
3279                 { "XID Length", "sna.xid.len", FT_UINT8, BASE_DEC, NULL, 0x0,
3280                     NULL, HFILL }},
3281
3282                 { &hf_sna_xid_id,
3283                 { "Node Identification", "sna.xid.id", FT_UINT32, BASE_HEX,
3284                     NULL, 0x0, NULL, HFILL }},
3285
3286                 { &hf_sna_xid_idblock,
3287                 { "ID Block", "sna.xid.idblock", FT_UINT32, BASE_HEX, NULL,
3288                     0xfff00000, NULL, HFILL }},
3289
3290                 { &hf_sna_xid_idnum,
3291                 { "ID Number", "sna.xid.idnum", FT_UINT32, BASE_HEX, NULL,
3292                     0x0fffff, NULL, HFILL }},
3293
3294                 { &hf_sna_xid_3_8,
3295                 { "Characteristics of XID sender", "sna.xid.type3.8", FT_UINT16,
3296                     BASE_HEX, NULL, 0x0, NULL, HFILL }},
3297
3298                 { &hf_sna_xid_3_init_self,
3299                 { "INIT-SELF support", "sna.xid.type3.initself",
3300                     FT_BOOLEAN, 16, NULL, 0x8000, NULL, HFILL }},
3301
3302                 { &hf_sna_xid_3_stand_bind,
3303                 { "Stand-Alone BIND Support", "sna.xid.type3.stand_bind",
3304                     FT_BOOLEAN, 16, NULL, 0x4000, NULL, HFILL }},
3305
3306                 { &hf_sna_xid_3_gener_bind,
3307                 { "Whole BIND PIU generated indicator",
3308                     "sna.xid.type3.gener_bind", FT_BOOLEAN, 16, NULL, 0x2000,
3309                     "Whole BIND PIU generated", HFILL }},
3310
3311                 { &hf_sna_xid_3_recve_bind,
3312                 { "Whole BIND PIU required indicator",
3313                     "sna.xid.type3.recve_bind", FT_BOOLEAN, 16, NULL, 0x1000,
3314                     "Whole BIND PIU required", HFILL }},
3315
3316                 { &hf_sna_xid_3_actpu,
3317                 { "ACTPU suppression indicator", "sna.xid.type3.actpu",
3318                     FT_BOOLEAN, 16, NULL, 0x0080, NULL, HFILL }},
3319
3320                 { &hf_sna_xid_3_nwnode,
3321                 { "Sender is network node", "sna.xid.type3.nwnode",
3322                     FT_BOOLEAN, 16, NULL, 0x0040, NULL, HFILL }},
3323
3324                 { &hf_sna_xid_3_cp,
3325                 { "Control Point Services", "sna.xid.type3.cp",
3326                     FT_BOOLEAN, 16, NULL, 0x0020, NULL, HFILL }},
3327
3328                 { &hf_sna_xid_3_cpcp,
3329                 { "CP-CP session support", "sna.xid.type3.cpcp",
3330                     FT_BOOLEAN, 16, NULL, 0x0010, NULL, HFILL }},
3331
3332                 { &hf_sna_xid_3_state,
3333                 { "XID exchange state indicator", "sna.xid.type3.state",
3334                     FT_UINT16, BASE_HEX, VALS(sna_xid_3_state_vals),
3335                     0x000c, NULL, HFILL }},
3336
3337                 { &hf_sna_xid_3_nonact,
3338                 { "Nonactivation Exchange", "sna.xid.type3.nonact",
3339                     FT_BOOLEAN, 16, NULL, 0x0002, NULL, HFILL }},
3340
3341                 { &hf_sna_xid_3_cpchange,
3342                 { "CP name change support", "sna.xid.type3.cpchange",
3343                     FT_BOOLEAN, 16, NULL, 0x0001, NULL, HFILL }},
3344
3345                 { &hf_sna_xid_3_10,
3346                 { "XID Type 3 Byte 10", "sna.xid.type3.10", FT_UINT8, BASE_HEX,
3347                     NULL, 0x0, NULL, HFILL }},
3348
3349                 { &hf_sna_xid_3_asend_bind,
3350                 { "Adaptive BIND pacing support as sender",
3351                     "sna.xid.type3.asend_bind", FT_BOOLEAN, 8, NULL, 0x80,
3352                     "Pacing support as sender", HFILL }},
3353
3354                 { &hf_sna_xid_3_arecv_bind,
3355                 { "Adaptive BIND pacing support as receiver",
3356                     "sna.xid.type3.asend_recv", FT_BOOLEAN, 8, NULL, 0x40,
3357                     "Pacing support as receive", HFILL }},
3358
3359                 { &hf_sna_xid_3_quiesce,
3360                 { "Quiesce TG Request",
3361                     "sna.xid.type3.quiesce", FT_BOOLEAN, 8, NULL, 0x20,
3362                     NULL, HFILL }},
3363
3364                 { &hf_sna_xid_3_pucap,
3365                 { "PU Capabilities",
3366                     "sna.xid.type3.pucap", FT_BOOLEAN, 8, NULL, 0x10,
3367                     NULL, HFILL }},
3368
3369                 { &hf_sna_xid_3_pbn,
3370                 { "Peripheral Border Node",
3371                     "sna.xid.type3.pbn", FT_BOOLEAN, 8, NULL, 0x08,
3372                     NULL, HFILL }},
3373
3374                 { &hf_sna_xid_3_pacing,
3375                 { "Qualifier for adaptive BIND pacing support",
3376                     "sna.xid.type3.pacing", FT_UINT8, BASE_HEX, NULL, 0x03,
3377                     NULL, HFILL }},
3378
3379                 { &hf_sna_xid_3_11,
3380                 { "XID Type 3 Byte 11", "sna.xid.type3.11", FT_UINT8, BASE_HEX,
3381                     NULL, 0x0, NULL, HFILL }},
3382
3383                 { &hf_sna_xid_3_tgshare,
3384                 { "TG Sharing Prohibited Indicator",
3385                     "sna.xid.type3.tgshare", FT_BOOLEAN, 8, NULL, 0x40,
3386                     NULL, HFILL }},
3387
3388                 { &hf_sna_xid_3_dedsvc,
3389                 { "Dedicated SVC Indicator",
3390                     "sna.xid.type3.dedsvc", FT_BOOLEAN, 8, NULL, 0x20,
3391                     NULL, HFILL }},
3392
3393                 { &hf_sna_xid_3_12,
3394                 { "XID Type 3 Byte 12", "sna.xid.type3.12", FT_UINT8, BASE_HEX,
3395                     NULL, 0x0, NULL, HFILL }},
3396
3397                 { &hf_sna_xid_3_negcsup,
3398                 { "Negotiation Complete Supported",
3399                     "sna.xid.type3.negcsup", FT_BOOLEAN, 8, NULL, 0x80,
3400                     NULL, HFILL }},
3401
3402                 { &hf_sna_xid_3_negcomp,
3403                 { "Negotiation Complete",
3404                     "sna.xid.type3.negcomp", FT_BOOLEAN, 8, NULL, 0x40,
3405                     NULL, HFILL }},
3406
3407                 { &hf_sna_xid_3_15,
3408                 { "XID Type 3 Byte 15", "sna.xid.type3.15", FT_UINT8, BASE_HEX,
3409                     NULL, 0x0, NULL, HFILL }},
3410
3411                 { &hf_sna_xid_3_partg,
3412                 { "Parallel TG Support",
3413                     "sna.xid.type3.partg", FT_BOOLEAN, 8, NULL, 0x80,
3414                     NULL, HFILL }},
3415
3416                 { &hf_sna_xid_3_dlur,
3417                 { "Dependent LU Requester Indicator",
3418                     "sna.xid.type3.dlur", FT_BOOLEAN, 8, NULL, 0x40,
3419                     NULL, HFILL }},
3420
3421                 { &hf_sna_xid_3_dlus,
3422                 { "DLUS Served LU Registration Indicator",
3423                     "sna.xid.type3.dlus", FT_BOOLEAN, 8, NULL, 0x20,
3424                     NULL, HFILL }},
3425
3426                 { &hf_sna_xid_3_exbn,
3427                 { "Extended HPR Border Node",
3428                     "sna.xid.type3.exbn", FT_BOOLEAN, 8, NULL, 0x10,
3429                     NULL, HFILL }},
3430
3431                 { &hf_sna_xid_3_genodai,
3432                 { "Generalized ODAI Usage Option",
3433                     "sna.xid.type3.genodai", FT_BOOLEAN, 8, NULL, 0x08,
3434                     NULL, HFILL }},
3435
3436                 { &hf_sna_xid_3_branch,
3437                 { "Branch Indicator", "sna.xid.type3.branch",
3438                     FT_UINT8, BASE_HEX, VALS(sna_xid_3_branch_vals),
3439                     0x06, NULL, HFILL }},
3440
3441                 { &hf_sna_xid_3_brnn,
3442                 { "Option Set 1123 Indicator",
3443                     "sna.xid.type3.brnn", FT_BOOLEAN, 8, NULL, 0x01,
3444                     NULL, HFILL }},
3445
3446                 { &hf_sna_xid_3_tg,
3447                 { "XID TG", "sna.xid.type3.tg", FT_UINT8, BASE_HEX, NULL, 0x0,
3448                     NULL, HFILL }},
3449
3450                 { &hf_sna_xid_3_dlc,
3451                 { "XID DLC", "sna.xid.type3.dlc", FT_UINT8, BASE_HEX, NULL, 0x0,
3452                     NULL, HFILL }},
3453
3454                 { &hf_sna_xid_3_dlen,
3455                 { "DLC Dependent Section Length", "sna.xid.type3.dlen",
3456                     FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3457
3458                 { &hf_sna_control_len,
3459                 { "Control Vector Length", "sna.control.len",
3460                     FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3461
3462                 { &hf_sna_control_key,
3463                 { "Control Vector Key", "sna.control.key",
3464                     FT_UINT8, BASE_HEX, VALS(sna_control_vals), 0x0, NULL,
3465                     HFILL }},
3466
3467                 { &hf_sna_control_hprkey,
3468                 { "Control Vector HPR Key", "sna.control.hprkey",
3469                     FT_UINT8, BASE_HEX, VALS(sna_control_hpr_vals), 0x0, NULL,
3470                     HFILL }},
3471
3472                 { &hf_sna_control_05_delay,
3473                 { "Channel Delay", "sna.control.05.delay",
3474                     FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
3475
3476                 { &hf_sna_control_05_type,
3477                 { "Network Address Type", "sna.control.05.type",
3478                     FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }},
3479
3480                 { &hf_sna_control_05_ptp,
3481                 { "Point-to-point", "sna.control.05.ptp",
3482                     FT_BOOLEAN, 8, NULL, 0x80, NULL, HFILL }},
3483
3484                 { &hf_sna_control_0e_type,
3485                 { "Type", "sna.control.0e.type",
3486                     FT_UINT8, BASE_HEX, VALS(sna_control_0e_type_vals),
3487                     0, NULL, HFILL }},
3488
3489                 { &hf_sna_control_0e_value,
3490                 { "Value", "sna.control.0e.value",
3491                     FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }},
3492         };
3493         static gint *ett[] = {
3494                 &ett_sna,
3495                 &ett_sna_th,
3496                 &ett_sna_th_fid,
3497                 &ett_sna_nlp_nhdr,
3498                 &ett_sna_nlp_nhdr_0,
3499                 &ett_sna_nlp_nhdr_1,
3500                 &ett_sna_nlp_thdr,
3501                 &ett_sna_nlp_thdr_8,
3502                 &ett_sna_nlp_thdr_9,
3503                 &ett_sna_nlp_opti_un,
3504                 &ett_sna_nlp_opti_0d,
3505                 &ett_sna_nlp_opti_0d_4,
3506                 &ett_sna_nlp_opti_0e,
3507                 &ett_sna_nlp_opti_0e_stat,
3508                 &ett_sna_nlp_opti_0e_absp,
3509                 &ett_sna_nlp_opti_0f,
3510                 &ett_sna_nlp_opti_10,
3511                 &ett_sna_nlp_opti_12,
3512                 &ett_sna_nlp_opti_14,
3513                 &ett_sna_nlp_opti_14_si,
3514                 &ett_sna_nlp_opti_14_si_2,
3515                 &ett_sna_nlp_opti_14_rr,
3516                 &ett_sna_nlp_opti_14_rr_2,
3517                 &ett_sna_nlp_opti_22,
3518                 &ett_sna_nlp_opti_22_2,
3519                 &ett_sna_nlp_opti_22_3,
3520                 &ett_sna_rh,
3521                 &ett_sna_rh_0,
3522                 &ett_sna_rh_1,
3523                 &ett_sna_rh_2,
3524                 &ett_sna_gds,
3525                 &ett_sna_xid_0,
3526                 &ett_sna_xid_id,
3527                 &ett_sna_xid_3_8,
3528                 &ett_sna_xid_3_10,
3529                 &ett_sna_xid_3_11,
3530                 &ett_sna_xid_3_12,
3531                 &ett_sna_xid_3_15,
3532                 &ett_sna_control_un,
3533                 &ett_sna_control_05,
3534                 &ett_sna_control_05hpr,
3535                 &ett_sna_control_05hpr_type,
3536                 &ett_sna_control_0e,
3537         };
3538         module_t *sna_module;
3539
3540         proto_sna = proto_register_protocol("Systems Network Architecture",
3541             "SNA", "sna");
3542         proto_register_field_array(proto_sna, hf, array_length(hf));
3543         proto_register_subtree_array(ett, array_length(ett));
3544         register_dissector("sna", dissect_sna, proto_sna);
3545
3546         proto_sna_xid = proto_register_protocol(
3547             "Systems Network Architecture XID", "SNA XID", "sna_xid");
3548         register_dissector("sna_xid", dissect_sna_xid, proto_sna_xid);
3549
3550         /* Register configuration options */
3551         sna_module = prefs_register_protocol(proto_sna, NULL);
3552         prefs_register_bool_preference(sna_module, "defragment",
3553                 "Reassemble fragmented BIUs",
3554                 "Whether fragmented BIUs should be reassembled",
3555                 &sna_defragment);
3556
3557         register_init_routine(sna_init);
3558 }
3559
3560 void
3561 proto_reg_handoff_sna(void)
3562 {
3563         dissector_handle_t sna_handle;
3564         dissector_handle_t sna_xid_handle;
3565
3566         sna_handle = find_dissector("sna");
3567         sna_xid_handle = find_dissector("sna_xid");
3568         dissector_add_uint("llc.dsap", SAP_SNA_PATHCTRL, sna_handle);
3569         dissector_add_uint("llc.dsap", SAP_SNA1, sna_handle);
3570         dissector_add_uint("llc.dsap", SAP_SNA2, sna_handle);
3571         dissector_add_uint("llc.dsap", SAP_SNA3, sna_handle);
3572         dissector_add_uint("llc.xid_dsap", SAP_SNA_PATHCTRL, sna_xid_handle);
3573         dissector_add_uint("llc.xid_dsap", SAP_SNA1, sna_xid_handle);
3574         dissector_add_uint("llc.xid_dsap", SAP_SNA2, sna_xid_handle);
3575         dissector_add_uint("llc.xid_dsap", SAP_SNA3, sna_xid_handle);
3576         /* RFC 2043 */
3577         dissector_add_uint("ppp.protocol", PPP_SNA, sna_handle);
3578         data_handle = find_dissector("data");
3579
3580 }