1.1 How to use osip
call osip_init to init the osip library
create transport layer to handle the outgoing and incoming messages.
1.2 osip internal
It implements transaction layer which is defined by RFC3261
osip structure
struct osip
{
/* list of transactions for ict, ist, nict, nist */
osip_list_t *osip_ict_transactions; /**< list of ict transactions */
osip_list_t *osip_ist_transactions; /**< list of ist transactions */
osip_list_t *osip_nict_transactions; /**< list of nict transactions */
osip_list_t *osip_nist_transactions; /**< list of nist transactions */
osip_list_t *ixt_retransmissions; /**< list of ixt elements */
osip_message_cb_t msg_callbacks[OSIP_MESSAGE_CALLBACK_COUNT];
osip_kill_transaction_cb_t kill_callbacks[OSIP_KILL_CALLBACK_COUNT];
osip_transport_error_cb_t
tp_error_callbacks[OSIP_TRANSPORT_ERROR_CALLBACK_COUNT];
int (*cb_send_message) (osip_transaction_t *, osip_message_t *, char *,
int, int);
};
Transaction type:
ICT, /**< Invite Client (outgoing) Transaction */
IST, /**< Invite Server (incoming) Transaction */
NICT,/**< Non-Invite Client (outgoing) Transaction */
NIST /**< Non-Invite Server (incoming) Transaction */
Events:
RCV_REQINVITE, /**< Event is an incoming INVITE request */
RCV_REQACK, /**< Event is an incoming ACK request */
RCV_REQUEST, /**< Event is an incoming NON-INVITE and NON-ACK request */
RCV_STATUS_1XX, /**< Event is an incoming informational response */
RCV_STATUS_2XX, /**< Event is an incoming 2XX response */
RCV_STATUS_3456XX,/**< Event is an incoming final response (not 2XX) */
/* FOR OUTGOING MESSAGE */
SND_REQINVITE, /**< Event is an outgoing INVITE request */
SND_REQACK, /**< Event is an outgoing ACK request */
SND_REQUEST, /**< Event is an outgoing NON-INVITE and NON-ACK request */
SND_STATUS_1XX, /**< Event is an outgoing informational response */
SND_STATUS_2XX, /**< Event is an outgoing 2XX response */
SND_STATUS_3456XX,/**< Event is an outgoing final response (not 2XX) */
KILL_TRANSACTION, /**< Event to 'kill' the transaction before termination */
/* other timer event not listed here*/
Callback:
There are four kinds of callbacks upper layer need to set for osip library:
osip_message_cb_t msg_callbacks[OSIP_MESSAGE_CALLBACK_COUNT];
Osip lib will call message callbacks to notify upper layer some information
osip_kill_transaction_cb_t kill_callbacks[OSIP_KILL_CALLBACK_COUNT];
Osip lib will call these callbacks when a transaction is finished.
osip_transport_error_cb_t tp_error_callbacks[OSIP_TRANSPORT_ERROR_CALLBACK_COUNT];
Osip lib will call these callbacks when the transport layer meet error.
int (*cb_send_message) (osip_transaction_t *, osip_message_t *, char *,
int, int);
Osip lib will call this callback to do the real transportation of the message.
eXosip set these callbacks in eXosip_set_callbacks.
osip_init
init 4 types of transaction state machine:
set transition_t list:
typedef struct _transition_t
{
state_t state;
type_t type;
void (*method) (void *, void *);
}
transition_t;
It set the process method for a type of event in a type of state
for example, in __ict_load_fsm ():
transition = (transition_t *) osip_malloc (sizeof (transition_t));
transition->state = ICT_PRE_CALLING;
transition->type = SND_REQINVITE;
transition->method = (void (*)(void *, void *)) &ict_snd_invite;
osip_list_add (ict_fsm->transitions, transition, -1);
How to process the SIP message
TU calls some functions to queue osip_event to the fifo of the transaction.
TU calls funtions, such as osip_ict_execute, which calls osip_transaction_execute to handle the osip_event in fifo:
osip_transaction_execute first find the type of event, and then get that type of fsm, and then call fsm_callmethod
fsm_callmethod will find the transition according to event type and transaction state, and the call transition->method
2 eXosip Overview
2.1 How to use eXosip lib
call eXosip and eXosip_listen_addr
poll the event periodly
2.2 eXosip lib internal:
It’s based on osip lib. It implements transport layer which is defined by RFC3261
The eXosip doesn’t wrapp the osip library. It just provides a transport layer for supporting message transfer.
eXosip_t structure
struct eXosip_t
{
struct eXosip_net net_interfaces[3];
osip_list_t *j_transactions;
osip_t *j_osip;
int j_stop_ua;
void *j_thread;
jpipe_t *j_socketctl; // to notify an request from upper layer is queued to fifo of transaction
jpipe_t *j_socketctl_event; //to notify event to upper layer
osip_fifo_t *j_events; //save event which will be sent to upper layer
};
eXosip_init:
init the struct eXosip
call osip_init to init the struct osip which is a member of eXosip(eXosip.j_osip
set osip lib callback: eXosip_set_callbacks (osip):
cb_snd_message is most important callback
create two pipe(eXosip.j_socketctl and eXosip.j_socketctl_event)
init fifo: osip_fifo_init(eXosip.j_events)
j_stop_ua is used to indicate whether thread should be stopped (used in _eXosip_thread)
eXosip_listen_addr:
listen on a port for SIP message
call _eXosip_thread
_eXosip_thread:
eXosip_read_message use select to wait for the message from upper layer or network
call osip_timers_ict_execute, osip_timers_nict_execute osip_timers_ist_execute and osip_timers_nist_execute to handle transaction timeout
call osip_ict_execute ,osip_nict_execute, osip_ist_execute and osip_nist_execute to handle the event in transaction FIFO
eXosip_process_newrequest is used to init UAS transaction
(eXosip_call_send_initial_invite is used to init UAC transaction)
for outgoing message:
build SIP message, put to the transaction fifo by calling OSIP API
then write something to pipe to notify _eXosip_thread to handle transaction
for incoming message:
_eXosip_thread is listening to the incoming socket, if there is a incoming message,
the _eXosip_thread will be waken up to create a new transaction, and handle transaction.
3 The process to send an outgoing message
eXosip_call_build_initial_invite
eXosip_call_send_initial_invite
eXosip_call_init
osip_transaction_init to init a ICT transaction
osip_new_outgoing_sipmessage to create a osip event
osip_transaction_add_event to add event to transaction FIFO
__eXosip_wakeup to wake up _eXosip_thread to handle the event
_eXosip_thread call osip_ict_execute, osip_ict_execute call osip_transaction_execute to find the type of event, get that type of fsm, and then call fsm_callmethod to handle the event. As the above description, fsm_callmethod will find the transition according to event type and transaction state, and the call transition->method. For ICT transaction in ICT_PRE_CALLING state, __ict_load_fsm set method to ict_snd_invite
ict_snd_invite will call osip-> cb_send_message, which is set by eXosip_set_callbacks as cb_snd_message
cb_snd_message will send the message to remote peer. _eXosip_thread will wait for remote response, and call osip_ict_execute to handle the response. The transaction state machine will be changed to different state according to the response. Meanwhile, the state machine will call callback set by eXosip_set_callbacks to notify eXosip state change. When eXosip receive the notification, eXosip will send eXosip-defined event to upper layer by queuing it to j_events. Upper layer applilcation which should call eXosip_event_wait to wait for events will get event, and handle it. Please refer to the example application UCT IMS Client.
4 The process to receive an incoming message
It is processed in _eXosip_thread:
receives the incoming message
eXosip_process_newrequest to create a new transaction, put to transaction FIFO
osip_ist_execute will handle the event
the following process is similar to osip_ict_execute described on the section 3.
分享到:
相关推荐
基于osip/exosip的SIP软件电话 是从csdn下了,原为VC6.0工程,里面缺少几个文件,经我修改并从网上下载了几个文件,现在是VS2005工程。 请有需要的同学下载一起研究。
工作需要收集到的sip+osip+exosip资料集合。内容如下 exoSip开发手册.pdf libeXosip2-3.3.0.tar.gz libosip2-3.3.0.tar.tar libosip reference manual.pdf oSIP开发者手册.doc oSIP协议栈(及eXoSIP,Ortp等)使用入门....
osip_exosip_框架,sip协议
osip和eXosip库运行在ARM上的交叉编译
osip和exosip的使用 osip.dll和osip.lib的编译
用于osip/exosip开发的必备工具手册
osip、eXosip、xml2、ortp协议栈源码,本人编译通过使用中,有用的希望评价 linux下的编译安装如有疑问可留言
包含有osip、exosip在vs2008环境下已经编译好的开发包,还有讲述osip、exoisp开发的文档及RFC文档,华为sip资料以及一个简单的demo程序。
根据网上的一些资源,自己写的一个文档,用最新的vs2010进行osip,exosip的编译,开发
vs2008编译的libosip2-3.6.0及libeXosip2-3.6.0, 可直接使用
第一次发资源,从gnu上面下载到的osip和exosip库代码
osip2 , exosip2 lib , VC6工程。直接配置好的workplace。。。 注意需要升级VC6的SDK,xp sp2
oSIP平台搭建,osipparser2的编译,osip2的编译,exosip2的编译,
很有用的资料,很难才收集到的。oSIP User Manual and ……
这是从osip官方网站上下载的源代码,对开发人员,很有帮助,和大家分享。还有,这些源代码可以用于windows和Linux操作系统
编译前,需要自己先搭建osip eXosip的库环境,去官网下载,就好了, Linux平台: 基于osip eXosip的服务器, 客户端源码, 可以编译通过,正常使用修改IP地址就可以了
其实这些开源的协议栈都是免费下载的,开发者都开源了,我并不想拿来赚取资源分,希望大家也能多多发布免费资源,毕竟我们只是一个下载使用者。觉得有用的希望评价,我会坚持发布免费资源~
osip2_&_exosip2协议源码
Osip2是一个开放源代码的sip协议栈,是开源代码中不多使用C语言写的协议栈之一,它具有短小简洁的特点,专注于sip底层解析使得它的...eXosip是Osip2的一个扩展协议集,它部分封装了Osip2协议栈,使得它更容易被使用。