.TH "attr" 3 "Version 1.0.5" "libmnl" \" -*- nroff -*- .ad l .nh .SH NAME attr \- Netlink attribute helpers .SH SYNOPSIS .br .PP .SS "Functions" .in +1c .ti -1c .RI "uint16_t \fBmnl_attr_get_type\fP (const struct nlattr *attr)" .br .ti -1c .RI "uint16_t \fBmnl_attr_get_len\fP (const struct nlattr *attr)" .br .ti -1c .RI "uint16_t \fBmnl_attr_get_payload_len\fP (const struct nlattr *attr)" .br .ti -1c .RI "void * \fBmnl_attr_get_payload\fP (const struct nlattr *attr)" .br .ti -1c .RI "bool \fBmnl_attr_ok\fP (const struct nlattr *attr, int len)" .br .ti -1c .RI "struct nlattr * \fBmnl_attr_next\fP (const struct nlattr *attr)" .br .ti -1c .RI "int \fBmnl_attr_type_valid\fP (const struct nlattr *attr, uint16_t max)" .br .ti -1c .RI "int \fBmnl_attr_validate\fP (const struct nlattr *attr, enum mnl_attr_data_type type)" .br .ti -1c .RI "int \fBmnl_attr_validate2\fP (const struct nlattr *attr, enum mnl_attr_data_type type, size_t exp_len)" .br .ti -1c .RI "int \fBmnl_attr_parse\fP (const struct nlmsghdr *nlh, unsigned int offset, mnl_attr_cb_t cb, void *data)" .br .ti -1c .RI "int \fBmnl_attr_parse_nested\fP (const struct nlattr *nested, mnl_attr_cb_t cb, void *data)" .br .ti -1c .RI "int \fBmnl_attr_parse_payload\fP (const void *payload, size_t payload_len, mnl_attr_cb_t cb, void *data)" .br .ti -1c .RI "uint8_t \fBmnl_attr_get_u8\fP (const struct nlattr *attr)" .br .ti -1c .RI "uint16_t \fBmnl_attr_get_u16\fP (const struct nlattr *attr)" .br .ti -1c .RI "uint32_t \fBmnl_attr_get_u32\fP (const struct nlattr *attr)" .br .ti -1c .RI "uint64_t \fBmnl_attr_get_u64\fP (const struct nlattr *attr)" .br .ti -1c .RI "const char * \fBmnl_attr_get_str\fP (const struct nlattr *attr)" .br .ti -1c .RI "void \fBmnl_attr_put\fP (struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data)" .br .ti -1c .RI "void \fBmnl_attr_put_u8\fP (struct nlmsghdr *nlh, uint16_t type, uint8_t data)" .br .ti -1c .RI "void \fBmnl_attr_put_u16\fP (struct nlmsghdr *nlh, uint16_t type, uint16_t data)" .br .ti -1c .RI "void \fBmnl_attr_put_u32\fP (struct nlmsghdr *nlh, uint16_t type, uint32_t data)" .br .ti -1c .RI "void \fBmnl_attr_put_u64\fP (struct nlmsghdr *nlh, uint16_t type, uint64_t data)" .br .ti -1c .RI "void \fBmnl_attr_put_str\fP (struct nlmsghdr *nlh, uint16_t type, const char *data)" .br .ti -1c .RI "void \fBmnl_attr_put_strz\fP (struct nlmsghdr *nlh, uint16_t type, const char *data)" .br .ti -1c .RI "struct nlattr * \fBmnl_attr_nest_start\fP (struct nlmsghdr *nlh, uint16_t type)" .br .ti -1c .RI "bool \fBmnl_attr_put_check\fP (struct nlmsghdr *nlh, size_t buflen, uint16_t type, size_t len, const void *data)" .br .ti -1c .RI "bool \fBmnl_attr_put_u8_check\fP (struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint8_t data)" .br .ti -1c .RI "bool \fBmnl_attr_put_u16_check\fP (struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint16_t data)" .br .ti -1c .RI "bool \fBmnl_attr_put_u32_check\fP (struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint32_t data)" .br .ti -1c .RI "bool \fBmnl_attr_put_u64_check\fP (struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint64_t data)" .br .ti -1c .RI "bool \fBmnl_attr_put_str_check\fP (struct nlmsghdr *nlh, size_t buflen, uint16_t type, const char *data)" .br .ti -1c .RI "bool \fBmnl_attr_put_strz_check\fP (struct nlmsghdr *nlh, size_t buflen, uint16_t type, const char *data)" .br .ti -1c .RI "struct nlattr * \fBmnl_attr_nest_start_check\fP (struct nlmsghdr *nlh, size_t buflen, uint16_t type)" .br .ti -1c .RI "void \fBmnl_attr_nest_end\fP (struct nlmsghdr *nlh, struct nlattr *start)" .br .ti -1c .RI "void \fBmnl_attr_nest_cancel\fP (struct nlmsghdr *nlh, struct nlattr *start)" .br .in -1c .SH "Detailed Description" .PP Netlink Type-Length-Value (TLV) attribute: .PP .nf |<-- 2 bytes -->|<-- 2 bytes -->|<-- variable -->| ------------------------------------------------- | length | type | value | ------------------------------------------------- |<--------- header ------------>|<-- payload --->| .fi .PP The payload of the Netlink message contains sequences of attributes that are expressed in TLV format\&. .SH "Function Documentation" .PP .SS "uint16_t mnl_attr_get_len (const struct nlattr * attr)" mnl_attr_get_len - get length of netlink attribute .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute .RE .PP This function returns the attribute length that is the attribute header plus the attribute payload\&. .PP Definition at line \fB50\fP of file \fBattr\&.c\fP\&. .SS "void * mnl_attr_get_payload (const struct nlattr * attr)" mnl_attr_get_payload - get pointer to the attribute payload .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute .RE .PP This function return a pointer to the attribute payload\&. .PP Definition at line \fB72\fP of file \fBattr\&.c\fP\&. .SS "uint16_t mnl_attr_get_payload_len (const struct nlattr * attr)" mnl_attr_get_payload_len - get the attribute payload-value length .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute .RE .PP This function returns the attribute payload-value length\&. .PP Definition at line \fB61\fP of file \fBattr\&.c\fP\&. .SS "const char * mnl_attr_get_str (const struct nlattr * attr)" mnl_attr_get_str - returns pointer to string attribute\&. .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute .RE .PP This function returns the payload of string attribute value\&. .PP Definition at line \fB380\fP of file \fBattr\&.c\fP\&. .SS "uint16_t mnl_attr_get_type (const struct nlattr * attr)" mnl_attr_get_type - get type of netlink attribute .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute .RE .PP This function returns the attribute type\&. .PP Definition at line \fB38\fP of file \fBattr\&.c\fP\&. .SS "uint16_t mnl_attr_get_u16 (const struct nlattr * attr)" mnl_attr_get_u16 - returns 16-bit unsigned integer attribute payload .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute .RE .PP This function returns the 16-bit value of the attribute payload\&. .PP Definition at line \fB343\fP of file \fBattr\&.c\fP\&. .SS "uint32_t mnl_attr_get_u32 (const struct nlattr * attr)" mnl_attr_get_u32 - returns 32-bit unsigned integer attribute payload .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute .RE .PP This function returns the 32-bit value of the attribute payload\&. .PP Definition at line \fB354\fP of file \fBattr\&.c\fP\&. .SS "uint64_t mnl_attr_get_u64 (const struct nlattr * attr)" mnl_attr_get_u64 - returns 64-bit unsigned integer attribute\&. .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute .RE .PP 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\&. .PP Definition at line \fB367\fP of file \fBattr\&.c\fP\&. .SS "uint8_t mnl_attr_get_u8 (const struct nlattr * attr)" mnl_attr_get_u8 - returns 8-bit unsigned integer attribute payload .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute .RE .PP This function returns the 8-bit value of the attribute payload\&. .PP Definition at line \fB332\fP of file \fBattr\&.c\fP\&. .SS "void mnl_attr_nest_cancel (struct nlmsghdr * nlh, struct nlattr * start)" mnl_attr_nest_cancel - cancel an attribute nest .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fIstart\fP pointer to the attribute nest returned by \fBmnl_attr_nest_start()\fP .RE .PP This function updates the attribute header that identifies the nest\&. .PP Definition at line \fB714\fP of file \fBattr\&.c\fP\&. .SS "void mnl_attr_nest_end (struct nlmsghdr * nlh, struct nlattr * start)" mnl_attr_nest_end - end an attribute nest .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fIstart\fP pointer to the attribute nest returned by \fBmnl_attr_nest_start()\fP .RE .PP This function updates the attribute header that identifies the nest\&. .PP Definition at line \fB701\fP of file \fBattr\&.c\fP\&. .SS "struct nlattr * mnl_attr_nest_start (struct nlmsghdr * nlh, uint16_t type)" mnl_attr_nest_start - start an attribute nest .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fItype\fP netlink attribute type .RE .PP 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\&. .PP Definition at line \fB514\fP of file \fBattr\&.c\fP\&. .SS "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 .PP \fBParameters\fP .RS 4 \fIbuflen\fP size of buffer which stores the message .br \fInlh\fP pointer to the netlink message .br \fItype\fP netlink attribute type .RE .PP 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\&. .PP Definition at line \fB685\fP of file \fBattr\&.c\fP\&. .SS "struct nlattr * mnl_attr_next (const struct nlattr * attr)" mnl_attr_next - get the next attribute in the payload of a netlink message .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to the current attribute .RE .PP This function returns a pointer to the next attribute after the one passed as parameter\&. You have to use \fBmnl_attr_ok()\fP to ensure that the next attribute is valid\&. .PP Definition at line \fB108\fP of file \fBattr\&.c\fP\&. .SS "bool mnl_attr_ok (const struct nlattr * attr, int len)" mnl_attr_ok - check if there is room for an attribute in a buffer .PP \fBParameters\fP .RS 4 \fIattr\fP attribute that we want to check if there is room for .br \fIlen\fP remaining bytes in a buffer that contains the attribute .RE .PP 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\&. .PP 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\&. .PP The len parameter may be negative in the case of malformed messages during attribute iteration, that is why we use a signed integer\&. .PP Definition at line \fB93\fP of file \fBattr\&.c\fP\&. .SS "int mnl_attr_parse (const struct nlmsghdr * nlh, unsigned int offset, mnl_attr_cb_t cb, void * data)" mnl_attr_parse - parse attributes .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to netlink message .br \fIoffset\fP offset to start parsing from (if payload is after any header) .br \fIcb\fP callback function that is called for each attribute .br \fIdata\fP pointer to data that is passed to the callback function .RE .PP 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)\&. .PP This function propagates the return value of the callback, which can be MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP\&. .PP Definition at line \fB255\fP of file \fBattr\&.c\fP\&. .SS "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 .PP \fBParameters\fP .RS 4 \fInested\fP pointer to netlink attribute that contains a nest .br \fIcb\fP callback function that is called for each attribute in the nest .br \fIdata\fP pointer to data passed to the callback function .RE .PP 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)\&. .PP This function propagates the return value of the callback, which can be MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP\&. .PP Definition at line \fB282\fP of file \fBattr\&.c\fP\&. .SS "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 .PP \fBParameters\fP .RS 4 \fIpayload\fP pointer to payload of the Netlink message .br \fIpayload_len\fP payload length that contains the attributes .br \fIcb\fP callback function that is called for each attribute .br \fIdata\fP pointer to data that is passed to the callback function .RE .PP This function takes a pointer to the area that contains the attributes, commonly known as the payload of the Netlink message\&. Thus, you have to pass a pointer to the Netlink message payload, instead of the entire message\&. .PP This function allows you to iterate over the sequence of attributes that are located at some payload offset\&. You can then put the attributes in one array as usual, or you can use any other data structure (such as lists or trees)\&. .PP This function propagates the return value of the callback, which can be MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP\&. .PP Definition at line \fB313\fP of file \fBattr\&.c\fP\&. .SS "void mnl_attr_put (struct nlmsghdr * nlh, uint16_t type, size_t len, const void * data)" mnl_attr_put - add an attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fItype\fP netlink attribute type that you want to add .br \fIlen\fP netlink attribute payload length .br \fIdata\fP pointer to the data that will be stored by the new attribute .RE .PP This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute\&. .PP Definition at line \fB395\fP of file \fBattr\&.c\fP\&. .SS "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 netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fIbuflen\fP size of buffer which stores the message .br \fItype\fP netlink attribute type that you want to add .br \fIlen\fP netlink attribute payload length .br \fIdata\fP pointer to the data that will be stored by the new attribute .RE .PP 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\&. .PP Definition at line \fB540\fP of file \fBattr\&.c\fP\&. .SS "void mnl_attr_put_str (struct nlmsghdr * nlh, uint16_t type, const char * data)" mnl_attr_put_str - add string attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fItype\fP netlink attribute type .br \fIdata\fP pointer to string data that is stored by the new attribute .RE .PP This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute\&. .PP Definition at line \fB481\fP of file \fBattr\&.c\fP\&. .SS "bool mnl_attr_put_str_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, const char * data)" mnl_attr_put_str_check - add string attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fIbuflen\fP size of buffer which stores the message .br \fItype\fP netlink attribute type .br \fIdata\fP pointer to string data that is stored by the new attribute .RE .PP 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\&. .PP Definition at line \fB647\fP of file \fBattr\&.c\fP\&. .SS "void mnl_attr_put_strz (struct nlmsghdr * nlh, uint16_t type, const char * data)" mnl_attr_put_strz - add string attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fItype\fP netlink attribute type .br \fIdata\fP pointer to string data that is stored by the new attribute .RE .PP This function is similar to mnl_attr_put_str, but it includes the NUL/zero ('\\0') terminator at the end of the string\&. .PP This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute\&. .PP Definition at line \fB499\fP of file \fBattr\&.c\fP\&. .SS "bool mnl_attr_put_strz_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, const char * data)" mnl_attr_put_strz_check - add string attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fIbuflen\fP size of buffer which stores the message .br \fItype\fP netlink attribute type .br \fIdata\fP pointer to string data that is stored by the new attribute .RE .PP This function is similar to mnl_attr_put_str, but it includes the NUL/zero ('\\0') terminator at the end of the string\&. .PP 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\&. .PP Definition at line \fB669\fP of file \fBattr\&.c\fP\&. .SS "void mnl_attr_put_u16 (struct nlmsghdr * nlh, uint16_t type, uint16_t data)" mnl_attr_put_u16 - add 16-bit unsigned integer attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fItype\fP netlink attribute type .br \fIdata\fP 16-bit unsigned integer data that is stored by the new attribute .RE .PP This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute\&. .PP Definition at line \fB436\fP of file \fBattr\&.c\fP\&. .SS "bool mnl_attr_put_u16_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, uint16_t data)" mnl_attr_put_u16_check - add 16-bit unsigned int attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fIbuflen\fP size of buffer which stores the message .br \fItype\fP netlink attribute type .br \fIdata\fP 16-bit unsigned integer data that is stored by the new attribute .RE .PP 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\&. .PP Definition at line \fB584\fP of file \fBattr\&.c\fP\&. .SS "void mnl_attr_put_u32 (struct nlmsghdr * nlh, uint16_t type, uint32_t data)" mnl_attr_put_u32 - add 32-bit unsigned integer attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fItype\fP netlink attribute type .br \fIdata\fP 32-bit unsigned integer data that is stored by the new attribute .RE .PP This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute\&. .PP Definition at line \fB451\fP of file \fBattr\&.c\fP\&. .SS "bool mnl_attr_put_u32_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, uint32_t data)" mnl_attr_put_u32_check - add 32-bit unsigned int attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fIbuflen\fP size of buffer which stores the message .br \fItype\fP netlink attribute type .br \fIdata\fP 32-bit unsigned integer data that is stored by the new attribute .RE .PP 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\&. .PP Definition at line \fB605\fP of file \fBattr\&.c\fP\&. .SS "void mnl_attr_put_u64 (struct nlmsghdr * nlh, uint16_t type, uint64_t data)" mnl_attr_put_u64 - add 64-bit unsigned integer attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fItype\fP netlink attribute type .br \fIdata\fP 64-bit unsigned integer data that is stored by the new attribute .RE .PP This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute\&. .PP Definition at line \fB466\fP of file \fBattr\&.c\fP\&. .SS "bool mnl_attr_put_u64_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, uint64_t data)" mnl_attr_put_u64_check - add 64-bit unsigned int attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fIbuflen\fP size of buffer which stores the message .br \fItype\fP netlink attribute type .br \fIdata\fP 64-bit unsigned integer data that is stored by the new attribute .RE .PP 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\&. .PP Definition at line \fB626\fP of file \fBattr\&.c\fP\&. .SS "void mnl_attr_put_u8 (struct nlmsghdr * nlh, uint16_t type, uint8_t data)" mnl_attr_put_u8 - add 8-bit unsigned integer attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fItype\fP netlink attribute type .br \fIdata\fP 8-bit unsigned integer data that is stored by the new attribute .RE .PP This function updates the length field of the Netlink message (nlmsg_len) by adding the size (header + payload) of the new attribute\&. .PP Definition at line \fB421\fP of file \fBattr\&.c\fP\&. .SS "bool mnl_attr_put_u8_check (struct nlmsghdr * nlh, size_t buflen, uint16_t type, uint8_t data)" mnl_attr_put_u8_check - add 8-bit unsigned int attribute to netlink message .PP \fBParameters\fP .RS 4 \fInlh\fP pointer to the netlink message .br \fIbuflen\fP size of buffer which stores the message .br \fItype\fP netlink attribute type .br \fIdata\fP 8-bit unsigned integer data that is stored by the new attribute .RE .PP 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\&. .PP Definition at line \fB563\fP of file \fBattr\&.c\fP\&. .SS "int mnl_attr_type_valid (const struct nlattr * attr, uint16_t max)" mnl_attr_type_valid - check if the attribute type is valid .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to attribute to be checked .br \fImax\fP maximum attribute type .RE .PP This function allows one to check if the attribute type is higher than the maximum supported type\&. If the attribute type is invalid, this function returns -1 and errno is explicitly set\&. On success, this function returns 1\&. .PP Strict attribute checking in user-space is not a good idea since you may run an old application with a newer kernel that supports new attributes\&. This leads to backward compatibility breakages in user-space\&. Better check if you support an attribute, if not, skip it\&. .PP Definition at line \fB127\fP of file \fBattr\&.c\fP\&. .SS "int mnl_attr_validate (const struct nlattr * attr, enum mnl_attr_data_type type)" mnl_attr_validate - validate netlink attribute (simplified version) .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute that we want to validate .br \fItype\fP data type (see enum mnl_attr_data_type) .RE .PP The validation is based on the data type\&. Specifically, it checks that integers (u8, u16, u32 and u64) have enough room for them\&. This function returns -1 in case of error, and errno is explicitly set\&. .PP Definition at line \fB207\fP of file \fBattr\&.c\fP\&. .SS "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) .PP \fBParameters\fP .RS 4 \fIattr\fP pointer to netlink attribute that we want to validate .br \fItype\fP attribute type (see enum mnl_attr_data_type) .br \fIexp_len\fP expected attribute data size .RE .PP This function allows one to perform a more accurate validation for attributes whose size is variable\&. If the size of the attribute is not what is expected, this functions returns -1 and errno is explicitly set\&. .PP Definition at line \fB229\fP of file \fBattr\&.c\fP\&. .SH "Author" .PP Generated automatically by Doxygen for libmnl from the source code\&.