现在的位置: 首页 > 综合 > 正文

oSIP协议栈浅析

2013年09月05日 ⁄ 综合 ⁄ 共 6090字 ⁄ 字号 评论关闭

全文下载连接(不保证永久有效):http://u.sohu.com/download?fileid=11702529523807282 

 

oSIP协议栈浅析
 
 
 


 
1. oSIP介绍
    oSIP是按照RFC3261(SIP)和RFC2327(SDP)标准,并使用标准c编写的一个SIP协议栈。它是一个公开源码的免费协议栈。oSIP协议栈结构简单而小巧,它并不提供高层的SIP会话控制的API,它主要提供一些解析SIP/SDP消息的API和事务处理的状态机。
oSIP支持线程安全,既可以用于多线程的编程模式,也可以用于单线程的编程模式;oSIP可以用来开发User Agent,IP soft-phone和SIP Proxy等等。
oSIP目前最后版本为V 0.9.7,不久oSIP版本将升级至oSIP2(V 1.99.7)。oSIP2主要调整了一些函数和结构名称,以及一些头文件的名称、内容结构的调整,整体的构架和功能不变。
本文以下描述都基于oSIP V0.9.6版本。
 
 
2. oSIP结构分析
2.1 oSIP结构
    oSIP主要包括三大部分的内容:状态机模块、解析器模块和工具模块。
    状态机模块的功能
完成对某个事务(注册过程,呼叫过程等等)状态记录,并在特定状态下触发相应的事件或回调函数。
    解析器模块的功能
       该模块主要完成对SIP消息结构剖析、SDP消息的结构剖析以及URI结构的剖析;
    工具模块的功能
       该模块提供一些SDP等处理的一些工具。
 
       oSIP的模块结构图如下(图2-1):


 

SIP parser

URL parser

SDP parser

Finite
State
Machines

Dialogue Facilities

SDP negotiation
Facilities

Application

状态机模块

解析器模块

工具模块(可选项)

oSIP模块

图2-1 oSIP结构

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


2.2 状态机(Finite State Machines)模块
2.2.1 概述
    oSIP状态机(Finite State Machines)主要分为四类,分别为:
Ø        ICT    -- Invite Client (outgoing) Transaction
Ø        NICT   -- Non-Invite Client (outgoing) Transaction
Ø        IST    -- Invite Server (incoming) Transaction
Ø        NIST   -- Non-Invite Server (incoming) Transaction
 


 
2.2.2 ICT状态机
 

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

表示从一种状态转换到另一种状态时将调用该回调函数

表示从一种状态转换到另一种状态时不调用任何回调函数

注:

      
 
 
 
 
cb_ict_Nxx_received:其中N表示一下几个值
       3            --     cb_ict_3xx_received
       4            --     cb_ict_4xx_received
       5            --     cb_ict_5xx_received
       6            --     cb_ict_6xx_received
 


 
2.2.3 NICT状态机
 

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

表示从一种状态转换到另一种状态时将调用该回调函数

表示从一种状态转换到另一种状态时不调用任何回调函数

注:

 
 
 
 
cb_nict_XXX_sent:其中XXX表示一下几种消息类型,
register  --     cb_nict_register_sent
bye         --     cb_nict_bye_sent
options  --     cb_nict_options_sent
info         --     cb_nict_info_sent
cancel    --     cb_nict_cancel_sent
notify      --     cb_nict_notify_sent
subscribe --     cb_nict_subscribe_sent
unknown --     cb_nict_unknown_sent
 
cb_nict_Nxx_received:其中N表示一下几个值
       2            --     cb_nict_2xx_received
       3            --     cb_nict_3xx_received
       4            --     cb_nict_4xx_received
       5            --     cb_nict_5xx_received
       6            --     cb_nict_6xx_received
 
 
2.2.4 IST状态机
 

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

表示从一种状态转换到另一种状态时将调用该回调函数

表示从一种状态转换到另一种状态时不调用任何回调函数

注:

 
 
 
 
cb_ist_Nxx_sent:其中N表示一下几个值,
3            --     cb_ist_3xx_sent
4            --     cb_ist_4xx_sent
5            --     cb_ist_5xx_sent
6            --     cb_ist_6xx_sent


 
2.2.5 NIST状态机

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

表示从一种状态转换到另一种状态时将调用该回调函数

表示从一种状态转换到另一种状态时不调用任何回调函数

注:

 
 
 
 
cb_nist_XXX_ received:其中XXX表示一下几种消息类型,
register  --     cb_nist_register_received
bye         --     cb_nist_bye_received
options  --     cb_nist_options_received
info         --     cb_nist_info_received
cancel    --     cb_nist_cancel_received
notify      --     cb_nist_notify_received
subscribe --     cb_nist_subscribe_received
unknown --     cb_nist_unknown_received
 
cb_nist_Nxx_ sent:其中N表示一下几个值
       2            --     cb_nist_2xx_sent
       3            --     cb_nist_3xx_sent
       4            --     cb_nist_4xx_sent
       5            --     cb_nist_5xx_sent
       6            --     cb_nist_6xx_sent
 
 
2.3 解析器(Parsers)模块
       oSIP的SIP Parser处理的SIP头域(SIP Header fields)及其相应的操作功能列表如下:

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()

抱歉!评论已关闭.