summaryrefslogtreecommitdiffstats
path: root/src/stateless
diff options
context:
space:
mode:
Diffstat (limited to 'src/stateless')
-rw-r--r--src/stateless/cp/trex_stateless_port.cpp21
-rw-r--r--src/stateless/cp/trex_stateless_port.h1
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: