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