Skip to content

Commit 9c349c0

Browse files
committed
new ndp ctt refactor
1 parent cafd9af commit 9c349c0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

input/ndp.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,29 @@ void NdpPacketReader::init(const char *params)
9797
m_ctt_metadata = true;
9898
}
9999
init_ifc(parser.m_dev);
100+
m_device = parser.m_dev;
100101
}
101102

102103
void NdpPacketReader::close()
103104
{
104105
ndpReader.close();
105106
}
106107

108+
#ifdef WITH_CTT
109+
std::pair<std::string, unsigned> NdpPacketReader::get_ctt_config() const
110+
{
111+
std::string dev = m_device;
112+
int channel_id = 0;
113+
std::size_t delimiter_found = m_device.find_last_of(":");
114+
if (delimiter_found != std::string::npos) {
115+
std::string channel_str = m_device.substr(delimiter_found + 1);
116+
dev = m_device.substr(0, delimiter_found);
117+
channel_id = std::stoi(channel_str);
118+
}
119+
return std::make_pair(dev, channel_id);
120+
}
121+
#endif /* WITH_CTT */
122+
107123
void NdpPacketReader::init_ifc(const std::string &dev)
108124
{
109125
if (ndpReader.init_interface(dev) != 0) {

input/ndp.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ class NdpPacketReader : public InputPlugin
7373
std::shared_ptr<telemetry::Directory> plugin_dir,
7474
std::shared_ptr<telemetry::Directory> queues_dir) override;
7575

76+
#ifdef WITH_CTT
77+
virtual std::pair<std::string, unsigned> get_ctt_config() const override;
78+
#endif /* WITH_CTT */
79+
7680
private:
7781
struct RxStats {
7882
uint64_t receivedPackets;
@@ -87,6 +91,8 @@ class NdpPacketReader : public InputPlugin
8791

8892
bool m_ctt_metadata = false;
8993

94+
std::string m_device;
95+
9096
void init_ifc(const std::string &dev);
9197
int parse_ctt_metadata(const ndp_packet *ndp_packet, Metadata_CTT &ctt);
9298
};

0 commit comments

Comments
 (0)