Stuart Stanley's ISIS dissection support.
[obnox/wireshark/wip.git] / packet-sna.c
1 /* packet-sna.c
2  * Routines for SNA
3  * Gilbert Ramirez <gram@xiexie.org>
4  *
5  * $Id: packet-sna.c,v 1.10 1999/11/22 06:24:39 gram Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@unicom.net>
9  * Copyright 1998 Gerald Combs
10  *
11  * 
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.
16  * 
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.
21  * 
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.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #ifdef HAVE_SYS_TYPES_H
32 # include <sys/types.h>
33 #endif
34
35 #include <glib.h>
36 #include "packet.h"
37 #include "packet-sna.h"
38
39 /*
40  * http://www.wanresources.com/snacell.html
41  *
42  */
43
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;
87
88 static int hf_sna_rh = -1;
89 static int hf_sna_rh_0 = -1;
90 static int hf_sna_rh_1 = -1;
91 static int hf_sna_rh_2 = -1;
92 static int hf_sna_rh_rri = -1;
93 static int hf_sna_rh_ru_category = -1;
94 static int hf_sna_rh_fi = -1;
95 static int hf_sna_rh_sdi = -1;
96 static int hf_sna_rh_bci = -1;
97 static int hf_sna_rh_eci = -1;
98 static int hf_sna_rh_dr1 = -1;
99 static int hf_sna_rh_lcci = -1;
100 static int hf_sna_rh_dr2 = -1;
101 static int hf_sna_rh_eri = -1;
102 static int hf_sna_rh_rti = -1;
103 static int hf_sna_rh_rlwi = -1;
104 static int hf_sna_rh_qri = -1;
105 static int hf_sna_rh_pi = -1;
106 static int hf_sna_rh_bbi = -1;
107 static int hf_sna_rh_ebi = -1;
108 static int hf_sna_rh_cdi = -1;
109 static int hf_sna_rh_csi = -1;
110 static int hf_sna_rh_edi = -1;
111 static int hf_sna_rh_pdi = -1;
112 static int hf_sna_rh_cebi = -1;
113 static int hf_sna_ru = -1;
114
115 static gint ett_sna = -1;
116 static gint ett_sna_th = -1;
117 static gint ett_sna_th_fid = -1;
118 static gint ett_sna_rh = -1;
119 static gint ett_sna_rh_0 = -1;
120 static gint ett_sna_rh_1 = -1;
121 static gint ett_sna_rh_2 = -1;
122
123 /* Format Identifier */
124 static const value_string sna_th_fid_vals[] = {
125         { 0x0,  "SNA device <--> Non-SNA Device" },
126         { 0x1,  "Subarea Nodes, without ER or VR" },
127         { 0x2,  "Subarea Node <--> PU2" },
128         { 0x3,  "Subarea Node or SNA host <--> Subarea Node" },
129         { 0x4,  "Subarea Nodes, supporting ER and VR" },
130         { 0x5,  "HPR RTP endpoint nodes" },
131         { 0xf,  "Adjaced Subarea Nodes, supporting ER and VR" },
132         { 0x0,  NULL }
133 };
134
135 /* Mapping Field */
136 static const value_string sna_th_mpf_vals[] = {
137         { 0, "Middle segment of a BIU" },
138         { 1, "Last segment of a BIU" },
139         { 2, "First segment of a BIU" },
140         { 3 , "Whole BIU" },
141         { 0,   NULL }
142 };
143
144 /* Expedited Flow Indicator */
145 static const value_string sna_th_efi_vals[] = {
146         { 0, "Normal Flow" },
147         { 1, "Expedited Flow" }
148 };
149
150 /* Request/Response Indicator */
151 static const value_string sna_rh_rri_vals[] = {
152         { 0, "Request" },
153         { 1, "Response" }
154 };
155
156 /* Request/Response Unit Category */
157 static const value_string sna_rh_ru_category_vals[] = {
158         { 0x00, "Function Management Data (FMD)" },
159         { 0x01, "Network Control (NC)" },
160         { 0x10, "Data Flow Control (DFC)" },
161         { 0x11, "Session Control (SC)" },
162 };
163
164 /* Format Indicator */
165 static const true_false_string sna_rh_fi_truth =
166         { "FM Header", "No FM Header" };
167
168 /* Sense Data Included */
169 static const true_false_string sna_rh_sdi_truth =
170         { "Included", "Not Included" };
171
172 /* Begin Chain Indicator */
173 static const true_false_string sna_rh_bci_truth =
174         { "First in Chain", "Not First in Chain" };
175
176 /* End Chain Indicator */
177 static const true_false_string sna_rh_eci_truth =
178         { "Last in Chain", "Not Last in Chain" };
179
180 /* Lengith-Checked Compression Indicator */
181 static const true_false_string sna_rh_lcci_truth =
182         { "Compressed", "Not Compressed" };
183
184 /* Response Type Indicator */
185 static const true_false_string sna_rh_rti_truth =
186         { "Negative", "Positive" };
187
188 /* Exception Response Indicator */
189 static const true_false_string sna_rh_eri_truth =
190         { "Exception", "Definite" };
191
192 /* Queued Response Indicator */
193 static const true_false_string sna_rh_qri_truth =
194         { "Enqueue response in TC queues", "Response bypasses TC queues" };
195
196 /* Code Selection Indicator */
197 static const value_string sna_rh_csi_vals[] = {
198         { 0, "EBCDIC" },
199         { 1, "ASCII" }
200 };
201
202 /* TG Sweep */
203 static const value_string sna_th_tg_sweep_vals[] = {
204         { 0, "This PIU may overtake any PU ahead of it." },
205         { 1, "This PIU does not ovetake any PIU ahead of it." }
206 };
207
208 /* ER_VR_SUPP_IND */
209 static const value_string sna_th_er_vr_supp_ind_vals[] = {
210         { 0, "Each node supports ER and VR protocols" },
211         { 1, "Includes at least one node that does not support ER and VR protocols"  }
212 };
213
214 /* VR_PAC_CNT_IND */
215 static const value_string sna_th_vr_pac_cnt_ind_vals[] = {
216         { 0, "Pacing count on the VR has not reached 0" },
217         { 1, "Pacing count on the VR has reached 0" }
218 };
219
220 /* NTWK_PRTY */
221 static const value_string sna_th_ntwk_prty_vals[] = {
222         { 0, "PIU flows at a lower priority" },
223         { 1, "PIU flows at network priority (highest transmission priority)" }
224 };
225
226 /* TGSF */
227 static const value_string sna_th_tgsf_vals[] = {
228         { 0x00, "Not segmented" },
229         { 0x01, "Last segment" },
230         { 0x10, "First segment" },
231         { 0x11, "Middle segment" }
232 };
233
234 /* PIUBF */
235 static const value_string sna_th_piubf_vals[] = {
236         { 0x00, "Single PIU frame" },
237         { 0x01, "Last PIU of a multiple PIU frame" },
238         { 0x10, "First PIU of a multiple PIU frame" },
239         { 0x11, "Middle PIU of a multiple PIU frame" }
240 };
241
242 /* NLPOI */
243 static const value_string sna_th_nlpoi_vals[] = {
244         { 0x0, "NLP starts within this FID4 TH" },
245         { 0x1, "NLP byte 0 starts after RH byte 0 following NLP C/P pad" },
246 };
247
248 /* TPF */
249 static const value_string sna_th_tpf_vals[] = {
250         { 0x00, "Low Priority" },
251         { 0x01, "Medium Priority" },
252         { 0x10, "High Priority" },
253 };
254
255 /* VR_CWI */
256 static const value_string sna_th_vr_cwi_vals[] = {
257         { 0x0, "Increment window size" },
258         { 0x1, "Decrement window size" },
259 };
260
261 /* TG_NONFIFO_IND */
262 static const true_false_string sna_th_tg_nonfifo_ind_truth =
263         { "TG FIFO is not required", "TG FIFO is required" };
264
265 /* VR_SQTI */
266 static const value_string sna_th_vr_sqti_vals[] = {
267         { 0x00, "Non-sequenced, Non-supervisory" },
268         { 0x01, "Non-sequenced, Supervisory" },
269         { 0x10, "Singly-sequenced" },
270 };
271
272 /* VRPRQ */
273 static const true_false_string sna_th_vrprq_truth = {
274         "VR pacing request is sent asking for a VR pacing response",
275         "No VR pacing response is requested",
276 };
277
278 /* VRPRS */
279 static const true_false_string sna_th_vrprs_truth = {
280         "VR pacing response is sent in response to a VRPRQ bit set",
281         "No pacing response sent",
282 };
283
284 /* VR_CWRI */
285 static const value_string sna_th_vr_cwri_vals[] = {
286         { 0, "Increment window size by 1" },
287         { 1, "Decrement window size by 1" },
288 };
289
290 /* VR_RWI */
291 static const true_false_string sna_th_vr_rwi_truth = {
292         "Reset window size to the minimum specified in NC_ACTVR",
293         "Do not reset window size",
294 };
295
296 static int  dissect_fid0_1 (const u_char*, int, frame_data*, proto_tree*);
297 static int  dissect_fid2 (const u_char*, int, frame_data*, proto_tree*);
298 static int  dissect_fid3 (const u_char*, int, frame_data*, proto_tree*);
299 static int  dissect_fid4 (const u_char*, int, frame_data*, proto_tree*);
300 static int  dissect_fid5 (const u_char*, int, frame_data*, proto_tree*);
301 static int  dissect_fidf (const u_char*, int, frame_data*, proto_tree*);
302 static void dissect_rh (const u_char*, int, frame_data*, proto_tree*);
303
304 void
305 dissect_sna(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
306
307         proto_tree      *sna_tree = NULL, *th_tree = NULL, *rh_tree = NULL;
308         proto_item      *sna_ti = NULL, *th_ti = NULL, *rh_ti = NULL;
309         guint8          th_fid;
310         int             sna_header_len = 0, th_header_len = 0;
311
312         /* SNA data should be printed in EBCDIC, not ASCII */
313         fd->encoding = CHAR_EBCDIC;
314
315         if (IS_DATA_IN_FRAME(offset)) {
316                 /* Transmission Header Format Identifier */
317                 th_fid = hi_nibble(pd[offset]);
318         }
319         else {
320                 /* If our first byte isn't here, stop dissecting */
321                 return;
322         }
323
324         /* Summary information */
325         if (check_col(fd, COL_PROTOCOL))
326                 col_add_str(fd, COL_PROTOCOL, "SNA");
327         if (check_col(fd, COL_INFO))
328                 col_add_str(fd, COL_INFO, val_to_str(th_fid, sna_th_fid_vals, "Unknown FID: %01x"));
329
330         if (tree) {
331
332                 /* Don't bother setting length. We'll set it later after we find
333                  * the lengths of TH/RH/RU */
334                 sna_ti = proto_tree_add_item(tree, proto_sna, offset, 0, NULL);
335                 sna_tree = proto_item_add_subtree(sna_ti, ett_sna);
336
337                 /* --- TH --- */
338                 /* Don't bother setting length. We'll set it later after we find
339                  * the length of TH */
340                 th_ti = proto_tree_add_item(sna_tree, hf_sna_th,  offset, 0, NULL);
341                 th_tree = proto_item_add_subtree(th_ti, ett_sna_th);
342         }
343
344         /* Get size of TH */
345         switch(th_fid) {
346                 case 0x0:
347                 case 0x1:
348                         th_header_len = dissect_fid0_1(pd, offset, fd, th_tree);
349                         break;
350                 case 0x2:
351                         th_header_len = dissect_fid2(pd, offset, fd, th_tree);
352                         break;
353                 case 0x3:
354                         th_header_len = dissect_fid3(pd, offset, fd, th_tree);
355                         break;
356                 case 0x4:
357                         th_header_len = dissect_fid4(pd, offset, fd, th_tree);
358                         break;
359                 case 0x5:
360                         th_header_len = dissect_fid5(pd, offset, fd, th_tree);
361                         break;
362                 case 0xf:
363                         th_header_len = dissect_fidf(pd, offset, fd, th_tree);
364                         break;
365                 default:
366                         dissect_data(pd, offset+1, fd, tree);
367         }
368
369         sna_header_len += th_header_len;
370         offset += th_header_len;
371
372         if (tree) {
373                 proto_item_set_len(th_ti, th_header_len);
374
375                 /* --- RH --- */
376                 if (BYTES_ARE_IN_FRAME(offset, 3)) {
377                         rh_ti = proto_tree_add_item(sna_tree, hf_sna_rh, offset, 3, NULL);
378                         rh_tree = proto_item_add_subtree(rh_ti, ett_sna_rh);
379                         dissect_rh(pd, offset, fd, rh_tree);
380                         sna_header_len += 3;
381                         offset += 3;
382                 }
383                 else {
384                         /* If our first byte isn't here, stop dissecting */
385                         return;
386                 }
387
388                 proto_item_set_len(sna_ti, sna_header_len);
389         }
390         else {
391                 if (BYTES_ARE_IN_FRAME(offset, 3)) {
392                         sna_header_len += 3;
393                         offset += 3;
394                 }
395
396         }
397
398         if (IS_DATA_IN_FRAME(offset+1)) {
399                 dissect_data(pd, offset, fd, tree);
400         }
401 }
402
403 /* FID Types 0 and 1 */
404 static int
405 dissect_fid0_1 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
406
407         proto_tree      *bf_tree;
408         proto_item      *bf_item;
409         guint8          th_0;
410         guint16         daf, oaf, snf, dcf;
411
412         static int bytes_in_header = 10;
413
414         if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
415                 return 0;
416         }
417
418         th_0 = pd[offset+0];
419         daf = pntohs(&pd[offset+2]);
420         oaf = pntohs(&pd[offset+4]);
421         snf = pntohs(&pd[offset+6]);
422         dcf = pntohs(&pd[offset+8]);
423
424         SET_ADDRESS(&pi.net_src, AT_SNA, 2, &pd[offset+4]);
425         SET_ADDRESS(&pi.src, AT_SNA, 2, &pd[offset+4]);
426         SET_ADDRESS(&pi.net_dst, AT_SNA, 2, &pd[offset+2]);
427         SET_ADDRESS(&pi.dst, AT_SNA, 2, &pd[offset+2]);
428
429         if (!tree) {
430                 return bytes_in_header;
431         }
432
433         /* Create the bitfield tree */
434         bf_item = proto_tree_add_item(tree, hf_sna_th_0, offset, 1, th_0);
435         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
436
437         proto_tree_add_item(bf_tree, hf_sna_th_fid, offset, 1, th_0);
438         proto_tree_add_item(bf_tree, hf_sna_th_mpf, offset, 1, th_0);
439         proto_tree_add_item(bf_tree, hf_sna_th_efi ,offset, 1, th_0);
440
441         proto_tree_add_text(tree, offset+1, 1, "Reserved");
442         proto_tree_add_item(tree, hf_sna_th_daf ,offset+2, 1, daf);
443         proto_tree_add_item(tree, hf_sna_th_oaf ,offset+4, 1, oaf);
444         proto_tree_add_item(tree, hf_sna_th_snf ,offset+6, 2, snf);
445         proto_tree_add_item(tree, hf_sna_th_dcf ,offset+8, 2, dcf);
446
447         return bytes_in_header;
448
449 }
450
451
452 /* FID Type 2 */
453 static int
454 dissect_fid2 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
455
456         proto_tree      *bf_tree;
457         proto_item      *bf_item;
458         guint8          th_0, daf, oaf;
459         guint16         snf;
460
461         static int bytes_in_header = 6;
462
463         if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
464                 return 0;
465         }
466
467         th_0 = pd[offset+0];
468         daf = pd[offset+2];
469         oaf = pd[offset+3];
470
471         /* Addresses in FID 2 are FT_UINT8 */
472         SET_ADDRESS(&pi.net_src, AT_SNA, 1, &pd[offset+3]);
473         SET_ADDRESS(&pi.src, AT_SNA, 1, &pd[offset+3]);
474         SET_ADDRESS(&pi.net_dst, AT_SNA, 1, &pd[offset+2]);
475         SET_ADDRESS(&pi.dst, AT_SNA, 1, &pd[offset+2]);
476
477         if (!tree) {
478                 return bytes_in_header;
479         }
480
481         snf = pntohs(&pd[offset+4]);
482
483         /* Create the bitfield tree */
484         bf_item = proto_tree_add_item(tree, hf_sna_th_0, offset, 1, th_0);
485         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
486
487         proto_tree_add_item(bf_tree, hf_sna_th_fid, offset, 1, th_0);
488         proto_tree_add_item(bf_tree, hf_sna_th_mpf, offset, 1, th_0);
489         proto_tree_add_item(bf_tree, hf_sna_th_odai ,offset, 1, th_0);
490         proto_tree_add_item(bf_tree, hf_sna_th_efi ,offset, 1, th_0);
491
492         /* Addresses in FID 2 are FT_UINT8 */
493         proto_tree_add_text(tree, offset+1, 1, "Reserved");
494         proto_tree_add_item_format(tree, hf_sna_th_daf ,offset+2, 1, daf,
495                         "Destination Address Field: 0x%02x", daf);
496         proto_tree_add_item_format(tree, hf_sna_th_oaf ,offset+3, 1, oaf,
497                         "Origin Address Field: 0x%02x", oaf);
498         proto_tree_add_item(tree, hf_sna_th_snf ,offset+4, 2, snf);
499
500         return bytes_in_header;
501 }
502
503 /* FID Type 3 */
504 static int
505 dissect_fid3 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
506
507         proto_tree      *bf_tree;
508         proto_item      *bf_item;
509         guint8          th_0;
510         guint8          lsid;
511
512         static int bytes_in_header = 2;
513
514         if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
515                 return 0;
516         }
517
518         if (!tree) {
519                 return bytes_in_header;
520         }
521
522         th_0 = pd[offset+0];
523         lsid = pd[offset+1];
524
525         /* Create the bitfield tree */
526         bf_item = proto_tree_add_item(tree, hf_sna_th_0, offset, 1, th_0);
527         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
528
529         proto_tree_add_item(bf_tree, hf_sna_th_fid, offset, 1, th_0);
530         proto_tree_add_item(bf_tree, hf_sna_th_mpf, offset, 1, th_0);
531         proto_tree_add_item(bf_tree, hf_sna_th_efi ,offset, 1, th_0);
532
533         proto_tree_add_item(tree, hf_sna_th_lsid ,offset+1, 1, lsid);
534
535         return bytes_in_header;
536 }
537
538 /* FID Type 4 */
539
540 gchar *
541 sna_fid_type_4_addr_to_str(const struct sna_fid_type_4_addr *addrp)
542 {
543   static gchar  str[3][14];
544   static gchar  *cur;
545
546   if (cur == &str[0][0]) {
547     cur = &str[1][0];
548   } else if (cur == &str[1][0]) {
549     cur = &str[2][0];
550   } else {
551     cur = &str[0][0];
552   }
553
554   sprintf(cur, "%08X.%04X", addrp->saf, addrp->ef);
555   return cur;
556 }
557
558 static int
559 dissect_fid4 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
560
561         proto_tree      *bf_tree;
562         proto_item      *bf_item;
563         guint8          th_byte, mft;
564         guint16         th_word;
565         guint16         def, oef, snf, dcf;
566         guint32         dsaf, osaf;
567         static struct sna_fid_type_4_addr src, dst;
568
569         static int bytes_in_header = 26;
570
571         if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
572                 return 0;
573         }
574
575         dsaf = pntohl(&pd[offset+8]);
576         osaf = pntohl(&pd[offset+12]);
577         def = pntohs(&pd[offset+18]);
578         oef = pntohs(&pd[offset+20]);
579         snf = pntohs(&pd[offset+22]);
580         dcf = pntohs(&pd[offset+24]);
581
582         /* Addresses in FID 4 are discontiguous, sigh */
583         src.saf = osaf;
584         src.ef = oef;
585         dst.saf = dsaf;
586         dst.ef = def;
587         SET_ADDRESS(&pi.net_src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
588             (guint8 *)&src);
589         SET_ADDRESS(&pi.src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
590             (guint8 *)&src);
591         SET_ADDRESS(&pi.net_dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
592             (guint8 *)&dst);
593         SET_ADDRESS(&pi.dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
594             (guint8 *)&dst);
595
596         if (!tree) {
597                 return bytes_in_header;
598         }
599
600         th_byte = pd[offset];
601
602         /* Create the bitfield tree */
603         bf_item = proto_tree_add_item(tree, hf_sna_th_0, offset, 1, th_byte);
604         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
605
606         /* Byte 0 */
607         proto_tree_add_item(bf_tree, hf_sna_th_fid, offset, 1, th_byte);
608         proto_tree_add_item(bf_tree, hf_sna_th_tg_sweep, offset, 1, th_byte);
609         proto_tree_add_item(bf_tree, hf_sna_th_er_vr_supp_ind, offset, 1, th_byte);
610         proto_tree_add_item(bf_tree, hf_sna_th_vr_pac_cnt_ind, offset, 1, th_byte);
611         proto_tree_add_item(bf_tree, hf_sna_th_ntwk_prty, offset, 1, th_byte);
612
613         offset += 1;
614         th_byte = pd[offset];
615
616         /* Create the bitfield tree */
617         bf_item = proto_tree_add_text(tree, offset, 1, "Transmision Header Byte 1");
618         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
619
620         /* Byte 1 */
621         proto_tree_add_item(bf_tree, hf_sna_th_tgsf, offset, 1, th_byte);
622         proto_tree_add_item(bf_tree, hf_sna_th_mft, offset, 1, th_byte);
623         proto_tree_add_item(bf_tree, hf_sna_th_piubf, offset, 1, th_byte);
624
625         mft = th_byte & 0x04;
626         offset += 1;
627         th_byte = pd[offset];
628
629         /* Create the bitfield tree */
630         bf_item = proto_tree_add_text(tree, offset, 1, "Transmision Header Byte 2");
631         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
632
633         /* Byte 2 */
634         if (mft) {
635                 proto_tree_add_item(bf_tree, hf_sna_th_nlpoi, offset, 1, th_byte);
636                 proto_tree_add_item(bf_tree, hf_sna_th_nlp_cp, offset, 1, th_byte);
637         }
638         else {
639                 proto_tree_add_item(bf_tree, hf_sna_th_iern, offset, 1, th_byte);
640         }
641         proto_tree_add_item(bf_tree, hf_sna_th_ern, offset, 1, th_byte);
642
643         offset += 1;
644         th_byte = pd[offset];
645
646         /* Create the bitfield tree */
647         bf_item = proto_tree_add_text(tree, offset, 1, "Transmision Header Byte 3");
648         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
649
650         /* Byte 3 */
651         proto_tree_add_item(bf_tree, hf_sna_th_vrn, offset, 1, th_byte);
652         proto_tree_add_item(bf_tree, hf_sna_th_tpf, offset, 1, th_byte);
653
654         offset += 1;
655         th_word = pntohs(&pd[offset]);
656
657         /* Create the bitfield tree */
658         bf_item = proto_tree_add_text(tree, offset, 2, "Transmision Header Bytes 4-5");
659         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
660
661         /* Bytes 4-5 */
662         proto_tree_add_item(bf_tree, hf_sna_th_vr_cwi, offset, 2, th_word);
663         proto_tree_add_item(bf_tree, hf_sna_th_tg_nonfifo_ind, offset, 2, th_word);
664         proto_tree_add_item(bf_tree, hf_sna_th_vr_sqti, offset, 2, th_word);
665
666         /* I'm not sure about byte-order on this one... */
667         proto_tree_add_item(bf_tree, hf_sna_th_tg_snf, offset, 2, th_word);
668
669         offset += 2;
670         th_word = pntohs(&pd[offset]);
671
672         /* Create the bitfield tree */
673         bf_item = proto_tree_add_text(tree, offset, 2, "Transmision Header Bytes 6-7");
674         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
675
676         /* Bytes 6-7 */
677         proto_tree_add_item(bf_tree, hf_sna_th_vrprq, offset, 2, th_word);
678         proto_tree_add_item(bf_tree, hf_sna_th_vrprs, offset, 2, th_word);
679         proto_tree_add_item(bf_tree, hf_sna_th_vr_cwri, offset, 2, th_word);
680         proto_tree_add_item(bf_tree, hf_sna_th_vr_rwi, offset, 2, th_word);
681
682         /* I'm not sure about byte-order on this one... */
683         proto_tree_add_item(bf_tree, hf_sna_th_vr_snf_send, offset, 2, th_word);
684
685         offset += 2;
686
687         /* Bytes 8-11 */
688         proto_tree_add_item(tree, hf_sna_th_dsaf, offset, 4, dsaf);
689
690         offset += 4;
691
692         /* Bytes 12-15 */
693         proto_tree_add_item(tree, hf_sna_th_osaf, offset, 4, osaf);
694
695         offset += 4;
696         th_byte = pd[offset];
697
698         /* Create the bitfield tree */
699         bf_item = proto_tree_add_text(tree, offset, 2, "Transmision Header Byte 16");
700         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
701
702         /* Byte 16 */
703         proto_tree_add_item(tree, hf_sna_th_snai, offset, 1, th_byte);
704
705         /* We luck out here because in their infinite wisdom the SNA
706          * architects placed the MPF and EFI fields in the same bitfield
707          * locations, even though for FID4 they're not in byte 0.
708          * Thank you IBM! */
709         proto_tree_add_item(tree, hf_sna_th_mpf, offset, 1, th_byte);
710         proto_tree_add_item(tree, hf_sna_th_efi, offset, 1, th_byte);
711
712         offset += 2; /* 1 for byte 16, 1 for byte 17 which is reserved */
713
714         /* Bytes 18-25 */
715         proto_tree_add_item(tree, hf_sna_th_def, offset+0, 2, def);
716         proto_tree_add_item(tree, hf_sna_th_oef, offset+2, 2, oef);
717         proto_tree_add_item(tree, hf_sna_th_snf, offset+4, 2, snf);
718         proto_tree_add_item(tree, hf_sna_th_snf, offset+6, 2, dcf);
719
720         return bytes_in_header;
721 }
722
723 /* FID Type 5 */
724 static int
725 dissect_fid5 (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
726
727         proto_tree      *bf_tree;
728         proto_item      *bf_item;
729         guint8          th_0;
730         guint16         snf;
731
732         static int bytes_in_header = 12;
733
734         if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
735                 return 0;
736         }
737
738         th_0 = pd[offset+0];
739         snf = pntohs(&pd[offset+2]);
740
741         if (!tree) {
742                 return bytes_in_header;
743         }
744
745         /* Create the bitfield tree */
746         bf_item = proto_tree_add_item(tree, hf_sna_th_0, offset, 1, th_0);
747         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
748
749         proto_tree_add_item(bf_tree, hf_sna_th_fid, offset, 1, th_0);
750         proto_tree_add_item(bf_tree, hf_sna_th_mpf, offset, 1, th_0);
751         proto_tree_add_item(bf_tree, hf_sna_th_efi, offset, 1, th_0);
752
753         proto_tree_add_text(tree, offset+1, 1, "Reserved");
754         proto_tree_add_item(tree, hf_sna_th_snf, offset+2, 2, snf);
755
756         proto_tree_add_item(tree, hf_sna_th_sa, offset+4, 8, &pd[offset+4]);
757
758         return bytes_in_header;
759
760 }
761
762 /* FID Type f */
763 static int
764 dissect_fidf (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
765
766         proto_tree      *bf_tree;
767         proto_item      *bf_item;
768         guint8          th_0, cmd_fmt, cmd_type;
769         guint16         cmd_sn, dcf;
770         
771         static int bytes_in_header = 26;
772
773         if (!BYTES_ARE_IN_FRAME(offset, bytes_in_header)) {
774                 return 0;
775         }
776
777         th_0 = pd[offset+0];
778         cmd_fmt = pd[offset+2];
779         cmd_type = pd[offset+3];
780         cmd_sn = pntohs(&pd[offset+4]);
781
782         /* Yup, bytes 6-23 are reserved! */
783         dcf = pntohs(&pd[offset+24]);
784
785         if (!tree) {
786                 return bytes_in_header;
787         }
788
789         /* Create the bitfield tree */
790         bf_item = proto_tree_add_item(tree, hf_sna_th_0, offset, 1, th_0);
791         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
792
793         proto_tree_add_item(bf_tree, hf_sna_th_fid, offset, 1, th_0);
794         proto_tree_add_text(tree, offset+1, 1, "Reserved");
795
796         proto_tree_add_item(tree, hf_sna_th_cmd_fmt,  offset+2, 1, cmd_fmt);
797         proto_tree_add_item(tree, hf_sna_th_cmd_type, offset+3, 1, cmd_type);
798         proto_tree_add_item(tree, hf_sna_th_cmd_sn,   offset+4, 2, cmd_sn);
799
800         proto_tree_add_text(tree, offset+6, 18, "Reserved");
801
802         proto_tree_add_item(tree, hf_sna_th_dcf, offset+24, 8, dcf);
803
804         return bytes_in_header;
805 }
806
807
808 /* RH */
809 static void
810 dissect_rh (const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
811
812         proto_tree      *bf_tree;
813         proto_item      *bf_item;
814         gboolean        is_response;
815         guint8          rh_0, rh_1, rh_2;
816
817         rh_0 = pd[offset+0];
818         rh_1 = pd[offset+1];
819         rh_2 = pd[offset+2];
820
821         is_response = (rh_0 & 0x80);
822
823         /* Create the bitfield tree for byte 0*/
824         bf_item = proto_tree_add_item(tree, hf_sna_rh_0, offset, 1, rh_0);
825         bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_0);
826
827         proto_tree_add_item(bf_tree, hf_sna_rh_rri, offset, 1, rh_0);
828         proto_tree_add_item(bf_tree, hf_sna_rh_ru_category, offset, 1, rh_0);
829         proto_tree_add_item(bf_tree, hf_sna_rh_fi, offset, 1, rh_0);
830         proto_tree_add_item(bf_tree, hf_sna_rh_sdi, offset, 1, rh_0);
831         proto_tree_add_item(bf_tree, hf_sna_rh_bci, offset, 1, rh_0);
832         proto_tree_add_item(bf_tree, hf_sna_rh_eci, offset, 1, rh_0);
833
834         offset += 1;
835
836         /* Create the bitfield tree for byte 1*/
837         bf_item = proto_tree_add_item(tree, hf_sna_rh_1, offset, 1, rh_1);
838         bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_1);
839
840         proto_tree_add_item(bf_tree, hf_sna_rh_dr1,  offset, 1, rh_1);
841
842         if (!is_response) {
843                 proto_tree_add_item(bf_tree, hf_sna_rh_lcci, offset, 1, rh_1);
844         }
845
846         proto_tree_add_item(bf_tree, hf_sna_rh_dr2,  offset, 1, rh_1);
847
848         if (is_response) {
849                 proto_tree_add_item(bf_tree, hf_sna_rh_rti,  offset, 1, rh_1);
850         }
851         else {
852                 proto_tree_add_item(bf_tree, hf_sna_rh_eri,  offset, 1, rh_1);
853                 proto_tree_add_item(bf_tree, hf_sna_rh_rlwi, offset, 1, rh_1);
854         }
855
856         proto_tree_add_item(bf_tree, hf_sna_rh_qri, offset, 1, rh_1);
857         proto_tree_add_item(bf_tree, hf_sna_rh_pi,  offset, 1, rh_1);
858
859         offset += 1;
860
861         /* Create the bitfield tree for byte 2*/
862         bf_item = proto_tree_add_item(tree, hf_sna_rh_2, offset, 1, rh_2);
863
864         if (!is_response) {
865                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_2);
866
867                 proto_tree_add_item(bf_tree, hf_sna_rh_bbi,  offset, 1, rh_2);
868                 proto_tree_add_item(bf_tree, hf_sna_rh_ebi,  offset, 1, rh_2);
869                 proto_tree_add_item(bf_tree, hf_sna_rh_cdi,  offset, 1, rh_2);
870                 proto_tree_add_item(bf_tree, hf_sna_rh_csi,  offset, 1, rh_2);
871                 proto_tree_add_item(bf_tree, hf_sna_rh_edi,  offset, 1, rh_2);
872                 proto_tree_add_item(bf_tree, hf_sna_rh_pdi,  offset, 1, rh_2);
873                 proto_tree_add_item(bf_tree, hf_sna_rh_cebi, offset, 1, rh_2);
874         }
875
876         /* XXX - check for sdi. If TRUE, the next 4 bytes will be sense data */
877 }
878
879 void
880 proto_register_sna(void)
881 {
882         static hf_register_info hf[] = {
883                 { &hf_sna_th,
884                 { "Transmission Header",        "sna.th", FT_NONE, BASE_NONE, NULL, 0x0,
885                         "" }},
886
887                 { &hf_sna_th_0,
888                 { "Transmission Header Byte 0", "sna.th.0", FT_UINT8, BASE_HEX, NULL, 0x0,
889                         "Byte 0 of Tranmission Header contains FID, MPF, ODAI,"
890                         " and EFI as bitfields." }},
891
892                 { &hf_sna_th_fid,
893                 { "Format Identifer",           "sna.th.fid", FT_UINT8, BASE_HEX, VALS(sna_th_fid_vals), 0xf0,
894                         "Format Identification" }},
895
896                 { &hf_sna_th_mpf,
897                 { "Mapping Field",              "sna.th.mpf", FT_UINT8, BASE_NONE, VALS(sna_th_mpf_vals), 0x0c,
898                         "The Mapping Field specifies whether the information field"
899                         " associated with the TH is a complete or partial BIU." }},
900
901                 { &hf_sna_th_odai,
902                 { "ODAI Assignment Indicator",  "sna.th.odai", FT_UINT8, BASE_DEC, NULL, 0x02,
903                         "The ODAI indicates which node assigned the OAF'-DAF' values"
904                         " carried in the TH." }},
905
906                 { &hf_sna_th_efi,
907                 { "Expedited Flow Indicator",   "sna.th.efi", FT_UINT8, BASE_DEC, VALS(sna_th_efi_vals), 0x01,
908                         "The EFI designates whether the PIU belongs to the normal"
909                         " or expedited flow." }},
910
911                 { &hf_sna_th_daf,
912                 { "Destination Address Field",  "sna.th.daf", FT_UINT16, BASE_HEX, NULL, 0x0,
913                         "" }},
914
915                 { &hf_sna_th_oaf,
916                 { "Origin Address Field",       "sna.th.oaf", FT_UINT16, BASE_HEX, NULL, 0x0,
917                         "" }},
918
919                 { &hf_sna_th_snf,
920                 { "Sequence Number Field",      "sna.th.snf", FT_UINT16, BASE_NONE, NULL, 0x0,
921                         "The Sequence Number Field contains a numerical identifier for"
922                         " the associated BIU."}},
923
924                 { &hf_sna_th_dcf,
925                 { "Data Count Field",   "sna.th.dcf", FT_UINT16, BASE_DEC, NULL, 0x0,
926                         "A binary count of the number of bytes in the BIU or BIU segment associated "
927                         "with the tranmission header. The count does not include any of the bytes "
928                         "in the transmission header."}},
929
930                 { &hf_sna_th_lsid,
931                 { "Local Session Identification",       "sna.th.lsid", FT_UINT8, BASE_HEX, NULL, 0x0,
932                         "" }},
933
934                 { &hf_sna_th_tg_sweep,
935                 { "Transmission Group Sweep",           "sna.th.tg_sweep", FT_UINT8, BASE_DEC,
936                         VALS(sna_th_tg_sweep_vals), 0x08,
937                         "" }},
938
939                 { &hf_sna_th_er_vr_supp_ind,
940                 { "ER and VR Support Indicator",        "sna.th.er_vr_supp_ind", FT_UINT8, BASE_DEC,
941                         VALS(sna_th_er_vr_supp_ind_vals), 0x04,
942                         "" }},
943
944                 { &hf_sna_th_vr_pac_cnt_ind,
945                 { "Virtual Route Pacing Count Indicator",       "sna.th.vr_pac_cnt_ind",
946                         FT_UINT8, BASE_DEC, VALS(sna_th_vr_pac_cnt_ind_vals), 0x02,
947                         "" }},
948
949                 { &hf_sna_th_ntwk_prty,
950                 { "Network Priority",   "sna.th.ntwk_prty",
951                         FT_UINT8, BASE_DEC, VALS(sna_th_ntwk_prty_vals), 0x01,
952                         "" }},
953
954                 { &hf_sna_th_tgsf,
955                 { "Transmission Group Segmenting Field",        "sna.th.tgsf",
956                         FT_UINT8, BASE_HEX, VALS(sna_th_tgsf_vals), 0xc0,
957                         "" }},
958
959                 { &hf_sna_th_mft,
960                 { "MPR FID4 Type",      "sna.th.mft", FT_BOOLEAN, BASE_NONE, NULL, 0x04,
961                         "" }},
962
963                 { &hf_sna_th_piubf,
964                 { "PIU Blocking Field", "sna.th.piubf", FT_UINT8, BASE_HEX,
965                         VALS(sna_th_piubf_vals), 0x03,
966                         "Specifies whether this frame contains a single PIU or multiple PIUs." }},
967
968                 { &hf_sna_th_iern,
969                 { "Initial Explicit Route Number",      "sna.th.iern", FT_UINT8, BASE_DEC, NULL, 0xf0,
970                         "" }},
971
972                 { &hf_sna_th_nlpoi,
973                 { "NLP Offset Indicator",       "sna.th.nlpoi", FT_UINT8, BASE_DEC,
974                         VALS(sna_th_nlpoi_vals), 0x80,
975                         "" }},
976
977                 { &hf_sna_th_nlp_cp,
978                 { "NLP Count or Padding",       "sna.th.nlp_cp", FT_UINT8, BASE_DEC, NULL, 0x70,
979                         "" }},
980
981                 { &hf_sna_th_ern,
982                 { "Explicit Route Number",      "sna.th.ern", FT_UINT8, BASE_DEC, NULL, 0x0f,
983                         "The ERN in a TH identifies an explicit route direction of flow." }},
984
985                 { &hf_sna_th_vrn,
986                 { "Virtual Route Number",       "sna.th.vrn", FT_UINT8, BASE_DEC, NULL, 0xf0,
987                         "" }},
988
989                 { &hf_sna_th_tpf,
990                 { "Transmission Priority Field",        "sna.th.tpf", FT_UINT8, BASE_HEX,
991                         VALS(sna_th_tpf_vals), 0x03,
992                         "" }},
993
994                 { &hf_sna_th_vr_cwi,
995                 { "Virtual Route Change Window Indicator",      "sna.th.vr_cwi", FT_UINT16, BASE_DEC,
996                         VALS(sna_th_vr_cwi_vals), 0x8000,
997                         "Used to change the window size of the virtual route by 1." }},
998
999                 { &hf_sna_th_tg_nonfifo_ind,
1000                 { "Transmission Group Non-FIFO Indicator",      "sna.th.tg_nonfifo_ind", FT_BOOLEAN, 16,
1001                         TFS(&sna_th_tg_nonfifo_ind_truth), 0x4000,
1002                         "Indicates whether or not FIFO discipline is to enforced in "
1003                         "transmitting PIUs through the tranmission groups to prevent the PIUs "
1004                         "getting out of sequence during transmission over the TGs." }},
1005
1006                 { &hf_sna_th_vr_sqti,
1007                 { "Virtual Route Sequence and Type Indicator",  "sna.th.vr_sqti", FT_UINT16, BASE_HEX,
1008                         VALS(sna_th_vr_sqti_vals), 0x3000,
1009                         "Specifies the PIU type." }},
1010
1011                 { &hf_sna_th_tg_snf,
1012                 { "Transmission Group Sequence Number Field",   "sna.th.tg_snf", FT_UINT16, BASE_DEC,
1013                         NULL, 0x0fff,
1014                         "" }},
1015
1016                 { &hf_sna_th_vrprq,
1017                 { "Virtual Route Pacing Request",       "sna.th.vrprq", FT_BOOLEAN, 16,
1018                         TFS(&sna_th_vrprq_truth), 0x8000,
1019                         "" }},
1020
1021                 { &hf_sna_th_vrprs,
1022                 { "Virtual Route Pacing Response",      "sna.th.vrprs", FT_BOOLEAN, 16,
1023                         TFS(&sna_th_vrprs_truth), 0x4000,
1024                         "" }},
1025
1026                 { &hf_sna_th_vr_cwri,
1027                 { "Virtual Route Change Window Reply Indicator",        "sna.th.vr_cwri", FT_UINT16, BASE_DEC,
1028                         VALS(sna_th_vr_cwri_vals), 0x2000,
1029                         "Permits changing of the window size by 1 for PIUs received by the "
1030                         "sender of this bit." }},
1031
1032                 { &hf_sna_th_vr_rwi,
1033                 { "Virtual Route Reset Window Indicator",       "sna.th.vr_rwi", FT_BOOLEAN, 16,
1034                         TFS(&sna_th_vr_rwi_truth), 0x1000,
1035                         "Indicates severe congestion in a node on the virtual route." }},
1036
1037                 { &hf_sna_th_vr_snf_send,
1038                 { "Virtual Route Send Sequence Number Field",   "sna.th.vr_snf_send", FT_UINT16, BASE_DEC,
1039                         NULL, 0x0fff,
1040                         "" }},
1041
1042                 { &hf_sna_th_dsaf,
1043                 { "Destination Subarea Address Field",  "sna.th.dsaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1044                         "" }},
1045
1046                 { &hf_sna_th_osaf,
1047                 { "Origin Subarea Address Field",       "sna.th.osaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1048                         "" }},
1049
1050                 { &hf_sna_th_snai,
1051                 { "SNA Indicator",      "sna.th.snai", FT_BOOLEAN, 8, NULL, 0x10,
1052                         "Used to identify whether the PIU originated or is destined for "
1053                         "an SNA or non-SNA device." }},
1054
1055                 { &hf_sna_th_def,
1056                 { "Destination Element Field",  "sna.th.def", FT_UINT16, BASE_HEX, NULL, 0x0,
1057                         "" }},
1058
1059                 { &hf_sna_th_oef,
1060                 { "Origin Element Field",       "sna.th.oef", FT_UINT16, BASE_HEX, NULL, 0x0,
1061                         "" }},
1062
1063                 { &hf_sna_th_sa,
1064                 { "Session Address",    "sna.th.sa", FT_BYTES, BASE_HEX, NULL, 0x0,
1065                         "" }},
1066
1067                 { &hf_sna_th_cmd_fmt,
1068                 { "Command Format",     "sna.th.cmd_fmt", FT_UINT8, BASE_HEX, NULL, 0x0,
1069                         "" }},
1070
1071                 { &hf_sna_th_cmd_type,
1072                 { "Command Type",       "sna.th.cmd_type", FT_UINT8, BASE_HEX, NULL, 0x0,
1073                         "" }},
1074
1075                 { &hf_sna_th_cmd_sn,
1076                 { "Command Sequence Number",    "sna.th.cmd_sn", FT_UINT16, BASE_DEC, NULL, 0x0,
1077                         "" }},
1078
1079
1080                 { &hf_sna_rh,
1081                 { "Request/Response Header",    "sna.rh", FT_NONE, BASE_NONE, NULL, 0x0,
1082                         "" }},
1083
1084                 { &hf_sna_rh_0,
1085                 { "Request/Response Header Byte 0",     "sna.rh.0", FT_UINT8, BASE_HEX, NULL, 0x0,
1086                         "" }},
1087
1088                 { &hf_sna_rh_1,
1089                 { "Request/Response Header Byte 1",     "sna.rh.1", FT_UINT8, BASE_HEX, NULL, 0x0,
1090                         "" }},
1091
1092                 { &hf_sna_rh_2,
1093                 { "Request/Response Header Byte 2",     "sna.rh.2", FT_UINT8, BASE_HEX, NULL, 0x0,
1094                         "" }},
1095
1096                 { &hf_sna_rh_rri,
1097                 { "Request/Response Indicator", "sna.rh.rri", FT_UINT8, BASE_DEC, VALS(sna_rh_rri_vals), 0x80,
1098                         "Denotes whether this is a request or a response." }},
1099
1100                 { &hf_sna_rh_ru_category,
1101                 { "Request/Response Unit Category",     "sna.rh.ru_category", FT_UINT8, BASE_HEX,
1102                         VALS(sna_rh_ru_category_vals), 0x60,
1103                         "" }},
1104
1105                 { &hf_sna_rh_fi,
1106                 { "Format Indicator",           "sna.rh.fi", FT_BOOLEAN, 8, TFS(&sna_rh_fi_truth), 0x08,
1107                         "" }},
1108
1109                 { &hf_sna_rh_sdi,
1110                 { "Sense Data Included",        "sna.rh.sdi", FT_BOOLEAN, 8, TFS(&sna_rh_sdi_truth), 0x04,
1111                         "Indicates that a 4-byte sense data field is included in the associated RU." }},
1112
1113                 { &hf_sna_rh_bci,
1114                 { "Begin Chain Indicator",      "sna.rh.bci", FT_BOOLEAN, 8, TFS(&sna_rh_bci_truth), 0x02,
1115                         "" }},
1116
1117                 { &hf_sna_rh_eci,
1118                 { "End Chain Indicator",        "sna.rh.eci", FT_BOOLEAN, 8, TFS(&sna_rh_eci_truth), 0x01,
1119                         "" }},
1120
1121                 { &hf_sna_rh_dr1,
1122                 { "Definite Response 1 Indicator",      "sna.rh.dr1", FT_BOOLEAN, 8, NULL, 0x80,
1123                         "" }},
1124
1125                 { &hf_sna_rh_lcci,
1126                 { "Length-Checked Compression Indicator",       "sna.rh.lcci", FT_BOOLEAN, 8,
1127                         TFS(&sna_rh_lcci_truth), 0x40,
1128                         "" }},
1129
1130                 { &hf_sna_rh_dr2,
1131                 { "Definite Response 2 Indicator",      "sna.rh.dr2", FT_BOOLEAN, 8, NULL, 0x20,
1132                         "" }},
1133
1134                 { &hf_sna_rh_eri,
1135                 { "Exception Response Indicator",       "sna.rh.eri", FT_BOOLEAN, 8, NULL, 0x10,
1136                         "Used in conjunction with DR1I and DR2I to indicate, in a request, "
1137                         "the form of response requested." }},
1138
1139                 { &hf_sna_rh_rti,
1140                 { "Response Type Indicator",    "sna.rh.rti", FT_BOOLEAN, 8, TFS(&sna_rh_rti_truth), 0x10,
1141                         "" }},
1142
1143                 { &hf_sna_rh_rlwi,
1144                 { "Request Larger Window Indicator",    "sna.rh.rlwi", FT_BOOLEAN, 8, NULL, 0x04,
1145                         "Indicates whether a larger pacing window was requested." }},
1146
1147                 { &hf_sna_rh_qri,
1148                 { "Queued Response Indicator",  "sna.rh.qri", FT_BOOLEAN, 8, TFS(&sna_rh_qri_truth), 0x02,
1149                         "" }},
1150
1151                 { &hf_sna_rh_pi,
1152                 { "Pacing Indicator",   "sna.rh.pi", FT_BOOLEAN, 8, NULL, 0x01,
1153                         "" }},
1154
1155                 { &hf_sna_rh_bbi,
1156                 { "Begin Bracket Indicator",    "sna.rh.bbi", FT_BOOLEAN, 8, NULL, 0x80,
1157                         "" }},
1158
1159                 { &hf_sna_rh_ebi,
1160                 { "End Bracket Indicator",      "sna.rh.ebi", FT_BOOLEAN, 8, NULL, 0x40,
1161                         "" }},
1162
1163                 { &hf_sna_rh_cdi,
1164                 { "Change Direction Indicator", "sna.rh.cdi", FT_BOOLEAN, 8, NULL, 0x20,
1165                         "" }},
1166
1167                 { &hf_sna_rh_csi,
1168                 { "Code Selection Indicator",   "sna.rh.csi", FT_BOOLEAN, 8, VALS(sna_rh_csi_vals), 0x08,
1169                         "Specifies the encoding used for the associated FMD RU." }},
1170
1171                 { &hf_sna_rh_edi,
1172                 { "Enciphered Data Indicator",  "sna.rh.edi", FT_BOOLEAN, 8, NULL, 0x04,
1173                         "Indicates that information in the associated RU is enciphered under "
1174                         "session-level cryptography protocols." }},
1175
1176                 { &hf_sna_rh_pdi,
1177                 { "Padded Data Indicator",      "sna.rh.pdi", FT_BOOLEAN, 8, NULL, 0x02,
1178                         "Indicates that the RU was padded at the end, before encipherment, to the next "
1179                         "integral multiple of 8 bytes." }},
1180
1181                 { &hf_sna_rh_cebi,
1182                 { "Conditional End Bracket Indicator",  "sna.rh.cebi", FT_BOOLEAN, 8, NULL, 0x01,
1183                         "Used to indicate the beginning or end of a group of exchanged "
1184                         "requests and responses called a bracket. Only used on LU-LU sessions." }},
1185
1186                 { &hf_sna_ru,
1187                 { "Request/Response Unit",      "sna.ru", FT_NONE, BASE_NONE, NULL, 0x0,
1188                         ""}},
1189         };
1190         static gint *ett[] = {
1191                 &ett_sna,
1192                 &ett_sna_th,
1193                 &ett_sna_th_fid,
1194                 &ett_sna_rh,
1195                 &ett_sna_rh_0,
1196                 &ett_sna_rh_1,
1197                 &ett_sna_rh_2,
1198         };
1199
1200         proto_sna = proto_register_protocol("Systems Network Architecture", "sna");
1201         proto_register_field_array(proto_sna, hf, array_length(hf));
1202         proto_register_subtree_array(ett, array_length(ett));
1203 }