[gssdp] client,resource-browser: Add UPnP version
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gssdp] client,resource-browser: Add UPnP version
- Date: Thu, 3 Jan 2019 11:21:35 +0000 (UTC)
commit 74a63abdf52b65eb79217a0b13cf5d0ae8e8e9c3
Author: Jens Georg <mail jensge org>
Date: Sat Dec 22 15:31:46 2018 +0100
client,resource-browser: Add UPnP version
The User-Agent header for the discovery message is now defined in UDA
1.1 and needs to include the UPnP version just as the Server: header.
Therefore, modify the Server header to also include the UPnP version
(which it had to have since UDA 1.0 anyway) and use it for the
User-Agent as well.
libgssdp/gssdp-client.c | 29 +++++++++++++++++++++++------
libgssdp/gssdp-client.h | 3 +++
libgssdp/gssdp-protocol.h | 2 +-
libgssdp/gssdp-resource-browser.c | 2 +-
4 files changed, 28 insertions(+), 8 deletions(-)
---
diff --git a/libgssdp/gssdp-client.c b/libgssdp/gssdp-client.c
index ee101a7..ae95656 100644
--- a/libgssdp/gssdp-client.c
+++ b/libgssdp/gssdp-client.c
@@ -138,8 +138,13 @@ enum {
static guint signals[LAST_SIGNAL];
+static const char *GSSDP_UDA_VERSION_STRINGS[] = {
+ [GSSDP_UDA_VERSION_1_0] = "1.0",
+ [GSSDP_UDA_VERSION_1_1] = "1.1"
+};
+
static char *
-make_server_id (void);
+make_server_id (GSSDPUDAVersion uda_version);
static gboolean
request_socket_source_cb (GIOChannel *source,
GIOCondition condition,
@@ -170,7 +175,7 @@ gssdp_client_init (GSSDPClient *client)
priv->active = TRUE;
/* Generate default server ID */
- priv->server_id = make_server_id ();
+ priv->server_id = make_server_id (gssdp_client_get_uda_version (client));
}
static void
@@ -1052,6 +1057,15 @@ gssdp_client_get_family (GSSDPClient *client)
return g_inet_address_get_family (priv->device.host_addr);
}
+GSSDPUDAVersion
+gssdp_client_get_uda_version (GSSDPClient *client)
+{
+ g_return_val_if_fail (GSSDP_IS_CLIENT (client), GSSDP_UDA_VERSION_UNSPECIFIED);
+ GSSDPClientPrivate *priv = gssdp_client_get_instance_private (client);
+
+ return priv->uda_version;
+}
+
/**
* _gssdp_client_send_message:
* @client: A #GSSDPClient
@@ -1182,18 +1196,20 @@ _gssdp_client_get_mcast_group_addr (GSSDPClient *client)
* Generates the default server ID
*/
static char *
-make_server_id (void)
+make_server_id (GSSDPUDAVersion uda_version)
{
#ifdef G_OS_WIN32
OSVERSIONINFO versioninfo;
versioninfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (GetVersionEx (&versioninfo)) {
- return g_strdup_printf ("Microsoft Windows/%ld.%ld GSSDP/%s",
+ return g_strdup_printf ("Microsoft Windows/%ld.%ld UPnP/%s GSSDP/%s",
versioninfo.dwMajorVersion,
versioninfo.dwMinorVersion,
+ GSSDP_UDA_VERSION_STRINGS[uda_version],
VERSION);
} else {
- return g_strdup_printf ("Microsoft Windows GSSDP/%s",
+ return g_strdup_printf ("Microsoft Windows/Unknown UPnP/%s GSSDP/%s",
+ GSSDP_UDA_VERSION_STRINGS[uda_version],
VERSION);
}
#else
@@ -1201,9 +1217,10 @@ make_server_id (void)
uname (&sysinfo);
- return g_strdup_printf ("%s/%s GSSDP/%s",
+ return g_strdup_printf ("%s/%s UPnP/%s GSSDP/%s",
sysinfo.sysname,
sysinfo.release,
+ GSSDP_UDA_VERSION_STRINGS[uda_version],
VERSION);
#endif
}
diff --git a/libgssdp/gssdp-client.h b/libgssdp/gssdp-client.h
index c552735..80cfb81 100644
--- a/libgssdp/gssdp-client.h
+++ b/libgssdp/gssdp-client.h
@@ -119,6 +119,9 @@ const char *
gssdp_client_guess_user_agent (GSSDPClient *client,
const char *ip_address);
+GSSDPUDAVersion
+gssdp_client_get_uda_version (GSSDPClient *client);
+
G_END_DECLS
#endif /* GSSDP_CLIENT_H */
diff --git a/libgssdp/gssdp-protocol.h b/libgssdp/gssdp-protocol.h
index 842091b..44bdf3b 100644
--- a/libgssdp/gssdp-protocol.h
+++ b/libgssdp/gssdp-protocol.h
@@ -36,7 +36,7 @@ G_BEGIN_DECLS
"Man: \"ssdp:discover\"\r\n" \
"ST: %s\r\n" \
"MX: %d\r\n" \
- "User-Agent: %s GSSDP/" VERSION "\r\n" \
+ "User-Agent: %s\r\n" \
#define SSDP_DISCOVERY_RESPONSE \
"HTTP/1.1 200 OK\r\n" \
diff --git a/libgssdp/gssdp-resource-browser.c b/libgssdp/gssdp-resource-browser.c
index 467cc0d..ebe501a 100644
--- a/libgssdp/gssdp-resource-browser.c
+++ b/libgssdp/gssdp-resource-browser.c
@@ -1142,7 +1142,7 @@ send_discovery_request (GSSDPResourceBrowser *resource_browser)
dest,
priv->target,
priv->mx,
- g_get_prgname () ? g_get_prgname () : "");
+ gssdp_client_get_server_id (priv->client));
_gssdp_client_send_message (priv->client,
NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]