-#ifndef LRAD_EVENT_H
-#define LRAD_EVENT_H
+#ifndef FR_EVENT_H
+#define FR_EVENT_H
/*
* event.h Simple event queue
#include <freeradius-devel/ident.h>
RCSIDH(event_h, "$Id$")
-typedef struct lrad_event_list_t lrad_event_list_t;
-typedef struct lrad_event_t lrad_event_t;
+typedef struct fr_event_list_t fr_event_list_t;
+typedef struct fr_event_t fr_event_t;
-typedef void (*lrad_event_callback_t)(void *);
-typedef void (*lrad_event_status_t)(struct timeval *);
-typedef void (*lrad_event_fd_handler_t)(lrad_event_list_t *el, int sock, void *ctx);
+typedef void (*fr_event_callback_t)(void *);
+typedef void (*fr_event_status_t)(struct timeval *);
+typedef void (*fr_event_fd_handler_t)(fr_event_list_t *el, int sock, void *ctx);
-lrad_event_list_t *lrad_event_list_create(lrad_event_status_t status);
-void lrad_event_list_free(lrad_event_list_t *el);
+fr_event_list_t *fr_event_list_create(fr_event_status_t status);
+void fr_event_list_free(fr_event_list_t *el);
-int lrad_event_list_num_elements(lrad_event_list_t *el);
+int fr_event_list_num_elements(fr_event_list_t *el);
-int lrad_event_insert(lrad_event_list_t *el,
- lrad_event_callback_t callback,
- void *ctx, struct timeval *when, lrad_event_t **ev_p);
-int lrad_event_delete(lrad_event_list_t *el, lrad_event_t **ev_p);
+int fr_event_insert(fr_event_list_t *el,
+ fr_event_callback_t callback,
+ void *ctx, struct timeval *when, fr_event_t **ev_p);
+int fr_event_delete(fr_event_list_t *el, fr_event_t **ev_p);
-int lrad_event_run(lrad_event_list_t *el, struct timeval *when);
+int fr_event_run(fr_event_list_t *el, struct timeval *when);
-int lrad_event_now(lrad_event_list_t *el, struct timeval *when);
+int fr_event_now(fr_event_list_t *el, struct timeval *when);
-int lrad_event_fd_insert(lrad_event_list_t *el, int type, int fd,
- lrad_event_fd_handler_t handler, void *ctx);
-int lrad_event_fd_delete(lrad_event_list_t *el, int type, int fd);
-int lrad_event_loop(lrad_event_list_t *el);
-void lrad_event_loop_exit(lrad_event_list_t *el, int code);
+int fr_event_fd_insert(fr_event_list_t *el, int type, int fd,
+ fr_event_fd_handler_t handler, void *ctx);
+int fr_event_fd_delete(fr_event_list_t *el, int type, int fd);
+int fr_event_loop(fr_event_list_t *el);
+void fr_event_loop_exit(fr_event_list_t *el, int code);
-#endif /* LRAD_HASH_H */
+#endif /* FR_HASH_H */
-#ifndef LRAD_HASH_H
-#define LRAD_HASH_H
+#ifndef FR_HASH_H
+#define FR_HASH_H
/*
* hash.h Structures and prototypes
* Fast hash, which isn't too bad. Don't use for cryptography,
* just for hashing internal data.
*/
-uint32_t lrad_hash(const void *, size_t);
-uint32_t lrad_hash_update(const void *data, size_t size, uint32_t hash);
-uint32_t lrad_hash_string(const char *p);
+uint32_t fr_hash(const void *, size_t);
+uint32_t fr_hash_update(const void *data, size_t size, uint32_t hash);
+uint32_t fr_hash_string(const char *p);
/*
* If you need fewer than 32-bits of hash, use this macro to get
* the number of bits in the hash you need. The upper bits of the
* hash will be set to zero.
*/
-uint32_t lrad_hash_fold(uint32_t hash, int bits);
+uint32_t fr_hash_fold(uint32_t hash, int bits);
-typedef struct lrad_hash_table_t lrad_hash_table_t;
-typedef void (*lrad_hash_table_free_t)(void *);
-typedef uint32_t (*lrad_hash_table_hash_t)(const void *);
-typedef int (*lrad_hash_table_cmp_t)(const void *, const void *);
-typedef int (*lrad_hash_table_walk_t)(void * /* ctx */, void * /* data */);
+typedef struct fr_hash_table_t fr_hash_table_t;
+typedef void (*fr_hash_table_free_t)(void *);
+typedef uint32_t (*fr_hash_table_hash_t)(const void *);
+typedef int (*fr_hash_table_cmp_t)(const void *, const void *);
+typedef int (*fr_hash_table_walk_t)(void * /* ctx */, void * /* data */);
-lrad_hash_table_t *lrad_hash_table_create(lrad_hash_table_hash_t hashNode,
- lrad_hash_table_cmp_t cmpNode,
- lrad_hash_table_free_t freeNode);
-void lrad_hash_table_free(lrad_hash_table_t *ht);
-int lrad_hash_table_insert(lrad_hash_table_t *ht, void *data);
-int lrad_hash_table_delete(lrad_hash_table_t *ht, const void *data);
-void *lrad_hash_table_yank(lrad_hash_table_t *ht, const void *data);
-int lrad_hash_table_replace(lrad_hash_table_t *ht, void *data);
-void *lrad_hash_table_finddata(lrad_hash_table_t *ht, const void *data);
-int lrad_hash_table_num_elements(lrad_hash_table_t *ht);
-int lrad_hash_table_walk(lrad_hash_table_t *ht,
- lrad_hash_table_walk_t callback,
+fr_hash_table_t *fr_hash_table_create(fr_hash_table_hash_t hashNode,
+ fr_hash_table_cmp_t cmpNode,
+ fr_hash_table_free_t freeNode);
+void fr_hash_table_free(fr_hash_table_t *ht);
+int fr_hash_table_insert(fr_hash_table_t *ht, void *data);
+int fr_hash_table_delete(fr_hash_table_t *ht, const void *data);
+void *fr_hash_table_yank(fr_hash_table_t *ht, const void *data);
+int fr_hash_table_replace(fr_hash_table_t *ht, void *data);
+void *fr_hash_table_finddata(fr_hash_table_t *ht, const void *data);
+int fr_hash_table_num_elements(fr_hash_table_t *ht);
+int fr_hash_table_walk(fr_hash_table_t *ht,
+ fr_hash_table_walk_t callback,
void *ctx);
-#endif /* LRAD_HASH_H */
+#endif /* FR_HASH_H */
int vendor;
int type;
int length; /* of data */
- LRAD_TOKEN operator;
+ FR_TOKEN operator;
ATTR_FLAGS flags;
struct value_pair *next;
uint32_t lvalue;
#endif
-typedef struct lrad_ipaddr_t {
+typedef struct fr_ipaddr_t {
int af; /* address family */
union {
struct in_addr ip4addr;
struct in6_addr ip6addr; /* maybe defined in missing.h */
} ipaddr;
-} lrad_ipaddr_t;
+} fr_ipaddr_t;
/*
* vector: Request authenticator from access-request packet
*/
typedef struct radius_packet {
int sockfd;
- lrad_ipaddr_t src_ipaddr;
- lrad_ipaddr_t dst_ipaddr;
+ fr_ipaddr_t src_ipaddr;
+ fr_ipaddr_t dst_ipaddr;
uint16_t src_port;
uint16_t dst_port;
int id;
int rad_send(RADIUS_PACKET *, const RADIUS_PACKET *, const char *secret);
int rad_packet_ok(RADIUS_PACKET *packet);
RADIUS_PACKET *rad_recv(int fd);
-ssize_t rad_recv_header(int sockfd, lrad_ipaddr_t *src_ipaddr, int *src_port,
+ssize_t rad_recv_header(int sockfd, fr_ipaddr_t *src_ipaddr, int *src_port,
int *code);
void rad_recv_discard(int sockfd);
int rad_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original,
void pairmove2(VALUE_PAIR **to, VALUE_PAIR **from, int attr);
VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value);
VALUE_PAIR *pairmake(const char *attribute, const char *value, int operator);
-VALUE_PAIR *pairread(char **ptr, LRAD_TOKEN *eol);
-LRAD_TOKEN userparse(char *buffer, VALUE_PAIR **first_pair);
+VALUE_PAIR *pairread(char **ptr, FR_TOKEN *eol);
+FR_TOKEN userparse(char *buffer, VALUE_PAIR **first_pair);
VALUE_PAIR *readvp2(FILE *fp, int *pfiledone, const char *errprefix);
/*
int rad_lockfd(int fd, int lock_len);
int rad_lockfd_nonblock(int fd, int lock_len);
int rad_unlockfd(int fd, int lock_len);
-void lrad_bin2hex(const uint8_t *bin, char *hex, int len);
-int lrad_hex2bin(const char *hex, uint8_t *bin, int len);
+void fr_bin2hex(const uint8_t *bin, char *hex, int len);
+int fr_hex2bin(const char *hex, uint8_t *bin, int len);
#ifndef HAVE_INET_PTON
int inet_pton(int af, const char *src, void *dst);
#endif
#ifndef HAVE_CLOSEFROM
int closefrom(int fd);
#endif
-int lrad_ipaddr_cmp(const lrad_ipaddr_t *a, const lrad_ipaddr_t *b);
+int fr_ipaddr_cmp(const fr_ipaddr_t *a, const fr_ipaddr_t *b);
-int ip_hton(const char *src, int af, lrad_ipaddr_t *dst);
-const char *ip_ntoh(const lrad_ipaddr_t *src, char *dst, size_t cnt);
+int ip_hton(const char *src, int af, fr_ipaddr_t *dst);
+const char *ip_ntoh(const fr_ipaddr_t *src, char *dst, size_t cnt);
/* random numbers in isaac.c */
/* context of random number generator */
-typedef struct lrad_randctx {
+typedef struct fr_randctx {
uint32_t randcnt;
uint32_t randrsl[256];
uint32_t randmem[256];
uint32_t randa;
uint32_t randb;
uint32_t randc;
-} lrad_randctx;
+} fr_randctx;
-void lrad_isaac(lrad_randctx *ctx);
-void lrad_randinit(lrad_randctx *ctx, int flag);
-uint32_t lrad_rand(void); /* like rand(), but better. */
-void lrad_rand_seed(const void *, size_t ); /* seed the random pool */
+void fr_isaac(fr_randctx *ctx);
+void fr_randinit(fr_randctx *ctx, int flag);
+uint32_t fr_rand(void); /* like rand(), but better. */
+void fr_rand_seed(const void *, size_t ); /* seed the random pool */
/* crypt wrapper from crypt.c */
-int lrad_crypt_check(const char *key, const char *salt);
+int fr_crypt_check(const char *key, const char *salt);
/* rbtree.c */
typedef struct rbtree_t rbtree_t;
/*
* FIFOs
*/
-typedef struct lrad_fifo_t lrad_fifo_t;
-typedef void (*lrad_fifo_free_t)(void *);
-lrad_fifo_t *lrad_fifo_create(int max_entries, lrad_fifo_free_t freeNode);
-void lrad_fifo_free(lrad_fifo_t *fi);
-int lrad_fifo_push(lrad_fifo_t *fi, void *data);
-void *lrad_fifo_pop(lrad_fifo_t *fi);
-void *lrad_fifo_peek(lrad_fifo_t *fi);
-int lrad_fifo_num_elements(lrad_fifo_t *fi);
+typedef struct fr_fifo_t fr_fifo_t;
+typedef void (*fr_fifo_free_t)(void *);
+fr_fifo_t *fr_fifo_create(int max_entries, fr_fifo_free_t freeNode);
+void fr_fifo_free(fr_fifo_t *fi);
+int fr_fifo_push(fr_fifo_t *fi, void *data);
+void *fr_fifo_pop(fr_fifo_t *fi);
+void *fr_fifo_peek(fr_fifo_t *fi);
+int fr_fifo_num_elements(fr_fifo_t *fi);
#include <freeradius-devel/packet.h>
*
*/
-#ifndef _LRAD_MD4_H
-#define _LRAD_MD4_H
+#ifndef _FR_MD4_H
+#define _FR_MD4_H
#include <freeradius-devel/ident.h>
RCSIDH(md4_h, "$Id$")
__attribute__((__bounded__(__minbytes__,2,MD4_BLOCK_LENGTH)))*/;
/*__END_DECLS*/
-#endif /* _LRAD_MD4_H */
+#endif /* _FR_MD4_H */
*
*/
-#ifndef _LRAD_MD5_H
-#define _LRAD_MD5_H
+#ifndef _FR_MD5_H
+#define _FR_MD5_H
#include <freeradius-devel/ident.h>
RCSIDH(md5_h, "$Id$")
/* __attribute__((__bounded__(__minbytes__,2,MD5_BLOCK_LENGTH)))*/;
/* __END_DECLS */
-#endif /* _LRAD_MD5_H */
+#endif /* _FR_MD5_H */
-#ifndef LRAD_PACKET_H
-#define LRAD_PACKET_H
+#ifndef FR_PACKET_H
+#define FR_PACKET_H
/*
* packet.h Structures and prototypes
#include <freeradius-devel/ident.h>
RCSIDH(packet_h, "$Id$")
-uint32_t lrad_request_packet_hash(const RADIUS_PACKET *packet);
-uint32_t lrad_reply_packet_hash(const RADIUS_PACKET *packet);
-int lrad_packet_cmp(const RADIUS_PACKET *a, const RADIUS_PACKET *b);
-void lrad_request_from_reply(RADIUS_PACKET *request,
+uint32_t fr_request_packet_hash(const RADIUS_PACKET *packet);
+uint32_t fr_reply_packet_hash(const RADIUS_PACKET *packet);
+int fr_packet_cmp(const RADIUS_PACKET *a, const RADIUS_PACKET *b);
+void fr_request_from_reply(RADIUS_PACKET *request,
const RADIUS_PACKET *reply);
-int lrad_socket(lrad_ipaddr_t *ipaddr, int port);
+int fr_socket(fr_ipaddr_t *ipaddr, int port);
-typedef struct lrad_packet_list_t lrad_packet_list_t;
+typedef struct fr_packet_list_t fr_packet_list_t;
-lrad_packet_list_t *lrad_packet_list_create(int alloc_id);
-void lrad_packet_list_free(lrad_packet_list_t *pl);
-int lrad_packet_list_insert(lrad_packet_list_t *pl,
+fr_packet_list_t *fr_packet_list_create(int alloc_id);
+void fr_packet_list_free(fr_packet_list_t *pl);
+int fr_packet_list_insert(fr_packet_list_t *pl,
RADIUS_PACKET **request_p);
-RADIUS_PACKET **lrad_packet_list_find(lrad_packet_list_t *pl,
+RADIUS_PACKET **fr_packet_list_find(fr_packet_list_t *pl,
RADIUS_PACKET *request);
-RADIUS_PACKET **lrad_packet_list_find_byreply(lrad_packet_list_t *pl,
+RADIUS_PACKET **fr_packet_list_find_byreply(fr_packet_list_t *pl,
RADIUS_PACKET *reply);
-RADIUS_PACKET **lrad_packet_list_yank(lrad_packet_list_t *pl,
+RADIUS_PACKET **fr_packet_list_yank(fr_packet_list_t *pl,
RADIUS_PACKET *request);
-int lrad_packet_list_num_elements(lrad_packet_list_t *pl);
-int lrad_packet_list_id_alloc(lrad_packet_list_t *pl,
+int fr_packet_list_num_elements(fr_packet_list_t *pl);
+int fr_packet_list_id_alloc(fr_packet_list_t *pl,
RADIUS_PACKET *request);
-int lrad_packet_list_id_free(lrad_packet_list_t *pl,
+int fr_packet_list_id_free(fr_packet_list_t *pl,
RADIUS_PACKET *request);
-int lrad_packet_list_socket_add(lrad_packet_list_t *pl, int sockfd);
-int lrad_packet_list_socket_remove(lrad_packet_list_t *pl, int sockfd);
-int lrad_packet_list_walk(lrad_packet_list_t *pl, void *ctx,
- lrad_hash_table_walk_t callback);
-int lrad_packet_list_fd_set(lrad_packet_list_t *pl, fd_set *set);
-RADIUS_PACKET *lrad_packet_list_recv(lrad_packet_list_t *pl, fd_set *set);
+int fr_packet_list_socket_add(fr_packet_list_t *pl, int sockfd);
+int fr_packet_list_socket_remove(fr_packet_list_t *pl, int sockfd);
+int fr_packet_list_walk(fr_packet_list_t *pl, void *ctx,
+ fr_hash_table_walk_t callback);
+int fr_packet_list_fd_set(fr_packet_list_t *pl, fd_set *set);
+RADIUS_PACKET *fr_packet_list_recv(fr_packet_list_t *pl, fd_set *set);
-int lrad_packet_list_num_incoming(lrad_packet_list_t *pl);
-int lrad_packet_list_num_outgoing(lrad_packet_list_t *pl);
+int fr_packet_list_num_incoming(fr_packet_list_t *pl);
+int fr_packet_list_num_outgoing(fr_packet_list_t *pl);
#ifndef offsetof
* the member from the returned pointer, and cast it to the
* required type.
*/
-# define lrad_packet2myptr(TYPE, MEMBER, PTR) (TYPE *) (((char *)PTR) - offsetof(TYPE, MEMBER))
-#endif /* LRAD_PACKET_H */
+# define fr_packet2myptr(TYPE, MEMBER, PTR) (TYPE *) (((char *)PTR) - offsetof(TYPE, MEMBER))
+#endif /* FR_PACKET_H */
typedef struct rad_snmp_client_entry_t rad_snmp_client_entry_t;
typedef struct radclient {
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
int prefix;
char *longname;
char *secret;
int child_state;
RAD_LISTEN_TYPE priority;
- lrad_event_t *ev;
+ fr_event_t *ev;
struct timeval next_when;
- lrad_event_callback_t next_callback;
+ fr_event_callback_t next_callback;
int in_request_hash;
int in_proxy_hash;
typedef struct main_config_t {
struct main_config *next;
int refcount;
- lrad_ipaddr_t myip; /* from the command-line only */
+ fr_ipaddr_t myip; /* from the command-line only */
int port; /* from the command-line only */
int log_auth;
int log_auth_badpass;
void client_free(RADCLIENT *client);
int client_add(RADCLIENT_LIST *clients, RADCLIENT *client);
RADCLIENT *client_find(const RADCLIENT_LIST *clients,
- const lrad_ipaddr_t *ipaddr);
+ const fr_ipaddr_t *ipaddr);
const char *client_name(const RADCLIENT_LIST *clients,
- const lrad_ipaddr_t *ipaddr);
+ const fr_ipaddr_t *ipaddr);
RADCLIENT *client_findbynumber(const RADCLIENT_LIST *clients,
int number);
-RADCLIENT *client_find_old(const lrad_ipaddr_t *ipaddr);
-const char *client_name_old(const lrad_ipaddr_t *ipaddr);
+RADCLIENT *client_find_old(const fr_ipaddr_t *ipaddr);
+const char *client_name_old(const fr_ipaddr_t *ipaddr);
/* files.c */
int pairlist_read(const char *file, PAIR_LIST **list, int complain);
const char *hostname;
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
int port;
const char *secret;
- lrad_event_t *ev;
+ fr_event_t *ev;
struct timeval when;
int response_window;
REALM *realm_find(const char *name);
home_server *home_server_ldb(const char *realmname, home_pool_t *pool, REQUEST *request);
-home_server *home_server_find(lrad_ipaddr_t *ipaddr, int port);
+home_server *home_server_find(fr_ipaddr_t *ipaddr, int port);
#endif /* REALMS_H */
-#ifndef _LRAD_SHA1_H
-#define _LRAD_SHA1_H
+#ifndef _FR_SHA1_H
+#define _FR_SHA1_H
/*
* FreeRADIUS defines to ensure globally unique SHA1 function names,
extern void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160]);
-#endif /* _LRAD_SHA1_H */
+#endif /* _FR_SHA1_H */
-#ifndef LRAD_TOKEN_H
-#define LRAD_TOKEN_H
+#ifndef FR_TOKEN_H
+#define FR_TOKEN_H
/*
* token.h Special tokens.
#include <freeradius-devel/ident.h>
RCSIDH(token_h, "$Id$")
-typedef enum lrad_token_t {
+typedef enum fr_token_t {
T_OP_INVALID = 0, /* invalid token */
T_EOL, /* end of line */
T_LCBRACE, /* { */
T_SINGLE_QUOTED_STRING, /* 'foo' 25 */
T_BACK_QUOTED_STRING, /* `foo` */
T_TOKEN_LAST
-} LRAD_TOKEN;
+} FR_TOKEN;
#define T_EQSTART T_OP_ADD
#define T_EQEND (T_OP_CMP_EQ + 1)
-typedef struct LRAD_NAME_NUMBER {
+typedef struct FR_NAME_NUMBER {
const char *name;
int number;
-} LRAD_NAME_NUMBER;
+} FR_NAME_NUMBER;
-int lrad_str2int(const LRAD_NAME_NUMBER *table, const char *name, int def);
-const char *lrad_int2str(const LRAD_NAME_NUMBER *table, int number,
+int fr_str2int(const FR_NAME_NUMBER *table, const char *name, int def);
+const char *fr_int2str(const FR_NAME_NUMBER *table, int number,
const char *def);
int getword (char **ptr, char *buf, int buflen);
int getbareword (char **ptr, char *buf, int buflen);
-LRAD_TOKEN gettoken(char **ptr, char *buf, int buflen);
-LRAD_TOKEN getstring(char **ptr, char *buf, int buflen);
+FR_TOKEN gettoken(char **ptr, char *buf, int buflen);
+FR_TOKEN getstring(char **ptr, char *buf, int buflen);
-#endif /* LRAD_TOKEN_H */
+#endif /* FR_TOKEN_H */
-#ifndef LRAD_VQP_H
-#define LRAD_VQP_H
+#ifndef FR_VQP_H
+#define FR_VQP_H
/*
* vqp.h Structures and prototypes for Cisco's VLAN Query Protocol
int vqp_decode(RADIUS_PACKET *packet);
int vqp_encode(RADIUS_PACKET *packet, RADIUS_PACKET *original);
-#endif /* LRAD_VQP_H */
+#endif /* FR_VQP_H */
#define DICT_VALUE_MAX_NAME_LEN (128)
#define DICT_VENDOR_MAX_NAME_LEN (128)
-static lrad_hash_table_t *vendors_byname = NULL;
-static lrad_hash_table_t *vendors_byvalue = NULL;
+static fr_hash_table_t *vendors_byname = NULL;
+static fr_hash_table_t *vendors_byvalue = NULL;
-static lrad_hash_table_t *attributes_byname = NULL;
-static lrad_hash_table_t *attributes_byvalue = NULL;
+static fr_hash_table_t *attributes_byname = NULL;
+static fr_hash_table_t *attributes_byvalue = NULL;
-static lrad_hash_table_t *values_byvalue = NULL;
-static lrad_hash_table_t *values_byname = NULL;
+static fr_hash_table_t *values_byvalue = NULL;
+static fr_hash_table_t *values_byname = NULL;
static DICT_ATTR *dict_base_attrs[256];
*/
static value_fixup_t *value_fixup = NULL;
-static const LRAD_NAME_NUMBER type_table[] = {
+static const FR_NAME_NUMBER type_table[] = {
{ "integer", PW_TYPE_INTEGER },
{ "string", PW_TYPE_STRING },
{ "ipaddr", PW_TYPE_IPADDR },
uint32_t hash;
const DICT_ATTR *attr = data;
- hash = lrad_hash(&attr->vendor, sizeof(attr->vendor));
- return lrad_hash_update(&attr->attr, sizeof(attr->attr), hash);
+ hash = fr_hash(&attr->vendor, sizeof(attr->vendor));
+ return fr_hash_update(&attr->attr, sizeof(attr->attr), hash);
}
static int dict_attr_value_cmp(const void *one, const void *two)
static uint32_t dict_vendor_value_hash(const void *data)
{
- return lrad_hash(&(((const DICT_VENDOR *)data)->vendorpec),
+ return fr_hash(&(((const DICT_VENDOR *)data)->vendorpec),
sizeof(((const DICT_VENDOR *)data)->vendorpec));
}
const DICT_VALUE *dval = data;
hash = dict_hashname(dval->name);
- return lrad_hash_update(&dval->attr, sizeof(dval->attr), hash);
+ return fr_hash_update(&dval->attr, sizeof(dval->attr), hash);
}
static int dict_value_name_cmp(const void *one, const void *two)
uint32_t hash;
const DICT_VALUE *dval = data;
- hash = lrad_hash(&dval->attr, sizeof(dval->attr));
- return lrad_hash_update(&dval->value, sizeof(dval->value), hash);
+ hash = fr_hash(&dval->attr, sizeof(dval->attr));
+ return fr_hash_update(&dval->value, sizeof(dval->value), hash);
}
static int dict_value_value_cmp(const void *one, const void *two)
/*
* Free the tables
*/
- lrad_hash_table_free(vendors_byname);
- lrad_hash_table_free(vendors_byvalue);
+ fr_hash_table_free(vendors_byname);
+ fr_hash_table_free(vendors_byvalue);
vendors_byname = NULL;
vendors_byvalue = NULL;
- lrad_hash_table_free(attributes_byname);
- lrad_hash_table_free(attributes_byvalue);
+ fr_hash_table_free(attributes_byname);
+ fr_hash_table_free(attributes_byvalue);
attributes_byname = NULL;
attributes_byvalue = NULL;
- lrad_hash_table_free(values_byname);
- lrad_hash_table_free(values_byvalue);
+ fr_hash_table_free(values_byname);
+ fr_hash_table_free(values_byvalue);
values_byname = NULL;
values_byvalue = NULL;
dv->vendorpec = value;
dv->type = dv->length = 1; /* defaults */
- if (!lrad_hash_table_insert(vendors_byname, dv)) {
+ if (!fr_hash_table_insert(vendors_byname, dv)) {
DICT_VENDOR *old_dv;
- old_dv = lrad_hash_table_finddata(vendors_byname, dv);
+ old_dv = fr_hash_table_finddata(vendors_byname, dv);
if (!old_dv) {
librad_log("dict_addvendor: Failed inserting vendor name %s", name);
return -1;
* files, but when we're printing them, (and looking up
* by value) we want to use the NEW name.
*/
- if (!lrad_hash_table_replace(vendors_byvalue, dv)) {
+ if (!fr_hash_table_replace(vendors_byvalue, dv)) {
librad_log("dict_addvendor: Failed inserting vendor %s",
name);
return -1;
/*
* Insert the attribute, only if it's not a duplicate.
*/
- if (!lrad_hash_table_insert(attributes_byname, attr)) {
+ if (!fr_hash_table_insert(attributes_byname, attr)) {
DICT_ATTR *a;
/*
* If the attribute has identical number, then
* ignore the duplicate.
*/
- a = lrad_hash_table_finddata(attributes_byname, attr);
+ a = fr_hash_table_finddata(attributes_byname, attr);
if (a && (strcasecmp(a->name, attr->name) == 0)) {
if (a->attr != attr->attr) {
librad_log("dict_addattr: Duplicate attribute name %s", name);
}
- lrad_hash_table_delete(attributes_byvalue, a);
+ fr_hash_table_delete(attributes_byvalue, a);
- if (!lrad_hash_table_replace(attributes_byname, attr)) {
+ if (!fr_hash_table_replace(attributes_byname, attr)) {
librad_log("dict_addattr: Internal error storing attribute %s", name);
fr_pool_free(attr);
return -1;
* files, but when we're printing them, (and looking up
* by value) we want to use the NEW name.
*/
- if (!lrad_hash_table_replace(attributes_byvalue, attr)) {
+ if (!fr_hash_table_replace(attributes_byvalue, attr)) {
librad_log("dict_addattr: Failed inserting attribute name %s", name);
return -1;
}
default:
fr_pool_free(dval);
librad_log("dict_addvalue: VALUEs cannot be defined for attributes of type '%s'",
- lrad_int2str(type_table, dattr->type, "?Unknown?"));
+ fr_int2str(type_table, dattr->type, "?Unknown?"));
return -1;
}
/*
* Add the value into the dictionary.
*/
- if (!lrad_hash_table_insert(values_byname, dval)) {
+ if (!fr_hash_table_insert(values_byname, dval)) {
if (dattr) {
DICT_VALUE *old;
* There are multiple VALUE's, keyed by attribute, so we
* take care of that here.
*/
- if (!lrad_hash_table_replace(values_byvalue, dval)) {
+ if (!fr_hash_table_replace(values_byvalue, dval)) {
librad_log("dict_addvalue: Failed inserting value %s",
namestr);
return -1;
/*
* find the type of the attribute.
*/
- type = lrad_str2int(type_table, argv[2], -1);
+ type = fr_str2int(type_table, argv[2], -1);
if (type < 0) {
librad_log("dict_init: %s[%d]: invalid type \"%s\"",
fn, line, argv[2]);
default:
librad_log("dict_init: %s[%d]: Attributes of type %s cannot be tagged.",
fn, line,
- lrad_int2str(type_table, type, "?Unknown?"));
+ fr_int2str(type_table, type, "?Unknown?"));
return -1;
}
dval->attr = my_da->attr;
dval->value = da->attr;
- if (!lrad_hash_table_insert(values_byname, dval)) {
+ if (!fr_hash_table_insert(values_byname, dval)) {
librad_log("dict_init: %s[%d]: Error create alias",
fn, line);
fr_pool_free(dval);
/*
* Seed the random pool with data.
*/
- lrad_rand_seed(&statbuf, sizeof(statbuf));
+ fr_rand_seed(&statbuf, sizeof(statbuf));
block_vendor = 0;
*
* Each vendor is malloc'd, so the free function is free.
*/
- vendors_byname = lrad_hash_table_create(dict_vendor_name_hash,
+ vendors_byname = fr_hash_table_create(dict_vendor_name_hash,
dict_vendor_name_cmp,
fr_pool_free);
if (!vendors_byname) {
* be vendors of the same value. If there are, we
* pick the latest one.
*/
- vendors_byvalue = lrad_hash_table_create(dict_vendor_value_hash,
+ vendors_byvalue = fr_hash_table_create(dict_vendor_value_hash,
dict_vendor_value_cmp,
fr_pool_free);
if (!vendors_byvalue) {
*
* Each attribute is malloc'd, so the free function is free.
*/
- attributes_byname = lrad_hash_table_create(dict_attr_name_hash,
+ attributes_byname = fr_hash_table_create(dict_attr_name_hash,
dict_attr_name_cmp,
fr_pool_free);
if (!attributes_byname) {
* be attributes of the same value. If there are, we
* pick the latest one.
*/
- attributes_byvalue = lrad_hash_table_create(dict_attr_value_hash,
+ attributes_byvalue = fr_hash_table_create(dict_attr_value_hash,
dict_attr_value_cmp,
fr_pool_free);
if (!attributes_byvalue) {
return -1;
}
- values_byname = lrad_hash_table_create(dict_value_name_hash,
+ values_byname = fr_hash_table_create(dict_value_name_hash,
dict_value_name_cmp,
fr_pool_free);
if (!values_byname) {
return -1;
}
- values_byvalue = lrad_hash_table_create(dict_value_value_hash,
+ values_byvalue = fr_hash_table_create(dict_value_value_hash,
dict_value_value_cmp,
fr_pool_free);
if (!values_byvalue) {
/*
* Add the value into the dictionary.
*/
- if (!lrad_hash_table_replace(values_byname,
+ if (!fr_hash_table_replace(values_byname,
this->dval)) {
librad_log("dict_addvalue: Duplicate value name %s for attribute %s", this->dval->name, a->name);
return -1;
* prefer the new name when printing
* values.
*/
- if (!lrad_hash_table_finddata(values_byvalue, this->dval)) {
- lrad_hash_table_replace(values_byvalue,
+ if (!fr_hash_table_finddata(values_byvalue, this->dval)) {
+ fr_hash_table_replace(values_byvalue,
this->dval);
}
free(this);
* lookups, and we don't want multi-threaded re-ordering
* of the table entries. That would be bad.
*/
- lrad_hash_table_walk(vendors_byname, null_callback, NULL);
- lrad_hash_table_walk(vendors_byvalue, null_callback, NULL);
+ fr_hash_table_walk(vendors_byname, null_callback, NULL);
+ fr_hash_table_walk(vendors_byvalue, null_callback, NULL);
- lrad_hash_table_walk(attributes_byname, null_callback, NULL);
- lrad_hash_table_walk(attributes_byvalue, null_callback, NULL);
+ fr_hash_table_walk(attributes_byname, null_callback, NULL);
+ fr_hash_table_walk(attributes_byvalue, null_callback, NULL);
- lrad_hash_table_walk(values_byvalue, null_callback, NULL);
- lrad_hash_table_walk(values_byname, null_callback, NULL);
+ fr_hash_table_walk(values_byvalue, null_callback, NULL);
+ fr_hash_table_walk(values_byname, null_callback, NULL);
return 0;
}
dattr.attr = attr;
dattr.vendor = VENDOR(attr) & 0x7fff;
- return lrad_hash_table_finddata(attributes_byvalue, &dattr);
+ return fr_hash_table_finddata(attributes_byvalue, &dattr);
}
/*
strlcpy(dattr.name, name, sizeof(dattr.name));
- return lrad_hash_table_finddata(attributes_byname, &dattr);
+ return fr_hash_table_finddata(attributes_byname, &dattr);
}
/*
* Look up the attribute alias target, and use
* the correct attribute number if found.
*/
- dv = lrad_hash_table_finddata(values_byname, &dval);
+ dv = fr_hash_table_finddata(values_byname, &dval);
if (dv) dval.attr = dv->value;
dval.value = value;
- return lrad_hash_table_finddata(values_byvalue, &dval);
+ return fr_hash_table_finddata(values_byvalue, &dval);
}
/*
* Look up the attribute alias target, and use
* the correct attribute number if found.
*/
- dv = lrad_hash_table_finddata(values_byname, my_dv);
+ dv = fr_hash_table_finddata(values_byname, my_dv);
if (dv) my_dv->attr = dv->value;
strlcpy(my_dv->name, name, DICT_VALUE_MAX_NAME_LEN);
- return lrad_hash_table_finddata(values_byname, my_dv);
+ return fr_hash_table_finddata(values_byname, my_dv);
}
/*
dv = (DICT_VENDOR *) buffer;
strlcpy(dv->name, name, DICT_VENDOR_MAX_NAME_LEN);
- dv = lrad_hash_table_finddata(vendors_byname, dv);
+ dv = fr_hash_table_finddata(vendors_byname, dv);
if (!dv) return 0;
return dv->vendorpec;
dv.vendorpec = vendorpec;
- return lrad_hash_table_finddata(vendors_byvalue, &dv);
+ return fr_hash_table_finddata(vendors_byvalue, &dv);
}
#include <freeradius-devel/libradius.h>
#include <freeradius-devel/event.h>
-typedef struct lrad_event_fd_t {
+typedef struct fr_event_fd_t {
int fd;
- lrad_event_fd_handler_t handler;
+ fr_event_fd_handler_t handler;
void *ctx;
-} lrad_event_fd_t;
+} fr_event_fd_t;
-struct lrad_event_list_t {
+struct fr_event_list_t {
rbtree_t *times;
rbtree_t *readers;
int exit;
- lrad_event_status_t status;
+ fr_event_status_t status;
struct timeval now;
int dispatch;
/*
* Internal structure for managing events.
*/
-struct lrad_event_t {
- lrad_event_callback_t callback;
+struct fr_event_t {
+ fr_event_callback_t callback;
void *ctx;
struct timeval when;
- lrad_event_t **ev_p;
+ fr_event_t **ev_p;
rbnode_t *node;
};
-static int lrad_event_list_time_cmp(const void *one, const void *two)
+static int fr_event_list_time_cmp(const void *one, const void *two)
{
- const lrad_event_t *a = one;
- const lrad_event_t *b = two;
+ const fr_event_t *a = one;
+ const fr_event_t *b = two;
if (a->when.tv_sec < b->when.tv_sec) return -1;
if (a->when.tv_sec > b->when.tv_sec) return +1;
}
-static int lrad_event_list_fd_cmp(const void *one, const void *two)
+static int fr_event_list_fd_cmp(const void *one, const void *two)
{
- const lrad_event_fd_t *a = one;
- const lrad_event_fd_t *b = two;
+ const fr_event_fd_t *a = one;
+ const fr_event_fd_t *b = two;
return a->fd - b->fd;
}
-void lrad_event_list_free(lrad_event_list_t *el)
+void fr_event_list_free(fr_event_list_t *el)
{
if (!el) return;
}
-lrad_event_list_t *lrad_event_list_create(lrad_event_status_t status)
+fr_event_list_t *fr_event_list_create(fr_event_status_t status)
{
- lrad_event_list_t *el;
+ fr_event_list_t *el;
el = malloc(sizeof(*el));
if (!el) return NULL;
memset(el, 0, sizeof(*el));
- el->times = rbtree_create(lrad_event_list_time_cmp,
+ el->times = rbtree_create(fr_event_list_time_cmp,
free, 0);
if (!el->times) {
- lrad_event_list_free(el);
+ fr_event_list_free(el);
return NULL;
}
- el->readers = rbtree_create(lrad_event_list_fd_cmp,
+ el->readers = rbtree_create(fr_event_list_fd_cmp,
free, 0);
if (!el->readers) {
- lrad_event_list_free(el);
+ fr_event_list_free(el);
return NULL;
}
return el;
}
-int lrad_event_list_num_elements(lrad_event_list_t *el)
+int fr_event_list_num_elements(fr_event_list_t *el)
{
if (!el) return 0;
}
-int lrad_event_delete(lrad_event_list_t *el, lrad_event_t **ev_p)
+int fr_event_delete(fr_event_list_t *el, fr_event_t **ev_p)
{
- lrad_event_t *ev;
+ fr_event_t *ev;
if (!el || !ev_p || !*ev_p) return 0;
}
-int lrad_event_insert(lrad_event_list_t *el,
- lrad_event_callback_t callback,
+int fr_event_insert(fr_event_list_t *el,
+ fr_event_callback_t callback,
void *ctx, struct timeval *when,
- lrad_event_t **ev_p)
+ fr_event_t **ev_p)
{
- lrad_event_t *ev;
+ fr_event_t *ev;
if (!el || !callback | !when) return 0;
- if (ev_p && *ev_p) lrad_event_delete(el, ev_p);
+ if (ev_p && *ev_p) fr_event_delete(el, ev_p);
ev = malloc(sizeof(*ev));
if (!ev) return 0;
}
-int lrad_event_run(lrad_event_list_t *el, struct timeval *when)
+int fr_event_run(fr_event_list_t *el, struct timeval *when)
{
- lrad_event_callback_t callback;
+ fr_event_callback_t callback;
void *ctx;
- lrad_event_t *ev;
+ fr_event_t *ev;
if (!el) return 0;
/*
* Delete the event before calling it.
*/
- lrad_event_delete(el, &ev);
+ fr_event_delete(el, &ev);
callback(ctx);
return 1;
}
-int lrad_event_now(lrad_event_list_t *el, struct timeval *when)
+int fr_event_now(fr_event_list_t *el, struct timeval *when)
{
if (!el || !when || !el->dispatch) return 0;
}
-int lrad_event_fd_insert(lrad_event_list_t *el, int type, int fd,
- lrad_event_fd_handler_t handler, void *ctx)
+int fr_event_fd_insert(fr_event_list_t *el, int type, int fd,
+ fr_event_fd_handler_t handler, void *ctx)
{
- lrad_event_fd_t *ef;
+ fr_event_fd_t *ef;
if (!el || (fd < 0) || !handler || !ctx) return 0;
return 1;
}
-int lrad_event_fd_delete(lrad_event_list_t *el, int type, int fd)
+int fr_event_fd_delete(fr_event_list_t *el, int type, int fd)
{
- lrad_event_fd_t my_ef;
+ fr_event_fd_t my_ef;
if (!el || (fd < 0)) return 0;
}
-void lrad_event_loop_exit(lrad_event_list_t *el, int code)
+void fr_event_loop_exit(fr_event_list_t *el, int code)
{
if (!el) return;
}
-static int lrad_event_fd_set(void *ctx, void *data)
+static int fr_event_fd_set(void *ctx, void *data)
{
fd_set *fds = ctx;
- lrad_event_fd_t *ef = data;
+ fr_event_fd_t *ef = data;
if (ef->fd < 0) return 0; /* ignore it */
return 0; /* continue walking */
}
-typedef struct lrad_fd_walk_t {
- lrad_event_list_t *el;
+typedef struct fr_fd_walk_t {
+ fr_event_list_t *el;
fd_set *fds;
-} lrad_fd_walk_t;
+} fr_fd_walk_t;
-static int lrad_event_fd_dispatch(void *ctx, void *data)
+static int fr_event_fd_dispatch(void *ctx, void *data)
{
- lrad_fd_walk_t *ew = ctx;
- lrad_event_fd_t *ef = data;
+ fr_fd_walk_t *ew = ctx;
+ fr_event_fd_t *ef = data;
if (ef->fd < 0) return 0;
}
-int lrad_event_loop(lrad_event_list_t *el)
+int fr_event_loop(fr_event_list_t *el)
{
int rcode;
fd_set read_fds;
struct timeval when, *wake;
- lrad_fd_walk_t ew;
+ fr_fd_walk_t ew;
/*
* Cache the list of FD's to watch.
if (el->changed) {
FD_ZERO(&el->read_fds);
- rbtree_walk(el->readers, InOrder, lrad_event_fd_set,
+ rbtree_walk(el->readers, InOrder, fr_event_fd_set,
&el->read_fds);
el->changed = 0;
}
when.tv_usec = 0;
if (rbtree_num_elements(el->times) > 0) {
- lrad_event_t *ev;
+ fr_event_t *ev;
ev = rbtree_min(el->times);
if (!ev) _exit(42);
do {
gettimeofday(&el->now, NULL);
when = el->now;
- } while (lrad_event_run(el, &when) == 1);
+ } while (fr_event_run(el, &when) == 1);
}
if (rcode <= 0) continue;
ew.el = el;
el->changed = 0;
- rbtree_walk(el->readers, InOrder, lrad_event_fd_dispatch, &ew);
+ rbtree_walk(el->readers, InOrder, fr_event_fd_dispatch, &ew);
}
el->dispatch = 0;
fflush(stdout);
}
-static lrad_randctx rand_pool;
+static fr_randctx rand_pool;
static uint32_t event_rand(void)
{
num = rand_pool.randrsl[rand_pool.randcnt++];
if (rand_pool.randcnt == 256) {
- lrad_isaac(&rand_pool);
+ fr_isaac(&rand_pool);
rand_pool.randcnt = 0;
}
int i, rcode;
struct timeval array[MAX];
struct timeval now, when;
- lrad_event_list_t *el;
+ fr_event_list_t *el;
- el = lrad_event_list_create();
+ el = fr_event_list_create();
if (!el) exit(1);
memset(&rand_pool, 0, sizeof(rand_pool));
rand_pool.randrsl[1] = time(NULL);
- lrad_randinit(&rand_pool, 1);
+ fr_randinit(&rand_pool, 1);
rand_pool.randcnt = 0;
gettimeofday(&array[0], NULL);
array[i].tv_usec -= 1000000;
array[i].tv_sec++;
}
- lrad_event_insert(el, print_time, &array[i], &array[i]);
+ fr_event_insert(el, print_time, &array[i], &array[i]);
}
- while (lrad_event_list_num_elements(el)) {
+ while (fr_event_list_num_elements(el)) {
gettimeofday(&now, NULL);
when = now;
- if (!lrad_event_run(el, &when)) {
+ if (!fr_event_run(el, &when)) {
int delay = (when.tv_sec - now.tv_sec) * 1000000;
delay += when.tv_usec;
delay -= now.tv_usec;
}
}
- lrad_event_list_free(el);
+ fr_event_list_free(el);
return 0;
}
#include <freeradius-devel/libradius.h>
-typedef struct lrad_fifo_entry_t {
- struct lrad_fifo_entry_t *next;
+typedef struct fr_fifo_entry_t {
+ struct fr_fifo_entry_t *next;
void *data;
-} lrad_fifo_entry_t;
+} fr_fifo_entry_t;
-struct lrad_fifo_t {
- lrad_fifo_entry_t *head, **tail;
- lrad_fifo_entry_t *freelist;
+struct fr_fifo_t {
+ fr_fifo_entry_t *head, **tail;
+ fr_fifo_entry_t *freelist;
int num_elements;
int max_entries;
- lrad_fifo_free_t freeNode;
+ fr_fifo_free_t freeNode;
};
-lrad_fifo_t *lrad_fifo_create(int max_entries, lrad_fifo_free_t freeNode)
+fr_fifo_t *fr_fifo_create(int max_entries, fr_fifo_free_t freeNode)
{
- lrad_fifo_t *fi;
+ fr_fifo_t *fi;
if ((max_entries < 2) || (max_entries > (1024 * 1024))) return NULL;
return fi;
}
-static void lrad_fifo_free_entries(lrad_fifo_t *fi, lrad_fifo_entry_t *head)
+static void fr_fifo_free_entries(fr_fifo_t *fi, fr_fifo_entry_t *head)
{
- lrad_fifo_entry_t *next;
+ fr_fifo_entry_t *next;
while (head) {
next = head->next;
}
}
-void lrad_fifo_free(lrad_fifo_t *fi)
+void fr_fifo_free(fr_fifo_t *fi)
{
if (!fi) return;
- lrad_fifo_free_entries(fi, fi->head);
- lrad_fifo_free_entries(fi, fi->freelist);
+ fr_fifo_free_entries(fi, fi->head);
+ fr_fifo_free_entries(fi, fi->freelist);
free(fi);
}
-static lrad_fifo_entry_t *lrad_fifo_alloc_entry(lrad_fifo_t *fi)
+static fr_fifo_entry_t *fr_fifo_alloc_entry(fr_fifo_t *fi)
{
- lrad_fifo_entry_t *entry;
+ fr_fifo_entry_t *entry;
if (fi->freelist) {
entry = fi->freelist;
return entry;
}
-int lrad_fifo_push(lrad_fifo_t *fi, void *data)
+int fr_fifo_push(fr_fifo_t *fi, void *data)
{
- lrad_fifo_entry_t *entry;
+ fr_fifo_entry_t *entry;
if (!fi || !data) return 0;
if (fi->num_elements >= fi->max_entries) return 0;
- entry = lrad_fifo_alloc_entry(fi);
+ entry = fr_fifo_alloc_entry(fi);
if (!entry) return 0;
entry->data = data;
return 1;
}
-static void lrad_fifo_free_entry(lrad_fifo_t *fi, lrad_fifo_entry_t *entry)
+static void fr_fifo_free_entry(fr_fifo_t *fi, fr_fifo_entry_t *entry)
{
entry->data = NULL;
entry->next = fi->freelist;
}
-void *lrad_fifo_pop(lrad_fifo_t *fi)
+void *fr_fifo_pop(fr_fifo_t *fi)
{
void *data;
- lrad_fifo_entry_t *entry;
+ fr_fifo_entry_t *entry;
if (!fi || !fi->head) return NULL;
fi->head = entry->next;
data = entry->data;
- lrad_fifo_free_entry(fi, entry);
+ fr_fifo_free_entry(fi, entry);
fi->num_elements--;
return data;
}
-void *lrad_fifo_peek(lrad_fifo_t *fi)
+void *fr_fifo_peek(fr_fifo_t *fi)
{
if (!fi || !fi->head) return NULL;
return fi->head->data;
}
-int lrad_fifo_num_elements(lrad_fifo_t *fi)
+int fr_fifo_num_elements(fr_fifo_t *fi)
{
if (!fi) return 0;
int main(int argc, char **argv)
{
int i, array[MAX];
- lrad_fifo_t *fi;
+ fr_fifo_t *fi;
- fi = lrad_fifo_create(MAX, NULL);
+ fi = fr_fifo_create(MAX, NULL);
if (!fi) exit(1);
for (i = 0; i < MAX; i++) {
array[i] = i;
- if (!lrad_fifo_push(fi, &array[i])) exit(2);
+ if (!fr_fifo_push(fi, &array[i])) exit(2);
}
for (i = 0; i < MAX; i++) {
int *p;
- p = lrad_fifo_pop(fi);
+ p = fr_fifo_pop(fi);
if (!p) {
fprintf(stderr, "No pop at %d\n", i);
exit(3);
*
* ??? What the heck is wrong with getservbyname?
*/
-static const LRAD_NAME_NUMBER filterPortType[] = {
+static const FR_NAME_NUMBER filterPortType[] = {
{ "ftp-data", 20 },
{ "ftp", 21 },
{ "telnet", 23 },
{ NULL , 0},
};
-static const LRAD_NAME_NUMBER filterType[] = {
+static const FR_NAME_NUMBER filterType[] = {
{ "generic", RAD_FILTER_GENERIC},
{ "ip", RAD_FILTER_IP},
{ "ipx", RAD_FILTER_IPX},
} FilterTokens;
-static const LRAD_NAME_NUMBER filterKeywords[] = {
+static const FR_NAME_NUMBER filterKeywords[] = {
{ "ip", FILTER_IP_TYPE },
{ "generic", FILTER_GENERIC_TYPE },
{ "in", FILTER_IN },
*
* ??? What the heck is wrong with getprotobyname?
*/
-static const LRAD_NAME_NUMBER filterProtoName[] = {
+static const FR_NAME_NUMBER filterProtoName[] = {
{ "tcp", 6 },
{ "udp", 17 },
{ "ospf", 89 },
RAD_COMPARE_NOT_EQUAL
} RadFilterComparison;
-static const LRAD_NAME_NUMBER filterCompare[] = {
+static const FR_NAME_NUMBER filterCompare[] = {
{ "<", RAD_COMPARE_LESS },
{ "=", RAD_COMPARE_EQUAL },
{ ">", RAD_COMPARE_GREATER },
/*
* Parse the node.
*/
- token = lrad_str2int(filterKeywords, argv[1], -1);
+ token = fr_str2int(filterKeywords, argv[1], -1);
switch (token) {
case FILTER_IPX_SRC_IPXNODE:
case FILTER_IPX_DST_IPXNODE:
/*
* Node must be 6 octets long.
*/
- token = lrad_hex2bin(p, net->node, IPX_NODE_ADDR_LEN);
+ token = fr_hex2bin(p, net->node, IPX_NODE_ADDR_LEN);
if (token != IPX_NODE_ADDR_LEN) return -1;
/*
/*
* Parse the socket.
*/
- token = lrad_str2int(filterKeywords, argv[3], -1);
+ token = fr_str2int(filterKeywords, argv[3], -1);
switch (token) {
case FILTER_IPX_SRC_IPXSOCK:
case FILTER_IPX_DST_IPXSOCK:
/*
* Parse the command "<", ">", "=" or "!="
*/
- token = lrad_str2int(filterCompare, argv[4], -1);
+ token = fr_str2int(filterCompare, argv[4], -1);
switch (token) {
case RAD_COMPARE_LESS:
case RAD_COMPARE_EQUAL:
if (argc < 4) return -1;
while ((argc > 0) && (flags != 0x03)) {
- token = lrad_str2int(filterKeywords, argv[0], -1);
+ token = fr_str2int(filterKeywords, argv[0], -1);
switch (token) {
case FILTER_IPX_SRC_IPXNET:
if (flags & 0x01) return -1;
/*
* There MUST be a comparison string.
*/
- rcode = lrad_str2int(filterCompare, compare, -1);
+ rcode = fr_str2int(filterCompare, compare, -1);
if (rcode < 0) return rcode;
if (strspn(str, "0123456789") == strlen(str)) {
token = atoi(str);
} else {
- token = lrad_str2int(filterPortType, str, -1);
+ token = fr_str2int(filterPortType, str, -1);
}
if ((token < 0) || (token > 65535)) return -1;
*/
flags = 0;
while ((argc > 0) && (flags != DONE_FLAGS)) {
- token = lrad_str2int(filterKeywords, argv[0], -1);
+ token = fr_str2int(filterKeywords, argv[0], -1);
switch (token) {
case FILTER_IP_SRC:
if (flags & IP_SRC_ADDR_FLAG) return -1;
if (strspn(argv[0], "0123456789") == strlen(argv[0])) {
token = atoi(argv[0]);
} else {
- token = lrad_str2int(filterProtoName, argv[0], -1);
+ token = fr_str2int(filterProtoName, argv[0], -1);
if (token == -1) {
librad_log("Unknown IP protocol \"%s\" in IP data filter",
argv[0]);
filter->offset = rcode;
filter->offset = htons(filter->offset);
- rcode = lrad_hex2bin(argv[1], filter->mask, sizeof(filter->mask));
+ rcode = fr_hex2bin(argv[1], filter->mask, sizeof(filter->mask));
if (rcode != sizeof(filter->mask)) return -1;
- token = lrad_hex2bin(argv[2], filter->value, sizeof(filter->value));
+ token = fr_hex2bin(argv[2], filter->value, sizeof(filter->value));
if (token != sizeof(filter->value)) return -1;
/*
flags = 0;
while (argc >= 1) {
- token = lrad_str2int(filterKeywords, argv[0], -1);
+ token = fr_str2int(filterKeywords, argv[0], -1);
switch (token) {
case FILTER_GENERIC_COMPNEQ:
if (flags & 0x01) return -1;
/*
* Decide which filter type it is: ip, ipx, or generic
*/
- type = lrad_str2int(filterType, argv[0], -1);
+ type = fr_str2int(filterType, argv[0], -1);
memset(&filter, 0, sizeof(filter));
/*
/*
* Parse direction
*/
- token = lrad_str2int(filterKeywords, argv[1], -1);
+ token = fr_str2int(filterKeywords, argv[1], -1);
switch (token) {
case FILTER_IN:
filter.direction = 1;
/*
* Parse action
*/
- token = lrad_str2int(filterKeywords, argv[2], -1);
+ token = fr_str2int(filterKeywords, argv[2], -1);
switch (token) {
case FILTER_FORWARD:
filter.forward = 1;
filter = (ascend_filter_t *) &(vp->vp_filter);
i = snprintf(p, len, "%s %s %s",
- lrad_int2str(filterType, filter->type, "??"),
+ fr_int2str(filterType, filter->type, "??"),
direction[filter->direction & 0x01],
action[filter->forward & 0x01]);
}
i = snprintf(p, len, " %s",
- lrad_int2str(filterProtoName, filter->u.ip.proto, "??"));
+ fr_int2str(filterProtoName, filter->u.ip.proto, "??"));
p += i;
len -= i;
if (filter->u.ip.srcPortComp > RAD_NO_COMPARE) {
i = snprintf(p, len, " srcport %s %d",
- lrad_int2str(filterCompare, filter->u.ip.srcPortComp, "??"),
+ fr_int2str(filterCompare, filter->u.ip.srcPortComp, "??"),
ntohs(filter->u.ip.srcport));
p += i;
len -= i;
if (filter->u.ip.dstPortComp > RAD_NO_COMPARE) {
i = snprintf(p, len, " dstport %s %d",
- lrad_int2str(filterCompare, filter->u.ip.dstPortComp, "??"),
+ fr_int2str(filterCompare, filter->u.ip.dstPortComp, "??"),
ntohs(filter->u.ip.dstport));
p += i;
len -= i;
if (filter->u.ipx.srcSocComp > RAD_NO_COMPARE) {
i = snprintf(p, len, " srcipxsock %s 0x%04x",
- lrad_int2str(filterCompare, filter->u.ipx.srcSocComp, "??"),
+ fr_int2str(filterCompare, filter->u.ipx.srcSocComp, "??"),
ntohs(filter->u.ipx.src.socket));
p += i;
len -= i;
if (filter->u.ipx.dstSocComp > RAD_NO_COMPARE) {
i = snprintf(p, len, " dstipxsock %s 0x%04x",
- lrad_int2str(filterCompare, filter->u.ipx.dstSocComp, "??"),
+ fr_int2str(filterCompare, filter->u.ipx.dstSocComp, "??"),
ntohs(filter->u.ipx.dst.socket));
p += i;
len -= i;
to return for gethostbyname() & gethostbyaddr(), if that is the
case then use only one mutex instead of seperate mutexes
*/
-static int lrad_hostbyname = 0;
-static int lrad_hodtbyaddr = 0;
-static pthread_mutex_t lrad_hostbyname_mutex;
-static pthread_mutex_t lrad_hodtbyaddr_mutex;
+static int fr_hostbyname = 0;
+static int fr_hodtbyaddr = 0;
+static pthread_mutex_t fr_hostbyname_mutex;
+static pthread_mutex_t fr_hodtbyaddr_mutex;
#endif
#undef LOCAL_GETHOSTBYNAMERSTYLE
struct hostent *hp;
#ifdef HAVE_PTHREAD_H
- if (lrad_hostbyname == 0) {
- pthread_mutex_init(&lrad_hostbyname_mutex, NULL);
- lrad_hostbyname = 1;
+ if (fr_hostbyname == 0) {
+ pthread_mutex_init(&fr_hostbyname_mutex, NULL);
+ fr_hostbyname = 1;
}
- pthread_mutex_lock(&lrad_hostbyname_mutex);
+ pthread_mutex_lock(&fr_hostbyname_mutex);
#endif
hp = gethostbyname(hostname);
}
#ifdef HAVE_PTHREAD_H
- pthread_mutex_unlock(&lrad_hostbyname_mutex);
+ pthread_mutex_unlock(&fr_hostbyname_mutex);
#endif
return hp;
struct hostent *hp;
#ifdef HAVE_PTHREAD_H
- if (lrad_hodtbyaddr == 0) {
- pthread_mutex_init(&lrad_hodtbyaddr_mutex, NULL);
- lrad_hodtbyaddr = 1;
+ if (fr_hodtbyaddr == 0) {
+ pthread_mutex_init(&fr_hodtbyaddr_mutex, NULL);
+ fr_hodtbyaddr = 1;
}
- pthread_mutex_lock(&lrad_hodtbyaddr_mutex);
+ pthread_mutex_lock(&fr_hodtbyaddr_mutex);
#endif
hp = gethostbyaddr(addr, len, type);
}
#ifdef HAVE_PTHREAD_H
- pthread_mutex_unlock(&lrad_hodtbyaddr_mutex);
+ pthread_mutex_unlock(&fr_hodtbyaddr_mutex);
#endif
return hp;
* A reasonable number of buckets to start off with.
* Should be a power of two.
*/
-#define LRAD_HASH_NUM_BUCKETS (64)
+#define FR_HASH_NUM_BUCKETS (64)
-typedef struct lrad_hash_entry_t {
- struct lrad_hash_entry_t *next;
+typedef struct fr_hash_entry_t {
+ struct fr_hash_entry_t *next;
uint32_t reversed;
uint32_t key;
void *data;
-} lrad_hash_entry_t;
+} fr_hash_entry_t;
-struct lrad_hash_table_t {
+struct fr_hash_table_t {
int num_elements;
int num_buckets; /* power of 2 */
int next_grow;
int mask;
- lrad_hash_table_free_t free;
- lrad_hash_table_hash_t hash;
- lrad_hash_table_cmp_t cmp;
+ fr_hash_table_free_t free;
+ fr_hash_table_hash_t hash;
+ fr_hash_table_cmp_t cmp;
- lrad_hash_entry_t null;
+ fr_hash_entry_t null;
- lrad_hash_entry_t **buckets;
+ fr_hash_entry_t **buckets;
};
#ifdef TESTING
}
-static lrad_hash_entry_t *list_find(lrad_hash_table_t *ht,
- lrad_hash_entry_t *head,
+static fr_hash_entry_t *list_find(fr_hash_table_t *ht,
+ fr_hash_entry_t *head,
uint32_t reversed,
const void *data)
{
- lrad_hash_entry_t *cur;
+ fr_hash_entry_t *cur;
for (cur = head; cur != &ht->null; cur = cur->next) {
if (cur->reversed == reversed) {
/*
* Inserts a new entry into the list, in order.
*/
-static int list_insert(lrad_hash_table_t *ht,
- lrad_hash_entry_t **head, lrad_hash_entry_t *node)
+static int list_insert(fr_hash_table_t *ht,
+ fr_hash_entry_t **head, fr_hash_entry_t *node)
{
- lrad_hash_entry_t **last, *cur;
+ fr_hash_entry_t **last, *cur;
last = head;
/*
* Delete an entry from the list.
*/
-static int list_delete(lrad_hash_table_t *ht,
- lrad_hash_entry_t **head, lrad_hash_entry_t *node)
+static int list_delete(fr_hash_table_t *ht,
+ fr_hash_entry_t **head, fr_hash_entry_t *node)
{
- lrad_hash_entry_t **last, *cur;
+ fr_hash_entry_t **last, *cur;
last = head;
*
* Memory usage in bytes is (20/3) * number of entries.
*/
-lrad_hash_table_t *lrad_hash_table_create(lrad_hash_table_hash_t hashNode,
- lrad_hash_table_cmp_t cmpNode,
- lrad_hash_table_free_t freeNode)
+fr_hash_table_t *fr_hash_table_create(fr_hash_table_hash_t hashNode,
+ fr_hash_table_cmp_t cmpNode,
+ fr_hash_table_free_t freeNode)
{
- lrad_hash_table_t *ht;
+ fr_hash_table_t *ht;
if (!hashNode) return NULL;
ht->free = freeNode;
ht->hash = hashNode;
ht->cmp = cmpNode;
- ht->num_buckets = LRAD_HASH_NUM_BUCKETS;
+ ht->num_buckets = FR_HASH_NUM_BUCKETS;
ht->mask = ht->num_buckets - 1;
/*
* wrong. To solve that problem, we walk down the whole chain,
* inserting the elements into the correct place.
*/
-static void lrad_hash_table_fixup(lrad_hash_table_t *ht, uint32_t entry)
+static void fr_hash_table_fixup(fr_hash_table_t *ht, uint32_t entry)
{
uint32_t parent_entry = parent_of(entry);
- lrad_hash_entry_t **last, *cur;
+ fr_hash_entry_t **last, *cur;
uint32_t this;
parent_entry = parent_of(entry);
/* parent_entry == entry if and only if entry == 0 */
if (!ht->buckets[parent_entry]) {
- lrad_hash_table_fixup(ht, parent_entry);
+ fr_hash_table_fixup(ht, parent_entry);
}
/*
/*
* Grow the hash table.
*/
-static void lrad_hash_table_grow(lrad_hash_table_t *ht)
+static void fr_hash_table_grow(fr_hash_table_t *ht)
{
- lrad_hash_entry_t **buckets;
+ fr_hash_entry_t **buckets;
buckets = malloc(sizeof(*buckets) * GROW_FACTOR * ht->num_buckets);
if (!buckets) return;
/*
* Insert data.
*/
-int lrad_hash_table_insert(lrad_hash_table_t *ht, void *data)
+int fr_hash_table_insert(fr_hash_table_t *ht, void *data)
{
uint32_t key;
uint32_t entry;
uint32_t reversed;
- lrad_hash_entry_t *node;
+ fr_hash_entry_t *node;
if (!ht || !data) return 0;
entry = key & ht->mask;
reversed = reverse(key);
- if (!ht->buckets[entry]) lrad_hash_table_fixup(ht, entry);
+ if (!ht->buckets[entry]) fr_hash_table_fixup(ht, entry);
/*
* If we try to do our own memory allocation here, the
*/
ht->num_elements++;
if (ht->num_elements >= ht->next_grow) {
- lrad_hash_table_grow(ht);
+ fr_hash_table_grow(ht);
}
return 1;
/*
* Internal find a node routine.
*/
-static lrad_hash_entry_t *lrad_hash_table_find(lrad_hash_table_t *ht,
+static fr_hash_entry_t *fr_hash_table_find(fr_hash_table_t *ht,
const void *data)
{
uint32_t key;
entry = key & ht->mask;
reversed = reverse(key);
- if (!ht->buckets[entry]) lrad_hash_table_fixup(ht, entry);
+ if (!ht->buckets[entry]) fr_hash_table_fixup(ht, entry);
return list_find(ht, ht->buckets[entry], reversed, data);
}
/*
* Replace old data with new data, OR insert if there is no old.
*/
-int lrad_hash_table_replace(lrad_hash_table_t *ht, void *data)
+int fr_hash_table_replace(fr_hash_table_t *ht, void *data)
{
- lrad_hash_entry_t *node;
+ fr_hash_entry_t *node;
if (!ht || !data) return 0;
- node = lrad_hash_table_find(ht, data);
- if (!node) return lrad_hash_table_insert(ht, data);
+ node = fr_hash_table_find(ht, data);
+ if (!node) return fr_hash_table_insert(ht, data);
if (ht->free) ht->free(node->data);
node->data = data;
/*
* Find data from a template
*/
-void *lrad_hash_table_finddata(lrad_hash_table_t *ht, const void *data)
+void *fr_hash_table_finddata(fr_hash_table_t *ht, const void *data)
{
- lrad_hash_entry_t *node;
+ fr_hash_entry_t *node;
- node = lrad_hash_table_find(ht, data);
+ node = fr_hash_table_find(ht, data);
if (!node) return NULL;
return node->data;
/*
* Yank an entry from the hash table, without freeing the data.
*/
-void *lrad_hash_table_yank(lrad_hash_table_t *ht, const void *data)
+void *fr_hash_table_yank(fr_hash_table_t *ht, const void *data)
{
uint32_t key;
uint32_t entry;
uint32_t reversed;
void *old;
- lrad_hash_entry_t *node;
+ fr_hash_entry_t *node;
if (!ht) return NULL;
entry = key & ht->mask;
reversed = reverse(key);
- if (!ht->buckets[entry]) lrad_hash_table_fixup(ht, entry);
+ if (!ht->buckets[entry]) fr_hash_table_fixup(ht, entry);
node = list_find(ht, ht->buckets[entry], reversed, data);
if (!node) return NULL;
/*
* Delete a piece of data from the hash table.
*/
-int lrad_hash_table_delete(lrad_hash_table_t *ht, const void *data)
+int fr_hash_table_delete(fr_hash_table_t *ht, const void *data)
{
void *old;
- old = lrad_hash_table_yank(ht, data);
+ old = fr_hash_table_yank(ht, data);
if (!old) return 0;
if (ht->free) ht->free(old);
/*
* Free a hash table
*/
-void lrad_hash_table_free(lrad_hash_table_t *ht)
+void fr_hash_table_free(fr_hash_table_t *ht)
{
int i;
- lrad_hash_entry_t *node, *next;
+ fr_hash_entry_t *node, *next;
if (!ht) return;
/*
* Count number of elements
*/
-int lrad_hash_table_num_elements(lrad_hash_table_t *ht)
+int fr_hash_table_num_elements(fr_hash_table_t *ht)
{
if (!ht) return 0;
/*
* Walk over the nodes, allowing deletes & inserts to happen.
*/
-int lrad_hash_table_walk(lrad_hash_table_t *ht,
- lrad_hash_table_walk_t callback,
+int fr_hash_table_walk(fr_hash_table_t *ht,
+ fr_hash_table_walk_t callback,
void *context)
{
int i, rcode;;
if (!ht || !callback) return 0;
for (i = ht->num_buckets - 1; i >= 0; i--) {
- lrad_hash_entry_t *node, *next;
+ fr_hash_entry_t *node, *next;
/*
* Ensure that the current bucket is filled.
*/
- if (!ht->buckets[i]) lrad_hash_table_fixup(ht, i);
+ if (!ht->buckets[i]) fr_hash_table_fixup(ht, i);
for (node = ht->buckets[i]; node != &ht->null; node = next) {
next = node->next;
/*
* Show what the hash table is doing.
*/
-int lrad_hash_table_info(lrad_hash_table_t *ht)
+int fr_hash_table_info(fr_hash_table_t *ht)
{
int i, a, collisions, uninitialized;
int array[256];
for (i = 0; i < ht->num_buckets; i++) {
uint32_t key;
int load;
- lrad_hash_entry_t *node, *next;
+ fr_hash_entry_t *node, *next;
/*
* If we haven't inserted or looked up an entry
* Which also includes public domain source. We've re-written
* it here for our purposes.
*/
-uint32_t lrad_hash(const void *data, size_t size)
+uint32_t fr_hash(const void *data, size_t size)
{
const uint8_t *p = data;
const uint8_t *q = p + size;
/*
* Continue hashing data.
*/
-uint32_t lrad_hash_update(const void *data, size_t size, uint32_t hash)
+uint32_t fr_hash_update(const void *data, size_t size, uint32_t hash)
{
const uint8_t *p = data;
const uint8_t *q = p + size;
*
* If you need a non-power-of-two hash, cope.
*/
-uint32_t lrad_hash_fold(uint32_t hash, int bits)
+uint32_t fr_hash_fold(uint32_t hash, int bits)
{
int count;
uint32_t result;
/*
* Hash a C string, so we loop over it once.
*/
-uint32_t lrad_hash_string(const char *p)
+uint32_t fr_hash_string(const char *p)
{
uint32_t hash = FNV_MAGIC_INIT;
static uint32_t hash_int(const void *data)
{
- return lrad_hash((int *) data, sizeof(int));
+ return fr_hash((int *) data, sizeof(int));
}
#define MAX 1024*1024
int main(int argc, char **argv)
{
int i, *p, *q, k;
- lrad_hash_table_t *ht;
+ fr_hash_table_t *ht;
int *array;
- ht = lrad_hash_table_create(hash_int, NULL, NULL);
+ ht = fr_hash_table_create(hash_int, NULL, NULL);
if (!ht) {
fprintf(stderr, "Hash create failed\n");
exit(1);
p = array + i;
*p = i;
- if (!lrad_hash_table_insert(ht, p)) {
+ if (!fr_hash_table_insert(ht, p)) {
fprintf(stderr, "Failed insert %08x\n", i);
exit(1);
}
#ifdef TEST_INSERT
- q = lrad_hash_table_finddata(ht, p);
+ q = fr_hash_table_finddata(ht, p);
if (q != p) {
fprintf(stderr, "Bad data %d\n", i);
exit(1);
#endif
}
- lrad_hash_table_info(ht);
+ fr_hash_table_info(ht);
/*
* Build this to see how lookups result in shortening
*/
if (1) {
for (i = 0; i < MAX ; i++) {
- q = lrad_hash_table_finddata(ht, &i);
+ q = fr_hash_table_finddata(ht, &i);
if (!q || *q != i) {
fprintf(stderr, "Failed finding %d\n", i);
exit(1);
}
#if 0
- if (!lrad_hash_table_delete(ht, &i)) {
+ if (!fr_hash_table_delete(ht, &i)) {
fprintf(stderr, "Failed deleting %d\n", i);
exit(1);
}
- q = lrad_hash_table_finddata(ht, &i);
+ q = fr_hash_table_finddata(ht, &i);
if (q) {
fprintf(stderr, "Failed to delete %08x\n", i);
exit(1);
#endif
}
- lrad_hash_table_info(ht);
+ fr_hash_table_info(ht);
}
- lrad_hash_table_free(ht);
+ fr_hash_table_free(ht);
free(array);
exit(0);
*(r++) = b = (ind(mm,y>>RANDSIZL) + x) & 0xffffffff; \
}
-void lrad_isaac(lrad_randctx *ctx)
+void fr_isaac(fr_randctx *ctx)
{
register uint32_t a,b,x,y,*m,*mm,*m2,*r,*mend;
mm=ctx->randmem; r=ctx->randrsl;
}
/* if (flag==1), then use the contents of randrsl[] to initialize mm[]. */
-void lrad_randinit(lrad_randctx *ctx, int flag)
+void fr_randinit(fr_randctx *ctx, int flag)
{
int i;
uint32_t a,b,c,d,e,f,g,h;
}
}
- lrad_isaac(ctx); /* fill in the first set of results */
+ fr_isaac(ctx); /* fill in the first set of results */
ctx->randcnt=RANDSIZ; /* prepare to use the first set of results */
}
int main()
{
uint32_t i,j;
- lrad_randctx ctx;
+ fr_randctx ctx;
ctx.randa = ctx.randb = ctx.randc = (uint32_t)0;
for (i=0; i<256; ++i) ctx.randrsl[i]=(uint32_t)0;
- lrad_randinit(&ctx, 1);
+ fr_randinit(&ctx, 1);
for (i=0; i<2; ++i) {
- lrad_isaac(&ctx);
+ fr_isaac(&ctx);
for (j=0; j<256; ++j) {
printf("%.8lx",ctx.randrsl[j]);
if ((j&7)==7) printf("\n");
* address family, or the first address (of whatever family),
* if AF_UNSPEC is used.
*/
-int ip_hton(const char *src, int af, lrad_ipaddr_t *dst)
+int ip_hton(const char *src, int af, fr_ipaddr_t *dst)
{
int error;
struct addrinfo hints, *ai = NULL, *res = NULL;
/*
* Look IP addreses up, and print names (depending on DNS config)
*/
-const char *ip_ntoh(const lrad_ipaddr_t *src, char *dst, size_t cnt)
+const char *ip_ntoh(const fr_ipaddr_t *src, char *dst, size_t cnt)
{
struct sockaddr_storage ss;
struct sockaddr_in *s4;
*
* We allow: hex == bin
*/
-int lrad_hex2bin(const char *hex, uint8_t *bin, int len)
+int fr_hex2bin(const char *hex, uint8_t *bin, int len)
{
int i;
char *c1, *c2;
*
* If the output buffer isn't long enough, we have a buffer overflow.
*/
-void lrad_bin2hex(const uint8_t *bin, char *hex, int len)
+void fr_bin2hex(const uint8_t *bin, char *hex, int len)
{
int i;
}
#endif
-int lrad_ipaddr_cmp(const lrad_ipaddr_t *a, const lrad_ipaddr_t *b)
+int fr_ipaddr_cmp(const fr_ipaddr_t *a, const fr_ipaddr_t *b)
{
if (a->af < b->af) return -1;
if (a->af > b->af) return +1;
* Take the key fields of a request packet, and convert it to a
* hash.
*/
-uint32_t lrad_request_packet_hash(const RADIUS_PACKET *packet)
+uint32_t fr_request_packet_hash(const RADIUS_PACKET *packet)
{
uint32_t hash;
if (packet->hash) return packet->hash;
- hash = lrad_hash(&packet->sockfd, sizeof(packet->sockfd));
- hash = lrad_hash_update(&packet->src_port, sizeof(packet->src_port),
+ hash = fr_hash(&packet->sockfd, sizeof(packet->sockfd));
+ hash = fr_hash_update(&packet->src_port, sizeof(packet->src_port),
hash);
- hash = lrad_hash_update(&packet->dst_port,
+ hash = fr_hash_update(&packet->dst_port,
sizeof(packet->dst_port), hash);
- hash = lrad_hash_update(&packet->src_ipaddr.af,
+ hash = fr_hash_update(&packet->src_ipaddr.af,
sizeof(packet->src_ipaddr.af), hash);
/*
*/
switch (packet->src_ipaddr.af) {
case AF_INET:
- hash = lrad_hash_update(&packet->src_ipaddr.ipaddr.ip4addr,
+ hash = fr_hash_update(&packet->src_ipaddr.ipaddr.ip4addr,
sizeof(packet->src_ipaddr.ipaddr.ip4addr),
hash);
- hash = lrad_hash_update(&packet->dst_ipaddr.ipaddr.ip4addr,
+ hash = fr_hash_update(&packet->dst_ipaddr.ipaddr.ip4addr,
sizeof(packet->dst_ipaddr.ipaddr.ip4addr),
hash);
break;
case AF_INET6:
- hash = lrad_hash_update(&packet->src_ipaddr.ipaddr.ip6addr,
+ hash = fr_hash_update(&packet->src_ipaddr.ipaddr.ip6addr,
sizeof(packet->src_ipaddr.ipaddr.ip6addr),
hash);
- hash = lrad_hash_update(&packet->dst_ipaddr.ipaddr.ip6addr,
+ hash = fr_hash_update(&packet->dst_ipaddr.ipaddr.ip6addr,
sizeof(packet->dst_ipaddr.ipaddr.ip6addr),
hash);
break;
break;
}
- return lrad_hash_update(&packet->id, sizeof(packet->id), hash);
+ return fr_hash_update(&packet->id, sizeof(packet->id), hash);
}
* of the request. e.g. where the request does (src, dst), we do
* (dst, src)
*/
-uint32_t lrad_reply_packet_hash(const RADIUS_PACKET *packet)
+uint32_t fr_reply_packet_hash(const RADIUS_PACKET *packet)
{
uint32_t hash;
- hash = lrad_hash(&packet->sockfd, sizeof(packet->sockfd));
- hash = lrad_hash_update(&packet->id, sizeof(packet->id), hash);
- hash = lrad_hash_update(&packet->src_port, sizeof(packet->src_port),
+ hash = fr_hash(&packet->sockfd, sizeof(packet->sockfd));
+ hash = fr_hash_update(&packet->id, sizeof(packet->id), hash);
+ hash = fr_hash_update(&packet->src_port, sizeof(packet->src_port),
hash);
- hash = lrad_hash_update(&packet->dst_port,
+ hash = fr_hash_update(&packet->dst_port,
sizeof(packet->dst_port), hash);
- hash = lrad_hash_update(&packet->src_ipaddr.af,
+ hash = fr_hash_update(&packet->src_ipaddr.af,
sizeof(packet->src_ipaddr.af), hash);
/*
*/
switch (packet->src_ipaddr.af) {
case AF_INET:
- hash = lrad_hash_update(&packet->dst_ipaddr.ipaddr.ip4addr,
+ hash = fr_hash_update(&packet->dst_ipaddr.ipaddr.ip4addr,
sizeof(packet->dst_ipaddr.ipaddr.ip4addr),
hash);
- hash = lrad_hash_update(&packet->src_ipaddr.ipaddr.ip4addr,
+ hash = fr_hash_update(&packet->src_ipaddr.ipaddr.ip4addr,
sizeof(packet->src_ipaddr.ipaddr.ip4addr),
hash);
break;
case AF_INET6:
- hash = lrad_hash_update(&packet->dst_ipaddr.ipaddr.ip6addr,
+ hash = fr_hash_update(&packet->dst_ipaddr.ipaddr.ip6addr,
sizeof(packet->dst_ipaddr.ipaddr.ip6addr),
hash);
- hash = lrad_hash_update(&packet->src_ipaddr.ipaddr.ip6addr,
+ hash = fr_hash_update(&packet->src_ipaddr.ipaddr.ip6addr,
sizeof(packet->src_ipaddr.ipaddr.ip6addr),
hash);
break;
break;
}
- return lrad_hash_update(&packet->id, sizeof(packet->id), hash);
+ return fr_hash_update(&packet->id, sizeof(packet->id), hash);
}
* That's because if the authentication vector is different,
* it means that the NAS has given up on the earlier request.
*/
-int lrad_packet_cmp(const RADIUS_PACKET *a, const RADIUS_PACKET *b)
+int fr_packet_cmp(const RADIUS_PACKET *a, const RADIUS_PACKET *b)
{
int rcode;
if (a->dst_port < b->dst_port) return -1;
if (a->dst_port > b->dst_port) return +1;
- rcode = lrad_ipaddr_cmp(&a->dst_ipaddr, &b->dst_ipaddr);
+ rcode = fr_ipaddr_cmp(&a->dst_ipaddr, &b->dst_ipaddr);
if (rcode != 0) return rcode;
- return lrad_ipaddr_cmp(&a->src_ipaddr, &b->src_ipaddr);
+ return fr_ipaddr_cmp(&a->src_ipaddr, &b->src_ipaddr);
}
/*
* Create a fake "request" from a reply, for later lookup.
*/
-void lrad_request_from_reply(RADIUS_PACKET *request,
+void fr_request_from_reply(RADIUS_PACKET *request,
const RADIUS_PACKET *reply)
{
request->sockfd = reply->sockfd;
/*
* Open a socket on the given IP and port.
*/
-int lrad_socket(lrad_ipaddr_t *ipaddr, int port)
+int fr_socket(fr_ipaddr_t *ipaddr, int port)
{
int sockfd;
struct sockaddr_storage salocal;
/*
* We need to keep track of the socket & it's IP/port.
*/
-typedef struct lrad_packet_socket_t {
+typedef struct fr_packet_socket_t {
int sockfd;
int num_outgoing;
int offset; /* 0..31 */
int inaddr_any;
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
int port;
-} lrad_packet_socket_t;
+} fr_packet_socket_t;
#define FNV_MAGIC_PRIME (0x01000193)
* Structure defining a list of packets (incoming or outgoing)
* that should be managed.
*/
-struct lrad_packet_list_t {
- lrad_hash_table_t *ht;
+struct fr_packet_list_t {
+ fr_hash_table_t *ht;
- lrad_hash_table_t *dst2id_ht;
+ fr_hash_table_t *dst2id_ht;
int alloc_id;
int num_outgoing;
uint32_t mask;
int last_recv;
- lrad_packet_socket_t sockets[MAX_SOCKETS];
+ fr_packet_socket_t sockets[MAX_SOCKETS];
};
/*
* Ugh. Doing this on every sent/received packet is not nice.
*/
-static lrad_packet_socket_t *lrad_socket_find(lrad_packet_list_t *pl,
+static fr_packet_socket_t *fr_socket_find(fr_packet_list_t *pl,
int sockfd)
{
int i, start;
return NULL;
}
-int lrad_packet_list_socket_remove(lrad_packet_list_t *pl, int sockfd)
+int fr_packet_list_socket_remove(fr_packet_list_t *pl, int sockfd)
{
- lrad_packet_socket_t *ps;
+ fr_packet_socket_t *ps;
if (!pl) return 0;
- ps = lrad_socket_find(pl, sockfd);
+ ps = fr_socket_find(pl, sockfd);
if (!ps) return 0;
/*
return 1;
}
-int lrad_packet_list_socket_add(lrad_packet_list_t *pl, int sockfd)
+int fr_packet_list_socket_add(fr_packet_list_t *pl, int sockfd)
{
int i, start;
struct sockaddr_storage src;
socklen_t sizeof_src = sizeof(src);
- lrad_packet_socket_t *ps;
+ fr_packet_socket_t *ps;
if (!pl) return 0;
static uint32_t packet_entry_hash(const void *data)
{
- return lrad_request_packet_hash(*(const RADIUS_PACKET * const *) data);
+ return fr_request_packet_hash(*(const RADIUS_PACKET * const *) data);
}
static int packet_entry_cmp(const void *one, const void *two)
const RADIUS_PACKET * const *a = one;
const RADIUS_PACKET * const *b = two;
- return lrad_packet_cmp(*a, *b);
+ return fr_packet_cmp(*a, *b);
}
/*
* This means that if destinations are added and removed, they
* won't be removed from this tree.
*/
-typedef struct lrad_packet_dst2id_t {
- lrad_ipaddr_t dst_ipaddr;
+typedef struct fr_packet_dst2id_t {
+ fr_ipaddr_t dst_ipaddr;
int dst_port;
uint32_t id[1]; /* really id[256] */
-} lrad_packet_dst2id_t;
+} fr_packet_dst2id_t;
static uint32_t packet_dst2id_hash(const void *data)
{
uint32_t hash;
- const lrad_packet_dst2id_t *pd = data;
+ const fr_packet_dst2id_t *pd = data;
- hash = lrad_hash(&pd->dst_port, sizeof(pd->dst_port));
+ hash = fr_hash(&pd->dst_port, sizeof(pd->dst_port));
switch (pd->dst_ipaddr.af) {
case AF_INET:
- hash = lrad_hash_update(&pd->dst_ipaddr.ipaddr.ip4addr,
+ hash = fr_hash_update(&pd->dst_ipaddr.ipaddr.ip4addr,
sizeof(pd->dst_ipaddr.ipaddr.ip4addr),
hash);
break;
case AF_INET6:
- hash = lrad_hash_update(&pd->dst_ipaddr.ipaddr.ip6addr,
+ hash = fr_hash_update(&pd->dst_ipaddr.ipaddr.ip6addr,
sizeof(pd->dst_ipaddr.ipaddr.ip6addr),
hash);
break;
static int packet_dst2id_cmp(const void *one, const void *two)
{
- const lrad_packet_dst2id_t *a = one;
- const lrad_packet_dst2id_t *b = two;
+ const fr_packet_dst2id_t *a = one;
+ const fr_packet_dst2id_t *b = two;
if (a->dst_port < b->dst_port) return -1;
if (a->dst_port > b->dst_port) return +1;
- return lrad_ipaddr_cmp(&a->dst_ipaddr, &b->dst_ipaddr);
+ return fr_ipaddr_cmp(&a->dst_ipaddr, &b->dst_ipaddr);
}
static void packet_dst2id_free(void *data)
}
-void lrad_packet_list_free(lrad_packet_list_t *pl)
+void fr_packet_list_free(fr_packet_list_t *pl)
{
if (!pl) return;
- lrad_hash_table_free(pl->ht);
- lrad_hash_table_free(pl->dst2id_ht);
+ fr_hash_table_free(pl->ht);
+ fr_hash_table_free(pl->dst2id_ht);
free(pl);
}
/*
* Caller is responsible for managing the packet entries.
*/
-lrad_packet_list_t *lrad_packet_list_create(int alloc_id)
+fr_packet_list_t *fr_packet_list_create(int alloc_id)
{
int i;
- lrad_packet_list_t *pl;
+ fr_packet_list_t *pl;
pl = malloc(sizeof(*pl));
if (!pl) return NULL;
memset(pl, 0, sizeof(*pl));
- pl->ht = lrad_hash_table_create(packet_entry_hash,
+ pl->ht = fr_hash_table_create(packet_entry_hash,
packet_entry_cmp,
NULL);
if (!pl->ht) {
- lrad_packet_list_free(pl);
+ fr_packet_list_free(pl);
return NULL;
}
if (alloc_id) {
pl->alloc_id = 1;
- pl->dst2id_ht = lrad_hash_table_create(packet_dst2id_hash,
+ pl->dst2id_ht = fr_hash_table_create(packet_dst2id_hash,
packet_dst2id_cmp,
packet_dst2id_free);
if (!pl->dst2id_ht) {
- lrad_packet_list_free(pl);
+ fr_packet_list_free(pl);
return NULL;
}
}
/*
- * If pl->alloc_id is set, then lrad_packet_list_id_alloc() MUST
+ * If pl->alloc_id is set, then fr_packet_list_id_alloc() MUST
* be called before inserting the packet into the list!
*/
-int lrad_packet_list_insert(lrad_packet_list_t *pl,
+int fr_packet_list_insert(fr_packet_list_t *pl,
RADIUS_PACKET **request_p)
{
if (!pl || !request_p || !*request_p) return 0;
- (*request_p)->hash = lrad_request_packet_hash(*request_p);
+ (*request_p)->hash = fr_request_packet_hash(*request_p);
- return lrad_hash_table_insert(pl->ht, request_p);
+ return fr_hash_table_insert(pl->ht, request_p);
}
-RADIUS_PACKET **lrad_packet_list_find(lrad_packet_list_t *pl,
+RADIUS_PACKET **fr_packet_list_find(fr_packet_list_t *pl,
RADIUS_PACKET *request)
{
if (!pl || !request) return 0;
- return lrad_hash_table_finddata(pl->ht, &request);
+ return fr_hash_table_finddata(pl->ht, &request);
}
* This presumes that the reply has dst_ipaddr && dst_port set up
* correctly (i.e. real IP, or "*").
*/
-RADIUS_PACKET **lrad_packet_list_find_byreply(lrad_packet_list_t *pl,
+RADIUS_PACKET **fr_packet_list_find_byreply(fr_packet_list_t *pl,
RADIUS_PACKET *reply)
{
RADIUS_PACKET my_request, *request;
- lrad_packet_socket_t *ps;
+ fr_packet_socket_t *ps;
if (!pl || !reply) return NULL;
- ps = lrad_socket_find(pl, reply->sockfd);
+ ps = fr_socket_find(pl, reply->sockfd);
if (!ps) return NULL;
/*
request = &my_request;
- return lrad_hash_table_finddata(pl->ht, &request);
+ return fr_hash_table_finddata(pl->ht, &request);
}
-RADIUS_PACKET **lrad_packet_list_yank(lrad_packet_list_t *pl,
+RADIUS_PACKET **fr_packet_list_yank(fr_packet_list_t *pl,
RADIUS_PACKET *request)
{
if (!pl || !request) return NULL;
- return lrad_hash_table_yank(pl->ht, &request);
+ return fr_hash_table_yank(pl->ht, &request);
}
-int lrad_packet_list_num_elements(lrad_packet_list_t *pl)
+int fr_packet_list_num_elements(fr_packet_list_t *pl)
{
if (!pl) return 0;
- return lrad_hash_table_num_elements(pl->ht);
+ return fr_hash_table_num_elements(pl->ht);
}
* the same mutex as the one protecting the insert/find/yank
* calls!
*/
-int lrad_packet_list_id_alloc(lrad_packet_list_t *pl,
+int fr_packet_list_id_alloc(fr_packet_list_t *pl,
RADIUS_PACKET *request)
{
int i, id, start;
uint32_t free_mask;
- lrad_packet_dst2id_t my_pd, *pd;
- lrad_packet_socket_t *ps;
+ fr_packet_dst2id_t my_pd, *pd;
+ fr_packet_socket_t *ps;
if (!pl || !pl->alloc_id || !request) return 0;
my_pd.dst_ipaddr = request->dst_ipaddr;
my_pd.dst_port = request->dst_port;
- pd = lrad_hash_table_finddata(pl->dst2id_ht, &my_pd);
+ pd = fr_hash_table_finddata(pl->dst2id_ht, &my_pd);
if (!pd) {
pd = malloc(sizeof(*pd) + 255 * sizeof(pd->id[0]));
if (!pd) return 0;
pd->dst_ipaddr = request->dst_ipaddr;
pd->dst_port = request->dst_port;
- if (!lrad_hash_table_insert(pl->dst2id_ht, pd)) {
+ if (!fr_hash_table_insert(pl->dst2id_ht, pd)) {
free(pd);
return 0;
}
* Id's only when all responses have been received, OR after
* a timeout.
*/
- id = start = (int) lrad_rand() & 0xff;
+ id = start = (int) fr_rand() & 0xff;
while (pd->id[id] == pl->mask) { /* all sockets are using this ID */
id++;
* Should be called AFTER yanking it from the list, so that
* any newly inserted entries don't collide with this one.
*/
-int lrad_packet_list_id_free(lrad_packet_list_t *pl,
+int fr_packet_list_id_free(fr_packet_list_t *pl,
RADIUS_PACKET *request)
{
- lrad_packet_socket_t *ps;
- lrad_packet_dst2id_t my_pd, *pd;
+ fr_packet_socket_t *ps;
+ fr_packet_dst2id_t my_pd, *pd;
if (!pl || !request) return 0;
- ps = lrad_socket_find(pl, request->sockfd);
+ ps = fr_socket_find(pl, request->sockfd);
if (!ps) return 0;
my_pd.dst_ipaddr = request->dst_ipaddr;
my_pd.dst_port = request->dst_port;
- pd = lrad_hash_table_finddata(pl->dst2id_ht, &my_pd);
+ pd = fr_hash_table_finddata(pl->dst2id_ht, &my_pd);
if (!pd) return 0;
pd->id[request->id] &= ~(1 << ps->offset);
return 1;
}
-int lrad_packet_list_walk(lrad_packet_list_t *pl, void *ctx,
- lrad_hash_table_walk_t callback)
+int fr_packet_list_walk(fr_packet_list_t *pl, void *ctx,
+ fr_hash_table_walk_t callback)
{
if (!pl || !callback) return 0;
- return lrad_hash_table_walk(pl->ht, callback, ctx);
+ return fr_hash_table_walk(pl->ht, callback, ctx);
}
-int lrad_packet_list_fd_set(lrad_packet_list_t *pl, fd_set *set)
+int fr_packet_list_fd_set(fr_packet_list_t *pl, fd_set *set)
{
int i, maxfd;
* FIXME: Add sockfd, if -1, do round-robin, else do sockfd
* IF in fdset.
*/
-RADIUS_PACKET *lrad_packet_list_recv(lrad_packet_list_t *pl, fd_set *set)
+RADIUS_PACKET *fr_packet_list_recv(fr_packet_list_t *pl, fd_set *set)
{
int start;
RADIUS_PACKET *packet;
if (!packet) continue;
/*
- * Call lrad_packet_list_find_byreply(). If it
+ * Call fr_packet_list_find_byreply(). If it
* doesn't find anything, discard the reply.
*/
return NULL;
}
-int lrad_packet_list_num_incoming(lrad_packet_list_t *pl)
+int fr_packet_list_num_incoming(fr_packet_list_t *pl)
{
int num_elements;
if (!pl) return 0;
- num_elements = lrad_hash_table_num_elements(pl->ht);
+ num_elements = fr_hash_table_num_elements(pl->ht);
if (num_elements < pl->num_outgoing) return 0; /* panic! */
return num_elements - pl->num_outgoing;
}
-int lrad_packet_list_num_outgoing(lrad_packet_list_t *pl)
+int fr_packet_list_num_outgoing(fr_packet_list_t *pl)
{
if (!pl) return 0;
strcpy(buf, "0x");
- lrad_bin2hex(vp->vp_octets, buf + 2, vp->length);
+ fr_bin2hex(vp->vp_octets, buf + 2, vp->length);
a = buf;
break;
uint8_t data[1];
} radius_packet_t;
-static lrad_randctx lrad_rand_pool; /* across multiple calls */
-static int lrad_rand_initialized = 0;
+static fr_randctx fr_rand_pool; /* across multiple calls */
+static int fr_rand_initialized = 0;
static unsigned int salt_offset = 0;
* possible combinations.
*/
static int rad_sendto(int sockfd, void *data, size_t data_len, int flags,
- lrad_ipaddr_t *src_ipaddr, int src_port,
- lrad_ipaddr_t *dst_ipaddr, int dst_port)
+ fr_ipaddr_t *src_ipaddr, int src_port,
+ fr_ipaddr_t *dst_ipaddr, int dst_port)
{
struct sockaddr_storage dst;
socklen_t sizeof_dst = sizeof(dst);
}
-ssize_t rad_recv_header(int sockfd, lrad_ipaddr_t *src_ipaddr, int *src_port,
+ssize_t rad_recv_header(int sockfd, fr_ipaddr_t *src_ipaddr, int *src_port,
int *code)
{
ssize_t data_len, packet_len;
* possible combinations.
*/
static ssize_t rad_recvfrom(int sockfd, uint8_t **pbuf, int flags,
- lrad_ipaddr_t *src_ipaddr, uint16_t *src_port,
- lrad_ipaddr_t *dst_ipaddr, uint16_t *dst_port)
+ fr_ipaddr_t *src_ipaddr, uint16_t *src_port,
+ fr_ipaddr_t *dst_ipaddr, uint16_t *dst_port)
{
struct sockaddr_storage src;
struct sockaddr_storage dst;
* add in some CSPRNG data. should be OK..
*/
passwd[0] = (0x80 | ( ((salt_offset++) & 0x0f) << 3) |
- (lrad_rand() & 0x07));
- passwd[1] = lrad_rand();
+ (fr_rand() & 0x07));
+ passwd[1] = fr_rand();
passwd[2] = inlen; /* length of the password string */
fr_MD5Init(&context);
* Merge information from the outside world into our
* random pool.
*/
- lrad_rand_seed(packet->data, AUTH_HDR_LEN);
+ fr_rand_seed(packet->data, AUTH_HDR_LEN);
return 0;
}
* add in some CSPRNG data. should be OK..
*/
salt[0] = (0x80 | ( ((salt_offset++) & 0x0f) << 3) |
- (lrad_rand() & 0x07));
- salt[1] = lrad_rand();
+ (fr_rand() & 0x07));
+ salt[1] = fr_rand();
/*
* Padd password to multiple of AUTH_PASS_LEN bytes.
*
* May be called any number of times.
*/
-void lrad_rand_seed(const void *data, size_t size)
+void fr_rand_seed(const void *data, size_t size)
{
uint32_t hash;
/*
* Ensure that the pool is initialized.
*/
- if (!lrad_rand_initialized) {
+ if (!fr_rand_initialized) {
int fd;
- memset(&lrad_rand_pool, 0, sizeof(lrad_rand_pool));
+ memset(&fr_rand_pool, 0, sizeof(fr_rand_pool));
fd = open("/dev/urandom", O_RDONLY);
if (fd >= 0) {
ssize_t this;
total = this = 0;
- while (total < sizeof(lrad_rand_pool.randrsl)) {
- this = read(fd, lrad_rand_pool.randrsl,
- sizeof(lrad_rand_pool.randrsl) - total);
+ while (total < sizeof(fr_rand_pool.randrsl)) {
+ this = read(fd, fr_rand_pool.randrsl,
+ sizeof(fr_rand_pool.randrsl) - total);
if ((this < 0) && (errno != EINTR)) break;
if (this > 0) total += this;
}
close(fd);
} else {
- lrad_rand_pool.randrsl[0] = fd;
- lrad_rand_pool.randrsl[1] = time(NULL);
- lrad_rand_pool.randrsl[2] = errno;
+ fr_rand_pool.randrsl[0] = fd;
+ fr_rand_pool.randrsl[1] = time(NULL);
+ fr_rand_pool.randrsl[2] = errno;
}
- lrad_randinit(&lrad_rand_pool, 1);
- lrad_rand_pool.randcnt = 0;
- lrad_rand_initialized = 1;
+ fr_randinit(&fr_rand_pool, 1);
+ fr_rand_pool.randcnt = 0;
+ fr_rand_initialized = 1;
}
if (!data) return;
/*
* Hash the user data
*/
- hash = lrad_rand();
- if (!hash) hash = lrad_rand();
- hash = lrad_hash_update(data, size, hash);
+ hash = fr_rand();
+ if (!hash) hash = fr_rand();
+ hash = fr_hash_update(data, size, hash);
- lrad_rand_pool.randmem[lrad_rand_pool.randcnt] ^= hash;
+ fr_rand_pool.randmem[fr_rand_pool.randcnt] ^= hash;
}
/*
* Return a 32-bit random number.
*/
-uint32_t lrad_rand(void)
+uint32_t fr_rand(void)
{
uint32_t num;
/*
* Ensure that the pool is initialized.
*/
- if (!lrad_rand_initialized) {
- lrad_rand_seed(NULL, 0);
+ if (!fr_rand_initialized) {
+ fr_rand_seed(NULL, 0);
}
- num = lrad_rand_pool.randrsl[lrad_rand_pool.randcnt++];
- if (lrad_rand_pool.randcnt == 256) {
- lrad_rand_pool.randcnt = 0;
- lrad_isaac(&lrad_rand_pool);
+ num = fr_rand_pool.randrsl[fr_rand_pool.randcnt++];
+ if (fr_rand_pool.randcnt == 256) {
+ fr_rand_pool.randcnt = 0;
+ fr_isaac(&fr_rand_pool);
}
return num;
* Don't expose the actual contents of the random
* pool.
*/
- base = lrad_rand();
+ base = fr_rand();
for (i = 0; i < AUTH_VECTOR_LEN; i += sizeof(uint32_t)) {
- hash = lrad_rand() ^ base;
+ hash = fr_rand() ^ base;
memcpy(rp->vector + i, &hash, sizeof(hash));
}
}
- lrad_rand(); /* stir the pool again */
+ fr_rand(); /* stir the pool again */
return rp;
}
#include <ctype.h>
-static const LRAD_NAME_NUMBER tokens[] = {
+static const FR_NAME_NUMBER tokens[] = {
{ "=~", T_OP_REG_EQ, }, /* order is important! */
{ "!~", T_OP_REG_NE, },
{ "{", T_LCBRACE, },
* At end-of-line, buf[0] is set to '\0'.
* Returns 0 or special token value.
*/
-static LRAD_TOKEN getthing(char **ptr, char *buf, int buflen, int tok,
- const LRAD_NAME_NUMBER *tokenlist)
+static FR_TOKEN getthing(char **ptr, char *buf, int buflen, int tok,
+ const FR_NAME_NUMBER *tokenlist)
{
char *s, *p;
int quote;
int escape;
unsigned int x;
- const LRAD_NAME_NUMBER*t;
- LRAD_TOKEN rcode;
+ const FR_NAME_NUMBER*t;
+ FR_TOKEN rcode;
buf[0] = 0;
while (isspace((int) *p))
p++;
*ptr = p;
- return (LRAD_TOKEN) t->number;
+ return (FR_TOKEN) t->number;
}
}
*/
int getbareword(char **ptr, char *buf, int buflen)
{
- LRAD_TOKEN token;
+ FR_TOKEN token;
token = getthing(ptr, buf, buflen, 0, NULL);
if (token != T_BARE_WORD) {
/*
* Read the next word, use tokens as delimiters.
*/
-LRAD_TOKEN gettoken(char **ptr, char *buf, int buflen)
+FR_TOKEN gettoken(char **ptr, char *buf, int buflen)
{
return getthing(ptr, buf, buflen, 1, tokens);
}
/*
* Expect a string.
*/
-LRAD_TOKEN getstring(char **ptr, char *buf, int buflen)
+FR_TOKEN getstring(char **ptr, char *buf, int buflen)
{
char *p = *ptr;
/*
* Convert a string to an integer
*/
-int lrad_str2int(const LRAD_NAME_NUMBER *table, const char *name, int def)
+int fr_str2int(const FR_NAME_NUMBER *table, const char *name, int def)
{
- const LRAD_NAME_NUMBER *this;
+ const FR_NAME_NUMBER *this;
for (this = table; this->name != NULL; this++) {
if (strcasecmp(this->name, name) == 0) {
/*
* Convert an integer to a string.
*/
-const char *lrad_int2str(const LRAD_NAME_NUMBER *table, int number,
+const char *fr_int2str(const FR_NAME_NUMBER *table, int number,
const char *def)
{
- const LRAD_NAME_NUMBER *this;
+ const FR_NAME_NUMBER *this;
for (this = table; this->name != NULL; this++) {
if (this->number == number) {
}
{
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
if (ip_hton(cs, AF_INET, &ipaddr) < 0) {
librad_log("Failed to find IP address for %s", cs);
* Read a valuepair from a buffer, and advance pointer.
* Sets *eol to T_EOL if end of line was encountered.
*/
-VALUE_PAIR *pairread(char **ptr, LRAD_TOKEN *eol)
+VALUE_PAIR *pairread(char **ptr, FR_TOKEN *eol)
{
char buf[64];
char attr[64];
char value[512];
char *p, *q;
- LRAD_TOKEN token, t, xlat;
+ FR_TOKEN token, t, xlat;
VALUE_PAIR *vp;
size_t len;
* Read one line of attribute/value pairs. This might contain
* multiple pairs seperated by comma's.
*/
-LRAD_TOKEN userparse(char *buffer, VALUE_PAIR **first_pair)
+FR_TOKEN userparse(char *buffer, VALUE_PAIR **first_pair)
{
VALUE_PAIR *vp;
char *p;
- LRAD_TOKEN last_token = T_OP_INVALID;
- LRAD_TOKEN previous_token;
+ FR_TOKEN last_token = T_OP_INVALID;
+ FR_TOKEN previous_token;
/*
* We allow an empty line.
VALUE_PAIR *readvp2(FILE *fp, int *pfiledone, const char *errprefix)
{
char buf[8192];
- LRAD_TOKEN last_token = T_EOL;
+ FR_TOKEN last_token = T_EOL;
VALUE_PAIR *vp;
VALUE_PAIR *list;
int error = 0;
* Duplicate code is bad.
*/
static int vqp_sendto(int sockfd, void *data, size_t data_len, int flags,
- lrad_ipaddr_t *src_ipaddr, lrad_ipaddr_t *dst_ipaddr,
+ fr_ipaddr_t *src_ipaddr, fr_ipaddr_t *dst_ipaddr,
int dst_port)
{
struct sockaddr_storage dst;
* FIXME: This is copied from rad_recvfrom, with minor edits.
*/
static ssize_t vqp_recvfrom(int sockfd, uint8_t **pbuf, int flags,
- lrad_ipaddr_t *src_ipaddr, uint16_t *src_port,
- lrad_ipaddr_t *dst_ipaddr, uint16_t *dst_port)
+ fr_ipaddr_t *src_ipaddr, uint16_t *src_port,
+ fr_ipaddr_t *dst_ipaddr, uint16_t *dst_port)
{
struct sockaddr_storage src;
struct sockaddr_storage dst;
return -1;
}
- switch (lrad_crypt_check((char *)auth_item->vp_strvalue,
+ switch (fr_crypt_check((char *)auth_item->vp_strvalue,
(char *)password_pair->vp_strvalue)) {
case -1:
rad_authlog("Login incorrect "
const RADCLIENT *a = one;
const RADCLIENT *b = two;
- return lrad_ipaddr_cmp(&a->ipaddr, &b->ipaddr);
+ return fr_ipaddr_cmp(&a->ipaddr, &b->ipaddr);
}
#ifdef WITH_SNMP
* Find a client in the RADCLIENTS list.
*/
RADCLIENT *client_find(const RADCLIENT_LIST *clients,
- const lrad_ipaddr_t *ipaddr)
+ const fr_ipaddr_t *ipaddr)
{
int i, max_prefix;
RADCLIENT myclient;
/*
* Old wrapper for client_find
*/
-RADCLIENT *client_find_old(const lrad_ipaddr_t *ipaddr)
+RADCLIENT *client_find_old(const fr_ipaddr_t *ipaddr)
{
return client_find(root_clients, ipaddr);
}
* Find the name of a client (prefer short name).
*/
const char *client_name(const RADCLIENT_LIST *clients,
- const lrad_ipaddr_t *ipaddr)
+ const fr_ipaddr_t *ipaddr)
{
/* We don't call this unless we should know about the client. */
RADCLIENT *cl;
return "UNKNOWN-CLIENT";
}
-const char *client_name_old(const lrad_ipaddr_t *ipaddr)
+const char *client_name_old(const fr_ipaddr_t *ipaddr)
{
return client_name(root_clients, ipaddr);
}
CONF_ITEM item;
char *attr;
char *value;
- LRAD_TOKEN operator;
- LRAD_TOKEN value_type;
+ FR_TOKEN operator;
+ FR_TOKEN value_type;
};
struct conf_part {
CONF_ITEM item;
* Create a new CONF_PAIR
*/
static CONF_PAIR *cf_pair_alloc(const char *attr, const char *value,
- LRAD_TOKEN operator, LRAD_TOKEN value_type,
+ FR_TOKEN operator, FR_TOKEN value_type,
CONF_SECTION *parent)
{
CONF_PAIR *cp;
int rcode = 0;
char **q;
const char *value;
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
const CONF_PAIR *cp;
char ipbuf[128];
/*
* No pthreads, no mutex.
*/
-static int lrad_crypt_init = 0;
-static pthread_mutex_t lrad_crypt_mutex;
+static int fr_crypt_init = 0;
+static pthread_mutex_t fr_crypt_mutex;
#endif
* -1 -- failed to crypt
* 1 -- check failed
*/
-int lrad_crypt_check(const char *key, const char *crypted)
+int fr_crypt_check(const char *key, const char *crypted)
{
char *passwd;
int cmp = 0;
/*
* Ensure we're thread-safe, as crypt() isn't.
*/
- if (lrad_crypt_init == 0) {
- pthread_mutex_init(&lrad_crypt_mutex, NULL);
- lrad_crypt_init = 1;
+ if (fr_crypt_init == 0) {
+ pthread_mutex_init(&fr_crypt_mutex, NULL);
+ fr_crypt_init = 1;
}
- pthread_mutex_lock(&lrad_crypt_mutex);
+ pthread_mutex_lock(&fr_crypt_mutex);
#endif
passwd = crypt(key, crypted);
}
#ifdef HAVE_PTHREAD_H
- pthread_mutex_unlock(&lrad_crypt_mutex);
+ pthread_mutex_unlock(&fr_crypt_mutex);
#endif
/*
FILE *fp;
int state;
time_t timestamp;
- lrad_ipaddr_t client_ip;
+ fr_ipaddr_t client_ip;
int load_factor; /* 1..100 */
int has_rtt;
* packets before having a collision, which means it's
* effectively impossible.
*/
- packet->id = lrad_rand() & 0xffff;
- packet->src_port = 1024 + (lrad_rand() & 0x7fff);
- packet->dst_port = 1024 + (lrad_rand() & 0x7fff);
+ packet->id = fr_rand() & 0xffff;
+ packet->src_port = 1024 + (fr_rand() & 0x7fff);
+ packet->dst_port = 1024 + (fr_rand() & 0x7fff);
packet->dst_ipaddr.af = AF_INET;
- packet->dst_ipaddr.ipaddr.ip4addr.s_addr = htonl((INADDR_LOOPBACK & ~0xffffff) | (lrad_rand() & 0xffffff));
+ packet->dst_ipaddr.ipaddr.ip4addr.s_addr = htonl((INADDR_LOOPBACK & ~0xffffff) | (fr_rand() & 0xffffff));
/*
* If everything's OK, this is a waste of memory.
static const char *expand_string(char *buffer, size_t sizeof_buffer,
REQUEST *request,
- LRAD_TOKEN value_type, const char *value)
+ FR_TOKEN value_type, const char *value)
{
int result;
char *p;
}
#ifdef HAVE_REGEX_H
-static LRAD_TOKEN getregex(char **ptr, char *buffer, size_t buflen, int *pcflags)
+static FR_TOKEN getregex(char **ptr, char *buffer, size_t buflen, int *pcflags)
{
char *p = *ptr;
char *q = buffer;
}
#endif
-static const LRAD_NAME_NUMBER modreturn_table[] = {
+static const FR_NAME_NUMBER modreturn_table[] = {
{ "reject", RLM_MODULE_REJECT },
{ "fail", RLM_MODULE_FAIL },
{ "ok", RLM_MODULE_OK },
int evaluate_next_condition = evaluate_it;
const char *p = *ptr;
const char *q, *start;
- LRAD_TOKEN token, lt, rt;
+ FR_TOKEN token, lt, rt;
char left[1024], right[1024], comp[4];
const char *pleft, *pright;
char xleft[1024], xright[1024];
result = (lint != 0);
} else if (lt == T_BARE_WORD) {
- result = (modreturn == lrad_str2int(modreturn_table, pleft, -1));
+ result = (modreturn == fr_str2int(modreturn_table, pleft, -1));
} else {
result = (*pleft != '\0');
}
CONF_ITEM item;
char *attr;
char *value;
- LRAD_TOKEN operator;
- LRAD_TOKEN value_type;
+ FR_TOKEN operator;
+ FR_TOKEN value_type;
};
/*
/*
* Ridiculous amounts of local state.
*/
-static lrad_event_list_t *el = NULL;
-static lrad_packet_list_t *pl = NULL;
+static fr_event_list_t *el = NULL;
+static fr_packet_list_t *pl = NULL;
static int request_num_counter = 0;
static struct timeval now;
static time_t start_time;
#define PTHREAD_MUTEX_UNLOCK(_x)
#endif
-#define INSERT_EVENT(_function, _ctx) if (!lrad_event_insert(el, _function, _ctx, &((_ctx)->when), &((_ctx)->ev))) { _rad_panic(__FILE__, __LINE__, "Failed to insert event"); }
+#define INSERT_EVENT(_function, _ctx) if (!fr_event_insert(el, _function, _ctx, &((_ctx)->when), &((_ctx)->ev))) { _rad_panic(__FILE__, __LINE__, "Failed to insert event"); }
-static lrad_packet_list_t *proxy_list = NULL;
+static fr_packet_list_t *proxy_list = NULL;
/*
* We keep the proxy FD's here. The RADIUS Id's are marked
{
if (!request->in_request_hash) return;
- lrad_packet_list_yank(pl, request->packet);
+ fr_packet_list_yank(pl, request->packet);
request->in_request_hash = FALSE;
snmp_inc_counters(request);
REQUEST *request;
PTHREAD_MUTEX_LOCK(&proxy_mutex);
- proxy_p = lrad_packet_list_find_byreply(proxy_list, reply);
+ proxy_p = fr_packet_list_find_byreply(proxy_list, reply);
if (!proxy_p) {
PTHREAD_MUTEX_UNLOCK(&proxy_mutex);
return NULL;
}
- request = lrad_packet2myptr(REQUEST, proxy, proxy_p);
+ request = fr_packet2myptr(REQUEST, proxy, proxy_p);
if (!request) {
PTHREAD_MUTEX_UNLOCK(&proxy_mutex);
* correctly.
*/
if (request->num_proxied_requests == request->num_proxied_responses) {
- lrad_packet_list_yank(proxy_list, request->proxy);
- lrad_packet_list_id_free(proxy_list, request->proxy);
+ fr_packet_list_yank(proxy_list, request->proxy);
+ fr_packet_list_id_free(proxy_list, request->proxy);
request->in_proxy_hash = FALSE;
}
if (!request->in_proxy_hash) return;
PTHREAD_MUTEX_LOCK(&proxy_mutex);
- lrad_packet_list_yank(proxy_list, request->proxy);
- lrad_packet_list_id_free(proxy_list, request->proxy);
+ fr_packet_list_yank(proxy_list, request->proxy);
+ fr_packet_list_id_free(proxy_list, request->proxy);
/*
* The home server hasn't replied, but we've given up on
request->home_server->total_requests_sent--;
}
- if (!lrad_packet_list_id_alloc(proxy_list, request->proxy)) {
+ if (!fr_packet_list_id_alloc(proxy_list, request->proxy)) {
int found;
rad_listen_t *proxy_listener;
}
rad_assert(found >= 0);
- if (!lrad_packet_list_socket_add(proxy_list, proxy_listener->fd)) {
+ if (!fr_packet_list_socket_add(proxy_list, proxy_listener->fd)) {
PTHREAD_MUTEX_UNLOCK(&proxy_mutex);
DEBUG2("ERROR: Failed to create a new socket for proxying requests.");
return 0; /* leak proxy_listener */
}
- if (!lrad_packet_list_id_alloc(proxy_list, request->proxy)) {
+ if (!fr_packet_list_id_alloc(proxy_list, request->proxy)) {
PTHREAD_MUTEX_UNLOCK(&proxy_mutex);
DEBUG2("ERROR: Failed to create a new socket for proxying requests.");
return 0;
rad_assert(proxy_listeners[proxy] != NULL);
request->proxy_listener = proxy_listeners[proxy];
- if (!lrad_packet_list_insert(proxy_list, &request->proxy)) {
- lrad_packet_list_id_free(proxy_list, request->proxy);
+ if (!fr_packet_list_insert(proxy_list, &request->proxy)) {
+ fr_packet_list_id_free(proxy_list, request->proxy);
PTHREAD_MUTEX_UNLOCK(&proxy_mutex);
DEBUG2("ERROR: Failed to insert entry into proxy list");
return 0;
request->number,
(unsigned int) (request->timestamp - start_time));
}
- lrad_event_delete(el, &request->ev);
+ fr_event_delete(el, &request->ev);
remove_from_proxy_hash(request);
remove_from_request_hash(request);
request_free(&request);
request->number, request->packet->id,
(unsigned int) (request->timestamp - start_time));
- lrad_event_delete(el, &request->ev);
+ fr_event_delete(el, &request->ev);
request_free(&request);
}
buffer, sizeof(buffer)),
request->proxy->dst_port);
- if (!lrad_event_delete(el, &home->ev)) {
+ if (!fr_event_delete(el, &home->ev)) {
DEBUG2("Hmm... no event for home server, WTF?");
}
- if (!lrad_event_delete(el, &request->ev)) {
+ if (!fr_event_delete(el, &request->ev)) {
DEBUG2("Hmm... no event for request, WTF?");
}
request->proxy = rad_alloc(1);
rad_assert(request->proxy != NULL);
- lrad_event_now(el, &request->when);
+ fr_event_now(el, &request->when);
home->when = request->when;
if (home->ping_check == HOME_PING_CHECK_STATUS_SERVER) {
*/
home->when.tv_sec += home->ping_interval - 2;
- jitter = lrad_rand();
+ jitter = fr_rand();
jitter ^= (jitter >> 10);
jitter &= ((1 << 23) - 1); /* 22 bits of 1 */
{
struct timeval when;
REQUEST *request = ctx;
- lrad_event_callback_t callback = NULL;
+ fr_event_callback_t callback = NULL;
rad_assert(request->magic == REQUEST_MAGIC);
* this call won't re-set it, because we're not
* in the event loop.
*/
- lrad_event_now(el, &now);
+ fr_event_now(el, &now);
if (timercmp(&now, &when, <)) {
if (request->delay < (USEC / 10)) {
* error.
*/
if (root->max_requests) {
- int request_count = lrad_packet_list_num_elements(pl);
+ int request_count = fr_packet_list_num_elements(pl);
/*
* This is a new request. Let's see if
REQUEST *request = NULL;
struct main_config_t *root = &mainconfig;
- packet_p = lrad_packet_list_find(pl, packet);
+ packet_p = fr_packet_list_find(pl, packet);
if (packet_p) {
- request = lrad_packet2myptr(REQUEST, packet, packet_p);
+ request = fr_packet2myptr(REQUEST, packet, packet_p);
rad_assert(request->in_request_hash);
if ((request->packet->data_len == packet->data_len) &&
/*
* Remember the request in the list.
*/
- if (!lrad_packet_list_insert(pl, &request->packet)) {
+ if (!fr_packet_list_insert(pl, &request->packet)) {
radlog(L_ERR, "Failed to insert request %d in the list of live requests: discarding", request->number);
request_free(&request);
return 0;
if ((flag & (RADIUS_SIGNAL_SELF_EXIT | RADIUS_SIGNAL_SELF_TERM)) != 0) {
if ((flag & RADIUS_SIGNAL_SELF_EXIT) != 0) {
- lrad_event_loop_exit(el, 1);
+ fr_event_loop_exit(el, 1);
} else {
- lrad_event_loop_exit(el, 2);
+ fr_event_loop_exit(el, 2);
}
return;
}
last_hup = when;
- lrad_event_loop_exit(el, 0x80);
+ fr_event_loop_exit(el, 0x80);
}
}
}
-static void event_signal_handler(lrad_event_list_t *xel, int fd, void *ctx)
+static void event_signal_handler(fr_event_list_t *xel, int fd, void *ctx)
{
size_t i, rcode;
char buffer[32];
tv_add(&when, usec);
- if (!lrad_event_fd_delete(el, 0, fd)) {
+ if (!fr_event_fd_delete(el, 0, fd)) {
rad_panic("Failed deleting fd");
}
- if (!lrad_event_insert(el, event_poll_fd, listener,
+ if (!fr_event_insert(el, event_poll_fd, listener,
&when, NULL)) {
rad_panic("Failed inserting event");
}
* FIXME: On Linux, use inotify to watch the detail file. This
*
*/
-static void event_detail_handler(lrad_event_list_t *xel, int fd, void *ctx)
+static void event_detail_handler(fr_event_list_t *xel, int fd, void *ctx)
{
rad_listen_t *listener = ctx;
RAD_REQUEST_FUNP fun;
}
-static void event_socket_handler(lrad_event_list_t *xel, int fd, void *ctx)
+static void event_socket_handler(fr_event_list_t *xel, int fd, void *ctx)
{
rad_listen_t *listener = ctx;
RAD_REQUEST_FUNP fun;
RAD_REQUEST_FUNP fun;
REQUEST *request;
rad_listen_t *listener = ctx;
- lrad_event_fd_handler_t handler;
+ fr_event_fd_handler_t handler;
/*
* Ignore the detail file if we're busy with other work.
gettimeofday(&when, NULL);
when.tv_sec += 1;
- if (!lrad_event_insert(el, event_poll_fd, listener,
+ if (!fr_event_insert(el, event_poll_fd, listener,
&when, NULL)) {
rad_panic("Failed inserting event");
}
/*
* We have an FD. Start watching it.
*/
- if (!lrad_event_fd_insert(el, 0, listener->fd,
+ if (!fr_event_fd_insert(el, 0, listener->fd,
handler, listener)) {
char buffer[256];
time(&start_time);
- el = lrad_event_list_create(event_status);
+ el = fr_event_list_create(event_status);
if (!el) return 0;
- pl = lrad_packet_list_create(0);
+ pl = fr_packet_list_create(0);
if (!el) return 0;
request_num_counter = 0;
* Create the tree for managing proxied requests and
* responses.
*/
- proxy_list = lrad_packet_list_create(1);
+ proxy_list = fr_packet_list_create(1);
if (!proxy_list) return 0;
#ifdef HAVE_PTHREAD_H
exit(1);
}
- if (!lrad_event_fd_insert(el, 0, self_pipe[0],
+ if (!fr_event_fd_insert(el, 0, self_pipe[0],
event_signal_handler, el)) {
radlog(L_ERR, "Failed creating handler for signals");
exit(1);
proxy_fds[this->fd & 0x1f] = this->fd;
proxy_listeners[this->fd & 0x1f] = this;
- if (!lrad_packet_list_socket_add(proxy_list,
+ if (!fr_packet_list_socket_add(proxy_list,
this->fd)) {
rad_assert(0 == 1);
}
gettimeofday(&when, NULL);
when.tv_sec += 1;
- if (!lrad_event_insert(el, event_poll_fd, this,
+ if (!fr_event_insert(el, event_poll_fd, this,
&when, NULL)) {
radlog(L_ERR, "Failed creating handler");
exit(1);
* FIXME: if we DO open the detail files automatically,
* then much of this code becomes simpler.
*/
- if (!lrad_event_fd_insert(el, 0, this->fd,
+ if (!fr_event_fd_insert(el, 0, this->fd,
event_socket_handler, this)) {
this->print(this, buffer, sizeof(buffer));
radlog(L_ERR, "Failed creating handler for socket %s",
static int request_hash_cb(void *ctx, void *data)
{
ctx = ctx; /* -Wunused */
- REQUEST *request = lrad_packet2myptr(REQUEST, packet, data);
+ REQUEST *request = fr_packet2myptr(REQUEST, packet, data);
rad_assert(request->in_proxy_hash == FALSE);
- lrad_event_delete(el, &request->ev);
+ fr_event_delete(el, &request->ev);
remove_from_request_hash(request);
request_free(&request);
static int proxy_hash_cb(void *ctx, void *data)
{
ctx = ctx; /* -Wunused */
- REQUEST *request = lrad_packet2myptr(REQUEST, proxy, data);
+ REQUEST *request = fr_packet2myptr(REQUEST, proxy, data);
- lrad_packet_list_yank(proxy_list, request->proxy);
+ fr_packet_list_yank(proxy_list, request->proxy);
request->in_proxy_hash = FALSE;
if (!request->in_request_hash) {
- lrad_event_delete(el, &request->ev);
+ fr_event_delete(el, &request->ev);
request_free(&request);
}
*/
if (proxy_list) {
PTHREAD_MUTEX_LOCK(&proxy_mutex);
- lrad_packet_list_walk(proxy_list, NULL, proxy_hash_cb);
+ fr_packet_list_walk(proxy_list, NULL, proxy_hash_cb);
PTHREAD_MUTEX_UNLOCK(&proxy_mutex);
- lrad_packet_list_free(proxy_list);
+ fr_packet_list_free(proxy_list);
proxy_list = NULL;
}
- lrad_packet_list_walk(pl, NULL, request_hash_cb);
+ fr_packet_list_walk(pl, NULL, request_hash_cb);
- lrad_packet_list_free(pl);
+ fr_packet_list_free(pl);
pl = NULL;
- lrad_event_list_free(el);
+ fr_event_list_free(el);
}
int radius_event_process(void)
just_started = TRUE;
- return lrad_event_loop(el);
+ return fr_event_loop(el);
}
void radius_handle_request(REQUEST *request, RAD_REQUEST_FUNP fun)
PAIR_LIST **last = &pl;
int lineno = 0;
int old_lineno = 0;
- LRAD_TOKEN parsecode;
+ FR_TOKEN parsecode;
char newfile[8192];
/*
/*
* For normal sockets.
*/
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
int port;
RADCLIENT_LIST *clients;
} listen_socket_t;
* Find a per-socket client.
*/
RADCLIENT *client_listener_find(const rad_listen_t *listener,
- const lrad_ipaddr_t *ipaddr)
+ const fr_ipaddr_t *ipaddr)
{
const RADCLIENT_LIST *clients;
{
int rcode;
int listen_port;
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
listen_socket_t *sock = this->data;
const char *section_name = NULL;
CONF_SECTION *client_cs, *parentcs;
RAD_REQUEST_FUNP fun = NULL;
char buffer[128];
RADCLIENT *client;
- lrad_ipaddr_t src_ipaddr;
+ fr_ipaddr_t src_ipaddr;
rcode = rad_recv_header(listener->fd, &src_ipaddr, &src_port, &code);
if (rcode < 0) return 0;
RAD_REQUEST_FUNP fun = NULL;
char buffer[128];
RADCLIENT *client;
- lrad_ipaddr_t src_ipaddr;
+ fr_ipaddr_t src_ipaddr;
rcode = rad_recv_header(listener->fd, &src_ipaddr, &src_port, &code);
if (rcode < 0) return 0;
if ((sock->port == other->port) &&
(sock->ipaddr.af == other->ipaddr.af) &&
- (lrad_ipaddr_cmp(&sock->ipaddr, &other->ipaddr) == 0)) {
+ (fr_ipaddr_cmp(&sock->ipaddr, &other->ipaddr) == 0)) {
this->fd = (*last)->fd;
(*last)->fd = -1;
return 0;
}
}
- this->fd = lrad_socket(&sock->ipaddr, sock->port);
+ this->fd = fr_socket(&sock->ipaddr, sock->port);
if (this->fd < 0) {
radlog(L_ERR, "ERROR: Failed to open socket: %s",
librad_errstr);
}
-static const LRAD_NAME_NUMBER listen_compare[] = {
+static const FR_NAME_NUMBER listen_compare[] = {
{ "auth", RAD_LISTEN_AUTH },
{ "acct", RAD_LISTEN_ACCT },
{ "detail", RAD_LISTEN_DETAIL },
return NULL;
}
- type = lrad_str2int(listen_compare, listen_type,
+ type = fr_str2int(listen_compare, listen_type,
RAD_LISTEN_NONE);
if (type == RAD_LISTEN_NONE) {
cf_log_err(cf_sectiontoitem(cs),
CONF_SECTION *cs;
rad_listen_t **last;
rad_listen_t *this;
- lrad_ipaddr_t server_ipaddr;
+ fr_ipaddr_t server_ipaddr;
int auth_port = 0;
/*
}
}
- if (port < 0) port = 1024 + (lrad_rand() & 0x1ff);
+ if (port < 0) port = 1024 + (fr_rand() & 0x1ff);
/*
* Address is still unspecified, use IPv4.
/*
* Logging facility names
*/
-static const LRAD_NAME_NUMBER levels[] = {
+static const FR_NAME_NUMBER levels[] = {
{ ": Debug: ", L_DBG },
{ ": Auth: ", L_AUTH },
{ ": Proxy: ", L_PROXY },
timeval = time(NULL);
CTIME_R(&timeval, buffer + len, sizeof(buffer) - len - 1);
- s = lrad_int2str(levels, (lvl & ~L_CONS), ": ");
+ s = fr_int2str(levels, (lvl & ~L_CONS), ": ");
strcat(buffer, s);
len = strlen(buffer);
static const char *localstatedir = NULL;
static const char *prefix = NULL;
static char *syslog_facility = NULL;
-static const LRAD_NAME_NUMBER str2fac[] = {
+static const FR_NAME_NUMBER str2fac[] = {
#ifdef LOG_KERN
{ "kern", LOG_KERN },
#endif
}
-static const LRAD_NAME_NUMBER str2dest[] = {
+static const FR_NAME_NUMBER str2dest[] = {
{ "null", RADLOG_NULL },
{ "files", RADLOG_FILES },
{ "syslog", RADLOG_SYSLOG },
"files");
if (rcode < 0) return -1;
- mainconfig.radlog_dest = lrad_str2int(str2dest, radlog_dest, RADLOG_NUM_DEST);
+ mainconfig.radlog_dest = fr_str2int(str2dest, radlog_dest, RADLOG_NUM_DEST);
if (mainconfig.radlog_dest == RADLOG_NUM_DEST) {
fprintf(stderr, "radiusd: Error: Unknown log_destination %s\n",
radlog_dest);
cf_section_free(&cs);
return -1;
}
- mainconfig.syslog_facility = lrad_str2int(str2fac, syslog_facility, -1);
+ mainconfig.syslog_facility = fr_str2int(str2fac, syslog_facility, -1);
if (mainconfig.syslog_facility < 0) {
fprintf(stderr, "radiusd: Error: Unknown syslog_facility %s\n",
syslog_facility);
module_instance_t *modinst;
} modsingle;
-static const LRAD_NAME_NUMBER grouptype_table[] = {
+static const FR_NAME_NUMBER grouptype_table[] = {
{ "", GROUPTYPE_SIMPLE },
{ "redundant ", GROUPTYPE_REDUNDANT },
{ "append ", GROUPTYPE_APPEND },
/* Here's where we recognize all of our keywords: first the rcodes, then the
* actions */
-static const LRAD_NAME_NUMBER rcode_table[] = {
+static const FR_NAME_NUMBER rcode_table[] = {
{ "reject", RLM_MODULE_REJECT },
{ "fail", RLM_MODULE_FAIL },
{ "ok", RLM_MODULE_OK },
if (strcasecmp(attr, "default") != 0) {
int rcode;
- rcode = lrad_str2int(rcode_table, attr, -1);
+ rcode = fr_str2int(rcode_table, attr, -1);
if (rcode < 0) {
cf_log_err(cf_pairtoitem(cp),
"Unknown module rcode '%s'.\n",
count++;
- if ((count * (lrad_rand() & 0xffff)) < (uint32_t) 0x10000) {
+ if ((count * (fr_rand() & 0xffff)) < (uint32_t) 0x10000) {
q = p;
}
}
stack.pointer + 1, modcall_spaces,
group_name[child->type],
child->name ? child->name : "",
- lrad_int2str(rcode_table,
+ fr_int2str(rcode_table,
stack.result[stack.pointer],
"??"));
goto do_return;
DEBUG2("%.*s[%s] returns %s",
stack.pointer + 1, modcall_spaces,
child->name ? child->name : "",
- lrad_int2str(rcode_table, myresult, "??"));
+ fr_int2str(rcode_table, myresult, "??"));
/*
stack.pointer + 1, modcall_spaces,
group_name[parent->type],
parent->name ? parent->name : "",
- lrad_int2str(rcode_table, myresult, "??"));
+ fr_int2str(rcode_table, myresult, "??"));
if ((parent->type == MOD_IF) ||
(parent->type == MOD_ELSIF)) {
for(i = 0; i<RLM_MODULE_NUMCODES; ++i) {
DEBUG("%.*s%s = %s", indent+1, "\t\t\t\t\t\t\t\t\t\t\t",
- lrad_int2str(rcode_table, i, "??"),
+ fr_int2str(rcode_table, i, "??"),
action2str(c->actions[i]));
}
* is that it's unique.
*/
do {
- value = lrad_rand() & 0x00ffffff;
+ value = fr_rand() & 0x00ffffff;
} while (dict_valbyattr(dattr->attr, value));
if (dict_addvalue(name, dattr->name, value) < 0) {
static int server_port = 0;
static int packet_code = 0;
-static lrad_ipaddr_t server_ipaddr;
+static fr_ipaddr_t server_ipaddr;
static int resend_count = 1;
static int done = 1;
static int print_filename = 0;
-static lrad_ipaddr_t client_ipaddr;
+static fr_ipaddr_t client_ipaddr;
static int client_port = 0;
static int sockfd;
static int last_used_id = -1;
static rbtree_t *filename_tree = NULL;
-static lrad_packet_list_t *pl = NULL;
+static fr_packet_list_t *pl = NULL;
static int sleep_time = -1;
/*
* One more unused RADIUS ID.
*/
- lrad_packet_list_id_free(pl, radclient->request);
+ fr_packet_list_id_free(pl, radclient->request);
radclient->request->id = -1;
/*
* this packet.
*/
retry:
- rcode = lrad_packet_list_id_alloc(pl, radclient->request);
+ rcode = fr_packet_list_id_alloc(pl, radclient->request);
if (rcode < 0) {
int mysockfd;
- mysockfd = lrad_socket(&client_ipaddr, 0);
+ mysockfd = fr_socket(&client_ipaddr, 0);
if (!mysockfd) {
fprintf(stderr, "radclient: Can't open new socket\n");
exit(1);
}
- if (!lrad_packet_list_socket_add(pl, mysockfd)) {
+ if (!fr_packet_list_socket_add(pl, mysockfd)) {
fprintf(stderr, "radclient: Can't add new socket\n");
exit(1);
}
assert(radclient->request->data == NULL);
for (i = 0; i < 4; i++) {
- *((uint32_t *) radclient->request->vector) = lrad_rand();
+ *((uint32_t *) radclient->request->vector) = fr_rand();
}
/*
/*
* Duplicate found. Serious error!
*/
- if (!lrad_packet_list_insert(pl, &radclient->request)) {
+ if (!fr_packet_list_insert(pl, &radclient->request)) {
assert(0 == 1);
}
* Delete the request from the tree of
* outstanding requests.
*/
- lrad_packet_list_yank(pl, radclient->request);
+ fr_packet_list_yank(pl, radclient->request);
fprintf(stderr, "radclient: no response from server for ID %d socket %d\n", radclient->request->id, radclient->request->sockfd);
deallocate_id(radclient);
/* And wait for reply, timing out as necessary */
FD_ZERO(&set);
- max_fd = lrad_packet_list_fd_set(pl, &set);
+ max_fd = fr_packet_list_fd_set(pl, &set);
if (max_fd < 0) exit(1); /* no sockets to listen on! */
if (wait_time <= 0) {
/*
* Look for the packet.
*/
- reply = lrad_packet_list_recv(pl, &set);
+ reply = fr_packet_list_recv(pl, &set);
if (!reply) {
fprintf(stderr, "radclient: received bad packet: %s\n",
librad_errstr);
if (librad_debug > 2) print_hex(reply);
- request_p = lrad_packet_list_find_byreply(pl, reply);
+ request_p = fr_packet_list_find_byreply(pl, reply);
if (!request_p) {
fprintf(stderr, "radclient: received response to request we did not send. (id=%d socket %d)\n", reply->id, reply->sockfd);
rad_free(&reply);
return -1; /* got reply to packet we didn't send */
}
- radclient = lrad_packet2myptr(radclient_t, request, request_p);
+ radclient = fr_packet2myptr(radclient_t, request, request_p);
/*
* Fails the signature validation: not a real reply.
goto packet_done; /* shared secret is incorrect */
}
- lrad_packet_list_yank(pl, radclient->request);
+ fr_packet_list_yank(pl, radclient->request);
if (print_filename) printf("%s:%d %d\n",
radclient->filename,
radclient->packet_number,
client_ipaddr = radclient_head->request->src_ipaddr;
client_port = radclient_head->request->src_port;
}
- sockfd = lrad_socket(&client_ipaddr, client_port);
+ sockfd = fr_socket(&client_ipaddr, client_port);
if (sockfd < 0) {
fprintf(stderr, "radclient: socket: %s\n", librad_errstr);
exit(1);
}
- pl = lrad_packet_list_create(1);
+ pl = fr_packet_list_create(1);
if (!pl) {
fprintf(stderr, "radclient: Out of memory\n");
exit(1);
}
- if (!lrad_packet_list_socket_add(pl, sockfd)) {
+ if (!fr_packet_list_socket_add(pl, sockfd)) {
fprintf(stderr, "radclient: Out of memory\n");
exit(1);
}
/*
* Still have outstanding requests.
*/
- if (lrad_packet_list_num_elements(pl) > 0) {
+ if (fr_packet_list_num_elements(pl) > 0) {
done = 0;
} else {
sleep_time = 0;
} while (!done);
rbtree_free(filename_tree);
- lrad_packet_list_free(pl);
+ fr_packet_list_free(pl);
dict_free();
if (do_summary) {
char *radius_filter = NULL;
int packet_count = -1; /* how many packets to sniff */
int opt;
- LRAD_TOKEN parsecode;
+ FR_TOKEN parsecode;
const char *radius_dir = RADIUS_DIR;
int port = 1812;
if (a->port < b->port) return -1;
if (a->port > b->port) return +1;
- return lrad_ipaddr_cmp(&a->ipaddr, &b->ipaddr);
+ return fr_ipaddr_cmp(&a->ipaddr, &b->ipaddr);
}
cp = cf_pair_find(cs, "type");
if (cp) {
- static LRAD_NAME_NUMBER pool_types[] = {
+ static FR_NAME_NUMBER pool_types[] = {
{ "load-balance", HOME_POOL_LOAD_BALANCE },
{ "fail-over", HOME_POOL_FAIL_OVER },
{ "round_robin", HOME_POOL_LOAD_BALANCE },
goto error;
}
- pool->type = lrad_str2int(pool_types, value, 0);
+ pool->type = fr_str2int(pool_types, value, 0);
if (!pool->type) {
cf_log_err(cf_pairtoitem(cp),
"Unknown type \"%s\".",
case HOME_POOL_CLIENT_BALANCE:
switch (request->packet->src_ipaddr.af) {
case AF_INET:
- hash = lrad_hash(&request->packet->src_ipaddr.ipaddr.ip4addr,
+ hash = fr_hash(&request->packet->src_ipaddr.ipaddr.ip4addr,
sizeof(request->packet->src_ipaddr.ipaddr.ip4addr));
break;
case AF_INET6:
- hash = lrad_hash(&request->packet->src_ipaddr.ipaddr.ip6addr,
+ hash = fr_hash(&request->packet->src_ipaddr.ipaddr.ip6addr,
sizeof(request->packet->src_ipaddr.ipaddr.ip6addr));
break;
default:
case HOME_POOL_CLIENT_PORT_BALANCE:
switch (request->packet->src_ipaddr.af) {
case AF_INET:
- hash = lrad_hash(&request->packet->src_ipaddr.ipaddr.ip4addr,
+ hash = fr_hash(&request->packet->src_ipaddr.ipaddr.ip4addr,
sizeof(request->packet->src_ipaddr.ipaddr.ip4addr));
break;
case AF_INET6:
- hash = lrad_hash(&request->packet->src_ipaddr.ipaddr.ip6addr,
+ hash = fr_hash(&request->packet->src_ipaddr.ipaddr.ip6addr,
sizeof(request->packet->src_ipaddr.ipaddr.ip6addr));
break;
default:
hash = 0;
break;
}
- lrad_hash_update(&request->packet->src_port,
+ fr_hash_update(&request->packet->src_port,
sizeof(request->packet->src_port), hash);
start = hash % pool->num_home_servers;
break;
case HOME_POOL_KEYED_BALANCE:
if ((vp = pairfind(request->config_items, PW_LOAD_BALANCE_KEY)) != NULL) {
- hash = lrad_hash(vp->vp_strvalue, vp->length);
+ hash = fr_hash(vp->vp_strvalue, vp->length);
start = hash % pool->num_home_servers;
break;
}
* From the list of servers which have the same
* load, choose one at random.
*/
- if (((count + 1) * (lrad_rand() & 0xffff)) < (uint32_t) 0x10000) {
+ if (((count + 1) * (fr_rand() & 0xffff)) < (uint32_t) 0x10000) {
found = home;
}
}
-home_server *home_server_find(lrad_ipaddr_t *ipaddr, int port)
+home_server *home_server_find(fr_ipaddr_t *ipaddr, int port)
{
home_server myhome;
char address[16];
char port[11];
RADCLIENT *cl;
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
ipaddr.af = AF_INET;
ipaddr.ipaddr.ip4addr.s_addr = nasaddr;
int spawn_flag;
pthread_mutex_t wait_mutex;
- lrad_hash_table_t *waiters;
+ fr_hash_table_t *waiters;
/*
* All threads wait on this semaphore, for requests
int max_queue_size;
int num_queued;
int can_read_detail;
- lrad_fifo_t *fifo[NUM_FIFOS];
+ fr_fifo_t *fifo[NUM_FIFOS];
} THREAD_POOL;
static THREAD_POOL thread_pool;
if (pid <= 0) break;
mytf.pid = pid;
- tf = lrad_hash_table_finddata(thread_pool.waiters, &mytf);
+ tf = fr_hash_table_finddata(thread_pool.waiters, &mytf);
if (!tf) continue;
tf->status = status;
tf->exited = 1;
- } while (lrad_hash_table_num_elements(thread_pool.waiters) > 0);
+ } while (fr_hash_table_num_elements(thread_pool.waiters) > 0);
pthread_mutex_unlock(&thread_pool.wait_mutex);
}
/*
* Push the request onto the appropriate fifo for that
*/
- if (!lrad_fifo_push(thread_pool.fifo[request->priority],
+ if (!fr_fifo_push(thread_pool.fifo[request->priority],
entry)) {
pthread_mutex_unlock(&thread_pool.queue_mutex);
radlog(L_ERR, "!!! ERROR !!! Failed inserting request %d into the queue", request->number);
* requests will be quickly cleared.
*/
for (i = 0; i < RAD_LISTEN_MAX; i++) {
- entry = lrad_fifo_peek(thread_pool.fifo[i]);
+ entry = fr_fifo_peek(thread_pool.fifo[i]);
if (!entry ||
(entry->request->master_state != REQUEST_STOP_PROCESSING)) {
continue;
/*
* This entry was marked to be stopped. Acknowledge it.
*/
- entry = lrad_fifo_pop(thread_pool.fifo[i]);
+ entry = fr_fifo_pop(thread_pool.fifo[i]);
rad_assert(entry != NULL);
entry->request->child_state = REQUEST_DONE;
}
* Pop results from the top of the queue
*/
for (i = start; i < RAD_LISTEN_MAX; i++) {
- entry = lrad_fifo_pop(thread_pool.fifo[i]);
+ entry = fr_fifo_pop(thread_pool.fifo[i]);
if (entry) {
start = i;
break;
{
const thread_fork_t *tf = data;
- return lrad_hash(&tf->pid, sizeof(tf->pid));
+ return fr_hash(&tf->pid, sizeof(tf->pid));
}
static int pid_cmp(const void *one, const void *two)
/*
* Create the hash table of child PID's
*/
- thread_pool.waiters = lrad_hash_table_create(pid_hash,
+ thread_pool.waiters = fr_hash_table_create(pid_hash,
pid_cmp,
free);
if (!thread_pool.waiters) {
* Allocate multiple fifos.
*/
for (i = 0; i < RAD_LISTEN_MAX; i++) {
- thread_pool.fifo[i] = lrad_fifo_create(65536, NULL);
+ thread_pool.fifo[i] = fr_fifo_create(65536, NULL);
if (!thread_pool.fifo[i]) {
radlog(L_ERR, "FATAL: Failed to set up request fifo");
return -1;
reap_children(); /* be nice to non-wait thingies */
- if (lrad_hash_table_num_elements(thread_pool.waiters) >= 1024) {
+ if (fr_hash_table_num_elements(thread_pool.waiters) >= 1024) {
return -1;
}
tf->pid = child_pid;
pthread_mutex_lock(&thread_pool.wait_mutex);
- rcode = lrad_hash_table_insert(thread_pool.waiters, tf);
+ rcode = fr_hash_table_insert(thread_pool.waiters, tf);
pthread_mutex_unlock(&thread_pool.wait_mutex);
if (!rcode) {
mytf.pid = pid;
pthread_mutex_lock(&thread_pool.wait_mutex);
- tf = lrad_hash_table_finddata(thread_pool.waiters, &mytf);
+ tf = fr_hash_table_finddata(thread_pool.waiters, &mytf);
pthread_mutex_unlock(&thread_pool.wait_mutex);
if (!tf) return -1;
*status = tf->status;
pthread_mutex_lock(&thread_pool.wait_mutex);
- lrad_hash_table_delete(thread_pool.waiters, &mytf);
+ fr_hash_table_delete(thread_pool.waiters, &mytf);
pthread_mutex_unlock(&thread_pool.wait_mutex);
return pid;
}
* 10 seconds have passed, give up on the child.
*/
pthread_mutex_lock(&thread_pool.wait_mutex);
- lrad_hash_table_delete(thread_pool.waiters, &mytf);
+ fr_hash_table_delete(thread_pool.waiters, &mytf);
pthread_mutex_unlock(&thread_pool.wait_mutex);
return 0;
#include <freeradius-devel/rad_assert.h>
extern RADCLIENT *client_listener_find(const rad_listen_t *listener,
- const lrad_ipaddr_t *ipaddr);
+ const fr_ipaddr_t *ipaddr);
#ifdef WITH_VMPS
/*
DICT_ATTR *dattr;
ATTR_FLAGS flags;
- static const LRAD_NAME_NUMBER names[] = {
+ static const FR_NAME_NUMBER names[] = {
{ "string", PW_TYPE_STRING },
{ "integer", PW_TYPE_INTEGER },
{ "ipaddr", PW_TYPE_IPADDR },
* so we don't have to do string comparisons on each
* packet.
*/
- data->dat_type = lrad_str2int(names, data->data_type, -1);
+ data->dat_type = fr_str2int(names, data->data_type, -1);
if (data->dat_type < 0) {
radlog(L_ERR, "rlm_checkval: Data type %s in not known",data->data_type);
checkval_detach(data);
}
static int sm_parse_file(FILE*fp,const char* fname) {
- LRAD_TOKEN tok;
+ FR_TOKEN tok;
VALUE_PAIR *vp = NULL;
sm_parse_state_t parse_state = SMP_USER;
unsigned long lino = 0;
/* log src/dst information */
int log_srcdst;
- lrad_hash_table_t *ht;
+ fr_hash_table_t *ht;
};
static const CONF_PARSER module_config[] = {
{
struct detail_instance *inst = instance;
free((char*) inst->last_made_directory);
- if (inst->ht) lrad_hash_table_free(inst->ht);
+ if (inst->ht) fr_hash_table_free(inst->ht);
free(inst);
return 0;
static uint32_t detail_hash(const void *data)
{
const DICT_ATTR *da = data;
- return lrad_hash(&(da->attr), sizeof(da->attr));
+ return fr_hash(&(da->attr), sizeof(da->attr));
}
static int detail_cmp(const void *a, const void *b)
if (cs) {
CONF_ITEM *ci;
- inst->ht = lrad_hash_table_create(detail_hash, detail_cmp,
+ inst->ht = fr_hash_table_create(detail_hash, detail_cmp,
NULL);
for (ci = cf_item_find_next(cs, NULL);
* since the suppression list will usually
* be small, it doesn't matter.
*/
- if (!lrad_hash_table_insert(inst->ht, da)) {
+ if (!fr_hash_table_insert(inst->ht, da)) {
radlog(L_ERR, "rlm_detail: Failed trying to remember %s", attr);
detail_detach(inst);
return -1;
da.attr = pair->attribute;
if (inst->ht &&
- lrad_hash_table_finddata(inst->ht, &da)) continue;
+ fr_hash_table_finddata(inst->ht, &da)) continue;
/*
* Don't print passwords in old format...
* Set A1 to Digest-HA1 if no User-Password found
*/
if (passwd->attribute == PW_DIGEST_HA1) {
- if (lrad_hex2bin(passwd->vp_strvalue, &a1[0], 16) != 16) {
+ if (fr_hex2bin(passwd->vp_strvalue, &a1[0], 16) != 16) {
DEBUG2("rlm_digest: Invalid text in Digest-HA1");
return RLM_MODULE_INVALID;
}
*/
if (passwd->attribute == PW_CLEARTEXT_PASSWORD) {
fr_md5_calc(hash, &a1[0], a1_len);
- lrad_bin2hex(hash, (char *) &a1[0], 16);
+ fr_bin2hex(hash, (char *) &a1[0], 16);
} else { /* MUST be Digest-HA1 */
memcpy(&a1[0], passwd->vp_strvalue, 32);
}
} else {
memcpy(&hash[0], &a1[0], a1_len);
}
- lrad_bin2hex(hash, (char *) kd, sizeof(hash));
+ fr_bin2hex(hash, (char *) kd, sizeof(hash));
#ifndef NDEBUG
if (debug_flag) {
fr_md5_calc(&hash[0], &a2[0], a2_len);
- lrad_bin2hex(hash, (char *) kd + kd_len, sizeof(hash));
+ fr_bin2hex(hash, (char *) kd + kd_len, sizeof(hash));
#ifndef NDEBUG
if (debug_flag) {
return RLM_MODULE_INVALID;
}
- if (lrad_hex2bin(&vp->vp_strvalue[0], &hash[0], vp->length >> 1) != (vp->length >> 1)) {
+ if (fr_hex2bin(&vp->vp_strvalue[0], &hash[0], vp->length >> 1) != (vp->length >> 1)) {
DEBUG2("rlm_digest: Invalid text in Digest-Response");
return RLM_MODULE_INVALID;
}
typedef struct _eap_handler {
struct _eap_handler *prev, *next;
uint8_t state[EAP_STATE_LEN];
- lrad_ipaddr_t src_ipaddr;
+ fr_ipaddr_t src_ipaddr;
unsigned int eap_id;
unsigned int eap_type;
static char filesecret[256];
const char *radius_dir = RADDBDIR;
const char *progname = "radeapclient";
-/* lrad_randctx randctx; */
+/* fr_randctx randctx; */
radlog_dest_t radlog_dest = RADLOG_STDERR;
newvp->vp_octets[1]=0;
newvp->length = 18; /* 16 bytes of nonce + padding */
- nonce[0]=lrad_rand();
- nonce[1]=lrad_rand();
- nonce[2]=lrad_rand();
- nonce[3]=lrad_rand();
+ nonce[0]=fr_rand();
+ nonce[1]=fr_rand();
+ nonce[2]=fr_rand();
+ nonce[3]=fr_rand();
memcpy(&newvp->vp_octets[2], nonce, 16);
pairreplace(&(rep->vps), newvp);
fclose(randinit);
}
}
- lrad_randinit(&randctx, 1);
+ fr_randinit(&randctx, 1);
#endif
req->id = id;
if (one->eap_id < two->eap_id) return -1;
if (one->eap_id > two->eap_id) return +1;
- rcode = lrad_ipaddr_cmp(&one->src_ipaddr, &two->src_ipaddr);
+ rcode = fr_ipaddr_cmp(&one->src_ipaddr, &two->src_ipaddr);
if (rcode != 0) return rcode;
return memcmp(one->state, two->state, sizeof(one->state));
* pseudo-random numbers.
*/
for (i = 0; i < sizeof(state_key); i++) {
- state_key[i] = lrad_rand();
+ state_key[i] = fr_rand();
}
key_initialized = 1;
/* Generate challenge (a random value). */
for (i = 0; i < sizeof(challenge); i++) {
- challenge[i] = lrad_rand();
+ challenge[i] = fr_rand();
}
memcpy(value, challenge, sizeof(challenge));
} else { /* MUST be NT-Password */
if (password->length == 32) {
- password->length = lrad_hex2bin(password->vp_strvalue,
+ password->length = fr_hex2bin(password->vp_strvalue,
password->vp_octets,
16);
}
* Fill the challenge with random bytes.
*/
for (i = 0; i < reply->count; i++) {
- reply->challenge[i] = lrad_rand();
+ reply->challenge[i] = fr_rand();
}
DEBUG2(" rlm_eap_leap: Issuing AP Challenge");
* Get a random challenge.
*/
for (i = 0; i < reply->value_size; i++) {
- reply->value[i] = lrad_rand();
+ reply->value[i] = fr_rand();
}
radlog(L_INFO, "rlm_eap_md5: Issuing Challenge");
*/
challenge->length = MSCHAPV2_CHALLENGE_LEN;
for (i = 0; i < MSCHAPV2_CHALLENGE_LEN; i++) {
- challenge->vp_strvalue[i] = lrad_rand();
+ challenge->vp_strvalue[i] = fr_rand();
}
radlog(L_INFO, "rlm_eap_mschapv2: Issuing Challenge");
/* autz */
char *usersfile;
- lrad_hash_table_t *users;
+ fr_hash_table_t *users;
/* preacct */
char *acctusersfile;
- lrad_hash_table_t *acctusers;
+ fr_hash_table_t *acctusers;
/* pre-proxy */
char *preproxy_usersfile;
- lrad_hash_table_t *preproxy_users;
+ fr_hash_table_t *preproxy_users;
/* authenticate */
char *auth_usersfile;
- lrad_hash_table_t *auth_users;
+ fr_hash_table_t *auth_users;
/* post-proxy */
char *postproxy_usersfile;
- lrad_hash_table_t *postproxy_users;
+ fr_hash_table_t *postproxy_users;
/* post-authenticate */
char *postauth_usersfile;
- lrad_hash_table_t *postauth_users;
+ fr_hash_table_t *postauth_users;
};
static uint32_t pairlist_hash(const void *data)
{
- return lrad_hash_string(((const PAIR_LIST *)data)->name);
+ return fr_hash_string(((const PAIR_LIST *)data)->name);
}
static int pairlist_cmp(const void *a, const void *b)
}
-static int getusersfile(const char *filename, lrad_hash_table_t **pht,
+static int getusersfile(const char *filename, fr_hash_table_t **pht,
char *compat_mode_str)
{
int rcode;
PAIR_LIST *users = NULL;
PAIR_LIST *entry, *next;
- lrad_hash_table_t *ht, *tailht;
+ fr_hash_table_t *ht, *tailht;
int order = 0;
if (!filename) {
}
- ht = lrad_hash_table_create(pairlist_hash, pairlist_cmp,
+ ht = fr_hash_table_create(pairlist_hash, pairlist_cmp,
my_pairlist_free);
if (!ht) {
pairlist_free(&users);
return -1;
}
- tailht = lrad_hash_table_create(pairlist_hash, pairlist_cmp,
+ tailht = fr_hash_table_create(pairlist_hash, pairlist_cmp,
NULL);
if (!tailht) {
- lrad_hash_table_free(ht);
+ fr_hash_table_free(ht);
pairlist_free(&users);
return -1;
}
* Insert it into the hash table, and remember
* the tail of the linked list.
*/
- tail = lrad_hash_table_finddata(tailht, entry);
+ tail = fr_hash_table_finddata(tailht, entry);
if (!tail) {
/*
* Insert it into the head & tail.
*/
- if (!lrad_hash_table_insert(ht, entry) ||
- !lrad_hash_table_insert(tailht, entry)) {
+ if (!fr_hash_table_insert(ht, entry) ||
+ !fr_hash_table_insert(tailht, entry)) {
pairlist_free(&next);
- lrad_hash_table_free(ht);
- lrad_hash_table_free(tailht);
+ fr_hash_table_free(ht);
+ fr_hash_table_free(tailht);
return -1;
}
} else {
tail->next = entry;
- if (!lrad_hash_table_replace(tailht, entry)) {
+ if (!fr_hash_table_replace(tailht, entry)) {
pairlist_free(&next);
- lrad_hash_table_free(ht);
- lrad_hash_table_free(tailht);
+ fr_hash_table_free(ht);
+ fr_hash_table_free(tailht);
return -1;
}
}
}
- lrad_hash_table_free(tailht);
+ fr_hash_table_free(tailht);
*pht = ht;
return 0;
static int file_detach(void *instance)
{
struct file_instance *inst = instance;
- lrad_hash_table_free(inst->users);
- lrad_hash_table_free(inst->acctusers);
- lrad_hash_table_free(inst->preproxy_users);
- lrad_hash_table_free(inst->auth_users);
- lrad_hash_table_free(inst->postproxy_users);
- lrad_hash_table_free(inst->postauth_users);
+ fr_hash_table_free(inst->users);
+ fr_hash_table_free(inst->acctusers);
+ fr_hash_table_free(inst->preproxy_users);
+ fr_hash_table_free(inst->auth_users);
+ fr_hash_table_free(inst->postproxy_users);
+ fr_hash_table_free(inst->postauth_users);
free(inst);
return 0;
}
* Common code called by everything below.
*/
static int file_common(struct file_instance *inst, REQUEST *request,
- const char *filename, lrad_hash_table_t *ht,
+ const char *filename, fr_hash_table_t *ht,
VALUE_PAIR *request_pairs, VALUE_PAIR **reply_pairs)
{
const char *name, *match;
if (!ht) return RLM_MODULE_NOOP;
my_pl.name = name;
- user_pl = lrad_hash_table_finddata(ht, &my_pl);
+ user_pl = fr_hash_table_finddata(ht, &my_pl);
my_pl.name = "DEFAULT";
- default_pl = lrad_hash_table_finddata(ht, &my_pl);
+ default_pl = fr_hash_table_finddata(ht, &my_pl);
/*
* Find the entry for the user.
fr_MD5Update(&md5_context, xlat_str, strlen(xlat_str));
fr_MD5Final(key_str, &md5_context);
key_str[17] = '\0';
- lrad_bin2hex(key_str,hex_str,16);
+ fr_bin2hex(key_str,hex_str,16);
hex_str[32] = '\0';
DEBUG("rlm_ippool: MD5 on 'key' directive maps to: %s",hex_str);
memcpy(key.key,key_str,16);
fr_MD5Update(&md5_context, xlat_str, strlen(xlat_str));
fr_MD5Final(key_str, &md5_context);
key_str[17] = '\0';
- lrad_bin2hex(key_str,hex_str,16);
+ fr_bin2hex(key_str,hex_str,16);
hex_str[32] = '\0';
DEBUG("rlm_ippool: MD5 on 'key' directive maps to: %s",hex_str);
memcpy(key.key,key_str,16);
fr_MD5Update(&md5_context, md5_input_str, strlen(md5_input_str));
fr_MD5Final(key_str, &md5_context);
memcpy(key.key,key_str,16);
- lrad_bin2hex(key_str,hex_str,16);
+ fr_bin2hex(key_str,hex_str,16);
hex_str[32] = '\0';
key_datum.dptr = (char *) &key;
key_datum.dsize = sizeof(ippool_key);
fr_MD5Update(&md5_context, md5_input_str, strlen(md5_input_str));
fr_MD5Final(key_str, &md5_context);
memcpy(key.key,key_str,16);
- lrad_bin2hex(key_str,hex_str,16);
+ fr_bin2hex(key_str,hex_str,16);
hex_str[32] = '\0';
printf("rlm_ippool_tool: Transforming pair nas/port (%s/%d) to md5 '%s'\n",
old_key.nas,old_key.port,hex_str);
printf("NAS:%s port:0x%x - ",old_key.nas,old_key.port);
else{
memcpy(key_str,key.key,16);
- lrad_bin2hex(key_str,hex_str,16);
+ fr_bin2hex(key_str,hex_str,16);
hex_str[32] = '\0';
printf("KEY: '%s' - ",hex_str);
}
printf("NAS:%s port:0x%x\n",old_key.nas,old_key.port);
else{
memcpy(key_str,key.key,16);
- lrad_bin2hex(key_str,hex_str,16);
+ fr_bin2hex(key_str,hex_str,16);
hex_str[32] = '\0';
printf("KEY: '%s' - ",hex_str);
}
if (sscanf(b, "%[^:]:%d", host, &port) == 2) { h = host; p = port; }
if (h) {
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
if (ip_hton(h, AF_INET, &ipaddr) < 0) {
radlog(L_ERR, "Can't find IP address for host %s", h);
continue;
struct TLDAP_RADIUS {
char* attr;
char* radius_attr;
- LRAD_TOKEN operator;
+ FR_TOKEN operator;
struct TLDAP_RADIUS* next;
};
typedef struct TLDAP_RADIUS TLDAP_RADIUS;
char buf[MAX_LINE_LEN], itemType[MAX_LINE_LEN];
char radiusAttribute[MAX_LINE_LEN], ldapAttribute[MAX_LINE_LEN];
int linenumber;
- LRAD_TOKEN operator;
+ FR_TOKEN operator;
char opstring[MAX_LINE_LEN];
/* open the mappings file for reading */
/*
* For auto-header discovery.
*/
-static const LRAD_NAME_NUMBER header_names[] = {
+static const FR_NAME_NUMBER header_names[] = {
{ "{clear}", PW_CLEARTEXT_PASSWORD },
{ "{cleartext}", PW_CLEARTEXT_PASSWORD },
{ "{md5}", PW_MD5_PASSWORD },
memcpy(autobuf, value, p - value + 1);
autobuf[p - value + 1] = '\0';
- attr = lrad_str2int(header_names,
+ attr = fr_str2int(header_names,
autobuf, 0);
if (!attr) continue;
value = p + 1;
/*
* Copied from src/lib/token.c
*/
-static const LRAD_NAME_NUMBER tokens[] = {
+static const FR_NAME_NUMBER tokens[] = {
{ "=~", T_OP_REG_EQ, }, /* order is important! */
{ "!~", T_OP_REG_NE, },
{ "{", T_LCBRACE, },
char *ptr;
char *value;
TLDAP_RADIUS *element;
- LRAD_TOKEN token, operator;
+ FR_TOKEN token, operator;
int is_generic_attribute;
char buf[MAX_STRING_LEN];
VALUE_PAIR *pairlist = NULL;
/*
* This is a generic attribute.
*/
- LRAD_TOKEN dummy; /* makes pairread happy */
+ FR_TOKEN dummy; /* makes pairread happy */
/* not sure if using pairread here is ok ... */
if ( (newpair = pairread(&value, &dummy)) != NULL) {
DEBUG("rlm_mschap: NT-Hash: %s",p);
ntpwdhash(buffer,p);
- lrad_bin2hex(buffer, out, 16);
+ fr_bin2hex(buffer, out, 16);
out[32] = '\0';
DEBUG("rlm_mschap: NT-Hash: Result: %s",out);
return 32;
DEBUG("rlm_mschap: LM-Hash: %s",p);
smbdes_lmpwdhash(p,buffer);
- lrad_bin2hex(buffer, out, 16);
+ fr_bin2hex(buffer, out, 16);
out[32] = '\0';
DEBUG("rlm_mschap: LM-Hash: Result: %s",out);
return 32;
/*
* Update the NT hash hash, from the NT key.
*/
- if (lrad_hex2bin(buffer + 8, nthashhash, 16) != 16) {
+ if (fr_hex2bin(buffer + 8, nthashhash, 16) != 16) {
DEBUG2(" rlm_mschap: Invalid output from ntlm_auth: NT_KEY has non-hex values");
return -1;
}
*/
if ((lm_password->length == 16) ||
((lm_password->length == 32) &&
- (lrad_hex2bin(lm_password->vp_strvalue,
+ (fr_hex2bin(lm_password->vp_strvalue,
lm_password->vp_strvalue, 16) == 16))) {
DEBUG2(" rlm_mschap: Found LM-Password");
lm_password->length = 16;
if (nt_password) {
if ((nt_password->length == 16) ||
((nt_password->length == 32) &&
- (lrad_hex2bin(nt_password->vp_strvalue,
+ (fr_hex2bin(nt_password->vp_strvalue,
nt_password->vp_strvalue, 16) == 16))) {
DEBUG2(" rlm_mschap: Found NT-Password");
nt_password->length = 16;
RCSID("$Id$")
/* avoid inclusion of these FR headers which conflict w/ OpenSSL */
-#define _LRAD_MD4_H
-#define _LRAD_SHA1_H
+#define _FR_MD4_H
+#define _FR_SHA1_H
#include <freeradius-devel/rad_assert.h>
RCSID("$Id$")
/* avoid inclusion of these FR headers which conflict w/ OpenSSL */
-#define _LRAD_MD4_H
-#define _LRAD_SHA1_H
+#define _FR_MD4_H
+#define _FR_SHA1_H
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/rad_assert.h>
RCSID("$Id$")
/* avoid inclusion of these FR headers which conflict w/ OpenSSL */
-#define _LRAD_MD4_H
-#define _LRAD_SHA1_H
+#define _FR_MD4_H
+#define _FR_SHA1_H
#include "extern.h"
while (bytes_read < len) {
int n;
unsigned int bytes_left = len - bytes_read;
- uint32_t r = lrad_rand();
+ uint32_t r = fr_rand();
n = sizeof(r) < bytes_left ? sizeof(r) : bytes_left;
(void) memcpy(rnd_data + bytes_read, &r, n);
{ NULL, -1, 0, NULL, NULL }
};
-static const LRAD_NAME_NUMBER schemes[] = {
+static const FR_NAME_NUMBER schemes[] = {
{ "clear", PAP_ENC_CLEAR },
{ "crypt", PAP_ENC_CRYPT },
{ "md5", PAP_ENC_MD5 },
/*
* For auto-header discovery.
*/
-static const LRAD_NAME_NUMBER header_names[] = {
+static const FR_NAME_NUMBER header_names[] = {
{ "{clear}", PW_CLEARTEXT_PASSWORD },
{ "{cleartext}", PW_CLEARTEXT_PASSWORD },
{ "{md5}", PW_MD5_PASSWORD },
return -1;
}
- inst->sch = lrad_str2int(schemes, inst->scheme, PAP_ENC_INVALID);
+ inst->sch = fr_str2int(schemes, inst->scheme, PAP_ENC_INVALID);
if (inst->sch == PAP_ENC_INVALID) {
radlog(L_ERR, "rlm_pap: Unknown scheme \"%s\"", inst->scheme);
pap_detach(inst);
* Hex encoding.
*/
if (vp->length >= (2 * min_length)) {
- decoded = lrad_hex2bin(vp->vp_octets, buffer, vp->length >> 1);
+ decoded = fr_hex2bin(vp->vp_octets, buffer, vp->length >> 1);
if (decoded == (vp->length >> 1)) {
DEBUG2("rlm_pap: Normalizing %s from hex encoding", vp->name);
memcpy(vp->vp_octets, buffer, decoded);
memcpy(buffer, q, p - q + 1);
buffer[p - q + 1] = '\0';
- attr = lrad_str2int(header_names, buffer, 0);
+ attr = fr_str2int(header_names, buffer, 0);
if (!attr) {
DEBUG2("rlm_pap: Found unknown header {%s}: Not doing anything", buffer);
break;
case PAP_ENC_CRYPT:
do_crypt:
DEBUG("rlm_pap: Using CRYPT encryption.");
- if (lrad_crypt_check((char *) request->password->vp_strvalue,
+ if (fr_crypt_check((char *) request->password->vp_strvalue,
(char *) vp->vp_strvalue) != 0) {
snprintf(module_fmsg,sizeof(module_fmsg),"rlm_pap: CRYPT password check failed");
goto make_msg;
snprintf(module_fmsg,sizeof(module_fmsg),"rlm_pap: mschap xlat failed");
goto make_msg;
}
- if ((lrad_hex2bin(digest, digest, 16) != vp->length) ||
+ if ((fr_hex2bin(digest, digest, 16) != vp->length) ||
(memcmp(digest, vp->vp_octets, vp->length) != 0)) {
snprintf(module_fmsg,sizeof(module_fmsg),"rlm_pap: NT password check failed");
goto make_msg;
snprintf(module_fmsg,sizeof(module_fmsg),"rlm_pap: mschap xlat failed");
goto make_msg;
}
- if ((lrad_hex2bin(digest, digest, 16) != vp->length) ||
+ if ((fr_hex2bin(digest, digest, 16) != vp->length) ||
(memcmp(digest, vp->vp_octets, vp->length) != 0)) {
snprintf(module_fmsg,sizeof(module_fmsg),"rlm_pap: LM password check failed");
make_msg:
/*
* Sanity check the value of NS-MTA-MD5-Password
*/
- if (lrad_hex2bin(vp->vp_octets, buff, 32) != 16) {
+ if (fr_hex2bin(vp->vp_octets, buff, 32) != 16) {
DEBUG("rlm_pap: Configured NS-MTA-MD5-Password has invalid value");
snprintf(module_fmsg,sizeof(module_fmsg),"rlm_pap: Configured NS-MTA-MD5-Password has invalid value");
goto make_msg;
if (indent) printf("%*s", indent, " ");
printf("\t%s %s ", assign->lhs,
- lrad_int2str(rlm_policy_tokens,
+ fr_int2str(rlm_policy_tokens,
assign->assign, "?"));
if (assign->rhs_type == POLICY_LEX_BARE_WORD) {
printf("%s\n", assign->rhs);
/*
* We always print this condition.
*/
- printf(" %s ", lrad_int2str(rlm_policy_tokens,
+ printf(" %s ", fr_int2str(rlm_policy_tokens,
condition->compare,
"?"));
if (condition->rhs_type == POLICY_LEX_BARE_WORD) {
if ((condition->child_condition != POLICY_LEX_BAD) &&
(condition->child_condition != POLICY_LEX_BARE_WORD)) {
- printf(" %s ", lrad_int2str(rlm_policy_tokens, condition->child_condition, "?"));
+ printf(" %s ", fr_int2str(rlm_policy_tokens, condition->child_condition, "?"));
policy_print(condition->child, indent);
}
}
if (indent) printf("%*s", indent, " ");
printf("%s %s {\n",
- lrad_int2str(policy_reserved_words,
+ fr_int2str(policy_reserved_words,
this->where, "?"),
- lrad_int2str(rlm_policy_tokens,
+ fr_int2str(rlm_policy_tokens,
this->how, "?"));
policy_print(this->attributes, indent + 1);
if (indent) printf("%*s", indent, " ");
this = (const policy_return_t *) item;
if (indent) printf("%*s", indent, " ");
printf("return %s\n",
- lrad_int2str(policy_return_codes,
+ fr_int2str(policy_return_codes,
this->rcode, "???"));
}
break;
this = (const policy_module_t *) item;
if (indent) printf("%*s", indent, " ");
printf("module %s <stuff>\n",
- lrad_int2str(policy_component_names,
+ fr_int2str(policy_component_names,
this->component, "???"));
}
break;
* evaluate all of it...
*/
rcode = policy_evaluate_name(state, this->lhs);
- data = lrad_int2str(policy_return_codes, rcode, "???");
+ data = fr_int2str(policy_return_codes, rcode, "???");
strlcpy(lhs_buffer, data, sizeof(lhs_buffer)); /* FIXME: yuck */
} else if (this->lhs_type == POLICY_LEX_DOUBLE_QUOTED_STRING) {
if (radius_xlat(lhs_buffer, sizeof(lhs_buffer), this->lhs,
const policy_assignment_t *assign)
{
VALUE_PAIR *vp;
- LRAD_TOKEN operator = T_OP_EQ;
+ FR_TOKEN operator = T_OP_EQ;
const char *value = assign->rhs;
char buffer[2048];
default:
fprintf(stderr, "Expected '=' for operator, not '%s' at line %d\n",
- lrad_int2str(rlm_policy_tokens,
+ fr_int2str(rlm_policy_tokens,
assign->assign, "?"),
assign->item.lineno);
return NULL;
state->request = request;
state->inst = inst;
state->rcode = RLM_MODULE_OK;
- state->component = lrad_str2int(policy_component_names, name,
+ state->component = fr_str2int(policy_component_names, name,
RLM_COMPONENT_COUNT);
rcode = policy_evaluate_name(state, name);
#include <freeradius-devel/modules.h>
-const LRAD_NAME_NUMBER policy_return_codes[] = {
+const FR_NAME_NUMBER policy_return_codes[] = {
{ "reject", RLM_MODULE_REJECT },
{ "fail", RLM_MODULE_FAIL },
{ "ok", RLM_MODULE_OK },
/*
* Explanations of what the lexical tokens are.
*/
-static const LRAD_NAME_NUMBER policy_explanations[] = {
+static const FR_NAME_NUMBER policy_explanations[] = {
{ "invalid input", POLICY_LEX_BAD },
{ "end of file", POLICY_LEX_EOF },
{ "end of line", POLICY_LEX_EOL },
};
-const LRAD_NAME_NUMBER rlm_policy_tokens[] = {
+const FR_NAME_NUMBER rlm_policy_tokens[] = {
{ "EOF", POLICY_LEX_EOF },
{ "#", POLICY_LEX_HASH },
{ "(", POLICY_LEX_L_BRACKET },
if (flags & POLICY_LEX_FLAG_PRINT_TOKEN) {
debug_tokens("[%s token %s] ",
(flags & POLICY_LEX_FLAG_PEEK) ? "peek " : "",
- lrad_int2str(rlm_policy_tokens,
+ fr_int2str(rlm_policy_tokens,
token, "?"));
}
return token;
/*
* Map reserved words to tokens, and vice versa.
*/
-const LRAD_NAME_NUMBER policy_reserved_words[] = {
+const FR_NAME_NUMBER policy_reserved_words[] = {
{ "if", POLICY_RESERVED_IF },
{ "else", POLICY_RESERVED_ELSE },
{ "debug", POLICY_RESERVED_DEBUG },
* Simplifies some later coding
*/
static int policy_lex_str2int(policy_lex_file_t *lexer,
- const LRAD_NAME_NUMBER *table, int default_value)
+ const FR_NAME_NUMBER *table, int default_value)
{
policy_lex_t token;
char buffer[256];
return default_value;
}
- return lrad_str2int(table, buffer, default_value);
+ return fr_str2int(table, buffer, default_value);
}
if (token != POLICY_LEX_L_BRACKET) {
fprintf(stderr, "%s[%d]: Expected '(', got \"%s\"\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, token, lhs));
+ fr_int2str(rlm_policy_tokens, token, lhs));
return 0;
}
if (token != POLICY_LEX_L_BRACKET) {
fprintf(stderr, "%s[%d]: Expected left bracket, got \"%s\"\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, token, "?"));
+ fr_int2str(rlm_policy_tokens, token, "?"));
return 0;
}
if (token != POLICY_LEX_R_BRACKET) {
fprintf(stderr, "%s[%d]: Expected right bracket, got \"%s\"\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, token, "?"));
+ fr_int2str(rlm_policy_tokens, token, "?"));
return 0;
}
} /* else it's a comparison? */
default:
fprintf(stderr, "%s[%d]: Invalid operator \"%s\"\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, compare, rhs));
+ fr_int2str(rlm_policy_tokens, compare, rhs));
rlm_policy_free_item((policy_item_t *) this);
return 0;
}
return 0;
}
debug_tokens("[COMPARE (%s %s %s)] ",
- lhs, lrad_int2str(rlm_policy_tokens, compare, "?"), rhs);
+ lhs, fr_int2str(rlm_policy_tokens, compare, "?"), rhs);
this->lhs = strdup(lhs);
this->compare = compare;
this->rhs_type = token;
if (token != POLICY_LEX_R_BRACKET) {
fprintf(stderr, "%s[%d]: Expected ')', got \"%s\"\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, token, "?"));
+ fr_int2str(rlm_policy_tokens, token, "?"));
rlm_policy_free_item((policy_item_t *) this);
return 0;
}
if ((token == POLICY_LEX_L_AND) || (token == POLICY_LEX_L_OR)) {
token = policy_lex_file(lexer, 0, NULL, 0); /* skip over it */
debug_tokens("[%s] ",
- lrad_int2str(rlm_policy_tokens, token, "?"));
+ fr_int2str(rlm_policy_tokens, token, "?"));
this->child_condition = token;
rcode = parse_condition(lexer, &(this->child));
if (!rcode) {
token = policy_lex_file(lexer, POLICY_LEX_FLAG_PEEK,
mystring, sizeof(mystring));
if ((token == POLICY_LEX_BARE_WORD) &&
- (lrad_str2int(policy_reserved_words, mystring,
+ (fr_str2int(policy_reserved_words, mystring,
POLICY_RESERVED_UNKNOWN) == POLICY_RESERVED_ELSE)) {
debug_tokens("[ELSE] ");
token = policy_lex_file(lexer, 0, mystring, sizeof(mystring));
token = policy_lex_file(lexer, POLICY_LEX_FLAG_PEEK,
mystring, sizeof(mystring));
if ((token == POLICY_LEX_BARE_WORD) &&
- (lrad_str2int(policy_reserved_words, mystring,
+ (fr_str2int(policy_reserved_words, mystring,
POLICY_RESERVED_UNKNOWN) == POLICY_RESERVED_IF)) {
token = policy_lex_file(lexer, 0,
mystring, sizeof(mystring));
if (token != POLICY_LEX_L_BRACKET) {
fprintf(stderr, "%s[%d]: Expected left bracket, got \"%s\"\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, token, "?"));
+ fr_int2str(rlm_policy_tokens, token, "?"));
return 0;
}
if (token != POLICY_LEX_R_BRACKET) {
fprintf(stderr, "%s[%d]: Expected right bracket, got \"%s\"\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, token, "?"));
+ fr_int2str(rlm_policy_tokens, token, "?"));
return 0;
}
default:
fprintf(stderr, "%s[%d]: Unexpected token %s\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, token, "?"));
+ fr_int2str(rlm_policy_tokens, token, "?"));
return 0; /* unknown */
}
}
-const LRAD_NAME_NUMBER policy_component_names[] = {
+const FR_NAME_NUMBER policy_component_names[] = {
{ "authenticate", RLM_COMPONENT_AUTH },
{ "authorize", RLM_COMPONENT_AUTZ },
{ "preacct", RLM_COMPONENT_PREACCT },
if (token != POLICY_LEX_DOUBLE_QUOTED_STRING) {
fprintf(stderr, "%s[%d]: Expected filename, got \"%s\"\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, token, "?"));
+ fr_int2str(rlm_policy_tokens, token, "?"));
return 0;
}
section_name = cf_section_name1(subcs);
rad_assert(section_name != NULL);
- component = lrad_str2int(policy_component_names, section_name,
+ component = fr_str2int(policy_component_names, section_name,
RLM_COMPONENT_COUNT);
if (component == RLM_COMPONENT_COUNT) {
fprintf(stderr, "%s[%d]: Invalid section name \"%s\"\n",
break;
case POLICY_LEX_BARE_WORD:
- reserved = lrad_str2int(policy_reserved_words,
+ reserved = fr_str2int(policy_reserved_words,
lhs,
POLICY_RESERVED_UNKNOWN);
switch (reserved) {
default:
fprintf(stderr, "%s[%d]: Unexpected %s\n",
lexer->filename, lexer->lineno,
- lrad_int2str(policy_explanations,
+ fr_int2str(policy_explanations,
token, "string"));
break;
}
default:
fprintf(stderr, "%s[%d]: Unexpected assign %s\n",
lexer->filename, lexer->lineno,
- lrad_int2str(policy_explanations,
+ fr_int2str(policy_explanations,
assign, "string"));
return 0;
}
(token != POLICY_LEX_DOUBLE_QUOTED_STRING)) {
fprintf(stderr, "%s[%d]: Unexpected rhs %s\n",
lexer->filename, lexer->lineno,
- lrad_int2str(policy_explanations,
+ fr_int2str(policy_explanations,
token, "string"));
rlm_policy_free_item((policy_item_t *) this);
return 0;
return 0;
}
debug_tokens("[ASSIGN %s %s %s]\n",
- lhs, lrad_int2str(rlm_policy_tokens, assign, "?"), rhs);
+ lhs, fr_int2str(rlm_policy_tokens, assign, "?"), rhs);
/*
* Fill in the assignment struct
if (token != POLICY_LEX_BARE_WORD) {
fprintf(stderr, "%s[%d]: Expected policy name, got \"%s\"\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, token, "?"));
+ fr_int2str(rlm_policy_tokens, token, "?"));
rlm_policy_free_item((policy_item_t *) this);
return 0;
}
if (token != POLICY_LEX_DOUBLE_QUOTED_STRING) {
fprintf(stderr, "%s[%d]: Expected filename, got \"%s\"\n",
lexer->filename, lexer->lineno,
- lrad_int2str(rlm_policy_tokens, token, "?"));
+ fr_int2str(rlm_policy_tokens, token, "?"));
return 0;
}
token = policy_lex_file(lexer, 0, buffer, sizeof(buffer));
switch (token) {
case POLICY_LEX_BARE_WORD:
- reserved = lrad_str2int(policy_reserved_words,
+ reserved = fr_str2int(policy_reserved_words,
buffer,
POLICY_RESERVED_UNKNOWN);
switch (reserved) {
/*
* Functions.
*/
-extern const LRAD_NAME_NUMBER rlm_policy_tokens[];
-extern const LRAD_NAME_NUMBER policy_reserved_words[];
-extern const LRAD_NAME_NUMBER policy_return_codes[];
-extern const LRAD_NAME_NUMBER policy_component_names[];
+extern const FR_NAME_NUMBER rlm_policy_tokens[];
+extern const FR_NAME_NUMBER policy_reserved_words[];
+extern const FR_NAME_NUMBER policy_return_codes[];
+extern const FR_NAME_NUMBER policy_component_names[];
extern int rlm_policy_insert(rbtree_t *head, policy_named_t *policy);
extern policy_named_t *rlm_policy_find(rbtree_t *head, const char *name);
vp = pairfind(request->packet->vps, PW_FREERADIUS_PROXIED_TO);
if (vp && (request->packet->src_ipaddr.af == AF_INET)) {
int i;
- lrad_ipaddr_t my_ipaddr;
+ fr_ipaddr_t my_ipaddr;
my_ipaddr.af = AF_INET;
my_ipaddr.ipaddr.ip4addr.s_addr = vp->vp_ipaddr;
* send it there again.
*/
for (i = 0; i < realm->acct_pool->num_home_servers; i++) {
- if (lrad_ipaddr_cmp(&realm->acct_pool->servers[i]->ipaddr,
+ if (fr_ipaddr_cmp(&realm->acct_pool->servers[i]->ipaddr,
&my_ipaddr) == 0) {
DEBUG2("Suppressing proxy due to FreeRADIUS-Proxied-To");
return 0;
* send it there again.
*/
for (i = 0; i < realm->acct_pool->num_home_servers; i++) {
- if ((lrad_ipaddr_cmp(&realm->acct_pool->servers[i]->ipaddr,
+ if ((fr_ipaddr_cmp(&realm->acct_pool->servers[i]->ipaddr,
&request->packet->src_ipaddr) == 0) &&
(realm->acct_pool->servers[i]->port == request->packet->src_port)) {
DEBUG2("Suppressing proxy because packet was already sent to a server in that realm");
int RFCNB_Name_To_IP(char *host, struct in_addr *Dest_IP)
{
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
if (ip_hton(host, AF_INET, &ipaddr) < 0) {
/* Try NetBIOS name lookup, how the hell do we do that? */
char *ptr, *value;
char buf[MAX_STRING_LEN];
char do_xlat = 0;
- LRAD_TOKEN token, operator = T_EOL;
+ FR_TOKEN token, operator = T_EOL;
/*
* Verify the 'Attribute' field
uint32_t ip_allocation;
VALUE_PAIR * vp;
SQLSOCK * sqlsocket;
- lrad_ipaddr_t ipaddr;
+ fr_ipaddr_t ipaddr;
char logstr[MAX_STRING_LEN];
/*
/*
* 0 means "ok"
*/
- if (lrad_crypt_check((char *) request->password->vp_strvalue,
+ if (fr_crypt_check((char *) request->password->vp_strvalue,
(char *) vp->vp_strvalue) != 0) {
radlog(L_AUTH, "rlm_unix: [%s]: invalid password",
request->username->vp_strvalue);