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

📄 sip_dialog.h

📁 基于sip协议的网络电话源码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* $Id: sip_dialog.h 980 2007-02-19 18:37:42Z bennylp $ *//*  * Copyright (C) 2003-2007 Benny Prijono <benny@prijono.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  */#ifndef __PJSIP_SIP_DIALOG_H__#define __PJSIP_SIP_DIALOG_H__/** * @file dialog.h * @brief SIP Dialog abstraction */#include <pjsip/sip_msg.h>#include <pjsip/sip_auth.h>#include <pjsip/sip_errno.h>#include <pjsip/sip_transport.h>#include <pj/sock.h>#include <pj/assert.h>/** * @defgroup PJSIP_DIALOG Base Dialog * @ingroup PJSIP_UA * @brief The base dialog framework to support dialog usages. * @{ * * The base dialog framework provides management for base dialog * properties such as <b>From</b> header, <b>To</b> header, <b>CSeq</b> * sequencing, <b>Call-ID</b> header, <b>Contact</b> header management,  * dialog <b>route-set</b> management, and common <b>authentication</b>.  * This basic dialog functionality will be shared by all <b>dialog * usages</b> of a particular dialog. * * More detailed information is explained in * <A HREF="/docs.htm">PJSIP Developer's Guide</A> * PDF document, and readers are encouraged to read the document to * get the concept behind dialog, dialog usages, and INVITE sessions. * * Application MUST initialize the user agent layer module by calling * #pjsip_ua_init_module() before using any of the dialog API, and link * the application with with <b>pjsip-core</b> library. */PJ_BEGIN_DECL/** * This structure is used to describe dialog's participants, which in this * case is local party (i.e. us) and remote party. */typedef struct pjsip_dlg_party{    pjsip_fromto_hdr	*info;	    /**< From/To header, inc tag.	*/    pj_str_t		 info_str;  /**< String rep of info header.	*/    pj_uint32_t		 tag_hval;  /**< Hashed value of the tag.	*/    pjsip_contact_hdr	*contact;   /**< Contact header.		*/    pj_int32_t		 first_cseq;/**< First CSeq seen.		*/    pj_int32_t		 cseq;	    /**< Next sequence number.		*/} pjsip_dlg_party;/** * Dialog state. */typedef enum pjsip_dialog_state{    /** Dialog is not established. */    PJSIP_DIALOG_STATE_NULL,    /** Dialog has been established (probably early) */    PJSIP_DIALOG_STATE_ESTABLISHED} pjsip_dialog_state;/** * This structure describes the dialog structure. Application MUST NOT * try to SET the values here directly, but instead it MUST use the * appropriate dialog API. The dialog declaration only needs to be made  * visible because other PJSIP modules need to see it (e.g. INVITE session, * the event framework, etc.). * * Application MAY READ the dialog contents directly after it acquires * dialog lock. * * To acquire dialog lock, use #pjsip_dlg_inc_lock(), and to release it, * use #pjsip_dlg_dec_lock(). DO NOT USE pj_mutex_lock()/pj_mutex_unlock() * on the dialog's mutex directly, because this will not protect against * dialog being destroyed. */struct pjsip_dialog{    /** The dialog set list. */    PJ_DECL_LIST_MEMBER(pjsip_dialog);    /* Dialog's system properties. */    char		obj_name[PJ_MAX_OBJ_NAME];  /**< Standard id.	    */    pj_pool_t	       *pool;	    /**< Dialog's pool.			    */    pj_mutex_t	       *mutex_;	    /**< Dialog's mutex. Do not call!!					 Use pjsip_dlg_inc_lock() instead!  */    pjsip_user_agent   *ua;	    /**< User agent instance.		    */    pjsip_endpoint     *endpt;	    /**< Endpoint instance.		    */    /** The dialog set which this dialog belongs (opaque type). */    void	       *dlg_set;    /* Dialog's session properties. */    pjsip_dialog_state	state;	    /**< Dialog state.			    */    pjsip_uri	       *target;	    /**< Current target.		    */    pjsip_hdr	        inv_hdr;    /**< Headers from hparam in dest URL    */    pjsip_dlg_party     local;	    /**< Local party info.		    */    pjsip_dlg_party     remote;	    /**< Remote party info.		    */    pjsip_role_e	role;	    /**< Initial role.			    */    pj_bool_t		uac_has_2xx;/**< UAC has received 2xx response?     */     pj_bool_t		secure;	    /**< Use secure transport?		    */    pjsip_cid_hdr      *call_id;    /**< Call-ID header.		    */    pjsip_route_hdr	route_set;  /**< Route set.			    */    pjsip_auth_clt_sess	auth_sess;  /**< Client authentication session.	    */    /** Session counter. */    int			sess_count; /**< Number of sessions.		    */    /** Transaction counter. */    int			tsx_count;  /**< Number of pending transactions.    */    /** Transport selector. */    pjsip_tpselector	tp_sel;    /* Dialog usages. */    unsigned		usage_cnt;  /**< Number of registered usages.	    */    pjsip_module       *usage[PJSIP_MAX_MODULE]; /**< Array of usages, 					 priority sorted		    */    /** Module specific data. */    void	       *mod_data[PJSIP_MAX_MODULE]; /**< Module data.	    */};/** * This utility function returns PJ_TRUE if the specified method is a * dialog creating request. This method property is used to determine * whether Contact header should be included in outgoing request. * * @param m		The SIP method. * * @return		PJ_TRUE if the method creates a dialog. */PJ_DECL(pj_bool_t) pjsip_method_creates_dialog(const pjsip_method *m);/** * Create a new dialog and return the instance in p_dlg parameter.  * After creating  the dialog, application can add modules as dialog usages * by calling  #pjsip_dlg_add_usage().  * * If the request has To tag parameter, dialog's local tag will be initialized  * from this value. Otherwise a globally unique id generator will be invoked to * create dialog's local tag. * * This function also initializes the dialog's route set based on the  * Record-Route headers in the request, if present. * * Note that initially, the session count in the dialog will be initialized  * to zero. * * @param ua		    The user agent module instance. * @param local_uri	    Dialog local URI (i.e. From header). * @param local_contact_uri Optional dialog local Contact URI.  *			    If this argument is NULL, the Contact will be *			    taken from the local URI. * @param remote_uri	    Dialog remote URI (i.e. To header). * @param target	    Optional initial remote target. If this argument *			    is NULL, the initial target will be set to *			    remote URI. * @param p_dlg		    Pointer to receive the dialog. * * @return		    PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_dlg_create_uac( pjsip_user_agent *ua,					   const pj_str_t *local_uri,					   const pj_str_t *local_contact_uri,					   const pj_str_t *remote_uri,					   const pj_str_t *target,					   pjsip_dialog **p_dlg);/** * Initialize UAS dialog from the information found in the incoming request  * that creates a dialog (such as INVITE, REFER, or SUBSCRIBE), and set the  * local Contact to contact. If contact is not specified, the local contact  * is initialized from the URI in the To header in the request.  * * This function will also create UAS transaction for the incoming request, * and associate the transaction to the rdata. Application can query the * transaction used to handle this request by calling #pjsip_rdata_get_tsx() * after this function returns. * * Note that initially, the session count in the dialog will be initialized  * to zero. * * * @param ua		    The user agent module instance. * @param rdata		    The incoming request that creates the dialog, *			    such as INVITE, SUBSCRIBE, or REFER. * @param contact	    Optional URI to be used as local Contact. If *			    this argument is NULL, the local contact will be *			    initialized from the value of To header in the *			    request. * @param p_dlg		    Pointer to receive the dialog. * * @return		    PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_dlg_create_uas(  pjsip_user_agent *ua,					    pjsip_rx_data *rdata,					    const pj_str_t *contact,					    pjsip_dialog **p_dlg);/** * Lock/bind dialog to a specific transport/listener. This is optional, * as normally transport will be selected automatically based on the  * destination of messages upon resolver completion. When the dialog is  * explicitly bound to the specific transport/listener, all transactions * originated by this dialog will use the specified transport/listener * when sending outgoing requests. * * Note that this doesn't affect the Contact header generated by this * dialog. Application must manually update the Contact header if * necessary, to adjust the address according to the transport being * selected. * * @param dlg	    The dialog instance. * @param sel	    Transport selector containing the specification of *		    transport or listener to be used by this dialog *		    to send requests. * * @return	    PJ_SUCCESS on success, or the appropriate error code. */PJ_DECL(pj_status_t) pjsip_dlg_set_transport(pjsip_dialog *dlg,					     const pjsip_tpselector *sel);/** * Create a new (forked) dialog on receipt on forked response in rdata.  * The new dialog will be created from original_dlg, except that it will have * new remote tag as copied from the To header in the response. Upon return,  * the new_dlg will have been registered to the user agent. Applications just  * need to add modules as dialog's usages. * * Note that initially, the session count in the dialog will be initialized  * to zero. * * @param original_dlg	    The original UAC dialog. * @param rdata		    The incoming forked response message. * @param new_dlg	    Pointer to receive the new dialog. * * @return		    PJ_SUCCESS on success. */PJ_DECL(pj_status_t) pjsip_dlg_fork(const pjsip_dialog *original_dlg,				    const pjsip_rx_data *rdata,				    pjsip_dialog **new_dlg );/** * Forcefully terminate the dialog. Application can only call this function * when there is no session associated to the dialog. If there are sessions * that use this dialog, this function will refuse to terminate the dialog. * For this case, application MUST call the appropriate termination function  * for each dialog session (e.g. #pjsip_inv_terminate() to terminate INVITE * session). * * @param dlg		    The dialog. * * @return		    PJ_SUCCESS if dialog has been terminated. */PJ_DECL(pj_status_t) pjsip_dlg_terminate( pjsip_dialog *dlg );/** * Set dialog's initial route set to route_set list. This can only be called * for UAC dialog, before any request is sent. After dialog has been  * established, the route set can not be changed. * * For UAS dialog,the route set will be initialized in pjsip_dlg_create_uas() * from the Record-Route headers in the incoming request. * * The route_set argument is standard list of Route headers (i.e. with  * sentinel). * * @param dlg		    The UAC dialog. * @param route_set	    List of Route header.

⌨️ 快捷键说明

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