From patchwork Mon May 9 16:41:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16119 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 4238982787; Mon, 9 May 2016 18:42:18 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=open-mesh.com Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=open-mesh-com.20150623.gappssmtp.com header.i=@open-mesh-com.20150623.gappssmtp.com header.b=fa5V1B1R; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received-SPF: Neutral (access neither permitted nor denied) identity=mailfrom; client-ip=2a00:1450:400c:c09::229; helo=mail-wm0-x229.google.com; envelope-from=sven.eckelmann@open-mesh.com; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=none header.from=open-mesh.com Received: from mail-wm0-x229.google.com (mail-wm0-x229.google.com [IPv6:2a00:1450:400c:c09::229]) by open-mesh.org (Postfix) with ESMTPS id 7C6AD82775 for ; Mon, 9 May 2016 18:41:57 +0200 (CEST) Received: by mail-wm0-x229.google.com with SMTP id g17so197194109wme.1 for ; Mon, 09 May 2016 09:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=21BOWkO0a4NBtUER54aPXZAY7JDdn/MezcUAFi14d8E=; b=fa5V1B1RMI7Lo+5/AAN7DkI0AMvh0FHhWpDIIR7B5ugtIuX2FGIkxK3KiV0qKHc9KD K4aeugrEcqpik+MZCchNtk0da9kt66sVQrQQE/3MJ7AmLNmZ/gW/Vvd0e8sKahz8EKHI tvJHOYTWypmqSpkubF4RGpAKoESL9OIg2tiQkbj6BMhboeyUuaiPeSAxV5bGzJsaadO+ wFXEoSKZhxayZhrZLidfZFJmGbUtMY46wBriHJeyGUNfB79jXkyomjd+QlZGfFdoK+Ii kFBz7JZwrxDf34zPgXFcBqSCiFam4dc2cG6o4cvvuHdDHEkwU9WT9jEaW5HRmoxQM037 tjRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=21BOWkO0a4NBtUER54aPXZAY7JDdn/MezcUAFi14d8E=; b=nNxgLMfW6nuqPHG4mfksR6udUmQH8OqLWlMxvH12DZ7kF3SEGaQC5DTzww3RooBQLF Q/DbfjVUd7LSMETWyu9ONxhFk0m7SzwKUPYQUExMFNelVVkrHxP8goP5MluR8vyYHWUv sIShcgFV6dJB6/xWXtKBexRjZzsfoJuUk4WvXTIOH2N+Bvg6lBpzLSKh6BYpKCvxts1W Dq9G3NxmXPYEFrvd1umhYVSPBdAcAoSN4M5wUjyagk4uJUca0ZfcRiH7sz3o2y5gmG8W 2BtUeHklI/YQyMUeuvaYhEZM4bD7uFgVqnGNFiSrluJ8wmMDpEtS8cMvlJNhqCTPmEsC hTag== X-Gm-Message-State: AOPr4FV3kkDDGuUI5FBbHfQ6EF9y8VnB+2KS3l1H2kVFPWiHnSREjipVEyVbL3UcwA9Tydx2 X-Received: by 10.28.139.137 with SMTP id n131mr11873267wmd.13.1462812117059; Mon, 09 May 2016 09:41:57 -0700 (PDT) Received: from sven-desktop.home.narfation.org (p4FFE56B5.dip0.t-ipconnect.de. [79.254.86.181]) by smtp.gmail.com with ESMTPSA id f8sm32072199wjm.13.2016.05.09.09.41.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 May 2016 09:41:56 -0700 (PDT) From: Sven Eckelmann X-Google-Original-From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 9 May 2016 18:41:52 +0200 Message-Id: <1462812114-16577-2-git-send-email-sven@open-mesh.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <6307812.WAqRcEYAvX@bentobox> References: <6307812.WAqRcEYAvX@bentobox> Subject: [B.A.T.M.A.N.] [PATCH v7 2/4] batctl: Add basic infrastructure to integrate netlink X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" From: Sven Eckelmann 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 Forwarded: https://patchwork.open-mesh.org/patch/16079/ --- Makefile | 12 ++++++++++++ batman_adv.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ netlink.c | 28 ++++++++++++++++++++++++++++ netlink.h | 30 ++++++++++++++++++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 batman_adv.h create mode 100644 netlink.c create mode 100644 netlink.h 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 . + */ + +#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/netlink.c b/netlink.c new file mode 100644 index 0000000..409953a --- /dev/null +++ b/netlink.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * + * Marek Lindner + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA + * + */ + +#include "netlink.h" +#include "main.h" + +#include "batman_adv.h" + +struct nla_policy batadv_netlink_policy[NUM_BATADV_ATTR] = { +}; diff --git a/netlink.h b/netlink.h new file mode 100644 index 0000000..0a4d3dd --- /dev/null +++ b/netlink.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2009-2016 B.A.T.M.A.N. contributors: + * + * Marek Lindner + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA + * + */ + +#ifndef _BATCTL_NETLINK_H +#define _BATCTL_NETLINK_H + +#include +#include + +extern struct nla_policy batadv_netlink_policy[]; + +#endif /* _BATCTL_NETLINK_H */