summaryrefslogtreecommitdiffstats
path: root/src/callback.c
Commit message (Collapse)AuthorAgeFilesLines
* callback: mark cb_ctl_array 'const' in mnl_cb_run2()Guillaume Nault2016-08-081-2/+2
| | | | | | | | | | | | | | | | | 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>
* src: cleanup function definitionsPablo Neira Ayuso2016-07-011-11/+10
| | | | | | | 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-011-2/+2
| | | | | | | | | | | | | | | | | | | | 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>
* 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>
* doc: don't show up EXPORT_SYMBOL in doxygenPablo Neira Ayuso2011-02-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Patrick reports that the doxygen output shows up EXPORT_SYMBOL and tells how to fix this: > I just noticed the EXPORT_SYMBOLs in libmnl showing up in > the doxygen output. Just in case you want to avoid this, > what I'm doing in libdect is (besides the appopriate linker > flags): > > #define __visible __attribute__((visibility("default"))) > > #define EXPORT_SYMBOL(x) typeof(x) (x) __visible > > > This allows to use EXPORT_SYMBOL as in the kernel, IOW > after the function definition. This patch also removes -Wredundant-decls to avoid a warning in every single use of this new approach. Now, this looks more like the Linux kernel way of exporting symbols. Reported-by: Patrick McHardy <kaber@trash.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* callback: use of inline in mnl_cb_run*() functionPablo Neira Ayuso2010-12-121-35/+44
| | | | | | | | | This patch defines a new function __mnl_cb_run() which is inlined in mnl_cb_run() and mnl_cb_run2(). This patch increases the size of the library in ~1KB. IIRC, Davem suggested this during the Netfilter Workshop. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* build: tag function headers rather than decls as exportedJan Engelhardt2010-11-191-5/+8
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* license: change licensing terms from GPLv2+ to LGPLv2.1+Pablo Neira Ayuso2010-11-191-2/+2
| | | | | | | | | | Existing contributors ACK'ed the license change via email: * Jozsef Kadlecsik * Jan Engelhardt * Cristian Rodríguez Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* callback: mnl_cb_run should use a void *Jan Engelhardt2010-10-221-3/+3
| | | | | | Because in most cases, it won't be a nul-terminated string :) Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
* src: add const qualifiersJan Engelhardt2010-10-221-1/+1
| | | | Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
* doxygen documentationPablo Neira Ayuso2010-09-081-16/+25
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* change errno values for mnl_cb_run[2]()Pablo Neira Ayuso2010-05-071-3/+6
| | | | | | | | | | | | | This patch changes the errno value of mnl_cb_run[2]() in the following two cases: * Invalid expected portID: ESRCH. * Invalid sequence number: EPROTO. I didn't find any better generic errno value. EINVAL is reserved for malformed messages, to avoid confusions. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* fix warning in mnl_cb_run2()Pablo Neira Ayuso2010-04-221-3/+3
| | | | | | | callback.c: In function ‘mnl_cb_run2’: callback.c:106: warning: pointer targets in passing argument 2 of ‘mnl_nlmsg_next’ differ in signednes Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* use size_t to indicate the buffer size in mnl_cb_run*()Pablo Neira Ayuso2010-04-221-2/+2
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* more consistency name issues: rename get_data*() to get_payload*()Pablo Neira Ayuso2010-04-051-1/+1
| | | | | | This includes renaming get_tail() to get_payload_tail() Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* check source of the netlink message and fix sequence tracking logicPablo Neira Ayuso2010-04-041-5/+12
| | | | | | | | | | | | 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>
* partially revert previous commitPablo Neira Ayuso2010-03-281-2/+2
| | | | | the use of unsigned int in the number of bytes affects other message handling helper function, hold on with this.
* use `unsigned int' for number of bytes and array size in callback APIPablo Neira Ayuso2010-03-281-3/+3
|
* add COPYING filePablo Neira Ayuso2010-03-261-2/+4
| | | | | | This library is distributed under GPLv2+. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* fix mnl_cb_run() and mnl_cb_run2() return value logicPablo Neira Ayuso2010-03-261-5/+13
|
* finish API documentationPablo Neira Ayuso2010-03-221-1/+0
| | | | | | This patch may contain errors but we can review them and fix them later, better to have it in the tree (to allow others to contribute) to keep it in my local tree.
* initial libmnl importPablo Neira Ayuso2010-03-191-0/+119