From patchwork Sat Jul 27 19:54:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: michael-dev X-Patchwork-Id: 262507 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 544162C010B for ; Sun, 28 Jul 2013 05:56:14 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 531DB17C0EE; Sat, 27 Jul 2013 15:56:12 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b4Vwblvs0Eyq; Sat, 27 Jul 2013 15:56:12 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id EF5BE17C0F0; Sat, 27 Jul 2013 15:55:21 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 3313817C0EE for ; Sat, 27 Jul 2013 15:55:20 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m8jFQnsChkCB for ; Sat, 27 Jul 2013 15:55:14 -0400 (EDT) Received: from mail.fem.tu-ilmenau.de (mail.fem.tu-ilmenau.de [141.24.101.79]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id A78BC17C10E for ; Sat, 27 Jul 2013 15:54:53 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.fem.tu-ilmenau.de (Postfix) with ESMTP id 836E6655D for ; Sat, 27 Jul 2013 21:54:52 +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 UJU14X7--vIv; Sat, 27 Jul 2013 21:54:51 +0200 (CEST) Received: from a234.fem.tu-ilmenau.de (unknown [10.42.51.234]) by mail.fem.tu-ilmenau.de (Postfix) with ESMTP; Sat, 27 Jul 2013 21:54:51 +0200 (CEST) Received: from [10.42.51.234] (localhost [127.0.0.1]) by a234.fem.tu-ilmenau.de (Postfix) with ESMTP id 884F4BED2D; Sat, 27 Jul 2013 21:54:51 +0200 (CEST) Subject: [PATCH v4 05/25] VLAN: Create new data type for VLAN description. To: hostap@lists.shmoo.com From: Michael Braun Date: Sat, 27 Jul 2013 21:54:51 +0200 Message-ID: <20130727195451.17627.62877.stgit@ray-controller> In-Reply-To: <20130727195247.17627.28374.stgit@ray-controller> References: <20130727195247.17627.28374.stgit@ray-controller> User-Agent: StGit/0.16 MIME-Version: 1.0 Cc: projekt-wlan@fem.tu-ilmenau.de X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com This hides away the details of the currently in-use VLAN model and is preparing for adding tagged VLAN support later on. Implementing this as inline functions lets the compiler create as fast code as before the change. Signed-hostap: Michael Braun --- src/common/vlan.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/common/vlan.h diff --git a/src/common/vlan.h b/src/common/vlan.h new file mode 100644 index 0000000..9982d46 --- /dev/null +++ b/src/common/vlan.h @@ -0,0 +1,53 @@ +/* + * hostapd / VLAN definitions and helpers functions + * Copyright (c) 2013, Michael Braun + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef HOSTAPD_VLAN_H +#define HOSTAPD_VLAN_H + +#define VLAN_NULL 0 +typedef int vlan_t; + +static inline void vlan_alloc(vlan_t *dst, const int untagged) +{ + *dst = untagged; +} + +static inline void vlan_alloc_copy(vlan_t *dst, const vlan_t *src) +{ + *dst = *src; +} + +static inline void vlan_free(vlan_t *dst) +{ + *dst = 0; +} + +static inline int vlan_cmp(const vlan_t *a, const vlan_t *b) +{ + if (!a && !b) + return 1; + if (!a || !b) + return 0; + return (*a == *b); +} + +static inline int vlan_untagged(const vlan_t *a) +{ + if (!a) + return 0; + return *a; +} + +static inline int vlan_notempty(const vlan_t *a) +{ + if (!a) + return 0; + return *a; +} + +#endif