⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exosip.c

📁 libosip2-3版本的osip源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
  OSIP_TRACE (osip_trace	      (__FILE__, __LINE__, OSIP_ERROR, NULL,	       "eXosip: Can't retry event %d with auth\n", je->type));  return -1;}static int_eXosip_redirect (eXosip_event_t * je){  switch (je->type)    {      case EXOSIP_CALL_REDIRECTED:        return _eXosip_redirect_invite (je);      case EXOSIP_CALL_MESSAGE_REDIRECTED:      case EXOSIP_MESSAGE_REDIRECTED:      case EXOSIP_SUBSCRIPTION_REDIRECTED:        OSIP_TRACE (osip_trace                    (__FILE__, __LINE__, OSIP_ERROR, NULL,                     "eXosip: not implemented\n"));        return -1;      default:        OSIP_TRACE (osip_trace                    (__FILE__, __LINE__, OSIP_ERROR, NULL,                     "eXosip: Can't redirect event %d\n", je->type));        return -1;    }}inteXosip_default_action (eXosip_event_t * je){  if (!je || !je->response)    return -1;  if (je->response->status_code == 401 || je->response->status_code == 407)    return eXosip_retry_with_auth (je);  else if (je->response->status_code >= 300 && je->response->status_code <= 399)    return _eXosip_redirect (je);  else    return 1;}voideXosip_automatic_refresh (void){  eXosip_subscribe_t *js;  eXosip_dialog_t *jd;  eXosip_reg_t *jr;  time_t now;  now = time (NULL);  for (js = eXosip.j_subscribes; js != NULL; js = js->next)    {      for (jd = js->s_dialogs; jd != NULL; jd = jd->next)        {          if (jd->d_dialog != NULL && (jd->d_id >= 1))  /* finished call */            {              osip_transaction_t *out_tr = NULL;              out_tr = osip_list_get (jd->d_out_trs, 0);              if (out_tr == NULL)                out_tr = js->s_out_tr;              if (js->s_reg_period == 0 || out_tr == NULL)                {              } else if (now - out_tr->birth_time > js->s_reg_period - 60)                {               /* will expires in 60 sec: send refresh! */                  int i;                  i =                    _eXosip_subscribe_send_request_with_credential (js,                                                                    jd, out_tr);                  if (i != 0)                    {                      OSIP_TRACE (osip_trace                                  (__FILE__, __LINE__, OSIP_ERROR, NULL,                                   "eXosip: could not clone subscribe for refresh\n"));                    }                }            }        }    }  for (jr = eXosip.j_reg; jr != NULL; jr = jr->next)    {      if (jr->r_id >= 1 && jr->r_last_tr != NULL)        {          if (jr->r_reg_period == 0)            {              /* skip refresh! */          } else if (now - jr->r_last_tr->birth_time > 900)            {              /* automatic refresh */              eXosip_register_send_register (jr->r_id, NULL);          } else if (now - jr->r_last_tr->birth_time > jr->r_reg_period - 60)            {              /* automatic refresh */              eXosip_register_send_register (jr->r_id, NULL);          } else if (now - jr->r_last_tr->birth_time > 120 &&                     (jr->r_last_tr->last_response == NULL                      || (!MSG_IS_STATUS_2XX (jr->r_last_tr->last_response))))            {              /* automatic refresh */              eXosip_register_send_register (jr->r_id, NULL);            }        }    }}voideXosip_retransmit_lost200ok(){	eXosip_call_t *jc;	eXosip_dialog_t *jd;	time_t now;	now = time (NULL);	for (jc = eXosip.j_calls; jc != NULL; jc = jc->next)	{		if (jc->c_id >= 1 && jc->c_dialogs != NULL)		{			for (jd = jc->c_dialogs; jd != NULL; jd = jd->next)			{				if (jd->d_id >=1 && jd->d_dialog != NULL && jd->d_200Ok!=NULL)				{					if (jd->d_count==5)					{						OSIP_TRACE (osip_trace									(__FILE__, __LINE__, OSIP_ERROR, NULL,									"eXosip: no ACK received during 20s: dropping call\n"));						/* hard for users to detect than I sent this BYE... */						jd->d_count=0;						osip_message_free(jd->d_200Ok);						jd->d_200Ok=NULL;						eXosip_call_terminate(jc->c_id, jd->d_id);					}					else if (jd->d_timer<now)					{						/* a dialog exist: retransmit lost 200ok */						jd->d_timer = time (NULL) + 4;						jd->d_count++;						jd = jc->c_dialogs;						/* TU retransmission */						cb_snd_message (NULL, jd->d_200Ok, NULL,0, -1);					}				}			}		}	}	return;}voideXosip_automatic_action (void){  eXosip_call_t *jc;  eXosip_subscribe_t *js;  eXosip_dialog_t *jd;  eXosip_notify_t *jn;  eXosip_reg_t *jr;  time_t now;  now = time (NULL);  for (jc = eXosip.j_calls; jc != NULL; jc = jc->next)    {      if (jc->c_id < 1)        {      } else if (jc->c_dialogs == NULL || jc->c_dialogs->d_dialog == NULL)        {          /* an EARLY dialog may have failed with 401,407 or 3Xx */          osip_transaction_t *out_tr = NULL;          out_tr = jc->c_out_tr;          if (out_tr != NULL              && (out_tr->state == ICT_TERMINATED                  || out_tr->state == NICT_TERMINATED                  || out_tr->state == ICT_COMPLETED                  || out_tr->state == NICT_COMPLETED) &&              now - out_tr->birth_time < 120 &&              out_tr->orig_request != NULL &&              out_tr->last_response != NULL &&              (out_tr->last_response->status_code == 401               || out_tr->last_response->status_code == 407))            {              /* retry with credential */              if (jc->c_retry < 3)                {                  int i;                  i = _eXosip_call_send_request_with_credential (jc, NULL, out_tr);                  if (i != 0)                    {                      OSIP_TRACE (osip_trace                                  (__FILE__, __LINE__, OSIP_ERROR, NULL,                                   "eXosip: could not clone msg for authentication\n"));                    }                  jc->c_retry++;                }          } else if (out_tr != NULL                     && (out_tr->state == ICT_TERMINATED                         || out_tr->state == NICT_TERMINATED                         || out_tr->state == ICT_COMPLETED                         || out_tr->state == NICT_COMPLETED) &&                     now - out_tr->birth_time < 120 &&                     out_tr->orig_request != NULL &&                     out_tr->last_response != NULL &&                     (out_tr->last_response->status_code >= 300                      && out_tr->last_response->status_code <= 399))            {              /* retry with credential */              int i;              i = _eXosip_call_redirect_request (jc, NULL, out_tr);              if (i != 0)                {                  OSIP_TRACE (osip_trace                              (__FILE__, __LINE__, OSIP_ERROR, NULL,                               "eXosip: could not clone msg for redirection\n"));                }            }        }      for (jd = jc->c_dialogs; jd != NULL; jd = jd->next)        {          if (jd->d_dialog == NULL)     /* finished call */            {          } else            {              osip_transaction_t *out_tr = NULL;              out_tr = osip_list_get (jd->d_out_trs, 0);              if (out_tr == NULL)                out_tr = jc->c_out_tr;              if (out_tr != NULL                  && (out_tr->state == ICT_TERMINATED                      || out_tr->state == NICT_TERMINATED                      || out_tr->state == ICT_COMPLETED                      || out_tr->state == NICT_COMPLETED) &&                  now - out_tr->birth_time < 120 &&                  out_tr->orig_request != NULL &&                  out_tr->last_response != NULL &&                  (out_tr->last_response->status_code == 401                   || out_tr->last_response->status_code == 407))                {                  /* retry with credential */                  if (jd->d_retry < 3)                    {                      int i;                      i =                        _eXosip_call_send_request_with_credential (jc, jd, out_tr);                      if (i != 0)                        {                          OSIP_TRACE (osip_trace                                      (__FILE__, __LINE__, OSIP_ERROR, NULL,                                       "eXosip: could not clone msg for authentication\n"));                        }                      jd->d_retry++;                    }              } else if (out_tr != NULL                         && (out_tr->state == ICT_TERMINATED                             || out_tr->state == NICT_TERMINATED                             || out_tr->state == ICT_COMPLETED                             || out_tr->state == NICT_COMPLETED) &&                         now - out_tr->birth_time < 120 &&                         out_tr->orig_request != NULL &&                         out_tr->last_response != NULL &&                         (out_tr->last_response->status_code >= 300                          && out_tr->last_response->status_code <= 399))                {                  /* retry with credential */                  int i;                  i = _eXosip_call_redirect_request (jc, jd, out_tr);                  if (i != 0)                    {                      OSIP_TRACE (osip_trace                                  (__FILE__, __LINE__, OSIP_ERROR, NULL,                                   "eXosip: could not clone msg for redirection\n"));                    }                }            }        }    }  for (js = eXosip.j_subscribes; js != NULL; js = js->next)    {      if (js->s_id < 1)        {      } else if (js->s_dialogs == NULL)        {          osip_transaction_t *out_tr = NULL;          out_tr = js->s_out_tr;          if (out_tr != NULL              && (out_tr->state == NICT_TERMINATED                  || out_tr->state == NICT_COMPLETED) &&              now - out_tr->birth_time < 120 &&              out_tr->orig_request != NULL &&              out_tr->last_response != NULL &&              (out_tr->last_response->status_code == 401               || out_tr->last_response->status_code == 407))            {              /* retry with credential */              if (js->s_retry < 3)                {                  int i;                  i =                    _eXosip_subscribe_send_request_with_credential (js, NULL,                                                                    out_tr);                  if (i != 0)                    {                      OSIP_TRACE (osip_trace                                  (__FILE__, __LINE__, OSIP_ERROR, NULL,                                   "eXosip: could not clone msg for authentication\n"));                    }                  js->s_retry++;                }            }        }      for (jd = js->s_dialogs; jd != NULL; jd = jd->next)        {          if (jd->d_dialog != NULL)     /* finished call */            {              if (jd->d_id >= 1)                {                  osip_transaction_t *out_tr = NULL;                  out_tr = osip_list_get (jd->d_out_trs, 0);                  if (out_tr == NULL)                    out_tr = js->s_out_tr;                  if (out_tr != NULL                      && (out_tr->state == NICT_TERMINATED                          || out_tr->state == NICT_COMPLETED) &&                      now - out_tr->birth_time < 120 &&                      out_tr->orig_request != NULL &&                      out_tr->last_response != NULL &&                      (out_tr->last_response->status_code == 401                       || out_tr->last_response->status_code == 407))                    {                      /* retry with credential */                      if (jd->d_retry < 3)                        {                          int i;                          i =                            _eXosip_subscribe_send_request_with_credential                            (js, jd, out_tr);                          if (i != 0)                            {                              OSIP_TRACE (osip_trace                                          (__FILE__, __LINE__, OSIP_ERROR,                                           NULL,                                           "eXosip: could not clone suscbribe for authentication\n"));                            }                          jd->d_retry++;                        }                  } else if (js->s_reg_period == 0 || out_tr == NULL)                    {                  } else if (now - out_tr->birth_time > js->s_reg_period - 60)                    {           /* will expires in 60 sec: send refresh! */                      int i;                      i =                        _eXosip_subscribe_send_request_with_credential (js,                                                                        jd,                                                                        out_tr);                      if (i != 0)                        {                          OSIP_TRACE (osip_trace                                      (__FILE__, __LINE__, OSIP_ERROR, NULL,                                       "eXosip: could not clone subscribe for refresh\n"));                        }                    }                }            }        }    }  for (jn = eXosip.j_notifies; jn != NULL; jn = jn->next)    {      for (jd = jn->n_dialogs; jd != NULL; jd = jd->next)        {          if (jd->d_dialog != NULL)     /* finished call */            {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -