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

Michael Braun michael-dev at fami-braun.de
Sat Jul 27 12:10:27 EDT 2013


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 at fami-braun.de>
---
 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 <michael-dev at 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



More information about the HostAP mailing list