radcli_avp_add_username(3)
π radcli_avp_add_username π
okay so bestie, this is a page from the Radius client library (section 3 of the manuals, iykyk), and it's genuinely one of the more thoughtful little functions out there. let me tell you all about it π«Ά
β¨ NAME β¨
radcli_avp_add_username β appends a User-Name AVP, and it'll tack on a realm as "username@realm" β but only if the username you handed it doesn't already have a realm in there. the way it just knows? iconic. π
πΈ SYNOPSIS πΈ
#include <radcli/>
int radcli_avp_add_username(
radcli_avp_list *list,
const radcli_ctx *ctx,
const char *username,
const char *realm
);
π¦ DESCRIPTION π¦
so this one was literally written for callers β think an application that's reading its own "default_realm" config knob β that need to send "username@realm" only when the caller-supplied username didn't already come with a realm attached. like, no double-realm situations here, we're not doing that today π
and here's the cute part: if you pass realm as NULL, it goes and reaches for ctx's own "default_realm" configuration option. so an application whose entire realm policy is just "whatever this ctx's config file says" never has to read that option out itself. literally so convenient, obsessed πβ¨
π PARAMETERS π
listβ the destination list. that's where the AVP lands πctxβ a context with a dictionary that defines User-Name. and yes, anyradcli_ctx_new()/radcli_ctx_read_config()context qualifies, so you're probably already good πusernameβ the username itself. it gets used as-is if it already contains an'@'. respect the existing realm, periodt.realmβ the realm to append ifusernamehas no'@'. three whole moods here:NULLβ usesctx's own"default_realm"configuration option (and if that option is unset or empty, no realm gets appended at all, no drama)""β explicitly suppresses appending a realm, even if"default_realm"is configured. sometimes you just want the username, alone, thriving π- any other string β used verbatim. you said it, it ships it π
β RETURN VALUE β
0on success β slay π-1on failure
and the failure cases, fr fr, are: no User-Name attribute in ctx's dictionary, allocation failure, or as radcli_avp_add_str(). so like, check your dictionary bestie π
π₯ SEE ALSO π₯
the whole friend group, in order:
radcli_avp_add_bytes(3),radcli_avp_add_bytes_by_num(3)radcli_avp_add_gigawords64(3),radcli_avp_add_gigawords64_by_num(3)radcli_avp_add_ip4(3),radcli_avp_add_ip4_by_num(3)radcli_avp_add_ip4prefix(3),radcli_avp_add_ip4prefix_by_num(3)radcli_avp_add_ip6(3),radcli_avp_add_ip6_by_num(3)radcli_avp_add_str(3),radcli_avp_add_str_by_num(3)radcli_avp_add_uint32(3),radcli_avp_add_uint32_by_num(3)radcli_avp_add_uint64(3),radcli_avp_add_uint64_by_num(3)radcli_avp_concat_str(3),radcli_avp_concat_str_by_num(3)radcli_avp_def(3)radcli_avp_get(3),radcli_avp_get_by_num(3)radcli_avp_get_bytes(3),radcli_avp_get_bytes_by_num(3)radcli_avp_get_cstr(3),radcli_avp_get_cstr_by_num(3)radcli_avp_get_gigawords64(3),radcli_avp_get_gigawords64_by_num(3)radcli_avp_get_ip4prefix(3),radcli_avp_get_ip4prefix_by_num(3)radcli_avp_get_ip6(3),radcli_avp_get_ip6_by_num(3)radcli_avp_get_uint32(3),radcli_avp_get_uint32_by_num(3)radcli_avp_get_uint64(3),radcli_avp_get_uint64_by_num(3)radcli_avp_iter_next(3)radcli_avp_list_error(3),radcli_avp_list_free(3),radcli_avp_list_iter(3),radcli_avp_list_new(3)
π sign-off π
this lil masterpiece comes from radcli, dated 2026-10-10, and lives at radcli_avp_add_username(3) in the Radius client library docs. go forth and append those AVPs responsibly bestie, ily, bye ππ·β¨
π¦ where this page comes from
- arch rolling: radcli 2.0.1-1 Β· BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms