2 * Copyright (c) 2011 Nicira Networks.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "dynamic-string.h"
32 while (!ds_get_line(&in, stdin)) {
33 struct ofpbuf odp_key;
39 /* Delete comments, skip blank lines. */
46 *strchr(s, '#') = '\0';
48 if (s[strspn(s, " ")] == '\0') {
53 /* Convert string to OVS DP key. */
54 ofpbuf_init(&odp_key, 0);
55 error = odp_flow_key_from_string(ds_cstr(&in), &odp_key);
57 printf("odp_flow_key_from_string: error\n");
61 /* Convert odp_key to flow. */
62 error = odp_flow_key_to_flow(odp_key.data, odp_key.size, &flow);
64 printf("odp_flow_key_to_flow: error\n");
68 /* Convert cls_rule back to odp_key. */
69 ofpbuf_uninit(&odp_key);
70 ofpbuf_init(&odp_key, 0);
71 odp_flow_key_from_flow(&odp_key, &flow);
73 /* Convert odp_key to string. */
75 odp_flow_key_format(odp_key.data, odp_key.size, &out);
80 ofpbuf_uninit(&odp_key);