2 * Copyright (c) 2011 Nicira, Inc.
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"
33 vlog_set_levels_from_string("odp_util:console:dbg");
34 while (!ds_get_line(&in, stdin)) {
35 enum odp_key_fitness fitness;
36 struct ofpbuf odp_key;
42 /* Delete comments, skip blank lines. */
49 *strchr(s, '#') = '\0';
51 if (s[strspn(s, " ")] == '\0') {
56 /* Convert string to OVS DP key. */
57 ofpbuf_init(&odp_key, 0);
58 error = odp_flow_key_from_string(ds_cstr(&in), NULL, &odp_key);
60 printf("odp_flow_key_from_string: error\n");
64 /* Convert odp_key to flow. */
65 fitness = odp_flow_key_to_flow(odp_key.data, odp_key.size, &flow);
70 case ODP_FIT_TOO_LITTLE:
71 printf("ODP_FIT_TOO_LITTLE: ");
74 case ODP_FIT_TOO_MUCH:
75 printf("ODP_FIT_TOO_MUCH: ");
79 printf("odp_flow_key_to_flow: error\n");
83 /* Convert cls_rule back to odp_key. */
84 ofpbuf_uninit(&odp_key);
85 ofpbuf_init(&odp_key, 0);
86 odp_flow_key_from_flow(&odp_key, &flow);
88 /* Convert odp_key to string. */
90 odp_flow_key_format(odp_key.data, odp_key.size, &out);
95 ofpbuf_uninit(&odp_key);