Removed Common
Change-Id: I01ea8f07220375c2ad9bc0092281d4f27c642303
diff --git a/aos/util/inet_addr.cc b/aos/util/inet_addr.cc
new file mode 100644
index 0000000..edb7dbb
--- /dev/null
+++ b/aos/util/inet_addr.cc
@@ -0,0 +1,41 @@
+#include "aos/util/inet_addr.h"
+
+#include <stdlib.h>
+#ifndef __VXWORKS__
+#include <string.h>
+
+#include "aos/byteorder.h"
+#else
+
+template<typename T>
+T hton(T);
+
+template<uint32_t>
+uint32_t hton(uint32_t v) { return v; }
+
+#endif
+
+namespace aos {
+namespace util {
+
+const char *MakeIPAddress(const in_addr &base_address,
+ ::aos::NetworkAddress last_segment) {
+ in_addr address = base_address;
+ SetLastSegment(&address, last_segment);
+
+#ifdef __VXWORKS__
+ char *r = static_cast<char *>(malloc(INET_ADDR_LEN));
+ inet_ntoa_b(address, r);
+ return r;
+#else
+ return strdup(inet_ntoa(address));
+#endif
+}
+
+void SetLastSegment(in_addr *address, ::aos::NetworkAddress last_segment) {
+ address->s_addr &= ~(hton<uint32_t>(0xFF));
+ address->s_addr |= hton<uint32_t>(static_cast<uint8_t>(last_segment));
+}
+
+} // namespace util
+} // namespace aos