summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2012-05-19 16:01:46 (GMT)
committer Jaromil <jaromil@dyne.org>2012-05-19 16:01:46 (GMT)
commitaf3171e20718586952301b3908dacb1893cedac6 (patch)
treef47c949a64d24ddd59bd4ab84b2e2bb54a747895
parent64a6656ac34d6b048b8a5f9927f82dd278addfb6 (diff)
commandline to specify network interface
-rw-r--r--src/hdsync_cli.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/hdsync_cli.cpp b/src/hdsync_cli.cpp
index 832ae99..d597cc8 100644
--- a/src/hdsync_cli.cpp
+++ b/src/hdsync_cli.cpp
@@ -47,7 +47,6 @@
#define DEBUG 1
// network settings
-#define ETHDEV "eth0"
#define PGMPORT "5555"
@@ -59,6 +58,7 @@ int port = 0;
int dryrun = 0;
int chanID = 0;
int chanTOT = 0;
+char ethiface[64];
// info on peers
@@ -76,7 +76,7 @@ char pgmaddr[256];
zmq_msg_t request;
// we use only getopt, no _long
-static const char *short_options = "-hvta:s:p:";
+static const char *short_options = "-hvta:i:s:p:";
void cmdline(int argc, char **argv);
@@ -451,6 +451,7 @@ void cmdline(int argc, char **argv) {
" -p port on which the UPNP AVTransport daemon is listening\n"
" -t dry run to test without a server (print out rendered xml)\n"
" -a manually specified pgm:// address for broadcast range\n"
+ " -i network interface to use (default: eth0)\n"
"\n"
" -h print this help\n"
" -v version information for this tool\n"
@@ -476,6 +477,10 @@ void cmdline(int argc, char **argv) {
snprintf(pgmstatic,255,"%s",optarg);
break;
+ case 'i':
+ snprintf(ethiface,63,"%s",optarg);
+ break;
+
case 'p':
sscanf (optarg, "%u", &port);
break;
@@ -484,6 +489,7 @@ void cmdline(int argc, char **argv) {
dryrun = 1;
break;
+
case '?':
fprintf(stderr,"unrecognized option: %s\n",optarg);
break;
@@ -523,7 +529,7 @@ int get_address() {
char addressBuffer[INET_ADDRSTRLEN];
inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
// printf("%s IP Address %s\n", ifa->ifa_name, addressBuffer);
- if( strcmp(ifa->ifa_name, ETHDEV) == 0) {
+ if( strcmp(ifa->ifa_name, ethiface) == 0) {
strncpy(IPv4, addressBuffer, 16);
if( pgmstatic[0] != 0 )
snprintf(pgmaddr,255,"%s",pgmstatic);
@@ -535,7 +541,7 @@ int get_address() {
if (ifAddrStruct!=NULL) freeifaddrs(ifAddrStruct);
if(!pgmaddr[0]) {
- printf("Error: ethernet interface %s is not configured\n",ETHDEV);
+ printf("Error: ethernet interface %s is not configured\n",ethiface);
return(0);
}
return(1);