Merge pull request #2827 from xmcclure/profile-clean-0.1
[mono.git] / mono / utils / networking.c
index 470455d5e7ee074673e6057228b949ebebf5dd34..bd461b01f1631443c3c6a70773424eebee1635dc 100644 (file)
 #include <mono/utils/networking.h>
 #include <glib.h>
 
+int
+mono_address_size_for_family (int family)
+{
+       switch (family) {
+       case AF_INET:
+               return sizeof (struct in_addr);
+       case AF_INET6:
+               return sizeof (struct in6_addr);
+       }
+       return 0;
+}
+
+
 void
 mono_free_address_info (MonoAddressInfo *ai)
 {
@@ -52,3 +65,11 @@ mono_socket_address_init (MonoSocketAddress *sa, socklen_t *len, int family, con
                g_error ("Cannot handle address family %d", family);
        }
 }
+
+void
+mono_address_init (MonoAddress *out_addr, int family, void *in_addr)
+{
+       memset (out_addr, 0, sizeof (MonoAddress));
+       out_addr->family = family;
+       memcpy (&out_addr->addr, in_addr, mono_address_size_for_family (family));
+}