This adds support for ofpacts_to_openflow11() to encode instructions although at this point only the OFPIT11_APPLY_ACTIONS instruction type is supported.
I am unsure if it would be better to use a new function that wraps the existing ofpacts_to_openflow11(). But for now I have simply modified ofpacts_to_openflow11(). Signed-off-by: Simon Horman <ho...@verge.net.au> --- v4 * No change v3 * Initial post --- lib/ofp-actions.c | 36 +++++++++++++++++++++++++++++++++--- lib/ofp-actions.h | 3 ++- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 17c8142..0f2a024 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -1371,12 +1371,42 @@ ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out) * 1.1 actions in 'openflow', appending the actions to any existing data in * 'openflow'. */ void -ofpacts_to_openflow11(const struct ofpact ofpacts[], struct ofpbuf *openflow) +ofpacts_to_openflow11(const struct ofpact ofpacts[], struct ofpbuf *openflow, + enum ofp11_instruction_type type) { const struct ofpact *a; - OFPACT_FOR_EACH (a, ofpacts) { - ofpact_to_openflow11(a, openflow); + switch (type) { + case OFPIT11_GOTO_TABLE: + case OFPIT11_WRITE_METADATA: + case OFPIT11_WRITE_ACTIONS: + /* FIXME: Implementation needed */ + NOT_REACHED(); + + case OFPIT11_APPLY_ACTIONS: { + struct ofp11_instruction_actions *oia; + size_t start_len = openflow->size; + + ofpbuf_put_uninit(openflow, sizeof *oia); + OFPACT_FOR_EACH (a, ofpacts) { + ofpact_to_openflow11(a, openflow); + } + oia = (struct ofp11_instruction_actions *)((char *)openflow->data + + start_len); + oia->type = htons(type); + oia->len = htons(openflow->size - start_len); + memset(oia->pad, 0, sizeof oia->pad); + + break; + } + + case OFPIT11_CLEAR_ACTIONS: + case OFPIT11_EXPERIMENTER: + /* FIXME: Implementation needed */ + NOT_REACHED(); + + default: + NOT_REACHED(); } } diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h index 49c2c27..7cf1eb5 100644 --- a/lib/ofp-actions.h +++ b/lib/ofp-actions.h @@ -390,7 +390,8 @@ enum ofperr ofpacts_check(const struct ofpact[], /* Converting ofpacts to OpenFlow. */ void ofpacts_to_openflow10(const struct ofpact[], struct ofpbuf *openflow); -void ofpacts_to_openflow11(const struct ofpact[], struct ofpbuf *openflow); +void ofpacts_to_openflow11(const struct ofpact[], struct ofpbuf *openflow, + enum ofp11_instruction_type type); /* Working with ofpacts. */ bool ofpacts_output_to_port(const struct ofpact[], uint16_t port); -- 1.7.10.2.484.gcd07cc5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev