3 * Gilbert Ramirez <gram@alumni.rice.edu>
5 * $Id: packet-sna.c,v 1.38 2002/01/21 07:36:43 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
35 #include <epan/packet.h>
37 #include <epan/sna-utils.h>
40 * http://www.wanresources.com/snacell.html
44 static int proto_sna = -1;
45 static int hf_sna_th = -1;
46 static int hf_sna_th_0 = -1;
47 static int hf_sna_th_fid = -1;
48 static int hf_sna_th_mpf = -1;
49 static int hf_sna_th_odai = -1;
50 static int hf_sna_th_efi = -1;
51 static int hf_sna_th_daf = -1;
52 static int hf_sna_th_oaf = -1;
53 static int hf_sna_th_snf = -1;
54 static int hf_sna_th_dcf = -1;
55 static int hf_sna_th_lsid = -1;
56 static int hf_sna_th_tg_sweep = -1;
57 static int hf_sna_th_er_vr_supp_ind = -1;
58 static int hf_sna_th_vr_pac_cnt_ind = -1;
59 static int hf_sna_th_ntwk_prty = -1;
60 static int hf_sna_th_tgsf = -1;
61 static int hf_sna_th_mft = -1;
62 static int hf_sna_th_piubf = -1;
63 static int hf_sna_th_iern = -1;
64 static int hf_sna_th_nlpoi = -1;
65 static int hf_sna_th_nlp_cp = -1;
66 static int hf_sna_th_ern = -1;
67 static int hf_sna_th_vrn = -1;
68 static int hf_sna_th_tpf = -1;
69 static int hf_sna_th_vr_cwi = -1;
70 static int hf_sna_th_tg_nonfifo_ind = -1;
71 static int hf_sna_th_vr_sqti = -1;
72 static int hf_sna_th_tg_snf = -1;
73 static int hf_sna_th_vrprq = -1;
74 static int hf_sna_th_vrprs = -1;
75 static int hf_sna_th_vr_cwri = -1;
76 static int hf_sna_th_vr_rwi = -1;
77 static int hf_sna_th_vr_snf_send = -1;
78 static int hf_sna_th_dsaf = -1;
79 static int hf_sna_th_osaf = -1;
80 static int hf_sna_th_snai = -1;
81 static int hf_sna_th_def = -1;
82 static int hf_sna_th_oef = -1;
83 static int hf_sna_th_sa = -1;
84 static int hf_sna_th_cmd_fmt = -1;
85 static int hf_sna_th_cmd_type = -1;
86 static int hf_sna_th_cmd_sn = -1;
88 static int hf_sna_rh = -1;
89 static int hf_sna_rh_0 = -1;
90 static int hf_sna_rh_1 = -1;
91 static int hf_sna_rh_2 = -1;
92 static int hf_sna_rh_rri = -1;
93 static int hf_sna_rh_ru_category = -1;
94 static int hf_sna_rh_fi = -1;
95 static int hf_sna_rh_sdi = -1;
96 static int hf_sna_rh_bci = -1;
97 static int hf_sna_rh_eci = -1;
98 static int hf_sna_rh_dr1 = -1;
99 static int hf_sna_rh_lcci = -1;
100 static int hf_sna_rh_dr2 = -1;
101 static int hf_sna_rh_eri = -1;
102 static int hf_sna_rh_rti = -1;
103 static int hf_sna_rh_rlwi = -1;
104 static int hf_sna_rh_qri = -1;
105 static int hf_sna_rh_pi = -1;
106 static int hf_sna_rh_bbi = -1;
107 static int hf_sna_rh_ebi = -1;
108 static int hf_sna_rh_cdi = -1;
109 static int hf_sna_rh_csi = -1;
110 static int hf_sna_rh_edi = -1;
111 static int hf_sna_rh_pdi = -1;
112 static int hf_sna_rh_cebi = -1;
113 /*static int hf_sna_ru = -1;*/
115 static gint ett_sna = -1;
116 static gint ett_sna_th = -1;
117 static gint ett_sna_th_fid = -1;
118 static gint ett_sna_rh = -1;
119 static gint ett_sna_rh_0 = -1;
120 static gint ett_sna_rh_1 = -1;
121 static gint ett_sna_rh_2 = -1;
123 static dissector_handle_t data_handle;
125 /* Format Identifier */
126 static const value_string sna_th_fid_vals[] = {
127 { 0x0, "SNA device <--> Non-SNA Device" },
128 { 0x1, "Subarea Nodes, without ER or VR" },
129 { 0x2, "Subarea Node <--> PU2" },
130 { 0x3, "Subarea Node or SNA host <--> Subarea Node" },
131 { 0x4, "Subarea Nodes, supporting ER and VR" },
132 { 0x5, "HPR RTP endpoint nodes" },
133 { 0xf, "Adjaced Subarea Nodes, supporting ER and VR" },
138 static const value_string sna_th_mpf_vals[] = {
139 { 0, "Middle segment of a BIU" },
140 { 1, "Last segment of a BIU" },
141 { 2, "First segment of a BIU" },
146 /* Expedited Flow Indicator */
147 static const value_string sna_th_efi_vals[] = {
148 { 0, "Normal Flow" },
149 { 1, "Expedited Flow" },
153 /* Request/Response Indicator */
154 static const value_string sna_rh_rri_vals[] = {
160 /* Request/Response Unit Category */
161 static const value_string sna_rh_ru_category_vals[] = {
162 { 0, "Function Management Data (FMD)" },
163 { 1, "Network Control (NC)" },
164 { 2, "Data Flow Control (DFC)" },
165 { 3, "Session Control (SC)" },
169 /* Format Indicator */
170 static const true_false_string sna_rh_fi_truth =
171 { "FM Header", "No FM Header" };
173 /* Sense Data Included */
174 static const true_false_string sna_rh_sdi_truth =
175 { "Included", "Not Included" };
177 /* Begin Chain Indicator */
178 static const true_false_string sna_rh_bci_truth =
179 { "First in Chain", "Not First in Chain" };
181 /* End Chain Indicator */
182 static const true_false_string sna_rh_eci_truth =
183 { "Last in Chain", "Not Last in Chain" };
185 /* Lengith-Checked Compression Indicator */
186 static const true_false_string sna_rh_lcci_truth =
187 { "Compressed", "Not Compressed" };
189 /* Response Type Indicator */
190 static const true_false_string sna_rh_rti_truth =
191 { "Negative", "Positive" };
193 /* Exception Response Indicator */
194 static const true_false_string sna_rh_eri_truth =
195 { "Exception", "Definite" };
197 /* Queued Response Indicator */
198 static const true_false_string sna_rh_qri_truth =
199 { "Enqueue response in TC queues", "Response bypasses TC queues" };
201 /* Code Selection Indicator */
202 static const value_string sna_rh_csi_vals[] = {
209 static const value_string sna_th_tg_sweep_vals[] = {
210 { 0, "This PIU may overtake any PU ahead of it." },
211 { 1, "This PIU does not ovetake any PIU ahead of it." },
216 static const value_string sna_th_er_vr_supp_ind_vals[] = {
217 { 0, "Each node supports ER and VR protocols" },
218 { 1, "Includes at least one node that does not support ER and VR protocols" },
223 static const value_string sna_th_vr_pac_cnt_ind_vals[] = {
224 { 0, "Pacing count on the VR has not reached 0" },
225 { 1, "Pacing count on the VR has reached 0" },
230 static const value_string sna_th_ntwk_prty_vals[] = {
231 { 0, "PIU flows at a lower priority" },
232 { 1, "PIU flows at network priority (highest transmission priority)" },
237 static const value_string sna_th_tgsf_vals[] = {
238 { 0, "Not segmented" },
239 { 1, "Last segment" },
240 { 2, "First segment" },
241 { 3, "Middle segment" },
246 static const value_string sna_th_piubf_vals[] = {
247 { 0, "Single PIU frame" },
248 { 1, "Last PIU of a multiple PIU frame" },
249 { 2, "First PIU of a multiple PIU frame" },
250 { 3, "Middle PIU of a multiple PIU frame" },
255 static const value_string sna_th_nlpoi_vals[] = {
256 { 0, "NLP starts within this FID4 TH" },
257 { 1, "NLP byte 0 starts after RH byte 0 following NLP C/P pad" },
262 static const value_string sna_th_tpf_vals[] = {
263 { 0, "Low Priority" },
264 { 1, "Medium Priority" },
265 { 2, "High Priority" },
270 static const value_string sna_th_vr_cwi_vals[] = {
271 { 0, "Increment window size" },
272 { 1, "Decrement window size" },
277 static const true_false_string sna_th_tg_nonfifo_ind_truth =
278 { "TG FIFO is not required", "TG FIFO is required" };
281 static const value_string sna_th_vr_sqti_vals[] = {
282 { 0, "Non-sequenced, Non-supervisory" },
283 { 1, "Non-sequenced, Supervisory" },
284 { 2, "Singly-sequenced" },
289 static const true_false_string sna_th_vrprq_truth = {
290 "VR pacing request is sent asking for a VR pacing response",
291 "No VR pacing response is requested",
295 static const true_false_string sna_th_vrprs_truth = {
296 "VR pacing response is sent in response to a VRPRQ bit set",
297 "No pacing response sent",
301 static const value_string sna_th_vr_cwri_vals[] = {
302 { 0, "Increment window size by 1" },
303 { 1, "Decrement window size by 1" },
308 static const true_false_string sna_th_vr_rwi_truth = {
309 "Reset window size to the minimum specified in NC_ACTVR",
310 "Do not reset window size",
313 static int dissect_fid0_1 (tvbuff_t*, packet_info*, proto_tree*);
314 static int dissect_fid2 (tvbuff_t*, packet_info*, proto_tree*);
315 static int dissect_fid3 (tvbuff_t*, proto_tree*);
316 static int dissect_fid4 (tvbuff_t*, packet_info*, proto_tree*);
317 static int dissect_fid5 (tvbuff_t*, proto_tree*);
318 static int dissect_fidf (tvbuff_t*, proto_tree*);
319 static void dissect_rh (tvbuff_t*, int, proto_tree*);
322 dissect_sna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
325 proto_tree *sna_tree = NULL, *th_tree = NULL, *rh_tree = NULL;
326 proto_item *sna_ti = NULL, *th_ti = NULL, *rh_ti = NULL;
328 int sna_header_len = 0, th_header_len = 0;
331 if (check_col(pinfo->cinfo, COL_PROTOCOL))
332 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNA");
333 if (check_col(pinfo->cinfo, COL_INFO))
334 col_clear(pinfo->cinfo, COL_INFO);
336 /* SNA data should be printed in EBCDIC, not ASCII */
337 pinfo->fd->flags.encoding = CHAR_EBCDIC;
339 /* Transmission Header Format Identifier */
340 th_fid = hi_nibble(tvb_get_guint8(tvb, 0));
342 /* Summary information */
343 if (check_col(pinfo->cinfo, COL_INFO))
344 col_add_str(pinfo->cinfo, COL_INFO,
345 val_to_str(th_fid, sna_th_fid_vals, "Unknown FID: %01x"));
349 /* Don't bother setting length. We'll set it later after we find
350 * the lengths of TH/RH/RU */
351 sna_ti = proto_tree_add_item(tree, proto_sna, tvb, 0, -1, FALSE);
352 sna_tree = proto_item_add_subtree(sna_ti, ett_sna);
355 /* Don't bother setting length. We'll set it later after we find
356 * the length of TH */
357 th_ti = proto_tree_add_item(sna_tree, hf_sna_th, tvb, 0, -1, FALSE);
358 th_tree = proto_item_add_subtree(th_ti, ett_sna_th);
365 th_header_len = dissect_fid0_1(tvb, pinfo, th_tree);
368 th_header_len = dissect_fid2(tvb, pinfo, th_tree);
371 th_header_len = dissect_fid3(tvb, th_tree);
374 th_header_len = dissect_fid4(tvb, pinfo, th_tree);
377 th_header_len = dissect_fid5(tvb, th_tree);
380 th_header_len = dissect_fidf(tvb, th_tree);
383 call_dissector(data_handle,tvb_new_subset(tvb, 1,-1,tvb_reported_length_remaining(tvb,1)), pinfo, tree);
386 sna_header_len += th_header_len;
387 offset = th_header_len;
390 proto_item_set_len(th_ti, th_header_len);
393 rh_ti = proto_tree_add_item(sna_tree, hf_sna_rh, tvb, offset, 3, FALSE);
394 rh_tree = proto_item_add_subtree(rh_ti, ett_sna_rh);
395 dissect_rh(tvb, offset, rh_tree);
399 proto_item_set_len(sna_ti, sna_header_len);
406 if (tvb_offset_exists(tvb, offset+1)) {
407 call_dissector(data_handle,tvb_new_subset(tvb, offset, -1, tvb_reported_length_remaining(tvb,offset)),pinfo, tree);
411 #define SNA_FID01_ADDR_LEN 2
413 /* FID Types 0 and 1 */
415 dissect_fid0_1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
422 const int bytes_in_header = 10;
426 th_0 = tvb_get_guint8(tvb, 0);
427 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
428 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
430 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
431 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
432 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
435 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
438 proto_tree_add_item(tree, hf_sna_th_daf, tvb, 2, 2, FALSE);
442 ptr = tvb_get_ptr(tvb, 2, SNA_FID01_ADDR_LEN);
443 SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
444 SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
447 proto_tree_add_item(tree, hf_sna_th_oaf, tvb, 4, 2, FALSE);
451 ptr = tvb_get_ptr(tvb, 4, SNA_FID01_ADDR_LEN);
452 SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
453 SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
455 /* If we're not filling a proto_tree, return now */
457 return bytes_in_header;
460 proto_tree_add_item(tree, hf_sna_th_snf, tvb, 6, 2, FALSE);
461 proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 8, 2, FALSE);
463 return bytes_in_header;
466 #define SNA_FID2_ADDR_LEN 1
470 dissect_fid2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
474 guint8 th_0=0, daf=0, oaf=0;
477 const int bytes_in_header = 6;
480 th_0 = tvb_get_guint8(tvb, 0);
481 daf = tvb_get_guint8(tvb, 2);
482 oaf = tvb_get_guint8(tvb, 3);
485 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
486 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
488 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
489 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
490 proto_tree_add_uint(bf_tree, hf_sna_th_odai,tvb, 0, 1, th_0);
491 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
494 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
497 proto_tree_add_uint_format(tree, hf_sna_th_daf, tvb, 2, 1, daf,
498 "Destination Address Field: 0x%02x", daf);
502 ptr = tvb_get_ptr(tvb, 2, SNA_FID2_ADDR_LEN);
503 SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
504 SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
508 proto_tree_add_uint_format(tree, hf_sna_th_oaf, tvb, 3, 1, oaf,
509 "Origin Address Field: 0x%02x", oaf);
513 ptr = tvb_get_ptr(tvb, 3, SNA_FID2_ADDR_LEN);
514 SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
515 SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
518 proto_tree_add_item(tree, hf_sna_th_snf, tvb, 4, 2, FALSE);
521 return bytes_in_header;
526 dissect_fid3(tvbuff_t *tvb, proto_tree *tree)
532 const int bytes_in_header = 2;
534 /* If we're not filling a proto_tree, return now */
536 return bytes_in_header;
539 th_0 = tvb_get_guint8(tvb, 0);
541 /* Create the bitfield tree */
542 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
543 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
545 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
546 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
547 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
549 proto_tree_add_item(tree, hf_sna_th_lsid, tvb, 1, 1, FALSE);
551 return bytes_in_header;
556 dissect_fid4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
565 static struct sna_fid_type_4_addr src, dst;
567 const int bytes_in_header = 26;
569 /* If we're not filling a proto_tree, return now */
571 return bytes_in_header;
575 th_byte = tvb_get_guint8(tvb, offset);
577 /* Create the bitfield tree */
578 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, offset, 1, th_byte);
579 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
582 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, offset, 1, th_byte);
583 proto_tree_add_uint(bf_tree, hf_sna_th_tg_sweep, tvb, offset, 1, th_byte);
584 proto_tree_add_uint(bf_tree, hf_sna_th_er_vr_supp_ind, tvb, offset, 1, th_byte);
585 proto_tree_add_uint(bf_tree, hf_sna_th_vr_pac_cnt_ind, tvb, offset, 1, th_byte);
586 proto_tree_add_uint(bf_tree, hf_sna_th_ntwk_prty, tvb, offset, 1, th_byte);
589 th_byte = tvb_get_guint8(tvb, offset);
591 /* Create the bitfield tree */
592 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 1");
593 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
596 proto_tree_add_uint(bf_tree, hf_sna_th_tgsf, tvb, offset, 1, th_byte);
597 proto_tree_add_boolean(bf_tree, hf_sna_th_mft, tvb, offset, 1, th_byte);
598 proto_tree_add_uint(bf_tree, hf_sna_th_piubf, tvb, offset, 1, th_byte);
600 mft = th_byte & 0x04;
602 th_byte = tvb_get_guint8(tvb, offset);
604 /* Create the bitfield tree */
605 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 2");
606 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
610 proto_tree_add_uint(bf_tree, hf_sna_th_nlpoi, tvb, offset, 1, th_byte);
611 proto_tree_add_uint(bf_tree, hf_sna_th_nlp_cp, tvb, offset, 1, th_byte);
614 proto_tree_add_uint(bf_tree, hf_sna_th_iern, tvb, offset, 1, th_byte);
616 proto_tree_add_uint(bf_tree, hf_sna_th_ern, tvb, offset, 1, th_byte);
619 th_byte = tvb_get_guint8(tvb, offset);
621 /* Create the bitfield tree */
622 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 3");
623 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
626 proto_tree_add_uint(bf_tree, hf_sna_th_vrn, tvb, offset, 1, th_byte);
627 proto_tree_add_uint(bf_tree, hf_sna_th_tpf, tvb, offset, 1, th_byte);
630 th_word = tvb_get_ntohs(tvb, offset);
632 /* Create the bitfield tree */
633 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Bytes 4-5");
634 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
637 proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwi, tvb, offset, 2, th_word);
638 proto_tree_add_boolean(bf_tree, hf_sna_th_tg_nonfifo_ind, tvb, offset, 2, th_word);
639 proto_tree_add_uint(bf_tree, hf_sna_th_vr_sqti, tvb, offset, 2, th_word);
641 /* I'm not sure about byte-order on this one... */
642 proto_tree_add_uint(bf_tree, hf_sna_th_tg_snf, tvb, offset, 2, th_word);
645 th_word = tvb_get_ntohs(tvb, offset);
647 /* Create the bitfield tree */
648 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Bytes 6-7");
649 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
652 proto_tree_add_boolean(bf_tree, hf_sna_th_vrprq, tvb, offset, 2, th_word);
653 proto_tree_add_boolean(bf_tree, hf_sna_th_vrprs, tvb, offset, 2, th_word);
654 proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwri, tvb, offset, 2, th_word);
655 proto_tree_add_boolean(bf_tree, hf_sna_th_vr_rwi, tvb, offset, 2, th_word);
657 /* I'm not sure about byte-order on this one... */
658 proto_tree_add_uint(bf_tree, hf_sna_th_vr_snf_send, tvb, offset, 2, th_word);
663 dsaf = tvb_get_ntohl(tvb, 8);
666 proto_tree_add_uint(tree, hf_sna_th_dsaf, tvb, offset, 4, dsaf);
671 osaf = tvb_get_ntohl(tvb, 12);
674 proto_tree_add_uint(tree, hf_sna_th_osaf, tvb, offset, 4, osaf);
677 th_byte = tvb_get_guint8(tvb, offset);
679 /* Create the bitfield tree */
680 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Byte 16");
681 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
684 proto_tree_add_boolean(tree, hf_sna_th_snai, tvb, offset, 1, th_byte);
686 /* We luck out here because in their infinite wisdom the SNA
687 * architects placed the MPF and EFI fields in the same bitfield
688 * locations, even though for FID4 they're not in byte 0.
690 proto_tree_add_uint(tree, hf_sna_th_mpf, tvb, offset, 1, th_byte);
691 proto_tree_add_uint(tree, hf_sna_th_efi, tvb, offset, 1, th_byte);
693 offset += 2; /* 1 for byte 16, 1 for byte 17 which is reserved */
697 def = tvb_get_ntohs(tvb, 18);
700 proto_tree_add_uint(tree, hf_sna_th_def, tvb, offset, 2, def);
703 /* Addresses in FID 4 are discontiguous, sigh */
706 SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8* )&dst);
707 SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&dst);
710 oef = tvb_get_ntohs(tvb, 20);
712 proto_tree_add_uint(tree, hf_sna_th_oef, tvb, offset+2, 2, oef);
715 /* Addresses in FID 4 are discontiguous, sigh */
718 SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&src);
719 SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&src);
722 proto_tree_add_item(tree, hf_sna_th_snf, tvb, offset+4, 2, FALSE);
723 proto_tree_add_item(tree, hf_sna_th_dcf, tvb, offset+6, 2, FALSE);
726 return bytes_in_header;
731 dissect_fid5(tvbuff_t *tvb, proto_tree *tree)
737 const int bytes_in_header = 12;
739 /* If we're not filling a proto_tree, return now */
741 return bytes_in_header;
744 th_0 = tvb_get_guint8(tvb, 0);
746 /* Create the bitfield tree */
747 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
748 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
750 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
751 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
752 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
754 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
755 proto_tree_add_item(tree, hf_sna_th_snf, tvb, 2, 2, FALSE);
757 proto_tree_add_item(tree, hf_sna_th_sa, tvb, 4, 8, FALSE);
759 return bytes_in_header;
765 dissect_fidf(tvbuff_t *tvb, proto_tree *tree)
771 const int bytes_in_header = 26;
773 /* If we're not filling a proto_tree, return now */
775 return bytes_in_header;
778 th_0 = tvb_get_guint8(tvb, 0);
780 /* Create the bitfield tree */
781 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
782 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
784 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
785 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
787 proto_tree_add_item(tree, hf_sna_th_cmd_fmt, tvb, 2, 1, FALSE);
788 proto_tree_add_item(tree, hf_sna_th_cmd_type, tvb, 3, 1, FALSE);
789 proto_tree_add_item(tree, hf_sna_th_cmd_sn, tvb, 4, 2, FALSE);
791 /* Yup, bytes 6-23 are reserved! */
792 proto_tree_add_text(tree, tvb, 6, 18, "Reserved");
794 proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 24, 2, FALSE);
796 return bytes_in_header;
802 dissect_rh(tvbuff_t *tvb, int offset, proto_tree *tree)
806 gboolean is_response;
807 guint8 rh_0, rh_1, rh_2;
810 /* Create the bitfield tree for byte 0*/
811 rh_0 = tvb_get_guint8(tvb, offset);
812 is_response = (rh_0 & 0x80);
814 bf_item = proto_tree_add_uint(tree, hf_sna_rh_0, tvb, offset, 1, rh_0);
815 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_0);
817 proto_tree_add_uint(bf_tree, hf_sna_rh_rri, tvb, offset, 1, rh_0);
818 proto_tree_add_uint(bf_tree, hf_sna_rh_ru_category, tvb, offset, 1, rh_0);
819 proto_tree_add_boolean(bf_tree, hf_sna_rh_fi, tvb, offset, 1, rh_0);
820 proto_tree_add_boolean(bf_tree, hf_sna_rh_sdi, tvb, offset, 1, rh_0);
821 proto_tree_add_boolean(bf_tree, hf_sna_rh_bci, tvb, offset, 1, rh_0);
822 proto_tree_add_boolean(bf_tree, hf_sna_rh_eci, tvb, offset, 1, rh_0);
825 rh_1 = tvb_get_guint8(tvb, offset);
827 /* Create the bitfield tree for byte 1*/
828 bf_item = proto_tree_add_uint(tree, hf_sna_rh_1, tvb, offset, 1, rh_1);
829 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_1);
831 proto_tree_add_boolean(bf_tree, hf_sna_rh_dr1, tvb, offset, 1, rh_1);
834 proto_tree_add_boolean(bf_tree, hf_sna_rh_lcci, tvb, offset, 1, rh_1);
837 proto_tree_add_boolean(bf_tree, hf_sna_rh_dr2, tvb, offset, 1, rh_1);
840 proto_tree_add_boolean(bf_tree, hf_sna_rh_rti, tvb, offset, 1, rh_1);
843 proto_tree_add_boolean(bf_tree, hf_sna_rh_eri, tvb, offset, 1, rh_1);
844 proto_tree_add_boolean(bf_tree, hf_sna_rh_rlwi, tvb, offset, 1, rh_1);
847 proto_tree_add_boolean(bf_tree, hf_sna_rh_qri, tvb, offset, 1, rh_1);
848 proto_tree_add_boolean(bf_tree, hf_sna_rh_pi, tvb, offset, 1, rh_1);
851 rh_2 = tvb_get_guint8(tvb, offset);
853 /* Create the bitfield tree for byte 2*/
854 bf_item = proto_tree_add_uint(tree, hf_sna_rh_2, tvb, offset, 1, rh_2);
857 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_2);
859 proto_tree_add_boolean(bf_tree, hf_sna_rh_bbi, tvb, offset, 1, rh_2);
860 proto_tree_add_boolean(bf_tree, hf_sna_rh_ebi, tvb, offset, 1, rh_2);
861 proto_tree_add_boolean(bf_tree, hf_sna_rh_cdi, tvb, offset, 1, rh_2);
862 proto_tree_add_uint(bf_tree, hf_sna_rh_csi, tvb, offset, 1, rh_2);
863 proto_tree_add_boolean(bf_tree, hf_sna_rh_edi, tvb, offset, 1, rh_2);
864 proto_tree_add_boolean(bf_tree, hf_sna_rh_pdi, tvb, offset, 1, rh_2);
865 proto_tree_add_boolean(bf_tree, hf_sna_rh_cebi, tvb, offset, 1, rh_2);
868 /* XXX - check for sdi. If TRUE, the next 4 bytes will be sense data */
872 proto_register_sna(void)
874 static hf_register_info hf[] = {
876 { "Transmission Header", "sna.th", FT_NONE, BASE_NONE, NULL, 0x0,
880 { "Transmission Header Byte 0", "sna.th.0", FT_UINT8, BASE_HEX, NULL, 0x0,
881 "Byte 0 of Tranmission Header contains FID, MPF, ODAI,"
882 " and EFI as bitfields.", HFILL }},
885 { "Format Identifer", "sna.th.fid", FT_UINT8, BASE_HEX, VALS(sna_th_fid_vals), 0xf0,
886 "Format Identification", HFILL }},
889 { "Mapping Field", "sna.th.mpf", FT_UINT8, BASE_DEC, VALS(sna_th_mpf_vals), 0x0c,
890 "The Mapping Field specifies whether the information field"
891 " associated with the TH is a complete or partial BIU.", HFILL }},
894 { "ODAI Assignment Indicator", "sna.th.odai", FT_UINT8, BASE_DEC, NULL, 0x02,
895 "The ODAI indicates which node assigned the OAF'-DAF' values"
896 " carried in the TH.", HFILL }},
899 { "Expedited Flow Indicator", "sna.th.efi", FT_UINT8, BASE_DEC, VALS(sna_th_efi_vals), 0x01,
900 "The EFI designates whether the PIU belongs to the normal"
901 " or expedited flow.", HFILL }},
904 { "Destination Address Field", "sna.th.daf", FT_UINT16, BASE_HEX, NULL, 0x0,
908 { "Origin Address Field", "sna.th.oaf", FT_UINT16, BASE_HEX, NULL, 0x0,
912 { "Sequence Number Field", "sna.th.snf", FT_UINT16, BASE_DEC, NULL, 0x0,
913 "The Sequence Number Field contains a numerical identifier for"
914 " the associated BIU.", HFILL }},
917 { "Data Count Field", "sna.th.dcf", FT_UINT16, BASE_DEC, NULL, 0x0,
918 "A binary count of the number of bytes in the BIU or BIU segment associated "
919 "with the tranmission header. The count does not include any of the bytes "
920 "in the transmission header.", HFILL }},
923 { "Local Session Identification", "sna.th.lsid", FT_UINT8, BASE_HEX, NULL, 0x0,
926 { &hf_sna_th_tg_sweep,
927 { "Transmission Group Sweep", "sna.th.tg_sweep", FT_UINT8, BASE_DEC,
928 VALS(sna_th_tg_sweep_vals), 0x08,
931 { &hf_sna_th_er_vr_supp_ind,
932 { "ER and VR Support Indicator", "sna.th.er_vr_supp_ind", FT_UINT8, BASE_DEC,
933 VALS(sna_th_er_vr_supp_ind_vals), 0x04,
936 { &hf_sna_th_vr_pac_cnt_ind,
937 { "Virtual Route Pacing Count Indicator", "sna.th.vr_pac_cnt_ind",
938 FT_UINT8, BASE_DEC, VALS(sna_th_vr_pac_cnt_ind_vals), 0x02,
941 { &hf_sna_th_ntwk_prty,
942 { "Network Priority", "sna.th.ntwk_prty",
943 FT_UINT8, BASE_DEC, VALS(sna_th_ntwk_prty_vals), 0x01,
947 { "Transmission Group Segmenting Field", "sna.th.tgsf",
948 FT_UINT8, BASE_HEX, VALS(sna_th_tgsf_vals), 0xc0,
952 { "MPR FID4 Type", "sna.th.mft", FT_BOOLEAN, BASE_NONE, NULL, 0x04,
956 { "PIU Blocking Field", "sna.th.piubf", FT_UINT8, BASE_HEX,
957 VALS(sna_th_piubf_vals), 0x03,
958 "Specifies whether this frame contains a single PIU or multiple PIUs.", HFILL }},
961 { "Initial Explicit Route Number", "sna.th.iern", FT_UINT8, BASE_DEC, NULL, 0xf0,
965 { "NLP Offset Indicator", "sna.th.nlpoi", FT_UINT8, BASE_DEC,
966 VALS(sna_th_nlpoi_vals), 0x80,
970 { "NLP Count or Padding", "sna.th.nlp_cp", FT_UINT8, BASE_DEC, NULL, 0x70,
974 { "Explicit Route Number", "sna.th.ern", FT_UINT8, BASE_DEC, NULL, 0x0f,
975 "The ERN in a TH identifies an explicit route direction of flow.", HFILL }},
978 { "Virtual Route Number", "sna.th.vrn", FT_UINT8, BASE_DEC, NULL, 0xf0,
982 { "Transmission Priority Field", "sna.th.tpf", FT_UINT8, BASE_HEX,
983 VALS(sna_th_tpf_vals), 0x03,
987 { "Virtual Route Change Window Indicator", "sna.th.vr_cwi", FT_UINT16, BASE_DEC,
988 VALS(sna_th_vr_cwi_vals), 0x8000,
989 "Used to change the window size of the virtual route by 1.", HFILL }},
991 { &hf_sna_th_tg_nonfifo_ind,
992 { "Transmission Group Non-FIFO Indicator", "sna.th.tg_nonfifo_ind", FT_BOOLEAN, 16,
993 TFS(&sna_th_tg_nonfifo_ind_truth), 0x4000,
994 "Indicates whether or not FIFO discipline is to enforced in "
995 "transmitting PIUs through the tranmission groups to prevent the PIUs "
996 "getting out of sequence during transmission over the TGs.", HFILL }},
998 { &hf_sna_th_vr_sqti,
999 { "Virtual Route Sequence and Type Indicator", "sna.th.vr_sqti", FT_UINT16, BASE_HEX,
1000 VALS(sna_th_vr_sqti_vals), 0x3000,
1001 "Specifies the PIU type.", HFILL }},
1003 { &hf_sna_th_tg_snf,
1004 { "Transmission Group Sequence Number Field", "sna.th.tg_snf", FT_UINT16, BASE_DEC,
1009 { "Virtual Route Pacing Request", "sna.th.vrprq", FT_BOOLEAN, 16,
1010 TFS(&sna_th_vrprq_truth), 0x8000,
1014 { "Virtual Route Pacing Response", "sna.th.vrprs", FT_BOOLEAN, 16,
1015 TFS(&sna_th_vrprs_truth), 0x4000,
1018 { &hf_sna_th_vr_cwri,
1019 { "Virtual Route Change Window Reply Indicator", "sna.th.vr_cwri", FT_UINT16, BASE_DEC,
1020 VALS(sna_th_vr_cwri_vals), 0x2000,
1021 "Permits changing of the window size by 1 for PIUs received by the "
1022 "sender of this bit.", HFILL }},
1024 { &hf_sna_th_vr_rwi,
1025 { "Virtual Route Reset Window Indicator", "sna.th.vr_rwi", FT_BOOLEAN, 16,
1026 TFS(&sna_th_vr_rwi_truth), 0x1000,
1027 "Indicates severe congestion in a node on the virtual route.", HFILL }},
1029 { &hf_sna_th_vr_snf_send,
1030 { "Virtual Route Send Sequence Number Field", "sna.th.vr_snf_send", FT_UINT16, BASE_DEC,
1035 { "Destination Subarea Address Field", "sna.th.dsaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1039 { "Origin Subarea Address Field", "sna.th.osaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1043 { "SNA Indicator", "sna.th.snai", FT_BOOLEAN, 8, NULL, 0x10,
1044 "Used to identify whether the PIU originated or is destined for "
1045 "an SNA or non-SNA device.", HFILL }},
1048 { "Destination Element Field", "sna.th.def", FT_UINT16, BASE_HEX, NULL, 0x0,
1052 { "Origin Element Field", "sna.th.oef", FT_UINT16, BASE_HEX, NULL, 0x0,
1056 { "Session Address", "sna.th.sa", FT_BYTES, BASE_HEX, NULL, 0x0,
1059 { &hf_sna_th_cmd_fmt,
1060 { "Command Format", "sna.th.cmd_fmt", FT_UINT8, BASE_HEX, NULL, 0x0,
1063 { &hf_sna_th_cmd_type,
1064 { "Command Type", "sna.th.cmd_type", FT_UINT8, BASE_HEX, NULL, 0x0,
1067 { &hf_sna_th_cmd_sn,
1068 { "Command Sequence Number", "sna.th.cmd_sn", FT_UINT16, BASE_DEC, NULL, 0x0,
1073 { "Request/Response Header", "sna.rh", FT_NONE, BASE_NONE, NULL, 0x0,
1077 { "Request/Response Header Byte 0", "sna.rh.0", FT_UINT8, BASE_HEX, NULL, 0x0,
1081 { "Request/Response Header Byte 1", "sna.rh.1", FT_UINT8, BASE_HEX, NULL, 0x0,
1085 { "Request/Response Header Byte 2", "sna.rh.2", FT_UINT8, BASE_HEX, NULL, 0x0,
1089 { "Request/Response Indicator", "sna.rh.rri", FT_UINT8, BASE_DEC, VALS(sna_rh_rri_vals), 0x80,
1090 "Denotes whether this is a request or a response.", HFILL }},
1092 { &hf_sna_rh_ru_category,
1093 { "Request/Response Unit Category", "sna.rh.ru_category", FT_UINT8, BASE_HEX,
1094 VALS(sna_rh_ru_category_vals), 0x60,
1098 { "Format Indicator", "sna.rh.fi", FT_BOOLEAN, 8, TFS(&sna_rh_fi_truth), 0x08,
1102 { "Sense Data Included", "sna.rh.sdi", FT_BOOLEAN, 8, TFS(&sna_rh_sdi_truth), 0x04,
1103 "Indicates that a 4-byte sense data field is included in the associated RU.", HFILL }},
1106 { "Begin Chain Indicator", "sna.rh.bci", FT_BOOLEAN, 8, TFS(&sna_rh_bci_truth), 0x02,
1110 { "End Chain Indicator", "sna.rh.eci", FT_BOOLEAN, 8, TFS(&sna_rh_eci_truth), 0x01,
1114 { "Definite Response 1 Indicator", "sna.rh.dr1", FT_BOOLEAN, 8, NULL, 0x80,
1118 { "Length-Checked Compression Indicator", "sna.rh.lcci", FT_BOOLEAN, 8,
1119 TFS(&sna_rh_lcci_truth), 0x40,
1123 { "Definite Response 2 Indicator", "sna.rh.dr2", FT_BOOLEAN, 8, NULL, 0x20,
1127 { "Exception Response Indicator", "sna.rh.eri", FT_BOOLEAN, 8, NULL, 0x10,
1128 "Used in conjunction with DR1I and DR2I to indicate, in a request, "
1129 "the form of response requested.", HFILL }},
1132 { "Response Type Indicator", "sna.rh.rti", FT_BOOLEAN, 8, TFS(&sna_rh_rti_truth), 0x10,
1136 { "Request Larger Window Indicator", "sna.rh.rlwi", FT_BOOLEAN, 8, NULL, 0x04,
1137 "Indicates whether a larger pacing window was requested.", HFILL }},
1140 { "Queued Response Indicator", "sna.rh.qri", FT_BOOLEAN, 8, TFS(&sna_rh_qri_truth), 0x02,
1144 { "Pacing Indicator", "sna.rh.pi", FT_BOOLEAN, 8, NULL, 0x01,
1148 { "Begin Bracket Indicator", "sna.rh.bbi", FT_BOOLEAN, 8, NULL, 0x80,
1152 { "End Bracket Indicator", "sna.rh.ebi", FT_BOOLEAN, 8, NULL, 0x40,
1156 { "Change Direction Indicator", "sna.rh.cdi", FT_BOOLEAN, 8, NULL, 0x20,
1160 { "Code Selection Indicator", "sna.rh.csi", FT_UINT8, BASE_DEC, VALS(sna_rh_csi_vals), 0x08,
1161 "Specifies the encoding used for the associated FMD RU.", HFILL }},
1164 { "Enciphered Data Indicator", "sna.rh.edi", FT_BOOLEAN, 8, NULL, 0x04,
1165 "Indicates that information in the associated RU is enciphered under "
1166 "session-level cryptography protocols.", HFILL }},
1169 { "Padded Data Indicator", "sna.rh.pdi", FT_BOOLEAN, 8, NULL, 0x02,
1170 "Indicates that the RU was padded at the end, before encipherment, to the next "
1171 "integral multiple of 8 bytes.", HFILL }},
1174 { "Conditional End Bracket Indicator", "sna.rh.cebi", FT_BOOLEAN, 8, NULL, 0x01,
1175 "Used to indicate the beginning or end of a group of exchanged "
1176 "requests and responses called a bracket. Only used on LU-LU sessions.", HFILL }},
1179 { "Request/Response Unit", "sna.ru", FT_NONE, BASE_NONE, NULL, 0x0,
1182 static gint *ett[] = {
1192 proto_sna = proto_register_protocol("Systems Network Architecture",
1194 proto_register_field_array(proto_sna, hf, array_length(hf));
1195 proto_register_subtree_array(ett, array_length(ett));
1196 register_dissector("sna", dissect_sna, proto_sna);
1200 proto_reg_handoff_sna(void)
1202 dissector_handle_t sna_handle;
1204 sna_handle = find_dissector("sna");
1205 dissector_add("llc.dsap", SAP_SNA_PATHCTRL, sna_handle);
1206 data_handle = find_dissector("data");