]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move to new naming scheme
authorAlan T. DeKok <aland@freeradius.org>
Mon, 1 Mar 2021 20:42:17 +0000 (15:42 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 1 Mar 2021 20:43:31 +0000 (15:43 -0500)
src/listen/vmps/proto_vmps.c
src/process/vmps/all.mk
src/process/vmps/base.c [moved from src/process/vmps/proto_vmps_process.c with 93% similarity]
src/process/vmps/proto_vmps_dynamic_client.c [deleted file]
src/process/vmps/proto_vmps_dynamic_client.mk [deleted file]
src/process/vmps/proto_vmps_process.mk [deleted file]

index 8753845e91e18514c4f53c77cd6ea40a557917cc..d1c382f8e1d616ebf4bd4c7feb4e463bb8a3456d 100644 (file)
@@ -309,42 +309,13 @@ static ssize_t mod_encode(void const *instance, request_t *request, uint8_t *buf
        return data_len;
 }
 
-static void mod_entry_point_set(void const *instance, request_t *request)
+static void mod_entry_point_set(UNUSED void const *instance, request_t *request)
 {
-       proto_vmps_t const      *inst = talloc_get_type_abort_const(instance, proto_vmps_t);
-       dl_module_inst_t                *type_submodule;
-       fr_io_track_t           *track = request->async->packet_ctx;
+       fr_assert(request->server_cs != NULL);
 
-       fr_assert(request->packet->code != 0);
-       fr_assert(request->packet->code <= FR_VQP_MAX_CODE);
-
-       request->server_cs = inst->io.server_cs;
-
-       /*
-        *      'track' can be NULL when there's no network listener.
-        */
-       if (inst->io.app_io && (track->dynamic == request->async->recv_time)) {
-               fr_app_worker_t const   *app_process;
-
-               app_process = (fr_app_worker_t const *) inst->io.dynamic_submodule->module->common;
-
-               request->async->process = app_process->entry_point;
-               request->async->process_inst = inst->io.dynamic_submodule;
-               track->dynamic = 0;
-               return;
-       }
-
-       type_submodule = inst->type_submodule_by_code[request->packet->code];
-       if (!type_submodule) {
-               REDEBUG("No module available to handle packet code %i", request->packet->code);
-               return;
-       }
-
-       request->async->process = ((fr_app_worker_t const *)type_submodule->module->common)->entry_point;
-       request->async->process_inst = type_submodule->data;
+       virtual_server_entry_point_set(request);
 }
 
-
 static int mod_priority_set(void const *instance, uint8_t const *buffer, UNUSED size_t buflen)
 {
        proto_vmps_t const *inst = talloc_get_type_abort_const(instance, proto_vmps_t);
index 8465d422c5db91a6dadc3a0f6ba7033e7fe2a208..a40d3fa4ac7098641517519e04682772d43eb139 100644 (file)
@@ -1 +1,9 @@
-SUBMAKEFILES := proto_vmps_process.mk proto_vmps_dynamic_client.mk
+TARGETNAME     := process_vmps
+
+ifneq "$(TARGETNAME)" ""
+TARGET         := $(TARGETNAME).a
+endif
+
+SOURCES                := base.c
+
+TGT_PREREQS    := libfreeradius-util.a libfreeradius-vmps.a
similarity index 93%
rename from src/process/vmps/proto_vmps_process.c
rename to src/process/vmps/base.c
index 0baa047353ba255c42af5900d459ecd02f525835..f98561bdefa2708b2193219239ad9aca969fee97 100644 (file)
@@ -16,7 +16,7 @@
 
 /**
  * $Id$
- * @file proto_vmps/proto_vmps_process.c
+ * @file src/process/vmps/base.c
  * @brief VMPS processing.
  *
  * @copyright 2018 The Freeradius server project.
@@ -24,7 +24,7 @@
  */
 #include <freeradius-devel/io/application.h>
 #include <freeradius-devel/server/protocol.h>
-#include <freeradius-devel/server/module.h>
+#include <freeradius-devel/server/process.h>
 #include <freeradius-devel/unlang/base.h>
 #include <freeradius-devel/util/dict.h>
 #include <freeradius-devel/util/debug.h>
 
 static fr_dict_t const *dict_vmps;
 
-extern fr_dict_autoload_t proto_vmps_process_dict[];
-fr_dict_autoload_t proto_vmps_process_dict[] = {
+extern fr_dict_autoload_t process_vmps_dict[];
+fr_dict_autoload_t process_vmps_dict[] = {
        { .out = &dict_vmps, .proto = "vmps" },
        { NULL }
 };
 
 static fr_dict_attr_t const *attr_packet_type;
 
-extern fr_dict_attr_autoload_t proto_vmps_process_dict_attr[];
-fr_dict_attr_autoload_t proto_vmps_process_dict_attr[] = {
+extern fr_dict_attr_autoload_t process_vmps_dict_attr[];
+fr_dict_attr_autoload_t process_vmps_dict_attr[] = {
        { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_vmps },
        { NULL }
 };
@@ -236,10 +236,11 @@ static const virtual_server_compile_t compile_list[] = {
 };
 
 
-extern fr_app_worker_t proto_vmps_process;
-fr_app_worker_t proto_vmps_process = {
+extern fr_process_module_t process_vmps;
+fr_process_module_t process_vmps = {
        .magic          = RLM_MODULE_INIT,
-       .name           = "vmps_process",
-       .entry_point    = mod_process,
+       .name           = "process_vmps",
+       .process        = mod_process,
        .compile_list   = compile_list,
+       .dict           = &dict_vmps,
 };
diff --git a/src/process/vmps/proto_vmps_dynamic_client.c b/src/process/vmps/proto_vmps_dynamic_client.c
deleted file mode 100644 (file)
index c6d65c5..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- *   This program is free software; you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or
- *   (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/**
- * $Id$
- * @file proto_vmps_dynamic_client.c
- * @brief VMPS dynamic clients
- *
- * @copyright 2018 The FreeRADIUS server project.
- * @copyright 2018 Alan DeKok (aland@deployingradius.com)
- */
-#include <freeradius-devel/io/application.h>
-#include <freeradius-devel/server/protocol.h>
-#include <freeradius-devel/server/module.h>
-#include <freeradius-devel/unlang/base.h>
-#include <freeradius-devel/util/dict.h>
-#include <freeradius-devel/util/debug.h>
-#include <freeradius-devel/vmps/vmps.h>
-
-static fr_dict_t const *dict_freeradius;
-static fr_dict_t const *dict_vmps;
-
-extern fr_dict_autoload_t proto_vmps_dynamic_client_dict[];
-fr_dict_autoload_t proto_vmps_dynamic_client_dict[] = {
-       { .out = &dict_freeradius, .proto = "freeradius" },
-       { .out = &dict_vmps, .proto = "vmps" },
-       { NULL }
-};
-
-static fr_dict_attr_t const *attr_freeradius_client_ip_address;
-static fr_dict_attr_t const *attr_freeradius_client_ip_prefix;
-static fr_dict_attr_t const *attr_freeradius_client_ipv6_address;
-static fr_dict_attr_t const *attr_freeradius_client_ipv6_prefix;
-
-extern fr_dict_attr_autoload_t proto_vmps_dynamic_client_dict_attr[];
-fr_dict_attr_autoload_t proto_vmps_dynamic_client_dict_attr[] = {
-       { .out = &attr_freeradius_client_ip_address, .name = "FreeRADIUS-Client-IP-Address", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_freeradius },
-       { .out = &attr_freeradius_client_ip_prefix, .name = "FreeRADIUS-Client-IP-Prefix", .type = FR_TYPE_IPV4_PREFIX, .dict = &dict_freeradius },
-       { .out = &attr_freeradius_client_ipv6_address, .name = "FreeRADIUS-Client-IPv6-Address", .type = FR_TYPE_IPV6_ADDR, .dict = &dict_freeradius },
-       { .out = &attr_freeradius_client_ipv6_prefix, .name = "FreeRADIUS-Client-IPv6-Prefix", .type = FR_TYPE_IPV6_PREFIX, .dict = &dict_freeradius },
-       { NULL }
-};
-
-#define CLIENT_ADD     (1)
-#define CLIENT_NAK     (257)
-
-static unlang_action_t mod_process(rlm_rcode_t *p_result, UNUSED module_ctx_t const *mctx, request_t *request)
-{
-       rlm_rcode_t rcode;
-       CONF_SECTION *unlang;
-
-       REQUEST_VERIFY(request);
-
-       switch (request->request_state) {
-       case REQUEST_INIT:
-               RDEBUG("Received %s ID %i", fr_vmps_codes[request->packet->code], request->packet->id);
-               log_request_proto_pair_list(L_DBG_LVL_1, request, NULL, &request->request_pairs, NULL);
-
-               request->component = "vmps";
-
-               unlang = cf_section_find(request->server_cs, "new", "client");
-               if (!unlang) {
-                       RWDEBUG("Failed to find 'new client' section");
-                       request->reply->code = CLIENT_NAK;
-                       goto send_reply;
-               }
-
-               RDEBUG("Running 'new client' from file %s", cf_filename(unlang));
-               if (unlang_interpret_push_section(request, unlang, RLM_MODULE_NOOP, UNLANG_TOP_FRAME) < 0) {
-                       RETURN_MODULE_FAIL;
-               }
-
-               request->request_state = REQUEST_RECV;
-               FALL_THROUGH;
-
-       case REQUEST_RECV:
-               rcode = unlang_interpret(request);
-
-               if (request->master_state == REQUEST_STOP_PROCESSING) {
-                       *p_result = RLM_MODULE_HANDLED;
-                       return UNLANG_ACTION_STOP_PROCESSING;
-               }
-
-               if (rcode == RLM_MODULE_YIELD) RETURN_MODULE_YIELD;
-
-               switch (rcode) {
-               case RLM_MODULE_OK:
-               case RLM_MODULE_UPDATED:
-                       request->reply->code = CLIENT_ADD;
-                       break;
-
-               case RLM_MODULE_FAIL:
-               case RLM_MODULE_HANDLED:
-                       request->reply->code = 0; /* don't reply */
-                       break;
-
-               default:
-               case RLM_MODULE_REJECT:
-                       request->reply->code = CLIENT_NAK;
-                       break;
-               }
-
-               unlang = cf_section_find(request->server_cs, "add", "client");
-               if (!unlang) goto send_reply;
-
-       rerun_nak:
-               RDEBUG("Running '%s client' from file %s", cf_section_name1(unlang), cf_filename(unlang));
-               if (unlang_interpret_push_section(request, unlang, RLM_MODULE_NOOP, UNLANG_TOP_FRAME) < 0) {
-                       RETURN_MODULE_FAIL;
-               }
-
-               request->request_state = REQUEST_SEND;
-               FALL_THROUGH;
-
-       case REQUEST_SEND:
-               rcode = unlang_interpret(request);
-
-               if (request->master_state == REQUEST_STOP_PROCESSING) {
-                       *p_result = RLM_MODULE_HANDLED;
-                       return UNLANG_ACTION_STOP_PROCESSING;
-               }
-
-               if (rcode == RLM_MODULE_YIELD) RETURN_MODULE_YIELD;
-
-               switch (rcode) {
-               case RLM_MODULE_NOOP:
-               case RLM_MODULE_OK:
-               case RLM_MODULE_UPDATED:
-               case RLM_MODULE_HANDLED:
-                       /* reply is already set */
-                       break;
-
-               default:
-                       /*
-                        *      If we over-ride an ACK with a NAK, run
-                        *      the NAK section.
-                        */
-                       if (request->reply->code != 257) {
-                               RWDEBUG("Failed running 'add client', trying 'deny client'.");
-
-                       deny:
-                               request->reply->code = CLIENT_NAK;
-
-                               unlang = cf_section_find(request->server_cs, "deny", "client");
-                               if (unlang) goto rerun_nak;
-
-                               RWDEBUG("Not running 'deny client' section as it does not exist");
-                       }
-                       break;
-               }
-
-               if (request->reply->code == CLIENT_ADD) {
-                       fr_pair_t *vp;
-
-                       vp = fr_pair_find_by_da(&request->control_pairs, attr_freeradius_client_ip_address);
-                       if (!vp) fr_pair_find_by_da(&request->control_pairs, attr_freeradius_client_ipv6_address);
-                       if (!vp) fr_pair_find_by_da(&request->control_pairs, attr_freeradius_client_ip_prefix);
-                       if (!vp) fr_pair_find_by_da(&request->control_pairs, attr_freeradius_client_ipv6_prefix);
-                       if (!vp) {
-                               ERROR("The 'control' list MUST contain a FreeRADIUS-Client.. IP address attribute");
-                               goto deny;
-                       }
-               }
-
-       send_reply:
-               /*
-                *      This is an internally generated request.  Don't print IP addresses.
-                */
-               if (request->reply->code == CLIENT_ADD) {
-                       RDEBUG("Adding client");
-               } else {
-                       RDEBUG("Denying client");
-               }
-               if (RDEBUG_ENABLED) log_request_pair_list(L_DBG_LVL_1, request, NULL, &request->reply_pairs, NULL);
-               break;
-
-       default:
-               RETURN_MODULE_FAIL;
-       }
-
-       RETURN_MODULE_OK;
-}
-
-
-static const virtual_server_compile_t compile_list[] = {
-       {
-               .name = "new",
-               .name2 = "client",
-               .component = MOD_AUTHORIZE,
-       },
-       {
-               .name = "add",
-               .name2 = "client",
-               .component = MOD_POST_AUTH,
-       },
-       {
-               .name = "deny",
-               .name2 = "client",
-               .component = MOD_POST_AUTH,
-       },
-
-       COMPILE_TERMINATOR
-};
-
-extern fr_app_worker_t proto_vmps_dynamic_client;
-fr_app_worker_t proto_vmps_dynamic_client = {
-       .magic          = RLM_MODULE_INIT,
-       .name           = "vmps_dynamic_client",
-       .entry_point    = mod_process,
-       .compile_list   = compile_list,
-};
diff --git a/src/process/vmps/proto_vmps_dynamic_client.mk b/src/process/vmps/proto_vmps_dynamic_client.mk
deleted file mode 100644 (file)
index aa19b4d..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGETNAME     := proto_vmps_dynamic_client
-
-ifneq "$(TARGETNAME)" ""
-TARGET         := $(TARGETNAME).a
-endif
-
-SOURCES                := proto_vmps_dynamic_client.c
-
-TGT_PREREQS    := libfreeradius-util.a libfreeradius-radius.a libfreeradius-vmps.a
diff --git a/src/process/vmps/proto_vmps_process.mk b/src/process/vmps/proto_vmps_process.mk
deleted file mode 100644 (file)
index f5632e8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-TARGETNAME     := proto_vmps_process
-
-ifneq "$(TARGETNAME)" ""
-TARGET         := $(TARGETNAME).a
-endif
-
-SOURCES                := proto_vmps_process.c
-
-TGT_PREREQS    := libfreeradius-util.a libfreeradius-radius.a libfreeradius-vmps.a