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 * "RADIUS Attributes for Virtual LAN and Priority Support"
54 * "RADIUS Filter Rule Attribute"
57 * "Dynamic Authorization Extensions to RADIUS"
60 * "Carrying Location Objects in RADIUS and Diameter"
63 * "Diameter Network Access Server Application"
65 * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
67 * TODO: Among other things to print ok MacIntosh and Vendor values
74 #include <netdissect-stdinc.h>
78 #include "netdissect.h"
79 #include "addrtoname.h"
83 static const char tstr
[] = " [|radius]";
85 #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
87 #define PRINT_HEX(bytes_len, ptr_data) \
90 ND_PRINT((ndo, "%02X", *ptr_data )); \
96 /* Radius packet codes */
97 #define RADCMD_ACCESS_REQ 1 /* Access-Request */
98 #define RADCMD_ACCESS_ACC 2 /* Access-Accept */
99 #define RADCMD_ACCESS_REJ 3 /* Access-Reject */
100 #define RADCMD_ACCOUN_REQ 4 /* Accounting-Request */
101 #define RADCMD_ACCOUN_RES 5 /* Accounting-Response */
102 #define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
103 #define RADCMD_STATUS_SER 12 /* Status-Server */
104 #define RADCMD_STATUS_CLI 13 /* Status-Client */
105 #define RADCMD_DISCON_REQ 40 /* Disconnect-Request */
106 #define RADCMD_DISCON_ACK 41 /* Disconnect-ACK */
107 #define RADCMD_DISCON_NAK 42 /* Disconnect-NAK */
108 #define RADCMD_COA_REQ 43 /* CoA-Request */
109 #define RADCMD_COA_ACK 44 /* CoA-ACK */
110 #define RADCMD_COA_NAK 45 /* CoA-NAK */
111 #define RADCMD_RESERVED 255 /* Reserved */
113 static const struct tok radius_command_values
[] = {
114 { RADCMD_ACCESS_REQ
, "Access-Request" },
115 { RADCMD_ACCESS_ACC
, "Access-Accept" },
116 { RADCMD_ACCESS_REJ
, "Access-Reject" },
117 { RADCMD_ACCOUN_REQ
, "Accounting-Request" },
118 { RADCMD_ACCOUN_RES
, "Accounting-Response" },
119 { RADCMD_ACCESS_CHA
, "Access-Challenge" },
120 { RADCMD_STATUS_SER
, "Status-Server" },
121 { RADCMD_STATUS_CLI
, "Status-Client" },
122 { RADCMD_DISCON_REQ
, "Disconnect-Request" },
123 { RADCMD_DISCON_ACK
, "Disconnect-ACK" },
124 { RADCMD_DISCON_NAK
, "Disconnect-NAK" },
125 { RADCMD_COA_REQ
, "CoA-Request" },
126 { RADCMD_COA_ACK
, "CoA-ACK" },
127 { RADCMD_COA_NAK
, "CoA-NAK" },
128 { RADCMD_RESERVED
, "Reserved" },
132 /********************************/
133 /* Begin Radius Attribute types */
134 /********************************/
137 #define LOG_IPHOST 14
138 #define LOG_SERVICE 15
140 #define SESSION_TIMEOUT 27
141 #define IDLE_TIMEOUT 28
142 #define FRM_ATALK_LINK 37
143 #define FRM_ATALK_NETWORK 38
145 #define ACCT_DELAY 41
146 #define ACCT_SESSION_TIME 46
148 #define EGRESS_VLAN_ID 56
149 #define EGRESS_VLAN_NAME 58
151 #define TUNNEL_TYPE 64
152 #define TUNNEL_MEDIUM 65
153 #define TUNNEL_CLIENT_END 66
154 #define TUNNEL_SERVER_END 67
155 #define TUNNEL_PASS 69
158 #define ARAP_FEATURES 71
160 #define TUNNEL_PRIV_GROUP 81
161 #define TUNNEL_ASSIGN_ID 82
162 #define TUNNEL_PREFERENCE 83
164 #define ARAP_CHALLENGE_RESP 84
165 #define ACCT_INT_INTERVAL 85
167 #define TUNNEL_CLIENT_AUTH 90
168 #define TUNNEL_SERVER_AUTH 91
170 #define ERROR_CAUSE 101
171 /********************************/
172 /* End Radius Attribute types */
173 /********************************/
175 #define RFC4675_TAGGED 0x31
176 #define RFC4675_UNTAGGED 0x32
178 static const struct tok rfc4675_tagged
[] = {
179 { RFC4675_TAGGED
, "Tagged" },
180 { RFC4675_UNTAGGED
, "Untagged" },
185 static void print_attr_string(netdissect_options
*, register const u_char
*, u_int
, u_short
);
186 static void print_attr_num(netdissect_options
*, register const u_char
*, u_int
, u_short
);
187 static void print_vendor_attr(netdissect_options
*, register const u_char
*, u_int
, u_short
);
188 static void print_attr_address(netdissect_options
*, register const u_char
*, u_int
, u_short
);
189 static void print_attr_address6(netdissect_options
*, register const u_char
*, u_int
, u_short
);
190 static void print_attr_netmask6(netdissect_options
*, register const u_char
*, u_int
, u_short
);
191 static void print_attr_time(netdissect_options
*, register const u_char
*, u_int
, u_short
);
192 static void print_attr_strange(netdissect_options
*, register const u_char
*, u_int
, u_short
);
195 struct radius_hdr
{ uint8_t code
; /* Radius packet code */
196 uint8_t id
; /* Radius packet id */
197 uint16_t len
; /* Radius total length */
198 uint8_t auth
[16]; /* Authenticator */
201 #define MIN_RADIUS_LEN 20
203 struct radius_attr
{ uint8_t type
; /* Attribute type */
204 uint8_t len
; /* Attribute length */
208 /* Service-Type Attribute standard values */
209 static const char *serv_type
[]={ NULL
,
218 "Callback NAS Prompt",
220 "Callback Administrative",
223 /* Framed-Protocol Attribute standard values */
224 static const char *frm_proto
[]={ NULL
,
228 "Gandalf proprietary",
233 /* Framed-Routing Attribute standard values */
234 static const char *frm_routing
[]={ "None",
240 /* Framed-Compression Attribute standard values */
241 static const char *frm_comp
[]={ "None",
247 /* Login-Service Attribute standard values */
248 static const char *login_serv
[]={ "Telnet",
251 "PortMaster(proprietary)",
260 /* Termination-Action Attribute standard values */
261 static const char *term_action
[]={ "Default",
265 /* Ingress-Filters Attribute standard values */
266 static const char *ingress_filters
[]={ NULL
,
271 /* NAS-Port-Type Attribute standard values */
272 static const char *nas_port_type
[]={ "Async",
279 "HDLC Clear Channel",
291 "Wireless - IEEE 802.11",
294 /* Acct-Status-Type Accounting Attribute standard values */
295 static const char *acct_status
[]={ NULL
,
309 "Tunnel-Link-Reject",
313 /* Acct-Authentic Accounting Attribute standard values */
314 static const char *acct_auth
[]={ NULL
,
320 /* Acct-Terminate-Cause Accounting Attribute standard values */
321 static const char *acct_term
[]={ NULL
,
336 "Service Unavailable",
342 /* Tunnel-Type Attribute standard values */
343 static const char *tunnel_type
[]={ NULL
,
355 "IP-in-IP Tunneling",
359 /* Tunnel-Medium-Type Attribute standard values */
360 static const char *tunnel_medium
[]={ NULL
,
375 "E.164 with NSAP subaddress",
378 /* ARAP-Zone-Access Attribute standard values */
379 static const char *arap_zone
[]={ NULL
,
380 "Only access to dfl zone",
381 "Use zone filter inc.",
383 "Use zone filter exc.",
386 static const char *prompt
[]={ "No Echo",
390 /* Error-Cause standard values */
391 #define ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED 201
392 #define ERROR_CAUSE_INVALID_EAP_PACKET 202
393 #define ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE 401
394 #define ERROR_CAUSE_MISSING_ATTRIBUTE 402
395 #define ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH 403
396 #define ERROR_CAUSE_INVALID_REQUEST 404
397 #define ERROR_CAUSE_UNSUPPORTED_SERVICE 405
398 #define ERROR_CAUSE_UNSUPPORTED_EXTENSION 406
399 #define ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE 407
400 #define ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED 501
401 #define ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE 502
402 #define ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND 503
403 #define ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE 504
404 #define ERROR_CAUSE_PROXY_PROCESSING_ERROR 505
405 #define ERROR_CAUSE_RESOURCES_UNAVAILABLE 506
406 #define ERROR_CAUSE_REQUEST_INITIATED 507
407 #define ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED 508
408 #define ERROR_CAUSE_LOCATION_INFO_REQUIRED 509
409 static const struct tok errorcausetype
[] = {
410 { ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED
, "Residual Session Context Removed" },
411 { ERROR_CAUSE_INVALID_EAP_PACKET
, "Invalid EAP Packet (Ignored)" },
412 { ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE
, "Unsupported Attribute" },
413 { ERROR_CAUSE_MISSING_ATTRIBUTE
, "Missing Attribute" },
414 { ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH
, "NAS Identification Mismatch" },
415 { ERROR_CAUSE_INVALID_REQUEST
, "Invalid Request" },
416 { ERROR_CAUSE_UNSUPPORTED_SERVICE
, "Unsupported Service" },
417 { ERROR_CAUSE_UNSUPPORTED_EXTENSION
, "Unsupported Extension" },
418 { ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE
, "Invalid Attribute Value" },
419 { ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED
, "Administratively Prohibited" },
420 { ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE
, "Request Not Routable (Proxy)" },
421 { ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND
, "Session Context Not Found" },
422 { ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE
, "Session Context Not Removable" },
423 { ERROR_CAUSE_PROXY_PROCESSING_ERROR
, "Other Proxy Processing Error" },
424 { ERROR_CAUSE_RESOURCES_UNAVAILABLE
, "Resources Unavailable" },
425 { ERROR_CAUSE_REQUEST_INITIATED
, "Request Initiated" },
426 { ERROR_CAUSE_MULTIPLE_SESSION_SELECTION_UNSUPPORTED
, "Multiple Session Selection Unsupported" },
427 { ERROR_CAUSE_LOCATION_INFO_REQUIRED
, "Location Info Required" },
432 static struct attrtype
{
433 const char *name
; /* Attribute name */
434 const char **subtypes
; /* Standard Values (if any) */
435 u_char siz_subtypes
; /* Size of total standard values */
436 u_char first_subtype
; /* First standard value is 0 or 1 */
437 void (*print_func
)(netdissect_options
*, register const u_char
*, u_int
, u_short
);
440 { NULL
, NULL
, 0, 0, NULL
},
441 { "User-Name", NULL
, 0, 0, print_attr_string
},
442 { "User-Password", NULL
, 0, 0, NULL
},
443 { "CHAP-Password", NULL
, 0, 0, NULL
},
444 { "NAS-IP-Address", NULL
, 0, 0, print_attr_address
},
445 { "NAS-Port", NULL
, 0, 0, print_attr_num
},
446 { "Service-Type", serv_type
, TAM_SIZE(serv_type
)-1, 1, print_attr_num
},
447 { "Framed-Protocol", frm_proto
, TAM_SIZE(frm_proto
)-1, 1, print_attr_num
},
448 { "Framed-IP-Address", NULL
, 0, 0, print_attr_address
},
449 { "Framed-IP-Netmask", NULL
, 0, 0, print_attr_address
},
450 { "Framed-Routing", frm_routing
, TAM_SIZE(frm_routing
), 0, print_attr_num
},
451 { "Filter-Id", NULL
, 0, 0, print_attr_string
},
452 { "Framed-MTU", NULL
, 0, 0, print_attr_num
},
453 { "Framed-Compression", frm_comp
, TAM_SIZE(frm_comp
), 0, print_attr_num
},
454 { "Login-IP-Host", NULL
, 0, 0, print_attr_address
},
455 { "Login-Service", login_serv
, TAM_SIZE(login_serv
), 0, print_attr_num
},
456 { "Login-TCP-Port", NULL
, 0, 0, print_attr_num
},
457 { "Unassigned", NULL
, 0, 0, NULL
}, /*17*/
458 { "Reply-Message", NULL
, 0, 0, print_attr_string
},
459 { "Callback-Number", NULL
, 0, 0, print_attr_string
},
460 { "Callback-Id", NULL
, 0, 0, print_attr_string
},
461 { "Unassigned", NULL
, 0, 0, NULL
}, /*21*/
462 { "Framed-Route", NULL
, 0, 0, print_attr_string
},
463 { "Framed-IPX-Network", NULL
, 0, 0, print_attr_num
},
464 { "State", NULL
, 0, 0, print_attr_string
},
465 { "Class", NULL
, 0, 0, print_attr_string
},
466 { "Vendor-Specific", NULL
, 0, 0, print_vendor_attr
},
467 { "Session-Timeout", NULL
, 0, 0, print_attr_num
},
468 { "Idle-Timeout", NULL
, 0, 0, print_attr_num
},
469 { "Termination-Action", term_action
, TAM_SIZE(term_action
), 0, print_attr_num
},
470 { "Called-Station-Id", NULL
, 0, 0, print_attr_string
},
471 { "Calling-Station-Id", NULL
, 0, 0, print_attr_string
},
472 { "NAS-Identifier", NULL
, 0, 0, print_attr_string
},
473 { "Proxy-State", NULL
, 0, 0, print_attr_string
},
474 { "Login-LAT-Service", NULL
, 0, 0, print_attr_string
},
475 { "Login-LAT-Node", NULL
, 0, 0, print_attr_string
},
476 { "Login-LAT-Group", NULL
, 0, 0, print_attr_string
},
477 { "Framed-AppleTalk-Link", NULL
, 0, 0, print_attr_num
},
478 { "Framed-AppleTalk-Network", NULL
, 0, 0, print_attr_num
},
479 { "Framed-AppleTalk-Zone", NULL
, 0, 0, print_attr_string
},
480 { "Acct-Status-Type", acct_status
, TAM_SIZE(acct_status
)-1, 1, print_attr_num
},
481 { "Acct-Delay-Time", NULL
, 0, 0, print_attr_num
},
482 { "Acct-Input-Octets", NULL
, 0, 0, print_attr_num
},
483 { "Acct-Output-Octets", NULL
, 0, 0, print_attr_num
},
484 { "Acct-Session-Id", NULL
, 0, 0, print_attr_string
},
485 { "Acct-Authentic", acct_auth
, TAM_SIZE(acct_auth
)-1, 1, print_attr_num
},
486 { "Acct-Session-Time", NULL
, 0, 0, print_attr_num
},
487 { "Acct-Input-Packets", NULL
, 0, 0, print_attr_num
},
488 { "Acct-Output-Packets", NULL
, 0, 0, print_attr_num
},
489 { "Acct-Terminate-Cause", acct_term
, TAM_SIZE(acct_term
)-1, 1, print_attr_num
},
490 { "Acct-Multi-Session-Id", NULL
, 0, 0, print_attr_string
},
491 { "Acct-Link-Count", NULL
, 0, 0, print_attr_num
},
492 { "Acct-Input-Gigawords", NULL
, 0, 0, print_attr_num
},
493 { "Acct-Output-Gigawords", NULL
, 0, 0, print_attr_num
},
494 { "Unassigned", NULL
, 0, 0, NULL
}, /*54*/
495 { "Event-Timestamp", NULL
, 0, 0, print_attr_time
},
496 { "Egress-VLANID", NULL
, 0, 0, print_attr_num
},
497 { "Ingress-Filters", ingress_filters
, TAM_SIZE(ingress_filters
)-1, 1, print_attr_num
},
498 { "Egress-VLAN-Name", NULL
, 0, 0, print_attr_string
},
499 { "User-Priority-Table", NULL
, 0, 0, NULL
},
500 { "CHAP-Challenge", NULL
, 0, 0, print_attr_string
},
501 { "NAS-Port-Type", nas_port_type
, TAM_SIZE(nas_port_type
), 0, print_attr_num
},
502 { "Port-Limit", NULL
, 0, 0, print_attr_num
},
503 { "Login-LAT-Port", NULL
, 0, 0, print_attr_string
}, /*63*/
504 { "Tunnel-Type", tunnel_type
, TAM_SIZE(tunnel_type
)-1, 1, print_attr_num
},
505 { "Tunnel-Medium-Type", tunnel_medium
, TAM_SIZE(tunnel_medium
)-1, 1, print_attr_num
},
506 { "Tunnel-Client-Endpoint", NULL
, 0, 0, print_attr_string
},
507 { "Tunnel-Server-Endpoint", NULL
, 0, 0, print_attr_string
},
508 { "Acct-Tunnel-Connection", NULL
, 0, 0, print_attr_string
},
509 { "Tunnel-Password", NULL
, 0, 0, print_attr_string
},
510 { "ARAP-Password", NULL
, 0, 0, print_attr_strange
},
511 { "ARAP-Features", NULL
, 0, 0, print_attr_strange
},
512 { "ARAP-Zone-Access", arap_zone
, TAM_SIZE(arap_zone
)-1, 1, print_attr_num
}, /*72*/
513 { "ARAP-Security", NULL
, 0, 0, print_attr_string
},
514 { "ARAP-Security-Data", NULL
, 0, 0, print_attr_string
},
515 { "Password-Retry", NULL
, 0, 0, print_attr_num
},
516 { "Prompt", prompt
, TAM_SIZE(prompt
), 0, print_attr_num
},
517 { "Connect-Info", NULL
, 0, 0, print_attr_string
},
518 { "Configuration-Token", NULL
, 0, 0, print_attr_string
},
519 { "EAP-Message", NULL
, 0, 0, print_attr_string
},
520 { "Message-Authenticator", NULL
, 0, 0, print_attr_string
}, /*80*/
521 { "Tunnel-Private-Group-ID", NULL
, 0, 0, print_attr_string
},
522 { "Tunnel-Assignment-ID", NULL
, 0, 0, print_attr_string
},
523 { "Tunnel-Preference", NULL
, 0, 0, print_attr_num
},
524 { "ARAP-Challenge-Response", NULL
, 0, 0, print_attr_strange
},
525 { "Acct-Interim-Interval", NULL
, 0, 0, print_attr_num
},
526 { "Acct-Tunnel-Packets-Lost", NULL
, 0, 0, print_attr_num
}, /*86*/
527 { "NAS-Port-Id", NULL
, 0, 0, print_attr_string
},
528 { "Framed-Pool", NULL
, 0, 0, print_attr_string
},
529 { "CUI", NULL
, 0, 0, print_attr_string
},
530 { "Tunnel-Client-Auth-ID", NULL
, 0, 0, print_attr_string
},
531 { "Tunnel-Server-Auth-ID", NULL
, 0, 0, print_attr_string
},
532 { "NAS-Filter-Rule", NULL
, 0, 0, print_attr_string
},
533 { "Unassigned", NULL
, 0, 0, NULL
}, /*93*/
534 { "Originating-Line-Info", NULL
, 0, 0, NULL
},
535 { "NAS-IPv6-Address", NULL
, 0, 0, print_attr_address6
},
536 { "Framed-Interface-ID", NULL
, 0, 0, NULL
},
537 { "Framed-IPv6-Prefix", NULL
, 0, 0, print_attr_netmask6
},
538 { "Login-IPv6-Host", NULL
, 0, 0, print_attr_address6
},
539 { "Framed-IPv6-Route", NULL
, 0, 0, print_attr_string
},
540 { "Framed-IPv6-Pool", NULL
, 0, 0, print_attr_string
},
541 { "Error-Cause", NULL
, 0, 0, print_attr_strange
}
545 /*****************************/
546 /* Print an attribute string */
547 /* value pointed by 'data' */
548 /* and 'length' size. */
549 /*****************************/
550 /* Returns nothing. */
551 /*****************************/
553 print_attr_string(netdissect_options
*ndo
,
554 register const u_char
*data
, u_int length
, u_short attr_code
)
558 ND_TCHECK2(data
[0],length
);
565 if (*data
&& (*data
<=0x1F) )
566 ND_PRINT((ndo
, "Tag[%u] ", *data
));
568 ND_PRINT((ndo
, "Tag[Unused] "));
571 ND_PRINT((ndo
, "Salt %u ", EXTRACT_16BITS(data
)));
575 case TUNNEL_CLIENT_END
:
576 case TUNNEL_SERVER_END
:
577 case TUNNEL_PRIV_GROUP
:
578 case TUNNEL_ASSIGN_ID
:
579 case TUNNEL_CLIENT_AUTH
:
580 case TUNNEL_SERVER_AUTH
:
586 ND_PRINT((ndo
, "Tag[%u] ", *data
));
588 ND_PRINT((ndo
, "Tag[Unused] "));
593 case EGRESS_VLAN_NAME
:
596 ND_PRINT((ndo
, "%s (0x%02x) ",
597 tok2str(rfc4675_tagged
,"Unknown tag",*data
),
604 for (i
=0; i
< length
&& *data
; i
++, data
++)
605 ND_PRINT((ndo
, "%c", (*data
< 32 || *data
> 126) ? '.' : *data
));
610 ND_PRINT((ndo
, "%s", tstr
));
614 * print vendor specific attributes
617 print_vendor_attr(netdissect_options
*ndo
,
618 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
627 ND_TCHECK2(*data
, 4);
628 vendor_id
= EXTRACT_32BITS(data
);
632 ND_PRINT((ndo
, "Vendor: %s (%u)",
633 tok2str(smi_values
,"Unknown",vendor_id
),
636 while (length
>= 2) {
637 ND_TCHECK2(*data
, 2);
639 vendor_type
= *(data
);
640 vendor_length
= *(data
+1);
642 if (vendor_length
< 2)
644 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
649 if (vendor_length
> length
)
651 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
659 ND_TCHECK2(*data
, vendor_length
);
661 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u, Value: ",
664 for (idx
= 0; idx
< vendor_length
; idx
++, data
++)
665 ND_PRINT((ndo
, "%c", (*data
< 32 || *data
> 126) ? '.' : *data
));
666 length
-=vendor_length
;
671 ND_PRINT((ndo
, "%s", tstr
));
674 /******************************/
675 /* Print an attribute numeric */
676 /* value pointed by 'data' */
677 /* and 'length' size. */
678 /******************************/
679 /* Returns nothing. */
680 /******************************/
682 print_attr_num(netdissect_options
*ndo
,
683 register const u_char
*data
, u_int length
, u_short attr_code
)
689 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
693 ND_TCHECK2(data
[0],4);
694 /* This attribute has standard values */
695 if (attr_type
[attr_code
].siz_subtypes
)
697 static const char **table
;
699 table
= attr_type
[attr_code
].subtypes
;
701 if ( (attr_code
== TUNNEL_TYPE
) || (attr_code
== TUNNEL_MEDIUM
) )
704 ND_PRINT((ndo
, "Tag[Unused] "));
706 ND_PRINT((ndo
, "Tag[%d] ", *data
));
708 data_value
= EXTRACT_24BITS(data
);
712 data_value
= EXTRACT_32BITS(data
);
714 if ( data_value
<= (uint32_t)(attr_type
[attr_code
].siz_subtypes
- 1 +
715 attr_type
[attr_code
].first_subtype
) &&
716 data_value
>= attr_type
[attr_code
].first_subtype
)
717 ND_PRINT((ndo
, "%s", table
[data_value
]));
719 ND_PRINT((ndo
, "#%u", data_value
));
723 switch(attr_code
) /* Be aware of special cases... */
726 if (EXTRACT_32BITS( data
) == 0xFFFFFFFE )
727 ND_PRINT((ndo
, "NAS Select"));
729 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
732 case SESSION_TIMEOUT
:
735 case ACCT_SESSION_TIME
:
736 case ACCT_INT_INTERVAL
:
737 timeout
= EXTRACT_32BITS( data
);
739 ND_PRINT((ndo
, "%02d secs", timeout
));
742 if ( timeout
< 3600 )
743 ND_PRINT((ndo
, "%02d:%02d min",
744 timeout
/ 60, timeout
% 60));
746 ND_PRINT((ndo
, "%02d:%02d:%02d hours",
747 timeout
/ 3600, (timeout
% 3600) / 60,
753 if (EXTRACT_32BITS(data
) )
754 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
756 ND_PRINT((ndo
, "Unnumbered"));
759 case FRM_ATALK_NETWORK
:
760 if (EXTRACT_32BITS(data
) )
761 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
763 ND_PRINT((ndo
, "NAS assigned"));
766 case TUNNEL_PREFERENCE
:
768 ND_PRINT((ndo
, "Tag[%d] ", *data
));
770 ND_PRINT((ndo
, "Tag[Unused] "));
772 ND_PRINT((ndo
, "%d", EXTRACT_24BITS(data
)));
776 ND_PRINT((ndo
, "%s (0x%02x) ",
777 tok2str(rfc4675_tagged
,"Unknown tag",*data
),
780 ND_PRINT((ndo
, "%d", EXTRACT_24BITS(data
)));
784 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
794 ND_PRINT((ndo
, "%s", tstr
));
797 /*****************************/
798 /* Print an attribute IPv4 */
799 /* address value pointed by */
800 /* 'data' and 'length' size. */
801 /*****************************/
802 /* Returns nothing. */
803 /*****************************/
805 print_attr_address(netdissect_options
*ndo
,
806 register const u_char
*data
, u_int length
, u_short attr_code
)
810 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
814 ND_TCHECK2(data
[0],4);
820 if (EXTRACT_32BITS(data
) == 0xFFFFFFFF )
821 ND_PRINT((ndo
, "User Selected"));
823 if (EXTRACT_32BITS(data
) == 0xFFFFFFFE )
824 ND_PRINT((ndo
, "NAS Select"));
826 ND_PRINT((ndo
, "%s",ipaddr_string(ndo
, data
)));
830 ND_PRINT((ndo
, "%s", ipaddr_string(ndo
, data
)));
837 ND_PRINT((ndo
, "%s", tstr
));
840 /*****************************/
841 /* Print an attribute IPv6 */
842 /* address value pointed by */
843 /* 'data' and 'length' size. */
844 /*****************************/
845 /* Returns nothing. */
846 /*****************************/
848 print_attr_address6(netdissect_options
*ndo
,
849 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
853 ND_PRINT((ndo
, "ERROR: length %u != 16", length
));
857 ND_TCHECK2(data
[0], 16);
859 ND_PRINT((ndo
, "%s", ip6addr_string(ndo
, data
)));
864 ND_PRINT((ndo
, "%s", tstr
));
868 print_attr_netmask6(netdissect_options
*ndo
,
869 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
873 if (length
< 2 || length
> 18)
875 ND_PRINT((ndo
, "ERROR: length %u not in range (2..18)", length
));
878 else if (data
[1] > 128)
880 ND_PRINT((ndo
, "ERROR: netmask %u not in range (0..128)", data
[1]));
884 ND_TCHECK2(data
[0], length
);
885 memset(data2
, 0, sizeof(data2
));
887 memcpy(data2
, data
+2, length
-2);
889 ND_PRINT((ndo
, "%s/%u", ip6addr_string(ndo
, data2
), data
[1]));
894 ND_PRINT((ndo
, "%s", tstr
));
897 /*************************************/
898 /* Print an attribute of 'secs since */
899 /* January 1, 1970 00:00 UTC' value */
900 /* pointed by 'data' and 'length' */
902 /*************************************/
903 /* Returns nothing. */
904 /*************************************/
906 print_attr_time(netdissect_options
*ndo
,
907 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
914 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
918 ND_TCHECK2(data
[0],4);
920 attr_time
= EXTRACT_32BITS(data
);
921 strlcpy(string
, ctime(&attr_time
), sizeof(string
));
922 /* Get rid of the newline */
924 ND_PRINT((ndo
, "%.24s", string
));
928 ND_PRINT((ndo
, "%s", tstr
));
931 /***********************************/
932 /* Print an attribute of 'strange' */
933 /* data format pointed by 'data' */
934 /* and 'length' size. */
935 /***********************************/
936 /* Returns nothing. */
937 /***********************************/
939 print_attr_strange(netdissect_options
*ndo
,
940 register const u_char
*data
, u_int length
, u_short attr_code
)
943 u_int error_cause_value
;
950 ND_PRINT((ndo
, "ERROR: length %u != 16", length
));
953 ND_PRINT((ndo
, "User_challenge ("));
954 ND_TCHECK2(data
[0],8);
956 PRINT_HEX(len_data
, data
);
957 ND_PRINT((ndo
, ") User_resp("));
958 ND_TCHECK2(data
[0],8);
960 PRINT_HEX(len_data
, data
);
961 ND_PRINT((ndo
, ")"));
967 ND_PRINT((ndo
, "ERROR: length %u != 14", length
));
970 ND_TCHECK2(data
[0],1);
972 ND_PRINT((ndo
, "User can change password"));
974 ND_PRINT((ndo
, "User cannot change password"));
976 ND_TCHECK2(data
[0],1);
977 ND_PRINT((ndo
, ", Min password length: %d", *data
));
979 ND_PRINT((ndo
, ", created at: "));
980 ND_TCHECK2(data
[0],4);
982 PRINT_HEX(len_data
, data
);
983 ND_PRINT((ndo
, ", expires in: "));
984 ND_TCHECK2(data
[0],4);
986 PRINT_HEX(len_data
, data
);
987 ND_PRINT((ndo
, ", Current Time: "));
988 ND_TCHECK2(data
[0],4);
990 PRINT_HEX(len_data
, data
);
993 case ARAP_CHALLENGE_RESP
:
996 ND_PRINT((ndo
, "ERROR: length %u != 8", length
));
999 ND_TCHECK2(data
[0],8);
1001 PRINT_HEX(len_data
, data
);
1007 ND_PRINT((ndo
, "Error: length %u != 4", length
));
1010 ND_TCHECK2(data
[0],4);
1012 error_cause_value
= EXTRACT_32BITS(data
);
1013 ND_PRINT((ndo
, "Error cause %u: %s", error_cause_value
, tok2str(errorcausetype
, "Error-Cause %u not known", error_cause_value
)));
1019 ND_PRINT((ndo
, "%s", tstr
));
1023 radius_attrs_print(netdissect_options
*ndo
,
1024 register const u_char
*attr
, u_int length
)
1026 register const struct radius_attr
*rad_attr
= (const struct radius_attr
*)attr
;
1027 const char *attr_string
;
1033 ND_TCHECK(*rad_attr
);
1035 if (rad_attr
->type
> 0 && rad_attr
->type
< TAM_SIZE(attr_type
))
1036 attr_string
= attr_type
[rad_attr
->type
].name
;
1038 attr_string
= "Unknown";
1039 if (rad_attr
->len
< 2)
1041 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
1047 if (rad_attr
->len
> length
)
1049 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
1055 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u, Value: ",
1060 if (rad_attr
->type
< TAM_SIZE(attr_type
))
1062 if (rad_attr
->len
> 2)
1064 if ( attr_type
[rad_attr
->type
].print_func
)
1065 (*attr_type
[rad_attr
->type
].print_func
)(
1066 ndo
, ((const u_char
*)(rad_attr
+1)),
1067 rad_attr
->len
- 2, rad_attr
->type
);
1070 /* do we also want to see a hex dump ? */
1071 if (ndo
->ndo_vflag
> 1)
1072 print_unknown_data(ndo
, (const u_char
*)rad_attr
+2, "\n\t ", (rad_attr
->len
)-2);
1074 length
-=(rad_attr
->len
);
1075 rad_attr
= (const struct radius_attr
*)( ((const char *)(rad_attr
))+rad_attr
->len
);
1080 ND_PRINT((ndo
, "%s", tstr
));
1084 radius_print(netdissect_options
*ndo
,
1085 const u_char
*dat
, u_int length
)
1087 register const struct radius_hdr
*rad
;
1088 u_int len
, auth_idx
;
1090 ND_TCHECK2(*dat
, MIN_RADIUS_LEN
);
1091 rad
= (const struct radius_hdr
*)dat
;
1092 len
= EXTRACT_16BITS(&rad
->len
);
1094 if (len
< MIN_RADIUS_LEN
)
1096 ND_PRINT((ndo
, "%s", tstr
));
1103 if (ndo
->ndo_vflag
< 1) {
1104 ND_PRINT((ndo
, "RADIUS, %s (%u), id: 0x%02x length: %u",
1105 tok2str(radius_command_values
,"Unknown Command",rad
->code
),
1112 ND_PRINT((ndo
, "RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
1114 tok2str(radius_command_values
,"Unknown Command",rad
->code
),
1118 for(auth_idx
=0; auth_idx
< 16; auth_idx
++)
1119 ND_PRINT((ndo
, "%02x", rad
->auth
[auth_idx
]));
1122 if (len
> MIN_RADIUS_LEN
)
1123 radius_attrs_print(ndo
, dat
+ MIN_RADIUS_LEN
, len
- MIN_RADIUS_LEN
);
1127 ND_PRINT((ndo
, "%s", tstr
));