*
*/
rs_stats_tmpl_t *rs_stats_collectd_init_latency(TALLOC_CTX *ctx, rs_stats_tmpl_t **out, rs_t *conf,
- char const *type, rs_latency_t *stats, fr_radius_packet_code_t code)
+ char const *type, rs_latency_t *stats, fr_packet_code_t code)
{
rs_stats_tmpl_t **tmpl = out, *last;
char *p;
};
#define INIT_STATS(_ti, _v) do {\
- strlcpy(buffer, fr_radius_packet_names[code], sizeof(buffer)); \
+ strlcpy(buffer, fr_packet_names[code], sizeof(buffer)); \
for (p = buffer; *p; ++p) *p = tolower((uint8_t) *p);\
last = *tmpl = rs_stats_collectd_init(ctx, conf, type, _ti, buffer, stats, _v);\
if (!*tmpl) {\
fp = stdin;
}
- packet = fr_radius_packet_alloc(NULL, false);
+ packet = fr_packet_alloc(NULL, false);
/*
* Read the VP's.
*/
if (fr_pair_list_afrom_file(packet, dict_dhcpv4, packet_vps, fp, &filedone) < 0) {
fr_perror("dhcpclient");
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
if (fp != stdin) fclose(fp);
return -1;
}
/*
* Set a port from the request type if we don't already have one
*/
-static void radclient_get_port(fr_radius_packet_code_t type, uint16_t *port)
+static void radclient_get_port(fr_packet_code_t type, uint16_t *port)
{
switch (type) {
default:
/*
* Resolve a port to a request type
*/
-static fr_radius_packet_code_t radclient_get_code(uint16_t port)
+static fr_packet_code_t radclient_get_code(uint16_t port)
{
/*
* getport returns 0 if the service doesn't exist
goto error;
}
- request->packet = fr_radius_packet_alloc(request, true);
+ request->packet = fr_packet_alloc(request, true);
if (!request->packet) {
ERROR("Out of memory");
goto error;
* authentication vector.
*/
if (request->packet->data) TALLOC_FREE(request->packet->data);
- if (request->reply) fr_radius_packet_free(&request->reply);
+ if (request->reply) fr_packet_free(&request->reply);
}
/*
/*
* Encode the packet.
*/
- if (fr_radius_packet_encode(request->packet, &request->request_pairs, NULL, secret) < 0) {
+ if (fr_packet_encode(request->packet, &request->request_pairs, NULL, secret) < 0) {
REDEBUG("Failed encoding packet for ID %d", request->packet->id);
deallocate_id(request);
request->done = true;
* Re-sign it, including updating the
* Message-Authenticator.
*/
- if (fr_radius_packet_sign(request->packet, NULL, secret) < 0) {
+ if (fr_packet_sign(request->packet, NULL, secret) < 0) {
REDEBUG("Failed signing packet for ID %d", request->packet->id);
deallocate_id(request);
request->done = true;
if (!packet) {
ERROR("Received reply to request we did not send. (id=%d socket %d)",
reply->id, reply->socket.fd);
- fr_radius_packet_free(&reply);
+ fr_packet_free(&reply);
return -1; /* got reply to packet we didn't send */
}
request = packet->uctx;
* Fails the signature validation: not a real reply.
* FIXME: Silently drop it and listen for another packet.
*/
- if (fr_radius_packet_verify(reply, request->packet, secret) < 0) {
+ if (fr_packet_verify(reply, request->packet, secret) < 0) {
REDEBUG("Reply verification failed");
stats.lost++;
goto packet_done; /* shared secret is incorrect */
* packet matched that.
*/
if ((request->filter_code != FR_RADIUS_CODE_UNDEFINED) && (request->reply->code != request->filter_code)) {
- if (FR_RADIUS_PACKET_CODE_VALID(request->reply->code)) {
- REDEBUG("%s: Expected %s got %s", request->name, fr_radius_packet_names[request->filter_code],
- fr_radius_packet_names[request->reply->code]);
+ if (fr_packet_CODE_VALID(request->reply->code)) {
+ REDEBUG("%s: Expected %s got %s", request->name, fr_packet_names[request->filter_code],
+ fr_packet_names[request->reply->code]);
} else {
REDEBUG("%s: Expected %u got %i", request->name, request->filter_code,
request->reply->code);
}
packet_done:
- fr_radius_packet_free(&request->reply);
- fr_radius_packet_free(&reply); /* may be NULL */
+ fr_packet_free(&request->reply);
+ fr_packet_free(&reply); /* may be NULL */
return 0;
}
/*
* Set a port from the request type if we don't already have one
*/
-static void radclient_get_port(fr_radius_packet_code_t type, uint16_t *port)
+static void radclient_get_port(fr_packet_code_t type, uint16_t *port)
{
switch (type) {
default:
/*
* Resolve a port to a request type
*/
-static fr_radius_packet_code_t radclient_get_code(uint16_t port)
+static fr_packet_code_t radclient_get_code(uint16_t port)
{
/*
* getport returns 0 if the service doesn't exist
return -1;
}
- request->reply = fr_radius_packet_alloc(request, false);
+ request->reply = fr_packet_alloc(request, false);
if (!request->reply) {
ERROR("Out of memory");
goto error;
}
- request->packet = fr_radius_packet_alloc(request, true);
+ request->packet = fr_packet_alloc(request, true);
if (!request->packet) {
ERROR("Out of memory");
goto error;
* authentication vector.
*/
if (request->packet->data) TALLOC_FREE(request->packet->data);
- if (request->reply) fr_radius_packet_free(&request->reply);
+ if (request->reply) fr_packet_free(&request->reply);
}
/*
/*
* Send the packet.
*/
- if (fr_radius_packet_send(request->packet, &request->request_pairs, NULL, secret) < 0) {
+ if (fr_packet_send(request->packet, &request->request_pairs, NULL, secret) < 0) {
REDEBUG("Failed to send packet for ID %d", request->packet->id);
deallocate_id(request);
request->done = true;
/*
* Read a packet from a network.
*/
- packet = fr_radius_packet_recv(NULL, coafd, 0, 200, false);
+ packet = fr_packet_recv(NULL, coafd, 0, 200, false);
if (!packet) {
DEBUG("Failed reading CoA packet");
return 0;
/*
* Fails the signature validation: not a real reply.
*/
- if (fr_radius_packet_verify(packet, NULL, secret) < 0) {
+ if (fr_packet_verify(packet, NULL, secret) < 0) {
DEBUG("CoA verification failed");
return 0;
}
* packet matched that.
*/
if (request->reply->code != request->filter_code) {
- if (FR_RADIUS_PACKET_CODE_VALID(request->reply->code)) {
- REDEBUG("%s: Expected %s got %s", request->name, fr_radius_packet_names[request->filter_code],
- fr_radius_packet_names[request->reply->code]);
+ if (fr_packet_CODE_VALID(request->reply->code)) {
+ REDEBUG("%s: Expected %s got %s", request->name, fr_packet_names[request->filter_code],
+ fr_packet_names[request->reply->code]);
} else {
REDEBUG("%s: Expected %u got %i", request->name, request->filter_code,
request->reply->code);
/*
* Send reply.
*/
- if (fr_radius_packet_send(request->reply, &request->reply_pairs, packet, secret) < 0) {
+ if (fr_packet_send(request->reply, &request->reply_pairs, packet, secret) < 0) {
REDEBUG("Failed sending CoA reply");
return 0;
}
if (!packet) {
ERROR("Received reply to request we did not send. (id=%d socket %d)",
reply->id, reply->socket.fd);
- fr_radius_packet_free(&reply);
+ fr_packet_free(&reply);
return -1; /* got reply to packet we didn't send */
}
request = packet->uctx;
* Fails the signature validation: not a real reply.
* FIXME: Silently drop it and listen for another packet.
*/
- if (fr_radius_packet_verify(reply, request->packet, secret) < 0) {
+ if (fr_packet_verify(reply, request->packet, secret) < 0) {
REDEBUG("Reply verification failed");
stats.lost++;
goto packet_done; /* shared secret is incorrect */
* packet matched that.
*/
if ((request->filter_code != FR_RADIUS_CODE_UNDEFINED) && (request->reply->code != request->filter_code)) {
- if (FR_RADIUS_PACKET_CODE_VALID(request->reply->code)) {
- REDEBUG("%s: Expected %s got %s", request->name, fr_radius_packet_names[request->filter_code],
- fr_radius_packet_names[request->reply->code]);
+ if (fr_packet_CODE_VALID(request->reply->code)) {
+ REDEBUG("%s: Expected %s got %s", request->name, fr_packet_names[request->filter_code],
+ fr_packet_names[request->reply->code]);
} else {
REDEBUG("%s: Expected %u got %i", request->name, request->filter_code,
request->reply->code);
}
packet_done:
- fr_radius_packet_free(&request->reply);
- fr_radius_packet_free(&reply); /* may be NULL */
+ fr_packet_free(&request->reply);
+ fr_packet_free(&reply); /* may be NULL */
return 0;
}
fr_pair_list_t reply_pairs;
fr_pair_list_t filter; //!< If the reply passes the filter, then the request passes.
- fr_radius_packet_code_t filter_code; //!< Expected code of the response packet.
+ fr_packet_code_t filter_code; //!< Expected code of the response packet.
int resend;
int tries;
}
/* Status, Type, Interface, Src, Src port, Dst, Dst port, ID */
- if (FR_RADIUS_PACKET_CODE_VALID(packet->code)) {
+ if (fr_packet_CODE_VALID(packet->code)) {
if (fr_sbuff_in_sprintf(&sbuff, "%s,%s,%s,%i,%s,%i,%i,",
- fr_radius_packet_names[packet->code], handle->name,
+ fr_packet_names[packet->code], handle->name,
src, packet->socket.inet.src_port, dst, packet->socket.inet.dst_port, packet->id) < 0) return;
} else {
if (fr_sbuff_in_sprintf(&sbuff, "%u,%s,%s,%i,%s,%i,%i,", packet->code, handle->name,
if (s <= 0) return;
}
- if (FR_RADIUS_PACKET_CODE_VALID(packet->code)) {
+ if (fr_packet_CODE_VALID(packet->code)) {
len = snprintf(p, s, "%s Id %i %s:%s:%d %s %s:%i ",
- fr_radius_packet_names[packet->code],
+ fr_packet_names[packet->code],
packet->id,
handle->name,
response ? dst : src,
* Print out verbose HEX output
*/
if (conf->print_packet && (fr_debug_lvl >= L_DBG_LVL_4)) {
- fr_radius_packet_log_hex(&default_log, packet);
+ fr_packet_log_hex(&default_log, packet);
}
if (conf->print_packet && (fr_debug_lvl >= L_DBG_LVL_2)) {
}
}
-static void rs_stats_print_code_fancy(rs_latency_t *stats, fr_radius_packet_code_t code)
+static void rs_stats_print_code_fancy(rs_latency_t *stats, fr_packet_code_t code)
{
int i;
bool have_rt = false;
if (!stats->interval.received && !have_rt && !stats->interval.reused) return;
if (stats->interval.received || stats->interval.linked) {
- INFO("%s counters:", fr_radius_packet_names[code]);
+ INFO("%s counters:", fr_packet_names[code]);
if (stats->interval.received > 0) {
INFO("\tTotal : %.3lf/s" , stats->interval.received);
}
if (stats->interval.linked > 0) {
INFO("\tLinked : %.3lf/s", stats->interval.linked);
INFO("\tUnlinked : %.3lf/s", stats->interval.unlinked);
- INFO("%s latency:", fr_radius_packet_names[code]);
+ INFO("%s latency:", fr_packet_names[code]);
INFO("\tHigh : %.3lfms", stats->interval.latency_high);
INFO("\tLow : %.3lfms", stats->interval.latency_low);
INFO("\tAverage : %.3lfms", stats->interval.latency_average);
}
if (have_rt || stats->interval.lost || stats->interval.reused) {
- INFO("%s retransmits & loss:", fr_radius_packet_names[code]);
+ INFO("%s retransmits & loss:", fr_packet_names[code]);
if (stats->interval.lost) INFO("\tLost : %.3lf/s", stats->interval.lost);
if (stats->interval.reused) INFO("\tID Reused : %.3lf/s", stats->interval.reused);
}
for (i = 0; i < rs_codes_len; i++) {
- char const *name = fr_radius_packet_names[rs_useful_codes[i]];
+ char const *name = fr_packet_names[rs_useful_codes[i]];
fprintf(stdout,
",\"%s received/s\""
}
}
- fr_radius_packet_free(&request->packet);
- fr_radius_packet_free(&request->expect);
- fr_radius_packet_free(&request->linked);
+ fr_packet_free(&request->packet);
+ fr_packet_free(&request->expect);
+ fr_packet_free(&request->linked);
return 0;
}
* recover once some requests timeout, so make an effort to deal
* with allocation failures gracefully.
*/
- packet = fr_radius_packet_alloc(conf, false);
+ packet = fr_packet_alloc(conf, false);
if (!packet) {
REDEBUG("Failed allocating memory to hold decoded packet");
rs_tv_add_ms(&header->ts, conf->stats.timeout, &stats->quiet);
packet->socket.inet.src_port = ntohs(udp->src);
packet->socket.inet.dst_port = ntohs(udp->dst);
- if (!fr_radius_packet_ok(packet, RADIUS_MAX_ATTRIBUTES, false, &reason)) {
+ if (!fr_packet_ok(packet, RADIUS_MAX_ATTRIBUTES, false, &reason)) {
fr_perror("radsniff");
if (conf->event_flags & RS_ERROR) {
rs_packet_print(NULL, count, RS_ERROR, event->in,
packet, &decoded, &elapsed, NULL, false, false);
}
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return;
}
if (conf->filter_response_code && (conf->filter_response_code != packet->code)) {
drop_response:
RDEBUG2("Response dropped by filter");
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
/* We now need to cleanup the original request too */
if (original) {
FILE *log_fp = fr_log_fp;
fr_log_fp = NULL;
- ret = fr_radius_packet_verify(packet, original->expect, conf->radius_secret);
+ ret = fr_packet_verify(packet, original->expect, conf->radius_secret);
fr_log_fp = log_fp;
if (ret != 0) {
fr_perror("Failed verifying packet ID %d", packet->id);
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return;
}
}
/*
* Only decode attributes if we want to print them or filter on them
- * fr_radius_packet_ok( does checks to verify the packet is actually valid.
+ * fr_packet_ok( does checks to verify the packet is actually valid.
*/
if (conf->decode_attrs) {
int ret;
#ifndef NDEBUG
- if (fr_debug_lvl >= L_DBG_LVL_4) fr_radius_packet_log_hex(&default_log, packet);
+ if (fr_debug_lvl >= L_DBG_LVL_4) fr_packet_log_hex(&default_log, packet);
#endif
ret = fr_radius_decode_simple(packet, &decoded,
original->expect->data + 4 : zeros,
conf->radius_secret);
if (ret < 0) {
- fr_radius_packet_free(&packet); /* Also frees vps */
+ fr_packet_free(&packet); /* Also frees vps */
REDEBUG("Failed decoding");
return;
}
* Explicitly free VPs first so list maintains integrity - it is reused below
*/
fr_pair_list_free(&original->link_vps);
- fr_radius_packet_free(&original->linked);
+ fr_packet_free(&original->linked);
fr_event_timer_delete(&original->event);
/*
* ...nope it's the first response to a request.
* complexity, reduces max capture rate, and is generally a PITA.
*/
if (conf->filter_request) {
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
RDEBUG2("Original request dropped by filter");
return;
}
drop_request:
RDEBUG2("Request dropped by filter");
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return;
}
FILE *log_fp = fr_log_fp;
fr_log_fp = NULL;
- ret = fr_radius_packet_verify(packet, NULL, conf->radius_secret);
+ ret = fr_packet_verify(packet, NULL, conf->radius_secret);
fr_log_fp = log_fp;
if (ret != 0) {
fr_perror("Failed verifying packet ID %d", packet->id);
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return;
}
}
/*
* Only decode attributes if we want to print them or filter on them
- * fr_radius_packet_ok( does checks to verify the packet is actually valid.
+ * fr_packet_ok( does checks to verify the packet is actually valid.
*/
if (conf->decode_attrs) {
int ret;
fr_log_fp = log_fp;
if (ret < 0) {
- fr_radius_packet_free(&packet); /* Also frees vps */
+ fr_packet_free(&packet); /* Also frees vps */
REDEBUG("Failed decoding");
return;
/*
* Save the request for later matching
*/
- search.expect = fr_radius_packet_alloc_reply(packet, packet);
+ search.expect = fr_packet_alloc_reply(packet, packet);
if (!search.expect) {
REDEBUG("Failed allocating memory to hold expected reply");
rs_tv_add_ms(&header->ts, conf->stats.timeout, &stats->quiet);
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return;
}
conf->link_da_num);
if (ret < 0) {
ERROR("Failed extracting RTX linking pairs from request");
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return;
}
}
/* We may of seen the response, but it may of been lost upstream */
fr_pair_list_free(&original->link_vps);
- fr_radius_packet_free(&original->linked);
+ fr_packet_free(&original->linked);
/* replace packet and vps */
fr_pair_list_free(&original->packet_vps);
- fr_radius_packet_free(&original->packet);
+ fr_packet_free(&original->packet);
original->packet = talloc_steal(original, packet);
fr_pair_list_append(&original->packet_vps, &decoded);
/* replace expected packets and vps */
fr_pair_list_free(&original->expect_vps);
- fr_radius_packet_free(&original->expect);
+ fr_packet_free(&original->expect);
original->expect = talloc_steal(original, search.expect);
fr_pair_list_append(&original->expect_vps, &search.expect_vps);
default:
REDEBUG("Unsupported code %i", packet->code);
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return;
}
* not be done by the event queue.
*/
if (response && !original) {
- fr_radius_packet_free(&packet); /* Also frees decoded */
+ fr_packet_free(&packet); /* Also frees decoded */
}
captured++;
DEBUG2(" RADIUS secret : [%s]", conf->radius_secret);
if (conf->filter_request_code) {
- DEBUG2(" RADIUS request code : [%s]", fr_radius_packet_names[conf->filter_request_code]);
+ DEBUG2(" RADIUS request code : [%s]", fr_packet_names[conf->filter_request_code]);
}
if (!fr_pair_list_empty(&conf->filter_request_vps)){
}
if (conf->filter_response_code) {
- DEBUG2(" RADIUS response code : [%s]", fr_radius_packet_names[conf->filter_response_code]);
+ DEBUG2(" RADIUS response code : [%s]", fr_packet_names[conf->filter_response_code]);
}
if (conf->to_output_dir) {
fr_pair_list_t filter_request_vps; //!< Sorted filter vps.
fr_pair_list_t filter_response_vps; //!< Sorted filter vps.
- fr_radius_packet_code_t filter_request_code; //!< Filter request packets by code.
- fr_radius_packet_code_t filter_response_code; //!< Filter response packets by code.
+ fr_packet_code_t filter_request_code; //!< Filter request packets by code.
+ fr_packet_code_t filter_response_code; //!< Filter response packets by code.
rs_status_t event_flags; //!< Events we log and capture on.
rs_packet_logger_t logger; //!< Packet logger
* collectd.c - Registration and processing functions
*/
rs_stats_tmpl_t *rs_stats_collectd_init_latency(TALLOC_CTX *ctx, rs_stats_tmpl_t **out, rs_t *conf,
- char const *type, rs_latency_t *stats, fr_radius_packet_code_t code);
+ char const *type, rs_latency_t *stats, fr_packet_code_t code);
void rs_stats_collectd_do_stats(rs_t *conf, rs_stats_tmpl_t *tmpls, struct timeval *now);
int rs_stats_collectd_open(rs_t *conf);
int rs_stats_collectd_close(rs_t *conf);
{
fr_packet_t *packet;
- packet = fr_radius_packet_alloc(conf, true);
+ packet = fr_packet_alloc(conf, true);
packet->code = conf->code;
* next call.
*/
for (i = 0; i < conf->retries; i++) {
- rcode = fr_radius_packet_send(packet, &request_vps, NULL, conf->secret);
+ rcode = fr_packet_send(packet, &request_vps, NULL, conf->secret);
if (rcode < 0) {
ERROR("Failed sending: %s", fr_syserror(errno));
return EXIT_FAILURE;
continue; /* Timeout */
case 1:
- reply = fr_radius_packet_recv(packet, packet->socket.fd, UDP_FLAGS_NONE,
+ reply = fr_packet_recv(packet, packet->socket.fd, UDP_FLAGS_NONE,
RADIUS_MAX_ATTRIBUTES, false);
if (!reply) {
fr_perror("Failed receiving reply");
* Create and initialize the new request.
*/
request = request_alloc_internal(ctx, NULL);
- if (!request->packet) request->packet = fr_radius_packet_alloc(request, false);
- if (!request->reply) request->reply = fr_radius_packet_alloc(request, false);
+ if (!request->packet) request->packet = fr_packet_alloc(request, false);
+ if (!request->reply) request->reply = fr_packet_alloc(request, false);
request->packet->socket = (fr_socket_t){
.type = SOCK_DGRAM,
return NULL;
}
- request->packet = fr_radius_packet_alloc(request, false);
+ request->packet = fr_packet_alloc(request, false);
if (!request->packet) {
fr_strerror_const("No memory");
goto error;
}
request->packet->timestamp = fr_time();
- request->reply = fr_radius_packet_alloc(request, false);
+ request->reply = fr_packet_alloc(request, false);
if (!request->reply) {
fr_strerror_const("No memory");
goto error;
request = request_alloc_internal(NULL, NULL);
if (!request) return NULL;
- if (!request->packet) request->packet = fr_radius_packet_alloc(request, false);
- if (!request->reply) request->reply = fr_radius_packet_alloc(request, false);
+ if (!request->packet) request->packet = fr_packet_alloc(request, false);
+ if (!request->reply) request->reply = fr_packet_alloc(request, false);
memcpy(request->packet, old->packet, sizeof(*request->packet));
(void) fr_pair_list_copy(request->request_ctx, &request->request_pairs, &old->request_pairs);
}
-fr_radius_packet_code_t chbind_process(request_t *request, CHBIND_REQ *chbind)
+fr_packet_code_t chbind_process(request_t *request, CHBIND_REQ *chbind)
{
- fr_radius_packet_code_t code;
+ fr_packet_code_t code;
rlm_rcode_t rcode;
request_t *fake = NULL;
uint8_t const *attr_data;
#define CHBIND_CODE_FAILURE 3
/* Channel binding function prototypes */
-fr_radius_packet_code_t chbind_process(request_t *request, CHBIND_REQ *chbind_req);
+fr_packet_code_t chbind_process(request_t *request, CHBIND_REQ *chbind_req);
fr_pair_t *eap_chbind_packet2vp(TALLOC_CTX *ctx, chbind_packet_t *chbind);
chbind_packet_t *eap_chbind_vp2packet(TALLOC_CTX *ctx, fr_pair_list_t *vps);
/*
* http://www.freeradius.org/rfc/rfc2869.html#EAP-Message
*
- * Checks for Message-Authenticator are handled by fr_radius_packet_recv().
+ * Checks for Message-Authenticator are handled by fr_packet_recv().
*/
/*
* For internal requests request->packet
* and request->reply are already populated.
*/
- if (!request->packet) MEM(request->packet = fr_radius_packet_alloc(request, false));
- if (!request->reply) MEM(request->reply = fr_radius_packet_alloc(request, false));
+ if (!request->packet) MEM(request->packet = fr_packet_alloc(request, false));
+ if (!request->reply) MEM(request->reply = fr_packet_alloc(request, false));
request->packet->timestamp = now;
request->async = talloc_zero(request, fr_async_t);
*/
request = request_local_alloc_external(autofree, NULL);
- request->packet = fr_radius_packet_alloc(request, false);
+ request->packet = fr_packet_alloc(request, false);
TEST_CHECK(request->packet != NULL);
- request->reply = fr_radius_packet_alloc(request, false);
+ request->reply = fr_packet_alloc(request, false);
TEST_CHECK(request->reply != NULL);
return request;
*
* FIXME: Permit different servers for inner && outer sessions?
*/
- child->packet = fr_radius_packet_alloc(child, true);
+ child->packet = fr_packet_alloc(child, true);
if (!child->packet) {
talloc_free(child);
return -1;
}
- child->reply = fr_radius_packet_alloc(child, false);
+ child->reply = fr_packet_alloc(child, false);
if (!child->reply) {
talloc_free(child);
return -1;
*/
request = request_local_alloc_external(autofree, NULL);
- request->packet = fr_radius_packet_alloc(request, false);
+ request->packet = fr_packet_alloc(request, false);
TEST_CHECK(request->packet != NULL);
- request->reply = fr_radius_packet_alloc(request, false);
+ request->reply = fr_packet_alloc(request, false);
TEST_CHECK(request->reply != NULL);
return request;
* - New fr_packet_t.
* - NULL on error.
*/
-fr_packet_t *fr_radius_packet_alloc(TALLOC_CTX *ctx, bool new_vector)
+fr_packet_t *fr_packet_alloc(TALLOC_CTX *ctx, bool new_vector)
{
fr_packet_t *rp;
* - New fr_packet_t.
* - NULL on error.
*/
-fr_packet_t *fr_radius_packet_alloc_reply(TALLOC_CTX *ctx, fr_packet_t *packet)
+fr_packet_t *fr_packet_alloc_reply(TALLOC_CTX *ctx, fr_packet_t *packet)
{
fr_packet_t *reply;
if (!packet) return NULL;
- reply = fr_radius_packet_alloc(ctx, false);
+ reply = fr_packet_alloc(ctx, false);
if (!reply) return NULL;
/*
/** Free a fr_packet_t
*
*/
-void fr_radius_packet_free(fr_packet_t **packet_p)
+void fr_packet_free(fr_packet_t **packet_p)
{
fr_packet_t *packet;
/*
* vector: Request authenticator from access-request packet
* Put in there by rad_decode, and must be put in the
- * response fr_packet_t as well before calling fr_radius_packet_send
+ * response fr_packet_t as well before calling fr_packet_send
*
* verified: Filled in by rad_decode for accounting-request packets
*
void *uctx;
} fr_packet_t;
-fr_packet_t *fr_radius_packet_alloc(TALLOC_CTX *ctx, bool new_vector);
-fr_packet_t *fr_radius_packet_alloc_reply(TALLOC_CTX *ctx, fr_packet_t *);
-void fr_radius_packet_free(fr_packet_t **);
+fr_packet_t *fr_packet_alloc(TALLOC_CTX *ctx, bool new_vector);
+fr_packet_t *fr_packet_alloc_reply(TALLOC_CTX *ctx, fr_packet_t *);
+void fr_packet_free(fr_packet_t **);
#ifdef __cplusplus
}
if (RDEBUG_ENABLED) {
RDEBUG("Sending %s ID %i from %pV:%i to %pV:%i length %zu via socket %s",
- fr_radius_packet_names[request->reply->code],
+ fr_packet_names[request->reply->code],
request->reply->id,
fr_box_ipaddr(request->reply->socket.inet.src_ipaddr),
request->reply->socket.inet.src_port,
* Print out what we received.
*/
DEBUG2("proto_radius_tcp - Received %s ID %d length %d %s",
- fr_radius_packet_names[buffer[0]], buffer[1],
+ fr_packet_names[buffer[0]], buffer[1],
(int) packet_len, thread->name);
return packet_len;
* Print out what we received.
*/
DEBUG2("proto_radius_udp - Received %s ID %d length %d %s",
- fr_radius_packet_names[buffer[0]], buffer[1],
+ fr_packet_names[buffer[0]], buffer[1],
(int) packet_len, thread->name);
return packet_len;
eap_fast_tlv_append(tls_session, attr_eap_fast_error, true, sizeof(value), &value);
}
-static void eap_fast_append_result(fr_tls_session_t *tls_session, fr_radius_packet_code_t code)
+static void eap_fast_append_result(fr_tls_session_t *tls_session, fr_packet_code_t code)
{
eap_fast_tunnel_t *t = talloc_get_type_abort(tls_session->opaque, eap_fast_tunnel_t);
uint16_t state;
return rcode;
}
-static fr_radius_packet_code_t eap_fast_eap_payload(request_t *request, eap_session_t *eap_session,
+static fr_packet_code_t eap_fast_eap_payload(request_t *request, eap_session_t *eap_session,
fr_tls_session_t *tls_session, fr_pair_t *tlv_eap_payload)
{
- fr_radius_packet_code_t code = FR_RADIUS_CODE_ACCESS_REJECT;
+ fr_packet_code_t code = FR_RADIUS_CODE_ACCESS_REJECT;
rlm_rcode_t rcode;
fr_pair_t *vp;
eap_fast_tunnel_t *t;
request->proxy->packet->src_port = 0;
request->proxy->packet->dst_port = 0;
fake->packet = NULL;
- fr_radius_packet_free(&fake->reply);
+ fr_packet_free(&fake->reply);
fake->reply = NULL;
/*
return code;
}
-static fr_radius_packet_code_t eap_fast_crypto_binding(request_t *request, UNUSED eap_session_t *eap_session,
+static fr_packet_code_t eap_fast_crypto_binding(request_t *request, UNUSED eap_session_t *eap_session,
fr_tls_session_t *tls_session, eap_tlv_crypto_binding_tlv_t *binding)
{
uint8_t cmac[sizeof(binding->compound_mac)];
return FR_RADIUS_CODE_ACCESS_ACCEPT;
}
-static fr_radius_packet_code_t eap_fast_process_tlvs(request_t *request, eap_session_t *eap_session,
+static fr_packet_code_t eap_fast_process_tlvs(request_t *request, eap_session_t *eap_session,
fr_tls_session_t *tls_session, fr_pair_list_t *fast_vps)
{
eap_fast_tunnel_t *t = talloc_get_type_abort(tls_session->opaque, eap_fast_tunnel_t);
for (vp = fr_pair_list_head(fast_vps);
vp;
vp = fr_pair_list_next(fast_vps, vp)) {
- fr_radius_packet_code_t code = FR_RADIUS_CODE_ACCESS_REJECT;
+ fr_packet_code_t code = FR_RADIUS_CODE_ACCESS_REJECT;
if (vp->da->parent == fr_dict_root(dict_eap_fast)) {
if (vp->da == attr_eap_fast_eap_payload) {
code = eap_fast_eap_payload(request, eap_session, tls_session, vp);
}
if (binding) {
- fr_radius_packet_code_t code = eap_fast_crypto_binding(request, eap_session, tls_session, binding);
+ fr_packet_code_t code = eap_fast_crypto_binding(request, eap_session, tls_session, binding);
if (code == FR_RADIUS_CODE_ACCESS_ACCEPT) {
t->stage = EAP_FAST_PROVISIONING;
}
/*
* Process the inner tunnel data
*/
-fr_radius_packet_code_t eap_fast_process(request_t *request, eap_session_t *eap_session, fr_tls_session_t *tls_session)
+fr_packet_code_t eap_fast_process(request_t *request, eap_session_t *eap_session, fr_tls_session_t *tls_session)
{
- fr_radius_packet_code_t code;
+ fr_packet_code_t code;
fr_pair_list_t fast_vps;
uint8_t const *data;
size_t data_len;
*/
void eap_fast_tlv_append(fr_tls_session_t *tls_session, fr_dict_attr_t const *da, bool mandatory,
int length, const void *data) CC_HINT(nonnull);
-fr_radius_packet_code_t eap_fast_process(request_t *request, eap_session_t *eap_session, fr_tls_session_t *tls_session) CC_HINT(nonnull);
+fr_packet_code_t eap_fast_process(request_t *request, eap_session_t *eap_session, fr_tls_session_t *tls_session) CC_HINT(nonnull);
/*
* A bunch of EAP-FAST helper functions.
* Note that we don't do *anything* with the reply
* attributes.
*/
- if (FR_RADIUS_PACKET_CODE_VALID(reply->code)) {
- RDEBUG2("Got tunneled reply %s", fr_radius_packet_names[reply->code]);
+ if (fr_packet_CODE_VALID(reply->code)) {
+ RDEBUG2("Got tunneled reply %s", fr_packet_names[reply->code]);
} else {
RDEBUG2("Got tunneled reply code %i", reply->code);
}
/*
* Process the TTLS portion of an EAP-TTLS request.
*/
-fr_radius_packet_code_t eap_ttls_process(request_t *request, eap_session_t *eap_session, fr_tls_session_t *tls_session) CC_HINT(nonnull);
+fr_packet_code_t eap_ttls_process(request_t *request, eap_session_t *eap_session, fr_tls_session_t *tls_session) CC_HINT(nonnull);
/*
* Process the "diameter" contents of the tunneled data.
*/
-fr_radius_packet_code_t eap_ttls_process(request_t *request, eap_session_t *eap_session, fr_tls_session_t *tls_session)
+fr_packet_code_t eap_ttls_process(request_t *request, eap_session_t *eap_session, fr_tls_session_t *tls_session)
{
- fr_radius_packet_code_t code = FR_RADIUS_CODE_ACCESS_REJECT;
+ fr_packet_code_t code = FR_RADIUS_CODE_ACCESS_REJECT;
rlm_rcode_t rcode;
fr_pair_t *vp = NULL;
fr_dcursor_t cursor;
*/
chbind = eap_chbind_vp2packet(request, &request->request_pairs);
if (chbind) {
- fr_radius_packet_code_t chbind_code;
+ fr_packet_code_t chbind_code;
CHBIND_REQ *req = talloc_zero(request, CHBIND_REQ);
RDEBUG2("received chbind request");
if (!inst->allowed[request->packet->code]) {
REDEBUG("Packet code %s is disallowed by the configuration",
- fr_radius_packet_names[request->packet->code]);
+ fr_packet_names[request->packet->code]);
RETURN_MODULE_FAIL;
}
*/
if (inst->replicate && inst->status_check) {
cf_log_warn(conf, "Ignoring 'status_check = %s' due to 'replicate = true'",
- fr_radius_packet_names[inst->status_check]);
+ fr_packet_names[inst->status_check]);
inst->status_check = 0;
}
} else if (!inst->allowed[inst->status_check]) {
cf_log_err(conf, "Using 'status_check = %s' requires also 'type = %s'",
- fr_radius_packet_names[inst->status_check], fr_radius_packet_names[inst->status_check]);
+ fr_packet_names[inst->status_check], fr_packet_names[inst->status_check]);
return -1;
}
talloc_const_free(request->name);
request->name = talloc_strdup(request, h->module_name);
- request->packet = fr_radius_packet_alloc(request, false);
- request->reply = fr_radius_packet_alloc(request, false);
+ request->packet = fr_packet_alloc(request, false);
+ request->reply = fr_packet_alloc(request, false);
/*
* Create the VPs, and ignore any errors
u->code = inst->parent->status_check;
request->packet->code = u->code;
- DEBUG3("%s - Status check packet type will be %s", h->module_name, fr_radius_packet_names[u->code]);
+ DEBUG3("%s - Status check packet type will be %s", h->module_name, fr_packet_names[u->code]);
log_request_pair_list(L_DBG_LVL_3, request, NULL, &request->request_pairs, NULL);
MEM(h->status_r = talloc_zero(request, udp_result_t));
}
DEBUG("%s - Sending %s ID %d length %ld over connection %s",
- h->module_name, fr_radius_packet_names[u->code], u->id, u->packet_len, h->name);
+ h->module_name, fr_packet_names[u->code], u->id, u->packet_len, h->name);
if (encode(h->inst, h->status_request, u, u->id) < 0) {
fail:
slen = write(h->fd, u->packet, u->packet_len);
if (slen < 0) {
ERROR("%s - Failed sending %s ID %d length %ld over connection %s: %s",
- h->module_name, fr_radius_packet_names[u->code], u->id, u->packet_len, h->name, fr_syserror(errno));
+ h->module_name, fr_packet_names[u->code], u->id, u->packet_len, h->name, fr_syserror(errno));
goto fail;
}
fr_assert((size_t)slen == u->packet_len);
code = data[0];
RDEBUG("Received %s ID %d length %ld reply packet on connection %s",
- fr_radius_packet_names[code], data[1], data_len, h->name);
+ fr_packet_names[code], data[1], data_len, h->name);
log_request_pair_list(L_DBG_LVL_2, request, NULL, reply, NULL);
*response_code = code;
u->id = u->rr->id;
RDEBUG("Sending %s ID %d length %ld over connection %s",
- fr_radius_packet_names[u->code], u->id, u->packet_len, h->name);
+ fr_packet_names[u->code], u->id, u->packet_len, h->name);
if (encode(h->inst, request, u, u->id) < 0) {
/*
(void) radius_track_entry_update(u->rr, u->packet + RADIUS_AUTH_VECTOR_OFFSET);
} else {
RDEBUG("Retransmitting %s ID %d length %ld over connection %s",
- fr_radius_packet_names[u->code], u->id, u->packet_len, h->name);
+ fr_packet_names[u->code], u->id, u->packet_len, h->name);
}
log_request_pair_list(L_DBG_LVL_2, request, NULL, &request->request_pairs, NULL);
}
RDEBUG("Sending %s ID %d length %ld over connection %s",
- fr_radius_packet_names[u->code], u->id, u->packet_len, h->name);
+ fr_packet_names[u->code], u->id, u->packet_len, h->name);
RHEXDUMP3(u->packet, u->packet_len, "Encoded packet");
h->coalesced[queued].treq = treq;
if (!local_stats[i]) continue;
- strlcpy(buffer + 18, fr_radius_packet_names[i], sizeof(buffer) - 18);
+ strlcpy(buffer + 18, fr_packet_names[i], sizeof(buffer) - 18);
da = fr_dict_attr_by_name(NULL, fr_dict_root(dict_radius), buffer);
if (!da) continue;
///< the same order as they were added.
} process_radius_request_pairs_t;
-#define FR_RADIUS_PROCESS_CODE_VALID(_x) (FR_RADIUS_PACKET_CODE_VALID(_x) || (_x == FR_RADIUS_CODE_DO_NOT_RESPOND))
+#define FR_RADIUS_PROCESS_CODE_VALID(_x) (fr_packet_CODE_VALID(_x) || (_x == FR_RADIUS_CODE_DO_NOT_RESPOND))
-#define PROCESS_PACKET_TYPE fr_radius_packet_code_t
+#define PROCESS_PACKET_TYPE fr_packet_code_t
#define PROCESS_CODE_MAX FR_RADIUS_CODE_MAX
#define PROCESS_CODE_DO_NOT_RESPOND FR_RADIUS_CODE_DO_NOT_RESPOND
#define PROCESS_PACKET_CODE_VALID FR_RADIUS_PROCESS_CODE_VALID
#endif
"",
received ? "Received" : "Sending",
- fr_radius_packet_names[packet->code],
+ fr_packet_names[packet->code],
packet->id,
packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
fr_box_ipaddr(packet->socket.inet.src_ipaddr),
PROCESS_TRACE;
- fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->reply->code));
+ fr_assert(fr_packet_CODE_VALID(request->reply->code));
/*
* https://tools.ietf.org/html/rfc7930#section-4
request->module = NULL;
fr_assert(request->dict == dict_radius);
- fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->packet->code));
+ fr_assert(fr_packet_CODE_VALID(request->packet->code));
UPDATE_STATE(packet);
process_ttls_auth_t auth; //!< Authentication configuration.
} process_ttls_t;
-#define PROCESS_PACKET_TYPE fr_radius_packet_code_t
+#define PROCESS_PACKET_TYPE fr_packet_code_t
#define PROCESS_CODE_MAX FR_RADIUS_CODE_MAX
#define PROCESS_CODE_DO_NOT_RESPOND FR_RADIUS_CODE_DO_NOT_RESPOND
-#define PROCESS_PACKET_CODE_VALID FR_RADIUS_PACKET_CODE_VALID
+#define PROCESS_PACKET_CODE_VALID fr_packet_CODE_VALID
#define PROCESS_INST process_ttls_t
#include <freeradius-devel/server/process.h>
#endif
"",
received ? "Received" : "Sending",
- fr_radius_packet_names[packet->code],
+ fr_packet_names[packet->code],
packet->id,
packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
fr_box_ipaddr(packet->socket.inet.src_ipaddr),
PROCESS_TRACE;
fr_assert(rcode < RLM_MODULE_NUMCODES);
- fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->reply->code));
+ fr_assert(fr_packet_CODE_VALID(request->reply->code));
if (auth_type_rcode[rcode] == FR_RADIUS_CODE_DO_NOT_RESPOND) {
request->reply->code = auth_type_rcode[rcode];
PROCESS_TRACE;
- fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->reply->code));
+ fr_assert(fr_packet_CODE_VALID(request->reply->code));
/*
* https://tools.ietf.org/html/rfc7930#section-4
PROCESS_TRACE;
- fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->packet->code));
+ fr_assert(fr_packet_CODE_VALID(request->packet->code));
request->component = "radius";
request->module = NULL;
fprintf(stdout, ## __VA_ARGS__); \
fprintf(stdout, "\n"); \
} \
- fr_radius_packet_free(&packet); \
+ fr_packet_free(&packet); \
return NULL; \
}
#endif
if (data_len < MIN_PACKET_SIZE) return NULL;
/* Now that checks are done, allocate packet */
- packet = fr_radius_packet_alloc(NULL, false);
+ packet = fr_packet_alloc(NULL, false);
if (!packet) {
fr_strerror_const("Failed allocating packet");
return NULL;
socklen_t sock_len;
uint8_t data_offset;
- packet = fr_radius_packet_alloc(NULL, false);
+ packet = fr_packet_alloc(NULL, false);
if (!packet) {
fr_strerror_const("Failed allocating packet");
return NULL;
raw_packet = talloc_zero_array(packet, uint8_t, MAX_PACKET_SIZE);
if (!raw_packet) {
fr_strerror_const("Out of memory");
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return NULL;
}
packet->data_len, attr_dhcp_message_type);
if (!code) {
fr_strerror_const("No message-type option was found in the packet");
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return NULL;
}
if ((code[1] < 1) || (code[2] == 0) || (code[2] > 8)) {
fr_strerror_const("Unknown value for message-type option");
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return NULL;
}
};
size_t fr_radius_request_name_table_len = NUM_ELEMENTS(fr_radius_request_name_table);
-char const *fr_radius_packet_names[FR_RADIUS_CODE_MAX] = {
+char const *fr_packet_names[FR_RADIUS_CODE_MAX] = {
"", //!< 0
"Access-Request",
"Access-Accept",
/** If we get a reply, the request must come from one of a small
* number of packet types.
*/
-static const fr_radius_packet_code_t allowed_replies[FR_RADIUS_CODE_MAX] = {
+static const fr_packet_code_t allowed_replies[FR_RADIUS_CODE_MAX] = {
[FR_RADIUS_CODE_ACCESS_ACCEPT] = FR_RADIUS_CODE_ACCESS_REQUEST,
[FR_RADIUS_CODE_ACCESS_CHALLENGE] = FR_RADIUS_CODE_ACCESS_REQUEST,
[FR_RADIUS_CODE_ACCESS_REJECT] = FR_RADIUS_CODE_ACCESS_REQUEST,
if (!allowed_replies[code]) {
fr_strerror_printf("%s packet received unknown reply code %s",
- fr_radius_packet_names[decode_ctx->request_code], fr_radius_packet_names[code]);
+ fr_packet_names[decode_ctx->request_code], fr_packet_names[code]);
return DECODE_FAIL_UNKNOWN_PACKET_CODE;
}
if ((code != FR_RADIUS_CODE_PROTOCOL_ERROR) && (decode_ctx->request_code != FR_RADIUS_CODE_STATUS_SERVER) &&
(allowed_replies[code] != decode_ctx->request_code)) {
fr_strerror_printf("%s packet received invalid reply code %s",
- fr_radius_packet_names[decode_ctx->request_code], fr_radius_packet_names[code]);
+ fr_packet_names[decode_ctx->request_code], fr_packet_names[code]);
return DECODE_FAIL_UNKNOWN_PACKET_CODE;
}
}
/*
* Encode the packet.
*/
- if (fr_radius_packet_encode(packet, list, NULL, (char const *) my->cfg.verify.secret) < 0) {
+ if (fr_packet_encode(packet, list, NULL, (char const *) my->cfg.verify.secret) < 0) {
fail:
fr_radius_code_id_push(my->codes, packet);
return -1;
}
- if (fr_radius_packet_sign(packet, NULL, (char const *) my->cfg.verify.secret) < 0) goto fail;
+ if (fr_packet_sign(packet, NULL, (char const *) my->cfg.verify.secret) < 0) goto fail;
slen = fr_bio_write(my->common.bio, &packet->socket, packet->data, packet->data_len);
if (slen <= 0) goto fail;
return 0;
}
-static const fr_radius_packet_code_t allowed_replies[FR_RADIUS_CODE_MAX] = {
+static const fr_packet_code_t allowed_replies[FR_RADIUS_CODE_MAX] = {
[FR_RADIUS_CODE_ACCESS_ACCEPT] = FR_RADIUS_CODE_ACCESS_REQUEST,
[FR_RADIUS_CODE_ACCESS_CHALLENGE] = FR_RADIUS_CODE_ACCESS_REQUEST,
[FR_RADIUS_CODE_ACCESS_REJECT] = FR_RADIUS_CODE_ACCESS_REQUEST,
/*
* Allocate the new request data structure
*/
- reply = fr_radius_packet_alloc(packet, false);
+ reply = fr_packet_alloc(packet, false);
if (!reply) return -1;
reply->socket = fd_ctx.socket;
*
* "length" is AT LEAST the length of this attribute, as we
* expect the caller to have verified the data with
- * fr_radius_packet_ok(). "length" may be up to the length of the
+ * fr_packet_ok(). "length" may be up to the length of the
* packet.
*
* This function will ONLY return -1 on programmer error or OOM. If
*/
case FLAG_TAGGED_TUNNEL_PASSWORD:
case FLAG_ENCRYPT_TUNNEL_PASSWORD:
- if (!packet_ctx->request_authenticator) goto raw;
+ if (!packet_ctx->request_authenticator) goto raw;
if (fr_radius_decode_tunnel_password(buffer, &data_len, packet_ctx) < 0) {
goto raw;
* Ascend-Send-Secret
* Ascend-Receive-Secret
*/
- case FLAG_ENCRYPT_ASCEND_SECRET:
+ case FLAG_ENCRYPT_ASCEND_SECRET:
if (!packet_ctx->request_authenticator) goto raw;
fr_radius_ascend_secret(&FR_DBUFF_TMP(buffer, sizeof(buffer)), p, data_len,
FR_RADIUS_CODE_PROTOCOL_ERROR = 52, //!< RFC7930 - Protocol-Error (generic NAK)
FR_RADIUS_CODE_MAX = 53, //!< Maximum possible protocol code
FR_RADIUS_CODE_DO_NOT_RESPOND = 256 //!< Special rcode to indicate we will not respond.
-} fr_radius_packet_code_t;
+} fr_packet_code_t;
#define FR_AUTH_UDP_PORT 1812
#define FR_AUTH_UDP_PORT_ALT 1645
if (pl->sockets[start].socket.type == SOCK_STREAM) {
packet = fr_tcp_recv(pl->sockets[start].socket.fd, false);
} else
- packet = fr_radius_packet_recv(NULL, pl->sockets[start].socket.fd, UDP_FLAGS_NONE,
+ packet = fr_packet_recv(NULL, pl->sockets[start].socket.fd, UDP_FLAGS_NONE,
max_attributes, require_ma);
if (!packet) continue;
*
* This really belongs in a utility library
*/
- if (FR_RADIUS_PACKET_CODE_VALID(packet->code)) {
+ if (fr_packet_CODE_VALID(packet->code)) {
fr_log(log, L_DBG, __FILE__, __LINE__,
"%s %s Id %i from %s%s%s:%i to %s%s%s:%i "
#ifdef WITH_IFINDEX_NAME_RESOLUTION
#endif
"length %zu\n",
received ? "Received" : "Sent",
- fr_radius_packet_names[packet->code],
+ fr_packet_names[packet->code],
packet->id,
packet->socket.inet.src_ipaddr.af == AF_INET6 ? "[" : "",
fr_inet_ntop(src_ipaddr, sizeof(src_ipaddr), &packet->socket.inet.src_ipaddr),
fr_packet_header_log(log, packet, received);
if (fr_debug_lvl >= L_DBG_LVL_1) fr_pair_list_log(log, 4, list);
#ifndef NDEBUG
- if (fr_debug_lvl >= L_DBG_LVL_4) fr_radius_packet_log_hex(log, packet);
+ if (fr_debug_lvl >= L_DBG_LVL_4) fr_packet_log_hex(log, packet);
#endif
}
/** Encode a packet
*
*/
-ssize_t fr_radius_packet_encode(fr_packet_t *packet, fr_pair_list_t *list,
+ssize_t fr_packet_encode(fr_packet_t *packet, fr_pair_list_t *list,
fr_packet_t const *original, char const *secret)
{
uint8_t const *original_data;
uint8_t data[MAX_PACKET_LEN];
#ifndef NDEBUG
- if (fr_debug_lvl >= L_DBG_LVL_4) fr_radius_packet_log_hex(&default_log, packet);
+ if (fr_debug_lvl >= L_DBG_LVL_4) fr_packet_log_hex(&default_log, packet);
#endif
if (original) {
* - True on success.
* - False on failure.
*/
-bool fr_radius_packet_ok(fr_packet_t *packet, uint32_t max_attributes, bool require_ma, decode_fail_t *reason)
+bool fr_packet_ok(fr_packet_t *packet, uint32_t max_attributes, bool require_ma, decode_fail_t *reason)
{
char host_ipaddr[INET6_ADDRSTRLEN];
/** Verify the Request/Response Authenticator (and Message-Authenticator if present) of a packet
*
*/
-int fr_radius_packet_verify(fr_packet_t *packet, fr_packet_t *original, char const *secret)
+int fr_packet_verify(fr_packet_t *packet, fr_packet_t *original, char const *secret)
{
char buffer[INET6_ADDRSTRLEN];
/** Sign a previously encoded packet
*
*/
-int fr_radius_packet_sign(fr_packet_t *packet, fr_packet_t const *original,
+int fr_packet_sign(fr_packet_t *packet, fr_packet_t const *original,
char const *secret)
{
int ret;
/** Receive UDP client requests, and fill in the basics of a fr_packet_t structure
*
*/
-fr_packet_t *fr_radius_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t max_attributes, bool require_ma)
+fr_packet_t *fr_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t max_attributes, bool require_ma)
{
ssize_t data_len;
fr_packet_t *packet;
/*
* Allocate the new request data structure
*/
- packet = fr_radius_packet_alloc(ctx, false);
+ packet = fr_packet_alloc(ctx, false);
if (!packet) {
fr_strerror_const("out of memory");
return NULL;
data_len = rad_recvfrom(fd, packet, flags);
if (data_len < 0) {
FR_DEBUG_STRERROR_PRINTF("Error receiving packet: %s", fr_syserror(errno));
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return NULL;
}
(packet->socket.inet.dst_ipaddr.af == AF_UNSPEC) ||
(packet->socket.inet.dst_port == 0)) {
FR_DEBUG_STRERROR_PRINTF("Error receiving packet: %s", fr_syserror(errno));
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return NULL;
}
#endif
*/
if (packet->data_len > MAX_PACKET_LEN) {
FR_DEBUG_STRERROR_PRINTF("Discarding packet: Larger than RFC limitation of 4096 bytes");
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return NULL;
}
*/
if ((packet->data_len == 0) || !packet->data) {
FR_DEBUG_STRERROR_PRINTF("Empty packet: Socket is not ready");
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return NULL;
}
/*
* See if it's a well-formed RADIUS packet.
*/
- if (!fr_radius_packet_ok(packet, max_attributes, require_ma, NULL)) {
- fr_radius_packet_free(&packet);
+ if (!fr_packet_ok(packet, max_attributes, require_ma, NULL)) {
+ fr_packet_free(&packet);
return NULL;
}
*
* Also attach reply attribute value pairs and any user message provided.
*/
-int fr_radius_packet_send(fr_packet_t *packet, fr_pair_list_t *list,
+int fr_packet_send(fr_packet_t *packet, fr_pair_list_t *list,
fr_packet_t const *original, char const *secret)
{
/*
/*
* Encode the packet.
*/
- if (fr_radius_packet_encode(packet, list, original, secret) < 0) {
+ if (fr_packet_encode(packet, list, original, secret) < 0) {
return -1;
}
* Re-sign it, including updating the
* Message-Authenticator.
*/
- if (fr_radius_packet_sign(packet, original, secret) < 0) {
+ if (fr_packet_sign(packet, original, secret) < 0) {
return -1;
}
return udp_send(&packet->socket, 0, packet->data, packet->data_len);
}
-void _fr_radius_packet_log_hex(fr_log_t const *log, fr_packet_t const *packet, char const *file, int line)
+void _fr_packet_log_hex(fr_log_t const *log, fr_packet_t const *packet, char const *file, int line)
{
uint8_t const *attr, *end;
char buffer[1024];
}
if ((packet->data[0] > 0) && (packet->data[0] < FR_RADIUS_CODE_MAX)) {
- fr_log(log, L_DBG, file, line, " Code : %s", fr_radius_packet_names[packet->data[0]]);
+ fr_log(log, L_DBG, file, line, " Code : %s", fr_packet_names[packet->data[0]]);
} else {
fr_log(log, L_DBG, file, line, " Code : %u", packet->data[0]);
}
* protocols/radius/base.c
*/
-extern char const *fr_radius_packet_names[FR_RADIUS_CODE_MAX];
-#define FR_RADIUS_PACKET_CODE_VALID(_x) ((_x > 0) && (_x < FR_RADIUS_CODE_MAX))
+extern char const *fr_packet_names[FR_RADIUS_CODE_MAX];
+#define fr_packet_CODE_VALID(_x) ((_x > 0) && (_x < FR_RADIUS_CODE_MAX))
#define AUTH_PASS_LEN (RADIUS_AUTH_VECTOR_LENGTH)
/*
* protocols/radius/packet.c
*/
-ssize_t fr_radius_packet_encode(fr_packet_t *packet, fr_pair_list_t *list,
+ssize_t fr_packet_encode(fr_packet_t *packet, fr_pair_list_t *list,
fr_packet_t const *original,
char const *secret) CC_HINT(nonnull (1,2,4));
-bool fr_radius_packet_ok(fr_packet_t *packet, uint32_t max_attributes, bool require_ma,
+bool fr_packet_ok(fr_packet_t *packet, uint32_t max_attributes, bool require_ma,
decode_fail_t *reason) CC_HINT(nonnull (1));
-int fr_radius_packet_verify(fr_packet_t *packet, fr_packet_t *original,
+int fr_packet_verify(fr_packet_t *packet, fr_packet_t *original,
char const *secret) CC_HINT(nonnull (1,3));
-int fr_radius_packet_sign(fr_packet_t *packet, fr_packet_t const *original,
+int fr_packet_sign(fr_packet_t *packet, fr_packet_t const *original,
char const *secret) CC_HINT(nonnull (1,3));
-fr_packet_t *fr_radius_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t max_attributes, bool require_ma);
-int fr_radius_packet_send(fr_packet_t *packet, fr_pair_list_t *list,
+fr_packet_t *fr_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t max_attributes, bool require_ma);
+int fr_packet_send(fr_packet_t *packet, fr_pair_list_t *list,
fr_packet_t const *original, char const *secret) CC_HINT(nonnull (1,2,4));
-#define fr_radius_packet_log_hex(_log, _packet) _fr_radius_packet_log_hex(_log, _packet, __FILE__, __LINE__)
-void _fr_radius_packet_log_hex(fr_log_t const *log, fr_packet_t const *packet, char const *file, int line) CC_HINT(nonnull);
+#define fr_packet_log_hex(_log, _packet) _fr_packet_log_hex(_log, _packet, __FILE__, __LINE__)
+void _fr_packet_log_hex(fr_log_t const *log, fr_packet_t const *packet, char const *file, int line) CC_HINT(nonnull);
/*
* protocols/radius/abinary.c
fr_packet_t *fr_tcp_recv(int sockfd, int flags)
{
- fr_packet_t *packet = fr_radius_packet_alloc(NULL, false);
+ fr_packet_t *packet = fr_packet_alloc(NULL, false);
if (!packet) return NULL;
packet->socket.fd = sockfd;
if (fr_tcp_read_packet(packet, RADIUS_MAX_ATTRIBUTES, flags) != 1) {
- fr_radius_packet_free(&packet);
+ fr_packet_free(&packet);
return NULL;
}
/*
* See if it's a well-formed RADIUS packet.
*/
- if (!fr_radius_packet_ok(packet, max_attributes, require_ma, NULL)) {
+ if (!fr_packet_ok(packet, max_attributes, require_ma, NULL)) {
return -1;
}
struct sockaddr_storage src;
socklen_t salen;
-} fr_radius_packet_ctx_t;
+} fr_packet_ctx_t;
static int debug_lvl = 0;
static int max_control_plane = 0;
static int test_decode(UNUSED void const *instance, request_t *request, uint8_t *const data, size_t data_len)
{
- fr_radius_packet_ctx_t const *pc = talloc_get_type_abort_const(request->async->listen->app_instance,
- fr_radius_packet_ctx_t);
+ fr_packet_ctx_t const *pc = talloc_get_type_abort_const(request->async->listen->app_instance,
+ fr_packet_ctx_t);
request->number = pc->id;
request->async->process = test_process;
static ssize_t test_encode(UNUSED void const *instance, request_t *request, uint8_t *buffer, size_t buffer_len)
{
fr_md5_ctx_t *md5_ctx;
- fr_radius_packet_ctx_t const *pc = talloc_get_type_abort_const(request->async->listen->app_instance,
- fr_radius_packet_ctx_t);
+ fr_packet_ctx_t const *pc = talloc_get_type_abort_const(request->async->listen->app_instance,
+ fr_packet_ctx_t);
MPRINT1("\t\tENCODE >>> request %"PRIu64" - data %p %p room %zd\n",
request->number, pc, buffer, buffer_len);
static void send_reply(int sockfd, fr_channel_data_t *reply)
{
- fr_radius_packet_ctx_t *pc = talloc_get_type_abort(reply->packet_ctx, fr_radius_packet_ctx_t);
+ fr_packet_ctx_t *pc = talloc_get_type_abort(reply->packet_ctx, fr_packet_ctx_t);
MPRINT1("Master got reply %d size %zd\n", pc->id, reply->m.data_size);
uint8_t *packet, *attr, *end;
size_t total_len;
ssize_t data_size;
- fr_radius_packet_ctx_t *packet_ctx;
+ fr_packet_ctx_t *packet_ctx;
if (events[i].filter == EVFILT_USER) {
(void) fr_channel_service_kevent(workers[0].ch, control_master, &events[i]);
cd = (fr_channel_data_t *) fr_message_reserve(ms, 4096);
fr_assert(cd != NULL);
- packet_ctx = talloc(ctx, fr_radius_packet_ctx_t);
+ packet_ctx = talloc(ctx, fr_packet_ctx_t);
fr_assert(packet_ctx != NULL);
packet_ctx->salen = sizeof(packet_ctx->src);