summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vom/interface_factory.cpp
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2017-11-28 22:29:13 -0800
committerNeale Ranns <nranns@cisco.com>2017-11-29 07:42:52 +0000
commita2ee029d0772e894911c84fb8a0cab5f253e145b (patch)
tree167d07ee3b3a482ef494f420ceef13a9657d4274 /src/vpp-api/vom/interface_factory.cpp
parente80ae9ea8ed04c82c151a548916926b5dbfe8ecb (diff)
VOM: logging, populate and stats fixes
logging: allow a client to register a callback handler to recieve log messages that way the client can maintain a correctly sequenced log populate: fix the creation of interface and the setting of the handle stats: the reset promise idea is not defined behaviour. Use an eanble/disable command pair Change-Id: I347720bb65df2874c7619e722d593bc863ee2bf1 Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
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