diff options
author | imarom <imarom@cisco.com> | 2016-02-28 04:30:11 -0500 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-02-28 04:30:58 -0500 |
commit | 5f17c48a1f6f7006cbb6e1b17eca2ebd6b682b78 (patch) | |
tree | d1af472bbc92962e6cf4757cf7da09bcd73edf82 /src/stateless | |
parent | 2f42eda77b027f5c9d39cba48373d75c0e1e2155 (diff) |
support for mac addr query
Diffstat (limited to 'src/stateless')
-rw-r--r-- | src/stateless/cp/trex_stateless_port.cpp | 21 | ||||
-rw-r--r-- | src/stateless/cp/trex_stateless_port.h | 1 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/stateless/cp/trex_stateless_port.cpp b/src/stateless/cp/trex_stateless_port.cpp index 43f32d22..01733117 100644 --- a/src/stateless/cp/trex_stateless_port.cpp +++ b/src/stateless/cp/trex_stateless_port.cpp @@ -679,7 +679,28 @@ TrexStatelessPort::get_promiscuous() { } +std::string +TrexStatelessPort::get_macaddr() { + uint8_t macaddr[6]; + std::string output; + get_stateless_obj()->get_platform_api()->get_macaddr(m_port_id, macaddr); + + for (int i = 0; i < 6; i++) { + char formatted[4]; + + if (i == 0) { + snprintf(formatted, sizeof(formatted), "%02x", macaddr[i]); + } else { + snprintf(formatted, sizeof(formatted), ":%02x", macaddr[i]); + } + + output += formatted; + } + + return output; + +} void TrexStatelessPort::add_stream(TrexStream *stream) { diff --git a/src/stateless/cp/trex_stateless_port.h b/src/stateless/cp/trex_stateless_port.h index 1d3eebc3..0d626375 100644 --- a/src/stateless/cp/trex_stateless_port.h +++ b/src/stateless/cp/trex_stateless_port.h @@ -331,6 +331,7 @@ public: */ void set_promiscuous(bool enabled); bool get_promiscuous(); + std::string get_macaddr(); private: |