res_pjsip.c 205 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2013, Digium, Inc.
  5. *
  6. * Mark Michelson <mmichelson@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. #include "asterisk.h"
  19. #include <pjsip.h>
  20. /* Needed for SUBSCRIBE, NOTIFY, and PUBLISH method definitions */
  21. #include <pjsip_simple.h>
  22. #include <pjsip/sip_transaction.h>
  23. #include <pj/timer.h>
  24. #include <pjlib.h>
  25. #include <pjmedia/errno.h>
  26. #include "asterisk/res_pjsip.h"
  27. #include "res_pjsip/include/res_pjsip_private.h"
  28. #include "asterisk/linkedlists.h"
  29. #include "asterisk/logger.h"
  30. #include "asterisk/lock.h"
  31. #include "asterisk/utils.h"
  32. #include "asterisk/astobj2.h"
  33. #include "asterisk/module.h"
  34. #include "asterisk/threadpool.h"
  35. #include "asterisk/taskprocessor.h"
  36. #include "asterisk/uuid.h"
  37. #include "asterisk/sorcery.h"
  38. #include "asterisk/file.h"
  39. #include "asterisk/cli.h"
  40. #include "asterisk/res_pjsip_cli.h"
  41. #include "asterisk/test.h"
  42. #include "asterisk/res_pjsip_presence_xml.h"
  43. #include "asterisk/res_pjproject.h"
  44. /*** MODULEINFO
  45. <depend>pjproject</depend>
  46. <depend>res_pjproject</depend>
  47. <depend>res_sorcery_config</depend>
  48. <depend>res_sorcery_memory</depend>
  49. <depend>res_sorcery_astdb</depend>
  50. <use type="module">res_statsd</use>
  51. <support_level>core</support_level>
  52. ***/
  53. /*** DOCUMENTATION
  54. <configInfo name="res_pjsip" language="en_US">
  55. <synopsis>SIP Resource using PJProject</synopsis>
  56. <configFile name="pjsip.conf">
  57. <configObject name="endpoint">
  58. <synopsis>Endpoint</synopsis>
  59. <description><para>
  60. The <emphasis>Endpoint</emphasis> is the primary configuration object.
  61. It contains the core SIP related options only, endpoints are <emphasis>NOT</emphasis>
  62. dialable entries of their own. Communication with another SIP device is
  63. accomplished via Addresses of Record (AoRs) which have one or more
  64. contacts associated with them. Endpoints <emphasis>NOT</emphasis> configured to
  65. use a <literal>transport</literal> will default to first transport found
  66. in <filename>pjsip.conf</filename> that matches its type.
  67. </para>
  68. <para>Example: An Endpoint has been configured with no transport.
  69. When it comes time to call an AoR, PJSIP will find the
  70. first transport that matches the type. A SIP URI of <literal>sip:5000@[11::33]</literal>
  71. will use the first IPv6 transport and try to send the request.
  72. </para>
  73. <para>If the anonymous endpoint identifier is in use an endpoint with the name
  74. "anonymous@domain" will be searched for as a last resort. If this is not found
  75. it will fall back to searching for "anonymous". If neither endpoints are found
  76. the anonymous endpoint identifier will not return an endpoint and anonymous
  77. calling will not be possible.
  78. </para>
  79. </description>
  80. <configOption name="100rel" default="yes">
  81. <synopsis>Allow support for RFC3262 provisional ACK tags</synopsis>
  82. <description>
  83. <enumlist>
  84. <enum name="no" />
  85. <enum name="required" />
  86. <enum name="yes" />
  87. </enumlist>
  88. </description>
  89. </configOption>
  90. <configOption name="aggregate_mwi" default="yes">
  91. <synopsis>Condense MWI notifications into a single NOTIFY.</synopsis>
  92. <description><para>When enabled, <replaceable>aggregate_mwi</replaceable> condenses message
  93. waiting notifications from multiple mailboxes into a single NOTIFY. If it is disabled,
  94. individual NOTIFYs are sent for each mailbox.</para></description>
  95. </configOption>
  96. <configOption name="allow">
  97. <synopsis>Media Codec(s) to allow</synopsis>
  98. </configOption>
  99. <configOption name="allow_overlap" default="yes">
  100. <synopsis>Enable RFC3578 overlap dialing support.</synopsis>
  101. </configOption>
  102. <configOption name="aors">
  103. <synopsis>AoR(s) to be used with the endpoint</synopsis>
  104. <description><para>
  105. List of comma separated AoRs that the endpoint should be associated with.
  106. </para></description>
  107. </configOption>
  108. <configOption name="auth">
  109. <synopsis>Authentication Object(s) associated with the endpoint</synopsis>
  110. <description><para>
  111. This is a comma-delimited list of <replaceable>auth</replaceable> sections defined
  112. in <filename>pjsip.conf</filename> to be used to verify inbound connection attempts.
  113. </para><para>
  114. Endpoints without an authentication object
  115. configured will allow connections without verification.</para>
  116. <note><para>
  117. Using the same auth section for inbound and outbound
  118. authentication is not recommended. There is a difference in
  119. meaning for an empty realm setting between inbound and outbound
  120. authentication uses. See the auth realm description for details.
  121. </para></note>
  122. </description>
  123. </configOption>
  124. <configOption name="callerid">
  125. <synopsis>CallerID information for the endpoint</synopsis>
  126. <description><para>
  127. Must be in the format <literal>Name &lt;Number&gt;</literal>,
  128. or only <literal>&lt;Number&gt;</literal>.
  129. </para></description>
  130. </configOption>
  131. <configOption name="callerid_privacy">
  132. <synopsis>Default privacy level</synopsis>
  133. <description>
  134. <enumlist>
  135. <enum name="allowed_not_screened" />
  136. <enum name="allowed_passed_screen" />
  137. <enum name="allowed_failed_screen" />
  138. <enum name="allowed" />
  139. <enum name="prohib_not_screened" />
  140. <enum name="prohib_passed_screen" />
  141. <enum name="prohib_failed_screen" />
  142. <enum name="prohib" />
  143. <enum name="unavailable" />
  144. </enumlist>
  145. </description>
  146. </configOption>
  147. <configOption name="callerid_tag">
  148. <synopsis>Internal id_tag for the endpoint</synopsis>
  149. </configOption>
  150. <configOption name="context">
  151. <synopsis>Dialplan context for inbound sessions</synopsis>
  152. </configOption>
  153. <configOption name="direct_media_glare_mitigation" default="none">
  154. <synopsis>Mitigation of direct media (re)INVITE glare</synopsis>
  155. <description>
  156. <para>
  157. This setting attempts to avoid creating INVITE glare scenarios
  158. by disabling direct media reINVITEs in one direction thereby allowing
  159. designated servers (according to this option) to initiate direct
  160. media reINVITEs without contention and significantly reducing call
  161. setup time.
  162. </para>
  163. <para>
  164. A more detailed description of how this option functions can be found on
  165. the Asterisk wiki https://wiki.asterisk.org/wiki/display/AST/SIP+Direct+Media+Reinvite+Glare+Avoidance
  166. </para>
  167. <enumlist>
  168. <enum name="none" />
  169. <enum name="outgoing" />
  170. <enum name="incoming" />
  171. </enumlist>
  172. </description>
  173. </configOption>
  174. <configOption name="direct_media_method" default="invite">
  175. <synopsis>Direct Media method type</synopsis>
  176. <description>
  177. <para>Method for setting up Direct Media between endpoints.</para>
  178. <enumlist>
  179. <enum name="invite" />
  180. <enum name="reinvite">
  181. <para>Alias for the <literal>invite</literal> value.</para>
  182. </enum>
  183. <enum name="update" />
  184. </enumlist>
  185. </description>
  186. </configOption>
  187. <configOption name="trust_connected_line">
  188. <synopsis>Accept Connected Line updates from this endpoint</synopsis>
  189. </configOption>
  190. <configOption name="send_connected_line">
  191. <synopsis>Send Connected Line updates to this endpoint</synopsis>
  192. </configOption>
  193. <configOption name="connected_line_method" default="invite">
  194. <synopsis>Connected line method type</synopsis>
  195. <description>
  196. <para>Method used when updating connected line information.</para>
  197. <enumlist>
  198. <enum name="invite">
  199. <para>When set to <literal>invite</literal>, check the remote's Allow header and
  200. if UPDATE is allowed, send UPDATE instead of INVITE to avoid SDP
  201. renegotiation. If UPDATE is not Allowed, send INVITE.</para>
  202. </enum>
  203. <enum name="reinvite">
  204. <para>Alias for the <literal>invite</literal> value.</para>
  205. </enum>
  206. <enum name="update">
  207. <para>If set to <literal>update</literal>, send UPDATE regardless of what the remote
  208. Allows. </para>
  209. </enum>
  210. </enumlist>
  211. </description>
  212. </configOption>
  213. <configOption name="direct_media" default="yes">
  214. <synopsis>Determines whether media may flow directly between endpoints.</synopsis>
  215. </configOption>
  216. <configOption name="disable_direct_media_on_nat" default="no">
  217. <synopsis>Disable direct media session refreshes when NAT obstructs the media session</synopsis>
  218. </configOption>
  219. <configOption name="disallow">
  220. <synopsis>Media Codec(s) to disallow</synopsis>
  221. </configOption>
  222. <configOption name="dtmf_mode" default="rfc4733">
  223. <synopsis>DTMF mode</synopsis>
  224. <description>
  225. <para>This setting allows to choose the DTMF mode for endpoint communication.</para>
  226. <enumlist>
  227. <enum name="rfc4733">
  228. <para>DTMF is sent out of band of the main audio stream. This
  229. supercedes the older <emphasis>RFC-2833</emphasis> used within
  230. the older <literal>chan_sip</literal>.</para>
  231. </enum>
  232. <enum name="inband">
  233. <para>DTMF is sent as part of audio stream.</para>
  234. </enum>
  235. <enum name="info">
  236. <para>DTMF is sent as SIP INFO packets.</para>
  237. </enum>
  238. <enum name="auto">
  239. <para>DTMF is sent as RFC 4733 if the other side supports it or as INBAND if not.</para>
  240. </enum>
  241. <enum name="auto_info">
  242. <para>DTMF is sent as RFC 4733 if the other side supports it or as SIP INFO if not.</para>
  243. </enum>
  244. </enumlist>
  245. </description>
  246. </configOption>
  247. <configOption name="media_address">
  248. <synopsis>IP address used in SDP for media handling</synopsis>
  249. <description><para>
  250. At the time of SDP creation, the IP address defined here will be used as
  251. the media address for individual streams in the SDP.
  252. </para>
  253. <note><para>
  254. Be aware that the <literal>external_media_address</literal> option, set in Transport
  255. configuration, can also affect the final media address used in the SDP.
  256. </para></note>
  257. </description>
  258. </configOption>
  259. <configOption name="bind_rtp_to_media_address">
  260. <synopsis>Bind the RTP instance to the media_address</synopsis>
  261. <description><para>
  262. If media_address is specified, this option causes the RTP instance to be bound to the
  263. specified ip address which causes the packets to be sent from that address.
  264. </para>
  265. </description>
  266. </configOption>
  267. <configOption name="force_rport" default="yes">
  268. <synopsis>Force use of return port</synopsis>
  269. </configOption>
  270. <configOption name="ice_support" default="no">
  271. <synopsis>Enable the ICE mechanism to help traverse NAT</synopsis>
  272. </configOption>
  273. <configOption name="identify_by">
  274. <synopsis>Way(s) for the endpoint to be identified</synopsis>
  275. <description>
  276. <para>Endpoints and AORs can be identified in multiple ways. This
  277. option is a comma separated list of methods the endpoint can be
  278. identified.
  279. </para>
  280. <note><para>
  281. This option controls both how an endpoint is matched for incoming
  282. traffic and also how an AOR is determined if a registration
  283. occurs. You must list at least one method that also matches for
  284. AORs or the registration will fail.
  285. </para></note>
  286. <enumlist>
  287. <enum name="username">
  288. <para>Matches the endpoint or AOR ID based on the username
  289. and domain in the From header (or To header for AORs). If
  290. an exact match on both username and domain/realm fails, the
  291. match is retried with just the username.
  292. </para>
  293. </enum>
  294. <enum name="auth_username">
  295. <para>Matches the endpoint or AOR ID based on the username
  296. and realm in the Authentication header. If an exact match
  297. on both username and domain/realm fails, the match is
  298. retried with just the username.
  299. </para>
  300. <note><para>This method of identification has some security
  301. considerations because an Authentication header is not
  302. present on the first message of a dialog when digest
  303. authentication is used. The client can't generate it until
  304. the server sends the challenge in a 401 response. Since
  305. Asterisk normally sends a security event when an incoming
  306. request can't be matched to an endpoint, using this method
  307. requires that the security event be deferred until a request
  308. is received with the Authentication header and only
  309. generated if the username doesn't result in a match. This
  310. may result in a delay before an attack is recognized. You
  311. can control how many unmatched requests are received from
  312. a single ip address before a security event is generated
  313. using the <literal>unidentified_request</literal>
  314. parameters in the "global" configuration object.
  315. </para></note>
  316. </enum>
  317. <enum name="ip">
  318. <para>Matches the endpoint based on the source IP address.
  319. </para>
  320. <para>This method of identification is not configured here
  321. but simply allowed by this configuration option. See the
  322. documentation for the <literal>identify</literal>
  323. configuration section for more details on this method of
  324. endpoint identification.
  325. </para>
  326. </enum>
  327. <enum name="header">
  328. <para>Matches the endpoint based on a configured SIP header
  329. value.
  330. </para>
  331. <para>This method of identification is not configured here
  332. but simply allowed by this configuration option. See the
  333. documentation for the <literal>identify</literal>
  334. configuration section for more details on this method of
  335. endpoint identification.
  336. </para>
  337. </enum>
  338. </enumlist>
  339. </description>
  340. </configOption>
  341. <configOption name="redirect_method">
  342. <synopsis>How redirects received from an endpoint are handled</synopsis>
  343. <description><para>
  344. When a redirect is received from an endpoint there are multiple ways it can be handled.
  345. If this option is set to <literal>user</literal> the user portion of the redirect target
  346. is treated as an extension within the dialplan and dialed using a Local channel. If this option
  347. is set to <literal>uri_core</literal> the target URI is returned to the dialing application
  348. which dials it using the PJSIP channel driver and endpoint originally used. If this option is
  349. set to <literal>uri_pjsip</literal> the redirect occurs within chan_pjsip itself and is not exposed
  350. to the core at all. The <literal>uri_pjsip</literal> option has the benefit of being more efficient
  351. and also supporting multiple potential redirect targets. The con is that since redirection occurs
  352. within chan_pjsip redirecting information is not forwarded and redirection can not be
  353. prevented.
  354. </para>
  355. <enumlist>
  356. <enum name="user" />
  357. <enum name="uri_core" />
  358. <enum name="uri_pjsip" />
  359. </enumlist>
  360. </description>
  361. </configOption>
  362. <configOption name="mailboxes">
  363. <synopsis>NOTIFY the endpoint when state changes for any of the specified mailboxes</synopsis>
  364. <description><para>
  365. Asterisk will send unsolicited MWI NOTIFY messages to the endpoint when state
  366. changes happen for any of the specified mailboxes. More than one mailbox can be
  367. specified with a comma-delimited string. app_voicemail mailboxes must be specified
  368. as mailbox@context; for example: mailboxes=6001@default. For mailboxes provided by
  369. external sources, such as through the res_external_mwi module, you must specify
  370. strings supported by the external system.
  371. </para><para>
  372. For endpoints that SUBSCRIBE for MWI, use the <literal>mailboxes</literal> option in your AOR
  373. configuration.
  374. </para></description>
  375. </configOption>
  376. <configOption name="mwi_subscribe_replaces_unsolicited">
  377. <synopsis>An MWI subscribe will replace sending unsolicited NOTIFYs</synopsis>
  378. </configOption>
  379. <configOption name="voicemail_extension">
  380. <synopsis>The voicemail extension to send in the NOTIFY Message-Account header</synopsis>
  381. </configOption>
  382. <configOption name="moh_suggest" default="default">
  383. <synopsis>Default Music On Hold class</synopsis>
  384. </configOption>
  385. <configOption name="outbound_auth">
  386. <synopsis>Authentication object(s) used for outbound requests</synopsis>
  387. <description><para>
  388. This is a comma-delimited list of <replaceable>auth</replaceable>
  389. sections defined in <filename>pjsip.conf</filename> used to respond
  390. to outbound connection authentication challenges.</para>
  391. <note><para>
  392. Using the same auth section for inbound and outbound
  393. authentication is not recommended. There is a difference in
  394. meaning for an empty realm setting between inbound and outbound
  395. authentication uses. See the auth realm description for details.
  396. </para></note>
  397. </description>
  398. </configOption>
  399. <configOption name="outbound_proxy">
  400. <synopsis>Full SIP URI of the outbound proxy used to send requests</synopsis>
  401. </configOption>
  402. <configOption name="rewrite_contact">
  403. <synopsis>Allow Contact header to be rewritten with the source IP address-port</synopsis>
  404. <description><para>
  405. On inbound SIP messages from this endpoint, the Contact header or an
  406. appropriate Record-Route header will be changed to have the source IP
  407. address and port. This option does not affect outbound messages sent to
  408. this endpoint. This option helps servers communicate with endpoints
  409. that are behind NATs. This option also helps reuse reliable transport
  410. connections such as TCP and TLS.
  411. </para></description>
  412. </configOption>
  413. <configOption name="rtp_ipv6" default="no">
  414. <synopsis>Allow use of IPv6 for RTP traffic</synopsis>
  415. </configOption>
  416. <configOption name="rtp_symmetric" default="no">
  417. <synopsis>Enforce that RTP must be symmetric</synopsis>
  418. </configOption>
  419. <configOption name="send_diversion" default="yes">
  420. <synopsis>Send the Diversion header, conveying the diversion
  421. information to the called user agent</synopsis>
  422. </configOption>
  423. <configOption name="send_pai" default="no">
  424. <synopsis>Send the P-Asserted-Identity header</synopsis>
  425. </configOption>
  426. <configOption name="send_rpid" default="no">
  427. <synopsis>Send the Remote-Party-ID header</synopsis>
  428. </configOption>
  429. <configOption name="rpid_immediate" default="no">
  430. <synopsis>Immediately send connected line updates on unanswered incoming calls.</synopsis>
  431. <description>
  432. <para>When enabled, immediately send <emphasis>180 Ringing</emphasis>
  433. or <emphasis>183 Progress</emphasis> response messages to the
  434. caller if the connected line information is updated before
  435. the call is answered. This can send a <emphasis>180 Ringing</emphasis>
  436. response before the call has even reached the far end. The
  437. caller can start hearing ringback before the far end even gets
  438. the call. Many phones tend to grab the first connected line
  439. information and refuse to update the display if it changes. The
  440. first information is not likely to be correct if the call
  441. goes to an endpoint not under the control of this Asterisk
  442. box.</para>
  443. <para>When disabled, a connected line update must wait for
  444. another reason to send a message with the connected line
  445. information to the caller before the call is answered. You can
  446. trigger the sending of the information by using an appropriate
  447. dialplan application such as <emphasis>Ringing</emphasis>.</para>
  448. </description>
  449. </configOption>
  450. <configOption name="timers_min_se" default="90">
  451. <synopsis>Minimum session timers expiration period</synopsis>
  452. <description><para>
  453. Minimum session timer expiration period. Time in seconds.
  454. </para></description>
  455. </configOption>
  456. <configOption name="timers" default="yes">
  457. <synopsis>Session timers for SIP packets</synopsis>
  458. <description>
  459. <enumlist>
  460. <enum name="no" />
  461. <enum name="yes" />
  462. <enum name="required" />
  463. <enum name="always" />
  464. <enum name="forced"><para>Alias of always</para></enum>
  465. </enumlist>
  466. </description>
  467. </configOption>
  468. <configOption name="timers_sess_expires" default="1800">
  469. <synopsis>Maximum session timer expiration period</synopsis>
  470. <description><para>
  471. Maximum session timer expiration period. Time in seconds.
  472. </para></description>
  473. </configOption>
  474. <configOption name="transport">
  475. <synopsis>Explicit transport configuration to use</synopsis>
  476. <description>
  477. <para>This will <emphasis>force</emphasis> the endpoint to use the
  478. specified transport configuration to send SIP messages. You need
  479. to already know what kind of transport (UDP/TCP/IPv4/etc) the
  480. endpoint device will use.
  481. </para>
  482. <note><para>Not specifying a transport will select the first
  483. configured transport in <filename>pjsip.conf</filename> which is
  484. compatible with the URI we are trying to contact.
  485. </para></note>
  486. <warning><para>Transport configuration is not affected by reloads. In order to
  487. change transports, a full Asterisk restart is required</para></warning>
  488. </description>
  489. </configOption>
  490. <configOption name="trust_id_inbound" default="no">
  491. <synopsis>Accept identification information received from this endpoint</synopsis>
  492. <description><para>This option determines whether Asterisk will accept
  493. identification from the endpoint from headers such as P-Asserted-Identity
  494. or Remote-Party-ID header. This option applies both to calls originating from the
  495. endpoint and calls originating from Asterisk. If <literal>no</literal>, the
  496. configured Caller-ID from pjsip.conf will always be used as the identity for
  497. the endpoint.</para></description>
  498. </configOption>
  499. <configOption name="trust_id_outbound" default="no">
  500. <synopsis>Send private identification details to the endpoint.</synopsis>
  501. <description><para>This option determines whether res_pjsip will send private
  502. identification information to the endpoint. If <literal>no</literal>,
  503. private Caller-ID information will not be forwarded to the endpoint.
  504. "Private" in this case refers to any method of restricting identification.
  505. Example: setting <replaceable>callerid_privacy</replaceable> to any
  506. <literal>prohib</literal> variation.
  507. Example: If <replaceable>trust_id_inbound</replaceable> is set to
  508. <literal>yes</literal>, the presence of a <literal>Privacy: id</literal>
  509. header in a SIP request or response would indicate the identification
  510. provided in the request is private.</para></description>
  511. </configOption>
  512. <configOption name="type">
  513. <synopsis>Must be of type 'endpoint'.</synopsis>
  514. </configOption>
  515. <configOption name="use_ptime" default="no">
  516. <synopsis>Use Endpoint's requested packetization interval</synopsis>
  517. </configOption>
  518. <configOption name="use_avpf" default="no">
  519. <synopsis>Determines whether res_pjsip will use and enforce usage of AVPF for this
  520. endpoint.</synopsis>
  521. <description><para>
  522. If set to <literal>yes</literal>, res_pjsip will use the AVPF or SAVPF RTP
  523. profile for all media offers on outbound calls and media updates and will
  524. decline media offers not using the AVPF or SAVPF profile.
  525. </para><para>
  526. If set to <literal>no</literal>, res_pjsip will use the AVP or SAVP RTP
  527. profile for all media offers on outbound calls and media updates, and will
  528. decline media offers not using the AVP or SAVP profile.
  529. </para></description>
  530. </configOption>
  531. <configOption name="force_avp" default="no">
  532. <synopsis>Determines whether res_pjsip will use and enforce usage of AVP,
  533. regardless of the RTP profile in use for this endpoint.</synopsis>
  534. <description><para>
  535. If set to <literal>yes</literal>, res_pjsip will use the AVP, AVPF, SAVP, or
  536. SAVPF RTP profile for all media offers on outbound calls and media updates including
  537. those for DTLS-SRTP streams.
  538. </para><para>
  539. If set to <literal>no</literal>, res_pjsip will use the respective RTP profile
  540. depending on configuration.
  541. </para></description>
  542. </configOption>
  543. <configOption name="media_use_received_transport" default="no">
  544. <synopsis>Determines whether res_pjsip will use the media transport received in the
  545. offer SDP in the corresponding answer SDP.</synopsis>
  546. <description><para>
  547. If set to <literal>yes</literal>, res_pjsip will use the received media transport.
  548. </para><para>
  549. If set to <literal>no</literal>, res_pjsip will use the respective RTP profile
  550. depending on configuration.
  551. </para></description>
  552. </configOption>
  553. <configOption name="media_encryption" default="no">
  554. <synopsis>Determines whether res_pjsip will use and enforce usage of media encryption
  555. for this endpoint.</synopsis>
  556. <description>
  557. <enumlist>
  558. <enum name="no"><para>
  559. res_pjsip will offer no encryption and allow no encryption to be setup.
  560. </para></enum>
  561. <enum name="sdes"><para>
  562. res_pjsip will offer standard SRTP setup via in-SDP keys. Encrypted SIP
  563. transport should be used in conjunction with this option to prevent
  564. exposure of media encryption keys.
  565. </para></enum>
  566. <enum name="dtls"><para>
  567. res_pjsip will offer DTLS-SRTP setup.
  568. </para></enum>
  569. </enumlist>
  570. </description>
  571. </configOption>
  572. <configOption name="media_encryption_optimistic" default="no">
  573. <synopsis>Determines whether encryption should be used if possible but does not terminate the
  574. session if not achieved.</synopsis>
  575. <description><para>
  576. This option only applies if <replaceable>media_encryption</replaceable> is
  577. set to <literal>sdes</literal> or <literal>dtls</literal>.
  578. </para></description>
  579. </configOption>
  580. <configOption name="g726_non_standard" default="no">
  581. <synopsis>Force g.726 to use AAL2 packing order when negotiating g.726 audio</synopsis>
  582. <description><para>
  583. When set to "yes" and an endpoint negotiates g.726 audio then use g.726 for AAL2
  584. packing order instead of what is recommended by RFC3551. Since this essentially
  585. replaces the underlying 'g726' codec with 'g726aal2' then 'g726aal2' needs to be
  586. specified in the endpoint's allowed codec list.
  587. </para></description>
  588. </configOption>
  589. <configOption name="inband_progress" default="no">
  590. <synopsis>Determines whether chan_pjsip will indicate ringing using inband
  591. progress.</synopsis>
  592. <description><para>
  593. If set to <literal>yes</literal>, chan_pjsip will send a 183 Session Progress
  594. when told to indicate ringing and will immediately start sending ringing
  595. as audio.
  596. </para><para>
  597. If set to <literal>no</literal>, chan_pjsip will send a 180 Ringing when told
  598. to indicate ringing and will NOT send it as audio.
  599. </para></description>
  600. </configOption>
  601. <configOption name="call_group">
  602. <synopsis>The numeric pickup groups for a channel.</synopsis>
  603. <description><para>
  604. Can be set to a comma separated list of numbers or ranges between the values
  605. of 0-63 (maximum of 64 groups).
  606. </para></description>
  607. </configOption>
  608. <configOption name="pickup_group">
  609. <synopsis>The numeric pickup groups that a channel can pickup.</synopsis>
  610. <description><para>
  611. Can be set to a comma separated list of numbers or ranges between the values
  612. of 0-63 (maximum of 64 groups).
  613. </para></description>
  614. </configOption>
  615. <configOption name="named_call_group">
  616. <synopsis>The named pickup groups for a channel.</synopsis>
  617. <description><para>
  618. Can be set to a comma separated list of case sensitive strings limited by
  619. supported line length.
  620. </para></description>
  621. </configOption>
  622. <configOption name="named_pickup_group">
  623. <synopsis>The named pickup groups that a channel can pickup.</synopsis>
  624. <description><para>
  625. Can be set to a comma separated list of case sensitive strings limited by
  626. supported line length.
  627. </para></description>
  628. </configOption>
  629. <configOption name="device_state_busy_at" default="0">
  630. <synopsis>The number of in-use channels which will cause busy to be returned as device state</synopsis>
  631. <description><para>
  632. When the number of in-use channels for the endpoint matches the devicestate_busy_at setting the
  633. PJSIP channel driver will return busy as the device state instead of in use.
  634. </para></description>
  635. </configOption>
  636. <configOption name="t38_udptl" default="no">
  637. <synopsis>Whether T.38 UDPTL support is enabled or not</synopsis>
  638. <description><para>
  639. If set to yes T.38 UDPTL support will be enabled, and T.38 negotiation requests will be accepted
  640. and relayed.
  641. </para></description>
  642. </configOption>
  643. <configOption name="t38_udptl_ec" default="none">
  644. <synopsis>T.38 UDPTL error correction method</synopsis>
  645. <description>
  646. <enumlist>
  647. <enum name="none"><para>
  648. No error correction should be used.
  649. </para></enum>
  650. <enum name="fec"><para>
  651. Forward error correction should be used.
  652. </para></enum>
  653. <enum name="redundancy"><para>
  654. Redundancy error correction should be used.
  655. </para></enum>
  656. </enumlist>
  657. </description>
  658. </configOption>
  659. <configOption name="t38_udptl_maxdatagram" default="0">
  660. <synopsis>T.38 UDPTL maximum datagram size</synopsis>
  661. <description><para>
  662. This option can be set to override the maximum datagram of a remote endpoint for broken
  663. endpoints.
  664. </para></description>
  665. </configOption>
  666. <configOption name="fax_detect" default="no">
  667. <synopsis>Whether CNG tone detection is enabled</synopsis>
  668. <description><para>
  669. This option can be set to send the session to the fax extension when a CNG tone is
  670. detected.
  671. </para></description>
  672. </configOption>
  673. <configOption name="fax_detect_timeout">
  674. <synopsis>How long into a call before fax_detect is disabled for the call</synopsis>
  675. <description><para>
  676. The option determines how many seconds into a call before the
  677. fax_detect option is disabled for the call. Setting the value
  678. to zero disables the timeout.
  679. </para></description>
  680. </configOption>
  681. <configOption name="t38_udptl_nat" default="no">
  682. <synopsis>Whether NAT support is enabled on UDPTL sessions</synopsis>
  683. <description><para>
  684. When enabled the UDPTL stack will send UDPTL packets to the source address of
  685. received packets.
  686. </para></description>
  687. </configOption>
  688. <configOption name="t38_udptl_ipv6" default="no">
  689. <synopsis>Whether IPv6 is used for UDPTL Sessions</synopsis>
  690. <description><para>
  691. When enabled the UDPTL stack will use IPv6.
  692. </para></description>
  693. </configOption>
  694. <configOption name="tone_zone">
  695. <synopsis>Set which country's indications to use for channels created for this endpoint.</synopsis>
  696. </configOption>
  697. <configOption name="language">
  698. <synopsis>Set the default language to use for channels created for this endpoint.</synopsis>
  699. </configOption>
  700. <configOption name="one_touch_recording" default="no">
  701. <synopsis>Determines whether one-touch recording is allowed for this endpoint.</synopsis>
  702. <see-also>
  703. <ref type="configOption">record_on_feature</ref>
  704. <ref type="configOption">record_off_feature</ref>
  705. </see-also>
  706. </configOption>
  707. <configOption name="record_on_feature" default="automixmon">
  708. <synopsis>The feature to enact when one-touch recording is turned on.</synopsis>
  709. <description>
  710. <para>When an INFO request for one-touch recording arrives with a Record header set to "on", this
  711. feature will be enabled for the channel. The feature designated here can be any built-in
  712. or dynamic feature defined in features.conf.</para>
  713. <note><para>This setting has no effect if the endpoint's one_touch_recording option is disabled</para></note>
  714. </description>
  715. <see-also>
  716. <ref type="configOption">one_touch_recording</ref>
  717. <ref type="configOption">record_off_feature</ref>
  718. </see-also>
  719. </configOption>
  720. <configOption name="record_off_feature" default="automixmon">
  721. <synopsis>The feature to enact when one-touch recording is turned off.</synopsis>
  722. <description>
  723. <para>When an INFO request for one-touch recording arrives with a Record header set to "off", this
  724. feature will be enabled for the channel. The feature designated here can be any built-in
  725. or dynamic feature defined in features.conf.</para>
  726. <note><para>This setting has no effect if the endpoint's one_touch_recording option is disabled</para></note>
  727. </description>
  728. <see-also>
  729. <ref type="configOption">one_touch_recording</ref>
  730. <ref type="configOption">record_on_feature</ref>
  731. </see-also>
  732. </configOption>
  733. <configOption name="rtp_engine" default="asterisk">
  734. <synopsis>Name of the RTP engine to use for channels created for this endpoint</synopsis>
  735. </configOption>
  736. <configOption name="allow_transfer" default="yes">
  737. <synopsis>Determines whether SIP REFER transfers are allowed for this endpoint</synopsis>
  738. </configOption>
  739. <configOption name="user_eq_phone" default="no">
  740. <synopsis>Determines whether a user=phone parameter is placed into the request URI if the user is determined to be a phone number</synopsis>
  741. </configOption>
  742. <configOption name="sdp_owner" default="-">
  743. <synopsis>String placed as the username portion of an SDP origin (o=) line.</synopsis>
  744. </configOption>
  745. <configOption name="sdp_session" default="Asterisk">
  746. <synopsis>String used for the SDP session (s=) line.</synopsis>
  747. </configOption>
  748. <configOption name="tos_audio">
  749. <synopsis>DSCP TOS bits for audio streams</synopsis>
  750. <description><para>
  751. See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
  752. </para></description>
  753. </configOption>
  754. <configOption name="tos_video">
  755. <synopsis>DSCP TOS bits for video streams</synopsis>
  756. <description><para>
  757. See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
  758. </para></description>
  759. </configOption>
  760. <configOption name="cos_audio">
  761. <synopsis>Priority for audio streams</synopsis>
  762. <description><para>
  763. See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
  764. </para></description>
  765. </configOption>
  766. <configOption name="cos_video">
  767. <synopsis>Priority for video streams</synopsis>
  768. <description><para>
  769. See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
  770. </para></description>
  771. </configOption>
  772. <configOption name="allow_subscribe" default="yes">
  773. <synopsis>Determines if endpoint is allowed to initiate subscriptions with Asterisk.</synopsis>
  774. </configOption>
  775. <configOption name="sub_min_expiry" default="60">
  776. <synopsis>The minimum allowed expiry time for subscriptions initiated by the endpoint.</synopsis>
  777. </configOption>
  778. <configOption name="from_user">
  779. <synopsis>Username to use in From header for requests to this endpoint.</synopsis>
  780. </configOption>
  781. <configOption name="mwi_from_user">
  782. <synopsis>Username to use in From header for unsolicited MWI NOTIFYs to this endpoint.</synopsis>
  783. </configOption>
  784. <configOption name="from_domain">
  785. <synopsis>Domain to user in From header for requests to this endpoint.</synopsis>
  786. </configOption>
  787. <configOption name="dtls_verify">
  788. <synopsis>Verify that the provided peer certificate is valid</synopsis>
  789. <description><para>
  790. This option only applies if <replaceable>media_encryption</replaceable> is
  791. set to <literal>dtls</literal>.
  792. </para></description>
  793. </configOption>
  794. <configOption name="dtls_rekey">
  795. <synopsis>Interval at which to renegotiate the TLS session and rekey the SRTP session</synopsis>
  796. <description><para>
  797. This option only applies if <replaceable>media_encryption</replaceable> is
  798. set to <literal>dtls</literal>.
  799. </para><para>
  800. If this is not set or the value provided is 0 rekeying will be disabled.
  801. </para></description>
  802. </configOption>
  803. <configOption name="dtls_cert_file">
  804. <synopsis>Path to certificate file to present to peer</synopsis>
  805. <description><para>
  806. This option only applies if <replaceable>media_encryption</replaceable> is
  807. set to <literal>dtls</literal>.
  808. </para></description>
  809. </configOption>
  810. <configOption name="dtls_private_key">
  811. <synopsis>Path to private key for certificate file</synopsis>
  812. <description><para>
  813. This option only applies if <replaceable>media_encryption</replaceable> is
  814. set to <literal>dtls</literal>.
  815. </para></description>
  816. </configOption>
  817. <configOption name="dtls_cipher">
  818. <synopsis>Cipher to use for DTLS negotiation</synopsis>
  819. <description><para>
  820. This option only applies if <replaceable>media_encryption</replaceable> is
  821. set to <literal>dtls</literal>.
  822. </para>
  823. <para>Many options for acceptable ciphers. See link for more:</para>
  824. <para>http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS
  825. </para></description>
  826. </configOption>
  827. <configOption name="dtls_ca_file">
  828. <synopsis>Path to certificate authority certificate</synopsis>
  829. <description><para>
  830. This option only applies if <replaceable>media_encryption</replaceable> is
  831. set to <literal>dtls</literal>.
  832. </para></description>
  833. </configOption>
  834. <configOption name="dtls_ca_path">
  835. <synopsis>Path to a directory containing certificate authority certificates</synopsis>
  836. <description><para>
  837. This option only applies if <replaceable>media_encryption</replaceable> is
  838. set to <literal>dtls</literal>.
  839. </para></description>
  840. </configOption>
  841. <configOption name="dtls_setup">
  842. <synopsis>Whether we are willing to accept connections, connect to the other party, or both.</synopsis>
  843. <description>
  844. <para>
  845. This option only applies if <replaceable>media_encryption</replaceable> is
  846. set to <literal>dtls</literal>.
  847. </para>
  848. <enumlist>
  849. <enum name="active"><para>
  850. res_pjsip will make a connection to the peer.
  851. </para></enum>
  852. <enum name="passive"><para>
  853. res_pjsip will accept connections from the peer.
  854. </para></enum>
  855. <enum name="actpass"><para>
  856. res_pjsip will offer and accept connections from the peer.
  857. </para></enum>
  858. </enumlist>
  859. </description>
  860. </configOption>
  861. <configOption name="dtls_fingerprint">
  862. <synopsis>Type of hash to use for the DTLS fingerprint in the SDP.</synopsis>
  863. <description>
  864. <para>
  865. This option only applies if <replaceable>media_encryption</replaceable> is
  866. set to <literal>dtls</literal>.
  867. </para>
  868. <enumlist>
  869. <enum name="SHA-256"></enum>
  870. <enum name="SHA-1"></enum>
  871. </enumlist>
  872. </description>
  873. </configOption>
  874. <configOption name="srtp_tag_32">
  875. <synopsis>Determines whether 32 byte tags should be used instead of 80 byte tags.</synopsis>
  876. <description><para>
  877. This option only applies if <replaceable>media_encryption</replaceable> is
  878. set to <literal>sdes</literal> or <literal>dtls</literal>.
  879. </para></description>
  880. </configOption>
  881. <configOption name="set_var">
  882. <synopsis>Variable set on a channel involving the endpoint.</synopsis>
  883. <description><para>
  884. When a new channel is created using the endpoint set the specified
  885. variable(s) on that channel. For multiple channel variables specify
  886. multiple 'set_var'(s).
  887. </para></description>
  888. </configOption>
  889. <configOption name="message_context">
  890. <synopsis>Context to route incoming MESSAGE requests to.</synopsis>
  891. <description><para>
  892. If specified, incoming MESSAGE requests will be routed to the indicated
  893. dialplan context. If no <replaceable>message_context</replaceable> is
  894. specified, then the <replaceable>context</replaceable> setting is used.
  895. </para></description>
  896. </configOption>
  897. <configOption name="accountcode">
  898. <synopsis>An accountcode to set automatically on any channels created for this endpoint.</synopsis>
  899. <description><para>
  900. If specified, any channel created for this endpoint will automatically
  901. have this accountcode set on it.
  902. </para></description>
  903. </configOption>
  904. <configOption name="rtp_keepalive">
  905. <synopsis>Number of seconds between RTP comfort noise keepalive packets.</synopsis>
  906. <description><para>
  907. At the specified interval, Asterisk will send an RTP comfort noise frame. This may
  908. be useful for situations where Asterisk is behind a NAT or firewall and must keep a
  909. hole open in order to allow for media to arrive at Asterisk.
  910. </para></description>
  911. </configOption>
  912. <configOption name="rtp_timeout" default="0">
  913. <synopsis>Maximum number of seconds without receiving RTP (while off hold) before terminating call.</synopsis>
  914. <description><para>
  915. This option configures the number of seconds without RTP (while off hold) before
  916. considering a channel as dead. When the number of seconds is reached the underlying
  917. channel is hung up. By default this option is set to 0, which means do not check.
  918. </para></description>
  919. </configOption>
  920. <configOption name="rtp_timeout_hold" default="0">
  921. <synopsis>Maximum number of seconds without receiving RTP (while on hold) before terminating call.</synopsis>
  922. <description><para>
  923. This option configures the number of seconds without RTP (while on hold) before
  924. considering a channel as dead. When the number of seconds is reached the underlying
  925. channel is hung up. By default this option is set to 0, which means do not check.
  926. </para></description>
  927. </configOption>
  928. <configOption name="acl">
  929. <synopsis>List of IP ACL section names in acl.conf</synopsis>
  930. <description><para>
  931. This matches sections configured in <literal>acl.conf</literal>. The value is
  932. defined as a list of comma-delimited section names.
  933. </para></description>
  934. </configOption>
  935. <configOption name="deny">
  936. <synopsis>List of IP addresses to deny access from</synopsis>
  937. <description><para>
  938. The value is a comma-delimited list of IP addresses. IP addresses may
  939. have a subnet mask appended. The subnet mask may be written in either
  940. CIDR or dotted-decimal notation. Separate the IP address and subnet
  941. mask with a slash ('/')
  942. </para></description>
  943. </configOption>
  944. <configOption name="permit">
  945. <synopsis>List of IP addresses to permit access from</synopsis>
  946. <description><para>
  947. The value is a comma-delimited list of IP addresses. IP addresses may
  948. have a subnet mask appended. The subnet mask may be written in either
  949. CIDR or dotted-decimal notation. Separate the IP address and subnet
  950. mask with a slash ('/')
  951. </para></description>
  952. </configOption>
  953. <configOption name="contact_acl">
  954. <synopsis>List of Contact ACL section names in acl.conf</synopsis>
  955. <description><para>
  956. This matches sections configured in <literal>acl.conf</literal>. The value is
  957. defined as a list of comma-delimited section names.
  958. </para></description>
  959. </configOption>
  960. <configOption name="contact_deny">
  961. <synopsis>List of Contact header addresses to deny</synopsis>
  962. <description><para>
  963. The value is a comma-delimited list of IP addresses. IP addresses may
  964. have a subnet mask appended. The subnet mask may be written in either
  965. CIDR or dotted-decimal notation. Separate the IP address and subnet
  966. mask with a slash ('/')
  967. </para></description>
  968. </configOption>
  969. <configOption name="contact_permit">
  970. <synopsis>List of Contact header addresses to permit</synopsis>
  971. <description><para>
  972. The value is a comma-delimited list of IP addresses. IP addresses may
  973. have a subnet mask appended. The subnet mask may be written in either
  974. CIDR or dotted-decimal notation. Separate the IP address and subnet
  975. mask with a slash ('/')
  976. </para></description>
  977. </configOption>
  978. <configOption name="subscribe_context">
  979. <synopsis>Context for incoming MESSAGE requests.</synopsis>
  980. <description><para>
  981. If specified, incoming SUBSCRIBE requests will be searched for the matching
  982. extension in the indicated context.
  983. If no <replaceable>subscribe_context</replaceable> is specified,
  984. then the <replaceable>context</replaceable> setting is used.
  985. </para></description>
  986. </configOption>
  987. <configOption name="contact_user" default="">
  988. <synopsis>Force the user on the outgoing Contact header to this value.</synopsis>
  989. <description><para>
  990. On outbound requests, force the user portion of the Contact header to this value.
  991. </para></description>
  992. </configOption>
  993. <configOption name="asymmetric_rtp_codec" default="no">
  994. <synopsis>Allow the sending and receiving RTP codec to differ</synopsis>
  995. <description><para>
  996. When set to "yes" the codec in use for sending will be allowed to differ from
  997. that of the received one. PJSIP will not automatically switch the sending one
  998. to the receiving one.
  999. </para></description>
  1000. </configOption>
  1001. <configOption name="rtcp_mux" default="no">
  1002. <synopsis>Enable RFC 5761 RTCP multiplexing on the RTP port</synopsis>
  1003. <description><para>
  1004. With this option enabled, Asterisk will attempt to negotiate the use of the "rtcp-mux"
  1005. attribute on all media streams. This will result in RTP and RTCP being sent and received
  1006. on the same port. This shifts the demultiplexing logic to the application rather than
  1007. the transport layer. This option is useful when interoperating with WebRTC endpoints
  1008. since they mandate this option's use.
  1009. </para></description>
  1010. </configOption>
  1011. <configOption name="refer_blind_progress" default="yes">
  1012. <synopsis>Whether to notifies all the progress details on blind transfer</synopsis>
  1013. <description><para>
  1014. Some SIP phones (Mitel/Aastra, Snom) expect a sip/frag "200 OK"
  1015. after REFER has been accepted. If set to <literal>no</literal> then asterisk
  1016. will not send the progress details, but immediately will send "200 OK".
  1017. </para></description>
  1018. </configOption>
  1019. <configOption name="notify_early_inuse_ringing" default="no">
  1020. <synopsis>Whether to notifies dialog-info 'early' on InUse&amp;Ringing state</synopsis>
  1021. <description><para>
  1022. Control whether dialog-info subscriptions get 'early' state
  1023. on Ringing when already INUSE.
  1024. </para></description>
  1025. </configOption>
  1026. <configOption name="incoming_mwi_mailbox">
  1027. <synopsis>Mailbox name to use when incoming MWI NOTIFYs are received</synopsis>
  1028. <description><para>
  1029. If an MWI NOTIFY is received <emphasis>from</emphasis> this endpoint,
  1030. this mailbox will be used when notifying other modules of MWI status
  1031. changes. If not set, incoming MWI NOTIFYs are ignored.
  1032. </para></description>
  1033. </configOption>
  1034. <configOption name="follow_early_media_fork">
  1035. <synopsis>Follow SDP forked media when To tag is different</synopsis>
  1036. <description><para>
  1037. On outgoing calls, if the UAS responds with different SDP attributes
  1038. on subsequent 18X or 2XX responses (such as a port update) AND the
  1039. To tag on the subsequent response is different than that on the previous
  1040. one, follow it. This usually happens when the INVITE is forked to multiple
  1041. UASs and more than one sends an SDP answer.
  1042. </para>
  1043. <note><para>
  1044. This option must also be enabled in the <literal>system</literal>
  1045. section for it to take effect here.
  1046. </para></note>
  1047. </description>
  1048. </configOption>
  1049. <configOption name="accept_multiple_sdp_answers" default="no">
  1050. <synopsis>Accept multiple SDP answers on non-100rel responses</synopsis>
  1051. <description><para>
  1052. On outgoing calls, if the UAS responds with different SDP attributes
  1053. on non-100rel 18X or 2XX responses (such as a port update) AND the
  1054. To tag on the subsequent response is the same as that on the previous one,
  1055. process the updated SDP. This can happen when the UAS needs to change ports
  1056. for some reason such as using a separate port for custom ringback.
  1057. </para>
  1058. <note><para>
  1059. This option must also be enabled in the <literal>system</literal>
  1060. section for it to take effect here.
  1061. </para></note>
  1062. </description>
  1063. </configOption>
  1064. <configOption name="suppress_q850_reason_headers" default="no">
  1065. <synopsis>Suppress Q.850 Reason headers for this endpoint</synopsis>
  1066. <description><para>
  1067. Some devices can't accept multiple Reason headers and get confused
  1068. when both 'SIP' and 'Q.850' Reason headers are received. This
  1069. option allows the 'Q.850' Reason header to be suppressed.</para>
  1070. </description>
  1071. </configOption>
  1072. </configObject>
  1073. <configObject name="auth">
  1074. <synopsis>Authentication type</synopsis>
  1075. <description><para>
  1076. Authentication objects hold the authentication information for use
  1077. by other objects such as <literal>endpoints</literal> or <literal>registrations</literal>.
  1078. This also allows for multiple objects to use a single auth object. See
  1079. the <literal>auth_type</literal> config option for password style choices.
  1080. </para></description>
  1081. <configOption name="auth_type" default="userpass">
  1082. <synopsis>Authentication type</synopsis>
  1083. <description><para>
  1084. This option specifies which of the password style config options should be read
  1085. when trying to authenticate an endpoint inbound request. If set to <literal>userpass</literal>
  1086. then we'll read from the 'password' option. For <literal>md5</literal> we'll read
  1087. from 'md5_cred'.
  1088. </para>
  1089. <enumlist>
  1090. <enum name="md5"/>
  1091. <enum name="userpass"/>
  1092. </enumlist>
  1093. </description>
  1094. </configOption>
  1095. <configOption name="nonce_lifetime" default="32">
  1096. <synopsis>Lifetime of a nonce associated with this authentication config.</synopsis>
  1097. </configOption>
  1098. <configOption name="md5_cred">
  1099. <synopsis>MD5 Hash used for authentication.</synopsis>
  1100. <description><para>Only used when auth_type is <literal>md5</literal>.</para></description>
  1101. </configOption>
  1102. <configOption name="password">
  1103. <synopsis>Plain text password used for authentication.</synopsis>
  1104. <description><para>Only used when auth_type is <literal>userpass</literal>.</para></description>
  1105. </configOption>
  1106. <configOption name="realm">
  1107. <synopsis>SIP realm for endpoint</synopsis>
  1108. <description><para>
  1109. The treatment of this value depends upon how the authentication
  1110. object is used.
  1111. </para><para>
  1112. When used as an inbound authentication object, the realm is sent
  1113. as part of the challenge so the peer can know which key to use
  1114. when responding. An empty value will use the
  1115. <replaceable>global</replaceable> section's
  1116. <literal>default_realm</literal> value when issuing a challenge.
  1117. </para><para>
  1118. When used as an outbound authentication object, the realm is
  1119. matched with the received challenge realm to determine which
  1120. authentication object to use when responding to the challenge. An
  1121. empty value matches any challenging realm when determining
  1122. which authentication object matches a received challenge.
  1123. </para>
  1124. <note><para>
  1125. Using the same auth section for inbound and outbound
  1126. authentication is not recommended. There is a difference in
  1127. meaning for an empty realm setting between inbound and outbound
  1128. authentication uses.</para></note>
  1129. </description>
  1130. </configOption>
  1131. <configOption name="type">
  1132. <synopsis>Must be 'auth'</synopsis>
  1133. </configOption>
  1134. <configOption name="username">
  1135. <synopsis>Username to use for account</synopsis>
  1136. </configOption>
  1137. </configObject>
  1138. <configObject name="domain_alias">
  1139. <synopsis>Domain Alias</synopsis>
  1140. <description><para>
  1141. Signifies that a domain is an alias. If the domain on a session is
  1142. not found to match an AoR then this object is used to see if we have
  1143. an alias for the AoR to which the endpoint is binding. This objects
  1144. name as defined in configuration should be the domain alias and a
  1145. config option is provided to specify the domain to be aliased.
  1146. </para></description>
  1147. <configOption name="type">
  1148. <synopsis>Must be of type 'domain_alias'.</synopsis>
  1149. </configOption>
  1150. <configOption name="domain">
  1151. <synopsis>Domain to be aliased</synopsis>
  1152. </configOption>
  1153. </configObject>
  1154. <configObject name="transport">
  1155. <synopsis>SIP Transport</synopsis>
  1156. <description><para>
  1157. <emphasis>Transports</emphasis>
  1158. </para>
  1159. <para>There are different transports and protocol derivatives
  1160. supported by <literal>res_pjsip</literal>. They are in order of
  1161. preference: UDP, TCP, and WebSocket (WS).</para>
  1162. <note><para>Changes to transport configuration in pjsip.conf will only be
  1163. effected on a complete restart of Asterisk. A module reload
  1164. will not suffice.</para></note>
  1165. </description>
  1166. <configOption name="async_operations" default="1">
  1167. <synopsis>Number of simultaneous Asynchronous Operations</synopsis>
  1168. </configOption>
  1169. <configOption name="bind">
  1170. <synopsis>IP Address and optional port to bind to for this transport</synopsis>
  1171. </configOption>
  1172. <configOption name="ca_list_file">
  1173. <synopsis>File containing a list of certificates to read (TLS ONLY, not WSS)</synopsis>
  1174. </configOption>
  1175. <configOption name="ca_list_path">
  1176. <synopsis>Path to directory containing a list of certificates to read (TLS ONLY, not WSS)</synopsis>
  1177. </configOption>
  1178. <configOption name="cert_file">
  1179. <synopsis>Certificate file for endpoint (TLS ONLY, not WSS)</synopsis>
  1180. <description><para>
  1181. A path to a .crt or .pem file can be provided. However, only
  1182. the certificate is read from the file, not the private key.
  1183. The <literal>priv_key_file</literal> option must supply a
  1184. matching key file.
  1185. </para></description>
  1186. </configOption>
  1187. <configOption name="cipher">
  1188. <synopsis>Preferred cryptography cipher names (TLS ONLY, not WSS)</synopsis>
  1189. <description>
  1190. <para>Comma separated list of cipher names or numeric equivalents.
  1191. Numeric equivalents can be either decimal or hexadecimal (0xX).
  1192. </para>
  1193. <para>There are many cipher names. Use the CLI command
  1194. <literal>pjsip list ciphers</literal> to see a list of cipher
  1195. names available for your installation. See link for more:</para>
  1196. <para>http://www.openssl.org/docs/apps/ciphers.html#CIPHER_SUITE_NAMES
  1197. </para>
  1198. </description>
  1199. </configOption>
  1200. <configOption name="domain">
  1201. <synopsis>Domain the transport comes from</synopsis>
  1202. </configOption>
  1203. <configOption name="external_media_address">
  1204. <synopsis>External IP address to use in RTP handling</synopsis>
  1205. <description><para>
  1206. When a request or response is sent out, if the destination of the
  1207. message is outside the IP network defined in the option <literal>localnet</literal>,
  1208. and the media address in the SDP is within the localnet network, then the
  1209. media address in the SDP will be rewritten to the value defined for
  1210. <literal>external_media_address</literal>.
  1211. </para></description>
  1212. </configOption>
  1213. <configOption name="external_signaling_address">
  1214. <synopsis>External address for SIP signalling</synopsis>
  1215. </configOption>
  1216. <configOption name="external_signaling_port" default="0">
  1217. <synopsis>External port for SIP signalling</synopsis>
  1218. </configOption>
  1219. <configOption name="method">
  1220. <synopsis>Method of SSL transport (TLS ONLY, not WSS)</synopsis>
  1221. <description>
  1222. <enumlist>
  1223. <enum name="default">
  1224. <para>The default as defined by PJSIP. This is currently TLSv1, but may change with future releases.</para>
  1225. </enum>
  1226. <enum name="unspecified">
  1227. <para>This option is equivalent to setting 'default'</para>
  1228. </enum>
  1229. <enum name="tlsv1" />
  1230. <enum name="tlsv1_1" />
  1231. <enum name="tlsv1_2" />
  1232. <enum name="sslv2" />
  1233. <enum name="sslv3" />
  1234. <enum name="sslv23" />
  1235. </enumlist>
  1236. </description>
  1237. </configOption>
  1238. <configOption name="local_net">
  1239. <synopsis>Network to consider local (used for NAT purposes).</synopsis>
  1240. <description><para>This must be in CIDR or dotted decimal format with the IP
  1241. and mask separated with a slash ('/').</para></description>
  1242. </configOption>
  1243. <configOption name="password">
  1244. <synopsis>Password required for transport</synopsis>
  1245. </configOption>
  1246. <configOption name="priv_key_file">
  1247. <synopsis>Private key file (TLS ONLY, not WSS)</synopsis>
  1248. </configOption>
  1249. <configOption name="protocol" default="udp">
  1250. <synopsis>Protocol to use for SIP traffic</synopsis>
  1251. <description>
  1252. <enumlist>
  1253. <enum name="udp" />
  1254. <enum name="tcp" />
  1255. <enum name="tls" />
  1256. <enum name="ws" />
  1257. <enum name="wss" />
  1258. </enumlist>
  1259. </description>
  1260. </configOption>
  1261. <configOption name="require_client_cert" default="false">
  1262. <synopsis>Require client certificate (TLS ONLY, not WSS)</synopsis>
  1263. </configOption>
  1264. <configOption name="type">
  1265. <synopsis>Must be of type 'transport'.</synopsis>
  1266. </configOption>
  1267. <configOption name="verify_client" default="false">
  1268. <synopsis>Require verification of client certificate (TLS ONLY, not WSS)</synopsis>
  1269. </configOption>
  1270. <configOption name="verify_server" default="false">
  1271. <synopsis>Require verification of server certificate (TLS ONLY, not WSS)</synopsis>
  1272. </configOption>
  1273. <configOption name="tos" default="false">
  1274. <synopsis>Enable TOS for the signalling sent over this transport</synopsis>
  1275. <description>
  1276. <para>See <literal>https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service</literal>
  1277. for more information on this parameter.</para>
  1278. <note><para>This option does not apply to the <replaceable>ws</replaceable>
  1279. or the <replaceable>wss</replaceable> protocols.</para></note>
  1280. </description>
  1281. </configOption>
  1282. <configOption name="cos" default="false">
  1283. <synopsis>Enable COS for the signalling sent over this transport</synopsis>
  1284. <description>
  1285. <para>See <literal>https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service</literal>
  1286. for more information on this parameter.</para>
  1287. <note><para>This option does not apply to the <replaceable>ws</replaceable>
  1288. or the <replaceable>wss</replaceable> protocols.</para></note>
  1289. </description>
  1290. </configOption>
  1291. <configOption name="websocket_write_timeout">
  1292. <synopsis>The timeout (in milliseconds) to set on WebSocket connections.</synopsis>
  1293. <description>
  1294. <para>If a websocket connection accepts input slowly, the timeout
  1295. for writes to it can be increased to keep it from being disconnected.
  1296. Value is in milliseconds; default is 100 ms.</para>
  1297. </description>
  1298. </configOption>
  1299. <configOption name="allow_reload" default="no">
  1300. <synopsis>Allow this transport to be reloaded.</synopsis>
  1301. <description>
  1302. <para>Allow this transport to be reloaded when res_pjsip is reloaded.
  1303. This option defaults to "no" because reloading a transport may disrupt
  1304. in-progress calls.</para>
  1305. </description>
  1306. </configOption>
  1307. <configOption name="symmetric_transport" default="no">
  1308. <synopsis>Use the same transport for outgoing requests as incoming ones.</synopsis>
  1309. <description>
  1310. <para>When a request from a dynamic contact
  1311. comes in on a transport with this option set to 'yes',
  1312. the transport name will be saved and used for subsequent
  1313. outgoing requests like OPTIONS, NOTIFY and INVITE. It's
  1314. saved as a contact uri parameter named 'x-ast-txp' and will
  1315. display with the contact uri in CLI, AMI, and ARI output.
  1316. On the outgoing request, if a transport wasn't explicitly
  1317. set on the endpoint AND the request URI is not a hostname,
  1318. the saved transport will be used and the 'x-ast-txp'
  1319. parameter stripped from the outgoing packet.
  1320. </para>
  1321. </description>
  1322. </configOption>
  1323. </configObject>
  1324. <configObject name="contact">
  1325. <synopsis>A way of creating an aliased name to a SIP URI</synopsis>
  1326. <description><para>
  1327. Contacts are a way to hide SIP URIs from the dialplan directly.
  1328. They are also used to make a group of contactable parties when
  1329. in use with <literal>AoR</literal> lists.
  1330. </para></description>
  1331. <configOption name="type">
  1332. <synopsis>Must be of type 'contact'.</synopsis>
  1333. </configOption>
  1334. <configOption name="uri">
  1335. <synopsis>SIP URI to contact peer</synopsis>
  1336. </configOption>
  1337. <configOption name="expiration_time">
  1338. <synopsis>Time to keep alive a contact</synopsis>
  1339. <description><para>
  1340. Time to keep alive a contact. String style specification.
  1341. </para></description>
  1342. </configOption>
  1343. <configOption name="qualify_frequency" default="0">
  1344. <synopsis>Interval at which to qualify a contact</synopsis>
  1345. <description><para>
  1346. Interval between attempts to qualify the contact for reachability.
  1347. If <literal>0</literal> never qualify. Time in seconds.
  1348. </para></description>
  1349. </configOption>
  1350. <configOption name="qualify_timeout" default="3.0">
  1351. <synopsis>Timeout for qualify</synopsis>
  1352. <description><para>
  1353. If the contact doesn't respond to the OPTIONS request before the timeout,
  1354. the contact is marked unavailable.
  1355. If <literal>0</literal> no timeout. Time in fractional seconds.
  1356. </para></description>
  1357. </configOption>
  1358. <configOption name="authenticate_qualify">
  1359. <synopsis>Authenticates a qualify challenge response if needed</synopsis>
  1360. <description>
  1361. <para>If true and a qualify request receives a challenge response then
  1362. authentication is attempted before declaring the contact available.
  1363. </para>
  1364. <note><para>This option does nothing as we will always complete
  1365. the challenge response authentication if the qualify request is
  1366. challenged.
  1367. </para></note>
  1368. </description>
  1369. </configOption>
  1370. <configOption name="outbound_proxy">
  1371. <synopsis>Outbound proxy used when sending OPTIONS request</synopsis>
  1372. <description><para>
  1373. If set the provided URI will be used as the outbound proxy when an
  1374. OPTIONS request is sent to a contact for qualify purposes.
  1375. </para></description>
  1376. </configOption>
  1377. <configOption name="path">
  1378. <synopsis>Stored Path vector for use in Route headers on outgoing requests.</synopsis>
  1379. </configOption>
  1380. <configOption name="user_agent">
  1381. <synopsis>User-Agent header from registration.</synopsis>
  1382. <description><para>
  1383. The User-Agent is automatically stored based on data present in incoming SIP
  1384. REGISTER requests and is not intended to be configured manually.
  1385. </para></description>
  1386. </configOption>
  1387. <configOption name="endpoint">
  1388. <synopsis>Endpoint name</synopsis>
  1389. <description><para>
  1390. The name of the endpoint this contact belongs to
  1391. </para></description>
  1392. </configOption>
  1393. <configOption name="reg_server">
  1394. <synopsis>Asterisk Server name</synopsis>
  1395. <description><para>
  1396. Asterisk Server name on which SIP endpoint registered.
  1397. </para></description>
  1398. </configOption>
  1399. <configOption name="via_addr">
  1400. <synopsis>IP-address of the last Via header from registration.</synopsis>
  1401. <description><para>
  1402. The last Via header should contain the address of UA which sent the request.
  1403. The IP-address of the last Via header is automatically stored based on data present
  1404. in incoming SIP REGISTER requests and is not intended to be configured manually.
  1405. </para></description>
  1406. </configOption>
  1407. <configOption name="via_port">
  1408. <synopsis>IP-port of the last Via header from registration.</synopsis>
  1409. <description><para>
  1410. The IP-port of the last Via header is automatically stored based on data present
  1411. in incoming SIP REGISTER requests and is not intended to be configured manually.
  1412. </para></description>
  1413. </configOption>
  1414. <configOption name="call_id">
  1415. <synopsis>Call-ID header from registration.</synopsis>
  1416. <description><para>
  1417. The Call-ID header is automatically stored based on data present
  1418. in incoming SIP REGISTER requests and is not intended to be configured manually.
  1419. </para></description>
  1420. </configOption>
  1421. <configOption name="prune_on_boot">
  1422. <synopsis>A contact that cannot survive a restart/boot.</synopsis>
  1423. <description><para>
  1424. The option is set if the incoming SIP REGISTER contact is rewritten
  1425. on a reliable transport and is not intended to be configured manually.
  1426. </para></description>
  1427. </configOption>
  1428. </configObject>
  1429. <configObject name="aor">
  1430. <synopsis>The configuration for a location of an endpoint</synopsis>
  1431. <description><para>
  1432. An AoR is what allows Asterisk to contact an endpoint via res_pjsip. If no
  1433. AoRs are specified, an endpoint will not be reachable by Asterisk.
  1434. Beyond that, an AoR has other uses within Asterisk, such as inbound
  1435. registration.
  1436. </para><para>
  1437. An <literal>AoR</literal> is a way to allow dialing a group
  1438. of <literal>Contacts</literal> that all use the same
  1439. <literal>endpoint</literal> for calls.
  1440. </para><para>
  1441. This can be used as another way of grouping a list of contacts to dial
  1442. rather than specifying them each directly when dialing via the dialplan.
  1443. This must be used in conjunction with the <literal>PJSIP_DIAL_CONTACTS</literal>.
  1444. </para><para>
  1445. Registrations: For Asterisk to match an inbound registration to an endpoint,
  1446. the AoR object name must match the user portion of the SIP URI in the "To:"
  1447. header of the inbound SIP registration. That will usually be equivalent
  1448. to the "user name" set in your hard or soft phones configuration.
  1449. </para></description>
  1450. <configOption name="contact">
  1451. <synopsis>Permanent contacts assigned to AoR</synopsis>
  1452. <description><para>
  1453. Contacts specified will be called whenever referenced
  1454. by <literal>chan_pjsip</literal>.
  1455. </para><para>
  1456. Use a separate "contact=" entry for each contact required. Contacts
  1457. are specified using a SIP URI.
  1458. </para></description>
  1459. </configOption>
  1460. <configOption name="default_expiration" default="3600">
  1461. <synopsis>Default expiration time in seconds for contacts that are dynamically bound to an AoR.</synopsis>
  1462. </configOption>
  1463. <configOption name="mailboxes">
  1464. <synopsis>Allow subscriptions for the specified mailbox(es)</synopsis>
  1465. <description><para>This option applies when an external entity subscribes to an AoR
  1466. for Message Waiting Indications. The mailboxes specified will be subscribed to.
  1467. More than one mailbox can be specified with a comma-delimited string.
  1468. app_voicemail mailboxes must be specified as mailbox@context;
  1469. for example: mailboxes=6001@default. For mailboxes provided by external sources,
  1470. such as through the res_external_mwi module, you must specify strings supported by
  1471. the external system.
  1472. </para><para>
  1473. For endpoints that cannot SUBSCRIBE for MWI, you can set the <literal>mailboxes</literal> option in your
  1474. endpoint configuration section to enable unsolicited MWI NOTIFYs to the endpoint.
  1475. </para></description>
  1476. </configOption>
  1477. <configOption name="voicemail_extension">
  1478. <synopsis>The voicemail extension to send in the NOTIFY Message-Account header</synopsis>
  1479. </configOption>
  1480. <configOption name="maximum_expiration" default="7200">
  1481. <synopsis>Maximum time to keep an AoR</synopsis>
  1482. <description><para>
  1483. Maximum time to keep a peer with explicit expiration. Time in seconds.
  1484. </para></description>
  1485. </configOption>
  1486. <configOption name="max_contacts" default="0">
  1487. <synopsis>Maximum number of contacts that can bind to an AoR</synopsis>
  1488. <description><para>
  1489. Maximum number of contacts that can associate with this AoR. This value does
  1490. not affect the number of contacts that can be added with the "contact" option.
  1491. It only limits contacts added through external interaction, such as
  1492. registration.
  1493. </para>
  1494. <note><para>The <replaceable>rewrite_contact</replaceable> option
  1495. registers the source address as the contact address to help with
  1496. NAT and reusing connection oriented transports such as TCP and
  1497. TLS. Unfortunately, refreshing a registration may register a
  1498. different contact address and exceed
  1499. <replaceable>max_contacts</replaceable>. The
  1500. <replaceable>remove_existing</replaceable> option can help by
  1501. removing the soonest to expire contact(s) over
  1502. <replaceable>max_contacts</replaceable> which is likely the
  1503. old <replaceable>rewrite_contact</replaceable> contact source
  1504. address being refreshed.
  1505. </para></note>
  1506. <note><para>This should be set to <literal>1</literal> and
  1507. <replaceable>remove_existing</replaceable> set to <literal>yes</literal> if you
  1508. wish to stick with the older <literal>chan_sip</literal> behaviour.
  1509. </para></note>
  1510. </description>
  1511. </configOption>
  1512. <configOption name="minimum_expiration" default="60">
  1513. <synopsis>Minimum keep alive time for an AoR</synopsis>
  1514. <description><para>
  1515. Minimum time to keep a peer with an explicit expiration. Time in seconds.
  1516. </para></description>
  1517. </configOption>
  1518. <configOption name="remove_existing" default="no">
  1519. <synopsis>Determines whether new contacts replace existing ones.</synopsis>
  1520. <description><para>
  1521. On receiving a new registration to the AoR should it remove enough
  1522. existing contacts not added or updated by the registration to
  1523. satisfy <replaceable>max_contacts</replaceable>? Any removed
  1524. contacts will expire the soonest.
  1525. </para>
  1526. <note><para>The <replaceable>rewrite_contact</replaceable> option
  1527. registers the source address as the contact address to help with
  1528. NAT and reusing connection oriented transports such as TCP and
  1529. TLS. Unfortunately, refreshing a registration may register a
  1530. different contact address and exceed
  1531. <replaceable>max_contacts</replaceable>. The
  1532. <replaceable>remove_existing</replaceable> option can help by
  1533. removing the soonest to expire contact(s) over
  1534. <replaceable>max_contacts</replaceable> which is likely the
  1535. old <replaceable>rewrite_contact</replaceable> contact source
  1536. address being refreshed.
  1537. </para></note>
  1538. <note><para>This should be set to <literal>yes</literal> and
  1539. <replaceable>max_contacts</replaceable> set to <literal>1</literal> if you
  1540. wish to stick with the older <literal>chan_sip</literal> behaviour.
  1541. </para></note>
  1542. </description>
  1543. </configOption>
  1544. <configOption name="type">
  1545. <synopsis>Must be of type 'aor'.</synopsis>
  1546. </configOption>
  1547. <configOption name="qualify_frequency" default="0">
  1548. <synopsis>Interval at which to qualify an AoR</synopsis>
  1549. <description><para>
  1550. Interval between attempts to qualify the AoR for reachability.
  1551. If <literal>0</literal> never qualify. Time in seconds.
  1552. </para></description>
  1553. </configOption>
  1554. <configOption name="qualify_timeout" default="3.0">
  1555. <synopsis>Timeout for qualify</synopsis>
  1556. <description><para>
  1557. If the contact doesn't respond to the OPTIONS request before the timeout,
  1558. the contact is marked unavailable.
  1559. If <literal>0</literal> no timeout. Time in fractional seconds.
  1560. </para></description>
  1561. </configOption>
  1562. <configOption name="authenticate_qualify">
  1563. <synopsis>Authenticates a qualify challenge response if needed</synopsis>
  1564. <description>
  1565. <para>If true and a qualify request receives a challenge response then
  1566. authentication is attempted before declaring the contact available.
  1567. </para>
  1568. <note><para>This option does nothing as we will always complete
  1569. the challenge response authentication if the qualify request is
  1570. challenged.
  1571. </para></note>
  1572. </description>
  1573. </configOption>
  1574. <configOption name="outbound_proxy">
  1575. <synopsis>Outbound proxy used when sending OPTIONS request</synopsis>
  1576. <description><para>
  1577. If set the provided URI will be used as the outbound proxy when an
  1578. OPTIONS request is sent to a contact for qualify purposes.
  1579. </para></description>
  1580. </configOption>
  1581. <configOption name="support_path">
  1582. <synopsis>Enables Path support for REGISTER requests and Route support for other requests.</synopsis>
  1583. <description><para>
  1584. When this option is enabled, the Path headers in register requests will be saved
  1585. and its contents will be used in Route headers for outbound out-of-dialog requests
  1586. and in Path headers for outbound 200 responses. Path support will also be indicated
  1587. in the Supported header.
  1588. </para></description>
  1589. </configOption>
  1590. </configObject>
  1591. <configObject name="system">
  1592. <synopsis>Options that apply to the SIP stack as well as other system-wide settings</synopsis>
  1593. <description><para>
  1594. The settings in this section are global. In addition to being global, the values will
  1595. not be re-evaluated when a reload is performed. This is because the values must be set
  1596. before the SIP stack is initialized. The only way to reset these values is to either
  1597. restart Asterisk, or unload res_pjsip.so and then load it again.
  1598. </para></description>
  1599. <configOption name="timer_t1" default="500">
  1600. <synopsis>Set transaction timer T1 value (milliseconds).</synopsis>
  1601. <description><para>
  1602. Timer T1 is the base for determining how long to wait before retransmitting
  1603. requests that receive no response when using an unreliable transport (e.g. UDP).
  1604. For more information on this timer, see RFC 3261, Section 17.1.1.1.
  1605. </para></description>
  1606. </configOption>
  1607. <configOption name="timer_b" default="32000">
  1608. <synopsis>Set transaction timer B value (milliseconds).</synopsis>
  1609. <description><para>
  1610. Timer B determines the maximum amount of time to wait after sending an INVITE
  1611. request before terminating the transaction. It is recommended that this be set
  1612. to 64 * Timer T1, but it may be set higher if desired. For more information on
  1613. this timer, see RFC 3261, Section 17.1.1.1.
  1614. </para></description>
  1615. </configOption>
  1616. <configOption name="compact_headers" default="no">
  1617. <synopsis>Use the short forms of common SIP header names.</synopsis>
  1618. </configOption>
  1619. <configOption name="threadpool_initial_size" default="0">
  1620. <synopsis>Initial number of threads in the res_pjsip threadpool.</synopsis>
  1621. </configOption>
  1622. <configOption name="threadpool_auto_increment" default="5">
  1623. <synopsis>The amount by which the number of threads is incremented when necessary.</synopsis>
  1624. </configOption>
  1625. <configOption name="threadpool_idle_timeout" default="60">
  1626. <synopsis>Number of seconds before an idle thread should be disposed of.</synopsis>
  1627. </configOption>
  1628. <configOption name="threadpool_max_size" default="0">
  1629. <synopsis>Maximum number of threads in the res_pjsip threadpool.
  1630. A value of 0 indicates no maximum.</synopsis>
  1631. </configOption>
  1632. <configOption name="disable_tcp_switch" default="yes">
  1633. <synopsis>Disable automatic switching from UDP to TCP transports.</synopsis>
  1634. <description><para>
  1635. Disable automatic switching from UDP to TCP transports if outgoing
  1636. request is too large. See RFC 3261 section 18.1.1.
  1637. </para></description>
  1638. </configOption>
  1639. <configOption name="follow_early_media_fork">
  1640. <synopsis>Follow SDP forked media when To tag is different</synopsis>
  1641. <description><para>
  1642. On outgoing calls, if the UAS responds with different SDP attributes
  1643. on subsequent 18X or 2XX responses (such as a port update) AND the
  1644. To tag on the subsequent response is different than that on the previous
  1645. one, follow it.
  1646. </para>
  1647. <note><para>
  1648. This option must also be enabled on endpoints that require
  1649. this functionality.
  1650. </para></note>
  1651. </description>
  1652. </configOption>
  1653. <configOption name="accept_multiple_sdp_answers">
  1654. <synopsis>Follow SDP forked media when To tag is the same</synopsis>
  1655. <description><para>
  1656. On outgoing calls, if the UAS responds with different SDP attributes
  1657. on non-100rel 18X or 2XX responses (such as a port update) AND the
  1658. To tag on the subsequent response is the same as that on the previous one,
  1659. process the updated SDP.
  1660. </para>
  1661. <note><para>
  1662. This option must also be enabled on endpoints that require
  1663. this functionality.
  1664. </para></note>
  1665. </description>
  1666. </configOption>
  1667. <configOption name="type">
  1668. <synopsis>Must be of type 'system' UNLESS the object name is 'system'.</synopsis>
  1669. </configOption>
  1670. </configObject>
  1671. <configObject name="global">
  1672. <synopsis>Options that apply globally to all SIP communications</synopsis>
  1673. <description><para>
  1674. The settings in this section are global. Unlike options in the <literal>system</literal>
  1675. section, these options can be refreshed by performing a reload.
  1676. </para></description>
  1677. <configOption name="max_forwards" default="70">
  1678. <synopsis>Value used in Max-Forwards header for SIP requests.</synopsis>
  1679. </configOption>
  1680. <configOption name="keep_alive_interval" default="90">
  1681. <synopsis>The interval (in seconds) to send keepalives to active connection-oriented transports.</synopsis>
  1682. </configOption>
  1683. <configOption name="contact_expiration_check_interval" default="30">
  1684. <synopsis>The interval (in seconds) to check for expired contacts.</synopsis>
  1685. </configOption>
  1686. <configOption name="disable_multi_domain" default="no">
  1687. <synopsis>Disable Multi Domain support</synopsis>
  1688. <description><para>
  1689. If disabled it can improve realtime performance by reducing the number of database requests.
  1690. </para></description>
  1691. </configOption>
  1692. <configOption name="max_initial_qualify_time" default="0">
  1693. <synopsis>The maximum amount of time from startup that qualifies should be attempted on all contacts.
  1694. If greater than the qualify_frequency for an aor, qualify_frequency will be used instead.</synopsis>
  1695. </configOption>
  1696. <configOption name="unidentified_request_period" default="5">
  1697. <synopsis>The number of seconds over which to accumulate unidentified requests.</synopsis>
  1698. <description><para>
  1699. If <literal>unidentified_request_count</literal> unidentified requests are received
  1700. during <literal>unidentified_request_period</literal>, a security event will be generated.
  1701. </para></description>
  1702. </configOption>
  1703. <configOption name="unidentified_request_count" default="5">
  1704. <synopsis>The number of unidentified requests from a single IP to allow.</synopsis>
  1705. <description><para>
  1706. If <literal>unidentified_request_count</literal> unidentified requests are received
  1707. during <literal>unidentified_request_period</literal>, a security event will be generated.
  1708. </para></description>
  1709. </configOption>
  1710. <configOption name="unidentified_request_prune_interval" default="30">
  1711. <synopsis>The interval at which unidentified requests are older than
  1712. twice the unidentified_request_period are pruned.</synopsis>
  1713. </configOption>
  1714. <configOption name="type">
  1715. <synopsis>Must be of type 'global' UNLESS the object name is 'global'.</synopsis>
  1716. </configOption>
  1717. <configOption name="user_agent" default="Asterisk &lt;Asterisk Version&gt;">
  1718. <synopsis>Value used in User-Agent header for SIP requests and Server header for SIP responses.</synopsis>
  1719. </configOption>
  1720. <configOption name="regcontext" default="">
  1721. <synopsis>When set, Asterisk will dynamically create and destroy a NoOp priority 1 extension for a given
  1722. peer who registers or unregisters with us.</synopsis>
  1723. </configOption>
  1724. <configOption name="default_outbound_endpoint" default="default_outbound_endpoint">
  1725. <synopsis>Endpoint to use when sending an outbound request to a URI without a specified endpoint.</synopsis>
  1726. </configOption>
  1727. <configOption name="default_voicemail_extension">
  1728. <synopsis>The voicemail extension to send in the NOTIFY Message-Account header if not specified on endpoint or aor</synopsis>
  1729. </configOption>
  1730. <configOption name="debug" default="no">
  1731. <synopsis>Enable/Disable SIP debug logging. Valid options include yes, no, or
  1732. a host address</synopsis>
  1733. </configOption>
  1734. <configOption name="endpoint_identifier_order">
  1735. <synopsis>The order by which endpoint identifiers are processed and checked.
  1736. Identifier names are usually derived from and can be found in the endpoint
  1737. identifier module itself (res_pjsip_endpoint_identifier_*).
  1738. You can use the CLI command "pjsip show identifiers" to see the
  1739. identifiers currently available.</synopsis>
  1740. <description>
  1741. <note><para>
  1742. One of the identifiers is "auth_username" which matches on the username in
  1743. an Authentication header. This method has some security considerations because an
  1744. Authentication header is not present on the first message of a dialog when
  1745. digest authentication is used. The client can't generate it until the server
  1746. sends the challenge in a 401 response. Since Asterisk normally sends a security
  1747. event when an incoming request can't be matched to an endpoint, using auth_username
  1748. requires that the security event be deferred until a request is received with
  1749. the Authentication header and only generated if the username doesn't result in a
  1750. match. This may result in a delay before an attack is recognized. You can control
  1751. how many unmatched requests are received from a single ip address before a security
  1752. event is generated using the unidentified_request parameters.
  1753. </para></note>
  1754. </description>
  1755. </configOption>
  1756. <configOption name="default_from_user" default="asterisk">
  1757. <synopsis>When Asterisk generates an outgoing SIP request, the From header username will be
  1758. set to this value if there is no better option (such as CallerID) to be
  1759. used.</synopsis>
  1760. </configOption>
  1761. <configOption name="default_realm" default="asterisk">
  1762. <synopsis>When Asterisk generates a challenge, the digest realm will be
  1763. set to this value if there is no better option (such as auth/realm) to be
  1764. used.</synopsis>
  1765. </configOption>
  1766. <configOption name="mwi_tps_queue_high" default="500">
  1767. <synopsis>MWI taskprocessor high water alert trigger level.</synopsis>
  1768. <description>
  1769. <para>On a heavily loaded system you may need to adjust the
  1770. taskprocessor queue limits. If any taskprocessor queue size
  1771. reaches its high water level then pjsip will stop processing
  1772. new requests until the alert is cleared. The alert clears
  1773. when all alerting taskprocessor queues have dropped to their
  1774. low water clear level.
  1775. </para>
  1776. </description>
  1777. </configOption>
  1778. <configOption name="mwi_tps_queue_low" default="-1">
  1779. <synopsis>MWI taskprocessor low water clear alert level.</synopsis>
  1780. <description>
  1781. <para>On a heavily loaded system you may need to adjust the
  1782. taskprocessor queue limits. If any taskprocessor queue size
  1783. reaches its high water level then pjsip will stop processing
  1784. new requests until the alert is cleared. The alert clears
  1785. when all alerting taskprocessor queues have dropped to their
  1786. low water clear level.
  1787. </para>
  1788. <note><para>Set to -1 for the low water level to be 90% of
  1789. the high water level.</para></note>
  1790. </description>
  1791. </configOption>
  1792. <configOption name="mwi_disable_initial_unsolicited" default="no">
  1793. <synopsis>Enable/Disable sending unsolicited MWI to all endpoints on startup.</synopsis>
  1794. <description>
  1795. <para>When the initial unsolicited MWI notification are
  1796. enabled on startup then the initial notifications
  1797. get sent at startup. If you have a lot of endpoints
  1798. (thousands) that use unsolicited MWI then you may
  1799. want to consider disabling the initial startup
  1800. notifications.
  1801. </para>
  1802. <para>When the initial unsolicited MWI notifications are
  1803. disabled on startup then the notifications will start
  1804. on the endpoint's next contact update.
  1805. </para>
  1806. </description>
  1807. </configOption>
  1808. <configOption name="ignore_uri_user_options">
  1809. <synopsis>Enable/Disable ignoring SIP URI user field options.</synopsis>
  1810. <description>
  1811. <para>If you have this option enabled and there are semicolons
  1812. in the user field of a SIP URI then the field is truncated
  1813. at the first semicolon. This effectively makes the semicolon
  1814. a non-usable character for PJSIP endpoint names, extensions,
  1815. and AORs. This can be useful for improving compatibility with
  1816. an ITSP that likes to use user options for whatever reason.
  1817. </para>
  1818. <example title="Sample SIP URI">
  1819. sip:1235557890;phone-context=national@x.x.x.x;user=phone
  1820. </example>
  1821. <example title="Sample SIP URI user field">
  1822. 1235557890;phone-context=national
  1823. </example>
  1824. <example title="Sample SIP URI user field truncated">
  1825. 1235557890
  1826. </example>
  1827. <note><para>The caller-id and redirecting number strings
  1828. obtained from incoming SIP URI user fields are always truncated
  1829. at the first semicolon.</para></note>
  1830. </description>
  1831. </configOption>
  1832. <configOption name="use_callerid_contact" default="no">
  1833. <synopsis>Place caller-id information into Contact header</synopsis>
  1834. <description><para>
  1835. This option will cause Asterisk to place caller-id information into
  1836. generated Contact headers.</para>
  1837. </description>
  1838. </configOption>
  1839. <configOption name="send_contact_status_on_update_registration" default="yes">
  1840. <synopsis>Enable sending AMI ContactStatus event when a device refreshes its registration.</synopsis>
  1841. </configOption>
  1842. </configObject>
  1843. </configFile>
  1844. </configInfo>
  1845. <manager name="PJSIPQualify" language="en_US">
  1846. <synopsis>
  1847. Qualify a chan_pjsip endpoint.
  1848. </synopsis>
  1849. <syntax>
  1850. <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
  1851. <parameter name="Endpoint" required="true">
  1852. <para>The endpoint you want to qualify.</para>
  1853. </parameter>
  1854. </syntax>
  1855. <description>
  1856. <para>Qualify a chan_pjsip endpoint.</para>
  1857. </description>
  1858. </manager>
  1859. <managerEvent language="en_US" name="IdentifyDetail">
  1860. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1861. <synopsis>Provide details about an identify section.</synopsis>
  1862. <syntax>
  1863. <parameter name="ObjectType">
  1864. <para>The object's type. This will always be 'identify'.</para>
  1865. </parameter>
  1866. <parameter name="ObjectName">
  1867. <para>The name of this object.</para>
  1868. </parameter>
  1869. <parameter name="Endpoint">
  1870. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip_endpoint_identifier_ip']/configFile[@name='pjsip.conf']/configObject[@name='identify']/configOption[@name='endpoint']/synopsis/node())"/></para>
  1871. </parameter>
  1872. <parameter name="SrvLookups">
  1873. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip_endpoint_identifier_ip']/configFile[@name='pjsip.conf']/configObject[@name='identify']/configOption[@name='srv_lookups']/synopsis/node())"/></para>
  1874. </parameter>
  1875. <parameter name="Match">
  1876. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip_endpoint_identifier_ip']/configFile[@name='pjsip.conf']/configObject[@name='identify']/configOption[@name='match']/synopsis/node())"/></para>
  1877. </parameter>
  1878. <parameter name="MatchHeader">
  1879. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip_endpoint_identifier_ip']/configFile[@name='pjsip.conf']/configObject[@name='identify']/configOption[@name='match_header']/synopsis/node())"/></para>
  1880. </parameter>
  1881. <parameter name="EndpointName">
  1882. <para>The name of the endpoint associated with this information.</para>
  1883. </parameter>
  1884. </syntax>
  1885. </managerEventInstance>
  1886. </managerEvent>
  1887. <managerEvent language="en_US" name="AorDetail">
  1888. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1889. <synopsis>Provide details about an Address of Record (AoR) section.</synopsis>
  1890. <syntax>
  1891. <parameter name="ObjectType">
  1892. <para>The object's type. This will always be 'aor'.</para>
  1893. </parameter>
  1894. <parameter name="ObjectName">
  1895. <para>The name of this object.</para>
  1896. </parameter>
  1897. <parameter name="MinimumExpiration">
  1898. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='minimum_expiration']/synopsis/node())"/></para>
  1899. </parameter>
  1900. <parameter name="MaximumExpiration">
  1901. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='maximum_expiration']/synopsis/node())"/></para>
  1902. </parameter>
  1903. <parameter name="DefaultExpiration">
  1904. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='default_expiration']/synopsis/node())"/></para>
  1905. </parameter>
  1906. <parameter name="QualifyFrequency">
  1907. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='qualify_frequency']/synopsis/node())"/></para>
  1908. </parameter>
  1909. <parameter name="AuthenticateQualify">
  1910. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='authenticate_qualify']/synopsis/node())"/></para>
  1911. </parameter>
  1912. <parameter name="MaxContacts">
  1913. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='max_contacts']/synopsis/node())"/></para>
  1914. </parameter>
  1915. <parameter name="RemoveExisting">
  1916. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='remove_existing']/synopsis/node())"/></para>
  1917. </parameter>
  1918. <parameter name="Mailboxes">
  1919. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='mailboxes']/synopsis/node())"/></para>
  1920. </parameter>
  1921. <parameter name="OutboundProxy">
  1922. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='outbound_proxy']/synopsis/node())"/></para>
  1923. </parameter>
  1924. <parameter name="SupportPath">
  1925. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='support_path']/synopsis/node())"/></para>
  1926. </parameter>
  1927. <parameter name="TotalContacts">
  1928. <para>The total number of contacts associated with this AoR.</para>
  1929. </parameter>
  1930. <parameter name="ContactsRegistered">
  1931. <para>The number of non-permanent contacts associated with this AoR.</para>
  1932. </parameter>
  1933. <parameter name="EndpointName">
  1934. <para>The name of the endpoint associated with this information.</para>
  1935. </parameter>
  1936. </syntax>
  1937. </managerEventInstance>
  1938. </managerEvent>
  1939. <managerEvent language="en_US" name="AuthDetail">
  1940. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1941. <synopsis>Provide details about an authentication section.</synopsis>
  1942. <syntax>
  1943. <parameter name="ObjectType">
  1944. <para>The object's type. This will always be 'auth'.</para>
  1945. </parameter>
  1946. <parameter name="ObjectName">
  1947. <para>The name of this object.</para>
  1948. </parameter>
  1949. <parameter name="Username">
  1950. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='username']/synopsis/node())"/></para>
  1951. </parameter>
  1952. <parameter name="Password">
  1953. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='username']/synopsis/node())"/></para>
  1954. </parameter>
  1955. <parameter name="Md5Cred">
  1956. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='md5_cred']/synopsis/node())"/></para>
  1957. </parameter>
  1958. <parameter name="Realm">
  1959. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='realm']/synopsis/node())"/></para>
  1960. </parameter>
  1961. <parameter name="NonceLifetime">
  1962. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='nonce_lifetime']/synopsis/node())"/></para>
  1963. </parameter>
  1964. <parameter name="AuthType">
  1965. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='auth_type']/synopsis/node())"/></para>
  1966. </parameter>
  1967. <parameter name="EndpointName">
  1968. <para>The name of the endpoint associated with this information.</para>
  1969. </parameter>
  1970. </syntax>
  1971. </managerEventInstance>
  1972. </managerEvent>
  1973. <managerEvent language="en_US" name="TransportDetail">
  1974. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1975. <synopsis>Provide details about an authentication section.</synopsis>
  1976. <syntax>
  1977. <parameter name="ObjectType">
  1978. <para>The object's type. This will always be 'transport'.</para>
  1979. </parameter>
  1980. <parameter name="ObjectName">
  1981. <para>The name of this object.</para>
  1982. </parameter>
  1983. <parameter name="Protocol">
  1984. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='protocol']/synopsis/node())"/></para>
  1985. </parameter>
  1986. <parameter name="Bind">
  1987. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='bind']/synopsis/node())"/></para>
  1988. </parameter>
  1989. <parameter name="AsycOperations">
  1990. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='async_operations']/synopsis/node())"/></para>
  1991. </parameter>
  1992. <parameter name="CaListFile">
  1993. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='ca_list_file']/synopsis/node())"/></para>
  1994. </parameter>
  1995. <parameter name="CaListPath">
  1996. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='ca_list_path']/synopsis/node())"/></para>
  1997. </parameter>
  1998. <parameter name="CertFile">
  1999. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='cert_file']/synopsis/node())"/></para>
  2000. </parameter>
  2001. <parameter name="PrivKeyFile">
  2002. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='priv_key_file']/synopsis/node())"/></para>
  2003. </parameter>
  2004. <parameter name="Password">
  2005. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='password']/synopsis/node())"/></para>
  2006. </parameter>
  2007. <parameter name="ExternalSignalingAddress">
  2008. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='external_signaling_address']/synopsis/node())"/></para>
  2009. </parameter>
  2010. <parameter name="ExternalSignalingPort">
  2011. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='external_signaling_port']/synopsis/node())"/></para>
  2012. </parameter>
  2013. <parameter name="ExternalMediaAddress">
  2014. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='external_media_address']/synopsis/node())"/></para>
  2015. </parameter>
  2016. <parameter name="Domain">
  2017. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='domain']/synopsis/node())"/></para>
  2018. </parameter>
  2019. <parameter name="VerifyServer">
  2020. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='verify_server']/synopsis/node())"/></para>
  2021. </parameter>
  2022. <parameter name="VerifyClient">
  2023. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='verify_client']/synopsis/node())"/></para>
  2024. </parameter>
  2025. <parameter name="RequireClientCert">
  2026. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='require_client_cert']/synopsis/node())"/></para>
  2027. </parameter>
  2028. <parameter name="Method">
  2029. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='method']/synopsis/node())"/></para>
  2030. </parameter>
  2031. <parameter name="Cipher">
  2032. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='cipher']/synopsis/node())"/></para>
  2033. </parameter>
  2034. <parameter name="LocalNet">
  2035. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='local_net']/synopsis/node())"/></para>
  2036. </parameter>
  2037. <parameter name="Tos">
  2038. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='tos']/synopsis/node())"/></para>
  2039. </parameter>
  2040. <parameter name="Cos">
  2041. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='cos']/synopsis/node())"/></para>
  2042. </parameter>
  2043. <parameter name="WebsocketWriteTimeout">
  2044. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='websocket_write_timeout']/synopsis/node())"/></para>
  2045. </parameter>
  2046. <parameter name="EndpointName">
  2047. <para>The name of the endpoint associated with this information.</para>
  2048. </parameter>
  2049. </syntax>
  2050. </managerEventInstance>
  2051. </managerEvent>
  2052. <managerEvent language="en_US" name="EndpointDetail">
  2053. <managerEventInstance class="EVENT_FLAG_COMMAND">
  2054. <synopsis>Provide details about an endpoint section.</synopsis>
  2055. <syntax>
  2056. <parameter name="ObjectType">
  2057. <para>The object's type. This will always be 'endpoint'.</para>
  2058. </parameter>
  2059. <parameter name="ObjectName">
  2060. <para>The name of this object.</para>
  2061. </parameter>
  2062. <parameter name="Context">
  2063. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='context']/synopsis/node())"/></para>
  2064. </parameter>
  2065. <parameter name="Disallow">
  2066. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='disallow']/synopsis/node())"/></para>
  2067. </parameter>
  2068. <parameter name="Allow">
  2069. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow']/synopsis/node())"/></para>
  2070. </parameter>
  2071. <parameter name="DtmfMode">
  2072. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtmf_mode']/synopsis/node())"/></para>
  2073. </parameter>
  2074. <parameter name="RtpIpv6">
  2075. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rtp_ipv6']/synopsis/node())"/></para>
  2076. </parameter>
  2077. <parameter name="RtpSymmetric">
  2078. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rtp_symmetric']/synopsis/node())"/></para>
  2079. </parameter>
  2080. <parameter name="IceSupport">
  2081. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='ice_support']/synopsis/node())"/></para>
  2082. </parameter>
  2083. <parameter name="UsePtime">
  2084. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='use_ptime']/synopsis/node())"/></para>
  2085. </parameter>
  2086. <parameter name="ForceRport">
  2087. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='force_rport']/synopsis/node())"/></para>
  2088. </parameter>
  2089. <parameter name="RewriteContact">
  2090. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rewrite_contact']/synopsis/node())"/></para>
  2091. </parameter>
  2092. <parameter name="Transport">
  2093. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='transport']/synopsis/node())"/></para>
  2094. </parameter>
  2095. <parameter name="OutboundProxy">
  2096. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='outbound_proxy']/synopsis/node())"/></para>
  2097. </parameter>
  2098. <parameter name="MohSuggest">
  2099. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='moh_suggest']/synopsis/node())"/></para>
  2100. </parameter>
  2101. <parameter name="100rel">
  2102. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='100rel']/synopsis/node())"/></para>
  2103. </parameter>
  2104. <parameter name="Timers">
  2105. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='timers']/synopsis/node())"/></para>
  2106. </parameter>
  2107. <parameter name="TimersMinSe">
  2108. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='timers_min_se']/synopsis/node())"/></para>
  2109. </parameter>
  2110. <parameter name="TimersSessExpires">
  2111. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='timers_sess_expires']/synopsis/node())"/></para>
  2112. </parameter>
  2113. <parameter name="Auth">
  2114. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='auth']/synopsis/node())"/></para>
  2115. </parameter>
  2116. <parameter name="OutboundAuth">
  2117. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='outbound_auth']/synopsis/node())"/></para>
  2118. </parameter>
  2119. <parameter name="Aors">
  2120. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='aors']/synopsis/node())"/></para>
  2121. </parameter>
  2122. <parameter name="MediaAddress">
  2123. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='media_address']/synopsis/node())"/></para>
  2124. </parameter>
  2125. <parameter name="IdentifyBy">
  2126. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='identify_by']/synopsis/node())"/></para>
  2127. </parameter>
  2128. <parameter name="DirectMedia">
  2129. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='direct_media']/synopsis/node())"/></para>
  2130. </parameter>
  2131. <parameter name="DirectMediaMethod">
  2132. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='direct_media_method']/synopsis/node())"/></para>
  2133. </parameter>
  2134. <parameter name="TrustConnectedLine">
  2135. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='trust_connected_line']/synopsis/node())"/></para>
  2136. </parameter>
  2137. <parameter name="SendConnectedLine">
  2138. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_connected_line']/synopsis/node())"/></para>
  2139. </parameter>
  2140. <parameter name="ConnectedLineMethod">
  2141. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='connected_line_method']/synopsis/node())"/></para>
  2142. </parameter>
  2143. <parameter name="DirectMediaGlareMitigation">
  2144. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='direct_media_glare_mitigation']/synopsis/node())"/></para>
  2145. </parameter>
  2146. <parameter name="DisableDirectMediaOnNat">
  2147. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='disable_direct_media_on_nat']/synopsis/node())"/></para>
  2148. </parameter>
  2149. <parameter name="Callerid">
  2150. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='callerid']/synopsis/node())"/></para>
  2151. </parameter>
  2152. <parameter name="CalleridPrivacy">
  2153. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='callerid_privacy']/synopsis/node())"/></para>
  2154. </parameter>
  2155. <parameter name="CalleridTag">
  2156. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='callerid_tag']/synopsis/node())"/></para>
  2157. </parameter>
  2158. <parameter name="TrustIdInbound">
  2159. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='trust_id_inbound']/synopsis/node())"/></para>
  2160. </parameter>
  2161. <parameter name="TrustIdOutbound">
  2162. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='trust_id_outbound']/synopsis/node())"/></para>
  2163. </parameter>
  2164. <parameter name="SendPai">
  2165. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_pai']/synopsis/node())"/></para>
  2166. </parameter>
  2167. <parameter name="SendRpid">
  2168. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_rpid']/synopsis/node())"/></para>
  2169. </parameter>
  2170. <parameter name="SendDiversion">
  2171. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_diversion']/synopsis/node())"/></para>
  2172. </parameter>
  2173. <parameter name="Mailboxes">
  2174. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='mailboxes']/synopsis/node())"/></para>
  2175. </parameter>
  2176. <parameter name="AggregateMwi">
  2177. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='aggregate_mwi']/synopsis/node())"/></para>
  2178. </parameter>
  2179. <parameter name="MediaEncryption">
  2180. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='media_encryption']/synopsis/node())"/></para>
  2181. </parameter>
  2182. <parameter name="MediaEncryptionOptimistic">
  2183. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='media_encryption_optimistic']/synopsis/node())"/></para>
  2184. </parameter>
  2185. <parameter name="UseAvpf">
  2186. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='use_avpf']/synopsis/node())"/></para>
  2187. </parameter>
  2188. <parameter name="ForceAvp">
  2189. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='force_avp']/synopsis/node())"/></para>
  2190. </parameter>
  2191. <parameter name="MediaUseReceivedTransport">
  2192. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='media_use_received_transport']/synopsis/node())"/></para>
  2193. </parameter>
  2194. <parameter name="OneTouchRecording">
  2195. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='one_touch_recording']/synopsis/node())"/></para>
  2196. </parameter>
  2197. <parameter name="InbandProgress">
  2198. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='inband_progress']/synopsis/node())"/></para>
  2199. </parameter>
  2200. <parameter name="CallGroup">
  2201. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='call_group']/synopsis/node())"/></para>
  2202. </parameter>
  2203. <parameter name="PickupGroup">
  2204. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='pickup_group']/synopsis/node())"/></para>
  2205. </parameter>
  2206. <parameter name="NamedCallGroup">
  2207. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='named_call_group']/synopsis/node())"/></para>
  2208. </parameter>
  2209. <parameter name="NamedPickupGroup">
  2210. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='named_pickup_group']/synopsis/node())"/></para>
  2211. </parameter>
  2212. <parameter name="DeviceStateBusyAt">
  2213. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='device_state_busy_at']/synopsis/node())"/></para>
  2214. </parameter>
  2215. <parameter name="T38Udptl">
  2216. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='t38_udptl']/synopsis/node())"/></para>
  2217. </parameter>
  2218. <parameter name="T38UdptlEc">
  2219. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='t38_udptl_ec']/synopsis/node())"/></para>
  2220. </parameter>
  2221. <parameter name="T38UdptlMaxdatagram">
  2222. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='t38_udptl_maxdatagram']/synopsis/node())"/></para>
  2223. </parameter>
  2224. <parameter name="FaxDetect">
  2225. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='fax_detect']/synopsis/node())"/></para>
  2226. </parameter>
  2227. <parameter name="T38UdptlNat">
  2228. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='t38_udptl_nat']/synopsis/node())"/></para>
  2229. </parameter>
  2230. <parameter name="T38UdptlIpv6">
  2231. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='t38_udptl_ipv6']/synopsis/node())"/></para>
  2232. </parameter>
  2233. <parameter name="ToneZone">
  2234. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='tone_zone']/synopsis/node())"/></para>
  2235. </parameter>
  2236. <parameter name="Language">
  2237. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='language']/synopsis/node())"/></para>
  2238. </parameter>
  2239. <parameter name="RecordOnFeature">
  2240. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='record_on_feature']/synopsis/node())"/></para>
  2241. </parameter>
  2242. <parameter name="RecordOffFeature">
  2243. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='record_off_feature']/synopsis/node())"/></para>
  2244. </parameter>
  2245. <parameter name="AllowTransfer">
  2246. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow_transfer']/synopsis/node())"/></para>
  2247. </parameter>
  2248. <parameter name="UserEqPhone">
  2249. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='user_eq_phone']/synopsis/node())"/></para>
  2250. </parameter>
  2251. <parameter name="SdpOwner">
  2252. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='sdp_owner']/synopsis/node())"/></para>
  2253. </parameter>
  2254. <parameter name="SdpSession">
  2255. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='sdp_session']/synopsis/node())"/></para>
  2256. </parameter>
  2257. <parameter name="TosAudio">
  2258. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='tos_audio']/synopsis/node())"/></para>
  2259. </parameter>
  2260. <parameter name="TosVideo">
  2261. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='tos_video']/synopsis/node())"/></para>
  2262. </parameter>
  2263. <parameter name="CosAudio">
  2264. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='cos_audio']/synopsis/node())"/></para>
  2265. </parameter>
  2266. <parameter name="CosVideo">
  2267. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='cos_video']/synopsis/node())"/></para>
  2268. </parameter>
  2269. <parameter name="AllowSubscribe">
  2270. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow_subscribe']/synopsis/node())"/></para>
  2271. </parameter>
  2272. <parameter name="SubMinExpiry">
  2273. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='sub_min_expiry']/synopsis/node())"/></para>
  2274. </parameter>
  2275. <parameter name="FromUser">
  2276. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='from_user']/synopsis/node())"/></para>
  2277. </parameter>
  2278. <parameter name="FromDomain">
  2279. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='from_domain']/synopsis/node())"/></para>
  2280. </parameter>
  2281. <parameter name="MwiFromUser">
  2282. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='mwi_from_user']/synopsis/node())"/></para>
  2283. </parameter>
  2284. <parameter name="RtpEngine">
  2285. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rtp_engine']/synopsis/node())"/></para>
  2286. </parameter>
  2287. <parameter name="DtlsVerify">
  2288. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_verify']/synopsis/node())"/></para>
  2289. </parameter>
  2290. <parameter name="DtlsRekey">
  2291. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_rekey']/synopsis/node())"/></para>
  2292. </parameter>
  2293. <parameter name="DtlsCertFile">
  2294. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_cert_file']/synopsis/node())"/></para>
  2295. </parameter>
  2296. <parameter name="DtlsPrivateKey">
  2297. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_private_key']/synopsis/node())"/></para>
  2298. </parameter>
  2299. <parameter name="DtlsCipher">
  2300. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_cipher']/synopsis/node())"/></para>
  2301. </parameter>
  2302. <parameter name="DtlsCaFile">
  2303. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_ca_file']/synopsis/node())"/></para>
  2304. </parameter>
  2305. <parameter name="DtlsCaPath">
  2306. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_ca_path']/synopsis/node())"/></para>
  2307. </parameter>
  2308. <parameter name="DtlsSetup">
  2309. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_setup']/synopsis/node())"/></para>
  2310. </parameter>
  2311. <parameter name="SrtpTag32">
  2312. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='srtp_tag_32']/synopsis/node())"/></para>
  2313. </parameter>
  2314. <parameter name="RedirectMethod">
  2315. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='redirect_method']/synopsis/node())"/></para>
  2316. </parameter>
  2317. <parameter name="SetVar">
  2318. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='set_var']/synopsis/node())"/></para>
  2319. </parameter>
  2320. <parameter name="MessageContext">
  2321. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='message_context']/synopsis/node())"/></para>
  2322. </parameter>
  2323. <parameter name="Accountcode">
  2324. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='accountcode']/synopsis/node())"/></para>
  2325. </parameter>
  2326. <parameter name="DeviceState">
  2327. <para>The aggregate device state for this endpoint.</para>
  2328. </parameter>
  2329. <parameter name="ActiveChannels">
  2330. <para>The number of active channels associated with this endpoint.</para>
  2331. </parameter>
  2332. <parameter name="SubscribeContext">
  2333. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='subscribe_context']/synopsis/node())"/></para>
  2334. </parameter>
  2335. <parameter name="Allowoverlap">
  2336. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow_overlap']/synopsis/node())"/></para>
  2337. </parameter>
  2338. </syntax>
  2339. </managerEventInstance>
  2340. </managerEvent>
  2341. <managerEvent language="en_US" name="ContactStatusDetail">
  2342. <managerEventInstance class="EVENT_FLAG_COMMAND">
  2343. <synopsis>Provide details about a contact's status.</synopsis>
  2344. <syntax>
  2345. <parameter name="AOR">
  2346. <para>The AoR that owns this contact.</para>
  2347. </parameter>
  2348. <parameter name="URI">
  2349. <para>This contact's URI.</para>
  2350. </parameter>
  2351. <parameter name="Status">
  2352. <para>This contact's status.</para>
  2353. <enumlist>
  2354. <enum name="Reachable"/>
  2355. <enum name="Unreachable"/>
  2356. </enumlist>
  2357. </parameter>
  2358. <parameter name="RoundtripUsec">
  2359. <para>The round trip time in microseconds.</para>
  2360. </parameter>
  2361. <parameter name="EndpointName">
  2362. <para>The name of the endpoint associated with this information.</para>
  2363. </parameter>
  2364. <parameter name="UserAgent">
  2365. <para>Content of the User-Agent header in REGISTER request</para>
  2366. </parameter>
  2367. <parameter name="RegExpire">
  2368. <para>Absolute time that this contact is no longer valid after</para>
  2369. </parameter>
  2370. <parameter name="ViaAddress">
  2371. <para>IP address:port of the last Via header in REGISTER request.
  2372. Will only appear in the event if available.</para>
  2373. </parameter>
  2374. <parameter name="CallID">
  2375. <para>Content of the Call-ID header in REGISTER request.
  2376. Will only appear in the event if available.</para>
  2377. </parameter>
  2378. <parameter name="ID">
  2379. <para>The sorcery ID of the contact.</para>
  2380. </parameter>
  2381. <parameter name="AuthenticateQualify">
  2382. <para>A boolean indicating whether a qualify should be authenticated.</para>
  2383. </parameter>
  2384. <parameter name="OutboundProxy">
  2385. <para>The contact's outbound proxy.</para>
  2386. </parameter>
  2387. <parameter name="Path">
  2388. <para>The Path header received on the REGISTER.</para>
  2389. </parameter>
  2390. <parameter name="QualifyFrequency">
  2391. <para>The interval in seconds at which the contact will be qualified.</para>
  2392. </parameter>
  2393. <parameter name="QualifyTimeout">
  2394. <para>The elapsed time in decimal seconds after which an OPTIONS
  2395. message is sent before the contact is considered unavailable.</para>
  2396. </parameter>
  2397. </syntax>
  2398. </managerEventInstance>
  2399. </managerEvent>
  2400. <managerEvent language="en_US" name="EndpointList">
  2401. <managerEventInstance class="EVENT_FLAG_COMMAND">
  2402. <synopsis>Provide details about a contact's status.</synopsis>
  2403. <syntax>
  2404. <parameter name="ObjectType">
  2405. <para>The object's type. This will always be 'endpoint'.</para>
  2406. </parameter>
  2407. <parameter name="ObjectName">
  2408. <para>The name of this object.</para>
  2409. </parameter>
  2410. <parameter name="Transport">
  2411. <para>The transport configurations associated with this endpoint.</para>
  2412. </parameter>
  2413. <parameter name="Aor">
  2414. <para>The aor configurations associated with this endpoint.</para>
  2415. </parameter>
  2416. <parameter name="Auths">
  2417. <para>The inbound authentication configurations associated with this endpoint.</para>
  2418. </parameter>
  2419. <parameter name="OutboundAuths">
  2420. <para>The outbound authentication configurations associated with this endpoint.</para>
  2421. </parameter>
  2422. <parameter name="DeviceState">
  2423. <para>The aggregate device state for this endpoint.</para>
  2424. </parameter>
  2425. <parameter name="ActiveChannels">
  2426. <para>The number of active channels associated with this endpoint.</para>
  2427. </parameter>
  2428. </syntax>
  2429. </managerEventInstance>
  2430. </managerEvent>
  2431. <manager name="PJSIPShowEndpoints" language="en_US">
  2432. <synopsis>
  2433. Lists PJSIP endpoints.
  2434. </synopsis>
  2435. <syntax />
  2436. <description>
  2437. <para>
  2438. Provides a listing of all endpoints. For each endpoint an <literal>EndpointList</literal> event
  2439. is raised that contains relevant attributes and status information. Once all
  2440. endpoints have been listed an <literal>EndpointListComplete</literal> event is issued.
  2441. </para>
  2442. </description>
  2443. <responses>
  2444. <list-elements>
  2445. <xi:include xpointer="xpointer(/docs/managerEvent[@name='EndpointList'])" />
  2446. </list-elements>
  2447. <managerEvent language="en_US" name="EndpointListComplete">
  2448. <managerEventInstance class="EVENT_FLAG_COMMAND">
  2449. <synopsis>Provide final information about an endpoint list.</synopsis>
  2450. <syntax>
  2451. <parameter name="EventList"/>
  2452. <parameter name="ListItems"/>
  2453. </syntax>
  2454. </managerEventInstance>
  2455. </managerEvent>
  2456. </responses>
  2457. </manager>
  2458. <manager name="PJSIPShowEndpoint" language="en_US">
  2459. <synopsis>
  2460. Detail listing of an endpoint and its objects.
  2461. </synopsis>
  2462. <syntax>
  2463. <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
  2464. <parameter name="Endpoint" required="true">
  2465. <para>The endpoint to list.</para>
  2466. </parameter>
  2467. </syntax>
  2468. <description>
  2469. <para>
  2470. Provides a detailed listing of options for a given endpoint. Events are issued
  2471. showing the configuration and status of the endpoint and associated objects. These
  2472. events include <literal>EndpointDetail</literal>, <literal>AorDetail</literal>,
  2473. <literal>AuthDetail</literal>, <literal>TransportDetail</literal>, and
  2474. <literal>IdentifyDetail</literal>. Some events may be listed multiple times if multiple objects are
  2475. associated (for instance AoRs). Once all detail events have been raised a final
  2476. <literal>EndpointDetailComplete</literal> event is issued.
  2477. </para>
  2478. </description>
  2479. <responses>
  2480. <list-elements>
  2481. <xi:include xpointer="xpointer(/docs/managerEvent[@name='EndpointDetail'])" />
  2482. <xi:include xpointer="xpointer(/docs/managerEvent[@name='IdentifyDetail'])" />
  2483. <xi:include xpointer="xpointer(/docs/managerEvent[@name='ContactStatusDetail'])" />
  2484. <xi:include xpointer="xpointer(/docs/managerEvent[@name='AuthDetail'])" />
  2485. <xi:include xpointer="xpointer(/docs/managerEvent[@name='TransportDetail'])" />
  2486. <xi:include xpointer="xpointer(/docs/managerEvent[@name='AorDetail'])" />
  2487. </list-elements>
  2488. <managerEvent language="en_US" name="EndpointDetailComplete">
  2489. <managerEventInstance class="EVENT_FLAG_COMMAND">
  2490. <synopsis>Provide final information about endpoint details.</synopsis>
  2491. <syntax>
  2492. <parameter name="EventList"/>
  2493. <parameter name="ListItems"/>
  2494. </syntax>
  2495. </managerEventInstance>
  2496. </managerEvent>
  2497. </responses>
  2498. </manager>
  2499. ***/
  2500. #define MOD_DATA_CONTACT "contact"
  2501. /*! Number of serializers in pool if one not supplied. */
  2502. #define SERIALIZER_POOL_SIZE 8
  2503. /*! Pool of serializers to use if not supplied. */
  2504. static struct ast_taskprocessor *serializer_pool[SERIALIZER_POOL_SIZE];
  2505. static pjsip_endpoint *ast_pjsip_endpoint;
  2506. static struct ast_threadpool *sip_threadpool;
  2507. /*! Local host address for IPv4 */
  2508. static pj_sockaddr host_ip_ipv4;
  2509. /*! Local host address for IPv4 (string form) */
  2510. static char host_ip_ipv4_string[PJ_INET6_ADDRSTRLEN];
  2511. /*! Local host address for IPv6 */
  2512. static pj_sockaddr host_ip_ipv6;
  2513. /*! Local host address for IPv6 (string form) */
  2514. static char host_ip_ipv6_string[PJ_INET6_ADDRSTRLEN];
  2515. static int register_service_noref(void *data)
  2516. {
  2517. pjsip_module **module = data;
  2518. if (!ast_pjsip_endpoint) {
  2519. ast_log(LOG_ERROR, "There is no PJSIP endpoint. Unable to register services\n");
  2520. return -1;
  2521. }
  2522. if (pjsip_endpt_register_module(ast_pjsip_endpoint, *module) != PJ_SUCCESS) {
  2523. ast_log(LOG_ERROR, "Unable to register module %.*s\n", (int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name));
  2524. return -1;
  2525. }
  2526. ast_debug(1, "Registered SIP service %.*s (%p)\n", (int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name), *module);
  2527. return 0;
  2528. }
  2529. static int register_service(void *data)
  2530. {
  2531. int res;
  2532. if (!(res = register_service_noref(data))) {
  2533. ast_module_ref(ast_module_info->self);
  2534. }
  2535. return res;
  2536. }
  2537. int internal_sip_register_service(pjsip_module *module)
  2538. {
  2539. return ast_sip_push_task_wait_servant(NULL, register_service_noref, &module);
  2540. }
  2541. int ast_sip_register_service(pjsip_module *module)
  2542. {
  2543. return ast_sip_push_task_wait_servant(NULL, register_service, &module);
  2544. }
  2545. static int unregister_service_noref(void *data)
  2546. {
  2547. pjsip_module **module = data;
  2548. if (!ast_pjsip_endpoint) {
  2549. return -1;
  2550. }
  2551. pjsip_endpt_unregister_module(ast_pjsip_endpoint, *module);
  2552. ast_debug(1, "Unregistered SIP service %.*s\n", (int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name));
  2553. return 0;
  2554. }
  2555. static int unregister_service(void *data)
  2556. {
  2557. int res;
  2558. if (!(res = unregister_service_noref(data))) {
  2559. ast_module_unref(ast_module_info->self);
  2560. }
  2561. return res;
  2562. }
  2563. int internal_sip_unregister_service(pjsip_module *module)
  2564. {
  2565. return ast_sip_push_task_wait_servant(NULL, unregister_service_noref, &module);
  2566. }
  2567. void ast_sip_unregister_service(pjsip_module *module)
  2568. {
  2569. ast_sip_push_task_wait_servant(NULL, unregister_service, &module);
  2570. }
  2571. static struct ast_sip_authenticator *registered_authenticator;
  2572. int ast_sip_register_authenticator(struct ast_sip_authenticator *auth)
  2573. {
  2574. if (registered_authenticator) {
  2575. ast_log(LOG_WARNING, "Authenticator %p is already registered. Cannot register a new one\n", registered_authenticator);
  2576. return -1;
  2577. }
  2578. registered_authenticator = auth;
  2579. ast_debug(1, "Registered SIP authenticator module %p\n", auth);
  2580. ast_module_ref(ast_module_info->self);
  2581. return 0;
  2582. }
  2583. void ast_sip_unregister_authenticator(struct ast_sip_authenticator *auth)
  2584. {
  2585. if (registered_authenticator != auth) {
  2586. ast_log(LOG_WARNING, "Trying to unregister authenticator %p but authenticator %p registered\n",
  2587. auth, registered_authenticator);
  2588. return;
  2589. }
  2590. registered_authenticator = NULL;
  2591. ast_debug(1, "Unregistered SIP authenticator %p\n", auth);
  2592. ast_module_unref(ast_module_info->self);
  2593. }
  2594. int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
  2595. {
  2596. if (!registered_authenticator) {
  2597. ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is not required\n");
  2598. return 0;
  2599. }
  2600. return registered_authenticator->requires_authentication(endpoint, rdata);
  2601. }
  2602. enum ast_sip_check_auth_result ast_sip_check_authentication(struct ast_sip_endpoint *endpoint,
  2603. pjsip_rx_data *rdata, pjsip_tx_data *tdata)
  2604. {
  2605. if (!registered_authenticator) {
  2606. ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is successful\n");
  2607. return AST_SIP_AUTHENTICATION_SUCCESS;
  2608. }
  2609. return registered_authenticator->check_authentication(endpoint, rdata, tdata);
  2610. }
  2611. static struct ast_sip_outbound_authenticator *registered_outbound_authenticator;
  2612. int ast_sip_register_outbound_authenticator(struct ast_sip_outbound_authenticator *auth)
  2613. {
  2614. if (registered_outbound_authenticator) {
  2615. ast_log(LOG_WARNING, "Outbound authenticator %p is already registered. Cannot register a new one\n", registered_outbound_authenticator);
  2616. return -1;
  2617. }
  2618. registered_outbound_authenticator = auth;
  2619. ast_debug(1, "Registered SIP outbound authenticator module %p\n", auth);
  2620. ast_module_ref(ast_module_info->self);
  2621. return 0;
  2622. }
  2623. void ast_sip_unregister_outbound_authenticator(struct ast_sip_outbound_authenticator *auth)
  2624. {
  2625. if (registered_outbound_authenticator != auth) {
  2626. ast_log(LOG_WARNING, "Trying to unregister outbound authenticator %p but outbound authenticator %p registered\n",
  2627. auth, registered_outbound_authenticator);
  2628. return;
  2629. }
  2630. registered_outbound_authenticator = NULL;
  2631. ast_debug(1, "Unregistered SIP outbound authenticator %p\n", auth);
  2632. ast_module_unref(ast_module_info->self);
  2633. }
  2634. int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge,
  2635. pjsip_transaction *tsx, pjsip_tx_data **new_request)
  2636. {
  2637. if (!registered_outbound_authenticator) {
  2638. ast_log(LOG_WARNING, "No SIP outbound authenticator registered. Cannot respond to authentication challenge\n");
  2639. return -1;
  2640. }
  2641. return registered_outbound_authenticator->create_request_with_auth(auths, challenge, tsx, new_request);
  2642. }
  2643. int ast_sip_create_request_with_auth_from_old(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge,
  2644. pjsip_tx_data *old_request, pjsip_tx_data **new_request)
  2645. {
  2646. if (!registered_outbound_authenticator) {
  2647. ast_log(LOG_WARNING, "No SIP outbound authenticator registered. Cannot respond to authentication challenge\n");
  2648. return -1;
  2649. }
  2650. return registered_outbound_authenticator->create_request_with_auth_from_old(auths, challenge, old_request, new_request);
  2651. }
  2652. struct endpoint_identifier_list {
  2653. const char *name;
  2654. unsigned int priority;
  2655. struct ast_sip_endpoint_identifier *identifier;
  2656. AST_RWLIST_ENTRY(endpoint_identifier_list) list;
  2657. };
  2658. static AST_RWLIST_HEAD_STATIC(endpoint_identifiers, endpoint_identifier_list);
  2659. int ast_sip_register_endpoint_identifier_with_name(struct ast_sip_endpoint_identifier *identifier,
  2660. const char *name)
  2661. {
  2662. char *prev, *current, *identifier_order;
  2663. struct endpoint_identifier_list *iter, *id_list_item;
  2664. SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  2665. id_list_item = ast_calloc(1, sizeof(*id_list_item));
  2666. if (!id_list_item) {
  2667. ast_log(LOG_ERROR, "Unable to add endpoint identifier. Out of memory.\n");
  2668. return -1;
  2669. }
  2670. id_list_item->identifier = identifier;
  2671. id_list_item->name = name;
  2672. ast_debug(1, "Register endpoint identifier %s(%p)\n", name ?: "", identifier);
  2673. if (ast_strlen_zero(name)) {
  2674. /* if an identifier has no name then place in front */
  2675. AST_RWLIST_INSERT_HEAD(&endpoint_identifiers, id_list_item, list);
  2676. ast_module_ref(ast_module_info->self);
  2677. return 0;
  2678. }
  2679. /* see if the name of the identifier is in the global endpoint_identifier_order list */
  2680. identifier_order = prev = current = ast_sip_get_endpoint_identifier_order();
  2681. if (ast_strlen_zero(identifier_order)) {
  2682. id_list_item->priority = UINT_MAX;
  2683. AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
  2684. ast_module_ref(ast_module_info->self);
  2685. ast_free(identifier_order);
  2686. return 0;
  2687. }
  2688. id_list_item->priority = 0;
  2689. while ((current = strchr(current, ','))) {
  2690. ++id_list_item->priority;
  2691. if (!strncmp(prev, name, current - prev)
  2692. && strlen(name) == current - prev) {
  2693. break;
  2694. }
  2695. prev = ++current;
  2696. }
  2697. if (!current) {
  2698. /* check to see if it is the only or last item */
  2699. if (!strcmp(prev, name)) {
  2700. ++id_list_item->priority;
  2701. } else {
  2702. id_list_item->priority = UINT_MAX;
  2703. }
  2704. }
  2705. if (id_list_item->priority == UINT_MAX || AST_RWLIST_EMPTY(&endpoint_identifiers)) {
  2706. /* if not in the endpoint_identifier_order list then consider it less in
  2707. priority and add it to the end */
  2708. AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
  2709. ast_module_ref(ast_module_info->self);
  2710. ast_free(identifier_order);
  2711. return 0;
  2712. }
  2713. AST_RWLIST_TRAVERSE_SAFE_BEGIN(&endpoint_identifiers, iter, list) {
  2714. if (id_list_item->priority < iter->priority) {
  2715. AST_RWLIST_INSERT_BEFORE_CURRENT(id_list_item, list);
  2716. break;
  2717. }
  2718. if (!AST_RWLIST_NEXT(iter, list)) {
  2719. AST_RWLIST_INSERT_AFTER(&endpoint_identifiers, iter, id_list_item, list);
  2720. break;
  2721. }
  2722. }
  2723. AST_RWLIST_TRAVERSE_SAFE_END;
  2724. ast_module_ref(ast_module_info->self);
  2725. ast_free(identifier_order);
  2726. return 0;
  2727. }
  2728. int ast_sip_register_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
  2729. {
  2730. return ast_sip_register_endpoint_identifier_with_name(identifier, NULL);
  2731. }
  2732. void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
  2733. {
  2734. struct endpoint_identifier_list *iter;
  2735. SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  2736. AST_RWLIST_TRAVERSE_SAFE_BEGIN(&endpoint_identifiers, iter, list) {
  2737. if (iter->identifier == identifier) {
  2738. AST_RWLIST_REMOVE_CURRENT(list);
  2739. ast_free(iter);
  2740. ast_debug(1, "Unregistered endpoint identifier %p\n", identifier);
  2741. ast_module_unref(ast_module_info->self);
  2742. break;
  2743. }
  2744. }
  2745. AST_RWLIST_TRAVERSE_SAFE_END;
  2746. }
  2747. struct ast_sip_endpoint *ast_sip_identify_endpoint(pjsip_rx_data *rdata)
  2748. {
  2749. struct endpoint_identifier_list *iter;
  2750. struct ast_sip_endpoint *endpoint = NULL;
  2751. SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
  2752. AST_RWLIST_TRAVERSE(&endpoint_identifiers, iter, list) {
  2753. ast_assert(iter->identifier->identify_endpoint != NULL);
  2754. endpoint = iter->identifier->identify_endpoint(rdata);
  2755. if (endpoint) {
  2756. break;
  2757. }
  2758. }
  2759. return endpoint;
  2760. }
  2761. static int do_cli_dump_endpt(void *v_a)
  2762. {
  2763. struct ast_cli_args *a = v_a;
  2764. ast_pjproject_log_intercept_begin(a->fd);
  2765. pjsip_endpt_dump(ast_sip_get_pjsip_endpoint(), a->argc == 4 ? PJ_TRUE : PJ_FALSE);
  2766. ast_pjproject_log_intercept_end();
  2767. return 0;
  2768. }
  2769. static char *cli_dump_endpt(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
  2770. {
  2771. switch (cmd) {
  2772. case CLI_INIT:
  2773. #ifdef AST_DEVMODE
  2774. e->command = "pjsip dump endpt [details]";
  2775. e->usage =
  2776. "Usage: pjsip dump endpt [details]\n"
  2777. " Dump the res_pjsip endpt internals.\n"
  2778. "\n"
  2779. "Warning: PJPROJECT documents that the function used by this\n"
  2780. "CLI command may cause a crash when asking for details because\n"
  2781. "it tries to access all active memory pools.\n";
  2782. #else
  2783. /*
  2784. * In non-developer mode we will not document or make easily accessible
  2785. * the details option even though it is still available. The user has
  2786. * to know it exists to use it. Presumably they would also be aware of
  2787. * the potential crash warning.
  2788. */
  2789. e->command = "pjsip dump endpt";
  2790. e->usage =
  2791. "Usage: pjsip dump endpt\n"
  2792. " Dump the res_pjsip endpt internals.\n";
  2793. #endif /* AST_DEVMODE */
  2794. return NULL;
  2795. case CLI_GENERATE:
  2796. return NULL;
  2797. }
  2798. if (4 < a->argc
  2799. || (a->argc == 4 && strcasecmp(a->argv[3], "details"))) {
  2800. return CLI_SHOWUSAGE;
  2801. }
  2802. ast_sip_push_task_wait_servant(NULL, do_cli_dump_endpt, a);
  2803. return CLI_SUCCESS;
  2804. }
  2805. static char *cli_show_endpoint_identifiers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
  2806. {
  2807. #define ENDPOINT_IDENTIFIER_FORMAT "%-20.20s\n"
  2808. struct endpoint_identifier_list *iter;
  2809. switch (cmd) {
  2810. case CLI_INIT:
  2811. e->command = "pjsip show identifiers";
  2812. e->usage = "Usage: pjsip show identifiers\n"
  2813. " List all registered endpoint identifiers\n";
  2814. return NULL;
  2815. case CLI_GENERATE:
  2816. return NULL;
  2817. }
  2818. if (a->argc != 3) {
  2819. return CLI_SHOWUSAGE;
  2820. }
  2821. ast_cli(a->fd, ENDPOINT_IDENTIFIER_FORMAT, "Identifier Names:");
  2822. {
  2823. SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
  2824. AST_RWLIST_TRAVERSE(&endpoint_identifiers, iter, list) {
  2825. ast_cli(a->fd, ENDPOINT_IDENTIFIER_FORMAT,
  2826. iter->name ? iter->name : "name not specified");
  2827. }
  2828. }
  2829. return CLI_SUCCESS;
  2830. #undef ENDPOINT_IDENTIFIER_FORMAT
  2831. }
  2832. static char *cli_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
  2833. {
  2834. struct ast_sip_cli_context context;
  2835. switch (cmd) {
  2836. case CLI_INIT:
  2837. e->command = "pjsip show settings";
  2838. e->usage = "Usage: pjsip show settings\n"
  2839. " Show global and system configuration options\n";
  2840. return NULL;
  2841. case CLI_GENERATE:
  2842. return NULL;
  2843. }
  2844. context.output_buffer = ast_str_create(256);
  2845. if (!context.output_buffer) {
  2846. ast_cli(a->fd, "Could not allocate output buffer.\n");
  2847. return CLI_FAILURE;
  2848. }
  2849. if (sip_cli_print_global(&context) || sip_cli_print_system(&context)) {
  2850. ast_free(context.output_buffer);
  2851. ast_cli(a->fd, "Error retrieving settings.\n");
  2852. return CLI_FAILURE;
  2853. }
  2854. ast_cli(a->fd, "%s", ast_str_buffer(context.output_buffer));
  2855. ast_free(context.output_buffer);
  2856. return CLI_SUCCESS;
  2857. }
  2858. static struct ast_cli_entry cli_commands[] = {
  2859. AST_CLI_DEFINE(cli_dump_endpt, "Dump the res_pjsip endpt internals"),
  2860. AST_CLI_DEFINE(cli_show_settings, "Show global and system configuration options"),
  2861. AST_CLI_DEFINE(cli_show_endpoint_identifiers, "List registered endpoint identifiers")
  2862. };
  2863. AST_RWLIST_HEAD_STATIC(endpoint_formatters, ast_sip_endpoint_formatter);
  2864. void internal_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
  2865. {
  2866. SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  2867. AST_RWLIST_INSERT_TAIL(&endpoint_formatters, obj, next);
  2868. }
  2869. int ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
  2870. {
  2871. internal_sip_register_endpoint_formatter(obj);
  2872. ast_module_ref(ast_module_info->self);
  2873. return 0;
  2874. }
  2875. int internal_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
  2876. {
  2877. struct ast_sip_endpoint_formatter *i;
  2878. SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  2879. AST_RWLIST_TRAVERSE_SAFE_BEGIN(&endpoint_formatters, i, next) {
  2880. if (i == obj) {
  2881. AST_RWLIST_REMOVE_CURRENT(next);
  2882. break;
  2883. }
  2884. }
  2885. AST_RWLIST_TRAVERSE_SAFE_END;
  2886. return i == obj ? 0 : -1;
  2887. }
  2888. void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
  2889. {
  2890. if (!internal_sip_unregister_endpoint_formatter(obj)) {
  2891. ast_module_unref(ast_module_info->self);
  2892. }
  2893. }
  2894. int ast_sip_format_endpoint_ami(struct ast_sip_endpoint *endpoint,
  2895. struct ast_sip_ami *ami, int *count)
  2896. {
  2897. int res = 0;
  2898. struct ast_sip_endpoint_formatter *i;
  2899. SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
  2900. *count = 0;
  2901. AST_RWLIST_TRAVERSE(&endpoint_formatters, i, next) {
  2902. if (i->format_ami && ((res = i->format_ami(endpoint, ami)) < 0)) {
  2903. return res;
  2904. }
  2905. if (!res) {
  2906. (*count)++;
  2907. }
  2908. }
  2909. return 0;
  2910. }
  2911. pjsip_endpoint *ast_sip_get_pjsip_endpoint(void)
  2912. {
  2913. return ast_pjsip_endpoint;
  2914. }
  2915. int ast_sip_will_uri_survive_restart(pjsip_sip_uri *uri, struct ast_sip_endpoint *endpoint,
  2916. pjsip_rx_data *rdata)
  2917. {
  2918. pj_str_t host_name;
  2919. int result = 1;
  2920. /* Determine if the contact cannot survive a restart/boot. */
  2921. if (uri->port == rdata->pkt_info.src_port
  2922. && !pj_strcmp(&uri->host,
  2923. pj_cstr(&host_name, rdata->pkt_info.src_name))
  2924. /* We have already checked if the URI scheme is sip: or sips: */
  2925. && PJSIP_TRANSPORT_IS_RELIABLE(rdata->tp_info.transport)) {
  2926. pj_str_t type_name;
  2927. /* Determine the transport parameter value */
  2928. if (!strcasecmp("WSS", rdata->tp_info.transport->type_name)) {
  2929. /* WSS is special, as it needs to be ws. */
  2930. pj_cstr(&type_name, "ws");
  2931. } else {
  2932. pj_cstr(&type_name, rdata->tp_info.transport->type_name);
  2933. }
  2934. if (!pj_stricmp(&uri->transport_param, &type_name)
  2935. && (endpoint->nat.rewrite_contact
  2936. /* Websockets are always rewritten */
  2937. || !pj_stricmp(&uri->transport_param,
  2938. pj_cstr(&type_name, "ws")))) {
  2939. /*
  2940. * The contact was rewritten to the reliable transport's
  2941. * source address. Disconnecting the transport for any
  2942. * reason invalidates the contact.
  2943. */
  2944. result = 0;
  2945. }
  2946. }
  2947. return result;
  2948. }
  2949. int ast_sip_get_transport_name(const struct ast_sip_endpoint *endpoint,
  2950. pjsip_sip_uri *sip_uri, char *buf, size_t buf_len)
  2951. {
  2952. char *host = NULL;
  2953. static const pj_str_t x_name = { AST_SIP_X_AST_TXP, AST_SIP_X_AST_TXP_LEN };
  2954. pjsip_param *x_transport;
  2955. if (!ast_strlen_zero(endpoint->transport)) {
  2956. ast_copy_string(buf, endpoint->transport, buf_len);
  2957. return 0;
  2958. }
  2959. x_transport = pjsip_param_find(&sip_uri->other_param, &x_name);
  2960. if (!x_transport) {
  2961. return -1;
  2962. }
  2963. /* Only use x_transport if the uri host is an ip (4 or 6) address */
  2964. host = ast_alloca(sip_uri->host.slen + 1);
  2965. ast_copy_pj_str(host, &sip_uri->host, sip_uri->host.slen + 1);
  2966. if (!ast_sockaddr_parse(NULL, host, PARSE_PORT_FORBID)) {
  2967. return -1;
  2968. }
  2969. ast_copy_pj_str(buf, &x_transport->value, buf_len);
  2970. return 0;
  2971. }
  2972. int ast_sip_dlg_set_transport(const struct ast_sip_endpoint *endpoint, pjsip_dialog *dlg,
  2973. pjsip_tpselector *selector)
  2974. {
  2975. pjsip_sip_uri *uri;
  2976. pjsip_tpselector sel = { .type = PJSIP_TPSELECTOR_NONE, };
  2977. uri = pjsip_uri_get_uri(dlg->target);
  2978. if (!selector) {
  2979. selector = &sel;
  2980. }
  2981. ast_sip_set_tpselector_from_ep_or_uri(endpoint, uri, selector);
  2982. pjsip_dlg_set_transport(dlg, selector);
  2983. return 0;
  2984. }
  2985. static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *user,
  2986. const char *domain, const pj_str_t *target, pjsip_tpselector *selector)
  2987. {
  2988. pj_str_t tmp, local_addr;
  2989. pjsip_uri *uri;
  2990. pjsip_sip_uri *sip_uri;
  2991. pjsip_transport_type_e type;
  2992. int local_port;
  2993. char default_user[PJSIP_MAX_URL_SIZE];
  2994. if (ast_strlen_zero(user)) {
  2995. ast_sip_get_default_from_user(default_user, sizeof(default_user));
  2996. user = default_user;
  2997. }
  2998. /* Parse the provided target URI so we can determine what transport it will end up using */
  2999. pj_strdup_with_null(pool, &tmp, target);
  3000. if (!(uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0)) ||
  3001. (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
  3002. return -1;
  3003. }
  3004. sip_uri = pjsip_uri_get_uri(uri);
  3005. /* Determine the transport type to use */
  3006. type = pjsip_transport_get_type_from_name(&sip_uri->transport_param);
  3007. if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) {
  3008. if (type == PJSIP_TRANSPORT_UNSPECIFIED
  3009. || !(pjsip_transport_get_flag_from_type(type) & PJSIP_TRANSPORT_SECURE)) {
  3010. type = PJSIP_TRANSPORT_TLS;
  3011. }
  3012. } else if (!sip_uri->transport_param.slen) {
  3013. type = PJSIP_TRANSPORT_UDP;
  3014. } else if (type == PJSIP_TRANSPORT_UNSPECIFIED) {
  3015. return -1;
  3016. }
  3017. /* If the host is IPv6 turn the transport into an IPv6 version */
  3018. if (pj_strchr(&sip_uri->host, ':')) {
  3019. type |= PJSIP_TRANSPORT_IPV6;
  3020. }
  3021. if (!ast_strlen_zero(domain)) {
  3022. from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
  3023. from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
  3024. "<sip:%s@%s%s%s>",
  3025. user,
  3026. domain,
  3027. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
  3028. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
  3029. return 0;
  3030. }
  3031. /* Get the local bound address for the transport that will be used when communicating with the provided URI */
  3032. if (pjsip_tpmgr_find_local_addr(pjsip_endpt_get_tpmgr(ast_sip_get_pjsip_endpoint()), pool, type, selector,
  3033. &local_addr, &local_port) != PJ_SUCCESS) {
  3034. /* If no local address can be retrieved using the transport manager use the host one */
  3035. pj_strdup(pool, &local_addr, pj_gethostname());
  3036. local_port = pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP);
  3037. }
  3038. /* If IPv6 was specified in the transport, set the proper type */
  3039. if (pj_strchr(&local_addr, ':')) {
  3040. type |= PJSIP_TRANSPORT_IPV6;
  3041. }
  3042. from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
  3043. from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
  3044. "<sip:%s@%s%.*s%s:%d%s%s>",
  3045. user,
  3046. (type & PJSIP_TRANSPORT_IPV6) ? "[" : "",
  3047. (int)local_addr.slen,
  3048. local_addr.ptr,
  3049. (type & PJSIP_TRANSPORT_IPV6) ? "]" : "",
  3050. local_port,
  3051. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
  3052. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
  3053. return 0;
  3054. }
  3055. int ast_sip_set_tpselector_from_transport(const struct ast_sip_transport *transport, pjsip_tpselector *selector)
  3056. {
  3057. RAII_VAR(struct ast_sip_transport_state *, transport_state, NULL, ao2_cleanup);
  3058. transport_state = ast_sip_get_transport_state(ast_sorcery_object_get_id(transport));
  3059. if (!transport_state) {
  3060. ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport state for '%s'\n",
  3061. ast_sorcery_object_get_id(transport));
  3062. return -1;
  3063. }
  3064. if (transport_state->transport) {
  3065. selector->type = PJSIP_TPSELECTOR_TRANSPORT;
  3066. selector->u.transport = transport_state->transport;
  3067. } else if (transport_state->factory) {
  3068. selector->type = PJSIP_TPSELECTOR_LISTENER;
  3069. selector->u.listener = transport_state->factory;
  3070. } else if (transport->type == AST_TRANSPORT_WS || transport->type == AST_TRANSPORT_WSS) {
  3071. /* The WebSocket transport has no factory as it can not create outgoing connections, so
  3072. * even if an endpoint is locked to a WebSocket transport we let the PJSIP logic
  3073. * find the existing connection if available and use it.
  3074. */
  3075. return 0;
  3076. } else {
  3077. return -1;
  3078. }
  3079. return 0;
  3080. }
  3081. int ast_sip_set_tpselector_from_transport_name(const char *transport_name, pjsip_tpselector *selector)
  3082. {
  3083. RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
  3084. if (ast_strlen_zero(transport_name)) {
  3085. return 0;
  3086. }
  3087. transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_name);
  3088. if (!transport) {
  3089. ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport '%s'\n",
  3090. transport_name);
  3091. return -1;
  3092. }
  3093. return ast_sip_set_tpselector_from_transport(transport, selector);
  3094. }
  3095. int ast_sip_set_tpselector_from_ep_or_uri(const struct ast_sip_endpoint *endpoint,
  3096. pjsip_sip_uri *sip_uri, pjsip_tpselector *selector)
  3097. {
  3098. char transport_name[128];
  3099. if (ast_sip_get_transport_name(endpoint, sip_uri, transport_name, sizeof(transport_name))) {
  3100. return 0;
  3101. }
  3102. return ast_sip_set_tpselector_from_transport_name(transport_name, selector);
  3103. }
  3104. void ast_sip_add_usereqphone(const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri)
  3105. {
  3106. pjsip_sip_uri *sip_uri;
  3107. int i = 0;
  3108. static const pj_str_t STR_PHONE = { "phone", 5 };
  3109. if (!endpoint || !endpoint->usereqphone || (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
  3110. return;
  3111. }
  3112. sip_uri = pjsip_uri_get_uri(uri);
  3113. if (!pj_strlen(&sip_uri->user)) {
  3114. return;
  3115. }
  3116. if (pj_strbuf(&sip_uri->user)[0] == '+') {
  3117. i = 1;
  3118. }
  3119. /* Test URI user against allowed characters in AST_DIGIT_ANY */
  3120. for (; i < pj_strlen(&sip_uri->user); i++) {
  3121. if (!strchr(AST_DIGIT_ANYNUM, pj_strbuf(&sip_uri->user)[i])) {
  3122. break;
  3123. }
  3124. }
  3125. if (i < pj_strlen(&sip_uri->user)) {
  3126. return;
  3127. }
  3128. sip_uri->user_param = STR_PHONE;
  3129. }
  3130. pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint,
  3131. const char *uri, const char *request_user)
  3132. {
  3133. char enclosed_uri[PJSIP_MAX_URL_SIZE];
  3134. pj_str_t local_uri = { "sip:temp@temp", 13 }, remote_uri, target_uri;
  3135. pj_status_t res;
  3136. pjsip_dialog *dlg = NULL;
  3137. const char *outbound_proxy = endpoint->outbound_proxy;
  3138. pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
  3139. static const pj_str_t HCONTACT = { "Contact", 7 };
  3140. snprintf(enclosed_uri, sizeof(enclosed_uri), "<%s>", uri);
  3141. pj_cstr(&remote_uri, enclosed_uri);
  3142. pj_cstr(&target_uri, uri);
  3143. res = pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, &target_uri, &dlg);
  3144. if (res != PJ_SUCCESS) {
  3145. if (res == PJSIP_EINVALIDURI) {
  3146. ast_log(LOG_ERROR,
  3147. "Endpoint '%s': Could not create dialog to invalid URI '%s'. Is endpoint registered and reachable?\n",
  3148. ast_sorcery_object_get_id(endpoint), uri);
  3149. }
  3150. return NULL;
  3151. }
  3152. /* We have to temporarily bump up the sess_count here so the dialog is not prematurely destroyed */
  3153. dlg->sess_count++;
  3154. ast_sip_dlg_set_transport(endpoint, dlg, &selector);
  3155. if (sip_dialog_create_from(dlg->pool, &local_uri, endpoint->fromuser, endpoint->fromdomain, &remote_uri, &selector)) {
  3156. dlg->sess_count--;
  3157. pjsip_dlg_terminate(dlg);
  3158. return NULL;
  3159. }
  3160. /* Update the dialog with the new local URI, we do it afterwards so we can use the dialog pool for construction */
  3161. pj_strdup_with_null(dlg->pool, &dlg->local.info_str, &local_uri);
  3162. dlg->local.info->uri = pjsip_parse_uri(dlg->pool, dlg->local.info_str.ptr, dlg->local.info_str.slen, 0);
  3163. if (!dlg->local.info->uri) {
  3164. ast_log(LOG_ERROR,
  3165. "Could not parse URI '%s' for endpoint '%s'\n",
  3166. dlg->local.info_str.ptr, ast_sorcery_object_get_id(endpoint));
  3167. dlg->sess_count--;
  3168. pjsip_dlg_terminate(dlg);
  3169. return NULL;
  3170. }
  3171. dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen, NULL);
  3172. if (!ast_strlen_zero(endpoint->contact_user)) {
  3173. pjsip_sip_uri *sip_uri;
  3174. sip_uri = pjsip_uri_get_uri(dlg->local.contact->uri);
  3175. pj_strdup2(dlg->pool, &sip_uri->user, endpoint->contact_user);
  3176. }
  3177. /* If a request user has been specified and we are permitted to change it, do so */
  3178. if (!ast_strlen_zero(request_user)) {
  3179. pjsip_sip_uri *sip_uri;
  3180. if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target)) {
  3181. sip_uri = pjsip_uri_get_uri(dlg->target);
  3182. pj_strdup2(dlg->pool, &sip_uri->user, request_user);
  3183. }
  3184. if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) || PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri)) {
  3185. sip_uri = pjsip_uri_get_uri(dlg->remote.info->uri);
  3186. pj_strdup2(dlg->pool, &sip_uri->user, request_user);
  3187. }
  3188. }
  3189. /* Add the user=phone parameter if applicable */
  3190. ast_sip_add_usereqphone(endpoint, dlg->pool, dlg->target);
  3191. ast_sip_add_usereqphone(endpoint, dlg->pool, dlg->remote.info->uri);
  3192. if (!ast_strlen_zero(outbound_proxy)) {
  3193. pjsip_route_hdr route_set, *route;
  3194. static const pj_str_t ROUTE_HNAME = { "Route", 5 };
  3195. pj_str_t tmp;
  3196. pj_list_init(&route_set);
  3197. pj_strdup2_with_null(dlg->pool, &tmp, outbound_proxy);
  3198. if (!(route = pjsip_parse_hdr(dlg->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
  3199. ast_log(LOG_ERROR, "Could not create dialog to endpoint '%s' as outbound proxy URI '%s' is not valid\n",
  3200. ast_sorcery_object_get_id(endpoint), outbound_proxy);
  3201. dlg->sess_count--;
  3202. pjsip_dlg_terminate(dlg);
  3203. return NULL;
  3204. }
  3205. pj_list_insert_nodes_before(&route_set, route);
  3206. pjsip_dlg_set_route_set(dlg, &route_set);
  3207. }
  3208. dlg->sess_count--;
  3209. return dlg;
  3210. }
  3211. /*!
  3212. * \brief Determine if a SIPS Contact header is required.
  3213. *
  3214. * This uses the guideline provided in RFC 3261 Section 12.1.1 to
  3215. * determine if the Contact header must be a sips: URI.
  3216. *
  3217. * \param rdata The incoming dialog-starting request
  3218. * \retval 0 SIPS not required
  3219. * \retval 1 SIPS required
  3220. */
  3221. static int uas_use_sips_contact(pjsip_rx_data *rdata)
  3222. {
  3223. pjsip_rr_hdr *record_route;
  3224. if (PJSIP_URI_SCHEME_IS_SIPS(rdata->msg_info.msg->line.req.uri)) {
  3225. return 1;
  3226. }
  3227. record_route = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_RECORD_ROUTE, NULL);
  3228. if (record_route) {
  3229. if (PJSIP_URI_SCHEME_IS_SIPS(&record_route->name_addr)) {
  3230. return 1;
  3231. }
  3232. } else {
  3233. pjsip_contact_hdr *contact;
  3234. contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
  3235. ast_assert(contact != NULL);
  3236. if (PJSIP_URI_SCHEME_IS_SIPS(contact->uri)) {
  3237. return 1;
  3238. }
  3239. }
  3240. return 0;
  3241. }
  3242. pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status)
  3243. {
  3244. pjsip_dialog *dlg;
  3245. pj_str_t contact;
  3246. pjsip_transport_type_e type = rdata->tp_info.transport->key.type;
  3247. pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
  3248. pjsip_transport *transport;
  3249. pjsip_contact_hdr *contact_hdr;
  3250. ast_assert(status != NULL);
  3251. contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
  3252. if (!contact_hdr || ast_sip_set_tpselector_from_ep_or_uri(endpoint, pjsip_uri_get_uri(contact_hdr->uri),
  3253. &selector)) {
  3254. return NULL;
  3255. }
  3256. transport = rdata->tp_info.transport;
  3257. if (selector.type == PJSIP_TPSELECTOR_TRANSPORT) {
  3258. transport = selector.u.transport;
  3259. }
  3260. type = transport->key.type;
  3261. contact.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE);
  3262. contact.slen = pj_ansi_snprintf(contact.ptr, PJSIP_MAX_URL_SIZE,
  3263. "<%s:%s%.*s%s:%d%s%s>",
  3264. uas_use_sips_contact(rdata) ? "sips" : "sip",
  3265. (type & PJSIP_TRANSPORT_IPV6) ? "[" : "",
  3266. (int)transport->local_name.host.slen,
  3267. transport->local_name.host.ptr,
  3268. (type & PJSIP_TRANSPORT_IPV6) ? "]" : "",
  3269. transport->local_name.port,
  3270. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
  3271. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
  3272. #ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
  3273. *status = pjsip_dlg_create_uas_and_inc_lock(pjsip_ua_instance(), rdata, &contact, &dlg);
  3274. #else
  3275. *status = pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, &contact, &dlg);
  3276. #endif
  3277. if (*status != PJ_SUCCESS) {
  3278. char err[PJ_ERR_MSG_SIZE];
  3279. pj_strerror(*status, err, sizeof(err));
  3280. ast_log(LOG_ERROR, "Could not create dialog with endpoint %s. %s\n",
  3281. ast_sorcery_object_get_id(endpoint), err);
  3282. return NULL;
  3283. }
  3284. dlg->sess_count++;
  3285. pjsip_dlg_set_transport(dlg, &selector);
  3286. dlg->sess_count--;
  3287. #ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
  3288. pjsip_dlg_dec_lock(dlg);
  3289. #endif
  3290. return dlg;
  3291. }
  3292. int ast_sip_create_rdata_with_contact(pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port,
  3293. char *transport_type, const char *local_name, int local_port, const char *contact)
  3294. {
  3295. pj_str_t tmp;
  3296. /*
  3297. * Initialize the error list in case there is a parse error
  3298. * in the given packet.
  3299. */
  3300. pj_list_init(&rdata->msg_info.parse_err);
  3301. rdata->tp_info.transport = PJ_POOL_ZALLOC_T(rdata->tp_info.pool, pjsip_transport);
  3302. if (!rdata->tp_info.transport) {
  3303. return -1;
  3304. }
  3305. ast_copy_string(rdata->pkt_info.packet, packet, sizeof(rdata->pkt_info.packet));
  3306. ast_copy_string(rdata->pkt_info.src_name, src_name, sizeof(rdata->pkt_info.src_name));
  3307. rdata->pkt_info.src_port = src_port;
  3308. pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&tmp, src_name), &rdata->pkt_info.src_addr);
  3309. pj_sockaddr_set_port(&rdata->pkt_info.src_addr, src_port);
  3310. pjsip_parse_rdata(packet, strlen(packet), rdata);
  3311. if (!rdata->msg_info.msg || !pj_list_empty(&rdata->msg_info.parse_err)) {
  3312. return -1;
  3313. }
  3314. if (!ast_strlen_zero(contact)) {
  3315. pjsip_contact_hdr *contact_hdr;
  3316. contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
  3317. if (contact_hdr) {
  3318. contact_hdr->uri = pjsip_parse_uri(rdata->tp_info.pool, (char *)contact,
  3319. strlen(contact), PJSIP_PARSE_URI_AS_NAMEADDR);
  3320. }
  3321. }
  3322. pj_strdup2(rdata->tp_info.pool, &rdata->msg_info.via->recvd_param, rdata->pkt_info.src_name);
  3323. rdata->msg_info.via->rport_param = -1;
  3324. rdata->tp_info.transport->key.type = pjsip_transport_get_type_from_name(pj_cstr(&tmp, transport_type));
  3325. rdata->tp_info.transport->type_name = transport_type;
  3326. pj_strdup2(rdata->tp_info.pool, &rdata->tp_info.transport->local_name.host, local_name);
  3327. rdata->tp_info.transport->local_name.port = local_port;
  3328. return 0;
  3329. }
  3330. int ast_sip_create_rdata(pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port,
  3331. char *transport_type, const char *local_name, int local_port)
  3332. {
  3333. return ast_sip_create_rdata_with_contact(rdata, packet, src_name, src_port, transport_type,
  3334. local_name, local_port, NULL);
  3335. }
  3336. /* PJSIP doesn't know about the INFO method, so we have to define it ourselves */
  3337. static const pjsip_method info_method = {PJSIP_OTHER_METHOD, {"INFO", 4} };
  3338. static const pjsip_method message_method = {PJSIP_OTHER_METHOD, {"MESSAGE", 7} };
  3339. static struct {
  3340. const char *method;
  3341. const pjsip_method *pmethod;
  3342. } methods [] = {
  3343. { "INVITE", &pjsip_invite_method },
  3344. { "CANCEL", &pjsip_cancel_method },
  3345. { "ACK", &pjsip_ack_method },
  3346. { "BYE", &pjsip_bye_method },
  3347. { "REGISTER", &pjsip_register_method },
  3348. { "OPTIONS", &pjsip_options_method },
  3349. { "SUBSCRIBE", &pjsip_subscribe_method },
  3350. { "NOTIFY", &pjsip_notify_method },
  3351. { "PUBLISH", &pjsip_publish_method },
  3352. { "INFO", &info_method },
  3353. { "MESSAGE", &message_method },
  3354. };
  3355. static const pjsip_method *get_pjsip_method(const char *method)
  3356. {
  3357. int i;
  3358. for (i = 0; i < ARRAY_LEN(methods); ++i) {
  3359. if (!strcmp(method, methods[i].method)) {
  3360. return methods[i].pmethod;
  3361. }
  3362. }
  3363. return NULL;
  3364. }
  3365. static int create_in_dialog_request(const pjsip_method *method, struct pjsip_dialog *dlg, pjsip_tx_data **tdata)
  3366. {
  3367. if (pjsip_dlg_create_request(dlg, method, -1, tdata) != PJ_SUCCESS) {
  3368. ast_log(LOG_WARNING, "Unable to create in-dialog request.\n");
  3369. return -1;
  3370. }
  3371. return 0;
  3372. }
  3373. static pj_bool_t supplement_on_rx_request(pjsip_rx_data *rdata);
  3374. static pjsip_module supplement_module = {
  3375. .name = { "Out of dialog supplement hook", 29 },
  3376. .id = -1,
  3377. .priority = PJSIP_MOD_PRIORITY_APPLICATION - 1,
  3378. .on_rx_request = supplement_on_rx_request,
  3379. };
  3380. static int create_out_of_dialog_request(const pjsip_method *method, struct ast_sip_endpoint *endpoint,
  3381. const char *uri, struct ast_sip_contact *provided_contact, pjsip_tx_data **tdata)
  3382. {
  3383. RAII_VAR(struct ast_sip_contact *, contact, ao2_bump(provided_contact), ao2_cleanup);
  3384. pj_str_t remote_uri;
  3385. pj_str_t from;
  3386. pj_pool_t *pool;
  3387. pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
  3388. pjsip_uri *sip_uri;
  3389. const char *fromuser;
  3390. if (ast_strlen_zero(uri)) {
  3391. if (!endpoint && (!contact || ast_strlen_zero(contact->uri))) {
  3392. ast_log(LOG_ERROR, "An endpoint and/or uri must be specified\n");
  3393. return -1;
  3394. }
  3395. if (!contact) {
  3396. contact = ast_sip_location_retrieve_contact_from_aor_list(endpoint->aors);
  3397. }
  3398. if (!contact || ast_strlen_zero(contact->uri)) {
  3399. ast_log(LOG_WARNING, "Unable to retrieve contact for endpoint %s\n",
  3400. ast_sorcery_object_get_id(endpoint));
  3401. return -1;
  3402. }
  3403. pj_cstr(&remote_uri, contact->uri);
  3404. } else {
  3405. pj_cstr(&remote_uri, uri);
  3406. }
  3407. pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "Outbound request", 256, 256);
  3408. if (!pool) {
  3409. ast_log(LOG_ERROR, "Unable to create PJLIB memory pool\n");
  3410. return -1;
  3411. }
  3412. sip_uri = pjsip_parse_uri(pool, remote_uri.ptr, remote_uri.slen, 0);
  3413. if (!sip_uri || (!PJSIP_URI_SCHEME_IS_SIP(sip_uri) && !PJSIP_URI_SCHEME_IS_SIPS(sip_uri))) {
  3414. ast_log(LOG_ERROR, "Unable to create outbound %.*s request to endpoint %s as URI '%s' is not valid\n",
  3415. (int) pj_strlen(&method->name), pj_strbuf(&method->name),
  3416. endpoint ? ast_sorcery_object_get_id(endpoint) : "<none>",
  3417. pj_strbuf(&remote_uri));
  3418. pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
  3419. return -1;
  3420. }
  3421. ast_sip_set_tpselector_from_ep_or_uri(endpoint, pjsip_uri_get_uri(sip_uri), &selector);
  3422. fromuser = endpoint ? (!ast_strlen_zero(endpoint->fromuser) ? endpoint->fromuser : ast_sorcery_object_get_id(endpoint)) : NULL;
  3423. if (sip_dialog_create_from(pool, &from, fromuser,
  3424. endpoint ? endpoint->fromdomain : NULL, &remote_uri, &selector)) {
  3425. ast_log(LOG_ERROR, "Unable to create From header for %.*s request to endpoint %s\n",
  3426. (int) pj_strlen(&method->name), pj_strbuf(&method->name),
  3427. endpoint ? ast_sorcery_object_get_id(endpoint) : "<none>");
  3428. pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
  3429. return -1;
  3430. }
  3431. if (pjsip_endpt_create_request(ast_sip_get_pjsip_endpoint(), method, &remote_uri,
  3432. &from, &remote_uri, &from, NULL, -1, NULL, tdata) != PJ_SUCCESS) {
  3433. ast_log(LOG_ERROR, "Unable to create outbound %.*s request to endpoint %s\n",
  3434. (int) pj_strlen(&method->name), pj_strbuf(&method->name),
  3435. endpoint ? ast_sorcery_object_get_id(endpoint) : "<none>");
  3436. pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
  3437. return -1;
  3438. }
  3439. pjsip_tx_data_set_transport(*tdata, &selector);
  3440. if (endpoint && !ast_strlen_zero(endpoint->contact_user)){
  3441. pjsip_contact_hdr *contact_hdr;
  3442. pjsip_sip_uri *contact_uri;
  3443. static const pj_str_t HCONTACT = { "Contact", 7 };
  3444. static const pj_str_t HCONTACTSHORT = { "m", 1 };
  3445. contact_hdr = pjsip_msg_find_hdr_by_names((*tdata)->msg, &HCONTACT, &HCONTACTSHORT, NULL);
  3446. if (contact_hdr) {
  3447. contact_uri = pjsip_uri_get_uri(contact_hdr->uri);
  3448. pj_strdup2(pool, &contact_uri->user, endpoint->contact_user);
  3449. }
  3450. }
  3451. /* Add the user=phone parameter if applicable */
  3452. ast_sip_add_usereqphone(endpoint, (*tdata)->pool, (*tdata)->msg->line.req.uri);
  3453. /* If an outbound proxy is specified on the endpoint apply it to this request */
  3454. if (endpoint && !ast_strlen_zero(endpoint->outbound_proxy) &&
  3455. ast_sip_set_outbound_proxy((*tdata), endpoint->outbound_proxy)) {
  3456. ast_log(LOG_ERROR, "Unable to apply outbound proxy on request %.*s to endpoint %s as outbound proxy URI '%s' is not valid\n",
  3457. (int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint),
  3458. endpoint->outbound_proxy);
  3459. pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
  3460. return -1;
  3461. }
  3462. ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
  3463. /* We can release this pool since request creation copied all the necessary
  3464. * data into the outbound request's pool
  3465. */
  3466. pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
  3467. return 0;
  3468. }
  3469. int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg,
  3470. struct ast_sip_endpoint *endpoint, const char *uri,
  3471. struct ast_sip_contact *contact, pjsip_tx_data **tdata)
  3472. {
  3473. const pjsip_method *pmethod = get_pjsip_method(method);
  3474. if (!pmethod) {
  3475. ast_log(LOG_WARNING, "Unknown method '%s'. Cannot send request\n", method);
  3476. return -1;
  3477. }
  3478. if (dlg) {
  3479. return create_in_dialog_request(pmethod, dlg, tdata);
  3480. } else {
  3481. ast_assert(endpoint != NULL);
  3482. return create_out_of_dialog_request(pmethod, endpoint, uri, contact, tdata);
  3483. }
  3484. }
  3485. AST_RWLIST_HEAD_STATIC(supplements, ast_sip_supplement);
  3486. void internal_sip_register_supplement(struct ast_sip_supplement *supplement)
  3487. {
  3488. struct ast_sip_supplement *iter;
  3489. int inserted = 0;
  3490. SCOPED_LOCK(lock, &supplements, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  3491. AST_RWLIST_TRAVERSE_SAFE_BEGIN(&supplements, iter, next) {
  3492. if (iter->priority > supplement->priority) {
  3493. AST_RWLIST_INSERT_BEFORE_CURRENT(supplement, next);
  3494. inserted = 1;
  3495. break;
  3496. }
  3497. }
  3498. AST_RWLIST_TRAVERSE_SAFE_END;
  3499. if (!inserted) {
  3500. AST_RWLIST_INSERT_TAIL(&supplements, supplement, next);
  3501. }
  3502. }
  3503. int ast_sip_register_supplement(struct ast_sip_supplement *supplement)
  3504. {
  3505. internal_sip_register_supplement(supplement);
  3506. ast_module_ref(ast_module_info->self);
  3507. return 0;
  3508. }
  3509. int internal_sip_unregister_supplement(struct ast_sip_supplement *supplement)
  3510. {
  3511. struct ast_sip_supplement *iter;
  3512. SCOPED_LOCK(lock, &supplements, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  3513. int res = -1;
  3514. AST_RWLIST_TRAVERSE_SAFE_BEGIN(&supplements, iter, next) {
  3515. if (supplement == iter) {
  3516. AST_RWLIST_REMOVE_CURRENT(next);
  3517. res = 0;
  3518. break;
  3519. }
  3520. }
  3521. AST_RWLIST_TRAVERSE_SAFE_END;
  3522. return res;
  3523. }
  3524. void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)
  3525. {
  3526. if (!internal_sip_unregister_supplement(supplement)) {
  3527. ast_module_unref(ast_module_info->self);
  3528. }
  3529. }
  3530. static int send_in_dialog_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg)
  3531. {
  3532. if (pjsip_dlg_send_request(dlg, tdata, -1, NULL) != PJ_SUCCESS) {
  3533. ast_log(LOG_WARNING, "Unable to send in-dialog request.\n");
  3534. return -1;
  3535. }
  3536. return 0;
  3537. }
  3538. static pj_bool_t does_method_match(const pj_str_t *message_method, const char *supplement_method)
  3539. {
  3540. pj_str_t method;
  3541. if (ast_strlen_zero(supplement_method)) {
  3542. return PJ_TRUE;
  3543. }
  3544. pj_cstr(&method, supplement_method);
  3545. return pj_stristr(&method, message_method) ? PJ_TRUE : PJ_FALSE;
  3546. }
  3547. /*! Maximum number of challenges before assuming that we are in a loop */
  3548. #define MAX_RX_CHALLENGES 10
  3549. #define TIMER_INACTIVE 0
  3550. #define TIMEOUT_TIMER2 5
  3551. /*! \brief Structure to hold information about an outbound request */
  3552. struct send_request_data {
  3553. /*! The endpoint associated with this request */
  3554. struct ast_sip_endpoint *endpoint;
  3555. /*! Information to be provided to the callback upon receipt of a response */
  3556. void *token;
  3557. /*! The callback to be called upon receipt of a response */
  3558. void (*callback)(void *token, pjsip_event *e);
  3559. /*! Number of challenges received. */
  3560. unsigned int challenge_count;
  3561. };
  3562. static void send_request_data_destroy(void *obj)
  3563. {
  3564. struct send_request_data *req_data = obj;
  3565. ao2_cleanup(req_data->endpoint);
  3566. }
  3567. static struct send_request_data *send_request_data_alloc(struct ast_sip_endpoint *endpoint,
  3568. void *token, void (*callback)(void *token, pjsip_event *e))
  3569. {
  3570. struct send_request_data *req_data;
  3571. req_data = ao2_alloc_options(sizeof(*req_data), send_request_data_destroy,
  3572. AO2_ALLOC_OPT_LOCK_NOLOCK);
  3573. if (!req_data) {
  3574. return NULL;
  3575. }
  3576. req_data->endpoint = ao2_bump(endpoint);
  3577. req_data->token = token;
  3578. req_data->callback = callback;
  3579. return req_data;
  3580. }
  3581. struct send_request_wrapper {
  3582. /*! Information to be provided to the callback upon receipt of a response */
  3583. void *token;
  3584. /*! The callback to be called upon receipt of a response */
  3585. void (*callback)(void *token, pjsip_event *e);
  3586. /*! Non-zero when the callback is called. */
  3587. unsigned int cb_called;
  3588. /*! Non-zero if endpt_send_request_cb() was called. */
  3589. unsigned int send_cb_called;
  3590. /*! Timeout timer. */
  3591. pj_timer_entry *timeout_timer;
  3592. /*! Original timeout. */
  3593. pj_int32_t timeout;
  3594. /*! The transmit data. */
  3595. pjsip_tx_data *tdata;
  3596. };
  3597. /*! \internal This function gets called by pjsip when the transaction ends,
  3598. * even if it timed out. The lock prevents a race condition if both the pjsip
  3599. * transaction timer and our own timer expire simultaneously.
  3600. */
  3601. static void endpt_send_request_cb(void *token, pjsip_event *e)
  3602. {
  3603. struct send_request_wrapper *req_wrapper = token;
  3604. unsigned int cb_called;
  3605. /*
  3606. * Needed because we cannot otherwise tell if this callback was
  3607. * called when pjsip_endpt_send_request() returns error.
  3608. */
  3609. req_wrapper->send_cb_called = 1;
  3610. if (e->body.tsx_state.type == PJSIP_EVENT_TIMER) {
  3611. ast_debug(2, "%p: PJSIP tsx timer expired\n", req_wrapper);
  3612. if (req_wrapper->timeout_timer
  3613. && req_wrapper->timeout_timer->id != TIMEOUT_TIMER2) {
  3614. ast_debug(3, "%p: Timeout already handled\n", req_wrapper);
  3615. ao2_ref(req_wrapper, -1);
  3616. return;
  3617. }
  3618. } else {
  3619. ast_debug(2, "%p: PJSIP tsx response received\n", req_wrapper);
  3620. }
  3621. ao2_lock(req_wrapper);
  3622. /* It's possible that our own timer was already processing while
  3623. * we were waiting on the lock so check the timer id. If it's
  3624. * still TIMER2 then we still need to process.
  3625. */
  3626. if (req_wrapper->timeout_timer
  3627. && req_wrapper->timeout_timer->id == TIMEOUT_TIMER2) {
  3628. int timers_cancelled = 0;
  3629. ast_debug(3, "%p: Cancelling timer\n", req_wrapper);
  3630. timers_cancelled = pj_timer_heap_cancel_if_active(
  3631. pjsip_endpt_get_timer_heap(ast_sip_get_pjsip_endpoint()),
  3632. req_wrapper->timeout_timer, TIMER_INACTIVE);
  3633. if (timers_cancelled > 0) {
  3634. /* If the timer was cancelled the callback will never run so
  3635. * clean up its reference to the wrapper.
  3636. */
  3637. ast_debug(3, "%p: Timer cancelled\n", req_wrapper);
  3638. ao2_ref(req_wrapper, -1);
  3639. } else {
  3640. /*
  3641. * If it wasn't cancelled, it MAY be in the callback already
  3642. * waiting on the lock. When we release the lock, it will
  3643. * now know not to proceed.
  3644. */
  3645. ast_debug(3, "%p: Timer already expired\n", req_wrapper);
  3646. }
  3647. }
  3648. cb_called = req_wrapper->cb_called;
  3649. req_wrapper->cb_called = 1;
  3650. ao2_unlock(req_wrapper);
  3651. /* It's possible that our own timer expired and called the callbacks
  3652. * so no need to call them again.
  3653. */
  3654. if (!cb_called && req_wrapper->callback) {
  3655. req_wrapper->callback(req_wrapper->token, e);
  3656. ast_debug(2, "%p: Callbacks executed\n", req_wrapper);
  3657. }
  3658. ao2_ref(req_wrapper, -1);
  3659. }
  3660. /*! \internal This function gets called by our own timer when it expires.
  3661. * If the timer is cancelled however, the function does NOT get called.
  3662. * The lock prevents a race condition if both the pjsip transaction timer
  3663. * and our own timer expire simultaneously.
  3664. */
  3665. static void send_request_timer_callback(pj_timer_heap_t *theap, pj_timer_entry *entry)
  3666. {
  3667. struct send_request_wrapper *req_wrapper = entry->user_data;
  3668. unsigned int cb_called;
  3669. ast_debug(2, "%p: Internal tsx timer expired after %d msec\n",
  3670. req_wrapper, req_wrapper->timeout);
  3671. ao2_lock(req_wrapper);
  3672. /*
  3673. * If the id is not TIMEOUT_TIMER2 then the timer was cancelled
  3674. * before we got the lock or it was already handled so just clean up.
  3675. */
  3676. if (entry->id != TIMEOUT_TIMER2) {
  3677. ao2_unlock(req_wrapper);
  3678. ast_debug(3, "%p: Timeout already handled\n", req_wrapper);
  3679. ao2_ref(req_wrapper, -1);
  3680. return;
  3681. }
  3682. entry->id = TIMER_INACTIVE;
  3683. ast_debug(3, "%p: Timer handled here\n", req_wrapper);
  3684. cb_called = req_wrapper->cb_called;
  3685. req_wrapper->cb_called = 1;
  3686. ao2_unlock(req_wrapper);
  3687. if (!cb_called && req_wrapper->callback) {
  3688. pjsip_event event;
  3689. PJSIP_EVENT_INIT_TX_MSG(event, req_wrapper->tdata);
  3690. event.body.tsx_state.type = PJSIP_EVENT_TIMER;
  3691. req_wrapper->callback(req_wrapper->token, &event);
  3692. ast_debug(2, "%p: Callbacks executed\n", req_wrapper);
  3693. }
  3694. ao2_ref(req_wrapper, -1);
  3695. }
  3696. static void send_request_wrapper_destructor(void *obj)
  3697. {
  3698. struct send_request_wrapper *req_wrapper = obj;
  3699. pjsip_tx_data_dec_ref(req_wrapper->tdata);
  3700. ast_debug(2, "%p: wrapper destroyed\n", req_wrapper);
  3701. }
  3702. static pj_status_t endpt_send_request(struct ast_sip_endpoint *endpoint,
  3703. pjsip_tx_data *tdata, pj_int32_t timeout, void *token, pjsip_endpt_send_callback cb)
  3704. {
  3705. struct send_request_wrapper *req_wrapper;
  3706. pj_status_t ret_val;
  3707. pjsip_endpoint *endpt = ast_sip_get_pjsip_endpoint();
  3708. if (!cb && token) {
  3709. /* Silly. Without a callback we cannot do anything with token. */
  3710. pjsip_tx_data_dec_ref(tdata);
  3711. return PJ_EINVAL;
  3712. }
  3713. /* Create wrapper to detect if the callback was actually called on an error. */
  3714. req_wrapper = ao2_alloc(sizeof(*req_wrapper), send_request_wrapper_destructor);
  3715. if (!req_wrapper) {
  3716. pjsip_tx_data_dec_ref(tdata);
  3717. return PJ_ENOMEM;
  3718. }
  3719. ast_debug(2, "%p: Wrapper created\n", req_wrapper);
  3720. req_wrapper->token = token;
  3721. req_wrapper->callback = cb;
  3722. req_wrapper->timeout = timeout;
  3723. req_wrapper->timeout_timer = NULL;
  3724. req_wrapper->tdata = tdata;
  3725. /* Add a reference to tdata. The wrapper destructor cleans it up. */
  3726. pjsip_tx_data_add_ref(tdata);
  3727. if (timeout > 0) {
  3728. pj_time_val timeout_timer_val = { timeout / 1000, timeout % 1000 };
  3729. req_wrapper->timeout_timer = PJ_POOL_ALLOC_T(tdata->pool, pj_timer_entry);
  3730. ast_debug(2, "%p: Set timer to %d msec\n", req_wrapper, timeout);
  3731. pj_timer_entry_init(req_wrapper->timeout_timer, TIMEOUT_TIMER2,
  3732. req_wrapper, send_request_timer_callback);
  3733. /* We need to insure that the wrapper and tdata are available if/when the
  3734. * timer callback is executed.
  3735. */
  3736. ao2_ref(req_wrapper, +1);
  3737. ret_val = pj_timer_heap_schedule(pjsip_endpt_get_timer_heap(endpt),
  3738. req_wrapper->timeout_timer, &timeout_timer_val);
  3739. if (ret_val != PJ_SUCCESS) {
  3740. ast_log(LOG_ERROR,
  3741. "Failed to set timer. Not sending %.*s request to endpoint %s.\n",
  3742. (int) pj_strlen(&tdata->msg->line.req.method.name),
  3743. pj_strbuf(&tdata->msg->line.req.method.name),
  3744. endpoint ? ast_sorcery_object_get_id(endpoint) : "<unknown>");
  3745. ao2_t_ref(req_wrapper, -2, "Drop timer and routine ref");
  3746. pjsip_tx_data_dec_ref(tdata);
  3747. return ret_val;
  3748. }
  3749. }
  3750. ast_sip_record_request_serializer(tdata);
  3751. /* We need to insure that the wrapper and tdata are available when the
  3752. * transaction callback is executed.
  3753. */
  3754. ao2_ref(req_wrapper, +1);
  3755. ret_val = pjsip_endpt_send_request(endpt, tdata, -1, req_wrapper, endpt_send_request_cb);
  3756. if (ret_val != PJ_SUCCESS) {
  3757. char errmsg[PJ_ERR_MSG_SIZE];
  3758. if (!req_wrapper->send_cb_called) {
  3759. /* endpt_send_request_cb is not expected to ever be called now. */
  3760. ao2_ref(req_wrapper, -1);
  3761. }
  3762. /* Complain of failure to send the request. */
  3763. pj_strerror(ret_val, errmsg, sizeof(errmsg));
  3764. ast_log(LOG_ERROR, "Error %d '%s' sending %.*s request to endpoint %s\n",
  3765. (int) ret_val, errmsg, (int) pj_strlen(&tdata->msg->line.req.method.name),
  3766. pj_strbuf(&tdata->msg->line.req.method.name),
  3767. endpoint ? ast_sorcery_object_get_id(endpoint) : "<unknown>");
  3768. if (timeout > 0) {
  3769. int timers_cancelled;
  3770. ao2_lock(req_wrapper);
  3771. timers_cancelled = pj_timer_heap_cancel_if_active(
  3772. pjsip_endpt_get_timer_heap(endpt),
  3773. req_wrapper->timeout_timer, TIMER_INACTIVE);
  3774. if (timers_cancelled > 0) {
  3775. ao2_ref(req_wrapper, -1);
  3776. }
  3777. /* Was the callback called? */
  3778. if (req_wrapper->cb_called) {
  3779. /*
  3780. * Yes so we cannot report any error. The callback
  3781. * has already freed any resources associated with
  3782. * token.
  3783. */
  3784. ret_val = PJ_SUCCESS;
  3785. } else {
  3786. /*
  3787. * No so we claim it is called so our caller can free
  3788. * any resources associated with token because of
  3789. * failure.
  3790. */
  3791. req_wrapper->cb_called = 1;
  3792. }
  3793. ao2_unlock(req_wrapper);
  3794. } else if (req_wrapper->cb_called) {
  3795. /*
  3796. * We cannot report any error. The callback has
  3797. * already freed any resources associated with
  3798. * token.
  3799. */
  3800. ret_val = PJ_SUCCESS;
  3801. }
  3802. }
  3803. ao2_ref(req_wrapper, -1);
  3804. return ret_val;
  3805. }
  3806. static void send_request_cb(void *token, pjsip_event *e)
  3807. {
  3808. struct send_request_data *req_data = token;
  3809. pjsip_transaction *tsx;
  3810. pjsip_rx_data *challenge;
  3811. pjsip_tx_data *tdata;
  3812. struct ast_sip_supplement *supplement;
  3813. struct ast_sip_endpoint *endpoint;
  3814. int res;
  3815. switch(e->body.tsx_state.type) {
  3816. case PJSIP_EVENT_TRANSPORT_ERROR:
  3817. case PJSIP_EVENT_TIMER:
  3818. break;
  3819. case PJSIP_EVENT_RX_MSG:
  3820. challenge = e->body.tsx_state.src.rdata;
  3821. /*
  3822. * Call any supplements that want to know about a response
  3823. * with any received data.
  3824. */
  3825. AST_RWLIST_RDLOCK(&supplements);
  3826. AST_LIST_TRAVERSE(&supplements, supplement, next) {
  3827. if (supplement->incoming_response
  3828. && does_method_match(&challenge->msg_info.cseq->method.name,
  3829. supplement->method)) {
  3830. supplement->incoming_response(req_data->endpoint, challenge);
  3831. }
  3832. }
  3833. AST_RWLIST_UNLOCK(&supplements);
  3834. /* Resend the request with a challenge response if we are challenged. */
  3835. tsx = e->body.tsx_state.tsx;
  3836. endpoint = ao2_bump(req_data->endpoint);
  3837. res = (tsx->status_code == 401 || tsx->status_code == 407)
  3838. && endpoint
  3839. && ++req_data->challenge_count < MAX_RX_CHALLENGES /* Not in a challenge loop */
  3840. && !ast_sip_create_request_with_auth(&endpoint->outbound_auths,
  3841. challenge, tsx, &tdata)
  3842. && endpt_send_request(endpoint, tdata, -1, req_data, send_request_cb)
  3843. == PJ_SUCCESS;
  3844. ao2_cleanup(endpoint);
  3845. if (res) {
  3846. /*
  3847. * Request with challenge response sent.
  3848. * Passed our req_data ref to the new request.
  3849. */
  3850. return;
  3851. }
  3852. break;
  3853. default:
  3854. ast_log(LOG_ERROR, "Unexpected PJSIP event %u\n", e->body.tsx_state.type);
  3855. break;
  3856. }
  3857. if (req_data->callback) {
  3858. req_data->callback(req_data->token, e);
  3859. }
  3860. ao2_ref(req_data, -1);
  3861. }
  3862. int ast_sip_send_out_of_dialog_request(pjsip_tx_data *tdata,
  3863. struct ast_sip_endpoint *endpoint, int timeout, void *token,
  3864. void (*callback)(void *token, pjsip_event *e))
  3865. {
  3866. struct ast_sip_supplement *supplement;
  3867. struct send_request_data *req_data;
  3868. struct ast_sip_contact *contact;
  3869. req_data = send_request_data_alloc(endpoint, token, callback);
  3870. if (!req_data) {
  3871. pjsip_tx_data_dec_ref(tdata);
  3872. return -1;
  3873. }
  3874. contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
  3875. AST_RWLIST_RDLOCK(&supplements);
  3876. AST_LIST_TRAVERSE(&supplements, supplement, next) {
  3877. if (supplement->outgoing_request
  3878. && does_method_match(&tdata->msg->line.req.method.name, supplement->method)) {
  3879. supplement->outgoing_request(endpoint, contact, tdata);
  3880. }
  3881. }
  3882. AST_RWLIST_UNLOCK(&supplements);
  3883. ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
  3884. ao2_cleanup(contact);
  3885. if (endpt_send_request(endpoint, tdata, timeout, req_data, send_request_cb)
  3886. != PJ_SUCCESS) {
  3887. ao2_cleanup(req_data);
  3888. return -1;
  3889. }
  3890. return 0;
  3891. }
  3892. int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg,
  3893. struct ast_sip_endpoint *endpoint, void *token,
  3894. void (*callback)(void *token, pjsip_event *e))
  3895. {
  3896. ast_assert(tdata->msg->type == PJSIP_REQUEST_MSG);
  3897. if (dlg) {
  3898. return send_in_dialog_request(tdata, dlg);
  3899. } else {
  3900. return ast_sip_send_out_of_dialog_request(tdata, endpoint, -1, token, callback);
  3901. }
  3902. }
  3903. int ast_sip_set_outbound_proxy(pjsip_tx_data *tdata, const char *proxy)
  3904. {
  3905. pjsip_route_hdr *route;
  3906. static const pj_str_t ROUTE_HNAME = { "Route", 5 };
  3907. pj_str_t tmp;
  3908. pj_strdup2_with_null(tdata->pool, &tmp, proxy);
  3909. if (!(route = pjsip_parse_hdr(tdata->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
  3910. return -1;
  3911. }
  3912. pj_list_insert_nodes_before(&tdata->msg->hdr, (pjsip_hdr*)route);
  3913. return 0;
  3914. }
  3915. int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
  3916. {
  3917. pj_str_t hdr_name;
  3918. pj_str_t hdr_value;
  3919. pjsip_generic_string_hdr *hdr;
  3920. pj_cstr(&hdr_name, name);
  3921. pj_cstr(&hdr_value, value);
  3922. hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
  3923. pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
  3924. return 0;
  3925. }
  3926. static pjsip_msg_body *ast_body_to_pjsip_body(pj_pool_t *pool, const struct ast_sip_body *body)
  3927. {
  3928. pj_str_t type;
  3929. pj_str_t subtype;
  3930. pj_str_t body_text;
  3931. pj_cstr(&type, body->type);
  3932. pj_cstr(&subtype, body->subtype);
  3933. pj_cstr(&body_text, body->body_text);
  3934. return pjsip_msg_body_create(pool, &type, &subtype, &body_text);
  3935. }
  3936. int ast_sip_add_body(pjsip_tx_data *tdata, const struct ast_sip_body *body)
  3937. {
  3938. pjsip_msg_body *pjsip_body = ast_body_to_pjsip_body(tdata->pool, body);
  3939. tdata->msg->body = pjsip_body;
  3940. return 0;
  3941. }
  3942. int ast_sip_add_body_multipart(pjsip_tx_data *tdata, const struct ast_sip_body *bodies[], int num_bodies)
  3943. {
  3944. int i;
  3945. /* NULL for type and subtype automatically creates "multipart/mixed" */
  3946. pjsip_msg_body *body = pjsip_multipart_create(tdata->pool, NULL, NULL);
  3947. for (i = 0; i < num_bodies; ++i) {
  3948. pjsip_multipart_part *part = pjsip_multipart_create_part(tdata->pool);
  3949. part->body = ast_body_to_pjsip_body(tdata->pool, bodies[i]);
  3950. pjsip_multipart_add_part(tdata->pool, body, part);
  3951. }
  3952. tdata->msg->body = body;
  3953. return 0;
  3954. }
  3955. int ast_sip_append_body(pjsip_tx_data *tdata, const char *body_text)
  3956. {
  3957. size_t combined_size = strlen(body_text) + tdata->msg->body->len;
  3958. struct ast_str *body_buffer = ast_str_alloca(combined_size);
  3959. ast_str_set(&body_buffer, 0, "%.*s%s", (int) tdata->msg->body->len, (char *) tdata->msg->body->data, body_text);
  3960. tdata->msg->body->data = pj_pool_alloc(tdata->pool, combined_size);
  3961. pj_memcpy(tdata->msg->body->data, ast_str_buffer(body_buffer), combined_size);
  3962. tdata->msg->body->len = combined_size;
  3963. return 0;
  3964. }
  3965. struct ast_taskprocessor *ast_sip_create_serializer_group_named(const char *name, struct ast_serializer_shutdown_group *shutdown_group)
  3966. {
  3967. return ast_threadpool_serializer_group(name, sip_threadpool, shutdown_group);
  3968. }
  3969. struct ast_taskprocessor *ast_sip_create_serializer_group(struct ast_serializer_shutdown_group *shutdown_group)
  3970. {
  3971. char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
  3972. /* Create name with seq number appended. */
  3973. ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "pjsip-group-serializer");
  3974. return ast_sip_create_serializer_group_named(tps_name, shutdown_group);
  3975. }
  3976. struct ast_taskprocessor *ast_sip_create_serializer_named(const char *name)
  3977. {
  3978. return ast_sip_create_serializer_group_named(name, NULL);
  3979. }
  3980. struct ast_taskprocessor *ast_sip_create_serializer(void)
  3981. {
  3982. char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
  3983. /* Create name with seq number appended. */
  3984. ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "pjsip-serializer");
  3985. return ast_sip_create_serializer_group_named(tps_name, NULL);
  3986. }
  3987. /*!
  3988. * \internal
  3989. * \brief Shutdown the serializers in the default pool.
  3990. * \since 14.0.0
  3991. *
  3992. * \return Nothing
  3993. */
  3994. static void serializer_pool_shutdown(void)
  3995. {
  3996. int idx;
  3997. for (idx = 0; idx < SERIALIZER_POOL_SIZE; ++idx) {
  3998. ast_taskprocessor_unreference(serializer_pool[idx]);
  3999. serializer_pool[idx] = NULL;
  4000. }
  4001. }
  4002. /*!
  4003. * \internal
  4004. * \brief Setup the serializers in the default pool.
  4005. * \since 14.0.0
  4006. *
  4007. * \retval 0 on success.
  4008. * \retval -1 on error.
  4009. */
  4010. static int serializer_pool_setup(void)
  4011. {
  4012. char tps_name[AST_TASKPROCESSOR_MAX_NAME + 1];
  4013. int idx;
  4014. for (idx = 0; idx < SERIALIZER_POOL_SIZE; ++idx) {
  4015. /* Create name with seq number appended. */
  4016. ast_taskprocessor_build_name(tps_name, sizeof(tps_name), "pjsip/default");
  4017. serializer_pool[idx] = ast_sip_create_serializer_named(tps_name);
  4018. if (!serializer_pool[idx]) {
  4019. serializer_pool_shutdown();
  4020. return -1;
  4021. }
  4022. }
  4023. return 0;
  4024. }
  4025. static struct ast_taskprocessor *serializer_pool_pick(void)
  4026. {
  4027. int idx;
  4028. int pos = 0;
  4029. if (!serializer_pool[0]) {
  4030. return NULL;
  4031. }
  4032. for (idx = 1; idx < SERIALIZER_POOL_SIZE; ++idx) {
  4033. if (ast_taskprocessor_size(serializer_pool[idx]) < ast_taskprocessor_size(serializer_pool[pos])) {
  4034. pos = idx;
  4035. }
  4036. }
  4037. return serializer_pool[pos];
  4038. }
  4039. int ast_sip_push_task(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
  4040. {
  4041. if (!serializer) {
  4042. serializer = serializer_pool_pick();
  4043. }
  4044. return ast_taskprocessor_push(serializer, sip_task, task_data);
  4045. }
  4046. struct sync_task_data {
  4047. ast_mutex_t lock;
  4048. ast_cond_t cond;
  4049. int complete;
  4050. int fail;
  4051. int (*task)(void *);
  4052. void *task_data;
  4053. };
  4054. static int sync_task(void *data)
  4055. {
  4056. struct sync_task_data *std = data;
  4057. int ret;
  4058. std->fail = std->task(std->task_data);
  4059. /*
  4060. * Once we unlock std->lock after signaling, we cannot access
  4061. * std again. The thread waiting within ast_sip_push_task_wait()
  4062. * is free to continue and release its local variable (std).
  4063. */
  4064. ast_mutex_lock(&std->lock);
  4065. std->complete = 1;
  4066. ast_cond_signal(&std->cond);
  4067. ret = std->fail;
  4068. ast_mutex_unlock(&std->lock);
  4069. return ret;
  4070. }
  4071. static int ast_sip_push_task_wait(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
  4072. {
  4073. /* This method is an onion */
  4074. struct sync_task_data std;
  4075. memset(&std, 0, sizeof(std));
  4076. ast_mutex_init(&std.lock);
  4077. ast_cond_init(&std.cond, NULL);
  4078. std.task = sip_task;
  4079. std.task_data = task_data;
  4080. if (ast_sip_push_task(serializer, sync_task, &std)) {
  4081. ast_mutex_destroy(&std.lock);
  4082. ast_cond_destroy(&std.cond);
  4083. return -1;
  4084. }
  4085. ast_mutex_lock(&std.lock);
  4086. while (!std.complete) {
  4087. ast_cond_wait(&std.cond, &std.lock);
  4088. }
  4089. ast_mutex_unlock(&std.lock);
  4090. ast_mutex_destroy(&std.lock);
  4091. ast_cond_destroy(&std.cond);
  4092. return std.fail;
  4093. }
  4094. int ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
  4095. {
  4096. if (ast_sip_thread_is_servant()) {
  4097. return sip_task(task_data);
  4098. }
  4099. return ast_sip_push_task_wait(serializer, sip_task, task_data);
  4100. }
  4101. int ast_sip_push_task_synchronous(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
  4102. {
  4103. return ast_sip_push_task_wait_servant(serializer, sip_task, task_data);
  4104. }
  4105. int ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
  4106. {
  4107. if (!serializer) {
  4108. /* Caller doesn't care which PJSIP serializer the task executes under. */
  4109. serializer = serializer_pool_pick();
  4110. if (!serializer) {
  4111. /* No serializer picked to execute the task */
  4112. return -1;
  4113. }
  4114. }
  4115. if (ast_taskprocessor_is_task(serializer)) {
  4116. /*
  4117. * We are the requested serializer so we must execute
  4118. * the task now or deadlock waiting on ourself to
  4119. * execute it.
  4120. */
  4121. return sip_task(task_data);
  4122. }
  4123. return ast_sip_push_task_wait(serializer, sip_task, task_data);
  4124. }
  4125. void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
  4126. {
  4127. size_t chars_to_copy = MIN(size - 1, pj_strlen(src));
  4128. memcpy(dest, pj_strbuf(src), chars_to_copy);
  4129. dest[chars_to_copy] = '\0';
  4130. }
  4131. int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype)
  4132. {
  4133. pjsip_media_type compare;
  4134. if (!content_type) {
  4135. return 0;
  4136. }
  4137. pjsip_media_type_init2(&compare, type, subtype);
  4138. return pjsip_media_type_cmp(content_type, &compare, 0) ? 0 : -1;
  4139. }
  4140. pj_caching_pool caching_pool;
  4141. pj_pool_t *memory_pool;
  4142. pj_thread_t *monitor_thread;
  4143. static int monitor_continue;
  4144. static void *monitor_thread_exec(void *endpt)
  4145. {
  4146. while (monitor_continue) {
  4147. const pj_time_val delay = {0, 10};
  4148. pjsip_endpt_handle_events(ast_pjsip_endpoint, &delay);
  4149. }
  4150. return NULL;
  4151. }
  4152. static void stop_monitor_thread(void)
  4153. {
  4154. monitor_continue = 0;
  4155. pj_thread_join(monitor_thread);
  4156. }
  4157. AST_THREADSTORAGE(pj_thread_storage);
  4158. AST_THREADSTORAGE(servant_id_storage);
  4159. #define SIP_SERVANT_ID 0x5E2F1D
  4160. static void sip_thread_start(void)
  4161. {
  4162. pj_thread_desc *desc;
  4163. pj_thread_t *thread;
  4164. uint32_t *servant_id;
  4165. servant_id = ast_threadstorage_get(&servant_id_storage, sizeof(*servant_id));
  4166. if (!servant_id) {
  4167. ast_log(LOG_ERROR, "Could not set SIP servant ID in thread-local storage.\n");
  4168. return;
  4169. }
  4170. *servant_id = SIP_SERVANT_ID;
  4171. desc = ast_threadstorage_get(&pj_thread_storage, sizeof(pj_thread_desc));
  4172. if (!desc) {
  4173. ast_log(LOG_ERROR, "Could not get thread desc from thread-local storage. Expect awful things to occur\n");
  4174. return;
  4175. }
  4176. pj_bzero(*desc, sizeof(*desc));
  4177. if (pj_thread_register("Asterisk Thread", *desc, &thread) != PJ_SUCCESS) {
  4178. ast_log(LOG_ERROR, "Couldn't register thread with PJLIB.\n");
  4179. }
  4180. }
  4181. int ast_sip_thread_is_servant(void)
  4182. {
  4183. uint32_t *servant_id;
  4184. if (monitor_thread &&
  4185. pthread_self() == *(pthread_t *)pj_thread_get_os_handle(monitor_thread)) {
  4186. return 1;
  4187. }
  4188. servant_id = ast_threadstorage_get(&servant_id_storage, sizeof(*servant_id));
  4189. if (!servant_id) {
  4190. return 0;
  4191. }
  4192. return *servant_id == SIP_SERVANT_ID;
  4193. }
  4194. void *ast_sip_dict_get(void *ht, const char *key)
  4195. {
  4196. unsigned int hval = 0;
  4197. if (!ht) {
  4198. return NULL;
  4199. }
  4200. return pj_hash_get(ht, key, PJ_HASH_KEY_STRING, &hval);
  4201. }
  4202. void *ast_sip_dict_set(pj_pool_t* pool, void *ht,
  4203. const char *key, void *val)
  4204. {
  4205. if (!ht) {
  4206. ht = pj_hash_create(pool, 11);
  4207. }
  4208. pj_hash_set(pool, ht, key, PJ_HASH_KEY_STRING, 0, val);
  4209. return ht;
  4210. }
  4211. static pj_bool_t supplement_on_rx_request(pjsip_rx_data *rdata)
  4212. {
  4213. struct ast_sip_supplement *supplement;
  4214. if (pjsip_rdata_get_dlg(rdata)) {
  4215. return PJ_FALSE;
  4216. }
  4217. AST_RWLIST_RDLOCK(&supplements);
  4218. AST_LIST_TRAVERSE(&supplements, supplement, next) {
  4219. if (supplement->incoming_request
  4220. && does_method_match(&rdata->msg_info.msg->line.req.method.name, supplement->method)) {
  4221. struct ast_sip_endpoint *endpoint;
  4222. endpoint = ast_pjsip_rdata_get_endpoint(rdata);
  4223. supplement->incoming_request(endpoint, rdata);
  4224. ao2_cleanup(endpoint);
  4225. }
  4226. }
  4227. AST_RWLIST_UNLOCK(&supplements);
  4228. return PJ_FALSE;
  4229. }
  4230. static void supplement_outgoing_response(pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
  4231. {
  4232. struct ast_sip_supplement *supplement;
  4233. pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
  4234. struct ast_sip_contact *contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
  4235. AST_RWLIST_RDLOCK(&supplements);
  4236. AST_LIST_TRAVERSE(&supplements, supplement, next) {
  4237. if (supplement->outgoing_response && does_method_match(&cseq->method.name, supplement->method)) {
  4238. supplement->outgoing_response(sip_endpoint, contact, tdata);
  4239. }
  4240. }
  4241. AST_RWLIST_UNLOCK(&supplements);
  4242. ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
  4243. ao2_cleanup(contact);
  4244. }
  4245. int ast_sip_send_response(pjsip_response_addr *res_addr, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
  4246. {
  4247. pj_status_t status;
  4248. supplement_outgoing_response(tdata, sip_endpoint);
  4249. status = pjsip_endpt_send_response(ast_sip_get_pjsip_endpoint(), res_addr, tdata, NULL, NULL);
  4250. if (status != PJ_SUCCESS) {
  4251. pjsip_tx_data_dec_ref(tdata);
  4252. }
  4253. return status == PJ_SUCCESS ? 0 : -1;
  4254. }
  4255. int ast_sip_send_stateful_response(pjsip_rx_data *rdata, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
  4256. {
  4257. pjsip_transaction *tsx;
  4258. if (pjsip_tsx_create_uas(NULL, rdata, &tsx) != PJ_SUCCESS) {
  4259. struct ast_sip_contact *contact;
  4260. /* ast_sip_create_response bumps the refcount of the contact and adds it to the tdata.
  4261. * We'll leak that reference if we don't get rid of it here.
  4262. */
  4263. contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
  4264. ao2_cleanup(contact);
  4265. ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
  4266. pjsip_tx_data_dec_ref(tdata);
  4267. return -1;
  4268. }
  4269. pjsip_tsx_recv_msg(tsx, rdata);
  4270. supplement_outgoing_response(tdata, sip_endpoint);
  4271. if (pjsip_tsx_send_msg(tsx, tdata) != PJ_SUCCESS) {
  4272. pjsip_tx_data_dec_ref(tdata);
  4273. return -1;
  4274. }
  4275. return 0;
  4276. }
  4277. int ast_sip_create_response(const pjsip_rx_data *rdata, int st_code,
  4278. struct ast_sip_contact *contact, pjsip_tx_data **tdata)
  4279. {
  4280. int res = pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, st_code, NULL, tdata);
  4281. if (!res) {
  4282. ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
  4283. }
  4284. return res;
  4285. }
  4286. int ast_sip_get_host_ip(int af, pj_sockaddr *addr)
  4287. {
  4288. if (af == pj_AF_INET() && !ast_strlen_zero(host_ip_ipv4_string)) {
  4289. pj_sockaddr_copy_addr(addr, &host_ip_ipv4);
  4290. return 0;
  4291. } else if (af == pj_AF_INET6() && !ast_strlen_zero(host_ip_ipv6_string)) {
  4292. pj_sockaddr_copy_addr(addr, &host_ip_ipv6);
  4293. return 0;
  4294. }
  4295. return -1;
  4296. }
  4297. const char *ast_sip_get_host_ip_string(int af)
  4298. {
  4299. if (af == pj_AF_INET()) {
  4300. return host_ip_ipv4_string;
  4301. } else if (af == pj_AF_INET6()) {
  4302. return host_ip_ipv6_string;
  4303. }
  4304. return NULL;
  4305. }
  4306. int ast_sip_dtmf_to_str(const enum ast_sip_dtmf_mode dtmf,
  4307. char *buf, size_t buf_len)
  4308. {
  4309. switch (dtmf) {
  4310. case AST_SIP_DTMF_NONE:
  4311. ast_copy_string(buf, "none", buf_len);
  4312. break;
  4313. case AST_SIP_DTMF_RFC_4733:
  4314. ast_copy_string(buf, "rfc4733", buf_len);
  4315. break;
  4316. case AST_SIP_DTMF_INBAND:
  4317. ast_copy_string(buf, "inband", buf_len);
  4318. break;
  4319. case AST_SIP_DTMF_INFO:
  4320. ast_copy_string(buf, "info", buf_len);
  4321. break;
  4322. case AST_SIP_DTMF_AUTO:
  4323. ast_copy_string(buf, "auto", buf_len);
  4324. break;
  4325. case AST_SIP_DTMF_AUTO_INFO:
  4326. ast_copy_string(buf, "auto_info", buf_len);
  4327. break;
  4328. default:
  4329. buf[0] = '\0';
  4330. return -1;
  4331. }
  4332. return 0;
  4333. }
  4334. int ast_sip_str_to_dtmf(const char * dtmf_mode)
  4335. {
  4336. int result = -1;
  4337. if (!strcasecmp(dtmf_mode, "info")) {
  4338. result = AST_SIP_DTMF_INFO;
  4339. } else if (!strcasecmp(dtmf_mode, "rfc4733")) {
  4340. result = AST_SIP_DTMF_RFC_4733;
  4341. } else if (!strcasecmp(dtmf_mode, "inband")) {
  4342. result = AST_SIP_DTMF_INBAND;
  4343. } else if (!strcasecmp(dtmf_mode, "none")) {
  4344. result = AST_SIP_DTMF_NONE;
  4345. } else if (!strcasecmp(dtmf_mode, "auto")) {
  4346. result = AST_SIP_DTMF_AUTO;
  4347. } else if (!strcasecmp(dtmf_mode, "auto_info")) {
  4348. result = AST_SIP_DTMF_AUTO_INFO;
  4349. }
  4350. return result;
  4351. }
  4352. /*!
  4353. * \brief Set name and number information on an identity header.
  4354. *
  4355. * \param pool Memory pool to use for string duplication
  4356. * \param id_hdr A From, P-Asserted-Identity, or Remote-Party-ID header to modify
  4357. * \param id The identity information to apply to the header
  4358. */
  4359. void ast_sip_modify_id_header(pj_pool_t *pool, pjsip_fromto_hdr *id_hdr, const struct ast_party_id *id)
  4360. {
  4361. pjsip_name_addr *id_name_addr;
  4362. pjsip_sip_uri *id_uri;
  4363. id_name_addr = (pjsip_name_addr *) id_hdr->uri;
  4364. id_uri = pjsip_uri_get_uri(id_name_addr->uri);
  4365. if (id->name.valid) {
  4366. if (!ast_strlen_zero(id->name.str)) {
  4367. int name_buf_len = strlen(id->name.str) * 2 + 1;
  4368. char *name_buf = ast_alloca(name_buf_len);
  4369. ast_escape_quoted(id->name.str, name_buf, name_buf_len);
  4370. pj_strdup2(pool, &id_name_addr->display, name_buf);
  4371. } else {
  4372. pj_strdup2(pool, &id_name_addr->display, NULL);
  4373. }
  4374. }
  4375. if (id->number.valid) {
  4376. pj_strdup2(pool, &id_uri->user, id->number.str);
  4377. }
  4378. }
  4379. static void remove_request_headers(pjsip_endpoint *endpt)
  4380. {
  4381. const pjsip_hdr *request_headers = pjsip_endpt_get_request_headers(endpt);
  4382. pjsip_hdr *iter = request_headers->next;
  4383. while (iter != request_headers) {
  4384. pjsip_hdr *to_erase = iter;
  4385. iter = iter->next;
  4386. pj_list_erase(to_erase);
  4387. }
  4388. }
  4389. long ast_sip_threadpool_queue_size(void)
  4390. {
  4391. return ast_threadpool_queue_size(sip_threadpool);
  4392. }
  4393. #ifdef TEST_FRAMEWORK
  4394. AST_TEST_DEFINE(xml_sanitization_end_null)
  4395. {
  4396. char sanitized[8];
  4397. switch (cmd) {
  4398. case TEST_INIT:
  4399. info->name = "xml_sanitization_end_null";
  4400. info->category = "/res/res_pjsip/";
  4401. info->summary = "Ensure XML sanitization works as expected with a long string";
  4402. info->description = "This test sanitizes a string which exceeds the output\n"
  4403. "buffer size. Once done the string is confirmed to be NULL terminated.";
  4404. return AST_TEST_NOT_RUN;
  4405. case TEST_EXECUTE:
  4406. break;
  4407. }
  4408. ast_sip_sanitize_xml("aaaaaaaaaaaa", sanitized, sizeof(sanitized));
  4409. if (sanitized[7] != '\0') {
  4410. ast_test_status_update(test, "Sanitized XML string is not null-terminated when it should be\n");
  4411. return AST_TEST_FAIL;
  4412. }
  4413. return AST_TEST_PASS;
  4414. }
  4415. AST_TEST_DEFINE(xml_sanitization_exceeds_buffer)
  4416. {
  4417. char sanitized[8];
  4418. switch (cmd) {
  4419. case TEST_INIT:
  4420. info->name = "xml_sanitization_exceeds_buffer";
  4421. info->category = "/res/res_pjsip/";
  4422. info->summary = "Ensure XML sanitization does not exceed buffer when output won't fit";
  4423. info->description = "This test sanitizes a string which before sanitization would\n"
  4424. "fit within the output buffer. After sanitization, however, the string would\n"
  4425. "exceed the buffer. Once done the string is confirmed to be NULL terminated.";
  4426. return AST_TEST_NOT_RUN;
  4427. case TEST_EXECUTE:
  4428. break;
  4429. }
  4430. ast_sip_sanitize_xml("<><><>&", sanitized, sizeof(sanitized));
  4431. if (sanitized[7] != '\0') {
  4432. ast_test_status_update(test, "Sanitized XML string is not null-terminated when it should be\n");
  4433. return AST_TEST_FAIL;
  4434. }
  4435. return AST_TEST_PASS;
  4436. }
  4437. #endif
  4438. /*!
  4439. * \internal
  4440. * \brief Reload configuration within a PJSIP thread
  4441. */
  4442. static int reload_configuration_task(void *obj)
  4443. {
  4444. ast_res_pjsip_reload_configuration();
  4445. ast_res_pjsip_init_options_handling(1);
  4446. ast_sip_initialize_dns();
  4447. return 0;
  4448. }
  4449. void internal_res_pjsip_ref(void)
  4450. {
  4451. ast_module_ref(ast_module_info->self);
  4452. }
  4453. void internal_res_pjsip_unref(void)
  4454. {
  4455. ast_module_unref(ast_module_info->self);
  4456. }
  4457. static int unload_pjsip(void *data)
  4458. {
  4459. /*
  4460. * These calls need the pjsip endpoint and serializer to clean up.
  4461. * If they're not set, then there's nothing to clean up anyway.
  4462. */
  4463. if (ast_pjsip_endpoint && serializer_pool[0]) {
  4464. ast_res_pjsip_cleanup_options_handling();
  4465. internal_sip_destroy_outbound_authentication();
  4466. ast_res_pjsip_cleanup_message_filter();
  4467. ast_sip_destroy_distributor();
  4468. ast_sip_destroy_transport_management();
  4469. ast_res_pjsip_destroy_configuration();
  4470. ast_sip_destroy_system();
  4471. ast_sip_destroy_global_headers();
  4472. internal_sip_unregister_service(&supplement_module);
  4473. ast_sip_destroy_transport_events();
  4474. }
  4475. if (monitor_thread) {
  4476. stop_monitor_thread();
  4477. monitor_thread = NULL;
  4478. }
  4479. if (memory_pool) {
  4480. /* This mimics the behavior of pj_pool_safe_release
  4481. * which was introduced in pjproject 2.6.
  4482. */
  4483. pj_pool_t *temp_pool = memory_pool;
  4484. memory_pool = NULL;
  4485. pj_pool_release(temp_pool);
  4486. }
  4487. ast_pjsip_endpoint = NULL;
  4488. if (caching_pool.lock) {
  4489. ast_pjproject_caching_pool_destroy(&caching_pool);
  4490. }
  4491. pj_shutdown();
  4492. return 0;
  4493. }
  4494. static int load_pjsip(void)
  4495. {
  4496. const unsigned int flags = 0; /* no port, no brackets */
  4497. pj_status_t status;
  4498. /* The third parameter is just copied from
  4499. * example code from PJLIB. This can be adjusted
  4500. * if necessary.
  4501. */
  4502. ast_pjproject_caching_pool_init(&caching_pool, NULL, 1024 * 1024);
  4503. if (pjsip_endpt_create(&caching_pool.factory, "SIP", &ast_pjsip_endpoint) != PJ_SUCCESS) {
  4504. ast_log(LOG_ERROR, "Failed to create PJSIP endpoint structure. Aborting load\n");
  4505. goto error;
  4506. }
  4507. /* PJSIP will automatically try to add a Max-Forwards header. Since we want to control that,
  4508. * we need to stop PJSIP from doing it automatically
  4509. */
  4510. remove_request_headers(ast_pjsip_endpoint);
  4511. memory_pool = pj_pool_create(&caching_pool.factory, "SIP", 1024, 1024, NULL);
  4512. if (!memory_pool) {
  4513. ast_log(LOG_ERROR, "Failed to create memory pool for SIP. Aborting load\n");
  4514. goto error;
  4515. }
  4516. if (!pj_gethostip(pj_AF_INET(), &host_ip_ipv4)) {
  4517. pj_sockaddr_print(&host_ip_ipv4, host_ip_ipv4_string, sizeof(host_ip_ipv4_string), flags);
  4518. ast_verb(3, "Local IPv4 address determined to be: %s\n", host_ip_ipv4_string);
  4519. }
  4520. if (!pj_gethostip(pj_AF_INET6(), &host_ip_ipv6)) {
  4521. pj_sockaddr_print(&host_ip_ipv6, host_ip_ipv6_string, sizeof(host_ip_ipv6_string), flags);
  4522. ast_verb(3, "Local IPv6 address determined to be: %s\n", host_ip_ipv6_string);
  4523. }
  4524. pjsip_tsx_layer_init_module(ast_pjsip_endpoint);
  4525. pjsip_ua_init_module(ast_pjsip_endpoint, NULL);
  4526. monitor_continue = 1;
  4527. status = pj_thread_create(memory_pool, "SIP", (pj_thread_proc *) &monitor_thread_exec,
  4528. NULL, PJ_THREAD_DEFAULT_STACK_SIZE * 2, 0, &monitor_thread);
  4529. if (status != PJ_SUCCESS) {
  4530. ast_log(LOG_ERROR, "Failed to start SIP monitor thread. Aborting load\n");
  4531. goto error;
  4532. }
  4533. return AST_MODULE_LOAD_SUCCESS;
  4534. error:
  4535. return AST_MODULE_LOAD_DECLINE;
  4536. }
  4537. /*
  4538. * This is a place holder function to ensure that pjmedia_strerr() is at
  4539. * least directly referenced by this module to ensure that the loader
  4540. * linker will link to the function. If a module only indirectly
  4541. * references a function from another module, such as a callback parameter
  4542. * to a function, the loader linker has been known to miss the link.
  4543. */
  4544. void never_called_res_pjsip(void);
  4545. void never_called_res_pjsip(void)
  4546. {
  4547. pjmedia_strerror(0, NULL, 0);
  4548. }
  4549. static int load_module(void)
  4550. {
  4551. struct ast_threadpool_options options;
  4552. CHECK_PJPROJECT_MODULE_LOADED();
  4553. /* pjproject and config_system need to be initialized before all else */
  4554. if (pj_init() != PJ_SUCCESS) {
  4555. return AST_MODULE_LOAD_DECLINE;
  4556. }
  4557. if (pjlib_util_init() != PJ_SUCCESS) {
  4558. goto error;
  4559. }
  4560. /* Register PJMEDIA error codes for SDP parsing errors */
  4561. if (pj_register_strerror(PJMEDIA_ERRNO_START, PJ_ERRNO_SPACE_SIZE, pjmedia_strerror)
  4562. != PJ_SUCCESS) {
  4563. ast_log(LOG_WARNING, "Failed to register pjmedia error codes. Codes will not be decoded.\n");
  4564. }
  4565. if (ast_sip_initialize_system()) {
  4566. ast_log(LOG_ERROR, "Failed to initialize SIP 'system' configuration section. Aborting load\n");
  4567. goto error;
  4568. }
  4569. /* The serializer needs threadpool and threadpool needs pjproject to be initialized so it's next */
  4570. sip_get_threadpool_options(&options);
  4571. options.thread_start = sip_thread_start;
  4572. sip_threadpool = ast_threadpool_create("SIP", NULL, &options);
  4573. if (!sip_threadpool) {
  4574. goto error;
  4575. }
  4576. if (serializer_pool_setup()) {
  4577. ast_log(LOG_ERROR, "Failed to create SIP serializer pool. Aborting load\n");
  4578. goto error;
  4579. }
  4580. if (ast_sip_initialize_scheduler()) {
  4581. ast_log(LOG_ERROR, "Failed to start scheduler. Aborting load\n");
  4582. goto error;
  4583. }
  4584. /* Now load all the pjproject infrastructure. */
  4585. if (load_pjsip()) {
  4586. goto error;
  4587. }
  4588. if (ast_sip_initialize_transport_events()) {
  4589. ast_log(LOG_ERROR, "Failed to initialize SIP transport monitor. Aborting load\n");
  4590. goto error;
  4591. }
  4592. ast_sip_initialize_dns();
  4593. ast_sip_initialize_global_headers();
  4594. if (ast_res_pjsip_preinit_options_handling()) {
  4595. ast_log(LOG_ERROR, "Failed to pre-initialize OPTIONS handling. Aborting load\n");
  4596. goto error;
  4597. }
  4598. if (ast_res_pjsip_initialize_configuration(ast_module_info)) {
  4599. ast_log(LOG_ERROR, "Failed to initialize SIP configuration. Aborting load\n");
  4600. goto error;
  4601. }
  4602. if (ast_sip_initialize_transport_management()) {
  4603. ast_log(LOG_ERROR, "Failed to initialize SIP transport management. Aborting load\n");
  4604. goto error;
  4605. }
  4606. if (ast_sip_initialize_distributor()) {
  4607. ast_log(LOG_ERROR, "Failed to register distributor module. Aborting load\n");
  4608. goto error;
  4609. }
  4610. if (internal_sip_register_service(&supplement_module)) {
  4611. ast_log(LOG_ERROR, "Failed to initialize supplement hooks. Aborting load\n");
  4612. goto error;
  4613. }
  4614. if (internal_sip_initialize_outbound_authentication()) {
  4615. ast_log(LOG_ERROR, "Failed to initialize outbound authentication. Aborting load\n");
  4616. goto error;
  4617. }
  4618. if (ast_res_pjsip_init_options_handling(0)) {
  4619. ast_log(LOG_ERROR, "Failed to initialize OPTIONS handling. Aborting load\n");
  4620. goto error;
  4621. }
  4622. if (ast_res_pjsip_init_message_filter()) {
  4623. ast_log(LOG_ERROR, "Failed to initialize message IP updating. Aborting load\n");
  4624. goto error;
  4625. }
  4626. ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands));
  4627. AST_TEST_REGISTER(xml_sanitization_end_null);
  4628. AST_TEST_REGISTER(xml_sanitization_exceeds_buffer);
  4629. ast_pjproject_ref();
  4630. return AST_MODULE_LOAD_SUCCESS;
  4631. error:
  4632. unload_pjsip(NULL);
  4633. /* These functions all check for NULLs and are safe to call at any time */
  4634. ast_sip_destroy_scheduler();
  4635. serializer_pool_shutdown();
  4636. ast_threadpool_shutdown(sip_threadpool);
  4637. return AST_MODULE_LOAD_DECLINE;
  4638. }
  4639. static int reload_module(void)
  4640. {
  4641. /*
  4642. * We must wait for the reload to complete so multiple
  4643. * reloads cannot happen at the same time.
  4644. */
  4645. if (ast_sip_push_task_wait_servant(NULL, reload_configuration_task, NULL)) {
  4646. ast_log(LOG_WARNING, "Failed to reload PJSIP\n");
  4647. return -1;
  4648. }
  4649. return 0;
  4650. }
  4651. static int unload_module(void)
  4652. {
  4653. AST_TEST_UNREGISTER(xml_sanitization_end_null);
  4654. AST_TEST_UNREGISTER(xml_sanitization_exceeds_buffer);
  4655. ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));
  4656. /* The thread this is called from cannot call PJSIP/PJLIB functions,
  4657. * so we have to push the work to the threadpool to handle
  4658. */
  4659. ast_sip_push_task_wait_servant(NULL, unload_pjsip, NULL);
  4660. ast_sip_destroy_scheduler();
  4661. serializer_pool_shutdown();
  4662. ast_threadpool_shutdown(sip_threadpool);
  4663. ast_pjproject_unref();
  4664. return 0;
  4665. }
  4666. AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Basic SIP resource",
  4667. .support_level = AST_MODULE_SUPPORT_CORE,
  4668. .load = load_module,
  4669. .unload = unload_module,
  4670. .reload = reload_module,
  4671. .load_pri = AST_MODPRI_CHANNEL_DEPEND - 5,
  4672. );