Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
nlattr.c File Reference
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/jiffies.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/string.h>
#include <linux/types.h>
#include <net/netlink.h>

Go to the source code of this file.

Functions

int nla_validate (const struct nlattr *head, int len, int maxtype, const struct nla_policy *policy)
 
int nla_policy_len (const struct nla_policy *p, int n)
 
int nla_parse (struct nlattr **tb, int maxtype, const struct nlattr *head, int len, const struct nla_policy *policy)
 
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)
 
 EXPORT_SYMBOL (nla_validate)
 
 EXPORT_SYMBOL (nla_policy_len)
 
 EXPORT_SYMBOL (nla_parse)
 
 EXPORT_SYMBOL (nla_find)
 
 EXPORT_SYMBOL (nla_strlcpy)
 
 EXPORT_SYMBOL (nla_memcpy)
 
 EXPORT_SYMBOL (nla_memcmp)
 
 EXPORT_SYMBOL (nla_strcmp)
 

Function Documentation

EXPORT_SYMBOL ( nla_validate  )
EXPORT_SYMBOL ( nla_policy_len  )
EXPORT_SYMBOL ( nla_parse  )
EXPORT_SYMBOL ( nla_find  )
EXPORT_SYMBOL ( nla_strlcpy  )
EXPORT_SYMBOL ( nla_memcpy  )
EXPORT_SYMBOL ( nla_memcmp  )
EXPORT_SYMBOL ( nla_strcmp  )
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_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.