diff options
author | Ben Pfaff <blp@nicira.com> | 2013-02-11 23:37:41 -0800 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2013-02-11 23:52:21 -0800 |
commit | 964a5f60c0b38e59993e92425709579b3394349a (patch) | |
tree | 9f7b3c0c639b2fff1b581e46dabb066a99a4c45b /lib/ofp-msgs.c | |
parent | e032c08628186e3bf351fc9e111cf919d0d06073 (diff) |
ofp-msgs: New function ofpraw_decode_assert().
This will acquire a caller in an upcoming patch.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/ofp-msgs.c')
-rw-r--r-- | lib/ofp-msgs.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/ofp-msgs.c b/lib/ofp-msgs.c index 05742288..efc4198a 100644 --- a/lib/ofp-msgs.c +++ b/lib/ofp-msgs.c @@ -320,6 +320,23 @@ ofpraw_decode(enum ofpraw *raw, const struct ofp_header *oh) return ofpraw_pull(raw, &msg); } +/* Does the same job as ofpraw_decode(), except that it assert-fails if + * ofpraw_decode() would have reported an error. Thus, it's able to use the + * return value for the OFPRAW_* message type instead of an error code. + * + * (It only makes sense to use this function if you previously called + * ofpraw_decode() on the message and thus know that it's OK.) */ +enum ofpraw +ofpraw_decode_assert(const struct ofp_header *oh) +{ + enum ofperr error; + enum ofpraw raw; + + error = ofpraw_decode(&raw, oh); + ovs_assert(!error); + return raw; +} + /* Determines the OFPRAW_* type of the OpenFlow message in 'msg', which starts * at 'msg->data' and has length 'msg->size' bytes. On success, returns 0 and * stores the type into '*rawp'. On failure, returns an OFPERR_* error code |