The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
types.c
Go to the documentation of this file.
1/*
2 * This program is 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 (at
5 * 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: 5bf76a7d2a8ae0625c902933db99414bc9e17078 $
19 * @file lib/eap/types.h
20 * @brief EAP type resolution
21 *
22 * @copyright 2019 The FreeRADIUS server project
23 */
24#include <freeradius-devel/util/value.h>
25
26#include "attrs.h"
27#include "types.h"
28
29/** Return an EAP-Type for a particular name
30 *
31 * Converts a name into an IANA EAP type.
32 *
33 * @param name to convert.
34 * @return
35 * - IANA EAP type.
36 * - #FR_EAP_METHOD_INVALID if the name doesn't match any known types.
37 */
39{
41
43 if (!dv) return FR_EAP_METHOD_INVALID;
44
45 if (dv->value->vb_uint32 >= FR_EAP_METHOD_MAX) return FR_EAP_METHOD_INVALID;
46
47 return dv->value->vb_uint32;
48}
49
50/** Return an EAP-name for a particular type
51 *
52 * Resolve
53 */
54char const *eap_type2name(eap_type_t method)
55{
57
59 if (dv) return dv->name;
60
61 return "unknown";
62}
fr_dict_enum_value_t * fr_dict_enum_by_value(fr_dict_attr_t const *da, fr_value_box_t const *value)
Lookup the structure representing an enum value in a fr_dict_attr_t.
Definition dict_util.c:3349
fr_value_box_t const * value
Enum value (what name maps to).
Definition dict.h:231
fr_dict_enum_value_t * fr_dict_enum_by_name(fr_dict_attr_t const *da, char const *name, ssize_t len)
Definition dict_util.c:3395
char const * name
Enum name.
Definition dict.h:228
Value of an enumerated attribute.
Definition dict.h:227
eap_type_t eap_name2type(char const *name)
Return an EAP-Type for a particular name.
Definition types.c:38
char const * eap_type2name(eap_type_t method)
Return an EAP-name for a particular type.
Definition types.c:54
enum eap_type eap_type_t
@ FR_EAP_METHOD_INVALID
Definition types.h:45
@ FR_EAP_METHOD_MAX
Definition types.h:102
HIDDEN fr_dict_attr_t const * attr_eap_type
Definition base.c:92
VQP attributes.
static char const * name
Types of values contained within an fr_value_box_t.
#define fr_box_uint32(_val)
Definition value.h:312