2 * Copyright (C) 2000 Alfredo Andres Omella. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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
14 * 3. The names of the authors may not be used to endorse or promote
15 * products derived from this software without specific prior
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.
23 /* \summary: Radius protocol printer */
26 * Radius printer routines as specified on:
29 * "Remote Authentication Dial In User Service (RADIUS)"
35 * "RADIUS Accounting Modifications for Tunnel Protocol Support"
38 * "RADIUS Attributes for Tunnel Protocol Support"
47 * "IEEE 802.1X Remote Authentication Dial In User Service (RADIUS)"
51 * "Diameter Extensible Authentication Protocol (EAP) Application"
54 * "RADIUS Attributes for Virtual LAN and Priority Support"
57 * "RADIUS Delegated-IPv6-Prefix Attribute"
60 * "RADIUS Filter Rule Attribute"
63 * "RADIUS Extension for Digest Authentication"
66 * "Dynamic Authorization Extensions to RADIUS"
69 * "Diameter Mobile IPv6"
72 * "Carrying Location Objects in RADIUS and Diameter"
75 * "RADIUS Support for Proxy Mobile IPv6"
78 * "Diameter Network Access Server Application"
80 * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
82 * TODO: Among other things to print ok MacIntosh and Vendor values
89 #include "netdissect-stdinc.h"
93 #include "netdissect.h"
94 #include "addrtoname.h"
99 #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
101 #define PRINT_HEX(bytes_len, ptr_data) \
104 ND_PRINT("%02X", *ptr_data ); \
110 /* Radius packet codes */
111 #define RADCMD_ACCESS_REQ 1 /* Access-Request */
112 #define RADCMD_ACCESS_ACC 2 /* Access-Accept */
113 #define RADCMD_ACCESS_REJ 3 /* Access-Reject */
114 #define RADCMD_ACCOUN_REQ 4 /* Accounting-Request */
115 #define RADCMD_ACCOUN_RES 5 /* Accounting-Response */
116 #define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
117 #define RADCMD_STATUS_SER 12 /* Status-Server */
118 #define RADCMD_STATUS_CLI 13 /* Status-Client */
119 #define RADCMD_DISCON_REQ 40 /* Disconnect-Request */
120 #define RADCMD_DISCON_ACK 41 /* Disconnect-ACK */
121 #define RADCMD_DISCON_NAK 42 /* Disconnect-NAK */
122 #define RADCMD_COA_REQ 43 /* CoA-Request */
123 #define RADCMD_COA_ACK 44 /* CoA-ACK */
124 #define RADCMD_COA_NAK 45 /* CoA-NAK */
125 #define RADCMD_RESERVED 255 /* Reserved */
127 static const struct tok radius_command_values
[] = {
128 { RADCMD_ACCESS_REQ
, "Access-Request" },
129 { RADCMD_ACCESS_ACC
, "Access-Accept" },
130 { RADCMD_ACCESS_REJ
, "Access-Reject" },
131 { RADCMD_ACCOUN_REQ
, "Accounting-Request" },
132 { RADCMD_ACCOUN_RES
, "Accounting-Response" },
133 { RADCMD_ACCESS_CHA
, "Access-Challenge" },
134 { RADCMD_STATUS_SER
, "Status-Server" },
135 { RADCMD_STATUS_CLI
, "Status-Client" },
136 { RADCMD_DISCON_REQ
, "Disconnect-Request" },
137 { RADCMD_DISCON_ACK
, "Disconnect-ACK" },
138 { RADCMD_DISCON_NAK
, "Disconnect-NAK" },
139 { RADCMD_COA_REQ
, "CoA-Request" },
140 { RADCMD_COA_ACK
, "CoA-ACK" },
141 { RADCMD_COA_NAK
, "CoA-NAK" },
142 { RADCMD_RESERVED
, "Reserved" },
146 /********************************/
147 /* Begin Radius Attribute types */
148 /********************************/
151 #define LOG_IPHOST 14
152 #define LOG_SERVICE 15
154 #define SESSION_TIMEOUT 27
155 #define IDLE_TIMEOUT 28
156 #define FRM_ATALK_LINK 37
157 #define FRM_ATALK_NETWORK 38
159 #define ACCT_DELAY 41
160 #define ACCT_SESSION_TIME 46
162 #define EGRESS_VLAN_ID 56
163 #define EGRESS_VLAN_NAME 58
165 #define TUNNEL_TYPE 64
166 #define TUNNEL_MEDIUM 65
167 #define TUNNEL_CLIENT_END 66
168 #define TUNNEL_SERVER_END 67
169 #define TUNNEL_PASS 69
172 #define ARAP_FEATURES 71
174 #define TUNNEL_PRIV_GROUP 81
175 #define TUNNEL_ASSIGN_ID 82
176 #define TUNNEL_PREFERENCE 83
178 #define ARAP_CHALLENGE_RESP 84
179 #define ACCT_INT_INTERVAL 85
181 #define TUNNEL_CLIENT_AUTH 90
182 #define TUNNEL_SERVER_AUTH 91
184 #define ERROR_CAUSE 101
185 /********************************/
186 /* End Radius Attribute types */
187 /********************************/
189 #define RFC4675_TAGGED 0x31
190 #define RFC4675_UNTAGGED 0x32
192 static const struct tok rfc4675_tagged
[] = {
193 { RFC4675_TAGGED
, "Tagged" },
194 { RFC4675_UNTAGGED
, "Untagged" },
199 static void print_attr_string(netdissect_options
*, const u_char
*, u_int
, u_short
);
200 static void print_attr_num(netdissect_options
*, const u_char
*, u_int
, u_short
);
201 static void print_vendor_attr(netdissect_options
*, const u_char
*, u_int
, u_short
);
202 static void print_attr_address(netdissect_options
*, const u_char
*, u_int
, u_short
);
203 static void print_attr_address6(netdissect_options
*, const u_char
*, u_int
, u_short
);
204 static void print_attr_netmask6(netdissect_options
*, const u_char
*, u_int
, u_short
);
205 static void print_attr_mip6_home_link_prefix(netdissect_options
*, const u_char
*, u_int
, u_short
);
206 static void print_attr_time(netdissect_options
*, const u_char
*, u_int
, u_short
);
207 static void print_attr_vector64(netdissect_options
*, register const u_char
*, u_int
, u_short
);
208 static void print_attr_strange(netdissect_options
*, const u_char
*, u_int
, u_short
);
211 struct radius_hdr
{ nd_uint8_t code
; /* Radius packet code */
212 nd_uint8_t id
; /* Radius packet id */
213 nd_uint16_t len
; /* Radius total length */
214 nd_byte auth
[16]; /* Authenticator */
217 #define MIN_RADIUS_LEN 20
219 struct radius_attr
{ nd_uint8_t type
; /* Attribute type */
220 nd_uint8_t len
; /* Attribute length */
224 /* Service-Type Attribute standard values */
225 static const char *serv_type
[]={ NULL
,
234 "Callback NAS Prompt",
236 "Callback Administrative",
239 /* Framed-Protocol Attribute standard values */
240 static const char *frm_proto
[]={ NULL
,
244 "Gandalf proprietary",
249 /* Framed-Routing Attribute standard values */
250 static const char *frm_routing
[]={ "None",
256 /* Framed-Compression Attribute standard values */
257 static const char *frm_comp
[]={ "None",
263 /* Login-Service Attribute standard values */
264 static const char *login_serv
[]={ "Telnet",
267 "PortMaster(proprietary)",
276 /* Termination-Action Attribute standard values */
277 static const char *term_action
[]={ "Default",
281 /* Ingress-Filters Attribute standard values */
282 static const char *ingress_filters
[]={ NULL
,
287 /* NAS-Port-Type Attribute standard values */
288 static const char *nas_port_type
[]={ "Async",
295 "HDLC Clear Channel",
307 "Wireless - IEEE 802.11",
310 /* Acct-Status-Type Accounting Attribute standard values */
311 static const char *acct_status
[]={ NULL
,
325 "Tunnel-Link-Reject",
329 /* Acct-Authentic Accounting Attribute standard values */
330 static const char *acct_auth
[]={ NULL
,
336 /* Acct-Terminate-Cause Accounting Attribute standard values */
337 static const char *acct_term
[]={ NULL
,
352 "Service Unavailable",
358 /* Tunnel-Type Attribute standard values */
359 static const char *tunnel_type
[]={ NULL
,
371 "IP-in-IP Tunneling",
375 /* Tunnel-Medium-Type Attribute standard values */
376 static const char *tunnel_medium
[]={ NULL
,
391 "E.164 with NSAP subaddress",
394 /* ARAP-Zone-Access Attribute standard values */
395 static const char *arap_zone
[]={ NULL
,
396 "Only access to dfl zone",
397 "Use zone filter inc.",
399 "Use zone filter exc.",
402 static const char *prompt
[]={ "No Echo",
406 /* Error-Cause standard values */
407 #define ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED 201
408 #define ERROR_CAUSE_INVALID_EAP_PACKET 202
409 #define ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE 401
410 #define ERROR_CAUSE_MISSING_ATTRIBUTE 402
411 #define ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH 403
412 #define ERROR_CAUSE_INVALID_REQUEST 404
413 #define ERROR_CAUSE_UNSUPPORTED_SERVICE 405
414 #define ERROR_CAUSE_UNSUPPORTED_EXTENSION 406
415 #define ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE 407
416 #define ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED 501
417 #define ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE 502
418 #define ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND 503
419 #define ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE 504
420 #define ERROR_CAUSE_PROXY_PROCESSING_ERROR 505
421 #define ERROR_CAUSE_RESOURCES_UNAVAILABLE 506
422 #define ERROR_CAUSE_REQUEST_INITIATED 507
423 #define ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED 508
424 #define ERROR_CAUSE_LOCATION_INFO_REQUIRED 509
425 static const struct tok errorcausetype
[] = {
426 { ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED
, "Residual Session Context Removed" },
427 { ERROR_CAUSE_INVALID_EAP_PACKET
, "Invalid EAP Packet (Ignored)" },
428 { ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE
, "Unsupported Attribute" },
429 { ERROR_CAUSE_MISSING_ATTRIBUTE
, "Missing Attribute" },
430 { ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH
, "NAS Identification Mismatch" },
431 { ERROR_CAUSE_INVALID_REQUEST
, "Invalid Request" },
432 { ERROR_CAUSE_UNSUPPORTED_SERVICE
, "Unsupported Service" },
433 { ERROR_CAUSE_UNSUPPORTED_EXTENSION
, "Unsupported Extension" },
434 { ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE
, "Invalid Attribute Value" },
435 { ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED
, "Administratively Prohibited" },
436 { ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE
, "Request Not Routable (Proxy)" },
437 { ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND
, "Session Context Not Found" },
438 { ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE
, "Session Context Not Removable" },
439 { ERROR_CAUSE_PROXY_PROCESSING_ERROR
, "Other Proxy Processing Error" },
440 { ERROR_CAUSE_RESOURCES_UNAVAILABLE
, "Resources Unavailable" },
441 { ERROR_CAUSE_REQUEST_INITIATED
, "Request Initiated" },
442 { ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED
, "Multiple Session Selection Unsupported" },
443 { ERROR_CAUSE_LOCATION_INFO_REQUIRED
, "Location Info Required" },
447 /* MIP6-Feature-Vector standard values */
448 #define MIP6_INTEGRATED 0x0000000000000001
449 #define LOCAL_HOME_AGENT_ASSIGNMENT 0x0000000000000002
450 #define PMIP6_SUPPORTED 0x0000010000000000
451 #define IP4_HOA_SUPPORTED 0x0000020000000000
452 #define LOCAL_MAG_ROUTING_SUPPORTED 0x0000040000000000
453 #define IP4_TRANSPORT_SUPPORTED 0x0000800000000000
454 #define IP4_HOA_ONLY_SUPPORTED 0x0001000000000000
455 static struct mip6_feature_vector
{
458 } mip6_feature_vector
[] = {
459 { MIP6_INTEGRATED
, "MIP6_INTEGRATED" },
460 { LOCAL_HOME_AGENT_ASSIGNMENT
, "LOCAL_HOME_AGENT_ASSIGNMENT" },
461 { PMIP6_SUPPORTED
, "PMIP6_SUPPORTED" },
462 { IP4_HOA_SUPPORTED
, "IP4_HOA_SUPPORTED" },
463 { LOCAL_MAG_ROUTING_SUPPORTED
, "LOCAL_MAG_ROUTING_SUPPORTED" },
464 { IP4_TRANSPORT_SUPPORTED
, "IP4_TRANSPORT_SUPPORTED" },
465 { IP4_HOA_ONLY_SUPPORTED
, "IP4_HOA_ONLY_SUPPORTED" }
469 static struct attrtype
{
470 const char *name
; /* Attribute name */
471 const char **subtypes
; /* Standard Values (if any) */
472 u_char siz_subtypes
; /* Size of total standard values */
473 u_char first_subtype
; /* First standard value is 0 or 1 */
474 void (*print_func
)(netdissect_options
*, const u_char
*, u_int
, u_short
);
477 { NULL
, NULL
, 0, 0, NULL
},
478 { "User-Name", NULL
, 0, 0, print_attr_string
},
479 { "User-Password", NULL
, 0, 0, NULL
},
480 { "CHAP-Password", NULL
, 0, 0, NULL
},
481 { "NAS-IP-Address", NULL
, 0, 0, print_attr_address
},
482 { "NAS-Port", NULL
, 0, 0, print_attr_num
},
483 { "Service-Type", serv_type
, TAM_SIZE(serv_type
)-1, 1, print_attr_num
},
484 { "Framed-Protocol", frm_proto
, TAM_SIZE(frm_proto
)-1, 1, print_attr_num
},
485 { "Framed-IP-Address", NULL
, 0, 0, print_attr_address
},
486 { "Framed-IP-Netmask", NULL
, 0, 0, print_attr_address
},
487 { "Framed-Routing", frm_routing
, TAM_SIZE(frm_routing
), 0, print_attr_num
},
488 { "Filter-Id", NULL
, 0, 0, print_attr_string
},
489 { "Framed-MTU", NULL
, 0, 0, print_attr_num
},
490 { "Framed-Compression", frm_comp
, TAM_SIZE(frm_comp
), 0, print_attr_num
},
491 { "Login-IP-Host", NULL
, 0, 0, print_attr_address
},
492 { "Login-Service", login_serv
, TAM_SIZE(login_serv
), 0, print_attr_num
},
493 { "Login-TCP-Port", NULL
, 0, 0, print_attr_num
},
494 { "Unassigned", NULL
, 0, 0, NULL
}, /*17*/
495 { "Reply-Message", NULL
, 0, 0, print_attr_string
},
496 { "Callback-Number", NULL
, 0, 0, print_attr_string
},
497 { "Callback-Id", NULL
, 0, 0, print_attr_string
},
498 { "Unassigned", NULL
, 0, 0, NULL
}, /*21*/
499 { "Framed-Route", NULL
, 0, 0, print_attr_string
},
500 { "Framed-IPX-Network", NULL
, 0, 0, print_attr_num
},
501 { "State", NULL
, 0, 0, print_attr_string
},
502 { "Class", NULL
, 0, 0, print_attr_string
},
503 { "Vendor-Specific", NULL
, 0, 0, print_vendor_attr
},
504 { "Session-Timeout", NULL
, 0, 0, print_attr_num
},
505 { "Idle-Timeout", NULL
, 0, 0, print_attr_num
},
506 { "Termination-Action", term_action
, TAM_SIZE(term_action
), 0, print_attr_num
},
507 { "Called-Station-Id", NULL
, 0, 0, print_attr_string
},
508 { "Calling-Station-Id", NULL
, 0, 0, print_attr_string
},
509 { "NAS-Identifier", NULL
, 0, 0, print_attr_string
},
510 { "Proxy-State", NULL
, 0, 0, print_attr_string
},
511 { "Login-LAT-Service", NULL
, 0, 0, print_attr_string
},
512 { "Login-LAT-Node", NULL
, 0, 0, print_attr_string
},
513 { "Login-LAT-Group", NULL
, 0, 0, print_attr_string
},
514 { "Framed-AppleTalk-Link", NULL
, 0, 0, print_attr_num
},
515 { "Framed-AppleTalk-Network", NULL
, 0, 0, print_attr_num
},
516 { "Framed-AppleTalk-Zone", NULL
, 0, 0, print_attr_string
},
517 { "Acct-Status-Type", acct_status
, TAM_SIZE(acct_status
)-1, 1, print_attr_num
},
518 { "Acct-Delay-Time", NULL
, 0, 0, print_attr_num
},
519 { "Acct-Input-Octets", NULL
, 0, 0, print_attr_num
},
520 { "Acct-Output-Octets", NULL
, 0, 0, print_attr_num
},
521 { "Acct-Session-Id", NULL
, 0, 0, print_attr_string
},
522 { "Acct-Authentic", acct_auth
, TAM_SIZE(acct_auth
)-1, 1, print_attr_num
},
523 { "Acct-Session-Time", NULL
, 0, 0, print_attr_num
},
524 { "Acct-Input-Packets", NULL
, 0, 0, print_attr_num
},
525 { "Acct-Output-Packets", NULL
, 0, 0, print_attr_num
},
526 { "Acct-Terminate-Cause", acct_term
, TAM_SIZE(acct_term
)-1, 1, print_attr_num
},
527 { "Acct-Multi-Session-Id", NULL
, 0, 0, print_attr_string
},
528 { "Acct-Link-Count", NULL
, 0, 0, print_attr_num
},
529 { "Acct-Input-Gigawords", NULL
, 0, 0, print_attr_num
},
530 { "Acct-Output-Gigawords", NULL
, 0, 0, print_attr_num
},
531 { "Unassigned", NULL
, 0, 0, NULL
}, /*54*/
532 { "Event-Timestamp", NULL
, 0, 0, print_attr_time
},
533 { "Egress-VLANID", NULL
, 0, 0, print_attr_num
},
534 { "Ingress-Filters", ingress_filters
, TAM_SIZE(ingress_filters
)-1, 1, print_attr_num
},
535 { "Egress-VLAN-Name", NULL
, 0, 0, print_attr_string
},
536 { "User-Priority-Table", NULL
, 0, 0, NULL
},
537 { "CHAP-Challenge", NULL
, 0, 0, print_attr_string
},
538 { "NAS-Port-Type", nas_port_type
, TAM_SIZE(nas_port_type
), 0, print_attr_num
},
539 { "Port-Limit", NULL
, 0, 0, print_attr_num
},
540 { "Login-LAT-Port", NULL
, 0, 0, print_attr_string
}, /*63*/
541 { "Tunnel-Type", tunnel_type
, TAM_SIZE(tunnel_type
)-1, 1, print_attr_num
},
542 { "Tunnel-Medium-Type", tunnel_medium
, TAM_SIZE(tunnel_medium
)-1, 1, print_attr_num
},
543 { "Tunnel-Client-Endpoint", NULL
, 0, 0, print_attr_string
},
544 { "Tunnel-Server-Endpoint", NULL
, 0, 0, print_attr_string
},
545 { "Acct-Tunnel-Connection", NULL
, 0, 0, print_attr_string
},
546 { "Tunnel-Password", NULL
, 0, 0, print_attr_string
},
547 { "ARAP-Password", NULL
, 0, 0, print_attr_strange
},
548 { "ARAP-Features", NULL
, 0, 0, print_attr_strange
},
549 { "ARAP-Zone-Access", arap_zone
, TAM_SIZE(arap_zone
)-1, 1, print_attr_num
}, /*72*/
550 { "ARAP-Security", NULL
, 0, 0, print_attr_string
},
551 { "ARAP-Security-Data", NULL
, 0, 0, print_attr_string
},
552 { "Password-Retry", NULL
, 0, 0, print_attr_num
},
553 { "Prompt", prompt
, TAM_SIZE(prompt
), 0, print_attr_num
},
554 { "Connect-Info", NULL
, 0, 0, print_attr_string
},
555 { "Configuration-Token", NULL
, 0, 0, print_attr_string
},
556 { "EAP-Message", NULL
, 0, 0, print_attr_string
},
557 { "Message-Authenticator", NULL
, 0, 0, print_attr_string
}, /*80*/
558 { "Tunnel-Private-Group-ID", NULL
, 0, 0, print_attr_string
},
559 { "Tunnel-Assignment-ID", NULL
, 0, 0, print_attr_string
},
560 { "Tunnel-Preference", NULL
, 0, 0, print_attr_num
},
561 { "ARAP-Challenge-Response", NULL
, 0, 0, print_attr_strange
},
562 { "Acct-Interim-Interval", NULL
, 0, 0, print_attr_num
},
563 { "Acct-Tunnel-Packets-Lost", NULL
, 0, 0, print_attr_num
}, /*86*/
564 { "NAS-Port-Id", NULL
, 0, 0, print_attr_string
},
565 { "Framed-Pool", NULL
, 0, 0, print_attr_string
},
566 { "CUI", NULL
, 0, 0, print_attr_string
},
567 { "Tunnel-Client-Auth-ID", NULL
, 0, 0, print_attr_string
},
568 { "Tunnel-Server-Auth-ID", NULL
, 0, 0, print_attr_string
},
569 { "NAS-Filter-Rule", NULL
, 0, 0, print_attr_string
},
570 { "Unassigned", NULL
, 0, 0, NULL
}, /*93*/
571 { "Originating-Line-Info", NULL
, 0, 0, NULL
},
572 { "NAS-IPv6-Address", NULL
, 0, 0, print_attr_address6
},
573 { "Framed-Interface-ID", NULL
, 0, 0, NULL
},
574 { "Framed-IPv6-Prefix", NULL
, 0, 0, print_attr_netmask6
},
575 { "Login-IPv6-Host", NULL
, 0, 0, print_attr_address6
},
576 { "Framed-IPv6-Route", NULL
, 0, 0, print_attr_string
},
577 { "Framed-IPv6-Pool", NULL
, 0, 0, print_attr_string
},
578 { "Error-Cause", NULL
, 0, 0, print_attr_strange
},
579 { "EAP-Key-Name", NULL
, 0, 0, NULL
},
580 { "Digest-Response", NULL
, 0, 0, print_attr_string
},
581 { "Digest-Realm", NULL
, 0, 0, print_attr_string
},
582 { "Digest-Nonce", NULL
, 0, 0, print_attr_string
},
583 { "Digest-Response-Auth", NULL
, 0, 0, print_attr_string
},
584 { "Digest-Nextnonce", NULL
, 0, 0, print_attr_string
},
585 { "Digest-Method", NULL
, 0, 0, print_attr_string
},
586 { "Digest-URI", NULL
, 0, 0, print_attr_string
},
587 { "Digest-Qop", NULL
, 0, 0, print_attr_string
},
588 { "Digest-Algorithm", NULL
, 0, 0, print_attr_string
},
589 { "Digest-Entity-Body-Hash", NULL
, 0, 0, print_attr_string
},
590 { "Digest-CNonce", NULL
, 0, 0, print_attr_string
},
591 { "Digest-Nonce-Count", NULL
, 0, 0, print_attr_string
},
592 { "Digest-Username", NULL
, 0, 0, print_attr_string
},
593 { "Digest-Opaque", NULL
, 0, 0, print_attr_string
},
594 { "Digest-Auth-Param", NULL
, 0, 0, print_attr_string
},
595 { "Digest-AKA-Auts", NULL
, 0, 0, print_attr_string
},
596 { "Digest-Domain", NULL
, 0, 0, print_attr_string
},
597 { "Digest-Stale", NULL
, 0, 0, print_attr_string
},
598 { "Digest-HA1", NULL
, 0, 0, print_attr_string
},
599 { "SIP-AOR", NULL
, 0, 0, print_attr_string
},
600 { "Delegated-IPv6-Prefix", NULL
, 0, 0, print_attr_netmask6
},
601 { "MIP6-Feature-Vector", NULL
, 0, 0, print_attr_vector64
},
602 { "MIP6-Home-Link-Prefix", NULL
, 0, 0, print_attr_mip6_home_link_prefix
},
606 /*****************************/
607 /* Print an attribute string */
608 /* value pointed by 'data' */
609 /* and 'length' size. */
610 /*****************************/
611 /* Returns nothing. */
612 /*****************************/
614 print_attr_string(netdissect_options
*ndo
,
615 const u_char
*data
, u_int length
, u_short attr_code
)
619 ND_TCHECK_LEN(data
, length
);
626 if (EXTRACT_U_1(data
) && (EXTRACT_U_1(data
) <= 0x1F))
627 ND_PRINT("Tag[%u] ", EXTRACT_U_1(data
));
629 ND_PRINT("Tag[Unused] ");
632 ND_PRINT("Salt %u ", EXTRACT_BE_U_2(data
));
636 case TUNNEL_CLIENT_END
:
637 case TUNNEL_SERVER_END
:
638 case TUNNEL_PRIV_GROUP
:
639 case TUNNEL_ASSIGN_ID
:
640 case TUNNEL_CLIENT_AUTH
:
641 case TUNNEL_SERVER_AUTH
:
642 if (EXTRACT_U_1(data
) <= 0x1F)
646 if (EXTRACT_U_1(data
))
647 ND_PRINT("Tag[%u] ", EXTRACT_U_1(data
));
649 ND_PRINT("Tag[Unused] ");
654 case EGRESS_VLAN_NAME
:
657 ND_PRINT("%s (0x%02x) ",
658 tok2str(rfc4675_tagged
,"Unknown tag",EXTRACT_U_1(data
)),
665 for (i
=0; i
< length
&& EXTRACT_U_1(data
); i
++, data
++)
666 ND_PRINT("%c", ND_ISPRINT(EXTRACT_U_1(data
)) ? EXTRACT_U_1(data
) : '.');
675 * print vendor specific attributes
678 print_vendor_attr(netdissect_options
*ndo
,
679 const u_char
*data
, u_int length
, u_short attr_code _U_
)
689 vendor_id
= EXTRACT_BE_U_4(data
);
693 ND_PRINT("Vendor: %s (%u)",
694 tok2str(smi_values
,"Unknown",vendor_id
),
697 while (length
>= 2) {
700 vendor_type
= EXTRACT_U_1(data
);
701 vendor_length
= EXTRACT_U_1(data
+ 1);
703 if (vendor_length
< 2)
705 ND_PRINT("\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
710 if (vendor_length
> length
)
712 ND_PRINT("\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
720 ND_TCHECK_LEN(data
, vendor_length
);
722 ND_PRINT("\n\t Vendor Attribute: %u, Length: %u, Value: ",
725 for (idx
= 0; idx
< vendor_length
; idx
++, data
++)
726 ND_PRINT("%c", ND_ISPRINT(EXTRACT_U_1(data
)) ? EXTRACT_U_1(data
) : '.');
727 length
-=vendor_length
;
735 /******************************/
736 /* Print an attribute numeric */
737 /* value pointed by 'data' */
738 /* and 'length' size. */
739 /******************************/
740 /* Returns nothing. */
741 /******************************/
743 print_attr_num(netdissect_options
*ndo
,
744 const u_char
*data
, u_int length
, u_short attr_code
)
750 ND_PRINT("ERROR: length %u != 4", length
);
755 /* This attribute has standard values */
756 if (attr_type
[attr_code
].siz_subtypes
)
758 static const char **table
;
760 table
= attr_type
[attr_code
].subtypes
;
762 if ( (attr_code
== TUNNEL_TYPE
) || (attr_code
== TUNNEL_MEDIUM
) )
764 if (!EXTRACT_U_1(data
))
765 ND_PRINT("Tag[Unused] ");
767 ND_PRINT("Tag[%u] ", EXTRACT_U_1(data
));
769 data_value
= EXTRACT_BE_U_3(data
);
773 data_value
= EXTRACT_BE_U_4(data
);
775 if ( data_value
<= (uint32_t)(attr_type
[attr_code
].siz_subtypes
- 1 +
776 attr_type
[attr_code
].first_subtype
) &&
777 data_value
>= attr_type
[attr_code
].first_subtype
)
778 ND_PRINT("%s", table
[data_value
]);
780 ND_PRINT("#%u", data_value
);
784 switch(attr_code
) /* Be aware of special cases... */
787 if (EXTRACT_BE_U_4(data
) == 0xFFFFFFFE )
788 ND_PRINT("NAS Select");
790 ND_PRINT("%u", EXTRACT_BE_U_4(data
));
793 case SESSION_TIMEOUT
:
796 case ACCT_SESSION_TIME
:
797 case ACCT_INT_INTERVAL
:
798 timeout
= EXTRACT_BE_U_4(data
);
800 ND_PRINT("%02d secs", timeout
);
803 if ( timeout
< 3600 )
804 ND_PRINT("%02d:%02d min",
805 timeout
/ 60, timeout
% 60);
807 ND_PRINT("%02d:%02d:%02d hours",
808 timeout
/ 3600, (timeout
% 3600) / 60,
814 if (EXTRACT_BE_U_4(data
))
815 ND_PRINT("%u", EXTRACT_BE_U_4(data
));
817 ND_PRINT("Unnumbered");
820 case FRM_ATALK_NETWORK
:
821 if (EXTRACT_BE_U_4(data
))
822 ND_PRINT("%u", EXTRACT_BE_U_4(data
));
824 ND_PRINT("NAS assigned");
827 case TUNNEL_PREFERENCE
:
828 if (EXTRACT_U_1(data
))
829 ND_PRINT("Tag[%u] ", EXTRACT_U_1(data
));
831 ND_PRINT("Tag[Unused] ");
833 ND_PRINT("%u", EXTRACT_BE_U_3(data
));
837 ND_PRINT("%s (0x%02x) ",
838 tok2str(rfc4675_tagged
,"Unknown tag",EXTRACT_U_1(data
)),
841 ND_PRINT("%u", EXTRACT_BE_U_3(data
));
845 ND_PRINT("%u", EXTRACT_BE_U_4(data
));
858 /*****************************/
859 /* Print an attribute IPv4 */
860 /* address value pointed by */
861 /* 'data' and 'length' size. */
862 /*****************************/
863 /* Returns nothing. */
864 /*****************************/
866 print_attr_address(netdissect_options
*ndo
,
867 const u_char
*data
, u_int length
, u_short attr_code
)
871 ND_PRINT("ERROR: length %u != 4", length
);
881 if (EXTRACT_BE_U_4(data
) == 0xFFFFFFFF )
882 ND_PRINT("User Selected");
884 if (EXTRACT_BE_U_4(data
) == 0xFFFFFFFE )
885 ND_PRINT("NAS Select");
887 ND_PRINT("%s",ipaddr_string(ndo
, data
));
891 ND_PRINT("%s", ipaddr_string(ndo
, data
));
901 /*****************************/
902 /* Print an attribute IPv6 */
903 /* address value pointed by */
904 /* 'data' and 'length' size. */
905 /*****************************/
906 /* Returns nothing. */
907 /*****************************/
909 print_attr_address6(netdissect_options
*ndo
,
910 const u_char
*data
, u_int length
, u_short attr_code _U_
)
914 ND_PRINT("ERROR: length %u != 16", length
);
920 ND_PRINT("%s", ip6addr_string(ndo
, data
));
929 print_attr_netmask6(netdissect_options
*ndo
,
930 const u_char
*data
, u_int length
, u_short attr_code _U_
)
934 if (length
< 2 || length
> 18)
936 ND_PRINT("ERROR: length %u not in range (2..18)", length
);
939 ND_TCHECK_LEN(data
, length
);
940 if (EXTRACT_U_1(data
+ 1) > 128)
942 ND_PRINT("ERROR: netmask %u not in range (0..128)", EXTRACT_U_1(data
+ 1));
946 memset(data2
, 0, sizeof(data2
));
948 memcpy(data2
, data
+2, length
-2);
950 ND_PRINT("%s/%u", ip6addr_string(ndo
, data2
), EXTRACT_U_1(data
+ 1));
952 if (EXTRACT_U_1(data
+ 1) > 8 * (length
- 2))
953 ND_PRINT(" (inconsistent prefix length)");
962 print_attr_mip6_home_link_prefix(netdissect_options
*ndo
,
963 const u_char
*data
, u_int length
, u_short attr_code _U_
)
967 ND_PRINT("ERROR: length %u != 17", length
);
970 ND_TCHECK_LEN(data
, length
);
971 if (EXTRACT_U_1(data
) > 128)
973 ND_PRINT("ERROR: netmask %u not in range (0..128)", EXTRACT_U_1(data
));
977 ND_PRINT("%s/%u", ip6addr_string(ndo
, data
+ 1), EXTRACT_U_1(data
));
985 /*************************************/
986 /* Print an attribute of 'secs since */
987 /* January 1, 1970 00:00 UTC' value */
988 /* pointed by 'data' and 'length' */
990 /*************************************/
991 /* Returns nothing. */
992 /*************************************/
994 print_attr_time(netdissect_options
*ndo
,
995 const u_char
*data
, u_int length
, u_short attr_code _U_
)
1002 ND_PRINT("ERROR: length %u != 4", length
);
1008 attr_time
= EXTRACT_BE_U_4(data
);
1009 strlcpy(string
, ctime(&attr_time
), sizeof(string
));
1010 /* Get rid of the newline */
1012 ND_PRINT("%.24s", string
);
1016 nd_print_trunc(ndo
);
1020 print_attr_vector64(netdissect_options
*ndo
,
1021 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
1023 uint64_t data_value
, i
;
1024 const char *sep
= "";
1028 ND_PRINT("ERROR: length %u != 8", length
);
1033 ND_TCHECK_8(data
[0]);
1035 data_value
= EXTRACT_BE_U_8(data
);
1036 /* Print the 64-bit field in a format similar to bittok2str(), less
1037 * flagging any unknown bits. This way it should be easier to replace
1038 * the custom code with a library function later.
1040 for (i
= 0; i
< TAM_SIZE(mip6_feature_vector
); i
++) {
1041 if (data_value
& mip6_feature_vector
[i
].v
) {
1042 ND_PRINT("%s%s", sep
, mip6_feature_vector
[i
].s
);
1052 nd_print_trunc(ndo
);
1055 /***********************************/
1056 /* Print an attribute of 'strange' */
1057 /* data format pointed by 'data' */
1058 /* and 'length' size. */
1059 /***********************************/
1060 /* Returns nothing. */
1061 /***********************************/
1063 print_attr_strange(netdissect_options
*ndo
,
1064 const u_char
*data
, u_int length
, u_short attr_code
)
1067 u_int error_cause_value
;
1074 ND_PRINT("ERROR: length %u != 16", length
);
1077 ND_PRINT("User_challenge (");
1080 PRINT_HEX(len_data
, data
);
1081 ND_PRINT(") User_resp(");
1084 PRINT_HEX(len_data
, data
);
1091 ND_PRINT("ERROR: length %u != 14", length
);
1095 if (EXTRACT_U_1(data
))
1096 ND_PRINT("User can change password");
1098 ND_PRINT("User cannot change password");
1101 ND_PRINT(", Min password length: %u", EXTRACT_U_1(data
));
1103 ND_PRINT(", created at: ");
1106 PRINT_HEX(len_data
, data
);
1107 ND_PRINT(", expires in: ");
1110 PRINT_HEX(len_data
, data
);
1111 ND_PRINT(", Current Time: ");
1114 PRINT_HEX(len_data
, data
);
1117 case ARAP_CHALLENGE_RESP
:
1120 ND_PRINT("ERROR: length %u != 8", length
);
1125 PRINT_HEX(len_data
, data
);
1131 ND_PRINT("Error: length %u != 4", length
);
1136 error_cause_value
= EXTRACT_BE_U_4(data
);
1137 ND_PRINT("Error cause %u: %s", error_cause_value
, tok2str(errorcausetype
, "Error-Cause %u not known", error_cause_value
));
1143 nd_print_trunc(ndo
);
1147 radius_attrs_print(netdissect_options
*ndo
,
1148 const u_char
*attr
, u_int length
)
1150 const struct radius_attr
*rad_attr
= (const struct radius_attr
*)attr
;
1151 const char *attr_string
;
1158 ND_TCHECK_SIZE(rad_attr
);
1160 type
= EXTRACT_U_1(rad_attr
->type
);
1161 len
= EXTRACT_U_1(rad_attr
->len
);
1162 if (type
!= 0 && type
< TAM_SIZE(attr_type
))
1163 attr_string
= attr_type
[type
].name
;
1165 attr_string
= "Unknown";
1168 ND_PRINT("\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
1176 ND_PRINT("\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
1182 ND_PRINT("\n\t %s Attribute (%u), length: %u, Value: ",
1187 if (type
< TAM_SIZE(attr_type
))
1191 if ( attr_type
[type
].print_func
)
1192 (*attr_type
[type
].print_func
)(
1193 ndo
, ((const u_char
*)(rad_attr
+1)),
1197 /* do we also want to see a hex dump ? */
1198 if (ndo
->ndo_vflag
> 1)
1199 print_unknown_data(ndo
, (const u_char
*)rad_attr
+2, "\n\t ", (len
)-2);
1202 rad_attr
= (const struct radius_attr
*)( ((const char *)(rad_attr
))+len
);
1207 nd_print_trunc(ndo
);
1211 radius_print(netdissect_options
*ndo
,
1212 const u_char
*dat
, u_int length
)
1214 const struct radius_hdr
*rad
;
1215 u_int len
, auth_idx
;
1217 ndo
->ndo_protocol
= "radius";
1218 ND_TCHECK_LEN(dat
, MIN_RADIUS_LEN
);
1219 rad
= (const struct radius_hdr
*)dat
;
1220 len
= EXTRACT_BE_U_2(rad
->len
);
1222 if (len
< MIN_RADIUS_LEN
)
1224 nd_print_trunc(ndo
);
1231 if (ndo
->ndo_vflag
< 1) {
1232 ND_PRINT("RADIUS, %s (%u), id: 0x%02x length: %u",
1233 tok2str(radius_command_values
,"Unknown Command",EXTRACT_U_1(rad
->code
)),
1234 EXTRACT_U_1(rad
->code
),
1235 EXTRACT_U_1(rad
->id
),
1240 ND_PRINT("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
1242 tok2str(radius_command_values
,"Unknown Command",EXTRACT_U_1(rad
->code
)),
1243 EXTRACT_U_1(rad
->code
),
1244 EXTRACT_U_1(rad
->id
));
1246 for(auth_idx
=0; auth_idx
< 16; auth_idx
++)
1247 ND_PRINT("%02x", rad
->auth
[auth_idx
]);
1250 if (len
> MIN_RADIUS_LEN
)
1251 radius_attrs_print(ndo
, dat
+ MIN_RADIUS_LEN
, len
- MIN_RADIUS_LEN
);
1255 nd_print_trunc(ndo
);