AM_CPPFLAGS = $(SSL_CFLAGS)
AM_CPPFLAGS += -I $(top_srcdir)/include
+AM_CPPFLAGS += -I $(top_srcdir)/lib
if HAVE_EXT
AM_CPPFLAGS += -I $(top_srcdir)/ext/include
endif
#include "fault.h"
#include "learning-switch.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "rconn.h"
#include "timeval.h"
#include <linux/rculist.h>
#include <linux/workqueue.h>
-#include "openflow-netlink.h"
+#include "openflow/openflow-netlink.h"
#include "datapath.h"
#include "nx_act_snat.h"
#include "table.h"
#include <linux/netdevice.h>
#include <linux/workqueue.h>
#include <linux/skbuff.h>
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "flow.h"
#include <net/checksum.h>
#include "forward.h"
#include "dp_act.h"
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "nx_act.h"
#include <linux/rcupdate.h>
#include <net/ip.h>
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "compat.h"
#include "snap.h"
#include <linux/skbuff.h>
#include <linux/if_ether.h>
-#include "openflow.h"
+#include "openflow/openflow.h"
struct sk_buff;
struct ofp_flow_mod;
#include <linux/types.h>
#include "forward.h"
#include "datapath.h"
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "dp_act.h"
#include "nx_msg.h"
#include "chain.h"
*/
/* Functions for Nicira-extended actions. */
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "dp_act.h"
#include "nx_act.h"
#include "nx_act_snat.h"
#include <linux/skbuff.h>
#include <linux/rcupdate.h>
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "datapath.h"
/* Cache of IP->MAC mappings on the side hidden by the SNAT */
#include "chain.h"
#include "datapath.h"
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "nx_act_snat.h"
#include "nx_msg.h"
-noinst_HEADERS += \
- include/command-line.h \
- include/compiler.h \
- include/csum.h \
- include/daemon.h \
- include/dhcp-client.h \
- include/dhcp.h \
- include/dirs.h \
- include/dynamic-string.h \
- include/dpif.h \
- include/fatal-signal.h \
- include/fault.h \
- include/flow.h \
- include/hash.h \
- include/learning-switch.h \
- include/list.h \
- include/mac-learning.h \
- include/netdev.h \
- include/netlink-protocol.h \
- include/netlink.h \
- include/nicira-ext.h \
- include/ofpbuf.h \
- include/ofp-print.h \
- include/openflow.h \
- include/openflow-netlink.h \
- include/packets.h \
- include/poll-loop.h \
- include/port-array.h \
- include/queue.h \
- include/random.h \
- include/rconn.h \
- include/sat-math.h \
- include/socket-util.h \
- include/type-props.h \
- include/timeval.h \
- include/stp.h \
- include/util.h \
- include/vconn.h \
- include/vconn-provider.h \
- include/vconn-ssl.h \
- include/vconn-stream.h \
- include/vlog-socket.h \
- include/vlog-modules.def \
- include/vlog.h \
- include/xtoxll.h
+include include/openflow/automake.mk
+++ /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 COMMAND_LINE_H
-#define COMMAND_LINE_H 1
-
-/* Utilities for command-line parsing. */
-
-struct option;
-char *long_options_to_short_options(const struct option *options);
-
-#endif /* command-line.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 COMPILER_H
-#define COMPILER_H 1
-
-#define NO_RETURN __attribute__((__noreturn__))
-#define UNUSED __attribute__((__unused__))
-#define PACKED __attribute__((__packed__))
-#define PRINTF_FORMAT(FMT, ARG1) __attribute__((__format__(printf, FMT, ARG1)))
-#define STRFTIME_FORMAT(FMT) __attribute__((__format__(__strftime__, FMT, 0)))
-#define likely(x) __builtin_expect((x),1)
-#define unlikely(x) __builtin_expect((x),0)
-
-#endif /* compiler.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 CSUM_H
-#define CSUM_H 1
-
-#include <stddef.h>
-#include <stdint.h>
-
-uint16_t csum(const void *, size_t);
-uint32_t csum_add16(uint32_t partial, uint16_t);
-uint32_t csum_add32(uint32_t partial, uint32_t);
-uint32_t csum_continue(uint32_t partial, const void *, size_t);
-uint16_t csum_finish(uint32_t partial);
-uint16_t recalc_csum16(uint16_t old_csum, uint16_t old_u16, uint16_t new_u16);
-uint16_t recalc_csum32(uint16_t old_csum, uint32_t old_u32, uint32_t new_u32);
-
-#endif /* csum.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 DAEMON_H
-#define DAEMON_H 1
-
-#include <stdbool.h>
-#include <sys/types.h>
-
-#define DAEMON_LONG_OPTIONS \
- {"detach", no_argument, 0, 'D'}, \
- {"force", no_argument, 0, 'f'}, \
- {"pidfile", optional_argument, 0, 'P'}
-
-#define DAEMON_OPTION_HANDLERS \
- case 'D': \
- set_detach(); \
- break; \
- \
- case 'P': \
- set_pidfile(optarg); \
- break; \
- \
- case 'f': \
- ignore_existing_pidfile(); \
- break;
-
-char *make_pidfile_name(const char *name);
-void set_pidfile(const char *name);
-const char *get_pidfile(void);
-void set_detach(void);
-void daemonize(void);
-void die_if_already_running(void);
-void ignore_existing_pidfile(void);
-void daemon_usage(void);
-pid_t read_pidfile(const char *name);
-
-#endif /* daemon.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 DHCP_CLIENT_H
-#define DHCP_CLIENT_H 1
-
-#include <stdbool.h>
-#include <stdint.h>
-
-struct dhclient;
-struct dhcp_msg;
-struct netdev;
-int dhclient_create(const char *netdev,
- void (*modify_request)(struct dhcp_msg *, void *aux),
- bool (*validate_offer)(const struct dhcp_msg *, void *aux),
- void *aux, struct dhclient **);
-void dhclient_set_max_timeout(struct dhclient *, unsigned int max_timeout);
-void dhclient_destroy(struct dhclient *);
-
-struct netdev *dhclient_get_netdev(struct dhclient *);
-
-void dhclient_init(struct dhclient *, uint32_t requested_ip);
-void dhclient_release(struct dhclient *);
-void dhclient_force_renew(struct dhclient *, int deadline);
-bool dhclient_is_bound(const struct dhclient *);
-bool dhclient_changed(struct dhclient *);
-
-const char *dhclient_get_state(const struct dhclient *);
-unsigned int dhclient_get_state_elapsed(const struct dhclient *);
-unsigned int dhclient_get_lease_remaining(const struct dhclient *);
-
-uint32_t dhclient_get_ip(const struct dhclient *);
-uint32_t dhclient_get_netmask(const struct dhclient *);
-uint32_t dhclient_get_router(const struct dhclient *);
-const struct dhcp_msg *dhclient_get_config(const struct dhclient *);
-
-int dhclient_configure_netdev(struct dhclient *);
-int dhclient_update_resolv_conf(struct dhclient *);
-
-void dhclient_run(struct dhclient *);
-void dhclient_wait(struct dhclient *);
-
-#endif /* dhcp-client.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 DHCP_H
-#define DHCP_H 1
-
-#include <stdint.h>
-#include "packets.h"
-#include "util.h"
-
-struct ds;
-struct ofpbuf;
-
-/* Values for 'op' field. */
-#define DHCP_BOOTREQUEST 1 /* Message sent by DHCP client. */
-#define DHCP_BOOTREPLY 2 /* Message sent by DHCP server. */
-
-/* Bits in 'flags' field. */
-#define DHCP_FLAGS_BROADCAST 0x8000 /* Server must broadcast all replies. */
-#define DHCP_FLAGS_MBZ 0x7fff /* Must be zero. */
-
-/* First four bytes of 'options' field. */
-#define DHCP_OPTS_COOKIE 0x63825363
-
-#define DHCP_HEADER_LEN 236
-struct dhcp_header {
- uint8_t op; /* DHCP_BOOTREQUEST or DHCP_BOOTREPLY. */
- uint8_t htype; /* ARP_HRD_ETHERNET (typically). */
- uint8_t hlen; /* ETH_ADDR_LEN (typically). */
- uint8_t hops; /* Hop count; set to 0 by client. */
- uint32_t xid; /* Transaction ID. */
- uint16_t secs; /* Since client started address acquisition. */
- uint16_t flags; /* DHCP_FLAGS_*. */
- uint32_t ciaddr; /* Client IP, if it has a lease for one. */
- uint32_t yiaddr; /* Client ("your") IP address. */
- uint32_t siaddr; /* Next server IP address. */
- uint32_t giaddr; /* Relay agent IP address. */
- uint8_t chaddr[16]; /* Client hardware address. */
- char sname[64]; /* Optional server host name. */
- char file[128]; /* Boot file name. */
- /* Followed by variable-length options field. */
-};
-BUILD_ASSERT_DECL(DHCP_HEADER_LEN == sizeof(struct dhcp_header));
-
-#define DHCP_ARGS \
- DHCP_ARG(FIXED, 0) /* Fixed-length option (PAD and END only). */ \
- DHCP_ARG(IP, 4) /* IP addresses. */ \
- DHCP_ARG(SECS, 4) /* 32-bit duration in seconds. */ \
- DHCP_ARG(STRING, 1) /* NVT string, optionally null-terminated. */ \
- DHCP_ARG(UINT8, 1) /* 8-bit unsigned integer. */ \
- DHCP_ARG(UINT16, 2) /* 16-bit unsigned integer. */ \
- DHCP_ARG(UINT32, 4) /* 32-bit unsigned integer. */ \
- DHCP_ARG(BOOLEAN, 1) /* Boolean octet (0 or 1). */
-
-/* DHCP option argument types. */
-enum dhcp_arg_type {
-#define DHCP_ARG(NAME, SIZE) DHCP_ARG_##NAME,
- DHCP_ARGS
-#undef DHCP_ARG
-};
-
-#define DHCP_MSGS \
- DHCP_MSG(DHCPDISCOVER, 1) /* Client->server: What IPs are available? */ \
- DHCP_MSG(DHCPOFFER, 2) /* Server->client: This IP is available. */ \
- DHCP_MSG(DHCPREQUEST, 3) /* Client->server: I want that IP. */ \
- DHCP_MSG(DHCPDECLINE, 4) /* Client->server: That IP is in use!. */ \
- DHCP_MSG(DHCPACK, 5) /* Server->client: You can have that IP. */ \
- DHCP_MSG(DHCPNAK, 6) /* Server->client: You can't have that IP. */ \
- DHCP_MSG(DHCPRELEASE, 7) /* Client->server: I'm done with this IP. */ \
- DHCP_MSG(DCHPINFORM, 8) /* Client->server: I'm using this IP. */
-
-/* DHCP message type (this is the argument for the DHCP_MSG_TYPE option). */
-enum dhcp_msg_type {
-#define DHCP_MSG(NAME, VALUE) NAME = VALUE,
- DHCP_MSGS
-#undef DHCP_MSG
-};
-const char *dhcp_type_name(enum dhcp_msg_type);
-
-/* DHCP allows for 256 standardized options and 256 vendor-specific options.
- * We put them in a single array, with the standard options at the
- * beginning. */
-#define DHCP_N_OPTIONS 512
-#define DHCP_VENDOR_OFS 256
-
-/* DHCP options. */
-#define DHCP_OPTS \
- /* arg min max */ \
- /* name code type args args */ \
- DHCP_OPT(PAD, 0, FIXED, 0, 0) \
- DHCP_OPT(END, 255, FIXED, 0, 0) \
- DHCP_OPT(SUBNET_MASK, 1, IP, 1, 1) \
- DHCP_OPT(TIME_OFFSET, 2, SECS, 1, 1) \
- DHCP_OPT(ROUTER, 3, IP, 1, SIZE_MAX) \
- /* Time Server Option is obsolete. */ \
- /* Name Server Option is obsolete. */ \
- DHCP_OPT(DNS_SERVER, 6, IP, 1, SIZE_MAX) \
- /* Log Server Option is obsolete. */ \
- /* Cookie Server Option is obsolete. */ \
- DHCP_OPT(LPR_SERVER, 9, IP, 1, SIZE_MAX) \
- /* Impress Server Option is obsolete. */ \
- /* Resource Location Server Option is obsolete. */ \
- DHCP_OPT(HOST_NAME, 12, STRING, 1, SIZE_MAX) \
- DHCP_OPT(BOOT_FILE_SIZE, 13, UINT16, 1, 1) \
- /* Merit Dump File option is obsolete. */ \
- DHCP_OPT(DOMAIN_NAME, 15, STRING, 1, SIZE_MAX) \
- /* Swap Server option is obsolete. */ \
- DHCP_OPT(ROOT_PATH, 17, STRING, 1, SIZE_MAX) \
- DHCP_OPT(EXTENSIONS_PATH, 18, STRING, 1, SIZE_MAX) \
- DHCP_OPT(IP_FORWARDING, 19, BOOLEAN, 1, 1) \
- DHCP_OPT(SOURCE_ROUTING, 20, BOOLEAN, 1, 1) \
- DHCP_OPT(POLICY_FILTER, 21, IP, 2, SIZE_MAX) \
- DHCP_OPT(MAX_DGRAM_REASSEMBLY, 22, UINT16, 1, 1) \
- DHCP_OPT(IP_TTL, 23, UINT8, 1, 1) \
- DHCP_OPT(PATH_MTU_TIMEOUT, 24, SECS, 1, 1) \
- DHCP_OPT(PATH_MTU_PLATEAU, 25, UINT16, 2, SIZE_MAX) \
- DHCP_OPT(MTU, 26, UINT16, 1, 1) \
- DHCP_OPT(ALL_SUBNETS_ARE_LOCAL, 27, BOOLEAN, 1, 1) \
- DHCP_OPT(BROADCAST_ADDRESS, 28, IP, 1, 1) \
- DHCP_OPT(PERFORM_MASK_DISCOVERY, 29, BOOLEAN, 1, 1) \
- DHCP_OPT(MASK_SUPPLIER, 30, BOOLEAN, 1, 1) \
- DHCP_OPT(PERFORM_ROUTER_DISCOVERY, 31, BOOLEAN, 1, 1) \
- DHCP_OPT(ROUTER_SOLICITATION, 32, IP, 1, 1) \
- DHCP_OPT(STATIC_ROUTE, 33, IP, 2, SIZE_MAX) \
- /* Trailer Encapsulation Option is obsolete. */ \
- DHCP_OPT(ARP_CACHE_TIMEOUT, 35, SECS, 1, 1) \
- DHCP_OPT(ETHERNET_ENCAPSULATION, 36, BOOLEAN, 1, 1) \
- DHCP_OPT(TCP_TTL, 37, UINT8, 1, 1) \
- DHCP_OPT(TCP_KEEPALIVE_INTERVAL, 38, SECS, 1, 1) \
- DHCP_OPT(TCP_KEEPALIVE_GARBAGE, 39, BOOLEAN, 1, 1) \
- DHCP_OPT(NIS_DOMAIN, 40, STRING, 1, SIZE_MAX) \
- DHCP_OPT(NIS_SERVERS, 41, IP, 1, SIZE_MAX) \
- DHCP_OPT(NTP_SERVERS, 42, IP, 1, SIZE_MAX) \
- DHCP_OPT(VENDOR_SPECIFIC, 43, UINT8, 1, SIZE_MAX) \
- DHCP_OPT(NETBIOS_NS, 44, IP, 1, SIZE_MAX) \
- DHCP_OPT(NETBIOS_DDS, 45, IP, 1, SIZE_MAX) \
- DHCP_OPT(NETBIOS_NODE_TYPE, 46, UINT8, 1, 1) \
- DHCP_OPT(NETBIOS_SCOPE, 47, STRING, 1, SIZE_MAX) \
- DHCP_OPT(X_FONT_SERVER, 48, IP, 1, SIZE_MAX) \
- DHCP_OPT(XDM, 49, IP, 1, SIZE_MAX) \
- DHCP_OPT(NISPLUS_DOMAIN, 64, STRING, 1, SIZE_MAX) \
- DHCP_OPT(NISPLUS_SERVERS, 65, IP, 1, SIZE_MAX) \
- DHCP_OPT(MOBILE_IP_HOME_AGENT, 68, IP, 0, SIZE_MAX) \
- DHCP_OPT(SMTP_SERVER, 69, IP, 1, SIZE_MAX) \
- DHCP_OPT(POP3_SERVER, 70, IP, 1, SIZE_MAX) \
- DHCP_OPT(NNTP_SERVER, 71, IP, 1, SIZE_MAX) \
- DHCP_OPT(WWW_SERVER, 72, IP, 1, SIZE_MAX) \
- DHCP_OPT(FINGER_SERVER, 73, IP, 1, SIZE_MAX) \
- DHCP_OPT(IRC_SERVER, 74, IP, 1, SIZE_MAX) \
- /* StreetTalk Server Option is obsolete. */ \
- /* StreetTalk Directory Assistance Server Option is obsolete. */ \
- DHCP_OPT(REQUESTED_IP, 50, IP, 1, 1) \
- DHCP_OPT(LEASE_TIME, 51, SECS, 1, 1) \
- DHCP_OPT(OPTION_OVERLOAD, 52, UINT8, 1, 1) \
- DHCP_OPT(TFTP_SERVER, 66, STRING, 1, SIZE_MAX) \
- DHCP_OPT(BOOTFILE_NAME, 67, STRING, 1, SIZE_MAX) \
- DHCP_OPT(DHCP_MSG_TYPE, 53, UINT8, 1, 1) \
- DHCP_OPT(SERVER_IDENTIFIER, 54, IP, 1, 1) \
- DHCP_OPT(PARAMETER_REQUEST_LIST, 55, UINT8, 1, SIZE_MAX) \
- DHCP_OPT(MESSAGE, 56, STRING, 1, SIZE_MAX) \
- DHCP_OPT(MAX_DHCP_MSG_SIZE, 57, UINT16, 1, 1) \
- DHCP_OPT(T1, 58, SECS, 1, 1) \
- DHCP_OPT(T2, 59, SECS, 1, 1) \
- DHCP_OPT(VENDOR_CLASS, 60, STRING, 1, SIZE_MAX) \
- DHCP_OPT(CLIENT_ID, 61, UINT8, 2, SIZE_MAX) \
- DHCP_VNDOPT(OFP_CONTROLLER_VCONN, 1, STRING, 1, SIZE_MAX) \
- DHCP_VNDOPT(OFP_PKI_URI, 2, STRING, 1, SIZE_MAX)
-
-/* Shorthand for defining vendor options (used above). */
-#define DHCP_VNDOPT(NAME, CODE, ARG, MIN, MAX) \
- DHCP_OPT(NAME, (CODE) + DHCP_VENDOR_OFS, ARG, MIN, MAX)
-
-/* DHCP option codes. */
-enum {
-#define DHCP_OPT(NAME, VALUE, ARGTYPE, MIN_ARGS, MAX_ARGS) \
- DHCP_CODE_##NAME = VALUE,
-DHCP_OPTS
-#undef DHCP_OPT
-};
-
-/* The contents of a DHCP option.
- *
- * DHCP options can (rarely) be present but lack content. To represent such an
- * option, 'n' is 0 and 'data' is non-null (but does not point to anything
- * useful). */
-struct dhcp_option {
- size_t n; /* Number of bytes of data. */
- void *data; /* Data. */
-};
-
-const char *dhcp_option_to_string(const struct dhcp_option *, int code,
- struct ds *);
-bool dhcp_option_equals(const struct dhcp_option *,
- const struct dhcp_option *);
-
-/* Abstracted DHCP protocol message, to make them easier to manipulate than
- * through raw protocol buffers. */
-struct dhcp_msg {
- /* For use by calling code. */
- uint8_t op; /* DHCP_BOOTREQUEST or DHCP_BOOTREPLY. */
- uint32_t xid; /* Transaction ID. */
- uint16_t secs; /* Since client started address acquisition. */
- uint16_t flags; /* DHCP_FLAGS_*. */
- uint32_t ciaddr; /* Client IP, if it has a lease for one. */
- uint32_t yiaddr; /* Client ("your") IP address. */
- uint32_t siaddr; /* Next server IP address. */
- uint32_t giaddr; /* Relay agent IP address. */
- uint8_t chaddr[ETH_ADDR_LEN]; /* Client hardware address. */
- enum dhcp_msg_type type; /* DHCP_CODE_DHCP_MSG_TYPE option argument. */
- struct dhcp_option options[DHCP_N_OPTIONS]; /* Indexed by option code. */
-
- /* For direct use only by dhcp_msg_*() functions. */
- uint8_t *data;
- size_t data_used, data_allocated;
-};
-
-void dhcp_msg_init(struct dhcp_msg *);
-void dhcp_msg_uninit(struct dhcp_msg *);
-void dhcp_msg_copy(struct dhcp_msg *, const struct dhcp_msg *);
-void dhcp_msg_put(struct dhcp_msg *, int code, const void *, size_t);
-void dhcp_msg_put_bool(struct dhcp_msg *, int code, bool);
-void dhcp_msg_put_secs(struct dhcp_msg *, int code, uint32_t);
-void dhcp_msg_put_ip(struct dhcp_msg *, int code, uint32_t);
-void dhcp_msg_put_string(struct dhcp_msg *, int code, const char *);
-void dhcp_msg_put_uint8(struct dhcp_msg *, int code, uint8_t);
-void dhcp_msg_put_uint8_array(struct dhcp_msg *, int code,
- const uint8_t[], size_t n);
-void dhcp_msg_put_uint16(struct dhcp_msg *, int code, uint16_t);
-void dhcp_msg_put_uint16_array(struct dhcp_msg *, int code,
- const uint16_t[], size_t n);
-const void *dhcp_msg_get(const struct dhcp_msg *, int code, size_t offset,
- size_t size);
-bool dhcp_msg_get_bool(const struct dhcp_msg *, int code,
- size_t offset, bool *);
-bool dhcp_msg_get_secs(const struct dhcp_msg *, int code,
- size_t offset, uint32_t *);
-bool dhcp_msg_get_ip(const struct dhcp_msg *, int code,
- size_t offset, uint32_t *);
-char *dhcp_msg_get_string(const struct dhcp_msg *, int code);
-bool dhcp_msg_get_uint8(const struct dhcp_msg *, int code,
- size_t offset, uint8_t *);
-bool dhcp_msg_get_uint16(const struct dhcp_msg *, int code,
- size_t offset, uint16_t *);
-const char *dhcp_msg_to_string(const struct dhcp_msg *, bool multiline,
- struct ds *);
-int dhcp_parse(struct dhcp_msg *, const struct ofpbuf *);
-void dhcp_assemble(const struct dhcp_msg *, struct ofpbuf *);
-
-#endif /* dhcp.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 DIRS_H
-#define DIRS_H 1
-
-extern const char ofp_pkgdatadir[]; /* /usr/local/share/openflow */
-extern const char ofp_rundir[]; /* /usr/local/var/run */
-extern const char ofp_logdir[]; /* /usr/local/var/log */
-
-#endif /* dirs.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 DPIF_H
-#define DPIF_H 1
-
-/* Operations for the datapath running in the local kernel. The interface can
- * generalize to multiple types of local datapaths, but the implementation only
- * supports the openflow kernel module via netlink. */
-
-#include <stdbool.h>
-#include <stdint.h>
-
-struct ofpbuf;
-struct ofp_match;
-
-/* A datapath interface. Opaque. */
-struct dpif
-{
- int dp_idx;
- struct nl_sock *sock;
-};
-
-int dpif_open(int dp_idx, bool subscribe, struct dpif *);
-void dpif_close(struct dpif *);
-int dpif_recv_openflow(struct dpif *, struct ofpbuf **, bool wait);
-int dpif_send_openflow(struct dpif *, struct ofpbuf *, bool wait);
-int dpif_add_dp(struct dpif *);
-int dpif_del_dp(struct dpif *);
-int dpif_add_port(struct dpif *, const char *netdev);
-int dpif_del_port(struct dpif *, const char *netdev);
-
-#endif /* dpif.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 DYNAMIC_STRING_H
-#define DYNAMIC_STRING_H 1
-
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include "compiler.h"
-
-struct tm;
-
-struct ds {
- char *string; /* Null-terminated string. */
- size_t length; /* Bytes used, not including null terminator. */
- size_t allocated; /* Bytes allocated, not including null terminator. */
-};
-
-#define DS_EMPTY_INITIALIZER { NULL, 0, 0 }
-
-void ds_init(struct ds *);
-void ds_clear(struct ds *);
-void ds_truncate(struct ds *, size_t new_length);
-void ds_reserve(struct ds *, size_t min_length);
-char *ds_put_uninit(struct ds *, size_t n);
-void ds_put_char(struct ds *, char);
-void ds_put_char_multiple(struct ds *, char, size_t n);
-void ds_put_cstr(struct ds *, const char *);
-void ds_put_format(struct ds *, const char *, ...) PRINTF_FORMAT(2, 3);
-void ds_put_format_valist(struct ds *, const char *, va_list)
- PRINTF_FORMAT(2, 0);
-void ds_put_printable(struct ds *, const char *, size_t);
-void ds_put_strftime(struct ds *, const char *, const struct tm *)
- STRFTIME_FORMAT(2);
-void ds_put_hex_dump(struct ds *ds, const void *buf_, size_t size,
- uintptr_t ofs, bool ascii);
-char *ds_cstr(struct ds *);
-void ds_destroy(struct ds *);
-
-int ds_last(const struct ds *);
-void ds_chomp(struct ds *, int c);
-
-#endif /* dynamic-string.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 FATAL_SIGNAL_H
-#define FATAL_SIGNAL_H 1
-
-#include <stdbool.h>
-
-/* Basic interface. */
-void fatal_signal_add_hook(void (*)(void *aux), void *aux, bool run_at_exit);
-void fatal_signal_block(void);
-void fatal_signal_unblock(void);
-void fatal_signal_fork(void);
-
-/* Convenience functions for unlinking files upon termination.
- *
- * These functions also unlink the files upon normal process termination via
- * exit(). */
-void fatal_signal_add_file_to_unlink(const char *);
-void fatal_signal_remove_file_to_unlink(const char *);
-
-/* Interface for other code that catches one of our signals and needs to pass
- * it through. */
-void fatal_signal_handler(int sig_nr);
-
-#endif /* fatal-signal.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 FAULT_H
-#define FAULT_H 1
-
-void register_fault_handlers(void);
-void log_backtrace(void);
-
-#endif /* fault.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 FLOW_H
-#define FLOW_H 1
-
-#include <stdbool.h>
-#include <stdint.h>
-#include "util.h"
-
-struct ofpbuf;
-
-/* Identification data for a flow.
- All fields are in network byte order.
- In decreasing order by size, so that flow structures can be hashed or
- compared bytewise. */
-struct flow {
- uint32_t nw_src; /* IP source address. */
- uint32_t nw_dst; /* IP destination address. */
- uint16_t in_port; /* Input switch port. */
- uint16_t dl_vlan; /* Input VLAN. */
- uint16_t dl_type; /* Ethernet frame type. */
- uint16_t tp_src; /* TCP/UDP source port. */
- uint16_t tp_dst; /* TCP/UDP destination port. */
- uint8_t dl_src[6]; /* Ethernet source address. */
- uint8_t dl_dst[6]; /* Ethernet destination address. */
- uint8_t nw_proto; /* IP protocol. */
- uint8_t reserved; /* Pad to 32-bit alignment. */
-};
-BUILD_ASSERT_DECL(sizeof (struct flow) == 32);
-
-int flow_extract(struct ofpbuf *, uint16_t in_port, struct flow *);
-void flow_print(FILE *, const struct flow *);
-int flow_compare(const struct flow *, const struct flow *);
-unsigned long int flow_hash(const struct flow *, uint32_t basis);
-
-#endif /* flow.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 HASH_H
-#define HASH_H 1
-
-#include <stddef.h>
-#include <stdint.h>
-
-#define HASH_FNV_BASIS UINT32_C(2166136261)
-#define HASH_FNV_PRIME UINT32_C(16777619)
-
-uint32_t hash_fnv(const void *, size_t, uint32_t basis);
-
-#endif /* hash.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 LEARNING_SWITCH_H
-#define LEARNING_SWITCH_H 1
-
-#include <stdbool.h>
-
-struct ofpbuf;
-struct rconn;
-
-struct lswitch *lswitch_create(struct rconn *, bool learn_macs, int max_idle);
-void lswitch_run(struct lswitch *, struct rconn *);
-void lswitch_wait(struct lswitch *);
-void lswitch_destroy(struct lswitch *);
-void lswitch_process_packet(struct lswitch *, struct rconn *,
- const struct ofpbuf *);
-
-
-#endif /* learning-switch.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 LIST_H
-#define LIST_H 1
-
-/* Doubly linked list. */
-
-#include <stdbool.h>
-#include <stddef.h>
-#include "util.h"
-
-/* Doubly linked list head or element. */
-struct list
- {
- struct list *prev; /* Previous list element. */
- struct list *next; /* Next list element. */
- };
-
-#define LIST_INITIALIZER(LIST) { LIST, LIST }
-
-void list_init(struct list *);
-
-/* List insertion. */
-void list_insert(struct list *, struct list *);
-void list_splice(struct list *before, struct list *first, struct list *last);
-void list_push_front(struct list *, struct list *);
-void list_push_back(struct list *, struct list *);
-void list_replace(struct list *, const struct list *);
-
-/* List removal. */
-struct list *list_remove(struct list *);
-struct list *list_pop_front(struct list *);
-struct list *list_pop_back(struct list *);
-
-/* List elements. */
-struct list *list_front(struct list *);
-struct list *list_back(struct list *);
-
-/* List properties. */
-size_t list_size(const struct list *);
-bool list_is_empty(const struct list *);
-
-#define LIST_FOR_EACH(ITER, STRUCT, MEMBER, LIST) \
- for (ITER = CONTAINER_OF((LIST)->next, STRUCT, MEMBER); \
- &(ITER)->MEMBER != (LIST); \
- ITER = CONTAINER_OF((ITER)->MEMBER.next, STRUCT, MEMBER))
-#define LIST_FOR_EACH_REVERSE(ITER, STRUCT, MEMBER, LIST) \
- for (ITER = CONTAINER_OF((LIST)->prev, STRUCT, MEMBER); \
- &(ITER)->MEMBER != (LIST); \
- ITER = CONTAINER_OF((ITER)->MEMBER.prev, STRUCT, MEMBER))
-#define LIST_FOR_EACH_SAFE(ITER, NEXT, STRUCT, MEMBER, LIST) \
- for (ITER = CONTAINER_OF((LIST)->next, STRUCT, MEMBER); \
- (NEXT = CONTAINER_OF((ITER)->MEMBER.next, STRUCT, MEMBER), \
- &(ITER)->MEMBER != (LIST)); \
- ITER = NEXT)
-
-#endif /* list.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_LEARNING_H
-#define MAC_LEARNING_H 1
-
-#include "packets.h"
-
-struct mac_learning *mac_learning_create(void);
-void mac_learning_destroy(struct mac_learning *);
-bool mac_learning_learn(struct mac_learning *,
- const uint8_t src[ETH_ADDR_LEN], uint16_t src_port);
-uint16_t mac_learning_lookup(const struct mac_learning *,
- const uint8_t dst[ETH_ADDR_LEN]);
-
-#endif /* mac-learning.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.
- */
-
-/* Generic interface to network devices.
- *
- * Currently, there is a single implementation of this interface that supports
- * Linux. The interface should be generic enough to be implementable on other
- * operating systems as well. */
-
-#ifndef NETDEV_H
-#define NETDEV_H 1
-
-#include <stdbool.h>
-#include <stdint.h>
-
-struct ofpbuf;
-struct in_addr;
-struct in6_addr;
-
-enum netdev_feature_type {
- NETDEV_FEAT_CURRENT,
- NETDEV_FEAT_ADVERTISED,
- NETDEV_FEAT_SUPPORTED,
- NETDEV_FEAT_PEER
-};
-
-enum netdev_flags {
- NETDEV_UP = 0x0001, /* Device enabled? */
- NETDEV_PROMISC = 0x0002 /* Promiscuous mode? */
-};
-
-enum netdev_pseudo_ethertype {
- NETDEV_ETH_TYPE_NONE = -128, /* Receive no frames. */
- NETDEV_ETH_TYPE_ANY, /* Receive all frames. */
- NETDEV_ETH_TYPE_802_2 /* Receive all IEEE 802.2 frames. */
-};
-
-struct netdev;
-
-int netdev_open(const char *name, int ethertype, struct netdev **);
-int netdev_open_tap(const char *name, struct netdev **);
-void netdev_close(struct netdev *);
-
-int netdev_recv(struct netdev *, struct ofpbuf *);
-void netdev_recv_wait(struct netdev *);
-int netdev_drain(struct netdev *);
-int netdev_send(struct netdev *, const struct ofpbuf *);
-int netdev_set_etheraddr(struct netdev *, const uint8_t mac[6]);
-const uint8_t *netdev_get_etheraddr(const struct netdev *);
-const char *netdev_get_name(const struct netdev *);
-int netdev_get_mtu(const struct netdev *);
-int netdev_get_link_status(const struct netdev *);
-uint32_t netdev_get_features(struct netdev *, int);
-bool netdev_get_in4(const struct netdev *, struct in_addr *);
-int netdev_set_in4(struct netdev *, struct in_addr addr, struct in_addr mask);
-int netdev_add_router(struct netdev *, struct in_addr router);
-bool netdev_get_in6(const struct netdev *, struct in6_addr *);
-int netdev_get_flags(const struct netdev *, enum netdev_flags *);
-int netdev_set_flags(struct netdev *, enum netdev_flags, bool permanent);
-int netdev_turn_flags_on(struct netdev *, enum netdev_flags, bool permanent);
-int netdev_turn_flags_off(struct netdev *, enum netdev_flags, bool permanent);
-int netdev_arp_lookup(const struct netdev *, uint32_t ip, uint8_t mac[6]);
-
-#endif /* netdev.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 NETLINK_PROTOCOL_H
-#define NETLINK_PROTOCOL_H 1
-
-/* Netlink protocol definitions.
- *
- * These definitions are equivalent to those in the Linux 2.6 kernel headers,
- * without requiring those headers to be available. */
-
-#include <stdint.h>
-#include <sys/socket.h>
-#include "util.h"
-
-#define NETLINK_GENERIC 16
-
-struct sockaddr_nl {
- sa_family_t nl_family;
- unsigned short int nl_pad;
- uint32_t nl_pid;
- uint32_t nl_groups;
-};
-BUILD_ASSERT_DECL(sizeof(struct sockaddr_nl) == 12);
-
-/* nlmsg_flags bits. */
-#define NLM_F_REQUEST 0x001
-#define NLM_F_MULTI 0x002
-#define NLM_F_ACK 0x004
-#define NLM_F_ECHO 0x008
-
-#define NLM_F_ROOT 0x100
-#define NLM_F_MATCH 0x200
-#define NLM_F_ATOMIC 0x400
-#define NLM_F_DUMP (NLM_F_ROOT | NLM_F_MATCH)
-
-/* nlmsg_type values. */
-#define NLMSG_NOOP 1
-#define NLMSG_ERROR 2
-#define NLMSG_DONE 3
-#define NLMSG_OVERRUN 4
-
-#define NLMSG_MIN_TYPE 0x10
-
-struct nlmsghdr {
- uint32_t nlmsg_len;
- uint16_t nlmsg_type;
- uint16_t nlmsg_flags;
- uint32_t nlmsg_seq;
- uint32_t nlmsg_pid;
-};
-BUILD_ASSERT_DECL(sizeof(struct nlmsghdr) == 16);
-
-#define NLMSG_ALIGNTO 4
-#define NLMSG_ALIGN(SIZE) ROUND_UP(SIZE, NLMSG_ALIGNTO)
-#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
-
-struct nlmsgerr
-{
- int error;
- struct nlmsghdr msg;
-};
-BUILD_ASSERT_DECL(sizeof(struct nlmsgerr) == 20);
-
-#define NETLINK_ADD_MEMBERSHIP 1
-#define NETLINK_DROP_MEMBERSHIP 2
-#define NETLINK_PKTINFO 3
-
-struct genlmsghdr {
- uint8_t cmd;
- uint8_t version;
- uint16_t reserved;
-};
-BUILD_ASSERT_DECL(sizeof(struct genlmsghdr) == 4);
-
-#define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr))
-
-struct nlattr {
- uint16_t nla_len;
- uint16_t nla_type;
-};
-BUILD_ASSERT_DECL(sizeof(struct nlattr) == 4);
-
-#define NLA_ALIGNTO 4
-#define NLA_ALIGN(SIZE) ROUND_UP(SIZE, NLA_ALIGNTO)
-#define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
-
-#define GENL_MIN_ID NLMSG_MIN_TYPE
-#define GENL_MAX_ID 1023
-
-#define GENL_ID_CTRL NLMSG_MIN_TYPE
-
-enum {
- CTRL_CMD_UNSPEC,
- CTRL_CMD_NEWFAMILY,
- CTRL_CMD_DELFAMILY,
- CTRL_CMD_GETFAMILY,
- CTRL_CMD_NEWOPS,
- CTRL_CMD_DELOPS,
- CTRL_CMD_GETOPS,
- __CTRL_CMD_MAX,
-};
-
-#define CTRL_CMD_MAX (__CTRL_CMD_MAX - 1)
-
-enum {
- CTRL_ATTR_UNSPEC,
- CTRL_ATTR_FAMILY_ID,
- CTRL_ATTR_FAMILY_NAME,
- CTRL_ATTR_VERSION,
- CTRL_ATTR_HDRSIZE,
- CTRL_ATTR_MAXATTR,
- CTRL_ATTR_OPS,
- __CTRL_ATTR_MAX,
-};
-
-#define CTRL_ATTR_MAX (__CTRL_ATTR_MAX - 1)
-
-enum {
- CTRL_ATTR_OP_UNSPEC,
- CTRL_ATTR_OP_ID,
- CTRL_ATTR_OP_FLAGS,
- __CTRL_ATTR_OP_MAX,
-};
-
-#define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1)
-
-#endif /* netlink-protocol.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 NETLINK_H
-#define NETLINK_H 1
-
-/* Netlink interface.
- *
- * Netlink is a datagram-based network protocol primarily for communication
- * between user processes and the kernel, and mainly on Linux. Netlink is
- * specified in RFC 3549, "Linux Netlink as an IP Services Protocol".
- *
- * Netlink is not suitable for use in physical networks of heterogeneous
- * machines because host byte order is used throughout. */
-
-#include <stdbool.h>
-#include <sys/uio.h>
-#include <stdint.h>
-
-struct ofpbuf;
-struct nl_sock;
-struct nlattr;
-
-/* Netlink sockets. */
-
-int nl_sock_create(int protocol, int multicast_group,
- size_t so_sndbuf, size_t so_rcvbuf,
- struct nl_sock **);
-void nl_sock_destroy(struct nl_sock *);
-
-int nl_sock_send(struct nl_sock *, const struct ofpbuf *, bool wait);
-int nl_sock_sendv(struct nl_sock *sock, const struct iovec iov[], size_t n_iov,
- bool wait);
-int nl_sock_recv(struct nl_sock *, struct ofpbuf **, bool wait);
-int nl_sock_transact(struct nl_sock *, const struct ofpbuf *request,
- struct ofpbuf **reply);
-
-int nl_sock_fd(const struct nl_sock *);
-\f
-/* Netlink messages. */
-
-/* Accessing headers and data. */
-struct nlmsghdr *nl_msg_nlmsghdr(const struct ofpbuf *);
-struct genlmsghdr *nl_msg_genlmsghdr(const struct ofpbuf *);
-bool nl_msg_nlmsgerr(const struct ofpbuf *, int *error);
-void nl_msg_reserve(struct ofpbuf *, size_t);
-
-/* Appending headers and raw data. */
-void nl_msg_put_nlmsghdr(struct ofpbuf *, struct nl_sock *,
- size_t expected_payload,
- uint32_t type, uint32_t flags);
-void nl_msg_put_genlmsghdr(struct ofpbuf *, struct nl_sock *,
- size_t expected_payload, int family, uint32_t flags,
- uint8_t cmd, uint8_t version);
-void nl_msg_put(struct ofpbuf *, const void *, size_t);
-void *nl_msg_put_uninit(struct ofpbuf *, size_t);
-
-/* Appending attributes. */
-void *nl_msg_put_unspec_uninit(struct ofpbuf *, uint16_t type, size_t);
-void nl_msg_put_unspec(struct ofpbuf *, uint16_t type, const void *, size_t);
-void nl_msg_put_flag(struct ofpbuf *, uint16_t type);
-void nl_msg_put_u8(struct ofpbuf *, uint16_t type, uint8_t value);
-void nl_msg_put_u16(struct ofpbuf *, uint16_t type, uint16_t value);
-void nl_msg_put_u32(struct ofpbuf *, uint16_t type, uint32_t value);
-void nl_msg_put_u64(struct ofpbuf *, uint16_t type, uint64_t value);
-void nl_msg_put_string(struct ofpbuf *, uint16_t type, const char *value);
-void nl_msg_put_nested(struct ofpbuf *, uint16_t type, struct ofpbuf *);
-\f
-/* Netlink attribute types. */
-enum nl_attr_type
-{
- NL_A_NO_ATTR = 0,
- NL_A_UNSPEC,
- NL_A_U8,
- NL_A_U16,
- NL_A_U32,
- NL_A_U64,
- NL_A_STRING,
- NL_A_FLAG,
- NL_A_NESTED,
- N_NL_ATTR_TYPES
-};
-
-/* Netlink attribute parsing. */
-const void* nl_attr_get(const struct nlattr *);
-size_t nl_attr_get_size(const struct nlattr *);
-const void* nl_attr_get_unspec(const struct nlattr *, size_t size);
-bool nl_attr_get_flag(const struct nlattr *);
-uint8_t nl_attr_get_u8(const struct nlattr *);
-uint16_t nl_attr_get_u16(const struct nlattr *);
-uint32_t nl_attr_get_u32(const struct nlattr *);
-uint64_t nl_attr_get_u64(const struct nlattr *);
-const char *nl_attr_get_string(const struct nlattr *);
-
-/* Netlink attribute policy.
- *
- * Specifies how to parse a single attribute from a Netlink message payload.
- *
- * See Nl_policy for example.
- */
-struct nl_policy
-{
- enum nl_attr_type type;
- size_t min_len, max_len;
- bool optional;
-};
-
-bool nl_policy_parse(const struct ofpbuf *, const struct nl_policy[],
- struct nlattr *[], size_t n_attrs);
-\f
-/* Miscellaneous. */
-
-int nl_lookup_genl_family(const char *name, int *number);
-
-#endif /* netlink.h */
+++ /dev/null
-/*
- * Distributed under the terms of the GNU GPL version 2.
- * Copyright (c) 2008 Nicira Networks
- */
-
-#ifndef NICIRA_EXT_H
-#define NICIRA_EXT_H 1
-
-#include "openflow.h"
-
-/* The following vendor extensions, proposed by Nicira Networks, are not yet
- * ready for standardization (and may never be), so they are not included in
- * openflow.h. */
-
-#define NX_VENDOR_ID 0x00002320
-
-enum nicira_type {
- /* Switch status request. The request body is an ASCII string that
- * specifies a prefix of the key names to include in the output; if it is
- * the null string, then all key-value pairs are included. */
- NXT_STATUS_REQUEST,
-
- /* Switch status reply. The reply body is an ASCII string of key-value
- * pairs in the form "key=value\n". */
- NXT_STATUS_REPLY,
-
- /* Configure an action. Most actions do not require configuration
- * beyond that supplied in the actual action call. */
- NXT_ACT_SET_CONFIG,
-
- /* Get configuration of action. */
- NXT_ACT_GET_CONFIG,
-
- /* Remote command execution. The request body is a sequence of strings
- * delimited by null bytes. The first string is a command name.
- * Subsequent strings are command arguments. */
- NXT_COMMAND_REQUEST,
-
- /* Remote command execution reply, sent when the command's execution
- * completes. The reply body is struct nx_command_reply. */
- NXT_COMMAND_REPLY
-};
-
-struct nicira_header {
- struct ofp_header header;
- uint32_t vendor; /* NX_VENDOR_ID. */
- uint32_t subtype; /* One of NXT_* above. */
-};
-OFP_ASSERT(sizeof(struct nicira_header) == sizeof(struct ofp_vendor_header) + 4);
-
-
-enum nx_snat_command {
- NXSC_ADD,
- NXSC_DELETE
-};
-
-/* Configuration for source-NATing */
-struct nx_snat_config {
- uint8_t command; /* One of NXSC_*. */
- uint8_t pad[3];
- uint16_t port; /* Physical switch port. */
- uint16_t mac_timeout; /* Time to cache MAC addresses of SNAT'd hosts
- in seconds. 0 uses the default value. */
-
- /* Range of IP addresses to impersonate. Set both values to the
- * same to support a single address. */
- uint32_t ip_addr_start;
- uint32_t ip_addr_end;
-
- /* Range of transport ports that should be used as new source port. A
- * value of zero, let's the switch choose.*/
- uint16_t tcp_start;
- uint16_t tcp_end;
- uint16_t udp_start;
- uint16_t udp_end;
-};
-OFP_ASSERT(sizeof(struct nx_snat_config) == 24);
-
-/* Action configuration. Not all actions require separate configuration. */
-struct nx_act_config {
- struct nicira_header header;
- uint16_t type; /* One of OFPAT_* */
- uint8_t pad[2];
- union {
- struct nx_snat_config snat[0];
- }; /* Array of action configurations. The number
- is inferred from the length field in the
- header. */
-};
-OFP_ASSERT(sizeof(struct nx_act_config) == 20);
-
-
-enum nx_action_subtype {
- NXAST_SNAT /* Source-NAT */
-};
-
-/* Action structure for NXAST_SNAT. */
-struct nx_action_snat {
- uint16_t type; /* OFPAT_VENDOR. */
- uint16_t len; /* Length is 8. */
- uint32_t vendor; /* NX_VENDOR_ID. */
- uint16_t subtype; /* NXAST_SNAT. */
- uint16_t port; /* Output port--it must be previously
- configured. */
- uint8_t pad[4];
-};
-OFP_ASSERT(sizeof(struct nx_action_snat) == 16);
-
-/* Header for Nicira-defined actions. */
-struct nx_action_header {
- uint16_t type; /* OFPAT_VENDOR. */
- uint16_t len; /* Length is 8. */
- uint32_t vendor; /* NX_VENDOR_ID. */
- uint16_t subtype; /* NXAST_*. */
- uint8_t pad[6];
-};
-OFP_ASSERT(sizeof(struct nx_action_header) == 16);
-
-/* Status bits for NXT_COMMAND_REPLY. */
-enum {
- NXT_STATUS_EXITED = 1 << 31, /* Exited normally. */
- NXT_STATUS_SIGNALED = 1 << 30, /* Exited due to signal. */
- NXT_STATUS_UNKNOWN = 1 << 29, /* Exited for unknown reason. */
- NXT_STATUS_COREDUMP = 1 << 28, /* Exited with core dump. */
- NXT_STATUS_ERROR = 1 << 27, /* Command could not be executed. */
- NXT_STATUS_STARTED = 1 << 26, /* Command was started. */
- NXT_STATUS_EXITSTATUS = 0xff, /* Exit code mask if NXT_STATUS_EXITED. */
- NXT_STATUS_TERMSIG = 0xff, /* Signal number if NXT_STATUS_SIGNALED. */
-};
-
-/* NXT_COMMAND_REPLY. */
-struct nx_command_reply {
- struct nicira_header nxh;
- uint32_t status; /* Status bits defined above. */
- /* Followed by any number of bytes of process output. */
-};
-OFP_ASSERT(sizeof(struct nx_command_reply) == 20);
-
-#endif /* nicira-ext.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.
- */
-
-/* OpenFlow protocol pretty-printer. */
-
-#ifndef __OFP_PRINT_H__
-#define __OFP_ORINT_H __1
-
-#include <stdio.h>
-
-struct ofp_flow_mod;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void ofp_print(FILE *, const void *, size_t, int verbosity);
-void ofp_print_packet(FILE *stream, const void *data, size_t len, size_t total_len);
-
-char *ofp_to_string(const void *, size_t, int verbosity);
-char *ofp_packet_to_string(const void *data, size_t len, size_t total_len);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ofppp.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 OFPBUF_H
-#define OFPBUF_H 1
-
-#include <stddef.h>
-
-/* Buffer for holding arbitrary data. An ofpbuf is automatically reallocated
- * as necessary if it grows too large for the available memory. */
-struct ofpbuf {
- void *base; /* First byte of area malloc()'d area. */
- size_t allocated; /* Number of bytes allocated. */
-
- void *data; /* First byte actually in use. */
- size_t size; /* Number of bytes in use. */
-
- void *l2; /* Link-level header. */
- void *l3; /* Network-level header. */
- void *l4; /* Transport-level header. */
- void *l7; /* Application data. */
-
- struct ofpbuf *next; /* Next in a list of ofpbufs. */
- void *private; /* Private pointer for use by owner. */
-};
-
-void ofpbuf_use(struct ofpbuf *, void *, size_t);
-
-void ofpbuf_init(struct ofpbuf *, size_t);
-void ofpbuf_uninit(struct ofpbuf *);
-void ofpbuf_reinit(struct ofpbuf *, size_t);
-
-struct ofpbuf *ofpbuf_new(size_t);
-struct ofpbuf *ofpbuf_clone(const struct ofpbuf *);
-void ofpbuf_delete(struct ofpbuf *);
-
-void *ofpbuf_at(const struct ofpbuf *, size_t offset, size_t size);
-void *ofpbuf_at_assert(const struct ofpbuf *, size_t offset, size_t size);
-void *ofpbuf_tail(const struct ofpbuf *);
-void *ofpbuf_end(const struct ofpbuf *);
-
-void *ofpbuf_put_uninit(struct ofpbuf *, size_t);
-void *ofpbuf_put_zeros(struct ofpbuf *, size_t);
-void *ofpbuf_put(struct ofpbuf *, const void *, size_t);
-void ofpbuf_reserve(struct ofpbuf *, size_t);
-void *ofpbuf_push_uninit(struct ofpbuf *b, size_t);
-void *ofpbuf_push(struct ofpbuf *b, const void *, size_t);
-
-size_t ofpbuf_headroom(struct ofpbuf *);
-size_t ofpbuf_tailroom(struct ofpbuf *);
-void ofpbuf_prealloc_headroom(struct ofpbuf *, size_t);
-void ofpbuf_prealloc_tailroom(struct ofpbuf *, size_t);
-
-void ofpbuf_clear(struct ofpbuf *);
-void *ofpbuf_pull(struct ofpbuf *, size_t);
-void *ofpbuf_try_pull(struct ofpbuf *, size_t);
-
-#endif /* ofpbuf.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 OPENFLOW_NETLINK_H
-#define OPENFLOW_NETLINK_H 1
-
-#define DP_GENL_FAMILY_NAME "OpenFlow"
-
-/* Attributes that can be attached to the datapath's netlink messages. */
-enum {
- DP_GENL_A_UNSPEC,
- DP_GENL_A_DP_IDX, /* Datapath Ethernet device name. */
- DP_GENL_A_PORTNAME, /* Device name for datapath port. */
- DP_GENL_A_MC_GROUP, /* Generic netlink multicast group. */
- DP_GENL_A_OPENFLOW, /* OpenFlow packet. */
-
- __DP_GENL_A_MAX,
- DP_GENL_A_MAX = __DP_GENL_A_MAX - 1
-};
-
-/* Commands that can be executed on the datapath's netlink interface. */
-enum dp_genl_command {
- DP_GENL_C_UNSPEC,
- DP_GENL_C_ADD_DP, /* Create datapath. */
- DP_GENL_C_DEL_DP, /* Destroy datapath. */
- DP_GENL_C_QUERY_DP, /* Get multicast group for datapath. */
- DP_GENL_C_ADD_PORT, /* Add port to datapath. */
- DP_GENL_C_DEL_PORT, /* Remove port from datapath. */
- DP_GENL_C_OPENFLOW, /* Encapsulated OpenFlow protocol. */
-
- __DP_GENL_C_MAX,
- DP_GENL_C_MAX = __DP_GENL_C_MAX - 1
-};
-
-#endif /* openflow-netlink.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.
- */
-
-/* OpenFlow: protocol between controller and datapath. */
-
-#ifndef OPENFLOW_H
-#define OPENFLOW_H 1
-
-#ifdef __KERNEL__
-#include <linux/types.h>
-#else
-#include <stdint.h>
-#endif
-
-#ifdef SWIG
-#define OFP_ASSERT(EXPR) /* SWIG can't handle OFP_ASSERT. */
-#elif !defined(__cplusplus)
-/* Build-time assertion for use in a declaration context. */
-#define OFP_ASSERT(EXPR) \
- extern int (*build_assert(void))[ sizeof(struct { \
- unsigned int build_assert_failed : (EXPR) ? 1 : -1; })]
-#else /* __cplusplus */
-#include <boost/static_assert.hpp>
-#define OFP_ASSERT BOOST_STATIC_ASSERT
-#endif /* __cplusplus */
-
-#ifndef SWIG
-#define OFP_PACKED __attribute__((packed))
-#else
-#define OFP_PACKED /* SWIG doesn't understand __attribute. */
-#endif
-
-/* The most significant bit being set in the version field indicates an
- * experimental OpenFlow version.
- */
-#define OFP_VERSION 0x96
-
-#define OFP_MAX_TABLE_NAME_LEN 32
-#define OFP_MAX_PORT_NAME_LEN 16
-
-#define OFP_TCP_PORT 6633
-#define OFP_SSL_PORT 6633
-
-#define OFP_ETH_ALEN 6 /* Bytes in an Ethernet address. */
-
-/* Port numbering. Physical ports are numbered starting from 0. */
-enum ofp_port {
- /* Maximum number of physical switch ports. */
- OFPP_MAX = 0xff00,
-
- /* Fake output "ports". */
- OFPP_IN_PORT = 0xfff8, /* Send the packet out the input port. This
- virtual port must be explicitly used
- in order to send back out of the input
- port. */
- OFPP_TABLE = 0xfff9, /* Perform actions in flow table.
- NB: This can only be the destination
- port for packet-out messages. */
- OFPP_NORMAL = 0xfffa, /* Process with normal L2/L3 switching. */
- OFPP_FLOOD = 0xfffb, /* All physical ports except input port and
- those disabled by STP. */
- OFPP_ALL = 0xfffc, /* All physical ports except input port. */
- OFPP_CONTROLLER = 0xfffd, /* Send to controller. */
- OFPP_LOCAL = 0xfffe, /* Local openflow "port". */
- OFPP_NONE = 0xffff /* Not associated with a physical port. */
-};
-
-enum ofp_type {
- /* Immutable messages. */
- OFPT_HELLO, /* Symmetric message */
- OFPT_ERROR, /* Symmetric message */
- OFPT_ECHO_REQUEST, /* Symmetric message */
- OFPT_ECHO_REPLY, /* Symmetric message */
- OFPT_VENDOR, /* Symmetric message */
-
- /* Switch configuration messages. */
- OFPT_FEATURES_REQUEST, /* Controller/switch message */
- OFPT_FEATURES_REPLY, /* Controller/switch message */
- OFPT_GET_CONFIG_REQUEST, /* Controller/switch message */
- OFPT_GET_CONFIG_REPLY, /* Controller/switch message */
- OFPT_SET_CONFIG, /* Controller/switch message */
-
- /* Asynchronous messages. */
- OFPT_PACKET_IN, /* Async message */
- OFPT_FLOW_EXPIRED, /* Async message */
- OFPT_PORT_STATUS, /* Async message */
-
- /* Controller command messages. */
- OFPT_PACKET_OUT, /* Controller/switch message */
- OFPT_FLOW_MOD, /* Controller/switch message */
- OFPT_PORT_MOD, /* Controller/switch message */
-
- /* Statistics messages. */
- OFPT_STATS_REQUEST, /* Controller/switch message */
- OFPT_STATS_REPLY /* Controller/switch message */
-};
-
-/* Header on all OpenFlow packets. */
-struct ofp_header {
- uint8_t version; /* OFP_VERSION. */
- uint8_t type; /* One of the OFPT_ constants. */
- uint16_t length; /* Length including this ofp_header. */
- uint32_t xid; /* Transactin id associated with this packet.
- Replies use the same id as was in the request
- to facilitate pairing. */
-};
-OFP_ASSERT(sizeof(struct ofp_header) == 8);
-
-/* OFPT_HELLO. This message has an empty body, but implementations must
- * ignore any data included in the body, to allow for future extensions. */
-struct ofp_hello {
- struct ofp_header header;
-};
-
-#define OFP_DEFAULT_MISS_SEND_LEN 128
-
-enum ofp_config_flags {
- /* Tells datapath to notify the controller of expired flow entries. */
- OFPC_SEND_FLOW_EXP = 1 << 0,
-
- /* Handling of IP fragments. */
- OFPC_FRAG_NORMAL = 0 << 1, /* No special handling for fragments. */
- OFPC_FRAG_DROP = 1 << 1, /* Drop fragments. */
- OFPC_FRAG_REASM = 2 << 1, /* Reassemble (only if OFPC_IP_REASM set). */
- OFPC_FRAG_MASK = 3 << 1
-};
-
-/* Switch configuration. */
-struct ofp_switch_config {
- struct ofp_header header;
- uint16_t flags; /* OFPC_* flags. */
- uint16_t miss_send_len; /* Max bytes of new flow that datapath should
- send to the controller. */
-};
-OFP_ASSERT(sizeof(struct ofp_switch_config) == 12);
-
-/* Capabilities supported by the datapath. */
-enum ofp_capabilities {
- OFPC_FLOW_STATS = 1 << 0, /* Flow statistics. */
- OFPC_TABLE_STATS = 1 << 1, /* Table statistics. */
- OFPC_PORT_STATS = 1 << 2, /* Port statistics. */
- OFPC_STP = 1 << 3, /* 802.1d spanning tree. */
- OFPC_MULTI_PHY_TX = 1 << 4, /* Supports transmitting through multiple
- physical interfaces */
- OFPC_IP_REASM = 1 << 5 /* Can reassemble IP fragments. */
-};
-
-/* Flags to indicate behavior of the physical port. These flags are
- * used in ofp_phy_port to describe the current configuration. They are
- * used in the ofp_port_mod message to configure the port's behavior.
- */
-enum ofp_port_config {
- OFPPC_PORT_DOWN = 1 << 0, /* Port is administratively down. */
-
- OFPPC_NO_STP = 1 << 1, /* Disable 802.1D spanning tree on port. */
- OFPPC_NO_RECV = 1 << 2, /* Drop most packets received on port. */
- OFPPC_NO_RECV_STP = 1 << 3, /* Drop received 802.1D STP packets. */
- OFPPC_NO_FLOOD = 1 << 4, /* Do not include this port when flooding. */
- OFPPC_NO_FWD = 1 << 5, /* Drop packets forwarded to port. */
- OFPPC_NO_PACKET_IN = 1 << 6 /* Do not send packet-in msgs for port. */
-};
-
-/* Current state of the physical port. These are not configurable from
- * the controller.
- */
-enum ofp_port_state {
- OFPPS_LINK_DOWN = 1 << 0, /* No physical link present. */
-
- /* The OFPPS_STP_* bits have no effect on switch operation. The
- * controller must adjust OFPPC_NO_RECV, OFPPC_NO_FWD, and
- * OFPPC_NO_PACKET_IN appropriately to fully implement an 802.1D spanning
- * tree. */
- OFPPS_STP_LISTEN = 0 << 8, /* Not learning or relaying frames. */
- OFPPS_STP_LEARN = 1 << 8, /* Learning but not relaying frames. */
- OFPPS_STP_FORWARD = 2 << 8, /* Learning and relaying frames. */
- OFPPS_STP_BLOCK = 3 << 8, /* Not part of spanning tree. */
- OFPPS_STP_MASK = 3 << 8 /* Bit mask for OFPPS_STP_* values. */
-};
-
-/* Features of physical ports available in a datapath. */
-enum ofp_port_features {
- OFPPF_10MB_HD = 1 << 0, /* 10 Mb half-duplex rate support. */
- OFPPF_10MB_FD = 1 << 1, /* 10 Mb full-duplex rate support. */
- OFPPF_100MB_HD = 1 << 2, /* 100 Mb half-duplex rate support. */
- OFPPF_100MB_FD = 1 << 3, /* 100 Mb full-duplex rate support. */
- OFPPF_1GB_HD = 1 << 4, /* 1 Gb half-duplex rate support. */
- OFPPF_1GB_FD = 1 << 5, /* 1 Gb full-duplex rate support. */
- OFPPF_10GB_FD = 1 << 6, /* 10 Gb full-duplex rate support. */
- OFPPF_COPPER = 1 << 7, /* Copper medium */
- OFPPF_FIBER = 1 << 8, /* Fiber medium */
- OFPPF_AUTONEG = 1 << 9, /* Auto-negotiation */
- OFPPF_PAUSE = 1 << 10, /* Pause */
- OFPPF_PAUSE_ASYM = 1 << 11 /* Asymmetric pause */
-};
-
-/* Description of a physical port */
-struct ofp_phy_port {
- uint16_t port_no;
- uint8_t hw_addr[OFP_ETH_ALEN];
- uint8_t name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
-
- uint32_t config; /* Bitmap of OFPPC_* flags. */
- uint32_t state; /* Bitmap of OFPPS_* flags. */
-
- /* Bitmaps of OFPPF_* that describe features. All bits zeroed if
- * unsupported or unavailable. */
- uint32_t curr; /* Current features. */
- uint32_t advertised; /* Features being advertised by the port. */
- uint32_t supported; /* Features supported by the port. */
- uint32_t peer; /* Features advertised by peer. */
-};
-OFP_ASSERT(sizeof(struct ofp_phy_port) == 48);
-
-/* Switch features. */
-struct ofp_switch_features {
- struct ofp_header header;
- uint64_t datapath_id; /* Datapath unique ID. Only the lower 48-bits
- are meaningful. */
-
- uint32_t n_buffers; /* Max packets buffered at once. */
-
- uint8_t n_tables; /* Number of tables supported by datapath. */
- uint8_t pad[3]; /* Align to 64-bits. */
-
- /* Features. */
- uint32_t capabilities; /* Bitmap of support "ofp_capabilities". */
- uint32_t actions; /* Bitmap of supported "ofp_action_type"s. */
-
- /* Port info.*/
- struct ofp_phy_port ports[0]; /* Port definitions. The number of ports
- is inferred from the length field in
- the header. */
-};
-OFP_ASSERT(sizeof(struct ofp_switch_features) == 32);
-
-/* What changed about the physical port */
-enum ofp_port_reason {
- OFPPR_ADD, /* The port was added */
- OFPPR_DELETE, /* The port was removed */
- OFPPR_MODIFY /* Some attribute of the port has changed */
-};
-
-/* A physical port has changed in the datapath */
-struct ofp_port_status {
- struct ofp_header header;
- uint8_t reason; /* One of OFPPR_* */
- uint8_t pad[7]; /* Align to 64-bits */
- struct ofp_phy_port desc;
-};
-OFP_ASSERT(sizeof(struct ofp_port_status) == 64);
-
-/* Modify behavior of the physical port */
-struct ofp_port_mod {
- struct ofp_header header;
- uint16_t port_no;
- uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not
- configurable. This is used to
- sanity-check the request, so it must
- be the same as returned in an
- ofp_phy_port struct. */
-
- uint32_t config; /* Bitmap of OFPPC_* flags. */
- uint32_t mask; /* Bitmap of OFPPC_* flags to be changed. */
-
- uint32_t advertise; /* Bitmap of "ofp_port_features"s. Zero all
- bits to prevent any action taking place. */
- uint8_t pad[4]; /* Pad to 64-bits. */
-};
-OFP_ASSERT(sizeof(struct ofp_port_mod) == 32);
-
-/* Why is this packet being sent to the controller? */
-enum ofp_packet_in_reason {
- OFPR_NO_MATCH, /* No matching flow. */
- OFPR_ACTION /* Action explicitly output to controller. */
-};
-
-/* Packet received on port (datapath -> controller). */
-struct ofp_packet_in {
- struct ofp_header header;
- uint32_t buffer_id; /* ID assigned by datapath. */
- uint16_t total_len; /* Full length of frame. */
- uint16_t in_port; /* Port on which frame was received. */
- uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */
- uint8_t pad;
- uint8_t data[0]; /* Ethernet frame, halfway through 32-bit word,
- so the IP header is 32-bit aligned. The
- amount of data is inferred from the length
- field in the header. Because of padding,
- offsetof(struct ofp_packet_in, data) ==
- sizeof(struct ofp_packet_in) - 2. */
-};
-OFP_ASSERT(sizeof(struct ofp_packet_in) == 20);
-
-enum ofp_action_type {
- OFPAT_OUTPUT, /* Output to switch port. */
- OFPAT_SET_VLAN_VID, /* Set the 802.1q VLAN id. */
- OFPAT_SET_VLAN_PCP, /* Set the 802.1q priority. */
- OFPAT_STRIP_VLAN, /* Strip the 802.1q header. */
- OFPAT_SET_DL_SRC, /* Ethernet source address. */
- OFPAT_SET_DL_DST, /* Ethernet destination address. */
- OFPAT_SET_NW_SRC, /* IP source address. */
- OFPAT_SET_NW_DST, /* IP destination address. */
- OFPAT_SET_TP_SRC, /* TCP/UDP source port. */
- OFPAT_SET_TP_DST, /* TCP/UDP destination port. */
- OFPAT_VENDOR = 0xffff
-};
-
-/* Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
- * When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max
- * number of bytes to send. A 'max_len' of zero means the entire packet
- * should be sent. */
-struct ofp_action_output {
- uint16_t type; /* OFPAT_OUTPUT. */
- uint16_t len; /* Length is 8. */
- uint16_t port; /* Output port. */
- uint16_t max_len; /* Max length to send to controller. */
-};
-OFP_ASSERT(sizeof(struct ofp_action_output) == 8);
-
-/* The VLAN id is 12 bits, so we can use the entire 16 bits to indicate
- * special conditions. All ones is used to match that no VLAN id was
- * set. */
-#define OFP_VLAN_NONE 0xffff
-
-/* Action structure for OFPAT_SET_VLAN_VID. */
-struct ofp_action_vlan_vid {
- uint16_t type; /* OFPAT_SET_VLAN_VID. */
- uint16_t len; /* Length is 8. */
- uint16_t vlan_vid; /* VLAN id. */
- uint8_t pad[2];
-};
-OFP_ASSERT(sizeof(struct ofp_action_vlan_vid) == 8);
-
-/* Action structure for OFPAT_SET_VLAN_PCP. */
-struct ofp_action_vlan_pcp {
- uint16_t type; /* OFPAT_SET_VLAN_PCP. */
- uint16_t len; /* Length is 8. */
- uint8_t vlan_pcp; /* VLAN priority. */
- uint8_t pad[3];
-};
-OFP_ASSERT(sizeof(struct ofp_action_vlan_vid) == 8);
-
-/* Action structure for OFPAT_SET_DL_SRC/DST. */
-struct ofp_action_dl_addr {
- uint16_t type; /* OFPAT_SET_DL_SRC/DST. */
- uint16_t len; /* Length is 16. */
- uint8_t dl_addr[OFP_ETH_ALEN]; /* Ethernet address. */
- uint8_t pad[6];
-};
-OFP_ASSERT(sizeof(struct ofp_action_dl_addr) == 16);
-
-/* Action structure for OFPAT_SET_NW_SRC/DST. */
-struct ofp_action_nw_addr {
- uint16_t type; /* OFPAT_SET_TW_SRC/DST. */
- uint16_t len; /* Length is 8. */
- uint32_t nw_addr; /* IP address. */
-};
-OFP_ASSERT(sizeof(struct ofp_action_nw_addr) == 8);
-
-/* Action structure for OFPAT_SET_TP_SRC/DST. */
-struct ofp_action_tp_port {
- uint16_t type; /* OFPAT_SET_TP_SRC/DST. */
- uint16_t len; /* Length is 8. */
- uint16_t tp_port; /* TCP/UDP port. */
- uint8_t pad[2];
-};
-OFP_ASSERT(sizeof(struct ofp_action_tp_port) == 8);
-
-/* Action header for OFPAT_VENDOR. The rest of the body is vendor-defined. */
-struct ofp_action_vendor_header {
- uint16_t type; /* OFPAT_VENDOR. */
- uint16_t len; /* Length is 8. */
- uint32_t vendor; /* Vendor ID, which takes the same form
- as in "struct ofp_vendor". */
-};
-OFP_ASSERT(sizeof(struct ofp_action_vendor_header) == 8);
-
-/* Action header that is common to all actions. The length includes the
- * header and any padding used to make the action 64-bit aligned.
- * NB: The length of an action *must* always be a multiple of eight. */
-struct ofp_action_header {
- uint16_t type; /* One of OFPAT_*. */
- uint16_t len; /* Length of action, including this
- header. This is the length of action,
- including any padding to make it
- 64-bit aligned. */
- uint8_t pad[4];
-};
-OFP_ASSERT(sizeof(struct ofp_action_header) == 8);
-
-/* Send packet (controller -> datapath). */
-struct ofp_packet_out {
- struct ofp_header header;
- uint32_t buffer_id; /* ID assigned by datapath (-1 if none). */
- uint16_t in_port; /* Packet's input port (OFPP_NONE if none). */
- uint16_t actions_len; /* Size of action array in bytes. */
- struct ofp_action_header actions[0]; /* Actions. */
- /* uint8_t data[0]; */ /* Packet data. The length is inferred
- from the length field in the header.
- (Only meaningful if buffer_id == -1.) */
-};
-OFP_ASSERT(sizeof(struct ofp_packet_out) == 16);
-
-enum ofp_flow_mod_command {
- OFPFC_ADD, /* New flow. */
- OFPFC_MODIFY, /* Modify all matching flows. */
- OFPFC_MODIFY_STRICT, /* Modify entry strictly matching wildcards */
- OFPFC_DELETE, /* Delete all matching flows. */
- OFPFC_DELETE_STRICT /* Strictly match wildcards and priority. */
-};
-
-/* Flow wildcards. */
-enum ofp_flow_wildcards {
- OFPFW_IN_PORT = 1 << 0, /* Switch input port. */
- OFPFW_DL_VLAN = 1 << 1, /* VLAN. */
- OFPFW_DL_SRC = 1 << 2, /* Ethernet source address. */
- OFPFW_DL_DST = 1 << 3, /* Ethernet destination address. */
- OFPFW_DL_TYPE = 1 << 4, /* Ethernet frame type. */
- OFPFW_NW_PROTO = 1 << 5, /* IP protocol. */
- OFPFW_TP_SRC = 1 << 6, /* TCP/UDP source port. */
- OFPFW_TP_DST = 1 << 7, /* TCP/UDP destination port. */
-
- /* IP source address wildcard bit count. 0 is exact match, 1 ignores the
- * LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard
- * the entire field. This is the *opposite* of the usual convention where
- * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded. */
- OFPFW_NW_SRC_SHIFT = 8,
- OFPFW_NW_SRC_BITS = 6,
- OFPFW_NW_SRC_MASK = ((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT,
- OFPFW_NW_SRC_ALL = 32 << OFPFW_NW_SRC_SHIFT,
-
- /* IP destination address wildcard bit count. Same format as source. */
- OFPFW_NW_DST_SHIFT = 14,
- OFPFW_NW_DST_BITS = 6,
- OFPFW_NW_DST_MASK = ((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT,
- OFPFW_NW_DST_ALL = 32 << OFPFW_NW_DST_SHIFT,
-
- /* Wildcard all fields. */
- OFPFW_ALL = ((1 << 20) - 1)
-};
-
-/* Values below this cutoff are 802.3 packets and the two bytes
- * following MAC addresses are used as a frame length. Otherwise, the
- * two bytes are used as the Ethernet type.
- */
-#define OFP_DL_TYPE_ETH2_CUTOFF 0x0600
-
-/* Value of dl_type to indicate that the frame does not include an
- * Ethernet type.
- */
-#define OFP_DL_TYPE_NOT_ETH_TYPE 0x05ff
-
-/* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
- * special conditions. All ones indicates that no VLAN id was set.
- */
-#define OFP_VLAN_NONE 0xffff
-
-/* Fields to match against flows */
-struct ofp_match {
- uint32_t wildcards; /* Wildcard fields. */
- uint16_t in_port; /* Input switch port. */
- uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */
- uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */
- uint16_t dl_vlan; /* Input VLAN. */
- uint16_t dl_type; /* Ethernet frame type. */
- uint8_t nw_proto; /* IP protocol. */
- uint8_t pad; /* Align to 32-bits. */
- uint32_t nw_src; /* IP source address. */
- uint32_t nw_dst; /* IP destination address. */
- uint16_t tp_src; /* TCP/UDP source port. */
- uint16_t tp_dst; /* TCP/UDP destination port. */
-};
-OFP_ASSERT(sizeof(struct ofp_match) == 36);
-
-/* Value used in "idle_timeout" and "hard_timeout" to indicate that the entry
- * is permanent. */
-#define OFP_FLOW_PERMANENT 0
-
-/* By default, choose a priority in the middle */
-#define OFP_DEFAULT_PRIORITY 0x8000
-
-/* Flow setup and teardown (controller -> datapath). */
-struct ofp_flow_mod {
- struct ofp_header header;
- struct ofp_match match; /* Fields to match */
-
- /* Flow actions. */
- uint16_t command; /* One of OFPFC_*. */
- uint16_t idle_timeout; /* Idle time before discarding (seconds). */
- uint16_t hard_timeout; /* Max time before discarding (seconds). */
- uint16_t priority; /* Priority level of flow entry. */
- uint32_t buffer_id; /* Buffered packet to apply to (or -1).
- Not meaningful for OFPFC_DELETE*. */
- uint32_t reserved; /* Reserved for future use. */
- struct ofp_action_header actions[0]; /* The action length is inferred
- from the length field in the
- header. */
-};
-OFP_ASSERT(sizeof(struct ofp_flow_mod) == 60);
-
-/* Why did this flow expire? */
-enum ofp_flow_expired_reason {
- OFPER_IDLE_TIMEOUT, /* Flow idle time exceeded idle_timeout. */
- OFPER_HARD_TIMEOUT /* Time exceeded hard_timeout. */
-};
-
-/* Flow expiration (datapath -> controller). */
-struct ofp_flow_expired {
- struct ofp_header header;
- struct ofp_match match; /* Description of fields */
-
- uint16_t priority; /* Priority level of flow entry. */
- uint8_t reason; /* One of OFPER_*. */
- uint8_t pad[1]; /* Align to 32-bits. */
-
- uint32_t duration; /* Time flow was alive in seconds. */
- uint8_t pad2[4]; /* Align to 64-bits. */
- uint64_t packet_count;
- uint64_t byte_count;
-};
-OFP_ASSERT(sizeof(struct ofp_flow_expired) == 72);
-
-/* Values for 'type' in ofp_error_message. These values are immutable: they
- * will not change in future versions of the protocol (although new values may
- * be added). */
-enum ofp_error_type {
- OFPET_HELLO_FAILED, /* Hello protocol failed. */
- OFPET_BAD_REQUEST, /* Request was not understood. */
- OFPET_BAD_ACTION, /* Error in action description. */
- OFPET_FLOW_MOD_FAILED /* Problem modifying flow entry. */
-};
-
-/* ofp_error_msg 'code' values for OFPET_HELLO_FAILED. 'data' contains an
- * ASCII text string that may give failure details. */
-enum ofp_hello_failed_code {
- OFPHFC_INCOMPATIBLE /* No compatible version. */
-};
-
-/* ofp_error_msg 'code' values for OFPET_BAD_REQUEST. 'data' contains at least
- * the first 64 bytes of the failed request. */
-enum ofp_bad_request_code {
- OFPBRC_BAD_VERSION, /* ofp_header.version not supported. */
- OFPBRC_BAD_TYPE, /* ofp_header.type not supported. */
- OFPBRC_BAD_STAT, /* ofp_stats_request.type not supported. */
- OFPBRC_BAD_VENDOR, /* Vendor not supported (in ofp_vendor or
- * ofp_stats_request or ofp_stats_reply). */
- OFPBRC_BAD_SUBTYPE /* Vendor subtype not supported. */
-};
-
-/* ofp_error_msg 'code' values for OFPET_BAD_ACTION. 'data' contains at least
- * the first 64 bytes of the failed request. */
-enum ofp_bad_action_code {
- OFPBAC_BAD_TYPE, /* Unknown action type. */
- OFPBAC_BAD_LEN, /* Length problem in actions. */
- OFPBAC_BAD_VENDOR, /* Unknown vendor id specified. */
- OFPBAC_BAD_VENDOR_TYPE, /* Unknown action type for vendor id. */
- OFPBAC_BAD_OUT_PORT, /* Problem validating output action. */
- OFPBAC_BAD_ARGUMENT /* Bad action argument. */
-};
-
-/* ofp_error_msg 'code' values for OFPET_FLOW_MOD_FAILED. 'data' contains
- * at least the first 64 bytes of the failed request. */
-enum ofp_flow_mod_failed_code {
- OFPFMFC_ALL_TABLES_FULL /* Flow not added because of full tables. */
-};
-
-/* OFPT_ERROR: Error message (datapath -> controller). */
-struct ofp_error_msg {
- struct ofp_header header;
-
- uint16_t type;
- uint16_t code;
- uint8_t data[0]; /* Variable-length data. Interpreted based
- on the type and code. */
-};
-OFP_ASSERT(sizeof(struct ofp_error_msg) == 12);
-
-enum ofp_stats_types {
- /* Description of this OpenFlow switch.
- * The request body is empty.
- * The reply body is struct ofp_desc_stats. */
- OFPST_DESC,
-
- /* Individual flow statistics.
- * The request body is struct ofp_flow_stats_request.
- * The reply body is an array of struct ofp_flow_stats. */
- OFPST_FLOW,
-
- /* Aggregate flow statistics.
- * The request body is struct ofp_aggregate_stats_request.
- * The reply body is struct ofp_aggregate_stats_reply. */
- OFPST_AGGREGATE,
-
- /* Flow table statistics.
- * The request body is empty.
- * The reply body is an array of struct ofp_table_stats. */
- OFPST_TABLE,
-
- /* Physical port statistics.
- * The request body is empty.
- * The reply body is an array of struct ofp_port_stats. */
- OFPST_PORT,
-
- /* Vendor extension.
- * The request and reply bodies begin with a 32-bit vendor ID, which takes
- * the same form as in "struct ofp_vendor". The request and reply bodies
- * are otherwise vendor-defined. */
- OFPST_VENDOR = 0xffff
-};
-
-struct ofp_stats_request {
- struct ofp_header header;
- uint16_t type; /* One of the OFPST_* constants. */
- uint16_t flags; /* OFPSF_REQ_* flags (none yet defined). */
- uint8_t body[0]; /* Body of the request. */
-};
-OFP_ASSERT(sizeof(struct ofp_stats_request) == 12);
-
-enum ofp_stats_reply_flags {
- OFPSF_REPLY_MORE = 1 << 0 /* More replies to follow */
-};
-
-struct ofp_stats_reply {
- struct ofp_header header;
- uint16_t type; /* One of the OFPST_* constants. */
- uint16_t flags; /* OFPSF_REPLY_* flags. */
- uint8_t body[0]; /* Body of the reply. */
-};
-OFP_ASSERT(sizeof(struct ofp_stats_reply) == 12);
-
-#define DESC_STR_LEN 256
-#define SERIAL_NUM_LEN 32
-/* Body of reply to OFPST_DESC request. Each entry is a NULL-terminated
- * ASCII string. */
-struct ofp_desc_stats {
- char mfr_desc[DESC_STR_LEN]; /* Manufacturer description. */
- char hw_desc[DESC_STR_LEN]; /* Hardware description. */
- char sw_desc[DESC_STR_LEN]; /* Software description. */
- char serial_num[SERIAL_NUM_LEN]; /* Serial number. */
-};
-OFP_ASSERT(sizeof(struct ofp_desc_stats) == 800);
-
-/* Body for ofp_stats_request of type OFPST_FLOW. */
-struct ofp_flow_stats_request {
- struct ofp_match match; /* Fields to match */
- uint8_t table_id; /* ID of table to read (from ofp_table_stats)
- or 0xff for all tables. */
- uint8_t pad[3]; /* Align to 32 bits. */
-};
-OFP_ASSERT(sizeof(struct ofp_flow_stats_request) == 40);
-
-/* Body of reply to OFPST_FLOW request. */
-struct ofp_flow_stats {
- uint16_t length; /* Length of this entry. */
- uint8_t table_id; /* ID of table flow came from. */
- uint8_t pad;
- struct ofp_match match; /* Description of fields. */
- uint32_t duration; /* Time flow has been alive in seconds. */
- uint16_t priority; /* Priority of the entry. Only meaningful
- when this is not an exact-match entry. */
- uint16_t idle_timeout; /* Number of seconds idle before expiration. */
- uint16_t hard_timeout; /* Number of seconds before expiration. */
- uint16_t pad2[3]; /* Pad to 64 bits. */
- uint64_t packet_count; /* Number of packets in flow. */
- uint64_t byte_count; /* Number of bytes in flow. */
- struct ofp_action_header actions[0]; /* Actions. */
-};
-OFP_ASSERT(sizeof(struct ofp_flow_stats) == 72);
-
-/* Body for ofp_stats_request of type OFPST_AGGREGATE. */
-struct ofp_aggregate_stats_request {
- struct ofp_match match; /* Fields to match */
- uint8_t table_id; /* ID of table to read (from ofp_table_stats)
- or 0xff for all tables. */
- uint8_t pad[3]; /* Align to 32 bits. */
-};
-OFP_ASSERT(sizeof(struct ofp_aggregate_stats_request) == 40);
-
-/* Body of reply to OFPST_AGGREGATE request. */
-struct ofp_aggregate_stats_reply {
- uint64_t packet_count; /* Number of packets in flows. */
- uint64_t byte_count; /* Number of bytes in flows. */
- uint32_t flow_count; /* Number of flows. */
- uint8_t pad[4]; /* Align to 64 bits. */
-};
-OFP_ASSERT(sizeof(struct ofp_aggregate_stats_reply) == 24);
-
-/* Body of reply to OFPST_TABLE request. */
-struct ofp_table_stats {
- uint8_t table_id; /* Identifier of table. Lower numbered tables
- are consulted first. */
- uint8_t pad[3]; /* Align to 32-bits */
- char name[OFP_MAX_TABLE_NAME_LEN];
- uint32_t wildcards; /* Bitmap of OFPFW_* wildcards that are
- supported by the table. */
- uint32_t max_entries; /* Max number of entries supported */
- uint32_t active_count; /* Number of active entries */
- uint64_t lookup_count; /* Number of packets looked up in table */
- uint64_t matched_count; /* Number of packets that hit table */
-};
-OFP_ASSERT(sizeof(struct ofp_table_stats) == 64);
-
-/* Body of reply to OFPST_PORT request. If a counter is unsupported, set
- * the field to all ones. */
-struct ofp_port_stats {
- uint16_t port_no;
- uint8_t pad[6]; /* Align to 64-bits. */
- uint64_t rx_packets; /* Number of received packets. */
- uint64_t tx_packets; /* Number of transmitted packets. */
- uint64_t rx_bytes; /* Number of received bytes. */
- uint64_t tx_bytes; /* Number of transmitted bytes. */
- uint64_t rx_dropped; /* Number of packets dropped by RX. */
- uint64_t tx_dropped; /* Number of packets dropped by TX. */
- uint64_t rx_errors; /* Number of receive errors. This is a super-set
- of receive errors and should be great than or
- equal to the sum of al rx_*_err values. */
- uint64_t tx_errors; /* Number of transmit errors. This is a super-set
- of transmit errors. */
- uint64_t rx_frame_err; /* Number of frame alignment errors. */
- uint64_t rx_over_err; /* Number of packets with RX overrun. */
- uint64_t rx_crc_err; /* Number of CRC errors. */
- uint64_t collisions; /* Number of collisions. */
-};
-OFP_ASSERT(sizeof(struct ofp_port_stats) == 104);
-
-/* Vendor extension. */
-struct ofp_vendor_header {
- struct ofp_header header; /* Type OFPT_VENDOR. */
- uint32_t vendor; /* Vendor ID:
- * - MSB 0: low-order bytes are IEEE OUI.
- * - MSB != 0: defined by OpenFlow
- * consortium. */
- /* Vendor-defined arbitrary additional data. */
-};
-OFP_ASSERT(sizeof(struct ofp_vendor_header) == 12);
-
-#endif /* openflow.h */
--- /dev/null
+noinst_HEADERS += \
+ include/openflow/nicira-ext.h \
+ include/openflow/openflow.h \
+ include/openflow/openflow-netlink.h
--- /dev/null
+/*
+ * Distributed under the terms of the GNU GPL version 2.
+ * Copyright (c) 2008 Nicira Networks
+ */
+
+#ifndef OPENFLOW_NICIRA_EXT_H
+#define OPENFLOW_NICIRA_EXT_H 1
+
+#include "openflow/openflow.h"
+
+/* The following vendor extensions, proposed by Nicira Networks, are not yet
+ * ready for standardization (and may never be), so they are not included in
+ * openflow.h. */
+
+#define NX_VENDOR_ID 0x00002320
+
+enum nicira_type {
+ /* Switch status request. The request body is an ASCII string that
+ * specifies a prefix of the key names to include in the output; if it is
+ * the null string, then all key-value pairs are included. */
+ NXT_STATUS_REQUEST,
+
+ /* Switch status reply. The reply body is an ASCII string of key-value
+ * pairs in the form "key=value\n". */
+ NXT_STATUS_REPLY,
+
+ /* Configure an action. Most actions do not require configuration
+ * beyond that supplied in the actual action call. */
+ NXT_ACT_SET_CONFIG,
+
+ /* Get configuration of action. */
+ NXT_ACT_GET_CONFIG,
+
+ /* Remote command execution. The request body is a sequence of strings
+ * delimited by null bytes. The first string is a command name.
+ * Subsequent strings are command arguments. */
+ NXT_COMMAND_REQUEST,
+
+ /* Remote command execution reply, sent when the command's execution
+ * completes. The reply body is struct nx_command_reply. */
+ NXT_COMMAND_REPLY
+};
+
+struct nicira_header {
+ struct ofp_header header;
+ uint32_t vendor; /* NX_VENDOR_ID. */
+ uint32_t subtype; /* One of NXT_* above. */
+};
+OFP_ASSERT(sizeof(struct nicira_header) == sizeof(struct ofp_vendor_header) + 4);
+
+
+enum nx_snat_command {
+ NXSC_ADD,
+ NXSC_DELETE
+};
+
+/* Configuration for source-NATing */
+struct nx_snat_config {
+ uint8_t command; /* One of NXSC_*. */
+ uint8_t pad[3];
+ uint16_t port; /* Physical switch port. */
+ uint16_t mac_timeout; /* Time to cache MAC addresses of SNAT'd hosts
+ in seconds. 0 uses the default value. */
+
+ /* Range of IP addresses to impersonate. Set both values to the
+ * same to support a single address. */
+ uint32_t ip_addr_start;
+ uint32_t ip_addr_end;
+
+ /* Range of transport ports that should be used as new source port. A
+ * value of zero, let's the switch choose.*/
+ uint16_t tcp_start;
+ uint16_t tcp_end;
+ uint16_t udp_start;
+ uint16_t udp_end;
+};
+OFP_ASSERT(sizeof(struct nx_snat_config) == 24);
+
+/* Action configuration. Not all actions require separate configuration. */
+struct nx_act_config {
+ struct nicira_header header;
+ uint16_t type; /* One of OFPAT_* */
+ uint8_t pad[2];
+ union {
+ struct nx_snat_config snat[0];
+ }; /* Array of action configurations. The number
+ is inferred from the length field in the
+ header. */
+};
+OFP_ASSERT(sizeof(struct nx_act_config) == 20);
+
+
+enum nx_action_subtype {
+ NXAST_SNAT /* Source-NAT */
+};
+
+/* Action structure for NXAST_SNAT. */
+struct nx_action_snat {
+ uint16_t type; /* OFPAT_VENDOR. */
+ uint16_t len; /* Length is 8. */
+ uint32_t vendor; /* NX_VENDOR_ID. */
+ uint16_t subtype; /* NXAST_SNAT. */
+ uint16_t port; /* Output port--it must be previously
+ configured. */
+ uint8_t pad[4];
+};
+OFP_ASSERT(sizeof(struct nx_action_snat) == 16);
+
+/* Header for Nicira-defined actions. */
+struct nx_action_header {
+ uint16_t type; /* OFPAT_VENDOR. */
+ uint16_t len; /* Length is 8. */
+ uint32_t vendor; /* NX_VENDOR_ID. */
+ uint16_t subtype; /* NXAST_*. */
+ uint8_t pad[6];
+};
+OFP_ASSERT(sizeof(struct nx_action_header) == 16);
+
+/* Status bits for NXT_COMMAND_REPLY. */
+enum {
+ NXT_STATUS_EXITED = 1 << 31, /* Exited normally. */
+ NXT_STATUS_SIGNALED = 1 << 30, /* Exited due to signal. */
+ NXT_STATUS_UNKNOWN = 1 << 29, /* Exited for unknown reason. */
+ NXT_STATUS_COREDUMP = 1 << 28, /* Exited with core dump. */
+ NXT_STATUS_ERROR = 1 << 27, /* Command could not be executed. */
+ NXT_STATUS_STARTED = 1 << 26, /* Command was started. */
+ NXT_STATUS_EXITSTATUS = 0xff, /* Exit code mask if NXT_STATUS_EXITED. */
+ NXT_STATUS_TERMSIG = 0xff, /* Signal number if NXT_STATUS_SIGNALED. */
+};
+
+/* NXT_COMMAND_REPLY. */
+struct nx_command_reply {
+ struct nicira_header nxh;
+ uint32_t status; /* Status bits defined above. */
+ /* Followed by any number of bytes of process output. */
+};
+OFP_ASSERT(sizeof(struct nx_command_reply) == 20);
+
+#endif /* openflow/nicira-ext.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 OPENFLOW_OPENFLOW_NETLINK_H
+#define OPENFLOW_OPENFLOW_NETLINK_H 1
+
+#define DP_GENL_FAMILY_NAME "OpenFlow"
+
+/* Attributes that can be attached to the datapath's netlink messages. */
+enum {
+ DP_GENL_A_UNSPEC,
+ DP_GENL_A_DP_IDX, /* Datapath Ethernet device name. */
+ DP_GENL_A_PORTNAME, /* Device name for datapath port. */
+ DP_GENL_A_MC_GROUP, /* Generic netlink multicast group. */
+ DP_GENL_A_OPENFLOW, /* OpenFlow packet. */
+
+ __DP_GENL_A_MAX,
+ DP_GENL_A_MAX = __DP_GENL_A_MAX - 1
+};
+
+/* Commands that can be executed on the datapath's netlink interface. */
+enum dp_genl_command {
+ DP_GENL_C_UNSPEC,
+ DP_GENL_C_ADD_DP, /* Create datapath. */
+ DP_GENL_C_DEL_DP, /* Destroy datapath. */
+ DP_GENL_C_QUERY_DP, /* Get multicast group for datapath. */
+ DP_GENL_C_ADD_PORT, /* Add port to datapath. */
+ DP_GENL_C_DEL_PORT, /* Remove port from datapath. */
+ DP_GENL_C_OPENFLOW, /* Encapsulated OpenFlow protocol. */
+
+ __DP_GENL_C_MAX,
+ DP_GENL_C_MAX = __DP_GENL_C_MAX - 1
+};
+
+#endif /* openflow/openflow-netlink.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.
+ */
+
+/* OpenFlow: protocol between controller and datapath. */
+
+#ifndef OPENFLOW_OPENFLOW_H
+#define OPENFLOW_OPENFLOW_H 1
+
+#ifdef __KERNEL__
+#include <linux/types.h>
+#else
+#include <stdint.h>
+#endif
+
+#ifdef SWIG
+#define OFP_ASSERT(EXPR) /* SWIG can't handle OFP_ASSERT. */
+#elif !defined(__cplusplus)
+/* Build-time assertion for use in a declaration context. */
+#define OFP_ASSERT(EXPR) \
+ extern int (*build_assert(void))[ sizeof(struct { \
+ unsigned int build_assert_failed : (EXPR) ? 1 : -1; })]
+#else /* __cplusplus */
+#include <boost/static_assert.hpp>
+#define OFP_ASSERT BOOST_STATIC_ASSERT
+#endif /* __cplusplus */
+
+#ifndef SWIG
+#define OFP_PACKED __attribute__((packed))
+#else
+#define OFP_PACKED /* SWIG doesn't understand __attribute. */
+#endif
+
+/* The most significant bit being set in the version field indicates an
+ * experimental OpenFlow version.
+ */
+#define OFP_VERSION 0x96
+
+#define OFP_MAX_TABLE_NAME_LEN 32
+#define OFP_MAX_PORT_NAME_LEN 16
+
+#define OFP_TCP_PORT 6633
+#define OFP_SSL_PORT 6633
+
+#define OFP_ETH_ALEN 6 /* Bytes in an Ethernet address. */
+
+/* Port numbering. Physical ports are numbered starting from 0. */
+enum ofp_port {
+ /* Maximum number of physical switch ports. */
+ OFPP_MAX = 0xff00,
+
+ /* Fake output "ports". */
+ OFPP_IN_PORT = 0xfff8, /* Send the packet out the input port. This
+ virtual port must be explicitly used
+ in order to send back out of the input
+ port. */
+ OFPP_TABLE = 0xfff9, /* Perform actions in flow table.
+ NB: This can only be the destination
+ port for packet-out messages. */
+ OFPP_NORMAL = 0xfffa, /* Process with normal L2/L3 switching. */
+ OFPP_FLOOD = 0xfffb, /* All physical ports except input port and
+ those disabled by STP. */
+ OFPP_ALL = 0xfffc, /* All physical ports except input port. */
+ OFPP_CONTROLLER = 0xfffd, /* Send to controller. */
+ OFPP_LOCAL = 0xfffe, /* Local openflow "port". */
+ OFPP_NONE = 0xffff /* Not associated with a physical port. */
+};
+
+enum ofp_type {
+ /* Immutable messages. */
+ OFPT_HELLO, /* Symmetric message */
+ OFPT_ERROR, /* Symmetric message */
+ OFPT_ECHO_REQUEST, /* Symmetric message */
+ OFPT_ECHO_REPLY, /* Symmetric message */
+ OFPT_VENDOR, /* Symmetric message */
+
+ /* Switch configuration messages. */
+ OFPT_FEATURES_REQUEST, /* Controller/switch message */
+ OFPT_FEATURES_REPLY, /* Controller/switch message */
+ OFPT_GET_CONFIG_REQUEST, /* Controller/switch message */
+ OFPT_GET_CONFIG_REPLY, /* Controller/switch message */
+ OFPT_SET_CONFIG, /* Controller/switch message */
+
+ /* Asynchronous messages. */
+ OFPT_PACKET_IN, /* Async message */
+ OFPT_FLOW_EXPIRED, /* Async message */
+ OFPT_PORT_STATUS, /* Async message */
+
+ /* Controller command messages. */
+ OFPT_PACKET_OUT, /* Controller/switch message */
+ OFPT_FLOW_MOD, /* Controller/switch message */
+ OFPT_PORT_MOD, /* Controller/switch message */
+
+ /* Statistics messages. */
+ OFPT_STATS_REQUEST, /* Controller/switch message */
+ OFPT_STATS_REPLY /* Controller/switch message */
+};
+
+/* Header on all OpenFlow packets. */
+struct ofp_header {
+ uint8_t version; /* OFP_VERSION. */
+ uint8_t type; /* One of the OFPT_ constants. */
+ uint16_t length; /* Length including this ofp_header. */
+ uint32_t xid; /* Transactin id associated with this packet.
+ Replies use the same id as was in the request
+ to facilitate pairing. */
+};
+OFP_ASSERT(sizeof(struct ofp_header) == 8);
+
+/* OFPT_HELLO. This message has an empty body, but implementations must
+ * ignore any data included in the body, to allow for future extensions. */
+struct ofp_hello {
+ struct ofp_header header;
+};
+
+#define OFP_DEFAULT_MISS_SEND_LEN 128
+
+enum ofp_config_flags {
+ /* Tells datapath to notify the controller of expired flow entries. */
+ OFPC_SEND_FLOW_EXP = 1 << 0,
+
+ /* Handling of IP fragments. */
+ OFPC_FRAG_NORMAL = 0 << 1, /* No special handling for fragments. */
+ OFPC_FRAG_DROP = 1 << 1, /* Drop fragments. */
+ OFPC_FRAG_REASM = 2 << 1, /* Reassemble (only if OFPC_IP_REASM set). */
+ OFPC_FRAG_MASK = 3 << 1
+};
+
+/* Switch configuration. */
+struct ofp_switch_config {
+ struct ofp_header header;
+ uint16_t flags; /* OFPC_* flags. */
+ uint16_t miss_send_len; /* Max bytes of new flow that datapath should
+ send to the controller. */
+};
+OFP_ASSERT(sizeof(struct ofp_switch_config) == 12);
+
+/* Capabilities supported by the datapath. */
+enum ofp_capabilities {
+ OFPC_FLOW_STATS = 1 << 0, /* Flow statistics. */
+ OFPC_TABLE_STATS = 1 << 1, /* Table statistics. */
+ OFPC_PORT_STATS = 1 << 2, /* Port statistics. */
+ OFPC_STP = 1 << 3, /* 802.1d spanning tree. */
+ OFPC_MULTI_PHY_TX = 1 << 4, /* Supports transmitting through multiple
+ physical interfaces */
+ OFPC_IP_REASM = 1 << 5 /* Can reassemble IP fragments. */
+};
+
+/* Flags to indicate behavior of the physical port. These flags are
+ * used in ofp_phy_port to describe the current configuration. They are
+ * used in the ofp_port_mod message to configure the port's behavior.
+ */
+enum ofp_port_config {
+ OFPPC_PORT_DOWN = 1 << 0, /* Port is administratively down. */
+
+ OFPPC_NO_STP = 1 << 1, /* Disable 802.1D spanning tree on port. */
+ OFPPC_NO_RECV = 1 << 2, /* Drop most packets received on port. */
+ OFPPC_NO_RECV_STP = 1 << 3, /* Drop received 802.1D STP packets. */
+ OFPPC_NO_FLOOD = 1 << 4, /* Do not include this port when flooding. */
+ OFPPC_NO_FWD = 1 << 5, /* Drop packets forwarded to port. */
+ OFPPC_NO_PACKET_IN = 1 << 6 /* Do not send packet-in msgs for port. */
+};
+
+/* Current state of the physical port. These are not configurable from
+ * the controller.
+ */
+enum ofp_port_state {
+ OFPPS_LINK_DOWN = 1 << 0, /* No physical link present. */
+
+ /* The OFPPS_STP_* bits have no effect on switch operation. The
+ * controller must adjust OFPPC_NO_RECV, OFPPC_NO_FWD, and
+ * OFPPC_NO_PACKET_IN appropriately to fully implement an 802.1D spanning
+ * tree. */
+ OFPPS_STP_LISTEN = 0 << 8, /* Not learning or relaying frames. */
+ OFPPS_STP_LEARN = 1 << 8, /* Learning but not relaying frames. */
+ OFPPS_STP_FORWARD = 2 << 8, /* Learning and relaying frames. */
+ OFPPS_STP_BLOCK = 3 << 8, /* Not part of spanning tree. */
+ OFPPS_STP_MASK = 3 << 8 /* Bit mask for OFPPS_STP_* values. */
+};
+
+/* Features of physical ports available in a datapath. */
+enum ofp_port_features {
+ OFPPF_10MB_HD = 1 << 0, /* 10 Mb half-duplex rate support. */
+ OFPPF_10MB_FD = 1 << 1, /* 10 Mb full-duplex rate support. */
+ OFPPF_100MB_HD = 1 << 2, /* 100 Mb half-duplex rate support. */
+ OFPPF_100MB_FD = 1 << 3, /* 100 Mb full-duplex rate support. */
+ OFPPF_1GB_HD = 1 << 4, /* 1 Gb half-duplex rate support. */
+ OFPPF_1GB_FD = 1 << 5, /* 1 Gb full-duplex rate support. */
+ OFPPF_10GB_FD = 1 << 6, /* 10 Gb full-duplex rate support. */
+ OFPPF_COPPER = 1 << 7, /* Copper medium */
+ OFPPF_FIBER = 1 << 8, /* Fiber medium */
+ OFPPF_AUTONEG = 1 << 9, /* Auto-negotiation */
+ OFPPF_PAUSE = 1 << 10, /* Pause */
+ OFPPF_PAUSE_ASYM = 1 << 11 /* Asymmetric pause */
+};
+
+/* Description of a physical port */
+struct ofp_phy_port {
+ uint16_t port_no;
+ uint8_t hw_addr[OFP_ETH_ALEN];
+ uint8_t name[OFP_MAX_PORT_NAME_LEN]; /* Null-terminated */
+
+ uint32_t config; /* Bitmap of OFPPC_* flags. */
+ uint32_t state; /* Bitmap of OFPPS_* flags. */
+
+ /* Bitmaps of OFPPF_* that describe features. All bits zeroed if
+ * unsupported or unavailable. */
+ uint32_t curr; /* Current features. */
+ uint32_t advertised; /* Features being advertised by the port. */
+ uint32_t supported; /* Features supported by the port. */
+ uint32_t peer; /* Features advertised by peer. */
+};
+OFP_ASSERT(sizeof(struct ofp_phy_port) == 48);
+
+/* Switch features. */
+struct ofp_switch_features {
+ struct ofp_header header;
+ uint64_t datapath_id; /* Datapath unique ID. Only the lower 48-bits
+ are meaningful. */
+
+ uint32_t n_buffers; /* Max packets buffered at once. */
+
+ uint8_t n_tables; /* Number of tables supported by datapath. */
+ uint8_t pad[3]; /* Align to 64-bits. */
+
+ /* Features. */
+ uint32_t capabilities; /* Bitmap of support "ofp_capabilities". */
+ uint32_t actions; /* Bitmap of supported "ofp_action_type"s. */
+
+ /* Port info.*/
+ struct ofp_phy_port ports[0]; /* Port definitions. The number of ports
+ is inferred from the length field in
+ the header. */
+};
+OFP_ASSERT(sizeof(struct ofp_switch_features) == 32);
+
+/* What changed about the physical port */
+enum ofp_port_reason {
+ OFPPR_ADD, /* The port was added */
+ OFPPR_DELETE, /* The port was removed */
+ OFPPR_MODIFY /* Some attribute of the port has changed */
+};
+
+/* A physical port has changed in the datapath */
+struct ofp_port_status {
+ struct ofp_header header;
+ uint8_t reason; /* One of OFPPR_* */
+ uint8_t pad[7]; /* Align to 64-bits */
+ struct ofp_phy_port desc;
+};
+OFP_ASSERT(sizeof(struct ofp_port_status) == 64);
+
+/* Modify behavior of the physical port */
+struct ofp_port_mod {
+ struct ofp_header header;
+ uint16_t port_no;
+ uint8_t hw_addr[OFP_ETH_ALEN]; /* The hardware address is not
+ configurable. This is used to
+ sanity-check the request, so it must
+ be the same as returned in an
+ ofp_phy_port struct. */
+
+ uint32_t config; /* Bitmap of OFPPC_* flags. */
+ uint32_t mask; /* Bitmap of OFPPC_* flags to be changed. */
+
+ uint32_t advertise; /* Bitmap of "ofp_port_features"s. Zero all
+ bits to prevent any action taking place. */
+ uint8_t pad[4]; /* Pad to 64-bits. */
+};
+OFP_ASSERT(sizeof(struct ofp_port_mod) == 32);
+
+/* Why is this packet being sent to the controller? */
+enum ofp_packet_in_reason {
+ OFPR_NO_MATCH, /* No matching flow. */
+ OFPR_ACTION /* Action explicitly output to controller. */
+};
+
+/* Packet received on port (datapath -> controller). */
+struct ofp_packet_in {
+ struct ofp_header header;
+ uint32_t buffer_id; /* ID assigned by datapath. */
+ uint16_t total_len; /* Full length of frame. */
+ uint16_t in_port; /* Port on which frame was received. */
+ uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */
+ uint8_t pad;
+ uint8_t data[0]; /* Ethernet frame, halfway through 32-bit word,
+ so the IP header is 32-bit aligned. The
+ amount of data is inferred from the length
+ field in the header. Because of padding,
+ offsetof(struct ofp_packet_in, data) ==
+ sizeof(struct ofp_packet_in) - 2. */
+};
+OFP_ASSERT(sizeof(struct ofp_packet_in) == 20);
+
+enum ofp_action_type {
+ OFPAT_OUTPUT, /* Output to switch port. */
+ OFPAT_SET_VLAN_VID, /* Set the 802.1q VLAN id. */
+ OFPAT_SET_VLAN_PCP, /* Set the 802.1q priority. */
+ OFPAT_STRIP_VLAN, /* Strip the 802.1q header. */
+ OFPAT_SET_DL_SRC, /* Ethernet source address. */
+ OFPAT_SET_DL_DST, /* Ethernet destination address. */
+ OFPAT_SET_NW_SRC, /* IP source address. */
+ OFPAT_SET_NW_DST, /* IP destination address. */
+ OFPAT_SET_TP_SRC, /* TCP/UDP source port. */
+ OFPAT_SET_TP_DST, /* TCP/UDP destination port. */
+ OFPAT_VENDOR = 0xffff
+};
+
+/* Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
+ * When the 'port' is the OFPP_CONTROLLER, 'max_len' indicates the max
+ * number of bytes to send. A 'max_len' of zero means the entire packet
+ * should be sent. */
+struct ofp_action_output {
+ uint16_t type; /* OFPAT_OUTPUT. */
+ uint16_t len; /* Length is 8. */
+ uint16_t port; /* Output port. */
+ uint16_t max_len; /* Max length to send to controller. */
+};
+OFP_ASSERT(sizeof(struct ofp_action_output) == 8);
+
+/* The VLAN id is 12 bits, so we can use the entire 16 bits to indicate
+ * special conditions. All ones is used to match that no VLAN id was
+ * set. */
+#define OFP_VLAN_NONE 0xffff
+
+/* Action structure for OFPAT_SET_VLAN_VID. */
+struct ofp_action_vlan_vid {
+ uint16_t type; /* OFPAT_SET_VLAN_VID. */
+ uint16_t len; /* Length is 8. */
+ uint16_t vlan_vid; /* VLAN id. */
+ uint8_t pad[2];
+};
+OFP_ASSERT(sizeof(struct ofp_action_vlan_vid) == 8);
+
+/* Action structure for OFPAT_SET_VLAN_PCP. */
+struct ofp_action_vlan_pcp {
+ uint16_t type; /* OFPAT_SET_VLAN_PCP. */
+ uint16_t len; /* Length is 8. */
+ uint8_t vlan_pcp; /* VLAN priority. */
+ uint8_t pad[3];
+};
+OFP_ASSERT(sizeof(struct ofp_action_vlan_vid) == 8);
+
+/* Action structure for OFPAT_SET_DL_SRC/DST. */
+struct ofp_action_dl_addr {
+ uint16_t type; /* OFPAT_SET_DL_SRC/DST. */
+ uint16_t len; /* Length is 16. */
+ uint8_t dl_addr[OFP_ETH_ALEN]; /* Ethernet address. */
+ uint8_t pad[6];
+};
+OFP_ASSERT(sizeof(struct ofp_action_dl_addr) == 16);
+
+/* Action structure for OFPAT_SET_NW_SRC/DST. */
+struct ofp_action_nw_addr {
+ uint16_t type; /* OFPAT_SET_TW_SRC/DST. */
+ uint16_t len; /* Length is 8. */
+ uint32_t nw_addr; /* IP address. */
+};
+OFP_ASSERT(sizeof(struct ofp_action_nw_addr) == 8);
+
+/* Action structure for OFPAT_SET_TP_SRC/DST. */
+struct ofp_action_tp_port {
+ uint16_t type; /* OFPAT_SET_TP_SRC/DST. */
+ uint16_t len; /* Length is 8. */
+ uint16_t tp_port; /* TCP/UDP port. */
+ uint8_t pad[2];
+};
+OFP_ASSERT(sizeof(struct ofp_action_tp_port) == 8);
+
+/* Action header for OFPAT_VENDOR. The rest of the body is vendor-defined. */
+struct ofp_action_vendor_header {
+ uint16_t type; /* OFPAT_VENDOR. */
+ uint16_t len; /* Length is 8. */
+ uint32_t vendor; /* Vendor ID, which takes the same form
+ as in "struct ofp_vendor". */
+};
+OFP_ASSERT(sizeof(struct ofp_action_vendor_header) == 8);
+
+/* Action header that is common to all actions. The length includes the
+ * header and any padding used to make the action 64-bit aligned.
+ * NB: The length of an action *must* always be a multiple of eight. */
+struct ofp_action_header {
+ uint16_t type; /* One of OFPAT_*. */
+ uint16_t len; /* Length of action, including this
+ header. This is the length of action,
+ including any padding to make it
+ 64-bit aligned. */
+ uint8_t pad[4];
+};
+OFP_ASSERT(sizeof(struct ofp_action_header) == 8);
+
+/* Send packet (controller -> datapath). */
+struct ofp_packet_out {
+ struct ofp_header header;
+ uint32_t buffer_id; /* ID assigned by datapath (-1 if none). */
+ uint16_t in_port; /* Packet's input port (OFPP_NONE if none). */
+ uint16_t actions_len; /* Size of action array in bytes. */
+ struct ofp_action_header actions[0]; /* Actions. */
+ /* uint8_t data[0]; */ /* Packet data. The length is inferred
+ from the length field in the header.
+ (Only meaningful if buffer_id == -1.) */
+};
+OFP_ASSERT(sizeof(struct ofp_packet_out) == 16);
+
+enum ofp_flow_mod_command {
+ OFPFC_ADD, /* New flow. */
+ OFPFC_MODIFY, /* Modify all matching flows. */
+ OFPFC_MODIFY_STRICT, /* Modify entry strictly matching wildcards */
+ OFPFC_DELETE, /* Delete all matching flows. */
+ OFPFC_DELETE_STRICT /* Strictly match wildcards and priority. */
+};
+
+/* Flow wildcards. */
+enum ofp_flow_wildcards {
+ OFPFW_IN_PORT = 1 << 0, /* Switch input port. */
+ OFPFW_DL_VLAN = 1 << 1, /* VLAN. */
+ OFPFW_DL_SRC = 1 << 2, /* Ethernet source address. */
+ OFPFW_DL_DST = 1 << 3, /* Ethernet destination address. */
+ OFPFW_DL_TYPE = 1 << 4, /* Ethernet frame type. */
+ OFPFW_NW_PROTO = 1 << 5, /* IP protocol. */
+ OFPFW_TP_SRC = 1 << 6, /* TCP/UDP source port. */
+ OFPFW_TP_DST = 1 << 7, /* TCP/UDP destination port. */
+
+ /* IP source address wildcard bit count. 0 is exact match, 1 ignores the
+ * LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard
+ * the entire field. This is the *opposite* of the usual convention where
+ * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded. */
+ OFPFW_NW_SRC_SHIFT = 8,
+ OFPFW_NW_SRC_BITS = 6,
+ OFPFW_NW_SRC_MASK = ((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT,
+ OFPFW_NW_SRC_ALL = 32 << OFPFW_NW_SRC_SHIFT,
+
+ /* IP destination address wildcard bit count. Same format as source. */
+ OFPFW_NW_DST_SHIFT = 14,
+ OFPFW_NW_DST_BITS = 6,
+ OFPFW_NW_DST_MASK = ((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT,
+ OFPFW_NW_DST_ALL = 32 << OFPFW_NW_DST_SHIFT,
+
+ /* Wildcard all fields. */
+ OFPFW_ALL = ((1 << 20) - 1)
+};
+
+/* Values below this cutoff are 802.3 packets and the two bytes
+ * following MAC addresses are used as a frame length. Otherwise, the
+ * two bytes are used as the Ethernet type.
+ */
+#define OFP_DL_TYPE_ETH2_CUTOFF 0x0600
+
+/* Value of dl_type to indicate that the frame does not include an
+ * Ethernet type.
+ */
+#define OFP_DL_TYPE_NOT_ETH_TYPE 0x05ff
+
+/* The VLAN id is 12-bits, so we can use the entire 16 bits to indicate
+ * special conditions. All ones indicates that no VLAN id was set.
+ */
+#define OFP_VLAN_NONE 0xffff
+
+/* Fields to match against flows */
+struct ofp_match {
+ uint32_t wildcards; /* Wildcard fields. */
+ uint16_t in_port; /* Input switch port. */
+ uint8_t dl_src[OFP_ETH_ALEN]; /* Ethernet source address. */
+ uint8_t dl_dst[OFP_ETH_ALEN]; /* Ethernet destination address. */
+ uint16_t dl_vlan; /* Input VLAN. */
+ uint16_t dl_type; /* Ethernet frame type. */
+ uint8_t nw_proto; /* IP protocol. */
+ uint8_t pad; /* Align to 32-bits. */
+ uint32_t nw_src; /* IP source address. */
+ uint32_t nw_dst; /* IP destination address. */
+ uint16_t tp_src; /* TCP/UDP source port. */
+ uint16_t tp_dst; /* TCP/UDP destination port. */
+};
+OFP_ASSERT(sizeof(struct ofp_match) == 36);
+
+/* Value used in "idle_timeout" and "hard_timeout" to indicate that the entry
+ * is permanent. */
+#define OFP_FLOW_PERMANENT 0
+
+/* By default, choose a priority in the middle */
+#define OFP_DEFAULT_PRIORITY 0x8000
+
+/* Flow setup and teardown (controller -> datapath). */
+struct ofp_flow_mod {
+ struct ofp_header header;
+ struct ofp_match match; /* Fields to match */
+
+ /* Flow actions. */
+ uint16_t command; /* One of OFPFC_*. */
+ uint16_t idle_timeout; /* Idle time before discarding (seconds). */
+ uint16_t hard_timeout; /* Max time before discarding (seconds). */
+ uint16_t priority; /* Priority level of flow entry. */
+ uint32_t buffer_id; /* Buffered packet to apply to (or -1).
+ Not meaningful for OFPFC_DELETE*. */
+ uint32_t reserved; /* Reserved for future use. */
+ struct ofp_action_header actions[0]; /* The action length is inferred
+ from the length field in the
+ header. */
+};
+OFP_ASSERT(sizeof(struct ofp_flow_mod) == 60);
+
+/* Why did this flow expire? */
+enum ofp_flow_expired_reason {
+ OFPER_IDLE_TIMEOUT, /* Flow idle time exceeded idle_timeout. */
+ OFPER_HARD_TIMEOUT /* Time exceeded hard_timeout. */
+};
+
+/* Flow expiration (datapath -> controller). */
+struct ofp_flow_expired {
+ struct ofp_header header;
+ struct ofp_match match; /* Description of fields */
+
+ uint16_t priority; /* Priority level of flow entry. */
+ uint8_t reason; /* One of OFPER_*. */
+ uint8_t pad[1]; /* Align to 32-bits. */
+
+ uint32_t duration; /* Time flow was alive in seconds. */
+ uint8_t pad2[4]; /* Align to 64-bits. */
+ uint64_t packet_count;
+ uint64_t byte_count;
+};
+OFP_ASSERT(sizeof(struct ofp_flow_expired) == 72);
+
+/* Values for 'type' in ofp_error_message. These values are immutable: they
+ * will not change in future versions of the protocol (although new values may
+ * be added). */
+enum ofp_error_type {
+ OFPET_HELLO_FAILED, /* Hello protocol failed. */
+ OFPET_BAD_REQUEST, /* Request was not understood. */
+ OFPET_BAD_ACTION, /* Error in action description. */
+ OFPET_FLOW_MOD_FAILED /* Problem modifying flow entry. */
+};
+
+/* ofp_error_msg 'code' values for OFPET_HELLO_FAILED. 'data' contains an
+ * ASCII text string that may give failure details. */
+enum ofp_hello_failed_code {
+ OFPHFC_INCOMPATIBLE /* No compatible version. */
+};
+
+/* ofp_error_msg 'code' values for OFPET_BAD_REQUEST. 'data' contains at least
+ * the first 64 bytes of the failed request. */
+enum ofp_bad_request_code {
+ OFPBRC_BAD_VERSION, /* ofp_header.version not supported. */
+ OFPBRC_BAD_TYPE, /* ofp_header.type not supported. */
+ OFPBRC_BAD_STAT, /* ofp_stats_request.type not supported. */
+ OFPBRC_BAD_VENDOR, /* Vendor not supported (in ofp_vendor or
+ * ofp_stats_request or ofp_stats_reply). */
+ OFPBRC_BAD_SUBTYPE /* Vendor subtype not supported. */
+};
+
+/* ofp_error_msg 'code' values for OFPET_BAD_ACTION. 'data' contains at least
+ * the first 64 bytes of the failed request. */
+enum ofp_bad_action_code {
+ OFPBAC_BAD_TYPE, /* Unknown action type. */
+ OFPBAC_BAD_LEN, /* Length problem in actions. */
+ OFPBAC_BAD_VENDOR, /* Unknown vendor id specified. */
+ OFPBAC_BAD_VENDOR_TYPE, /* Unknown action type for vendor id. */
+ OFPBAC_BAD_OUT_PORT, /* Problem validating output action. */
+ OFPBAC_BAD_ARGUMENT /* Bad action argument. */
+};
+
+/* ofp_error_msg 'code' values for OFPET_FLOW_MOD_FAILED. 'data' contains
+ * at least the first 64 bytes of the failed request. */
+enum ofp_flow_mod_failed_code {
+ OFPFMFC_ALL_TABLES_FULL /* Flow not added because of full tables. */
+};
+
+/* OFPT_ERROR: Error message (datapath -> controller). */
+struct ofp_error_msg {
+ struct ofp_header header;
+
+ uint16_t type;
+ uint16_t code;
+ uint8_t data[0]; /* Variable-length data. Interpreted based
+ on the type and code. */
+};
+OFP_ASSERT(sizeof(struct ofp_error_msg) == 12);
+
+enum ofp_stats_types {
+ /* Description of this OpenFlow switch.
+ * The request body is empty.
+ * The reply body is struct ofp_desc_stats. */
+ OFPST_DESC,
+
+ /* Individual flow statistics.
+ * The request body is struct ofp_flow_stats_request.
+ * The reply body is an array of struct ofp_flow_stats. */
+ OFPST_FLOW,
+
+ /* Aggregate flow statistics.
+ * The request body is struct ofp_aggregate_stats_request.
+ * The reply body is struct ofp_aggregate_stats_reply. */
+ OFPST_AGGREGATE,
+
+ /* Flow table statistics.
+ * The request body is empty.
+ * The reply body is an array of struct ofp_table_stats. */
+ OFPST_TABLE,
+
+ /* Physical port statistics.
+ * The request body is empty.
+ * The reply body is an array of struct ofp_port_stats. */
+ OFPST_PORT,
+
+ /* Vendor extension.
+ * The request and reply bodies begin with a 32-bit vendor ID, which takes
+ * the same form as in "struct ofp_vendor". The request and reply bodies
+ * are otherwise vendor-defined. */
+ OFPST_VENDOR = 0xffff
+};
+
+struct ofp_stats_request {
+ struct ofp_header header;
+ uint16_t type; /* One of the OFPST_* constants. */
+ uint16_t flags; /* OFPSF_REQ_* flags (none yet defined). */
+ uint8_t body[0]; /* Body of the request. */
+};
+OFP_ASSERT(sizeof(struct ofp_stats_request) == 12);
+
+enum ofp_stats_reply_flags {
+ OFPSF_REPLY_MORE = 1 << 0 /* More replies to follow */
+};
+
+struct ofp_stats_reply {
+ struct ofp_header header;
+ uint16_t type; /* One of the OFPST_* constants. */
+ uint16_t flags; /* OFPSF_REPLY_* flags. */
+ uint8_t body[0]; /* Body of the reply. */
+};
+OFP_ASSERT(sizeof(struct ofp_stats_reply) == 12);
+
+#define DESC_STR_LEN 256
+#define SERIAL_NUM_LEN 32
+/* Body of reply to OFPST_DESC request. Each entry is a NULL-terminated
+ * ASCII string. */
+struct ofp_desc_stats {
+ char mfr_desc[DESC_STR_LEN]; /* Manufacturer description. */
+ char hw_desc[DESC_STR_LEN]; /* Hardware description. */
+ char sw_desc[DESC_STR_LEN]; /* Software description. */
+ char serial_num[SERIAL_NUM_LEN]; /* Serial number. */
+};
+OFP_ASSERT(sizeof(struct ofp_desc_stats) == 800);
+
+/* Body for ofp_stats_request of type OFPST_FLOW. */
+struct ofp_flow_stats_request {
+ struct ofp_match match; /* Fields to match */
+ uint8_t table_id; /* ID of table to read (from ofp_table_stats)
+ or 0xff for all tables. */
+ uint8_t pad[3]; /* Align to 32 bits. */
+};
+OFP_ASSERT(sizeof(struct ofp_flow_stats_request) == 40);
+
+/* Body of reply to OFPST_FLOW request. */
+struct ofp_flow_stats {
+ uint16_t length; /* Length of this entry. */
+ uint8_t table_id; /* ID of table flow came from. */
+ uint8_t pad;
+ struct ofp_match match; /* Description of fields. */
+ uint32_t duration; /* Time flow has been alive in seconds. */
+ uint16_t priority; /* Priority of the entry. Only meaningful
+ when this is not an exact-match entry. */
+ uint16_t idle_timeout; /* Number of seconds idle before expiration. */
+ uint16_t hard_timeout; /* Number of seconds before expiration. */
+ uint16_t pad2[3]; /* Pad to 64 bits. */
+ uint64_t packet_count; /* Number of packets in flow. */
+ uint64_t byte_count; /* Number of bytes in flow. */
+ struct ofp_action_header actions[0]; /* Actions. */
+};
+OFP_ASSERT(sizeof(struct ofp_flow_stats) == 72);
+
+/* Body for ofp_stats_request of type OFPST_AGGREGATE. */
+struct ofp_aggregate_stats_request {
+ struct ofp_match match; /* Fields to match */
+ uint8_t table_id; /* ID of table to read (from ofp_table_stats)
+ or 0xff for all tables. */
+ uint8_t pad[3]; /* Align to 32 bits. */
+};
+OFP_ASSERT(sizeof(struct ofp_aggregate_stats_request) == 40);
+
+/* Body of reply to OFPST_AGGREGATE request. */
+struct ofp_aggregate_stats_reply {
+ uint64_t packet_count; /* Number of packets in flows. */
+ uint64_t byte_count; /* Number of bytes in flows. */
+ uint32_t flow_count; /* Number of flows. */
+ uint8_t pad[4]; /* Align to 64 bits. */
+};
+OFP_ASSERT(sizeof(struct ofp_aggregate_stats_reply) == 24);
+
+/* Body of reply to OFPST_TABLE request. */
+struct ofp_table_stats {
+ uint8_t table_id; /* Identifier of table. Lower numbered tables
+ are consulted first. */
+ uint8_t pad[3]; /* Align to 32-bits */
+ char name[OFP_MAX_TABLE_NAME_LEN];
+ uint32_t wildcards; /* Bitmap of OFPFW_* wildcards that are
+ supported by the table. */
+ uint32_t max_entries; /* Max number of entries supported */
+ uint32_t active_count; /* Number of active entries */
+ uint64_t lookup_count; /* Number of packets looked up in table */
+ uint64_t matched_count; /* Number of packets that hit table */
+};
+OFP_ASSERT(sizeof(struct ofp_table_stats) == 64);
+
+/* Body of reply to OFPST_PORT request. If a counter is unsupported, set
+ * the field to all ones. */
+struct ofp_port_stats {
+ uint16_t port_no;
+ uint8_t pad[6]; /* Align to 64-bits. */
+ uint64_t rx_packets; /* Number of received packets. */
+ uint64_t tx_packets; /* Number of transmitted packets. */
+ uint64_t rx_bytes; /* Number of received bytes. */
+ uint64_t tx_bytes; /* Number of transmitted bytes. */
+ uint64_t rx_dropped; /* Number of packets dropped by RX. */
+ uint64_t tx_dropped; /* Number of packets dropped by TX. */
+ uint64_t rx_errors; /* Number of receive errors. This is a super-set
+ of receive errors and should be great than or
+ equal to the sum of al rx_*_err values. */
+ uint64_t tx_errors; /* Number of transmit errors. This is a super-set
+ of transmit errors. */
+ uint64_t rx_frame_err; /* Number of frame alignment errors. */
+ uint64_t rx_over_err; /* Number of packets with RX overrun. */
+ uint64_t rx_crc_err; /* Number of CRC errors. */
+ uint64_t collisions; /* Number of collisions. */
+};
+OFP_ASSERT(sizeof(struct ofp_port_stats) == 104);
+
+/* Vendor extension. */
+struct ofp_vendor_header {
+ struct ofp_header header; /* Type OFPT_VENDOR. */
+ uint32_t vendor; /* Vendor ID:
+ * - MSB 0: low-order bytes are IEEE OUI.
+ * - MSB != 0: defined by OpenFlow
+ * consortium. */
+ /* Vendor-defined arbitrary additional data. */
+};
+OFP_ASSERT(sizeof(struct ofp_vendor_header) == 12);
+
+#endif /* openflow/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 PACKETS_H
-#define PACKETS_H 1
-
-#include <stdint.h>
-#include <string.h>
-#include "compiler.h"
-#include "random.h"
-#include "util.h"
-
-#define ETH_ADDR_LEN 6
-
-static const uint8_t eth_addr_broadcast[ETH_ADDR_LEN] UNUSED
- = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-
-static inline bool eth_addr_is_broadcast(const uint8_t ea[6])
-{
- 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])
-{
- return ea[0] & 1;
-}
-static inline bool eth_addr_is_local(const uint8_t ea[6])
-{
- return ea[0] & 2;
-}
-static inline bool eth_addr_is_zero(const uint8_t ea[6])
-{
- return !(ea[0] | ea[1] | ea[2] | ea[3] | ea[4] | ea[5]);
-}
-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);
-}
-static inline uint64_t eth_addr_to_uint64(const uint8_t ea[ETH_ADDR_LEN])
-{
- return (((uint64_t) ea[0] << 40)
- | ((uint64_t) ea[1] << 32)
- | ((uint64_t) ea[2] << 24)
- | ((uint64_t) ea[3] << 16)
- | ((uint64_t) ea[4] << 8)
- | ea[5]);
-}
-static inline void eth_addr_from_uint64(uint64_t x, uint8_t ea[ETH_ADDR_LEN])
-{
- ea[0] = x >> 40;
- ea[1] = x >> 32;
- ea[2] = x >> 24;
- ea[3] = x >> 16;
- ea[4] = x >> 8;
- ea[5] = x;
-}
-static inline void eth_addr_random(uint8_t ea[ETH_ADDR_LEN])
-{
- random_bytes(ea, ETH_ADDR_LEN);
- ea[0] &= ~1; /* Unicast. */
- ea[0] |= 2; /* Private. */
-}
-
-#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
-#define ETH_TYPE_VLAN 0x8100
-
-#define ETH_HEADER_LEN 14
-#define ETH_PAYLOAD_MIN 46
-#define ETH_PAYLOAD_MAX 1500
-#define ETH_TOTAL_MIN (ETH_HEADER_LEN + ETH_PAYLOAD_MIN)
-#define ETH_TOTAL_MAX (ETH_HEADER_LEN + ETH_PAYLOAD_MAX)
-#define ETH_VLAN_TOTAL_MAX (ETH_HEADER_LEN + VLAN_HEADER_LEN + ETH_PAYLOAD_MAX)
-struct eth_header {
- uint8_t eth_dst[ETH_ADDR_LEN];
- uint8_t eth_src[ETH_ADDR_LEN];
- uint16_t eth_type;
-} __attribute__((packed));
-BUILD_ASSERT_DECL(ETH_HEADER_LEN == sizeof(struct eth_header));
-
-#define LLC_DSAP_SNAP 0xaa
-#define LLC_SSAP_SNAP 0xaa
-#define LLC_CNTL_SNAP 3
-
-#define LLC_HEADER_LEN 3
-struct llc_header {
- uint8_t llc_dsap;
- uint8_t llc_ssap;
- uint8_t llc_cntl;
-} __attribute__((packed));
-BUILD_ASSERT_DECL(LLC_HEADER_LEN == sizeof(struct llc_header));
-
-#define SNAP_ORG_ETHERNET "\0\0" /* The compiler adds a null byte, so
- sizeof(SNAP_ORG_ETHERNET) == 3. */
-#define SNAP_HEADER_LEN 5
-struct snap_header {
- uint8_t snap_org[3];
- uint16_t snap_type;
-} __attribute__((packed));
-BUILD_ASSERT_DECL(SNAP_HEADER_LEN == sizeof(struct snap_header));
-
-#define LLC_SNAP_HEADER_LEN (LLC_HEADER_LEN + SNAP_HEADER_LEN)
-struct llc_snap_header {
- struct llc_header llc;
- struct snap_header snap;
-} __attribute__((packed));
-BUILD_ASSERT_DECL(LLC_SNAP_HEADER_LEN == sizeof(struct llc_snap_header));
-
-#define VLAN_VID_MASK 0x0fff
-#define VLAN_PCP_MASK 0xe000
-
-#define VLAN_HEADER_LEN 4
-struct vlan_header {
- uint16_t vlan_tci; /* Lowest 12 bits are VLAN ID. */
- uint16_t vlan_next_type;
-};
-BUILD_ASSERT_DECL(VLAN_HEADER_LEN == sizeof(struct vlan_header));
-
-#define VLAN_ETH_HEADER_LEN (ETH_HEADER_LEN + VLAN_HEADER_LEN)
-struct vlan_eth_header {
- uint8_t veth_dst[ETH_ADDR_LEN];
- uint8_t veth_src[ETH_ADDR_LEN];
- uint16_t veth_type; /* Always htons(ETH_TYPE_VLAN). */
- uint16_t veth_tci; /* Lowest 12 bits are VLAN ID. */
- uint16_t veth_next_type;
-} __attribute__((packed));
-BUILD_ASSERT_DECL(VLAN_ETH_HEADER_LEN == sizeof(struct vlan_eth_header));
-
-#define IP_FMT "%"PRIu8".%"PRIu8".%"PRIu8".%"PRIu8
-#define IP_ARGS(ip) \
- ((uint8_t *) ip)[0], \
- ((uint8_t *) ip)[1], \
- ((uint8_t *) ip)[2], \
- ((uint8_t *) ip)[3]
-
-#define IP_VER(ip_ihl_ver) ((ip_ihl_ver) >> 4)
-#define IP_IHL(ip_ihl_ver) ((ip_ihl_ver) & 15)
-#define IP_IHL_VER(ihl, ver) (((ver) << 4) | (ihl))
-
-#define IP_TYPE_ICMP 1
-#define IP_TYPE_TCP 6
-#define IP_TYPE_UDP 17
-
-#define IP_VERSION 4
-
-#define IP_DONT_FRAGMENT 0x4000 /* Don't fragment. */
-#define IP_MORE_FRAGMENTS 0x2000 /* More fragments. */
-#define IP_FRAG_OFF_MASK 0x1fff /* Fragment offset. */
-#define IP_IS_FRAGMENT(ip_frag_off) \
- ((ip_frag_off) & htons(IP_MORE_FRAGMENTS | IP_FRAG_OFF_MASK))
-
-#define IP_HEADER_LEN 20
-struct ip_header {
- uint8_t ip_ihl_ver;
- uint8_t ip_tos;
- uint16_t ip_tot_len;
- uint16_t ip_id;
- uint16_t ip_frag_off;
- uint8_t ip_ttl;
- uint8_t ip_proto;
- uint16_t ip_csum;
- uint32_t ip_src;
- uint32_t ip_dst;
-};
-BUILD_ASSERT_DECL(IP_HEADER_LEN == sizeof(struct ip_header));
-
-#define UDP_HEADER_LEN 8
-struct udp_header {
- uint16_t udp_src;
- uint16_t udp_dst;
- uint16_t udp_len;
- uint16_t udp_csum;
-};
-BUILD_ASSERT_DECL(UDP_HEADER_LEN == sizeof(struct udp_header));
-
-#define TCP_FIN 0x01
-#define TCP_SYN 0x02
-#define TCP_RST 0x04
-#define TCP_PSH 0x08
-#define TCP_ACK 0x10
-#define TCP_URG 0x20
-
-#define TCP_FLAGS(tcp_ctl) (htons(tcp_ctl) & 0x003f)
-#define TCP_OFFSET(tcp_ctl) (htons(tcp_ctl) >> 12)
-
-#define TCP_HEADER_LEN 20
-struct tcp_header {
- uint16_t tcp_src;
- uint16_t tcp_dst;
- uint32_t tcp_seq;
- uint32_t tcp_ack;
- uint16_t tcp_ctl;
- uint16_t tcp_winsz;
- uint16_t tcp_csum;
- uint16_t tcp_urg;
-};
-BUILD_ASSERT_DECL(TCP_HEADER_LEN == sizeof(struct tcp_header));
-
-#define ARP_HRD_ETHERNET 1
-#define ARP_PRO_IP 0x0800
-#define ARP_OP_REQUEST 1
-#define ARP_OP_REPLY 2
-
-#define ARP_ETH_HEADER_LEN 28
-struct arp_eth_header {
- /* Generic members. */
- uint16_t ar_hrd; /* Hardware type. */
- uint16_t ar_pro; /* Protocol type. */
- uint8_t ar_hln; /* Hardware address length. */
- uint8_t ar_pln; /* Protocol address length. */
- uint16_t ar_op; /* Opcode. */
-
- /* Ethernet+IPv4 specific members. */
- uint8_t ar_sha[ETH_ADDR_LEN]; /* Sender hardware address. */
- uint32_t ar_spa; /* Sender protocol address. */
- uint8_t ar_tha[ETH_ADDR_LEN]; /* Target hardware address. */
- uint32_t ar_tpa; /* Target protocol address. */
-} __attribute__((packed));
-BUILD_ASSERT_DECL(ARP_ETH_HEADER_LEN == sizeof(struct arp_eth_header));
-
-#endif /* packets.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.
- */
-
-/* High-level wrapper around the "poll" system call.
- *
- * Intended usage is for the program's main loop to go about its business
- * servicing whatever events it needs to. Then, when it runs out of immediate
- * tasks, it calls each subordinate module's "wait" function, which in turn
- * calls one (or more) of the functions poll_fd_wait(), poll_immediate_wake(),
- * and poll_timer_wait() to register to be awakened when the appropriate event
- * occurs. Then the main loop calls poll_block(), which blocks until one of
- * the registered events happens.
- *
- * There is also some support for autonomous subroutines that are executed by
- * poll_block() when a file descriptor becomes ready. To prevent these
- * routines from starving if events are continuously ready, the application
- * should bound the amount of work it does between poll_block() calls. */
-
-#ifndef POLL_LOOP_H
-#define POLL_LOOP_H 1
-
-#include <poll.h>
-
-struct poll_waiter;
-
-/* Schedule events to wake up the following poll_block(). */
-struct poll_waiter *poll_fd_wait(int fd, short int events);
-void poll_timer_wait(int msec);
-void poll_immediate_wake(void);
-
-/* Wait until an event occurs. */
-void poll_block(void);
-
-/* Autonomous function callbacks. */
-typedef void poll_fd_func(int fd, short int revents, void *aux);
-struct poll_waiter *poll_fd_callback(int fd, short int events,
- poll_fd_func *, void *aux);
-
-/* Cancel a file descriptor callback or event. */
-void poll_cancel(struct poll_waiter *);
-
-#endif /* poll-loop.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 PORT_ARRAY_H
-#define PORT_ARRAY_H 1
-
-#include <assert.h>
-#include "openflow.h"
-#include "util.h"
-
-static inline uint16_t
-port_array_extract_bits__(uint16_t data, int start, int count)
-{
- return (data >> start) & ((1u << count) - 1);
-}
-
-/* Level 1: most-significant bits. */
-#define PORT_ARRAY_L1_BITS 5
-#define PORT_ARRAY_L1_SHIFT (PORT_ARRAY_L3_BITS + PORT_ARRAY_L2_BITS)
-#define PORT_ARRAY_L1_SIZE (1u << PORT_ARRAY_L1_BITS)
-#define PORT_ARRAY_L1(IDX) \
- port_array_extract_bits__(IDX, PORT_ARRAY_L1_SHIFT, PORT_ARRAY_L1_BITS)
-
-/* Level 2: middle bits. */
-#define PORT_ARRAY_L2_BITS 5
-#define PORT_ARRAY_L2_SHIFT PORT_ARRAY_L3_BITS
-#define PORT_ARRAY_L2_SIZE (1u << PORT_ARRAY_L2_BITS)
-#define PORT_ARRAY_L2(IDX) \
- port_array_extract_bits__(IDX, PORT_ARRAY_L2_SHIFT, PORT_ARRAY_L2_BITS)
-
-/* Level 3: least-significant bits. */
-#define PORT_ARRAY_L3_BITS 6
-#define PORT_ARRAY_L3_SHIFT 0
-#define PORT_ARRAY_L3_SIZE (1u << PORT_ARRAY_L3_BITS)
-#define PORT_ARRAY_L3(IDX) \
- port_array_extract_bits__(IDX, PORT_ARRAY_L3_SHIFT, PORT_ARRAY_L3_BITS)
-
-#define PORT_ARRAY_SIZE (1u << (PORT_ARRAY_L1_BITS \
- + PORT_ARRAY_L2_BITS \
- + PORT_ARRAY_L3_BITS))
-
-BUILD_ASSERT_DECL(PORT_ARRAY_SIZE > 0xffff);
-
-/* A "sparse array" of up to 65536 elements (numbered 0...65535), implemented
- * as a 3-level trie. Most efficient when the elements are clustered
- * together. */
-struct port_array {
- struct port_array_l2 *l1[1u << PORT_ARRAY_L1_BITS];
-};
-
-struct port_array_l2 {
- struct port_array_l3 *l2[1u << PORT_ARRAY_L2_BITS];
-};
-
-struct port_array_l3 {
- void *l3[1u << PORT_ARRAY_L3_BITS];
-};
-
-/* Returns the value of the element numbered 'idx' in 'pa', or a null pointer
- * if no element numbered 'idx' has been set. */
-static inline void *
-port_array_get(const struct port_array *pa, uint16_t idx)
-{
- unsigned int l1_idx = PORT_ARRAY_L1(idx);
- unsigned int l2_idx = PORT_ARRAY_L2(idx);
- unsigned int l3_idx = PORT_ARRAY_L3(idx);
- return pa->l1[l1_idx]->l2[l2_idx]->l3[l3_idx];
-}
-
-void port_array_init(struct port_array *);
-void port_array_destroy(struct port_array *);
-void port_array_set(struct port_array *, uint16_t idx, void *);
-void *port_array_first(const struct port_array *, unsigned int *);
-void *port_array_next(const struct port_array *, unsigned int *);
-
-#endif /* port-array.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 QUEUE_H
-#define QUEUE_H 1
-
-/* Packet queue. */
-struct ofp_queue {
- int n; /* Number of queued packets. */
- struct ofpbuf *head; /* First queued packet, null if n == 0. */
- struct ofpbuf *tail; /* Last queued packet, null if n == 0. */
-};
-
-void queue_init(struct ofp_queue *);
-void queue_destroy(struct ofp_queue *);
-void queue_clear(struct ofp_queue *);
-void queue_advance_head(struct ofp_queue *, struct ofpbuf *next);
-void queue_push_tail(struct ofp_queue *, struct ofpbuf *);
-struct ofpbuf *queue_pop_head(struct ofp_queue *);
-
-#endif /* queue.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 RANDOM_H
-#define RANDOM_H 1
-
-#include <stddef.h>
-#include <stdint.h>
-
-void random_bytes(void *, size_t);
-uint32_t random_uint32(void);
-int random_range(int max);
-
-#endif /* random.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 RCONN_H
-#define RCONN_H 1
-
-#include "queue.h"
-#include <stdbool.h>
-#include <stdint.h>
-#include <time.h>
-
-/* A wrapper around vconn that provides queuing and optionally reliability.
- *
- * An rconn maintains a message transmission queue of bounded length specified
- * by the caller. The rconn does not guarantee reliable delivery of
- * queued messages: all queued messages are dropped when reconnection becomes
- * necessary.
- *
- * An rconn optionally provides reliable communication, in this sense: the
- * rconn will re-connect, with exponential backoff, when the underlying vconn
- * disconnects.
- */
-
-struct vconn;
-
-struct rconn *rconn_new(const char *name,
- int inactivity_probe_interval, int max_backoff);
-struct rconn *rconn_new_from_vconn(const char *name, struct vconn *);
-struct rconn *rconn_create(int inactivity_probe_interval, int max_backoff);
-int rconn_connect(struct rconn *, const char *name);
-void rconn_connect_unreliably(struct rconn *,
- const char *name, struct vconn *vconn);
-void rconn_disconnect(struct rconn *);
-void rconn_destroy(struct rconn *);
-
-void rconn_run(struct rconn *);
-void rconn_run_wait(struct rconn *);
-struct ofpbuf *rconn_recv(struct rconn *);
-void rconn_recv_wait(struct rconn *);
-int rconn_send(struct rconn *, struct ofpbuf *, int *n_queued);
-int rconn_send_with_limit(struct rconn *, struct ofpbuf *,
- int *n_queued, int queue_limit);
-unsigned int rconn_packets_sent(const struct rconn *);
-unsigned int rconn_packets_received(const struct rconn *);
-
-void rconn_add_monitor(struct rconn *, struct vconn *);
-
-const char *rconn_get_name(const struct rconn *);
-bool rconn_is_alive(const struct rconn *);
-bool rconn_is_connected(const struct rconn *);
-int rconn_failure_duration(const struct rconn *);
-bool rconn_is_connectivity_questionable(struct rconn *);
-
-uint32_t rconn_get_ip(const struct rconn *);
-
-const char *rconn_get_state(const struct rconn *);
-unsigned int rconn_get_attempted_connections(const struct rconn *);
-unsigned int rconn_get_successful_connections(const struct rconn *);
-time_t rconn_get_last_connection(const struct rconn *);
-time_t rconn_get_creation_time(const struct rconn *);
-unsigned long int rconn_get_total_time_connected(const struct rconn *);
-int rconn_get_backoff(const struct rconn *);
-unsigned int rconn_get_state_elapsed(const struct rconn *);
-
-#endif /* rconn.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 SAT_MATH_H
-#define SAT_MATH_H 1
-
-#include <assert.h>
-#include <limits.h>
-
-/* Saturating addition: overflow yields UINT_MAX. */
-static inline unsigned int
-sat_add(unsigned int x, unsigned int y)
-{
- return x + y >= x ? x + y : UINT_MAX;
-}
-
-/* Saturating subtraction: underflow yields 0. */
-static inline unsigned int
-sat_sub(unsigned int x, unsigned int y)
-{
- return x >= y ? x - y : 0;
-}
-
-/* Saturating multiplication: overflow yields UINT_MAX. */
-static inline unsigned int
-sat_mul(unsigned int x, unsigned int y)
-{
- return (!y ? 0
- : x <= UINT_MAX / y ? x * y
- : UINT_MAX);
-}
-
-#endif /* sat-math.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 SOCKET_UTIL_H
-#define SOCKET_UTIL_H 1
-
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <stdbool.h>
-
-int set_nonblocking(int fd);
-int get_max_fds(void);
-int lookup_ip(const char *host_name, struct in_addr *address);
-int get_socket_error(int sock);
-int check_connection_completion(int fd);
-int drain_rcvbuf(int fd);
-void drain_fd(int fd, size_t n_packets);
-int make_unix_socket(int style, bool nonblock, bool passcred,
- const char *bind_path, const char *connect_path);
-int get_unix_name_len(socklen_t sun_len);
-
-#endif /* socket-util.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 STP_H
-#define STP_H 1
-
-/* This is an implementation of Spanning Tree Protocol as described in IEEE
- * 802.1D-1998, clauses 8 and 9. Section numbers refer to this standard. */
-
-#include <stdbool.h>
-#include <stdint.h>
-#include "compiler.h"
-#include "util.h"
-
-/* Ethernet address used as the destination for STP frames. */
-extern const uint8_t stp_eth_addr[6];
-
-/* LLC field values used for STP frames. */
-#define STP_LLC_SSAP 0x42
-#define STP_LLC_DSAP 0x42
-#define STP_LLC_CNTL 0x03
-
-/* Bridge identifier. Top 16 bits are a priority value (numerically lower
- * values are higher priorities). Bottom 48 bits are MAC address of bridge. */
-typedef uint64_t stp_identifier;
-
-/* Basic STP functionality. */
-#define STP_MAX_PORTS 255
-struct stp *stp_create(const char *name, stp_identifier bridge_id,
- void (*send_bpdu)(const void *bpdu, size_t bpdu_size,
- int port_no, void *aux),
- void *aux);
-void stp_destroy(struct stp *);
-void stp_tick(struct stp *, int elapsed);
-void stp_set_bridge_id(struct stp *, stp_identifier bridge_id);
-void stp_set_bridge_priority(struct stp *, uint16_t new_priority);
-
-/* STP properties. */
-const char *stp_get_name(const struct stp *);
-stp_identifier stp_get_bridge_id(const struct stp *);
-stp_identifier stp_get_designated_root(const struct stp *);
-bool stp_is_root_bridge(const struct stp *);
-int stp_get_root_path_cost(const struct stp *);
-
-/* Obtaining STP ports. */
-struct stp_port *stp_get_port(struct stp *, int port_no);
-struct stp_port *stp_get_root_port(struct stp *);
-bool stp_get_changed_port(struct stp *, struct stp_port **portp);
-
-/* State of an STP port.
- *
- * A port is in exactly one state at any given time, but distinct bits are used
- * for states to allow testing for more than one state with a bit mask. */
-enum stp_state {
- STP_DISABLED = 1 << 0, /* 8.4.5: Disabled by management. */
- STP_LISTENING = 1 << 1, /* 8.4.2: Not learning or relaying frames. */
- STP_LEARNING = 1 << 2, /* 8.4.3: Learning but not relaying frames. */
- STP_FORWARDING = 1 << 3, /* 8.4.4: Learning and relaying frames. */
- STP_BLOCKING = 1 << 4 /* 8.4.1: Initial boot state. */
-};
-const char *stp_state_name(enum stp_state);
-bool stp_forward_in_state(enum stp_state);
-bool stp_learn_in_state(enum stp_state);
-
-void stp_received_bpdu(struct stp_port *, const void *bpdu, size_t bpdu_size);
-
-struct stp *stp_port_get_stp(struct stp_port *);
-int stp_port_no(const struct stp_port *);
-enum stp_state stp_port_get_state(const struct stp_port *);
-void stp_port_enable(struct stp_port *);
-void stp_port_disable(struct stp_port *);
-void stp_port_set_priority(struct stp_port *, uint8_t new_priority);
-void stp_port_set_path_cost(struct stp_port *, unsigned int path_cost);
-void stp_port_set_speed(struct stp_port *, unsigned int speed);
-void stp_port_enable_change_detection(struct stp_port *);
-void stp_port_disable_change_detection(struct stp_port *);
-
-#endif /* stp.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 TIMEVAL_H
-#define TIMEVAL_H 1
-
-#include <time.h>
-#include "type-props.h"
-#include "util.h"
-
-struct pollfd;
-
-/* POSIX allows floating-point time_t, but we don't support it. */
-BUILD_ASSERT_DECL(TYPE_IS_INTEGER(time_t));
-
-/* We do try to cater to unsigned time_t, but I want to know about it if we
- * ever encounter such a platform. */
-BUILD_ASSERT_DECL(TYPE_IS_SIGNED(time_t));
-
-#define TIME_MAX TYPE_MAXIMUM(time_t)
-#define TIME_MIN TYPE_MINIMUM(time_t)
-
-/* Interval between updates to the time reported by time_gettimeofday(), in ms.
- * This should not be adjusted much below 10 ms or so with the current
- * implementation, or too much time will be wasted in signal handlers and calls
- * to time(0). */
-#define TIME_UPDATE_INTERVAL 100
-
-void time_init(void);
-void time_refresh(void);
-time_t time_now(void);
-long long int time_msec(void);
-void time_alarm(unsigned int secs);
-int time_poll(struct pollfd *, int n_pollfds, int timeout);
-
-#endif /* timeval.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 TYPE_PROPS_H
-#define TYPE_PROPS_H 1
-
-#include <limits.h>
-
-#define TYPE_IS_INTEGER(TYPE) ((TYPE) 1.5 == (TYPE) 1)
-#define TYPE_IS_SIGNED(TYPE) ((TYPE) 0 > (TYPE) -1)
-#define TYPE_VALUE_BITS(TYPE) (sizeof(TYPE) * CHAR_BIT - TYPE_IS_SIGNED(TYPE))
-#define TYPE_MINIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \
- ? ~(TYPE)0 << TYPE_VALUE_BITS(TYPE) \
- : 0)
-#define TYPE_MAXIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \
- ? ~(~(TYPE)0 << TYPE_VALUE_BITS(TYPE)) \
- : (TYPE)-1)
-
-#endif /* type-props.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 UTIL_H
-#define UTIL_H 1
-
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include "compiler.h"
-
-#ifndef va_copy
-#ifdef __va_copy
-#define va_copy __va_copy
-#else
-#define va_copy(dst, src) ((dst) = (src))
-#endif
-#endif
-
-#ifndef __cplusplus
-/* Build-time assertion for use in a statement context. */
-#define BUILD_ASSERT(EXPR) \
- sizeof(struct { unsigned int build_assert_failed : (EXPR) ? 1 : -1; })
-
-/* Build-time assertion for use in a declaration context. */
-#define BUILD_ASSERT_DECL(EXPR) \
- extern int (*build_assert(void))[BUILD_ASSERT(EXPR)]
-#else /* __cplusplus */
-#include <boost/static_assert.hpp>
-#define BUILD_ASSERT BOOST_STATIC_ASSERT
-#define BUILD_ASSERT_DECL BOOST_STATIC_ASSERT
-#endif /* __cplusplus */
-
-extern const char *program_name;
-
-#define ARRAY_SIZE(ARRAY) (sizeof ARRAY / sizeof *ARRAY)
-#define ROUND_UP(X, Y) (((X) + ((Y) - 1)) / (Y) * (Y))
-#define ROUND_DOWN(X, Y) ((X) / (Y) * (Y))
-
-#ifndef MIN
-#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
-#endif
-
-#ifndef MAX
-#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
-#endif
-
-#define NOT_REACHED() abort()
-#define NOT_IMPLEMENTED() abort()
-#define NOT_TESTED() ((void) 0) /* XXX should print a message. */
-
-/* Given POINTER, the address of the given MEMBER in a STRUCT object, returns
- the STRUCT object. */
-#define CONTAINER_OF(POINTER, STRUCT, MEMBER) \
- ((STRUCT *) ((char *) (POINTER) - offsetof (STRUCT, MEMBER)))
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void set_program_name(const char *);
-
-void out_of_memory(void);
-void *xmalloc(size_t);
-void *xcalloc(size_t, size_t);
-void *xrealloc(void *, size_t);
-void *xmemdup(const void *, size_t);
-char *xmemdup0(const char *, size_t);
-char *xstrdup(const char *);
-char *xasprintf(const char *format, ...) PRINTF_FORMAT(1, 2);
-char *xvasprintf(const char *format, va_list) PRINTF_FORMAT(1, 0);
-
-#ifndef HAVE_STRLCPY
-void strlcpy(char *dst, const char *src, size_t size);
-#endif
-
-void ofp_fatal(int err_no, const char *format, ...)
- PRINTF_FORMAT(2, 3) NO_RETURN;
-void ofp_error(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3);
-void ofp_hex_dump(FILE *, const void *, size_t, uintptr_t offset, bool ascii);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* util.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 VCONN_PROVIDER_H
-#define VCONN_PROVIDER_H 1
-
-/* Provider interface to vconns, which provide a virtual connection to an
- * OpenFlow device. */
-
-#include <assert.h>
-#include "vconn.h"
-\f
-/* Active virtual connection to an OpenFlow device. */
-
-/* Active virtual connection to an OpenFlow device.
- *
- * This structure should be treated as opaque by vconn implementations. */
-struct vconn {
- struct vconn_class *class;
- int state;
- int error;
- int min_version;
- int version;
- uint32_t ip;
- char *name;
-};
-
-void vconn_init(struct vconn *, struct vconn_class *, int connect_status,
- uint32_t ip, const char *name);
-static inline void vconn_assert_class(const struct vconn *vconn,
- const struct vconn_class *class)
-{
- assert(vconn->class == class);
-}
-
-struct vconn_class {
- /* Prefix for connection names, e.g. "nl", "tcp". */
- const char *name;
-
- /* Attempts to connect to an OpenFlow device. 'name' is the full
- * connection name provided by the user, e.g. "nl:0", "tcp:1.2.3.4". This
- * name is useful for error messages but must not be modified.
- *
- * 'suffix' is a copy of 'name' following the colon and may be modified.
- *
- * Returns 0 if successful, otherwise a positive errno value. If
- * successful, stores a pointer to the new connection in '*vconnp'.
- *
- * The open function must not block waiting for a connection to complete.
- * If the connection cannot be completed immediately, it should return
- * EAGAIN (not EINPROGRESS, as returned by the connect system call) and
- * continue the connection in the background. */
- int (*open)(const char *name, char *suffix, struct vconn **vconnp);
-
- /* Closes 'vconn' and frees associated memory. */
- void (*close)(struct vconn *vconn);
-
- /* Tries to complete the connection on 'vconn'. If 'vconn''s connection is
- * complete, returns 0 if the connection was successful or a positive errno
- * value if it failed. If the connection is still in progress, returns
- * EAGAIN.
- *
- * The connect function must not block waiting for the connection to
- * complete; instead, it should return EAGAIN immediately. */
- int (*connect)(struct vconn *vconn);
-
- /* Tries to receive an OpenFlow message from 'vconn'. If successful,
- * stores the received message into '*msgp' and returns 0. The caller is
- * responsible for destroying the message with ofpbuf_delete(). On
- * failure, returns a positive errno value and stores a null pointer into
- * '*msgp'.
- *
- * If the connection has been closed in the normal fashion, returns EOF.
- *
- * The recv function must not block waiting for a packet to arrive. If no
- * packets have been received, it should return EAGAIN. */
- int (*recv)(struct vconn *vconn, struct ofpbuf **msgp);
-
- /* Tries to queue 'msg' for transmission on 'vconn'. If successful,
- * returns 0, in which case ownership of 'msg' is transferred to the vconn.
- * Success does not guarantee that 'msg' has been or ever will be delivered
- * to the peer, only that it has been queued for transmission.
- *
- * Returns a positive errno value on failure, in which case the caller
- * retains ownership of 'msg'.
- *
- * The send function must not block. If 'msg' cannot be immediately
- * accepted for transmission, it should return EAGAIN. */
- int (*send)(struct vconn *vconn, struct ofpbuf *msg);
-
- /* Arranges for the poll loop to wake up when 'vconn' is ready to take an
- * action of the given 'type'. */
- void (*wait)(struct vconn *vconn, enum vconn_wait_type type);
-};
-\f
-/* Passive virtual connection to an OpenFlow device.
- *
- * This structure should be treated as opaque by vconn implementations. */
-struct pvconn {
- struct pvconn_class *class;
- char *name;
-};
-
-void pvconn_init(struct pvconn *, struct pvconn_class *, const char *name);
-static inline void pvconn_assert_class(const struct pvconn *pvconn,
- const struct pvconn_class *class)
-{
- assert(pvconn->class == class);
-}
-
-struct pvconn_class {
- /* Prefix for connection names, e.g. "ptcp", "pssl". */
- const char *name;
-
- /* Attempts to start listening for OpenFlow connections. 'name' is the
- * full connection name provided by the user, e.g. "nl:0", "tcp:1.2.3.4".
- * This name is useful for error messages but must not be modified.
- *
- * 'suffix' is a copy of 'name' following the colon and may be modified.
- *
- * Returns 0 if successful, otherwise a positive errno value. If
- * successful, stores a pointer to the new connection in '*pvconnp'.
- *
- * The listen function must not block. If the connection cannot be
- * completed immediately, it should return EAGAIN (not EINPROGRESS, as
- * returned by the connect system call) and continue the connection in the
- * background. */
- int (*listen)(const char *name, char *suffix, struct pvconn **pvconnp);
-
- /* Closes 'pvconn' and frees associated memory. */
- void (*close)(struct pvconn *pvconn);
-
- /* Tries to accept a new connection on 'pvconn'. If successful, stores the
- * new connection in '*new_vconnp' and returns 0. Otherwise, returns a
- * positive errno value.
- *
- * The accept function must not block waiting for a connection. If no
- * connection is ready to be accepted, it should return EAGAIN. */
- int (*accept)(struct pvconn *pvconn, struct vconn **new_vconnp);
-
- /* Arranges for the poll loop to wake up when a connection is ready to be
- * accepted on 'pvconn'. */
- void (*wait)(struct pvconn *pvconn);
-};
-
-/* Active and passive vconn classes. */
-extern struct vconn_class tcp_vconn_class;
-extern struct pvconn_class ptcp_pvconn_class;
-extern struct vconn_class unix_vconn_class;
-extern struct pvconn_class punix_pvconn_class;
-#ifdef HAVE_OPENSSL
-extern struct vconn_class ssl_vconn_class;
-extern struct pvconn_class pssl_pvconn_class;
-#endif
-#ifdef HAVE_NETLINK
-extern struct vconn_class netlink_vconn_class;
-#endif
-
-#endif /* vconn-provider.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 VCONN_SSL_H
-#define VCONN_SSL_H 1
-
-#include <stdbool.h>
-
-#ifdef HAVE_OPENSSL
-bool vconn_ssl_is_configured(void);
-void vconn_ssl_set_private_key_file(const char *file_name);
-void vconn_ssl_set_certificate_file(const char *file_name);
-void vconn_ssl_set_ca_cert_file(const char *file_name, bool bootstrap);
-void vconn_ssl_set_peer_ca_cert_file(const char *file_name);
-
-#define VCONN_SSL_LONG_OPTIONS \
- {"private-key", required_argument, 0, 'p'}, \
- {"certificate", required_argument, 0, 'c'}, \
- {"ca-cert", required_argument, 0, 'C'},
-
-#define VCONN_SSL_OPTION_HANDLERS \
- case 'p': \
- vconn_ssl_set_private_key_file(optarg); \
- break; \
- \
- case 'c': \
- vconn_ssl_set_certificate_file(optarg); \
- break; \
- \
- case 'C': \
- vconn_ssl_set_ca_cert_file(optarg, false); \
- break;
-#else /* !HAVE_OPENSSL */
-static inline bool vconn_ssl_is_configured(void)
-{
- return false;
-}
-#define VCONN_SSL_LONG_OPTIONS
-#define VCONN_SSL_OPTION_HANDLERS
-#endif /* !HAVE_OPENSSL */
-
-#endif /* vconn-ssl.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 VCONN_STREAM_H
-#define VCONN_STREAM_H 1
-
-#include <stddef.h>
-#include <stdint.h>
-
-struct vconn;
-struct pvconn;
-struct sockaddr;
-
-int new_stream_vconn(const char *name, int fd, int connect_status,
- uint32_t ip, struct vconn **vconnp);
-int new_pstream_pvconn(const char *name, int fd,
- int (*accept_cb)(int fd, const struct sockaddr *,
- size_t sa_len, struct vconn **),
- struct pvconn **pvconnp);
-
-#endif /* vconn-stream.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 VCONN_H
-#define VCONN_H 1
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-struct ofpbuf;
-struct flow;
-struct ofp_header;
-struct pvconn;
-struct vconn;
-
-void vconn_usage(bool active, bool passive, bool bootstrap);
-
-/* Active vconns: virtual connections to OpenFlow devices. */
-int vconn_open(const char *name, int min_version, struct vconn **);
-void vconn_close(struct vconn *);
-const char *vconn_get_name(const struct vconn *);
-uint32_t vconn_get_ip(const struct vconn *);
-int vconn_connect(struct vconn *);
-int vconn_recv(struct vconn *, struct ofpbuf **);
-int vconn_send(struct vconn *, struct ofpbuf *);
-int vconn_recv_xid(struct vconn *, uint32_t xid, struct ofpbuf **);
-int vconn_transact(struct vconn *, struct ofpbuf *, struct ofpbuf **);
-
-int vconn_open_block(const char *name, int min_version, struct vconn **);
-int vconn_send_block(struct vconn *, struct ofpbuf *);
-int vconn_recv_block(struct vconn *, struct ofpbuf **);
-
-enum vconn_wait_type {
- WAIT_CONNECT,
- WAIT_RECV,
- WAIT_SEND
-};
-void vconn_wait(struct vconn *, enum vconn_wait_type);
-void vconn_connect_wait(struct vconn *);
-void vconn_recv_wait(struct vconn *);
-void vconn_send_wait(struct vconn *);
-
-/* Passive vconns: virtual listeners for incoming OpenFlow connections. */
-int pvconn_open(const char *name, struct pvconn **);
-void pvconn_close(struct pvconn *);
-int pvconn_accept(struct pvconn *, int min_version, struct vconn **);
-void pvconn_wait(struct pvconn *);
-
-/* OpenFlow protocol utility functions. */
-void *make_openflow(size_t openflow_len, uint8_t type, struct ofpbuf **);
-void *make_openflow_xid(size_t openflow_len, uint8_t type,
- uint32_t xid, struct ofpbuf **);
-void update_openflow_length(struct ofpbuf *);
-struct ofpbuf *make_add_flow(const struct flow *, uint32_t buffer_id,
- uint16_t max_idle, size_t actions_len);
-struct ofpbuf *make_add_simple_flow(const struct flow *,
- uint32_t buffer_id, uint16_t out_port,
- uint16_t max_idle);
-struct ofpbuf *make_buffered_packet_out(uint32_t buffer_id,
- uint16_t in_port, uint16_t out_port);
-struct ofpbuf *make_unbuffered_packet_out(const struct ofpbuf *packet,
- uint16_t in_port, uint16_t out_port);
-struct ofpbuf *make_echo_request(void);
-struct ofpbuf *make_echo_reply(const struct ofp_header *rq);
-
-#endif /* vconn.h */
+++ /dev/null
-/* Modules that can emit log messages. */
-VLOG_MODULE(chain)
-VLOG_MODULE(controller)
-VLOG_MODULE(ctlpath)
-VLOG_MODULE(daemon)
-VLOG_MODULE(datapath)
-VLOG_MODULE(dhcp)
-VLOG_MODULE(dhcp_client)
-VLOG_MODULE(discovery)
-VLOG_MODULE(dpif)
-VLOG_MODULE(dpctl)
-VLOG_MODULE(executer)
-VLOG_MODULE(fail_open)
-VLOG_MODULE(fault)
-VLOG_MODULE(flow)
-VLOG_MODULE(in_band)
-VLOG_MODULE(learning_switch)
-VLOG_MODULE(mac_learning)
-VLOG_MODULE(netdev)
-VLOG_MODULE(netlink)
-VLOG_MODULE(ofp_discover)
-VLOG_MODULE(poll_loop)
-VLOG_MODULE(port_watcher)
-VLOG_MODULE(secchan)
-VLOG_MODULE(rconn)
-VLOG_MODULE(snat)
-VLOG_MODULE(stp)
-VLOG_MODULE(stp_secchan)
-VLOG_MODULE(status)
-VLOG_MODULE(switch)
-VLOG_MODULE(terminal)
-VLOG_MODULE(socket_util)
-VLOG_MODULE(vconn_netlink)
-VLOG_MODULE(vconn_tcp)
-VLOG_MODULE(vconn_ssl)
-VLOG_MODULE(vconn_stream)
-VLOG_MODULE(vconn_unix)
-VLOG_MODULE(vconn)
-VLOG_MODULE(vlog)
-VLOG_MODULE(vlog_socket)
-
-#ifdef HAVE_EXT
-#include "ext/vlogext-modules.def"
-#endif
-
-#undef VLOG_MODULE
+++ /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 VLOG_SOCKET_H
-#define VLOG_SOCKET_H 1
-
-/* Server for Vlog control connection. */
-struct vlog_server;
-int vlog_server_listen(const char *path, struct vlog_server **);
-void vlog_server_close(struct vlog_server *);
-
-/* Client for Vlog control connection. */
-struct vlog_client;
-int vlog_client_connect(const char *path, struct vlog_client **);
-void vlog_client_close(struct vlog_client *);
-int vlog_client_send(struct vlog_client *, const char *request);
-int vlog_client_recv(struct vlog_client *, char **reply);
-int vlog_client_transact(struct vlog_client *,
- const char *request, char **reply);
-const char *vlog_client_target(const struct vlog_client *);
-
-#endif /* vlog-socket.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 VLOG_H
-#define VLOG_H 1
-
-#include <limits.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <time.h>
-#include "util.h"
-
-/* Logging importance levels. */
-#define VLOG_LEVELS \
- VLOG_LEVEL(EMER, LOG_ALERT) \
- VLOG_LEVEL(ERR, LOG_ERR) \
- VLOG_LEVEL(WARN, LOG_WARNING) \
- VLOG_LEVEL(DBG, LOG_DEBUG)
-enum vlog_level {
-#define VLOG_LEVEL(NAME, SYSLOG_LEVEL) VLL_##NAME,
- VLOG_LEVELS
-#undef VLOG_LEVEL
- VLL_N_LEVELS
-};
-
-const char *vlog_get_level_name(enum vlog_level);
-enum vlog_level vlog_get_level_val(const char *name);
-
-/* Facilities that we can log to. */
-#define VLOG_FACILITIES \
- VLOG_FACILITY(SYSLOG, "%05N|%c|%p|%m") \
- VLOG_FACILITY(CONSOLE, "%d{%b %d %H:%M:%S}|%05N|%c|%p|%m") \
- VLOG_FACILITY(FILE, "%d{%b %d %H:%M:%S}|%05N|%c|%p|%m")
-enum vlog_facility {
-#define VLOG_FACILITY(NAME, PATTERN) VLF_##NAME,
- VLOG_FACILITIES
-#undef VLOG_FACILITY
- VLF_N_FACILITIES,
- VLF_ANY_FACILITY = -1
-};
-
-const char *vlog_get_facility_name(enum vlog_facility);
-enum vlog_facility vlog_get_facility_val(const char *name);
-
-/* VLM_ constant for each vlog module. */
-enum vlog_module {
-#define VLOG_MODULE(NAME) VLM_##NAME,
-#include "vlog-modules.def"
- VLM_N_MODULES,
- VLM_ANY_MODULE = -1
-};
-
-const char *vlog_get_module_name(enum vlog_module);
-enum vlog_module vlog_get_module_val(const char *name);
-
-/* Rate-limiter for log messages. */
-struct vlog_rate_limit {
- /* Configuration settings. */
- unsigned int rate; /* Tokens per second. */
- unsigned int burst; /* Max cumulative tokens credit. */
-
- /* Current status. */
- unsigned int tokens; /* Current number of tokens. */
- time_t last_fill; /* Last time tokens added. */
- time_t first_dropped; /* Time first message was dropped. */
- unsigned int n_dropped; /* Number of messages dropped. */
-};
-
-/* Number of tokens to emit a message. We add 'rate' token per second, which
- * is 60 times the unit used for 'rate', thus 60 tokens are required to emit
- * one message. */
-#define VLOG_MSG_TOKENS 60
-
-/* Initializer for a struct vlog_rate_limit, to set up a maximum rate of RATE
- * messages per minute and a maximum burst size of BURST messages. */
-#define VLOG_RATE_LIMIT_INIT(RATE, BURST) \
- { \
- RATE, /* rate */ \
- (MIN(BURST, UINT_MAX / VLOG_MSG_TOKENS) \
- * VLOG_MSG_TOKENS), /* burst */ \
- 0, /* tokens */ \
- 0, /* last_fill */ \
- 0, /* n_dropped */ \
- }
-
-/* Configuring how each module logs messages. */
-enum vlog_level vlog_get_level(enum vlog_module, enum vlog_facility);
-void vlog_set_levels(enum vlog_module, enum vlog_facility, enum vlog_level);
-char *vlog_set_levels_from_string(const char *);
-char *vlog_get_levels(void);
-bool vlog_is_enabled(enum vlog_module, enum vlog_level);
-void vlog_set_verbosity(const char *arg);
-
-/* Configuring log facilities. */
-void vlog_set_pattern(enum vlog_facility, const char *pattern);
-const char *vlog_get_log_file(void);
-int vlog_set_log_file(const char *file_name);
-int vlog_reopen_log_file(void);
-
-/* Function for actual logging. */
-void vlog_init(void);
-void vlog_exit(void);
-void vlog(enum vlog_module, enum vlog_level, const char *format, ...)
- __attribute__((format(printf, 3, 4)));
-void vlog_valist(enum vlog_module, enum vlog_level, const char *, va_list)
- __attribute__((format(printf, 3, 0)));
-void vlog_rate_limit(enum vlog_module, enum vlog_level,
- struct vlog_rate_limit *, const char *, ...)
- __attribute__((format(printf, 4, 5)));
-
-/* Convenience macros. To use these, define THIS_MODULE as a macro that
- * expands to the module used by the current source file, e.g.
- * #include "vlog.h"
- * #define THIS_MODULE VLM_netlink
- * Guaranteed to preserve errno.
- */
-#define VLOG_EMER(...) VLOG(VLL_EMER, __VA_ARGS__)
-#define VLOG_ERR(...) VLOG(VLL_ERR, __VA_ARGS__)
-#define VLOG_WARN(...) VLOG(VLL_WARN, __VA_ARGS__)
-#define VLOG_DBG(...) VLOG(VLL_DBG, __VA_ARGS__)
-
-/* More convenience macros, for testing whether a given level is enabled in
- * THIS_MODULE. When constructing a log message is expensive, this enables it
- * to be skipped. */
-#define VLOG_IS_EMER_ENABLED() true
-#define VLOG_IS_ERR_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_EMER)
-#define VLOG_IS_WARN_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_WARN)
-#define VLOG_IS_DBG_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_DBG)
-
-/* Convenience macros. To use these, define THIS_MODULE as a macro that
- * expands to the module used by the current source file, e.g.
- * #include "vlog.h"
- * #define THIS_MODULE VLM_netlink
- * Guaranteed to preserve errno.
- */
-#define VLOG_ERR_RL(RL, ...) \
- vlog_rate_limit(THIS_MODULE, VLL_ERR, RL, __VA_ARGS__)
-#define VLOG_WARN_RL(RL, ...) \
- vlog_rate_limit(THIS_MODULE, VLL_WARN, RL, __VA_ARGS__)
-#define VLOG_DBG_RL(RL, ...) \
- vlog_rate_limit(THIS_MODULE, VLL_DBG, RL, __VA_ARGS__)
-
-/* Command line processing. */
-#define VLOG_OPTION_ENUMS OPT_LOG_FILE
-#define VLOG_LONG_OPTIONS \
- {"verbose", optional_argument, 0, 'v'}, \
- {"log-file", optional_argument, 0, OPT_LOG_FILE}
-#define VLOG_OPTION_HANDLERS \
- case 'v': \
- vlog_set_verbosity(optarg); \
- break; \
- case OPT_LOG_FILE: \
- vlog_set_log_file(optarg); \
- break;
-void vlog_usage(void);
-
-/* Implementation details. */
-#define VLOG(LEVEL, ...) \
- do { \
- if (min_vlog_levels[THIS_MODULE] >= LEVEL) { \
- vlog(THIS_MODULE, LEVEL, __VA_ARGS__); \
- } \
- } while (0)
-extern enum vlog_level min_vlog_levels[VLM_N_MODULES];
-
-
-#endif /* vlog.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 XTOXLL_H
-#define XTOXLL_H 1
-
-#include <arpa/inet.h>
-#include <sys/types.h>
-
-static inline uint64_t
-htonll(uint64_t n)
-{
- return htonl(1) == 1 ? n : ((uint64_t) htonl(n) << 32) | htonl(n >> 32);
-}
-
-static inline uint64_t
-ntohll(uint64_t n)
-{
- return htonl(1) == 1 ? n : ((uint64_t) ntohl(n) << 32) | ntohl(n >> 32);
-}
-
-#endif /* xtoxll.h */
lib_libopenflow_a_SOURCES = \
lib/command-line.c \
+ lib/command-line.h \
+ lib/compiler.h \
lib/csum.c \
+ lib/csum.h \
lib/daemon.c \
+ lib/daemon.h \
lib/dhcp-client.c \
+ lib/dhcp-client.h \
lib/dhcp.c \
+ lib/dhcp.h \
+ lib/dhparams.h \
+ lib/dirs.c \
+ lib/dirs.h \
lib/dynamic-string.c \
+ lib/dynamic-string.h \
lib/fatal-signal.c \
+ lib/fatal-signal.h \
lib/fault.c \
+ lib/fault.h \
lib/flow.c \
+ lib/flow.h \
lib/hash.c \
+ lib/hash.h \
lib/learning-switch.c \
+ lib/learning-switch.h \
lib/list.c \
+ lib/list.h \
lib/mac-learning.c \
+ lib/mac-learning.h \
lib/netdev.c \
- lib/ofpbuf.c \
+ lib/netdev.h \
lib/ofp-print.c \
+ lib/ofp-print.h \
+ lib/ofpbuf.c \
+ lib/ofpbuf.h \
+ lib/packets.h \
lib/poll-loop.c \
+ lib/poll-loop.h \
lib/port-array.c \
+ lib/port-array.h \
lib/queue.c \
+ lib/queue.h \
lib/random.c \
+ lib/random.h \
lib/rconn.c \
+ lib/rconn.h \
+ lib/sat-math.h \
lib/socket-util.c \
- lib/timeval.c \
+ lib/socket-util.h \
lib/stp.c \
+ lib/stp.h \
+ lib/timeval.c \
+ lib/timeval.h \
+ lib/type-props.h \
lib/util.c \
+ lib/util.h \
+ lib/vconn-provider.h \
+ lib/vconn-ssl.h \
+ lib/vconn-stream.c \
+ lib/vconn-stream.h \
lib/vconn-tcp.c \
lib/vconn-unix.c \
- lib/vconn-stream.c \
lib/vconn.c \
+ lib/vconn.h \
+ lib/vlog-modules.def \
lib/vlog-socket.c \
- lib/dirs.c \
- lib/vlog.c
+ lib/vlog-socket.h \
+ lib/vlog.c \
+ lib/vlog.h \
+ lib/xtoxll.h
if HAVE_NETLINK
lib_libopenflow_a_SOURCES += \
lib/dpif.c \
+ lib/dpif.h \
+ lib/netlink-protocol.h \
lib/netlink.c \
+ lib/netlink.h \
lib/vconn-netlink.c
endif
--- /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 COMMAND_LINE_H
+#define COMMAND_LINE_H 1
+
+/* Utilities for command-line parsing. */
+
+struct option;
+char *long_options_to_short_options(const struct option *options);
+
+#endif /* command-line.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 COMPILER_H
+#define COMPILER_H 1
+
+#define NO_RETURN __attribute__((__noreturn__))
+#define UNUSED __attribute__((__unused__))
+#define PACKED __attribute__((__packed__))
+#define PRINTF_FORMAT(FMT, ARG1) __attribute__((__format__(printf, FMT, ARG1)))
+#define STRFTIME_FORMAT(FMT) __attribute__((__format__(__strftime__, FMT, 0)))
+#define likely(x) __builtin_expect((x),1)
+#define unlikely(x) __builtin_expect((x),0)
+
+#endif /* compiler.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 CSUM_H
+#define CSUM_H 1
+
+#include <stddef.h>
+#include <stdint.h>
+
+uint16_t csum(const void *, size_t);
+uint32_t csum_add16(uint32_t partial, uint16_t);
+uint32_t csum_add32(uint32_t partial, uint32_t);
+uint32_t csum_continue(uint32_t partial, const void *, size_t);
+uint16_t csum_finish(uint32_t partial);
+uint16_t recalc_csum16(uint16_t old_csum, uint16_t old_u16, uint16_t new_u16);
+uint16_t recalc_csum32(uint16_t old_csum, uint32_t old_u32, uint32_t new_u32);
+
+#endif /* csum.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 DAEMON_H
+#define DAEMON_H 1
+
+#include <stdbool.h>
+#include <sys/types.h>
+
+#define DAEMON_LONG_OPTIONS \
+ {"detach", no_argument, 0, 'D'}, \
+ {"force", no_argument, 0, 'f'}, \
+ {"pidfile", optional_argument, 0, 'P'}
+
+#define DAEMON_OPTION_HANDLERS \
+ case 'D': \
+ set_detach(); \
+ break; \
+ \
+ case 'P': \
+ set_pidfile(optarg); \
+ break; \
+ \
+ case 'f': \
+ ignore_existing_pidfile(); \
+ break;
+
+char *make_pidfile_name(const char *name);
+void set_pidfile(const char *name);
+const char *get_pidfile(void);
+void set_detach(void);
+void daemonize(void);
+void die_if_already_running(void);
+void ignore_existing_pidfile(void);
+void daemon_usage(void);
+pid_t read_pidfile(const char *name);
+
+#endif /* daemon.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 DHCP_CLIENT_H
+#define DHCP_CLIENT_H 1
+
+#include <stdbool.h>
+#include <stdint.h>
+
+struct dhclient;
+struct dhcp_msg;
+struct netdev;
+int dhclient_create(const char *netdev,
+ void (*modify_request)(struct dhcp_msg *, void *aux),
+ bool (*validate_offer)(const struct dhcp_msg *, void *aux),
+ void *aux, struct dhclient **);
+void dhclient_set_max_timeout(struct dhclient *, unsigned int max_timeout);
+void dhclient_destroy(struct dhclient *);
+
+struct netdev *dhclient_get_netdev(struct dhclient *);
+
+void dhclient_init(struct dhclient *, uint32_t requested_ip);
+void dhclient_release(struct dhclient *);
+void dhclient_force_renew(struct dhclient *, int deadline);
+bool dhclient_is_bound(const struct dhclient *);
+bool dhclient_changed(struct dhclient *);
+
+const char *dhclient_get_state(const struct dhclient *);
+unsigned int dhclient_get_state_elapsed(const struct dhclient *);
+unsigned int dhclient_get_lease_remaining(const struct dhclient *);
+
+uint32_t dhclient_get_ip(const struct dhclient *);
+uint32_t dhclient_get_netmask(const struct dhclient *);
+uint32_t dhclient_get_router(const struct dhclient *);
+const struct dhcp_msg *dhclient_get_config(const struct dhclient *);
+
+int dhclient_configure_netdev(struct dhclient *);
+int dhclient_update_resolv_conf(struct dhclient *);
+
+void dhclient_run(struct dhclient *);
+void dhclient_wait(struct dhclient *);
+
+#endif /* dhcp-client.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 DHCP_H
+#define DHCP_H 1
+
+#include <stdint.h>
+#include "packets.h"
+#include "util.h"
+
+struct ds;
+struct ofpbuf;
+
+/* Values for 'op' field. */
+#define DHCP_BOOTREQUEST 1 /* Message sent by DHCP client. */
+#define DHCP_BOOTREPLY 2 /* Message sent by DHCP server. */
+
+/* Bits in 'flags' field. */
+#define DHCP_FLAGS_BROADCAST 0x8000 /* Server must broadcast all replies. */
+#define DHCP_FLAGS_MBZ 0x7fff /* Must be zero. */
+
+/* First four bytes of 'options' field. */
+#define DHCP_OPTS_COOKIE 0x63825363
+
+#define DHCP_HEADER_LEN 236
+struct dhcp_header {
+ uint8_t op; /* DHCP_BOOTREQUEST or DHCP_BOOTREPLY. */
+ uint8_t htype; /* ARP_HRD_ETHERNET (typically). */
+ uint8_t hlen; /* ETH_ADDR_LEN (typically). */
+ uint8_t hops; /* Hop count; set to 0 by client. */
+ uint32_t xid; /* Transaction ID. */
+ uint16_t secs; /* Since client started address acquisition. */
+ uint16_t flags; /* DHCP_FLAGS_*. */
+ uint32_t ciaddr; /* Client IP, if it has a lease for one. */
+ uint32_t yiaddr; /* Client ("your") IP address. */
+ uint32_t siaddr; /* Next server IP address. */
+ uint32_t giaddr; /* Relay agent IP address. */
+ uint8_t chaddr[16]; /* Client hardware address. */
+ char sname[64]; /* Optional server host name. */
+ char file[128]; /* Boot file name. */
+ /* Followed by variable-length options field. */
+};
+BUILD_ASSERT_DECL(DHCP_HEADER_LEN == sizeof(struct dhcp_header));
+
+#define DHCP_ARGS \
+ DHCP_ARG(FIXED, 0) /* Fixed-length option (PAD and END only). */ \
+ DHCP_ARG(IP, 4) /* IP addresses. */ \
+ DHCP_ARG(SECS, 4) /* 32-bit duration in seconds. */ \
+ DHCP_ARG(STRING, 1) /* NVT string, optionally null-terminated. */ \
+ DHCP_ARG(UINT8, 1) /* 8-bit unsigned integer. */ \
+ DHCP_ARG(UINT16, 2) /* 16-bit unsigned integer. */ \
+ DHCP_ARG(UINT32, 4) /* 32-bit unsigned integer. */ \
+ DHCP_ARG(BOOLEAN, 1) /* Boolean octet (0 or 1). */
+
+/* DHCP option argument types. */
+enum dhcp_arg_type {
+#define DHCP_ARG(NAME, SIZE) DHCP_ARG_##NAME,
+ DHCP_ARGS
+#undef DHCP_ARG
+};
+
+#define DHCP_MSGS \
+ DHCP_MSG(DHCPDISCOVER, 1) /* Client->server: What IPs are available? */ \
+ DHCP_MSG(DHCPOFFER, 2) /* Server->client: This IP is available. */ \
+ DHCP_MSG(DHCPREQUEST, 3) /* Client->server: I want that IP. */ \
+ DHCP_MSG(DHCPDECLINE, 4) /* Client->server: That IP is in use!. */ \
+ DHCP_MSG(DHCPACK, 5) /* Server->client: You can have that IP. */ \
+ DHCP_MSG(DHCPNAK, 6) /* Server->client: You can't have that IP. */ \
+ DHCP_MSG(DHCPRELEASE, 7) /* Client->server: I'm done with this IP. */ \
+ DHCP_MSG(DCHPINFORM, 8) /* Client->server: I'm using this IP. */
+
+/* DHCP message type (this is the argument for the DHCP_MSG_TYPE option). */
+enum dhcp_msg_type {
+#define DHCP_MSG(NAME, VALUE) NAME = VALUE,
+ DHCP_MSGS
+#undef DHCP_MSG
+};
+const char *dhcp_type_name(enum dhcp_msg_type);
+
+/* DHCP allows for 256 standardized options and 256 vendor-specific options.
+ * We put them in a single array, with the standard options at the
+ * beginning. */
+#define DHCP_N_OPTIONS 512
+#define DHCP_VENDOR_OFS 256
+
+/* DHCP options. */
+#define DHCP_OPTS \
+ /* arg min max */ \
+ /* name code type args args */ \
+ DHCP_OPT(PAD, 0, FIXED, 0, 0) \
+ DHCP_OPT(END, 255, FIXED, 0, 0) \
+ DHCP_OPT(SUBNET_MASK, 1, IP, 1, 1) \
+ DHCP_OPT(TIME_OFFSET, 2, SECS, 1, 1) \
+ DHCP_OPT(ROUTER, 3, IP, 1, SIZE_MAX) \
+ /* Time Server Option is obsolete. */ \
+ /* Name Server Option is obsolete. */ \
+ DHCP_OPT(DNS_SERVER, 6, IP, 1, SIZE_MAX) \
+ /* Log Server Option is obsolete. */ \
+ /* Cookie Server Option is obsolete. */ \
+ DHCP_OPT(LPR_SERVER, 9, IP, 1, SIZE_MAX) \
+ /* Impress Server Option is obsolete. */ \
+ /* Resource Location Server Option is obsolete. */ \
+ DHCP_OPT(HOST_NAME, 12, STRING, 1, SIZE_MAX) \
+ DHCP_OPT(BOOT_FILE_SIZE, 13, UINT16, 1, 1) \
+ /* Merit Dump File option is obsolete. */ \
+ DHCP_OPT(DOMAIN_NAME, 15, STRING, 1, SIZE_MAX) \
+ /* Swap Server option is obsolete. */ \
+ DHCP_OPT(ROOT_PATH, 17, STRING, 1, SIZE_MAX) \
+ DHCP_OPT(EXTENSIONS_PATH, 18, STRING, 1, SIZE_MAX) \
+ DHCP_OPT(IP_FORWARDING, 19, BOOLEAN, 1, 1) \
+ DHCP_OPT(SOURCE_ROUTING, 20, BOOLEAN, 1, 1) \
+ DHCP_OPT(POLICY_FILTER, 21, IP, 2, SIZE_MAX) \
+ DHCP_OPT(MAX_DGRAM_REASSEMBLY, 22, UINT16, 1, 1) \
+ DHCP_OPT(IP_TTL, 23, UINT8, 1, 1) \
+ DHCP_OPT(PATH_MTU_TIMEOUT, 24, SECS, 1, 1) \
+ DHCP_OPT(PATH_MTU_PLATEAU, 25, UINT16, 2, SIZE_MAX) \
+ DHCP_OPT(MTU, 26, UINT16, 1, 1) \
+ DHCP_OPT(ALL_SUBNETS_ARE_LOCAL, 27, BOOLEAN, 1, 1) \
+ DHCP_OPT(BROADCAST_ADDRESS, 28, IP, 1, 1) \
+ DHCP_OPT(PERFORM_MASK_DISCOVERY, 29, BOOLEAN, 1, 1) \
+ DHCP_OPT(MASK_SUPPLIER, 30, BOOLEAN, 1, 1) \
+ DHCP_OPT(PERFORM_ROUTER_DISCOVERY, 31, BOOLEAN, 1, 1) \
+ DHCP_OPT(ROUTER_SOLICITATION, 32, IP, 1, 1) \
+ DHCP_OPT(STATIC_ROUTE, 33, IP, 2, SIZE_MAX) \
+ /* Trailer Encapsulation Option is obsolete. */ \
+ DHCP_OPT(ARP_CACHE_TIMEOUT, 35, SECS, 1, 1) \
+ DHCP_OPT(ETHERNET_ENCAPSULATION, 36, BOOLEAN, 1, 1) \
+ DHCP_OPT(TCP_TTL, 37, UINT8, 1, 1) \
+ DHCP_OPT(TCP_KEEPALIVE_INTERVAL, 38, SECS, 1, 1) \
+ DHCP_OPT(TCP_KEEPALIVE_GARBAGE, 39, BOOLEAN, 1, 1) \
+ DHCP_OPT(NIS_DOMAIN, 40, STRING, 1, SIZE_MAX) \
+ DHCP_OPT(NIS_SERVERS, 41, IP, 1, SIZE_MAX) \
+ DHCP_OPT(NTP_SERVERS, 42, IP, 1, SIZE_MAX) \
+ DHCP_OPT(VENDOR_SPECIFIC, 43, UINT8, 1, SIZE_MAX) \
+ DHCP_OPT(NETBIOS_NS, 44, IP, 1, SIZE_MAX) \
+ DHCP_OPT(NETBIOS_DDS, 45, IP, 1, SIZE_MAX) \
+ DHCP_OPT(NETBIOS_NODE_TYPE, 46, UINT8, 1, 1) \
+ DHCP_OPT(NETBIOS_SCOPE, 47, STRING, 1, SIZE_MAX) \
+ DHCP_OPT(X_FONT_SERVER, 48, IP, 1, SIZE_MAX) \
+ DHCP_OPT(XDM, 49, IP, 1, SIZE_MAX) \
+ DHCP_OPT(NISPLUS_DOMAIN, 64, STRING, 1, SIZE_MAX) \
+ DHCP_OPT(NISPLUS_SERVERS, 65, IP, 1, SIZE_MAX) \
+ DHCP_OPT(MOBILE_IP_HOME_AGENT, 68, IP, 0, SIZE_MAX) \
+ DHCP_OPT(SMTP_SERVER, 69, IP, 1, SIZE_MAX) \
+ DHCP_OPT(POP3_SERVER, 70, IP, 1, SIZE_MAX) \
+ DHCP_OPT(NNTP_SERVER, 71, IP, 1, SIZE_MAX) \
+ DHCP_OPT(WWW_SERVER, 72, IP, 1, SIZE_MAX) \
+ DHCP_OPT(FINGER_SERVER, 73, IP, 1, SIZE_MAX) \
+ DHCP_OPT(IRC_SERVER, 74, IP, 1, SIZE_MAX) \
+ /* StreetTalk Server Option is obsolete. */ \
+ /* StreetTalk Directory Assistance Server Option is obsolete. */ \
+ DHCP_OPT(REQUESTED_IP, 50, IP, 1, 1) \
+ DHCP_OPT(LEASE_TIME, 51, SECS, 1, 1) \
+ DHCP_OPT(OPTION_OVERLOAD, 52, UINT8, 1, 1) \
+ DHCP_OPT(TFTP_SERVER, 66, STRING, 1, SIZE_MAX) \
+ DHCP_OPT(BOOTFILE_NAME, 67, STRING, 1, SIZE_MAX) \
+ DHCP_OPT(DHCP_MSG_TYPE, 53, UINT8, 1, 1) \
+ DHCP_OPT(SERVER_IDENTIFIER, 54, IP, 1, 1) \
+ DHCP_OPT(PARAMETER_REQUEST_LIST, 55, UINT8, 1, SIZE_MAX) \
+ DHCP_OPT(MESSAGE, 56, STRING, 1, SIZE_MAX) \
+ DHCP_OPT(MAX_DHCP_MSG_SIZE, 57, UINT16, 1, 1) \
+ DHCP_OPT(T1, 58, SECS, 1, 1) \
+ DHCP_OPT(T2, 59, SECS, 1, 1) \
+ DHCP_OPT(VENDOR_CLASS, 60, STRING, 1, SIZE_MAX) \
+ DHCP_OPT(CLIENT_ID, 61, UINT8, 2, SIZE_MAX) \
+ DHCP_VNDOPT(OFP_CONTROLLER_VCONN, 1, STRING, 1, SIZE_MAX) \
+ DHCP_VNDOPT(OFP_PKI_URI, 2, STRING, 1, SIZE_MAX)
+
+/* Shorthand for defining vendor options (used above). */
+#define DHCP_VNDOPT(NAME, CODE, ARG, MIN, MAX) \
+ DHCP_OPT(NAME, (CODE) + DHCP_VENDOR_OFS, ARG, MIN, MAX)
+
+/* DHCP option codes. */
+enum {
+#define DHCP_OPT(NAME, VALUE, ARGTYPE, MIN_ARGS, MAX_ARGS) \
+ DHCP_CODE_##NAME = VALUE,
+DHCP_OPTS
+#undef DHCP_OPT
+};
+
+/* The contents of a DHCP option.
+ *
+ * DHCP options can (rarely) be present but lack content. To represent such an
+ * option, 'n' is 0 and 'data' is non-null (but does not point to anything
+ * useful). */
+struct dhcp_option {
+ size_t n; /* Number of bytes of data. */
+ void *data; /* Data. */
+};
+
+const char *dhcp_option_to_string(const struct dhcp_option *, int code,
+ struct ds *);
+bool dhcp_option_equals(const struct dhcp_option *,
+ const struct dhcp_option *);
+
+/* Abstracted DHCP protocol message, to make them easier to manipulate than
+ * through raw protocol buffers. */
+struct dhcp_msg {
+ /* For use by calling code. */
+ uint8_t op; /* DHCP_BOOTREQUEST or DHCP_BOOTREPLY. */
+ uint32_t xid; /* Transaction ID. */
+ uint16_t secs; /* Since client started address acquisition. */
+ uint16_t flags; /* DHCP_FLAGS_*. */
+ uint32_t ciaddr; /* Client IP, if it has a lease for one. */
+ uint32_t yiaddr; /* Client ("your") IP address. */
+ uint32_t siaddr; /* Next server IP address. */
+ uint32_t giaddr; /* Relay agent IP address. */
+ uint8_t chaddr[ETH_ADDR_LEN]; /* Client hardware address. */
+ enum dhcp_msg_type type; /* DHCP_CODE_DHCP_MSG_TYPE option argument. */
+ struct dhcp_option options[DHCP_N_OPTIONS]; /* Indexed by option code. */
+
+ /* For direct use only by dhcp_msg_*() functions. */
+ uint8_t *data;
+ size_t data_used, data_allocated;
+};
+
+void dhcp_msg_init(struct dhcp_msg *);
+void dhcp_msg_uninit(struct dhcp_msg *);
+void dhcp_msg_copy(struct dhcp_msg *, const struct dhcp_msg *);
+void dhcp_msg_put(struct dhcp_msg *, int code, const void *, size_t);
+void dhcp_msg_put_bool(struct dhcp_msg *, int code, bool);
+void dhcp_msg_put_secs(struct dhcp_msg *, int code, uint32_t);
+void dhcp_msg_put_ip(struct dhcp_msg *, int code, uint32_t);
+void dhcp_msg_put_string(struct dhcp_msg *, int code, const char *);
+void dhcp_msg_put_uint8(struct dhcp_msg *, int code, uint8_t);
+void dhcp_msg_put_uint8_array(struct dhcp_msg *, int code,
+ const uint8_t[], size_t n);
+void dhcp_msg_put_uint16(struct dhcp_msg *, int code, uint16_t);
+void dhcp_msg_put_uint16_array(struct dhcp_msg *, int code,
+ const uint16_t[], size_t n);
+const void *dhcp_msg_get(const struct dhcp_msg *, int code, size_t offset,
+ size_t size);
+bool dhcp_msg_get_bool(const struct dhcp_msg *, int code,
+ size_t offset, bool *);
+bool dhcp_msg_get_secs(const struct dhcp_msg *, int code,
+ size_t offset, uint32_t *);
+bool dhcp_msg_get_ip(const struct dhcp_msg *, int code,
+ size_t offset, uint32_t *);
+char *dhcp_msg_get_string(const struct dhcp_msg *, int code);
+bool dhcp_msg_get_uint8(const struct dhcp_msg *, int code,
+ size_t offset, uint8_t *);
+bool dhcp_msg_get_uint16(const struct dhcp_msg *, int code,
+ size_t offset, uint16_t *);
+const char *dhcp_msg_to_string(const struct dhcp_msg *, bool multiline,
+ struct ds *);
+int dhcp_parse(struct dhcp_msg *, const struct ofpbuf *);
+void dhcp_assemble(const struct dhcp_msg *, struct ofpbuf *);
+
+#endif /* dhcp.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 DIRS_H
+#define DIRS_H 1
+
+extern const char ofp_pkgdatadir[]; /* /usr/local/share/openflow */
+extern const char ofp_rundir[]; /* /usr/local/var/run */
+extern const char ofp_logdir[]; /* /usr/local/var/log */
+
+#endif /* dirs.h */
#include "netlink.h"
#include "netlink-protocol.h"
#include "ofpbuf.h"
-#include "openflow-netlink.h"
-#include "openflow.h"
+#include "openflow/openflow-netlink.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "util.h"
#include "xtoxll.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 DPIF_H
+#define DPIF_H 1
+
+/* Operations for the datapath running in the local kernel. The interface can
+ * generalize to multiple types of local datapaths, but the implementation only
+ * supports the openflow kernel module via netlink. */
+
+#include <stdbool.h>
+#include <stdint.h>
+
+struct ofpbuf;
+struct ofp_match;
+
+/* A datapath interface. Opaque. */
+struct dpif
+{
+ int dp_idx;
+ struct nl_sock *sock;
+};
+
+int dpif_open(int dp_idx, bool subscribe, struct dpif *);
+void dpif_close(struct dpif *);
+int dpif_recv_openflow(struct dpif *, struct ofpbuf **, bool wait);
+int dpif_send_openflow(struct dpif *, struct ofpbuf *, bool wait);
+int dpif_add_dp(struct dpif *);
+int dpif_del_dp(struct dpif *);
+int dpif_add_port(struct dpif *, const char *netdev);
+int dpif_del_port(struct dpif *, const char *netdev);
+
+#endif /* dpif.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 DYNAMIC_STRING_H
+#define DYNAMIC_STRING_H 1
+
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include "compiler.h"
+
+struct tm;
+
+struct ds {
+ char *string; /* Null-terminated string. */
+ size_t length; /* Bytes used, not including null terminator. */
+ size_t allocated; /* Bytes allocated, not including null terminator. */
+};
+
+#define DS_EMPTY_INITIALIZER { NULL, 0, 0 }
+
+void ds_init(struct ds *);
+void ds_clear(struct ds *);
+void ds_truncate(struct ds *, size_t new_length);
+void ds_reserve(struct ds *, size_t min_length);
+char *ds_put_uninit(struct ds *, size_t n);
+void ds_put_char(struct ds *, char);
+void ds_put_char_multiple(struct ds *, char, size_t n);
+void ds_put_cstr(struct ds *, const char *);
+void ds_put_format(struct ds *, const char *, ...) PRINTF_FORMAT(2, 3);
+void ds_put_format_valist(struct ds *, const char *, va_list)
+ PRINTF_FORMAT(2, 0);
+void ds_put_printable(struct ds *, const char *, size_t);
+void ds_put_strftime(struct ds *, const char *, const struct tm *)
+ STRFTIME_FORMAT(2);
+void ds_put_hex_dump(struct ds *ds, const void *buf_, size_t size,
+ uintptr_t ofs, bool ascii);
+char *ds_cstr(struct ds *);
+void ds_destroy(struct ds *);
+
+int ds_last(const struct ds *);
+void ds_chomp(struct ds *, int c);
+
+#endif /* dynamic-string.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 FATAL_SIGNAL_H
+#define FATAL_SIGNAL_H 1
+
+#include <stdbool.h>
+
+/* Basic interface. */
+void fatal_signal_add_hook(void (*)(void *aux), void *aux, bool run_at_exit);
+void fatal_signal_block(void);
+void fatal_signal_unblock(void);
+void fatal_signal_fork(void);
+
+/* Convenience functions for unlinking files upon termination.
+ *
+ * These functions also unlink the files upon normal process termination via
+ * exit(). */
+void fatal_signal_add_file_to_unlink(const char *);
+void fatal_signal_remove_file_to_unlink(const char *);
+
+/* Interface for other code that catches one of our signals and needs to pass
+ * it through. */
+void fatal_signal_handler(int sig_nr);
+
+#endif /* fatal-signal.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 FAULT_H
+#define FAULT_H 1
+
+void register_fault_handlers(void);
+void log_backtrace(void);
+
+#endif /* fault.h */
#include <string.h>
#include "hash.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "vlog.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 FLOW_H
+#define FLOW_H 1
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "util.h"
+
+struct ofpbuf;
+
+/* Identification data for a flow.
+ All fields are in network byte order.
+ In decreasing order by size, so that flow structures can be hashed or
+ compared bytewise. */
+struct flow {
+ uint32_t nw_src; /* IP source address. */
+ uint32_t nw_dst; /* IP destination address. */
+ uint16_t in_port; /* Input switch port. */
+ uint16_t dl_vlan; /* Input VLAN. */
+ uint16_t dl_type; /* Ethernet frame type. */
+ uint16_t tp_src; /* TCP/UDP source port. */
+ uint16_t tp_dst; /* TCP/UDP destination port. */
+ uint8_t dl_src[6]; /* Ethernet source address. */
+ uint8_t dl_dst[6]; /* Ethernet destination address. */
+ uint8_t nw_proto; /* IP protocol. */
+ uint8_t reserved; /* Pad to 32-bit alignment. */
+};
+BUILD_ASSERT_DECL(sizeof (struct flow) == 32);
+
+int flow_extract(struct ofpbuf *, uint16_t in_port, struct flow *);
+void flow_print(FILE *, const struct flow *);
+int flow_compare(const struct flow *, const struct flow *);
+unsigned long int flow_hash(const struct flow *, uint32_t basis);
+
+#endif /* flow.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 HASH_H
+#define HASH_H 1
+
+#include <stddef.h>
+#include <stdint.h>
+
+#define HASH_FNV_BASIS UINT32_C(2166136261)
+#define HASH_FNV_PRIME UINT32_C(16777619)
+
+uint32_t hash_fnv(const void *, size_t, uint32_t basis);
+
+#endif /* hash.h */
#include "mac-learning.h"
#include "ofpbuf.h"
#include "ofp-print.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "queue.h"
#include "rconn.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 LEARNING_SWITCH_H
+#define LEARNING_SWITCH_H 1
+
+#include <stdbool.h>
+
+struct ofpbuf;
+struct rconn;
+
+struct lswitch *lswitch_create(struct rconn *, bool learn_macs, int max_idle);
+void lswitch_run(struct lswitch *, struct rconn *);
+void lswitch_wait(struct lswitch *);
+void lswitch_destroy(struct lswitch *);
+void lswitch_process_packet(struct lswitch *, struct rconn *,
+ const struct ofpbuf *);
+
+
+#endif /* learning-switch.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 LIST_H
+#define LIST_H 1
+
+/* Doubly linked list. */
+
+#include <stdbool.h>
+#include <stddef.h>
+#include "util.h"
+
+/* Doubly linked list head or element. */
+struct list
+ {
+ struct list *prev; /* Previous list element. */
+ struct list *next; /* Next list element. */
+ };
+
+#define LIST_INITIALIZER(LIST) { LIST, LIST }
+
+void list_init(struct list *);
+
+/* List insertion. */
+void list_insert(struct list *, struct list *);
+void list_splice(struct list *before, struct list *first, struct list *last);
+void list_push_front(struct list *, struct list *);
+void list_push_back(struct list *, struct list *);
+void list_replace(struct list *, const struct list *);
+
+/* List removal. */
+struct list *list_remove(struct list *);
+struct list *list_pop_front(struct list *);
+struct list *list_pop_back(struct list *);
+
+/* List elements. */
+struct list *list_front(struct list *);
+struct list *list_back(struct list *);
+
+/* List properties. */
+size_t list_size(const struct list *);
+bool list_is_empty(const struct list *);
+
+#define LIST_FOR_EACH(ITER, STRUCT, MEMBER, LIST) \
+ for (ITER = CONTAINER_OF((LIST)->next, STRUCT, MEMBER); \
+ &(ITER)->MEMBER != (LIST); \
+ ITER = CONTAINER_OF((ITER)->MEMBER.next, STRUCT, MEMBER))
+#define LIST_FOR_EACH_REVERSE(ITER, STRUCT, MEMBER, LIST) \
+ for (ITER = CONTAINER_OF((LIST)->prev, STRUCT, MEMBER); \
+ &(ITER)->MEMBER != (LIST); \
+ ITER = CONTAINER_OF((ITER)->MEMBER.prev, STRUCT, MEMBER))
+#define LIST_FOR_EACH_SAFE(ITER, NEXT, STRUCT, MEMBER, LIST) \
+ for (ITER = CONTAINER_OF((LIST)->next, STRUCT, MEMBER); \
+ (NEXT = CONTAINER_OF((ITER)->MEMBER.next, STRUCT, MEMBER), \
+ &(ITER)->MEMBER != (LIST)); \
+ ITER = NEXT)
+
+#endif /* list.h */
#include "hash.h"
#include "list.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "timeval.h"
#include "util.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_LEARNING_H
+#define MAC_LEARNING_H 1
+
+#include "packets.h"
+
+struct mac_learning *mac_learning_create(void);
+void mac_learning_destroy(struct mac_learning *);
+bool mac_learning_learn(struct mac_learning *,
+ const uint8_t src[ETH_ADDR_LEN], uint16_t src_port);
+uint16_t mac_learning_lookup(const struct mac_learning *,
+ const uint8_t dst[ETH_ADDR_LEN]);
+
+#endif /* mac-learning.h */
#include "fatal-signal.h"
#include "list.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "poll-loop.h"
#include "socket-util.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.
+ */
+
+/* Generic interface to network devices.
+ *
+ * Currently, there is a single implementation of this interface that supports
+ * Linux. The interface should be generic enough to be implementable on other
+ * operating systems as well. */
+
+#ifndef NETDEV_H
+#define NETDEV_H 1
+
+#include <stdbool.h>
+#include <stdint.h>
+
+struct ofpbuf;
+struct in_addr;
+struct in6_addr;
+
+enum netdev_feature_type {
+ NETDEV_FEAT_CURRENT,
+ NETDEV_FEAT_ADVERTISED,
+ NETDEV_FEAT_SUPPORTED,
+ NETDEV_FEAT_PEER
+};
+
+enum netdev_flags {
+ NETDEV_UP = 0x0001, /* Device enabled? */
+ NETDEV_PROMISC = 0x0002 /* Promiscuous mode? */
+};
+
+enum netdev_pseudo_ethertype {
+ NETDEV_ETH_TYPE_NONE = -128, /* Receive no frames. */
+ NETDEV_ETH_TYPE_ANY, /* Receive all frames. */
+ NETDEV_ETH_TYPE_802_2 /* Receive all IEEE 802.2 frames. */
+};
+
+struct netdev;
+
+int netdev_open(const char *name, int ethertype, struct netdev **);
+int netdev_open_tap(const char *name, struct netdev **);
+void netdev_close(struct netdev *);
+
+int netdev_recv(struct netdev *, struct ofpbuf *);
+void netdev_recv_wait(struct netdev *);
+int netdev_drain(struct netdev *);
+int netdev_send(struct netdev *, const struct ofpbuf *);
+int netdev_set_etheraddr(struct netdev *, const uint8_t mac[6]);
+const uint8_t *netdev_get_etheraddr(const struct netdev *);
+const char *netdev_get_name(const struct netdev *);
+int netdev_get_mtu(const struct netdev *);
+int netdev_get_link_status(const struct netdev *);
+uint32_t netdev_get_features(struct netdev *, int);
+bool netdev_get_in4(const struct netdev *, struct in_addr *);
+int netdev_set_in4(struct netdev *, struct in_addr addr, struct in_addr mask);
+int netdev_add_router(struct netdev *, struct in_addr router);
+bool netdev_get_in6(const struct netdev *, struct in6_addr *);
+int netdev_get_flags(const struct netdev *, enum netdev_flags *);
+int netdev_set_flags(struct netdev *, enum netdev_flags, bool permanent);
+int netdev_turn_flags_on(struct netdev *, enum netdev_flags, bool permanent);
+int netdev_turn_flags_off(struct netdev *, enum netdev_flags, bool permanent);
+int netdev_arp_lookup(const struct netdev *, uint32_t ip, uint8_t mac[6]);
+
+#endif /* netdev.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 NETLINK_PROTOCOL_H
+#define NETLINK_PROTOCOL_H 1
+
+/* Netlink protocol definitions.
+ *
+ * These definitions are equivalent to those in the Linux 2.6 kernel headers,
+ * without requiring those headers to be available. */
+
+#include <stdint.h>
+#include <sys/socket.h>
+#include "util.h"
+
+#define NETLINK_GENERIC 16
+
+struct sockaddr_nl {
+ sa_family_t nl_family;
+ unsigned short int nl_pad;
+ uint32_t nl_pid;
+ uint32_t nl_groups;
+};
+BUILD_ASSERT_DECL(sizeof(struct sockaddr_nl) == 12);
+
+/* nlmsg_flags bits. */
+#define NLM_F_REQUEST 0x001
+#define NLM_F_MULTI 0x002
+#define NLM_F_ACK 0x004
+#define NLM_F_ECHO 0x008
+
+#define NLM_F_ROOT 0x100
+#define NLM_F_MATCH 0x200
+#define NLM_F_ATOMIC 0x400
+#define NLM_F_DUMP (NLM_F_ROOT | NLM_F_MATCH)
+
+/* nlmsg_type values. */
+#define NLMSG_NOOP 1
+#define NLMSG_ERROR 2
+#define NLMSG_DONE 3
+#define NLMSG_OVERRUN 4
+
+#define NLMSG_MIN_TYPE 0x10
+
+struct nlmsghdr {
+ uint32_t nlmsg_len;
+ uint16_t nlmsg_type;
+ uint16_t nlmsg_flags;
+ uint32_t nlmsg_seq;
+ uint32_t nlmsg_pid;
+};
+BUILD_ASSERT_DECL(sizeof(struct nlmsghdr) == 16);
+
+#define NLMSG_ALIGNTO 4
+#define NLMSG_ALIGN(SIZE) ROUND_UP(SIZE, NLMSG_ALIGNTO)
+#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
+
+struct nlmsgerr
+{
+ int error;
+ struct nlmsghdr msg;
+};
+BUILD_ASSERT_DECL(sizeof(struct nlmsgerr) == 20);
+
+#define NETLINK_ADD_MEMBERSHIP 1
+#define NETLINK_DROP_MEMBERSHIP 2
+#define NETLINK_PKTINFO 3
+
+struct genlmsghdr {
+ uint8_t cmd;
+ uint8_t version;
+ uint16_t reserved;
+};
+BUILD_ASSERT_DECL(sizeof(struct genlmsghdr) == 4);
+
+#define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr))
+
+struct nlattr {
+ uint16_t nla_len;
+ uint16_t nla_type;
+};
+BUILD_ASSERT_DECL(sizeof(struct nlattr) == 4);
+
+#define NLA_ALIGNTO 4
+#define NLA_ALIGN(SIZE) ROUND_UP(SIZE, NLA_ALIGNTO)
+#define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
+
+#define GENL_MIN_ID NLMSG_MIN_TYPE
+#define GENL_MAX_ID 1023
+
+#define GENL_ID_CTRL NLMSG_MIN_TYPE
+
+enum {
+ CTRL_CMD_UNSPEC,
+ CTRL_CMD_NEWFAMILY,
+ CTRL_CMD_DELFAMILY,
+ CTRL_CMD_GETFAMILY,
+ CTRL_CMD_NEWOPS,
+ CTRL_CMD_DELOPS,
+ CTRL_CMD_GETOPS,
+ __CTRL_CMD_MAX,
+};
+
+#define CTRL_CMD_MAX (__CTRL_CMD_MAX - 1)
+
+enum {
+ CTRL_ATTR_UNSPEC,
+ CTRL_ATTR_FAMILY_ID,
+ CTRL_ATTR_FAMILY_NAME,
+ CTRL_ATTR_VERSION,
+ CTRL_ATTR_HDRSIZE,
+ CTRL_ATTR_MAXATTR,
+ CTRL_ATTR_OPS,
+ __CTRL_ATTR_MAX,
+};
+
+#define CTRL_ATTR_MAX (__CTRL_ATTR_MAX - 1)
+
+enum {
+ CTRL_ATTR_OP_UNSPEC,
+ CTRL_ATTR_OP_ID,
+ CTRL_ATTR_OP_FLAGS,
+ __CTRL_ATTR_OP_MAX,
+};
+
+#define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1)
+
+#endif /* netlink-protocol.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 NETLINK_H
+#define NETLINK_H 1
+
+/* Netlink interface.
+ *
+ * Netlink is a datagram-based network protocol primarily for communication
+ * between user processes and the kernel, and mainly on Linux. Netlink is
+ * specified in RFC 3549, "Linux Netlink as an IP Services Protocol".
+ *
+ * Netlink is not suitable for use in physical networks of heterogeneous
+ * machines because host byte order is used throughout. */
+
+#include <stdbool.h>
+#include <sys/uio.h>
+#include <stdint.h>
+
+struct ofpbuf;
+struct nl_sock;
+struct nlattr;
+
+/* Netlink sockets. */
+
+int nl_sock_create(int protocol, int multicast_group,
+ size_t so_sndbuf, size_t so_rcvbuf,
+ struct nl_sock **);
+void nl_sock_destroy(struct nl_sock *);
+
+int nl_sock_send(struct nl_sock *, const struct ofpbuf *, bool wait);
+int nl_sock_sendv(struct nl_sock *sock, const struct iovec iov[], size_t n_iov,
+ bool wait);
+int nl_sock_recv(struct nl_sock *, struct ofpbuf **, bool wait);
+int nl_sock_transact(struct nl_sock *, const struct ofpbuf *request,
+ struct ofpbuf **reply);
+
+int nl_sock_fd(const struct nl_sock *);
+\f
+/* Netlink messages. */
+
+/* Accessing headers and data. */
+struct nlmsghdr *nl_msg_nlmsghdr(const struct ofpbuf *);
+struct genlmsghdr *nl_msg_genlmsghdr(const struct ofpbuf *);
+bool nl_msg_nlmsgerr(const struct ofpbuf *, int *error);
+void nl_msg_reserve(struct ofpbuf *, size_t);
+
+/* Appending headers and raw data. */
+void nl_msg_put_nlmsghdr(struct ofpbuf *, struct nl_sock *,
+ size_t expected_payload,
+ uint32_t type, uint32_t flags);
+void nl_msg_put_genlmsghdr(struct ofpbuf *, struct nl_sock *,
+ size_t expected_payload, int family, uint32_t flags,
+ uint8_t cmd, uint8_t version);
+void nl_msg_put(struct ofpbuf *, const void *, size_t);
+void *nl_msg_put_uninit(struct ofpbuf *, size_t);
+
+/* Appending attributes. */
+void *nl_msg_put_unspec_uninit(struct ofpbuf *, uint16_t type, size_t);
+void nl_msg_put_unspec(struct ofpbuf *, uint16_t type, const void *, size_t);
+void nl_msg_put_flag(struct ofpbuf *, uint16_t type);
+void nl_msg_put_u8(struct ofpbuf *, uint16_t type, uint8_t value);
+void nl_msg_put_u16(struct ofpbuf *, uint16_t type, uint16_t value);
+void nl_msg_put_u32(struct ofpbuf *, uint16_t type, uint32_t value);
+void nl_msg_put_u64(struct ofpbuf *, uint16_t type, uint64_t value);
+void nl_msg_put_string(struct ofpbuf *, uint16_t type, const char *value);
+void nl_msg_put_nested(struct ofpbuf *, uint16_t type, struct ofpbuf *);
+\f
+/* Netlink attribute types. */
+enum nl_attr_type
+{
+ NL_A_NO_ATTR = 0,
+ NL_A_UNSPEC,
+ NL_A_U8,
+ NL_A_U16,
+ NL_A_U32,
+ NL_A_U64,
+ NL_A_STRING,
+ NL_A_FLAG,
+ NL_A_NESTED,
+ N_NL_ATTR_TYPES
+};
+
+/* Netlink attribute parsing. */
+const void* nl_attr_get(const struct nlattr *);
+size_t nl_attr_get_size(const struct nlattr *);
+const void* nl_attr_get_unspec(const struct nlattr *, size_t size);
+bool nl_attr_get_flag(const struct nlattr *);
+uint8_t nl_attr_get_u8(const struct nlattr *);
+uint16_t nl_attr_get_u16(const struct nlattr *);
+uint32_t nl_attr_get_u32(const struct nlattr *);
+uint64_t nl_attr_get_u64(const struct nlattr *);
+const char *nl_attr_get_string(const struct nlattr *);
+
+/* Netlink attribute policy.
+ *
+ * Specifies how to parse a single attribute from a Netlink message payload.
+ *
+ * See Nl_policy for example.
+ */
+struct nl_policy
+{
+ enum nl_attr_type type;
+ size_t min_len, max_len;
+ bool optional;
+};
+
+bool nl_policy_parse(const struct ofpbuf *, const struct nl_policy[],
+ struct nlattr *[], size_t n_attrs);
+\f
+/* Miscellaneous. */
+
+int nl_lookup_genl_family(const char *name, int *number);
+
+#endif /* netlink.h */
#include "dynamic-string.h"
#include "flow.h"
#include "ofpbuf.h"
-#include "openflow.h"
-#include "nicira-ext.h"
+#include "openflow/openflow.h"
+#include "openflow/nicira-ext.h"
#include "packets.h"
#include "util.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.
+ */
+
+/* OpenFlow protocol pretty-printer. */
+
+#ifndef __OFP_PRINT_H__
+#define __OFP_ORINT_H __1
+
+#include <stdio.h>
+
+struct ofp_flow_mod;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void ofp_print(FILE *, const void *, size_t, int verbosity);
+void ofp_print_packet(FILE *stream, const void *data, size_t len, size_t total_len);
+
+char *ofp_to_string(const void *, size_t, int verbosity);
+char *ofp_packet_to_string(const void *data, size_t len, size_t total_len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ofppp.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 OFPBUF_H
+#define OFPBUF_H 1
+
+#include <stddef.h>
+
+/* Buffer for holding arbitrary data. An ofpbuf is automatically reallocated
+ * as necessary if it grows too large for the available memory. */
+struct ofpbuf {
+ void *base; /* First byte of area malloc()'d area. */
+ size_t allocated; /* Number of bytes allocated. */
+
+ void *data; /* First byte actually in use. */
+ size_t size; /* Number of bytes in use. */
+
+ void *l2; /* Link-level header. */
+ void *l3; /* Network-level header. */
+ void *l4; /* Transport-level header. */
+ void *l7; /* Application data. */
+
+ struct ofpbuf *next; /* Next in a list of ofpbufs. */
+ void *private; /* Private pointer for use by owner. */
+};
+
+void ofpbuf_use(struct ofpbuf *, void *, size_t);
+
+void ofpbuf_init(struct ofpbuf *, size_t);
+void ofpbuf_uninit(struct ofpbuf *);
+void ofpbuf_reinit(struct ofpbuf *, size_t);
+
+struct ofpbuf *ofpbuf_new(size_t);
+struct ofpbuf *ofpbuf_clone(const struct ofpbuf *);
+void ofpbuf_delete(struct ofpbuf *);
+
+void *ofpbuf_at(const struct ofpbuf *, size_t offset, size_t size);
+void *ofpbuf_at_assert(const struct ofpbuf *, size_t offset, size_t size);
+void *ofpbuf_tail(const struct ofpbuf *);
+void *ofpbuf_end(const struct ofpbuf *);
+
+void *ofpbuf_put_uninit(struct ofpbuf *, size_t);
+void *ofpbuf_put_zeros(struct ofpbuf *, size_t);
+void *ofpbuf_put(struct ofpbuf *, const void *, size_t);
+void ofpbuf_reserve(struct ofpbuf *, size_t);
+void *ofpbuf_push_uninit(struct ofpbuf *b, size_t);
+void *ofpbuf_push(struct ofpbuf *b, const void *, size_t);
+
+size_t ofpbuf_headroom(struct ofpbuf *);
+size_t ofpbuf_tailroom(struct ofpbuf *);
+void ofpbuf_prealloc_headroom(struct ofpbuf *, size_t);
+void ofpbuf_prealloc_tailroom(struct ofpbuf *, size_t);
+
+void ofpbuf_clear(struct ofpbuf *);
+void *ofpbuf_pull(struct ofpbuf *, size_t);
+void *ofpbuf_try_pull(struct ofpbuf *, size_t);
+
+#endif /* ofpbuf.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 PACKETS_H
+#define PACKETS_H 1
+
+#include <stdint.h>
+#include <string.h>
+#include "compiler.h"
+#include "random.h"
+#include "util.h"
+
+#define ETH_ADDR_LEN 6
+
+static const uint8_t eth_addr_broadcast[ETH_ADDR_LEN] UNUSED
+ = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+
+static inline bool eth_addr_is_broadcast(const uint8_t ea[6])
+{
+ 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])
+{
+ return ea[0] & 1;
+}
+static inline bool eth_addr_is_local(const uint8_t ea[6])
+{
+ return ea[0] & 2;
+}
+static inline bool eth_addr_is_zero(const uint8_t ea[6])
+{
+ return !(ea[0] | ea[1] | ea[2] | ea[3] | ea[4] | ea[5]);
+}
+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);
+}
+static inline uint64_t eth_addr_to_uint64(const uint8_t ea[ETH_ADDR_LEN])
+{
+ return (((uint64_t) ea[0] << 40)
+ | ((uint64_t) ea[1] << 32)
+ | ((uint64_t) ea[2] << 24)
+ | ((uint64_t) ea[3] << 16)
+ | ((uint64_t) ea[4] << 8)
+ | ea[5]);
+}
+static inline void eth_addr_from_uint64(uint64_t x, uint8_t ea[ETH_ADDR_LEN])
+{
+ ea[0] = x >> 40;
+ ea[1] = x >> 32;
+ ea[2] = x >> 24;
+ ea[3] = x >> 16;
+ ea[4] = x >> 8;
+ ea[5] = x;
+}
+static inline void eth_addr_random(uint8_t ea[ETH_ADDR_LEN])
+{
+ random_bytes(ea, ETH_ADDR_LEN);
+ ea[0] &= ~1; /* Unicast. */
+ ea[0] |= 2; /* Private. */
+}
+
+#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
+#define ETH_TYPE_VLAN 0x8100
+
+#define ETH_HEADER_LEN 14
+#define ETH_PAYLOAD_MIN 46
+#define ETH_PAYLOAD_MAX 1500
+#define ETH_TOTAL_MIN (ETH_HEADER_LEN + ETH_PAYLOAD_MIN)
+#define ETH_TOTAL_MAX (ETH_HEADER_LEN + ETH_PAYLOAD_MAX)
+#define ETH_VLAN_TOTAL_MAX (ETH_HEADER_LEN + VLAN_HEADER_LEN + ETH_PAYLOAD_MAX)
+struct eth_header {
+ uint8_t eth_dst[ETH_ADDR_LEN];
+ uint8_t eth_src[ETH_ADDR_LEN];
+ uint16_t eth_type;
+} __attribute__((packed));
+BUILD_ASSERT_DECL(ETH_HEADER_LEN == sizeof(struct eth_header));
+
+#define LLC_DSAP_SNAP 0xaa
+#define LLC_SSAP_SNAP 0xaa
+#define LLC_CNTL_SNAP 3
+
+#define LLC_HEADER_LEN 3
+struct llc_header {
+ uint8_t llc_dsap;
+ uint8_t llc_ssap;
+ uint8_t llc_cntl;
+} __attribute__((packed));
+BUILD_ASSERT_DECL(LLC_HEADER_LEN == sizeof(struct llc_header));
+
+#define SNAP_ORG_ETHERNET "\0\0" /* The compiler adds a null byte, so
+ sizeof(SNAP_ORG_ETHERNET) == 3. */
+#define SNAP_HEADER_LEN 5
+struct snap_header {
+ uint8_t snap_org[3];
+ uint16_t snap_type;
+} __attribute__((packed));
+BUILD_ASSERT_DECL(SNAP_HEADER_LEN == sizeof(struct snap_header));
+
+#define LLC_SNAP_HEADER_LEN (LLC_HEADER_LEN + SNAP_HEADER_LEN)
+struct llc_snap_header {
+ struct llc_header llc;
+ struct snap_header snap;
+} __attribute__((packed));
+BUILD_ASSERT_DECL(LLC_SNAP_HEADER_LEN == sizeof(struct llc_snap_header));
+
+#define VLAN_VID_MASK 0x0fff
+#define VLAN_PCP_MASK 0xe000
+
+#define VLAN_HEADER_LEN 4
+struct vlan_header {
+ uint16_t vlan_tci; /* Lowest 12 bits are VLAN ID. */
+ uint16_t vlan_next_type;
+};
+BUILD_ASSERT_DECL(VLAN_HEADER_LEN == sizeof(struct vlan_header));
+
+#define VLAN_ETH_HEADER_LEN (ETH_HEADER_LEN + VLAN_HEADER_LEN)
+struct vlan_eth_header {
+ uint8_t veth_dst[ETH_ADDR_LEN];
+ uint8_t veth_src[ETH_ADDR_LEN];
+ uint16_t veth_type; /* Always htons(ETH_TYPE_VLAN). */
+ uint16_t veth_tci; /* Lowest 12 bits are VLAN ID. */
+ uint16_t veth_next_type;
+} __attribute__((packed));
+BUILD_ASSERT_DECL(VLAN_ETH_HEADER_LEN == sizeof(struct vlan_eth_header));
+
+#define IP_FMT "%"PRIu8".%"PRIu8".%"PRIu8".%"PRIu8
+#define IP_ARGS(ip) \
+ ((uint8_t *) ip)[0], \
+ ((uint8_t *) ip)[1], \
+ ((uint8_t *) ip)[2], \
+ ((uint8_t *) ip)[3]
+
+#define IP_VER(ip_ihl_ver) ((ip_ihl_ver) >> 4)
+#define IP_IHL(ip_ihl_ver) ((ip_ihl_ver) & 15)
+#define IP_IHL_VER(ihl, ver) (((ver) << 4) | (ihl))
+
+#define IP_TYPE_ICMP 1
+#define IP_TYPE_TCP 6
+#define IP_TYPE_UDP 17
+
+#define IP_VERSION 4
+
+#define IP_DONT_FRAGMENT 0x4000 /* Don't fragment. */
+#define IP_MORE_FRAGMENTS 0x2000 /* More fragments. */
+#define IP_FRAG_OFF_MASK 0x1fff /* Fragment offset. */
+#define IP_IS_FRAGMENT(ip_frag_off) \
+ ((ip_frag_off) & htons(IP_MORE_FRAGMENTS | IP_FRAG_OFF_MASK))
+
+#define IP_HEADER_LEN 20
+struct ip_header {
+ uint8_t ip_ihl_ver;
+ uint8_t ip_tos;
+ uint16_t ip_tot_len;
+ uint16_t ip_id;
+ uint16_t ip_frag_off;
+ uint8_t ip_ttl;
+ uint8_t ip_proto;
+ uint16_t ip_csum;
+ uint32_t ip_src;
+ uint32_t ip_dst;
+};
+BUILD_ASSERT_DECL(IP_HEADER_LEN == sizeof(struct ip_header));
+
+#define UDP_HEADER_LEN 8
+struct udp_header {
+ uint16_t udp_src;
+ uint16_t udp_dst;
+ uint16_t udp_len;
+ uint16_t udp_csum;
+};
+BUILD_ASSERT_DECL(UDP_HEADER_LEN == sizeof(struct udp_header));
+
+#define TCP_FIN 0x01
+#define TCP_SYN 0x02
+#define TCP_RST 0x04
+#define TCP_PSH 0x08
+#define TCP_ACK 0x10
+#define TCP_URG 0x20
+
+#define TCP_FLAGS(tcp_ctl) (htons(tcp_ctl) & 0x003f)
+#define TCP_OFFSET(tcp_ctl) (htons(tcp_ctl) >> 12)
+
+#define TCP_HEADER_LEN 20
+struct tcp_header {
+ uint16_t tcp_src;
+ uint16_t tcp_dst;
+ uint32_t tcp_seq;
+ uint32_t tcp_ack;
+ uint16_t tcp_ctl;
+ uint16_t tcp_winsz;
+ uint16_t tcp_csum;
+ uint16_t tcp_urg;
+};
+BUILD_ASSERT_DECL(TCP_HEADER_LEN == sizeof(struct tcp_header));
+
+#define ARP_HRD_ETHERNET 1
+#define ARP_PRO_IP 0x0800
+#define ARP_OP_REQUEST 1
+#define ARP_OP_REPLY 2
+
+#define ARP_ETH_HEADER_LEN 28
+struct arp_eth_header {
+ /* Generic members. */
+ uint16_t ar_hrd; /* Hardware type. */
+ uint16_t ar_pro; /* Protocol type. */
+ uint8_t ar_hln; /* Hardware address length. */
+ uint8_t ar_pln; /* Protocol address length. */
+ uint16_t ar_op; /* Opcode. */
+
+ /* Ethernet+IPv4 specific members. */
+ uint8_t ar_sha[ETH_ADDR_LEN]; /* Sender hardware address. */
+ uint32_t ar_spa; /* Sender protocol address. */
+ uint8_t ar_tha[ETH_ADDR_LEN]; /* Target hardware address. */
+ uint32_t ar_tpa; /* Target protocol address. */
+} __attribute__((packed));
+BUILD_ASSERT_DECL(ARP_ETH_HEADER_LEN == sizeof(struct arp_eth_header));
+
+#endif /* packets.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.
+ */
+
+/* High-level wrapper around the "poll" system call.
+ *
+ * Intended usage is for the program's main loop to go about its business
+ * servicing whatever events it needs to. Then, when it runs out of immediate
+ * tasks, it calls each subordinate module's "wait" function, which in turn
+ * calls one (or more) of the functions poll_fd_wait(), poll_immediate_wake(),
+ * and poll_timer_wait() to register to be awakened when the appropriate event
+ * occurs. Then the main loop calls poll_block(), which blocks until one of
+ * the registered events happens.
+ *
+ * There is also some support for autonomous subroutines that are executed by
+ * poll_block() when a file descriptor becomes ready. To prevent these
+ * routines from starving if events are continuously ready, the application
+ * should bound the amount of work it does between poll_block() calls. */
+
+#ifndef POLL_LOOP_H
+#define POLL_LOOP_H 1
+
+#include <poll.h>
+
+struct poll_waiter;
+
+/* Schedule events to wake up the following poll_block(). */
+struct poll_waiter *poll_fd_wait(int fd, short int events);
+void poll_timer_wait(int msec);
+void poll_immediate_wake(void);
+
+/* Wait until an event occurs. */
+void poll_block(void);
+
+/* Autonomous function callbacks. */
+typedef void poll_fd_func(int fd, short int revents, void *aux);
+struct poll_waiter *poll_fd_callback(int fd, short int events,
+ poll_fd_func *, void *aux);
+
+/* Cancel a file descriptor callback or event. */
+void poll_cancel(struct poll_waiter *);
+
+#endif /* poll-loop.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 PORT_ARRAY_H
+#define PORT_ARRAY_H 1
+
+#include <assert.h>
+#include "openflow/openflow.h"
+#include "util.h"
+
+static inline uint16_t
+port_array_extract_bits__(uint16_t data, int start, int count)
+{
+ return (data >> start) & ((1u << count) - 1);
+}
+
+/* Level 1: most-significant bits. */
+#define PORT_ARRAY_L1_BITS 5
+#define PORT_ARRAY_L1_SHIFT (PORT_ARRAY_L3_BITS + PORT_ARRAY_L2_BITS)
+#define PORT_ARRAY_L1_SIZE (1u << PORT_ARRAY_L1_BITS)
+#define PORT_ARRAY_L1(IDX) \
+ port_array_extract_bits__(IDX, PORT_ARRAY_L1_SHIFT, PORT_ARRAY_L1_BITS)
+
+/* Level 2: middle bits. */
+#define PORT_ARRAY_L2_BITS 5
+#define PORT_ARRAY_L2_SHIFT PORT_ARRAY_L3_BITS
+#define PORT_ARRAY_L2_SIZE (1u << PORT_ARRAY_L2_BITS)
+#define PORT_ARRAY_L2(IDX) \
+ port_array_extract_bits__(IDX, PORT_ARRAY_L2_SHIFT, PORT_ARRAY_L2_BITS)
+
+/* Level 3: least-significant bits. */
+#define PORT_ARRAY_L3_BITS 6
+#define PORT_ARRAY_L3_SHIFT 0
+#define PORT_ARRAY_L3_SIZE (1u << PORT_ARRAY_L3_BITS)
+#define PORT_ARRAY_L3(IDX) \
+ port_array_extract_bits__(IDX, PORT_ARRAY_L3_SHIFT, PORT_ARRAY_L3_BITS)
+
+#define PORT_ARRAY_SIZE (1u << (PORT_ARRAY_L1_BITS \
+ + PORT_ARRAY_L2_BITS \
+ + PORT_ARRAY_L3_BITS))
+
+BUILD_ASSERT_DECL(PORT_ARRAY_SIZE > 0xffff);
+
+/* A "sparse array" of up to 65536 elements (numbered 0...65535), implemented
+ * as a 3-level trie. Most efficient when the elements are clustered
+ * together. */
+struct port_array {
+ struct port_array_l2 *l1[1u << PORT_ARRAY_L1_BITS];
+};
+
+struct port_array_l2 {
+ struct port_array_l3 *l2[1u << PORT_ARRAY_L2_BITS];
+};
+
+struct port_array_l3 {
+ void *l3[1u << PORT_ARRAY_L3_BITS];
+};
+
+/* Returns the value of the element numbered 'idx' in 'pa', or a null pointer
+ * if no element numbered 'idx' has been set. */
+static inline void *
+port_array_get(const struct port_array *pa, uint16_t idx)
+{
+ unsigned int l1_idx = PORT_ARRAY_L1(idx);
+ unsigned int l2_idx = PORT_ARRAY_L2(idx);
+ unsigned int l3_idx = PORT_ARRAY_L3(idx);
+ return pa->l1[l1_idx]->l2[l2_idx]->l3[l3_idx];
+}
+
+void port_array_init(struct port_array *);
+void port_array_destroy(struct port_array *);
+void port_array_set(struct port_array *, uint16_t idx, void *);
+void *port_array_first(const struct port_array *, unsigned int *);
+void *port_array_next(const struct port_array *, unsigned int *);
+
+#endif /* port-array.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 QUEUE_H
+#define QUEUE_H 1
+
+/* Packet queue. */
+struct ofp_queue {
+ int n; /* Number of queued packets. */
+ struct ofpbuf *head; /* First queued packet, null if n == 0. */
+ struct ofpbuf *tail; /* Last queued packet, null if n == 0. */
+};
+
+void queue_init(struct ofp_queue *);
+void queue_destroy(struct ofp_queue *);
+void queue_clear(struct ofp_queue *);
+void queue_advance_head(struct ofp_queue *, struct ofpbuf *next);
+void queue_push_tail(struct ofp_queue *, struct ofpbuf *);
+struct ofpbuf *queue_pop_head(struct ofp_queue *);
+
+#endif /* queue.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 RANDOM_H
+#define RANDOM_H 1
+
+#include <stddef.h>
+#include <stdint.h>
+
+void random_bytes(void *, size_t);
+uint32_t random_uint32(void);
+int random_range(int max);
+
+#endif /* random.h */
#include <stdlib.h>
#include <string.h>
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "sat-math.h"
#include "timeval.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 RCONN_H
+#define RCONN_H 1
+
+#include "queue.h"
+#include <stdbool.h>
+#include <stdint.h>
+#include <time.h>
+
+/* A wrapper around vconn that provides queuing and optionally reliability.
+ *
+ * An rconn maintains a message transmission queue of bounded length specified
+ * by the caller. The rconn does not guarantee reliable delivery of
+ * queued messages: all queued messages are dropped when reconnection becomes
+ * necessary.
+ *
+ * An rconn optionally provides reliable communication, in this sense: the
+ * rconn will re-connect, with exponential backoff, when the underlying vconn
+ * disconnects.
+ */
+
+struct vconn;
+
+struct rconn *rconn_new(const char *name,
+ int inactivity_probe_interval, int max_backoff);
+struct rconn *rconn_new_from_vconn(const char *name, struct vconn *);
+struct rconn *rconn_create(int inactivity_probe_interval, int max_backoff);
+int rconn_connect(struct rconn *, const char *name);
+void rconn_connect_unreliably(struct rconn *,
+ const char *name, struct vconn *vconn);
+void rconn_disconnect(struct rconn *);
+void rconn_destroy(struct rconn *);
+
+void rconn_run(struct rconn *);
+void rconn_run_wait(struct rconn *);
+struct ofpbuf *rconn_recv(struct rconn *);
+void rconn_recv_wait(struct rconn *);
+int rconn_send(struct rconn *, struct ofpbuf *, int *n_queued);
+int rconn_send_with_limit(struct rconn *, struct ofpbuf *,
+ int *n_queued, int queue_limit);
+unsigned int rconn_packets_sent(const struct rconn *);
+unsigned int rconn_packets_received(const struct rconn *);
+
+void rconn_add_monitor(struct rconn *, struct vconn *);
+
+const char *rconn_get_name(const struct rconn *);
+bool rconn_is_alive(const struct rconn *);
+bool rconn_is_connected(const struct rconn *);
+int rconn_failure_duration(const struct rconn *);
+bool rconn_is_connectivity_questionable(struct rconn *);
+
+uint32_t rconn_get_ip(const struct rconn *);
+
+const char *rconn_get_state(const struct rconn *);
+unsigned int rconn_get_attempted_connections(const struct rconn *);
+unsigned int rconn_get_successful_connections(const struct rconn *);
+time_t rconn_get_last_connection(const struct rconn *);
+time_t rconn_get_creation_time(const struct rconn *);
+unsigned long int rconn_get_total_time_connected(const struct rconn *);
+int rconn_get_backoff(const struct rconn *);
+unsigned int rconn_get_state_elapsed(const struct rconn *);
+
+#endif /* rconn.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 SAT_MATH_H
+#define SAT_MATH_H 1
+
+#include <assert.h>
+#include <limits.h>
+
+/* Saturating addition: overflow yields UINT_MAX. */
+static inline unsigned int
+sat_add(unsigned int x, unsigned int y)
+{
+ return x + y >= x ? x + y : UINT_MAX;
+}
+
+/* Saturating subtraction: underflow yields 0. */
+static inline unsigned int
+sat_sub(unsigned int x, unsigned int y)
+{
+ return x >= y ? x - y : 0;
+}
+
+/* Saturating multiplication: overflow yields UINT_MAX. */
+static inline unsigned int
+sat_mul(unsigned int x, unsigned int y)
+{
+ return (!y ? 0
+ : x <= UINT_MAX / y ? x * y
+ : UINT_MAX);
+}
+
+#endif /* sat-math.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 SOCKET_UTIL_H
+#define SOCKET_UTIL_H 1
+
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <stdbool.h>
+
+int set_nonblocking(int fd);
+int get_max_fds(void);
+int lookup_ip(const char *host_name, struct in_addr *address);
+int get_socket_error(int sock);
+int check_connection_completion(int fd);
+int drain_rcvbuf(int fd);
+void drain_fd(int fd, size_t n_packets);
+int make_unix_socket(int style, bool nonblock, bool passcred,
+ const char *bind_path, const char *connect_path);
+int get_unix_name_len(socklen_t sun_len);
+
+#endif /* socket-util.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 STP_H
+#define STP_H 1
+
+/* This is an implementation of Spanning Tree Protocol as described in IEEE
+ * 802.1D-1998, clauses 8 and 9. Section numbers refer to this standard. */
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "compiler.h"
+#include "util.h"
+
+/* Ethernet address used as the destination for STP frames. */
+extern const uint8_t stp_eth_addr[6];
+
+/* LLC field values used for STP frames. */
+#define STP_LLC_SSAP 0x42
+#define STP_LLC_DSAP 0x42
+#define STP_LLC_CNTL 0x03
+
+/* Bridge identifier. Top 16 bits are a priority value (numerically lower
+ * values are higher priorities). Bottom 48 bits are MAC address of bridge. */
+typedef uint64_t stp_identifier;
+
+/* Basic STP functionality. */
+#define STP_MAX_PORTS 255
+struct stp *stp_create(const char *name, stp_identifier bridge_id,
+ void (*send_bpdu)(const void *bpdu, size_t bpdu_size,
+ int port_no, void *aux),
+ void *aux);
+void stp_destroy(struct stp *);
+void stp_tick(struct stp *, int elapsed);
+void stp_set_bridge_id(struct stp *, stp_identifier bridge_id);
+void stp_set_bridge_priority(struct stp *, uint16_t new_priority);
+
+/* STP properties. */
+const char *stp_get_name(const struct stp *);
+stp_identifier stp_get_bridge_id(const struct stp *);
+stp_identifier stp_get_designated_root(const struct stp *);
+bool stp_is_root_bridge(const struct stp *);
+int stp_get_root_path_cost(const struct stp *);
+
+/* Obtaining STP ports. */
+struct stp_port *stp_get_port(struct stp *, int port_no);
+struct stp_port *stp_get_root_port(struct stp *);
+bool stp_get_changed_port(struct stp *, struct stp_port **portp);
+
+/* State of an STP port.
+ *
+ * A port is in exactly one state at any given time, but distinct bits are used
+ * for states to allow testing for more than one state with a bit mask. */
+enum stp_state {
+ STP_DISABLED = 1 << 0, /* 8.4.5: Disabled by management. */
+ STP_LISTENING = 1 << 1, /* 8.4.2: Not learning or relaying frames. */
+ STP_LEARNING = 1 << 2, /* 8.4.3: Learning but not relaying frames. */
+ STP_FORWARDING = 1 << 3, /* 8.4.4: Learning and relaying frames. */
+ STP_BLOCKING = 1 << 4 /* 8.4.1: Initial boot state. */
+};
+const char *stp_state_name(enum stp_state);
+bool stp_forward_in_state(enum stp_state);
+bool stp_learn_in_state(enum stp_state);
+
+void stp_received_bpdu(struct stp_port *, const void *bpdu, size_t bpdu_size);
+
+struct stp *stp_port_get_stp(struct stp_port *);
+int stp_port_no(const struct stp_port *);
+enum stp_state stp_port_get_state(const struct stp_port *);
+void stp_port_enable(struct stp_port *);
+void stp_port_disable(struct stp_port *);
+void stp_port_set_priority(struct stp_port *, uint8_t new_priority);
+void stp_port_set_path_cost(struct stp_port *, unsigned int path_cost);
+void stp_port_set_speed(struct stp_port *, unsigned int speed);
+void stp_port_enable_change_detection(struct stp_port *);
+void stp_port_disable_change_detection(struct stp_port *);
+
+#endif /* stp.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 TIMEVAL_H
+#define TIMEVAL_H 1
+
+#include <time.h>
+#include "type-props.h"
+#include "util.h"
+
+struct pollfd;
+
+/* POSIX allows floating-point time_t, but we don't support it. */
+BUILD_ASSERT_DECL(TYPE_IS_INTEGER(time_t));
+
+/* We do try to cater to unsigned time_t, but I want to know about it if we
+ * ever encounter such a platform. */
+BUILD_ASSERT_DECL(TYPE_IS_SIGNED(time_t));
+
+#define TIME_MAX TYPE_MAXIMUM(time_t)
+#define TIME_MIN TYPE_MINIMUM(time_t)
+
+/* Interval between updates to the time reported by time_gettimeofday(), in ms.
+ * This should not be adjusted much below 10 ms or so with the current
+ * implementation, or too much time will be wasted in signal handlers and calls
+ * to time(0). */
+#define TIME_UPDATE_INTERVAL 100
+
+void time_init(void);
+void time_refresh(void);
+time_t time_now(void);
+long long int time_msec(void);
+void time_alarm(unsigned int secs);
+int time_poll(struct pollfd *, int n_pollfds, int timeout);
+
+#endif /* timeval.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 TYPE_PROPS_H
+#define TYPE_PROPS_H 1
+
+#include <limits.h>
+
+#define TYPE_IS_INTEGER(TYPE) ((TYPE) 1.5 == (TYPE) 1)
+#define TYPE_IS_SIGNED(TYPE) ((TYPE) 0 > (TYPE) -1)
+#define TYPE_VALUE_BITS(TYPE) (sizeof(TYPE) * CHAR_BIT - TYPE_IS_SIGNED(TYPE))
+#define TYPE_MINIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \
+ ? ~(TYPE)0 << TYPE_VALUE_BITS(TYPE) \
+ : 0)
+#define TYPE_MAXIMUM(TYPE) (TYPE_IS_SIGNED(TYPE) \
+ ? ~(~(TYPE)0 << TYPE_VALUE_BITS(TYPE)) \
+ : (TYPE)-1)
+
+#endif /* type-props.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 UTIL_H
+#define UTIL_H 1
+
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include "compiler.h"
+
+#ifndef va_copy
+#ifdef __va_copy
+#define va_copy __va_copy
+#else
+#define va_copy(dst, src) ((dst) = (src))
+#endif
+#endif
+
+#ifndef __cplusplus
+/* Build-time assertion for use in a statement context. */
+#define BUILD_ASSERT(EXPR) \
+ sizeof(struct { unsigned int build_assert_failed : (EXPR) ? 1 : -1; })
+
+/* Build-time assertion for use in a declaration context. */
+#define BUILD_ASSERT_DECL(EXPR) \
+ extern int (*build_assert(void))[BUILD_ASSERT(EXPR)]
+#else /* __cplusplus */
+#include <boost/static_assert.hpp>
+#define BUILD_ASSERT BOOST_STATIC_ASSERT
+#define BUILD_ASSERT_DECL BOOST_STATIC_ASSERT
+#endif /* __cplusplus */
+
+extern const char *program_name;
+
+#define ARRAY_SIZE(ARRAY) (sizeof ARRAY / sizeof *ARRAY)
+#define ROUND_UP(X, Y) (((X) + ((Y) - 1)) / (Y) * (Y))
+#define ROUND_DOWN(X, Y) ((X) / (Y) * (Y))
+
+#ifndef MIN
+#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
+#endif
+
+#ifndef MAX
+#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
+#endif
+
+#define NOT_REACHED() abort()
+#define NOT_IMPLEMENTED() abort()
+#define NOT_TESTED() ((void) 0) /* XXX should print a message. */
+
+/* Given POINTER, the address of the given MEMBER in a STRUCT object, returns
+ the STRUCT object. */
+#define CONTAINER_OF(POINTER, STRUCT, MEMBER) \
+ ((STRUCT *) ((char *) (POINTER) - offsetof (STRUCT, MEMBER)))
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void set_program_name(const char *);
+
+void out_of_memory(void);
+void *xmalloc(size_t);
+void *xcalloc(size_t, size_t);
+void *xrealloc(void *, size_t);
+void *xmemdup(const void *, size_t);
+char *xmemdup0(const char *, size_t);
+char *xstrdup(const char *);
+char *xasprintf(const char *format, ...) PRINTF_FORMAT(1, 2);
+char *xvasprintf(const char *format, va_list) PRINTF_FORMAT(1, 0);
+
+#ifndef HAVE_STRLCPY
+void strlcpy(char *dst, const char *src, size_t size);
+#endif
+
+void ofp_fatal(int err_no, const char *format, ...)
+ PRINTF_FORMAT(2, 3) NO_RETURN;
+void ofp_error(int err_no, const char *format, ...) PRINTF_FORMAT(2, 3);
+void ofp_hex_dump(FILE *, const void *, size_t, uintptr_t offset, bool ascii);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* util.h */
#include "dpif.h"
#include "netlink.h"
#include "ofpbuf.h"
-#include "openflow-netlink.h"
-#include "openflow.h"
+#include "openflow/openflow-netlink.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "socket-util.h"
#include "util.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 VCONN_PROVIDER_H
+#define VCONN_PROVIDER_H 1
+
+/* Provider interface to vconns, which provide a virtual connection to an
+ * OpenFlow device. */
+
+#include <assert.h>
+#include "vconn.h"
+\f
+/* Active virtual connection to an OpenFlow device. */
+
+/* Active virtual connection to an OpenFlow device.
+ *
+ * This structure should be treated as opaque by vconn implementations. */
+struct vconn {
+ struct vconn_class *class;
+ int state;
+ int error;
+ int min_version;
+ int version;
+ uint32_t ip;
+ char *name;
+};
+
+void vconn_init(struct vconn *, struct vconn_class *, int connect_status,
+ uint32_t ip, const char *name);
+static inline void vconn_assert_class(const struct vconn *vconn,
+ const struct vconn_class *class)
+{
+ assert(vconn->class == class);
+}
+
+struct vconn_class {
+ /* Prefix for connection names, e.g. "nl", "tcp". */
+ const char *name;
+
+ /* Attempts to connect to an OpenFlow device. 'name' is the full
+ * connection name provided by the user, e.g. "nl:0", "tcp:1.2.3.4". This
+ * name is useful for error messages but must not be modified.
+ *
+ * 'suffix' is a copy of 'name' following the colon and may be modified.
+ *
+ * Returns 0 if successful, otherwise a positive errno value. If
+ * successful, stores a pointer to the new connection in '*vconnp'.
+ *
+ * The open function must not block waiting for a connection to complete.
+ * If the connection cannot be completed immediately, it should return
+ * EAGAIN (not EINPROGRESS, as returned by the connect system call) and
+ * continue the connection in the background. */
+ int (*open)(const char *name, char *suffix, struct vconn **vconnp);
+
+ /* Closes 'vconn' and frees associated memory. */
+ void (*close)(struct vconn *vconn);
+
+ /* Tries to complete the connection on 'vconn'. If 'vconn''s connection is
+ * complete, returns 0 if the connection was successful or a positive errno
+ * value if it failed. If the connection is still in progress, returns
+ * EAGAIN.
+ *
+ * The connect function must not block waiting for the connection to
+ * complete; instead, it should return EAGAIN immediately. */
+ int (*connect)(struct vconn *vconn);
+
+ /* Tries to receive an OpenFlow message from 'vconn'. If successful,
+ * stores the received message into '*msgp' and returns 0. The caller is
+ * responsible for destroying the message with ofpbuf_delete(). On
+ * failure, returns a positive errno value and stores a null pointer into
+ * '*msgp'.
+ *
+ * If the connection has been closed in the normal fashion, returns EOF.
+ *
+ * The recv function must not block waiting for a packet to arrive. If no
+ * packets have been received, it should return EAGAIN. */
+ int (*recv)(struct vconn *vconn, struct ofpbuf **msgp);
+
+ /* Tries to queue 'msg' for transmission on 'vconn'. If successful,
+ * returns 0, in which case ownership of 'msg' is transferred to the vconn.
+ * Success does not guarantee that 'msg' has been or ever will be delivered
+ * to the peer, only that it has been queued for transmission.
+ *
+ * Returns a positive errno value on failure, in which case the caller
+ * retains ownership of 'msg'.
+ *
+ * The send function must not block. If 'msg' cannot be immediately
+ * accepted for transmission, it should return EAGAIN. */
+ int (*send)(struct vconn *vconn, struct ofpbuf *msg);
+
+ /* Arranges for the poll loop to wake up when 'vconn' is ready to take an
+ * action of the given 'type'. */
+ void (*wait)(struct vconn *vconn, enum vconn_wait_type type);
+};
+\f
+/* Passive virtual connection to an OpenFlow device.
+ *
+ * This structure should be treated as opaque by vconn implementations. */
+struct pvconn {
+ struct pvconn_class *class;
+ char *name;
+};
+
+void pvconn_init(struct pvconn *, struct pvconn_class *, const char *name);
+static inline void pvconn_assert_class(const struct pvconn *pvconn,
+ const struct pvconn_class *class)
+{
+ assert(pvconn->class == class);
+}
+
+struct pvconn_class {
+ /* Prefix for connection names, e.g. "ptcp", "pssl". */
+ const char *name;
+
+ /* Attempts to start listening for OpenFlow connections. 'name' is the
+ * full connection name provided by the user, e.g. "nl:0", "tcp:1.2.3.4".
+ * This name is useful for error messages but must not be modified.
+ *
+ * 'suffix' is a copy of 'name' following the colon and may be modified.
+ *
+ * Returns 0 if successful, otherwise a positive errno value. If
+ * successful, stores a pointer to the new connection in '*pvconnp'.
+ *
+ * The listen function must not block. If the connection cannot be
+ * completed immediately, it should return EAGAIN (not EINPROGRESS, as
+ * returned by the connect system call) and continue the connection in the
+ * background. */
+ int (*listen)(const char *name, char *suffix, struct pvconn **pvconnp);
+
+ /* Closes 'pvconn' and frees associated memory. */
+ void (*close)(struct pvconn *pvconn);
+
+ /* Tries to accept a new connection on 'pvconn'. If successful, stores the
+ * new connection in '*new_vconnp' and returns 0. Otherwise, returns a
+ * positive errno value.
+ *
+ * The accept function must not block waiting for a connection. If no
+ * connection is ready to be accepted, it should return EAGAIN. */
+ int (*accept)(struct pvconn *pvconn, struct vconn **new_vconnp);
+
+ /* Arranges for the poll loop to wake up when a connection is ready to be
+ * accepted on 'pvconn'. */
+ void (*wait)(struct pvconn *pvconn);
+};
+
+/* Active and passive vconn classes. */
+extern struct vconn_class tcp_vconn_class;
+extern struct pvconn_class ptcp_pvconn_class;
+extern struct vconn_class unix_vconn_class;
+extern struct pvconn_class punix_pvconn_class;
+#ifdef HAVE_OPENSSL
+extern struct vconn_class ssl_vconn_class;
+extern struct pvconn_class pssl_pvconn_class;
+#endif
+#ifdef HAVE_NETLINK
+extern struct vconn_class netlink_vconn_class;
+#endif
+
+#endif /* vconn-provider.h */
#include <unistd.h>
#include "dynamic-string.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "poll-loop.h"
#include "socket-util.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 VCONN_SSL_H
+#define VCONN_SSL_H 1
+
+#include <stdbool.h>
+
+#ifdef HAVE_OPENSSL
+bool vconn_ssl_is_configured(void);
+void vconn_ssl_set_private_key_file(const char *file_name);
+void vconn_ssl_set_certificate_file(const char *file_name);
+void vconn_ssl_set_ca_cert_file(const char *file_name, bool bootstrap);
+void vconn_ssl_set_peer_ca_cert_file(const char *file_name);
+
+#define VCONN_SSL_LONG_OPTIONS \
+ {"private-key", required_argument, 0, 'p'}, \
+ {"certificate", required_argument, 0, 'c'}, \
+ {"ca-cert", required_argument, 0, 'C'},
+
+#define VCONN_SSL_OPTION_HANDLERS \
+ case 'p': \
+ vconn_ssl_set_private_key_file(optarg); \
+ break; \
+ \
+ case 'c': \
+ vconn_ssl_set_certificate_file(optarg); \
+ break; \
+ \
+ case 'C': \
+ vconn_ssl_set_ca_cert_file(optarg, false); \
+ break;
+#else /* !HAVE_OPENSSL */
+static inline bool vconn_ssl_is_configured(void)
+{
+ return false;
+}
+#define VCONN_SSL_LONG_OPTIONS
+#define VCONN_SSL_OPTION_HANDLERS
+#endif /* !HAVE_OPENSSL */
+
+#endif /* vconn-ssl.h */
#include <sys/types.h>
#include <unistd.h>
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "socket-util.h"
#include "util.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 VCONN_STREAM_H
+#define VCONN_STREAM_H 1
+
+#include <stddef.h>
+#include <stdint.h>
+
+struct vconn;
+struct pvconn;
+struct sockaddr;
+
+int new_stream_vconn(const char *name, int fd, int connect_status,
+ uint32_t ip, struct vconn **vconnp);
+int new_pstream_pvconn(const char *name, int fd,
+ int (*accept_cb)(int fd, const struct sockaddr *,
+ size_t sa_len, struct vconn **),
+ struct pvconn **pvconnp);
+
+#endif /* vconn-stream.h */
#include "packets.h"
#include "socket-util.h"
#include "util.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "vconn-provider.h"
#include "vconn-stream.h"
#include <string.h>
#include <unistd.h>
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "poll-loop.h"
#include "socket-util.h"
#include "flow.h"
#include "ofp-print.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "random.h"
#include "util.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 VCONN_H
+#define VCONN_H 1
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+struct ofpbuf;
+struct flow;
+struct ofp_header;
+struct pvconn;
+struct vconn;
+
+void vconn_usage(bool active, bool passive, bool bootstrap);
+
+/* Active vconns: virtual connections to OpenFlow devices. */
+int vconn_open(const char *name, int min_version, struct vconn **);
+void vconn_close(struct vconn *);
+const char *vconn_get_name(const struct vconn *);
+uint32_t vconn_get_ip(const struct vconn *);
+int vconn_connect(struct vconn *);
+int vconn_recv(struct vconn *, struct ofpbuf **);
+int vconn_send(struct vconn *, struct ofpbuf *);
+int vconn_recv_xid(struct vconn *, uint32_t xid, struct ofpbuf **);
+int vconn_transact(struct vconn *, struct ofpbuf *, struct ofpbuf **);
+
+int vconn_open_block(const char *name, int min_version, struct vconn **);
+int vconn_send_block(struct vconn *, struct ofpbuf *);
+int vconn_recv_block(struct vconn *, struct ofpbuf **);
+
+enum vconn_wait_type {
+ WAIT_CONNECT,
+ WAIT_RECV,
+ WAIT_SEND
+};
+void vconn_wait(struct vconn *, enum vconn_wait_type);
+void vconn_connect_wait(struct vconn *);
+void vconn_recv_wait(struct vconn *);
+void vconn_send_wait(struct vconn *);
+
+/* Passive vconns: virtual listeners for incoming OpenFlow connections. */
+int pvconn_open(const char *name, struct pvconn **);
+void pvconn_close(struct pvconn *);
+int pvconn_accept(struct pvconn *, int min_version, struct vconn **);
+void pvconn_wait(struct pvconn *);
+
+/* OpenFlow protocol utility functions. */
+void *make_openflow(size_t openflow_len, uint8_t type, struct ofpbuf **);
+void *make_openflow_xid(size_t openflow_len, uint8_t type,
+ uint32_t xid, struct ofpbuf **);
+void update_openflow_length(struct ofpbuf *);
+struct ofpbuf *make_add_flow(const struct flow *, uint32_t buffer_id,
+ uint16_t max_idle, size_t actions_len);
+struct ofpbuf *make_add_simple_flow(const struct flow *,
+ uint32_t buffer_id, uint16_t out_port,
+ uint16_t max_idle);
+struct ofpbuf *make_buffered_packet_out(uint32_t buffer_id,
+ uint16_t in_port, uint16_t out_port);
+struct ofpbuf *make_unbuffered_packet_out(const struct ofpbuf *packet,
+ uint16_t in_port, uint16_t out_port);
+struct ofpbuf *make_echo_request(void);
+struct ofpbuf *make_echo_reply(const struct ofp_header *rq);
+
+#endif /* vconn.h */
--- /dev/null
+/* Modules that can emit log messages. */
+VLOG_MODULE(chain)
+VLOG_MODULE(controller)
+VLOG_MODULE(ctlpath)
+VLOG_MODULE(daemon)
+VLOG_MODULE(datapath)
+VLOG_MODULE(dhcp)
+VLOG_MODULE(dhcp_client)
+VLOG_MODULE(discovery)
+VLOG_MODULE(dpif)
+VLOG_MODULE(dpctl)
+VLOG_MODULE(executer)
+VLOG_MODULE(fail_open)
+VLOG_MODULE(fault)
+VLOG_MODULE(flow)
+VLOG_MODULE(in_band)
+VLOG_MODULE(learning_switch)
+VLOG_MODULE(mac_learning)
+VLOG_MODULE(netdev)
+VLOG_MODULE(netlink)
+VLOG_MODULE(ofp_discover)
+VLOG_MODULE(poll_loop)
+VLOG_MODULE(port_watcher)
+VLOG_MODULE(secchan)
+VLOG_MODULE(rconn)
+VLOG_MODULE(snat)
+VLOG_MODULE(stp)
+VLOG_MODULE(stp_secchan)
+VLOG_MODULE(status)
+VLOG_MODULE(switch)
+VLOG_MODULE(terminal)
+VLOG_MODULE(socket_util)
+VLOG_MODULE(vconn_netlink)
+VLOG_MODULE(vconn_tcp)
+VLOG_MODULE(vconn_ssl)
+VLOG_MODULE(vconn_stream)
+VLOG_MODULE(vconn_unix)
+VLOG_MODULE(vconn)
+VLOG_MODULE(vlog)
+VLOG_MODULE(vlog_socket)
+
+#ifdef HAVE_EXT
+#include "ext/vlogext-modules.def"
+#endif
+
+#undef VLOG_MODULE
--- /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 VLOG_SOCKET_H
+#define VLOG_SOCKET_H 1
+
+/* Server for Vlog control connection. */
+struct vlog_server;
+int vlog_server_listen(const char *path, struct vlog_server **);
+void vlog_server_close(struct vlog_server *);
+
+/* Client for Vlog control connection. */
+struct vlog_client;
+int vlog_client_connect(const char *path, struct vlog_client **);
+void vlog_client_close(struct vlog_client *);
+int vlog_client_send(struct vlog_client *, const char *request);
+int vlog_client_recv(struct vlog_client *, char **reply);
+int vlog_client_transact(struct vlog_client *,
+ const char *request, char **reply);
+const char *vlog_client_target(const struct vlog_client *);
+
+#endif /* vlog-socket.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 VLOG_H
+#define VLOG_H 1
+
+#include <limits.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <time.h>
+#include "util.h"
+
+/* Logging importance levels. */
+#define VLOG_LEVELS \
+ VLOG_LEVEL(EMER, LOG_ALERT) \
+ VLOG_LEVEL(ERR, LOG_ERR) \
+ VLOG_LEVEL(WARN, LOG_WARNING) \
+ VLOG_LEVEL(DBG, LOG_DEBUG)
+enum vlog_level {
+#define VLOG_LEVEL(NAME, SYSLOG_LEVEL) VLL_##NAME,
+ VLOG_LEVELS
+#undef VLOG_LEVEL
+ VLL_N_LEVELS
+};
+
+const char *vlog_get_level_name(enum vlog_level);
+enum vlog_level vlog_get_level_val(const char *name);
+
+/* Facilities that we can log to. */
+#define VLOG_FACILITIES \
+ VLOG_FACILITY(SYSLOG, "%05N|%c|%p|%m") \
+ VLOG_FACILITY(CONSOLE, "%d{%b %d %H:%M:%S}|%05N|%c|%p|%m") \
+ VLOG_FACILITY(FILE, "%d{%b %d %H:%M:%S}|%05N|%c|%p|%m")
+enum vlog_facility {
+#define VLOG_FACILITY(NAME, PATTERN) VLF_##NAME,
+ VLOG_FACILITIES
+#undef VLOG_FACILITY
+ VLF_N_FACILITIES,
+ VLF_ANY_FACILITY = -1
+};
+
+const char *vlog_get_facility_name(enum vlog_facility);
+enum vlog_facility vlog_get_facility_val(const char *name);
+
+/* VLM_ constant for each vlog module. */
+enum vlog_module {
+#define VLOG_MODULE(NAME) VLM_##NAME,
+#include "vlog-modules.def"
+ VLM_N_MODULES,
+ VLM_ANY_MODULE = -1
+};
+
+const char *vlog_get_module_name(enum vlog_module);
+enum vlog_module vlog_get_module_val(const char *name);
+
+/* Rate-limiter for log messages. */
+struct vlog_rate_limit {
+ /* Configuration settings. */
+ unsigned int rate; /* Tokens per second. */
+ unsigned int burst; /* Max cumulative tokens credit. */
+
+ /* Current status. */
+ unsigned int tokens; /* Current number of tokens. */
+ time_t last_fill; /* Last time tokens added. */
+ time_t first_dropped; /* Time first message was dropped. */
+ unsigned int n_dropped; /* Number of messages dropped. */
+};
+
+/* Number of tokens to emit a message. We add 'rate' token per second, which
+ * is 60 times the unit used for 'rate', thus 60 tokens are required to emit
+ * one message. */
+#define VLOG_MSG_TOKENS 60
+
+/* Initializer for a struct vlog_rate_limit, to set up a maximum rate of RATE
+ * messages per minute and a maximum burst size of BURST messages. */
+#define VLOG_RATE_LIMIT_INIT(RATE, BURST) \
+ { \
+ RATE, /* rate */ \
+ (MIN(BURST, UINT_MAX / VLOG_MSG_TOKENS) \
+ * VLOG_MSG_TOKENS), /* burst */ \
+ 0, /* tokens */ \
+ 0, /* last_fill */ \
+ 0, /* n_dropped */ \
+ }
+
+/* Configuring how each module logs messages. */
+enum vlog_level vlog_get_level(enum vlog_module, enum vlog_facility);
+void vlog_set_levels(enum vlog_module, enum vlog_facility, enum vlog_level);
+char *vlog_set_levels_from_string(const char *);
+char *vlog_get_levels(void);
+bool vlog_is_enabled(enum vlog_module, enum vlog_level);
+void vlog_set_verbosity(const char *arg);
+
+/* Configuring log facilities. */
+void vlog_set_pattern(enum vlog_facility, const char *pattern);
+const char *vlog_get_log_file(void);
+int vlog_set_log_file(const char *file_name);
+int vlog_reopen_log_file(void);
+
+/* Function for actual logging. */
+void vlog_init(void);
+void vlog_exit(void);
+void vlog(enum vlog_module, enum vlog_level, const char *format, ...)
+ __attribute__((format(printf, 3, 4)));
+void vlog_valist(enum vlog_module, enum vlog_level, const char *, va_list)
+ __attribute__((format(printf, 3, 0)));
+void vlog_rate_limit(enum vlog_module, enum vlog_level,
+ struct vlog_rate_limit *, const char *, ...)
+ __attribute__((format(printf, 4, 5)));
+
+/* Convenience macros. To use these, define THIS_MODULE as a macro that
+ * expands to the module used by the current source file, e.g.
+ * #include "vlog.h"
+ * #define THIS_MODULE VLM_netlink
+ * Guaranteed to preserve errno.
+ */
+#define VLOG_EMER(...) VLOG(VLL_EMER, __VA_ARGS__)
+#define VLOG_ERR(...) VLOG(VLL_ERR, __VA_ARGS__)
+#define VLOG_WARN(...) VLOG(VLL_WARN, __VA_ARGS__)
+#define VLOG_DBG(...) VLOG(VLL_DBG, __VA_ARGS__)
+
+/* More convenience macros, for testing whether a given level is enabled in
+ * THIS_MODULE. When constructing a log message is expensive, this enables it
+ * to be skipped. */
+#define VLOG_IS_EMER_ENABLED() true
+#define VLOG_IS_ERR_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_EMER)
+#define VLOG_IS_WARN_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_WARN)
+#define VLOG_IS_DBG_ENABLED() vlog_is_enabled(THIS_MODULE, VLL_DBG)
+
+/* Convenience macros. To use these, define THIS_MODULE as a macro that
+ * expands to the module used by the current source file, e.g.
+ * #include "vlog.h"
+ * #define THIS_MODULE VLM_netlink
+ * Guaranteed to preserve errno.
+ */
+#define VLOG_ERR_RL(RL, ...) \
+ vlog_rate_limit(THIS_MODULE, VLL_ERR, RL, __VA_ARGS__)
+#define VLOG_WARN_RL(RL, ...) \
+ vlog_rate_limit(THIS_MODULE, VLL_WARN, RL, __VA_ARGS__)
+#define VLOG_DBG_RL(RL, ...) \
+ vlog_rate_limit(THIS_MODULE, VLL_DBG, RL, __VA_ARGS__)
+
+/* Command line processing. */
+#define VLOG_OPTION_ENUMS OPT_LOG_FILE
+#define VLOG_LONG_OPTIONS \
+ {"verbose", optional_argument, 0, 'v'}, \
+ {"log-file", optional_argument, 0, OPT_LOG_FILE}
+#define VLOG_OPTION_HANDLERS \
+ case 'v': \
+ vlog_set_verbosity(optarg); \
+ break; \
+ case OPT_LOG_FILE: \
+ vlog_set_log_file(optarg); \
+ break;
+void vlog_usage(void);
+
+/* Implementation details. */
+#define VLOG(LEVEL, ...) \
+ do { \
+ if (min_vlog_levels[THIS_MODULE] >= LEVEL) { \
+ vlog(THIS_MODULE, LEVEL, __VA_ARGS__); \
+ } \
+ } while (0)
+extern enum vlog_level min_vlog_levels[VLM_N_MODULES];
+
+
+#endif /* vlog.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 XTOXLL_H
+#define XTOXLL_H 1
+
+#include <arpa/inet.h>
+#include <sys/types.h>
+
+static inline uint64_t
+htonll(uint64_t n)
+{
+ return htonl(1) == 1 ? n : ((uint64_t) htonl(n) << 32) | htonl(n >> 32);
+}
+
+static inline uint64_t
+ntohll(uint64_t n)
+{
+ return htonl(1) == 1 ? n : ((uint64_t) ntohl(n) << 32) | ntohl(n >> 32);
+}
+
+#endif /* xtoxll.h */
#include "dhcp-client.h"
#include "dhcp.h"
#include "netdev.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "port-watcher.h"
#include "secchan.h"
#include <unistd.h>
#include "dynamic-string.h"
#include "fatal-signal.h"
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "rconn.h"
#include "secchan.h"
#include "mac-learning.h"
#include "netdev.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "port-watcher.h"
#include "rconn.h"
#include <stdlib.h>
#include "dynamic-string.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "port-array.h"
#include "rconn.h"
#include <arpa/inet.h>
#include <stdlib.h>
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "queue.h"
#include "rconn.h"
#include "in-band.h"
#include "list.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "port-watcher.h"
#include "poll-loop.h"
#include <arpa/inet.h>
#include <inttypes.h>
#include <stdlib.h>
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "port-watcher.h"
#define THIS_MODULE VLM_snat
#include <errno.h>
#include <unistd.h>
#include "dynamic-string.h"
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "rconn.h"
#include "timeval.h"
#include "vconn.h"
#include "flow.h"
#include "secchan.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "port-watcher.h"
#include "rconn.h"
#include "list.h"
#include "netdev.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "poll-loop.h"
#include "rconn.h"
#include "csum.h"
#include "packets.h"
#include "dp_act.h"
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "nx_act.h"
#ifndef DP_ACT_H
#define DP_ACT_H 1
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "switch-flow.h"
#include "datapath.h"
*/
/* Functions for Nicira-extended actions. */
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "nx_act.h"
uint16_t
#include <stdlib.h>
#include <string.h>
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "timeval.h"
#define SWITCH_FLOW_H 1
#include <time.h>
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "flow.h"
#include "list.h"
#include "daemon.h"
#include "datapath.h"
#include "fault.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "poll-loop.h"
#include "queue.h"
#include "util.h"
#include <stdlib.h>
#include "flow.h"
#include "list.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "switch-flow.h"
#include "datapath.h"
+#include <stdlib.h>
+
+#include "interface.h"
-+#include "../../include/openflow.h"
++#include "../../include/openflow/openflow.h"
+#include "../../include/ofp-print.h"
+
+void
#ifdef HAVE_NETLINK
#include "netdev.h"
#include "netlink.h"
-#include "openflow-netlink.h"
+#include "openflow/openflow-netlink.h"
#endif
#include "command-line.h"
#include "compiler.h"
#include "dpif.h"
-#include "nicira-ext.h"
+#include "openflow/nicira-ext.h"
#include "ofp-print.h"
#include "ofpbuf.h"
-#include "openflow.h"
+#include "openflow/openflow.h"
#include "packets.h"
#include "random.h"
#include "socket-util.h"