]>
git.proxmox.com Git - ovs.git/blob - tests/test-odp.c
2 * Copyright (c) 2011, 2012, 2013 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"
35 vlog_set_levels_from_string_assert("odp_util:console:dbg");
36 while (!ds_get_test_line(&in
, stdin
)) {
37 enum odp_key_fitness fitness
;
38 struct ofpbuf odp_key
;
43 /* Convert string to OVS DP key. */
44 ofpbuf_init(&odp_key
, 0);
45 error
= odp_flow_key_from_string(ds_cstr(&in
), NULL
, &odp_key
);
47 printf("odp_flow_key_from_string: error\n");
51 /* Convert odp_key to flow. */
52 fitness
= odp_flow_key_to_flow(odp_key
.data
, odp_key
.size
, &flow
);
57 case ODP_FIT_TOO_LITTLE
:
58 printf("ODP_FIT_TOO_LITTLE: ");
61 case ODP_FIT_TOO_MUCH
:
62 printf("ODP_FIT_TOO_MUCH: ");
66 printf("odp_flow_key_to_flow: error\n");
70 /* Convert cls_rule back to odp_key. */
71 ofpbuf_uninit(&odp_key
);
72 ofpbuf_init(&odp_key
, 0);
73 odp_flow_key_from_flow(&odp_key
, &flow
, flow
.in_port
);
75 if (odp_key
.size
> ODPUTIL_FLOW_KEY_BYTES
) {
76 printf ("too long: %zu > %d\n",
77 odp_key
.size
, ODPUTIL_FLOW_KEY_BYTES
);
81 /* Convert odp_key to string. */
83 odp_flow_key_format(odp_key
.data
, odp_key
.size
, &out
);
88 ofpbuf_uninit(&odp_key
);
101 vlog_set_levels_from_string_assert("odp_util:console:dbg");
102 while (!ds_get_test_line(&in
, stdin
)) {
103 struct ofpbuf odp_actions
;
107 /* Convert string to OVS DP actions. */
108 ofpbuf_init(&odp_actions
, 0);
109 error
= odp_actions_from_string(ds_cstr(&in
), NULL
, &odp_actions
);
111 printf("odp_actions_from_string: error\n");
115 /* Convert odp_actions back to string. */
117 format_odp_actions(&out
, odp_actions
.data
, odp_actions
.size
);
122 ofpbuf_uninit(&odp_actions
);
130 main(int argc
, char *argv
[])
132 if (argc
== 2 &&!strcmp(argv
[1], "parse-keys")) {
134 } else if (argc
== 2 && !strcmp(argv
[1], "parse-actions")) {
135 return parse_actions();
137 ovs_fatal(0, "usage: %s parse-keys | parse-actions", argv
[0]);