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"
22 const interface::type_t interface::type_t::UNKNOWN(0, "unknown");
23 const interface::type_t interface::type_t::BVI(1, "BVI");
24 const interface::type_t interface::type_t::ETHERNET(2, "Ehternet");
25 const interface::type_t interface::type_t::VXLAN(3, "VXLAN");
26 const interface::type_t interface::type_t::AFPACKET(4, "AFPACKET");
27 const interface::type_t interface::type_t::LOOPBACK(5, "LOOPBACK");
28 const interface::type_t interface::type_t::LOCAL(6, "LOCAL");
29 const interface::type_t interface::type_t::TAP(7, "TAP");
31 const interface::oper_state_t interface::oper_state_t::DOWN(0, "down");
32 const interface::oper_state_t interface::oper_state_t::UP(1, "up");
34 const interface::admin_state_t interface::admin_state_t::DOWN(0, "down");
35 const interface::admin_state_t interface::admin_state_t::UP(1, "up");
38 interface::type_t::from_string(const std::string& str)
40 if (str.find("Ethernet") != std::string::npos) {
41 return interface::type_t::ETHERNET;
42 } else if (str.find("vxlan") != std::string::npos) {
43 return interface::type_t::VXLAN;
44 } else if (str.find("loop") != std::string::npos) {
45 return interface::type_t::LOOPBACK;
46 } else if (str.find("host-") != std::string::npos) {
47 return interface::type_t::AFPACKET;
48 } else if (str.find("local") != std::string::npos) {
49 return interface::type_t::LOCAL;
50 } else if (str.find("tap") != std::string::npos) {
51 return interface::type_t::TAP;
52 } else if (str.find("bvi") != std::string::npos) {
53 return interface::type_t::BVI;
56 return interface::type_t::UNKNOWN;
59 interface::type_t::type_t(int v, const std::string& s)
60 : enum_base<interface::type_t>(v, s)
64 interface::oper_state_t::oper_state_t(int v, const std::string& s)
65 : enum_base<interface::oper_state_t>(v, s)
69 interface::admin_state_t::admin_state_t(int v, const std::string& s)
70 : enum_base<interface::admin_state_t>(v, s)
74 interface::admin_state_t
75 interface::admin_state_t::from_int(uint8_t v)
78 return (interface::admin_state_t::DOWN);
80 return (interface::admin_state_t::UP);
83 interface::oper_state_t
84 interface::oper_state_t::from_int(uint8_t v)
87 return (interface::oper_state_t::DOWN);
89 return (interface::oper_state_t::UP);
94 * fd.io coding-style-patch-verification: ON
97 * eval: (c-set-style "mozilla")