2001-10-22 14:58:33 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 Alfredo Andres Omella. All rights reserved.
|
2002-06-12 01:08:37 +08:00
|
|
|
*
|
2001-10-22 14:58:33 +08:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
2002-06-12 01:08:37 +08:00
|
|
|
*
|
2001-10-22 14:58:33 +08:00
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. The names of the authors may not be used to endorse or promote
|
|
|
|
* products derived from this software without specific prior
|
|
|
|
* written permission.
|
2002-06-12 01:08:37 +08:00
|
|
|
*
|
2001-10-22 14:58:33 +08:00
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
2000-10-06 14:49:20 +08:00
|
|
|
/*
|
|
|
|
* Radius printer routines as specified on:
|
|
|
|
*
|
|
|
|
* RFC 2865:
|
|
|
|
* "Remote Authentication Dial In User Service (RADIUS)"
|
|
|
|
*
|
|
|
|
* RFC 2866:
|
|
|
|
* "RADIUS Accounting"
|
|
|
|
*
|
|
|
|
* RFC 2867:
|
|
|
|
* "RADIUS Accounting Modifications for Tunnel Protocol Support"
|
|
|
|
*
|
|
|
|
* RFC 2868:
|
|
|
|
* "RADIUS Attributes for Tunnel Protocol Support"
|
|
|
|
*
|
|
|
|
* RFC 2869:
|
|
|
|
* "RADIUS Extensions"
|
|
|
|
*
|
2000-12-18 16:16:58 +08:00
|
|
|
* Alfredo Andres Omella (aandres@s21sec.com) v0.1 2000/09/15
|
2000-10-06 14:49:20 +08:00
|
|
|
*
|
2002-06-12 01:08:37 +08:00
|
|
|
* TODO: Among other things to print ok MacIntosh and Vendor values
|
2000-10-06 14:49:20 +08:00
|
|
|
*/
|
|
|
|
|
2003-11-16 17:36:07 +08:00
|
|
|
#ifndef lint
|
|
|
|
static const char rcsid[] _U_ =
|
2005-09-26 09:01:55 +08:00
|
|
|
"$Id: print-radius.c,v 1.28 2005-09-26 01:01:55 guy Exp $";
|
2003-11-16 17:36:07 +08:00
|
|
|
#endif
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2002-08-01 16:52:55 +08:00
|
|
|
#include <tcpdump-stdinc.h>
|
2000-10-06 14:49:20 +08:00
|
|
|
|
2002-08-01 16:52:55 +08:00
|
|
|
#include <string.h>
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "interface.h"
|
|
|
|
#include "addrtoname.h"
|
|
|
|
#include "extract.h"
|
2003-11-26 16:49:14 +08:00
|
|
|
#include "oui.h"
|
2000-10-06 14:49:20 +08:00
|
|
|
|
2000-10-08 16:48:48 +08:00
|
|
|
#define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
#define PRINT_HEX(bytes_len, ptr_data) \
|
|
|
|
while(bytes_len) \
|
|
|
|
{ \
|
2000-10-08 16:48:48 +08:00
|
|
|
printf("%02X", *ptr_data ); \
|
2000-10-06 14:49:20 +08:00
|
|
|
ptr_data++; \
|
|
|
|
bytes_len--; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Radius packet codes */
|
|
|
|
#define RADCMD_ACCESS_REQ 1 /* Access-Request */
|
|
|
|
#define RADCMD_ACCESS_ACC 2 /* Access-Accept */
|
|
|
|
#define RADCMD_ACCESS_REJ 3 /* Access-Reject */
|
|
|
|
#define RADCMD_ACCOUN_REQ 4 /* Accounting-Request */
|
|
|
|
#define RADCMD_ACCOUN_RES 5 /* Accounting-Response */
|
|
|
|
#define RADCMD_ACCESS_CHA 11 /* Access-Challenge */
|
|
|
|
#define RADCMD_STATUS_SER 12 /* Status-Server */
|
|
|
|
#define RADCMD_STATUS_CLI 13 /* Status-Client */
|
|
|
|
#define RADCMD_RESERVED 255 /* Reserved */
|
|
|
|
|
2003-11-26 16:49:14 +08:00
|
|
|
static struct tok radius_command_values[] = {
|
|
|
|
{ RADCMD_ACCESS_REQ, "Access Request" },
|
|
|
|
{ RADCMD_ACCESS_ACC, "Access Accept" },
|
|
|
|
{ RADCMD_ACCESS_REJ, "Access Reject" },
|
|
|
|
{ RADCMD_ACCOUN_REQ, "Accounting Request" },
|
|
|
|
{ RADCMD_ACCOUN_RES, "Accounting Response" },
|
|
|
|
{ RADCMD_ACCESS_CHA, "Access Challenge" },
|
|
|
|
{ RADCMD_STATUS_SER, "Status Server" },
|
|
|
|
{ RADCMD_STATUS_CLI, "Status Client" },
|
|
|
|
{ RADCMD_RESERVED, "Reserved" },
|
|
|
|
{ 0, NULL}
|
|
|
|
};
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
/********************************/
|
|
|
|
/* Begin Radius Attribute types */
|
|
|
|
/********************************/
|
|
|
|
#define SERV_TYPE 6
|
|
|
|
#define FRM_IPADDR 8
|
|
|
|
#define LOG_IPHOST 14
|
|
|
|
#define LOG_SERVICE 15
|
|
|
|
#define FRM_IPX 23
|
|
|
|
#define SESSION_TIMEOUT 27
|
|
|
|
#define IDLE_TIMEOUT 28
|
|
|
|
#define FRM_ATALK_LINK 37
|
|
|
|
#define FRM_ATALK_NETWORK 38
|
|
|
|
|
|
|
|
#define ACCT_DELAY 41
|
|
|
|
#define ACCT_SESSION_TIME 46
|
|
|
|
|
|
|
|
#define TUNNEL_TYPE 64
|
|
|
|
#define TUNNEL_MEDIUM 65
|
|
|
|
#define TUNNEL_CLIENT_END 66
|
|
|
|
#define TUNNEL_SERVER_END 67
|
|
|
|
#define TUNNEL_PASS 69
|
|
|
|
|
|
|
|
#define ARAP_PASS 70
|
|
|
|
#define ARAP_FEATURES 71
|
|
|
|
|
|
|
|
#define TUNNEL_PRIV_GROUP 81
|
|
|
|
#define TUNNEL_ASSIGN_ID 82
|
|
|
|
#define TUNNEL_PREFERENCE 83
|
|
|
|
|
|
|
|
#define ARAP_CHALLENGE_RESP 84
|
|
|
|
#define ACCT_INT_INTERVAL 85
|
|
|
|
|
|
|
|
#define TUNNEL_CLIENT_AUTH 90
|
|
|
|
#define TUNNEL_SERVER_AUTH 91
|
|
|
|
/********************************/
|
|
|
|
/* End Radius Attribute types */
|
|
|
|
/********************************/
|
|
|
|
|
|
|
|
|
|
|
|
static void print_attr_string(register u_char *, u_int, u_short );
|
|
|
|
static void print_attr_num(register u_char *, u_int, u_short );
|
2003-11-26 16:49:14 +08:00
|
|
|
static void print_vendor_attr(register u_char *, u_int, u_short );
|
2000-10-06 14:49:20 +08:00
|
|
|
static void print_attr_address(register u_char *, u_int, u_short);
|
|
|
|
static void print_attr_time(register u_char *, u_int, u_short);
|
|
|
|
static void print_attr_strange(register u_char *, u_int, u_short);
|
|
|
|
|
|
|
|
|
Get rid of some includes, and use "u_int8_t" and "u_int16_t" in packet
layout definitions, as per Alfredo Andrs's suggestion.
Don't use expressions with side effects inside EXTRACT macros - the
arguments of those macros are used more than once, so the side-effects
(incrementing the pointer) occurs more than once, and they occur in a
sequence that may not be the same for all compilers.
When printing a UNIX time value, extract the value into a "time_t"
variable, and then pass a pointer to that variable to "ctime()", don't
cast the result of "EXTRACT_32BITS()" to a pointer. Also, when printing
the result of "ctime()", print only the first 24 characters, so that the
newline at the end isn't printed.
Cast the first argument passed to "radius_attr_print()", and the
argument passed to the print function for an attribute, to "u_char *",
not "char *", as those routines expect a "u_char *".
2000-10-10 13:14:35 +08:00
|
|
|
struct radius_hdr { u_int8_t code; /* Radius packet code */
|
|
|
|
u_int8_t id; /* Radius packet id */
|
|
|
|
u_int16_t len; /* Radius total length */
|
|
|
|
u_int8_t auth[16]; /* Authenticator */
|
2002-12-11 15:13:49 +08:00
|
|
|
};
|
2000-10-06 14:49:20 +08:00
|
|
|
|
2001-06-18 17:16:28 +08:00
|
|
|
#define MIN_RADIUS_LEN 20
|
2000-10-06 14:49:20 +08:00
|
|
|
|
Get rid of some includes, and use "u_int8_t" and "u_int16_t" in packet
layout definitions, as per Alfredo Andrs's suggestion.
Don't use expressions with side effects inside EXTRACT macros - the
arguments of those macros are used more than once, so the side-effects
(incrementing the pointer) occurs more than once, and they occur in a
sequence that may not be the same for all compilers.
When printing a UNIX time value, extract the value into a "time_t"
variable, and then pass a pointer to that variable to "ctime()", don't
cast the result of "EXTRACT_32BITS()" to a pointer. Also, when printing
the result of "ctime()", print only the first 24 characters, so that the
newline at the end isn't printed.
Cast the first argument passed to "radius_attr_print()", and the
argument passed to the print function for an attribute, to "u_char *",
not "char *", as those routines expect a "u_char *".
2000-10-10 13:14:35 +08:00
|
|
|
struct radius_attr { u_int8_t type; /* Attribute type */
|
|
|
|
u_int8_t len; /* Attribute length */
|
2002-12-11 15:13:49 +08:00
|
|
|
};
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
|
2002-06-12 01:08:37 +08:00
|
|
|
/* Service-Type Attribute standard values */
|
2000-10-06 14:49:20 +08:00
|
|
|
static const char *serv_type[]={ NULL,
|
|
|
|
"Login",
|
2002-06-12 01:08:37 +08:00
|
|
|
"Framed",
|
2000-10-06 14:49:20 +08:00
|
|
|
"Callback Login",
|
|
|
|
"Callback Framed",
|
|
|
|
"Outbound",
|
|
|
|
"Administrative",
|
2002-06-12 01:08:37 +08:00
|
|
|
"NAS Prompt",
|
2000-10-06 14:49:20 +08:00
|
|
|
"Authenticate Only",
|
|
|
|
"Callback NAS Prompt",
|
|
|
|
"Call Check",
|
|
|
|
"Callback Administrative",
|
2002-06-12 01:08:37 +08:00
|
|
|
};
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
/* Framed-Protocol Attribute standard values */
|
|
|
|
static const char *frm_proto[]={ NULL,
|
|
|
|
"PPP",
|
|
|
|
"SLIP",
|
|
|
|
"ARAP",
|
|
|
|
"Gandalf proprietary",
|
|
|
|
"Xylogics IPX/SLIP",
|
|
|
|
"X.75 Synchronous",
|
2002-06-12 01:08:37 +08:00
|
|
|
};
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
/* Framed-Routing Attribute standard values */
|
|
|
|
static const char *frm_routing[]={ "None",
|
|
|
|
"Send",
|
|
|
|
"Listen",
|
|
|
|
"Send&Listen",
|
2002-06-12 01:08:37 +08:00
|
|
|
};
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
/* Framed-Compression Attribute standard values */
|
|
|
|
static const char *frm_comp[]={ "None",
|
|
|
|
"VJ TCP/IP",
|
|
|
|
"IPX",
|
|
|
|
"Stac-LZS",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Login-Service Attribute standard values */
|
|
|
|
static const char *login_serv[]={ "Telnet",
|
|
|
|
"Rlogin",
|
|
|
|
"TCP Clear",
|
|
|
|
"PortMaster(proprietary)",
|
|
|
|
"LAT",
|
|
|
|
"X.25-PAD",
|
|
|
|
"X.25-T3POS",
|
|
|
|
"Unassigned",
|
|
|
|
"TCP Clear Quiet",
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Termination-Action Attribute standard values */
|
|
|
|
static const char *term_action[]={ "Default",
|
|
|
|
"RADIUS-Request",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* NAS-Port-Type Attribute standard values */
|
|
|
|
static const char *nas_port_type[]={ "Async",
|
|
|
|
"Sync",
|
|
|
|
"ISDN Sync",
|
|
|
|
"ISDN Async V.120",
|
|
|
|
"ISDN Async V.110",
|
|
|
|
"Virtual",
|
|
|
|
"PIAFS",
|
|
|
|
"HDLC Clear Channel",
|
|
|
|
"X.25",
|
|
|
|
"X.75",
|
|
|
|
"G.3 Fax",
|
|
|
|
"SDSL",
|
|
|
|
"ADSL-CAP",
|
|
|
|
"ADSL-DMT",
|
|
|
|
"ISDN-DSL",
|
|
|
|
"Ethernet",
|
|
|
|
"xDSL",
|
|
|
|
"Cable",
|
|
|
|
"Wireless - Other",
|
|
|
|
"Wireless - IEEE 802.11",
|
2002-06-12 01:08:37 +08:00
|
|
|
};
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
/* Acct-Status-Type Accounting Attribute standard values */
|
|
|
|
static const char *acct_status[]={ NULL,
|
|
|
|
"Start",
|
|
|
|
"Stop",
|
|
|
|
"Interim-Update",
|
|
|
|
"Unassigned",
|
|
|
|
"Unassigned",
|
|
|
|
"Unassigned",
|
|
|
|
"Accounting-On",
|
|
|
|
"Accounting-Off",
|
|
|
|
"Tunnel-Start",
|
|
|
|
"Tunnel-Stop",
|
|
|
|
"Tunnel-Reject",
|
|
|
|
"Tunnel-Link-Start",
|
|
|
|
"Tunnel-Link-Stop",
|
|
|
|
"Tunnel-Link-Reject",
|
|
|
|
"Failed",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Acct-Authentic Accounting Attribute standard values */
|
|
|
|
static const char *acct_auth[]={ NULL,
|
|
|
|
"RADIUS",
|
|
|
|
"Local",
|
|
|
|
"Remote",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Acct-Terminate-Cause Accounting Attribute standard values */
|
|
|
|
static const char *acct_term[]={ NULL,
|
|
|
|
"User Request",
|
|
|
|
"Lost Carrier",
|
|
|
|
"Lost Service",
|
|
|
|
"Idle Timeout",
|
|
|
|
"Session Timeout",
|
|
|
|
"Admin Reset",
|
|
|
|
"Admin Reboot",
|
|
|
|
"Port Error",
|
|
|
|
"NAS Error",
|
|
|
|
"NAS Request",
|
|
|
|
"NAS Reboot",
|
|
|
|
"Port Unneeded",
|
|
|
|
"Port Preempted",
|
|
|
|
"Port Suspended",
|
|
|
|
"Service Unavailable",
|
|
|
|
"Callback",
|
|
|
|
"User Error",
|
|
|
|
"Host Request",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Tunnel-Type Attribute standard values */
|
|
|
|
static const char *tunnel_type[]={ NULL,
|
|
|
|
"PPTP",
|
|
|
|
"L2F",
|
|
|
|
"L2TP",
|
|
|
|
"ATMP",
|
|
|
|
"VTP",
|
|
|
|
"AH",
|
|
|
|
"IP-IP",
|
|
|
|
"MIN-IP-IP",
|
|
|
|
"ESP",
|
|
|
|
"GRE",
|
|
|
|
"DVS",
|
|
|
|
"IP-in-IP Tunneling",
|
|
|
|
};
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
/* Tunnel-Medium-Type Attribute standard values */
|
|
|
|
static const char *tunnel_medium[]={ NULL,
|
|
|
|
"IPv4",
|
|
|
|
"IPv6",
|
|
|
|
"NSAP",
|
|
|
|
"HDLC",
|
|
|
|
"BBN 1822",
|
|
|
|
"802",
|
|
|
|
"E.163",
|
|
|
|
"E.164",
|
|
|
|
"F.69",
|
|
|
|
"X.121",
|
|
|
|
"IPX",
|
|
|
|
"Appletalk",
|
|
|
|
"Decnet IV",
|
|
|
|
"Banyan Vines",
|
|
|
|
"E.164 with NSAP subaddress",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ARAP-Zone-Access Attribute standard values */
|
|
|
|
static const char *arap_zone[]={ NULL,
|
|
|
|
"Only access to dfl zone",
|
|
|
|
"Use zone filter inc.",
|
|
|
|
"Not used",
|
|
|
|
"Use zone filter exc.",
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char *prompt[]={ "No Echo",
|
|
|
|
"Echo",
|
|
|
|
};
|
2002-06-12 01:08:37 +08:00
|
|
|
|
|
|
|
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
struct attrtype { const char *name; /* Attribute name */
|
2000-10-06 14:49:20 +08:00
|
|
|
const char **subtypes; /* Standard Values (if any) */
|
|
|
|
u_char siz_subtypes; /* Size of total standard values */
|
|
|
|
u_char first_subtype; /* First standard value is 0 or 1 */
|
|
|
|
void (*print_func)(register u_char *, u_int, u_short );
|
|
|
|
} attr_type[]=
|
|
|
|
{
|
2003-11-26 16:49:14 +08:00
|
|
|
{ NULL, NULL, 0, 0, NULL },
|
|
|
|
{ "Username", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Password", NULL, 0, 0, NULL },
|
|
|
|
{ "CHAP Password", NULL, 0, 0, NULL },
|
|
|
|
{ "NAS IP Address", NULL, 0, 0, print_attr_address },
|
|
|
|
{ "NAS Port", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Service Type", serv_type, TAM_SIZE(serv_type)-1, 1, print_attr_num },
|
|
|
|
{ "Framed Protocol", frm_proto, TAM_SIZE(frm_proto)-1, 1, print_attr_num },
|
|
|
|
{ "Framed IP Address", NULL, 0, 0, print_attr_address },
|
|
|
|
{ "Framed IP Network", NULL, 0, 0, print_attr_address },
|
|
|
|
{ "Framed Routing", frm_routing, TAM_SIZE(frm_routing), 0, print_attr_num },
|
|
|
|
{ "Filter ID", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Framed MTU", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Framed Compression", frm_comp, TAM_SIZE(frm_comp), 0, print_attr_num },
|
|
|
|
{ "Login IP Host", NULL, 0, 0, print_attr_address },
|
|
|
|
{ "Login Service", login_serv, TAM_SIZE(login_serv), 0, print_attr_num },
|
|
|
|
{ "Login TCP Port", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Unassigned", NULL, 0, 0, NULL }, /*17*/
|
|
|
|
{ "Reply", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Callback-number", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Callback-ID", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Unassigned", NULL, 0, 0, NULL }, /*21*/
|
|
|
|
{ "Framed Route", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Framed IPX Network", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "State", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Class", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Vendor Specific", NULL, 0, 0, print_vendor_attr },
|
|
|
|
{ "Session Timeout", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Idle Timeout", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Termination Action", term_action, TAM_SIZE(term_action), 0, print_attr_num },
|
|
|
|
{ "Called Station", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Calling Station", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "NAS ID", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Proxy State", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Login LAT Service", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Login LAT Node", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Login LAT Group", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Framed Appletalk Link", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Framed Appltalk Net", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Framed Appletalk Zone", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Accounting Status", acct_status, TAM_SIZE(acct_status)-1, 1, print_attr_num },
|
|
|
|
{ "Accounting Delay", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Accounting Input Octets", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Accounting Output Octets", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Accounting Session ID", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Accounting Authentication", acct_auth, TAM_SIZE(acct_auth)-1, 1, print_attr_num },
|
|
|
|
{ "Accounting Session Time", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Accounting Input Packets", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Accounting Output Packets", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Accounting Termination Cause", acct_term, TAM_SIZE(acct_term)-1, 1, print_attr_num },
|
|
|
|
{ "Accounting Multilink Session ID", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Accounting Link Count", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Accounting Input Giga", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Accounting Output Giga", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Unassigned", NULL, 0, 0, NULL }, /*54*/
|
|
|
|
{ "Event Timestamp", NULL, 0, 0, print_attr_time },
|
|
|
|
{ "Unassigned", NULL, 0, 0, NULL }, /*56*/
|
|
|
|
{ "Unassigned", NULL, 0, 0, NULL }, /*57*/
|
|
|
|
{ "Unassigned", NULL, 0, 0, NULL }, /*58*/
|
|
|
|
{ "Unassigned", NULL, 0, 0, NULL }, /*59*/
|
|
|
|
{ "CHAP challenge", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "NAS Port Type", nas_port_type, TAM_SIZE(nas_port_type), 0, print_attr_num },
|
|
|
|
{ "Port Limit", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Login LAT Port", NULL, 0, 0, print_attr_string }, /*63*/
|
|
|
|
{ "Tunnel Type", tunnel_type, TAM_SIZE(tunnel_type)-1, 1, print_attr_num },
|
|
|
|
{ "Tunnel Medium", tunnel_medium, TAM_SIZE(tunnel_medium)-1, 1, print_attr_num },
|
|
|
|
{ "Tunnel Client End", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Tunnel Server End", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Accounting Tunnel connect", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Tunnel Password", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "ARAP Password", NULL, 0, 0, print_attr_strange },
|
|
|
|
{ "ARAP Feature", NULL, 0, 0, print_attr_strange },
|
|
|
|
{ "ARAP Zone Acces", arap_zone, TAM_SIZE(arap_zone)-1, 1, print_attr_num }, /*72*/
|
|
|
|
{ "ARAP Security", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "ARAP Security Data", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Password Retry", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Prompt", prompt, TAM_SIZE(prompt), 0, print_attr_num },
|
|
|
|
{ "Connect Info", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Config Token", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "EAP Message", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Message Authentication", NULL, 0, 0, print_attr_string }, /*80*/
|
|
|
|
{ "Tunnel Private Group", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Tunnel Assigned ID", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Tunnel Preference", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "ARAP Challenge Response", NULL, 0, 0, print_attr_strange },
|
|
|
|
{ "Accounting Interim Interval", NULL, 0, 0, print_attr_num },
|
|
|
|
{ "Accounting Tunnel packets lost", NULL, 0, 0, print_attr_num }, /*86*/
|
|
|
|
{ "NAS Port ID", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Framed Pool", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Unassigned", NULL, 0, 0, NULL },
|
|
|
|
{ "Tunnel Client Authentication ID", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Tunnel Server Authentication ID", NULL, 0, 0, print_attr_string },
|
|
|
|
{ "Unassigned", NULL, 0, 0, NULL }, /*92*/
|
|
|
|
{ "Unassigned", NULL, 0, 0, NULL } /*93*/
|
2002-06-12 01:08:37 +08:00
|
|
|
};
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* Print an attribute string */
|
|
|
|
/* value pointed by 'data' */
|
|
|
|
/* and 'length' size. */
|
|
|
|
/*****************************/
|
|
|
|
/* Returns nothing. */
|
|
|
|
/*****************************/
|
|
|
|
static void
|
|
|
|
print_attr_string(register u_char *data, u_int length, u_short attr_code )
|
|
|
|
{
|
|
|
|
register u_int i;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
TCHECK2(data[0],length);
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
switch(attr_code)
|
|
|
|
{
|
|
|
|
case TUNNEL_PASS:
|
2005-09-26 09:01:55 +08:00
|
|
|
if (length < 3)
|
|
|
|
{
|
|
|
|
printf(" [|radius]");
|
|
|
|
return;
|
|
|
|
}
|
2000-10-06 14:49:20 +08:00
|
|
|
if (*data && (*data <=0x1F) )
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("Tag %u, ",*data);
|
2000-10-06 14:49:20 +08:00
|
|
|
data++;
|
2005-09-26 09:01:55 +08:00
|
|
|
length--;
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("Salt %u ",EXTRACT_16BITS(data) );
|
2000-10-06 14:49:20 +08:00
|
|
|
data+=2;
|
|
|
|
length-=2;
|
|
|
|
break;
|
|
|
|
case TUNNEL_CLIENT_END:
|
|
|
|
case TUNNEL_SERVER_END:
|
|
|
|
case TUNNEL_PRIV_GROUP:
|
|
|
|
case TUNNEL_ASSIGN_ID:
|
|
|
|
case TUNNEL_CLIENT_AUTH:
|
|
|
|
case TUNNEL_SERVER_AUTH:
|
|
|
|
if (*data <= 0x1F)
|
|
|
|
{
|
2005-09-26 09:01:55 +08:00
|
|
|
if (length < 1)
|
|
|
|
{
|
|
|
|
printf(" [|radius]");
|
|
|
|
return;
|
|
|
|
}
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("Tag %u",*data);
|
2000-10-06 14:49:20 +08:00
|
|
|
data++;
|
|
|
|
length--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-01-07 16:00:51 +08:00
|
|
|
for (i=0; *data && i < length ; i++, data++)
|
2000-10-06 14:49:20 +08:00
|
|
|
printf("%c",(*data < 32 || *data > 128) ? '.' : *data );
|
|
|
|
|
|
|
|
return;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
trunc:
|
2005-09-26 09:01:55 +08:00
|
|
|
printf(" [|radius]");
|
2002-06-12 01:08:37 +08:00
|
|
|
}
|
2000-10-06 14:49:20 +08:00
|
|
|
|
2003-11-26 16:49:14 +08:00
|
|
|
/*
|
|
|
|
* print vendor specific attributes
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_vendor_attr(register u_char *data, u_int length, u_short attr_code _U_)
|
|
|
|
{
|
|
|
|
u_int idx;
|
|
|
|
u_int vendor_id;
|
|
|
|
u_int vendor_type;
|
|
|
|
u_int vendor_length;
|
|
|
|
|
2005-09-26 09:01:55 +08:00
|
|
|
if (length < 4)
|
|
|
|
goto trunc;
|
|
|
|
TCHECK2(*data, 4);
|
2003-11-26 16:49:14 +08:00
|
|
|
vendor_id = EXTRACT_32BITS(data);
|
|
|
|
data+=4;
|
|
|
|
length-=4;
|
|
|
|
|
|
|
|
printf("Vendor: %s (%u)",
|
2004-01-25 17:56:15 +08:00
|
|
|
tok2str(smi_values,"Unknown",vendor_id),
|
2003-11-26 16:49:14 +08:00
|
|
|
vendor_id);
|
|
|
|
|
|
|
|
while (length >= 2) {
|
2005-09-26 09:01:55 +08:00
|
|
|
TCHECK2(*data, 2);
|
2004-01-25 17:31:14 +08:00
|
|
|
|
2003-11-26 16:49:14 +08:00
|
|
|
vendor_type = *(data);
|
|
|
|
vendor_length = *(data+1);
|
2004-01-25 17:31:14 +08:00
|
|
|
|
2005-09-26 09:01:55 +08:00
|
|
|
if (vendor_length < 2)
|
|
|
|
{
|
|
|
|
printf("\n\t Vendor Attribute: %u, Length: %u (bogus, must be >= 2)",
|
|
|
|
vendor_type,
|
|
|
|
vendor_length);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (vendor_length > length)
|
|
|
|
{
|
|
|
|
printf("\n\t Vendor Attribute: %u, Length: %u (bogus, goes past end of vendor-specific attribute)",
|
|
|
|
vendor_type,
|
|
|
|
vendor_length);
|
|
|
|
return;
|
|
|
|
}
|
2003-11-26 16:49:14 +08:00
|
|
|
data+=2;
|
2005-09-26 09:01:55 +08:00
|
|
|
vendor_length-=2;
|
|
|
|
length-=2;
|
|
|
|
TCHECK2(*data, vendor_length);
|
2004-01-25 17:31:14 +08:00
|
|
|
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("\n\t Vendor Attribute: %u, Length: %u, Value: ",
|
|
|
|
vendor_type,
|
|
|
|
vendor_length);
|
|
|
|
for (idx = 0; idx < vendor_length ; idx++, data++)
|
|
|
|
printf("%c",(*data < 32 || *data > 128) ? '.' : *data );
|
|
|
|
length-=vendor_length;
|
|
|
|
}
|
2005-09-26 09:01:55 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
trunc:
|
|
|
|
printf(" [|radius]");
|
2003-11-26 16:49:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
|
|
|
|
/******************************/
|
|
|
|
/* Print an attribute numeric */
|
|
|
|
/* value pointed by 'data' */
|
|
|
|
/* and 'length' size. */
|
|
|
|
/******************************/
|
|
|
|
/* Returns nothing. */
|
|
|
|
/******************************/
|
|
|
|
static void
|
|
|
|
print_attr_num(register u_char *data, u_int length, u_short attr_code )
|
|
|
|
{
|
Get rid of some includes, and use "u_int8_t" and "u_int16_t" in packet
layout definitions, as per Alfredo Andrs's suggestion.
Don't use expressions with side effects inside EXTRACT macros - the
arguments of those macros are used more than once, so the side-effects
(incrementing the pointer) occurs more than once, and they occur in a
sequence that may not be the same for all compilers.
When printing a UNIX time value, extract the value into a "time_t"
variable, and then pass a pointer to that variable to "ctime()", don't
cast the result of "EXTRACT_32BITS()" to a pointer. Also, when printing
the result of "ctime()", print only the first 24 characters, so that the
newline at the end isn't printed.
Cast the first argument passed to "radius_attr_print()", and the
argument passed to the print function for an attribute, to "u_char *",
not "char *", as those routines expect a "u_char *".
2000-10-10 13:14:35 +08:00
|
|
|
u_int8_t tag;
|
2000-10-06 14:49:20 +08:00
|
|
|
u_int32_t timeout;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-12-04 04:31:26 +08:00
|
|
|
if (length != 4)
|
|
|
|
{
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("ERROR: length %u != 4", length);
|
2000-12-04 04:31:26 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
TCHECK2(data[0],4);
|
|
|
|
/* This attribute has standard values */
|
2002-06-12 01:08:37 +08:00
|
|
|
if (attr_type[attr_code].siz_subtypes)
|
2000-10-06 14:49:20 +08:00
|
|
|
{
|
|
|
|
static const char **table;
|
|
|
|
u_int32_t data_value;
|
|
|
|
table = attr_type[attr_code].subtypes;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
if ( (attr_code == TUNNEL_TYPE) || (attr_code == TUNNEL_MEDIUM) )
|
|
|
|
{
|
|
|
|
if (!*data)
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("Tag[Unused]");
|
2000-10-06 14:49:20 +08:00
|
|
|
else
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("Tag[%d]", *data);
|
Get rid of some includes, and use "u_int8_t" and "u_int16_t" in packet
layout definitions, as per Alfredo Andrs's suggestion.
Don't use expressions with side effects inside EXTRACT macros - the
arguments of those macros are used more than once, so the side-effects
(incrementing the pointer) occurs more than once, and they occur in a
sequence that may not be the same for all compilers.
When printing a UNIX time value, extract the value into a "time_t"
variable, and then pass a pointer to that variable to "ctime()", don't
cast the result of "EXTRACT_32BITS()" to a pointer. Also, when printing
the result of "ctime()", print only the first 24 characters, so that the
newline at the end isn't printed.
Cast the first argument passed to "radius_attr_print()", and the
argument passed to the print function for an attribute, to "u_char *",
not "char *", as those routines expect a "u_char *".
2000-10-10 13:14:35 +08:00
|
|
|
data++;
|
|
|
|
data_value = EXTRACT_24BITS(data);
|
2000-10-06 14:49:20 +08:00
|
|
|
}
|
|
|
|
else
|
Get rid of some includes, and use "u_int8_t" and "u_int16_t" in packet
layout definitions, as per Alfredo Andrs's suggestion.
Don't use expressions with side effects inside EXTRACT macros - the
arguments of those macros are used more than once, so the side-effects
(incrementing the pointer) occurs more than once, and they occur in a
sequence that may not be the same for all compilers.
When printing a UNIX time value, extract the value into a "time_t"
variable, and then pass a pointer to that variable to "ctime()", don't
cast the result of "EXTRACT_32BITS()" to a pointer. Also, when printing
the result of "ctime()", print only the first 24 characters, so that the
newline at the end isn't printed.
Cast the first argument passed to "radius_attr_print()", and the
argument passed to the print function for an attribute, to "u_char *",
not "char *", as those routines expect a "u_char *".
2000-10-10 13:14:35 +08:00
|
|
|
{
|
|
|
|
data_value = EXTRACT_32BITS(data);
|
|
|
|
}
|
Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
From Neil T. Spring: fixes for many of those warnings:
addrtoname.c, configure.in: Linux needs netinet/ether.h for
ether_ntohost
print-*.c: change char *foo = "bar" to const char *foo = "bar"
to appease -Wwrite-strings; should affect no run-time behavior.
print-*.c: make some variables unsigned.
print-bgp.c: plen ('prefix len') is unsigned, no reason to
validate by comparing to zero.
print-cnfp.c, print-rx.c: use intoa, provided by addrtoname,
instead of inet_ntoa.
print-domain.c: unsigned int l; (l=foo()) < 0 is guaranteed to
be false, so check for (u_int)-1, which represents failure,
explicitly.
print-isakmp.c: complete initialization of attrmap objects.
print-lwres.c: "if(x); print foo;" seemed much more likely to be
intended to be "if(x) { print foo; }".
print-smb.c: complete initialization of some structures.
In addition, add some fixes for the signed vs. unsigned comparison
warnings:
extract.h: cast the result of the byte-extraction-and-combining,
as, at least for the 16-bit version, C's integral promotions
will turn "u_int16_t" into "int" if there are other "int"s
nearby.
print-*.c: make some more variables unsigned, or add casts to an
unsigned type of signed values known not to be negative, or add
casts to "int" of unsigned values known to fit in an "int", and
make other changes needed to handle the aforementioned variables
now being unsigned.
print-isakmp.c: clean up the handling of error/status indicators
in notify messages.
print-ppp.c: get rid of a check that an unsigned quantity is >=
0.
print-radius.c: clean up some of the bounds checking.
print-smb.c: extract the word count into a "u_int" to avoid the
aforementioned problems with C's integral promotions.
print-snmp.c: change a check that an unsigned variable is >= 0
to a check that it's != 0.
Also, fix some formats to use "%u" rather than "%d" for unsigned
quantities.
2002-09-05 08:00:07 +08:00
|
|
|
if ( data_value <= (u_int32_t)(attr_type[attr_code].siz_subtypes - 1 +
|
2002-07-04 00:27:12 +08:00
|
|
|
attr_type[attr_code].first_subtype) &&
|
|
|
|
data_value >= attr_type[attr_code].first_subtype )
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("%s",table[data_value]);
|
2000-10-06 14:49:20 +08:00
|
|
|
else
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("#%u",data_value);
|
2000-10-06 14:49:20 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch(attr_code) /* Be aware of special cases... */
|
|
|
|
{
|
|
|
|
case FRM_IPX:
|
|
|
|
if (EXTRACT_32BITS( data) == 0xFFFFFFFE )
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("NAS Select");
|
2000-10-06 14:49:20 +08:00
|
|
|
else
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("%d",EXTRACT_32BITS( data) );
|
2000-10-06 14:49:20 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SESSION_TIMEOUT:
|
|
|
|
case IDLE_TIMEOUT:
|
|
|
|
case ACCT_DELAY:
|
|
|
|
case ACCT_SESSION_TIME:
|
|
|
|
case ACCT_INT_INTERVAL:
|
|
|
|
timeout = EXTRACT_32BITS( data);
|
|
|
|
if ( timeout < 60 )
|
2003-11-26 16:49:14 +08:00
|
|
|
printf( "%02d secs", timeout);
|
2000-10-06 14:49:20 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( timeout < 3600 )
|
2003-11-26 16:49:14 +08:00
|
|
|
printf( "%02d:%02d min",
|
2000-10-06 14:49:20 +08:00
|
|
|
timeout / 60, timeout % 60);
|
|
|
|
else
|
2003-11-26 16:49:14 +08:00
|
|
|
printf( "%02d:%02d:%02d hours",
|
2002-06-12 01:08:37 +08:00
|
|
|
timeout / 3600, (timeout % 3600) / 60,
|
2000-10-06 14:49:20 +08:00
|
|
|
timeout % 60);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRM_ATALK_LINK:
|
2002-06-12 01:08:37 +08:00
|
|
|
if (EXTRACT_32BITS(data) )
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("%d",EXTRACT_32BITS(data) );
|
2000-10-06 14:49:20 +08:00
|
|
|
else
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("Unnumbered" );
|
2000-10-06 14:49:20 +08:00
|
|
|
break;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
case FRM_ATALK_NETWORK:
|
2002-06-12 01:08:37 +08:00
|
|
|
if (EXTRACT_32BITS(data) )
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("%d",EXTRACT_32BITS(data) );
|
2000-10-06 14:49:20 +08:00
|
|
|
else
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("NAS assigned" );
|
2000-10-06 14:49:20 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TUNNEL_PREFERENCE:
|
Get rid of some includes, and use "u_int8_t" and "u_int16_t" in packet
layout definitions, as per Alfredo Andrs's suggestion.
Don't use expressions with side effects inside EXTRACT macros - the
arguments of those macros are used more than once, so the side-effects
(incrementing the pointer) occurs more than once, and they occur in a
sequence that may not be the same for all compilers.
When printing a UNIX time value, extract the value into a "time_t"
variable, and then pass a pointer to that variable to "ctime()", don't
cast the result of "EXTRACT_32BITS()" to a pointer. Also, when printing
the result of "ctime()", print only the first 24 characters, so that the
newline at the end isn't printed.
Cast the first argument passed to "radius_attr_print()", and the
argument passed to the print function for an attribute, to "u_char *",
not "char *", as those routines expect a "u_char *".
2000-10-10 13:14:35 +08:00
|
|
|
tag = *data;
|
|
|
|
data++;
|
|
|
|
if (tag == 0)
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("Tag (Unused) %d",EXTRACT_24BITS(data) );
|
2000-10-06 14:49:20 +08:00
|
|
|
else
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("Tag (%d) %d", tag, EXTRACT_24BITS(data) );
|
2000-10-06 14:49:20 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("%d",EXTRACT_32BITS( data) );
|
2000-10-06 14:49:20 +08:00
|
|
|
break;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
} /* switch */
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
} /* if-else */
|
|
|
|
|
|
|
|
return;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
trunc:
|
2005-09-26 09:01:55 +08:00
|
|
|
printf(" [|radius]");
|
2000-10-06 14:49:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************/
|
|
|
|
/* Print an attribute IPv4 */
|
|
|
|
/* address value pointed by */
|
|
|
|
/* 'data' and 'length' size. */
|
|
|
|
/*****************************/
|
|
|
|
/* Returns nothing. */
|
|
|
|
/*****************************/
|
|
|
|
static void
|
|
|
|
print_attr_address(register u_char *data, u_int length, u_short attr_code )
|
|
|
|
{
|
2000-12-04 04:31:26 +08:00
|
|
|
if (length != 4)
|
|
|
|
{
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("ERROR: length %u != 4", length);
|
2000-12-04 04:31:26 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
TCHECK2(data[0],4);
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
switch(attr_code)
|
|
|
|
{
|
|
|
|
case FRM_IPADDR:
|
|
|
|
case LOG_IPHOST:
|
|
|
|
if (EXTRACT_32BITS(data) == 0xFFFFFFFF )
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("User Selected");
|
2000-10-06 14:49:20 +08:00
|
|
|
else
|
|
|
|
if (EXTRACT_32BITS(data) == 0xFFFFFFFE )
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("NAS Select");
|
2000-10-06 14:49:20 +08:00
|
|
|
else
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("%s",ipaddr_string(data));
|
2000-10-06 14:49:20 +08:00
|
|
|
break;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
default:
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("%s",ipaddr_string(data) );
|
2000-10-06 14:49:20 +08:00
|
|
|
break;
|
|
|
|
}
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
return;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
trunc:
|
2005-09-26 09:01:55 +08:00
|
|
|
printf(" [|radius]");
|
2000-10-06 14:49:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************/
|
|
|
|
/* Print an attribute of 'secs since */
|
|
|
|
/* January 1, 1970 00:00 UTC' value */
|
|
|
|
/* pointed by 'data' and 'length' */
|
|
|
|
/* size. */
|
|
|
|
/*************************************/
|
|
|
|
/* Returns nothing. */
|
|
|
|
/*************************************/
|
2002-11-11 04:37:31 +08:00
|
|
|
static void print_attr_time(register u_char *data, u_int length, u_short attr_code _U_)
|
2000-10-06 14:49:20 +08:00
|
|
|
{
|
Get rid of some includes, and use "u_int8_t" and "u_int16_t" in packet
layout definitions, as per Alfredo Andrs's suggestion.
Don't use expressions with side effects inside EXTRACT macros - the
arguments of those macros are used more than once, so the side-effects
(incrementing the pointer) occurs more than once, and they occur in a
sequence that may not be the same for all compilers.
When printing a UNIX time value, extract the value into a "time_t"
variable, and then pass a pointer to that variable to "ctime()", don't
cast the result of "EXTRACT_32BITS()" to a pointer. Also, when printing
the result of "ctime()", print only the first 24 characters, so that the
newline at the end isn't printed.
Cast the first argument passed to "radius_attr_print()", and the
argument passed to the print function for an attribute, to "u_char *",
not "char *", as those routines expect a "u_char *".
2000-10-10 13:14:35 +08:00
|
|
|
time_t attr_time;
|
2000-12-04 04:31:26 +08:00
|
|
|
char string[26];
|
|
|
|
|
|
|
|
if (length != 4)
|
|
|
|
{
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("ERROR: length %u != 4", length);
|
2000-12-04 04:31:26 +08:00
|
|
|
return;
|
|
|
|
}
|
Get rid of some includes, and use "u_int8_t" and "u_int16_t" in packet
layout definitions, as per Alfredo Andrs's suggestion.
Don't use expressions with side effects inside EXTRACT macros - the
arguments of those macros are used more than once, so the side-effects
(incrementing the pointer) occurs more than once, and they occur in a
sequence that may not be the same for all compilers.
When printing a UNIX time value, extract the value into a "time_t"
variable, and then pass a pointer to that variable to "ctime()", don't
cast the result of "EXTRACT_32BITS()" to a pointer. Also, when printing
the result of "ctime()", print only the first 24 characters, so that the
newline at the end isn't printed.
Cast the first argument passed to "radius_attr_print()", and the
argument passed to the print function for an attribute, to "u_char *",
not "char *", as those routines expect a "u_char *".
2000-10-10 13:14:35 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
TCHECK2(data[0],4);
|
2002-06-12 01:08:37 +08:00
|
|
|
|
Get rid of some includes, and use "u_int8_t" and "u_int16_t" in packet
layout definitions, as per Alfredo Andrs's suggestion.
Don't use expressions with side effects inside EXTRACT macros - the
arguments of those macros are used more than once, so the side-effects
(incrementing the pointer) occurs more than once, and they occur in a
sequence that may not be the same for all compilers.
When printing a UNIX time value, extract the value into a "time_t"
variable, and then pass a pointer to that variable to "ctime()", don't
cast the result of "EXTRACT_32BITS()" to a pointer. Also, when printing
the result of "ctime()", print only the first 24 characters, so that the
newline at the end isn't printed.
Cast the first argument passed to "radius_attr_print()", and the
argument passed to the print function for an attribute, to "u_char *",
not "char *", as those routines expect a "u_char *".
2000-10-10 13:14:35 +08:00
|
|
|
attr_time = EXTRACT_32BITS(data);
|
2001-06-26 05:13:33 +08:00
|
|
|
strlcpy(string, ctime(&attr_time), sizeof(string));
|
2000-12-04 04:31:26 +08:00
|
|
|
/* Get rid of the newline */
|
|
|
|
string[24] = '\0';
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("%.24s", string);
|
2000-10-06 14:49:20 +08:00
|
|
|
return;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
trunc:
|
2005-09-26 09:01:55 +08:00
|
|
|
printf(" [|radius]");
|
2000-10-06 14:49:20 +08:00
|
|
|
}
|
|
|
|
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
/***********************************/
|
|
|
|
/* Print an attribute of 'strange' */
|
|
|
|
/* data format pointed by 'data' */
|
|
|
|
/* and 'length' size. */
|
|
|
|
/***********************************/
|
|
|
|
/* Returns nothing. */
|
|
|
|
/***********************************/
|
|
|
|
static void print_attr_strange(register u_char *data, u_int length, u_short attr_code)
|
|
|
|
{
|
2000-12-04 04:31:26 +08:00
|
|
|
u_short len_data;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
switch(attr_code)
|
|
|
|
{
|
|
|
|
case ARAP_PASS:
|
2000-12-04 04:31:26 +08:00
|
|
|
if (length != 16)
|
|
|
|
{
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("ERROR: length %u != 16", length);
|
2000-12-04 04:31:26 +08:00
|
|
|
return;
|
|
|
|
}
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("User_challenge (");
|
2000-10-06 14:49:20 +08:00
|
|
|
TCHECK2(data[0],8);
|
2000-12-04 04:31:26 +08:00
|
|
|
len_data = 8;
|
2000-10-06 14:49:20 +08:00
|
|
|
PRINT_HEX(len_data, data);
|
2003-11-26 16:49:14 +08:00
|
|
|
printf(") User_resp(");
|
2000-10-06 14:49:20 +08:00
|
|
|
TCHECK2(data[0],8);
|
2000-12-04 04:31:26 +08:00
|
|
|
len_data = 8;
|
2000-10-06 14:49:20 +08:00
|
|
|
PRINT_HEX(len_data, data);
|
2003-11-26 16:49:14 +08:00
|
|
|
printf(")");
|
2000-10-06 14:49:20 +08:00
|
|
|
break;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
case ARAP_FEATURES:
|
2000-12-04 04:31:26 +08:00
|
|
|
if (length != 14)
|
|
|
|
{
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("ERROR: length %u != 14", length);
|
2000-12-04 04:31:26 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
TCHECK2(data[0],1);
|
2000-10-06 14:49:20 +08:00
|
|
|
if (*data)
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("User can change password");
|
2000-10-06 14:49:20 +08:00
|
|
|
else
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("User cannot change password");
|
2000-10-06 14:49:20 +08:00
|
|
|
data++;
|
2000-12-04 04:31:26 +08:00
|
|
|
TCHECK2(data[0],1);
|
2003-11-26 16:49:14 +08:00
|
|
|
printf(", Min password length: %d",*data);
|
2000-12-04 04:31:26 +08:00
|
|
|
data++;
|
2003-11-26 16:49:14 +08:00
|
|
|
printf(", created at: ");
|
2000-12-04 04:31:26 +08:00
|
|
|
TCHECK2(data[0],4);
|
|
|
|
len_data = 4;
|
2000-10-06 14:49:20 +08:00
|
|
|
PRINT_HEX(len_data, data);
|
2003-11-26 16:49:14 +08:00
|
|
|
printf(", expires in: ");
|
2000-12-04 04:31:26 +08:00
|
|
|
TCHECK2(data[0],4);
|
|
|
|
len_data = 4;
|
2000-10-06 14:49:20 +08:00
|
|
|
PRINT_HEX(len_data, data);
|
2003-11-26 16:49:14 +08:00
|
|
|
printf(", Current Time: ");
|
2000-12-04 04:31:26 +08:00
|
|
|
TCHECK2(data[0],4);
|
2005-09-26 09:01:55 +08:00
|
|
|
len_data = 4;
|
2000-10-06 14:49:20 +08:00
|
|
|
PRINT_HEX(len_data, data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ARAP_CHALLENGE_RESP:
|
2000-12-04 04:31:26 +08:00
|
|
|
if (length < 8)
|
|
|
|
{
|
2003-11-26 16:49:14 +08:00
|
|
|
printf("ERROR: length %u != 8", length);
|
2000-12-04 04:31:26 +08:00
|
|
|
return;
|
|
|
|
}
|
2000-10-06 14:49:20 +08:00
|
|
|
TCHECK2(data[0],8);
|
2000-12-04 04:31:26 +08:00
|
|
|
len_data = 8;
|
2000-10-06 14:49:20 +08:00
|
|
|
PRINT_HEX(len_data, data);
|
|
|
|
break;
|
|
|
|
}
|
2005-09-26 09:01:55 +08:00
|
|
|
return;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
trunc:
|
2005-09-26 09:01:55 +08:00
|
|
|
printf(" [|radius]");
|
2000-10-06 14:49:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2005-09-26 09:01:55 +08:00
|
|
|
radius_attrs_print(register const u_char *attr, u_int length)
|
2000-10-06 14:49:20 +08:00
|
|
|
{
|
|
|
|
register const struct radius_attr *rad_attr = (struct radius_attr *)attr;
|
2005-09-26 09:01:55 +08:00
|
|
|
const char *attr_string;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
while (length > 0)
|
|
|
|
{
|
2005-09-26 09:01:55 +08:00
|
|
|
if (length < 2)
|
|
|
|
goto trunc;
|
|
|
|
TCHECK(*rad_attr);
|
|
|
|
|
|
|
|
if (rad_attr->type > 0 && rad_attr->type < TAM_SIZE(attr_type))
|
|
|
|
attr_string = attr_type[rad_attr->type].name;
|
|
|
|
else
|
|
|
|
attr_string = "Unknown";
|
|
|
|
if (rad_attr->len < 2)
|
2001-06-18 17:16:28 +08:00
|
|
|
{
|
2005-09-26 09:01:55 +08:00
|
|
|
printf("\n\t %s Attribute (%u), length: %u (bogus, must be >= 2)",
|
|
|
|
attr_string,
|
|
|
|
rad_attr->type,
|
|
|
|
rad_attr->len);
|
2002-06-12 01:08:37 +08:00
|
|
|
return;
|
2001-06-18 17:16:28 +08:00
|
|
|
}
|
2005-09-26 09:01:55 +08:00
|
|
|
if (rad_attr->len > length)
|
2000-10-06 14:49:20 +08:00
|
|
|
{
|
2005-09-26 09:01:55 +08:00
|
|
|
printf("\n\t %s Attribute (%u), length: %u (bogus, goes past end of packet)",
|
|
|
|
attr_string,
|
|
|
|
rad_attr->type,
|
|
|
|
rad_attr->len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
printf("\n\t %s Attribute (%u), length: %u, Value: ",
|
|
|
|
attr_string,
|
|
|
|
rad_attr->type,
|
|
|
|
rad_attr->len);
|
2003-11-26 16:49:14 +08:00
|
|
|
|
2005-09-26 09:01:55 +08:00
|
|
|
if (rad_attr->type < TAM_SIZE(attr_type))
|
|
|
|
{
|
|
|
|
if (rad_attr->len > 2)
|
|
|
|
{
|
|
|
|
if ( attr_type[rad_attr->type].print_func )
|
|
|
|
(*attr_type[rad_attr->type].print_func)(
|
|
|
|
((u_char *)(rad_attr+1)),
|
|
|
|
rad_attr->len - 2, rad_attr->type);
|
2003-11-26 16:49:14 +08:00
|
|
|
}
|
2000-10-06 14:49:20 +08:00
|
|
|
}
|
2004-07-22 05:45:47 +08:00
|
|
|
/* do we also want to see a hex dump ? */
|
2005-09-26 09:01:55 +08:00
|
|
|
if (vflag> 1)
|
2004-07-22 05:45:47 +08:00
|
|
|
print_unknown_data((u_char *)rad_attr+2,"\n\t ",(rad_attr->len)-2);
|
2003-12-15 21:52:15 +08:00
|
|
|
|
2000-10-06 14:49:20 +08:00
|
|
|
length-=(rad_attr->len);
|
|
|
|
rad_attr = (struct radius_attr *)( ((char *)(rad_attr))+rad_attr->len);
|
|
|
|
}
|
2005-09-26 09:01:55 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
trunc:
|
|
|
|
printf(" [|radius]");
|
2000-10-06 14:49:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
radius_print(const u_char *dat, u_int length)
|
|
|
|
{
|
|
|
|
register const struct radius_hdr *rad;
|
2003-11-26 16:49:14 +08:00
|
|
|
u_int len, auth_idx;
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2005-09-26 09:01:55 +08:00
|
|
|
TCHECK2(*dat, MIN_RADIUS_LEN);
|
2000-10-06 14:49:20 +08:00
|
|
|
rad = (struct radius_hdr *)dat;
|
2002-12-11 15:13:49 +08:00
|
|
|
len = EXTRACT_16BITS(&rad->len);
|
2001-06-18 17:16:28 +08:00
|
|
|
|
|
|
|
if (len < MIN_RADIUS_LEN)
|
|
|
|
{
|
|
|
|
printf(" [|radius]");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-09-26 09:01:55 +08:00
|
|
|
if (len > length)
|
|
|
|
len = length;
|
2001-06-18 17:16:28 +08:00
|
|
|
|
2003-11-26 16:49:14 +08:00
|
|
|
if (vflag < 1) {
|
|
|
|
printf("RADIUS, %s (%u), id: 0x%02x length: %u",
|
|
|
|
tok2str(radius_command_values,"Unknown Command",rad->code),
|
|
|
|
rad->code,
|
|
|
|
rad->id,
|
2005-09-26 09:01:55 +08:00
|
|
|
len);
|
2003-11-26 16:49:14 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("RADIUS, length: %u\n\t%s (%u), id: 0x%02x, Authenticator: ",
|
2005-09-26 09:01:55 +08:00
|
|
|
len,
|
2003-11-26 16:49:14 +08:00
|
|
|
tok2str(radius_command_values,"Unknown Command",rad->code),
|
|
|
|
rad->code,
|
|
|
|
rad->id);
|
|
|
|
|
|
|
|
for(auth_idx=0; auth_idx < 16; auth_idx++)
|
|
|
|
printf("%02x", rad->auth[auth_idx] );
|
2000-10-06 14:49:20 +08:00
|
|
|
}
|
2002-06-12 01:08:37 +08:00
|
|
|
|
2005-09-26 09:01:55 +08:00
|
|
|
if (len > MIN_RADIUS_LEN)
|
|
|
|
radius_attrs_print( dat + MIN_RADIUS_LEN, len - MIN_RADIUS_LEN);
|
|
|
|
return;
|
|
|
|
|
|
|
|
trunc:
|
|
|
|
printf(" [|radius]");
|
2000-10-06 14:49:20 +08:00
|
|
|
}
|