Transcript
  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    1/66

    V1.0.0 (2010-04)

    doubango Programers Guide

    1

    ubang 3GPP IMS/!" #rame$or% &1.0.0

    Programmers GuideProgrammers Guide

    by

    Mamadou Diopdiopmamadou {AT} doubango.org

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    2/66

    V1.0.0 (2010-04)

    License

    doubango3GPP IMS/!" #rame$or% &ersion 1.0

    'orig*+ , 200-2010 Mamadou io diomamadou ! doubango.org

    doubango is a ree so+$are5 ou 6an redis+ribu+e i+ and/or modi i+ under +*e +erms o +*e G78

    Genera9 Pub9i6 i6ense as ub9is*ed b +*e #ree So+$are #ounda+ion: ei+*er &ersion 3 o +*e

    i6ense: or (a+ our o+ion) an 9a+er &ersion.

    doubango is dis+ribu+ed in +*e *oe +*a+ i+ $i99 be useu9: bu+ ;I! ;??7!>@

    $i+*ou+ e&en +*e im9ied $arran+ o M"?' or #I!7"SS #=? P?!I'8?

    P8?P=S". See +*e G78 Genera9 Pub9i6 i6ense or more de+ai9s.

    >ou s*ou9d *a&e re6ei&ed a 6o o +*e GNU General Public Licencea9ong $i+* doubango. I no+:

    see *++5//$$$.gnu.org/9i6enses/.

    doubango Programers Guide

    2

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    3/66

    V1.0.0 (2010-04)

    Table of Contents

    1 #ore$ord ............................................................................................................................................B

    2 S6oe ................................................................................................................................................. C

    3 eini+ions and abbre&ia+ions ............................................................................................................ C

    3.1 eini+ions ................................................................................................................................. C

    3.2 bbre&ia+ions ............................................................................................................................. C

    4 Genera9 in+rodu6+ion ..........................................................................................................................

    4.1 r6*i+e6+ure ................................................................................................................................

    4.2 I7 .........................................................................................................................................

    4.3 ProDe6+s .......................................................................................................................................

    4.3.1 +inSE ...............................................................................................................................

    4.3.2 +inSig'om ........................................................................................................................

    4.3.3 +inSMS ...............................................................................................................................

    4.3.4 +in7"! ...............................................................................................................................

    4.3.F +inIPSe6 ..............................................................................................................................

    4.3. +in

    .1 =bDe6+ eini+ion ..................................................................................................................... 12

    .2 'ons+ru6+or ...............................................................................................................................13

    .3 es+ru6+or .................................................................................................................................13.4 'omara+or .............................................................................................................................. 13

    .F ?eeren6e 6oun+ing .................................................................................................................. 13

    . In*eri+en6e ............................................................................................................................... 14

    .B 8sage ....................................................................................................................................... 14

    .C is+s ..........................................................................................................................................14

    B !*reading ......................................................................................................................................... 1F

    B.1 !*reads .....................................................................................................................................1F

    B.2 Mu+ees ....................................................................................................................................1F

    B.3 !*read-Sae =bDe6+s ................................................................................................................ 1F

    B.4 Sema*ores .............................................................................................................................. 1F

    B.F 'ondi+ion Variab9es ..................................................................................................................1B. ?unnab9e .................................................................................................................................. 1

    C #ina9 Sa+e Ma6*ine .......................................................................................................................... 1B

    !imer Manager ................................................................................................................................ 1C

    10 So6%e+s and 7e+$or% #un6+ions .................................................................................................... 1

    10.1 So6%e+s ................................................................................................................................... 1

    10.2 !ansor+ ..................................................................................................................................1

    11 7S ............................................................................................................................................... 1

    11.1 ?esour6e ?e6ords ...................................................................................................................20

    11.2 "78M .................................................................................................................................... 21

    11.2.1 8sage ............................................................................................................................... 21

    12

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    4/66

    V1.0.0 (2010-04)

    14.1 S!872 ................................................................................................................................... 22

    14.2 !8?7 .....................................................................................................................................22

    14.3 I'" ......................................................................................................................................... 22

    1F

    1F.1 Ini+ia9iJa+ion ........................................................................................................................... 22

    1F.2 Sessions ..................................................................................................................................23

    1F.2.1 'reden+ia9s ....................................................................................................................... 231F.2.2 =+ions ............................................................................................................................ 23

    1F.2.3

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    5/66

    V1.0.0 (2010-04)

    22.1.3 IMS Pub9i6 Iden+i+ (IMP8) ............................................................................................ 4

    22.1.4 Preerred Iden+i+ ............................................................................................................. 4

    22.1.F 'rea+ing +*e s+a6% ............................................................................................................ 4B

    22.1. S+ar+ing +*e s+a6% ............................................................................................................. 4C

    22.1.B 'a99ba6% un6+ion .............................................................................................................4C

    22.1.C Se++ing +*e Pro-'S'# .................................................................................................. 4C

    22.1. Se++ing +*e 9o6a9 IP and Por+ ............................................................................................ 4C22.1.10

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    6/66

    V1.0.0 (2010-04)

    22.1.3 =rigina+ing Iden+ii6a+ion ?es+ri6+ion ............................................................................FF

    22.1.4 !ermina+ing Iden+ii6a+ion ?es+ri6+ion ...........................................................................FF

    22.1.F 'ommuni6a+ion i&ersion 8n6ondi+iona9 .....................................................................FF

    22.1. 'ommuni6a+ion i&ersion on no+ ogged in 3GPP !S 24.04 .................................... FF

    22.1.B 'ommuni6a+ion i&ersion on Aus .............................................................................. FF

    22.1.C 'ommuni6a+ion i&ersion on no+ ?ea6*ab9e ................................................................ FF

    22.1. 'ommuni6a+ion i&ersion on 7o ?e9 ....................................................................... FF22.1.10 Aarring o 99 In6oming 'a99s ..................................................................................... FF

    22.1.11 Aarring o 99 =u+going 'a99s ......................................................................................FF

    22.1.12 Aarring o =u+going In+erna+iona9 'a99s ...................................................................... FF

    22.1.13 Aarring o In6oming 'a99s - ;*en ?oaming ...............................................................FF

    22.1.14 'ommuni6a+ion

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    7/66

    V1.0.0 (2010-04)

    11 ForewordForeword

    3GPP IMS (IP Mu9+imedia Subss+em) is +*e ne+ genera+ion ne+$or% or de9i&ering IP mu9+imedia

    ser&i6es. IMS is s+andardiJed b +*e 3 rdGenera+ion Par+ners*i ProDe6+ (3GPP). IMS ser&i6es 6ou9d

    be used o&er an +e o ne+$or%: su6* as 3GPP !": GP?S: ;ire9ess 7: 'M2000 or ied

    9ine.

    doubango is an eerimen+a9: oen sour6e 3GPP IMS/!" rame$or% or bo+* embedded and

    des%+o ss+ems. !*e rame$or% is $ri++en in 7SI-' +o ease or+abi9i+ and *as been 6areu99

    designed +o ei6ien+9 $or% on embedded ss+ems $i+* 9imi+ed memor and 9o$ 6omu+ing o$er

    and +o be e+reme9 or+ab9e.

    doubango is a se+ o sma99 PIs u++ed +oge+*er +o orm a o$eru9 3GPP IMS/!" rame$or%.

    !*ese s+a6%s im9emen+ man ro+o6o9s su6* as SIP/SP:

    Sig'om: MS?P: H'P: 7! !ra&ersa9 (S!87: !8?7 and I'") O

    doubango Programmers Guide

    B

    http://en.wikipedia.org/wiki/3GPP_Long_Term_Evolutionhttp://en.wikipedia.org/wiki/3GPP_Long_Term_Evolution
  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    8/66

    V1.0.0 (2010-04)

    22 ScopeScope

    !*is user guide is a reeren6e do6umen+ e9aining *o$ +o de&e9o IMS a9i6a+ions using

    doubango.

    33 Definitions and abbreviationsDefinitions and abbreviations3.1 Definitions

    ;e99-%no$n ' obDe6+

    SIP session is an O

    SIP a6+ion is an O and erormed on a SIP session

    Media Session is an O (udio: Video: MS?P O)

    3.2 Abbreviations

    3GPP

    !"

    IMS

    I7

    SM

    S'

    SM-?

    SM-!

    ?P8

    !P8

    P8

    doubango Programmers Guide

    C

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    9/66

    V1.0.0 (2010-04)

    44 General introductionGeneral introduction

    4.1 Architecture

    4.2 A!A

    doubango *as been assigned ri&a+e en+errise number (P"7) 35368b I7. !*e 6om9e+e 9is+ isa&ai9ab9e a+ *++5//$$$.iana.org/assignmen+s/en+errise-numbers. 99 ne+$or% ro+o6o9s (e.g.

    ou M8S! 6a99 tnet_startup()tnet_startup() beore using an ne+$or% un6+ion reied $i+* tnet_.tnet_.

    tnet_cleanuptnet_cleanupis used +o +ermina+e use o ne+$or% un6+ions.

    Prei5 tnettnet

    PI reeren6e5 *++5//doubango.org/PI/+in7"!/

    4.3.5 tinyIPSec

    Prei5 tipsectipsec

    PI reeren6e5 *++5//doubango.org/PI/+inIPSe6/

    4.3.6 tinyHTTP

    Prei5 thttpthttp

    PI reeren6e5 *++5//doubango.org/PI/+in

    4.3.7 tinyXCAP

    Prei5 txcaptxcap

    PI reeren6e5 *++5//doubango.org/PI/+inH'P/

    4.3.8 tinyMEIA

    Prei5 tmediatmedia

    PI reeren6e5 *++5//doubango.org/PI/+inM"I/

    4.3.! tinySP

    Prei5 tsdptsdp

    doubango Programmers Guide

    http://www.iana.org/assignments/enterprise-numbershttp://doubango.org/API/tinySAKhttp://doubango.org/API/tinySigComp/http://doubango.org/API/tinySMS/%0Dhttp://doubango.org/API/tinyNET/http://doubango.org/API/tinyIPSec/http://doubango.org/API/tinyHTTP/http://doubango.org/API/tinyXCAP/http://doubango.org/API/tinyMEDIA/http://www.iana.org/assignments/enterprise-numbershttp://doubango.org/API/tinySAKhttp://doubango.org/API/tinySigComp/http://doubango.org/API/tinySMS/%0Dhttp://doubango.org/API/tinyNET/http://doubango.org/API/tinyIPSec/http://doubango.org/API/tinyHTTP/http://doubango.org/API/tinyXCAP/http://doubango.org/API/tinyMEDIA/
  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    10/66

    V1.0.0 (2010-04)

    PI reeren6e5 *++5//doubango.org/PI/+inSP/

    4.3.1" tinyMS#P

    Prei5 tmsrptmsrp

    PI reeren6e5 *++5//doubango.org/PI/+inMS?P/

    4.3.11 tiny$STPrei5 tgsttgst

    PI reeren6e5 *++5//doubango.org/PI/+inGS!/

    4.3.12 tinySIP

    Prei5 tsiptsip

    PI reeren6e5 *++5//doubango.org/PI/+inSIP/

    doubango Programmers Guide

    10

    http://doubango.org/API/tinySDP/http://doubango.org/API/tinyMSRP/http://doubango.org/API/tinyGST/http://doubango.org/API/tinySIP/http://doubango.org/API/tinySDP/http://doubango.org/API/tinyMSRP/http://doubango.org/API/tinyGST/http://doubango.org/API/tinySIP/
  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    11/66

    V1.0.0 (2010-04)

    $$ Debu%%in%Debu%%in%

    !*e rame$or% oers 4 debugging 9e&e9s. !*e minimum 9e&e9 is deined b se++ing +*e &a9ue o

    DEB!_"E#E"DEB!_"E#E"ma6ro. e&e9 &a9ues are5

    DEB!_"E#E"_IN$%DEB!_"E#E"_IN$%5 I+s +*e minimum &a9ue. 8sed +o 9og user inorma+ion: a9i6a+ion

    rogress: 6onigura+ion O

    DEB!_"E#E"_&A'NDEB!_"E#E"_&A'N5 Signa9 +*a+ some+*ing +*a+ 6ou9d 6*ange +*e norma9 ro6ess *aened.

    !*is +e o error s*ou9d no+ b9o6% +*e a9i6a+ion.

    DEB!_"E#E"_E''%'DEB!_"E#E"_E''%'5 I+s +*e deau9+ minimum &a9ue. Signa9s +*a+ +*e 6urren+ oera+ion *as

    ai9ed. I +*e oera+ion $as 6ri+i6a9 (e.g. +*read 6rea+ion) +*en +*is $i99 bad9 6*ange +*e

    a9i6a+ion be*a&ior: o+*er$ise (e.g. sending da+a o&er ne+$or%) +*e a9i6a+ion $i99

    6on+inue +o be*a&e as ee6+ed.

    DEB!_"E#E"_$ATA"DEB!_"E#E"_$ATA"5 I+s +*e maimum &a9ue. !*is %ind o errors is signa9ed Dus+ beore +*e

    a9i6a+ion 6ras*es or en+ers in a s+a+e rom $*i6* i+s imossib9e +o re6o&er rom.

    99 +*ese ma6ros $i99 rin+ +*e message +o stderrstderr. In our re9ease rogram: ou s*ou9d deineT_*A#E_DEB!_* (+de,ine T_*A#E_DEB!_* -+de,ine T_*A#E_DEB!_* -) &ariab9e in order +o su9 our o$n debugging

    ma6ros (or un6+ions). >our ma6ros (or un6+ions) s*ou9d be deined in a i9e named m_de/ug.hm_de/ug.h.

    !*is is +i6a99 used in 6onDun6+ion $i+* 6us+om 9oggers (e.g. 9og4D: 9og4ne+: 9ogi9eO).

    doubango Programmers Guide

    11

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    12/66

    V1.0.0 (2010-04)

    && A!S'C (b#ect "ro%ra))in%A!S'C (b#ect "ro%ra))in%

    s ou robab9 %no$: ' is no+ an obDe6+ orien+ed 9anguage.

    !oda: ==P (=bDe6+-=rien+ed Programing) is +*e bes+ $a +o rogram $e99 designed so+$ares.

    In +*is do6umen+ a $e99-deined obDe6+Q is a se6ia9 ' s+ru6+ure. 99 un6+ions s*o$n in +*is 6*a+er

    are ar+ o +inSEroDe6+.

    !o e9ain *o$ $e99-deined obDe6+s are im9emen+ed and used: I $i99 gi&e an eam9e based on

    PersonQ obDe6+.

    !*e erson obDe6+ is de69ared 9i%e +*is5

    tpede,structperson_s0

    T_DE1"A'E_%B2E1T3 45 6andator 54

    char5 name3structperson_s5 girl,riend3

    7person_t3

    &.1 (b#ect Definition

    n obDe6+ deini+ion 6ou9d be 6onsidered as a 69ass deini+ion. !*e deini+ion *o9ds +*e obDe6+s

    manda+or un6+ions: siJe and a reeren6e 6oun+er.

    !*e manda+or un6+ions are +*e constructorconstructor: +*e destructordestructor and +*e comparator.comparator.

    ' s+ru6+ure is Rde,inede,ined as an obDe6+ b using T_DE1"A'E_%B2E1TT_DE1"A'E_%B2E1Tma6ro in i+s bod.

    oin+er +o an obDe6+ deini+ion s*a99 oin+ +o astruct tsk_o/8ect_de,_sstruct tsk_o/8ect_de,_s.

    tpede,structtsk_o/8ect_de,_s0

    449 The si:e o, the o/8ect.si:e_t si:e3449 Pointer to the constructor.tsk_o/8ect_t5 (5 constructor) (tsk_o/8ect_t 5;

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    13/66

    V1.0.0 (2010-04)

    person_cmp73

    &.2 Constructor

    !*e constructor is on9 resonsib9e or +*e ini+ia9iJa+ion and $on+ a99o6a+e +*e obDe6+. ;*en

    assed +o +*e 6ons+ru6+or: +*e obDe6+ is a9read a99o6a+ed.

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    14/66

    V1.0.0 (2010-04)

    de6remen+ed (b 1) $*en ou 6a99tsk_o/8ect_unre,tsk_o/8ect_unre,.

    ;*en +*e 6oun+er &a9ue rea6*es Jero: +*en +*e obDe6+ is garbaged (reed).

    &.& nheritence

    s ou ee6+: in*eri+an6e is no+ suor+ed in 7SI-'.

    s an ' S+ru6+ure 6ou9d be 6as+ed +o a oin+er +o i+s irs+ e9emen+: in*eri+an6e 6ou9d be a6*ie&ed9i%e +*is5

    +includetsk.h

    44 (a student is a person)tpede,structstudent_s0

    structperson_s5 person3 44 6ust /e the ,irst elementchar5 school3

    7student_t3

    44 (as a student is a person ou can do)student_t5 s3((person_t5)s)@name ? tsk_strdup(/o/)3

    s person_tperson_tis a $e99-deined obDe6+: +*en student_tstudent_tis a9so $e99-deined.

    &.+ ,sa%e

    =n6e +*e obDe6+s deini+ion is de69ared and a99 i+s manda+or un6+ions im9emen+ed: i+ is used 9i%e

    +*is5

    44 creates a person =ill call the constructorperson_t5 /o/ ? tsk_o/8ect_ne=(Fperson_de,_t; /o/)344 creates /o/Gs girl,riend/o/@girl,riend ? tsk_o/8ect_ne=(Fperson_de,_t; alice)344 deletes /o/ =ill delete /oth /o/ and /o/Gs girl,riend ,ield / calling their destructorstsk_o/8ect_unre,(/o/)3

    s i+s *ard +o gues+ $*i6* arame+ers +*e 6ons+ru6+ ee6+s: i+s 6ommon +o use ma6ro (or un6+ion)*e9ers. In our eam9e +*e ma6ro $i99 9oo% 9i%e +*is5

    44 create a person+de,inePE'%N_1'EATE(name) tsk_o/8ect_ne=(Fperson_de,_t; (constchar5)name)

    s +*e des+ru6+or *as ied arame+ers: +*ere is a 6ommon ma6ro +o des+ro a99 %ind o $e99-deined

    obDe6+s. T_%B2E1T_A$E_$'EE()T_%B2E1T_A$E_$'EE() is used +o des+ro an obDe6+. !*e obDe6+ $i99 be reed on9 i@

    $*en de6remen+ed b 1 +*e reeren6e 6oun+ o +*e obDe6+ is eKua9 +o Jero. In a99 6ase (reed or no+)

    +*e oin+er &a9ue $i99 be se+ +o N""N"".

    !*e abo&e eam9e 6an be re$ri++en 9i%e +*is5

    +includetsk.h

    44 create a person =ill call the constructorperson_t5 /o/ ? PE'%N_1'EATE(/o/)344 create /o/Gs girl,riend/o/@girl,riend ? PE'%N_1'EATE(alice)344 delete /o/ =ill delete /oth /o/ and /o/Gs girl,riend ,ield / calling their destructorsT_%B2E1T_A$E_$'EE(/o/)3

    &.- ists

    doubango Programmers Guide

    14

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    15/66

    V1.0.0 (2010-04)

    ++ Threadin%Threadin%

    !*e rame$or% ro&ides an oera+ing ss+em agnos+i6 +*reading un6+ions or bo+* ;I732 and

    8ni-9i%e ss+ems.

    +.1 Threads

    >ou don+ need +*ousands o un6+ions +o manage +*reads. In +*e #rame$or% $e on9 need +o 6rea+e:

    ause and des+ro +*reads.

    !*reads 6an be 6rea+ed using tsk_thread_create()tsk_thread_create()and Doined usingtsk_thread_8oin()tsk_thread_8oin().

    >ou 6an +emorar 6ease +*e ee6u+ing o a +*read b 6a99ingtsk_thread_sleep()tsk_thread_sleep().

    +includetsk.h

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    16/66

    V1.0.0 (2010-04)

    'oun+ing sema*ores are used +o 6on+ro9 +*e a66ess +o a or+ion o 6ode $*i6* mig*+ be ee6u+ed

    b mu9+i9e +*reads. +*read $i99 *a&e rig*+s +o ee6u+e +*e or+ion o 6ode on9 i +*e sema*ores

    in+erna9 6oun+er &a9ue is dieren+ +*an Jero. Aeore ee6u+ing +*e 6ode +o 6on+ro9: a +*read s*ou9d

    de6remen+ +*e 6oun+er +o 6*e6% i i+ *as ermi+.

    +includetsk.h

    44 (create the semaphore)tsk_semaphore_handle_t 5sem ? tsk_semaphore_create()344 (increment the counter)tsk_semaphore_increment(sem)344 (decrement the counter)tsk_semaphore_decrement(sem)344 (desto the semaphore)tsk_semaphore_destro(Fsem)3

    Sema*ores are no+ $e99-deined obDe6+s@ ou s*ou9d use tsk_semaphore_destrotsk_semaphore_destro ins+ead o

    T_%B2E1T_A$E_$'EE()T_%B2E1T_A$E_$'EE()+o des+ro +*em.

    Mu+ees are binar sema*ores (6oun+er &a9ue is a9$as eKua9s +o 1 or 0).

    +.$ Condition ariables

    'ondi+ion &ariab9es are used +o 6on+ro9 +*e a66ess +o a or+ion o 6ode $*i6* mig*+ be ee6u+ed b

    mu9+i9e +*reads. "a6* +*read $i99 b9o6% un+i9 a 6er+ain 6ondi+ion is signa9ed or msmsmi99ise6onds *a&e

    assed.

    tsk_cond=ait_create()tsk_cond=ait_create() is used +o 6rea+e a 6ondi+ion &ariab9e: tsk_cond=ait_=ait()tsk_cond=ait_=ait() +o $ai+

    indeini+e9un+i9 +*e 6ondi+ion is signa9edandtsk_cond=ait_timed=ait(condition; ms)tsk_cond=ait_timed=ait(condition; ms) +o $ai+

    un+i9 +*e 6ondi+ion is signa9ed or msmsmi99ise6onds *a&e assed.

    tsk_cond=ait_signal(condition)tsk_cond=ait_signal(condition)is used +o a9er+ +*e irs+ $ai+ing +*read +*a+ +*e 6ondi+ion is no$

    +rue and tsk_cond=ait_/roadcast(cond=ait)tsk_cond=ait_/roadcast(cond=ait)is used +o a9er+ a99 $ai+ing +*reads.

    'ondi+ion &ariab9es are no+ $e99-deined obDe6+s@ ou s*ou9d use tsk_cond=ait_destro()tsk_cond=ait_destro()ins+ead o

    T_%B2E1T_A$E_$'EE()T_%B2E1T_A$E_$'EE()+o des+ro +*em.

    +.& *unnable

    runna/lerunna/leobDe6+ is a $e99-deined obDe6+ and is de69ared using T_DE1"A'E_'NNAB"ET_DE1"A'E_'NNAB"Ema6ro.

    runna/lerunna/leobDe6+ mus+ be e9i6i+9 s+ar+ed using tsk_runna/le_start()tsk_runna/le_start()and is im9i6i+9 s+oed

    $*en des+roed.. >ou 6an e9i6i+9 s+o +*e obDe6+ b 6a99ingtsk_runna/le_stop()tsk_runna/le_stop().

    doubango Programmers Guide

    1

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    17/66

    V1.0.0 (2010-04)

    -- Final Sate /achineFinal Sate /achine

    doubango Programmers Guide

    1B

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    18/66

    V1.0.0 (2010-04)

    Ti)er /ana%erTi)er /ana%er

    doubango Programmers Guide

    1C

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    19/66

    V1.0.0 (2010-04)

    11 Socets and !etwor FunctionsSocets and !etwor Functions

    99 ne+$or% un6+ions are ar+ o +in7"!roDe6+s.

    >ou M8S! 6a99 tnet_startup()tnet_startup()beore using an ne+$or% un6+ion (tnet_5tnet_5).. tnet_cleanup()tnet_cleanup() is

    used +o +ermina+e use o ne+$or% un6+ions. !*e s+ar+u un6+ion $i99 de+ermine $*e+*er +*e *os+ is

    a 9i++9e-endianQ ma6*ine or no+ (a+ run+ime). !o *a&e a66ess +o a99 ne+$or%ing un6+ions: ou s*ou9dRin69ude Ktinnet.hLi9e in our roDe6+.

    1.1 Socets

    #or erorman6e reason: a99 so6%e+s 6rea+ed using +in7"!are non-b9o6%ing b deau9+. !*e ne$9

    6rea+ed so6%e+ $i99 be au+oma+i6a99 bound +o asso6ia+e i+ $i+* an IP address and or+ number.

    tnet_socket_create()tnet_socket_create() ma6ro is used +o 6rea+e and bind a non-b9o6%ing so6%e+. 8se

    tnet_socket_create_>()tnet_socket_create_>()ma6ro +o 6on+ro9 $*e+*er +*e so6%e+ s*ou9d be bound or no+. !*e same

    ma6ro is used +o or6e +*e s+a6% +o 6rea+e a b9o6%ing so6%e+.

    so6%e+ obDe6+ is deined 9i%e +*is5

    tpede,structtnet_socket_s0

    T_DE1"A'E_%B2E1T3

    tnet_socket_tpe_t tpe3tnet_,d_t ,d3tnet_ip_t ip3uint-M_t port3

    tnet_tls_socket_handle_t5 tlshandle37tnet_socket_t3

    !o 6rea+e a so6%e+5

    44 (create udp ip

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    20/66

    V1.0.0 (2010-04)

    IP&4 and IP&) and arse resonses. !*e 6ore rame$or% im9emen+s ?#' 3401: 3402: 3403 and

    3404: a9so %no$n as nami6 e9ega+ion is6o&er Ss+em (S).

    !*e 7S ser&ers are au+oma+i6a99 9oaded b +*e s+a6% $*en ou 6rea+e a 6on+e+

    (tnet_dns_ctx_create()tnet_dns_ctx_create())..=n ;indo$s ss+ems (HP: VIS!: B and '") +*e ser&ers are re+rie&ed

    using ;I732 PIs. =n 8ni-9i%e ss+ems (bo+* des%+o and embedded) su6* as ebian: 8bun+u:

    7o%ias 700O +*e 9is+ o 7S ser&ers 6omes rom 4etc4resolou 6an

    a66ess +*is s*ared memor b using propert_get()propert_get()and propert_set()propert_set()un6+ion $*i6* are ar+ o

    Aioni6. In a99 6ases: ou 6an re+rie&e +*e 7S ser&ers ourse9 (e.g. using Da&a/'R #rame$or%s) and

    add +*em +o +*e 6on+e+ using tnet_dns_add_ser

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    21/66

    V1.0.0 (2010-04)

    naptr@replacement)37

    77else0

    T_DEB!_E''%'(&e got an error response ,rom the DN ser(ctx; E>QIP; Q-@RCC@SSS@SSSS;e-M.org)))0T_DEB!_IN$%('I?Hs; uri)3T_$'EE(uri)3

    7else0

    T_DEB!_E''%'(EN6(Hs) ,ailed; Q-@RCC@SSS@SSSS)3

    7

    T_%B2E1T_A$E_$'EE(response)3T_%B2E1T_A$E_$'EE(ctx)3

    'onso9e =u+u+5

    5IN$% 'I?sip-M-M-RCCC@[email protected],reegate=a.com

    E>QIPE>QIPis +*e name o SIP "78M ser&i6e assigned b +*e I7. n assigned ser&i6e () 6ou9d be

    used e&en i +*e asso6ia+ed addresse +e isn+ a $e99-%non$ in+erne+ address.

    !o ge+ a99 in+erne+ addresses (emai9: IH2: I': ().tnet_dns_enum_>().

    doubango Programmers Guide

    21

    http://www.doubango.org/API/tinyNET/group__tnet__dns__group.html#ga0c2c6cdb03f205b6ce16af9398d91730http://www.doubango.org/API/tinyNET/group__tnet__dns__group.html#ga0c2c6cdb03f205b6ce16af9398d91730
  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    22/66

    V1.0.0 (2010-04)

    1212 D6C"v4D6C"v4

    1313 D6C"v&D6C"v&

    1414 !AT Traversal!AT Traversal

    14.1 ST,!2

    14.2 T,*!

    14.3 C5

    1$1$ 6TT"76TT"S6TT"76TT"S!*e

    *and9ed b +*e s+a6%. ?eKues+s $i99 be assed +o +*e a9i6a+ion 9aer as isQ and no ne$ 6onne6+ion

    $i99 be oened.

    Ao+* IP&4 and IP& are suor+ed. I +*e *os+ name (#7) reso9u+ion 9eads +o bo+* IP&4 and IP&

    resu9+s: +*en IP&4 $i99 be used b deau9+.

    ;*en

    mu+ua9 au+*en+i6a+ion +*e !S/SS 6er+ii6a+e i9es M8S! be se+s b usingT*TTP_TA1_ET_T"_1E'T(1A_$I"E_T'; PB_$I"E_T'; P'I#_$I"E_T').T*TTP_TA1_ET_T"_1E'T(1A_$I"E_T'; PB_$I"E_T'; P'I#_$I"E_T').

    1$.1 nitiali8ation

    s +*e

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    23/66

    V1.0.0 (2010-04)

    returnC37

    thttp_stack_handle_t5 stack ? thttp_stack_create(test_stack_call/ack;44 T" certi,icates (not mandator) to sho= ho= parameters are passed to the stackT*TTP_TA1_ET_T"_1E'T([email protected]; 1UUtlsUUpu/@crt.pem; 1UUtlsUUpu/@

    ke.pem);T*TTP_TA1_ET_N""())345 6T al=as /e present 54

    i,((ret ? thttp_stack_start(stack)))0T_DEB!_E''%'($ailed to start the *TTP4*TTP stack.)3goto/ail3

    7

    s+a6% is a $e99-deined obDe6+ and mus+ be des+roed b usingT_%B2E1T_A$E_$'EE()T_%B2E1T_A$E_$'EE() ma6ro.

    1$.2 Sessions

    session 6ou9d be seen as a eer2eer ersis+en+ 6onne6+ion and $i99 be main+ained b +*e s+a6% as

    9ong as ou $is* +o %ee +*e ne+$or% 6onne6+ion oened (no+ e9i6i+9 des+roed). I +*e

    6onne6+ion is 69osed b +*e remo+e eer: +*en +*e s+a6% $i99 au+oma+i6a99 reoen i+ $*en ou +r +o

    send a ne$

    session is des+roed.s +*e 6onne6+ion is ersis+en+: +*en ou 6an send mu9+i9e reKues+s $i+*ou+ $ai+ing or ea6*

    resonse. !*is mode is 6a99ed Pie9iningQ and is deined as er ?#' 21 se6+ion C.1.2.2.

    >ou s*ou9d no+ ie9ine reKues+s using non-idemo+en+ me+*ods or non-idemo+en+ seKuen6es o

    me+*ods. !*is means +*a+ ou 6an sae9 ie9ine G"! or

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    24/66

    V1.0.0 (2010-04)

    o+ions $i99 be a9ied +o a99 under9ing reKues+s: un9ess +*e reKues+ redeines +*is o+ion.

    #or more inorma+ion: 9ease &isi+ +*e $ebsi+e.

    15.2.3 He')e(&

    99 *eaders s*a99 be se+ b usingT*TTP_EI%N_ET_*EADE'(name; $e99-%no$ a6+ions ou 6an erorm5 1%NNET1%NNET: DE"ETEDE"ETE: !ET!ET: *EAD*EAD: %PTI%N%PTI%N: PAT1*PAT1*: P%TP%T: PTPTand T'A1ET'A1E.

    >ou 6an use thttp_action_per,orm(session; url; method; V)thttp_action_per,orm(session; url; method; V)un6+ion +o send a 6us+om reKues+.

    99 thttp_action_5()thttp_action_5() un6+ions are non-b9o6%ing.

    99 reKues+s are sen+ in an asn6*ronous manner and +*e resu9+ (

    O) $i99 be assed +o +*e 6a99ba6% un6+ion.

    !*e 6ode be9o$ s*o$s *o$ +o send *TTP PT*TTP PTreKues+.

    intret ? thttp_action_PT(session; http44===.dou/ango.org;44 action@leSCC);

    44 paloadT*TTP_A1TI%N_ET_PAO"%AD(1omment alle:@

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    25/66

    V1.0.0 (2010-04)

    1&1& :CA":CA"

    !*e H'P #rame$or% is main9 based on ?#' 4C2F and uses +in

    6an be used +o im9emen+s ad&an6ed =M un6+iona9i+ies su6* "n*an6ed ddress Aoo%: Presen6e

    u+*oriJa+ion ?u9es: Ser&i6e 'onigura+ion O

    + s+ar+u +*e s+a6% $i99 9oad a99 suor+ed 8Is $i+* +*eir deau9+ &a9ues.

    1&.1 nitiali8ation

    s +*e H'P s+a6% deends on +*e

    (+in7"!): ou M8S! 6a99 tnet_startup()tnet_startup() beore using an H'P un6+ion (txcap_5txcap_5)..

    tnet_cleanup()tnet_cleanup()is used +o +ermina+e use o ne+$or% un6+ions.

    !*e eam9e be9o$ demons+ra+es *o$ +o 6rea+e and s+ar+ a H'P s+a6%. In +*is eam9e: the xcap@the xcap@

    rootroot 8?I is http44dou/ango.orgRCRC4ser

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    26/66

    V1.0.0 (2010-04)

    + s+ar+u: +*e s+a6% $i99 9oad a99 suor+ed 8Is $i+* +*eir deau9+ &a9ues. >ou 6an a+ an +ime

    6*ange +*ese &a9ues or regis+er our o$n 8I obDe6+. !*e 9is+ o deau9+ 8Is $i+* +*eir deau9+

    &a9ues are s*o$n in +*e ne+ se6+ions.

    ;*en ou are abou+ +o send a reKues+: i+s no+ manda+or +o use a regis+ered 8I bu+ i+s easier +o

    genera+e +*e se9e6+or as a99 arame+ers are re-6onigured.

    16.2.1 e,'-*t A%I&

    !*e +ab9e be9o$ s*o$s +*e deau9+ 8Is as +*e are deined b +*e s+a6% a+ s+ar+u.%d M%M&"'$pe Namespace Documen (cope Re#erence

    6a-6as a9i6a+ion/6a-6asLm9 urn5ie+5arams5m95ns5

    6a-6as

    inde g9oba9 ?#' 4C2F se6+ion 12.1

    resour6e-9is+s a9i6a+ion/resour6e-9is+sLm9

    urn5ie+5arams5m95ns5resour6e-9is+s

    inde users ?#' 4C2 se6+ion 3.4.1

    r9s-ser&i6es a9i6a+ion/r9s-ser&i6esLm9

    urn5ie+5arams5m95ns5r9s-ser&i6es

    inde users ?#' 4C2 se6+ion 4.4.1

    res-ru9es a9i6a+ion/au+*-o9i6Lm9

    urn5ie+5arams5m95ns5res-ru9es

    inde users ?#' F02F se6+ion .1

    org.oenmobi9ea99ian6e.res-ru9es a9i6a+ion/au+*-o9i6Lm9 urn5ie+5arams5m95ns56ommon-o9i6 res-ru9es users W=M-!S-Presen6eSIMP"HM

    -V11-200C02B-X

    se6+ion F.1.1.2

    dire6+or a9i6a+ion/dire6+orLm9 urn5ie+5arams5m95ns5

    6a-dire6+or

    dire6+or.m9 users dra+-gar6ia-sim9e-6a-

    dire6+or-00 se6+ion .1

    org.oenmobi9ea99ian6e.6a

    -dire6+or

    a9i6a+ion/&nd.oma.6a-

    dire6+orLm9

    urn5oma5m95dm56a-

    dire6+or

    dire6+or.m9 users W=M-!S-HM'ore-

    V11-200C02B-Xse6+ion .B.2.1

    org.oenmobi9ea99ian6e.res-6on+en+

    a9i6a+ion/&nd.oma.res-6on+en+Lm9

    urn5oma5m95rs5res-6on+en+

    omas+a+us-i6on/r6ss+a+us

    i6on

    users W=M-!S-Presen6e-SIMP"'on+en+HM-

    V10-200C1223-'X

    se6+ion F.1.2

    org.oenmobi9ea99ian6e.6on&

    -*is+or

    a9i6a+ion/&nd.oma.im.*is

    +or-9is+Lm9

    urn5oma5m95im5*is+or-

    9is+

    6on&-*is+or users W=M-!S-IMHM-

    V10-200B0C1-'Xse6+ion F.1.2

    org.oenmobi9ea99ian6e.deerred-9is+

    a9i6a+ion/&nd.oma.im.deerred-9is+Lm9

    urn5oma5m95im5*is+or-9is+

    deerred-9is+ users W=M-!S-IMHM-V10-200B0C1-'X

    se6+ion F.2.2

    org.oenmobi9ea99ian6e.grou

    -usage-9is+

    a9i6a+ion/&nd.oma.grou

    -usage-9is+Lm9

    rn5ie+5arams5m95ns5re

    sour6e-9is+s

    inde users W=M-!S-HMS*ared-

    V11-200C02B-X

    sub69ause F.2.2

    16.2.2 A%I (egi&t('tion

    !*e 6ode be9o$ s*o$s *o$ +o regis+er +$o 8Is. I +*e 8I obDe6+ a9read eis+ (6ase-

    insensi+i&e 6omarison on +*e id): +*en i+ $i99 be uda+ed. 99 ie9ds are manda+or (id: mime-+e:namesa6e: do6umen+ and s6oe).

    txcap_stack_set(stack;TW1AP_TA1_ET_AID(m@xcap@caps; application4m@xcap@capsQxml;

    urniet,paramsxmlnsm@xcap@caps ; m@document; tsk_true);TW1AP_TA1_ET_AID(m@resource@lists; application4m@resource@listsQxml ;

    urniet,paramsxmlnsm@resource@lists ; m@document; tsk_,alse);

    TW1AP_TA1_ET_N""())345 mandator 54

    !*e s+a6% s*ou9d be 6rea+ed as s*o$n a+ se6+ion 1.1.

    =n9 8Is $*i6* don+ aear in +*e +ab9e abo&e s*ou9d be regis+ered using +*is me+*od

    1&.3 Selector

    !*e se9e6+or is a *e9er un6+ion $*i6* 6ou9d be used +o 6ons+ru6+ H'P 8?Is. H'P 8?I is

    doubango Programmers Guide

    2

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    27/66

    V1.0.0 (2010-04)

    6ons+ru6+ed as er ?#' 4C2F se6+ion . TW1AP_E"E1T%'_N%DE_ET5() ma6ros are used +o bui9d a

    6om9e+e and $e99-ormed 8?I (a9read er6en+ en6oded).

    99 eam9es be9o$ assume +*a+ our A%' (used as WI)A%' (used as WI) is sip/o/dou/ango.com : $e are using

    +*e YrcsZ9is+ and +*e xcap@rootxcap@root 8?I is http44dou/ango.orgRCRC4serou $i99 a9so no+i6e +*a+

    TW1AP_E"E1T%'_N%DE_ET_N""()TW1AP_E"E1T%'_N%DE_ET_N""()ma6ro is used +o ends +*e node se9e6+ion arame+ers assed +o

    txcap_selector_get_url()txcap_selector_get_url(): i+s manda+or and s*ou9d a9$as be +*e 9as+ one.

    Se9e6+ HMS 6aabi9i+ies5

    char5 urlstring ? txcap_selector_get_url(stack; xcap@caps;TW1AP_E"E1T%'_N%DE_ET_N""())3

    T_DEB!_IN$%(HsUn; urlstring)3T_$'EE(urlstring)3

    'onso9e =u+u+5

    http44dou/ango.orgRCRC4ser

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    28/66

    V1.0.0 (2010-04)

    'onso9e =u+u+5

    http44dou/ango.orgRCRC4ser>rcsH>>HSD4entrHSBuri?H>>sip/o/dou/ango.orgH>>HSD

    Se9e6+ bobs dis9a-name

    char5 urlstring ? txcap_selector_get_url(stack; resource@lists;TW1AP_E"E1T%'_N%DE_ET_ATT'IBTE( list; name; rcs);

    TW1AP_E"E1T%'_N%DE_ET_ATT'IBTE( entr; uri; sip/o/dou/ango.org);TW1AP_E"E1T%'_N%DE_ET_NA6E(displa@name);TW1AP_E"E1T%'_N%DE_ET_N""())3

    T_DEB!_IN$%(HsUn; urlstring)3T_$'EE(urlstring)3

    'onso9e =u+u+5

    http44dou/ango.orgRCRC4ser>rcsH>>HSD4entrHSBuri?H>>sip/o/dou/ango.orgH>>HSD4displa@name

    Se9e6+ +*e dis9a-name o +*e 1s+ en+r

    char5 urlstring ? txcap_selector_get_url(stack; resource@lists;TW1AP_E"E1T%'_N%DE_ET_ATT'IBTE( list; name; rcs);TW1AP_E"E1T%'_N%DE_ET_P%(entr; -);TW1AP_E"E1T%'_N%DE_ET_NA6E(displa@name);TW1AP_E"E1T%'_N%DE_ET_N""())3

    T_DEB!_IN$%(HsUn; urlstring)3T_$'EE(urlstring)3

    'onso9e =u+u+5

    http44dou/ango.orgRCRC4ser>rcsH>>HSD4entrHSB-HSD4displa@name

    Se9e6+ bob rom osi+ion 23

    char5 urlstring ? txcap_selector_get_url(stack; resource@lists;TW1AP_E"E1T%'_N%DE_ET_ATT'IBTE( list; name; rcs);TW1AP_E"E1T%'_N%DE_ET_P%_ATT'IBTE( entr; >X; uri; sip/o/dou/ango.org);TW1AP_E"E1T%'_N%DE_ET_N""())3

    T_DEB!_IN$%(HsUn; urlstring)3T_$'EE(urlstring)3

    'onso9e =u+u+5http44dou/ango.orgRCRC4ser>rcsH>>HSD4entrHSB>XHSDHSBuri?H>>sip/o/dou/ango.orgH>>HSD

    7amesa6es +es+

    char5 urlstring ? txcap_selector_get_url(stack; resource@lists;TW1AP_E"E1T%'_N%DE_ET_NA6E(,oo);TW1AP_E"E1T%'_N%DE_ET_NA6E(a/ar);TW1AP_E"E1T%'_N%DE_ET_NA6E(//a:);TW1AP_E"E1T%'_N%DE_ET_NA6EPA1E( a; urnnamespace-@uri);TW1AP_E"E1T%'_N%DE_ET_NA6EPA1E( /; urnnamespace>@uri);TW1AP_E"E1T%'_N%DE_ET_N""())3

    T_DEB!_IN$%(HsUn; urlstring)3T_$'EE(urlstring)3

    'onso9e =u+u+5http44dou/ango.orgRCRC4ser>urnnamespace-@uriH>>)xmlns(/?H>>urnnamespace>@uriH>>)

    1&.4 :D/C ,sa%e

    I+ is assumed +*a+ +*e address o +*e HMS (or aggrega+ion Pro) is

    dou/ango.orgRCRC4ser

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    29/66

    V1.0.0 (2010-04)

    txcap_action_create_documenttxcap_action_create_document5 'rea+es ne$ do6umen+ b sending a *TTP4*TTP PT*TTP4*TTP PTreKues+. !*e deau9+ !ont"nt#Typ" $i99 be +*e one asso6ia+ed $i+* +*e 8I o +*e

    do6umen+: un9ess ou ro&ide our o$n !ont"nt#Typ"b using TW1AP_A1TI%N_ET_*EADE'()TW1AP_A1TI%N_ET_*EADE'().

    txcap_action_create_attri/utetxcap_action_create_attri/ute5 'rea+es ne$ a++ribu+e b sending a *TTP4*TTP PT*TTP4*TTP PTreKues+. !*e deau9+ !ont"nt#Typ" $i99 be application4xcap@attQxmlQ: un9ess ou

    ro&ide our o$n !ont"nt#Typ"b using TW1AP_A1TI%N_ET_*EADE'()TW1AP_A1TI%N_ET_*EADE'().

    txcap_action_replace_elementtxcap_action_replace_element5 ?e9a6es an e9emen+ b sending a *TTP4*TTP PT*TTP4*TTP PTreKues+.

    !*e deau9+ !ont"nt#Typ"$i99 be application4xcap@elQxmlQ: un9ess ou ro&ide our

    o$n !ont"nt#Typ"b using TW1AP_A1TI%N_ET_*EADE'()TW1AP_A1TI%N_ET_*EADE'().

    txcap_action_replace_documenttxcap_action_replace_document5 ?e9a6es a do6umen+ b sending a *TTP4*TTP PT*TTP4*TTP PTreKues+. !*e deau9+ !ont"nt#Typ" $i99 be +*e one asso6ia+ed $i+* +*e 8I o +*e

    do6umen+: un9ess ou ro&ide our o$n !ont"nt#Typ"b using TW1AP_A1TI%N_ET_*EADE'()TW1AP_A1TI%N_ET_*EADE'().

    txcap_action_replace_attri/utetxcap_action_replace_attri/ute5 ?e9a6es an a++ribu+e b sending a *TTP4*TTP PT*TTP4*TTP PTreKues+. !*e deau9+ !ont"nt#Typ" $i99 be application4xcap@attQxmlQ: un9ess ou

    ro&ide our o$n !ont"nt#Typ"b using TW1AP_A1TI%N_ET_*EADE'()TW1AP_A1TI%N_ET_*EADE'().

    txcap_action_,etch_elementtxcap_action_,etch_element5 ?e+rie&es an e9emen+ rom +*e HMS b sending a

    *TTP4*TTP !ET*TTP4*TTP !ET reKues+. !*e deau9+ !ont"nt#Typ" $i99 be application4xcap@

    elQxmlQ: un9ess ou ro&ide our o$n !ont"nt#Typ"b using TW1AP_A1TI%N_ET_*EADE'()TW1AP_A1TI%N_ET_*EADE'().

    txcap_action_,etch_documenttxcap_action_,etch_document5 ?e+rie&es a do6umen+ rom +*e HMS b sending a

    *TTP4*TTP !ET*TTP4*TTP !ETreKues+. !*e deau9+ !ont"nt#Typ"$i99 be +*e one asso6ia+ed $i+* +*e 8I

    o +*e do6umen+: un9ess ou ro&ide our o$n !ont"nt#Typ" b using

    TW1AP_A1TI%N_ET_*EADE'()TW1AP_A1TI%N_ET_*EADE'().

    txcap_action_,etch_attri/utetxcap_action_,etch_attri/ute5 ?e+rie&es an a++ribu+e rom +*e HMS b sending a

    *TTP4*TTP !ET*TTP4*TTP !ET reKues+. !*e deau9+ !ont"nt#Typ" $i99 be application4xcap@

    attQxmlQ: un9ess ou ro&ide our o$n !ont"nt#Typ"b using TW1AP_A1TI%N_ET_*EADE'()TW1AP_A1TI%N_ET_*EADE'().

    txcap_action_delete_elementtxcap_action_delete_element5 e9e+es an e9emen+ rom +*e HMS b sending a *TTP4*TTP*TTP4*TTP

    DE"ETEDE"ETEreKues+.

    txcap_action_delete_documenttxcap_action_delete_document5 e9e+es a do6umen+ rom +*e HMS b sending a

    *TTP4*TTP DE"ETE*TTP4*TTP DE"ETE reKues+.

    txcap_action_delete_attri/utetxcap_action_delete_attri/ute5 e9e+es an a++ribu+e rom +*e HMS b sending a

    *TTP4*TTP DE"ETE*TTP4*TTP DE"ETEreKues+.

    !o unders+and *o$ +*e s+a6% is 6rea+ed: 9ease reer +o se6+ion 1.1.

    16.4.1 #et(ie/ing XMS c'p'0i*itie&

    !*e 6ode be9o$ s*o$s *o$ an HM' ob+ains +*e HMS 6aabi9i+ies do6umen+.int ret ? txcap_action_,etch_document(stack;

    44 selectorTW1AP_A1TI%N_ET_E"E1T%'(xcap@caps;

    TW1AP_E"E1T%'_N%DE_ET_N""());44 ends parametersTW1AP_A1TI%N_ET_N""())3

    !*e HM' $i99 send5

    !ET 4ser

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    30/66

    V1.0.0 (2010-04)

    16.4.2 A))(e&& oo

    !*e 6ode be9o$ s*o$s *o$ an HM' ob+ains 8?I is+s (ddress Aoo%).

    int ret ? txcap_action_,etch_document(stack;44 action@le

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    31/66

    V1.0.0 (2010-04)

    TW1AP_A1TI%N_ET_E"E1T%'(resource@lists;TW1AP_E"E1T%'_N%DE_ET_ATT'IBTE( list; name; ne=list);TW1AP_E"E1T%'_N%DE_ET_ATT'IBTE( entr; uri; Ksipalicedou/ango.orgL);TW1AP_E"E1T%'_N%DE_ET_N""());

    44 paloadTW1AP_A1TI%N_ET_PAO"%AD(PAO"%AD; strlen(PAO"%AD));44 ends parametersTW1AP_A1TI%N_ET_N""())3

    !*e HM' $i99 send5PT 4ser>ne=listH>>HSD4entrHSBuri?H>>sipalicedou/ango.orgH>>HSD *TTP4-.-*ost dou/ango.orgRCRC1ontent@"ength ->S1onnection eep@Ali

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    32/66

    V1.0.0 (2010-04)

    1+1+ Si%nalin%Si%nalin%Co)pression ;Si%Co)p

    "ngineering !as% #or6e (I"!#) ?=

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    33/66

    V1.0.0 (2010-04)

    i6+ionar or Signa9ing 'omression (Sig'om)

    [ ?#' 40BB5 7ega+i&e 6%no$9edgemen+ Me6*anism or Signa9ing 'omression

    [ ?#' 4445 Signa9ing 'omression (Sig'om) 8sers\ Guide

    [ ?#' 44F5 Signa9ing 'omression (Sig'om) !or+ure !es+s

    [ ?#' 4C5 Signa9ing 'omression (Sig'om) 'orre6+ions and '9arii6a+ions

    [ ?#' F045 9ing Signa9ing 'omression (Sig'om) +o +*e Session Ini+ia+ion Pro+o6o9 (SIP)

    [ ?#' F1125 !*e Presen6e-Se6ii6 S+a+i6 i6+ionar or Signa9ing 'omression (Sig6om)[ ?#' 125 PPP in

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    34/66

    V1.0.0 (2010-04)

    6omressor is 9i%e an in+era6e and s*ou9d im9emen+s tcomp_compressor_compress_,tcomp_compressor_compress_,: $*i6* is

    deined 9i%e +*is5

    tpede,tsk_/ool_t (5tcomp_compressor_compress_,)(tcomp_compartment_t 5lp1ompartment; const

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    35/66

    V1.0.0 (2010-04)

    1-1- *(bust 6eader Co)pression ;*(6C

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    36/66

    V1.0.0 (2010-04)

    11 S/S over "S/S over "

    SMS s+ands or S*or+ Message Ser&i6e or Si9en+ Messaging Ser&i6e and is a 6ommuni6a+ion ser&i6e

    s+andardiJed in +*e GSM mobi9e 6ommuni6a+ion ss+em: using s+andardiJed 6ommuni6a+ions

    ro+o6o9s a99o$ing +*e in+er6*ange o s*or+ +e+ messages be+$een mobi9e +e9e*one de&i6es.

    SMS +e6*no9og *as been se6iied b +*e "!SI in GSM 03.40 and 03.3C do6umen+s (3GPP !S23.040 and 3GPP !S 23.03C rese6+i&e9). !*ese do6umen+s on9 des6ribe *o$ +o use SMS o&er

    mobi9e ne+$or%s (no+*ing or IP ne+$or%s). !*e suor+ o SMS o&er IP ne+$or%s *as been deined

    in 3GPP !S 24.341: $*i6* is u99 im9emen+ed b doubango +*roug* +inSMS. !o *a&e a66ess +o

    a99 SMS un6+ions: ou s*ou9d Rin69ude Ktinsms.hLi9e in our roDe6+.

    In +*is se6+ion: $e $i99 e9ain *o$ +o use SMS +e6*no9og o&er IP $i+*in +*e IP Mu9+imedia (IM)

    'ore 7e+$or% ('7) subss+em based on +*e Session Ini+ia+ion Pro+o6o9 (SIP) and SIP "&en+s as

    deined in 3GPP !S 24.22.

    Protoco% %ay"r o&"r&i"' for th" Short ("ag" S"r&ic"

    1.1 /odes

    In rea9 $or9d: +*ere are +$o $as +o re6ei&e or send SMS messages o&er mobi9e ne+$or%s5 Ainar

    (P8) and !e+ mode.

    1!.1.1 Tet mo)e

    !*e 8" s*a99 send +*e SMS as an o+*er SIP M"SSG" reKues+ and i+s u +o +*e IP-SM-G; +oen6ode +*e a9oad beore re+ransmission. !*is mode is ou+ o s6oe be6ause +*ere is no+*ing

    se6ia9 +o do.

    1!.1.2 in'(y mo)e

    !*e 8" s*a99 im9emen+ +*e ro9es o an SM-o&er-IP sender and an SM-o&er-IP re6ei&er: a66ording

    +*e ro6edures in se6+ions F.3.1 and F.3.2 in 3GPP !S 24.341.

    !*e IMS 6ore ne+$or% s*a99 +a%e +*e ro9e o an IP-SM-G; and suor+ +*e genera9 ro6edures in

    Se6+ion F.3.3.1 o 3GPP !S 24.341: and +*e un6+ions (ans$ering o rou+ing inorma+ion Kuer: and

    +ransor+ 9aer in+er$or%ing) a66ording +o +*e ro6edures in Se6+ions F.3.3.3 and F.3.3.4 in 3GPP

    !S 24.341.I+s u +o +*e 8" +o en6ode +*e a9oad in binar orma+ beore sending +*e SMS. !*e a9oad

    6on+ains a seKuen6e o *eade6ima9 o6+e+s or de6ima9 semi-o6+e+s s+rings en6oded in binar orma+.

    doubango Programmers Guide

    3

    http://doubango.org/API/tinySMS/http://doubango.org/API/tinySMS/
  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    37/66

    V1.0.0 (2010-04)

    !*e o&era99 P8 (Pro+o6o9 a+a 8ni+) s+ring 6on+ains some useu9 inorma+ion (SMS' address:

    Ser&i6e 'en+er !ime S+am: Sender 7umber: Message ?eeren6e ...) 9us +*e a6+ua9 message

    (a9oad).

    !*e 9eng+* o +*e a9oad 6an be u +o 10 6*ara6+ers $*ere ea6* 6*ara6+er reresen+ Bbi+s

    W10/Bbi+sX: W140/Cbi+sX or WB0/1bi+sX. A deau9+: ea6* 6*ara6+er reresen+s Bbi+s en6oded as er

    3GPP !S 23.03C.

    #or IMS and !" 7e+$or%s: SMS messages s*a99 be en6asu9a+ed in ?P8s (?e9a Pro+o6o9 a+a

    8ni+) da+a s+ring as deined in 3GPP !S 24.011 se6+ion B.3. !*e ?P8 da+a is +ranserred rom SM

    en+i+ +o SM en+i+ using SIP M"SSG" reKues+s. !*ese SIP reKues+s s*a99 use +*e MIM" +e

    application4XSM^3constchar5 short_message ? hello =orld3uintR_t mr ? Cx$S3

    su/mit ? tsms_tpdu_su/mit_create(mr; smsc; destination)3

    45 encode the user data to !6 ^@/it alpha/et 54i,((/u,,er ? tsms_pack_to_^/it(short_message)))0

    ret ? tsms_tpdu_su/mit_set_userdata(su/mit; /u,,er; tsms_alpha_^/it)3i,((hex ? tsms_tpdu_su/mit_tohexastring(su/mit)))0

    T_DEB!_IN$%(6@B6IT?Hs; hex)3T_$'EE(hex)3

    7T_%B2E1T_A$E_$'EE(/u,,er)3

    7

    T_%B2E1T_A$E_$'EE(su/mit)3

    !*e 6ode abo&e $i99 ou+u+5

    )6*+33)+))))F*++F5)C*+3333+63,5-.6))))//)0&83,*0FD)6DDDF.,36+*

    0133010000# SMS' ddress inorma+ion (3GPP !S 23.040 se6+ion .1.2.F)

    05 address 9eng+* (o6+e+s)

    15 +e o +*e number is in+erna+iona9 and +*e numbering 9an id is IS7.

    33010000#5 SMS' address: s$aed and in semi o6+e+s (L33100000). s +*e SMS' address 9eng+* is odd(): +*ena +rai9ing # *as been added beore s$aing.

    11 SMS-S8AMI! irs+ o6+e+ (3GPP !S 23.040 se6+ion .2.2.2)o no+ reDe6+ du9i6a+es / ?e9a+i&e &a9idi+ eriod orma+ / 7o s+a+us reor+ reKues+ed / 7o *eader in +*e user da+a / 7o

    re9 a+*

    doubango Programmers Guide

    3B

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    38/66

    V1.0.0 (2010-04)

    #F !P-Message-?eeren6e (3GPP !S 23.040 se6+ion .2.3.)

    0'13333132F4B !P-es+ina+ion-ddress (3GPP !S 23.040 se6+ion .2.3.C)0'5 !*e 9eng+* o +*e des+ina+ion addresses (semi o6+e+s).

    15 +e o +*e number is in+erna+iona9 and +*e numbering 9an id is IS7.

    3333132F4B5 des+ina+ion address: s$aed and in semi o6+e+s (L33331234FB).

    00 !P-Pro+o6o9-Iden+iier (3GPP !S 23.040 se6+ion .2.3.)00 !P-a+a-'oding-S6*eme (3GPP !S 23.040 se6+ion .2.3.10)

    '9ass 0 / GSM B bi+ deau9+ a9*abe+

    #or more inorma+ion abou+ +*is ie9d: 9ease reer +o 3GPP !S 23.03C se6+ion 4

    !P-Va9idi+-Period (3GPP !S 23.040 se6+ion .2.3.12)4 das

    0A !P-8ser-a+a-eng+* (3GPP !S 23.040 se6+ion .2.3.1)

    115 s $e are using GSM Bbi+ deau9+ a9*abe+: +*en +*e 9eng+* is +*e number o se+e+s.

    "C32A#0#B231 !P-8ser-a+a (3GPP !S 23.040 se6+ion .2.3.24)C-bi+ o6+e+s reresen+ing B-bi+ da+a.

    !*e origina9 da+a (C-bi+) is *e99o $or9dQ

    !*e message s*ou9d be sen+ o&er +*e ne+$or% as binar 6on+en+. #or SMS-S8AMI! messages:

    binar seria9iJa+ion is erormed b tsms_tpdu_su/mit_seriali:e()tsms_tpdu_su/mit_seriali:e().

    !*e 6ode be9o$ s*o$s *o$ +o seria9iJe a SMS-S8AMI! message as binar 6on+en+.

    i,((/u,,er ? T_B$$E'_1'EATE_N""()))0i,(9(ret ? tsms_tpdu_su/mit_seriali:e(su/mit; /u,,er)))0 44 ret ? send(socket; /u,,er@data; /u,,er@si:e)3

    7T_%B2E1T_A$E_$'EE(/u,,er)3

    7

    S' re6ei&ing binar SMS-S8AMI! message (or an o+*er SMS-]) rom +*e ne+$or% s*ou9d use

    tsms_tpdu_message_deseriali:e_mo()tsms_tpdu_message_deseriali:e_mo()un6+ion+o deseria9iJe +*e 6on+en+.

    1!.2.2 SMSEIE#

    SMS-"IV"? messages are used +o 6on&e s*or+ messages rom +*e S' (Ser&i6e 'en+er) +o +*e

    MS (Mobi9e S+a+ion). SMS-"IV"?-?"P=?! messages are used or osi+i&e or nega+i&e

    a6%no$9edgemen+ +o an SMS-"IV"? or SMS-S!!8S-?"P=?!.

    #or more inorma+ion: 9ease reer +o 3GPP !S 23.040 se6+ion .2.2.1.

    !*e 6ode be9o$ s*o$s *o$ +o re6ei&e a SMS-"IV"? message: sen+ rom +*e S' +o +*e MS

    (M!).

    +includetsk.h+includetinsms.h

    tsms_tpdu_message_t5 sms_an ? tsms_tpdu_message_deseriali:e_mt(data; si:e)3i,(sms_an FF sms_an@mti ?? tsms_tpdu_mti_deli

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    39/66

    V1.0.0 (2010-04)

    T_%B2E1T_A$E_$'EE(report)3T_%B2E1T_A$E_$'EE(/u,,er)3

    1!.2.3 SMSSTAT%S#EP+#T

    SMS-S!!8S-?"P=?! messages are used +o 6on&e s+a+us reor+s rom +*e S' (Ser&i6e

    'en+er).+o +*e MS (Mobi9e S+a+ion).

    #or more inorma+ion: 9ease reer +o 3GPP !S 23.040 se6+ion .2.2.3.

    !*e 6ode be9o$ s*o$s *o$ +o re6ei&e a SMS-S!!8S-?"P=?! message: sen+ rom +*e S' +o +*e

    MS (M!).

    +includetsk.h+includetinsms.h

    tsms_tpdu_message_t5 sms_an ? tsms_tpdu_message_deseriali:e_mt(/u,,er@data; /u,,er@si:e)3i,(sms_an FF sms_an@mti ?? tsms_tpdu_mti_status_report_mt)0

    tsms_tpdu_status_report_t5 sms_status_report ? T6_TPD_TAT_'EP%'T(sms_an)3s=itch(sms_status_report@st)0

    casetsms_tpdu_status_recei

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    40/66

    V1.0.0 (2010-04)

    #C !P-Message-7umber (3GPP !S 23.040 se6+ion .2.3.1C)

    0'13333132F4B !P-es+ina+ion-ddress (3GPP !S 23.040 se6+ion .2.3.C)0'5 !*e 9eng+* o +*e des+ina+ion addresses (semi o6+e+s).

    15 +e o +*e number is in+erna+iona9 and +*e numbering 9an id is IS7.

    3333132F4B5 des+ina+ion address: s$aed and in semi o6+e+s (L33331234FB).

    00 !P-8ser-a+a-eng+* (3GPP !S 23.040 se6+ion .2.3.1)005 7o da+a

    !*e message s*ou9d be sen+ o&er +*e ne+$or% as binar 6on+en+. #or SMS-'=MM7 messages:

    binar seria9iJa+ion is erormed b tsms_tpdu_command_seriali:e()tsms_tpdu_command_seriali:e().

    !*e 6ode be9o$ s*o$s *o$ +o seria9iJe a SMS-'=MM7 message as binar 6on+en+.

    i,((/u,,er ? T_B$$E'_1'EATE_N""()))0ret ? tsms_tpdu_command_seriali:e(command; /u,,er)344 ret ? send(socket; /u,,er@data; /u,,er@si:e)3

    T_%B2E1T_A$E_$'EE(/u,,er)37

    S' re6ei&ing binar SMS-'=MM7 message (or an o+*er SMS-]) o&er +*e ne+$or% s*ou9d

    usetsms_tpdu_message_deseriali:e_mo()tsms_tpdu_message_deseriali:e_mo(),unction +o deseria9iJe +*e 6on+en+.

    1.3 Service provided b= the S/'*!*e S*or+ Message ?e9a aer (SM-?) ro&ides a ser&i6e +o +*e S*or+ Message !ranser aer

    (SM-!). !*is ser&i6e enab9es +*e SM-! +o send !ranser Pro+o6o9 a+a 8ni+s (!P8s) +o i+s eer

    en+i+: re6ei&e !P8s rom i+s eer en+i+ and re6ei&e reor+s abou+ ear9ier reKues+s or !P8s +o

    be +ranserred.

    #or more inorma+ion abou+ *o$ doubango ro&ides SM-! ser&i6es: 9ease reer +o +*e re&ious

    se6+ion.

    1!.3.1 #PATA

    ?P-! messages are use +o re9a +*e !P8s. !*ese messages 6ou9d be sen+ rom +*e 7e+$or% +o

    Mobi9e S+a+ion (M!) or rom +*e Mobi9e S+a+ion +o +*e 7e+$or% (M=).#or more inorma+ion: 9ease reer +o 3GPP !S 24.011 se6+ion B.3.1.

    !*e 6ode be9o$ s*o$s *o$ +o send a ?P-! message $i+* a ?P-8ser-a+a (see 3GPP !S

    23.011 se6+ion C.2.F.3) inorma+ion e9emen+ $*i6* in69udes SMS-S8AMI! as +e indi6a+or (+*is

    use 6ase 6omes rom 3GPP !S 24.341 6*a+er A.F).

    +includetsk.h+includetinsms.h

    intret3tsk_/u,,er_t5 /u,,er ? tsk_null3tsms_tpdu_su/mit_t5 sms_su/mit ? tsk_null3tsms_rpdu_data_t5 rp_data ? tsk_null3

    constchar5 smsc ? QXX-CCCCC]3constchar5 destination ? QXXXXM->XSM^3constchar5 short_message ? hello =orld3uintR_t mr ? Cx$S3char5 hex3

    44 create 6o/ile %riginated 6@B6IT messagesms_su/mit ? tsms_tpdu_su/mit_create(mr; smsc; destination)344 et content ,or 6@B6ITi,((/u,,er ? tsms_pack_to_^/it(short_message)))0

    ret ? tsms_tpdu_su/mit_set_userdata(sms_su/mit; /u,,er; tsms_alpha_^/it)3T_%B2E1T_A$E_$'EE(/u,,er)3

    744 create 'P@DATA(6@B6IT) message and print its content (,or test onl)rp_data ? tsms_rpdu_data_create_mo(mr; smsc; T6_TPD_6EA!E(sms_su/mit))3i,((hex ? tsms_rpdu_message_tohexastring(T6_'PD_6EA!E(rp_data))))0

    T_DEB!_IN$%('P@DATA?Hs; hex)3T_$'EE(hex)3

    7

    T_%B2E1T_A$E_$'EE(/u,,er)3

    doubango Programmers Guide

    40

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    41/66

    V1.0.0 (2010-04)

    T_%B2E1T_A$E_$'EE(sms_su/mit)3T_%B2E1T_A$E_$'EE(rp_data)3

    !*e 6ode abo&e $i99 ou+u+5

    ))F5)))6*+33)+))))F*+F)6*+33)+))))F*++F5)C*+3333+63,5-.6))))//)0&83,*0FD)6D

    DDF.,36+*

    00 ?P-Message !e (3GPP !S 24.011 se6+ion C.2.2)

    005 ?P-! (Mobi9e s+a+ion +o 7e+$or%). Mobi9e =rigina+ed.#F ?P-Message ?eeren6e (3GPP !S 24.011 se6+ion C.2.3)

    #F5 See +*e 6ode.

    00 ?P-=rigina+or ddress (3GPP !S 24.011 se6+ion C.2.F.1)

    005 #or Mobi9e origina+ed messages: +*is ie9d is em+.0133010000# ?P-es+ina+ion ddress (3GPP !S 23.011 se6+ion C.2.F.2)

    05 address 9eng+* (o6+e+s)

    15 +e o +*e number is in+erna+iona9 and +*e numbering 9an id is IS7.

    33010000#5 SMS' address: s$aed and in semi o6+e+s (L33100000). s +*eSMS' address 9eng+* is odd(): +*en a +rai9ing # *as been added beore

    s$aing.

    #or Mobi9e origina+ed messages: +*is ie9d 6on+ains +*e SMS' address.

    11#F0'13333132F4B00000A"C32A#0#B231 ?P-8ser a+a (3GPP !S 24.011 se6+ion C.2.F.3)115 eng+* indi6a+or

    #F0'13333132F4B00000A"C32A#0#B2315 SMS-S8AMI!

    message. #or more inorma+ion: 9ease reer +o +*e SMS-S8AMI!se6+ion.

    !*e message s*ou9d be sen+ o&er +*e ne+$or% as binar 6on+en+. #or ?P-! messages: binar

    seria9iJa+ion is erormed b tsms_rpdu_data_seriali:e()tsms_rpdu_data_seriali:e().

    !*e 6ode be9o$ s*o$s *o$ +o seria9iJe a ?P-! message as binar 6on+en+.

    i,((/u,,er ? T_B$$E'_1'EATE_N""()))0ret ? tsms_rpdu_data_seriali:e(rp_data; /u,,er)344 ret ? send(socket; /u,,er@data; /u,,er@si:e)3

    T_%B2E1T_A$E_$'EE(/u,,er)37

    S' re6ei&ing binar ?P-! message (or an o+*er ?P-]) o&er +*e ne+$or% s*ou9d use

    tsms_rpdu_message_deseriali:e ()()un6+ion+o deseria9iJe +*e 6on+en+.

    !*e 6ode be9o$ s*o$s *o$ +o re6ei&e a ?P-! message $i+* a ?P-8ser-a+a (see 3GPP !S23.011 se6+ion C.2.F.3) inorma+ion e9emen+ $*i6* in69udes SMS-"IV"? as +e indi6a+or (+*is

    use 6ase 6omes rom 3GPP !S 24.341 6*a+er A.).

    +includetsk.h+includetinsms.h

    tsms_rpdu_message_t5 rp_message ? tsk_null3tsms_tpdu_message_t5 tpdu ? tsk_null3

    i,(9(rp_message ? tsms_rpdu_message_deseriali:e(data; si:e)))0 45 Deseriali:e 'P@5 6essage 54T_DEB!_E''%'($ailed to deseriali:e the 'P@6EA!E)3goto/ail3

    7

    i,(rp_message@mti ?? tsms_rpdu_tpe_data_mt)0 45 6o/ile Terminated 'P@DATA54char5 ascii ? tsk_null3tsms_rpdu_data_t5 rp_data ? T6_'PD_DATA(rp_message)3i,((tpdu ? tsms_tpdu_message_deseriali:e_mt(rp_data@udata@data; rp_data@udata@si:e)))0

    45 Deseriali:e 6@5 6essage ($rom 1 to 6) 54i,(tpdu@mti ?? tsms_tpdu_mti_deli

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    42/66

    V1.0.0 (2010-04)

    mobi9e *as memor a&ai9ab9e +o re6ei&e one or more s*or+ messages.

    #or more inorma+ion: 9ease reer +o 3GPP !S 24.011 se6+ion B.3.2.

    !*e 6ode be9o$ s*o$s *o$ +o send a ?P-SMM message.

    +includetsk.h+includetinsms.h

    intret3tsk_/u,,er_t5 /u,,er ? tsk_null3tsms_rpdu_smma_t5 rp_smma ? tsk_null3uintR_t mr ? Cx$S3

    44 create 'P@66A messagerp_smma ? tsms_rpdu_smma_create(mr)344 seriali:e/u,,er ? T_B$$E'_1'EATE_N""()3ret ? tsms_rpdu_data_seriali:e(rp_smma; /u,,er)344 send(socket; /u,,er@data; /u,,er@si:e)3

    T_%B2E1T_A$E_$'EE(/u,,er)3T_%B2E1T_A$E_$'EE(rp_smma)3

    1!.3.3 #PACK?P-'E messages are sen+ be+$een +*e MS' and +*e mobi9e s+a+ion in bo+* dire6+ions and used +o

    re9a +*e a6%no$9edgemen+ o a ?P-! or ?P-SMM message re6e+ion.

    #or more inorma+ion: 9ease reer +o 3GPP !S 24.011 se6+ion B.3.2.3.

    !*e 6ode be9o$ s*o$s *o$ +o send a ?P-'E message $i+* a ?P-8ser-a+a (see 3GPP !S 23.011

    se6+ion C.2.F.3) inorma+ion e9emen+ $*i6* in69udes SMS-"IV"?-?"P=?! as +e indi6a+or

    (+*is use 6ase 6omes rom 3GPP !S 24.341 6*a+er A. se6+ion C).

    +includetsk.h+includetinsms.h

    intret3

    tsk_/u,,er_t5 /u,,er ? tsk_null3tsms_tpdu_report_t5 sms_report ? tsk_null3tsms_rpdu_ack_t5 rp_ack? tsk_null3constchar5 smsc ? QXX-CCCCCC3tsk_/ool_t isB6IT ? tsk_,alse3 45 is 6@DE"I#E'@'EP%'T 54tsk_/ool_t isE''%' ? tsk_,alse3uintR_t mr ? Cx$S3

    44 create 6@DE"I#E'@'EP%'T messagesms_report ? tsms_tpdu_report_create(smsc; isB6IT; isE''%')344 create 6o/ile %riginated 'P@A1 messagerp_ack ? tsms_rpdu_ack_create_mo(mr; T6_TPD_6EA!E(sms_report))344 seriali:e and send/u,,er ? T_B$$E'_1'EATE_N""()3i,(9(ret ? tsms_rpdu_data_seriali:e(rp_ack; /u,,er)))0

    44 send(socket; /u,,er@data; /u,,er@si:e)37T_%B2E1T_A$E_$'EE(/u,,er)3T_%B2E1T_A$E_$'EE(sms_report)3T_%B2E1T_A$E_$'EE(rp_ack)3

    1!.3.4 #PE##+#

    ?P-"??=? messages are sen+ be+$een +*e MS' and +*e mobi9e s+a+ion in bo+* dire6+ions and used

    +o re9a an error 6ause rom an erroneous s*or+ message or no+ii6a+ion +ranser a++em+.

    #or more inorma+ion: 9ease reer +o 3GPP !S 24.011 se6+ionB.3.2.4.

    !*e 6ode be9o$ s*o$s *o$ +o send a ?P-"??=? message $i+* a ?P-8ser-a+a (see 3GPP !S

    23.011 se6+ion C.2.F.3) inorma+ion e9emen+ $*i6* in69udes SMS-"IV"?-?"P=?! as +e

    indi6a+or. In +*is eam9e: +*e error message is sen+ be6ause +*e 6a99 is barredQ. #or moreinorma+ion abou+ +*e 6ause &a9ues +*a+ ma be 6on+ained in an ?P-"??=? message: 9ease reer +o

    3GPP !S 24.011 se6+ion C.2.F.4.

    doubango Programmers Guide

    42

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    43/66

    V1.0.0 (2010-04)

    +includetsk.h+includetinsms.h

    intret3tsk_/u,,er_t5 /u,,er ? tsk_null3tsms_tpdu_report_t5 sms_report ? tsk_null3tsms_rpdu_error_t5 rp_error? tsk_null3tsk_/ool_t isB6IT ? tsk_,alse3 45 is 6@DE"I#E'@'EP%'T 54tsk_/ool_t isE''%' ? tsk_true3

    constchar5 smsc ? QXX-CCCCCC3uintR_t mr ? Cx$S3

    44 create 6@DE"I#E'@'EP%'T messagesms_report ? tsms_tpdu_report_create(smsc; isB6IT; isE''%')344 create 6o/ile %riginated 'P@E''%' messagerp_error ? tsms_rpdu_error_create_mo(mr; T6_TPD_6EA!E(sms_report); CxCA45call /arred54)344 seriali:e/u,,er ? T_B$$E'_1'EATE_N""()3i,(9(ret ? tsms_rpdu_data_seriali:e(rp_error; /u,,er)))0

    44 send(socket; /u,,er@data; /u,,er@si:e)37

    T_%B2E1T_A$E_$'EE(/u,,er)3T_%B2E1T_A$E_$'EE(sms_report)3T_%B2E1T_A$E_$'EE(rp_error)3

    doubango Programmers Guide

    43

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    44/66

    V1.0.0 (2010-04)

    22 /S*"/S*"

    doubango Programmers Guide

    44

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    45/66

    V1.0.0 (2010-04)

    2121 SD"SD"

    doubango Programmers Guide

    4F

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    46/66

    V1.0.0 (2010-04)

    2222 S"S";3G"" /S7T5ou s*ou9d ne&er 6*ange i+s&a9ue on6e +*e s+a6% is s+ar+ed. I +*e address o +*e Pro-'S'# is missing: +*en +*e s+a6% $i99

    au+oma+i6a99 use 7S 7P!?LS?V and/or

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    47/66

    V1.0.0 (2010-04)

    used +o ?"GIS!"? +*e user is barred: +*en +*e s+a6% $i99 use +*e deau9+ 8?I re+urned b +*e S-

    'S'#.

    >ou s*ou9d ne&er manua99 se+ +*is SIP *eader (P-Preerred-Iden+i+)@ i+s u +o +*e s+a6%.

    22.1.5 C(e'ting t9e &t'c

    tsip_stack_create(call/ack; realm_uri; impi_uri; impu_uri; V)tsip_stack_create(call/ack; realm_uri; impi_uri; impu_uri; V) un6+ion is used +o 6rea+e a

    ne$ 3GPP IMS/!" s+a6%. !*is un6+ion $i99 re+urn a &a9id *and9e i su66eed and NullNullo+*er$ise.

    In +*e 6ode be9o$: $e on9 use manda+or arame+ers (e6e+ +*e pass=ordpass=ord). !*e Pro-'S'# IP

    address and Por+ are missing and ou s*ou9d use TIP_TA1_ET_P'%WO_11$()TIP_TA1_ET_P'%WO_11$() +o se+ +*em i

    reKuired. #or more inorma+ion: 9ease reer +o +*e ne+ se6+ion (22.1.C).

    tsip_stack_handle_t 5stack ? tsk_null3intret3

    constchar5 realm_uri ? [email protected] impi_uri ? /o/[email protected] impu_uri ? sip/o/[email protected]

    intapp_call/ack(consttsip_e

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    48/66

    V1.0.0 (2010-04)

    T_%B2E1T_A$E_$'EE(stack)3

    tnet_cleanup()3

    TIP_TA1_ET_N""()TIP_TA1_ET_N""()ma6ro is manda+or: i+s used +o +ermina+e +*e 9is+ o arame+ers assed +o

    +*e un6+ion. !*is ma6ro s*ou9d a9$as be +*e 9as+ one. #or more inorma+ion: 9ease reer +o +*e

    SIP PI reeren6e.

    TTIP_TA1_ET_PA&%'D()IP_TA1_ET_PA&%'D() ma6ro is no+ manda+or: i+s used +o se+ +*e users ass$ord.'reden+ia9s are a9$as used a+ s+a6%-9e&e9. !*e 6a99ba6% un6+ion $i99 be used +o a9er+ +*e user abou+

    ne$ in6oming SIP messages: media s+a+e 6*anges: errors O More inorma+ion abou+ +*e 6a99ba6%

    un6+ion is gi&en be9o$.

    s+a6% is a $e99-deined obDe6+ and s*ou9d be des+roed using T_%B2E1T_A$E_$'EE().T_%B2E1T_A$E_$'EE(). ;*en

    des+roed: +*e s+a6% au+oma+i6a99 rees a99 under9ing sessions and 69ean9 *ang-u a99 SIP dia9ogs.

    22.1.6 St'(ting t9e &t'c

    tsip_stack_start(stack)tsip_stack_start(stack)un6+ion is used +o s+ar+ +*e s+a6%. !*is un6+ion re+urn Jero i su66eed and

    non-Jero error 6ode o+*er$ise. I +*e s+a6% ai9s +o s+ar+: ou s*ou9d 9oo% a+ +*e debug ou+u+ or

    more inorma+ion. >ou 6an 6a99 +*is un6+ion in +*e 8I +*read as i+ $i99 immedia+e9 re+urn and a99

    addi+iona9 +as%s $i99 be done in a seara+e +*read. ;*en users oera+ions are erormed on +*e

    s+a6% $*i9e i+s s+ar+ing in ba6%ground: +*eses oera+ions $i99 be Kueued and ee6u+ed $*en +*e

    s+a6% s+ar+s.

    !o s+o +*e s+a6%: use tsip_stack_stop(stack)tsip_stack_stop(stack). !*is un6+ion is +*read-sae and s*ou9d re+urn Jero

    i su66eed (or i +*e s+a6% is a9read s+oed) and non-Jero error 6ode o+*er$ise.

    22.1.7 C'**0'c ,-nction

    !*e 6a99ba6% un6+ion is no+ manda+or bu+ i+s *ig*9 re6ommended +o ro&ide one. !*is un6+ion

    is 6a99ed b +*e s+a6% +o a9er+ +*e user end a9i6a+ion abou+ bo+* SIP and media e&en+s.

    !*e signa+ure o +*e 6a99ba6% un6+ion is gi&en be9o$5intintapp_call/ack(app_call/ack(constconsttsip_e

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    49/66

    V1.0.0 (2010-04)

    $or%around is +o se+ +*e IP address ourse9. !*e IP address o +*e emu9a+or is a9$as -C.C.>.-S.

    #or a99 o+*er ss+ems (;indo$s HP/B/'": Ninu: M' =S H: iP*one: Smbian O) +*is un6+ion

    is use9ess and ou s*ou9d 9e+ +*e s+a6% se9e6+ +*e bes+ 9o6a9 IP address and Por+.

    unsignedlocal_port ? ->X3constchar5 local_ip ? SSSSaaaa///cccddd3

    unsignedpcsc,_port ? CMC3

    constchar5 pcsc,_ip ? MMMMeeee///cccddd3constchar5 transport ? udp3 45 GudpG or GtcpG or GtlsG or GsctpG 54constchar5 ip_

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    50/66

    V1.0.0 (2010-04)

    #or more inorma+ion: 9ease reer +o +*e SIP PI reeren6e.

    22.2 Sessions

    session 6ou9d be seen as a SIP dia9og as er ?#' 321 se6+ion 12. #or eam9e: ?"GIS!"?:

    S8AS'?IA": P8AIS

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    51/66

    V1.0.0 (2010-04)

    TIP_EI%N_ET_N""())3

    Session-9e&e9 o+ions 6ou9d be added $*en +*e session is abou+ i+ be 6rea+ed

    (tsip_ssession_create())tsip_ssession_create())or a+ an +ime (tsip_ssession_set()).tsip_ssession_set()).

    22.2.3 C'p'0i*itie&

    'aabi9i+ies are used +o se+ +*e 8" 6*ara6+eris+i6s b using +*e 'on+a6+Q *eader. s +*e

    rogrammer doesn+ *a&e a66ess +o +*e 6on+a6+ *eader: TIP_EI%N_ET_1AP() is used +o

    ad&er+ise +*e 8" 6as. #or more inorma+ion: 9ease reer +o I"!# ?#' 3C40. ;*en +*e message

    don+ *a&e 'on+a6+Q *eader (e.g. M"SSG" or P8AIS

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    52/66

    V1.0.0 (2010-04)

    TIP_A1TI%N_ET_*EADE'(6@*eader@>; 6@#alue@>);

    TIP_A1TI%N_ET_N""())3

    I a *eader added a+ s+a6%-9e&e9 or session-9e&e9 is a9so added a+ reKues+-9e&e9: +*en +*is *eader $i99

    be du9i6a+ed. !*e sessionsessionarame+er is a SIP session obDe6+ 6rea+ed as er se6+ion >>.>essions.

    22.3.2 +-tgoing

    22.3.3 Incoming

    22.4 "ro0='CSCF discover=

    22.4.1 HCP/4

    22.4.2 HCP/6

    22.4.3 NS NAPT#;S#

    22.$ *e%istration

    22.5.1 IMSAKA

    doubango u99 im9emen+s IMS-E (u+*en+i6a+ion and Ee greemen+) as er 3GPP !S 24.22

    and 3GPP !S 33.203.

    In order +o 6omu+e +*e resonse: +*e rame$or% needs +*e IE: 'E: M# and =era+or Id &a9ues.

    #or more inorma+ion abou+ +*ese ie9ds: 9ease reer +o 3GPP !S 3G Se6uri+ series (3GPP !S

    3F.20F: 3GPP !S 3F.20: 3GPP !S 3F.20B: 3GPP !S 3F.20C and 3GPP !S 3F.0).

    !*e IE (In+egri+ Ee) and 'E ('i*er Ee) &a9ues are au+oma+i6a99 6omu+ed rom +*e users

    6reden+ia9s and ou don+ need +o su9 +*em. ou s*ou9d use TIP_TA1_ET_I6_AA_A6$()TIP_TA1_ET_I6_AA_A6$()ma6ro +o se+ +*e M# &a9ue.

    !*e =era+or Id i9ed is a 12C-bi+ (1 b+es) &a9ue $*i6* is used as an inu+ +o +*e un6+ions 1: 1]:

    2: 3: 4: F and F]. >ou s*ou9d use TIP_TA1_ET_I6_AA_%PE'AT%'_ID()TIP_TA1_ET_I6_AA_%PE'AT%'_ID()ma6ro +o se+ +*e

    =era+or Id &a9ue a+ s+a6%-9e&e9

    Ise6: Se6-gree (nego):

    22.5.2 Initi'* (egi&t('tion

    22.5.3 E'(*y IMS Sec-(ity

    Aasi6 SIP a9i6a+ion s*ou9d use +*is o+ion +o disab9e some *ea& IMS au+*en+i6a+ion ro6edures.

    "ar9 IMS as er 3GPP !S 33.BC is ar+ia99 suor+ed and s*ou9d be se+ a+ s+a6%-9e&e9 b using

    TIP_TA1_ET_EA'"O_I6(ENAB"ED_B%%")TIP_TA1_ET_EA'"O_I6(ENAB"ED_B%%")ma6ro.

    22.5.4 I)entitie&

    Ge++ing P-sso6ia+ed-8?Is (and 6*e6%ing i an iden+i+ is barred)

    Se++ing P-Preerred-Iden+i+ies

    doubango Programmers Guide

    F2

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    53/66

    V1.0.0 (2010-04)

    22.5.5 Net

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    54/66

    V1.0.0 (2010-04)

    message en6oded as er 3GPP !S 24.011 se6+ion B.3. !*e SM-o&er-IP sender s*a99 use MIM" +e

    a9i6a+ion/&nd.3g.smsQ or +*is urose.

    22.14.2 #ecei/ing SMS

    22.14.3 #o'ming Con&i)e('tion&

    3GPP !S 23.2B23GPP !S 23.221

    3GPP !S 24.301

    22.1$ !AT Traversal

    22.15.1 (po(t

    !*is is +*e sim9es+ $a +o dea9 $i+* 7!s rob9em a+ signa99ing (SIP on9) 9an or 6onne6+ion9ess

    ro+o6o9s (e.g. 8P). rpor*as been deined in I"!# ?#' 3FC1 and a9 +o bo+* 6onne6+ion9ess

    (e.g. 8P) and 6onne6+ion-orien+ed (e.g. !'P: !S: S'!P) ro+o6o9s. !*is o+ion is a9$as enab9ed

    e&en i ou use S!87: !8?7 or I'" (no+ e69usi&e).

    Ae6ause 6onne6+ion-orien+ed ro+o6o9s su6* as !'P are bidire6+iona9 i+ is easier +o dea9 $i+* 7!

    +ra&ersa9 (a99 resonses $i99 be sen+ ba6% using +*e same 6onne6+ion rom $*i6* +*e reKues+ *as

    been re6ei&ed rom).

    !*e *i9oso* (o rpor) is +*a+: $*en ou add +*is a++ribu+e ( rpor) in our reKues+s (#ia#ia

    IP4>.C4DP -]>.-MR.-M.-CR>^>CR3/ranch?:]h!/->X3rportIP4>.C4DP -]>.-MR.-M.-CR>^>CR3/ranch?:]h!/->X3rport) +*en a99 resonses $i99 be sen+

    ba6% +o +*e ipportipport rom $*i6* +*e reKues+ *as been re6ei&ed rom. !*is arame+er M8S! be

    added in +*e +o mos+ ViaQ *eader.

    !*e resonse $i99 6on+ain a ne$ arame+er (re6ei&edQ) 6on+aining +*e IP address rom $*i6* +*e

    reKues+ *as been re6ei&ed and +*e rpor&a9ue $i99 be i99ed $i+* +*e maed sour6e or+. In +*is

    $a +*e 69ien+ (+*e sender o +*e reKues+) 6an 9earn i+\s rou+ab9e IP address and or+ (#ia#iaIP4>.C4DP -]>.-MR.-M.-CR>^>CR3/ranch?:]h!/->X3rport?->X3recei.C4DP -]>.-MR.-M.-CR>^>CR3/ranch?:]h!/->X3rport?->X3recei

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    55/66

    V1.0.0 (2010-04)

    22.16.3 +(igin'ting I)enti,ic'tion #e&t(iction

    3GPP !S 24.0B

    22.16.4 Te(min'ting I)enti,ic'tion #e&t(iction

    3GPP !S 24.0C

    22.16.5 Comm-nic'tion i/e(&ion %ncon)ition'*3GPP !S 24.04

    22.16.6 Comm-nic'tion i/e(&ion on not ogge) in 3$PP TS 24.6"4

    22.16.7 Comm-nic'tion i/e(&ion on -&y

    3GPP !S 24.04

    22.16.8 Comm-nic'tion i/e(&ion on not #e'c9'0*e

    3GPP !S 24.04

    22.16.! Comm-nic'tion i/e(&ion on No #ep*y

    3GPP !S 24.04

    22.16.1" '((ing o, A** Incoming C'**&

    3GPP !S 24.11

    22.16.11 '((ing o, A** +-tgoing C'**&

    3GPP !S 24.11

    22.16.12 '((ing o, +-tgoing Inte(n'tion'* C'**&

    3GPP !S 24.11

    22.16.13 '((ing o, Incoming C'**& =9en #o'ming

    3GPP !S 24.11

    22.16.14 Comm-nic'tion Ho*)

    3GPP !S 24.10

    22.16.15 Me&&'ge ='iting In)ic'tion

    3GPP !S 24.0

    22.16.16 Comm-nic'tion ='iting

    3GPP !S 24.1F

    22.16.17 A)Hoc M-*ti P'(ty Con,e(ence

    3GPP !S 24.0F

    22.16.18 S-pp*ement'(y Se(/ice Con,ig-('tion

    3GPP !S 24.23

    doubango Programmers Guide

    FF

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    56/66

    V1.0.0 (2010-04)

    22.1+ S" "reconditions ;>oSou on9 need +*e '/'LL edi+ions.

    s a99 o+*er ss+ems ou 6an use G78 Aui9d !oo9s $i+* MinG; or 'g$in. #or more inorma+ion:

    9ease reer +o se6+ion 23.1.

    23.3 indows /obile

    >ou 6an use +*e Visua9 S+udio ProDe6+s des6ribed abo&e. >ou s*ou9d ins+a99 ;indo$s Mobi9e SEF.0 or Po6%e+ P'Q or 9a+er.

    'ross-6omi9a+ion $i+* MinG; or 'g$in 6ou9d be a6*ie&ed b using 'eG''. #or more

    inorma+ion: 9ease reer +o subse6+ion 23.1.1.

    23.4 /AC (S :7i"hone7i"ad

    !*e sour6e 6ode 6on+ains H6ode roDe6+ i9es under (D%BAN!%_*%6E)4xcode4tin5(D%BAN!%_*%6E)4xcode4tin5.

    s s+a+ed abo&e: G78 bui9d +oo9s use li/toolli/tool$*i6* used li/tooli:eli/tooli:e6ommand +o genera+e s*ared

    9ibraries. Ma6 =S H does s*i $i+* +*e li/tooli:eli/tooli:e6ommand: bu+ due +o 6on9i6+: i+ *as been

    renamed +o gli/tooli:egli/tooli:e(or G78 9ib+oo9iJe). In order or +*e autogen.shautogen.shs6ri+s +o be 9aun6*ed:

    ou *a&e +o se6i +*e en&ironmen+ &ariab9e "IBT%%"I`E"IBT%%"I`Eas o99o$5 "IBT%%"I`E?gli/tooli:e .4autogen.sh "IBT%%"I`E?gli/tooli:e .4autogen.sh

    Not" for (ac )S * +,.- Sno' $"opard/0Sno$ eoard is an *brid oera+ing ss+em +*a+ 6an run

    on bo+* 32 and 4 bi+s a9i6a+ions: and e&en mi +*e +$o addressing mode. A deau9+: +*e G''

    6omi9er +arge+s +*e C4 ar6*i+e6+ure: e&en on 32 bi+s %erne9s. !*ereore: ou need +o e9i6i+9

    se+ +*e ar6*i+e6+ure +o bui9d $*en using +*e au+o-+oo9s5

    1or i23- archit"ctur"0

    1"$A!?@arch iXRM "D$"A!?@arch iXRM .4con,igure 1"$A!?@arch iXRM "D$"A!?@arch iXRM .4con,igure

    1or 43-_-5 archit"ctur"0

    1"$A!?@arch xRM_M "D$"A!?@arch xRM_M .4con,igure 1"$A!?@arch xRM_M "D$"A!?@arch xRM_M .4con,igure

    doubango Programmers Guide

    FC

    http://cegcc.sourceforge.net/http://cegcc.sourceforge.net/
  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    59/66

    V1.0.0 (2010-04)

    23.$ ,ni0'ie s=ste)s

    23.& Binu0

    23.+ Goo%le Android

    23.7.1 S9'(e) i0('(ie&

    Ae6ause +*ere is an issue $i+* G78 9ib+oo9 ?M 6ross-6omi9a+ion (on9 s+a+i6 9ibraries): ou

    s*ou9d use +*e ndroid se6ia9 ma%ei9es (under (D%BAN!%_*%6E4(D%BAN!%_*%6E4android@pro8ectsandroid@pro8ects)) in order +o

    bui9d s*ared 9ibraries. S*ared 9ibraries are reKuired or +*ose $*o $an+ +o use doubango in +*eir

    ^a&a (^7I/a9&i%) or Mono (P/In&o%e) rograms.

    1) dDus+ (D%BAN!%_*%6E)[email protected](D%BAN!%_*%6E)[email protected]

    a) '*ange AND'%ID_ND_'%%TAND'%ID_ND_'%%T &ariab9e +o oin+ +o +*e 7E roo+ dire6+or (e.g.

    4cgdri.-U/inexport PAT*?AND'%ID_ND_'%%TU/uildUpre/uiltU(*%T)Uarm@ea/i@.>.-U/inPAT*PAT*

    $*ere *%T*%Tis eKua9 +odar=in@xRMdar=in@xRM on M' =S H:=indo=s=indo=s on ;indo$s HP/Vis+a/B andlinux@linux@

    xRMxRMon 8ni-9i%e ss+ems.

    F) Se+ our 6us+om (1$"A!)(1$"A!)9ags +o 6*ange +*e deau9+ be*a&ior5

    a) "am9e5 export 1$"A!?L@gX %C DDEB!_"E#E"?DEB!_"E#E"_IN$%L.export 1$"A!?L@gX %C DDEB!_"E#E"?DEB!_"E#E"_IN$%L.>ou 6an o 6ourse

    se+ an &a9id G''(1$"A!)(1$"A!)9ags.

    ) Go +o +*e android-roDe6+s roo+ dire6+or5

    a) cd (D%BAN!%_*%6E)4android@pro8ectscd (D%BAN!%_*%6E)4android@pro8ects

    B) Aui9d and de9o a roDe6+5

    a) makemakeP'%2E1T?tin5 allP'%2E1T?tin5 all

    $*ere tin5tin5is eKua9 +o tinAtinAor tinNETtinNETor tin*TTPtin*TTPor O. #or eam9e: +o bui9d tinAtinAroDe6+: +e make P'%2E1T?tinA allmake P'%2E1T?tinA all. !*is $i99 bui9d and de9o +*e roDe6+ on +*e de&i6e or

    emu9a+or. 99 9ibraries $i99 be de9oed +o "IB_DI'"IB_DI'(deau9+ &a9ueU4sstem4li/4sstem4li/) and ee6u+ab9e

    +o EWE1_DI'EWE1_DI'(deau9+ &a9ueU4data4tmp4data4tmp).

    23.- S=)bian S&

    !*e easies+ $a +o 6omi9e: +es+ and de9o our a9i6a+ion on S0 ss+ems is +o use 'arbideroDe6+s $*i6* are under (D%BAN!%_*%6E)4car/ide4tin5(D%BAN!%_*%6E)4car/ide4tin5.

    doubango Programmers Guide

    F

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    60/66

    V1.0.0 (2010-04)

    2424 De)onstrationDe)onstration

    !o s*o$ *o$ o$eru9 +*e 3GPP IMS/!" s+a6% is: $e *a&e de&e9oed a +in bu+ u99 ea+ured

    demo rogram. !*e demo rogram is name +in"M=and is ar+ o +*e sour6e 6ode.

    +in"M=is a 6ommand-9ine rogram $or%ing on an ss+em suor+ed b doubango rame$or%

    (su6* as ndroid: Smbian S0: ;indo$s Mobi9e: iP*one: Ninu: ;indo$s HP/Vis+a/B: M' =SH: 8ni-i%e ss+ems O). I+ is used +o +es+ a99 SIP and media ea+ures. !*e rogram oers an

    e9egan+ and eas $a +o ee6u+e man 6ommands b using s6enarios. #or more inorma+ion abou+

    s6enarios: 9ease reer +o +*e se6+ion 24.2.

    24.1 DSS

    D((Ls+ands or Doubango (im9e (6ri+ing Language and is used +o $ri+e s6enarios. #or more

    inorma+ion: 9ease reer +o +*e ne+ se6+ions.

    24.1.1 Synop&i&

    8sage5 ++command (--[option] @@[level])++command (--[option] @@[level])commandcommandis manda+or and s*ou9d s+ar+ +*e 6ommand-9ine. >ou 6an $ri+e a 6ommand on se&era9 9ines

    b using ba6%-s9as*es (UU). Ao+* optionoptionand le

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    61/66

    V1.0.0 (2010-04)

    o+ion.

    Le4el /lias Descripion &ample

    s+a6% s+ S+a6%-9e&e9 o+ion TTs+

    session ss Session-9e&e9 o+ion TTss

    a6+ion reKues+: a: r 6+ion-9e&e9 o+ion TTa

    24.1.4 Comm'n)&

    n a9ias is a s*or+ name used +o iden+i a 6ommand.

    Command /lias Reuired 2pions 2pional 2pions Descripion

    audio,7 a +o Ma%es audio 6a99.

    audio&ideo,7 a& +o Ma%es audio/&ideo 6a99.

    6onig-session 6ss sid+7 'onigures an session (?"GIS!"?: P8AISou 6an

    use --a +o se+ +*e a9oad.

    &ideo

    ,7 37

    & *eader: a: +o Ma%es &ideo 6a99.

    +8se LLdum +o re+rie&e +*e sid (a.%.a session iden+iier),!*is 6ommand s*ou9d on9 be ee6u+ed i +*e s+a6% is running. !o run +*e s+a6%: use LLrun3totoo+ion is no+ reKuired bu+ s*ou9d be se+: o+*er$ise: +*e reKues+ $i99 be sen+ +o ourse9

    "am9es5

    'onigure +*e S+a6% (QQcstQQcst or QQcon,ig@stackQQcon,ig@stack)

    QQcst @@realm dou/ango.org @@impi /o/[email protected] @@impu sip/o/QQcst @@realm dou/ango.org @@impi /o/[email protected] @@impu sip/o/[email protected] @@[email protected] @@p=dmamadoumamadou @@header Pri

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    62/66

    V1.0.0 (2010-04)

    QQsu/ @@to sipmamadouims.inex/ee.com @@expires XMCC @@header Eou 6an 6on+inue +o +e in our 6ommands +o +*e Y6ommand rom+s in ara99e9

    $i+* +*e ee6u+ion o +*e s6enario.

    !o e9ain *o$ s6enarios 6ou9d be $ri++en: $e $i99 ana9se an eam9e i9e (rerodu6ed be9o$) s+e

    b s+e. !*is i9e 6on+ains 14 s+es (rom 0-13).

    ++ $or more in,ormation a/out scenarios; please re,er to the ProgrammerGs !uide++ $or more in,ormation a/out scenarios; please re,er to the ProgrammerGs !uide

    + C @ userGs parameters (like ANI@1 +de,ine)+ C @ userGs parameters (like ANI@1 +de,ine)

    HHdomain [email protected] [email protected]

    HHuser /o/HHuser /o/

    HHp=d msecretHHp=d msecret

    HHprox_ip -]>.-MR.C.-X + IP address or $bDNHHprox_ip -]>.-MR.C.-X + IP address or $bDN

    HHprox_port CMCHHprox_port CMC

    HHprox_trans udp + udp; tcp; tls or sctpHHprox_trans udp + udp; tcp; tls or sctp

    HHexpires -CC + expires used / all dialogsHHexpires -CC + expires used / all dialogs

    HHsleep@sec -.C + num/er o, seconds to =ait /e,ore sending next sip messageHHsleep@sec -.C + num/er o, seconds to =ait /e,ore sending next sip message

    HHreg@sidHHreg@sid

    HHsu/@reg@sidHHsu/@reg@sid

    HHsu/@pres@sidHHsu/@pres@sid

    HHpu/@sidHHpu/@sid

    doubango Programmers Guide

    2

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    63/66

    V1.0.0 (2010-04)

    + - @ con,igure the stack+ - @ con,igure the stack

    QQcst @@realm (domain) @@impi (user)(domain) @@impu sip(user)(domain)QQcst @@realm (domain) @@impi (user)(domain) @@impu sip(user)(domain)@@p=d (p=d) U@@p=d (p=d) U

    @@pcsc,@ip (prox_ip) @@pcsc,@port (prox_port) @@pcsc,@trans @@pcsc,@ip (prox_ip) @@pcsc,@port (prox_port) @@pcsc,@trans (prox_trans)U(prox_trans)U

    @@header Pri

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    64/66

    V1.0.0 (2010-04)

    + -- @ unregister+ -- @ unregister

    QQhu @@sid (reg@sid)QQhu @@sid (reg@sid)

    + -> @ sleep+ -> @ sleep

    QQsleep @@sec (sleep@sec)QQsleep @@sec (sleep@sec)

    + -X @ Exit the application+ -X @ Exit the application

    QQeQQe

    "4amp%".n

    99 6ommands (++++): o+ions (----) and 9e&e9s (@@@@) used in +*is i9e are e9ained in +*e re&ious

    se6+ions. !*ere is +*e 9is+ o a99 reser&ed smbo9s5

    1. ##is used +o 6ommen+ (ignore) 9ines. !*is smbo9 6an be used a+ +*e beginning or midd9e o a

    9ine.

    2. ++++is used +o ee6u+e a 6ommand. S*ou9d a9$as be a+ +*e beginning o a 9ine. Suor+ed6ommands are 9is+ed a+ se6+ion 24.1.4.

    3. -- is used +o se+ 6ommand o+ions. S*ou9d a9$as be used $i+* a 6ommand. Suor+ed

    o+ions are 9is+ed a+ se6+ion 24.1.2.

    4. @@@@ is used +o deined +*e 9e&e9 a+ $*i6* +*e o+ion s*ou9d be used. Suor+ed 9e&e9s are

    9is+ed a+ se6+ion 24.1.3.

    F. %%%% is used +o de69are users arame+ers. I+ is eKui&a9en+ +o 7SI-' Rdeine ma6ro. In our

    eam9e: HHdomain [email protected] [email protected] eKui&a9en+ +o +de,ine domain [email protected]+de,ine domain [email protected].

    . $$$$ is used +o rin+ +*e &a9ue o a re&ious9 deined users arame+er. Y( and Y) aren+*eses

    are o+iona99 used +o de9imi+ +*e name o +*e arame+er. In our eam9e: (domain)(domain)$i99

    rin+ [email protected]@ims.test.

    B. >>>> is used +o redire6+ +*e sid (session id) &a9ue in+o a users arame+er. !*is arame+er

    6ou9d be used 9a+er +o *ang-u or reres* a session.

    C. \\(ba6%s9as*) is used +o $ri+e mu9+i-9ine 6ommands. "a6* 9ine s*ou9d ends $i+* +*is smbo9:

    e6e+ +*e 9as+ one.

    (ep") e69are a99 users arame+ers. reg@sidreg@sid: su/@reg@sid;su/@reg@sid; su/@pres@sidsu/@pres@sid and pu/@sidpu/@sid are

    &a9ue9ess arame+ers used +o s+ore dnami6a99 genera+ed session ids (sid). 8sers arame+ers are

    6ross-s6enario: $*i6* means +*a+ embedded s6enarios (LLsn) 6an a9so reeren6e +*em. n eam9e

    o embedded s6enario is gi&en a+ sep".. !*is embedded s6enario (ub9is*.sn) $i99 use pu/@sidpu/@sid +o

    s+ore +*e &a9ue o i+s session iden+iier. s a s6enario is ee6u+ed 9ine b 9ine: ou s*ou9d de69are ( %%

    %%) our arame+ers beore beginning +o reeren6e ($$$$) +*em.

    (ep"+ 'onigures +*e s+a6%. QQcstQQcst is s*or+ or QQcon,ig@stackQQcon,ig@stack. #or eam9e: @@impu sip@@impu sip

    (user)(domain)(user)(domain) is used +o se+ +*e users IMP8 (IMS Pub9i6 Iden+i+). !*e rero6essor $i99

    6*ange +*is ormer s+a+emen+ in+o @@impu sip/o/[email protected]@@impu sip/o/[email protected]. s +*ere is no 9e&e9: a99 *eaders

    (--*eader) $i99 be added a+ s+a6% 9e&e9.

    (ep",?uns +*e s+a6%. QQrQQris s*or+ or QQrunQQrun. !*is 6ommand is manda+or and s*ou9d be ee6u+ed

    beore s+ar+ing +o send an SIP message.

    doubango Programmers Guide

    4

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    65/66

    V1.0.0 (2010-04)

    (ep"3Sends SIP ?"GIS!"? message. QQregQQreg is s*or+ or QQregisterQQregister. nd QQxpQQxp is s*or+ or QQ

    QexpiresQexpires. @@caps@@capso+ion is used +o se+ +*e users 6aabi9i+ies. !*e session id: $*i6* is au+oma+i6a99

    genera+ed (or uniKueness) b +*e s+a6%: is s+ored (>>>>) in HHreg@sidHHreg@sidarame+er or 9a+er use. !*e

    *eader added +o +*e reKues+ $i99 be reeren6ed a+ a6+ion-9e&e9 (@@@@): $*i6* means +*a+ on9 +*e ini+ia9

    ?"GIS!"? $i99 6on+ain +*is *eader. I +*e 9e&e9 o+ion $as missing: +*en +*is *eader $ou9d be

    added a+ session-9e&e9 (bo+* ini+ia9 and subseKuen+ reKues+s).

    (ep"-Pauses (1.0 se6ond) +*e users main +*read. !*e s+a6% $i99 6on+inue +o run in ba6%ground. In

    +*is 6ase: $e use +*is 6ommand +o gi&e +*e s+a6% +*e +ime +o 6om9e+e +*e regis+ra+ion ro6ess. In

    ne+ re9eases: 6ond$ai+s $i99 be used.

    (ep"5S8AS'?IA" +o reg e&en+ a6%age. QQsu/QQsu/is s*or+ or QQsu/cri/eQQsu/cri/e. !*e session id $i99 be

    s+ored (>>>>) in HHsu/@reg@sidHHsu/@reg@sidarame+er or 9a+er use. s +*ere are no 9e&e9s: a99 o+ions $i99 be

    added a+ session-9e&e9. In +*is 6ommand: @@to sip(user)(domain)@@to sip(user)(domain)o+ion is used +o se+ +*e

    des+ina+ion SIP 8?I (!o *eader and ?eKues+ 8?I). !*e rero6essor $i99 6*ange +*is ormer

    s+a+emen+ in+o @@to sip/o/[email protected]@@to sip/o/[email protected].

    (ep"6S8AS'?IA" +o resen6e e&en+ a6%age. See (ep"5or more des6ri+ion.

    (ep"."e6u+e an embedded s6enario. + +*is s+e: +*e in+erre+er $i99 read: 9oad: rero6ess +*enee6u+e +*is e+erna9 s6enario. !*is means +*a+ +*e 6ommands deined in +*is e+erna9 s6enario $i99

    be ee6u+ed beore s+es C-13. >ou 6an use +*is 6ommand (QQsnQQsn) in+o s6enarios +o orm an ee6u+ion

    6*ain (9i%e 7SI-' +include+include). 99 arame+ers deined in one s6enario $i99 be &isib9e +o a99 o+*ers:

    un9ess +*e are de69ared a+er +*e s6enario is 9oaded.

    (ep"8See (ep"-or more inorma+ion. !*e dieren6e $i+* sep"-is +*a+ +*e main +*read $i99

    ause un+i9 +*e user resses "7!"? as +*e number o se6onds is U0 (-1 in +*is 6ase).

    (ep"*Sends unsubs6ribe reKues+s or bo+* resen6e and reg e&en+ a6%ages. QQhuQQhuis s*or+ or QQ

    QhangupQhangup. @@sid@@sido+ion is used +o deine $*i6* session +o *ang-u.

    (ep"+)See (ep"-or more inorma+ion.(ep"++Sends unregis+er reKues+. QQhuQQhuis s*or+ or QQhangupQQhangup. @@sid@@sido+ion is used +o deine $*i6*

    session +o *ang-u.

    (ep"+,See (ep"-or more inorma+ion.

    (ep"+3"i+s +*e a9i6a+ion5 QQeQQeis s*or+ or QQexitQQexit. ;*en ou 6a99 +*is 6ommand beore *anging

    u a99 sessions: +*en +*e s+a6% $i99 roer9 *ang +*em u b s+ar+ing +o s*u+do$n non-regis+er

    sessions.

    24.2.2 H'cing t9e A+#

    =n some emu9a+ors: su6* as Goog9e ndroid or ;indo$s mobi9e: +*e IP address and or+ on $*i6*

    $e bound +o is no+ rou+ab9e. !*is IP address and or+ is used in +*e 'on+a6+Q *eader +o orm our=?. =n ;indo$s Mobi9e: +*e $or%around is +o 6rad9e +*e emu9a+or in order +o *a&e +*e same

    address +*an +*e *os+ ma6*ine. =n Goog9e ndroid: ou s*ou9d se+ +*e &a9ue o *A1_A%'*A1_A%' ma6ro

    (rom (D%BAN!%_*%6E)4tinDE6%4demo_con,ig.h(D%BAN!%_*%6E)4tinDE6%4demo_con,ig.h) +o 1 and 6*ange our s6enario +o send a SIP

    =P!I=7S (QQoptQQopt) beore an o+*er reKues+. !*is on9 $or%s i our ser&er suor+s rporas er

    ?#' 3FC1 and =P!I=7S reKues+s as er ?#' 321 se6+ion 11. QQsleepQQsleep6ommand 6ou9d be used +o

    a99o$ +*e =P!I=7S reKues+-resonse +o 6om9e+e beore sending +*e ne+ reKues+s.

    24.2.3 Common %&eC'&e&

    #or a99 use-6ases 9is+ed be9o$: ou 6an use ba6%s9as* (_) 6*ara6+ers +o $ri+e our 6ommand on

    se&era9 9ines.1. Pub9is* our resen6e

    QQpu/ @@toQQpu/ @@to sip(user)(domain)sip(user)(domain)@@header 1ontent@Tpe?application4pid,Qxml a @@pa@@header 1ontent@Tpe?application4pid,Qxml a @@pa

    doubango Programmers Guide

    F

  • 7/26/2019 DOUBANGO VoIP stack programer Guide

    66/66

    V1.0.0 (2010-04)

    \xml