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