summaryrefslogtreecommitdiffstats
path: root/examples/rtnl-link-event.c
Commit message (Collapse)AuthorAgeFilesLines
* examples: put examples files into specific directoriesPablo Neira Ayuso2010-09-081-100/+0
| | | | | | | put examples files into specific directories according to the Netlink bus they work with. And minor update in the readme file Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* relax mnl_attr_type_valid() checkings and change errno valuePablo Neira Ayuso2010-05-091-4/+3
| | | | | | | | This patch relaxes strict attribute checkings in the example files. I have also changed the errno value, now it's EOPNOTSUPP instead of EINVAL. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* add licensing terms of example filesPablo Neira Ayuso2010-05-031-0/+6
| | | | Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* fix lots of compilation warnings in example filesPablo Neira Ayuso2010-04-221-3/+0
| | | | | | They have been spotted by -Wall -Wextra Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* remove mnl_nlmsg_get_len() functionPablo Neira Ayuso2010-04-121-1/+1
| | | | | | | | | 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>
* 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>
* rename mnl_attr_type_ok() by mnl_attr_type_valid() for consistencyPablo Neira Ayuso2010-04-051-2/+2
| | | | | | | 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>
* rename mnl_attr_type_invalid() by mnl_attr_type_ok()Pablo Neira Ayuso2010-04-041-2/+2
| | | | | | And include the prototype in libmnl.h, since it was missing Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* check source of the netlink message and fix sequence tracking logicPablo Neira Ayuso2010-04-041-1/+1
| | | | | | | | | | | | 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>
* add validation infrastructure and rework attribute parsingPablo Neira Ayuso2010-04-031-2/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* revert abcaad6b65ed368c13c353ed71619332f76d9c2aPablo Neira Ayuso2010-04-031-4/+0
| | | | it's deeply broken 8-)
* check portid of received messages in examplesPablo Neira Ayuso2010-04-031-0/+4
| | | | | | | netlink is not connection-oriented, we have to check the origin of the message. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
* initial libmnl importPablo Neira Ayuso2010-03-191-0/+70