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