Coverage Report

Created: 2026-03-31 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/freeradius-server/src/protocols/vmps/base.c
Line
Count
Source
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: 9221ca87e767e9c18f73c39d73ac9c86662d1be3 $
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: 9221ca87e767e9c18f73c39d73ac9c86662d1be3 $")
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
  DICT_AUTOLOAD_TERMINATOR
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
  DICT_AUTOLOAD_TERMINATOR
52
};
53
54
55
int fr_vmps_global_init(void)
56
0
{
57
0
  if (instance_count > 0) {
58
0
    instance_count++;
59
0
    return 0;
60
0
  }
61
62
0
  instance_count++;
63
64
0
  if (fr_dict_autoload(libfreeradius_vmps) < 0) {
65
0
  fail:
66
0
    instance_count--;
67
0
    return -1;
68
0
  }
69
70
0
  if (fr_dict_attr_autoload(libfreeradius_vmps_dict_attr) < 0) {
71
0
    fr_dict_autofree(libfreeradius_vmps);
72
0
    goto fail;
73
0
  }
74
75
76
0
  return 0;
77
0
}
78
79
void fr_vmps_global_free(void)
80
0
{
81
0
  fr_assert(instance_count > 0);
82
83
0
  if (--instance_count > 0) return;
84
85
0
  fr_dict_autofree(libfreeradius_vmps);
86
0
}