[ovs-dev] [PATCH 5/6 RFC] lib/ofp-util: add decoder for role status asynchronous message
Alexandru Copot
alex.mihai.c at gmail.com
Tue Oct 8 09:26:22 UTC 2013
Signed-off-by: Alexandru Copot <alex.mihai.c at gmail.com>
Cc: Daniel Baluta <dbaluta at ixiacom.com>
---
lib/ofp-util.c | 27 +++++++++++++++++++++++++++
lib/ofp-util.h | 2 ++
2 files changed, 29 insertions(+)
diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 9bc30a7..cdc9f16 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -3923,6 +3923,33 @@ ofputil_encode_role_status(const struct ofputil_role_status *status,
return buf;
}
+
+enum ofperr
+ofputil_decode_role_status(const struct ofp_header *oh,
+ struct ofputil_role_status *rs)
+{
+ struct ofpbuf b;
+ enum ofpraw raw;
+
+ ofpbuf_use_const(&b, oh, ntohs(oh->length));
+ raw = ofpraw_pull_assert(&b);
+ if (raw != OFPRAW_OFPT14_ROLE_STATUS)
+ NOT_REACHED();
+
+ const struct ofp14_role_status *r = b.l3;
+ if (r->role != htonl(OFPCR12_ROLE_NOCHANGE) &&
+ r->role != htonl(OFPCR12_ROLE_EQUAL) &&
+ r->role != htonl(OFPCR12_ROLE_MASTER) &&
+ r->role != htonl(OFPCR12_ROLE_SLAVE)) {
+ return OFPERR_OFPRRFC_BAD_ROLE;
+ }
+
+ rs->role = ntohl(r->role);
+ rs->generation_id = ntohll(r->generation_id);
+
+ return 0;
+}
+
/* Table stats. */
static void
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index c3a35a7..3abfb9d 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -693,6 +693,8 @@ struct ofpbuf *ofputil_encode_role_status(
const struct ofputil_role_status *status,
enum ofputil_protocol protocol);
+enum ofperr ofputil_decode_role_status(const struct ofp_header *oh,
+ struct ofputil_role_status *rs);
/* Abstract table stats.
*
* For now we use ofp12_table_stats as a superset of the other protocol
--
1.8.4
More information about the dev
mailing list