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