summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-02-28 14:32:57 +0200
committerimarom <imarom@cisco.com>2016-02-28 14:33:26 +0200
commit21fe2befe8806ac2a70cfb1d1c45737bee7e2702 (patch)
tree4a774d3a156f3418ea22a2ad88602056eb77fab6 /src/common
parentb83eb43c25f0452c152d31966da4b1af5c304a6b (diff)
more info for ports (API and TUI)
Diffstat (limited to 'src/common')
-rwxr-xr-xsrc/common/basic_utils.cpp14
-rwxr-xr-xsrc/common/basic_utils.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/src/common/basic_utils.cpp b/src/common/basic_utils.cpp
index 1cd5ce8f..34c37755 100755
--- a/src/common/basic_utils.cpp
+++ b/src/common/basic_utils.cpp
@@ -160,4 +160,18 @@ void TestDump(void){
utl_DumpBuffer2(stdout,buffer,31,1,4,SHOW_BUFFER_ADDR_EN |SHOW_BUFFER_CHAR);
}
+void utl_macaddr_to_str(const uint8_t *macaddr, std::string &output) {
+
+ 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;
+ }
+
+}
diff --git a/src/common/basic_utils.h b/src/common/basic_utils.h
index 4bd208d3..77282eea 100755
--- a/src/common/basic_utils.h
+++ b/src/common/basic_utils.h
@@ -85,6 +85,7 @@ inline void utl_swap(T& a, T& b) {
bool utl_is_file_exists (const std::string& name) ;
+void utl_macaddr_to_str(const uint8_t *macaddr, std::string &output);
#endif