Add gtk2/glib2 handling to configure. Use --enable-gtk2 to use
[obnox/wireshark/wip.git] / packet-sna.c
1 /* packet-sna.c
2  * Routines for SNA
3  * Gilbert Ramirez <gram@alumni.rice.edu>
4  *
5  * $Id: packet-sna.c,v 1.41 2002/08/02 23:36:02 jmayer Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
9  * Copyright 1998 Gerald Combs
10  * 
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.
15  * 
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.
20  * 
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.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include <glib.h>
31 #include <epan/packet.h>
32 #include "llcsaps.h"
33 #include "ppptypes.h"
34 #include <epan/sna-utils.h>
35
36 /*
37  * http://www.wanresources.com/snacell.html
38  * ftp://ftp.software.ibm.com/networking/pub/standards/aiw/formats/
39  *
40  */
41
42 static int proto_sna = -1;
43 static int hf_sna_th = -1;
44 static int hf_sna_th_0 = -1;
45 static int hf_sna_th_fid = -1;
46 static int hf_sna_th_mpf = -1;
47 static int hf_sna_th_odai = -1;
48 static int hf_sna_th_efi = -1;
49 static int hf_sna_th_daf = -1;
50 static int hf_sna_th_oaf = -1;
51 static int hf_sna_th_snf = -1;
52 static int hf_sna_th_dcf = -1;
53 static int hf_sna_th_lsid = -1;
54 static int hf_sna_th_tg_sweep = -1;
55 static int hf_sna_th_er_vr_supp_ind = -1;
56 static int hf_sna_th_vr_pac_cnt_ind = -1;
57 static int hf_sna_th_ntwk_prty = -1;
58 static int hf_sna_th_tgsf = -1;
59 static int hf_sna_th_mft = -1;
60 static int hf_sna_th_piubf = -1;
61 static int hf_sna_th_iern = -1;
62 static int hf_sna_th_nlpoi = -1;
63 static int hf_sna_th_nlp_cp = -1;
64 static int hf_sna_th_ern = -1;
65 static int hf_sna_th_vrn = -1;
66 static int hf_sna_th_tpf = -1;
67 static int hf_sna_th_vr_cwi = -1;
68 static int hf_sna_th_tg_nonfifo_ind = -1;
69 static int hf_sna_th_vr_sqti = -1;
70 static int hf_sna_th_tg_snf = -1;
71 static int hf_sna_th_vrprq = -1;
72 static int hf_sna_th_vrprs = -1;
73 static int hf_sna_th_vr_cwri = -1;
74 static int hf_sna_th_vr_rwi = -1;
75 static int hf_sna_th_vr_snf_send = -1;
76 static int hf_sna_th_dsaf = -1;
77 static int hf_sna_th_osaf = -1;
78 static int hf_sna_th_snai = -1;
79 static int hf_sna_th_def = -1;
80 static int hf_sna_th_oef = -1;
81 static int hf_sna_th_sa = -1;
82 static int hf_sna_th_cmd_fmt = -1;
83 static int hf_sna_th_cmd_type = -1;
84 static int hf_sna_th_cmd_sn = -1;
85
86 static int hf_sna_nlp_nhdr = -1;
87 static int hf_sna_nlp_nhdr_0 = -1;
88 static int hf_sna_nlp_sm = -1;
89 static int hf_sna_nlp_tpf = -1;
90 static int hf_sna_nlp_nhdr_1 = -1;
91 static int hf_sna_nlp_ft = -1;
92 static int hf_sna_nlp_tspi = -1;
93 static int hf_sna_nlp_slowdn1 = -1;
94 static int hf_sna_nlp_slowdn2 = -1;
95 static int hf_sna_nlp_fra = -1;
96 static int hf_sna_nlp_anr = -1;
97 static int hf_sna_nlp_frh = -1;
98 static int hf_sna_nlp_thdr = -1;
99 static int hf_sna_nlp_tcid = -1;
100 static int hf_sna_nlp_thdr_8 = -1;
101 static int hf_sna_nlp_setupi = -1;
102 static int hf_sna_nlp_somi = -1;
103 static int hf_sna_nlp_eomi = -1;
104 static int hf_sna_nlp_sri = -1;
105 static int hf_sna_nlp_rasapi = -1;
106 static int hf_sna_nlp_retryi = -1;
107 static int hf_sna_nlp_thdr_9 = -1;
108 static int hf_sna_nlp_lmi = -1;
109 static int hf_sna_nlp_cqfi = -1;
110 static int hf_sna_nlp_osi = -1;
111 static int hf_sna_nlp_offset = -1;
112 static int hf_sna_nlp_dlf = -1;
113 static int hf_sna_nlp_bsn = -1;
114
115 static int hf_sna_rh = -1;
116 static int hf_sna_rh_0 = -1;
117 static int hf_sna_rh_1 = -1;
118 static int hf_sna_rh_2 = -1;
119 static int hf_sna_rh_rri = -1;
120 static int hf_sna_rh_ru_category = -1;
121 static int hf_sna_rh_fi = -1;
122 static int hf_sna_rh_sdi = -1;
123 static int hf_sna_rh_bci = -1;
124 static int hf_sna_rh_eci = -1;
125 static int hf_sna_rh_dr1 = -1;
126 static int hf_sna_rh_lcci = -1;
127 static int hf_sna_rh_dr2 = -1;
128 static int hf_sna_rh_eri = -1;
129 static int hf_sna_rh_rti = -1;
130 static int hf_sna_rh_rlwi = -1;
131 static int hf_sna_rh_qri = -1;
132 static int hf_sna_rh_pi = -1;
133 static int hf_sna_rh_bbi = -1;
134 static int hf_sna_rh_ebi = -1;
135 static int hf_sna_rh_cdi = -1;
136 static int hf_sna_rh_csi = -1;
137 static int hf_sna_rh_edi = -1;
138 static int hf_sna_rh_pdi = -1;
139 static int hf_sna_rh_cebi = -1;
140 /*static int hf_sna_ru = -1;*/
141
142 static gint ett_sna = -1;
143 static gint ett_sna_th = -1;
144 static gint ett_sna_th_fid = -1;
145 static gint ett_sna_nlp_nhdr = -1;
146 static gint ett_sna_nlp_nhdr_0 = -1;
147 static gint ett_sna_nlp_nhdr_1 = -1;
148 static gint ett_sna_nlp_thdr = -1;
149 static gint ett_sna_nlp_thdr_8 = -1;
150 static gint ett_sna_nlp_thdr_9 = -1;
151 static gint ett_sna_rh = -1;
152 static gint ett_sna_rh_0 = -1;
153 static gint ett_sna_rh_1 = -1;
154 static gint ett_sna_rh_2 = -1;
155
156 static dissector_handle_t data_handle;
157
158 /* Format Identifier */
159 static const value_string sna_th_fid_vals[] = {
160         { 0x0,  "SNA device <--> Non-SNA Device" },
161         { 0x1,  "Subarea Nodes, without ER or VR" },
162         { 0x2,  "Subarea Node <--> PU2" },
163         { 0x3,  "Subarea Node or SNA host <--> Subarea Node" },
164         { 0x4,  "Subarea Nodes, supporting ER and VR" },
165         { 0x5,  "HPR RTP endpoint nodes" },
166         { 0xa,  "HPR NLP Frame Routing" },
167         { 0xb,  "HPR NLP Frame Routing" },
168         { 0xc,  "HPR NLP Automatic Network Routing" },
169         { 0xd,  "HPR NLP Automatic Network Routing" },
170         { 0xf,  "Adjaced Subarea Nodes, supporting ER and VR" },
171         { 0x0,  NULL }
172 };
173
174 /* Mapping Field */
175 static const value_string sna_th_mpf_vals[] = {
176         { 0, "Middle segment of a BIU" },
177         { 1, "Last segment of a BIU" },
178         { 2, "First segment of a BIU" },
179         { 3 , "Whole BIU" },
180         { 0,   NULL }
181 };
182
183 /* Expedited Flow Indicator */
184 static const value_string sna_th_efi_vals[] = {
185         { 0, "Normal Flow" },
186         { 1, "Expedited Flow" },
187         { 0x0,  NULL }
188 };
189
190 /* Request/Response Indicator */
191 static const value_string sna_rh_rri_vals[] = {
192         { 0, "Request" },
193         { 1, "Response" },
194         { 0x0,  NULL }
195 };
196
197 /* Request/Response Unit Category */
198 static const value_string sna_rh_ru_category_vals[] = {
199         { 0, "Function Management Data (FMD)" },
200         { 1, "Network Control (NC)" },
201         { 2, "Data Flow Control (DFC)" },
202         { 3, "Session Control (SC)" },
203         { 0x0,  NULL }
204 };
205
206 /* Format Indicator */
207 static const true_false_string sna_rh_fi_truth =
208         { "FM Header", "No FM Header" };
209
210 /* Sense Data Included */
211 static const true_false_string sna_rh_sdi_truth =
212         { "Included", "Not Included" };
213
214 /* Begin Chain Indicator */
215 static const true_false_string sna_rh_bci_truth =
216         { "First in Chain", "Not First in Chain" };
217
218 /* End Chain Indicator */
219 static const true_false_string sna_rh_eci_truth =
220         { "Last in Chain", "Not Last in Chain" };
221
222 /* Lengith-Checked Compression Indicator */
223 static const true_false_string sna_rh_lcci_truth =
224         { "Compressed", "Not Compressed" };
225
226 /* Response Type Indicator */
227 static const true_false_string sna_rh_rti_truth =
228         { "Negative", "Positive" };
229
230 /* Exception Response Indicator */
231 static const true_false_string sna_rh_eri_truth =
232         { "Exception", "Definite" };
233
234 /* Queued Response Indicator */
235 static const true_false_string sna_rh_qri_truth =
236         { "Enqueue response in TC queues", "Response bypasses TC queues" };
237
238 /* Code Selection Indicator */
239 static const value_string sna_rh_csi_vals[] = {
240         { 0, "EBCDIC" },
241         { 1, "ASCII" },
242         { 0x0,  NULL }
243 };
244
245 /* TG Sweep */
246 static const value_string sna_th_tg_sweep_vals[] = {
247         { 0, "This PIU may overtake any PU ahead of it." },
248         { 1, "This PIU does not ovetake any PIU ahead of it." },
249         { 0x0,  NULL }
250 };
251
252 /* ER_VR_SUPP_IND */
253 static const value_string sna_th_er_vr_supp_ind_vals[] = {
254         { 0, "Each node supports ER and VR protocols" },
255         { 1, "Includes at least one node that does not support ER and VR protocols"  },
256         { 0x0,  NULL }
257 };
258
259 /* VR_PAC_CNT_IND */
260 static const value_string sna_th_vr_pac_cnt_ind_vals[] = {
261         { 0, "Pacing count on the VR has not reached 0" },
262         { 1, "Pacing count on the VR has reached 0" },
263         { 0x0,  NULL }
264 };
265
266 /* NTWK_PRTY */
267 static const value_string sna_th_ntwk_prty_vals[] = {
268         { 0, "PIU flows at a lower priority" },
269         { 1, "PIU flows at network priority (highest transmission priority)" },
270         { 0x0,  NULL }
271 };
272
273 /* TGSF */
274 static const value_string sna_th_tgsf_vals[] = {
275         { 0, "Not segmented" },
276         { 1, "Last segment" },
277         { 2, "First segment" },
278         { 3, "Middle segment" },
279         { 0x0,  NULL }
280 };
281
282 /* PIUBF */
283 static const value_string sna_th_piubf_vals[] = {
284         { 0, "Single PIU frame" },
285         { 1, "Last PIU of a multiple PIU frame" },
286         { 2, "First PIU of a multiple PIU frame" },
287         { 3, "Middle PIU of a multiple PIU frame" },
288         { 0x0,  NULL }
289 };
290
291 /* NLPOI */
292 static const value_string sna_th_nlpoi_vals[] = {
293         { 0, "NLP starts within this FID4 TH" },
294         { 1, "NLP byte 0 starts after RH byte 0 following NLP C/P pad" },
295         { 0x0,  NULL }
296 };
297
298 /* TPF */
299 static const value_string sna_th_tpf_vals[] = {
300         { 0, "Low Priority" },
301         { 1, "Medium Priority" },
302         { 2, "High Priority" },
303         { 3, "Network Priority" },
304         { 0x0,  NULL }
305 };
306
307 /* VR_CWI */
308 static const value_string sna_th_vr_cwi_vals[] = {
309         { 0, "Increment window size" },
310         { 1, "Decrement window size" },
311         { 0x0,  NULL }
312 };
313
314 /* TG_NONFIFO_IND */
315 static const true_false_string sna_th_tg_nonfifo_ind_truth =
316         { "TG FIFO is not required", "TG FIFO is required" };
317
318 /* VR_SQTI */
319 static const value_string sna_th_vr_sqti_vals[] = {
320         { 0, "Non-sequenced, Non-supervisory" },
321         { 1, "Non-sequenced, Supervisory" },
322         { 2, "Singly-sequenced" },
323         { 0x0,  NULL }
324 };
325
326 /* VRPRQ */
327 static const true_false_string sna_th_vrprq_truth = {
328         "VR pacing request is sent asking for a VR pacing response",
329         "No VR pacing response is requested",
330 };
331
332 /* VRPRS */
333 static const true_false_string sna_th_vrprs_truth = {
334         "VR pacing response is sent in response to a VRPRQ bit set",
335         "No pacing response sent",
336 };
337
338 /* VR_CWRI */
339 static const value_string sna_th_vr_cwri_vals[] = {
340         { 0, "Increment window size by 1" },
341         { 1, "Decrement window size by 1" },
342         { 0x0,  NULL }
343 };
344
345 /* VR_RWI */
346 static const true_false_string sna_th_vr_rwi_truth = {
347         "Reset window size to the minimum specified in NC_ACTVR",
348         "Do not reset window size",
349 };
350
351 /* Switching Mode */
352 static const value_string sna_nlp_sm_vals[] = {
353         { 5, "Function routing" },
354         { 6, "Automatic network routing" },
355         { 0x0,  NULL }
356 };
357
358 static const true_false_string sna_nlp_tspi_truth =
359         { "Time sensitive", "Not time sensitive" };
360
361 static const true_false_string sna_nlp_slowdn1_truth =
362         { "Minor congestion", "No minor congestion" };
363
364 static const true_false_string sna_nlp_slowdn2_truth =
365         { "Major congestion", "No major congestion" };
366
367 /* Function Type */
368 static const value_string sna_nlp_ft_vals[] = {
369         { 0x10, "LDLC" },
370         { 0x0,  NULL }
371 };
372
373 static const value_string sna_nlp_frh_vals[] = {
374         { 0x03, "XID complete request" },
375         { 0x04, "XID complete response" },
376         { 0x0,  NULL }
377 };
378
379 static const true_false_string sna_nlp_setupi_truth =
380         { "Connection setup segment present", "Connection setup segment not present" };
381
382 static const true_false_string sna_nlp_somi_truth =
383         { "Start of message", "Not start of message" };
384
385 static const true_false_string sna_nlp_eomi_truth =
386         { "End of message", "Not end of message" };
387
388 static const true_false_string sna_nlp_sri_truth =
389         { "Status requested", "No status requested" };
390
391 static const true_false_string sna_nlp_rasapi_truth =
392         { "Reply as soon as possible", "No need to reply as soon as possible" };
393
394 static const true_false_string sna_nlp_retryi_truth =
395         { "Undefined", "Sender will retransmit" };
396
397 static const true_false_string sna_nlp_lmi_truth =
398         { "Last message", "Not last message" };
399
400 static const true_false_string sna_nlp_cqfi_truth =
401         { "CQFI included", "CQFI not included" };
402
403 static const true_false_string sna_nlp_osi_truth =
404         { "Optional segments present", "No optional segments present" };
405
406
407 static int  dissect_fid0_1 (tvbuff_t*, packet_info*, proto_tree*);
408 static int  dissect_fid2 (tvbuff_t*, packet_info*, proto_tree*);
409 static int  dissect_fid3 (tvbuff_t*, proto_tree*);
410 static int  dissect_fid4 (tvbuff_t*, packet_info*, proto_tree*);
411 static int  dissect_fid5 (tvbuff_t*, proto_tree*);
412 static int  dissect_fidf (tvbuff_t*, proto_tree*);
413 static void dissect_fid (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
414 static void dissect_nlp (tvbuff_t*, packet_info*, proto_tree*, proto_tree*);
415 static void dissect_rh (tvbuff_t*, int, proto_tree*);
416
417 static void
418 dissect_sna(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
419 {
420         guint8          fid;
421         proto_tree      *sna_tree = NULL;
422         proto_item      *sna_ti = NULL;
423
424         if (check_col(pinfo->cinfo, COL_PROTOCOL))
425                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "SNA");
426         if (check_col(pinfo->cinfo, COL_INFO))
427                 col_clear(pinfo->cinfo, COL_INFO);
428
429         /* SNA data should be printed in EBCDIC, not ASCII */
430         pinfo->fd->flags.encoding = CHAR_EBCDIC;
431
432         if (tree) {
433
434                 /* Don't bother setting length. We'll set it later after we find
435                  * the lengths of TH/RH/RU */
436                 sna_ti = proto_tree_add_item(tree, proto_sna, tvb, 0, -1, FALSE);
437                 sna_tree = proto_item_add_subtree(sna_ti, ett_sna);
438         }
439
440         /* Transmission Header Format Identifier */
441         fid = hi_nibble(tvb_get_guint8(tvb, 0));
442         switch(fid) {
443                 case 0xa:       /* HPR Network Layer Packet */
444                 case 0xb:
445                 case 0xc:
446                 case 0xd:
447                         dissect_nlp(tvb, pinfo, sna_tree, tree);
448                         break;
449                 default:
450                         dissect_fid(tvb, pinfo, sna_tree, tree);
451         }
452 }
453
454 static void
455 dissect_fid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
456     proto_tree *parent_tree)
457 {
458
459         proto_tree      *th_tree = NULL, *rh_tree = NULL;
460         proto_item      *th_ti = NULL, *rh_ti = NULL;
461         guint8          th_fid;
462         int             sna_header_len = 0, th_header_len = 0;
463         int             offset;
464
465         /* Transmission Header Format Identifier */
466         th_fid = hi_nibble(tvb_get_guint8(tvb, 0));
467
468         /* Summary information */
469         if (check_col(pinfo->cinfo, COL_INFO))
470                 col_add_str(pinfo->cinfo, COL_INFO,
471                                 val_to_str(th_fid, sna_th_fid_vals, "Unknown FID: %01x"));
472
473         if (tree) {
474
475                 /* --- TH --- */
476                 /* Don't bother setting length. We'll set it later after we find
477                  * the length of TH */
478                 th_ti = proto_tree_add_item(tree, hf_sna_th, tvb,  0, -1, FALSE);
479                 th_tree = proto_item_add_subtree(th_ti, ett_sna_th);
480         }
481
482         /* Get size of TH */
483         switch(th_fid) {
484                 case 0x0:
485                 case 0x1:
486                         th_header_len = dissect_fid0_1(tvb, pinfo, th_tree);
487                         break;
488                 case 0x2:
489                         th_header_len = dissect_fid2(tvb, pinfo, th_tree);
490                         break;
491                 case 0x3:
492                         th_header_len = dissect_fid3(tvb, th_tree);
493                         break;
494                 case 0x4:
495                         th_header_len = dissect_fid4(tvb, pinfo, th_tree);
496                         break;
497                 case 0x5:
498                         th_header_len = dissect_fid5(tvb, th_tree);
499                         break;
500                 case 0xf:
501                         th_header_len = dissect_fidf(tvb, th_tree);
502                         break;
503                 default:
504                         call_dissector(data_handle,
505                             tvb_new_subset(tvb, 1, -1, -1), pinfo, parent_tree);
506                         return;
507         }
508
509         sna_header_len += th_header_len;
510         offset = th_header_len;
511
512         if (tree) {
513                 proto_item_set_len(th_ti, th_header_len);
514
515                 /* --- RH --- */
516                 rh_ti = proto_tree_add_item(tree, hf_sna_rh, tvb, offset, 3, FALSE);
517                 rh_tree = proto_item_add_subtree(rh_ti, ett_sna_rh);
518                 dissect_rh(tvb, offset, rh_tree);
519
520                 sna_header_len += 3;
521                 offset += 3;
522         }
523         else {
524                 sna_header_len += 3;
525                 offset += 3;
526         }
527
528         if (tvb_offset_exists(tvb, offset+1)) {
529                 call_dissector(data_handle, tvb_new_subset(tvb, offset, -1, -1),
530                     pinfo, parent_tree);
531         }
532 }
533
534 #define SNA_FID01_ADDR_LEN      2
535
536 /* FID Types 0 and 1 */
537 static int
538 dissect_fid0_1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
539 {
540         proto_tree      *bf_tree;
541         proto_item      *bf_item;
542         guint8          th_0;
543         const guint8    *ptr;
544
545         const int bytes_in_header = 10;
546
547         if (tree) {
548                 /* Byte 0 */
549                 th_0 = tvb_get_guint8(tvb, 0);
550                 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
551                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
552
553                 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
554                 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
555                 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
556
557                 /* Byte 1 */
558                 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
559
560                 /* Bytes 2-3 */
561                 proto_tree_add_item(tree, hf_sna_th_daf, tvb, 2, 2, FALSE);
562         }
563
564         /* Set DST addr */
565         ptr = tvb_get_ptr(tvb, 2, SNA_FID01_ADDR_LEN);
566         SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
567         SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
568
569         if (tree) {
570                 proto_tree_add_item(tree, hf_sna_th_oaf, tvb, 4, 2, FALSE);
571         }
572
573         /* Set SRC addr */
574         ptr = tvb_get_ptr(tvb, 4, SNA_FID01_ADDR_LEN);
575         SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
576         SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID01_ADDR_LEN, ptr);
577
578         /* If we're not filling a proto_tree, return now */
579         if (tree) {
580                 return bytes_in_header;
581         }
582
583         proto_tree_add_item(tree, hf_sna_th_snf, tvb, 6, 2, FALSE);
584         proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 8, 2, FALSE);
585
586         return bytes_in_header;
587 }
588
589 #define SNA_FID2_ADDR_LEN       1
590
591 /* FID Type 2 */
592 static int
593 dissect_fid2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
594 {
595         proto_tree      *bf_tree;
596         proto_item      *bf_item;
597         guint8          th_0=0, daf=0, oaf=0;
598         const guint8    *ptr;
599
600         const int bytes_in_header = 6;
601
602         if (tree) {
603                 th_0 = tvb_get_guint8(tvb, 0);
604                 daf = tvb_get_guint8(tvb, 2);
605                 oaf = tvb_get_guint8(tvb, 3);
606
607                 /* Byte 0 */
608                 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
609                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
610
611                 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
612                 proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
613                 proto_tree_add_uint(bf_tree, hf_sna_th_odai,tvb, 0, 1, th_0);
614                 proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
615
616                 /* Byte 1 */
617                 proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
618
619                 /* Byte 2 */
620                 proto_tree_add_uint_format(tree, hf_sna_th_daf, tvb, 2, 1, daf,
621                                 "Destination Address Field: 0x%02x", daf);
622         }
623
624         /* Set DST addr */
625         ptr = tvb_get_ptr(tvb, 2, SNA_FID2_ADDR_LEN);
626         SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
627         SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
628
629         if (tree) {
630                 /* Byte 3 */
631                 proto_tree_add_uint_format(tree, hf_sna_th_oaf, tvb, 3, 1, oaf,
632                                 "Origin Address Field: 0x%02x", oaf);
633         }
634
635         /* Set SRC addr */
636         ptr = tvb_get_ptr(tvb, 3, SNA_FID2_ADDR_LEN);
637         SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
638         SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID2_ADDR_LEN, ptr);
639
640         if (tree) {
641                 proto_tree_add_item(tree, hf_sna_th_snf, tvb, 4, 2, FALSE);
642         }
643
644         return bytes_in_header;
645 }
646
647 /* FID Type 3 */
648 static int
649 dissect_fid3(tvbuff_t *tvb, proto_tree *tree)
650 {
651         proto_tree      *bf_tree;
652         proto_item      *bf_item;
653         guint8          th_0;
654
655         const int bytes_in_header = 2;
656
657         /* If we're not filling a proto_tree, return now */
658         if (!tree) {
659                 return bytes_in_header;
660         }
661
662         th_0 = tvb_get_guint8(tvb, 0);
663
664         /* Create the bitfield tree */
665         bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
666         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
667
668         proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
669         proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
670         proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
671
672         proto_tree_add_item(tree, hf_sna_th_lsid, tvb, 1, 1, FALSE);
673
674         return bytes_in_header;
675 }
676
677
678 static int
679 dissect_fid4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
680 {
681         proto_tree      *bf_tree;
682         proto_item      *bf_item;
683         int             offset = 0;
684         guint8          th_byte, mft;
685         guint16         th_word;
686         guint16         def, oef;
687         guint32         dsaf, osaf;
688         static struct sna_fid_type_4_addr src, dst;
689
690         const int bytes_in_header = 26;
691
692         /* If we're not filling a proto_tree, return now */
693         if (!tree) {
694                 return bytes_in_header;
695         }
696
697         if (tree) {
698                 th_byte = tvb_get_guint8(tvb, offset);
699
700                 /* Create the bitfield tree */
701                 bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, offset, 1, th_byte);
702                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
703
704                 /* Byte 0 */
705                 proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, offset, 1, th_byte);
706                 proto_tree_add_uint(bf_tree, hf_sna_th_tg_sweep, tvb, offset, 1, th_byte);
707                 proto_tree_add_uint(bf_tree, hf_sna_th_er_vr_supp_ind, tvb, offset, 1, th_byte);
708                 proto_tree_add_uint(bf_tree, hf_sna_th_vr_pac_cnt_ind, tvb, offset, 1, th_byte);
709                 proto_tree_add_uint(bf_tree, hf_sna_th_ntwk_prty, tvb, offset, 1, th_byte);
710
711                 offset += 1;
712                 th_byte = tvb_get_guint8(tvb, offset);
713
714                 /* Create the bitfield tree */
715                 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 1");
716                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
717
718                 /* Byte 1 */
719                 proto_tree_add_uint(bf_tree, hf_sna_th_tgsf, tvb, offset, 1, th_byte);
720                 proto_tree_add_boolean(bf_tree, hf_sna_th_mft, tvb, offset, 1, th_byte);
721                 proto_tree_add_uint(bf_tree, hf_sna_th_piubf, tvb, offset, 1, th_byte);
722
723                 mft = th_byte & 0x04;
724                 offset += 1;
725                 th_byte = tvb_get_guint8(tvb, offset);
726
727                 /* Create the bitfield tree */
728                 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 2");
729                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
730
731                 /* Byte 2 */
732                 if (mft) {
733                         proto_tree_add_uint(bf_tree, hf_sna_th_nlpoi, tvb, offset, 1, th_byte);
734                         proto_tree_add_uint(bf_tree, hf_sna_th_nlp_cp, tvb, offset, 1, th_byte);
735                 }
736                 else {
737                         proto_tree_add_uint(bf_tree, hf_sna_th_iern, tvb, offset, 1, th_byte);
738                 }
739                 proto_tree_add_uint(bf_tree, hf_sna_th_ern, tvb, offset, 1, th_byte);
740
741                 offset += 1;
742                 th_byte = tvb_get_guint8(tvb, offset);
743
744                 /* Create the bitfield tree */
745                 bf_item = proto_tree_add_text(tree, tvb, offset, 1, "Transmision Header Byte 3");
746                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
747
748                 /* Byte 3 */
749                 proto_tree_add_uint(bf_tree, hf_sna_th_vrn, tvb, offset, 1, th_byte);
750                 proto_tree_add_uint(bf_tree, hf_sna_th_tpf, tvb, offset, 1, th_byte);
751
752                 offset += 1;
753                 th_word = tvb_get_ntohs(tvb, offset);
754
755                 /* Create the bitfield tree */
756                 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Bytes 4-5");
757                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
758
759                 /* Bytes 4-5 */
760                 proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwi, tvb, offset, 2, th_word);
761                 proto_tree_add_boolean(bf_tree, hf_sna_th_tg_nonfifo_ind, tvb, offset, 2, th_word);
762                 proto_tree_add_uint(bf_tree, hf_sna_th_vr_sqti, tvb, offset, 2, th_word);
763
764                 /* I'm not sure about byte-order on this one... */
765                 proto_tree_add_uint(bf_tree, hf_sna_th_tg_snf, tvb, offset, 2, th_word);
766
767                 offset += 2;
768                 th_word = tvb_get_ntohs(tvb, offset);
769
770                 /* Create the bitfield tree */
771                 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Bytes 6-7");
772                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
773
774                 /* Bytes 6-7 */
775                 proto_tree_add_boolean(bf_tree, hf_sna_th_vrprq, tvb, offset, 2, th_word);
776                 proto_tree_add_boolean(bf_tree, hf_sna_th_vrprs, tvb, offset, 2, th_word);
777                 proto_tree_add_uint(bf_tree, hf_sna_th_vr_cwri, tvb, offset, 2, th_word);
778                 proto_tree_add_boolean(bf_tree, hf_sna_th_vr_rwi, tvb, offset, 2, th_word);
779
780                 /* I'm not sure about byte-order on this one... */
781                 proto_tree_add_uint(bf_tree, hf_sna_th_vr_snf_send, tvb, offset, 2, th_word);
782
783                 offset += 2;
784         }
785
786         dsaf = tvb_get_ntohl(tvb, 8);
787         if (tree) {
788                 /* Bytes 8-11 */
789                 proto_tree_add_uint(tree, hf_sna_th_dsaf, tvb, offset, 4, dsaf);
790
791                 offset += 4;
792         }
793
794         osaf = tvb_get_ntohl(tvb, 12);
795         if (tree) {
796                 /* Bytes 12-15 */
797                 proto_tree_add_uint(tree, hf_sna_th_osaf, tvb, offset, 4, osaf);
798
799                 offset += 4;
800                 th_byte = tvb_get_guint8(tvb, offset);
801
802                 /* Create the bitfield tree */
803                 bf_item = proto_tree_add_text(tree, tvb, offset, 2, "Transmision Header Byte 16");
804                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
805
806                 /* Byte 16 */
807                 proto_tree_add_boolean(tree, hf_sna_th_snai, tvb, offset, 1, th_byte);
808
809                 /* We luck out here because in their infinite wisdom the SNA
810                  * architects placed the MPF and EFI fields in the same bitfield
811                  * locations, even though for FID4 they're not in byte 0.
812                  * Thank you IBM! */
813                 proto_tree_add_uint(tree, hf_sna_th_mpf, tvb, offset, 1, th_byte);
814                 proto_tree_add_uint(tree, hf_sna_th_efi, tvb, offset, 1, th_byte);
815
816                 offset += 2; /* 1 for byte 16, 1 for byte 17 which is reserved */
817         }
818
819
820         def = tvb_get_ntohs(tvb, 18);
821         if (tree) {
822                 /* Bytes 18-25 */
823                 proto_tree_add_uint(tree, hf_sna_th_def, tvb, offset, 2, def);
824         }
825
826         /* Addresses in FID 4 are discontiguous, sigh */
827         dst.saf = dsaf;
828         dst.ef = def;
829         SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8* )&dst);
830         SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&dst);
831
832
833         oef = tvb_get_ntohs(tvb, 20);
834         if (tree) {
835                 proto_tree_add_uint(tree, hf_sna_th_oef, tvb, offset+2, 2, oef);
836         }
837
838         /* Addresses in FID 4 are discontiguous, sigh */
839         src.saf = osaf;
840         src.ef = oef;
841         SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&src);
842         SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN, (guint8 *)&src);
843
844         if (tree) {
845                 proto_tree_add_item(tree, hf_sna_th_snf, tvb, offset+4, 2, FALSE);
846                 proto_tree_add_item(tree, hf_sna_th_dcf, tvb, offset+6, 2, FALSE);
847         }
848
849         return bytes_in_header;
850 }
851
852 /* FID Type 5 */
853 static int
854 dissect_fid5(tvbuff_t *tvb, proto_tree *tree)
855 {
856         proto_tree      *bf_tree;
857         proto_item      *bf_item;
858         guint8          th_0;
859
860         const int bytes_in_header = 12;
861
862         /* If we're not filling a proto_tree, return now */
863         if (!tree) {
864                 return bytes_in_header;
865         }
866
867         th_0 = tvb_get_guint8(tvb, 0);
868
869         /* Create the bitfield tree */
870         bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
871         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
872
873         proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
874         proto_tree_add_uint(bf_tree, hf_sna_th_mpf, tvb, 0, 1, th_0);
875         proto_tree_add_uint(bf_tree, hf_sna_th_efi, tvb, 0, 1, th_0);
876
877         proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
878         proto_tree_add_item(tree, hf_sna_th_snf, tvb, 2, 2, FALSE);
879
880         proto_tree_add_item(tree, hf_sna_th_sa, tvb, 4, 8, FALSE);
881
882         return bytes_in_header;
883
884 }
885
886 /* FID Type f */
887 static int
888 dissect_fidf(tvbuff_t *tvb, proto_tree *tree)
889 {
890         proto_tree      *bf_tree;
891         proto_item      *bf_item;
892         guint8          th_0;
893         
894         const int bytes_in_header = 26;
895
896         /* If we're not filling a proto_tree, return now */
897         if (!tree) {
898                 return bytes_in_header;
899         }
900
901         th_0 = tvb_get_guint8(tvb, 0);
902
903         /* Create the bitfield tree */
904         bf_item = proto_tree_add_uint(tree, hf_sna_th_0, tvb, 0, 1, th_0);
905         bf_tree = proto_item_add_subtree(bf_item, ett_sna_th_fid);
906
907         proto_tree_add_uint(bf_tree, hf_sna_th_fid, tvb, 0, 1, th_0);
908         proto_tree_add_text(tree, tvb, 1, 1, "Reserved");
909
910         proto_tree_add_item(tree, hf_sna_th_cmd_fmt, tvb,  2, 1, FALSE);
911         proto_tree_add_item(tree, hf_sna_th_cmd_type, tvb, 3, 1, FALSE);
912         proto_tree_add_item(tree, hf_sna_th_cmd_sn, tvb,   4, 2, FALSE);
913
914         /* Yup, bytes 6-23 are reserved! */
915         proto_tree_add_text(tree, tvb, 6, 18, "Reserved");
916
917         proto_tree_add_item(tree, hf_sna_th_dcf, tvb, 24, 2, FALSE);
918
919         return bytes_in_header;
920 }
921
922 /* HPR Network Layer Packet */
923 static void
924 dissect_nlp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
925     proto_tree *parent_tree)
926 {
927         proto_tree      *nlp_tree, *bf_tree;
928         proto_item      *nlp_item, *bf_item, *h_item;
929         guint8          nhdr_0, nhdr_1, nhdr_x, thdr_8, thdr_9;
930         guint32         thdr_len, thdr_dlf, thdr_bsn;
931
932         int index = 0, counter = 0;
933
934         nlp_tree = NULL;
935         nlp_item = NULL;
936
937         nhdr_0 = tvb_get_guint8(tvb, index);
938         nhdr_1 = tvb_get_guint8(tvb, index+1);
939
940         if (check_col(pinfo->cinfo, COL_INFO))
941                 col_add_str(pinfo->cinfo, COL_INFO, "HPR NLP Packet");
942
943         if (tree) {
944                 /* Don't bother setting length. We'll set it later after we find
945                  * the lengths of NHDR */
946                 nlp_item = proto_tree_add_item(tree, hf_sna_nlp_nhdr, tvb, index, -1, FALSE);
947                 nlp_tree = proto_item_add_subtree(nlp_item, ett_sna_nlp_nhdr);
948
949                 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_nhdr_0, tvb, index, 1, nhdr_0);
950                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_nhdr_0);
951
952                 proto_tree_add_uint(bf_tree, hf_sna_nlp_sm, tvb, index, 1, nhdr_0);
953                 proto_tree_add_uint(bf_tree, hf_sna_nlp_tpf, tvb, index, 1, nhdr_0);
954
955                 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_nhdr_1, tvb, index+1, 1, nhdr_1);
956                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_nhdr_1);
957
958                 proto_tree_add_uint(bf_tree, hf_sna_nlp_ft, tvb, index+1, 1, nhdr_1);
959                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_tspi, tvb, index+1, 1, nhdr_1);
960                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_slowdn1, tvb, index+1, 1, nhdr_1);
961                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_slowdn2, tvb, index+1, 1, nhdr_1);
962         }
963         /* ANR or FR lists */
964
965         index += 2;
966         counter = 0;
967
968         if ((nhdr_0 & 0xe0) == 0xa0) {
969                 do {
970                         nhdr_x = tvb_get_guint8(tvb, index + counter);
971                         counter ++;
972                 } while (nhdr_x != 0xff);
973                 if (tree)
974                         h_item = proto_tree_add_item(nlp_tree, hf_sna_nlp_fra, tvb, index, counter, FALSE);
975                 index += counter;
976
977                 index++; /* 1 Byte Reserved */
978
979                 if (tree) {
980                         proto_item_set_len(nlp_item, index);
981                 }
982                 if ((nhdr_1 & 0x80) == 0x10) {
983                         nhdr_x = tvb_get_guint8(tvb, index);
984                         if (tree) {
985                                 proto_tree_add_uint(tree, hf_sna_nlp_frh, tvb, index, 1, nhdr_x);
986                         }
987                         index ++;
988
989                         if (tvb_offset_exists(tvb, index+1)) {
990                                 call_dissector(data_handle,
991                                         tvb_new_subset(tvb, index, -1, -1),
992                                         pinfo, parent_tree);
993                         }
994                         return;
995                 }
996         }
997         if ((nhdr_0 & 0xe0) == 0xc0) {
998                 do {
999                         nhdr_x = tvb_get_guint8(tvb, index + counter);
1000                         counter ++;
1001                 } while (nhdr_x != 0xff);
1002                 if (tree)
1003                         h_item = proto_tree_add_item(nlp_tree, hf_sna_nlp_anr, tvb, index, counter, FALSE);
1004                 index += counter;
1005
1006                 index++; /* 1 Byte Reserved */
1007
1008                 if (tree) {
1009                         proto_item_set_len(nlp_item, index);
1010                 }
1011
1012         }
1013
1014         thdr_8 = tvb_get_guint8(tvb, index+8);
1015         thdr_9 = tvb_get_guint8(tvb, index+9);
1016         thdr_len = tvb_get_ntohs(tvb, index+10);
1017         thdr_dlf = tvb_get_ntohl(tvb, index+12);
1018         thdr_bsn = tvb_get_ntohl(tvb, index+16);
1019
1020         if (tree) {
1021                 /* Don't bother setting length. We'll set it later after we find
1022                  * the lengths of NHDR */
1023                 nlp_item = proto_tree_add_item(tree, hf_sna_nlp_thdr, tvb, index, -1, FALSE);
1024                 nlp_tree = proto_item_add_subtree(nlp_item, ett_sna_nlp_thdr);
1025
1026                 bf_item = proto_tree_add_item(nlp_tree, hf_sna_nlp_tcid, tvb, index, 8, FALSE);
1027
1028                 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_thdr_8, tvb, index+8, 1, thdr_8);
1029                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_thdr_8);
1030
1031                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_setupi, tvb, index+8, 1, thdr_8);
1032                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_somi, tvb, index+8, 1, thdr_8);
1033                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_eomi, tvb, index+8, 1, thdr_8);
1034                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_sri, tvb, index+8, 1, thdr_8);
1035                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_rasapi, tvb, index+8, 1, thdr_8);
1036                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_retryi, tvb, index+8, 1, thdr_8);
1037
1038                 bf_item = proto_tree_add_uint(nlp_tree, hf_sna_nlp_thdr_9, tvb, index+9, 1, thdr_9);
1039                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_nlp_thdr_9);
1040
1041                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_lmi, tvb, index+9, 1, thdr_9);
1042                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_cqfi, tvb, index+9, 1, thdr_9);
1043                 proto_tree_add_boolean(bf_tree, hf_sna_nlp_osi, tvb, index+9, 1, thdr_9);
1044
1045                 proto_tree_add_uint(nlp_tree, hf_sna_nlp_offset, tvb, index+10, 2, thdr_len);
1046                 proto_tree_add_uint(nlp_tree, hf_sna_nlp_dlf, tvb, index+12, 4, thdr_dlf);
1047                 proto_tree_add_uint(nlp_tree, hf_sna_nlp_bsn, tvb, index+16, 4, thdr_bsn);
1048
1049                 proto_item_set_len(nlp_item, thdr_len);
1050         }
1051         index += (thdr_len << 2);
1052         if (((thdr_8 & 0x20) == 0) && thdr_dlf) {
1053                 if (check_col(pinfo->cinfo, COL_INFO))
1054                         col_add_str(pinfo->cinfo, COL_INFO, "HPR Fragment");
1055                 if (tvb_offset_exists(tvb, index+1)) {
1056                         call_dissector(data_handle,
1057                                 tvb_new_subset(tvb, index, -1, -1), pinfo,
1058                                 parent_tree);
1059                 }
1060                 return;
1061         }
1062         if (tvb_offset_exists(tvb, index+1)) {
1063                 dissect_fid(tvb_new_subset(tvb, index, -1, -1), pinfo, tree,
1064                         parent_tree);
1065         }
1066 }
1067
1068 /* RH */
1069 static void
1070 dissect_rh(tvbuff_t *tvb, int offset, proto_tree *tree)
1071 {
1072         proto_tree      *bf_tree;
1073         proto_item      *bf_item;
1074         gboolean        is_response;
1075         guint8          rh_0, rh_1, rh_2;
1076
1077
1078         /* Create the bitfield tree for byte 0*/
1079         rh_0 = tvb_get_guint8(tvb, offset);
1080         is_response = (rh_0 & 0x80);
1081
1082         bf_item = proto_tree_add_uint(tree, hf_sna_rh_0, tvb, offset, 1, rh_0);
1083         bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_0);
1084
1085         proto_tree_add_uint(bf_tree, hf_sna_rh_rri, tvb, offset, 1, rh_0);
1086         proto_tree_add_uint(bf_tree, hf_sna_rh_ru_category, tvb, offset, 1, rh_0);
1087         proto_tree_add_boolean(bf_tree, hf_sna_rh_fi, tvb, offset, 1, rh_0);
1088         proto_tree_add_boolean(bf_tree, hf_sna_rh_sdi, tvb, offset, 1, rh_0);
1089         proto_tree_add_boolean(bf_tree, hf_sna_rh_bci, tvb, offset, 1, rh_0);
1090         proto_tree_add_boolean(bf_tree, hf_sna_rh_eci, tvb, offset, 1, rh_0);
1091
1092         offset += 1;
1093         rh_1 = tvb_get_guint8(tvb, offset);
1094
1095         /* Create the bitfield tree for byte 1*/
1096         bf_item = proto_tree_add_uint(tree, hf_sna_rh_1, tvb, offset, 1, rh_1);
1097         bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_1);
1098
1099         proto_tree_add_boolean(bf_tree, hf_sna_rh_dr1, tvb,  offset, 1, rh_1);
1100
1101         if (!is_response) {
1102                 proto_tree_add_boolean(bf_tree, hf_sna_rh_lcci, tvb, offset, 1, rh_1);
1103         }
1104
1105         proto_tree_add_boolean(bf_tree, hf_sna_rh_dr2, tvb,  offset, 1, rh_1);
1106
1107         if (is_response) {
1108                 proto_tree_add_boolean(bf_tree, hf_sna_rh_rti, tvb,  offset, 1, rh_1);
1109         }
1110         else {
1111                 proto_tree_add_boolean(bf_tree, hf_sna_rh_eri, tvb,  offset, 1, rh_1);
1112                 proto_tree_add_boolean(bf_tree, hf_sna_rh_rlwi, tvb, offset, 1, rh_1);
1113         }
1114
1115         proto_tree_add_boolean(bf_tree, hf_sna_rh_qri, tvb, offset, 1, rh_1);
1116         proto_tree_add_boolean(bf_tree, hf_sna_rh_pi, tvb,  offset, 1, rh_1);
1117
1118         offset += 1;
1119         rh_2 = tvb_get_guint8(tvb, offset);
1120
1121         /* Create the bitfield tree for byte 2*/
1122         bf_item = proto_tree_add_uint(tree, hf_sna_rh_2, tvb, offset, 1, rh_2);
1123
1124         if (!is_response) {
1125                 bf_tree = proto_item_add_subtree(bf_item, ett_sna_rh_2);
1126
1127                 proto_tree_add_boolean(bf_tree, hf_sna_rh_bbi, tvb,  offset, 1, rh_2);
1128                 proto_tree_add_boolean(bf_tree, hf_sna_rh_ebi, tvb,  offset, 1, rh_2);
1129                 proto_tree_add_boolean(bf_tree, hf_sna_rh_cdi, tvb,  offset, 1, rh_2);
1130                 proto_tree_add_uint(bf_tree, hf_sna_rh_csi, tvb,  offset, 1, rh_2);
1131                 proto_tree_add_boolean(bf_tree, hf_sna_rh_edi, tvb,  offset, 1, rh_2);
1132                 proto_tree_add_boolean(bf_tree, hf_sna_rh_pdi, tvb,  offset, 1, rh_2);
1133                 proto_tree_add_boolean(bf_tree, hf_sna_rh_cebi, tvb, offset, 1, rh_2);
1134         }
1135
1136         /* XXX - check for sdi. If TRUE, the next 4 bytes will be sense data */
1137 }
1138
1139 void
1140 proto_register_sna(void)
1141 {
1142         static hf_register_info hf[] = {
1143                 { &hf_sna_th,
1144                 { "Transmission Header",        "sna.th", FT_NONE, BASE_NONE, NULL, 0x0,
1145                         "", HFILL }},
1146
1147                 { &hf_sna_th_0,
1148                 { "Transmission Header Byte 0", "sna.th.0", FT_UINT8, BASE_HEX, NULL, 0x0,
1149                         "Byte 0 of Tranmission Header contains FID, MPF, ODAI,"
1150                         " and EFI as bitfields.", HFILL }},
1151
1152                 { &hf_sna_th_fid,
1153                 { "Format Identifer",           "sna.th.fid", FT_UINT8, BASE_HEX, VALS(sna_th_fid_vals), 0xf0,
1154                         "Format Identification", HFILL }},
1155
1156                 { &hf_sna_th_mpf,
1157                 { "Mapping Field",              "sna.th.mpf", FT_UINT8, BASE_DEC, VALS(sna_th_mpf_vals), 0x0c,
1158                         "The Mapping Field specifies whether the information field"
1159                         " associated with the TH is a complete or partial BIU.", HFILL }},
1160
1161                 { &hf_sna_th_odai,
1162                 { "ODAI Assignment Indicator",  "sna.th.odai", FT_UINT8, BASE_DEC, NULL, 0x02,
1163                         "The ODAI indicates which node assigned the OAF'-DAF' values"
1164                         " carried in the TH.", HFILL }},
1165
1166                 { &hf_sna_th_efi,
1167                 { "Expedited Flow Indicator",   "sna.th.efi", FT_UINT8, BASE_DEC, VALS(sna_th_efi_vals), 0x01,
1168                         "The EFI designates whether the PIU belongs to the normal"
1169                         " or expedited flow.", HFILL }},
1170
1171                 { &hf_sna_th_daf,
1172                 { "Destination Address Field",  "sna.th.daf", FT_UINT16, BASE_HEX, NULL, 0x0,
1173                         "", HFILL }},
1174
1175                 { &hf_sna_th_oaf,
1176                 { "Origin Address Field",       "sna.th.oaf", FT_UINT16, BASE_HEX, NULL, 0x0,
1177                         "", HFILL }},
1178
1179                 { &hf_sna_th_snf,
1180                 { "Sequence Number Field",      "sna.th.snf", FT_UINT16, BASE_DEC, NULL, 0x0,
1181                         "The Sequence Number Field contains a numerical identifier for"
1182                         " the associated BIU.", HFILL }},
1183
1184                 { &hf_sna_th_dcf,
1185                 { "Data Count Field",   "sna.th.dcf", FT_UINT16, BASE_DEC, NULL, 0x0,
1186                         "A binary count of the number of bytes in the BIU or BIU segment associated "
1187                         "with the tranmission header. The count does not include any of the bytes "
1188                         "in the transmission header.", HFILL }},
1189
1190                 { &hf_sna_th_lsid,
1191                 { "Local Session Identification",       "sna.th.lsid", FT_UINT8, BASE_HEX, NULL, 0x0,
1192                         "", HFILL }},
1193
1194                 { &hf_sna_th_tg_sweep,
1195                 { "Transmission Group Sweep",           "sna.th.tg_sweep", FT_UINT8, BASE_DEC,
1196                         VALS(sna_th_tg_sweep_vals), 0x08,
1197                         "", HFILL }},
1198
1199                 { &hf_sna_th_er_vr_supp_ind,
1200                 { "ER and VR Support Indicator",        "sna.th.er_vr_supp_ind", FT_UINT8, BASE_DEC,
1201                         VALS(sna_th_er_vr_supp_ind_vals), 0x04,
1202                         "", HFILL }},
1203
1204                 { &hf_sna_th_vr_pac_cnt_ind,
1205                 { "Virtual Route Pacing Count Indicator",       "sna.th.vr_pac_cnt_ind",
1206                         FT_UINT8, BASE_DEC, VALS(sna_th_vr_pac_cnt_ind_vals), 0x02,
1207                         "", HFILL }},
1208
1209                 { &hf_sna_th_ntwk_prty,
1210                 { "Network Priority",   "sna.th.ntwk_prty",
1211                         FT_UINT8, BASE_DEC, VALS(sna_th_ntwk_prty_vals), 0x01,
1212                         "", HFILL }},
1213
1214                 { &hf_sna_th_tgsf,
1215                 { "Transmission Group Segmenting Field",        "sna.th.tgsf",
1216                         FT_UINT8, BASE_HEX, VALS(sna_th_tgsf_vals), 0xc0,
1217                         "", HFILL }},
1218
1219                 { &hf_sna_th_mft,
1220                 { "MPR FID4 Type",      "sna.th.mft", FT_BOOLEAN, BASE_NONE, NULL, 0x04,
1221                         "", HFILL }},
1222
1223                 { &hf_sna_th_piubf,
1224                 { "PIU Blocking Field", "sna.th.piubf", FT_UINT8, BASE_HEX,
1225                         VALS(sna_th_piubf_vals), 0x03,
1226                         "Specifies whether this frame contains a single PIU or multiple PIUs.", HFILL }},
1227
1228                 { &hf_sna_th_iern,
1229                 { "Initial Explicit Route Number",      "sna.th.iern", FT_UINT8, BASE_DEC, NULL, 0xf0,
1230                         "", HFILL }},
1231
1232                 { &hf_sna_th_nlpoi,
1233                 { "NLP Offset Indicator",       "sna.th.nlpoi", FT_UINT8, BASE_DEC,
1234                         VALS(sna_th_nlpoi_vals), 0x80,
1235                         "", HFILL }},
1236
1237                 { &hf_sna_th_nlp_cp,
1238                 { "NLP Count or Padding",       "sna.th.nlp_cp", FT_UINT8, BASE_DEC, NULL, 0x70,
1239                         "", HFILL }},
1240
1241                 { &hf_sna_th_ern,
1242                 { "Explicit Route Number",      "sna.th.ern", FT_UINT8, BASE_DEC, NULL, 0x0f,
1243                         "The ERN in a TH identifies an explicit route direction of flow.", HFILL }},
1244
1245                 { &hf_sna_th_vrn,
1246                 { "Virtual Route Number",       "sna.th.vrn", FT_UINT8, BASE_DEC, NULL, 0xf0,
1247                         "", HFILL }},
1248
1249                 { &hf_sna_th_tpf,
1250                 { "Transmission Priority Field",        "sna.th.tpf", FT_UINT8, BASE_HEX,
1251                         VALS(sna_th_tpf_vals), 0x03,
1252                         "", HFILL }},
1253
1254                 { &hf_sna_th_vr_cwi,
1255                 { "Virtual Route Change Window Indicator",      "sna.th.vr_cwi", FT_UINT16, BASE_DEC,
1256                         VALS(sna_th_vr_cwi_vals), 0x8000,
1257                         "Used to change the window size of the virtual route by 1.", HFILL }},
1258
1259                 { &hf_sna_th_tg_nonfifo_ind,
1260                 { "Transmission Group Non-FIFO Indicator",      "sna.th.tg_nonfifo_ind", FT_BOOLEAN, 16,
1261                         TFS(&sna_th_tg_nonfifo_ind_truth), 0x4000,
1262                         "Indicates whether or not FIFO discipline is to enforced in "
1263                         "transmitting PIUs through the tranmission groups to prevent the PIUs "
1264                         "getting out of sequence during transmission over the TGs.", HFILL }},
1265
1266                 { &hf_sna_th_vr_sqti,
1267                 { "Virtual Route Sequence and Type Indicator",  "sna.th.vr_sqti", FT_UINT16, BASE_HEX,
1268                         VALS(sna_th_vr_sqti_vals), 0x3000,
1269                         "Specifies the PIU type.", HFILL }},
1270
1271                 { &hf_sna_th_tg_snf,
1272                 { "Transmission Group Sequence Number Field",   "sna.th.tg_snf", FT_UINT16, BASE_DEC,
1273                         NULL, 0x0fff,
1274                         "", HFILL }},
1275
1276                 { &hf_sna_th_vrprq,
1277                 { "Virtual Route Pacing Request",       "sna.th.vrprq", FT_BOOLEAN, 16,
1278                         TFS(&sna_th_vrprq_truth), 0x8000,
1279                         "", HFILL }},
1280
1281                 { &hf_sna_th_vrprs,
1282                 { "Virtual Route Pacing Response",      "sna.th.vrprs", FT_BOOLEAN, 16,
1283                         TFS(&sna_th_vrprs_truth), 0x4000,
1284                         "", HFILL }},
1285
1286                 { &hf_sna_th_vr_cwri,
1287                 { "Virtual Route Change Window Reply Indicator",        "sna.th.vr_cwri", FT_UINT16, BASE_DEC,
1288                         VALS(sna_th_vr_cwri_vals), 0x2000,
1289                         "Permits changing of the window size by 1 for PIUs received by the "
1290                         "sender of this bit.", HFILL }},
1291
1292                 { &hf_sna_th_vr_rwi,
1293                 { "Virtual Route Reset Window Indicator",       "sna.th.vr_rwi", FT_BOOLEAN, 16,
1294                         TFS(&sna_th_vr_rwi_truth), 0x1000,
1295                         "Indicates severe congestion in a node on the virtual route.", HFILL }},
1296
1297                 { &hf_sna_th_vr_snf_send,
1298                 { "Virtual Route Send Sequence Number Field",   "sna.th.vr_snf_send", FT_UINT16, BASE_DEC,
1299                         NULL, 0x0fff,
1300                         "", HFILL }},
1301
1302                 { &hf_sna_th_dsaf,
1303                 { "Destination Subarea Address Field",  "sna.th.dsaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1304                         "", HFILL }},
1305
1306                 { &hf_sna_th_osaf,
1307                 { "Origin Subarea Address Field",       "sna.th.osaf", FT_UINT32, BASE_HEX, NULL, 0x0,
1308                         "", HFILL }},
1309
1310                 { &hf_sna_th_snai,
1311                 { "SNA Indicator",      "sna.th.snai", FT_BOOLEAN, 8, NULL, 0x10,
1312                         "Used to identify whether the PIU originated or is destined for "
1313                         "an SNA or non-SNA device.", HFILL }},
1314
1315                 { &hf_sna_th_def,
1316                 { "Destination Element Field",  "sna.th.def", FT_UINT16, BASE_HEX, NULL, 0x0,
1317                         "", HFILL }},
1318
1319                 { &hf_sna_th_oef,
1320                 { "Origin Element Field",       "sna.th.oef", FT_UINT16, BASE_HEX, NULL, 0x0,
1321                         "", HFILL }},
1322
1323                 { &hf_sna_th_sa,
1324                 { "Session Address",    "sna.th.sa", FT_BYTES, BASE_HEX, NULL, 0x0,
1325                         "", HFILL }},
1326
1327                 { &hf_sna_th_cmd_fmt,
1328                 { "Command Format",     "sna.th.cmd_fmt", FT_UINT8, BASE_HEX, NULL, 0x0,
1329                         "", HFILL }},
1330
1331                 { &hf_sna_th_cmd_type,
1332                 { "Command Type",       "sna.th.cmd_type", FT_UINT8, BASE_HEX, NULL, 0x0,
1333                         "", HFILL }},
1334
1335                 { &hf_sna_th_cmd_sn,
1336                 { "Command Sequence Number",    "sna.th.cmd_sn", FT_UINT16, BASE_DEC, NULL, 0x0,
1337                         "", HFILL }},
1338
1339                 { &hf_sna_nlp_nhdr,
1340                 { "Network Layer Packet Header",        "sna.nlp.nhdr", FT_NONE, BASE_NONE, NULL, 0x0,
1341                         "Network Layer Packet Header (NHDR)", HFILL }},
1342
1343                 { &hf_sna_nlp_nhdr_0,
1344                 { "Network Layer Packet Header Byte 0", "sna.nlp.nhdr.0", FT_UINT8, BASE_HEX, NULL, 0x0,
1345                         "Byte 0 of Network Layer Packet contains SM and TPF", HFILL }},
1346
1347                 { &hf_sna_nlp_nhdr_1,
1348                 { "Network Layer Packet Header Bype 1", "sna.nlp.nhdr.1", FT_UINT8, BASE_HEX, NULL, 0x0,
1349                         "Byte 1 of Network Layer Packet contains FT,"
1350                         " Time Sensitive Packet Indicator and Congestion Indicator", HFILL }},
1351
1352                 { &hf_sna_nlp_sm,
1353                 { "Switching Mode Field",       "sna.nlp.nhdr.sm", FT_UINT8, BASE_HEX,
1354                         VALS(sna_nlp_sm_vals), 0xe0,
1355                         "", HFILL }},
1356
1357                 { &hf_sna_nlp_tpf,
1358                 { "Transmission Priority Field",        "sna.nlp.nhdr.tpf", FT_UINT8, BASE_HEX,
1359                         VALS(sna_th_tpf_vals), 0x06,
1360                         "", HFILL }},
1361
1362                 { &hf_sna_nlp_ft,
1363                 { "Function Type",      "sna.nlp.nhdr.ft", FT_UINT8, BASE_HEX,
1364                         VALS(sna_nlp_ft_vals), 0xF0,
1365                         "", HFILL }},
1366
1367                 { &hf_sna_nlp_tspi,
1368                 { "Time Sensitive Packet Indicator",    "sna.nlp.nhdr.tspi", FT_BOOLEAN, 8,
1369                         TFS(&sna_nlp_tspi_truth), 0x08,
1370                         "", HFILL }},
1371
1372                 { &hf_sna_nlp_slowdn1,
1373                 { "Slowdown 1", "sna.nlp.nhdr.slowdn1", FT_BOOLEAN, 8,
1374                         TFS(&sna_nlp_slowdn1_truth), 0x04,
1375                         "", HFILL }},
1376
1377                 { &hf_sna_nlp_slowdn2,
1378                 { "Slowdown 2", "sna.nlp.nhdr.slowdn2", FT_BOOLEAN, 8,
1379                         TFS(&sna_nlp_slowdn2_truth), 0x02,
1380                         "", HFILL }},
1381
1382                 { &hf_sna_nlp_fra,
1383                 { "Function Routing Address Entry",     "sna.nlp.nhdr.fra", FT_BYTES, BASE_NONE, NULL, 0,
1384                         "", HFILL }},
1385
1386                 { &hf_sna_nlp_anr,
1387                 { "Automatic Network Routing Entry",    "sna.nlp.nhdr.anr", FT_BYTES, BASE_HEX, NULL, 0,
1388                         "", HFILL }},
1389
1390                 { &hf_sna_nlp_frh,
1391                 { "Transmission Priority Field",        "sna.nlp.frh", FT_UINT8, BASE_HEX,
1392                         VALS(sna_nlp_frh_vals), 0, "", HFILL }},
1393
1394                 { &hf_sna_nlp_thdr,
1395                 { "RTP Transport Header",       "sna.nlp.thdr", FT_NONE, BASE_NONE, NULL, 0x0,
1396                         "RTP Transport Header (THDR)", HFILL }},
1397
1398                 { &hf_sna_nlp_tcid,
1399                 { "Transport Connection Identifier",    "sna.nlp.thdr.tcid", FT_BYTES, BASE_HEX, NULL, 0x0,
1400                         "Transport Connection Identifier (TCID)", HFILL }},
1401
1402                 { &hf_sna_nlp_thdr_8,
1403                 { "RTP Transport Packet Header Bype 8", "sna.nlp.thdr.8", FT_UINT8, BASE_HEX, NULL, 0x0,
1404                         "Byte 8 of RTP Transport Packet Header", HFILL }},
1405
1406                 { &hf_sna_nlp_setupi,
1407                 { "Setup Indicator",    "sna.nlp.thdr.setupi", FT_BOOLEAN, 8,
1408                         TFS(&sna_nlp_setupi_truth), 0x40,
1409                         "", HFILL }},
1410
1411                 { &hf_sna_nlp_somi,
1412                 { "Start Of Message Indicator", "sna.nlp.thdr.somi", FT_BOOLEAN, 8,
1413                         TFS(&sna_nlp_somi_truth), 0x20,
1414                         "", HFILL }},
1415
1416                 { &hf_sna_nlp_eomi,
1417                 { "End Of Message Indicator",   "sna.nlp.thdr.eomi", FT_BOOLEAN, 8,
1418                         TFS(&sna_nlp_eomi_truth), 0x10,
1419                         "", HFILL }},
1420
1421                 { &hf_sna_nlp_sri,
1422                 { "Session Request Indicator",  "sna.nlp.thdr.sri", FT_BOOLEAN, 8,
1423                         TFS(&sna_nlp_sri_truth), 0x08,
1424                         "", HFILL }},
1425
1426                 { &hf_sna_nlp_rasapi,
1427                 { "Reply ASAP Indicator",       "sna.nlp.thdr.rasapi", FT_BOOLEAN, 8,
1428                         TFS(&sna_nlp_rasapi_truth), 0x04,
1429                         "", HFILL }},
1430
1431                 { &hf_sna_nlp_retryi,
1432                 { "Retry Indicator",    "sna.nlp.thdr.retryi", FT_BOOLEAN, 8,
1433                         TFS(&sna_nlp_retryi_truth), 0x02,
1434                         "", HFILL }},
1435
1436                 { &hf_sna_nlp_thdr_9,
1437                 { "RTP Transport Packet Header Bype 9", "sna.nlp.thdr.9", FT_UINT8, BASE_HEX, NULL, 0x0,
1438                         "Byte 9 of RTP Transport Packet Header", HFILL }},
1439
1440                 { &hf_sna_nlp_lmi,
1441                 { "Last Message Indicator",     "sna.nlp.thdr.lmi", FT_BOOLEAN, 8,
1442                         TFS(&sna_nlp_lmi_truth), 0x80,
1443                         "", HFILL }},
1444
1445                 { &hf_sna_nlp_cqfi,
1446                 { "Connection Qualifyer Field Indicator",       "sna.nlp.thdr.cqfi", FT_BOOLEAN, 8,
1447                         TFS(&sna_nlp_cqfi_truth), 0x08,
1448                         "", HFILL }},
1449
1450                 { &hf_sna_nlp_osi,
1451                 { "Optional Segments Present Indicator",        "sna.nlp.thdr.osi", FT_BOOLEAN, 8,
1452                         TFS(&sna_nlp_osi_truth), 0x04,
1453                         "", HFILL }},
1454
1455                 { &hf_sna_nlp_offset,
1456                 { "Data Offset/4",      "sna.nlp.thdr.offset", FT_UINT16, BASE_HEX, NULL, 0x0,
1457                         "Data Offset in words", HFILL }},
1458
1459                 { &hf_sna_nlp_dlf,
1460                 { "Data Length Field",  "sna.nlp.thdr.dlf", FT_UINT32, BASE_HEX, NULL, 0x0,
1461                         "Data Length Field", HFILL }},
1462
1463                 { &hf_sna_nlp_bsn,
1464                 { "Byte Sequence Number",       "sna.nlp.thdr.bsn", FT_UINT32, BASE_HEX, NULL, 0x0,
1465                         "Byte Sequence Number", HFILL }},
1466
1467
1468                 { &hf_sna_rh,
1469                 { "Request/Response Header",    "sna.rh", FT_NONE, BASE_NONE, NULL, 0x0,
1470                         "", HFILL }},
1471
1472                 { &hf_sna_rh_0,
1473                 { "Request/Response Header Byte 0",     "sna.rh.0", FT_UINT8, BASE_HEX, NULL, 0x0,
1474                         "", HFILL }},
1475
1476                 { &hf_sna_rh_1,
1477                 { "Request/Response Header Byte 1",     "sna.rh.1", FT_UINT8, BASE_HEX, NULL, 0x0,
1478                         "", HFILL }},
1479
1480                 { &hf_sna_rh_2,
1481                 { "Request/Response Header Byte 2",     "sna.rh.2", FT_UINT8, BASE_HEX, NULL, 0x0,
1482                         "", HFILL }},
1483
1484                 { &hf_sna_rh_rri,
1485                 { "Request/Response Indicator", "sna.rh.rri", FT_UINT8, BASE_DEC, VALS(sna_rh_rri_vals), 0x80,
1486                         "Denotes whether this is a request or a response.", HFILL }},
1487
1488                 { &hf_sna_rh_ru_category,
1489                 { "Request/Response Unit Category",     "sna.rh.ru_category", FT_UINT8, BASE_HEX,
1490                         VALS(sna_rh_ru_category_vals), 0x60,
1491                         "", HFILL }},
1492
1493                 { &hf_sna_rh_fi,
1494                 { "Format Indicator",           "sna.rh.fi", FT_BOOLEAN, 8, TFS(&sna_rh_fi_truth), 0x08,
1495                         "", HFILL }},
1496
1497                 { &hf_sna_rh_sdi,
1498                 { "Sense Data Included",        "sna.rh.sdi", FT_BOOLEAN, 8, TFS(&sna_rh_sdi_truth), 0x04,
1499                         "Indicates that a 4-byte sense data field is included in the associated RU.", HFILL }},
1500
1501                 { &hf_sna_rh_bci,
1502                 { "Begin Chain Indicator",      "sna.rh.bci", FT_BOOLEAN, 8, TFS(&sna_rh_bci_truth), 0x02,
1503                         "", HFILL }},
1504
1505                 { &hf_sna_rh_eci,
1506                 { "End Chain Indicator",        "sna.rh.eci", FT_BOOLEAN, 8, TFS(&sna_rh_eci_truth), 0x01,
1507                         "", HFILL }},
1508
1509                 { &hf_sna_rh_dr1,
1510                 { "Definite Response 1 Indicator",      "sna.rh.dr1", FT_BOOLEAN, 8, NULL, 0x80,
1511                         "", HFILL }},
1512
1513                 { &hf_sna_rh_lcci,
1514                 { "Length-Checked Compression Indicator",       "sna.rh.lcci", FT_BOOLEAN, 8,
1515                         TFS(&sna_rh_lcci_truth), 0x40,
1516                         "", HFILL }},
1517
1518                 { &hf_sna_rh_dr2,
1519                 { "Definite Response 2 Indicator",      "sna.rh.dr2", FT_BOOLEAN, 8, NULL, 0x20,
1520                         "", HFILL }},
1521
1522                 { &hf_sna_rh_eri,
1523                 { "Exception Response Indicator",       "sna.rh.eri", FT_BOOLEAN, 8, NULL, 0x10,
1524                         "Used in conjunction with DR1I and DR2I to indicate, in a request, "
1525                         "the form of response requested.", HFILL }},
1526
1527                 { &hf_sna_rh_rti,
1528                 { "Response Type Indicator",    "sna.rh.rti", FT_BOOLEAN, 8, TFS(&sna_rh_rti_truth), 0x10,
1529                         "", HFILL }},
1530
1531                 { &hf_sna_rh_rlwi,
1532                 { "Request Larger Window Indicator",    "sna.rh.rlwi", FT_BOOLEAN, 8, NULL, 0x04,
1533                         "Indicates whether a larger pacing window was requested.", HFILL }},
1534
1535                 { &hf_sna_rh_qri,
1536                 { "Queued Response Indicator",  "sna.rh.qri", FT_BOOLEAN, 8, TFS(&sna_rh_qri_truth), 0x02,
1537                         "", HFILL }},
1538
1539                 { &hf_sna_rh_pi,
1540                 { "Pacing Indicator",   "sna.rh.pi", FT_BOOLEAN, 8, NULL, 0x01,
1541                         "", HFILL }},
1542
1543                 { &hf_sna_rh_bbi,
1544                 { "Begin Bracket Indicator",    "sna.rh.bbi", FT_BOOLEAN, 8, NULL, 0x80,
1545                         "", HFILL }},
1546
1547                 { &hf_sna_rh_ebi,
1548                 { "End Bracket Indicator",      "sna.rh.ebi", FT_BOOLEAN, 8, NULL, 0x40,
1549                         "", HFILL }},
1550
1551                 { &hf_sna_rh_cdi,
1552                 { "Change Direction Indicator", "sna.rh.cdi", FT_BOOLEAN, 8, NULL, 0x20,
1553                         "", HFILL }},
1554
1555                 { &hf_sna_rh_csi,
1556                 { "Code Selection Indicator",   "sna.rh.csi", FT_UINT8, BASE_DEC, VALS(sna_rh_csi_vals), 0x08,
1557                         "Specifies the encoding used for the associated FMD RU.", HFILL }},
1558
1559                 { &hf_sna_rh_edi,
1560                 { "Enciphered Data Indicator",  "sna.rh.edi", FT_BOOLEAN, 8, NULL, 0x04,
1561                         "Indicates that information in the associated RU is enciphered under "
1562                         "session-level cryptography protocols.", HFILL }},
1563
1564                 { &hf_sna_rh_pdi,
1565                 { "Padded Data Indicator",      "sna.rh.pdi", FT_BOOLEAN, 8, NULL, 0x02,
1566                         "Indicates that the RU was padded at the end, before encipherment, to the next "
1567                         "integral multiple of 8 bytes.", HFILL }},
1568
1569                 { &hf_sna_rh_cebi,
1570                 { "Conditional End Bracket Indicator",  "sna.rh.cebi", FT_BOOLEAN, 8, NULL, 0x01,
1571                         "Used to indicate the beginning or end of a group of exchanged "
1572                         "requests and responses called a bracket. Only used on LU-LU sessions.", HFILL }},
1573
1574 /*                { &hf_sna_ru,
1575                 { "Request/Response Unit",      "sna.ru", FT_NONE, BASE_NONE, NULL, 0x0,
1576                         "", HFILL }},*/
1577         };
1578         static gint *ett[] = {
1579                 &ett_sna,
1580                 &ett_sna_th,
1581                 &ett_sna_th_fid,
1582                 &ett_sna_nlp_nhdr,
1583                 &ett_sna_nlp_nhdr_0,
1584                 &ett_sna_nlp_nhdr_1,
1585                 &ett_sna_nlp_thdr,
1586                 &ett_sna_nlp_thdr_8,
1587                 &ett_sna_nlp_thdr_9,
1588                 &ett_sna_rh,
1589                 &ett_sna_rh_0,
1590                 &ett_sna_rh_1,
1591                 &ett_sna_rh_2,
1592         };
1593
1594         proto_sna = proto_register_protocol("Systems Network Architecture",
1595             "SNA", "sna");
1596         proto_register_field_array(proto_sna, hf, array_length(hf));
1597         proto_register_subtree_array(ett, array_length(ett));
1598         register_dissector("sna", dissect_sna, proto_sna);
1599 }
1600
1601 void
1602 proto_reg_handoff_sna(void)
1603 {
1604         dissector_handle_t sna_handle;
1605
1606         sna_handle = find_dissector("sna");
1607         dissector_add("llc.dsap", SAP_SNA_PATHCTRL, sna_handle);
1608         /* RFC 2043 */
1609         dissector_add("ppp.protocol", PPP_SNA, sna_handle);
1610         data_handle = find_dissector("data");
1611 }