- fix: various correction in Record-Route processing

This commit is contained in:
Thomas Ries 2004-10-24 08:38:51 +00:00
parent dd3c548fa0
commit 1ede069877
4 changed files with 108 additions and 50 deletions

View File

@ -1,10 +1,12 @@
0.5.9
=====
24-Oct-2004: - Default Expires timeout is now configurable.
23-Oct-2004: - fix: route_processing.c - when adding my record-route header,
the 'lr' parameter was not dynamically allocated
the 'lr' parameter was not dynamically allocated memory
(possible crash when trying to free is)
- up to 1000 characters per line in config file (was 120),
some typos corrected (by Tero Pelander)
- fix: various correction in Record-Route processing
13-Oct-2004: - utils.c: preparation for chroot() (consider syslog)
09-Oct-2004: - comp_osip.c: libosip2-2.0.9 compatibility (There SEEM
to happen some API changes forward and backward:

View File

@ -110,6 +110,14 @@ rtp_port_high = 7079
#
rtp_timeout = 300
######################################################################
# Default Expiration timeout for Registrations
# If a REGISTER request does not contain an Expires header
# or expires= parameter in the Contact header, this number of
# seconds will be used - and reported back to the UA in the answer.
#
default_expires = 600
######################################################################
# Proxy authentication
# If proxy_auth_realm is defined (a string), clients will be forced

View File

@ -394,29 +394,22 @@ int proxy_request (sip_ticket_t *ticket) {
* RFC 3261, Section 16.6 step 4
* Proxy Behavior - Request Forwarding - Add a Record-route header
*/
#if 0
/* NOT IMPLEMENTED - this requires proper implementation of
the Route headers first. */
route_add_recordroute(ticket);
#endif
/*
* for incoming requests that DO include a Record-Route header,
* include my own as well. The local UA will probably send its answer
* to the topmost Route Header (8.1.2 of RFC3261)
* for ALL incoming requests, include my Record-Route header.
* The local UA will probably send its answer to the topmost
* Route Header (8.1.2 of RFC3261)
*/
if ((request->record_routes) &&
(!osip_list_eol(request->record_routes, 0))) {
if (type == REQTYP_INCOMING) {
DEBUGC(DBCLASS_PROXY,"Adding my Record-Route");
route_add_recordroute(ticket);
} else {
/*
* outgoing packets must not have a record route header, as
* these likely will contain private IP addresses.
*/
DEBUGC(DBCLASS_PROXY,"Purging Record-Routes (outgoing packet)");
route_purge_recordroute(ticket);
}
if (type == REQTYP_INCOMING) {
DEBUGC(DBCLASS_PROXY,"Adding my Record-Route");
route_add_recordroute(ticket);
} else {
/*
* outgoing packets must not have my record route header, as
* this likely will contain a private IP address (my inbound).
*/
DEBUGC(DBCLASS_PROXY,"Purging Record-Routes (outgoing packet)");
route_purge_recordroute(ticket);
}
/*
@ -679,7 +672,7 @@ int proxy_response (sip_ticket_t *ticket) {
}
}
/* &&&& Open Issue &&&&
it has been seen with corss-provider calls that the FROM may be 'garbled'
it has been seen with cross-provider calls that the FROM may be 'garbled'
(e.g 1393xxx@proxy01.sipphone.com for calls made sipphone -> FWD)
How can we deal with this? Should I take into consideration the 'Via'
headers? This is the only clue I have, pointing to the *real* UA.
@ -837,24 +830,21 @@ int proxy_response (sip_ticket_t *ticket) {
}
/*
* for incoming requests that DO include a Record-Route header,
* include my own as well. The local UA will probably send its answer
* to the topmost Route Header (8.1.2 of RFC3261)
* for ALL incoming response include my Record-Route header.
* The local UA will probably send its answer to the topmost
* Route Header (8.1.2 of RFC3261)
*/
if ((response->record_routes) &&
(!osip_list_eol(response->record_routes, 0))) {
if (type == RESTYP_INCOMING) {
DEBUGC(DBCLASS_PROXY,"Adding my Record-Route");
route_add_recordroute(ticket);
} else {
/*
* outgoing packets must not have a record route header, as
* these likely will contain private IP addresses.
*/
DEBUGC(DBCLASS_PROXY,"Purging Record-Routes (outgoing packet)");
route_purge_recordroute(ticket);
}
}
if (type == RESTYP_INCOMING) {
DEBUGC(DBCLASS_PROXY,"Adding my Record-Route");
route_add_recordroute(ticket);
} else {
/*
* outgoing packets must not have my record route header, as
* this likely will contain a private IP address (my inbound).
*/
DEBUGC(DBCLASS_PROXY,"Purging Record-Routes (outgoing packet)");
route_purge_recordroute(ticket);
}
/*
* check if we need to send to an outbound proxy

View File

@ -85,6 +85,15 @@ int route_preprocess(sip_ticket_t *ticket){
* the last Route entry if it belongs to me...
*
* Any proper explanation to this is heavily welcome
*
* &&&&
* 23Oct2004/xar
* Of course this was a stupid error of siproxd himself
* when adding Record-Route headers...
* - Request: add Record-Route header as top element of list
* - Response: add Record-Route header as last element of list
* So this code should be cleaned up - and only examine the first
* entry in the Record-set.
*/
for (j=0,i=last; j<2; j++, i=0) {
DEBUGC(DBCLASS_PROXY, "route_preprocess: checking Route "
@ -201,6 +210,7 @@ We should use the first Route header to send the packet to
int route_add_recordroute(sip_ticket_t *ticket){
osip_message_t *mymsg=ticket->sipmsg;
int sts;
int position;
struct in_addr addr;
osip_record_route_t *r_route;
osip_uri_t *uri_of_proxy;
@ -251,12 +261,21 @@ int route_add_recordroute(sip_ticket_t *ticket){
osip_uri_set_port(uri_of_proxy, osip_strdup(tmp));
/* 'lr' parameter */
osip_uri_uparam_add(uri_of_proxy, osip_strdup("lr"), NULL);
osip_uri_uparam_add(uri_of_proxy, osip_strdup("lr"),NULL);
osip_record_route_set_url(r_route, uri_of_proxy);
/* insert before all other record-route */
osip_list_add (mymsg->record_routes, r_route, 0);
position=0;
/* if it is a response, add in to the end of the list
* (reverse order as in request!) */
if ((ticket->direction==RESTYP_INCOMING) ||
(ticket->direction==RESTYP_OUTGOING)) {
position = -1;
}
/* insert into record-route list*/
osip_list_add (mymsg->record_routes, r_route, position);
} else {
osip_record_route_free(r_route);
} /* if url_init */
@ -278,14 +297,53 @@ int route_add_recordroute(sip_ticket_t *ticket){
int route_purge_recordroute(sip_ticket_t *ticket){
osip_message_t *mymsg=ticket->sipmsg;
osip_record_route_t *r_route=NULL;
int last, i, sts;
struct in_addr addr1, addr2, addr3;
if (mymsg->record_routes && !osip_list_eol(mymsg->record_routes, 0)) {
while (!osip_list_eol(mymsg->record_routes, 0)) {
r_route = (osip_record_route_t *) osip_list_get(mymsg->record_routes, 0);
osip_list_remove(mymsg->record_routes, 0);
osip_record_route_free(r_route);
/* mymsg->record_routes will be freed by osip_message_free() */
}
if (mymsg->record_routes) {
last=osip_list_size(mymsg->record_routes)-1;
/* I *MUST NOT* purge any alien (non-mine) Record-Route headers,
* only the ones I've put in myself! */
if (last >= 0) {
for (i=last; i>=0; i--) {
r_route = (osip_record_route_t *)
osip_list_get(mymsg->record_routes, i);
/* skip empty entries */
if (r_route == NULL) continue;
if (r_route->url == NULL) continue;
if (r_route->url->host == NULL) continue;
/* resolve IP addresses (of RR header, inbound & outbound IF) */
sts = get_ip_by_host(r_route->url->host, &addr1);
if (get_ip_by_ifname(configuration.inbound_if, &addr2)
!= STS_SUCCESS) {
ERROR("can't find inbound interface %s - configuration error?",
configuration.inbound_if);
return STS_FAILURE;
}
if (get_ip_by_ifname(configuration.outbound_if, &addr3)
!= STS_SUCCESS) {
ERROR("can't find outbound interface %s - configuration error?",
configuration.outbound_if);
return STS_FAILURE;
}
/* check if my own route header? */
if ((sts == STS_SUCCESS) &&
((memcmp(&addr1, &addr2, sizeof(addr1)) == 0) ||
(memcmp(&addr1, &addr3, sizeof(addr1)) == 0)) &&
(r_route->url->port ?
configuration.sip_listen_port == atoi(r_route->url->port):
configuration.sip_listen_port == SIP_PORT)) {
osip_list_remove(mymsg->record_routes, i);
osip_record_route_free(r_route);
DEBUGC(DBCLASS_PROXY, "removed Record-Route header pointing "
"to myself");
}
} // for
} // if
}
return STS_SUCCESS;
}