From: Simon Horman Date: Tue, 7 Aug 2012 21:49:41 +0000 (+0900) Subject: ofp-actions: Return action size X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a07c15bc39154c2a31b9c14d54db1b10a8f77312;p=openvswitch ofp-actions: Return action size Modify ofpacts_put_openflow11_actions() to return the length of actions appended. This will be used when encoding Packet Out messages for Open Flow 1.1 and 1.2. The motivation for this is to avoid open coding the size calculation which may end up being needed elsewhere too. Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 0874cc46..11642d1e 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -1384,15 +1384,18 @@ ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out) /* Converts the ofpacts in 'ofpacts' (terminated by OFPACT_END) into OpenFlow * 1.1 actions in 'openflow', appending the actions to any existing data in * 'openflow'. */ -void +size_t ofpacts_put_openflow11_actions(const struct ofpact ofpacts[], size_t ofpacts_len, struct ofpbuf *openflow) { const struct ofpact *a; + size_t start_size = openflow->size; OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) { ofpact_to_openflow11(a, openflow); } + + return openflow->size - start_size; } void diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h index 7c9cb055..d5497a82 100644 --- a/lib/ofp-actions.h +++ b/lib/ofp-actions.h @@ -396,8 +396,8 @@ enum ofperr ofpacts_check(const struct ofpact[], size_t ofpacts_len, /* Converting ofpacts to OpenFlow. */ void ofpacts_put_openflow10(const struct ofpact[], size_t ofpacts_len, struct ofpbuf *openflow); -void ofpacts_put_openflow11_actions(const struct ofpact[], size_t ofpacts_len, - struct ofpbuf *openflow); +size_t ofpacts_put_openflow11_actions(const struct ofpact[], size_t ofpacts_len, + struct ofpbuf *openflow); void ofpacts_put_openflow11_instructions(const struct ofpact[], size_t ofpacts_len, struct ofpbuf *openflow);