|
Radcli library 2.0.0
A simple radius library -- new API reference
|
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. | |
Looking up an attribute's definition – name, wire type, OID, and named VALUEs – from the dictionary a radcli_ctx has loaded.
| enum 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. |
| const char * radcli_attr_def_name | ( | const radcli_attr_def * | def | ) |
Return an attribute definition's canonical name.
| def | an attribute definition from radcli_dict_lookup() or a sibling. |
| 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.
| def | an attribute definition from radcli_dict_lookup() or a sibling. |
| buf | destination buffer; may be NULL if buflen is 0. |
| buflen | size of buf in bytes. |
| radcli_attr_type radcli_attr_def_type | ( | const radcli_attr_def * | def | ) |
Return an attribute definition's wire type.
| def | an attribute definition from radcli_dict_lookup() or a sibling. |
| 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.
| ctx | a context with a dictionary loaded. |
| name | the attribute name, e.g. "Framed-IP-Address". |
| 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.
| ctx | a context with a dictionary loaded. |
| attrid | the attribute ID (a PW_* constant, or a vendor type ID when vendor is non-zero). |
| vendor | the vendor PEN, or 0 for a standard attribute. |
| 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.
| ctx | a context with a dictionary loaded. |
| oid | the dot-separated OID text. |
| 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.
| ctx | a context with a dictionary loaded. | |
| def | the attribute the VALUE belongs to, from radcli_dict_lookup() or a sibling. | |
| name | the VALUE's name, as it appears in a VALUE dictionary line. | |
| [out] | out | the VALUE's numeric value, set only on success. |