fix VXLAN acronym
[dpdk.git] / lib / librte_ether / rte_ether.h
index c6782b8..f173509 100644 (file)
@@ -1,13 +1,13 @@
 /*-
  *   BSD LICENSE
- * 
- *   Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
+ *
+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
  *   All rights reserved.
- * 
+ *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
  *   are met:
- * 
+ *
  *     * Redistributions of source code must retain the above copyright
  *       notice, this list of conditions and the following disclaimer.
  *     * Redistributions in binary form must reproduce the above copyright
@@ -17,7 +17,7 @@
  *     * Neither the name of Intel Corporation nor the names of its
  *       contributors may be used to endorse or promote products derived
  *       from this software without specific prior written permission.
- * 
+ *
  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -67,6 +67,8 @@ extern "C" {
 
 #define ETHER_MAX_VLAN_ID  4095 /**< Maximum VLAN ID. */
 
+#define ETHER_MIN_MTU 68 /**< Minimum MTU for IPv4 packets, see RFC 791. */
+
 /**
  * Ethernet address:
  * A universally administered address is uniquely assigned to a device by its
@@ -85,6 +87,30 @@ struct ether_addr {
 #define ETHER_LOCAL_ADMIN_ADDR 0x02 /**< Locally assigned Eth. address. */
 #define ETHER_GROUP_ADDR       0x01 /**< Multicast or broadcast Eth. address. */
 
+/**
+ * Check if two Ethernet addresses are the same.
+ *
+ * @param ea1
+ *  A pointer to the first ether_addr structure containing
+ *  the ethernet address.
+ * @param ea2
+ *  A pointer to the second ether_addr structure containing
+ *  the ethernet address.
+ *
+ * @return
+ *  True  (1) if the given two ethernet address are the same;
+ *  False (0) otherwise.
+ */
+static inline int is_same_ether_addr(const struct ether_addr *ea1,
+                                    const struct ether_addr *ea2)
+{
+       int i;
+       for (i = 0; i < ETHER_ADDR_LEN; i++)
+               if (ea1->addr_bytes[i] != ea2->addr_bytes[i])
+                       return 0;
+       return 1;
+}
+
 /**
  * Check if an Ethernet address is filled with zeros.
  *
@@ -179,7 +205,7 @@ static inline int is_universal_ether_addr(const struct ether_addr *ea)
  */
 static inline int is_local_admin_ether_addr(const struct ether_addr *ea)
 {
-       return ((ea->addr_bytes[0] & ETHER_LOCAL_ADMIN_ADDR) == 1);
+       return ((ea->addr_bytes[0] & ETHER_LOCAL_ADMIN_ADDR) != 0);
 }
 
 /**
@@ -260,6 +286,16 @@ struct vlan_hdr {
        uint16_t eth_proto;/**< Ethernet type of encapsulated frame. */
 } __attribute__((__packed__));
 
+/**
+ * VXLAN protocol header.
+ * Contains the 8-bit flag, 24-bit VXLAN Network Identifier and
+ * Reserved fields (24 bits and 8 bits)
+ */
+struct vxlan_hdr {
+       uint32_t vx_flags; /**< flag (8) + Reserved (24). */
+       uint32_t vx_vni;   /**< VNI (24) + Reserved (8). */
+} __attribute__((__packed__));
+
 /* Ethernet frame types */
 #define ETHER_TYPE_IPv4 0x0800 /**< IPv4 Protocol. */
 #define ETHER_TYPE_IPv6 0x86DD /**< IPv6 Protocol. */
@@ -268,6 +304,9 @@ struct vlan_hdr {
 #define ETHER_TYPE_VLAN 0x8100 /**< IEEE 802.1Q VLAN tagging. */
 #define ETHER_TYPE_1588 0x88F7 /**< IEEE 802.1AS 1588 Precise Time Protocol. */
 
+#define ETHER_VXLAN_HLEN (sizeof(struct udp_hdr) + sizeof(struct vxlan_hdr))
+/**< VXLAN tunnel header length. */
+
 #ifdef __cplusplus
 }
 #endif