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