]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
make VMPS use the new auto-compiler for virtual_server_compile_t
authorAlan T. DeKok <aland@freeradius.org>
Thu, 18 Apr 2019 17:28:34 +0000 (13:28 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 18 Apr 2019 17:28:34 +0000 (13:28 -0400)
Now that the "namespace" is cached and restored correctly.

share/dictionary/vqp/dictionary [deleted file]
share/dictionary/vqp/dictionary.vqp [deleted file]
src/include/all.mk
src/modules/proto_vmps/proto_vmps.c
src/modules/proto_vmps/proto_vmps_all.c
src/protocols/vqp/attrs.h
src/protocols/vqp/base.c
src/protocols/vqp/vqp.c

diff --git a/share/dictionary/vqp/dictionary b/share/dictionary/vqp/dictionary
deleted file mode 100644 (file)
index 0c61a05..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# -*- text -*-
-# Copyright (C) 2019 The FreeRADIUS Server project and contributors
-# This work is licensed under CC-BY version 4.0 https://creativecommons.org/licenses/by/4.0
-# Version $Id$
-#
-#      The FreeRADIUS Vendor-Specific dictionary for SNMP operations.
-#
-# Version:     $Id$
-#
-
-PROTOCOL       VQP     6               format=2
-BEGIN-PROTOCOL VQP
-
-$INCLUDE dictionary.vqp
-
-END-PROTOCOL VQP
diff --git a/share/dictionary/vqp/dictionary.vqp b/share/dictionary/vqp/dictionary.vqp
deleted file mode 100644 (file)
index 0f2d750..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-# -*- text -*-
-# Copyright (C) 2019 The FreeRADIUS Server project and contributors
-# This work is licensed under CC-BY version 4.0 https://creativecommons.org/licenses/by/4.0
-# Version $Id$
-##############################################################################
-#
-#      Cisco's VLAN Query Protocol
-#
-#      The default destination port is 1589.
-#
-#      $Id$
-#
-##############################################################################
-
-#
-#  VQP / VMPS internal attributes for the packet header
-#
-ATTRIBUTE      Packet-Type                             1       integer internal
-ATTRIBUTE      Error-Code                              2       integer internal
-ATTRIBUTE      Sequence-Number                         3       integer internal
-
-#
-#  VQP / VMPS Attributes
-#
-ATTRIBUTE      Client-IPv4-Address                     0x0c01  ipaddr
-ATTRIBUTE      Port-Name                               0x0c02  string
-ATTRIBUTE      VLAN-Name                               0x0c03  string
-
-# VTP domain
-ATTRIBUTE      Domain-Name                             0x0c04  string
-
-# Encapsulates an Ethernet frame...
-ATTRIBUTE      Ethernet-Frame                          0x0c05  octets
-ATTRIBUTE      MAC-Address                             0x0c06  ether
-ATTRIBUTE      Unknown                                 0x0c07  octets
-ATTRIBUTE      Cookie                                  0x0c08  ether
-
-#
-#      VQP integer mappings
-#
-
-VALUE  Packet-Type                     Join-Request            1
-VALUE  Packet-Type                     Join-Response           2
-VALUE  Packet-Type                     Reconfirm-Request       3
-VALUE  Packet-Type                     Reconfirm-Response      4
-
-VALUE  Packet-Type                     Do-Not-Respond          256
-
-VALUE  Error-Code                      No-Error                0
-VALUE  Error-Code                      Wrong-Version           1
-VALUE  Error-Code                      Insufficient-Resources  2
-VALUE  Error-Code                      Deny                    3
-VALUE  Error-Code                      Shutdown                4
-VALUE  Error-Code                      Wrong-Mgmt-Domain       5
index cbd84398750922c6c2855d998ff8a0208029c594..fa887dfec91d2d578b7e563cd0e54556da113404 100644 (file)
@@ -47,7 +47,7 @@ DICT += $(wildcard $(addsuffix /dictionary.freeradius*,$(addprefix share/diction
 DICT += $(wildcard $(addsuffix /dictionary,$(addprefix share/dictionary/,$(PROTOCOLS))))
 
 # Add in protocol specific dictionaries (should be done in proto_* modules?)
-DICT += share/dictionary/vqp/dictionary.vqp
+DICT += share/dictionary/vmps/dictionary.vmps
 
 NORMALIZE      := tr -- '[:lower:]/+.-' '[:upper:]____' | sed 's/241_//;'
 HEADER         := "/* AUTO_GENERATED FILE.  DO NOT EDIT */"
index d2d4cf2f12034f22a03f8d1e030f12d407b6f71f..2717fdaf6700a947fb38ea78674a0292be9db33d 100644 (file)
@@ -83,7 +83,7 @@ static fr_dict_t *dict_vmps;
 
 extern fr_dict_autoload_t proto_vmps_dict[];
 fr_dict_autoload_t proto_vmps_dict[] = {
-       { .out = &dict_vmps, .proto = "vqp" },
+       { .out = &dict_vmps, .proto = "vmps" },
        { NULL }
 };
 
@@ -570,7 +570,10 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf)
 
 static int mod_load(void)
 {
-       if (fr_vqp_init() < 0) return -1;
+       if (fr_vqp_init() < 0) {
+               ERROR("Failed initializing the VMPS dictionaries: %s", fr_strerror());
+               return -1;
+       }
 
        return 0;
 }
index ac530d1e9a337552bb587bda428e62cb517cf389..ae436e991b473da79c3b5a2ca64d0be5986be133 100644 (file)
@@ -36,7 +36,7 @@ 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 = "vqp" },
+       { .out = &dict_vmps, .proto = "vmps" },
        { NULL }
 };
 
@@ -213,27 +213,11 @@ static virtual_server_compile_t compile_list[] = {
        COMPILE_TERMINATOR
 };
 
-static int mod_instantiate(UNUSED void *instance, CONF_SECTION *process_app_cs)
-{
-       CONF_SECTION            *listen_cs = cf_item_to_section(cf_parent(process_app_cs));
-       CONF_SECTION            *server_cs;
-       vp_tmpl_rules_t         parse_rules;
-
-       memset(&parse_rules, 0, sizeof(parse_rules));
-       parse_rules.dict_def = dict_vmps;
-
-       rad_assert(listen_cs);
-
-       server_cs = cf_item_to_section(cf_parent(listen_cs));
-       rad_assert(strcmp(cf_section_name1(server_cs), "server") == 0);
-
-       return virtual_server_compile_sections(server_cs, compile_list, &parse_rules);
-}
 
 extern fr_app_worker_t proto_vmps_all;
 fr_app_worker_t proto_vmps_all = {
        .magic          = RLM_MODULE_INIT,
        .name           = "vmps_all",
-       .instantiate    = mod_instantiate,
        .entry_point    = mod_process,
+       .compile_list   = compile_list,
 };
index e6f14068e39bc6dfe72bd2c2c2341bd4ed4373f3..9190734c7cec1322a000fec2856f8f9bebd9049c 100644 (file)
@@ -26,7 +26,7 @@ RCSIDH(vqp_attrs_h, "$Id$")
 
 #include <freeradius-devel/util/dict.h>
 
-extern fr_dict_t *dict_vqp;
+extern fr_dict_t *dict_vmps;
 
 extern fr_dict_attr_t const *attr_error_code;
 extern fr_dict_attr_t const *attr_packet_type;
index 4e40c338334cba5a49fc04c2b001c8b3731131c6..ff5f819efa727607ae7784fa6bab441268bdaf1f 100644 (file)
@@ -31,11 +31,11 @@ RCSID("$Id$")
 
 static int instance_count = 0;
 
-fr_dict_t *dict_vqp;
+fr_dict_t *dict_vmps;
 
 extern fr_dict_autoload_t libfreeradius_vqp[];
 fr_dict_autoload_t libfreeradius_vqp[] = {
-       { .out = &dict_vqp, .proto = "vqp" },
+       { .out = &dict_vmps, .proto = "vmps" },
        { NULL }
 };
 
@@ -45,9 +45,9 @@ fr_dict_attr_t const *attr_sequence_number;
 
 extern fr_dict_attr_autoload_t libfreeradius_vqp_dict_attr[];
 fr_dict_attr_autoload_t libfreeradius_vqp_dict_attr[] = {
-       { .out = &attr_error_code, .name = "Error-Code", .type = FR_TYPE_UINT32, .dict = &dict_vqp },
-       { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_vqp },
-       { .out = &attr_sequence_number, .name = "Sequence-Number", .type = FR_TYPE_UINT32, .dict = &dict_vqp },
+       { .out = &attr_error_code, .name = "Error-Code", .type = FR_TYPE_UINT32, .dict = &dict_vmps },
+       { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_vmps },
+       { .out = &attr_sequence_number, .name = "Sequence-Number", .type = FR_TYPE_UINT32, .dict = &dict_vmps },
        { NULL }
 };
 
@@ -59,8 +59,13 @@ int fr_vqp_init(void)
                return 0;
        }
 
-       if (fr_dict_autoload(libfreeradius_vqp) < 0) return -1;
+       if (fr_dict_autoload(libfreeradius_vqp) < 0) {
+               fr_strerror_printf("Failed loading the 'vmps' dictionary - %s", fr_strerror());
+               return -1;
+       }
+
        if (fr_dict_attr_autoload(libfreeradius_vqp_dict_attr) < 0) {
+               fr_strerror_printf("Failed loading the 'vmps' attributes");
                fr_dict_autofree(libfreeradius_vqp);
                return -1;
        }
index 90d10646b0f2659f77c57854e79d590681d7aab5..ec4a78fedf823d4850f7591eca5df0d35331f0be 100644 (file)
@@ -328,7 +328,7 @@ int vqp_decode(RADIUS_PACKET *packet)
                /*
                 *      Create the VP.
                 */
-               vp = fr_pair_afrom_child_num(packet, fr_dict_root(dict_vqp), attr);
+               vp = fr_pair_afrom_child_num(packet, fr_dict_root(dict_vmps), attr);
                if (!vp) {
                        fr_strerror_printf("No memory");
 
@@ -571,7 +571,7 @@ int vqp_encode(RADIUS_PACKET *packet, RADIUS_PACKET *original)
        for (i = 0; i < VQP_MAX_ATTRIBUTES; i++) {
                if (!contents[code][i]) break;
 
-               vps[i] = fr_pair_find_by_child_num(packet->vps, fr_dict_root(dict_vqp),
+               vps[i] = fr_pair_find_by_child_num(packet->vps, fr_dict_root(dict_vmps),
                                                   contents[code][i], TAG_ANY);
 
                /*