コード例 #1
0
ファイル: AmSession.cpp プロジェクト: Chocolatbuddha/sems
void AmSession::updateRefreshMethod(const string& headers) {
  if (refresh_method == REFRESH_UPDATE_FB_REINV) {
    if (key_in_list(getHeader(headers, SIP_HDR_ALLOW),
		    SIP_METH_UPDATE)) {
      DBG("remote allows UPDATE, using UPDATE for session refresh.\n");
      refresh_method = REFRESH_UPDATE;
    }
  }
}
コード例 #2
0
void SessionTimer::updateTimer(AmSession* s, const AmSipRequest& req) {

  if((req.method == "INVITE")||(req.method == "UPDATE")){
    
    remote_timer_aware = 
      key_in_list(getHeader(req.hdrs, SIP_HDR_SUPPORTED),"timer");
    
    // determine session interval
    string sess_expires_hdr = getHeader(req.hdrs, "Session-Expires", "x");
    
    //session_interval = get_session_interval_from(req);
    if (!sess_expires_hdr.empty()) {
      if (str2i(strip_header_params(sess_expires_hdr),
		session_interval)) {
	WARN("error while parsing Session-Expires header value '%s'\n", 
	     strip_header_params(sess_expires_hdr).c_str()); // exception?
	session_interval = session_timer_conf.getSessionExpires();  
      }
    } else {
      session_interval = session_timer_conf.getSessionExpires();  
    }

    // get Min-SE
    unsigned int i_minse = session_timer_conf.getMinimumTimer();
    string min_se_hdr = getHeader(req.hdrs, "Min-SE");
    if (!min_se_hdr.empty()) {
      if (str2i(strip_header_params(min_se_hdr),
		i_minse)) {
	WARN("error while parsing Min-SE header value '%s'\n", 
	     strip_header_params(min_se_hdr).c_str()); // exception?
      }
    }

    // calculate actual se
    unsigned int min = session_timer_conf.getMinimumTimer();
    if (i_minse > min)
      min = i_minse;
    if ((session_timer_conf.getSessionExpires() < min)||
	(session_interval<min)) {
      session_interval = min;
    } else {
      if (session_timer_conf.getSessionExpires() < session_interval)
	session_interval = session_timer_conf.getSessionExpires();
    }
     
    // determine session refresher -- cf rfc4028 Table 2
    // only if the remote party supports timer and asks 
    // to be refresher we will let the remote party do it. 
    // if remote supports timer and does not specify,
    // could also be refresher=uac
    if ((remote_timer_aware) && (!sess_expires_hdr.empty()) &&
	(get_header_param(sess_expires_hdr, "refresher") == "uac")) {
      DBG("session refresher will be remote UAC.\n");
      session_refresher      = refresh_remote;
      session_refresher_role = UAC;
    } else {
      DBG("session refresher will be local UAS.\n");
      session_refresher      = refresh_local;
      session_refresher_role = UAS;
    }
    
    removeTimers(s);
    setTimers(s);

  } else if (req.method == "BYE") { // remove all timers?
    removeTimers(s);
  }
}