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