📄 nua_dialog.h
字号:
/* * This file is part of the Sofia-SIP package * * Copyright (C) 2006 Nokia Corporation. * * Contact: Pekka Pessi <pekka.pessi@nokia.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */#ifndef NUA_DIALOG_H/** Defined when <nua_dialog.h> has been included. */#define NUA_DIALOG_H/**@IFILE nua_dialog.h * @brief Dialog and dialog usage handling * * @author Pekka Pessi <Pekka.Pessi@nokia.com> * @author Kai Vehmanen <Kai.Vehmanen@nokia.com> * * @date Created: Wed Mar 8 11:38:18 EET 2006 ppessi */#include <nua_types.h>#ifndef NTA_H#include <sofia-sip/nta.h>#endiftypedef struct { sip_method_t sm_method; char const *sm_method_name; int sm_event; struct { unsigned create_dialog:1, in_dialog:1, target_refresh:1, add_contact:1; unsigned :0; } sm_flags; /** Initialize server-side request. */ int (*sm_init)(nua_server_request_t *sr); /** Preprocess server-side request (after handle has been created). */ int (*sm_preprocess)(nua_server_request_t *sr); /** Update server-side request parameters */ int (*sm_params)(nua_server_request_t *sr, tagi_t const *tags); /** Respond to server-side request. */ int (*sm_respond)(nua_server_request_t *sr, tagi_t const *tags); /** Report server-side request to application. */ int (*sm_report)(nua_server_request_t *sr, tagi_t const *tags);} nua_server_methods_t;/* Server side transaction */struct nua_server_request { struct nua_server_request *sr_next, **sr_prev; nua_server_methods_t const *sr_methods; nua_owner_t *sr_owner; /**< Backpointer to handle */ nua_dialog_usage_t *sr_usage; /**< Backpointer to usage */ nta_incoming_t *sr_irq; /**< Server transaction object */ struct { msg_t *msg; /**< Request message */ sip_t const *sip; /**< Headers in request message */ } sr_request; struct { msg_t *msg; /**< Response message */ sip_t *sip; /**< Headers in response message */ } sr_response; sip_method_t sr_method; /**< Request method */ int sr_application; /**< Status by application */ int sr_status; /**< Status code */ char const *sr_phrase; /**< Status phrase */ unsigned sr_event:1; /**< Reported to application */ unsigned sr_initial:1; /**< Handle was created by this request */ unsigned sr_add_contact:1; /**< Add Contact header to the response */ unsigned sr_target_refresh:1; /**< Refresh target */ unsigned sr_terminating:1; /**< Terminate usage after final response */ unsigned sr_gracefully:1; /**< Terminate usage gracefully */ unsigned sr_neutral:1; /**< No effect on session or other usage */ /* Flags used with 100rel */ unsigned sr_100rel:1, sr_pracked:1; /* Flags used with offer-answer */ unsigned sr_offer_recv:1; /**< We have received an offer */ unsigned sr_answer_sent:2; /**< We have answered (reliably, if >1) */ unsigned sr_offer_sent:2; /**< We have offered SDP (reliably, if >1) */ unsigned sr_answer_recv:1; /**< We have received SDP answer */ unsigned :0; char const *sr_sdp; /**< SDP received from client */ size_t sr_sdp_len; /**< SDP length */ /**< Save 200 OK nua_respond() signal until PRACK has been received */ nua_saved_signal_t sr_signal[1];};#define SR_STATUS(sr, status, phrase) \ ((sr)->sr_phrase = (phrase), (sr)->sr_status = (status))#define SR_STATUS1(sr, statusphrase) \ sr_status(sr, statusphrase)#define SR_HAS_SAVED_SIGNAL(sr) ((sr)->sr_signal[0] != NULL)su_inline int sr_status(nua_server_request_t *sr, int status, char const *phrase){ return (void)(sr->sr_phrase = phrase), (sr->sr_status = status);}/* Methods for client request. @internal */typedef struct { sip_method_t crm_method; char const *crm_method_name; size_t crm_extra; /**< Size of private data */ struct { unsigned create_dialog:1, in_dialog:1, target_refresh:1; unsigned:0; } crm_flags; /** Generate a request message. * * @retval 1 when request message has been created * @retval 0 when request message should be created in normal fashion * @retval -1 upon an error */ int (*crm_template)(nua_client_request_t *cr, msg_t **return_msg, tagi_t const *tags); /**@a crm_init is called when a client request is sent first time. * * @retval 1 when request has been responded * @retval 0 when request should be sent in normal fashion * @retval -1 upon an error */ int (*crm_init)(nua_client_request_t *, msg_t *msg, sip_t *sip, tagi_t const *tags); /** @a crm_send is called each time when a client request is sent. * * @retval 1 when request has been responded * @retval 0 when request has been sent * @retval -1 upon an error (request message has not been destroyed) * @retval -2 upon an error (request message has been destroyed) */ int (*crm_send)(nua_client_request_t *, msg_t *msg, sip_t *sip, tagi_t const *tags); /** @a crm_check_restart is called each time when a response is received. * * It is used to restart reqquest after responses with method-specific * status code or method-specific way of restarting the request. * * @retval 1 when request has been restarted * @retval 0 when response should be processed normally */ int (*crm_check_restart)(nua_client_request_t *, int status, char const *phrase, sip_t const *sip); /** @a crm_recv is called each time a final response is received. * * A final response is in range 200 .. 699 (or internal response) and it * cannot be restarted. * * crm_recv() should call nua_base_client_response() or * nua_base_client_tresponse(). The return values below are documented with * nua_base_client_response(), too. * * @retval 0 if response was preliminary * @retval 1 if response was final * @retval 2 if response destroyed the handle, too. */ int (*crm_recv)(nua_client_request_t *, int status, char const *phrase, sip_t const *sip); /** @a crm_preliminary is called each time a preliminary response is received. * * A preliminary response is in range 101 .. 199. * * crm_preliminary() should call nua_base_client_response() or * nua_base_client_tresponse(). * * @retval 0 if response was preliminary * @retval 1 if response was final * @retval 2 if response destroyed the handle, too. */ int (*crm_preliminary)(nua_client_request_t *, int status, char const *phrase, sip_t const *sip); /** @a crm_report is called each time a response is received and it is * reported to the application. * * The status and phrase may be different from the status and phrase * received from the network, e.g., when the request is restarted. * * @return The return value should be 0. It is currently ignored. */ int (*crm_report)(nua_client_request_t *, int status, char const *phrase, sip_t const *sip, nta_outgoing_t *orq, tagi_t const *tags); /** @a crm_complete is called when a client-side request is destroyed. * * @return The return value should be 0. It is currently ignored. */ int (*crm_complete)(nua_client_request_t *);} nua_client_methods_t;/* Client-side request. Documented by nua_client_create() */struct nua_client_request{ nua_client_request_t *cr_next, **cr_prev; /**< Linked list of requests */ nua_owner_t *cr_owner; nua_dialog_usage_t *cr_usage; nua_saved_signal_t cr_signal[1]; tagi_t const *cr_tags; nua_client_methods_t const *cr_methods; msg_t *cr_msg; sip_t *cr_sip; nta_outgoing_t *cr_orq; su_timer_t *cr_timer; /**< Expires or retry timer */ /*nua_event_t*/ int cr_event; /**< Request event */ sip_method_t cr_method; char const *cr_method_name; url_t *cr_target; char const *cr_phrase; /**< Latest status phrase */ unsigned short cr_status; /**< Latest status */ unsigned short cr_retry_count; /**< Retry count for this request */ uint32_t cr_seq; /* Flags used with offer-answer */ unsigned short cr_answer_recv; /**< Recv answer in response * with this status. */ unsigned cr_offer_sent:1; /**< Sent offer in this request */ unsigned cr_offer_recv:1; /**< Recv offer in a response */ unsigned cr_answer_sent:1; /**< Sent answer in (PR)ACK */ /* Flags with usage */ unsigned cr_neutral:1; /**< No effect on session or other usage */ /* Lifelong flags? */ unsigned cr_auto:1; /**< Request was generated by stack */ unsigned cr_has_contact:1; /**< Request has user Contact */ unsigned cr_contactize:1; /**< Request needs Contact */ unsigned cr_dialog:1; /**< Request can initiate dialog */ /* Current state */ unsigned cr_waiting:1; /**< Request is waiting */ unsigned cr_challenged:1; /**< Request was challenged */ unsigned cr_wait_for_cred:1; /**< Request is pending authentication */ unsigned cr_wait_for_timer:1; /**< Request is waiting for a timer to expire */ unsigned cr_restarting:1; /**< Request is being restarted */ unsigned cr_reporting:1; /**< Reporting in progress */ unsigned cr_terminating:1; /**< Request terminates the usage */ signed int cr_terminated:2; /**< Response terminated usage (1) or whole dialog (-1) */ unsigned cr_graceful:1; /**< Graceful termination required */};struct nua_dialog_state{ /** Dialog owner */ nua_owner_t *ds_owner; /** Dialog usages. */ nua_dialog_usage_t *ds_usage; /** Client requests */ nua_client_request_t *ds_cr; /** Server requests */ nua_server_request_t *ds_sr; /* Dialog and subscription state */ unsigned ds_reporting:1; /**< We are reporting */ unsigned ds_route:1; /**< We have route */ unsigned ds_terminating:1; /**< Being terminated */ unsigned ds_has_session:1; /**< We have session */ unsigned ds_has_register:1; /**< We have registration */ unsigned ds_has_publish:1; /**< We have publish */ unsigned ds_got_session:1; /**< We have (or have had) session */ unsigned ds_got_referrals:1; /**< We have (or have had) referrals */ unsigned :0; unsigned ds_has_events; /**< We have events */ unsigned ds_has_subscribes; /**< We have subscriptions */ unsigned ds_has_notifys; /**< We have notifiers */ sip_from_t const *ds_local; /**< Local address */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -