Radcli library 2.0.0
A simple radius library -- legacy API reference
Loading...
Searching...
No Matches
dict.c
1/*
2 * Copyright (C) 1995,1996,1997 Lars Fenneberg
3 *
4 * Copyright 1992 Livingston Enterprises, Inc.
5 *
6 * Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
7 * and Merit Network, Inc. All Rights Reserved
8 *
9 * See the file COPYRIGHT for the respective terms and conditions.
10 * If the file is missing contact me at lf@elemental.net
11 * and I'll send you a copy.
12 *
13 */
14
21
22/* This file is a compatibility shim over lib/dict2.c, the canonical,
23 * hash-indexed dictionary implementation. It exists only because
24 * DICT_ATTR/DICT_VALUE/DICT_VENDOR are frozen public ABI returned by
25 * pointer: every rc_dict_*() lookup/construction function below resolves
26 * through dict2.h and then hands back a lazily-materialized, cached shadow
27 * struct (radcli_dict_*_to_legacy()) matching what a linear-scanned
28 * next-chain used to return directly. rc_read_dictionary()/
29 * rc_read_dictionary_from_buffer()/rc_dict_free() -- the only three
30 * functions any external caller checked (including ocserv) actually uses --
31 * are real code in lib/dict2.c, not shimmed here. Every symbol below is
32 * declared in include/radcli/radcli.h; radcli2.h's dictionary-lookup API
33 * (radcli_dict_lookup() and friends) has no such ABI constraint and lives
34 * in lib/dict2.c entirely, alongside its real implementation. New internal
35 * code should call lib/dict2.h's functions directly instead of the shim
36 * below. See doc/requirements/dict.md.
37 */
38
39#include <config.h>
40#include <includes.h>
41#include <radcli/radcli.h>
42#include "dict2.h"
43
59DICT_ATTR *rc_dict_addattr(rc_handle *rh, char const * namestr, uint32_t value, int type, uint32_t vendorspec)
60{
61 return radcli_dict_attr_to_legacy(radcli_dict_attr_add(rh, namestr, value, type, vendorspec));
62}
63
78DICT_VALUE *rc_dict_addval(rc_handle *rh, char const * attrstr, char const * namestr, uint32_t value)
79{
80 return radcli_dict_value_to_legacy(radcli_dict_value_add(rh, attrstr, namestr, value));
81}
82
96DICT_VENDOR *rc_dict_addvend(rc_handle *rh, char const * namestr, uint32_t vendorspec)
97{
98 return radcli_dict_vendor_to_legacy(radcli_dict_vendor_add(rh, namestr, vendorspec));
99}
100
107DICT_ATTR *rc_dict_getattr(rc_handle const *rh, uint64_t attribute)
108{
109 return radcli_dict_attr_to_legacy(radcli_dict_attr_by_id(rh, attribute));
110}
111
119DICT_ATTR *rc_dict_findattr(rc_handle const *rh, char const *attrname)
120{
121 return radcli_dict_attr_to_legacy(radcli_dict_attr_by_name(rh, attrname));
122}
123
130DICT_VALUE *rc_dict_findval(rc_handle const *rh, char const *valname)
131{
132 return radcli_dict_value_to_legacy(radcli_dict_value_by_name(rh, valname));
133}
134
141DICT_VENDOR *rc_dict_findvend(rc_handle const *rh, char const *vendorname)
142{
143 return radcli_dict_vendor_to_legacy(radcli_dict_vendor_by_name(rh, vendorname));
144}
145
152DICT_VENDOR *rc_dict_getvend (rc_handle const *rh, uint32_t vendorspec)
153{
154 return radcli_dict_vendor_to_legacy(radcli_dict_vendor_by_pec(rh, vendorspec));
155}
156
164DICT_VALUE *rc_dict_getval(rc_handle const *rh, uint32_t value, char const *attrname)
165{
166 return radcli_dict_value_to_legacy(radcli_dict_value_by_attr(rh, attrname, value));
167}
168
DICT_VALUE * rc_dict_getval(rc_handle const *rh, uint32_t value, char const *attrname)
Get DICT_VALUE based on attribute name and integer value number.
Definition dict.c:164
DICT_ATTR * rc_dict_addattr(rc_handle *rh, char const *namestr, uint32_t value, int type, uint32_t vendorspec)
Add attribute to dictionary.
Definition dict.c:59
DICT_VENDOR * rc_dict_findvend(rc_handle const *rh, char const *vendorname)
Lookup a DICT_VENDOR by its name.
Definition dict.c:141
DICT_VALUE * rc_dict_findval(rc_handle const *rh, char const *valname)
Lookup a DICT_VALUE by its name.
Definition dict.c:130
DICT_VENDOR * rc_dict_getvend(rc_handle const *rh, uint32_t vendorspec)
Lookup a DICT_VENDOR by its IANA number.
Definition dict.c:152
DICT_ATTR * rc_dict_getattr(rc_handle const *rh, uint64_t attribute)
Lookup a DICT_ATTR by attribute number.
Definition dict.c:107
DICT_VALUE * rc_dict_addval(rc_handle *rh, char const *attrstr, char const *namestr, uint32_t value)
Add value to dictionary.
Definition dict.c:78
DICT_VENDOR * rc_dict_addvend(rc_handle *rh, char const *namestr, uint32_t vendorspec)
Add vendor to dictionary.
Definition dict.c:96
DICT_ATTR * rc_dict_findattr(rc_handle const *rh, char const *attrname)
Lookup a DICT_ATTR by its name.
Definition dict.c:119