#ifndef lint
static const char rcsid[] =
- "$Id: print-radius.c,v 1.13 2002-07-03 16:27:12 fenner Exp $";
+ "$Id: print-radius.c,v 1.19 2002-12-11 07:14:07 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <string.h>
-
-#include <sys/param.h>
+#include <tcpdump-stdinc.h>
-#include <netinet/in.h>
+#include <string.h>
#include <stdio.h>
-#ifdef TIME_WITH_SYS_TIME
-#include <time.h>
-#endif
-
#include "interface.h"
#include "addrtoname.h"
#include "extract.h"
};
-struct attrtype { char *name; /* Attribute name */
+struct attrtype { const char *name; /* Attribute name */
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 */
{
data_value = EXTRACT_32BITS(data);
}
- if ( data_value <= (attr_type[attr_code].siz_subtypes - 1 +
+ if ( data_value <= (u_int32_t)(attr_type[attr_code].siz_subtypes - 1 +
attr_type[attr_code].first_subtype) &&
data_value >= attr_type[attr_code].first_subtype )
printf("{%s}",table[data_value]);
else
- printf("{#%d}",data_value);
+ printf("{#%u}",data_value);
}
else
{
/*************************************/
/* Returns nothing. */
/*************************************/
-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 _U_)
{
time_t attr_time;
char string[26];
radius_print(const u_char *dat, u_int length)
{
register const struct radius_hdr *rad;
- register int i;
- int len;
+ register u_int i;
+ u_int len;
- i = min(length, snapend - dat);
+ if (snapend < dat)
+ {
+ printf(" [|radius]");
+ return;
+ }
+ i = snapend - dat;
+ if (i > length)
+ i = length;
if (i < MIN_RADIUS_LEN)
{
}
rad = (struct radius_hdr *)dat;
- len = ntohs(rad->len);
+ len = EXTRACT_16BITS(&rad->len);
if (len < MIN_RADIUS_LEN)
{
switch (rad->code)
{
case RADCMD_ACCESS_REQ:
- printf(" rad-access-req %d", length);
+ printf(" rad-access-req %u", length);
break;
case RADCMD_ACCESS_ACC:
- printf(" rad-access-accept %d", length);
+ printf(" rad-access-accept %u", length);
break;
case RADCMD_ACCESS_REJ:
- printf(" rad-access-reject %d", length);
+ printf(" rad-access-reject %u", length);
break;
case RADCMD_ACCOUN_REQ:
- printf(" rad-account-req %d", length);
+ printf(" rad-account-req %u", length);
break;
case RADCMD_ACCOUN_RES:
- printf(" rad-account-resp %d", length);
+ printf(" rad-account-resp %u", length);
break;
case RADCMD_ACCESS_CHA:
- printf(" rad-access-cha %d", length);
+ printf(" rad-access-cha %u", length);
break;
case RADCMD_STATUS_SER:
- printf(" rad-status-serv %d", length);
+ printf(" rad-status-serv %u", length);
break;
case RADCMD_STATUS_CLI:
- printf(" rad-status-cli %d", length);
+ printf(" rad-status-cli %u", length);
break;
case RADCMD_RESERVED:
- printf(" rad-reserved %d", length);
+ printf(" rad-reserved %u", length);
break;
default:
- printf(" rad-#%d %d", rad->code, length);
+ printf(" rad-#%u %u", rad->code, length);
break;
}
- printf(" [id %d]", rad->id);
+ printf(" [id %u]", rad->id);
if (i)
radius_attr_print( dat + MIN_RADIUS_LEN, i);