From: Alan T. DeKok Date: Thu, 18 Apr 2019 17:28:34 +0000 (-0400) Subject: make VMPS use the new auto-compiler for virtual_server_compile_t X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3caf957b86b8fde9c34de60334ec36a4e2015cd2;p=thirdparty%2Ffreeradius-server.git make VMPS use the new auto-compiler for virtual_server_compile_t Now that the "namespace" is cached and restored correctly. --- diff --git a/share/dictionary/vqp/dictionary b/share/dictionary/vqp/dictionary deleted file mode 100644 index 0c61a05e2e8..00000000000 --- a/share/dictionary/vqp/dictionary +++ /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 index 0f2d7507520..00000000000 --- a/share/dictionary/vqp/dictionary.vqp +++ /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 diff --git a/src/include/all.mk b/src/include/all.mk index cbd84398750..fa887dfec91 100644 --- a/src/include/all.mk +++ b/src/include/all.mk @@ -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 */" diff --git a/src/modules/proto_vmps/proto_vmps.c b/src/modules/proto_vmps/proto_vmps.c index d2d4cf2f120..2717fdaf670 100644 --- a/src/modules/proto_vmps/proto_vmps.c +++ b/src/modules/proto_vmps/proto_vmps.c @@ -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; } diff --git a/src/modules/proto_vmps/proto_vmps_all.c b/src/modules/proto_vmps/proto_vmps_all.c index ac530d1e9a3..ae436e991b4 100644 --- a/src/modules/proto_vmps/proto_vmps_all.c +++ b/src/modules/proto_vmps/proto_vmps_all.c @@ -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, }; diff --git a/src/protocols/vqp/attrs.h b/src/protocols/vqp/attrs.h index e6f14068e39..9190734c7ce 100644 --- a/src/protocols/vqp/attrs.h +++ b/src/protocols/vqp/attrs.h @@ -26,7 +26,7 @@ RCSIDH(vqp_attrs_h, "$Id$") #include -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; diff --git a/src/protocols/vqp/base.c b/src/protocols/vqp/base.c index 4e40c338334..ff5f819efa7 100644 --- a/src/protocols/vqp/base.c +++ b/src/protocols/vqp/base.c @@ -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; } diff --git a/src/protocols/vqp/vqp.c b/src/protocols/vqp/vqp.c index 90d10646b0f..ec4a78fedf8 100644 --- a/src/protocols/vqp/vqp.c +++ b/src/protocols/vqp/vqp.c @@ -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); /*