diff options
author | Simon Horman <simon.horman@netronome.com> | 2014-11-10 13:47:56 +0900 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2014-11-10 10:05:26 -0800 |
commit | aead63f2eccb028490e9fcb7b1b53ada76a3c22d (patch) | |
tree | ea3c122fea6c7b096950fefa592331cac11a14fe | |
parent | 655ed3ae5e77ddc9da74790585bb52759db9b165 (diff) |
ofp-util: Refactor decoding of OpenFlow 1.1 group mod messages.
This refactoring is in preparation for supporting encoding
of (draft) OpenFlow 1.5 group mod messages.
ONF-JIRA: EXT-350
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
-rw-r--r-- | lib/ofp-util.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/lib/ofp-util.c b/lib/ofp-util.c index 96bc6a496..493b79bbc 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -7420,13 +7420,28 @@ ofputil_encode_group_mod(enum ofp_version ofp_version, } } +static enum ofperr +ofputil_pull_ofp11_group_mod(struct ofpbuf *msg, enum ofp_version ofp_version, + struct ofputil_group_mod *gm) +{ + const struct ofp11_group_mod *ogm; + + ogm = ofpbuf_pull(msg, sizeof *ogm); + gm->command = ntohs(ogm->command); + gm->type = ogm->type; + gm->group_id = ntohl(ogm->group_id); + + return ofputil_pull_ofp11_buckets(msg, ofpbuf_size(msg), ofp_version, + &gm->buckets); +} + /* Converts OpenFlow group mod message 'oh' into an abstract group mod in * 'gm'. Returns 0 if successful, otherwise an OpenFlow error code. */ enum ofperr ofputil_decode_group_mod(const struct ofp_header *oh, struct ofputil_group_mod *gm) { - const struct ofp11_group_mod *ogm; + enum ofp_version ofp_version = oh->version; struct ofpbuf msg; struct ofputil_bucket *bucket; enum ofperr err; @@ -7434,13 +7449,21 @@ ofputil_decode_group_mod(const struct ofp_header *oh, ofpbuf_use_const(&msg, oh, ntohs(oh->length)); ofpraw_pull_assert(&msg); - ogm = ofpbuf_pull(&msg, sizeof *ogm); - gm->command = ntohs(ogm->command); - gm->type = ogm->type; - gm->group_id = ntohl(ogm->group_id); + switch (ofp_version) + { + case OFP11_VERSION: + case OFP12_VERSION: + case OFP13_VERSION: + case OFP14_VERSION: + case OFP15_VERSION: + err = ofputil_pull_ofp11_group_mod(&msg, ofp_version, gm); + break; + + case OFP10_VERSION: + default: + OVS_NOT_REACHED(); + } - err = ofputil_pull_ofp11_buckets(&msg, ofpbuf_size(&msg), oh->version, - &gm->buckets); if (err) { return err; } |