Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-atn-sl.c
blob30540ecefd5df81ddca69299bffa5a7cee9d7471
1 /* packet-atn-sl.c
2 * Routines for ISO/OSI network protocol packet disassembly
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
11 #include "config.h"
13 #include <wsutil/array.h>
14 #include <epan/packet.h>
16 void proto_register_atn_sl(void);
17 void proto_reg_handoff_atn_sl(void);
19 /* protocols and fields */
21 static int proto_atn_sl;
22 static int ett_atn_sl;
24 static int hf_atn_sl_tt;
25 static int hf_atn_sl_sc;
27 /* ATN traffic types (ICAO doc 9705 Edition3 SV5 5.6.2.2.6.7.3) */
28 #define ATN_TT_ATSC_NO_PREFERENCE 0x01
29 #define ATN_TT_ATSC_CLASS_A 0x10
30 #define ATN_TT_ATSC_CLASS_B 0x11
31 #define ATN_TT_ATSC_CLASS_C 0x12
32 #define ATN_TT_ATSC_CLASS_D 0x13
33 #define ATN_TT_ATSC_CLASS_E 0x14
34 #define ATN_TT_ATSC_CLASS_F 0x15
35 #define ATN_TT_ATSC_CLASS_G 0x16
36 #define ATN_TT_ATSC_CLASS_H 0x17
37 #define ATN_TT_AOC_NO_PREFERENCE 0x21
38 #define ATN_TT_AOC_G 0x22
39 #define ATN_TT_AOC_V 0x23
40 #define ATN_TT_AOC_S 0x24
41 #define ATN_TT_AOC_H 0x25
42 #define ATN_TT_AOC_M 0x26
43 #define ATN_TT_AOC_G_V 0x27
44 #define ATN_TT_AOC_G_V_S 0x28
45 #define ATN_TT_AOC_G_V_H_S 0x29
46 #define ATN_TT_ADM_NO_PREFERENCE 0x30
47 #define ATN_TT_SYS_MGMT_NO_PREFERENCE 0x60
49 /* ATN security classification (ICAO doc 9705 Edition3 SV5 5.6.2.2.6.8.3) */
50 #define ATN_SC_UNCLASSIFIED 0x01
51 #define ATN_SC_RESTRICTED 0x02
52 #define ATN_SC_CONFIDENTIAL 0x03
53 #define ATN_SC_SECRET 0x04
54 #define ATN_SC_TOP_SECRET 0x05
56 /* ATN security label records */
57 #define OSI_OPT_SECURITY_ATN_SR 0xc0
58 #define OSI_OPT_SECURITY_ATN_TT 0x0f
59 #define OSI_OPT_SECURITY_ATN_SC 0x03
60 #define OSI_OPT_SECURITY_ATN_SR_LEN 6
61 #define OSI_OPT_SECURITY_ATN_TT_LEN 1
62 #define OSI_OPT_SECURITY_ATN_SC_LEN 1
63 #define OSI_OPT_SECURITY_ATN_SI_MAX_LEN 8
66 static const unsigned char atn_security_registration_val[] = {
67 0x06, 0x04, 0x2b, 0x1b, 0x00, 0x00
68 }; /* =iso(1).org(3).ICAO(27).ATN(0).TrafficType(0)*/
70 #if 0
71 static const value_string osi_opt_sec_atn_sr_vals[] = {
72 {OSI_OPT_SECURITY_ATN_SR, "ATN Security Label"},
73 {0, NULL}
75 #endif
77 static const value_string osi_opt_sec_atn_si_vals[] = {
78 {OSI_OPT_SECURITY_ATN_TT, "Traffic Type and Routing"},
79 {OSI_OPT_SECURITY_ATN_SC, "Security classification"},
80 {0, NULL}
83 static const value_string osi_opt_sec_atn_tt_vals[] = {
84 {ATN_TT_ATSC_NO_PREFERENCE, "ATSC No preference"},
85 {ATN_TT_ATSC_CLASS_A, "ATSC Class A"},
86 {ATN_TT_ATSC_CLASS_B, "ATSC Class B"},
87 {ATN_TT_ATSC_CLASS_C, "ATSC Class C"},
88 {ATN_TT_ATSC_CLASS_D, "ATSC Class D"},
89 {ATN_TT_ATSC_CLASS_E, "ATSC Class E"},
90 {ATN_TT_ATSC_CLASS_F, "ATSC Class F"},
91 {ATN_TT_ATSC_CLASS_G, "ATSC Class G"},
92 {ATN_TT_ATSC_CLASS_H, "ATSC Class H"},
93 {ATN_TT_AOC_NO_PREFERENCE, "AOC No preference"},
94 {ATN_TT_AOC_G, "AOC Gatelink only"},
95 {ATN_TT_AOC_V, "AOC VHF only"},
96 {ATN_TT_AOC_S, "AOC Satellite only"},
97 {ATN_TT_AOC_H, "AOC HF only"},
98 {ATN_TT_AOC_M, "AOC Mode S only"},
99 {ATN_TT_AOC_G_V, "AOC Gatelink first, then VHF"},
100 {ATN_TT_AOC_G_V_S, "AOC Gatelink first, then VHF, then Satellite"},
101 {ATN_TT_AOC_G_V_H_S, "AOC Gatelink first, then VHF, then HF, then Satellite"},
102 {ATN_TT_ADM_NO_PREFERENCE, "ATN Administrative No preference"},
103 {ATN_TT_SYS_MGMT_NO_PREFERENCE, "ATN Systems Management No preference"},
104 {0, NULL}
107 static const value_string osi_opt_sec_atn_sc_vals[] = {
108 {ATN_SC_UNCLASSIFIED, "unclassified"},
109 {ATN_SC_RESTRICTED, "restricted"},
110 {ATN_SC_CONFIDENTIAL, "confidential"},
111 {ATN_SC_SECRET, "secret"},
112 {ATN_SC_TOP_SECRET, "top secret"},
113 {0, NULL}
116 /* dissect ATN security label used for policy based interdomain routing.*/
117 /* For details see ICAO doc 9705 Edition 3 SV5 5.6.2.2.2.2 */
118 static int
119 dissect_atn_sl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
120 void* data _U_)
122 proto_item *ti;
123 proto_tree *atn_sl_tree;
124 unsigned offset = 0;
125 unsigned char len = 0;
126 uint8_t tag_name = 0;
127 unsigned security_info_end = 0;
129 ti = proto_tree_add_item(tree, proto_atn_sl, tvb, offset, -1, ENC_NA);
130 atn_sl_tree = proto_item_add_subtree(ti, ett_atn_sl);
132 /* check Security Registration Length */
133 len = tvb_get_uint8(tvb, offset);
134 if ( OSI_OPT_SECURITY_ATN_SR_LEN != len )
135 return tvb_captured_length(tvb);
136 offset++;
138 /* check Security Registration ID */
139 if ( tvb_memeql(tvb, offset, atn_security_registration_val, OSI_OPT_SECURITY_ATN_SR_LEN) )
140 return tvb_captured_length(tvb);
142 offset += OSI_OPT_SECURITY_ATN_SR_LEN;
144 /* Security Information length */
145 len = tvb_get_uint8(tvb, offset);
147 if ( OSI_OPT_SECURITY_ATN_SI_MAX_LEN < len )
148 return tvb_captured_length(tvb);
150 offset++;
152 security_info_end = offset + len;
153 while ( offset < security_info_end ) {
154 /* check tag name length*/
155 len = tvb_get_uint8(tvb, offset); /* check tag name length*/
156 if ( len != 1 )
157 return tvb_captured_length(tvb);
159 offset++;
161 tag_name = tvb_get_uint8(tvb, offset);
162 offset++;
164 switch(tag_name) {
165 case OSI_OPT_SECURITY_ATN_TT:
166 /* check tag set length*/
167 len = tvb_get_uint8(tvb, offset);
168 if ( len != OSI_OPT_SECURITY_ATN_TT_LEN )
169 return tvb_captured_length(tvb);
171 offset++;
172 proto_tree_add_uint_format(atn_sl_tree, hf_atn_sl_tt, tvb, offset, 1,
173 tvb_get_uint8(tvb, offset), "%s: %s",
174 val_to_str(OSI_OPT_SECURITY_ATN_TT, osi_opt_sec_atn_si_vals, "Unknown (0x%x)"),
175 val_to_str(tvb_get_uint8(tvb, offset ), osi_opt_sec_atn_tt_vals, "Unknown (0x%x)"));
176 offset += len;
177 break;
179 case OSI_OPT_SECURITY_ATN_SC:
180 /* check tag set length*/
181 len = tvb_get_uint8(tvb, offset);
182 if ( len != OSI_OPT_SECURITY_ATN_SC_LEN )
183 return tvb_captured_length(tvb);
185 offset++;
186 proto_tree_add_uint_format(atn_sl_tree, hf_atn_sl_sc, tvb, offset, 1,
187 tvb_get_uint8(tvb, offset), "%s: %s",
188 val_to_str(OSI_OPT_SECURITY_ATN_SC, osi_opt_sec_atn_si_vals, "Unknown (0x%x)"),
189 val_to_str(tvb_get_uint8(tvb, offset ), osi_opt_sec_atn_sc_vals, "Unknown (0x%x)"));
190 offset += len;
191 break;
193 default:
194 return tvb_captured_length(tvb);
197 return tvb_captured_length(tvb);
200 void
201 proto_register_atn_sl(void)
203 static hf_register_info hf[] = {
204 { &hf_atn_sl_tt,
205 { "ATN traffic type", "atn_sl.tt", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
207 { &hf_atn_sl_sc,
208 { "ATN security classification", "atn_sl.sc", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
210 static int *ett[] = {
211 &ett_atn_sl,
214 proto_atn_sl = proto_register_protocol("ATN Security Label", "ATN SL", "atn_sl");
215 proto_register_field_array(proto_atn_sl, hf, array_length(hf));
216 proto_register_subtree_array(ett, array_length(ett));
219 void
220 proto_reg_handoff_atn_sl(void)
222 dissector_handle_t atn_sl_handle;
224 atn_sl_handle = create_dissector_handle(dissect_atn_sl, proto_atn_sl);
225 dissector_add_for_decode_as("osi.opt_security", atn_sl_handle);
229 * Editor modelines - https://www.wireshark.org/tools/modelines.html
231 * Local variables:
232 * c-basic-offset: 2
233 * tab-width: 8
234 * indent-tabs-mode: nil
235 * End:
237 * vi: set shiftwidth=2 tabstop=8 expandtab:
238 * :indentSize=4:tabSize=8:noTabs=true: