Commit 37465c76 authored by Jean-Paul Saman's avatar Jean-Paul Saman

dvbinfo: add commandline options for selecting a multicast interface.

parent 4da7ecbf
...@@ -94,7 +94,7 @@ typedef struct dvbinfo_capture_s ...@@ -94,7 +94,7 @@ typedef struct dvbinfo_capture_s
static void usage(void) static void usage(void)
{ {
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
printf("Usage: dvbinfo [-h] [-d <debug>] [-f|-m| [[-u|-t] -i <ipaddress:port>] -o <outputfile>\n"); printf("Usage: dvbinfo [-h] [-d <debug>] [-f|-m| [[-u|-t] -a <mcast_interface> -i <ipaddress:port>] -o <outputfile>\n");
printf(" [-s [bandwidth|table|packet] --summary-file <file> --summary-period <ms>]\n"); printf(" [-s [bandwidth|table|packet] --summary-file <file> --summary-period <ms>]\n");
#else #else
printf("Usage: dvbinfo [-h] [-d <debug>] [-f|\n"); printf("Usage: dvbinfo [-h] [-d <debug>] [-f|\n");
...@@ -106,6 +106,7 @@ static void usage(void) ...@@ -106,6 +106,7 @@ static void usage(void)
printf(" -f | --file : filename\n"); printf(" -f | --file : filename\n");
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
printf(" -i | --ipadddress : hostname or ipaddress\n"); printf(" -i | --ipadddress : hostname or ipaddress\n");
printf(" -a | --miface : multicast interface to use\n");
printf(" -t | --tcp : tcp network transport\n"); printf(" -t | --tcp : tcp network transport\n");
printf(" -u | --udp : udp network transport\n"); printf(" -u | --udp : udp network transport\n");
printf("\nOutputs: \n"); printf("\nOutputs: \n");
...@@ -171,6 +172,7 @@ static params_t *params_init(void) ...@@ -171,6 +172,7 @@ static params_t *params_init(void)
param->fd_in = param->fd_out = -1; param->fd_in = param->fd_out = -1;
param->input = NULL; param->input = NULL;
param->output = NULL; param->output = NULL;
param->mcast_interface = NULL;
param->b_verbose = false; param->b_verbose = false;
param->b_monitor = false; param->b_monitor = false;
...@@ -190,6 +192,7 @@ static params_t *params_init(void) ...@@ -190,6 +192,7 @@ static params_t *params_init(void)
static void params_free(params_t *param) static void params_free(params_t *param)
{ {
free(param->mcast_interface);
free(param->input); free(param->input);
free(param->output); free(param->output);
free(param->summary.file); free(param->summary.file);
...@@ -223,7 +226,7 @@ static void dvbinfo_open(params_t *param) ...@@ -223,7 +226,7 @@ static void dvbinfo_open(params_t *param)
} }
if (param->input && param->b_udp) if (param->input && param->b_udp)
{ {
param->fd_in = udp_open(param->input, param->port); param->fd_in = udp_open(param->mcast_interface, param->input, param->port);
if (param->fd_in < 0) if (param->fd_in < 0)
goto error; goto error;
} }
...@@ -457,6 +460,7 @@ int main(int argc, char **pp_argv) ...@@ -457,6 +460,7 @@ int main(int argc, char **pp_argv)
{ "file", required_argument, NULL, 'f' }, { "file", required_argument, NULL, 'f' },
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
{ "ipaddress", required_argument, NULL, 'i' }, { "ipaddress", required_argument, NULL, 'i' },
{ "miface", required_argument, NULL, 'a' },
{ "tcp", no_argument, NULL, 't' }, { "tcp", no_argument, NULL, 't' },
{ "udp", no_argument, NULL, 'u' }, { "udp", no_argument, NULL, 'u' },
/* - outputs - */ /* - outputs - */
...@@ -471,7 +475,7 @@ int main(int argc, char **pp_argv) ...@@ -471,7 +475,7 @@ int main(int argc, char **pp_argv)
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
while ((c = getopt_long(argc, pp_argv, "d:f:i:ho:ms:tu", long_options, NULL)) != -1) while ((c = getopt_long(argc, pp_argv, "a:d:f:i:ho:ms:tu", long_options, NULL)) != -1)
#else #else
while ((c = getopt_long(argc, pp_argv, "d:f:h", long_options, NULL)) != -1) while ((c = getopt_long(argc, pp_argv, "d:f:h", long_options, NULL)) != -1)
#endif #endif
...@@ -507,6 +511,17 @@ int main(int argc, char **pp_argv) ...@@ -507,6 +511,17 @@ int main(int argc, char **pp_argv)
break; break;
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
case 'a':
{
if (optarg)
{
if (asprintf(&param->mcast_interface, "%s", optarg) < 0)
{
params_free(param);
usage();
}
}
}
case 'i': case 'i':
if (optarg) if (optarg)
{ {
......
...@@ -37,7 +37,10 @@ typedef struct params_s ...@@ -37,7 +37,10 @@ typedef struct params_s
/* parameters */ /* parameters */
char *output; char *output;
char *input; char *input;
int port; int port;
char *mcast_interface;
bool b_udp; bool b_udp;
bool b_tcp; bool b_tcp;
bool b_file; bool b_file;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment