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

📄 sip_util.h

📁 基于sip协议的网络电话源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/** * This structure describes destination information to send response. * It is initialized by calling #pjsip_get_response_addr(). * * If the response message should be sent using transport from which * the request was received, then transport, addr, and addr_len fields * are initialized. * * The dst_host field is also initialized. It should be used when server * fails to send the response using the transport from which the request * was received, or when the transport is NULL, which means server * must send the response to this address (this situation occurs when * maddr parameter is set, or when rport param is not set in the request). */typedef struct pjsip_response_addr{    pjsip_transport *transport;	/**< Immediate transport to be used. */    pj_sockaddr	     addr;	/**< Immediate address to send to.   */    int		     addr_len;	/**< Address length.		     */    pjsip_host_info  dst_host;	/**< Destination host to contact.    */} pjsip_response_addr;/** * Determine which address (and transport) to use to send response message * based on the received request. This function follows the specification * in section 18.2.2 of RFC 3261 and RFC 3581 for calculating the destination * address and transport. * * The information about destination to send the response will be returned * in res_addr argument. Please see #pjsip_response_addr for more info. * * @param pool	    The pool. * @param rdata	    The incoming request received by the server. * @param res_addr  On return, it will be initialized with information about *		    destination address and transport to send the response. * * @return	    zero (PJ_OK) if successfull. */PJ_DECL(pj_status_t) pjsip_get_response_addr(pj_pool_t *pool,					     pjsip_rx_data *rdata,					     pjsip_response_addr *res_addr);/** * Send response in tdata statelessly. The function will take care of which  * response destination and transport to use based on the information in the  * Via header (such as the presence of rport, symmetric transport, etc.). * * This function will create a new ephemeral transport if no existing  * transports can be used to send the message to the destination. The ephemeral * transport will be destroyed after some period if it is not used to send any  * more messages. * * The behavior of this function complies with section 18.2.2 of RFC 3261 * and RFC 3581. * * @param endpt	    The endpoint instance. * @param res_addr  The information about the address and transport to send *		    the response to. Application can get this information *		    by calling #pjsip_get_response_addr(). * @param tdata	    The response message to be sent. * @param token	    Token to be passed back when the callback is called. * @param cb	    Optional callback to notify the transmission status *		    to application, and to inform whether next address or *		    transport will be tried. *  * @return	    PJ_SUCCESS if response has been successfully created and *		    sent to transport layer, or a non-zero error code.  *		    However, even when it returns PJ_SUCCESS, there is no  *		    guarantee that the response has been successfully sent. */PJ_DECL(pj_status_t) pjsip_endpt_send_response( pjsip_endpoint *endpt,					        pjsip_response_addr *res_addr,					        pjsip_tx_data *tdata,						void *token,						void (*cb)(pjsip_send_state*,							   pj_ssize_t sent,							   pj_bool_t *cont));/** * This is a convenient function which wraps #pjsip_get_response_addr() and * #pjsip_endpt_send_response() in a single function. * * @param endpt	    The endpoint instance. * @param rdata	    The original request to be responded. * @param tdata	    The response message to be sent. * @param token	    Token to be passed back when the callback is called. * @param cb	    Optional callback to notify the transmission status *		    to application, and to inform whether next address or *		    transport will be tried. *  * @return	    PJ_SUCCESS if response has been successfully created and *		    sent to transport layer, or a non-zero error code.  *		    However, even when it returns PJ_SUCCESS, there is no  *		    guarantee that the response has been successfully sent. */PJ_DECL(pj_status_t) pjsip_endpt_send_response2(pjsip_endpoint *endpt,					        pjsip_rx_data *rdata,					        pjsip_tx_data *tdata,						void *token,						void (*cb)(pjsip_send_state*,							   pj_ssize_t sent,							   pj_bool_t *cont));/** * This composite function sends response message statelessly to an incoming * request message. Internally it calls #pjsip_endpt_create_response() and * #pjsip_endpt_send_response(). * * @param endpt	    The endpoint instance. * @param rdata	    The incoming request message. * @param st_code   Status code of the response. * @param st_text   Optional status text of the response. * @param hdr_list  Optional header list to be added to the response. * @param body	    Optional message body to be added to the response. * * @return	    PJ_SUCCESS if response message has successfully been *		    sent. */PJ_DECL(pj_status_t) pjsip_endpt_respond_stateless(pjsip_endpoint *endpt,						   pjsip_rx_data *rdata,						   int st_code,						   const pj_str_t *st_text,						   const pjsip_hdr *hdr_list,						   const pjsip_msg_body *body);						    /** * @} *//** * @defgroup PJSIP_TRANSACT_UTIL Stateful Operations * @ingroup PJSIP_TRANSACT * @brief Utility function to send requests/responses statefully. * @{ *//** * This composite function creates and sends response statefully for the * incoming request. * * @param endpt	    The endpoint instance. * @param tsx_user  The module to be registered as transaction user. * @param rdata	    The incoming request message. * @param st_code   Status code of the response. * @param st_text   Optional status text of the response. * @param hdr_list  Optional header list to be added to the response. * @param body	    Optional message body to be added to the response. * @param p_tsx	    Optional pointer to receive the transaction which was *		    created to send the response. * * @return	    PJ_SUCCESS if response message has successfully been *		    created. */PJ_DECL(pj_status_t) pjsip_endpt_respond( pjsip_endpoint *endpt,					  pjsip_module *tsx_user,					  pjsip_rx_data *rdata,					  int st_code,					  const pj_str_t *st_text,					  const pjsip_hdr *hdr_list,					  const pjsip_msg_body *body,					  pjsip_transaction **p_tsx );/** * Send outgoing request and initiate UAC transaction for the request. * This is an auxiliary function to be used by application to send arbitrary * requests outside a dialog. To send a request within a dialog, application * should use #pjsip_dlg_send_request instead. * * @param endpt	    The endpoint instance. * @param tdata	    The transmit data to be sent. * @param timeout   Optional timeout for final response to be received, or -1  *		    if the transaction should not have a timeout restriction. *		    The value is in miliseconds. * @param token	    Optional token to be associated with the transaction, and  *		    to be passed to the callback. * @param cb	    Optional callback to be called when the transaction has *		    received a final response. The callback will be called with *		    the previously registered token and the event that triggers *		    the completion of the transaction. * * @return	    PJ_SUCCESS, or the appropriate error code. */PJ_DECL(pj_status_t) pjsip_endpt_send_request( pjsip_endpoint *endpt,					       pjsip_tx_data *tdata,					       pj_int32_t timeout,					       void *token,					       void (*cb)(void*,pjsip_event*));/** * @} *//** * @defgroup PJSIP_PROXY_CORE Core Proxy Layer * @ingroup PJSIP * @brief Core proxy operations * @{ *//** * Create new request message to be forwarded upstream to new destination URI  * in uri. The new request is a full/deep clone of the request received in  * rdata, unless if other copy mechanism is specified in the options.  * The branch parameter, if not NULL, will be used as the branch-param in  * the Via header. If it is NULL, then a unique branch parameter will be used. * * Note: this function DOES NOT perform Route information preprocessing as *	  described in RFC 3261 Section 16.4. Application must take care of *	  removing/updating the Route headers according of the rules as *	  described in that section. * * @param endpt	    The endpoint instance. * @param rdata	    The incoming request message. * @param uri	    The URI where the request will be forwarded to. * @param branch    Optional branch parameter. Application may specify its *		    own branch, for example if it wishes to perform loop *		    detection. If the branch parameter is not specified, *		    this function will generate its own by calling  *		    #pjsip_calculate_branch_id() function. * @param options   Optional option flags when duplicating the message. * @param tdata	    The result. * * @return	    PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_endpt_create_request_fwd(pjsip_endpoint *endpt,						    pjsip_rx_data *rdata, 						    const pjsip_uri *uri,						    const pj_str_t *branch,						    unsigned options,						    pjsip_tx_data **tdata);/** * Create new response message to be forwarded downstream by the proxy from  * the response message found in rdata. Note that this function practically  * will clone the response as is, i.e. without checking the validity of the  * response or removing top most Via header. This function will perform  * full/deep clone of the response, unless other copy mechanism is used in  * the options. * * @param endpt	    The endpoint instance. * @param rdata	    The incoming response message. * @param options   Optional option flags when duplicate the message. * @param tdata	    The result * * @return	    PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_endpt_create_response_fwd( pjsip_endpoint *endpt,						      pjsip_rx_data *rdata, 						      unsigned options,						      pjsip_tx_data **tdata);/** * Create a globally unique branch parameter based on the information in  * the incoming request message, for the purpose of creating a new request * for forwarding. This is the default implementation used by  * #pjsip_endpt_create_request_fwd() function if the branch parameter is * not specified. * * The default implementation here will just create an MD5 hash of the * top-most Via. * * Note that the returned string was allocated from rdata's pool. * * @param rdata	    The incoming request message. * * @return	    Unique branch-ID string. */PJ_DECL(pj_str_t) pjsip_calculate_branch_id( pjsip_rx_data *rdata );/** * @} */PJ_END_DECL#endif	/* __PJSIP_SIP_MISC_H__ */

⌨️ 快捷键说明

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