This reduces the number of warnings on compile.
typedef struct dict_vendor {
int vendorpec;
- int type; /* length of type data */
- int length; /* length of length data */
- int flags;
+ size_t type; /* length of type data */
+ size_t length; /* length of length data */
+ size_t flags;
char name[1];
} DICT_VENDOR;
typedef struct value_pair {
const char *name;
unsigned int attribute;
- int vendor;
+ unsigned int vendor;
int type;
size_t length; /* of data */
FR_TOKEN operator;
VALUE_PAIR *paircreate(int attr, int vendor, int type);
void pairfree(VALUE_PAIR **);
void pairbasicfree(VALUE_PAIR *pair);
-VALUE_PAIR *pairfind(VALUE_PAIR *, int attr, int vendor);
-void pairdelete(VALUE_PAIR **, int attr, int vendor);
+VALUE_PAIR *pairfind(VALUE_PAIR *, unsigned int attr, unsigned int vendor);
+void pairdelete(VALUE_PAIR **, unsigned int attr, unsigned int vendor);
void pairadd(VALUE_PAIR **, VALUE_PAIR *);
void pairreplace(VALUE_PAIR **first, VALUE_PAIR *add);
int paircmp(VALUE_PAIR *check, VALUE_PAIR *data);
VALUE_PAIR *paircopyvp(const VALUE_PAIR *vp);
VALUE_PAIR *paircopy(VALUE_PAIR *vp);
-VALUE_PAIR *paircopy2(VALUE_PAIR *vp, int attr, int vendor);
+VALUE_PAIR *paircopy2(VALUE_PAIR *vp, unsigned int attr, unsigned int vendor);
void pairmove(VALUE_PAIR **to, VALUE_PAIR **from);
-void pairmove2(VALUE_PAIR **to, VALUE_PAIR **from, int attr, int vendor);
+void pairmove2(VALUE_PAIR **to, VALUE_PAIR **from, unsigned int attr, unsigned int vendor);
VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value);
VALUE_PAIR *pairmake(const char *attribute, const char *value, int operator);
VALUE_PAIR *pairread(const char **ptr, FR_TOKEN *eol);
extern const char *radacct_dir;
extern const char *radlog_dir;
extern const char *radlib_dir;
-extern const char *radius_dir;
+extern char *radius_dir;
extern const char *radius_libdir;
extern uint32_t expiration_seconds;
extern int log_stripped_names;
int timestr_match(char *, time_t);
/* valuepair.c */
-int paircompare_register(int attr, int otherattr,
+int paircompare_register(unsigned int attr, int otherattr,
RAD_COMPARE_FUNC func,
void *instance);
-void paircompare_unregister(int attr, RAD_COMPARE_FUNC func);
+void paircompare_unregister(unsigned int attr, RAD_COMPARE_FUNC func);
int paircompare(REQUEST *req, VALUE_PAIR *request, VALUE_PAIR *check,
VALUE_PAIR **reply);
void pairxlatmove(REQUEST *, VALUE_PAIR **to, VALUE_PAIR **from);
int radius_callback_compare(REQUEST *req, VALUE_PAIR *request,
VALUE_PAIR *check, VALUE_PAIR *check_pairs,
VALUE_PAIR **reply_pairs);
-int radius_find_compare(int attribute);
+int radius_find_compare(unsigned int attribute);
VALUE_PAIR *radius_paircreate(REQUEST *request, VALUE_PAIR **vps,
- int attribute, int vendor, int type);
+ unsigned int attribute, unsigned int vendor, int type);
VALUE_PAIR *radius_pairmake(REQUEST *request, VALUE_PAIR **vps,
const char *attribute, const char *value,
int operator);
void listen_free(rad_listen_t **head);
int listen_init(CONF_SECTION *cs, rad_listen_t **head);
int proxy_new_listener(home_server *home, int src_port);
-RADCLIENT *client_listener_find(const rad_listen_t *listener,
+RADCLIENT *client_listener_find(rad_listen_t *listener,
const fr_ipaddr_t *ipaddr, int src_port);
#ifdef WITH_STATS
RADCLIENT *client);
REQUEST *received_proxy_response(RADIUS_PACKET *packet);
int event_new_fd(rad_listen_t *listener);
+void revive_home_server(void *ctx);
+void mark_home_server_dead(home_server *home, struct timeval *when);
/* evaluate.c */
int radius_evaluate_condition(REQUEST *request, int modreturn, int depth,
int radius_update_attrlist(REQUEST *request, CONF_SECTION *cs,
VALUE_PAIR *input_vps, const char *name);
void radius_pairmove(REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from);
+int radius_get_vp(REQUEST *request, const char *name, VALUE_PAIR **vp_p);
#endif /*RADIUSD_H*/
/*
* Find the pair with the matching attribute
*/
-VALUE_PAIR * pairfind(VALUE_PAIR *first, int attr, int vendor)
+VALUE_PAIR * pairfind(VALUE_PAIR *first, unsigned int attr, unsigned int vendor)
{
while (first) {
if ((first->attribute == attr) && (first->vendor == vendor)) {
/*
* Delete the pair(s) with the matching attribute
*/
-void pairdelete(VALUE_PAIR **first, int attr, int vendor)
+void pairdelete(VALUE_PAIR **first, unsigned int attr, unsigned int vendor)
{
VALUE_PAIR *i, *next;
VALUE_PAIR **last = first;
/*
* Copy just a certain type of pairs.
*/
-VALUE_PAIR *paircopy2(VALUE_PAIR *vp, int attr, int vendor)
+VALUE_PAIR *paircopy2(VALUE_PAIR *vp, unsigned int attr, unsigned int vendor)
{
VALUE_PAIR *first, *n, **last;
last = &first;
while (vp) {
- if ((attr >= 0) &&
+ if ((attr > 0) &&
!((vp->attribute == attr) && (vp->vendor == vendor))) {
vp = vp->next;
continue;
*/
VALUE_PAIR *paircopy(VALUE_PAIR *vp)
{
- return paircopy2(vp, -1, 0);
+ return paircopy2(vp, 0, 0);
}
/*
* Move one kind of attributes from one list to the other
*/
-void pairmove2(VALUE_PAIR **to, VALUE_PAIR **from, int attr, int vendor)
+void pairmove2(VALUE_PAIR **to, VALUE_PAIR **from, unsigned int attr, unsigned int vendor)
{
VALUE_PAIR *to_tail, *i, *next;
VALUE_PAIR *iprev = NULL;
return 1;
}
-extern void revive_home_server(void *ctx);
-extern void mark_home_server_dead(home_server *home, struct timeval *when);
-
static int command_set_home_server_state(rad_listen_t *listener, int argc, char *argv[])
{
int last;
/*
* Find a per-socket client.
*/
-RADCLIENT *client_listener_find(const rad_listen_t *listener,
+RADCLIENT *client_listener_find(rad_listen_t *listener,
const fr_ipaddr_t *ipaddr, int src_port)
{
#ifdef WITH_DYNAMIC_CLIENTS
/*
* For configuration file stuff.
*/
-const char *radius_dir = RADDBDIR;
+char *radius_dir = RADDBDIR;
const char *progname = "radconf2xml";
/*
* Global variables.
*/
const char *progname = NULL;
-const char *radius_dir = NULL;
+char *radius_dir = NULL;
const char *radacct_dir = NULL;
const char *radlog_dir = NULL;
const char *radlib_dir = NULL;
/*
* For configuration file stuff.
*/
-const char *radius_dir = RADDBDIR;
+char *radius_dir = RADDBDIR;
const char *progname = "radmin";
/*
const char *radlog_dir = NULL;
const char *radutmp_file = NULL;
-const char *radius_dir = NULL;
+char *radius_dir = NULL;
const char *radacct_dir = NULL;
const char *radlib_dir = NULL;
uint32_t myip = INADDR_ANY;
}
+static size_t xlat_cs(CONF_SECTION *cs, char *fmt, char *out, size_t outlen)
+
+{
+ const char *value = NULL;
+
+ /*
+ * Instance name
+ */
+ if (strcmp(fmt, "instance") == 0) {
+ value = cf_section_name2(cs);
+ if (!value) {
+ *out = '\0';
+ return 0;
+ }
+ } else {
+ CONF_PAIR *cp;
+
+ cp = cf_pair_find(cs, fmt);
+ if (!cp || !(value = cf_pair_value(cp))) {
+ *out = '\0';
+ return 0;
+ }
+ }
+
+ strlcpy(out, value, outlen);
+
+ return strlen(out);
+}
+
+
/*
* Xlat for %{home_server:foo}
*/
char *fmt, char *out, size_t outlen,
UNUSED RADIUS_ESCAPE_STRING func)
{
- const char *value = NULL;
- CONF_PAIR *cp;
-
if (!fmt || !out || (outlen < 1)) return 0;
if (!request || !request->home_server) {
return 0;
}
- cp = cf_pair_find(request->home_server->cs, fmt);
- if (!cp || !(value = cf_pair_value(cp))) {
- *out = '\0';
- return 0;
- }
-
- strlcpy(out, value, outlen);
-
- return strlen(out);
+ return xlat_cs(request->home_server->cs, fmt, out, outlen);
}
char *fmt, char *out, size_t outlen,
UNUSED RADIUS_ESCAPE_STRING func)
{
- const char *value = NULL;
- CONF_PAIR *cp;
-
if (!fmt || !out || (outlen < 1)) return 0;
if (!request || !request->home_pool) {
return 0;
}
- cp = cf_pair_find(request->home_pool->cs, fmt);
- if (!cp || !(value = cf_pair_value(cp))) {
- *out = '\0';
- return 0;
- }
-
- strlcpy(out, value, outlen);
-
- return strlen(out);
+ return xlat_cs(request->home_pool->cs, fmt, out, outlen);
}
#endif
#endif
struct cmp {
- int attribute;
- int otherattr;
+ unsigned int attribute;
+ unsigned int otherattr;
void *instance; /* module instance */
RAD_COMPARE_FUNC compare;
struct cmp *next;
/*
* Find a comparison function for two attributes.
*/
-int radius_find_compare(int attribute)
+int radius_find_compare(unsigned int attribute)
{
struct cmp *c;
/*
* See what attribute we want to compare with.
*/
-static int otherattr(int attr)
+static int otherattr(unsigned int attr)
{
struct cmp *c;
* For example, PW_GROUP in a check item needs to be compared
* with PW_USER_NAME in the incoming request.
*/
-int paircompare_register(int attr, int compare_attr, RAD_COMPARE_FUNC fun, void *instance)
+int paircompare_register(unsigned int attr, int compare_attr, RAD_COMPARE_FUNC fun, void *instance)
{
struct cmp *c;
/*
* Unregister a function.
*/
-void paircompare_unregister(int attr, RAD_COMPARE_FUNC fun)
+void paircompare_unregister(unsigned int attr, RAD_COMPARE_FUNC fun)
{
struct cmp *c, *last;
try_again:
if (other >= 0) {
for (; auth_item != NULL; auth_item = auth_item->next) {
- if (auth_item->attribute == other || other == 0)
+ if (auth_item->attribute == (unsigned int) other || other == 0)
break;
}
}
* it causes the server to exit!
*/
VALUE_PAIR *radius_paircreate(REQUEST *request, VALUE_PAIR **vps,
- int attribute, int vendor, int type)
+ unsigned int attribute, unsigned int vendor, int type)
{
VALUE_PAIR *vp;
#if REQUEST_MAX_REGEX > 8
#error Please fix the following line
#endif
-static const int xlat_inst[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; /* up to 8 for regex */
+static int xlat_inst[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; /* up to 8 for regex */
/*
expand2 = TRUE;
} else if ((p[0] == '"') || p[0] == '\'') {
- getstring(&p, l, strlen(l));
+ getstring((const char **) &p, l, strlen(l));
} else {
l = p;
static int totalapp = 0;
static int totaldeny = 0;
static char filesecret[256];
-const char *radius_dir = RADDBDIR;
+char *radius_dir = NULL;
const char *progname = "radeapclient";
/* fr_randctx randctx; */
printf("%s %s packet %s host %s port %d, id=%d, length=%d\n",
received, fr_packet_codes[packet->code], from,
inet_ntop(ip->af, &ip->ipaddr, buffer, sizeof(buffer)),
- port, packet->id, packet->data_len);
+ port, packet->id, (int) packet->data_len);
} else {
printf("%s packet %s host %s port %d code=%d, id=%d, length=%d\n",
received, from,
inet_ntop(ip->af, &ip->ipaddr, buffer, sizeof(buffer)),
port,
- packet->code, packet->id, packet->data_len);
+ packet->code, packet->id, (int) packet->data_len);
}
for (vp = packet->vps; vp != NULL; vp = vp->next) {
count = atoi(optarg);
break;
case 'd':
- radius_dir = optarg;
+ radius_dir = strdup(optarg);
break;
case 'f':
filename = optarg;
usage();
}
+ if (!radius_dir) radius_dir = strdup(RADDBDIR);
+
if (dict_init(radius_dir, RADIUS_DICTIONARY) < 0) {
fr_perror("radclient");
return 1;
sendrecv_eap(req);
}
+ free(radius_dir);
if(do_summary) {
printf("\n\t Total approved auths: %d\n", totalapp);
printf("\t Total denied auths: %d\n", totaldeny);
return "?";
}
-static void print_tunneled_data(uint8_t *data, size_t data_len)
+static void print_tunneled_data(const uint8_t *data, size_t data_len)
{
size_t i;
if ((debug_flag > 2) && fr_log_fp) {
for (i = 0; i < data_len; i++) {
- if ((i & 0x0f) == 0) fprintf(fr_log_fp, " PEAP tunnel data in %04x: ", i);
+ if ((i & 0x0f) == 0) fprintf(fr_log_fp, " PEAP tunnel data in %02x: ", (int) i);
fprintf(fr_log_fp, "%02x ", data[i]);
* information.
*/
if (eaptls_handle_idx < 0) {
- eaptls_handle_idx = SSL_get_ex_new_index(0, "eaptls_handle_idx",
- NULL, NULL, NULL);
+ eaptls_handle_idx = SSL_get_ex_new_index(0, &eaptls_handle_idx,
+ NULL, NULL, NULL);
}
if (eaptls_conf_idx < 0) {
- eaptls_conf_idx = SSL_get_ex_new_index(0, "eaptls_conf_idx",
+ eaptls_conf_idx = SSL_get_ex_new_index(0, &eaptls_conf_idx,
NULL, NULL, NULL);
}
if (eaptls_session_idx < 0) {
- eaptls_session_idx = SSL_get_ex_new_index(0, "eaptls_session_idx",
+ eaptls_session_idx = SSL_get_ex_new_index(0, &eaptls_session_idx,
NULL, NULL,
eaptls_session_free);
}
}
static int
-sock_write(JRADIUS * inst, JRSOCK *jrsock, char *b, size_t blen) {
+sock_write(JRADIUS * inst, JRSOCK *jrsock, uint8_t *b, size_t blen) {
int fd = jrsock->con.sock;
int timeout = inst->write_timeout;
struct timeval tv;
for (vp = vps; vp != NULL; vp = vp->next) {
- radlog(L_DBG, LOG_PREFIX "packing attribute %s (type: %d; len: %d)", vp->name, vp->attribute, vp->length);
+ radlog(L_DBG, LOG_PREFIX "packing attribute %s (type: %d; len: %u)", vp->name, vp->attribute, (unsigned int) vp->length);
i = vp->attribute; /* element is int, not uint32_t */
if (pack_uint32(ba, i) == -1) return -1;