layout definitions, as per Alfredo Andrés'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 *".
#ifndef lint
static const char rcsid[] =
#ifndef lint
static const char rcsid[] =
- "$Id: print-radius.c,v 1.2 2000-10-08 08:48:48 guy Exp $";
+ "$Id: print-radius.c,v 1.3 2000-10-10 05:14:35 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
#endif
#ifdef HAVE_CONFIG_H
#include "addrtoname.h"
#include "extract.h"
#include "addrtoname.h"
#include "extract.h"
-#include "ip.h"
-#include "udp.h"
-
#define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
#define PRINT_HEX(bytes_len, ptr_data) \
#define TAM_SIZE(x) (sizeof(x)/sizeof(x[0]) )
#define PRINT_HEX(bytes_len, ptr_data) \
static void print_attr_strange(register u_char *, u_int, u_short);
static void print_attr_strange(register u_char *, u_int, u_short);
-struct radius_hdr { u_char code; /* Radius packet code */
- u_char id; /* Radius packet id */
- u_short len; /* Radius total length */
- u_char auth[16]; /* Authenticator */
+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 */
-struct radius_attr { u_char type; /* Attribute type */
- u_char len; /* Attribute length */
+struct radius_attr { u_int8_t type; /* Attribute type */
+ u_int8_t len; /* Attribute length */
static void
print_attr_num(register u_char *data, u_int length, u_short attr_code )
{
static void
print_attr_num(register u_char *data, u_int length, u_short attr_code )
{
u_int32_t timeout;
TCHECK2(data[0],4);
u_int32_t timeout;
TCHECK2(data[0],4);
printf("{Tag[Unused]");
else
printf("{Tag[%d]", *data);
printf("{Tag[Unused]");
else
printf("{Tag[%d]", *data);
- data_value = EXTRACT_24BITS(++data);
+ data++;
+ data_value = EXTRACT_24BITS(data);
- data_value = EXTRACT_32BITS(++data);
+ {
+ data++;
+ data_value = EXTRACT_32BITS(data);
+ }
if ( data_value <= (attr_type[attr_code].siz_subtypes - 1 +
attr_type[attr_code].first_subtype) )
printf("{%s}",table[data_value]);
if ( data_value <= (attr_type[attr_code].siz_subtypes - 1 +
attr_type[attr_code].first_subtype) )
printf("{%s}",table[data_value]);
break;
case TUNNEL_PREFERENCE:
break;
case TUNNEL_PREFERENCE:
- if (!*data)
- printf("{Tag[Unused] %d}",EXTRACT_24BITS(++data) );
+ tag = *data;
+ data++;
+ if (tag == 0)
+ printf("{Tag[Unused] %d}",EXTRACT_24BITS(data) );
- printf("{Tag[%d] %d}", *data, EXTRACT_24BITS(++data) );
+ printf("{Tag[%d] %d}", tag, EXTRACT_24BITS(data) );
/*************************************/
static void print_attr_time(register u_char *data, u_int length, u_short attr_code)
{
/*************************************/
static void print_attr_time(register u_char *data, u_int length, u_short attr_code)
{
- printf("{%s}", ctime( ((const time_t *)EXTRACT_32BITS(data) )) );
+ attr_time = EXTRACT_32BITS(data);
+ printf("{%.24s}", ctime(&attr_time));
printf(" %s",attr_type[rad_attr->type].name);
if ( attr_type[rad_attr->type].print_func )
printf(" %s",attr_type[rad_attr->type].name);
if ( attr_type[rad_attr->type].print_func )
- (*attr_type[rad_attr->type].print_func)( ((char *)(rad_attr+1)),
+ (*attr_type[rad_attr->type].print_func)( ((u_char *)(rad_attr+1)),
rad_attr->len - 2, rad_attr->type);
}
}
rad_attr->len - 2, rad_attr->type);
}
}
printf(" [id %d]", rad->id);
if (i)
printf(" [id %d]", rad->id);
if (i)
- radius_attr_print( ((char *)(rad+1)), i);
+ radius_attr_print( ((u_char *)(rad+1)), i);