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

📄 jcallback.c

📁 libeXosip2-3.0.3.tar.gz
💻 C
📖 第 1 页 / 共 5 页
字号:
        port = 5060;    }  net = &eXosip.net_interfaces[1];  /* remove preloaded route if there is no tag in the To header   */    {      osip_route_t *route=NULL;      osip_generic_param_t *tag=NULL;      osip_message_get_route (sip, 0, &route);            osip_to_get_tag (sip->to, &tag);      if (tag==NULL && route != NULL && route->url != NULL)	{	  osip_list_remove(&sip->routes, 0);	}      i = osip_message_to_str (sip, &message, &length);      if (tag==NULL && route != NULL && route->url != NULL)	{	  osip_list_add(&sip->routes, route, 0);	}    }  if (i != 0 || length <= 0)    {      return -1;    }  /* Step 1: find existing socket to send message */  if (out_socket <= 0)    {      out_socket = _eXosip_tcp_find_socket (host, port);      /* Step 2: create new socket with host:port */      if (out_socket <= 0)        {          out_socket = _eXosip_tcp_connect_socket (host, port);        }      OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,                              "Message sent: \n%s (to dest=%s:%i)\n",                              message, host, port));  } else    {      OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,                              "Message sent: \n%s (reusing REQUEST connection)\n",                              message, host, port));    }  if (out_socket <= 0)    {      return -1;    }  if (0 > send (out_socket, (const void *) message, length, 0))    {#ifdef WIN32      if (WSAECONNREFUSED == WSAGetLastError ())#else      if (ECONNREFUSED == errno)#endif        {          /* This can be considered as an error, but for the moment,             I prefer that the application continue to try sending             message again and again... so we are not in a error case.             Nevertheless, this error should be announced!             ALSO, UAS may not have any other options than retry always             on the same port.           */          osip_free (message);          return 1;      } else        {          /* SIP_NETWORK_ERROR; */#if !defined(_WIN32_WCE)          OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL,                                  "TCP error: \n%s\n", strerror (errno)));#endif          osip_free (message);          return -1;        }    }  osip_free (message);  return 0;}#endifstatic voidcb_xixt_kill_transaction (int type, osip_transaction_t * tr){  int i;  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO1, NULL,               "cb_nict_kill_transaction (id=%i)\r\n", tr->transactionid));  i = osip_remove_transaction (eXosip.j_osip, tr);  if (i != 0)    {      OSIP_TRACE (osip_trace                  (__FILE__, __LINE__, OSIP_BUG, NULL,                   "cb_nict_kill_transaction Error: Could not remove transaction from the oSIP stack? (id=%i)\r\n",                   tr->transactionid));    }  if (MSG_IS_REGISTER (tr->orig_request)      && type == OSIP_NICT_KILL_TRANSACTION && tr->last_response == NULL)    {      rcvregister_failure (tr, NULL);      return;    }#ifndef MINISIZE  if (type == OSIP_NICT_KILL_TRANSACTION)    {      eXosip_dialog_t *jd;      eXosip_subscribe_t *js;      eXosip_notify_t *jn;      eXosip_call_t *jc;      jinfo_t *jinfo = (jinfo_t *) osip_transaction_get_your_instance (tr);            if (jinfo == NULL && tr->last_response == NULL)	{	  eXosip_event_t *je;	  je = eXosip_event_init_for_message (EXOSIP_MESSAGE_REQUESTFAILURE, tr);	  report_event (je, NULL);	  return;	}      if (jinfo == NULL)	{	  return;	}      jc = jinfo->jc;      jd = jinfo->jd;      jn = jinfo->jn;      js = jinfo->js;            if (jn == NULL && js == NULL)	{	  eXosip_event_t *je;	  if (jc!=NULL)	    {	      report_call_event (EXOSIP_CALL_MESSAGE_REQUESTFAILURE, jc, jd, tr);	      return;	    }	  je = eXosip_event_init_for_message (EXOSIP_MESSAGE_REQUESTFAILURE, tr);	  report_event (je, NULL);	  return;	}            /* no answer to a NOTIFY request! */      if (MSG_IS_NOTIFY (tr->orig_request) && tr->last_response == NULL)	{	  /* delete the dialog! */	  eXosip_event_t *je;	  	  je = eXosip_event_init_for_notify (EXOSIP_NOTIFICATION_REQUESTFAILURE,					     jn, jd, tr);	  report_event (je, NULL);	  REMOVE_ELEMENT (eXosip.j_notifies, jn);	  eXosip_notify_free (jn);	  return;	}            if (MSG_IS_NOTIFY (tr->orig_request)	  && tr->last_response != NULL && tr->last_response->status_code > 299)	{	  /* delete the dialog! */	  if (tr->last_response->status_code != 407	      && tr->last_response->status_code != 401)	    {	      REMOVE_ELEMENT (eXosip.j_notifies, jn);	      eXosip_notify_free (jn);	      return;	    }	}            if (MSG_IS_NOTIFY (tr->orig_request)	  && tr->last_response != NULL	  && tr->last_response->status_code > 199	  && tr->last_response->status_code < 300)	{	  if (jn->n_ss_status == EXOSIP_SUBCRSTATE_TERMINATED)	    {	      /* delete the dialog! */	      REMOVE_ELEMENT (eXosip.j_notifies, jn);	      eXosip_notify_free (jn);	      return;	    }	}            /* no answer to a SUBSCRIBE request! */      if (MSG_IS_SUBSCRIBE (tr->orig_request) && tr->last_response == NULL)	{	  eXosip_event_t *je;	  	  je = eXosip_event_init_for_subscribe (EXOSIP_SUBSCRIPTION_REQUESTFAILURE,						js, jd, tr);	  report_event (je, NULL);	  /* delete the dialog! */	  REMOVE_ELEMENT (eXosip.j_subscribes, js);	  eXosip_subscribe_free (js);	  return;	}            /* detect SUBSCRIBE request that close the dialogs! */      /* expires=0 with MSN */      if (MSG_IS_SUBSCRIBE (tr->orig_request))	{	  osip_header_t *expires;	  	  osip_message_get_expires (tr->orig_request, 0, &expires);	  if (expires == NULL || expires->hvalue == NULL)	    {	    } else if (0 == strcmp (expires->hvalue, "0"))	      {		/* delete the dialog! */		REMOVE_ELEMENT (eXosip.j_subscribes, js);		eXosip_subscribe_free (js);		return;	      }	}    }#endif}#ifndef MINISIZEstatic voidcb_rcvinvite (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL, "cb_rcvinvite (id=%i)\n",               tr->transactionid));}static voidcb_rcvack (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL, "cb_rcvack (id=%i)\n",               tr->transactionid));}static voidcb_rcvack2 (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL, "cb_rcvack2 (id=%i)\r\n",               tr->transactionid));}static voidcb_rcvcancel (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_rcvcancel (id=%i)\r\n", tr->transactionid));}#endifstatic voidcb_rcvregister (int type, osip_transaction_t * tr, osip_message_t * sip){  eXosip_event_t *je;  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_rcvregister (id=%i)\r\n", tr->transactionid));  je = eXosip_event_init_for_message (EXOSIP_MESSAGE_NEW, tr);  eXosip_event_add (je);  return;}static voidcb_rcvrequest (int type, osip_transaction_t * tr, osip_message_t * sip){  eXosip_dialog_t *jd;  eXosip_call_t *jc;#ifndef MINISIZE  eXosip_notify_t *jn;  eXosip_subscribe_t *js;#endif  jinfo_t *jinfo = (jinfo_t *) osip_transaction_get_your_instance (tr);  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_rcvunkrequest (id=%i)\r\n", tr->transactionid));  if (jinfo == NULL)    {      eXosip_event_t *je;      je = eXosip_event_init_for_message (EXOSIP_MESSAGE_NEW, tr);      eXosip_event_add (je);      return;    }  jd = jinfo->jd;  jc = jinfo->jc;#ifndef MINISIZE  jn = jinfo->jn;  js = jinfo->js;  if (jc == NULL && jn == NULL && js == NULL)    {      eXosip_event_t *je;      je = eXosip_event_init_for_message (EXOSIP_MESSAGE_NEW, tr);      eXosip_event_add (je);      return;    }#else  if (jc == NULL)    {      eXosip_event_t *je;      je = eXosip_event_init_for_message (EXOSIP_MESSAGE_NEW, tr);      eXosip_event_add (je);      return;    }#endif  else if (jc != NULL)    {      OSIP_TRACE (osip_trace                  (__FILE__, __LINE__, OSIP_INFO3, NULL,                   "cb_rcv? (id=%i)\r\n", tr->transactionid));      if (MSG_IS_BYE(sip))      {          /* already sent */      }      else          report_call_event (EXOSIP_CALL_MESSAGE_NEW, jc, jd, tr);      return;    }#ifndef MINISIZE  else if (jn != NULL)    {      if (MSG_IS_SUBSCRIBE (sip))        {	  eXosip_event_t *je;          je =            eXosip_event_init_for_notify (EXOSIP_IN_SUBSCRIPTION_NEW, jn, jd, tr);          report_event (je, NULL);          return;        }      return;    }  else if (js != NULL)    {      if (MSG_IS_NOTIFY (sip))        {	  eXosip_event_t *je;          je =            eXosip_event_init_for_subscribe (EXOSIP_SUBSCRIPTION_NOTIFY, js,                                             jd, tr);          report_event (je, NULL);          return;        }      return;    }#endif}#ifndef MINISIZEstatic voidcb_sndinvite (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndinvite (id=%i)\r\n", tr->transactionid));}static voidcb_sndack (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL, "cb_sndack (id=%i)\r\n",               tr->transactionid));}static voidcb_sndregister (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndregister (id=%i)\r\n", tr->transactionid));}static voidcb_sndbye (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL, "cb_sndbye (id=%i)\r\n",               tr->transactionid));}static voidcb_sndcancel (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndcancel (id=%i)\r\n", tr->transactionid));}static voidcb_sndinfo (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL, "cb_sndinfo (id=%i)\r\n",               tr->transactionid));}static voidcb_sndoptions (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndoptions (id=%i)\r\n", tr->transactionid));}static voidcb_sndnotify (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndnotify (id=%i)\r\n", tr->transactionid));}static voidcb_sndsubscribe (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndsubscibe (id=%i)\r\n", tr->transactionid));}static voidcb_sndunkrequest (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndunkrequest (id=%i)\r\n", tr->transactionid));}

⌨️ 快捷键说明

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