From patchwork Sat Sep 24 20:53:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: michael-dev X-Patchwork-Id: 674404 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3shNY35MxTz9s5g for ; Sun, 25 Sep 2016 07:24:55 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bnuR7-0000mq-UY; Sat, 24 Sep 2016 21:24:41 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bnuPW-0007b6-Uu for hostap@bombadil.infradead.org; Sat, 24 Sep 2016 21:23:03 +0000 Received: from mail.fem.tu-ilmenau.de ([141.24.220.54]) by merlin.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bnu3C-0000zz-Vc for hostap@lists.infradead.org; Sat, 24 Sep 2016 20:59:59 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.fem.tu-ilmenau.de (Postfix) with ESMTP id EA5E56997; Sat, 24 Sep 2016 22:54:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at fem.tu-ilmenau.de Received: from mail.fem.tu-ilmenau.de ([127.0.0.1]) by localhost (mail.fem.tu-ilmenau.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5vhevsnj3aVJ; Sat, 24 Sep 2016 22:54:18 +0200 (CEST) Received: from mail-backup.fem.tu-ilmenau.de (mail-backup.net.fem.tu-ilmenau.de [10.42.40.22]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.fem.tu-ilmenau.de (Postfix) with ESMTPS; Sat, 24 Sep 2016 22:54:18 +0200 (CEST) Received: from a234.fem.tu-ilmenau.de (ray-controller.net.fem.tu-ilmenau.de [10.42.51.234]) by mail-backup.fem.tu-ilmenau.de (Postfix) with ESMTP id C226E5604C; Sat, 24 Sep 2016 22:54:18 +0200 (CEST) Received: by a234.fem.tu-ilmenau.de (Postfix, from userid 1000) id B240C3020ED0; Sat, 24 Sep 2016 22:54:18 +0200 (CEST) From: Michael Braun To: hostap@lists.infradead.org Subject: [PATCH v2 18/33] factor out ifconfig for use with macvlan Date: Sat, 24 Sep 2016 22:53:59 +0200 Message-Id: <1474750454-6626-19-git-send-email-michael-dev@fami-braun.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1474750454-6626-1-git-send-email-michael-dev@fami-braun.de> References: <1474750454-6626-1-git-send-email-michael-dev@fami-braun.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160924_165959_264495_28B802D3 X-CRM114-Status: GOOD ( 14.90 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [141.24.220.54 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: projekt-wlan@fem.tu-ilmenau.de, Michael Braun MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Michael Braun --- hostapd/Makefile | 6 +++++- src/ap/vlan_full.c | 8 +------- src/ap/vlan_ifconfig.c | 9 ++++++++- src/ap/vlan_ifconfig.h | 16 ++++++++++++++++ src/ap/vlan_init.c | 1 + src/ap/vlan_util.h | 3 --- 6 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 src/ap/vlan_ifconfig.h diff --git a/hostapd/Makefile b/hostapd/Makefile index 46dffe5..20f7ef3 100644 --- a/hostapd/Makefile +++ b/hostapd/Makefile @@ -200,8 +200,8 @@ ifdef CONFIG_NO_VLAN CFLAGS += -DCONFIG_NO_VLAN else OBJS += ../src/ap/vlan_init.o -OBJS += ../src/ap/vlan_ifconfig.o OBJS += ../src/ap/vlan.o +NEED_IFCONFIG=y ifdef CONFIG_FULL_DYNAMIC_VLAN # Define CONFIG_FULL_DYNAMIC_VLAN to have hostapd manipulate bridges # and VLAN interfaces for the VLAN feature. @@ -215,6 +215,10 @@ endif endif endif +ifdef NEED_IFCONFIG +OBJS += ../src/ap/vlan_ifconfig.o +endif + ifdef CONFIG_NO_CTRL_IFACE CFLAGS += -DCONFIG_NO_CTRL_IFACE else diff --git a/src/ap/vlan_full.c b/src/ap/vlan_full.c index aa42335..3740857 100644 --- a/src/ap/vlan_full.c +++ b/src/ap/vlan_full.c @@ -25,6 +25,7 @@ #include "wpa_auth.h" #include "vlan_init.h" #include "vlan_util.h" +#include "vlan_ifconfig.h" struct full_dynamic_vlan { @@ -116,13 +117,6 @@ static int dyn_iface_put(struct hostapd_data *hapd, const char *ifname) } -static int ifconfig_down(const char *if_name) -{ - wpa_printf(MSG_DEBUG, "VLAN: Set interface %s down", if_name); - return ifconfig_helper(if_name, 0); -} - - /* This value should be 256 ONLY. If it is something else, then hostapd * might crash!, as this value has been hard-coded in 2.4.x kernel * bridging code. diff --git a/src/ap/vlan_ifconfig.c b/src/ap/vlan_ifconfig.c index ef953a5..0295ec5 100644 --- a/src/ap/vlan_ifconfig.c +++ b/src/ap/vlan_ifconfig.c @@ -16,7 +16,7 @@ #include "vlan_util.h" -int ifconfig_helper(const char *if_name, int up) +static int ifconfig_helper(const char *if_name, int up) { int fd; struct ifreq ifr; @@ -67,3 +67,10 @@ int iface_exists(const char *ifname) { return if_nametoindex(ifname); } + + +int ifconfig_down(const char *if_name) +{ + wpa_printf(MSG_DEBUG, "VLAN: Set interface %s down", if_name); + return ifconfig_helper(if_name, 0); +} diff --git a/src/ap/vlan_ifconfig.h b/src/ap/vlan_ifconfig.h new file mode 100644 index 0000000..53c3fa2 --- /dev/null +++ b/src/ap/vlan_ifconfig.h @@ -0,0 +1,16 @@ +/* + * hostapd / VLAN ifconfig helpers + * Copyright 2003, Instant802 Networks, Inc. + * Copyright 2005-2006, Devicescape Software, Inc. + * Copyright (c) 2009, Jouni Malinen + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef HOSTAPD_VLAN_IFCONFIG_H +#define HOSTAPD_VLAN_IFCONFIG_H +int ifconfig_up(const char *if_name); +int iface_exists(const char *ifname); +int ifconfig_down(const char *if_name); +#endif /* HOSTAPD_VLAN_IFCONFIG_H */ diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c index 31e4fc6..f931f67 100644 --- a/src/ap/vlan_init.c +++ b/src/ap/vlan_init.c @@ -17,6 +17,7 @@ #include "wpa_auth.h" #include "vlan_init.h" #include "vlan_util.h" +#include "vlan_ifconfig.h" static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan, diff --git a/src/ap/vlan_util.h b/src/ap/vlan_util.h index 2446859..6a541d4 100644 --- a/src/ap/vlan_util.h +++ b/src/ap/vlan_util.h @@ -17,9 +17,6 @@ int vlan_add(const char *if_name, int vid, const char *vlan_if_name); int vlan_rem(const char *if_name); int vlan_set_name_type(unsigned int name_type); -int ifconfig_helper(const char *if_name, int up); -int ifconfig_up(const char *if_name); -int iface_exists(const char *ifname); int vlan_if_remove(struct hostapd_data *hapd, struct hostapd_vlan *vlan); struct full_dynamic_vlan *