mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-25 21:53:17 -05:00
More UPnP work. Still doesn't show up in network neighborhood. Not quite sure why not, though. :)
This commit is contained in:
parent
a6b9099e01
commit
096975abfe
22
admin-root/upnp-basic.xml
Normal file
22
admin-root/upnp-basic.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<root xmlns="urn:schemas-upnp-org:device-1-0">
|
||||||
|
<specVersion>
|
||||||
|
<major>1</major>
|
||||||
|
<minor>0</minor>
|
||||||
|
</specVersion>
|
||||||
|
<URLBase>http://@host@:@config general/port@/</URLBase>
|
||||||
|
<device>
|
||||||
|
<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
|
||||||
|
<friendlyName>@servername@</friendlyName>
|
||||||
|
<manufacturer>Firefly Media Services</manufacturer>
|
||||||
|
<manufacturerURL>http://www.fireflymediaserver.org/</manufacturerURL>
|
||||||
|
<modelDescription>Firefly Media Server (version
|
||||||
|
@version@)</modelDescription>
|
||||||
|
<modelName></modelName>
|
||||||
|
<modelURL></modelURL>
|
||||||
|
<serialNumber></serialNumber>
|
||||||
|
<UDN>uuid:12345678-1234-1234-1234-123456789012</UDN>
|
||||||
|
<UPC></UPC>
|
||||||
|
<presentationURL>http://@host@:@config general/port@/</presentationURL>
|
||||||
|
</device>
|
||||||
|
</root>
|
@ -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_flags(WS_CONNINFO *pwsc, void *value, char *arg);
|
||||||
static void config_emit_conffile(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_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_subst_stream(WS_CONNINFO *pwsc, int fd_src);
|
||||||
static void config_content_type(WS_CONNINFO *pwsc, char *path);
|
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,"logfile",(void*)&config.logfile, config_emit_string },
|
||||||
{ 1,0,0,CONFIG_TYPE_STRING,"art_filename",(void*)&config.artfilename,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,"conffile",(void*)NULL,config_emit_conffile },
|
||||||
{ 0,0,0,CONFIG_TYPE_SPECIAL,"host",(void*)NULL,config_emit_host },
|
{ 0,0,0,CONFIG_TYPE_SPECIAL,"host",(void*)NULL,config_emit_host },
|
||||||
{ 0,0,0,CONFIG_TYPE_SPECIAL,"release",(void*)VERSION,config_emit_literal },
|
{ 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_writefd(pwsc,"HTTP/1.1 200 OK\r\n");
|
||||||
ws_emitheaders(pwsc);
|
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);
|
config_subst_stream(pwsc, file_fd);
|
||||||
} else {
|
} else {
|
||||||
copyfile(file_fd,pwsc->fd);
|
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)))
|
if((pwsc->hostname) && (os_islocaladdr(pwsc->hostname)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
if(strncasecmp(pwsc->uri,"/upnp",5) == 0)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
adminpassword=conf_alloc_string("general","admin_pw",NULL);
|
adminpassword=conf_alloc_string("general","admin_pw",NULL);
|
||||||
if((!adminpassword) || (strlen(adminpassword)==0)) {
|
if((!adminpassword) || (strlen(adminpassword)==0)) {
|
||||||
/* we'll handle this later */
|
/* we'll handle this later */
|
||||||
@ -439,6 +447,43 @@ int config_auth(WS_CONNINFO *pwsc, char *user, char *password) {
|
|||||||
return res;
|
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
|
* emit the host value passed by the client web server. This
|
||||||
|
19
src/upnp.c
19
src/upnp.c
@ -21,6 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -139,7 +140,7 @@ void upnp_build_packet(char *packet, int len, UPNP_PACKETINFO *pi) {
|
|||||||
|
|
||||||
if(pi->body) {
|
if(pi->body) {
|
||||||
snprintf(buffer,sizeof(buffer),"Content-Length: %d\r\n\r\n",
|
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(buffer,packet,len);
|
||||||
len=upnp_strcat(pi->body,packet,len);
|
len=upnp_strcat(pi->body,packet,len);
|
||||||
} else {
|
} else {
|
||||||
@ -198,11 +199,17 @@ int upnp_init(void) {
|
|||||||
int result;
|
int result;
|
||||||
|
|
||||||
memset(&upnp_packetlist,0,sizeof(upnp_packetlist));
|
memset(&upnp_packetlist,0,sizeof(upnp_packetlist));
|
||||||
upnp_add_packet("base","/",NULL,NULL,NULL);
|
upnp_add_packet("base","/upnp-basic.xml",NULL,NULL,NULL);
|
||||||
upnp_add_packet("base","/",
|
upnp_add_packet("base","/upnp-basic.xml",
|
||||||
"urn:schemas-upnp-org:device:Basic:1.0",
|
"urn:schemas-upnp-org:device:MediaServer:1",
|
||||||
"urn:schemas-upnp-org:device:Basic:1.0",NULL);
|
"urn:schemas-upnp-org:device:MediaServer:1",NULL);
|
||||||
upnp_add_packet("base","/","upnp:rootdevice","upnp:rootdevice",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);
|
upnp_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
result = setsockopt(upnp_socket, IPPROTO_IP, IP_MULTICAST_TTL,
|
result = setsockopt(upnp_socket, IPPROTO_IP, IP_MULTICAST_TTL,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user