Netlink Message Construction/Parsing Interface.
More...
|
| Attributes |
| Netlink Attributes Construction/Parsing Interface.
|
|
|
#define | NL_AUTO_PID 0 |
| Will cause the netlink pid to be set to the pid assigned to the netlink handle (socket) just before sending the message off. More...
|
|
#define | NL_AUTO_SEQ 0 |
| May be used to refer to a sequence number which should be automatically set just before sending the message off. More...
|
|
|
int | nlmsg_valid_hdr (const struct nlmsghdr *nlh, int hdrlen) |
|
int | nlmsg_ok (const struct nlmsghdr *nlh, int remaining) |
| check if the netlink message fits into the remaining bytes More...
|
|
struct nlmsghdr * | nlmsg_next (struct nlmsghdr *nlh, int *remaining) |
| next netlink message in message stream More...
|
|
int | nlmsg_parse (struct nlmsghdr *nlh, int hdrlen, struct nlattr *tb[], int maxtype, struct nla_policy *policy) |
| parse attributes of a netlink message More...
|
|
struct nlattr * | nlmsg_find_attr (struct nlmsghdr *nlh, int hdrlen, int attrtype) |
| nlmsg_find_attr - find a specific attribute in a netlink message More...
|
|
int | nlmsg_validate (struct nlmsghdr *nlh, int hdrlen, int maxtype, struct nla_policy *policy) |
| nlmsg_validate - validate a netlink message including attributes More...
|
|
|
struct nl_msg * | nlmsg_alloc (void) |
| Allocate a new netlink message with the default maximum payload size. More...
|
|
struct nl_msg * | nlmsg_alloc_size (size_t max) |
| Allocate a new netlink message with maximum payload size specified.
|
|
struct nl_msg * | nlmsg_inherit (struct nlmsghdr *hdr) |
| Allocate a new netlink message and inherit netlink message header. More...
|
|
struct nl_msg * | nlmsg_alloc_simple (int nlmsgtype, int flags) |
| Allocate a new netlink message. More...
|
|
void | nlmsg_set_default_size (size_t max) |
| Set the default maximum message payload size for allocated messages. More...
|
|
struct nl_msg * | nlmsg_convert (struct nlmsghdr *hdr) |
| Convert a netlink message received from a netlink socket to a nl_msg. More...
|
|
void * | nlmsg_reserve (struct nl_msg *n, size_t len, int pad) |
| Reserve room for additional data in a netlink message. More...
|
|
int | nlmsg_append (struct nl_msg *n, void *data, size_t len, int pad) |
| Append data to tail of a netlink message. More...
|
|
int | nlmsg_expand (struct nl_msg *n, size_t newlen) |
| Expand maximum payload size of a netlink message. More...
|
|
struct nlmsghdr * | nlmsg_put (struct nl_msg *n, uint32_t pid, uint32_t seq, int type, int payload, int flags) |
| Add a netlink message header to a netlink message. More...
|
|
struct nlmsghdr * | nlmsg_hdr (struct nl_msg *n) |
| Return actual netlink message. More...
|
|
void | nlmsg_free (struct nl_msg *n) |
| Free a netlink message. More...
|
|
|
void | nlmsg_set_proto (struct nl_msg *msg, int protocol) |
|
int | nlmsg_get_proto (struct nl_msg *msg) |
|
size_t | nlmsg_get_max_size (struct nl_msg *msg) |
|
void | nlmsg_set_src (struct nl_msg *msg, struct sockaddr_nl *addr) |
|
struct sockaddr_nl * | nlmsg_get_src (struct nl_msg *msg) |
|
void | nlmsg_set_dst (struct nl_msg *msg, struct sockaddr_nl *addr) |
|
struct sockaddr_nl * | nlmsg_get_dst (struct nl_msg *msg) |
|
void | nlmsg_set_creds (struct nl_msg *msg, struct ucred *creds) |
|
struct ucred * | nlmsg_get_creds (struct nl_msg *msg) |
|
|
char * | nl_nlmsgtype2str (int type, char *buf, size_t size) |
|
int | nl_str2nlmsgtype (const char *name) |
|
|
char * | nl_nlmsg_flags2str (int flags, char *buf, size_t len) |
|
|
int | nl_msg_parse (struct nl_msg *msg, void(*cb)(struct nl_object *, void *), void *arg) |
|
|
void | nl_msg_dump (struct nl_msg *msg, FILE *ofd) |
| Dump message in human readable format to file descriptor. More...
|
|
|
#define | NLM_F_REQUEST 1 |
| Must be set on all request messages (typically from user space to kernel space).
|
|
#define | NLM_F_MULTI 2 |
| Indicates the message is part of a multipart message terminated by NLMSG_DONE.
|
|
#define | NLM_F_ACK 4 |
| Request for an acknowledgment on success.
|
|
#define | NLM_F_ECHO 8 |
| Echo this request.
|
|
|
#define | NLM_F_REPLACE 0x100 |
| Replace existing matching config object with this request.
|
|
#define | NLM_F_EXCL 0x200 |
| Don't replace the config object if it already exists.
|
|
#define | NLM_F_CREATE 0x400 |
| Create config object if it doesn't already exist.
|
|
#define | NLM_F_APPEND 0x800 |
| Add to the end of the object list.
|
|
|
#define | NLMSG_NOOP 0x1 |
| No operation, message must be ignored.
|
|
#define | NLMSG_ERROR 0x2 |
| The message signals an error and the payload contains a nlmsgerr structure. More...
|
|
#define | NLMSG_DONE 0x3 |
| Message terminates a multipart message.
|
|
#define | NLMSG_OVERRUN 0x4 |
| The message signals that data got lost.
|
|
#define | NLMSG_MIN_TYPE 0x10 |
| Lower limit of reserved message types.
|
|
The following information is partly extracted from RFC3549 (ftp://ftp.rfc-editor.org/in-notes/rfc3549.txt)
- Message Format
- Netlink messages consist of a byte stream with one or multiple Netlink headers and an associated payload. If the payload is too big to fit into a single message it, can be split over multiple Netlink messages, collectively called a multipart message. For multipart messages, the first and all following headers have the
NLM_F_MULTI
Netlink header flag set, except for the last header which has the Netlink header type NLMSG_DONE
.
- The Netlink message header (struct nlmsghdr) is shown below.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Flags |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Process ID (PID) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- The netlink message header and payload must be aligned properly:
<------- NLMSG_ALIGN(hlen) ------> <---- NLMSG_ALIGN(len) --->
+----------------------------+- - -+- - - - - - - - - - -+- - -+
| Header | Pad | Payload | Pad |
+----------------------------+- - -+- - - - - - - - - - -+- - -+
- Message Format:
+----------+- - -+-------------+- - -+-------- - -
+----------+- - -+-------------+- - -+-------- - -
- The payload may consist of arbitary data but may have strict alignment and formatting rules depening on the specific netlink families.
<----------------------
nlmsg_len(nlh) --------------------->
+----------------------+- - -+--------------------------------+
| Family Header | Pad | Attributes |
+----------------------+- - -+--------------------------------+
- The ACK Netlink Message
- This message is actually used to denote both an ACK and a NACK. Typically, the direction is from FEC to CPC (in response to an ACK request message). However, the CPC should be able to send ACKs back to FEC when requested.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Netlink message header |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Error code |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| OLD Netlink message header |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- Example
.nlmsg_flags = MY_FLAGS,
};
- 4) Parsing messages
int n;
unsigned char *buf;
}
◆ NL_AUTO_PID
◆ NL_AUTO_SEQ
◆ nlmsg_for_each_attr
#define nlmsg_for_each_attr |
( |
|
pos, |
|
|
|
nlh, |
|
|
|
hdrlen, |
|
|
|
rem |
|
) |
| |
Value:int nlmsg_attrlen(const struct nlmsghdr *, int)
length of attributes data
struct nlattr * nlmsg_attrdata(const struct nlmsghdr *, int)
head of attributes data
#define nla_for_each_attr(pos, head, len, rem)
iterate over a stream of attributes
- Parameters
-
pos | loop counter, set to current attribute |
nlh | netlink message header |
hdrlen | length of family header |
rem | initialized to len, holds bytes currently remaining in stream |
Definition at line 126 of file msg.h.
◆ nlmsg_for_each_msg
#define nlmsg_for_each_msg |
( |
|
pos, |
|
|
|
head, |
|
|
|
len, |
|
|
|
rem |
|
) |
| |
Value:for (pos = head, rem = len; \
nlmsg_ok(pos, rem); \
struct nlmsghdr * nlmsg_next(struct nlmsghdr *, int *)
next netlink message in message stream
- Parameters
-
pos | loop counter, set to current message |
head | head of message stream |
len | length of message stream |
rem | initialized to len, holds bytes currently remaining in stream |
Definition at line 137 of file msg.h.
◆ NLM_F_ATOMIC
#define NLM_F_ATOMIC 0x400 |
This may require special privileges because it has the potential to interrupt service in the FE for a longer time.
Definition at line 106 of file netlink-kernel.h.
◆ NLMSG_ERROR
This can be looked at as a NACK and typically it is from FEC to CPC.
Definition at line 159 of file netlink-kernel.h.
◆ nlmsg_msg_size()
int nlmsg_msg_size |
( |
int |
payload | ) |
|
◆ nlmsg_total_size()
int nlmsg_total_size |
( |
int |
payload | ) |
|
◆ nlmsg_padlen()
int nlmsg_padlen |
( |
int |
payload | ) |
|
- Parameters
-
payload | length of message payload |
Definition at line 202 of file msg.c.
References nlmsg_msg_size(), and nlmsg_total_size().
int nlmsg_total_size(int payload)
length of netlink message including padding
int nlmsg_msg_size(int payload)
length of netlink message not including padding
◆ nlmsg_data()
void* nlmsg_data |
( |
const struct nlmsghdr * |
nlh | ) |
|
◆ nlmsg_len()
int nlmsg_len |
( |
const struct nlmsghdr * |
nlh | ) |
|
◆ nlmsg_attrdata()
struct nlattr* nlmsg_attrdata |
( |
const struct nlmsghdr * |
nlh, |
|
|
int |
hdrlen |
|
) |
| |
- Parameters
-
nlh | netlink message header |
hdrlen | length of family specific header |
Definition at line 249 of file msg.c.
References nlmsg_data().
Referenced by nlmsg_find_attr().
252 return (
struct nlattr *) (data + NLMSG_ALIGN(hdrlen));
void * nlmsg_data(const struct nlmsghdr *nlh)
head of message payload
◆ nlmsg_attrlen()
int nlmsg_attrlen |
( |
const struct nlmsghdr * |
nlh, |
|
|
int |
hdrlen |
|
) |
| |
- Parameters
-
nlh | netlink message header |
hdrlen | length of family specific header |
Definition at line 260 of file msg.c.
References nlmsg_len().
Referenced by nlmsg_find_attr().
262 return nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen);
int nlmsg_len(const struct nlmsghdr *nlh)
length of message payload
◆ nlmsg_ok()
int nlmsg_ok |
( |
const struct nlmsghdr * |
nlh, |
|
|
int |
remaining |
|
) |
| |
- Parameters
-
nlh | netlink message header |
remaining | number of bytes remaining in message stream |
Definition at line 285 of file msg.c.
References nlmsghdr::nlmsg_len.
287 return (remaining >= (
int)
sizeof(
struct nlmsghdr) &&
uint32_t nlmsg_len
Length of message including header.
◆ nlmsg_next()
- Parameters
-
nlh | netlink message header |
remaining | number of bytes remaining in message stream |
- Returns
- the next netlink message in the message stream and decrements remaining by the size of the current message.
Definition at line 300 of file msg.c.
References nlmsghdr::nlmsg_len.
302 int totlen = NLMSG_ALIGN(nlh->
nlmsg_len);
304 *remaining -= totlen;
306 return (
struct nlmsghdr *) ((
unsigned char *) nlh + totlen);
uint32_t nlmsg_len
Length of message including header.
◆ nlmsg_parse()
int nlmsg_parse |
( |
struct nlmsghdr * |
nlh, |
|
|
int |
hdrlen, |
|
|
struct nlattr * |
tb[], |
|
|
int |
maxtype, |
|
|
struct nla_policy * |
policy |
|
) |
| |
- Parameters
-
nlh | netlink message header |
hdrlen | length of family specific header |
tb | destination array with maxtype+1 elements |
maxtype | maximum attribute type to be expected |
policy | validation policy |
See nla_parse()
Definition at line 319 of file msg.c.
322 if (!nlmsg_valid_hdr(nlh, hdrlen))
323 return nl_errno(EINVAL);
int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen)
length of attributes data
struct nlattr * nlmsg_attrdata(const struct nlmsghdr *nlh, int hdrlen)
head of attributes data
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.
◆ nlmsg_find_attr()
struct nlattr* nlmsg_find_attr |
( |
struct nlmsghdr * |
nlh, |
|
|
int |
hdrlen, |
|
|
int |
attrtype |
|
) |
| |
- Parameters
-
nlh | netlink message header |
hdrlen | length of familiy specific header |
attrtype | type of attribute to look for |
Returns the first attribute which matches the specified type.
Definition at line 337 of file msg.c.
References nla_find(), nlmsg_attrdata(), and nlmsg_attrlen().
int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen)
length of attributes data
struct nlattr * nlmsg_attrdata(const struct nlmsghdr *nlh, int hdrlen)
head of attributes data
struct nlattr * nla_find(struct nlattr *head, int len, int attrtype)
Find a specific attribute in a stream of attributes.
◆ nlmsg_validate()
int nlmsg_validate |
( |
struct nlmsghdr * |
nlh, |
|
|
int |
hdrlen, |
|
|
int |
maxtype, |
|
|
struct nla_policy * |
policy |
|
) |
| |
- Parameters
-
nlh | netlinket message header |
hdrlen | length of familiy specific header |
maxtype | maximum attribute type to be expected |
policy | validation policy |
Definition at line 350 of file msg.c.
353 if (!nlmsg_valid_hdr(nlh, hdrlen))
354 return nl_errno(EINVAL);
int nla_validate(struct nlattr *head, int len, int maxtype, struct nla_policy *policy)
Validate a stream of attributes.
int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen)
length of attributes data
struct nlattr * nlmsg_attrdata(const struct nlmsghdr *nlh, int hdrlen)
head of attributes data
◆ nlmsg_alloc()
struct nl_msg* nlmsg_alloc |
( |
void |
| ) |
|
◆ nlmsg_inherit()
struct nl_msg* nlmsg_inherit |
( |
struct nlmsghdr * |
hdr | ) |
|
- Parameters
-
hdr | Netlink message header template |
Allocates a new netlink message and inherits the original message header. If hdr is not NULL it will be used as a template for the netlink message header, otherwise the header is left blank.
- Returns
- Newly allocated netlink message or NULL
Definition at line 424 of file msg.c.
References nlmsg_alloc(), nlmsghdr::nlmsg_flags, nlmsghdr::nlmsg_pid, nlmsghdr::nlmsg_seq, and nlmsghdr::nlmsg_type.
Referenced by nlmsg_alloc_simple().
uint16_t nlmsg_type
Message type (content type)
struct nl_msg * nlmsg_alloc(void)
Allocate a new netlink message with the default maximum payload size.
uint32_t nlmsg_seq
Sequence number.
uint32_t nlmsg_pid
Netlink PID of the proccess sending the message.
uint16_t nlmsg_flags
Message flags.
◆ nlmsg_alloc_simple()
struct nl_msg* nlmsg_alloc_simple |
( |
int |
nlmsgtype, |
|
|
int |
flags |
|
) |
| |
◆ nlmsg_set_default_size()
void nlmsg_set_default_size |
( |
size_t |
max | ) |
|
- Parameters
-
max | Size of payload in bytes. |
Definition at line 467 of file msg.c.
References nlmsg_total_size().
472 default_msg_size = max;
int nlmsg_total_size(int payload)
length of netlink message including padding
◆ nlmsg_convert()
struct nl_msg* nlmsg_convert |
( |
struct nlmsghdr * |
hdr | ) |
|
- Parameters
-
hdr | Netlink message received from netlink socket. |
Allocates a new netlink message and copies all of the data pointed to by hdr into the new message object.
- Returns
- Newly allocated netlink message or NULL.
Definition at line 484 of file msg.c.
488 nm = __nlmsg_alloc(NLMSG_ALIGN(hdr->
nlmsg_len));
void nlmsg_free(struct nl_msg *n)
Free a netlink message.
uint32_t nlmsg_len
Length of message including header.
◆ nlmsg_reserve()
void* nlmsg_reserve |
( |
struct nl_msg * |
n, |
|
|
size_t |
len, |
|
|
int |
pad |
|
) |
| |
- Parameters
-
n | netlink message |
len | length of additional data to reserve room for |
pad | number of bytes to align data to |
Reserves room for additional data at the tail of the an existing netlink message. Eventual padding required will be zeroed out.
- Returns
- Pointer to start of additional data tailroom or NULL.
Definition at line 512 of file msg.c.
References nlmsg_len().
Referenced by nlmsg_append(), and nlmsg_put().
514 void *buf = n->nm_nlh;
518 tlen = pad ? ((len + (pad - 1)) & ~(pad - 1)) : len;
526 n->nm_nlh->nlmsg_len += tlen;
529 memset(buf + len, 0, tlen - len);
531 NL_DBG(2,
"msg %p: Reserved %zu bytes, pad=%d, nlmsg_len=%d\n",
532 n, len, pad, n->nm_nlh->nlmsg_len);
int nlmsg_len(const struct nlmsghdr *nlh)
length of message payload
◆ nlmsg_append()
int nlmsg_append |
( |
struct nl_msg * |
n, |
|
|
void * |
data, |
|
|
size_t |
len, |
|
|
int |
pad |
|
) |
| |
- Parameters
-
n | netlink message |
data | data to add |
len | length of data |
pad | Number of bytes to align data to. |
Extends the netlink message as needed and appends the data of given length to the message.
- Returns
- 0 on success or a negative error code
Definition at line 549 of file msg.c.
References nlmsg_reserve().
Referenced by nl_send_simple(), rtnl_link_build_change_request(), rtnl_neightbl_build_change_request(), and rtnl_qdisc_build_delete_request().
555 return nl_errno(ENOMEM);
557 memcpy(tmp, data, len);
558 NL_DBG(2,
"msg %p: Appended %zu bytes with padding %d\n", n, len, pad);
void * nlmsg_reserve(struct nl_msg *n, size_t len, int pad)
Reserve room for additional data in a netlink message.
◆ nlmsg_expand()
int nlmsg_expand |
( |
struct nl_msg * |
n, |
|
|
size_t |
newlen |
|
) |
| |
- Parameters
-
n | Netlink message. |
newlen | New maximum payload size. |
Reallocates the payload section of a netlink message and increases the maximum payload size of the message.
- Note
- Any pointers pointing to old payload block will be stale and need to be refetched. Therfore, do not expand while constructing nested attributes or while reserved data blocks are held.
- Returns
- 0 on success or a negative error code.
Definition at line 577 of file msg.c.
581 if (newlen <= n->nm_size)
582 return nl_errno(EINVAL);
584 tmp = realloc(n->nm_nlh, newlen);
586 return nl_errno(ENOMEM);
◆ nlmsg_put()
struct nlmsghdr* nlmsg_put |
( |
struct nl_msg * |
n, |
|
|
uint32_t |
pid, |
|
|
uint32_t |
seq, |
|
|
int |
type, |
|
|
int |
payload, |
|
|
int |
flags |
|
) |
| |
- Parameters
-
n | netlink message |
pid | netlink process id or NL_AUTO_PID |
seq | sequence number of message or NL_AUTO_SEQ |
type | message type |
payload | length of message payload |
flags | message flags |
Adds or overwrites the netlink message header in an existing message object. If payload is greater-than zero additional room will be reserved, f.e. for family specific headers. It can be accesed via nlmsg_data().
- Returns
- A pointer to the netlink message header or NULL.
Definition at line 610 of file msg.c.
References nlmsghdr::nlmsg_flags, nlmsghdr::nlmsg_pid, nlmsg_reserve(), nlmsghdr::nlmsg_seq, and nlmsghdr::nlmsg_type.
Referenced by genlmsg_put(), and nfnlmsg_put().
615 if (n->nm_nlh->nlmsg_len < NLMSG_HDRLEN)
618 nlh = (
struct nlmsghdr *) n->nm_nlh;
624 NL_DBG(2,
"msg %p: Added netlink header type=%d, flags=%d, pid=%d, " 625 "seq=%d\n", n, type, flags, pid, seq);
uint16_t nlmsg_type
Message type (content type)
void * nlmsg_reserve(struct nl_msg *n, size_t len, int pad)
Reserve room for additional data in a netlink message.
uint32_t nlmsg_seq
Sequence number.
uint32_t nlmsg_pid
Netlink PID of the proccess sending the message.
uint16_t nlmsg_flags
Message flags.
◆ nlmsg_hdr()
struct nlmsghdr* nlmsg_hdr |
( |
struct nl_msg * |
n | ) |
|
◆ nlmsg_free()
void nlmsg_free |
( |
struct nl_msg * |
n | ) |
|
- Parameters
-
Destroys a netlink message and frees up all used memory.
- Precondition
- The message must be unused.
Definition at line 656 of file msg.c.
Referenced by flnl_lookup(), nl_send_simple(), rtnl_class_add(), rtnl_cls_add(), rtnl_cls_change(), rtnl_cls_delete(), rtnl_link_build_change_request(), rtnl_link_change(), rtnl_neigh_add(), rtnl_neigh_change(), rtnl_neigh_delete(), rtnl_neightbl_build_change_request(), rtnl_neightbl_change(), rtnl_qdisc_add(), rtnl_qdisc_change(), rtnl_qdisc_delete(), rtnl_rule_add(), and rtnl_rule_delete().
663 NL_DBG(2,
"msg %p: Freed\n", n);
◆ nl_msg_dump()
void nl_msg_dump |
( |
struct nl_msg * |
msg, |
|
|
FILE * |
ofd |
|
) |
| |
- Parameters
-
msg | Message to print |
ofd | File descriptor. |
Definition at line 947 of file msg.c.
References nlmsg_hdr().
952 "-------------------------- BEGIN NETLINK MESSAGE " 953 "---------------------------\n");
955 fprintf(ofd,
" [HEADER] %Zu octets\n",
sizeof(
struct nlmsghdr));
960 struct nl_msg *errmsg;
964 fprintf(ofd,
" [ERRORMSG] %Zu octets\n",
sizeof(*err));
965 fprintf(ofd,
" .error = %d \"%s\"\n", err->
error,
966 strerror_r(-err->
error, buf,
sizeof(buf)));
967 fprintf(ofd,
" [ORIGINAL MESSAGE] %Zu octets\n",
sizeof(*hdr));
970 print_hdr(ofd, errmsg);
981 payloadlen -= attrlen;
984 fprintf(ofd,
" [PAYLOAD] %d octets\n", payloadlen);
985 dump_hex(ofd,
nlmsg_data(hdr), payloadlen, 0);
988 struct nlattr *attrs;
993 dump_attrs(ofd, attrs, attrlen, 0);
998 "--------------------------- END NETLINK MESSAGE " 999 "---------------------------\n");
int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen)
length of attributes data
void * nlmsg_data(const struct nlmsghdr *nlh)
head of message payload
uint16_t nlmsg_type
Message type (content type)
struct nl_msg * nlmsg_inherit(struct nlmsghdr *hdr)
Allocate a new netlink message and inherit netlink message header.
void nlmsg_free(struct nl_msg *n)
Free a netlink message.
int error
Error code (errno number)
uint32_t nlmsg_len
Length of message including header.
#define NLMSG_ERROR
The message signals an error and the payload contains a nlmsgerr structure.
struct nlattr * nlmsg_attrdata(const struct nlmsghdr *nlh, int hdrlen)
head of attributes data
struct nlmsghdr * nlmsg_hdr(struct nl_msg *n)
Return actual netlink message.
struct nlmsghdr msg
Original netlink message causing the error.
int nlmsg_len(const struct nlmsghdr *nlh)
length of message payload
struct nl_cache_ops * nl_cache_ops_associate(int protocol, int msgtype)
Associate protocol and message type to cache operations.
int nlmsg_msg_size(int payload)
length of netlink message not including padding