summaryrefslogtreecommitdiff
path: root/include/libmnl
AgeCommit message (Collapse)Author
2015-10-18Merge remote-tracking branch 'source/master' into upstreamupstreamAlex Harpin
2015-10-04socket: introduce mnl_socket_open2()Guillaume Nault
Define mnl_socket_open2() so that user can pass a set of SOCK_* flags at socket creation time. Signed-off-by: Guillaume Nault <g.nault@alphalink.fr> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2015-03-02header: use sysconf() instead of getpagesize()Markus Teich
The sysconf(_SC_PAGESIZE) call is more portable since it does not need _BSD_SOURCE defined. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2014-09-25socket: creating a struct mnl_socket from a pre-existing socketKen-ichirou MATSUZAWA
This patch defines a new function mnl_socket_fdopen() which creates a struct mnl_socket object from a pre-existing socket like obtained from other process and different domain/type from the same prodess. Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2013-07-16include: don't force compiler to enter C++11 modePablo Neira Ayuso
Thomas reports that g++ forces you to enable C++11 mode if you want to use <cstdint>. Tested with g++ (GCC) 4.4.4. He reports that this compiles fine without the special headers. So let's get rid of them. This reverts bb8c40e. Reported-by: Thomas Jarosch <thomas.jarosch@intra2net.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Tested-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
2012-05-22libmnl 1.0.3 packagedebian/1.0.3+vyatta1Gaurav Sinha
2012-05-18parse: add mnl_attr_for_each_payloadPablo Neira Ayuso
This function allows you to parse the payload of the Netlink message. Thus, you can skip the headers and go down to the part of the message you want to parse. This patch has updated the LIBVERSION and it also bumps the version to 1.0.3, in case that someone wants to package some snapshot, not to mess with the new symbol we have added. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-12-30header: fix invalid use of type void * in arithmetic of mnl_for_each_nest(...)Pablo Neira Ayuso
This patch fixes the following warnings: netlink.c:121: warning: pointer of type ‘void *’ used in arithmetic netlink.c:121: warning: pointer of type ‘void *’ used in subtraction We cannot use type void * for pointer arithmetic operations. This was introduced in 478dc5f4ab8d0a639d1bafe3bd53ff3309727836 Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-12-25header: fix signess issues in MNL_SOCKET_BUFFER_SIZEPablo Neira Ayuso
This patch fixes the following compilation warning: warning: comparison between signed and unsigned integer expressions warning: signed and unsigned type in conditional expression Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-12-20include: add missing unistd.hJan Engelhardt
When a project uses MNL_SOCKET_BUFFER_SIZE without having included unistd.h, it gets: mystuff.c:36:2: warning: implicit declaration of function "getpagesize" It is libmnl's job to include this, since mystuff.c did not use getpagesize anywhere. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
2010-12-17nlmsg: add new message batching infrastructurePablo Neira Ayuso
This patch adds the new message batching infrastructure that allows to store several messages into one single datagram. This patch includes an example for ctnetlink. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-12-17header: missing parenthesis in MNL_SOCKET_BUFFER_SIZE definitionPablo Neira Ayuso
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-12-17header: use getpagesize() for MNL_SOCKET_BUFFER_SIZEPablo Neira Ayuso
This system call returns PAGE_SIZE which depends on the architecture. See linux/netlink.h for more information on the appropriate datagram size for netlink. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-12-17attr: add put function that allows to check buffer sizePablo Neira Ayuso
This patch adds a set of function that allows to check the size of the buffer. This is useful for attribute batching. This is strongly based on a patch from Jozsef. Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-12-09header: add MNL_ARRAY_SIZE(x)Pablo Neira Ayuso
This patch adds MNL_ARRAY_SIZE(x) which likely to defined over and over again if you use mnl_cb_run2(...). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-11-22attr: add mnl_attr_nest_cancel()Pablo Neira Ayuso
This patch adds mnl_attr_nest_cancel() that allows to cancel the current nest that we are building. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-11-19build: tag function headers rather than decls as exportedJan Engelhardt
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-11-19nlmsg: remove unexisting mnl_nlmsg_total_sizePablo Neira Ayuso
Remove function whose implementation does not exist. It seems to me like a leftover from the early days of the library. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-11-16socket: propagate sendto/recvmsg's return typesJan Engelhardt
sendto/recvfrom return ssize_t, so libmnl should not truncate the result range. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
2010-11-16attr: avoid multiple definition of hidden variableJan Engelhardt
When nesting two mnl_attr_for_each loops, the __len__ variable will be declared twice, eliciting a warning when -Wshadow is turned on. There can also be warnings in pre-C99 because declarations and code are mixed. Do without any temporaries that are not explicitly specified as macro parameters. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
2010-11-15include: use C++ headers in C++ modeJan Engelhardt
Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-11-15src: implement both GCC visibility support and export scriptCristian Rodríguez
Read "How to write shared libraries" from Ulrich Drepper for more information on this patch. Specifically section 2.2: Export control and section 3: Maintaining APIs and ABIs. Signed-off-by: Cristian Rodríguez <cristian.rodriguez@opensuse.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-11-11nlmsg: use bool for mnl_nlmsg_ok()Jan Engelhardt
Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-11-07nlmsg: rework mnl_nlmsg_fprintfPablo Neira Ayuso
This patch reworks mnl_nlmsg_fprintf. It breaks backward compatibility of this function, there was no way to improve it without doing so (and we are still in time to break thing, BTW). Signed-off-bu: Pablo Neira Ayuso <pablo@netfilter.org>
2010-10-25attr: rename str_null from NULL awayJan Engelhardt
A small little pedantism: NULL (as in, the pointer) isn't NUL (as in, the character with value zero, '\0'). I propose to rename it to strz, for the zero-terminated string (sometimes referred to as ASCIZ string, but of course C isn't tied to ASCII). Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-10-25nlmsg: use bool return type for yes-no functionsJan Engelhardt
Signed-off-by: Jan Engelhardt <jengelh@medozas.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-10-22include: add cplusplus guards for externJan Engelhardt
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
2010-10-22socket: use more appropriate types for mnl_socket_bindJan Engelhardt
groups, being a bitmask, should be unsigned; and let's also use pid_t for pid. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
2010-10-22callback: mnl_cb_run should use a void *Jan Engelhardt
Because in most cases, it won't be a nul-terminated string :) Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
2010-10-22attr: string functions should take char *Jan Engelhardt
I do not quite see the point of using strlen in conjunction with non-string data; so let's use char * as argument types to catch misuses. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
2010-10-22include: consistent usage of "extern"Jan Engelhardt
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
2010-10-21src: define MNL_SOCKET_BUFFER_SIZE to 8192ULPablo Neira Ayuso
Davem spotted during the Netfilter Workshop that user-space applications should use 8KB buffers for recv(). I accidentally found that NFLOG is not following this approach (in this case we're using 131072 bytes messages), we have to document this. Anyway, according to linux/netlink.h (and to complete this log message): "skb should fit one page. This choice is good for headerless malloc. But we should limit to 8K so that userspace does not have to use enormous buffer sizes on recvmsg() calls just to avoid MSG_TRUNC when PAGE_SIZE is very large." Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-06-25socket: remove mnl_socket_sendmsg() and mnl_socket_recvmsg()Pablo Neira Ayuso
These functions are too simple wrappers that bloat the library. We can use mnl_socket_get_fd() to obtain the file descriptor and invoke message-oriented system call instead. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-05-17nlmsg: use size_t instead of int for several input parametersPablo Neira Ayuso
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-30add helpers to nest attributesPablo Neira Ayuso
Based on code from Jozsef Kadlecsik and its ipset-5 implementation. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-22remove references to 'generic' in header filePablo Neira Ayuso
The term 'Generic' is used in GeNetlink, we don't want any confusion with it. Better remove it. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-22use size_t to indicate the buffer size in mnl_cb_run*()Pablo Neira Ayuso
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-22review data types for input parameters of mnl_attr_*() functionsPablo Neira Ayuso
This patch includes the following changes: * use uint16_t for attribute types in mnl_attr_put_*() function * use uint16_t for maximun type in mnl_attr_type_valid(...) * use size_t for attribute size validation in mnl_attr_validate2(...) * use unsigned int for offset in mnl_attr_parse(...) instead of int Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-19add mnl_nlmsg_fprintf() function for debugging purposesPablo Neira Ayuso
This function is still quite preliminary, comments welcome! Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-16fix for mnl_attr_for_each_nested()Jozsef Kadlecsik
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-12remove mnl_nlmsg_get_len() functionPablo Neira Ayuso
Remove mnl_nlmsg_get_len() since it returns a field of a structure that is public (struct nlmsghdr). We can directly access the header fields and they are not likely to change in the future (at least for this version of Netlink I think). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-05more consistency name issues: rename get_data*() to get_payload*()Pablo Neira Ayuso
This includes renaming get_tail() to get_payload_tail() Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-05rename mnl_nlmsg_payload_size() to mnl_nlmsg_get_payload_len() for consistencyPablo Neira Ayuso
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-05rename mnl_attr_type_ok() by mnl_attr_type_valid() for consistencyPablo Neira Ayuso
better to rename this function since its return value is not similar to other _ok() functions, for consistency. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-04rename mnl_attr_type_invalid() by mnl_attr_type_ok()Pablo Neira Ayuso
And include the prototype in libmnl.h, since it was missing Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-04remove mnl_align() as it's been replaced by MNL_ALIGN()Pablo Neira Ayuso
We remove mnl_align() since it has been replaced by the macro MNL_ALIGN(). The macro allows its use in static arrays and such. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-04check source of the netlink message and fix sequence tracking logicPablo Neira Ayuso
This patch changes the callback handlers to include netlink portID checking. Thus, we avoid that any malicious process can spoof messages. If portid, sequence number of the message is != 0, we check if the message is what we expect. This allows to use the same netlink channel for dumps (portid, seq != 0) and event-based notifications (portid, seq == 0). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-03add validation infrastructure and rework attribute parsingPablo Neira Ayuso
This patch includes the new validation infrastructure which is decoupled from the attribute parsing. It is composed of: - mnl_attr_type_invalid: that allows to check if the attribute type is valid (ie. the type is not higher than WXYZ_MAX). - mnl_attr_validate: that allows to validate that there's enough room for the attribute data. The patch includes the rework of the attribute parsers. Now, you don't have to use an array of pointer to store the result of the parsing, you can use whatever data structure instead. The prototype as it follows: typedef int (*mnl_attr_cb_t)(const struct nlattr *attr, void *data); extern int mnl_attr_parse(const struct nlmsghdr *nlh, int offset, mnl_attr_cb_t cb, void *data) There are three versions of rtnl-link-dump.c that show how attribute parsing can be done now. Probably that many examples are not good idea, I may remove some of them from the tree in the future. This patch also merges mnl_attr_parse_at_offset into mnl_attr_parse. This patch modifies MNL_ALIGN so that we can use it in static arrays (the use of mnl_align() is not allowed in compilation time to initialize an array field). I have added the mnl_attr_for_each() macro and I have changed mnl_attr_for_each_nested() to declare the length variable internally. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-03use C99 types uintXX_t instead of POSIX u_intXX_tPablo Neira Ayuso
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2010-04-03constify several mnl_socket_* parameters and use size_t instead of intPablo Neira Ayuso
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>