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