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 * "Diameter Network Access Server Application"
62 * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
64 * TODO: Among other things to print ok MacIntosh and Vendor values
71 #include <netdissect-stdinc.h>
75 #include "netdissect.h"
76 #include "addrtoname.h"
80 static const char tstr
[] = " [|radius]";
82 #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
84 #define PRINT_HEX(bytes_len, ptr_data) \
87 ND_PRINT((ndo, "%02X", *ptr_data )); \
93 /* Radius packet codes */
94 #define RADCMD_ACCESS_REQ 1 /* Access-Request */
95 #define RADCMD_ACCESS_ACC 2 /* Access-Accept */
96 #define RADCMD_ACCESS_REJ 3 /* Access-Reject */
97 #define RADCMD_ACCOUN_REQ 4 /* Accounting-Request */
98 #define RADCMD_ACCOUN_RES 5 /* Accounting-Response */
99 #define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
100 #define RADCMD_STATUS_SER 12 /* Status-Server */
101 #define RADCMD_STATUS_CLI 13 /* Status-Client */
102 #define RADCMD_DISCON_REQ 40 /* Disconnect-Request */
103 #define RADCMD_DISCON_ACK 41 /* Disconnect-ACK */
104 #define RADCMD_DISCON_NAK 42 /* Disconnect-NAK */
105 #define RADCMD_COA_REQ 43 /* CoA-Request */
106 #define RADCMD_COA_ACK 44 /* CoA-ACK */
107 #define RADCMD_COA_NAK 45 /* CoA-NAK */
108 #define RADCMD_RESERVED 255 /* Reserved */
110 static const struct tok radius_command_values
[] = {
111 { RADCMD_ACCESS_REQ
, "Access-Request" },
112 { RADCMD_ACCESS_ACC
, "Access-Accept" },
113 { RADCMD_ACCESS_REJ
, "Access-Reject" },
114 { RADCMD_ACCOUN_REQ
, "Accounting-Request" },
115 { RADCMD_ACCOUN_RES
, "Accounting-Response" },
116 { RADCMD_ACCESS_CHA
, "Access-Challenge" },
117 { RADCMD_STATUS_SER
, "Status-Server" },
118 { RADCMD_STATUS_CLI
, "Status-Client" },
119 { RADCMD_DISCON_REQ
, "Disconnect-Request" },
120 { RADCMD_DISCON_ACK
, "Disconnect-ACK" },
121 { RADCMD_DISCON_NAK
, "Disconnect-NAK" },
122 { RADCMD_COA_REQ
, "CoA-Request" },
123 { RADCMD_COA_ACK
, "CoA-ACK" },
124 { RADCMD_COA_NAK
, "CoA-NAK" },
125 { RADCMD_RESERVED
, "Reserved" },
129 /********************************/
130 /* Begin Radius Attribute types */
131 /********************************/
134 #define LOG_IPHOST 14
135 #define LOG_SERVICE 15
137 #define SESSION_TIMEOUT 27
138 #define IDLE_TIMEOUT 28
139 #define FRM_ATALK_LINK 37
140 #define FRM_ATALK_NETWORK 38
142 #define ACCT_DELAY 41
143 #define ACCT_SESSION_TIME 46
145 #define EGRESS_VLAN_ID 56
146 #define EGRESS_VLAN_NAME 58
148 #define TUNNEL_TYPE 64
149 #define TUNNEL_MEDIUM 65
150 #define TUNNEL_CLIENT_END 66
151 #define TUNNEL_SERVER_END 67
152 #define TUNNEL_PASS 69
155 #define ARAP_FEATURES 71
157 #define TUNNEL_PRIV_GROUP 81
158 #define TUNNEL_ASSIGN_ID 82
159 #define TUNNEL_PREFERENCE 83
161 #define ARAP_CHALLENGE_RESP 84
162 #define ACCT_INT_INTERVAL 85
164 #define TUNNEL_CLIENT_AUTH 90
165 #define TUNNEL_SERVER_AUTH 91
166 /********************************/
167 /* End Radius Attribute types */
168 /********************************/
170 #define RFC4675_TAGGED 0x31
171 #define RFC4675_UNTAGGED 0x32
173 static const struct tok rfc4675_tagged
[] = {
174 { RFC4675_TAGGED
, "Tagged" },
175 { RFC4675_UNTAGGED
, "Untagged" },
180 static void print_attr_string(netdissect_options
*, register const u_char
*, u_int
, u_short
);
181 static void print_attr_num(netdissect_options
*, register const u_char
*, u_int
, u_short
);
182 static void print_vendor_attr(netdissect_options
*, register const u_char
*, u_int
, u_short
);
183 static void print_attr_address(netdissect_options
*, register const u_char
*, u_int
, u_short
);
184 static void print_attr_address6(netdissect_options
*, register const u_char
*, u_int
, u_short
);
185 static void print_attr_netmask6(netdissect_options
*, register const u_char
*, u_int
, u_short
);
186 static void print_attr_time(netdissect_options
*, register const u_char
*, u_int
, u_short
);
187 static void print_attr_strange(netdissect_options
*, register const u_char
*, u_int
, u_short
);
190 struct radius_hdr
{ uint8_t code
; /* Radius packet code */
191 uint8_t id
; /* Radius packet id */
192 uint16_t len
; /* Radius total length */
193 uint8_t auth
[16]; /* Authenticator */
196 #define MIN_RADIUS_LEN 20
198 struct radius_attr
{ uint8_t type
; /* Attribute type */
199 uint8_t len
; /* Attribute length */
203 /* Service-Type Attribute standard values */
204 static const char *serv_type
[]={ NULL
,
213 "Callback NAS Prompt",
215 "Callback Administrative",
218 /* Framed-Protocol Attribute standard values */
219 static const char *frm_proto
[]={ NULL
,
223 "Gandalf proprietary",
228 /* Framed-Routing Attribute standard values */
229 static const char *frm_routing
[]={ "None",
235 /* Framed-Compression Attribute standard values */
236 static const char *frm_comp
[]={ "None",
242 /* Login-Service Attribute standard values */
243 static const char *login_serv
[]={ "Telnet",
246 "PortMaster(proprietary)",
255 /* Termination-Action Attribute standard values */
256 static const char *term_action
[]={ "Default",
260 /* Ingress-Filters Attribute standard values */
261 static const char *ingress_filters
[]={ NULL
,
266 /* NAS-Port-Type Attribute standard values */
267 static const char *nas_port_type
[]={ "Async",
274 "HDLC Clear Channel",
286 "Wireless - IEEE 802.11",
289 /* Acct-Status-Type Accounting Attribute standard values */
290 static const char *acct_status
[]={ NULL
,
304 "Tunnel-Link-Reject",
308 /* Acct-Authentic Accounting Attribute standard values */
309 static const char *acct_auth
[]={ NULL
,
315 /* Acct-Terminate-Cause Accounting Attribute standard values */
316 static const char *acct_term
[]={ NULL
,
331 "Service Unavailable",
337 /* Tunnel-Type Attribute standard values */
338 static const char *tunnel_type
[]={ NULL
,
350 "IP-in-IP Tunneling",
354 /* Tunnel-Medium-Type Attribute standard values */
355 static const char *tunnel_medium
[]={ NULL
,
370 "E.164 with NSAP subaddress",
373 /* ARAP-Zone-Access Attribute standard values */
374 static const char *arap_zone
[]={ NULL
,
375 "Only access to dfl zone",
376 "Use zone filter inc.",
378 "Use zone filter exc.",
381 static const char *prompt
[]={ "No Echo",
386 static struct attrtype
{
387 const char *name
; /* Attribute name */
388 const char **subtypes
; /* Standard Values (if any) */
389 u_char siz_subtypes
; /* Size of total standard values */
390 u_char first_subtype
; /* First standard value is 0 or 1 */
391 void (*print_func
)(netdissect_options
*, register const u_char
*, u_int
, u_short
);
394 { NULL
, NULL
, 0, 0, NULL
},
395 { "User-Name", NULL
, 0, 0, print_attr_string
},
396 { "User-Password", NULL
, 0, 0, NULL
},
397 { "CHAP-Password", NULL
, 0, 0, NULL
},
398 { "NAS-IP-Address", NULL
, 0, 0, print_attr_address
},
399 { "NAS-Port", NULL
, 0, 0, print_attr_num
},
400 { "Service-Type", serv_type
, TAM_SIZE(serv_type
)-1, 1, print_attr_num
},
401 { "Framed-Protocol", frm_proto
, TAM_SIZE(frm_proto
)-1, 1, print_attr_num
},
402 { "Framed-IP-Address", NULL
, 0, 0, print_attr_address
},
403 { "Framed-IP-Netmask", NULL
, 0, 0, print_attr_address
},
404 { "Framed-Routing", frm_routing
, TAM_SIZE(frm_routing
), 0, print_attr_num
},
405 { "Filter-Id", NULL
, 0, 0, print_attr_string
},
406 { "Framed-MTU", NULL
, 0, 0, print_attr_num
},
407 { "Framed-Compression", frm_comp
, TAM_SIZE(frm_comp
), 0, print_attr_num
},
408 { "Login-IP-Host", NULL
, 0, 0, print_attr_address
},
409 { "Login-Service", login_serv
, TAM_SIZE(login_serv
), 0, print_attr_num
},
410 { "Login-TCP-Port", NULL
, 0, 0, print_attr_num
},
411 { "Unassigned", NULL
, 0, 0, NULL
}, /*17*/
412 { "Reply-Message", NULL
, 0, 0, print_attr_string
},
413 { "Callback-Number", NULL
, 0, 0, print_attr_string
},
414 { "Callback-Id", NULL
, 0, 0, print_attr_string
},
415 { "Unassigned", NULL
, 0, 0, NULL
}, /*21*/
416 { "Framed-Route", NULL
, 0, 0, print_attr_string
},
417 { "Framed-IPX-Network", NULL
, 0, 0, print_attr_num
},
418 { "State", NULL
, 0, 0, print_attr_string
},
419 { "Class", NULL
, 0, 0, print_attr_string
},
420 { "Vendor-Specific", NULL
, 0, 0, print_vendor_attr
},
421 { "Session-Timeout", NULL
, 0, 0, print_attr_num
},
422 { "Idle-Timeout", NULL
, 0, 0, print_attr_num
},
423 { "Termination-Action", term_action
, TAM_SIZE(term_action
), 0, print_attr_num
},
424 { "Called-Station-Id", NULL
, 0, 0, print_attr_string
},
425 { "Calling-Station-Id", NULL
, 0, 0, print_attr_string
},
426 { "NAS-Identifier", NULL
, 0, 0, print_attr_string
},
427 { "Proxy-State", NULL
, 0, 0, print_attr_string
},
428 { "Login-LAT-Service", NULL
, 0, 0, print_attr_string
},
429 { "Login-LAT-Node", NULL
, 0, 0, print_attr_string
},
430 { "Login-LAT-Group", NULL
, 0, 0, print_attr_string
},
431 { "Framed-AppleTalk-Link", NULL
, 0, 0, print_attr_num
},
432 { "Framed-AppleTalk-Network", NULL
, 0, 0, print_attr_num
},
433 { "Framed-AppleTalk-Zone", NULL
, 0, 0, print_attr_string
},
434 { "Acct-Status-Type", acct_status
, TAM_SIZE(acct_status
)-1, 1, print_attr_num
},
435 { "Acct-Delay-Time", NULL
, 0, 0, print_attr_num
},
436 { "Acct-Input-Octets", NULL
, 0, 0, print_attr_num
},
437 { "Acct-Output-Octets", NULL
, 0, 0, print_attr_num
},
438 { "Acct-Session-Id", NULL
, 0, 0, print_attr_string
},
439 { "Acct-Authentic", acct_auth
, TAM_SIZE(acct_auth
)-1, 1, print_attr_num
},
440 { "Acct-Session-Time", NULL
, 0, 0, print_attr_num
},
441 { "Acct-Input-Packets", NULL
, 0, 0, print_attr_num
},
442 { "Acct-Output-Packets", NULL
, 0, 0, print_attr_num
},
443 { "Acct-Terminate-Cause", acct_term
, TAM_SIZE(acct_term
)-1, 1, print_attr_num
},
444 { "Acct-Multi-Session-Id", NULL
, 0, 0, print_attr_string
},
445 { "Acct-Link-Count", NULL
, 0, 0, print_attr_num
},
446 { "Acct-Input-Gigawords", NULL
, 0, 0, print_attr_num
},
447 { "Acct-Output-Gigawords", NULL
, 0, 0, print_attr_num
},
448 { "Unassigned", NULL
, 0, 0, NULL
}, /*54*/
449 { "Event-Timestamp", NULL
, 0, 0, print_attr_time
},
450 { "Egress-VLANID", NULL
, 0, 0, print_attr_num
},
451 { "Ingress-Filters", ingress_filters
, TAM_SIZE(ingress_filters
)-1, 1, print_attr_num
},
452 { "Egress-VLAN-Name", NULL
, 0, 0, print_attr_string
},
453 { "User-Priority-Table", NULL
, 0, 0, NULL
},
454 { "CHAP-Challenge", NULL
, 0, 0, print_attr_string
},
455 { "NAS-Port-Type", nas_port_type
, TAM_SIZE(nas_port_type
), 0, print_attr_num
},
456 { "Port-Limit", NULL
, 0, 0, print_attr_num
},
457 { "Login-LAT-Port", NULL
, 0, 0, print_attr_string
}, /*63*/
458 { "Tunnel-Type", tunnel_type
, TAM_SIZE(tunnel_type
)-1, 1, print_attr_num
},
459 { "Tunnel-Medium-Type", tunnel_medium
, TAM_SIZE(tunnel_medium
)-1, 1, print_attr_num
},
460 { "Tunnel-Client-Endpoint", NULL
, 0, 0, print_attr_string
},
461 { "Tunnel-Server-Endpoint", NULL
, 0, 0, print_attr_string
},
462 { "Acct-Tunnel-Connection", NULL
, 0, 0, print_attr_string
},
463 { "Tunnel-Password", NULL
, 0, 0, print_attr_string
},
464 { "ARAP-Password", NULL
, 0, 0, print_attr_strange
},
465 { "ARAP-Features", NULL
, 0, 0, print_attr_strange
},
466 { "ARAP-Zone-Access", arap_zone
, TAM_SIZE(arap_zone
)-1, 1, print_attr_num
}, /*72*/
467 { "ARAP-Security", NULL
, 0, 0, print_attr_string
},
468 { "ARAP-Security-Data", NULL
, 0, 0, print_attr_string
},
469 { "Password-Retry", NULL
, 0, 0, print_attr_num
},
470 { "Prompt", prompt
, TAM_SIZE(prompt
), 0, print_attr_num
},
471 { "Connect-Info", NULL
, 0, 0, print_attr_string
},
472 { "Configuration-Token", NULL
, 0, 0, print_attr_string
},
473 { "EAP-Message", NULL
, 0, 0, print_attr_string
},
474 { "Message-Authenticator", NULL
, 0, 0, print_attr_string
}, /*80*/
475 { "Tunnel-Private-Group-ID", NULL
, 0, 0, print_attr_string
},
476 { "Tunnel-Assignment-ID", NULL
, 0, 0, print_attr_string
},
477 { "Tunnel-Preference", NULL
, 0, 0, print_attr_num
},
478 { "ARAP-Challenge-Response", NULL
, 0, 0, print_attr_strange
},
479 { "Acct-Interim-Interval", NULL
, 0, 0, print_attr_num
},
480 { "Acct-Tunnel-Packets-Lost", NULL
, 0, 0, print_attr_num
}, /*86*/
481 { "NAS-Port-Id", NULL
, 0, 0, print_attr_string
},
482 { "Framed-Pool", NULL
, 0, 0, print_attr_string
},
483 { "CUI", NULL
, 0, 0, print_attr_string
},
484 { "Tunnel-Client-Auth-ID", NULL
, 0, 0, print_attr_string
},
485 { "Tunnel-Server-Auth-ID", NULL
, 0, 0, print_attr_string
},
486 { "NAS-Filter-Rule", NULL
, 0, 0, print_attr_string
},
487 { "Unassigned", NULL
, 0, 0, NULL
}, /*93*/
488 { "Originating-Line-Info", NULL
, 0, 0, NULL
},
489 { "NAS-IPv6-Address", NULL
, 0, 0, print_attr_address6
},
490 { "Framed-Interface-ID", NULL
, 0, 0, NULL
},
491 { "Framed-IPv6-Prefix", NULL
, 0, 0, print_attr_netmask6
},
492 { "Login-IPv6-Host", NULL
, 0, 0, print_attr_address6
},
493 { "Framed-IPv6-Route", NULL
, 0, 0, print_attr_string
},
494 { "Framed-IPv6-Pool", NULL
, 0, 0, print_attr_string
}
498 /*****************************/
499 /* Print an attribute string */
500 /* value pointed by 'data' */
501 /* and 'length' size. */
502 /*****************************/
503 /* Returns nothing. */
504 /*****************************/
506 print_attr_string(netdissect_options
*ndo
,
507 register const u_char
*data
, u_int length
, u_short attr_code
)
511 ND_TCHECK2(data
[0],length
);
518 if (*data
&& (*data
<=0x1F) )
519 ND_PRINT((ndo
, "Tag[%u] ", *data
));
521 ND_PRINT((ndo
, "Tag[Unused] "));
524 ND_PRINT((ndo
, "Salt %u ", EXTRACT_16BITS(data
)));
528 case TUNNEL_CLIENT_END
:
529 case TUNNEL_SERVER_END
:
530 case TUNNEL_PRIV_GROUP
:
531 case TUNNEL_ASSIGN_ID
:
532 case TUNNEL_CLIENT_AUTH
:
533 case TUNNEL_SERVER_AUTH
:
539 ND_PRINT((ndo
, "Tag[%u] ", *data
));
541 ND_PRINT((ndo
, "Tag[Unused] "));
546 case EGRESS_VLAN_NAME
:
549 ND_PRINT((ndo
, "%s (0x%02x) ",
550 tok2str(rfc4675_tagged
,"Unknown tag",*data
),
557 for (i
=0; i
< length
&& *data
; i
++, data
++)
558 ND_PRINT((ndo
, "%c", (*data
< 32 || *data
> 126) ? '.' : *data
));
563 ND_PRINT((ndo
, "%s", tstr
));
567 * print vendor specific attributes
570 print_vendor_attr(netdissect_options
*ndo
,
571 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
580 ND_TCHECK2(*data
, 4);
581 vendor_id
= EXTRACT_32BITS(data
);
585 ND_PRINT((ndo
, "Vendor: %s (%u)",
586 tok2str(smi_values
,"Unknown",vendor_id
),
589 while (length
>= 2) {
590 ND_TCHECK2(*data
, 2);
592 vendor_type
= *(data
);
593 vendor_length
= *(data
+1);
595 if (vendor_length
< 2)
597 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
602 if (vendor_length
> length
)
604 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
612 ND_TCHECK2(*data
, vendor_length
);
614 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u, Value: ",
617 for (idx
= 0; idx
< vendor_length
; idx
++, data
++)
618 ND_PRINT((ndo
, "%c", (*data
< 32 || *data
> 126) ? '.' : *data
));
619 length
-=vendor_length
;
624 ND_PRINT((ndo
, "%s", tstr
));
627 /******************************/
628 /* Print an attribute numeric */
629 /* value pointed by 'data' */
630 /* and 'length' size. */
631 /******************************/
632 /* Returns nothing. */
633 /******************************/
635 print_attr_num(netdissect_options
*ndo
,
636 register const u_char
*data
, u_int length
, u_short attr_code
)
642 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
646 ND_TCHECK2(data
[0],4);
647 /* This attribute has standard values */
648 if (attr_type
[attr_code
].siz_subtypes
)
650 static const char **table
;
652 table
= attr_type
[attr_code
].subtypes
;
654 if ( (attr_code
== TUNNEL_TYPE
) || (attr_code
== TUNNEL_MEDIUM
) )
657 ND_PRINT((ndo
, "Tag[Unused] "));
659 ND_PRINT((ndo
, "Tag[%d] ", *data
));
661 data_value
= EXTRACT_24BITS(data
);
665 data_value
= EXTRACT_32BITS(data
);
667 if ( data_value
<= (uint32_t)(attr_type
[attr_code
].siz_subtypes
- 1 +
668 attr_type
[attr_code
].first_subtype
) &&
669 data_value
>= attr_type
[attr_code
].first_subtype
)
670 ND_PRINT((ndo
, "%s", table
[data_value
]));
672 ND_PRINT((ndo
, "#%u", data_value
));
676 switch(attr_code
) /* Be aware of special cases... */
679 if (EXTRACT_32BITS( data
) == 0xFFFFFFFE )
680 ND_PRINT((ndo
, "NAS Select"));
682 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
685 case SESSION_TIMEOUT
:
688 case ACCT_SESSION_TIME
:
689 case ACCT_INT_INTERVAL
:
690 timeout
= EXTRACT_32BITS( data
);
692 ND_PRINT((ndo
, "%02d secs", timeout
));
695 if ( timeout
< 3600 )
696 ND_PRINT((ndo
, "%02d:%02d min",
697 timeout
/ 60, timeout
% 60));
699 ND_PRINT((ndo
, "%02d:%02d:%02d hours",
700 timeout
/ 3600, (timeout
% 3600) / 60,
706 if (EXTRACT_32BITS(data
) )
707 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
709 ND_PRINT((ndo
, "Unnumbered"));
712 case FRM_ATALK_NETWORK
:
713 if (EXTRACT_32BITS(data
) )
714 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
716 ND_PRINT((ndo
, "NAS assigned"));
719 case TUNNEL_PREFERENCE
:
721 ND_PRINT((ndo
, "Tag[%d] ", *data
));
723 ND_PRINT((ndo
, "Tag[Unused] "));
725 ND_PRINT((ndo
, "%d", EXTRACT_24BITS(data
)));
729 ND_PRINT((ndo
, "%s (0x%02x) ",
730 tok2str(rfc4675_tagged
,"Unknown tag",*data
),
733 ND_PRINT((ndo
, "%d", EXTRACT_24BITS(data
)));
737 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
747 ND_PRINT((ndo
, "%s", tstr
));
750 /*****************************/
751 /* Print an attribute IPv4 */
752 /* address value pointed by */
753 /* 'data' and 'length' size. */
754 /*****************************/
755 /* Returns nothing. */
756 /*****************************/
758 print_attr_address(netdissect_options
*ndo
,
759 register const u_char
*data
, u_int length
, u_short attr_code
)
763 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
767 ND_TCHECK2(data
[0],4);
773 if (EXTRACT_32BITS(data
) == 0xFFFFFFFF )
774 ND_PRINT((ndo
, "User Selected"));
776 if (EXTRACT_32BITS(data
) == 0xFFFFFFFE )
777 ND_PRINT((ndo
, "NAS Select"));
779 ND_PRINT((ndo
, "%s",ipaddr_string(ndo
, data
)));
783 ND_PRINT((ndo
, "%s", ipaddr_string(ndo
, data
)));
790 ND_PRINT((ndo
, "%s", tstr
));
793 /*****************************/
794 /* Print an attribute IPv6 */
795 /* address value pointed by */
796 /* 'data' and 'length' size. */
797 /*****************************/
798 /* Returns nothing. */
799 /*****************************/
801 print_attr_address6(netdissect_options
*ndo
,
802 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
806 ND_PRINT((ndo
, "ERROR: length %u != 16", length
));
810 ND_TCHECK2(data
[0], 16);
812 ND_PRINT((ndo
, "%s", ip6addr_string(ndo
, data
)));
817 ND_PRINT((ndo
, "%s", tstr
));
821 print_attr_netmask6(netdissect_options
*ndo
,
822 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
826 if (length
< 2 || length
> 18)
828 ND_PRINT((ndo
, "ERROR: length %u not in range (2..18)", length
));
831 else if (data
[1] > 128)
833 ND_PRINT((ndo
, "ERROR: netmask %u not in range (0..128)", data
[1]));
837 ND_TCHECK2(data
[0], length
);
838 memset(data2
, 0, sizeof(data2
));
840 memcpy(data2
, data
+2, length
-2);
842 ND_PRINT((ndo
, "%s/%u", ip6addr_string(ndo
, data2
), data
[1]));
847 ND_PRINT((ndo
, "%s", tstr
));
850 /*************************************/
851 /* Print an attribute of 'secs since */
852 /* January 1, 1970 00:00 UTC' value */
853 /* pointed by 'data' and 'length' */
855 /*************************************/
856 /* Returns nothing. */
857 /*************************************/
859 print_attr_time(netdissect_options
*ndo
,
860 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
867 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
871 ND_TCHECK2(data
[0],4);
873 attr_time
= EXTRACT_32BITS(data
);
874 strlcpy(string
, ctime(&attr_time
), sizeof(string
));
875 /* Get rid of the newline */
877 ND_PRINT((ndo
, "%.24s", string
));
881 ND_PRINT((ndo
, "%s", tstr
));
884 /***********************************/
885 /* Print an attribute of 'strange' */
886 /* data format pointed by 'data' */
887 /* and 'length' size. */
888 /***********************************/
889 /* Returns nothing. */
890 /***********************************/
892 print_attr_strange(netdissect_options
*ndo
,
893 register const u_char
*data
, u_int length
, u_short attr_code
)
902 ND_PRINT((ndo
, "ERROR: length %u != 16", length
));
905 ND_PRINT((ndo
, "User_challenge ("));
906 ND_TCHECK2(data
[0],8);
908 PRINT_HEX(len_data
, data
);
909 ND_PRINT((ndo
, ") User_resp("));
910 ND_TCHECK2(data
[0],8);
912 PRINT_HEX(len_data
, data
);
913 ND_PRINT((ndo
, ")"));
919 ND_PRINT((ndo
, "ERROR: length %u != 14", length
));
922 ND_TCHECK2(data
[0],1);
924 ND_PRINT((ndo
, "User can change password"));
926 ND_PRINT((ndo
, "User cannot change password"));
928 ND_TCHECK2(data
[0],1);
929 ND_PRINT((ndo
, ", Min password length: %d", *data
));
931 ND_PRINT((ndo
, ", created at: "));
932 ND_TCHECK2(data
[0],4);
934 PRINT_HEX(len_data
, data
);
935 ND_PRINT((ndo
, ", expires in: "));
936 ND_TCHECK2(data
[0],4);
938 PRINT_HEX(len_data
, data
);
939 ND_PRINT((ndo
, ", Current Time: "));
940 ND_TCHECK2(data
[0],4);
942 PRINT_HEX(len_data
, data
);
945 case ARAP_CHALLENGE_RESP
:
948 ND_PRINT((ndo
, "ERROR: length %u != 8", length
));
951 ND_TCHECK2(data
[0],8);
953 PRINT_HEX(len_data
, data
);
959 ND_PRINT((ndo
, "%s", tstr
));
963 radius_attrs_print(netdissect_options
*ndo
,
964 register const u_char
*attr
, u_int length
)
966 register const struct radius_attr
*rad_attr
= (const struct radius_attr
*)attr
;
967 const char *attr_string
;
973 ND_TCHECK(*rad_attr
);
975 if (rad_attr
->type
> 0 && rad_attr
->type
< TAM_SIZE(attr_type
))
976 attr_string
= attr_type
[rad_attr
->type
].name
;
978 attr_string
= "Unknown";
979 if (rad_attr
->len
< 2)
981 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
987 if (rad_attr
->len
> length
)
989 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
995 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u, Value: ",
1000 if (rad_attr
->type
< TAM_SIZE(attr_type
))
1002 if (rad_attr
->len
> 2)
1004 if ( attr_type
[rad_attr
->type
].print_func
)
1005 (*attr_type
[rad_attr
->type
].print_func
)(
1006 ndo
, ((const u_char
*)(rad_attr
+1)),
1007 rad_attr
->len
- 2, rad_attr
->type
);
1010 /* do we also want to see a hex dump ? */
1011 if (ndo
->ndo_vflag
> 1)
1012 print_unknown_data(ndo
, (const u_char
*)rad_attr
+2, "\n\t ", (rad_attr
->len
)-2);
1014 length
-=(rad_attr
->len
);
1015 rad_attr
= (const struct radius_attr
*)( ((const char *)(rad_attr
))+rad_attr
->len
);
1020 ND_PRINT((ndo
, "%s", tstr
));
1024 radius_print(netdissect_options
*ndo
,
1025 const u_char
*dat
, u_int length
)
1027 register const struct radius_hdr
*rad
;
1028 u_int len
, auth_idx
;
1030 ND_TCHECK2(*dat
, MIN_RADIUS_LEN
);
1031 rad
= (const struct radius_hdr
*)dat
;
1032 len
= EXTRACT_16BITS(&rad
->len
);
1034 if (len
< MIN_RADIUS_LEN
)
1036 ND_PRINT((ndo
, "%s", tstr
));
1043 if (ndo
->ndo_vflag
< 1) {
1044 ND_PRINT((ndo
, "RADIUS, %s (%u), id: 0x%02x length: %u",
1045 tok2str(radius_command_values
,"Unknown Command",rad
->code
),
1052 ND_PRINT((ndo
, "RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
1054 tok2str(radius_command_values
,"Unknown Command",rad
->code
),
1058 for(auth_idx
=0; auth_idx
< 16; auth_idx
++)
1059 ND_PRINT((ndo
, "%02x", rad
->auth
[auth_idx
]));
1062 if (len
> MIN_RADIUS_LEN
)
1063 radius_attrs_print(ndo
, dat
+ MIN_RADIUS_LEN
, len
- MIN_RADIUS_LEN
);
1067 ND_PRINT((ndo
, "%s", tstr
));