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

📄 sipproxyserver.c

📁 这是HPOC SIP栈的SIPUA
💻 C
📖 第 1 页 / 共 2 页
字号:
/* @@ WARNING: This example is automatically included in the user
   @@ documentation. (Note: The lines containing '@@' are removed
   @@ automatically). */

#include <strings.h>

#include "sip_api.h"

char * forward_to_uri = NULL;

sip_bool_t sip_exit = SIP_FALSE;

/*
 * FACILITY:
 *
 *      sip_trans_on_invite
 *
 * ABSTRACT:
 *
 *      The SIP transaction INVITE reception callback
 *
 * FORMAL PARAMETERS:
 *
 *      instance      : The SIP transaction instance
 *      trans         : The transaction ID
 *      request_uri   : The request URI to forward the ACK
 *      from          : The from header
 *      to            : The to header
 *      call_id       : The call ID
 *      cseq          : The CSEQ
 *      contact       : The contact header
 *      request       : Additional headers in the ACK
 *      body          : The ACK body
 *      user_info     : The user info
 *
 * RETURN VALUE:
 *
 *      SIP_NORMAL : successful completion
 *
 */

sip_status_t sip_trans_on_invite
  (
    sip_trans_inst_t              instance,
    sip_trans_t                   trans,
    sip_msg_uri_t               * request_uri,
    sip_msg_header_t            * from,
    sip_msg_header_t            * to,
    sip_msg_header_t            * call_id,
    sip_msg_header_t            * cseq,
    sip_msg_header_t            * contact,
    sip_msg_header_vector_t     * request,
    sip_msg_body_t              * body,
    sip_user_info_t             * user_info,
    sip_uint8_t                   transport_id
  )
{
  sip_status_t    sip_status;
  sip_msg_uri_t * uri[1];

  /* Modify the request URI */
  uri[0] = sip_msg_parse_uri(forward_to_uri, NULL);/*将forward_to_uri解析为sip_msg_uri_t类型*/
/*在parser文档中119页*/

  if (!uri[0]) {
    printf("Parse error in the forward URI.\n");
    return SIP_NORMAL;
  }

  /* We forward the INVITE ,此例程就是前转*/
  sip_status = sip_trans_forward_request(instance,
                                         trans,
                                         SIP_MSG_INVITE,
                                         uri,
                                         uri,
                                         NULL,
                                         1,
                                         request,
                                         body,
                                         SIP_FALSE,
                                         SIP_BEHAVIOR_TRANS_STATEFUL,
                                         NULL);/*此例程在开发手册的112页,重要*/
  if (sip_status != SIP_NORMAL)
    {
      printf("Error %d in forwarding an INVITE\n", sip_status);
    }
  else
    {
      printf("INVITE request forwarded to %s.\n",
             forward_to_uri);
    }

  sip_msg_free_uri(uri[0]);/*在parser中,用来删除一个URI,第103页*/

  return SIP_NORMAL;
}

/*
 * FACILITY:
 *
 *      sip_trans_on_ack
 *
 * ABSTRACT:
 *
 *      The SIP transaction ACK reception callback
 *
 * FORMAL PARAMETERS:
 *
 *      instance      : The SIP transaction instance
 *      trans         : The transaction ID
 *      request_uri   : The request URI to forward the ACK
 *      from          : The from header
 *      to            : The to header
 *      call_id       : The call ID
 *      cseq          : The CSEQ
 *      request       : Additional headers in the ACK
 *      body          : The ACK body
 *      user_info     : The user info
 *
 * RETURN VALUE:
 *
 *      SIP_NORMAL : successful completion
 *
 */

sip_status_t sip_trans_on_ack
  (
    sip_trans_inst_t              instance,
    sip_trans_t                   trans,
    sip_msg_uri_t               * request_uri,
    sip_msg_header_t            * from,
    sip_msg_header_t            * to,
    sip_msg_header_t            * call_id,
    sip_msg_header_t            * cseq,
    sip_msg_header_vector_t     * request,
    sip_msg_body_t              * body,
    sip_user_info_t             * user_info,
    sip_uint8_t                   transport_id
  )
{
  sip_status_t    sip_status;
  sip_msg_uri_t * uri[1];

  /* Modify the request URI */
  uri[0] = sip_msg_parse_uri(forward_to_uri, NULL);/*将forward_to_uri解析为sip_msg_uri_t类型*/
/*在parser文档中119页*/

  if (!uri[0]) {
    printf("Parse error in the forward URI.\n");
    return SIP_NORMAL;
  }

  /* We forward the ACK */
  sip_status = sip_trans_forward_request(instance,
                                         trans,
                                         SIP_MSG_ACK,
                                         uri,
                                         uri,
                                         NULL,
                                         1,
                                         request,
                                         body,
                                         SIP_FALSE,
                                         SIP_BEHAVIOR_TRANS_STATEFUL,
                                         NULL);/*此例程在开发手册的112页,重要*/
  if (sip_status != SIP_NORMAL)
    {
      printf("Error %d in forwarding an ACK\n", sip_status);
    }
  else
    {
      printf("ACK request forwarded to %s.\n",
             forward_to_uri);
    }

  sip_msg_free_uri(uri[0]);/*在parser中,用来删除一个URI,第103页*/

  return SIP_NORMAL;
}

/*
 * FACILITY:
 *
 *      sip_trans_on_bye
 *
 * ABSTRACT:
 *
 *      The SIP transaction BYE reception callback
 *
 * FORMAL PARAMETERS:
 *
 *      instance      : The SIP transaction instance
 *      trans         : The transaction ID
 *      request_uri   : The request URI to forward the BYE
 *      from          : The from header
 *      to            : The to header
 *      call_id       : The call ID
 *      cseq          : The CSEQ
 *      request       : Additional headers in the BYE
 *      body          : The BYE body
 *      user_info     : The user info
 *
 * RETURN VALUE:
 *
 *      SIP_NORMAL : successful completion
 *
 */

sip_status_t sip_trans_on_bye
  (
    sip_trans_inst_t              instance,
    sip_trans_t                   trans,
    sip_msg_uri_t               * request_uri,
    sip_msg_header_t            * from,
    sip_msg_header_t            * to,
    sip_msg_header_t            * call_id,
    sip_msg_header_t            * cseq,
    sip_msg_header_vector_t     * request,
    sip_msg_body_t              * body,
    sip_user_info_t             * user_info,
    sip_uint8_t                   transport_id
  )
{
  sip_status_t    sip_status;
  sip_msg_uri_t * uri[1];

  /* Modify the request URI */
  uri[0] = sip_msg_parse_uri(forward_to_uri, NULL);/*将forward_to_uri解析为sip_msg_uri_t类型*/
/*在parser文档中119页*/

  if (!uri[0]) {
    printf("Parse error in the forward URI.\n");
    return SIP_NORMAL;
  }

  /* We forward the BYE */
  sip_status = sip_trans_forward_request(instance,
                                         trans,
                                         SIP_MSG_BYE,
                                         uri,
                                         uri,
                                         NULL,
                                         1,
                                         request,
                                         body,
                                         SIP_FALSE,
                                         SIP_BEHAVIOR_TRANS_STATEFUL,
                                         NULL);/*此例程在开发手册的112页,重要*/
  if (sip_status != SIP_NORMAL)
    {
      printf("Error %d in forwarding a BYE\n", sip_status);
    }
  else
    {
      printf("BYE request forwarded to %s.\n",
             forward_to_uri);
    }

  sip_msg_free_uri(uri[0]);/*在parser中,用来删除一个URI,第103页*/

  return SIP_NORMAL;
}

/*
 * FACILITY:
 *
 *      sip_trans_on_response
 *
 * ABSTRACT:
 *
 *      The SIP transaction response reception callback
 *
 * FORMAL PARAMETERS:
 *
 *      instance           : The SIP transaction instance
 *      trans              : The transaction ID
 *      primary_trans      : The primary transaction ID
 *      branch_next_hop    : The initial request destination
 *      branch_request_uri : The initial request-uri
 *      status_code        : The response status code
 *      reason_phrase      : The response reason phrase
 *      from               : The response from header
 *      to                 : The response to header
 *      call_id            : The response call_id header
 *      cseq               : The response cseq header 
 *      response           : The response headers
 *      body               : The response body if any
 *      user_info          : The user info
 *
 * RETURN VALUE:
 *
 *      SIP_NORMAL : successful completion
 *
 */

sip_status_t sip_trans_on_response
  (
    sip_trans_inst_t              instance,
    sip_trans_t                   trans,
    sip_trans_t                   primary_trans,

⌨️ 快捷键说明

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