netlink(3) — Linux manual page

NAME | LIBRARY | SYNOPSIS | DESCRIPTION | VERSIONS | STANDARDS | SEE ALSO | COLOPHON

netlink(3)               Library Functions Manual              netlink(3)

NAME         top

       netlink - Netlink macros

LIBRARY         top

       Standard C library (libc, -lc)

SYNOPSIS         top

       #include <asm/types.h>
       #include <linux/netlink.h>

       int NLMSG_ALIGN(size_t size);
       int NLMSG_LENGTH(size_t size);
       int NLMSG_SPACE(size_t size);
       void *NLMSG_DATA(struct nlmsghdr *nlh);
       struct nlmsghdr *NLMSG_NEXT(struct nlmsghdr *nlh, int size);
       int NLMSG_OK(struct nlmsghdr *nlh, int size);
       int NLMSG_PAYLOAD(struct nlmsghdr *nlh, int size);

DESCRIPTION         top

       <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 size of a netlink message up to align it
              properly.

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

       NLMSG_SPACE()
              Return the number of bytes that a netlink message with
              payload of size 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 size argument is an lvalue containing the remaining
              size of the message buffer.  This macro decrements it by
              the size 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 size of the payload associated with the
              nlmsghdr.

VERSIONS         top

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

STANDARDS         top

       Linux.

SEE ALSO         top

       libnetlink(3), netlink(7)

COLOPHON         top

       This page is part of the man-pages (Linux kernel and C library
       user-space interface documentation) project.  Information about
       the project can be found at 
       ⟨https://www.kernel.org/doc/man-pages/⟩.  If you have a bug report
       for this manual page, see
       ⟨https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING⟩.
       This page was obtained from the tarball man-pages-6.10.tar.gz
       fetched from
       ⟨https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/⟩ on
       2025-02-02.  If you discover any rendering problems in this HTML
       version of the page, or you believe there is a better or more up-
       to-date source for the page, or you have corrections or
       improvements to the information in this COLOPHON (which is not
       part of the original manual page), send a mail to
       man-pages@man7.org

Linux man-pages 6.10            2024-11-17                     netlink(3)

Pages that refer to this page: libnetlink(3)rtnetlink(3)netlink(7)sock_diag(7)