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"
44 * "IEEE 802.1X Remote Authentication Dial In User Service (RADIUS)"
48 * "RADIUS Attributes for Virtual LAN and Priority Support"
51 * "Dynamic Authorization Extensions to RADIUS"
53 * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
55 * TODO: Among other things to print ok MacIntosh and Vendor values
62 #include <netdissect-stdinc.h>
66 #include "netdissect.h"
67 #include "addrtoname.h"
71 static const char tstr
[] = " [|radius]";
73 #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
75 #define PRINT_HEX(bytes_len, ptr_data) \
78 ND_PRINT((ndo, "%02X", *ptr_data )); \
84 /* Radius packet codes */
85 #define RADCMD_ACCESS_REQ 1 /* Access-Request */
86 #define RADCMD_ACCESS_ACC 2 /* Access-Accept */
87 #define RADCMD_ACCESS_REJ 3 /* Access-Reject */
88 #define RADCMD_ACCOUN_REQ 4 /* Accounting-Request */
89 #define RADCMD_ACCOUN_RES 5 /* Accounting-Response */
90 #define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
91 #define RADCMD_STATUS_SER 12 /* Status-Server */
92 #define RADCMD_STATUS_CLI 13 /* Status-Client */
93 #define RADCMD_DISCON_REQ 40 /* Disconnect-Request */
94 #define RADCMD_DISCON_ACK 41 /* Disconnect-ACK */
95 #define RADCMD_DISCON_NAK 42 /* Disconnect-NAK */
96 #define RADCMD_COA_REQ 43 /* CoA-Request */
97 #define RADCMD_COA_ACK 44 /* CoA-ACK */
98 #define RADCMD_COA_NAK 45 /* CoA-NAK */
99 #define RADCMD_RESERVED 255 /* Reserved */
101 static const struct tok radius_command_values
[] = {
102 { RADCMD_ACCESS_REQ
, "Access-Request" },
103 { RADCMD_ACCESS_ACC
, "Access-Accept" },
104 { RADCMD_ACCESS_REJ
, "Access-Reject" },
105 { RADCMD_ACCOUN_REQ
, "Accounting-Request" },
106 { RADCMD_ACCOUN_RES
, "Accounting-Response" },
107 { RADCMD_ACCESS_CHA
, "Access-Challenge" },
108 { RADCMD_STATUS_SER
, "Status-Server" },
109 { RADCMD_STATUS_CLI
, "Status-Client" },
110 { RADCMD_DISCON_REQ
, "Disconnect-Request" },
111 { RADCMD_DISCON_ACK
, "Disconnect-ACK" },
112 { RADCMD_DISCON_NAK
, "Disconnect-NAK" },
113 { RADCMD_COA_REQ
, "CoA-Request" },
114 { RADCMD_COA_ACK
, "CoA-ACK" },
115 { RADCMD_COA_NAK
, "CoA-NAK" },
116 { RADCMD_RESERVED
, "Reserved" },
120 /********************************/
121 /* Begin Radius Attribute types */
122 /********************************/
125 #define LOG_IPHOST 14
126 #define LOG_SERVICE 15
128 #define SESSION_TIMEOUT 27
129 #define IDLE_TIMEOUT 28
130 #define FRM_ATALK_LINK 37
131 #define FRM_ATALK_NETWORK 38
133 #define ACCT_DELAY 41
134 #define ACCT_SESSION_TIME 46
136 #define EGRESS_VLAN_ID 56
137 #define EGRESS_VLAN_NAME 58
139 #define TUNNEL_TYPE 64
140 #define TUNNEL_MEDIUM 65
141 #define TUNNEL_CLIENT_END 66
142 #define TUNNEL_SERVER_END 67
143 #define TUNNEL_PASS 69
146 #define ARAP_FEATURES 71
148 #define TUNNEL_PRIV_GROUP 81
149 #define TUNNEL_ASSIGN_ID 82
150 #define TUNNEL_PREFERENCE 83
152 #define ARAP_CHALLENGE_RESP 84
153 #define ACCT_INT_INTERVAL 85
155 #define TUNNEL_CLIENT_AUTH 90
156 #define TUNNEL_SERVER_AUTH 91
157 /********************************/
158 /* End Radius Attribute types */
159 /********************************/
161 #define RFC4675_TAGGED 0x31
162 #define RFC4675_UNTAGGED 0x32
164 static const struct tok rfc4675_tagged
[] = {
165 { RFC4675_TAGGED
, "Tagged" },
166 { RFC4675_UNTAGGED
, "Untagged" },
171 static void print_attr_string(netdissect_options
*, register const u_char
*, u_int
, u_short
);
172 static void print_attr_num(netdissect_options
*, register const u_char
*, u_int
, u_short
);
173 static void print_vendor_attr(netdissect_options
*, register const u_char
*, u_int
, u_short
);
174 static void print_attr_address(netdissect_options
*, register const u_char
*, u_int
, u_short
);
175 static void print_attr_time(netdissect_options
*, register const u_char
*, u_int
, u_short
);
176 static void print_attr_strange(netdissect_options
*, register const u_char
*, u_int
, u_short
);
179 struct radius_hdr
{ uint8_t code
; /* Radius packet code */
180 uint8_t id
; /* Radius packet id */
181 uint16_t len
; /* Radius total length */
182 uint8_t auth
[16]; /* Authenticator */
185 #define MIN_RADIUS_LEN 20
187 struct radius_attr
{ uint8_t type
; /* Attribute type */
188 uint8_t len
; /* Attribute length */
192 /* Service-Type Attribute standard values */
193 static const char *serv_type
[]={ NULL
,
202 "Callback NAS Prompt",
204 "Callback Administrative",
207 /* Framed-Protocol Attribute standard values */
208 static const char *frm_proto
[]={ NULL
,
212 "Gandalf proprietary",
217 /* Framed-Routing Attribute standard values */
218 static const char *frm_routing
[]={ "None",
224 /* Framed-Compression Attribute standard values */
225 static const char *frm_comp
[]={ "None",
231 /* Login-Service Attribute standard values */
232 static const char *login_serv
[]={ "Telnet",
235 "PortMaster(proprietary)",
244 /* Termination-Action Attribute standard values */
245 static const char *term_action
[]={ "Default",
249 /* Ingress-Filters Attribute standard values */
250 static const char *ingress_filters
[]={ NULL
,
255 /* NAS-Port-Type Attribute standard values */
256 static const char *nas_port_type
[]={ "Async",
263 "HDLC Clear Channel",
275 "Wireless - IEEE 802.11",
278 /* Acct-Status-Type Accounting Attribute standard values */
279 static const char *acct_status
[]={ NULL
,
293 "Tunnel-Link-Reject",
297 /* Acct-Authentic Accounting Attribute standard values */
298 static const char *acct_auth
[]={ NULL
,
304 /* Acct-Terminate-Cause Accounting Attribute standard values */
305 static const char *acct_term
[]={ NULL
,
320 "Service Unavailable",
326 /* Tunnel-Type Attribute standard values */
327 static const char *tunnel_type
[]={ NULL
,
339 "IP-in-IP Tunneling",
343 /* Tunnel-Medium-Type Attribute standard values */
344 static const char *tunnel_medium
[]={ NULL
,
359 "E.164 with NSAP subaddress",
362 /* ARAP-Zone-Access Attribute standard values */
363 static const char *arap_zone
[]={ NULL
,
364 "Only access to dfl zone",
365 "Use zone filter inc.",
367 "Use zone filter exc.",
370 static const char *prompt
[]={ "No Echo",
375 struct attrtype
{ const char *name
; /* Attribute name */
376 const char **subtypes
; /* Standard Values (if any) */
377 u_char siz_subtypes
; /* Size of total standard values */
378 u_char first_subtype
; /* First standard value is 0 or 1 */
379 void (*print_func
)(netdissect_options
*, register const u_char
*, u_int
, u_short
);
382 { NULL
, NULL
, 0, 0, NULL
},
383 { "User-Name", NULL
, 0, 0, print_attr_string
},
384 { "User-Password", NULL
, 0, 0, NULL
},
385 { "CHAP-Password", NULL
, 0, 0, NULL
},
386 { "NAS-IP-Address", NULL
, 0, 0, print_attr_address
},
387 { "NAS-Port", NULL
, 0, 0, print_attr_num
},
388 { "Service-Type", serv_type
, TAM_SIZE(serv_type
)-1, 1, print_attr_num
},
389 { "Framed-Protocol", frm_proto
, TAM_SIZE(frm_proto
)-1, 1, print_attr_num
},
390 { "Framed-IP-Address", NULL
, 0, 0, print_attr_address
},
391 { "Framed-IP-Netmask", NULL
, 0, 0, print_attr_address
},
392 { "Framed-Routing", frm_routing
, TAM_SIZE(frm_routing
), 0, print_attr_num
},
393 { "Filter-Id", NULL
, 0, 0, print_attr_string
},
394 { "Framed-MTU", NULL
, 0, 0, print_attr_num
},
395 { "Framed-Compression", frm_comp
, TAM_SIZE(frm_comp
), 0, print_attr_num
},
396 { "Login-IP-Host", NULL
, 0, 0, print_attr_address
},
397 { "Login-Service", login_serv
, TAM_SIZE(login_serv
), 0, print_attr_num
},
398 { "Login-TCP-Port", NULL
, 0, 0, print_attr_num
},
399 { "Unassigned", NULL
, 0, 0, NULL
}, /*17*/
400 { "Reply-Message", NULL
, 0, 0, print_attr_string
},
401 { "Callback-Number", NULL
, 0, 0, print_attr_string
},
402 { "Callback-Id", NULL
, 0, 0, print_attr_string
},
403 { "Unassigned", NULL
, 0, 0, NULL
}, /*21*/
404 { "Framed-Route", NULL
, 0, 0, print_attr_string
},
405 { "Framed-IPX-Network", NULL
, 0, 0, print_attr_num
},
406 { "State", NULL
, 0, 0, print_attr_string
},
407 { "Class", NULL
, 0, 0, print_attr_string
},
408 { "Vendor-Specific", NULL
, 0, 0, print_vendor_attr
},
409 { "Session-Timeout", NULL
, 0, 0, print_attr_num
},
410 { "Idle-Timeout", NULL
, 0, 0, print_attr_num
},
411 { "Termination-Action", term_action
, TAM_SIZE(term_action
), 0, print_attr_num
},
412 { "Called-Station-Id", NULL
, 0, 0, print_attr_string
},
413 { "Calling-Station-Id", NULL
, 0, 0, print_attr_string
},
414 { "NAS-Identifier", NULL
, 0, 0, print_attr_string
},
415 { "Proxy-State", NULL
, 0, 0, print_attr_string
},
416 { "Login-LAT-Service", NULL
, 0, 0, print_attr_string
},
417 { "Login-LAT-Node", NULL
, 0, 0, print_attr_string
},
418 { "Login-LAT-Group", NULL
, 0, 0, print_attr_string
},
419 { "Framed-AppleTalk-Link", NULL
, 0, 0, print_attr_num
},
420 { "Framed-AppleTalk-Network", NULL
, 0, 0, print_attr_num
},
421 { "Framed-AppleTalk-Zone", NULL
, 0, 0, print_attr_string
},
422 { "Acct-Status-Type", acct_status
, TAM_SIZE(acct_status
)-1, 1, print_attr_num
},
423 { "Acct-Delay-Time", NULL
, 0, 0, print_attr_num
},
424 { "Acct-Input-Octets", NULL
, 0, 0, print_attr_num
},
425 { "Acct-Output-Octets", NULL
, 0, 0, print_attr_num
},
426 { "Acct-Session-Id", NULL
, 0, 0, print_attr_string
},
427 { "Acct-Authentic", acct_auth
, TAM_SIZE(acct_auth
)-1, 1, print_attr_num
},
428 { "Acct-Session-Time", NULL
, 0, 0, print_attr_num
},
429 { "Acct-Input-Packets", NULL
, 0, 0, print_attr_num
},
430 { "Acct-Output-Packets", NULL
, 0, 0, print_attr_num
},
431 { "Acct-Terminate-Cause", acct_term
, TAM_SIZE(acct_term
)-1, 1, print_attr_num
},
432 { "Acct-Multi-Session-Id", NULL
, 0, 0, print_attr_string
},
433 { "Acct-Link-Count", NULL
, 0, 0, print_attr_num
},
434 { "Acct-Input-Gigawords", NULL
, 0, 0, print_attr_num
},
435 { "Acct-Output-Gigawords", NULL
, 0, 0, print_attr_num
},
436 { "Unassigned", NULL
, 0, 0, NULL
}, /*54*/
437 { "Event-Timestamp", NULL
, 0, 0, print_attr_time
},
438 { "Egress-VLANID", NULL
, 0, 0, print_attr_num
},
439 { "Ingress-Filters", ingress_filters
, TAM_SIZE(ingress_filters
)-1, 1, print_attr_num
},
440 { "Egress-VLAN-Name", NULL
, 0, 0, print_attr_string
},
441 { "User-Priority-Table", NULL
, 0, 0, NULL
},
442 { "CHAP-Challenge", NULL
, 0, 0, print_attr_string
},
443 { "NAS-Port-Type", nas_port_type
, TAM_SIZE(nas_port_type
), 0, print_attr_num
},
444 { "Port-Limit", NULL
, 0, 0, print_attr_num
},
445 { "Login-LAT-Port", NULL
, 0, 0, print_attr_string
}, /*63*/
446 { "Tunnel-Type", tunnel_type
, TAM_SIZE(tunnel_type
)-1, 1, print_attr_num
},
447 { "Tunnel-Medium-Type", tunnel_medium
, TAM_SIZE(tunnel_medium
)-1, 1, print_attr_num
},
448 { "Tunnel-Client-Endpoint", NULL
, 0, 0, print_attr_string
},
449 { "Tunnel-Server-Endpoint", NULL
, 0, 0, print_attr_string
},
450 { "Acct-Tunnel-Connection", NULL
, 0, 0, print_attr_string
},
451 { "Tunnel-Password", NULL
, 0, 0, print_attr_string
},
452 { "ARAP-Password", NULL
, 0, 0, print_attr_strange
},
453 { "ARAP-Features", NULL
, 0, 0, print_attr_strange
},
454 { "ARAP-Zone-Access", arap_zone
, TAM_SIZE(arap_zone
)-1, 1, print_attr_num
}, /*72*/
455 { "ARAP-Security", NULL
, 0, 0, print_attr_string
},
456 { "ARAP-Security-Data", NULL
, 0, 0, print_attr_string
},
457 { "Password-Retry", NULL
, 0, 0, print_attr_num
},
458 { "Prompt", prompt
, TAM_SIZE(prompt
), 0, print_attr_num
},
459 { "Connect-Info", NULL
, 0, 0, print_attr_string
},
460 { "Configuration-Token", NULL
, 0, 0, print_attr_string
},
461 { "EAP-Message", NULL
, 0, 0, print_attr_string
},
462 { "Message-Authenticator", NULL
, 0, 0, print_attr_string
}, /*80*/
463 { "Tunnel-Private-Group-ID", NULL
, 0, 0, print_attr_string
},
464 { "Tunnel-Assignment-ID", NULL
, 0, 0, print_attr_string
},
465 { "Tunnel-Preference", NULL
, 0, 0, print_attr_num
},
466 { "ARAP-Challenge-Response", NULL
, 0, 0, print_attr_strange
},
467 { "Acct-Interim-Interval", NULL
, 0, 0, print_attr_num
},
468 { "Acct-Tunnel-Packets-Lost", NULL
, 0, 0, print_attr_num
}, /*86*/
469 { "NAS-Port-Id", NULL
, 0, 0, print_attr_string
},
470 { "Framed-Pool", NULL
, 0, 0, print_attr_string
},
471 { "CUI", NULL
, 0, 0, print_attr_string
},
472 { "Tunnel-Client-Auth-ID", NULL
, 0, 0, print_attr_string
},
473 { "Tunnel-Server-Auth-ID", NULL
, 0, 0, print_attr_string
},
474 { "Unassigned", NULL
, 0, 0, NULL
}, /*92*/
475 { "Unassigned", NULL
, 0, 0, NULL
} /*93*/
479 /*****************************/
480 /* Print an attribute string */
481 /* value pointed by 'data' */
482 /* and 'length' size. */
483 /*****************************/
484 /* Returns nothing. */
485 /*****************************/
487 print_attr_string(netdissect_options
*ndo
,
488 register const u_char
*data
, u_int length
, u_short attr_code
)
492 ND_TCHECK2(data
[0],length
);
499 ND_PRINT((ndo
, "%s", tstr
));
502 if (*data
&& (*data
<=0x1F) )
503 ND_PRINT((ndo
, "Tag[%u] ", *data
));
505 ND_PRINT((ndo
, "Tag[Unused] "));
508 ND_PRINT((ndo
, "Salt %u ", EXTRACT_16BITS(data
)));
512 case TUNNEL_CLIENT_END
:
513 case TUNNEL_SERVER_END
:
514 case TUNNEL_PRIV_GROUP
:
515 case TUNNEL_ASSIGN_ID
:
516 case TUNNEL_CLIENT_AUTH
:
517 case TUNNEL_SERVER_AUTH
:
522 ND_PRINT((ndo
, "%s", tstr
));
526 ND_PRINT((ndo
, "Tag[%u] ", *data
));
528 ND_PRINT((ndo
, "Tag[Unused] "));
533 case EGRESS_VLAN_NAME
:
534 ND_PRINT((ndo
, "%s (0x%02x) ",
535 tok2str(rfc4675_tagged
,"Unknown tag",*data
),
542 for (i
=0; *data
&& i
< length
; i
++, data
++)
543 ND_PRINT((ndo
, "%c", (*data
< 32 || *data
> 126) ? '.' : *data
));
548 ND_PRINT((ndo
, "%s", tstr
));
552 * print vendor specific attributes
555 print_vendor_attr(netdissect_options
*ndo
,
556 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
565 ND_TCHECK2(*data
, 4);
566 vendor_id
= EXTRACT_32BITS(data
);
570 ND_PRINT((ndo
, "Vendor: %s (%u)",
571 tok2str(smi_values
,"Unknown",vendor_id
),
574 while (length
>= 2) {
575 ND_TCHECK2(*data
, 2);
577 vendor_type
= *(data
);
578 vendor_length
= *(data
+1);
580 if (vendor_length
< 2)
582 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
587 if (vendor_length
> length
)
589 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
597 ND_TCHECK2(*data
, vendor_length
);
599 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u, Value: ",
602 for (idx
= 0; idx
< vendor_length
; idx
++, data
++)
603 ND_PRINT((ndo
, "%c", (*data
< 32 || *data
> 126) ? '.' : *data
));
604 length
-=vendor_length
;
609 ND_PRINT((ndo
, "%s", tstr
));
612 /******************************/
613 /* Print an attribute numeric */
614 /* value pointed by 'data' */
615 /* and 'length' size. */
616 /******************************/
617 /* Returns nothing. */
618 /******************************/
620 print_attr_num(netdissect_options
*ndo
,
621 register const u_char
*data
, u_int length
, u_short attr_code
)
627 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
631 ND_TCHECK2(data
[0],4);
632 /* This attribute has standard values */
633 if (attr_type
[attr_code
].siz_subtypes
)
635 static const char **table
;
637 table
= attr_type
[attr_code
].subtypes
;
639 if ( (attr_code
== TUNNEL_TYPE
) || (attr_code
== TUNNEL_MEDIUM
) )
642 ND_PRINT((ndo
, "Tag[Unused] "));
644 ND_PRINT((ndo
, "Tag[%d] ", *data
));
646 data_value
= EXTRACT_24BITS(data
);
650 data_value
= EXTRACT_32BITS(data
);
652 if ( data_value
<= (uint32_t)(attr_type
[attr_code
].siz_subtypes
- 1 +
653 attr_type
[attr_code
].first_subtype
) &&
654 data_value
>= attr_type
[attr_code
].first_subtype
)
655 ND_PRINT((ndo
, "%s", table
[data_value
]));
657 ND_PRINT((ndo
, "#%u", data_value
));
661 switch(attr_code
) /* Be aware of special cases... */
664 if (EXTRACT_32BITS( data
) == 0xFFFFFFFE )
665 ND_PRINT((ndo
, "NAS Select"));
667 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
670 case SESSION_TIMEOUT
:
673 case ACCT_SESSION_TIME
:
674 case ACCT_INT_INTERVAL
:
675 timeout
= EXTRACT_32BITS( data
);
677 ND_PRINT((ndo
, "%02d secs", timeout
));
680 if ( timeout
< 3600 )
681 ND_PRINT((ndo
, "%02d:%02d min",
682 timeout
/ 60, timeout
% 60));
684 ND_PRINT((ndo
, "%02d:%02d:%02d hours",
685 timeout
/ 3600, (timeout
% 3600) / 60,
691 if (EXTRACT_32BITS(data
) )
692 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
694 ND_PRINT((ndo
, "Unnumbered"));
697 case FRM_ATALK_NETWORK
:
698 if (EXTRACT_32BITS(data
) )
699 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
701 ND_PRINT((ndo
, "NAS assigned"));
704 case TUNNEL_PREFERENCE
:
706 ND_PRINT((ndo
, "Tag[%d] ", *data
));
708 ND_PRINT((ndo
, "Tag[Unused] "));
710 ND_PRINT((ndo
, "%d", EXTRACT_24BITS(data
)));
714 ND_PRINT((ndo
, "%s (0x%02x) ",
715 tok2str(rfc4675_tagged
,"Unknown tag",*data
),
718 ND_PRINT((ndo
, "%d", EXTRACT_24BITS(data
)));
722 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
732 ND_PRINT((ndo
, "%s", tstr
));
735 /*****************************/
736 /* Print an attribute IPv4 */
737 /* address value pointed by */
738 /* 'data' and 'length' size. */
739 /*****************************/
740 /* Returns nothing. */
741 /*****************************/
743 print_attr_address(netdissect_options
*ndo
,
744 register const u_char
*data
, u_int length
, u_short attr_code
)
748 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
752 ND_TCHECK2(data
[0],4);
758 if (EXTRACT_32BITS(data
) == 0xFFFFFFFF )
759 ND_PRINT((ndo
, "User Selected"));
761 if (EXTRACT_32BITS(data
) == 0xFFFFFFFE )
762 ND_PRINT((ndo
, "NAS Select"));
764 ND_PRINT((ndo
, "%s",ipaddr_string(ndo
, data
)));
768 ND_PRINT((ndo
, "%s", ipaddr_string(ndo
, data
)));
775 ND_PRINT((ndo
, "%s", tstr
));
778 /*************************************/
779 /* Print an attribute of 'secs since */
780 /* January 1, 1970 00:00 UTC' value */
781 /* pointed by 'data' and 'length' */
783 /*************************************/
784 /* Returns nothing. */
785 /*************************************/
787 print_attr_time(netdissect_options
*ndo
,
788 register const u_char
*data
, u_int length
, u_short attr_code _U_
)
795 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
799 ND_TCHECK2(data
[0],4);
801 attr_time
= EXTRACT_32BITS(data
);
802 strlcpy(string
, ctime(&attr_time
), sizeof(string
));
803 /* Get rid of the newline */
805 ND_PRINT((ndo
, "%.24s", string
));
809 ND_PRINT((ndo
, "%s", tstr
));
812 /***********************************/
813 /* Print an attribute of 'strange' */
814 /* data format pointed by 'data' */
815 /* and 'length' size. */
816 /***********************************/
817 /* Returns nothing. */
818 /***********************************/
820 print_attr_strange(netdissect_options
*ndo
,
821 register const u_char
*data
, u_int length
, u_short attr_code
)
830 ND_PRINT((ndo
, "ERROR: length %u != 16", length
));
833 ND_PRINT((ndo
, "User_challenge ("));
834 ND_TCHECK2(data
[0],8);
836 PRINT_HEX(len_data
, data
);
837 ND_PRINT((ndo
, ") User_resp("));
838 ND_TCHECK2(data
[0],8);
840 PRINT_HEX(len_data
, data
);
841 ND_PRINT((ndo
, ")"));
847 ND_PRINT((ndo
, "ERROR: length %u != 14", length
));
850 ND_TCHECK2(data
[0],1);
852 ND_PRINT((ndo
, "User can change password"));
854 ND_PRINT((ndo
, "User cannot change password"));
856 ND_TCHECK2(data
[0],1);
857 ND_PRINT((ndo
, ", Min password length: %d", *data
));
859 ND_PRINT((ndo
, ", created at: "));
860 ND_TCHECK2(data
[0],4);
862 PRINT_HEX(len_data
, data
);
863 ND_PRINT((ndo
, ", expires in: "));
864 ND_TCHECK2(data
[0],4);
866 PRINT_HEX(len_data
, data
);
867 ND_PRINT((ndo
, ", Current Time: "));
868 ND_TCHECK2(data
[0],4);
870 PRINT_HEX(len_data
, data
);
873 case ARAP_CHALLENGE_RESP
:
876 ND_PRINT((ndo
, "ERROR: length %u != 8", length
));
879 ND_TCHECK2(data
[0],8);
881 PRINT_HEX(len_data
, data
);
887 ND_PRINT((ndo
, "%s", tstr
));
891 radius_attrs_print(netdissect_options
*ndo
,
892 register const u_char
*attr
, u_int length
)
894 register const struct radius_attr
*rad_attr
= (const struct radius_attr
*)attr
;
895 const char *attr_string
;
901 ND_TCHECK(*rad_attr
);
903 if (rad_attr
->type
> 0 && rad_attr
->type
< TAM_SIZE(attr_type
))
904 attr_string
= attr_type
[rad_attr
->type
].name
;
906 attr_string
= "Unknown";
907 if (rad_attr
->len
< 2)
909 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
915 if (rad_attr
->len
> length
)
917 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
923 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u, Value: ",
928 if (rad_attr
->type
< TAM_SIZE(attr_type
))
930 if (rad_attr
->len
> 2)
932 if ( attr_type
[rad_attr
->type
].print_func
)
933 (*attr_type
[rad_attr
->type
].print_func
)(
934 ndo
, ((const u_char
*)(rad_attr
+1)),
935 rad_attr
->len
- 2, rad_attr
->type
);
938 /* do we also want to see a hex dump ? */
939 if (ndo
->ndo_vflag
> 1)
940 print_unknown_data(ndo
, (const u_char
*)rad_attr
+2, "\n\t ", (rad_attr
->len
)-2);
942 length
-=(rad_attr
->len
);
943 rad_attr
= (const struct radius_attr
*)( ((const char *)(rad_attr
))+rad_attr
->len
);
948 ND_PRINT((ndo
, "%s", tstr
));
952 radius_print(netdissect_options
*ndo
,
953 const u_char
*dat
, u_int length
)
955 register const struct radius_hdr
*rad
;
958 ND_TCHECK2(*dat
, MIN_RADIUS_LEN
);
959 rad
= (const struct radius_hdr
*)dat
;
960 len
= EXTRACT_16BITS(&rad
->len
);
962 if (len
< MIN_RADIUS_LEN
)
964 ND_PRINT((ndo
, "%s", tstr
));
971 if (ndo
->ndo_vflag
< 1) {
972 ND_PRINT((ndo
, "RADIUS, %s (%u), id: 0x%02x length: %u",
973 tok2str(radius_command_values
,"Unknown Command",rad
->code
),
980 ND_PRINT((ndo
, "RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
982 tok2str(radius_command_values
,"Unknown Command",rad
->code
),
986 for(auth_idx
=0; auth_idx
< 16; auth_idx
++)
987 ND_PRINT((ndo
, "%02x", rad
->auth
[auth_idx
]));
990 if (len
> MIN_RADIUS_LEN
)
991 radius_attrs_print(ndo
, dat
+ MIN_RADIUS_LEN
, len
- MIN_RADIUS_LEN
);
995 ND_PRINT((ndo
, "%s", tstr
));