全文下载连接(不保证永久有效):http://u.sohu.com/download?fileid=11702529523807282
oSIP协议栈浅析 1. oSIP介绍... 1 2. oSIP结构分析... 1 2.1 oSIP结构... 1 2.2 状态机(Finite State Machines)模块... 2 2.2.1 概述... 2 2.2.2 ICT状态机... 3 2.2.3 NICT状态机... 4 2.2.4 IST状态机... 5 2.2.5 NIST状态机... 6 2.3 解析器(Parsers)模块... 7 2.3.1 SIP Parser7 2.3.2 SDP Parser9 2.3.3 URL Parser10 2.4 工具(Facilities)模块... 11 2.4.1 SDP negotiator11 2.4.2 Dialog management11 3. oSIP特点... 11 3.1 oSIP的优点... 11 3.2 oSIP的缺点... 12 4. oSIP应用结构图... 12 5. oSIP使用概述... 13 5.1 初始化oSIP. 13 5.2 注册CALL BACK函数... 13 5.3 Transaction操作... 15 6. 参考... 15
SIP parser |
URL parser |
SDP parser |
Finite State Machines |
Dialogue Facilities |
SDP negotiation Facilities |
Application |
状态机模块 |
解析器模块 |
工具模块(可选项) |
oSIP模块 |
图2-1 oSIP结构 |
ICT_PRE_CALLING |
ICT_COMPLETED |
ICT_PROCEEDING |
ICT_TERMINATED |
Transaction initialization |
ICT_CALLING |
cb_ict_transport_error |
cb_ict_invite_sent |
cb_ict_invite_sent2 |
cb_ict_transport_error |
图 2-2: ICT State Machine |
cb_ict_kill_transaction |
cb_ict_transport_error |
cb_ict_1xx_received |
cb_ict_2xx_received |
cb_ict_transport_error |
cb_ict_1xx_received |
cb_ict_Nxx_received |
cb_ict_Nxx_received |
cb_ict_3456xx_received2 cb_ict_ack_sent2 |
cb_ict_xxx_xxxx |
表示从一种状态转换到另一种状态时将调用该回调函数 |
表示从一种状态转换到另一种状态时不调用任何回调函数 |
NICT_PRE_TRYING |
NICT_COMPLETED |
NICT_PROCEEDING |
NICT_TERMINATED |
Transaction initialization |
NICT_TRYING |
cb_nict_transport_error |
cb_nict_XXX_sent |
cb_nict_request_sent2 |
cb_nict_1xx_received |
图2-3: NICT State Machine |
cb_nict_Nxx_received |
cb_nict_kill_transaction |
cb_nict_transport_error |
cb_nict_request_sent2 |
cb_nict_1xx_received |
cb_nict_Nxx_received |
cb_nict_transport_error |
cb_nict_xxx_xxxx |
表示从一种状态转换到另一种状态时将调用该回调函数 |
表示从一种状态转换到另一种状态时不调用任何回调函数 |
IST_PRE_PROCEEDING |
IST_CONFIRMED |
IST_COMPLETED |
IST_TERMINATED |
Transaction initialization |
IST_PROCEEDING |
cb_ist_invite_received |
cb_ist_Nxx_sent |
图2-4: IST State Machine |
cb_ist_ack_received |
cb_ist_1xx_sent |
cb_ist_transport_error |
cb_ist_2xx_sent |
cb_ist_ack_received2 |
cb_ist_3456xx_sent2 |
cb_ist_invite_received2 |
cb_ist_kill_transaction |
cb_ist_transport_error |
cb_ist_xxx_xxxx |
表示从一种状态转换到另一种状态时将调用该回调函数 |
表示从一种状态转换到另一种状态时不调用任何回调函数 |
NIST_PRE_TRYING |
NIST_COMPLETED |
NIST_PROCEEDING |
NIST_TERMINATED |
Transaction initialization |
NIST_TRYING |
cb_nist_XXX_ received |
cb_nist_1xx_sent |
图2-5: NIST State Machine |
cb_nist_Nxx_sent |
cb_nist_kill_transaction |
cb_nist_transport_error |
cb_nist_1xx_sent |
cb_nist_Nxx_sent |
cb_nist_transport_error |
cb_nist_request_received2 |
cb_nist_request_received2 |
cb_nist_xxx_xxxx |
表示从一种状态转换到另一种状态时将调用该回调函数 |
表示从一种状态转换到另一种状态时不调用任何回调函数 |
SIP Header(头域) | Functions(函数名称—简写) | |
Accept | set(),get() | ☆ |
Accept-Encoding | set(),get(),init(),parse(),2char(),free(),clone() Getelement(),setelement() | ☆ |
Accept-Language | set(),get() | ☆ |
Alert-Info | set(),get() | ☆ |
Allow | set(),get() | ☆ |
Authentication-Info | ||
Authorization | Init(),set(),parse(),get(),getauth_type(),setauth_type(), Getusername(),setusername(),getrealm(),setrealm(), Getnonce(),setnonce(),geturi(),seturi(),getresponse(), Setresponse(),getdigest(),setdigest(),getalgorithm(), Setalgorithm(),getcnonce(),setcnonce(),getopaque(), Setopaque(),getmessage_qop(),setmessage_qop(), getnonce_count(),setnonce_count(),2char(),free(), clone() | ☆ |
Call-ID | set(),get(),parse(),2char(),free(),clone(),getnumber(), setnumber(),gethost(),sethost() | ☆ |
Call-Info | set(),get(),init(),parse(),2char(),free(),clone(), geturi(),seturi() | ☆ |
Contact | set(),get(),init(),parse(),2char(),free(),clone() | ☆ |
Content-Disposition | set(),get(),parse() | ☆ |
Content-Encoding | set(),get() | ☆ |
Content-Language | ||
Content-Length | set(),get(),init(),parse(),2char(),free(),clone() | ☆ |
Content-Type | set(),get(),init(),parse(),2char(),free(),clone() | ☆ |
CSeq | set(),get(),init(),parse(),2char(),free(),clone(), getnumber(),setnumber(),getmethod(),setmethod() | ☆ |
Date | ||
Error-Info | set(),get() | ☆ |
Expires | ||
From | set(),get(),init(),parse(),2char(),free(),clone(), getdisplayname(),setdisplayname(),geturl(),seturl(), param_get(),param_parseall(),param_setvalue(), param_getvalue(),param_getname(),param_setname(), compare() | ☆ |
In-Reply-To | ||
Max-Forwards | ||
Min-Expires | ||
MIME-Version | set(),get() | ☆ |
Organization | ||
Priority | ||
Proxy-Authenticate | set(),get() | ☆ |
Proxy-Authorization | set(),get() | ☆ |
Proxy-Require | ||
Record-Route | set(),get(),init(),parse(),2char(),free() | ☆ |
Reply-To | ||
Require | ||
Retry-After | ||
Route | set(),get(),init(),parse(),2char(),free() | ☆ |
Server | ||
Subject | ||
Supported | ||
Timestamp | ||
To | set(),get(),init(),parse(),2char(),free(),clone() | ☆ |
Unsupported | ||
User-Agent | ||
Via | set(),append(),get(),init(),free(),parse(),2char(), setversion(),getversion(),setprotocol(),getprotocol(), sethost(),gethost(),setport(),getport(),setcomment(), getcomment(),clone() | ☆ |
Warning | ||
WWW-Authenticate | Init(),set(),quoted_string_set(),token_set(),parse(), get(),getauth_type(),setauth_type(),getrealm(),setrealm(), getdomain(),setdomain(),getnonce(),setnonce(),getstale(), setstale(),getopaque(),setopaque(),getalgorithm(), setalgorithm(),getqop_options(),setqop_options(),2char(), free(),clone() | ☆ |
type(类型) | Functions(函数名称—简写) |
v | version_set(),version_get() |
o | origin_set(),username_get(),sess_id_get(), sess_version_get(),nettype_get(),addrtype_get(), addr_get() |
s | name_set(),name_get() |
i | info_set(),info_get() |
u | uri_set(),uri_get() |
e | email_add(),email_get() |
p | phone_add(),phone_get() |
c | connection_add(),connection_get(),nettype_get(), addrtype_get(),addr_get(),addr_multicast_ttl_get(), addr_multicast_int_get() |
b | bandwidth_add(),bwtype_get(),bandwidth_get() |
t | time_descr_add(),start_time_get(),stop_time_get() |
r | repeat_add(),repeat_get() |
z | adjustments_set(),adjustments_get() |
k | key_set(),keytype_get(),keydata_get() |
a | attribute_add(),att_field_get(),att_value_get() |
m | media_add(),media_get(),port_get(),number_of_port_get(), proto_get(),payload_add(),payload_get(), |
Receive/Send SIP Messages |
SIP parser |
URL parser |
SDP parser |
Finite State Machines |
Dialogue Facilities |
SDP negotiation Facilities |
Main thread |
状态机模块 |
解析器模块 |
工具模块(可选项) |
oSIP模块 |
图4-1 oSIP应用 |
Receive/Send RTP/RTCP |
oSIP Instance |
Transaction Context |
① |
② |
③ |
⑥ |
④ |
⑤ |
⑦ |
B |
A |
Application |
osip_global_init
()
和
osip_init()
,具体
操作代码如下:
osip_t *osip; // initialise internal element first if (0!=osip_global_init()) return -1; // allocate a global osip element. if (0!=osip_init(&osip)) return -1; |
osip_setcb_send_message(osip, &application_cb_snd_message); |
osip_setcb_ict_kill_transaction(osip,&application_cb_ict_kill_transaction); osip_setcb_ist_kill_transaction(osip,&application_cb_ist_kill_transaction); osip_setcb_nict_kill_transaction(osip,&application_cb_nict_kill_transaction); osip_setcb_nist_kill_transaction(osip,&application_cb_nist_kill_transaction); |
osip_setcb_ict_transport_error(osip,&application_cb_transport_error); osip_setcb_ist_transport_error(osip,&application_cb_transport_error); osip_setcb_nict_transport_error(osip,&application_cb_transport_error); osip_setcb_nist_transport_error(osip,&application_cb_transport_error); |
osip_setcb_ict_2xx_received2(osip,&application_cb_rcvresp_retransmission); osip_setcb_ict_3456xx_received2(osip,&application_cb_rcvresp_retransmission); osip_setcb_ict_invite_sent2(osip,&application_cb_sndreq_retransmission); osip_setcb_ist_2xx_sent2(osip,&application_cb_sndresp_retransmission); osip_setcb_ist_3456xx_sent2(osip,&application_cb_sndresp_retransmission); osip_setcb_ist_invite_received2(osip,&application_cb_rcvreq_retransmission); osip_setcb_nict_2xx_received2(osip,&application_cb_rcvresp_retransmission); osip_setcb_nict_3456xx_received2(osip,&application_cb_rcvresp_retransmission); osip_setcb_nict_request_sent2(osip,&application_cb_sndreq_retransmission); osip_setcb_nist_2xx_sent2(osip,&application_cb_sndresp_retransmission); osip_setcb_nist_3456xx_sent2(osip,&application_cb_sndresp_retransmission); osip_setcb_nist_request_received2(osip,&application_cb_rcvreq_retransmission); osip_setcb_ict_invite_sent (osip,&application_cb_sndinvite); osip_setcb_ict_ack_sent (osip,&application_cb_sndack); osip_setcb_nict_register_sent(osip,&application_cb_sndregister); osip_setcb_nict_bye_sent (osip,&application_cb_sndbye); osip_setcb_nict_cancel_sent (osip,&application_cb_sndcancel); osip_setcb_nict_info_sent (osip,&application_cb_sndinfo); osip_setcb_nict_options_sent (osip,&application_cb_sndoptions); osip_setcb_nict_subscribe_sent (osip,&application_cb_sndoptions); osip_setcb_nict_notify_sent (osip,&application_cb_sndoptions); osip_setcb_nict_unknown_sent(osip,&application_cb_sndunkrequest); osip_setcb_ict_1xx_received(osip,&application_cb_rcv1xx); osip_setcb_ict_2xx_received(osip,&application_cb_rcv2xx); osip_setcb_ict_3xx_received(osip,&application_cb_rcv3xx); osip_setcb_ict_4xx_received(osip,&application_cb_rcv4xx); osip_setcb_ict_5xx_received(osip,&application_cb_rcv5xx); osip_setcb_ict_6xx_received(osip,&application_cb_rcv6xx); osip_setcb_ist_1xx_sent(osip,&application_cb_snd1xx); osip_setcb_ist_2xx_sent(osip,&application_cb_snd2xx); osip_setcb_ist_3xx_sent(osip,&application_cb_snd3xx); osip_setcb_ist_4xx_sent(osip,&application_cb_snd4xx); osip_setcb_ist_5xx_sent(osip,&application_cb_snd5xx); |
osip_setcb_ist_6xx_sent(osip,&application_cb_snd6xx); osip_setcb_nict_1xx_received(osip,&application_cb_rcv1xx); osip_setcb_nict_2xx_received(osip,&application_cb_rcv2xx); osip_setcb_nict_3xx_received(osip,&application_cb_rcv3xx); osip_setcb_nict_4xx_received(osip,&application_cb_rcv4xx); osip_setcb_nict_5xx_received(osip,&application_cb_rcv5xx); osip_setcb_nict_6xx_received(osip,&application_cb_rcv6xx); osip_setcb_nist_1xx_sent(osip,&application_cb_snd1xx); osip_setcb_nist_2xx_sent(osip,&application_cb_snd2xx); osip_setcb_nist_3xx_sent(osip,&application_cb_snd3xx); osip_setcb_nist_4xx_sent(osip,&application_cb_snd4xx); osip_setcb_nist_5xx_sent(osip,&application_cb_snd5xx); osip_setcb_nist_6xx_sent(osip,&application_cb_snd6xx); osip_setcb_ist_invite_received (osip,&application_cb_rcvinvite); osip_setcb_ist_ack_received (osip,&application_cb_rcvack); osip_setcb_ist_ack_received2 (osip,&application_cb_rcvack2); osip_setcb_nist_register_received(osip,&application_cb_rcvregister); osip_setcb_nist_bye_received (osip,&application_cb_rcvbye); osip_setcb_nist_cancel_received (osip,&application_cb_rcvcancel); osip_setcb_nist_info_received (osip,&application_cb_rcvinfo); osip_setcb_nist_options_received (osip,&application_cb_rcvoptions); osip_setcb_nist_subscribe_received(osip,&application_cb_rcvoptions); osip_setcb_nist_notify_received (osip,&application_cb_rcvoptions); osip_setcb_nist_unknown_received (osip,&application_cb_rcvunkrequest); |