summaryrefslogtreecommitdiff
path: root/staging
diff options
context:
space:
mode:
authorJon Schipp <jonschipp@gmail.com>2014-07-24 18:01:43 +0000
committerTobias Klauser <tklauser@distanz.ch>2014-07-25 08:21:58 +0200
commit2de653340c789c2ef4b442b146c3f3e53e306c31 (patch)
tree4a080d8db93f368acaa0360422df92873da6d3cf /staging
parent52463b7934760b1afabd6523913a48ba2a7c51ee (diff)
mausezahn: bind to IP address in interactive mode
Adds new option ``-l'' that can be used to set mausezahn's listen address to bind to an IP of choice. e.g. mausezahn -l 127.0.0.1 -x Signed-off-by: Jon Schipp <jonschipp@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'staging')
-rw-r--r--staging/cli.c2
-rw-r--r--staging/cli.h1
-rw-r--r--staging/mausezahn.c9
3 files changed, 9 insertions, 3 deletions
diff --git a/staging/cli.c b/staging/cli.c
index ad040a1..7d8e2ce 100644
--- a/staging/cli.c
+++ b/staging/cli.c
@@ -532,7 +532,7 @@ int cli()
// Listen on port mz_port (default: 25542, towel day)
memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET;
- servaddr.sin_addr.s_addr = htonl(INADDR_ANY); // TODO: specified interface
+ inet_aton(mz_listen_addr, &servaddr.sin_addr);
servaddr.sin_port = htons(mz_port);
bind(s, (struct sockaddr *)&servaddr, sizeof(servaddr));
diff --git a/staging/cli.h b/staging/cli.h
index 5762de4..dd8e5e1 100644
--- a/staging/cli.h
+++ b/staging/cli.h
@@ -59,6 +59,7 @@ struct cli_def *gcli;
char mz_username[32];
char mz_password[32];
char mz_enable[32];
+char mz_listen_addr[15];
int mz_port;
struct mops *clipkt; // actual packet used by CLI thread
diff --git a/staging/mausezahn.c b/staging/mausezahn.c
index 759ac28..8b2c499 100644
--- a/staging/mausezahn.c
+++ b/staging/mausezahn.c
@@ -33,7 +33,7 @@
int verbose_level = 0;
-static const char *short_options = "46hqvVSxra:A:b:B:c:d:E:f:F:p:P:t:T:M:Q:X:";
+static const char *short_options = "46hqvVSxra:A:b:B:c:d:E:f:F:l:p:P:t:T:M:Q:X:";
static void signal_handler(int number)
{
@@ -109,6 +109,7 @@ static void help(void)
"Usage: mausezahn [options] [interface] <keyword>|<arg-string>|<hex-string>\n"
"Options:\n"
" -x <port> Interactive mode with telnet CLI, default port: 25542\n"
+ " -l <ip> Listen address to bind to when in interactive mode, default: 0.0.0.0\n"
" -4 IPv4 mode (default)\n"
" -6 IPv6 mode\n"
" -c <count> Send packet count times, default:1, infinite:0\n"
@@ -208,8 +209,9 @@ int reset()
fp2 = NULL;
mz_port = 0;
mz_rand = 0;
+ char mz_listen_addr[15] = "0.0.0.0";
mp_head = NULL;
-
+
for (i=0;i<TIME_COUNT_MAX;i++) jitter[i] = 0;
time0_flag = 0; // If set then time0 has valid data
@@ -395,6 +397,9 @@ int getopts (int argc, char *argv[])
case 'x':
mz_port = MZ_DEFAULT_PORT;
break;
+ case 'l':
+ strncpy (mz_listen_addr, optarg, sizeof(mz_listen_addr));
+ break;
case 'a':
strncpy (tx.eth_src_txt, optarg, 32);
tx.packet_mode = 0;