#ifndef DISABLE_SOCKETS
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
#define __APPLE_USE_RFC_3542
#endif
#include <glib.h>
#include <string.h>
#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <errno.h>
-
-#include <sys/types.h>
#ifdef HOST_WIN32
#include <ws2tcpip.h>
#else
#include <netdb.h>
#include <arpa/inet.h>
#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#include <errno.h>
+
+#include <sys/types.h>
#include <mono/metadata/object.h>
#include <mono/io-layer/io-layer.h>
#define AI_ADDRCONFIG 0
#endif
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
/*
* We remove this until we have a Darwin implementation
* that can walk the result of struct ifconf. The current
/* Need a byte for the '\0' terminator/prefix, and the first
* two bytes hold the SocketAddress family
*/
- if (len - 2 >= MONO_SIZEOF_SUNPATH) {
+ if (len - 2 >= sizeof(sock_un->sun_path)) {
mono_raise_exception (mono_get_exception_index_out_of_range ());
}
void ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal(SOCKET sock, gint32 level, gint32 name, MonoObject **obj_val, gint32 *error)
{
- int system_level;
- int system_name;
+ int system_level = 0;
+ int system_name = 0;
int ret;
int val;
socklen_t valsize=sizeof(val);
void ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal(SOCKET sock, gint32 level, gint32 name, MonoArray **byte_val, gint32 *error)
{
- int system_level;
- int system_name;
+ int system_level = 0;
+ int system_name = 0;
int ret;
guchar *buf;
socklen_t valsize;
#endif /* AF_INET6 */
#endif
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__FreeBSD__)
#if defined(HAVE_GETIFADDRS) && defined(HAVE_IF_NAMETOINDEX)
static int
}
#endif
-#endif /* __APPLE__ */
+#endif /* defined(__APPLE__) || defined(__FreeBSD__) */
void ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal(SOCKET sock, gint32 level, gint32 name, MonoObject *obj_val, MonoArray *byte_val, gint32 int_val, gint32 *error)
{
struct linger linger;
- int system_level;
- int system_name;
+ int system_level = 0;
+ int system_name = 0;
int ret;
#ifdef AF_INET6
int sol_ip;
field=mono_class_get_field_from_name(obj_val->vtable->klass, "ifIndex");
mreq6.ipv6mr_interface =*(guint64 *)(((char *)obj_val)+field->offset);
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__FreeBSD__)
/*
* Bug #5504:
*
hints.ai_flags = AI_CANONNAME;
if (*hostname && getaddrinfo(hostname, NULL, &hints, &info) == -1) {
+ g_free (hostname);
return(FALSE);
}
#else
he = _wapi_gethostbyname (hostname);
#endif
- g_free(hostname);
- if (*hostname && he==NULL)
+ if (*hostname && he==NULL) {
+ g_free (hostname);
return(FALSE);
+ }
+
+ g_free (hostname);
return(hostent_to_IPHostEntry(he, h_name, h_aliases, h_addr_list, add_local_ips));
}