aboutsummaryrefslogtreecommitdiffstats
path: root/src/VppUtil.cpp
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2019-06-19 08:30:46 -0700
committerNeale Ranns <nranns@cisco.com>2019-06-26 16:41:01 +0000
commita83d9d67113dc75d21a68dba14891ed5e1bea7ec (patch)
tree829b8724c836bc48be1a45901291df129d678f69 /src/VppUtil.cpp
parentef426ed7714e87cee2097ed5245a78b92a0158ce (diff)
Initial Commit of VPP OPflex Renderer
Change-Id: I6264537538ad2646cddfa404de38a6bbf3abaa35 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/VppUtil.cpp')
-rw-r--r--src/VppUtil.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/VppUtil.cpp b/src/VppUtil.cpp
new file mode 100644
index 0000000..9874923
--- /dev/null
+++ b/src/VppUtil.cpp
@@ -0,0 +1,47 @@
+/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */
+/*
+ * Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+#include <string>
+
+#include "VppUtil.hpp"
+
+namespace VPP
+{
+const interface::type_t &
+getIntfTypeFromName(const std::string &name)
+{
+ if (name.find("Bond") != std::string::npos)
+ return interface::type_t::BOND;
+ else if (name.find("Ethernet") != std::string::npos)
+ return interface::type_t::ETHERNET;
+ else if ((name.find("tapv2") != std::string::npos) ||
+ (name.find("tap") != std::string::npos))
+ return interface::type_t::TAPV2;
+ else if ((name.find("vhost") != std::string::npos) ||
+ (name.find("vhu") != std::string::npos))
+ return interface::type_t::VHOST;
+
+ return interface::type_t::AFPACKET;
+}
+
+boost::optional<mac_address_t>
+mac_from_modb(boost::optional<const opflex::modb::MAC &> mo)
+{
+ if (!mo) return boost::none;
+
+ return (mac_address_t(mo->toString()));
+}
+
+}; // namespace VPP
+
+/*
+ * Local Variables:
+ * eval: (c-set-style "llvm.org")
+ * End:
+ */