Data Structures | |
struct | nla_policy |
attribute validation policy More... | |
Validation Policy Types | |
enum | { NLA_UNSPEC, NLA_U8, NLA_U16, NLA_U32, NLA_U64, NLA_STRING, NLA_FLAG, NLA_MSECS, NLA_NESTED, __NLA_TYPE_MAX } |
Standard attribute types to specify validation policy. More... | |
#define | NLA_TYPE_MAX (__NLA_TYPE_MAX - 1) |
Maximum netlink validation policy type. | |
Attribute Parsing | |
int | nla_ok (const struct nlattr *nla, int remaining) |
check if the netlink attribute fits into the remaining bytes | |
struct nlattr * | nla_next (const struct nlattr *nla, int *remaining) |
next netlink attribte in attribute stream | |
int | nla_parse (struct nlattr *tb[], int maxtype, struct nlattr *head, int len, struct nla_policy *policy) |
Parse a stream of attributes into a tb buffer. | |
int | nla_parse_nested (struct nlattr *tb[], int maxtype, struct nlattr *nla, struct nla_policy *policy) |
parse nested attributes | |
int | nla_validate (struct nlattr *head, int len, int maxtype, struct nla_policy *policy) |
Validate a stream of attributes. | |
struct nlattr * | nla_find (struct nlattr *head, int len, int attrtype) |
Find a specific attribute in a stream of attributes. | |
Size Calculations | |
int | nla_attr_size (int payload) |
length of attribute not including padding | |
int | nla_total_size (int payload) |
total length of attribute including padding | |
int | nla_padlen (int payload) |
length of padding at the tail of the attribute | |
Payload Access | |
int | nla_type (const struct nlattr *nla) |
attribute type | |
void * | nla_data (const struct nlattr *nla) |
head of payload | |
int | nla_len (const struct nlattr *nla) |
length of payload | |
Utilities | |
int | nla_memcpy (void *dest, struct nlattr *src, int count) |
Copy a netlink attribute into another memory area. | |
size_t | nla_strlcpy (char *dst, const struct nlattr *nla, size_t dstsize) |
Copy string attribute payload into a sized buffer. | |
int | nla_memcmp (const struct nlattr *nla, const void *data, size_t size) |
Compare an attribute with sized memory area. | |
int | nla_strcmp (const struct nlattr *nla, const char *str) |
Compare a string attribute against a string. | |
Attribute Construction | |
struct nlattr * | nla_reserve (struct nl_msg *n, int attrtype, int attrlen) |
reserve room for attribute on the skb | |
int | nla_put (struct nl_msg *n, int attrtype, int attrlen, const void *data) |
Add a netlink attribute to a netlink message. | |
int | nla_put_nested (struct nl_msg *n, int attrtype, struct nl_msg *nested) |
Add a nested netlink attribute to a netlink message. | |
int | nla_put_u8 (struct nl_msg *n, int attrtype, uint8_t value) |
Add a u16 netlink attribute to a netlink message. | |
int | nla_put_u16 (struct nl_msg *n, int attrtype, uint16_t value) |
Add a u16 netlink attribute to a netlink message. | |
int | nla_put_u32 (struct nl_msg *n, int attrtype, uint32_t value) |
Add a u32 netlink attribute to a netlink message. | |
int | nla_put_u64 (struct nl_msg *n, int attrtype, uint64_t value) |
Add a u64 netlink attribute to a netlink message. | |
int | nla_put_string (struct nl_msg *n, int attrtype, const char *str) |
Add a string netlink attribute to a netlink message. | |
int | nla_put_flag (struct nl_msg *n, int attrtype) |
Add a flag netlink attribute to a netlink message. | |
int | nla_put_msecs (struct nl_msg *n, int attrtype, unsigned long msecs) |
Add a msecs netlink attribute to a netlink message. | |
int | nla_put_data (struct nl_msg *n, int attrtype, struct nl_data *data) |
Add an abstract data netlink attribute to a netlink message. | |
int | nla_put_addr (struct nl_msg *n, int attrtype, struct nl_addr *addr) |
Add an abstract address netlink attribute to a netlink message. | |
Attribute Nesting | |
struct nlattr * | nla_nest_start (struct nl_msg *n, int attrtype) |
Start a new level of nested attributes. | |
int | nla_nest_end (struct nl_msg *n, struct nlattr *start) |
Finalize nesting of attributes. | |
Attribute Reading | |
uint32_t | nla_get_u32 (struct nlattr *nla) |
Return payload of u32 attribute. | |
uint16_t | nla_get_u16 (struct nlattr *nla) |
Return payload of u16 attribute. | |
uint8_t | nla_get_u8 (struct nlattr *nla) |
Return payload of u8 attribute. | |
uint64_t | nla_get_u64 (struct nlattr *nla) |
Return payload of u64 attribute. | |
char * | nla_get_string (struct nlattr *nla) |
return payload of string attribute | |
int | nla_get_flag (struct nlattr *nla) |
Return payload of flag attribute. | |
unsigned long | nla_get_msecs (struct nlattr *nla) |
Return payload of msecs attribute. | |
struct nl_addr * | nla_get_addr (struct nlattr *nla, int family) |
Return payload of address attribute. | |
struct nl_data * | nla_get_data (struct nlattr *nla) |
Return payload of abstract data attribute. | |
Attribute Construction (Exception Based) | |
All these functions jump to nla_put_failure in case of a failure instead of returning an error code. | |
#define | NLA_PUT(n, attrtype, attrlen, data) |
Add a netlink attribute to a netlink message. | |
#define | NLA_PUT_TYPE(n, type, attrtype, value) |
Add a basic netlink attribute to a netlink message. | |
#define | NLA_PUT_U8(n, attrtype, value) NLA_PUT_TYPE(n, uint8_t, attrtype, value) |
Add a u8 netlink attribute to a netlink message. | |
#define | NLA_PUT_U16(n, attrtype, value) NLA_PUT_TYPE(n, uint16_t, attrtype, value) |
Add a u16 netlink attribute to a netlink message. | |
#define | NLA_PUT_U32(n, attrtype, value) NLA_PUT_TYPE(n, uint32_t, attrtype, value) |
Add a u32 netlink attribute to a netlink message. | |
#define | NLA_PUT_U64(n, attrtype, value) NLA_PUT_TYPE(n, uint64_t, attrtype, value) |
Add a u64 netlink attribute to a netlink message. | |
#define | NLA_PUT_STRING(n, attrtype, value) NLA_PUT(n, attrtype, strlen(value) + 1, value) |
Add a character string netlink attribute to a netlink message. | |
#define | NLA_PUT_FLAG(n, attrtype) NLA_PUT(n, attrtype, 0, NULL) |
Add a flag netlink attribute to a netlink message. | |
#define | NLA_PUT_MSECS(n, attrtype, msecs) NLA_PUT_U64(n, attrtype, msecs) |
Add a msecs netlink attribute to a netlink message. | |
#define | NLA_PUT_ADDR(n, attrtype, addr) |
Add a address attribute to a netlink message. | |
Iterators | |
#define | nla_for_each_attr(pos, head, len, rem) |
iterate over a stream of attributes | |
#define | nla_for_each_nested(pos, nla, rem) |
iterate over a stream of nested attributes |
<------- nla_total_size(payload) -------> <---- nla_attr_size(payload) -----> +----------+- - -+- - - - - - - - - +- - -+-------- - - | Header | Pad | Payload | Pad | Header +----------+- - -+- - - - - - - - - +- - -+-------- - - <- nla_len(nla) -> ^ nla_data(nla)----^ | nla_next(nla)-----------------------------'
<------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)--> +---------------------+- - -+- - - - - - - - - -+- - -+ | Header | Pad | Payload | Pad | | (struct nlattr) | ing | | ing | +---------------------+- - -+- - - - - - - - - -+- - -+ <-------------- nlattr->nla_len -------------->
<-------------------- NLA_ALIGN(...) -------------------> +---------------+- - - - - - - - - - - - - - - - - -+- - -+ | |+---------+---------+- - -+-------+| | | TLV Header || TLV 1 | TLV 2 | | TLV n || Pad | | |+---------+---------+- - -+-------+| | +---------------+- - - - - - - - - - - - - - - - - -+- - -+ <--------- nla_data(nla) --------->
int param1 = 10; char *param2 = "parameter text"; struct nl_msg *msg = nlmsg_alloc(); nla_put_u32(msg, 1, param1); nla_put_string(msg, 2, param2); nl_send_auto_complete(handle, nl_msg_get(msg)); nlmsg_free(msg);
struct nl_msg * nested_config(void) { int a = 5, int b = 10; struct nl_msg *n = nlmsg_alloc(); nla_put_u32(n, 10, a); nla_put_u32(n, 20, b); return n; } ... struct nl_msg *m = nlmsg_alloc(); struct nl_msg *nest = nested_config(); nla_put_nested(m, 1, nest); nl_send_auto_complete(handle, nl_msg_get(m)); nlmsg_free(nest); nlmsg_free(m);
#define NLA_PUT | ( | n, | |||
attrtype, | |||||
attrlen, | |||||
data | ) |
#define NLA_PUT_TYPE | ( | n, | |||
type, | |||||
attrtype, | |||||
value | ) |
#define nla_for_each_attr | ( | pos, | |||
head, | |||||
len, | |||||
rem | ) |
Value:
pos | loop counter, set to current attribute | |
head | head of attribute stream | |
len | length of attribute stream | |
rem | initialized to len, holds bytes currently remaining in stream |
Definition at line 264 of file attr.h.
Referenced by nla_find(), nla_parse(), and nla_validate().
#define nla_for_each_nested | ( | pos, | |||
nla, | |||||
rem | ) |
Value:
pos | loop counter, set to current attribute | |
nla | attribute containing the nested attributes | |
rem | initialized to len, holds bytes currently remaining in stream |
#define NLA_PUT_U8 | ( | n, | |||
attrtype, | |||||
value | ) | NLA_PUT_TYPE(n, uint8_t, attrtype, value) |
n | netlink message | |
attrtype | attribute type | |
value | numeric value |
Definition at line 183 of file attr.h.
Referenced by rtnl_link_build_change_request().
#define NLA_PUT_U16 | ( | n, | |||
attrtype, | |||||
value | ) | NLA_PUT_TYPE(n, uint16_t, attrtype, value) |
#define NLA_PUT_U32 | ( | n, | |||
attrtype, | |||||
value | ) | NLA_PUT_TYPE(n, uint32_t, attrtype, value) |
n | netlink message | |
attrtype | attribute type | |
value | numeric value |
Definition at line 201 of file attr.h.
Referenced by rtnl_link_build_change_request().
#define NLA_PUT_U64 | ( | n, | |||
attrtype, | |||||
value | ) | NLA_PUT_TYPE(n, uint64_t, attrtype, value) |
#define NLA_PUT_STRING | ( | n, | |||
attrtype, | |||||
value | ) | NLA_PUT(n, attrtype, strlen(value) + 1, value) |
n | netlink message | |
attrtype | attribute type | |
value | character string |
Definition at line 219 of file attr.h.
Referenced by rtnl_link_build_change_request().
#define NLA_PUT_FLAG | ( | n, | |||
attrtype | ) | NLA_PUT(n, attrtype, 0, NULL) |
#define NLA_PUT_MSECS | ( | n, | |||
attrtype, | |||||
msecs | ) | NLA_PUT_U64(n, attrtype, msecs) |
#define NLA_PUT_ADDR | ( | n, | |||
attrtype, | |||||
addr | ) |
Value:
NLA_PUT(n, attrtype, nl_addr_get_len(addr), \ nl_addr_get_binary_addr(addr))
n | netlink message | |
attrtype | attribute type | |
addr | abstract address object |
Definition at line 245 of file attr.h.
Referenced by rtnl_link_build_change_request().
anonymous enum |
Definition at line 35 of file attr.h.
00035 { 00036 NLA_UNSPEC, /**< Unspecified type */ 00037 NLA_U8, /**< 8bit integer */ 00038 NLA_U16, /**< 16bit integer */ 00039 NLA_U32, /**< 32bit integer */ 00040 NLA_U64, /**< 64bit integer */ 00041 NLA_STRING, /**< character string */ 00042 NLA_FLAG, /**< flag */ 00043 NLA_MSECS, /**< micro seconds (64bit) */ 00044 NLA_NESTED, /**< nested attributes */ 00045 __NLA_TYPE_MAX, 00046 };
int nla_attr_size | ( | int | payload | ) |
payload | length of payload |
Definition at line 108 of file attr.c.
Referenced by nla_padlen(), nla_reserve(), and nla_total_size().
int nla_total_size | ( | int | payload | ) |
payload | length of payload |
Definition at line 117 of file attr.c.
References nla_attr_size().
Referenced by nla_padlen(), and nla_reserve().
00118 { 00119 return NLA_ALIGN(nla_attr_size(payload)); 00120 }
int nla_padlen | ( | int | payload | ) |
payload | length of payload |
Definition at line 126 of file attr.c.
References nla_attr_size(), and nla_total_size().
Referenced by nla_reserve().
00127 { 00128 return nla_total_size(payload) - nla_attr_size(payload); 00129 }
int nla_type | ( | const struct nlattr * | nla | ) |
nla | netlink attribute |
Definition at line 142 of file attr.c.
Referenced by nla_find(), and nla_parse().
void* nla_data | ( | const struct nlattr * | nla | ) |
nla | netlink attribute |
Definition at line 151 of file attr.c.
Referenced by nla_get_addr(), nla_get_data(), nla_get_string(), nla_get_u16(), nla_get_u32(), nla_get_u8(), nla_memcmp(), nla_memcpy(), nla_parse_nested(), nla_put(), nla_strcmp(), and nla_strlcpy().
int nla_len | ( | const struct nlattr * | nla | ) |
nla | netlink attribute |
Definition at line 160 of file attr.c.
Referenced by nla_get_addr(), nla_get_data(), nla_memcmp(), nla_memcpy(), nla_parse_nested(), nla_strcmp(), and nla_strlcpy().
int nla_ok | ( | const struct nlattr * | nla, | |
int | remaining | |||
) |
struct nlattr* nla_next | ( | const struct nlattr * | nla, | |
int * | remaining | |||
) | [read] |
nla | netlink attribute | |
remaining | number of bytes remaining in attribute stream |
Definition at line 192 of file attr.c.
00193 { 00194 int totlen = NLA_ALIGN(nla->nla_len); 00195 00196 *remaining -= totlen; 00197 return (struct nlattr *) ((char *) nla + totlen); 00198 }
int nla_parse | ( | struct nlattr * | tb[], | |
int | maxtype, | |||
struct nlattr * | head, | |||
int | len, | |||
struct nla_policy * | policy | |||
) |
tb | destination array with maxtype+1 elements | |
maxtype | maximum attribute type to be expected | |
head | head of attribute stream | |
len | length of attribute stream | |
policy | validation policy |
Definition at line 262 of file attr.c.
References nla_for_each_attr, and nla_type().
Referenced by nla_parse_nested(), and nlmsg_parse().
00264 { 00265 struct nlattr *nla; 00266 int rem, err; 00267 00268 memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); 00269 00270 nla_for_each_attr(nla, head, len, rem) { 00271 int type = nla_type(nla); 00272 00273 if (type == 0) { 00274 fprintf(stderr, "Illegal nla->nla_type == 0\n"); 00275 continue; 00276 } 00277 00278 if (type <= maxtype) { 00279 if (policy) { 00280 err = validate_nla(nla, maxtype, policy); 00281 if (err < 0) 00282 goto errout; 00283 } 00284 00285 tb[type] = nla; 00286 } 00287 } 00288 00289 if (rem > 0) 00290 fprintf(stderr, "netlink: %d bytes leftover after parsing " 00291 "attributes.\n", rem); 00292 00293 err = 0; 00294 errout: 00295 return err; 00296 }
int nla_parse_nested | ( | struct nlattr * | tb[], | |
int | maxtype, | |||
struct nlattr * | nla, | |||
struct nla_policy * | policy | |||
) |
tb | destination array with maxtype+1 elements | |
maxtype | maximum attribute type to be expected | |
nla | attribute containing the nested attributes | |
policy | validation policy |
Definition at line 308 of file attr.c.
References nla_data(), nla_len(), and nla_parse().
int nla_validate | ( | struct nlattr * | head, | |
int | len, | |||
int | maxtype, | |||
struct nla_policy * | policy | |||
) |
head | head of attribute stream | |
len | length of attribute stream | |
maxtype | maximum attribute type to be expected | |
policy | validation policy |
Definition at line 328 of file attr.c.
References nla_for_each_attr.
Referenced by nlmsg_validate().
00330 { 00331 struct nlattr *nla; 00332 int rem, err; 00333 00334 nla_for_each_attr(nla, head, len, rem) { 00335 err = validate_nla(nla, maxtype, policy); 00336 if (err < 0) 00337 goto errout; 00338 } 00339 00340 err = 0; 00341 errout: 00342 return err; 00343 }
struct nlattr* nla_find | ( | struct nlattr * | head, | |
int | len, | |||
int | attrtype | |||
) | [read] |
head | head of attribute stream | |
len | length of attribute stream | |
attrtype | type of attribute to look for |
Definition at line 353 of file attr.c.
References nla_for_each_attr, and nla_type().
Referenced by nlmsg_find_attr().
00354 { 00355 struct nlattr *nla; 00356 int rem; 00357 00358 nla_for_each_attr(nla, head, len, rem) 00359 if (nla_type(nla) == attrtype) 00360 return nla; 00361 00362 return NULL; 00363 }
int nla_memcpy | ( | void * | dest, | |
struct nlattr * | src, | |||
int | count | |||
) |
dest | where to copy to memcpy | |
src | netlink attribute to copy from | |
count | size of the destination area |
Definition at line 383 of file attr.c.
References nla_data(), and nla_len().
Referenced by nla_get_u64().
00384 { 00385 int minlen; 00386 00387 if (!src) 00388 return 0; 00389 00390 minlen = min_t(int, count, nla_len(src)); 00391 memcpy(dest, nla_data(src), minlen); 00392 00393 return minlen; 00394 }
size_t nla_strlcpy | ( | char * | dst, | |
const struct nlattr * | nla, | |||
size_t | dstsize | |||
) |
dst | where to copy the string to | |
nla | attribute to copy the string from | |
dstsize | size of destination buffer |
Definition at line 408 of file attr.c.
References nla_data(), and nla_len().
00409 { 00410 size_t srclen = nla_len(nla); 00411 char *src = nla_data(nla); 00412 00413 if (srclen > 0 && src[srclen - 1] == '\0') 00414 srclen--; 00415 00416 if (dstsize > 0) { 00417 size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen; 00418 00419 memset(dst, 0, dstsize); 00420 memcpy(dst, src, len); 00421 } 00422 00423 return srclen; 00424 }
int nla_memcmp | ( | const struct nlattr * | nla, | |
const void * | data, | |||
size_t | size | |||
) |
int nla_strcmp | ( | const struct nlattr * | nla, | |
const char * | str | |||
) |
nla | netlink string attribute | |
str | another string |
Definition at line 448 of file attr.c.
References nla_data(), and nla_len().
00449 { 00450 int len = strlen(str) + 1; 00451 int d = nla_len(nla) - len; 00452 00453 if (d == 0) 00454 d = memcmp(nla_data(nla), str, len); 00455 00456 return d; 00457 }
struct nlattr* nla_reserve | ( | struct nl_msg * | n, | |
int | attrtype, | |||
int | attrlen | |||
) | [read] |
n | netlink message | |
attrtype | attribute type | |
attrlen | length of attribute payload |
Definition at line 475 of file attr.c.
References nla_attr_size(), nla_padlen(), nla_total_size(), and nlmsg_data().
Referenced by nla_put().
00476 { 00477 struct nlattr *nla; 00478 int tlen; 00479 00480 tlen = NLMSG_ALIGN(n->nm_nlh->nlmsg_len) + nla_total_size(attrlen); 00481 00482 if ((tlen + n->nm_nlh->nlmsg_len) > n->nm_size) { 00483 nl_errno(ENOBUFS); 00484 return NULL; 00485 } 00486 00487 nla = (struct nlattr *) nlmsg_tail(n->nm_nlh); 00488 nla->nla_type = attrtype; 00489 nla->nla_len = nla_attr_size(attrlen); 00490 00491 memset((unsigned char *) nla + nla->nla_len, 0, nla_padlen(attrlen)); 00492 n->nm_nlh->nlmsg_len = tlen; 00493 00494 NL_DBG(2, "msg %p: Reserved %d bytes at offset +%td for attr %d " 00495 "nlmsg_len=%d\n", n, attrlen, 00496 (void *) nla - nlmsg_data(n->nm_nlh), 00497 attrtype, n->nm_nlh->nlmsg_len); 00498 00499 return nla; 00500 }
int nla_put | ( | struct nl_msg * | n, | |
int | attrtype, | |||
int | attrlen, | |||
const void * | data | |||
) |
n | netlink message | |
attrtype | attribute type | |
attrlen | length of attribute payload | |
data | head of attribute payload |
Definition at line 512 of file attr.c.
References nla_data(), nla_reserve(), and nlmsg_data().
Referenced by nla_nest_start(), nla_put_addr(), nla_put_data(), nla_put_flag(), nla_put_nested(), nla_put_string(), nla_put_u16(), nla_put_u32(), nla_put_u64(), and nla_put_u8().
00513 { 00514 struct nlattr *nla; 00515 00516 nla = nla_reserve(n, attrtype, attrlen); 00517 if (!nla) 00518 return nl_errno(ENOMEM); 00519 00520 memcpy(nla_data(nla), data, attrlen); 00521 NL_DBG(2, "msg %p: Wrote %d bytes at offset +%td for attr %d\n", 00522 n, attrlen, (void *) nla - nlmsg_data(n->nm_nlh), attrtype); 00523 00524 return 0; 00525 }
int nla_put_nested | ( | struct nl_msg * | n, | |
int | attrtype, | |||
struct nl_msg * | nested | |||
) |
n | netlink message | |
attrtype | attribute type | |
nested | netlink attribute to nest |
Definition at line 536 of file attr.c.
References nla_put(), nlmsg_data(), and nlmsg_len().
Referenced by rtnl_neightbl_build_change_request().
00537 { 00538 return nla_put(n, attrtype, nlmsg_len(nested->nm_nlh), 00539 nlmsg_data(nested->nm_nlh)); 00540 }
int nla_put_u8 | ( | struct nl_msg * | n, | |
int | attrtype, | |||
uint8_t | value | |||
) |
int nla_put_u16 | ( | struct nl_msg * | n, | |
int | attrtype, | |||
uint16_t | value | |||
) |
int nla_put_u32 | ( | struct nl_msg * | n, | |
int | attrtype, | |||
uint32_t | value | |||
) |
n | netlink message | |
attrtype | attribute type | |
value | numeric value |
Definition at line 570 of file attr.c.
References nla_put().
Referenced by rtnl_neightbl_build_change_request().
00571 { 00572 return nla_put(n, attrtype, sizeof(uint32_t), &value); 00573 }
int nla_put_u64 | ( | struct nl_msg * | n, | |
int | attrtype, | |||
uint64_t | value | |||
) |
n | netlink message | |
attrtype | attribute type | |
value | numeric value |
Definition at line 581 of file attr.c.
References nla_put().
Referenced by nla_put_msecs(), and rtnl_neightbl_build_change_request().
00582 { 00583 return nla_put(n, attrtype, sizeof(uint64_t), &value); 00584 }
int nla_put_string | ( | struct nl_msg * | n, | |
int | attrtype, | |||
const char * | str | |||
) |
n | netlink message | |
attrtype | attribute type | |
str | NUL terminated string |
Definition at line 592 of file attr.c.
References nla_put().
Referenced by rtnl_neightbl_build_change_request().
00593 { 00594 return nla_put(n, attrtype, strlen(str) + 1, str); 00595 }
int nla_put_flag | ( | struct nl_msg * | n, | |
int | attrtype | |||
) |
int nla_put_msecs | ( | struct nl_msg * | n, | |
int | attrtype, | |||
unsigned long | msecs | |||
) |
n | netlink message | |
attrtype | attribute type | |
msecs | number of msecs |
Definition at line 613 of file attr.c.
References nla_put_u64().
00614 { 00615 return nla_put_u64(n, attrtype, msecs); 00616 }
int nla_put_data | ( | struct nl_msg * | n, | |
int | attrtype, | |||
struct nl_data * | data | |||
) |
n | netlink message | |
attrtype | attribute type | |
data | abstract data |
Definition at line 624 of file attr.c.
References nl_data_get(), nl_data_get_size(), and nla_put().
00625 { 00626 return nla_put(n, attrtype, nl_data_get_size(data), 00627 nl_data_get(data)); 00628 }
int nla_put_addr | ( | struct nl_msg * | n, | |
int | attrtype, | |||
struct nl_addr * | addr | |||
) |
n | netlink message | |
attrtype | attribute type | |
addr | abstract address |
Definition at line 636 of file attr.c.
References nl_addr_get_binary_addr(), nl_addr_get_len(), and nla_put().
00637 { 00638 return nla_put(n, attrtype, nl_addr_get_len(addr), 00639 nl_addr_get_binary_addr(addr)); 00640 }
struct nlattr* nla_nest_start | ( | struct nl_msg * | n, | |
int | attrtype | |||
) | [read] |
n | netlink message | |
attrtype | attribute type of container |
Definition at line 656 of file attr.c.
References nla_put().
Referenced by rtnl_link_build_change_request().
00657 { 00658 struct nlattr *start = (struct nlattr *) nlmsg_tail(n->nm_nlh); 00659 00660 if (nla_put(n, attrtype, 0, NULL) < 0) 00661 return NULL; 00662 00663 return start; 00664 }
int nla_nest_end | ( | struct nl_msg * | n, | |
struct nlattr * | start | |||
) |
n | netlink message | |
start | container attribute |
Definition at line 676 of file attr.c.
Referenced by rtnl_link_build_change_request().
00677 { 00678 start->nla_len = (unsigned char *) nlmsg_tail(n->nm_nlh) - 00679 (unsigned char *) start; 00680 return 0; 00681 }
uint32_t nla_get_u32 | ( | struct nlattr * | nla | ) |
nla | u32 netlink attribute |
Definition at line 694 of file attr.c.
References nla_data().
00695 { 00696 return *(uint32_t *) nla_data(nla); 00697 }
uint16_t nla_get_u16 | ( | struct nlattr * | nla | ) |
nla | u16 netlink attribute |
Definition at line 703 of file attr.c.
References nla_data().
00704 { 00705 return *(uint16_t *) nla_data(nla); 00706 }
uint8_t nla_get_u8 | ( | struct nlattr * | nla | ) |
nla | u8 netlink attribute |
Definition at line 712 of file attr.c.
References nla_data().
00713 { 00714 return *(uint8_t *) nla_data(nla); 00715 }
uint64_t nla_get_u64 | ( | struct nlattr * | nla | ) |
nla | u64 netlink attribute |
Definition at line 721 of file attr.c.
References nla_memcpy().
Referenced by nla_get_msecs().
00722 { 00723 uint64_t tmp; 00724 00725 nla_memcpy(&tmp, nla, sizeof(tmp)); 00726 00727 return tmp; 00728 }
char* nla_get_string | ( | struct nlattr * | nla | ) |
nla | string netlink attribute |
Definition at line 734 of file attr.c.
References nla_data().
00735 { 00736 return (char *) nla_data(nla); 00737 }
int nla_get_flag | ( | struct nlattr * | nla | ) |
unsigned long nla_get_msecs | ( | struct nlattr * | nla | ) |
nla | msecs netlink attribute |
Definition at line 754 of file attr.c.
References nla_get_u64().
00755 { 00756 return nla_get_u64(nla); 00757 }
struct nl_addr* nla_get_addr | ( | struct nlattr * | nla, | |
int | family | |||
) | [read] |
nla | address netlink attribute | |
family | address family |
Definition at line 766 of file attr.c.
References nl_addr_build(), nla_data(), and nla_len().
00767 { 00768 return nl_addr_build(family, nla_data(nla), nla_len(nla)); 00769 }
struct nl_data* nla_get_data | ( | struct nlattr * | nla | ) | [read] |
nla | abstract data netlink attribute |
Definition at line 777 of file attr.c.
References nl_data_alloc(), nla_data(), and nla_len().
00778 { 00779 return nl_data_alloc(nla_data(nla), nla_len(nla)); 00780 }