noinst_HEADERS += \
include/openflow/nicira-ext.h \
include/openflow/openflow-1.0.h \
+ include/openflow/openflow-1.1.h \
+ include/openflow/openflow-common.h \
include/openflow/openflow.h
if HAVE_PYTHON
touch $@
HSTAMP_FILES = \
- include/openflow/openflow.hstamp \
+ include/openflow/nicira.hstamp \
include/openflow/openflow-1.0.hstamp \
- include/openflow/nicira.hstamp
+ include/openflow/openflow-1.1.hstamp \
+ include/openflow/openflow.hstamp
ALL_LOCAL += $(HSTAMP_FILES)
$(HSTAMP_FILES): build-aux/check-structs
-include/openflow/openflow-1.0.hstamp: include/openflow/openflow.h
+include/openflow/openflow-1.0.hstamp: include/openflow/openflow-common.h
+include/openflow/openflow-1.1.hstamp: include/openflow/openflow-common.h
include/openflow/nicira-ext.hstamp: \
include/openflow/openflow-1.0.h \
+ include/openflow/openflow-1.1.h \
+ include/openflow/openflow-common.h \
include/openflow/openflow.h
endif
#ifndef OPENFLOW_OPENFLOW10_H
#define OPENFLOW_OPENFLOW10_H 1
-#include "openvswitch/types.h"
-
-#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 */
-
-/* Version number:
- * Non-experimental versions released: 0x01
- * Experimental versions released: 0x81 -- 0x99
- */
-/* The most significant bit being set in the version field indicates an
- * experimental OpenFlow version.
- */
-#define OFP_VERSION 0x01
-#define OFP10_VERSION 0x01
-
-#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. */
+#include "openflow/openflow-common.h"
/* Port numbering. Physical ports are numbered starting from 1. */
enum ofp_port {
/* Header on all OpenFlow packets. */
struct ofp_header {
- uint8_t version; /* OFP_VERSION. */
+ uint8_t version; /* An OpenFlow version number, e.g. OFP10_VERSION. */
uint8_t type; /* One of the OFPT_ constants. */
ovs_be16 length; /* Length including this ofp_header. */
ovs_be32 xid; /* Transaction id associated with this packet.
--- /dev/null
+/* Copyright (c) 2008, 2011 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.
+ */
+
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* OpenFlow: protocol between controller and datapath. */
+
+#ifndef OPENFLOW_11_H
+#define OPENFLOW_11_H 1
+
+#include "openflow/openflow-common.h"
+
+/* Nothing here yet. */
+
+#endif /* openflow/openflow-1.1.h */
--- /dev/null
+/* Copyright (c) 2008, 2011 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.
+ */
+
+/*
+ * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OPENFLOW_COMMON_H
+#define OPENFLOW_COMMON_H 1
+
+#include "openvswitch/types.h"
+
+#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 */
+
+/* Version number:
+ * Non-experimental versions released: 0x01 0x02
+ * Experimental versions released: 0x81 -- 0x99
+ */
+/* The most significant bit being set in the version field indicates an
+ * experimental OpenFlow version.
+ */
+#define OFP10_VERSION 0x01
+#define OFP11_VERSION 0x02
+
+#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. */
+
+#endif /* openflow/openflow-common.h */
#define OPENFLOW_OPENFLOW_H 1
#include "openflow/openflow-1.0.h"
+#include "openflow/openflow-1.1.h"
#endif /* openflow/openflow.h */
ofputil_protocol_from_ofp_version(int version)
{
switch (version) {
- case OFP_VERSION: return OFPUTIL_P_OF10;
+ case OFP10_VERSION: return OFPUTIL_P_OF10;
default: return 0;
}
}
packet = ofpbuf_new(send_len + header_len);
opi = ofpbuf_put_zeros(packet, header_len);
- opi->header.version = OFP_VERSION;
+ opi->header.version = OFP10_VERSION;
opi->header.type = OFPT_PACKET_IN;
opi->total_len = htons(pin->total_len);
opi->in_port = htons(pin->fmd.in_port);
ofpbuf_put(packet, pin->packet, send_len);
npi = packet->data;
- npi->nxh.header.version = OFP_VERSION;
+ npi->nxh.header.version = OFP10_VERSION;
npi->nxh.header.type = OFPT_VENDOR;
npi->nxh.vendor = htonl(NX_VENDOR_ID);
npi->nxh.subtype = htonl(NXT_PACKET_IN);
assert(openflow_len <= UINT16_MAX);
oh = ofpbuf_put_uninit(buffer, openflow_len);
- oh->version = OFP_VERSION;
+ oh->version = OFP10_VERSION;
oh->type = type;
oh->length = htons(openflow_len);
oh->xid = xid;
size_t size = sizeof *ofm + actions_len;
struct ofpbuf *out = ofpbuf_new(size);
ofm = ofpbuf_put_zeros(out, sizeof *ofm);
- ofm->header.version = OFP_VERSION;
+ ofm->header.version = OFP10_VERSION;
ofm->header.type = OFPT_FLOW_MOD;
ofm->header.length = htons(size);
ofm->cookie = 0;
struct ofp_header *rq;
struct ofpbuf *out = ofpbuf_new(sizeof *rq);
rq = ofpbuf_put_uninit(out, sizeof *rq);
- rq->version = OFP_VERSION;
+ rq->version = OFP10_VERSION;
rq->type = OFPT_ECHO_REQUEST;
rq->length = htons(sizeof *rq);
rq->xid = htonl(0);
VLOG_INFO("%s: connecting...", rc->name);
}
rc->n_attempted_connections++;
- retval = vconn_open(rc->target, OFP_VERSION, &rc->vconn);
+ retval = vconn_open(rc->target, OFP10_VERSION, &rc->vconn);
if (!retval) {
rc->remote_ip = vconn_get_remote_ip(rc->vconn);
rc->local_ip = vconn_get_local_ip(rc->vconn);
return STREAM_SSL;
case PAIR('{', '"'):
return STREAM_JSONRPC;
- case PAIR(OFP_VERSION, OFPT_HELLO):
+ case PAIR(OFP10_VERSION, OFPT_HELLO):
return STREAM_OPENFLOW;
}
}
*
* The vconn will automatically negotiate an OpenFlow protocol version
* acceptable to both peers on the connection. The version negotiated will be
- * no lower than 'min_version' and no higher than OFP_VERSION.
+ * no lower than 'min_version' and no higher than OFP10_VERSION.
*
* Returns 0 if successful, otherwise a positive errno value. If successful,
* stores a pointer to the new connection in '*vconnp', otherwise a null
ds_destroy(&msg);
}
- vconn->version = MIN(OFP_VERSION, oh->version);
+ vconn->version = MIN(OFP10_VERSION, oh->version);
if (vconn->version < vconn->min_version) {
VLOG_WARN_RL(&bad_ofmsg_rl,
"%s: version negotiation failed: we support "
"versions 0x%02x to 0x%02x inclusive but peer "
"supports no later than version 0x%02"PRIx8,
- vconn->name, vconn->min_version, OFP_VERSION,
+ vconn->name, vconn->min_version, OFP10_VERSION,
oh->version);
vconn->state = VCS_SEND_ERROR;
} else {
"(we support versions 0x%02x to 0x%02x inclusive, "
"peer no later than version 0x%02"PRIx8")",
vconn->name, vconn->version, vconn->min_version,
- OFP_VERSION, oh->version);
+ OFP10_VERSION, oh->version);
vconn->state = VCS_CONNECTED;
}
ofpbuf_delete(b);
snprintf(s, sizeof s, "We support versions 0x%02x to 0x%02x inclusive but "
"you support no later than version 0x%02"PRIx8".",
- vconn->min_version, OFP_VERSION, vconn->version);
+ vconn->min_version, OFP10_VERSION, vconn->version);
b = ofperr_encode_hello(OFPERR_OFPHFC_INCOMPATIBLE,
ofperr_domain_from_version(vconn->version), s);
retval = do_send(vconn, b);
*
* The new vconn will automatically negotiate an OpenFlow protocol version
* acceptable to both peers on the connection. The version negotiated will be
- * no lower than 'min_version' and no higher than OFP_VERSION.
+ * no lower than 'min_version' and no higher than OFP10_VERSION.
*
* pvconn_accept() will not block waiting for a connection. If no connection
* is ready to be accepted, it returns EAGAIN immediately. */
struct vconn *vconn;
int retval;
- retval = pvconn_accept(ofservice->pvconn, OFP_VERSION, &vconn);
+ retval = pvconn_accept(ofservice->pvconn, OFP10_VERSION, &vconn);
if (!retval) {
struct rconn *rconn;
char *name;
struct vconn *vconn;
int retval;
- retval = pvconn_accept(mgr->snoops[i], OFP_VERSION, &vconn);
+ retval = pvconn_accept(mgr->snoops[i], OFP10_VERSION, &vconn);
if (!retval) {
add_snooper(mgr, vconn);
} else if (retval != EAGAIN) {
: EPROTO);
fpv_create(type, &fpv);
- CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP_VERSION, &vconn), 0);
+ CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP10_VERSION, &vconn), 0);
fpv_close(&fpv);
vconn_run(vconn);
CHECK_ERRNO(vconn_connect(vconn), expected_error);
: EPROTO);
fpv_create(type, &fpv);
- CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP_VERSION, &vconn), 0);
+ CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP10_VERSION, &vconn), 0);
vconn_run(vconn);
stream_close(fpv_accept(&fpv));
fpv_close(&fpv);
struct stream *stream;
fpv_create(type, &fpv);
- CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP_VERSION, &vconn), 0);
+ CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP10_VERSION, &vconn), 0);
vconn_run(vconn);
stream = fpv_accept(&fpv);
fpv_destroy(&fpv);
retval = stream_recv(stream, &hello, sizeof hello);
if (retval == sizeof hello) {
- CHECK(hello.version, OFP_VERSION);
+ CHECK(hello.version, OFP10_VERSION);
CHECK(hello.type, OFPT_HELLO);
CHECK(ntohs(hello.length), sizeof hello);
break;
size_t n_sent;
fpv_create(type, &fpv);
- CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP_VERSION, &vconn), 0);
+ CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP10_VERSION, &vconn), 0);
vconn_run(vconn);
stream = fpv_accept(&fpv);
fpv_destroy(&fpv);
struct ofp_header hello;
int retval = stream_recv(stream, &hello, sizeof hello);
if (retval == sizeof hello) {
- CHECK(hello.version, OFP_VERSION);
+ CHECK(hello.version, OFP10_VERSION);
CHECK(hello.type, OFPT_HELLO);
CHECK(ntohs(hello.length), sizeof hello);
read_hello = true;
const char *type = argv[1];
struct ofp_header hello;
- hello.version = OFP_VERSION;
+ hello.version = OFP10_VERSION;
hello.type = OFPT_HELLO;
hello.length = htons(sizeof hello);
hello.xid = htonl(0x12345678);
struct ofp_header hello;
char buffer[sizeof hello * 2];
- hello.version = OFP_VERSION;
+ hello.version = OFP10_VERSION;
hello.type = OFPT_HELLO;
hello.length = htons(sizeof buffer);
hello.xid = htonl(0x12345678);
const char *type = argv[1];
struct ofp_header echo;
- echo.version = OFP_VERSION;
+ echo.version = OFP10_VERSION;
echo.type = OFPT_ECHO_REQUEST;
echo.length = htons(sizeof echo);
echo.xid = htonl(0x89abcdef);
const char *type = argv[1];
struct ofp_header hello;
- hello.version = OFP_VERSION - 1;
+ hello.version = OFP10_VERSION - 1;
hello.type = OFPT_HELLO;
hello.length = htons(sizeof hello);
hello.xid = htonl(0x12345678);
const char *name = argv[i];
struct vconn *vconn;
- retval = vconn_open(name, OFP_VERSION, &vconn);
+ retval = vconn_open(name, OFP10_VERSION, &vconn);
if (!retval) {
if (n_switches >= MAX_SWITCHES) {
ovs_fatal(0, "max %d switch connections", n_switches);
for (i = 0; i < n_listeners && n_switches < MAX_SWITCHES; ) {
struct vconn *new_vconn;
- retval = pvconn_accept(listeners[i], OFP_VERSION, &new_vconn);
+ retval = pvconn_accept(listeners[i], OFP10_VERSION, &new_vconn);
if (!retval || retval == EAGAIN) {
if (!retval) {
new_switch(&switches[n_switches++], new_vconn);
usage();
case 'V':
- ovs_print_version(OFP_VERSION, OFP_VERSION);
+ ovs_print_version(OFP10_VERSION, OFP10_VERSION);
exit(EXIT_SUCCESS);
VLOG_OPTION_HANDLERS
usage();
case 'V':
- ovs_print_version(OFP_VERSION, OFP_VERSION);
+ ovs_print_version(OFP10_VERSION, OFP10_VERSION);
exit(EXIT_SUCCESS);
case OPT_STRICT:
{
char *vconn_name = xasprintf("unix:%s", name);
VLOG_DBG("connecting to %s", vconn_name);
- run(vconn_open_block(vconn_name, OFP_VERSION, vconnp),
+ run(vconn_open_block(vconn_name, OFP10_VERSION, vconnp),
"connecting to %s", vconn_name);
free(vconn_name);
}
free(datapath_type);
if (strchr(name, ':')) {
- run(vconn_open_block(name, OFP_VERSION, vconnp),
+ run(vconn_open_block(name, OFP10_VERSION, vconnp),
"connecting to %s", name);
} else if (!stat(name, &s) && S_ISSOCK(s.st_mode)) {
open_vconn_socket(name, vconnp);
usage();
case 'V':
- ovs_print_version(OFP_VERSION, OFP_VERSION);
+ ovs_print_version(OFP10_VERSION, OFP10_VERSION);
exit(EXIT_SUCCESS);
case OPT_MLOCKALL: