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