- fix: various correction in Record-Route processing
This commit is contained in:
parent
dd3c548fa0
commit
1ede069877
@ -1,10 +1,12 @@
|
|||||||
0.5.9
|
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,
|
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)
|
(possible crash when trying to free is)
|
||||||
- up to 1000 characters per line in config file (was 120),
|
- up to 1000 characters per line in config file (was 120),
|
||||||
some typos corrected (by Tero Pelander)
|
some typos corrected (by Tero Pelander)
|
||||||
|
- fix: various correction in Record-Route processing
|
||||||
13-Oct-2004: - utils.c: preparation for chroot() (consider syslog)
|
13-Oct-2004: - utils.c: preparation for chroot() (consider syslog)
|
||||||
09-Oct-2004: - comp_osip.c: libosip2-2.0.9 compatibility (There SEEM
|
09-Oct-2004: - comp_osip.c: libosip2-2.0.9 compatibility (There SEEM
|
||||||
to happen some API changes forward and backward:
|
to happen some API changes forward and backward:
|
||||||
|
|||||||
@ -110,6 +110,14 @@ rtp_port_high = 7079
|
|||||||
#
|
#
|
||||||
rtp_timeout = 300
|
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
|
# Proxy authentication
|
||||||
# If proxy_auth_realm is defined (a string), clients will be forced
|
# If proxy_auth_realm is defined (a string), clients will be forced
|
||||||
|
|||||||
34
src/proxy.c
34
src/proxy.c
@ -394,30 +394,23 @@ int proxy_request (sip_ticket_t *ticket) {
|
|||||||
* RFC 3261, Section 16.6 step 4
|
* RFC 3261, Section 16.6 step 4
|
||||||
* Proxy Behavior - Request Forwarding - Add a Record-route header
|
* 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,
|
* for ALL incoming requests, include my Record-Route header.
|
||||||
* include my own as well. The local UA will probably send its answer
|
* The local UA will probably send its answer to the topmost
|
||||||
* to the topmost Route Header (8.1.2 of RFC3261)
|
* Route Header (8.1.2 of RFC3261)
|
||||||
*/
|
*/
|
||||||
if ((request->record_routes) &&
|
|
||||||
(!osip_list_eol(request->record_routes, 0))) {
|
|
||||||
if (type == REQTYP_INCOMING) {
|
if (type == REQTYP_INCOMING) {
|
||||||
DEBUGC(DBCLASS_PROXY,"Adding my Record-Route");
|
DEBUGC(DBCLASS_PROXY,"Adding my Record-Route");
|
||||||
route_add_recordroute(ticket);
|
route_add_recordroute(ticket);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* outgoing packets must not have a record route header, as
|
* outgoing packets must not have my record route header, as
|
||||||
* these likely will contain private IP addresses.
|
* this likely will contain a private IP address (my inbound).
|
||||||
*/
|
*/
|
||||||
DEBUGC(DBCLASS_PROXY,"Purging Record-Routes (outgoing packet)");
|
DEBUGC(DBCLASS_PROXY,"Purging Record-Routes (outgoing packet)");
|
||||||
route_purge_recordroute(ticket);
|
route_purge_recordroute(ticket);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RFC 3261, Section 16.6 step 5
|
* RFC 3261, Section 16.6 step 5
|
||||||
@ -679,7 +672,7 @@ int proxy_response (sip_ticket_t *ticket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* &&&& Open Issue &&&&
|
/* &&&& 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)
|
(e.g 1393xxx@proxy01.sipphone.com for calls made sipphone -> FWD)
|
||||||
How can we deal with this? Should I take into consideration the 'Via'
|
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.
|
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,
|
* for ALL incoming response include my Record-Route header.
|
||||||
* include my own as well. The local UA will probably send its answer
|
* The local UA will probably send its answer to the topmost
|
||||||
* to the topmost Route Header (8.1.2 of RFC3261)
|
* Route Header (8.1.2 of RFC3261)
|
||||||
*/
|
*/
|
||||||
if ((response->record_routes) &&
|
|
||||||
(!osip_list_eol(response->record_routes, 0))) {
|
|
||||||
if (type == RESTYP_INCOMING) {
|
if (type == RESTYP_INCOMING) {
|
||||||
DEBUGC(DBCLASS_PROXY,"Adding my Record-Route");
|
DEBUGC(DBCLASS_PROXY,"Adding my Record-Route");
|
||||||
route_add_recordroute(ticket);
|
route_add_recordroute(ticket);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* outgoing packets must not have a record route header, as
|
* outgoing packets must not have my record route header, as
|
||||||
* these likely will contain private IP addresses.
|
* this likely will contain a private IP address (my inbound).
|
||||||
*/
|
*/
|
||||||
DEBUGC(DBCLASS_PROXY,"Purging Record-Routes (outgoing packet)");
|
DEBUGC(DBCLASS_PROXY,"Purging Record-Routes (outgoing packet)");
|
||||||
route_purge_recordroute(ticket);
|
route_purge_recordroute(ticket);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* check if we need to send to an outbound proxy
|
* check if we need to send to an outbound proxy
|
||||||
|
|||||||
@ -85,6 +85,15 @@ int route_preprocess(sip_ticket_t *ticket){
|
|||||||
* the last Route entry if it belongs to me...
|
* the last Route entry if it belongs to me...
|
||||||
*
|
*
|
||||||
* Any proper explanation to this is heavily welcome
|
* 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) {
|
for (j=0,i=last; j<2; j++, i=0) {
|
||||||
DEBUGC(DBCLASS_PROXY, "route_preprocess: checking Route "
|
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){
|
int route_add_recordroute(sip_ticket_t *ticket){
|
||||||
osip_message_t *mymsg=ticket->sipmsg;
|
osip_message_t *mymsg=ticket->sipmsg;
|
||||||
int sts;
|
int sts;
|
||||||
|
int position;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
osip_record_route_t *r_route;
|
osip_record_route_t *r_route;
|
||||||
osip_uri_t *uri_of_proxy;
|
osip_uri_t *uri_of_proxy;
|
||||||
@ -255,8 +265,17 @@ int route_add_recordroute(sip_ticket_t *ticket){
|
|||||||
|
|
||||||
osip_record_route_set_url(r_route, uri_of_proxy);
|
osip_record_route_set_url(r_route, uri_of_proxy);
|
||||||
|
|
||||||
/* insert before all other record-route */
|
position=0;
|
||||||
osip_list_add (mymsg->record_routes, r_route, 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 {
|
} else {
|
||||||
osip_record_route_free(r_route);
|
osip_record_route_free(r_route);
|
||||||
} /* if url_init */
|
} /* if url_init */
|
||||||
@ -278,14 +297,53 @@ int route_add_recordroute(sip_ticket_t *ticket){
|
|||||||
int route_purge_recordroute(sip_ticket_t *ticket){
|
int route_purge_recordroute(sip_ticket_t *ticket){
|
||||||
osip_message_t *mymsg=ticket->sipmsg;
|
osip_message_t *mymsg=ticket->sipmsg;
|
||||||
osip_record_route_t *r_route=NULL;
|
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)) {
|
if (mymsg->record_routes) {
|
||||||
while (!osip_list_eol(mymsg->record_routes, 0)) {
|
last=osip_list_size(mymsg->record_routes)-1;
|
||||||
r_route = (osip_record_route_t *) osip_list_get(mymsg->record_routes, 0);
|
/* I *MUST NOT* purge any alien (non-mine) Record-Route headers,
|
||||||
osip_list_remove(mymsg->record_routes, 0);
|
* only the ones I've put in myself! */
|
||||||
osip_record_route_free(r_route);
|
if (last >= 0) {
|
||||||
/* mymsg->record_routes will be freed by osip_message_free() */
|
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;
|
return STS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user