#include <sys/uio.h>
#endif
-#include <net/if.h>
-
#include "gcancellable.h"
#include "gioenumtypes.h"
#include "ginetaddress.h"
static gboolean
g_socket_multicast_group_operation (GSocket *socket,
GInetAddress *group,
+ gboolean source_specific,
const gchar *interface,
gboolean join_group,
GError **error)
mc_req.imr_interface.s_addr = g_htonl (INADDR_ANY);
#endif
- optname = join_group ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
+ if (source_specific)
+ optname = join_group ? IP_ADD_SOURCE_MEMBERSHIP : IP_DROP_SOURCE_MEMBERSHIP;
+ else
+ optname = join_group ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
result = setsockopt (socket->priv->fd, IPPROTO_IP, optname,
&mc_req, sizeof (mc_req));
}
* @socket: a #GSocket.
* @group: a #GInetAddress specifying the group address to join.
* @interface: Interface to use
+ * @source_specific: %TRUE if source-specific multicast should be used
* @error: #GError for error reporting, or %NULL to ignore.
*
* Registers @socket to receive multicast messages sent to @group.
* been bound to an appropriate interface and port with
* g_socket_bind().
*
+ * If @source_specific is %TRUE, source-specific multicast as defined
+ * in RFC 4604 is used.
+ *
* Returns: %TRUE on success, %FALSE on error.
*
* Since: 2.32
gboolean
g_socket_join_multicast_group (GSocket *socket,
GInetAddress *group,
+ gboolean source_specific,
const gchar *interface,
GError **error)
{
- return g_socket_multicast_group_operation (socket, group, interface, TRUE, error);
+ return g_socket_multicast_group_operation (socket, group, source_specific, interface, TRUE, error);
}
/**
* @socket: a #GSocket.
* @group: a #GInetAddress specifying the group address to leave.
* @interface: Interface to use
+ * @source_specific: %TRUE if source-specific multicast should be used
* @error: #GError for error reporting, or %NULL to ignore.
*
* Removes @socket from the multicast group @group (while still
* allowing it to receive unicast messages).
*
+ * If @source_specific is %TRUE, source-specific multicast as defined
+ * in RFC 4604 is used.
+ *
* Returns: %TRUE on success, %FALSE on error.
*
* Since: 2.32
gboolean
g_socket_leave_multicast_group (GSocket *socket,
GInetAddress *group,
+ gboolean source_specific,
const gchar *interface,
GError **error)
{
- return g_socket_multicast_group_operation (socket, group, interface, FALSE, error);
+ return g_socket_multicast_group_operation (socket, group, source_specific, interface, FALSE, error);
}
/**