]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Autoload proto_vmps_all attributes
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 28 May 2018 05:09:25 +0000 (11:09 +0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 28 May 2018 05:09:25 +0000 (11:09 +0600)
share/dictionary
src/modules/proto_vmps/proto_vmps_all.c

index b0fdbf15e9b86bfd07b885dcd51598907e538067..d16201ac848f79fd0a28b8740a474f43aa6ef468 100644 (file)
@@ -177,7 +177,6 @@ $INCLUDE dictionary.compatible
 $INCLUDE dictionary.cosine
 $INCLUDE dictionary.dante
 $INCLUDE dictionary.dellemc
-$INCLUDE dictionary.dhcpv4
 $INCLUDE dictionary.dlink
 $INCLUDE dictionary.digium
 $INCLUDE dictionary.dragonwave
@@ -302,6 +301,8 @@ $INCLUDE dictionary.zyxel
 #  This should be auto-loaded in the future.
 #
 $INCLUDE dictionary.arp
+$INCLUDE dictionary.vqp
+$INCLUDE dictionary.dhcpv4
 
 #
 #      And finally the server internal attributes.
index b7430bcffb7f96b54c9686f9c5c3911fe8dd4ab0..35f8bb4edf6af8a9d72787ffb48ff00dd57b48b1 100644 (file)
 #include <freeradius-devel/rad_assert.h>
 #include "vqp.h"
 
+static fr_dict_t *dict_vmps;
+
+extern fr_dict_autoload_t proto_vmps_all_dict[];
+fr_dict_autoload_t proto_vmps_all_dict[] = {
+       { .out = &dict_vmps, .proto = "vmps" },
+       { NULL }
+};
+
+static fr_dict_attr_t const *attr_vmps_packet_type;
+
+extern fr_dict_attr_autoload_t proto_vmps_all_dict_attr[];
+fr_dict_attr_autoload_t proto_vmps_all_dict_attr[] = {
+       { .out = &attr_vmps_packet_type, .name = "VMPS-Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_vmps },
+       { NULL }
+};
+
 static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request, UNUSED fr_io_action_t action)
 {
-       rlm_rcode_t rcode;
-       CONF_SECTION *unlang;
-       fr_dict_enum_t const *dv;
-       fr_dict_attr_t const *da = NULL;
+       rlm_rcode_t             rcode;
+       CONF_SECTION            *unlang;
+       fr_dict_enum_t const    *dv;
 
        REQUEST_VERIFY(request);
 
        switch (request->request_state) {
        case REQUEST_INIT:
-               log_request(L_DBG, L_DBG_LVL_1, request, "Received %s ID %08x",
-                              fr_vmps_codes[request->packet->code], request->packet->id);
+               RDEBUG("Received %s ID %08x", fr_vmps_codes[request->packet->code], request->packet->id);
                log_request_proto_pair_list(L_DBG_LVL_1, request, request->packet->vps, "");
 
                request->component = "vmps";
 
-               da = fr_dict_attr_by_num(NULL, 0, FR_VMPS_PACKET_TYPE);
-               rad_assert(da != NULL);
-               dv = fr_dict_enum_by_value(da, fr_box_uint32(request->packet->code));
+               dv = fr_dict_enum_by_value(attr_vmps_packet_type, fr_box_uint32(request->packet->code));
                if (!dv) {
                        REDEBUG("Failed to find value for &request:VMPS-Packet-Type");
                        return FR_IO_FAIL;
@@ -100,10 +112,7 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request,
                        break;
                }
 
-               if (!da) da = fr_dict_attr_by_num(NULL, 0, FR_VMPS_PACKET_TYPE);
-               rad_assert(da != NULL);
-
-               dv = fr_dict_enum_by_value(da, fr_box_uint32(request->reply->code));
+               dv = fr_dict_enum_by_value(attr_vmps_packet_type, fr_box_uint32(request->reply->code));
                unlang = NULL;
                if (dv) unlang = cf_section_find(request->server_cs, "send", dv->alias);
 
@@ -139,15 +148,14 @@ static fr_io_final_t mod_process(UNUSED void const *instance, REQUEST *request,
                         *      the NAK section.
                         */
                        if (request->reply->code != FR_VMPS_PACKET_TYPE_VALUE_DO_NOT_RESPOND) {
-                               if (!da) da = fr_dict_attr_by_num(NULL, 0, FR_VMPS_PACKET_TYPE);
-                               rad_assert(da != NULL);
-
-                               dv = fr_dict_enum_by_value(da, fr_box_uint32(request->reply->code));
+                               dv = fr_dict_enum_by_value(attr_vmps_packet_type,
+                                                          fr_box_uint32(request->reply->code));
                                RWDEBUG("Failed running 'send %s', trying 'send Do-Not-Respond'.", dv->alias);
 
                                request->reply->code = FR_VMPS_PACKET_TYPE_VALUE_DO_NOT_RESPOND;
 
-                               dv = fr_dict_enum_by_value(da, fr_box_uint32(request->reply->code));
+                               dv = fr_dict_enum_by_value(attr_vmps_packet_type,
+                                                          fr_box_uint32(request->reply->code));
                                unlang = NULL;
                                if (!dv) goto send_reply;