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