|
|
|
@ -54,6 +54,9 @@
|
|
|
|
|
#ifdef HAVE_GETOPT_H
|
|
|
|
|
# include <getopt.h>
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_SYSLOG_H
|
|
|
|
|
# include <syslog.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "helper.h"
|
|
|
|
|
#include "header_f.h"
|
|
|
|
@ -157,9 +160,10 @@ void print_long_help() {
|
|
|
|
|
" --transport=STRING specify transport to be used\n"
|
|
|
|
|
" --headers=STRING adds additional headers to the request\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
|
|
|
|
|
);
|
|
|
|
|
exit_code(0);
|
|
|
|
|
exit_code(0, __PRETTY_FUNCTION__, NULL);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -231,9 +235,10 @@ 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 NUMBER log exit message to syslog with given log level\n"
|
|
|
|
|
, DEFAULT_TIMEOUT
|
|
|
|
|
);
|
|
|
|
|
exit_code(0);
|
|
|
|
|
exit_code(0, __PRETTY_FUNCTION__, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
@ -296,6 +301,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
{"transport", 1, 0, 'E'},
|
|
|
|
|
{"headers", 1, 0, 'j'},
|
|
|
|
|
{"authhash", 1, 0, 'J'},
|
|
|
|
|
{"syslog", 1, 0, 'K'},
|
|
|
|
|
#ifdef WITH_TLS_TRANSP
|
|
|
|
|
{"tls-ca-cert", 1, 0, 'k'},
|
|
|
|
|
#endif
|
|
|
|
@ -304,7 +310,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
#endif
|
|
|
|
|
/* some initialisation to be safe */
|
|
|
|
|
file_b=uri_b=trace=lport=usrloc=flood=verbose=randtrash=trashchar = 0;
|
|
|
|
|
warning_ext=rand_rem=nonce_count=replace_b=invite=message = 0;
|
|
|
|
|
warning_ext=rand_rem=nonce_count=replace_b=invite=message=sysl = 0;
|
|
|
|
|
sleep_ms=empty_contact=nagios_warn=timing=outbound_proxy=symmetric = 0;
|
|
|
|
|
namebeg=nameend=maxforw= -1;
|
|
|
|
|
#ifdef OLDSTYLE_FQDN
|
|
|
|
@ -345,9 +351,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:l:Lm:MnNo:O:p:P:q:r:Rs:St:Tu:UvVwW:x:Xz: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:Xz: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: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){
|
|
|
|
|
case 'a':
|
|
|
|
@ -355,7 +361,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
password = str_alloc(SIPSAK_MAX_PASSWD_LEN);
|
|
|
|
|
printf("Please enter the password (max. length %i): ", SIPSAK_MAX_PASSWD_LEN);
|
|
|
|
|
if (read_stdin(password, SIPSAK_MAX_PASSWD_LEN, 1) == 0) {
|
|
|
|
|
exit_code(0);
|
|
|
|
|
exit_code(0, __PRETTY_FUNCTION__, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -379,15 +385,15 @@ int main(int argc, char *argv[])
|
|
|
|
|
parse_uri(backup, &scheme, &user, &host, &port);
|
|
|
|
|
if (scheme == NULL) {
|
|
|
|
|
fprintf(stderr, "error: missing scheme in From URI\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing scheme in From URI");
|
|
|
|
|
}
|
|
|
|
|
else if (user == NULL) {
|
|
|
|
|
fprintf(stderr, "error: missing username in From URI\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing username in From URI");
|
|
|
|
|
}
|
|
|
|
|
else if (host == NULL) {
|
|
|
|
|
fprintf(stderr, "error: missing host in From URI\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing host in From URI");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
from_uri=str_alloc(strlen(optarg)+1);
|
|
|
|
@ -412,7 +418,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
if (scheme == NULL) {
|
|
|
|
|
fprintf(stderr, "error: REGISTER Contact uri doesn't not contain "
|
|
|
|
|
"sip:, sips:, *, or is not empty\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "unsupported Contact for registration");
|
|
|
|
|
}
|
|
|
|
|
/*else if (user == NULL) {
|
|
|
|
|
fprintf(stderr, "error: missing username in Contact uri\n");
|
|
|
|
@ -420,7 +426,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
}*/
|
|
|
|
|
else if (host == NULL) {
|
|
|
|
|
fprintf(stderr, "error: missing host in Contact uri\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing host in Contact");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
contact_uri=str_alloc(strlen(optarg)+1);
|
|
|
|
@ -436,7 +442,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
timer_final = str_to_int(0, optarg);
|
|
|
|
|
if (timer_final <= 0) {
|
|
|
|
|
fprintf(stderr, "error: option D has to be above 0\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "option D has to be above 0");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'e':
|
|
|
|
@ -459,7 +465,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
#endif
|
|
|
|
|
else {
|
|
|
|
|
fprintf(stderr, "error: unsupported transport '%s', supported values: udp, tcp\n", optarg);
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "unsupported transport");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'F':
|
|
|
|
@ -472,25 +478,25 @@ int main(int argc, char *argv[])
|
|
|
|
|
pf = fopen(optarg, "rb");
|
|
|
|
|
if (!pf){
|
|
|
|
|
fprintf(stderr, "error: unable to open the file '%s'.\n", optarg);
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "failed to open file from the f option");
|
|
|
|
|
}
|
|
|
|
|
if (fread(buff, 1, sizeof(buff), pf) >= sizeof(buff)){
|
|
|
|
|
fprintf(stderr, "error:the file is too big. try files of less "
|
|
|
|
|
"than %i bytes.\n", BUFSIZE);
|
|
|
|
|
fprintf(stderr, " or recompile the program with bigger "
|
|
|
|
|
"BUFSIZE defined.\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "file to big for buffer");
|
|
|
|
|
}
|
|
|
|
|
fclose(pf);
|
|
|
|
|
}
|
|
|
|
|
else if (strlen(optarg) == 1 && STRNCASECMP(optarg, "-", 1) == 0) {
|
|
|
|
|
if (read_stdin(&buff[0], sizeof(buff), 0) == 0) {
|
|
|
|
|
exit_code(0);
|
|
|
|
|
exit_code(0, __PRETTY_FUNCTION__, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fprintf(stderr, "error: unable to handle input file name: %s\n", optarg);
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "unsupported input file name");
|
|
|
|
|
}
|
|
|
|
|
file_b=1;
|
|
|
|
|
break;
|
|
|
|
@ -518,7 +524,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
case 'J':
|
|
|
|
|
if (strlen(optarg) < SIPSAK_HASHHEXLEN_MD5) {
|
|
|
|
|
fprintf(stderr, "error: authhash string is too short\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "authhash string is too short");
|
|
|
|
|
}
|
|
|
|
|
authhash=optarg;
|
|
|
|
|
break;
|
|
|
|
@ -527,12 +533,22 @@ int main(int argc, char *argv[])
|
|
|
|
|
pf = fopen(optarg, "rb");
|
|
|
|
|
if (!pf){
|
|
|
|
|
fprintf(stderr, "error: unable to open the CA cert file '%s'.\n", optarg);
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "failed to open CA cert file");
|
|
|
|
|
}
|
|
|
|
|
fclose(pf);
|
|
|
|
|
ca_file=optarg;
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
|
|
|
|
case 'K':
|
|
|
|
|
sysl=str_to_int(0, optarg);
|
|
|
|
|
if (sysl < LOG_ALERT || sysl > LOG_DEBUG) {
|
|
|
|
|
fprintf(stderr, "error: syslog value '%d' must be between ALERT (1) and DEBUG (7)\n", optarg);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "unsupported syslog value for option K");
|
|
|
|
|
}
|
|
|
|
|
#ifdef HAVE_SYSLOG_H
|
|
|
|
|
openlog(PACKAGE_NAME, LOG_CONS|LOG_NOWAIT|LOG_PID, LOG_USER);
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
|
|
|
|
case 'l':
|
|
|
|
|
lport=str_to_int(0, optarg);
|
|
|
|
|
break;
|
|
|
|
@ -568,7 +584,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
parse_uri(optarg, &scheme, &user, &host, &port);
|
|
|
|
|
if (host == NULL) {
|
|
|
|
|
fprintf(stderr, "error: missing in host in outbound proxy\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing host in outbound proxy");
|
|
|
|
|
}
|
|
|
|
|
if (is_ip(host)) {
|
|
|
|
|
address = getaddress(host);
|
|
|
|
@ -589,7 +605,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
if (!address){
|
|
|
|
|
fprintf(stderr, "error:unable to determine the outbound proxy "
|
|
|
|
|
"address\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "failed to resolve the outbound proxy");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (port && !rport) {
|
|
|
|
@ -613,11 +629,11 @@ int main(int argc, char *argv[])
|
|
|
|
|
};
|
|
|
|
|
if (!re) {
|
|
|
|
|
fprintf(stderr, "Error: can't allocate RE\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "failed to allocate memory for regualr expression");
|
|
|
|
|
};
|
|
|
|
|
if (regcomp(re, optarg, REG_EXTENDED|REG_ICASE|REG_NEWLINE )!=0) {
|
|
|
|
|
fprintf(stderr, "Error: compiling RE: %s\n", optarg );
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "failed to compile regular expression");
|
|
|
|
|
};
|
|
|
|
|
break;
|
|
|
|
|
case 'r':
|
|
|
|
@ -635,15 +651,15 @@ int main(int argc, char *argv[])
|
|
|
|
|
parse_uri(optarg, &scheme, &user, &host, &port);
|
|
|
|
|
if (scheme == NULL) {
|
|
|
|
|
fprintf(stderr, "error: missing scheme in sip uri\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing scheme in target SIP URI");
|
|
|
|
|
}
|
|
|
|
|
if (strlen(optarg) == 4 && STRNCASECMP(optarg,"sips",4) == 0){
|
|
|
|
|
fprintf(stderr, "error: sips is not supported yet\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "unsupported scheme SIPS in target URI");
|
|
|
|
|
}
|
|
|
|
|
else if (strlen(optarg) != 3 || STRNCASECMP(optarg,"sip",3) != 0){
|
|
|
|
|
fprintf(stderr, "error: scheme of sip uri has to be sip\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "unsupported scheme in target URI");
|
|
|
|
|
}
|
|
|
|
|
if (user != NULL) {
|
|
|
|
|
username = user;
|
|
|
|
@ -653,7 +669,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
fprintf(stderr, "error: missing hostname in sip uri\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing host name in target URI");
|
|
|
|
|
}
|
|
|
|
|
if (port && !rport) {
|
|
|
|
|
rport = port;
|
|
|
|
@ -676,7 +692,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
}
|
|
|
|
|
if (!address){
|
|
|
|
|
fprintf(stderr, "error:unable to determine the IP address for: %s\n", domainname);
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "failed to resolve host from target URI");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (port != 0) {
|
|
|
|
@ -759,7 +775,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
printf(", DEBUG");
|
|
|
|
|
#endif
|
|
|
|
|
printf("\n");
|
|
|
|
|
exit_code(0);
|
|
|
|
|
exit_code(0, __PRETTY_FUNCTION__, NULL);
|
|
|
|
|
break;
|
|
|
|
|
case 'w':
|
|
|
|
|
warning_ext=1;
|
|
|
|
@ -779,19 +795,19 @@ int main(int argc, char *argv[])
|
|
|
|
|
rand_rem=str_to_int(0, optarg);
|
|
|
|
|
if (rand_rem < 0 || rand_rem > 100) {
|
|
|
|
|
fprintf(stderr, "error: z option must between 0 and 100\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "value for option z out of range");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'Z':
|
|
|
|
|
timer_t1 = str_to_int(0, optarg);
|
|
|
|
|
if (timer_t1 <= 0) {
|
|
|
|
|
fprintf(stderr, "error: Z option must be above 0\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "value for option Z must be above 0");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(stderr, "error: unknown parameter %c\n", c);
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "unknown parameter");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -801,7 +817,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
}
|
|
|
|
|
if (rport > 65535 || rport <= 0) {
|
|
|
|
|
fprintf(stderr, "error: invalid remote port: %i\n", rport);
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "remote port out of range");
|
|
|
|
|
}
|
|
|
|
|
if (transport == 0) {
|
|
|
|
|
transport = SIP_UDP_TRANSPORT;
|
|
|
|
@ -831,11 +847,11 @@ int main(int argc, char *argv[])
|
|
|
|
|
if (usrloc || flood || randtrash) {
|
|
|
|
|
fprintf(stderr, "error: trace can't be combined with usrloc, random or "
|
|
|
|
|
"flood\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "trace mode can't be combined with other modes");
|
|
|
|
|
}
|
|
|
|
|
if (!uri_b) {
|
|
|
|
|
fprintf(stderr, "error: for trace mode a SIPURI is realy needed\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing URI for trace mode");
|
|
|
|
|
}
|
|
|
|
|
if (file_b) {
|
|
|
|
|
fprintf(stderr, "warning: file will be ignored for tracing.");
|
|
|
|
@ -843,7 +859,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
if (!username) {
|
|
|
|
|
fprintf(stderr, "error: for trace mode without a file the SIPURI have to "
|
|
|
|
|
"contain a username\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing username in target URI");
|
|
|
|
|
}
|
|
|
|
|
if (!via_ins){
|
|
|
|
|
fprintf(stderr, "warning: Via-Line is needed for tracing. Ignoring -i\n");
|
|
|
|
@ -860,33 +876,33 @@ int main(int argc, char *argv[])
|
|
|
|
|
if (trace || flood || randtrash) {
|
|
|
|
|
fprintf(stderr, "error: usrloc can't be combined with trace, random or "
|
|
|
|
|
"flood\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "usrloc mode can't be combined with other modes");
|
|
|
|
|
}
|
|
|
|
|
if (!username || !uri_b) {
|
|
|
|
|
fprintf(stderr, "error: for the USRLOC mode you have to give a SIPURI with "
|
|
|
|
|
"a username\n at least\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing target URI or username in URI");
|
|
|
|
|
}
|
|
|
|
|
if (namebeg>0 && nameend==-1) {
|
|
|
|
|
fprintf(stderr, "error: if a starting numbers is given also an ending "
|
|
|
|
|
"number have to be specified\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing end number");
|
|
|
|
|
}
|
|
|
|
|
if (invite && message) {
|
|
|
|
|
fprintf(stderr, "error: invite and message tests are XOR\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "INVITE and MESSAGE tests are XOR");
|
|
|
|
|
}
|
|
|
|
|
if (!usrloc && invite && !lport) {
|
|
|
|
|
fprintf(stderr, "warning: Do NOT use the usrloc invite mode without "
|
|
|
|
|
"registering sipsak before.\n See man page for "
|
|
|
|
|
"details.\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "don't use usrloc INVITE mode without registerting before");
|
|
|
|
|
}
|
|
|
|
|
if (contact_uri!=NULL) {
|
|
|
|
|
if (invite || message) {
|
|
|
|
|
fprintf(stderr, "error: Contact uri is not support for invites or "
|
|
|
|
|
"messages\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "Contact URI not supported for INVITE or MESSAGE mode");
|
|
|
|
|
}
|
|
|
|
|
if (nameend!=-1 || namebeg!=-1) {
|
|
|
|
|
fprintf(stderr, "warning: ignoring starting or ending number if Contact"
|
|
|
|
@ -911,11 +927,11 @@ int main(int argc, char *argv[])
|
|
|
|
|
if (trace || usrloc || randtrash) {
|
|
|
|
|
fprintf(stderr, "error: flood can't be combined with trace, random or "
|
|
|
|
|
"usrloc\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "flood mode can't be combined with other modes");
|
|
|
|
|
}
|
|
|
|
|
if (!uri_b) {
|
|
|
|
|
fprintf(stderr, "error: we need at least a sip uri for flood\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing target URI");
|
|
|
|
|
}
|
|
|
|
|
if (redirects) {
|
|
|
|
|
fprintf(stderr, "warning: redirects are not expected in flood. "
|
|
|
|
@ -927,11 +943,11 @@ int main(int argc, char *argv[])
|
|
|
|
|
if (trace || usrloc || flood) {
|
|
|
|
|
fprintf(stderr, "error: random can't be combined with trace, flood or "
|
|
|
|
|
"usrloc\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "random mode can't be combined with other modes");
|
|
|
|
|
}
|
|
|
|
|
if (!uri_b) {
|
|
|
|
|
fprintf(stderr, "error: need at least a sip uri for random\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing target URI");
|
|
|
|
|
}
|
|
|
|
|
if (redirects) {
|
|
|
|
|
fprintf(stderr, "warning: redirects are not expected in random. "
|
|
|
|
@ -950,7 +966,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
}
|
|
|
|
|
if (!uri_b) {
|
|
|
|
|
fprintf(stderr, "error: need at least a sip uri to send a meesage\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing target SIP URI");
|
|
|
|
|
}
|
|
|
|
|
if (nameend==-1)
|
|
|
|
|
nameend=0;
|
|
|
|
@ -960,7 +976,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
else {
|
|
|
|
|
if (!uri_b) {
|
|
|
|
|
fprintf(stderr, "error: a spi uri is needed at least\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "missing target SIP URI");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -978,7 +994,7 @@ int main(int argc, char *argv[])
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(stderr, "unknown transport: %i\n", transport);
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "unknown transport");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_TLS_TRANSP
|
|
|
|
@ -1010,14 +1026,14 @@ int main(int argc, char *argv[])
|
|
|
|
|
if (processes > 1) {
|
|
|
|
|
if (signal(SIGCHLD , sigchld_handler) == SIG_ERR ) {
|
|
|
|
|
fprintf(stderr, "error: Could not install SIGCHLD handler\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "failed to install SIGCHLD handler");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < processes - 1; i++) {
|
|
|
|
|
if ((pid = fork()) < 0) {
|
|
|
|
|
fprintf(stderr, "error: Cannot fork\n");
|
|
|
|
|
exit_code(2);
|
|
|
|
|
exit_code(2, __PRETTY_FUNCTION__, "failed to fork");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pid == 0){
|
|
|
|
|