summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vom/interface_factory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vpp-api/vom/interface_factory.cpp')
-rw-r--r--src/vpp-api/vom/interface_factory.cpp54
1 files changed, 30 insertions, 24 deletions
diff --git a/src/vpp-api/vom/interface_factory.cpp b/src/vpp-api/vom/interface_factory.cpp
index cd2d373f0bf..b8815ed7ac9 100644
--- a/src/vpp-api/vom/interface_factory.cpp
+++ b/src/vpp-api/vom/interface_factory.cpp
@@ -20,14 +20,14 @@
#include "vom/tap_interface.hpp"
namespace VOM {
-std::unique_ptr<interface>
+std::shared_ptr<interface>
interface_factory::new_interface(const vapi_payload_sw_interface_details& vd)
{
- std::unique_ptr<interface> up_itf;
+ std::shared_ptr<interface> sp;
/**
- * Determine the interface type from the name and VLAN attributes
- */
+ * Determine the interface type from the name and VLAN attributes
+ */
std::string name = reinterpret_cast<const char*>(vd.interface_name);
interface::type_t type = interface::type_t::from_string(name);
interface::admin_state_t state =
@@ -37,48 +37,54 @@ interface_factory::new_interface(const vapi_payload_sw_interface_details& vd)
if (interface::type_t::AFPACKET == type) {
/*
- * need to strip VPP's "host-" prefix from the interface name
- */
+ * need to strip VPP's "host-" prefix from the interface name
+ */
name = name.substr(5);
}
/**
- * if the tag is set, then we wrote that to specify a name to make
- * the interface type more specific
- */
+ * if the tag is set, then we wrote that to specify a name to make
+ * the interface type more specific
+ */
if (vd.tag[0] != 0) {
name = std::string(reinterpret_cast<const char*>(vd.tag));
type = interface::type_t::from_string(name);
}
/*
- * pull out the other special cases
- */
+ * pull out the other special cases
+ */
if (interface::type_t::TAP == type) {
/*
- * TAP interface
- */
- up_itf.reset(new tap_interface(hdl, name, state, route::prefix_t()));
+ * TAP interface
+ */
+ sp = tap_interface(name, state, route::prefix_t()).singular();
} else if ((name.find(".") != std::string::npos) && (0 != vd.sub_id)) {
/*
- * Sub-interface
- * split the name into the parent and VLAN
- */
+ * Sub-interface
+ * split the name into the parent and VLAN
+ */
std::vector<std::string> parts;
boost::split(parts, name, boost::is_any_of("."));
interface parent(parts[0], type, state);
- up_itf.reset(new sub_interface(hdl, parent, state, vd.sub_id));
+ sp = sub_interface(parent, state, vd.sub_id).singular();
} else if (interface::type_t::VXLAN == type) {
/*
- * there's not enough inforation in a SW interface record to
- * construct
- * a VXLAN tunnel. so skip it.
- */
+ * there's not enough information in a SW interface record to
+ * construct a VXLAN tunnel. so skip it.
+ */
} else {
- up_itf.reset(new interface(hdl, l2_address, name, type, state));
+ sp = interface(name, type, state).singular();
+ sp->set(l2_address);
}
- return (up_itf);
+ /*
+ * set the handle on the intterface - N.B. this is the sigluar instance
+ * not a stack local.
+ */
+ sp->set(hdl);
+
+ return (sp);
}
}; // namespace VOM