[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-wget] [PATCH] add support for --bindport to choose the TCP source p
From: |
Alban Crequy |
Subject: |
[Bug-wget] [PATCH] add support for --bindport to choose the TCP source port |
Date: |
Tue, 28 Jan 2014 22:40:35 +0000 |
It was useful for my tests on traffic control and I am not sure it makes sense
in other use cases.
---
src/connect.c | 4 ++--
src/init.c | 1 +
src/main.c | 1 +
src/options.h | 1 +
4 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/connect.c b/src/connect.c
index bfb079b..cba52d1 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -190,7 +190,7 @@ resolve_bind_address (struct sockaddr *sa)
if (called)
{
if (should_bind)
- sockaddr_set_data (sa, &ip, 0);
+ sockaddr_set_data (sa, &ip, opt.bind_port);
return should_bind;
}
called = true;
@@ -212,7 +212,7 @@ resolve_bind_address (struct sockaddr *sa)
ip = *address_list_address_at (al, 0);
address_list_release (al);
- sockaddr_set_data (sa, &ip, 0);
+ sockaddr_set_data (sa, &ip, opt.bind_port);
should_bind = true;
return true;
}
diff --git a/src/init.c b/src/init.c
index 43d5ae9..1c8c75a 100644
--- a/src/init.c
+++ b/src/init.c
@@ -137,6 +137,7 @@ static const struct {
{ "backups", &opt.backups, cmd_number },
{ "base", &opt.base_href, cmd_string },
{ "bindaddress", &opt.bind_address, cmd_string },
+ { "bindport", &opt.bind_port, cmd_number },
{ "bodydata", &opt.body_data, cmd_string },
{ "bodyfile", &opt.body_file, cmd_string },
#ifdef HAVE_SSL
diff --git a/src/main.c b/src/main.c
index 2aa961d..ee0af91 100644
--- a/src/main.c
+++ b/src/main.c
@@ -167,6 +167,7 @@ static struct cmdline_option option_data[] =
{ "backups", 0, OPT_BOOLEAN, "backups", -1 },
{ "base", 'B', OPT_VALUE, "base", -1 },
{ "bind-address", 0, OPT_VALUE, "bindaddress", -1 },
+ { "bind-port", 0, OPT_VALUE, "bindport", -1 },
{ "body-data", 0, OPT_VALUE, "bodydata", -1 },
{ "body-file", 0, OPT_VALUE, "bodyfile", -1 },
{ IF_SSL ("ca-certificate"), 0, OPT_VALUE, "cacertificate", -1 },
diff --git a/src/options.h b/src/options.h
index e00fadc..e01e9fd 100644
--- a/src/options.h
+++ b/src/options.h
@@ -195,6 +195,7 @@ struct options
bool page_requisites; /* Whether we need to download all files
necessary to display a page properly. */
char *bind_address; /* What local IP address to bind to. */
+ int bind_port; /* What local port to bind to. */
#ifdef HAVE_SSL
enum {
--
1.8.5.3
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Bug-wget] [PATCH] add support for --bindport to choose the TCP source port,
Alban Crequy <=