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