rc_avpair_assign(3)

πŸ“¦
version 1.5.2 Β· 4 versions
, in alpine 3.24, epel 10, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

πŸ’– rc_avpair_assign(3) β€” Radius client library πŸ’–

okay bestie, welcome to the <radcli/radcli.h> cinematic universe 🌈 today we're doing rc_avpair_assign and honestly? she's a baddie. she takes a value and she assigns it to an attribute-value pair. that's the whole job. no cap. πŸŽ€


✨ NAME ✨

rc_avpair_assign β€” it assigns a value to an attribute-value pair, and yes the original manpage left this part basically blank, so consider this the glow-up πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <radcli/radcli.h>

int rc_avpair_assign(
    VALUE_PAIR  *vp,
    void const  *pval,
    int          len
);

look at her. three args. iconic. πŸ‘‘


🌸 DESCRIPTION 🌸

Assigns the given value to an attribute-value pair. periodt. that's it, that's the function 🫢

now here's where you gotta pay attention, because the type of the value changes everything:

  • if the value is of type PW_TYPE_STRING, it must either be a null terminated string with len set to -1, or raw data with the length properly set. pick a lane bestie 😭
  • for PW_TYPE_DATE, PW_TYPE_INTEGER, and PW_TYPE_IPADDR, an uint32_t number should be set at pval. and for IPv4 addresses it should be in host byte order β€” do not come in here with network byte order, i'm serious πŸ™ˆ
  • for PW_TYPE_IPV6ADDR type, a 16-byte long address is expected.
  • for PW_TYPE_IPV6PREFIX, the rfc3162 prefix format is expected. simply that is: a zero byte, a byte with the value of prefix (e.g., 112), and the remaining bytes are the IPv6 address. yes really. that's the format. we don't make the rules, rfc3162 does ⭐

πŸ’œ PARAMETERS πŸ’œ

  • vp β€” a pointer to a VALUE_PAIR structure.
  • pval β€” the value (e.g., the actual username).
  • len β€” the length of pval, or -1 if to calculate (in case of strings).

πŸŽ€ STRUCTURES πŸŽ€

⚠️ bestie, avoid using this structure directly. use the rc_avpair_get_ functions. i'm begging. it's for your own good πŸ™
struct rc_value_pair {
  char                   name[RC_NAME_LENGTH+1];      // attribute name if known.
  uint64_t               attribute; // attribute numeric value of type rc_attr_id including vendor; use VENDOR() and ATTRID() to separate.
  rc_attr_type           type;      // attribute type.
  uint32_t               lvalue;    // attribute value if type is PW_TYPE_INTEGER, PW_TYPE_DATE or PW_TYPE_IPADDR.
  char                   strvalue[AUTH_STRING_LEN+1];  // contains attribute value in other cases.
  struct rc_value_pair  *next;
  char                   pad[32];       // unused pad
};

πŸ”₯ RETURN VALUE πŸ”₯

  • 0 on success πŸ’–
  • -1 on failure πŸ’€

🧚 SEE ALSO 🧚

the whole squad, fr fr β€” everyone's invited:


and that's the page, bestie! ✨ this radcli moment was served to you by radcli, dated 2023-01-29 β€” go forth and assign those value pairs, you absolute main character πŸ«ΆπŸ’…πŸŒΈ

πŸ“¦ where this page comes from