diff options
Diffstat (limited to 'tinySIP/include/tinysip/dialogs')
11 files changed, 968 insertions, 0 deletions
diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog.h b/tinySIP/include/tinysip/dialogs/tsip_dialog.h new file mode 100644 index 0000000..e6280b9 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog.h @@ -0,0 +1,208 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO 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 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ + +/**@file tsip_dialog.h + * @brief SIP dialog base class as per RFC 3261 subclause 17. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_DIALOG_H +#define TINYSIP_DIALOG_H + +#include "tinysip_config.h" + +#include "tsip.h" +#include "tinysip/tsip_uri.h" +#include "tinysip/tsip_timers.h" +#include "tinysip/tsip_message.h" +#include "tinysip/tsip_ssession.h" + +#include "tinysip/authentication/tsip_challenge.h" +#include "tinysip/tsip_action.h" + +#include "tinysip/headers/tsip_header_Record_Route.h" + +#include "tsk_safeobj.h" +#include "tsk_list.h" +#include "tsk_string.h" +#include "tsk_fsm.h" + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG(self) ((tsip_dialog_t*)(self)) +#define TSIP_DIALOG_GET_STATE(self) TSIP_DIALOG((self))->state +#define TSIP_DIALOG_GET_FSM(self) TSIP_DIALOG((self))->fsm +#define TSIP_DIALOG_GET_SS(self) TSIP_DIALOG((self))->ss +#define TSIP_DIALOG_GET_STACK(self) TSIP_STACK(TSIP_DIALOG_GET_SS((self))->stack) + +#define TSIP_DIALOG_TIMER_CANCEL(TX) \ + tsk_timer_mgr_global_cancel(self->timer##TX.id) + +// TX MUST be in seconds +#define TSIP_DIALOG_TIMER_SCHEDULE(name, TX) \ + self->timer##TX.id = tsk_timer_mgr_global_schedule(self->timer##TX.timeout, TSK_TIMER_CALLBACK_F(tsip_dialog_##name##_timer_callback), self) + +#define TSIP_DIALOG_SIGNAL(self, code, phrase) \ + tsip_event_signal(tsip_event_dialog, TSIP_DIALOG(self)->ss, code, phrase) + +#define TSIP_DIALOG_SIGNAL_2(self, code, phrase, message) \ + tsip_event_signal_2(tsip_event_dialog, TSIP_DIALOG(self)->ss, code, phrase, message) + +#if !defined(TSIP_DIALOG_SHUTDOWN_TIMEOUT) +# define TSIP_DIALOG_SHUTDOWN_TIMEOUT 2000 /* miliseconds. */ +#endif + +#if !defined(TSIP_DIALOG_INVALID_ID) +# define TSIP_DIALOG_INVALID_ID 0 +#endif + +typedef uint64_t tsip_dialog_id_t; + +typedef enum tsip_dialog_state_e +{ + tsip_initial, + tsip_early, + tsip_established, + tsip_terminated +} +tsip_dialog_state_t; + +typedef enum tsip_dialog_type_e +{ + tsip_dialog_unknown, + tsip_dialog_INVITE, + tsip_dialog_MESSAGE, + tsip_dialog_INFO, + tsip_dialog_OPTIONS, + tsip_dialog_PUBLISH, + tsip_dialog_REGISTER, + tsip_dialog_SUBSCRIBE, +} +tsip_dialog_type_t; + +typedef enum tsip_dialog_event_type_e +{ + tsip_dialog_i_msg, + tsip_dialog_o_msg, + tsip_dialog_transac_ok, + tsip_dialog_canceled, + tsip_dialog_terminated, + tsip_dialog_timedout, + tsip_dialog_error, + tsip_dialog_transport_error, +} +tsip_dialog_event_type_t; + +typedef int (*tsip_dialog_event_callback_f)(const void *arg, tsip_dialog_event_type_t type, const tsip_message_t *msg); +#define TSIP_DIALOG_EVENT_CALLBACK_F(callback) ((tsip_dialog_event_callback_f)(callback)) + +/*================================ +*/ +typedef struct tsip_dialog_s +{ + TSK_DECLARE_OBJECT; + + tsip_dialog_type_t type; + tsip_dialog_id_t id; + + tsk_fsm_t* fsm; + + tsip_ssession_t* ss; + tsip_action_t* curr_action; + + tsip_dialog_state_t state; + + tsk_bool_t initialized; + tsk_bool_t running; + + tnet_fd_t connected_fd; + + struct{ + char* phrase; + short code; + tsip_message_t* message; + } last_error; + + char* tag_local; + tsip_uri_t* uri_local; + char* tag_remote; + tsip_uri_t* uri_remote; + + tsip_uri_t* uri_remote_target; + struct sockaddr_storage remote_addr; // Only valid for Dgram + + uint32_t cseq_value; + char* cseq_method; + + int64_t expires; /* in milliseconds */ + + char* callid; + + tsip_header_Record_Routes_L_t *record_routes; + + tsip_challenges_L_t *challenges; + + tsip_dialog_event_callback_f callback; + + TSK_DECLARE_SAFEOBJ; +} +tsip_dialog_t; + +#define TSIP_DECLARE_DIALOG tsip_dialog_t __dialog__ + +typedef tsk_list_t tsip_dialogs_L_t; +/* +================================*/ + +tsip_request_t *tsip_dialog_request_new(const tsip_dialog_t *self, const char* method); +int tsip_dialog_request_send(const tsip_dialog_t *self, tsip_request_t* request); +tsip_response_t *tsip_dialog_response_new(tsip_dialog_t *self, short status, const char* phrase, const tsip_request_t* request); +int tsip_dialog_response_send(const tsip_dialog_t *self, tsip_response_t* response); +int tsip_dialog_apply_action(tsip_message_t* message, const tsip_action_t* action); + +int64_t tsip_dialog_get_newdelay(tsip_dialog_t *self, const tsip_message_t* message); +int tsip_dialog_update(tsip_dialog_t *self, const tsip_response_t* response); +int tsip_dialog_update_2(tsip_dialog_t *self, const tsip_request_t* invite); +int tsip_dialog_getCKIK(tsip_dialog_t *self, AKA_CK_T *ck, AKA_IK_T *ik); + +int tsip_dialog_init(tsip_dialog_t *self, tsip_dialog_type_t type, const char* call_id, tsip_ssession_t* ss, tsk_fsm_state_id curr, tsk_fsm_state_id term); +int tsip_dialog_fsm_act(tsip_dialog_t* self, tsk_fsm_action_id , const tsip_message_t* , const tsip_action_handle_t*); +#define tsip_dialog_fsm_act_2(self, action_id) tsip_dialog_fsm_act((self), (action_id), tsk_null, tsk_null) +tsk_bool_t tsip_dialog_keep_action(const tsip_dialog_t* self, const tsip_response_t *response); +int tsip_dialog_set_connected_fd(tsip_dialog_t* self, tnet_fd_t fd); +int tsip_dialog_set_curr_action(tsip_dialog_t* self, const tsip_action_t* action); +int tsip_dialog_set_lasterror(tsip_dialog_t* self, const char* phrase, short code); +int tsip_dialog_set_lasterror_2(tsip_dialog_t* self, const char* phrase, short code, const tsip_message_t *message); +int tsip_dialog_get_lasterror(const tsip_dialog_t* self, short *code, const char** phrase, const tsip_message_t **message); +int tsip_dialog_hangup(tsip_dialog_t *self, const tsip_action_t* action); +int tsip_dialog_shutdown(tsip_dialog_t *self, const tsip_action_t* action); +int tsip_dialog_signal_transport_error(tsip_dialog_t *self); +int tsip_dialog_remove(const tsip_dialog_t* self); +int tsip_dialog_cmp(const tsip_dialog_t *d1, const tsip_dialog_t *d2); +int tsip_dialog_deinit(tsip_dialog_t *self); + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_H */ + diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_info.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_info.h new file mode 100644 index 0000000..94fe6ad --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_info.h @@ -0,0 +1,57 @@ +/* Copyright (C) 2011 Doubango Telecom <http://www.doubango.org> +* Copyright (C) 2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango(dot)org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO 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 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ + +/**@file tsip_dialog_info.h + * @brief SIP dialog INFO. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_DIALOG_INFO_H +#define TINYSIP_DIALOG_INFO_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +/* Forward declaration */ +struct tsip_message_s; + +#define TSIP_DIALOG_INFO(self) ((tsip_dialog_info_t*)(self)) + +typedef struct tsip_dialog_info +{ + TSIP_DECLARE_DIALOG; + /**< Last incoming message. */ + struct tsip_message_s* last_iMessage; +} +tsip_dialog_info_t; + +tsip_dialog_info_t* tsip_dialog_info_create(const tsip_ssession_handle_t* ss); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_info_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_INFO_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.common.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.common.h new file mode 100644 index 0000000..1496ca7 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.common.h @@ -0,0 +1,122 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO 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 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.common.h + * @brief SIP dialog INVITE (common variables). + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_DIALOG_INVITE_COMMON_H +#define TINYSIP_DIALOG_INVITE_COMMON_H + +#include "tinysip/api/tsip_api_invite.h" + +#define DEBUG_STATE_MACHINE 1 +#define TSIP_DIALOG_INVITE_SIGNAL(self, type, code, phrase, message) \ + tsip_invite_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) +#define TSIP_DIALOG_INVITE_TIMER_SCHEDULE(TX) TSIP_DIALOG_TIMER_SCHEDULE(invite, TX) + +#define TSIP_DIALOG_INVITE_ICE_CONNCHECK_TIMEOUT 16000 + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_accept = tsip_atype_accept, + _fsm_action_reject = tsip_atype_hangup, + _fsm_action_dtmf_send = tsip_atype_dtmf_send, + _fsm_action_msrp_send_msg = tsip_atype_lmessage, + _fsm_action_oINVITE = tsip_atype_invite, + _fsm_action_oCANCEL = tsip_atype_cancel, + _fsm_action_oHold = tsip_atype_hold, + _fsm_action_oResume = tsip_atype_resume, + _fsm_action_oECT = tsip_atype_ect, + _fsm_action_iECT_ACCEPT = tsip_atype_ect_accept, + _fsm_action_iECT_REJECT = tsip_atype_ect_reject, + _fsm_action_iECT_lNOTIFY = tsip_atype_ect_lnotify, + _fsm_action_oINFO = tsip_atype_info_send, + _fsm_action_oBYE = tsip_atype_hangup, + _fsm_action_oShutdown = tsip_atype_shutdown, + _fsm_action_transporterror = tsip_atype_transport_error, + + _fsm_action_iINVITE = 0xFF, + _fsm_action_oUPDATE, + _fsm_action_iUPDATE, + _fsm_action_iCANCEL, + _fsm_action_iPRACK, + _fsm_action_oPRACK, + _fsm_action_iACK, + _fsm_action_oACK, + _fsm_action_iOPTIONS, + _fsm_action_oOPTIONS, + _fsm_action_iBYE, + _fsm_action_iREFER, + _fsm_action_iINFO, + _fsm_action_iNOTIFY, + + _fsm_action_timer100rel, + _fsm_action_timerRefresh, + _fsm_action_timerRSVP, + + _fsm_action_i1xx, + _fsm_action_i2xx, + _fsm_action_i300_to_i699, + _fsm_action_i401_i407, + _fsm_action_i422, + + _fsm_action_shutdown_timedout, /* Any -> Terminated */ + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_Outgoing, + _fsm_state_Incoming, + _fsm_state_Trying, + _fsm_state_Ringing, + _fsm_state_Cancelling, + _fsm_state_InProgress, + + _fsm_state_Holding, + _fsm_state_Resuming, + + _fsm_state_oECTing, + _fsm_state_iECTing, + _fsm_state_iECTreq, + + _fsm_state_Connected, + _fsm_state_Terminated +} +_fsm_state_t; + + +#define send_INVITE(self, force_sdp) send_INVITEorUPDATE(self, tsk_true, force_sdp) +#define send_UPDATE(self, force_sdp) send_INVITEorUPDATE(self, tsk_false, force_sdp) + +#else +#error "This file must only be included in a source(.c or .cxx)" + +#endif /* TINYSIP_DIALOG_INVITE_COMMON_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.h new file mode 100644 index 0000000..b3bbfea --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_invite.h @@ -0,0 +1,128 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO 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 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ + +/**@file tsip_dialog_invite.h + * @brief SIP dialog INVITE. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_DIALOG_INVITE_H +#define TINYSIP_DIALOG_INVITE_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +#include "tinymedia/tmedia_session.h" + + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG_INVITE(self) ((tsip_dialog_invite_t*)(self)) + +typedef struct tsip_dialog_invite +{ + TSIP_DECLARE_DIALOG; + + tsk_bool_t support_update; /**< Indicates whether the remote party support UPDATE */ + tsk_bool_t is_client; + tsk_bool_t is_transf; + tsk_bool_t refersub; + tsk_bool_t use_rtcp; + tsk_bool_t use_rtcpmux; + tsk_bool_t is_initial_iack_pending; // we're waiting for the initial incoming ACK (for the 200 OK) to ensure the session + tsk_bool_t is_cancelling; // whether we're cancelling the outgoing INVITE + uint32_t rseq; + uint32_t cseq_out_media_update; // CSeq for the last media update request (INVITE or UPDATE). + uint64_t last_out_fastupdate_time; + + tsip_timer_t timershutdown; + tsip_timer_t timer100rel; + + tsip_response_t* last_o1xxrel; + tsip_request_t* last_iInvite; + tsip_request_t* last_oInvite; + tsip_request_t* last_iRefer; + tmedia_session_mgr_t* msession_mgr; /**< Media session Manager */ + + struct tsip_ssession_s* ss_transf; + + /* ICE */ + struct{ + tmedia_type_t media_type; + tsk_bool_t is_jingle; + tsk_bool_t start_smgr; + struct tnet_ice_ctx_s *ctx_audio; + struct tnet_ice_ctx_s *ctx_video; + tsk_fsm_action_id last_action_id; + tsip_action_t* last_action; + tsip_message_t* last_message; + int32_t last_sdp_ro_ver; + } ice; + + /* Session Timers */ + struct{ + tsip_timer_t timer; + char* refresher; + uint64_t minse; + tsk_bool_t is_refresher; + } stimers; + /* QoS (Preconditions) */ + struct{ + tsip_timer_t timer; + enum tmedia_qos_stype_e type; + enum tmedia_qos_strength_e strength; + } qos; + /* Hold/Resume */ + struct{ + unsigned remote:1; + unsigned local:1; + } hold; + + struct{ + unsigned _100rel:1; + unsigned precondition:1; + unsigned timer:1; + unsigned norefersub:1; + unsigned ice:1; + } supported; + + struct{ + unsigned _100rel:1; + unsigned precondition:1; + unsigned timer:1; + unsigned norefersub; + unsigned ice:1; + } required; +} +tsip_dialog_invite_t; + +tsip_dialog_invite_t* tsip_dialog_invite_create(const tsip_ssession_handle_t* ss, const char* call_id); + +int tsip_dialog_invite_start(tsip_dialog_invite_t *self); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_invite_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_INVITE_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_layer.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_layer.h new file mode 100644 index 0000000..3539361 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_layer.h @@ -0,0 +1,88 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO 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 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ + +/**@file tsip_dialog.h + * @brief SIP dialog layer. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_DIALOG_LAYER_H +#define TINYSIP_DIALOG_LAYER_H + +#include "tinysip_config.h" + +#include "tsip.h" +#include "tinysip/dialogs/tsip_dialog.h" + +#include "tsk_condwait.h" +#include "tsk_safeobj.h" +#include "tsk_list.h" + +TSIP_BEGIN_DECLS + +typedef struct tsip_dialog_layer_s +{ + TSK_DECLARE_OBJECT; + + const tsip_stack_t *stack; + + tsip_dialogs_L_t *dialogs; + + struct{ + tsk_bool_t inprogress; + tsk_bool_t phase2; /* whether unregistering? */ + tsk_condwait_handle_t* condwait; + } shutdown; + + TSK_DECLARE_SAFEOBJ; +} +tsip_dialog_layer_t; + +typedef tsk_list_t tsip_dialog_layers_L_t; + +tsip_dialog_layer_t* tsip_dialog_layer_create(tsip_stack_t* stack); + +TINYSIP_API tsip_dialog_t* tsip_dialog_layer_find_by_ss(tsip_dialog_layer_t *self, const tsip_ssession_handle_t *ss); +tsip_dialog_t* tsip_dialog_layer_find_by_ssid(tsip_dialog_layer_t *self, tsip_ssession_id_t ssid); +tsip_dialog_t* tsip_dialog_layer_find_by_callid(tsip_dialog_layer_t *self, const char* callid); +tsk_bool_t tsip_dialog_layer_have_dialog_with_callid(const tsip_dialog_layer_t *self, const char* callid); + +tsk_size_t tsip_dialog_layer_count_active_calls(tsip_dialog_layer_t *self); + + +TINYSIP_API int tsip_dialog_layer_shutdownAll(tsip_dialog_layer_t *self); +int tsip_dialog_layer_signal_stack_disconnected(tsip_dialog_layer_t *self); +int tsip_dialog_layer_signal_peer_disconnected(tsip_dialog_layer_t *self, const struct tsip_transport_stream_peer_s* peer); +int tsip_dialog_layer_remove_callid_from_stream_peers(tsip_dialog_layer_t *self, const char* callid); +tsip_dialog_t* tsip_dialog_layer_new(tsip_dialog_layer_t *self, tsip_dialog_type_t type, const tsip_ssession_t *ss); +int tsip_dialog_layer_remove(tsip_dialog_layer_t *self, const tsip_dialog_t *dialog); + +int tsip_dialog_layer_handle_incoming_msg(const tsip_dialog_layer_t *self, tsip_message_t* message); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_layer_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_LAYER_H */ + diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_message.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_message.h new file mode 100644 index 0000000..904af54 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_message.h @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO 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 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ + +/**@file tsip_dialog_message.h + * @brief SIP dialog MESSAGE. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_DIALOG_MESSAGE_H +#define TINYSIP_DIALOG_MESSAGE_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +/* Forward declaration */ +struct tsip_message_s; + +#define TSIP_DIALOG_MESSAGE(self) ((tsip_dialog_message_t*)(self)) + +typedef struct tsip_dialog_message +{ + TSIP_DECLARE_DIALOG; + /**< Last incoming or outgoing message. */ + struct tsip_message_s* request; +} +tsip_dialog_message_t; + +tsip_dialog_message_t* tsip_dialog_message_create(const tsip_ssession_handle_t* ss); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_message_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_MESSAGE_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_options.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_options.h new file mode 100644 index 0000000..e092a32 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_options.h @@ -0,0 +1,54 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO 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 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ + +/**@file tsip_dialog_options.h + * @brief SIP dialog OPTIONS as per RFC 3261 section 11. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_DIALOG_OPTIONS_H +#define TINYSIP_DIALOG_OPTIONS_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG_OPTIONS(self) ((tsip_dialog_options_t*)(self)) + +typedef struct tsip_dialog_options +{ + TSIP_DECLARE_DIALOG; + /**< Last incoming message. */ + struct tsip_message_s* last_iMessage; +} +tsip_dialog_options_t; + +tsip_dialog_options_t* tsip_dialog_options_create(const tsip_ssession_handle_t* ss); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_options_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_OPTIONS_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_publish.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_publish.h new file mode 100644 index 0000000..b4ef37b --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_publish.h @@ -0,0 +1,60 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO 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 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ + +/**@file tsip_dialog_publish.h + * @brief SIP dialog PUBLISH as per RFC 3903. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_DIALOG_PUBLISH_H +#define TINYSIP_DIALOG_PUBLISH_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG_PUBLISH(self) ((tsip_dialog_publish_t*)(self)) + +typedef struct tsip_dialog_publish +{ + TSIP_DECLARE_DIALOG; + + tsip_timer_t timerrefresh; + tsip_timer_t timershutdown; + + tsk_bool_t unpublishing; + char* etag; +} +tsip_dialog_publish_t; + +tsip_dialog_publish_t* tsip_dialog_publish_create(const tsip_ssession_handle_t* ss); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_publish_def_t; + + +TSIP_END_DECLS + + +#endif /* TINYSIP_DIALOG_PUBLISH_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_register.common.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_register.common.h new file mode 100644 index 0000000..94e4897 --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_register.common.h @@ -0,0 +1,75 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as publishd by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ +#ifndef TINYSIP_DIALOG_REGISTER_COMMON_H +#define TINYSIP_DIALOG_REGISTER_COMMON_H + +#include "tinysip/api/tsip_api_register.h" + +#define DEBUG_STATE_MACHINE 1 +#define TSIP_DIALOG_REGISTER_TIMER_SCHEDULE(TX) TSIP_DIALOG_TIMER_SCHEDULE(register, TX) +#define TSIP_DIALOG_REGISTER_SIGNAL(self, type, code, phrase, message) \ + tsip_register_event_signal(type, TSIP_DIALOG(self)->ss, code, phrase, message) + + +/* ======================== actions ======================== */ +typedef enum _fsm_action_e +{ + _fsm_action_accept = tsip_atype_accept, + _fsm_action_reject = tsip_atype_hangup, + _fsm_action_hangup = tsip_atype_hangup, + _fsm_action_oREGISTER = tsip_atype_register, + _fsm_action_cancel = tsip_atype_cancel, + _fsm_action_shutdown = tsip_atype_shutdown, + _fsm_action_transporterror = tsip_atype_transport_error, + + _fsm_action_1xx = 0xFF, + _fsm_action_2xx, + _fsm_action_401_407_421_494, + _fsm_action_423, + _fsm_action_300_to_699, + + _fsm_action_iREGISTER, + + _fsm_action_shutdown_timedout, /* Any -> Terminated */ + _fsm_action_error, +} +_fsm_action_t; + +/* ======================== states ======================== */ +typedef enum _fsm_state_e +{ + _fsm_state_Started, + _fsm_state_InProgress, // Outgoing (Client) + _fsm_state_Incoming, // Incoming (Server) + _fsm_state_Connected, + _fsm_state_Terminated +} +_fsm_state_t; + + +#define _fsm_cond_silent_shutdown _fsm_cond_silent_hangup +#define _fsm_cond_not_silent_shutdown _fsm_cond_not_silent_hangup + +#else +#error "This file must only be included in a source(.c or .cxx)" + +#endif /* TINYSIP_DIALOG_REGISTER_COMMON_H */ diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_register.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_register.h new file mode 100644 index 0000000..d2acf1a --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_register.h @@ -0,0 +1,62 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO 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 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ + +/**@file tsip_dialog_register.h + * @brief SIP dialog REGISTER. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_DIALOG_REGISTER_H +#define TINYSIP_DIALOG_REGISTER_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG_REGISTER(self) ((tsip_dialog_register_t*)(self)) + +/**< SIP REGISTER dialog */ +typedef struct tsip_dialog_register +{ + TSIP_DECLARE_DIALOG; + + tsip_timer_t timerrefresh; + tsip_timer_t timershutdown; + + tsip_request_t* last_iRegister; + + tsk_bool_t unregistering; + tsk_bool_t is_server; +} +tsip_dialog_register_t; + +tsip_dialog_register_t* tsip_dialog_register_create(const tsip_ssession_handle_t* ss, const char* call_id); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_register_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_REGISTER_H */ + diff --git a/tinySIP/include/tinysip/dialogs/tsip_dialog_subscribe.h b/tinySIP/include/tinysip/dialogs/tsip_dialog_subscribe.h new file mode 100644 index 0000000..c7db35b --- /dev/null +++ b/tinySIP/include/tinysip/dialogs/tsip_dialog_subscribe.h @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2010-2011 Mamadou Diop. +* +* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO 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 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO 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 DOUBANGO. +* +*/ + +/**@file tsip_dialog_subscribe.h + * @brief SIP dialog SUBSCRIBE as per RFC 3265. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_DIALOG_SUBSCRIBE_H +#define TINYSIP_DIALOG_SUBSCRIBE_H + +#include "tinysip_config.h" +#include "tinysip/dialogs/tsip_dialog.h" + +TSIP_BEGIN_DECLS + +#define TSIP_DIALOG_SUBSCRIBE(self) ((tsip_dialog_subscribe_t*)(self)) + +typedef struct tsip_dialog_subscribe +{ + TSIP_DECLARE_DIALOG; + + tsip_timer_t timerrefresh; + tsip_timer_t timershutdown; + + tsk_bool_t unsubscribing; +} +tsip_dialog_subscribe_t; + +tsip_dialog_subscribe_t* tsip_dialog_subscribe_create(const tsip_ssession_handle_t* ss); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_dialog_subscribe_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_DIALOG_SUBSCRIBE_H */ |