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 Filter Rule Attribute"
60 * "Dynamic Authorization Extensions to RADIUS"
63 * "Carrying Location Objects in RADIUS and Diameter"
66 * "Diameter Network Access Server Application"
68 * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
70 * TODO: Among other things to print ok MacIntosh and Vendor values
77 #include <netdissect-stdinc.h>
81 #include "netdissect.h"
82 #include "addrtoname.h"
86 static const char tstr
[] = " [|radius]";
88 #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
90 #define PRINT_HEX(bytes_len, ptr_data) \
93 ND_PRINT((ndo, "%02X", *ptr_data )); \
99 /* Radius packet codes */
100 #define RADCMD_ACCESS_REQ 1 /* Access-Request */
101 #define RADCMD_ACCESS_ACC 2 /* Access-Accept */
102 #define RADCMD_ACCESS_REJ 3 /* Access-Reject */
103 #define RADCMD_ACCOUN_REQ 4 /* Accounting-Request */
104 #define RADCMD_ACCOUN_RES 5 /* Accounting-Response */
105 #define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
106 #define RADCMD_STATUS_SER 12 /* Status-Server */
107 #define RADCMD_STATUS_CLI 13 /* Status-Client */
108 #define RADCMD_DISCON_REQ 40 /* Disconnect-Request */
109 #define RADCMD_DISCON_ACK 41 /* Disconnect-ACK */
110 #define RADCMD_DISCON_NAK 42 /* Disconnect-NAK */
111 #define RADCMD_COA_REQ 43 /* CoA-Request */
112 #define RADCMD_COA_ACK 44 /* CoA-ACK */
113 #define RADCMD_COA_NAK 45 /* CoA-NAK */
114 #define RADCMD_RESERVED 255 /* Reserved */
116 static const struct tok radius_command_values
[] = {
117 { RADCMD_ACCESS_REQ
, "Access-Request" },
118 { RADCMD_ACCESS_ACC
, "Access-Accept" },
119 { RADCMD_ACCESS_REJ
, "Access-Reject" },
120 { RADCMD_ACCOUN_REQ
, "Accounting-Request" },
121 { RADCMD_ACCOUN_RES
, "Accounting-Response" },
122 { RADCMD_ACCESS_CHA
, "Access-Challenge" },
123 { RADCMD_STATUS_SER
, "Status-Server" },
124 { RADCMD_STATUS_CLI
, "Status-Client" },
125 { RADCMD_DISCON_REQ
, "Disconnect-Request" },
126 { RADCMD_DISCON_ACK
, "Disconnect-ACK" },
127 { RADCMD_DISCON_NAK
, "Disconnect-NAK" },
128 { RADCMD_COA_REQ
, "CoA-Request" },
129 { RADCMD_COA_ACK
, "CoA-ACK" },
130 { RADCMD_COA_NAK
, "CoA-NAK" },
131 { RADCMD_RESERVED
, "Reserved" },
135 /********************************/
136 /* Begin Radius Attribute types */
137 /********************************/
140 #define LOG_IPHOST 14
141 #define LOG_SERVICE 15
143 #define SESSION_TIMEOUT 27
144 #define IDLE_TIMEOUT 28
145 #define FRM_ATALK_LINK 37
146 #define FRM_ATALK_NETWORK 38
148 #define ACCT_DELAY 41
149 #define ACCT_SESSION_TIME 46
151 #define EGRESS_VLAN_ID 56
152 #define EGRESS_VLAN_NAME 58
154 #define TUNNEL_TYPE 64
155 #define TUNNEL_MEDIUM 65
156 #define TUNNEL_CLIENT_END 66
157 #define TUNNEL_SERVER_END 67
158 #define TUNNEL_PASS 69
161 #define ARAP_FEATURES 71
163 #define TUNNEL_PRIV_GROUP 81
164 #define TUNNEL_ASSIGN_ID 82
165 #define TUNNEL_PREFERENCE 83
167 #define ARAP_CHALLENGE_RESP 84
168 #define ACCT_INT_INTERVAL 85
170 #define TUNNEL_CLIENT_AUTH 90
171 #define TUNNEL_SERVER_AUTH 91
173 #define ERROR_CAUSE 101
174 /********************************/
175 /* End Radius Attribute types */
176 /********************************/
178 #define RFC4675_TAGGED 0x31
179 #define RFC4675_UNTAGGED 0x32
181 static const struct tok rfc4675_tagged
[] = {
182 { RFC4675_TAGGED
, "Tagged" },
183 { RFC4675_UNTAGGED
, "Untagged" },
188 static void print_attr_string(netdissect_options
*, register const u_char
*, u_int
, u_short
);
189 static void print_attr_num(netdissect_options
*, register const u_char
*, u_int
, u_short
);
190 static void print_vendor_attr(netdissect_options
*, register const u_char
*, u_int
, u_short
);
191 static void print_attr_address(netdissect_options
*, register const u_char
*, u_int
, u_short
);
192 static void print_attr_address6(netdissect_options
*, register const u_char
*, u_int
, u_short
);
193 static void print_attr_netmask6(netdissect_options
*, register const u_char
*, u_int
, u_short
);
194 static void print_attr_time(netdissect_options
*, register const u_char
*, u_int
, u_short
);
195 static void print_attr_strange(netdissect_options
*, register const u_char
*, u_int
, u_short
);
198 struct radius_hdr
{ uint8_t code
; /* Radius packet code */
199 uint8_t id
; /* Radius packet id */
200 uint16_t len
; /* Radius total length */
201 uint8_t auth
[16]; /* Authenticator */
204 #define MIN_RADIUS_LEN 20
206 struct radius_attr
{ uint8_t type
; /* Attribute type */
207 uint8_t len
; /* Attribute length */
211 /* Service-Type Attribute standard values */
212 static const char *serv_type
[]={ NULL
,
221 "Callback NAS Prompt",
223 "Callback Administrative",
226 /* Framed-Protocol Attribute standard values */
227 static const char *frm_proto
[]={ NULL
,
231 "Gandalf proprietary",
236 /* Framed-Routing Attribute standard values */
237 static const char *frm_routing
[]={ "None",
243 /* Framed-Compression Attribute standard values */
244 static const char *frm_comp
[]={ "None",
250 /* Login-Service Attribute standard values */
251 static const char *login_serv
[]={ "Telnet",
254 "PortMaster(proprietary)",
263 /* Termination-Action Attribute standard values */
264 static const char *term_action
[]={ "Default",
268 /* Ingress-Filters Attribute standard values */
269 static const char *ingress_filters
[]={ NULL
,
274 /* NAS-Port-Type Attribute standard values */
275 static const char *nas_port_type
[]={ "Async",
282 "HDLC Clear Channel",
294 "Wireless - IEEE 802.11",
297 /* Acct-Status-Type Accounting Attribute standard values */
298 static const char *acct_status
[]={ NULL
,
312 "Tunnel-Link-Reject",
316 /* Acct-Authentic Accounting Attribute standard values */
317 static const char *acct_auth
[]={ NULL
,
323 /* Acct-Terminate-Cause Accounting Attribute standard values */
324 static const char *acct_term
[]={ NULL
,
339 "Service Unavailable",
345 /* Tunnel-Type Attribute standard values */
346 static const char *tunnel_type
[]={ NULL
,
358 "IP-in-IP Tunneling",
362 /* Tunnel-Medium-Type Attribute standard values */
363 static const char *tunnel_medium
[]={ NULL
,
378 "E.164 with NSAP subaddress",
381 /* ARAP-Zone-Access Attribute standard values */
382 static const char *arap_zone
[]={ NULL
,
383 "Only access to dfl zone",
384 "Use zone filter inc.",
386 "Use zone filter exc.",
389 static const char *prompt
[]={ "No Echo",
393 /* Error-Cause standard values */
394 #define ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED 201
395 #define ERROR_CAUSE_INVALID_EAP_PACKET 202
396 #define ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE 401
397 #define ERROR_CAUSE_MISSING_ATTRIBUTE 402
398 #define ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH 403
399 #define ERROR_CAUSE_INVALID_REQUEST 404
400 #define ERROR_CAUSE_UNSUPPORTED_SERVICE 405
401 #define ERROR_CAUSE_UNSUPPORTED_EXTENSION 406
402 #define ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE 407
403 #define ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED 501
404 #define ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE 502
405 #define ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND 503
406 #define ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE 504
407 #define ERROR_CAUSE_PROXY_PROCESSING_ERROR 505
408 #define ERROR_CAUSE_RESOURCES_UNAVAILABLE 506
409 #define ERROR_CAUSE_REQUEST_INITIATED 507
410 #define ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED 508
411 #define ERROR_CAUSE_LOCATION_INFO_REQUIRED 509
412 static const struct tok errorcausetype
[] = {
413 { ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED
, "Residual Session Context Removed" },
414 { ERROR_CAUSE_INVALID_EAP_PACKET
, "Invalid EAP Packet (Ignored)" },
415 { ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE
, "Unsupported Attribute" },
416 { ERROR_CAUSE_MISSING_ATTRIBUTE
, "Missing Attribute" },
417 { ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH
, "NAS Identification Mismatch" },
418 { ERROR_CAUSE_INVALID_REQUEST
, "Invalid Request" },
419 { ERROR_CAUSE_UNSUPPORTED_SERVICE
, "Unsupported Service" },
420 { ERROR_CAUSE_UNSUPPORTED_EXTENSION
, "Unsupported Extension" },
421 { ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE
, "Invalid Attribute Value" },
422 { ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED
, "Administratively Prohibited" },
423 { ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE
, "Request Not Routable (Proxy)" },
424 { ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND
, "Session Context Not Found" },
425 { ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE
, "Session Context Not Removable" },
426 { ERROR_CAUSE_PROXY_PROCESSING_ERROR
, "Other Proxy Processing Error" },
427 { ERROR_CAUSE_RESOURCES_UNAVAILABLE
, "Resources Unavailable" },
428 { ERROR_CAUSE_REQUEST_INITIATED
, "Request Initiated" },
429 { ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED
, "Multiple Session Selection Unsupported" },
430 { ERROR_CAUSE_LOCATION_INFO_REQUIRED
, "Location Info Required" },
435 static struct attrtype
{
436 const char *name
; /* Attribute name */
437 const char **subtypes
; /* Standard Values (if any) */
438 u_char siz_subtypes
; /* Size of total standard values */
439 u_char first_subtype
; /* First standard value is 0 or 1 */
440 void (*print_func
)(netdissect_options
*, register const u_char
*, u_int
, u_short
);
443 { NULL
, NULL
, 0, 0, NULL
},
444 { "User-Name", NULL
, 0, 0, print_attr_string
},
445 { "User-Password", NULL
, 0, 0, NULL
},
446 { "CHAP-Password", NULL
, 0, 0, NULL
},
447 { "NAS-IP-Address", NULL
, 0, 0, print_attr_address
},
448 { "NAS-Port", NULL
, 0, 0, print_attr_num
},
449 { "Service-Type", serv_type
, TAM_SIZE(serv_type
)-1, 1, print_attr_num
},
450 { "Framed-Protocol", frm_proto
, TAM_SIZE(frm_proto
)-1, 1, print_attr_num
},
451 { "Framed-IP-Address", NULL
, 0, 0, print_attr_address
},
452 { "Framed-IP-Netmask", NULL
, 0, 0, print_attr_address
},
453 { "Framed-Routing", frm_routing
, TAM_SIZE(frm_routing
), 0, print_attr_num
},
454 { "Filter-Id", NULL
, 0, 0, print_attr_string
},
455 { "Framed-MTU", NULL
, 0, 0, print_attr_num
},
456 { "Framed-Compression", frm_comp
, TAM_SIZE(frm_comp
), 0, print_attr_num
},
457 { "Login-IP-Host", NULL
, 0, 0, print_attr_address
},
458 { "Login-Service", login_serv
, TAM_SIZE(login_serv
), 0, print_attr_num
},
459 { "Login-TCP-Port", NULL
, 0, 0, print_attr_num
},
460 { "Unassigned", NULL
, 0, 0, NULL
}, /*17*/
461 { "Reply-Message", NULL
, 0, 0, print_attr_string
},
462 { "Callback-Number", NULL
, 0, 0, print_attr_string
},
463 { "Callback-Id", NULL
, 0, 0, print_attr_string
},
464 { "Unassigned", NULL
, 0, 0, NULL
}, /*21*/
465 { "Framed-Route", NULL
, 0, 0, print_attr_string
},
466 { "Framed-IPX-Network", NULL
, 0, 0, print_attr_num
},
467 { "State", NULL
, 0, 0, print_attr_string
},
468 { "Class", NULL
, 0, 0, print_attr_string
},
469 { "Vendor-Specific", NULL
, 0, 0, print_vendor_attr
},
470 { "Session-Timeout", NULL
, 0, 0, print_attr_num
},
471 { "Idle-Timeout", NULL
, 0, 0, print_attr_num
},
472 { "Termination-Action", term_action
, TAM_SIZE(term_action
), 0, print_attr_num
},
473 { "Called-Station-Id", NULL
, 0, 0, print_attr_string
},
474 { "Calling-Station-Id", NULL
, 0, 0, print_attr_string
},
475 { "NAS-Identifier", NULL
, 0, 0, print_attr_string
},
476 { "Proxy-State", NULL
, 0, 0, print_attr_string
},
477 { "Login-LAT-Service", NULL
, 0, 0, print_attr_string
},
478 { "Login-LAT-Node", NULL
, 0, 0, print_attr_string
},
479 { "Login-LAT-Group", NULL
, 0, 0, print_attr_string
},
480 { "Framed-AppleTalk-Link", NULL
, 0, 0, print_attr_num
},
481 { "Framed-AppleTalk-Network", NULL
, 0, 0, print_attr_num
},
482 { "Framed-AppleTalk-Zone", NULL
, 0, 0, print_attr_string
},
483 { "Acct-Status-Type", acct_status
, TAM_SIZE(acct_status
)-1, 1, print_attr_num
},
484 { "Acct-Delay-Time", NULL
, 0, 0, print_attr_num
},
485 { "Acct-Input-Octets", NULL
, 0, 0, print_attr_num
},
486 { "Acct-Output-Octets", NULL
, 0, 0, print_attr_num
},
487 { "Acct-Session-Id", NULL
, 0, 0, print_attr_string
},
488 { "Acct-Authentic", acct_auth
, TAM_SIZE(acct_auth
)-1, 1, print_attr_num
},
489 { "Acct-Session-Time", NULL
, 0, 0, print_attr_num
},
490 { "Acct-Input-Packets", NULL
, 0, 0, print_attr_num
},
491 { "Acct-Output-Packets", NULL
, 0, 0, print_attr_num
},
492 { "Acct-Terminate-Cause", acct_term
, TAM_SIZE(acct_term
)-1, 1, print_attr_num
},
493 { "Acct-Multi-Session-Id", NULL
, 0, 0, print_attr_string
},
494 { "Acct-Link-Count", NULL
, 0, 0, print_attr_num
},
495 { "Acct-Input-Gigawords", NULL
, 0, 0, print_attr_num
},
496 { "Acct-Output-Gigawords", NULL
, 0, 0, print_attr_num
},
497 { "Unassigned", NULL
, 0, 0, NULL
}, /*54*/
498 { "Event-Timestamp", NULL
, 0, 0, print_attr_time
},
499 { "Egress-VLANID", NULL
, 0, 0, print_attr_num
},
500 { "Ingress-Filters", ingress_filters
, TAM_SIZE(ingress_filters
)-1, 1, print_attr_num
},
501 { "Egress-VLAN-Name", NULL
, 0, 0, print_attr_string
},
502 { "User-Priority-Table", NULL
, 0, 0, NULL
},
503 { "CHAP-Challenge", NULL
, 0, 0, print_attr_string
},
504 { "NAS-Port-Type", nas_port_type
, TAM_SIZE(nas_port_type
), 0, print_attr_num
},
505 { "Port-Limit", NULL
, 0, 0, print_attr_num
},
506 { "Login-LAT-Port", NULL
, 0, 0, print_attr_string
}, /*63*/
507 { "Tunnel-Type", tunnel_type
, TAM_SIZE(tunnel_type
)-1, 1, print_attr_num
},
508 { "Tunnel-Medium-Type", tunnel_medium
, TAM_SIZE(tunnel_medium
)-1, 1, print_attr_num
},
509 { "Tunnel-Client-Endpoint", NULL
, 0, 0, print_attr_string
},
510 { "Tunnel-Server-Endpoint", NULL
, 0, 0, print_attr_string
},
511 { "Acct-Tunnel-Connection", NULL
, 0, 0, print_attr_string
},
512 { "Tunnel-Password", NULL
, 0, 0, print_attr_string
},
513 { "ARAP-Password", NULL
, 0, 0, print_attr_strange
},
514 { "ARAP-Features", NULL
, 0, 0, print_attr_strange
},
515 { "ARAP-Zone-Access", arap_zone
, TAM_SIZE(arap_zone
)-1, 1, print_attr_num
}, /*72*/
516 { "ARAP-Security", NULL
, 0, 0, print_attr_string
},
517 { "ARAP-Security-Data", NULL
, 0, 0, print_attr_string
},
518 { "Password-Retry", NULL
, 0, 0, print_attr_num
},
519 { "Prompt", prompt
, TAM_SIZE(prompt
), 0, print_attr_num
},
520 { "Connect-Info", NULL
, 0, 0, print_attr_string
},
521 { "Configuration-Token", NULL
, 0, 0, print_attr_string
},
522 { "EAP-Message", NULL
, 0, 0, print_attr_string
},
523 { "Message-Authenticator", NULL
, 0, 0, print_attr_string
}, /*80*/
524 { "Tunnel-Private-Group-ID", NULL
, 0, 0, print_attr_string
},
525 { "Tunnel-Assignment-ID", NULL
, 0, 0, print_attr_string
},
526 { "Tunnel-Preference", NULL
, 0, 0, print_attr_num
},
527 { "ARAP-Challenge-Response", NULL
, 0, 0, print_attr_strange
},
528 { "Acct-Interim-Interval", NULL
, 0, 0, print_attr_num
},
529 { "Acct-Tunnel-Packets-Lost", NULL
, 0, 0, print_attr_num
}, /*86*/
530 { "NAS-Port-Id", NULL
, 0, 0, print_attr_string
},
531 { "Framed-Pool", NULL
, 0, 0, print_attr_string
},
532 { "CUI", NULL
, 0, 0, print_attr_string
},
533 { "Tunnel-Client-Auth-ID", NULL
, 0, 0, print_attr_string
},
534 { "Tunnel-Server-Auth-ID", NULL
, 0, 0, print_attr_string
},
535 { "NAS-Filter-Rule", NULL
, 0, 0, print_attr_string
},
536 { "Unassigned", NULL
, 0, 0, NULL
}, /*93*/
537 { "Originating-Line-Info", NULL
, 0, 0, NULL
},
538 { "NAS-IPv6-Address", NULL
, 0, 0, print_attr_address6
},
539 { "Framed-Interface-ID", NULL
, 0, 0, NULL
},
540 { "Framed-IPv6-Prefix", NULL
, 0, 0, print_attr_netmask6
},
541 { "Login-IPv6-Host", NULL
, 0, 0, print_attr_address6
},
542 { "Framed-IPv6-Route", NULL
, 0, 0, print_attr_string
},
543 { "Framed-IPv6-Pool", NULL
, 0, 0, print_attr_string
},
544 { "Error-Cause", NULL
, 0, 0, print_attr_strange
},
545 { "EAP-Key-Name", NULL
, 0, 0, NULL
}
549 /*****************************/
550 /* Print an attribute string */
551 /* value pointed by 'data' */
552 /* and 'length' size. */
553 /*****************************/
554 /* Returns nothing. */
555 /*****************************/
557 print_attr_string(netdissect_options
*ndo
,
558 register const u_char
*data
, u_int length
, u_short attr_code
)
562 ND_TCHECK2(data
[0],length
);
569 if (*data
&& (*data
<=0x1F) )
570 ND_PRINT((ndo
, "Tag[%u] ", *data
));
572 ND_PRINT((ndo
, "Tag[Unused] "));
575 ND_PRINT((ndo
, "Salt %u ", EXTRACT_16BITS(data
)));
579 case TUNNEL_CLIENT_END
:
580 case TUNNEL_SERVER_END
:
581 case TUNNEL_PRIV_GROUP
:
582 case TUNNEL_ASSIGN_ID
:
583 case TUNNEL_CLIENT_AUTH
:
584 case TUNNEL_SERVER_AUTH
:
590 ND_PRINT((ndo
, "Tag[%u] ", *data
));
592 ND_PRINT((ndo
, "Tag[Unused] "));
597 case EGRESS_VLAN_NAME
:
600 ND_PRINT((ndo
, "%s (0x%02x) ",
601 tok2str(rfc4675_tagged
,"Unknown tag",*data
),
608 for (i
=0; i
< length
&& *data
; i
++, data
++)
609 ND_PRINT((ndo
, "%c", (*data
< 32 || *data
> 126) ? '.' : *data
));
614 ND_PRINT((ndo
, "%s", tstr
));
618 * print vendor specific attributes
621 print_vendor_attr(netdissect_options
*ndo
,
622 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
631 ND_TCHECK2(*data
, 4);
632 vendor_id
= EXTRACT_32BITS(data
);
636 ND_PRINT((ndo
, "Vendor: %s (%u)",
637 tok2str(smi_values
,"Unknown",vendor_id
),
640 while (length
>= 2) {
641 ND_TCHECK2(*data
, 2);
643 vendor_type
= *(data
);
644 vendor_length
= *(data
+1);
646 if (vendor_length
< 2)
648 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
653 if (vendor_length
> length
)
655 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
663 ND_TCHECK2(*data
, vendor_length
);
665 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u, Value: ",
668 for (idx
= 0; idx
< vendor_length
; idx
++, data
++)
669 ND_PRINT((ndo
, "%c", (*data
< 32 || *data
> 126) ? '.' : *data
));
670 length
-=vendor_length
;
675 ND_PRINT((ndo
, "%s", tstr
));
678 /******************************/
679 /* Print an attribute numeric */
680 /* value pointed by 'data' */
681 /* and 'length' size. */
682 /******************************/
683 /* Returns nothing. */
684 /******************************/
686 print_attr_num(netdissect_options
*ndo
,
687 register const u_char
*data
, u_int length
, u_short attr_code
)
693 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
697 ND_TCHECK2(data
[0],4);
698 /* This attribute has standard values */
699 if (attr_type
[attr_code
].siz_subtypes
)
701 static const char **table
;
703 table
= attr_type
[attr_code
].subtypes
;
705 if ( (attr_code
== TUNNEL_TYPE
) || (attr_code
== TUNNEL_MEDIUM
) )
708 ND_PRINT((ndo
, "Tag[Unused] "));
710 ND_PRINT((ndo
, "Tag[%d] ", *data
));
712 data_value
= EXTRACT_24BITS(data
);
716 data_value
= EXTRACT_32BITS(data
);
718 if ( data_value
<= (uint32_t)(attr_type
[attr_code
].siz_subtypes
- 1 +
719 attr_type
[attr_code
].first_subtype
) &&
720 data_value
>= attr_type
[attr_code
].first_subtype
)
721 ND_PRINT((ndo
, "%s", table
[data_value
]));
723 ND_PRINT((ndo
, "#%u", data_value
));
727 switch(attr_code
) /* Be aware of special cases... */
730 if (EXTRACT_32BITS( data
) == 0xFFFFFFFE )
731 ND_PRINT((ndo
, "NAS Select"));
733 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
736 case SESSION_TIMEOUT
:
739 case ACCT_SESSION_TIME
:
740 case ACCT_INT_INTERVAL
:
741 timeout
= EXTRACT_32BITS( data
);
743 ND_PRINT((ndo
, "%02d secs", timeout
));
746 if ( timeout
< 3600 )
747 ND_PRINT((ndo
, "%02d:%02d min",
748 timeout
/ 60, timeout
% 60));
750 ND_PRINT((ndo
, "%02d:%02d:%02d hours",
751 timeout
/ 3600, (timeout
% 3600) / 60,
757 if (EXTRACT_32BITS(data
) )
758 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
760 ND_PRINT((ndo
, "Unnumbered"));
763 case FRM_ATALK_NETWORK
:
764 if (EXTRACT_32BITS(data
) )
765 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
767 ND_PRINT((ndo
, "NAS assigned"));
770 case TUNNEL_PREFERENCE
:
772 ND_PRINT((ndo
, "Tag[%d] ", *data
));
774 ND_PRINT((ndo
, "Tag[Unused] "));
776 ND_PRINT((ndo
, "%d", EXTRACT_24BITS(data
)));
780 ND_PRINT((ndo
, "%s (0x%02x) ",
781 tok2str(rfc4675_tagged
,"Unknown tag",*data
),
784 ND_PRINT((ndo
, "%d", EXTRACT_24BITS(data
)));
788 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
798 ND_PRINT((ndo
, "%s", tstr
));
801 /*****************************/
802 /* Print an attribute IPv4 */
803 /* address value pointed by */
804 /* 'data' and 'length' size. */
805 /*****************************/
806 /* Returns nothing. */
807 /*****************************/
809 print_attr_address(netdissect_options
*ndo
,
810 register const u_char
*data
, u_int length
, u_short attr_code
)
814 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
818 ND_TCHECK2(data
[0],4);
824 if (EXTRACT_32BITS(data
) == 0xFFFFFFFF )
825 ND_PRINT((ndo
, "User Selected"));
827 if (EXTRACT_32BITS(data
) == 0xFFFFFFFE )
828 ND_PRINT((ndo
, "NAS Select"));
830 ND_PRINT((ndo
, "%s",ipaddr_string(ndo
, data
)));
834 ND_PRINT((ndo
, "%s", ipaddr_string(ndo
, data
)));
841 ND_PRINT((ndo
, "%s", tstr
));
844 /*****************************/
845 /* Print an attribute IPv6 */
846 /* address value pointed by */
847 /* 'data' and 'length' size. */
848 /*****************************/
849 /* Returns nothing. */
850 /*****************************/
852 print_attr_address6(netdissect_options
*ndo
,
853 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
857 ND_PRINT((ndo
, "ERROR: length %u != 16", length
));
861 ND_TCHECK2(data
[0], 16);
863 ND_PRINT((ndo
, "%s", ip6addr_string(ndo
, data
)));
868 ND_PRINT((ndo
, "%s", tstr
));
872 print_attr_netmask6(netdissect_options
*ndo
,
873 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
877 if (length
< 2 || length
> 18)
879 ND_PRINT((ndo
, "ERROR: length %u not in range (2..18)", length
));
882 else if (data
[1] > 128)
884 ND_PRINT((ndo
, "ERROR: netmask %u not in range (0..128)", data
[1]));
888 ND_TCHECK2(data
[0], length
);
889 memset(data2
, 0, sizeof(data2
));
891 memcpy(data2
, data
+2, length
-2);
893 ND_PRINT((ndo
, "%s/%u", ip6addr_string(ndo
, data2
), data
[1]));
898 ND_PRINT((ndo
, "%s", tstr
));
901 /*************************************/
902 /* Print an attribute of 'secs since */
903 /* January 1, 1970 00:00 UTC' value */
904 /* pointed by 'data' and 'length' */
906 /*************************************/
907 /* Returns nothing. */
908 /*************************************/
910 print_attr_time(netdissect_options
*ndo
,
911 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
918 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
922 ND_TCHECK2(data
[0],4);
924 attr_time
= EXTRACT_32BITS(data
);
925 strlcpy(string
, ctime(&attr_time
), sizeof(string
));
926 /* Get rid of the newline */
928 ND_PRINT((ndo
, "%.24s", string
));
932 ND_PRINT((ndo
, "%s", tstr
));
935 /***********************************/
936 /* Print an attribute of 'strange' */
937 /* data format pointed by 'data' */
938 /* and 'length' size. */
939 /***********************************/
940 /* Returns nothing. */
941 /***********************************/
943 print_attr_strange(netdissect_options
*ndo
,
944 register const u_char
*data
, u_int length
, u_short attr_code
)
947 u_int error_cause_value
;
954 ND_PRINT((ndo
, "ERROR: length %u != 16", length
));
957 ND_PRINT((ndo
, "User_challenge ("));
958 ND_TCHECK2(data
[0],8);
960 PRINT_HEX(len_data
, data
);
961 ND_PRINT((ndo
, ") User_resp("));
962 ND_TCHECK2(data
[0],8);
964 PRINT_HEX(len_data
, data
);
965 ND_PRINT((ndo
, ")"));
971 ND_PRINT((ndo
, "ERROR: length %u != 14", length
));
974 ND_TCHECK2(data
[0],1);
976 ND_PRINT((ndo
, "User can change password"));
978 ND_PRINT((ndo
, "User cannot change password"));
980 ND_TCHECK2(data
[0],1);
981 ND_PRINT((ndo
, ", Min password length: %d", *data
));
983 ND_PRINT((ndo
, ", created at: "));
984 ND_TCHECK2(data
[0],4);
986 PRINT_HEX(len_data
, data
);
987 ND_PRINT((ndo
, ", expires in: "));
988 ND_TCHECK2(data
[0],4);
990 PRINT_HEX(len_data
, data
);
991 ND_PRINT((ndo
, ", Current Time: "));
992 ND_TCHECK2(data
[0],4);
994 PRINT_HEX(len_data
, data
);
997 case ARAP_CHALLENGE_RESP
:
1000 ND_PRINT((ndo
, "ERROR: length %u != 8", length
));
1003 ND_TCHECK2(data
[0],8);
1005 PRINT_HEX(len_data
, data
);
1011 ND_PRINT((ndo
, "Error: length %u != 4", length
));
1014 ND_TCHECK2(data
[0],4);
1016 error_cause_value
= EXTRACT_32BITS(data
);
1017 ND_PRINT((ndo
, "Error cause %u: %s", error_cause_value
, tok2str(errorcausetype
, "Error-Cause %u not known", error_cause_value
)));
1023 ND_PRINT((ndo
, "%s", tstr
));
1027 radius_attrs_print(netdissect_options
*ndo
,
1028 register const u_char
*attr
, u_int length
)
1030 register const struct radius_attr
*rad_attr
= (const struct radius_attr
*)attr
;
1031 const char *attr_string
;
1037 ND_TCHECK(*rad_attr
);
1039 if (rad_attr
->type
> 0 && rad_attr
->type
< TAM_SIZE(attr_type
))
1040 attr_string
= attr_type
[rad_attr
->type
].name
;
1042 attr_string
= "Unknown";
1043 if (rad_attr
->len
< 2)
1045 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
1051 if (rad_attr
->len
> length
)
1053 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
1059 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u, Value: ",
1064 if (rad_attr
->type
< TAM_SIZE(attr_type
))
1066 if (rad_attr
->len
> 2)
1068 if ( attr_type
[rad_attr
->type
].print_func
)
1069 (*attr_type
[rad_attr
->type
].print_func
)(
1070 ndo
, ((const u_char
*)(rad_attr
+1)),
1071 rad_attr
->len
- 2, rad_attr
->type
);
1074 /* do we also want to see a hex dump ? */
1075 if (ndo
->ndo_vflag
> 1)
1076 print_unknown_data(ndo
, (const u_char
*)rad_attr
+2, "\n\t ", (rad_attr
->len
)-2);
1078 length
-=(rad_attr
->len
);
1079 rad_attr
= (const struct radius_attr
*)( ((const char *)(rad_attr
))+rad_attr
->len
);
1084 ND_PRINT((ndo
, "%s", tstr
));
1088 radius_print(netdissect_options
*ndo
,
1089 const u_char
*dat
, u_int length
)
1091 register const struct radius_hdr
*rad
;
1092 u_int len
, auth_idx
;
1094 ND_TCHECK2(*dat
, MIN_RADIUS_LEN
);
1095 rad
= (const struct radius_hdr
*)dat
;
1096 len
= EXTRACT_16BITS(&rad
->len
);
1098 if (len
< MIN_RADIUS_LEN
)
1100 ND_PRINT((ndo
, "%s", tstr
));
1107 if (ndo
->ndo_vflag
< 1) {
1108 ND_PRINT((ndo
, "RADIUS, %s (%u), id: 0x%02x length: %u",
1109 tok2str(radius_command_values
,"Unknown Command",rad
->code
),
1116 ND_PRINT((ndo
, "RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
1118 tok2str(radius_command_values
,"Unknown Command",rad
->code
),
1122 for(auth_idx
=0; auth_idx
< 16; auth_idx
++)
1123 ND_PRINT((ndo
, "%02x", rad
->auth
[auth_idx
]));
1126 if (len
> MIN_RADIUS_LEN
)
1127 radius_attrs_print(ndo
, dat
+ MIN_RADIUS_LEN
, len
- MIN_RADIUS_LEN
);
1131 ND_PRINT((ndo
, "%s", tstr
));