2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2010, Digium, Inc.
6 * See http://www.asterisk.org for more information about
7 * the Asterisk project. Please do not directly contact
8 * any of the maintainers of this project for assistance;
9 * the project provides a web site, mailing lists and IRC
10 * channels for your use.
12 * This program is free software, distributed under the terms of
13 * the GNU General Public License Version 2. See the LICENSE file
14 * at the top of the source tree.
19 * \brief chan_sip header file
27 #include "asterisk/stringfields.h"
28 #include "asterisk/linkedlists.h"
29 #include "asterisk/strings.h"
30 #include "asterisk/tcptls.h"
31 #include "asterisk/test.h"
32 #include "asterisk/channel.h"
33 #include "asterisk/app.h"
34 #include "asterisk/astobj.h"
35 #include "asterisk/indications.h"
36 #include "asterisk/security_events.h"
37 #include "asterisk/features.h"
38 #include "asterisk/rtp_engine.h"
39 #include "asterisk/netsock2.h"
40 #include "asterisk/features_config.h"
52 /* Arguments for sip_find_peer */
53 #define FINDUSERS (1 << 0)
54 #define FINDPEERS (1 << 1)
55 #define FINDALLDEVICES (FINDUSERS | FINDPEERS)
57 #define SIPBUFSIZE 512 /*!< Buffer size for many operations */
61 #define SIP_RESERVED ";/?:@&=+$,# " /*!< Reserved characters in the username part of the URI */
63 #define DEFAULT_DEFAULT_EXPIRY 120
64 #define DEFAULT_MIN_EXPIRY 60
65 #define DEFAULT_MAX_EXPIRY 3600
66 #define DEFAULT_MWI_EXPIRY 3600
67 #define DEFAULT_REGISTRATION_TIMEOUT 20
68 #define DEFAULT_MAX_FORWARDS 70
70 #define DEFAULT_AUTHLIMIT 100
71 #define DEFAULT_AUTHTIMEOUT 30
73 /* guard limit must be larger than guard secs */
74 /* guard min must be < 1000, and should be >= 250 */
75 #define EXPIRY_GUARD_SECS 15 /*!< How long before expiry do we reregister */
76 #define EXPIRY_GUARD_LIMIT 30 /*!< Below here, we use EXPIRY_GUARD_PCT instead of EXPIRY_GUARD_SECS */
77 #define EXPIRY_GUARD_MIN 500 /*!< This is the minimum guard time applied. If
78 * GUARD_PCT turns out to be lower than this, it
79 * will use this time instead.
80 * This is in milliseconds.
82 #define EXPIRY_GUARD_PCT 0.20 /*!< Percentage of expires timeout to use when
83 * below EXPIRY_GUARD_LIMIT */
84 #define DEFAULT_EXPIRY 900 /*!< Expire slowly */
86 #define DEFAULT_QUALIFY_GAP 100
87 #define DEFAULT_QUALIFY_PEERS 1
89 #define CALLERID_UNKNOWN "Anonymous"
90 #define FROMDOMAIN_INVALID "anonymous.invalid"
92 #define DEFAULT_MAXMS 2000 /*!< Qualification: Must be faster than 2 seconds by default */
93 #define DEFAULT_QUALIFYFREQ 60 * 1000 /*!< Qualification: How often to check for the host to be up */
94 #define DEFAULT_FREQ_NOTOK 10 * 1000 /*!< Qualification: How often to check, if the host is down... */
96 #define DEFAULT_RETRANS 1000 /*!< How frequently to retransmit Default: 2 * 500 ms in RFC 3261 */
97 #define DEFAULT_TIMER_T1 500 /*!< SIP timer T1 (according to RFC 3261) */
98 #define SIP_TRANS_TIMEOUT 64 * DEFAULT_TIMER_T1 /*!< SIP request timeout (rfc 3261) 64*T1
99 * \todo Use known T1 for timeout (peerpoke)
101 #define DEFAULT_TRANS_TIMEOUT -1 /*!< Use default SIP transaction timeout */
102 #define PROVIS_KEEPALIVE_TIMEOUT 60000 /*!< How long to wait before retransmitting a provisional response (rfc 3261 13.3.1.1) */
103 #define MAX_AUTHTRIES 3 /*!< Try authentication three times, then fail */
105 #define SIP_MAX_HEADERS 64 /*!< Max amount of SIP headers to read */
106 #define SIP_MAX_LINES 256 /*!< Max amount of lines in SIP attachment (like SDP) */
107 #define SIP_MAX_PACKET_SIZE 20480 /*!< Max SIP packet size */
108 #define SIP_MIN_PACKET 4096 /*!< Initialize size of memory to allocate for packets */
109 #define MAX_HISTORY_ENTRIES 50 /*!< Max entires in the history list for a sip_pvt */
111 #define INITIAL_CSEQ 101 /*!< Our initial sip sequence number */
113 #define DEFAULT_MAX_SE 1800 /*!< Session-Timer Default Session-Expires period (RFC 4028) */
114 #define DEFAULT_MIN_SE 90 /*!< Session-Timer Default Min-SE period (RFC 4028) */
116 #define SDP_MAX_RTPMAP_CODECS 32 /*!< Maximum number of codecs allowed in received SDP */
121 #define DEC_CALL_LIMIT 0
122 #define INC_CALL_LIMIT 1
123 #define DEC_CALL_RINGING 2
124 #define INC_CALL_RINGING 3
126 /*! Define SIP option tags, used in Require: and Supported: headers
127 * We need to be aware of these properties in the phones to use
128 * the replace: header. We should not do that without knowing
129 * that the other end supports it...
130 * This is nothing we can configure, we learn by the dialog
131 * Supported: header on the REGISTER (peer) or the INVITE
133 * We are not using many of these today, but will in the future.
134 * This is documented in RFC 3261
137 #define NOT_SUPPORTED 0
140 #define SIP_OPT_REPLACES (1 << 0)
141 #define SIP_OPT_100REL (1 << 1)
142 #define SIP_OPT_TIMER (1 << 2)
143 #define SIP_OPT_EARLY_SESSION (1 << 3)
144 #define SIP_OPT_JOIN (1 << 4)
145 #define SIP_OPT_PATH (1 << 5)
146 #define SIP_OPT_PREF (1 << 6)
147 #define SIP_OPT_PRECONDITION (1 << 7)
148 #define SIP_OPT_PRIVACY (1 << 8)
149 #define SIP_OPT_SDP_ANAT (1 << 9)
150 #define SIP_OPT_SEC_AGREE (1 << 10)
151 #define SIP_OPT_EVENTLIST (1 << 11)
152 #define SIP_OPT_GRUU (1 << 12)
153 #define SIP_OPT_TARGET_DIALOG (1 << 13)
154 #define SIP_OPT_NOREFERSUB (1 << 14)
155 #define SIP_OPT_HISTINFO (1 << 15)
156 #define SIP_OPT_RESPRIORITY (1 << 16)
157 #define SIP_OPT_FROMCHANGE (1 << 17)
158 #define SIP_OPT_RECLISTINV (1 << 18)
159 #define SIP_OPT_RECLISTSUB (1 << 19)
160 #define SIP_OPT_OUTBOUND (1 << 20)
161 #define SIP_OPT_UNKNOWN (1 << 21)
163 /*! \brief SIP Methods we support
164 * \todo This string should be set dynamically. We only support REFER and SUBSCRIBE if we have
165 * allowsubscribe and allowrefer on in sip.conf.
167 #define ALLOWED_METHODS "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE"
169 /*! \brief Standard SIP unsecure port for UDP and TCP from RFC 3261. DO NOT CHANGE THIS */
170 #define STANDARD_SIP_PORT 5060
171 /*! \brief Standard SIP TLS port from RFC 3261. DO NOT CHANGE THIS */
172 #define STANDARD_TLS_PORT 5061
174 /*! \note in many SIP headers, absence of a port number implies port 5060,
175 * and this is why we cannot change the above constant.
176 * There is a limited number of places in asterisk where we could,
177 * in principle, use a different "default" port number, but
178 * we do not support this feature at the moment.
179 * You can run Asterisk with SIP on a different port with a configuration
180 * option. If you change this value in the source code, the signalling will be incorrect.
184 /*! \name DefaultValues Default values, set and reset in reload_config before reading configuration
186 These are default values in the source. There are other recommended values in the
187 sip.conf.sample for new installations. These may differ to keep backwards compatibility,
188 yet encouraging new behaviour on new installations
191 #define DEFAULT_CONTEXT "default" /*!< The default context for [general] section as well as devices */
192 #define DEFAULT_RECORD_FEATURE "automon" /*!< The default feature specified for use with INFO */
193 #define DEFAULT_MOHINTERPRET "default" /*!< The default music class */
194 #define DEFAULT_MOHSUGGEST ""
195 #define DEFAULT_VMEXTEN "asterisk" /*!< Default voicemail extension */
196 #define DEFAULT_CALLERID "asterisk" /*!< Default caller ID */
197 #define DEFAULT_MWI_FROM ""
198 #define DEFAULT_NOTIFYMIME "application/simple-message-summary"
199 #define DEFAULT_ALLOWGUEST TRUE
200 #define DEFAULT_RTPKEEPALIVE 0 /*!< Default RTPkeepalive setting */
201 #define DEFAULT_CALLCOUNTER FALSE /*!< Do not enable call counters by default */
202 #define DEFAULT_SRVLOOKUP TRUE /*!< Recommended setting is ON */
203 #define DEFAULT_COMPACTHEADERS FALSE /*!< Send compact (one-character) SIP headers. Default off */
204 #define DEFAULT_TOS_SIP 0 /*!< Call signalling packets should be marked as DSCP CS3, but the default is 0 to be compatible with previous versions. */
205 #define DEFAULT_TOS_AUDIO 0 /*!< Audio packets should be marked as DSCP EF (Expedited Forwarding), but the default is 0 to be compatible with previous versions. */
206 #define DEFAULT_TOS_VIDEO 0 /*!< Video packets should be marked as DSCP AF41, but the default is 0 to be compatible with previous versions. */
207 #define DEFAULT_TOS_TEXT 0 /*!< Text packets should be marked as XXXX XXXX, but the default is 0 to be compatible with previous versions. */
208 #define DEFAULT_COS_SIP 4 /*!< Level 2 class of service for SIP signalling */
209 #define DEFAULT_COS_AUDIO 5 /*!< Level 2 class of service for audio media */
210 #define DEFAULT_COS_VIDEO 6 /*!< Level 2 class of service for video media */
211 #define DEFAULT_COS_TEXT 5 /*!< Level 2 class of service for text media (T.140) */
212 #define DEFAULT_ALLOW_EXT_DOM TRUE /*!< Allow external domains */
213 #define DEFAULT_REALM "asterisk" /*!< Realm for HTTP digest authentication */
214 #define DEFAULT_DOMAINSASREALM FALSE /*!< Use the domain option to guess the realm for registration and invite requests */
215 #define DEFAULT_NOTIFYRINGING TRUE /*!< Notify devicestate system on ringing state */
216 #define DEFAULT_NOTIFYCID DISABLED /*!< Include CID with ringing notifications */
217 #define DEFAULT_PEDANTIC TRUE /*!< Follow SIP standards for dialog matching */
218 #define DEFAULT_AUTOCREATEPEER AUTOPEERS_DISABLED /*!< Don't create peers automagically */
219 #define DEFAULT_MATCHEXTERNADDRLOCALLY FALSE /*!< Match extern IP locally default setting */
220 #define DEFAULT_QUALIFY FALSE /*!< Don't monitor devices */
221 #define DEFAULT_KEEPALIVE 0 /*!< Don't send keep alive packets */
222 #define DEFAULT_KEEPALIVE_INTERVAL 60 /*!< Send keep alive packets at 60 second intervals */
223 #define DEFAULT_ALWAYSAUTHREJECT TRUE /*!< Don't reject authentication requests always */
224 #define DEFAULT_AUTH_OPTIONS FALSE
225 #define DEFAULT_AUTH_MESSAGE TRUE
226 #define DEFAULT_ACCEPT_OUTOFCALL_MESSAGE TRUE
227 #define DEFAULT_REGEXTENONQUALIFY FALSE
228 #define DEFAULT_LEGACY_USEROPTION_PARSING FALSE
229 #define DEFAULT_SEND_DIVERSION TRUE
230 #define DEFAULT_T1MIN 100 /*!< 100 MS for minimal roundtrip time */
231 #define DEFAULT_MAX_CALL_BITRATE (384) /*!< Max bitrate for video */
232 #ifndef DEFAULT_USERAGENT
233 #define DEFAULT_USERAGENT "Asterisk PBX" /*!< Default Useragent: header unless re-defined in sip.conf */
234 #define DEFAULT_SDPSESSION "Asterisk PBX" /*!< Default SDP session name, (s=) header unless re-defined in sip.conf */
235 #define DEFAULT_SDPOWNER "root" /*!< Default SDP username field in (o=) header unless re-defined in sip.conf */
236 #define DEFAULT_ENGINE "asterisk" /*!< Default RTP engine to use for sessions */
237 #define DEFAULT_STORE_SIP_CAUSE FALSE /*!< Don't store HASH(SIP_CAUSE,<channel name>) for channels by default */
242 Various flags for the flags field in the pvt structure
243 Trying to sort these up (one or more of the following):
247 When flags are used by multiple structures, it is important that
248 they have a common layout so it is easy to copy them.
251 #define SIP_OUTGOING (1 << 0) /*!< D: Direction of the last transaction in this dialog */
252 #define SIP_OFFER_CC (1 << 1) /*!< D: Offer CC on subsequent responses */
253 #define SIP_RINGING (1 << 2) /*!< D: Have sent 180 ringing */
254 #define SIP_PROGRESS_SENT (1 << 3) /*!< D: Have sent 183 message progress */
255 #define SIP_NEEDREINVITE (1 << 4) /*!< D: Do we need to send another reinvite? */
256 #define SIP_PENDINGBYE (1 << 5) /*!< D: Need to send bye after we ack? */
257 #define SIP_GOTREFER (1 << 6) /*!< D: Got a refer? */
258 #define SIP_CALL_LIMIT (1 << 7) /*!< D: Call limit enforced for this call */
259 #define SIP_INC_COUNT (1 << 8) /*!< D: Did this dialog increment the counter of in-use calls? */
260 #define SIP_INC_RINGING (1 << 9) /*!< D: Did this connection increment the counter of in-use calls? */
261 #define SIP_DEFER_BYE_ON_TRANSFER (1 << 10) /*!< D: Do not hangup at first ast_hangup */
263 #define SIP_PROMISCREDIR (1 << 11) /*!< DP: Promiscuous redirection */
264 #define SIP_TRUSTRPID (1 << 12) /*!< DP: Trust RPID headers? */
265 #define SIP_USEREQPHONE (1 << 13) /*!< DP: Add user=phone to numeric URI. Default off */
266 #define SIP_USECLIENTCODE (1 << 14) /*!< DP: Trust X-ClientCode info message */
268 /* DTMF flags - see str2dtmfmode() and dtmfmode2str() */
269 #define SIP_DTMF (7 << 15) /*!< DP: DTMF Support: five settings, uses three bits */
270 #define SIP_DTMF_RFC2833 (0 << 15) /*!< DP: DTMF Support: RTP DTMF - "rfc2833" */
271 #define SIP_DTMF_INBAND (1 << 15) /*!< DP: DTMF Support: Inband audio, only for ULAW/ALAW - "inband" */
272 #define SIP_DTMF_INFO (2 << 15) /*!< DP: DTMF Support: SIP Info messages - "info" */
273 #define SIP_DTMF_AUTO (3 << 15) /*!< DP: DTMF Support: AUTO switch between rfc2833 and in-band DTMF */
274 #define SIP_DTMF_SHORTINFO (4 << 15) /*!< DP: DTMF Support: SIP Info messages - "info" - short variant */
277 #define SIP_NAT_FORCE_RPORT (1 << 18) /*!< DP: Force rport even if not present in the request */
278 #define SIP_NAT_RPORT_PRESENT (1 << 19) /*!< DP: rport was present in the request */
280 /* re-INVITE related settings */
281 #define SIP_REINVITE (7 << 20) /*!< DP: four settings, uses three bits */
282 #define SIP_REINVITE_NONE (0 << 20) /*!< DP: no reinvite allowed */
283 #define SIP_DIRECT_MEDIA (1 << 20) /*!< DP: allow peers to be reinvited to send media directly p2p */
284 #define SIP_DIRECT_MEDIA_NAT (2 << 20) /*!< DP: allow media reinvite when new peer is behind NAT */
285 #define SIP_REINVITE_UPDATE (4 << 20) /*!< DP: use UPDATE (RFC3311) when reinviting this peer */
287 /* "insecure" settings - see insecure2str() */
288 #define SIP_INSECURE (3 << 23) /*!< DP: three settings, uses two bits */
289 #define SIP_INSECURE_NONE (0 << 23) /*!< DP: secure mode */
290 #define SIP_INSECURE_PORT (1 << 23) /*!< DP: don't require matching port for incoming requests */
291 #define SIP_INSECURE_INVITE (1 << 24) /*!< DP: don't require authentication for incoming INVITEs */
293 /* Sending PROGRESS in-band settings */
294 #define SIP_PROG_INBAND (3 << 25) /*!< DP: three settings, uses two bits */
295 #define SIP_PROG_INBAND_NEVER (0 << 25)
296 #define SIP_PROG_INBAND_NO (1 << 25)
297 #define SIP_PROG_INBAND_YES (2 << 25)
299 #define SIP_USEPATH (1 << 27) /*!< GDP: Trust and use incoming Path headers? */
300 #define SIP_SENDRPID (3 << 29) /*!< DP: Remote Party-ID Support */
301 #define SIP_SENDRPID_NO (0 << 29)
302 #define SIP_SENDRPID_PAI (1 << 29) /*!< Use "P-Asserted-Identity" for rpid */
303 #define SIP_SENDRPID_RPID (2 << 29) /*!< Use "Remote-Party-ID" for rpid */
304 #define SIP_G726_NONSTANDARD (1 << 31) /*!< DP: Use non-standard packing for G726-32 data */
306 /*! \brief Flags to copy from peer/user to dialog */
307 #define SIP_FLAGS_TO_COPY \
308 (SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \
309 SIP_PROG_INBAND | SIP_USECLIENTCODE | SIP_NAT_FORCE_RPORT | SIP_G726_NONSTANDARD | \
310 SIP_USEREQPHONE | SIP_INSECURE | SIP_USEPATH)
314 a second page of flags (for flags[1] */
317 #define SIP_PAGE2_RTCACHEFRIENDS (1 << 0) /*!< GP: Should we keep RT objects in memory for extended time? */
318 #define SIP_PAGE2_RTAUTOCLEAR (1 << 1) /*!< GP: Should we clean memory from peers after expiry? */
319 #define SIP_PAGE2_RPID_UPDATE (1 << 2)
320 #define SIP_PAGE2_Q850_REASON (1 << 3) /*!< DP: Get/send cause code via Reason header */
321 #define SIP_PAGE2_SYMMETRICRTP (1 << 4) /*!< GDP: Whether symmetric RTP is enabled or not */
322 #define SIP_PAGE2_STATECHANGEQUEUE (1 << 5) /*!< D: Unsent state pending change exists */
323 #define SIP_PAGE2_CONNECTLINEUPDATE_PEND (1 << 6)
324 #define SIP_PAGE2_RPID_IMMEDIATE (1 << 7)
325 #define SIP_PAGE2_RPORT_PRESENT (1 << 8) /*!< Was rport received in the Via header? */
326 #define SIP_PAGE2_PREFERRED_CODEC (1 << 9) /*!< GDP: Only respond with single most preferred joint codec */
327 #define SIP_PAGE2_VIDEOSUPPORT (1 << 10) /*!< DP: Video supported if offered? */
328 #define SIP_PAGE2_TEXTSUPPORT (1 << 11) /*!< GDP: Global text enable */
329 #define SIP_PAGE2_ALLOWSUBSCRIBE (1 << 12) /*!< GP: Allow subscriptions from this peer? */
331 #define SIP_PAGE2_ALLOWOVERLAP (3 << 13) /*!< DP: Allow overlap dialing ? */
332 #define SIP_PAGE2_ALLOWOVERLAP_NO (0 << 13) /*!< No, terminate with 404 Not found */
333 #define SIP_PAGE2_ALLOWOVERLAP_YES (1 << 13) /*!< Yes, using the 484 Address Incomplete response */
334 #define SIP_PAGE2_ALLOWOVERLAP_DTMF (2 << 13) /*!< Yes, using the DTMF transmission through Early Media */
335 #define SIP_PAGE2_ALLOWOVERLAP_SPARE (3 << 13) /*!< Spare (reserved for another dialling transmission mechanisms like KPML) */
337 #define SIP_PAGE2_SUBSCRIBEMWIONLY (1 << 15) /*!< GP: Only issue MWI notification if subscribed to */
338 #define SIP_PAGE2_IGNORESDPVERSION (1 << 16) /*!< GDP: Ignore the SDP session version number we receive and treat all sessions as new */
340 #define SIP_PAGE2_T38SUPPORT (3 << 17) /*!< GDP: T.38 Fax Support */
341 #define SIP_PAGE2_T38SUPPORT_UDPTL (1 << 17) /*!< GDP: T.38 Fax Support (no error correction) */
342 #define SIP_PAGE2_T38SUPPORT_UDPTL_FEC (2 << 17) /*!< GDP: T.38 Fax Support (FEC error correction) */
343 #define SIP_PAGE2_T38SUPPORT_UDPTL_REDUNDANCY (3 << 17) /*!< GDP: T.38 Fax Support (redundancy error correction) */
345 #define SIP_PAGE2_CALL_ONHOLD (3 << 19) /*!< D: Call hold states: */
346 #define SIP_PAGE2_CALL_ONHOLD_ACTIVE (1 << 19) /*!< D: Active hold */
347 #define SIP_PAGE2_CALL_ONHOLD_ONEDIR (2 << 19) /*!< D: One directional hold */
348 #define SIP_PAGE2_CALL_ONHOLD_INACTIVE (3 << 19) /*!< D: Inactive hold */
350 #define SIP_PAGE2_RFC2833_COMPENSATE (1 << 21) /*!< DP: Compensate for buggy RFC2833 implementations */
351 #define SIP_PAGE2_BUGGY_MWI (1 << 22) /*!< DP: Buggy CISCO MWI fix */
352 #define SIP_PAGE2_DIALOG_ESTABLISHED (1 << 23) /*!< 29: Has a dialog been established? */
354 #define SIP_PAGE2_FAX_DETECT (3 << 24) /*!< DP: Fax Detection support */
355 #define SIP_PAGE2_FAX_DETECT_CNG (1 << 24) /*!< DP: Fax Detection support - detect CNG in audio */
356 #define SIP_PAGE2_FAX_DETECT_T38 (2 << 24) /*!< DP: Fax Detection support - detect T.38 reinvite from peer */
357 #define SIP_PAGE2_FAX_DETECT_BOTH (3 << 24) /*!< DP: Fax Detection support - detect both */
359 #define SIP_PAGE2_UDPTL_DESTINATION (1 << 26) /*!< DP: Use source IP of RTP as destination if NAT is enabled */
360 #define SIP_PAGE2_VIDEOSUPPORT_ALWAYS (1 << 27) /*!< DP: Always set up video, even if endpoints don't support it */
361 #define SIP_PAGE2_HAVEPEERCONTEXT (1 << 28) /*< Are we associated with a configured peer context? */
362 #define SIP_PAGE2_USE_SRTP (1 << 29) /*!< DP: Whether we should offer (only) SRTP */
364 #define SIP_PAGE2_TRUST_ID_OUTBOUND (3 << 30) /*!< DP: Do we trust the peer with private presence information? */
365 #define SIP_PAGE2_TRUST_ID_OUTBOUND_LEGACY (0 << 30) /*!< Legacy, Do not provide private presence information, but include PAI/RPID when private */
366 #define SIP_PAGE2_TRUST_ID_OUTBOUND_NO (1 << 30) /*!< No, Do not provide private presence information, do not include PAI/RPID when private */
367 #define SIP_PAGE2_TRUST_ID_OUTBOUND_YES (2 << 30) /*!< Yes, provide private presence information in PAI/RPID headers */
369 #define SIP_PAGE2_FLAGS_TO_COPY \
370 (SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_IGNORESDPVERSION | \
371 SIP_PAGE2_VIDEOSUPPORT | SIP_PAGE2_T38SUPPORT | SIP_PAGE2_RFC2833_COMPENSATE | \
372 SIP_PAGE2_BUGGY_MWI | SIP_PAGE2_TEXTSUPPORT | SIP_PAGE2_FAX_DETECT | \
373 SIP_PAGE2_UDPTL_DESTINATION | SIP_PAGE2_VIDEOSUPPORT_ALWAYS | SIP_PAGE2_PREFERRED_CODEC | \
374 SIP_PAGE2_RPID_IMMEDIATE | SIP_PAGE2_RPID_UPDATE | SIP_PAGE2_SYMMETRICRTP |\
375 SIP_PAGE2_Q850_REASON | SIP_PAGE2_HAVEPEERCONTEXT | SIP_PAGE2_USE_SRTP | SIP_PAGE2_TRUST_ID_OUTBOUND)
378 #define SIP_PAGE3_SNOM_AOC (1 << 0) /*!< DPG: Allow snom aoc messages */
379 #define SIP_PAGE3_SRTP_TAG_32 (1 << 1) /*!< DP: Use a 32bit auth tag in INVITE not 80bit */
380 #define SIP_PAGE3_NAT_AUTO_RPORT (1 << 2) /*!< DGP: Set SIP_NAT_FORCE_RPORT when NAT is detected */
381 #define SIP_PAGE3_NAT_AUTO_COMEDIA (1 << 3) /*!< DGP: Set SIP_PAGE2_SYMMETRICRTP when NAT is detected */
382 #define SIP_PAGE3_DIRECT_MEDIA_OUTGOING (1 << 4) /*!< DP: Only send direct media reinvites on outgoing calls */
383 #define SIP_PAGE3_USE_AVPF (1 << 5) /*!< DGP: Support a minimal AVPF-compatible profile */
384 #define SIP_PAGE3_ICE_SUPPORT (1 << 6) /*!< DGP: Enable ICE support */
385 #define SIP_PAGE3_IGNORE_PREFCAPS (1 << 7) /*!< DP: Ignore prefcaps when setting up an outgoing call leg */
386 #define SIP_PAGE3_DISCARD_REMOTE_HOLD_RETRIEVAL (1 << 8) /*!< DGP: Stop telling the peer to start music on hold */
388 #define SIP_PAGE3_FLAGS_TO_COPY \
389 (SIP_PAGE3_SNOM_AOC | SIP_PAGE3_SRTP_TAG_32 | SIP_PAGE3_NAT_AUTO_RPORT | SIP_PAGE3_NAT_AUTO_COMEDIA | \
390 SIP_PAGE3_DIRECT_MEDIA_OUTGOING | SIP_PAGE3_USE_AVPF | SIP_PAGE3_ICE_SUPPORT | SIP_PAGE3_IGNORE_PREFCAPS | \
391 SIP_PAGE3_DISCARD_REMOTE_HOLD_RETRIEVAL)
393 #define CHECK_AUTH_BUF_INITLEN 256
397 /*----------------------------------------------------------*/
399 /*----------------------------------------------------------*/
401 /*! \brief Authorization scheme for call transfers
403 * \note Not a bitfield flag, since there are plans for other modes,
404 * like "only allow transfers for authenticated devices"
407 TRANSFER_OPENFORALL, /*!< Allow all SIP transfers */
408 TRANSFER_CLOSED, /*!< Allow no SIP transfers */
411 /*! \brief The result of a lot of functions */
413 AST_SUCCESS = 0, /*!< FALSE means success, funny enough */
414 AST_FAILURE = -1, /*!< Failure code */
417 /*! \brief The results from handling an invite request
419 * \note Start at these values so we do not conflict with
420 * check_auth_results values when returning from
421 * handle_request_invite. check_auth_results only returned during
422 * authentication routines
424 enum inv_req_result {
425 INV_REQ_SUCCESS = 11, /*!< Success code */
426 INV_REQ_FAILED = 10, /*!< Failure code */
427 INV_REQ_ERROR = 9, /*!< Error code */
430 /*! \brief States for the INVITE transaction, not the dialog
431 * \note this is for the INVITE that sets up the dialog
434 INV_NONE = 0, /*!< No state at all, maybe not an INVITE dialog */
435 INV_CALLING = 1, /*!< Invite sent, no answer */
436 INV_PROCEEDING = 2, /*!< We got/sent 1xx message */
437 INV_EARLY_MEDIA = 3, /*!< We got 18x message with to-tag back */
438 INV_COMPLETED = 4, /*!< Got final response with error. Wait for ACK, then CONFIRMED */
439 INV_CONFIRMED = 5, /*!< Confirmed response - we've got an ack (Incoming calls only) */
440 INV_TERMINATED = 6, /*!< Transaction done - either successful (AST_STATE_UP) or failed, but done
441 The only way out of this is a BYE from one side */
442 INV_CANCELLED = 7, /*!< Transaction cancelled by client or server in non-terminated state */
445 /*! \brief When sending a SIP message, we can send with a few options, depending on
446 * type of SIP request. UNRELIABLE is moslty used for responses to repeated requests,
447 * where the original response would be sent RELIABLE in an INVITE transaction
450 XMIT_CRITICAL = 2, /*!< Transmit critical SIP message reliably, with re-transmits.
451 * If it fails, it's critical and will cause a teardown of the session */
452 XMIT_RELIABLE = 1, /*!< Transmit SIP message reliably, with re-transmits */
453 XMIT_UNRELIABLE = 0, /*!< Transmit SIP message without bothering with re-transmits */
456 /*! \brief Results from the parse_register() function */
457 enum parse_register_result {
458 PARSE_REGISTER_DENIED,
459 PARSE_REGISTER_FAILED,
460 PARSE_REGISTER_UPDATE,
461 PARSE_REGISTER_QUERY,
464 /*! \brief Type of subscription, based on the packages we do support, see \ref subscription_types */
465 enum subscriptiontype {
475 /*! \brief The number of media types in enum \ref media_type below. */
476 #define OFFERED_MEDIA_COUNT 4
478 /*! \brief Media types generate different "dummy answers" for not accepting the offer of
479 a media stream. We need to add definitions for each RTP profile. Secure RTP is not
480 the same as normal RTP and will require a new definition */
482 SDP_AUDIO, /*!< RTP/AVP Audio */
483 SDP_VIDEO, /*!< RTP/AVP Video */
484 SDP_IMAGE, /*!< Image udptl, not TCP or RTP */
485 SDP_TEXT, /*!< RTP/AVP Realtime Text */
486 SDP_UNKNOWN, /*!< Unknown media type */
489 /*! \brief Authentication types - proxy or www authentication
490 * \note Endpoints, like Asterisk, should always use WWW authentication to
491 * allow multiple authentications in the same call - to the proxy and
499 /*! \brief Result from get_destination function */
500 enum sip_get_dest_result {
501 SIP_GET_DEST_EXTEN_MATCHMORE = 1,
502 SIP_GET_DEST_EXTEN_FOUND = 0,
503 SIP_GET_DEST_EXTEN_NOT_FOUND = -1,
504 SIP_GET_DEST_REFUSED = -2,
505 SIP_GET_DEST_INVALID_URI = -3,
508 /*! \brief Authentication result from check_auth* functions */
509 enum check_auth_result {
510 AUTH_DONT_KNOW = -100, /*!< no result, need to check further */
511 /* XXX maybe this is the same as AUTH_NOT_FOUND */
513 AUTH_CHALLENGE_SENT = 1,
514 AUTH_SECRET_FAILED = -1,
515 AUTH_USERNAME_MISMATCH = -2,
516 AUTH_NOT_FOUND = -3, /*!< returned by register_verify */
517 AUTH_UNKNOWN_DOMAIN = -5,
518 AUTH_PEER_NOT_DYNAMIC = -6,
519 AUTH_ACL_FAILED = -7,
520 AUTH_BAD_TRANSPORT = -8,
521 AUTH_RTP_FAILED = -9,
522 AUTH_SESSION_LIMIT = -10,
525 /*! \brief States for outbound registrations (with register= lines in sip.conf */
526 enum sipregistrystate {
527 REG_STATE_UNREGISTERED = 0, /*!< We are not registered
528 * \note Initial state. We should have a timeout scheduled for the initial
529 * (or next) registration transmission, calling sip_reregister
532 REG_STATE_REGSENT, /*!< Registration request sent
533 * \note sent initial request, waiting for an ack or a timeout to
534 * retransmit the initial request.
537 REG_STATE_AUTHSENT, /*!< We have tried to authenticate
538 * \note entered after transmit_register with auth info,
539 * waiting for an ack.
542 REG_STATE_REGISTERED, /*!< Registered and done */
544 REG_STATE_REJECTED, /*!< Registration rejected
545 * \note only used when the remote party has an expire larger than
546 * our max-expire. This is a final state from which we do not
547 * recover (not sure how correctly).
550 REG_STATE_TIMEOUT, /*!< Registration timed out
551 * \note XXX unused */
553 REG_STATE_NOAUTH, /*!< We have no accepted credentials
554 * \note fatal - no chance to proceed */
556 REG_STATE_FAILED, /*!< Registration failed after several tries
557 * \note fatal - no chance to proceed */
560 /*! \brief Modes in which Asterisk can be configured to run SIP Session-Timers */
562 SESSION_TIMER_MODE_INVALID = 0, /*!< Invalid value */
563 SESSION_TIMER_MODE_ACCEPT, /*!< Honor inbound Session-Timer requests */
564 SESSION_TIMER_MODE_ORIGINATE, /*!< Originate outbound and honor inbound requests */
565 SESSION_TIMER_MODE_REFUSE /*!< Ignore inbound Session-Timers requests */
568 /*! \brief The entity playing the refresher role for Session-Timers */
570 SESSION_TIMER_REFRESHER_AUTO, /*!< Negotiated */
571 SESSION_TIMER_REFRESHER_US, /*!< Initially prefer session refresh by Asterisk */
572 SESSION_TIMER_REFRESHER_THEM, /*!< Initially prefer session refresh by the other side */
575 enum st_refresher_param {
576 SESSION_TIMER_REFRESHER_PARAM_UNKNOWN,
577 SESSION_TIMER_REFRESHER_PARAM_UAC,
578 SESSION_TIMER_REFRESHER_PARAM_UAS,
581 /*! \brief Automatic peer registration behavior
583 enum autocreatepeer_mode {
584 AUTOPEERS_DISABLED = 0, /*!< Automatic peer creation disabled */
585 AUTOPEERS_VOLATILE, /*!< Automatic peers dropped on sip reload (pre-1.8 behavior) */
586 AUTOPEERS_PERSIST /*!< Automatic peers survive sip configuration reload */
589 /*! \brief States whether a SIP message can create a dialog in Asterisk. */
590 enum can_create_dialog {
591 CAN_NOT_CREATE_DIALOG,
593 CAN_CREATE_DIALOG_UNSUPPORTED_METHOD,
596 /*! \brief SIP Request methods known by Asterisk
598 * \note Do _NOT_ make any changes to this enum, or the array following it;
599 * if you think you are doing the right thing, you are probably
600 * not doing the right thing. If you think there are changes
601 * needed, get someone else to review them first _before_
602 * submitting a patch. If these two lists do not match properly
603 * bad things will happen.
606 SIP_UNKNOWN, /*!< Unknown response */
607 SIP_RESPONSE, /*!< Not request, response to outbound request */
608 SIP_REGISTER, /*!< Registration to the mothership, tell us where you are located */
609 SIP_OPTIONS, /*!< Check capabilities of a device, used for "ping" too */
610 SIP_NOTIFY, /*!< Status update, Part of the event package standard, result of a SUBSCRIBE or a REFER */
611 SIP_INVITE, /*!< Set up a session */
612 SIP_ACK, /*!< End of a three-way handshake started with INVITE. */
613 SIP_PRACK, /*!< Reliable pre-call signalling. Not supported in Asterisk. */
614 SIP_BYE, /*!< End of a session */
615 SIP_REFER, /*!< Refer to another URI (transfer) */
616 SIP_SUBSCRIBE, /*!< Subscribe for updates (voicemail, session status, device status, presence) */
617 SIP_MESSAGE, /*!< Text messaging */
618 SIP_UPDATE, /*!< Update a dialog. We can send UPDATE; but not accept it */
619 SIP_INFO, /*!< Information updates during a session */
620 SIP_CANCEL, /*!< Cancel an INVITE */
621 SIP_PUBLISH, /*!< Not supported in Asterisk */
622 SIP_PING, /*!< Not supported at all, no standard but still implemented out there */
625 /*! \brief Settings for the 'notifycid' option, see sip.conf.sample for details. */
626 enum notifycid_setting {
632 /*! \brief Modes for SIP domain handling in the PBX */
634 SIP_DOMAIN_AUTO, /*!< This domain is auto-configured */
635 SIP_DOMAIN_CONFIG, /*!< This domain is from configuration */
638 /*! \brief debugging state
639 * We store separately the debugging requests from the config file
640 * and requests from the CLI. Debugging is enabled if either is set
641 * (which means that if sipdebug is set in the config file, we can
642 * only turn it off by reloading the config).
646 sip_debug_config = 1,
647 sip_debug_console = 2,
650 /*! \brief T38 States for a call */
652 T38_DISABLED = 0, /*!< Not enabled */
653 T38_LOCAL_REINVITE, /*!< Offered from local - REINVITE */
654 T38_PEER_REINVITE, /*!< Offered from peer - REINVITE */
655 T38_ENABLED, /*!< Negotiated (enabled) */
656 T38_REJECTED /*!< Refused */
659 /*! \brief Parameters to know status of transfer */
661 REFER_IDLE, /*!< No REFER is in progress */
662 REFER_SENT, /*!< Sent REFER to transferee */
663 REFER_RECEIVED, /*!< Received REFER from transferrer */
664 REFER_CONFIRMED, /*!< Refer confirmed with a 100 TRYING (unused) */
665 REFER_ACCEPTED, /*!< Accepted by transferee */
666 REFER_RINGING, /*!< Target Ringing */
667 REFER_200OK, /*!< Answered by transfer target */
668 REFER_FAILED, /*!< REFER declined - go on */
669 REFER_NOAUTH /*!< We had no auth for REFER */
673 SIP_TYPE_PEER = (1 << 0),
674 SIP_TYPE_USER = (1 << 1),
677 enum t38_action_flag {
678 SDP_T38_NONE = 0, /*!< Do not modify T38 information at all */
679 SDP_T38_INITIATE, /*!< Remote side has requested T38 with us */
680 SDP_T38_ACCEPT, /*!< Remote side accepted our T38 request */
683 enum sip_tcptls_alert {
684 TCPTLS_ALERT_DATA, /*!< \brief There is new data to be sent out */
685 TCPTLS_ALERT_STOP, /*!< \brief A request to stop the tcp_handler thread */
696 /*----------------------------------------------------------*/
697 /*---- STRUCTS ----*/
698 /*----------------------------------------------------------*/
700 /*! \brief definition of a sip proxy server
702 * For outbound proxies, a sip_peer will contain a reference to a
703 * dynamically allocated instance of a sip_proxy. A sip_pvt may also
704 * contain a reference to a peer's outboundproxy, or it may contain
705 * a reference to the sip_cfg.outboundproxy.
708 char name[MAXHOSTNAMELEN]; /*!< DNS name of domain/host or IP */
709 struct ast_sockaddr ip; /*!< Currently used IP address and port */
711 time_t last_dnsupdate; /*!< When this was resolved */
712 enum ast_transport transport;
713 int force; /*!< If it's an outbound proxy, Force use of this outbound proxy for all outbound requests */
714 /* Room for a SRV record chain based on the name */
717 /*! \brief argument for the 'show channels|subscriptions' callback. */
718 struct __show_chan_arg {
721 int numchans; /* return value */
724 /*! \name GlobalSettings
725 Global settings apply to the channel (often settings you can change in the general section
729 /*! \brief a place to store all global settings for the sip channel driver
731 These are settings that will be possibly to apply on a group level later on.
732 \note Do not add settings that only apply to the channel itself and can't
733 be applied to devices (trunks, services, phones)
735 struct sip_settings {
736 int peer_rtupdate; /*!< G: Update database with registration data for peer? */
737 int rtsave_sysname; /*!< G: Save system name at registration? */
738 int rtsave_path; /*!< G: Save path header on registration */
739 int ignore_regexpire; /*!< G: Ignore expiration of peer */
740 int rtautoclear; /*!< Realtime ?? */
741 int directrtpsetup; /*!< Enable support for Direct RTP setup (no re-invites) */
742 int pedanticsipchecking; /*!< Extra checking ? Default off */
743 enum autocreatepeer_mode autocreatepeer; /*!< Auto creation of peers at registration? Default off. */
744 int srvlookup; /*!< SRV Lookup on or off. Default is on */
745 int allowguest; /*!< allow unauthenticated peers to connect? */
746 int alwaysauthreject; /*!< Send 401 Unauthorized for all failing requests */
747 int auth_options_requests; /*!< Authenticate OPTIONS requests */
748 int auth_message_requests; /*!< Authenticate MESSAGE requests */
749 int accept_outofcall_message; /*!< Accept MESSAGE outside of a call */
750 int compactheaders; /*!< send compact sip headers */
751 int allow_external_domains; /*!< Accept calls to external SIP domains? */
752 int regextenonqualify; /*!< Whether to add/remove regexten when qualifying peers */
753 int legacy_useroption_parsing; /*!< Whether to strip useroptions in URI via semicolons */
754 int send_diversion; /*!< Whether to Send SIP Diversion headers */
755 int matchexternaddrlocally; /*!< Match externaddr/externhost setting against localnet setting */
756 char regcontext[AST_MAX_CONTEXT]; /*!< Context for auto-extensions */
757 char messagecontext[AST_MAX_CONTEXT]; /*!< Default context for out of dialog msgs. */
758 unsigned int disallowed_methods; /*!< methods that we should never try to use */
759 int notifyringing; /*!< Send notifications on ringing */
760 int notifyhold; /*!< Send notifications on hold */
761 enum notifycid_setting notifycid; /*!< Send CID with ringing notifications */
762 enum transfermodes allowtransfer; /*!< SIP Refer restriction scheme */
763 int allowsubscribe; /*!< Flag for disabling ALL subscriptions, this is FALSE only if all peers are FALSE
764 the global setting is in globals_flags[1] */
765 char realm[MAXHOSTNAMELEN]; /*!< Default realm */
766 int domainsasrealm; /*!< Use domains lists as realms */
767 struct sip_proxy outboundproxy; /*!< Outbound proxy */
768 char default_context[AST_MAX_CONTEXT];
769 char default_subscribecontext[AST_MAX_CONTEXT];
770 char default_record_on_feature[AST_FEATURE_MAX_LEN];
771 char default_record_off_feature[AST_FEATURE_MAX_LEN];
772 struct ast_acl_list *contact_acl; /*! \brief Global list of addresses dynamic peers are not allowed to use */
773 struct ast_format_cap *caps; /*!< Supported codecs */
775 int default_max_forwards; /*!< Default max forwards (SIP Anti-loop) */
778 struct ast_websocket;
780 /*! \brief The SIP socket definition */
782 enum ast_transport type; /*!< UDP, TCP or TLS */
783 int fd; /*!< Filed descriptor, the actual socket */
785 struct ast_tcptls_session_instance *tcptls_session; /* If tcp or tls, a socket manager */
786 struct ast_websocket *ws_session; /*! If ws or wss, a WebSocket session */
789 /*! \brief sip_request: The data grabbed from the UDP socket
792 * Incoming messages: we first store the data from the socket in data[],
793 * adding a trailing \0 to make string parsing routines happy.
794 * Then call parse_request() and req.method = find_sip_method();
795 * to initialize the other fields. The \r\n at the end of each line is
796 * replaced by \0, so that data[] is not a conforming SIP message anymore.
797 * After this processing, rlpart1 is set to non-NULL to remember
798 * that we can run get_header() on this kind of packet.
800 * parse_request() splits the first line as follows:
801 * Requests have in the first line method uri SIP/2.0
802 * rlpart1 = method; rlpart2 = uri;
803 * Responses have in the first line SIP/2.0 NNN description
804 * rlpart1 = SIP/2.0; rlpart2 = NNN + description;
806 * For outgoing packets, we initialize the fields with init_req() or init_resp()
807 * (which fills the first line to "METHOD uri SIP/2.0" or "SIP/2.0 code text"),
808 * and then fill the rest with add_header() and add_line().
809 * The \r\n at the end of the line are still there, so the get_header()
810 * and similar functions don't work on these packets.
814 ptrdiff_t rlpart1; /*!< Offset of the SIP Method Name or "SIP/2.0" protocol version */
815 ptrdiff_t rlpart2; /*!< Offset of the Request URI or Response Status */
816 int headers; /*!< # of SIP Headers */
817 int method; /*!< Method of this request */
818 int lines; /*!< Body Content */
819 unsigned int sdp_start; /*!< the line number where the SDP begins */
820 unsigned int sdp_count; /*!< the number of lines of SDP */
821 char debug; /*!< print extra debugging if non zero */
822 char has_to_tag; /*!< non-zero if packet has To: tag */
823 char ignore; /*!< if non-zero This is a re-transmit, ignore it */
824 char authenticated; /*!< non-zero if this request was authenticated */
825 ptrdiff_t header[SIP_MAX_HEADERS]; /*!< Array of offsets into the request string of each SIP header*/
826 ptrdiff_t line[SIP_MAX_LINES]; /*!< Array of offsets into the request string of each SDP line*/
827 struct ast_str *data;
828 struct ast_str *content;
829 /* XXX Do we need to unref socket.ser when the request goes away? */
830 struct sip_socket socket; /*!< The socket used for this request */
831 AST_LIST_ENTRY(sip_request) next;
832 unsigned int reqsipoptions; /*!< Items needed for Required header in responses */
835 /* \brief given a sip_request and an offset, return the char * that resides there
837 * It used to be that rlpart1, rlpart2, and the header and line arrays were character
838 * pointers. They are now offsets into the ast_str portion of the sip_request structure.
839 * To avoid adding a bunch of redundant pointer arithmetic to the code, this macro is
840 * provided to retrieve the string at a particular offset within the request's buffer
842 #define REQ_OFFSET_TO_STR(req,offset) (ast_str_buffer((req)->data) + ((req)->offset))
844 /*! \brief Parameters to the transmit_invite function */
845 struct sip_invite_param {
846 int addsipheaders; /*!< Add extra SIP headers */
847 const char *uri_options; /*!< URI options to add to the URI */
848 const char *vxml_url; /*!< VXML url for Cisco phones */
849 char *auth; /*!< Authentication */
850 char *authheader; /*!< Auth header */
851 enum sip_auth_type auth_type; /*!< Authentication type */
852 const char *replaces; /*!< Replaces header for call transfers */
853 int transfer; /*!< Flag - is this Invite part of a SIP transfer? (invite/replaces) */
854 struct sip_proxy *outboundproxy; /*!< Outbound proxy URI */
857 /*! \brief Structure to store Via information */
860 const char *protocol;
868 /*! \brief Domain data structure.
869 \note In the future, we will connect this to a configuration tree specific
873 char domain[MAXHOSTNAMELEN]; /*!< SIP domain we are responsible for */
874 char context[AST_MAX_EXTENSION]; /*!< Incoming context for this domain */
875 enum domain_mode mode; /*!< How did we find this domain? */
876 AST_LIST_ENTRY(domain) list; /*!< List mechanics */
879 /*! \brief sip_history: Structure for saving transactions within a SIP dialog */
881 AST_LIST_ENTRY(sip_history) list;
882 char event[0]; /* actually more, depending on needs */
885 /*! \brief sip_auth: Credentials for authentication to other SIP services */
887 AST_LIST_ENTRY(sip_auth) node;
888 char realm[AST_MAX_EXTENSION]; /*!< Realm in which these credentials are valid */
889 char username[256]; /*!< Username */
890 char secret[256]; /*!< Secret */
891 char md5secret[256]; /*!< MD5Secret */
894 /*! \brief Container of SIP authentication credentials. */
895 struct sip_auth_container {
896 AST_LIST_HEAD_NOLOCK(, sip_auth) list;
899 /*! \brief T.38 channel settings (at some point we need to make this alloc'ed */
900 struct t38properties {
901 enum t38state state; /*!< T.38 state */
902 struct ast_control_t38_parameters our_parms;
903 struct ast_control_t38_parameters their_parms;
906 /*! \brief generic struct to map between strings and integers.
907 * Fill it with x-s pairs, terminate with an entry with s = NULL;
908 * Then you can call map_x_s(...) to map an integer to a string,
909 * and map_s_x() for the string -> integer mapping.
916 /*! \brief Structure to handle SIP transfers. Dynamically allocated when needed */
918 AST_DECLARE_STRING_FIELDS(
919 AST_STRING_FIELD(refer_to); /*!< Place to store REFER-TO extension */
920 AST_STRING_FIELD(refer_to_domain); /*!< Place to store REFER-TO domain */
921 AST_STRING_FIELD(refer_to_urioption); /*!< Place to store REFER-TO uri options */
922 AST_STRING_FIELD(refer_to_context); /*!< Place to store REFER-TO context */
923 AST_STRING_FIELD(referred_by); /*!< Place to store REFERRED-BY extension */
924 AST_STRING_FIELD(refer_contact); /*!< Place to store Contact info from a REFER extension */
925 AST_STRING_FIELD(replaces_callid); /*!< Replace info: callid */
926 AST_STRING_FIELD(replaces_callid_totag); /*!< Replace info: to-tag */
927 AST_STRING_FIELD(replaces_callid_fromtag); /*!< Replace info: from-tag */
929 int attendedtransfer; /*!< Attended or blind transfer? */
930 int localtransfer; /*!< Transfer to local domain? */
931 enum referstatus status; /*!< REFER status */
934 /*! \brief Struct to handle custom SIP notify requests. Dynamically allocated when needed */
936 struct ast_variable *headers;
937 struct ast_str *content;
940 /*! \brief Structure that encapsulates all attributes related to running
941 * SIP Session-Timers feature on a per dialog basis.
944 int st_active; /*!< Session-Timers on/off */
945 int st_interval; /*!< Session-Timers negotiated session refresh interval */
946 enum st_refresher st_ref; /*!< Session-Timers cached refresher */
947 int st_schedid; /*!< Session-Timers ast_sched scheduler id */
948 int st_active_peer_ua; /*!< Session-Timers on/off in peer UA */
949 int st_cached_min_se; /*!< Session-Timers cached Min-SE */
950 int st_cached_max_se; /*!< Session-Timers cached Session-Expires */
951 enum st_mode st_cached_mode; /*!< Session-Timers cached M.O. */
952 enum st_refresher st_cached_ref; /*!< Session-Timers session refresher */
953 unsigned char quit_flag:1; /*!< Stop trying to lock; just quit */
957 /*! \brief Structure that encapsulates all attributes related to configuration
958 * of SIP Session-Timers feature on a per user/peer basis.
961 enum st_mode st_mode_oper; /*!< Mode of operation for Session-Timers */
962 enum st_refresher_param st_ref; /*!< Session-Timer refresher */
963 int st_min_se; /*!< Lowest threshold for session refresh interval */
964 int st_max_se; /*!< Highest threshold for session refresh interval */
967 /*! \brief Structure for remembering offered media in an INVITE, to make sure we reply
968 to all media streams. */
969 struct offered_media {
970 enum media_type type; /*!< The type of media that was offered */
971 char *decline_m_line; /*!< Used if the media type is unknown/unused or a media stream is declined */
972 AST_LIST_ENTRY(offered_media) next;
975 /*! Additional headers to send with MESSAGE method packet. */
977 AST_LIST_ENTRY(sip_msg_hdr) next;
978 /*! Name of header to stick in MESSAGE */
980 /*! Value of header to stick in MESSAGE */
982 /*! The name and value strings are stuffed here in that order. */
986 /*! \brief Structure used for each SIP dialog, ie. a call, a registration, a subscribe.
987 * Created and initialized by sip_alloc(), the descriptor goes into the list of
988 * descriptors (dialoglist).
991 struct sip_pvt *next; /*!< Next dialog in chain */
992 enum invitestates invitestate; /*!< Track state of SIP_INVITEs */
993 struct ast_callid *logger_callid; /*!< Identifier for call used in log messages */
994 int method; /*!< SIP method that opened this dialog */
995 AST_DECLARE_STRING_FIELDS(
996 AST_STRING_FIELD(callid); /*!< Global CallID */
997 AST_STRING_FIELD(initviabranch); /*!< The branch ID from the topmost Via header in the initial request */
998 AST_STRING_FIELD(initviasentby); /*!< The sent-by from the topmost Via header in the initial request */
999 AST_STRING_FIELD(accountcode); /*!< Account code */
1000 AST_STRING_FIELD(realm); /*!< Authorization realm */
1001 AST_STRING_FIELD(nonce); /*!< Authorization nonce */
1002 AST_STRING_FIELD(opaque); /*!< Opaque nonsense */
1003 AST_STRING_FIELD(qop); /*!< Quality of Protection, since SIP wasn't complicated enough yet. */
1004 AST_STRING_FIELD(domain); /*!< Authorization domain */
1005 AST_STRING_FIELD(from); /*!< The From: header */
1006 AST_STRING_FIELD(useragent); /*!< User agent in SIP request */
1007 AST_STRING_FIELD(exten); /*!< Extension where to start */
1008 AST_STRING_FIELD(context); /*!< Context for this call */
1009 AST_STRING_FIELD(messagecontext); /*!< Default context for outofcall messages. */
1010 AST_STRING_FIELD(subscribecontext); /*!< Subscribecontext */
1011 AST_STRING_FIELD(subscribeuri); /*!< Subscribecontext */
1012 AST_STRING_FIELD(fromdomain); /*!< Domain to show in the from field */
1013 AST_STRING_FIELD(fromuser); /*!< User to show in the user field */
1014 AST_STRING_FIELD(fromname); /*!< Name to show in the user field */
1015 AST_STRING_FIELD(tohost); /*!< Host we should put in the "to" field */
1016 AST_STRING_FIELD(todnid); /*!< DNID of this call (overrides host) */
1017 AST_STRING_FIELD(language); /*!< Default language for this call */
1018 AST_STRING_FIELD(mohinterpret); /*!< MOH class to use when put on hold */
1019 AST_STRING_FIELD(mohsuggest); /*!< MOH class to suggest when putting a peer on hold */
1020 AST_STRING_FIELD(rdnis); /*!< Referring DNIS */
1021 AST_STRING_FIELD(redircause); /*!< Referring cause */
1022 AST_STRING_FIELD(theirtag); /*!< Their tag */
1023 AST_STRING_FIELD(theirprovtag); /*!< Provisional their tag, used when evaluating responses to invites */
1024 AST_STRING_FIELD(tag); /*!< Our tag for this session */
1025 AST_STRING_FIELD(username); /*!< [user] name */
1026 AST_STRING_FIELD(peername); /*!< [peer] name, not set if [user] */
1027 AST_STRING_FIELD(authname); /*!< Who we use for authentication */
1028 AST_STRING_FIELD(uri); /*!< Original requested URI */
1029 AST_STRING_FIELD(okcontacturi); /*!< URI from the 200 OK on INVITE */
1030 AST_STRING_FIELD(peersecret); /*!< Password */
1031 AST_STRING_FIELD(peermd5secret);
1032 AST_STRING_FIELD(cid_num); /*!< Caller*ID number */
1033 AST_STRING_FIELD(cid_name); /*!< Caller*ID name */
1034 AST_STRING_FIELD(cid_tag); /*!< Caller*ID tag */
1035 AST_STRING_FIELD(mwi_from); /*!< Name to place in the From header in outgoing NOTIFY requests */
1036 AST_STRING_FIELD(fullcontact); /*!< The Contact: that the UA registers with us */
1037 /* we only store the part in <brackets> in this field. */
1038 AST_STRING_FIELD(our_contact); /*!< Our contact header */
1039 AST_STRING_FIELD(url); /*!< URL to be sent with next message to peer */
1040 AST_STRING_FIELD(parkinglot); /*!< Parkinglot */
1041 AST_STRING_FIELD(engine); /*!< RTP engine to use */
1042 AST_STRING_FIELD(dialstring); /*!< The dialstring used to call this SIP endpoint */
1043 AST_STRING_FIELD(last_presence_subtype); /*!< The last presence subtype sent for a subscription. */
1044 AST_STRING_FIELD(last_presence_message); /*!< The last presence message for a subscription */
1045 AST_STRING_FIELD(msg_body); /*!< Text for a MESSAGE body */
1046 AST_STRING_FIELD(tel_phone_context); /*!< The phone-context portion of a TEL URI */
1048 char via[128]; /*!< Via: header */
1049 int maxforwards; /*!< SIP Loop prevention */
1050 struct sip_socket socket; /*!< The socket used for this dialog */
1051 uint32_t ocseq; /*!< Current outgoing seqno */
1052 uint32_t icseq; /*!< Current incoming seqno */
1053 uint32_t init_icseq; /*!< Initial incoming seqno from first request */
1054 ast_group_t callgroup; /*!< Call group */
1055 ast_group_t pickupgroup; /*!< Pickup group */
1056 struct ast_namedgroups *named_callgroups; /*!< Named call group */
1057 struct ast_namedgroups *named_pickupgroups; /*!< Named pickup group */
1058 uint32_t lastinvite; /*!< Last seqno of invite */
1059 struct ast_flags flags[3]; /*!< SIP_ flags */
1061 /* boolean flags that don't belong in flags */
1062 unsigned short do_history:1; /*!< Set if we want to record history */
1063 unsigned short alreadygone:1; /*!< the peer has sent a message indicating termination of the dialog */
1064 unsigned short needdestroy:1; /*!< this dialog needs to be destroyed by the monitor thread */
1065 unsigned short final_destruction_scheduled:1; /*!< final dialog destruction is scheduled. Keep dialog
1066 * around until then to handle retransmits. */
1067 unsigned short outgoing_call:1; /*!< this is an outgoing call */
1068 unsigned short answered_elsewhere:1; /*!< This call is cancelled due to answer on another channel */
1069 unsigned short novideo:1; /*!< Didn't get video in invite, don't offer */
1070 unsigned short notext:1; /*!< Text not supported (?) */
1071 unsigned short session_modify:1; /*!< Session modification request true/false */
1072 unsigned short route_persistent:1; /*!< Is this the "real" route? */
1073 unsigned short autoframing:1; /*!< Whether to use our local configuration for frame sizes (off)
1074 * or respect the other endpoint's request for frame sizes (on)
1075 * for incoming calls
1077 unsigned short req_secure_signaling:1;/*!< Whether we are required to have secure signaling or not */
1078 unsigned short natdetected:1; /*!< Whether we detected a NAT when processing the Via */
1079 int timer_t1; /*!< SIP timer T1, ms rtt */
1080 int timer_b; /*!< SIP timer B, ms */
1081 unsigned int sipoptions; /*!< Supported SIP options on the other end */
1082 unsigned int reqsipoptions; /*!< Required SIP options on the other end */
1083 struct ast_codec_pref prefs; /*!< codec prefs */
1084 struct ast_format_cap *caps; /*!< Special capability (codec) */
1085 struct ast_format_cap *jointcaps; /*!< Supported capability at both ends (codecs) */
1086 struct ast_format_cap *peercaps; /*!< Supported peer capability */
1087 struct ast_format_cap *redircaps; /*!< Redirect codecs */
1088 struct ast_format_cap *prefcaps; /*!< Preferred codec (outbound only) */
1089 int noncodeccapability; /*!< DTMF RFC2833 telephony-event */
1090 int jointnoncodeccapability; /*!< Joint Non codec capability */
1091 int maxcallbitrate; /*!< Maximum Call Bitrate for Video Calls */
1092 int t38_maxdatagram; /*!< T.38 FaxMaxDatagram override */
1093 int request_queue_sched_id; /*!< Scheduler ID of any scheduled action to process queued requests */
1094 int provisional_keepalive_sched_id; /*!< Scheduler ID for provisional responses that need to be sent out to avoid cancellation */
1095 const char *last_provisional; /*!< The last successfully transmitted provisonal response message */
1096 int authtries; /*!< Times we've tried to authenticate */
1097 struct sip_proxy *outboundproxy; /*!< Outbound proxy for this dialog. Use ref_proxy to set this instead of setting it directly*/
1098 struct t38properties t38; /*!< T38 settings */
1099 struct ast_sockaddr udptlredirip; /*!< Where our T.38 UDPTL should be going if not to us */
1100 struct ast_udptl *udptl; /*!< T.38 UDPTL session */
1101 char zone[MAX_TONEZONE_COUNTRY]; /*!< Default tone zone for channels created by this dialog */
1102 int callingpres; /*!< Calling presentation */
1103 int expiry; /*!< How long we take to expire */
1104 int sessionversion; /*!< SDP Session Version */
1105 int sessionid; /*!< SDP Session ID */
1106 long branch; /*!< The branch identifier of this session */
1107 long invite_branch; /*!< The branch used when we sent the initial INVITE */
1108 int64_t sessionversion_remote; /*!< Remote UA's SDP Session Version */
1109 unsigned int portinuri:1; /*!< Non zero if a port has been specified, will also disable srv lookups */
1110 struct ast_sockaddr sa; /*!< Our peer */
1111 struct ast_sockaddr redirip; /*!< Where our RTP should be going if not to us */
1112 struct ast_sockaddr vredirip; /*!< Where our Video RTP should be going if not to us */
1113 struct ast_sockaddr tredirip; /*!< Where our Text RTP should be going if not to us */
1114 time_t lastrtprx; /*!< Last RTP received */
1115 time_t lastrtptx; /*!< Last RTP sent */
1116 int rtptimeout; /*!< RTP timeout time */
1117 int rtpholdtimeout; /*!< RTP timeout time on hold*/
1118 int rtpkeepalive; /*!< RTP send packets for keepalive */
1119 struct ast_acl_list *directmediaacl; /*!< Which IPs are allowed to interchange direct media with this peer - copied from sip_peer */
1120 struct ast_sockaddr recv; /*!< Received as */
1121 struct ast_sockaddr ourip; /*!< Our IP (as seen from the outside) */
1122 enum transfermodes allowtransfer; /*!< REFER: restriction scheme */
1123 struct ast_channel *owner; /*!< Who owns us (if we have an owner) */
1124 struct sip_route route; /*!< List of routing steps (fm Record-Route) */
1125 struct sip_notify *notify; /*!< Custom notify type */
1126 struct sip_auth_container *peerauth;/*!< Realm authentication credentials */
1127 int noncecount; /*!< Nonce-count */
1128 unsigned int stalenonce:1; /*!< Marks the current nonce as responded too */
1129 unsigned int ongoing_reinvite:1; /*!< There is a reinvite in progress that might need to be cleaned up */
1130 char lastmsg[256]; /*!< Last Message sent/received */
1131 int amaflags; /*!< AMA Flags */
1132 uint32_t pendinginvite; /*!< Any pending INVITE or state NOTIFY (in subscribe pvt's) ? (seqno of this) */
1133 uint32_t glareinvite; /*!< A invite received while a pending invite is already present is stored here. Its seqno is the
1134 value. Since this glare invite's seqno is not the same as the pending invite's, it must be
1135 held in order to properly process acknowledgements for our 491 response. */
1136 struct sip_request initreq; /*!< Latest request that opened a new transaction
1138 NOT the request that opened the dialog */
1140 int initid; /*!< Auto-congest ID if appropriate (scheduler) */
1141 int waitid; /*!< Wait ID for scheduler after 491 or other delays */
1142 int reinviteid; /*!< Reinvite in case of provisional, but no final response */
1143 int autokillid; /*!< Auto-kill ID (scheduler) */
1144 int t38id; /*!< T.38 Response ID */
1145 struct sip_refer *refer; /*!< REFER: SIP transfer data structure */
1146 enum subscriptiontype subscribed; /*!< SUBSCRIBE: Is this dialog a subscription? */
1147 int stateid; /*!< SUBSCRIBE: ID for devicestate subscriptions */
1148 int laststate; /*!< SUBSCRIBE: Last known extension state */
1149 struct ao2_container *last_device_state_info; /*!< SUBSCRIBE: last known extended extension state (take care of refs)*/
1150 struct timeval last_ringing_channel_time; /*!< SUBSCRIBE: channel timestamp of the channel which caused the last early-state notification */
1151 int last_presence_state; /*!< SUBSCRIBE: Last known presence state */
1152 uint32_t dialogver; /*!< SUBSCRIBE: Version for subscription dialog-info */
1154 struct ast_dsp *dsp; /*!< Inband DTMF or Fax CNG tone Detection dsp */
1156 struct sip_peer *relatedpeer; /*!< If this dialog is related to a peer, which one
1157 Used in peerpoke, mwi subscriptions */
1158 struct sip_registry *registry; /*!< If this is a REGISTER dialog, to which registry */
1159 struct ast_rtp_instance *rtp; /*!< RTP Session */
1160 struct ast_rtp_instance *vrtp; /*!< Video RTP session */
1161 struct ast_rtp_instance *trtp; /*!< Text RTP session */
1162 struct sip_pkt *packets; /*!< Packets scheduled for re-transmission */
1163 struct sip_history_head *history; /*!< History of this SIP dialog */
1164 size_t history_entries; /*!< Number of entires in the history */
1165 struct ast_variable *chanvars; /*!< Channel variables to set for inbound call */
1166 AST_LIST_HEAD_NOLOCK(, sip_msg_hdr) msg_headers; /*!< Additional MESSAGE headers to send. */
1167 AST_LIST_HEAD_NOLOCK(request_queue, sip_request) request_queue; /*!< Requests that arrived but could not be processed immediately */
1168 struct sip_invite_param *options; /*!< Options for INVITE */
1169 struct sip_st_dlg *stimer; /*!< SIP Session-Timers */
1170 struct ast_sdp_srtp *srtp; /*!< Structure to hold Secure RTP session data for audio */
1171 struct ast_sdp_srtp *vsrtp; /*!< Structure to hold Secure RTP session data for video */
1172 struct ast_sdp_srtp *tsrtp; /*!< Structure to hold Secure RTP session data for text */
1174 int red; /*!< T.140 RTP Redundancy */
1175 int hangupcause; /*!< Storage of hangupcause copied from our owner before we disconnect from the AST channel (only used at hangup) */
1177 struct sip_subscription_mwi *mwi; /*!< If this is a subscription MWI dialog, to which subscription */
1178 /*! The SIP methods supported by this peer. We get this information from the Allow header of the first
1179 * message we receive from an endpoint during a dialog.
1181 unsigned int allowed_methods;
1182 /*! Some peers are not trustworthy with their Allow headers, and so we need to override their wicked
1183 * ways through configuration. This is a copy of the peer's disallowed_methods, so that we can apply them
1184 * to the sip_pvt at various stages of dialog establishment
1186 unsigned int disallowed_methods;
1187 /*! When receiving an SDP offer, it is important to take note of what media types were offered.
1188 * By doing this, even if we don't want to answer a particular media stream with something meaningful, we can
1189 * still put an m= line in our answer with the port set to 0.
1191 * The reason for the length being 4 (OFFERED_MEDIA_COUNT) is that in this branch of Asterisk, the only media types supported are
1192 * image, audio, text, and video. Therefore we need to keep track of which types of media were offered.
1193 * Note that secure RTP defines new types of SDP media.
1195 * If we wanted to be 100% correct, we would keep a list of all media streams offered. That way we could respond
1196 * even to unknown media types, and we could respond to multiple streams of the same type. Such large-scale changes
1197 * are not a good idea for released branches, though, so we're compromising by just making sure that for the common cases:
1198 * audio and video, audio and T.38, and audio and text, we give the appropriate response to both media streams.
1200 * The large-scale changes would be a good idea for implementing during an SDP rewrite.
1202 AST_LIST_HEAD_NOLOCK(, offered_media) offered_media;
1203 struct ast_cc_config_params *cc_params;
1204 struct sip_epa_entry *epa_entry;
1205 int fromdomainport; /*!< Domain port to show in from field */
1207 struct ast_rtp_dtls_cfg dtls_cfg;
1210 /*! \brief sip packet - raw format for outbound packets that are sent or scheduled for transmission
1211 * Packets are linked in a list, whose head is in the struct sip_pvt they belong to.
1212 * Each packet holds a reference to the parent struct sip_pvt.
1213 * This structure is allocated in __sip_reliable_xmit() and only for packets that
1214 * require retransmissions.
1217 struct sip_pkt *next; /*!< Next packet in linked list */
1218 int retrans; /*!< Retransmission number */
1219 int method; /*!< SIP method for this packet */
1220 uint32_t seqno; /*!< Sequence number */
1221 char is_resp; /*!< 1 if this is a response packet (e.g. 200 OK), 0 if it is a request */
1222 char is_fatal; /*!< non-zero if there is a fatal error */
1223 int response_code; /*!< If this is a response, the response code */
1224 struct sip_pvt *owner; /*!< Owner AST call */
1225 int retransid; /*!< Retransmission ID */
1226 int timer_a; /*!< SIP timer A, retransmission timer */
1227 int timer_t1; /*!< SIP Timer T1, estimated RTT or 500 ms */
1228 struct timeval time_sent; /*!< When pkt was sent */
1229 int64_t retrans_stop_time; /*!< Time in ms after 'now' that retransmission must stop */
1230 int retrans_stop; /*!< Timeout is reached, stop retransmission */
1231 struct ast_str *data;
1235 * \brief A peer's mailbox
1237 * We could use STRINGFIELDS here, but for only one string, its
1238 * too much effort ...
1240 struct sip_mailbox {
1241 /*! Associated MWI subscription */
1242 struct stasis_subscription *event_sub;
1243 AST_LIST_ENTRY(sip_mailbox) entry;
1244 unsigned int delme:1;
1248 /*! \brief Structure for SIP peer data, we place calls to peers if registered or fixed IP address (host)
1250 /* XXX field 'name' must be first otherwise sip_addrcmp() will fail, as will astobj2 hashing of the structure */
1252 char name[80]; /*!< the unique name of this object */
1253 AST_DECLARE_STRING_FIELDS(
1254 AST_STRING_FIELD(secret); /*!< Password for inbound auth */
1255 AST_STRING_FIELD(md5secret); /*!< Password in MD5 */
1256 AST_STRING_FIELD(description); /*!< Description of this peer */
1257 AST_STRING_FIELD(remotesecret); /*!< Remote secret (trunks, remote devices) */
1258 AST_STRING_FIELD(context); /*!< Default context for incoming calls */
1259 AST_STRING_FIELD(messagecontext); /*!< Default context for outofcall messages. */
1260 AST_STRING_FIELD(subscribecontext); /*!< Default context for subscriptions */
1261 AST_STRING_FIELD(username); /*!< Temporary username until registration */
1262 AST_STRING_FIELD(accountcode); /*!< Account code */
1263 AST_STRING_FIELD(tohost); /*!< If not dynamic, IP address */
1264 AST_STRING_FIELD(regexten); /*!< Extension to register (if regcontext is used) */
1265 AST_STRING_FIELD(fromuser); /*!< From: user when calling this peer */
1266 AST_STRING_FIELD(fromdomain); /*!< From: domain when calling this peer */
1267 AST_STRING_FIELD(fullcontact); /*!< Contact registered with us (not in sip.conf) */
1268 AST_STRING_FIELD(cid_num); /*!< Caller ID num */
1269 AST_STRING_FIELD(cid_name); /*!< Caller ID name */
1270 AST_STRING_FIELD(cid_tag); /*!< Caller ID tag */
1271 AST_STRING_FIELD(vmexten); /*!< Dialplan extension for MWI notify message*/
1272 AST_STRING_FIELD(language); /*!< Default language for prompts */
1273 AST_STRING_FIELD(mohinterpret); /*!< Music on Hold class */
1274 AST_STRING_FIELD(mohsuggest); /*!< Music on Hold class */
1275 AST_STRING_FIELD(parkinglot); /*!< Parkinglot */
1276 AST_STRING_FIELD(useragent); /*!< User agent in SIP request (saved from registration) */
1277 AST_STRING_FIELD(mwi_from); /*!< Name to place in From header for outgoing NOTIFY requests */
1278 AST_STRING_FIELD(engine); /*!< RTP Engine to use */
1279 AST_STRING_FIELD(unsolicited_mailbox); /*!< Mailbox to store received unsolicited MWI NOTIFY messages information in */
1280 AST_STRING_FIELD(zone); /*!< Tonezone for this device */
1281 AST_STRING_FIELD(record_on_feature); /*!< Feature to use when receiving INFO with record: on during a call */
1282 AST_STRING_FIELD(record_off_feature); /*!< Feature to use when receiving INFO with record: off during a call */
1283 AST_STRING_FIELD(callback); /*!< Callback extension */
1285 struct sip_socket socket; /*!< Socket used for this peer */
1286 enum ast_transport default_outbound_transport; /*!< Peer Registration may change the default outbound transport.
1287 If register expires, default should be reset. to this value */
1288 /* things that don't belong in flags */
1289 unsigned short transports:5; /*!< Transports (enum ast_transport) that are acceptable for this peer */
1290 unsigned short is_realtime:1; /*!< this is a 'realtime' peer */
1291 unsigned short rt_fromcontact:1;/*!< copy fromcontact from realtime */
1292 unsigned short host_dynamic:1; /*!< Dynamic Peers register with Asterisk */
1293 unsigned short selfdestruct:1; /*!< Automatic peers need to destruct themselves */
1294 unsigned short the_mark:1; /*!< moved out of ASTOBJ into struct proper; That which bears the_mark should be deleted! */
1295 unsigned short autoframing:1; /*!< Whether to use our local configuration for frame sizes (off)
1296 * or respect the other endpoint's request for frame sizes (on)
1297 * for incoming calls
1299 unsigned short deprecated_username:1; /*!< If it's a realtime peer, are they using the deprecated "username" instead of "defaultuser" */
1300 struct sip_auth_container *auth;/*!< Realm authentication credentials */
1301 int amaflags; /*!< AMA Flags (for billing) */
1302 int callingpres; /*!< Calling id presentation */
1303 int inuse; /*!< Number of calls in use */
1304 int ringing; /*!< Number of calls ringing */
1305 int onhold; /*!< Peer has someone on hold */
1306 int call_limit; /*!< Limit of concurrent calls */
1307 int t38_maxdatagram; /*!< T.38 FaxMaxDatagram override */
1308 int busy_level; /*!< Level of active channels where we signal busy */
1309 int maxforwards; /*!< SIP Loop prevention */
1310 enum transfermodes allowtransfer; /*! SIP Refer restriction scheme */
1311 struct ast_codec_pref prefs; /*!< codec prefs */
1312 int lastmsgssent; /*!< The last known VM message counts (new/old) */
1313 unsigned int sipoptions; /*!< Supported SIP options */
1314 struct ast_flags flags[3]; /*!< SIP_ flags */
1316 /*! Mailboxes that this peer cares about */
1317 AST_LIST_HEAD_NOLOCK(, sip_mailbox) mailboxes;
1319 int maxcallbitrate; /*!< Maximum Bitrate for a video call */
1320 int expire; /*!< When to expire this peer registration */
1321 struct ast_format_cap *caps; /*!< Codec capability */
1322 int rtptimeout; /*!< RTP timeout */
1323 int rtpholdtimeout; /*!< RTP Hold Timeout */
1324 int rtpkeepalive; /*!< Send RTP packets for keepalive */
1325 ast_group_t callgroup; /*!< Call group */
1326 ast_group_t pickupgroup; /*!< Pickup group */
1327 struct ast_namedgroups *named_callgroups; /*!< Named call group */
1328 struct ast_namedgroups *named_pickupgroups; /*!< Named pickup group */
1329 struct sip_proxy *outboundproxy;/*!< Outbound proxy for this peer */
1330 struct ast_dnsmgr_entry *dnsmgr;/*!< DNS refresh manager for peer */
1331 struct ast_sockaddr addr; /*!< IP address of peer */
1332 unsigned int portinuri:1; /*!< Whether the port should be included in the URI */
1333 struct sip_pvt *call; /*!< Call pointer */
1334 int pokeexpire; /*!< Qualification: When to expire poke (qualify= checking) */
1335 int lastms; /*!< Qualification: How long last response took (in ms), or -1 for no response */
1336 int maxms; /*!< Qualification: Max ms we will accept for the host to be up, 0 to not monitor */
1337 int qualifyfreq; /*!< Qualification: Qualification: How often to check for the host to be up */
1338 struct timeval ps; /*!< Qualification: Time for sending SIP OPTION in sip_pke_peer() */
1339 int keepalive; /*!< Keepalive: How often to send keep alive packet */
1340 int keepalivesend; /*!< Keepalive: Scheduled item for sending keep alive packet */
1341 struct ast_sockaddr defaddr; /*!< Default IP address, used until registration */
1342 struct ast_acl_list *acl; /*!< Access control list */
1343 struct ast_acl_list *contactacl; /*!< Restrict what IPs are allowed in the Contact header (for registration) */
1344 struct ast_acl_list *directmediaacl; /*!< Restrict what IPs are allowed to interchange direct media with */
1345 struct ast_variable *chanvars; /*!< Variables to set for channel created by user */
1346 struct sip_pvt *mwipvt; /*!< Subscription for MWI */
1347 struct sip_st_cfg stimer; /*!< SIP Session-Timers */
1348 int timer_t1; /*!< The maximum T1 value for the peer */
1349 int timer_b; /*!< The maximum timer B (transaction timeouts) */
1350 int fromdomainport; /*!< The From: domain port */
1351 struct sip_route path; /*!< List of out-of-dialog outgoing routing steps (fm Path headers) */
1353 /*XXX Seems like we suddenly have two flags with the same content. Why? To be continued... */
1354 enum sip_peer_type type; /*!< Distinguish between "user" and "peer" types. This is used solely for CLI and manager commands */
1355 unsigned int disallowed_methods;
1356 struct ast_cc_config_params *cc_params;
1358 struct ast_endpoint *endpoint;
1360 struct ast_rtp_dtls_cfg dtls_cfg;
1364 * \brief Registrations with other SIP proxies
1366 * Created by sip_register(), the entry is linked in the 'regl' list,
1367 * and never deleted (other than at 'sip reload' or module unload times).
1368 * The entry always has a pending timeout, either waiting for an ACK to
1369 * the REGISTER message (in which case we have to retransmit the request),
1370 * or waiting for the next REGISTER message to be sent (either the initial one,
1371 * or once the previously completed registration one expires).
1372 * The registration can be in one of many states, though at the moment
1373 * the handling is a bit mixed.
1375 * \todo Convert this to astobj2
1377 struct sip_registry {
1378 ASTOBJ_COMPONENTS_FULL(struct sip_registry, 80, 1);
1379 AST_DECLARE_STRING_FIELDS(
1380 AST_STRING_FIELD(callid); /*!< Global Call-ID */
1381 AST_STRING_FIELD(realm); /*!< Authorization realm */
1382 AST_STRING_FIELD(nonce); /*!< Authorization nonce */
1383 AST_STRING_FIELD(opaque); /*!< Opaque nonsense */
1384 AST_STRING_FIELD(qop); /*!< Quality of Protection, since SIP wasn't complicated enough yet. */
1385 AST_STRING_FIELD(authdomain); /*!< Authorization domain */
1386 AST_STRING_FIELD(regdomain); /*!< Registration doamin */
1387 AST_STRING_FIELD(username); /*!< Who we are registering as */
1388 AST_STRING_FIELD(authuser); /*!< Who we *authenticate* as */
1389 AST_STRING_FIELD(hostname); /*!< Domain or host we register to */
1390 AST_STRING_FIELD(secret); /*!< Password in clear text */
1391 AST_STRING_FIELD(md5secret); /*!< Password in md5 */
1392 AST_STRING_FIELD(callback); /*!< Contact extension */
1393 AST_STRING_FIELD(peername); /*!< Peer registering to */
1394 AST_STRING_FIELD(localtag); /*!< Local tag generated same time as callid */
1396 enum ast_transport transport; /*!< Transport for this registration UDP, TCP or TLS */
1397 int portno; /*!< Optional port override */
1398 int regdomainport; /*!< Port override for domainport */
1399 int expire; /*!< Sched ID of expiration */
1400 int configured_expiry; /*!< Configured value to use for the Expires header */
1401 int expiry; /*!< Negotiated value used for the Expires header */
1402 int regattempts; /*!< Number of attempts (since the last success) */
1403 int timeout; /*!< sched id of sip_reg_timeout */
1404 int refresh; /*!< How often to refresh */
1405 struct sip_pvt *call; /*!< create a sip_pvt structure for each outbound "registration dialog" in progress */
1406 enum sipregistrystate regstate; /*!< Registration state (see above) */
1407 struct timeval regtime; /*!< Last successful registration time */
1408 int callid_valid; /*!< 0 means we haven't chosen callid for this registry yet. */
1409 uint32_t ocseq; /*!< Sequence number we got to for REGISTERs for this registry */
1410 struct ast_dnsmgr_entry *dnsmgr; /*!< DNS refresh manager for register */
1411 struct ast_sockaddr us; /*!< Who the server thinks we are */
1412 int noncecount; /*!< Nonce-count */
1413 char lastmsg[256]; /*!< Last Message sent/received */
1416 struct tcptls_packet {
1417 AST_LIST_ENTRY(tcptls_packet) entry;
1418 struct ast_str *data;
1421 /*! \brief Definition of a thread that handles a socket */
1422 struct sip_threadinfo {
1423 /*! TRUE if the thread needs to kill itself. (The module is being unloaded.) */
1425 int alert_pipe[2]; /*! Used to alert tcptls thread when packet is ready to be written */
1427 struct ast_tcptls_session_instance *tcptls_session;
1428 enum ast_transport type; /*!< We keep a copy of the type here so we can display it in the connection list */
1429 AST_LIST_HEAD_NOLOCK(, tcptls_packet) packet_q;
1433 * \brief Definition of an MWI subscription to another server
1435 * \todo Convert this to astobj2.
1437 struct sip_subscription_mwi {
1438 ASTOBJ_COMPONENTS_FULL(struct sip_subscription_mwi,1,1);
1439 AST_DECLARE_STRING_FIELDS(
1440 AST_STRING_FIELD(username); /*!< Who we are sending the subscription as */
1441 AST_STRING_FIELD(authuser); /*!< Who we *authenticate* as */
1442 AST_STRING_FIELD(hostname); /*!< Domain or host we subscribe to */
1443 AST_STRING_FIELD(secret); /*!< Password in clear text */
1444 AST_STRING_FIELD(mailbox); /*!< Mailbox store to put MWI into */
1446 enum ast_transport transport; /*!< Transport to use */
1447 int portno; /*!< Optional port override */
1448 int resub; /*!< Sched ID of resubscription */
1449 unsigned int subscribed:1; /*!< Whether we are currently subscribed or not */
1450 struct sip_pvt *call; /*!< Outbound subscription dialog */
1451 struct ast_dnsmgr_entry *dnsmgr; /*!< DNS refresh manager for subscription */
1452 struct ast_sockaddr us; /*!< Who the server thinks we are */
1456 * SIP PUBLISH support!
1457 * PUBLISH support was added to chan_sip due to its use in the call-completion
1458 * event package. In order to suspend and unsuspend monitoring of a called party,
1459 * a PUBLISH message must be sent. Rather than try to hack in PUBLISH transmission
1460 * and reception solely for the purposes of handling call-completion-related messages,
1461 * an effort has been made to create a generic framework for handling PUBLISH messages.
1463 * There are two main components to the effort, the event publication agent (EPA) and
1464 * the event state compositor (ESC). Both of these terms appear in RFC 3903, and the
1465 * implementation in Asterisk conforms to the defintions there. An EPA is a UAC that
1466 * transmits PUBLISH requests. An ESC is a UAS that receives PUBLISH requests and
1467 * acts appropriately based on the content of those requests.
1470 * The main structure in chan_sip is the event_state_compositor. There is an
1471 * event_state_compositor structure for each event package supported (as of Nov 2009
1472 * this is only the call-completion package). The structure contains data which is
1473 * intrinsic to the event package itself, such as the name of the package and a set
1474 * of callbacks for handling incoming PUBLISH requests. In addition, the
1475 * event_state_compositor struct contains an ao2_container of sip_esc_entries.
1477 * A sip_esc_entry corresponds to an entity which has sent a PUBLISH to Asterisk. We are
1478 * able to match the incoming PUBLISH to a sip_esc_entry using the Sip-If-Match header
1479 * of the message. Of course, if none is present, then a new sip_esc_entry will be created.
1481 * Once it is determined what type of PUBLISH request has come in (from RFC 3903, it may
1482 * be an initial, modify, refresh, or remove), then the event package-specific callbacks
1483 * may be called. If your event package doesn't need to take any specific action for a
1484 * specific PUBLISH type, it is perfectly safe to not define the callback at all. The callback
1485 * only needs to take care of application-specific information. If there is a problem, it is
1486 * up to the callback to take care of sending an appropriate 4xx or 5xx response code. In such
1487 * a case, the callback should return -1. This will tell the function that called the handler
1488 * that an appropriate error response has been sent. If the callback returns 0, however, then
1489 * the caller of the callback will generate a new entity tag and send a 200 OK response.
1491 * ESC entries are reference-counted, however as an implementor of a specific event package,
1492 * this should be transparent, since the reference counts are handled by the general ESC
1496 * The event publication agent in chan_sip is structured quite a bit differently than the
1497 * ESC. With an ESC, an appropriate entry has to be found based on the contents of an incoming
1498 * PUBLISH message. With an EPA, the application interested in sending the PUBLISH can maintain
1499 * a reference to the appropriate EPA entry instead. Similarly, when matching a PUBLISH response
1500 * to an appropriate EPA entry, the sip_pvt can maintain a reference to the corresponding
1501 * EPA entry. The result of this train of thought is that there is no compelling reason to
1502 * maintain a container of these entries.
1504 * Instead, there is only the sip_epa_entry structure. Every sip_epa_entry has an entity tag
1505 * that it maintains so that subsequent PUBLISH requests will be identifiable by the ESC on
1506 * the far end. In addition, there is a static_data field which contains information that is
1507 * common to all sip_epa_entries for a specific event package. This static data includes the
1508 * name of the event package and callbacks for handling specific responses for outgoing PUBLISHes.
1509 * Also, there is a field for pointing to instance-specific data. This can include the current
1510 * published state or other identifying information that is specific to an instance of an EPA
1511 * entry of a particular event package.
1513 * When an application wishes to send a PUBLISH request, it simply will call create_epa_entry,
1514 * followed by transmit_publish in order to send the PUBLISH. That's all that is necessary.
1515 * Like with ESC entries, sip_epa_entries are reference counted. Unlike ESC entries, though,
1516 * sip_epa_entries reference counts have to be maintained to some degree by the application making
1517 * use of the sip_epa_entry. The application will acquire a reference to the EPA entry when it
1518 * calls create_epa_entry. When the application has finished using the EPA entry (which may not
1519 * be until after several PUBLISH transactions have taken place) it must use ao2_ref to decrease
1520 * the reference count by 1.
1524 * \brief The states that can be represented in a SIP call-completion PUBLISH
1526 enum sip_cc_publish_state {
1527 /*! Closed, i.e. unavailable */
1529 /*! Open, i.e. available */
1534 * \brief The states that can be represented in a SIP call-completion NOTIFY
1536 enum sip_cc_notify_state {
1537 /*! Queued, i.e. unavailable */
1539 /*! Ready, i.e. available */
1544 * \brief The types of PUBLISH messages defined in RFC 3903
1546 enum sip_publish_type {
1551 * This actually is not defined in RFC 3903. We use this as a constant
1552 * to indicate that an incoming PUBLISH does not fit into any of the
1553 * other categories and is thus invalid.
1555 SIP_PUBLISH_UNKNOWN,
1560 * The first PUBLISH sent. This will contain a non-zero Expires header
1561 * as well as a body that indicates the current state of the endpoint
1562 * that has sent the message. The initial PUBLISH is the only type
1563 * of PUBLISH to not contain a Sip-If-Match header in it.
1565 SIP_PUBLISH_INITIAL,
1570 * Used to keep a published state from expiring. This will contain a
1571 * non-zero Expires header but no body since its purpose is not to
1574 SIP_PUBLISH_REFRESH,
1579 * Used to change state from its previous value. This will contain
1580 * a body updating the published state. May or may not contain an
1588 * Used to remove published state from an ESC. This will contain
1589 * an Expires header set to 0 and likely no body.
1595 * Data which is the same for all instances of an EPA for a
1596 * particular event package
1598 struct epa_static_data {
1599 /*! The event type */
1600 enum subscriptiontype event;
1602 * The name of the event as it would
1603 * appear in a SIP message
1607 * The callback called when a 200 OK is received on an outbound PUBLISH
1609 void (*handle_ok)(struct sip_pvt *, struct sip_request *, struct sip_epa_entry *);
1611 * The callback called when an error response is received on an outbound PUBLISH
1613 void (*handle_error)(struct sip_pvt *, const int resp, struct sip_request *, struct sip_epa_entry *);
1615 * Destructor to call to clean up instance data
1617 void (*destructor)(void *instance_data);
1621 * \brief backend for an event publication agent
1623 struct epa_backend {
1624 const struct epa_static_data *static_data;
1625 AST_LIST_ENTRY(epa_backend) next;
1628 struct sip_epa_entry {
1630 * When we are going to send a publish, we need to
1631 * know the type of PUBLISH to send.
1633 enum sip_publish_type publish_type;
1635 * When we send a PUBLISH, we have to be
1636 * sure to include the entity tag that we
1637 * received in the previous response.
1639 char entity_tag[SIPBUFSIZE];
1641 * The destination to which this EPA should send
1642 * PUBLISHes. This may be the name of a SIP peer
1645 char destination[SIPBUFSIZE];
1647 * The body of the most recently-sent PUBLISH message.
1648 * This is useful for situations such as authentication,
1649 * in which we must send a message identical to the
1650 * one previously sent
1652 char body[SIPBUFSIZE];
1654 * Every event package has some constant data and
1655 * callbacks that all instances will share. This
1656 * data resides in this field.
1658 const struct epa_static_data *static_data;
1660 * In addition to the static data that all instances
1661 * of sip_epa_entry will have, each instance will
1662 * require its own instance-specific data.
1664 void *instance_data;
1668 * \brief Instance data for a Call completion EPA entry
1670 struct cc_epa_entry {
1672 * The core ID of the CC transaction
1673 * for which this EPA entry belongs. This
1674 * essentially acts as a unique identifier
1675 * for the entry and is used in the hash
1676 * and comparison functions
1680 * We keep the last known state of the
1681 * device in question handy in case
1682 * it needs to be known by a third party.
1683 * Also, in the case where for some reason
1684 * we get asked to transmit state that we
1685 * already sent, we can just ignore the
1688 enum sip_cc_publish_state current_state;
1691 struct event_state_compositor;
1694 * \brief common ESC items for all event types
1696 * The entity_id field serves as a means by which
1697 * A specific entry may be found.
1699 struct sip_esc_entry {
1701 * The name of the party who
1702 * sent us the PUBLISH. This will more
1703 * than likely correspond to a peer name.
1705 * This field's utility isn't really that
1706 * great. It's mainly just a user-recognizable
1707 * handle that can be printed in debug messages.
1709 const char *device_name;
1711 * The event package for which this esc_entry
1712 * exists. Most of the time this isn't really
1713 * necessary since you'll have easy access to the
1714 * ESC which contains this entry. However, in
1715 * some circumstances, we won't have the ESC
1720 * The entity ID used when corresponding
1721 * with the EPA on the other side. As the
1722 * ESC, we generate an entity ID for each
1723 * received PUBLISH and store it in this
1726 char entity_tag[30];
1728 * The ID for the scheduler. We schedule
1729 * destruction of a sip_esc_entry when we
1730 * receive a PUBLISH. The destruction is
1731 * scheduled for the duration received in
1732 * the Expires header.
1736 * Each ESC entry will be for a specific
1737 * event type. Those entries will need to
1738 * carry data which is intrinsic to the
1739 * ESC entry but which is specific to
1742 void *event_specific_data;
1745 typedef int (* const esc_publish_callback)(struct sip_pvt *, struct sip_request *, struct event_state_compositor *, struct sip_esc_entry *);
1748 * \brief Callbacks for SIP ESCs
1751 * The names of the callbacks are self-explanatory. The
1752 * corresponding handler is called whenever the specific
1753 * type of PUBLISH is received.
1755 struct sip_esc_publish_callbacks {
1756 const esc_publish_callback initial_handler;
1757 const esc_publish_callback refresh_handler;
1758 const esc_publish_callback modify_handler;
1759 const esc_publish_callback remove_handler;
1762 struct sip_cc_agent_pvt {
1764 /* A copy of the original call's Call-ID.
1765 * We use this as a search key when attempting
1766 * to find a particular sip_pvt.
1768 char original_callid[SIPBUFSIZE];
1769 /* A copy of the exten called originally.
1770 * We use this to set the proper extension
1771 * to dial during the recall since the incoming
1772 * request URI is one that was generated just
1775 char original_exten[SIPBUFSIZE];
1776 /* A reference to the dialog which we will
1777 * be sending a NOTIFY on when it comes time
1780 struct sip_pvt *subscribe_pvt;
1781 /* When we send a NOTIFY, we include a URI
1782 * that should be used by the caller when he
1783 * wishes to send a PUBLISH or INVITE to us.
1784 * We store that URI here.
1786 char notify_uri[SIPBUFSIZE];
1787 /* When we advertise call completion to a caller,
1788 * we provide a URI for the caller to use when
1789 * he sends us a SUBSCRIBE. We store it for matching
1790 * purposes when we receive the SUBSCRIBE from the
1793 char subscribe_uri[SIPBUFSIZE];
1797 struct sip_monitor_instance {
1798 AST_DECLARE_STRING_FIELDS(
1799 AST_STRING_FIELD(subscribe_uri);
1800 AST_STRING_FIELD(notify_uri);
1801 AST_STRING_FIELD(peername);
1802 AST_STRING_FIELD(device_name);
1805 struct sip_pvt *subscription_pvt;
1806 struct sip_epa_entry *suspension_entry;
1809 /*! \brief List of well-known SIP options. If we get this in a require,
1810 we should check the list and answer accordingly. */
1811 static const struct cfsip_options {
1812 int id; /*!< Bitmap ID */
1813 int supported; /*!< Supported by Asterisk ? */
1814 char * const text; /*!< Text id, as in standard */
1815 } sip_options[] = { /* XXX used in 3 places */
1816 /* RFC3262: PRACK 100% reliability */
1817 { SIP_OPT_100REL, NOT_SUPPORTED, "100rel" },
1818 /* RFC3959: SIP Early session support */
1819 { SIP_OPT_EARLY_SESSION, NOT_SUPPORTED, "early-session" },
1820 /* SIMPLE events: RFC4662 */
1821 { SIP_OPT_EVENTLIST, NOT_SUPPORTED, "eventlist" },
1822 /* RFC 4916- Connected line ID updates */
1823 { SIP_OPT_FROMCHANGE, NOT_SUPPORTED, "from-change" },
1824 /* GRUU: Globally Routable User Agent URI's */
1825 { SIP_OPT_GRUU, NOT_SUPPORTED, "gruu" },
1826 /* RFC4244 History info */
1827 { SIP_OPT_HISTINFO, NOT_SUPPORTED, "histinfo" },
1828 /* RFC3911: SIP Join header support */
1829 { SIP_OPT_JOIN, NOT_SUPPORTED, "join" },
1830 /* Disable the REFER subscription, RFC 4488 */
1831 { SIP_OPT_NOREFERSUB, NOT_SUPPORTED, "norefersub" },
1832 /* SIP outbound - the final NAT battle - draft-sip-outbound */
1833 { SIP_OPT_OUTBOUND, NOT_SUPPORTED, "outbound" },
1834 /* RFC3327: Path support */
1835 { SIP_OPT_PATH, NOT_SUPPORTED, "path" },
1836 /* RFC3840: Callee preferences */
1837 { SIP_OPT_PREF, NOT_SUPPORTED, "pref" },
1838 /* RFC3312: Precondition support */
1839 { SIP_OPT_PRECONDITION, NOT_SUPPORTED, "precondition" },
1840 /* RFC3323: Privacy with proxies*/
1841 { SIP_OPT_PRIVACY, NOT_SUPPORTED, "privacy" },
1842 /* RFC-ietf-sip-uri-list-conferencing-02.txt conference invite lists */
1843 { SIP_OPT_RECLISTINV, NOT_SUPPORTED, "recipient-list-invite" },
1844 /* RFC-ietf-sip-uri-list-subscribe-02.txt - subscription lists */
1845 { SIP_OPT_RECLISTSUB, NOT_SUPPORTED, "recipient-list-subscribe" },
1846 /* RFC3891: Replaces: header for transfer */
1847 { SIP_OPT_REPLACES, SUPPORTED, "replaces" },
1848 /* One version of Polycom firmware has the wrong label */
1849 { SIP_OPT_REPLACES, SUPPORTED, "replace" },
1850 /* RFC4412 Resource priorities */
1851 { SIP_OPT_RESPRIORITY, NOT_SUPPORTED, "resource-priority" },
1852 /* RFC3329: Security agreement mechanism */
1853 { SIP_OPT_SEC_AGREE, NOT_SUPPORTED, "sec_agree" },
1854 /* RFC4092: Usage of the SDP ANAT Semantics in the SIP */
1855 { SIP_OPT_SDP_ANAT, NOT_SUPPORTED, "sdp-anat" },
1856 /* RFC4028: SIP Session-Timers */
1857 { SIP_OPT_TIMER, SUPPORTED, "timer" },
1858 /* RFC4538: Target-dialog */
1859 { SIP_OPT_TARGET_DIALOG,NOT_SUPPORTED, "tdialog" },
1867 AST_THREADSTORAGE(check_auth_buf);
1869 /*----------------------------------------------------------*/
1870 /*---- FUNCTIONS ----*/
1871 /*----------------------------------------------------------*/
1873 struct sip_peer *sip_find_peer(const char *peer, struct ast_sockaddr *addr, int realtime, int which_objects, int devstate_only, int transport);
1874 void sip_auth_headers(enum sip_auth_type code, char **header, char **respheader);
1875 const char *sip_get_header(const struct sip_request *req, const char *name);
1876 const char *sip_get_transport(enum ast_transport t);
1879 #define sip_ref_peer(arg1,arg2) _ref_peer((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
1880 #define sip_unref_peer(arg1,arg2) _unref_peer((arg1),(arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
1881 struct sip_peer *_ref_peer(struct sip_peer *peer, char *tag, char *file, int line, const char *func);
1882 void *_unref_peer(struct sip_peer *peer, char *tag, char *file, int line, const char *func);
1884 struct sip_peer *sip_ref_peer(struct sip_peer *peer, char *tag);
1885 void *sip_unref_peer(struct sip_peer *peer, char *tag);
1886 #endif /* REF_DEBUG */