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