diff --git a/ChangeLog b/ChangeLog index 0ae9c42..52d5064 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,12 @@ 0.5.12 ====== - 14-Jul-2005: - allocate only even port numbers for RTP traffic + 9-Oct-2005: - Expiration timeout is now taken from the REGISTER response 1-Oct-2005: - [1278537] Read proxy_auth_pwfile after config file is read - [1278591] Proxy-Authenticate header not included in response - process empty Contact header (means "query registrations") (only supported for registrations at a remote server) - handle multiple Contact headers (e.g. in REGISTER response) + 14-Jul-2005: - allocate only even port numbers for RTP traffic 0.5.11 ====== diff --git a/src/proxy.c b/src/proxy.c index 5ce1e71..0e6844b 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -786,7 +786,10 @@ int proxy_response (sip_ticket_t *ticket) { * REGISTER returns *my* Contact header information. * Rewrite Contact header back to represent the true address. * Other responses do return the Contact header of the sender. + * also change the expiration timeout to the value returned by the + * server. */ + sts = register_set_expire(ticket); sip_rewrite_contact(ticket, DIR_INCOMING); } diff --git a/src/register.c b/src/register.c index c72ba8e..91092a1 100644 --- a/src/register.c +++ b/src/register.c @@ -601,3 +601,72 @@ int register_response(sip_ticket_t *ticket, int flag) { return STS_SUCCESS; } + +/* + * set expiration timeout from a SIP response + * + * RETURNS + * STS_SUCCESS on success + * STS_FAILURE on error + */ +int register_set_expire(sip_ticket_t *ticket) { + int i, j; + int expires=-1; + osip_contact_t *contact; + time_t time_now; + osip_header_t *expires_hdr=NULL; + osip_uri_param_t *expires_param=NULL; + + if (ticket->direction != RESTYP_INCOMING) { + WARN("register_set_expire called with != incoming response"); + return STS_FAILURE; + } + + time(&time_now); + + DEBUGC(DBCLASS_REG,"REGISTER response, looking for 'Expire' information"); + + /* evaluate Expires Header field */ + osip_message_get_expires(ticket->sipmsg, 0, &expires_hdr); + + /* loop for all existing contact headers in message */ + for (j=0; contact != NULL; j++) { + osip_message_get_contact(ticket->sipmsg, j, &contact); + + /* + * look for an Contact expires parameter - in case of REGISTER + * these two are equal. The Contact expires has higher priority! + */ + if (contact==NULL) continue; + + osip_contact_param_get_byname(contact, EXPIRES, &expires_param); + + if (expires_param && expires_param->gvalue) { + /* get expires from contact Header */ + expires=atoi(expires_param->gvalue); + } else if (expires_hdr && expires_hdr->hvalue) { + /* get expires from expires Header */ + expires=atoi(expires_hdr->hvalue); + } + + if (expires > 0) { + + /* search for an entry */ + for (i=0;iurl, urlmap[i].masq_url)==STS_SUCCESS)) break; + } + + /* found a mapping entry */ + if (isip_method : "NULL") : ((ticket.sipmsg->reason_phrase) ? ticket.sipmsg->reason_phrase : "NULL"))); - + /* - * if an REQ REGISTER, check if it is directed to myself, + * if a REQ REGISTER, check if it is directed to myself, * or am I just the outbound proxy but no registrar. * - If I'm the registrar, register & generate answer * - If I'm just the outbound proxy, register, rewrite & forward @@ -441,9 +441,7 @@ int main (int argc, char *argv[]) sts = proxy_request(&ticket); } } else { - if (MSG_IS_REQUEST(ticket.sipmsg)) { - sip_gen_response(&ticket, 408 /*request timeout*/); - } + sip_gen_response(&ticket, 408 /*request timeout*/); } } else { WARN("non-authorized registration attempt from %s", diff --git a/src/siproxd.h b/src/siproxd.h index 382b99d..2f6b53b 100644 --- a/src/siproxd.h +++ b/src/siproxd.h @@ -131,6 +131,7 @@ void register_save(void); int register_client(sip_ticket_t *ticket, int force_lcl_masq); /*X*/ void register_agemap(void); int register_response(sip_ticket_t *ticket, int flag); /*X*/ +int register_set_expire(sip_ticket_t *ticket); /*X*/ /* proxy.c */ int proxy_request (sip_ticket_t *ticket); /*X*/