Asterisk - The Open Source Telephony Project GIT-master-f36a736
res_pjsip.h
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#ifndef _RES_PJSIP_H
20#define _RES_PJSIP_H
21
22#include <pjsip.h>
23/* Needed for SUBSCRIBE, NOTIFY, and PUBLISH method definitions */
24#include <pjsip_simple.h>
25#include <pjsip/sip_transaction.h>
26#include <pj/timer.h>
27/* Needed for pj_sockaddr */
28#include <pjlib.h>
29
31/* Needed for struct ast_sockaddr */
32#include "asterisk/netsock2.h"
33/* Needed for linked list macros */
35/* Needed for ast_party_id */
36#include "asterisk/channel.h"
37/* Needed for ast_sorcery */
38#include "asterisk/sorcery.h"
39/* Needed for ast_dnsmgr */
40#include "asterisk/dnsmgr.h"
41/* Needed for ast_endpoint */
42#include "asterisk/endpoints.h"
43/* Needed for ast_t38_ec_modes */
44#include "asterisk/udptl.h"
45/* Needed for ast_rtp_dtls_cfg struct */
46#include "asterisk/rtp_engine.h"
47/* Needed for AST_VECTOR macro */
48#include "asterisk/vector.h"
49/* Needed for ast_sip_for_each_channel_snapshot struct */
52#include "asterisk/stream.h"
53
54#ifdef HAVE_PJSIP_TLS_TRANSPORT_RESTART
55/* Needed for knowing if the cert or priv key files changed */
56#include <sys/stat.h>
57#endif
58
59#define PJSIP_MINVERSION(m,n,p) (((m << 24) | (n << 16) | (p << 8)) >= PJ_VERSION_NUM)
60
61#ifndef PJSIP_EXPIRES_NOT_SPECIFIED
62/*
63 * Added in pjproject 2.10.0. However define here if someone compiles against a
64 * version of pjproject < 2.10.0.
65 *
66 * Usually defined in pjsip/include/pjsip/sip_msg.h (included as part of <pjsip.h>)
67 */
68#define PJSIP_EXPIRES_NOT_SPECIFIED ((pj_uint32_t)-1)
69#endif
70
71#define PJSTR_PRINTF_SPEC "%.*s"
72#define PJSTR_PRINTF_VAR(_v) ((int)(_v).slen), ((_v).ptr)
73
74#define AST_SIP_AUTH_MAX_REALM_LENGTH 255 /* From the auth/realm realtime column size */
75
76/* ":12345" */
77#define COLON_PORT_STRLEN 6
78/*
79 * "<ipaddr>:<port>"
80 * PJ_INET6_ADDRSTRLEN includes the NULL terminator
81 */
82#define IP6ADDR_COLON_PORT_BUFLEN (PJ_INET6_ADDRSTRLEN + COLON_PORT_STRLEN)
83
84/*!
85 * \brief Fill a buffer with a pjsip transport's remote ip address and port
86 *
87 * \param _transport The pjsip_transport to use
88 * \param _dest The destination buffer of at least IP6ADDR_COLON_PORT_BUFLEN bytes
89 */
90#define AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR(_transport, _dest) \
91 pj_sockaddr_print(&_transport->key.rem_addr, _dest, sizeof(_dest), 1);
92
93/* Forward declarations of PJSIP stuff */
94struct pjsip_rx_data;
95struct pjsip_module;
96struct pjsip_tx_data;
97struct pjsip_dialog;
98struct pjsip_transport;
99struct pjsip_tpfactory;
100struct pjsip_tls_setting;
101struct pjsip_tpselector;
102
103/*! \brief Maximum number of ciphers supported for a TLS transport */
104#define SIP_TLS_MAX_CIPHERS 64
105
106/*! Maximum number of challenges before assuming that we are in a loop */
107#define MAX_RX_CHALLENGES 10
108
110
111static const pj_str_t AST_PJ_STR_EMPTY = { "", 0 };
112
113/*!
114 * \brief Structure for SIP transport information
115 */
117 /*! \brief Transport itself */
118 struct pjsip_transport *transport;
119 /*! \brief Transport factory */
120 struct pjsip_tpfactory *factory;
121 /*!
122 * Transport id
123 * \since 13.8.0
124 */
125 char *id;
126 /*!
127 * Transport type
128 * \since 13.8.0
129 */
131 /*!
132 * Address and port to bind to
133 * \since 13.8.0
134 */
135 pj_sockaddr host;
136 /*!
137 * TLS settings
138 * \since 13.8.0
139 */
140 pjsip_tls_setting tls;
141 /*!
142 * Configured TLS ciphers
143 * \since 13.8.0
144 */
146 /*!
147 * Optional local network information, used for NAT purposes.
148 * "deny" (set) means that it's in the local network. Use the
149 * ast_sip_transport_is_nonlocal and ast_sip_transport_is_local
150 * macro's.
151 * \since 13.8.0
152 */
154 /*!
155 * DNS manager for refreshing the external signaling address
156 * \since 13.8.0
157 */
159 /*!
160 * Optional external signaling address information
161 * \since 13.8.0
162 */
164 /*!
165 * DNS manager for refreshing the external media address
166 * \since 13.18.0
167 */
169 /*!
170 * Optional external signaling address information
171 * \since 13.18.0
172 */
174 /*!
175 * Set when this transport is a flow of signaling to a target
176 * \since 17.0.0
177 */
178 int flow;
179 /*!
180 * The P-Preferred-Identity to use on traffic using this transport
181 * \since 17.0.0
182 */
184 /*!
185 * The Service Routes to use on traffic using this transport
186 * \since 17.0.0
187 */
189 /*!
190 * Disregard RFC5922 7.2, and allow wildcard certs (TLS only)
191 */
193 /*!
194 * If true, fail if server certificate cannot verify (TLS only)
195 */
197#ifdef HAVE_PJSIP_TLS_TRANSPORT_RESTART
198 /*!
199 * The stats information for the certificate file, if configured
200 */
201 struct stat cert_file_stat;
202 /*!
203 * The stats information for the private key file, if configured
204 */
205 struct stat privkey_file_stat;
206#endif
207};
208
209#define ast_sip_transport_is_nonlocal(transport_state, addr) \
210 (!transport_state->localnet || ast_apply_ha(transport_state->localnet, addr) == AST_SENSE_ALLOW)
211
212#define ast_sip_transport_is_local(transport_state, addr) \
213 (transport_state->localnet && ast_apply_ha(transport_state->localnet, addr) != AST_SENSE_ALLOW)
214
215/*!
216 * \brief Transport to bind to
217 */
219 /*! Sorcery object details */
222 /*! Certificate of authority list file */
224 /*! Certificate of authority list path */
226 /*! Public certificate file */
228 /*! Optional private key of the certificate file */
230 /*! Password to open the private key */
232 /*! External signaling address */
234 /*! External media address */
236 /*! Optional domain to use for messages if provided could not be found */
238 );
239 /*! Type of transport */
241 /*!
242 * \deprecated Moved to ast_sip_transport_state
243 * \version 13.8.0 deprecated
244 * Address and port to bind to
245 */
246 pj_sockaddr host;
247 /*! Number of simultaneous asynchronous operations */
248 unsigned int async_operations;
249 /*! Optional external port for signaling */
251 /*!
252 * \deprecated Moved to ast_sip_transport_state
253 * \version 13.7.1 deprecated
254 * TLS settings
255 */
256 pjsip_tls_setting tls;
257 /*!
258 * \deprecated Moved to ast_sip_transport_state
259 * \version 13.7.1 deprecated
260 * Configured TLS ciphers
261 */
263 /*!
264 * \deprecated Moved to ast_sip_transport_state
265 * \version 13.7.1 deprecated
266 * Optional local network information, used for NAT purposes
267 */
269 /*!
270 * \deprecated Moved to ast_sip_transport_state
271 * \version 13.7.1 deprecated
272 * DNS manager for refreshing the external address
273 */
275 /*!
276 * \deprecated Moved to ast_sip_transport_state
277 * \version 13.7.1 deprecated
278 * Optional external address information
279 */
281 /*!
282 * \deprecated
283 * \version 13.7.1 deprecated
284 * Transport state information
285 */
287 /*! QOS DSCP TOS bits */
288 unsigned int tos;
289 /*! QOS COS value */
290 unsigned int cos;
291 /*! Write timeout */
293 /*! Allow reload */
295 /*! Automatically send requests out the same transport requests have come in on */
297 /*! This is a flow to another target */
298 int flow;
299 /*! Enable TCP keepalive */
301 /*! Time in seconds the connection needs to remain idle before TCP starts sending keepalive probes */
303 /*! The time in seconds between individual keepalive probes */
305 /*! The maximum number of keepalive probes TCP should send before dropping the connection */
307};
308
309#define SIP_SORCERY_DOMAIN_ALIAS_TYPE "domain_alias"
310
311/*!
312 * Details about a SIP domain alias
313 */
315 /*! Sorcery object details */
318 /*! Domain to be aliased to */
320 );
321};
322
323/*!
324 * \brief Structure for SIP nat hook information
325 */
327 /*! Sorcery object details */
329 /*! Callback for when a message is going outside of our local network */
330 void (*outgoing_external_message)(struct pjsip_tx_data *tdata, struct ast_sip_transport *transport);
331};
332
333/*! \brief Structure which contains information about a transport */
335 /*! \brief Type of transport */
337 /*! \brief Potential pointer to the transport itself, if UDP */
338 pjsip_transport *transport;
339 /*! \brief Potential pointer to the transport factory itself, if TCP/TLS */
340 pjsip_tpfactory *factory;
341 /*! \brief Local address for transport */
343 /*! \brief Local port for transport */
345};
346
347/*!
348 * \brief The kind of security negotiation
349 */
351 /*! No security mechanism negotiation */
353 /*! Use mediasec security mechanism negotiation */
355 /* Add RFC 3329 (sec-agree) mechanism negotiation in the future */
356};
357
358/*!
359 * \brief The security mechanism type
360 */
363 /* Use msrp-tls as security mechanism */
365 /* Use sdes-srtp as security mechanism */
367 /* Use dtls-srtp as security mechanism */
369 /* Add RFC 3329 (sec-agree) mechanisms like tle, digest, ipsec-ike in the future */
370};
371
372/*!
373 * \brief Structure representing a security mechanism as defined in RFC 3329
374 */
376 /* Used to determine which security mechanism to use. */
378 /* The preference of this security mechanism. The higher the value, the more preferred. */
379 float qvalue;
380 /* Optional mechanism parameters. */
382};
383
385
386/*!
387 * \brief Contact associated with an address of record
388 */
390 /*! Sorcery object details, the id is the aor name plus a random string */
393 /*! Full URI of the contact */
395 /*! Outbound proxy to use for qualify */
397 /*! Path information to place in Route headers */
399 /*! Content of the User-Agent header in REGISTER request */
401 /*! The name of the aor this contact belongs to */
403 /*! Asterisk Server name */
405 /*! IP-address of the Via header in REGISTER request */
407 /*! Content of the Call-ID header in REGISTER request */
409 /*! The name of the endpoint that added the contact */
411 );
412 /*! Absolute time that this contact is no longer valid after */
413 struct timeval expiration_time;
414 /*! Frequency to send OPTIONS requests to contact. 0 is disabled. */
415 unsigned int qualify_frequency;
416 /*! If true authenticate the qualify challenge response if needed */
418 /*! Qualify timeout. 0 is diabled. */
420 /*! Endpoint that added the contact, only available in observers */
422 /*! Port of the Via header in REGISTER request */
424 /*! If true delete the contact on Asterisk restart/boot */
426};
427
428/*!
429 * \brief Status type for a contact.
430 */
432 /*! Frequency > 0, but no response from remote uri */
434 /*! Frequency > 0, and got response from remote uri */
436 /*! Default last status, and when a contact status object is not found */
438 /*! Frequency == 0, has a contact, but don't know status (non-qualified) */
441};
442
443/*!
444 * \brief A contact's status.
445 *
446 * Maintains a contact's current status and round trip time if available.
447 */
450 /*! The original contact's URI */
452 /*! The name of the aor this contact_status belongs to */
454 );
455 /*! The round trip time in microseconds */
456 int64_t rtt;
457 /*!
458 * The security mechanism list of the contact (RFC 3329).
459 * Stores the values of Security-Server headers in 401/421/494 responses to an
460 * in-dialog request or successful outbound registration which will be used to
461 * set the Security-Verify headers of all subsequent requests to the contact.
462 */
464 /*! Current status for a contact (default - unavailable) */
466 /*! Last status for a contact (default - unavailable) */
468 /*! Name of the contact */
469 char name[0];
470};
471
472/*!
473 * \brief A SIP address of record
474 */
476 /*! Sorcery object details, the id is the AOR name */
479 /*! Voicemail boxes for this AOR */
481 /*! Outbound proxy for OPTIONS requests */
483 );
484 /*! Minimum expiration time */
485 unsigned int minimum_expiration;
486 /*! Maximum expiration time */
487 unsigned int maximum_expiration;
488 /*! Default contact expiration if one is not provided in the contact */
489 unsigned int default_expiration;
490 /*! Frequency to send OPTIONS requests to AOR contacts. 0 is disabled. */
491 unsigned int qualify_frequency;
492 /*! If true authenticate the qualify challenge response if needed */
494 /*! Maximum number of external contacts, 0 to disable */
495 unsigned int max_contacts;
496 /*! Whether to remove any existing contacts not related to an incoming REGISTER when it comes in */
497 unsigned int remove_existing;
498 /*! Any permanent configured contacts */
500 /*! Determines whether SIP Path headers are supported */
501 unsigned int support_path;
502 /*! Qualify timeout. 0 is diabled. */
504 /*! Voicemail extension to set in Message-Account */
506 /*! Whether to remove unavailable contacts over max_contacts at all or first if remove_existing is enabled */
507 unsigned int remove_unavailable;
508};
509
510/*!
511 * \brief A wrapper for contact that adds the aor_id and
512 * a consistent contact id. Used by ast_sip_for_each_contact.
513 */
515 /*! The id of the parent aor. */
516 char *aor_id;
517 /*! The id of contact in form of aor_id/contact_uri. */
519 /*! Pointer to the actual contact. */
521};
522
523/*!
524 * \brief 100rel modes for SIP endpoints
525 */
527 /*! Do not support 100rel. (no) */
529 /*! As UAC, indicate 100rel support in Supported header. (yes) */
531 /*! As UAS, send 1xx responses reliably, if the UAC indicated its support. Otherwise same as AST_SIP_100REL_SUPPORTED. (peer_supported) */
533 /*! Require the use of 100rel. (required) */
535};
536
537/*!
538 * \brief DTMF modes for SIP endpoints
539 */
541 /*! No DTMF to be used */
543 /* XXX Should this be 2833 instead? */
544 /*! Use RFC 4733 events for DTMF */
546 /*! Use DTMF in the audio stream */
548 /*! Use SIP INFO DTMF (blech) */
550 /*! Use SIP 4733 if supported by the other side or INBAND if not */
552 /*! Use SIP 4733 if supported by the other side or INFO DTMF (blech) if not */
554};
555
556/*!
557 * \brief Methods of storing SIP digest authentication credentials.
558 *
559 * Note that both methods result in MD5 digest authentication being
560 * used. The two methods simply alter how Asterisk determines the
561 * credentials for a SIP authentication
562 */
564 /*! Credentials stored as a username and password combination */
566 /*! Credentials stored as an MD5 sum */
568 /*! Google Oauth */
570 /*! Credentials not stored this is a fake auth */
573
574#define SIP_SORCERY_AUTH_TYPE "auth"
575
577 /*! Sorcery ID of the auth is its name */
580 /*! Identification for these credentials */
582 /*! Authentication username */
584 /*! Authentication password */
586 /*! Authentication credentials in MD5 format (hash of user:realm:pass) */
588 /*! Refresh token to use for OAuth authentication */
590 /*! Client ID to use for OAuth authentication */
592 /*! Secret to use for OAuth authentication */
594 );
595 /*! The time period (in seconds) that a nonce may be reused */
596 unsigned int nonce_lifetime;
597 /*! Used to determine what to use when authenticating */
599};
600
602
603/*!
604 * \brief Different methods by which incoming requests can be matched to endpoints
605 */
607 /*! Identify based on user name in From header */
609 /*! Identify based on user name in Auth header first, then From header */
611 /*! Identify based on source IP address */
613 /*! Identify based on arbitrary headers */
615 /*! Identify based on request uri */
617};
619
621 /*! Use reinvite to negotiate direct media */
623 /*! Use UPDATE to negotiate direct media */
625};
626
628 /*! Take no special action to mitigate reinvite glare */
630 /*! Do not send an initial direct media session refresh on outgoing call legs
631 * Subsequent session refreshes will be sent no matter the session direction
632 */
634 /*! Do not send an initial direct media session refresh on incoming call legs
635 * Subsequent session refreshes will be sent no matter the session direction
636 */
638};
639
641 /*! Invalid media encryption configuration */
643 /*! Do not allow any encryption of session media */
645 /*! Offer SDES-encrypted session media */
647 /*! Offer encrypted session media with datagram TLS key exchange */
649};
650
652 /*! User portion of the target URI should be used as the target in the dialplan */
654 /*! Target URI should be used as the target in the dialplan */
656 /*! Target URI should be used as the target within chan_pjsip itself */
658};
659
660/*!
661 * \brief Incoming/Outgoing call offer/answer joint codec preference.
662 *
663 * The default is INTERSECT ALL LOCAL.
664 */
666 /*! Two bits for merge */
667 /*! Intersection of local and remote */
669 /*! Union of local and remote */
671
672 /*! Two bits for filter */
673 /*! No filter */
675 /*! Only the first */
677
678 /*! Two bits for preference and sort */
679 /*! Prefer, and order by local values */
681 /*! Prefer, and order by remote values */
683};
684
685/*!
686 * \brief Returns true if the preference is set in the parameter
687 * \since 18.0.0
688 *
689 * \param __param A ast_flags struct with one or more of enum ast_sip_call_codec_pref set
690 * \param __codec_pref The last component of one of the enum values
691 * \retval 1 if the enum value is set
692 * \retval 0 if not
693 */
694#define ast_sip_call_codec_pref_test(__param, __codec_pref) (!!(ast_test_flag( &__param, AST_SIP_CALL_CODEC_PREF_ ## __codec_pref )))
695
696/*!
697 * \brief Session timers options
698 */
700 /*! Minimum session expiration period, in seconds */
701 unsigned int min_se;
702 /*! Session expiration period, in seconds */
703 unsigned int sess_expires;
704};
705
706/*!
707 * \brief Endpoint configuration for SIP extensions.
708 *
709 * SIP extensions, in this case refers to features
710 * indicated in Supported or Required headers.
711 */
713 /*! Enabled SIP extensions */
714 unsigned int flags;
715 /*! Timer options */
717};
718
719/*!
720 * \brief Endpoint configuration for unsolicited MWI
721 */
724 /*! Configured voicemail boxes for this endpoint. Used for MWI */
726 /*! Username to use when sending MWI NOTIFYs to this endpoint */
728 );
729 /*! Should mailbox states be combined into a single notification? */
730 unsigned int aggregate;
731 /*! Should a subscribe replace unsolicited notifies? */
733 /*! Voicemail extension to set in Message-Account */
735};
736
737/*!
738 * \brief Endpoint subscription configuration
739 */
741 /*! Indicates if endpoint is allowed to initiate subscriptions */
742 unsigned int allow;
743 /*! The minimum allowed expiration for subscriptions from endpoint */
744 unsigned int minexpiry;
745 /*! Message waiting configuration */
747 /*! Context for SUBSCRIBE requests */
749};
750
751/*!
752 * \brief NAT configuration options for endpoints
753 */
755 /*! Whether to force using the source IP address/port for sending responses */
756 unsigned int force_rport;
757 /*! Whether to rewrite the Contact header with the source IP address/port or not */
758 unsigned int rewrite_contact;
759};
760
761/*!
762 * \brief Party identification options for endpoints
763 *
764 * This includes caller ID, connected line, and redirecting-related options
765 */
768 /*! Do we accept identification information from this endpoint */
769 unsigned int trust_inbound;
770 /*! Do we send private identification information to this endpoint? */
771 unsigned int trust_outbound;
772 /*! Do we send P-Asserted-Identity headers to this endpoint? */
773 unsigned int send_pai;
774 /*! Do we send Remote-Party-ID headers to this endpoint? */
775 unsigned int send_rpid;
776 /*! Do we send messages for connected line updates for unanswered incoming calls immediately to this endpoint? */
777 unsigned int rpid_immediate;
778 /*! Do we add Diversion headers to applicable outgoing requests/responses? */
779 unsigned int send_diversion;
780 /*! Do we accept connected line updates from this endpoint? */
782 /*! Do we send connected line updates to this endpoint? */
784 /*! When performing connected line update, which method should be used */
786 /*! Do we add History-Info headers to applicable outgoing requests/responses? */
787 unsigned int send_history_info;
788};
789
790/*!
791 * \brief Call pickup configuration options for endpoints
792 */
794 /*! Call group */
796 /*! Pickup group */
798 /*! Named call group */
799 struct ast_namedgroups *named_callgroups;
800 /*! Named pickup group */
801 struct ast_namedgroups *named_pickupgroups;
802};
803
804/*!
805 * \brief Configuration for one-touch INFO recording
806 */
809 /*! Feature to enact when one-touch recording INFO with Record: On is received */
811 /*! Feature to enact when one-touch recording INFO with Record: Off is received */
813 );
814 /*! Is one-touch recording permitted? */
815 unsigned int enabled;
816};
817
818/*!
819 * \brief Endpoint configuration options for INFO packages
820 */
822 /*! Configuration for one-touch recording */
824};
825
826/*!
827 * \brief RTP configuration for SIP endpoints
828 */
831 /*! Configured RTP engine for this endpoint. */
833 );
834 /*! Whether IPv6 RTP is enabled or not */
835 unsigned int ipv6;
836 /*! Whether symmetric RTP is enabled or not */
837 unsigned int symmetric;
838 /*! Whether ICE support is enabled or not */
839 unsigned int ice_support;
840 /*! Whether to use the "ptime" attribute received from the endpoint or not */
841 unsigned int use_ptime;
842 /*! Do we use AVPF exclusively for this endpoint? */
843 unsigned int use_avpf;
844 /*! Do we force AVP, AVPF, SAVP, or SAVPF even for DTLS media streams? */
845 unsigned int force_avp;
846 /*! Do we use the received media transport in our answer SDP */
848 /*! \brief DTLS-SRTP configuration information */
850 /*! Should SRTP use a 32 byte tag instead of an 80 byte tag? */
851 unsigned int srtp_tag_32;
852 /*! Do we use media encryption? what type? */
854 /*! Do we want to optimistically support encryption if possible? */
856 /*! Number of seconds between RTP keepalive packets */
857 unsigned int keepalive;
858 /*! Number of seconds before terminating channel due to lack of RTP (when not on hold) */
859 unsigned int timeout;
860 /*! Number of seconds before terminating channel due to lack of RTP (when on hold) */
861 unsigned int timeout_hold;
862 /*! Follow forked media with a different To tag */
864 /*! Accept updated SDPs on non-100rel 18X and 2XX responses with the same To tag */
866};
867
868/*!
869 * \brief Direct media options for SIP endpoints
870 */
872 /*! Boolean indicating if direct_media is permissible */
873 unsigned int enabled;
874 /*! When using direct media, which method should be used */
876 /*! Take steps to mitigate glare for direct media */
878 /*! Do not attempt direct media session refreshes if a media NAT is detected */
879 unsigned int disable_on_nat;
880};
881
883 /*! Whether T.38 UDPTL support is enabled or not */
884 unsigned int enabled;
885 /*! Error correction setting for T.38 UDPTL */
887 /*! Explicit T.38 max datagram value, may be 0 to indicate the remote side can be trusted */
888 unsigned int maxdatagram;
889 /*! Whether NAT Support is enabled for T.38 UDPTL sessions or not */
890 unsigned int nat;
891 /*! Whether to use IPv6 for UDPTL or not */
892 unsigned int ipv6;
893 /*! Bind the UDPTL instance to the media_address */
895};
896
897/*!
898 * \brief Media configuration for SIP endpoints
899 */
902 /*! Optional media address to use in SDP */
904 /*! SDP origin username */
906 /*! SDP session name */
908 );
909 /*! RTP media configuration */
911 /*! Direct media options */
913 /*! T.38 (FoIP) options */
915 /*! Configured codecs */
917 /*! Capabilities in topology form */
919 /*! DSCP TOS bits for audio streams */
920 unsigned int tos_audio;
921 /*! Priority for audio streams */
922 unsigned int cos_audio;
923 /*! DSCP TOS bits for video streams */
924 unsigned int tos_video;
925 /*! Priority for video streams */
926 unsigned int cos_video;
927 /*! Is g.726 packed in a non standard way */
928 unsigned int g726_non_standard;
929 /*! Bind the RTP instance to the media_address */
931 /*! Use RTCP-MUX */
932 unsigned int rtcp_mux;
933 /*! Maximum number of audio streams to offer/accept */
934 unsigned int max_audio_streams;
935 /*! Maximum number of video streams to offer/accept */
936 unsigned int max_video_streams;
937 /*! Use BUNDLE */
938 unsigned int bundle;
939 /*! Enable webrtc settings and defaults */
940 unsigned int webrtc;
941 /*! Codec preference for an incoming offer */
943 /*! Codec preference for an outgoing offer */
945 /*! Codec negotiation prefs for incoming offers */
947 /*! Codec negotiation prefs for outgoing offers */
949 /*! Codec negotiation prefs for incoming answers */
951 /*! Codec negotiation prefs for outgoing answers */
953};
954
955/*!
956 * \brief An entity with which Asterisk communicates
957 */
961 /*! Context to send incoming calls to */
963 /*! Name of an explicit transport to use */
965 /*! Outbound proxy to use */
967 /*! Explicit AORs to dial if none are specified */
969 /*! Musiconhold class to suggest that the other side use when placing on hold */
971 /*! Configured tone zone for this endpoint. */
973 /*! Configured language for this endpoint. */
975 /*! Default username to place in From header */
977 /*! Domain to place in From header */
979 /*! Context to route incoming MESSAGE requests to */
981 /*! Accountcode to auto-set on channels */
983 /*! If set, we'll push incoming MWI NOTIFYs to stasis using this mailbox */
985 /*! STIR/SHAKEN profile to use */
987 );
988 /*! Configuration for extensions */
990 /*! Configuration relating to media */
992 /*! SUBSCRIBE/NOTIFY configuration options */
994 /*! NAT configuration */
996 /*! Party identification options */
998 /*! Configuration options for INFO packages */
1000 /*! Call pickup configuration */
1002 /*! Inbound authentication credentials */
1004 /*! Outbound authentication credentials */
1006 /*! DTMF mode to use with this endpoint */
1008 /*! Method(s) by which the endpoint should be identified. */
1010 /*! Order of the method(s) by which the endpoint should be identified. */
1012 /*! Boolean indicating if ringing should be sent as inband progress */
1013 unsigned int inband_progress;
1014 /*! Pointer to the persistent Asterisk endpoint */
1016 /*! The number of channels at which busy device state is returned */
1018 /*! Whether fax detection is enabled or not (CNG tone detection) */
1019 unsigned int faxdetect;
1020 /*! Determines if transfers (using REFER) are allowed by this endpoint */
1021 unsigned int allowtransfer;
1022 /*! Method used when handling redirects */
1024 /*! Variables set on channel creation */
1026 /*! Whether to place a 'user=phone' parameter into the request URI if user is a number */
1027 unsigned int usereqphone;
1028 /*! Whether to pass through hold and unhold using re-invites with recvonly and sendrecv */
1029 unsigned int moh_passthrough;
1030 /*! Access control list */
1032 /*! Restrict what IPs are allowed in the Contact header (for registration) */
1034 /*! The number of seconds into call to disable fax detection. (0 = disabled) */
1035 unsigned int faxdetect_timeout;
1036 /*! Override the user on the outgoing Contact header with this value. */
1038 /*! Whether to response SDP offer with single most preferred codec. */
1040 /*! Do we allow an asymmetric RTP codec? */
1042 /*! Do we allow overlap dialling? */
1043 unsigned int allow_overlap;
1044 /*! Whether to notifies all the progress details on blind transfer */
1046 /*! Whether to notifies dialog-info 'early' on INUSE && RINGING state */
1048 /*! Suppress Q.850 Reason headers on this endpoint */
1050 /*! Ignore 183 if no SDP is present */
1052 /*! Type of security negotiation to use (RFC 3329). */
1054 /*! Client security mechanisms (RFC 3329). */
1056 /*! Set which STIR/SHAKEN behaviors we want on this endpoint */
1057 unsigned int stir_shaken;
1058 /*! Should we authenticate OPTIONS requests per RFC 3261? */
1060 /*! The name of the geoloc profile to apply when Asterisk receives a call from this endpoint */
1061 AST_STRING_FIELD_EXTENDED(geoloc_incoming_call_profile);
1062 /*! The name of the geoloc profile to apply when Asterisk sends a call to this endpoint */
1063 AST_STRING_FIELD_EXTENDED(geoloc_outgoing_call_profile);
1064 /*! The context to use for overlap dialing, if different from the endpoint's context */
1066 /*! 100rel mode to use with this endpoint */
1068 /*! Send Advice-of-Charge messages */
1069 unsigned int send_aoc;
1070 /*! Tenant ID for the endpoint */
1072 /*! Ignore remote hold requests */
1074};
1075
1076/*! URI parameter for symmetric transport */
1077#define AST_SIP_X_AST_TXP "x-ast-txp"
1078#define AST_SIP_X_AST_TXP_LEN 9
1079
1080/*! Common media types used throughout res_pjsip and pjproject */
1081extern pjsip_media_type pjsip_media_type_application_json;
1083extern pjsip_media_type pjsip_media_type_application_pidf_xml;
1084extern pjsip_media_type pjsip_media_type_application_xpidf_xml;
1085extern pjsip_media_type pjsip_media_type_application_cpim_xpidf_xml;
1086extern pjsip_media_type pjsip_media_type_application_rlmi_xml;
1088extern pjsip_media_type pjsip_media_type_application_sdp;
1089extern pjsip_media_type pjsip_media_type_multipart_alternative;
1090extern pjsip_media_type pjsip_media_type_multipart_mixed;
1091extern pjsip_media_type pjsip_media_type_multipart_related;
1092extern pjsip_media_type pjsip_media_type_text_plain;
1093
1094/*!
1095 * \brief Compare pjsip media types
1096 *
1097 * \param a the first media type
1098 * \param b the second media type
1099 * \retval 1 Media types are equal
1100 * \retval 0 Media types are not equal
1101 */
1102int ast_sip_are_media_types_equal(pjsip_media_type *a, pjsip_media_type *b);
1103
1104/*!
1105 * \brief Check if a media type is in a list of others
1106 *
1107 * \param a pjsip_media_type to search for
1108 * \param ... one or more pointers to pjsip_media_types the last of which must be "SENTINEL"
1109 * \retval 1 Media types are equal
1110 * \retval 0 Media types are not equal
1111 */
1112int ast_sip_is_media_type_in(pjsip_media_type *a, ...) attribute_sentinel;
1113
1114/*!
1115 * \brief Add security headers to transmission data
1116 *
1117 * \param security_mechanisms Vector of security mechanisms.
1118 * \param header_name The header name under which to add the security mechanisms.
1119 * One of Security-Client, Security-Server, Security-Verify.
1120 * \param add_qval If zero, don't add the q-value to the header.
1121 * \param tdata The transmission data.
1122 * \retval 0 Success
1123 * \retval non-zero Failure
1124 */
1126 const char *header_name, int add_qval, pjsip_tx_data *tdata);
1127
1128/*!
1129 * \brief Append to security mechanism vector from SIP header
1130 *
1131 * \param hdr The header of the security mechanisms.
1132 * \param security_mechanisms Vector of security mechanisms to append to.
1133 * Header name must be one of Security-Client, Security-Server, Security-Verify.
1134 */
1135void ast_sip_header_to_security_mechanism(const pjsip_generic_string_hdr *hdr,
1136 struct ast_sip_security_mechanism_vector *security_mechanisms);
1137
1138/*!
1139 * \brief Initialize security mechanism vector from string of security mechanisms.
1140 *
1141 * \param security_mechanism Pointer to vector of security mechanisms to initialize.
1142 * \param value String of security mechanisms as defined in RFC 3329.
1143 * \retval 0 Success
1144 * \retval non-zero Failure
1145 */
1146int ast_sip_security_mechanism_vector_init(struct ast_sip_security_mechanism_vector *security_mechanism, const char *value);
1147
1148/*!
1149 * \brief Removes all headers of a specific name and value from a pjsip_msg.
1150 *
1151 * \param msg PJSIP message from which to remove headers.
1152 * \param hdr_name Name of the header to remove.
1153 * \param value Optional string value of the header to remove.
1154 * If NULL, remove all headers of given hdr_name.
1155 */
1156void ast_sip_remove_headers_by_name_and_value(pjsip_msg *msg, const pj_str_t *hdr_name, const char* value);
1157
1158/*!
1159 * \brief Duplicate a security mechanism.
1160 *
1161 * \param dst Security mechanism to duplicate to.
1162 * \param src Security mechanism to duplicate.
1163 */
1165 const struct ast_sip_security_mechanism_vector *src);
1166
1167/*!
1168 * \brief Free contents of a security mechanism vector.
1169 *
1170 * \param security_mechanisms Vector whose contents are to be freed
1171 */
1173
1174/*!
1175 * \brief Allocate a security mechanism from a string.
1176 *
1177 * \param security_mechanism Pointer-pointer to the security mechanism to allocate.
1178 * \param value The security mechanism string as defined in RFC 3329 (section 2.2)
1179 * in the form <mechanism_name>;q=<q_value>;<mechanism_parameters>
1180 * \retval 0 Success
1181 * \retval non-zero Failure
1182 */
1183int ast_sip_str_to_security_mechanism(struct ast_sip_security_mechanism **security_mechanism, const char *value);
1184
1185/*!
1186 * \brief Writes the security mechanisms of an endpoint into a buffer as a string and returns the buffer.
1187 *
1188 * \note The buffer must be freed by the caller.
1189 *
1190 * \param endpoint Pointer to endpoint.
1191 * \param add_qvalue If non-zero, the q-value is printed as well
1192 * \param buf The buffer to write the string into
1193 * \retval 0 Success
1194 * \retval non-zero Failure
1195 */
1196int ast_sip_security_mechanisms_to_str(const struct ast_sip_security_mechanism_vector *security_mechanisms, int add_qvalue, char **buf);
1197
1198/*!
1199 * \brief Set the security negotiation based on a given string.
1200 *
1201 * \param security_negotiation Security negotiation enum to set.
1202 * \param val String that represents a security_negotiation value.
1203 * \retval 0 Success
1204 * \retval non-zero Failure
1205 */
1206int ast_sip_set_security_negotiation(enum ast_sip_security_negotiation *security_negotiation, const char *val);
1207
1208/*!
1209 * \brief Initialize an auth vector with the configured values.
1210 *
1211 * \param vector Vector to initialize
1212 * \param auth_names Comma-separated list of names to set in the array
1213 * \retval 0 Success
1214 * \retval non-zero Failure
1215 */
1216int ast_sip_auth_vector_init(struct ast_sip_auth_vector *vector, const char *auth_names);
1217
1218/*!
1219 * \brief Free contents of an auth vector.
1220 *
1221 * \param vector Vector whose contents are to be freed
1222 */
1224
1225/*!
1226 * \brief Possible returns from ast_sip_check_authentication
1227 */
1229 /*! Authentication needs to be challenged */
1231 /*! Authentication succeeded */
1233 /*! Authentication failed */
1235 /*! Authentication encountered some internal error */
1237};
1238
1239/*!
1240 * \brief An interchangeable way of handling digest authentication for SIP.
1241 *
1242 * An authenticator is responsible for filling in the callbacks provided below. Each is called from a publicly available
1243 * function in res_sip. The authenticator can use configuration or other local policy to determine whether authentication
1244 * should take place and what credentials should be used when challenging and authenticating a request.
1245 */
1247 /*!
1248 * \brief Check if a request requires authentication
1249 * See ast_sip_requires_authentication for more details
1250 */
1251 int (*requires_authentication)(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
1252 /*!
1253 * \brief Check that an incoming request passes authentication.
1254 *
1255 * The tdata parameter is useful for adding information such as digest challenges.
1256 *
1257 * \param endpoint The endpoint sending the incoming request
1258 * \param rdata The incoming request
1259 * \param tdata Tentative outgoing request.
1260 */
1262 pjsip_rx_data *rdata, pjsip_tx_data *tdata);
1263};
1264
1265/*!
1266 * \brief an interchangeable way of responding to authentication challenges
1267 *
1268 * An outbound authenticator takes incoming challenges and formulates a new SIP request with
1269 * credentials.
1270 */
1272 /*!
1273 * \brief Create a new request with authentication credentials
1274 *
1275 * \param auths A vector of IDs of auth sorcery objects
1276 * \param challenge The SIP response with authentication challenge(s)
1277 * \param old_request The request that received the auth challenge(s)
1278 * \param new_request The new SIP request with challenge response(s)
1279 * \retval 0 Successfully created new request
1280 * \retval -1 Failed to create a new request
1281 */
1282 int (*create_request_with_auth)(const struct ast_sip_auth_vector *auths, struct pjsip_rx_data *challenge,
1283 struct pjsip_tx_data *old_request, struct pjsip_tx_data **new_request);
1284};
1285
1286/*!
1287 * \brief An entity responsible for identifying the source of a SIP message
1288 */
1290 /*!
1291 * \brief Callback used to identify the source of a message.
1292 * See ast_sip_identify_endpoint for more details
1293 */
1294 struct ast_sip_endpoint *(*identify_endpoint)(pjsip_rx_data *rdata);
1295};
1296
1297/*!
1298 * \brief Contact retrieval filtering flags
1299 */
1301 /*! \brief Default filter flags */
1303
1304 /*! \brief Return only reachable or unknown contacts */
1306};
1307
1308/*!
1309 * \brief Adds a Date header to the tdata, formatted like:
1310 * Date: Wed, 01 Jan 2021 14:53:01 GMT
1311 * \since 16.19.0
1312 *
1313 * \note There is no checking done to see if the header already exists
1314 * before adding it. It's up to the caller of this function to determine
1315 * if that needs to be done or not.
1316 */
1317void ast_sip_add_date_header(pjsip_tx_data *tdata);
1318
1319/*!
1320 * \brief Register a SIP service in Asterisk.
1321 *
1322 * This is more-or-less a wrapper around pjsip_endpt_register_module().
1323 * Registering a service makes it so that PJSIP will call into the
1324 * service at appropriate times. For more information about PJSIP module
1325 * callbacks, see the PJSIP documentation. Asterisk modules that call
1326 * this function will likely do so at module load time.
1327 *
1328 * \param module The module that is to be registered with PJSIP
1329 * \retval 0 Success
1330 * \retval -1 Failure
1331 */
1332int ast_sip_register_service(pjsip_module *module);
1333
1334/*!
1335 * This is the opposite of ast_sip_register_service(). Unregistering a
1336 * service means that PJSIP will no longer call into the module any more.
1337 * This will likely occur when an Asterisk module is unloaded.
1338 *
1339 * \param module The PJSIP module to unregister
1340 */
1341void ast_sip_unregister_service(pjsip_module *module);
1342
1343/*!
1344 * \brief Register a SIP authenticator
1345 *
1346 * An authenticator has three main purposes:
1347 * 1) Determining if authentication should be performed on an incoming request
1348 * 2) Gathering credentials necessary for issuing an authentication challenge
1349 * 3) Authenticating a request that has credentials
1350 *
1351 * Asterisk provides a default authenticator, but it may be replaced by a
1352 * custom one if desired.
1353 *
1354 * \param auth The authenticator to register
1355 * \retval 0 Success
1356 * \retval -1 Failure
1357 */
1359
1360/*!
1361 * \brief Unregister a SIP authenticator
1362 *
1363 * When there is no authenticator registered, requests cannot be challenged
1364 * or authenticated.
1365 *
1366 * \param auth The authenticator to unregister
1367 */
1369
1370 /*!
1371 * \brief Register an outbound SIP authenticator
1372 *
1373 * An outbound authenticator is responsible for creating responses to
1374 * authentication challenges by remote endpoints.
1375 *
1376 * \param outbound_auth The authenticator to register
1377 * \retval 0 Success
1378 * \retval -1 Failure
1379 */
1381
1382/*!
1383 * \brief Unregister an outbound SIP authenticator
1384 *
1385 * When there is no outbound authenticator registered, authentication challenges
1386 * will be handled as any other final response would be.
1387 *
1388 * \param auth The authenticator to unregister
1389 */
1391
1392/*!
1393 * \brief Register a SIP endpoint identifier with a name.
1394 *
1395 * An endpoint identifier's purpose is to determine which endpoint a given SIP
1396 * message has come from.
1397 *
1398 * Multiple endpoint identifiers may be registered so that if an endpoint
1399 * cannot be identified by one identifier, it may be identified by another.
1400 *
1401 * \param identifier The SIP endpoint identifier to register
1402 * \param name The name of the endpoint identifier
1403 * \retval 0 Success
1404 * \retval -1 Failure
1405 */
1407 const char *name);
1408
1409/*!
1410 * \brief Register a SIP endpoint identifier
1411 *
1412 * An endpoint identifier's purpose is to determine which endpoint a given SIP
1413 * message has come from.
1414 *
1415 * Multiple endpoint identifiers may be registered so that if an endpoint
1416 * cannot be identified by one identifier, it may be identified by another.
1417 *
1418 * Asterisk provides two endpoint identifiers. One identifies endpoints based
1419 * on the user part of the From header URI. The other identifies endpoints based
1420 * on the source IP address.
1421 *
1422 * If the order in which endpoint identifiers is run is important to you, then
1423 * be sure to load individual endpoint identifier modules in the order you wish
1424 * for them to be run in modules.conf
1425 *
1426 * \note endpoint identifiers registered using this method (no name specified)
1427 * are placed at the front of the endpoint identifiers list ahead of any
1428 * named identifiers.
1429 *
1430 * \param identifier The SIP endpoint identifier to register
1431 * \retval 0 Success
1432 * \retval -1 Failure
1433 */
1435
1436/*!
1437 * \brief Unregister a SIP endpoint identifier
1438 *
1439 * This stops an endpoint identifier from being used.
1440 *
1441 * \param identifier The SIP endoint identifier to unregister
1442 */
1444
1445/*!
1446 * \brief Allocate a new SIP endpoint
1447 *
1448 * This will return an endpoint with its refcount increased by one. This reference
1449 * can be released using ao2_ref().
1450 *
1451 * \param name The name of the endpoint.
1452 * \retval NULL Endpoint allocation failed
1453 * \retval non-NULL The newly allocated endpoint
1454 */
1455void *ast_sip_endpoint_alloc(const char *name);
1456
1457/*!
1458 * \brief Change state of a persistent endpoint.
1459 *
1460 * \param endpoint_name The SIP endpoint name to change state.
1461 * \param state The new state
1462 * \retval 0 Success
1463 * \retval -1 Endpoint not found
1464 */
1465int ast_sip_persistent_endpoint_update_state(const char *endpoint_name, enum ast_endpoint_state state);
1466
1467/*!
1468 * \brief Publish the change of state for a contact.
1469 *
1470 * \param endpoint_name The SIP endpoint name.
1471 * \param contact_status The contact status.
1472 */
1473void ast_sip_persistent_endpoint_publish_contact_state(const char *endpoint_name, const struct ast_sip_contact_status *contact_status);
1474
1475/*!
1476 * \brief Retrieve the current status for a contact.
1477 *
1478 * \param contact The contact.
1479 *
1480 * \retval non-NULL Success
1481 * \retval NULL Status information not found
1482 *
1483 * \note The returned contact status object is immutable.
1484 */
1486
1487/*!
1488 * \brief Get a pointer to the PJSIP endpoint.
1489 *
1490 * This is useful when modules have specific information they need
1491 * to register with the PJSIP core.
1492 * \retval NULL endpoint has not been created yet.
1493 * \retval non-NULL PJSIP endpoint.
1494 */
1495pjsip_endpoint *ast_sip_get_pjsip_endpoint(void);
1496
1497/*!
1498 * \brief Get a pointer to the SIP sorcery structure.
1499 *
1500 * \retval NULL sorcery has not been initialized
1501 * \retval non-NULL sorcery structure
1502 */
1503struct ast_sorcery *ast_sip_get_sorcery(void);
1504
1505/*!
1506 * \brief Retrieve a named AOR
1507 *
1508 * \param aor_name Name of the AOR
1509 *
1510 * \retval NULL if not found
1511 * \retval non-NULL if found
1512 */
1513struct ast_sip_aor *ast_sip_location_retrieve_aor(const char *aor_name);
1514
1515/*!
1516 * \brief Retrieve the first bound contact for an AOR
1517 *
1518 * \param aor Pointer to the AOR
1519 * \retval NULL if no contacts available
1520 * \retval non-NULL if contacts available
1521 */
1523
1524/*!
1525 * \brief Retrieve the first bound contact for an AOR and filter based on flags
1526 * \since 13.16.0
1527 *
1528 * \param aor Pointer to the AOR
1529 * \param flags Filtering flags
1530 * \retval NULL if no contacts available
1531 * \retval non-NULL if contacts available
1532 */
1534 unsigned int flags);
1535
1536/*!
1537 * \brief Retrieve all contacts currently available for an AOR
1538 *
1539 * \param aor Pointer to the AOR
1540 *
1541 * \retval NULL if no contacts available
1542 * \retval non-NULL if contacts available
1543 *
1544 * \warning
1545 * Since this function prunes expired contacts before returning, it holds a named write
1546 * lock on the aor. If you already hold the lock, call ast_sip_location_retrieve_aor_contacts_nolock instead.
1547 */
1549
1550/*!
1551 * \brief Retrieve all contacts currently available for an AOR and filter based on flags
1552 * \since 13.16.0
1553 *
1554 * \param aor Pointer to the AOR
1555 * \param flags Filtering flags
1556 *
1557 * \retval NULL if no contacts available
1558 * \retval non-NULL if contacts available
1559 *
1560 * \warning
1561 * Since this function prunes expired contacts before returning, it holds a named write
1562 * lock on the aor. If you already hold the lock, call ast_sip_location_retrieve_aor_contacts_nolock instead.
1563 */
1565 unsigned int flags);
1566
1567/*!
1568 * \brief Retrieve all contacts currently available for an AOR without locking the AOR
1569 * \since 13.9.0
1570 *
1571 * \param aor Pointer to the AOR
1572 *
1573 * \retval NULL if no contacts available
1574 * \retval non-NULL if contacts available
1575 *
1576 * \warning
1577 * This function should only be called if you already hold a named write lock on the aor.
1578 */
1580
1581/*!
1582 * \brief Retrieve all contacts currently available for an AOR without locking the AOR and filter based on flags
1583 * \since 13.16.0
1584 *
1585 * \param aor Pointer to the AOR
1586 * \param flags Filtering flags
1587 *
1588 * \retval NULL if no contacts available
1589 * \retval non-NULL if contacts available
1590 *
1591 * \warning
1592 * This function should only be called if you already hold a named write lock on the aor.
1593 */
1595 unsigned int flags);
1596
1597/*!
1598 * \brief Retrieve the first bound contact from a list of AORs
1599 *
1600 * \param aor_list A comma-separated list of AOR names
1601 * \retval NULL if no contacts available
1602 * \retval non-NULL if contacts available
1603 */
1605
1606/*!
1607 * \brief Retrieve all contacts from a list of AORs
1608 *
1609 * \param aor_list A comma-separated list of AOR names
1610 * \retval NULL if no contacts available
1611 * \retval non-NULL container (which must be freed) if contacts available
1612 */
1614
1615/*!
1616 * \brief Retrieve the first bound contact AND the AOR chosen from a list of AORs
1617 *
1618 * \param aor_list A comma-separated list of AOR names
1619 * \param aor The chosen AOR
1620 * \param contact The chosen contact
1621 */
1622 void ast_sip_location_retrieve_contact_and_aor_from_list(const char *aor_list, struct ast_sip_aor **aor,
1623 struct ast_sip_contact **contact);
1624
1625/*!
1626 * \brief Retrieve the first bound contact AND the AOR chosen from a list of AORs and filter based on flags
1627 * \since 13.16.0
1628 *
1629 * \param aor_list A comma-separated list of AOR names
1630 * \param flags Filtering flags
1631 * \param aor The chosen AOR
1632 * \param contact The chosen contact
1633 */
1634void ast_sip_location_retrieve_contact_and_aor_from_list_filtered(const char *aor_list, unsigned int flags,
1635 struct ast_sip_aor **aor, struct ast_sip_contact **contact);
1636
1637/*!
1638 * \brief Retrieve a named contact
1639 *
1640 * \param contact_name Name of the contact
1641 *
1642 * \retval NULL if not found
1643 * \retval non-NULL if found
1644 */
1645struct ast_sip_contact *ast_sip_location_retrieve_contact(const char *contact_name);
1646
1647/*!
1648 * \brief Add a new contact to an AOR
1649 *
1650 * \param aor Pointer to the AOR
1651 * \param uri Full contact URI
1652 * \param expiration_time Optional expiration time of the contact
1653 * \param path_info Path information
1654 * \param user_agent User-Agent header from REGISTER request
1655 * \param via_addr
1656 * \param via_port
1657 * \param call_id
1658 * \param endpoint The endpoint that resulted in the contact being added
1659 *
1660 * \retval -1 failure
1661 * \retval 0 success
1662 *
1663 * \warning
1664 * This function holds a named write lock on the aor. If you already hold the lock
1665 * you should call ast_sip_location_add_contact_nolock instead.
1666 */
1667int ast_sip_location_add_contact(struct ast_sip_aor *aor, const char *uri,
1668 struct timeval expiration_time, const char *path_info, const char *user_agent,
1669 const char *via_addr, int via_port, const char *call_id,
1670 struct ast_sip_endpoint *endpoint);
1671
1672/*!
1673 * \brief Add a new contact to an AOR without locking the AOR
1674 * \since 13.9.0
1675 *
1676 * \param aor Pointer to the AOR
1677 * \param uri Full contact URI
1678 * \param expiration_time Optional expiration time of the contact
1679 * \param path_info Path information
1680 * \param user_agent User-Agent header from REGISTER request
1681 * \param via_addr
1682 * \param via_port
1683 * \param call_id
1684 * \param endpoint The endpoint that resulted in the contact being added
1685 *
1686 * \retval -1 failure
1687 * \retval 0 success
1688 *
1689 * \warning
1690 * This function should only be called if you already hold a named write lock on the aor.
1691 */
1693 struct timeval expiration_time, const char *path_info, const char *user_agent,
1694 const char *via_addr, int via_port, const char *call_id,
1695 struct ast_sip_endpoint *endpoint);
1696
1697/*!
1698 * \brief Create a new contact for an AOR without locking the AOR
1699 * \since 13.18.0
1700 *
1701 * \param aor Pointer to the AOR
1702 * \param uri Full contact URI
1703 * \param expiration_time Optional expiration time of the contact
1704 * \param path_info Path information
1705 * \param user_agent User-Agent header from REGISTER request
1706 * \param via_addr
1707 * \param via_port
1708 * \param call_id
1709 * \param prune_on_boot Non-zero if the contact cannot survive a restart/boot.
1710 * \param endpoint The endpoint that resulted in the contact being added
1711 *
1712 * \return The created contact or NULL on failure.
1713 *
1714 * \warning
1715 * This function should only be called if you already hold a named write lock on the aor.
1716 */
1718 const char *uri, struct timeval expiration_time, const char *path_info,
1719 const char *user_agent, const char *via_addr, int via_port, const char *call_id,
1721
1722/*!
1723 * \brief Update a contact
1724 *
1725 * \param contact New contact object with details
1726 *
1727 * \retval -1 failure
1728 * \retval 0 success
1729 */
1731
1732/*!
1733* \brief Delete a contact
1734*
1735* \param contact Contact object to delete
1736*
1737* \retval -1 failure
1738* \retval 0 success
1739*/
1741
1742/*!
1743 * \brief Prune the prune_on_boot contacts
1744 * \since 13.18.0
1745 */
1747
1748/*!
1749 * \brief Callback called when an outbound request with authentication credentials is to be sent in dialog
1750 *
1751 * This callback will have the created request on it. The callback's purpose is to do any extra
1752 * housekeeping that needs to be done as well as to send the request out.
1753 *
1754 * This callback is only necessary if working with a PJSIP API that sits between the application
1755 * and the dialog layer.
1756 *
1757 * \param dlg The dialog to which the request belongs
1758 * \param tdata The created request to be sent out
1759 * \param user_data Data supplied with the callback
1760 *
1761 * \retval 0 Success
1762 * \retval -1 Failure
1763 */
1764typedef int (*ast_sip_dialog_outbound_auth_cb)(pjsip_dialog *dlg, pjsip_tx_data *tdata, void *user_data);
1765
1766/*!
1767 * \brief Set up outbound authentication on a SIP dialog
1768 *
1769 * This sets up the infrastructure so that all requests associated with a created dialog
1770 * can be re-sent with authentication credentials if the original request is challenged.
1771 *
1772 * \param dlg The dialog on which requests will be authenticated
1773 * \param endpoint The endpoint whom this dialog pertains to
1774 * \param cb Callback to call to send requests with authentication
1775 * \param user_data Data to be provided to the callback when it is called
1776 *
1777 * \retval 0 Success
1778 * \retval -1 Failure
1779 */
1781 ast_sip_dialog_outbound_auth_cb cb, void *user_data);
1782
1783/*!
1784 * \brief Retrieves a reference to the artificial auth.
1785 *
1786 * \retval The artificial auth
1787 */
1789
1790/*!
1791 * \brief Retrieves a reference to the artificial endpoint.
1792 *
1793 * \retval The artificial endpoint
1794 */
1796
1797/*! \defgroup pjsip_threading PJSIP Threading Model
1798 * @{
1799 * \page PJSIP PJSIP Threading Model
1800 *
1801 * There are three major types of threads that SIP will have to deal with:
1802 * \li Asterisk threads
1803 * \li PJSIP threads
1804 * \li SIP threadpool threads (a.k.a. "servants")
1805 *
1806 * \par Asterisk Threads
1807 *
1808 * Asterisk threads are those that originate from outside of SIP but within
1809 * Asterisk. The most common of these threads are PBX (channel) threads and
1810 * the autoservice thread. Most interaction with these threads will be through
1811 * channel technology callbacks. Within these threads, it is fine to handle
1812 * Asterisk data from outside of SIP, but any handling of SIP data should be
1813 * left to servants, \b especially if you wish to call into PJSIP for anything.
1814 * Asterisk threads are not registered with PJLIB, so attempting to call into
1815 * PJSIP will cause an assertion to be triggered, thus causing the program to
1816 * crash.
1817 *
1818 * \par PJSIP Threads
1819 *
1820 * PJSIP threads are those that originate from handling of PJSIP events, such
1821 * as an incoming SIP request or response, or a transaction timeout. The role
1822 * of these threads is to process information as quickly as possible so that
1823 * the next item on the SIP socket(s) can be serviced. On incoming messages,
1824 * Asterisk automatically will push the request to a servant thread. When your
1825 * module callback is called, processing will already be in a servant. However,
1826 * for other PJSIP events, such as transaction state changes due to timer
1827 * expirations, your module will be called into from a PJSIP thread. If you
1828 * are called into from a PJSIP thread, then you should push whatever processing
1829 * is needed to a servant as soon as possible. You can discern if you are currently
1830 * in a SIP servant thread using the \ref ast_sip_thread_is_servant function.
1831 *
1832 * \par Servants
1833 *
1834 * Servants are where the bulk of SIP work should be performed. These threads
1835 * exist in order to do the work that Asterisk threads and PJSIP threads hand
1836 * off to them. Servant threads register themselves with PJLIB, meaning that
1837 * they are capable of calling PJSIP and PJLIB functions if they wish.
1838 *
1839 * \par Serializer
1840 *
1841 * Tasks are handed off to servant threads using the API call \ref ast_sip_push_task.
1842 * The first parameter of this call is a serializer. If this pointer
1843 * is NULL, then the work will be handed off to whatever servant can currently handle
1844 * the task. If this pointer is non-NULL, then the task will not be executed until
1845 * previous tasks pushed with the same serializer have completed. For more information
1846 * on serializers and the benefits they provide, see \ref ast_threadpool_serializer
1847 *
1848 * \par Scheduler
1849 *
1850 * Some situations require that a task run periodically or at a future time. Normally
1851 * the ast_sched functionality would be used but ast_sched only uses 1 thread for all
1852 * tasks and that thread isn't registered with PJLIB and therefore can't do any PJSIP
1853 * related work.
1854 *
1855 * ast_sip_sched uses ast_sched only as a scheduled queue. When a task is ready to run,
1856 * it's pushed to a Serializer to be invoked asynchronously by a Servant. This ensures
1857 * that the task is executed in a PJLIB registered thread and allows the ast_sched thread
1858 * to immediately continue processing the queue. The Serializer used by ast_sip_sched
1859 * is one of your choosing or a random one from the res_pjsip pool if you don't choose one.
1860 *
1861 * \note
1862 *
1863 * Do not make assumptions about individual threads based on a corresponding serializer.
1864 * In other words, just because several tasks use the same serializer when being pushed
1865 * to servants, it does not mean that the same thread is necessarily going to execute those
1866 * tasks, even though they are all guaranteed to be executed in sequence.
1867 */
1868
1869typedef int (*ast_sip_task)(void *user_data);
1870
1871/*!
1872 * \brief Create a new serializer for SIP tasks
1873 * \since 13.8.0
1874 *
1875 * See \ref ast_threadpool_serializer for more information on serializers.
1876 * SIP creates serializers so that tasks operating on similar data will run
1877 * in sequence.
1878 *
1879 * \param name Name of the serializer. (must be unique)
1880 *
1881 * \retval NULL Failure
1882 * \retval non-NULL Newly-created serializer
1883 */
1885
1887
1888/*!
1889 * \brief Create a new serializer for SIP tasks
1890 * \since 13.8.0
1891 *
1892 * See \ref ast_threadpool_serializer for more information on serializers.
1893 * SIP creates serializers so that tasks operating on similar data will run
1894 * in sequence.
1895 *
1896 * \param name Name of the serializer. (must be unique)
1897 * \param shutdown_group Group shutdown controller. (NULL if no group association)
1898 *
1899 * \retval NULL Failure
1900 * \retval non-NULL Newly-created serializer
1901 */
1903
1904/*!
1905 * \brief Determine the distributor serializer for the SIP message.
1906 * \since 13.10.0
1907 *
1908 * \param rdata The incoming message.
1909 *
1910 * \retval Calculated distributor serializer on success.
1911 * \retval NULL on error.
1912 */
1913struct ast_taskprocessor *ast_sip_get_distributor_serializer(pjsip_rx_data *rdata);
1914
1915/*!
1916 * \brief Set a serializer on a SIP dialog so requests and responses are automatically serialized
1917 *
1918 * Passing a NULL serializer is a way to remove a serializer from a dialog.
1919 *
1920 * \param dlg The SIP dialog itself
1921 * \param serializer The serializer to use
1922 */
1923void ast_sip_dialog_set_serializer(pjsip_dialog *dlg, struct ast_taskprocessor *serializer);
1924
1925/*!
1926 * \brief Set an endpoint on a SIP dialog so in-dialog requests do not undergo endpoint lookup.
1927 *
1928 * \param dlg The SIP dialog itself
1929 * \param endpoint The endpoint that this dialog is communicating with
1930 */
1931void ast_sip_dialog_set_endpoint(pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint);
1932
1933/*!
1934 * \brief Get the endpoint associated with this dialog
1935 *
1936 * This function increases the refcount of the endpoint by one. Release
1937 * the reference once you are finished with the endpoint.
1938 *
1939 * \param dlg The SIP dialog from which to retrieve the endpoint
1940 * \retval NULL No endpoint associated with this dialog
1941 * \retval non-NULL The endpoint.
1942 */
1943struct ast_sip_endpoint *ast_sip_dialog_get_endpoint(pjsip_dialog *dlg);
1944
1945/*!
1946 * \brief Pushes a task to SIP servants
1947 *
1948 * This uses the serializer provided to determine how to push the task.
1949 * If the serializer is NULL, then the task will be pushed to the
1950 * servants directly. If the serializer is non-NULL, then the task will be
1951 * queued behind other tasks associated with the same serializer.
1952 *
1953 * \param serializer The serializer to which the task belongs. Can be NULL
1954 * \param sip_task The task to execute
1955 * \param task_data The parameter to pass to the task when it executes
1956 * \retval 0 Success
1957 * \retval -1 Failure
1958 */
1959int ast_sip_push_task(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data);
1960
1961/*!
1962 * \brief Push a task to SIP servants and wait for it to complete.
1963 *
1964 * Like \ref ast_sip_push_task except that it blocks until the task
1965 * completes. If the current thread is a SIP servant thread then the
1966 * task executes immediately. Otherwise, the specified serializer
1967 * executes the task and the current thread waits for it to complete.
1968 *
1969 * \note PJPROJECT callbacks tend to have locks already held when
1970 * called.
1971 *
1972 * \warning \b Never hold locks that may be acquired by a SIP servant
1973 * thread when calling this function. Doing so may cause a deadlock
1974 * if all SIP servant threads are blocked waiting to acquire the lock
1975 * while the thread holding the lock is waiting for a free SIP servant
1976 * thread.
1977 *
1978 * \warning \b Use of this function in an ao2 destructor callback is a
1979 * bad idea. You don't have control over which thread executes the
1980 * destructor. Attempting to shift execution to another thread with
1981 * this function is likely to cause deadlock.
1982 *
1983 * \param serializer The SIP serializer to execute the task if the
1984 * current thread is not a SIP servant. NULL if any of the default
1985 * serializers can be used.
1986 * \param sip_task The task to execute
1987 * \param task_data The parameter to pass to the task when it executes
1988 *
1989 * \note The sip_task() return value may need to be distinguished from
1990 * the failure to push the task.
1991 *
1992 * \return sip_task() return value on success.
1993 * \retval -1 Failure to push the task.
1994 */
1995int ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data);
1996
1997/*!
1998 * \brief Push a task to SIP servants and wait for it to complete.
1999 * \deprecated Replaced with ast_sip_push_task_wait_servant().
2000 */
2001int ast_sip_push_task_synchronous(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data);
2002
2003/*!
2004 * \brief Push a task to the serializer and wait for it to complete.
2005 *
2006 * Like \ref ast_sip_push_task except that it blocks until the task is
2007 * completed by the specified serializer. If the specified serializer
2008 * is the current thread then the task executes immediately.
2009 *
2010 * \note PJPROJECT callbacks tend to have locks already held when
2011 * called.
2012 *
2013 * \warning \b Never hold locks that may be acquired by a SIP servant
2014 * thread when calling this function. Doing so may cause a deadlock
2015 * if all SIP servant threads are blocked waiting to acquire the lock
2016 * while the thread holding the lock is waiting for a free SIP servant
2017 * thread for the serializer to execute in.
2018 *
2019 * \warning \b Never hold locks that may be acquired by the serializer
2020 * when calling this function. Doing so will cause a deadlock.
2021 *
2022 * \warning \b Never use this function in the pjsip monitor thread (It
2023 * is a SIP servant thread). This is likely to cause a deadlock.
2024 *
2025 * \warning \b Use of this function in an ao2 destructor callback is a
2026 * bad idea. You don't have control over which thread executes the
2027 * destructor. Attempting to shift execution to another thread with
2028 * this function is likely to cause deadlock.
2029 *
2030 * \param serializer The SIP serializer to execute the task. NULL if
2031 * any of the default serializers can be used.
2032 * \param sip_task The task to execute
2033 * \param task_data The parameter to pass to the task when it executes
2034 *
2035 * \note It is generally better to call
2036 * ast_sip_push_task_wait_servant() if you pass NULL for the
2037 * serializer parameter.
2038 *
2039 * \note The sip_task() return value may need to be distinguished from
2040 * the failure to push the task.
2041 *
2042 * \return sip_task() return value on success.
2043 * \retval -1 Failure to push the task.
2044 */
2045int ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data);
2046
2047/*!
2048 * \brief Determine if the current thread is a SIP servant thread
2049 *
2050 * \retval 0 This is not a SIP servant thread
2051 * \retval 1 This is a SIP servant thread
2052 */
2054
2055/*!
2056 * \brief Task flags for the res_pjsip scheduler
2057 *
2058 * The default is AST_SIP_SCHED_TASK_FIXED
2059 * | AST_SIP_SCHED_TASK_DATA_NOT_AO2
2060 * | AST_SIP_SCHED_TASK_DATA_NO_CLEANUP
2061 * | AST_SIP_SCHED_TASK_PERIODIC
2062 */
2064 /*!
2065 * The defaults
2066 */
2068
2069 /*!
2070 * Run at a fixed interval.
2071 * Stop scheduling if the callback returns <= 0.
2072 * Any other value is ignored.
2073 */
2075 /*!
2076 * Run at a variable interval.
2077 * Stop scheduling if the callback returns <= 0.
2078 * Any other return value is used as the new interval.
2079 */
2081
2082 /*!
2083 * Run just once.
2084 * Return values are ignored.
2085 */
2087
2088 /*!
2089 * The task data is not an AO2 object.
2090 */
2092 /*!
2093 * The task data is an AO2 object.
2094 * A reference count will be held by the scheduler until
2095 * after the task has run for the final time (if ever).
2096 */
2098
2099 /*!
2100 * Don't take any cleanup action on the data
2101 */
2103 /*!
2104 * If AST_SIP_SCHED_TASK_DATA_AO2 is set, decrement the reference count
2105 * otherwise call ast_free on it.
2106 */
2108
2109 /*!
2110 * \brief The task is scheduled at multiples of interval
2111 * \see Interval
2112 */
2114 /*!
2115 * \brief The next invocation of the task is at last finish + interval
2116 * \see Interval
2117 */
2119 /*!
2120 * \brief The scheduled task's events are tracked in the debug log.
2121 * \details
2122 * Schedule events such as scheduling, running, rescheduling, canceling,
2123 * and destroying are logged about the task.
2124 */
2126};
2127
2128/*!
2129 * \brief Scheduler task data structure
2130 */
2131struct ast_sip_sched_task;
2132
2133/*!
2134 * \brief Schedule a task to run in the res_pjsip thread pool
2135 * \since 13.9.0
2136 *
2137 * \param serializer The serializer to use. If NULL, don't use a serializer (see note below)
2138 * \param interval The invocation interval in milliseconds (see note below)
2139 * \param sip_task The task to invoke
2140 * \param name An optional name to associate with the task
2141 * \param task_data Optional data to pass to the task
2142 * \param flags One of enum ast_sip_scheduler_task_type
2143 *
2144 * \returns Pointer to \ref ast_sip_sched_task ao2 object which must be dereferenced when done.
2145 *
2146 * \par Serialization
2147 *
2148 * Specifying a serializer guarantees serialized execution but NOT specifying a serializer
2149 * may still result in tasks being effectively serialized if the thread pool is busy.
2150 * The point of the serializer BTW is not to prevent parallel executions of the SAME task.
2151 * That happens automatically (see below). It's to prevent the task from running at the same
2152 * time as other work using the same serializer, whether or not it's being run by the scheduler.
2153 *
2154 * \par Interval
2155 *
2156 * The interval is used to calculate the next time the task should run. There are two models.
2157 *
2158 * \ref AST_SIP_SCHED_TASK_PERIODIC specifies that the invocations of the task occur at the
2159 * specific interval. That is, every \p interval milliseconds, regardless of how long the task
2160 * takes. If the task takes longer than \p interval, it will be scheduled at the next available
2161 * multiple of \p interval. For example: If the task has an interval of 60 seconds and the task
2162 * takes 70 seconds, the next invocation will happen at 120 seconds.
2163 *
2164 * \ref AST_SIP_SCHED_TASK_DELAY specifies that the next invocation of the task should start
2165 * at \p interval milliseconds after the current invocation has finished.
2166 *
2167 */
2169 int interval, ast_sip_task sip_task, const char *name, void *task_data,
2171
2172/*!
2173 * \brief Cancels the next invocation of a task
2174 * \since 13.9.0
2175 *
2176 * \param schtd The task structure pointer
2177 * \retval 0 Success
2178 * \retval -1 Failure
2179 * \note Only cancels future invocations not the currently running invocation.
2180 */
2182
2183/*!
2184 * \brief Cancels the next invocation of a task by name
2185 * \since 13.9.0
2186 *
2187 * \param name The task name
2188 * \retval 0 Success
2189 * \retval -1 Failure
2190 * \note Only cancels future invocations not the currently running invocation.
2191 */
2193
2194/*!
2195 * \brief Gets the last start and end times of the task
2196 * \since 13.9.0
2197 *
2198 * \param schtd The task structure pointer
2199 * \param[out] when_queued Pointer to a timeval structure to contain the time when queued
2200 * \param[out] last_start Pointer to a timeval structure to contain the time when last started
2201 * \param[out] last_end Pointer to a timeval structure to contain the time when last ended
2202 * \retval 0 Success
2203 * \retval -1 Failure
2204 * \note Any of the pointers can be NULL if you don't need them.
2205 */
2207 struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end);
2208
2209/*!
2210 * \brief Gets the queued, last start, last_end, time left, interval, next run
2211 * \since 16.15.0
2212 * \since 18.1.0
2213 *
2214 * \param schtd The task structure pointer
2215 * \param[out] when_queued Pointer to a timeval structure to contain the time when queued
2216 * \param[out] last_start Pointer to a timeval structure to contain the time when last started
2217 * \param[out] last_end Pointer to a timeval structure to contain the time when last ended
2218 * \param[out] interval Pointer to an int to contain the interval in ms
2219 * \param[out] time_left Pointer to an int to contain the ms left to the next run
2220 * \param[out] next_start Pointer to a timeval structure to contain the next run time
2221 * \retval 0 Success
2222 * \retval -1 Failure
2223 * \note Any of the pointers can be NULL if you don't need them.
2224 */
2226 struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end,
2227 int *interval, int *time_left, struct timeval *next_start);
2228
2229/*!
2230 * \brief Gets the last start and end times of the task by name
2231 * \since 13.9.0
2232 *
2233 * \param name The task name
2234 * \param[out] when_queued Pointer to a timeval structure to contain the time when queued
2235 * \param[out] last_start Pointer to a timeval structure to contain the time when last started
2236 * \param[out] last_end Pointer to a timeval structure to contain the time when last ended
2237 * \retval 0 Success
2238 * \retval -1 Failure
2239 * \note Any of the pointers can be NULL if you don't need them.
2240 */
2242 struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end);
2243
2244/*!
2245 * \brief Gets the queued, last start, last_end, time left, interval, next run by task name
2246 * \since 16.15.0
2247 * \since 18.1.0
2248 *
2249 * \param name The task name
2250 * \param[out] when_queued Pointer to a timeval structure to contain the time when queued
2251 * \param[out] last_start Pointer to a timeval structure to contain the time when last started
2252 * \param[out] last_end Pointer to a timeval structure to contain the time when last ended
2253 * \param[out] interval Pointer to an int to contain the interval in ms
2254 * \param[out] time_left Pointer to an int to contain the ms left to the next run
2255 * \param[out] next_start Pointer to a timeval structure to contain the next run time
2256 * \retval 0 Success
2257 * \retval -1 Failure
2258 * \note Any of the pointers can be NULL if you don't need them.
2259 */
2261 struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end,
2262 int *interval, int *time_left, struct timeval *next_start);
2263
2264/*!
2265 * \brief Gets the number of milliseconds until the next invocation
2266 * \since 13.9.0
2267 *
2268 * \param schtd The task structure pointer
2269 * \return The number of milliseconds until the next invocation or -1 if the task isn't scheduled
2270 */
2272
2273/*!
2274 * \brief Gets the number of milliseconds until the next invocation
2275 * \since 13.9.0
2276 *
2277 * \param name The task name
2278 * \return The number of milliseconds until the next invocation or -1 if the task isn't scheduled
2279 */
2281
2282/*!
2283 * \brief Checks if the task is currently running
2284 * \since 13.9.0
2285 *
2286 * \param schtd The task structure pointer
2287 * \retval 0 not running
2288 * \retval 1 running
2289 */
2291
2292/*!
2293 * \brief Checks if the task is currently running
2294 * \since 13.9.0
2295 *
2296 * \param name The task name
2297 * \retval 0 not running or not found
2298 * \retval 1 running
2299 */
2301
2302/*!
2303 * \brief Gets the task name
2304 * \since 13.9.0
2305 *
2306 * \param schtd The task structure pointer
2307 * \param name, maxlen
2308 * \retval 0 success
2309 * \retval 1 failure
2310 */
2311int ast_sip_sched_task_get_name(struct ast_sip_sched_task *schtd, char *name, size_t maxlen);
2312
2313/*!
2314 * @}
2315 */
2316
2317/*!
2318 * \brief SIP body description
2319 *
2320 * This contains a type and subtype that will be added as
2321 * the "Content-Type" for the message as well as the body
2322 * text.
2323 */
2325 /*! Type of the body, such as "application" */
2326 const char *type;
2327 /*! Subtype of the body, such as "sdp" */
2328 const char *subtype;
2329 /*! The text to go in the body */
2330 const char *body_text;
2331};
2332
2333/*!
2334 * \brief General purpose method for creating a UAC dialog with an endpoint
2335 *
2336 * \param endpoint A pointer to the endpoint
2337 * \param aor_name Optional name of the AOR to target, may even be an explicit SIP URI
2338 * \param request_user Optional user to place into the target URI
2339 *
2340 * \retval non-NULL success
2341 * \retval NULL failure
2342 */
2343pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *aor_name, const char *request_user);
2344
2345/*!
2346 * \brief General purpose method for creating a UAS dialog with an endpoint
2347 *
2348 * \deprecated This function is unsafe (due to the returned object not being locked nor
2349 * having its reference incremented) and should no longer be used. Instead
2350 * use ast_sip_create_dialog_uas_locked so a properly locked and referenced
2351 * object is returned.
2352 *
2353 * \param endpoint A pointer to the endpoint
2354 * \param rdata The request that is starting the dialog
2355 * \param[out] status On failure, the reason for failure in creating the dialog
2356 */
2357pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status);
2358
2359/*!
2360 * \brief General purpose method for creating a UAS dialog with an endpoint
2361 *
2362 * This function creates and returns a locked, and referenced counted pjsip
2363 * dialog object. The caller is thus responsible for freeing the allocated
2364 * memory, decrementing the reference, and releasing the lock when done with
2365 * the returned object.
2366 *
2367 * \note The safest way to unlock the object, and decrement its reference is by
2368 * calling pjsip_dlg_dec_lock. Alternatively, pjsip_dlg_dec_session can be
2369 * used to decrement the reference only.
2370 *
2371 * The dialog is returned locked and with a reference in order to ensure that the
2372 * dialog object, and any of its associated objects (e.g. transaction) are not
2373 * untimely destroyed. For instance, that could happen when a transport error
2374 * occurs.
2375 *
2376 * As long as the caller maintains a reference to the dialog there should be no
2377 * worry that it might unknowingly be destroyed. However, once the caller unlocks
2378 * the dialog there is a danger that some of the dialog's internal objects could
2379 * be lost and/or compromised. For example, when the aforementioned transport error
2380 * occurs the dialog's associated transaction gets destroyed (see pjsip_dlg_on_tsx_state
2381 * in sip_dialog.c, and mod_inv_on_tsx_state in sip_inv.c).
2382 *
2383 * In this case and before using the dialog again the caller should re-lock the
2384 * dialog, check to make sure the dialog is still established, and the transaction
2385 * still exists and has not been destroyed.
2386 *
2387 * \param endpoint A pointer to the endpoint
2388 * \param rdata The request that is starting the dialog
2389 * \param[out] status On failure, the reason for failure in creating the dialog
2390 *
2391 * \retval A locked, and reference counted pjsip_dialog object.
2392 * \retval NULL on failure
2393 */
2394pjsip_dialog *ast_sip_create_dialog_uas_locked(const struct ast_sip_endpoint *endpoint,
2395 pjsip_rx_data *rdata, pj_status_t *status);
2396
2397/*!
2398 * \brief General purpose method for creating an rdata structure using specific information
2399 * \since 13.15.0
2400 *
2401 * \param[out] rdata The rdata structure that will be populated
2402 * \param packet A SIP message
2403 * \param src_name The source IP address of the message
2404 * \param src_port The source port of the message
2405 * \param transport_type The type of transport the message was received on
2406 * \param local_name The local IP address the message was received on
2407 * \param local_port The local port the message was received on
2408 * \param contact_uri The contact URI of the message
2409 *
2410 * \retval 0 success
2411 * \retval -1 failure
2412 */
2413int ast_sip_create_rdata_with_contact(pjsip_rx_data *rdata, char *packet,
2414 const char *src_name, int src_port, char *transport_type, const char *local_name,
2415 int local_port, const char *contact_uri);
2416
2417/*!
2418 * \brief General purpose method for creating an rdata structure using specific information
2419 *
2420 * \param[out] rdata The rdata structure that will be populated
2421 * \param packet A SIP message
2422 * \param src_name The source IP address of the message
2423 * \param src_port The source port of the message
2424 * \param transport_type The type of transport the message was received on
2425 * \param local_name The local IP address the message was received on
2426 * \param local_port The local port the message was received on
2427 *
2428 * \retval 0 success
2429 * \retval -1 failure
2430 */
2431int ast_sip_create_rdata(pjsip_rx_data *rdata, char *packet, const char *src_name,
2432 int src_port, char *transport_type, const char *local_name, int local_port);
2433
2434/*!
2435 * \brief General purpose method for creating a SIP request
2436 *
2437 * Its typical use would be to create one-off requests such as an out of dialog
2438 * SIP MESSAGE.
2439 *
2440 * The request can either be in- or out-of-dialog. If in-dialog, the
2441 * dlg parameter MUST be present. If out-of-dialog the endpoint parameter
2442 * MUST be present. If both are present, then we will assume that the message
2443 * is to be sent in-dialog.
2444 *
2445 * The uri parameter can be specified if the request should be sent to an explicit
2446 * URI rather than one configured on the endpoint.
2447 *
2448 * \param method The method of the SIP request to send
2449 * \param dlg Optional. If specified, the dialog on which to request the message.
2450 * \param endpoint Optional. If specified, the request will be created out-of-dialog to the endpoint.
2451 * \param uri Optional. If specified, the request will be sent to this URI rather
2452 * than one configured for the endpoint.
2453 * \param contact The contact with which this request is associated for out-of-dialog requests.
2454 * \param[out] tdata The newly-created request
2455 *
2456 * The provided contact is attached to tdata with its reference bumped, but will
2457 * not survive for the entire lifetime of tdata since the contact is cleaned up
2458 * when all supplements have completed execution.
2459 *
2460 * \retval 0 Success
2461 * \retval -1 Failure
2462 */
2463int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg,
2464 struct ast_sip_endpoint *endpoint, const char *uri,
2465 struct ast_sip_contact *contact, pjsip_tx_data **tdata);
2466
2467/*!
2468 * \brief General purpose method for sending a SIP request
2469 *
2470 * This is a companion function for \ref ast_sip_create_request. The request
2471 * created there can be passed to this function, though any request may be
2472 * passed in.
2473 *
2474 * This will automatically set up handling outbound authentication challenges if
2475 * they arrive.
2476 *
2477 * \param tdata The request to send
2478 * \param dlg Optional. The dialog in which the request is sent. Otherwise it is out-of-dialog.
2479 * \param endpoint Optional. If specified, the out-of-dialog request is sent to the endpoint.
2480 * \param token Data to be passed to the callback upon receipt of out-of-dialog response.
2481 * \param callback Callback to be called upon receipt of out-of-dialog response.
2482 *
2483 * \retval 0 Success
2484 * \retval -1 Failure (out-of-dialog callback will not be called.)
2485 */
2486int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg,
2487 struct ast_sip_endpoint *endpoint, void *token,
2488 void (*callback)(void *token, pjsip_event *e));
2489
2490/*!
2491 * \brief General purpose method for sending an Out-Of-Dialog SIP request
2492 *
2493 * This is a companion function for \ref ast_sip_create_request. The request
2494 * created there can be passed to this function, though any request may be
2495 * passed in.
2496 *
2497 * This will automatically set up handling outbound authentication challenges if
2498 * they arrive.
2499 *
2500 * \param tdata The request to send
2501 * \param endpoint Optional. If specified, the out-of-dialog request is sent to the endpoint.
2502 * \param timeout If non-zero, after the timeout the transaction will be terminated
2503 * and the callback will be called with the PJSIP_EVENT_TIMER type.
2504 * \param token Data to be passed to the callback upon receipt of out-of-dialog response.
2505 * \param callback Callback to be called upon receipt of out-of-dialog response.
2506 *
2507 * \retval 0 Success
2508 * \retval -1 Failure (out-of-dialog callback will not be called.)
2509 *
2510 * \note Timeout processing:
2511 * There are 2 timers associated with this request, PJSIP timer_b which is
2512 * set globally in the "system" section of pjsip.conf, and the timeout specified
2513 * on this call. The timer that expires first (before normal completion) will
2514 * cause the callback to be run with e->body.tsx_state.type = PJSIP_EVENT_TIMER.
2515 * The timer that expires second is simply ignored and the callback is not run again.
2516 */
2517int ast_sip_send_out_of_dialog_request(pjsip_tx_data *tdata,
2518 struct ast_sip_endpoint *endpoint, int timeout, void *token,
2519 void (*callback)(void *token, pjsip_event *e));
2520
2521/*!
2522 * \brief General purpose method for creating a SIP response
2523 *
2524 * Its typical use would be to create responses for out of dialog
2525 * requests.
2526 *
2527 * \param rdata The rdata from the incoming request.
2528 * \param st_code The response code to transmit.
2529 * \param contact The contact with which this request is associated.
2530 * \param[out] p_tdata The newly-created response
2531 *
2532 * The provided contact is attached to tdata with its reference bumped, but will
2533 * not survive for the entire lifetime of tdata since the contact is cleaned up
2534 * when all supplements have completed execution.
2535 *
2536 * \retval 0 Success
2537 * \retval -1 Failure
2538 */
2539int ast_sip_create_response(const pjsip_rx_data *rdata, int st_code,
2540 struct ast_sip_contact *contact, pjsip_tx_data **p_tdata);
2541
2542/*!
2543 * \brief Send a response to an out of dialog request
2544 *
2545 * Use this function sparingly, since this does not create a transaction
2546 * within PJSIP. This means that if the request is retransmitted, it is
2547 * your responsibility to detect this and not process the same request
2548 * twice, and to send the same response for each retransmission.
2549 *
2550 * \param res_addr The response address for this response
2551 * \param tdata The response to send
2552 * \param sip_endpoint The ast_sip_endpoint associated with this response
2553 *
2554 * \retval 0 Success
2555 * \retval -1 Failure
2556 */
2557int ast_sip_send_response(pjsip_response_addr *res_addr, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint);
2558
2559/*!
2560 * \brief Send a stateful response to an out of dialog request
2561 *
2562 * This creates a transaction within PJSIP, meaning that if the request
2563 * that we are responding to is retransmitted, we will not attempt to
2564 * re-handle the request.
2565 *
2566 * \param rdata The request that is being responded to
2567 * \param tdata The response to send
2568 * \param sip_endpoint The ast_sip_endpoint associated with this response
2569 *
2570 * \since 13.4.0
2571 *
2572 * \retval 0 Success
2573 * \retval -1 Failure
2574 */
2575int ast_sip_send_stateful_response(pjsip_rx_data *rdata, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint);
2576
2577/*!
2578 * \brief Determine if an incoming request requires authentication
2579 *
2580 * This calls into the registered authenticator's requires_authentication callback
2581 * in order to determine if the request requires authentication.
2582 *
2583 * If there is no registered authenticator, then authentication will be assumed
2584 * not to be required.
2585 *
2586 * \param endpoint The endpoint from which the request originates
2587 * \param rdata The incoming SIP request
2588 * \retval non-zero The request requires authentication
2589 * \retval 0 The request does not require authentication
2590 */
2591int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
2592
2593/*!
2594 * \brief Method to determine authentication status of an incoming request
2595 *
2596 * This will call into a registered authenticator. The registered authenticator will
2597 * do what is necessary to determine whether the incoming request passes authentication.
2598 * A tentative response is passed into this function so that if, say, a digest authentication
2599 * challenge should be sent in the ensuing response, it can be added to the response.
2600 *
2601 * \param endpoint The endpoint from the request was sent
2602 * \param rdata The request to potentially authenticate
2603 * \param tdata Tentative response to the request
2604 * \return The result of checking authentication.
2605 */
2607 pjsip_rx_data *rdata, pjsip_tx_data *tdata);
2608
2609/*!
2610 * \brief Create a response to an authentication challenge
2611 *
2612 * This will call into an outbound authenticator's create_request_with_auth callback
2613 * to create a new request with authentication credentials. See the create_request_with_auth
2614 * callback in the \ref ast_sip_outbound_authenticator structure for details about
2615 * the parameters and return values.
2616 */
2617int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge,
2618 pjsip_tx_data *tdata, pjsip_tx_data **new_request);
2619
2620/*!
2621 * \brief Determine the endpoint that has sent a SIP message
2622 *
2623 * This will call into each of the registered endpoint identifiers'
2624 * identify_endpoint() callbacks until one returns a non-NULL endpoint.
2625 * This will return an ao2 object. Its reference count will need to be
2626 * decremented when completed using the endpoint.
2627 *
2628 * \param rdata The inbound SIP message to use when identifying the endpoint.
2629 * \retval NULL No matching endpoint
2630 * \retval non-NULL The matching endpoint
2631 */
2632struct ast_sip_endpoint *ast_sip_identify_endpoint(pjsip_rx_data *rdata);
2633
2634/*!
2635 * \brief Get a specific header value from rdata
2636 *
2637 * \note The returned value does not need to be freed since it's from the rdata pool
2638 *
2639 * \param rdata The rdata
2640 * \param str The header to find
2641 *
2642 * \retval NULL on failure
2643 * \retval The header value on success
2644 */
2645char *ast_sip_rdata_get_header_value(pjsip_rx_data *rdata, const pj_str_t str);
2646
2647/*!
2648 * \brief Set the outbound proxy for an outbound SIP message
2649 *
2650 * \param tdata The message to set the outbound proxy on
2651 * \param proxy SIP uri of the proxy
2652 * \retval 0 Success
2653 * \retval -1 Failure
2654 */
2655int ast_sip_set_outbound_proxy(pjsip_tx_data *tdata, const char *proxy);
2656
2657/*!
2658 * \brief Add a header to an outbound SIP message
2659 *
2660 * \param tdata The message to add the header to
2661 * \param name The header name
2662 * \param value The header value
2663 * \retval 0 Success
2664 * \retval -1 Failure
2665 */
2666int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value);
2667
2668/*!
2669 * \brief Add a header to an outbound SIP message, returning a pointer to the header
2670 *
2671 * \param tdata The message to add the header to
2672 * \param name The header name
2673 * \param value The header value
2674 * \return The pjsip_generic_string_hdr * added.
2675 */
2676pjsip_generic_string_hdr *ast_sip_add_header2(pjsip_tx_data *tdata,
2677 const char *name, const char *value);
2678
2679/*!
2680 * \brief Add a body to an outbound SIP message
2681 *
2682 * If this is called multiple times, the latest body will replace the current
2683 * body.
2684 *
2685 * \param tdata The message to add the body to
2686 * \param body The message body to add
2687 * \retval 0 Success
2688 * \retval -1 Failure
2689 */
2690int ast_sip_add_body(pjsip_tx_data *tdata, const struct ast_sip_body *body);
2691
2692/*!
2693 * \brief Add a multipart body to an outbound SIP message
2694 *
2695 * This will treat each part of the input vector as part of a multipart body and
2696 * add each part to the SIP message.
2697 *
2698 * \param tdata The message to add the body to
2699 * \param bodies The message bodies to add
2700 * \param num_bodies The parts of the body to add
2701 * \retval 0 Success
2702 * \retval -1 Failure
2703 */
2704int ast_sip_add_body_multipart(pjsip_tx_data *tdata, const struct ast_sip_body *bodies[], int num_bodies);
2705
2706/*!
2707 * \brief Append body data to a SIP message
2708 *
2709 * This acts mostly the same as ast_sip_add_body, except that rather than replacing
2710 * a body if it currently exists, it appends data to an existing body.
2711 *
2712 * \param tdata The message to append the body to
2713 * \param body_text The string to append to the end of the current body
2714 * \retval 0 Success
2715 * \retval -1 Failure
2716 */
2717int ast_sip_append_body(pjsip_tx_data *tdata, const char *body_text);
2718
2719/*!
2720 * \brief Copy a pj_str_t into a standard character buffer.
2721 *
2722 * pj_str_t is not NULL-terminated. Any place that expects a NULL-
2723 * terminated string needs to have the pj_str_t copied into a separate
2724 * buffer.
2725 *
2726 * This method copies the pj_str_t contents into the destination buffer
2727 * and NULL-terminates the buffer.
2728 *
2729 * \param dest The destination buffer
2730 * \param src The pj_str_t to copy
2731 * \param size The size of the destination buffer.
2732 */
2733void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size);
2734
2735/*!
2736 * \brief Create and copy a pj_str_t into a standard character buffer.
2737 *
2738 * pj_str_t is not NULL-terminated. Any place that expects a NULL-
2739 * terminated string needs to have the pj_str_t copied into a separate
2740 * buffer.
2741 *
2742 * Copies the pj_str_t contents into a newly allocated buffer pointed to
2743 * by dest. NULL-terminates the buffer.
2744 *
2745 * \note Caller is responsible for freeing the allocated memory.
2746 *
2747 * \param[out] dest The destination buffer
2748 * \param src The pj_str_t to copy
2749 * \return Number of characters copied or negative value on error
2750 */
2751int ast_copy_pj_str2(char **dest, const pj_str_t *src);
2752
2753/*!
2754 * \brief Get the looked-up endpoint on an out-of dialog request or response
2755 *
2756 * The function may ONLY be called on out-of-dialog requests or responses. For
2757 * in-dialog requests and responses, it is required that the user of the dialog
2758 * has the looked-up endpoint stored locally.
2759 *
2760 * This function should never return NULL if the message is out-of-dialog. It will
2761 * always return NULL if the message is in-dialog.
2762 *
2763 * This function will increase the reference count of the returned endpoint by one.
2764 * Release your reference using the ao2_ref function when finished.
2765 *
2766 * \param rdata Out-of-dialog request or response
2767 * \return The looked up endpoint
2768 */
2769struct ast_sip_endpoint *ast_pjsip_rdata_get_endpoint(pjsip_rx_data *rdata);
2770
2771/*!
2772 * \brief Add 'user=phone' parameter to URI if enabled and user is a phone number.
2773 *
2774 * \param endpoint The endpoint to use for configuration
2775 * \param pool The memory pool to allocate the parameter from
2776 * \param uri The URI to check for user and to add parameter to
2777 */
2778void ast_sip_add_usereqphone(const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri);
2779
2780/*!
2781 * \brief Retrieve any endpoints available to sorcery.
2782 *
2783 * \retval Endpoints available to sorcery, NULL if no endpoints found.
2784 */
2786
2787/*!
2788 * \brief Retrieve the default outbound endpoint.
2789 *
2790 * \retval The default outbound endpoint, NULL if not found.
2791 */
2793
2794/*!
2795 * \brief Retrieve relevant SIP auth structures from sorcery
2796 *
2797 * \param auths Vector of sorcery IDs of auth credentials to retrieve
2798 * \param[out] out The retrieved auths are stored here
2799 */
2800int ast_sip_retrieve_auths(const struct ast_sip_auth_vector *auths, struct ast_sip_auth **out);
2801
2802/*!
2803 * \brief Clean up retrieved auth structures from memory
2804 *
2805 * Call this function once you have completed operating on auths
2806 * retrieved from \ref ast_sip_retrieve_auths
2807 *
2808 * \param auths An array of auth object pointers to clean up
2809 * \param num_auths The number of auths in the array
2810 */
2811void ast_sip_cleanup_auths(struct ast_sip_auth *auths[], size_t num_auths);
2812
2814/*!
2815 * \brief Retrieve relevant SIP auth structures from sorcery as a vector
2816 *
2817 * \param auth_ids Vector of sorcery IDs of auth credentials to retrieve
2818 * \param[out] auth_objects A pointer ast_sip_auth_objects_vector to hold the objects
2819 *
2820 * \retval 0 Success
2821 * \retval -1 Number of auth objects found is less than the number of names supplied.
2822 *
2823 * \warning The number of auth objects retrieved may be less than the
2824 * number of auth ids supplied if auth objects couldn't be found for
2825 * some of them.
2826 *
2827 * \note Since the ref count on all auth objects returned has been
2828 * bumped, you must call ast_sip_cleanup_auth_objects_vector() to decrement
2829 * the ref count on all of the auth objects in the vector,
2830 * then call AST_VECTOR_FREE() on the vector itself.
2831 *
2832 */
2833int ast_sip_retrieve_auths_vector(const struct ast_sip_auth_vector *auth_ids,
2834 struct ast_sip_auth_objects_vector *auth_objects);
2835
2836/*!
2837 * \brief Clean up retrieved auth objects in vector
2838 *
2839 * Call this function once you have completed operating on auths
2840 * retrieved from \ref ast_sip_retrieve_auths_vector. All
2841 * auth objects will have their reference counts decremented and
2842 * the vector size will be reset to 0. You must still call
2843 * AST_VECTOR_FREE() on the vector itself.
2844 *
2845 * \param auth_objects A vector of auth structures to clean up
2846 */
2847#define ast_sip_cleanup_auth_objects_vector(auth_objects) AST_VECTOR_RESET(auth_objects, ao2_cleanup)
2848
2849/*!
2850 * \brief Checks if the given content type matches type/subtype.
2851 *
2852 * Compares the pjsip_media_type with the passed type and subtype and
2853 * returns the result of that comparison. The media type parameters are
2854 * ignored.
2855 *
2856 * \param content_type The pjsip_media_type structure to compare
2857 * \param type The media type to compare
2858 * \param subtype The media subtype to compare
2859 * \retval 0 No match
2860 * \retval -1 Match
2861 */
2862int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype);
2863
2864/*!
2865 * \brief Send a security event notification for when an invalid endpoint is requested
2866 *
2867 * \param name Name of the endpoint requested
2868 * \param rdata Received message
2869 */
2870void ast_sip_report_invalid_endpoint(const char *name, pjsip_rx_data *rdata);
2871
2872/*!
2873 * \brief Send a security event notification for when an ACL check fails
2874 *
2875 * \param endpoint Pointer to the endpoint in use
2876 * \param rdata Received message
2877 * \param name Name of the ACL
2878 */
2879void ast_sip_report_failed_acl(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, const char *name);
2880
2881/*!
2882 * \brief Send a security event notification for when a challenge response has failed
2883 *
2884 * \param endpoint Pointer to the endpoint in use
2885 * \param rdata Received message
2886 */
2887void ast_sip_report_auth_failed_challenge_response(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
2888
2889/*!
2890 * \brief Send a security event notification for when authentication succeeds
2891 *
2892 * \param endpoint Pointer to the endpoint in use
2893 * \param rdata Received message
2894 */
2895void ast_sip_report_auth_success(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
2896
2897/*!
2898 * \brief Send a security event notification for when an authentication challenge is sent
2899 *
2900 * \param endpoint Pointer to the endpoint in use
2901 * \param rdata Received message
2902 * \param tdata Sent message
2903 */
2904void ast_sip_report_auth_challenge_sent(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata);
2905
2906/*!
2907 * \brief Send a security event notification for when a request is not supported
2908 *
2909 * \param endpoint Pointer to the endpoint in use
2910 * \param rdata Received message
2911 * \param req_type the type of request
2912 */
2913void ast_sip_report_req_no_support(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata,
2914 const char* req_type);
2915
2916/*!
2917 * \brief Send a security event notification for when a memory limit is hit.
2918 *
2919 * \param endpoint Pointer to the endpoint in use
2920 * \param rdata Received message
2921 */
2922void ast_sip_report_mem_limit(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
2923
2924int ast_sip_add_global_request_header(const char *name, const char *value, int replace);
2925int ast_sip_add_global_response_header(const char *name, const char *value, int replace);
2926
2927/*!
2928 * \brief Retrieves the value associated with the given key.
2929 *
2930 * \param ht the hash table/dictionary to search
2931 * \param key the key to find
2932 *
2933 * \retval the value associated with the key, NULL otherwise.
2934 */
2935void *ast_sip_dict_get(void *ht, const char *key);
2936
2937/*!
2938 * \brief Using the dictionary stored in mod_data array at a given id,
2939 * retrieve the value associated with the given key.
2940 *
2941 * \param mod_data a module data array
2942 * \param id the mod_data array index
2943 * \param key the key to find
2944 *
2945 * \retval the value associated with the key, NULL otherwise.
2946 */
2947#define ast_sip_mod_data_get(mod_data, id, key) \
2948 ast_sip_dict_get(mod_data[id], key)
2949
2950/*!
2951 * \brief Set the value for the given key.
2952 *
2953 * Note - if the hash table does not exist one is created first, the key/value
2954 * pair is set, and the hash table returned.
2955 *
2956 * \param pool the pool to allocate memory in
2957 * \param ht the hash table/dictionary in which to store the key/value pair
2958 * \param key the key to associate a value with
2959 * \param val the value to associate with a key
2960 *
2961 * \retval the given, or newly created, hash table.
2962 */
2963void *ast_sip_dict_set(pj_pool_t* pool, void *ht,
2964 const char *key, void *val);
2965
2966/*!
2967 * \brief Utilizing a mod_data array for a given id, set the value
2968 * associated with the given key.
2969 *
2970 * For a given structure's mod_data array set the element indexed by id to
2971 * be a dictionary containing the key/val pair.
2972 *
2973 * \param pool a memory allocation pool
2974 * \param mod_data a module data array
2975 * \param id the mod_data array index
2976 * \param key the key to find
2977 * \param val the value to associate with a key
2978 */
2979#define ast_sip_mod_data_set(pool, mod_data, id, key, val) \
2980 mod_data[id] = ast_sip_dict_set(pool, mod_data[id], key, val)
2981
2982/*!
2983 * \brief For every contact on an AOR call the given 'on_contact' handler.
2984 *
2985 * \param aor the aor containing a list of contacts to iterate
2986 * \param on_contact callback on each contact on an AOR. The object
2987 * received by the callback will be a ast_sip_contact_wrapper structure.
2988 * \param arg user data passed to handler
2989 * \retval 0 Success, non-zero on failure
2990 */
2991int ast_sip_for_each_contact(const struct ast_sip_aor *aor,
2992 ao2_callback_fn on_contact, void *arg);
2993
2994/*!
2995 * \brief Handler used to convert a contact to a string.
2996 *
2997 * \param object the ast_sip_aor_contact_pair containing a list of contacts to iterate and the contact
2998 * \param arg user data passed to handler
2999 * \param flags
3000 * \retval 0 Success, non-zero on failure
3001 */
3002int ast_sip_contact_to_str(void *object, void *arg, int flags);
3003
3004/*!
3005 * \brief For every aor in the comma separated aors string call the
3006 * given 'on_aor' handler.
3007 *
3008 * \param aors a comma separated list of aors
3009 * \param on_aor callback for each aor
3010 * \param arg user data passed to handler
3011 * \retval 0 Success, non-zero on failure
3012 */
3013int ast_sip_for_each_aor(const char *aors, ao2_callback_fn on_aor, void *arg);
3014
3015/*!
3016 * \brief For every auth in the array call the given 'on_auth' handler.
3017 *
3018 * \param array an array of auths
3019 * \param on_auth callback for each auth
3020 * \param arg user data passed to handler
3021 * \retval 0 Success, non-zero on failure
3022 */
3024 ao2_callback_fn on_auth, void *arg);
3025
3026/*!
3027 * \brief Converts the given auth type to a string
3028 *
3029 * \param type the auth type to convert
3030 * \retval a string representative of the auth type
3031 */
3033
3034/*!
3035 * \brief Converts an auths array to a string of comma separated values
3036 *
3037 * \param auths an auth array
3038 * \param buf the string buffer to write the object data
3039 * \retval 0 Success, non-zero on failure
3040 */
3041int ast_sip_auths_to_str(const struct ast_sip_auth_vector *auths, char **buf);
3042
3043/*!
3044 * \brief AMI variable container
3045 */
3047 /*! Manager session */
3048 struct mansession *s;
3049 /*! Manager message */
3050 const struct message *m;
3051 /*! Manager Action ID */
3052 const char *action_id;
3053 /*! user specified argument data */
3054 void *arg;
3055 /*! count of objects */
3057};
3058
3059/*!
3060 * \brief Creates a string to store AMI event data in.
3061 *
3062 * \param event the event to set
3063 * \param ami AMI session and message container
3064 * \retval an initialized ast_str or NULL on error.
3065 */
3066struct ast_str *ast_sip_create_ami_event(const char *event,
3067 struct ast_sip_ami *ami);
3068
3069/*!
3070 * \brief An entity responsible formatting endpoint information.
3071 */
3073 /*!
3074 * \brief Callback used to format endpoint information over AMI.
3075 */
3076 int (*format_ami)(const struct ast_sip_endpoint *endpoint,
3077 struct ast_sip_ami *ami);
3079};
3080
3081/*!
3082 * \brief Register an endpoint formatter.
3083 *
3084 * \param obj the formatter to register
3085 */
3087
3088/*!
3089 * \brief Unregister an endpoint formatter.
3090 *
3091 * \param obj the formatter to unregister
3092 */
3094
3095/*!
3096 * \brief Converts a sorcery object to a string of object properties.
3097 *
3098 * \param obj the sorcery object to convert
3099 * \param buf the string buffer to write the object data
3100 * \retval 0 Success, non-zero on failure
3101 */
3102int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf);
3103
3104/*!
3105 * \brief Formats the endpoint and sends over AMI.
3106 *
3107 * \param endpoint the endpoint to format and send
3108 * \param ami AMI variable container
3109 * \param count the number of formatters operated on
3110 * \retval 0 Success, otherwise non-zero on error
3111 */
3113 struct ast_sip_ami *ami, int *count);
3114
3115/*!
3116 * \brief Formats the contact and sends over AMI.
3117 *
3118 * \param obj a pointer an ast_sip_contact_wrapper structure
3119 * \param arg a pointer to an ast_sip_ami structure
3120 * \param flags ignored
3121 * \retval 0 Success, otherwise non-zero on error
3122 */
3123int ast_sip_format_contact_ami(void *obj, void *arg, int flags);
3124
3125/*!
3126 * \brief Format auth details for AMI.
3127 *
3128 * \param auths an auth array
3129 * \param ami ami variable container
3130 * \retval 0 Success, non-zero on failure
3131 */
3132int ast_sip_format_auths_ami(const struct ast_sip_auth_vector *auths,
3133 struct ast_sip_ami *ami);
3134
3135/*!
3136 * \brief Retrieve the endpoint snapshot for an endpoint
3137 *
3138 * \param endpoint The endpoint whose snapshot is to be retrieved.
3139 * \retval The endpoint snapshot
3140 */
3142 const struct ast_sip_endpoint *endpoint);
3143
3144/*!
3145 * \brief Retrieve the device state for an endpoint.
3146 *
3147 * \param endpoint The endpoint whose state is to be retrieved.
3148 * \retval The device state.
3149 */
3150const char *ast_sip_get_device_state(const struct ast_sip_endpoint *endpoint);
3151
3152/*!
3153 * \brief For every channel snapshot on an endpoint snapshot call the given
3154 * 'on_channel_snapshot' handler.
3155 *
3156 * \param endpoint_snapshot snapshot of an endpoint
3157 * \param on_channel_snapshot callback for each channel snapshot
3158 * \param arg user data passed to handler
3159 * \retval 0 Success, non-zero on failure
3160 */
3161int ast_sip_for_each_channel_snapshot(const struct ast_endpoint_snapshot *endpoint_snapshot,
3162 ao2_callback_fn on_channel_snapshot,
3163 void *arg);
3164
3165/*!
3166 * \brief For every channel snapshot on an endpoint all the given
3167 * 'on_channel_snapshot' handler.
3168 *
3169 * \param endpoint endpoint
3170 * \param on_channel_snapshot callback for each channel snapshot
3171 * \param arg user data passed to handler
3172 * \retval 0 Success, non-zero on failure
3173 */
3174int ast_sip_for_each_channel(const struct ast_sip_endpoint *endpoint,
3175 ao2_callback_fn on_channel_snapshot,
3176 void *arg);
3177
3179 /*! Top priority. Supplements with this priority are those that need to run before any others */
3181 /*! Channel creation priority.
3182 * chan_pjsip creates a channel at this priority. If your supplement depends on being run before
3183 * or after channel creation, then set your priority to be lower or higher than this value.
3184 */
3186 /*! Lowest priority. Supplements with this priority should be run after all other supplements */
3188};
3189
3190/*!
3191 * \brief A supplement to SIP message processing
3192 *
3193 * These can be registered by any module in order to add
3194 * processing to incoming and outgoing SIP out of dialog
3195 * requests and responses
3196 */
3198 /*! Method on which to call the callbacks. If NULL, call on all methods */
3199 const char *method;
3200 /*! Priority for this supplement. Lower numbers are visited before higher numbers */
3202 /*!
3203 * \brief Called on incoming SIP request
3204 * This method can indicate a failure in processing in its return. If there
3205 * is a failure, it is required that this method sends a response to the request.
3206 * This method is always called from a SIP servant thread.
3207 *
3208 * \note
3209 * The following PJSIP methods will not work properly:
3210 * pjsip_rdata_get_dlg()
3211 * pjsip_rdata_get_tsx()
3212 * The reason is that the rdata passed into this function is a cloned rdata structure,
3213 * and its module data is not copied during the cloning operation.
3214 * If you need to get the dialog, you can get it via session->inv_session->dlg.
3215 *
3216 * \note
3217 * There is no guarantee that a channel will be present on the session when this is called.
3218 */
3219 int (*incoming_request)(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata);
3220 /*!
3221 * \brief Called on an incoming SIP response
3222 * This method is always called from a SIP servant thread.
3223 *
3224 * \note
3225 * The following PJSIP methods will not work properly:
3226 * pjsip_rdata_get_dlg()
3227 * pjsip_rdata_get_tsx()
3228 * The reason is that the rdata passed into this function is a cloned rdata structure,
3229 * and its module data is not copied during the cloning operation.
3230 * If you need to get the dialog, you can get it via session->inv_session->dlg.
3231 *
3232 * \note
3233 * There is no guarantee that a channel will be present on the session when this is called.
3234 */
3235 void (*incoming_response)(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata);
3236 /*!
3237 * \brief Called on an outgoing SIP request
3238 * This method is always called from a SIP servant thread.
3239 */
3240 void (*outgoing_request)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata);
3241 /*!
3242 * \brief Called on an outgoing SIP response
3243 * This method is always called from a SIP servant thread.
3244 */
3245 void (*outgoing_response)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata);
3246 /*! Next item in the list */
3248};
3249
3250/*!
3251 * \brief Register a supplement to SIP out of dialog processing
3252 *
3253 * This allows for someone to insert themselves in the processing of out
3254 * of dialog SIP requests and responses. This, for example could allow for
3255 * a module to set channel data based on headers in an incoming message.
3256 * Similarly, a module could reject an incoming request if desired.
3257 *
3258 * \param supplement The supplement to register
3259 */
3260void ast_sip_register_supplement(struct ast_sip_supplement *supplement);
3261
3262/*!
3263 * \brief Unregister a an supplement to SIP out of dialog processing
3264 *
3265 * \param supplement The supplement to unregister
3266 */
3267void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement);
3268
3269/*!
3270 * \brief Retrieve the global MWI taskprocessor high water alert trigger level.
3271 *
3272 * \since 13.12.0
3273 *
3274 * \retval the system MWI taskprocessor high water alert trigger level
3275 */
3276unsigned int ast_sip_get_mwi_tps_queue_high(void);
3277
3278/*!
3279 * \brief Retrieve the global MWI taskprocessor low water clear alert level.
3280 *
3281 * \since 13.12.0
3282 *
3283 * \retval the system MWI taskprocessor low water clear alert level
3284 */
3286
3287/*!
3288 * \brief Retrieve the global setting 'disable sending unsolicited mwi on startup'.
3289 * \since 13.12.0
3290 *
3291 * \retval non zero if disable.
3292 */
3294
3295/*!
3296 * \brief Retrieve the global setting 'allow_sending_180_after_183'.
3297 *
3298 * \retval non zero if disable.
3299 */
3301
3302/*!
3303 * \brief Retrieve the global setting 'use_callerid_contact'.
3304 * \since 13.24.0
3305 *
3306 * \retval non zero if CALLERID(num) is to be used as the default username in the contact
3307 */
3308unsigned int ast_sip_get_use_callerid_contact(void);
3309
3310/*!
3311 * \brief Retrieve the global setting 'norefersub'.
3312 *
3313 * \retval non zero if norefersub is to be sent in "Supported" Headers
3314 */
3315unsigned int ast_sip_get_norefersub(void);
3316
3317/*!
3318 * \brief Retrieve the global setting 'ignore_uri_user_options'.
3319 * \since 13.12.0
3320 *
3321 * \retval non zero if ignore the user field options.
3322 */
3323unsigned int ast_sip_get_ignore_uri_user_options(void);
3324
3325/*!
3326 * \brief Retrieve the global setting 'send_contact_status_on_update_registration'.
3327 * \since 16.2.0
3328 *
3329 * \retval non zero if need to send AMI ContactStatus event when a contact is updated.
3330 */
3332
3333
3334/*!
3335 * \brief Truncate the URI user field options string if enabled.
3336 * \since 13.12.0
3337 *
3338 * \param str URI user field string to truncate if enabled
3339 *
3340 * \details
3341 * We need to be able to handle URI's looking like
3342 * "sip:1235557890;phone-context=national@x.x.x.x;user=phone"
3343 *
3344 * Where the URI user field is:
3345 * "1235557890;phone-context=national"
3346 *
3347 * When truncated the string will become:
3348 * "1235557890"
3349 */
3350#define AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(str) \
3351 do { \
3352 char *__semi = strchr((str), ';'); \
3353 if (__semi && ast_sip_get_ignore_uri_user_options()) { \
3354 *__semi = '\0'; \
3355 } \
3356 } while (0)
3357
3358/*!
3359 * \brief Retrieve the system debug setting (yes|no|host).
3360 *
3361 * \note returned string needs to be de-allocated by caller.
3362 *
3363 * \retval the system debug setting.
3364 */
3365char *ast_sip_get_debug(void);
3366
3367/*!
3368 * \brief Retrieve the global regcontext setting.
3369 *
3370 * \since 13.8.0
3371 *
3372 * \note returned string needs to be de-allocated by caller.
3373 *
3374 * \retval the global regcontext setting
3375 */
3376char *ast_sip_get_regcontext(void);
3377
3378/*!
3379 * \brief Retrieve the global endpoint_identifier_order setting.
3380 *
3381 * Specifies the order by which endpoint identifiers should be regarded.
3382 *
3383 * \retval the global endpoint_identifier_order value
3384 */
3386
3387/*!
3388 * \brief Retrieve the default voicemail extension.
3389 * \since 13.9.0
3390 *
3391 * \note returned string needs to be de-allocated by caller.
3392 *
3393 * \retval the default voicemail extension
3394 */
3396
3397/*!
3398 * \brief Retrieve the global default realm.
3399 *
3400 * This is the value placed in outbound challenges' realm if there
3401 * is no better option (such as an auth-configured realm).
3402 *
3403 * \param[out] realm The default realm
3404 * \param size The buffer size of realm
3405 */
3406void ast_sip_get_default_realm(char *realm, size_t size);
3407
3408/*!
3409 * \brief Retrieve the global default from user.
3410 *
3411 * This is the value placed in outbound requests' From header if there
3412 * is no better option (such as an endpoint-configured from_user or
3413 * caller ID number).
3414 *
3415 * \param[out] from_user The default from user
3416 * \param size The buffer size of from_user
3417 */
3418void ast_sip_get_default_from_user(char *from_user, size_t size);
3419
3420/*!
3421 * \brief Retrieve the system keep alive interval setting.
3422 *
3423 * \retval the keep alive interval.
3424 */
3425unsigned int ast_sip_get_keep_alive_interval(void);
3426
3427/*!
3428 * \brief Retrieve the system contact expiration check interval setting.
3429 *
3430 * \retval the contact expiration check interval.
3431 */
3433
3434/*!
3435 * \brief Retrieve the system setting 'disable multi domain'.
3436 * \since 13.9.0
3437 *
3438 * \retval non zero if disable multi domain.
3439 */
3440unsigned int ast_sip_get_disable_multi_domain(void);
3441
3442/*!
3443 * \brief Retrieve the system max initial qualify time.
3444 *
3445 * \retval the maximum initial qualify time.
3446 */
3447unsigned int ast_sip_get_max_initial_qualify_time(void);
3448
3449/*!
3450 * \brief translate ast_sip_contact_status_type to character string.
3451 *
3452 * \retval the character string equivalent.
3453 */
3454
3457
3458/*!
3459 * \brief Set a request to use the next value in the list of resolved addresses.
3460 *
3461 * \param tdata the tx data from the original request
3462 * \retval 0 No more addresses to try
3463 * \retval 1 The request was successfully re-intialized
3464 */
3465int ast_sip_failover_request(pjsip_tx_data *tdata);
3466
3467/*!
3468 * \brief Retrieve the local host address in IP form
3469 *
3470 * \param af The address family to retrieve
3471 * \param addr A place to store the local host address
3472 *
3473 * \retval 0 success
3474 * \retval -1 failure
3475 *
3476 * \since 13.6.0
3477 */
3478int ast_sip_get_host_ip(int af, pj_sockaddr *addr);
3479
3480/*!
3481 * \brief Retrieve the local host address in string form
3482 *
3483 * \param af The address family to retrieve
3484 *
3485 * \retval non-NULL success
3486 * \retval NULL failure
3487 *
3488 * \since 13.6.0
3489 *
3490 * \note An empty string may be returned if the address family is valid but no local address exists
3491 */
3492const char *ast_sip_get_host_ip_string(int af);
3493
3494/*!
3495 * \brief Return the size of the SIP threadpool's task queue
3496 * \since 13.7.0
3497 */
3499
3500/*!
3501 * \brief Retrieve the SIP threadpool object
3502 */
3504
3505/*!
3506 * \brief Retrieve transport state
3507 * \since 13.7.1
3508 *
3509 * \param transport_id
3510 * \retval transport_state
3511 *
3512 * \note ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object
3513 */
3514struct ast_sip_transport_state *ast_sip_get_transport_state(const char *transport_id);
3515
3516/*!
3517 * \brief Return the SIP URI of the Contact header
3518 *
3519 * \param tdata
3520 * \retval Pointer to SIP URI of Contact
3521 * \retval NULL if Contact header not found or not a SIP(S) URI
3522 *
3523 * \note Do not free the returned object.
3524 */
3525pjsip_sip_uri *ast_sip_get_contact_sip_uri(pjsip_tx_data *tdata);
3526
3527/*!
3528 * \brief Returns the transport state currently in use based on request transport details
3529 *
3530 * \param details
3531 * \retval transport_state
3532 *
3533 * \note ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object
3534 */
3536
3537/*!
3538 * \brief Sets request transport details based on tdata
3539 *
3540 * \param details pre-allocated request transport details to set
3541 * \param tdata
3542 * \param use_ipv6 if non-zero, ipv6 transports will be considered
3543 * \retval 0 success
3544 * \retval -1 failure
3545 */
3546int ast_sip_set_request_transport_details(struct ast_sip_request_transport_details *details, pjsip_tx_data *tdata, int use_ipv6);
3547
3548/*!
3549 * \brief Replace domain and port of SIP URI to point to (external) signaling address of this Asterisk instance
3550 *
3551 * \param uri
3552 * \param tdata
3553 *
3554 * \retval 0 success
3555 * \retval -1 failure
3556 *
3557 * \note Uses domain and port in Contact header if it exists, otherwise the local URI of the dialog is used if the
3558 * message is sent within the context of a dialog. Further, NAT settings are considered - i.e. if the target
3559 * is not in the localnet, the external_signaling_address and port are used.
3560 */
3561int ast_sip_rewrite_uri_to_local(pjsip_sip_uri *uri, pjsip_tx_data *tdata);
3562
3563/*!
3564 * \brief Retrieves all transport states
3565 * \since 13.7.1
3566 *
3567 * \retval ao2_container
3568 *
3569 * \note ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object
3570 */
3572
3573/*!
3574 * \brief Sets pjsip_tpselector from ast_sip_transport
3575 * \since 13.8.0
3576 *
3577 * \param transport The transport to be used
3578 * \param selector The selector to be populated
3579 * \retval 0 success
3580 * \retval -1 failure
3581 *
3582 * \note The transport selector must be unreffed using ast_sip_tpselector_unref
3583 */
3584int ast_sip_set_tpselector_from_transport(const struct ast_sip_transport *transport, pjsip_tpselector *selector);
3585
3586/*!
3587 * \brief Sets pjsip_tpselector from ast_sip_transport
3588 * \since 13.8.0
3589 *
3590 * \param transport_name The name of the transport to be used
3591 * \param selector The selector to be populated
3592 * \retval 0 success
3593 * \retval -1 failure
3594 *
3595 * \note The transport selector must be unreffed using ast_sip_tpselector_unref
3596 */
3597int ast_sip_set_tpselector_from_transport_name(const char *transport_name, pjsip_tpselector *selector);
3598
3599/*!
3600 * \brief Unreference a pjsip_tpselector
3601 * \since 17.0.0
3602 *
3603 * \param selector The selector to be unreffed
3604 */
3605void ast_sip_tpselector_unref(pjsip_tpselector *selector);
3606
3607/*!
3608 * \brief Sets the PJSIP transport on a child transport
3609 * \since 17.0.0
3610 *
3611 * \param transport_name The name of the transport to be updated
3612 * \param transport The PJSIP transport
3613 * \retval 0 success
3614 * \retval -1 failure
3615 */
3616int ast_sip_transport_state_set_transport(const char *transport_name, pjsip_transport *transport);
3617
3618/*!
3619 * \brief Sets the P-Preferred-Identity on a child transport
3620 * \since 17.0.0
3621 *
3622 * \param transport_name The name of the transport to be set on
3623 * \param identity The P-Preferred-Identity to use on requests on this transport
3624 * \retval 0 success
3625 * \retval -1 failure
3626 */
3627int ast_sip_transport_state_set_preferred_identity(const char *transport_name, const char *identity);
3628
3629/*!
3630 * \brief Sets the service routes on a child transport
3631 * \since 17.0.0
3632 *
3633 * \param transport_name The name of the transport to be set on
3634 * \param service_routes A vector of service routes
3635 * \retval 0 success
3636 * \retval -1 failure
3637 *
3638 * \note This assumes ownership of the service routes in both success and failure scenarios
3639 */
3640int ast_sip_transport_state_set_service_routes(const char *transport_name, struct ast_sip_service_route_vector *service_routes);
3641
3642/*!
3643 * \brief Apply the configuration for a transport to an outgoing message
3644 * \since 17.0.0
3645 *
3646 * \param transport_name The name of the transport to apply configuration from
3647 * \param tdata The SIP message
3648 */
3649void ast_sip_message_apply_transport(const char *transport_name, pjsip_tx_data *tdata);
3650
3651/*!
3652 * \brief Allocate a vector of service routes
3653 * \since 17.0.0
3654 *
3655 * \retval non-NULL success
3656 * \retval NULL failure
3657 */
3659
3660/*!
3661 * \brief Destroy a vector of service routes
3662 * \since 17.0.0
3663 *
3664 * \param service_routes A vector of service routes
3665 */
3667
3668/*!
3669 * \brief Set the ID for a connected line update
3670 *
3671 * \retval -1 on failure, 0 on success
3672 */
3673int ast_sip_set_id_connected_line(struct pjsip_rx_data *rdata, struct ast_party_id *id);
3674
3675/*!
3676 * \brief Set the ID from an INVITE
3677 *
3678 * \param rdata
3679 * \param id ID structure to fill
3680 * \param default_id Default ID structure with data to use (for non-trusted endpoints)
3681 * \param trust_inbound Whether or not the endpoint is trusted (controls whether PAI or RPID can be used)
3682 *
3683 * \retval -1 on failure, 0 on success
3684 */
3685int ast_sip_set_id_from_invite(struct pjsip_rx_data *rdata, struct ast_party_id *id, struct ast_party_id *default_id, int trust_inbound);
3686
3687/*!
3688 * \brief Set name and number information on an identity header.
3689 *
3690 * \param pool Memory pool to use for string duplication
3691 * \param id_hdr A From, P-Asserted-Identity, or Remote-Party-ID header to modify
3692 * \param id The identity information to apply to the header
3693 */
3694void ast_sip_modify_id_header(pj_pool_t *pool, pjsip_fromto_hdr *id_hdr,
3695 const struct ast_party_id *id);
3696
3697/*!
3698 * \brief Retrieves an endpoint and URI from the "to" string.
3699 *
3700 * This URI is used as the Request URI.
3701 *
3702 * Expects the given 'to' to be in one of the following formats:
3703 * Why we allow so many is a mystery.
3704 *
3705 * Basic:
3706 *
3707 * endpoint : We'll get URI from the default aor/contact
3708 * endpoint/aor : We'll get the URI from the specific aor/contact
3709 * endpoint@domain : We toss the domain part and just use the endpoint
3710 *
3711 * These all use the endpoint and specified URI:
3712 * \verbatim
3713 endpoint/<sip[s]:host>
3714 endpoint/<sip[s]:user@host>
3715 endpoint/"Bob" <sip[s]:host>
3716 endpoint/"Bob" <sip[s]:user@host>
3717 endpoint/sip[s]:host
3718 endpoint/sip[s]:user@host
3719 endpoint/host
3720 endpoint/user@host
3721 \endverbatim
3722 *
3723 * These all use the default endpoint and specified URI:
3724 * \verbatim
3725 <sip[s]:host>
3726 <sip[s]:user@host>
3727 "Bob" <sip[s]:host>
3728 "Bob" <sip[s]:user@host>
3729 sip[s]:host
3730 sip[s]:user@host
3731 \endverbatim
3732 *
3733 * These use the default endpoint and specified host:
3734 * \verbatim
3735 host
3736 user@host
3737 \endverbatim
3738 *
3739 * This form is similar to a dialstring:
3740 * \verbatim
3741 PJSIP/user@endpoint
3742 \endverbatim
3743 *
3744 * In this case, the user will be added to the endpoint contact's URI.
3745 * If the contact URI already has a user, it will be replaced.
3746 *
3747 * The ones that have the sip[s] scheme are the easiest to parse.
3748 * The rest all have some issue.
3749 *
3750 * endpoint vs host : We have to test for endpoint first
3751 * endpoint/aor vs endpoint/host : We have to test for aor first
3752 * What if there's an aor with the same
3753 * name as the host?
3754 * endpoint@domain vs user@host : We have to test for endpoint first.
3755 * What if there's an endpoint with the
3756 * same name as the user?
3757 *
3758 * \param to 'To' field with possible endpoint
3759 * \param get_default_outbound If nonzero, try to retrieve the default
3760 * outbound endpoint if no endpoint was found.
3761 * Otherwise, return NULL if no endpoint was found.
3762 * \param uri Pointer to a char* which will be set to the URI.
3763 * Always must be ast_free'd by the caller - even if the return value is NULL!
3764 *
3765 * \note The logic below could probably be condensed but then it wouldn't be
3766 * as clear.
3767 */
3768struct ast_sip_endpoint *ast_sip_get_endpoint(const char *to, int get_default_outbound, char **uri);
3769
3770/*!
3771 * \brief Replace the To URI in the tdata with the supplied one
3772 *
3773 * \param tdata the outbound message data structure
3774 * \param to URI to replace the To URI with. Must be a valid SIP URI.
3775 *
3776 * \retval 0: success, -1: failure
3777 */
3778int ast_sip_update_to_uri(pjsip_tx_data *tdata, const char *to);
3779
3780/*!
3781 * \brief Overwrite fields in the outbound 'From' header
3782 *
3783 * The outbound 'From' header is created/added in ast_sip_create_request with
3784 * default data. If available that data may be info specified in the 'from_user'
3785 * and 'from_domain' options found on the endpoint. That information will be
3786 * overwritten with data in the given 'from' parameter.
3787 *
3788 * \param tdata the outbound message data structure
3789 * \param from info to copy into the header.
3790 * Can be either a SIP URI, or in the format user[@domain]
3791 *
3792 * \retval 0: success, -1: failure
3793 */
3794int ast_sip_update_from(pjsip_tx_data *tdata, char *from);
3795
3796/*!
3797 * \brief Retrieve the unidentified request security event thresholds
3798 * \since 13.8.0
3799 *
3800 * \param count The maximum number of unidentified requests per source ip to accumulate before emitting a security event
3801 * \param period The period in seconds over which to accumulate unidentified requests
3802 * \param prune_interval The interval in seconds at which expired entries will be pruned
3803 */
3804void ast_sip_get_unidentified_request_thresholds(unsigned int *count, unsigned int *period,
3805 unsigned int *prune_interval);
3806
3807/*!
3808 * \brief Get the transport name from an endpoint or request uri
3809 * \since 13.15.0
3810 *
3811 * \param endpoint
3812 * \param sip_uri
3813 * \param buf Buffer to receive transport name
3814 * \param buf_len Buffer length
3815 *
3816 * \retval 0 Success
3817 * \retval -1 Failure
3818 *
3819 * \note
3820 * If endpoint->transport is not NULL, it is returned in buf.
3821 * Otherwise if sip_uri has an 'x-ast-txp' parameter AND the sip_uri host is
3822 * an ip4 or ip6 address, its value is returned,
3823 */
3824int ast_sip_get_transport_name(const struct ast_sip_endpoint *endpoint,
3825 pjsip_sip_uri *sip_uri, char *buf, size_t buf_len);
3826
3827/*!
3828 * \brief Sets pjsip_tpselector from an endpoint or uri
3829 * \since 13.15.0
3830 *
3831 * \param endpoint If endpoint->transport is set, it's used
3832 * \param sip_uri If sip_uri contains a x-ast-txp parameter, it's used
3833 * \param selector The selector to be populated
3834 *
3835 * \retval 0 success
3836 * \retval -1 failure
3837 */
3839 pjsip_sip_uri *sip_uri, pjsip_tpselector *selector);
3840
3841/*!
3842 * \brief Set the transport on a dialog
3843 * \since 13.15.0
3844 *
3845 * \param endpoint
3846 * \param dlg
3847 * \param selector (optional)
3848 *
3849 * \note
3850 * This API calls ast_sip_get_transport_name(endpoint, dlg->target) and if the result is
3851 * non-NULL, calls pjsip_dlg_set_transport. If 'selector' is non-NULL, it is updated with
3852 * the selector used.
3853 *
3854 * \note
3855 * It is the responsibility of the caller to unref the passed in selector if one is provided.
3856 */
3857int ast_sip_dlg_set_transport(const struct ast_sip_endpoint *endpoint, pjsip_dialog *dlg,
3858 pjsip_tpselector *selector);
3859
3860/*!
3861 * \brief Convert the DTMF mode enum value into a string
3862 * \since 13.18.0
3863 *
3864 * \param dtmf the dtmf mode
3865 * \param buf Buffer to receive dtmf mode string
3866 * \param buf_len Buffer length
3867 *
3868 * \retval 0 Success
3869 * \retval -1 Failure
3870 *
3871 */
3873 char *buf, size_t buf_len);
3874
3875/*!
3876 * \brief Convert the DTMF mode name into an enum
3877 * \since 13.18.0
3878 *
3879 * \param dtmf_mode dtmf mode as a string
3880 *
3881 * \retval >= 0 The enum value
3882 * \retval -1 Failure
3883 *
3884 */
3885int ast_sip_str_to_dtmf(const char *dtmf_mode);
3886
3887/*!
3888 * \brief Convert the call codec preference flags to a string
3889 * \since 18.0.0
3890 *
3891 * \param pref the call codec preference setting
3892 *
3893 * \returns a constant string with either the setting value or 'unknown'
3894 * \note Don't try to free the string!
3895 *
3896 */
3897const char *ast_sip_call_codec_pref_to_str(struct ast_flags pref);
3898
3899/*!
3900 * \brief Convert a call codec preference string to preference flags
3901 * \since 18.0.0
3902 *
3903 * \param pref A pointer to an ast_flags structure to receive the preference flags
3904 * \param pref_str The call codec preference setting string
3905 * \param is_outgoing Is for outgoing calls?
3906 *
3907 * \retval 0 The string was parsed successfully
3908 * \retval -1 The string option was invalid
3909 */
3910int ast_sip_call_codec_str_to_pref(struct ast_flags *pref, const char *pref_str, int is_outgoing);
3911
3912/*!
3913 * \brief Transport shutdown monitor callback.
3914 * \since 13.18.0
3915 *
3916 * \param data User data to know what to do when transport shuts down.
3917 *
3918 * \note The callback does not need to care that data is an ao2 object.
3919 */
3920typedef void (*ast_transport_monitor_shutdown_cb)(void *data);
3921
3922/*!
3923 * \brief Transport shutdown monitor data matcher
3924 * \since 13.20.0
3925 *
3926 * \param a User data to compare.
3927 * \param b User data to compare.
3928 *
3929 * \retval 1 The data objects match
3930 * \retval 0 The data objects don't match
3931 */
3932typedef int (*ast_transport_monitor_data_matcher)(void *a, void *b);
3933
3935 /*! \brief Successfully registered the transport monitor */
3937 /*! \brief Replaced the already existing transport monitor with new one. */
3939 /*!
3940 * \brief Transport not found to monitor.
3941 * \note Transport is either already shutdown or is not reliable.
3942 */
3944 /*! \brief Error while registering transport monitor. */
3946};
3947
3948/*!
3949 * \brief Register a reliable transport shutdown monitor callback.
3950 * \deprecated Replaced with ast_sip_transport_monitor_register_key().
3951 * \since 13.20.0
3952 *
3953 * \param transport Transport to monitor for shutdown.
3954 * \param cb Who to call when transport is shutdown.
3955 * \param ao2_data Data to pass with the callback.
3956 *
3957 * \note The data object passed will have its reference count automatically
3958 * incremented by this call and automatically decremented after the callback
3959 * runs or when the callback is unregistered.
3960 *
3961 * There is no checking for duplicate registrations.
3962 *
3963 * \return enum ast_transport_monitor_reg
3964 */
3966 ast_transport_monitor_shutdown_cb cb, void *ao2_data);
3967
3968/*!
3969 * \brief Register a reliable transport shutdown monitor callback.
3970 *
3971 * \param transport_key Key for the transport to monitor for shutdown.
3972 * Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR.
3973 * \param cb Who to call when transport is shutdown.
3974 * \param ao2_data Data to pass with the callback.
3975 *
3976 * \note The data object passed will have its reference count automatically
3977 * incremented by this call and automatically decremented after the callback
3978 * runs or when the callback is unregistered.
3979 *
3980 * There is no checking for duplicate registrations.
3981 *
3982 * \return enum ast_transport_monitor_reg
3983 */
3985 const char *transport_key, ast_transport_monitor_shutdown_cb cb,
3986 void *ao2_data);
3987
3988/*!
3989 * \brief Register a reliable transport shutdown monitor callback replacing any duplicate.
3990 * \deprecated Replaced with ast_sip_transport_monitor_register_replace_key().
3991 * \since 13.26.0
3992 * \since 16.3.0
3993 *
3994 * \param transport Transport to monitor for shutdown.
3995 * \param cb Who to call when transport is shutdown.
3996 * \param ao2_data Data to pass with the callback.
3997 * \param matches Matcher function that returns true if data matches a previously
3998 * registered data object
3999 *
4000 * \note The data object passed will have its reference count automatically
4001 * incremented by this call and automatically decremented after the callback
4002 * runs or when the callback is unregistered.
4003 *
4004 * This function checks for duplicates, and overwrites/replaces the old monitor
4005 * with the given one.
4006 *
4007 * \return enum ast_transport_monitor_reg
4008 */
4011
4012/*!
4013 * \brief Register a reliable transport shutdown monitor callback replacing any duplicate.
4014 *
4015 * \param transport_key Key for the transport to monitor for shutdown.
4016 * Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR.
4017 * \param cb Who to call when transport is shutdown.
4018 * \param ao2_data Data to pass with the callback.
4019 * \param matches Matcher function that returns true if data matches a previously
4020 * registered data object
4021 *
4022 * \note The data object passed will have its reference count automatically
4023 * incremented by this call and automatically decremented after the callback
4024 * runs or when the callback is unregistered.
4025 *
4026 * This function checks for duplicates, and overwrites/replaces the old monitor
4027 * with the given one.
4028 *
4029 * \return enum ast_transport_monitor_reg
4030 */
4032 const char *transport_key, ast_transport_monitor_shutdown_cb cb,
4033 void *ao2_data, ast_transport_monitor_data_matcher matches);
4034
4035/*!
4036 * \brief Unregister a reliable transport shutdown monitor
4037 * \deprecated Replaced with ast_sip_transport_monitor_unregister_key().
4038 * \since 13.20.0
4039 *
4040 * \param transport Transport to monitor for shutdown.
4041 * \param cb The callback that was used for the original register.
4042 * \param data Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object.
4043 * If NULL, all monitors with the provided callback are unregistered.
4044 * \param matches Matcher function that returns true if data matches the previously
4045 * registered data object. If NULL, a simple pointer comparison is done.
4046 *
4047 * \note The data object passed into the original register will have its reference count
4048 * automatically decremented.
4049 */
4052
4053/*!
4054 * \brief Unregister a reliable transport shutdown monitor
4055 *
4056 * \param transport_key Key for the transport to monitor for shutdown.
4057 * Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR.
4058 * \param cb The callback that was used for the original register.
4059 * \param data Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object.
4060 * If NULL, all monitors with the provided callback are unregistered.
4061 * \param matches Matcher function that returns true if data matches the previously
4062 * registered data object. If NULL, a simple pointer comparison is done.
4063 *
4064 * \note The data object passed into the original register will have its reference count
4065 * automatically decremented.
4066 */
4067void ast_sip_transport_monitor_unregister_key(const char *transport_key,
4069
4070/*!
4071 * \brief Unregister a transport shutdown monitor from all reliable transports
4072 * \since 13.20.0
4073 *
4074 * \param cb The callback that was used for the original register.
4075 * \param data Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object.
4076 * If NULL, all monitors with the provided callback are unregistered.
4077 * \param matches Matcher function that returns true if ao2_data matches the previously
4078 * registered data object. If NULL, a simple pointer comparison is done.
4079 *
4080 * \note The data object passed into the original register will have its reference count
4081 * automatically decremented.
4082 */
4084 void *data, ast_transport_monitor_data_matcher matches);
4085
4086/*! Transport state notification registration element. */
4088 /*! PJPROJECT transport state notification callback */
4089 pjsip_tp_state_callback cb;
4091};
4092
4093/*!
4094 * \brief Register a transport state notification callback element.
4095 * \since 13.18.0
4096 *
4097 * \param element What we are registering.
4098 */
4100
4101/*!
4102 * \brief Unregister a transport state notification callback element.
4103 * \since 13.18.0
4104 *
4105 * \param element What we are unregistering.
4106 */
4108
4109/*!
4110 * \brief Check whether a pjsip_uri is SIP/SIPS or not
4111 * \since 16.28.0
4112 *
4113 * \param uri The pjsip_uri to check
4114 *
4115 * \retval 1 if true
4116 * \retval 0 if false
4117 */
4118int ast_sip_is_uri_sip_sips(pjsip_uri *uri);
4119
4120/*!
4121 * \brief Check whether a pjsip_uri is allowed or not
4122 * \since 16.28.0
4123 *
4124 * \param uri The pjsip_uri to check
4125 *
4126 * \retval 1 if allowed
4127 * \retval 0 if not allowed
4128 */
4129int ast_sip_is_allowed_uri(pjsip_uri *uri);
4130
4131/*!
4132 * \brief Get the user portion of the pjsip_uri
4133 * \since 16.28.0
4134 *
4135 * \param uri The pjsip_uri to get the user from
4136 *
4137 * \note This function will check what kind of URI it receives and return
4138 * the user based off of that
4139 *
4140 * \return User string or empty string if not present
4141 */
4142const pj_str_t *ast_sip_pjsip_uri_get_username(pjsip_uri *uri);
4143
4144/*!
4145 * \brief Get the host portion of the pjsip_uri
4146 * \since 16.28.0
4147 *
4148 * \param uri The pjsip_uri to get the host from
4149 *
4150 * \note This function will check what kind of URI it receives and return
4151 * the host based off of that
4152 *
4153 * \return Host string or empty string if not present
4154 */
4155const pj_str_t *ast_sip_pjsip_uri_get_hostname(pjsip_uri *uri);
4156
4157/*!
4158 * \brief Find an 'other' SIP/SIPS URI parameter by name
4159 * \since 16.28.0
4160 *
4161 * A convenience function to find a named parameter from a SIP/SIPS URI. This
4162 * function will not find the following standard SIP/SIPS URI parameters which
4163 * are stored separately by PJSIP:
4164 *
4165 * \li `user`
4166 * \li `method`
4167 * \li `transport`
4168 * \li `ttl`
4169 * \li `lr`
4170 * \li `maddr`
4171 *
4172 * \param uri The pjsip_uri to get the parameter from
4173 * \param param_str The name of the parameter to find
4174 *
4175 * \note This function will check what kind of URI it receives and return
4176 * the parameter based off of that
4177 *
4178 * \return Find parameter or NULL if not present
4179 */
4180struct pjsip_param *ast_sip_pjsip_uri_get_other_param(pjsip_uri *uri, const pj_str_t *param_str);
4181
4182/*!
4183 * \brief Retrieve the system setting 'all_codecs_on_empty_reinvite'.
4184 *
4185 * \retval non zero if we should return all codecs on empty re-INVITE
4186 */
4188
4189
4190/*!
4191 * \brief Convert SIP hangup causes to Asterisk hangup causes
4192 *
4193 * \param cause SIP cause
4194 *
4195 * \retval matched cause code from causes.h
4196 */
4197const int ast_sip_hangup_sip2cause(int cause);
4198
4199/*!
4200 * \brief Convert name to SIP response code
4201 *
4202 * \param name SIP response code name matching one of the
4203 * enum names defined in "enum pjsip_status_code"
4204 * defined in sip_msg.h. May be specified with or
4205 * without the PJSIP_SC_ prefix.
4206 *
4207 * \retval SIP response code
4208 * \retval -1 if matching code not found
4209 */
4210int ast_sip_str2rc(const char *name);
4211
4212#endif /* _RES_PJSIP_H */
jack_status_t status
Definition: app_jack.c:146
const char * str
Definition: app_jack.c:147
int() ao2_callback_fn(void *obj, void *arg, int flags)
Type of a generic callback function.
Definition: astobj2.h:1226
static const char type[]
Definition: chan_ooh323.c:109
General Asterisk PBX channel definitions.
unsigned long long ast_group_t
Definition: channel.h:215
#define AST_MAX_CONTEXT
Definition: channel.h:135
#define attribute_sentinel
Definition: compiler.h:65
Background DNS update manager.
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
Endpoint abstractions.
ast_endpoint_state
Valid states for an endpoint.
Definition: endpoints.h:51
char * address
Definition: f2c.h:59
static const char name[]
Definition: format_mp3.c:68
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:888
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
struct ast_sip_endpoint * ast_sip_dialog_get_endpoint(pjsip_dialog *dlg)
Get the endpoint associated with this dialog.
int(* ast_sip_task)(void *user_data)
Definition: res_pjsip.h:1869
int ast_sip_sched_task_get_times2(struct ast_sip_sched_task *schtd, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end, int *interval, int *time_left, struct timeval *next_start)
Gets the queued, last start, last_end, time left, interval, next run.
struct ast_taskprocessor * ast_sip_get_distributor_serializer(pjsip_rx_data *rdata)
Determine the distributor serializer for the SIP message.
ast_sip_scheduler_task_flags
Task flags for the res_pjsip scheduler.
Definition: res_pjsip.h:2063
int ast_sip_sched_task_cancel_by_name(const char *name)
Cancels the next invocation of a task by name.
int ast_sip_push_task(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Pushes a task to SIP servants.
Definition: res_pjsip.c:2099
struct ast_taskprocessor * ast_sip_create_serializer(const char *name)
Create a new serializer for SIP tasks.
Definition: res_pjsip.c:2094
struct ast_taskprocessor * ast_sip_create_serializer_group(const char *name, struct ast_serializer_shutdown_group *shutdown_group)
Create a new serializer for SIP tasks.
Definition: res_pjsip.c:2089
struct ast_sip_sched_task * ast_sip_schedule_task(struct ast_taskprocessor *serializer, int interval, ast_sip_task sip_task, const char *name, void *task_data, enum ast_sip_scheduler_task_flags flags)
Schedule a task to run in the res_pjsip thread pool.
void ast_sip_dialog_set_endpoint(pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint)
Set an endpoint on a SIP dialog so in-dialog requests do not undergo endpoint lookup.
int ast_sip_sched_task_cancel(struct ast_sip_sched_task *schtd)
Cancels the next invocation of a task.
int ast_sip_sched_is_task_running(struct ast_sip_sched_task *schtd)
Checks if the task is currently running.
int ast_sip_thread_is_servant(void)
Determine if the current thread is a SIP servant thread.
Definition: res_pjsip.c:2310
int ast_sip_sched_task_get_name(struct ast_sip_sched_task *schtd, char *name, size_t maxlen)
Gets the task name.
int ast_sip_sched_task_get_next_run(struct ast_sip_sched_task *schtd)
Gets the number of milliseconds until the next invocation.
void ast_sip_dialog_set_serializer(pjsip_dialog *dlg, struct ast_taskprocessor *serializer)
Set a serializer on a SIP dialog so requests and responses are automatically serialized.
int ast_sip_push_task_synchronous(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to SIP servants and wait for it to complete.
Definition: res_pjsip.c:2174
int ast_sip_sched_task_get_times(struct ast_sip_sched_task *schtd, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end)
Gets the last start and end times of the task.
int ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to SIP servants and wait for it to complete.
Definition: res_pjsip.c:2165
int ast_sip_sched_task_get_next_run_by_name(const char *name)
Gets the number of milliseconds until the next invocation.
int ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to the serializer and wait for it to complete.
Definition: res_pjsip.c:2179
int ast_sip_sched_is_task_running_by_name(const char *name)
Checks if the task is currently running.
int ast_sip_sched_task_get_times_by_name2(const char *name, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end, int *interval, int *time_left, struct timeval *next_start)
Gets the queued, last start, last_end, time left, interval, next run by task name.
int ast_sip_sched_task_get_times_by_name(const char *name, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end)
Gets the last start and end times of the task by name.
@ AST_SIP_SCHED_TASK_ONESHOT
Definition: res_pjsip.h:2086
@ AST_SIP_SCHED_TASK_DELAY
The next invocation of the task is at last finish + interval.
Definition: res_pjsip.h:2118
@ AST_SIP_SCHED_TASK_TRACK
The scheduled task's events are tracked in the debug log.
Definition: res_pjsip.h:2125
@ AST_SIP_SCHED_TASK_DATA_NOT_AO2
Definition: res_pjsip.h:2091
@ AST_SIP_SCHED_TASK_DEFAULTS
Definition: res_pjsip.h:2067
@ AST_SIP_SCHED_TASK_FIXED
Definition: res_pjsip.h:2074
@ AST_SIP_SCHED_TASK_PERIODIC
The task is scheduled at multiples of interval.
Definition: res_pjsip.h:2113
@ AST_SIP_SCHED_TASK_DATA_AO2
Definition: res_pjsip.h:2097
@ AST_SIP_SCHED_TASK_DATA_FREE
Definition: res_pjsip.h:2107
@ AST_SIP_SCHED_TASK_DATA_NO_CLEANUP
Definition: res_pjsip.h:2102
@ AST_SIP_SCHED_TASK_VARIABLE
Definition: res_pjsip.h:2080
A set of macros to manage forward-linked lists.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:410
#define AST_RWLIST_ENTRY
Definition: linkedlists.h:415
Network socket handling.
ast_transport
Definition: netsock2.h:59
static struct ast_serializer_shutdown_group * shutdown_group
Shutdown group for options serializers.
const char * method
Definition: res_pjsip.c:1279
ast_sip_security_mechanism_type
The security mechanism type.
Definition: res_pjsip.h:361
@ AST_SIP_SECURITY_MECH_DTLS_SRTP
Definition: res_pjsip.h:368
@ AST_SIP_SECURITY_MECH_SDES_SRTP
Definition: res_pjsip.h:366
@ AST_SIP_SECURITY_MECH_MSRP_TLS
Definition: res_pjsip.h:364
@ AST_SIP_SECURITY_MECH_NONE
Definition: res_pjsip.h:362
struct ast_sip_auth * ast_sip_get_artificial_auth(void)
Retrieves a reference to the artificial auth.
int ast_sip_dialog_setup_outbound_authentication(pjsip_dialog *dlg, const struct ast_sip_endpoint *endpoint, ast_sip_dialog_outbound_auth_cb cb, void *user_data)
Set up outbound authentication on a SIP dialog.
void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)
Unregister a an supplement to SIP out of dialog processing.
Definition: res_pjsip.c:1476
struct ast_sip_endpoint * ast_sip_get_endpoint(const char *to, int get_default_outbound, char **uri)
Retrieves an endpoint and URI from the "to" string.
Definition: res_pjsip.c:3249
void ast_sip_add_usereqphone(const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri)
Add 'user=phone' parameter to URI if enabled and user is a phone number.
Definition: res_pjsip.c:930
unsigned int ast_sip_get_norefersub(void)
Retrieve the global setting 'norefersub'.
struct pjsip_param * ast_sip_pjsip_uri_get_other_param(pjsip_uri *uri, const pj_str_t *param_str)
Find an 'other' SIP/SIPS URI parameter by name.
Definition: res_pjsip.c:3511
const pj_str_t * ast_sip_pjsip_uri_get_username(pjsip_uri *uri)
Get the user portion of the pjsip_uri.
Definition: res_pjsip.c:3477
void ast_sip_header_to_security_mechanism(const pjsip_generic_string_hdr *hdr, struct ast_sip_security_mechanism_vector *security_mechanisms)
Append to security mechanism vector from SIP header.
unsigned int ast_sip_get_max_initial_qualify_time(void)
Retrieve the system max initial qualify time.
unsigned int ast_sip_get_keep_alive_interval(void)
Retrieve the system keep alive interval setting.
void ast_sip_persistent_endpoint_publish_contact_state(const char *endpoint_name, const struct ast_sip_contact_status *contact_status)
Publish the change of state for a contact.
int ast_sip_set_security_negotiation(enum ast_sip_security_negotiation *security_negotiation, const char *val)
Set the security negotiation based on a given string.
void ast_sip_unregister_service(pjsip_module *module)
Definition: res_pjsip.c:133
unsigned int ast_sip_get_allow_sending_180_after_183(void)
Retrieve the global setting 'allow_sending_180_after_183'.
ast_sip_endpoint_identifier_type
Different methods by which incoming requests can be matched to endpoints.
Definition: res_pjsip.h:606
@ AST_SIP_ENDPOINT_IDENTIFY_BY_HEADER
Definition: res_pjsip.h:614
@ AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME
Definition: res_pjsip.h:608
@ AST_SIP_ENDPOINT_IDENTIFY_BY_REQUEST_URI
Definition: res_pjsip.h:616
@ AST_SIP_ENDPOINT_IDENTIFY_BY_IP
Definition: res_pjsip.h:612
@ AST_SIP_ENDPOINT_IDENTIFY_BY_AUTH_USERNAME
Definition: res_pjsip.h:610
const char * ast_sip_get_host_ip_string(int af)
Retrieve the local host address in string form.
Definition: res_pjsip.c:2493
char * ast_sip_get_endpoint_identifier_order(void)
Retrieve the global endpoint_identifier_order setting.
int(* ast_transport_monitor_data_matcher)(void *a, void *b)
Transport shutdown monitor data matcher.
Definition: res_pjsip.h:3932
void ast_sip_security_mechanisms_vector_copy(struct ast_sip_security_mechanism_vector *dst, const struct ast_sip_security_mechanism_vector *src)
Duplicate a security mechanism.
pjsip_media_type pjsip_media_type_application_media_control_xml
Definition: res_pjsip.c:3910
int ast_sip_call_codec_str_to_pref(struct ast_flags *pref, const char *pref_str, int is_outgoing)
Convert a call codec preference string to preference flags.
Definition: res_pjsip.c:2577
int ast_sip_transport_state_set_transport(const char *transport_name, pjsip_transport *transport)
Sets the PJSIP transport on a child transport.
char * ast_sip_rdata_get_header_value(pjsip_rx_data *rdata, const pj_str_t str)
Get a specific header value from rdata.
Definition: res_pjsip.c:345
pjsip_dialog * ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status)
General purpose method for creating a UAS dialog with an endpoint.
Definition: res_pjsip.c:1176
struct ast_sip_contact * ast_sip_location_retrieve_contact_from_aor_list(const char *aor_list)
Retrieve the first bound contact from a list of AORs.
Definition: location.c:304
int ast_sip_location_add_contact(struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, struct ast_sip_endpoint *endpoint)
Add a new contact to an AOR.
Definition: location.c:429
void ast_sip_location_retrieve_contact_and_aor_from_list(const char *aor_list, struct ast_sip_aor **aor, struct ast_sip_contact **contact)
Retrieve the first bound contact AND the AOR chosen from a list of AORs.
Definition: location.c:266
struct ast_sip_endpoint * ast_sip_get_artificial_endpoint(void)
Retrieves a reference to the artificial endpoint.
pjsip_media_type pjsip_media_type_application_json
Definition: res_pjsip.c:3909
int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
Determine if an incoming request requires authentication.
Definition: res_pjsip.c:163
void ast_sip_report_mem_limit(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
Send a security event notification for when a memory limit is hit.
int ast_sip_send_response(pjsip_response_addr *res_addr, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
Send a response to an out of dialog request.
Definition: res_pjsip.c:2396
pjsip_generic_string_hdr * ast_sip_add_header2(pjsip_tx_data *tdata, const char *name, const char *value)
Add a header to an outbound SIP message, returning a pointer to the header.
Definition: res_pjsip.c:2023
void ast_sip_report_req_no_support(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, const char *req_type)
Send a security event notification for when a request is not supported.
struct ao2_container * ast_sip_get_endpoints(void)
Retrieve any endpoints available to sorcery.
int ast_copy_pj_str2(char **dest, const pj_str_t *src)
Create and copy a pj_str_t into a standard character buffer.
Definition: res_pjsip.c:2208
int ast_sip_get_host_ip(int af, pj_sockaddr *addr)
Retrieve the local host address in IP form.
Definition: res_pjsip.c:2480
int ast_sip_for_each_auth(const struct ast_sip_auth_vector *array, ao2_callback_fn on_auth, void *arg)
For every auth in the array call the given 'on_auth' handler.
Definition: config_auth.c:135
void ast_sip_report_auth_success(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
Send a security event notification for when authentication succeeds.
struct ao2_container * ast_sip_get_transport_states(void)
Retrieves all transport states.
ast_sip_session_redirect
Definition: res_pjsip.h:651
@ AST_SIP_REDIRECT_URI_CORE
Definition: res_pjsip.h:655
@ AST_SIP_REDIRECT_URI_PJSIP
Definition: res_pjsip.h:657
@ AST_SIP_REDIRECT_USER
Definition: res_pjsip.h:653
int ast_sip_create_response(const pjsip_rx_data *rdata, int st_code, struct ast_sip_contact *contact, pjsip_tx_data **p_tdata)
General purpose method for creating a SIP response.
Definition: res_pjsip.c:2468
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
Definition: res_pjsip.c:117
void * ast_sip_endpoint_alloc(const char *name)
Allocate a new SIP endpoint.
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
Definition: location.c:147
int ast_sip_is_allowed_uri(pjsip_uri *uri)
Check whether a pjsip_uri is allowed or not.
Definition: res_pjsip.c:3472
pjsip_dialog * ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *aor_name, const char *request_user)
General purpose method for creating a UAC dialog with an endpoint.
Definition: res_pjsip.c:964
int ast_sip_for_each_channel_snapshot(const struct ast_endpoint_snapshot *endpoint_snapshot, ao2_callback_fn on_channel_snapshot, void *arg)
For every channel snapshot on an endpoint snapshot call the given 'on_channel_snapshot' handler.
struct ao2_container * ast_sip_location_retrieve_aor_contacts_nolock_filtered(const struct ast_sip_aor *aor, unsigned int flags)
Retrieve all contacts currently available for an AOR without locking the AOR and filter based on flag...
Definition: location.c:219
void ast_sip_transport_state_register(struct ast_sip_tpmgr_state_callback *element)
Register a transport state notification callback element.
void ast_sip_cleanup_auths(struct ast_sip_auth *auths[], size_t num_auths)
Clean up retrieved auth structures from memory.
int ast_sip_for_each_contact(const struct ast_sip_aor *aor, ao2_callback_fn on_contact, void *arg)
For every contact on an AOR call the given 'on_contact' handler.
Definition: location.c:722
const int ast_sip_hangup_sip2cause(int cause)
Convert SIP hangup causes to Asterisk hangup causes.
Definition: res_pjsip.c:3531
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_key(const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *ao2_data)
Register a reliable transport shutdown monitor callback.
int ast_sip_rewrite_uri_to_local(pjsip_sip_uri *uri, pjsip_tx_data *tdata)
Replace domain and port of SIP URI to point to (external) signaling address of this Asterisk instance...
Definition: res_pjsip.c:605
int ast_sip_format_auths_ami(const struct ast_sip_auth_vector *auths, struct ast_sip_ami *ami)
Format auth details for AMI.
Definition: config_auth.c:195
int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge, pjsip_tx_data *tdata, pjsip_tx_data **new_request)
Create a response to an authentication challenge.
Definition: res_pjsip.c:214
int ast_sip_for_each_aor(const char *aors, ao2_callback_fn on_aor, void *arg)
For every aor in the comma separated aors string call the given 'on_aor' handler.
Definition: location.c:687
struct ast_sip_contact * ast_sip_location_retrieve_first_aor_contact_filtered(const struct ast_sip_aor *aor, unsigned int flags)
Retrieve the first bound contact for an AOR and filter based on flags.
Definition: location.c:199
int ast_sip_set_id_connected_line(struct pjsip_rx_data *rdata, struct ast_party_id *id)
Set the ID for a connected line update.
Definition: res_pjsip.c:2822
pjsip_media_type pjsip_media_type_application_sdp
Definition: res_pjsip.c:3916
ast_sip_session_media_encryption
Definition: res_pjsip.h:640
@ AST_SIP_MEDIA_ENCRYPT_SDES
Definition: res_pjsip.h:646
@ AST_SIP_MEDIA_TRANSPORT_INVALID
Definition: res_pjsip.h:642
@ AST_SIP_MEDIA_ENCRYPT_NONE
Definition: res_pjsip.h:644
@ AST_SIP_MEDIA_ENCRYPT_DTLS
Definition: res_pjsip.h:648
void ast_sip_register_supplement(struct ast_sip_supplement *supplement)
Register a supplement to SIP out of dialog processing.
Definition: res_pjsip.c:1456
void ast_sip_add_date_header(pjsip_tx_data *tdata)
Adds a Date header to the tdata, formatted like: Date: Wed, 01 Jan 2021 14:53:01 GMT.
Definition: res_pjsip.c:90
pjsip_media_type pjsip_media_type_text_plain
Definition: res_pjsip.c:3920
void ast_sip_report_auth_challenge_sent(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata)
Send a security event notification for when an authentication challenge is sent.
void ast_sip_message_apply_transport(const char *transport_name, pjsip_tx_data *tdata)
Apply the configuration for a transport to an outgoing message.
void ast_sip_unregister_outbound_authenticator(struct ast_sip_outbound_authenticator *auth)
Unregister an outbound SIP authenticator.
Definition: res_pjsip.c:203
int ast_sip_set_id_from_invite(struct pjsip_rx_data *rdata, struct ast_party_id *id, struct ast_party_id *default_id, int trust_inbound)
Set the ID from an INVITE.
Definition: res_pjsip.c:2827
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_replace(pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *ao2_data, ast_transport_monitor_data_matcher matches)
Register a reliable transport shutdown monitor callback replacing any duplicate.
pjsip_media_type pjsip_media_type_application_pidf_xml
Definition: res_pjsip.c:3911
void ast_sip_transport_monitor_unregister(pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches)
Unregister a reliable transport shutdown monitor.
int ast_sip_auths_to_str(const struct ast_sip_auth_vector *auths, char **buf)
Converts an auths array to a string of comma separated values.
int ast_sip_create_rdata(pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port, char *transport_type, const char *local_name, int local_port)
General purpose method for creating an rdata structure using specific information.
Definition: res_pjsip.c:1266
enum ast_sip_check_auth_result ast_sip_check_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata)
Method to determine authentication status of an incoming request.
Definition: res_pjsip.c:179
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:520
int ast_sip_register_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
Register a SIP endpoint identifier.
Definition: res_pjsip.c:310
struct ast_endpoint_snapshot * ast_sip_get_endpoint_snapshot(const struct ast_sip_endpoint *endpoint)
Retrieve the endpoint snapshot for an endpoint.
void * ast_sip_dict_get(void *ht, const char *key)
Retrieves the value associated with the given key.
Definition: res_pjsip.c:2327
unsigned int ast_sip_get_send_contact_status_on_update_registration(void)
Retrieve the global setting 'send_contact_status_on_update_registration'.
int ast_sip_update_from(pjsip_tx_data *tdata, char *from)
Overwrite fields in the outbound 'From' header.
Definition: res_pjsip.c:3383
ast_sip_supplement_priority
Definition: res_pjsip.h:3178
@ AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL
Definition: res_pjsip.h:3185
@ AST_SIP_SUPPLEMENT_PRIORITY_FIRST
Definition: res_pjsip.h:3180
@ AST_SIP_SUPPLEMENT_PRIORITY_LAST
Definition: res_pjsip.h:3187
int ast_sip_format_endpoint_ami(struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami, int *count)
Formats the endpoint and sends over AMI.
Definition: res_pjsip.c:501
int ast_sip_dtmf_to_str(const enum ast_sip_dtmf_mode dtmf, char *buf, size_t buf_len)
Convert the DTMF mode enum value into a string.
Definition: res_pjsip.c:2504
int ast_sip_str2rc(const char *name)
Convert name to SIP response code.
Definition: res_pjsip.c:3714
int ast_sip_set_tpselector_from_transport(const struct ast_sip_transport *transport, pjsip_tpselector *selector)
Sets pjsip_tpselector from ast_sip_transport.
Definition: res_pjsip.c:843
int ast_sip_retrieve_auths(const struct ast_sip_auth_vector *auths, struct ast_sip_auth **out)
Retrieve relevant SIP auth structures from sorcery.
struct ast_sip_endpoint * ast_pjsip_rdata_get_endpoint(pjsip_rx_data *rdata)
Get the looked-up endpoint on an out-of dialog request or response.
int ast_sip_is_uri_sip_sips(pjsip_uri *uri)
Check whether a pjsip_uri is SIP/SIPS or not.
Definition: res_pjsip.c:3467
int ast_sip_set_tpselector_from_ep_or_uri(const struct ast_sip_endpoint *endpoint, pjsip_sip_uri *sip_uri, pjsip_tpselector *selector)
Sets pjsip_tpselector from an endpoint or uri.
Definition: res_pjsip.c:911
void ast_sip_service_route_vector_destroy(struct ast_sip_service_route_vector *service_routes)
Destroy a vector of service routes.
void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
Unregister a SIP endpoint identifier.
Definition: res_pjsip.c:315
const char * ast_sip_get_contact_short_status_label(const enum ast_sip_contact_status_type status)
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
Definition: res_pjsip.c:2201
void ast_sip_security_mechanisms_vector_destroy(struct ast_sip_security_mechanism_vector *security_mechanisms)
Free contents of a security mechanism vector.
void ast_sip_transport_monitor_unregister_all(ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches)
Unregister a transport shutdown monitor from all reliable transports.
const char * ast_sip_call_codec_pref_to_str(struct ast_flags pref)
Convert the call codec preference flags to a string.
Definition: res_pjsip.c:2554
struct ast_sip_endpoint * ast_sip_identify_endpoint(pjsip_rx_data *rdata)
Determine the endpoint that has sent a SIP message.
Definition: res_pjsip.c:330
int ast_sip_send_out_of_dialog_request(pjsip_tx_data *tdata, struct ast_sip_endpoint *endpoint, int timeout, void *token, void(*callback)(void *token, pjsip_event *e))
General purpose method for sending an Out-Of-Dialog SIP request.
Definition: res_pjsip.c:1938
pjsip_dialog * ast_sip_create_dialog_uas_locked(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status)
General purpose method for creating a UAS dialog with an endpoint.
Definition: res_pjsip.c:1192
pjsip_media_type pjsip_media_type_application_simple_message_summary
Definition: res_pjsip.c:3915
struct ast_sip_transport_state * ast_sip_find_transport_state_in_use(struct ast_sip_request_transport_details *details)
Returns the transport state currently in use based on request transport details.
Definition: res_pjsip.c:595
int ast_sip_format_contact_ami(void *obj, void *arg, int flags)
Formats the contact and sends over AMI.
#define SIP_TLS_MAX_CIPHERS
Maximum number of ciphers supported for a TLS transport.
Definition: res_pjsip.h:104
int ast_sip_dlg_set_transport(const struct ast_sip_endpoint *endpoint, pjsip_dialog *dlg, pjsip_tpselector *selector)
Set the transport on a dialog.
Definition: res_pjsip.c:727
int ast_sip_is_media_type_in(pjsip_media_type *a,...) attribute_sentinel
Check if a media type is in a list of others.
Definition: res_pjsip.c:2228
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_replace_key(const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *ao2_data, ast_transport_monitor_data_matcher matches)
Register a reliable transport shutdown monitor callback replacing any duplicate.
unsigned int ast_sip_get_use_callerid_contact(void)
Retrieve the global setting 'use_callerid_contact'.
char * ast_sip_get_default_voicemail_extension(void)
Retrieve the default voicemail extension.
ast_sip_contact_filter
Contact retrieval filtering flags.
Definition: res_pjsip.h:1300
@ AST_SIP_CONTACT_FILTER_REACHABLE
Return only reachable or unknown contacts.
Definition: res_pjsip.h:1305
@ AST_SIP_CONTACT_FILTER_DEFAULT
Default filter flags.
Definition: res_pjsip.h:1302
void ast_sip_unregister_authenticator(struct ast_sip_authenticator *auth)
Unregister a SIP authenticator.
Definition: res_pjsip.c:152
unsigned int ast_sip_get_contact_expiration_check_interval(void)
Retrieve the system contact expiration check interval setting.
int ast_sip_persistent_endpoint_update_state(const char *endpoint_name, enum ast_endpoint_state state)
Change state of a persistent endpoint.
int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, void *token, void(*callback)(void *token, pjsip_event *e))
General purpose method for sending a SIP request.
Definition: res_pjsip.c:1979
const char * ast_sip_get_device_state(const struct ast_sip_endpoint *endpoint)
Retrieve the device state for an endpoint.
long ast_sip_threadpool_queue_size(void)
Return the size of the SIP threadpool's task queue.
Definition: res_pjsip.c:3457
struct ast_sip_endpoint * ast_sip_default_outbound_endpoint(void)
Retrieve the default outbound endpoint.
int ast_sip_set_request_transport_details(struct ast_sip_request_transport_details *details, pjsip_tx_data *tdata, int use_ipv6)
Sets request transport details based on tdata.
Definition: res_pjsip.c:648
void ast_sip_report_invalid_endpoint(const char *name, pjsip_rx_data *rdata)
Send a security event notification for when an invalid endpoint is requested.
int ast_sip_register_outbound_authenticator(struct ast_sip_outbound_authenticator *outbound_auth)
Register an outbound SIP authenticator.
Definition: res_pjsip.c:191
void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Register an endpoint formatter.
Definition: res_pjsip.c:481
int ast_sip_add_global_request_header(const char *name, const char *value, int replace)
int ast_sip_add_body(pjsip_tx_data *tdata, const struct ast_sip_body *body)
Add a body to an outbound SIP message.
Definition: res_pjsip.c:2052
int ast_sip_security_mechanisms_to_str(const struct ast_sip_security_mechanism_vector *security_mechanisms, int add_qvalue, char **buf)
Writes the security mechanisms of an endpoint into a buffer as a string and returns the buffer.
void * ast_sip_dict_set(pj_pool_t *pool, void *ht, const char *key, void *val)
Set the value for the given key.
Definition: res_pjsip.c:2338
int ast_sip_are_media_types_equal(pjsip_media_type *a, pjsip_media_type *b)
Compare pjsip media types.
Definition: res_pjsip.c:2219
void ast_sip_tpselector_unref(pjsip_tpselector *selector)
Unreference a pjsip_tpselector.
Definition: res_pjsip.c:923
void ast_sip_get_default_realm(char *realm, size_t size)
Retrieve the global default realm.
struct ao2_container * ast_sip_location_retrieve_aor_contacts_nolock(const struct ast_sip_aor *aor)
Retrieve all contacts currently available for an AOR without locking the AOR.
Definition: location.c:214
int ast_sip_get_transport_name(const struct ast_sip_endpoint *endpoint, pjsip_sip_uri *sip_uri, char *buf, size_t buf_len)
Get the transport name from an endpoint or request uri.
Definition: res_pjsip.c:698
unsigned int ast_sip_get_disable_multi_domain(void)
Retrieve the system setting 'disable multi domain'.
void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Unregister an endpoint formatter.
Definition: res_pjsip.c:487
int ast_sip_retrieve_auths_vector(const struct ast_sip_auth_vector *auth_ids, struct ast_sip_auth_objects_vector *auth_objects)
Retrieve relevant SIP auth structures from sorcery as a vector.
ast_sip_dtmf_mode
DTMF modes for SIP endpoints.
Definition: res_pjsip.h:540
@ AST_SIP_DTMF_NONE
Definition: res_pjsip.h:542
@ AST_SIP_DTMF_AUTO_INFO
Definition: res_pjsip.h:553
@ AST_SIP_DTMF_AUTO
Definition: res_pjsip.h:551
@ AST_SIP_DTMF_INBAND
Definition: res_pjsip.h:547
@ AST_SIP_DTMF_INFO
Definition: res_pjsip.h:549
@ AST_SIP_DTMF_RFC_4733
Definition: res_pjsip.h:545
unsigned int ast_sip_get_ignore_uri_user_options(void)
Retrieve the global setting 'ignore_uri_user_options'.
int ast_sip_register_authenticator(struct ast_sip_authenticator *auth)
Register a SIP authenticator.
Definition: res_pjsip.c:140
static const pj_str_t AST_PJ_STR_EMPTY
Definition: res_pjsip.h:111
struct ast_sip_service_route_vector * ast_sip_service_route_vector_alloc(void)
Allocate a vector of service routes.
struct ast_sip_contact * ast_sip_location_retrieve_contact(const char *contact_name)
Retrieve a named contact.
Definition: location.c:350
enum ast_transport_monitor_reg ast_sip_transport_monitor_register(pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *ao2_data)
Register a reliable transport shutdown monitor callback.
int ast_sip_str_to_security_mechanism(struct ast_sip_security_mechanism **security_mechanism, const char *value)
Allocate a security mechanism from a string.
int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf)
Converts a sorcery object to a string of object properties.
void ast_sip_transport_state_unregister(struct ast_sip_tpmgr_state_callback *element)
Unregister a transport state notification callback element.
int ast_sip_add_body_multipart(pjsip_tx_data *tdata, const struct ast_sip_body *bodies[], int num_bodies)
Add a multipart body to an outbound SIP message.
Definition: res_pjsip.c:2059
ast_sip_auth_type
Methods of storing SIP digest authentication credentials.
Definition: res_pjsip.h:563
@ AST_SIP_AUTH_TYPE_GOOGLE_OAUTH
Definition: res_pjsip.h:569
@ AST_SIP_AUTH_TYPE_ARTIFICIAL
Definition: res_pjsip.h:571
@ AST_SIP_AUTH_TYPE_MD5
Definition: res_pjsip.h:567
@ AST_SIP_AUTH_TYPE_USER_PASS
Definition: res_pjsip.h:565
pjsip_media_type pjsip_media_type_application_rlmi_xml
Definition: res_pjsip.c:3914
ast_transport_monitor_reg
Definition: res_pjsip.h:3934
@ AST_TRANSPORT_MONITOR_REG_NOT_FOUND
Transport not found to monitor.
Definition: res_pjsip.h:3943
@ AST_TRANSPORT_MONITOR_REG_REPLACED
Replaced the already existing transport monitor with new one.
Definition: res_pjsip.h:3938
@ AST_TRANSPORT_MONITOR_REG_FAILED
Error while registering transport monitor.
Definition: res_pjsip.h:3945
@ AST_TRANSPORT_MONITOR_REG_SUCCESS
Successfully registered the transport monitor.
Definition: res_pjsip.h:3936
void(* ast_transport_monitor_shutdown_cb)(void *data)
Transport shutdown monitor callback.
Definition: res_pjsip.h:3920
int ast_sip_add_global_response_header(const char *name, const char *value, int replace)
struct ao2_container * ast_sip_location_retrieve_contacts_from_aor_list(const char *aor_list)
Retrieve all contacts from a list of AORs.
Definition: location.c:335
int ast_sip_update_to_uri(pjsip_tx_data *tdata, const char *to)
Replace the To URI in the tdata with the supplied one.
Definition: res_pjsip.c:3323
pjsip_media_type pjsip_media_type_multipart_mixed
Definition: res_pjsip.c:3918
void ast_sip_report_auth_failed_challenge_response(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
Send a security event notification for when a challenge response has failed.
void ast_sip_remove_headers_by_name_and_value(pjsip_msg *msg, const pj_str_t *hdr_name, const char *value)
Removes all headers of a specific name and value from a pjsip_msg.
pjsip_media_type pjsip_media_type_application_xpidf_xml
Definition: res_pjsip.c:3912
void ast_sip_location_retrieve_contact_and_aor_from_list_filtered(const char *aor_list, unsigned int flags, struct ast_sip_aor **aor, struct ast_sip_contact **contact)
Retrieve the first bound contact AND the AOR chosen from a list of AORs and filter based on flags.
Definition: location.c:272
int ast_sip_set_outbound_proxy(pjsip_tx_data *tdata, const char *proxy)
Set the outbound proxy for an outbound SIP message.
Definition: res_pjsip.c:1992
struct ast_sip_transport_state * ast_sip_get_transport_state(const char *transport_id)
Retrieve transport state.
unsigned int ast_sip_get_mwi_disable_initial_unsolicited(void)
Retrieve the global setting 'disable sending unsolicited mwi on startup'.
void ast_sip_auth_vector_destroy(struct ast_sip_auth_vector *vector)
Free contents of an auth vector.
struct ast_threadpool * ast_sip_threadpool(void)
Retrieve the SIP threadpool object.
Definition: res_pjsip.c:3462
int ast_sip_register_endpoint_identifier_with_name(struct ast_sip_endpoint_identifier *identifier, const char *name)
Register a SIP endpoint identifier with a name.
Definition: res_pjsip.c:233
pjsip_media_type pjsip_media_type_multipart_alternative
Definition: res_pjsip.c:3917
ast_sip_security_negotiation
The kind of security negotiation.
Definition: res_pjsip.h:350
@ AST_SIP_SECURITY_NEG_MEDIASEC
Definition: res_pjsip.h:354
@ AST_SIP_SECURITY_NEG_NONE
Definition: res_pjsip.h:352
int ast_sip_set_tpselector_from_transport_name(const char *transport_name, pjsip_tpselector *selector)
Sets pjsip_tpselector from ast_sip_transport.
Definition: res_pjsip.c:893
int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, const char *uri, struct ast_sip_contact *contact, pjsip_tx_data **tdata)
General purpose method for creating a SIP request.
Definition: res_pjsip.c:1435
struct ast_str * ast_sip_create_ami_event(const char *event, struct ast_sip_ami *ami)
Creates a string to store AMI event data in.
int ast_sip_get_mwi_tps_queue_low(void)
Retrieve the global MWI taskprocessor low water clear alert level.
struct ast_sip_contact * ast_sip_location_create_contact(struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, int prune_on_boot, struct ast_sip_endpoint *endpoint)
Create a new contact for an AOR without locking the AOR.
Definition: location.c:355
int ast_sip_str_to_dtmf(const char *dtmf_mode)
Convert the DTMF mode name into an enum.
Definition: res_pjsip.c:2533
int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
Add a header to an outbound SIP message.
Definition: res_pjsip.c:2008
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
const pj_str_t * ast_sip_pjsip_uri_get_hostname(pjsip_uri *uri)
Get the host portion of the pjsip_uri.
Definition: res_pjsip.c:3496
char * ast_sip_get_regcontext(void)
Retrieve the global regcontext setting.
ast_sip_check_auth_result
Possible returns from ast_sip_check_authentication.
Definition: res_pjsip.h:1228
@ AST_SIP_AUTHENTICATION_CHALLENGE
Definition: res_pjsip.h:1230
@ AST_SIP_AUTHENTICATION_ERROR
Definition: res_pjsip.h:1236
@ AST_SIP_AUTHENTICATION_SUCCESS
Definition: res_pjsip.h:1232
@ AST_SIP_AUTHENTICATION_FAILED
Definition: res_pjsip.h:1234
ast_sip_call_codec_pref
Incoming/Outgoing call offer/answer joint codec preference.
Definition: res_pjsip.h:665
@ AST_SIP_CALL_CODEC_PREF_ALL
Definition: res_pjsip.h:674
@ AST_SIP_CALL_CODEC_PREF_LOCAL
Definition: res_pjsip.h:680
@ AST_SIP_CALL_CODEC_PREF_REMOTE
Definition: res_pjsip.h:682
@ AST_SIP_CALL_CODEC_PREF_UNION
Definition: res_pjsip.h:670
@ AST_SIP_CALL_CODEC_PREF_FIRST
Definition: res_pjsip.h:676
@ AST_SIP_CALL_CODEC_PREF_INTERSECT
Definition: res_pjsip.h:668
const char * ast_sip_auth_type_to_str(enum ast_sip_auth_type type)
Converts the given auth type to a string.
Definition: config_auth.c:80
struct ast_sip_contact_status * ast_sip_get_contact_status(const struct ast_sip_contact *contact)
Retrieve the current status for a contact.
int(* ast_sip_dialog_outbound_auth_cb)(pjsip_dialog *dlg, pjsip_tx_data *tdata, void *user_data)
Callback called when an outbound request with authentication credentials is to be sent in dialog.
Definition: res_pjsip.h:1764
int ast_sip_security_mechanism_vector_init(struct ast_sip_security_mechanism_vector *security_mechanism, const char *value)
Initialize security mechanism vector from string of security mechanisms.
int ast_sip_location_update_contact(struct ast_sip_contact *contact)
Update a contact.
Definition: location.c:445
const char * ast_sip_get_contact_status_label(const enum ast_sip_contact_status_type status)
translate ast_sip_contact_status_type to character string.
int ast_sip_send_stateful_response(pjsip_rx_data *rdata, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
Send a stateful response to an out of dialog request.
Definition: res_pjsip.c:2424
int ast_sip_for_each_channel(const struct ast_sip_endpoint *endpoint, ao2_callback_fn on_channel_snapshot, void *arg)
For every channel snapshot on an endpoint all the given 'on_channel_snapshot' handler.
int ast_sip_auth_vector_init(struct ast_sip_auth_vector *vector, const char *auth_names)
Initialize an auth vector with the configured values.
ast_sip_contact_status_type
Status type for a contact.
Definition: res_pjsip.h:431
@ AVAILABLE
Definition: res_pjsip.h:435
@ UNAVAILABLE
Definition: res_pjsip.h:433
@ REMOVED
Definition: res_pjsip.h:440
@ UNKNOWN
Definition: res_pjsip.h:437
@ CREATED
Definition: res_pjsip.h:439
void ast_sip_get_default_from_user(char *from_user, size_t size)
Retrieve the global default from user.
unsigned int ast_sip_get_mwi_tps_queue_high(void)
Retrieve the global MWI taskprocessor high water alert trigger level.
int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype)
Checks if the given content type matches type/subtype.
Definition: res_pjsip.c:2248
void ast_sip_transport_monitor_unregister_key(const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches)
Unregister a reliable transport shutdown monitor.
int ast_sip_append_body(pjsip_tx_data *tdata, const char *body_text)
Append body data to a SIP message.
Definition: res_pjsip.c:2075
int ast_sip_add_security_headers(struct ast_sip_security_mechanism_vector *security_mechanisms, const char *header_name, int add_qval, pjsip_tx_data *tdata)
Add security headers to transmission data.
int ast_sip_contact_to_str(void *object, void *arg, int flags)
Handler used to convert a contact to a string.
Definition: location.c:770
struct ast_sip_contact * ast_sip_location_retrieve_first_aor_contact(const struct ast_sip_aor *aor)
Retrieve the first bound contact for an AOR.
Definition: location.c:194
int ast_sip_transport_state_set_preferred_identity(const char *transport_name, const char *identity)
Sets the P-Preferred-Identity on a child transport.
unsigned int ast_sip_get_all_codecs_on_empty_reinvite(void)
Retrieve the system setting 'all_codecs_on_empty_reinvite'.
void ast_sip_location_prune_boot_contacts(void)
Prune the prune_on_boot contacts.
Definition: location.c:469
ast_sip_100rel_mode
100rel modes for SIP endpoints
Definition: res_pjsip.h:526
@ AST_SIP_100REL_PEER_SUPPORTED
Definition: res_pjsip.h:532
@ AST_SIP_100REL_UNSUPPORTED
Definition: res_pjsip.h:528
@ AST_SIP_100REL_SUPPORTED
Definition: res_pjsip.h:530
@ AST_SIP_100REL_REQUIRED
Definition: res_pjsip.h:534
struct ao2_container * ast_sip_location_retrieve_aor_contacts(const struct ast_sip_aor *aor)
Retrieve all contacts currently available for an AOR.
Definition: location.c:247
ast_sip_direct_media_glare_mitigation
Definition: res_pjsip.h:627
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_NONE
Definition: res_pjsip.h:629
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_INCOMING
Definition: res_pjsip.h:637
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_OUTGOING
Definition: res_pjsip.h:633
pjsip_media_type pjsip_media_type_application_cpim_xpidf_xml
Definition: res_pjsip.c:3913
struct ao2_container * ast_sip_location_retrieve_aor_contacts_filtered(const struct ast_sip_aor *aor, unsigned int flags)
Retrieve all contacts currently available for an AOR and filter based on flags.
Definition: location.c:252
pjsip_sip_uri * ast_sip_get_contact_sip_uri(pjsip_tx_data *tdata)
Return the SIP URI of the Contact header.
Definition: res_pjsip.c:564
int ast_sip_location_delete_contact(struct ast_sip_contact *contact)
Delete a contact.
Definition: location.c:450
int ast_sip_create_rdata_with_contact(pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port, char *transport_type, const char *local_name, int local_port, const char *contact_uri)
General purpose method for creating an rdata structure using specific information.
Definition: res_pjsip.c:1214
pjsip_media_type pjsip_media_type_multipart_related
Definition: res_pjsip.c:3919
int ast_sip_failover_request(pjsip_tx_data *tdata)
Set a request to use the next value in the list of resolved addresses.
Definition: res_pjsip.c:1816
void ast_sip_report_failed_acl(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, const char *name)
Send a security event notification for when an ACL check fails.
int ast_sip_location_add_contact_nolock(struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, struct ast_sip_endpoint *endpoint)
Add a new contact to an AOR without locking the AOR.
Definition: location.c:416
int ast_sip_transport_state_set_service_routes(const char *transport_name, struct ast_sip_service_route_vector *service_routes)
Sets the service routes on a child transport.
ast_sip_session_refresh_method
Definition: res_pjsip.h:620
@ AST_SIP_SESSION_REFRESH_METHOD_UPDATE
Definition: res_pjsip.h:624
@ AST_SIP_SESSION_REFRESH_METHOD_INVITE
Definition: res_pjsip.h:622
void ast_sip_get_unidentified_request_thresholds(unsigned int *count, unsigned int *period, unsigned int *prune_interval)
Retrieve the unidentified request security event thresholds.
char * ast_sip_get_debug(void)
Retrieve the system debug setting (yes|no|host).
void ast_sip_modify_id_header(pj_pool_t *pool, pjsip_fromto_hdr *id_hdr, const struct ast_party_id *id)
Set name and number information on an identity header.
Definition: res_pjsip.c:2850
static void challenge(const char *realm, pjsip_tx_data *tdata, const pjsip_rx_data *rdata, int is_stale)
astobj2 callback for adding digest challenges to responses
Pluggable RTP Architecture.
Sorcery Data Access Layer API.
Endpoint abstractions.
Media Stream API.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definition: stringfields.h:341
#define AST_STRING_FIELD(name)
Declare a string field.
Definition: stringfields.h:303
Generic container type.
Wrapper for an ast_acl linked list.
Definition: acl.h:76
Definition: dnsmgr.c:66
A snapshot of an endpoint's state.
Structure used to handle boolean flags.
Definition: utils.h:199
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
internal representation of ACL entries In principle user applications would have no need for this,...
Definition: acl.h:51
Information needed to identify an endpoint in a call.
Definition: channel.h:340
DTLS configuration structure.
Definition: rtp_engine.h:605
AMI variable container.
Definition: res_pjsip.h:3046
const char * action_id
Definition: res_pjsip.h:3052
struct mansession * s
Definition: res_pjsip.h:3048
void * arg
Definition: res_pjsip.h:3054
const struct message * m
Definition: res_pjsip.h:3050
A SIP address of record.
Definition: res_pjsip.h:475
SORCERY_OBJECT(details)
unsigned int minimum_expiration
Definition: res_pjsip.h:485
unsigned int remove_existing
Definition: res_pjsip.h:497
double qualify_timeout
Definition: res_pjsip.h:503
char * voicemail_extension
Definition: res_pjsip.h:505
unsigned int max_contacts
Definition: res_pjsip.h:495
unsigned int support_path
Definition: res_pjsip.h:501
struct ao2_container * permanent_contacts
Definition: res_pjsip.h:499
unsigned int remove_unavailable
Definition: res_pjsip.h:507
const ast_string_field outbound_proxy
Definition: res_pjsip.h:483
unsigned int maximum_expiration
Definition: res_pjsip.h:487
const ast_string_field mailboxes
Definition: res_pjsip.h:483
unsigned int default_expiration
Definition: res_pjsip.h:489
int authenticate_qualify
Definition: res_pjsip.h:493
unsigned int qualify_frequency
Definition: res_pjsip.h:491
SORCERY_OBJECT(details)
const ast_string_field oauth_clientid
Definition: res_pjsip.h:594
const ast_string_field oauth_secret
Definition: res_pjsip.h:594
const ast_string_field md5_creds
Definition: res_pjsip.h:594
const ast_string_field realm
Definition: res_pjsip.h:594
unsigned int nonce_lifetime
Definition: res_pjsip.h:596
const ast_string_field auth_user
Definition: res_pjsip.h:594
const ast_string_field refresh_token
Definition: res_pjsip.h:594
const ast_string_field auth_pass
Definition: res_pjsip.h:594
enum ast_sip_auth_type type
Definition: res_pjsip.h:598
An interchangeable way of handling digest authentication for SIP.
Definition: res_pjsip.h:1246
enum ast_sip_check_auth_result(* check_authentication)(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata)
Check that an incoming request passes authentication.
Definition: res_pjsip.h:1261
int(* requires_authentication)(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
Check if a request requires authentication See ast_sip_requires_authentication for more details.
Definition: res_pjsip.h:1251
SIP body description.
Definition: res_pjsip.h:2324
const char * type
Definition: res_pjsip.h:2326
const char * body_text
Definition: res_pjsip.h:2330
const char * subtype
Definition: res_pjsip.h:2328
A contact's status.
Definition: res_pjsip.h:448
const ast_string_field uri
Definition: res_pjsip.h:454
enum ast_sip_contact_status_type status
Definition: res_pjsip.h:465
enum ast_sip_contact_status_type last_status
Definition: res_pjsip.h:467
const ast_string_field aor
Definition: res_pjsip.h:454
struct ast_sip_security_mechanism_vector security_mechanisms
Definition: res_pjsip.h:463
A wrapper for contact that adds the aor_id and a consistent contact id. Used by ast_sip_for_each_cont...
Definition: res_pjsip.h:514
struct ast_sip_contact * contact
Definition: res_pjsip.h:520
Contact associated with an address of record.
Definition: res_pjsip.h:389
SORCERY_OBJECT(details)
const ast_string_field uri
Definition: res_pjsip.h:411
double qualify_timeout
Definition: res_pjsip.h:419
struct ast_sip_endpoint * endpoint
Definition: res_pjsip.h:421
const ast_string_field via_addr
Definition: res_pjsip.h:411
const ast_string_field call_id
Definition: res_pjsip.h:411
const ast_string_field aor
Definition: res_pjsip.h:411
const ast_string_field outbound_proxy
Definition: res_pjsip.h:411
struct timeval expiration_time
Definition: res_pjsip.h:413
const ast_string_field path
Definition: res_pjsip.h:411
const ast_string_field endpoint_name
Definition: res_pjsip.h:411
int authenticate_qualify
Definition: res_pjsip.h:417
const ast_string_field reg_server
Definition: res_pjsip.h:411
const ast_string_field user_agent
Definition: res_pjsip.h:411
unsigned int qualify_frequency
Definition: res_pjsip.h:415
Direct media options for SIP endpoints.
Definition: res_pjsip.h:871
enum ast_sip_direct_media_glare_mitigation glare_mitigation
Definition: res_pjsip.h:877
enum ast_sip_session_refresh_method method
Definition: res_pjsip.h:875
const ast_string_field domain
Definition: res_pjsip.h:320
Endpoint configuration for SIP extensions.
Definition: res_pjsip.h:712
struct ast_sip_timer_options timer
Definition: res_pjsip.h:716
An entity responsible formatting endpoint information.
Definition: res_pjsip.h:3072
int(* format_ami)(const struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami)
Callback used to format endpoint information over AMI.
Definition: res_pjsip.h:3076
Party identification options for endpoints.
Definition: res_pjsip.h:766
struct ast_party_id self
Definition: res_pjsip.h:767
enum ast_sip_session_refresh_method refresh_method
Definition: res_pjsip.h:785
An entity responsible for identifying the source of a SIP message.
Definition: res_pjsip.h:1289
Endpoint configuration options for INFO packages.
Definition: res_pjsip.h:821
struct ast_sip_info_recording_configuration recording
Definition: res_pjsip.h:823
Media configuration for SIP endpoints.
Definition: res_pjsip.h:900
struct ast_sip_media_rtp_configuration rtp
Definition: res_pjsip.h:910
struct ast_stream_topology * topology
Definition: res_pjsip.h:918
struct ast_format_cap * codecs
Definition: res_pjsip.h:916
const ast_string_field sdpowner
Definition: res_pjsip.h:908
struct ast_stream_codec_negotiation_prefs codec_prefs_incoming_offer
Definition: res_pjsip.h:946
struct ast_stream_codec_negotiation_prefs codec_prefs_incoming_answer
Definition: res_pjsip.h:950
struct ast_sip_direct_media_configuration direct_media
Definition: res_pjsip.h:912
struct ast_stream_codec_negotiation_prefs codec_prefs_outgoing_offer
Definition: res_pjsip.h:948
struct ast_flags incoming_call_offer_pref
Definition: res_pjsip.h:942
struct ast_flags outgoing_call_offer_pref
Definition: res_pjsip.h:944
struct ast_sip_t38_configuration t38
Definition: res_pjsip.h:914
const ast_string_field sdpsession
Definition: res_pjsip.h:908
struct ast_stream_codec_negotiation_prefs codec_prefs_outgoing_answer
Definition: res_pjsip.h:952
NAT configuration options for endpoints.
Definition: res_pjsip.h:754
Call pickup configuration options for endpoints.
Definition: res_pjsip.h:793
struct ast_namedgroups * named_pickupgroups
Definition: res_pjsip.h:801
struct ast_namedgroups * named_callgroups
Definition: res_pjsip.h:799
Endpoint subscription configuration.
Definition: res_pjsip.h:740
struct ast_sip_mwi_configuration mwi
Definition: res_pjsip.h:746
An entity with which Asterisk communicates.
Definition: res_pjsip.h:958
struct ast_sip_auth_vector outbound_auths
Definition: res_pjsip.h:1005
SORCERY_OBJECT(details)
const ast_string_field language
Definition: res_pjsip.h:987
const ast_string_field zone
Definition: res_pjsip.h:987
enum ast_sip_endpoint_identifier_type ident_method
Definition: res_pjsip.h:1009
char * contact_user
Definition: res_pjsip.h:1037
struct ast_endpoint * persistent
Definition: res_pjsip.h:1015
enum ast_sip_session_redirect redirect_method
Definition: res_pjsip.h:1023
unsigned int faxdetect_timeout
Definition: res_pjsip.h:1035
const ast_string_field incoming_mwi_mailbox
Definition: res_pjsip.h:987
const ast_string_field transport
Definition: res_pjsip.h:987
struct ast_sip_endpoint_id_configuration id
Definition: res_pjsip.h:997
const ast_string_field mohsuggest
Definition: res_pjsip.h:987
const ast_string_field aors
Definition: res_pjsip.h:987
const ast_string_field accountcode
Definition: res_pjsip.h:987
unsigned int send_aoc
Definition: res_pjsip.h:1069
unsigned int moh_passthrough
Definition: res_pjsip.h:1029
struct ast_sip_endpoint_pickup_configuration pickup
Definition: res_pjsip.h:1001
enum ast_sip_security_negotiation security_negotiation
Definition: res_pjsip.h:1053
unsigned int refer_blind_progress
Definition: res_pjsip.h:1045
unsigned int preferred_codec_only
Definition: res_pjsip.h:1039
struct ast_sip_identify_by_vector ident_method_order
Definition: res_pjsip.h:1011
AST_STRING_FIELD_EXTENDED(overlap_context)
struct ast_sip_endpoint_extensions extensions
Definition: res_pjsip.h:989
struct ast_sip_auth_vector inbound_auths
Definition: res_pjsip.h:1003
const ast_string_field context
Definition: res_pjsip.h:987
const ast_string_field message_context
Definition: res_pjsip.h:987
struct ast_sip_endpoint_media_configuration media
Definition: res_pjsip.h:991
int suppress_moh_on_sendonly
Definition: res_pjsip.h:1073
const ast_string_field outbound_proxy
Definition: res_pjsip.h:987
unsigned int notify_early_inuse_ringing
Definition: res_pjsip.h:1047
const ast_string_field fromdomain
Definition: res_pjsip.h:987
unsigned int stir_shaken
Definition: res_pjsip.h:1057
const ast_string_field stir_shaken_profile
Definition: res_pjsip.h:987
unsigned int suppress_q850_reason_headers
Definition: res_pjsip.h:1049
unsigned int ignore_183_without_sdp
Definition: res_pjsip.h:1051
unsigned int allow_unauthenticated_options
Definition: res_pjsip.h:1059
struct ast_acl_list * contact_acl
Definition: res_pjsip.h:1033
unsigned int allow_overlap
Definition: res_pjsip.h:1043
unsigned int usereqphone
Definition: res_pjsip.h:1027
AST_STRING_FIELD_EXTENDED(tenantid)
enum ast_sip_dtmf_mode dtmf
Definition: res_pjsip.h:1007
struct ast_acl_list * acl
Definition: res_pjsip.h:1031
const ast_string_field fromuser
Definition: res_pjsip.h:987
unsigned int inband_progress
Definition: res_pjsip.h:1013
struct ast_sip_endpoint_subscription_configuration subscription
Definition: res_pjsip.h:993
struct ast_sip_endpoint_nat_configuration nat
Definition: res_pjsip.h:995
enum ast_sip_100rel_mode rel100
Definition: res_pjsip.h:1067
AST_STRING_FIELD_EXTENDED(geoloc_incoming_call_profile)
unsigned int allowtransfer
Definition: res_pjsip.h:1021
struct ast_sip_endpoint_info_configuration info
Definition: res_pjsip.h:999
AST_STRING_FIELD_EXTENDED(geoloc_outgoing_call_profile)
unsigned int devicestate_busy_at
Definition: res_pjsip.h:1017
unsigned int asymmetric_rtp_codec
Definition: res_pjsip.h:1041
unsigned int faxdetect
Definition: res_pjsip.h:1019
struct ast_sip_security_mechanism_vector security_mechanisms
Definition: res_pjsip.h:1055
struct ast_variable * channel_vars
Definition: res_pjsip.h:1025
Configuration for one-touch INFO recording.
Definition: res_pjsip.h:807
const ast_string_field onfeature
Definition: res_pjsip.h:813
const ast_string_field offfeature
Definition: res_pjsip.h:813
RTP configuration for SIP endpoints.
Definition: res_pjsip.h:829
struct ast_rtp_dtls_cfg dtls_cfg
DTLS-SRTP configuration information.
Definition: res_pjsip.h:849
const ast_string_field engine
Definition: res_pjsip.h:833
unsigned int use_received_transport
Definition: res_pjsip.h:847
enum ast_sip_session_media_encryption encryption
Definition: res_pjsip.h:853
unsigned int follow_early_media_fork
Definition: res_pjsip.h:863
unsigned int encryption_optimistic
Definition: res_pjsip.h:855
unsigned int accept_multiple_sdp_answers
Definition: res_pjsip.h:865
Endpoint configuration for unsolicited MWI.
Definition: res_pjsip.h:722
const ast_string_field mailboxes
Definition: res_pjsip.h:728
unsigned int aggregate
Definition: res_pjsip.h:730
const ast_string_field fromuser
Definition: res_pjsip.h:728
unsigned int subscribe_replaces_unsolicited
Definition: res_pjsip.h:732
Structure for SIP nat hook information.
Definition: res_pjsip.h:326
SORCERY_OBJECT(details)
void(* outgoing_external_message)(struct pjsip_tx_data *tdata, struct ast_sip_transport *transport)
Definition: res_pjsip.h:330
an interchangeable way of responding to authentication challenges
Definition: res_pjsip.h:1271
int(* create_request_with_auth)(const struct ast_sip_auth_vector *auths, struct pjsip_rx_data *challenge, struct pjsip_tx_data *old_request, struct pjsip_tx_data **new_request)
Create a new request with authentication credentials.
Definition: res_pjsip.h:1282
Structure which contains information about a transport.
Definition: res_pjsip.h:334
int local_port
Local port for transport.
Definition: res_pjsip.h:344
pjsip_transport * transport
Potential pointer to the transport itself, if UDP.
Definition: res_pjsip.h:338
enum ast_transport type
Type of transport.
Definition: res_pjsip.h:336
pjsip_tpfactory * factory
Potential pointer to the transport factory itself, if TCP/TLS.
Definition: res_pjsip.h:340
pj_str_t local_address
Local address for transport.
Definition: res_pjsip.h:342
struct timeval last_start
struct timeval when_queued
struct timeval last_end
enum ast_sip_scheduler_task_flags flags
Structure representing a security mechanism as defined in RFC 3329.
Definition: res_pjsip.h:375
struct ast_vector_string mechanism_parameters
Definition: res_pjsip.h:381
enum ast_sip_security_mechanism_type type
Definition: res_pjsip.h:377
A supplement to SIP message processing.
Definition: res_pjsip.h:3197
void(* outgoing_request)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata)
Called on an outgoing SIP request This method is always called from a SIP servant thread.
Definition: res_pjsip.h:3240
int(* incoming_request)(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata)
Called on incoming SIP request This method can indicate a failure in processing in its return....
Definition: res_pjsip.h:3219
void(* outgoing_response)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata)
Called on an outgoing SIP response This method is always called from a SIP servant thread.
Definition: res_pjsip.h:3245
void(* incoming_response)(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata)
Called on an incoming SIP response This method is always called from a SIP servant thread.
Definition: res_pjsip.h:3235
const char * method
Definition: res_pjsip.h:3199
enum ast_sip_supplement_priority priority
Definition: res_pjsip.h:3201
struct ast_sip_supplement * next
Definition: res_pjsip.h:3247
unsigned int maxdatagram
Definition: res_pjsip.h:888
unsigned int bind_udptl_to_media_address
Definition: res_pjsip.h:894
enum ast_t38_ec_modes error_correction
Definition: res_pjsip.h:886
Session timers options.
Definition: res_pjsip.h:699
unsigned int sess_expires
Definition: res_pjsip.h:703
unsigned int min_se
Definition: res_pjsip.h:701
struct ast_sip_tpmgr_state_callback::@257 node
pjsip_tp_state_callback cb
Definition: res_pjsip.h:4089
Structure for SIP transport information.
Definition: res_pjsip.h:116
struct pjsip_tpfactory * factory
Transport factory.
Definition: res_pjsip.h:120
pjsip_tls_setting tls
Definition: res_pjsip.h:140
struct ast_dnsmgr_entry * external_media_address_refresher
Definition: res_pjsip.h:168
enum ast_transport type
Definition: res_pjsip.h:130
struct ast_sip_service_route_vector * service_routes
Definition: res_pjsip.h:188
struct pjsip_transport * transport
Transport itself.
Definition: res_pjsip.h:118
struct ast_ha * localnet
Definition: res_pjsip.h:153
struct ast_dnsmgr_entry * external_signaling_address_refresher
Definition: res_pjsip.h:158
pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS]
Definition: res_pjsip.h:145
struct ast_sockaddr external_signaling_address
Definition: res_pjsip.h:163
struct ast_sockaddr external_media_address
Definition: res_pjsip.h:173
Transport to bind to.
Definition: res_pjsip.h:218
SORCERY_OBJECT(details)
unsigned int tos
Definition: res_pjsip.h:288
pjsip_tls_setting tls
Definition: res_pjsip.h:256
struct ast_sockaddr external_address
Definition: res_pjsip.h:280
const ast_string_field privkey_file
Definition: res_pjsip.h:238
const ast_string_field ca_list_path
Definition: res_pjsip.h:238
const ast_string_field domain
Definition: res_pjsip.h:238
enum ast_transport type
Definition: res_pjsip.h:240
const ast_string_field cert_file
Definition: res_pjsip.h:238
const ast_string_field password
Definition: res_pjsip.h:238
int tcp_keepalive_probe_count
Definition: res_pjsip.h:306
const ast_string_field external_signaling_address
Definition: res_pjsip.h:238
const ast_string_field ca_list_file
Definition: res_pjsip.h:238
unsigned int external_signaling_port
Definition: res_pjsip.h:250
struct ast_sip_transport_state * state
Definition: res_pjsip.h:286
struct ast_ha * localnet
Definition: res_pjsip.h:268
unsigned int async_operations
Definition: res_pjsip.h:248
int tcp_keepalive_enable
Definition: res_pjsip.h:300
pj_sockaddr host
Definition: res_pjsip.h:246
pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS]
Definition: res_pjsip.h:262
const ast_string_field external_media_address
Definition: res_pjsip.h:238
int tcp_keepalive_interval_time
Definition: res_pjsip.h:304
struct ast_dnsmgr_entry * external_address_refresher
Definition: res_pjsip.h:274
int tcp_keepalive_idle_time
Definition: res_pjsip.h:302
unsigned int cos
Definition: res_pjsip.h:290
Socket address structure.
Definition: netsock2.h:97
Full structure for sorcery.
Definition: sorcery.c:230
Support for dynamic strings.
Definition: strings.h:623
A ast_taskprocessor structure is a singleton by name.
Definition: taskprocessor.c:69
An opaque threadpool structure.
Definition: threadpool.c:36
Structure for variables, used for configurations and for channel variables.
String vector definitions.
Definition: vector.h:55
Definition: astman.c:222
In case you didn't read that giant block of text above the mansession_session struct,...
Definition: manager.c:326
userdata associated with baseline taskprocessor test
Definition: ast_expr2.c:325
int value
Definition: syslog.c:37
static struct test_val b
static struct test_val a
UDPTL support for T.38.
ast_t38_ec_modes
Definition: udptl.h:37
FILE * out
Definition: utils/frame.c:33
Vector container support.
#define AST_VECTOR(name, type)
Define a vector structure.
Definition: vector.h:44