if OS_WIN32
appinfo_sources += gwin32appinfo.c gwin32appinfo.h
-platform_libadd += -lshlwapi -lws2_32 -ldnsapi
+platform_libadd += -lshlwapi -lws2_32 -ldnsapi -liphlpapi
win32_sources = $(win32_actual_sources)
giowin32includedir=$(includedir)/gio-win32-2.0/gio
return TRUE;
}
+#if !defined(HAVE_IF_NAMETOINDEX) && defined(G_OS_WIN32)
+static guint
+if_nametoindex (const gchar *iface)
+{
+ PIP_ADAPTER_ADDRESSES addresses = NULL, p;
+ gulong addresses_len = 0;
+ guint idx = 0;
+ DWORD res;
+
+ res = GetAdaptersAddresses (AF_UNSPEC, 0, NULL, NULL, &addresses_len);
+ if (res != NO_ERROR && res != ERROR_BUFFER_OVERFLOW)
+ {
+ if (res == ERROR_NO_DATA)
+ errno = ENXIO;
+ else
+ errno = EINVAL;
+ return 0;
+ }
+
+ addresses = g_malloc (addresses_len);
+ res = GetAdaptersAddresses (AF_UNSPEC, 0, NULL, addresses, &addresses_len);
+
+ if (res != NO_ERROR)
+ {
+ g_free (addresses);
+ if (res == ERROR_NO_DATA)
+ errno = ENXIO;
+ else
+ errno = EINVAL;
+ return 0;
+ }
+
+ p = addresses;
+ while (p)
+ {
+ if (strcmp (p->AdapterName, iface) == 0)
+ {
+ idx = p->IfIndex;
+ break;
+ }
+ p = p->Next;
+ }
+
+ if (p == NULL)
+ errno = ENXIO;
+
+ g_free (addresses);
+
+ return idx;
+}
+
+#define HAVE_IF_NAMETOINDEX 1
+#endif
+
static gboolean
g_socket_multicast_group_operation (GSocket *socket,
GInetAddress *group,
mc_req.imr_ifindex = if_nametoindex (iface);
else
mc_req.imr_ifindex = 0; /* Pick any. */
+#elif defined(G_OS_WIN32)
+ if (iface)
+ mc_req.imr_interface.s_addr = g_htonl (if_nametoindex (iface));
+ else
+ mc_req.imr_interface.s_addr = g_htonl (INADDR_ANY);
#else
mc_req.imr_interface.s_addr = g_htonl (INADDR_ANY);
#endif