res_pjsip.c 134 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185
  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 <pjlib.h>
  23. #include "asterisk/res_pjsip.h"
  24. #include "res_pjsip/include/res_pjsip_private.h"
  25. #include "asterisk/linkedlists.h"
  26. #include "asterisk/logger.h"
  27. #include "asterisk/lock.h"
  28. #include "asterisk/utils.h"
  29. #include "asterisk/astobj2.h"
  30. #include "asterisk/module.h"
  31. #include "asterisk/threadpool.h"
  32. #include "asterisk/taskprocessor.h"
  33. #include "asterisk/uuid.h"
  34. #include "asterisk/sorcery.h"
  35. /*** MODULEINFO
  36. <depend>pjproject</depend>
  37. <depend>res_sorcery_config</depend>
  38. <support_level>core</support_level>
  39. ***/
  40. /*** DOCUMENTATION
  41. <configInfo name="res_pjsip" language="en_US">
  42. <synopsis>SIP Resource using PJProject</synopsis>
  43. <configFile name="pjsip.conf">
  44. <configObject name="endpoint">
  45. <synopsis>Endpoint</synopsis>
  46. <description><para>
  47. The <emphasis>Endpoint</emphasis> is the primary configuration object.
  48. It contains the core SIP related options only, endpoints are <emphasis>NOT</emphasis>
  49. dialable entries of their own. Communication with another SIP device is
  50. accomplished via Addresses of Record (AoRs) which have one or more
  51. contacts assicated with them. Endpoints <emphasis>NOT</emphasis> configured to
  52. use a <literal>transport</literal> will default to first transport found
  53. in <filename>pjsip.conf</filename> that matches its type.
  54. </para>
  55. <para>Example: An Endpoint has been configured with no transport.
  56. When it comes time to call an AoR, PJSIP will find the
  57. first transport that matches the type. A SIP URI of <literal>sip:5000@[11::33]</literal>
  58. will use the first IPv6 transport and try to send the request.
  59. </para>
  60. <para>If the anonymous endpoint identifier is in use an endpoint with the name
  61. "anonymous@domain" will be searched for as a last resort. If this is not found
  62. it will fall back to searching for "anonymous". If neither endpoints are found
  63. the anonymous endpoint identifier will not return an endpoint and anonymous
  64. calling will not be possible.
  65. </para>
  66. </description>
  67. <configOption name="100rel" default="yes">
  68. <synopsis>Allow support for RFC3262 provisional ACK tags</synopsis>
  69. <description>
  70. <enumlist>
  71. <enum name="no" />
  72. <enum name="required" />
  73. <enum name="yes" />
  74. </enumlist>
  75. </description>
  76. </configOption>
  77. <configOption name="aggregate_mwi" default="yes">
  78. <synopsis>Condense MWI notifications into a single NOTIFY.</synopsis>
  79. <description><para>When enabled, <replaceable>aggregate_mwi</replaceable> condenses message
  80. waiting notifications from multiple mailboxes into a single NOTIFY. If it is disabled,
  81. individual NOTIFYs are sent for each mailbox.</para></description>
  82. </configOption>
  83. <configOption name="allow">
  84. <synopsis>Media Codec(s) to allow</synopsis>
  85. </configOption>
  86. <configOption name="aors">
  87. <synopsis>AoR(s) to be used with the endpoint</synopsis>
  88. <description><para>
  89. List of comma separated AoRs that the endpoint should be associated with.
  90. </para></description>
  91. </configOption>
  92. <configOption name="auth">
  93. <synopsis>Authentication Object(s) associated with the endpoint</synopsis>
  94. <description><para>
  95. This is a comma-delimited list of <replaceable>auth</replaceable> sections defined
  96. in <filename>pjsip.conf</filename> to be used to verify inbound connection attempts.
  97. </para><para>
  98. Endpoints without an <literal>authentication</literal> object
  99. configured will allow connections without vertification.
  100. </para></description>
  101. </configOption>
  102. <configOption name="callerid">
  103. <synopsis>CallerID information for the endpoint</synopsis>
  104. <description><para>
  105. Must be in the format <literal>Name &lt;Number&gt;</literal>,
  106. or only <literal>&lt;Number&gt;</literal>.
  107. </para></description>
  108. </configOption>
  109. <configOption name="callerid_privacy">
  110. <synopsis>Default privacy level</synopsis>
  111. <description>
  112. <enumlist>
  113. <enum name="allowed_not_screened" />
  114. <enum name="allowed_passed_screen" />
  115. <enum name="allowed_failed_screen" />
  116. <enum name="allowed" />
  117. <enum name="prohib_not_screened" />
  118. <enum name="prohib_passed_screen" />
  119. <enum name="prohib_failed_screen" />
  120. <enum name="prohib" />
  121. <enum name="unavailable" />
  122. </enumlist>
  123. </description>
  124. </configOption>
  125. <configOption name="callerid_tag">
  126. <synopsis>Internal id_tag for the endpoint</synopsis>
  127. </configOption>
  128. <configOption name="context">
  129. <synopsis>Dialplan context for inbound sessions</synopsis>
  130. </configOption>
  131. <configOption name="direct_media_glare_mitigation" default="none">
  132. <synopsis>Mitigation of direct media (re)INVITE glare</synopsis>
  133. <description>
  134. <para>
  135. This setting attempts to avoid creating INVITE glare scenarios
  136. by disabling direct media reINVITEs in one direction thereby allowing
  137. designated servers (according to this option) to initiate direct
  138. media reINVITEs without contention and significantly reducing call
  139. setup time.
  140. </para>
  141. <para>
  142. A more detailed description of how this option functions can be found on
  143. the Asterisk wiki https://wiki.asterisk.org/wiki/display/AST/SIP+Direct+Media+Reinvite+Glare+Avoidance
  144. </para>
  145. <enumlist>
  146. <enum name="none" />
  147. <enum name="outgoing" />
  148. <enum name="incoming" />
  149. </enumlist>
  150. </description>
  151. </configOption>
  152. <configOption name="direct_media_method" default="invite">
  153. <synopsis>Direct Media method type</synopsis>
  154. <description>
  155. <para>Method for setting up Direct Media between endpoints.</para>
  156. <enumlist>
  157. <enum name="invite" />
  158. <enum name="reinvite">
  159. <para>Alias for the <literal>invite</literal> value.</para>
  160. </enum>
  161. <enum name="update" />
  162. </enumlist>
  163. </description>
  164. </configOption>
  165. <configOption name="connected_line_method" default="invite">
  166. <synopsis>Connected line method type</synopsis>
  167. <description>
  168. <para>Method used when updating connected line information.</para>
  169. <enumlist>
  170. <enum name="invite" />
  171. <enum name="reinvite">
  172. <para>Alias for the <literal>invite</literal> value.</para>
  173. </enum>
  174. <enum name="update" />
  175. </enumlist>
  176. </description>
  177. </configOption>
  178. <configOption name="direct_media" default="yes">
  179. <synopsis>Determines whether media may flow directly between endpoints.</synopsis>
  180. </configOption>
  181. <configOption name="disable_direct_media_on_nat" default="no">
  182. <synopsis>Disable direct media session refreshes when NAT obstructs the media session</synopsis>
  183. </configOption>
  184. <configOption name="disallow">
  185. <synopsis>Media Codec(s) to disallow</synopsis>
  186. </configOption>
  187. <configOption name="dtmf_mode" default="rfc4733">
  188. <synopsis>DTMF mode</synopsis>
  189. <description>
  190. <para>This setting allows to choose the DTMF mode for endpoint communication.</para>
  191. <enumlist>
  192. <enum name="rfc4733">
  193. <para>DTMF is sent out of band of the main audio stream.This
  194. supercedes the older <emphasis>RFC-2833</emphasis> used within
  195. the older <literal>chan_sip</literal>.</para>
  196. </enum>
  197. <enum name="inband">
  198. <para>DTMF is sent as part of audio stream.</para>
  199. </enum>
  200. <enum name="info">
  201. <para>DTMF is sent as SIP INFO packets.</para>
  202. </enum>
  203. </enumlist>
  204. </description>
  205. </configOption>
  206. <configOption name="media_address">
  207. <synopsis>IP address used in SDP for media handling</synopsis>
  208. <description><para>
  209. At the time of SDP creation, the IP address defined here will be used as
  210. the media address for individual streams in the SDP.
  211. </para>
  212. <note><para>
  213. Be aware that the <literal>external_media_address</literal> option, set in Transport
  214. configuration, can also affect the final media address used in the SDP.
  215. </para></note>
  216. </description>
  217. </configOption>
  218. <configOption name="force_rport" default="yes">
  219. <synopsis>Force use of return port</synopsis>
  220. </configOption>
  221. <configOption name="ice_support" default="no">
  222. <synopsis>Enable the ICE mechanism to help traverse NAT</synopsis>
  223. </configOption>
  224. <configOption name="identify_by" default="username,location">
  225. <synopsis>Way(s) for Endpoint to be identified</synopsis>
  226. <description><para>
  227. An endpoint can be identified in multiple ways. Currently, the only supported
  228. option is <literal>username</literal>, which matches the endpoint based on the
  229. username in the From header.
  230. </para>
  231. <note><para>Endpoints can also be identified by IP address; however, that method
  232. of identification is not handled by this configuration option. See the documentation
  233. for the <literal>identify</literal> configuration section for more details on that
  234. method of endpoint identification. If this option is set to <literal>username</literal>
  235. and an <literal>identify</literal> configuration section exists for the endpoint, then
  236. the endpoint can be identified in multiple ways.</para></note>
  237. <enumlist>
  238. <enum name="username" />
  239. </enumlist>
  240. </description>
  241. </configOption>
  242. <configOption name="redirect_method">
  243. <synopsis>How redirects received from an endpoint are handled</synopsis>
  244. <description><para>
  245. When a redirect is received from an endpoint there are multiple ways it can be handled.
  246. If this option is set to <literal>user</literal> the user portion of the redirect target
  247. is treated as an extension within the dialplan and dialed using a Local channel. If this option
  248. is set to <literal>uri_core</literal> the target URI is returned to the dialing application
  249. which dials it using the PJSIP channel driver and endpoint originally used. If this option is
  250. set to <literal>uri_pjsip</literal> the redirect occurs within chan_pjsip itself and is not exposed
  251. to the core at all. The <literal>uri_pjsip</literal> option has the benefit of being more efficient
  252. and also supporting multiple potential redirect targets. The con is that since redirection occurs
  253. within chan_pjsip redirecting information is not forwarded and redirection can not be
  254. prevented.
  255. </para>
  256. <enumlist>
  257. <enum name="user" />
  258. <enum name="uri_core" />
  259. <enum name="uri_pjsip" />
  260. </enumlist>
  261. </description>
  262. </configOption>
  263. <configOption name="mailboxes">
  264. <synopsis>NOTIFY the endpoint when state changes for any of the specified mailboxes</synopsis>
  265. <description><para>
  266. Asterisk will send unsolicited MWI NOTIFY messages to the endpoint when state
  267. changes happen for any of the specified mailboxes. More than one mailbox can be
  268. specified with a comma-delimited string. app_voicemail mailboxes must be specified
  269. as mailbox@context; for example: mailboxes=6001@default. For mailboxes provided by
  270. external sources, such as through the res_external_mwi module, you must specify
  271. strings supported by the external system.
  272. </para><para>
  273. For endpoints that SUBSCRIBE for MWI, use the <literal>mailboxes</literal> option in your AOR
  274. configuration.
  275. </para></description>
  276. </configOption>
  277. <configOption name="moh_suggest" default="default">
  278. <synopsis>Default Music On Hold class</synopsis>
  279. </configOption>
  280. <configOption name="outbound_auth">
  281. <synopsis>Authentication object used for outbound requests</synopsis>
  282. </configOption>
  283. <configOption name="outbound_proxy">
  284. <synopsis>Proxy through which to send requests, a full SIP URI must be provided</synopsis>
  285. </configOption>
  286. <configOption name="rewrite_contact">
  287. <synopsis>Allow Contact header to be rewritten with the source IP address-port</synopsis>
  288. <description><para>
  289. On inbound SIP messages from this endpoint, the Contact header will be changed to have the
  290. source IP address and port. This option does not affect outbound messages send to this
  291. endpoint.
  292. </para></description>
  293. </configOption>
  294. <configOption name="rtp_ipv6" default="no">
  295. <synopsis>Allow use of IPv6 for RTP traffic</synopsis>
  296. </configOption>
  297. <configOption name="rtp_symmetric" default="no">
  298. <synopsis>Enforce that RTP must be symmetric</synopsis>
  299. </configOption>
  300. <configOption name="send_diversion" default="yes">
  301. <synopsis>Send the Diversion header, conveying the diversion
  302. information to the called user agent</synopsis>
  303. </configOption>
  304. <configOption name="send_pai" default="no">
  305. <synopsis>Send the P-Asserted-Identity header</synopsis>
  306. </configOption>
  307. <configOption name="send_rpid" default="no">
  308. <synopsis>Send the Remote-Party-ID header</synopsis>
  309. </configOption>
  310. <configOption name="timers_min_se" default="90">
  311. <synopsis>Minimum session timers expiration period</synopsis>
  312. <description><para>
  313. Minimium session timer expiration period. Time in seconds.
  314. </para></description>
  315. </configOption>
  316. <configOption name="timers" default="yes">
  317. <synopsis>Session timers for SIP packets</synopsis>
  318. <description>
  319. <enumlist>
  320. <enum name="forced" />
  321. <enum name="no" />
  322. <enum name="required" />
  323. <enum name="yes" />
  324. </enumlist>
  325. </description>
  326. </configOption>
  327. <configOption name="timers_sess_expires" default="1800">
  328. <synopsis>Maximum session timer expiration period</synopsis>
  329. <description><para>
  330. Maximium session timer expiration period. Time in seconds.
  331. </para></description>
  332. </configOption>
  333. <configOption name="transport">
  334. <synopsis>Desired transport configuration</synopsis>
  335. <description><para>
  336. This will set the desired transport configuration to send SIP data through.
  337. </para>
  338. <warning><para>Not specifying a transport will <emphasis>DEFAULT</emphasis>
  339. to the first configured transport in <filename>pjsip.conf</filename> which is
  340. valid for the URI we are trying to contact.
  341. </para></warning>
  342. <warning><para>Transport configuration is not affected by reloads. In order to
  343. change transports, a full Asterisk restart is required</para></warning>
  344. </description>
  345. </configOption>
  346. <configOption name="trust_id_inbound" default="no">
  347. <synopsis>Accept identification information received from this endpoint</synopsis>
  348. <description><para>This option determines whether Asterisk will accept
  349. identification from the endpoint from headers such as P-Asserted-Identity
  350. or Remote-Party-ID header. This option applies both to calls originating from the
  351. endpoint and calls originating from Asterisk. If <literal>no</literal>, the
  352. configured Caller-ID from pjsip.conf will always be used as the identity for
  353. the endpoint.</para></description>
  354. </configOption>
  355. <configOption name="trust_id_outbound" default="no">
  356. <synopsis>Send private identification details to the endpoint.</synopsis>
  357. <description><para>This option determines whether res_pjsip will send private
  358. identification information to the endpoint. If <literal>no</literal>,
  359. private Caller-ID information will not be forwarded to the endpoint.
  360. "Private" in this case refers to any method of restricting identification.
  361. Example: setting <replaceable>callerid_privacy</replaceable> to any
  362. <literal>prohib</literal> variation.
  363. Example: If <replaceable>trust_id_inbound</replaceable> is set to
  364. <literal>yes</literal>, the presence of a <literal>Privacy: id</literal>
  365. header in a SIP request or response would indicate the identification
  366. provided in the request is private.</para></description>
  367. </configOption>
  368. <configOption name="type">
  369. <synopsis>Must be of type 'endpoint'.</synopsis>
  370. </configOption>
  371. <configOption name="use_ptime" default="no">
  372. <synopsis>Use Endpoint's requested packetisation interval</synopsis>
  373. </configOption>
  374. <configOption name="use_avpf" default="no">
  375. <synopsis>Determines whether res_pjsip will use and enforce usage of AVPF for this
  376. endpoint.</synopsis>
  377. <description><para>
  378. If set to <literal>yes</literal>, res_pjsip will use the AVPF or SAVPF RTP
  379. profile for all media offers on outbound calls and media updates and will
  380. decline media offers not using the AVPF or SAVPF profile.
  381. </para><para>
  382. If set to <literal>no</literal>, res_pjsip will use the AVP or SAVP RTP
  383. profile for all media offers on outbound calls and media updates, and will
  384. decline media offers not using the AVP or SAVP profile.
  385. </para></description>
  386. </configOption>
  387. <configOption name="force_avp" default="no">
  388. <synopsis>Determines whether res_pjsip will use and enforce usage of AVP,
  389. regardless of the RTP profile in use for this endpoint.</synopsis>
  390. <description><para>
  391. If set to <literal>yes</literal>, res_pjsip will use the AVP, AVPF, SAVP, or
  392. SAVPF RTP profile for all media offers on outbound calls and media updates including
  393. those for DTLS-SRTP streams.
  394. </para><para>
  395. If set to <literal>no</literal>, res_pjsip will use the respective RTP profile
  396. depending on configuration.
  397. </para></description>
  398. </configOption>
  399. <configOption name="media_use_received_transport" default="no">
  400. <synopsis>Determines whether res_pjsip will use the media transport received in the
  401. offer SDP in the corresponding answer SDP.</synopsis>
  402. <description><para>
  403. If set to <literal>yes</literal>, res_pjsip will use the received media transport.
  404. </para><para>
  405. If set to <literal>no</literal>, res_pjsip will use the respective RTP profile
  406. depending on configuration.
  407. </para></description>
  408. </configOption>
  409. <configOption name="media_encryption" default="no">
  410. <synopsis>Determines whether res_pjsip will use and enforce usage of media encryption
  411. for this endpoint.</synopsis>
  412. <description>
  413. <enumlist>
  414. <enum name="no"><para>
  415. res_pjsip will offer no encryption and allow no encryption to be setup.
  416. </para></enum>
  417. <enum name="sdes"><para>
  418. res_pjsip will offer standard SRTP setup via in-SDP keys. Encrypted SIP
  419. transport should be used in conjunction with this option to prevent
  420. exposure of media encryption keys.
  421. </para></enum>
  422. <enum name="dtls"><para>
  423. res_pjsip will offer DTLS-SRTP setup.
  424. </para></enum>
  425. </enumlist>
  426. </description>
  427. </configOption>
  428. <configOption name="inband_progress" default="no">
  429. <synopsis>Determines whether chan_pjsip will indicate ringing using inband
  430. progress.</synopsis>
  431. <description><para>
  432. If set to <literal>yes</literal>, chan_pjsip will send a 183 Session Progress
  433. when told to indicate ringing and will immediately start sending ringing
  434. as audio.
  435. </para><para>
  436. If set to <literal>no</literal>, chan_pjsip will send a 180 Ringing when told
  437. to indicate ringing and will NOT send it as audio.
  438. </para></description>
  439. </configOption>
  440. <configOption name="call_group">
  441. <synopsis>The numeric pickup groups for a channel.</synopsis>
  442. <description><para>
  443. Can be set to a comma separated list of numbers or ranges between the values
  444. of 0-63 (maximum of 64 groups).
  445. </para></description>
  446. </configOption>
  447. <configOption name="pickup_group">
  448. <synopsis>The numeric pickup groups that a channel can pickup.</synopsis>
  449. <description><para>
  450. Can be set to a comma separated list of numbers or ranges between the values
  451. of 0-63 (maximum of 64 groups).
  452. </para></description>
  453. </configOption>
  454. <configOption name="named_call_group">
  455. <synopsis>The named pickup groups for a channel.</synopsis>
  456. <description><para>
  457. Can be set to a comma separated list of case sensitive strings limited by
  458. supported line length.
  459. </para></description>
  460. </configOption>
  461. <configOption name="named_pickup_group">
  462. <synopsis>The named pickup groups that a channel can pickup.</synopsis>
  463. <description><para>
  464. Can be set to a comma separated list of case sensitive strings limited by
  465. supported line length.
  466. </para></description>
  467. </configOption>
  468. <configOption name="device_state_busy_at" default="0">
  469. <synopsis>The number of in-use channels which will cause busy to be returned as device state</synopsis>
  470. <description><para>
  471. When the number of in-use channels for the endpoint matches the devicestate_busy_at setting the
  472. PJSIP channel driver will return busy as the device state instead of in use.
  473. </para></description>
  474. </configOption>
  475. <configOption name="t38_udptl" default="no">
  476. <synopsis>Whether T.38 UDPTL support is enabled or not</synopsis>
  477. <description><para>
  478. If set to yes T.38 UDPTL support will be enabled, and T.38 negotiation requests will be accepted
  479. and relayed.
  480. </para></description>
  481. </configOption>
  482. <configOption name="t38_udptl_ec" default="none">
  483. <synopsis>T.38 UDPTL error correction method</synopsis>
  484. <description>
  485. <enumlist>
  486. <enum name="none"><para>
  487. No error correction should be used.
  488. </para></enum>
  489. <enum name="fec"><para>
  490. Forward error correction should be used.
  491. </para></enum>
  492. <enum name="redundancy"><para>
  493. Redundacy error correction should be used.
  494. </para></enum>
  495. </enumlist>
  496. </description>
  497. </configOption>
  498. <configOption name="t38_udptl_maxdatagram" default="0">
  499. <synopsis>T.38 UDPTL maximum datagram size</synopsis>
  500. <description><para>
  501. This option can be set to override the maximum datagram of a remote endpoint for broken
  502. endpoints.
  503. </para></description>
  504. </configOption>
  505. <configOption name="fax_detect" default="no">
  506. <synopsis>Whether CNG tone detection is enabled</synopsis>
  507. <description><para>
  508. This option can be set to send the session to the fax extension when a CNG tone is
  509. detected.
  510. </para></description>
  511. </configOption>
  512. <configOption name="t38_udptl_nat" default="no">
  513. <synopsis>Whether NAT support is enabled on UDPTL sessions</synopsis>
  514. <description><para>
  515. When enabled the UDPTL stack will send UDPTL packets to the source address of
  516. received packets.
  517. </para></description>
  518. </configOption>
  519. <configOption name="t38_udptl_ipv6" default="no">
  520. <synopsis>Whether IPv6 is used for UDPTL Sessions</synopsis>
  521. <description><para>
  522. When enabled the UDPTL stack will use IPv6.
  523. </para></description>
  524. </configOption>
  525. <configOption name="tone_zone">
  526. <synopsis>Set which country's indications to use for channels created for this endpoint.</synopsis>
  527. </configOption>
  528. <configOption name="language">
  529. <synopsis>Set the default language to use for channels created for this endpoint.</synopsis>
  530. </configOption>
  531. <configOption name="one_touch_recording" default="no">
  532. <synopsis>Determines whether one-touch recording is allowed for this endpoint.</synopsis>
  533. <see-also>
  534. <ref type="configOption">record_on_feature</ref>
  535. <ref type="configOption">record_off_feature</ref>
  536. </see-also>
  537. </configOption>
  538. <configOption name="record_on_feature" default="automixmon">
  539. <synopsis>The feature to enact when one-touch recording is turned on.</synopsis>
  540. <description>
  541. <para>When an INFO request for one-touch recording arrives with a Record header set to "on", this
  542. feature will be enabled for the channel. The feature designated here can be any built-in
  543. or dynamic feature defined in features.conf.</para>
  544. <note><para>This setting has no effect if the endpoint's one_touch_recording option is disabled</para></note>
  545. </description>
  546. <see-also>
  547. <ref type="configOption">one_touch_recording</ref>
  548. <ref type="configOption">record_off_feature</ref>
  549. </see-also>
  550. </configOption>
  551. <configOption name="record_off_feature" default="automixmon">
  552. <synopsis>The feature to enact when one-touch recording is turned off.</synopsis>
  553. <description>
  554. <para>When an INFO request for one-touch recording arrives with a Record header set to "off", this
  555. feature will be enabled for the channel. The feature designated here can be any built-in
  556. or dynamic feature defined in features.conf.</para>
  557. <note><para>This setting has no effect if the endpoint's one_touch_recording option is disabled</para></note>
  558. </description>
  559. <see-also>
  560. <ref type="configOption">one_touch_recording</ref>
  561. <ref type="configOption">record_on_feature</ref>
  562. </see-also>
  563. </configOption>
  564. <configOption name="rtp_engine" default="asterisk">
  565. <synopsis>Name of the RTP engine to use for channels created for this endpoint</synopsis>
  566. </configOption>
  567. <configOption name="allow_transfer" default="yes">
  568. <synopsis>Determines whether SIP REFER transfers are allowed for this endpoint</synopsis>
  569. </configOption>
  570. <configOption name="sdp_owner" default="-">
  571. <synopsis>String placed as the username portion of an SDP origin (o=) line.</synopsis>
  572. </configOption>
  573. <configOption name="sdp_session" default="Asterisk">
  574. <synopsis>String used for the SDP session (s=) line.</synopsis>
  575. </configOption>
  576. <configOption name="tos_audio">
  577. <synopsis>DSCP TOS bits for audio streams</synopsis>
  578. <description><para>
  579. See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
  580. </para></description>
  581. </configOption>
  582. <configOption name="tos_video">
  583. <synopsis>DSCP TOS bits for video streams</synopsis>
  584. <description><para>
  585. See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
  586. </para></description>
  587. </configOption>
  588. <configOption name="cos_audio">
  589. <synopsis>Priority for audio streams</synopsis>
  590. <description><para>
  591. See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
  592. </para></description>
  593. </configOption>
  594. <configOption name="cos_video">
  595. <synopsis>Priority for video streams</synopsis>
  596. <description><para>
  597. See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
  598. </para></description>
  599. </configOption>
  600. <configOption name="allow_subscribe" default="yes">
  601. <synopsis>Determines if endpoint is allowed to initiate subscriptions with Asterisk.</synopsis>
  602. </configOption>
  603. <configOption name="sub_min_expiry" default="60">
  604. <synopsis>The minimum allowed expiry time for subscriptions initiated by the endpoint.</synopsis>
  605. </configOption>
  606. <configOption name="from_user">
  607. <synopsis>Username to use in From header for requests to this endpoint.</synopsis>
  608. </configOption>
  609. <configOption name="mwi_from_user">
  610. <synopsis>Username to use in From header for unsolicited MWI NOTIFYs to this endpoint.</synopsis>
  611. </configOption>
  612. <configOption name="from_domain">
  613. <synopsis>Domain to user in From header for requests to this endpoint.</synopsis>
  614. </configOption>
  615. <configOption name="dtls_verify">
  616. <synopsis>Verify that the provided peer certificate is valid</synopsis>
  617. <description><para>
  618. This option only applies if <replaceable>media_encryption</replaceable> is
  619. set to <literal>dtls</literal>.
  620. </para></description>
  621. </configOption>
  622. <configOption name="dtls_rekey">
  623. <synopsis>Interval at which to renegotiate the TLS session and rekey the SRTP session</synopsis>
  624. <description><para>
  625. This option only applies if <replaceable>media_encryption</replaceable> is
  626. set to <literal>dtls</literal>.
  627. </para><para>
  628. If this is not set or the value provided is 0 rekeying will be disabled.
  629. </para></description>
  630. </configOption>
  631. <configOption name="dtls_cert_file">
  632. <synopsis>Path to certificate file to present to peer</synopsis>
  633. <description><para>
  634. This option only applies if <replaceable>media_encryption</replaceable> is
  635. set to <literal>dtls</literal>.
  636. </para></description>
  637. </configOption>
  638. <configOption name="dtls_private_key">
  639. <synopsis>Path to private key for certificate file</synopsis>
  640. <description><para>
  641. This option only applies if <replaceable>media_encryption</replaceable> is
  642. set to <literal>dtls</literal>.
  643. </para></description>
  644. </configOption>
  645. <configOption name="dtls_cipher">
  646. <synopsis>Cipher to use for DTLS negotiation</synopsis>
  647. <description><para>
  648. This option only applies if <replaceable>media_encryption</replaceable> is
  649. set to <literal>dtls</literal>.
  650. </para>
  651. <para>Many options for acceptable ciphers. See link for more:</para>
  652. <para>http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS
  653. </para></description>
  654. </configOption>
  655. <configOption name="dtls_ca_file">
  656. <synopsis>Path to certificate authority certificate</synopsis>
  657. <description><para>
  658. This option only applies if <replaceable>media_encryption</replaceable> is
  659. set to <literal>dtls</literal>.
  660. </para></description>
  661. </configOption>
  662. <configOption name="dtls_ca_path">
  663. <synopsis>Path to a directory containing certificate authority certificates</synopsis>
  664. <description><para>
  665. This option only applies if <replaceable>media_encryption</replaceable> is
  666. set to <literal>dtls</literal>.
  667. </para></description>
  668. </configOption>
  669. <configOption name="dtls_setup">
  670. <synopsis>Whether we are willing to accept connections, connect to the other party, or both.</synopsis>
  671. <description>
  672. <para>
  673. This option only applies if <replaceable>media_encryption</replaceable> is
  674. set to <literal>dtls</literal>.
  675. </para>
  676. <enumlist>
  677. <enum name="active"><para>
  678. res_pjsip will make a connection to the peer.
  679. </para></enum>
  680. <enum name="passive"><para>
  681. res_pjsip will accept connections from the peer.
  682. </para></enum>
  683. <enum name="actpass"><para>
  684. res_pjsip will offer and accept connections from the peer.
  685. </para></enum>
  686. </enumlist>
  687. </description>
  688. </configOption>
  689. <configOption name="dtls_fingerprint">
  690. <synopsis>Type of hash to use for the DTLS fingerprint in the SDP.</synopsis>
  691. <description>
  692. <para>
  693. This option only applies if <replaceable>media_encryption</replaceable> is
  694. set to <literal>dtls</literal>.
  695. </para>
  696. <enumlist>
  697. <enum name="SHA-256"></enum>
  698. <enum name="SHA-1"></enum>
  699. </enumlist>
  700. </description>
  701. </configOption>
  702. <configOption name="srtp_tag_32">
  703. <synopsis>Determines whether 32 byte tags should be used instead of 80 byte tags.</synopsis>
  704. <description><para>
  705. This option only applies if <replaceable>media_encryption</replaceable> is
  706. set to <literal>sdes</literal> or <literal>dtls</literal>.
  707. </para></description>
  708. </configOption>
  709. <configOption name="set_var">
  710. <synopsis>Variable set on a channel involving the endpoint.</synopsis>
  711. <description><para>
  712. When a new channel is created using the endpoint set the specified
  713. variable(s) on that channel. For multiple channel variables specify
  714. multiple 'set_var'(s).
  715. </para></description>
  716. </configOption>
  717. <configOption name="message_context">
  718. <synopsis>Context to route incoming MESSAGE requests to.</synopsis>
  719. <description><para>
  720. If specified, incoming MESSAGE requests will be routed to the indicated
  721. dialplan context. If no <replaceable>message_context</replaceable> is
  722. specified, then the <replaceable>context</replaceable> setting is used.
  723. </para></description>
  724. </configOption>
  725. <configOption name="accountcode">
  726. <synopsis>An accountcode to set automatically on any channels created for this endpoint.</synopsis>
  727. <description><para>
  728. If specified, any channel created for this endpoint will automatically
  729. have this accountcode set on it.
  730. </para></description>
  731. </configOption>
  732. </configObject>
  733. <configObject name="auth">
  734. <synopsis>Authentication type</synopsis>
  735. <description><para>
  736. Authentication objects hold the authentication information for use
  737. by other objects such as <literal>endpoints</literal> or <literal>registrations</literal>.
  738. This also allows for multiple objects to use a single auth object. See
  739. the <literal>auth_type</literal> config option for password style choices.
  740. </para></description>
  741. <configOption name="auth_type" default="userpass">
  742. <synopsis>Authentication type</synopsis>
  743. <description><para>
  744. This option specifies which of the password style config options should be read
  745. when trying to authenticate an endpoint inbound request. If set to <literal>userpass</literal>
  746. then we'll read from the 'password' option. For <literal>md5</literal> we'll read
  747. from 'md5_cred'.
  748. </para>
  749. <enumlist>
  750. <enum name="md5"/>
  751. <enum name="userpass"/>
  752. </enumlist>
  753. </description>
  754. </configOption>
  755. <configOption name="nonce_lifetime" default="32">
  756. <synopsis>Lifetime of a nonce associated with this authentication config.</synopsis>
  757. </configOption>
  758. <configOption name="md5_cred">
  759. <synopsis>MD5 Hash used for authentication.</synopsis>
  760. <description><para>Only used when auth_type is <literal>md5</literal>.</para></description>
  761. </configOption>
  762. <configOption name="password">
  763. <synopsis>PlainText password used for authentication.</synopsis>
  764. <description><para>Only used when auth_type is <literal>userpass</literal>.</para></description>
  765. </configOption>
  766. <configOption name="realm" default="asterisk">
  767. <synopsis>SIP realm for endpoint</synopsis>
  768. </configOption>
  769. <configOption name="type">
  770. <synopsis>Must be 'auth'</synopsis>
  771. </configOption>
  772. <configOption name="username">
  773. <synopsis>Username to use for account</synopsis>
  774. </configOption>
  775. </configObject>
  776. <configObject name="domain_alias">
  777. <synopsis>Domain Alias</synopsis>
  778. <description><para>
  779. Signifies that a domain is an alias. If the domain on a session is
  780. not found to match an AoR then this object is used to see if we have
  781. an alias for the AoR to which the endpoint is binding. This objects
  782. name as defined in configuration should be the domain alias and a
  783. config option is provided to specify the domain to be aliased.
  784. </para></description>
  785. <configOption name="type">
  786. <synopsis>Must be of type 'domain_alias'.</synopsis>
  787. </configOption>
  788. <configOption name="domain">
  789. <synopsis>Domain to be aliased</synopsis>
  790. </configOption>
  791. </configObject>
  792. <configObject name="transport">
  793. <synopsis>SIP Transport</synopsis>
  794. <description><para>
  795. <emphasis>Transports</emphasis>
  796. </para>
  797. <para>There are different transports and protocol derivatives
  798. supported by <literal>res_pjsip</literal>. They are in order of
  799. preference: UDP, TCP, and WebSocket (WS).</para>
  800. <note><para>Changes to transport configuration in pjsip.conf will only be
  801. effected on a complete restart of Asterisk. A module reload
  802. will not suffice.</para></note>
  803. </description>
  804. <configOption name="async_operations" default="1">
  805. <synopsis>Number of simultaneous Asynchronous Operations</synopsis>
  806. </configOption>
  807. <configOption name="bind">
  808. <synopsis>IP Address and optional port to bind to for this transport</synopsis>
  809. </configOption>
  810. <configOption name="ca_list_file">
  811. <synopsis>File containing a list of certificates to read (TLS ONLY)</synopsis>
  812. </configOption>
  813. <configOption name="cert_file">
  814. <synopsis>Certificate file for endpoint (TLS ONLY)</synopsis>
  815. </configOption>
  816. <configOption name="cipher">
  817. <synopsis>Preferred cryptography cipher names (TLS ONLY)</synopsis>
  818. <description>
  819. <para>Comma separated list of cipher names or numeric equivalents.
  820. Numeric equivalents can be either decimal or hexadecimal (0xX).
  821. </para>
  822. <para>There are many cipher names. Use the CLI command
  823. <literal>pjsip list ciphers</literal> to see a list of cipher
  824. names available for your installation. See link for more:</para>
  825. <para>http://www.openssl.org/docs/apps/ciphers.html#CIPHER_SUITE_NAMES
  826. </para>
  827. </description>
  828. </configOption>
  829. <configOption name="domain">
  830. <synopsis>Domain the transport comes from</synopsis>
  831. </configOption>
  832. <configOption name="external_media_address">
  833. <synopsis>External IP address to use in RTP handling</synopsis>
  834. <description><para>
  835. When a request or response is sent out, if the destination of the
  836. message is outside the IP network defined in the option <literal>localnet</literal>,
  837. and the media address in the SDP is within the localnet network, then the
  838. media address in the SDP will be rewritten to the value defined for
  839. <literal>external_media_address</literal>.
  840. </para></description>
  841. </configOption>
  842. <configOption name="external_signaling_address">
  843. <synopsis>External address for SIP signalling</synopsis>
  844. </configOption>
  845. <configOption name="external_signaling_port" default="0">
  846. <synopsis>External port for SIP signalling</synopsis>
  847. </configOption>
  848. <configOption name="method">
  849. <synopsis>Method of SSL transport (TLS ONLY)</synopsis>
  850. <description>
  851. <enumlist>
  852. <enum name="default" />
  853. <enum name="unspecified" />
  854. <enum name="tlsv1" />
  855. <enum name="sslv2" />
  856. <enum name="sslv3" />
  857. <enum name="sslv23" />
  858. </enumlist>
  859. </description>
  860. </configOption>
  861. <configOption name="local_net">
  862. <synopsis>Network to consider local (used for NAT purposes).</synopsis>
  863. <description><para>This must be in CIDR or dotted decimal format with the IP
  864. and mask separated with a slash ('/').</para></description>
  865. </configOption>
  866. <configOption name="password">
  867. <synopsis>Password required for transport</synopsis>
  868. </configOption>
  869. <configOption name="priv_key_file">
  870. <synopsis>Private key file (TLS ONLY)</synopsis>
  871. </configOption>
  872. <configOption name="protocol" default="udp">
  873. <synopsis>Protocol to use for SIP traffic</synopsis>
  874. <description>
  875. <enumlist>
  876. <enum name="udp" />
  877. <enum name="tcp" />
  878. <enum name="tls" />
  879. <enum name="ws" />
  880. <enum name="wss" />
  881. </enumlist>
  882. </description>
  883. </configOption>
  884. <configOption name="require_client_cert" default="false">
  885. <synopsis>Require client certificate (TLS ONLY)</synopsis>
  886. </configOption>
  887. <configOption name="type">
  888. <synopsis>Must be of type 'transport'.</synopsis>
  889. </configOption>
  890. <configOption name="verify_client" default="false">
  891. <synopsis>Require verification of client certificate (TLS ONLY)</synopsis>
  892. </configOption>
  893. <configOption name="verify_server" default="false">
  894. <synopsis>Require verification of server certificate (TLS ONLY)</synopsis>
  895. </configOption>
  896. <configOption name="tos" default="false">
  897. <synopsis>Enable TOS for the signalling sent over this transport</synopsis>
  898. <description>
  899. <para>See <literal>https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service</literal>
  900. for more information on this parameter.</para>
  901. <note><para>This option does not apply to the <replaceable>ws</replaceable>
  902. or the <replaceable>wss</replaceable> protocols.</para></note>
  903. </description>
  904. </configOption>
  905. <configOption name="cos" default="false">
  906. <synopsis>Enable COS for the signalling sent over this transport</synopsis>
  907. <description>
  908. <para>See <literal>https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service</literal>
  909. for more information on this parameter.</para>
  910. <note><para>This option does not apply to the <replaceable>ws</replaceable>
  911. or the <replaceable>wss</replaceable> protocols.</para></note>
  912. </description>
  913. </configOption>
  914. <configOption name="websocket_write_timeout">
  915. <synopsis>The timeout (in milliseconds) to set on WebSocket connections.</synopsis>
  916. <description>
  917. <para>If a websocket connection accepts input slowly, the timeout
  918. for writes to it can be increased to keep it from being disconnected.
  919. Value is in milliseconds; default is 100 ms.</para>
  920. </description>
  921. </configOption>
  922. </configObject>
  923. <configObject name="contact">
  924. <synopsis>A way of creating an aliased name to a SIP URI</synopsis>
  925. <description><para>
  926. Contacts are a way to hide SIP URIs from the dialplan directly.
  927. They are also used to make a group of contactable parties when
  928. in use with <literal>AoR</literal> lists.
  929. </para></description>
  930. <configOption name="type">
  931. <synopsis>Must be of type 'contact'.</synopsis>
  932. </configOption>
  933. <configOption name="uri">
  934. <synopsis>SIP URI to contact peer</synopsis>
  935. </configOption>
  936. <configOption name="expiration_time">
  937. <synopsis>Time to keep alive a contact</synopsis>
  938. <description><para>
  939. Time to keep alive a contact. String style specification.
  940. </para></description>
  941. </configOption>
  942. <configOption name="qualify_frequency" default="0">
  943. <synopsis>Interval at which to qualify a contact</synopsis>
  944. <description><para>
  945. Interval between attempts to qualify the contact for reachability.
  946. If <literal>0</literal> never qualify. Time in seconds.
  947. </para></description>
  948. </configOption>
  949. <configOption name="outbound_proxy">
  950. <synopsis>Outbound proxy used when sending OPTIONS request</synopsis>
  951. <description><para>
  952. If set the provided URI will be used as the outbound proxy when an
  953. OPTIONS request is sent to a contact for qualify purposes.
  954. </para></description>
  955. </configOption>
  956. <configOption name="path">
  957. <synopsis>Stored Path vector for use in Route headers on outgoing requests.</synopsis>
  958. </configOption>
  959. <configOption name="user_agent">
  960. <synopsis>User-Agent header from registration.</synopsis>
  961. <description><para>
  962. The User-Agent is automatically stored based on data present in incoming SIP
  963. REGISTER requests and is not intended to be configured manually.
  964. </para></description>
  965. </configOption>
  966. </configObject>
  967. <configObject name="aor">
  968. <synopsis>The configuration for a location of an endpoint</synopsis>
  969. <description><para>
  970. An AoR is what allows Asterisk to contact an endpoint via res_pjsip. If no
  971. AoRs are specified, an endpoint will not be reachable by Asterisk.
  972. Beyond that, an AoR has other uses within Asterisk, such as inbound
  973. registration.
  974. </para><para>
  975. An <literal>AoR</literal> is a way to allow dialing a group
  976. of <literal>Contacts</literal> that all use the same
  977. <literal>endpoint</literal> for calls.
  978. </para><para>
  979. This can be used as another way of grouping a list of contacts to dial
  980. rather than specifing them each directly when dialing via the dialplan.
  981. This must be used in conjuction with the <literal>PJSIP_DIAL_CONTACTS</literal>.
  982. </para><para>
  983. Registrations: For Asterisk to match an inbound registration to an endpoint,
  984. the AoR object name must match the user portion of the SIP URI in the "To:"
  985. header of the inbound SIP registration. That will usually be equivalent
  986. to the "user name" set in your hard or soft phones configuration.
  987. </para></description>
  988. <configOption name="contact">
  989. <synopsis>Permanent contacts assigned to AoR</synopsis>
  990. <description><para>
  991. Contacts specified will be called whenever referenced
  992. by <literal>chan_pjsip</literal>.
  993. </para><para>
  994. Use a separate "contact=" entry for each contact required. Contacts
  995. are specified using a SIP URI.
  996. </para></description>
  997. </configOption>
  998. <configOption name="default_expiration" default="3600">
  999. <synopsis>Default expiration time in seconds for contacts that are dynamically bound to an AoR.</synopsis>
  1000. </configOption>
  1001. <configOption name="mailboxes">
  1002. <synopsis>Allow subscriptions for the specified mailbox(es)</synopsis>
  1003. <description><para>This option applies when an external entity subscribes to an AoR
  1004. for Message Waiting Indications. The mailboxes specified will be subscribed to.
  1005. More than one mailbox can be specified with a comma-delimited string.
  1006. app_voicemail mailboxes must be specified as mailbox@context;
  1007. for example: mailboxes=6001@default. For mailboxes provided by external sources,
  1008. such as through the res_external_mwi module, you must specify strings supported by
  1009. the external system.
  1010. </para><para>
  1011. For endpoints that cannot SUBSCRIBE for MWI, you can set the <literal>mailboxes</literal> option in your
  1012. endpoint configuration section to enable unsolicited MWI NOTIFYs to the endpoint.
  1013. </para></description>
  1014. </configOption>
  1015. <configOption name="maximum_expiration" default="7200">
  1016. <synopsis>Maximum time to keep an AoR</synopsis>
  1017. <description><para>
  1018. Maximium time to keep a peer with explicit expiration. Time in seconds.
  1019. </para></description>
  1020. </configOption>
  1021. <configOption name="max_contacts" default="0">
  1022. <synopsis>Maximum number of contacts that can bind to an AoR</synopsis>
  1023. <description><para>
  1024. Maximum number of contacts that can associate with this AoR. This value does
  1025. not affect the number of contacts that can be added with the "contact" option.
  1026. It only limits contacts added through external interaction, such as
  1027. registration.
  1028. </para>
  1029. <note><para>This should be set to <literal>1</literal> and
  1030. <replaceable>remove_existing</replaceable> set to <literal>yes</literal> if you
  1031. wish to stick with the older <literal>chan_sip</literal> behaviour.
  1032. </para></note>
  1033. </description>
  1034. </configOption>
  1035. <configOption name="minimum_expiration" default="60">
  1036. <synopsis>Minimum keep alive time for an AoR</synopsis>
  1037. <description><para>
  1038. Minimum time to keep a peer with an explict expiration. Time in seconds.
  1039. </para></description>
  1040. </configOption>
  1041. <configOption name="remove_existing" default="no">
  1042. <synopsis>Determines whether new contacts replace existing ones.</synopsis>
  1043. <description><para>
  1044. On receiving a new registration to the AoR should it remove
  1045. the existing contact that was registered against it?
  1046. </para>
  1047. <note><para>This should be set to <literal>yes</literal> and
  1048. <replaceable>max_contacts</replaceable> set to <literal>1</literal> if you
  1049. wish to stick with the older <literal>chan_sip</literal> behaviour.
  1050. </para></note>
  1051. </description>
  1052. </configOption>
  1053. <configOption name="type">
  1054. <synopsis>Must be of type 'aor'.</synopsis>
  1055. </configOption>
  1056. <configOption name="qualify_frequency" default="0">
  1057. <synopsis>Interval at which to qualify an AoR</synopsis>
  1058. <description><para>
  1059. Interval between attempts to qualify the AoR for reachability.
  1060. If <literal>0</literal> never qualify. Time in seconds.
  1061. </para></description>
  1062. </configOption>
  1063. <configOption name="authenticate_qualify" default="no">
  1064. <synopsis>Authenticates a qualify request if needed</synopsis>
  1065. <description><para>
  1066. If true and a qualify request receives a challenge or authenticate response
  1067. authentication is attempted before declaring the contact available.
  1068. </para></description>
  1069. </configOption>
  1070. <configOption name="outbound_proxy">
  1071. <synopsis>Outbound proxy used when sending OPTIONS request</synopsis>
  1072. <description><para>
  1073. If set the provided URI will be used as the outbound proxy when an
  1074. OPTIONS request is sent to a contact for qualify purposes.
  1075. </para></description>
  1076. </configOption>
  1077. <configOption name="support_path">
  1078. <synopsis>Enables Path support for REGISTER requests and Route support for other requests.</synopsis>
  1079. <description><para>
  1080. When this option is enabled, the Path headers in register requests will be saved
  1081. and its contents will be used in Route headers for outbound out-of-dialog requests
  1082. and in Path headers for outbound 200 responses. Path support will also be indicated
  1083. in the Supported header.
  1084. </para></description>
  1085. </configOption>
  1086. </configObject>
  1087. <configObject name="system">
  1088. <synopsis>Options that apply to the SIP stack as well as other system-wide settings</synopsis>
  1089. <description><para>
  1090. The settings in this section are global. In addition to being global, the values will
  1091. not be re-evaluated when a reload is performed. This is because the values must be set
  1092. before the SIP stack is initialized. The only way to reset these values is to either
  1093. restart Asterisk, or unload res_pjsip.so and then load it again.
  1094. </para></description>
  1095. <configOption name="timer_t1" default="500">
  1096. <synopsis>Set transaction timer T1 value (milliseconds).</synopsis>
  1097. <description><para>
  1098. Timer T1 is the base for determining how long to wait before retransmitting
  1099. requests that receive no response when using an unreliable transport (e.g. UDP).
  1100. For more information on this timer, see RFC 3261, Section 17.1.1.1.
  1101. </para></description>
  1102. </configOption>
  1103. <configOption name="timer_b" default="32000">
  1104. <synopsis>Set transaction timer B value (milliseconds).</synopsis>
  1105. <description><para>
  1106. Timer B determines the maximum amount of time to wait after sending an INVITE
  1107. request before terminating the transaction. It is recommended that this be set
  1108. to 64 * Timer T1, but it may be set higher if desired. For more information on
  1109. this timer, see RFC 3261, Section 17.1.1.1.
  1110. </para></description>
  1111. </configOption>
  1112. <configOption name="compact_headers" default="no">
  1113. <synopsis>Use the short forms of common SIP header names.</synopsis>
  1114. </configOption>
  1115. <configOption name="threadpool_initial_size" default="0">
  1116. <synopsis>Initial number of threads in the res_pjsip threadpool.</synopsis>
  1117. </configOption>
  1118. <configOption name="threadpool_auto_increment" default="5">
  1119. <synopsis>The amount by which the number of threads is incremented when necessary.</synopsis>
  1120. </configOption>
  1121. <configOption name="threadpool_idle_timeout" default="60">
  1122. <synopsis>Number of seconds before an idle thread should be disposed of.</synopsis>
  1123. </configOption>
  1124. <configOption name="threadpool_max_size" default="0">
  1125. <synopsis>Maximum number of threads in the res_pjsip threadpool.
  1126. A value of 0 indicates no maximum.</synopsis>
  1127. </configOption>
  1128. <configOption name="type">
  1129. <synopsis>Must be of type 'system'.</synopsis>
  1130. </configOption>
  1131. </configObject>
  1132. <configObject name="global">
  1133. <synopsis>Options that apply globally to all SIP communications</synopsis>
  1134. <description><para>
  1135. The settings in this section are global. Unlike options in the <literal>system</literal>
  1136. section, these options can be refreshed by performing a reload.
  1137. </para></description>
  1138. <configOption name="max_forwards" default="70">
  1139. <synopsis>Value used in Max-Forwards header for SIP requests.</synopsis>
  1140. </configOption>
  1141. <configOption name="type">
  1142. <synopsis>Must be of type 'global'.</synopsis>
  1143. </configOption>
  1144. <configOption name="user_agent" default="Asterisk &lt;Asterisk Version&gt;">
  1145. <synopsis>Value used in User-Agent header for SIP requests and Server header for SIP responses.</synopsis>
  1146. </configOption>
  1147. <configOption name="default_outbound_endpoint" default="default_outbound_endpoint">
  1148. <synopsis>Endpoint to use when sending an outbound request to a URI without a specified endpoint.</synopsis>
  1149. </configOption>
  1150. <configOption name="debug" default="no">
  1151. <synopsis>Enable/Disable SIP debug logging. Valid options include yes|no or
  1152. a host address</synopsis>
  1153. </configOption>
  1154. </configObject>
  1155. </configFile>
  1156. </configInfo>
  1157. <manager name="PJSIPQualify" language="en_US">
  1158. <synopsis>
  1159. Qualify a chan_pjsip endpoint.
  1160. </synopsis>
  1161. <syntax>
  1162. <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
  1163. <parameter name="Endpoint" required="true">
  1164. <para>The endpoint you want to qualify.</para>
  1165. </parameter>
  1166. </syntax>
  1167. <description>
  1168. <para>Qualify a chan_pjsip endpoint.</para>
  1169. </description>
  1170. </manager>
  1171. <managerEvent language="en_US" name="IdentifyDetail">
  1172. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1173. <synopsis>Provide details about an identify section.</synopsis>
  1174. <syntax>
  1175. <parameter name="ObjectType">
  1176. <para>The object's type. This will always be 'identify'.</para>
  1177. </parameter>
  1178. <parameter name="ObjectName">
  1179. <para>The name of this object.</para>
  1180. </parameter>
  1181. <parameter name="Endpoint">
  1182. <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>
  1183. </parameter>
  1184. <parameter name="Match">
  1185. <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>
  1186. </parameter>
  1187. <parameter name="EndpointName">
  1188. <para>The name of the endpoint associated with this information.</para>
  1189. </parameter>
  1190. </syntax>
  1191. </managerEventInstance>
  1192. </managerEvent>
  1193. <managerEvent language="en_US" name="AorDetail">
  1194. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1195. <synopsis>Provide details about an Address of Record (AoR) section.</synopsis>
  1196. <syntax>
  1197. <parameter name="ObjectType">
  1198. <para>The object's type. This will always be 'aor'.</para>
  1199. </parameter>
  1200. <parameter name="ObjectName">
  1201. <para>The name of this object.</para>
  1202. </parameter>
  1203. <parameter name="MinimumExpiration">
  1204. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='minimum_expiration']/synopsis/node())"/></para>
  1205. </parameter>
  1206. <parameter name="MaximumExpiration">
  1207. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='maximum_expiration']/synopsis/node())"/></para>
  1208. </parameter>
  1209. <parameter name="DefaultExpiration">
  1210. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='default_expiration']/synopsis/node())"/></para>
  1211. </parameter>
  1212. <parameter name="QualifyFrequency">
  1213. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='qualify_frequency']/synopsis/node())"/></para>
  1214. </parameter>
  1215. <parameter name="AuthenticateQualify">
  1216. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='authenticate_qualify']/synopsis/node())"/></para>
  1217. </parameter>
  1218. <parameter name="MaxContacts">
  1219. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='max_contacts']/synopsis/node())"/></para>
  1220. </parameter>
  1221. <parameter name="RemoveExisting">
  1222. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='remove_existing']/synopsis/node())"/></para>
  1223. </parameter>
  1224. <parameter name="Mailboxes">
  1225. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='mailboxes']/synopsis/node())"/></para>
  1226. </parameter>
  1227. <parameter name="OutboundProxy">
  1228. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='outbound_proxy']/synopsis/node())"/></para>
  1229. </parameter>
  1230. <parameter name="SupportPath">
  1231. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='support_path']/synopsis/node())"/></para>
  1232. </parameter>
  1233. <parameter name="TotalContacts">
  1234. <para>The total number of contacts associated with this AoR.</para>
  1235. </parameter>
  1236. <parameter name="ContactsRegistered">
  1237. <para>The number of non-permanent contacts associated with this AoR.</para>
  1238. </parameter>
  1239. <parameter name="EndpointName">
  1240. <para>The name of the endpoint associated with this information.</para>
  1241. </parameter>
  1242. </syntax>
  1243. </managerEventInstance>
  1244. </managerEvent>
  1245. <managerEvent language="en_US" name="AuthDetail">
  1246. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1247. <synopsis>Provide details about an authentication section.</synopsis>
  1248. <syntax>
  1249. <parameter name="ObjectType">
  1250. <para>The object's type. This will always be 'auth'.</para>
  1251. </parameter>
  1252. <parameter name="ObjectName">
  1253. <para>The name of this object.</para>
  1254. </parameter>
  1255. <parameter name="Username">
  1256. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='username']/synopsis/node())"/></para>
  1257. </parameter>
  1258. <parameter name="Password">
  1259. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='username']/synopsis/node())"/></para>
  1260. </parameter>
  1261. <parameter name="Md5Cred">
  1262. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='md5_cred']/synopsis/node())"/></para>
  1263. </parameter>
  1264. <parameter name="Realm">
  1265. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='realm']/synopsis/node())"/></para>
  1266. </parameter>
  1267. <parameter name="NonceLifetime">
  1268. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='nonce_lifetime']/synopsis/node())"/></para>
  1269. </parameter>
  1270. <parameter name="AuthType">
  1271. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='auth_type']/synopsis/node())"/></para>
  1272. </parameter>
  1273. <parameter name="EndpointName">
  1274. <para>The name of the endpoint associated with this information.</para>
  1275. </parameter>
  1276. </syntax>
  1277. </managerEventInstance>
  1278. </managerEvent>
  1279. <managerEvent language="en_US" name="TransportDetail">
  1280. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1281. <synopsis>Provide details about an authentication section.</synopsis>
  1282. <syntax>
  1283. <parameter name="ObjectType">
  1284. <para>The object's type. This will always be 'transport'.</para>
  1285. </parameter>
  1286. <parameter name="ObjectName">
  1287. <para>The name of this object.</para>
  1288. </parameter>
  1289. <parameter name="Protocol">
  1290. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='protocol']/synopsis/node())"/></para>
  1291. </parameter>
  1292. <parameter name="Bind">
  1293. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='bind']/synopsis/node())"/></para>
  1294. </parameter>
  1295. <parameter name="AsycOperations">
  1296. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='async_operations']/synopsis/node())"/></para>
  1297. </parameter>
  1298. <parameter name="CaListFile">
  1299. <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>
  1300. </parameter>
  1301. <parameter name="CertFile">
  1302. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='cert_file']/synopsis/node())"/></para>
  1303. </parameter>
  1304. <parameter name="PrivKeyFile">
  1305. <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>
  1306. </parameter>
  1307. <parameter name="Password">
  1308. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='password']/synopsis/node())"/></para>
  1309. </parameter>
  1310. <parameter name="ExternalSignalingAddress">
  1311. <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>
  1312. </parameter>
  1313. <parameter name="ExternalSignalingPort">
  1314. <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>
  1315. </parameter>
  1316. <parameter name="ExternalMediaAddress">
  1317. <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>
  1318. </parameter>
  1319. <parameter name="Domain">
  1320. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='domain']/synopsis/node())"/></para>
  1321. </parameter>
  1322. <parameter name="VerifyServer">
  1323. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='verify_server']/synopsis/node())"/></para>
  1324. </parameter>
  1325. <parameter name="VerifyClient">
  1326. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='verify_client']/synopsis/node())"/></para>
  1327. </parameter>
  1328. <parameter name="RequireClientCert">
  1329. <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>
  1330. </parameter>
  1331. <parameter name="Method">
  1332. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='method']/synopsis/node())"/></para>
  1333. </parameter>
  1334. <parameter name="Cipher">
  1335. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='cipher']/synopsis/node())"/></para>
  1336. </parameter>
  1337. <parameter name="LocalNet">
  1338. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='local_net']/synopsis/node())"/></para>
  1339. </parameter>
  1340. <parameter name="Tos">
  1341. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='tos']/synopsis/node())"/></para>
  1342. </parameter>
  1343. <parameter name="Cos">
  1344. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='cos']/synopsis/node())"/></para>
  1345. </parameter>
  1346. <parameter name="WebsocketWriteTimeout">
  1347. <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>
  1348. </parameter>
  1349. <parameter name="EndpointName">
  1350. <para>The name of the endpoint associated with this information.</para>
  1351. </parameter>
  1352. </syntax>
  1353. </managerEventInstance>
  1354. </managerEvent>
  1355. <managerEvent language="en_US" name="EndpointDetail">
  1356. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1357. <synopsis>Provide details about an endpoint section.</synopsis>
  1358. <syntax>
  1359. <parameter name="ObjectType">
  1360. <para>The object's type. This will always be 'endpoint'.</para>
  1361. </parameter>
  1362. <parameter name="ObjectName">
  1363. <para>The name of this object.</para>
  1364. </parameter>
  1365. <parameter name="Context">
  1366. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='context']/synopsis/node())"/></para>
  1367. </parameter>
  1368. <parameter name="Disallow">
  1369. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='disallow']/synopsis/node())"/></para>
  1370. </parameter>
  1371. <parameter name="Allow">
  1372. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow']/synopsis/node())"/></para>
  1373. </parameter>
  1374. <parameter name="DtmfMode">
  1375. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtmf_mode']/synopsis/node())"/></para>
  1376. </parameter>
  1377. <parameter name="RtpIpv6">
  1378. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rtp_ipv6']/synopsis/node())"/></para>
  1379. </parameter>
  1380. <parameter name="RtpSymmetric">
  1381. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rtp_symmetric']/synopsis/node())"/></para>
  1382. </parameter>
  1383. <parameter name="IceSupport">
  1384. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='ice_support']/synopsis/node())"/></para>
  1385. </parameter>
  1386. <parameter name="UsePtime">
  1387. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='use_ptime']/synopsis/node())"/></para>
  1388. </parameter>
  1389. <parameter name="ForceRport">
  1390. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='force_rport']/synopsis/node())"/></para>
  1391. </parameter>
  1392. <parameter name="RewriteContact">
  1393. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rewrite_contact']/synopsis/node())"/></para>
  1394. </parameter>
  1395. <parameter name="Transport">
  1396. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='transport']/synopsis/node())"/></para>
  1397. </parameter>
  1398. <parameter name="OutboundProxy">
  1399. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='outbound_proxy']/synopsis/node())"/></para>
  1400. </parameter>
  1401. <parameter name="MohSuggest">
  1402. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='moh_suggest']/synopsis/node())"/></para>
  1403. </parameter>
  1404. <parameter name="100rel">
  1405. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='100rel']/synopsis/node())"/></para>
  1406. </parameter>
  1407. <parameter name="Timers">
  1408. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='timers']/synopsis/node())"/></para>
  1409. </parameter>
  1410. <parameter name="TimersMinSe">
  1411. <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>
  1412. </parameter>
  1413. <parameter name="TimersSessExpires">
  1414. <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>
  1415. </parameter>
  1416. <parameter name="Auth">
  1417. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='auth']/synopsis/node())"/></para>
  1418. </parameter>
  1419. <parameter name="OutboundAuth">
  1420. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='outbound_auth']/synopsis/node())"/></para>
  1421. </parameter>
  1422. <parameter name="Aors">
  1423. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='aors']/synopsis/node())"/></para>
  1424. </parameter>
  1425. <parameter name="MediaAddress">
  1426. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='media_address']/synopsis/node())"/></para>
  1427. </parameter>
  1428. <parameter name="IdentifyBy">
  1429. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='identify_by']/synopsis/node())"/></para>
  1430. </parameter>
  1431. <parameter name="DirectMedia">
  1432. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='direct_media']/synopsis/node())"/></para>
  1433. </parameter>
  1434. <parameter name="DirectMediaMethod">
  1435. <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>
  1436. </parameter>
  1437. <parameter name="ConnectedLineMethod">
  1438. <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>
  1439. </parameter>
  1440. <parameter name="DirectMediaGlareMitigation">
  1441. <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>
  1442. </parameter>
  1443. <parameter name="DisableDirectMediaOnNat">
  1444. <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>
  1445. </parameter>
  1446. <parameter name="Callerid">
  1447. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='callerid']/synopsis/node())"/></para>
  1448. </parameter>
  1449. <parameter name="CalleridPrivacy">
  1450. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='callerid_privacy']/synopsis/node())"/></para>
  1451. </parameter>
  1452. <parameter name="CalleridTag">
  1453. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='callerid_tag']/synopsis/node())"/></para>
  1454. </parameter>
  1455. <parameter name="TrustIdInbound">
  1456. <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>
  1457. </parameter>
  1458. <parameter name="TrustIdOutbound">
  1459. <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>
  1460. </parameter>
  1461. <parameter name="SendPai">
  1462. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_pai']/synopsis/node())"/></para>
  1463. </parameter>
  1464. <parameter name="SendRpid">
  1465. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_rpid']/synopsis/node())"/></para>
  1466. </parameter>
  1467. <parameter name="SendDiversion">
  1468. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_diversion']/synopsis/node())"/></para>
  1469. </parameter>
  1470. <parameter name="Mailboxes">
  1471. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='mailboxes']/synopsis/node())"/></para>
  1472. </parameter>
  1473. <parameter name="AggregateMwi">
  1474. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='aggregate_mwi']/synopsis/node())"/></para>
  1475. </parameter>
  1476. <parameter name="MediaEncryption">
  1477. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='media_encryption']/synopsis/node())"/></para>
  1478. </parameter>
  1479. <parameter name="UseAvpf">
  1480. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='use_avpf']/synopsis/node())"/></para>
  1481. </parameter>
  1482. <parameter name="ForceAvp">
  1483. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='force_avp']/synopsis/node())"/></para>
  1484. </parameter>
  1485. <parameter name="MediaUseReceivedTransport">
  1486. <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>
  1487. </parameter>
  1488. <parameter name="OneTouchRecording">
  1489. <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>
  1490. </parameter>
  1491. <parameter name="InbandProgress">
  1492. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='inband_progress']/synopsis/node())"/></para>
  1493. </parameter>
  1494. <parameter name="CallGroup">
  1495. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='call_group']/synopsis/node())"/></para>
  1496. </parameter>
  1497. <parameter name="PickupGroup">
  1498. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='pickup_group']/synopsis/node())"/></para>
  1499. </parameter>
  1500. <parameter name="NamedCallGroup">
  1501. <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>
  1502. </parameter>
  1503. <parameter name="NamedPickupGroup">
  1504. <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>
  1505. </parameter>
  1506. <parameter name="DeviceStateBusyAt">
  1507. <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>
  1508. </parameter>
  1509. <parameter name="T38Udptl">
  1510. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='t38_udptl']/synopsis/node())"/></para>
  1511. </parameter>
  1512. <parameter name="T38UdptlEc">
  1513. <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>
  1514. </parameter>
  1515. <parameter name="T38UdptlMaxdatagram">
  1516. <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>
  1517. </parameter>
  1518. <parameter name="FaxDetect">
  1519. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='fax_detect']/synopsis/node())"/></para>
  1520. </parameter>
  1521. <parameter name="T38UdptlNat">
  1522. <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>
  1523. </parameter>
  1524. <parameter name="T38UdptlIpv6">
  1525. <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>
  1526. </parameter>
  1527. <parameter name="ToneZone">
  1528. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='tone_zone']/synopsis/node())"/></para>
  1529. </parameter>
  1530. <parameter name="Language">
  1531. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='language']/synopsis/node())"/></para>
  1532. </parameter>
  1533. <parameter name="RecordOnFeature">
  1534. <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>
  1535. </parameter>
  1536. <parameter name="RecordOffFeature">
  1537. <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>
  1538. </parameter>
  1539. <parameter name="AllowTransfer">
  1540. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow_transfer']/synopsis/node())"/></para>
  1541. </parameter>
  1542. <parameter name="SdpOwner">
  1543. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='sdp_owner']/synopsis/node())"/></para>
  1544. </parameter>
  1545. <parameter name="SdpSession">
  1546. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='sdp_session']/synopsis/node())"/></para>
  1547. </parameter>
  1548. <parameter name="TosAudio">
  1549. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='tos_audio']/synopsis/node())"/></para>
  1550. </parameter>
  1551. <parameter name="TosVideo">
  1552. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='tos_video']/synopsis/node())"/></para>
  1553. </parameter>
  1554. <parameter name="CosAudio">
  1555. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='cos_audio']/synopsis/node())"/></para>
  1556. </parameter>
  1557. <parameter name="CosVideo">
  1558. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='cos_video']/synopsis/node())"/></para>
  1559. </parameter>
  1560. <parameter name="AllowSubscribe">
  1561. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow_subscribe']/synopsis/node())"/></para>
  1562. </parameter>
  1563. <parameter name="SubMinExpiry">
  1564. <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>
  1565. </parameter>
  1566. <parameter name="FromUser">
  1567. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='from_user']/synopsis/node())"/></para>
  1568. </parameter>
  1569. <parameter name="FromDomain">
  1570. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='from_domain']/synopsis/node())"/></para>
  1571. </parameter>
  1572. <parameter name="MwiFromUser">
  1573. <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>
  1574. </parameter>
  1575. <parameter name="RtpEngine">
  1576. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rtp_engine']/synopsis/node())"/></para>
  1577. </parameter>
  1578. <parameter name="DtlsVerify">
  1579. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_verify']/synopsis/node())"/></para>
  1580. </parameter>
  1581. <parameter name="DtlsRekey">
  1582. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_rekey']/synopsis/node())"/></para>
  1583. </parameter>
  1584. <parameter name="DtlsCertFile">
  1585. <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>
  1586. </parameter>
  1587. <parameter name="DtlsPrivateKey">
  1588. <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>
  1589. </parameter>
  1590. <parameter name="DtlsCipher">
  1591. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_cipher']/synopsis/node())"/></para>
  1592. </parameter>
  1593. <parameter name="DtlsCaFile">
  1594. <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>
  1595. </parameter>
  1596. <parameter name="DtlsCaPath">
  1597. <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>
  1598. </parameter>
  1599. <parameter name="DtlsSetup">
  1600. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_setup']/synopsis/node())"/></para>
  1601. </parameter>
  1602. <parameter name="SrtpTag32">
  1603. <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>
  1604. </parameter>
  1605. <parameter name="RedirectMethod">
  1606. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='redirect_method']/synopsis/node())"/></para>
  1607. </parameter>
  1608. <parameter name="SetVar">
  1609. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='set_var']/synopsis/node())"/></para>
  1610. </parameter>
  1611. <parameter name="MessageContext">
  1612. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='message_context']/synopsis/node())"/></para>
  1613. </parameter>
  1614. <parameter name="Accountcode">
  1615. <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='accountcode']/synopsis/node())"/></para>
  1616. </parameter>
  1617. <parameter name="DeviceState">
  1618. <para>The aggregate device state for this endpoint.</para>
  1619. </parameter>
  1620. <parameter name="ActiveChannels">
  1621. <para>The number of active channels associated with this endpoint.</para>
  1622. </parameter>
  1623. </syntax>
  1624. </managerEventInstance>
  1625. </managerEvent>
  1626. <managerEvent language="en_US" name="ContactStatusDetail">
  1627. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1628. <synopsis>Provide details about a contact's status.</synopsis>
  1629. <syntax>
  1630. <parameter name="AOR">
  1631. <para>The AoR that owns this contact.</para>
  1632. </parameter>
  1633. <parameter name="URI">
  1634. <para>This contact's URI.</para>
  1635. </parameter>
  1636. <parameter name="Status">
  1637. <para>This contact's status.</para>
  1638. <enumlist>
  1639. <enum name="Reachable"/>
  1640. <enum name="Unreachable"/>
  1641. </enumlist>
  1642. </parameter>
  1643. <parameter name="RoundtripUsec">
  1644. <para>The round trip time in microseconds.</para>
  1645. </parameter>
  1646. <parameter name="EndpointName">
  1647. <para>The name of the endpoint associated with this information.</para>
  1648. </parameter>
  1649. </syntax>
  1650. </managerEventInstance>
  1651. </managerEvent>
  1652. <managerEvent language="en_US" name="EndpointList">
  1653. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1654. <synopsis>Provide details about a contact's status.</synopsis>
  1655. <syntax>
  1656. <parameter name="ObjectType">
  1657. <para>The object's type. This will always be 'endpoint'.</para>
  1658. </parameter>
  1659. <parameter name="ObjectName">
  1660. <para>The name of this object.</para>
  1661. </parameter>
  1662. <parameter name="Transport">
  1663. <para>The transport configurations associated with this endpoint.</para>
  1664. </parameter>
  1665. <parameter name="Aor">
  1666. <para>The aor configurations associated with this endpoint.</para>
  1667. </parameter>
  1668. <parameter name="Auths">
  1669. <para>The inbound authentication configurations associated with this endpoint.</para>
  1670. </parameter>
  1671. <parameter name="OutboundAuths">
  1672. <para>The outbound authentication configurations associated with this endpoint.</para>
  1673. </parameter>
  1674. <parameter name="DeviceState">
  1675. <para>The aggregate device state for this endpoint.</para>
  1676. </parameter>
  1677. <parameter name="ActiveChannels">
  1678. <para>The number of active channels associated with this endpoint.</para>
  1679. </parameter>
  1680. </syntax>
  1681. </managerEventInstance>
  1682. </managerEvent>
  1683. <manager name="PJSIPShowEndpoints" language="en_US">
  1684. <synopsis>
  1685. Lists PJSIP endpoints.
  1686. </synopsis>
  1687. <syntax />
  1688. <description>
  1689. <para>
  1690. Provides a listing of all endpoints. For each endpoint an <literal>EndpointList</literal> event
  1691. is raised that contains relevant attributes and status information. Once all
  1692. endpoints have been listed an <literal>EndpointListComplete</literal> event is issued.
  1693. </para>
  1694. </description>
  1695. <responses>
  1696. <list-elements>
  1697. <xi:include xpointer="xpointer(/docs/managerEvent[@name='EndpointList'])" />
  1698. </list-elements>
  1699. <managerEvent language="en_US" name="EndpointListComplete">
  1700. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1701. <synopsis>Provide final information about an endpoint list.</synopsis>
  1702. <syntax>
  1703. <parameter name="EventList"/>
  1704. <parameter name="ListItems"/>
  1705. </syntax>
  1706. </managerEventInstance>
  1707. </managerEvent>
  1708. </responses>
  1709. </manager>
  1710. <manager name="PJSIPShowEndpoint" language="en_US">
  1711. <synopsis>
  1712. Detail listing of an endpoint and its objects.
  1713. </synopsis>
  1714. <syntax>
  1715. <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
  1716. <parameter name="Endpoint" required="true">
  1717. <para>The endpoint to list.</para>
  1718. </parameter>
  1719. </syntax>
  1720. <description>
  1721. <para>
  1722. Provides a detailed listing of options for a given endpoint. Events are issued
  1723. showing the configuration and status of the endpoint and associated objects. These
  1724. events include <literal>EndpointDetail</literal>, <literal>AorDetail</literal>,
  1725. <literal>AuthDetail</literal>, <literal>TransportDetail</literal>, and
  1726. <literal>IdentifyDetail</literal>. Some events may be listed multiple times if multiple objects are
  1727. associated (for instance AoRs). Once all detail events have been raised a final
  1728. <literal>EndpointDetailComplete</literal> event is issued.
  1729. </para>
  1730. </description>
  1731. <responses>
  1732. <list-elements>
  1733. <xi:include xpointer="xpointer(/docs/managerEvent[@name='EndpointDetail'])" />
  1734. <xi:include xpointer="xpointer(/docs/managerEvent[@name='IdentifyDetail'])" />
  1735. <xi:include xpointer="xpointer(/docs/managerEvent[@name='ContactStatusDetail'])" />
  1736. <xi:include xpointer="xpointer(/docs/managerEvent[@name='AuthDetail'])" />
  1737. <xi:include xpointer="xpointer(/docs/managerEvent[@name='TransportDetail'])" />
  1738. <xi:include xpointer="xpointer(/docs/managerEvent[@name='AorDetail'])" />
  1739. </list-elements>
  1740. <managerEvent language="en_US" name="EndpointDetailComplete">
  1741. <managerEventInstance class="EVENT_FLAG_COMMAND">
  1742. <synopsis>Provide final information about endpoint details.</synopsis>
  1743. <syntax>
  1744. <parameter name="EventList"/>
  1745. <parameter name="ListItems"/>
  1746. </syntax>
  1747. </managerEventInstance>
  1748. </managerEvent>
  1749. </responses>
  1750. </manager>
  1751. ***/
  1752. #define MOD_DATA_CONTACT "contact"
  1753. static pjsip_endpoint *ast_pjsip_endpoint;
  1754. static struct ast_threadpool *sip_threadpool;
  1755. static int register_service(void *data)
  1756. {
  1757. pjsip_module **module = data;
  1758. if (!ast_pjsip_endpoint) {
  1759. ast_log(LOG_ERROR, "There is no PJSIP endpoint. Unable to register services\n");
  1760. return -1;
  1761. }
  1762. if (pjsip_endpt_register_module(ast_pjsip_endpoint, *module) != PJ_SUCCESS) {
  1763. ast_log(LOG_ERROR, "Unable to register module %.*s\n", (int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name));
  1764. return -1;
  1765. }
  1766. ast_debug(1, "Registered SIP service %.*s (%p)\n", (int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name), *module);
  1767. ast_module_ref(ast_module_info->self);
  1768. return 0;
  1769. }
  1770. int ast_sip_register_service(pjsip_module *module)
  1771. {
  1772. return ast_sip_push_task_synchronous(NULL, register_service, &module);
  1773. }
  1774. static int unregister_service(void *data)
  1775. {
  1776. pjsip_module **module = data;
  1777. ast_module_unref(ast_module_info->self);
  1778. if (!ast_pjsip_endpoint) {
  1779. return -1;
  1780. }
  1781. pjsip_endpt_unregister_module(ast_pjsip_endpoint, *module);
  1782. ast_debug(1, "Unregistered SIP service %.*s\n", (int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name));
  1783. return 0;
  1784. }
  1785. void ast_sip_unregister_service(pjsip_module *module)
  1786. {
  1787. ast_sip_push_task_synchronous(NULL, unregister_service, &module);
  1788. }
  1789. static struct ast_sip_authenticator *registered_authenticator;
  1790. int ast_sip_register_authenticator(struct ast_sip_authenticator *auth)
  1791. {
  1792. if (registered_authenticator) {
  1793. ast_log(LOG_WARNING, "Authenticator %p is already registered. Cannot register a new one\n", registered_authenticator);
  1794. return -1;
  1795. }
  1796. registered_authenticator = auth;
  1797. ast_debug(1, "Registered SIP authenticator module %p\n", auth);
  1798. ast_module_ref(ast_module_info->self);
  1799. return 0;
  1800. }
  1801. void ast_sip_unregister_authenticator(struct ast_sip_authenticator *auth)
  1802. {
  1803. if (registered_authenticator != auth) {
  1804. ast_log(LOG_WARNING, "Trying to unregister authenticator %p but authenticator %p registered\n",
  1805. auth, registered_authenticator);
  1806. return;
  1807. }
  1808. registered_authenticator = NULL;
  1809. ast_debug(1, "Unregistered SIP authenticator %p\n", auth);
  1810. ast_module_unref(ast_module_info->self);
  1811. }
  1812. int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
  1813. {
  1814. if (!registered_authenticator) {
  1815. ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is not required\n");
  1816. return 0;
  1817. }
  1818. return registered_authenticator->requires_authentication(endpoint, rdata);
  1819. }
  1820. enum ast_sip_check_auth_result ast_sip_check_authentication(struct ast_sip_endpoint *endpoint,
  1821. pjsip_rx_data *rdata, pjsip_tx_data *tdata)
  1822. {
  1823. if (!registered_authenticator) {
  1824. ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is successful\n");
  1825. return 0;
  1826. }
  1827. return registered_authenticator->check_authentication(endpoint, rdata, tdata);
  1828. }
  1829. static struct ast_sip_outbound_authenticator *registered_outbound_authenticator;
  1830. int ast_sip_register_outbound_authenticator(struct ast_sip_outbound_authenticator *auth)
  1831. {
  1832. if (registered_outbound_authenticator) {
  1833. ast_log(LOG_WARNING, "Outbound authenticator %p is already registered. Cannot register a new one\n", registered_outbound_authenticator);
  1834. return -1;
  1835. }
  1836. registered_outbound_authenticator = auth;
  1837. ast_debug(1, "Registered SIP outbound authenticator module %p\n", auth);
  1838. ast_module_ref(ast_module_info->self);
  1839. return 0;
  1840. }
  1841. void ast_sip_unregister_outbound_authenticator(struct ast_sip_outbound_authenticator *auth)
  1842. {
  1843. if (registered_outbound_authenticator != auth) {
  1844. ast_log(LOG_WARNING, "Trying to unregister outbound authenticator %p but outbound authenticator %p registered\n",
  1845. auth, registered_outbound_authenticator);
  1846. return;
  1847. }
  1848. registered_outbound_authenticator = NULL;
  1849. ast_debug(1, "Unregistered SIP outbound authenticator %p\n", auth);
  1850. ast_module_unref(ast_module_info->self);
  1851. }
  1852. int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge,
  1853. pjsip_transaction *tsx, pjsip_tx_data **new_request)
  1854. {
  1855. if (!registered_outbound_authenticator) {
  1856. ast_log(LOG_WARNING, "No SIP outbound authenticator registered. Cannot respond to authentication challenge\n");
  1857. return -1;
  1858. }
  1859. return registered_outbound_authenticator->create_request_with_auth(auths, challenge, tsx, new_request);
  1860. }
  1861. struct endpoint_identifier_list {
  1862. struct ast_sip_endpoint_identifier *identifier;
  1863. AST_RWLIST_ENTRY(endpoint_identifier_list) list;
  1864. };
  1865. static AST_RWLIST_HEAD_STATIC(endpoint_identifiers, endpoint_identifier_list);
  1866. int ast_sip_register_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
  1867. {
  1868. struct endpoint_identifier_list *id_list_item;
  1869. SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  1870. id_list_item = ast_calloc(1, sizeof(*id_list_item));
  1871. if (!id_list_item) {
  1872. ast_log(LOG_ERROR, "Unabled to add endpoint identifier. Out of memory.\n");
  1873. return -1;
  1874. }
  1875. id_list_item->identifier = identifier;
  1876. AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
  1877. ast_debug(1, "Registered endpoint identifier %p\n", identifier);
  1878. ast_module_ref(ast_module_info->self);
  1879. return 0;
  1880. }
  1881. void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
  1882. {
  1883. struct endpoint_identifier_list *iter;
  1884. SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  1885. AST_RWLIST_TRAVERSE_SAFE_BEGIN(&endpoint_identifiers, iter, list) {
  1886. if (iter->identifier == identifier) {
  1887. AST_RWLIST_REMOVE_CURRENT(list);
  1888. ast_free(iter);
  1889. ast_debug(1, "Unregistered endpoint identifier %p\n", identifier);
  1890. ast_module_unref(ast_module_info->self);
  1891. break;
  1892. }
  1893. }
  1894. AST_RWLIST_TRAVERSE_SAFE_END;
  1895. }
  1896. struct ast_sip_endpoint *ast_sip_identify_endpoint(pjsip_rx_data *rdata)
  1897. {
  1898. struct endpoint_identifier_list *iter;
  1899. struct ast_sip_endpoint *endpoint = NULL;
  1900. SCOPED_LOCK(lock, &endpoint_identifiers, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
  1901. AST_RWLIST_TRAVERSE(&endpoint_identifiers, iter, list) {
  1902. ast_assert(iter->identifier->identify_endpoint != NULL);
  1903. endpoint = iter->identifier->identify_endpoint(rdata);
  1904. if (endpoint) {
  1905. break;
  1906. }
  1907. }
  1908. return endpoint;
  1909. }
  1910. AST_RWLIST_HEAD_STATIC(endpoint_formatters, ast_sip_endpoint_formatter);
  1911. int ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
  1912. {
  1913. SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  1914. AST_RWLIST_INSERT_TAIL(&endpoint_formatters, obj, next);
  1915. ast_module_ref(ast_module_info->self);
  1916. return 0;
  1917. }
  1918. void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
  1919. {
  1920. struct ast_sip_endpoint_formatter *i;
  1921. SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  1922. AST_RWLIST_TRAVERSE_SAFE_BEGIN(&endpoint_formatters, i, next) {
  1923. if (i == obj) {
  1924. AST_RWLIST_REMOVE_CURRENT(next);
  1925. ast_module_unref(ast_module_info->self);
  1926. break;
  1927. }
  1928. }
  1929. AST_RWLIST_TRAVERSE_SAFE_END;
  1930. }
  1931. int ast_sip_format_endpoint_ami(struct ast_sip_endpoint *endpoint,
  1932. struct ast_sip_ami *ami, int *count)
  1933. {
  1934. int res = 0;
  1935. struct ast_sip_endpoint_formatter *i;
  1936. SCOPED_LOCK(lock, &endpoint_formatters, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK);
  1937. *count = 0;
  1938. AST_RWLIST_TRAVERSE(&endpoint_formatters, i, next) {
  1939. if (i->format_ami && ((res = i->format_ami(endpoint, ami)) < 0)) {
  1940. return res;
  1941. }
  1942. if (!res) {
  1943. (*count)++;
  1944. }
  1945. }
  1946. return 0;
  1947. }
  1948. pjsip_endpoint *ast_sip_get_pjsip_endpoint(void)
  1949. {
  1950. return ast_pjsip_endpoint;
  1951. }
  1952. static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *user, const char *domain, const pj_str_t *target, pjsip_tpselector *selector)
  1953. {
  1954. pj_str_t tmp, local_addr;
  1955. pjsip_uri *uri;
  1956. pjsip_sip_uri *sip_uri;
  1957. pjsip_transport_type_e type = PJSIP_TRANSPORT_UNSPECIFIED;
  1958. int local_port;
  1959. char uuid_str[AST_UUID_STR_LEN];
  1960. if (ast_strlen_zero(user)) {
  1961. user = ast_uuid_generate_str(uuid_str, sizeof(uuid_str));
  1962. }
  1963. /* Parse the provided target URI so we can determine what transport it will end up using */
  1964. pj_strdup_with_null(pool, &tmp, target);
  1965. if (!(uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0)) ||
  1966. (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
  1967. return -1;
  1968. }
  1969. sip_uri = pjsip_uri_get_uri(uri);
  1970. /* Determine the transport type to use */
  1971. if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) {
  1972. type = PJSIP_TRANSPORT_TLS;
  1973. } else if (!sip_uri->transport_param.slen) {
  1974. type = PJSIP_TRANSPORT_UDP;
  1975. } else {
  1976. type = pjsip_transport_get_type_from_name(&sip_uri->transport_param);
  1977. }
  1978. if (type == PJSIP_TRANSPORT_UNSPECIFIED) {
  1979. return -1;
  1980. }
  1981. /* If the host is IPv6 turn the transport into an IPv6 version */
  1982. if (pj_strchr(&sip_uri->host, ':') && type < PJSIP_TRANSPORT_START_OTHER) {
  1983. type = (pjsip_transport_type_e)(((int)type) + PJSIP_TRANSPORT_IPV6);
  1984. }
  1985. if (!ast_strlen_zero(domain)) {
  1986. from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
  1987. from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
  1988. "<sip:%s@%s%s%s>",
  1989. user,
  1990. domain,
  1991. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
  1992. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
  1993. return 0;
  1994. }
  1995. /* Get the local bound address for the transport that will be used when communicating with the provided URI */
  1996. if (pjsip_tpmgr_find_local_addr(pjsip_endpt_get_tpmgr(ast_sip_get_pjsip_endpoint()), pool, type, selector,
  1997. &local_addr, &local_port) != PJ_SUCCESS) {
  1998. /* If no local address can be retrieved using the transport manager use the host one */
  1999. pj_strdup(pool, &local_addr, pj_gethostname());
  2000. local_port = pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP);
  2001. }
  2002. /* If IPv6 was specified in the transport, set the proper type */
  2003. if (pj_strchr(&local_addr, ':') && type < PJSIP_TRANSPORT_START_OTHER) {
  2004. type = (pjsip_transport_type_e)(((int)type) + PJSIP_TRANSPORT_IPV6);
  2005. }
  2006. from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
  2007. from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
  2008. "<sip:%s@%s%.*s%s:%d%s%s>",
  2009. user,
  2010. (type & PJSIP_TRANSPORT_IPV6) ? "[" : "",
  2011. (int)local_addr.slen,
  2012. local_addr.ptr,
  2013. (type & PJSIP_TRANSPORT_IPV6) ? "]" : "",
  2014. local_port,
  2015. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
  2016. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
  2017. return 0;
  2018. }
  2019. static int sip_get_tpselector_from_endpoint(const struct ast_sip_endpoint *endpoint, pjsip_tpselector *selector)
  2020. {
  2021. RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
  2022. const char *transport_name = endpoint->transport;
  2023. if (ast_strlen_zero(transport_name)) {
  2024. return 0;
  2025. }
  2026. transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_name);
  2027. if (!transport || !transport->state) {
  2028. ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport '%s' for endpoint '%s'\n",
  2029. transport_name, ast_sorcery_object_get_id(endpoint));
  2030. return -1;
  2031. }
  2032. if (transport->state->transport) {
  2033. selector->type = PJSIP_TPSELECTOR_TRANSPORT;
  2034. selector->u.transport = transport->state->transport;
  2035. } else if (transport->state->factory) {
  2036. selector->type = PJSIP_TPSELECTOR_LISTENER;
  2037. selector->u.listener = transport->state->factory;
  2038. } else if (transport->type == AST_TRANSPORT_WS || transport->type == AST_TRANSPORT_WSS) {
  2039. /* The WebSocket transport has no factory as it can not create outgoing connections, so
  2040. * even if an endpoint is locked to a WebSocket transport we let the PJSIP logic
  2041. * find the existing connection if available and use it.
  2042. */
  2043. return 0;
  2044. } else {
  2045. return -1;
  2046. }
  2047. return 0;
  2048. }
  2049. pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *uri, const char *request_user)
  2050. {
  2051. char enclosed_uri[PJSIP_MAX_URL_SIZE];
  2052. pj_str_t local_uri = { "sip:temp@temp", 13 }, remote_uri, target_uri;
  2053. pjsip_dialog *dlg = NULL;
  2054. const char *outbound_proxy = endpoint->outbound_proxy;
  2055. pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
  2056. static const pj_str_t HCONTACT = { "Contact", 7 };
  2057. snprintf(enclosed_uri, sizeof(enclosed_uri), "<%s>", uri);
  2058. pj_cstr(&remote_uri, enclosed_uri);
  2059. pj_cstr(&target_uri, uri);
  2060. if (pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, &target_uri, &dlg) != PJ_SUCCESS) {
  2061. return NULL;
  2062. }
  2063. if (sip_get_tpselector_from_endpoint(endpoint, &selector)) {
  2064. pjsip_dlg_terminate(dlg);
  2065. return NULL;
  2066. }
  2067. if (sip_dialog_create_from(dlg->pool, &local_uri, endpoint->fromuser, endpoint->fromdomain, &remote_uri, &selector)) {
  2068. pjsip_dlg_terminate(dlg);
  2069. return NULL;
  2070. }
  2071. /* Update the dialog with the new local URI, we do it afterwards so we can use the dialog pool for construction */
  2072. pj_strdup_with_null(dlg->pool, &dlg->local.info_str, &local_uri);
  2073. dlg->local.info->uri = pjsip_parse_uri(dlg->pool, dlg->local.info_str.ptr, dlg->local.info_str.slen, 0);
  2074. dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen, NULL);
  2075. /* If a request user has been specified and we are permitted to change it, do so */
  2076. if (!ast_strlen_zero(request_user)) {
  2077. pjsip_sip_uri *sip_uri;
  2078. if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target)) {
  2079. sip_uri = pjsip_uri_get_uri(dlg->target);
  2080. pj_strdup2(dlg->pool, &sip_uri->user, request_user);
  2081. }
  2082. if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) || PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri)) {
  2083. sip_uri = pjsip_uri_get_uri(dlg->remote.info->uri);
  2084. pj_strdup2(dlg->pool, &sip_uri->user, request_user);
  2085. }
  2086. }
  2087. /* We have to temporarily bump up the sess_count here so the dialog is not prematurely destroyed */
  2088. dlg->sess_count++;
  2089. pjsip_dlg_set_transport(dlg, &selector);
  2090. if (!ast_strlen_zero(outbound_proxy)) {
  2091. pjsip_route_hdr route_set, *route;
  2092. static const pj_str_t ROUTE_HNAME = { "Route", 5 };
  2093. pj_str_t tmp;
  2094. pj_list_init(&route_set);
  2095. pj_strdup2_with_null(dlg->pool, &tmp, outbound_proxy);
  2096. if (!(route = pjsip_parse_hdr(dlg->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
  2097. dlg->sess_count--;
  2098. pjsip_dlg_terminate(dlg);
  2099. return NULL;
  2100. }
  2101. pj_list_insert_nodes_before(&route_set, route);
  2102. pjsip_dlg_set_route_set(dlg, &route_set);
  2103. }
  2104. dlg->sess_count--;
  2105. return dlg;
  2106. }
  2107. pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
  2108. {
  2109. pjsip_dialog *dlg;
  2110. pj_str_t contact;
  2111. pjsip_transport_type_e type = rdata->tp_info.transport->key.type;
  2112. pj_status_t status;
  2113. contact.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE);
  2114. contact.slen = pj_ansi_snprintf(contact.ptr, PJSIP_MAX_URL_SIZE,
  2115. "<sip:%s%.*s%s:%d%s%s>",
  2116. (type & PJSIP_TRANSPORT_IPV6) ? "[" : "",
  2117. (int)rdata->tp_info.transport->local_name.host.slen,
  2118. rdata->tp_info.transport->local_name.host.ptr,
  2119. (type & PJSIP_TRANSPORT_IPV6) ? "]" : "",
  2120. rdata->tp_info.transport->local_name.port,
  2121. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
  2122. (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
  2123. status = pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, &contact, &dlg);
  2124. if (status != PJ_SUCCESS) {
  2125. char err[PJ_ERR_MSG_SIZE];
  2126. pj_strerror(status, err, sizeof(err));
  2127. ast_log(LOG_ERROR, "Could not create dialog with endpoint %s. %s\n",
  2128. ast_sorcery_object_get_id(endpoint), err);
  2129. return NULL;
  2130. }
  2131. return dlg;
  2132. }
  2133. int ast_sip_create_rdata(pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port,
  2134. char *transport_type, const char *local_name, int local_port)
  2135. {
  2136. pj_str_t tmp;
  2137. rdata->tp_info.transport = PJ_POOL_ZALLOC_T(rdata->tp_info.pool, pjsip_transport);
  2138. if (!rdata->tp_info.transport) {
  2139. return -1;
  2140. }
  2141. ast_copy_string(rdata->pkt_info.packet, packet, sizeof(rdata->pkt_info.packet));
  2142. ast_copy_string(rdata->pkt_info.src_name, src_name, sizeof(rdata->pkt_info.src_name));
  2143. rdata->pkt_info.src_port = src_port;
  2144. pjsip_parse_rdata(packet, strlen(packet), rdata);
  2145. if (!rdata->msg_info.msg) {
  2146. return -1;
  2147. }
  2148. pj_strdup2(rdata->tp_info.pool, &rdata->msg_info.via->recvd_param, rdata->pkt_info.src_name);
  2149. rdata->msg_info.via->rport_param = -1;
  2150. rdata->tp_info.transport->key.type = pjsip_transport_get_type_from_name(pj_cstr(&tmp, transport_type));
  2151. rdata->tp_info.transport->type_name = transport_type;
  2152. pj_strdup2(rdata->tp_info.pool, &rdata->tp_info.transport->local_name.host, local_name);
  2153. rdata->tp_info.transport->local_name.port = local_port;
  2154. return 0;
  2155. }
  2156. /* PJSIP doesn't know about the INFO method, so we have to define it ourselves */
  2157. static const pjsip_method info_method = {PJSIP_OTHER_METHOD, {"INFO", 4} };
  2158. static const pjsip_method message_method = {PJSIP_OTHER_METHOD, {"MESSAGE", 7} };
  2159. static struct {
  2160. const char *method;
  2161. const pjsip_method *pmethod;
  2162. } methods [] = {
  2163. { "INVITE", &pjsip_invite_method },
  2164. { "CANCEL", &pjsip_cancel_method },
  2165. { "ACK", &pjsip_ack_method },
  2166. { "BYE", &pjsip_bye_method },
  2167. { "REGISTER", &pjsip_register_method },
  2168. { "OPTIONS", &pjsip_options_method },
  2169. { "SUBSCRIBE", &pjsip_subscribe_method },
  2170. { "NOTIFY", &pjsip_notify_method },
  2171. { "PUBLISH", &pjsip_publish_method },
  2172. { "INFO", &info_method },
  2173. { "MESSAGE", &message_method },
  2174. };
  2175. static const pjsip_method *get_pjsip_method(const char *method)
  2176. {
  2177. int i;
  2178. for (i = 0; i < ARRAY_LEN(methods); ++i) {
  2179. if (!strcmp(method, methods[i].method)) {
  2180. return methods[i].pmethod;
  2181. }
  2182. }
  2183. return NULL;
  2184. }
  2185. static int create_in_dialog_request(const pjsip_method *method, struct pjsip_dialog *dlg, pjsip_tx_data **tdata)
  2186. {
  2187. if (pjsip_dlg_create_request(dlg, method, -1, tdata) != PJ_SUCCESS) {
  2188. ast_log(LOG_WARNING, "Unable to create in-dialog request.\n");
  2189. return -1;
  2190. }
  2191. return 0;
  2192. }
  2193. static pj_bool_t supplement_on_rx_request(pjsip_rx_data *rdata);
  2194. static pjsip_module supplement_module = {
  2195. .name = { "Out of dialog supplement hook", 29 },
  2196. .id = -1,
  2197. .priority = PJSIP_MOD_PRIORITY_APPLICATION - 1,
  2198. .on_rx_request = supplement_on_rx_request,
  2199. };
  2200. static int create_out_of_dialog_request(const pjsip_method *method, struct ast_sip_endpoint *endpoint,
  2201. const char *uri, struct ast_sip_contact *provided_contact, pjsip_tx_data **tdata)
  2202. {
  2203. RAII_VAR(struct ast_sip_contact *, contact, ao2_bump(provided_contact), ao2_cleanup);
  2204. pj_str_t remote_uri;
  2205. pj_str_t from;
  2206. pj_pool_t *pool;
  2207. pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
  2208. if (ast_strlen_zero(uri)) {
  2209. if (!endpoint && (!contact || ast_strlen_zero(contact->uri))) {
  2210. ast_log(LOG_ERROR, "An endpoint and/or uri must be specified\n");
  2211. return -1;
  2212. }
  2213. if (!contact) {
  2214. contact = ast_sip_location_retrieve_contact_from_aor_list(endpoint->aors);
  2215. }
  2216. if (!contact || ast_strlen_zero(contact->uri)) {
  2217. ast_log(LOG_ERROR, "Unable to retrieve contact for endpoint %s\n",
  2218. ast_sorcery_object_get_id(endpoint));
  2219. return -1;
  2220. }
  2221. pj_cstr(&remote_uri, contact->uri);
  2222. } else {
  2223. pj_cstr(&remote_uri, uri);
  2224. }
  2225. if (endpoint) {
  2226. if (sip_get_tpselector_from_endpoint(endpoint, &selector)) {
  2227. ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport selector for endpoint %s\n",
  2228. ast_sorcery_object_get_id(endpoint));
  2229. return -1;
  2230. }
  2231. }
  2232. pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "Outbound request", 256, 256);
  2233. if (!pool) {
  2234. ast_log(LOG_ERROR, "Unable to create PJLIB memory pool\n");
  2235. return -1;
  2236. }
  2237. if (sip_dialog_create_from(pool, &from, endpoint ? endpoint->fromuser : NULL,
  2238. endpoint ? endpoint->fromdomain : NULL, &remote_uri, &selector)) {
  2239. ast_log(LOG_ERROR, "Unable to create From header for %.*s request to endpoint %s\n",
  2240. (int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint));
  2241. pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
  2242. return -1;
  2243. }
  2244. if (pjsip_endpt_create_request(ast_sip_get_pjsip_endpoint(), method, &remote_uri,
  2245. &from, &remote_uri, &from, NULL, -1, NULL, tdata) != PJ_SUCCESS) {
  2246. ast_log(LOG_ERROR, "Unable to create outbound %.*s request to endpoint %s\n",
  2247. (int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint));
  2248. pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
  2249. return -1;
  2250. }
  2251. /* If an outbound proxy is specified on the endpoint apply it to this request */
  2252. if (endpoint && !ast_strlen_zero(endpoint->outbound_proxy) &&
  2253. ast_sip_set_outbound_proxy((*tdata), endpoint->outbound_proxy)) {
  2254. ast_log(LOG_ERROR, "Unable to apply outbound proxy on request %.*s to endpoint %s\n",
  2255. (int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint));
  2256. pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
  2257. return -1;
  2258. }
  2259. ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
  2260. /* We can release this pool since request creation copied all the necessary
  2261. * data into the outbound request's pool
  2262. */
  2263. pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
  2264. return 0;
  2265. }
  2266. int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg,
  2267. struct ast_sip_endpoint *endpoint, const char *uri,
  2268. struct ast_sip_contact *contact, pjsip_tx_data **tdata)
  2269. {
  2270. const pjsip_method *pmethod = get_pjsip_method(method);
  2271. if (!pmethod) {
  2272. ast_log(LOG_WARNING, "Unknown method '%s'. Cannot send request\n", method);
  2273. return -1;
  2274. }
  2275. if (dlg) {
  2276. return create_in_dialog_request(pmethod, dlg, tdata);
  2277. } else {
  2278. return create_out_of_dialog_request(pmethod, endpoint, uri, contact, tdata);
  2279. }
  2280. }
  2281. AST_RWLIST_HEAD_STATIC(supplements, ast_sip_supplement);
  2282. int ast_sip_register_supplement(struct ast_sip_supplement *supplement)
  2283. {
  2284. struct ast_sip_supplement *iter;
  2285. int inserted = 0;
  2286. SCOPED_LOCK(lock, &supplements, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  2287. AST_RWLIST_TRAVERSE_SAFE_BEGIN(&supplements, iter, next) {
  2288. if (iter->priority > supplement->priority) {
  2289. AST_RWLIST_INSERT_BEFORE_CURRENT(supplement, next);
  2290. inserted = 1;
  2291. break;
  2292. }
  2293. }
  2294. AST_RWLIST_TRAVERSE_SAFE_END;
  2295. if (!inserted) {
  2296. AST_RWLIST_INSERT_TAIL(&supplements, supplement, next);
  2297. }
  2298. ast_module_ref(ast_module_info->self);
  2299. return 0;
  2300. }
  2301. void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)
  2302. {
  2303. struct ast_sip_supplement *iter;
  2304. SCOPED_LOCK(lock, &supplements, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
  2305. AST_RWLIST_TRAVERSE_SAFE_BEGIN(&supplements, iter, next) {
  2306. if (supplement == iter) {
  2307. AST_RWLIST_REMOVE_CURRENT(next);
  2308. ast_module_unref(ast_module_info->self);
  2309. break;
  2310. }
  2311. }
  2312. AST_RWLIST_TRAVERSE_SAFE_END;
  2313. }
  2314. static int send_in_dialog_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg)
  2315. {
  2316. if (pjsip_dlg_send_request(dlg, tdata, -1, NULL) != PJ_SUCCESS) {
  2317. ast_log(LOG_WARNING, "Unable to send in-dialog request.\n");
  2318. return -1;
  2319. }
  2320. return 0;
  2321. }
  2322. static pj_bool_t does_method_match(const pj_str_t *message_method, const char *supplement_method)
  2323. {
  2324. pj_str_t method;
  2325. if (ast_strlen_zero(supplement_method)) {
  2326. return PJ_TRUE;
  2327. }
  2328. pj_cstr(&method, supplement_method);
  2329. return pj_stristr(&method, message_method) ? PJ_TRUE : PJ_FALSE;
  2330. }
  2331. /*! Maximum number of challenges before assuming that we are in a loop */
  2332. #define MAX_RX_CHALLENGES 10
  2333. /*! \brief Structure to hold information about an outbound request */
  2334. struct send_request_data {
  2335. /*! The endpoint associated with this request */
  2336. struct ast_sip_endpoint *endpoint;
  2337. /*! Information to be provided to the callback upon receipt of a response */
  2338. void *token;
  2339. /*! The callback to be called upon receipt of a response */
  2340. void (*callback)(void *token, pjsip_event *e);
  2341. /*! Number of challenges received. */
  2342. unsigned int challenge_count;
  2343. };
  2344. static void send_request_data_destroy(void *obj)
  2345. {
  2346. struct send_request_data *req_data = obj;
  2347. ao2_cleanup(req_data->endpoint);
  2348. }
  2349. static struct send_request_data *send_request_data_alloc(struct ast_sip_endpoint *endpoint,
  2350. void *token, void (*callback)(void *token, pjsip_event *e))
  2351. {
  2352. struct send_request_data *req_data;
  2353. req_data = ao2_alloc_options(sizeof(*req_data), send_request_data_destroy,
  2354. AO2_ALLOC_OPT_LOCK_NOLOCK);
  2355. if (!req_data) {
  2356. return NULL;
  2357. }
  2358. req_data->endpoint = ao2_bump(endpoint);
  2359. req_data->token = token;
  2360. req_data->callback = callback;
  2361. return req_data;
  2362. }
  2363. struct send_request_wrapper {
  2364. /*! Information to be provided to the callback upon receipt of a response */
  2365. void *token;
  2366. /*! The callback to be called upon receipt of a response */
  2367. void (*callback)(void *token, pjsip_event *e);
  2368. /*! Non-zero when the callback is called. */
  2369. unsigned int cb_called;
  2370. };
  2371. static void endpt_send_request_wrapper(void *token, pjsip_event *e)
  2372. {
  2373. struct send_request_wrapper *req_wrapper = token;
  2374. req_wrapper->cb_called = 1;
  2375. if (req_wrapper->callback) {
  2376. req_wrapper->callback(req_wrapper->token, e);
  2377. }
  2378. ao2_ref(req_wrapper, -1);
  2379. }
  2380. static pj_status_t endpt_send_request(struct ast_sip_endpoint *endpoint,
  2381. pjsip_tx_data *tdata, pj_int32_t timeout, void *token, pjsip_endpt_send_callback cb)
  2382. {
  2383. struct send_request_wrapper *req_wrapper;
  2384. pj_status_t ret_val;
  2385. /* Create wrapper to detect if the callback was actually called on an error. */
  2386. req_wrapper = ao2_alloc_options(sizeof(*req_wrapper), NULL,
  2387. AO2_ALLOC_OPT_LOCK_NOLOCK);
  2388. if (!req_wrapper) {
  2389. pjsip_tx_data_dec_ref(tdata);
  2390. return PJ_ENOMEM;
  2391. }
  2392. req_wrapper->token = token;
  2393. req_wrapper->callback = cb;
  2394. ao2_ref(req_wrapper, +1);
  2395. ret_val = pjsip_endpt_send_request(ast_sip_get_pjsip_endpoint(), tdata, timeout,
  2396. req_wrapper, endpt_send_request_wrapper);
  2397. if (ret_val != PJ_SUCCESS) {
  2398. char errmsg[PJ_ERR_MSG_SIZE];
  2399. /* Complain of failure to send the request. */
  2400. pj_strerror(ret_val, errmsg, sizeof(errmsg));
  2401. ast_log(LOG_ERROR, "Error %d '%s' sending %.*s request to endpoint %s\n",
  2402. (int) ret_val, errmsg, (int) pj_strlen(&tdata->msg->line.req.method.name),
  2403. pj_strbuf(&tdata->msg->line.req.method.name),
  2404. endpoint ? ast_sorcery_object_get_id(endpoint) : "<unknown>");
  2405. /* Was the callback called? */
  2406. if (req_wrapper->cb_called) {
  2407. /*
  2408. * Yes so we cannot report any error. The callback
  2409. * has already freed any resources associated with
  2410. * token.
  2411. */
  2412. ret_val = PJ_SUCCESS;
  2413. } else {
  2414. /* No and it is not expected to ever be called. */
  2415. ao2_ref(req_wrapper, -1);
  2416. }
  2417. }
  2418. ao2_ref(req_wrapper, -1);
  2419. return ret_val;
  2420. }
  2421. static void send_request_cb(void *token, pjsip_event *e)
  2422. {
  2423. struct send_request_data *req_data = token;
  2424. pjsip_transaction *tsx;
  2425. pjsip_rx_data *challenge;
  2426. pjsip_tx_data *tdata;
  2427. struct ast_sip_supplement *supplement;
  2428. struct ast_sip_endpoint *endpoint;
  2429. int res;
  2430. switch(e->body.tsx_state.type) {
  2431. case PJSIP_EVENT_TRANSPORT_ERROR:
  2432. case PJSIP_EVENT_TIMER:
  2433. break;
  2434. case PJSIP_EVENT_RX_MSG:
  2435. challenge = e->body.tsx_state.src.rdata;
  2436. /*
  2437. * Call any supplements that want to know about a response
  2438. * with any received data.
  2439. */
  2440. AST_RWLIST_RDLOCK(&supplements);
  2441. AST_LIST_TRAVERSE(&supplements, supplement, next) {
  2442. if (supplement->incoming_response
  2443. && does_method_match(&challenge->msg_info.cseq->method.name,
  2444. supplement->method)) {
  2445. supplement->incoming_response(req_data->endpoint, challenge);
  2446. }
  2447. }
  2448. AST_RWLIST_UNLOCK(&supplements);
  2449. /* Resend the request with a challenge response if we are challenged. */
  2450. tsx = e->body.tsx_state.tsx;
  2451. endpoint = ao2_bump(req_data->endpoint);
  2452. res = (tsx->status_code == 401 || tsx->status_code == 407)
  2453. && endpoint
  2454. && ++req_data->challenge_count < MAX_RX_CHALLENGES /* Not in a challenge loop */
  2455. && !ast_sip_create_request_with_auth(&endpoint->outbound_auths,
  2456. challenge, tsx, &tdata)
  2457. && endpt_send_request(endpoint, tdata, -1, req_data, send_request_cb)
  2458. == PJ_SUCCESS;
  2459. ao2_cleanup(endpoint);
  2460. if (res) {
  2461. /*
  2462. * Request with challenge response sent.
  2463. * Passed our req_data ref to the new request.
  2464. */
  2465. return;
  2466. }
  2467. break;
  2468. default:
  2469. ast_log(LOG_ERROR, "Unexpected PJSIP event %d\n", e->body.tsx_state.type);
  2470. break;
  2471. }
  2472. if (req_data->callback) {
  2473. req_data->callback(req_data->token, e);
  2474. }
  2475. ao2_ref(req_data, -1);
  2476. }
  2477. static int send_out_of_dialog_request(pjsip_tx_data *tdata, struct ast_sip_endpoint *endpoint,
  2478. void *token, void (*callback)(void *token, pjsip_event *e))
  2479. {
  2480. struct ast_sip_supplement *supplement;
  2481. struct send_request_data *req_data;
  2482. struct ast_sip_contact *contact;
  2483. req_data = send_request_data_alloc(endpoint, token, callback);
  2484. if (!req_data) {
  2485. pjsip_tx_data_dec_ref(tdata);
  2486. return -1;
  2487. }
  2488. contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
  2489. AST_RWLIST_RDLOCK(&supplements);
  2490. AST_LIST_TRAVERSE(&supplements, supplement, next) {
  2491. if (supplement->outgoing_request
  2492. && does_method_match(&tdata->msg->line.req.method.name, supplement->method)) {
  2493. supplement->outgoing_request(endpoint, contact, tdata);
  2494. }
  2495. }
  2496. AST_RWLIST_UNLOCK(&supplements);
  2497. ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
  2498. ao2_cleanup(contact);
  2499. if (endpt_send_request(endpoint, tdata, -1, req_data, send_request_cb)
  2500. != PJ_SUCCESS) {
  2501. ao2_cleanup(req_data);
  2502. return -1;
  2503. }
  2504. return 0;
  2505. }
  2506. int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg,
  2507. struct ast_sip_endpoint *endpoint, void *token,
  2508. void (*callback)(void *token, pjsip_event *e))
  2509. {
  2510. ast_assert(tdata->msg->type == PJSIP_REQUEST_MSG);
  2511. if (dlg) {
  2512. return send_in_dialog_request(tdata, dlg);
  2513. } else {
  2514. return send_out_of_dialog_request(tdata, endpoint, token, callback);
  2515. }
  2516. }
  2517. int ast_sip_set_outbound_proxy(pjsip_tx_data *tdata, const char *proxy)
  2518. {
  2519. pjsip_route_hdr *route;
  2520. static const pj_str_t ROUTE_HNAME = { "Route", 5 };
  2521. pj_str_t tmp;
  2522. pj_strdup2_with_null(tdata->pool, &tmp, proxy);
  2523. if (!(route = pjsip_parse_hdr(tdata->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
  2524. return -1;
  2525. }
  2526. pj_list_insert_nodes_before(&tdata->msg->hdr, (pjsip_hdr*)route);
  2527. return 0;
  2528. }
  2529. int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
  2530. {
  2531. pj_str_t hdr_name;
  2532. pj_str_t hdr_value;
  2533. pjsip_generic_string_hdr *hdr;
  2534. pj_cstr(&hdr_name, name);
  2535. pj_cstr(&hdr_value, value);
  2536. hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
  2537. pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
  2538. return 0;
  2539. }
  2540. static pjsip_msg_body *ast_body_to_pjsip_body(pj_pool_t *pool, const struct ast_sip_body *body)
  2541. {
  2542. pj_str_t type;
  2543. pj_str_t subtype;
  2544. pj_str_t body_text;
  2545. pj_cstr(&type, body->type);
  2546. pj_cstr(&subtype, body->subtype);
  2547. pj_cstr(&body_text, body->body_text);
  2548. return pjsip_msg_body_create(pool, &type, &subtype, &body_text);
  2549. }
  2550. int ast_sip_add_body(pjsip_tx_data *tdata, const struct ast_sip_body *body)
  2551. {
  2552. pjsip_msg_body *pjsip_body = ast_body_to_pjsip_body(tdata->pool, body);
  2553. tdata->msg->body = pjsip_body;
  2554. return 0;
  2555. }
  2556. int ast_sip_add_body_multipart(pjsip_tx_data *tdata, const struct ast_sip_body *bodies[], int num_bodies)
  2557. {
  2558. int i;
  2559. /* NULL for type and subtype automatically creates "multipart/mixed" */
  2560. pjsip_msg_body *body = pjsip_multipart_create(tdata->pool, NULL, NULL);
  2561. for (i = 0; i < num_bodies; ++i) {
  2562. pjsip_multipart_part *part = pjsip_multipart_create_part(tdata->pool);
  2563. part->body = ast_body_to_pjsip_body(tdata->pool, bodies[i]);
  2564. pjsip_multipart_add_part(tdata->pool, body, part);
  2565. }
  2566. tdata->msg->body = body;
  2567. return 0;
  2568. }
  2569. int ast_sip_append_body(pjsip_tx_data *tdata, const char *body_text)
  2570. {
  2571. size_t combined_size = strlen(body_text) + tdata->msg->body->len;
  2572. struct ast_str *body_buffer = ast_str_alloca(combined_size);
  2573. ast_str_set(&body_buffer, 0, "%.*s%s", (int) tdata->msg->body->len, (char *) tdata->msg->body->data, body_text);
  2574. tdata->msg->body->data = pj_pool_alloc(tdata->pool, combined_size);
  2575. pj_memcpy(tdata->msg->body->data, ast_str_buffer(body_buffer), combined_size);
  2576. tdata->msg->body->len = combined_size;
  2577. return 0;
  2578. }
  2579. struct ast_taskprocessor *ast_sip_create_serializer(void)
  2580. {
  2581. struct ast_taskprocessor *serializer;
  2582. char name[AST_UUID_STR_LEN];
  2583. ast_uuid_generate_str(name, sizeof(name));
  2584. serializer = ast_threadpool_serializer(name, sip_threadpool);
  2585. if (!serializer) {
  2586. return NULL;
  2587. }
  2588. return serializer;
  2589. }
  2590. int ast_sip_push_task(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
  2591. {
  2592. if (serializer) {
  2593. return ast_taskprocessor_push(serializer, sip_task, task_data);
  2594. } else {
  2595. return ast_threadpool_push(sip_threadpool, sip_task, task_data);
  2596. }
  2597. }
  2598. struct sync_task_data {
  2599. ast_mutex_t lock;
  2600. ast_cond_t cond;
  2601. int complete;
  2602. int fail;
  2603. int (*task)(void *);
  2604. void *task_data;
  2605. };
  2606. static int sync_task(void *data)
  2607. {
  2608. struct sync_task_data *std = data;
  2609. std->fail = std->task(std->task_data);
  2610. ast_mutex_lock(&std->lock);
  2611. std->complete = 1;
  2612. ast_cond_signal(&std->cond);
  2613. ast_mutex_unlock(&std->lock);
  2614. return std->fail;
  2615. }
  2616. int ast_sip_push_task_synchronous(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
  2617. {
  2618. /* This method is an onion */
  2619. struct sync_task_data std;
  2620. if (ast_sip_thread_is_servant()) {
  2621. return sip_task(task_data);
  2622. }
  2623. memset(&std, 0, sizeof(std));
  2624. ast_mutex_init(&std.lock);
  2625. ast_cond_init(&std.cond, NULL);
  2626. std.task = sip_task;
  2627. std.task_data = task_data;
  2628. if (serializer) {
  2629. if (ast_taskprocessor_push(serializer, sync_task, &std)) {
  2630. ast_mutex_destroy(&std.lock);
  2631. ast_cond_destroy(&std.cond);
  2632. return -1;
  2633. }
  2634. } else {
  2635. if (ast_threadpool_push(sip_threadpool, sync_task, &std)) {
  2636. ast_mutex_destroy(&std.lock);
  2637. ast_cond_destroy(&std.cond);
  2638. return -1;
  2639. }
  2640. }
  2641. ast_mutex_lock(&std.lock);
  2642. while (!std.complete) {
  2643. ast_cond_wait(&std.cond, &std.lock);
  2644. }
  2645. ast_mutex_unlock(&std.lock);
  2646. ast_mutex_destroy(&std.lock);
  2647. ast_cond_destroy(&std.cond);
  2648. return std.fail;
  2649. }
  2650. void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
  2651. {
  2652. size_t chars_to_copy = MIN(size - 1, pj_strlen(src));
  2653. memcpy(dest, pj_strbuf(src), chars_to_copy);
  2654. dest[chars_to_copy] = '\0';
  2655. }
  2656. int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype)
  2657. {
  2658. pjsip_media_type compare;
  2659. if (!content_type) {
  2660. return 0;
  2661. }
  2662. pjsip_media_type_init2(&compare, type, subtype);
  2663. return pjsip_media_type_cmp(content_type, &compare, 0) ? 0 : -1;
  2664. }
  2665. pj_caching_pool caching_pool;
  2666. pj_pool_t *memory_pool;
  2667. pj_thread_t *monitor_thread;
  2668. static int monitor_continue;
  2669. static void *monitor_thread_exec(void *endpt)
  2670. {
  2671. while (monitor_continue) {
  2672. const pj_time_val delay = {0, 10};
  2673. pjsip_endpt_handle_events(ast_pjsip_endpoint, &delay);
  2674. }
  2675. return NULL;
  2676. }
  2677. static void stop_monitor_thread(void)
  2678. {
  2679. monitor_continue = 0;
  2680. pj_thread_join(monitor_thread);
  2681. }
  2682. AST_THREADSTORAGE(pj_thread_storage);
  2683. AST_THREADSTORAGE(servant_id_storage);
  2684. #define SIP_SERVANT_ID 0x5E2F1D
  2685. static void sip_thread_start(void)
  2686. {
  2687. pj_thread_desc *desc;
  2688. pj_thread_t *thread;
  2689. uint32_t *servant_id;
  2690. servant_id = ast_threadstorage_get(&servant_id_storage, sizeof(*servant_id));
  2691. if (!servant_id) {
  2692. ast_log(LOG_ERROR, "Could not set SIP servant ID in thread-local storage.\n");
  2693. return;
  2694. }
  2695. *servant_id = SIP_SERVANT_ID;
  2696. desc = ast_threadstorage_get(&pj_thread_storage, sizeof(pj_thread_desc));
  2697. if (!desc) {
  2698. ast_log(LOG_ERROR, "Could not get thread desc from thread-local storage. Expect awful things to occur\n");
  2699. return;
  2700. }
  2701. pj_bzero(*desc, sizeof(*desc));
  2702. if (pj_thread_register("Asterisk Thread", *desc, &thread) != PJ_SUCCESS) {
  2703. ast_log(LOG_ERROR, "Couldn't register thread with PJLIB.\n");
  2704. }
  2705. }
  2706. int ast_sip_thread_is_servant(void)
  2707. {
  2708. uint32_t *servant_id;
  2709. if (monitor_thread &&
  2710. pthread_self() == *(pthread_t *)pj_thread_get_os_handle(monitor_thread)) {
  2711. return 1;
  2712. }
  2713. servant_id = ast_threadstorage_get(&servant_id_storage, sizeof(*servant_id));
  2714. if (!servant_id) {
  2715. return 0;
  2716. }
  2717. return *servant_id == SIP_SERVANT_ID;
  2718. }
  2719. void *ast_sip_dict_get(void *ht, const char *key)
  2720. {
  2721. unsigned int hval = 0;
  2722. if (!ht) {
  2723. return NULL;
  2724. }
  2725. return pj_hash_get(ht, key, PJ_HASH_KEY_STRING, &hval);
  2726. }
  2727. void *ast_sip_dict_set(pj_pool_t* pool, void *ht,
  2728. const char *key, void *val)
  2729. {
  2730. if (!ht) {
  2731. ht = pj_hash_create(pool, 11);
  2732. }
  2733. pj_hash_set(pool, ht, key, PJ_HASH_KEY_STRING, 0, val);
  2734. return ht;
  2735. }
  2736. static pj_bool_t supplement_on_rx_request(pjsip_rx_data *rdata)
  2737. {
  2738. struct ast_sip_supplement *supplement;
  2739. if (pjsip_rdata_get_dlg(rdata)) {
  2740. return PJ_FALSE;
  2741. }
  2742. AST_RWLIST_RDLOCK(&supplements);
  2743. AST_LIST_TRAVERSE(&supplements, supplement, next) {
  2744. if (supplement->incoming_request && does_method_match(&rdata->msg_info.msg->line.req.method.name, supplement->method)) {
  2745. supplement->incoming_request(ast_pjsip_rdata_get_endpoint(rdata), rdata);
  2746. }
  2747. }
  2748. AST_RWLIST_UNLOCK(&supplements);
  2749. return PJ_FALSE;
  2750. }
  2751. int ast_sip_send_response(pjsip_response_addr *res_addr, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
  2752. {
  2753. struct ast_sip_supplement *supplement;
  2754. pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
  2755. struct ast_sip_contact *contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
  2756. AST_RWLIST_RDLOCK(&supplements);
  2757. AST_LIST_TRAVERSE(&supplements, supplement, next) {
  2758. if (supplement->outgoing_response && does_method_match(&cseq->method.name, supplement->method)) {
  2759. supplement->outgoing_response(sip_endpoint, contact, tdata);
  2760. }
  2761. }
  2762. AST_RWLIST_UNLOCK(&supplements);
  2763. ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
  2764. ao2_cleanup(contact);
  2765. return pjsip_endpt_send_response(ast_sip_get_pjsip_endpoint(), res_addr, tdata, NULL, NULL);
  2766. }
  2767. int ast_sip_create_response(const pjsip_rx_data *rdata, int st_code,
  2768. struct ast_sip_contact *contact, pjsip_tx_data **tdata)
  2769. {
  2770. int res = pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, st_code, NULL, tdata);
  2771. if (!res) {
  2772. ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
  2773. }
  2774. return res;
  2775. }
  2776. static void remove_request_headers(pjsip_endpoint *endpt)
  2777. {
  2778. const pjsip_hdr *request_headers = pjsip_endpt_get_request_headers(endpt);
  2779. pjsip_hdr *iter = request_headers->next;
  2780. while (iter != request_headers) {
  2781. pjsip_hdr *to_erase = iter;
  2782. iter = iter->next;
  2783. pj_list_erase(to_erase);
  2784. }
  2785. }
  2786. /*!
  2787. * \internal
  2788. * \brief Reload configuration within a PJSIP thread
  2789. */
  2790. static int reload_configuration_task(void *obj)
  2791. {
  2792. ast_res_pjsip_reload_configuration();
  2793. ast_res_pjsip_init_options_handling(1);
  2794. ast_sip_initialize_dns();
  2795. return 0;
  2796. }
  2797. static int load_module(void)
  2798. {
  2799. /* The third parameter is just copied from
  2800. * example code from PJLIB. This can be adjusted
  2801. * if necessary.
  2802. */
  2803. pj_status_t status;
  2804. struct ast_threadpool_options options;
  2805. if (pj_init() != PJ_SUCCESS) {
  2806. return AST_MODULE_LOAD_DECLINE;
  2807. }
  2808. if (pjlib_util_init() != PJ_SUCCESS) {
  2809. pj_shutdown();
  2810. return AST_MODULE_LOAD_DECLINE;
  2811. }
  2812. pj_caching_pool_init(&caching_pool, NULL, 1024 * 1024);
  2813. if (pjsip_endpt_create(&caching_pool.factory, "SIP", &ast_pjsip_endpoint) != PJ_SUCCESS) {
  2814. ast_log(LOG_ERROR, "Failed to create PJSIP endpoint structure. Aborting load\n");
  2815. pj_caching_pool_destroy(&caching_pool);
  2816. return AST_MODULE_LOAD_DECLINE;
  2817. }
  2818. /* PJSIP will automatically try to add a Max-Forwards header. Since we want to control that,
  2819. * we need to stop PJSIP from doing it automatically
  2820. */
  2821. remove_request_headers(ast_pjsip_endpoint);
  2822. memory_pool = pj_pool_create(&caching_pool.factory, "SIP", 1024, 1024, NULL);
  2823. if (!memory_pool) {
  2824. ast_log(LOG_ERROR, "Failed to create memory pool for SIP. Aborting load\n");
  2825. pjsip_endpt_destroy(ast_pjsip_endpoint);
  2826. ast_pjsip_endpoint = NULL;
  2827. pj_caching_pool_destroy(&caching_pool);
  2828. return AST_MODULE_LOAD_DECLINE;
  2829. }
  2830. if (ast_sip_initialize_system()) {
  2831. ast_log(LOG_ERROR, "Failed to initialize SIP 'system' configuration section. Aborting load\n");
  2832. pj_pool_release(memory_pool);
  2833. memory_pool = NULL;
  2834. pjsip_endpt_destroy(ast_pjsip_endpoint);
  2835. ast_pjsip_endpoint = NULL;
  2836. pj_caching_pool_destroy(&caching_pool);
  2837. return AST_MODULE_LOAD_DECLINE;
  2838. }
  2839. sip_get_threadpool_options(&options);
  2840. options.thread_start = sip_thread_start;
  2841. sip_threadpool = ast_threadpool_create("SIP", NULL, &options);
  2842. if (!sip_threadpool) {
  2843. ast_log(LOG_ERROR, "Failed to create SIP threadpool. Aborting load\n");
  2844. ast_sip_destroy_system();
  2845. pj_pool_release(memory_pool);
  2846. memory_pool = NULL;
  2847. pjsip_endpt_destroy(ast_pjsip_endpoint);
  2848. ast_pjsip_endpoint = NULL;
  2849. pj_caching_pool_destroy(&caching_pool);
  2850. return AST_MODULE_LOAD_DECLINE;
  2851. }
  2852. ast_sip_initialize_dns();
  2853. pjsip_tsx_layer_init_module(ast_pjsip_endpoint);
  2854. pjsip_ua_init_module(ast_pjsip_endpoint, NULL);
  2855. monitor_continue = 1;
  2856. status = pj_thread_create(memory_pool, "SIP", (pj_thread_proc *) &monitor_thread_exec,
  2857. NULL, PJ_THREAD_DEFAULT_STACK_SIZE * 2, 0, &monitor_thread);
  2858. if (status != PJ_SUCCESS) {
  2859. ast_log(LOG_ERROR, "Failed to start SIP monitor thread. Aborting load\n");
  2860. ast_sip_destroy_system();
  2861. pj_pool_release(memory_pool);
  2862. memory_pool = NULL;
  2863. pjsip_endpt_destroy(ast_pjsip_endpoint);
  2864. ast_pjsip_endpoint = NULL;
  2865. pj_caching_pool_destroy(&caching_pool);
  2866. return AST_MODULE_LOAD_DECLINE;
  2867. }
  2868. ast_sip_initialize_global_headers();
  2869. if (ast_res_pjsip_initialize_configuration(ast_module_info)) {
  2870. ast_log(LOG_ERROR, "Failed to initialize SIP configuration. Aborting load\n");
  2871. ast_sip_destroy_global_headers();
  2872. stop_monitor_thread();
  2873. ast_sip_destroy_system();
  2874. pj_pool_release(memory_pool);
  2875. memory_pool = NULL;
  2876. pjsip_endpt_destroy(ast_pjsip_endpoint);
  2877. ast_pjsip_endpoint = NULL;
  2878. pj_caching_pool_destroy(&caching_pool);
  2879. return AST_MODULE_LOAD_DECLINE;
  2880. }
  2881. if (ast_sip_initialize_distributor()) {
  2882. ast_log(LOG_ERROR, "Failed to register distributor module. Aborting load\n");
  2883. ast_res_pjsip_destroy_configuration();
  2884. ast_sip_destroy_global_headers();
  2885. stop_monitor_thread();
  2886. ast_sip_destroy_system();
  2887. pj_pool_release(memory_pool);
  2888. memory_pool = NULL;
  2889. pjsip_endpt_destroy(ast_pjsip_endpoint);
  2890. ast_pjsip_endpoint = NULL;
  2891. pj_caching_pool_destroy(&caching_pool);
  2892. return AST_MODULE_LOAD_DECLINE;
  2893. }
  2894. if (ast_sip_register_service(&supplement_module)) {
  2895. ast_log(LOG_ERROR, "Failed to initialize supplement hooks. Aborting load\n");
  2896. ast_sip_destroy_distributor();
  2897. ast_res_pjsip_destroy_configuration();
  2898. ast_sip_destroy_global_headers();
  2899. stop_monitor_thread();
  2900. ast_sip_destroy_system();
  2901. pj_pool_release(memory_pool);
  2902. memory_pool = NULL;
  2903. pjsip_endpt_destroy(ast_pjsip_endpoint);
  2904. ast_pjsip_endpoint = NULL;
  2905. pj_caching_pool_destroy(&caching_pool);
  2906. return AST_MODULE_LOAD_DECLINE;
  2907. }
  2908. if (ast_sip_initialize_outbound_authentication()) {
  2909. ast_log(LOG_ERROR, "Failed to initialize outbound authentication. Aborting load\n");
  2910. ast_sip_unregister_service(&supplement_module);
  2911. ast_sip_destroy_distributor();
  2912. ast_res_pjsip_destroy_configuration();
  2913. ast_sip_destroy_global_headers();
  2914. stop_monitor_thread();
  2915. ast_sip_destroy_system();
  2916. pj_pool_release(memory_pool);
  2917. memory_pool = NULL;
  2918. pjsip_endpt_destroy(ast_pjsip_endpoint);
  2919. ast_pjsip_endpoint = NULL;
  2920. pj_caching_pool_destroy(&caching_pool);
  2921. return AST_MODULE_LOAD_DECLINE;
  2922. }
  2923. ast_res_pjsip_init_options_handling(0);
  2924. ast_module_ref(ast_module_info->self);
  2925. return AST_MODULE_LOAD_SUCCESS;
  2926. }
  2927. static int reload_module(void)
  2928. {
  2929. if (ast_sip_push_task(NULL, reload_configuration_task, NULL)) {
  2930. ast_log(LOG_WARNING, "Failed to reload PJSIP\n");
  2931. return -1;
  2932. }
  2933. return 0;
  2934. }
  2935. static int unload_module(void)
  2936. {
  2937. /* This will never get called as this module can't be unloaded */
  2938. return 0;
  2939. }
  2940. AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Basic SIP resource",
  2941. .support_level = AST_MODULE_SUPPORT_CORE,
  2942. .load = load_module,
  2943. .unload = unload_module,
  2944. .reload = reload_module,
  2945. .load_pri = AST_MODPRI_CHANNEL_DEPEND - 5,
  2946. );