diff -Naurp httpd-2.4.1/docs/man/ab.1 httpd-2.4.1.oden/docs/man/ab.1 --- httpd-2.4.1/docs/man/ab.1 2012-01-09 18:03:50.000000000 +0100 +++ httpd-2.4.1.oden/docs/man/ab.1 2012-03-03 12:55:24.277176752 +0100 @@ -124,6 +124,9 @@ String to use as attributes for <table>\ -X \fIproxy\fR[:\fIport\fR] Use a proxy server for the requests\&. .TP +-s \fIsrc_address\fR +Set the local source address\&. +.TP -y \fI<tr>-attributes\fR String to use as attributes for <tr>\&. .TP diff -Naurp httpd-2.4.1/support/ab.c httpd-2.4.1.oden/support/ab.c --- httpd-2.4.1/support/ab.c 2011-10-01 21:48:14.000000000 +0200 +++ httpd-2.4.1.oden/support/ab.c 2012-03-03 12:57:29.040169570 +0100 @@ -291,6 +291,7 @@ int proxyport = 0; /* proxy port */ const char *connecthost; const char *myhost; apr_port_t connectport; +char *src_address; const char *gnuplot; /* GNUplot file */ const char *csvperc; /* CSV Percentile file */ char url[1024]; @@ -1166,6 +1167,7 @@ static void output_html_results(void) static void start_connect(struct connection * c) { apr_status_t rv; + apr_sockaddr_t *from; if (!(started < requests)) return; @@ -1213,6 +1215,14 @@ static void start_connect(struct connect } } + if (src_address) { + if ((rv = apr_sockaddr_info_get(&from, src_address, destsa->family, + 0, 0, c->ctx)) != APR_SUCCESS) + apr_err("src_address get", rv); + if ((rv = apr_socket_bind(c->aprsock, from)) != APR_SUCCESS) + apr_err("src_address bind", rv); + } + c->start = lasttime = apr_time_now(); #ifdef USE_SSL if (is_ssl) { @@ -1874,6 +1884,7 @@ static void usage(const char *progname) fprintf(stderr, " -P attribute Add Basic Proxy Authentication, the attributes\n"); fprintf(stderr, " are a colon separated username and password.\n"); fprintf(stderr, " -X proxy:port Proxyserver and port number to use\n"); + fprintf(stderr, " -s src_address Set the local source address\n"); fprintf(stderr, " -V Print version number and exit\n"); fprintf(stderr, " -k Use HTTP KeepAlive feature\n"); fprintf(stderr, " -d Do not show percentiles served table.\n"); @@ -2052,7 +2063,7 @@ int main(int argc, const char * const ar myhost = NULL; /* 0.0.0.0 or :: */ apr_getopt_init(&opt, cntxt, argc, argv); - while ((status = apr_getopt(opt, "n:c:t:b:T:p:u:v:rkVhwix:y:z:C:H:P:A:g:X:de:SqB:" + while ((status = apr_getopt(opt, "s:n:c:t:b:T:p:u:v:rkVhwix:y:z:C:H:P:A:g:X:de:SqB:" #ifdef USE_SSL "Z:f:" #endif @@ -2067,6 +2078,9 @@ int main(int argc, const char * const ar case 'k': keepalive = 1; break; + case 's': + src_address = strdup(optarg); + break; case 'q': heartbeatres = 0; break;