Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-radius.h
blobfce240c788d2800cab530945453ec15903388c3d
1 /*
2 * packet-radius.h
4 * Definitions for RADIUS packet disassembly
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include <epan/proto.h>
14 /* radius packet-type codes */
15 /* 09/12/2011: Updated from IANA:
16 * http://www.iana.org/assignments/radius-types/radius-types.xml#radius-types-27
18 #define RADIUS_PKT_TYPE_ACCESS_REQUEST 1
19 #define RADIUS_PKT_TYPE_ACCESS_ACCEPT 2
20 #define RADIUS_PKT_TYPE_ACCESS_REJECT 3
21 #define RADIUS_PKT_TYPE_ACCOUNTING_REQUEST 4
22 #define RADIUS_PKT_TYPE_ACCOUNTING_RESPONSE 5
23 #define RADIUS_PKT_TYPE_ACCOUNTING_STATUS 6
24 #define RADIUS_PKT_TYPE_PASSWORD_REQUEST 7
25 #define RADIUS_PKT_TYPE_PASSWORD_ACK 8
26 #define RADIUS_PKT_TYPE_PASSWORD_REJECT 9
27 #define RADIUS_PKT_TYPE_ACCOUNTING_MESSAGE 10
28 #define RADIUS_PKT_TYPE_ACCESS_CHALLENGE 11
29 #define RADIUS_PKT_TYPE_STATUS_SERVER 12
30 #define RADIUS_PKT_TYPE_STATUS_CLIENT 13
32 #define RADIUS_PKT_TYPE_RESOURCE_FREE_REQUEST 21
33 #define RADIUS_PKT_TYPE_RESOURCE_FREE_RESPONSE 22
34 #define RADIUS_PKT_TYPE_RESOURCE_QUERY_REQUEST 23
35 #define RADIUS_PKT_TYPE_RESOURCE_QUERY_RESPONSE 24
36 #define RADIUS_PKT_TYPE_ALTERNATE_RESOURCE_RECLAIM_REQUEST 25
37 #define RADIUS_PKT_TYPE_NAS_REBOOT_REQUEST 26
38 #define RADIUS_PKT_TYPE_NAS_REBOOT_RESPONSE 27
40 #define RADIUS_PKT_TYPE_NEXT_PASSCODE 29
41 #define RADIUS_PKT_TYPE_NEW_PIN 30
42 #define RADIUS_PKT_TYPE_TERMINATE_SESSION 31
43 #define RADIUS_PKT_TYPE_PASSWORD_EXPIRED 32
44 #define RADIUS_PKT_TYPE_EVENT_REQUEST 33
45 #define RADIUS_PKT_TYPE_EVENT_RESPONSE 34
47 #define RADIUS_PKT_TYPE_DISCONNECT_REQUEST 40
48 #define RADIUS_PKT_TYPE_DISCONNECT_ACK 41
49 #define RADIUS_PKT_TYPE_DISCONNECT_NAK 42
50 #define RADIUS_PKT_TYPE_COA_REQUEST 43
51 #define RADIUS_PKT_TYPE_COA_ACK 44
52 #define RADIUS_PKT_TYPE_COA_NAK 45
54 #define RADIUS_PKT_TYPE_IP_ADDRESS_ALLOCATE 50
55 #define RADIUS_PKT_TYPE_IP_ADDRESS_RELEASE 51
57 /* ALU proprietary packet type codes */
58 #define RADIUS_PKT_TYPE_ALU_STATE_REQUEST 129
59 #define RADIUS_PKT_TYPE_ALU_STATE_ACCEPT 130
60 #define RADIUS_PKT_TYPE_ALU_STATE_REJECT 131
61 #define RADIUS_PKT_TYPE_ALU_STATE_ERROR 132
63 /* Radius Attribute Types*/
64 /* 09/12/2011: Updated from IANA:
65 * http://www.iana.org/assignments/radius-types/radius-types.xml#radius-types-1
67 #define RADIUS_ATTR_TYPE_VENDOR_SPECIFIC 26
68 #define RADIUS_ATTR_TYPE_EAP_MESSAGE 79
69 #define RADIUS_ATTR_TYPE_MESSAGE_AUTHENTICATOR 80
70 #define RADIUS_ATTR_TYPE_EXTENDED_1 241
71 #define RADIUS_ATTR_TYPE_EXTENDED_2 242
72 #define RADIUS_ATTR_TYPE_EXTENDED_3 243
73 #define RADIUS_ATTR_TYPE_EXTENDED_4 244
74 #define RADIUS_ATTR_TYPE_EXTENDED_5 245
75 #define RADIUS_ATTR_TYPE_EXTENDED_6 246
77 #define RADIUS_ATTR_TYPE_IS_EXTENDED(avp_type) \
78 ((avp_type) == RADIUS_ATTR_TYPE_EXTENDED_1 || \
79 (avp_type) == RADIUS_ATTR_TYPE_EXTENDED_2 || \
80 (avp_type) == RADIUS_ATTR_TYPE_EXTENDED_3 || \
81 (avp_type) == RADIUS_ATTR_TYPE_EXTENDED_4 || \
82 (avp_type) == RADIUS_ATTR_TYPE_EXTENDED_5 || \
83 (avp_type) == RADIUS_ATTR_TYPE_EXTENDED_6)
85 #define RADIUS_ATTR_TYPE_IS_EXTENDED_LONG(avp_type) \
86 ((avp_type) == RADIUS_ATTR_TYPE_EXTENDED_5 || \
87 (avp_type) == RADIUS_ATTR_TYPE_EXTENDED_6)
90 typedef struct _radius_vendor_info_t {
91 char *name;
92 unsigned code;
93 GHashTable* attrs_by_id;
94 int ett;
95 unsigned type_octets;
96 unsigned length_octets;
97 bool has_flags;
98 } radius_vendor_info_t;
100 typedef struct _radius_call_t
102 unsigned code;
103 unsigned ident;
104 uint8_t req_authenticator[16];
106 uint32_t req_num; /* frame number request seen */
107 uint32_t rsp_num; /* frame number response seen */
108 uint32_t rspcode;
109 nstime_t req_time;
110 bool responded;
111 } radius_call_t;
113 typedef struct _radius_attr_info_t radius_attr_info_t;
114 typedef void (radius_attr_dissector_t)(radius_attr_info_t*, proto_tree*, packet_info*, tvbuff_t*, int, int, proto_item* );
116 typedef const char* (radius_avp_dissector_t)(proto_tree*,tvbuff_t*, packet_info*);
118 typedef union _radius_attr_type_t {
119 uint8_t u8_code[2];
120 unsigned value;
121 } radius_attr_type_t;
123 struct _radius_attr_info_t {
124 char *name;
125 radius_attr_type_t code;
126 unsigned encrypt; /* 0 or value for "encrypt=" option */
127 bool tagged;
128 bool concat;
129 radius_attr_dissector_t* type;
130 radius_avp_dissector_t* dissector;
131 const value_string *vs;
132 int ett;
133 int hf;
134 int hf_alt; /* 64-bit version for integers, IPv6 for radius_combo_ip */
135 int hf_enc; /* version for encrypted attributes */
136 int hf_tag;
137 int hf_len;
138 GHashTable* tlvs_by_id; /**< Owns the data (see also radius_dictionary_t). */
142 * Attributes and Vendors are a mapping between IDs and names. Names
143 * are normally uniquely identified by a number. Identifiers for
144 * Vendor-Specific Attributes (VSA) are scoped within the vendor.
146 * The attribute/vendor structures are owned by the by_id tables,
147 * the by_name tables point to the same data.
149 typedef struct _radius_dictionary_t {
150 GHashTable* attrs_by_id;
151 GHashTable* attrs_by_name;
152 GHashTable* vendors_by_id;
153 GHashTable* vendors_by_name;
154 GHashTable* tlvs_by_name; /**< Used for debugging duplicate assignments, does not own the data. */
155 } radius_dictionary_t;
157 radius_attr_dissector_t radius_integer;
158 radius_attr_dissector_t radius_string;
159 radius_attr_dissector_t radius_octets;
160 radius_attr_dissector_t radius_ipaddr;
161 radius_attr_dissector_t radius_ipv6addr;
162 radius_attr_dissector_t radius_ipv6prefix;
163 radius_attr_dissector_t radius_ipxnet;
164 radius_attr_dissector_t radius_date;
165 radius_attr_dissector_t radius_abinary;
166 radius_attr_dissector_t radius_ether;
167 radius_attr_dissector_t radius_ifid;
168 radius_attr_dissector_t radius_byte;
169 radius_attr_dissector_t radius_short;
170 radius_attr_dissector_t radius_signed;
171 radius_attr_dissector_t radius_combo_ip;
172 radius_attr_dissector_t radius_tlv;
174 extern void radius_register_avp_dissector(uint32_t vendor_id, uint32_t attribute_id, radius_avp_dissector_t dissector);
175 void dissect_attribute_value_pairs(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, int offset, unsigned length, radius_call_t *radius_call);
176 extern void free_radius_attr_info(void *data);
178 /* from radius_dict.l */
179 bool radius_load_dictionary (radius_dictionary_t* dict, char* directory, const char* filename, char** err_str);