#include "flow.h"
#include "hash.h"
#include "list.h"
-#include "mac.h"
#include "ofp-print.h"
#include "openflow.h"
+#include "packets.h"
#include "poll-loop.h"
#include "queue.h"
#include "time.h"
flow_extract(&pkt, ntohs(opi->in_port), &flow);
/* Learn the source. */
- if (!mac_is_multicast(flow.dl_src)) {
+ if (!eth_addr_is_multicast(flow.dl_src)) {
struct mac_source *src;
struct list *bucket;
bool found;
found = false;
LIST_FOR_EACH (src, struct mac_source, hash_list, bucket) {
if (src->datapath_id == sw->datapath_id
- && mac_equals(src->mac, flow.dl_src)) {
+ && eth_addr_equals(src->mac, flow.dl_src)) {
found = true;
break;
}
if (ntohs(flow.in_port) != src->port) {
src->port = ntohs(flow.in_port);
- VLOG_DBG("learned that "MAC_FMT" is on datapath %"PRIx64" port %d",
- MAC_ARGS(src->mac), ntohll(src->datapath_id),
+ VLOG_DBG("learned that "ETH_ADDR_FMT" is on datapath %"
+ PRIx64" port %d",
+ ETH_ADDR_ARGS(src->mac), ntohll(src->datapath_id),
src->port);
}
} else {
- VLOG_DBG("multicast packet source "MAC_FMT, MAC_ARGS(flow.dl_src));
+ VLOG_DBG("multicast packet source "ETH_ADDR_FMT,
+ ETH_ADDR_ARGS(flow.dl_src));
}
/* Figure out the destination. */
out_port = OFPP_FLOOD;
- if (!mac_is_multicast(flow.dl_dst)) {
+ if (!eth_addr_is_multicast(flow.dl_dst)) {
struct mac_source *dst;
struct list *bucket;
bucket = mac_table_bucket(sw->datapath_id, flow.dl_dst);
LIST_FOR_EACH (dst, struct mac_source, hash_list, bucket) {
if (dst->datapath_id == sw->datapath_id
- && mac_equals(dst->mac, flow.dl_dst)) {
+ && eth_addr_equals(dst->mac, flow.dl_dst)) {
out_port = dst->port;
break;
}
hash.h \
ip.h \
list.h \
- mac.h \
netlink.h \
ofp-print.h \
openflow.h \
+++ /dev/null
-/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
- * Junior University
- *
- * We are making the OpenFlow specification and associated documentation
- * (Software) available for public use and benefit with the expectation
- * that others will use, modify and enhance the Software and contribute
- * those enhancements back to the community. However, since we would
- * like to make the Software available for broadest use, with as few
- * restrictions as possible permission is hereby granted, free of
- * charge, to any person obtaining a copy of this Software to deal in
- * the Software under the copyrights without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * The name and trademarks of copyright holder(s) may NOT be used in
- * advertising or publicity pertaining to the Software or any
- * derivatives without specific, written prior permission.
- */
-#ifndef MAC_H
-#define MAC_H 1
-
-#include <string.h>
-#include <inttypes.h>
-#include <stdbool.h>
-#include "packets.h"
-
-static inline bool mac_is_multicast(const uint8_t mac[ETH_ADDR_LEN])
-{
- return mac[0] & 0x80;
-}
-
-static inline bool mac_is_private(const uint8_t mac[ETH_ADDR_LEN])
-{
- return mac[0] & 0x40;
-}
-
-static inline bool mac_is_broadcast(const uint8_t mac[ETH_ADDR_LEN])
-{
- return (mac[0] & mac[1] & mac[2] & mac[3] & mac[4] & mac[5]) == 0xff;
-}
-
-static inline bool mac_is_zero(const uint8_t mac[ETH_ADDR_LEN])
-{
- return (mac[0] | mac[1] | mac[2] | mac[3] | mac[4] | mac[5]) == 0;
-}
-
-static inline bool mac_equals(const uint8_t a[ETH_ADDR_LEN],
- const uint8_t b[ETH_ADDR_LEN])
-{
- return !memcmp(a, b, ETH_ADDR_LEN);
-}
-
-#define MAC_FMT \
- "%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8
-#define MAC_ARGS(mac) \
- (mac)[0], (mac)[1], (mac)[2], (mac)[3], (mac)[4], (mac)[5]
-
-
-#endif /* mac.h */
#define PACKETS_H 1
#include <stdint.h>
+#include <string.h>
#include "util.h"
#define ETH_ADDR_LEN 6
{
return ea[0] & 2;
}
+static inline bool eth_addr_equals(const uint8_t a[ETH_ADDR_LEN],
+ const uint8_t b[ETH_ADDR_LEN])
+{
+ return !memcmp(a, b, ETH_ADDR_LEN);
+}
+#define ETH_ADDR_FMT \
+ "%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8":%02"PRIx8
+#define ETH_ADDR_ARGS(ea) \
+ (ea)[0], (ea)[1], (ea)[2], (ea)[3], (ea)[4], (ea)[5]
#define ETH_TYPE_IP 0x0800
#define ETH_TYPE_ARP 0x0806
#include <string.h>
#include "buffer.h"
-#include "mac.h"
#include "netlink.h"
#include "ofp-print.h"
#include "openflow-netlink.h"
#include "openflow.h"
+#include "packets.h"
#include "util.h"
#include "xtoxll.h"
#include "buffer.h"
#include "hash.h"
#include "ip.h"
-#include "mac.h"
#include "openflow.h"
#include "packets.h"
flow_print(FILE *stream, const struct flow *flow)
{
fprintf(stream,
- "port%04x:vlan%04x mac"MAC_FMT"->"MAC_FMT" "
+ "port%04x:vlan%04x mac"ETH_ADDR_FMT"->"ETH_ADDR_FMT" "
"proto%04x ip"IP_FMT"->"IP_FMT" port%d->%d",
ntohs(flow->in_port), ntohs(flow->dl_vlan),
- MAC_ARGS(flow->dl_src), MAC_ARGS(flow->dl_dst),
+ ETH_ADDR_ARGS(flow->dl_src), ETH_ADDR_ARGS(flow->dl_dst),
ntohs(flow->dl_type),
IP_ARGS(&flow->nw_src), IP_ARGS(&flow->nw_dst),
ntohs(flow->tp_src), ntohs(flow->tp_dst));
#include <ctype.h>
#include "ip.h"
-#include "mac.h"
#include "compiler.h"
#include "util.h"
#include "openflow.h"
+#include "packets.h"
/* Dumps the contents of the Ethernet frame in the 'len' bytes starting at
* 'data' to 'stream' using tcpdump. 'total_len' specifies the full length of
}
name[j] = '\0';
- fprintf(stream, " %2d(%s): addr:"MAC_FMT", speed:%d, flags:%#x, "
+ fprintf(stream, " %2d(%s): addr:"ETH_ADDR_FMT", speed:%d, flags:%#x, "
"feat:%#x\n", ntohs(port->port_no), name,
- MAC_ARGS(port->hw_addr), ntohl(port->speed), ntohl(port->flags),
- ntohl(port->features));
+ ETH_ADDR_ARGS(port->hw_addr), ntohl(port->speed),
+ ntohl(port->flags), ntohl(port->features));
}
/* Pretty-print the OFPT_DATA_HELLO packet of 'len' bytes at 'oh' to 'stream'
print_wild(f, "inport", w & OFPFW_IN_PORT, "%04x", ntohs(om->in_port));
print_wild(f, ":vlan", w & OFPFW_DL_VLAN, "%04x", ntohs(om->dl_vlan));
- print_wild(f, " mac[", w & OFPFW_DL_SRC, MAC_FMT, MAC_ARGS(om->dl_src));
- print_wild(f, "->", w & OFPFW_DL_DST, MAC_FMT, MAC_ARGS(om->dl_dst));
+ print_wild(f, " mac[", w & OFPFW_DL_SRC,
+ ETH_ADDR_FMT, ETH_ADDR_ARGS(om->dl_src));
+ print_wild(f, "->", w & OFPFW_DL_DST,
+ ETH_ADDR_FMT, ETH_ADDR_ARGS(om->dl_dst));
print_wild(f, "] type", w & OFPFW_DL_TYPE, "%04x", ntohs(om->dl_type));
print_wild(f, " ip[", w & OFPFW_NW_SRC, IP_FMT, IP_ARGS(&om->nw_src));
print_wild(f, "->", w & OFPFW_NW_DST, IP_FMT, IP_ARGS(&om->nw_dst));