3 * Gilbert Ramirez <gram@xiexie.org>
5 * $Id: packet-sna.c,v 1.29 2001/06/02 22:18:17 gram Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@zing.org>
9 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #ifdef HAVE_SYS_TYPES_H
32 # include <sys/types.h>
38 #include "sna-utils.h"
41 * http://www.wanresources.com/snacell.html
45 static int proto_sna = -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_rh = -1;
90 static int hf_sna_rh_0 = -1;
91 static int hf_sna_rh_1 = -1;
92 static int hf_sna_rh_2 = -1;
93 static int hf_sna_rh_rri = -1;
94 static int hf_sna_rh_ru_category = -1;
95 static int hf_sna_rh_fi = -1;
96 static int hf_sna_rh_sdi = -1;
97 static int hf_sna_rh_bci = -1;
98 static int hf_sna_rh_eci = -1;
99 static int hf_sna_rh_dr1 = -1;
100 static int hf_sna_rh_lcci = -1;
101 static int hf_sna_rh_dr2 = -1;
102 static int hf_sna_rh_eri = -1;
103 static int hf_sna_rh_rti = -1;
104 static int hf_sna_rh_rlwi = -1;
105 static int hf_sna_rh_qri = -1;
106 static int hf_sna_rh_pi = -1;
107 static int hf_sna_rh_bbi = -1;
108 static int hf_sna_rh_ebi = -1;
109 static int hf_sna_rh_cdi = -1;
110 static int hf_sna_rh_csi = -1;
111 static int hf_sna_rh_edi = -1;
112 static int hf_sna_rh_pdi = -1;
113 static int hf_sna_rh_cebi = -1;
114 /*static int hf_sna_ru = -1;*/
116 static gint ett_sna = -1;
117 static gint ett_sna_th = -1;
118 static gint ett_sna_th_fid = -1;
119 static gint ett_sna_rh = -1;
120 static gint ett_sna_rh_0 = -1;
121 static gint ett_sna_rh_1 = -1;
122 static gint ett_sna_rh_2 = -1;
124 /* Format Identifier */
125 static const value_string sna_th_fid_vals[] = {
126 { 0x0, "SNA device <--> Non-SNA Device" },
127 { 0x1, "Subarea Nodes, without ER or VR" },
128 { 0x2, "Subarea Node <--> PU2" },
129 { 0x3, "Subarea Node or SNA host <--> Subarea Node" },
130 { 0x4, "Subarea Nodes, supporting ER and VR" },
131 { 0x5, "HPR RTP endpoint nodes" },
132 { 0xf, "Adjaced Subarea Nodes, supporting ER and VR" },
137 static const value_string sna_th_mpf_vals[] = {
138 { 0, "Middle segment of a BIU" },
139 { 1, "Last segment of a BIU" },
140 { 2, "First segment of a BIU" },
145 /* Expedited Flow Indicator */
146 static const value_string sna_th_efi_vals[] = {
147 { 0, "Normal Flow" },
148 { 1, "Expedited Flow" },
152 /* Request/Response Indicator */
153 static const value_string sna_rh_rri_vals[] = {
159 /* Request/Response Unit Category */
160 static const value_string sna_rh_ru_category_vals[] = {
161 { 0, "Function Management Data (FMD)" },
162 { 1, "Network Control (NC)" },
163 { 2, "Data Flow Control (DFC)" },
164 { 3, "Session Control (SC)" },
168 /* Format Indicator */
169 static const true_false_string sna_rh_fi_truth =
170 { "FM Header", "No FM Header" };
172 /* Sense Data Included */
173 static const true_false_string sna_rh_sdi_truth =
174 { "Included", "Not Included" };
176 /* Begin Chain Indicator */
177 static const true_false_string sna_rh_bci_truth =
178 { "First in Chain", "Not First in Chain" };
180 /* End Chain Indicator */
181 static const true_false_string sna_rh_eci_truth =
182 { "Last in Chain", "Not Last in Chain" };
184 /* Lengith-Checked Compression Indicator */
185 static const true_false_string sna_rh_lcci_truth =
186 { "Compressed", "Not Compressed" };
188 /* Response Type Indicator */
189 static const true_false_string sna_rh_rti_truth =
190 { "Negative", "Positive" };
192 /* Exception Response Indicator */
193 static const true_false_string sna_rh_eri_truth =
194 { "Exception", "Definite" };
196 /* Queued Response Indicator */
197 static const true_false_string sna_rh_qri_truth =
198 { "Enqueue response in TC queues", "Response bypasses TC queues" };
200 /* Code Selection Indicator */
201 static const value_string sna_rh_csi_vals[] = {
208 static const value_string sna_th_tg_sweep_vals[] = {
209 { 0, "This PIU may overtake any PU ahead of it." },
210 { 1, "This PIU does not ovetake any PIU ahead of it." },
215 static const value_string sna_th_er_vr_supp_ind_vals[] = {
216 { 0, "Each node supports ER and VR protocols" },
217 { 1, "Includes at least one node that does not support ER and VR protocols" },
222 static const value_string sna_th_vr_pac_cnt_ind_vals[] = {
223 { 0, "Pacing count on the VR has not reached 0" },
224 { 1, "Pacing count on the VR has reached 0" },
229 static const value_string sna_th_ntwk_prty_vals[] = {
230 { 0, "PIU flows at a lower priority" },
231 { 1, "PIU flows at network priority (highest transmission priority)" },
236 static const value_string sna_th_tgsf_vals[] = {
237 { 0, "Not segmented" },
238 { 1, "Last segment" },
239 { 2, "First segment" },
240 { 3, "Middle segment" },
245 static const value_string sna_th_piubf_vals[] = {
246 { 0, "Single PIU frame" },
247 { 1, "Last PIU of a multiple PIU frame" },
248 { 2, "First PIU of a multiple PIU frame" },
249 { 3, "Middle PIU of a multiple PIU frame" },
254 static const value_string sna_th_nlpoi_vals[] = {
255 { 0, "NLP starts within this FID4 TH" },
256 { 1, "NLP byte 0 starts after RH byte 0 following NLP C/P pad" },
261 static const value_string sna_th_tpf_vals[] = {
262 { 0, "Low Priority" },
263 { 1, "Medium Priority" },
264 { 2, "High Priority" },
269 static const value_string sna_th_vr_cwi_vals[] = {
270 { 0, "Increment window size" },
271 { 1, "Decrement window size" },
276 static const true_false_string sna_th_tg_nonfifo_ind_truth =
277 { "TG FIFO is not required", "TG FIFO is required" };
280 static const value_string sna_th_vr_sqti_vals[] = {
281 { 0, "Non-sequenced, Non-supervisory" },
282 { 1, "Non-sequenced, Supervisory" },
283 { 2, "Singly-sequenced" },
288 static const true_false_string sna_th_vrprq_truth = {
289 "VR pacing request is sent asking for a VR pacing response",
290 "No VR pacing response is requested",
294 static const true_false_string sna_th_vrprs_truth = {
295 "VR pacing response is sent in response to a VRPRQ bit set",
296 "No pacing response sent",
300 static const value_string sna_th_vr_cwri_vals[] = {
301 { 0, "Increment window size by 1" },
302 { 1, "Decrement window size by 1" },
307 static const true_false_string sna_th_vr_rwi_truth = {
308 "Reset window size to the minimum specified in NC_ACTVR",
309 "Do not reset window size",
312 static int dissect_fid0_1 (tvbuff_t*, packet_info*, proto_tree*);
313 static int dissect_fid2 (tvbuff_t*, packet_info*, proto_tree*);
314 static int dissect_fid3 (tvbuff_t*, proto_tree*);
315 static int dissect_fid4 (tvbuff_t*, proto_tree*);
316 static int dissect_fid5 (tvbuff_t*, proto_tree*);
317 static int dissect_fidf (tvbuff_t*, proto_tree*);
318 static void dissect_rh (tvbuff_t*, int, proto_tree*);
321 dissect_sna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
324 proto_tree *sna_tree = NULL, *th_tree = NULL, *rh_tree = NULL;
325 proto_item *sna_ti = NULL, *th_ti = NULL, *rh_ti = NULL;
327 int sna_header_len = 0, th_header_len = 0;
330 if (check_col(pinfo->fd, COL_PROTOCOL))
331 col_set_str(pinfo->fd, COL_PROTOCOL, "SNA");
332 if (check_col(pinfo->fd, COL_INFO))
333 col_clear(pinfo->fd, COL_INFO);
335 /* SNA data should be printed in EBCDIC, not ASCII */
336 pinfo->fd->flags.encoding = CHAR_EBCDIC;
338 /* Transmission Header Format Identifier */
339 th_fid = hi_nibble(tvb_get_guint8(tvb, 0));
341 /* Summary information */
342 if (check_col(pinfo->fd, COL_INFO))
343 col_add_str(pinfo->fd, COL_INFO,
344 val_to_str(th_fid, sna_th_fid_vals, "Unknown FID: %01x"));
348 /* Don't bother setting length. We'll set it later after we find
349 * the lengths of TH/RH/RU */
350 sna_ti = proto_tree_add_item(tree, proto_sna, tvb, 0, 0, FALSE);
351 sna_tree = proto_item_add_subtree(sna_ti, ett_sna);
354 /* Don't bother setting length. We'll set it later after we find
355 * the length of TH */
356 th_ti = proto_tree_add_item(sna_tree, hf_sna_th, tvb, 0, 0, FALSE);
357 th_tree = proto_item_add_subtree(th_ti, ett_sna_th);
364 th_header_len = dissect_fid0_1(tvb, pinfo, th_tree);
367 th_header_len = dissect_fid2(tvb, pinfo, th_tree);
370 th_header_len = dissect_fid3(tvb, th_tree);
373 th_header_len = dissect_fid4(tvb, th_tree);
376 th_header_len = dissect_fid5(tvb, th_tree);
379 th_header_len = dissect_fidf(tvb, th_tree);
382 dissect_data(tvb, 1, pinfo, tree);
385 sna_header_len += th_header_len;
386 offset = th_header_len;
389 proto_item_set_len(th_ti, th_header_len);
392 rh_ti = proto_tree_add_item(sna_tree, hf_sna_rh, tvb, offset, 3, FALSE);
393 rh_tree = proto_item_add_subtree(rh_ti, ett_sna_rh);
394 dissect_rh(tvb, offset, rh_tree);
398 proto_item_set_len(sna_ti, sna_header_len);
405 if (tvb_offset_exists(tvb, offset+1)) {
406 dissect_data(tvb, offset, pinfo, tree);
410 #define SNA_FID01_ADDR_LEN 2
412 /* FID Types 0 and 1 */
414 dissect_fid0_1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
421 const int bytes_in_header = 10;
425 th_0 = tvb_get_guint8(tvb, 0);
426 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
427 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
429 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
430 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
431 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
434 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
437 proto_tree_add_item(tree, hf_sna_th_daf, tvb, 2, 2, FALSE);
441 ptr = tvb_get_ptr(tvb, 2, SNA_FID01_ADDR_LEN);
442 SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
443 SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
446 proto_tree_add_item(tree, hf_sna_th_oaf, tvb, 4, 2, FALSE);
450 ptr = tvb_get_ptr(tvb, 4, SNA_FID01_ADDR_LEN);
451 SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
452 SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
454 /* If we're not filling a proto_tree, return now */
456 return bytes_in_header;
459 proto_tree_add_item(tree, hf_sna_th_snf, tvb, 6, 2, FALSE);
460 proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 8, 2, FALSE);
462 return bytes_in_header;
465 #define SNA_FID2_ADDR_LEN 1
469 dissect_fid2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
473 guint8 th_0=0, daf=0, oaf=0;
476 const int bytes_in_header = 6;
479 th_0 = tvb_get_guint8(tvb, 0);
480 daf = tvb_get_guint8(tvb, 2);
481 oaf = tvb_get_guint8(tvb, 3);
484 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
485 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
487 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
488 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
489 proto_tree_add_uint(bf_tree, hf_sna_th_odai,tvb, 0, 1, th_0);
490 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
493 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
496 proto_tree_add_uint_format(tree, hf_sna_th_daf, tvb, 2, 1, daf,
497 "Destination Address Field: 0x%02x", daf);
501 ptr = tvb_get_ptr(tvb, 2, SNA_FID2_ADDR_LEN);
502 SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
503 SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
507 proto_tree_add_uint_format(tree, hf_sna_th_oaf, tvb, 3, 1, oaf,
508 "Origin Address Field: 0x%02x", oaf);
512 ptr = tvb_get_ptr(tvb, 3, SNA_FID2_ADDR_LEN);
513 SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
514 SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
517 proto_tree_add_item(tree, hf_sna_th_snf, tvb, 4, 2, FALSE);
520 return bytes_in_header;
525 dissect_fid3(tvbuff_t *tvb, proto_tree *tree)
531 const int bytes_in_header = 2;
533 /* If we're not filling a proto_tree, return now */
535 return bytes_in_header;
538 th_0 = tvb_get_guint8(tvb, 0);
540 /* Create the bitfield tree */
541 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
542 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
544 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
545 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
546 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
548 proto_tree_add_item(tree, hf_sna_th_lsid, tvb, 1, 1, FALSE);
550 return bytes_in_header;
555 dissect_fid4(tvbuff_t *tvb, proto_tree *tree)
564 static struct sna_fid_type_4_addr src, dst;
566 const int bytes_in_header = 26;
568 /* If we're not filling a proto_tree, return now */
570 return bytes_in_header;
574 th_byte = tvb_get_guint8(tvb, offset);
576 /* Create the bitfield tree */
577 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, offset, 1, th_byte);
578 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
581 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, offset, 1, th_byte);
582 proto_tree_add_uint(bf_tree, hf_sna_th_tg_sweep, tvb, offset, 1, th_byte);
583 proto_tree_add_uint(bf_tree, hf_sna_th_er_vr_supp_ind, tvb, offset, 1, th_byte);
584 proto_tree_add_uint(bf_tree, hf_sna_th_vr_pac_cnt_ind, tvb, offset, 1, th_byte);
585 proto_tree_add_uint(bf_tree, hf_sna_th_ntwk_prty, tvb, offset, 1, th_byte);
588 th_byte = tvb_get_guint8(tvb, offset);
590 /* Create the bitfield tree */
591 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 1");
592 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
595 proto_tree_add_uint(bf_tree, hf_sna_th_tgsf, tvb, offset, 1, th_byte);
596 proto_tree_add_boolean(bf_tree, hf_sna_th_mft, tvb, offset, 1, th_byte);
597 proto_tree_add_uint(bf_tree, hf_sna_th_piubf, tvb, offset, 1, th_byte);
599 mft = th_byte & 0x04;
601 th_byte = tvb_get_guint8(tvb, offset);
603 /* Create the bitfield tree */
604 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 2");
605 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
609 proto_tree_add_uint(bf_tree, hf_sna_th_nlpoi, tvb, offset, 1, th_byte);
610 proto_tree_add_uint(bf_tree, hf_sna_th_nlp_cp, tvb, offset, 1, th_byte);
613 proto_tree_add_uint(bf_tree, hf_sna_th_iern, tvb, offset, 1, th_byte);
615 proto_tree_add_uint(bf_tree, hf_sna_th_ern, tvb, offset, 1, th_byte);
618 th_byte = tvb_get_guint8(tvb, offset);
620 /* Create the bitfield tree */
621 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 3");
622 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
625 proto_tree_add_uint(bf_tree, hf_sna_th_vrn, tvb, offset, 1, th_byte);
626 proto_tree_add_uint(bf_tree, hf_sna_th_tpf, tvb, offset, 1, th_byte);
629 th_word = tvb_get_ntohs(tvb, offset);
631 /* Create the bitfield tree */
632 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Bytes 4-5");
633 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
636 proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwi, tvb, offset, 2, th_word);
637 proto_tree_add_boolean(bf_tree, hf_sna_th_tg_nonfifo_ind, tvb, offset, 2, th_word);
638 proto_tree_add_uint(bf_tree, hf_sna_th_vr_sqti, tvb, offset, 2, th_word);
640 /* I'm not sure about byte-order on this one... */
641 proto_tree_add_uint(bf_tree, hf_sna_th_tg_snf, tvb, offset, 2, th_word);
644 th_word = tvb_get_ntohs(tvb, offset);
646 /* Create the bitfield tree */
647 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Bytes 6-7");
648 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
651 proto_tree_add_boolean(bf_tree, hf_sna_th_vrprq, tvb, offset, 2, th_word);
652 proto_tree_add_boolean(bf_tree, hf_sna_th_vrprs, tvb, offset, 2, th_word);
653 proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwri, tvb, offset, 2, th_word);
654 proto_tree_add_boolean(bf_tree, hf_sna_th_vr_rwi, tvb, offset, 2, th_word);
656 /* I'm not sure about byte-order on this one... */
657 proto_tree_add_uint(bf_tree, hf_sna_th_vr_snf_send, tvb, offset, 2, th_word);
662 dsaf = tvb_get_ntohl(tvb, 8);
665 proto_tree_add_uint(tree, hf_sna_th_dsaf, tvb, offset, 4, dsaf);
670 osaf = tvb_get_ntohl(tvb, 12);
673 proto_tree_add_uint(tree, hf_sna_th_osaf, tvb, offset, 4, osaf);
676 th_byte = tvb_get_guint8(tvb, offset);
678 /* Create the bitfield tree */
679 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Byte 16");
680 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
683 proto_tree_add_boolean(tree, hf_sna_th_snai, tvb, offset, 1, th_byte);
685 /* We luck out here because in their infinite wisdom the SNA
686 * architects placed the MPF and EFI fields in the same bitfield
687 * locations, even though for FID4 they're not in byte 0.
689 proto_tree_add_uint(tree, hf_sna_th_mpf, tvb, offset, 1, th_byte);
690 proto_tree_add_uint(tree, hf_sna_th_efi, tvb, offset, 1, th_byte);
692 offset += 2; /* 1 for byte 16, 1 for byte 17 which is reserved */
696 def = tvb_get_ntohs(tvb, 18);
699 proto_tree_add_uint(tree, hf_sna_th_def, tvb, offset, 2, def);
702 /* Addresses in FID 4 are discontiguous, sigh */
705 SET_ADDRESS(&pi.net_dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8* )&dst);
706 SET_ADDRESS(&pi.dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&dst);
709 oef = tvb_get_ntohs(tvb, 20);
711 proto_tree_add_uint(tree, hf_sna_th_oef, tvb, offset+2, 2, oef);
714 /* Addresses in FID 4 are discontiguous, sigh */
717 SET_ADDRESS(&pi.net_src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&src);
718 SET_ADDRESS(&pi.src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&src);
721 proto_tree_add_item(tree, hf_sna_th_snf, tvb, offset+4, 2, FALSE);
722 proto_tree_add_item(tree, hf_sna_th_dcf, tvb, offset+6, 2, FALSE);
725 return bytes_in_header;
730 dissect_fid5(tvbuff_t *tvb, proto_tree *tree)
736 const int bytes_in_header = 12;
738 /* If we're not filling a proto_tree, return now */
740 return bytes_in_header;
743 th_0 = tvb_get_guint8(tvb, 0);
745 /* Create the bitfield tree */
746 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
747 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
749 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
750 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
751 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
753 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
754 proto_tree_add_item(tree, hf_sna_th_snf, tvb, 2, 2, FALSE);
756 proto_tree_add_item(tree, hf_sna_th_sa, tvb, 4, 8, FALSE);
758 return bytes_in_header;
764 dissect_fidf(tvbuff_t *tvb, proto_tree *tree)
770 const int bytes_in_header = 26;
772 /* If we're not filling a proto_tree, return now */
774 return bytes_in_header;
777 th_0 = tvb_get_guint8(tvb, 0);
779 /* Create the bitfield tree */
780 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
781 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
783 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
784 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
786 proto_tree_add_item(tree, hf_sna_th_cmd_fmt, tvb, 2, 1, FALSE);
787 proto_tree_add_item(tree, hf_sna_th_cmd_type, tvb, 3, 1, FALSE);
788 proto_tree_add_item(tree, hf_sna_th_cmd_sn, tvb, 4, 2, FALSE);
790 /* Yup, bytes 6-23 are reserved! */
791 proto_tree_add_text(tree, tvb, 6, 18, "Reserved");
793 proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 24, 2, FALSE);
795 return bytes_in_header;
801 dissect_rh(tvbuff_t *tvb, int offset, proto_tree *tree)
805 gboolean is_response;
806 guint8 rh_0, rh_1, rh_2;
809 /* Create the bitfield tree for byte 0*/
810 rh_0 = tvb_get_guint8(tvb, offset);
811 is_response = (rh_0 & 0x80);
813 bf_item = proto_tree_add_uint(tree, hf_sna_rh_0, tvb, offset, 1, rh_0);
814 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_0);
816 proto_tree_add_uint(bf_tree, hf_sna_rh_rri, tvb, offset, 1, rh_0);
817 proto_tree_add_uint(bf_tree, hf_sna_rh_ru_category, tvb, offset, 1, rh_0);
818 proto_tree_add_boolean(bf_tree, hf_sna_rh_fi, tvb, offset, 1, rh_0);
819 proto_tree_add_boolean(bf_tree, hf_sna_rh_sdi, tvb, offset, 1, rh_0);
820 proto_tree_add_boolean(bf_tree, hf_sna_rh_bci, tvb, offset, 1, rh_0);
821 proto_tree_add_boolean(bf_tree, hf_sna_rh_eci, tvb, offset, 1, rh_0);
824 rh_1 = tvb_get_guint8(tvb, offset);
826 /* Create the bitfield tree for byte 1*/
827 bf_item = proto_tree_add_uint(tree, hf_sna_rh_1, tvb, offset, 1, rh_1);
828 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_1);
830 proto_tree_add_boolean(bf_tree, hf_sna_rh_dr1, tvb, offset, 1, rh_1);
833 proto_tree_add_boolean(bf_tree, hf_sna_rh_lcci, tvb, offset, 1, rh_1);
836 proto_tree_add_boolean(bf_tree, hf_sna_rh_dr2, tvb, offset, 1, rh_1);
839 proto_tree_add_boolean(bf_tree, hf_sna_rh_rti, tvb, offset, 1, rh_1);
842 proto_tree_add_boolean(bf_tree, hf_sna_rh_eri, tvb, offset, 1, rh_1);
843 proto_tree_add_boolean(bf_tree, hf_sna_rh_rlwi, tvb, offset, 1, rh_1);
846 proto_tree_add_boolean(bf_tree, hf_sna_rh_qri, tvb, offset, 1, rh_1);
847 proto_tree_add_boolean(bf_tree, hf_sna_rh_pi, tvb, offset, 1, rh_1);
850 rh_2 = tvb_get_guint8(tvb, offset);
852 /* Create the bitfield tree for byte 2*/
853 bf_item = proto_tree_add_uint(tree, hf_sna_rh_2, tvb, offset, 1, rh_2);
856 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_2);
858 proto_tree_add_boolean(bf_tree, hf_sna_rh_bbi, tvb, offset, 1, rh_2);
859 proto_tree_add_boolean(bf_tree, hf_sna_rh_ebi, tvb, offset, 1, rh_2);
860 proto_tree_add_boolean(bf_tree, hf_sna_rh_cdi, tvb, offset, 1, rh_2);
861 proto_tree_add_uint(bf_tree, hf_sna_rh_csi, tvb, offset, 1, rh_2);
862 proto_tree_add_boolean(bf_tree, hf_sna_rh_edi, tvb, offset, 1, rh_2);
863 proto_tree_add_boolean(bf_tree, hf_sna_rh_pdi, tvb, offset, 1, rh_2);
864 proto_tree_add_boolean(bf_tree, hf_sna_rh_cebi, tvb, offset, 1, rh_2);
867 /* XXX - check for sdi. If TRUE, the next 4 bytes will be sense data */
871 proto_register_sna(void)
873 static hf_register_info hf[] = {
875 { "Transmission Header", "sna.th", FT_NONE, BASE_NONE, NULL, 0x0,
879 { "Transmission Header Byte 0", "sna.th.0", FT_UINT8, BASE_HEX, NULL, 0x0,
880 "Byte 0 of Tranmission Header contains FID, MPF, ODAI,"
881 " and EFI as bitfields." }},
884 { "Format Identifer", "sna.th.fid", FT_UINT8, BASE_HEX, VALS(sna_th_fid_vals), 0xf0,
885 "Format Identification" }},
888 { "Mapping Field", "sna.th.mpf", FT_UINT8, BASE_DEC, VALS(sna_th_mpf_vals), 0x0c,
889 "The Mapping Field specifies whether the information field"
890 " associated with the TH is a complete or partial BIU." }},
893 { "ODAI Assignment Indicator", "sna.th.odai", FT_UINT8, BASE_DEC, NULL, 0x02,
894 "The ODAI indicates which node assigned the OAF'-DAF' values"
895 " carried in the TH." }},
898 { "Expedited Flow Indicator", "sna.th.efi", FT_UINT8, BASE_DEC, VALS(sna_th_efi_vals), 0x01,
899 "The EFI designates whether the PIU belongs to the normal"
900 " or expedited flow." }},
903 { "Destination Address Field", "sna.th.daf", FT_UINT16, BASE_HEX, NULL, 0x0,
907 { "Origin Address Field", "sna.th.oaf", FT_UINT16, BASE_HEX, NULL, 0x0,
911 { "Sequence Number Field", "sna.th.snf", FT_UINT16, BASE_DEC, NULL, 0x0,
912 "The Sequence Number Field contains a numerical identifier for"
913 " the associated BIU."}},
916 { "Data Count Field", "sna.th.dcf", FT_UINT16, BASE_DEC, NULL, 0x0,
917 "A binary count of the number of bytes in the BIU or BIU segment associated "
918 "with the tranmission header. The count does not include any of the bytes "
919 "in the transmission header."}},
922 { "Local Session Identification", "sna.th.lsid", FT_UINT8, BASE_HEX, NULL, 0x0,
925 { &hf_sna_th_tg_sweep,
926 { "Transmission Group Sweep", "sna.th.tg_sweep", FT_UINT8, BASE_DEC,
927 VALS(sna_th_tg_sweep_vals), 0x08,
930 { &hf_sna_th_er_vr_supp_ind,
931 { "ER and VR Support Indicator", "sna.th.er_vr_supp_ind", FT_UINT8, BASE_DEC,
932 VALS(sna_th_er_vr_supp_ind_vals), 0x04,
935 { &hf_sna_th_vr_pac_cnt_ind,
936 { "Virtual Route Pacing Count Indicator", "sna.th.vr_pac_cnt_ind",
937 FT_UINT8, BASE_DEC, VALS(sna_th_vr_pac_cnt_ind_vals), 0x02,
940 { &hf_sna_th_ntwk_prty,
941 { "Network Priority", "sna.th.ntwk_prty",
942 FT_UINT8, BASE_DEC, VALS(sna_th_ntwk_prty_vals), 0x01,
946 { "Transmission Group Segmenting Field", "sna.th.tgsf",
947 FT_UINT8, BASE_HEX, VALS(sna_th_tgsf_vals), 0xc0,
951 { "MPR FID4 Type", "sna.th.mft", FT_BOOLEAN, BASE_NONE, NULL, 0x04,
955 { "PIU Blocking Field", "sna.th.piubf", FT_UINT8, BASE_HEX,
956 VALS(sna_th_piubf_vals), 0x03,
957 "Specifies whether this frame contains a single PIU or multiple PIUs." }},
960 { "Initial Explicit Route Number", "sna.th.iern", FT_UINT8, BASE_DEC, NULL, 0xf0,
964 { "NLP Offset Indicator", "sna.th.nlpoi", FT_UINT8, BASE_DEC,
965 VALS(sna_th_nlpoi_vals), 0x80,
969 { "NLP Count or Padding", "sna.th.nlp_cp", FT_UINT8, BASE_DEC, NULL, 0x70,
973 { "Explicit Route Number", "sna.th.ern", FT_UINT8, BASE_DEC, NULL, 0x0f,
974 "The ERN in a TH identifies an explicit route direction of flow." }},
977 { "Virtual Route Number", "sna.th.vrn", FT_UINT8, BASE_DEC, NULL, 0xf0,
981 { "Transmission Priority Field", "sna.th.tpf", FT_UINT8, BASE_HEX,
982 VALS(sna_th_tpf_vals), 0x03,
986 { "Virtual Route Change Window Indicator", "sna.th.vr_cwi", FT_UINT16, BASE_DEC,
987 VALS(sna_th_vr_cwi_vals), 0x8000,
988 "Used to change the window size of the virtual route by 1." }},
990 { &hf_sna_th_tg_nonfifo_ind,
991 { "Transmission Group Non-FIFO Indicator", "sna.th.tg_nonfifo_ind", FT_BOOLEAN, 16,
992 TFS(&sna_th_tg_nonfifo_ind_truth), 0x4000,
993 "Indicates whether or not FIFO discipline is to enforced in "
994 "transmitting PIUs through the tranmission groups to prevent the PIUs "
995 "getting out of sequence during transmission over the TGs." }},
997 { &hf_sna_th_vr_sqti,
998 { "Virtual Route Sequence and Type Indicator", "sna.th.vr_sqti", FT_UINT16, BASE_HEX,
999 VALS(sna_th_vr_sqti_vals), 0x3000,
1000 "Specifies the PIU type." }},
1002 { &hf_sna_th_tg_snf,
1003 { "Transmission Group Sequence Number Field", "sna.th.tg_snf", FT_UINT16, BASE_DEC,
1008 { "Virtual Route Pacing Request", "sna.th.vrprq", FT_BOOLEAN, 16,
1009 TFS(&sna_th_vrprq_truth), 0x8000,
1013 { "Virtual Route Pacing Response", "sna.th.vrprs", FT_BOOLEAN, 16,
1014 TFS(&sna_th_vrprs_truth), 0x4000,
1017 { &hf_sna_th_vr_cwri,
1018 { "Virtual Route Change Window Reply Indicator", "sna.th.vr_cwri", FT_UINT16, BASE_DEC,
1019 VALS(sna_th_vr_cwri_vals), 0x2000,
1020 "Permits changing of the window size by 1 for PIUs received by the "
1021 "sender of this bit." }},
1023 { &hf_sna_th_vr_rwi,
1024 { "Virtual Route Reset Window Indicator", "sna.th.vr_rwi", FT_BOOLEAN, 16,
1025 TFS(&sna_th_vr_rwi_truth), 0x1000,
1026 "Indicates severe congestion in a node on the virtual route." }},
1028 { &hf_sna_th_vr_snf_send,
1029 { "Virtual Route Send Sequence Number Field", "sna.th.vr_snf_send", FT_UINT16, BASE_DEC,
1034 { "Destination Subarea Address Field", "sna.th.dsaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1038 { "Origin Subarea Address Field", "sna.th.osaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1042 { "SNA Indicator", "sna.th.snai", FT_BOOLEAN, 8, NULL, 0x10,
1043 "Used to identify whether the PIU originated or is destined for "
1044 "an SNA or non-SNA device." }},
1047 { "Destination Element Field", "sna.th.def", FT_UINT16, BASE_HEX, NULL, 0x0,
1051 { "Origin Element Field", "sna.th.oef", FT_UINT16, BASE_HEX, NULL, 0x0,
1055 { "Session Address", "sna.th.sa", FT_BYTES, BASE_HEX, NULL, 0x0,
1058 { &hf_sna_th_cmd_fmt,
1059 { "Command Format", "sna.th.cmd_fmt", FT_UINT8, BASE_HEX, NULL, 0x0,
1062 { &hf_sna_th_cmd_type,
1063 { "Command Type", "sna.th.cmd_type", FT_UINT8, BASE_HEX, NULL, 0x0,
1066 { &hf_sna_th_cmd_sn,
1067 { "Command Sequence Number", "sna.th.cmd_sn", FT_UINT16, BASE_DEC, NULL, 0x0,
1072 { "Request/Response Header", "sna.rh", FT_NONE, BASE_NONE, NULL, 0x0,
1076 { "Request/Response Header Byte 0", "sna.rh.0", FT_UINT8, BASE_HEX, NULL, 0x0,
1080 { "Request/Response Header Byte 1", "sna.rh.1", FT_UINT8, BASE_HEX, NULL, 0x0,
1084 { "Request/Response Header Byte 2", "sna.rh.2", FT_UINT8, BASE_HEX, NULL, 0x0,
1088 { "Request/Response Indicator", "sna.rh.rri", FT_UINT8, BASE_DEC, VALS(sna_rh_rri_vals), 0x80,
1089 "Denotes whether this is a request or a response." }},
1091 { &hf_sna_rh_ru_category,
1092 { "Request/Response Unit Category", "sna.rh.ru_category", FT_UINT8, BASE_HEX,
1093 VALS(sna_rh_ru_category_vals), 0x60,
1097 { "Format Indicator", "sna.rh.fi", FT_BOOLEAN, 8, TFS(&sna_rh_fi_truth), 0x08,
1101 { "Sense Data Included", "sna.rh.sdi", FT_BOOLEAN, 8, TFS(&sna_rh_sdi_truth), 0x04,
1102 "Indicates that a 4-byte sense data field is included in the associated RU." }},
1105 { "Begin Chain Indicator", "sna.rh.bci", FT_BOOLEAN, 8, TFS(&sna_rh_bci_truth), 0x02,
1109 { "End Chain Indicator", "sna.rh.eci", FT_BOOLEAN, 8, TFS(&sna_rh_eci_truth), 0x01,
1113 { "Definite Response 1 Indicator", "sna.rh.dr1", FT_BOOLEAN, 8, NULL, 0x80,
1117 { "Length-Checked Compression Indicator", "sna.rh.lcci", FT_BOOLEAN, 8,
1118 TFS(&sna_rh_lcci_truth), 0x40,
1122 { "Definite Response 2 Indicator", "sna.rh.dr2", FT_BOOLEAN, 8, NULL, 0x20,
1126 { "Exception Response Indicator", "sna.rh.eri", FT_BOOLEAN, 8, NULL, 0x10,
1127 "Used in conjunction with DR1I and DR2I to indicate, in a request, "
1128 "the form of response requested." }},
1131 { "Response Type Indicator", "sna.rh.rti", FT_BOOLEAN, 8, TFS(&sna_rh_rti_truth), 0x10,
1135 { "Request Larger Window Indicator", "sna.rh.rlwi", FT_BOOLEAN, 8, NULL, 0x04,
1136 "Indicates whether a larger pacing window was requested." }},
1139 { "Queued Response Indicator", "sna.rh.qri", FT_BOOLEAN, 8, TFS(&sna_rh_qri_truth), 0x02,
1143 { "Pacing Indicator", "sna.rh.pi", FT_BOOLEAN, 8, NULL, 0x01,
1147 { "Begin Bracket Indicator", "sna.rh.bbi", FT_BOOLEAN, 8, NULL, 0x80,
1151 { "End Bracket Indicator", "sna.rh.ebi", FT_BOOLEAN, 8, NULL, 0x40,
1155 { "Change Direction Indicator", "sna.rh.cdi", FT_BOOLEAN, 8, NULL, 0x20,
1159 { "Code Selection Indicator", "sna.rh.csi", FT_UINT8, BASE_DEC, VALS(sna_rh_csi_vals), 0x08,
1160 "Specifies the encoding used for the associated FMD RU." }},
1163 { "Enciphered Data Indicator", "sna.rh.edi", FT_BOOLEAN, 8, NULL, 0x04,
1164 "Indicates that information in the associated RU is enciphered under "
1165 "session-level cryptography protocols." }},
1168 { "Padded Data Indicator", "sna.rh.pdi", FT_BOOLEAN, 8, NULL, 0x02,
1169 "Indicates that the RU was padded at the end, before encipherment, to the next "
1170 "integral multiple of 8 bytes." }},
1173 { "Conditional End Bracket Indicator", "sna.rh.cebi", FT_BOOLEAN, 8, NULL, 0x01,
1174 "Used to indicate the beginning or end of a group of exchanged "
1175 "requests and responses called a bracket. Only used on LU-LU sessions." }},
1178 { "Request/Response Unit", "sna.ru", FT_NONE, BASE_NONE, NULL, 0x0,
1181 static gint *ett[] = {
1191 proto_sna = proto_register_protocol("Systems Network Architecture",
1193 proto_register_field_array(proto_sna, hf, array_length(hf));
1194 proto_register_subtree_array(ett, array_length(ett));
1198 proto_reg_handoff_sna(void)
1200 dissector_add("llc.dsap", SAP_SNA_PATHCTRL, dissect_sna,