logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

netlink - Netlink macros

Description

<linux/netlink.h>  defines  several  standard  macros  to  access or create a netlink datagram.  They are
       similar in spirit to the macros defined in cmsg(3) for auxiliary data.  The buffer passed to and  from  a
       netlink socket should be accessed using only these macros.

       NLMSG_ALIGN()
              Round the length of a netlink message up to align it properly.

       NLMSG_LENGTH()
              Given  the  payload  length,  len, this macro returns the aligned length to store in the nlmsg_len
              field of the nlmsghdr.

       NLMSG_SPACE()
              Return the number of bytes that a netlink message with payload of len would occupy.

       NLMSG_DATA()
              Return a pointer to the payload associated with the passed nlmsghdr.

       NLMSG_NEXT()
              Get the next nlmsghdr in a multipart message.  The caller  must  check  if  the  current  nlmsghdr
              didn't  have  the NLMSG_DONE set—this function doesn't return NULL on end.  The len argument is an
              lvalue containing the remaining length of the message buffer.  This macro  decrements  it  by  the
              length of the message header.

       NLMSG_OK()
              Return true if the netlink message is not truncated and is in a form suitable for parsing.

       NLMSG_PAYLOAD()
              Return the length of the payload associated with the nlmsghdr.

Library

       Standard C library (libc, -lc)

Name

       netlink - Netlink macros

See Also

libnetlink(3), netlink(7)

Linux man-pages 6.9.1                              2024-05-02                                         netlink(3)

Standards

       Linux.

Synopsis

#include<asm/types.h>#include<linux/netlink.h>intNLMSG_ALIGN(size_tlen);intNLMSG_LENGTH(size_tlen);intNLMSG_SPACE(size_tlen);void*NLMSG_DATA(structnlmsghdr*nlh);structnlmsghdr*NLMSG_NEXT(structnlmsghdr*nlh,intlen);intNLMSG_OK(structnlmsghdr*nlh,intlen);intNLMSG_PAYLOAD(structnlmsghdr*nlh,intlen);

Versions

       It is often better to use netlink via libnetlink than via the low-level kernel interface.

See Also