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 /* https://www.iana.org/assignments/aaa-parameters/aaa-parameters.xhtml */
449 #define MIP6_INTEGRATED 0x0000000000000001
450 #define LOCAL_HOME_AGENT_ASSIGNMENT 0x0000000000000002
451 #define PMIP6_SUPPORTED 0x0000010000000000
452 #define IP4_HOA_SUPPORTED 0x0000020000000000
453 #define LOCAL_MAG_ROUTING_SUPPORTED 0x0000040000000000
454 #define ASSIGN_LOCAL_IP 0x0000080000000000
455 #define MIP4_SUPPORTED 0x0000100000000000
456 #define OPTIMIZED_IDLE_MODE_MOBILITY 0x0000200000000000
457 #define GTPv2_SUPPORTED 0x0000400000000000
458 #define IP4_TRANSPORT_SUPPORTED 0x0000800000000000
459 #define IP4_HOA_ONLY_SUPPORTED 0x0001000000000000
460 #define INTER_MAG_ROUTING_SUPPORTED 0x0002000000000000
461 static const struct mip6_feature_vector
{
464 } mip6_feature_vector
[] = {
465 { MIP6_INTEGRATED
, "MIP6_INTEGRATED" },
466 { LOCAL_HOME_AGENT_ASSIGNMENT
, "LOCAL_HOME_AGENT_ASSIGNMENT" },
467 { PMIP6_SUPPORTED
, "PMIP6_SUPPORTED" },
468 { IP4_HOA_SUPPORTED
, "IP4_HOA_SUPPORTED" },
469 { LOCAL_MAG_ROUTING_SUPPORTED
, "LOCAL_MAG_ROUTING_SUPPORTED" },
470 { ASSIGN_LOCAL_IP
, "ASSIGN_LOCAL_IP" },
471 { MIP4_SUPPORTED
, "MIP4_SUPPORTED" },
472 { OPTIMIZED_IDLE_MODE_MOBILITY
, "OPTIMIZED_IDLE_MODE_MOBILITY" },
473 { GTPv2_SUPPORTED
, "GTPv2_SUPPORTED" },
474 { IP4_TRANSPORT_SUPPORTED
, "IP4_TRANSPORT_SUPPORTED" },
475 { IP4_HOA_ONLY_SUPPORTED
, "IP4_HOA_ONLY_SUPPORTED" },
476 { INTER_MAG_ROUTING_SUPPORTED
, "INTER_MAG_ROUTING_SUPPORTED" },
480 static const struct attrtype
{
481 const char *name
; /* Attribute name */
482 const char **subtypes
; /* Standard Values (if any) */
483 u_char siz_subtypes
; /* Size of total standard values */
484 u_char first_subtype
; /* First standard value is 0 or 1 */
485 void (*print_func
)(netdissect_options
*, const u_char
*, u_int
, u_short
);
488 { NULL
, NULL
, 0, 0, NULL
},
489 { "User-Name", NULL
, 0, 0, print_attr_string
},
490 { "User-Password", NULL
, 0, 0, NULL
},
491 { "CHAP-Password", NULL
, 0, 0, NULL
},
492 { "NAS-IP-Address", NULL
, 0, 0, print_attr_address
},
493 { "NAS-Port", NULL
, 0, 0, print_attr_num
},
494 { "Service-Type", serv_type
, TAM_SIZE(serv_type
)-1, 1, print_attr_num
},
495 { "Framed-Protocol", frm_proto
, TAM_SIZE(frm_proto
)-1, 1, print_attr_num
},
496 { "Framed-IP-Address", NULL
, 0, 0, print_attr_address
},
497 { "Framed-IP-Netmask", NULL
, 0, 0, print_attr_address
},
498 { "Framed-Routing", frm_routing
, TAM_SIZE(frm_routing
), 0, print_attr_num
},
499 { "Filter-Id", NULL
, 0, 0, print_attr_string
},
500 { "Framed-MTU", NULL
, 0, 0, print_attr_num
},
501 { "Framed-Compression", frm_comp
, TAM_SIZE(frm_comp
), 0, print_attr_num
},
502 { "Login-IP-Host", NULL
, 0, 0, print_attr_address
},
503 { "Login-Service", login_serv
, TAM_SIZE(login_serv
), 0, print_attr_num
},
504 { "Login-TCP-Port", NULL
, 0, 0, print_attr_num
},
505 { "Unassigned", NULL
, 0, 0, NULL
}, /*17*/
506 { "Reply-Message", NULL
, 0, 0, print_attr_string
},
507 { "Callback-Number", NULL
, 0, 0, print_attr_string
},
508 { "Callback-Id", NULL
, 0, 0, print_attr_string
},
509 { "Unassigned", NULL
, 0, 0, NULL
}, /*21*/
510 { "Framed-Route", NULL
, 0, 0, print_attr_string
},
511 { "Framed-IPX-Network", NULL
, 0, 0, print_attr_num
},
512 { "State", NULL
, 0, 0, print_attr_string
},
513 { "Class", NULL
, 0, 0, print_attr_string
},
514 { "Vendor-Specific", NULL
, 0, 0, print_vendor_attr
},
515 { "Session-Timeout", NULL
, 0, 0, print_attr_num
},
516 { "Idle-Timeout", NULL
, 0, 0, print_attr_num
},
517 { "Termination-Action", term_action
, TAM_SIZE(term_action
), 0, print_attr_num
},
518 { "Called-Station-Id", NULL
, 0, 0, print_attr_string
},
519 { "Calling-Station-Id", NULL
, 0, 0, print_attr_string
},
520 { "NAS-Identifier", NULL
, 0, 0, print_attr_string
},
521 { "Proxy-State", NULL
, 0, 0, print_attr_string
},
522 { "Login-LAT-Service", NULL
, 0, 0, print_attr_string
},
523 { "Login-LAT-Node", NULL
, 0, 0, print_attr_string
},
524 { "Login-LAT-Group", NULL
, 0, 0, print_attr_string
},
525 { "Framed-AppleTalk-Link", NULL
, 0, 0, print_attr_num
},
526 { "Framed-AppleTalk-Network", NULL
, 0, 0, print_attr_num
},
527 { "Framed-AppleTalk-Zone", NULL
, 0, 0, print_attr_string
},
528 { "Acct-Status-Type", acct_status
, TAM_SIZE(acct_status
)-1, 1, print_attr_num
},
529 { "Acct-Delay-Time", NULL
, 0, 0, print_attr_num
},
530 { "Acct-Input-Octets", NULL
, 0, 0, print_attr_num
},
531 { "Acct-Output-Octets", NULL
, 0, 0, print_attr_num
},
532 { "Acct-Session-Id", NULL
, 0, 0, print_attr_string
},
533 { "Acct-Authentic", acct_auth
, TAM_SIZE(acct_auth
)-1, 1, print_attr_num
},
534 { "Acct-Session-Time", NULL
, 0, 0, print_attr_num
},
535 { "Acct-Input-Packets", NULL
, 0, 0, print_attr_num
},
536 { "Acct-Output-Packets", NULL
, 0, 0, print_attr_num
},
537 { "Acct-Terminate-Cause", acct_term
, TAM_SIZE(acct_term
)-1, 1, print_attr_num
},
538 { "Acct-Multi-Session-Id", NULL
, 0, 0, print_attr_string
},
539 { "Acct-Link-Count", NULL
, 0, 0, print_attr_num
},
540 { "Acct-Input-Gigawords", NULL
, 0, 0, print_attr_num
},
541 { "Acct-Output-Gigawords", NULL
, 0, 0, print_attr_num
},
542 { "Unassigned", NULL
, 0, 0, NULL
}, /*54*/
543 { "Event-Timestamp", NULL
, 0, 0, print_attr_time
},
544 { "Egress-VLANID", NULL
, 0, 0, print_attr_num
},
545 { "Ingress-Filters", ingress_filters
, TAM_SIZE(ingress_filters
)-1, 1, print_attr_num
},
546 { "Egress-VLAN-Name", NULL
, 0, 0, print_attr_string
},
547 { "User-Priority-Table", NULL
, 0, 0, NULL
},
548 { "CHAP-Challenge", NULL
, 0, 0, print_attr_string
},
549 { "NAS-Port-Type", nas_port_type
, TAM_SIZE(nas_port_type
), 0, print_attr_num
},
550 { "Port-Limit", NULL
, 0, 0, print_attr_num
},
551 { "Login-LAT-Port", NULL
, 0, 0, print_attr_string
}, /*63*/
552 { "Tunnel-Type", tunnel_type
, TAM_SIZE(tunnel_type
)-1, 1, print_attr_num
},
553 { "Tunnel-Medium-Type", tunnel_medium
, TAM_SIZE(tunnel_medium
)-1, 1, print_attr_num
},
554 { "Tunnel-Client-Endpoint", NULL
, 0, 0, print_attr_string
},
555 { "Tunnel-Server-Endpoint", NULL
, 0, 0, print_attr_string
},
556 { "Acct-Tunnel-Connection", NULL
, 0, 0, print_attr_string
},
557 { "Tunnel-Password", NULL
, 0, 0, print_attr_string
},
558 { "ARAP-Password", NULL
, 0, 0, print_attr_strange
},
559 { "ARAP-Features", NULL
, 0, 0, print_attr_strange
},
560 { "ARAP-Zone-Access", arap_zone
, TAM_SIZE(arap_zone
)-1, 1, print_attr_num
}, /*72*/
561 { "ARAP-Security", NULL
, 0, 0, print_attr_string
},
562 { "ARAP-Security-Data", NULL
, 0, 0, print_attr_string
},
563 { "Password-Retry", NULL
, 0, 0, print_attr_num
},
564 { "Prompt", prompt
, TAM_SIZE(prompt
), 0, print_attr_num
},
565 { "Connect-Info", NULL
, 0, 0, print_attr_string
},
566 { "Configuration-Token", NULL
, 0, 0, print_attr_string
},
567 { "EAP-Message", NULL
, 0, 0, print_attr_string
},
568 { "Message-Authenticator", NULL
, 0, 0, print_attr_string
}, /*80*/
569 { "Tunnel-Private-Group-ID", NULL
, 0, 0, print_attr_string
},
570 { "Tunnel-Assignment-ID", NULL
, 0, 0, print_attr_string
},
571 { "Tunnel-Preference", NULL
, 0, 0, print_attr_num
},
572 { "ARAP-Challenge-Response", NULL
, 0, 0, print_attr_strange
},
573 { "Acct-Interim-Interval", NULL
, 0, 0, print_attr_num
},
574 { "Acct-Tunnel-Packets-Lost", NULL
, 0, 0, print_attr_num
}, /*86*/
575 { "NAS-Port-Id", NULL
, 0, 0, print_attr_string
},
576 { "Framed-Pool", NULL
, 0, 0, print_attr_string
},
577 { "CUI", NULL
, 0, 0, print_attr_string
},
578 { "Tunnel-Client-Auth-ID", NULL
, 0, 0, print_attr_string
},
579 { "Tunnel-Server-Auth-ID", NULL
, 0, 0, print_attr_string
},
580 { "NAS-Filter-Rule", NULL
, 0, 0, print_attr_string
},
581 { "Unassigned", NULL
, 0, 0, NULL
}, /*93*/
582 { "Originating-Line-Info", NULL
, 0, 0, NULL
},
583 { "NAS-IPv6-Address", NULL
, 0, 0, print_attr_address6
},
584 { "Framed-Interface-ID", NULL
, 0, 0, NULL
},
585 { "Framed-IPv6-Prefix", NULL
, 0, 0, print_attr_netmask6
},
586 { "Login-IPv6-Host", NULL
, 0, 0, print_attr_address6
},
587 { "Framed-IPv6-Route", NULL
, 0, 0, print_attr_string
},
588 { "Framed-IPv6-Pool", NULL
, 0, 0, print_attr_string
},
589 { "Error-Cause", NULL
, 0, 0, print_attr_strange
},
590 { "EAP-Key-Name", NULL
, 0, 0, NULL
},
591 { "Digest-Response", NULL
, 0, 0, print_attr_string
},
592 { "Digest-Realm", NULL
, 0, 0, print_attr_string
},
593 { "Digest-Nonce", NULL
, 0, 0, print_attr_string
},
594 { "Digest-Response-Auth", NULL
, 0, 0, print_attr_string
},
595 { "Digest-Nextnonce", NULL
, 0, 0, print_attr_string
},
596 { "Digest-Method", NULL
, 0, 0, print_attr_string
},
597 { "Digest-URI", NULL
, 0, 0, print_attr_string
},
598 { "Digest-Qop", NULL
, 0, 0, print_attr_string
},
599 { "Digest-Algorithm", NULL
, 0, 0, print_attr_string
},
600 { "Digest-Entity-Body-Hash", NULL
, 0, 0, print_attr_string
},
601 { "Digest-CNonce", NULL
, 0, 0, print_attr_string
},
602 { "Digest-Nonce-Count", NULL
, 0, 0, print_attr_string
},
603 { "Digest-Username", NULL
, 0, 0, print_attr_string
},
604 { "Digest-Opaque", NULL
, 0, 0, print_attr_string
},
605 { "Digest-Auth-Param", NULL
, 0, 0, print_attr_string
},
606 { "Digest-AKA-Auts", NULL
, 0, 0, print_attr_string
},
607 { "Digest-Domain", NULL
, 0, 0, print_attr_string
},
608 { "Digest-Stale", NULL
, 0, 0, print_attr_string
},
609 { "Digest-HA1", NULL
, 0, 0, print_attr_string
},
610 { "SIP-AOR", NULL
, 0, 0, print_attr_string
},
611 { "Delegated-IPv6-Prefix", NULL
, 0, 0, print_attr_netmask6
},
612 { "MIP6-Feature-Vector", NULL
, 0, 0, print_attr_vector64
},
613 { "MIP6-Home-Link-Prefix", NULL
, 0, 0, print_attr_mip6_home_link_prefix
},
617 /*****************************/
618 /* Print an attribute string */
619 /* value pointed by 'data' */
620 /* and 'length' size. */
621 /*****************************/
622 /* Returns nothing. */
623 /*****************************/
625 print_attr_string(netdissect_options
*ndo
,
626 const u_char
*data
, u_int length
, u_short attr_code
)
630 ND_TCHECK_LEN(data
, length
);
637 if (GET_U_1(data
) && (GET_U_1(data
) <= 0x1F))
638 ND_PRINT("Tag[%u] ", GET_U_1(data
));
640 ND_PRINT("Tag[Unused] ");
643 ND_PRINT("Salt %u ", GET_BE_U_2(data
));
647 case TUNNEL_CLIENT_END
:
648 case TUNNEL_SERVER_END
:
649 case TUNNEL_PRIV_GROUP
:
650 case TUNNEL_ASSIGN_ID
:
651 case TUNNEL_CLIENT_AUTH
:
652 case TUNNEL_SERVER_AUTH
:
653 if (GET_U_1(data
) <= 0x1F)
658 ND_PRINT("Tag[%u] ", GET_U_1(data
));
660 ND_PRINT("Tag[Unused] ");
665 case EGRESS_VLAN_NAME
:
668 ND_PRINT("%s (0x%02x) ",
669 tok2str(rfc4675_tagged
,"Unknown tag",GET_U_1(data
)),
676 for (i
=0; i
< length
&& GET_U_1(data
); i
++, data
++)
677 ND_PRINT("%c", ND_ISPRINT(GET_U_1(data
)) ? GET_U_1(data
) : '.');
686 * print vendor specific attributes
689 print_vendor_attr(netdissect_options
*ndo
,
690 const u_char
*data
, u_int length
, u_short attr_code _U_
)
700 vendor_id
= GET_BE_U_4(data
);
704 ND_PRINT("Vendor: %s (%u)",
705 tok2str(smi_values
,"Unknown",vendor_id
),
708 while (length
>= 2) {
711 vendor_type
= GET_U_1(data
);
712 vendor_length
= GET_U_1(data
+ 1);
714 if (vendor_length
< 2)
716 ND_PRINT("\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
721 if (vendor_length
> length
)
723 ND_PRINT("\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
731 ND_TCHECK_LEN(data
, vendor_length
);
733 ND_PRINT("\n\t Vendor Attribute: %u, Length: %u, Value: ",
736 for (idx
= 0; idx
< vendor_length
; idx
++, data
++)
737 ND_PRINT("%c", ND_ISPRINT(GET_U_1(data
)) ? GET_U_1(data
) : '.');
738 length
-=vendor_length
;
746 /******************************/
747 /* Print an attribute numeric */
748 /* value pointed by 'data' */
749 /* and 'length' size. */
750 /******************************/
751 /* Returns nothing. */
752 /******************************/
754 print_attr_num(netdissect_options
*ndo
,
755 const u_char
*data
, u_int length
, u_short attr_code
)
761 ND_PRINT("ERROR: length %u != 4", length
);
766 /* This attribute has standard values */
767 if (attr_type
[attr_code
].siz_subtypes
)
769 static const char **table
;
771 table
= attr_type
[attr_code
].subtypes
;
773 if ( (attr_code
== TUNNEL_TYPE
) || (attr_code
== TUNNEL_MEDIUM
) )
776 ND_PRINT("Tag[Unused] ");
778 ND_PRINT("Tag[%u] ", GET_U_1(data
));
780 data_value
= GET_BE_U_3(data
);
784 data_value
= GET_BE_U_4(data
);
786 if ( data_value
<= (uint32_t)(attr_type
[attr_code
].siz_subtypes
- 1 +
787 attr_type
[attr_code
].first_subtype
) &&
788 data_value
>= attr_type
[attr_code
].first_subtype
)
789 ND_PRINT("%s", table
[data_value
]);
791 ND_PRINT("#%u", data_value
);
795 switch(attr_code
) /* Be aware of special cases... */
798 if (GET_BE_U_4(data
) == 0xFFFFFFFE )
799 ND_PRINT("NAS Select");
801 ND_PRINT("%u", GET_BE_U_4(data
));
804 case SESSION_TIMEOUT
:
807 case ACCT_SESSION_TIME
:
808 case ACCT_INT_INTERVAL
:
809 timeout
= GET_BE_U_4(data
);
811 ND_PRINT("%02d secs", timeout
);
814 if ( timeout
< 3600 )
815 ND_PRINT("%02d:%02d min",
816 timeout
/ 60, timeout
% 60);
818 ND_PRINT("%02d:%02d:%02d hours",
819 timeout
/ 3600, (timeout
% 3600) / 60,
825 if (GET_BE_U_4(data
))
826 ND_PRINT("%u", GET_BE_U_4(data
));
828 ND_PRINT("Unnumbered");
831 case FRM_ATALK_NETWORK
:
832 if (GET_BE_U_4(data
))
833 ND_PRINT("%u", GET_BE_U_4(data
));
835 ND_PRINT("NAS assigned");
838 case TUNNEL_PREFERENCE
:
840 ND_PRINT("Tag[%u] ", GET_U_1(data
));
842 ND_PRINT("Tag[Unused] ");
844 ND_PRINT("%u", GET_BE_U_3(data
));
848 ND_PRINT("%s (0x%02x) ",
849 tok2str(rfc4675_tagged
,"Unknown tag",GET_U_1(data
)),
852 ND_PRINT("%u", GET_BE_U_3(data
));
856 ND_PRINT("%u", GET_BE_U_4(data
));
869 /*****************************/
870 /* Print an attribute IPv4 */
871 /* address value pointed by */
872 /* 'data' and 'length' size. */
873 /*****************************/
874 /* Returns nothing. */
875 /*****************************/
877 print_attr_address(netdissect_options
*ndo
,
878 const u_char
*data
, u_int length
, u_short attr_code
)
882 ND_PRINT("ERROR: length %u != 4", length
);
892 if (GET_BE_U_4(data
) == 0xFFFFFFFF )
893 ND_PRINT("User Selected");
895 if (GET_BE_U_4(data
) == 0xFFFFFFFE )
896 ND_PRINT("NAS Select");
898 ND_PRINT("%s",ipaddr_string(ndo
, data
));
902 ND_PRINT("%s", ipaddr_string(ndo
, data
));
912 /*****************************/
913 /* Print an attribute IPv6 */
914 /* address value pointed by */
915 /* 'data' and 'length' size. */
916 /*****************************/
917 /* Returns nothing. */
918 /*****************************/
920 print_attr_address6(netdissect_options
*ndo
,
921 const u_char
*data
, u_int length
, u_short attr_code _U_
)
925 ND_PRINT("ERROR: length %u != 16", length
);
931 ND_PRINT("%s", ip6addr_string(ndo
, data
));
940 print_attr_netmask6(netdissect_options
*ndo
,
941 const u_char
*data
, u_int length
, u_short attr_code _U_
)
945 if (length
< 2 || length
> 18)
947 ND_PRINT("ERROR: length %u not in range (2..18)", length
);
950 ND_TCHECK_LEN(data
, length
);
951 if (GET_U_1(data
+ 1) > 128)
953 ND_PRINT("ERROR: netmask %u not in range (0..128)", GET_U_1(data
+ 1));
957 memset(data2
, 0, sizeof(data2
));
959 memcpy(data2
, data
+2, length
-2);
961 ND_PRINT("%s/%u", ip6addr_string(ndo
, data2
), GET_U_1(data
+ 1));
963 if (GET_U_1(data
+ 1) > 8 * (length
- 2))
964 ND_PRINT(" (inconsistent prefix length)");
973 print_attr_mip6_home_link_prefix(netdissect_options
*ndo
,
974 const u_char
*data
, u_int length
, u_short attr_code _U_
)
978 ND_PRINT("ERROR: length %u != 17", length
);
981 ND_TCHECK_LEN(data
, length
);
982 if (GET_U_1(data
) > 128)
984 ND_PRINT("ERROR: netmask %u not in range (0..128)", GET_U_1(data
));
988 ND_PRINT("%s/%u", ip6addr_string(ndo
, data
+ 1), GET_U_1(data
));
996 /*************************************/
997 /* Print an attribute of 'secs since */
998 /* January 1, 1970 00:00 UTC' value */
999 /* pointed by 'data' and 'length' */
1001 /*************************************/
1002 /* Returns nothing. */
1003 /*************************************/
1005 print_attr_time(netdissect_options
*ndo
,
1006 const u_char
*data
, u_int length
, u_short attr_code _U_
)
1013 ND_PRINT("ERROR: length %u != 4", length
);
1019 attr_time
= GET_BE_U_4(data
);
1020 strlcpy(string
, ctime(&attr_time
), sizeof(string
));
1021 /* Get rid of the newline */
1023 ND_PRINT("%.24s", string
);
1027 nd_print_trunc(ndo
);
1031 print_attr_vector64(netdissect_options
*ndo
,
1032 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
1034 uint64_t data_value
, i
;
1035 const char *sep
= "";
1039 ND_PRINT("ERROR: length %u != 8", length
);
1045 data_value
= GET_BE_U_8(data
);
1046 /* Print the 64-bit field in a format similar to bittok2str(), less
1047 * flagging any unknown bits. This way it should be easier to replace
1048 * the custom code with a library function later.
1050 for (i
= 0; i
< TAM_SIZE(mip6_feature_vector
); i
++) {
1051 if (data_value
& mip6_feature_vector
[i
].v
) {
1052 ND_PRINT("%s%s", sep
, mip6_feature_vector
[i
].s
);
1062 nd_print_trunc(ndo
);
1065 /***********************************/
1066 /* Print an attribute of 'strange' */
1067 /* data format pointed by 'data' */
1068 /* and 'length' size. */
1069 /***********************************/
1070 /* Returns nothing. */
1071 /***********************************/
1073 print_attr_strange(netdissect_options
*ndo
,
1074 const u_char
*data
, u_int length
, u_short attr_code
)
1077 u_int error_cause_value
;
1084 ND_PRINT("ERROR: length %u != 16", length
);
1087 ND_PRINT("User_challenge (");
1090 PRINT_HEX(len_data
, data
);
1091 ND_PRINT(") User_resp(");
1094 PRINT_HEX(len_data
, data
);
1101 ND_PRINT("ERROR: length %u != 14", length
);
1106 ND_PRINT("User can change password");
1108 ND_PRINT("User cannot change password");
1111 ND_PRINT(", Min password length: %u", GET_U_1(data
));
1113 ND_PRINT(", created at: ");
1116 PRINT_HEX(len_data
, data
);
1117 ND_PRINT(", expires in: ");
1120 PRINT_HEX(len_data
, data
);
1121 ND_PRINT(", Current Time: ");
1124 PRINT_HEX(len_data
, data
);
1127 case ARAP_CHALLENGE_RESP
:
1130 ND_PRINT("ERROR: length %u != 8", length
);
1135 PRINT_HEX(len_data
, data
);
1141 ND_PRINT("Error: length %u != 4", length
);
1146 error_cause_value
= GET_BE_U_4(data
);
1147 ND_PRINT("Error cause %u: %s", error_cause_value
, tok2str(errorcausetype
, "Error-Cause %u not known", error_cause_value
));
1153 nd_print_trunc(ndo
);
1157 radius_attrs_print(netdissect_options
*ndo
,
1158 const u_char
*attr
, u_int length
)
1160 const struct radius_attr
*rad_attr
= (const struct radius_attr
*)attr
;
1161 const char *attr_string
;
1168 ND_TCHECK_SIZE(rad_attr
);
1170 type
= GET_U_1(rad_attr
->type
);
1171 len
= GET_U_1(rad_attr
->len
);
1172 if (type
!= 0 && type
< TAM_SIZE(attr_type
))
1173 attr_string
= attr_type
[type
].name
;
1175 attr_string
= "Unknown";
1177 ND_PRINT("\n\t %s Attribute (%u), length: %u",
1183 ND_PRINT(" (bogus, must be >= 2)");
1188 ND_PRINT(" (bogus, goes past end of packet)");
1191 ND_PRINT(", Value: ");
1193 if (type
< TAM_SIZE(attr_type
))
1197 if ( attr_type
[type
].print_func
)
1198 (*attr_type
[type
].print_func
)(
1199 ndo
, ((const u_char
*)(rad_attr
+1)),
1203 /* do we also want to see a hex dump ? */
1204 if (ndo
->ndo_vflag
> 1)
1205 print_unknown_data(ndo
, (const u_char
*)rad_attr
+2, "\n\t ", (len
)-2);
1208 rad_attr
= (const struct radius_attr
*)( ((const char *)(rad_attr
))+len
);
1213 nd_print_trunc(ndo
);
1217 radius_print(netdissect_options
*ndo
,
1218 const u_char
*dat
, u_int length
)
1220 const struct radius_hdr
*rad
;
1221 u_int len
, auth_idx
;
1223 ndo
->ndo_protocol
= "radius";
1224 ND_TCHECK_LEN(dat
, MIN_RADIUS_LEN
);
1225 rad
= (const struct radius_hdr
*)dat
;
1226 len
= GET_BE_U_2(rad
->len
);
1228 if (len
< MIN_RADIUS_LEN
)
1230 nd_print_trunc(ndo
);
1237 if (ndo
->ndo_vflag
< 1) {
1238 ND_PRINT("RADIUS, %s (%u), id: 0x%02x length: %u",
1239 tok2str(radius_command_values
,"Unknown Command",GET_U_1(rad
->code
)),
1246 ND_PRINT("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
1248 tok2str(radius_command_values
,"Unknown Command",GET_U_1(rad
->code
)),
1252 for(auth_idx
=0; auth_idx
< 16; auth_idx
++)
1253 ND_PRINT("%02x", rad
->auth
[auth_idx
]);
1256 if (len
> MIN_RADIUS_LEN
)
1257 radius_attrs_print(ndo
, dat
+ MIN_RADIUS_LEN
, len
- MIN_RADIUS_LEN
);
1261 nd_print_trunc(ndo
);