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

Convenience wrappers over radcli_dict_lookup_num() + the matching radcli_avp_add_*(), for the common case of a well-known attribute a caller already has a legacy PW_* constant for. More...

Functions

int radcli_avp_add_bytes_by_num (radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, const void *value, size_t len)
 Look up an attribute by legacy numeric ID and append its bytes.
int radcli_avp_add_str_by_num (radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, const char *value)
 Look up a string-typed attribute by legacy numeric ID and append it.
int radcli_avp_add_uint32_by_num (radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, uint32_t value)
 Look up an integer/IPv4-address/date-typed attribute by legacy numeric ID and append it.
int radcli_avp_add_uint64_by_num (radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, uint64_t value)
 Look up a 64-bit integer-typed attribute by legacy numeric ID and append it.
int radcli_avp_add_ip4_by_num (radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, struct in_addr value)
 Look up an IPv4-address-typed attribute by legacy numeric ID and append it.
int radcli_avp_add_ip6_by_num (radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, const struct in6_addr *value, unsigned prefix)
 Look up an IPv6-address or IPv6-prefix-typed attribute by legacy numeric ID and append it.
int radcli_avp_add_ip4prefix_by_num (radcli_avp_list *list, const radcli_ctx *ctx, uint32_t attrid, uint32_t vendor, struct in_addr value, unsigned prefix)
 Look up an IPv4-prefix-typed attribute by legacy numeric ID and append it.

Detailed Description

Convenience wrappers over radcli_dict_lookup_num() + the matching radcli_avp_add_*(), for the common case of a well-known attribute a caller already has a legacy PW_* constant for.

Each folds a radcli_dict_lookup_num() call into the add itself, so appending a well-known attribute (e.g. one of the RFC 2865/2866/2869 attributes the built-in dictionary radcli_ctx_read_config() loads always carries) is back to a single call with a single failure path, instead of a separate lookup, a NULL check on its result, and then the add – exactly the rc_avpair_add() shape radcli.h callers are used to. The un-suffixed radcli_avp_add_*() functions remain the right choice when a radcli_attr_def is already in hand (e.g. reused across a loop, or obtained via radcli_dict_lookup()/radcli_dict_lookup_oid() for a name or OID rather than a numeric ID), or when a NULL from the lookup is a meaningful, distinct outcome the caller wants to detect on its own (e.g. an attribute that depends on an optional, caller-supplied dictionary).

Function Documentation

◆ radcli_avp_add_bytes_by_num()

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

Look up an attribute by legacy numeric ID and append its bytes.

Parameters
listdestination list.
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.
valuethe bytes to copy in; may be NULL only if len is 0.
lennumber of bytes at value.
Returns
0 on success, -1 on failure (no such attribute, or as radcli_avp_add_bytes()).

Definition at line 466 of file avp.c.

◆ radcli_avp_add_ip4_by_num()

int radcli_avp_add_ip4_by_num ( radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor,
struct in_addr value )

Look up an IPv4-address-typed attribute by legacy numeric ID and append it.

Parameters
listdestination list.
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.
valuethe address, in the usual network byte order struct in_addr carries.
Returns
0 on success, -1 on failure (no such attribute, or as radcli_avp_add_ip4()).

Definition at line 539 of file avp.c.

◆ radcli_avp_add_ip4prefix_by_num()

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

Look up an IPv4-prefix-typed attribute by legacy numeric ID and append it.

Parameters
listdestination list.
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.
valuethe address.
prefixthe prefix length (0-32).
Returns
0 on success, -1 on failure (no such attribute, or as radcli_avp_add_ip4prefix()).

Definition at line 578 of file avp.c.

◆ radcli_avp_add_ip6_by_num()

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

Look up an IPv6-address or IPv6-prefix-typed attribute by legacy numeric ID and append it.

Parameters
listdestination list.
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.
valuethe address.
prefixthe prefix length (0-128); ignored/must be 0 for RADCLI_TYPE_IPV6ADDR.
Returns
0 on success, -1 on failure (no such attribute, or as radcli_avp_add_ip6()).

Definition at line 558 of file avp.c.

◆ radcli_avp_add_str_by_num()

int radcli_avp_add_str_by_num ( radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor,
const char * value )

Look up a string-typed attribute by legacy numeric ID and append it.

Parameters
listdestination list.
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.
valuea null-terminated string.
Returns
0 on success, -1 on failure (no such attribute, or as radcli_avp_add_str()).

Definition at line 485 of file avp.c.

◆ radcli_avp_add_uint32_by_num()

int radcli_avp_add_uint32_by_num ( radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor,
uint32_t value )

Look up an integer/IPv4-address/date-typed attribute by legacy numeric ID and append it.

Parameters
listdestination list.
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.
valuethe value; an IPv4 address is given in host byte order.
Returns
0 on success, -1 on failure (no such attribute, or as radcli_avp_add_uint32()).

Definition at line 503 of file avp.c.

◆ radcli_avp_add_uint64_by_num()

int radcli_avp_add_uint64_by_num ( radcli_avp_list * list,
const radcli_ctx * ctx,
uint32_t attrid,
uint32_t vendor,
uint64_t value )

Look up a 64-bit integer-typed attribute by legacy numeric ID and append it.

Parameters
listdestination list.
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.
valuethe value.
Returns
0 on success, -1 on failure (no such attribute, or as radcli_avp_add_uint64()).

Definition at line 521 of file avp.c.