Asterisk - The Open Source Telephony Project  GIT-master-8beac82
res_pjsip.c
Go to the documentation of this file.
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 #include <pjmedia/errno.h>
28 
29 #include "asterisk/res_pjsip.h"
31 #include "asterisk/linkedlists.h"
32 #include "asterisk/logger.h"
33 #include "asterisk/lock.h"
34 #include "asterisk/utils.h"
35 #include "asterisk/astobj2.h"
36 #include "asterisk/module.h"
37 #include "asterisk/serializer.h"
38 #include "asterisk/threadpool.h"
39 #include "asterisk/taskprocessor.h"
40 #include "asterisk/uuid.h"
41 #include "asterisk/sorcery.h"
42 #include "asterisk/file.h"
43 #include "asterisk/cli.h"
44 #include "asterisk/res_pjsip_cli.h"
45 #include "asterisk/test.h"
47 #include "asterisk/res_pjproject.h"
48 
49 /*** MODULEINFO
50  <depend>pjproject</depend>
51  <depend>res_pjproject</depend>
52  <depend>res_sorcery_config</depend>
53  <depend>res_sorcery_memory</depend>
54  <depend>res_sorcery_astdb</depend>
55  <use type="module">res_statsd</use>
56  <support_level>core</support_level>
57  ***/
58 
59 /*** DOCUMENTATION
60  <configInfo name="res_pjsip" language="en_US">
61  <synopsis>SIP Resource using PJProject</synopsis>
62  <configFile name="pjsip.conf">
63  <configObject name="endpoint">
64  <synopsis>Endpoint</synopsis>
65  <description><para>
66  The <emphasis>Endpoint</emphasis> is the primary configuration object.
67  It contains the core SIP related options only, endpoints are <emphasis>NOT</emphasis>
68  dialable entries of their own. Communication with another SIP device is
69  accomplished via Addresses of Record (AoRs) which have one or more
70  contacts associated with them. Endpoints <emphasis>NOT</emphasis> configured to
71  use a <literal>transport</literal> will default to first transport found
72  in <filename>pjsip.conf</filename> that matches its type.
73  </para>
74  <para>Example: An Endpoint has been configured with no transport.
75  When it comes time to call an AoR, PJSIP will find the
76  first transport that matches the type. A SIP URI of <literal>sip:5000@[11::33]</literal>
77  will use the first IPv6 transport and try to send the request.
78  </para>
79  <para>If the anonymous endpoint identifier is in use an endpoint with the name
80  "anonymous@domain" will be searched for as a last resort. If this is not found
81  it will fall back to searching for "anonymous". If neither endpoints are found
82  the anonymous endpoint identifier will not return an endpoint and anonymous
83  calling will not be possible.
84  </para>
85  </description>
86  <configOption name="100rel" default="yes">
87  <synopsis>Allow support for RFC3262 provisional ACK tags</synopsis>
88  <description>
89  <enumlist>
90  <enum name="no" />
91  <enum name="required" />
92  <enum name="yes" />
93  </enumlist>
94  </description>
95  </configOption>
96  <configOption name="aggregate_mwi" default="yes">
97  <synopsis>Condense MWI notifications into a single NOTIFY.</synopsis>
98  <description><para>When enabled, <replaceable>aggregate_mwi</replaceable> condenses message
99  waiting notifications from multiple mailboxes into a single NOTIFY. If it is disabled,
100  individual NOTIFYs are sent for each mailbox.</para></description>
101  </configOption>
102  <configOption name="allow">
103  <synopsis>Media Codec(s) to allow</synopsis>
104  </configOption>
105  <configOption name="codec_prefs_incoming_offer">
106  <synopsis>Codec negotiation prefs for incoming offers.</synopsis>
107  <description>
108  <para>
109  This is a string that describes how the codecs
110  specified on an incoming SDP offer (pending) are reconciled with the codecs specified
111  on an endpoint (configured) before being sent to the Asterisk core.
112  The string actually specifies 4 <literal>name:value</literal> pair parameters
113  separated by commas. Whitespace is ignored and they may be specified in any order.
114  Note that this option is reserved for future functionality.
115 
116  </para>
117  <para>
118  Parameters:
119  </para>
120  <enumlist>
121  <enum name="prefer: &lt; pending | configured &gt;">
122  <para>
123  </para>
124  <enumlist>
125  <enum name="pending"><para>The codec list from the caller. (default)</para></enum>
126  <enum name="configured"><para>The codec list from the endpoint.</para></enum>
127  </enumlist>
128  </enum>
129  <enum name="operation : &lt; intersect | only_preferred | only_nonpreferred &gt;">
130  <para>
131  </para>
132  <enumlist>
133  <enum name="intersect"><para>Only common codecs with the preferred codecs first. (default)</para></enum>
134  <enum name="only_preferred"><para>Use only the preferred codecs.</para></enum>
135  <enum name="only_nonpreferred"><para>Use only the non-preferred codecs.</para></enum>
136  </enumlist>
137  </enum>
138  <enum name="keep : &lt; all | first &gt;">
139  <para>
140  </para>
141  <enumlist>
142  <enum name="all"><para>After the operation, keep all codecs. (default)</para></enum>
143  <enum name="first"><para>After the operation, keep only the first codec.</para></enum>
144  </enumlist>
145  </enum>
146  <enum name="transcode : &lt; allow | prevent &gt;">
147  <para>
148  </para>
149  <enumlist>
150  <enum name="allow"><para>Allow transcoding. (default)</para></enum>
151  <enum name="prevent"><para>Prevent transcoding.</para></enum>
152  </enumlist>
153  </enum>
154  </enumlist>
155  <para>
156  </para>
157  <example>
158  codec_prefs_incoming_offer = prefer: pending, operation: intersect, keep: all, transcode: allow
159  </example>
160  <para>
161  Prefer the codecs coming from the caller. Use only the ones that are common.
162  keeping the order of the preferred list. Keep all codecs in the result. Allow transcoding.
163  </para>
164  </description>
165  </configOption>
166  <configOption name="codec_prefs_outgoing_offer">
167  <synopsis>Codec negotiation prefs for outgoing offers.</synopsis>
168  <description>
169  <para>
170  This is a string that describes how the codecs specified in the topology that
171  comes from the Asterisk core (pending) are reconciled with the codecs specified on an
172  endpoint (configured) when sending an SDP offer.
173  The string actually specifies 4 <literal>name:value</literal> pair parameters
174  separated by commas. Whitespace is ignored and they may be specified in any order.
175  Note that this option is reserved for future functionality.
176 
177  </para>
178  <para>
179  Parameters:
180  </para>
181  <enumlist>
182  <enum name="prefer: &lt; pending | configured &gt;">
183  <para>
184  </para>
185  <enumlist>
186  <enum name="pending"><para>The codec list from the core. (default)</para></enum>
187  <enum name="configured"><para>The codec list from the endpoint.</para></enum>
188  </enumlist>
189  </enum>
190  <enum name="operation : &lt; union | intersect | only_preferred | only_nonpreferred &gt;">
191  <para>
192  </para>
193  <enumlist>
194  <enum name="union"><para>Merge the lists with the preferred codecs first. (default)</para></enum>
195  <enum name="intersect"><para>Only common codecs with the preferred codecs first. (default)</para></enum>
196  <enum name="only_preferred"><para>Use only the preferred codecs.</para></enum>
197  <enum name="only_nonpreferred"><para>Use only the non-preferred codecs.</para></enum>
198  </enumlist>
199  </enum>
200  <enum name="keep : &lt; all | first &gt;">
201  <para>
202  </para>
203  <enumlist>
204  <enum name="all"><para>After the operation, keep all codecs. (default)</para></enum>
205  <enum name="first"><para>After the operation, keep only the first codec.</para></enum>
206  </enumlist>
207  </enum>
208  <enum name="transcode : &lt; allow | prevent &gt;">
209  <para>
210  </para>
211  <enumlist>
212  <enum name="allow"><para>Allow transcoding. (default)</para></enum>
213  <enum name="prevent"><para>Prevent transcoding.</para></enum>
214  </enumlist>
215  </enum>
216  </enumlist>
217  <para>
218  </para>
219  <example>
220  codec_prefs_outgoing_offer = prefer: configured, operation: union, keep: first, transcode: prevent
221  </example>
222  <para>
223  Prefer the codecs coming from the endpoint. Merge them with the codecs from the core
224  keeping the order of the preferred list. Keep only the first one. No transcoding allowed.
225  </para>
226  </description>
227  </configOption>
228  <configOption name="codec_prefs_incoming_answer">
229  <synopsis>Codec negotiation prefs for incoming answers.</synopsis>
230  <description>
231  <para>
232  This is a string that describes how the codecs specified in an incoming SDP answer
233  (pending) are reconciled with the codecs specified on an endpoint (configured)
234  when receiving an SDP answer.
235  The string actually specifies 4 <literal>name:value</literal> pair parameters
236  separated by commas. Whitespace is ignored and they may be specified in any order.
237  Note that this option is reserved for future functionality.
238 
239  </para>
240  <para>
241  Parameters:
242  </para>
243  <enumlist>
244  <enum name="prefer: &lt; pending | configured &gt;">
245  <para>
246  </para>
247  <enumlist>
248  <enum name="pending"><para>The codec list in the received SDP answer. (default)</para></enum>
249  <enum name="configured"><para>The codec list from the endpoint.</para></enum>
250  </enumlist>
251  </enum>
252  <enum name="operation : &lt; union | intersect | only_preferred | only_nonpreferred &gt;">
253  <para>
254  </para>
255  <enumlist>
256  <enum name="union"><para>Merge the lists with the preferred codecs first.</para></enum>
257  <enum name="intersect"><para>Only common codecs with the preferred codecs first. (default)</para></enum>
258  <enum name="only_preferred"><para>Use only the preferred codecs.</para></enum>
259  <enum name="only_nonpreferred"><para>Use only the non-preferred codecs.</para></enum>
260  </enumlist>
261  </enum>
262  <enum name="keep : &lt; all | first &gt;">
263  <para>
264  </para>
265  <enumlist>
266  <enum name="all"><para>After the operation, keep all codecs. (default)</para></enum>
267  <enum name="first"><para>After the operation, keep only the first codec.</para></enum>
268  </enumlist>
269  </enum>
270  <enum name="transcode : &lt; allow | prevent &gt;">
271  <para>
272  The transcode parameter is ignored when processing answers.
273  </para>
274  </enum>
275  </enumlist>
276  <para>
277  </para>
278  <example>
279  codec_prefs_incoming_answer = keep: first
280  </example>
281  <para>
282  Use the defaults but keep oinly the first codec.
283  </para>
284  </description>
285  </configOption>
286  <configOption name="codec_prefs_outgoing_answer">
287  <synopsis>Codec negotiation prefs for outgoing answers.</synopsis>
288  <description>
289  <para>
290  This is a string that describes how the codecs that come from the core (pending)
291  are reconciled with the codecs specified on an endpoint (configured)
292  when sending an SDP answer.
293  The string actually specifies 4 <literal>name:value</literal> pair parameters
294  separated by commas. Whitespace is ignored and they may be specified in any order.
295  Note that this option is reserved for future functionality.
296 
297  </para>
298  <para>
299  Parameters:
300  </para>
301  <enumlist>
302  <enum name="prefer: &lt; pending | configured &gt;">
303  <para>
304  </para>
305  <enumlist>
306  <enum name="pending"><para>The codec list that came from the core. (default)</para></enum>
307  <enum name="configured"><para>The codec list from the endpoint.</para></enum>
308  </enumlist>
309  </enum>
310  <enum name="operation : &lt; union | intersect | only_preferred | only_nonpreferred &gt;">
311  <para>
312  </para>
313  <enumlist>
314  <enum name="union"><para>Merge the lists with the preferred codecs first.</para></enum>
315  <enum name="intersect"><para>Only common codecs with the preferred codecs first. (default)</para></enum>
316  <enum name="only_preferred"><para>Use only the preferred codecs.</para></enum>
317  <enum name="only_nonpreferred"><para>Use only the non-preferred codecs.</para></enum>
318  </enumlist>
319  </enum>
320  <enum name="keep : &lt; all | first &gt;">
321  <para>
322  </para>
323  <enumlist>
324  <enum name="all"><para>After the operation, keep all codecs. (default)</para></enum>
325  <enum name="first"><para>After the operation, keep only the first codec.</para></enum>
326  </enumlist>
327  </enum>
328  <enum name="transcode : &lt; allow | prevent &gt;">
329  <para>
330  The transcode parameter is ignored when processing answers.
331  </para>
332  </enum>
333  </enumlist>
334  <para>
335  </para>
336  <example>
337  codec_prefs_incoming_answer = keep: first
338  </example>
339  <para>
340  Use the defaults but keep oinly the first codec.
341  </para>
342  </description>
343  </configOption>
344  <configOption name="allow_overlap" default="yes">
345  <synopsis>Enable RFC3578 overlap dialing support.</synopsis>
346  </configOption>
347  <configOption name="aors">
348  <synopsis>AoR(s) to be used with the endpoint</synopsis>
349  <description><para>
350  List of comma separated AoRs that the endpoint should be associated with.
351  </para></description>
352  </configOption>
353  <configOption name="auth">
354  <synopsis>Authentication Object(s) associated with the endpoint</synopsis>
355  <description><para>
356  This is a comma-delimited list of <replaceable>auth</replaceable> sections defined
357  in <filename>pjsip.conf</filename> to be used to verify inbound connection attempts.
358  </para><para>
359  Endpoints without an authentication object
360  configured will allow connections without verification.</para>
361  <note><para>
362  Using the same auth section for inbound and outbound
363  authentication is not recommended. There is a difference in
364  meaning for an empty realm setting between inbound and outbound
365  authentication uses. See the auth realm description for details.
366  </para></note>
367  </description>
368  </configOption>
369  <configOption name="callerid">
370  <synopsis>CallerID information for the endpoint</synopsis>
371  <description><para>
372  Must be in the format <literal>Name &lt;Number&gt;</literal>,
373  or only <literal>&lt;Number&gt;</literal>.
374  </para></description>
375  </configOption>
376  <configOption name="callerid_privacy">
377  <synopsis>Default privacy level</synopsis>
378  <description>
379  <enumlist>
380  <enum name="allowed_not_screened" />
381  <enum name="allowed_passed_screen" />
382  <enum name="allowed_failed_screen" />
383  <enum name="allowed" />
384  <enum name="prohib_not_screened" />
385  <enum name="prohib_passed_screen" />
386  <enum name="prohib_failed_screen" />
387  <enum name="prohib" />
388  <enum name="unavailable" />
389  </enumlist>
390  </description>
391  </configOption>
392  <configOption name="callerid_tag">
393  <synopsis>Internal id_tag for the endpoint</synopsis>
394  </configOption>
395  <configOption name="context">
396  <synopsis>Dialplan context for inbound sessions</synopsis>
397  </configOption>
398  <configOption name="direct_media_glare_mitigation" default="none">
399  <synopsis>Mitigation of direct media (re)INVITE glare</synopsis>
400  <description>
401  <para>
402  This setting attempts to avoid creating INVITE glare scenarios
403  by disabling direct media reINVITEs in one direction thereby allowing
404  designated servers (according to this option) to initiate direct
405  media reINVITEs without contention and significantly reducing call
406  setup time.
407  </para>
408  <para>
409  A more detailed description of how this option functions can be found on
410  the Asterisk wiki https://wiki.asterisk.org/wiki/display/AST/SIP+Direct+Media+Reinvite+Glare+Avoidance
411  </para>
412  <enumlist>
413  <enum name="none" />
414  <enum name="outgoing" />
415  <enum name="incoming" />
416  </enumlist>
417  </description>
418  </configOption>
419  <configOption name="direct_media_method" default="invite">
420  <synopsis>Direct Media method type</synopsis>
421  <description>
422  <para>Method for setting up Direct Media between endpoints.</para>
423  <enumlist>
424  <enum name="invite" />
425  <enum name="reinvite">
426  <para>Alias for the <literal>invite</literal> value.</para>
427  </enum>
428  <enum name="update" />
429  </enumlist>
430  </description>
431  </configOption>
432  <configOption name="trust_connected_line">
433  <synopsis>Accept Connected Line updates from this endpoint</synopsis>
434  </configOption>
435  <configOption name="send_connected_line">
436  <synopsis>Send Connected Line updates to this endpoint</synopsis>
437  </configOption>
438  <configOption name="connected_line_method" default="invite">
439  <synopsis>Connected line method type</synopsis>
440  <description>
441  <para>Method used when updating connected line information.</para>
442  <enumlist>
443  <enum name="invite">
444  <para>When set to <literal>invite</literal>, check the remote's Allow header and
445  if UPDATE is allowed, send UPDATE instead of INVITE to avoid SDP
446  renegotiation. If UPDATE is not Allowed, send INVITE.</para>
447  </enum>
448  <enum name="reinvite">
449  <para>Alias for the <literal>invite</literal> value.</para>
450  </enum>
451  <enum name="update">
452  <para>If set to <literal>update</literal>, send UPDATE regardless of what the remote
453  Allows. </para>
454  </enum>
455  </enumlist>
456  </description>
457  </configOption>
458  <configOption name="direct_media" default="yes">
459  <synopsis>Determines whether media may flow directly between endpoints.</synopsis>
460  </configOption>
461  <configOption name="disable_direct_media_on_nat" default="no">
462  <synopsis>Disable direct media session refreshes when NAT obstructs the media session</synopsis>
463  </configOption>
464  <configOption name="disallow">
465  <synopsis>Media Codec(s) to disallow</synopsis>
466  </configOption>
467  <configOption name="dtmf_mode" default="rfc4733">
468  <synopsis>DTMF mode</synopsis>
469  <description>
470  <para>This setting allows to choose the DTMF mode for endpoint communication.</para>
471  <enumlist>
472  <enum name="rfc4733">
473  <para>DTMF is sent out of band of the main audio stream. This
474  supercedes the older <emphasis>RFC-2833</emphasis> used within
475  the older <literal>chan_sip</literal>.</para>
476  </enum>
477  <enum name="inband">
478  <para>DTMF is sent as part of audio stream.</para>
479  </enum>
480  <enum name="info">
481  <para>DTMF is sent as SIP INFO packets.</para>
482  </enum>
483  <enum name="auto">
484  <para>DTMF is sent as RFC 4733 if the other side supports it or as INBAND if not.</para>
485  </enum>
486  <enum name="auto_info">
487  <para>DTMF is sent as RFC 4733 if the other side supports it or as SIP INFO if not.</para>
488  </enum>
489  </enumlist>
490  </description>
491  </configOption>
492  <configOption name="media_address">
493  <synopsis>IP address used in SDP for media handling</synopsis>
494  <description><para>
495  At the time of SDP creation, the IP address defined here will be used as
496  the media address for individual streams in the SDP.
497  </para>
498  <note><para>
499  Be aware that the <literal>external_media_address</literal> option, set in Transport
500  configuration, can also affect the final media address used in the SDP.
501  </para></note>
502  </description>
503  </configOption>
504  <configOption name="bind_rtp_to_media_address">
505  <synopsis>Bind the RTP instance to the media_address</synopsis>
506  <description><para>
507  If media_address is specified, this option causes the RTP instance to be bound to the
508  specified ip address which causes the packets to be sent from that address.
509  </para>
510  </description>
511  </configOption>
512  <configOption name="force_rport" default="yes">
513  <synopsis>Force use of return port</synopsis>
514  </configOption>
515  <configOption name="ice_support" default="no">
516  <synopsis>Enable the ICE mechanism to help traverse NAT</synopsis>
517  </configOption>
518  <configOption name="identify_by">
519  <synopsis>Way(s) for the endpoint to be identified</synopsis>
520  <description>
521  <para>Endpoints and AORs can be identified in multiple ways. This
522  option is a comma separated list of methods the endpoint can be
523  identified.
524  </para>
525  <note><para>
526  This option controls both how an endpoint is matched for incoming
527  traffic and also how an AOR is determined if a registration
528  occurs. You must list at least one method that also matches for
529  AORs or the registration will fail.
530  </para></note>
531  <enumlist>
532  <enum name="username">
533  <para>Matches the endpoint or AOR ID based on the username
534  and domain in the From header (or To header for AORs). If
535  an exact match on both username and domain/realm fails, the
536  match is retried with just the username.
537  </para>
538  </enum>
539  <enum name="auth_username">
540  <para>Matches the endpoint or AOR ID based on the username
541  and realm in the Authentication header. If an exact match
542  on both username and domain/realm fails, the match is
543  retried with just the username.
544  </para>
545  <note><para>This method of identification has some security
546  considerations because an Authentication header is not
547  present on the first message of a dialog when digest
548  authentication is used. The client can't generate it until
549  the server sends the challenge in a 401 response. Since
550  Asterisk normally sends a security event when an incoming
551  request can't be matched to an endpoint, using this method
552  requires that the security event be deferred until a request
553  is received with the Authentication header and only
554  generated if the username doesn't result in a match. This
555  may result in a delay before an attack is recognized. You
556  can control how many unmatched requests are received from
557  a single ip address before a security event is generated
558  using the <literal>unidentified_request</literal>
559  parameters in the "global" configuration object.
560  </para></note>
561  </enum>
562  <enum name="ip">
563  <para>Matches the endpoint based on the source IP address.
564  </para>
565  <para>This method of identification is not configured here
566  but simply allowed by this configuration option. See the
567  documentation for the <literal>identify</literal>
568  configuration section for more details on this method of
569  endpoint identification.
570  </para>
571  </enum>
572  <enum name="header">
573  <para>Matches the endpoint based on a configured SIP header
574  value.
575  </para>
576  <para>This method of identification is not configured here
577  but simply allowed by this configuration option. See the
578  documentation for the <literal>identify</literal>
579  configuration section for more details on this method of
580  endpoint identification.
581  </para>
582  </enum>
583  </enumlist>
584  </description>
585  </configOption>
586  <configOption name="redirect_method">
587  <synopsis>How redirects received from an endpoint are handled</synopsis>
588  <description><para>
589  When a redirect is received from an endpoint there are multiple ways it can be handled.
590  If this option is set to <literal>user</literal> the user portion of the redirect target
591  is treated as an extension within the dialplan and dialed using a Local channel. If this option
592  is set to <literal>uri_core</literal> the target URI is returned to the dialing application
593  which dials it using the PJSIP channel driver and endpoint originally used. If this option is
594  set to <literal>uri_pjsip</literal> the redirect occurs within chan_pjsip itself and is not exposed
595  to the core at all. The <literal>uri_pjsip</literal> option has the benefit of being more efficient
596  and also supporting multiple potential redirect targets. The con is that since redirection occurs
597  within chan_pjsip redirecting information is not forwarded and redirection can not be
598  prevented.
599  </para>
600  <enumlist>
601  <enum name="user" />
602  <enum name="uri_core" />
603  <enum name="uri_pjsip" />
604  </enumlist>
605  </description>
606  </configOption>
607  <configOption name="mailboxes">
608  <synopsis>NOTIFY the endpoint when state changes for any of the specified mailboxes</synopsis>
609  <description><para>
610  Asterisk will send unsolicited MWI NOTIFY messages to the endpoint when state
611  changes happen for any of the specified mailboxes. More than one mailbox can be
612  specified with a comma-delimited string. app_voicemail mailboxes must be specified
613  as mailbox@context; for example: mailboxes=6001@default. For mailboxes provided by
614  external sources, such as through the res_mwi_external module, you must specify
615  strings supported by the external system.
616  </para><para>
617  For endpoints that SUBSCRIBE for MWI, use the <literal>mailboxes</literal> option in your AOR
618  configuration.
619  </para></description>
620  </configOption>
621  <configOption name="mwi_subscribe_replaces_unsolicited">
622  <synopsis>An MWI subscribe will replace sending unsolicited NOTIFYs</synopsis>
623  </configOption>
624  <configOption name="voicemail_extension">
625  <synopsis>The voicemail extension to send in the NOTIFY Message-Account header</synopsis>
626  </configOption>
627  <configOption name="moh_suggest" default="default">
628  <synopsis>Default Music On Hold class</synopsis>
629  </configOption>
630  <configOption name="outbound_auth">
631  <synopsis>Authentication object(s) used for outbound requests</synopsis>
632  <description><para>
633  This is a comma-delimited list of <replaceable>auth</replaceable>
634  sections defined in <filename>pjsip.conf</filename> used to respond
635  to outbound connection authentication challenges.</para>
636  <note><para>
637  Using the same auth section for inbound and outbound
638  authentication is not recommended. There is a difference in
639  meaning for an empty realm setting between inbound and outbound
640  authentication uses. See the auth realm description for details.
641  </para></note>
642  </description>
643  </configOption>
644  <configOption name="outbound_proxy">
645  <synopsis>Full SIP URI of the outbound proxy used to send requests</synopsis>
646  </configOption>
647  <configOption name="rewrite_contact">
648  <synopsis>Allow Contact header to be rewritten with the source IP address-port</synopsis>
649  <description><para>
650  On inbound SIP messages from this endpoint, the Contact header or an
651  appropriate Record-Route header will be changed to have the source IP
652  address and port. This option does not affect outbound messages sent to
653  this endpoint. This option helps servers communicate with endpoints
654  that are behind NATs. This option also helps reuse reliable transport
655  connections such as TCP and TLS.
656  </para></description>
657  </configOption>
658  <configOption name="rtp_ipv6" default="no">
659  <synopsis>Allow use of IPv6 for RTP traffic</synopsis>
660  </configOption>
661  <configOption name="rtp_symmetric" default="no">
662  <synopsis>Enforce that RTP must be symmetric</synopsis>
663  </configOption>
664  <configOption name="send_diversion" default="yes">
665  <synopsis>Send the Diversion header, conveying the diversion
666  information to the called user agent</synopsis>
667  </configOption>
668  <configOption name="send_history_info" default="no">
669  <synopsis>Send the History-Info header, conveying the diversion
670  information to the called and calling user agents</synopsis>
671  </configOption>
672  <configOption name="send_pai" default="no">
673  <synopsis>Send the P-Asserted-Identity header</synopsis>
674  </configOption>
675  <configOption name="send_rpid" default="no">
676  <synopsis>Send the Remote-Party-ID header</synopsis>
677  </configOption>
678  <configOption name="rpid_immediate" default="no">
679  <synopsis>Immediately send connected line updates on unanswered incoming calls.</synopsis>
680  <description>
681  <para>When enabled, immediately send <emphasis>180 Ringing</emphasis>
682  or <emphasis>183 Progress</emphasis> response messages to the
683  caller if the connected line information is updated before
684  the call is answered. This can send a <emphasis>180 Ringing</emphasis>
685  response before the call has even reached the far end. The
686  caller can start hearing ringback before the far end even gets
687  the call. Many phones tend to grab the first connected line
688  information and refuse to update the display if it changes. The
689  first information is not likely to be correct if the call
690  goes to an endpoint not under the control of this Asterisk
691  box.</para>
692  <para>When disabled, a connected line update must wait for
693  another reason to send a message with the connected line
694  information to the caller before the call is answered. You can
695  trigger the sending of the information by using an appropriate
696  dialplan application such as <emphasis>Ringing</emphasis>.</para>
697  </description>
698  </configOption>
699  <configOption name="timers_min_se" default="90">
700  <synopsis>Minimum session timers expiration period</synopsis>
701  <description><para>
702  Minimum session timer expiration period. Time in seconds.
703  </para></description>
704  </configOption>
705  <configOption name="timers" default="yes">
706  <synopsis>Session timers for SIP packets</synopsis>
707  <description>
708  <enumlist>
709  <enum name="no" />
710  <enum name="yes" />
711  <enum name="required" />
712  <enum name="always" />
713  <enum name="forced"><para>Alias of always</para></enum>
714  </enumlist>
715  </description>
716  </configOption>
717  <configOption name="timers_sess_expires" default="1800">
718  <synopsis>Maximum session timer expiration period</synopsis>
719  <description><para>
720  Maximum session timer expiration period. Time in seconds.
721  </para></description>
722  </configOption>
723  <configOption name="transport">
724  <synopsis>Explicit transport configuration to use</synopsis>
725  <description>
726  <para>This will <emphasis>force</emphasis> the endpoint to use the
727  specified transport configuration to send SIP messages. You need
728  to already know what kind of transport (UDP/TCP/IPv4/etc) the
729  endpoint device will use.
730  </para>
731  <note><para>Not specifying a transport will select the first
732  configured transport in <filename>pjsip.conf</filename> which is
733  compatible with the URI we are trying to contact.
734  </para></note>
735  <warning><para>Transport configuration is not affected by reloads. In order to
736  change transports, a full Asterisk restart is required</para></warning>
737  </description>
738  </configOption>
739  <configOption name="trust_id_inbound" default="no">
740  <synopsis>Accept identification information received from this endpoint</synopsis>
741  <description><para>This option determines whether Asterisk will accept
742  identification from the endpoint from headers such as P-Asserted-Identity
743  or Remote-Party-ID header. This option applies both to calls originating from the
744  endpoint and calls originating from Asterisk. If <literal>no</literal>, the
745  configured Caller-ID from pjsip.conf will always be used as the identity for
746  the endpoint.</para></description>
747  </configOption>
748  <configOption name="trust_id_outbound" default="no">
749  <synopsis>Send private identification details to the endpoint.</synopsis>
750  <description><para>This option determines whether res_pjsip will send private
751  identification information to the endpoint. If <literal>no</literal>,
752  private Caller-ID information will not be forwarded to the endpoint.
753  "Private" in this case refers to any method of restricting identification.
754  Example: setting <replaceable>callerid_privacy</replaceable> to any
755  <literal>prohib</literal> variation.
756  Example: If <replaceable>trust_id_inbound</replaceable> is set to
757  <literal>yes</literal>, the presence of a <literal>Privacy: id</literal>
758  header in a SIP request or response would indicate the identification
759  provided in the request is private.</para></description>
760  </configOption>
761  <configOption name="type">
762  <synopsis>Must be of type 'endpoint'.</synopsis>
763  </configOption>
764  <configOption name="use_ptime" default="no">
765  <synopsis>Use Endpoint's requested packetization interval</synopsis>
766  </configOption>
767  <configOption name="use_avpf" default="no">
768  <synopsis>Determines whether res_pjsip will use and enforce usage of AVPF for this
769  endpoint.</synopsis>
770  <description><para>
771  If set to <literal>yes</literal>, res_pjsip will use the AVPF or SAVPF RTP
772  profile for all media offers on outbound calls and media updates and will
773  decline media offers not using the AVPF or SAVPF profile.
774  </para><para>
775  If set to <literal>no</literal>, res_pjsip will use the AVP or SAVP RTP
776  profile for all media offers on outbound calls and media updates, and will
777  decline media offers not using the AVP or SAVP profile.
778  </para></description>
779  </configOption>
780  <configOption name="force_avp" default="no">
781  <synopsis>Determines whether res_pjsip will use and enforce usage of AVP,
782  regardless of the RTP profile in use for this endpoint.</synopsis>
783  <description><para>
784  If set to <literal>yes</literal>, res_pjsip will use the AVP, AVPF, SAVP, or
785  SAVPF RTP profile for all media offers on outbound calls and media updates including
786  those for DTLS-SRTP streams.
787  </para><para>
788  If set to <literal>no</literal>, res_pjsip will use the respective RTP profile
789  depending on configuration.
790  </para></description>
791  </configOption>
792  <configOption name="media_use_received_transport" default="no">
793  <synopsis>Determines whether res_pjsip will use the media transport received in the
794  offer SDP in the corresponding answer SDP.</synopsis>
795  <description><para>
796  If set to <literal>yes</literal>, res_pjsip will use the received media transport.
797  </para><para>
798  If set to <literal>no</literal>, res_pjsip will use the respective RTP profile
799  depending on configuration.
800  </para></description>
801  </configOption>
802  <configOption name="media_encryption" default="no">
803  <synopsis>Determines whether res_pjsip will use and enforce usage of media encryption
804  for this endpoint.</synopsis>
805  <description>
806  <enumlist>
807  <enum name="no"><para>
808  res_pjsip will offer no encryption and allow no encryption to be setup.
809  </para></enum>
810  <enum name="sdes"><para>
811  res_pjsip will offer standard SRTP setup via in-SDP keys. Encrypted SIP
812  transport should be used in conjunction with this option to prevent
813  exposure of media encryption keys.
814  </para></enum>
815  <enum name="dtls"><para>
816  res_pjsip will offer DTLS-SRTP setup.
817  </para></enum>
818  </enumlist>
819  </description>
820  </configOption>
821  <configOption name="media_encryption_optimistic" default="no">
822  <synopsis>Determines whether encryption should be used if possible but does not terminate the
823  session if not achieved.</synopsis>
824  <description><para>
825  This option only applies if <replaceable>media_encryption</replaceable> is
826  set to <literal>sdes</literal> or <literal>dtls</literal>.
827  </para></description>
828  </configOption>
829  <configOption name="g726_non_standard" default="no">
830  <synopsis>Force g.726 to use AAL2 packing order when negotiating g.726 audio</synopsis>
831  <description><para>
832  When set to "yes" and an endpoint negotiates g.726 audio then use g.726 for AAL2
833  packing order instead of what is recommended by RFC3551. Since this essentially
834  replaces the underlying 'g726' codec with 'g726aal2' then 'g726aal2' needs to be
835  specified in the endpoint's allowed codec list.
836  </para></description>
837  </configOption>
838  <configOption name="inband_progress" default="no">
839  <synopsis>Determines whether chan_pjsip will indicate ringing using inband
840  progress.</synopsis>
841  <description><para>
842  If set to <literal>yes</literal>, chan_pjsip will send a 183 Session Progress
843  when told to indicate ringing and will immediately start sending ringing
844  as audio.
845  </para><para>
846  If set to <literal>no</literal>, chan_pjsip will send a 180 Ringing when told
847  to indicate ringing and will NOT send it as audio.
848  </para></description>
849  </configOption>
850  <configOption name="call_group">
851  <synopsis>The numeric pickup groups for a channel.</synopsis>
852  <description><para>
853  Can be set to a comma separated list of numbers or ranges between the values
854  of 0-63 (maximum of 64 groups).
855  </para></description>
856  </configOption>
857  <configOption name="pickup_group">
858  <synopsis>The numeric pickup groups that a channel can pickup.</synopsis>
859  <description><para>
860  Can be set to a comma separated list of numbers or ranges between the values
861  of 0-63 (maximum of 64 groups).
862  </para></description>
863  </configOption>
864  <configOption name="named_call_group">
865  <synopsis>The named pickup groups for a channel.</synopsis>
866  <description><para>
867  Can be set to a comma separated list of case sensitive strings limited by
868  supported line length.
869  </para></description>
870  </configOption>
871  <configOption name="named_pickup_group">
872  <synopsis>The named pickup groups that a channel can pickup.</synopsis>
873  <description><para>
874  Can be set to a comma separated list of case sensitive strings limited by
875  supported line length.
876  </para></description>
877  </configOption>
878  <configOption name="device_state_busy_at" default="0">
879  <synopsis>The number of in-use channels which will cause busy to be returned as device state</synopsis>
880  <description><para>
881  When the number of in-use channels for the endpoint matches the devicestate_busy_at setting the
882  PJSIP channel driver will return busy as the device state instead of in use.
883  </para></description>
884  </configOption>
885  <configOption name="t38_udptl" default="no">
886  <synopsis>Whether T.38 UDPTL support is enabled or not</synopsis>
887  <description><para>
888  If set to yes T.38 UDPTL support will be enabled, and T.38 negotiation requests will be accepted
889  and relayed.
890  </para></description>
891  </configOption>
892  <configOption name="t38_udptl_ec" default="none">
893  <synopsis>T.38 UDPTL error correction method</synopsis>
894  <description>
895  <enumlist>
896  <enum name="none"><para>
897  No error correction should be used.
898  </para></enum>
899  <enum name="fec"><para>
900  Forward error correction should be used.
901  </para></enum>
902  <enum name="redundancy"><para>
903  Redundancy error correction should be used.
904  </para></enum>
905  </enumlist>
906  </description>
907  </configOption>
908  <configOption name="t38_udptl_maxdatagram" default="0">
909  <synopsis>T.38 UDPTL maximum datagram size</synopsis>
910  <description><para>
911  This option can be set to override the maximum datagram of a remote endpoint for broken
912  endpoints.
913  </para></description>
914  </configOption>
915  <configOption name="fax_detect" default="no">
916  <synopsis>Whether CNG tone detection is enabled</synopsis>
917  <description><para>
918  This option can be set to send the session to the fax extension when a CNG tone is
919  detected.
920  </para></description>
921  </configOption>
922  <configOption name="fax_detect_timeout">
923  <synopsis>How long into a call before fax_detect is disabled for the call</synopsis>
924  <description><para>
925  The option determines how many seconds into a call before the
926  fax_detect option is disabled for the call. Setting the value
927  to zero disables the timeout.
928  </para></description>
929  </configOption>
930  <configOption name="t38_udptl_nat" default="no">
931  <synopsis>Whether NAT support is enabled on UDPTL sessions</synopsis>
932  <description><para>
933  When enabled the UDPTL stack will send UDPTL packets to the source address of
934  received packets.
935  </para></description>
936  </configOption>
937  <configOption name="t38_udptl_ipv6" default="no">
938  <synopsis>Whether IPv6 is used for UDPTL Sessions</synopsis>
939  <description><para>
940  When enabled the UDPTL stack will use IPv6.
941  </para></description>
942  </configOption>
943  <configOption name="t38_bind_udptl_to_media_address" default="no">
944  <synopsis>Bind the UDPTL instance to the media_adress</synopsis>
945  <description><para>
946  If media_address is specified, this option causes the UDPTL instance to be bound to
947  the specified ip address which causes the packets to be sent from that address.
948  </para></description>
949  </configOption>
950  <configOption name="tone_zone">
951  <synopsis>Set which country's indications to use for channels created for this endpoint.</synopsis>
952  </configOption>
953  <configOption name="language">
954  <synopsis>Set the default language to use for channels created for this endpoint.</synopsis>
955  </configOption>
956  <configOption name="one_touch_recording" default="no">
957  <synopsis>Determines whether one-touch recording is allowed for this endpoint.</synopsis>
958  <see-also>
959  <ref type="configOption">record_on_feature</ref>
960  <ref type="configOption">record_off_feature</ref>
961  </see-also>
962  </configOption>
963  <configOption name="record_on_feature" default="automixmon">
964  <synopsis>The feature to enact when one-touch recording is turned on.</synopsis>
965  <description>
966  <para>When an INFO request for one-touch recording arrives with a Record header set to "on", this
967  feature will be enabled for the channel. The feature designated here can be any built-in
968  or dynamic feature defined in features.conf.</para>
969  <note><para>This setting has no effect if the endpoint's one_touch_recording option is disabled</para></note>
970  </description>
971  <see-also>
972  <ref type="configOption">one_touch_recording</ref>
973  <ref type="configOption">record_off_feature</ref>
974  </see-also>
975  </configOption>
976  <configOption name="record_off_feature" default="automixmon">
977  <synopsis>The feature to enact when one-touch recording is turned off.</synopsis>
978  <description>
979  <para>When an INFO request for one-touch recording arrives with a Record header set to "off", this
980  feature will be enabled for the channel. The feature designated here can be any built-in
981  or dynamic feature defined in features.conf.</para>
982  <note><para>This setting has no effect if the endpoint's one_touch_recording option is disabled</para></note>
983  </description>
984  <see-also>
985  <ref type="configOption">one_touch_recording</ref>
986  <ref type="configOption">record_on_feature</ref>
987  </see-also>
988  </configOption>
989  <configOption name="rtp_engine" default="asterisk">
990  <synopsis>Name of the RTP engine to use for channels created for this endpoint</synopsis>
991  </configOption>
992  <configOption name="allow_transfer" default="yes">
993  <synopsis>Determines whether SIP REFER transfers are allowed for this endpoint</synopsis>
994  </configOption>
995  <configOption name="user_eq_phone" default="no">
996  <synopsis>Determines whether a user=phone parameter is placed into the request URI if the user is determined to be a phone number</synopsis>
997  </configOption>
998  <configOption name="moh_passthrough" default="no">
999  <synopsis>Determines whether hold and unhold will be passed through using re-INVITEs with recvonly and sendrecv to the remote side</synopsis>
1000  </configOption>
1001  <configOption name="sdp_owner" default="-">
1002  <synopsis>String placed as the username portion of an SDP origin (o=) line.</synopsis>
1003  </configOption>
1004  <configOption name="sdp_session" default="Asterisk">
1005  <synopsis>String used for the SDP session (s=) line.</synopsis>
1006  </configOption>
1007  <configOption name="tos_audio">
1008  <synopsis>DSCP TOS bits for audio streams</synopsis>
1009  <description><para>
1010  See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
1011  </para></description>
1012  </configOption>
1013  <configOption name="tos_video">
1014  <synopsis>DSCP TOS bits for video streams</synopsis>
1015  <description><para>
1016  See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
1017  </para></description>
1018  </configOption>
1019  <configOption name="cos_audio">
1020  <synopsis>Priority for audio streams</synopsis>
1021  <description><para>
1022  See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
1023  </para></description>
1024  </configOption>
1025  <configOption name="cos_video">
1026  <synopsis>Priority for video streams</synopsis>
1027  <description><para>
1028  See https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service for more information about QoS settings
1029  </para></description>
1030  </configOption>
1031  <configOption name="allow_subscribe" default="yes">
1032  <synopsis>Determines if endpoint is allowed to initiate subscriptions with Asterisk.</synopsis>
1033  </configOption>
1034  <configOption name="sub_min_expiry" default="60">
1035  <synopsis>The minimum allowed expiry time for subscriptions initiated by the endpoint.</synopsis>
1036  </configOption>
1037  <configOption name="from_user">
1038  <synopsis>Username to use in From header for requests to this endpoint.</synopsis>
1039  </configOption>
1040  <configOption name="mwi_from_user">
1041  <synopsis>Username to use in From header for unsolicited MWI NOTIFYs to this endpoint.</synopsis>
1042  </configOption>
1043  <configOption name="from_domain">
1044  <synopsis>Domain to user in From header for requests to this endpoint.</synopsis>
1045  </configOption>
1046  <configOption name="dtls_verify">
1047  <synopsis>Verify that the provided peer certificate is valid</synopsis>
1048  <description><para>
1049  This option only applies if <replaceable>media_encryption</replaceable> is
1050  set to <literal>dtls</literal>.
1051  </para><para>
1052  It can be one of the following values:
1053  </para><enumlist>
1054  <enum name="no"><para>
1055  meaning no verificaton is done.
1056  </para></enum>
1057  <enum name="fingerprint"><para>
1058  meaning to verify the remote fingerprint.
1059  </para></enum>
1060  <enum name="certificate"><para>
1061  meaning to verify the remote certificate.
1062  </para></enum>
1063  <enum name="yes"><para>
1064  meaning to verify both the remote fingerprint and certificate.
1065  </para></enum>
1066  </enumlist>
1067  </description>
1068  </configOption>
1069  <configOption name="dtls_rekey">
1070  <synopsis>Interval at which to renegotiate the TLS session and rekey the SRTP session</synopsis>
1071  <description><para>
1072  This option only applies if <replaceable>media_encryption</replaceable> is
1073  set to <literal>dtls</literal>.
1074  </para><para>
1075  If this is not set or the value provided is 0 rekeying will be disabled.
1076  </para></description>
1077  </configOption>
1078  <configOption name="dtls_auto_generate_cert" default="no">
1079  <synopsis>Whether or not to automatically generate an ephemeral X.509 certificate</synopsis>
1080  <description>
1081  <para>
1082  If enabled, Asterisk will generate an X.509 certificate for each DTLS session.
1083  This option only applies if <replaceable>media_encryption</replaceable> is set
1084  to <literal>dtls</literal>. This option will be automatically enabled if
1085  <literal>webrtc</literal> is enabled and <literal>dtls_cert_file</literal> is
1086  not specified.
1087  </para>
1088  </description>
1089  </configOption>
1090  <configOption name="dtls_cert_file">
1091  <synopsis>Path to certificate file to present to peer</synopsis>
1092  <description><para>
1093  This option only applies if <replaceable>media_encryption</replaceable> is
1094  set to <literal>dtls</literal>.
1095  </para></description>
1096  </configOption>
1097  <configOption name="dtls_private_key">
1098  <synopsis>Path to private key for certificate file</synopsis>
1099  <description><para>
1100  This option only applies if <replaceable>media_encryption</replaceable> is
1101  set to <literal>dtls</literal>.
1102  </para></description>
1103  </configOption>
1104  <configOption name="dtls_cipher">
1105  <synopsis>Cipher to use for DTLS negotiation</synopsis>
1106  <description><para>
1107  This option only applies if <replaceable>media_encryption</replaceable> is
1108  set to <literal>dtls</literal>.
1109  </para>
1110  <para>Many options for acceptable ciphers. See link for more:</para>
1111  <para>http://www.openssl.org/docs/apps/ciphers.html#CIPHER_STRINGS
1112  </para></description>
1113  </configOption>
1114  <configOption name="dtls_ca_file">
1115  <synopsis>Path to certificate authority certificate</synopsis>
1116  <description><para>
1117  This option only applies if <replaceable>media_encryption</replaceable> is
1118  set to <literal>dtls</literal>.
1119  </para></description>
1120  </configOption>
1121  <configOption name="dtls_ca_path">
1122  <synopsis>Path to a directory containing certificate authority certificates</synopsis>
1123  <description><para>
1124  This option only applies if <replaceable>media_encryption</replaceable> is
1125  set to <literal>dtls</literal>.
1126  </para></description>
1127  </configOption>
1128  <configOption name="dtls_setup">
1129  <synopsis>Whether we are willing to accept connections, connect to the other party, or both.</synopsis>
1130  <description>
1131  <para>
1132  This option only applies if <replaceable>media_encryption</replaceable> is
1133  set to <literal>dtls</literal>.
1134  </para>
1135  <enumlist>
1136  <enum name="active"><para>
1137  res_pjsip will make a connection to the peer.
1138  </para></enum>
1139  <enum name="passive"><para>
1140  res_pjsip will accept connections from the peer.
1141  </para></enum>
1142  <enum name="actpass"><para>
1143  res_pjsip will offer and accept connections from the peer.
1144  </para></enum>
1145  </enumlist>
1146  </description>
1147  </configOption>
1148  <configOption name="dtls_fingerprint">
1149  <synopsis>Type of hash to use for the DTLS fingerprint in the SDP.</synopsis>
1150  <description>
1151  <para>
1152  This option only applies if <replaceable>media_encryption</replaceable> is
1153  set to <literal>dtls</literal>.
1154  </para>
1155  <enumlist>
1156  <enum name="SHA-256"></enum>
1157  <enum name="SHA-1"></enum>
1158  </enumlist>
1159  </description>
1160  </configOption>
1161  <configOption name="srtp_tag_32">
1162  <synopsis>Determines whether 32 byte tags should be used instead of 80 byte tags.</synopsis>
1163  <description><para>
1164  This option only applies if <replaceable>media_encryption</replaceable> is
1165  set to <literal>sdes</literal> or <literal>dtls</literal>.
1166  </para></description>
1167  </configOption>
1168  <configOption name="set_var">
1169  <synopsis>Variable set on a channel involving the endpoint.</synopsis>
1170  <description><para>
1171  When a new channel is created using the endpoint set the specified
1172  variable(s) on that channel. For multiple channel variables specify
1173  multiple 'set_var'(s).
1174  </para></description>
1175  </configOption>
1176  <configOption name="message_context">
1177  <synopsis>Context to route incoming MESSAGE requests to.</synopsis>
1178  <description><para>
1179  If specified, incoming MESSAGE requests will be routed to the indicated
1180  dialplan context. If no <replaceable>message_context</replaceable> is
1181  specified, then the <replaceable>context</replaceable> setting is used.
1182  </para></description>
1183  </configOption>
1184  <configOption name="accountcode">
1185  <synopsis>An accountcode to set automatically on any channels created for this endpoint.</synopsis>
1186  <description><para>
1187  If specified, any channel created for this endpoint will automatically
1188  have this accountcode set on it.
1189  </para></description>
1190  </configOption>
1191  <configOption name="preferred_codec_only" default="no">
1192  <synopsis>Respond to a SIP invite with the single most preferred codec (DEPRECATED)</synopsis>
1193  <description><para>Respond to a SIP invite with the single most preferred codec
1194  rather than advertising all joint codec capabilities. This limits the other side's codec
1195  choice to exactly what we prefer.</para>
1196  <warning><para>This option has been deprecated in favor of
1197  <literal>incoming_call_offer_pref</literal>. Setting both options is unsupported.</para>
1198  </warning>
1199  </description>
1200  <see-also>
1201  <ref type="configOption">incoming_call_offer_pref</ref>
1202  </see-also>
1203  </configOption>
1204  <configOption name="incoming_call_offer_pref" default="local">
1205  <synopsis>Preferences for selecting codecs for an incoming call.</synopsis>
1206  <description>
1207  <para>Based on this setting, a joint list of preferred codecs between those
1208  received in an incoming SDP offer (remote), and those specified in the
1209  endpoint's "allow" parameter (local) es created and is passed to the Asterisk
1210  core. </para>
1211  <note><para>This list will consist of only those codecs found in both lists.</para></note>
1212  <enumlist>
1213  <enum name="local"><para>
1214  Include all codecs in the local list that are also in the remote list
1215  preserving the local order. (default).
1216  </para></enum>
1217  <enum name="local_first"><para>
1218  Include only the first codec in the local list that is also in the remote list.
1219  </para></enum>
1220  <enum name="remote"><para>
1221  Include all codecs in the remote list that are also in the local list
1222  preserving the remote order.
1223  </para></enum>
1224  <enum name="remote_first"><para>
1225  Include only the first codec in the remote list that is also in the local list.
1226  </para></enum>
1227  </enumlist>
1228  </description>
1229  </configOption>
1230  <configOption name="outgoing_call_offer_pref" default="remote_merge">
1231  <synopsis>Preferences for selecting codecs for an outgoing call.</synopsis>
1232  <description>
1233  <para>Based on this setting, a joint list of preferred codecs between
1234  those received from the Asterisk core (remote), and those specified in
1235  the endpoint's "allow" parameter (local) is created and is used to create
1236  the outgoing SDP offer.</para>
1237  <enumlist>
1238  <enum name="local"><para>
1239  Include all codecs in the local list that are also in the remote list
1240  preserving the local order.
1241  </para></enum>
1242  <enum name="local_merge"><para>
1243  Include all codecs in the local list preserving the local order.
1244  </para></enum>
1245  <enum name="local_first"><para>
1246  Include only the first codec in the local list.
1247  </para></enum>
1248  <enum name="remote"><para>
1249  Include all codecs in the remote list that are also in the local list
1250  preserving the remote order.
1251  </para></enum>
1252  <enum name="remote_merge"><para>
1253  Include all codecs in the local list preserving the remote order. (default)
1254  </para></enum>
1255  <enum name="remote_first"><para>
1256  Include only the first codec in the remote list that is also in the local list.
1257  </para></enum>
1258  </enumlist>
1259  </description>
1260  </configOption>
1261  <configOption name="rtp_keepalive">
1262  <synopsis>Number of seconds between RTP comfort noise keepalive packets.</synopsis>
1263  <description><para>
1264  At the specified interval, Asterisk will send an RTP comfort noise frame. This may
1265  be useful for situations where Asterisk is behind a NAT or firewall and must keep
1266  a hole open in order to allow for media to arrive at Asterisk.
1267  </para></description>
1268  </configOption>
1269  <configOption name="rtp_timeout" default="0">
1270  <synopsis>Maximum number of seconds without receiving RTP (while off hold) before terminating call.</synopsis>
1271  <description><para>
1272  This option configures the number of seconds without RTP (while off hold) before
1273  considering a channel as dead. When the number of seconds is reached the underlying
1274  channel is hung up. By default this option is set to 0, which means do not check.
1275  </para></description>
1276  </configOption>
1277  <configOption name="rtp_timeout_hold" default="0">
1278  <synopsis>Maximum number of seconds without receiving RTP (while on hold) before terminating call.</synopsis>
1279  <description><para>
1280  This option configures the number of seconds without RTP (while on hold) before
1281  considering a channel as dead. When the number of seconds is reached the underlying
1282  channel is hung up. By default this option is set to 0, which means do not check.
1283  </para></description>
1284  </configOption>
1285  <configOption name="acl">
1286  <synopsis>List of IP ACL section names in acl.conf</synopsis>
1287  <description><para>
1288  This matches sections configured in <literal>acl.conf</literal>. The value is
1289  defined as a list of comma-delimited section names.
1290  </para></description>
1291  </configOption>
1292  <configOption name="deny">
1293  <synopsis>List of IP addresses to deny access from</synopsis>
1294  <description><para>
1295  The value is a comma-delimited list of IP addresses. IP addresses may
1296  have a subnet mask appended. The subnet mask may be written in either
1297  CIDR or dotted-decimal notation. Separate the IP address and subnet
1298  mask with a slash ('/')
1299  </para></description>
1300  </configOption>
1301  <configOption name="permit">
1302  <synopsis>List of IP addresses to permit access from</synopsis>
1303  <description><para>
1304  The value is a comma-delimited list of IP addresses. IP addresses may
1305  have a subnet mask appended. The subnet mask may be written in either
1306  CIDR or dotted-decimal notation. Separate the IP address and subnet
1307  mask with a slash ('/')
1308  </para></description>
1309  </configOption>
1310  <configOption name="contact_acl">
1311  <synopsis>List of Contact ACL section names in acl.conf</synopsis>
1312  <description><para>
1313  This matches sections configured in <literal>acl.conf</literal>. The value is
1314  defined as a list of comma-delimited section names.
1315  </para></description>
1316  </configOption>
1317  <configOption name="contact_deny">
1318  <synopsis>List of Contact header addresses to deny</synopsis>
1319  <description><para>
1320  The value is a comma-delimited list of IP addresses. IP addresses may
1321  have a subnet mask appended. The subnet mask may be written in either
1322  CIDR or dotted-decimal notation. Separate the IP address and subnet
1323  mask with a slash ('/')
1324  </para></description>
1325  </configOption>
1326  <configOption name="contact_permit">
1327  <synopsis>List of Contact header addresses to permit</synopsis>
1328  <description><para>
1329  The value is a comma-delimited list of IP addresses. IP addresses may
1330  have a subnet mask appended. The subnet mask may be written in either
1331  CIDR or dotted-decimal notation. Separate the IP address and subnet
1332  mask with a slash ('/')
1333  </para></description>
1334  </configOption>
1335  <configOption name="subscribe_context">
1336  <synopsis>Context for incoming MESSAGE requests.</synopsis>
1337  <description><para>
1338  If specified, incoming SUBSCRIBE requests will be searched for the matching
1339  extension in the indicated context.
1340  If no <replaceable>subscribe_context</replaceable> is specified,
1341  then the <replaceable>context</replaceable> setting is used.
1342  </para></description>
1343  </configOption>
1344  <configOption name="contact_user" default="">
1345  <synopsis>Force the user on the outgoing Contact header to this value.</synopsis>
1346  <description><para>
1347  On outbound requests, force the user portion of the Contact header to this value.
1348  </para></description>
1349  </configOption>
1350  <configOption name="asymmetric_rtp_codec" default="no">
1351  <synopsis>Allow the sending and receiving RTP codec to differ</synopsis>
1352  <description><para>
1353  When set to "yes" the codec in use for sending will be allowed to differ from
1354  that of the received one. PJSIP will not automatically switch the sending one
1355  to the receiving one.
1356  </para></description>
1357  </configOption>
1358  <configOption name="rtcp_mux" default="no">
1359  <synopsis>Enable RFC 5761 RTCP multiplexing on the RTP port</synopsis>
1360  <description><para>
1361  With this option enabled, Asterisk will attempt to negotiate the use of the "rtcp-mux"
1362  attribute on all media streams. This will result in RTP and RTCP being sent and received
1363  on the same port. This shifts the demultiplexing logic to the application rather than
1364  the transport layer. This option is useful when interoperating with WebRTC endpoints
1365  since they mandate this option's use.
1366  </para></description>
1367  </configOption>
1368  <configOption name="refer_blind_progress" default="yes">
1369  <synopsis>Whether to notifies all the progress details on blind transfer</synopsis>
1370  <description><para>
1371  Some SIP phones (Mitel/Aastra, Snom) expect a sip/frag "200 OK"
1372  after REFER has been accepted. If set to <literal>no</literal> then asterisk
1373  will not send the progress details, but immediately will send "200 OK".
1374  </para></description>
1375  </configOption>
1376  <configOption name="notify_early_inuse_ringing" default="no">
1377  <synopsis>Whether to notifies dialog-info 'early' on InUse&amp;Ringing state</synopsis>
1378  <description><para>
1379  Control whether dialog-info subscriptions get 'early' state
1380  on Ringing when already INUSE.
1381  </para></description>
1382  </configOption>
1383  <configOption name="max_audio_streams" default="1">
1384  <synopsis>The maximum number of allowed audio streams for the endpoint</synopsis>
1385  <description><para>
1386  This option enforces a limit on the maximum simultaneous negotiated audio
1387  streams allowed for the endpoint.
1388  </para></description>
1389  </configOption>
1390  <configOption name="max_video_streams" default="1">
1391  <synopsis>The maximum number of allowed video streams for the endpoint</synopsis>
1392  <description><para>
1393  This option enforces a limit on the maximum simultaneous negotiated video
1394  streams allowed for the endpoint.
1395  </para></description>
1396  </configOption>
1397  <configOption name="bundle" default="no">
1398  <synopsis>Enable RTP bundling</synopsis>
1399  <description><para>
1400  With this option enabled, Asterisk will attempt to negotiate the use of bundle.
1401  If negotiated this will result in multiple RTP streams being carried over the same
1402  underlying transport. Note that enabling bundle will also enable the rtcp_mux option.
1403  </para></description>
1404  </configOption>
1405  <configOption name="webrtc" default="no">
1406  <synopsis>Defaults and enables some options that are relevant to WebRTC</synopsis>
1407  <description><para>
1408  When set to "yes" this also enables the following values that are needed in
1409  order for basic WebRTC support to work: rtcp_mux, use_avpf, ice_support, and
1410  use_received_transport. The following configuration settings also get defaulted
1411  as follows:</para>
1412  <para>media_encryption=dtls</para>
1413  <para>dtls_auto_generate_cert=yes (if dtls_cert_file is not set)</para>
1414  <para>dtls_verify=fingerprint</para>
1415  <para>dtls_setup=actpass</para>
1416  </description>
1417  </configOption>
1418  <configOption name="incoming_mwi_mailbox">
1419  <synopsis>Mailbox name to use when incoming MWI NOTIFYs are received</synopsis>
1420  <description><para>
1421  If an MWI NOTIFY is received <emphasis>from</emphasis> this endpoint,
1422  this mailbox will be used when notifying other modules of MWI status
1423  changes. If not set, incoming MWI NOTIFYs are ignored.
1424  </para></description>
1425  </configOption>
1426  <configOption name="follow_early_media_fork">
1427  <synopsis>Follow SDP forked media when To tag is different</synopsis>
1428  <description><para>
1429  On outgoing calls, if the UAS responds with different SDP attributes
1430  on subsequent 18X or 2XX responses (such as a port update) AND the
1431  To tag on the subsequent response is different than that on the previous
1432  one, follow it. This usually happens when the INVITE is forked to multiple
1433  UASs and more than one sends an SDP answer.
1434  </para>
1435  <note><para>
1436  This option must also be enabled in the <literal>system</literal>
1437  section for it to take effect here.
1438  </para></note>
1439  </description>
1440  </configOption>
1441  <configOption name="accept_multiple_sdp_answers" default="no">
1442  <synopsis>Accept multiple SDP answers on non-100rel responses</synopsis>
1443  <description><para>
1444  On outgoing calls, if the UAS responds with different SDP attributes
1445  on non-100rel 18X or 2XX responses (such as a port update) AND the
1446  To tag on the subsequent response is the same as that on the previous one,
1447  process the updated SDP. This can happen when the UAS needs to change ports
1448  for some reason such as using a separate port for custom ringback.
1449  </para>
1450  <note><para>
1451  This option must also be enabled in the <literal>system</literal>
1452  section for it to take effect here.
1453  </para></note>
1454  </description>
1455  </configOption>
1456  <configOption name="suppress_q850_reason_headers" default="no">
1457  <synopsis>Suppress Q.850 Reason headers for this endpoint</synopsis>
1458  <description><para>
1459  Some devices can't accept multiple Reason headers and get confused
1460  when both 'SIP' and 'Q.850' Reason headers are received. This
1461  option allows the 'Q.850' Reason header to be suppressed.</para>
1462  </description>
1463  </configOption>
1464  <configOption name="ignore_183_without_sdp" default="no">
1465  <synopsis>Do not forward 183 when it doesn't contain SDP</synopsis>
1466  <description><para>
1467  Certain SS7 internetworking scenarios can result in a 183
1468  to be generated for reasons other than early media. Forwarding
1469  this 183 can cause loss of ringback tone. This flag emulates
1470  the behavior of chan_sip and prevents these 183 responses from
1471  being forwarded.</para>
1472  </description>
1473  </configOption>
1474  <configOption name="stir_shaken" default="no">
1475  <synopsis>Enable STIR/SHAKEN support on this endpoint</synopsis>
1476  <description><para>
1477  Enable STIR/SHAKEN support on this endpoint. On incoming INVITEs,
1478  the Identity header will be checked for validity. On outgoing
1479  INVITEs, an Identity header will be added.</para>
1480  </description>
1481  </configOption>
1482  <configOption name="allow_unauthenticated_options" default="no">
1483  <synopsis>Skip authentication when receiving OPTIONS requests</synopsis>
1484  <description><para>
1485  RFC 3261 says that the response to an OPTIONS request MUST be the
1486  same had the request been an INVITE. Some UAs use OPTIONS requests
1487  like a 'ping' and the expectation is that they will return a
1488  200 OK.</para>
1489  <para>Enabling <literal>allow_unauthenticated_options</literal>
1490  will skip authentication of OPTIONS requests for the given
1491  endpoint.</para>
1492  <para>There are security implications to enabling this setting as
1493  it can allow information disclosure to occur - specifically, if
1494  enabled, an external party could enumerate and find the endpoint
1495  name by sending OPTIONS requests and examining the
1496  responses.</para>
1497  </description>
1498  </configOption>
1499  </configObject>
1500  <configObject name="auth">
1501  <synopsis>Authentication type</synopsis>
1502  <description><para>
1503  Authentication objects hold the authentication information for use
1504  by other objects such as <literal>endpoints</literal> or <literal>registrations</literal>.
1505  This also allows for multiple objects to use a single auth object. See
1506  the <literal>auth_type</literal> config option for password style choices.
1507  </para></description>
1508  <configOption name="auth_type" default="userpass">
1509  <synopsis>Authentication type</synopsis>
1510  <description><para>
1511  This option specifies which of the password style config options should be read
1512  when trying to authenticate an endpoint inbound request. If set to <literal>userpass</literal>
1513  then we'll read from the 'password' option. For <literal>md5</literal> we'll read
1514  from 'md5_cred'. If set to <literal>google_oauth</literal> then we'll read from the
1515  refresh_token/oauth_clientid/oauth_secret fields. The following values are valid:
1516  </para>
1517  <enumlist>
1518  <enum name="md5"/>
1519  <enum name="userpass"/>
1520  <enum name="google_oauth"/>
1521  </enumlist>
1522  <para>
1523  </para>
1524  <note>
1525  <para>
1526  This setting only describes whether the password is in
1527  plain text or has been pre-hashed with MD5. It doesn't describe
1528  the acceptable digest algorithms we'll accept in a received
1529  challenge.
1530  </para>
1531  </note>
1532  </description>
1533  </configOption>
1534  <configOption name="nonce_lifetime" default="32">
1535  <synopsis>Lifetime of a nonce associated with this authentication config.</synopsis>
1536  </configOption>
1537  <configOption name="md5_cred" default="">
1538  <synopsis>MD5 Hash used for authentication.</synopsis>
1539  <description><para>
1540  Only used when auth_type is <literal>md5</literal>.
1541  As an alternative to specifying a plain text password,
1542  you can hash the username, realm and password
1543  together one time and place the hash value here.
1544  The input to the hash function must be in the
1545  following format:
1546  </para>
1547  <para>
1548  </para>
1549  <para>
1550  &lt;username&gt;:&lt;realm&gt;:&lt;password&gt;
1551  </para>
1552  <para>
1553  </para>
1554  <para>
1555  For incoming authentication (asterisk is the server),
1556  the realm must match either the realm set in this object
1557  or the <variable>default_realm</variable> set in in the
1558  <replaceable>global</replaceable> object.
1559  </para>
1560  <para>
1561  </para>
1562  <para>
1563  For outgoing authentication (asterisk is the UAC),
1564  the realm must match what the server will be sending
1565  in their WWW-Authenticate header. It can't be blank
1566  unless you expect the server to be sending a blank
1567  realm in the header. You can't use pre-hashed
1568  paswords with a wildcard auth object.
1569  You can generate the hash with the following shell
1570  command:
1571  </para>
1572  <para>
1573  </para>
1574  <para>
1575  $ echo -n "myname:myrealm:mypassword" | md5sum
1576  </para>
1577  <para>
1578  </para>
1579  <para>
1580  Note the '-n'. You don't want a newline to be part
1581  of the hash.
1582  </para></description>
1583  </configOption>
1584  <configOption name="password">
1585  <synopsis>Plain text password used for authentication.</synopsis>
1586  <description><para>Only used when auth_type is <literal>userpass</literal>.</para></description>
1587  </configOption>
1588  <configOption name="refresh_token">
1589  <synopsis>OAuth 2.0 refresh token</synopsis>
1590  </configOption>
1591  <configOption name="oauth_clientid">
1592  <synopsis>OAuth 2.0 application's client id</synopsis>
1593  </configOption>
1594  <configOption name="oauth_secret">
1595  <synopsis>OAuth 2.0 application's secret</synopsis>
1596  </configOption>
1597  <configOption name="realm" default="">
1598  <synopsis>SIP realm for endpoint</synopsis>
1599  <description><para>
1600  For incoming authentication (asterisk is the UAS),
1601  this is the realm to be sent on WWW-Authenticate
1602  headers. If not specified, the <replaceable>global</replaceable>
1603  object's <variable>default_realm</variable> will be used.
1604  </para>
1605  <para>
1606  </para>
1607  <para>
1608  For outgoing authentication (asterisk is the UAS), this
1609  must either be the realm the server is expected to send,
1610  or left blank or contain a single '*' to automatically
1611  use the realm sent by the server. If you have multiple
1612  auth object for an endpoint, the realm is also used to
1613  match the auth object to the realm the server sent.
1614  </para>
1615  <para>
1616  </para>
1617  <note>
1618  <para>
1619  Using the same auth section for inbound and outbound
1620  authentication is not recommended. There is a difference in
1621  meaning for an empty realm setting between inbound and outbound
1622  authentication uses.
1623  </para>
1624  </note>
1625  <para>
1626  </para>
1627  <note>
1628  <para>
1629  If more than one auth object with the same realm or
1630  more than one wildcard auth object associated to
1631  an endpoint, we can only use the first one of
1632  each defined on the endpoint.
1633  </para>
1634  </note>
1635  </description>
1636  </configOption>
1637  <configOption name="type">
1638  <synopsis>Must be 'auth'</synopsis>
1639  </configOption>
1640  <configOption name="username">
1641  <synopsis>Username to use for account</synopsis>
1642  </configOption>
1643  </configObject>
1644  <configObject name="domain_alias">
1645  <synopsis>Domain Alias</synopsis>
1646  <description><para>
1647  Signifies that a domain is an alias. If the domain on a session is
1648  not found to match an AoR then this object is used to see if we have
1649  an alias for the AoR to which the endpoint is binding. This objects
1650  name as defined in configuration should be the domain alias and a
1651  config option is provided to specify the domain to be aliased.
1652  </para></description>
1653  <configOption name="type">
1654  <synopsis>Must be of type 'domain_alias'.</synopsis>
1655  </configOption>
1656  <configOption name="domain">
1657  <synopsis>Domain to be aliased</synopsis>
1658  </configOption>
1659  </configObject>
1660  <configObject name="transport">
1661  <synopsis>SIP Transport</synopsis>
1662  <description><para>
1663  <emphasis>Transports</emphasis>
1664  </para>
1665  <para>There are different transports and protocol derivatives
1666  supported by <literal>res_pjsip</literal>. They are in order of
1667  preference: UDP, TCP, and WebSocket (WS).</para>
1668  <note><para>Changes to transport configuration in pjsip.conf will only be
1669  effected on a complete restart of Asterisk. A module reload
1670  will not suffice.</para></note>
1671  </description>
1672  <configOption name="async_operations" default="1">
1673  <synopsis>Number of simultaneous Asynchronous Operations</synopsis>
1674  </configOption>
1675  <configOption name="bind">
1676  <synopsis>IP Address and optional port to bind to for this transport</synopsis>
1677  </configOption>
1678  <configOption name="ca_list_file">
1679  <synopsis>File containing a list of certificates to read (TLS ONLY, not WSS)</synopsis>
1680  </configOption>
1681  <configOption name="ca_list_path">
1682  <synopsis>Path to directory containing a list of certificates to read (TLS ONLY, not WSS)</synopsis>
1683  </configOption>
1684  <configOption name="cert_file">
1685  <synopsis>Certificate file for endpoint (TLS ONLY, not WSS)</synopsis>
1686  <description><para>
1687  A path to a .crt or .pem file can be provided. However, only
1688  the certificate is read from the file, not the private key.
1689  The <literal>priv_key_file</literal> option must supply a
1690  matching key file.
1691  </para></description>
1692  </configOption>
1693  <configOption name="cipher">
1694  <synopsis>Preferred cryptography cipher names (TLS ONLY, not WSS)</synopsis>
1695  <description>
1696  <para>Comma separated list of cipher names or numeric equivalents.
1697  Numeric equivalents can be either decimal or hexadecimal (0xX).
1698  </para>
1699  <para>There are many cipher names. Use the CLI command
1700  <literal>pjsip list ciphers</literal> to see a list of cipher
1701  names available for your installation. See link for more:</para>
1702  <para>http://www.openssl.org/docs/apps/ciphers.html#CIPHER_SUITE_NAMES
1703  </para>
1704  </description>
1705  </configOption>
1706  <configOption name="domain">
1707  <synopsis>Domain the transport comes from</synopsis>
1708  </configOption>
1709  <configOption name="external_media_address">
1710  <synopsis>External IP address to use in RTP handling</synopsis>
1711  <description><para>
1712  When a request or response is sent out, if the destination of the
1713  message is outside the IP network defined in the option <literal>localnet</literal>,
1714  and the media address in the SDP is within the localnet network, then the
1715  media address in the SDP will be rewritten to the value defined for
1716  <literal>external_media_address</literal>.
1717  </para></description>
1718  </configOption>
1719  <configOption name="external_signaling_address">
1720  <synopsis>External address for SIP signalling</synopsis>
1721  </configOption>
1722  <configOption name="external_signaling_port" default="0">
1723  <synopsis>External port for SIP signalling</synopsis>
1724  </configOption>
1725  <configOption name="method">
1726  <synopsis>Method of SSL transport (TLS ONLY, not WSS)</synopsis>
1727  <description>
1728  <enumlist>
1729  <enum name="default">
1730  <para>The default as defined by PJSIP. This is currently TLSv1, but may change with future releases.</para>
1731  </enum>
1732  <enum name="unspecified">
1733  <para>This option is equivalent to setting 'default'</para>
1734  </enum>
1735  <enum name="tlsv1" />
1736  <enum name="tlsv1_1" />
1737  <enum name="tlsv1_2" />
1738  <enum name="sslv2" />
1739  <enum name="sslv3" />
1740  <enum name="sslv23" />
1741  </enumlist>
1742  </description>
1743  </configOption>
1744  <configOption name="local_net">
1745  <synopsis>Network to consider local (used for NAT purposes).</synopsis>
1746  <description><para>This must be in CIDR or dotted decimal format with the IP
1747  and mask separated with a slash ('/').</para></description>
1748  </configOption>
1749  <configOption name="password">
1750  <synopsis>Password required for transport</synopsis>
1751  </configOption>
1752  <configOption name="priv_key_file">
1753  <synopsis>Private key file (TLS ONLY, not WSS)</synopsis>
1754  </configOption>
1755  <configOption name="protocol" default="udp">
1756  <synopsis>Protocol to use for SIP traffic</synopsis>
1757  <description>
1758  <enumlist>
1759  <enum name="udp" />
1760  <enum name="tcp" />
1761  <enum name="tls" />
1762  <enum name="ws" />
1763  <enum name="wss" />
1764  <enum name="flow" />
1765  </enumlist>
1766  </description>
1767  </configOption>
1768  <configOption name="require_client_cert" default="false">
1769  <synopsis>Require client certificate (TLS ONLY, not WSS)</synopsis>
1770  </configOption>
1771  <configOption name="type">
1772  <synopsis>Must be of type 'transport'.</synopsis>
1773  </configOption>
1774  <configOption name="verify_client" default="false">
1775  <synopsis>Require verification of client certificate (TLS ONLY, not WSS)</synopsis>
1776  </configOption>
1777  <configOption name="verify_server" default="false">
1778  <synopsis>Require verification of server certificate (TLS ONLY, not WSS)</synopsis>
1779  </configOption>
1780  <configOption name="tos" default="false">
1781  <synopsis>Enable TOS for the signalling sent over this transport</synopsis>
1782  <description>
1783  <para>See <literal>https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service</literal>
1784  for more information on this parameter.</para>
1785  <note><para>This option does not apply to the <replaceable>ws</replaceable>
1786  or the <replaceable>wss</replaceable> protocols.</para></note>
1787  </description>
1788  </configOption>
1789  <configOption name="cos" default="false">
1790  <synopsis>Enable COS for the signalling sent over this transport</synopsis>
1791  <description>
1792  <para>See <literal>https://wiki.asterisk.org/wiki/display/AST/IP+Quality+of+Service</literal>
1793  for more information on this parameter.</para>
1794  <note><para>This option does not apply to the <replaceable>ws</replaceable>
1795  or the <replaceable>wss</replaceable> protocols.</para></note>
1796  </description>
1797  </configOption>
1798  <configOption name="websocket_write_timeout">
1799  <synopsis>The timeout (in milliseconds) to set on WebSocket connections.</synopsis>
1800  <description>
1801  <para>If a websocket connection accepts input slowly, the timeout
1802  for writes to it can be increased to keep it from being disconnected.
1803  Value is in milliseconds; default is 100 ms.</para>
1804  </description>
1805  </configOption>
1806  <configOption name="allow_reload" default="no">
1807  <synopsis>Allow this transport to be reloaded.</synopsis>
1808  <description>
1809  <para>Allow this transport to be reloaded when res_pjsip is reloaded.
1810  This option defaults to "no" because reloading a transport may disrupt
1811  in-progress calls.</para>
1812  </description>
1813  </configOption>
1814  <configOption name="symmetric_transport" default="no">
1815  <synopsis>Use the same transport for outgoing requests as incoming ones.</synopsis>
1816  <description>
1817  <para>When a request from a dynamic contact
1818  comes in on a transport with this option set to 'yes',
1819  the transport name will be saved and used for subsequent
1820  outgoing requests like OPTIONS, NOTIFY and INVITE. It's
1821  saved as a contact uri parameter named 'x-ast-txp' and will
1822  display with the contact uri in CLI, AMI, and ARI output.
1823  On the outgoing request, if a transport wasn't explicitly
1824  set on the endpoint AND the request URI is not a hostname,
1825  the saved transport will be used and the 'x-ast-txp'
1826  parameter stripped from the outgoing packet.
1827  </para>
1828  </description>
1829  </configOption>
1830  </configObject>
1831  <configObject name="contact">
1832  <synopsis>A way of creating an aliased name to a SIP URI</synopsis>
1833  <description><para>
1834  Contacts are a way to hide SIP URIs from the dialplan directly.
1835  They are also used to make a group of contactable parties when
1836  in use with <literal>AoR</literal> lists.
1837  </para></description>
1838  <configOption name="type">
1839  <synopsis>Must be of type 'contact'.</synopsis>
1840  </configOption>
1841  <configOption name="uri">
1842  <synopsis>SIP URI to contact peer</synopsis>
1843  </configOption>
1844  <configOption name="expiration_time">
1845  <synopsis>Time to keep alive a contact</synopsis>
1846  <description><para>
1847  Time to keep alive a contact. String style specification.
1848  </para></description>
1849  </configOption>
1850  <configOption name="qualify_frequency" default="0">
1851  <synopsis>Interval at which to qualify a contact</synopsis>
1852  <description><para>
1853  Interval between attempts to qualify the contact for reachability.
1854  If <literal>0</literal> never qualify. Time in seconds.
1855  </para></description>
1856  </configOption>
1857  <configOption name="qualify_timeout" default="3.0">
1858  <synopsis>Timeout for qualify</synopsis>
1859  <description><para>
1860  If the contact doesn't respond to the OPTIONS request before the timeout,
1861  the contact is marked unavailable.
1862  If <literal>0</literal> no timeout. Time in fractional seconds.
1863  </para></description>
1864  </configOption>
1865  <configOption name="authenticate_qualify">
1866  <synopsis>Authenticates a qualify challenge response if needed</synopsis>
1867  <description>
1868  <para>If true and a qualify request receives a challenge response then
1869  authentication is attempted before declaring the contact available.
1870  </para>
1871  <note><para>This option does nothing as we will always complete
1872  the challenge response authentication if the qualify request is
1873  challenged.
1874  </para></note>
1875  </description>
1876  </configOption>
1877  <configOption name="outbound_proxy">
1878  <synopsis>Outbound proxy used when sending OPTIONS request</synopsis>
1879  <description><para>
1880  If set the provided URI will be used as the outbound proxy when an
1881  OPTIONS request is sent to a contact for qualify purposes.
1882  </para></description>
1883  </configOption>
1884  <configOption name="path">
1885  <synopsis>Stored Path vector for use in Route headers on outgoing requests.</synopsis>
1886  </configOption>
1887  <configOption name="user_agent">
1888  <synopsis>User-Agent header from registration.</synopsis>
1889  <description><para>
1890  The User-Agent is automatically stored based on data present in incoming SIP
1891  REGISTER requests and is not intended to be configured manually.
1892  </para></description>
1893  </configOption>
1894  <configOption name="endpoint">
1895  <synopsis>Endpoint name</synopsis>
1896  <description><para>
1897  The name of the endpoint this contact belongs to
1898  </para></description>
1899  </configOption>
1900  <configOption name="reg_server">
1901  <synopsis>Asterisk Server name</synopsis>
1902  <description><para>
1903  Asterisk Server name on which SIP endpoint registered.
1904  </para></description>
1905  </configOption>
1906  <configOption name="via_addr">
1907  <synopsis>IP-address of the last Via header from registration.</synopsis>
1908  <description><para>
1909  The last Via header should contain the address of UA which sent the request.
1910  The IP-address of the last Via header is automatically stored based on data present
1911  in incoming SIP REGISTER requests and is not intended to be configured manually.
1912  </para></description>
1913  </configOption>
1914  <configOption name="via_port">
1915  <synopsis>IP-port of the last Via header from registration.</synopsis>
1916  <description><para>
1917  The IP-port of the last Via header is automatically stored based on data present
1918  in incoming SIP REGISTER requests and is not intended to be configured manually.
1919  </para></description>
1920  </configOption>
1921  <configOption name="call_id">
1922  <synopsis>Call-ID header from registration.</synopsis>
1923  <description><para>
1924  The Call-ID header is automatically stored based on data present
1925  in incoming SIP REGISTER requests and is not intended to be configured manually.
1926  </para></description>
1927  </configOption>
1928  <configOption name="prune_on_boot">
1929  <synopsis>A contact that cannot survive a restart/boot.</synopsis>
1930  <description><para>
1931  The option is set if the incoming SIP REGISTER contact is rewritten
1932  on a reliable transport and is not intended to be configured manually.
1933  </para></description>
1934  </configOption>
1935  </configObject>
1936  <configObject name="aor">
1937  <synopsis>The configuration for a location of an endpoint</synopsis>
1938  <description><para>
1939  An AoR is what allows Asterisk to contact an endpoint via res_pjsip. If no
1940  AoRs are specified, an endpoint will not be reachable by Asterisk.
1941  Beyond that, an AoR has other uses within Asterisk, such as inbound
1942  registration.
1943  </para><para>
1944  An <literal>AoR</literal> is a way to allow dialing a group
1945  of <literal>Contacts</literal> that all use the same
1946  <literal>endpoint</literal> for calls.
1947  </para><para>
1948  This can be used as another way of grouping a list of contacts to dial
1949  rather than specifying them each directly when dialing via the dialplan.
1950  This must be used in conjunction with the <literal>PJSIP_DIAL_CONTACTS</literal>.
1951  </para><para>
1952  Registrations: For Asterisk to match an inbound registration to an endpoint,
1953  the AoR object name must match the user portion of the SIP URI in the "To:"
1954  header of the inbound SIP registration. That will usually be equivalent
1955  to the "user name" set in your hard or soft phones configuration.
1956  </para></description>
1957  <configOption name="contact">
1958  <synopsis>Permanent contacts assigned to AoR</synopsis>
1959  <description><para>
1960  Contacts specified will be called whenever referenced
1961  by <literal>chan_pjsip</literal>.
1962  </para><para>
1963  Use a separate "contact=" entry for each contact required. Contacts
1964  are specified using a SIP URI.
1965  </para></description>
1966  </configOption>
1967  <configOption name="default_expiration" default="3600">
1968  <synopsis>Default expiration time in seconds for contacts that are dynamically bound to an AoR.</synopsis>
1969  </configOption>
1970  <configOption name="mailboxes">
1971  <synopsis>Allow subscriptions for the specified mailbox(es)</synopsis>
1972  <description><para>This option applies when an external entity subscribes to an AoR
1973  for Message Waiting Indications. The mailboxes specified will be subscribed to.
1974  More than one mailbox can be specified with a comma-delimited string.
1975  app_voicemail mailboxes must be specified as mailbox@context;
1976  for example: mailboxes=6001@default. For mailboxes provided by external sources,
1977  such as through the res_mwi_external module, you must specify strings supported by
1978  the external system.
1979  </para><para>
1980  For endpoints that cannot SUBSCRIBE for MWI, you can set the <literal>mailboxes</literal> option in your
1981  endpoint configuration section to enable unsolicited MWI NOTIFYs to the endpoint.
1982  </para></description>
1983  </configOption>
1984  <configOption name="voicemail_extension">
1985  <synopsis>The voicemail extension to send in the NOTIFY Message-Account header</synopsis>
1986  </configOption>
1987  <configOption name="maximum_expiration" default="7200">
1988  <synopsis>Maximum time to keep an AoR</synopsis>
1989  <description><para>
1990  Maximum time to keep a peer with explicit expiration. Time in seconds.
1991  </para></description>
1992  </configOption>
1993  <configOption name="max_contacts" default="0">
1994  <synopsis>Maximum number of contacts that can bind to an AoR</synopsis>
1995  <description><para>
1996  Maximum number of contacts that can associate with this AoR. This value does
1997  not affect the number of contacts that can be added with the "contact" option.
1998  It only limits contacts added through external interaction, such as
1999  registration.
2000  </para>
2001  <note><para>The <replaceable>rewrite_contact</replaceable> option
2002  registers the source address as the contact address to help with
2003  NAT and reusing connection oriented transports such as TCP and
2004  TLS. Unfortunately, refreshing a registration may register a
2005  different contact address and exceed
2006  <replaceable>max_contacts</replaceable>. The
2007  <replaceable>remove_existing</replaceable> and
2008  <replaceable>remove_unavailable</replaceable> options can help by
2009  removing either the soonest to expire or unavailable contact(s) over
2010  <replaceable>max_contacts</replaceable> which is likely the
2011  old <replaceable>rewrite_contact</replaceable> contact source
2012  address being refreshed.
2013  </para></note>
2014  <note><para>This should be set to <literal>1</literal> and
2015  <replaceable>remove_existing</replaceable> set to <literal>yes</literal> if you
2016  wish to stick with the older <literal>chan_sip</literal> behaviour.
2017  </para></note>
2018  </description>
2019  </configOption>
2020  <configOption name="minimum_expiration" default="60">
2021  <synopsis>Minimum keep alive time for an AoR</synopsis>
2022  <description><para>
2023  Minimum time to keep a peer with an explicit expiration. Time in seconds.
2024  </para></description>
2025  </configOption>
2026  <configOption name="remove_existing" default="no">
2027  <synopsis>Determines whether new contacts replace existing ones.</synopsis>
2028  <description><para>
2029  On receiving a new registration to the AoR should it remove enough
2030  existing contacts not added or updated by the registration to
2031  satisfy <replaceable>max_contacts</replaceable>? Any removed
2032  contacts will expire the soonest.
2033  </para>
2034  <note><para>The <replaceable>rewrite_contact</replaceable> option
2035  registers the source address as the contact address to help with
2036  NAT and reusing connection oriented transports such as TCP and
2037  TLS. Unfortunately, refreshing a registration may register a
2038  different contact address and exceed
2039  <replaceable>max_contacts</replaceable>. The
2040  <replaceable>remove_existing</replaceable> option can help by
2041  removing the soonest to expire contact(s) over
2042  <replaceable>max_contacts</replaceable> which is likely the
2043  old <replaceable>rewrite_contact</replaceable> contact source
2044  address being refreshed.
2045  </para></note>
2046  <note><para>This should be set to <literal>yes</literal> and
2047  <replaceable>max_contacts</replaceable> set to <literal>1</literal> if you
2048  wish to stick with the older <literal>chan_sip</literal> behaviour.
2049  </para></note>
2050  </description>
2051  </configOption>
2052  <configOption name="remove_unavailable" default="no">
2053  <synopsis>Determines whether new contacts should replace unavailable ones.</synopsis>
2054  <description><para>
2055  The effect of this setting depends on the setting of
2056  <replaceable>remove_existing</replaceable>.</para>
2057  <para>If <replaceable>remove_existing</replaceable> is set to
2058  <literal>no</literal> (default), setting remove_unavailable to
2059  <literal>yes</literal> will remove only unavailable contacts that exceed
2060  <replaceable>max_contacts</replaceable> to allow an incoming
2061  REGISTER to complete sucessfully.</para>
2062  <para>If <replaceable>remove_existing</replaceable> is set to
2063  <literal>yes</literal>, setting remove_unavailable to
2064  <literal>yes</literal> will prioritize unavailable contacts for removal
2065  instead of just removing the contact that expires the soonest.</para>
2066  <note><para>See <replaceable>remove_existing</replaceable> and
2067  <replaceable>max_contacts</replaceable> for further information about how
2068  these 3 settings interact.
2069  </para></note>
2070  </description>
2071  </configOption>
2072  <configOption name="type">
2073  <synopsis>Must be of type 'aor'.</synopsis>
2074  </configOption>
2075  <configOption name="qualify_frequency" default="0">
2076  <synopsis>Interval at which to qualify an AoR</synopsis>
2077  <description><para>
2078  Interval between attempts to qualify the AoR for reachability.
2079  If <literal>0</literal> never qualify. Time in seconds.
2080  </para></description>
2081  </configOption>
2082  <configOption name="qualify_timeout" default="3.0">
2083  <synopsis>Timeout for qualify</synopsis>
2084  <description><para>
2085  If the contact doesn't respond to the OPTIONS request before the timeout,
2086  the contact is marked unavailable.
2087  If <literal>0</literal> no timeout. Time in fractional seconds.
2088  </para></description>
2089  </configOption>
2090  <configOption name="authenticate_qualify">
2091  <synopsis>Authenticates a qualify challenge response if needed</synopsis>
2092  <description>
2093  <para>If true and a qualify request receives a challenge response then
2094  authentication is attempted before declaring the contact available.
2095  </para>
2096  <note><para>This option does nothing as we will always complete
2097  the challenge response authentication if the qualify request is
2098  challenged.
2099  </para></note>
2100  </description>
2101  </configOption>
2102  <configOption name="outbound_proxy">
2103  <synopsis>Outbound proxy used when sending OPTIONS request</synopsis>
2104  <description><para>
2105  If set the provided URI will be used as the outbound proxy when an
2106  OPTIONS request is sent to a contact for qualify purposes.
2107  </para></description>
2108  </configOption>
2109  <configOption name="support_path">
2110  <synopsis>Enables Path support for REGISTER requests and Route support for other requests.</synopsis>
2111  <description><para>
2112  When this option is enabled, the Path headers in register requests will be saved
2113  and its contents will be used in Route headers for outbound out-of-dialog requests
2114  and in Path headers for outbound 200 responses. Path support will also be indicated
2115  in the Supported header.
2116  </para></description>
2117  </configOption>
2118  </configObject>
2119  <configObject name="system">
2120  <synopsis>Options that apply to the SIP stack as well as other system-wide settings</synopsis>
2121  <description><para>
2122  The settings in this section are global. In addition to being global, the values will
2123  not be re-evaluated when a reload is performed. This is because the values must be set
2124  before the SIP stack is initialized. The only way to reset these values is to either
2125  restart Asterisk, or unload res_pjsip.so and then load it again.
2126  </para></description>
2127  <configOption name="timer_t1" default="500">
2128  <synopsis>Set transaction timer T1 value (milliseconds).</synopsis>
2129  <description><para>
2130  Timer T1 is the base for determining how long to wait before retransmitting
2131  requests that receive no response when using an unreliable transport (e.g. UDP).
2132  For more information on this timer, see RFC 3261, Section 17.1.1.1.
2133  </para></description>
2134  </configOption>
2135  <configOption name="timer_b" default="32000">
2136  <synopsis>Set transaction timer B value (milliseconds).</synopsis>
2137  <description><para>
2138  Timer B determines the maximum amount of time to wait after sending an INVITE
2139  request before terminating the transaction. It is recommended that this be set
2140  to 64 * Timer T1, but it may be set higher if desired. For more information on
2141  this timer, see RFC 3261, Section 17.1.1.1.
2142  </para></description>
2143  </configOption>
2144  <configOption name="compact_headers" default="no">
2145  <synopsis>Use the short forms of common SIP header names.</synopsis>
2146  </configOption>
2147  <configOption name="threadpool_initial_size" default="0">
2148  <synopsis>Initial number of threads in the res_pjsip threadpool.</synopsis>
2149  </configOption>
2150  <configOption name="threadpool_auto_increment" default="5">
2151  <synopsis>The amount by which the number of threads is incremented when necessary.</synopsis>
2152  </configOption>
2153  <configOption name="threadpool_idle_timeout" default="60">
2154  <synopsis>Number of seconds before an idle thread should be disposed of.</synopsis>
2155  </configOption>
2156  <configOption name="threadpool_max_size" default="0">
2157  <synopsis>Maximum number of threads in the res_pjsip threadpool.
2158  A value of 0 indicates no maximum.</synopsis>
2159  </configOption>
2160  <configOption name="disable_tcp_switch" default="yes">
2161  <synopsis>Disable automatic switching from UDP to TCP transports.</synopsis>
2162  <description><para>
2163  Disable automatic switching from UDP to TCP transports if outgoing
2164  request is too large. See RFC 3261 section 18.1.1.
2165  </para></description>
2166  </configOption>
2167  <configOption name="follow_early_media_fork">
2168  <synopsis>Follow SDP forked media when To tag is different</synopsis>
2169  <description><para>
2170  On outgoing calls, if the UAS responds with different SDP attributes
2171  on subsequent 18X or 2XX responses (such as a port update) AND the
2172  To tag on the subsequent response is different than that on the previous
2173  one, follow it.
2174  </para>
2175  <note><para>
2176  This option must also be enabled on endpoints that require
2177  this functionality.
2178  </para></note>
2179  </description>
2180  </configOption>
2181  <configOption name="accept_multiple_sdp_answers">
2182  <synopsis>Follow SDP forked media when To tag is the same</synopsis>
2183  <description><para>
2184  On outgoing calls, if the UAS responds with different SDP attributes
2185  on non-100rel 18X or 2XX responses (such as a port update) AND the
2186  To tag on the subsequent response is the same as that on the previous one,
2187  process the updated SDP.
2188  </para>
2189  <note><para>
2190  This option must also be enabled on endpoints that require
2191  this functionality.
2192  </para></note>
2193  </description>
2194  </configOption>
2195  <configOption name="disable_rport" default="no">
2196  <synopsis>Disable the use of rport in outgoing requests.</synopsis>
2197  <description><para>
2198  Remove "rport" parameter from the outgoing requests.
2199  </para></description>
2200  </configOption>
2201  <configOption name="type">
2202  <synopsis>Must be of type 'system' UNLESS the object name is 'system'.</synopsis>
2203  </configOption>
2204  </configObject>
2205  <configObject name="global">
2206  <synopsis>Options that apply globally to all SIP communications</synopsis>
2207  <description><para>
2208  The settings in this section are global. Unlike options in the <literal>system</literal>
2209  section, these options can be refreshed by performing a reload.
2210  </para></description>
2211  <configOption name="max_forwards" default="70">
2212  <synopsis>Value used in Max-Forwards header for SIP requests.</synopsis>
2213  </configOption>
2214  <configOption name="keep_alive_interval" default="90">
2215  <synopsis>The interval (in seconds) to send keepalives to active connection-oriented transports.</synopsis>
2216  </configOption>
2217  <configOption name="contact_expiration_check_interval" default="30">
2218  <synopsis>The interval (in seconds) to check for expired contacts.</synopsis>
2219  </configOption>
2220  <configOption name="disable_multi_domain" default="no">
2221  <synopsis>Disable Multi Domain support</synopsis>
2222  <description><para>
2223  If disabled it can improve realtime performance by reducing the number of database requests.
2224  </para></description>
2225  </configOption>
2226  <configOption name="max_initial_qualify_time" default="0">
2227  <synopsis>The maximum amount of time from startup that qualifies should be attempted on all contacts.
2228  If greater than the qualify_frequency for an aor, qualify_frequency will be used instead.</synopsis>
2229  </configOption>
2230  <configOption name="unidentified_request_period" default="5">
2231  <synopsis>The number of seconds over which to accumulate unidentified requests.</synopsis>
2232  <description><para>
2233  If <literal>unidentified_request_count</literal> unidentified requests are received
2234  during <literal>unidentified_request_period</literal>, a security event will be generated.
2235  </para></description>
2236  </configOption>
2237  <configOption name="unidentified_request_count" default="5">
2238  <synopsis>The number of unidentified requests from a single IP to allow.</synopsis>
2239  <description><para>
2240  If <literal>unidentified_request_count</literal> unidentified requests are received
2241  during <literal>unidentified_request_period</literal>, a security event will be generated.
2242  </para></description>
2243  </configOption>
2244  <configOption name="unidentified_request_prune_interval" default="30">
2245  <synopsis>The interval at which unidentified requests are older than
2246  twice the unidentified_request_period are pruned.</synopsis>
2247  </configOption>
2248  <configOption name="type">
2249  <synopsis>Must be of type 'global' UNLESS the object name is 'global'.</synopsis>
2250  </configOption>
2251  <configOption name="user_agent" default="Asterisk &lt;Asterisk Version&gt;">
2252  <synopsis>Value used in User-Agent header for SIP requests and Server header for SIP responses.</synopsis>
2253  </configOption>
2254  <configOption name="regcontext" default="">
2255  <synopsis>When set, Asterisk will dynamically create and destroy a NoOp priority 1 extension for a given
2256  peer who registers or unregisters with us.</synopsis>
2257  </configOption>
2258  <configOption name="default_outbound_endpoint" default="default_outbound_endpoint">
2259  <synopsis>Endpoint to use when sending an outbound request to a URI without a specified endpoint.</synopsis>
2260  </configOption>
2261  <configOption name="default_voicemail_extension">
2262  <synopsis>The voicemail extension to send in the NOTIFY Message-Account header if not specified on endpoint or aor</synopsis>
2263  </configOption>
2264  <configOption name="debug" default="no">
2265  <synopsis>Enable/Disable SIP debug logging. Valid options include yes, no, or
2266  a host address</synopsis>
2267  </configOption>
2268  <configOption name="endpoint_identifier_order">
2269  <synopsis>The order by which endpoint identifiers are processed and checked.
2270  Identifier names are usually derived from and can be found in the endpoint
2271  identifier module itself (res_pjsip_endpoint_identifier_*).
2272  You can use the CLI command "pjsip show identifiers" to see the
2273  identifiers currently available.</synopsis>
2274  <description>
2275  <note><para>
2276  One of the identifiers is "auth_username" which matches on the username in
2277  an Authentication header. This method has some security considerations because an
2278  Authentication header is not present on the first message of a dialog when
2279  digest authentication is used. The client can't generate it until the server
2280  sends the challenge in a 401 response. Since Asterisk normally sends a security
2281  event when an incoming request can't be matched to an endpoint, using auth_username
2282  requires that the security event be deferred until a request is received with
2283  the Authentication header and only generated if the username doesn't result in a
2284  match. This may result in a delay before an attack is recognized. You can control
2285  how many unmatched requests are received from a single ip address before a security
2286  event is generated using the unidentified_request parameters.
2287  </para></note>
2288  </description>
2289  </configOption>
2290  <configOption name="default_from_user" default="asterisk">
2291  <synopsis>When Asterisk generates an outgoing SIP request, the From header username will be
2292  set to this value if there is no better option (such as CallerID) to be
2293  used.</synopsis>
2294  </configOption>
2295  <configOption name="default_realm" default="asterisk">
2296  <synopsis>When Asterisk generates a challenge, the digest realm will be
2297  set to this value if there is no better option (such as auth/realm) to be
2298  used.</synopsis>
2299  </configOption>
2300  <configOption name="mwi_tps_queue_high" default="500">
2301  <synopsis>MWI taskprocessor high water alert trigger level.</synopsis>
2302  <description>
2303  <para>On a heavily loaded system you may need to adjust the
2304  taskprocessor queue limits. If any taskprocessor queue size
2305  reaches its high water level then pjsip will stop processing
2306  new requests until the alert is cleared. The alert clears
2307  when all alerting taskprocessor queues have dropped to their
2308  low water clear level.
2309  </para>
2310  </description>
2311  </configOption>
2312  <configOption name="mwi_tps_queue_low" default="-1">
2313  <synopsis>MWI taskprocessor low water clear alert level.</synopsis>
2314  <description>
2315  <para>On a heavily loaded system you may need to adjust the
2316  taskprocessor queue limits. If any taskprocessor queue size
2317  reaches its high water level then pjsip will stop processing
2318  new requests until the alert is cleared. The alert clears
2319  when all alerting taskprocessor queues have dropped to their
2320  low water clear level.
2321  </para>
2322  <note><para>Set to -1 for the low water level to be 90% of
2323  the high water level.</para></note>
2324  </description>
2325  </configOption>
2326  <configOption name="mwi_disable_initial_unsolicited" default="no">
2327  <synopsis>Enable/Disable sending unsolicited MWI to all endpoints on startup.</synopsis>
2328  <description>
2329  <para>When the initial unsolicited MWI notification are
2330  enabled on startup then the initial notifications
2331  get sent at startup. If you have a lot of endpoints
2332  (thousands) that use unsolicited MWI then you may
2333  want to consider disabling the initial startup
2334  notifications.
2335  </para>
2336  <para>When the initial unsolicited MWI notifications are
2337  disabled on startup then the notifications will start
2338  on the endpoint's next contact update.
2339  </para>
2340  </description>
2341  </configOption>
2342  <configOption name="ignore_uri_user_options">
2343  <synopsis>Enable/Disable ignoring SIP URI user field options.</synopsis>
2344  <description>
2345  <para>If you have this option enabled and there are semicolons
2346  in the user field of a SIP URI then the field is truncated
2347  at the first semicolon. This effectively makes the semicolon
2348  a non-usable character for PJSIP endpoint names, extensions,
2349  and AORs. This can be useful for improving compatibility with
2350  an ITSP that likes to use user options for whatever reason.
2351  </para>
2352  <example title="Sample SIP URI">
2353  sip:1235557890;phone-context=national@x.x.x.x;user=phone
2354  </example>
2355  <example title="Sample SIP URI user field">
2356  1235557890;phone-context=national
2357  </example>
2358  <example title="Sample SIP URI user field truncated">
2359  1235557890
2360  </example>
2361  <note><para>The caller-id and redirecting number strings
2362  obtained from incoming SIP URI user fields are always truncated
2363  at the first semicolon.</para></note>
2364  </description>
2365  </configOption>
2366  <configOption name="use_callerid_contact" default="no">
2367  <synopsis>Place caller-id information into Contact header</synopsis>
2368  <description><para>
2369  This option will cause Asterisk to place caller-id information into
2370  generated Contact headers.</para>
2371  </description>
2372  </configOption>
2373  <configOption name="send_contact_status_on_update_registration" default="no">
2374  <synopsis>Enable sending AMI ContactStatus event when a device refreshes its registration.</synopsis>
2375  </configOption>
2376  <configOption name="taskprocessor_overload_trigger">
2377  <synopsis>Trigger scope for taskprocessor overloads</synopsis>
2378  <description><para>
2379  This option specifies the trigger the distributor will use for
2380  detecting taskprocessor overloads. When it detects an overload condition,
2381  the distrubutor will stop accepting new requests until the overload is
2382  cleared.
2383  </para>
2384  <enumlist>
2385  <enum name="global"><para>(default) Any taskprocessor overload will trigger.</para></enum>
2386  <enum name="pjsip_only"><para>Only pjsip taskprocessor overloads will trigger.</para></enum>
2387  <enum name="none"><para>No overload detection will be performed.</para></enum>
2388  </enumlist>
2389  <warning><para>
2390  The "none" and "pjsip_only" options should be used
2391  with extreme caution and only to mitigate specific issues.
2392  Under certain conditions they could make things worse.
2393  </para></warning>
2394  </description>
2395  </configOption>
2396  <configOption name="norefersub" default="yes">
2397  <synopsis>Advertise support for RFC4488 REFER subscription suppression</synopsis>
2398  </configOption>
2399  </configObject>
2400  </configFile>
2401  </configInfo>
2402  <manager name="PJSIPQualify" language="en_US">
2403  <synopsis>
2404  Qualify a chan_pjsip endpoint.
2405  </synopsis>
2406  <syntax>
2407  <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
2408  <parameter name="Endpoint" required="true">
2409  <para>The endpoint you want to qualify.</para>
2410  </parameter>
2411  </syntax>
2412  <description>
2413  <para>Qualify a chan_pjsip endpoint.</para>
2414  </description>
2415  </manager>
2416  <managerEvent language="en_US" name="IdentifyDetail">
2417  <managerEventInstance class="EVENT_FLAG_COMMAND">
2418  <synopsis>Provide details about an identify section.</synopsis>
2419  <syntax>
2420  <parameter name="ObjectType">
2421  <para>The object's type. This will always be 'identify'.</para>
2422  </parameter>
2423  <parameter name="ObjectName">
2424  <para>The name of this object.</para>
2425  </parameter>
2426  <parameter name="Endpoint">
2427  <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>
2428  </parameter>
2429  <parameter name="SrvLookups">
2430  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip_endpoint_identifier_ip']/configFile[@name='pjsip.conf']/configObject[@name='identify']/configOption[@name='srv_lookups']/synopsis/node())"/></para>
2431  </parameter>
2432  <parameter name="Match">
2433  <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>
2434  </parameter>
2435  <parameter name="MatchHeader">
2436  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip_endpoint_identifier_ip']/configFile[@name='pjsip.conf']/configObject[@name='identify']/configOption[@name='match_header']/synopsis/node())"/></para>
2437  </parameter>
2438  <parameter name="EndpointName">
2439  <para>The name of the endpoint associated with this information.</para>
2440  </parameter>
2441  </syntax>
2442  </managerEventInstance>
2443  </managerEvent>
2444  <managerEvent language="en_US" name="AorDetail">
2445  <managerEventInstance class="EVENT_FLAG_COMMAND">
2446  <synopsis>Provide details about an Address of Record (AoR) section.</synopsis>
2447  <syntax>
2448  <parameter name="ObjectType">
2449  <para>The object's type. This will always be 'aor'.</para>
2450  </parameter>
2451  <parameter name="ObjectName">
2452  <para>The name of this object.</para>
2453  </parameter>
2454  <parameter name="MinimumExpiration">
2455  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='minimum_expiration']/synopsis/node())"/></para>
2456  </parameter>
2457  <parameter name="MaximumExpiration">
2458  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='maximum_expiration']/synopsis/node())"/></para>
2459  </parameter>
2460  <parameter name="DefaultExpiration">
2461  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='default_expiration']/synopsis/node())"/></para>
2462  </parameter>
2463  <parameter name="QualifyFrequency">
2464  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='qualify_frequency']/synopsis/node())"/></para>
2465  </parameter>
2466  <parameter name="AuthenticateQualify">
2467  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='authenticate_qualify']/synopsis/node())"/></para>
2468  </parameter>
2469  <parameter name="MaxContacts">
2470  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='max_contacts']/synopsis/node())"/></para>
2471  </parameter>
2472  <parameter name="RemoveExisting">
2473  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='remove_existing']/synopsis/node())"/></para>
2474  </parameter>
2475  <parameter name="RemoveUnavailable">
2476  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='remove_unavailable']/synopsis/node())"/></para>
2477  </parameter>
2478  <parameter name="Mailboxes">
2479  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='mailboxes']/synopsis/node())"/></para>
2480  </parameter>
2481  <parameter name="OutboundProxy">
2482  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='outbound_proxy']/synopsis/node())"/></para>
2483  </parameter>
2484  <parameter name="SupportPath">
2485  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='support_path']/synopsis/node())"/></para>
2486  </parameter>
2487  <parameter name="TotalContacts">
2488  <para>The total number of contacts associated with this AoR.</para>
2489  </parameter>
2490  <parameter name="ContactsRegistered">
2491  <para>The number of non-permanent contacts associated with this AoR.</para>
2492  </parameter>
2493  <parameter name="EndpointName">
2494  <para>The name of the endpoint associated with this information.</para>
2495  </parameter>
2496  </syntax>
2497  </managerEventInstance>
2498  </managerEvent>
2499  <managerEvent language="en_US" name="AuthDetail">
2500  <managerEventInstance class="EVENT_FLAG_COMMAND">
2501  <synopsis>Provide details about an authentication section.</synopsis>
2502  <syntax>
2503  <parameter name="ObjectType">
2504  <para>The object's type. This will always be 'auth'.</para>
2505  </parameter>
2506  <parameter name="ObjectName">
2507  <para>The name of this object.</para>
2508  </parameter>
2509  <parameter name="Username">
2510  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='username']/synopsis/node())"/></para>
2511  </parameter>
2512  <parameter name="Password">
2513  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='username']/synopsis/node())"/></para>
2514  </parameter>
2515  <parameter name="Md5Cred">
2516  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='md5_cred']/synopsis/node())"/></para>
2517  </parameter>
2518  <parameter name="Realm">
2519  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='realm']/synopsis/node())"/></para>
2520  </parameter>
2521  <parameter name="NonceLifetime">
2522  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='nonce_lifetime']/synopsis/node())"/></para>
2523  </parameter>
2524  <parameter name="AuthType">
2525  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='auth_type']/synopsis/node())"/></para>
2526  </parameter>
2527  <parameter name="EndpointName">
2528  <para>The name of the endpoint associated with this information.</para>
2529  </parameter>
2530  </syntax>
2531  </managerEventInstance>
2532  </managerEvent>
2533  <managerEvent language="en_US" name="TransportDetail">
2534  <managerEventInstance class="EVENT_FLAG_COMMAND">
2535  <synopsis>Provide details about an authentication section.</synopsis>
2536  <syntax>
2537  <parameter name="ObjectType">
2538  <para>The object's type. This will always be 'transport'.</para>
2539  </parameter>
2540  <parameter name="ObjectName">
2541  <para>The name of this object.</para>
2542  </parameter>
2543  <parameter name="Protocol">
2544  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='protocol']/synopsis/node())"/></para>
2545  </parameter>
2546  <parameter name="Bind">
2547  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='bind']/synopsis/node())"/></para>
2548  </parameter>
2549  <parameter name="AsycOperations">
2550  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='async_operations']/synopsis/node())"/></para>
2551  </parameter>
2552  <parameter name="CaListFile">
2553  <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>
2554  </parameter>
2555  <parameter name="CaListPath">
2556  <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>
2557  </parameter>
2558  <parameter name="CertFile">
2559  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='cert_file']/synopsis/node())"/></para>
2560  </parameter>
2561  <parameter name="PrivKeyFile">
2562  <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>
2563  </parameter>
2564  <parameter name="Password">
2565  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='password']/synopsis/node())"/></para>
2566  </parameter>
2567  <parameter name="ExternalSignalingAddress">
2568  <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>
2569  </parameter>
2570  <parameter name="ExternalSignalingPort">
2571  <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>
2572  </parameter>
2573  <parameter name="ExternalMediaAddress">
2574  <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>
2575  </parameter>
2576  <parameter name="Domain">
2577  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='domain']/synopsis/node())"/></para>
2578  </parameter>
2579  <parameter name="VerifyServer">
2580  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='verify_server']/synopsis/node())"/></para>
2581  </parameter>
2582  <parameter name="VerifyClient">
2583  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='verify_client']/synopsis/node())"/></para>
2584  </parameter>
2585  <parameter name="RequireClientCert">
2586  <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>
2587  </parameter>
2588  <parameter name="Method">
2589  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='method']/synopsis/node())"/></para>
2590  </parameter>
2591  <parameter name="Cipher">
2592  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='cipher']/synopsis/node())"/></para>
2593  </parameter>
2594  <parameter name="LocalNet">
2595  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='local_net']/synopsis/node())"/></para>
2596  </parameter>
2597  <parameter name="Tos">
2598  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='tos']/synopsis/node())"/></para>
2599  </parameter>
2600  <parameter name="Cos">
2601  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='transport']/configOption[@name='cos']/synopsis/node())"/></para>
2602  </parameter>
2603  <parameter name="WebsocketWriteTimeout">
2604  <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>
2605  </parameter>
2606  <parameter name="EndpointName">
2607  <para>The name of the endpoint associated with this information.</para>
2608  </parameter>
2609  </syntax>
2610  </managerEventInstance>
2611  </managerEvent>
2612  <managerEvent language="en_US" name="EndpointDetail">
2613  <managerEventInstance class="EVENT_FLAG_COMMAND">
2614  <synopsis>Provide details about an endpoint section.</synopsis>
2615  <syntax>
2616  <parameter name="ObjectType">
2617  <para>The object's type. This will always be 'endpoint'.</para>
2618  </parameter>
2619  <parameter name="ObjectName">
2620  <para>The name of this object.</para>
2621  </parameter>
2622  <parameter name="Context">
2623  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='context']/synopsis/node())"/></para>
2624  </parameter>
2625  <parameter name="Disallow">
2626  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='disallow']/synopsis/node())"/></para>
2627  </parameter>
2628  <parameter name="Allow">
2629  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow']/synopsis/node())"/></para>
2630  </parameter>
2631  <parameter name="DtmfMode">
2632  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtmf_mode']/synopsis/node())"/></para>
2633  </parameter>
2634  <parameter name="RtpIpv6">
2635  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rtp_ipv6']/synopsis/node())"/></para>
2636  </parameter>
2637  <parameter name="RtpSymmetric">
2638  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rtp_symmetric']/synopsis/node())"/></para>
2639  </parameter>
2640  <parameter name="IceSupport">
2641  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='ice_support']/synopsis/node())"/></para>
2642  </parameter>
2643  <parameter name="UsePtime">
2644  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='use_ptime']/synopsis/node())"/></para>
2645  </parameter>
2646  <parameter name="ForceRport">
2647  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='force_rport']/synopsis/node())"/></para>
2648  </parameter>
2649  <parameter name="RewriteContact">
2650  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rewrite_contact']/synopsis/node())"/></para>
2651  </parameter>
2652  <parameter name="Transport">
2653  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='transport']/synopsis/node())"/></para>
2654  </parameter>
2655  <parameter name="OutboundProxy">
2656  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='outbound_proxy']/synopsis/node())"/></para>
2657  </parameter>
2658  <parameter name="MohSuggest">
2659  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='moh_suggest']/synopsis/node())"/></para>
2660  </parameter>
2661  <parameter name="100rel">
2662  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='100rel']/synopsis/node())"/></para>
2663  </parameter>
2664  <parameter name="Timers">
2665  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='timers']/synopsis/node())"/></para>
2666  </parameter>
2667  <parameter name="TimersMinSe">
2668  <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>
2669  </parameter>
2670  <parameter name="TimersSessExpires">
2671  <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>
2672  </parameter>
2673  <parameter name="Auth">
2674  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='auth']/synopsis/node())"/></para>
2675  </parameter>
2676  <parameter name="OutboundAuth">
2677  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='outbound_auth']/synopsis/node())"/></para>
2678  </parameter>
2679  <parameter name="Aors">
2680  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='aors']/synopsis/node())"/></para>
2681  </parameter>
2682  <parameter name="MediaAddress">
2683  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='media_address']/synopsis/node())"/></para>
2684  </parameter>
2685  <parameter name="IdentifyBy">
2686  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='identify_by']/synopsis/node())"/></para>
2687  </parameter>
2688  <parameter name="DirectMedia">
2689  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='direct_media']/synopsis/node())"/></para>
2690  </parameter>
2691  <parameter name="DirectMediaMethod">
2692  <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>
2693  </parameter>
2694  <parameter name="TrustConnectedLine">
2695  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='trust_connected_line']/synopsis/node())"/></para>
2696  </parameter>
2697  <parameter name="SendConnectedLine">
2698  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_connected_line']/synopsis/node())"/></para>
2699  </parameter>
2700  <parameter name="ConnectedLineMethod">
2701  <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>
2702  </parameter>
2703  <parameter name="DirectMediaGlareMitigation">
2704  <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>
2705  </parameter>
2706  <parameter name="DisableDirectMediaOnNat">
2707  <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>
2708  </parameter>
2709  <parameter name="Callerid">
2710  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='callerid']/synopsis/node())"/></para>
2711  </parameter>
2712  <parameter name="CalleridPrivacy">
2713  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='callerid_privacy']/synopsis/node())"/></para>
2714  </parameter>
2715  <parameter name="CalleridTag">
2716  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='callerid_tag']/synopsis/node())"/></para>
2717  </parameter>
2718  <parameter name="TrustIdInbound">
2719  <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>
2720  </parameter>
2721  <parameter name="TrustIdOutbound">
2722  <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>
2723  </parameter>
2724  <parameter name="SendPai">
2725  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_pai']/synopsis/node())"/></para>
2726  </parameter>
2727  <parameter name="SendRpid">
2728  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_rpid']/synopsis/node())"/></para>
2729  </parameter>
2730  <parameter name="SendDiversion">
2731  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='send_diversion']/synopsis/node())"/></para>
2732  </parameter>
2733  <parameter name="Mailboxes">
2734  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='mailboxes']/synopsis/node())"/></para>
2735  </parameter>
2736  <parameter name="AggregateMwi">
2737  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='aggregate_mwi']/synopsis/node())"/></para>
2738  </parameter>
2739  <parameter name="MediaEncryption">
2740  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='media_encryption']/synopsis/node())"/></para>
2741  </parameter>
2742  <parameter name="MediaEncryptionOptimistic">
2743  <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>
2744  </parameter>
2745  <parameter name="UseAvpf">
2746  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='use_avpf']/synopsis/node())"/></para>
2747  </parameter>
2748  <parameter name="ForceAvp">
2749  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='force_avp']/synopsis/node())"/></para>
2750  </parameter>
2751  <parameter name="MediaUseReceivedTransport">
2752  <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>
2753  </parameter>
2754  <parameter name="OneTouchRecording">
2755  <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>
2756  </parameter>
2757  <parameter name="InbandProgress">
2758  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='inband_progress']/synopsis/node())"/></para>
2759  </parameter>
2760  <parameter name="CallGroup">
2761  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='call_group']/synopsis/node())"/></para>
2762  </parameter>
2763  <parameter name="PickupGroup">
2764  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='pickup_group']/synopsis/node())"/></para>
2765  </parameter>
2766  <parameter name="NamedCallGroup">
2767  <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>
2768  </parameter>
2769  <parameter name="NamedPickupGroup">
2770  <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>
2771  </parameter>
2772  <parameter name="DeviceStateBusyAt">
2773  <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>
2774  </parameter>
2775  <parameter name="T38Udptl">
2776  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='t38_udptl']/synopsis/node())"/></para>
2777  </parameter>
2778  <parameter name="T38UdptlEc">
2779  <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>
2780  </parameter>
2781  <parameter name="T38UdptlMaxdatagram">
2782  <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>
2783  </parameter>
2784  <parameter name="FaxDetect">
2785  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='fax_detect']/synopsis/node())"/></para>
2786  </parameter>
2787  <parameter name="T38UdptlNat">
2788  <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>
2789  </parameter>
2790  <parameter name="T38UdptlIpv6">
2791  <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>
2792  </parameter>
2793  <parameter name="T38BindUdptlToMediaAddress">
2794  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='t38_bind_udptl_to_media_address']/synopsis/node())"/></para>
2795  </parameter>
2796  <parameter name="ToneZone">
2797  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='tone_zone']/synopsis/node())"/></para>
2798  </parameter>
2799  <parameter name="Language">
2800  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='language']/synopsis/node())"/></para>
2801  </parameter>
2802  <parameter name="RecordOnFeature">
2803  <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>
2804  </parameter>
2805  <parameter name="RecordOffFeature">
2806  <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>
2807  </parameter>
2808  <parameter name="AllowTransfer">
2809  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow_transfer']/synopsis/node())"/></para>
2810  </parameter>
2811  <parameter name="UserEqPhone">
2812  <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>
2813  </parameter>
2814  <parameter name="MohPassthrough">
2815  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='moh_passthrough']/synopsis/node())"/></para>
2816  </parameter>
2817  <parameter name="SdpOwner">
2818  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='sdp_owner']/synopsis/node())"/></para>
2819  </parameter>
2820  <parameter name="SdpSession">
2821  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='sdp_session']/synopsis/node())"/></para>
2822  </parameter>
2823  <parameter name="TosAudio">
2824  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='tos_audio']/synopsis/node())"/></para>
2825  </parameter>
2826  <parameter name="TosVideo">
2827  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='tos_video']/synopsis/node())"/></para>
2828  </parameter>
2829  <parameter name="CosAudio">
2830  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='cos_audio']/synopsis/node())"/></para>
2831  </parameter>
2832  <parameter name="CosVideo">
2833  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='cos_video']/synopsis/node())"/></para>
2834  </parameter>
2835  <parameter name="AllowSubscribe">
2836  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow_subscribe']/synopsis/node())"/></para>
2837  </parameter>
2838  <parameter name="SubMinExpiry">
2839  <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>
2840  </parameter>
2841  <parameter name="FromUser">
2842  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='from_user']/synopsis/node())"/></para>
2843  </parameter>
2844  <parameter name="FromDomain">
2845  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='from_domain']/synopsis/node())"/></para>
2846  </parameter>
2847  <parameter name="MwiFromUser">
2848  <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>
2849  </parameter>
2850  <parameter name="RtpEngine">
2851  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='rtp_engine']/synopsis/node())"/></para>
2852  </parameter>
2853  <parameter name="DtlsVerify">
2854  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_verify']/synopsis/node())"/></para>
2855  </parameter>
2856  <parameter name="DtlsRekey">
2857  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_rekey']/synopsis/node())"/></para>
2858  </parameter>
2859  <parameter name="DtlsCertFile">
2860  <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>
2861  </parameter>
2862  <parameter name="DtlsPrivateKey">
2863  <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>
2864  </parameter>
2865  <parameter name="DtlsCipher">
2866  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_cipher']/synopsis/node())"/></para>
2867  </parameter>
2868  <parameter name="DtlsCaFile">
2869  <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>
2870  </parameter>
2871  <parameter name="DtlsCaPath">
2872  <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>
2873  </parameter>
2874  <parameter name="DtlsSetup">
2875  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='dtls_setup']/synopsis/node())"/></para>
2876  </parameter>
2877  <parameter name="SrtpTag32">
2878  <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>
2879  </parameter>
2880  <parameter name="RedirectMethod">
2881  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='redirect_method']/synopsis/node())"/></para>
2882  </parameter>
2883  <parameter name="SetVar">
2884  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='set_var']/synopsis/node())"/></para>
2885  </parameter>
2886  <parameter name="MessageContext">
2887  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='message_context']/synopsis/node())"/></para>
2888  </parameter>
2889  <parameter name="Accountcode">
2890  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='accountcode']/synopsis/node())"/></para>
2891  </parameter>
2892  <parameter name="PreferredCodecOnly">
2893  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='preferred_codec_only']/synopsis/node())"/></para>
2894  </parameter>
2895  <parameter name="DeviceState">
2896  <para>The aggregate device state for this endpoint.</para>
2897  </parameter>
2898  <parameter name="ActiveChannels">
2899  <para>The number of active channels associated with this endpoint.</para>
2900  </parameter>
2901  <parameter name="SubscribeContext">
2902  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='subscribe_context']/synopsis/node())"/></para>
2903  </parameter>
2904  <parameter name="Allowoverlap">
2905  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='endpoint']/configOption[@name='allow_overlap']/synopsis/node())"/></para>
2906  </parameter>
2907  </syntax>
2908  </managerEventInstance>
2909  </managerEvent>
2910  <managerEvent language="en_US" name="AorList">
2911  <managerEventInstance class="EVENT_FLAG_COMMAND">
2912  <synopsis>Provide details about an Address of Record (AoR) section.</synopsis>
2913  <syntax>
2914  <parameter name="ObjectType">
2915  <para>The object's type. This will always be 'aor'.</para>
2916  </parameter>
2917  <parameter name="ObjectName">
2918  <para>The name of this object.</para>
2919  </parameter>
2920  <parameter name="MinimumExpiration">
2921  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='minimum_expiration']/synopsis/node())"/></para>
2922  </parameter>
2923  <parameter name="MaximumExpiration">
2924  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='maximum_expiration']/synopsis/node())"/></para>
2925  </parameter>
2926  <parameter name="DefaultExpiration">
2927  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='default_expiration']/synopsis/node())"/></para>
2928  </parameter>
2929  <parameter name="QualifyFrequency">
2930  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='qualify_frequency']/synopsis/node())"/></para>
2931  </parameter>
2932  <parameter name="AuthenticateQualify">
2933  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='authenticate_qualify']/synopsis/node())"/></para>
2934  </parameter>
2935  <parameter name="MaxContacts">
2936  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='max_contacts']/synopsis/node())"/></para>
2937  </parameter>
2938  <parameter name="RemoveExisting">
2939  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='remove_existing']/synopsis/node())"/></para>
2940  </parameter>
2941  <parameter name="RemoveUnavailable">
2942  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='remove_unavailable']/synopsis/node())"/></para>
2943  </parameter>
2944  <parameter name="Mailboxes">
2945  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='mailboxes']/synopsis/node())"/></para>
2946  </parameter>
2947  <parameter name="OutboundProxy">
2948  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='outbound_proxy']/synopsis/node())"/></para>
2949  </parameter>
2950  <parameter name="SupportPath">
2951  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='aor']/configOption[@name='support_path']/synopsis/node())"/></para>
2952  </parameter>
2953  </syntax>
2954  </managerEventInstance>
2955  </managerEvent>
2956  <managerEvent language="en_US" name="AuthList">
2957  <managerEventInstance class="EVENT_FLAG_COMMAND">
2958  <synopsis>Provide details about an Address of Record (Auth) section.</synopsis>
2959  <syntax>
2960  <parameter name="ObjectType">
2961  <para>The object's type. This will always be 'auth'.</para>
2962  </parameter>
2963  <parameter name="ObjectName">
2964  <para>The name of this object.</para>
2965  </parameter>
2966  <parameter name="Username">
2967  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='username']/synopsis/node())"/></para>
2968  </parameter>
2969  <parameter name="Md5Cred">
2970  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='md5_cred']/synopsis/node())"/></para>
2971  </parameter>
2972  <parameter name="Realm">
2973  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='realm']/synopsis/node())"/></para>
2974  </parameter>
2975  <parameter name="AuthType">
2976  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='auth_type']/synopsis/node())"/></para>
2977  </parameter>
2978  <parameter name="Password">
2979  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='password']/synopsis/node())"/></para>
2980  </parameter>
2981  <parameter name="NonceLifetime">
2982  <para><xi:include xpointer="xpointer(/docs/configInfo[@name='res_pjsip']/configFile[@name='pjsip.conf']/configObject[@name='auth']/configOption[@name='nonce_lifetime']/synopsis/node())"/></para>
2983  </parameter>
2984  </syntax>
2985  </managerEventInstance>
2986  </managerEvent>
2987  <managerEvent language="en_US" name="ContactList">
2988  <managerEventInstance class="EVENT_FLAG_COMMAND">
2989  <synopsis>Provide details about a contact section.</synopsis>
2990  <syntax>
2991  <parameter name="ObjectType">
2992  <para>The object's type. This will always be 'contact'.</para>
2993  </parameter>
2994  <parameter name="ObjectName">
2995  <para>The name of this object.</para>
2996  </parameter>
2997  <parameter name="ViaAddr">
2998  <para>IP address of the last Via header in REGISTER request.
2999  Will only appear in the event if available.</para>
3000  </parameter>
3001  <parameter name="ViaPort">
3002  <para>Port number of the last Via header in REGISTER request.
3003  Will only appear in the event if available.</para>
3004  </parameter>
3005  <parameter name="QualifyTimeout">
3006  <para>The elapsed time in decimal seconds after which an OPTIONS
3007  message is sent before the contact is considered unavailable.</para>
3008  </parameter>
3009  <parameter name="CallId">
3010  <para>Content of the Call-ID header in REGISTER request.
3011  Will only appear in the event if available.</para>
3012  </parameter>
3013  <parameter name="RegServer">
3014  <para>Asterisk Server name.</para>
3015  </parameter>
3016  <parameter name="PruneOnBoot">
3017  <para>If true delete the contact on Asterisk restart/boot.</para>
3018  </parameter>
3019  <parameter name="Path">
3020  <para>The Path header received on the REGISTER.</para>
3021  </parameter>
3022  <parameter name="Endpoint">
3023  <para>The name of the endpoint associated with this information.</para>
3024  </parameter>
3025  <parameter name="AuthenticateQualify">
3026  <para>A boolean indicating whether a qualify should be authenticated.</para>
3027  </parameter>
3028  <parameter name="Uri">
3029  <para>This contact's URI.</para>
3030  </parameter>
3031  <parameter name="QualifyFrequency">
3032  <para>The interval in seconds at which the contact will be qualified.</para>
3033  </parameter>
3034  <parameter name="UserAgent">
3035  <para>Content of the User-Agent header in REGISTER request</para>
3036  </parameter>
3037  <parameter name="ExpirationTime">
3038  <para>Absolute time that this contact is no longer valid after</para>
3039  </parameter>
3040  <parameter name="OutboundProxy">
3041  <para>The contact's outbound proxy.</para>
3042  </parameter>
3043  <parameter name="Status">
3044  <para>This contact's status.</para>
3045  <enumlist>
3046  <enum name="Reachable"/>
3047  <enum name="Unreachable"/>
3048  <enum name="NonQualified"/>
3049  <enum name="Unknown"/>
3050  </enumlist>
3051  </parameter>
3052  <parameter name="RoundtripUsec">
3053  <para>The round trip time in microseconds.</para>
3054  </parameter>
3055  </syntax>
3056  </managerEventInstance>
3057  </managerEvent>
3058  <managerEvent language="en_US" name="ContactStatusDetail">
3059  <managerEventInstance class="EVENT_FLAG_COMMAND">
3060  <synopsis>Provide details about a contact's status.</synopsis>
3061  <syntax>
3062  <parameter name="AOR">
3063  <para>The AoR that owns this contact.</para>
3064  </parameter>
3065  <parameter name="URI">
3066  <para>This contact's URI.</para>
3067  </parameter>
3068  <parameter name="Status">
3069  <para>This contact's status.</para>
3070  <enumlist>
3071  <enum name="Reachable"/>
3072  <enum name="Unreachable"/>
3073  <enum name="NonQualified"/>
3074  <enum name="Unknown"/>
3075  </enumlist>
3076  </parameter>
3077  <parameter name="RoundtripUsec">
3078  <para>The round trip time in microseconds.</para>
3079  </parameter>
3080  <parameter name="EndpointName">
3081  <para>The name of the endpoint associated with this information.</para>
3082  </parameter>
3083  <parameter name="UserAgent">
3084  <para>Content of the User-Agent header in REGISTER request</para>
3085  </parameter>
3086  <parameter name="RegExpire">
3087  <para>Absolute time that this contact is no longer valid after</para>
3088  </parameter>
3089  <parameter name="ViaAddress">
3090  <para>IP address:port of the last Via header in REGISTER request.
3091  Will only appear in the event if available.</para>
3092  </parameter>
3093  <parameter name="CallID">
3094  <para>Content of the Call-ID header in REGISTER request.
3095  Will only appear in the event if available.</para>
3096  </parameter>
3097  <parameter name="ID">
3098  <para>The sorcery ID of the contact.</para>
3099  </parameter>
3100  <parameter name="AuthenticateQualify">
3101  <para>A boolean indicating whether a qualify should be authenticated.</para>
3102  </parameter>
3103  <parameter name="OutboundProxy">
3104  <para>The contact's outbound proxy.</para>
3105  </parameter>
3106  <parameter name="Path">
3107  <para>The Path header received on the REGISTER.</para>
3108  </parameter>
3109  <parameter name="QualifyFrequency">
3110  <para>The interval in seconds at which the contact will be qualified.</para>
3111  </parameter>
3112  <parameter name="QualifyTimeout">
3113  <para>The elapsed time in decimal seconds after which an OPTIONS
3114  message is sent before the contact is considered unavailable.</para>
3115  </parameter>
3116  </syntax>
3117  </managerEventInstance>
3118  </managerEvent>
3119  <managerEvent language="en_US" name="EndpointList">
3120  <managerEventInstance class="EVENT_FLAG_COMMAND">
3121  <synopsis>Provide details about a contact's status.</synopsis>
3122  <syntax>
3123  <parameter name="ObjectType">
3124  <para>The object's type. This will always be 'endpoint'.</para>
3125  </parameter>
3126  <parameter name="ObjectName">
3127  <para>The name of this object.</para>
3128  </parameter>
3129  <parameter name="Transport">
3130  <para>The transport configurations associated with this endpoint.</para>
3131  </parameter>
3132  <parameter name="Aor">
3133  <para>The aor configurations associated with this endpoint.</para>
3134  </parameter>
3135  <parameter name="Auths">
3136  <para>The inbound authentication configurations associated with this endpoint.</para>
3137  </parameter>
3138  <parameter name="OutboundAuths">
3139  <para>The outbound authentication configurations associated with this endpoint.</para>
3140  </parameter>
3141  <parameter name="DeviceState">
3142  <para>The aggregate device state for this endpoint.</para>
3143  </parameter>
3144  <parameter name="ActiveChannels">
3145  <para>The number of active channels associated with this endpoint.</para>
3146  </parameter>
3147  </syntax>
3148  </managerEventInstance>
3149  </managerEvent>
3150  <manager name="PJSIPShowEndpoints" language="en_US">
3151  <synopsis>
3152  Lists PJSIP endpoints.
3153  </synopsis>
3154  <syntax />
3155  <description>
3156  <para>
3157  Provides a listing of all endpoints. For each endpoint an <literal>EndpointList</literal> event
3158  is raised that contains relevant attributes and status information. Once all
3159  endpoints have been listed an <literal>EndpointListComplete</literal> event is issued.
3160  </para>
3161  </description>
3162  <responses>
3163  <list-elements>
3164  <xi:include xpointer="xpointer(/docs/managerEvent[@name='EndpointList'])" />
3165  </list-elements>
3166  <managerEvent language="en_US" name="EndpointListComplete">
3167  <managerEventInstance class="EVENT_FLAG_COMMAND">
3168  <synopsis>Provide final information about an endpoint list.</synopsis>
3169  <syntax>
3170  <parameter name="EventList"/>
3171  <parameter name="ListItems"/>
3172  </syntax>
3173  </managerEventInstance>
3174  </managerEvent>
3175  </responses>
3176  </manager>
3177  <manager name="PJSIPShowEndpoint" language="en_US">
3178  <synopsis>
3179  Detail listing of an endpoint and its objects.
3180  </synopsis>
3181  <syntax>
3182  <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
3183  <parameter name="Endpoint" required="true">
3184  <para>The endpoint to list.</para>
3185  </parameter>
3186  </syntax>
3187  <description>
3188  <para>
3189  Provides a detailed listing of options for a given endpoint. Events are issued
3190  showing the configuration and status of the endpoint and associated objects. These
3191  events include <literal>EndpointDetail</literal>, <literal>AorDetail</literal>,
3192  <literal>AuthDetail</literal>, <literal>TransportDetail</literal>, and
3193  <literal>IdentifyDetail</literal>. Some events may be listed multiple times if multiple objects are
3194  associated (for instance AoRs). Once all detail events have been raised a final
3195  <literal>EndpointDetailComplete</literal> event is issued.
3196  </para>
3197  </description>
3198  <responses>
3199  <list-elements>
3200  <xi:include xpointer="xpointer(/docs/managerEvent[@name='EndpointDetail'])" />
3201  <xi:include xpointer="xpointer(/docs/managerEvent[@name='IdentifyDetail'])" />
3202  <xi:include xpointer="xpointer(/docs/managerEvent[@name='ContactStatusDetail'])" />
3203  <xi:include xpointer="xpointer(/docs/managerEvent[@name='AuthDetail'])" />
3204  <xi:include xpointer="xpointer(/docs/managerEvent[@name='TransportDetail'])" />
3205  <xi:include xpointer="xpointer(/docs/managerEvent[@name='AorDetail'])" />
3206  </list-elements>
3207  <managerEvent language="en_US" name="EndpointDetailComplete">
3208  <managerEventInstance class="EVENT_FLAG_COMMAND">
3209  <synopsis>Provide final information about endpoint details.</synopsis>
3210  <syntax>
3211  <parameter name="EventList"/>
3212  <parameter name="ListItems"/>
3213  </syntax>
3214  </managerEventInstance>
3215  </managerEvent>
3216  </responses>
3217  </manager>
3218  <manager name="PJSIPShowAors" language="en_US">
3219  <synopsis>
3220  Lists PJSIP AORs.
3221  </synopsis>
3222  <syntax />
3223  <description>
3224  <para>
3225  Provides a listing of all AORs. For each AOR an <literal>AorList</literal> event
3226  is raised that contains relevant attributes and status information. Once all
3227  aors have been listed an <literal>AorListComplete</literal> event is issued.
3228  </para>
3229  </description>
3230  <responses>
3231  <list-elements>
3232  <xi:include xpointer="xpointer(/docs/managerEvent[@name='AorList'])" />
3233  </list-elements>
3234  <managerEvent language="en_US" name="AorListComplete">
3235  <managerEventInstance class="EVENT_FLAG_COMMAND">
3236  <synopsis>Provide final information about an aor list.</synopsis>
3237  <syntax>
3238  <parameter name="EventList"/>
3239  <parameter name="ListItems"/>
3240  </syntax>
3241  </managerEventInstance>
3242  </managerEvent>
3243  </responses>
3244  </manager>
3245  <manager name="PJSIPShowAuths" language="en_US">
3246  <synopsis>
3247  Lists PJSIP Auths.
3248  </synopsis>
3249  <syntax />
3250  <description>
3251  <para>Provides a listing of all Auths. For each Auth an <literal>AuthList</literal> event
3252  is raised that contains relevant attributes and status information. Once all
3253  auths have been listed an <literal>AuthListComplete</literal> event is issued.
3254  </para>
3255  </description>
3256  <responses>
3257  <list-elements>
3258  <xi:include xpointer="xpointer(/docs/managerEvent[@name='AuthList'])" />
3259  </list-elements>
3260  <managerEvent language="en_US" name="AuthListComplete">
3261  <managerEventInstance class="EVENT_FLAG_COMMAND">
3262  <synopsis>Provide final information about an auth list.</synopsis>
3263  <syntax>
3264  <parameter name="EventList"/>
3265  <parameter name="ListItems"/>
3266  </syntax>
3267  </managerEventInstance>
3268  </managerEvent>
3269  </responses>
3270  </manager>
3271  <manager name="PJSIPShowContacts" language="en_US">
3272  <synopsis>
3273  Lists PJSIP Contacts.
3274  </synopsis>
3275  <syntax />
3276  <description>
3277  <para>Provides a listing of all Contacts. For each Contact a <literal>ContactList</literal>
3278  event is raised that contains relevant attributes and status information.
3279  Once all contacts have been listed a <literal>ContactListComplete</literal> event
3280  is issued.
3281  </para>
3282  </description>
3283  <responses>
3284  <list-elements>
3285  <xi:include xpointer="xpointer(/docs/managerEvent[@name='ContactList'])" />
3286  </list-elements>
3287  <managerEvent language="en_US" name="ContactListComplete">
3288  <managerEventInstance class="EVENT_FLAG_COMMAND">
3289  <synopsis>Provide final information about a contact list.</synopsis>
3290  <syntax>
3291  <parameter name="EventList"/>
3292  <parameter name="ListItems"/>
3293  </syntax>
3294  </managerEventInstance>
3295  </managerEvent>
3296  </responses>
3297  </manager>
3298 
3299  ***/
3300 
3301 #define MOD_DATA_CONTACT "contact"
3302 
3303 /*! Number of serializers in pool if one not supplied. */
3304 #define SERIALIZER_POOL_SIZE 8
3305 
3306 /*! Pool of serializers to use if not supplied. */
3308 
3309 static pjsip_endpoint *ast_pjsip_endpoint;
3310 
3312 
3313 /*! Local host address for IPv4 */
3314 static pj_sockaddr host_ip_ipv4;
3315 
3316 /*! Local host address for IPv4 (string form) */
3317 static char host_ip_ipv4_string[PJ_INET6_ADDRSTRLEN];
3318 
3319 /*! Local host address for IPv6 */
3320 static pj_sockaddr host_ip_ipv6;
3321 
3322 /*! Local host address for IPv6 (string form) */
3323 static char host_ip_ipv6_string[PJ_INET6_ADDRSTRLEN];
3324 
3325 void ast_sip_add_date_header(pjsip_tx_data *tdata)
3326 {
3327  char date[256];
3328  struct tm tm;
3329  time_t t = time(NULL);
3330 
3331  gmtime_r(&t, &tm);
3332  strftime(date, sizeof(date), "%a, %d %b %Y %T GMT", &tm);
3333 
3334  ast_sip_add_header(tdata, "Date", date);
3335 }
3336 
3337 static int register_service(void *data)
3338 {
3339  pjsip_module **module = data;
3340  if (!ast_pjsip_endpoint) {
3341  ast_log(LOG_ERROR, "There is no PJSIP endpoint. Unable to register services\n");
3342  return -1;
3343  }
3344  if (pjsip_endpt_register_module(ast_pjsip_endpoint, *module) != PJ_SUCCESS) {
3345  ast_log(LOG_ERROR, "Unable to register module %.*s\n", (int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name));
3346  return -1;
3347  }
3348  ast_debug(1, "Registered SIP service %.*s (%p)\n", (int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name), *module);
3349  return 0;
3350 }
3351 
3352 int ast_sip_register_service(pjsip_module *module)
3353 {
3355 }
3356 
3357 static int unregister_service(void *data)
3358 {
3359  pjsip_module **module = data;
3360  if (!ast_pjsip_endpoint) {
3361  return -1;
3362  }
3363  pjsip_endpt_unregister_module(ast_pjsip_endpoint, *module);
3364  ast_debug(1, "Unregistered SIP service %.*s\n", (int) pj_strlen(&(*module)->name), pj_strbuf(&(*module)->name));
3365  return 0;
3366 }
3367 
3368 void ast_sip_unregister_service(pjsip_module *module)
3369 {
3371 }
3372 
3374 
3376 {
3377  if (registered_authenticator) {
3378  ast_log(LOG_WARNING, "Authenticator %p is already registered. Cannot register a new one\n", registered_authenticator);
3379  return -1;
3380  }
3381  registered_authenticator = auth;
3382  ast_debug(1, "Registered SIP authenticator module %p\n", auth);
3383 
3384  return 0;
3385 }
3386 
3388 {
3389  if (registered_authenticator != auth) {
3390  ast_log(LOG_WARNING, "Trying to unregister authenticator %p but authenticator %p registered\n",
3391  auth, registered_authenticator);
3392  return;
3393  }
3394  registered_authenticator = NULL;
3395  ast_debug(1, "Unregistered SIP authenticator %p\n", auth);
3396 }
3397 
3398 int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
3399 {
3400  if (endpoint->allow_unauthenticated_options
3401  && !pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, &pjsip_options_method)) {
3402  ast_debug(3, "Skipping OPTIONS authentication due to endpoint configuration\n");
3403  return 0;
3404  }
3405 
3406  if (!registered_authenticator) {
3407  ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is not required\n");
3408  return 0;
3409  }
3410 
3411  return registered_authenticator->requires_authentication(endpoint, rdata);
3412 }
3413 
3415  pjsip_rx_data *rdata, pjsip_tx_data *tdata)
3416 {
3417  if (!registered_authenticator) {
3418  ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is successful\n");
3420  }
3421  return registered_authenticator->check_authentication(endpoint, rdata, tdata);
3422 }
3423 
3425 
3427 {
3428  if (registered_outbound_authenticator) {
3429  ast_log(LOG_WARNING, "Outbound authenticator %p is already registered. Cannot register a new one\n", registered_outbound_authenticator);
3430  return -1;
3431  }
3432  registered_outbound_authenticator = auth;
3433  ast_debug(1, "Registered SIP outbound authenticator module %p\n", auth);
3434 
3435  return 0;
3436 }
3437 
3439 {
3440  if (registered_outbound_authenticator != auth) {
3441  ast_log(LOG_WARNING, "Trying to unregister outbound authenticator %p but outbound authenticator %p registered\n",
3442  auth, registered_outbound_authenticator);
3443  return;
3444  }
3445  registered_outbound_authenticator = NULL;
3446  ast_debug(1, "Unregistered SIP outbound authenticator %p\n", auth);
3447 }
3448 
3449 int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge,
3450  pjsip_tx_data *old_request, pjsip_tx_data **new_request)
3451 {
3452  if (!registered_outbound_authenticator) {
3453  ast_log(LOG_WARNING, "No SIP outbound authenticator registered. Cannot respond to authentication challenge\n");
3454  return -1;
3455  }
3456  return registered_outbound_authenticator->create_request_with_auth(auths, challenge, old_request, new_request);
3457 }
3458 
3460  const char *name;
3461  unsigned int priority;
3464 };
3465 
3467 
3469  const char *name)
3470 {
3471  char *prev, *current, *identifier_order;
3472  struct endpoint_identifier_list *iter, *id_list_item;
3474 
3475  id_list_item = ast_calloc(1, sizeof(*id_list_item));
3476  if (!id_list_item) {
3477  ast_log(LOG_ERROR, "Unable to add endpoint identifier. Out of memory.\n");
3478  return -1;
3479  }
3480  id_list_item->identifier = identifier;
3481  id_list_item->name = name;
3482 
3483  ast_debug(1, "Register endpoint identifier %s(%p)\n", name ?: "", identifier);
3484 
3485  if (ast_strlen_zero(name)) {
3486  /* if an identifier has no name then place in front */
3487  AST_RWLIST_INSERT_HEAD(&endpoint_identifiers, id_list_item, list);
3488  return 0;
3489  }
3490 
3491  /* see if the name of the identifier is in the global endpoint_identifier_order list */
3492  identifier_order = prev = current = ast_sip_get_endpoint_identifier_order();
3493 
3494  if (ast_strlen_zero(identifier_order)) {
3495  id_list_item->priority = UINT_MAX;
3496  AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
3497  ast_free(identifier_order);
3498  return 0;
3499  }
3500 
3501  id_list_item->priority = 0;
3502  while ((current = strchr(current, ','))) {
3503  ++id_list_item->priority;
3504  if (!strncmp(prev, name, current - prev)
3505  && strlen(name) == current - prev) {
3506  break;
3507  }
3508  prev = ++current;
3509  }
3510 
3511  if (!current) {
3512  /* check to see if it is the only or last item */
3513  if (!strcmp(prev, name)) {
3514  ++id_list_item->priority;
3515  } else {
3516  id_list_item->priority = UINT_MAX;
3517  }
3518  }
3519 
3520  if (id_list_item->priority == UINT_MAX || AST_RWLIST_EMPTY(&endpoint_identifiers)) {
3521  /* if not in the endpoint_identifier_order list then consider it less in
3522  priority and add it to the end */
3523  AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
3524  ast_free(identifier_order);
3525  return 0;
3526  }
3527 
3529  if (id_list_item->priority < iter->priority) {
3530  AST_RWLIST_INSERT_BEFORE_CURRENT(id_list_item, list);
3531  break;
3532  }
3533 
3534  if (!AST_RWLIST_NEXT(iter, list)) {
3535  AST_RWLIST_INSERT_AFTER(&endpoint_identifiers, iter, id_list_item, list);
3536  break;
3537  }
3538  }
3540 
3541  ast_free(identifier_order);
3542  return 0;
3543 }
3544 
3546 {
3548 }
3549 
3551 {
3552  struct endpoint_identifier_list *iter;
3555  if (iter->identifier == identifier) {
3557  ast_free(iter);
3558  ast_debug(1, "Unregistered endpoint identifier %p\n", identifier);
3559  break;
3560  }
3561  }
3563 }
3564 
3565 struct ast_sip_endpoint *ast_sip_identify_endpoint(pjsip_rx_data *rdata)
3566 {
3567  struct endpoint_identifier_list *iter;
3568  struct ast_sip_endpoint *endpoint = NULL;
3572  endpoint = iter->identifier->identify_endpoint(rdata);
3573  if (endpoint) {
3574  break;
3575  }
3576  }
3577  return endpoint;
3578 }
3579 
3580 char *ast_sip_rdata_get_header_value(pjsip_rx_data *rdata, const pj_str_t str)
3581 {
3582  pjsip_generic_string_hdr *hdr;
3583  pj_str_t hdr_val;
3584 
3585  hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str, NULL);
3586  if (!hdr) {
3587  return NULL;
3588  }
3589 
3590  pj_strdup_with_null(rdata->tp_info.pool, &hdr_val, &hdr->hvalue);
3591 
3592  return hdr_val.ptr;
3593 }
3594 
3595 static int do_cli_dump_endpt(void *v_a)
3596 {
3597  struct ast_cli_args *a = v_a;
3598 
3600  pjsip_endpt_dump(ast_sip_get_pjsip_endpoint(), a->argc == 4 ? PJ_TRUE : PJ_FALSE);
3602 
3603  return 0;
3604 }
3605 
3606 static char *cli_dump_endpt(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
3607 {
3608  switch (cmd) {
3609  case CLI_INIT:
3610 #ifdef AST_DEVMODE
3611  e->command = "pjsip dump endpt [details]";
3612  e->usage =
3613  "Usage: pjsip dump endpt [details]\n"
3614  " Dump the res_pjsip endpt internals.\n"
3615  "\n"
3616  "Warning: PJPROJECT documents that the function used by this\n"
3617  "CLI command may cause a crash when asking for details because\n"
3618  "it tries to access all active memory pools.\n";
3619 #else
3620  /*
3621  * In non-developer mode we will not document or make easily accessible
3622  * the details option even though it is still available. The user has
3623  * to know it exists to use it. Presumably they would also be aware of
3624  * the potential crash warning.
3625  */
3626  e->command = "pjsip dump endpt";
3627  e->usage =
3628  "Usage: pjsip dump endpt\n"
3629  " Dump the res_pjsip endpt internals.\n";
3630 #endif /* AST_DEVMODE */
3631  return NULL;
3632  case CLI_GENERATE:
3633  return NULL;
3634  }
3635 
3636  if (4 < a->argc
3637  || (a->argc == 4 && strcasecmp(a->argv[3], "details"))) {
3638  return CLI_SHOWUSAGE;
3639  }
3640 
3642 
3643  return CLI_SUCCESS;
3644 }
3645 
3646 static char *cli_show_endpoint_identifiers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
3647 {
3648 #define ENDPOINT_IDENTIFIER_FORMAT "%-20.20s\n"
3649  struct endpoint_identifier_list *iter;
3650 
3651  switch (cmd) {
3652  case CLI_INIT:
3653  e->command = "pjsip show identifiers";
3654  e->usage = "Usage: pjsip show identifiers\n"
3655  " List all registered endpoint identifiers\n";
3656  return NULL;
3657  case CLI_GENERATE:
3658  return NULL;
3659  }
3660 
3661  if (a->argc != 3) {
3662  return CLI_SHOWUSAGE;
3663  }
3664 
3665  ast_cli(a->fd, ENDPOINT_IDENTIFIER_FORMAT, "Identifier Names:");
3666  {
3670  iter->name ? iter->name : "name not specified");
3671  }
3672  }
3673  return CLI_SUCCESS;
3674 #undef ENDPOINT_IDENTIFIER_FORMAT
3675 }
3676 
3677 static char *cli_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
3678 {
3679  struct ast_sip_cli_context context;
3680 
3681  switch (cmd) {
3682  case CLI_INIT:
3683  e->command = "pjsip show settings";
3684  e->usage = "Usage: pjsip show settings\n"
3685  " Show global and system configuration options\n";
3686  return NULL;
3687  case CLI_GENERATE:
3688  return NULL;
3689  }
3690 
3691  context.output_buffer = ast_str_create(256);
3692  if (!context.output_buffer) {
3693  ast_cli(a->fd, "Could not allocate output buffer.\n");
3694  return CLI_FAILURE;
3695  }
3696 
3697  if (sip_cli_print_global(&context) || sip_cli_print_system(&context)) {
3698  ast_free(context.output_buffer);
3699  ast_cli(a->fd, "Error retrieving settings.\n");
3700  return CLI_FAILURE;
3701  }
3702 
3703  ast_cli(a->fd, "%s", ast_str_buffer(context.output_buffer));
3704  ast_free(context.output_buffer);
3705  return CLI_SUCCESS;
3706 }
3707 
3708 static struct ast_cli_entry cli_commands[] = {
3709  AST_CLI_DEFINE(cli_dump_endpt, "Dump the res_pjsip endpt internals"),
3710  AST_CLI_DEFINE(cli_show_settings, "Show global and system configuration options"),
3711  AST_CLI_DEFINE(cli_show_endpoint_identifiers, "List registered endpoint identifiers")
3712 };
3713 
3715 
3717 {
3720 }
3721 
3723 {
3724  struct ast_sip_endpoint_formatter *i;
3726 
3728  if (i == obj) {
3730  break;
3731  }
3732  }
3734 }
3735 
3737  struct ast_sip_ami *ami, int *count)
3738 {
3739  int res = 0;
3740  struct ast_sip_endpoint_formatter *i;
3742  *count = 0;
3744  if (i->format_ami && ((res = i->format_ami(endpoint, ami)) < 0)) {
3745  return res;
3746  }
3747 
3748  if (!res) {
3749  (*count)++;
3750  }
3751  }
3752  return 0;
3753 }
3754 
3755 pjsip_endpoint *ast_sip_get_pjsip_endpoint(void)
3756 {
3757  return ast_pjsip_endpoint;
3758 }
3759 
3760 int ast_sip_will_uri_survive_restart(pjsip_sip_uri *uri, struct ast_sip_endpoint *endpoint,
3761  pjsip_rx_data *rdata)
3762 {
3763  pj_str_t host_name;
3764  int result = 1;
3765 
3766  /* Determine if the contact cannot survive a restart/boot. */
3767  if (uri->port == rdata->pkt_info.src_port
3768  && !pj_strcmp(&uri->host,
3769  pj_cstr(&host_name, rdata->pkt_info.src_name))
3770  /* We have already checked if the URI scheme is sip: or sips: */
3771  && PJSIP_TRANSPORT_IS_RELIABLE(rdata->tp_info.transport)) {
3772  pj_str_t type_name;
3773 
3774  /* Determine the transport parameter value */
3775  if (!strcasecmp("WSS", rdata->tp_info.transport->type_name)) {
3776  /* WSS is special, as it needs to be ws. */
3777  pj_cstr(&type_name, "ws");
3778  } else {
3779  pj_cstr(&type_name, rdata->tp_info.transport->type_name);
3780  }
3781 
3782  if (!pj_stricmp(&uri->transport_param, &type_name)
3783  && (endpoint->nat.rewrite_contact
3784  /* Websockets are always rewritten */
3785  || !pj_stricmp(&uri->transport_param,
3786  pj_cstr(&type_name, "ws")))) {
3787  /*
3788  * The contact was rewritten to the reliable transport's
3789  * source address. Disconnecting the transport for any
3790  * reason invalidates the contact.
3791  */
3792  result = 0;
3793  }
3794  }
3795 
3796  return result;
3797 }
3798 
3800  pjsip_sip_uri *sip_uri, char *buf, size_t buf_len)
3801 {
3802  char *host = NULL;
3803  static const pj_str_t x_name = { AST_SIP_X_AST_TXP, AST_SIP_X_AST_TXP_LEN };
3804  pjsip_param *x_transport;
3805 
3806  if (!ast_strlen_zero(endpoint->transport)) {
3807  ast_copy_string(buf, endpoint->transport, buf_len);
3808  return 0;
3809  }
3810 
3811  x_transport = pjsip_param_find(&sip_uri->other_param, &x_name);
3812  if (!x_transport) {
3813  return -1;
3814  }
3815 
3816  /* Only use x_transport if the uri host is an ip (4 or 6) address */
3817  host = ast_alloca(sip_uri->host.slen + 1);
3818  ast_copy_pj_str(host, &sip_uri->host, sip_uri->host.slen + 1);
3819  if (!ast_sockaddr_parse(NULL, host, PARSE_PORT_FORBID)) {
3820  return -1;
3821  }
3822 
3823  ast_copy_pj_str(buf, &x_transport->value, buf_len);
3824 
3825  return 0;
3826 }
3827 
3828 int ast_sip_dlg_set_transport(const struct ast_sip_endpoint *endpoint, pjsip_dialog *dlg,
3829  pjsip_tpselector *selector)
3830 {
3831  pjsip_sip_uri *uri;
3832  pjsip_tpselector sel = { .type = PJSIP_TPSELECTOR_NONE, };
3833 
3834  uri = pjsip_uri_get_uri(dlg->target);
3835  if (!selector) {
3836  selector = &sel;
3837  }
3838 
3839  ast_sip_set_tpselector_from_ep_or_uri(endpoint, uri, selector);
3840 
3841  pjsip_dlg_set_transport(dlg, selector);
3842 
3843  if (selector == &sel) {
3845  }
3846 
3847  return 0;
3848 }
3849 
3850 static int sip_dialog_create_from(pj_pool_t *pool, pj_str_t *from, const char *user,
3851  const char *domain, const pj_str_t *target, pjsip_tpselector *selector)
3852 {
3853  pj_str_t tmp, local_addr;
3854  pjsip_uri *uri;
3855  pjsip_sip_uri *sip_uri;
3856  pjsip_transport_type_e type;
3857  int local_port;
3858  char default_user[PJSIP_MAX_URL_SIZE];
3859 
3860  if (ast_strlen_zero(user)) {
3861  ast_sip_get_default_from_user(default_user, sizeof(default_user));
3862  user = default_user;
3863  }
3864 
3865  /* Parse the provided target URI so we can determine what transport it will end up using */
3866  pj_strdup_with_null(pool, &tmp, target);
3867 
3868  if (!(uri = pjsip_parse_uri(pool, tmp.ptr, tmp.slen, 0)) ||
3869  (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
3870  return -1;
3871  }
3872 
3873  sip_uri = pjsip_uri_get_uri(uri);
3874 
3875  /* Determine the transport type to use */
3876  type = pjsip_transport_get_type_from_name(&sip_uri->transport_param);
3877  if (PJSIP_URI_SCHEME_IS_SIPS(sip_uri)) {
3878  if (type == PJSIP_TRANSPORT_UNSPECIFIED
3879  || !(pjsip_transport_get_flag_from_type(type) & PJSIP_TRANSPORT_SECURE)) {
3880  type = PJSIP_TRANSPORT_TLS;
3881  }
3882  } else if (!sip_uri->transport_param.slen) {
3883  type = PJSIP_TRANSPORT_UDP;
3884  } else if (type == PJSIP_TRANSPORT_UNSPECIFIED) {
3885  return -1;
3886  }
3887 
3888  /* If the host is IPv6 turn the transport into an IPv6 version */
3889  if (pj_strchr(&sip_uri->host, ':')) {
3890  type |= PJSIP_TRANSPORT_IPV6;
3891  }
3892 
3893  /* In multidomain scenario, username may contain @ with domain info */
3894  if (!ast_sip_get_disable_multi_domain() && strchr(user, '@')) {
3895  from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
3896  from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
3897  "<sip:%s%s%s>",
3898  user,
3899  (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
3900  (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
3901  return 0;
3902  }
3903 
3904  if (!ast_strlen_zero(domain)) {
3905  from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
3906  from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
3907  "<sip:%s@%s%s%s>",
3908  user,
3909  domain,
3910  (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
3911  (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
3912  return 0;
3913  }
3914 
3915  /* Get the local bound address for the transport that will be used when communicating with the provided URI */
3916  if (pjsip_tpmgr_find_local_addr(pjsip_endpt_get_tpmgr(ast_sip_get_pjsip_endpoint()), pool, type, selector,
3917  &local_addr, &local_port) != PJ_SUCCESS) {
3918 
3919  /* If no local address can be retrieved using the transport manager use the host one */
3920  pj_strdup(pool, &local_addr, pj_gethostname());
3921  local_port = pjsip_transport_get_default_port_for_type(PJSIP_TRANSPORT_UDP);
3922  }
3923 
3924  /* If IPv6 was specified in the transport, set the proper type */
3925  if (pj_strchr(&local_addr, ':')) {
3926  type |= PJSIP_TRANSPORT_IPV6;
3927  }
3928 
3929  from->ptr = pj_pool_alloc(pool, PJSIP_MAX_URL_SIZE);
3930  from->slen = pj_ansi_snprintf(from->ptr, PJSIP_MAX_URL_SIZE,
3931  "<sip:%s@%s%.*s%s:%d%s%s>",
3932  user,
3933  (type & PJSIP_TRANSPORT_IPV6) ? "[" : "",
3934  (int)local_addr.slen,
3935  local_addr.ptr,
3936  (type & PJSIP_TRANSPORT_IPV6) ? "]" : "",
3937  local_port,
3938  (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
3939  (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
3940 
3941  return 0;
3942 }
3943 
3944 int ast_sip_set_tpselector_from_transport(const struct ast_sip_transport *transport, pjsip_tpselector *selector)
3945 {
3946  int res = 0;
3947  struct ast_sip_transport_state *transport_state;
3948 
3949  transport_state = ast_sip_get_transport_state(ast_sorcery_object_get_id(transport));
3950  if (!transport_state) {
3951  ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport state for '%s'\n",
3952  ast_sorcery_object_get_id(transport));
3953  return -1;
3954  }
3955 
3956  /* Only flows maintain dynamic state which needs protection */
3957  if (transport_state->flow) {
3958  ao2_lock(transport_state);
3959  }
3960 
3961  if (transport_state->transport) {
3962  selector->type = PJSIP_TPSELECTOR_TRANSPORT;
3963  selector->u.transport = transport_state->transport;
3964  pjsip_transport_add_ref(selector->u.transport);
3965  } else if (transport_state->factory) {
3966  selector->type = PJSIP_TPSELECTOR_LISTENER;
3967  selector->u.listener = transport_state->factory;
3968  } else if (transport->type == AST_TRANSPORT_WS || transport->type == AST_TRANSPORT_WSS) {
3969  /* The WebSocket transport has no factory as it can not create outgoing connections, so
3970  * even if an endpoint is locked to a WebSocket transport we let the PJSIP logic
3971  * find the existing connection if available and use it.
3972  */
3973  } else if (transport->flow) {
3974  /* This is a child of another transport, so we need to establish a new connection */
3975 #ifdef HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE
3976  selector->disable_connection_reuse = PJ_TRUE;
3977 #else
3978  ast_log(LOG_WARNING, "Connection reuse could not be disabled on transport '%s' as support is not available\n",
3979  ast_sorcery_object_get_id(transport));
3980 #endif
3981  } else {
3982  res = -1;
3983  }
3984 
3985  if (transport_state->flow) {
3986  ao2_unlock(transport_state);
3987  }
3988 
3989  ao2_ref(transport_state, -1);
3990 
3991  return res;
3992 }
3993 
3994 int ast_sip_set_tpselector_from_transport_name(const char *transport_name, pjsip_tpselector *selector)
3995 {
3997 
3998  if (ast_strlen_zero(transport_name)) {
3999  return 0;
4000  }
4001 
4002  transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_name);
4003  if (!transport) {
4004  ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport '%s'\n",
4005  transport_name);
4006  return -1;
4007  }
4008 
4010 }
4011 
4013  pjsip_sip_uri *sip_uri, pjsip_tpselector *selector)
4014 {
4015  char transport_name[128];
4016 
4017  if (ast_sip_get_transport_name(endpoint, sip_uri, transport_name, sizeof(transport_name))) {
4018  return 0;
4019  }
4020 
4021  return ast_sip_set_tpselector_from_transport_name(transport_name, selector);
4022 }
4023 
4024 void ast_sip_tpselector_unref(pjsip_tpselector *selector)
4025 {
4026  if (selector->type == PJSIP_TPSELECTOR_TRANSPORT && selector->u.transport) {
4027  pjsip_transport_dec_ref(selector->u.transport);
4028  }
4029 }
4030 
4031 void ast_sip_add_usereqphone(const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri)
4032 {
4033  pjsip_sip_uri *sip_uri;
4034  int i = 0;
4035  static const pj_str_t STR_PHONE = { "phone", 5 };
4036 
4037  if (!endpoint || !endpoint->usereqphone || (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
4038  return;
4039  }
4040 
4041  sip_uri = pjsip_uri_get_uri(uri);
4042 
4043  if (!pj_strlen(&sip_uri->user)) {
4044  return;
4045  }
4046 
4047  if (pj_strbuf(&sip_uri->user)[0] == '+') {
4048  i = 1;
4049  }
4050 
4051  /* Test URI user against allowed characters in AST_DIGIT_ANY */
4052  for (; i < pj_strlen(&sip_uri->user); i++) {
4053  if (!strchr(AST_DIGIT_ANY, pj_strbuf(&sip_uri->user)[i])) {
4054  break;
4055  }
4056  }
4057 
4058  if (i < pj_strlen(&sip_uri->user)) {
4059  return;
4060  }
4061 
4062  sip_uri->user_param = STR_PHONE;
4063 }
4064 
4065 pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint,
4066  const char *uri, const char *request_user)
4067 {
4068  char enclosed_uri[PJSIP_MAX_URL_SIZE];
4069  pj_str_t local_uri = { "sip:temp@temp", 13 }, remote_uri, target_uri;
4070  pj_status_t res;
4071  pjsip_dialog *dlg = NULL;
4072  const char *outbound_proxy = endpoint->outbound_proxy;
4073  pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
4074  static const pj_str_t HCONTACT = { "Contact", 7 };
4075 
4076  snprintf(enclosed_uri, sizeof(enclosed_uri), "<%s>", uri);
4077  pj_cstr(&remote_uri, enclosed_uri);
4078 
4079  pj_cstr(&target_uri, uri);
4080 
4081  res = pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, &target_uri, &dlg);
4082  if (res == PJ_SUCCESS && !(PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target))) {
4083  /* dlg->target is a pjsip_other_uri, but it's assumed to be a
4084  * pjsip_sip_uri below. Fail fast. */
4085  res = PJSIP_EINVALIDURI;
4086  pjsip_dlg_terminate(dlg);
4087  }
4088  if (res != PJ_SUCCESS) {
4089  if (res == PJSIP_EINVALIDURI) {
4091  "Endpoint '%s': Could not create dialog to invalid URI '%s'. Is endpoint registered and reachable?\n",
4092  ast_sorcery_object_get_id(endpoint), uri);
4093  }
4094  return NULL;
4095  }
4096 
4097  /* We have to temporarily bump up the sess_count here so the dialog is not prematurely destroyed */
4098  dlg->sess_count++;
4099 
4100  ast_sip_dlg_set_transport(endpoint, dlg, &selector);
4101 
4102  if (sip_dialog_create_from(dlg->pool, &local_uri, endpoint->fromuser, endpoint->fromdomain, &remote_uri, &selector)) {
4103  dlg->sess_count--;
4104  pjsip_dlg_terminate(dlg);
4105  ast_sip_tpselector_unref(&selector);
4106  return NULL;
4107  }
4108 
4109  ast_sip_tpselector_unref(&selector);
4110 
4111  /* Update the dialog with the new local URI, we do it afterwards so we can use the dialog pool for construction */
4112  pj_strdup_with_null(dlg->pool, &dlg->local.info_str, &local_uri);
4113  dlg->local.info->uri = pjsip_parse_uri(dlg->pool, dlg->local.info_str.ptr, dlg->local.info_str.slen, 0);
4114  if (!dlg->local.info->uri) {
4116  "Could not parse URI '%s' for endpoint '%s'\n",
4117  dlg->local.info_str.ptr, ast_sorcery_object_get_id(endpoint));
4118  dlg->sess_count--;
4119  pjsip_dlg_terminate(dlg);
4120  return NULL;
4121  }
4122 
4123  dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen, NULL);
4124 
4125  if (!ast_strlen_zero(endpoint->contact_user)) {
4126  pjsip_sip_uri *sip_uri;
4127 
4128  sip_uri = pjsip_uri_get_uri(dlg->local.contact->uri);
4129  pj_strdup2(dlg->pool, &sip_uri->user, endpoint->contact_user);
4130  }
4131 
4132  /* If a request user has been specified and we are permitted to change it, do so */
4133  if (!ast_strlen_zero(request_user)) {
4134  pjsip_sip_uri *sip_uri;
4135 
4136  if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target)) {
4137  sip_uri = pjsip_uri_get_uri(dlg->target);
4138  pj_strdup2(dlg->pool, &sip_uri->user, request_user);
4139  }
4140  if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) || PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri)) {
4141  sip_uri = pjsip_uri_get_uri(dlg->remote.info->uri);
4142  pj_strdup2(dlg->pool, &sip_uri->user, request_user);
4143  }
4144  }
4145 
4146  /* Add the user=phone parameter if applicable */
4147  ast_sip_add_usereqphone(endpoint, dlg->pool, dlg->target);
4148  ast_sip_add_usereqphone(endpoint, dlg->pool, dlg->remote.info->uri);
4149 
4150  if (!ast_strlen_zero(outbound_proxy)) {
4151  pjsip_route_hdr route_set, *route;
4152  static const pj_str_t ROUTE_HNAME = { "Route", 5 };
4153  pj_str_t tmp;
4154 
4155  pj_list_init(&route_set);
4156 
4157  pj_strdup2_with_null(dlg->pool, &tmp, outbound_proxy);
4158  if (!(route = pjsip_parse_hdr(dlg->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
4159  ast_log(LOG_ERROR, "Could not create dialog to endpoint '%s' as outbound proxy URI '%s' is not valid\n",
4160  ast_sorcery_object_get_id(endpoint), outbound_proxy);
4161  dlg->sess_count--;
4162  pjsip_dlg_terminate(dlg);
4163  return NULL;
4164  }
4165  pj_list_insert_nodes_before(&route_set, route);
4166 
4167  pjsip_dlg_set_route_set(dlg, &route_set);
4168  }
4169 
4170  dlg->sess_count--;
4171 
4172  return dlg;
4173 }
4174 
4175 /*!
4176  * \brief Determine if a SIPS Contact header is required.
4177  *
4178  * This uses the guideline provided in RFC 3261 Section 12.1.1 to
4179  * determine if the Contact header must be a sips: URI.
4180  *
4181  * \param rdata The incoming dialog-starting request
4182  * \retval 0 SIPS not required
4183  * \retval 1 SIPS required
4184  */
4185 static int uas_use_sips_contact(pjsip_rx_data *rdata)
4186 {
4187  pjsip_rr_hdr *record_route;
4188 
4189  if (PJSIP_URI_SCHEME_IS_SIPS(rdata->msg_info.msg->line.req.uri)) {
4190  return 1;
4191  }
4192 
4193  record_route = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_RECORD_ROUTE, NULL);
4194  if (record_route) {
4195  if (PJSIP_URI_SCHEME_IS_SIPS(&record_route->name_addr)) {
4196  return 1;
4197  }
4198  } else {
4199  pjsip_contact_hdr *contact;
4200 
4201  contact = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
4202  ast_assert(contact != NULL);
4203  if (PJSIP_URI_SCHEME_IS_SIPS(contact->uri)) {
4204  return 1;
4205  }
4206  }
4207 
4208  return 0;
4209 }
4210 
4211 typedef pj_status_t (*create_dlg_uac)(pjsip_user_agent *ua, pjsip_rx_data *rdata,
4212  const pj_str_t *contact, pjsip_dialog **p_dlg);
4213 
4214 static pjsip_dialog *create_dialog_uas(const struct ast_sip_endpoint *endpoint,
4215  pjsip_rx_data *rdata, pj_status_t *status, create_dlg_uac create_fun)
4216 {
4217  pjsip_dialog *dlg;
4218  pj_str_t contact;
4219  pjsip_transport_type_e type = rdata->tp_info.transport->key.type;
4220  pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
4221  pjsip_transport *transport;
4222  pjsip_contact_hdr *contact_hdr;
4223 
4224  ast_assert(status != NULL);
4225 
4226  contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
4227  if (!contact_hdr || ast_sip_set_tpselector_from_ep_or_uri(endpoint, pjsip_uri_get_uri(contact_hdr->uri),
4228  &selector)) {
4229  return NULL;
4230  }
4231 
4232  transport = rdata->tp_info.transport;
4233  if (selector.type == PJSIP_TPSELECTOR_TRANSPORT) {
4234  transport = selector.u.transport;
4235  }
4236  type = transport->key.type;
4237 
4238  contact.ptr = pj_pool_alloc(rdata->tp_info.pool, PJSIP_MAX_URL_SIZE);
4239  contact.slen = pj_ansi_snprintf(contact.ptr, PJSIP_MAX_URL_SIZE,
4240  "<%s:%s%.*s%s:%d%s%s>",
4241  uas_use_sips_contact(rdata) ? "sips" : "sip",
4242  (type & PJSIP_TRANSPORT_IPV6) ? "[" : "",
4243  (int)transport->local_name.host.slen,
4244  transport->local_name.host.ptr,
4245  (type & PJSIP_TRANSPORT_IPV6) ? "]" : "",
4246  transport->local_name.port,
4247  (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? ";transport=" : "",
4248  (type != PJSIP_TRANSPORT_UDP && type != PJSIP_TRANSPORT_UDP6) ? pjsip_transport_get_type_name(type) : "");
4249 
4250  *status = create_fun(pjsip_ua_instance(), rdata, &contact, &dlg);
4251  if (*status != PJ_SUCCESS) {
4252  char err[PJ_ERR_MSG_SIZE];
4253 
4254  pj_strerror(*status, err, sizeof(err));
4255  ast_log(LOG_ERROR, "Could not create dialog with endpoint %s. %s\n",
4256  ast_sorcery_object_get_id(endpoint), err);
4257  ast_sip_tpselector_unref(&selector);
4258  return NULL;
4259  }
4260 
4261  dlg->sess_count++;
4262  pjsip_dlg_set_transport(dlg, &selector);
4263  dlg->sess_count--;
4264 
4265  ast_sip_tpselector_unref(&selector);
4266 
4267  return dlg;
4268 }
4269 
4270 pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status)
4271 {
4272 #ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
4273  pjsip_dialog *dlg;
4274 
4275  dlg = create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas_and_inc_lock);
4276  if (dlg) {
4277  pjsip_dlg_dec_lock(dlg);
4278  }
4279 
4280  return dlg;
4281 #else
4282  return create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas);
4283 #endif
4284 }
4285 
4286 pjsip_dialog *ast_sip_create_dialog_uas_locked(const struct ast_sip_endpoint *endpoint,
4287  pjsip_rx_data *rdata, pj_status_t *status)
4288 {
4289 #ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
4290  return create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas_and_inc_lock);
4291 #else
4292  /*
4293  * This is put here in order to be compatible with older versions of pjproject.
4294  * Best we can do in this case is immediately lock after getting the dialog.
4295  * However, that does leave a "gap" between creating and locking.
4296  */
4297  pjsip_dialog *dlg;
4298 
4299  dlg = create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas);
4300  if (dlg) {
4301  pjsip_dlg_inc_lock(dlg);
4302  }
4303 
4304  return dlg;
4305 #endif
4306  }
4307 
4308 int ast_sip_create_rdata_with_contact(pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port,
4309  char *transport_type, const char *local_name, int local_port, const char *contact)
4310 {
4311  pj_str_t tmp;
4312 
4313  /*
4314  * Initialize the error list in case there is a parse error
4315  * in the given packet.
4316  */
4317  pj_list_init(&rdata->msg_info.parse_err);
4318 
4319  rdata->tp_info.transport = PJ_POOL_ZALLOC_T(rdata->tp_info.pool, pjsip_transport);
4320  if (!rdata->tp_info.transport) {
4321  return -1;
4322  }
4323 
4324  ast_copy_string(rdata->pkt_info.packet, packet, sizeof(rdata->pkt_info.packet));
4325  ast_copy_string(rdata->pkt_info.src_name, src_name, sizeof(rdata->pkt_info.src_name));
4326  rdata->pkt_info.src_port = src_port;
4327  pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&tmp, src_name), &rdata->pkt_info.src_addr);
4328  pj_sockaddr_set_port(&rdata->pkt_info.src_addr, src_port);
4329 
4330  pjsip_parse_rdata(packet, strlen(packet), rdata);
4331  if (!rdata->msg_info.msg || !pj_list_empty(&rdata->msg_info.parse_err)) {
4332  return -1;
4333  }
4334 
4335  if (!ast_strlen_zero(contact)) {
4336  pjsip_contact_hdr *contact_hdr;
4337 
4338  contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
4339  if (contact_hdr) {
4340  contact_hdr->uri = pjsip_parse_uri(rdata->tp_info.pool, (char *)contact,
4341  strlen(contact), PJSIP_PARSE_URI_AS_NAMEADDR);
4342  if (!contact_hdr->uri) {
4343  ast_log(LOG_WARNING, "Unable to parse contact URI from '%s'.\n", contact);
4344  return -1;
4345  }
4346  }
4347  }
4348 
4349  pj_strdup2(rdata->tp_info.pool, &rdata->msg_info.via->recvd_param, rdata->pkt_info.src_name);
4350  rdata->msg_info.via->rport_param = -1;
4351 
4352  rdata->tp_info.transport->key.type = pjsip_transport_get_type_from_name(pj_cstr(&tmp, transport_type));
4353  rdata->tp_info.transport->type_name = transport_type;
4354  pj_strdup2(rdata->tp_info.pool, &rdata->tp_info.transport->local_name.host, local_name);
4355  rdata->tp_info.transport->local_name.port = local_port;
4356 
4357  return 0;
4358 }
4359 
4360 int ast_sip_create_rdata(pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port,
4361  char *transport_type, const char *local_name, int local_port)
4362 {
4363  return ast_sip_create_rdata_with_contact(rdata, packet, src_name, src_port, transport_type,
4364  local_name, local_port, NULL);
4365 }
4366 
4367 /* PJSIP doesn't know about the INFO method, so we have to define it ourselves */
4368 static const pjsip_method info_method = {PJSIP_OTHER_METHOD, {"INFO", 4} };
4369 static const pjsip_method message_method = {PJSIP_OTHER_METHOD, {"MESSAGE", 7} };
4370 
4371 static struct {
4372  const char *method;
4373  const pjsip_method *pmethod;
4374 } methods [] = {
4375  { "INVITE", &pjsip_invite_method },
4376  { "CANCEL", &pjsip_cancel_method },
4377  { "ACK", &pjsip_ack_method },
4378  { "BYE", &pjsip_bye_method },
4379  { "REGISTER", &pjsip_register_method },
4380  { "OPTIONS", &pjsip_options_method },
4381  { "SUBSCRIBE", &pjsip_subscribe_method },
4382  { "NOTIFY", &pjsip_notify_method },
4383  { "PUBLISH", &pjsip_publish_method },
4384  { "INFO", &info_method },
4385  { "MESSAGE", &message_method },
4386 };
4387 
4388 static const pjsip_method *get_pjsip_method(const char *method)
4389 {
4390  int i;
4391  for (i = 0; i < ARRAY_LEN(methods); ++i) {
4392  if (!strcmp(method, methods[i].method)) {
4393  return methods[i].pmethod;
4394  }
4395  }
4396  return NULL;
4397 }
4398 
4399 static int create_in_dialog_request(const pjsip_method *method, struct pjsip_dialog *dlg, pjsip_tx_data **tdata)
4400 {
4401  if (pjsip_dlg_create_request(dlg, method, -1, tdata) != PJ_SUCCESS) {
4402  ast_log(LOG_WARNING, "Unable to create in-dialog request.\n");
4403  return -1;
4404  }
4405 
4406  return 0;
4407 }
4408 
4409 static pj_bool_t supplement_on_rx_request(pjsip_rx_data *rdata);
4410 static pjsip_module supplement_module = {
4411  .name = { "Out of dialog supplement hook", 29 },
4412  .id = -1,
4413  .priority = PJSIP_MOD_PRIORITY_APPLICATION - 1,
4414  .on_rx_request = supplement_on_rx_request,
4415 };
4416 
4417 static int create_out_of_dialog_request(const pjsip_method *method, struct ast_sip_endpoint *endpoint,
4418  const char *uri, struct ast_sip_contact *provided_contact, pjsip_tx_data **tdata)
4419 {
4420  RAII_VAR(struct ast_sip_contact *, contact, ao2_bump(provided_contact), ao2_cleanup);
4421  pj_str_t remote_uri;
4422  pj_str_t from;
4423  pj_pool_t *pool;
4424  pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
4425  pjsip_uri *sip_uri;
4426  const char *fromuser;
4427 
4428  if (ast_strlen_zero(uri)) {
4429  if (!endpoint && (!contact || ast_strlen_zero(contact->uri))) {
4430  ast_log(LOG_ERROR, "An endpoint and/or uri must be specified\n");
4431  return -1;
4432  }
4433 
4434  if (!contact) {
4436  }
4437  if (!contact || ast_strlen_zero(contact->uri)) {
4438  ast_log(LOG_WARNING, "Unable to retrieve contact for endpoint %s\n",
4439  ast_sorcery_object_get_id(endpoint));
4440  return -1;
4441  }
4442 
4443  pj_cstr(&remote_uri, contact->uri);
4444  } else {
4445  pj_cstr(&remote_uri, uri);
4446  }
4447 
4448  pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "Outbound request", 256, 256);
4449 
4450  if (!pool) {
4451  ast_log(LOG_ERROR, "Unable to create PJLIB memory pool\n");
4452  return -1;
4453  }
4454 
4455  sip_uri = pjsip_parse_uri(pool, remote_uri.ptr, remote_uri.slen, 0);
4456  if (!sip_uri || (!PJSIP_URI_SCHEME_IS_SIP(sip_uri) && !PJSIP_URI_SCHEME_IS_SIPS(sip_uri))) {
4457  ast_log(LOG_ERROR, "Unable to create outbound %.*s request to endpoint %s as URI '%s' is not valid\n",
4458  (int) pj_strlen(&method->name), pj_strbuf(&method->name),
4459  endpoint ? ast_sorcery_object_get_id(endpoint) : "<none>",
4460  pj_strbuf(&remote_uri));
4461  pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
4462  return -1;
4463  }
4464 
4465  ast_sip_set_tpselector_from_ep_or_uri(endpoint, pjsip_uri_get_uri(sip_uri), &selector);
4466 
4467  fromuser = endpoint ? (!ast_strlen_zero(endpoint->fromuser) ? endpoint->fromuser : ast_sorcery_object_get_id(endpoint)) : NULL;
4468  if (sip_dialog_create_from(pool, &from, fromuser,
4469  endpoint ? endpoint->fromdomain : NULL, &remote_uri, &selector)) {
4470  ast_log(LOG_ERROR, "Unable to create From header for %.*s request to endpoint %s\n",
4471  (int) pj_strlen(&method->name), pj_strbuf(&method->name),
4472  endpoint ? ast_sorcery_object_get_id(endpoint) : "<none>");
4473  pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
4474  ast_sip_tpselector_unref(&selector);
4475  return -1;
4476  }
4477 
4478  if (pjsip_endpt_create_request(ast_sip_get_pjsip_endpoint(), method, &remote_uri,
4479  &from, &remote_uri, &from, NULL, -1, NULL, tdata) != PJ_SUCCESS) {
4480  ast_log(LOG_ERROR, "Unable to create outbound %.*s request to endpoint %s\n",
4481  (int) pj_strlen(&method->name), pj_strbuf(&method->name),
4482  endpoint ? ast_sorcery_object_get_id(endpoint) : "<none>");
4483  pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
4484  ast_sip_tpselector_unref(&selector);
4485  return -1;
4486  }
4487 
4488  pjsip_tx_data_set_transport(*tdata, &selector);
4489 
4490  ast_sip_tpselector_unref(&selector);
4491 
4492  if (endpoint && !ast_strlen_zero(endpoint->contact_user)){
4493  pjsip_contact_hdr *contact_hdr;
4494  pjsip_sip_uri *contact_uri;
4495  static const pj_str_t HCONTACT = { "Contact", 7 };
4496  static const pj_str_t HCONTACTSHORT = { "m", 1 };
4497 
4498  contact_hdr = pjsip_msg_find_hdr_by_names((*tdata)->msg, &HCONTACT, &HCONTACTSHORT, NULL);
4499  if (contact_hdr) {
4500  contact_uri = pjsip_uri_get_uri(contact_hdr->uri);
4501  pj_strdup2((*tdata)->pool, &contact_uri->user, endpoint->contact_user);
4502  }
4503  }
4504 
4505  /* Add the user=phone parameter if applicable */
4506  ast_sip_add_usereqphone(endpoint, (*tdata)->pool, (*tdata)->msg->line.req.uri);
4507 
4508  /* If an outbound proxy is specified on the endpoint apply it to this request */
4509  if (endpoint && !ast_strlen_zero(endpoint->outbound_proxy) &&
4510  ast_sip_set_outbound_proxy((*tdata), endpoint->outbound_proxy)) {
4511  ast_log(LOG_ERROR, "Unable to apply outbound proxy on request %.*s to endpoint %s as outbound proxy URI '%s' is not valid\n",
4512  (int) pj_strlen(&method->name), pj_strbuf(&method->name), ast_sorcery_object_get_id(endpoint),
4513  endpoint->outbound_proxy);
4514  pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
4515  return -1;
4516  }
4517 
4518  ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
4519 
4520  /* We can release this pool since request creation copied all the necessary
4521  * data into the outbound request's pool
4522  */
4523  pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
4524  return 0;
4525 }
4526 
4527 int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg,
4528  struct ast_sip_endpoint *endpoint, const char *uri,
4529  struct ast_sip_contact *contact, pjsip_tx_data **tdata)
4530 {
4531  const pjsip_method *pmethod = get_pjsip_method(method);
4532 
4533  if (!pmethod) {
4534  ast_log(LOG_WARNING, "Unknown method '%s'. Cannot send request\n", method);
4535  return -1;
4536  }
4537 
4538  if (dlg) {
4539  return create_in_dialog_request(pmethod, dlg, tdata);
4540  } else {
4541  ast_assert(endpoint != NULL);
4542  return create_out_of_dialog_request(pmethod, endpoint, uri, contact, tdata);
4543  }
4544 }
4545 
4547 
4549 {
4550  struct ast_sip_supplement *iter;
4551  int inserted = 0;
4553 
4555  if (iter->priority > supplement->priority) {
4557  inserted = 1;
4558  break;
4559  }
4560  }
4562 
4563  if (!inserted) {
4564  AST_RWLIST_INSERT_TAIL(&supplements, supplement, next);
4565  }
4566 }
4567 
4569 {
4570  struct ast_sip_supplement *iter;
4572 
4574  if (supplement == iter) {
4576  break;
4577  }
4578  }
4580 }
4581 
4582 static int send_in_dialog_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg)
4583 {
4584  if (pjsip_dlg_send_request(dlg, tdata, -1, NULL) != PJ_SUCCESS) {
4585  ast_log(LOG_WARNING, "Unable to send in-dialog request.\n");
4586  return -1;
4587  }
4588  return 0;
4589 }
4590 
4591 static pj_bool_t does_method_match(const pj_str_t *message_method, const char *supplement_method)
4592 {
4593  pj_str_t method;
4594 
4595  if (ast_strlen_zero(supplement_method)) {
4596  return PJ_TRUE;
4597  }
4598 
4599  pj_cstr(&method, supplement_method);
4600 
4601  return pj_stristr(&method, message_method) ? PJ_TRUE : PJ_FALSE;
4602 }
4603 
4604 #define TIMER_INACTIVE 0
4605 #define TIMEOUT_TIMER2 5
4606 
4607 /*! \brief Structure to hold information about an outbound request */
4609  /*! The endpoint associated with this request */
4611  /*! Information to be provided to the callback upon receipt of a response */
4612  void *token;
4613  /*! The callback to be called upon receipt of a response */
4614  void (*callback)(void *token, pjsip_event *e);
4615  /*! Number of challenges received. */
4616  unsigned int challenge_count;
4617 };
4618 
4619 static void send_request_data_destroy(void *obj)
4620 {
4621  struct send_request_data *req_data = obj;
4622 
4623  ao2_cleanup(req_data->endpoint);
4624 }
4625 
4627  void *token, void (*callback)(void *token, pjsip_event *e))
4628 {
4629  struct send_request_data *req_data;
4630 
4631  req_data = ao2_alloc_options(sizeof(*req_data), send_request_data_destroy,
4633  if (!req_data) {
4634  return NULL;
4635  }
4636 
4637  req_data->endpoint = ao2_bump(endpoint);
4638  req_data->token = token;
4639  req_data->callback = callback;
4640 
4641  return req_data;
4642 }
4643 
4645  /*! Information to be provided to the callback upon receipt of a response */
4646  void *token;
4647  /*! The callback to be called upon receipt of a response */
4648  void (*callback)(void *token, pjsip_event *e);
4649  /*! Non-zero when the callback is called. */
4650  unsigned int cb_called;
4651  /*! Non-zero if endpt_send_request_cb() was called. */
4652  unsigned int send_cb_called;
4653  /*! Timeout timer. */
4654  pj_timer_entry *timeout_timer;
4655  /*! Original timeout. */
4656  pj_int32_t timeout;
4657  /*! The transmit data. */
4658  pjsip_tx_data *tdata;
4659 };
4660 
4661 /*! \internal This function gets called by pjsip when the transaction ends,
4662  * even if it timed out. The lock prevents a race condition if both the pjsip
4663  * transaction timer and our own timer expire simultaneously.
4664  */
4665 static void endpt_send_request_cb(void *token, pjsip_event *e)
4666 {
4667  struct send_request_wrapper *req_wrapper = token;
4668  unsigned int cb_called;
4669 
4670  /*
4671  * Needed because we cannot otherwise tell if this callback was
4672  * called when pjsip_endpt_send_request() returns error.
4673  */
4674  req_wrapper->send_cb_called = 1;
4675 
4676  if (e->body.tsx_state.type == PJSIP_EVENT_TIMER) {
4677  ast_debug(2, "%p: PJSIP tsx timer expired\n", req_wrapper);
4678 
4679  if (req_wrapper->timeout_timer
4680  && req_wrapper->timeout_timer->id != TIMEOUT_TIMER2) {
4681  ast_debug(3, "%p: Timeout already handled\n", req_wrapper);
4682  ao2_ref(req_wrapper, -1);
4683  return;
4684  }
4685  } else {
4686  ast_debug(2, "%p: PJSIP tsx response received\n", req_wrapper);
4687  }
4688 
4689  ao2_lock(req_wrapper);
4690 
4691  /* It's possible that our own timer was already processing while
4692  * we were waiting on the lock so check the timer id. If it's
4693  * still TIMER2 then we still need to process.
4694  */
4695  if (req_wrapper->timeout_timer
4696  && req_wrapper->timeout_timer->id == TIMEOUT_TIMER2) {
4697  int timers_cancelled = 0;
4698 
4699  ast_debug(3, "%p: Cancelling timer\n", req_wrapper);
4700 
4701  timers_cancelled = pj_timer_heap_cancel_if_active(
4702  pjsip_endpt_get_timer_heap(ast_sip_get_pjsip_endpoint()),
4703  req_wrapper->timeout_timer, TIMER_INACTIVE);
4704  if (timers_cancelled > 0) {
4705  /* If the timer was cancelled the callback will never run so
4706  * clean up its reference to the wrapper.
4707  */
4708  ast_debug(3, "%p: Timer cancelled\n", req_wrapper);
4709  ao2_ref(req_wrapper, -1);
4710  } else {
4711  /*
4712  * If it wasn't cancelled, it MAY be in the callback already
4713  * waiting on the lock. When we release the lock, it will
4714  * now know not to proceed.
4715  */
4716  ast_debug(3, "%p: Timer already expired\n", req_wrapper);
4717  }
4718  }
4719 
4720  cb_called = req_wrapper->cb_called;
4721  req_wrapper->cb_called = 1;
4722  ao2_unlock(req_wrapper);
4723 
4724  /* It's possible that our own timer expired and called the callbacks
4725  * so no need to call them again.
4726  */
4727  if (!cb_called && req_wrapper->callback) {
4728  req_wrapper->callback(req_wrapper->token, e);
4729  ast_debug(2, "%p: Callbacks executed\n", req_wrapper);
4730  }
4731 
4732  ao2_ref(req_wrapper, -1);
4733 }
4734 
4735 /*! \internal This function gets called by our own timer when it expires.
4736  * If the timer is cancelled however, the function does NOT get called.
4737  * The lock prevents a race condition if both the pjsip transaction timer
4738  * and our own timer expire simultaneously.
4739  */
4740 static void send_request_timer_callback(pj_timer_heap_t *theap, pj_timer_entry *entry)
4741 {
4742  struct send_request_wrapper *req_wrapper = entry->user_data;
4743  unsigned int cb_called;
4744 
4745  ast_debug(2, "%p: Internal tsx timer expired after %d msec\n",
4746  req_wrapper, req_wrapper->timeout);
4747 
4748  ao2_lock(req_wrapper);
4749  /*
4750  * If the id is not TIMEOUT_TIMER2 then the timer was cancelled
4751  * before we got the lock or it was already handled so just clean up.
4752  */
4753  if (entry->id != TIMEOUT_TIMER2) {
4754  ao2_unlock(req_wrapper);
4755  ast_debug(3, "%p: Timeout already handled\n", req_wrapper);
4756  ao2_ref(req_wrapper, -1);
4757  return;
4758  }
4759  entry->id = TIMER_INACTIVE;
4760 
4761  ast_debug(3, "%p: Timer handled here\n", req_wrapper);
4762 
4763  cb_called = req_wrapper->cb_called;
4764  req_wrapper->cb_called = 1;
4765  ao2_unlock(req_wrapper);
4766 
4767  if (!cb_called && req_wrapper->callback) {
4768  pjsip_event event;
4769 
4770  PJSIP_EVENT_INIT_TX_MSG(event, req_wrapper->tdata);
4771  event.body.tsx_state.type = PJSIP_EVENT_TIMER;
4772 
4773  req_wrapper->callback(req_wrapper->token, &event);
4774  ast_debug(2, "%p: Callbacks executed\n", req_wrapper);
4775  }
4776 
4777  ao2_ref(req_wrapper, -1);
4778 }
4779 
4780 static void send_request_wrapper_destructor(void *obj)
4781 {
4782  struct send_request_wrapper *req_wrapper = obj;
4783 
4784  pjsip_tx_data_dec_ref(req_wrapper->tdata);
4785  ast_debug(2, "%p: wrapper destroyed\n", req_wrapper);
4786 }
4787 
4788 static pj_status_t endpt_send_request(struct ast_sip_endpoint *endpoint,
4789  pjsip_tx_data *tdata, pj_int32_t timeout, void *token, pjsip_endpt_send_callback cb)
4790 {
4791  struct send_request_wrapper *req_wrapper;
4792  pj_status_t ret_val;
4793  pjsip_endpoint *endpt = ast_sip_get_pjsip_endpoint();
4794 
4795  if (!cb && token) {
4796  /* Silly. Without a callback we cannot do anything with token. */
4797  pjsip_tx_data_dec_ref(tdata);
4798  return PJ_EINVAL;
4799  }
4800 
4801  /* Create wrapper to detect if the callback was actually called on an error. */
4802  req_wrapper = ao2_alloc(sizeof(*req_wrapper), send_request_wrapper_destructor);
4803  if (!req_wrapper) {
4804  pjsip_tx_data_dec_ref(tdata);
4805  return PJ_ENOMEM;
4806  }
4807 
4808  ast_debug(2, "%p: Wrapper created\n", req_wrapper);
4809 
4810  req_wrapper->token = token;
4811  req_wrapper->callback = cb;
4812  req_wrapper->timeout = timeout;
4813  req_wrapper->timeout_timer = NULL;
4814  req_wrapper->tdata = tdata;
4815  /* Add a reference to tdata. The wrapper destructor cleans it up. */
4816  pjsip_tx_data_add_ref(tdata);
4817 
4818  if (timeout > 0) {
4819  pj_time_val timeout_timer_val = { timeout / 1000, timeout % 1000 };
4820 
4821  req_wrapper->timeout_timer = PJ_POOL_ALLOC_T(tdata->pool, pj_timer_entry);
4822 
4823  ast_debug(2, "%p: Set timer to %d msec\n", req_wrapper, timeout);
4824 
4825  pj_timer_entry_init(req_wrapper->timeout_timer, TIMEOUT_TIMER2,
4826  req_wrapper, send_request_timer_callback);
4827 
4828  /* We need to insure that the wrapper and tdata are available if/when the
4829  * timer callback is executed.
4830  */
4831  ao2_ref(req_wrapper, +1);
4832  ret_val = pj_timer_heap_schedule(pjsip_endpt_get_timer_heap(endpt),
4833  req_wrapper->timeout_timer, &timeout_timer_val);
4834  if (ret_val != PJ_SUCCESS) {
4836  "Failed to set timer. Not sending %.*s request to endpoint %s.\n",
4837  (int) pj_strlen(&tdata->msg->line.req.method.name),
4838  pj_strbuf(&tdata->msg->line.req.method.name),
4839  endpoint ? ast_sorcery_object_get_id(endpoint) : "<unknown>");
4840  ao2_t_ref(req_wrapper, -2, "Drop timer and routine ref");
4841  pjsip_tx_data_dec_ref(tdata);
4842  return ret_val;
4843  }
4844  }
4845 
4846  /* We need to insure that the wrapper and tdata are available when the
4847  * transaction callback is executed.
4848  */
4849  ao2_ref(req_wrapper, +1);
4850  ret_val = pjsip_endpt_send_request(endpt, tdata, -1, req_wrapper, endpt_send_request_cb);
4851  if (ret_val != PJ_SUCCESS) {
4852  char errmsg[PJ_ERR_MSG_SIZE];
4853 
4854  if (!req_wrapper->send_cb_called) {
4855  /* endpt_send_request_cb is not expected to ever be called now. */
4856  ao2_ref(req_wrapper, -1);
4857  }
4858 
4859  /* Complain of failure to send the request. */
4860  pj_strerror(ret_val, errmsg, sizeof(errmsg));
4861  ast_log(LOG_ERROR, "Error %d '%s' sending %.*s request to endpoint %s\n",
4862  (int) ret_val, errmsg, (int) pj_strlen(&tdata->msg->line.req.method.name),
4863  pj_strbuf(&tdata->msg->line.req.method.name),
4864  endpoint ? ast_sorcery_object_get_id(endpoint) : "<unknown>");
4865 
4866  if (timeout > 0) {
4867  int timers_cancelled;
4868 
4869  ao2_lock(req_wrapper);
4870  timers_cancelled = pj_timer_heap_cancel_if_active(
4871  pjsip_endpt_get_timer_heap(endpt),
4872  req_wrapper->timeout_timer, TIMER_INACTIVE);
4873  if (timers_cancelled > 0) {
4874  ao2_ref(req_wrapper, -1);
4875  }
4876 
4877  /* Was the callback called? */
4878  if (req_wrapper->cb_called) {
4879  /*
4880  * Yes so we cannot report any error. The callback
4881  * has already freed any resources associated with
4882  * token.
4883  */
4884  ret_val = PJ_SUCCESS;
4885  } else {
4886  /*
4887  * No so we claim it is called so our caller can free
4888  * any resources associated with token because of
4889  * failure.
4890  */
4891  req_wrapper->cb_called = 1;
4892  }
4893  ao2_unlock(req_wrapper);
4894  } else if (req_wrapper->cb_called) {
4895  /*
4896  * We cannot report any error. The callback has
4897  * already freed any resources associated with
4898  * token.
4899  */
4900  ret_val = PJ_SUCCESS;
4901  }
4902  }
4903 
4904  ao2_ref(req_wrapper, -1);
4905  return ret_val;
4906 }
4907 
4908 int ast_sip_failover_request(pjsip_tx_data *tdata)
4909 {
4910  pjsip_via_hdr *via;
4911 
4912  if (!tdata || !tdata->dest_info.addr.count
4913  || (tdata->dest_info.cur_addr == tdata->dest_info.addr.count - 1)) {
4914  /* No more addresses to try */
4915  return 0;
4916  }
4917 
4918  /* Try next address */
4919  ++tdata->dest_info.cur_addr;
4920 
4921  via = (pjsip_via_hdr*)pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
4922  via->branch_param.slen = 0;
4923 
4924  pjsip_tx_data_invalidate_msg(tdata);
4925 
4926  return 1;
4927 }
4928 
4929 static void send_request_cb(void *token, pjsip_event *e);
4930 
4931 static int check_request_status(struct send_request_data *req_data, pjsip_event *e)
4932 {
4933  struct ast_sip_endpoint *endpoint;
4934  pjsip_transaction *tsx;
4935  pjsip_tx_data *tdata;
4936  int res = 0;
4937 
4938  if (!(endpoint = ao2_bump(req_data->endpoint))) {
4939  return 0;
4940  }
4941 
4942  tsx = e->body.tsx_state.tsx;
4943 
4944  switch (tsx->status_code) {
4945  case 401:
4946  case 407:
4947  /* Resend the request with a challenge response if we are challenged. */
4948  res = ++req_data->challenge_count < MAX_RX_CHALLENGES /* Not in a challenge loop */
4950  e->body.tsx_state.src.rdata, tsx->last_tx, &tdata);
4951  break;
4952  case 408:
4953  case 503:
4954  if ((res = ast_sip_failover_request(tsx->last_tx))) {
4955  tdata = tsx->last_tx;
4956  /*
4957  * Bump the ref since it will be on a new transaction and
4958  * we don't want it to go away along with the old transaction.
4959  */
4960  pjsip_tx_data_add_ref(tdata);
4961  }
4962  break;
4963  }
4964 
4965  if (res) {
4966  res = endpt_send_request(endpoint, tdata, -1,
4967  req_data, send_request_cb) == PJ_SUCCESS;
4968  }
4969 
4970  ao2_ref(endpoint, -1);
4971  return res;
4972 }
4973 
4974 static void send_request_cb(void *token, pjsip_event *e)
4975 {
4976  struct send_request_data *req_data = token;
4977  pjsip_rx_data *challenge;
4978  struct ast_sip_supplement *supplement;
4979 
4980  if (e->type == PJSIP_EVENT_TSX_STATE) {
4981  switch(e->body.tsx_state.type) {
4982  case PJSIP_EVENT_TRANSPORT_ERROR:
4983  case PJSIP_EVENT_TIMER:
4984  /*
4985  * Check the request status on transport error or timeout. A transport
4986  * error can occur when a TCP socket closes and that can be the result
4987  * of a 503. Also we may need to failover on a timeout (408).
4988  */
4989  if (check_request_status(req_data, e)) {
4990  return;
4991  }
4992  break;
4993  case PJSIP_EVENT_RX_MSG:
4994  challenge = e->body.tsx_state.src.rdata;
4995 
4996  /*
4997  * Call any supplements that want to know about a response
4998  * with any received data.
4999  */
5001  AST_LIST_TRAVERSE(&supplements, supplement, next) {
5002  if (supplement->incoming_response
5003  && does_method_match(&challenge->msg_info.cseq->method.name,
5004  supplement->method)) {
5005  supplement->incoming_response(req_data->endpoint, challenge);
5006  }
5007  }
5009 
5010  if (check_request_status(req_data, e)) {
5011  /*
5012  * Request with challenge response or failover sent.
5013  * Passed our req_data ref to the new request.
5014  */
5015  return;
5016  }
5017  break;
5018  default:
5019  ast_log(LOG_ERROR, "Unexpected PJSIP event %u\n", e->body.tsx_state.type);
5020  break;
5021  }
5022  }
5023 
5024  if (req_data->callback) {
5025  req_data->callback(req_data->token, e);
5026  }
5027  ao2_ref(req_data, -1);
5028 }
5029 
5030 int ast_sip_send_out_of_dialog_request(pjsip_tx_data *tdata,
5031  struct ast_sip_endpoint *endpoint, int timeout, void *token,
5032  void (*callback)(void *token, pjsip_event *e))
5033 {
5034  struct ast_sip_supplement *supplement;
5035  struct send_request_data *req_data;
5036  struct ast_sip_contact *contact;
5037 
5038  req_data = send_request_data_alloc(endpoint, token, callback);
5039  if (!req_data) {
5040  pjsip_tx_data_dec_ref(tdata);
5041  return -1;
5042  }
5043 
5044  if (endpoint) {
5045  ast_sip_message_apply_transport(endpoint->transport, tdata);
5046  }
5047 
5048  contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
5049 
5051  AST_LIST_TRAVERSE(&supplements, supplement, next) {
5052  if (supplement->outgoing_request
5053  && does_method_match(&tdata->msg->line.req.method.name, supplement->method)) {
5054  supplement->outgoing_request(endpoint, contact, tdata);
5055  }
5056  }
5058 
5059  ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
5060  ao2_cleanup(contact);
5061 
5062  if (endpt_send_request(endpoint, tdata, timeout, req_data, send_request_cb)
5063  != PJ_SUCCESS) {
5064  ao2_cleanup(req_data);
5065  return -1;
5066  }
5067 
5068  return 0;
5069 }
5070 
5071 int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg,
5072  struct ast_sip_endpoint *endpoint, void *token,
5073  void (*callback)(void *token, pjsip_event *e))
5074 {
5075  ast_assert(tdata->msg->type == PJSIP_REQUEST_MSG);
5076 
5077  if (dlg) {
5078  return send_in_dialog_request(tdata, dlg);
5079  } else {
5080  return ast_sip_send_out_of_dialog_request(tdata, endpoint, -1, token, callback);
5081  }
5082 }
5083 
5084 int ast_sip_set_outbound_proxy(pjsip_tx_data *tdata, const char *proxy)
5085 {
5086  pjsip_route_hdr *route;
5087  static const pj_str_t ROUTE_HNAME = { "Route", 5 };
5088  pj_str_t tmp;
5089 
5090  pj_strdup2_with_null(tdata->pool, &tmp, proxy);
5091  if (!(route = pjsip_parse_hdr(tdata->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
5092  return -1;
5093  }
5094 
5095  pj_list_insert_nodes_before(&tdata->msg->hdr, (pjsip_hdr*)route);
5096 
5097  return 0;
5098 }
5099 
5100 int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
5101 {
5102  pj_str_t hdr_name;
5103  pj_str_t hdr_value;
5104  pjsip_generic_string_hdr *hdr;
5105 
5106  pj_cstr(&hdr_name, name);
5107  pj_cstr(&hdr_value, value);
5108 
5109  hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
5110 
5111  pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
5112  return 0;
5113 }
5114 
5115 static pjsip_msg_body *ast_body_to_pjsip_body(pj_pool_t *pool, const struct ast_sip_body *body)
5116 {
5117  pj_str_t type;
5118  pj_str_t subtype;
5119  pj_str_t body_text;
5120 
5121  pj_cstr(&type, body->type);
5122  pj_cstr(&subtype, body->subtype);
5123  pj_cstr(&body_text, body->body_text);
5124 
5125  return pjsip_msg_body_create(pool, &type, &subtype, &body_text);
5126 }
5127 
5128 int ast_sip_add_body(pjsip_tx_data *tdata, const struct ast_sip_body *body)
5129 {
5130  pjsip_msg_body *pjsip_body = ast_body_to_pjsip_body(tdata->pool, body);
5131  tdata->msg->body = pjsip_body;
5132  return 0;
5133 }
5134 
5135 int ast_sip_add_body_multipart(pjsip_tx_data *tdata, const struct ast_sip_body *bodies[], int num_bodies)
5136 {
5137  int i;
5138  /* NULL for type and subtype automatically creates "multipart/mixed" */
5139  pjsip_msg_body *body = pjsip_multipart_create(tdata->pool, NULL, NULL);
5140 
5141  for (i = 0; i < num_bodies; ++i) {
5142  pjsip_multipart_part *part = pjsip_multipart_create_part(tdata->pool);
5143  part->body = ast_body_to_pjsip_body(tdata->pool, bodies[i]);
5144  pjsip_multipart_add_part(tdata->pool, body, part);
5145  }
5146 
5147  tdata->msg->body = body;
5148  return 0;
5149 }
5150 
5151 int ast_sip_append_body(pjsip_tx_data *tdata, const char *body_text)
5152 {
5153  size_t combined_size = strlen(body_text) + tdata->msg->body->len;
5154  struct ast_str *body_buffer = ast_str_alloca(combined_size);
5155 
5156  ast_str_set(&body_buffer, 0, "%.*s%s", (int) tdata->msg->body->len, (char *) tdata->msg->body->data, body_text);
5157 
5158  tdata->msg->body->data = pj_pool_alloc(tdata->pool, combined_size);
5159  pj_memcpy(tdata->msg->body->data, ast_str_buffer(body_buffer), combined_size);
5160  tdata->msg->body->len = combined_size;
5161 
5162  return 0;
5163 }
5164 
5166 {
5167  return ast_threadpool_serializer_group(name, sip_threadpool, shutdown_group);
5168 }
5169 
5171 {
5172  return ast_sip_create_serializer_group(name, NULL);
5173 }
5174 
5175 int ast_sip_push_task(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
5176 {
5177  if (!serializer) {
5178  serializer = ast_serializer_pool_get(sip_serializer_pool);
5179  }
5180 
5181  return ast_taskprocessor_push(serializer, sip_task, task_data);
5182 }
5183 
5184 struct sync_task_data {
5185  ast_mutex_t lock;
5186  ast_cond_t cond;
5187  int complete;
5188  int fail;
5189  int (*task)(void *);
5190  void *task_data;
5191 };
5192 
5193 static int sync_task(void *data)
5194 {
5195  struct sync_task_data *std = data;
5196  int ret;
5197 
5198  std->fail = std->task(std->task_data);
5199 
5200  /*
5201  * Once we unlock std->lock after signaling, we cannot access
5202  * std again. The thread waiting within ast_sip_push_task_wait()
5203  * is free to continue and release its local variable (std).
5204  */
5205  ast_mutex_lock(&std->lock);
5206  std->complete = 1;
5207  ast_cond_signal(&std->cond);
5208  ret = std->fail;
5209  ast_mutex_unlock(&std->lock);
5210  return ret;
5211 }
5212 
5213 static int ast_sip_push_task_wait(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
5214 {
5215  /* This method is an onion */
5216  struct sync_task_data std;
5217 
5218  memset(&std, 0, sizeof(std));
5219  ast_mutex_init(&std.lock);
5220  ast_cond_init(&std.cond, NULL);
5221  std.task = sip_task;
5222  std.task_data = task_data;
5223 
5224  if (ast_sip_push_task(serializer, sync_task, &std)) {
5225  ast_mutex_destroy(&std.lock);
5226  ast_cond_destroy(&std.cond);
5227  return -1;
5228  }
5229 
5230  ast_mutex_lock(&std.lock);
5231  while (!std.complete) {
5232  ast_cond_wait(&std.cond, &std.lock);
5233  }
5234  ast_mutex_unlock(&std.lock);
5235 
5236  ast_mutex_destroy(&std.lock);
5237  ast_cond_destroy(&std.cond);
5238  return std.fail;
5239 }
5240 
5241 int ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
5242 {
5243  if (ast_sip_thread_is_servant()) {
5244  return sip_task(task_data);
5245  }
5246 
5247  return ast_sip_push_task_wait(serializer, sip_task, task_data);
5248 }
5249 
5250 int ast_sip_push_task_synchronous(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
5251 {
5252  return ast_sip_push_task_wait_servant(serializer, sip_task, task_data);
5253 }
5254 
5255 int ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data)
5256 {
5257  if (!serializer) {
5258  /* Caller doesn't care which PJSIP serializer the task executes under. */
5259  serializer = ast_serializer_pool_get(sip_serializer_pool);
5260  if (!serializer) {
5261  /* No serializer picked to execute the task */
5262  return -1;
5263  }
5264  }
5265  if (ast_taskprocessor_is_task(serializer)) {
5266  /*
5267  * We are the requested serializer so we must execute
5268  * the task now or deadlock waiting on ourself to
5269  * execute it.
5270  */
5271  return sip_task(task_data);
5272  }
5273 
5274  return ast_sip_push_task_wait(serializer, sip_task, task_data);
5275 }
5276 
5277 void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
5278 {
5279  size_t chars_to_copy = MIN(size - 1, pj_strlen(src));
5280  memcpy(dest, pj_strbuf(src), chars_to_copy);
5281  dest[chars_to_copy] = '\0';
5282 }
5283 
5284 int ast_copy_pj_str2(char **dest, const pj_str_t *src)
5285 {
5286  int res = ast_asprintf(dest, "%.*s", (int)pj_strlen(src), pj_strbuf(src));
5287 
5288  if (res < 0) {
5289  *dest = NULL;
5290  }
5291 
5292  return res;
5293 }
5294 
5295 
5296 int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype)
5297 {
5298  pjsip_media_type compare;
5299 
5300  if (!content_type) {
5301  return 0;
5302  }
5303 
5304  pjsip_media_type_init2(&compare, type, subtype);
5305 
5306  return pjsip_media_type_cmp(content_type, &compare, 0) ? 0 : -1;
5307 }
5308 
5309 pj_caching_pool caching_pool;
5310 pj_pool_t *memory_pool;
5311 pj_thread_t *monitor_thread;
5312 static int monitor_continue;
5313 
5314 static void *monitor_thread_exec(void *endpt)
5315 {
5316  while (monitor_continue) {
5317  const pj_time_val delay = {0, 10};
5318  pjsip_endpt_handle_events(ast_pjsip_endpoint, &delay);
5319  }
5320  return NULL;
5321 }
5322 
5323 static void stop_monitor_thread(void)
5324 {
5325  monitor_continue = 0;
5326  pj_thread_join(monitor_thread);
5327 }
5328 
5331 #define SIP_SERVANT_ID 0x5E2F1D
5332 
5333 static void sip_thread_start(void)
5334 {
5335  pj_thread_desc *desc;
5336  pj_thread_t *thread;
5337  uint32_t *servant_id;
5338 
5339  servant_id = ast_threadstorage_get(&servant_id_storage, sizeof(*servant_id));
5340  if (!servant_id) {
5341  ast_log(LOG_ERROR, "Could not set SIP servant ID in thread-local storage.\n");
5342  return;
5343  }
5344  *servant_id = SIP_SERVANT_ID;
5345 
5346  desc = ast_threadstorage_get(&pj_thread_storage, sizeof(pj_thread_desc));
5347  if (!desc) {
5348  ast_log(LOG_ERROR, "Could not get thread desc from thread-local storage. Expect awful things to occur\n");
5349  return;
5350  }
5351  pj_bzero(*desc, sizeof(*desc));
5352 
5353  if (pj_thread_register("Asterisk Thread", *desc, &thread) != PJ_SUCCESS) {
5354  ast_log(LOG_ERROR, "Couldn't register thread with PJLIB.\n");
5355  }
5356 }
5357 
5359 {
5360  uint32_t *servant_id;
5361 
5362  if (monitor_thread &&
5363  pthread_self() == *(pthread_t *)pj_thread_get_os_handle(monitor_thread)) {
5364  return 1;
5365  }
5366 
5367  servant_id = ast_threadstorage_get(&servant_id_storage, sizeof(*servant_id));
5368  if (!servant_id) {
5369  return 0;
5370  }
5371 
5372  return *servant_id == SIP_SERVANT_ID;
5373 }
5374 
5375 void *ast_sip_dict_get(void *ht, const char *key)
5376 {
5377  unsigned int hval = 0;
5378 
5379  if (!ht) {
5380  return NULL;
5381  }
5382 
5383  return pj_hash_get(ht, key, PJ_HASH_KEY_STRING, &hval);
5384 }
5385 
5386 void *ast_sip_dict_set(pj_pool_t* pool, void *ht,
5387  const char *key, void *val)
5388 {
5389  if (!ht) {
5390  ht = pj_hash_create(pool, 11);
5391  }
5392 
5393  pj_hash_set(pool, ht, key, PJ_HASH_KEY_STRING, 0, val);
5394 
5395  return ht;
5396 }
5397 
5398 static pj_bool_t supplement_on_rx_request(pjsip_rx_data *rdata)
5399 {
5400  struct ast_sip_supplement *supplement;
5401 
5402  if (pjsip_rdata_get_dlg(rdata)) {
5403  return PJ_FALSE;
5404  }
5405 
5407  AST_LIST_TRAVERSE(&supplements, supplement, next) {
5408  if (supplement->incoming_request
5409  && does_method_match(&rdata->msg_info.msg->line.req.method.name, supplement->method)) {
5410  struct ast_sip_endpoint *endpoint;
5411 
5412  endpoint = ast_pjsip_rdata_get_endpoint(rdata);
5413  supplement->incoming_request(endpoint, rdata);
5414  ao2_cleanup(endpoint);
5415  }
5416  }
5418 
5419  return PJ_FALSE;
5420 }
5421 
5422 static void supplement_outgoing_response(pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
5423 {
5424  struct ast_sip_supplement *supplement;
5425  pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ, NULL);
5427 
5428  if (sip_endpoint) {
5429  ast_sip_message_apply_transport(sip_endpoint->transport, tdata);
5430  }
5431 
5433  AST_LIST_TRAVERSE(&supplements, supplement, next) {
5434  if (supplement->outgoing_response && does_method_match(&cseq->method.name, supplement->method)) {
5435  supplement->outgoing_response(sip_endpoint, contact, tdata);
5436  }
5437  }
5439 
5440  ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
5441  ao2_cleanup(contact);
5442 }
5443 
5444 int ast_sip_send_response(pjsip_response_addr *res_addr, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
5445 {
5446  pj_status_t status;
5447 
5448  supplement_outgoing_response(tdata, sip_endpoint);
5449  status = pjsip_endpt_send_response(ast_sip_get_pjsip_endpoint(), res_addr, tdata, NULL, NULL);
5450  if (status != PJ_SUCCESS) {
5451  pjsip_tx_data_dec_ref(tdata);
5452  }
5453 
5454  return status == PJ_SUCCESS ? 0 : -1;
5455 }
5456 
5457 int ast_sip_send_stateful_response(pjsip_rx_data *rdata, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
5458 {
5459  pjsip_transaction *tsx;
5460 
5461  if (pjsip_tsx_create_uas(NULL, rdata, &tsx) != PJ_SUCCESS) {
5462  struct ast_sip_contact *contact;
5463 
5464  /* ast_sip_create_response bumps the refcount of the contact and adds it to the tdata.
5465  * We'll leak that reference if we don't get rid of it here.
5466  */
5467  contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
5468  ao2_cleanup(contact);
5469  ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
5470  pjsip_tx_data_dec_ref(tdata);
5471  return -1;
5472  }
5473  pjsip_tsx_recv_msg(tsx, rdata);
5474 
5475  supplement_outgoing_response(tdata, sip_endpoint);
5476 
5477  if (pjsip_tsx_send_msg(tsx, tdata) != PJ_SUCCESS) {
5478  pjsip_tx_data_dec_ref(tdata);
5479  return -1;
5480  }
5481 
5482  return 0;
5483 }
5484 
5485 int ast_sip_create_response(const pjsip_rx_data *rdata, int st_code,
5486  struct ast_sip_contact *contact, pjsip_tx_data **tdata)
5487 {
5488  int res = pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, st_code, NULL, tdata);
5489 
5490  if (!res) {
5491  ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
5492  }
5493 
5494  return res;
5495 }
5496 
5497 int ast_sip_get_host_ip(int af, pj_sockaddr *addr)
5498 {
5499  if (af == pj_AF_INET() && !ast_strlen_zero(host_ip_ipv4_string)) {
5500  pj_sockaddr_copy_addr(addr, &host_ip_ipv4);
5501  return 0;
5502  } else if (af == pj_AF_INET6() && !ast_strlen_zero(host_ip_ipv6_string)) {
5503  pj_sockaddr_copy_addr(addr, &host_ip_ipv6);
5504  return 0;
5505  }
5506 
5507  return -1;
5508 }
5509 
5510 const char *ast_sip_get_host_ip_string(int af)
5511 {
5512  if (af == pj_AF_INET()) {
5513  return host_ip_ipv4_string;
5514  } else if (af == pj_AF_INET6()) {
5515  return host_ip_ipv6_string;
5516  }
5517 
5518  return NULL;
5519 }
5520 
5522  char *buf, size_t buf_len)
5523 {
5524  switch (dtmf) {
5525  case AST_SIP_DTMF_NONE:
5526  ast_copy_string(buf, "none", buf_len);
5527  break;
5528  case AST_SIP_DTMF_RFC_4733:
5529  ast_copy_string(buf, "rfc4733", buf_len);
5530  break;
5531  case AST_SIP_DTMF_INBAND:
5532  ast_copy_string(buf, "inband", buf_len);
5533  break;
5534  case AST_SIP_DTMF_INFO:
5535  ast_copy_string(buf, "info", buf_len);
5536  break;
5537  case AST_SIP_DTMF_AUTO:
5538  ast_copy_string(buf, "auto", buf_len);
5539  break;
5541  ast_copy_string(buf, "auto_info", buf_len);
5542  break;
5543  default:
5544  buf[0] = '\0';
5545  return -1;
5546  }
5547  return 0;
5548 }
5549 
5550 int ast_sip_str_to_dtmf(const char * dtmf_mode)
5551 {
5552  int result = -1;
5553 
5554  if (!strcasecmp(dtmf_mode, "info")) {
5555  result = AST_SIP_DTMF_INFO;
5556  } else if (!strcasecmp(dtmf_mode, "rfc4733")) {
5557  result = AST_SIP_DTMF_RFC_4733;
5558  } else if (!strcasecmp(dtmf_mode, "inband")) {
5559  result = AST_SIP_DTMF_INBAND;
5560  } else if (!strcasecmp(dtmf_mode, "none")) {
5561  result = AST_SIP_DTMF_NONE;
5562  } else if (!strcasecmp(dtmf_mode, "auto")) {
5563  result = AST_SIP_DTMF_AUTO;
5564  } else if (!strcasecmp(dtmf_mode, "auto_info")) {
5565  result = AST_SIP_DTMF_AUTO_INFO;
5566  }
5567 
5568  return result;
5569 }
5570 
5572 {
5573  const char *value;
5574 
5575  if (ast_sip_call_codec_pref_test(pref, LOCAL) && ast_sip_call_codec_pref_test(pref, INTERSECT) && ast_sip_call_codec_pref_test(pref, ALL)) {
5576  value = "local";
5577  } else if (ast_sip_call_codec_pref_test(pref, LOCAL) && ast_sip_call_codec_pref_test(pref, UNION) && ast_sip_call_codec_pref_test(pref, ALL)) {
5578  value = "local_merge";
5579  } else if (ast_sip_call_codec_pref_test(pref, LOCAL) && ast_sip_call_codec_pref_test(pref, INTERSECT) && ast_sip_call_codec_pref_test(pref, FIRST)) {
5580  value = "local_first";
5581  } else if (ast_sip_call_codec_pref_test(pref, REMOTE) && ast_sip_call_codec_pref_test(pref, INTERSECT) && ast_sip_call_codec_pref_test(pref, ALL)) {
5582  value = "remote";
5583  } else if (ast_sip_call_codec_pref_test(pref, REMOTE) && ast_sip_call_codec_pref_test(pref, UNION) && ast_sip_call_codec_pref_test(pref, ALL)) {
5584  value = "remote_merge";
5585  } else if (ast_sip_call_codec_pref_test(pref, REMOTE) && ast_sip_call_codec_pref_test(pref, UNION) && ast_sip_call_codec_pref_test(pref, FIRST)) {
5586  value = "remote_first";
5587  } else {
5588  value = "unknown";
5589  }
5590 
5591  return value;
5592 }
5593 
5594 int ast_sip_call_codec_str_to_pref(struct ast_flags *pref, const char *pref_str, int is_outgoing)
5595 {
5596  pref->flags = 0;
5597 
5598  if (strcmp(pref_str, "local") == 0) {
5600  } else if (is_outgoing && strcmp(pref_str, "local_merge") == 0) {
5602  } else if (strcmp(pref_str, "local_first") == 0) {
5604  } else if (strcmp(pref_str, "remote") == 0) {
5606  } else if (is_outgoing && strcmp(pref_str, "remote_merge") == 0) {
5608  } else if (strcmp(pref_str, "remote_first") == 0) {
5610  } else {
5611  return -1;
5612  }
5613 
5614  return 0;
5615 }
5616 
5617 /*!
5618  * \brief Set name and number information on an identity header.
5619  *
5620  * \param pool Memory pool to use for string duplication
5621