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