gboolean
gssdp_socket_enable_loop (GSocket *socket,
- gboolean enable,
+ gboolean _enable,
GError **error) {
+#if defined(__OpenBSD__)
+ guint8 enable = (guint8) _enable;
+#else
+ gboolean enable = _enable;
+#endif
return gssdp_socket_option_set (socket,
IPPROTO_IP,
IP_MULTICAST_LOOP,
gboolean
gssdp_socket_set_ttl (GSocket *socket,
- int ttl,
+ int _ttl,
GError **error) {
+#if defined(__OpenBSD__)
+ guint8 ttl = (guint8) _ttl;
+#else
+ int ttl = _ttl;
+#endif
return gssdp_socket_option_set (socket,
IPPROTO_IP,
IP_MULTICAST_TTL,
error);
}
-#ifdef G_OS_WIN32
gboolean
gssdp_socket_reuse_address (GSocket *socket,
gboolean enable,
GError **error) {
+#if defined(G_OS_WIN32) || defined(__OpenBSD__)
return gssdp_socket_option_set (socket,
SOL_SOCKET,
+#if defined(__OpenBSD__)
+ SO_REUSEPORT,
+#else
SO_REUSEADDR,
+#endif
+
(char *) &enable,
sizeof (enable),
error);
-}
#endif
+ return TRUE;
+}
/*
port);
}
-#ifdef G_OS_WIN32
- /* normally g_socket_bind does this, but it is disabled on
+ /* Normally g_socket_bind does this, but it is disabled on
* windows since SO_REUSEADDR has different semantics
- * there. Nevertheless, there's no way without for
- * multicast sockets
+ * there, also we nees SO_REUSEPORT on OpenBSD. This is a nop
+ * everywhere else.
*/
if (!gssdp_socket_reuse_address (self->priv->socket,
TRUE,
goto error;
}
-#endif
+
/* Bind to requested port and address */
if (!g_socket_bind (self->priv->socket,
bind_address,