/src/freeradius-server/src/protocols/vmps/base.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * This program is free software; you can redistribute it and/or modify |
3 | | * it under the terms of the GNU General Public License as published by |
4 | | * the Free Software Foundation; either version 2 of the License, or |
5 | | * (at your option) any later version. |
6 | | * |
7 | | * This program is distributed in the hope that it will be useful, |
8 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | | * GNU General Public License for more details. |
11 | | * |
12 | | * You should have received a copy of the GNU General Public License |
13 | | * along with this program; if not, write to the Free Software |
14 | | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
15 | | */ |
16 | | |
17 | | /** |
18 | | * $Id: c96015252024d63ede39e6f4468301e571e55b09 $ |
19 | | * |
20 | | * @file src/protocols/vmps/vmps.h |
21 | | * @brief Structures and prototypes for Cisco's VLAN Query Protocol |
22 | | * |
23 | | * @copyright 2018 The FreeRADIUS server project |
24 | | */ |
25 | | |
26 | | RCSID("$Id: c96015252024d63ede39e6f4468301e571e55b09 $") |
27 | | |
28 | | #include <freeradius-devel/util/pair.h> |
29 | | #include "vmps.h" |
30 | | #include "attrs.h" |
31 | | |
32 | | static uint32_t instance_count = 0; |
33 | | |
34 | | fr_dict_t const *dict_vmps; |
35 | | |
36 | | extern fr_dict_autoload_t libfreeradius_vmps[]; |
37 | | fr_dict_autoload_t libfreeradius_vmps[] = { |
38 | | { .out = &dict_vmps, .proto = "vmps" }, |
39 | | { NULL } |
40 | | }; |
41 | | |
42 | | fr_dict_attr_t const *attr_error_code; |
43 | | fr_dict_attr_t const *attr_packet_type; |
44 | | fr_dict_attr_t const *attr_sequence_number; |
45 | | |
46 | | extern fr_dict_attr_autoload_t libfreeradius_vmps_dict_attr[]; |
47 | | fr_dict_attr_autoload_t libfreeradius_vmps_dict_attr[] = { |
48 | | { .out = &attr_error_code, .name = "Error-Code", .type = FR_TYPE_UINT8, .dict = &dict_vmps }, |
49 | | { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_vmps }, |
50 | | { .out = &attr_sequence_number, .name = "Sequence-Number", .type = FR_TYPE_UINT32, .dict = &dict_vmps }, |
51 | | { NULL } |
52 | | }; |
53 | | |
54 | | |
55 | | int fr_vmps_init(void) |
56 | 300 | { |
57 | 300 | if (instance_count > 0) { |
58 | 0 | instance_count++; |
59 | 0 | return 0; |
60 | 0 | } |
61 | | |
62 | 300 | if (fr_dict_autoload(libfreeradius_vmps) < 0) { |
63 | 0 | fr_strerror_const_push("Failed loading the 'vmps' dictionary"); |
64 | 0 | return -1; |
65 | 0 | } |
66 | | |
67 | 300 | if (fr_dict_attr_autoload(libfreeradius_vmps_dict_attr) < 0) { |
68 | 0 | fr_strerror_const("Failed loading the 'vmps' attributes"); |
69 | 0 | fr_dict_autofree(libfreeradius_vmps); |
70 | 0 | return -1; |
71 | 0 | } |
72 | | |
73 | 300 | instance_count++; |
74 | | |
75 | 300 | return 0; |
76 | 300 | } |
77 | | |
78 | | void fr_vmps_free(void) |
79 | 300 | { |
80 | 300 | if (--instance_count > 0) return; |
81 | | |
82 | 300 | fr_dict_autofree(libfreeradius_vmps); |
83 | 300 | } |