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 * Radius printer routines as specified on:
26 * "Remote Authentication Dial In User Service (RADIUS)"
32 * "RADIUS Accounting Modifications for Tunnel Protocol Support"
35 * "RADIUS Attributes for Tunnel Protocol Support"
41 * "RADIUS Attributes for Virtual LAN and Priority Support"
44 * "Dynamic Authorization Extensions to RADIUS"
46 * Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
48 * TODO: Among other things to print ok MacIntosh and Vendor values
51 #define NETDISSECT_REWORKED
56 #include <tcpdump-stdinc.h>
60 #include "interface.h"
61 #include "addrtoname.h"
65 static const char tstr
[] = " [|radius]";
67 #define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
69 #define PRINT_HEX(bytes_len, ptr_data) \
72 ND_PRINT((ndo, "%02X", *ptr_data )); \
78 /* Radius packet codes */
79 #define RADCMD_ACCESS_REQ 1 /* Access-Request */
80 #define RADCMD_ACCESS_ACC 2 /* Access-Accept */
81 #define RADCMD_ACCESS_REJ 3 /* Access-Reject */
82 #define RADCMD_ACCOUN_REQ 4 /* Accounting-Request */
83 #define RADCMD_ACCOUN_RES 5 /* Accounting-Response */
84 #define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
85 #define RADCMD_STATUS_SER 12 /* Status-Server */
86 #define RADCMD_STATUS_CLI 13 /* Status-Client */
87 #define RADCMD_DISCON_REQ 40 /* Disconnect-Request */
88 #define RADCMD_DISCON_ACK 41 /* Disconnect-ACK */
89 #define RADCMD_DISCON_NAK 42 /* Disconnect-NAK */
90 #define RADCMD_COA_REQ 43 /* CoA-Request */
91 #define RADCMD_COA_ACK 44 /* CoA-ACK */
92 #define RADCMD_COA_NAK 45 /* CoA-NAK */
93 #define RADCMD_RESERVED 255 /* Reserved */
95 static const struct tok radius_command_values
[] = {
96 { RADCMD_ACCESS_REQ
, "Access-Request" },
97 { RADCMD_ACCESS_ACC
, "Access-Accept" },
98 { RADCMD_ACCESS_REJ
, "Access-Reject" },
99 { RADCMD_ACCOUN_REQ
, "Accounting-Request" },
100 { RADCMD_ACCOUN_RES
, "Accounting-Response" },
101 { RADCMD_ACCESS_CHA
, "Access-Challenge" },
102 { RADCMD_STATUS_SER
, "Status-Server" },
103 { RADCMD_STATUS_CLI
, "Status-Client" },
104 { RADCMD_DISCON_REQ
, "Disconnect-Request" },
105 { RADCMD_DISCON_ACK
, "Disconnect-ACK" },
106 { RADCMD_DISCON_NAK
, "Disconnect-NAK" },
107 { RADCMD_COA_REQ
, "CoA-Request" },
108 { RADCMD_COA_ACK
, "CoA-ACK" },
109 { RADCMD_COA_NAK
, "CoA-NAK" },
110 { RADCMD_RESERVED
, "Reserved" },
114 /********************************/
115 /* Begin Radius Attribute types */
116 /********************************/
119 #define LOG_IPHOST 14
120 #define LOG_SERVICE 15
122 #define SESSION_TIMEOUT 27
123 #define IDLE_TIMEOUT 28
124 #define FRM_ATALK_LINK 37
125 #define FRM_ATALK_NETWORK 38
127 #define ACCT_DELAY 41
128 #define ACCT_SESSION_TIME 46
130 #define EGRESS_VLAN_ID 56
131 #define EGRESS_VLAN_NAME 58
133 #define TUNNEL_TYPE 64
134 #define TUNNEL_MEDIUM 65
135 #define TUNNEL_CLIENT_END 66
136 #define TUNNEL_SERVER_END 67
137 #define TUNNEL_PASS 69
140 #define ARAP_FEATURES 71
142 #define TUNNEL_PRIV_GROUP 81
143 #define TUNNEL_ASSIGN_ID 82
144 #define TUNNEL_PREFERENCE 83
146 #define ARAP_CHALLENGE_RESP 84
147 #define ACCT_INT_INTERVAL 85
149 #define TUNNEL_CLIENT_AUTH 90
150 #define TUNNEL_SERVER_AUTH 91
151 /********************************/
152 /* End Radius Attribute types */
153 /********************************/
155 #define RFC4675_TAGGED 0x31
156 #define RFC4675_UNTAGGED 0x32
158 static const struct tok rfc4675_tagged
[] = {
159 { RFC4675_TAGGED
, "Tagged" },
160 { RFC4675_UNTAGGED
, "Untagged" },
165 static void print_attr_string(netdissect_options
*, register u_char
*, u_int
, u_short
);
166 static void print_attr_num(netdissect_options
*, register u_char
*, u_int
, u_short
);
167 static void print_vendor_attr(netdissect_options
*, register u_char
*, u_int
, u_short
);
168 static void print_attr_address(netdissect_options
*, register u_char
*, u_int
, u_short
);
169 static void print_attr_time(netdissect_options
*, register u_char
*, u_int
, u_short
);
170 static void print_attr_strange(netdissect_options
*, register u_char
*, u_int
, u_short
);
173 struct radius_hdr
{ uint8_t code
; /* Radius packet code */
174 uint8_t id
; /* Radius packet id */
175 uint16_t len
; /* Radius total length */
176 uint8_t auth
[16]; /* Authenticator */
179 #define MIN_RADIUS_LEN 20
181 struct radius_attr
{ uint8_t type
; /* Attribute type */
182 uint8_t len
; /* Attribute length */
186 /* Service-Type Attribute standard values */
187 static const char *serv_type
[]={ NULL
,
196 "Callback NAS Prompt",
198 "Callback Administrative",
201 /* Framed-Protocol Attribute standard values */
202 static const char *frm_proto
[]={ NULL
,
206 "Gandalf proprietary",
211 /* Framed-Routing Attribute standard values */
212 static const char *frm_routing
[]={ "None",
218 /* Framed-Compression Attribute standard values */
219 static const char *frm_comp
[]={ "None",
225 /* Login-Service Attribute standard values */
226 static const char *login_serv
[]={ "Telnet",
229 "PortMaster(proprietary)",
238 /* Termination-Action Attribute standard values */
239 static const char *term_action
[]={ "Default",
243 /* Ingress-Filters Attribute standard values */
244 static const char *ingress_filters
[]={ NULL
,
249 /* NAS-Port-Type Attribute standard values */
250 static const char *nas_port_type
[]={ "Async",
257 "HDLC Clear Channel",
269 "Wireless - IEEE 802.11",
272 /* Acct-Status-Type Accounting Attribute standard values */
273 static const char *acct_status
[]={ NULL
,
287 "Tunnel-Link-Reject",
291 /* Acct-Authentic Accounting Attribute standard values */
292 static const char *acct_auth
[]={ NULL
,
298 /* Acct-Terminate-Cause Accounting Attribute standard values */
299 static const char *acct_term
[]={ NULL
,
314 "Service Unavailable",
320 /* Tunnel-Type Attribute standard values */
321 static const char *tunnel_type
[]={ NULL
,
333 "IP-in-IP Tunneling",
336 /* Tunnel-Medium-Type Attribute standard values */
337 static const char *tunnel_medium
[]={ NULL
,
352 "E.164 with NSAP subaddress",
355 /* ARAP-Zone-Access Attribute standard values */
356 static const char *arap_zone
[]={ NULL
,
357 "Only access to dfl zone",
358 "Use zone filter inc.",
360 "Use zone filter exc.",
363 static const char *prompt
[]={ "No Echo",
368 struct attrtype
{ const char *name
; /* Attribute name */
369 const char **subtypes
; /* Standard Values (if any) */
370 u_char siz_subtypes
; /* Size of total standard values */
371 u_char first_subtype
; /* First standard value is 0 or 1 */
372 void (*print_func
)(netdissect_options
*, register u_char
*, u_int
, u_short
);
375 { NULL
, NULL
, 0, 0, NULL
},
376 { "User-Name", NULL
, 0, 0, print_attr_string
},
377 { "User-Password", NULL
, 0, 0, NULL
},
378 { "CHAP-Password", NULL
, 0, 0, NULL
},
379 { "NAS-IP-Address", NULL
, 0, 0, print_attr_address
},
380 { "NAS-Port", NULL
, 0, 0, print_attr_num
},
381 { "Service-Type", serv_type
, TAM_SIZE(serv_type
)-1, 1, print_attr_num
},
382 { "Framed-Protocol", frm_proto
, TAM_SIZE(frm_proto
)-1, 1, print_attr_num
},
383 { "Framed-IP-Address", NULL
, 0, 0, print_attr_address
},
384 { "Framed-IP-Netmask", NULL
, 0, 0, print_attr_address
},
385 { "Framed-Routing", frm_routing
, TAM_SIZE(frm_routing
), 0, print_attr_num
},
386 { "Filter-Id", NULL
, 0, 0, print_attr_string
},
387 { "Framed-MTU", NULL
, 0, 0, print_attr_num
},
388 { "Framed-Compression", frm_comp
, TAM_SIZE(frm_comp
), 0, print_attr_num
},
389 { "Login-IP-Host", NULL
, 0, 0, print_attr_address
},
390 { "Login-Service", login_serv
, TAM_SIZE(login_serv
), 0, print_attr_num
},
391 { "Login-TCP-Port", NULL
, 0, 0, print_attr_num
},
392 { "Unassigned", NULL
, 0, 0, NULL
}, /*17*/
393 { "Reply-Message", NULL
, 0, 0, print_attr_string
},
394 { "Callback-Number", NULL
, 0, 0, print_attr_string
},
395 { "Callback-Id", NULL
, 0, 0, print_attr_string
},
396 { "Unassigned", NULL
, 0, 0, NULL
}, /*21*/
397 { "Framed-Route", NULL
, 0, 0, print_attr_string
},
398 { "Framed-IPX-Network", NULL
, 0, 0, print_attr_num
},
399 { "State", NULL
, 0, 0, print_attr_string
},
400 { "Class", NULL
, 0, 0, print_attr_string
},
401 { "Vendor-Specific", NULL
, 0, 0, print_vendor_attr
},
402 { "Session-Timeout", NULL
, 0, 0, print_attr_num
},
403 { "Idle-Timeout", NULL
, 0, 0, print_attr_num
},
404 { "Termination-Action", term_action
, TAM_SIZE(term_action
), 0, print_attr_num
},
405 { "Called-Station-Id", NULL
, 0, 0, print_attr_string
},
406 { "Calling-Station-Id", NULL
, 0, 0, print_attr_string
},
407 { "NAS-Identifier", NULL
, 0, 0, print_attr_string
},
408 { "Proxy-State", NULL
, 0, 0, print_attr_string
},
409 { "Login-LAT-Service", NULL
, 0, 0, print_attr_string
},
410 { "Login-LAT-Node", NULL
, 0, 0, print_attr_string
},
411 { "Login-LAT-Group", NULL
, 0, 0, print_attr_string
},
412 { "Framed-AppleTalk-Link", NULL
, 0, 0, print_attr_num
},
413 { "Framed-AppleTalk-Network", NULL
, 0, 0, print_attr_num
},
414 { "Framed-AppleTalk-Zone", NULL
, 0, 0, print_attr_string
},
415 { "Acct-Status-Type", acct_status
, TAM_SIZE(acct_status
)-1, 1, print_attr_num
},
416 { "Acct-Delay-Time", NULL
, 0, 0, print_attr_num
},
417 { "Acct-Input-Octets", NULL
, 0, 0, print_attr_num
},
418 { "Acct-Output-Octets", NULL
, 0, 0, print_attr_num
},
419 { "Acct-Session-Id", NULL
, 0, 0, print_attr_string
},
420 { "Acct-Authentic", acct_auth
, TAM_SIZE(acct_auth
)-1, 1, print_attr_num
},
421 { "Acct-Session-Time", NULL
, 0, 0, print_attr_num
},
422 { "Acct-Input-Packets", NULL
, 0, 0, print_attr_num
},
423 { "Acct-Output-Packets", NULL
, 0, 0, print_attr_num
},
424 { "Acct-Terminate-Cause", acct_term
, TAM_SIZE(acct_term
)-1, 1, print_attr_num
},
425 { "Acct-Multi-Session-Id", NULL
, 0, 0, print_attr_string
},
426 { "Acct-Link-Count", NULL
, 0, 0, print_attr_num
},
427 { "Acct-Input-Gigawords", NULL
, 0, 0, print_attr_num
},
428 { "Acct-Output-Gigawords", NULL
, 0, 0, print_attr_num
},
429 { "Unassigned", NULL
, 0, 0, NULL
}, /*54*/
430 { "Event-Timestamp", NULL
, 0, 0, print_attr_time
},
431 { "Egress-VLANID", NULL
, 0, 0, print_attr_num
},
432 { "Ingress-Filters", ingress_filters
, TAM_SIZE(ingress_filters
)-1, 1, print_attr_num
},
433 { "Egress-VLAN-Name", NULL
, 0, 0, print_attr_string
},
434 { "User-Priority-Table", NULL
, 0, 0, NULL
},
435 { "CHAP-Challenge", NULL
, 0, 0, print_attr_string
},
436 { "NAS-Port-Type", nas_port_type
, TAM_SIZE(nas_port_type
), 0, print_attr_num
},
437 { "Port-Limit", NULL
, 0, 0, print_attr_num
},
438 { "Login-LAT-Port", NULL
, 0, 0, print_attr_string
}, /*63*/
439 { "Tunnel-Type", tunnel_type
, TAM_SIZE(tunnel_type
)-1, 1, print_attr_num
},
440 { "Tunnel-Medium-Type", tunnel_medium
, TAM_SIZE(tunnel_medium
)-1, 1, print_attr_num
},
441 { "Tunnel-Client-Endpoint", NULL
, 0, 0, print_attr_string
},
442 { "Tunnel-Server-Endpoint", NULL
, 0, 0, print_attr_string
},
443 { "Acct-Tunnel-Connection", NULL
, 0, 0, print_attr_string
},
444 { "Tunnel-Password", NULL
, 0, 0, print_attr_string
},
445 { "ARAP-Password", NULL
, 0, 0, print_attr_strange
},
446 { "ARAP-Features", NULL
, 0, 0, print_attr_strange
},
447 { "ARAP-Zone-Access", arap_zone
, TAM_SIZE(arap_zone
)-1, 1, print_attr_num
}, /*72*/
448 { "ARAP-Security", NULL
, 0, 0, print_attr_string
},
449 { "ARAP-Security-Data", NULL
, 0, 0, print_attr_string
},
450 { "Password-Retry", NULL
, 0, 0, print_attr_num
},
451 { "Prompt", prompt
, TAM_SIZE(prompt
), 0, print_attr_num
},
452 { "Connect-Info", NULL
, 0, 0, print_attr_string
},
453 { "Configuration-Token", NULL
, 0, 0, print_attr_string
},
454 { "EAP-Message", NULL
, 0, 0, print_attr_string
},
455 { "Message-Authenticator", NULL
, 0, 0, print_attr_string
}, /*80*/
456 { "Tunnel-Private-Group-ID", NULL
, 0, 0, print_attr_string
},
457 { "Tunnel-Assignment-ID", NULL
, 0, 0, print_attr_string
},
458 { "Tunnel-Preference", NULL
, 0, 0, print_attr_num
},
459 { "ARAP-Challenge-Response", NULL
, 0, 0, print_attr_strange
},
460 { "Acct-Interim-Interval", NULL
, 0, 0, print_attr_num
},
461 { "Acct-Tunnel-Packets-Lost", NULL
, 0, 0, print_attr_num
}, /*86*/
462 { "NAS-Port-Id", NULL
, 0, 0, print_attr_string
},
463 { "Framed-Pool", NULL
, 0, 0, print_attr_string
},
464 { "CUI", NULL
, 0, 0, print_attr_string
},
465 { "Tunnel-Client-Auth-ID", NULL
, 0, 0, print_attr_string
},
466 { "Tunnel-Server-Auth-ID", NULL
, 0, 0, print_attr_string
},
467 { "Unassigned", NULL
, 0, 0, NULL
}, /*92*/
468 { "Unassigned", NULL
, 0, 0, NULL
} /*93*/
472 /*****************************/
473 /* Print an attribute string */
474 /* value pointed by 'data' */
475 /* and 'length' size. */
476 /*****************************/
477 /* Returns nothing. */
478 /*****************************/
480 print_attr_string(netdissect_options
*ndo
,
481 register u_char
*data
, u_int length
, u_short attr_code
)
485 ND_TCHECK2(data
[0],length
);
492 ND_PRINT((ndo
, "%s", tstr
));
495 if (*data
&& (*data
<=0x1F) )
496 ND_PRINT((ndo
, "Tag[%u] ", *data
));
498 ND_PRINT((ndo
, "Tag[Unused] "));
501 ND_PRINT((ndo
, "Salt %u ", EXTRACT_16BITS(data
)));
505 case TUNNEL_CLIENT_END
:
506 case TUNNEL_SERVER_END
:
507 case TUNNEL_PRIV_GROUP
:
508 case TUNNEL_ASSIGN_ID
:
509 case TUNNEL_CLIENT_AUTH
:
510 case TUNNEL_SERVER_AUTH
:
515 ND_PRINT((ndo
, "%s", tstr
));
519 ND_PRINT((ndo
, "Tag[%u] ", *data
));
521 ND_PRINT((ndo
, "Tag[Unused] "));
526 case EGRESS_VLAN_NAME
:
527 ND_PRINT((ndo
, "%s (0x%02x) ",
528 tok2str(rfc4675_tagged
,"Unknown tag",*data
),
535 for (i
=0; *data
&& i
< length
; i
++, data
++)
536 ND_PRINT((ndo
, "%c", (*data
< 32 || *data
> 128) ? '.' : *data
));
541 ND_PRINT((ndo
, "%s", tstr
));
545 * print vendor specific attributes
548 print_vendor_attr(netdissect_options
*ndo
,
549 register u_char
*data
, u_int length
, u_short attr_code _U_
)
558 ND_TCHECK2(*data
, 4);
559 vendor_id
= EXTRACT_32BITS(data
);
563 ND_PRINT((ndo
, "Vendor: %s (%u)",
564 tok2str(smi_values
,"Unknown",vendor_id
),
567 while (length
>= 2) {
568 ND_TCHECK2(*data
, 2);
570 vendor_type
= *(data
);
571 vendor_length
= *(data
+1);
573 if (vendor_length
< 2)
575 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
580 if (vendor_length
> length
)
582 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
590 ND_TCHECK2(*data
, vendor_length
);
592 ND_PRINT((ndo
, "\n\t Vendor Attribute: %u, Length: %u, Value: ",
595 for (idx
= 0; idx
< vendor_length
; idx
++, data
++)
596 ND_PRINT((ndo
, "%c", (*data
< 32 || *data
> 128) ? '.' : *data
));
597 length
-=vendor_length
;
602 ND_PRINT((ndo
, "%s", tstr
));
605 /******************************/
606 /* Print an attribute numeric */
607 /* value pointed by 'data' */
608 /* and 'length' size. */
609 /******************************/
610 /* Returns nothing. */
611 /******************************/
613 print_attr_num(netdissect_options
*ndo
,
614 register u_char
*data
, u_int length
, u_short attr_code
)
620 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
624 ND_TCHECK2(data
[0],4);
625 /* This attribute has standard values */
626 if (attr_type
[attr_code
].siz_subtypes
)
628 static const char **table
;
630 table
= attr_type
[attr_code
].subtypes
;
632 if ( (attr_code
== TUNNEL_TYPE
) || (attr_code
== TUNNEL_MEDIUM
) )
635 ND_PRINT((ndo
, "Tag[Unused] "));
637 ND_PRINT((ndo
, "Tag[%d] ", *data
));
639 data_value
= EXTRACT_24BITS(data
);
643 data_value
= EXTRACT_32BITS(data
);
645 if ( data_value
<= (uint32_t)(attr_type
[attr_code
].siz_subtypes
- 1 +
646 attr_type
[attr_code
].first_subtype
) &&
647 data_value
>= attr_type
[attr_code
].first_subtype
)
648 ND_PRINT((ndo
, "%s", table
[data_value
]));
650 ND_PRINT((ndo
, "#%u", data_value
));
654 switch(attr_code
) /* Be aware of special cases... */
657 if (EXTRACT_32BITS( data
) == 0xFFFFFFFE )
658 ND_PRINT((ndo
, "NAS Select"));
660 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
663 case SESSION_TIMEOUT
:
666 case ACCT_SESSION_TIME
:
667 case ACCT_INT_INTERVAL
:
668 timeout
= EXTRACT_32BITS( data
);
670 ND_PRINT((ndo
, "%02d secs", timeout
));
673 if ( timeout
< 3600 )
674 ND_PRINT((ndo
, "%02d:%02d min",
675 timeout
/ 60, timeout
% 60));
677 ND_PRINT((ndo
, "%02d:%02d:%02d hours",
678 timeout
/ 3600, (timeout
% 3600) / 60,
684 if (EXTRACT_32BITS(data
) )
685 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
687 ND_PRINT((ndo
, "Unnumbered"));
690 case FRM_ATALK_NETWORK
:
691 if (EXTRACT_32BITS(data
) )
692 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
694 ND_PRINT((ndo
, "NAS assigned"));
697 case TUNNEL_PREFERENCE
:
699 ND_PRINT((ndo
, "Tag[%d] ", *data
));
701 ND_PRINT((ndo
, "Tag[Unused] "));
703 ND_PRINT((ndo
, "%d", EXTRACT_24BITS(data
)));
707 ND_PRINT((ndo
, "%s (0x%02x) ",
708 tok2str(rfc4675_tagged
,"Unknown tag",*data
),
711 ND_PRINT((ndo
, "%d", EXTRACT_24BITS(data
)));
715 ND_PRINT((ndo
, "%d", EXTRACT_32BITS(data
)));
725 ND_PRINT((ndo
, "%s", tstr
));
728 /*****************************/
729 /* Print an attribute IPv4 */
730 /* address value pointed by */
731 /* 'data' and 'length' size. */
732 /*****************************/
733 /* Returns nothing. */
734 /*****************************/
736 print_attr_address(netdissect_options
*ndo
,
737 register u_char
*data
, u_int length
, u_short attr_code
)
741 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
745 ND_TCHECK2(data
[0],4);
751 if (EXTRACT_32BITS(data
) == 0xFFFFFFFF )
752 ND_PRINT((ndo
, "User Selected"));
754 if (EXTRACT_32BITS(data
) == 0xFFFFFFFE )
755 ND_PRINT((ndo
, "NAS Select"));
757 ND_PRINT((ndo
, "%s",ipaddr_string(ndo
, data
)));
761 ND_PRINT((ndo
, "%s", ipaddr_string(ndo
, data
)));
768 ND_PRINT((ndo
, "%s", tstr
));
771 /*************************************/
772 /* Print an attribute of 'secs since */
773 /* January 1, 1970 00:00 UTC' value */
774 /* pointed by 'data' and 'length' */
776 /*************************************/
777 /* Returns nothing. */
778 /*************************************/
780 print_attr_time(netdissect_options
*ndo
,
781 register u_char
*data
, u_int length
, u_short attr_code _U_
)
789 ND_PRINT((ndo
, "ERROR: length %u != 4", length
));
793 ND_TCHECK2(data
[0],4);
795 attr_time
= EXTRACT_32BITS(data
);
796 if ((p
= ctime(&attr_time
)) == NULL
)
798 strlcpy(string
, p
, sizeof(string
));
799 /* Get rid of the newline */
801 ND_PRINT((ndo
, "%.24s", string
));
805 ND_PRINT((ndo
, "%s", tstr
));
808 /***********************************/
809 /* Print an attribute of 'strange' */
810 /* data format pointed by 'data' */
811 /* and 'length' size. */
812 /***********************************/
813 /* Returns nothing. */
814 /***********************************/
816 print_attr_strange(netdissect_options
*ndo
,
817 register u_char
*data
, u_int length
, u_short attr_code
)
826 ND_PRINT((ndo
, "ERROR: length %u != 16", length
));
829 ND_PRINT((ndo
, "User_challenge ("));
830 ND_TCHECK2(data
[0],8);
832 PRINT_HEX(len_data
, data
);
833 ND_PRINT((ndo
, ") User_resp("));
834 ND_TCHECK2(data
[0],8);
836 PRINT_HEX(len_data
, data
);
837 ND_PRINT((ndo
, ")"));
843 ND_PRINT((ndo
, "ERROR: length %u != 14", length
));
846 ND_TCHECK2(data
[0],1);
848 ND_PRINT((ndo
, "User can change password"));
850 ND_PRINT((ndo
, "User cannot change password"));
852 ND_TCHECK2(data
[0],1);
853 ND_PRINT((ndo
, ", Min password length: %d", *data
));
855 ND_PRINT((ndo
, ", created at: "));
856 ND_TCHECK2(data
[0],4);
858 PRINT_HEX(len_data
, data
);
859 ND_PRINT((ndo
, ", expires in: "));
860 ND_TCHECK2(data
[0],4);
862 PRINT_HEX(len_data
, data
);
863 ND_PRINT((ndo
, ", Current Time: "));
864 ND_TCHECK2(data
[0],4);
866 PRINT_HEX(len_data
, data
);
869 case ARAP_CHALLENGE_RESP
:
872 ND_PRINT((ndo
, "ERROR: length %u != 8", length
));
875 ND_TCHECK2(data
[0],8);
877 PRINT_HEX(len_data
, data
);
883 ND_PRINT((ndo
, "%s", tstr
));
887 radius_attrs_print(netdissect_options
*ndo
,
888 register const u_char
*attr
, u_int length
)
890 register const struct radius_attr
*rad_attr
= (struct radius_attr
*)attr
;
891 const char *attr_string
;
897 ND_TCHECK(*rad_attr
);
899 if (rad_attr
->type
> 0 && rad_attr
->type
< TAM_SIZE(attr_type
))
900 attr_string
= attr_type
[rad_attr
->type
].name
;
902 attr_string
= "Unknown";
903 if (rad_attr
->len
< 2)
905 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
911 if (rad_attr
->len
> length
)
913 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
919 ND_PRINT((ndo
, "\n\t %s Attribute (%u), length: %u, Value: ",
924 if (rad_attr
->type
< TAM_SIZE(attr_type
))
926 if (rad_attr
->len
> 2)
928 if ( attr_type
[rad_attr
->type
].print_func
)
929 (*attr_type
[rad_attr
->type
].print_func
)(
930 ndo
, ((u_char
*)(rad_attr
+1)),
931 rad_attr
->len
- 2, rad_attr
->type
);
934 /* do we also want to see a hex dump ? */
935 if (ndo
->ndo_vflag
> 1)
936 print_unknown_data(ndo
, (u_char
*)rad_attr
+2, "\n\t ", (rad_attr
->len
)-2);
938 length
-=(rad_attr
->len
);
939 rad_attr
= (struct radius_attr
*)( ((char *)(rad_attr
))+rad_attr
->len
);
944 ND_PRINT((ndo
, "%s", tstr
));
948 radius_print(netdissect_options
*ndo
,
949 const u_char
*dat
, u_int length
)
951 register const struct radius_hdr
*rad
;
954 ND_TCHECK2(*dat
, MIN_RADIUS_LEN
);
955 rad
= (struct radius_hdr
*)dat
;
956 len
= EXTRACT_16BITS(&rad
->len
);
958 if (len
< MIN_RADIUS_LEN
)
960 ND_PRINT((ndo
, "%s", tstr
));
967 if (ndo
->ndo_vflag
< 1) {
968 ND_PRINT((ndo
, "RADIUS, %s (%u), id: 0x%02x length: %u",
969 tok2str(radius_command_values
,"Unknown Command",rad
->code
),
976 ND_PRINT((ndo
, "RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
978 tok2str(radius_command_values
,"Unknown Command",rad
->code
),
982 for(auth_idx
=0; auth_idx
< 16; auth_idx
++)
983 ND_PRINT((ndo
, "%02x", rad
->auth
[auth_idx
]));
986 if (len
> MIN_RADIUS_LEN
)
987 radius_attrs_print(ndo
, dat
+ MIN_RADIUS_LEN
, len
- MIN_RADIUS_LEN
);
991 ND_PRINT((ndo
, "%s", tstr
));