summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* examples: fix neigh max attributesLaura Garcia Liebana2018-05-231-2/+2
| | | | | | | | Use NDA_MAX for neigh maximum attributes instead of IFA_MAX, which is only for interfaces. Signed-off-by: Laura Garcia Liebana <nevola@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: add arp cache dump exampleLaura Garcia Liebana2018-05-182-1/+166
| | | | | | | | | Adding ARP example in order to dump the info in the form: index=<interface> family=<family> dst=<destination ip> lladdr=<mac address> state=<arp status> Signed-off-by: Laura Garcia Liebana <nevola@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* libmnl: zero attribute paddingFlorian Westphal2018-03-201-0/+5
| | | | | | | | | | | | | | | | | | | | | | Sergei Trofimovich reports 'uninitialized bytes' warnings from nftables: Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s) at 0x55B9EFB: sendmsg (in /lib64/libc-2.25.so) by 0x43E658: mnl_nft_socket_sendmsg (mnl.c:239) by 0x43E658: mnl_batch_talk (mnl.c:254) by 0x407898: nft_netlink (libnftables.c:58) by 0x407898: nft_run (libnftables.c:96) by 0x407CD5: nft_run_cmd_from_buffer (libnftables.c:291) by 0x406EDE: main (main.c:274) This is harmless, the uninitialized memory is the padding that sometimes needs to be inserted between end of an attribute and the beginning of the new attribute. Zero it to silence memory sanitizer output. Signed-off-by: Florian Westphal <fw@strlen.de> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: rtnl-addr-dump: fix typoStephen Hemminger2018-01-191-1/+1
| | | | | | | | The example about addresses uses link attributes when it meant to use address attributes. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* callback: mark cb_ctl_array 'const' in mnl_cb_run2()Guillaume Nault2016-08-082-3/+4
| | | | | | | | | | | | | | | | | Users of mnl_cb_run2() would typically pass a 'static const' array as cb_ctl_array parameter. Unfortunately this triggers a compiler warning because the prototype doesn't declare cb_ctl_array with the 'const' qualifier. Since mnl_cb_run2() and __mnl_cb_run() don't modify cb_ctl_array (and don't have any reason to do so in the future), we can mark this parameter as 'const'. There should be no impact on existing users beyond removing the compiler warning when using a constant array. Signed-off-by: Guillaume Nault <g.nault@alphalink.fr> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: nfct-daemon: Fix test building on musl libcKylie McClain2016-07-211-0/+1
| | | | | | | On musl libc, sys/select.h is where FD_* definitions are located. Signed-off-by: Kylie McClain <somasis@exherbo.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: libmnl 1.0.4 releaselibmnl-1.0.4Pablo Neira Ayuso2016-07-022-2/+2
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* src: cleanup function definitionsPablo Neira Ayuso2016-07-014-72/+51
| | | | | | | Place the returned value, function name and parameters (as many as can fit) in the same line. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* Move declaration of visibility attributes before definition.Peter Foley2016-07-014-68/+68
| | | | | | | | | | | | | | | | | | | | When compiling with clang, the visibility attributes are ignored since they are after the definition of the exported function. Fix this by moving the attribute declaration before the function. attr.c:439:1: error: attribute declaration must precede definition [-Werror,-Wignored-attributes] EXPORT_SYMBOL(mnl_attr_put_u8); ^ ./internal.h:7:41: note: expanded from macro 'EXPORT_SYMBOL' ^ ./internal.h:6:35: note: expanded from macro '__visible' ^ attr.c:435:6: note: previous definition is here void mnl_attr_put_u8(struct nlmsghdr *nlh, uint16_t type, uint8_t data) ^ Signed-off-by: Peter Foley <pefoley2@pefoley.com>
* nlmsg: Improve payload printingCarlos Falgueras García2016-06-081-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | It makes more sense to use isprint() than isalnum() because we use non alphanumeric characters like '%', '_', etc. And, in case of non printable character, print a space is preferable to print a NULL (0) in order to keep alignment. Before: ... |00012|--|00002| |len |flags| type| | 5f 5f 73 65 | | data | s e | 74 25 64 00 | | data | t d ... After: ... |00012|--|00002| |len |flags| type| | 5f 5f 73 65 | | data | _ _ s e | 74 25 64 00 | | data | t % d ... Signed-off-by: Carlos Falgueras García <carlosfg@riseup.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* socket: introduce mnl_socket_open2()Guillaume Nault2015-10-043-10/+35
| | | | | | | | 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>
* example: netfilter: get rid of aligned_be64 definitionsPablo Neira Ayuso2015-05-262-10/+0
| | | | | | | | | | This is defined in <linux/types.h>, which is included by the nfnetlink_* header files. Thus, we can get rid of u_int64_t which causes problems to musl according to Felix Janda. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples/netfilter: Include <endian.h> for be64tohFelix Janda2015-05-252-0/+2
| | | | | Signed-off-by: Felix Janda <felix.janda@posteo.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* header: use sysconf() instead of getpagesize()Markus Teich2015-03-021-1/+1
| | | | | | | 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>
* attr: minor doc fix in mnl_attr_next()Hisao Tanabe2015-01-101-1/+0
| | | | | | | mnl_attr_next(): remove unused param - len Signed-off-by: Hisao Tanabe <xtanabe@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* doc: minor fixKen-ichirou MATSUZAWA2014-10-242-5/+3
| | | | | | | | | | | mnl_attr_ok(): fix return value type mnl_attr_put_u8(): remove unused param - len mnl_attr_put_u8_check(): remove unused param - len mnl_nlmsg_ok(): fix return value type mnl_nlmsg_batch_stop(): not return batch size, but release it Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> Signed-off-by: Florian Westphal <fw@strlen.de>
* socket: creating a struct mnl_socket from a pre-existing socketKen-ichirou MATSUZAWA2014-09-253-0/+39
| | | | | | | | | 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>
* socket: calloc expects struct size as second parameterPablo Neira Ayuso2014-09-241-1/+1
| | | | | | | The parameters where accidentally swapped. Reported-by: Chris Rapier <rapier@psc.edu> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* include: cache copy of include/linux/socket.hPablo Neira Ayuso2014-06-132-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | This fixes compilation in Debian Squeeze: CC attr.lo In file included from ../include/libmnl/libmnl.h:9, from socket.c:10: ../include/linux/netlink.h:35: error: expected specifier-qualifier-list before ‘__kernel_sa_family_t’ In file included from ../include/libmnl/libmnl.h:9, from callback.c:11: ../include/linux/netlink.h:35: error: expected specifier-qualifier-list before ‘__kernel_sa_family_t’ socket.c: In function ‘mnl_socket_get_portid’: socket.c:102: error: ‘const struct sockaddr_nl’ has no member named ‘nl_pid’ socket.c: In function ‘mnl_socket_bind’: socket.c:146: error: ‘struct sockaddr_nl’ has no member named ‘nl_family’ socket.c:147: error: ‘struct sockaddr_nl’ has no member named ‘nl_groups’ socket.c:148: error: ‘struct sockaddr_nl’ has no member named ‘nl_pid’ socket.c:163: error: ‘struct sockaddr_nl’ has no member named ‘nl_family’ socket.c: In function ‘mnl_socket_sendto’: socket.c:184: error: unknown field ‘nl_family’ specified in initializer socket.c:185: warning: excess elements in struct initializer socket.c:185: warning: (near initialization for ‘snl’) Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: use mnl_socket_setsockoptKen-ichirou MATSUZAWA2013-12-071-4/+2
| | | | | | | instead of raw setsockopt() Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> Signed-off-by: Florian Westphal <fw@strlen.de>
* examples: fix display conditionKen-ichirou MATSUZAWA2013-12-071-2/+3
| | | | | Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> Signed-off-by: Florian Westphal <fw@strlen.de>
* examples: made sub functions the sameKen-ichirou MATSUZAWA2013-12-072-6/+17
| | | | | | | show entry in oneline and RTA_PRIORITY Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> Signed-off-by: Florian Westphal <fw@strlen.de>
* attr: validate MNL_TYPE_MSEC same as MNL_TYPE_U64Ken-ichirou MATSUZAWA2013-12-071-0/+1
| | | | | Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> Signed-off-by: Florian Westphal <fw@strlen.de>
* examples: use mnl_nlmsg_get_payload()Ken-ichirou MATSUZAWA2013-12-071-1/+1
| | | | | | | not increment (nlmsghdr) pointer Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> Signed-off-by: Florian Westphal <fw@strlen.de>
* examples: fix trivial error messageKen-ichirou MATSUZAWA2013-12-0715-34/+34
| | | | | Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> Signed-off-by: Florian Westphal <fw@strlen.de>
* examples: set attr tableKen-ichirou MATSUZAWA2013-12-072-0/+8
| | | | | | | Florian adviced rtnl-route-event.c has same problem Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp> Signed-off-by: Florian Westphal <fw@strlen.de>
* doc: mnl_socket_open returns NULL on errorShawn Landden2013-12-071-1/+1
| | | | Signed-off-by: Florian Westphal <fw@strlen.de>
* configure: uclinux is also linuxGustavo Zacarias2013-09-171-1/+1
| | | | | Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* include: don't force compiler to enter C++11 modePablo Neira Ayuso2013-07-161-8/+3
| | | | | | | | | | | 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>
* examples: netfilter: add nfct daemon skeleton codePablo Neira Ayuso2013-07-052-1/+370
| | | | | | | | This patch adds the skeleton code for a daemon that collects statistics via ctnetlink. Consider it a simplified version of ulogd2. It also contains some documentation on several interesting tweaks. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* include: cache copy of nfnetlink_conntrack.hPablo Neira Ayuso2013-06-114-1/+255
| | | | | | | To ensure that examples compile in any installation. This header is not installed in the system. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: netfilter: add nfct-dumpPablo Neira Ayuso2013-05-312-0/+322
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: add rtnl-addr-dumpPablo Neira Ayuso2013-05-282-1/+138
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: rtnl-link-dump: display HW addressPablo Neira Ayuso2013-05-271-1/+19
|
* examples: rtnl-route-dump: display also metric/priorityPablo Neira Ayuso2013-05-021-0/+3
| | | | | | If present in the route message, otherwise simply skip it. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: rtnl-route-add: fix typo in IPv6 supportPablo Neira Ayuso2013-05-021-1/+1
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: rtnl-route-event: update Makefile.amPablo Neira Ayuso2013-04-241-1/+5
| | | | | | So you can compile rtnl-route-event via `make check' Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: rtnl-route-event: add example to listen to IPv4/IPv6 routesPablo Neira Ayuso2013-04-241-0/+330
| | | | | | Derived from rtnl-route-dump.c Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: rtnl-route-add improvements (including IPv6 support)Pablo Neira Ayuso2013-04-241-24/+57
| | | | | | | | | | | | | | | Now, both IPv4 and IPv6 are supported simultaneously in one single file. While at it: * I moved the declarations to the beginning of the main function. * Renamed mask by prefix, which seems more appropriate to me. * Use RTPROTO_STATIC, as the route has been added by the administrator. * Set NLM_F_ACK, so we get a report from the kernel about our query and treat reply from the kernel. * Stricter argc checking. * Use perror instead of printf for error reporting. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* callback: fix missing handling of NLM_F_DUMP_INTRStephen Hemminger2013-03-271-1/+8
| | | | | | | | | | Propagate the error to the user-space application, that should retry. [ I have mangled this patch to document EINTR in mnl_cb_run. --pablo ] Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* headers: update netlink.h to 3.9Stephen Hemminger2013-03-261-5/+10
| | | | | | | | Use sanitized kernel header from 3.9 upstream kernel. Reported-by: Nicolas Dichtel <nicolas.dichtel@6wind.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: add kobject-eventPablo Neira Ayuso2013-03-264-2/+57
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* examples: add genl-group-eventsPablo Neira Ayuso2013-03-192-1/+68
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* doxygen: fix a variable name.Eric Leblond2013-03-141-1/+1
| | | | | | Variable name in doxygen description was not correct. Signed-off-by: Eric Leblond <eric@regit.org>
* examples: rtnl-route-dump: add IPv6 supportPhilip Prindeville2012-08-091-5/+108
| | | | | | | | | [ Pablo has modified the original patch modified to fix some compilation warnings with gcc-4.7 and select the protocol family as argument from the command line. ] Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* parse: add mnl_attr_for_each_payloadlibmnl-1.0.3Pablo Neira Ayuso2012-05-185-6/+45
| | | | | | | | | | | | 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>
* nlmsg: fix valgrind warnings about paddingStephen Hemminger2012-04-191-2/+3
| | | | | | | | | When using mnl_nlmsg_put_extra_header() it pads out the addtional header but only zeros the original size not the padded value. Which cause valgrind to complain about sendto() with uninitialized byte. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: libmnl 1.0.2 releaselibmnl-1.0.2Pablo Neira Ayuso2012-01-021-1/+1
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* example: release them in the public domainPablo Neira Ayuso2012-01-0212-72/+12
| | | | | | | | I have decided to release the examples in this library in the public domain. Jan Engelhardt, who has been the sole contributor so far, has agreed with this re-licensing by communication via e-mail. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: kernel-like compilation messagesPablo Neira Ayuso2011-12-271-0/+3
| | | | | | | | | | CC socket.lo CC callback.lo CC nlmsg.lo CC attr.lo CCLD libmnl.la Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>