summaryrefslogtreecommitdiff
path: root/proto_vlan.h
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2015-08-17 00:21:30 +0300
committerTobias Klauser <tklauser@distanz.ch>2015-08-17 09:43:27 +0200
commitf4b90d0194cdb5275823116b2229c04249225d7e (patch)
tree703e59f323c3e9875aec66f764b365c88f8391cc /proto_vlan.h
parent69cb4a22c8bbe841ec3b0bf1983610548f4dce74 (diff)
netsniff-ng: vlan: Use helpers when parse vlan header
Add proto_vlan.h with helpers to parse VLAN fields. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'proto_vlan.h')
-rw-r--r--proto_vlan.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/proto_vlan.h b/proto_vlan.h
new file mode 100644
index 0000000..dc31cfa
--- /dev/null
+++ b/proto_vlan.h
@@ -0,0 +1,27 @@
+/*
+ * proto_vlan.h - VLAN proto helpers & declarations
+ * Subject to the GPL, version 2.
+ */
+
+#ifndef PROTO_VLAN_H
+#define PROTO_VLAN_H
+
+#include <stdbool.h>
+#include <inttypes.h>
+
+static inline uint16_t vlan_tci2prio(uint16_t tci)
+{
+ return (tci & 0xe000) >> 13;
+}
+
+static inline uint16_t vlan_tci2cfi(uint16_t tci)
+{
+ return (tci & 0x1000) >> 12;
+}
+
+static inline uint16_t vlan_tci2vid(uint16_t tci)
+{
+ return tci & 0x0fff;
+}
+
+#endif