Patchwork [v3,05/25] VLAN: Create new data type for VLAN description.

login
register
mail settings
Submitter michael-dev@fami-braun.de
Date July 27, 2013, 4:10 p.m.
Message ID <20130727161016.1152.73233.stgit@ray-controller>
Download mbox | patch
Permalink /patch/262466/
State Superseded
Headers show

Comments

michael-dev@fami-braun.de - July 27, 2013, 4:10 p.m.
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 <michael-dev@fami-braun.de>
---
 src/common/vlan.h |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 src/common/vlan.h

Patch

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 <michael-dev@fami-braun.de>
+ *
+ * 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