cosmetics and some better error handling w/ strings and data structures

(NULL ptrs)
This commit is contained in:
Thomas Ries 2002-11-08 20:48:16 +00:00
parent c45aa20f68
commit 6bb397118a
6 changed files with 49 additions and 17 deletions

View File

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

View File

@ -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;
}

View File

@ -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;
@ -494,8 +498,10 @@ int proxy_add_myvia (sip_t *request, int interface) {
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 */

View File

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

View File

@ -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",