summaryrefslogtreecommitdiff
path: root/ofproto
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2018-02-16 11:43:56 -0800
committerBen Pfaff <blp@ovn.org>2018-03-14 11:34:41 -0700
commitd8790c08437106f1d71960330e4e35de4fef16f6 (patch)
treec836a578fed177a7f4e574413042017a14a54108 /ofproto
parent225c33ba64a4de1aa30b05f8549c0628fe7fe6e3 (diff)
downloadopenvswitch-d8790c08437106f1d71960330e4e35de4fef16f6.tar.gz
ofp-packet: Better abstract packet-in format.
This commit relieves the caller of code that deals with the format of packet-in messages from some of the burden of understanding the packet format. It also renames the constants to appear to be at a higher level of abstraction. Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
Diffstat (limited to 'ofproto')
-rw-r--r--ofproto/connmgr.c8
-rw-r--r--ofproto/connmgr.h5
-rw-r--r--ofproto/ofproto.c14
3 files changed, 12 insertions, 15 deletions
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index bf43fbd73..964b8c8d8 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -73,7 +73,7 @@ struct ofconn {
/* OpenFlow state. */
enum ofp12_controller_role role; /* Role. */
enum ofputil_protocol protocol; /* Current protocol variant. */
- enum nx_packet_in_format packet_in_format; /* OFPT_PACKET_IN format. */
+ enum ofputil_packet_in_format packet_in_format;
/* OFPT_PACKET_IN related data. */
struct rconn_packet_counter *packet_in_counter; /* # queued on 'rconn'. */
@@ -1044,7 +1044,7 @@ ofconn_set_protocol(struct ofconn *ofconn, enum ofputil_protocol protocol)
* NXPIF_*.
*
* The default, if no other format has been set, is NXPIF_STANDARD. */
-enum nx_packet_in_format
+enum ofputil_packet_in_format
ofconn_get_packet_in_format(struct ofconn *ofconn)
{
return ofconn->packet_in_format;
@@ -1054,7 +1054,7 @@ ofconn_get_packet_in_format(struct ofconn *ofconn)
* NXPIF_*). */
void
ofconn_set_packet_in_format(struct ofconn *ofconn,
- enum nx_packet_in_format packet_in_format)
+ enum ofputil_packet_in_format packet_in_format)
{
ofconn->packet_in_format = packet_in_format;
}
@@ -1303,7 +1303,7 @@ ofconn_flush(struct ofconn *ofconn)
ofconn->role = OFPCR12_ROLE_EQUAL;
ofconn_set_protocol(ofconn, OFPUTIL_P_NONE);
- ofconn->packet_in_format = NXPIF_STANDARD;
+ ofconn->packet_in_format = OFPUTIL_PACKET_IN_STD;
rconn_packet_counter_destroy(ofconn->packet_in_counter);
ofconn->packet_in_counter = rconn_packet_counter_create();
diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h
index c41189216..2405fbd79 100644
--- a/ofproto/connmgr.h
+++ b/ofproto/connmgr.h
@@ -112,8 +112,9 @@ void ofconn_set_role(struct ofconn *, enum ofp12_controller_role);
enum ofputil_protocol ofconn_get_protocol(const struct ofconn *);
void ofconn_set_protocol(struct ofconn *, enum ofputil_protocol);
-enum nx_packet_in_format ofconn_get_packet_in_format(struct ofconn *);
-void ofconn_set_packet_in_format(struct ofconn *, enum nx_packet_in_format);
+enum ofputil_packet_in_format ofconn_get_packet_in_format(struct ofconn *);
+void ofconn_set_packet_in_format(struct ofconn *,
+ enum ofputil_packet_in_format);
void ofconn_set_controller_id(struct ofconn *, uint16_t controller_id);
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 531e2e7f1..57ce3c81f 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -5890,16 +5890,12 @@ static enum ofperr
handle_nxt_set_packet_in_format(struct ofconn *ofconn,
const struct ofp_header *oh)
{
- const struct nx_set_packet_in_format *msg = ofpmsg_body(oh);
- uint32_t format;
-
- format = ntohl(msg->format);
- if (!ofputil_packet_in_format_is_valid(format)) {
- return OFPERR_OFPBRC_EPERM;
+ enum ofputil_packet_in_format format;
+ enum ofperr error = ofputil_decode_set_packet_in_format(oh, &format);
+ if (!error) {
+ ofconn_set_packet_in_format(ofconn, format);
}
-
- ofconn_set_packet_in_format(ofconn, format);
- return 0;
+ return error;
}
static enum ofperr