From 263f223eb9cbcf07cc593b1a84e743c2528fe586 Mon Sep 17 00:00:00 2001 From: Erik Alexandre Pucci <eap08@c3sl.ufpr.br> Date: Sun, 28 Nov 2010 16:04:48 -0200 Subject: [PATCH] client.c: Added "--nic" option The client now can be bound to a specific network interface device by using the "--nic=device_name" ("-n" for short) option, where device_name is the NIC name (e.g. eth0, wlan0). Signed-off-by: Erik Alexandre Pucci <eap08@c3sl.ufpr.br> Acked-by: Ricardo Tavares de Oliveira <rto07@c3sl.ufpr.br> Signed-off-by: Danilo K. S. Yorinori <danilok@c3sl.ufpr.br> --- src/client.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/client.c b/src/client.c index dda8781..608a936 100644 --- a/src/client.c +++ b/src/client.c @@ -121,6 +121,7 @@ void print_help(void) ERROR("-U, --puid=userid Proxy user id\n"); ERROR("-w, --ppasswd=pswd Proxy password\n"); ERROR("-h, --help Show this help\n"); + ERROR("-n, --nic=eth0 Network interface to be bound\n"); } /*---------------------------------------------------------------------------- @@ -143,23 +144,24 @@ int verify_parameters(int argc, char **argv, struct soap *soap, char **url, int inventory, update, help, invalid_option; static struct option long_options[] = { - {"help", no_argument, 0, 'h'}, + {"help", no_argument, 0, 'h'}, {INVENTORYOPTION, no_argument, 0, 'i'}, - {UPDATEOPTION, no_argument, 0, 'u'}, - {"url", required_argument, 0, 'l'}, - {"inep", required_argument, 0, 'I'}, - {"phost", required_argument, 0, 'H'}, - {"pport", required_argument, 0, 'p'}, - {"puid", required_argument, 0, 'U'}, + {UPDATEOPTION, no_argument, 0, 'u'}, + {"url", required_argument, 0, 'l'}, + {"inep", required_argument, 0, 'I'}, + {"phost", required_argument, 0, 'H'}, + {"pport", required_argument, 0, 'p'}, + {"puid", required_argument, 0, 'U'}, {"ppasswd", required_argument, 0, 'w'}, + {"nic", required_argument, 0, 'n'}, {0, 0, 0, 0} }; inventory = update = help = invalid_option = 0; /* Parse command line */ - while ((option = getopt_long(argc, argv, "hiul:I:H:p:U:w:", long_options, - &option_index)) != -1) + while ((option = getopt_long(argc, argv, "hiul:I:H:p:U:w:n:", + long_options, &option_index)) != -1) { switch(option) { @@ -199,6 +201,11 @@ int verify_parameters(int argc, char **argv, struct soap *soap, char **url, /* Print help message */ help = 1; break; + case 'n': + soap->device = malloc(sizeof(char) * strlen(optarg)); + strcpy(soap->device, optarg); + DEBUG("Network interface device \"%s\" used\n", soap->device); + break; case '?': /* Invalid option(s) passed in command line */ invalid_option = 1; -- GitLab