3 * Gilbert Ramirez <gram@alumni.rice.edu>
5 * $Id: packet-sna.c,v 1.43 2002/09/23 21:58:22 gram 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.
31 #include <epan/packet.h>
34 #include <epan/sna-utils.h>
36 #include "reassemble.h"
39 * http://www.wanresources.com/snacell.html
40 * ftp://ftp.software.ibm.com/networking/pub/standards/aiw/formats/
44 static int proto_sna = -1;
45 static int 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_nlp_nhdr = -1;
89 static int hf_sna_nlp_nhdr_0 = -1;
90 static int hf_sna_nlp_sm = -1;
91 static int hf_sna_nlp_tpf = -1;
92 static int hf_sna_nlp_nhdr_1 = -1;
93 static int hf_sna_nlp_ft = -1;
94 static int hf_sna_nlp_tspi = -1;
95 static int hf_sna_nlp_slowdn1 = -1;
96 static int hf_sna_nlp_slowdn2 = -1;
97 static int hf_sna_nlp_fra = -1;
98 static int hf_sna_nlp_anr = -1;
99 static int hf_sna_nlp_frh = -1;
100 static int hf_sna_nlp_thdr = -1;
101 static int hf_sna_nlp_tcid = -1;
102 static int hf_sna_nlp_thdr_8 = -1;
103 static int hf_sna_nlp_setupi = -1;
104 static int hf_sna_nlp_somi = -1;
105 static int hf_sna_nlp_eomi = -1;
106 static int hf_sna_nlp_sri = -1;
107 static int hf_sna_nlp_rasapi = -1;
108 static int hf_sna_nlp_retryi = -1;
109 static int hf_sna_nlp_thdr_9 = -1;
110 static int hf_sna_nlp_lmi = -1;
111 static int hf_sna_nlp_cqfi = -1;
112 static int hf_sna_nlp_osi = -1;
113 static int hf_sna_nlp_offset = -1;
114 static int hf_sna_nlp_dlf = -1;
115 static int hf_sna_nlp_bsn = -1;
117 static int hf_sna_rh = -1;
118 static int hf_sna_rh_0 = -1;
119 static int hf_sna_rh_1 = -1;
120 static int hf_sna_rh_2 = -1;
121 static int hf_sna_rh_rri = -1;
122 static int hf_sna_rh_ru_category = -1;
123 static int hf_sna_rh_fi = -1;
124 static int hf_sna_rh_sdi = -1;
125 static int hf_sna_rh_bci = -1;
126 static int hf_sna_rh_eci = -1;
127 static int hf_sna_rh_dr1 = -1;
128 static int hf_sna_rh_lcci = -1;
129 static int hf_sna_rh_dr2 = -1;
130 static int hf_sna_rh_eri = -1;
131 static int hf_sna_rh_rti = -1;
132 static int hf_sna_rh_rlwi = -1;
133 static int hf_sna_rh_qri = -1;
134 static int hf_sna_rh_pi = -1;
135 static int hf_sna_rh_bbi = -1;
136 static int hf_sna_rh_ebi = -1;
137 static int hf_sna_rh_cdi = -1;
138 static int hf_sna_rh_csi = -1;
139 static int hf_sna_rh_edi = -1;
140 static int hf_sna_rh_pdi = -1;
141 static int hf_sna_rh_cebi = -1;
142 /*static int hf_sna_ru = -1;*/
144 static gint ett_sna = -1;
145 static gint ett_sna_th = -1;
146 static gint ett_sna_th_fid = -1;
147 static gint ett_sna_nlp_nhdr = -1;
148 static gint ett_sna_nlp_nhdr_0 = -1;
149 static gint ett_sna_nlp_nhdr_1 = -1;
150 static gint ett_sna_nlp_thdr = -1;
151 static gint ett_sna_nlp_thdr_8 = -1;
152 static gint ett_sna_nlp_thdr_9 = -1;
153 static gint ett_sna_rh = -1;
154 static gint ett_sna_rh_0 = -1;
155 static gint ett_sna_rh_1 = -1;
156 static gint ett_sna_rh_2 = -1;
158 static dissector_handle_t data_handle;
160 /* Defragment fragmented SNA BIUs*/
161 static gboolean sna_defragment = FALSE;
162 static GHashTable *sna_fragment_table = NULL;
163 static GHashTable *sna_reassembled_table = NULL;
165 /* Format Identifier */
166 static const value_string sna_th_fid_vals[] = {
167 { 0x0, "SNA device <--> Non-SNA Device" },
168 { 0x1, "Subarea Nodes, without ER or VR" },
169 { 0x2, "Subarea Node <--> PU2" },
170 { 0x3, "Subarea Node or SNA host <--> Subarea Node" },
171 { 0x4, "Subarea Nodes, supporting ER and VR" },
172 { 0x5, "HPR RTP endpoint nodes" },
173 { 0xa, "HPR NLP Frame Routing" },
174 { 0xb, "HPR NLP Frame Routing" },
175 { 0xc, "HPR NLP Automatic Network Routing" },
176 { 0xd, "HPR NLP Automatic Network Routing" },
177 { 0xf, "Adjaced Subarea Nodes, supporting ER and VR" },
182 #define MPF_MIDDLE_SEGMENT 0
183 #define MPF_LAST_SEGMENT 1
184 #define MPF_FIRST_SEGMENT 2
185 #define MPF_WHOLE_BIU 3
187 static const value_string sna_th_mpf_vals[] = {
188 { MPF_MIDDLE_SEGMENT, "Middle segment of a BIU" },
189 { MPF_LAST_SEGMENT, "Last segment of a BIU" },
190 { MPF_FIRST_SEGMENT, "First segment of a BIU" },
191 { MPF_WHOLE_BIU, "Whole BIU" },
195 /* Expedited Flow Indicator */
196 static const value_string sna_th_efi_vals[] = {
197 { 0, "Normal Flow" },
198 { 1, "Expedited Flow" },
202 /* Request/Response Indicator */
203 static const value_string sna_rh_rri_vals[] = {
209 /* Request/Response Unit Category */
210 static const value_string sna_rh_ru_category_vals[] = {
211 { 0, "Function Management Data (FMD)" },
212 { 1, "Network Control (NC)" },
213 { 2, "Data Flow Control (DFC)" },
214 { 3, "Session Control (SC)" },
218 /* Format Indicator */
219 static const true_false_string sna_rh_fi_truth =
220 { "FM Header", "No FM Header" };
222 /* Sense Data Included */
223 static const true_false_string sna_rh_sdi_truth =
224 { "Included", "Not Included" };
226 /* Begin Chain Indicator */
227 static const true_false_string sna_rh_bci_truth =
228 { "First in Chain", "Not First in Chain" };
230 /* End Chain Indicator */
231 static const true_false_string sna_rh_eci_truth =
232 { "Last in Chain", "Not Last in Chain" };
234 /* Lengith-Checked Compression Indicator */
235 static const true_false_string sna_rh_lcci_truth =
236 { "Compressed", "Not Compressed" };
238 /* Response Type Indicator */
239 static const true_false_string sna_rh_rti_truth =
240 { "Negative", "Positive" };
242 /* Exception Response Indicator */
243 static const true_false_string sna_rh_eri_truth =
244 { "Exception", "Definite" };
246 /* Queued Response Indicator */
247 static const true_false_string sna_rh_qri_truth =
248 { "Enqueue response in TC queues", "Response bypasses TC queues" };
250 /* Code Selection Indicator */
251 static const value_string sna_rh_csi_vals[] = {
258 static const value_string sna_th_tg_sweep_vals[] = {
259 { 0, "This PIU may overtake any PU ahead of it." },
260 { 1, "This PIU does not ovetake any PIU ahead of it." },
265 static const value_string sna_th_er_vr_supp_ind_vals[] = {
266 { 0, "Each node supports ER and VR protocols" },
267 { 1, "Includes at least one node that does not support ER and VR protocols" },
272 static const value_string sna_th_vr_pac_cnt_ind_vals[] = {
273 { 0, "Pacing count on the VR has not reached 0" },
274 { 1, "Pacing count on the VR has reached 0" },
279 static const value_string sna_th_ntwk_prty_vals[] = {
280 { 0, "PIU flows at a lower priority" },
281 { 1, "PIU flows at network priority (highest transmission priority)" },
286 static const value_string sna_th_tgsf_vals[] = {
287 { 0, "Not segmented" },
288 { 1, "Last segment" },
289 { 2, "First segment" },
290 { 3, "Middle segment" },
295 static const value_string sna_th_piubf_vals[] = {
296 { 0, "Single PIU frame" },
297 { 1, "Last PIU of a multiple PIU frame" },
298 { 2, "First PIU of a multiple PIU frame" },
299 { 3, "Middle PIU of a multiple PIU frame" },
304 static const value_string sna_th_nlpoi_vals[] = {
305 { 0, "NLP starts within this FID4 TH" },
306 { 1, "NLP byte 0 starts after RH byte 0 following NLP C/P pad" },
311 static const value_string sna_th_tpf_vals[] = {
312 { 0, "Low Priority" },
313 { 1, "Medium Priority" },
314 { 2, "High Priority" },
315 { 3, "Network Priority" },
320 static const value_string sna_th_vr_cwi_vals[] = {
321 { 0, "Increment window size" },
322 { 1, "Decrement window size" },
327 static const true_false_string sna_th_tg_nonfifo_ind_truth =
328 { "TG FIFO is not required", "TG FIFO is required" };
331 static const value_string sna_th_vr_sqti_vals[] = {
332 { 0, "Non-sequenced, Non-supervisory" },
333 { 1, "Non-sequenced, Supervisory" },
334 { 2, "Singly-sequenced" },
339 static const true_false_string sna_th_vrprq_truth = {
340 "VR pacing request is sent asking for a VR pacing response",
341 "No VR pacing response is requested",
345 static const true_false_string sna_th_vrprs_truth = {
346 "VR pacing response is sent in response to a VRPRQ bit set",
347 "No pacing response sent",
351 static const value_string sna_th_vr_cwri_vals[] = {
352 { 0, "Increment window size by 1" },
353 { 1, "Decrement window size by 1" },
358 static const true_false_string sna_th_vr_rwi_truth = {
359 "Reset window size to the minimum specified in NC_ACTVR",
360 "Do not reset window size",
364 static const value_string sna_nlp_sm_vals[] = {
365 { 5, "Function routing" },
366 { 6, "Automatic network routing" },
370 static const true_false_string sna_nlp_tspi_truth =
371 { "Time sensitive", "Not time sensitive" };
373 static const true_false_string sna_nlp_slowdn1_truth =
374 { "Minor congestion", "No minor congestion" };
376 static const true_false_string sna_nlp_slowdn2_truth =
377 { "Major congestion", "No major congestion" };
380 static const value_string sna_nlp_ft_vals[] = {
385 static const value_string sna_nlp_frh_vals[] = {
386 { 0x03, "XID complete request" },
387 { 0x04, "XID complete response" },
391 static const true_false_string sna_nlp_setupi_truth =
392 { "Connection setup segment present", "Connection setup segment not present" };
394 static const true_false_string sna_nlp_somi_truth =
395 { "Start of message", "Not start of message" };
397 static const true_false_string sna_nlp_eomi_truth =
398 { "End of message", "Not end of message" };
400 static const true_false_string sna_nlp_sri_truth =
401 { "Status requested", "No status requested" };
403 static const true_false_string sna_nlp_rasapi_truth =
404 { "Reply as soon as possible", "No need to reply as soon as possible" };
406 static const true_false_string sna_nlp_retryi_truth =
407 { "Undefined", "Sender will retransmit" };
409 static const true_false_string sna_nlp_lmi_truth =
410 { "Last message", "Not last message" };
412 static const true_false_string sna_nlp_cqfi_truth =
413 { "CQFI included", "CQFI not included" };
415 static const true_false_string sna_nlp_osi_truth =
416 { "Optional segments present", "No optional segments present" };
419 /* Values to direct the top-most dissector what to dissect
421 enum next_dissection_enum {
427 typedef enum next_dissection_enum next_dissection_t;
430 static int dissect_fid0_1 (tvbuff_t*, packet_info*, proto_tree*);
431 static int dissect_fid2 (tvbuff_t*, packet_info*, proto_tree*, tvbuff_t**,
433 static int dissect_fid3 (tvbuff_t*, proto_tree*);
434 static int dissect_fid4 (tvbuff_t*, packet_info*, proto_tree*);
435 static int dissect_fid5 (tvbuff_t*, proto_tree*);
436 static int dissect_fidf (tvbuff_t*, proto_tree*);
437 static void dissect_fid (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
438 static void dissect_nlp (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
439 static void dissect_rh (tvbuff_t*, int, proto_tree*);
442 mpf_value(guint8 th_byte)
444 return (th_byte & 0x0c) >> 2;
449 dissect_sna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
452 proto_tree *sna_tree = NULL;
453 proto_item *sna_ti = NULL;
455 if (check_col(pinfo->cinfo, COL_PROTOCOL))
456 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNA");
457 if (check_col(pinfo->cinfo, COL_INFO))
458 col_clear(pinfo->cinfo, COL_INFO);
460 /* SNA data should be printed in EBCDIC, not ASCII */
461 pinfo->fd->flags.encoding = CHAR_EBCDIC;
465 /* Don't bother setting length. We'll set it later after we find
466 * the lengths of TH/RH/RU */
467 sna_ti = proto_tree_add_item(tree, proto_sna, tvb, 0, -1, FALSE);
468 sna_tree = proto_item_add_subtree(sna_ti, ett_sna);
471 /* Transmission Header Format Identifier */
472 fid = hi_nibble(tvb_get_guint8(tvb, 0));
474 case 0xa: /* HPR Network Layer Packet */
478 dissect_nlp(tvb, pinfo, sna_tree, tree);
481 dissect_fid(tvb, pinfo, sna_tree, tree);
488 dissect_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
489 proto_tree *parent_tree)
492 proto_tree *th_tree = NULL, *rh_tree = NULL;
493 proto_item *th_ti = NULL, *rh_ti = NULL;
495 int th_header_len = 0;
496 int offset, rh_offset;
497 tvbuff_t *rh_tvb = NULL;
498 next_dissection_t continue_dissecting = everything;
500 /* Transmission Header Format Identifier */
501 th_fid = hi_nibble(tvb_get_guint8(tvb, 0));
503 /* Summary information */
504 if (check_col(pinfo->cinfo, COL_INFO))
505 col_add_str(pinfo->cinfo, COL_INFO,
506 val_to_str(th_fid, sna_th_fid_vals, "Unknown FID: %01x"));
511 /* Don't bother setting length. We'll set it later after we find
512 * the length of TH */
513 th_ti = proto_tree_add_item(tree, hf_sna_th, tvb, 0, -1, FALSE);
514 th_tree = proto_item_add_subtree(th_ti, ett_sna_th);
521 th_header_len = dissect_fid0_1(tvb, pinfo, th_tree);
524 th_header_len = dissect_fid2(tvb, pinfo, th_tree, &rh_tvb,
525 &continue_dissecting);
528 th_header_len = dissect_fid3(tvb, th_tree);
531 th_header_len = dissect_fid4(tvb, pinfo, th_tree);
534 th_header_len = dissect_fid5(tvb, th_tree);
537 th_header_len = dissect_fidf(tvb, th_tree);
540 call_dissector(data_handle,
541 tvb_new_subset(tvb, 1, -1, -1), pinfo, parent_tree);
545 offset = th_header_len;
547 /* Short-circuit ? */
548 if (continue_dissecting == stop_here) {
550 proto_tree_add_text(tree, tvb, offset, -1,
557 /* If the FID dissector function didn't create an rh_tvb, then we just
558 * use the rest of our tvbuff as the rh_tvb. */
560 rh_tvb = tvb_new_subset(tvb, offset, -1, -1);
564 /* Process the rest of the SNA packet, starting with RH */
567 proto_item_set_len(th_ti, th_header_len);
570 rh_ti = proto_tree_add_item(tree, hf_sna_rh, rh_tvb, rh_offset, RH_LEN, FALSE);
571 rh_tree = proto_item_add_subtree(rh_ti, ett_sna_rh);
572 dissect_rh(rh_tvb, rh_offset, rh_tree);
578 if (tvb_offset_exists(rh_tvb, rh_offset+1)) {
579 /* Short-circuit ? */
580 if (continue_dissecting == rh_only) {
582 proto_tree_add_text(tree, rh_tvb, rh_offset, -1,
588 call_dissector(data_handle, tvb_new_subset(rh_tvb, rh_offset, -1, -1),
593 #define FIRST_FRAG_NUMBER 0
594 #define MIDDLE_FRAG_NUMBER 1
595 #define LAST_FRAG_NUMBER 2
597 /* FID2 is defragged by sequence. The weird thing is that we have neither
598 * absolute sequence numbers, nor byte offets. Other FIDs have byte offsets
599 * (the DCF field), but not FID2. The only thing we have to go with is "FIRST",
600 * "MIDDLE", or "LAST". If the BIU is split into 3 frames, then everything is
601 * fine, * "FIRST", "MIDDLE", and "LAST" map nicely onto frag-number 0, 1,
602 * and 2. However, if the BIU is split into 2 frames, then we only have
603 * "FIRST" and "LAST", and the mapping *should* be frag-number 0 and 1,
606 * The SNA docs say "FID2 PIUs cannot be blocked because there is no DCF in the
607 * TH format for deblocking" (note on Figure 4-2 in the IBM SNA documention,
608 * see the FTP URL in the comment near the top of this file). I *think*
609 * this means that the fragmented frames cannot arrive out of order.
610 * Well, I *want* it to mean this, because w/o this limitation, if you
611 * get a "FIRST" frame and a "LAST" frame, how long should you wait to
612 * see if a "MIDDLE" frame every arrives????? Thus, if frames *have* to
613 * arrive in order, then we're saved.
615 * The problem then boils down to figuring out if "LAST" means frag-number 1
616 * (in the case of a BIU split into 2 frames) or frag-number 2
617 * (in the case of a BIU split into 3 frames).
619 * Assuming fragmented FID2 BIU frames *do* arrive in order, the obvious
620 * way to handle the mapping of "LAST" to either frag-number 1 or
621 * frag-number 2 is to keep a hash which tracks the frames seen, etc.
622 * This consumes resources. A trickier way, but a way which works, is to
623 * always map the "LAST" BIU segment to frag-number 2. Here's the trickery:
624 * if we add frag-number 2, which we know to be the "LAST" BIU segment,
625 * and the reassembly code tells us that the the BIU is still not reassmebled,
626 * then, owing to the, ahem, /fact/, that fragmented BIU segments arrive
627 * in order :), we know that 1) "FIRST" did come, and 2) there's no "MIDDLE",
628 * because this BIU was fragmented into 2 frames, not 3. So, we'll be
629 * tricky and add a zero-length "MIDDLE" BIU frame (i.e, frag-number 1)
630 * to complete the reassembly.
633 defragment_by_sequence(packet_info *pinfo, tvbuff_t *tvb, int offset, int mpf, int id)
635 fragment_data *fd_head;
636 int frag_number = -1;
637 int more_frags = TRUE;
638 tvbuff_t *rh_tvb = NULL;
640 /* Determine frag_number and more_frags */
645 case MPF_FIRST_SEGMENT:
646 frag_number = FIRST_FRAG_NUMBER;
648 case MPF_MIDDLE_SEGMENT:
649 frag_number = MIDDLE_FRAG_NUMBER;
651 case MPF_LAST_SEGMENT:
652 frag_number = LAST_FRAG_NUMBER;
656 g_assert_not_reached();
659 /* If sna_defragment is on, and this is a fragment.. */
660 if (frag_number > -1) {
662 /* XXX - check length ??? */
663 fd_head = fragment_add_seq(tvb, offset, pinfo, id,
666 tvb_length_remaining(tvb, offset),
669 /* We added the LAST segment and reassembly didn't complete. Insert
670 * a zero-length MIDDLE segment to turn a 2-frame BIU-fragmentation
671 * into a 3-frame BIU-fragmentation (empty middle frag).
672 * See above long comment about this trickery. */
673 if (mpf == MPF_LAST_SEGMENT && !fd_head) {
674 fd_head = fragment_add_seq(tvb, offset, pinfo, id,
675 sna_fragment_table, MIDDLE_FRAG_NUMBER,
679 if (fd_head != NULL) {
680 /* We have the complete reassembled payload. */
681 rh_tvb = tvb_new_real_data(fd_head->data,
682 fd_head->len, fd_head->len);
684 /* Add the tvbuff to the chain of tvbuffs so that
685 * it will get cleaned up too. */
686 tvb_set_child_real_data_tvbuff(tvb, rh_tvb);
688 /* Add the defragmented data to the data source list. */
689 add_new_data_source(pinfo, rh_tvb, "Reassembled SNA BIU");
695 #define SNA_FID01_ADDR_LEN 2
697 /* FID Types 0 and 1 */
699 dissect_fid0_1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
706 const int bytes_in_header = 10;
710 th_0 = tvb_get_guint8(tvb, 0);
711 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
712 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
714 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
715 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
716 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
719 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
722 proto_tree_add_item(tree, hf_sna_th_daf, tvb, 2, 2, FALSE);
726 ptr = tvb_get_ptr(tvb, 2, SNA_FID01_ADDR_LEN);
727 SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
728 SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
731 proto_tree_add_item(tree, hf_sna_th_oaf, tvb, 4, 2, FALSE);
735 ptr = tvb_get_ptr(tvb, 4, SNA_FID01_ADDR_LEN);
736 SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
737 SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
739 /* If we're not filling a proto_tree, return now */
741 return bytes_in_header;
744 proto_tree_add_item(tree, hf_sna_th_snf, tvb, 6, 2, FALSE);
745 proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 8, 2, FALSE);
747 return bytes_in_header;
750 #define SNA_FID2_ADDR_LEN 1
754 dissect_fid2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
755 tvbuff_t **rh_tvb_ptr, next_dissection_t *continue_dissecting)
759 guint8 th_0=0, daf=0, oaf=0;
761 unsigned int mpf, id;
763 const int bytes_in_header = 6;
765 th_0 = tvb_get_guint8(tvb, 0);
766 mpf = mpf_value(th_0);
769 daf = tvb_get_guint8(tvb, 2);
770 oaf = tvb_get_guint8(tvb, 3);
773 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
774 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
776 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
777 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
778 proto_tree_add_uint(bf_tree, hf_sna_th_odai,tvb, 0, 1, th_0);
779 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
783 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
786 proto_tree_add_uint_format(tree, hf_sna_th_daf, tvb, 2, 1, daf,
787 "Destination Address Field: 0x%02x", daf);
791 ptr = tvb_get_ptr(tvb, 2, SNA_FID2_ADDR_LEN);
792 SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
793 SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
797 proto_tree_add_uint_format(tree, hf_sna_th_oaf, tvb, 3, 1, oaf,
798 "Origin Address Field: 0x%02x", oaf);
802 ptr = tvb_get_ptr(tvb, 3, SNA_FID2_ADDR_LEN);
803 SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
804 SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
806 id = tvb_get_ntohs(tvb, 4);
808 proto_tree_add_uint(tree, hf_sna_th_snf, tvb, 4, 2, id);
811 if (mpf != MPF_WHOLE_BIU && !sna_defragment) {
812 if (mpf == MPF_FIRST_SEGMENT) {
813 *continue_dissecting = rh_only;
816 *continue_dissecting = stop_here;
820 else if (sna_defragment) {
821 *rh_tvb_ptr = defragment_by_sequence(pinfo, tvb, bytes_in_header,
825 return bytes_in_header;
830 dissect_fid3(tvbuff_t *tvb, proto_tree *tree)
836 const int bytes_in_header = 2;
838 /* If we're not filling a proto_tree, return now */
840 return bytes_in_header;
843 th_0 = tvb_get_guint8(tvb, 0);
845 /* Create the bitfield tree */
846 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
847 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
849 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
850 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
851 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
853 proto_tree_add_item(tree, hf_sna_th_lsid, tvb, 1, 1, FALSE);
855 return bytes_in_header;
860 dissect_fid4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
869 static struct sna_fid_type_4_addr src, dst;
871 const int bytes_in_header = 26;
873 /* If we're not filling a proto_tree, return now */
875 return bytes_in_header;
879 th_byte = tvb_get_guint8(tvb, offset);
881 /* Create the bitfield tree */
882 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, offset, 1, th_byte);
883 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
886 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, offset, 1, th_byte);
887 proto_tree_add_uint(bf_tree, hf_sna_th_tg_sweep, tvb, offset, 1, th_byte);
888 proto_tree_add_uint(bf_tree, hf_sna_th_er_vr_supp_ind, tvb, offset, 1, th_byte);
889 proto_tree_add_uint(bf_tree, hf_sna_th_vr_pac_cnt_ind, tvb, offset, 1, th_byte);
890 proto_tree_add_uint(bf_tree, hf_sna_th_ntwk_prty, tvb, offset, 1, th_byte);
893 th_byte = tvb_get_guint8(tvb, offset);
895 /* Create the bitfield tree */
896 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 1");
897 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
900 proto_tree_add_uint(bf_tree, hf_sna_th_tgsf, tvb, offset, 1, th_byte);
901 proto_tree_add_boolean(bf_tree, hf_sna_th_mft, tvb, offset, 1, th_byte);
902 proto_tree_add_uint(bf_tree, hf_sna_th_piubf, tvb, offset, 1, th_byte);
904 mft = th_byte & 0x04;
906 th_byte = tvb_get_guint8(tvb, offset);
908 /* Create the bitfield tree */
909 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 2");
910 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
914 proto_tree_add_uint(bf_tree, hf_sna_th_nlpoi, tvb, offset, 1, th_byte);
915 proto_tree_add_uint(bf_tree, hf_sna_th_nlp_cp, tvb, offset, 1, th_byte);
918 proto_tree_add_uint(bf_tree, hf_sna_th_iern, tvb, offset, 1, th_byte);
920 proto_tree_add_uint(bf_tree, hf_sna_th_ern, tvb, offset, 1, th_byte);
923 th_byte = tvb_get_guint8(tvb, offset);
925 /* Create the bitfield tree */
926 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 3");
927 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
930 proto_tree_add_uint(bf_tree, hf_sna_th_vrn, tvb, offset, 1, th_byte);
931 proto_tree_add_uint(bf_tree, hf_sna_th_tpf, tvb, offset, 1, th_byte);
934 th_word = tvb_get_ntohs(tvb, offset);
936 /* Create the bitfield tree */
937 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Bytes 4-5");
938 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
941 proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwi, tvb, offset, 2, th_word);
942 proto_tree_add_boolean(bf_tree, hf_sna_th_tg_nonfifo_ind, tvb, offset, 2, th_word);
943 proto_tree_add_uint(bf_tree, hf_sna_th_vr_sqti, tvb, offset, 2, th_word);
945 /* I'm not sure about byte-order on this one... */
946 proto_tree_add_uint(bf_tree, hf_sna_th_tg_snf, tvb, offset, 2, th_word);
949 th_word = tvb_get_ntohs(tvb, offset);
951 /* Create the bitfield tree */
952 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Bytes 6-7");
953 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
956 proto_tree_add_boolean(bf_tree, hf_sna_th_vrprq, tvb, offset, 2, th_word);
957 proto_tree_add_boolean(bf_tree, hf_sna_th_vrprs, tvb, offset, 2, th_word);
958 proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwri, tvb, offset, 2, th_word);
959 proto_tree_add_boolean(bf_tree, hf_sna_th_vr_rwi, tvb, offset, 2, th_word);
961 /* I'm not sure about byte-order on this one... */
962 proto_tree_add_uint(bf_tree, hf_sna_th_vr_snf_send, tvb, offset, 2, th_word);
967 dsaf = tvb_get_ntohl(tvb, 8);
970 proto_tree_add_uint(tree, hf_sna_th_dsaf, tvb, offset, 4, dsaf);
975 osaf = tvb_get_ntohl(tvb, 12);
978 proto_tree_add_uint(tree, hf_sna_th_osaf, tvb, offset, 4, osaf);
981 th_byte = tvb_get_guint8(tvb, offset);
983 /* Create the bitfield tree */
984 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Byte 16");
985 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
988 proto_tree_add_boolean(tree, hf_sna_th_snai, tvb, offset, 1, th_byte);
990 /* We luck out here because in their infinite wisdom the SNA
991 * architects placed the MPF and EFI fields in the same bitfield
992 * locations, even though for FID4 they're not in byte 0.
994 proto_tree_add_uint(tree, hf_sna_th_mpf, tvb, offset, 1, th_byte);
995 proto_tree_add_uint(tree, hf_sna_th_efi, tvb, offset, 1, th_byte);
997 offset += 2; /* 1 for byte 16, 1 for byte 17 which is reserved */
1001 def = tvb_get_ntohs(tvb, 18);
1004 proto_tree_add_uint(tree, hf_sna_th_def, tvb, offset, 2, def);
1007 /* Addresses in FID 4 are discontiguous, sigh */
1010 SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8* )&dst);
1011 SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&dst);
1014 oef = tvb_get_ntohs(tvb, 20);
1016 proto_tree_add_uint(tree, hf_sna_th_oef, tvb, offset+2, 2, oef);
1019 /* Addresses in FID 4 are discontiguous, sigh */
1022 SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&src);
1023 SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&src);
1026 proto_tree_add_item(tree, hf_sna_th_snf, tvb, offset+4, 2, FALSE);
1027 proto_tree_add_item(tree, hf_sna_th_dcf, tvb, offset+6, 2, FALSE);
1030 return bytes_in_header;
1035 dissect_fid5(tvbuff_t *tvb, proto_tree *tree)
1037 proto_tree *bf_tree;
1038 proto_item *bf_item;
1041 const int bytes_in_header = 12;
1043 /* If we're not filling a proto_tree, return now */
1045 return bytes_in_header;
1048 th_0 = tvb_get_guint8(tvb, 0);
1050 /* Create the bitfield tree */
1051 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
1052 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1054 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
1055 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
1056 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
1058 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
1059 proto_tree_add_item(tree, hf_sna_th_snf, tvb, 2, 2, FALSE);
1061 proto_tree_add_item(tree, hf_sna_th_sa, tvb, 4, 8, FALSE);
1063 return bytes_in_header;
1069 dissect_fidf(tvbuff_t *tvb, proto_tree *tree)
1071 proto_tree *bf_tree;
1072 proto_item *bf_item;
1075 const int bytes_in_header = 26;
1077 /* If we're not filling a proto_tree, return now */
1079 return bytes_in_header;
1082 th_0 = tvb_get_guint8(tvb, 0);
1084 /* Create the bitfield tree */
1085 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
1086 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
1088 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
1089 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
1091 proto_tree_add_item(tree, hf_sna_th_cmd_fmt, tvb, 2, 1, FALSE);
1092 proto_tree_add_item(tree, hf_sna_th_cmd_type, tvb, 3, 1, FALSE);
1093 proto_tree_add_item(tree, hf_sna_th_cmd_sn, tvb, 4, 2, FALSE);
1095 /* Yup, bytes 6-23 are reserved! */
1096 proto_tree_add_text(tree, tvb, 6, 18, "Reserved");
1098 proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 24, 2, FALSE);
1100 return bytes_in_header;
1103 /* HPR Network Layer Packet */
1105 dissect_nlp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
1106 proto_tree *parent_tree)
1108 proto_tree *nlp_tree, *bf_tree;
1109 proto_item *nlp_item, *bf_item, *h_item;
1110 guint8 nhdr_0, nhdr_1, nhdr_x, thdr_8, thdr_9;
1111 guint32 thdr_len, thdr_dlf, thdr_bsn;
1113 int index = 0, counter = 0;
1118 nhdr_0 = tvb_get_guint8(tvb, index);
1119 nhdr_1 = tvb_get_guint8(tvb, index+1);
1121 if (check_col(pinfo->cinfo, COL_INFO))
1122 col_add_str(pinfo->cinfo, COL_INFO, "HPR NLP Packet");
1125 /* Don't bother setting length. We'll set it later after we find
1126 * the lengths of NHDR */
1127 nlp_item = proto_tree_add_item(tree, hf_sna_nlp_nhdr, tvb, index, -1, FALSE);
1128 nlp_tree = proto_item_add_subtree(nlp_item, ett_sna_nlp_nhdr);
1130 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_nhdr_0, tvb, index, 1, nhdr_0);
1131 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_nhdr_0);
1133 proto_tree_add_uint(bf_tree, hf_sna_nlp_sm, tvb, index, 1, nhdr_0);
1134 proto_tree_add_uint(bf_tree, hf_sna_nlp_tpf, tvb, index, 1, nhdr_0);
1136 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_nhdr_1, tvb, index+1, 1, nhdr_1);
1137 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_nhdr_1);
1139 proto_tree_add_uint(bf_tree, hf_sna_nlp_ft, tvb, index+1, 1, nhdr_1);
1140 proto_tree_add_boolean(bf_tree, hf_sna_nlp_tspi, tvb, index+1, 1, nhdr_1);
1141 proto_tree_add_boolean(bf_tree, hf_sna_nlp_slowdn1, tvb, index+1, 1, nhdr_1);
1142 proto_tree_add_boolean(bf_tree, hf_sna_nlp_slowdn2, tvb, index+1, 1, nhdr_1);
1144 /* ANR or FR lists */
1149 if ((nhdr_0 & 0xe0) == 0xa0) {
1151 nhdr_x = tvb_get_guint8(tvb, index + counter);
1153 } while (nhdr_x != 0xff);
1155 h_item = proto_tree_add_item(nlp_tree, hf_sna_nlp_fra, tvb, index, counter, FALSE);
1158 index++; /* 1 Byte Reserved */
1161 proto_item_set_len(nlp_item, index);
1163 if ((nhdr_1 & 0x80) == 0x10) {
1164 nhdr_x = tvb_get_guint8(tvb, index);
1166 proto_tree_add_uint(tree, hf_sna_nlp_frh, tvb, index, 1, nhdr_x);
1170 if (tvb_offset_exists(tvb, index+1)) {
1171 call_dissector(data_handle,
1172 tvb_new_subset(tvb, index, -1, -1),
1173 pinfo, parent_tree);
1178 if ((nhdr_0 & 0xe0) == 0xc0) {
1180 nhdr_x = tvb_get_guint8(tvb, index + counter);
1182 } while (nhdr_x != 0xff);
1184 h_item = proto_tree_add_item(nlp_tree, hf_sna_nlp_anr, tvb, index, counter, FALSE);
1187 index++; /* 1 Byte Reserved */
1190 proto_item_set_len(nlp_item, index);
1195 thdr_8 = tvb_get_guint8(tvb, index+8);
1196 thdr_9 = tvb_get_guint8(tvb, index+9);
1197 thdr_len = tvb_get_ntohs(tvb, index+10);
1198 thdr_dlf = tvb_get_ntohl(tvb, index+12);
1199 thdr_bsn = tvb_get_ntohl(tvb, index+16);
1202 /* Don't bother setting length. We'll set it later after we find
1203 * the lengths of NHDR */
1204 nlp_item = proto_tree_add_item(tree, hf_sna_nlp_thdr, tvb, index, -1, FALSE);
1205 nlp_tree = proto_item_add_subtree(nlp_item, ett_sna_nlp_thdr);
1207 bf_item = proto_tree_add_item(nlp_tree, hf_sna_nlp_tcid, tvb, index, 8, FALSE);
1209 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_thdr_8, tvb, index+8, 1, thdr_8);
1210 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_thdr_8);
1212 proto_tree_add_boolean(bf_tree, hf_sna_nlp_setupi, tvb, index+8, 1, thdr_8);
1213 proto_tree_add_boolean(bf_tree, hf_sna_nlp_somi, tvb, index+8, 1, thdr_8);
1214 proto_tree_add_boolean(bf_tree, hf_sna_nlp_eomi, tvb, index+8, 1, thdr_8);
1215 proto_tree_add_boolean(bf_tree, hf_sna_nlp_sri, tvb, index+8, 1, thdr_8);
1216 proto_tree_add_boolean(bf_tree, hf_sna_nlp_rasapi, tvb, index+8, 1, thdr_8);
1217 proto_tree_add_boolean(bf_tree, hf_sna_nlp_retryi, tvb, index+8, 1, thdr_8);
1219 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_thdr_9, tvb, index+9, 1, thdr_9);
1220 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_thdr_9);
1222 proto_tree_add_boolean(bf_tree, hf_sna_nlp_lmi, tvb, index+9, 1, thdr_9);
1223 proto_tree_add_boolean(bf_tree, hf_sna_nlp_cqfi, tvb, index+9, 1, thdr_9);
1224 proto_tree_add_boolean(bf_tree, hf_sna_nlp_osi, tvb, index+9, 1, thdr_9);
1226 proto_tree_add_uint(nlp_tree, hf_sna_nlp_offset, tvb, index+10, 2, thdr_len);
1227 proto_tree_add_uint(nlp_tree, hf_sna_nlp_dlf, tvb, index+12, 4, thdr_dlf);
1228 proto_tree_add_uint(nlp_tree, hf_sna_nlp_bsn, tvb, index+16, 4, thdr_bsn);
1230 proto_item_set_len(nlp_item, thdr_len);
1232 index += (thdr_len << 2);
1233 if (((thdr_8 & 0x20) == 0) && thdr_dlf) {
1234 if (check_col(pinfo->cinfo, COL_INFO))
1235 col_add_str(pinfo->cinfo, COL_INFO, "HPR Fragment");
1236 if (tvb_offset_exists(tvb, index+1)) {
1237 call_dissector(data_handle,
1238 tvb_new_subset(tvb, index, -1, -1), pinfo,
1243 if (tvb_offset_exists(tvb, index+1)) {
1244 dissect_fid(tvb_new_subset(tvb, index, -1, -1), pinfo, tree,
1251 dissect_rh(tvbuff_t *tvb, int offset, proto_tree *tree)
1253 proto_tree *bf_tree;
1254 proto_item *bf_item;
1255 gboolean is_response;
1256 guint8 rh_0, rh_1, rh_2;
1259 /* Create the bitfield tree for byte 0*/
1260 rh_0 = tvb_get_guint8(tvb, offset);
1261 is_response = (rh_0 & 0x80);
1263 bf_item = proto_tree_add_uint(tree, hf_sna_rh_0, tvb, offset, 1, rh_0);
1264 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_0);
1266 proto_tree_add_uint(bf_tree, hf_sna_rh_rri, tvb, offset, 1, rh_0);
1267 proto_tree_add_uint(bf_tree, hf_sna_rh_ru_category, tvb, offset, 1, rh_0);
1268 proto_tree_add_boolean(bf_tree, hf_sna_rh_fi, tvb, offset, 1, rh_0);
1269 proto_tree_add_boolean(bf_tree, hf_sna_rh_sdi, tvb, offset, 1, rh_0);
1270 proto_tree_add_boolean(bf_tree, hf_sna_rh_bci, tvb, offset, 1, rh_0);
1271 proto_tree_add_boolean(bf_tree, hf_sna_rh_eci, tvb, offset, 1, rh_0);
1274 rh_1 = tvb_get_guint8(tvb, offset);
1276 /* Create the bitfield tree for byte 1*/
1277 bf_item = proto_tree_add_uint(tree, hf_sna_rh_1, tvb, offset, 1, rh_1);
1278 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_1);
1280 proto_tree_add_boolean(bf_tree, hf_sna_rh_dr1, tvb, offset, 1, rh_1);
1283 proto_tree_add_boolean(bf_tree, hf_sna_rh_lcci, tvb, offset, 1, rh_1);
1286 proto_tree_add_boolean(bf_tree, hf_sna_rh_dr2, tvb, offset, 1, rh_1);
1289 proto_tree_add_boolean(bf_tree, hf_sna_rh_rti, tvb, offset, 1, rh_1);
1292 proto_tree_add_boolean(bf_tree, hf_sna_rh_eri, tvb, offset, 1, rh_1);
1293 proto_tree_add_boolean(bf_tree, hf_sna_rh_rlwi, tvb, offset, 1, rh_1);
1296 proto_tree_add_boolean(bf_tree, hf_sna_rh_qri, tvb, offset, 1, rh_1);
1297 proto_tree_add_boolean(bf_tree, hf_sna_rh_pi, tvb, offset, 1, rh_1);
1300 rh_2 = tvb_get_guint8(tvb, offset);
1302 /* Create the bitfield tree for byte 2*/
1303 bf_item = proto_tree_add_uint(tree, hf_sna_rh_2, tvb, offset, 1, rh_2);
1306 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_2);
1308 proto_tree_add_boolean(bf_tree, hf_sna_rh_bbi, tvb, offset, 1, rh_2);
1309 proto_tree_add_boolean(bf_tree, hf_sna_rh_ebi, tvb, offset, 1, rh_2);
1310 proto_tree_add_boolean(bf_tree, hf_sna_rh_cdi, tvb, offset, 1, rh_2);
1311 proto_tree_add_uint(bf_tree, hf_sna_rh_csi, tvb, offset, 1, rh_2);
1312 proto_tree_add_boolean(bf_tree, hf_sna_rh_edi, tvb, offset, 1, rh_2);
1313 proto_tree_add_boolean(bf_tree, hf_sna_rh_pdi, tvb, offset, 1, rh_2);
1314 proto_tree_add_boolean(bf_tree, hf_sna_rh_cebi, tvb, offset, 1, rh_2);
1317 /* XXX - check for sdi. If TRUE, the next 4 bytes will be sense data */
1323 fragment_table_init(&sna_fragment_table);
1324 reassembled_table_init(&sna_reassembled_table);
1329 proto_register_sna(void)
1331 static hf_register_info hf[] = {
1333 { "Transmission Header", "sna.th", FT_NONE, BASE_NONE, NULL, 0x0,
1337 { "Transmission Header Byte 0", "sna.th.0", FT_UINT8, BASE_HEX, NULL, 0x0,
1338 "Byte 0 of Tranmission Header contains FID, MPF, ODAI,"
1339 " and EFI as bitfields.", HFILL }},
1342 { "Format Identifer", "sna.th.fid", FT_UINT8, BASE_HEX, VALS(sna_th_fid_vals), 0xf0,
1343 "Format Identification", HFILL }},
1346 { "Mapping Field", "sna.th.mpf", FT_UINT8, BASE_DEC, VALS(sna_th_mpf_vals), 0x0c,
1347 "The Mapping Field specifies whether the information field"
1348 " associated with the TH is a complete or partial BIU.", HFILL }},
1351 { "ODAI Assignment Indicator", "sna.th.odai", FT_UINT8, BASE_DEC, NULL, 0x02,
1352 "The ODAI indicates which node assigned the OAF'-DAF' values"
1353 " carried in the TH.", HFILL }},
1356 { "Expedited Flow Indicator", "sna.th.efi", FT_UINT8, BASE_DEC, VALS(sna_th_efi_vals), 0x01,
1357 "The EFI designates whether the PIU belongs to the normal"
1358 " or expedited flow.", HFILL }},
1361 { "Destination Address Field", "sna.th.daf", FT_UINT16, BASE_HEX, NULL, 0x0,
1365 { "Origin Address Field", "sna.th.oaf", FT_UINT16, BASE_HEX, NULL, 0x0,
1369 { "Sequence Number Field", "sna.th.snf", FT_UINT16, BASE_DEC, NULL, 0x0,
1370 "The Sequence Number Field contains a numerical identifier for"
1371 " the associated BIU.", HFILL }},
1374 { "Data Count Field", "sna.th.dcf", FT_UINT16, BASE_DEC, NULL, 0x0,
1375 "A binary count of the number of bytes in the BIU or BIU segment associated "
1376 "with the tranmission header. The count does not include any of the bytes "
1377 "in the transmission header.", HFILL }},
1380 { "Local Session Identification", "sna.th.lsid", FT_UINT8, BASE_HEX, NULL, 0x0,
1383 { &hf_sna_th_tg_sweep,
1384 { "Transmission Group Sweep", "sna.th.tg_sweep", FT_UINT8, BASE_DEC,
1385 VALS(sna_th_tg_sweep_vals), 0x08,
1388 { &hf_sna_th_er_vr_supp_ind,
1389 { "ER and VR Support Indicator", "sna.th.er_vr_supp_ind", FT_UINT8, BASE_DEC,
1390 VALS(sna_th_er_vr_supp_ind_vals), 0x04,
1393 { &hf_sna_th_vr_pac_cnt_ind,
1394 { "Virtual Route Pacing Count Indicator", "sna.th.vr_pac_cnt_ind",
1395 FT_UINT8, BASE_DEC, VALS(sna_th_vr_pac_cnt_ind_vals), 0x02,
1398 { &hf_sna_th_ntwk_prty,
1399 { "Network Priority", "sna.th.ntwk_prty",
1400 FT_UINT8, BASE_DEC, VALS(sna_th_ntwk_prty_vals), 0x01,
1404 { "Transmission Group Segmenting Field", "sna.th.tgsf",
1405 FT_UINT8, BASE_HEX, VALS(sna_th_tgsf_vals), 0xc0,
1409 { "MPR FID4 Type", "sna.th.mft", FT_BOOLEAN, BASE_NONE, NULL, 0x04,
1413 { "PIU Blocking Field", "sna.th.piubf", FT_UINT8, BASE_HEX,
1414 VALS(sna_th_piubf_vals), 0x03,
1415 "Specifies whether this frame contains a single PIU or multiple PIUs.", HFILL }},
1418 { "Initial Explicit Route Number", "sna.th.iern", FT_UINT8, BASE_DEC, NULL, 0xf0,
1422 { "NLP Offset Indicator", "sna.th.nlpoi", FT_UINT8, BASE_DEC,
1423 VALS(sna_th_nlpoi_vals), 0x80,
1426 { &hf_sna_th_nlp_cp,
1427 { "NLP Count or Padding", "sna.th.nlp_cp", FT_UINT8, BASE_DEC, NULL, 0x70,
1431 { "Explicit Route Number", "sna.th.ern", FT_UINT8, BASE_DEC, NULL, 0x0f,
1432 "The ERN in a TH identifies an explicit route direction of flow.", HFILL }},
1435 { "Virtual Route Number", "sna.th.vrn", FT_UINT8, BASE_DEC, NULL, 0xf0,
1439 { "Transmission Priority Field", "sna.th.tpf", FT_UINT8, BASE_HEX,
1440 VALS(sna_th_tpf_vals), 0x03,
1443 { &hf_sna_th_vr_cwi,
1444 { "Virtual Route Change Window Indicator", "sna.th.vr_cwi", FT_UINT16, BASE_DEC,
1445 VALS(sna_th_vr_cwi_vals), 0x8000,
1446 "Used to change the window size of the virtual route by 1.", HFILL }},
1448 { &hf_sna_th_tg_nonfifo_ind,
1449 { "Transmission Group Non-FIFO Indicator", "sna.th.tg_nonfifo_ind", FT_BOOLEAN, 16,
1450 TFS(&sna_th_tg_nonfifo_ind_truth), 0x4000,
1451 "Indicates whether or not FIFO discipline is to enforced in "
1452 "transmitting PIUs through the tranmission groups to prevent the PIUs "
1453 "getting out of sequence during transmission over the TGs.", HFILL }},
1455 { &hf_sna_th_vr_sqti,
1456 { "Virtual Route Sequence and Type Indicator", "sna.th.vr_sqti", FT_UINT16, BASE_HEX,
1457 VALS(sna_th_vr_sqti_vals), 0x3000,
1458 "Specifies the PIU type.", HFILL }},
1460 { &hf_sna_th_tg_snf,
1461 { "Transmission Group Sequence Number Field", "sna.th.tg_snf", FT_UINT16, BASE_DEC,
1466 { "Virtual Route Pacing Request", "sna.th.vrprq", FT_BOOLEAN, 16,
1467 TFS(&sna_th_vrprq_truth), 0x8000,
1471 { "Virtual Route Pacing Response", "sna.th.vrprs", FT_BOOLEAN, 16,
1472 TFS(&sna_th_vrprs_truth), 0x4000,
1475 { &hf_sna_th_vr_cwri,
1476 { "Virtual Route Change Window Reply Indicator", "sna.th.vr_cwri", FT_UINT16, BASE_DEC,
1477 VALS(sna_th_vr_cwri_vals), 0x2000,
1478 "Permits changing of the window size by 1 for PIUs received by the "
1479 "sender of this bit.", HFILL }},
1481 { &hf_sna_th_vr_rwi,
1482 { "Virtual Route Reset Window Indicator", "sna.th.vr_rwi", FT_BOOLEAN, 16,
1483 TFS(&sna_th_vr_rwi_truth), 0x1000,
1484 "Indicates severe congestion in a node on the virtual route.", HFILL }},
1486 { &hf_sna_th_vr_snf_send,
1487 { "Virtual Route Send Sequence Number Field", "sna.th.vr_snf_send", FT_UINT16, BASE_DEC,
1492 { "Destination Subarea Address Field", "sna.th.dsaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1496 { "Origin Subarea Address Field", "sna.th.osaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1500 { "SNA Indicator", "sna.th.snai", FT_BOOLEAN, 8, NULL, 0x10,
1501 "Used to identify whether the PIU originated or is destined for "
1502 "an SNA or non-SNA device.", HFILL }},
1505 { "Destination Element Field", "sna.th.def", FT_UINT16, BASE_HEX, NULL, 0x0,
1509 { "Origin Element Field", "sna.th.oef", FT_UINT16, BASE_HEX, NULL, 0x0,
1513 { "Session Address", "sna.th.sa", FT_BYTES, BASE_HEX, NULL, 0x0,
1516 { &hf_sna_th_cmd_fmt,
1517 { "Command Format", "sna.th.cmd_fmt", FT_UINT8, BASE_HEX, NULL, 0x0,
1520 { &hf_sna_th_cmd_type,
1521 { "Command Type", "sna.th.cmd_type", FT_UINT8, BASE_HEX, NULL, 0x0,
1524 { &hf_sna_th_cmd_sn,
1525 { "Command Sequence Number", "sna.th.cmd_sn", FT_UINT16, BASE_DEC, NULL, 0x0,
1529 { "Network Layer Packet Header", "sna.nlp.nhdr", FT_NONE, BASE_NONE, NULL, 0x0,
1530 "Network Layer Packet Header (NHDR)", HFILL }},
1532 { &hf_sna_nlp_nhdr_0,
1533 { "Network Layer Packet Header Byte 0", "sna.nlp.nhdr.0", FT_UINT8, BASE_HEX, NULL, 0x0,
1534 "Byte 0 of Network Layer Packet contains SM and TPF", HFILL }},
1536 { &hf_sna_nlp_nhdr_1,
1537 { "Network Layer Packet Header Bype 1", "sna.nlp.nhdr.1", FT_UINT8, BASE_HEX, NULL, 0x0,
1538 "Byte 1 of Network Layer Packet contains FT,"
1539 " Time Sensitive Packet Indicator and Congestion Indicator", HFILL }},
1542 { "Switching Mode Field", "sna.nlp.nhdr.sm", FT_UINT8, BASE_HEX,
1543 VALS(sna_nlp_sm_vals), 0xe0,
1547 { "Transmission Priority Field", "sna.nlp.nhdr.tpf", FT_UINT8, BASE_HEX,
1548 VALS(sna_th_tpf_vals), 0x06,
1552 { "Function Type", "sna.nlp.nhdr.ft", FT_UINT8, BASE_HEX,
1553 VALS(sna_nlp_ft_vals), 0xF0,
1557 { "Time Sensitive Packet Indicator", "sna.nlp.nhdr.tspi", FT_BOOLEAN, 8,
1558 TFS(&sna_nlp_tspi_truth), 0x08,
1561 { &hf_sna_nlp_slowdn1,
1562 { "Slowdown 1", "sna.nlp.nhdr.slowdn1", FT_BOOLEAN, 8,
1563 TFS(&sna_nlp_slowdn1_truth), 0x04,
1566 { &hf_sna_nlp_slowdn2,
1567 { "Slowdown 2", "sna.nlp.nhdr.slowdn2", FT_BOOLEAN, 8,
1568 TFS(&sna_nlp_slowdn2_truth), 0x02,
1572 { "Function Routing Address Entry", "sna.nlp.nhdr.fra", FT_BYTES, BASE_NONE, NULL, 0,
1576 { "Automatic Network Routing Entry", "sna.nlp.nhdr.anr", FT_BYTES, BASE_HEX, NULL, 0,
1580 { "Transmission Priority Field", "sna.nlp.frh", FT_UINT8, BASE_HEX,
1581 VALS(sna_nlp_frh_vals), 0, "", HFILL }},
1584 { "RTP Transport Header", "sna.nlp.thdr", FT_NONE, BASE_NONE, NULL, 0x0,
1585 "RTP Transport Header (THDR)", HFILL }},
1588 { "Transport Connection Identifier", "sna.nlp.thdr.tcid", FT_BYTES, BASE_HEX, NULL, 0x0,
1589 "Transport Connection Identifier (TCID)", HFILL }},
1591 { &hf_sna_nlp_thdr_8,
1592 { "RTP Transport Packet Header Bype 8", "sna.nlp.thdr.8", FT_UINT8, BASE_HEX, NULL, 0x0,
1593 "Byte 8 of RTP Transport Packet Header", HFILL }},
1595 { &hf_sna_nlp_setupi,
1596 { "Setup Indicator", "sna.nlp.thdr.setupi", FT_BOOLEAN, 8,
1597 TFS(&sna_nlp_setupi_truth), 0x40,
1601 { "Start Of Message Indicator", "sna.nlp.thdr.somi", FT_BOOLEAN, 8,
1602 TFS(&sna_nlp_somi_truth), 0x20,
1606 { "End Of Message Indicator", "sna.nlp.thdr.eomi", FT_BOOLEAN, 8,
1607 TFS(&sna_nlp_eomi_truth), 0x10,
1611 { "Session Request Indicator", "sna.nlp.thdr.sri", FT_BOOLEAN, 8,
1612 TFS(&sna_nlp_sri_truth), 0x08,
1615 { &hf_sna_nlp_rasapi,
1616 { "Reply ASAP Indicator", "sna.nlp.thdr.rasapi", FT_BOOLEAN, 8,
1617 TFS(&sna_nlp_rasapi_truth), 0x04,
1620 { &hf_sna_nlp_retryi,
1621 { "Retry Indicator", "sna.nlp.thdr.retryi", FT_BOOLEAN, 8,
1622 TFS(&sna_nlp_retryi_truth), 0x02,
1625 { &hf_sna_nlp_thdr_9,
1626 { "RTP Transport Packet Header Bype 9", "sna.nlp.thdr.9", FT_UINT8, BASE_HEX, NULL, 0x0,
1627 "Byte 9 of RTP Transport Packet Header", HFILL }},
1630 { "Last Message Indicator", "sna.nlp.thdr.lmi", FT_BOOLEAN, 8,
1631 TFS(&sna_nlp_lmi_truth), 0x80,
1635 { "Connection Qualifyer Field Indicator", "sna.nlp.thdr.cqfi", FT_BOOLEAN, 8,
1636 TFS(&sna_nlp_cqfi_truth), 0x08,
1640 { "Optional Segments Present Indicator", "sna.nlp.thdr.osi", FT_BOOLEAN, 8,
1641 TFS(&sna_nlp_osi_truth), 0x04,
1644 { &hf_sna_nlp_offset,
1645 { "Data Offset/4", "sna.nlp.thdr.offset", FT_UINT16, BASE_HEX, NULL, 0x0,
1646 "Data Offset in words", HFILL }},
1649 { "Data Length Field", "sna.nlp.thdr.dlf", FT_UINT32, BASE_HEX, NULL, 0x0,
1650 "Data Length Field", HFILL }},
1653 { "Byte Sequence Number", "sna.nlp.thdr.bsn", FT_UINT32, BASE_HEX, NULL, 0x0,
1654 "Byte Sequence Number", HFILL }},
1658 { "Request/Response Header", "sna.rh", FT_NONE, BASE_NONE, NULL, 0x0,
1662 { "Request/Response Header Byte 0", "sna.rh.0", FT_UINT8, BASE_HEX, NULL, 0x0,
1666 { "Request/Response Header Byte 1", "sna.rh.1", FT_UINT8, BASE_HEX, NULL, 0x0,
1670 { "Request/Response Header Byte 2", "sna.rh.2", FT_UINT8, BASE_HEX, NULL, 0x0,
1674 { "Request/Response Indicator", "sna.rh.rri", FT_UINT8, BASE_DEC, VALS(sna_rh_rri_vals), 0x80,
1675 "Denotes whether this is a request or a response.", HFILL }},
1677 { &hf_sna_rh_ru_category,
1678 { "Request/Response Unit Category", "sna.rh.ru_category", FT_UINT8, BASE_HEX,
1679 VALS(sna_rh_ru_category_vals), 0x60,
1683 { "Format Indicator", "sna.rh.fi", FT_BOOLEAN, 8, TFS(&sna_rh_fi_truth), 0x08,
1687 { "Sense Data Included", "sna.rh.sdi", FT_BOOLEAN, 8, TFS(&sna_rh_sdi_truth), 0x04,
1688 "Indicates that a 4-byte sense data field is included in the associated RU.", HFILL }},
1691 { "Begin Chain Indicator", "sna.rh.bci", FT_BOOLEAN, 8, TFS(&sna_rh_bci_truth), 0x02,
1695 { "End Chain Indicator", "sna.rh.eci", FT_BOOLEAN, 8, TFS(&sna_rh_eci_truth), 0x01,
1699 { "Definite Response 1 Indicator", "sna.rh.dr1", FT_BOOLEAN, 8, NULL, 0x80,
1703 { "Length-Checked Compression Indicator", "sna.rh.lcci", FT_BOOLEAN, 8,
1704 TFS(&sna_rh_lcci_truth), 0x40,
1708 { "Definite Response 2 Indicator", "sna.rh.dr2", FT_BOOLEAN, 8, NULL, 0x20,
1712 { "Exception Response Indicator", "sna.rh.eri", FT_BOOLEAN, 8, NULL, 0x10,
1713 "Used in conjunction with DR1I and DR2I to indicate, in a request, "
1714 "the form of response requested.", HFILL }},
1717 { "Response Type Indicator", "sna.rh.rti", FT_BOOLEAN, 8, TFS(&sna_rh_rti_truth), 0x10,
1721 { "Request Larger Window Indicator", "sna.rh.rlwi", FT_BOOLEAN, 8, NULL, 0x04,
1722 "Indicates whether a larger pacing window was requested.", HFILL }},
1725 { "Queued Response Indicator", "sna.rh.qri", FT_BOOLEAN, 8, TFS(&sna_rh_qri_truth), 0x02,
1729 { "Pacing Indicator", "sna.rh.pi", FT_BOOLEAN, 8, NULL, 0x01,
1733 { "Begin Bracket Indicator", "sna.rh.bbi", FT_BOOLEAN, 8, NULL, 0x80,
1737 { "End Bracket Indicator", "sna.rh.ebi", FT_BOOLEAN, 8, NULL, 0x40,
1741 { "Change Direction Indicator", "sna.rh.cdi", FT_BOOLEAN, 8, NULL, 0x20,
1745 { "Code Selection Indicator", "sna.rh.csi", FT_UINT8, BASE_DEC, VALS(sna_rh_csi_vals), 0x08,
1746 "Specifies the encoding used for the associated FMD RU.", HFILL }},
1749 { "Enciphered Data Indicator", "sna.rh.edi", FT_BOOLEAN, 8, NULL, 0x04,
1750 "Indicates that information in the associated RU is enciphered under "
1751 "session-level cryptography protocols.", HFILL }},
1754 { "Padded Data Indicator", "sna.rh.pdi", FT_BOOLEAN, 8, NULL, 0x02,
1755 "Indicates that the RU was padded at the end, before encipherment, to the next "
1756 "integral multiple of 8 bytes.", HFILL }},
1759 { "Conditional End Bracket Indicator", "sna.rh.cebi", FT_BOOLEAN, 8, NULL, 0x01,
1760 "Used to indicate the beginning or end of a group of exchanged "
1761 "requests and responses called a bracket. Only used on LU-LU sessions.", HFILL }},
1764 { "Request/Response Unit", "sna.ru", FT_NONE, BASE_NONE, NULL, 0x0,
1767 static gint *ett[] = {
1772 &ett_sna_nlp_nhdr_0,
1773 &ett_sna_nlp_nhdr_1,
1775 &ett_sna_nlp_thdr_8,
1776 &ett_sna_nlp_thdr_9,
1782 module_t *sna_module;
1784 proto_sna = proto_register_protocol("Systems Network Architecture",
1786 proto_register_field_array(proto_sna, hf, array_length(hf));
1787 proto_register_subtree_array(ett, array_length(ett));
1788 register_dissector("sna", dissect_sna, proto_sna);
1790 /* Register configuration options */
1791 sna_module = prefs_register_protocol(proto_sna, NULL);
1792 prefs_register_bool_preference(sna_module, "defragment",
1793 "Reassemble fragmented BIUs",
1794 "Whether fragmented BIUs should be reassembled",
1800 proto_reg_handoff_sna(void)
1802 dissector_handle_t sna_handle;
1804 sna_handle = find_dissector("sna");
1805 dissector_add("llc.dsap", SAP_SNA_PATHCTRL, sna_handle);
1807 dissector_add("ppp.protocol", PPP_SNA, sna_handle);
1808 data_handle = find_dissector("data");
1810 register_init_routine(sna_init);