[ovs-dev] [PATCH v6 02/13] Break packets.h into private and public parts

ben at skyportsystems.com ben at skyportsystems.com
Tue Apr 5 01:32:02 UTC 2016


From: Ben Warren <ben at skyportsystems.com>

Public (struct definitions and some prototypes) go in
include/openvswitch

Signed-off-by: Ben Warren <ben at skyportsystems.com>
---
 include/openvswitch/automake.mk |  1 +
 include/openvswitch/packets.h   | 64 +++++++++++++++++++++++++++++++++++++++++
 lib/packets.h                   | 43 +--------------------------
 3 files changed, 66 insertions(+), 42 deletions(-)
 create mode 100644 include/openvswitch/packets.h

diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
index 8d253f3..fc183ff 100644
--- a/include/openvswitch/automake.mk
+++ b/include/openvswitch/automake.mk
@@ -7,6 +7,7 @@ openvswitchinclude_HEADERS = \
 	include/openvswitch/ofpbuf.h \
 	include/openvswitch/ofp-errors.h \
 	include/openvswitch/ofp-parse.h \
+	include/openvswitch/packets.h \
 	include/openvswitch/thread.h \
 	include/openvswitch/token-bucket.h \
 	include/openvswitch/tun-metadata.h \
diff --git a/include/openvswitch/packets.h b/include/openvswitch/packets.h
new file mode 100644
index 0000000..5d97309
--- /dev/null
+++ b/include/openvswitch/packets.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OPENVSWITCH_PACKETS_H
+#define OPENVSWITCH_PACKETS_H 1
+
+#include <netinet/in.h>
+#include "openvswitch/tun-metadata.h"
+
+/* Tunnel information used in flow key and metadata. */
+struct flow_tnl {
+    ovs_be32 ip_dst;
+    struct in6_addr ipv6_dst;
+    ovs_be32 ip_src;
+    struct in6_addr ipv6_src;
+    ovs_be64 tun_id;
+    uint16_t flags;
+    uint8_t ip_tos;
+    uint8_t ip_ttl;
+    ovs_be16 tp_src;
+    ovs_be16 tp_dst;
+    ovs_be16 gbp_id;
+    uint8_t  gbp_flags;
+    uint8_t  pad1[5];        /* Pad to 64 bits. */
+    struct tun_metadata metadata;
+};
+
+/* Some flags are exposed through OpenFlow while others are used only
+ * internally. */
+
+/* Public flags */
+#define FLOW_TNL_F_OAM (1 << 0)
+
+#define FLOW_TNL_PUB_F_MASK ((1 << 1) - 1)
+
+/* Private flags */
+#define FLOW_TNL_F_DONT_FRAGMENT (1 << 1)
+#define FLOW_TNL_F_CSUM (1 << 2)
+#define FLOW_TNL_F_KEY (1 << 3)
+
+#define FLOW_TNL_F_MASK ((1 << 4) - 1)
+
+/* Unfortunately, a "struct flow" sometimes has to handle OpenFlow port
+ * numbers and other times datapath (dpif) port numbers.  This union allows
+ * access to both. */
+union flow_in_port {
+    odp_port_t odp_port;
+    ofp_port_t ofp_port;
+};
+
+#endif /* packets.h */
diff --git a/lib/packets.h b/lib/packets.h
index a8ea24b..8139a6b 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -19,11 +19,11 @@
 
 #include <inttypes.h>
 #include <sys/types.h>
-#include <netinet/in.h>
 #include <stdint.h>
 #include <string.h>
 #include "compiler.h"
 #include "openvswitch/geneve.h"
+#include "openvswitch/packets.h"
 #include "openvswitch/types.h"
 #include "odp-netlink.h"
 #include "random.h"
@@ -35,39 +35,6 @@
 struct dp_packet;
 struct ds;
 
-/* Tunnel information used in flow key and metadata. */
-struct flow_tnl {
-    ovs_be32 ip_dst;
-    struct in6_addr ipv6_dst;
-    ovs_be32 ip_src;
-    struct in6_addr ipv6_src;
-    ovs_be64 tun_id;
-    uint16_t flags;
-    uint8_t ip_tos;
-    uint8_t ip_ttl;
-    ovs_be16 tp_src;
-    ovs_be16 tp_dst;
-    ovs_be16 gbp_id;
-    uint8_t  gbp_flags;
-    uint8_t  pad1[5];        /* Pad to 64 bits. */
-    struct tun_metadata metadata;
-};
-
-/* Some flags are exposed through OpenFlow while others are used only
- * internally. */
-
-/* Public flags */
-#define FLOW_TNL_F_OAM (1 << 0)
-
-#define FLOW_TNL_PUB_F_MASK ((1 << 1) - 1)
-
-/* Private flags */
-#define FLOW_TNL_F_DONT_FRAGMENT (1 << 1)
-#define FLOW_TNL_F_CSUM (1 << 2)
-#define FLOW_TNL_F_KEY (1 << 3)
-
-#define FLOW_TNL_F_MASK ((1 << 4) - 1)
-
 /* Purely internal to OVS userspace. These flags should never be exposed to
  * the outside world and so aren't included in the flags mask. */
 
@@ -123,14 +90,6 @@ flow_tnl_equal(const struct flow_tnl *a, const struct flow_tnl *b)
     return a_size == flow_tnl_size(b) && !memcmp(a, b, a_size);
 }
 
-/* Unfortunately, a "struct flow" sometimes has to handle OpenFlow port
- * numbers and other times datapath (dpif) port numbers.  This union allows
- * access to both. */
-union flow_in_port {
-    odp_port_t odp_port;
-    ofp_port_t ofp_port;
-};
-
 /* Datapath packet metadata */
 struct pkt_metadata {
     uint32_t recirc_id;         /* Recirculation id carried with the
-- 
2.5.0




More information about the dev mailing list