From a5eab8042453dbbf5cd24fa2c2b4c605a18eede8 Mon Sep 17 00:00:00 2001 From: methodus Date: Thu, 27 Dec 2012 18:19:31 +0100 Subject: Added command line options for IP address, interace and port. --- upnp.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/upnp.cpp b/upnp.cpp index 9784969..06e23d2 100644 --- a/upnp.cpp +++ b/upnp.cpp @@ -34,13 +34,24 @@ const char *cPluginUpnp::CommandLineHelp(void) " \n" " -d --db-dir= Specifies the directory\n" " where the the database\n" - " file shall be located.\n"); + " file shall be located.\n" + " -a --address= Binds the server to the\n" + " specific IP address.\n" + " -i --interface= Binds the server to the\n" + " specific network\n" + " interface.\n" + " -p --port= Sets the port where the\n" + " UPnP server shall listen\n" + " on."); } bool cPluginUpnp::ProcessArgs(int argc, char *argv[]) { static struct option long_options[] = { {"db-dir", required_argument, NULL, 'd'}, + {"port", required_argument, NULL, 'p'}, + {"address", required_argument, NULL, 'a'}, + {"interface",required_argument, NULL, 'i'}, {0, 0, 0, 0} }; @@ -48,11 +59,22 @@ bool cPluginUpnp::ProcessArgs(int argc, char *argv[]) upnp::cConfig config = mMediaServer->GetConfiguration(); int c = 0; int index = -1; - while((c = getopt_long(argc, argv, "d:",long_options, &index)) != -1){ + while((c = getopt_long(argc, argv, "d:p:a:i:",long_options, &index)) != -1){ switch(c){ case 'd': if(!cMenuSetupUPnP::SetupParse("databaseDir", optarg, config)) return false; break; + case 'p': + if(!cMenuSetupUPnP::SetupParse("port", optarg, config)) return false; + break; + case 'a': + if(!cMenuSetupUPnP::SetupParse("address", optarg, config) || + !cMenuSetupUPnP::SetupParse("bindToAddress", "1", config)) return false; + break; + case 'i': + if(!cMenuSetupUPnP::SetupParse("interface", optarg, config) || + !cMenuSetupUPnP::SetupParse("bindToAddress", "0", config)) return false; + break; default: return false; } -- cgit v1.2.3