ETH_ADDR_LEN is defined in lib/packets.h, valued 6.
Use this macro instead of magic number 6 to represent the length
of eth mac address.
Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
#include <stdbool.h>
#include <inttypes.h>
+#include "packets.h"
+
struct bfd;
struct dpif_flow_stats;
struct flow;
bool bfd_should_send_packet(const struct bfd *);
void bfd_put_packet(struct bfd *bfd, struct ofpbuf *packet,
- uint8_t eth_src[6]);
+ uint8_t eth_src[ETH_ADDR_LEN]);
bool bfd_should_process_flow(const struct bfd *, const struct flow *,
struct flow_wildcards *);
#define CFM_MAX_RMPS 256
/* Ethernet destination address of CCM packets. */
-static const uint8_t eth_addr_ccm[6] = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x30 };
-static const uint8_t eth_addr_ccm_x[6] = {
+static const uint8_t eth_addr_ccm[ETH_ADDR_LEN] = {
+ 0x01, 0x80, 0xC2, 0x00, 0x00, 0x30 };
+static const uint8_t eth_addr_ccm_x[ETH_ADDR_LEN] = {
0x01, 0x23, 0x20, 0x00, 0x00, 0x30
};
#include "hmap.h"
#include "openvswitch/types.h"
+#include "packets.h"
struct flow;
struct ofpbuf;
void cfm_unref(struct cfm *);
void cfm_run(struct cfm *);
bool cfm_should_send_ccm(struct cfm *);
-void cfm_compose_ccm(struct cfm *, struct ofpbuf *packet, uint8_t eth_src[6]);
+void cfm_compose_ccm(struct cfm *, struct ofpbuf *packet, uint8_t eth_src[ETH_ADDR_LEN]);
void cfm_wait(struct cfm *);
bool cfm_configure(struct cfm *, const struct cfm_settings *);
void cfm_set_netdev(struct cfm *, const struct netdev *);
union flow_in_port in_port; /* Input port.*/
/* L2, Order the same as in the Ethernet header! */
- uint8_t dl_dst[6]; /* Ethernet destination address. */
- uint8_t dl_src[6]; /* Ethernet source address. */
+ uint8_t dl_dst[ETH_ADDR_LEN]; /* Ethernet destination address. */
+ uint8_t dl_src[ETH_ADDR_LEN]; /* Ethernet source address. */
ovs_be16 dl_type; /* Ethernet frame type. */
ovs_be16 vlan_tci; /* If 802.1Q, TCI | VLAN_CFI; otherwise 0. */
ovs_be32 mpls_lse[FLOW_MAX_MPLS_LABELS]; /* MPLS label stack entry. */
uint8_t nw_tos; /* IP ToS (including DSCP and ECN). */
uint8_t nw_ttl; /* IP TTL/Hop Limit. */
uint8_t nw_proto; /* IP protocol or low 8 bits of ARP opcode. */
- uint8_t arp_sha[6]; /* ARP/ND source hardware address. */
- uint8_t arp_tha[6]; /* ARP/ND target hardware address. */
+ uint8_t arp_sha[ETH_ADDR_LEN]; /* ARP/ND source hardware address. */
+ uint8_t arp_tha[ETH_ADDR_LEN]; /* ARP/ND target hardware address. */
struct in6_addr nd_target; /* IPv6 neighbor discovery (ND) target. */
ovs_be16 tcp_flags; /* TCP flags. With L3 to avoid matching L4. */
ovs_be16 pad; /* Padding. */
}
static void
-format_eth_masked(struct ds *s, const char *name, const uint8_t eth[6],
- const uint8_t mask[6])
+format_eth_masked(struct ds *s, const char *name,
+ const uint8_t eth[ETH_ADDR_LEN],
+ const uint8_t mask[ETH_ADDR_LEN])
{
if (!eth_addr_is_zero(mask)) {
ds_put_format(s, "%s=", name);
#define MATCH_H 1
#include "flow.h"
+#include "packets.h"
struct ds;
void match_set_pkt_mark_masked(struct match *, uint32_t pkt_mark, uint32_t mask);
void match_set_skb_priority(struct match *, uint32_t skb_priority);
void match_set_dl_type(struct match *, ovs_be16);
-void match_set_dl_src(struct match *, const uint8_t[6]);
-void match_set_dl_src_masked(struct match *, const uint8_t dl_src[6],
- const uint8_t mask[6]);
-void match_set_dl_dst(struct match *, const uint8_t[6]);
-void match_set_dl_dst_masked(struct match *, const uint8_t dl_dst[6],
- const uint8_t mask[6]);
+void match_set_dl_src(struct match *, const uint8_t[ETH_ADDR_LEN]);
+void match_set_dl_src_masked(struct match *, const uint8_t dl_src[ETH_ADDR_LEN],
+ const uint8_t mask[ETH_ADDR_LEN]);
+void match_set_dl_dst(struct match *, const uint8_t[ETH_ADDR_LEN]);
+void match_set_dl_dst_masked(struct match *, const uint8_t dl_dst[ETH_ADDR_LEN],
+ const uint8_t mask[ETH_ADDR_LEN]);
void match_set_dl_tci(struct match *, ovs_be16 tci);
void match_set_dl_tci_masked(struct match *, ovs_be16 tci, ovs_be16 mask);
void match_set_any_vid(struct match *);
void match_set_nw_frag_masked(struct match *, uint8_t nw_frag, uint8_t mask);
void match_set_icmp_type(struct match *, uint8_t);
void match_set_icmp_code(struct match *, uint8_t);
-void match_set_arp_sha(struct match *, const uint8_t[6]);
+void match_set_arp_sha(struct match *, const uint8_t[ETH_ADDR_LEN]);
void match_set_arp_sha_masked(struct match *,
- const uint8_t arp_sha[6],
- const uint8_t mask[6]);
-void match_set_arp_tha(struct match *, const uint8_t[6]);
+ const uint8_t arp_sha[ETH_ADDR_LEN],
+ const uint8_t mask[ETH_ADDR_LEN]);
+void match_set_arp_tha(struct match *, const uint8_t[ETH_ADDR_LEN]);
void match_set_arp_tha_masked(struct match *,
- const uint8_t arp_tha[6],
- const uint8_t mask[6]);
+ const uint8_t arp_tha[ETH_ADDR_LEN],
+ const uint8_t mask[ETH_ADDR_LEN]);
void match_set_ipv6_src(struct match *, const struct in6_addr *);
void match_set_ipv6_src_masked(struct match *, const struct in6_addr *,
const struct in6_addr *);
#include "netdev.h"
#include "list.h"
#include "ovs-numa.h"
+#include "packets.h"
#include "seq.h"
#include "shash.h"
#include "smap.h"
void (*send_wait)(struct netdev *netdev, int qid);
/* Sets 'netdev''s Ethernet address to 'mac' */
- int (*set_etheraddr)(struct netdev *netdev, const uint8_t mac[6]);
+ int (*set_etheraddr)(struct netdev *netdev,
+ const uint8_t mac[ETH_ADDR_LEN]);
/* Retrieves 'netdev''s Ethernet address into 'mac'.
*
* This address will be advertised as 'netdev''s MAC address through the
* OpenFlow protocol, among other uses. */
- int (*get_etheraddr)(const struct netdev *netdev, uint8_t mac[6]);
+ int (*get_etheraddr)(const struct netdev *netdev,
+ uint8_t mac[ETH_ADDR_LEN]);
/* Retrieves 'netdev''s MTU into '*mtup'.
*
* This function may be set to null if it would always return EOPNOTSUPP
* anyhow. */
int (*arp_lookup)(const struct netdev *netdev, ovs_be32 ip,
- uint8_t mac[6]);
+ uint8_t mac[ETH_ADDR_LEN]);
/* Retrieves the current set of flags on 'netdev' into '*old_flags'. Then,
* turns off the flags that are set to 1 in 'off' and turns on the flags
#include "fatal-signal.h"
#include "netdev-provider.h"
#include "ofpbuf.h"
+#include "packets.h"
#include "poll-loop.h"
#include "shash.h"
#include "svec.h"
}
static int
-netdev_windows_get_etheraddr(const struct netdev *netdev_, uint8_t mac[6])
+netdev_windows_get_etheraddr(const struct netdev *netdev_,
+ uint8_t mac[ETH_ADDR_LEN])
{
struct netdev_windows *netdev = netdev_windows_cast(netdev_);
/* This functionality is not really required by the datapath.
* But vswitchd bringup expects this to be implemented. */
static int
-netdev_windows_set_etheraddr(const struct netdev *netdev_, uint8_t mac[6])
+netdev_windows_set_etheraddr(const struct netdev *netdev_,
+ uint8_t mac[ETH_ADDR_LEN])
{
return 0;
}
#include <stddef.h>
#include <stdint.h>
#include "openvswitch/types.h"
+#include "packets.h"
#ifdef __cplusplus
extern "C" {
void netdev_send_wait(struct netdev *, int qid);
/* Hardware address. */
-int netdev_set_etheraddr(struct netdev *, const uint8_t mac[6]);
-int netdev_get_etheraddr(const struct netdev *, uint8_t mac[6]);
+int netdev_set_etheraddr(struct netdev *, const uint8_t mac[ETH_ADDR_LEN]);
+int netdev_get_etheraddr(const struct netdev *, uint8_t mac[ETH_ADDR_LEN]);
/* PHY interface. */
bool netdev_get_carrier(const struct netdev *);
int netdev_get_next_hop(const struct netdev *, const struct in_addr *host,
struct in_addr *next_hop, char **);
int netdev_get_status(const struct netdev *, struct smap *);
-int netdev_arp_lookup(const struct netdev *, ovs_be32 ip, uint8_t mac[6]);
+int netdev_arp_lookup(const struct netdev *, ovs_be32 ip,
+ uint8_t mac[ETH_ADDR_LEN]);
struct netdev *netdev_find_dev_by_in4(const struct in_addr *);
* Returns NULL if successful, otherwise a malloc()'d string describing the
* error. The caller is responsible for freeing the returned string. */
char * WARN_UNUSED_RESULT
-str_to_mac(const char *str, uint8_t mac[6])
+str_to_mac(const char *str, uint8_t mac[ETH_ADDR_LEN])
{
if (!ovs_scan(str, ETH_ADDR_SCAN_FMT, ETH_ADDR_SCAN_ARGS(mac))) {
return xasprintf("invalid mac address %s", str);
#include <stdio.h>
#include "compiler.h"
#include "openvswitch/types.h"
+#include "packets.h"
struct flow;
struct ofpbuf;
char *str_to_u32(const char *str, uint32_t *valuep) WARN_UNUSED_RESULT;
char *str_to_u64(const char *str, uint64_t *valuep) WARN_UNUSED_RESULT;
char *str_to_be64(const char *str, ovs_be64 *valuep) WARN_UNUSED_RESULT;
-char *str_to_mac(const char *str, uint8_t mac[6]) WARN_UNUSED_RESULT;
+char *str_to_mac(const char *str, uint8_t mac[ETH_ADDR_LEN]) WARN_UNUSED_RESULT;
char *str_to_ip(const char *str, ovs_be32 *ip) WARN_UNUSED_RESULT;
#endif /* ofp-parse.h */
static const uint8_t eth_addr_bfd[ETH_ADDR_LEN] OVS_UNUSED
= { 0x00, 0x23, 0x20, 0x00, 0x00, 0x01 };
-static inline bool eth_addr_is_broadcast(const uint8_t ea[6])
+static inline bool eth_addr_is_broadcast(const uint8_t ea[ETH_ADDR_LEN])
{
return (ea[0] & ea[1] & ea[2] & ea[3] & ea[4] & ea[5]) == 0xff;
}
-static inline bool eth_addr_is_multicast(const uint8_t ea[6])
+static inline bool eth_addr_is_multicast(const uint8_t ea[ETH_ADDR_LEN])
{
return ea[0] & 1;
}
-static inline bool eth_addr_is_local(const uint8_t ea[6])
+static inline bool eth_addr_is_local(const uint8_t ea[ETH_ADDR_LEN])
{
/* Local if it is either a locally administered address or a Nicira random
* address. */
return ea[0] & 2
|| (ea[0] == 0x00 && ea[1] == 0x23 && ea[2] == 0x20 && ea[3] & 0x80);
}
-static inline bool eth_addr_is_zero(const uint8_t ea[6])
+static inline bool eth_addr_is_zero(const uint8_t ea[ETH_ADDR_LEN])
{
return !(ea[0] | ea[1] | ea[2] | ea[3] | ea[4] | ea[5]);
}
}
static struct bond_slave *
-bond_find_slave_by_mac(const struct bond *bond, const uint8_t mac[6])
+bond_find_slave_by_mac(const struct bond *bond, const uint8_t mac[ETH_ADDR_LEN])
{
struct bond_slave *slave;
/* Find the last active slave */
HMAP_FOR_EACH(slave, hmap_node, &bond->slaves) {
- uint8_t slave_mac[6];
+ uint8_t slave_mac[ETH_ADDR_LEN];
if (netdev_get_etheraddr(slave->netdev, slave_mac)) {
continue;
static void
bond_active_slave_changed(struct bond *bond)
{
- uint8_t mac[6];
+ uint8_t mac[ETH_ADDR_LEN];
netdev_get_etheraddr(bond->active_slave->netdev, mac);
memcpy(bond->active_slave_mac, mac, sizeof bond->active_slave_mac);
bool lacp_fallback_ab_cfg; /* Fallback to active-backup on LACP failure. */
- uint8_t active_slave_mac[6];/* The MAC address of the interface
+ uint8_t active_slave_mac[ETH_ADDR_LEN];
+ /* The MAC address of the interface
that was active during the last
ovs run. */
};
struct ofpbuf *bond_compose_learning_packet(struct bond *,
const uint8_t eth_src[ETH_ADDR_LEN],
uint16_t vlan, void **port_aux);
-bool bond_get_changed_active_slave(const char *name, uint8_t mac[6],
- bool force);
+bool bond_get_changed_active_slave(const char *name, uint8_t mac[ETH_ADDR_LEN],
+ bool force);
/* Packet processing. */
enum bond_verdict {
struct ipfix_data_record_flow_key_common {
ovs_be32 observation_point_id; /* OBSERVATION_POINT_ID */
uint8_t flow_direction; /* FLOW_DIRECTION */
- uint8_t source_mac_address[6]; /* SOURCE_MAC_ADDRESS */
- uint8_t destination_mac_address[6]; /* DESTINATION_MAC_ADDRESS */
+ uint8_t source_mac_address[ETH_ADDR_LEN]; /* SOURCE_MAC_ADDRESS */
+ uint8_t destination_mac_address[ETH_ADDR_LEN]; /* DESTINATION_MAC_ADDRESS */
ovs_be16 ethernet_type; /* ETHERNET_TYPE */
uint8_t ethernet_header_length; /* ETHERNET_HEADER_LENGTH */
});
static ovs_be16 tp_src_values[] = { CONSTANT_HTONS(49362),
CONSTANT_HTONS(80) };
static ovs_be16 tp_dst_values[] = { CONSTANT_HTONS(6667), CONSTANT_HTONS(22) };
-static uint8_t dl_src_values[][6] = { { 0x00, 0x02, 0xe3, 0x0f, 0x80, 0xa4 },
+static uint8_t dl_src_values[][ETH_ADDR_LEN] = {
+ { 0x00, 0x02, 0xe3, 0x0f, 0x80, 0xa4 },
{ 0x5e, 0x33, 0x7f, 0x5f, 0x1e, 0x99 } };
-static uint8_t dl_dst_values[][6] = { { 0x4a, 0x27, 0x71, 0xae, 0x64, 0xc1 },
+static uint8_t dl_dst_values[][ETH_ADDR_LEN] = {
+ { 0x4a, 0x27, 0x71, 0xae, 0x64, 0xc1 },
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } };
static uint8_t nw_proto_values[] = { IPPROTO_TCP, IPPROTO_ICMP };
static uint8_t nw_dscp_values[] = { 48, 0 };
static void
port_refresh_bond_status(struct port *port, bool force_update)
{
- uint8_t mac[6];
+ uint8_t mac[ETH_ADDR_LEN];
/* Return if port is not a bond */
if (list_is_singleton(&port->ifaces)) {