From: Alan T. DeKok Date: Mon, 1 May 2017 15:55:26 +0000 (-0400) Subject: rename fr_radius_foo to fr_radius_packet_foo X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0362e0725827ab2e605c0423635cfd84e7d49792;p=thirdparty%2Ffreeradius-server.git rename fr_radius_foo to fr_radius_packet_foo These functions take RADIUS_PACKETs as arguments. We want to create new functions which operate on raw buffers, so these need to be renamed. --- diff --git a/src/include/libradius.h b/src/include/libradius.h index 24ce9d85685..76b590b1f2c 100644 --- a/src/include/libradius.h +++ b/src/include/libradius.h @@ -120,7 +120,7 @@ typedef void (*sig_t)(int); /* * vector: Request authenticator from access-request packet * Put in there by rad_decode, and must be put in the - * response RADIUS_PACKET as well before calling fr_radius_send + * response RADIUS_PACKET as well before calling fr_radius_packet_send * * verified: Filled in by rad_decode for accounting-request packets * @@ -216,23 +216,23 @@ void fr_radius_ascend_secret(uint8_t *digest, uint8_t const *vector, char const void fr_radius_print_hex(RADIUS_PACKET const *packet); -int fr_radius_send(RADIUS_PACKET *, RADIUS_PACKET const *, char const *secret); +int fr_radius_packet_send(RADIUS_PACKET *, RADIUS_PACKET const *, char const *secret); ssize_t fr_radius_len(uint8_t const *data, size_t data_len); -bool fr_radius_ok(RADIUS_PACKET *packet, bool require_ma, decode_fail_t *reason); +bool fr_radius_packet_ok(RADIUS_PACKET *packet, bool require_ma, decode_fail_t *reason); RADIUS_PACKET *fr_radius_recv(TALLOC_CTX *ctx, int fd, int flags, bool require_ma); ssize_t fr_radius_recv_header(int sockfd, fr_ipaddr_t *src_ipaddr, uint16_t *src_port, unsigned int *code); -int fr_radius_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret); +int fr_radius_packet_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret); int fr_radius_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret); int fr_radius_encode(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret); -int fr_radius_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret); +int fr_radius_packet_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret); int fr_radius_digest_cmp(uint8_t const *a, uint8_t const *b, size_t length); diff --git a/src/lib/util/radius.c b/src/lib/util/radius.c index 016781e05c8..04d9e35f3b3 100644 --- a/src/lib/util/radius.c +++ b/src/lib/util/radius.c @@ -381,7 +381,7 @@ static ssize_t rad_recvfrom(int sockfd, RADIUS_PACKET *packet, int flags) /** Sign a previously encoded packet * */ -int fr_radius_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original, +int fr_radius_packet_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret) { radius_packet_t *hdr = (radius_packet_t *)packet->data; @@ -396,7 +396,7 @@ int fr_radius_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original, if (!packet->data || (packet->data_len < RADIUS_HDR_LEN) || (packet->offset < 0)) { - fr_strerror_printf("ERROR: You must call fr_radius_encode() before fr_radius_sign()"); + fr_strerror_printf("ERROR: You must call fr_radius_encode() before fr_radius_packet_sign()"); return -1; } @@ -523,7 +523,7 @@ int fr_radius_sign(RADIUS_PACKET *packet, RADIUS_PACKET const *original, * * Also attach reply attribute value pairs and any user message provided. */ -int fr_radius_send(RADIUS_PACKET *packet, RADIUS_PACKET const *original, +int fr_radius_packet_send(RADIUS_PACKET *packet, RADIUS_PACKET const *original, char const *secret) { /* @@ -548,7 +548,7 @@ int fr_radius_send(RADIUS_PACKET *packet, RADIUS_PACKET const *original, * Re-sign it, including updating the * Message-Authenticator. */ - if (fr_radius_sign(packet, original, secret) < 0) { + if (fr_radius_packet_sign(packet, original, secret) < 0) { return -1; } @@ -748,7 +748,7 @@ ssize_t fr_radius_len(uint8_t const *data, size_t data_len) * - True on success. * - False on failure. */ -bool fr_radius_ok(RADIUS_PACKET *packet, bool require_ma, decode_fail_t *reason) +bool fr_radius_packet_ok(RADIUS_PACKET *packet, bool require_ma, decode_fail_t *reason) { uint8_t *attr; size_t totallen; @@ -1124,7 +1124,7 @@ RADIUS_PACKET *fr_radius_recv(TALLOC_CTX *ctx, int fd, int flags, bool require_m /* * See if it's a well-formed RADIUS packet. */ - if (!fr_radius_ok(packet, require_ma, NULL)) { + if (!fr_radius_packet_ok(packet, require_ma, NULL)) { fr_radius_free(&packet); return NULL; } @@ -1155,7 +1155,7 @@ RADIUS_PACKET *fr_radius_recv(TALLOC_CTX *ctx, int fd, int flags, bool require_m /** Verify the Request/Response Authenticator (and Message-Authenticator if present) of a packet * */ -int fr_radius_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret) +int fr_radius_packet_verify(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const *secret) { uint8_t *ptr; int length; @@ -1556,7 +1556,7 @@ int fr_radius_decode(RADIUS_PACKET *packet, RADIUS_PACKET *original, char const /* * VSA's may not have been counted properly in - * fr_radius_ok() above, as it is hard to count + * fr_radius_packet_ok() above, as it is hard to count * then without using the dictionary. We * therefore enforce the limits here, too. */ diff --git a/src/lib/util/radius_decode.c b/src/lib/util/radius_decode.c index d145f9f2d76..b594e8d68d0 100644 --- a/src/lib/util/radius_decode.c +++ b/src/lib/util/radius_decode.c @@ -896,7 +896,7 @@ create_attrs: * * "length" is AT LEAST the length of this attribute, as we * expect the caller to have verified the data with - * fr_radius_ok(). "length" may be up to the length of the + * fr_radius_packet_ok(). "length" may be up to the length of the * packet. * * @return diff --git a/src/lib/util/tcp.c b/src/lib/util/tcp.c index 105987b4f3a..6d1b36e3f4f 100644 --- a/src/lib/util/tcp.c +++ b/src/lib/util/tcp.c @@ -140,7 +140,7 @@ int fr_tcp_read_packet(RADIUS_PACKET *packet, bool require_ma) /* * See if it's a well-formed RADIUS packet. */ - if (!fr_radius_ok(packet, require_ma, NULL)) { + if (!fr_radius_packet_ok(packet, require_ma, NULL)) { return -1; } diff --git a/src/main/listen.c b/src/main/listen.c index 3419a5b67ac..27eb7300faa 100644 --- a/src/main/listen.c +++ b/src/main/listen.c @@ -1657,7 +1657,7 @@ static int auth_socket_send(NDEBUG_UNUSED rad_listen_t *listener, REQUEST *reque } #endif - if (fr_radius_send(request->reply, request->packet, + if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) { RERROR("Failed sending reply: %s", fr_strerror()); @@ -1697,7 +1697,7 @@ static int acct_socket_send(NDEBUG_UNUSED rad_listen_t *listener, REQUEST *reque } # endif - if (fr_radius_send(request->reply, request->packet, + if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) { RERROR("Failed sending reply: %s", fr_strerror()); @@ -1719,7 +1719,7 @@ static int proxy_socket_send(NDEBUG_UNUSED rad_listen_t *listener, REQUEST *requ rad_assert(request->proxy->listener == listener); rad_assert(listener->send == proxy_socket_send); - if (fr_radius_send(request->proxy->packet, NULL, + if (fr_radius_packet_send(request->proxy->packet, NULL, request->proxy->home_server->secret) < 0) { RERROR("Failed sending proxied request: %s", fr_strerror()); @@ -2440,7 +2440,7 @@ static int client_socket_encode(UNUSED rad_listen_t *listener, REQUEST *request) request->reply->data_len, MAX_PACKET_LEN); } - if (fr_radius_sign(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) { RPERROR("Failed signing packet"); return -1; @@ -2456,7 +2456,7 @@ static int client_socket_decode(UNUSED rad_listen_t *listener, REQUEST *request) listen_socket_t *sock; #endif - if (fr_radius_verify(request->packet, NULL, + if (fr_radius_packet_verify(request->packet, NULL, request->client->secret) < 0) { return -1; } @@ -2499,7 +2499,7 @@ static int proxy_socket_encode(UNUSED rad_listen_t *listener, REQUEST *request) request->proxy->packet->data_len, MAX_PACKET_LEN); } - if (fr_radius_sign(request->proxy->packet, NULL, request->proxy->home_server->secret) < 0) { + if (fr_radius_packet_sign(request->proxy->packet, NULL, request->proxy->home_server->secret) < 0) { RPERROR("Failed signing proxied packet"); return -1; @@ -2512,7 +2512,7 @@ static int proxy_socket_encode(UNUSED rad_listen_t *listener, REQUEST *request) static int proxy_socket_decode(UNUSED rad_listen_t *listener, REQUEST *request) { /* - * fr_radius_verify is run in event.c, received_proxy_response() + * fr_radius_packet_verify is run in event.c, received_proxy_response() */ return fr_radius_decode(request->proxy->reply, request->proxy->packet, diff --git a/src/main/process.c b/src/main/process.c index 09bd82a4abb..a6d9826bbb6 100644 --- a/src/main/process.c +++ b/src/main/process.c @@ -2393,7 +2393,7 @@ int request_proxy_reply(RADIUS_PACKET *reply) * ignore it. This does the MD5 calculations in the * server core, but I guess we can fix that later. */ - if (!proxy->reply && (fr_radius_verify(reply, proxy->packet, proxy->home_server->secret) != 0)) { + if (!proxy->reply && (fr_radius_packet_verify(reply, proxy->packet, proxy->home_server->secret) != 0)) { RWDEBUG("Discarding invalid reply from host %s port %d - ID: %d: %s", inet_ntop(reply->src_ipaddr.af, &reply->src_ipaddr.ipaddr, buffer, sizeof(buffer)), reply->src_port, reply->id, fr_strerror()); diff --git a/src/main/radclient.c b/src/main/radclient.c index 2037621e5f7..cb24a70ef85 100644 --- a/src/main/radclient.c +++ b/src/main/radclient.c @@ -961,7 +961,7 @@ static int send_one_packet(rc_request_t *request) /* * Send the packet. */ - if (fr_radius_send(request->packet, NULL, secret) < 0) { + if (fr_radius_packet_send(request->packet, NULL, secret) < 0) { REDEBUG("Failed to send packet for ID %d", request->packet->id); deallocate_id(request); request->done = true; @@ -1055,7 +1055,7 @@ static int recv_one_packet(int wait_time) * Fails the signature validation: not a real reply. * FIXME: Silently drop it and listen for another packet. */ - if (fr_radius_verify(reply, request->packet, secret) < 0) { + if (fr_radius_packet_verify(reply, request->packet, secret) < 0) { REDEBUG("Reply verification failed"); stats.lost++; goto packet_done; /* shared secret is incorrect */ diff --git a/src/main/radsniff.c b/src/main/radsniff.c index fbd482e4935..f65d4e767ef 100644 --- a/src/main/radsniff.c +++ b/src/main/radsniff.c @@ -1330,7 +1330,7 @@ static void rs_packet_process(uint64_t count, rs_event_t *event, struct pcap_pkt current->src_port = ntohs(udp->src); current->dst_port = ntohs(udp->dst); - if (!fr_radius_ok(current, false, &reason)) { + if (!fr_radius_packet_ok(current, false, &reason)) { REDEBUG("%s", fr_strerror()); if (conf->event_flags & RS_ERROR) { rs_packet_print(NULL, count, RS_ERROR, event->in, current, &elapsed, NULL, false, false); @@ -1375,7 +1375,7 @@ 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_verify(current, original->expect, conf->radius_secret); + ret = fr_radius_packet_verify(current, original->expect, conf->radius_secret); fr_log_fp = log_fp; if (ret != 0) { REDEBUG("Failed verifying packet ID %d", current->id); @@ -1386,7 +1386,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_ok( does checks to verify the packet is actually valid. + * fr_radius_packet_ok( does checks to verify the packet is actually valid. */ if (conf->decode_attrs) { int ret; @@ -1492,7 +1492,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_ok( does checks to verify the packet is actually valid. + * fr_radius_packet_ok( does checks to verify the packet is actually valid. */ if (conf->decode_attrs) { int ret; diff --git a/src/main/radsnmp.c b/src/main/radsnmp.c index 6482145581f..b58143464f7 100644 --- a/src/main/radsnmp.c +++ b/src/main/radsnmp.c @@ -759,7 +759,7 @@ static int radsnmp_send_recv(radsnmp_conf_t *conf, int fd) ERROR("Failed encoding request: %s", fr_strerror()); return EXIT_FAILURE; } - if (fr_radius_sign(request, NULL, conf->secret) < 0) { + if (fr_radius_packet_sign(request, NULL, conf->secret) < 0) { ERROR("Failed signing request: %s", fr_strerror()); return EXIT_FAILURE; } diff --git a/src/main/tls_listen.c b/src/main/tls_listen.c index b855a6358b1..cf56930a517 100644 --- a/src/main/tls_listen.c +++ b/src/main/tls_listen.c @@ -251,7 +251,7 @@ static int tls_socket_recv(rad_listen_t *listener) packet->vps = NULL; pthread_mutex_unlock(&sock->mutex); - if (!fr_radius_ok(packet, 0, NULL)) { + if (!fr_radius_packet_ok(packet, 0, NULL)) { if (DEBUG_ENABLED) ERROR("Receive - %s", fr_strerror()); DEBUG("Closing TLS socket from client"); pthread_mutex_lock(&sock->mutex); @@ -408,7 +408,7 @@ int dual_tls_send(rad_listen_t *listener, REQUEST *request) /* * Sign the packet. */ - if (fr_radius_sign(request->reply, request->packet, + if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) { RPERROR("Failed signing packet"); return 0; diff --git a/src/modules/proto_radius/proto_radius_acct.c b/src/modules/proto_radius/proto_radius_acct.c index f667c5d816c..56072d34506 100644 --- a/src/modules/proto_radius/proto_radius_acct.c +++ b/src/modules/proto_radius/proto_radius_acct.c @@ -214,12 +214,12 @@ static void acct_running(REQUEST *request, fr_state_action_t action) goto done; } - if (fr_radius_sign(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) { RDEBUG("Failed signing RADIUS reply: %s", fr_strerror()); goto done; } - if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) { RDEBUG("Failed sending RADIUS reply: %s", fr_strerror()); } /* FALL-THROUGH */ diff --git a/src/modules/proto_radius/proto_radius_auth.c b/src/modules/proto_radius/proto_radius_auth.c index cea439358d9..8605ab3daf2 100644 --- a/src/modules/proto_radius/proto_radius_auth.c +++ b/src/modules/proto_radius/proto_radius_auth.c @@ -169,7 +169,7 @@ static void auth_cleanup_delay(REQUEST *request, fr_state_action_t action) if (request->reply->code != 0) { gettimeofday(&request->reply->timestamp, NULL); - if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) { RDEBUG("Failed sending RADIUS reply: %s", fr_strerror()); goto done; } @@ -243,7 +243,7 @@ static void auth_reject_delay(REQUEST *request, fr_state_action_t action) if (RDEBUG_ENABLED) common_packet_debug(request, request->reply, false); gettimeofday(&request->reply->timestamp, NULL); - if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) { RDEBUG("Failed sending RADIUS reply: %s", fr_strerror()); goto done; } @@ -771,7 +771,7 @@ static void auth_running(REQUEST *request, fr_state_action_t action) goto stop_processing; } - if (fr_radius_sign(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) { RDEBUG("Failed signing RADIUS reply: %s", fr_strerror()); /* @@ -844,7 +844,7 @@ static void auth_running(REQUEST *request, fr_state_action_t action) /* else fall through to sending the response immediately. */ } - if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) { RDEBUG("Failed sending RADIUS reply: %s", fr_strerror()); goto done; } diff --git a/src/modules/proto_radius/proto_radius_coa.c b/src/modules/proto_radius/proto_radius_coa.c index 15dafca0355..3d6104bf2da 100644 --- a/src/modules/proto_radius/proto_radius_coa.c +++ b/src/modules/proto_radius/proto_radius_coa.c @@ -253,12 +253,12 @@ static void coa_running(REQUEST *request, fr_state_action_t action) goto done; } - if (fr_radius_sign(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) { RDEBUG("Failed signing RADIUS reply: %s", fr_strerror()); goto done; } - if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) { RDEBUG("Failed sending RADIUS reply: %s", fr_strerror()); } /* FALL-THROUGH */ diff --git a/src/modules/proto_radius/proto_radius_status.c b/src/modules/proto_radius/proto_radius_status.c index aa87d9a70a0..49e88444806 100644 --- a/src/modules/proto_radius/proto_radius_status.c +++ b/src/modules/proto_radius/proto_radius_status.c @@ -214,12 +214,12 @@ static void status_running(REQUEST *request, fr_state_action_t action) goto done; } - if (fr_radius_sign(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_sign(request->reply, request->packet, request->client->secret) < 0) { RDEBUG("Failed signing RADIUS reply: %s", fr_strerror()); goto done; } - if (fr_radius_send(request->reply, request->packet, request->client->secret) < 0) { + if (fr_radius_packet_send(request->reply, request->packet, request->client->secret) < 0) { RDEBUG("Failed sending RADIUS reply: %s", fr_strerror()); } /* FALL-THROUGH */ diff --git a/src/modules/rlm_radius_client/rlm_radius_client.c b/src/modules/rlm_radius_client/rlm_radius_client.c index 4d9e55c370f..55fe9a205ba 100644 --- a/src/modules/rlm_radius_client/rlm_radius_client.c +++ b/src/modules/rlm_radius_client/rlm_radius_client.c @@ -150,7 +150,7 @@ static void mod_event_fd(UNUSED fr_event_list_t *el, int fd, void *ctx) /* * If the reply fails the signature validation, it's not a real reply. */ - if (fr_radius_verify(reply, ccr->packet, ccr->inst->home_server->secret) < 0) { + if (fr_radius_packet_verify(reply, ccr->packet, ccr->inst->home_server->secret) < 0) { REDEBUG("Reply verification failed for home server %s", ccr->inst->home_server->name); fr_radius_free(&reply); return; @@ -280,7 +280,7 @@ static void mod_action_dup(REQUEST *request, void *instance, UNUSED void *thread buffer, sizeof(buffer)), packet->dst_port, packet->id); - fr_radius_send(packet, NULL, inst->home_server->secret); + fr_radius_packet_send(packet, NULL, inst->home_server->secret); packet->count++; } @@ -417,7 +417,7 @@ static rlm_rcode_t mod_wait_for_reply(REQUEST *request, rlm_radius_client_instan buffer, sizeof(buffer)), packet->dst_port, packet->id); - (void) fr_radius_send(packet, NULL, inst->home_server->secret); + (void) fr_radius_packet_send(packet, NULL, inst->home_server->secret); packet->count++; timeout = ccr->inst->home_server->response_window; diff --git a/src/modules/rlm_replicate/rlm_replicate.c b/src/modules/rlm_replicate/rlm_replicate.c index f5775d2c26e..23f055d80ac 100644 --- a/src/modules/rlm_replicate/rlm_replicate.c +++ b/src/modules/rlm_replicate/rlm_replicate.c @@ -213,7 +213,7 @@ static rlm_rcode_t replicate_packet(UNUSED void const *instance, REQUEST *reques * Encode, sign and then send the packet. */ RDEBUG("Replicating %s list to Realm \"%s\"", fr_int2str(pair_lists, list, ""), realm->name); - if (fr_radius_send(packet, NULL, home->secret) < 0) { + if (fr_radius_packet_send(packet, NULL, home->secret) < 0) { RPEDEBUG("Failed replicating packet"); rcode = RLM_MODULE_FAIL; goto done;