3 * Gilbert Ramirez <gram@xiexie.org>
5 * $Id: packet-sna.c,v 1.22 2001/01/03 21:52:40 guy 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 "packet-sna.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 { 0x00, "Function Management Data (FMD)" },
162 { 0x01, "Network Control (NC)" },
163 { 0x10, "Data Flow Control (DFC)" },
164 { 0x11, "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 { 0x00, "Not segmented" },
238 { 0x01, "Last segment" },
239 { 0x10, "First segment" },
240 { 0x11, "Middle segment" },
245 static const value_string sna_th_piubf_vals[] = {
246 { 0x00, "Single PIU frame" },
247 { 0x01, "Last PIU of a multiple PIU frame" },
248 { 0x10, "First PIU of a multiple PIU frame" },
249 { 0x11, "Middle PIU of a multiple PIU frame" },
254 static const value_string sna_th_nlpoi_vals[] = {
255 { 0x0, "NLP starts within this FID4 TH" },
256 { 0x1, "NLP byte 0 starts after RH byte 0 following NLP C/P pad" },
261 static const value_string sna_th_tpf_vals[] = {
262 { 0x00, "Low Priority" },
263 { 0x01, "Medium Priority" },
264 { 0x10, "High Priority" },
269 static const value_string sna_th_vr_cwi_vals[] = {
270 { 0x0, "Increment window size" },
271 { 0x1, "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 { 0x00, "Non-sequenced, Non-supervisory" },
282 { 0x01, "Non-sequenced, Supervisory" },
283 { 0x10, "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 (const u_char*, int, frame_data*, proto_tree*);
313 static int dissect_fid2 (const u_char*, int, frame_data*, proto_tree*);
314 static int dissect_fid3 (const u_char*, int, frame_data*, proto_tree*);
315 static int dissect_fid4 (const u_char*, int, frame_data*, proto_tree*);
316 static int dissect_fid5 (const u_char*, int, frame_data*, proto_tree*);
317 static int dissect_fidf (const u_char*, int, frame_data*, proto_tree*);
318 static void dissect_rh (const u_char*, int, frame_data*, proto_tree*);
321 dissect_sna(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
323 proto_tree *sna_tree = NULL, *th_tree = NULL, *rh_tree = NULL;
324 proto_item *sna_ti = NULL, *th_ti = NULL, *rh_ti = NULL;
326 int sna_header_len = 0, th_header_len = 0;
328 OLD_CHECK_DISPLAY_AS_DATA(proto_sna, pd, offset, fd, tree);
330 /* SNA data should be printed in EBCDIC, not ASCII */
331 fd->flags.encoding = CHAR_EBCDIC;
333 if (IS_DATA_IN_FRAME(offset)) {
334 /* Transmission Header Format Identifier */
335 th_fid = hi_nibble(pd[offset]);
338 /* If our first byte isn't here, stop dissecting */
342 /* Summary information */
343 if (check_col(fd, COL_PROTOCOL))
344 col_set_str(fd, COL_PROTOCOL, "SNA");
345 if (check_col(fd, COL_INFO))
346 col_add_str(fd, COL_INFO, val_to_str(th_fid, sna_th_fid_vals, "Unknown FID: %01x"));
350 /* Don't bother setting length. We'll set it later after we find
351 * the lengths of TH/RH/RU */
352 sna_ti = proto_tree_add_item(tree, proto_sna, NullTVB, offset, 0, FALSE);
353 sna_tree = proto_item_add_subtree(sna_ti, ett_sna);
356 /* Don't bother setting length. We'll set it later after we find
357 * the length of TH */
358 th_ti = proto_tree_add_item(sna_tree, hf_sna_th, NullTVB, offset, 0, FALSE);
359 th_tree = proto_item_add_subtree(th_ti, ett_sna_th);
366 th_header_len = dissect_fid0_1(pd, offset, fd, th_tree);
369 th_header_len = dissect_fid2(pd, offset, fd, th_tree);
372 th_header_len = dissect_fid3(pd, offset, fd, th_tree);
375 th_header_len = dissect_fid4(pd, offset, fd, th_tree);
378 th_header_len = dissect_fid5(pd, offset, fd, th_tree);
381 th_header_len = dissect_fidf(pd, offset, fd, th_tree);
384 old_dissect_data(pd, offset+1, fd, tree);
387 sna_header_len += th_header_len;
388 offset += th_header_len;
391 proto_item_set_len(th_ti, th_header_len);
394 if (BYTES_ARE_IN_FRAME(offset, 3)) {
395 rh_ti = proto_tree_add_item(sna_tree, hf_sna_rh, NullTVB, offset, 3, FALSE);
396 rh_tree = proto_item_add_subtree(rh_ti, ett_sna_rh);
397 dissect_rh(pd, offset, fd, rh_tree);
402 /* If our first byte isn't here, stop dissecting */
406 proto_item_set_len(sna_ti, sna_header_len);
409 if (BYTES_ARE_IN_FRAME(offset, 3)) {
416 if (IS_DATA_IN_FRAME(offset+1)) {
417 old_dissect_data(pd, offset, fd, tree);
421 /* FID Types 0 and 1 */
423 dissect_fid0_1 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
428 guint16 daf, oaf, snf, dcf;
430 static int bytes_in_header = 10;
432 if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
437 daf = pntohs(&pd[offset+2]);
438 oaf = pntohs(&pd[offset+4]);
439 snf = pntohs(&pd[offset+6]);
440 dcf = pntohs(&pd[offset+8]);
442 SET_ADDRESS(&pi.net_src, AT_SNA, 2, &pd[offset+4]);
443 SET_ADDRESS(&pi.src, AT_SNA, 2, &pd[offset+4]);
444 SET_ADDRESS(&pi.net_dst, AT_SNA, 2, &pd[offset+2]);
445 SET_ADDRESS(&pi.dst, AT_SNA, 2, &pd[offset+2]);
448 return bytes_in_header;
451 /* Create the bitfield tree */
452 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, NullTVB, offset, 1, th_0);
453 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
455 proto_tree_add_uint(bf_tree, hf_sna_th_fid, NullTVB, offset, 1, th_0);
456 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, NullTVB, offset, 1, th_0);
457 proto_tree_add_uint(bf_tree, hf_sna_th_efi , NullTVB,offset, 1, th_0);
459 proto_tree_add_text(tree, NullTVB, offset+1, 1, "Reserved");
460 proto_tree_add_uint(tree, hf_sna_th_daf , NullTVB,offset+2, 1, daf);
461 proto_tree_add_uint(tree, hf_sna_th_oaf , NullTVB,offset+4, 1, oaf);
462 proto_tree_add_uint(tree, hf_sna_th_snf , NullTVB,offset+6, 2, snf);
463 proto_tree_add_uint(tree, hf_sna_th_dcf , NullTVB,offset+8, 2, dcf);
465 return bytes_in_header;
472 dissect_fid2 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
476 guint8 th_0, daf, oaf;
479 static int bytes_in_header = 6;
481 if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
489 /* Addresses in FID 2 are FT_UINT8 */
490 SET_ADDRESS(&pi.net_src, AT_SNA, 1, &pd[offset+3]);
491 SET_ADDRESS(&pi.src, AT_SNA, 1, &pd[offset+3]);
492 SET_ADDRESS(&pi.net_dst, AT_SNA, 1, &pd[offset+2]);
493 SET_ADDRESS(&pi.dst, AT_SNA, 1, &pd[offset+2]);
496 return bytes_in_header;
499 snf = pntohs(&pd[offset+4]);
501 /* Create the bitfield tree */
502 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, NullTVB, offset, 1, th_0);
503 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
505 proto_tree_add_uint(bf_tree, hf_sna_th_fid, NullTVB, offset, 1, th_0);
506 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, NullTVB, offset, 1, th_0);
507 proto_tree_add_uint(bf_tree, hf_sna_th_odai , NullTVB,offset, 1, th_0);
508 proto_tree_add_uint(bf_tree, hf_sna_th_efi , NullTVB,offset, 1, th_0);
510 /* Addresses in FID 2 are FT_UINT8 */
511 proto_tree_add_text(tree, NullTVB, offset+1, 1, "Reserved");
512 proto_tree_add_uint_format(tree, hf_sna_th_daf , NullTVB,offset+2, 1, daf,
513 "Destination Address Field: 0x%02x", daf);
514 proto_tree_add_uint_format(tree, hf_sna_th_oaf , NullTVB,offset+3, 1, oaf,
515 "Origin Address Field: 0x%02x", oaf);
516 proto_tree_add_uint(tree, hf_sna_th_snf , NullTVB,offset+4, 2, snf);
518 return bytes_in_header;
523 dissect_fid3 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
530 static int bytes_in_header = 2;
532 if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
537 return bytes_in_header;
543 /* Create the bitfield tree */
544 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, NullTVB, offset, 1, th_0);
545 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
547 proto_tree_add_uint(bf_tree, hf_sna_th_fid, NullTVB, offset, 1, th_0);
548 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, NullTVB, offset, 1, th_0);
549 proto_tree_add_uint(bf_tree, hf_sna_th_efi , NullTVB,offset, 1, th_0);
551 proto_tree_add_uint(tree, hf_sna_th_lsid , NullTVB,offset+1, 1, lsid);
553 return bytes_in_header;
559 sna_fid_type_4_addr_to_str(const struct sna_fid_type_4_addr *addrp)
561 static gchar str[3][14];
564 if (cur == &str[0][0]) {
566 } else if (cur == &str[1][0]) {
572 sprintf(cur, "%08X.%04X", addrp->saf, addrp->ef);
577 dissect_fid4 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
583 guint16 def, oef, snf, dcf;
585 static struct sna_fid_type_4_addr src, dst;
587 static int bytes_in_header = 26;
589 if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
593 dsaf = pntohl(&pd[offset+8]);
594 osaf = pntohl(&pd[offset+12]);
595 def = pntohs(&pd[offset+18]);
596 oef = pntohs(&pd[offset+20]);
597 snf = pntohs(&pd[offset+22]);
598 dcf = pntohs(&pd[offset+24]);
600 /* Addresses in FID 4 are discontiguous, sigh */
605 SET_ADDRESS(&pi.net_src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
607 SET_ADDRESS(&pi.src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
609 SET_ADDRESS(&pi.net_dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
611 SET_ADDRESS(&pi.dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
615 return bytes_in_header;
618 th_byte = pd[offset];
620 /* Create the bitfield tree */
621 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, NullTVB, offset, 1, th_byte);
622 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
625 proto_tree_add_uint(bf_tree, hf_sna_th_fid, NullTVB, offset, 1, th_byte);
626 proto_tree_add_uint(bf_tree, hf_sna_th_tg_sweep, NullTVB, offset, 1, th_byte);
627 proto_tree_add_uint(bf_tree, hf_sna_th_er_vr_supp_ind, NullTVB, offset, 1, th_byte);
628 proto_tree_add_uint(bf_tree, hf_sna_th_vr_pac_cnt_ind, NullTVB, offset, 1, th_byte);
629 proto_tree_add_uint(bf_tree, hf_sna_th_ntwk_prty, NullTVB, offset, 1, th_byte);
632 th_byte = pd[offset];
634 /* Create the bitfield tree */
635 bf_item = proto_tree_add_text(tree, NullTVB, offset, 1, "Transmision Header Byte 1");
636 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
639 proto_tree_add_uint(bf_tree, hf_sna_th_tgsf, NullTVB, offset, 1, th_byte);
640 proto_tree_add_boolean(bf_tree, hf_sna_th_mft, NullTVB, offset, 1, th_byte);
641 proto_tree_add_uint(bf_tree, hf_sna_th_piubf, NullTVB, offset, 1, th_byte);
643 mft = th_byte & 0x04;
645 th_byte = pd[offset];
647 /* Create the bitfield tree */
648 bf_item = proto_tree_add_text(tree, NullTVB, offset, 1, "Transmision Header Byte 2");
649 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
653 proto_tree_add_uint(bf_tree, hf_sna_th_nlpoi, NullTVB, offset, 1, th_byte);
654 proto_tree_add_uint(bf_tree, hf_sna_th_nlp_cp, NullTVB, offset, 1, th_byte);
657 proto_tree_add_uint(bf_tree, hf_sna_th_iern, NullTVB, offset, 1, th_byte);
659 proto_tree_add_uint(bf_tree, hf_sna_th_ern, NullTVB, offset, 1, th_byte);
662 th_byte = pd[offset];
664 /* Create the bitfield tree */
665 bf_item = proto_tree_add_text(tree, NullTVB, offset, 1, "Transmision Header Byte 3");
666 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
669 proto_tree_add_uint(bf_tree, hf_sna_th_vrn, NullTVB, offset, 1, th_byte);
670 proto_tree_add_uint(bf_tree, hf_sna_th_tpf, NullTVB, offset, 1, th_byte);
673 th_word = pntohs(&pd[offset]);
675 /* Create the bitfield tree */
676 bf_item = proto_tree_add_text(tree, NullTVB, offset, 2, "Transmision Header Bytes 4-5");
677 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
680 proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwi, NullTVB, offset, 2, th_word);
681 proto_tree_add_boolean(bf_tree, hf_sna_th_tg_nonfifo_ind, NullTVB, offset, 2, th_word);
682 proto_tree_add_uint(bf_tree, hf_sna_th_vr_sqti, NullTVB, offset, 2, th_word);
684 /* I'm not sure about byte-order on this one... */
685 proto_tree_add_uint(bf_tree, hf_sna_th_tg_snf, NullTVB, offset, 2, th_word);
688 th_word = pntohs(&pd[offset]);
690 /* Create the bitfield tree */
691 bf_item = proto_tree_add_text(tree, NullTVB, offset, 2, "Transmision Header Bytes 6-7");
692 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
695 proto_tree_add_boolean(bf_tree, hf_sna_th_vrprq, NullTVB, offset, 2, th_word);
696 proto_tree_add_boolean(bf_tree, hf_sna_th_vrprs, NullTVB, offset, 2, th_word);
697 proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwri, NullTVB, offset, 2, th_word);
698 proto_tree_add_boolean(bf_tree, hf_sna_th_vr_rwi, NullTVB, offset, 2, th_word);
700 /* I'm not sure about byte-order on this one... */
701 proto_tree_add_uint(bf_tree, hf_sna_th_vr_snf_send, NullTVB, offset, 2, th_word);
706 proto_tree_add_uint(tree, hf_sna_th_dsaf, NullTVB, offset, 4, dsaf);
711 proto_tree_add_uint(tree, hf_sna_th_osaf, NullTVB, offset, 4, osaf);
714 th_byte = pd[offset];
716 /* Create the bitfield tree */
717 bf_item = proto_tree_add_text(tree, NullTVB, offset, 2, "Transmision Header Byte 16");
718 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
721 proto_tree_add_boolean(tree, hf_sna_th_snai, NullTVB, offset, 1, th_byte);
723 /* We luck out here because in their infinite wisdom the SNA
724 * architects placed the MPF and EFI fields in the same bitfield
725 * locations, even though for FID4 they're not in byte 0.
727 proto_tree_add_uint(tree, hf_sna_th_mpf, NullTVB, offset, 1, th_byte);
728 proto_tree_add_uint(tree, hf_sna_th_efi, NullTVB, offset, 1, th_byte);
730 offset += 2; /* 1 for byte 16, 1 for byte 17 which is reserved */
733 proto_tree_add_uint(tree, hf_sna_th_def, NullTVB, offset+0, 2, def);
734 proto_tree_add_uint(tree, hf_sna_th_oef, NullTVB, offset+2, 2, oef);
735 proto_tree_add_uint(tree, hf_sna_th_snf, NullTVB, offset+4, 2, snf);
736 proto_tree_add_uint(tree, hf_sna_th_snf, NullTVB, offset+6, 2, dcf);
738 return bytes_in_header;
743 dissect_fid5 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
750 static int bytes_in_header = 12;
752 if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
757 snf = pntohs(&pd[offset+2]);
760 return bytes_in_header;
763 /* Create the bitfield tree */
764 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, NullTVB, offset, 1, th_0);
765 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
767 proto_tree_add_uint(bf_tree, hf_sna_th_fid, NullTVB, offset, 1, th_0);
768 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, NullTVB, offset, 1, th_0);
769 proto_tree_add_uint(bf_tree, hf_sna_th_efi, NullTVB, offset, 1, th_0);
771 proto_tree_add_text(tree, NullTVB, offset+1, 1, "Reserved");
772 proto_tree_add_uint(tree, hf_sna_th_snf, NullTVB, offset+2, 2, snf);
774 proto_tree_add_bytes(tree, hf_sna_th_sa, NullTVB, offset+4, 8, &pd[offset+4]);
776 return bytes_in_header;
782 dissect_fidf (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
786 guint8 th_0, cmd_fmt, cmd_type;
789 static int bytes_in_header = 26;
791 if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
796 cmd_fmt = pd[offset+2];
797 cmd_type = pd[offset+3];
798 cmd_sn = pntohs(&pd[offset+4]);
800 /* Yup, bytes 6-23 are reserved! */
801 dcf = pntohs(&pd[offset+24]);
804 return bytes_in_header;
807 /* Create the bitfield tree */
808 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, NullTVB, offset, 1, th_0);
809 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
811 proto_tree_add_uint(bf_tree, hf_sna_th_fid, NullTVB, offset, 1, th_0);
812 proto_tree_add_text(tree, NullTVB, offset+1, 1, "Reserved");
814 proto_tree_add_uint(tree, hf_sna_th_cmd_fmt, NullTVB, offset+2, 1, cmd_fmt);
815 proto_tree_add_uint(tree, hf_sna_th_cmd_type, NullTVB, offset+3, 1, cmd_type);
816 proto_tree_add_uint(tree, hf_sna_th_cmd_sn, NullTVB, offset+4, 2, cmd_sn);
818 proto_tree_add_text(tree, NullTVB, offset+6, 18, "Reserved");
820 proto_tree_add_uint(tree, hf_sna_th_dcf, NullTVB, offset+24, 8, dcf);
822 return bytes_in_header;
828 dissect_rh (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
832 gboolean is_response;
833 guint8 rh_0, rh_1, rh_2;
839 is_response = (rh_0 & 0x80);
841 /* Create the bitfield tree for byte 0*/
842 bf_item = proto_tree_add_uint(tree, hf_sna_rh_0, NullTVB, offset, 1, rh_0);
843 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_0);
845 proto_tree_add_uint(bf_tree, hf_sna_rh_rri, NullTVB, offset, 1, rh_0);
846 proto_tree_add_uint(bf_tree, hf_sna_rh_ru_category, NullTVB, offset, 1, rh_0);
847 proto_tree_add_boolean(bf_tree, hf_sna_rh_fi, NullTVB, offset, 1, rh_0);
848 proto_tree_add_boolean(bf_tree, hf_sna_rh_sdi, NullTVB, offset, 1, rh_0);
849 proto_tree_add_boolean(bf_tree, hf_sna_rh_bci, NullTVB, offset, 1, rh_0);
850 proto_tree_add_boolean(bf_tree, hf_sna_rh_eci, NullTVB, offset, 1, rh_0);
854 /* Create the bitfield tree for byte 1*/
855 bf_item = proto_tree_add_uint(tree, hf_sna_rh_1, NullTVB, offset, 1, rh_1);
856 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_1);
858 proto_tree_add_boolean(bf_tree, hf_sna_rh_dr1, NullTVB, offset, 1, rh_1);
861 proto_tree_add_boolean(bf_tree, hf_sna_rh_lcci, NullTVB, offset, 1, rh_1);
864 proto_tree_add_boolean(bf_tree, hf_sna_rh_dr2, NullTVB, offset, 1, rh_1);
867 proto_tree_add_boolean(bf_tree, hf_sna_rh_rti, NullTVB, offset, 1, rh_1);
870 proto_tree_add_boolean(bf_tree, hf_sna_rh_eri, NullTVB, offset, 1, rh_1);
871 proto_tree_add_boolean(bf_tree, hf_sna_rh_rlwi, NullTVB, offset, 1, rh_1);
874 proto_tree_add_boolean(bf_tree, hf_sna_rh_qri, NullTVB, offset, 1, rh_1);
875 proto_tree_add_boolean(bf_tree, hf_sna_rh_pi, NullTVB, offset, 1, rh_1);
879 /* Create the bitfield tree for byte 2*/
880 bf_item = proto_tree_add_uint(tree, hf_sna_rh_2, NullTVB, offset, 1, rh_2);
883 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_2);
885 proto_tree_add_boolean(bf_tree, hf_sna_rh_bbi, NullTVB, offset, 1, rh_2);
886 proto_tree_add_boolean(bf_tree, hf_sna_rh_ebi, NullTVB, offset, 1, rh_2);
887 proto_tree_add_boolean(bf_tree, hf_sna_rh_cdi, NullTVB, offset, 1, rh_2);
888 proto_tree_add_uint(bf_tree, hf_sna_rh_csi, NullTVB, offset, 1, rh_2);
889 proto_tree_add_boolean(bf_tree, hf_sna_rh_edi, NullTVB, offset, 1, rh_2);
890 proto_tree_add_boolean(bf_tree, hf_sna_rh_pdi, NullTVB, offset, 1, rh_2);
891 proto_tree_add_boolean(bf_tree, hf_sna_rh_cebi, NullTVB, offset, 1, rh_2);
894 /* XXX - check for sdi. If TRUE, the next 4 bytes will be sense data */
898 proto_register_sna(void)
900 static hf_register_info hf[] = {
902 { "Transmission Header", "sna.th", FT_NONE, BASE_NONE, NULL, 0x0,
906 { "Transmission Header Byte 0", "sna.th.0", FT_UINT8, BASE_HEX, NULL, 0x0,
907 "Byte 0 of Tranmission Header contains FID, MPF, ODAI,"
908 " and EFI as bitfields." }},
911 { "Format Identifer", "sna.th.fid", FT_UINT8, BASE_HEX, VALS(sna_th_fid_vals), 0xf0,
912 "Format Identification" }},
915 { "Mapping Field", "sna.th.mpf", FT_UINT8, BASE_NONE, VALS(sna_th_mpf_vals), 0x0c,
916 "The Mapping Field specifies whether the information field"
917 " associated with the TH is a complete or partial BIU." }},
920 { "ODAI Assignment Indicator", "sna.th.odai", FT_UINT8, BASE_DEC, NULL, 0x02,
921 "The ODAI indicates which node assigned the OAF'-DAF' values"
922 " carried in the TH." }},
925 { "Expedited Flow Indicator", "sna.th.efi", FT_UINT8, BASE_DEC, VALS(sna_th_efi_vals), 0x01,
926 "The EFI designates whether the PIU belongs to the normal"
927 " or expedited flow." }},
930 { "Destination Address Field", "sna.th.daf", FT_UINT16, BASE_HEX, NULL, 0x0,
934 { "Origin Address Field", "sna.th.oaf", FT_UINT16, BASE_HEX, NULL, 0x0,
938 { "Sequence Number Field", "sna.th.snf", FT_UINT16, BASE_NONE, NULL, 0x0,
939 "The Sequence Number Field contains a numerical identifier for"
940 " the associated BIU."}},
943 { "Data Count Field", "sna.th.dcf", FT_UINT16, BASE_DEC, NULL, 0x0,
944 "A binary count of the number of bytes in the BIU or BIU segment associated "
945 "with the tranmission header. The count does not include any of the bytes "
946 "in the transmission header."}},
949 { "Local Session Identification", "sna.th.lsid", FT_UINT8, BASE_HEX, NULL, 0x0,
952 { &hf_sna_th_tg_sweep,
953 { "Transmission Group Sweep", "sna.th.tg_sweep", FT_UINT8, BASE_DEC,
954 VALS(sna_th_tg_sweep_vals), 0x08,
957 { &hf_sna_th_er_vr_supp_ind,
958 { "ER and VR Support Indicator", "sna.th.er_vr_supp_ind", FT_UINT8, BASE_DEC,
959 VALS(sna_th_er_vr_supp_ind_vals), 0x04,
962 { &hf_sna_th_vr_pac_cnt_ind,
963 { "Virtual Route Pacing Count Indicator", "sna.th.vr_pac_cnt_ind",
964 FT_UINT8, BASE_DEC, VALS(sna_th_vr_pac_cnt_ind_vals), 0x02,
967 { &hf_sna_th_ntwk_prty,
968 { "Network Priority", "sna.th.ntwk_prty",
969 FT_UINT8, BASE_DEC, VALS(sna_th_ntwk_prty_vals), 0x01,
973 { "Transmission Group Segmenting Field", "sna.th.tgsf",
974 FT_UINT8, BASE_HEX, VALS(sna_th_tgsf_vals), 0xc0,
978 { "MPR FID4 Type", "sna.th.mft", FT_BOOLEAN, BASE_NONE, NULL, 0x04,
982 { "PIU Blocking Field", "sna.th.piubf", FT_UINT8, BASE_HEX,
983 VALS(sna_th_piubf_vals), 0x03,
984 "Specifies whether this frame contains a single PIU or multiple PIUs." }},
987 { "Initial Explicit Route Number", "sna.th.iern", FT_UINT8, BASE_DEC, NULL, 0xf0,
991 { "NLP Offset Indicator", "sna.th.nlpoi", FT_UINT8, BASE_DEC,
992 VALS(sna_th_nlpoi_vals), 0x80,
996 { "NLP Count or Padding", "sna.th.nlp_cp", FT_UINT8, BASE_DEC, NULL, 0x70,
1000 { "Explicit Route Number", "sna.th.ern", FT_UINT8, BASE_DEC, NULL, 0x0f,
1001 "The ERN in a TH identifies an explicit route direction of flow." }},
1004 { "Virtual Route Number", "sna.th.vrn", FT_UINT8, BASE_DEC, NULL, 0xf0,
1008 { "Transmission Priority Field", "sna.th.tpf", FT_UINT8, BASE_HEX,
1009 VALS(sna_th_tpf_vals), 0x03,
1012 { &hf_sna_th_vr_cwi,
1013 { "Virtual Route Change Window Indicator", "sna.th.vr_cwi", FT_UINT16, BASE_DEC,
1014 VALS(sna_th_vr_cwi_vals), 0x8000,
1015 "Used to change the window size of the virtual route by 1." }},
1017 { &hf_sna_th_tg_nonfifo_ind,
1018 { "Transmission Group Non-FIFO Indicator", "sna.th.tg_nonfifo_ind", FT_BOOLEAN, 16,
1019 TFS(&sna_th_tg_nonfifo_ind_truth), 0x4000,
1020 "Indicates whether or not FIFO discipline is to enforced in "
1021 "transmitting PIUs through the tranmission groups to prevent the PIUs "
1022 "getting out of sequence during transmission over the TGs." }},
1024 { &hf_sna_th_vr_sqti,
1025 { "Virtual Route Sequence and Type Indicator", "sna.th.vr_sqti", FT_UINT16, BASE_HEX,
1026 VALS(sna_th_vr_sqti_vals), 0x3000,
1027 "Specifies the PIU type." }},
1029 { &hf_sna_th_tg_snf,
1030 { "Transmission Group Sequence Number Field", "sna.th.tg_snf", FT_UINT16, BASE_DEC,
1035 { "Virtual Route Pacing Request", "sna.th.vrprq", FT_BOOLEAN, 16,
1036 TFS(&sna_th_vrprq_truth), 0x8000,
1040 { "Virtual Route Pacing Response", "sna.th.vrprs", FT_BOOLEAN, 16,
1041 TFS(&sna_th_vrprs_truth), 0x4000,
1044 { &hf_sna_th_vr_cwri,
1045 { "Virtual Route Change Window Reply Indicator", "sna.th.vr_cwri", FT_UINT16, BASE_DEC,
1046 VALS(sna_th_vr_cwri_vals), 0x2000,
1047 "Permits changing of the window size by 1 for PIUs received by the "
1048 "sender of this bit." }},
1050 { &hf_sna_th_vr_rwi,
1051 { "Virtual Route Reset Window Indicator", "sna.th.vr_rwi", FT_BOOLEAN, 16,
1052 TFS(&sna_th_vr_rwi_truth), 0x1000,
1053 "Indicates severe congestion in a node on the virtual route." }},
1055 { &hf_sna_th_vr_snf_send,
1056 { "Virtual Route Send Sequence Number Field", "sna.th.vr_snf_send", FT_UINT16, BASE_DEC,
1061 { "Destination Subarea Address Field", "sna.th.dsaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1065 { "Origin Subarea Address Field", "sna.th.osaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1069 { "SNA Indicator", "sna.th.snai", FT_BOOLEAN, 8, NULL, 0x10,
1070 "Used to identify whether the PIU originated or is destined for "
1071 "an SNA or non-SNA device." }},
1074 { "Destination Element Field", "sna.th.def", FT_UINT16, BASE_HEX, NULL, 0x0,
1078 { "Origin Element Field", "sna.th.oef", FT_UINT16, BASE_HEX, NULL, 0x0,
1082 { "Session Address", "sna.th.sa", FT_BYTES, BASE_HEX, NULL, 0x0,
1085 { &hf_sna_th_cmd_fmt,
1086 { "Command Format", "sna.th.cmd_fmt", FT_UINT8, BASE_HEX, NULL, 0x0,
1089 { &hf_sna_th_cmd_type,
1090 { "Command Type", "sna.th.cmd_type", FT_UINT8, BASE_HEX, NULL, 0x0,
1093 { &hf_sna_th_cmd_sn,
1094 { "Command Sequence Number", "sna.th.cmd_sn", FT_UINT16, BASE_DEC, NULL, 0x0,
1099 { "Request/Response Header", "sna.rh", FT_NONE, BASE_NONE, NULL, 0x0,
1103 { "Request/Response Header Byte 0", "sna.rh.0", FT_UINT8, BASE_HEX, NULL, 0x0,
1107 { "Request/Response Header Byte 1", "sna.rh.1", FT_UINT8, BASE_HEX, NULL, 0x0,
1111 { "Request/Response Header Byte 2", "sna.rh.2", FT_UINT8, BASE_HEX, NULL, 0x0,
1115 { "Request/Response Indicator", "sna.rh.rri", FT_UINT8, BASE_DEC, VALS(sna_rh_rri_vals), 0x80,
1116 "Denotes whether this is a request or a response." }},
1118 { &hf_sna_rh_ru_category,
1119 { "Request/Response Unit Category", "sna.rh.ru_category", FT_UINT8, BASE_HEX,
1120 VALS(sna_rh_ru_category_vals), 0x60,
1124 { "Format Indicator", "sna.rh.fi", FT_BOOLEAN, 8, TFS(&sna_rh_fi_truth), 0x08,
1128 { "Sense Data Included", "sna.rh.sdi", FT_BOOLEAN, 8, TFS(&sna_rh_sdi_truth), 0x04,
1129 "Indicates that a 4-byte sense data field is included in the associated RU." }},
1132 { "Begin Chain Indicator", "sna.rh.bci", FT_BOOLEAN, 8, TFS(&sna_rh_bci_truth), 0x02,
1136 { "End Chain Indicator", "sna.rh.eci", FT_BOOLEAN, 8, TFS(&sna_rh_eci_truth), 0x01,
1140 { "Definite Response 1 Indicator", "sna.rh.dr1", FT_BOOLEAN, 8, NULL, 0x80,
1144 { "Length-Checked Compression Indicator", "sna.rh.lcci", FT_BOOLEAN, 8,
1145 TFS(&sna_rh_lcci_truth), 0x40,
1149 { "Definite Response 2 Indicator", "sna.rh.dr2", FT_BOOLEAN, 8, NULL, 0x20,
1153 { "Exception Response Indicator", "sna.rh.eri", FT_BOOLEAN, 8, NULL, 0x10,
1154 "Used in conjunction with DR1I and DR2I to indicate, in a request, "
1155 "the form of response requested." }},
1158 { "Response Type Indicator", "sna.rh.rti", FT_BOOLEAN, 8, TFS(&sna_rh_rti_truth), 0x10,
1162 { "Request Larger Window Indicator", "sna.rh.rlwi", FT_BOOLEAN, 8, NULL, 0x04,
1163 "Indicates whether a larger pacing window was requested." }},
1166 { "Queued Response Indicator", "sna.rh.qri", FT_BOOLEAN, 8, TFS(&sna_rh_qri_truth), 0x02,
1170 { "Pacing Indicator", "sna.rh.pi", FT_BOOLEAN, 8, NULL, 0x01,
1174 { "Begin Bracket Indicator", "sna.rh.bbi", FT_BOOLEAN, 8, NULL, 0x80,
1178 { "End Bracket Indicator", "sna.rh.ebi", FT_BOOLEAN, 8, NULL, 0x40,
1182 { "Change Direction Indicator", "sna.rh.cdi", FT_BOOLEAN, 8, NULL, 0x20,
1186 { "Code Selection Indicator", "sna.rh.csi", FT_UINT8, BASE_DEC, VALS(sna_rh_csi_vals), 0x08,
1187 "Specifies the encoding used for the associated FMD RU." }},
1190 { "Enciphered Data Indicator", "sna.rh.edi", FT_BOOLEAN, 8, NULL, 0x04,
1191 "Indicates that information in the associated RU is enciphered under "
1192 "session-level cryptography protocols." }},
1195 { "Padded Data Indicator", "sna.rh.pdi", FT_BOOLEAN, 8, NULL, 0x02,
1196 "Indicates that the RU was padded at the end, before encipherment, to the next "
1197 "integral multiple of 8 bytes." }},
1200 { "Conditional End Bracket Indicator", "sna.rh.cebi", FT_BOOLEAN, 8, NULL, 0x01,
1201 "Used to indicate the beginning or end of a group of exchanged "
1202 "requests and responses called a bracket. Only used on LU-LU sessions." }},
1205 { "Request/Response Unit", "sna.ru", FT_NONE, BASE_NONE, NULL, 0x0,
1208 static gint *ett[] = {
1218 proto_sna = proto_register_protocol("Systems Network Architecture",
1220 proto_register_field_array(proto_sna, hf, array_length(hf));
1221 proto_register_subtree_array(ett, array_length(ett));
1225 proto_reg_handoff_sna(void)
1227 old_dissector_add("llc.dsap", SAP_SNA_PATHCTRL, dissect_sna);