diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bfd.h | 4 | ||||
-rw-r--r-- | lib/cfm.c | 5 | ||||
-rw-r--r-- | lib/cfm.h | 3 | ||||
-rw-r--r-- | lib/flow.h | 8 | ||||
-rw-r--r-- | lib/match.c | 5 | ||||
-rw-r--r-- | lib/match.h | 25 | ||||
-rw-r--r-- | lib/netdev-provider.h | 9 | ||||
-rw-r--r-- | lib/netdev-windows.c | 7 | ||||
-rw-r--r-- | lib/netdev.h | 8 | ||||
-rw-r--r-- | lib/ofp-parse.c | 2 | ||||
-rw-r--r-- | lib/ofp-parse.h | 3 | ||||
-rw-r--r-- | lib/packets.h | 8 |
12 files changed, 51 insertions, 36 deletions
@@ -21,6 +21,8 @@ #include <stdbool.h> #include <inttypes.h> +#include "packets.h" + struct bfd; struct dpif_flow_stats; struct flow; @@ -34,7 +36,7 @@ void bfd_run(struct bfd *); 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 *); @@ -43,8 +43,9 @@ VLOG_DEFINE_THIS_MODULE(cfm); #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 }; @@ -20,6 +20,7 @@ #include "hmap.h" #include "openvswitch/types.h" +#include "packets.h" struct flow; struct ofpbuf; @@ -92,7 +93,7 @@ struct cfm *cfm_ref(const struct cfm *); 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 *); diff --git a/lib/flow.h b/lib/flow.h index 09988f6cc..14bc41435 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -104,8 +104,8 @@ struct flow { 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. */ @@ -120,8 +120,8 @@ struct flow { 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. */ diff --git a/lib/match.c b/lib/match.c index 0eb11f08a..1a28396e9 100644 --- a/lib/match.c +++ b/lib/match.c @@ -736,8 +736,9 @@ match_init_hidden_fields(struct match *m) } 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); diff --git a/lib/match.h b/lib/match.h index ce9fb28b7..af08fc0a2 100644 --- a/lib/match.h +++ b/lib/match.h @@ -18,6 +18,7 @@ #define MATCH_H 1 #include "flow.h" +#include "packets.h" struct ds; @@ -73,12 +74,12 @@ void match_set_pkt_mark(struct match *, uint32_t pkt_mark); 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 *); @@ -114,14 +115,14 @@ void match_set_nw_frag(struct match *, uint8_t nw_frag); 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 *); diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index af9ea3c23..7862c2d5d 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -23,6 +23,7 @@ #include "netdev.h" #include "list.h" #include "ovs-numa.h" +#include "packets.h" #include "seq.h" #include "shash.h" #include "smap.h" @@ -309,13 +310,15 @@ struct netdev_class { 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'. * @@ -653,7 +656,7 @@ struct netdev_class { * 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 diff --git a/lib/netdev-windows.c b/lib/netdev-windows.c index f9f96ecf1..75380e4ad 100644 --- a/lib/netdev-windows.c +++ b/lib/netdev-windows.c @@ -24,6 +24,7 @@ #include "fatal-signal.h" #include "netdev-provider.h" #include "ofpbuf.h" +#include "packets.h" #include "poll-loop.h" #include "shash.h" #include "svec.h" @@ -300,7 +301,8 @@ netdev_windows_dealloc(struct netdev *netdev_) } 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_); @@ -330,7 +332,8 @@ netdev_windows_get_mtu(const struct netdev *netdev_, int *mtup) /* 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; } diff --git a/lib/netdev.h b/lib/netdev.h index fc4180a74..79b21a0d5 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -21,6 +21,7 @@ #include <stddef.h> #include <stdint.h> #include "openvswitch/types.h" +#include "packets.h" #ifdef __cplusplus extern "C" { @@ -181,8 +182,8 @@ int netdev_send(struct netdev *, int qid, struct dpif_packet **, int cnt, 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 *); @@ -246,7 +247,8 @@ int netdev_add_router(struct netdev *, struct in_addr router); 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 *); diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c index eed5a0816..729139fcf 100644 --- a/lib/ofp-parse.c +++ b/lib/ofp-parse.c @@ -145,7 +145,7 @@ str_to_be64(const char *str, ovs_be64 *valuep) * 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); diff --git a/lib/ofp-parse.h b/lib/ofp-parse.h index 4636dffd3..789febf28 100644 --- a/lib/ofp-parse.h +++ b/lib/ofp-parse.h @@ -24,6 +24,7 @@ #include <stdio.h> #include "compiler.h" #include "openvswitch/types.h" +#include "packets.h" struct flow; struct ofpbuf; @@ -90,7 +91,7 @@ char *str_to_u16(const char *str, const char *name, uint16_t *valuep) 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 */ diff --git a/lib/packets.h b/lib/packets.h index 26c6ff1b4..fc7e60216 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -83,23 +83,23 @@ static const uint8_t eth_addr_lacp[ETH_ADDR_LEN] OVS_UNUSED 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]); } |