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