print-radius.c revision 1.11 1 1.1 christos /*
2 1.1 christos * Copyright (C) 2000 Alfredo Andres Omella. All rights reserved.
3 1.1 christos *
4 1.1 christos * Redistribution and use in source and binary forms, with or without
5 1.1 christos * modification, are permitted provided that the following conditions
6 1.1 christos * are met:
7 1.1 christos *
8 1.1 christos * 1. Redistributions of source code must retain the above copyright
9 1.1 christos * notice, this list of conditions and the following disclaimer.
10 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 christos * notice, this list of conditions and the following disclaimer in
12 1.1 christos * the documentation and/or other materials provided with the
13 1.1 christos * distribution.
14 1.1 christos * 3. The names of the authors may not be used to endorse or promote
15 1.1 christos * products derived from this software without specific prior
16 1.1 christos * written permission.
17 1.1 christos *
18 1.1 christos * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
19 1.1 christos * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
20 1.1 christos * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 1.1 christos */
22 1.8 spz
23 1.8 spz /* \summary: Radius protocol printer */
24 1.8 spz
25 1.1 christos /*
26 1.1 christos * Radius printer routines as specified on:
27 1.1 christos *
28 1.1 christos * RFC 2865:
29 1.1 christos * "Remote Authentication Dial In User Service (RADIUS)"
30 1.1 christos *
31 1.1 christos * RFC 2866:
32 1.1 christos * "RADIUS Accounting"
33 1.1 christos *
34 1.1 christos * RFC 2867:
35 1.1 christos * "RADIUS Accounting Modifications for Tunnel Protocol Support"
36 1.1 christos *
37 1.1 christos * RFC 2868:
38 1.1 christos * "RADIUS Attributes for Tunnel Protocol Support"
39 1.1 christos *
40 1.1 christos * RFC 2869:
41 1.1 christos * "RADIUS Extensions"
42 1.1 christos *
43 1.10 christos * RFC 3162:
44 1.10 christos * "RADIUS and IPv6"
45 1.10 christos *
46 1.7 christos * RFC 3580:
47 1.7 christos * "IEEE 802.1X Remote Authentication Dial In User Service (RADIUS)"
48 1.7 christos * "Usage Guidelines"
49 1.7 christos *
50 1.10 christos * RFC 4072:
51 1.10 christos * "Diameter Extensible Authentication Protocol (EAP) Application"
52 1.10 christos *
53 1.6 christos * RFC 4675:
54 1.6 christos * "RADIUS Attributes for Virtual LAN and Priority Support"
55 1.6 christos *
56 1.10 christos * RFC 4818:
57 1.10 christos * "RADIUS Delegated-IPv6-Prefix Attribute"
58 1.10 christos *
59 1.10 christos * RFC 4849:
60 1.10 christos * "RADIUS Filter Rule Attribute"
61 1.10 christos *
62 1.10 christos * RFC 5090:
63 1.10 christos * "RADIUS Extension for Digest Authentication"
64 1.10 christos *
65 1.6 christos * RFC 5176:
66 1.6 christos * "Dynamic Authorization Extensions to RADIUS"
67 1.6 christos *
68 1.10 christos * RFC 5447:
69 1.10 christos * "Diameter Mobile IPv6"
70 1.10 christos *
71 1.10 christos * RFC 5580:
72 1.10 christos * "Carrying Location Objects in RADIUS and Diameter"
73 1.10 christos *
74 1.10 christos * RFC 6572:
75 1.10 christos * "RADIUS Support for Proxy Mobile IPv6"
76 1.10 christos *
77 1.10 christos * RFC 7155:
78 1.10 christos * "Diameter Network Access Server Application"
79 1.10 christos *
80 1.1 christos * Alfredo Andres Omella (aandres (at) s21sec.com) v0.1 2000/09/15
81 1.1 christos *
82 1.1 christos * TODO: Among other things to print ok MacIntosh and Vendor values
83 1.1 christos */
84 1.1 christos
85 1.7 christos #include <sys/cdefs.h>
86 1.7 christos #ifndef lint
87 1.11 christos __RCSID("$NetBSD: print-radius.c,v 1.11 2024/09/02 16:15:32 christos Exp $");
88 1.7 christos #endif
89 1.7 christos
90 1.10 christos #include <config.h>
91 1.1 christos
92 1.10 christos #include "netdissect-stdinc.h"
93 1.1 christos
94 1.1 christos #include <string.h>
95 1.1 christos
96 1.10 christos #include "netdissect-ctype.h"
97 1.10 christos
98 1.7 christos #include "netdissect.h"
99 1.1 christos #include "addrtoname.h"
100 1.1 christos #include "extract.h"
101 1.1 christos #include "oui.h"
102 1.10 christos #include "ntp.h"
103 1.1 christos
104 1.5 christos
105 1.1 christos #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
106 1.1 christos
107 1.1 christos #define PRINT_HEX(bytes_len, ptr_data) \
108 1.1 christos while(bytes_len) \
109 1.1 christos { \
110 1.10 christos ND_PRINT("%02X", GET_U_1(ptr_data)); \
111 1.1 christos ptr_data++; \
112 1.1 christos bytes_len--; \
113 1.1 christos }
114 1.1 christos
115 1.1 christos
116 1.1 christos /* Radius packet codes */
117 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-27 */
118 1.11 christos #define RADCMD_ACCESS_REQ 1 /* Access-Request */
119 1.11 christos #define RADCMD_ACCESS_ACC 2 /* Access-Accept */
120 1.11 christos #define RADCMD_ACCESS_REJ 3 /* Access-Reject */
121 1.11 christos #define RADCMD_ACCOUNT_REQ 4 /* Accounting-Request */
122 1.11 christos #define RADCMD_ACCOUNT_RES 5 /* Accounting-Response */
123 1.11 christos #define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
124 1.11 christos #define RADCMD_STATUS_SER 12 /* Status-Server */
125 1.11 christos #define RADCMD_STATUS_CLI 13 /* Status-Client */
126 1.11 christos #define RADCMD_DISCON_REQ 40 /* Disconnect-Request */
127 1.11 christos #define RADCMD_DISCON_ACK 41 /* Disconnect-ACK */
128 1.11 christos #define RADCMD_DISCON_NAK 42 /* Disconnect-NAK */
129 1.11 christos #define RADCMD_COA_REQ 43 /* CoA-Request */
130 1.11 christos #define RADCMD_COA_ACK 44 /* CoA-ACK */
131 1.11 christos #define RADCMD_COA_NAK 45 /* CoA-NAK */
132 1.11 christos #define RADCMD_RESERVED 255 /* Reserved */
133 1.1 christos
134 1.4 christos static const struct tok radius_command_values[] = {
135 1.11 christos { RADCMD_ACCESS_REQ, "Access-Request" },
136 1.11 christos { RADCMD_ACCESS_ACC, "Access-Accept" },
137 1.11 christos { RADCMD_ACCESS_REJ, "Access-Reject" },
138 1.11 christos { RADCMD_ACCOUNT_REQ, "Accounting-Request" },
139 1.11 christos { RADCMD_ACCOUNT_RES, "Accounting-Response" },
140 1.11 christos { RADCMD_ACCESS_CHA, "Access-Challenge" },
141 1.11 christos { RADCMD_STATUS_SER, "Status-Server" },
142 1.11 christos { RADCMD_STATUS_CLI, "Status-Client" },
143 1.11 christos { RADCMD_DISCON_REQ, "Disconnect-Request" },
144 1.11 christos { RADCMD_DISCON_ACK, "Disconnect-ACK" },
145 1.11 christos { RADCMD_DISCON_NAK, "Disconnect-NAK" },
146 1.11 christos { RADCMD_COA_REQ, "CoA-Request" },
147 1.11 christos { RADCMD_COA_ACK, "CoA-ACK" },
148 1.11 christos { RADCMD_COA_NAK, "CoA-NAK" },
149 1.11 christos { RADCMD_RESERVED, "Reserved" },
150 1.1 christos { 0, NULL}
151 1.1 christos };
152 1.1 christos
153 1.1 christos /********************************/
154 1.1 christos /* Begin Radius Attribute types */
155 1.1 christos /********************************/
156 1.1 christos #define SERV_TYPE 6
157 1.1 christos #define FRM_IPADDR 8
158 1.1 christos #define LOG_IPHOST 14
159 1.1 christos #define LOG_SERVICE 15
160 1.1 christos #define FRM_IPX 23
161 1.1 christos #define SESSION_TIMEOUT 27
162 1.1 christos #define IDLE_TIMEOUT 28
163 1.1 christos #define FRM_ATALK_LINK 37
164 1.1 christos #define FRM_ATALK_NETWORK 38
165 1.1 christos
166 1.1 christos #define ACCT_DELAY 41
167 1.1 christos #define ACCT_SESSION_TIME 46
168 1.1 christos
169 1.6 christos #define EGRESS_VLAN_ID 56
170 1.6 christos #define EGRESS_VLAN_NAME 58
171 1.6 christos
172 1.1 christos #define TUNNEL_TYPE 64
173 1.1 christos #define TUNNEL_MEDIUM 65
174 1.1 christos #define TUNNEL_CLIENT_END 66
175 1.1 christos #define TUNNEL_SERVER_END 67
176 1.1 christos #define TUNNEL_PASS 69
177 1.1 christos
178 1.1 christos #define ARAP_PASS 70
179 1.1 christos #define ARAP_FEATURES 71
180 1.1 christos
181 1.10 christos #define EAP_MESSAGE 79
182 1.10 christos
183 1.1 christos #define TUNNEL_PRIV_GROUP 81
184 1.1 christos #define TUNNEL_ASSIGN_ID 82
185 1.1 christos #define TUNNEL_PREFERENCE 83
186 1.1 christos
187 1.1 christos #define ARAP_CHALLENGE_RESP 84
188 1.1 christos #define ACCT_INT_INTERVAL 85
189 1.1 christos
190 1.1 christos #define TUNNEL_CLIENT_AUTH 90
191 1.1 christos #define TUNNEL_SERVER_AUTH 91
192 1.10 christos
193 1.10 christos #define ERROR_CAUSE 101
194 1.1 christos /********************************/
195 1.1 christos /* End Radius Attribute types */
196 1.1 christos /********************************/
197 1.1 christos
198 1.6 christos #define RFC4675_TAGGED 0x31
199 1.6 christos #define RFC4675_UNTAGGED 0x32
200 1.6 christos
201 1.6 christos static const struct tok rfc4675_tagged[] = {
202 1.6 christos { RFC4675_TAGGED, "Tagged" },
203 1.6 christos { RFC4675_UNTAGGED, "Untagged" },
204 1.6 christos { 0, NULL}
205 1.6 christos };
206 1.6 christos
207 1.1 christos
208 1.10 christos static void print_attr_string(netdissect_options *, const u_char *, u_int, u_short );
209 1.10 christos static void print_attr_num(netdissect_options *, const u_char *, u_int, u_short );
210 1.10 christos static void print_vendor_attr(netdissect_options *, const u_char *, u_int, u_short );
211 1.10 christos static void print_attr_address(netdissect_options *, const u_char *, u_int, u_short);
212 1.10 christos static void print_attr_address6(netdissect_options *, const u_char *, u_int, u_short);
213 1.10 christos static void print_attr_netmask6(netdissect_options *, const u_char *, u_int, u_short);
214 1.10 christos static void print_attr_mip6_home_link_prefix(netdissect_options *, const u_char *, u_int, u_short);
215 1.10 christos static void print_attr_operator_name(netdissect_options *, const u_char *, u_int, u_short);
216 1.10 christos static void print_attr_location_information(netdissect_options *, const u_char *, u_int, u_short);
217 1.10 christos static void print_attr_location_data(netdissect_options *, const u_char *, u_int, u_short);
218 1.10 christos static void print_basic_location_policy_rules(netdissect_options *, const u_char *, u_int, u_short);
219 1.10 christos static void print_attr_time(netdissect_options *, const u_char *, u_int, u_short);
220 1.11 christos static void print_attr_vector64(netdissect_options *, const u_char *, u_int, u_short);
221 1.10 christos static void print_attr_strange(netdissect_options *, const u_char *, u_int, u_short);
222 1.10 christos
223 1.10 christos
224 1.10 christos struct radius_hdr { nd_uint8_t code; /* Radius packet code */
225 1.10 christos nd_uint8_t id; /* Radius packet id */
226 1.10 christos nd_uint16_t len; /* Radius total length */
227 1.10 christos nd_byte auth[16]; /* Authenticator */
228 1.1 christos };
229 1.1 christos
230 1.1 christos #define MIN_RADIUS_LEN 20
231 1.1 christos
232 1.10 christos struct radius_attr { nd_uint8_t type; /* Attribute type */
233 1.10 christos nd_uint8_t len; /* Attribute length */
234 1.1 christos };
235 1.1 christos
236 1.1 christos
237 1.1 christos /* Service-Type Attribute standard values */
238 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-4 */
239 1.1 christos static const char *serv_type[]={ NULL,
240 1.1 christos "Login",
241 1.1 christos "Framed",
242 1.1 christos "Callback Login",
243 1.1 christos "Callback Framed",
244 1.1 christos "Outbound",
245 1.1 christos "Administrative",
246 1.1 christos "NAS Prompt",
247 1.1 christos "Authenticate Only",
248 1.1 christos "Callback NAS Prompt",
249 1.10 christos /* ^ [0, 9] ^ */
250 1.1 christos "Call Check",
251 1.1 christos "Callback Administrative",
252 1.10 christos "Voice",
253 1.10 christos "Fax",
254 1.10 christos "Modem Relay",
255 1.10 christos "IAPP-Register",
256 1.10 christos "IAPP-AP-Check",
257 1.10 christos "Authorize Only",
258 1.10 christos "Framed-Management",
259 1.10 christos "Additional-Authorization",
260 1.10 christos /* ^ [10, 19] ^ */
261 1.1 christos };
262 1.1 christos
263 1.1 christos /* Framed-Protocol Attribute standard values */
264 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-5 */
265 1.1 christos static const char *frm_proto[]={ NULL,
266 1.1 christos "PPP",
267 1.1 christos "SLIP",
268 1.1 christos "ARAP",
269 1.1 christos "Gandalf proprietary",
270 1.1 christos "Xylogics IPX/SLIP",
271 1.1 christos "X.75 Synchronous",
272 1.10 christos "GPRS PDP Context",
273 1.1 christos };
274 1.1 christos
275 1.1 christos /* Framed-Routing Attribute standard values */
276 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-6 */
277 1.1 christos static const char *frm_routing[]={ "None",
278 1.1 christos "Send",
279 1.1 christos "Listen",
280 1.1 christos "Send&Listen",
281 1.1 christos };
282 1.1 christos
283 1.1 christos /* Framed-Compression Attribute standard values */
284 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-7 */
285 1.1 christos static const char *frm_comp[]={ "None",
286 1.1 christos "VJ TCP/IP",
287 1.1 christos "IPX",
288 1.1 christos "Stac-LZS",
289 1.1 christos };
290 1.1 christos
291 1.1 christos /* Login-Service Attribute standard values */
292 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-8 */
293 1.1 christos static const char *login_serv[]={ "Telnet",
294 1.1 christos "Rlogin",
295 1.1 christos "TCP Clear",
296 1.1 christos "PortMaster(proprietary)",
297 1.1 christos "LAT",
298 1.1 christos "X.25-PAD",
299 1.1 christos "X.25-T3POS",
300 1.1 christos "Unassigned",
301 1.1 christos "TCP Clear Quiet",
302 1.1 christos };
303 1.1 christos
304 1.1 christos
305 1.1 christos /* Termination-Action Attribute standard values */
306 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-9 */
307 1.1 christos static const char *term_action[]={ "Default",
308 1.1 christos "RADIUS-Request",
309 1.1 christos };
310 1.1 christos
311 1.6 christos /* Ingress-Filters Attribute standard values */
312 1.6 christos static const char *ingress_filters[]={ NULL,
313 1.6 christos "Enabled",
314 1.6 christos "Disabled",
315 1.6 christos };
316 1.6 christos
317 1.1 christos /* NAS-Port-Type Attribute standard values */
318 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-13 */
319 1.1 christos static const char *nas_port_type[]={ "Async",
320 1.1 christos "Sync",
321 1.1 christos "ISDN Sync",
322 1.1 christos "ISDN Async V.120",
323 1.1 christos "ISDN Async V.110",
324 1.1 christos "Virtual",
325 1.1 christos "PIAFS",
326 1.1 christos "HDLC Clear Channel",
327 1.1 christos "X.25",
328 1.1 christos "X.75",
329 1.10 christos /* ^ [0, 9] ^ */
330 1.1 christos "G.3 Fax",
331 1.1 christos "SDSL",
332 1.1 christos "ADSL-CAP",
333 1.1 christos "ADSL-DMT",
334 1.1 christos "ISDN-DSL",
335 1.1 christos "Ethernet",
336 1.1 christos "xDSL",
337 1.1 christos "Cable",
338 1.1 christos "Wireless - Other",
339 1.1 christos "Wireless - IEEE 802.11",
340 1.10 christos /* ^ [10, 19] ^ */
341 1.10 christos "Token-Ring",
342 1.10 christos "FDDI",
343 1.10 christos "Wireless - CDMA200",
344 1.10 christos "Wireless - UMTS",
345 1.10 christos "Wireless - 1X-EV",
346 1.10 christos "IAPP",
347 1.10 christos "FTTP",
348 1.10 christos "Wireless - IEEE 802.16",
349 1.10 christos "Wireless - IEEE 802.20",
350 1.10 christos "Wireless - IEEE 802.22",
351 1.10 christos /* ^ [20, 29] ^ */
352 1.10 christos "PPPoA",
353 1.10 christos "PPPoEoA",
354 1.10 christos "PPPoEoE",
355 1.10 christos "PPPoEoVLAN",
356 1.10 christos "PPPoEoQinQ",
357 1.10 christos "xPON",
358 1.10 christos "Wireless - XGP",
359 1.10 christos "WiMAX Pre-Release 8 IWK Function",
360 1.10 christos "WIMAX-WIFI-IWK",
361 1.10 christos "WIMAX-SFF",
362 1.10 christos /* ^ [30, 39] ^ */
363 1.10 christos "WIMAX-HA-LMA",
364 1.10 christos "WIMAX-DHCP",
365 1.10 christos "WIMAX-LBS",
366 1.10 christos "WIMAX-WVS",
367 1.1 christos };
368 1.1 christos
369 1.1 christos /* Acct-Status-Type Accounting Attribute standard values */
370 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-10 */
371 1.1 christos static const char *acct_status[]={ NULL,
372 1.1 christos "Start",
373 1.1 christos "Stop",
374 1.1 christos "Interim-Update",
375 1.1 christos "Unassigned",
376 1.1 christos "Unassigned",
377 1.1 christos "Unassigned",
378 1.1 christos "Accounting-On",
379 1.1 christos "Accounting-Off",
380 1.1 christos "Tunnel-Start",
381 1.10 christos /* ^ [0, 9] ^ */
382 1.1 christos "Tunnel-Stop",
383 1.1 christos "Tunnel-Reject",
384 1.1 christos "Tunnel-Link-Start",
385 1.1 christos "Tunnel-Link-Stop",
386 1.1 christos "Tunnel-Link-Reject",
387 1.1 christos "Failed",
388 1.1 christos };
389 1.1 christos
390 1.1 christos /* Acct-Authentic Accounting Attribute standard values */
391 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-11 */
392 1.1 christos static const char *acct_auth[]={ NULL,
393 1.1 christos "RADIUS",
394 1.1 christos "Local",
395 1.1 christos "Remote",
396 1.10 christos "Diameter",
397 1.1 christos };
398 1.1 christos
399 1.1 christos /* Acct-Terminate-Cause Accounting Attribute standard values */
400 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-12 */
401 1.1 christos static const char *acct_term[]={ NULL,
402 1.1 christos "User Request",
403 1.1 christos "Lost Carrier",
404 1.1 christos "Lost Service",
405 1.1 christos "Idle Timeout",
406 1.1 christos "Session Timeout",
407 1.1 christos "Admin Reset",
408 1.1 christos "Admin Reboot",
409 1.1 christos "Port Error",
410 1.1 christos "NAS Error",
411 1.10 christos /* ^ [0, 9] ^ */
412 1.1 christos "NAS Request",
413 1.1 christos "NAS Reboot",
414 1.1 christos "Port Unneeded",
415 1.1 christos "Port Preempted",
416 1.1 christos "Port Suspended",
417 1.1 christos "Service Unavailable",
418 1.1 christos "Callback",
419 1.1 christos "User Error",
420 1.1 christos "Host Request",
421 1.10 christos "Supplicant Restart",
422 1.10 christos /* ^ [10, 19] ^ */
423 1.10 christos "Reauthentication Failure",
424 1.10 christos "Port Reinitialized",
425 1.10 christos "Port Administratively Disabled",
426 1.10 christos "Lost Power",
427 1.1 christos };
428 1.1 christos
429 1.1 christos /* Tunnel-Type Attribute standard values */
430 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-14 */
431 1.1 christos static const char *tunnel_type[]={ NULL,
432 1.1 christos "PPTP",
433 1.1 christos "L2F",
434 1.1 christos "L2TP",
435 1.1 christos "ATMP",
436 1.1 christos "VTP",
437 1.1 christos "AH",
438 1.1 christos "IP-IP",
439 1.1 christos "MIN-IP-IP",
440 1.1 christos "ESP",
441 1.10 christos /* ^ [0, 9] ^ */
442 1.1 christos "GRE",
443 1.1 christos "DVS",
444 1.1 christos "IP-in-IP Tunneling",
445 1.7 christos "VLAN",
446 1.1 christos };
447 1.1 christos
448 1.1 christos /* Tunnel-Medium-Type Attribute standard values */
449 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-15 */
450 1.1 christos static const char *tunnel_medium[]={ NULL,
451 1.1 christos "IPv4",
452 1.1 christos "IPv6",
453 1.1 christos "NSAP",
454 1.1 christos "HDLC",
455 1.1 christos "BBN 1822",
456 1.1 christos "802",
457 1.1 christos "E.163",
458 1.1 christos "E.164",
459 1.1 christos "F.69",
460 1.10 christos /* ^ [0, 9] ^ */
461 1.1 christos "X.121",
462 1.1 christos "IPX",
463 1.1 christos "Appletalk",
464 1.1 christos "Decnet IV",
465 1.1 christos "Banyan Vines",
466 1.1 christos "E.164 with NSAP subaddress",
467 1.1 christos };
468 1.1 christos
469 1.1 christos /* ARAP-Zone-Access Attribute standard values */
470 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-16 */
471 1.1 christos static const char *arap_zone[]={ NULL,
472 1.1 christos "Only access to dfl zone",
473 1.1 christos "Use zone filter inc.",
474 1.1 christos "Not used",
475 1.1 christos "Use zone filter exc.",
476 1.1 christos };
477 1.1 christos
478 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-17 */
479 1.1 christos static const char *prompt[]={ "No Echo",
480 1.1 christos "Echo",
481 1.1 christos };
482 1.1 christos
483 1.10 christos /* Error-Cause standard values */
484 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-18 */
485 1.10 christos #define ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED 201
486 1.10 christos #define ERROR_CAUSE_INVALID_EAP_PACKET 202
487 1.10 christos #define ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE 401
488 1.10 christos #define ERROR_CAUSE_MISSING_ATTRIBUTE 402
489 1.10 christos #define ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH 403
490 1.10 christos #define ERROR_CAUSE_INVALID_REQUEST 404
491 1.10 christos #define ERROR_CAUSE_UNSUPPORTED_SERVICE 405
492 1.10 christos #define ERROR_CAUSE_UNSUPPORTED_EXTENSION 406
493 1.10 christos #define ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE 407
494 1.10 christos #define ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED 501
495 1.10 christos #define ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE 502
496 1.10 christos #define ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND 503
497 1.10 christos #define ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE 504
498 1.10 christos #define ERROR_CAUSE_PROXY_PROCESSING_ERROR 505
499 1.10 christos #define ERROR_CAUSE_RESOURCES_UNAVAILABLE 506
500 1.10 christos #define ERROR_CAUSE_REQUEST_INITIATED 507
501 1.10 christos #define ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED 508
502 1.10 christos #define ERROR_CAUSE_LOCATION_INFO_REQUIRED 509
503 1.10 christos static const struct tok errorcausetype[] = {
504 1.10 christos { ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED, "Residual Session Context Removed" },
505 1.10 christos { ERROR_CAUSE_INVALID_EAP_PACKET, "Invalid EAP Packet (Ignored)" },
506 1.10 christos { ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE, "Unsupported Attribute" },
507 1.10 christos { ERROR_CAUSE_MISSING_ATTRIBUTE, "Missing Attribute" },
508 1.10 christos { ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH, "NAS Identification Mismatch" },
509 1.10 christos { ERROR_CAUSE_INVALID_REQUEST, "Invalid Request" },
510 1.10 christos { ERROR_CAUSE_UNSUPPORTED_SERVICE, "Unsupported Service" },
511 1.10 christos { ERROR_CAUSE_UNSUPPORTED_EXTENSION, "Unsupported Extension" },
512 1.10 christos { ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE, "Invalid Attribute Value" },
513 1.10 christos { ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED, "Administratively Prohibited" },
514 1.10 christos { ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE, "Request Not Routable (Proxy)" },
515 1.10 christos { ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND, "Session Context Not Found" },
516 1.10 christos { ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE, "Session Context Not Removable" },
517 1.10 christos { ERROR_CAUSE_PROXY_PROCESSING_ERROR, "Other Proxy Processing Error" },
518 1.10 christos { ERROR_CAUSE_RESOURCES_UNAVAILABLE, "Resources Unavailable" },
519 1.10 christos { ERROR_CAUSE_REQUEST_INITIATED, "Request Initiated" },
520 1.10 christos { ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED, "Multiple Session Selection Unsupported" },
521 1.10 christos { ERROR_CAUSE_LOCATION_INFO_REQUIRED, "Location Info Required" },
522 1.10 christos { 0, NULL }
523 1.10 christos };
524 1.10 christos
525 1.10 christos /* MIP6-Feature-Vector standard values */
526 1.10 christos /* https://www.iana.org/assignments/aaa-parameters/aaa-parameters.xhtml */
527 1.10 christos #define MIP6_INTEGRATED 0x0000000000000001
528 1.10 christos #define LOCAL_HOME_AGENT_ASSIGNMENT 0x0000000000000002
529 1.10 christos #define PMIP6_SUPPORTED 0x0000010000000000
530 1.10 christos #define IP4_HOA_SUPPORTED 0x0000020000000000
531 1.10 christos #define LOCAL_MAG_ROUTING_SUPPORTED 0x0000040000000000
532 1.10 christos #define ASSIGN_LOCAL_IP 0x0000080000000000
533 1.10 christos #define MIP4_SUPPORTED 0x0000100000000000
534 1.10 christos #define OPTIMIZED_IDLE_MODE_MOBILITY 0x0000200000000000
535 1.10 christos #define GTPv2_SUPPORTED 0x0000400000000000
536 1.10 christos #define IP4_TRANSPORT_SUPPORTED 0x0000800000000000
537 1.10 christos #define IP4_HOA_ONLY_SUPPORTED 0x0001000000000000
538 1.10 christos #define INTER_MAG_ROUTING_SUPPORTED 0x0002000000000000
539 1.10 christos static const struct mip6_feature_vector {
540 1.10 christos uint64_t v;
541 1.10 christos const char *s;
542 1.10 christos } mip6_feature_vector[] = {
543 1.10 christos { MIP6_INTEGRATED, "MIP6_INTEGRATED" },
544 1.10 christos { LOCAL_HOME_AGENT_ASSIGNMENT, "LOCAL_HOME_AGENT_ASSIGNMENT" },
545 1.10 christos { PMIP6_SUPPORTED, "PMIP6_SUPPORTED" },
546 1.10 christos { IP4_HOA_SUPPORTED, "IP4_HOA_SUPPORTED" },
547 1.10 christos { LOCAL_MAG_ROUTING_SUPPORTED, "LOCAL_MAG_ROUTING_SUPPORTED" },
548 1.10 christos { ASSIGN_LOCAL_IP, "ASSIGN_LOCAL_IP" },
549 1.10 christos { MIP4_SUPPORTED, "MIP4_SUPPORTED" },
550 1.10 christos { OPTIMIZED_IDLE_MODE_MOBILITY, "OPTIMIZED_IDLE_MODE_MOBILITY" },
551 1.10 christos { GTPv2_SUPPORTED, "GTPv2_SUPPORTED" },
552 1.10 christos { IP4_TRANSPORT_SUPPORTED, "IP4_TRANSPORT_SUPPORTED" },
553 1.10 christos { IP4_HOA_ONLY_SUPPORTED, "IP4_HOA_ONLY_SUPPORTED" },
554 1.10 christos { INTER_MAG_ROUTING_SUPPORTED, "INTER_MAG_ROUTING_SUPPORTED" },
555 1.10 christos };
556 1.1 christos
557 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-19 */
558 1.10 christos #define OPERATOR_NAME_TADIG 0x30
559 1.10 christos #define OPERATOR_NAME_REALM 0x31
560 1.10 christos #define OPERATOR_NAME_E212 0x32
561 1.10 christos #define OPERATOR_NAME_ICC 0x33
562 1.10 christos static const struct tok operator_name_vector[] = {
563 1.10 christos { OPERATOR_NAME_TADIG, "TADIG" },
564 1.10 christos { OPERATOR_NAME_REALM, "REALM" },
565 1.10 christos { OPERATOR_NAME_E212, "E212" },
566 1.10 christos { OPERATOR_NAME_ICC, "ICC" },
567 1.10 christos { 0, NULL }
568 1.10 christos };
569 1.10 christos
570 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-20 */
571 1.10 christos #define LOCATION_INFORMATION_CODE_CIVIC 0
572 1.10 christos #define LOCATION_INFORMATION_CODE_GEOSPATIAL 1
573 1.10 christos static const struct tok location_information_code_vector[] = {
574 1.10 christos { LOCATION_INFORMATION_CODE_CIVIC , "Civic" },
575 1.10 christos { LOCATION_INFORMATION_CODE_GEOSPATIAL, "Geospatial" },
576 1.10 christos { 0, NULL }
577 1.10 christos };
578 1.10 christos
579 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-21 */
580 1.10 christos #define LOCATION_INFORMATION_ENTITY_USER 0
581 1.10 christos #define LOCATION_INFORMATION_ENTITY_RADIUS 1
582 1.10 christos static const struct tok location_information_entity_vector[] = {
583 1.10 christos { LOCATION_INFORMATION_ENTITY_USER, "User" },
584 1.10 christos { LOCATION_INFORMATION_ENTITY_RADIUS, "RADIUS" },
585 1.10 christos { 0, NULL }
586 1.10 christos };
587 1.10 christos
588 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-22 */
589 1.10 christos static const struct tok blpr_bm[] = {
590 1.10 christos { 0x0001, "MBZ-15" },
591 1.10 christos { 0x0002, "MBZ-14" },
592 1.10 christos { 0x0004, "MBZ-13" },
593 1.10 christos { 0x0008, "MBZ-12" },
594 1.10 christos { 0x0010, "MBZ-11" },
595 1.10 christos { 0x0020, "MBZ-10" },
596 1.10 christos { 0x0040, "MBZ-9" },
597 1.10 christos { 0x0080, "MBZ-8" },
598 1.10 christos { 0x0100, "MBZ-7" },
599 1.10 christos { 0x0200, "MBZ-6" },
600 1.10 christos { 0x0400, "MBZ-5" },
601 1.10 christos { 0x0800, "MBZ-4" },
602 1.10 christos { 0x1000, "MBZ-3" },
603 1.10 christos { 0x2000, "MBZ-2" },
604 1.10 christos { 0x4000, "MBZ-1" },
605 1.10 christos { 0x8000, "Retransmission Allowed" },
606 1.10 christos { 0, NULL }
607 1.10 christos };
608 1.10 christos
609 1.10 christos /* https://www.iana.org/assignments/radius-types/radius-types.xhtml#radius-types-2 */
610 1.10 christos static const struct attrtype {
611 1.8 spz const char *name; /* Attribute name */
612 1.1 christos const char **subtypes; /* Standard Values (if any) */
613 1.1 christos u_char siz_subtypes; /* Size of total standard values */
614 1.1 christos u_char first_subtype; /* First standard value is 0 or 1 */
615 1.10 christos void (*print_func)(netdissect_options *, const u_char *, u_int, u_short);
616 1.1 christos } attr_type[]=
617 1.1 christos {
618 1.1 christos { NULL, NULL, 0, 0, NULL },
619 1.6 christos { "User-Name", NULL, 0, 0, print_attr_string },
620 1.6 christos { "User-Password", NULL, 0, 0, NULL },
621 1.6 christos { "CHAP-Password", NULL, 0, 0, NULL },
622 1.6 christos { "NAS-IP-Address", NULL, 0, 0, print_attr_address },
623 1.6 christos { "NAS-Port", NULL, 0, 0, print_attr_num },
624 1.6 christos { "Service-Type", serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num },
625 1.6 christos { "Framed-Protocol", frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num },
626 1.6 christos { "Framed-IP-Address", NULL, 0, 0, print_attr_address },
627 1.6 christos { "Framed-IP-Netmask", NULL, 0, 0, print_attr_address },
628 1.10 christos /* ^ [0, 9] ^ */
629 1.6 christos { "Framed-Routing", frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num },
630 1.6 christos { "Filter-Id", NULL, 0, 0, print_attr_string },
631 1.6 christos { "Framed-MTU", NULL, 0, 0, print_attr_num },
632 1.6 christos { "Framed-Compression", frm_comp, TAM_SIZE(frm_comp), 0, print_attr_num },
633 1.6 christos { "Login-IP-Host", NULL, 0, 0, print_attr_address },
634 1.6 christos { "Login-Service", login_serv, TAM_SIZE(login_serv), 0, print_attr_num },
635 1.6 christos { "Login-TCP-Port", NULL, 0, 0, print_attr_num },
636 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*17*/
637 1.6 christos { "Reply-Message", NULL, 0, 0, print_attr_string },
638 1.6 christos { "Callback-Number", NULL, 0, 0, print_attr_string },
639 1.10 christos /* ^ [10, 19] ^ */
640 1.6 christos { "Callback-Id", NULL, 0, 0, print_attr_string },
641 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*21*/
642 1.6 christos { "Framed-Route", NULL, 0, 0, print_attr_string },
643 1.6 christos { "Framed-IPX-Network", NULL, 0, 0, print_attr_num },
644 1.1 christos { "State", NULL, 0, 0, print_attr_string },
645 1.1 christos { "Class", NULL, 0, 0, print_attr_string },
646 1.6 christos { "Vendor-Specific", NULL, 0, 0, print_vendor_attr },
647 1.6 christos { "Session-Timeout", NULL, 0, 0, print_attr_num },
648 1.6 christos { "Idle-Timeout", NULL, 0, 0, print_attr_num },
649 1.6 christos { "Termination-Action", term_action, TAM_SIZE(term_action), 0, print_attr_num },
650 1.10 christos /* ^ [20, 29] ^ */
651 1.6 christos { "Called-Station-Id", NULL, 0, 0, print_attr_string },
652 1.6 christos { "Calling-Station-Id", NULL, 0, 0, print_attr_string },
653 1.6 christos { "NAS-Identifier", NULL, 0, 0, print_attr_string },
654 1.6 christos { "Proxy-State", NULL, 0, 0, print_attr_string },
655 1.6 christos { "Login-LAT-Service", NULL, 0, 0, print_attr_string },
656 1.6 christos { "Login-LAT-Node", NULL, 0, 0, print_attr_string },
657 1.6 christos { "Login-LAT-Group", NULL, 0, 0, print_attr_string },
658 1.6 christos { "Framed-AppleTalk-Link", NULL, 0, 0, print_attr_num },
659 1.6 christos { "Framed-AppleTalk-Network", NULL, 0, 0, print_attr_num },
660 1.6 christos { "Framed-AppleTalk-Zone", NULL, 0, 0, print_attr_string },
661 1.10 christos /* ^ [30, 39] ^ */
662 1.6 christos { "Acct-Status-Type", acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num },
663 1.6 christos { "Acct-Delay-Time", NULL, 0, 0, print_attr_num },
664 1.6 christos { "Acct-Input-Octets", NULL, 0, 0, print_attr_num },
665 1.6 christos { "Acct-Output-Octets", NULL, 0, 0, print_attr_num },
666 1.6 christos { "Acct-Session-Id", NULL, 0, 0, print_attr_string },
667 1.6 christos { "Acct-Authentic", acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num },
668 1.6 christos { "Acct-Session-Time", NULL, 0, 0, print_attr_num },
669 1.6 christos { "Acct-Input-Packets", NULL, 0, 0, print_attr_num },
670 1.6 christos { "Acct-Output-Packets", NULL, 0, 0, print_attr_num },
671 1.6 christos { "Acct-Terminate-Cause", acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num },
672 1.10 christos /* ^ [40, 49] ^ */
673 1.6 christos { "Acct-Multi-Session-Id", NULL, 0, 0, print_attr_string },
674 1.6 christos { "Acct-Link-Count", NULL, 0, 0, print_attr_num },
675 1.6 christos { "Acct-Input-Gigawords", NULL, 0, 0, print_attr_num },
676 1.6 christos { "Acct-Output-Gigawords", NULL, 0, 0, print_attr_num },
677 1.1 christos { "Unassigned", NULL, 0, 0, NULL }, /*54*/
678 1.6 christos { "Event-Timestamp", NULL, 0, 0, print_attr_time },
679 1.6 christos { "Egress-VLANID", NULL, 0, 0, print_attr_num },
680 1.6 christos { "Ingress-Filters", ingress_filters, TAM_SIZE(ingress_filters)-1, 1, print_attr_num },
681 1.6 christos { "Egress-VLAN-Name", NULL, 0, 0, print_attr_string },
682 1.6 christos { "User-Priority-Table", NULL, 0, 0, NULL },
683 1.10 christos /* ^ [50, 59] ^ */
684 1.6 christos { "CHAP-Challenge", NULL, 0, 0, print_attr_string },
685 1.6 christos { "NAS-Port-Type", nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num },
686 1.6 christos { "Port-Limit", NULL, 0, 0, print_attr_num },
687 1.6 christos { "Login-LAT-Port", NULL, 0, 0, print_attr_string }, /*63*/
688 1.6 christos { "Tunnel-Type", tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num },
689 1.6 christos { "Tunnel-Medium-Type", tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num },
690 1.6 christos { "Tunnel-Client-Endpoint", NULL, 0, 0, print_attr_string },
691 1.6 christos { "Tunnel-Server-Endpoint", NULL, 0, 0, print_attr_string },
692 1.6 christos { "Acct-Tunnel-Connection", NULL, 0, 0, print_attr_string },
693 1.6 christos { "Tunnel-Password", NULL, 0, 0, print_attr_string },
694 1.10 christos /* ^ [60, 69] ^ */
695 1.6 christos { "ARAP-Password", NULL, 0, 0, print_attr_strange },
696 1.6 christos { "ARAP-Features", NULL, 0, 0, print_attr_strange },
697 1.6 christos { "ARAP-Zone-Access", arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, /*72*/
698 1.6 christos { "ARAP-Security", NULL, 0, 0, print_attr_string },
699 1.6 christos { "ARAP-Security-Data", NULL, 0, 0, print_attr_string },
700 1.6 christos { "Password-Retry", NULL, 0, 0, print_attr_num },
701 1.1 christos { "Prompt", prompt, TAM_SIZE(prompt), 0, print_attr_num },
702 1.6 christos { "Connect-Info", NULL, 0, 0, print_attr_string },
703 1.6 christos { "Configuration-Token", NULL, 0, 0, print_attr_string },
704 1.6 christos { "EAP-Message", NULL, 0, 0, print_attr_string },
705 1.10 christos /* ^ [70, 79] ^ */
706 1.6 christos { "Message-Authenticator", NULL, 0, 0, print_attr_string }, /*80*/
707 1.6 christos { "Tunnel-Private-Group-ID", NULL, 0, 0, print_attr_string },
708 1.6 christos { "Tunnel-Assignment-ID", NULL, 0, 0, print_attr_string },
709 1.6 christos { "Tunnel-Preference", NULL, 0, 0, print_attr_num },
710 1.6 christos { "ARAP-Challenge-Response", NULL, 0, 0, print_attr_strange },
711 1.6 christos { "Acct-Interim-Interval", NULL, 0, 0, print_attr_num },
712 1.6 christos { "Acct-Tunnel-Packets-Lost", NULL, 0, 0, print_attr_num }, /*86*/
713 1.6 christos { "NAS-Port-Id", NULL, 0, 0, print_attr_string },
714 1.6 christos { "Framed-Pool", NULL, 0, 0, print_attr_string },
715 1.6 christos { "CUI", NULL, 0, 0, print_attr_string },
716 1.10 christos /* ^ [80, 89] ^ */
717 1.6 christos { "Tunnel-Client-Auth-ID", NULL, 0, 0, print_attr_string },
718 1.6 christos { "Tunnel-Server-Auth-ID", NULL, 0, 0, print_attr_string },
719 1.10 christos { "NAS-Filter-Rule", NULL, 0, 0, print_attr_string },
720 1.10 christos { "Unassigned", NULL, 0, 0, NULL }, /*93*/
721 1.10 christos { "Originating-Line-Info", NULL, 0, 0, NULL },
722 1.10 christos { "NAS-IPv6-Address", NULL, 0, 0, print_attr_address6 },
723 1.10 christos { "Framed-Interface-ID", NULL, 0, 0, NULL },
724 1.10 christos { "Framed-IPv6-Prefix", NULL, 0, 0, print_attr_netmask6 },
725 1.10 christos { "Login-IPv6-Host", NULL, 0, 0, print_attr_address6 },
726 1.10 christos { "Framed-IPv6-Route", NULL, 0, 0, print_attr_string },
727 1.10 christos /* ^ [90, 99] ^ */
728 1.10 christos { "Framed-IPv6-Pool", NULL, 0, 0, print_attr_string },
729 1.10 christos { "Error-Cause", NULL, 0, 0, print_attr_strange },
730 1.10 christos { "EAP-Key-Name", NULL, 0, 0, NULL },
731 1.10 christos { "Digest-Response", NULL, 0, 0, print_attr_string },
732 1.10 christos { "Digest-Realm", NULL, 0, 0, print_attr_string },
733 1.10 christos { "Digest-Nonce", NULL, 0, 0, print_attr_string },
734 1.10 christos { "Digest-Response-Auth", NULL, 0, 0, print_attr_string },
735 1.10 christos { "Digest-Nextnonce", NULL, 0, 0, print_attr_string },
736 1.10 christos { "Digest-Method", NULL, 0, 0, print_attr_string },
737 1.10 christos { "Digest-URI", NULL, 0, 0, print_attr_string },
738 1.10 christos /* ^ [100, 109] ^ */
739 1.10 christos { "Digest-Qop", NULL, 0, 0, print_attr_string },
740 1.10 christos { "Digest-Algorithm", NULL, 0, 0, print_attr_string },
741 1.10 christos { "Digest-Entity-Body-Hash", NULL, 0, 0, print_attr_string },
742 1.10 christos { "Digest-CNonce", NULL, 0, 0, print_attr_string },
743 1.10 christos { "Digest-Nonce-Count", NULL, 0, 0, print_attr_string },
744 1.10 christos { "Digest-Username", NULL, 0, 0, print_attr_string },
745 1.10 christos { "Digest-Opaque", NULL, 0, 0, print_attr_string },
746 1.10 christos { "Digest-Auth-Param", NULL, 0, 0, print_attr_string },
747 1.10 christos { "Digest-AKA-Auts", NULL, 0, 0, print_attr_string },
748 1.10 christos { "Digest-Domain", NULL, 0, 0, print_attr_string },
749 1.10 christos /* ^ [110, 119] ^ */
750 1.10 christos { "Digest-Stale", NULL, 0, 0, print_attr_string },
751 1.10 christos { "Digest-HA1", NULL, 0, 0, print_attr_string },
752 1.10 christos { "SIP-AOR", NULL, 0, 0, print_attr_string },
753 1.10 christos { "Delegated-IPv6-Prefix", NULL, 0, 0, print_attr_netmask6 },
754 1.10 christos { "MIP6-Feature-Vector", NULL, 0, 0, print_attr_vector64 },
755 1.10 christos { "MIP6-Home-Link-Prefix", NULL, 0, 0, print_attr_mip6_home_link_prefix },
756 1.10 christos { "Operator-Name", NULL, 0, 0, print_attr_operator_name },
757 1.10 christos { "Location-Information", NULL, 0, 0, print_attr_location_information },
758 1.10 christos { "Location-Data", NULL, 0, 0, print_attr_location_data },
759 1.10 christos { "Basic-Location-Policy-Rules", NULL, 0, 0, print_basic_location_policy_rules }
760 1.10 christos /* ^ [120, 129] ^ */
761 1.1 christos };
762 1.1 christos
763 1.1 christos
764 1.1 christos /*****************************/
765 1.1 christos /* Print an attribute string */
766 1.1 christos /* value pointed by 'data' */
767 1.1 christos /* and 'length' size. */
768 1.1 christos /*****************************/
769 1.1 christos /* Returns nothing. */
770 1.1 christos /*****************************/
771 1.1 christos static void
772 1.5 christos print_attr_string(netdissect_options *ndo,
773 1.10 christos const u_char *data, u_int length, u_short attr_code)
774 1.1 christos {
775 1.10 christos u_int i;
776 1.1 christos
777 1.10 christos ND_TCHECK_LEN(data, length);
778 1.1 christos
779 1.11 christos switch(attr_code) {
780 1.1 christos case TUNNEL_PASS:
781 1.1 christos if (length < 3)
782 1.9 christos goto trunc;
783 1.10 christos if (GET_U_1(data) && (GET_U_1(data) <= 0x1F))
784 1.10 christos ND_PRINT("Tag[%u] ", GET_U_1(data));
785 1.6 christos else
786 1.10 christos ND_PRINT("Tag[Unused] ");
787 1.1 christos data++;
788 1.1 christos length--;
789 1.10 christos ND_PRINT("Salt %u ", GET_BE_U_2(data));
790 1.1 christos data+=2;
791 1.1 christos length-=2;
792 1.1 christos break;
793 1.1 christos case TUNNEL_CLIENT_END:
794 1.1 christos case TUNNEL_SERVER_END:
795 1.1 christos case TUNNEL_PRIV_GROUP:
796 1.1 christos case TUNNEL_ASSIGN_ID:
797 1.1 christos case TUNNEL_CLIENT_AUTH:
798 1.1 christos case TUNNEL_SERVER_AUTH:
799 1.11 christos if (GET_U_1(data) <= 0x1F) {
800 1.1 christos if (length < 1)
801 1.9 christos goto trunc;
802 1.10 christos if (GET_U_1(data))
803 1.10 christos ND_PRINT("Tag[%u] ", GET_U_1(data));
804 1.6 christos else
805 1.10 christos ND_PRINT("Tag[Unused] ");
806 1.1 christos data++;
807 1.1 christos length--;
808 1.1 christos }
809 1.1 christos break;
810 1.6 christos case EGRESS_VLAN_NAME:
811 1.9 christos if (length < 1)
812 1.9 christos goto trunc;
813 1.10 christos ND_PRINT("%s (0x%02x) ",
814 1.10 christos tok2str(rfc4675_tagged,"Unknown tag",GET_U_1(data)),
815 1.10 christos GET_U_1(data));
816 1.6 christos data++;
817 1.6 christos length--;
818 1.6 christos break;
819 1.10 christos case EAP_MESSAGE:
820 1.10 christos if (length < 1)
821 1.10 christos goto trunc;
822 1.10 christos eap_print(ndo, data, length);
823 1.10 christos return;
824 1.1 christos }
825 1.1 christos
826 1.10 christos for (i=0; i < length && GET_U_1(data); i++, data++)
827 1.10 christos ND_PRINT("%c", ND_ASCII_ISPRINT(GET_U_1(data)) ? GET_U_1(data) : '.');
828 1.1 christos
829 1.1 christos return;
830 1.1 christos
831 1.1 christos trunc:
832 1.10 christos nd_print_trunc(ndo);
833 1.1 christos }
834 1.1 christos
835 1.1 christos /*
836 1.1 christos * print vendor specific attributes
837 1.1 christos */
838 1.1 christos static void
839 1.5 christos print_vendor_attr(netdissect_options *ndo,
840 1.10 christos const u_char *data, u_int length, u_short attr_code _U_)
841 1.1 christos {
842 1.1 christos u_int idx;
843 1.1 christos u_int vendor_id;
844 1.1 christos u_int vendor_type;
845 1.1 christos u_int vendor_length;
846 1.1 christos
847 1.1 christos if (length < 4)
848 1.1 christos goto trunc;
849 1.10 christos vendor_id = GET_BE_U_4(data);
850 1.1 christos data+=4;
851 1.1 christos length-=4;
852 1.1 christos
853 1.10 christos ND_PRINT("Vendor: %s (%u)",
854 1.1 christos tok2str(smi_values,"Unknown",vendor_id),
855 1.10 christos vendor_id);
856 1.1 christos
857 1.1 christos while (length >= 2) {
858 1.10 christos vendor_type = GET_U_1(data);
859 1.10 christos vendor_length = GET_U_1(data + 1);
860 1.1 christos
861 1.11 christos if (vendor_length < 2) {
862 1.10 christos ND_PRINT("\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
863 1.1 christos vendor_type,
864 1.10 christos vendor_length);
865 1.1 christos return;
866 1.1 christos }
867 1.11 christos if (vendor_length > length) {
868 1.10 christos ND_PRINT("\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
869 1.1 christos vendor_type,
870 1.10 christos vendor_length);
871 1.1 christos return;
872 1.1 christos }
873 1.1 christos data+=2;
874 1.1 christos vendor_length-=2;
875 1.1 christos length-=2;
876 1.10 christos ND_TCHECK_LEN(data, vendor_length);
877 1.1 christos
878 1.10 christos ND_PRINT("\n\t Vendor Attribute: %u, Length: %u, Value: ",
879 1.1 christos vendor_type,
880 1.10 christos vendor_length);
881 1.1 christos for (idx = 0; idx < vendor_length ; idx++, data++)
882 1.10 christos ND_PRINT("%c", ND_ASCII_ISPRINT(GET_U_1(data)) ? GET_U_1(data) : '.');
883 1.1 christos length-=vendor_length;
884 1.1 christos }
885 1.1 christos return;
886 1.1 christos
887 1.1 christos trunc:
888 1.10 christos nd_print_trunc(ndo);
889 1.1 christos }
890 1.1 christos
891 1.1 christos /******************************/
892 1.1 christos /* Print an attribute numeric */
893 1.1 christos /* value pointed by 'data' */
894 1.1 christos /* and 'length' size. */
895 1.1 christos /******************************/
896 1.1 christos /* Returns nothing. */
897 1.1 christos /******************************/
898 1.1 christos static void
899 1.5 christos print_attr_num(netdissect_options *ndo,
900 1.10 christos const u_char *data, u_int length, u_short attr_code)
901 1.1 christos {
902 1.5 christos uint32_t timeout;
903 1.1 christos
904 1.11 christos if (length != 4) {
905 1.10 christos ND_PRINT("ERROR: length %u != 4", length);
906 1.1 christos return;
907 1.1 christos }
908 1.1 christos
909 1.1 christos /* This attribute has standard values */
910 1.11 christos if (attr_type[attr_code].siz_subtypes) {
911 1.1 christos static const char **table;
912 1.5 christos uint32_t data_value;
913 1.1 christos table = attr_type[attr_code].subtypes;
914 1.1 christos
915 1.11 christos if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) ) {
916 1.10 christos if (!GET_U_1(data))
917 1.10 christos ND_PRINT("Tag[Unused] ");
918 1.1 christos else
919 1.10 christos ND_PRINT("Tag[%u] ", GET_U_1(data));
920 1.1 christos data++;
921 1.10 christos data_value = GET_BE_U_3(data);
922 1.11 christos } else {
923 1.10 christos data_value = GET_BE_U_4(data);
924 1.1 christos }
925 1.5 christos if ( data_value <= (uint32_t)(attr_type[attr_code].siz_subtypes - 1 +
926 1.1 christos attr_type[attr_code].first_subtype) &&
927 1.1 christos data_value >= attr_type[attr_code].first_subtype )
928 1.10 christos ND_PRINT("%s", table[data_value]);
929 1.1 christos else
930 1.10 christos ND_PRINT("#%u", data_value);
931 1.11 christos } else {
932 1.1 christos switch(attr_code) /* Be aware of special cases... */
933 1.1 christos {
934 1.1 christos case FRM_IPX:
935 1.10 christos if (GET_BE_U_4(data) == 0xFFFFFFFE )
936 1.10 christos ND_PRINT("NAS Select");
937 1.1 christos else
938 1.10 christos ND_PRINT("%u", GET_BE_U_4(data));
939 1.1 christos break;
940 1.1 christos
941 1.1 christos case SESSION_TIMEOUT:
942 1.1 christos case IDLE_TIMEOUT:
943 1.1 christos case ACCT_DELAY:
944 1.1 christos case ACCT_SESSION_TIME:
945 1.1 christos case ACCT_INT_INTERVAL:
946 1.10 christos timeout = GET_BE_U_4(data);
947 1.1 christos if ( timeout < 60 )
948 1.10 christos ND_PRINT("%02d secs", timeout);
949 1.11 christos else {
950 1.1 christos if ( timeout < 3600 )
951 1.10 christos ND_PRINT("%02d:%02d min",
952 1.10 christos timeout / 60, timeout % 60);
953 1.1 christos else
954 1.10 christos ND_PRINT("%02d:%02d:%02d hours",
955 1.1 christos timeout / 3600, (timeout % 3600) / 60,
956 1.10 christos timeout % 60);
957 1.1 christos }
958 1.1 christos break;
959 1.1 christos
960 1.1 christos case FRM_ATALK_LINK:
961 1.10 christos if (GET_BE_U_4(data))
962 1.10 christos ND_PRINT("%u", GET_BE_U_4(data));
963 1.1 christos else
964 1.10 christos ND_PRINT("Unnumbered");
965 1.1 christos break;
966 1.1 christos
967 1.1 christos case FRM_ATALK_NETWORK:
968 1.10 christos if (GET_BE_U_4(data))
969 1.10 christos ND_PRINT("%u", GET_BE_U_4(data));
970 1.1 christos else
971 1.10 christos ND_PRINT("NAS assigned");
972 1.1 christos break;
973 1.1 christos
974 1.1 christos case TUNNEL_PREFERENCE:
975 1.10 christos if (GET_U_1(data))
976 1.10 christos ND_PRINT("Tag[%u] ", GET_U_1(data));
977 1.6 christos else
978 1.10 christos ND_PRINT("Tag[Unused] ");
979 1.1 christos data++;
980 1.10 christos ND_PRINT("%u", GET_BE_U_3(data));
981 1.6 christos break;
982 1.6 christos
983 1.6 christos case EGRESS_VLAN_ID:
984 1.10 christos ND_PRINT("%s (0x%02x) ",
985 1.10 christos tok2str(rfc4675_tagged,"Unknown tag",GET_U_1(data)),
986 1.10 christos GET_U_1(data));
987 1.6 christos data++;
988 1.10 christos ND_PRINT("%u", GET_BE_U_3(data));
989 1.1 christos break;
990 1.1 christos
991 1.1 christos default:
992 1.10 christos ND_PRINT("%u", GET_BE_U_4(data));
993 1.1 christos break;
994 1.1 christos
995 1.1 christos } /* switch */
996 1.1 christos
997 1.1 christos } /* if-else */
998 1.1 christos }
999 1.1 christos
1000 1.1 christos /*****************************/
1001 1.1 christos /* Print an attribute IPv4 */
1002 1.1 christos /* address value pointed by */
1003 1.1 christos /* 'data' and 'length' size. */
1004 1.1 christos /*****************************/
1005 1.1 christos /* Returns nothing. */
1006 1.1 christos /*****************************/
1007 1.1 christos static void
1008 1.5 christos print_attr_address(netdissect_options *ndo,
1009 1.10 christos const u_char *data, u_int length, u_short attr_code)
1010 1.1 christos {
1011 1.11 christos if (length != 4) {
1012 1.10 christos ND_PRINT("ERROR: length %u != 4", length);
1013 1.1 christos return;
1014 1.1 christos }
1015 1.1 christos
1016 1.11 christos switch(attr_code) {
1017 1.1 christos case FRM_IPADDR:
1018 1.1 christos case LOG_IPHOST:
1019 1.10 christos if (GET_BE_U_4(data) == 0xFFFFFFFF )
1020 1.10 christos ND_PRINT("User Selected");
1021 1.1 christos else
1022 1.10 christos if (GET_BE_U_4(data) == 0xFFFFFFFE )
1023 1.10 christos ND_PRINT("NAS Select");
1024 1.1 christos else
1025 1.10 christos ND_PRINT("%s",GET_IPADDR_STRING(data));
1026 1.1 christos break;
1027 1.1 christos
1028 1.1 christos default:
1029 1.10 christos ND_PRINT("%s", GET_IPADDR_STRING(data));
1030 1.1 christos break;
1031 1.1 christos }
1032 1.10 christos }
1033 1.10 christos
1034 1.10 christos /*****************************/
1035 1.10 christos /* Print an attribute IPv6 */
1036 1.10 christos /* address value pointed by */
1037 1.10 christos /* 'data' and 'length' size. */
1038 1.10 christos /*****************************/
1039 1.10 christos /* Returns nothing. */
1040 1.10 christos /*****************************/
1041 1.10 christos static void
1042 1.10 christos print_attr_address6(netdissect_options *ndo,
1043 1.10 christos const u_char *data, u_int length, u_short attr_code _U_)
1044 1.10 christos {
1045 1.11 christos if (length != 16) {
1046 1.10 christos ND_PRINT("ERROR: length %u != 16", length);
1047 1.10 christos return;
1048 1.10 christos }
1049 1.10 christos
1050 1.10 christos ND_PRINT("%s", GET_IP6ADDR_STRING(data));
1051 1.10 christos }
1052 1.10 christos
1053 1.10 christos static void
1054 1.10 christos print_attr_netmask6(netdissect_options *ndo,
1055 1.10 christos const u_char *data, u_int length, u_short attr_code _U_)
1056 1.10 christos {
1057 1.10 christos u_char data2[16];
1058 1.10 christos
1059 1.11 christos if (length < 2 || length > 18) {
1060 1.10 christos ND_PRINT("ERROR: length %u not in range (2..18)", length);
1061 1.10 christos return;
1062 1.10 christos }
1063 1.10 christos ND_TCHECK_LEN(data, length);
1064 1.11 christos if (GET_U_1(data + 1) > 128) {
1065 1.10 christos ND_PRINT("ERROR: netmask %u not in range (0..128)", GET_U_1(data + 1));
1066 1.10 christos return;
1067 1.10 christos }
1068 1.10 christos
1069 1.10 christos memset(data2, 0, sizeof(data2));
1070 1.10 christos if (length > 2)
1071 1.10 christos memcpy(data2, data+2, length-2);
1072 1.10 christos
1073 1.10 christos ND_PRINT("%s/%u", ip6addr_string(ndo, data2), GET_U_1(data + 1)); /* local buffer, not packet data; don't use GET_IP6ADDR_STRING() */
1074 1.10 christos
1075 1.10 christos if (GET_U_1(data + 1) > 8 * (length - 2))
1076 1.10 christos ND_PRINT(" (inconsistent prefix length)");
1077 1.1 christos
1078 1.1 christos return;
1079 1.1 christos
1080 1.1 christos trunc:
1081 1.10 christos nd_print_trunc(ndo);
1082 1.1 christos }
1083 1.1 christos
1084 1.10 christos static void
1085 1.10 christos print_attr_mip6_home_link_prefix(netdissect_options *ndo,
1086 1.10 christos const u_char *data, u_int length, u_short attr_code _U_)
1087 1.10 christos {
1088 1.11 christos if (length != 17) {
1089 1.10 christos ND_PRINT("ERROR: length %u != 17", length);
1090 1.10 christos return;
1091 1.10 christos }
1092 1.10 christos ND_TCHECK_LEN(data, length);
1093 1.11 christos if (GET_U_1(data) > 128) {
1094 1.10 christos ND_PRINT("ERROR: netmask %u not in range (0..128)", GET_U_1(data));
1095 1.10 christos return;
1096 1.10 christos }
1097 1.10 christos
1098 1.10 christos ND_PRINT("%s/%u", GET_IP6ADDR_STRING(data + 1), GET_U_1(data));
1099 1.10 christos
1100 1.10 christos return;
1101 1.10 christos
1102 1.10 christos trunc:
1103 1.10 christos nd_print_trunc(ndo);
1104 1.10 christos }
1105 1.10 christos
1106 1.10 christos static void
1107 1.10 christos print_attr_operator_name(netdissect_options *ndo,
1108 1.10 christos const u_char *data, u_int length, u_short attr_code _U_)
1109 1.10 christos {
1110 1.10 christos u_int namespace_value;
1111 1.10 christos
1112 1.10 christos ND_TCHECK_LEN(data, length);
1113 1.11 christos if (length < 2) {
1114 1.10 christos ND_PRINT("ERROR: length %u < 2", length);
1115 1.10 christos return;
1116 1.10 christos }
1117 1.10 christos namespace_value = GET_U_1(data);
1118 1.10 christos data++;
1119 1.10 christos ND_PRINT("[%s] ", tok2str(operator_name_vector, "unknown namespace %u", namespace_value));
1120 1.10 christos
1121 1.10 christos (void)nd_printn(ndo, data, length - 1, NULL);
1122 1.10 christos
1123 1.10 christos return;
1124 1.10 christos
1125 1.10 christos trunc:
1126 1.10 christos nd_print_trunc(ndo);
1127 1.10 christos }
1128 1.10 christos
1129 1.10 christos static void
1130 1.10 christos print_attr_location_information(netdissect_options *ndo,
1131 1.10 christos const u_char *data, u_int length, u_short attr_code _U_)
1132 1.10 christos {
1133 1.10 christos uint16_t index;
1134 1.10 christos uint8_t code, entity;
1135 1.10 christos
1136 1.10 christos ND_TCHECK_LEN(data, length);
1137 1.11 christos if (length < 21) {
1138 1.10 christos ND_PRINT("ERROR: length %u < 21", length);
1139 1.10 christos return;
1140 1.10 christos }
1141 1.10 christos
1142 1.10 christos index = GET_BE_U_2(data);
1143 1.10 christos data += 2;
1144 1.10 christos
1145 1.10 christos code = GET_U_1(data);
1146 1.10 christos data++;
1147 1.10 christos
1148 1.10 christos entity = GET_U_1(data);
1149 1.10 christos data++;
1150 1.10 christos
1151 1.10 christos ND_PRINT("index %u, code %s, entity %s, ",
1152 1.10 christos index,
1153 1.10 christos tok2str(location_information_code_vector, "Unknown (%u)", code),
1154 1.10 christos tok2str(location_information_entity_vector, "Unknown (%u)", entity)
1155 1.10 christos );
1156 1.10 christos
1157 1.10 christos ND_PRINT("sighting time ");
1158 1.10 christos p_ntp_time(ndo, (const struct l_fixedpt *)data);
1159 1.10 christos ND_PRINT(", ");
1160 1.10 christos data += 8;
1161 1.10 christos
1162 1.10 christos ND_PRINT("time to live ");
1163 1.10 christos p_ntp_time(ndo, (const struct l_fixedpt *)data);
1164 1.10 christos ND_PRINT(", ");
1165 1.10 christos data += 8;
1166 1.10 christos
1167 1.10 christos ND_PRINT("method \"");
1168 1.10 christos (void)nd_printn(ndo, data, length - 20, NULL);
1169 1.10 christos ND_PRINT("\"");
1170 1.10 christos
1171 1.10 christos return;
1172 1.10 christos
1173 1.10 christos trunc:
1174 1.10 christos nd_print_trunc(ndo);
1175 1.10 christos }
1176 1.10 christos
1177 1.10 christos static void
1178 1.10 christos print_attr_location_data(netdissect_options *ndo,
1179 1.10 christos const u_char *data, u_int length, u_short attr_code _U_)
1180 1.10 christos {
1181 1.10 christos uint16_t index;
1182 1.10 christos
1183 1.10 christos ND_TCHECK_LEN(data, length);
1184 1.11 christos if (length < 3) {
1185 1.10 christos ND_PRINT("ERROR: length %u < 3", length);
1186 1.10 christos return;
1187 1.10 christos }
1188 1.10 christos
1189 1.10 christos index = GET_BE_U_2(data);
1190 1.10 christos data += 2;
1191 1.10 christos ND_PRINT("index %u, location", index);
1192 1.10 christos
1193 1.10 christos /* The Location field of the String field of the Location-Data attribute
1194 1.10 christos * can have two completely different structures depending on the value of
1195 1.10 christos * the Code field of a Location-Info attribute, which supposedly precedes
1196 1.10 christos * the current attribute. Unfortunately, this choice of encoding makes it
1197 1.10 christos * non-trivial to decode the Location field without preserving some state
1198 1.10 christos * between the attributes.
1199 1.10 christos */
1200 1.10 christos hex_and_ascii_print(ndo, "\n\t ", data, length - 2);
1201 1.10 christos
1202 1.10 christos return;
1203 1.10 christos
1204 1.10 christos trunc:
1205 1.10 christos nd_print_trunc(ndo);
1206 1.10 christos }
1207 1.10 christos
1208 1.10 christos static void
1209 1.10 christos print_basic_location_policy_rules(netdissect_options *ndo,
1210 1.10 christos const u_char *data, u_int length, u_short attr_code _U_)
1211 1.10 christos {
1212 1.10 christos uint16_t flags;
1213 1.10 christos
1214 1.10 christos ND_TCHECK_LEN(data, length);
1215 1.11 christos if (length < 10) {
1216 1.10 christos ND_PRINT("ERROR: length %u < 10", length);
1217 1.10 christos return;
1218 1.10 christos }
1219 1.10 christos
1220 1.10 christos flags = GET_BE_U_2(data);
1221 1.10 christos data += 2;
1222 1.10 christos ND_PRINT("flags [%s], ", bittok2str(blpr_bm, "none", flags));
1223 1.10 christos
1224 1.10 christos ND_PRINT("retention expires ");
1225 1.10 christos p_ntp_time(ndo, (const struct l_fixedpt *)data);
1226 1.10 christos data += 8;
1227 1.10 christos
1228 1.10 christos if (length > 10) {
1229 1.10 christos ND_PRINT(", note well \"");
1230 1.10 christos (void)nd_printn(ndo, data, length - 10, NULL);
1231 1.10 christos ND_PRINT("\"");
1232 1.10 christos }
1233 1.10 christos
1234 1.10 christos return;
1235 1.10 christos
1236 1.10 christos trunc:
1237 1.10 christos nd_print_trunc(ndo);
1238 1.10 christos }
1239 1.10 christos
1240 1.10 christos
1241 1.1 christos /*************************************/
1242 1.1 christos /* Print an attribute of 'secs since */
1243 1.1 christos /* January 1, 1970 00:00 UTC' value */
1244 1.1 christos /* pointed by 'data' and 'length' */
1245 1.1 christos /* size. */
1246 1.1 christos /*************************************/
1247 1.1 christos /* Returns nothing. */
1248 1.1 christos /*************************************/
1249 1.5 christos static void
1250 1.5 christos print_attr_time(netdissect_options *ndo,
1251 1.10 christos const u_char *data, u_int length, u_short attr_code _U_)
1252 1.1 christos {
1253 1.1 christos time_t attr_time;
1254 1.1 christos char string[26];
1255 1.1 christos
1256 1.11 christos if (length != 4) {
1257 1.10 christos ND_PRINT("ERROR: length %u != 4", length);
1258 1.1 christos return;
1259 1.1 christos }
1260 1.1 christos
1261 1.10 christos attr_time = GET_BE_U_4(data);
1262 1.10 christos strlcpy(string, ctime(&attr_time), sizeof(string));
1263 1.1 christos /* Get rid of the newline */
1264 1.1 christos string[24] = '\0';
1265 1.10 christos ND_PRINT("%.24s", string);
1266 1.10 christos }
1267 1.10 christos
1268 1.10 christos static void
1269 1.10 christos print_attr_vector64(netdissect_options *ndo,
1270 1.11 christos const u_char *data, u_int length, u_short attr_code _U_)
1271 1.10 christos {
1272 1.10 christos uint64_t data_value, i;
1273 1.10 christos const char *sep = "";
1274 1.10 christos
1275 1.11 christos if (length != 8) {
1276 1.10 christos ND_PRINT("ERROR: length %u != 8", length);
1277 1.10 christos return;
1278 1.10 christos }
1279 1.10 christos
1280 1.10 christos ND_PRINT("[");
1281 1.10 christos
1282 1.10 christos data_value = GET_BE_U_8(data);
1283 1.10 christos /* Print the 64-bit field in a format similar to bittok2str(), less
1284 1.10 christos * flagging any unknown bits. This way it should be easier to replace
1285 1.10 christos * the custom code with a library function later.
1286 1.10 christos */
1287 1.10 christos for (i = 0; i < TAM_SIZE(mip6_feature_vector); i++) {
1288 1.10 christos if (data_value & mip6_feature_vector[i].v) {
1289 1.10 christos ND_PRINT("%s%s", sep, mip6_feature_vector[i].s);
1290 1.10 christos sep = ", ";
1291 1.10 christos }
1292 1.10 christos }
1293 1.1 christos
1294 1.10 christos ND_PRINT("]");
1295 1.1 christos }
1296 1.1 christos
1297 1.1 christos /***********************************/
1298 1.1 christos /* Print an attribute of 'strange' */
1299 1.1 christos /* data format pointed by 'data' */
1300 1.1 christos /* and 'length' size. */
1301 1.1 christos /***********************************/
1302 1.1 christos /* Returns nothing. */
1303 1.1 christos /***********************************/
1304 1.5 christos static void
1305 1.5 christos print_attr_strange(netdissect_options *ndo,
1306 1.10 christos const u_char *data, u_int length, u_short attr_code)
1307 1.1 christos {
1308 1.1 christos u_short len_data;
1309 1.10 christos u_int error_cause_value;
1310 1.1 christos
1311 1.11 christos switch(attr_code) {
1312 1.1 christos case ARAP_PASS:
1313 1.11 christos if (length != 16) {
1314 1.10 christos ND_PRINT("ERROR: length %u != 16", length);
1315 1.1 christos return;
1316 1.1 christos }
1317 1.10 christos ND_PRINT("User_challenge (");
1318 1.1 christos len_data = 8;
1319 1.1 christos PRINT_HEX(len_data, data);
1320 1.10 christos ND_PRINT(") User_resp(");
1321 1.1 christos len_data = 8;
1322 1.1 christos PRINT_HEX(len_data, data);
1323 1.10 christos ND_PRINT(")");
1324 1.1 christos break;
1325 1.1 christos
1326 1.1 christos case ARAP_FEATURES:
1327 1.11 christos if (length != 14) {
1328 1.10 christos ND_PRINT("ERROR: length %u != 14", length);
1329 1.1 christos return;
1330 1.1 christos }
1331 1.10 christos if (GET_U_1(data))
1332 1.10 christos ND_PRINT("User can change password");
1333 1.1 christos else
1334 1.10 christos ND_PRINT("User cannot change password");
1335 1.1 christos data++;
1336 1.10 christos ND_PRINT(", Min password length: %u", GET_U_1(data));
1337 1.1 christos data++;
1338 1.10 christos ND_PRINT(", created at: ");
1339 1.1 christos len_data = 4;
1340 1.1 christos PRINT_HEX(len_data, data);
1341 1.10 christos ND_PRINT(", expires in: ");
1342 1.1 christos len_data = 4;
1343 1.1 christos PRINT_HEX(len_data, data);
1344 1.10 christos ND_PRINT(", Current Time: ");
1345 1.1 christos len_data = 4;
1346 1.1 christos PRINT_HEX(len_data, data);
1347 1.1 christos break;
1348 1.1 christos
1349 1.1 christos case ARAP_CHALLENGE_RESP:
1350 1.11 christos if (length < 8) {
1351 1.10 christos ND_PRINT("ERROR: length %u != 8", length);
1352 1.1 christos return;
1353 1.1 christos }
1354 1.1 christos len_data = 8;
1355 1.1 christos PRINT_HEX(len_data, data);
1356 1.1 christos break;
1357 1.10 christos
1358 1.10 christos case ERROR_CAUSE:
1359 1.11 christos if (length != 4) {
1360 1.10 christos ND_PRINT("Error: length %u != 4", length);
1361 1.10 christos return;
1362 1.10 christos }
1363 1.10 christos
1364 1.10 christos error_cause_value = GET_BE_U_4(data);
1365 1.10 christos ND_PRINT("Error cause %u: %s", error_cause_value, tok2str(errorcausetype, "Error-Cause %u not known", error_cause_value));
1366 1.10 christos break;
1367 1.1 christos }
1368 1.1 christos return;
1369 1.1 christos }
1370 1.1 christos
1371 1.1 christos static void
1372 1.5 christos radius_attrs_print(netdissect_options *ndo,
1373 1.10 christos const u_char *attr, u_int length)
1374 1.1 christos {
1375 1.10 christos const struct radius_attr *rad_attr = (const struct radius_attr *)attr;
1376 1.1 christos const char *attr_string;
1377 1.10 christos uint8_t type, len;
1378 1.1 christos
1379 1.11 christos while (length > 0) {
1380 1.1 christos if (length < 2)
1381 1.1 christos goto trunc;
1382 1.10 christos ND_TCHECK_SIZE(rad_attr);
1383 1.5 christos
1384 1.10 christos type = GET_U_1(rad_attr->type);
1385 1.10 christos len = GET_U_1(rad_attr->len);
1386 1.10 christos if (type != 0 && type < TAM_SIZE(attr_type))
1387 1.10 christos attr_string = attr_type[type].name;
1388 1.1 christos else
1389 1.1 christos attr_string = "Unknown";
1390 1.10 christos
1391 1.10 christos ND_PRINT("\n\t %s Attribute (%u), length: %u",
1392 1.10 christos attr_string,
1393 1.10 christos type,
1394 1.10 christos len);
1395 1.11 christos if (len < 2) {
1396 1.10 christos ND_PRINT(" (bogus, must be >= 2)");
1397 1.10 christos return;
1398 1.1 christos }
1399 1.11 christos if (len > length) {
1400 1.10 christos ND_PRINT(" (bogus, goes past end of packet)");
1401 1.1 christos return;
1402 1.1 christos }
1403 1.10 christos ND_PRINT(", Value: ");
1404 1.1 christos
1405 1.11 christos if (type < TAM_SIZE(attr_type)) {
1406 1.11 christos if (len > 2) {
1407 1.10 christos if ( attr_type[type].print_func )
1408 1.10 christos (*attr_type[type].print_func)(
1409 1.7 christos ndo, ((const u_char *)(rad_attr+1)),
1410 1.10 christos len - 2, type);
1411 1.1 christos }
1412 1.1 christos }
1413 1.1 christos /* do we also want to see a hex dump ? */
1414 1.5 christos if (ndo->ndo_vflag> 1)
1415 1.10 christos print_unknown_data(ndo, (const u_char *)rad_attr+2, "\n\t ", (len)-2);
1416 1.1 christos
1417 1.10 christos length-=(len);
1418 1.10 christos rad_attr = (const struct radius_attr *)( ((const char *)(rad_attr))+len);
1419 1.1 christos }
1420 1.1 christos return;
1421 1.1 christos
1422 1.1 christos trunc:
1423 1.10 christos nd_print_trunc(ndo);
1424 1.1 christos }
1425 1.1 christos
1426 1.1 christos void
1427 1.5 christos radius_print(netdissect_options *ndo,
1428 1.5 christos const u_char *dat, u_int length)
1429 1.1 christos {
1430 1.10 christos const struct radius_hdr *rad;
1431 1.1 christos u_int len, auth_idx;
1432 1.1 christos
1433 1.10 christos ndo->ndo_protocol = "radius";
1434 1.10 christos ND_TCHECK_LEN(dat, MIN_RADIUS_LEN);
1435 1.7 christos rad = (const struct radius_hdr *)dat;
1436 1.10 christos len = GET_BE_U_2(rad->len);
1437 1.1 christos
1438 1.11 christos if (len < MIN_RADIUS_LEN) {
1439 1.10 christos nd_print_trunc(ndo);
1440 1.1 christos return;
1441 1.1 christos }
1442 1.1 christos
1443 1.1 christos if (len > length)
1444 1.1 christos len = length;
1445 1.1 christos
1446 1.5 christos if (ndo->ndo_vflag < 1) {
1447 1.10 christos ND_PRINT("RADIUS, %s (%u), id: 0x%02x length: %u",
1448 1.10 christos tok2str(radius_command_values,"Unknown Command",GET_U_1(rad->code)),
1449 1.10 christos GET_U_1(rad->code),
1450 1.10 christos GET_U_1(rad->id),
1451 1.10 christos len);
1452 1.1 christos return;
1453 1.11 christos } else {
1454 1.10 christos ND_PRINT("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
1455 1.1 christos len,
1456 1.10 christos tok2str(radius_command_values,"Unknown Command",GET_U_1(rad->code)),
1457 1.10 christos GET_U_1(rad->code),
1458 1.10 christos GET_U_1(rad->id));
1459 1.1 christos
1460 1.1 christos for(auth_idx=0; auth_idx < 16; auth_idx++)
1461 1.10 christos ND_PRINT("%02x", rad->auth[auth_idx]);
1462 1.1 christos }
1463 1.1 christos
1464 1.1 christos if (len > MIN_RADIUS_LEN)
1465 1.5 christos radius_attrs_print(ndo, dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
1466 1.1 christos return;
1467 1.1 christos
1468 1.1 christos trunc:
1469 1.10 christos nd_print_trunc(ndo);
1470 1.1 christos }
1471