diff --git a/src/configfile.c b/src/configfile.c index 4c412109..b391bfbd 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -133,6 +133,7 @@ CONFIGELEMENT config_elements[] = { { 1,0,0,CONFIG_TYPE_INT,"compress",(void*)&config.compress,config_emit_int }, { 1,0,0,CONFIG_TYPE_STRING,"playlist",(void*)&config.playlist,config_emit_string }, { 1,0,0,CONFIG_TYPE_STRING,"extensions",(void*)&config.extensions,config_emit_string }, + { 1,0,0,CONFIG_TYPE_STRING,"interface",(void*)&config.iface,config_emit_string }, { 1,0,0,CONFIG_TYPE_STRING,"ssc_extensions",(void*)&config.ssc_extensions,config_emit_string }, { 1,0,0,CONFIG_TYPE_STRING,"ssc_prog",(void*)&config.ssc_prog,config_emit_string }, { 1,0,0,CONFIG_TYPE_STRING,"password",(void*)&config.readpassword, config_emit_string }, @@ -303,6 +304,7 @@ int config_read(char *file) { config.web_root=NULL; config.adminpassword=NULL; config.readpassword=NULL; + config.iface=NULL; config.mp3dir=NULL; config.playlist=NULL; config.runas=NULL; diff --git a/src/daapd.h b/src/daapd.h index b27e81b3..2862d096 100644 --- a/src/daapd.h +++ b/src/daapd.h @@ -49,6 +49,7 @@ typedef struct tag_config { int reload; /**< Time to reload and/or rescan the database? */ char *configfile; /**< path to config file */ char *web_root; /**< path to the dir containing the web files */ + char *iface; /**< interface to advertise on */ int port; /**< port to listen on */ int rescan_interval; /**< How often to do a background fs rescan */ int always_scan; /**< 0 to minimize disk usage (embedded devices) */ diff --git a/src/err.c b/src/err.c index 75e120a5..f0fd3c71 100644 --- a/src/err.c +++ b/src/err.c @@ -118,7 +118,7 @@ void err_log(int level, unsigned int cat, char *fmt, ...) err_lock_mutex(); /* atomic file writes */ - if((!level) && (err_logdestination != LOGDEST_STDERR) && (!(cat & L_REND))) { + if((!level) && (err_logdestination != LOGDEST_STDERR)) { fprintf(stderr,"%s",errbuf); fprintf(stderr,"Aborting\n"); fflush(stderr); /* shouldn't have to do this? */ diff --git a/src/main.c b/src/main.c index 8bdf2d14..b4efda8e 100644 --- a/src/main.c +++ b/src/main.c @@ -517,8 +517,8 @@ int main(int argc, char *argv[]) { #ifndef WITHOUT_MDNS if(config.use_mdns) { /* register services */ DPRINTF(E_LOG,L_MAIN|L_REND,"Registering rendezvous names\n"); - rend_register(config.servername,"_daap._tcp",config.port); - rend_register(config.servername,"_http._tcp",config.port); + rend_register(config.servername,"_daap._tcp",config.port,config.iface); + rend_register(config.servername,"_http._tcp",config.port,config.iface); } #endif diff --git a/src/rend-posix.c b/src/rend-posix.c index 76c590da..a62c5a7c 100644 --- a/src/rend-posix.c +++ b/src/rend-posix.c @@ -89,6 +89,9 @@ Change History (most recent first): $Log$ + Revision 1.25 2005/08/16 02:26:32 rpedde + Add interface directive to config file -- fix stderr logging on rendezvous child + Revision 1.24 2005/08/15 03:16:54 rpedde specify interface to register @@ -196,6 +199,21 @@ #include "rend-unix.h" +/* + * I'll take some extra hackishness, please... + */ +typedef struct PosixNetworkInterface PosixNetworkInterface; + +struct PosixNetworkInterface { + NetworkInterfaceInfo coreIntf; + const char * intfName; + PosixNetworkInterface * aliasIntf; + int index; + int multicastSocket; + int multicastSocketv6; +}; + + static mDNS mDNSStorage; // mDNS core uses this to store its globals static mDNS_PlatformSupport PlatformStorage; // Stores this platform's globals @@ -394,21 +412,30 @@ static void DeregisterOurServices(void) } } - -mDNSInterfaceID rend__get_interface_id(char *iface) { +mDNSInterfaceID rend_get_interface_id(char *iface) { PosixNetworkInterface *pni; if(!iface) return mDNSInterface_Any; - /* we'll cheat and get the underlying posix interface */ - pni = SearchForInterfaceByName(mDNSStorage, iface); - if(!pni) { - DPRINTF(E_LOG,L_REND,"Could not find interface %s - ignoring\n"); + if(!strlen(iface)) return mDNSInterface_Any; + + DPRINTF(E_LOG,L_REND,"Searching for interface %s\n",iface); + + pni=(PosixNetworkInterface*)mDNSStorage.HostInterfaces; + while(pni) { + DPRINTF(E_INF,L_REND,"Found interface %s, index %d\n",pni->intfName, + pni->index); + if(strcasecmp(pni->intfName,iface) == 0) { + DPRINTF(E_INF,L_REND,"Found interface id: %d\n",pni->coreIntf.InterfaceID); + return pni->coreIntf.InterfaceID; + } + pni=(PosixNetworkInterface*)(pni->coreIntf.next); } - return pni->coreIntf.mDNSInterfaceID; + DPRINTF(E_INF,L_REND,"Could not find interface.\n"); + return mDNSInterface_Any; } /* @@ -463,6 +490,9 @@ int rend_private_init(char *user) { mStatus status; mDNSBool result; + + fprintf(stderr,"w00t\n"); + status = mDNS_Init(&mDNSStorage, &PlatformStorage, mDNS_Init_NoCache, mDNS_Init_ZeroCacheSize, mDNS_Init_AdvertiseLocalAddresses, diff --git a/src/rend-unix.c b/src/rend-unix.c index 7fe83145..80c19605 100644 --- a/src/rend-unix.c +++ b/src/rend-unix.c @@ -108,7 +108,7 @@ int rend_init(char *user) { if((fd = open("/dev/null", O_RDWR, 0)) != -1) { dup2(fd, STDIN_FILENO); dup2(fd, STDOUT_FILENO); - dup2(fd, STDERR_FILENO); + // dup2(fd, STDERR_FILENO); if (fd > 2) close(fd); } diff --git a/src/rend-unix.h b/src/rend-unix.h index 96656d4c..a4e592a1 100644 --- a/src/rend-unix.h +++ b/src/rend-unix.h @@ -22,7 +22,7 @@ #ifndef _REND_UNIX_H_ #define _REND_UNIX_H_ -#define MAX_NAME_LEN 256 +#define MAX_NAME_LEN 200 /* Is there a posixly correct constant for this? */ #define MAX_IFACE_NAME_LEN 20