+\f
+/* Undocumented commands for unit testing. */
+
+static void
+do_parse_flows(int argc OVS_UNUSED, char *argv[])
+{
+ enum nx_flow_format flow_format;
+ struct list packets;
+ FILE *file;
+
+ file = fopen(argv[1], "r");
+ if (file == NULL) {
+ ovs_fatal(errno, "%s: open", argv[2]);
+ }
+
+ list_init(&packets);
+ flow_format = NXFF_OPENFLOW10;
+ if (preferred_flow_format > 0) {
+ flow_format = preferred_flow_format;
+ }
+
+ while (parse_ofp_add_flow_file(&packets, &flow_format, file)) {
+ struct ofpbuf *packet, *next;
+
+ LIST_FOR_EACH_SAFE (packet, next, list_node, &packets) {
+ ofp_print(stdout, packet->data, packet->size, verbosity);
+ list_remove(&packet->list_node);
+ ofpbuf_delete(packet);
+ }
+ }
+ fclose(file);
+}
+
+static void
+do_parse_nx_match(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
+{
+ struct ds in;
+
+ ds_init(&in);
+ while (!ds_get_line(&in, stdin)) {
+ struct ofpbuf nx_match;
+ struct cls_rule rule;
+ int match_len;
+ int error;
+ char *s;
+
+ /* Delete comments, skip blank lines. */
+ s = ds_cstr(&in);
+ if (*s == '#') {
+ puts(s);
+ continue;
+ }
+ if (strchr(s, '#')) {
+ *strchr(s, '#') = '\0';
+ }
+ if (s[strspn(s, " ")] == '\0') {
+ putchar('\n');
+ continue;
+ }
+
+ /* Convert string to nx_match. */
+ ofpbuf_init(&nx_match, 0);
+ match_len = nx_match_from_string(ds_cstr(&in), &nx_match);
+
+ /* Convert nx_match to cls_rule. */
+ error = nx_pull_match(&nx_match, match_len, 0, &rule);
+ if (!error) {
+ char *out;
+
+ /* Convert cls_rule back to nx_match. */
+ ofpbuf_uninit(&nx_match);
+ ofpbuf_init(&nx_match, 0);
+ match_len = nx_put_match(&nx_match, &rule);
+
+ /* Convert nx_match to string. */
+ out = nx_match_to_string(nx_match.data, match_len);
+ puts(out);
+ free(out);
+ } else {
+ printf("nx_pull_match() returned error %x\n", error);
+ }
+
+ ofpbuf_uninit(&nx_match);
+ }
+ ds_destroy(&in);
+}