diff --git a/admin-root/upnp-basic.xml b/admin-root/upnp-basic.xml
new file mode 100644
index 00000000..7785652f
--- /dev/null
+++ b/admin-root/upnp-basic.xml
@@ -0,0 +1,22 @@
+
+
+
+ 1
+ 0
+
+ http://@host@:@config general/port@/
+
+ urn:schemas-upnp-org:device:Basic:1
+ @servername@
+ Firefly Media Services
+ http://www.fireflymediaserver.org/
+ Firefly Media Server (version
+ @version@)
+
+
+
+ uuid:12345678-1234-1234-1234-123456789012
+
+ http://@host@:@config general/port@/
+
+
\ No newline at end of file
diff --git a/src/configfile.c b/src/configfile.c
index 6a2df953..d16f848e 100644
--- a/src/configfile.c
+++ b/src/configfile.c
@@ -80,6 +80,8 @@ static void config_emit_system(WS_CONNINFO *pwsc, void *value, char *arg);
static void config_emit_flags(WS_CONNINFO *pwsc, void *value, char *arg);
static void config_emit_conffile(WS_CONNINFO *pwsc, void *value, char *arg);
static void config_emit_host(WS_CONNINFO *pwsc, void *value, char *arg);
+static void config_emit_config(WS_CONNINFO *pwsc, void *value, char *arg);
+static void config_emit_servername(WS_CONNINFO *pwsc, void *value, char *arg);
static void config_subst_stream(WS_CONNINFO *pwsc, int fd_src);
static void config_content_type(WS_CONNINFO *pwsc, char *path);
@@ -143,6 +145,8 @@ CONFIGELEMENT config_elements[] = {
{ 1,0,0,CONFIG_TYPE_STRING,"logfile",(void*)&config.logfile, config_emit_string },
{ 1,0,0,CONFIG_TYPE_STRING,"art_filename",(void*)&config.artfilename,config_emit_string },
*/
+ { 0,0,0,CONFIG_TYPE_SPECIAL,"servername",(void*)NULL,config_emit_servername },
+ { 0,0,0,CONFIG_TYPE_SPECIAL,"config",(void*)NULL,config_emit_config },
{ 0,0,0,CONFIG_TYPE_SPECIAL,"conffile",(void*)NULL,config_emit_conffile },
{ 0,0,0,CONFIG_TYPE_SPECIAL,"host",(void*)NULL,config_emit_host },
{ 0,0,0,CONFIG_TYPE_SPECIAL,"release",(void*)VERSION,config_emit_literal },
@@ -393,7 +397,8 @@ void config_handler(WS_CONNINFO *pwsc) {
ws_writefd(pwsc,"HTTP/1.1 200 OK\r\n");
ws_emitheaders(pwsc);
- if(strcasecmp(&resolved_path[strlen(resolved_path) - 5],".html") == 0) {
+ if((strcasecmp(&resolved_path[strlen(resolved_path) - 5],".html") == 0) ||
+ (strcasecmp(&resolved_path[strlen(resolved_path) - 4],".xml") == 0)) {
config_subst_stream(pwsc, file_fd);
} else {
copyfile(file_fd,pwsc->fd);
@@ -418,6 +423,9 @@ int config_auth(WS_CONNINFO *pwsc, char *user, char *password) {
if((pwsc->hostname) && (os_islocaladdr(pwsc->hostname)))
return TRUE;
+ if(strncasecmp(pwsc->uri,"/upnp",5) == 0)
+ return TRUE;
+
adminpassword=conf_alloc_string("general","admin_pw",NULL);
if((!adminpassword) || (strlen(adminpassword)==0)) {
/* we'll handle this later */
@@ -439,6 +447,43 @@ int config_auth(WS_CONNINFO *pwsc, char *user, char *password) {
return res;
}
+/**
+ * write the current servername
+ */
+void config_emit_servername(WS_CONNINFO *pwsc, void *value, char *arg) {
+ char *servername = conf_get_servername();
+
+ ws_writefd(pwsc,"%s",servername);
+ free(servername);
+}
+
+/**
+ * write a config value
+ */
+void config_emit_config(WS_CONNINFO *pwsc, void *value, char *arg) {
+ char *new_arg = strdup(arg);
+ char *section = new_arg;
+ char *key;
+ char *result_value;
+
+ if(!new_arg)
+ return;
+
+ key = strchr(new_arg,'/');
+ if(!key)
+ return;
+
+ *key = '\0';
+ key++;
+
+ result_value = conf_alloc_string(section, key, NULL);
+ if(!result_value)
+ ws_writefd(pwsc,"NULL");
+ else {
+ ws_writefd(pwsc,"%s",result_value);
+ free(result_value);
+ }
+}
/**
* emit the host value passed by the client web server. This
diff --git a/src/upnp.c b/src/upnp.c
index 3d5cad36..d6a1c322 100755
--- a/src/upnp.c
+++ b/src/upnp.c
@@ -21,6 +21,7 @@
*/
#include
+#include
#include
#include
#include
@@ -139,7 +140,7 @@ void upnp_build_packet(char *packet, int len, UPNP_PACKETINFO *pi) {
if(pi->body) {
snprintf(buffer,sizeof(buffer),"Content-Length: %d\r\n\r\n",
- strlen(pi->body));
+ (int)strlen(pi->body));
len=upnp_strcat(buffer,packet,len);
len=upnp_strcat(pi->body,packet,len);
} else {
@@ -198,11 +199,17 @@ int upnp_init(void) {
int result;
memset(&upnp_packetlist,0,sizeof(upnp_packetlist));
- upnp_add_packet("base","/",NULL,NULL,NULL);
- upnp_add_packet("base","/",
- "urn:schemas-upnp-org:device:Basic:1.0",
- "urn:schemas-upnp-org:device:Basic:1.0",NULL);
- upnp_add_packet("base","/","upnp:rootdevice","upnp:rootdevice",NULL);
+ upnp_add_packet("base","/upnp-basic.xml",NULL,NULL,NULL);
+ upnp_add_packet("base","/upnp-basic.xml",
+ "urn:schemas-upnp-org:device:MediaServer:1",
+ "urn:schemas-upnp-org:device:MediaServer:1",NULL);
+ upnp_add_packet("base","/upnp-basic.xml",
+ "urn:schemas-upnp-org:service:ContentDirectory:1",
+ "urn:schemas-upnp-org:service:ContentDirectory:1",NULL);
+ upnp_add_packet("basic","/upnp-basic.xml",
+ "urn:schemas-upnp-org:service:ConnectionManager:1",
+ "urn:schemas-upnp-org:service:ConnectionManager:1",NULL);
+ upnp_add_packet("base","/upnp-basic.xml","upnp:rootdevice","upnp:rootdevice",NULL);
upnp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
result = setsockopt(upnp_socket, IPPROTO_IP, IP_MULTICAST_TTL,