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