FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
interface_types.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "vom/interface.hpp"
17 namespace VOM {
18 /*
19  * constants and enums
20  */
21 const interface::type_t interface::type_t::UNKNOWN(0, "unknown");
22 const interface::type_t interface::type_t::BVI(1, "BVI");
23 const interface::type_t interface::type_t::ETHERNET(2, "Ethernet");
24 const interface::type_t interface::type_t::VXLAN(3, "VXLAN");
25 const interface::type_t interface::type_t::AFPACKET(4, "AFPACKET");
26 const interface::type_t interface::type_t::LOOPBACK(5, "LOOPBACK");
27 const interface::type_t interface::type_t::LOCAL(6, "LOCAL");
28 const interface::type_t interface::type_t::TAPV2(7, "TAPV2");
29 const interface::type_t interface::type_t::VHOST(8, "VHOST");
30 const interface::type_t interface::type_t::BOND(9, "Bond");
31 const interface::type_t interface::type_t::PIPE(10, "Pipe");
32 const interface::type_t interface::type_t::PIPE_END(11, "Pipe-end");
33 
34 const interface::oper_state_t interface::oper_state_t::DOWN(0, "down");
35 const interface::oper_state_t interface::oper_state_t::UP(1, "up");
36 
37 const interface::admin_state_t interface::admin_state_t::DOWN(0, "down");
38 const interface::admin_state_t interface::admin_state_t::UP(1, "up");
39 
40 const interface::stats_type_t interface::stats_type_t::DETAILED(0, "detailed");
41 const interface::stats_type_t interface::stats_type_t::NORMAL(1, "normal");
42 
43 interface::type_t
45 {
46  if ((str.find("Virtual") != std::string::npos) ||
47  (str.find("vhost") != std::string::npos) ||
48  (str.find("vhu") != std::string::npos) ||
49  (str.find("vhost-user") != std::string::npos)) {
51  } else if (str.find("bond") != std::string::npos) {
53  } else if (str.find("dpdk") != std::string::npos) {
55  } else if (str.find("VXLAN") != std::string::npos) {
57  } else if ((str.find("Loopback") != std::string::npos) ||
58  (str.find("recirc") != std::string::npos)) {
60  } else if (str.find("af-packet") != std::string::npos) {
62  } else if (str.find("local") != std::string::npos) {
64  } else if ((str.find("tapcli") != std::string::npos) ||
65  (str.find("tuntap") != std::string::npos)) {
67  } else if (str.find("virtio") != std::string::npos) {
69  } else if (str.find("BVI") != std::string::npos) {
71  } else if (str.find("Pipe") != std::string::npos) {
73  }
74 
76 }
77 
78 interface::type_t::type_t(int v, const std::string& s)
79  : enum_base<interface::type_t>(v, s)
80 {}
81 
82 interface::oper_state_t::oper_state_t(int v, const std::string& s)
83  : enum_base<interface::oper_state_t>(v, s)
84 {}
85 
86 interface::admin_state_t::admin_state_t(int v, const std::string& s)
87  : enum_base<interface::admin_state_t>(v, s)
88 {}
89 
90 interface::stats_type_t::stats_type_t(int v, const std::string& s)
91  : enum_base<interface::stats_type_t>(v, s)
92 {}
93 
94 interface::admin_state_t
96 {
97  if (0 == v) {
99  }
101 }
102 
105 {
106  if (0 == v) {
108  }
110 }
111 }
112 
113 /*
114  * fd.io coding-style-patch-verification: OFF
115  *
116  * Local Variables:
117  * eval: (c-set-style "mozilla")
118  * End:
119  */
VOM::interface::type_t::BVI
const static type_t BVI
A brideged Virtual interface (aka SVI or IRB)
Definition: interface.hpp:76
VOM::interface::oper_state_t::from_int
static oper_state_t from_int(uint8_t val)
Convert VPP's numerical value to enum type.
Definition: interface_types.cpp:104
VOM
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
VOM::interface::type_t::VXLAN
const static type_t VXLAN
VXLAN interface.
Definition: interface.hpp:80
VOM::interface::type_t::from_string
static type_t from_string(const std::string &str)
Convert VPP's name of the interface to a type.
Definition: interface_types.cpp:44
VOM::interface::type_t::LOCAL
const static type_t LOCAL
Local interface type (specific to VPP)
Definition: interface.hpp:96
VOM::interface::type_t::LOOPBACK
const static type_t LOOPBACK
loopback interface type
Definition: interface.hpp:92
VOM::interface::type_t::BOND
const static type_t BOND
bond interface type
Definition: interface.hpp:111
VOM::interface::type_t::PIPE
const static type_t PIPE
pipe-parent type
Definition: interface.hpp:116
VOM::interface::stats_type_t::DETAILED
const static stats_type_t DETAILED
Definition: interface.hpp:46
VOM::interface::type_t::ETHERNET
const static type_t ETHERNET
Ethernet interface type.
Definition: interface.hpp:84
VOM::enum_base
A template base class for all enum types.
Definition: enum_base.hpp:30
VOM::interface::oper_state_t::UP
const static oper_state_t UP
Operational UP state.
Definition: interface.hpp:173
VOM::interface
A representation of an interface in VPP.
Definition: interface.hpp:41
VOM::interface::type_t::AFPACKET
const static type_t AFPACKET
AF-Packet interface type.
Definition: interface.hpp:88
VOM::interface::type_t::VHOST
const static type_t VHOST
vhost-user interface type
Definition: interface.hpp:106
VOM::interface::admin_state_t::from_int
static admin_state_t from_int(uint8_t val)
Convert VPP's numerical value to enum type.
Definition: interface_types.cpp:95
VOM::interface::interface
interface(const std::string &name, type_t type, admin_state_t state, const std::string &tag="")
Construct a new object matching the desried state.
Definition: interface.cpp:51
VOM::interface::type_t::TAPV2
const static type_t TAPV2
TAPv2 interface type.
Definition: interface.hpp:101
VOM::interface::admin_state_t::DOWN
const static admin_state_t DOWN
Admin DOWN state.
Definition: interface.hpp:143
VOM::interface::type_t
An interface type.
Definition: interface.hpp:67
VOM::interface::oper_state_t
The oper state of the interface.
Definition: interface.hpp:164
interface.hpp
VOM::interface::type_t::UNKNOWN
const static type_t UNKNOWN
Unknown type.
Definition: interface.hpp:72
VOM::interface::stats_type_t::NORMAL
const static stats_type_t NORMAL
Definition: interface.hpp:47
VOM::interface::type_t::PIPE_END
const static type_t PIPE_END
pipe-end type
Definition: interface.hpp:121
VOM::interface::admin_state_t::UP
const static admin_state_t UP
Admin UP state.
Definition: interface.hpp:147
string
const char *const string
Definition: cJSON.h:172
VOM::interface::oper_state_t::DOWN
const static oper_state_t DOWN
Operational DOWN state.
Definition: interface.hpp:169