/*
* Copyright (C) 2006, 2007, 2008 OpenedHand Ltd.
* Copyright (C) 2009 Nokia Corporation.
+ * Copyright (C) 2013 Intel Corporation.
*
* Author: Jorn Baayen <jorn@openedhand.com>
* Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
* <zeeshan.ali@nokia.com>
+ * Jens Georg <jensg@openismus.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
char *server_id;
guint socket_ttl;
+ guint msearch_port;
GSSDPNetworkDevice device;
GSSDPSocketSource *request_socket;
PROP_HOST_IP,
PROP_ACTIVE,
PROP_SOCKET_TTL,
+ PROP_MSEARCH_PORT,
};
enum {
/* Setup send socket. For security reasons, it is not recommended to
* send M-SEARCH with source port == SSDP_PORT */
- client->priv->search_socket = gssdp_socket_source_new
- (GSSDP_SOCKET_SOURCE_TYPE_SEARCH,
- gssdp_client_get_host_ip (client),
- client->priv->socket_ttl,
- &internal_error);
+ client->priv->search_socket = GSSDP_SOCKET_SOURCE (g_initable_new
+ (GSSDP_TYPE_SOCKET_SOURCE,
+ NULL,
+ &internal_error,
+ "type", GSSDP_SOCKET_SOURCE_TYPE_SEARCH,
+ "host-ip", gssdp_client_get_host_ip (client),
+ "ttl", client->priv->socket_ttl,
+ "port", client->priv->msearch_port,
+ NULL));
+
if (client->priv->search_socket != NULL) {
gssdp_socket_source_set_callback
(client->priv->search_socket,
case PROP_SOCKET_TTL:
g_value_set_uint (value, client->priv->socket_ttl);
break;
+ case PROP_MSEARCH_PORT:
+ g_value_set_uint (value, client->priv->msearch_port);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
case PROP_SOCKET_TTL:
client->priv->socket_ttl = g_value_get_uint (value);
break;
+ case PROP_MSEARCH_PORT:
+ client->priv->msearch_port = g_value_get_uint (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
G_PARAM_STATIC_BLURB));
/**
+ * GSSDPClient:msearch-port:
+ *
+ * UDP port to use for sending multicast M-SEARCH requests on the
+ * network. If not set (or set to 0) a random port will be used.
+ * This property can be only set during object construction.
+ */
+ g_object_class_install_property
+ (object_class,
+ PROP_MSEARCH_PORT,
+ g_param_spec_uint
+ ("msearch-port",
+ "M-SEARCH port",
+ "UDP port to use for M-SEARCH requests",
+ 0, G_MAXUINT16,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
* GSSDPClient::message-received: (skip)
*
* Internal signal.
NULL);
}
+/**
+ * gssdp_client_new_with_port:
+ * @iface: (allow-none): The name of the network interface, or %NULL for
+ * auto-detection.
+ * @msearch_port: The network port to use for M-SEARCH requests or 0 for
+ * random.
+ * @error: (allow-none): Location to store error, or %NULL.
+ *
+ * Return value: A new #GSSDPClient object.
+ **/
+GSSDPClient *
+gssdp_client_new_with_port (const char *iface,
+ guint16 msearch_port,
+ GError **error)
+{
+ return g_initable_new (GSSDP_TYPE_CLIENT,
+ NULL,
+ error,
+ "interface", iface,
+ "msearch-port", msearch_port,
+ NULL);
+}
+
/*
* gssdp_client_get_main_context: (skip)
* @client: A #GSSDPClient
char *host_ip;
guint ttl;
+ guint port;
};
enum {
PROP_TYPE,
PROP_HOST_IP,
PROP_TTL,
+ PROP_PORT
};
static void
case PROP_TTL:
self->priv->ttl = g_value_get_uint (value);
break;
+ case PROP_PORT:
+ self->priv->port = g_value_get_uint (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
} else {
guint port = SSDP_PORT;
- /* Chose random port For the socket source used by M-SEARCH */
+ /* Use user-supplied or random port for the socket source used
+ * by M-SEARCH */
if (self->priv->type == GSSDP_SOCKET_SOURCE_TYPE_SEARCH)
- port = 0;
+ port = self->priv->port;
+
bind_address = g_inet_socket_address_new (iface_address,
port);
}
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property
+ (object_class,
+ PROP_PORT,
+ g_param_spec_uint
+ ("port",
+ "UDP port",
+ "UDP port to use for TYPE_SEARCH sockets",
+ 0, G_MAXUINT16,
+ 0,
+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
}