summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Kukkonen <jku@goto.fi>2014-07-30 11:35:52 +0300
committerJens Georg <mail@jensge.org>2014-08-06 01:11:46 +0200
commitdd001ff917fbec59e8df79f1ff3a5f6baed72b75 (patch)
treefeb4af9172bec015fe82a3f2a6b98a6e8d2a8be4
parentf8dee020b6c80dbba6babe1a8628288b3e6a7d1e (diff)
downloadgssdp-dd001ff917fbec59e8df79f1ff3a5f6baed72b75.tar.gz
Accept messages from other networks on loopback
Kernel does smart things and routes traffic sent to other networks through loopback. We need to accept messages like that. https://bugzilla.gnome.org/show_bug.cgi?id=733851
-rw-r--r--libgssdp/gssdp-client.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/libgssdp/gssdp-client.c b/libgssdp/gssdp-client.c
index 0fc7831..71b486a 100644
--- a/libgssdp/gssdp-client.c
+++ b/libgssdp/gssdp-client.c
@@ -91,6 +91,9 @@ typedef unsigned long in_addr_t;
/* Size of the buffer used for reading from the socket */
#define BUF_SIZE 65536
+/* interface index for loopback device */
+#define LOOPBACK_IFINDEX 1
+
static void
gssdp_client_initable_iface_init (gpointer g_iface,
gpointer iface_data);
@@ -1165,14 +1168,20 @@ socket_source_cb (GSSDPSocketSource *socket_source, GSSDPClient *client)
int i;
for (i = 0; i < num_messages; i++) {
GSSDPPktinfoMessage *msg;
+ gint msg_ifindex;
+
if (!GSSDP_IS_PKTINFO_MESSAGE (messages[i]))
continue;
msg = GSSDP_PKTINFO_MESSAGE (messages[i]);
- if (!((gssdp_pktinfo_message_get_ifindex (msg) ==
- client->priv->device.index) &&
- (g_inet_address_equal (gssdp_pktinfo_message_get_local_addr (msg),
- client->priv->device.host_addr))))
+ msg_ifindex = gssdp_pktinfo_message_get_ifindex (msg);
+ /* message needs to be on correct interface or on
+ * loopback (as kernel can be smart and route things
+ * there even if sent to another network) */
+ if (!((msg_ifindex == client->priv->device.index ||
+ msg_ifindex == LOOPBACK_IFINDEX) &&
+ (g_inet_address_equal (gssdp_pktinfo_message_get_local_addr (msg),
+ client->priv->device.host_addr))))
goto out;
else
break;