
#ifndef PWDB_RADIUS_PUBLIC_H
#define PWDB_RADIUS_PUBLIC_H

#include "../radius.h"

/* RADIUS stuff */

/* For the folowing struct, the 255 string length limit
 * is supposed to be enforced by the RADIUS server...
 */
typedef struct {
/* flags set in this structure */
            u_char flags[255];
/*  1 */	u_char user_name[255];
/*  2 */	u_char password[255];
/*  3 */	u_char chap_password[255];
/*  4 */	u_char client_id[4];
/*  5 */	u_int  client_port_id;
/*  6 */	u_int  user_service_type;
/*  7 */	u_int  framed_protocol;
/*  8 */	u_char framed_address[4];
/*  9 */	u_char framed_netmask[4];
/* 10 */	u_int  framed_routing;
/* 11 */	u_char framed_filter_id[255];
/* 12 */	u_int  framed_mtu;
/* 13 */	u_int  framed_compression;
/* 14 */	u_char login_host[4];
/* 15 */	u_int  login_service;
/* 16 */	u_int  login_tcp_port;
/* 17 */	u_char old_password[255];
/* 18 */	u_char port_message[255];
/* 19 */	u_char dialback_no[255];
/* 20 */	u_char dialback_name[255];
/* 21 */	u_int  expiration;
/* 22 */	u_char framed_route[255];
/* 23 */	u_char framed_ipx_network[4];
/* 24 */	u_char challenge_state[255];
/* 40 */	u_int  acct_status_type;
/* 41 */	u_int  acct_delay_time;
/* 42 */	u_char acct_session_id[255];
/* 43 */	u_int  acct_authentic;
/* 44 */	u_int  acct_session_time;
} RAD_USER_DATA;

/* This is the core functions we export */
int rad_authenticate (RAD_USER_DATA *, const char*, const char*);
int rad_change_passwd (RAD_USER_DATA *, const char*, const char*,
                       const char *);

/* Return codes for the above function */
#define PWDB_RADIUS_SUCCESS		0	/* success */
#define PWDB_RADIUS_CONF_ERR	1	/* configuration file error */
#define PWDB_RADIUS_AUTH_FAIL	2	/* authetication failure */
#define PWDB_RADIUS_NET_FAIL	3	/* comm. with the RADIUS server failed */
#define PWDB_RADIUS_BAD_REQ		4	/* bad request */
#define PWDB_RADIUS_RESOLV_ERR	5	/* resolver error on server hostname */
#define PWDB_RADIUS_LOCAL_ERR	6	/* local error - services file, etc. */
#define PWDB_RADIUS_SOCKET_ERR	7	/* socket creation/communication error */

/* Helper RADIUS functions */
const char * radstr_ust(u_int type);
const char * radstr_fp(u_int type);
const char * radstr_fr(u_int type);
const char * radstr_ls(u_int type); 
const char * radstr_ast(u_int type);
const char * radstr_aa(u_int type);

/* RADIUS code */
char *  ip_hostname( UINT4 );
UINT4   get_ipaddr( char * );
int     good_ipaddr( char * );
void    ipaddr2str( char *, UINT4 );
void    pairfree( VALUE_PAIR * );
UINT4   ipstr2long( char * );

/******************************************************************/

#endif /* PWDB_RADIUS_PUBLIC_H */
