[ovs-dev] [PATCH 07/17] ofp-actions: instruction formatter
Isaku Yamahata
yamahata at valinux.co.jp
Wed Jul 18 11:41:21 UTC 2012
Signed-off-by: Isaku Yamahata <yamahata at valinux.co.jp>
---
lib/ofp-actions.c | 42 +++++++++++++++++++++++++++++++++---------
1 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c
index 6c78ac1..2489879 100644
--- a/lib/ofp-actions.c
+++ b/lib/ofp-actions.c
@@ -1602,6 +1602,8 @@ ofpacts_equal(const struct ofpact *a, size_t a_len,
}
/* Formatting ofpacts. */
+static void ofpacts_format__(const struct ofpact *ofpacts, size_t ofpacts_len,
+ struct ds *string);
static void
print_note(const struct ofpact_note *note, struct ds *string)
@@ -1642,6 +1644,7 @@ ofpact_format(const struct ofpact *a, struct ds *s)
const struct ofpact_autopath *autopath;
const struct ofpact_controller *controller;
const struct ofpact_tunnel *tunnel;
+ const struct ofpact_inst_actions *inst_actions;
uint16_t port;
switch (a->type) {
@@ -1779,7 +1782,10 @@ ofpact_format(const struct ofpact *a, struct ds *s)
case OFPACT_RESUBMIT:
resubmit = ofpact_get_RESUBMIT(a);
- if (resubmit->in_port != OFPP_IN_PORT && resubmit->table_id == 255) {
+ if (resubmit->ofpact.compat == OFPUTIL_OFPIT11_GOTO_TABLE) {
+ ds_put_format(s, "goto_table:%"PRIu8, resubmit->table_id);
+ } else if (resubmit->in_port != OFPP_IN_PORT &&
+ resubmit->table_id == 255) {
ds_put_format(s, "resubmit:%"PRIu16, resubmit->in_port);
} else {
ds_put_format(s, "resubmit(");
@@ -1818,10 +1824,21 @@ ofpact_format(const struct ofpact *a, struct ds *s)
break;
case OFPACT_APPLY_ACTIONS:
+ ds_put_cstr(s, "apply_actions(");
+ inst_actions = ofpact_get_APPLY_ACTIONS(a);
+ ofpacts_format__(inst_actions->ofpacts, inst_actions->ofpacts_len, s);
+ ds_put_cstr(s, ")");
+ break;
+
case OFPACT_CLEAR_ACTIONS:
+ ds_put_cstr(s, "clear_actions");
+ break;
+
case OFPACT_WRITE_ACTIONS:
- /* TODO:XXX */
- NOT_REACHED();
+ ds_put_cstr(s, "write_actions(");
+ inst_actions = ofpact_get_WRITE_ACTIONS(a);
+ ofpacts_format__(inst_actions->ofpacts, inst_actions->ofpacts_len, s);
+ ds_put_cstr(s, ")");
break;
}
}
@@ -1840,13 +1857,10 @@ ofpact_is_instruction(const struct ofpact *a)
/* TODO:XXX meter, write_metadata */
}
-/* Appends a string representing the actions in 'ofpacts' (terminated by
- * OFPACT_END) to 'string'. */
-void
-ofpacts_format(const struct ofpact *ofpacts, size_t ofpacts_len,
- struct ds *string)
+static void
+ofpacts_format__(const struct ofpact *ofpacts, size_t ofpacts_len,
+ struct ds *string)
{
- ds_put_cstr(string, "actions=");
if (!ofpacts_len) {
ds_put_cstr(string, "drop");
} else {
@@ -1860,6 +1874,16 @@ ofpacts_format(const struct ofpact *ofpacts, size_t ofpacts_len,
}
}
}
+
+/* Appends a string representing the actions in 'ofpacts' (terminated by
+ * OFPACT_END) to 'string'. */
+void
+ofpacts_format(const struct ofpact *ofpacts, size_t ofpacts_len,
+ struct ds *string)
+{
+ ds_put_cstr(string, "actions=");
+ ofpacts_format__(ofpacts, ofpacts_len, string);
+}
/* Internal use by helpers. */
--
1.7.1.1
More information about the dev
mailing list