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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #include "vom/interface.hpp"
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");
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");
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");
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");
44 interface::type_t::from_string(const std::string& str)
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)) {
50 return interface::type_t::VHOST;
51 } else if (str.find("bond") != std::string::npos) {
52 return interface::type_t::BOND;
53 } else if (str.find("dpdk") != std::string::npos) {
54 return interface::type_t::ETHERNET;
55 } else if (str.find("VXLAN") != std::string::npos) {
56 return interface::type_t::VXLAN;
57 } else if ((str.find("Loopback") != std::string::npos) ||
58 (str.find("recirc") != std::string::npos)) {
59 return interface::type_t::LOOPBACK;
60 } else if (str.find("af-packet") != std::string::npos) {
61 return interface::type_t::AFPACKET;
62 } else if (str.find("local") != std::string::npos) {
63 return interface::type_t::LOCAL;
64 } else if ((str.find("tapcli") != std::string::npos) ||
65 (str.find("tuntap") != std::string::npos)) {
66 return interface::type_t::UNKNOWN;
67 } else if (str.find("virtio") != std::string::npos) {
68 return interface::type_t::TAPV2;
69 } else if (str.find("BVI") != std::string::npos) {
70 return interface::type_t::BVI;
71 } else if (str.find("Pipe") != std::string::npos) {
72 return interface::type_t::PIPE;
75 return interface::type_t::UNKNOWN;
78 interface::type_t::type_t(int v, const std::string& s)
79 : enum_base<interface::type_t>(v, s)
82 interface::oper_state_t::oper_state_t(int v, const std::string& s)
83 : enum_base<interface::oper_state_t>(v, s)
86 interface::admin_state_t::admin_state_t(int v, const std::string& s)
87 : enum_base<interface::admin_state_t>(v, s)
90 interface::stats_type_t::stats_type_t(int v, const std::string& s)
91 : enum_base<interface::stats_type_t>(v, s)
94 interface::admin_state_t
95 interface::admin_state_t::from_int(uint8_t v)
98 return (interface::admin_state_t::DOWN);
100 return (interface::admin_state_t::UP);
103 interface::oper_state_t
104 interface::oper_state_t::from_int(uint8_t v)
107 return (interface::oper_state_t::DOWN);
109 return (interface::oper_state_t::UP);
114 * fd.io coding-style-patch-verification: ON
117 * eval: (c-set-style "mozilla")