diff options
Diffstat (limited to 'tinySIP/include/tinysip/transactions')
6 files changed, 500 insertions, 0 deletions
diff --git a/tinySIP/include/tinysip/transactions/tsip_transac.h b/tinySIP/include/tinysip/transactions/tsip_transac.h new file mode 100644 index 0000000..3a896a0 --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac.h @@ -0,0 +1,181 @@ +/* +* 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_transac.h + * @brief SIP transaction base class as per RFC 3261 subclause 17. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_TRANSAC_H +#define TINYSIP_TRANSAC_H + +#include "tinysip_config.h" + +#include "tsip.h" +#include "tinysip/tsip_timers.h" +#include "tinysip/tsip_message.h" + +#include "tinysip/dialogs/tsip_dialog.h" + +#include "tsk_safeobj.h" +#include "tsk_list.h" +#include "tsk_fsm.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSAC(self) ((tsip_transac_t*)(self)) +#define TSIP_TRANSAC_GET_TYPE(self) TSIP_TRANSAC((self))->type +#define TSIP_TRANSAC_GET_FSM(self) TSIP_TRANSAC((self))->fsm +#define TSIP_TRANSAC_GET_SESSION(self) ((struct tsip_ssession_s*)(TSIP_TRANSAC_GET_DIALOG((self)) ? TSIP_TRANSAC_GET_DIALOG((self))->ss : tsk_null)) +#define TSIP_TRANSAC_GET_DIALOG(self) ((struct tsip_dialog_s*)(TSIP_TRANSAC_GET_DST((self))->type == tsip_transac_dst_type_dialog ? TSIP_TRANSAC_GET_DST((self))->dialog.dlg : tsk_null)) +#define TSIP_TRANSAC_GET_DST(self) TSIP_TRANSAC((self))->dst +#define TSIP_TRANSAC_GET_STACK(self) TSIP_TRANSAC_GET_DST((self))->stack +#define TSIP_TRANSAC_GET_TIMER_MGR(self) TSIP_TRANSAC_GET_STACK((self))->timer_mgr + +#define TSIP_TRANSAC_IS_CLIENT(self) ((self) && ((self)->type == tsip_transac_type_ict || (self)->type == tsip_transac_type_nict)) +#define TSIP_TRANSAC_IS_SERVER(self) !TSIP_TRANSAC_IS_CLIENT((self)) + +#define TSIP_TRANSAC_MAGIC_COOKIE "z9hG4bK" + +#define TSIP_TRANSAC_SYNC_BEGIN(self) tsk_safeobj_lock(TSIP_TRANSAC(self)) +#define TSIP_TRANSAC_SYNC_END(self) tsk_safeobj_unlock(TSIP_TRANSAC(self)) + +#define TRANSAC_TIMER_SCHEDULE(name, TX) \ + self->timer##TX.id = tsk_timer_mgr_global_schedule(self->timer##TX.timeout, TSK_TIMER_CALLBACK_F(tsip_transac_##name##_timer_callback), self) + +#define TRANSAC_TIMER_CANCEL(TX) \ + tsk_timer_mgr_global_cancel(self->timer##TX.id) + +typedef enum tsip_transac_event_type_e +{ + tsip_transac_incoming_msg, + tsip_transac_outgoing_msg, + tsip_transac_canceled, + tsip_transac_terminated, + tsip_transac_timedout, + tsip_transac_error, + tsip_transac_transport_error +} +tsip_transac_event_type_t; + +/*typedef struct tsip_transac_event_s +{ + tsip_transac_event_type_t type; + const tsip_message_t *msg; +} +tsip_transac_event_t; + +#define TSIP_TRANSAC_EVENT_INIT(transac_event, type, msg) \ + transac_event.type = type; \ + transac_event.msg = msg;*/ + +typedef int (*tsip_transac_event_callback_f)(const void *arg, tsip_transac_event_type_t type, const tsip_message_t *msg); +#define TSIP_TRANSAC_EVENT_CALLBACK_F(callback) ((tsip_transac_event_callback_f)(callback)) + +typedef enum tsip_transac_type_e +{ + tsip_transac_type_ict, /**< Invite Client Transaction. */ + tsip_transac_type_ist, /**< Invite Server Transaction. */ + tsip_transac_type_nict, /**< Non-Invite Client Transaction. */ + tsip_transac_type_nist, /**< Non-Invite Server Transaction. */ +} +tsip_transac_type_t; + + + +typedef enum tsip_transac_dst_type_e +{ + tsip_transac_dst_type_dialog, + tsip_transac_dst_type_net +} +tsip_transac_dst_type_t; + +typedef struct tsip_transac_dst_s +{ + TSK_DECLARE_OBJECT; + + tsip_transac_dst_type_t type; + struct tsip_stack_s* stack; + + union{ + struct{ + tsip_dialog_t *dlg; + }dialog; + + //struct{ + //}net; + }; +} +tsip_transac_dst_t; +#define TSIP_TRANSAC_DST(self) ((tsip_transac_dst_t*)(self)) +#define TSIP_DECLARE_TRANSAC_DST tsip_transac_dst_t __transac__ + + +typedef struct tsip_transac_s +{ + TSK_DECLARE_OBJECT; + + tsip_transac_type_t type; + + struct tsip_transac_dst_s* dst; + tsk_fsm_t *fsm; + + tsk_bool_t reliable; + tsk_bool_t running; + tsk_bool_t initialized; + + char *branch; + + int32_t cseq_value; + char* cseq_method; + + char* callid; + + tsip_transac_event_callback_f callback; +} +tsip_transac_t; + +#define TSIP_DECLARE_TRANSAC tsip_transac_t __transac__ + +typedef tsk_list_t tsip_transacs_L_t; /**< List of @ref tsip_transac_t elements. */ +/* +================================*/ + +int tsip_transac_init(tsip_transac_t *self, tsip_transac_type_t type, int32_t cseq_value, const char* cseq_method, const char* callid, struct tsip_transac_dst_s* dst, tsk_fsm_state_id curr, tsk_fsm_state_id term); +int tsip_transac_deinit(tsip_transac_t *self); +int tsip_transac_start(tsip_transac_t *self, const tsip_request_t* request); +int tsip_transac_deliver(tsip_transac_t* self, tsip_dialog_event_type_t event_type, const tsip_message_t *msg); +int tsip_transac_send(tsip_transac_t *self, const char *branch, tsip_message_t *msg); +int tsip_transac_cmp(const tsip_transac_t *t1, const tsip_transac_t *t2); +int tsip_transac_remove(const tsip_transac_t* self); +int tsip_transac_fsm_act(tsip_transac_t* self, tsk_fsm_action_id , const tsip_message_t*); + + +struct tsip_transac_dst_s* tsip_transac_dst_dialog_create(tsip_dialog_t *dlg); +struct tsip_transac_dst_s* tsip_transac_dst_net_create(struct tsip_stack_s* stack); + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac_ict.h b/tinySIP/include/tinysip/transactions/tsip_transac_ict.h new file mode 100644 index 0000000..a34a413 --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac_ict.h @@ -0,0 +1,63 @@ +/* +* 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_transac_ict.h + * @brief SIP INVITE Client Transaction as per RFC 3261 subclause 17.1.1. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_TRANSAC_ICT_H +#define TINYSIP_TRANSAC_ICT_H + +#include "tinysip_config.h" + +#include "tinysip/transactions/tsip_transac.h" +#include "tinysip/tsip_message.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSAC_ICT(self) ((tsip_transac_ict_t*)(self)) + +typedef struct tsip_transac_ict +{ + TSIP_DECLARE_TRANSAC; + + tsip_request_t* request; + + tsip_timer_t timerA; + tsip_timer_t timerB; + tsip_timer_t timerD; + tsip_timer_t timerM; +} +tsip_transac_ict_t; + +tsip_transac_ict_t* tsip_transac_ict_create(int32_t cseq_value, const char* callid, tsip_transac_dst_t* dst); +int tsip_transac_ict_start(tsip_transac_ict_t *self, const tsip_request_t* request); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transac_ict_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_ICT_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac_ist.h b/tinySIP/include/tinysip/transactions/tsip_transac_ist.h new file mode 100644 index 0000000..82abdbe --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac_ist.h @@ -0,0 +1,64 @@ +/* +* 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_transac_ist.h + * @brief SIP INVITE Server Transaction as per RFC 3261 subclause 17.2.1. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_TRANSAC_IST_H +#define TINYSIP_TRANSAC_IST_H + +#include "tinysip_config.h" +#include "tinysip/transactions/tsip_transac.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSAC_IST(self) ((tsip_transac_ist_t*)(self)) + + +typedef struct tsip_transac_ist +{ + TSIP_DECLARE_TRANSAC; + + tsip_response_t* lastResponse; + tsk_bool_t acked; + + tsip_timer_t timerH; + tsip_timer_t timerI; + tsip_timer_t timerG; + tsip_timer_t timerL; + tsip_timer_t timerX; +} +tsip_transac_ist_t; + +tsip_transac_ist_t* tsip_transac_ist_create(int32_t cseq_value, const char* callid, tsip_transac_dst_t* dst); +int tsip_transac_ist_start(tsip_transac_ist_t *self, const tsip_request_t* request); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transac_ist_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_IST_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac_layer.h b/tinySIP/include/tinysip/transactions/tsip_transac_layer.h new file mode 100644 index 0000000..acc532c --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac_layer.h @@ -0,0 +1,72 @@ +/* +* 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_transac.h + * @brief SIP transaction layer. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_TRANSAC_LAYER_H +#define TINYSIP_TRANSAC_LAYER_H + +#include "tinysip_config.h" + +#include "tsip.h" +#include "tinysip/transactions/tsip_transac.h" + +#include "tsk_safeobj.h" +#include "tsk_list.h" + +TSIP_BEGIN_DECLS + +typedef struct tsip_transac_layer_s +{ + TSK_DECLARE_OBJECT; + + const struct tsip_stack_s *stack; + + tsip_transacs_L_t *transactions; + + TSK_DECLARE_SAFEOBJ; +} +tsip_transac_layer_t; + +typedef tsk_list_t tsip_transac_layers_L_t; +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transac_layer_def_t; + +tsip_transac_layer_t* tsip_transac_layer_create(tsip_stack_t* stack); + +tsip_transac_t* tsip_transac_layer_new(const tsip_transac_layer_t *self, tsk_bool_t isCT, const tsip_message_t* msg, tsip_transac_dst_t* dst); +int tsip_transac_layer_remove(tsip_transac_layer_t *self, const tsip_transac_t *transac); +int tsip_transac_layer_cancel_by_dialog(tsip_transac_layer_t *self, const struct tsip_dialog_s* dialog); + +tsip_transac_t* tsip_transac_layer_find_client(const tsip_transac_layer_t *self, const tsip_message_t* message); +tsip_transac_t* tsip_transac_layer_find_server(const tsip_transac_layer_t *self, const tsip_message_t* message); + +int tsip_transac_layer_handle_incoming_msg(const tsip_transac_layer_t *self, const tsip_message_t* message); + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_LAYER_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac_nict.h b/tinySIP/include/tinysip/transactions/tsip_transac_nict.h new file mode 100644 index 0000000..4052bd0 --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac_nict.h @@ -0,0 +1,61 @@ +/* +* 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_transac_nict.h + * @brief SIP Non-INVITE Client Transaction as per RFC 3261 subcaluse 17.1.2. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_TRANSAC_NICT_H +#define TINYSIP_TRANSAC_NICT_H + +#include "tinysip_config.h" + +#include "tinysip/transactions/tsip_transac.h" +#include "tinysip/tsip_message.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSAC_NICT(self) ((tsip_transac_nict_t*)(self)) + +typedef struct tsip_transac_nict +{ + TSIP_DECLARE_TRANSAC; + + tsip_request_t* request; + tsip_timer_t timerE; + tsip_timer_t timerF; + tsip_timer_t timerK; +} +tsip_transac_nict_t; + +tsip_transac_nict_t* tsip_transac_nict_create(int32_t cseq_value, const char* cseq_method, const char* callid, tsip_transac_dst_t* dst); +int tsip_transac_nict_start(tsip_transac_nict_t *self, const tsip_request_t* request); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transac_nict_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_NICT_H */ + diff --git a/tinySIP/include/tinysip/transactions/tsip_transac_nist.h b/tinySIP/include/tinysip/transactions/tsip_transac_nist.h new file mode 100644 index 0000000..f2234a1 --- /dev/null +++ b/tinySIP/include/tinysip/transactions/tsip_transac_nist.h @@ -0,0 +1,59 @@ +/* +* 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_transac_nist.h + * @brief SIP Non-INVITE Server Transaction as per RFC 3261 subclause 17.2.2. + * + * @author Mamadou Diop <diopmamadou(at)doubango[dot]org> + * + + */ +#ifndef TINYSIP_TRANSAC_NIST_H +#define TINYSIP_TRANSAC_NIST_H + +#include "tinysip_config.h" + +#include "tinysip/transactions/tsip_transac.h" +#include "tinysip/tsip_message.h" + +TSIP_BEGIN_DECLS + +#define TSIP_TRANSAC_NIST(self) ((tsip_transac_nist_t*)(self)) + +typedef struct tsip_transac_nist +{ + TSIP_DECLARE_TRANSAC; + + tsip_response_t* lastResponse; + tsip_timer_t timerJ; +} +tsip_transac_nist_t; + +tsip_transac_nist_t* tsip_transac_nist_create(int32_t cseq_value, const char* cseq_method, const char* callid, tsip_transac_dst_t* dst); +int tsip_transac_nist_start(tsip_transac_nist_t *self, const tsip_request_t* request); + +TINYSIP_GEXTERN const tsk_object_def_t *tsip_transac_nist_def_t; + +TSIP_END_DECLS + +#endif /* TINYSIP_TRANSAC_NIST_H */ + |