diff --git a/Makefile b/Makefile index c517dce..d03ba45 100644 --- a/Makefile +++ b/Makefile @@ -76,29 +76,29 @@ depend: config.h # DO NOT DELETE -minidlna.o: config.h upnpglobalvars.h miniupnpdtypes.h -minidlna.o: upnphttp.h upnpdescgen.h miniupnpdpath.h getifaddr.h upnpsoap.h +minidlna.o: config.h upnpglobalvars.h minidlnatypes.h +minidlna.o: upnphttp.h upnpdescgen.h minidlnapath.h getifaddr.h upnpsoap.h minidlna.o: options.h minissdp.h daemonize.h upnpevents.h minidlna.o: commonrdr.h -upnphttp.o: config.h upnphttp.h upnpdescgen.h miniupnpdpath.h upnpsoap.h +upnphttp.o: config.h upnphttp.h upnpdescgen.h minidlnapath.h upnpsoap.h upnphttp.o: upnpevents.h -upnpdescgen.o: config.h upnpdescgen.h miniupnpdpath.h upnpglobalvars.h -upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h -upnpsoap.o: config.h upnpglobalvars.h miniupnpdtypes.h +upnpdescgen.o: config.h upnpdescgen.h minidlnapath.h upnpglobalvars.h +upnpdescgen.o: minidlnatypes.h upnpdescstrings.h +upnpsoap.o: config.h upnpglobalvars.h minidlnatypes.h upnpsoap.o: upnphttp.h upnpsoap.h upnpreplyparse.h getifaddr.h upnpreplyparse.o: upnpreplyparse.h minixml.h minixml.o: minixml.h getifaddr.o: getifaddr.h daemonize.o: daemonize.h config.h upnpglobalvars.o: config.h upnpglobalvars.h -upnpglobalvars.o: miniupnpdtypes.h +upnpglobalvars.o: minidlnatypes.h options.o: options.h config.h upnpglobalvars.h -options.o: miniupnpdtypes.h -minissdp.o: config.h upnpdescstrings.h miniupnpdpath.h upnphttp.h -minissdp.o: upnpglobalvars.h miniupnpdtypes.h minissdp.h -upnpevents.o: config.h upnpevents.h miniupnpdpath.h upnpglobalvars.h -upnpevents.o: miniupnpdtypes.h upnpdescgen.h +options.o: minidlnatypes.h +minissdp.o: config.h upnpdescstrings.h minidlnapath.h upnphttp.h +minissdp.o: upnpglobalvars.h minidlnatypes.h minissdp.h +upnpevents.o: config.h upnpevents.h minidlnapath.h upnpglobalvars.h +upnpevents.o: minidlnatypes.h upnpdescgen.h netfilter/iptcrdr.o: netfilter/iptcrdr.h commonrdr.h config.h testupnpdescgen.o: config.h upnpdescgen.h -upnpdescgen.o: config.h upnpdescgen.h miniupnpdpath.h upnpglobalvars.h -upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h +upnpdescgen.o: config.h upnpdescgen.h minidlnapath.h upnpglobalvars.h +upnpdescgen.o: minidlnatypes.h upnpdescstrings.h diff --git a/genconfig.sh b/genconfig.sh index 8224827..9bd7089 100755 --- a/genconfig.sh +++ b/genconfig.sh @@ -133,20 +133,11 @@ echo "/* The cache duration is indicated in seconds */" >> ${CONFIGFILE} echo "#define GETIFSTATS_CACHING_DURATION 2" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE} -echo "/* Uncomment the following line to enable multiple external ip support */" >> ${CONFIGFILE} -echo "/* note : Thas is EXPERIMENTAL, do not use that unless you know perfectly what you are doing */" >> ${CONFIGFILE} -echo "/*#define MULTIPLE_EXTERNAL_IP*/" >> ${CONFIGFILE} -echo "" >> ${CONFIGFILE} - echo "/* Comment the following line to use home made daemonize() func instead" >> ${CONFIGFILE} echo " * of BSD daemon() */" >> ${CONFIGFILE} echo "#define USE_DAEMON" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE} -echo "/* Uncomment the following line to enable lease file support */" >> ${CONFIGFILE} -echo "/*#define ENABLE_LEASEFILE*/" >> ${CONFIGFILE} -echo "" >> ${CONFIGFILE} - echo "/* Experimental UPnP Events support. */" >> ${CONFIGFILE} echo "#define ENABLE_EVENTS" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE} diff --git a/minidlna.c b/minidlna.c index d66dbd0..c269add 100644 --- a/minidlna.c +++ b/minidlna.c @@ -39,12 +39,12 @@ #include "upnpglobalvars.h" #include "upnphttp.h" #include "upnpdescgen.h" -#include "miniupnpdpath.h" +#include "minidlnapath.h" #include "getifaddr.h" #include "upnpsoap.h" #include "options.h" #include "minissdp.h" -#include "miniupnpdtypes.h" +#include "minidlnatypes.h" #include "daemonize.h" #include "upnpevents.h" #include "scanner.h" @@ -148,9 +148,6 @@ struct runtime_vars { /*struct lan_addr_s lan_addr[MAX_LAN_ADDR];*/ int port; /* HTTP Port */ int notify_interval; /* seconds between SSDP announces */ - /* unused rules cleaning related variables : */ - int clean_ruleset_threshold; /* threshold for removing unused rules */ - int clean_ruleset_interval; /* (minimum) interval between checks */ }; /* parselanaddr() @@ -188,23 +185,6 @@ parselanaddr(struct lan_addr_s * lan_addr, const char * str) return -1; } lan_addr->mask.s_addr = htonl(nbits ? (0xffffffff << (32 - nbits)) : 0); -#ifdef MULTIPLE_EXTERNAL_IP - while(*p && isspace(*p)) - p++; - if(*p) { - n = 0; - while(p[n] && !isspace(*p)) - n++; - if(n<=15) { - memcpy(lan_addr->ext_ip_str, p, n); - lan_addr->ext_ip_str[n] = '\0'; - if(!inet_aton(lan_addr->ext_ip_str, &lan_addr->ext_ip_addr)) { - /* error */ - fprintf(stderr, "Error parsing address : %s\n", lan_addr->ext_ip_str); - } - } - } -#endif return 0; } @@ -293,8 +273,6 @@ init(int argc, char * * argv, struct runtime_vars * v) n_lan_addr++; v->port = -1; v->notify_interval = 30; /* seconds between SSDP announces */ - v->clean_ruleset_threshold = 20; - v->clean_ruleset_interval = 0; /* interval between ruleset check. 0=disabled */ /* read options file first since * command line arguments have final say */ @@ -349,22 +327,10 @@ init(int argc, char * * argv, struct runtime_vars * v) strncpy(modelnumber, ary_options[i].value, MODELNUMBER_MAX_LEN); modelnumber[MODELNUMBER_MAX_LEN-1] = '\0'; break; - case UPNPCLEANTHRESHOLD: - v->clean_ruleset_threshold = atoi(ary_options[i].value); - break; - case UPNPCLEANINTERVAL: - v->clean_ruleset_interval = atoi(ary_options[i].value); - break; case UPNPSECUREMODE: if(strcmp(ary_options[i].value, "yes") == 0) SETFLAG(SECUREMODEMASK); break; -#ifdef ENABLE_LEASEFILE - case UPNPLEASEFILE: - lease_file = ary_options[i].value; - remove(lease_file); - break; -#endif case UPNPFRIENDLYNAME: strncpy(friendly_name, ary_options[i].value, FRIENDLYNAME_MAX_LEN); friendly_name[FRIENDLYNAME_MAX_LEN-1] = '\0'; diff --git a/minidlna.conf b/minidlna.conf index bb21444..343172a 100644 --- a/minidlna.conf +++ b/minidlna.conf @@ -9,9 +9,6 @@ media_dir=/opt # set this if you want to customize the name that shows up on your clients #friendly_name=My DLNA Server -# lease file location -#lease_file=/var/log/upnp.leases - # "secure" mode : UPnP client are allowed to add mappings only # to their IP secure_mode=no @@ -25,8 +22,6 @@ system_uptime=no # notify interval in seconds. default is 30 seconds. notify_interval=900 -clean_ruleset_interval=600 - # serial and model number the daemon will report to clients # in its XML description serial=12345678 diff --git a/miniupnpdpath.h b/minidlnapath.h similarity index 90% rename from miniupnpdpath.h rename to minidlnapath.h index 546508a..1a2bd7a 100644 --- a/miniupnpdpath.h +++ b/minidlnapath.h @@ -9,9 +9,9 @@ #include "config.h" -/* Paths and other URLs in the miniupnpd http server */ +/* Paths and other URLs in the minidlna http server */ -#define ROOTDESC_PATH "/rootDesc.xml" +#define ROOTDESC_PATH "/rootDesc.xml" #define CONTENTDIRECTORY_PATH "/ContentDir.xml" #define CONTENTDIRECTORY_CONTROLURL "/ctl/ContentDir" diff --git a/miniupnpdtypes.h b/minidlnatypes.h similarity index 85% rename from miniupnpdtypes.h rename to minidlnatypes.h index 70ba799..a6f4872 100644 --- a/miniupnpdtypes.h +++ b/minidlnatypes.h @@ -14,10 +14,6 @@ struct lan_addr_s { char str[16]; /* example: 192.168.0.1 */ struct in_addr addr, mask; /* ip/mask */ -#ifdef MULTIPLE_EXTERNAL_IP - char ext_ip_str[16]; - struct in_addr ext_ip_addr; -#endif }; #endif diff --git a/minissdp.c b/minissdp.c index 87ba70a..143f2da 100644 --- a/minissdp.c +++ b/minissdp.c @@ -14,7 +14,7 @@ #include #include "config.h" #include "upnpdescstrings.h" -#include "miniupnpdpath.h" +#include "minidlnapath.h" #include "upnphttp.h" #include "upnpglobalvars.h" #include "minissdp.h" diff --git a/minissdp.h b/minissdp.h index d56fe0e..5767f90 100644 --- a/minissdp.h +++ b/minissdp.h @@ -6,7 +6,7 @@ #ifndef __MINISSDP_H__ #define __MINISSDP_H__ -/*#include "miniupnpdtypes.h"*/ +/*#include "minidlnatypes.h"*/ int OpenAndConfSSDPReceiveSocket(); diff --git a/options.c b/options.c index 78a7138..bb10262 100644 --- a/options.c +++ b/options.c @@ -32,12 +32,7 @@ static const struct { { UPNPUUID, "uuid"}, { UPNPSERIAL, "serial"}, { UPNPMODEL_NUMBER, "model_number"}, - { UPNPCLEANTHRESHOLD, "clean_ruleset_threshold"}, - { UPNPCLEANINTERVAL, "clean_ruleset_interval"}, { UPNPENABLE, "enable_upnp"}, -#ifdef ENABLE_LEASEFILE - { UPNPLEASEFILE, "lease_file"}, -#endif { UPNPFRIENDLYNAME, "friendly_name"}, { UPNPMEDIADIR, "media_dir"}, { UPNPSECUREMODE, "secure_mode"} diff --git a/options.h b/options.h index c15e687..113656e 100644 --- a/options.h +++ b/options.h @@ -24,13 +24,8 @@ enum upnpconfigoptions { UPNPUUID, /* uuid */ UPNPSERIAL, /* serial */ UPNPMODEL_NUMBER, /* model_number */ - UPNPCLEANTHRESHOLD, /* clean_ruleset_threshold */ - UPNPCLEANINTERVAL, /* clean_ruleset_interval */ UPNPENABLENATPMP, /* enable_natpmp */ UPNPSECUREMODE, /* secure_mode */ -#ifdef ENABLE_LEASEFILE - UPNPLEASEFILE, /* lease_file */ -#endif UPNPFRIENDLYNAME, /* how the system should show up to DLNA clients */ UPNPMEDIADIR, /* directory to search for UPnP-A/V content */ UPNPENABLE /* enable_upnp */ diff --git a/scanner.c b/scanner.c index d56a992..a94aa1d 100644 --- a/scanner.c +++ b/scanner.c @@ -525,6 +525,36 @@ sql_failed: return (ret != SQLITE_OK); } +int +filter_audio(const struct dirent *d) +{ + return ( (*d->d_name != '.') && + ((d->d_type == DT_DIR) || + ((d->d_type == DT_REG) && + is_audio(d->d_name) ) + ) ); +} + +int +filter_video(const struct dirent *d) +{ + return ( (*d->d_name != '.') && + ((d->d_type == DT_DIR) || + ((d->d_type == DT_REG) && + is_video(d->d_name) ) + ) ); +} + +int +filter_images(const struct dirent *d) +{ + return ( (*d->d_name != '.') && + ((d->d_type == DT_DIR) || + ((d->d_type == DT_REG) && + is_image(d->d_name) ) + ) ); +} + int filter_media(const struct dirent *d) { diff --git a/testupnpdescgen.c b/testupnpdescgen.c index 833a4ad..96a93d1 100644 --- a/testupnpdescgen.c +++ b/testupnpdescgen.c @@ -18,8 +18,6 @@ char serialnumber[] = "12345678"; char modelnumber[] = "1"; char presentationurl[] = "http://192.168.0.1:8080/"; -char * use_ext_ip_addr = NULL; - int getifaddr(const char * ifname, char * buf, int len) { strncpy(buf, "1.2.3.4", len); diff --git a/upnpdescgen.c b/upnpdescgen.c index f9d1b16..edba222 100644 --- a/upnpdescgen.c +++ b/upnpdescgen.c @@ -16,7 +16,7 @@ #include "getifaddr.h" #endif #include "upnpdescgen.h" -#include "miniupnpdpath.h" +#include "minidlnapath.h" #include "upnpglobalvars.h" #include "upnpdescstrings.h" diff --git a/upnpevents.c b/upnpevents.c index a0e06f2..f5b6628 100644 --- a/upnpevents.c +++ b/upnpevents.c @@ -20,7 +20,7 @@ #include #include "config.h" #include "upnpevents.h" -#include "miniupnpdpath.h" +#include "minidlnapath.h" #include "upnpglobalvars.h" #include "upnpdescgen.h" diff --git a/upnpglobalvars.c b/upnpglobalvars.c index 335f909..f6adbea 100644 --- a/upnpglobalvars.c +++ b/upnpglobalvars.c @@ -11,15 +11,6 @@ #include "config.h" #include "upnpglobalvars.h" -/* file to store leases */ -#ifdef ENABLE_LEASEFILE -const char* lease_file = 0; -#endif - -/* forced ip address to use for this interface - * when NULL, getifaddr() is used */ -const char * use_ext_ip_addr = 0; - /* LAN address */ /*const char * listen_addr = 0;*/ @@ -48,10 +39,6 @@ char modelnumber[MODELNUMBER_MAX_LEN] = "1"; * http://nnn.nnn.nnn.nnn:ppppp/ => max 30 bytes including terminating 0 */ char presentationurl[PRESENTATIONURL_MAX_LEN]; -/* UPnP permission rules : */ -struct upnpperm * upnppermlist = 0; -unsigned int num_upnpperm = 0; - int n_lan_addr = 0; struct lan_addr_s lan_addr[MAX_LAN_ADDR]; diff --git a/upnpglobalvars.h b/upnpglobalvars.h index 82fd3ca..6fe18f0 100644 --- a/upnpglobalvars.h +++ b/upnpglobalvars.h @@ -8,7 +8,7 @@ #define __UPNPGLOBALVARS_H__ #include -#include "miniupnpdtypes.h" +#include "minidlnatypes.h" #include "config.h" #include @@ -44,15 +44,6 @@ "http-get:*:video/dvd:*," \ "http-get:*:video/x-ms-wmv:*" -/* file to store all leases */ -#ifdef ENABLE_LEASEFILE -extern const char * lease_file; -#endif - -/* forced ip address to use for this interface - * when NULL, getifaddr() is used */ -extern const char * use_ext_ip_addr; - /* statup time */ extern time_t startup_time; @@ -80,10 +71,6 @@ extern char modelnumber[]; #define PRESENTATIONURL_MAX_LEN (64) extern char presentationurl[]; -/* UPnP permission rules : */ -extern struct upnpperm * upnppermlist; -extern unsigned int num_upnpperm; - /* lan addresses */ /* MAX_LAN_ADDR : maximum number of interfaces * to listen to SSDP traffic */ diff --git a/upnphttp.c b/upnphttp.c index 3e44169..ea76643 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -22,7 +22,7 @@ #include "config.h" #include "upnphttp.h" #include "upnpdescgen.h" -#include "miniupnpdpath.h" +#include "minidlnapath.h" #include "upnpsoap.h" #include "upnpevents.h"