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