Skip to content

Commit

Permalink
Move common table into the library
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Nov 20, 2015
1 parent 186d9d9 commit 32b1b67
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/include/libradius.h
Expand Up @@ -223,9 +223,10 @@ do { \
#define AUTH_PASS_LEN (AUTH_VECTOR_LEN)
#define MAX_PASS_LEN (128)
#define FR_TUNNEL_PW_ENC_LENGTH(_x) (2 + 1 + _x + PAD(_x + 1, 16))
extern FR_NAME_NUMBER const fr_request_types[];

void fr_radius_make_secret(uint8_t *digest, uint8_t const *vector, char const *secret, uint8_t const *value);

void rad_print_hex(RADIUS_PACKET *packet);
int rad_send(RADIUS_PACKET *, RADIUS_PACKET const *, char const *secret);
bool rad_packet_ok(RADIUS_PACKET *packet, int flags, decode_fail_t *reason);
RADIUS_PACKET *rad_recv(TALLOC_CTX *ctx, int fd, int flags);
Expand Down Expand Up @@ -351,7 +352,6 @@ extern uint32_t fr_max_attributes; /* per incoming packet */
extern char const *fr_packet_codes[FR_MAX_PACKET_CODE];
#define is_radius_code(_x) ((_x > 0) && (_x < FR_MAX_PACKET_CODE))
extern FILE *fr_log_fp;
void rad_print_hex(RADIUS_PACKET *packet);
void fr_printf_log(char const *, ...) CC_HINT(format (printf, 1, 2));

/*
Expand Down
11 changes: 11 additions & 0 deletions src/lib/radius.c
Expand Up @@ -48,6 +48,17 @@ typedef struct radius_packet_t {
* Some messages get printed out only in debugging mode.
*/
#define FR_DEBUG_STRERROR_PRINTF if (fr_debug_lvl) fr_strerror_printf
FR_NAME_NUMBER const fr_request_types[] = {
{ "auth", PW_CODE_ACCESS_REQUEST },
{ "challenge", PW_CODE_ACCESS_CHALLENGE },
{ "acct", PW_CODE_ACCOUNTING_REQUEST },
{ "status", PW_CODE_STATUS_SERVER },
{ "disconnect", PW_CODE_DISCONNECT_REQUEST },
{ "coa", PW_CODE_COA_REQUEST },
{ "auto", PW_CODE_UNDEFINED },

{ NULL, 0}
};

/*
* The RFC says 4096 octets max, and most packets are less than 256.
Expand Down
14 changes: 1 addition & 13 deletions src/main/radclient.c
Expand Up @@ -110,18 +110,6 @@ static void NEVER_RETURNS usage(void)
exit(1);
}

static const FR_NAME_NUMBER request_types[] = {
{ "auth", PW_CODE_ACCESS_REQUEST },
{ "challenge", PW_CODE_ACCESS_CHALLENGE },
{ "acct", PW_CODE_ACCOUNTING_REQUEST },
{ "status", PW_CODE_STATUS_SERVER },
{ "disconnect", PW_CODE_DISCONNECT_REQUEST },
{ "coa", PW_CODE_COA_REQUEST },
{ "auto", PW_CODE_UNDEFINED },

{ NULL, 0}
};

/*
* Free a radclient struct, which may (or may not)
* already be in the list.
Expand Down Expand Up @@ -1376,7 +1364,7 @@ int main(int argc, char **argv)
* Get the request type
*/
if (!isdigit((int) argv[2][0])) {
packet_code = fr_str2int(request_types, argv[2], -2);
packet_code = fr_str2int(fr_request_types, argv[2], -2);
if (packet_code == -2) {
ERROR("Unrecognised request type \"%s\"", argv[2]);
usage();
Expand Down
15 changes: 1 addition & 14 deletions src/modules/rlm_eap/radeapclient.c
Expand Up @@ -271,19 +271,6 @@ static void NEVER_RETURNS usage(void)
exit(1);
}

static const FR_NAME_NUMBER rc_request_types[] = {
{ "auth", PW_CODE_ACCESS_REQUEST },
{ "challenge", PW_CODE_ACCESS_CHALLENGE },
{ "acct", PW_CODE_ACCOUNTING_REQUEST },
{ "status", PW_CODE_STATUS_SERVER },
{ "disconnect", PW_CODE_DISCONNECT_REQUEST },
{ "coa", PW_CODE_COA_REQUEST },
{ "auto", PW_CODE_UNDEFINED },

{ NULL, 0}
};


/* This is not called, but is required by libfreeradius-eap.so */
int rad_virtual_server(REQUEST UNUSED *request)
{
Expand Down Expand Up @@ -2359,7 +2346,7 @@ int main(int argc, char **argv)
* Get the request type
*/
if (!isdigit((int) argv[2][0])) {
packet_code = fr_str2int(rc_request_types, argv[2], -2);
packet_code = fr_str2int(fr_request_types, argv[2], -2);
if (packet_code == -2) {
ERROR("Unrecognised request type \"%s\"", argv[2]);
usage();
Expand Down

0 comments on commit 32b1b67

Please sign in to comment.