2004-11-03 13:51:07 +00:00
|
|
|
.\" This manpage copyright 1998 by Andi Kleen. Subject to the GPL.
|
|
|
|
.\" Based on the original comments from Alexey Kuznetsov
|
|
|
|
.\" $Id: netlink.3,v 1.1 1999/05/14 17:17:24 freitag Exp $
|
2007-05-18 09:55:10 +00:00
|
|
|
.TH NETLINK 3 1999-05-14 "GNU" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
netlink \- Netlink macros
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.nf
|
2007-06-13 21:48:16 +00:00
|
|
|
.\" FIXME . what will glibc 2.1 use here?
|
2007-06-21 22:55:04 +00:00
|
|
|
.\" May 2007: glibc 2.5, things look to be unchanged -- the header file
|
2007-05-21 10:01:48 +00:00
|
|
|
.\" is still linux/netlink.h -- mtk
|
2004-11-03 13:51:07 +00:00
|
|
|
.B #include <asm/types.h>
|
|
|
|
.br
|
2007-04-12 22:42:49 +00:00
|
|
|
.B #include <linux/netlink.h>
|
2007-12-23 13:45:24 +00:00
|
|
|
.sp
|
2004-11-03 13:51:07 +00:00
|
|
|
.BI "int NLMSG_ALIGN(size_t " len );
|
2007-04-12 22:42:49 +00:00
|
|
|
.br
|
2004-11-03 13:51:07 +00:00
|
|
|
.BI "int NLMSG_LENGTH(size_t " len );
|
|
|
|
.br
|
|
|
|
.BI "int NLMSG_SPACE(size_t " len );
|
|
|
|
.br
|
|
|
|
.BI "void *NLMSG_DATA(struct nlmsghdr *" nlh );
|
|
|
|
.br
|
|
|
|
.BI "struct nlmsghdr *NLMSG_NEXT(struct nlmsghdr *" nlh ", int " len );
|
|
|
|
.br
|
|
|
|
.BI "int NLMSG_OK(struct nlmsghdr *" nlh ", int " len );
|
|
|
|
.br
|
|
|
|
.BI "int NLMSG_PAYLOAD(struct nlmsghdr *" nlh ", int " len );
|
|
|
|
.fi
|
|
|
|
.SH DESCRIPTION
|
2005-11-03 12:47:27 +00:00
|
|
|
.I <linux/netlink.h>
|
2004-11-03 13:51:07 +00:00
|
|
|
defines several standard macros to access or create a netlink datagram.
|
2007-04-12 22:42:49 +00:00
|
|
|
They are similar in spirit to the macros defined in
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR cmsg (3)
|
2007-04-12 22:42:49 +00:00
|
|
|
for auxiliary data.
|
|
|
|
The buffer passed to and from a netlink socket should
|
2007-06-16 07:46:30 +00:00
|
|
|
only be accessed using these macros.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2007-12-16 13:29:10 +00:00
|
|
|
.BR NLMSG_ALIGN ()
|
2004-11-03 13:51:07 +00:00
|
|
|
Round the length of a netlink message up to align it properly.
|
|
|
|
.TP
|
2007-12-16 13:29:10 +00:00
|
|
|
.BR NLMSG_LENGTH ()
|
2007-06-16 07:46:30 +00:00
|
|
|
Given the payload length,
|
2007-06-21 22:55:04 +00:00
|
|
|
.IR len ,
|
2007-06-16 07:46:30 +00:00
|
|
|
this macro returns the aligned length to store in the
|
2007-06-23 07:56:56 +00:00
|
|
|
.I nlmsg_len
|
2007-04-12 22:42:49 +00:00
|
|
|
field of the
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR nlmsghdr .
|
|
|
|
.TP
|
2007-12-16 13:29:10 +00:00
|
|
|
.BR NLMSG_SPACE ()
|
2007-06-16 07:46:30 +00:00
|
|
|
Return the number of bytes that a netlink message with payload of
|
|
|
|
.I len
|
2004-11-03 13:51:07 +00:00
|
|
|
would occupy.
|
|
|
|
.TP
|
2007-12-16 13:29:10 +00:00
|
|
|
.BR NLMSG_DATA ()
|
2007-04-12 22:42:49 +00:00
|
|
|
Return a pointer to the payload associated with the passed
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR nlmsghdr .
|
|
|
|
.TP
|
2007-06-13 21:48:16 +00:00
|
|
|
.\" this is bizarre, maybe the interface should be fixed.
|
2007-12-16 13:29:10 +00:00
|
|
|
.BR NLMSG_NEXT ()
|
2007-04-12 22:42:49 +00:00
|
|
|
Get the next
|
2004-11-03 13:51:07 +00:00
|
|
|
.I nlmsghdr
|
2007-04-12 22:42:49 +00:00
|
|
|
in a multipart message.
|
2007-12-16 13:29:10 +00:00
|
|
|
The caller must check if the current
|
|
|
|
.I nlmsghdr
|
|
|
|
didn't have the
|
|
|
|
.B NLMSG_DONE
|
2007-04-12 22:42:49 +00:00
|
|
|
set \(em this function doesn't return NULL on end.
|
2008-07-10 20:53:08 +00:00
|
|
|
The
|
|
|
|
.I len
|
|
|
|
argument is an lvalue containing the remaining length
|
2007-04-12 22:42:49 +00:00
|
|
|
of the message buffer.
|
2005-07-18 12:43:00 +00:00
|
|
|
This macro decrements it by the length of the message header.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2007-12-16 13:29:10 +00:00
|
|
|
.BR NLMSG_OK ()
|
2007-04-12 22:42:49 +00:00
|
|
|
Return true if the netlink message is not truncated and ok to parse.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2007-12-16 13:29:10 +00:00
|
|
|
.BR NLMSG_PAYLOAD ()
|
2007-04-12 22:42:49 +00:00
|
|
|
Return the length of the payload associated with the
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR nlmsghdr .
|
2007-07-18 20:25:14 +00:00
|
|
|
.SH CONFORMING TO
|
2007-06-16 07:46:30 +00:00
|
|
|
These macros are non-standard Linux extensions.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NOTES
|
2007-04-12 22:42:49 +00:00
|
|
|
It is often better to use netlink via
|
2007-06-23 07:56:56 +00:00
|
|
|
.I libnetlink
|
2007-06-23 08:22:53 +00:00
|
|
|
than via the low-level kernel interface.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR netlink (7)
|
2008-07-12 12:37:12 +00:00
|
|
|
.br
|
2004-11-03 13:51:07 +00:00
|
|
|
and ftp://ftp.inr.ac.ru/ip-routing/iproute2* for libnetlink
|