mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
GSocket: Add support for source-specific multicast (RFC 4604)
This commit is contained in:
parent
97f25892ea
commit
03b40522df
@ -47,8 +47,6 @@
|
|||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <net/if.h>
|
|
||||||
|
|
||||||
#include "gcancellable.h"
|
#include "gcancellable.h"
|
||||||
#include "gioenumtypes.h"
|
#include "gioenumtypes.h"
|
||||||
#include "ginetaddress.h"
|
#include "ginetaddress.h"
|
||||||
@ -1690,6 +1688,7 @@ g_socket_bind (GSocket *socket,
|
|||||||
static gboolean
|
static gboolean
|
||||||
g_socket_multicast_group_operation (GSocket *socket,
|
g_socket_multicast_group_operation (GSocket *socket,
|
||||||
GInetAddress *group,
|
GInetAddress *group,
|
||||||
|
gboolean source_specific,
|
||||||
const gchar *interface,
|
const gchar *interface,
|
||||||
gboolean join_group,
|
gboolean join_group,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -1725,7 +1724,10 @@ g_socket_multicast_group_operation (GSocket *socket,
|
|||||||
mc_req.imr_interface.s_addr = g_htonl (INADDR_ANY);
|
mc_req.imr_interface.s_addr = g_htonl (INADDR_ANY);
|
||||||
#endif
|
#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,
|
result = setsockopt (socket->priv->fd, IPPROTO_IP, optname,
|
||||||
&mc_req, sizeof (mc_req));
|
&mc_req, sizeof (mc_req));
|
||||||
}
|
}
|
||||||
@ -1766,6 +1768,7 @@ g_socket_multicast_group_operation (GSocket *socket,
|
|||||||
* @socket: a #GSocket.
|
* @socket: a #GSocket.
|
||||||
* @group: a #GInetAddress specifying the group address to join.
|
* @group: a #GInetAddress specifying the group address to join.
|
||||||
* @interface: Interface to use
|
* @interface: Interface to use
|
||||||
|
* @source_specific: %TRUE if source-specific multicast should be used
|
||||||
* @error: #GError for error reporting, or %NULL to ignore.
|
* @error: #GError for error reporting, or %NULL to ignore.
|
||||||
*
|
*
|
||||||
* Registers @socket to receive multicast messages sent to @group.
|
* Registers @socket to receive multicast messages sent to @group.
|
||||||
@ -1773,6 +1776,9 @@ g_socket_multicast_group_operation (GSocket *socket,
|
|||||||
* been bound to an appropriate interface and port with
|
* been bound to an appropriate interface and port with
|
||||||
* g_socket_bind().
|
* 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.
|
* Returns: %TRUE on success, %FALSE on error.
|
||||||
*
|
*
|
||||||
* Since: 2.32
|
* Since: 2.32
|
||||||
@ -1780,10 +1786,11 @@ g_socket_multicast_group_operation (GSocket *socket,
|
|||||||
gboolean
|
gboolean
|
||||||
g_socket_join_multicast_group (GSocket *socket,
|
g_socket_join_multicast_group (GSocket *socket,
|
||||||
GInetAddress *group,
|
GInetAddress *group,
|
||||||
|
gboolean source_specific,
|
||||||
const gchar *interface,
|
const gchar *interface,
|
||||||
GError **error)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1791,11 +1798,15 @@ g_socket_join_multicast_group (GSocket *socket,
|
|||||||
* @socket: a #GSocket.
|
* @socket: a #GSocket.
|
||||||
* @group: a #GInetAddress specifying the group address to leave.
|
* @group: a #GInetAddress specifying the group address to leave.
|
||||||
* @interface: Interface to use
|
* @interface: Interface to use
|
||||||
|
* @source_specific: %TRUE if source-specific multicast should be used
|
||||||
* @error: #GError for error reporting, or %NULL to ignore.
|
* @error: #GError for error reporting, or %NULL to ignore.
|
||||||
*
|
*
|
||||||
* Removes @socket from the multicast group @group (while still
|
* Removes @socket from the multicast group @group (while still
|
||||||
* allowing it to receive unicast messages).
|
* 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.
|
* Returns: %TRUE on success, %FALSE on error.
|
||||||
*
|
*
|
||||||
* Since: 2.32
|
* Since: 2.32
|
||||||
@ -1803,10 +1814,11 @@ g_socket_join_multicast_group (GSocket *socket,
|
|||||||
gboolean
|
gboolean
|
||||||
g_socket_leave_multicast_group (GSocket *socket,
|
g_socket_leave_multicast_group (GSocket *socket,
|
||||||
GInetAddress *group,
|
GInetAddress *group,
|
||||||
|
gboolean source_specific,
|
||||||
const gchar *interface,
|
const gchar *interface,
|
||||||
GError **error)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,10 +113,12 @@ gboolean g_socket_bind (GSocket
|
|||||||
GError **error);
|
GError **error);
|
||||||
gboolean g_socket_join_multicast_group (GSocket *socket,
|
gboolean g_socket_join_multicast_group (GSocket *socket,
|
||||||
GInetAddress *group,
|
GInetAddress *group,
|
||||||
|
gboolean source_specific,
|
||||||
const gchar *interface,
|
const gchar *interface,
|
||||||
GError **error);
|
GError **error);
|
||||||
gboolean g_socket_leave_multicast_group (GSocket *socket,
|
gboolean g_socket_leave_multicast_group (GSocket *socket,
|
||||||
GInetAddress *group,
|
GInetAddress *group,
|
||||||
|
gboolean source_specific,
|
||||||
const gchar *interface,
|
const gchar *interface,
|
||||||
GError **error);
|
GError **error);
|
||||||
gboolean g_socket_connect (GSocket *socket,
|
gboolean g_socket_connect (GSocket *socket,
|
||||||
|
Loading…
Reference in New Issue
Block a user