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