added syslog support

git-svn-id: http://svn.berlios.de/svnroot/repos/sipsak/trunk@437 75b5f7c7-cfd4-0310-b54c-e118b2c5249a
(cherry picked from commit 4905b7e8c1f1a6955b12907b28b7589c1f49ecdc)
changes/49/4849/1
nils-ohlmeier 18 years ago committed by Victor Seva
parent aee09b0602
commit 977126da04

@ -83,7 +83,7 @@ void insert_auth(char *message, char *authreq)
fprintf(stderr, "request:\n%s\nresponse:\n%s\nerror: authorization failed\n "
" request already contains (Proxy-) Authorization, but "
"received 40[1|7], see above\n", message, authreq);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to add auth header, because request contained already one");
}
/* make a backup of all except the request line because for
simplicity we insert the auth header direct behind the request line */
@ -111,12 +111,12 @@ void insert_auth(char *message, char *authreq)
if ((begin=STRCASESTR(auth, "Basic"))!=NULL) {
fprintf(stderr, "%s\nerror: authentication method Basic is deprecated since"
" RFC 3261 and not supported by sipsak\n", authreq);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "authentication method 'Basic' is deprecated");
}
if ((begin=STRCASESTR(auth, "Digest"))==NULL) {
fprintf(stderr, "%s\nerror: couldn't find authentication method Digest in "
"the 40[1|7] response above\n", authreq);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "missing authentication method 'Digest' in reply");
}
if ((begin=STRCASESTR(auth, "algorithm="))!=NULL) {
begin+=10;
@ -130,7 +130,7 @@ void insert_auth(char *message, char *authreq)
#endif
else {
fprintf(stderr, "\n%s\nerror: unsupported authentication algorithm\n", authreq);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "unsupported authentication algorithm");
}
}
else {
@ -201,7 +201,7 @@ void insert_auth(char *message, char *authreq)
}
else {
fprintf(stderr, "%s\nerror: realm not found in 401 above\n", authreq);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "realm not found in reply");
}
/* copy opaque if needed */
if ((begin=STRCASESTR(auth, OPAQUE_STR))!=NULL) {
@ -221,7 +221,7 @@ void insert_auth(char *message, char *authreq)
if (STRCASESTR(begin, QOPAUTH_STR)==NULL) {
fprintf(stderr, "response\n%s\nerror: qop \"auth\" not supported by"
" server\n", authreq);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "qop 'auth' is not supported by server");
}
qop_auth=1;
}
@ -243,7 +243,7 @@ void insert_auth(char *message, char *authreq)
}
else {
fprintf(stderr, "%s\nerror: nonce not found in 401 above\n", authreq);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "missing nonce in reply");
}
/* if qop is supported we need som additional header */
if (qop_auth == 1) {
@ -344,7 +344,7 @@ void insert_auth(char *message, char *authreq)
else {
fprintf(stderr, "%s\nerror: couldn't find Proxy- or WWW-Authentication header"
" in the 401 response above\n", authreq);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "missing authentication header in reply");
}
if (verbose>1)
printf("authorizing\n");

@ -166,6 +166,12 @@
/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL
/* Define to 1 if you have the `syslog' function. */
#undef HAVE_SYSLOG
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H

7
configure vendored

@ -5255,7 +5255,9 @@ fi
done
for ac_header in getopt.h
for ac_header in getopt.h syslog.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@ -6580,7 +6582,8 @@ done
for ac_func in calloc getdomainname getopt_long inet_ntop strncasecmp strcasestr
for ac_func in calloc getdomainname getopt_long inet_ntop strncasecmp strcasestr syslog
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5

@ -35,7 +35,7 @@ AC_SUBST([LIBS])
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([ctype.h errno.h arpa/inet.h netdb.h netinet/in.h netinet/in_systm.h limits.h sys/poll.h regex.h signal.h stdarg.h stdlib.h stdio.h string.h sys/param.h sys/socket.h sys/time.h unistd.h sys/utsname.h],,[AC_MSG_ERROR([missing required header (see above)])],)
AC_CHECK_HEADERS([getopt.h])
AC_CHECK_HEADERS([getopt.h syslog.h])
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
@ -51,7 +51,7 @@ AC_HEADER_TIME
AC_FUNC_MALLOC
AC_FUNC_SELECT_ARGTYPES
AC_CHECK_FUNCS([getchar gethostbyname gethostname getopt getpid gettimeofday memset ntohs regcomp select socket strchr strcmp strstr strtol uname],,[AC_MSG_ERROR([missing required function (see above)])])
AC_CHECK_FUNCS([calloc getdomainname getopt_long inet_ntop strncasecmp strcasestr])
AC_CHECK_FUNCS([calloc getdomainname getopt_long inet_ntop strncasecmp strcasestr syslog])
# Check if the check unit test framework is available
AM_PATH_CHECK([0.9.3])

@ -29,12 +29,15 @@
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_SYSLOG_H
# include <syslog.h>
#endif
#include "exit_code.h"
enum exit_modes exit_mode = EM_DEFAULT;
void exit_code(int code)
void exit_code(int code, const char *function, const char *reason)
{
#ifdef WITH_TLS_TRANSP
if (transport == SIP_TLS_TRANSPORT) {
@ -53,24 +56,28 @@ void exit_code(int code)
}
#endif /* WITH_TLS_TRANSP */
if ((sysl > 0) && (reason != NULL)) {
#ifdef HAVE_SYSLOG
syslog(LOG_INFO, "%s: %s", function, reason);
closelog();
#endif
}
switch(exit_mode) {
case EM_DEFAULT:
if (code == 4) {
exit(0);
}
else {
} else {
exit(code);
}
case EM_NAGIOS:
if (code == 0) {
printf("SIP ok\n");
exit(0);
}
else if (code == 4) {
} else if (code == 4) {
printf("SIP warning\n");
exit(1);
}
else {
} else {
printf("SIP failure\n");
exit(2);
}

@ -24,6 +24,6 @@ enum exit_modes { EM_DEFAULT, EM_NAGIOS };
extern enum exit_modes exit_mode;
void exit_code( int code );
void exit_code(int code, const char *function, const char *reason);
#endif

@ -33,7 +33,7 @@ void insert_header(char *mes, char *header, int first) {
ins = strchr(mes, '\n');
if (ins == NULL) {
printf("failed to find a new line in the message\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to find a new line in the message");
}
ins++;
}
@ -60,7 +60,7 @@ void add_via(char *mes)
if(via == NULL) {
fprintf(stderr, "error: failed to find a position to insert Via:\n"
"'%s'\n", mes);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to find position to insert to insert Via header");
}
via++;
}
@ -78,7 +78,7 @@ void add_via(char *mes)
if (strlen(mes)+strlen(via_line)>= BUFSIZE){
printf("can't add our Via Header Line because file is too big\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "Via header to big for buffer");
}
/* finnaly make a backup, insert our via and append the backup */
backup=str_alloc((strlen(via)+1));
@ -101,7 +101,7 @@ void cpy_vias(char *reply, char *dest){
if ((first_via=STRCASESTR(reply, VIA_STR))==NULL &&
(first_via=STRCASESTR(reply, VIA_SHORT_STR))==NULL ){
fprintf(stderr, "error: the received message doesn't contain a Via header\n");
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "missing Via header in message");
}
last_via=first_via+4;
middle_via=last_via;
@ -130,7 +130,7 @@ void cpy_to(char *reply, char *dest) {
if ((dst_to=STRCASESTR(dest, TO_STR))==NULL &&
(dst_to=STRCASESTR(dest, TO_SHORT_STR))==NULL) {
fprintf(stderr, "error: could not find To in the destination: %s\n", dest);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "missing To header in target buffer");
}
if (*dst_to == '\n')
dst_to++;
@ -169,7 +169,7 @@ void set_maxforw(char *mes, int value){
max=strchr(mes,'\n');
if (!max) {
printf("failed to find newline\n");
exit_code(254);
exit_code(254, __PRETTY_FUNCTION__, "missing newline in buffer");
}
max++;
backup=str_alloc(strlen(max)+1);
@ -224,7 +224,7 @@ void uri_replace(char *mes, char *uri)
foo=strchr(mes, '\n');
if (!foo) {
printf("failed to find newline\n");
exit_code(254);
exit_code(254, __PRETTY_FUNCTION__, "missing newline in buffer");
}
foo++;
backup=str_alloc(strlen(foo)+1);
@ -312,15 +312,15 @@ void cpy_rr(char* src, char *dst, int route) {
cr = strchr(dst, '\n');
if (cr == NULL) {
fprintf(stderr, "error: failed to end of line in destination\n");
exit_code(3);
fprintf(stderr, "error: failed to find newline in destination\n");
exit_code(3, __PRETTY_FUNCTION__, "missing newline in target buffer");
}
cr++;
rr = STRCASESTR(src, RR_STR);
if (rr != NULL) {
if (find_lr_parameter(rr) == 0) {
fprintf(stderr, "error: strict routing is not support yet\n");
exit_code(252);
exit_code(252, __PRETTY_FUNCTION__, "strict routing is not supported");
}
backup=str_alloc(strlen(cr)+1);
strncpy(backup, cr, strlen(cr));
@ -339,7 +339,7 @@ void cpy_rr(char* src, char *dst, int route) {
cr2 = strchr(rr, '\n');
if (cr2 == NULL) {
fprintf(stderr, "error: failed to find end of line\n");
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "missing newline in buffer");
}
strncpy(cr, rr + RR_STR_LEN, (cr2 - (rr + len) + 1));
cr+=(cr2 - (rr + RR_STR_LEN) + 1);
@ -596,7 +596,7 @@ void print_message_line(char *message)
crlf=strchr(message, '\n');
if (!crlf) {
printf("failed to find newline\n");
exit_code(254);
exit_code(254, __PRETTY_FUNCTION__, "missing newline in buffer");
}
else if (*(crlf - 1) == '\r')
crlf--;

@ -133,7 +133,7 @@ unsigned long getaddress(char *host) {
pent = gethostbyname(host);
if (!pent) {
printf("'%s' is unresolveable\n", host);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "hostname is not resolveable");
}
lp = (long *) (pent->h_addr);
l = *lp;
@ -151,7 +151,7 @@ static const unsigned char *parse_rr(const unsigned char *aptr, const unsigned c
status = ares_expand_name(aptr, abuf, alen, &name, &len);
if (status != ARES_SUCCESS) {
printf("error: failed to expand query name\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to expand query name");
}
aptr += len;
if (aptr + NS_RRFIXEDSZ > abuf + alen) {
@ -202,7 +202,7 @@ static const unsigned char *parse_rr(const unsigned char *aptr, const unsigned c
ca_tmpname = malloc(strlen(name));
if (ca_tmpname == NULL) {
printf("error: failed to allocate memory\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "memory allocation failure");
}
strcpy(ca_tmpname, name);
free(name);
@ -318,7 +318,7 @@ inline unsigned long srv_ares(char *host, int *port, char *srv) {
srvh = malloc(srvh_len);
if (srvh == NULL) {
printf("error: failed to allocate memory (%i) for ares query\n", srvh_len);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "memory allocation failure");
}
memset(srvh, 0, srvh_len);
strncpy(srvh, srv, strlen(srv));
@ -339,7 +339,7 @@ inline unsigned long srv_ares(char *host, int *port, char *srv) {
count = select(nfds, &read_fds, &write_fds, NULL, tvp);
if (count < 0 && errno != EINVAL) {
perror("ares select");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "ares DNS resolution failure");
}
ares_process(channel, &read_fds, &write_fds);
}
@ -368,7 +368,7 @@ inline unsigned long srv_ruli(char *host, int *port, char *srv) {
/* sync query failure? */
if (!sync_query) {
printf("DNS SRV lookup failed for: %s\n", host);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "DNS SRV lookup failed");
}
srv_code = ruli_sync_srv_code(sync_query);
@ -376,13 +376,13 @@ inline unsigned long srv_ruli(char *host, int *port, char *srv) {
if (srv_code == RULI_SRV_CODE_ALARM) {
printf("Timeout during DNS SRV lookup for: %s\n", host);
ruli_sync_delete(sync_query);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "timeout during DNS SRV lookup");
}
/* service provided? */
else if (srv_code == RULI_SRV_CODE_UNAVAILABLE) {
printf("SRV service not provided for: %s\n", host);
ruli_sync_delete(sync_query);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "missing service in DNS SRV reply");
}
else if (srv_code) {
int rcode = ruli_sync_rcode(sync_query);
@ -409,7 +409,7 @@ inline unsigned long srv_ruli(char *host, int *port, char *srv) {
if (addr_list_size < 1) {
printf("missing addresses in SRV lookup for: %s\n", host);
ruli_sync_delete(sync_query);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "missing address in DNS SRV reply");
}
*port = entry->port;
@ -452,7 +452,7 @@ unsigned long getsrvadr(char *host, int *port, unsigned int *transport) {
status = ares_init_options(&channel, &options, optmask);
if (status != ARES_SUCCESS) {
printf("error: failed to initialize ares\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to init ares lib");
}
#endif
@ -516,7 +516,7 @@ void get_fqdn() {
else {
if (gethostname(&hname[0], namelen) < 0) {
fprintf(stderr, "error: cannot determine hostname\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to determine hostname");
}
}
#ifdef HAVE_GETDOMAINNAME
@ -524,7 +524,7 @@ void get_fqdn() {
if ((strchr(hname, '.'))==NULL) {
if (getdomainname(&dname[0], namelen) < 0) {
fprintf(stderr, "error: cannot determine domainname\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to get domainname");
}
if (strcmp(&dname[0],"(none)")!=0)
snprintf(fqdn, FQDN_SIZE, "%s.%s", hname, dname);
@ -553,7 +553,7 @@ void get_fqdn() {
}
else {
fprintf(stderr, "error: cannot resolve local hostname: %s\n", hname);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to resolve local hostname");
}
}
if ((strchr(fqdn, '.'))==NULL) {
@ -563,7 +563,7 @@ void get_fqdn() {
}
else {
fprintf(stderr, "error: this FQDN or IP is not valid: %s\n", fqdn);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "invalid IP or FQDN");
}
}
@ -628,7 +628,7 @@ void replace_strings(char *mes, char *strings) {
repl = str_alloc(strlen(val) + 3);
if (repl == NULL) {
printf("failed to allocate memory\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "memory allocation failure");
}
sprintf(repl, "$%s$", atr);
replace_string(mes, repl, val);
@ -794,7 +794,7 @@ error:
if (mode == 0) {
/* libcheck expects a return value not an exit code */
#ifndef RUNNING_CHECK
exit_code(ret);
exit_code(ret, __PRETTY_FUNCTION__, NULL);
#endif
}
return (ret * - 1);
@ -833,7 +833,7 @@ void *str_alloc(size_t size) {
#endif
if (ptr == NULL) {
fprintf(stderr, "error: memory allocation failed\n");
exit_code(255);
exit_code(255, __PRETTY_FUNCTION__, "memory allocation failure");
}
#ifndef HAVE_CALLOC
memset(ptr, 0, size);

@ -35,7 +35,7 @@ void create_msg(int action, char *req_buff, char *repl_buff, char *username, int
if(cseq == 0) {
fprintf(stderr, "error: CSeq 0 is not allowed\n");
exit_code(253);
exit_code(253, __PRETTY_FUNCTION__, "invalid CSeq 0");
}
if (req_buff == NULL)
abort();
@ -306,7 +306,7 @@ void create_msg(int action, char *req_buff, char *repl_buff, char *username, int
break;
default:
fprintf(stderr, "error: unknown request type to create\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "unknown request type requested");
break;
}
if (headers) {

@ -75,9 +75,9 @@ inline static void on_success(char *rep)
{
if ((rep != NULL) && re && regexec(re, rep, 0, 0, 0) == REG_NOMATCH) {
fprintf(stderr, "error: RegExp failed\n");
exit_code(32);
exit_code(32, __PRETTY_FUNCTION__, "regular expression failed");
} else {
exit_code(0);
exit_code(0, __PRETTY_FUNCTION__, NULL);
}
}
@ -115,7 +115,7 @@ void handle_3xx(struct sockaddr_in *tadr)
if (contact==NULL) {
fprintf(stderr, "error: cannot find Contact in this "
"redirect:\n%s\n", rec);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "missing Contact header in reply");
}
/* correct our request */
uri_replace(req, contact);
@ -132,7 +132,7 @@ void handle_3xx(struct sockaddr_in *tadr)
fprintf(stderr, "error: cannot determine host "
"address from Contact of redirect:"
"\n%s\n", rec);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "missing host in Contact header");
}
if (!rport) {
rport = 5060;
@ -144,7 +144,7 @@ void handle_3xx(struct sockaddr_in *tadr)
else {
fprintf(stderr, "error: cannot handle this redirect:"
"\n%s\n", rec);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "unsupported redirect reply");
}
}
@ -208,7 +208,7 @@ void trace_reply()
if (regexec(&(regexps.okexp), rec, 0, 0, 0) == REG_NOERROR)
on_success(rec);
else
exit_code(1);
exit_code(1, __PRETTY_FUNCTION__, "received final non-2xx reply");
}
}
@ -281,7 +281,7 @@ void handle_default()
on_success(rec);
}
else {
exit_code(1);
exit_code(1, __PRETTY_FUNCTION__, "received final non-2xx reply");
}
}
}
@ -315,12 +315,12 @@ void handle_randtrash()
if (cseq_counter == nameend) {
if (counters.randretrys == 0) {
printf("random end reached. server survived :) respect!\n");
exit_code(0);
exit_code(0, __PRETTY_FUNCTION__, NULL);
}
else {
printf("maximum sendings reached but did not "
"get a response on this request:\n%s\n", req);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "missing reply on trashed request");
}
}
else {
@ -364,7 +364,7 @@ void handle_usrloc()
fprintf(stderr, "received:\n%s\nerror: didn't "
"received '200 OK' on register (see "
"above). aborting\n", rec);
exit_code(1);
exit_code(1, __PRETTY_FUNCTION__, "received non-2xx reply for REGISTER");
}
if (invite == 0 && message == 0) {
if (namebeg==nameend) {
@ -390,7 +390,7 @@ void handle_usrloc()
" retransmitted.\n",
counters.retrans_s_c, delays.retryAfter);
if (counters.retrans_s_c > nagios_warn) {
exit_code(4);
exit_code(4, __PRETTY_FUNCTION__, "#retransmissions above nagios warn level");
}
}
if (timing) {
@ -449,7 +449,7 @@ void handle_usrloc()
fprintf(stderr, "received:\n%s\nerror: did not "
"received the INVITE that was sent "
"(see above). aborting\n", rec);
exit_code(1);
exit_code(1, __PRETTY_FUNCTION__, "did not received our own INVITE request");
}
break;
case INV_OK_RECV:
@ -478,7 +478,7 @@ void handle_usrloc()
"received the '200 OK' that was sent "
"as the reply on the INVITE (see "
"above). aborting\n", rec);
exit_code(1);
exit_code(1, __PRETTY_FUNCTION__, "did not received our own 200 reply");
}
break;
case INV_ACK_RECV:
@ -528,7 +528,7 @@ void handle_usrloc()
" retransmitted.\n",
counters.retrans_s_c, delays.retryAfter);
if (counters.retrans_s_c > nagios_warn) {
exit_code(4);
exit_code(4, __PRETTY_FUNCTION__, "#retransmissions above nagios warn level");
}
}
on_success(rec);
@ -566,7 +566,7 @@ void handle_usrloc()
"received the 'ACK' that was sent "
"as the reply on the '200 OK' (see "
"above). aborting\n", rec);
exit_code(1);
exit_code(1, __PRETTY_FUNCTION__, "missing ACK that was send by myself");
}
break;
case MES_RECV:
@ -590,7 +590,7 @@ void handle_usrloc()
fprintf(stderr, "received:\n%s\nerror: did not "
"received the 'MESSAGE' that was sent "
"(see above). aborting\n", rec);
exit_code(1);
exit_code(1, __PRETTY_FUNCTION__, "did not received my own MESSAGE request");
}
break;
case MES_OK_RECV:
@ -638,7 +638,7 @@ void handle_usrloc()
" retransmitted.\n",
counters.retrans_s_c, delays.retryAfter);
if (counters.retrans_s_c > nagios_warn) {
exit_code(4);
exit_code(4, __PRETTY_FUNCTION__, "#retransmissions above nagios warn level");
}
}
on_success(rec);
@ -686,7 +686,7 @@ void handle_usrloc()
"aborting\n", rec);
}
}
exit_code(1);
exit_code(1, __PRETTY_FUNCTION__, "received non-2xx reply for MESSAGE request");
}
break;
case UNREG_REP:
@ -721,12 +721,12 @@ void handle_usrloc()
"remove bindings request for %s%i (see"
" above). aborting\n", rec, username,
namebeg);
exit_code(1);
exit_code(1, __PRETTY_FUNCTION__, "received non-2xx reply for de-register request");
}
break;
default:
fprintf(stderr, "error: unknown step in usrloc\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "unknown step in usrloc");
break;
} /* switch */
} /* regexec proexp */
@ -1005,7 +1005,7 @@ void shoot(char *buf, int buff_size)
counters.run++;
}
printf("%.3f/%.3f/%.3f ms\n", delays.small_delay, delays.all_delay / counters.run, delays.big_delay);
exit_code(0);
exit_code(0, __PRETTY_FUNCTION__, NULL);
}
counters.run++;
new_transaction(req);
@ -1014,7 +1014,7 @@ void shoot(char *buf, int buff_size)
}
fprintf(stderr, "%s\nerror: received 40[17] but cannot "
"authentication without a username or auth username\n", rec);
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "missing username for authentication");
}
/* prevents a strange error */
regcomp(&(regexps.authexp), "^SIP/[0-9]\\.[0-9] 40[17] ", REG_EXTENDED|REG_NOSUB|REG_ICASE);
@ -1057,7 +1057,7 @@ void shoot(char *buf, int buff_size)
printf("failed\n");
}
perror("socket error");
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "internal socket error");
}
} /* !flood */
else {
@ -1070,7 +1070,7 @@ void shoot(char *buf, int buff_size)
deltaT(&(timers.firstsendt), &(timers.sendtime)), namebeg);
printf("we sent %f requests per second.\n",
(namebeg/(deltaT(&(timers.firstsendt), &(timers.sendtime)))*1000));
exit_code(0);
exit_code(0, __PRETTY_FUNCTION__, NULL);
}
namebeg++;
cseq_counter++;
@ -1080,7 +1080,7 @@ void shoot(char *buf, int buff_size)
/* this should never happen any more... */
if (randtrash == 1) {
exit_code(0);
exit_code(0, __PRETTY_FUNCTION__, NULL);
}
printf("** give up retransmissioning....\n");
if (counters.retrans_r_c>0 && (verbose > 1)) {
@ -1089,5 +1089,5 @@ void shoot(char *buf, int buff_size)
if (counters.retrans_s_c>0 && (verbose > 1)) {
printf("sent %i retransmissions during test\n", counters.retrans_s_c);
}
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "got outside of endless messaging loop");
}

@ -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){

@ -326,7 +326,7 @@ int verbose, nameend, namebeg, expires_t, flood, warning_ext, invite, message;
int maxforw, lport, rport, randtrash, trashchar, numeric, symmetric;
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;
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 fqdn[FQDN_SIZE];

@ -488,7 +488,7 @@ void create_tls_ctx() {
if (ctx == NULL) {
ERR_print_errors_fp(stderr);
perror("create_tls_ctx: failed to create TLS ctx");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to create TLS ctx");
}
/*if (!SSL_CTX_use_certificate_chain_file(ctx, cert_file)) {
perror("create_tls_ctx: failed to load certificate file");
@ -540,11 +540,11 @@ void create_sockets(struct sipsak_con_data *cd) {
cd->usock = (int)socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (cd->usock==-1) {
perror("unconnected UDP socket creation failed");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to create unconnected UDP socket");
}
if (bind(cd->usock, (struct sockaddr *) &(cd->adr), sizeof(struct sockaddr_in) )==-1) {
perror("unconnected UDP socket binding failed");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to bind unconnected UDP socket");
}
}
@ -561,14 +561,14 @@ void create_sockets(struct sipsak_con_data *cd) {
cd->csock = (int)socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (cd->csock==-1) {
perror("connected UDP socket creation failed");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to create connected UDP socket");
}
if (!symmetric)
cd->adr.sin_port = htons((short)0);
if (bind(cd->csock, (struct sockaddr *) &(cd->adr), sizeof(struct sockaddr_in) )==-1) {
perror("connected UDP socket binding failed");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to bind connected UDP socket");
}
#ifdef RAW_SUPPORT
}
@ -576,11 +576,11 @@ void create_sockets(struct sipsak_con_data *cd) {
cd->csock = (int)socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (cd->csock==-1) {
perror("connected UDP socket creation failed");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to create connected UDP socket");
}
if (bind(cd->csock, (struct sockaddr *) &(cd->adr), sizeof(struct sockaddr_in) )==-1) {
perror("connected UDP socket binding failed");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to bind connected UDP socket");
}
}
#endif
@ -589,11 +589,11 @@ void create_sockets(struct sipsak_con_data *cd) {
cd->csock = (int)socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (cd->csock==-1) {
perror("TCP socket creation failed");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to create TCP socket");
}
if (bind(cd->csock, (struct sockaddr *) &(cd->adr), sizeof(struct sockaddr_in) )==-1) {
perror("TCP socket binding failed");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to bind TCP socket");
}
#ifdef WITH_TLS_TRANSP
if (transport == SIP_TLS_TRANSPORT) {
@ -615,11 +615,11 @@ void create_sockets(struct sipsak_con_data *cd) {
ssl = SSL_new(ctx);
if (ssl == NULL) {
perror("TLS failed to create SSL object");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to create SSL object");
}
if (SSL_set_fd(ssl, cd->csock) != 1) {
perror("TLS failed to add socket to SSL object");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to add socket to SSL object");
}
# endif /* USE_OPENSSL */
#endif /* USE_GNUTLS */
@ -696,7 +696,7 @@ void send_message(char* mes, struct sipsak_con_data *cd,
if (verbose)
printf("\n");
perror("send failure");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "send failure");
}
#ifdef HAVE_INET_NTOP
if (verbose > 2) {
@ -726,7 +726,7 @@ void check_socket_error(int socket, int size) {
perror("send failure");
if (randtrash == 1)
printf ("last message before send failure:\n%s\n", req);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "send failure");
}
}
}
@ -795,7 +795,7 @@ int check_for_message(char *recv, int size, struct sipsak_con_data *cd,
printf("sended the following message three "
"times without getting a response:\n%s\n"
"give up further retransmissions...\n", req);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "too many retransmissions, giving up...");
}
else {
printf("resending it without additional "
@ -809,7 +809,7 @@ int check_for_message(char *recv, int size, struct sipsak_con_data *cd,
if (timing == 0) {
if (verbose>0)
printf("*** giving up, no final response after %.3f ms\n", senddiff);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "timeout (no final response)");
}
else {
timing--;
@ -820,7 +820,7 @@ int check_for_message(char *recv, int size, struct sipsak_con_data *cd,
sd->retryAfter = timer_t1;
if (timing == 0) {
printf("%.3f/%.3f/%.3f ms\n", sd->small_delay, sd->all_delay / count->run, sd->big_delay);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "timeout (no final response)");
}
}
}
@ -841,7 +841,7 @@ int check_for_message(char *recv, int size, struct sipsak_con_data *cd,
}
else if ( ret == -1 ) {
perror("select error");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "internal select error");
}
else if (((cd->usock != -1) && FD_ISSET(cd->usock, &fd)) || ((cd->csock != -1) && FD_ISSET(cd->csock, &fd))) {
if ((cd->usock != -1) && FD_ISSET(cd->usock, &fd))
@ -850,7 +850,7 @@ int check_for_message(char *recv, int size, struct sipsak_con_data *cd,
ret = cd->csock;
else {
printf("unable to determine the socket which received something\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to determine receiving socket");
}
/* no timeout, no error ... something has happened :-) */
if (trace == 0 && usrloc ==0 && invite == 0 && message == 0 && randtrash == 0 && (verbose > 1))
@ -967,7 +967,7 @@ int recv_message(char *buf, int size, int inv_trans,
ret = recvfrom(rawsock, buf, size, 0, (struct sockaddr *)&faddr, &flen);
if (ret == -1) {
perror("error while trying to read from icmp raw socket");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "failed to read from ICMP RAW socket");
}
r_ip_hdr = (struct ip *) buf;
r_ip_len = r_ip_hdr->ip_hl << 2;
@ -1002,7 +1002,7 @@ int recv_message(char *buf, int size, int inv_trans,
#else
printf("\n");
#endif // HAVE_INET_NTOP
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "received ICMP error");
}
else {
if (verbose > 2)
@ -1076,7 +1076,7 @@ int recv_message(char *buf, int size, int inv_trans,
else {
check_socket_error(sock, size);
printf("\nnothing received, select returned error\n");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "nothing received, select returned error");
}
return ret;
}
@ -1110,7 +1110,7 @@ int set_target(struct sockaddr_in *adr, unsigned long target, int port, int sock
if (socket != -1) {
if (connect(socket, (struct sockaddr *)adr, sizeof(struct sockaddr_in)) == -1) {
perror("connecting socket failed");
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "connection socket failed");
}
#ifdef WITH_TLS_TRANSP
if (transport == SIP_TLS_TRANSPORT) {
@ -1119,7 +1119,7 @@ int set_target(struct sockaddr_in *adr, unsigned long target, int port, int sock
if (ret < 0) {
dbg("TLS Handshake FAILED!!!\n");
gnutls_perror(ret);
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "TLS handshake failed");
}
else if (verbose > 2) {
dbg(" TLS Handshake was completed!\n");
@ -1142,13 +1142,13 @@ int set_target(struct sockaddr_in *adr, unsigned long target, int port, int sock
tls_dump_cert_info("TLS connect: server certificate", cert);
if (SSL_get_verify_result(ssl) != X509_V_OK) {
perror("TLS connect: server certifcate verification failed!!!\n");
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "TLS server certificate verification falied");
}
X509_free(cert);
}
else {
perror("TLS connect: server did not present a certificate\n");
exit_code(3);
exit_code(3, __PRETTY_FUNCTION__, "missing TLS server certificate");
}
}
else {
@ -1188,7 +1188,7 @@ int set_target(struct sockaddr_in *adr, unsigned long target, int port, int sock
default:
printf("TLS error: %d\n", err);
}
exit_code(2);
exit_code(2, __PRETTY_FUNCTION__, "generic SSL error");
}
# endif /* USE_OPENSSL */
# endif /* USE_GNUTLS */

Loading…
Cancel
Save