added option -k, --local-ip

(cherry picked from commit af8ab2a08218876521794317b5e08bd2d191185c)
changes/49/4849/1
root 10 years ago committed by Victor Seva
parent 9fbed2f23c
commit c88d446f37

@ -317,6 +317,9 @@ option is required if this option is provided. The given
.BR string
is expected to be a hex string with the length of the used hash function.
.IP "-k, --local-ip STRING"
The local ip address to be used
.IP "-l, --local-port PORT"
The receiving UDP socket will use the local network
.I port.

@ -159,6 +159,7 @@ void print_long_help() {
" --timer-t1=NUMBER timeout T1 in ms (default: %i)\n"
" --transport=STRING specify transport to be used\n"
" --headers=STRING adds additional headers to the request\n"
" --local-ip=STRING specify local ip address to be used\n"
" --authhash=STRING ha1 hash for authentication instead of password\n"
" --sylog=NUMBER log exit message to syslog with given log level\n"
, DEFAULT_TIMEOUT
@ -241,6 +242,7 @@ void print_help() {
" -E STRING specify transport to be used\n"
" -j STRING adds additional headers to the request\n"
" -J STRING ha1 hash for authentication instead of password\n"
" -k STRING specify local ip address to be used\n"
" -K NUMBER log exit message to syslog with given log level\n"
, DEFAULT_TIMEOUT
);
@ -307,6 +309,7 @@ int main(int argc, char *argv[])
{"transport", 1, 0, 'E'},
{"headers", 1, 0, 'j'},
{"authhash", 1, 0, 'J'},
{"local-ip", 1, 0, 'k'},
{"syslog", 1, 0, 'K'},
#ifdef WITH_TLS_TRANSP
{"tls-ca-cert", 1, 0, 0},
@ -328,7 +331,7 @@ int main(int argc, char *argv[])
#endif
via_ins=redirects=fix_crlf=processes = 1;
username=password=replace_str=hostname=contact_uri=mes_body = NULL;
con_dis=auth_username=from_uri=headers=authhash = NULL;
con_dis=auth_username=from_uri=headers=authhash=local_ip = NULL;
scheme = user = host = backup = req = rep = rec = NULL;
re = NULL;
address= 0;
@ -360,9 +363,9 @@ int main(int argc, char *argv[])
/* lots of command line switches to handle*/
#ifdef HAVE_GETOPT_LONG
while ((c=getopt_long(argc, argv, "a:A:b:B:c:C:dD:e:E:f:Fg:GhH:iIj:J:K:l:Lm:MnNo:O:p:P:q:r:Rs:St:Tu:UvVwW:x:z:Z:", l_opts, &option_index)) != EOF){
while ((c=getopt_long(argc, argv, "a:A:b:B:c:C:dD:e:E:f:Fg:GhH:iIj:J:k:K:l:Lm:MnNo:O:p:P:q:r:Rs:St:Tu:UvVwW:x:z:Z:", l_opts, &option_index)) != EOF){
#else
while ((c=getopt(argc, argv, "a:A:b:B:c:C:dD:e:E:f:Fg:GhH:iIj:J:K:l:Lm:MnNo:O:p:P:q:r:Rs:St:Tu:UvVwW:x:z:Z:")) != EOF){
while ((c=getopt(argc, argv, "a:A:b:B:c:C:dD:e:E:f:Fg:GhH:iIj:J:k:K:l:Lm:MnNo:O:p:P:q:r:Rs:St:Tu:UvVwW:x:z:Z:")) != EOF){
#endif
switch(c){
#ifdef HAVE_GETOPT_LONG
@ -575,6 +578,9 @@ int main(int argc, char *argv[])
}
authhash=optarg;
break;
case 'k':
local_ip=optarg;
break;
case 'K':
sysl=str_to_int(0, optarg);
if (sysl < LOG_ALERT || sysl > LOG_DEBUG) {

@ -329,7 +329,7 @@ int file_b, uri_b, trace, via_ins, usrloc, redirects, rand_rem, replace_b;
int empty_contact, nagios_warn, fix_crlf, timing, outbound_proxy;
int timer_t1, timer_t2, timer_final, sysl;
char *username, *domainname, *password, *replace_str, *hostname, *contact_uri;
char *mes_body, *con_dis, *auth_username, *from_uri, *headers, *authhash;
char *mes_body, *con_dis, *auth_username, *from_uri, *headers, *authhash, *local_ip;
char fqdn[FQDN_SIZE];
char target_dot[INET_ADDRSTRLEN], source_dot[INET_ADDRSTRLEN];
char *req, *rep, *rec, *transport_str;

@ -564,7 +564,11 @@ void create_sockets(struct sipsak_con_data *cd) {
memset(&(cd->adr), 0, sizeof(struct sockaddr_in));
cd->adr.sin_family = AF_INET;
cd->adr.sin_addr.s_addr = htonl( INADDR_ANY);
if(local_ip) {
cd->adr.sin_addr.s_addr = inet_addr(local_ip);
} else {
cd->adr.sin_addr.s_addr = htonl( INADDR_ANY);
}
cd->adr.sin_port = htons((short)lport);
if (transport == SIP_UDP_TRANSPORT) {

Loading…
Cancel
Save