Radcli library 2.0.0
A simple radius library -- new API reference
Loading...
Searching...
No Matches
Dictionary

Looking up an attribute's definition – name, wire type, OID, and named VALUEs – from the dictionary a radcli_ctx has loaded. More...

Macros

#define RADCLI_OID_MAX_COMPONENTS   5

Typedefs

typedef enum radcli_attr_type radcli_attr_type
typedef struct radcli_attr_def_st radcli_attr_def

Enumerations

enum  radcli_attr_type {
  RADCLI_TYPE_STRING = 0 , RADCLI_TYPE_INTEGER = 1 , RADCLI_TYPE_IPADDR = 2 , RADCLI_TYPE_DATE = 3 ,
  RADCLI_TYPE_IPV6ADDR = 4 , RADCLI_TYPE_IPV6PREFIX = 5 , RADCLI_TYPE_INTEGER64 = 6 , RADCLI_TYPE_IPV4PREFIX = 7 ,
  RADCLI_TYPE_TEXT = 8 , RADCLI_TYPE_IFID = 9
}

Functions

const radcli_attr_def * radcli_dict_lookup (const radcli_ctx *ctx, const char *name)
 Look up a dictionary attribute by its canonical name.
const radcli_attr_def * radcli_dict_lookup_num (const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor)
 Look up a dictionary attribute by its legacy numeric ID and vendor.
const radcli_attr_def * radcli_dict_lookup_oid (const radcli_ctx *ctx, const char *oid)
 Look up a dictionary attribute by RFC 6929 §2.7 OID notation.
const char * radcli_attr_def_name (const radcli_attr_def *def)
 Return an attribute definition's canonical name.
radcli_attr_type radcli_attr_def_type (const radcli_attr_def *def)
 Return an attribute definition's wire type.
int radcli_attr_def_oid (const radcli_attr_def *def, char *buf, size_t buflen)
 Render an attribute definition's RFC 6929 §2.7 OID notation.
int radcli_dict_lookup_value (const radcli_ctx *ctx, const radcli_attr_def *def, const char *name, uint32_t *out)
 Resolve a dictionary VALUE by name, scoped to one attribute.

Detailed Description

Looking up an attribute's definition – name, wire type, OID, and named VALUEs – from the dictionary a radcli_ctx has loaded.

Macro Definition Documentation

◆ RADCLI_OID_MAX_COMPONENTS

#define RADCLI_OID_MAX_COMPONENTS   5

Definition at line 488 of file dict2.c.

Typedef Documentation

◆ radcli_attr_def

typedef struct radcli_attr_def_st radcli_attr_def

Definition at line 253 of file radcli2.h.

Enumeration Type Documentation

◆ radcli_attr_type

Attribute types recognised by the new API.

Independent of radcli.h's rc_attr_type: it grows on its own schedule rather than forcing the legacy enum, and therefore the legacy PW_TYPE_MAX, to change – RADCLI_TYPE_INTEGER64 is the first payoff of that split: the dictionary can carry an attribute no VALUE_PAIR-based caller could ever have been compiled against.

RADCLI_TYPE_INTEGER64 implements the "integer64" data type of RFC 8044 (Data Types for RADIUS, SS3.3): an 8-octet unsigned integer in network byte order. MIP6-Feature-Vector (etc/dictionary attribute 124, RFC 5447 SS4.2.5) is, per IANA, the only standard attribute of this type.

Every enumerator below documents the radcli_avp_add_*()/radcli_avp_get_*() pair that reads and writes it, so a caller never has to read lib/avp.c to find the right function for a given radcli_attr_def's type.

Enumerator
RADCLI_TYPE_STRING 

A printable string of opaque octets. Read/written with radcli_avp_add_str()/ radcli_avp_get_cstr() (NUL-terminated text access) or, for the raw bytes with no NUL/UTF-8 checks, radcli_avp_add_bytes()/ radcli_avp_get_bytes().

RADCLI_TYPE_INTEGER 

A 32-bit integer, host byte order. Read/written with radcli_avp_add_uint32()/ radcli_avp_get_uint32().

RADCLI_TYPE_IPADDR 

An IPv4 address in host byte order. Written with radcli_avp_add_ip4() (takes a struct in_addr) or radcli_avp_add_uint32() (takes the address as a host-byte-order uint32_t); read back with radcli_avp_get_uint32() – there is no separate ip4 getter.

RADCLI_TYPE_DATE 

Seconds since epoch, as a 32-bit integer. Implements RFC 8044 SS3.5's "time" data type; the dictionary may spell an attribute of this type "date" or "time". Read/written with radcli_avp_add_uint32()/ radcli_avp_get_uint32(), same as RADCLI_TYPE_INTEGER.

RADCLI_TYPE_IPV6ADDR 

A 128-bit IPv6 address. Read/written with radcli_avp_add_ip6()/ radcli_avp_get_ip6(), passing prefix 0.

RADCLI_TYPE_IPV6PREFIX 

An IPv6 prefix (RFC 3162 wire format). Read/written with radcli_avp_add_ip6()/ radcli_avp_get_ip6(), same pair as RADCLI_TYPE_IPV6ADDR but with a meaningful prefix length.

RADCLI_TYPE_INTEGER64 

A 64-bit integer, network byte order on the wire. Read/written with radcli_avp_add_uint64()/ radcli_avp_get_uint64() – the same pair RADCLI_TYPE_IFID uses below, since both are 8 raw octets.

RADCLI_TYPE_IPV4PREFIX 

An IPv4 prefix (RFC 8044 SS3.9 wire format). Read/written with radcli_avp_add_ip4prefix()/ radcli_avp_get_ip4prefix().

RADCLI_TYPE_TEXT 

UTF-8 human-readable text (RFC 8044 SS3.1), distinct from RADCLI_TYPE_STRING's opaque octets. radcli_avp_add_str() accepts both RADCLI_TYPE_STRING and RADCLI_TYPE_TEXT attributes, validating UTF-8 only for the latter; radcli_avp_get_cstr() likewise validates UTF-8 only for RADCLI_TYPE_TEXT, in addition to its embedded-NUL check for every type.

RADCLI_TYPE_IFID 

An 8-octet IPv6 interface identifier in network byte order (RFC 8044 SS3.7's "ifid" data type; the dictionary spells it "ifid" – e.g. Framed-Interface-Id, etc/dictionary attribute 96, RFC 3162 SS2.3). Not a numeric quantity, but identical in wire shape to RADCLI_TYPE_INTEGER64 (8 raw octets), so it is read/written with the very same radcli_avp_add_uint64()/ radcli_avp_get_uint64() pair rather than a dedicated ifid-specific function.

Definition at line 173 of file radcli2.h.

Function Documentation

◆ radcli_attr_def_name()

const char * radcli_attr_def_name ( const radcli_attr_def * def)

Return an attribute definition's canonical name.

Parameters
defan attribute definition from radcli_dict_lookup() or a sibling.
Returns
the name; never NULL for a non-NULL def.

Definition at line 615 of file dict2.c.

◆ radcli_attr_def_oid()

int radcli_attr_def_oid ( const radcli_attr_def * def,
char * buf,
size_t buflen )

Render an attribute definition's RFC 6929 §2.7 OID notation.

Parameters
defan attribute definition from radcli_dict_lookup() or a sibling.
bufdestination buffer; may be NULL if buflen is 0.
buflensize of buf in bytes.
Returns
the number of characters the OID text would occupy, excluding the terminating null, as with snprintf(); negative if def is NULL.

Definition at line 638 of file dict2.c.

◆ radcli_attr_def_type()

radcli_attr_type radcli_attr_def_type ( const radcli_attr_def * def)

Return an attribute definition's wire type.

Parameters
defan attribute definition from radcli_dict_lookup() or a sibling.

Definition at line 624 of file dict2.c.

◆ radcli_dict_lookup()

const radcli_attr_def * radcli_dict_lookup ( const radcli_ctx * ctx,
const char * name )

Look up a dictionary attribute by its canonical name.

Case-insensitive, matching the legacy dictionary's own lookup rules.

Parameters
ctxa context with a dictionary loaded.
namethe attribute name, e.g. "Framed-IP-Address".
Returns
the attribute definition, or NULL if no such attribute is loaded.

Definition at line 542 of file dict2.c.

◆ radcli_dict_lookup_num()

const radcli_attr_def * radcli_dict_lookup_num ( const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor )

Look up a dictionary attribute by its legacy numeric ID and vendor.

Bridges callers that still hold a radcli.h PW_* constant; equivalent to radcli_dict_lookup_oid() with the same attribute expressed as an OID.

Parameters
ctxa context with a dictionary loaded.
attridthe attribute ID (a PW_* constant, or a vendor type ID when vendor is non-zero).
vendorthe vendor PEN, or 0 for a standard attribute.
Returns
the attribute definition, or NULL if no such attribute is loaded. Non-NULL for any RFC 2865/2866/2869 attribute ID on a context that has the built-in dictionary loaded – every radcli_ctx_read_config() context, and every radcli_ctx_new() context unless created with RADCLI_CTX_NO_BUILTIN_DICT.

Definition at line 564 of file dict2.c.

◆ radcli_dict_lookup_oid()

const radcli_attr_def * radcli_dict_lookup_oid ( const radcli_ctx * ctx,
const char * oid )

Look up a dictionary attribute by RFC 6929 §2.7 OID notation.

Accepts a standard attribute as a single component ("1" for User-Name) or a vendor-specific attribute as "26.<vendor-id>.<vendor-type>" (e.g. "26.311.11"). Longer forms naming an RFC 6929 extended, long-extended, or TLV-nested attribute parse without error but currently match nothing: the bundled dictionary carries no RFC 6929 extended/long-extended/TLV-nested attributes yet.

Parameters
ctxa context with a dictionary loaded.
oidthe dot-separated OID text.
Returns
the attribute definition, or NULL if the OID is malformed or matches no loaded attribute.

Definition at line 586 of file dict2.c.

◆ radcli_dict_lookup_value()

int radcli_dict_lookup_value ( const radcli_ctx * ctx,
const radcli_attr_def * def,
const char * name,
uint32_t * out )

Resolve a dictionary VALUE by name, scoped to one attribute.

The runtime, VALUE-name counterpart to radcli_dict_lookup(): covers a vendor-specific or supplemental-dictionary VALUE with no compiled-in constant in radcli-defs.h (which only covers RFC 2865/2866/2869 standard VALUEs). A VALUE name is only meaningful together with the attribute it was defined under – two different attributes may each define a VALUE named e.g. "Yes" – so def fixes that scope, the same way radcli_dict_value_by_attr()/rc_dict_getval() already scope a numeric VALUE lookup by attribute rather than matching across the whole dictionary.

Parameters
ctxa context with a dictionary loaded.
defthe attribute the VALUE belongs to, from radcli_dict_lookup() or a sibling.
namethe VALUE's name, as it appears in a VALUE dictionary line.
[out]outthe VALUE's numeric value, set only on success.
Returns
0 on success, -1 if ctx/def/name/out is NULL or no such VALUE is defined for def.

Definition at line 674 of file dict2.c.