netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
attr.c File Reference
#include <netlink-local.h>
#include <netlink/netlink.h>
#include <netlink/utils.h>
#include <netlink/addr.h>
#include <netlink/attr.h>
#include <netlink/msg.h>
#include <linux/socket.h>
Include dependency graph for attr.c:

Functions

Attribute Size Calculation
int nla_attr_size (int payload)
 Return size of attribute whithout padding. More...
 
int nla_total_size (int payload)
 Return size of attribute including padding. More...
 
int nla_padlen (int payload)
 Return length of padding at the tail of the attribute. More...
 
Helper Functions
int nla_memcpy (void *dest, struct nlattr *src, int count)
 Copy attribute payload to another memory area. More...
 
size_t nla_strlcpy (char *dst, const struct nlattr *nla, size_t dstsize)
 Copy string attribute payload to a buffer. More...
 
int nla_memcmp (const struct nlattr *nla, const void *data, size_t size)
 Compare attribute payload with memory area. More...
 
int nla_strcmp (const struct nlattr *nla, const char *str)
 Compare string attribute payload with string. More...
 
Unspecific Attribute
struct nlattrnla_reserve (struct nl_msg *msg, int attrtype, int attrlen)
 Reserve space for a attribute. More...
 
int nla_put (struct nl_msg *msg, int attrtype, int datalen, const void *data)
 Add a unspecific attribute to netlink message. More...
 
int nla_put_data (struct nl_msg *msg, int attrtype, struct nl_data *data)
 Add abstract data as unspecific attribute to netlink message. More...
 
int nla_put_addr (struct nl_msg *msg, int attrtype, struct nl_addr *addr)
 Add abstract address as unspecific attribute to netlink message. More...
 
Integer Attributes
int nla_put_u8 (struct nl_msg *msg, int attrtype, uint8_t value)
 Add 8 bit integer attribute to netlink message. More...
 
uint8_t nla_get_u8 (struct nlattr *nla)
 Return value of 8 bit integer attribute. More...
 
int nla_put_u16 (struct nl_msg *msg, int attrtype, uint16_t value)
 Add 16 bit integer attribute to netlink message. More...
 
uint16_t nla_get_u16 (struct nlattr *nla)
 Return payload of 16 bit integer attribute. More...
 
int nla_put_u32 (struct nl_msg *msg, int attrtype, uint32_t value)
 Add 32 bit integer attribute to netlink message. More...
 
uint32_t nla_get_u32 (struct nlattr *nla)
 Return payload of 32 bit integer attribute. More...
 
int nla_put_u64 (struct nl_msg *msg, int attrtype, uint64_t value)
 Add 64 bit integer attribute to netlink message. More...
 
uint64_t nla_get_u64 (struct nlattr *nla)
 Return payload of u64 attribute. More...
 
String Attribute
int nla_put_string (struct nl_msg *msg, int attrtype, const char *str)
 Add string attribute to netlink message. More...
 
char * nla_get_string (struct nlattr *nla)
 Return payload of string attribute. More...
 
char * nla_strdup (struct nlattr *nla)
 
Flag Attribute
int nla_put_flag (struct nl_msg *msg, int attrtype)
 Add flag netlink attribute to netlink message. More...
 
int nla_get_flag (struct nlattr *nla)
 Return true if flag attribute is set. More...
 
Microseconds Attribute
int nla_put_msecs (struct nl_msg *n, int attrtype, unsigned long msecs)
 Add a msecs netlink attribute to a netlink message. More...
 
unsigned long nla_get_msecs (struct nlattr *nla)
 Return payload of msecs attribute. More...
 
Nested Attribute
int nla_put_nested (struct nl_msg *msg, int attrtype, struct nl_msg *nested)
 Add nested attributes to netlink message. More...
 
struct nlattrnla_nest_start (struct nl_msg *msg, int attrtype)
 Start a new level of nested attributes. More...
 
int nla_nest_end (struct nl_msg *msg, struct nlattr *start)
 Finalize nesting of attributes. More...
 
int nla_parse_nested (struct nlattr *tb[], int maxtype, struct nlattr *nla, struct nla_policy *policy)
 Create attribute index based on nested attribute. More...
 

Parsing Attributes

int nla_type (const struct nlattr *nla)
 Return type of the attribute. More...
 
void * nla_data (const struct nlattr *nla)
 Return pointer to the payload section. More...
 
int nla_len (const struct nlattr *nla)
 Return length of the payload . More...
 
int nla_ok (const struct nlattr *nla, int remaining)
 Check if the attribute header and payload can be accessed safely. More...
 
struct nlattrnla_next (const struct nlattr *nla, int *remaining)
 Return next attribute in a stream of attributes. More...
 
int nla_parse (struct nlattr *tb[], int maxtype, struct nlattr *head, int len, struct nla_policy *policy)
 Create attribute index based on a stream of attributes. More...
 
int nla_validate (struct nlattr *head, int len, int maxtype, struct nla_policy *policy)
 Validate a stream of attributes. More...
 
struct nlattrnla_find (struct nlattr *head, int len, int attrtype)
 Find a single attribute in a stream of attributes. More...