Radcli library 2.0.0
A simple radius library -- new API reference
Loading...
Searching...
No Matches
radcli_avp_get_*_by_num() – lookup-and-get in one call

Receive-side mirror of radcli2-avp-by-num: fold radcli_dict_lookup_num() + radcli_avp_get() + the matching typed getter into one call, for the common case of a well-known, single-occurrence attribute a caller already has a legacy PW_* constant for. More...

Functions

const radcli_avp * radcli_avp_get_by_num (const radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, unsigned idx)
 Look up the idx-th occurrence of an attribute by legacy numeric ID.
int radcli_avp_get_uint32_by_num (const radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, uint32_t *out)
 Look up an integer/IPv4-address/date-typed attribute by legacy numeric ID and read its first occurrence.
int radcli_avp_get_uint64_by_num (const radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, uint64_t *out)
 Look up a 64-bit integer-typed attribute by legacy numeric ID and read its first occurrence.
int radcli_avp_get_ip6_by_num (const radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, struct in6_addr *out, unsigned *prefix)
 Look up an IPv6-address or IPv6-prefix-typed attribute by legacy numeric ID and read its first occurrence.
int radcli_avp_get_ip4prefix_by_num (const radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, struct in_addr *out, unsigned *prefix)
 Look up an IPv4-prefix-typed attribute by legacy numeric ID and read its first occurrence.
int radcli_avp_get_bytes_by_num (const radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, const void **out, size_t *len)
 Look up an attribute by legacy numeric ID and read its first occurrence's raw bytes.
const char * radcli_avp_get_cstr_by_num (const radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor)
 Look up an attribute by legacy numeric ID and read its first occurrence as a NUL-terminated string.

Detailed Description

Receive-side mirror of radcli2-avp-by-num: fold radcli_dict_lookup_num() + radcli_avp_get() + the matching typed getter into one call, for the common case of a well-known, single-occurrence attribute a caller already has a legacy PW_* constant for.

Each returns the first occurrence only (idx 0) – the common case for every attribute that is not documented to legitimately repeat. An attribute that can carry more than one meaningful occurrence in a single reply (e.g. Reply-Message, Framed-Route) needs radcli_avp_get_by_num() (this group's plain finder, which does take idx) in a small loop instead – see radcli_avp_concat_str_by_num() for the specific, very common case of concatenating every occurrence of a text attribute.

Function Documentation

◆ radcli_avp_get_by_num()

const radcli_avp * radcli_avp_get_by_num ( const radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor,
unsigned idx )

Look up the idx-th occurrence of an attribute by legacy numeric ID.

Parameters
listthe list to search.
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.
idx0 for the first occurrence, 1 for the second, and so on.
Returns
the matching attribute, or NULL if no such attribute is defined, or fewer than idx+1 occurrences exist in list.

Definition at line 952 of file avp.c.

◆ radcli_avp_get_bytes_by_num()

int radcli_avp_get_bytes_by_num ( const radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor,
const void ** out,
size_t * len )

Look up an attribute by legacy numeric ID and read its first occurrence's raw bytes.

Parameters
listthe list to search.
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.
outwhere to write a pointer to the value; valid for list's lifetime. May be NULL.
lenwhere to write the value's length in bytes. May be NULL.
Returns
0 on success, -1 on failure (no such attribute, or no occurrence).

Definition at line 1047 of file avp.c.

◆ radcli_avp_get_cstr_by_num()

const char * radcli_avp_get_cstr_by_num ( const radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor )

Look up an attribute by legacy numeric ID and read its first occurrence as a NUL-terminated string.

Parameters
listthe list to search.
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
a pointer valid for list's lifetime (owned by list – never freed by the caller), or NULL if no such attribute is defined, no occurrence exists, or as radcli_avp_get_cstr() (embedded NUL byte, or invalid UTF-8 for a RADCLI_TYPE_TEXT attribute).

Definition at line 1068 of file avp.c.

◆ radcli_avp_get_ip4prefix_by_num()

int radcli_avp_get_ip4prefix_by_num ( const radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor,
struct in_addr * out,
unsigned * prefix )

Look up an IPv4-prefix-typed attribute by legacy numeric ID and read its first occurrence.

Parameters
listthe list to search.
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.
outwhere to write the address. May be NULL.
prefixwhere to write the prefix length. May be NULL.
Returns
0 on success, -1 on failure (no such attribute, no occurrence, or as radcli_avp_get_ip4prefix()).

Definition at line 1027 of file avp.c.

◆ radcli_avp_get_ip6_by_num()

int radcli_avp_get_ip6_by_num ( const radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor,
struct in6_addr * out,
unsigned * prefix )

Look up an IPv6-address or IPv6-prefix-typed attribute by legacy numeric ID and read its first occurrence.

Parameters
listthe list to search.
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.
outwhere to write the address. May be NULL.
prefixwhere to write the prefix length. May be NULL.
Returns
0 on success, -1 on failure (no such attribute, no occurrence, or as radcli_avp_get_ip6()).

Definition at line 1007 of file avp.c.

◆ radcli_avp_get_uint32_by_num()

int radcli_avp_get_uint32_by_num ( const radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor,
uint32_t * out )

Look up an integer/IPv4-address/date-typed attribute by legacy numeric ID and read its first occurrence.

Parameters
listthe list to search.
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.
outwhere to write the value; an IPv4 address is returned in host byte order. May be NULL.
Returns
0 on success, -1 on failure (no such attribute, no occurrence, or as radcli_avp_get_uint32()).

Definition at line 970 of file avp.c.

◆ radcli_avp_get_uint64_by_num()

int radcli_avp_get_uint64_by_num ( const radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor,
uint64_t * out )

Look up a 64-bit integer-typed attribute by legacy numeric ID and read its first occurrence.

Parameters
listthe list to search.
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.
outwhere to write the value. May be NULL.
Returns
0 on success, -1 on failure (no such attribute, no occurrence, or as radcli_avp_get_uint64()).

Definition at line 988 of file avp.c.