Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
netlink.h File Reference
#include <linux/types.h>
#include <linux/netlink.h>
#include <linux/jiffies.h>

Go to the source code of this file.

Data Structures

struct  nla_policy
 
struct  nl_info
 

Macros

#define NLA_TYPE_MAX   (__NLA_TYPE_MAX - 1)
 
#define nlmsg_for_each_attr(pos, nlh, hdrlen, rem)
 
#define nlmsg_for_each_msg(pos, head, len, rem)
 
#define nla_for_each_attr(pos, head, len, rem)
 
#define nla_for_each_nested(pos, nla, rem)   nla_for_each_attr(pos, nla_data(nla), nla_len(nla), rem)
 

Enumerations

enum  {
  NLA_UNSPEC, NLA_U8, NLA_U16, NLA_U32,
  NLA_U64, NLA_STRING, NLA_FLAG, NLA_MSECS,
  NLA_NESTED, NLA_NESTED_COMPAT, NLA_NUL_STRING, NLA_BINARY,
  NLA_S8, NLA_S16, NLA_S32, NLA_S64,
  __NLA_TYPE_MAX
}
 

Functions

int netlink_rcv_skb (struct sk_buff *skb, int(*cb)(struct sk_buff *, struct nlmsghdr *))
 
int nlmsg_notify (struct sock *sk, struct sk_buff *skb, u32 portid, unsigned int group, int report, gfp_t flags)
 
int nla_validate (const struct nlattr *head, int len, int maxtype, const struct nla_policy *policy)
 
int nla_parse (struct nlattr **tb, int maxtype, const struct nlattr *head, int len, const struct nla_policy *policy)
 
int nla_policy_len (const struct nla_policy *, int)
 
struct nlattrnla_find (const struct nlattr *head, int len, int attrtype)
 
size_t nla_strlcpy (char *dst, const struct nlattr *nla, size_t dstsize)
 
int nla_memcpy (void *dest, const struct nlattr *src, int count)
 
int nla_memcmp (const struct nlattr *nla, const void *data, size_t size)
 
int nla_strcmp (const struct nlattr *nla, const char *str)
 
struct nlattr__nla_reserve (struct sk_buff *skb, int attrtype, int attrlen)
 
void__nla_reserve_nohdr (struct sk_buff *skb, int attrlen)
 
struct nlattrnla_reserve (struct sk_buff *skb, int attrtype, int attrlen)
 
voidnla_reserve_nohdr (struct sk_buff *skb, int attrlen)
 
void __nla_put (struct sk_buff *skb, int attrtype, int attrlen, const void *data)
 
void __nla_put_nohdr (struct sk_buff *skb, int attrlen, const void *data)
 
int nla_put (struct sk_buff *skb, int attrtype, int attrlen, const void *data)
 
int nla_put_nohdr (struct sk_buff *skb, int attrlen, const void *data)
 
int nla_append (struct sk_buff *skb, int attrlen, const void *data)
 

Macro Definition Documentation

#define nla_for_each_attr (   pos,
  head,
  len,
  rem 
)
Value:
for (pos = head, rem = len; \
nla_ok(pos, rem); \
pos = nla_next(pos, &(rem)))

nla_for_each_attr - iterate over a stream of attributes : loop counter, set to current attribute : head of attribute stream : length of attribute stream : initialized to len, holds bytes currently remaining in stream

Definition at line 1187 of file netlink.h.

#define nla_for_each_nested (   pos,
  nla,
  rem 
)    nla_for_each_attr(pos, nla_data(nla), nla_len(nla), rem)

nla_for_each_nested - iterate over nested attributes : loop counter, set to current attribute : attribute containing the nested attributes : initialized to len, holds bytes currently remaining in stream

Definition at line 1198 of file netlink.h.

#define NLA_TYPE_MAX   (__NLA_TYPE_MAX - 1)

Definition at line 178 of file netlink.h.

#define nlmsg_for_each_attr (   pos,
  nlh,
  hdrlen,
  rem 
)
Value:
nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \
nlmsg_attrlen(nlh, hdrlen), rem)

nlmsg_for_each_attr - iterate over a stream of attributes : loop counter, set to current attribute : netlink message header : length of familiy specific header : initialized to len, holds bytes currently remaining in stream

Definition at line 440 of file netlink.h.

#define nlmsg_for_each_msg (   pos,
  head,
  len,
  rem 
)
Value:
for (pos = head, rem = len; \
nlmsg_ok(pos, rem); \
pos = nlmsg_next(pos, &(rem)))

nlmsg_for_each_msg - iterate over a stream of messages : loop counter, set to current message : head of message stream : length of message stream : initialized to len, holds bytes currently remaining in stream

Definition at line 608 of file netlink.h.

Enumeration Type Documentation

anonymous enum

Standard attribute types to specify validation policy

Enumerator:
NLA_UNSPEC 
NLA_U8 
NLA_U16 
NLA_U32 
NLA_U64 
NLA_STRING 
NLA_FLAG 
NLA_MSECS 
NLA_NESTED 
NLA_NESTED_COMPAT 
NLA_NUL_STRING 
NLA_BINARY 
NLA_S8 
NLA_S16 
NLA_S32 
NLA_S64 
__NLA_TYPE_MAX 

Definition at line 158 of file netlink.h.

Function Documentation

void __nla_put ( struct sk_buff skb,
int  attrtype,
int  attrlen,
const void data 
)
void __nla_put_nohdr ( struct sk_buff skb,
int  attrlen,
const void data 
)
struct nlattr* __nla_reserve ( struct sk_buff skb,
int  attrtype,
int  attrlen 
)
read
void* __nla_reserve_nohdr ( struct sk_buff skb,
int  attrlen 
)
int netlink_rcv_skb ( struct sk_buff skb,
int(*)(struct sk_buff *, struct nlmsghdr *)  cb 
)
int nla_append ( struct sk_buff skb,
int  attrlen,
const void data 
)
struct nlattr* nla_find ( const struct nlattr head,
int  len,
int  attrtype 
)
read

nla_find - Find a specific attribute in a stream of attributes : head of attribute stream : length of attribute stream : type of attribute to look for

Returns the first attribute in the stream matching the specified type.

Definition at line 220 of file nlattr.c.

int nla_memcmp ( const struct nlattr nla,
const void data,
size_t  size 
)

nla_memcmp - Compare an attribute with sized memory area : netlink attribute : memory area : size of memory area

Definition at line 288 of file nlattr.c.

int nla_memcpy ( void dest,
const struct nlattr src,
int  count 
)

nla_memcpy - Copy a netlink attribute into another memory area : where to copy to memcpy : netlink attribute to copy from : size of the destination area

Note: The number of bytes copied is limited by the length of attribute's payload. memcpy

Returns the number of bytes copied.

Definition at line 273 of file nlattr.c.

int nla_parse ( struct nlattr **  tb,
int  maxtype,
const struct nlattr head,
int  len,
const struct nla_policy policy 
)

nla_parse - Parse a stream of attributes into a tb buffer : destination array with maxtype+1 elements : maximum attribute type to be expected : head of attribute stream : length of attribute stream : validation policy

Parses a stream of attributes and stores a pointer to each attribute in the tb array accessible via the attribute type. Attributes with a type exceeding maxtype will be silently ignored for backwards compatibility reasons. policy may be set to NULL if no validation is required.

Returns 0 on success or a negative error code.

Definition at line 181 of file nlattr.c.

int nla_policy_len ( const struct nla_policy p,
int  n 
)

nla_policy_len - Determin the max. length of a policy : policy to use
: number of policies

Determines the max. length of the policy. It is currently used to allocated Netlink buffers roughly the size of the actual message.

Returns 0 on success or a negative error code.

Definition at line 152 of file nlattr.c.

int nla_put ( struct sk_buff skb,
int  attrtype,
int  attrlen,
const void data 
)
int nla_put_nohdr ( struct sk_buff skb,
int  attrlen,
const void data 
)
struct nlattr* nla_reserve ( struct sk_buff skb,
int  attrtype,
int  attrlen 
)
read
void* nla_reserve_nohdr ( struct sk_buff skb,
int  attrlen 
)
int nla_strcmp ( const struct nlattr nla,
const char str 
)

nla_strcmp - Compare a string attribute against a string : netlink string attribute : another string

Definition at line 304 of file nlattr.c.

size_t nla_strlcpy ( char dst,
const struct nlattr nla,
size_t  dstsize 
)

nla_strlcpy - Copy string attribute payload into a sized buffer : where to copy the string to : attribute to copy the string from : size of destination buffer

Copies at most dstsize - 1 bytes into the destination buffer. The result is always a valid NUL-terminated string. Unlike strlcpy the destination buffer is always padded out.

Returns the length of the source buffer.

Definition at line 244 of file nlattr.c.

int nla_validate ( const struct nlattr head,
int  len,
int  maxtype,
const struct nla_policy policy 
)

nla_validate - Validate a stream of attributes : head of attribute stream : length of attribute stream : maximum attribute type to be expected : validation policy

Validates all attributes in the specified attribute stream against the specified policy. Attributes with a type exceeding maxtype will be ignored. See documenation of struct nla_policy for more details.

Returns 0 on success or a negative error code.

Definition at line 123 of file nlattr.c.

int nlmsg_notify ( struct sock sk,
struct sk_buff skb,
u32  portid,
unsigned int  group,
int  report,
gfp_t  flags 
)