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