Repository : ssh://git@open-mesh.org/batctl
On branch : master
commit 8f0805f2d467bc009d56f819504f20f3a04fb002 Author: Sven Eckelmann sven.eckelmann@open-mesh.com Date: Mon May 9 18:41:52 2016 +0200
batctl: Add basic infrastructure to integrate netlink
Netlink can be used to add new communication functionality to the kernel module. It can also be used to replace the old debugfs files. The binary interface used for this will be defined in the added files.
Signed-off-by: Sven Eckelmann sven.eckelmann@open-mesh.com Signed-off-by: Marek Lindner mareklindner@neomailbox.ch
8f0805f2d467bc009d56f819504f20f3a04fb002 Makefile | 12 +++++++++++ batman_adv.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++ translate.h => netlink.c | 9 ++++---- traceroute.h => netlink.h | 11 ++++++---- 4 files changed, 77 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile index a037847..3fa21f4 100755 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ OBJ += hash.o OBJ += ioctl.o OBJ += list-batman.o OBJ += main.o +OBJ += netlink.o OBJ += ping.o OBJ += sys.o OBJ += tcpdump.o @@ -73,6 +74,17 @@ endif CFLAGS += $(LIBNL_CFLAGS) LDLIBS += $(LIBNL_LDLIBS)
+ifeq ($(origin LIBNL_GENL_CFLAGS) $(origin LIBNL_GENL_LDLIBS), undefined undefined) + LIBNL_GENL_NAME ?= libnl-genl-3.0 + ifeq ($(shell $(PKG_CONFIG) --modversion $(LIBNL_GENL_NAME) 2>/dev/null),) + $(error No $(LIBNL_GENL_NAME) development libraries found!) + endif + LIBNL_GENL_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(LIBNL_GENL_NAME)) + LIBNL_GENL_LDLIBS += $(shell $(PKG_CONFIG) --libs $(LIBNL_GENL_NAME)) +endif +CFLAGS += $(LIBNL_GENL_CFLAGS) +LDLIBS += $(LIBNL_GENL_LDLIBS) + # standard build tools ifeq ($(CONFIG_BATCTL_BISECT),y) OBJ += $(OBJ_BISECT) diff --git a/batman_adv.h b/batman_adv.h new file mode 100644 index 0000000..ba611a7 --- /dev/null +++ b/batman_adv.h @@ -0,0 +1,53 @@ +/* Copyright (C) 2016 B.A.T.M.A.N. contributors: + * + * Matthias Schiffer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + */ + +#ifndef _UAPI_LINUX_BATMAN_ADV_H_ +#define _UAPI_LINUX_BATMAN_ADV_H_ + +#define BATADV_NL_NAME "batadv" + +/** + * enum batadv_nl_attrs - batman-adv netlink attributes + * + * @BATADV_ATTR_UNSPEC: unspecified attribute to catch errors + * @__BATADV_ATTR_AFTER_LAST: internal use + * @NUM_BATADV_ATTR: total number of batadv_nl_attrs available + * @BATADV_ATTR_MAX: highest attribute number currently defined + */ +enum batadv_nl_attrs { + BATADV_ATTR_UNSPEC, + /* add attributes above here, update the policy in netlink.c */ + __BATADV_ATTR_AFTER_LAST, + NUM_BATADV_ATTR = __BATADV_ATTR_AFTER_LAST, + BATADV_ATTR_MAX = __BATADV_ATTR_AFTER_LAST - 1 +}; + +/** + * enum batadv_nl_commands - supported batman-adv netlink commands + * + * @BATADV_CMD_UNSPEC: unspecified command to catch errors + * @__BATADV_CMD_AFTER_LAST: internal use + * @BATADV_CMD_MAX: highest used command number + */ +enum batadv_nl_commands { + BATADV_CMD_UNSPEC, + /* add new commands above here */ + __BATADV_CMD_AFTER_LAST, + BATADV_CMD_MAX = __BATADV_CMD_AFTER_LAST - 1 +}; + +#endif /* _UAPI_LINUX_BATMAN_ADV_H_ */ diff --git a/translate.h b/netlink.c similarity index 85% copy from translate.h copy to netlink.c index f652091..409953a 100644 --- a/translate.h +++ b/netlink.c @@ -19,9 +19,10 @@ * */
-#ifndef _BATCTL_TRANSLATE_H -#define _BATCTL_TRANSLATE_H +#include "netlink.h" +#include "main.h"
-int translate(char *mesh_iface, int argc, char **argv); +#include "batman_adv.h"
-#endif +struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { +}; diff --git a/traceroute.h b/netlink.h similarity index 79% copy from traceroute.h copy to netlink.h index 6dc5603..0a4d3dd 100644 --- a/traceroute.h +++ b/netlink.h @@ -19,9 +19,12 @@ * */
-#ifndef _BATCTL_TRACEROUTE_H -#define _BATCTL_TRACEROUTE_H +#ifndef _BATCTL_NETLINK_H +#define _BATCTL_NETLINK_H
-int traceroute(char *mesh_iface, int argc, char **argv); +#include <netlink/genl/genl.h> +#include <netlink/genl/ctrl.h>
-#endif +extern struct nla_policy batadv_netlink_policy[]; + +#endif /* _BATCTL_NETLINK_H */