From: Arran Cudbard-Bell Date: Wed, 6 Mar 2024 20:12:07 +0000 (-0600) Subject: s/fr_radius_packet/fr_packet/g X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c06455ea89271ac9f2d359d4edaf6c6cf12cb44;p=thirdparty%2Ffreeradius-server.git s/fr_radius_packet/fr_packet/g --- diff --git a/src/bin/collectd.c b/src/bin/collectd.c index efab2bbc70e..7a1e8fafb7b 100644 --- a/src/bin/collectd.c +++ b/src/bin/collectd.c @@ -238,7 +238,7 @@ error: * */ 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; @@ -264,7 +264,7 @@ rs_stats_tmpl_t *rs_stats_collectd_init_latency(TALLOC_CTX *ctx, rs_stats_tmpl_t }; #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) {\ diff --git a/src/bin/dhcpclient.c b/src/bin/dhcpclient.c index 67708e85533..a892c213f26 100644 --- a/src/bin/dhcpclient.c +++ b/src/bin/dhcpclient.c @@ -154,14 +154,14 @@ static int request_init(fr_packet_t **out, fr_pair_list_t *packet_vps, char cons 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; } diff --git a/src/bin/radclient-ng.c b/src/bin/radclient-ng.c index 93b147c9731..0f45bc414c1 100644 --- a/src/bin/radclient-ng.c +++ b/src/bin/radclient-ng.c @@ -273,7 +273,7 @@ static int getport(char const *name) /* * 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: @@ -306,7 +306,7 @@ static void radclient_get_port(fr_radius_packet_code_t type, uint16_t *port) /* * 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 @@ -401,7 +401,7 @@ static int radclient_init(TALLOC_CTX *ctx, rc_file_pair_t *files) 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; @@ -720,7 +720,7 @@ static void deallocate_id(rc_request_t *request) * 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); } /* @@ -876,7 +876,7 @@ static int send_one_packet(rc_request_t *request) /* * 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; @@ -887,7 +887,7 @@ static int send_one_packet(rc_request_t *request) * 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; @@ -955,7 +955,7 @@ static int recv_one_packet(fr_time_delta_t wait_time) 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; @@ -964,7 +964,7 @@ static int recv_one_packet(fr_time_delta_t wait_time) * 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 */ @@ -1016,9 +1016,9 @@ static int recv_one_packet(fr_time_delta_t wait_time) * 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); @@ -1048,8 +1048,8 @@ static int recv_one_packet(fr_time_delta_t wait_time) } 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; } diff --git a/src/bin/radclient.c b/src/bin/radclient.c index a44a82a6530..1823748764a 100644 --- a/src/bin/radclient.c +++ b/src/bin/radclient.c @@ -290,7 +290,7 @@ static int getport(char const *name) /* * 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: @@ -323,7 +323,7 @@ static void radclient_get_port(fr_radius_packet_code_t type, uint16_t *port) /* * 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 @@ -383,7 +383,7 @@ static int coa_init(rc_request_t *parent, FILE *coa_reply, char const *reply_fil return -1; } - request->reply = fr_radius_packet_alloc(request, false); + request->reply = fr_packet_alloc(request, false); if (!request->reply) { ERROR("Out of memory"); @@ -533,7 +533,7 @@ static int radclient_init(TALLOC_CTX *ctx, rc_file_pair_t *files) 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; @@ -928,7 +928,7 @@ static void deallocate_id(rc_request_t *request) * 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); } /* @@ -1111,7 +1111,7 @@ static int send_one_packet(rc_request_t *request) /* * 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; @@ -1151,7 +1151,7 @@ static int recv_coa_packet(fr_time_delta_t wait_time) /* * 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; @@ -1160,7 +1160,7 @@ static int recv_coa_packet(fr_time_delta_t wait_time) /* * 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; } @@ -1197,9 +1197,9 @@ static int recv_coa_packet(fr_time_delta_t wait_time) * 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); @@ -1249,7 +1249,7 @@ static int recv_coa_packet(fr_time_delta_t wait_time) /* * 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; } @@ -1332,7 +1332,7 @@ static int recv_one_packet(fr_time_delta_t wait_time) 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; @@ -1341,7 +1341,7 @@ static int recv_one_packet(fr_time_delta_t wait_time) * 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 */ @@ -1393,9 +1393,9 @@ static int recv_one_packet(fr_time_delta_t wait_time) * 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); @@ -1425,8 +1425,8 @@ static int recv_one_packet(fr_time_delta_t wait_time) } 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; } diff --git a/src/bin/radclient.h b/src/bin/radclient.h index e163f780e1f..e587c957e06 100644 --- a/src/bin/radclient.h +++ b/src/bin/radclient.h @@ -92,7 +92,7 @@ struct rc_request { 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; diff --git a/src/bin/radsniff.c b/src/bin/radsniff.c index a01b63995ea..54a4eb21e9d 100644 --- a/src/bin/radsniff.c +++ b/src/bin/radsniff.c @@ -336,9 +336,9 @@ static void rs_packet_print_csv(uint64_t count, rs_status_t status, fr_pcap_t *h } /* 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, @@ -409,9 +409,9 @@ static void rs_packet_print_fancy(uint64_t count, rs_status_t status, fr_pcap_t 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, @@ -459,7 +459,7 @@ static void rs_packet_print_fancy(uint64_t count, rs_status_t status, fr_pcap_t * 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)) { @@ -633,7 +633,7 @@ static void rs_stats_process_counters(rs_latency_t *stats) } } -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; @@ -643,7 +643,7 @@ static void rs_stats_print_code_fancy(rs_latency_t *stats, fr_radius_packet_code 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); } @@ -652,7 +652,7 @@ static void rs_stats_print_code_fancy(rs_latency_t *stats, fr_radius_packet_code 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); @@ -660,7 +660,7 @@ static void rs_stats_print_code_fancy(rs_latency_t *stats, fr_radius_packet_code } 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); @@ -738,7 +738,7 @@ static void rs_stats_print_csv_header(rs_update_t *this) } 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\"" @@ -1052,9 +1052,9 @@ static int _request_free(rs_request_t *request) } } - 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; } @@ -1391,7 +1391,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt * 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); @@ -1426,13 +1426,13 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt 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; } @@ -1458,7 +1458,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt 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) { @@ -1472,24 +1472,24 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt 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, @@ -1498,7 +1498,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt 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; } @@ -1529,7 +1529,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt * 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. @@ -1566,7 +1566,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt * 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; } @@ -1593,7 +1593,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt drop_request: RDEBUG2("Request dropped by filter"); - fr_radius_packet_free(&packet); + fr_packet_free(&packet); return; } @@ -1608,11 +1608,11 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt 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; } } @@ -1625,7 +1625,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt /* * 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; @@ -1638,7 +1638,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt 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; @@ -1650,11 +1650,11 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt /* * 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; } @@ -1667,7 +1667,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt 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; } } @@ -1733,11 +1733,11 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt /* 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); @@ -1748,7 +1748,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt /* 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); @@ -1828,7 +1828,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt default: REDEBUG("Unsupported code %i", packet->code); - fr_radius_packet_free(&packet); + fr_packet_free(&packet); return; } @@ -1911,7 +1911,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt * 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++; @@ -2894,7 +2894,7 @@ int main(int argc, char *argv[]) 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)){ @@ -2903,7 +2903,7 @@ int main(int argc, char *argv[]) } 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) { diff --git a/src/bin/radsniff.h b/src/bin/radsniff.h index 10c2de3c134..17d2373a919 100644 --- a/src/bin/radsniff.h +++ b/src/bin/radsniff.h @@ -296,8 +296,8 @@ struct rs { 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 @@ -352,7 +352,7 @@ struct rs_stats_tmpl * 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); diff --git a/src/bin/radsnmp.c b/src/bin/radsnmp.c index a6736f10cf1..a9d40a5e2fc 100644 --- a/src/bin/radsnmp.c +++ b/src/bin/radsnmp.c @@ -166,7 +166,7 @@ static fr_packet_t *radsnmp_alloc(radsnmp_conf_t *conf, int fd) { fr_packet_t *packet; - packet = fr_radius_packet_alloc(conf, true); + packet = fr_packet_alloc(conf, true); packet->code = conf->code; @@ -797,7 +797,7 @@ do { \ * 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; @@ -814,7 +814,7 @@ do { \ 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"); diff --git a/src/bin/unit_test_module.c b/src/bin/unit_test_module.c index 759e0d272ff..99c4c92aff9 100644 --- a/src/bin/unit_test_module.c +++ b/src/bin/unit_test_module.c @@ -137,8 +137,8 @@ static request_t *request_from_internal(TALLOC_CTX *ctx) * 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, @@ -209,14 +209,14 @@ static request_t *request_from_file(TALLOC_CTX *ctx, FILE *fp, fr_client_t *clie 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; @@ -612,8 +612,8 @@ static request_t *request_clone(request_t *old, int number, CONF_SECTION *server 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); diff --git a/src/lib/eap/chbind.c b/src/lib/eap/chbind.c index e4231463aca..f5cd6351a37 100644 --- a/src/lib/eap/chbind.c +++ b/src/lib/eap/chbind.c @@ -168,9 +168,9 @@ static size_t chbind_get_data(chbind_packet_t const *packet, } -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; diff --git a/src/lib/eap/chbind.h b/src/lib/eap/chbind.h index adc6a9f506a..e3b792c2c92 100644 --- a/src/lib/eap/chbind.h +++ b/src/lib/eap/chbind.h @@ -57,7 +57,7 @@ typedef struct { #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); diff --git a/src/lib/eap/compose.c b/src/lib/eap/compose.c index f64e8580288..032eff53ce8 100644 --- a/src/lib/eap/compose.c +++ b/src/lib/eap/compose.c @@ -312,7 +312,7 @@ rlm_rcode_t eap_start(request_t *request, rlm_eap_method_t const methods[], bool /* * 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(). */ /* diff --git a/src/lib/io/worker.c b/src/lib/io/worker.c index 5c5590ae3b8..2af781c8444 100644 --- a/src/lib/io/worker.c +++ b/src/lib/io/worker.c @@ -779,8 +779,8 @@ void worker_request_init(fr_worker_t *worker, request_t *request, fr_time_t now) * 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); diff --git a/src/lib/server/pair_server_tests.c b/src/lib/server/pair_server_tests.c index 07f28ec9fd8..1f5c8729ec4 100644 --- a/src/lib/server/pair_server_tests.c +++ b/src/lib/server/pair_server_tests.c @@ -88,10 +88,10 @@ static request_t *request_fake_alloc(void) */ 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; diff --git a/src/lib/server/request.c b/src/lib/server/request.c index 0dd20048c15..000d8995437 100644 --- a/src/lib/server/request.c +++ b/src/lib/server/request.c @@ -209,13 +209,13 @@ static inline CC_HINT(always_inline) int request_child_init(request_t *child, re * * 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; diff --git a/src/lib/server/tmpl_dcursor_tests.c b/src/lib/server/tmpl_dcursor_tests.c index 7018c56d7df..1dcc5f7ffc5 100644 --- a/src/lib/server/tmpl_dcursor_tests.c +++ b/src/lib/server/tmpl_dcursor_tests.c @@ -50,10 +50,10 @@ static request_t *request_fake_alloc(void) */ 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; diff --git a/src/lib/util/packet.c b/src/lib/util/packet.c index 510b8a04979..62da5ac0140 100644 --- a/src/lib/util/packet.c +++ b/src/lib/util/packet.c @@ -35,7 +35,7 @@ RCSID("$Id$") * - 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; @@ -60,13 +60,13 @@ fr_packet_t *fr_radius_packet_alloc(TALLOC_CTX *ctx, bool new_vector) * - 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; /* @@ -86,7 +86,7 @@ fr_packet_t *fr_radius_packet_alloc_reply(TALLOC_CTX *ctx, fr_packet_t *packet) /** 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; diff --git a/src/lib/util/packet.h b/src/lib/util/packet.h index f579a21d3f9..072759f7944 100644 --- a/src/lib/util/packet.h +++ b/src/lib/util/packet.h @@ -47,7 +47,7 @@ extern "C" { /* * 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 * @@ -76,9 +76,9 @@ typedef struct { 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 } diff --git a/src/listen/radius/proto_radius.c b/src/listen/radius/proto_radius.c index b58b84f73ac..a3a4de6d7bd 100644 --- a/src/listen/radius/proto_radius.c +++ b/src/listen/radius/proto_radius.c @@ -413,7 +413,7 @@ static ssize_t mod_encode(UNUSED void const *instance, request_t *request, uint8 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, diff --git a/src/listen/radius/proto_radius_tcp.c b/src/listen/radius/proto_radius_tcp.c index 48635a5dfff..4ae95a59e67 100644 --- a/src/listen/radius/proto_radius_tcp.c +++ b/src/listen/radius/proto_radius_tcp.c @@ -229,7 +229,7 @@ have_packet: * 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; diff --git a/src/listen/radius/proto_radius_udp.c b/src/listen/radius/proto_radius_udp.c index 870654d43e6..b0b9ac83409 100644 --- a/src/listen/radius/proto_radius_udp.c +++ b/src/listen/radius/proto_radius_udp.c @@ -190,7 +190,7 @@ static ssize_t mod_read(fr_listen_t *li, void **packet_ctx, fr_time_t *recv_time * 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; diff --git a/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.c b/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.c index 049ef12bf1d..e359c0860c7 100644 --- a/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.c +++ b/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.c @@ -124,7 +124,7 @@ static void eap_fast_send_error(fr_tls_session_t *tls_session, int error) 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; @@ -567,10 +567,10 @@ static rlm_rcode_t CC_HINT(nonnull) process_reply(UNUSED eap_session_t *eap_sess 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; @@ -703,7 +703,7 @@ static fr_radius_packet_code_t eap_fast_eap_payload(request_t *request, eap_sess 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; /* @@ -774,7 +774,7 @@ static fr_radius_packet_code_t eap_fast_eap_payload(request_t *request, eap_sess 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)]; @@ -797,7 +797,7 @@ static fr_radius_packet_code_t eap_fast_crypto_binding(request_t *request, UNUSE 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); @@ -809,7 +809,7 @@ static fr_radius_packet_code_t eap_fast_process_tlvs(request_t *request, eap_ses 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); @@ -881,7 +881,7 @@ static fr_radius_packet_code_t eap_fast_process_tlvs(request_t *request, eap_ses } 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; } @@ -895,9 +895,9 @@ static fr_radius_packet_code_t eap_fast_process_tlvs(request_t *request, eap_ses /* * 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; diff --git a/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.h b/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.h index d54b0f868ec..871de6730df 100644 --- a/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.h +++ b/src/modules/rlm_eap/types/rlm_eap_fast/eap_fast.h @@ -254,7 +254,7 @@ extern HIDDEN fr_dict_t const *dict_eap_fast; */ 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. diff --git a/src/modules/rlm_eap/types/rlm_eap_peap/peap.c b/src/modules/rlm_eap/types/rlm_eap_peap/peap.c index 3a83b95c1b6..713d384dabb 100644 --- a/src/modules/rlm_eap/types/rlm_eap_peap/peap.c +++ b/src/modules/rlm_eap/types/rlm_eap_peap/peap.c @@ -289,8 +289,8 @@ static rlm_rcode_t CC_HINT(nonnull) process_reply(eap_session_t *eap_session, fr * 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); } diff --git a/src/modules/rlm_eap/types/rlm_eap_ttls/eap_ttls.h b/src/modules/rlm_eap/types/rlm_eap_ttls/eap_ttls.h index 34cc7534c79..cf068564853 100644 --- a/src/modules/rlm_eap/types/rlm_eap_ttls/eap_ttls.h +++ b/src/modules/rlm_eap/types/rlm_eap_ttls/eap_ttls.h @@ -51,4 +51,4 @@ typedef struct { /* * 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); diff --git a/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c b/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c index 7f54bb0d2bd..789abbbe995 100644 --- a/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c +++ b/src/modules/rlm_eap/types/rlm_eap_ttls/ttls.c @@ -614,9 +614,9 @@ static rlm_rcode_t CC_HINT(nonnull) process_reply(NDEBUG_UNUSED eap_session_t *e /* * 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; @@ -723,7 +723,7 @@ fr_radius_packet_code_t eap_ttls_process(request_t *request, eap_session_t *eap_ */ 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"); diff --git a/src/modules/rlm_radius/rlm_radius.c b/src/modules/rlm_radius/rlm_radius.c index ba1ae364fc8..71097b51efa 100644 --- a/src/modules/rlm_radius/rlm_radius.c +++ b/src/modules/rlm_radius/rlm_radius.c @@ -418,7 +418,7 @@ static unlang_action_t CC_HINT(nonnull) mod_process(rlm_rcode_t *p_result, modul 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; } @@ -503,7 +503,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) */ 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; } @@ -520,7 +520,7 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx) } 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; } diff --git a/src/modules/rlm_radius/rlm_radius_udp.c b/src/modules/rlm_radius/rlm_radius_udp.c index 9f4cb8c9953..0e29eceb8f1 100644 --- a/src/modules/rlm_radius/rlm_radius_udp.c +++ b/src/modules/rlm_radius/rlm_radius_udp.c @@ -351,8 +351,8 @@ static void CC_HINT(nonnull) status_check_alloc(udp_handle_t *h) 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 @@ -411,7 +411,7 @@ static void CC_HINT(nonnull) status_check_alloc(udp_handle_t *h) 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)); @@ -638,7 +638,7 @@ static void conn_writable_status_check(fr_event_list_t *el, UNUSED int fd, UNUSE } 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: @@ -651,7 +651,7 @@ static void conn_writable_status_check(fr_event_list_t *el, UNUSED int fd, UNUSE 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); @@ -1175,7 +1175,7 @@ static decode_fail_t decode(TALLOC_CTX *ctx, fr_pair_list_t *reply, uint8_t *res 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; @@ -1772,7 +1772,7 @@ static void request_mux(fr_event_list_t *el, 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) { /* @@ -1793,7 +1793,7 @@ static void request_mux(fr_event_list_t *el, (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); @@ -2001,7 +2001,7 @@ static void request_mux_replicate(UNUSED fr_event_list_t *el, } 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; diff --git a/src/modules/rlm_stats/rlm_stats.c b/src/modules/rlm_stats/rlm_stats.c index e5ec8c57968..3a692fd8ed8 100644 --- a/src/modules/rlm_stats/rlm_stats.c +++ b/src/modules/rlm_stats/rlm_stats.c @@ -333,7 +333,7 @@ static unlang_action_t CC_HINT(nonnull) mod_stats(rlm_rcode_t *p_result, module_ 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; diff --git a/src/process/radius/base.c b/src/process/radius/base.c index 52a39d49749..73f865915b8 100644 --- a/src/process/radius/base.c +++ b/src/process/radius/base.c @@ -171,9 +171,9 @@ typedef struct { ///< 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 @@ -234,7 +234,7 @@ static void radius_packet_debug(request_t *request, fr_packet_t *packet, fr_pair #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), @@ -880,7 +880,7 @@ RESUME(protocol_error) 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 @@ -924,7 +924,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc 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); diff --git a/src/process/ttls/base.c b/src/process/ttls/base.c index a353b9389f5..2e444f9197d 100644 --- a/src/process/ttls/base.c +++ b/src/process/ttls/base.c @@ -158,10 +158,10 @@ typedef struct { 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 @@ -217,7 +217,7 @@ static void radius_packet_debug(request_t *request, fr_packet_t *packet, fr_pair #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), @@ -452,7 +452,7 @@ RESUME(auth_type) 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]; @@ -614,7 +614,7 @@ RESUME(protocol_error) 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 @@ -654,7 +654,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc 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; diff --git a/src/protocols/dhcpv4/dhcpv4.h b/src/protocols/dhcpv4/dhcpv4.h index cd584b95c8f..24d41959218 100644 --- a/src/protocols/dhcpv4/dhcpv4.h +++ b/src/protocols/dhcpv4/dhcpv4.h @@ -141,7 +141,7 @@ extern HIDDEN fr_dict_attr_t const *dhcp_option_82; fprintf(stdout, ## __VA_ARGS__); \ fprintf(stdout, "\n"); \ } \ - fr_radius_packet_free(&packet); \ + fr_packet_free(&packet); \ return NULL; \ } #endif diff --git a/src/protocols/dhcpv4/packet.c b/src/protocols/dhcpv4/packet.c index 28c98867de1..bb142c503ae 100644 --- a/src/protocols/dhcpv4/packet.c +++ b/src/protocols/dhcpv4/packet.c @@ -410,7 +410,7 @@ fr_packet_t *fr_dhcpv4_packet_alloc(uint8_t const *data, ssize_t data_len) 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; diff --git a/src/protocols/dhcpv4/raw.c b/src/protocols/dhcpv4/raw.c index f565e5dc52a..695592a9014 100644 --- a/src/protocols/dhcpv4/raw.c +++ b/src/protocols/dhcpv4/raw.c @@ -187,7 +187,7 @@ fr_packet_t *fr_dhcpv4_raw_packet_recv(int sockfd, struct sockaddr_ll *link_laye 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; @@ -196,7 +196,7 @@ fr_packet_t *fr_dhcpv4_raw_packet_recv(int sockfd, struct sockaddr_ll *link_laye 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; } @@ -305,13 +305,13 @@ fr_packet_t *fr_dhcpv4_raw_packet_recv(int sockfd, struct sockaddr_ll *link_laye 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; } diff --git a/src/protocols/radius/base.c b/src/protocols/radius/base.c index c926ef37315..498733d1e7a 100644 --- a/src/protocols/radius/base.c +++ b/src/protocols/radius/base.c @@ -91,7 +91,7 @@ fr_table_num_sorted_t const fr_radius_request_name_table[] = { }; 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", @@ -151,7 +151,7 @@ char const *fr_radius_packet_names[FR_RADIUS_CODE_MAX] = { /** 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, @@ -1028,7 +1028,7 @@ ssize_t fr_radius_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, 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; } @@ -1042,7 +1042,7 @@ ssize_t fr_radius_decode(TALLOC_CTX *ctx, fr_pair_list_t *out, 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; } } diff --git a/src/protocols/radius/client.c b/src/protocols/radius/client.c index 2dc174d2743..bb8b383870a 100644 --- a/src/protocols/radius/client.c +++ b/src/protocols/radius/client.c @@ -101,13 +101,13 @@ int fr_radius_client_fd_bio_write(fr_radius_client_fd_bio_t *my, UNUSED void *pa /* * 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; @@ -115,7 +115,7 @@ int fr_radius_client_fd_bio_write(fr_radius_client_fd_bio_t *my, UNUSED void *pa 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, @@ -193,7 +193,7 @@ int fr_radius_client_fd_bio_read(fr_bio_packet_t *bio, UNUSED void *packet_ctx, /* * 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; diff --git a/src/protocols/radius/decode.c b/src/protocols/radius/decode.c index 2566775f5b5..23a983bcc02 100644 --- a/src/protocols/radius/decode.c +++ b/src/protocols/radius/decode.c @@ -1461,7 +1461,7 @@ static ssize_t decode_tlv_trampoline(TALLOC_CTX *ctx, fr_pair_list_t *out, * * "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 @@ -1660,7 +1660,7 @@ ssize_t fr_radius_decode_pair_value(TALLOC_CTX *ctx, fr_pair_list_t *out, */ 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; @@ -1671,7 +1671,7 @@ ssize_t fr_radius_decode_pair_value(TALLOC_CTX *ctx, fr_pair_list_t *out, * 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, diff --git a/src/protocols/radius/defs.h b/src/protocols/radius/defs.h index 21d3ab5f27f..7bf1107fa69 100644 --- a/src/protocols/radius/defs.h +++ b/src/protocols/radius/defs.h @@ -52,7 +52,7 @@ typedef enum { 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 diff --git a/src/protocols/radius/list.c b/src/protocols/radius/list.c index 3d7a602f296..cb1e1514650 100644 --- a/src/protocols/radius/list.c +++ b/src/protocols/radius/list.c @@ -688,7 +688,7 @@ fr_packet_t *fr_packet_list_recv(fr_packet_list_t *pl, fd_set *set, uint32_t max 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; @@ -744,7 +744,7 @@ void fr_packet_header_log(fr_log_t const *log, fr_packet_t *packet, bool receive * * 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 @@ -752,7 +752,7 @@ void fr_packet_header_log(fr_log_t const *log, fr_packet_t *packet, bool receive #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), @@ -803,6 +803,6 @@ void fr_packet_log(fr_log_t const *log, fr_packet_t *packet, fr_pair_list_t *lis 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 } diff --git a/src/protocols/radius/packet.c b/src/protocols/radius/packet.c index a9a76c20925..cae9c7e8d24 100644 --- a/src/protocols/radius/packet.c +++ b/src/protocols/radius/packet.c @@ -49,7 +49,7 @@ typedef struct { /** 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; @@ -61,7 +61,7 @@ ssize_t fr_radius_packet_encode(fr_packet_t *packet, fr_pair_list_t *list, 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) { @@ -112,7 +112,7 @@ ssize_t fr_radius_packet_encode(fr_packet_t *packet, fr_pair_list_t *list, * - 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]; @@ -136,7 +136,7 @@ bool fr_radius_packet_ok(fr_packet_t *packet, uint32_t max_attributes, bool requ /** 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]; @@ -157,7 +157,7 @@ int fr_radius_packet_verify(fr_packet_t *packet, fr_packet_t *original, char con /** 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; @@ -208,7 +208,7 @@ static ssize_t rad_recvfrom(int sockfd, fr_packet_t *packet, int flags) /** 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; @@ -216,7 +216,7 @@ fr_packet_t *fr_radius_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t /* * 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; @@ -225,7 +225,7 @@ fr_packet_t *fr_radius_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t 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; } @@ -238,7 +238,7 @@ fr_packet_t *fr_radius_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t (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 @@ -252,7 +252,7 @@ fr_packet_t *fr_radius_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t */ 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; } @@ -264,15 +264,15 @@ fr_packet_t *fr_radius_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t */ 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; } @@ -294,7 +294,7 @@ fr_packet_t *fr_radius_packet_recv(TALLOC_CTX *ctx, int fd, int flags, uint32_t * * 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) { /* @@ -311,7 +311,7 @@ int fr_radius_packet_send(fr_packet_t *packet, fr_pair_list_t *list, /* * Encode the packet. */ - if (fr_radius_packet_encode(packet, list, original, secret) < 0) { + if (fr_packet_encode(packet, list, original, secret) < 0) { return -1; } @@ -319,7 +319,7 @@ int fr_radius_packet_send(fr_packet_t *packet, fr_pair_list_t *list, * 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; } @@ -352,7 +352,7 @@ int fr_radius_packet_send(fr_packet_t *packet, fr_pair_list_t *list, 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]; @@ -370,7 +370,7 @@ void _fr_radius_packet_log_hex(fr_log_t const *log, fr_packet_t const *packet, c } 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]); } diff --git a/src/protocols/radius/radius.h b/src/protocols/radius/radius.h index 6ab24ea3a14..f5b8f3b33d5 100644 --- a/src/protocols/radius/radius.h +++ b/src/protocols/radius/radius.h @@ -47,8 +47,8 @@ * 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) @@ -188,24 +188,24 @@ void fr_radius_global_free(void); /* * 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 diff --git a/src/protocols/radius/tcp.c b/src/protocols/radius/tcp.c index bbcff289a19..5a4f0eddf25 100644 --- a/src/protocols/radius/tcp.c +++ b/src/protocols/radius/tcp.c @@ -30,14 +30,14 @@ RCSID("$Id$") 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; } @@ -141,7 +141,7 @@ int fr_tcp_read_packet(fr_packet_t *packet, uint32_t max_attributes, bool requir /* * 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; } diff --git a/src/tests/util/radius1_test.c b/src/tests/util/radius1_test.c index b5deb63ed6e..8fd3b9be6e0 100644 --- a/src/tests/util/radius1_test.c +++ b/src/tests/util/radius1_test.c @@ -63,7 +63,7 @@ typedef struct { 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; @@ -98,8 +98,8 @@ static rlm_rcode_t test_process(UNUSED void const *instance, request_t *request, 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; @@ -114,8 +114,8 @@ static int test_decode(UNUSED void const *instance, request_t *request, uint8_t 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); @@ -189,7 +189,7 @@ static void *worker_thread(void *arg) 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); @@ -332,7 +332,7 @@ static void master_process(TALLOC_CTX *ctx) 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]); @@ -345,7 +345,7 @@ static void master_process(TALLOC_CTX *ctx) 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);