attr(3)

πŸ“¦
version 1.0.5 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu questing

🌸 NAME 🌸

attr β€” Netlink attribute helpers πŸ’… (this is the attr(3) page, straight out of the Library Functions Manual, and bestie, we're gonna get through all of it together 🫢)


✨ SYNOPSIS ✨

Functions

uint16_t mnl_attr_get_type (const struct nlattr *attr)
uint16_t mnl_attr_get_len (const struct nlattr *attr)
uint16_t mnl_attr_get_payload_len (const struct nlattr *attr)
void * mnl_attr_get_payload (const struct nlattr *attr)
bool mnl_attr_ok (const struct nlattr *attr, int len)
struct nlattr * mnl_attr_next (const struct nlattr *attr)
int mnl_attr_type_valid (const struct nlattr *attr, uint16_t max)
int mnl_attr_validate (const struct nlattr *attr, enum
    mnl_attr_data_type type)
int mnl_attr_validate2 (const struct nlattr *attr, enum
    mnl_attr_data_type type, size_t exp_len)
int mnl_attr_parse (const struct nlmsghdr *nlh, unsigned int offset,
    mnl_attr_cb_t cb, void *data)
int mnl_attr_parse_nested (const struct nlattr *nested, mnl_attr_cb_t
    cb, void *data)
int mnl_attr_parse_payload (const void *payload, size_t payload_len,
    mnl_attr_cb_t cb, void *data)
uint8_t mnl_attr_get_u8 (const struct nlattr *attr)
uint16_t mnl_attr_get_u16 (const struct nlattr *attr)
uint32_t mnl_attr_get_u32 (const struct nlattr *attr)
uint64_t mnl_attr_get_u64 (const struct nlattr *attr)
const char * mnl_attr_get_str (const struct nlattr *attr)
void mnl_attr_put (struct nlmsghdr *nlh, uint16_t type, size_t len,
    const void *data)
void mnl_attr_put_u8 (struct nlmsghdr *nlh, uint16_t type, uint8_t data)
void mnl_attr_put_u16 (struct nlmsghdr *nlh, uint16_t type, uint16_t
    data)
void mnl_attr_put_u32 (struct nlmsghdr *nlh, uint16_t type, uint32_t
    data)
void mnl_attr_put_u64 (struct nlmsghdr *nlh, uint16_t type, uint64_t
    data)
void mnl_attr_put_str (struct nlmsghdr *nlh, uint16_t type, const char
    *data)
void mnl_attr_put_strz (struct nlmsghdr *nlh, uint16_t type, const char
    *data)
struct nlattr * mnl_attr_nest_start (struct nlmsghdr *nlh, uint16_t
    type)
bool mnl_attr_put_check (struct nlmsghdr *nlh, size_t buflen, uint16_t
    type, size_t len, const void *data)
bool mnl_attr_put_u8_check (struct nlmsghdr *nlh, size_t buflen,
    uint16_t type, uint8_t data)
bool mnl_attr_put_u16_check (struct nlmsghdr *nlh, size_t buflen,
    uint16_t type, uint16_t data)
bool mnl_attr_put_u32_check (struct nlmsghdr *nlh, size_t buflen,
    uint16_t type, uint32_t data)
bool mnl_attr_put_u64_check (struct nlmsghdr *nlh, size_t buflen,
    uint16_t type, uint64_t data)
bool mnl_attr_put_str_check (struct nlmsghdr *nlh, size_t buflen,
    uint16_t type, const char *data)
bool mnl_attr_put_strz_check (struct nlmsghdr *nlh, size_t buflen,
    uint16_t type, const char *data)
struct nlattr * mnl_attr_nest_start_check (struct nlmsghdr *nlh, size_t
    buflen, uint16_t type)
void mnl_attr_nest_end (struct nlmsghdr *nlh, struct nlattr *start)
void mnl_attr_nest_cancel (struct nlmsghdr *nlh, struct nlattr *start)

Okay so that's the whole roster of functions, and every single one of them gets its own little moment down in Function Documentation 🌈. No skipping, no skimming, we're doing this properly ✨


πŸ¦‹ Detailed Description πŸ¦‹

Netlink Type-Length-Value (TLV) attribute:

        |<-- 2 bytes -->|<-- 2 bytes -->|<-- variable -->|
        -------------------------------------------------
        |     length    |      type     |      value     |
        -------------------------------------------------
        |<--------- header ------------>|<-- payload --->|

The payload of the Netlink message contains sequences of attributes that are expressed in TLV format. Periodt. That's the whole vibe β€” a big ol' payload just stuffed with these little TLV besties, one after another after another πŸ’–


πŸ’– Function Documentation πŸ’–

uint16_t mnl_attr_get_len (const struct nlattr * attr)

mnl_attr_get_len β€” get length of netlink attribute

Parameters

  • attr β€” pointer to netlink attribute

This function returns the attribute length that is the attribute header plus the attribute payload. Like, both parts, together, no crumbs left behind πŸ“

Definition at line 50 of file attr.c.


void * mnl_attr_get_payload (const struct nlattr * attr)

mnl_attr_get_payload β€” get pointer to the attribute payload

Parameters

  • attr β€” pointer to netlink attribute

This function return a pointer to the attribute payload. Just a little pointer, hand-delivered, so you can go poke at the good stuff yourself πŸ’…

Definition at line 72 of file attr.c.


uint16_t mnl_attr_get_payload_len (const struct nlattr * attr)

mnl_attr_get_payload_len β€” get the attribute payload-value length

Parameters

  • attr β€” pointer to netlink attribute

This function returns the attribute payload-value length. Not the header, not the whole thing β€” just the payload-value, specifically πŸŽ€

Definition at line 61 of file attr.c.


const char * mnl_attr_get_str (const struct nlattr * attr)

mnl_attr_get_str β€” returns pointer to string attribute.

Parameters

  • attr β€” pointer to netlink attribute

This function returns the payload of string attribute value. A whole lil string, right there, ready for you 🌸

Definition at line 380 of file attr.c.


uint16_t mnl_attr_get_type (const struct nlattr * attr)

mnl_attr_get_type β€” get type of netlink attribute

Parameters

  • attr β€” pointer to netlink attribute

This function returns the attribute type. The type!! The identity!! The main character energy of the attribute πŸ‘‘

Definition at line 38 of file attr.c.


uint16_t mnl_attr_get_u16 (const struct nlattr * attr)

mnl_attr_get_u16 β€” returns 16-bit unsigned integer attribute payload

Parameters

  • attr β€” pointer to netlink attribute

This function returns the 16-bit value of the attribute payload. Sixteen bits, zero drama ✨

Definition at line 343 of file attr.c.


uint32_t mnl_attr_get_u32 (const struct nlattr * attr)

mnl_attr_get_u32 β€” returns 32-bit unsigned integer attribute payload

Parameters

  • attr β€” pointer to netlink attribute

This function returns the 32-bit value of the attribute payload. Thirty-two bits of pure payload, slay πŸ’œ

Definition at line 354 of file attr.c.


uint64_t mnl_attr_get_u64 (const struct nlattr * attr)

mnl_attr_get_u64 β€” returns 64-bit unsigned integer attribute.

Parameters

  • attr β€” pointer to netlink attribute

This function returns the 64-bit value of the attribute payload. This function is align-safe, since accessing 64-bit Netlink attributes is a common source of alignment issues. So like, this one's got your back, no cap 🫢

Definition at line 367 of file attr.c.


uint8_t mnl_attr_get_u8 (const struct nlattr * attr)

mnl_attr_get_u8 β€” returns 8-bit unsigned integer attribute payload

Parameters

  • attr β€” pointer to netlink attribute

This function returns the 8-bit value of the attribute payload. Smol. Adorable. Eight bits and iconic πŸŽ€

Definition at line 332 of file attr.c.


void mnl_attr_nest_cancel (struct nlmsghdr * nlh, struct nlattr * start)

mnl_attr_nest_cancel β€” cancel an attribute nest

Parameters

  • nlh β€” pointer to the netlink message
  • start β€” pointer to the attribute nest returned by mnl_attr_nest_start()

This function updates the attribute header that identifies the nest. Basically you started a nest and then changed your mind β€” not me doing that, but okay, we support you πŸ’€

Definition at line 714 of file attr.c.


void mnl_attr_nest_end (struct nlmsghdr * nlh, struct nlattr * start)

mnl_attr_nest_end β€” end an attribute nest

Parameters

  • nlh β€” pointer to the netlink message
  • start β€” pointer to the attribute nest returned by mnl_attr_nest_start()

This function updates the attribute header that identifies the nest. Closing the nest, wrapping it up, beautiful, tidy, we love a clean finish ✨

Definition at line 701 of file attr.c.


struct nlattr * mnl_attr_nest_start (struct nlmsghdr * nlh, uint16_t type)

mnl_attr_nest_start β€” start an attribute nest

Parameters

  • nlh β€” pointer to the netlink message
  • type β€” netlink attribute type

This function adds the attribute header that identifies the beginning of an attribute nest. This function always returns a valid pointer to the beginning of the nest. Always. Never misses. Reliability is her brand πŸ’…

Definition at line 514 of file attr.c.


struct nlattr * mnl_attr_nest_start_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type)

mnl_attr_nest_start_check β€” start an attribute nest

Parameters

  • buflen β€” size of buffer which stores the message
  • nlh β€” pointer to the netlink message
  • type β€” netlink attribute type

This function adds the attribute header that identifies the beginning of an attribute nest. If the nested attribute cannot be added then NULL, otherwise valid pointer to the beginning of the nest is returned. So it checks first β€” the responsible sibling of mnl_attr_nest_start() πŸ™ˆ

Definition at line 685 of file attr.c.


struct nlattr * mnl_attr_next (const struct nlattr * attr)

mnl_attr_next β€” get the next attribute in the payload of a netlink message

Parameters

  • attr β€” pointer to the current attribute

This function returns a pointer to the next attribute after the one passed as parameter. You have to use mnl_attr_ok() to ensure that the next attribute is valid. Do not skip that step, bestie, I am begging 😭

Definition at line 108 of file attr.c.


bool mnl_attr_ok (const struct nlattr * attr, int len)

mnl_attr_ok β€” check if there is room for an attribute in a buffer

Parameters

  • attr β€” attribute that we want to check if there is room for
  • len β€” remaining bytes in a buffer that contains the attribute

This function is used to check that a buffer, which is supposed to contain an attribute, has enough room for the attribute that it stores, i.e. this function can be used to verify that an attribute is neither malformed nor truncated. Vibe check passed or vibe check failed, nothing in between.

This function does not set errno in case of error since it is intended for iterations. Thus, it returns true on success and false on error.

The len parameter may be negative in the case of malformed messages during attribute iteration, that is why we use a signed integer. Yeah, negative len is a thing that happens, and that is exactly why it's signed, iykyk 🫠

Definition at line 93 of file attr.c.


int mnl_attr_parse (const struct nlmsghdr * nlh, unsigned int offset, mnl_attr_cb_t cb, void * data)

mnl_attr_parse β€” parse attributes

Parameters

  • nlh β€” pointer to netlink message
  • offset β€” offset to start parsing from (if payload is after any header)
  • cb β€” callback function that is called for each attribute
  • data β€” pointer to data that is passed to the callback function

This function allows you to iterate over the sequence of attributes that compose the Netlink message. You can then put the attribute in an array as it usually happens at this stage or you can use any other data structure (such as lists or trees). Your call, your data structure, your era 🌈

This function propagates the return value of the callback, which can be MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP.

Definition at line 255 of file attr.c.


int mnl_attr_parse_nested (const struct nlattr * nested, mnl_attr_cb_t cb, void * data)

mnl_attr_parse_nested β€” parse attributes inside a nest

Parameters

  • nested β€” pointer to netlink attribute that contains a nest
  • cb β€” callback function that is called for each attribute in the nest
  • data β€” pointer to data passed to the callback function

This function allows you to iterate over the sequence of attributes that compose the Netlink message. You can then put the attribute in an array as it usually happens at this stage or you can use any other data structure (such as lists or trees). Same energy as above, but we're going inside the nest this time πŸͺΊ

This function propagates the return value of the callback, which can be MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP.

Definition at line 282 of file attr.c.


int mnl_attr_parse_payload (const void * payload, size_t payload_len, mnl_attr_cb_t cb, void * data)

mnl_attr_parse_payload β€” parse attributes in payload of Netlink message

Parameters

  • payload β€” pointer to the payload of the Netlink message
  • payload_len β€” the payload length that contains the attributes
  • cb β€” the callback function that gets called for each attribute
  • data β€” pointer to data that gets passed to the callback function

Okay so real talk: this one wants a pointer to the area that contains the attributes, aka the payload of the Netlink message. So bestie, you pass a pointer to the Netlink message payload, not the entire message. Do not do the whole message. Just the payload. I'm serious 🫢

What it lets you do is iterate over the sequence of attributes sitting at some payload offset. Then you can shove those attributes into one array like normal, or honestly use literally any other data structure you vibe with β€” lists, trees, whatever's giving ✨

And it propagates the return value of the callback, which can be MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP.

Definition at line 313 of file attr.c.


πŸ’– mnl_attr_put

void mnl_attr_put (struct nlmsghdr * nlh, uint16_t type, size_t len, const void * data)

mnl_attr_put β€” add an attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • type β€” the netlink attribute type you want to add
  • len β€” the netlink attribute payload length
  • data β€” pointer to the data that will be stored by the new attribute

This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. That's the whole move. Length go up, attribute go in πŸ”₯

Definition at line 395 of file attr.c.


🌸 mnl_attr_put_check

bool mnl_attr_put_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, size_t len, const void * data)

mnl_attr_put_check β€” add an attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • buflen β€” size of the buffer which stores the message
  • type β€” the netlink attribute type you want to add
  • len β€” the netlink attribute payload length
  • data β€” pointer to the data that will be stored by the new attribute

So this one is the careful bestie πŸ’… It first checks that the data can actually be added to the message (does it fit in the buffer, queen?), and then it updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute.

It returns true if the attribute could be added to the message, otherwise false comes back at you.

Definition at line 540 of file attr.c.


πŸŽ€ mnl_attr_put_str

void mnl_attr_put_str (struct nlmsghdr * nlh, uint16_t type, const char * data)

mnl_attr_put_str β€” add a string attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • type β€” netlink attribute type
  • data β€” pointer to string data that is stored by the new attribute

This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. String edition, slay ✨

Definition at line 481 of file attr.c.


πŸ¦‹ mnl_attr_put_str_check

bool mnl_attr_put_str_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, const char * data)

mnl_attr_put_str_check β€” add a string attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • buflen β€” size of the buffer which stores the message
  • type β€” netlink attribute type
  • data β€” pointer to string data that is stored by the new attribute

Same energy as above but with the safety net: this function first checks that the data can be added to the message (fits into the buffer) and then updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. Returns true if the attribute could be added to the message, otherwise false is returned.

And then, because the docs are simply Like That, it says it again: this function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. Yes bestie, it's in there twice. No cap. That's literally what the page says. 😭

Definition at line 647 of file attr.c.


πŸ’œ mnl_attr_put_strz

void mnl_attr_put_strz (struct nlmsghdr * nlh, uint16_t type, const char * data)

mnl_attr_put_strz β€” add a string attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • type β€” netlink attribute type
  • data β€” pointer to string data that is stored by the new attribute

This function is similar to mnl_attr_put_str, but β€” and this is the whole personality β€” it includes the NUL/zero ('\0') terminator at the end of the string. The z is for zero, iykyk 🧚

This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute.

Definition at line 499 of file attr.c.


🌈 mnl_attr_put_strz_check

bool mnl_attr_put_strz_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, const char * data)

mnl_attr_put_strz_check β€” add a string attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • buflen β€” size of the buffer which stores the message
  • type β€” netlink attribute type
  • data β€” pointer to string data that is stored by the new attribute

This function is similar to mnl_attr_put_str, but it includes the NUL/zero ('\0') terminator at the end of the string.

This function first checks that the data can be added to the message (fits into the buffer) and then updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. The function returns true if the attribute could be added to the message, otherwise false is returned.

Definition at line 669 of file attr.c.


⭐ mnl_attr_put_u16

void mnl_attr_put_u16 (struct nlmsghdr * nlh, uint16_t type, uint16_t data)

mnl_attr_put_u16 β€” add a 16-bit unsigned integer attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • type β€” netlink attribute type
  • data β€” 16-bit unsigned integer data that is stored by the new attribute

This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute.

Definition at line 436 of file attr.c.


πŸ’– mnl_attr_put_u16_check

bool mnl_attr_put_u16_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, uint16_t data)

mnl_attr_put_u16_check β€” add a 16-bit unsigned int attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • buflen β€” size of the buffer which stores the message
  • type β€” netlink attribute type
  • data β€” 16-bit unsigned integer data that is stored by the new attribute

This function first checks that the data can be added to the message (fits into the buffer) and then updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. The function returns true if the attribute could be added to the message, otherwise false is returned.

This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. Yeah. Again. The page really does say it twice. We keep it. Periodt. πŸ™ˆ

Definition at line 584 of file attr.c.


πŸ”₯ mnl_attr_put_u32

void mnl_attr_put_u32 (struct nlmsghdr * nlh, uint16_t type, uint32_t data)

mnl_attr_put_u32 β€” add a 32-bit unsigned integer attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • type β€” netlink attribute type
  • data β€” 32-bit unsigned integer data that is stored by the new attribute

This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute.

Definition at line 451 of file attr.c.


✨ mnl_attr_put_u32_check

bool mnl_attr_put_u32_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, uint32_t data)

mnl_attr_put_u32_check β€” add a 32-bit unsigned int attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • buflen β€” size of the buffer which stores the message
  • type β€” netlink attribute type
  • data β€” 32-bit unsigned integer data that is stored by the new attribute

This function first checks that the data can be added to the message (fits into the buffer) and then updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. The function returns true if the attribute could be added to the message, otherwise false is returned.

This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. Still saying it twice. Still iconic. πŸ’…

Definition at line 605 of file attr.c.


πŸ‘‘ mnl_attr_put_u64

void mnl_attr_put_u64 (struct nlmsghdr * nlh, uint16_t type, uint64_t data)

mnl_attr_put_u64 β€” add a 64-bit unsigned integer attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • type β€” netlink attribute type
  • data β€” 64-bit unsigned integer data that is stored by the new attribute

This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. Big number energy πŸ”₯

Definition at line 466 of file attr.c.


πŸ“ mnl_attr_put_u64_check

bool mnl_attr_put_u64_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, uint64_t data)

mnl_attr_put_u64_check β€” add a 64-bit unsigned int attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • buflen β€” size of the buffer which stores the message
  • type β€” netlink attribute type
  • data β€” 64-bit unsigned integer data that is stored by the new attribute

This function first checks that the data can be added to the message (fits into the buffer) and then updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. The function returns true if the attribute could be added to the message, otherwise false is returned.

This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. Third time's the charm, bestie, it's literally the same sentence again 😭

Definition at line 626 of file attr.c.


πŸŽ€ mnl_attr_put_u8

void mnl_attr_put_u8 (struct nlmsghdr * nlh, uint16_t type, uint8_t data)

mnl_attr_put_u8 β€” add an 8-bit unsigned integer attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • type β€” netlink attribute type
  • data β€” 8-bit unsigned integer data that is stored by the new attribute

This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. Tiny number, big vibes 🌸

Definition at line 421 of file attr.c.


🫢 mnl_attr_put_u8_check

bool mnl_attr_put_u8_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, uint8_t data)

mnl_attr_put_u8_check β€” add an 8-bit unsigned int attribute to a netlink message

Parameters

  • nlh β€” pointer to the netlink message
  • buflen β€” size of the buffer which stores the message
  • type β€” netlink attribute type
  • data β€” 8-bit unsigned integer data that is stored by the new attribute

This function first checks that the data can be added to the message (fits into the buffer) and then updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute. The function returns true if the attribute could be added to the message, otherwise false is returned. (Only once this time. Growth. πŸ’…)

Definition at line 563 of file attr.c.


πŸ¦‹ mnl_attr_type_valid

int mnl_attr_type_valid (const struct nlattr * attr, uint16_t max)

mnl_attr_type_valid β€” check if the attribute type is valid

Parameters

  • attr β€” pointer to the attribute to be checked
  • max β€” maximum attribute type

okay so this function is basically the vibe check for attribute types ✨ it lets you check if the attribute type is higher than the maximum supported type. and if that attribute type is invalid?? it returns -1 and errno gets explicitly set β€” no cap, it does not leave you guessing. but on success, bestie, it returns 1. πŸ’–

⚠️ okay real talk though: doing strict attribute checking in user-space is not a good idea. because you might run an old application with a newer kernel that supports new attributes, and that leads to backward compatibility breakages in user-space. instead, the move is to check if you support an attribute, and if you don't, just skip it. that's it, that's the whole strategy. 🫢

Definition at line 127 of file attr.c.


int mnl_attr_validate πŸ¦‹

int mnl_attr_validate (const struct nlattr * attr, enum mnl_attr_data_type type)

mnl_attr_validate β€” validate netlink attribute (simplified version) πŸ’…

Parameters

  • attr β€” pointer to netlink attribute that we want to validate
  • type β€” data type (see enum mnl_attr_data_type)

so the validation is based on the data type, right? specifically it checks that integers (u8, u16, u32 and u64) have enough room for them. like, does this thing actually fit. that's the whole job. 🌸

this function returns -1 in case of error, and errno is explicitly set.

Definition at line 207 of file attr.c.


int mnl_attr_validate2 πŸŽ€

int mnl_attr_validate2 (const struct nlattr * attr, enum mnl_attr_data_type type, size_t exp_len)

mnl_attr_validate2 β€” validate netlink attribute (extended version) ✨

Parameters

  • attr β€” pointer to netlink attribute that we want to validate
  • type β€” attribute type (see enum mnl_attr_data_type)
  • exp_len β€” expected attribute data size

okay so this one is the glow-up version, it lets you do a more accurate validation for attributes whose size is variable β€” because not every attribute is out here being a fixed size, iykyk. and if the size of the attribute is not what is expected? this function returns -1 and errno is explicitly set. periodt. πŸ’€

Definition at line 229 of file attr.c.


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libmnl from the source code.


and that's a wrap on the attr(3) page bestie, literally iconic of you to read the whole thing πŸ§šπŸ’– this was libmnl, Version 1.0.5, and yeah it's attr(3) β€” go forth and validate those attributes, you absolute main character 🌈⭐

πŸ“¦ where this page comes from