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