Branch data Line data Source code
1 : : /*
2 : : * Copyright (c) 2010, 2011, 2012, 2013, 2015 Nicira, Inc.
3 : : *
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:
7 : : *
8 : : * http://www.apache.org/licenses/LICENSE-2.0
9 : : *
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.
15 : : */
16 : :
17 : : #include <config.h>
18 : : #include "dummy.h"
19 : : #include <string.h>
20 : : #include "util.h"
21 : :
22 : : /* Enables support for "dummy" network devices and dpifs, which are useful for
23 : : * testing. A client program might call this function if it is designed
24 : : * specifically for testing or the user enables it on the command line.
25 : : *
26 : : * 'arg' is parsed to determine the override level (see the definition of enum
27 : : * dummy_level).
28 : : *
29 : : * There is no strong reason why dummy devices shouldn't always be enabled. */
30 : : void
31 : 543 : dummy_enable(const char *arg)
32 : : {
33 : : enum dummy_level level;
34 : :
35 [ + + ][ - + ]: 543 : if (!arg || !arg[0]) {
36 : 461 : level = DUMMY_OVERRIDE_NONE;
37 [ + + ]: 82 : } else if (!strcmp(arg, "system")) {
38 : 81 : level = DUMMY_OVERRIDE_SYSTEM;
39 [ + - ]: 1 : } else if (!strcmp(arg, "override")) {
40 : 1 : level = DUMMY_OVERRIDE_ALL;
41 : : } else {
42 : 0 : ovs_fatal(0, "%s: unknown dummy level", arg);
43 : : }
44 : :
45 : 543 : netdev_dummy_register(level);
46 : 543 : dpif_dummy_register(level);
47 : 543 : timeval_dummy_register();
48 : 543 : ofpact_dummy_enable();
49 : 543 : }
50 : :
|