Merged revisions 316617 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r316617 | dvossel | 2011-05-04 08:44:41 -0500 (Wed, 04 May 2011) | 19 lines
  
  Merged revisions 316616 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ........
    r316616 | dvossel | 2011-05-04 08:40:41 -0500 (Wed, 04 May 2011) | 12 lines
    
    Fixes session-timers=refuse not being enforced for *caller*
    
    During handle_request_invite, the session timer mode was retrieved from
    a cached variable.  This patch forces a peer lookup of the session timer
    mode in the case of an incoming invite.
    
    (closes issue #18804)
    Reported by: wdoekes
    Patches: 
          issue18804_session_timer_refuse_caller.patch uploaded by wdoekes (license 717)
          issue_18804_v2.diff uploaded by dvossel (license 671)
  ........
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@316618 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David Vossel
2011-05-04 13:48:07 +00:00
parent 99d0da2a2d
commit 3bf4b09a6e

View File

@@ -1565,7 +1565,7 @@ static int parse_session_expires(const char *p_hdrval, int *const p_interval, en
static int parse_minse(const char *p_hdrval, int *const p_interval); static int parse_minse(const char *p_hdrval, int *const p_interval);
static int st_get_se(struct sip_pvt *, int max); static int st_get_se(struct sip_pvt *, int max);
static enum st_refresher st_get_refresher(struct sip_pvt *); static enum st_refresher st_get_refresher(struct sip_pvt *);
static enum st_mode st_get_mode(struct sip_pvt *); static enum st_mode st_get_mode(struct sip_pvt *, int no_cached);
static struct sip_st_dlg* sip_st_alloc(struct sip_pvt *const p); static struct sip_st_dlg* sip_st_alloc(struct sip_pvt *const p);
/*------- RTP Glue functions -------- */ /*------- RTP Glue functions -------- */
@@ -9551,7 +9551,7 @@ static int process_sdp_a_image(const char *a, struct sip_pvt *p)
static int add_supported_header(struct sip_pvt *pvt, struct sip_request *req) static int add_supported_header(struct sip_pvt *pvt, struct sip_request *req)
{ {
int res; int res;
if (st_get_mode(pvt) != SESSION_TIMER_MODE_REFUSE) { if (st_get_mode(pvt, 0) != SESSION_TIMER_MODE_REFUSE) {
res = add_header(req, "Supported", "replaces, timer"); res = add_header(req, "Supported", "replaces, timer");
} else { } else {
res = add_header(req, "Supported", "replaces"); res = add_header(req, "Supported", "replaces");
@@ -11925,7 +11925,7 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init,
} }
/* Add Session-Timers related headers */ /* Add Session-Timers related headers */
if (st_get_mode(p) == SESSION_TIMER_MODE_ORIGINATE) { if (st_get_mode(p, 0) == SESSION_TIMER_MODE_ORIGINATE) {
char i2astr[10]; char i2astr[10];
if (!p->stimer->st_interval) { if (!p->stimer->st_interval) {
@@ -19632,7 +19632,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
} }
/* Check for Session-Timers related headers */ /* Check for Session-Timers related headers */
if (st_get_mode(p) != SESSION_TIMER_MODE_REFUSE && p->outgoing_call == TRUE && !reinvite) { if (st_get_mode(p, 0) != SESSION_TIMER_MODE_REFUSE && p->outgoing_call == TRUE && !reinvite) {
p_hdrval = (char*)get_header(req, "Session-Expires"); p_hdrval = (char*)get_header(req, "Session-Expires");
if (!ast_strlen_zero(p_hdrval)) { if (!ast_strlen_zero(p_hdrval)) {
/* UAS supports Session-Timers */ /* UAS supports Session-Timers */
@@ -19654,7 +19654,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, const char *rest
start_session_timer(p); start_session_timer(p);
} else { } else {
/* UAS doesn't support Session-Timers */ /* UAS doesn't support Session-Timers */
if (st_get_mode(p) == SESSION_TIMER_MODE_ORIGINATE) { if (st_get_mode(p, 0) == SESSION_TIMER_MODE_ORIGINATE) {
p->stimer->st_ref = SESSION_TIMER_REFRESHER_UAC; p->stimer->st_ref = SESSION_TIMER_REFRESHER_UAC;
p->stimer->st_active_peer_ua = FALSE; p->stimer->st_active_peer_ua = FALSE;
start_session_timer(p); start_session_timer(p);
@@ -22092,7 +22092,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
} }
dlg_min_se = st_get_se(p, FALSE); dlg_min_se = st_get_se(p, FALSE);
switch (st_get_mode(p)) { switch (st_get_mode(p, 1)) {
case SESSION_TIMER_MODE_ACCEPT: case SESSION_TIMER_MODE_ACCEPT:
case SESSION_TIMER_MODE_ORIGINATE: case SESSION_TIMER_MODE_ORIGINATE:
if (uac_max_se > 0 && uac_max_se < dlg_min_se) { if (uac_max_se > 0 && uac_max_se < dlg_min_se) {
@@ -22138,14 +22138,14 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
break; break;
default: default:
ast_log(LOG_ERROR, "Internal Error %d at %s:%d\n", st_get_mode(p), __FILE__, __LINE__); ast_log(LOG_ERROR, "Internal Error %d at %s:%d\n", st_get_mode(p, 1), __FILE__, __LINE__);
break; break;
} }
} else { } else {
/* The UAC did not request session-timers. Asterisk (UAS), will now decide /* The UAC did not request session-timers. Asterisk (UAS), will now decide
(based on session-timer-mode in sip.conf) whether to run session-timers for (based on session-timer-mode in sip.conf) whether to run session-timers for
this session or not. */ this session or not. */
switch (st_get_mode(p)) { switch (st_get_mode(p, 1)) {
case SESSION_TIMER_MODE_ORIGINATE: case SESSION_TIMER_MODE_ORIGINATE:
st_active = TRUE; st_active = TRUE;
st_interval = st_get_se(p, TRUE); st_interval = st_get_se(p, TRUE);
@@ -25300,15 +25300,18 @@ enum st_refresher st_get_refresher(struct sip_pvt *p)
} }
/*! \brief Get the session-timer mode /*!
* \param p pointer to the SIP dialog * \brief Get the session-timer mode
* \param p pointer to the SIP dialog
* \param no_cached, set this to true in order to force a peername lookup on
* the session timer mode.
*/ */
enum st_mode st_get_mode(struct sip_pvt *p) enum st_mode st_get_mode(struct sip_pvt *p, int no_cached)
{ {
if (!p->stimer) if (!p->stimer)
sip_st_alloc(p); sip_st_alloc(p);
if (p->stimer->st_cached_mode != SESSION_TIMER_MODE_INVALID) if (!no_cached && p->stimer->st_cached_mode != SESSION_TIMER_MODE_INVALID)
return p->stimer->st_cached_mode; return p->stimer->st_cached_mode;
if (p->relatedpeer) { if (p->relatedpeer) {