Skip to content

Commit

Permalink
ofp-util: Refactor decoding of OpenFlow 1.1 group mod messages.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
shorman-netronome authored and blp committed Nov 10, 2014
1 parent 655ed3a commit aead63f
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions lib/ofp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7420,27 +7420,50 @@ 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;

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;
}
Expand Down

0 comments on commit aead63f

Please sign in to comment.