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