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