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