diff --git a/src/accessctl.c b/src/accessctl.c index 3ad4b4a..584f6aa 100644 --- a/src/accessctl.c +++ b/src/accessctl.c @@ -102,7 +102,7 @@ int accesslist_check (struct sockaddr_in from) { /* - * checks for a match of the 'from' address with the supplies + * checks for a match of the 'from' address with the supplied * access list. * * RETURNS diff --git a/src/auth.c b/src/auth.c index d21c68c..ec5703d 100644 --- a/src/auth.c +++ b/src/auth.c @@ -80,7 +80,7 @@ int authenticate_proxy(sip_t *request) { } /* authentication failed */ - DEBUGC(DBCLASS_AUTH,"proxy-auth failed"); + WARN("authenticate_proxy failed"); return STS_FAILURE; } diff --git a/src/proxy.c b/src/proxy.c index 0168f67..8621ae8 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -185,23 +185,24 @@ int proxy_request (sip_t *request) { /* add my Via header line (outbound interface)*/ sts = proxy_add_myvia(request, 0); if (sts == STS_FAILURE) { - WARN("adding my outbound via failed!"); + ERROR("adding my outbound via failed!"); } /* if this is CANCEL/BYE request, stop RTP proxying */ if (MSG_IS_BYE(request) || MSG_IS_CANCEL(request)) { - /* stop the RTP proxying stream */ rtp_stop_fwd(msg_getcall_id(request)); } break; default: - DEBUGC(DBCLASS_PROXY,"request: refuse to proxy - UA not registered?"); + DEBUGC(DBCLASS_PROXY,"proxy_request: refused to proxy"); WARN("request from/to unregistered UA (%s@%s)", request->from->url->username, request->from->url->host); -/* some clients seem to run amok when passing back a negative response */ +/* some clients seem to run amok when passing back a negative response + * so we simply drop the request silently + */ // proxy_gen_response(request, 403 /*forbidden*/); return STS_FAILURE; } @@ -377,7 +378,10 @@ int proxy_response (sip_t *response) { break; default: - DEBUGC(DBCLASS_PROXY,"response: refuse to proxy - UA not registered?"); + DEBUGC(DBCLASS_PROXY,"proxy_response: refused to proxy"); + WARN("response from/to unregistered UA (%s@%s)", + request->from->url->username, + request->from->url->host); /* some clients seem to run amok when passing back a negative response */ // proxy_gen_response(request, 403 /*forbidden*/); return STS_FAILURE; @@ -488,14 +492,16 @@ int proxy_add_myvia (sip_t *request, int interface) { sts = get_ip_by_host(configuration.inboundhost, &addr); } - sprintf (tmp, "SIP/2.0/UDP %s:%i", inet_ntoa(addr), - configuration.sip_listen_port); + sprintf(tmp, "SIP/2.0/UDP %s:%i", inet_ntoa(addr), + configuration.sip_listen_port); DEBUGC(DBCLASS_BABBLE,"adding VIA:%s",tmp); sts = via_init(&via); if (sts!=0) return STS_FAILURE; /* allocation failed */ + sts = via_parse(via, tmp); if (sts!=0) return STS_FAILURE; + list_add(request->vias,via,0); return STS_SUCCESS; @@ -694,9 +700,6 @@ int proxy_rewrite_invitation_body(sip_t *mymsg){ memcpy (ptr, data2_c, strlen(data2_c)); } - - - } /* remove old body */ diff --git a/src/register.c b/src/register.c index ad94701..ba3ee00 100644 --- a/src/register.c +++ b/src/register.c @@ -143,7 +143,7 @@ int register_client(sip_t *my_msg) { } if (i >= URLMAP_SIZE) { - /* entry no existing, create new one */ + /* entry not existing, create new one */ i=j; DEBUGC(DBCLASS_REG,"create new entry for %s@%s at slot=%i", url1_contact->username, url1_contact->host, i); diff --git a/src/sock.c b/src/sock.c index 3ac0350..7c23101 100644 --- a/src/sock.c +++ b/src/sock.c @@ -138,7 +138,7 @@ int sipsock_send_udp(int *sock, struct in_addr addr, int port, DUMP_BUFFER(DBCLASS_NETTRAF, buffer, size); } - sts = sendto (*sock, buffer, size, 0, &dst_addr, sizeof(dst_addr)); + sts = sendto(*sock, buffer, size, 0, &dst_addr, sizeof(dst_addr)); if (sts == -1) { if (errno != ECONNREFUSED) { diff --git a/src/utils.c b/src/utils.c index cbc3eab..d0a2803 100644 --- a/src/utils.c +++ b/src/utils.c @@ -63,6 +63,14 @@ sip_t *msg_make_template_reply (sip_t * request, int code) { msg_setstatuscode (response, tmp); msg_setreasonphrase (response, msg_getreason (code)); + if (request->to==NULL) { + ERROR("msg_make_template_reply: empty To in request header"); + } + + if (request->from==NULL) { + ERROR("msg_make_template_reply: empty From in request header"); + } + to_clone (request->to, &response->to); from_clone (request->from, &response->from); @@ -102,7 +110,7 @@ int check_vialoop (sip_t *my_msg) { found_own_via=0; pos = 1; /* for detecting a loop, don't check the first entry - as this is my VIA! */ + as this is my own VIA! */ while (!list_eol (my_msg->vias, pos)) { via_t *via; via = (via_t *) list_get (my_msg->vias, pos); @@ -179,7 +187,15 @@ int get_ip_by_host(char *hostname, struct in_addr *addr) { } dns_cache[DNS_CACHE_SIZE]; static int cache_initialized=0; - if (hostname == NULL) return STS_FAILURE; + if (hostname == NULL) { + ERROR("get_ip_by_host: NULL hostname requested"); + return STS_FAILURE; + } + + if (addr == NULL) { + ERROR("get_ip_by_host: NULL in_addr passed"); + return STS_FAILURE; + } /* first time: initialize DNS cache */ if (cache_initialized == 0) { @@ -260,7 +276,20 @@ int get_ip_by_host(char *hostname, struct in_addr *addr) { int compare_url(url_t *url1, url_t *url2) { int sts; - if ((url1 == NULL) || (url2 == NULL)) return STS_FAILURE; + if ((url1 == NULL) || (url2 == NULL)) { + ERROR("compare_url: NULL ptr: url1=0x%p, url2=0x%p",url1, url2); + return STS_FAILURE; + } + if ((url1->username == NULL) || (url2->username == NULL)) { + ERROR("compare_url: NULL ptr: url1->username=0x%p, url2->username=0x%p", + url1->username, url2->username); + return STS_FAILURE; + } + if ((url1->host == NULL) || (url2->host == NULL)) { + ERROR("compare_url: NULL ptr: url1->host=0x%p, url2->host=0x%p", + url1->host, url2->host); + return STS_FAILURE; + } /* comparison of hosts should be based on IP addresses, no? */ DEBUGC(DBCLASS_BABBLE, "comparing urls: %s@%s -> %s@%s",