]> sjero.net Git - wget/commitdiff
Add --bindport option to force TCP source port. bindport
authorSamuel Jero <sjero@purdue.edu>
Fri, 13 Jun 2014 01:28:44 +0000 (20:28 -0500)
committerSamuel Jero <sjero@purdue.edu>
Fri, 13 Jun 2014 01:28:44 +0000 (20:28 -0500)
https://lists.gnu.org/archive/html/bug-wget/2014-01/msg00070.html

src/connect.c
src/init.c
src/main.c
src/options.h

index 1e4a44bae3d8d98e12b6efaffc195feb7e650ac0..90e2abf4a49da2d5901120a4eaa9dc081afa14e7 100644 (file)
@@ -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;
 }
index 9a6fd2b5c4f5e76780c4ecc5d6056518d4971512..fd8eb0c0e9c94673e9b38d124f3a89a9e2199a8d 100644 (file)
@@ -138,6 +138,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
index 4b230531f07df963098cd1352b74826cf286bca3..1e087067498524df231a3c9d9a78c802d0c47670 100644 (file)
@@ -161,6 +161,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 },
index cd4e5188fd0a13518e730b9f09f0176e0fc4f4c4..ccca0d30857ec7d8d34f59e99e43e003f9df393d 100644 (file)
@@ -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 {