From 83974732903f85c33973632c4bb2aed703cb6989 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Wed, 8 Aug 2012 06:49:46 +0900 Subject: [PATCH] ofp-util: Allow encoding of Open Flow 1.2 Flow Removed messages Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- lib/ofp-msgs.h | 3 +++ lib/ofp-util.c | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/ofp-msgs.h b/lib/ofp-msgs.h index 62cdf666a..05ef3341b 100644 --- a/lib/ofp-msgs.h +++ b/lib/ofp-msgs.h @@ -134,6 +134,8 @@ enum ofpraw { /* OFPT 1.0 (11): struct ofp_flow_removed. */ OFPRAW_OFPT10_FLOW_REMOVED, + /* OFPT 1.1+ (11): struct ofp11_flow_removed, uint8_t[8][]. */ + OFPRAW_OFPT11_FLOW_REMOVED, /* NXT 1.0+ (14): struct nx_flow_removed, uint8_t[8][]. */ OFPRAW_NXT_FLOW_REMOVED, @@ -332,6 +334,7 @@ enum ofptype { * OFPRAW_OFPT12_PACKET_IN. * OFPRAW_NXT_PACKET_IN. */ OFPTYPE_FLOW_REMOVED, /* OFPRAW_OFPT10_FLOW_REMOVED. + * OFPRAW_OFPT11_FLOW_REMOVED. * OFPRAW_NXT_FLOW_REMOVED. */ OFPTYPE_PORT_STATUS, /* OFPRAW_OFPT10_PORT_STATUS. * OFPRAW_OFPT11_PORT_STATUS. */ diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 6b92dcdb8..805c505ef 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -1861,6 +1861,26 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr, struct ofpbuf *msg; switch (protocol) { + case OFPUTIL_P_OF12: { + struct ofp12_flow_removed *ofr; + + msg = ofpraw_alloc_xid(OFPRAW_OFPT11_FLOW_REMOVED, + ofputil_protocol_to_ofp_version(protocol), + htonl(0), NXM_TYPICAL_LEN); + ofr = ofpbuf_put_zeros(msg, sizeof *ofr); + ofr->cookie = fr->cookie; + ofr->priority = htons(fr->rule.priority); + ofr->reason = fr->reason; + ofr->table_id = 0; + ofr->duration_sec = htonl(fr->duration_sec); + ofr->duration_nsec = htonl(fr->duration_nsec); + ofr->idle_timeout = htons(fr->idle_timeout); + ofr->packet_count = htonll(fr->packet_count); + ofr->byte_count = htonll(fr->byte_count); + oxm_put_match(msg, &fr->rule); + break; + } + case OFPUTIL_P_OF10: case OFPUTIL_P_OF10_TID: { struct ofp_flow_removed *ofr; @@ -1903,7 +1923,6 @@ ofputil_encode_flow_removed(const struct ofputil_flow_removed *fr, break; } - case OFPUTIL_P_OF12: default: NOT_REACHED(); } -- 2.43.0