![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
sip3.h
Go to the documentation of this file.
00001 /* 00002 * Asterisk -- A telephony toolkit for Linux. 00003 * 00004 * Implementation of SIP - The Session Initiation protocol 00005 * 00006 * Version 3 of the SIP channel 00007 * 00008 * Copyright (C) 2003-2006, Digium Inc 00009 * and Edvina AB (for the chan_sip3 additions/changes) 00010 * 00011 * Mark Spencer <markster@linux-support.net> 00012 * and Olle E. Johansson <oej@edvina.net> 00013 * 00014 * This program is free software, distributed under the terms of 00015 * the GNU General Public License 00016 * 00017 * 00018 * For more information about chan_sip3: \ref chan_sip3_00index 00019 */ 00020 00021 #ifndef _SIP3_H 00022 #define _SIP3_H 00023 00024 /* remove this line, and I can't be responsible for what happens to your 00025 favourite PBX ... :-) 00026 */ 00027 #define THIS_IS_A_TEST "Pineapples are sweet" 00028 00029 #ifndef FALSE 00030 #define FALSE 0 00031 #endif 00032 00033 #ifndef TRUE 00034 #define TRUE 1 00035 #endif 00036 00037 #ifndef MAX 00038 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 00039 #endif 00040 00041 00042 #define VIDEO_CODEC_MASK 0x1fc0000 /*!< Video codecs from H.261 thru AST_FORMAT_MAX_VIDEO */ 00043 #ifndef IPTOS_MINCOST 00044 #define IPTOS_MINCOST 0x02 00045 #endif 00046 00047 #define DEFAULT_DEFAULT_EXPIRY 120 00048 #define DEFAULT_MIN_EXPIRY 60 /*! Minimum expiry time for subscription and registration requests */ 00049 #define DEFAULT_MAX_EXPIRY 3600 /*! Maximum expiry time for regs and subs */ 00050 #define DEFAULT_REGISTRATION_TIMEOUT 20 00051 #define DEFAULT_MAX_FORWARDS 70 00052 #define DEFAULT_EXTERNREFRESH 30 00053 00054 /* These strings needs to be localized */ 00055 #define CALLERID_UNKNOWN "Unknown" 00056 00057 /*! \brief Magic marker for registration contacts */ 00058 #define REG_MAGICMARKER "ASTZVXW" 00059 00060 /* guard limit must be larger than guard secs */ 00061 /* guard min must be < 1000, and should be >= 250 */ 00062 #define EXPIRY_GUARD_SECS 15 /*!< How long before expiry do we reregister */ 00063 #define EXPIRY_GUARD_LIMIT 30 /*!< Below here, we use EXPIRY_GUARD_PCT instead of 00064 EXPIRY_GUARD_SECS */ 00065 #define EXPIRY_GUARD_MIN 500 /*!< This is the minimum guard time applied. If 00066 GUARD_PCT turns out to be lower than this, it 00067 will use this time instead. 00068 This is in milliseconds. */ 00069 #define EXPIRY_GUARD_PCT 0.20 /*!< Percentage of expires timeout to use when 00070 below EXPIRY_GUARD_LIMIT */ 00071 #define DEFAULT_EXPIRY 900 /*!< Expire slowly */ 00072 00073 #define DEFAULT_QUALIFY_MAXMS 2000 /*!< Qualification: Must be faster than 2 seconds by default */ 00074 #define DEFAULT_QUALIFY_FREQ_OK 60 * 1000 /*!< Qualification: How often to check for the host to be up */ 00075 00076 #define DEFAULT_QUALIFY_FREQ_NOTOK 10 * 1000 /*!< Qualification: How often to check, if the host is down... */ 00077 00078 #define DEFAULT_RETRANS 1000 /*!< How frequently to retransmit Default: 2 * 500 ms in RFC 3261 */ 00079 #define MAX_RETRANS 6 /*!< Try only 6 times for retransmissions, a total of 7 transmissions */ 00080 #define SIP_TIMER_T1_DEFAULT 500 /*!< Timer T1 default value (from rfc 3261) */ 00081 #define SIP_TIMER_T2_DEFAULT 4000 /*!< Timer T2 default value (from rfc 3261) */ 00082 #define SIP_TIMER_T4_DEFAULT 5000 /*!< Timer T4 default value (from rfc 3261) */ 00083 #define SIP_TIMER_B_DEFAULT (64 * SIP_TIMER_T1_DEFAULT) /*!< Timer B - timeout for INVITEs */ 00084 #define SIP_TIMER_F_DEFAULT (64 * SIP_TIMER_T1_DEFAULT) /*!< Timer F - timeout for non-INVITEs */ 00085 #define SIP_TRANS_TIMEOUT 32000 /*!< SIP request timeout (rfc 3261) 64*T1 00086 \todo Use known T1 for timeout (peerpoke) 00087 */ 00088 #define DEFAULT_TRANS_TIMEOUT -1 /* Use default SIP transaction timeout */ 00089 #define MAX_AUTHTRIES 3 /*!< Try authentication three times, then fail */ 00090 00091 #define SIP_MAX_HEADERS 64 /*!< Max amount of SIP headers to read */ 00092 #define SIP_MAX_LINES 64 /*!< Max amount of lines in SIP attachment (like SDP) */ 00093 00094 #define SIP_MAX_PACKET 4096 /*!< Also from RFC 3261 (2543), should sub headers tho */ 00095 00096 #define SIP_MSG_BUFSIZE 65536 00097 00098 #define INITIAL_CSEQ 101 /*!< our initial sip sequence number */ 00099 00100 #define RTP 1 00101 #define NO_RTP 0 00102 00103 /*! Define SIP option tags, used in Require: and Supported: headers 00104 We need to be aware of these properties in the phones to use 00105 the replace: header. We should not do that without knowing 00106 that the other end supports it... 00107 This is nothing we can configure, we learn by the dialog 00108 Supported: header on the REGISTER (peer) or the INVITE 00109 (other devices) 00110 We are not using many of these today, but will in the future. 00111 This is documented in RFC 3261 00112 */ 00113 #define SUPPORTED 1 00114 #define NOT_SUPPORTED 0 00115 00116 #define SIP_OPT_REPLACES (1 << 0) 00117 #define SIP_OPT_100REL (1 << 1) 00118 #define SIP_OPT_TIMER (1 << 2) 00119 #define SIP_OPT_EARLY_SESSION (1 << 3) 00120 #define SIP_OPT_JOIN (1 << 4) 00121 #define SIP_OPT_PATH (1 << 5) 00122 #define SIP_OPT_PREF (1 << 6) 00123 #define SIP_OPT_PRECONDITION (1 << 7) 00124 #define SIP_OPT_PRIVACY (1 << 8) 00125 #define SIP_OPT_SDP_ANAT (1 << 9) 00126 #define SIP_OPT_SEC_AGREE (1 << 10) 00127 #define SIP_OPT_EVENTLIST (1 << 11) 00128 #define SIP_OPT_GRUU (1 << 12) 00129 #define SIP_OPT_TARGET_DIALOG (1 << 13) 00130 #define SIP_OPT_NOREFERSUB (1 << 14) 00131 #define SIP_OPT_HISTINFO (1 << 15) 00132 #define SIP_OPT_RESPRIORITY (1 << 16) 00133 00134 00135 /*! \brief SIP Methods we support */ 00136 #define ALLOWED_METHODS "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY" 00137 00138 /*! \brief SIP Extensions we support */ 00139 #define SUPPORTED_EXTENSIONS "replaces" 00140 00141 00142 /* Default values, set and reset in reload_config before reading configuration */ 00143 /* These are default values in the source. There are other recommended values in the 00144 sip.conf.sample for new installations. These may differ to keep backwards compatibility, 00145 yet encouraging new behaviour on new installations 00146 */ 00147 #define DEFAULT_LISTEN_SIP_PORT 5060 /*!< From RFC 3261 (former 2543) */ 00148 #define STANDARD_SIP_PORT 5060 /*!< From RFC 3261 (former 2543) */ 00149 #define DEFAULT_CONTEXT "default" 00150 #define DEFAULT_MOHINTERPRET "default" 00151 #define DEFAULT_MOHSUGGEST "" 00152 #define DEFAULT_VMEXTEN "asterisk" 00153 #define DEFAULT_CALLERID "asterisk" 00154 #define DEFAULT_NOTIFYMIME "application/simple-message-summary" 00155 #define DEFAULT_MWITIME 10 00156 #define DEFAULT_ALLOWGUEST TRUE 00157 #define DEFAULT_SRVLOOKUP FALSE /*!< Recommended setting is ON */ 00158 #define DEFAULT_COMPACTHEADERS FALSE 00159 #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. */ 00160 #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. */ 00161 #define DEFAULT_TOS_VIDEO 0 /*!< Video packets should be marked as DSCP AF41, but the default is 0 to be compatible with previous versions. */ 00162 #define DEFAULT_TOS_PRESENCE 0 /*!< Presence notifications does not need SIP priority */ 00163 #define DEFAULT_ALLOW_EXT_DOM TRUE 00164 #define DEFAULT_REALM "asterisk" 00165 #define DEFAULT_NOTIFYRINGING TRUE 00166 #define DEFAULT_AUTOCREATEPEER FALSE 00167 #define DEFAULT_QUALIFY FALSE 00168 #define DEFAULT_T1MIN 100 /*!< 100 MS for minimal roundtrip time */ 00169 #define DEFAULT_MAX_CALL_BITRATE (384) /*!< Max bitrate for video */ 00170 #ifndef DEFAULT_USERAGENT 00171 #define DEFAULT_USERAGENT "Asterisk PBX" /*!< Default Useragent: header unless re-defined in sip.conf */ 00172 #endif 00173 00174 #define DEC_CALL_LIMIT 0 00175 #define INC_CALL_LIMIT 1 00176 #define DEC_CALL_RINGING 2 00177 #define INC_CALL_RINGING 3 00178 00179 /* --------- ENUM declarations */ 00180 00181 /*! \brief Variants for sending responses with transmit_response_with_attachment() */ 00182 enum responseattach { 00183 WITH_MINEXPIRY, 00184 WITH_DATE, 00185 WITH_ALLOW, 00186 WITH_SDP, 00187 WITH_T38_SDP, 00188 }; 00189 00190 /*! \brief Authorization scheme for call transfers 00191 \note Not a bitfield flag, since there are plans for other modes, 00192 like "only allow transfers for authenticated devices" */ 00193 enum transfermodes { 00194 TRANSFER_OPENFORALL, /*!< Allow all SIP transfers */ 00195 TRANSFER_CLOSED, /*!< Allow no SIP transfers */ 00196 }; 00197 00198 typedef enum { 00199 AST_FALSE = 0, 00200 AST_TRUE = 1, 00201 AST_HAVENOCLUEANDDONOTCARE = -1, 00202 } sip_boolean; 00203 00204 enum sip_result { 00205 AST_SUCCESS = 0, 00206 AST_FAILURE = -1, 00207 }; 00208 00209 /* Do _NOT_ make any changes to this enum, or the array following it; 00210 if you think you are doing the right thing, you are probably 00211 not doing the right thing. If you think there are changes 00212 needed, get someone else to review them first _before_ 00213 submitting a patch. If these two lists do not match properly 00214 bad things will happen. 00215 */ 00216 00217 enum objecttype { 00218 SIP_USER = (1 << 0), /* USER places calls to the PBX */ 00219 SIP_PEER = (1 << 1), /* Peer receives calls from PBX (and places calls) */ 00220 }; 00221 00222 00223 enum xmittype { 00224 XMIT_CRITICAL = 2, /*!< Transmit critical SIP message reliably, with re-transmits. 00225 If it fails, it's critical and will cause a teardown of the session */ 00226 XMIT_RELIABLE = 1, /*!< Transmit SIP message reliably, with re-transmits */ 00227 XMIT_UNRELIABLE = 0, /*!< Transmit SIP message without bothering with re-transmits */ 00228 }; 00229 00230 enum parse_register_result { 00231 PARSE_REGISTER_FAILED_MINEXPIRY, 00232 PARSE_REGISTER_FAILED, 00233 PARSE_REGISTER_UPDATE, 00234 PARSE_REGISTER_QUERY, 00235 }; 00236 00237 enum subscriptiontype { 00238 NONE = 0, 00239 XPIDF_XML, 00240 DIALOG_INFO_XML, 00241 CPIM_PIDF_XML, 00242 PIDF_XML, 00243 MWI_NOTIFICATION 00244 }; 00245 00246 /*! \brief SIP Request methods known by Asterisk */ 00247 enum sipmethod { 00248 SIP_UNKNOWN, /*!< Unknown response */ 00249 SIP_RESPONSE, /*!< Not request, response to outbound request */ 00250 SIP_REGISTER, 00251 SIP_OPTIONS, 00252 SIP_NOTIFY, 00253 SIP_INVITE, 00254 SIP_ACK, 00255 SIP_PRACK, /*!< Not supported at all */ 00256 SIP_BYE, 00257 SIP_REFER, 00258 SIP_SUBSCRIBE, 00259 SIP_MESSAGE, 00260 SIP_UPDATE, /*!< We can send UPDATE; but not accept it */ 00261 SIP_INFO, 00262 SIP_CANCEL, 00263 SIP_PUBLISH, /*!< Not supported at all */ 00264 }; 00265 00266 enum sipdebuglevel { 00267 SIPDEBUG_ALL = 0, /*!< All requests and responses */ 00268 SIPDEBUG_CALLS, /*!< INVITE, CANCEL, ACK & BYE */ 00269 SIPDEBUG_NOPOKE, /*!< Everything BUT OPTIONS */ 00270 }; 00271 00272 /*! \brief Authentication types - proxy or www authentication 00273 \note Endpoints, like Asterisk, should always use WWW authentication to 00274 allow multiple authentications in the same call - to the proxy and 00275 to the end point. 00276 */ 00277 enum sip_auth_type { 00278 PROXY_AUTH = 407, 00279 WWW_AUTH = 401, 00280 }; 00281 00282 /*! \brief Authentication result from check_auth* functions */ 00283 enum check_auth_result { 00284 AUTH_SUCCESSFUL = 0, 00285 AUTH_CHALLENGE_SENT = 1, 00286 AUTH_SECRET_FAILED = -1, 00287 AUTH_USERNAME_MISMATCH = -2, 00288 AUTH_NOT_FOUND = -3, /* Returned by register_verify */ 00289 AUTH_FAKE_AUTH = -4, 00290 AUTH_UNKNOWN_DOMAIN = -5, 00291 }; 00292 00293 /*! \brief States for outbound registrations (with register= lines in sip.conf */ 00294 enum sipregistrystate { 00295 REG_STATE_UNREGISTERED = 0, /*!< We are not registred */ 00296 REG_STATE_REGSENT, /*!< Registration request sent */ 00297 REG_STATE_AUTHSENT, /*!< We have tried to authenticate */ 00298 REG_STATE_REGISTERED, /*!< Registred and done */ 00299 REG_STATE_REJECTED, /*!< Registration rejected */ 00300 REG_STATE_TIMEOUT, /*!< Registration timed out */ 00301 REG_STATE_NOAUTH, /*!< We have no accepted credentials */ 00302 REG_STATE_FAILED, /*!< Registration failed after several tries */ 00303 }; 00304 00305 00306 /*! \brief Modes for SIP domain handling in the PBX */ 00307 enum domain_mode { 00308 SIP_DOMAIN_AUTO, /*!< This domain is auto-configured */ 00309 SIP_DOMAIN_CONFIG, /*!< This domain is from configuration */ 00310 }; 00311 00312 /*! \brief T38 States for a call */ 00313 enum t38state { 00314 T38_DISABLED = 0, /*!< Not enabled */ 00315 T38_LOCAL_DIRECT, /*!< Offered from local */ 00316 T38_LOCAL_REINVITE, /*!< Offered from local - REINVITE */ 00317 T38_PEER_DIRECT, /*!< Offered from peer */ 00318 T38_PEER_REINVITE, /*!< Offered from peer - REINVITE */ 00319 T38_ENABLED /*!< Negotiated (enabled) */ 00320 }; 00321 00322 00323 /*! \brief Parameters to know status of transfer */ 00324 enum referstatus { 00325 REFER_IDLE, /*!< No REFER is in progress */ 00326 REFER_SENT, /*!< Sent REFER to transferee */ 00327 REFER_RECEIVED, /*!< Received REFER from transferer */ 00328 REFER_CONFIRMED, /*!< Refer confirmed with a 100 TRYING */ 00329 REFER_ACCEPTED, /*!< Accepted by transferee */ 00330 REFER_RINGING, /*!< Target Ringing */ 00331 REFER_200OK, /*!< Answered by transfer target */ 00332 REFER_FAILED, /*!< REFER declined - go on */ 00333 REFER_NOAUTH /*!< We had no auth for REFER */ 00334 }; 00335 00336 /*!< SIP RFC 3261 states for the INVITE transaction */ 00337 enum invitetrans_state { 00338 INV_STATE_CALLING = 1, /*!< Early state. Invite sent (only for client) */ 00339 INV_STATE_PROCEEDING = 2, /*!< Sent/Got 1xx message */ 00340 INV_STATE_PROCEEDING_EARLY_MEDIA = 3, /*!< Sent/Got 18x message */ 00341 INV_STATE_COMPLETED = 3, /*!< Sent/Got 300-699 message, Waiting for ACK, Then CONFIRMED */ 00342 INV_STATE_CONFIRMED = 4, /*!< For server transactions: We got an ACK (no more retries) */ 00343 INV_STATE_TERMINATED = 5, /*!< Sent/Got Transaction completed, finished, over and out buddy 00344 - We might have a call or not - check p->owner->_state */ 00345 INV_STATE_CANCELLED = 6, /*!< Sent/Got CANCEL or BYE in non-TERMINATED state */ 00346 }; 00347 00348 /*! \brief Transaction state for non-invite transactions */ 00349 enum transaction_state { 00350 TRANS_TRYING, /*!< Client: initiated transaction */ 00351 TRANS_PROCEEDING, /*!< Client: Provisional response received */ 00352 TRANS_COMPLETED, /*!< Final response received/sent */ 00353 TRANS_TERMINATED, /*!< We're done, no more re-transmits */ 00354 }; 00355 00356 enum dialogstate { 00357 DIALOG_STATE_TRYING, /*!< Sent invite, no response yet. Please answer :-) 00358 \ref AST_STATE_RING, AST_STATE_DOWN, AST_STATE_RESERVED 00359 AST_STATE_OFFHOOK, AST_STATE_DIALING 00360 */ 00361 DIALOG_STATE_PROCEEDING, /*!< Got 1xx reply without tag - something is alive! 00362 \ref AST_STATE_RINGING 00363 */ 00364 DIALOG_STATE_EARLY, /*!< We have early media or 1xx reply WITH tag 00365 If we get another with a different tag, it's another 00366 dialog (create a new pvt and, well, live with it 00367 \ref AST_STATE_UP ??? 00368 */ 00369 DIALOG_STATE_CONFIRMED, /*!< 2xx received, we have something going on, buddy 00370 \ref AST_STATE_UP 00371 */ 00372 DIALOG_STATE_CONFIRMED_HOLD, /*!< We are in CONFIRMED state on HOLD 00373 This is an ASTERISK state 00374 \ref AST_STATE_UP */ 00375 DIALOG_STATE_TERMINATED, /*!< This call is down - timeout, hangup, replaced 00376 \ref AST_STATE_DOWN 00377 */ 00378 DIALOG_STATE_TERMINATED_AUTH, /*!< Asterisk state for dialog that need to restart in 00379 TRYING for authentication */ 00380 00381 }; 00382 00383 /*! \brief SIP configuration options enum for configuration matrix sip_config[] */ 00384 enum sip_config_options { 00385 SIP_CONF_NONE = 0, /*!< Unknown */ 00386 SIP_CONF_NOT_VALID_FOR_OBJECT = 1, /*!< Configuration label not valid for object specified */ 00387 SIP_CONF_NOT_FOUND = 2, /*!< Unknown */ 00388 00389 SIP_CONF_ACCSECRET, 00390 SIP_CONF_ALLOW, 00391 SIP_CONF_ALLOWEXTERNALDOMAINS, 00392 SIP_CONF_ALLOWGUEST, 00393 SIP_CONF_ALLOWOVERLAP, 00394 SIP_CONF_ALLOWSUBSCRIBE, 00395 SIP_CONF_ALLOWTRANSFER, 00396 SIP_CONF_ALWAYSAUTHREJECT, 00397 SIP_CONF_AUTH, 00398 SIP_CONF_AUTHUSER, 00399 SIP_CONF_AUTOCREATEPEER, 00400 SIP_CONF_AUTODOMAIN, 00401 SIP_CONF_AUTOFRAMING, 00402 SIP_CONF_BINDADDR, 00403 SIP_CONF_BINDPORT, 00404 SIP_CONF_CALLERID, 00405 SIP_CONF_CALLERPRES, 00406 SIP_CONF_CALLEVENTS, 00407 SIP_CONF_CALLGROUP, 00408 SIP_CONF_CALL_LIMIT, 00409 SIP_CONF_CANREINVITE, 00410 SIP_CONF_CDR_AMAFLAGS, 00411 SIP_CONF_CDR_ACCOUNTCODE, 00412 SIP_CONF_CHANVAR, 00413 SIP_CONF_CID_NAME, 00414 SIP_CONF_CID_NUMBER, 00415 SIP_CONF_COMPACTHEADERS, 00416 SIP_CONF_DEFAULTIP, 00417 SIP_CONF_DEFAULTUSER, 00418 SIP_CONF_DEFAULTPORT, 00419 SIP_CONF_DEFCONTEXT, 00420 SIP_CONF_DENY, 00421 SIP_CONF_DISALLOW, 00422 SIP_CONF_DOMAIN, 00423 SIP_CONF_DTMFMODE, 00424 SIP_CONF_EXPIRYDEFAULT, 00425 SIP_CONF_EXPIRYMAX, 00426 SIP_CONF_EXPIRYMIN, 00427 SIP_CONF_EXTERNHOST, 00428 SIP_CONF_EXTERNIP, 00429 SIP_CONF_EXTERNPORT, 00430 SIP_CONF_EXTERNREFRESH, 00431 SIP_CONF_FROMDOMAIN, 00432 SIP_CONF_FROMUSER, 00433 SIP_CONF_G726NONSTANDARD, 00434 SIP_CONF_GROUPDESC, 00435 SIP_CONF_GROUPVAR, 00436 SIP_CONF_HISTORYDUMP, 00437 SIP_CONF_HISTORYRECORD, 00438 SIP_CONF_HOST, 00439 SIP_CONF_IGNOREREGEXPIRE, 00440 SIP_CONF_INSECURE, 00441 SIP_CONF_JBENABLE, 00442 SIP_CONF_JBFORCE, 00443 SIP_CONF_JBIMPL, 00444 SIP_CONF_JBLOG, 00445 SIP_CONF_JBMAXSIZE, 00446 SIP_CONF_JBRESYNC, 00447 SIP_CONF_LANGUAGE, 00448 SIP_CONF_LOCALNET, 00449 SIP_CONF_MAXCALLBITRATE, 00450 SIP_CONF_MAXFORWARDS, 00451 SIP_CONF_MD5SECRET, 00452 SIP_CONF_MOHINTERPRET, 00453 SIP_CONF_MOHSUGGEST, 00454 SIP_CONF_MWICHECK, 00455 SIP_CONF_MWISUBSCRIBE, 00456 SIP_CONF_NAT, 00457 SIP_CONF_NOTIFYHOLD, 00458 SIP_CONF_NOTIFYMIME, 00459 SIP_CONF_NOTIFYRINGING, 00460 SIP_CONF_OUTBOUNDPROXY, 00461 SIP_CONF_OBPROXYPORT, 00462 SIP_CONF_PERMIT, 00463 SIP_CONF_PICKUPGROUP, 00464 SIP_CONF_PORT, 00465 SIP_CONF_PROGRESSINBAND, 00466 SIP_CONF_PROMISCREDIR, 00467 SIP_CONF_PROXY, 00468 SIP_CONF_PROXYPORT, 00469 SIP_CONF_QUALIFY, 00470 SIP_CONF_QUALIFY_TIMER_NOT_OK, 00471 SIP_CONF_QUALIFY_TIMER_OK, 00472 SIP_CONF_REALM, 00473 SIP_CONF_REGCONTEXT, 00474 SIP_CONF_REGEXTEN, 00475 SIP_CONF_REGISTER, 00476 SIP_CONF_REGISTRAR, 00477 SIP_CONF_REGISTRARPORT, 00478 SIP_CONF_REGISTERATTEMPTS, 00479 SIP_CONF_REGISTERTIMEOUT, 00480 SIP_CONF_RELAXDTMF, 00481 SIP_CONF_RFC2833COMPENSATE, 00482 SIP_CONF_RTAUTOCLEAR, 00483 SIP_CONF_RTFULLCONTACT, 00484 SIP_CONF_RTIPADDR, 00485 SIP_CONF_RTPHOLDTIMEOUT, 00486 SIP_CONF_RTPKEEPALIVE, 00487 SIP_CONF_RTPTIMEOUT, 00488 SIP_CONF_RTNAME, /* Only for realtime */ 00489 SIP_CONF_RTREGSECONDS, 00490 SIP_CONF_RTSAVESYSTEMNAME, 00491 SIP_CONF_RTUPDATE, 00492 SIP_CONF_RT_CACHEFRIENDS, 00493 SIP_CONF_SECRET, 00494 SIP_CONF_SENDRPID, 00495 SIP_CONF_SETVAR, 00496 SIP_CONF_SIPDEBUG, 00497 SIP_CONF_SIPDEBUGLEVEL, 00498 SIP_CONF_SRVLOOKUP, 00499 SIP_CONF_SUBSCRIBECONTEXT, 00500 SIP_CONF_T1MIN, 00501 SIP_CONF_T1DEFAULT, 00502 SIP_CONF_T2DEFAULT, 00503 SIP_CONF_T4DEFAULT, 00504 SIP_CONF_TIMER_B, 00505 SIP_CONF_TIMER_F, 00506 SIP_CONF_T38PT_RTP, 00507 SIP_CONF_T38PT_TCP, 00508 SIP_CONF_T38PT_UDPTL, 00509 SIP_CONF_TOS_AUDIO, 00510 SIP_CONF_TOS_PRESENSE, 00511 SIP_CONF_TOS_SIP, 00512 SIP_CONF_TOS_VIDEO, 00513 SIP_CONF_TRUSTRPID, 00514 SIP_CONF_TYPE, 00515 SIP_CONF_USECLIENTCODE, 00516 SIP_CONF_USEREQPHONE, 00517 SIP_CONF_USERAGENT, 00518 SIP_CONF_VIDEOSUPPORT, 00519 SIP_CONF_VMAILBOX, 00520 SIP_CONF_VMEXTEN, 00521 }; 00522 00523 /*! \brief For each config object, a flag that says where this config object 00524 can be used */ 00525 enum sip_config_objects { 00526 SIP_CONFOBJ_NONE = 0, /*!< Not valid option (futureware) */ 00527 SIP_CONFOBJ_GENERAL = (1 << 0), /*!< [general] section */ 00528 SIP_CONFOBJ_PHONE = (1 << 1), /*!< phone configuration */ 00529 SIP_CONFOBJ_SERVICE = (1 << 2), /*!< Service configuration */ 00530 SIP_CONFOBJ_TRUNK = (1 << 3), /*!< Trunk configuration */ 00531 SIP_CONFOBJ_DOMAIN = (1 << 4), /*!< Domain configurations */ 00532 SIP_CONFOBJ_REALM = (1 << 5), /*!< Realm configurations */ 00533 SIP_CONFOBJ_ALL = (SIP_CONFOBJ_GENERAL | SIP_CONFOBJ_PHONE | SIP_CONFOBJ_SERVICE | SIP_CONFOBJ_TRUNK | SIP_CONFOBJ_DOMAIN), 00534 SIP_CONFOBJ_LINE = (SIP_CONFOBJ_PHONE | SIP_CONFOBJ_SERVICE | SIP_CONFOBJ_TRUNK), 00535 SIP_CONFOBJ_GONE = (1 << 7), /*!< Not valid option (history) */ 00536 }; 00537 00538 00539 enum sip_config_category { 00540 SIP_CONFCAT_MISC, /* Misc options */ 00541 SIP_CONFCAT_JB, /* Jitter buffer options */ 00542 SIP_CONFCAT_NAT, /* NAT support */ 00543 SIP_CONFCAT_TIMERS, /* Various signalling timers */ 00544 SIP_CONFCAT_REGISTRY, /* Inbound and outbound registrations and subscriptions */ 00545 SIP_CONFCAT_DEFAULT, /* Default settings */ 00546 SIP_CONFCAT_STATUS, /* Subscriptions and status reports (AMI/queue) */ 00547 SIP_CONFCAT_SIGNAL, /* SIP signalling options */ 00548 SIP_CONFCAT_REALTIME, /* ARA options */ 00549 SIP_CONFCAT_NETWORK, /* Network interface, QoS */ 00550 SIP_CONFCAT_LINE, /* Device, channel, trunk option only */ 00551 }; 00552 00553 00554 /* -------- Structure declarations */ 00555 00556 /*! \brief SIP configuration definition structure */ 00557 struct sip_config_struct { 00558 enum sip_config_options option; /*!< ENUM option id */ 00559 enum sip_config_category category; /*!< SIP configuration category */ 00560 const char *label; /*!< Text label used in configuration file */ 00561 enum sip_config_objects valid; /*!< Where option is valid - see \ref sip_config_category*/ 00562 const char *desc; /*!< Short description */ 00563 }; 00564 00565 00566 /* Define struct sip_history_head */ 00567 AST_LIST_HEAD_NOLOCK(sip_history_head, sip_history); 00568 00569 /*! \brief sip_request: The data grabbed from the UDP socket 00570 Should be renamed sip_message - since we use the same structure 00571 for both requests and responses 00572 */ 00573 struct sip_request { 00574 int method; /*!< Method of this request or response */ 00575 unsigned int allocid; /*!< Allocation ID for debugging */ 00576 enum transaction_state state; /*!< State of this transaction */ 00577 char *rlPart1; /*!< SIP Method Name or "SIP/2.0" protocol version */ 00578 char *rlPart2; /*!< The Request URI or Response Status */ 00579 const char *cseqheader; /*!< Pointer to the cseq header */ 00580 const char *callid; /*!< Pointer to the call ID header */ 00581 const char *via; /*!< Pointer to the Via header */ 00582 const char *to; /*!< Pointer to the To header */ 00583 const char *from; /*!< Pointer to the from header */ 00584 int len; /*!< Length */ 00585 00586 int headers; /*!< # of SIP Headers */ 00587 unsigned int flags; /*!< SIP_PKT Flags for this packet */ 00588 char *header[SIP_MAX_HEADERS]; /*!< Pointers to the headers */ 00589 int lines; /*!< Body Content */ 00590 char *line[SIP_MAX_LINES]; /*!< Pointer to content (attachment) lines */ 00591 unsigned int sdp_start; /*!< the line number where the SDP begins */ 00592 unsigned int sdp_end; /*!< the line number where the SDP ends */ 00593 00594 /* New stuff to be implemented */ 00595 // struct sip_request *nextrans; /*!< Next transaction */ 00596 // struct sip_request *nextmess; /*!< Next message within *this* transaction */ 00597 00598 /* Retransmission data */ 00599 struct sip_request *next; /*!< For linked list of packets, use this */ 00600 int retrans; /*!< Retransmission number */ 00601 int seqno; /*!< Sequence number */ 00602 struct sip_dialog *dialog; /*!< Owner SIP dialog */ 00603 int retransid; /*!< Retransmission ID */ 00604 int timer_a; /*!< SIP timer A, retransmission timer */ 00605 int timer_t1; /*!< SIP Timer T1, estimated RTT or 500 ms */ 00606 int timer_t2; /*!< SIP Timer T2, defaults to 4 secs */ 00607 size_t data_size; /*! Size of the data allocation */ 00608 00609 char *data; /*!< The actual message - allocated on demand sized to order */ 00610 00611 /* For retransmits, we need to know which socket to use */ 00612 struct sip_network *socket; /*!< SIP socket for this request */ 00613 }; 00614 00615 /*! \brief Invite transaction state */ 00616 struct sip_trans { 00617 struct sip_request initreq; /*!< Initial request */ 00618 int is_outbound; /*!< TRUE if this is an outbound request */ 00619 int cseq; /*!< Cseq for this transaction */ 00620 enum transaction_state state; /*!< Transaction status */ 00621 enum invitetrans_state invstate; /*!< Invite transaction state */ 00622 }; 00623 00624 /*! \brief Description of SUBSCRIBE events */ 00625 struct cfsubscription_types { 00626 enum subscriptiontype type; 00627 const char * const event; 00628 const char * const mediatype; 00629 const char * const text; 00630 }; 00631 00632 00633 /*! \brief Structure for parsing of SIP methods. 00634 \note Note that sip_methods[i].id == i must hold or the code breaks */ 00635 struct cfsip_methods { 00636 enum sipmethod id; 00637 int need_rtp; /*!< when this is the 'primary' use for a pvt structure, does it need RTP? */ 00638 char * const text; 00639 int creates_dialog; /*! Whether or not this method can create dialog */ 00640 }; 00641 00642 /*! \brief Structure for expiration times for inbound/outbound REGISTER */ 00643 struct expiry_times { 00644 int min_expiry; 00645 int max_expiry; 00646 int default_expiry; 00647 int expiry; /* ?? Is this ever used? */ 00648 }; 00649 00650 /*! \brief List of well-known SIP options. If we get this in a require, 00651 we should check the list and answer accordingly. */ 00652 struct cfsip_options { 00653 int id; /*!< Bitmap ID */ 00654 int supported; /*!< Supported by Asterisk ? */ 00655 char * const text; /*!< Text id, as in standard */ 00656 }; 00657 00658 00659 /* 00660 * A sip packet is stored into the data[] buffer, with the header followed 00661 * by an empty line and the body of the message. 00662 * On outgoing packets, data is accumulated in data[] with len reflecting 00663 * the next available byte, headers and lines count the number of lines 00664 * in both parts. There are no '\0' in data[0..len-1]. 00665 * 00666 * On received packet, the input read from the socket is copied into data[], 00667 * len is set and the string is NUL-terminated. Then a parser fills up 00668 * the other fields -header[] and line[] to point to the lines of the 00669 * message, rlPart1 and rlPart2 parse the first lnie as below: 00670 * 00671 * Requests have in the first line METHOD URI SIP/2.0 00672 * rlPart1 = method; rlPart2 = uri; 00673 * Responses have in the first line SIP/2.0 code description 00674 * rlPart1 = SIP/2.0; rlPart2 = code + description; 00675 * 00676 */ 00677 00678 /*! \brief structure used in transfers */ 00679 struct sip_dual { 00680 struct ast_channel *chan1; /*!< First channel involved */ 00681 struct ast_channel *chan2; /*!< Second channel involved */ 00682 struct sip_request *req; /*!< Request that caused the transfer (REFER) */ 00683 int seqno; /*!< Sequence number */ 00684 }; 00685 00686 /*! \brief Parameters to the transmit_invite function */ 00687 struct sip_invite_param { 00688 int addsipheaders; /*!< Add extra SIP headers */ 00689 const char *uri_options; /*!< URI options to add to the URI */ 00690 const char *vxml_url; /*!< VXML url for Cisco phones */ 00691 char *auth; /*!< Authentication */ 00692 char *authheader; /*!< Auth header */ 00693 enum sip_auth_type auth_type; /*!< Authentication type */ 00694 const char *replaces; /*!< Replaces header for call transfers */ 00695 int transfer; /*!< Flag - is this Invite part of a SIP transfer? (invite/replaces) */ 00696 }; 00697 00698 /*! \brief Structure to save routing information for a SIP session */ 00699 struct sip_route { 00700 struct sip_route *next; 00701 char hop[0]; 00702 }; 00703 00704 /* RTP timers */ 00705 struct rtptimers { 00706 int rtptimeout; /*!< Time out call if no RTP */ 00707 int rtpholdtimeout; 00708 int rtpkeepalive; /*!< Send RTP keepalives */ 00709 }; 00710 00711 /*! Global settings only apply to the channel */ 00712 struct sip_globals { 00713 struct ast_jb_conf jbconf; /*!< Jitterbuffer configuration */ 00714 struct rtptimers rtptimer; /*!< RTP timers */ 00715 int maxforwards; /*!< Max forwards */ 00716 int notifyringing; /*!< Send notifications on ringing */ 00717 int alwaysauthreject; /*!< Send 401 Unauthorized for all failing requests */ 00718 int srvlookup; /*!< SRV Lookup on or off. Default is off, RFC behavior is on */ 00719 int autocreatepeer; /*!< Auto creation of peers at registration? Default off. */ 00720 int relaxdtmf; /*!< Relax DTMF */ 00721 int reg_timeout; 00722 int regattempts_max; /*!< Registration attempts before giving up */ 00723 int allowguest; /*!< allow unauthenticated users/peers to connect? */ 00724 int allowsubscribe; /*!< Flag for disabling ALL subscriptions, this is FALSE only if all peers are FALSE 00725 the global setting is in globals_flags[1] */ 00726 int rtautoclear; /*!< Realtime caching options */ 00727 int mwitime; /*!< Time between MWI checks for peers */ 00728 unsigned int tos_sip; /*!< IP type of service for SIP packets */ 00729 unsigned int tos_audio; /*!< IP type of service for audio RTP packets */ 00730 unsigned int tos_video; /*!< IP type of service for video RTP packets */ 00731 unsigned int tos_presense; /*!< IP type of service for SIP presence packets */ 00732 int compactheaders; /*!< send compact sip headers */ 00733 int recordhistory; /*!< Record SIP history. Off by default */ 00734 int dumphistory; /*!< Dump history to verbose before destroying SIP dialog */ 00735 char realm[MAXHOSTNAMELEN]; /*!< Default realm */ 00736 char regcontext[AST_MAX_CONTEXT]; /*!< Context for auto-extensions */ 00737 char useragent[AST_MAX_EXTENSION]; /*!< Useragent for the SIP channel */ 00738 int allow_external_domains; /*!< Accept calls to external SIP domains? */ 00739 int callevents; /*!< Whether we send manager events or not */ 00740 int t1min; /*!< T1 roundtrip time minimum \ref sip3_timer_doc */ 00741 int t1default; /*!< T1 roundtrip time default \ref sip3_timer_doc */ 00742 int t2default; /*!< T2 default timer \ref sip3_timer_doc */ 00743 int t4default; /*!< T4 default timer \ref sip3_timer_doc */ 00744 int siptimer_b; /*!< B: Invite time-out (default 64*T1) */ 00745 int siptimer_f; /*!< F: Non-Invite time-out (default 64*T1) */ 00746 enum transfermodes allowtransfer; /*!< SIP Refer restriction scheme */ 00747 int autoframing; /*!< Follow the peers framing setting */ 00748 struct ast_flags flags[2]; /*!< Flags for various default settings */ 00749 int default_qualifycheck_ok; /*!< Default qualify time when status is ok */ 00750 int default_qualifycheck_notok; /*!< Default qualify time when statusis not ok */ 00751 int default_qualify; /*!< Default Qualify= setting */ 00752 int capability; /*!< Codec support */ 00753 int dtmf_capability; /*!< DTMF support (2833) */ 00754 int t38_capability; /*!< T38 Capability */ 00755 char default_context[AST_MAX_CONTEXT]; 00756 char default_subscribecontext[AST_MAX_CONTEXT]; 00757 char default_language[MAX_LANGUAGE]; 00758 char default_callerid[AST_MAX_EXTENSION]; 00759 char default_fromdomain[AST_MAX_EXTENSION]; 00760 char default_notifymime[AST_MAX_EXTENSION]; 00761 char default_vmexten[AST_MAX_EXTENSION]; 00762 char default_mohinterpret[MAX_MUSICCLASS]; /*!< Global setting for moh class to use when put on hold */ 00763 char default_mohsuggest[MAX_MUSICCLASS]; /*!< Global setting for moh class to suggest when putting 00764 * a bridged channel on hold */ 00765 int default_maxcallbitrate; /*!< Maximum bitrate for call */ 00766 struct ast_codec_pref default_prefs; /*!< Default codec prefs */ 00767 enum sipdebuglevel debuglevel; /*!< SIP debug level */ 00768 }; 00769 00770 00771 /*! \brief Domain data structure. 00772 \note In the future, we will connect this to a configuration tree specific 00773 for this domain 00774 */ 00775 struct domain { 00776 char domain[MAXHOSTNAMELEN]; /*!< SIP domain we are responsible for */ 00777 char context[AST_MAX_EXTENSION]; /*!< Incoming context for this domain */ 00778 enum domain_mode mode; /*!< How did we find this domain? */ 00779 struct sip_globals globals; /*!< Globals for this domain */ 00780 AST_LIST_ENTRY(domain) list; /*!< List mechanics */ 00781 }; 00782 00783 /*! \brief sip_history: Structure for saving transactions within a SIP dialog */ 00784 struct sip_history { 00785 AST_LIST_ENTRY(sip_history) list; 00786 char event[0]; /* actually more, depending on needs */ 00787 }; 00788 00789 /*! \brief sip_auth: Creadentials for authentication to other SIP services */ 00790 struct sip_auth { 00791 char realm[AST_MAX_EXTENSION]; /*!< Realm in which these credentials are valid */ 00792 char username[256]; /*!< Username */ 00793 char secret[256]; /*!< Secret */ 00794 char md5secret[256]; /*!< MD5Secret */ 00795 struct sip_auth *next; /*!< Next auth structure in list */ 00796 }; 00797 00798 /*! \brief T.38 channel settings (at some point we need to make this alloc'ed */ 00799 struct t38properties { 00800 struct ast_flags t38support; /*!< Flag for udptl, rtp or tcp support for this session */ 00801 int capability; /*!< Our T38 capability */ 00802 int peercapability; /*!< Peers T38 capability */ 00803 int jointcapability; /*!< Supported T38 capability at both ends */ 00804 enum t38state state; /*!< T.38 state */ 00805 }; 00806 00807 /*! \brief SIP devices (phones) */ 00808 struct sip_device_list { 00809 ASTOBJ_CONTAINER_COMPONENTS(struct sip_device); 00810 }; 00811 00812 /*! \brief The register list: Other SIP proxys we register with and place calls to */ 00813 struct sip_register_list { 00814 ASTOBJ_CONTAINER_COMPONENTS(struct sip_registry); 00815 int recheck; 00816 }; 00817 00818 /**--- some list management macros. **/ 00819 #define UNLINK(element, head, prev) do { \ 00820 if (prev) \ 00821 (prev)->next = (element)->next; \ 00822 else \ 00823 (head) = (element)->next; \ 00824 } while (0) 00825 00826 00827 /*! \brief Append to SIP dialog history 00828 \return Always returns 0 */ 00829 #define append_history(p, event, fmt , args... ) append_history_full(p, "%-15s " fmt, event, ## args) 00830 00831 00832 /*--- Various flags for the flags field in the pvt structure */ 00833 #define SIP_ALREADYGONE (1 << 0) /*!< Whether or not we've already been destroyed by our peer */ 00834 #define SIP_NEEDDESTROY (1 << 1) /*!< if we need to be destroyed by the monitor thread */ 00835 #define SIP_NOVIDEO (1 << 2) /*!< Didn't get video in invite, don't offer */ 00836 #define SIP_RINGING (1 << 3) /*!< Have sent 180 ringing */ 00837 #define SIP_PROGRESS_SENT (1 << 4) /*!< Have sent 183 message progress */ 00838 #define SIP_NEEDREINVITE (1 << 5) /*!< Do we need to send another reinvite? */ 00839 #define SIP_PENDINGBYE (1 << 6) /*!< Need to send bye after we ack? */ 00840 #define SIP_GOTREFER (1 << 7) /*!< Got a refer? */ 00841 #define SIP_PROMISCREDIR (1 << 8) /*!< Promiscuous redirection */ 00842 #define SIP_TRUSTRPID (1 << 9) /*!< Trust RPID headers? */ 00843 #define SIP_USEREQPHONE (1 << 10) /*!< Add user=phone to numeric URI. Default off */ 00844 #define SIP_REALTIME (1 << 11) /*!< Flag for realtime users */ 00845 #define SIP_USECLIENTCODE (1 << 12) /*!< Trust X-ClientCode info message */ 00846 #define SIP_OUTGOING (1 << 13) /*!< Is this an outgoing call? */ 00847 #define SIP_CAN_BYE (1 << 14) /*!< Can we send BYE on this dialog? */ 00848 #define SIP_DEFER_BYE_ON_TRANSFER (1 << 15) /*!< Do not hangup at first ast_hangup */ 00849 #define SIP_DTMF (3 << 16) /*!< DTMF Support: four settings, uses two bits */ 00850 #define SIP_DTMF_RFC2833 (0 << 16) /*!< DTMF Support: RTP DTMF - "rfc2833" */ 00851 #define SIP_DTMF_INBAND (1 << 16) /*!< DTMF Support: Inband audio, only for ULAW/ALAW - "inband" */ 00852 #define SIP_DTMF_INFO (2 << 16) /*!< DTMF Support: SIP Info messages - "info" */ 00853 #define SIP_DTMF_AUTO (3 << 16) /*!< DTMF Support: AUTO switch between rfc2833 and in-band DTMF */ 00854 /* NAT settings */ 00855 #define SIP_NAT (3 << 18) /*!< four settings, uses two bits */ 00856 #define SIP_NAT_NEVER (0 << 18) /*!< No nat support */ 00857 #define SIP_NAT_RFC3581 (1 << 18) /*!< NAT RFC3581 */ 00858 #define SIP_NAT_ROUTE (2 << 18) /*!< NAT Only ROUTE */ 00859 #define SIP_NAT_ALWAYS (3 << 18) /*!< NAT Both ROUTE and RFC3581 */ 00860 /* re-INVITE related settings */ 00861 #define SIP_REINVITE (7 << 20) /*!< three bits used */ 00862 #define SIP_CAN_REINVITE (1 << 20) /*!< allow peers to be reinvited to send media directly p2p */ 00863 #define SIP_CAN_REINVITE_NAT (2 << 20) /*!< allow media reinvite when new peer is behind NAT */ 00864 #define SIP_REINVITE_UPDATE (4 << 20) /*!< use UPDATE (RFC3311) when reinviting this peer */ 00865 /* "insecure" settings */ 00866 #define SIP_INSECURE_PORT (1 << 23) /*!< don't require matching port for incoming requests */ 00867 #define SIP_INSECURE_INVITE (1 << 24) /*!< don't require authentication for incoming INVITEs */ 00868 /* Sending PROGRESS in-band settings */ 00869 #define SIP_PROG_INBAND (3 << 25) /*!< three settings, uses two bits */ 00870 #define SIP_PROG_INBAND_NEVER (0 << 25) 00871 #define SIP_PROG_INBAND_NO (1 << 25) 00872 #define SIP_PROG_INBAND_YES (2 << 25) 00873 #define SIP_NO_HISTORY (1 << 27) /*!< Supress recording request/response history */ 00874 #define SIP_CALL_LIMIT (1 << 28) /*!< Call limit enforced for this call */ 00875 #define SIP_SENDRPID (1 << 29) /*!< Remote Party-ID Support */ 00876 #define SIP_INC_COUNT (1 << 30) /*!< Did this connection increment the counter of in-use calls? */ 00877 #define SIP_G726_NONSTANDARD (1 << 31) /*!< Use non-standard packing for G726-32 data */ 00878 00879 #define SIP_FLAGS_TO_COPY \ 00880 (SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \ 00881 SIP_PROG_INBAND | SIP_USECLIENTCODE | SIP_NAT | SIP_G726_NONSTANDARD | \ 00882 SIP_USEREQPHONE | SIP_INSECURE_PORT | SIP_INSECURE_INVITE) 00883 00884 /*--- a new page of flags (for flags[1] */ 00885 /* realtime flags */ 00886 #define SIP_PAGE2_RTCACHEFRIENDS (1 << 0) 00887 #define SIP_PAGE2_RTUPDATE (1 << 1) 00888 #define SIP_PAGE2_RTAUTOCLEAR (1 << 2) 00889 #define SIP_PAGE2_RT_FROMCONTACT (1 << 4) 00890 #define SIP_PAGE2_RTSAVE_SYSNAME (1 << 5) 00891 /* Space for addition of other realtime flags in the future */ 00892 #define SIP_PAGE2_IGNOREREGEXPIRE (1 << 10) 00893 #define SIP_PAGE2_DEBUG (3 << 11) 00894 #define SIP_PAGE2_DEBUG_CONFIG (1 << 11) 00895 #define SIP_PAGE2_DEBUG_CONSOLE (1 << 12) 00896 #define SIP_PAGE2_DYNAMIC (1 << 13) /*!< Dynamic Peers register with Asterisk */ 00897 #define SIP_PAGE2_SELFDESTRUCT (1 << 14) /*!< Automatic peers need to destruct themselves */ 00898 #define SIP_PAGE2_VIDEOSUPPORT (1 << 15) 00899 #define SIP_PAGE2_ALLOWSUBSCRIBE (1 << 16) /*!< Allow subscriptions from this peer? */ 00900 #define SIP_PAGE2_ALLOWOVERLAP (1 << 17) /*!< Allow overlap dialing ? */ 00901 #define SIP_PAGE2_SUBSCRIBEMWIONLY (1 << 18) /*!< Only issue MWI notification if subscribed to */ 00902 #define SIP_PAGE2_INC_RINGING (1 << 19) /*!< Did this connection increment the counter of in-use calls? */ 00903 #define SIP_PAGE2_T38SUPPORT (7 << 20) /*!< T38 Fax Passthrough Support */ 00904 #define SIP_PAGE2_T38SUPPORT_UDPTL (1 << 20) /*!< 20: T38 Fax Passthrough Support */ 00905 #define SIP_PAGE2_T38SUPPORT_RTP (2 << 20) /*!< 21: T38 Fax Passthrough Support */ 00906 #define SIP_PAGE2_T38SUPPORT_TCP (4 << 20) /*!< 22: T38 Fax Passthrough Support */ 00907 #define SIP_PAGE2_CALL_ONHOLD (3 << 23) /*!< Call states */ 00908 #define SIP_PAGE2_CALL_ONHOLD_ONEDIR (1 << 23) /*!< 23: One directional hold */ 00909 #define SIP_PAGE2_CALL_ONHOLD_INACTIVE (2 << 24) /*!< 24: Inactive */ 00910 #define SIP_PAGE2_RFC2833_COMPENSATE (1 << 26) 00911 #define SIP_PAGE2_SERVICE (1 << 27) /*!< Whether this device is a service or not */ 00912 #define SIP_PAGE2_COMPACTHEADERS (1 << 28) /*!< Whether this device is a service or not */ 00913 00914 00915 #define SIP_PAGE2_FLAGS_TO_COPY \ 00916 (SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_VIDEOSUPPORT | SIP_PAGE2_T38SUPPORT | \ 00917 SIP_PAGE2_RFC2833_COMPENSATE | SIP_PAGE2_COMPACTHEADERS ) 00918 00919 /* SIP packet flags */ 00920 #define SIP_PKT_DEBUG (1 << 0) /*!< Debug this packet */ 00921 #define SIP_PKT_WITH_TOTAG (1 << 1) /*!< This packet has a to-tag */ 00922 #define SIP_PKT_IGNORE (1 << 2) /*!< This is a re-transmit, ignore it */ 00923 #define SIP_PKT_IGNORE_RESP (1 << 3) /*!< Resp ignore - ??? */ 00924 #define SIP_PKT_IGNORE_REQ (1 << 4) /*!< Req ignore - ??? */ 00925 #define SIP_PKT_INITREQ (1 << 5) /*!< This is the initial request in this dialog 00926 Will be freed when dialog is destroyed or 00927 when replaced. 00928 */ 00929 #define SIP_PKT_RESPONSE (1 << 6) /*!< This packet is a response, not a request */ 00930 #define SIP_PKT_FATAL (1 << 7) /*! Fatal - if this does not get through, the dialog dies */ 00931 #define SIP_PKT_CONNECTED (1 << 8) /*! This packet is connected to a dialog and should not 00932 be free'd by sipsock_read() */ 00933 #define SIP_PKT_PARSED (1 << 9) /*! Already parsed by parse_request */ 00934 00935 #define CAN_CREATE_DIALOG 0 00936 #define CAN_NOT_CREATE_DIALOG 1 00937 00938 /* T.38 set of flags */ 00939 #define T38FAX_FILL_BIT_REMOVAL (1 << 0) /*!< Default: 0 (unset)*/ 00940 #define T38FAX_TRANSCODING_MMR (1 << 1) /*!< Default: 0 (unset)*/ 00941 #define T38FAX_TRANSCODING_JBIG (1 << 2) /*!< Default: 0 (unset)*/ 00942 /* Rate management */ 00943 #define T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF (0 << 3) 00944 #define T38FAX_RATE_MANAGEMENT_LOCAL_TCF (1 << 3) /*!< Unset for transferredTCF (UDPTL), set for localTCF (TPKT) */ 00945 /* UDP Error correction */ 00946 #define T38FAX_UDP_EC_NONE (0 << 4) /*!< two bits, if unset NO t38UDPEC field in T38 SDP*/ 00947 #define T38FAX_UDP_EC_FEC (1 << 4) /*!< Set for t38UDPFEC */ 00948 #define T38FAX_UDP_EC_REDUNDANCY (2 << 4) /*!< Set for t38UDPRedundancy */ 00949 /* T38 Spec version */ 00950 #define T38FAX_VERSION (3 << 6) /*!< two bits, 2 values so far, up to 4 values max */ 00951 #define T38FAX_VERSION_0 (0 << 6) /*!< Version 0 */ 00952 #define T38FAX_VERSION_1 (1 << 6) /*!< Version 1 */ 00953 /* Maximum Fax Rate */ 00954 #define T38FAX_RATE_2400 (1 << 8) /*!< 2400 bps t38FaxRate */ 00955 #define T38FAX_RATE_4800 (1 << 9) /*!< 4800 bps t38FaxRate */ 00956 #define T38FAX_RATE_7200 (1 << 10) /*!< 7200 bps t38FaxRate */ 00957 #define T38FAX_RATE_9600 (1 << 11) /*!< 9600 bps t38FaxRate */ 00958 #define T38FAX_RATE_12000 (1 << 12) /*!< 12000 bps t38FaxRate */ 00959 #define T38FAX_RATE_14400 (1 << 13) /*!< 14400 bps t38FaxRate */ 00960 00961 #define sipdebug ast_test_flag(&global.flags[1], SIP_PAGE2_DEBUG) 00962 #define sipdebug_config ast_test_flag(&global.flags[1], SIP_PAGE2_DEBUG_CONFIG) 00963 #define sipdebug_console ast_test_flag(&global.flags[1], SIP_PAGE2_DEBUG_CONSOLE) 00964 00965 00966 /*! \brief Structure to handle SIP transfers. Dynamically allocated when needed */ 00967 /* OEJ: Should be moved to string fields */ 00968 struct sip_refer { 00969 char refer_to[AST_MAX_EXTENSION]; /*!< Place to store REFER-TO extension */ 00970 char refer_to_domain[AST_MAX_EXTENSION]; /*!< Place to store REFER-TO domain */ 00971 char refer_to_urioption[AST_MAX_EXTENSION]; /*!< Place to store REFER-TO uri options */ 00972 char refer_to_context[AST_MAX_EXTENSION]; /*!< Place to store REFER-TO context */ 00973 char referred_by[AST_MAX_EXTENSION]; /*!< Place to store REFERRED-BY extension */ 00974 char referred_by_name[AST_MAX_EXTENSION]; /*!< Place to store REFERRED-BY extension */ 00975 char refer_contact[AST_MAX_EXTENSION]; /*!< Place to store Contact info from a REFER extension */ 00976 char replaces_callid[BUFSIZ]; /*!< Replace info: callid */ 00977 char replaces_callid_totag[BUFSIZ/2]; /*!< Replace info: to-tag */ 00978 char replaces_callid_fromtag[BUFSIZ/2]; /*!< Replace info: from-tag */ 00979 struct sip_dialog *refer_call; /*!< Call we are referring */ 00980 int attendedtransfer; /*!< Attended or blind transfer? */ 00981 int localtransfer; /*!< Transfer to local domain? */ 00982 enum referstatus status; /*!< REFER status */ 00983 }; 00984 00985 /*! \brief PVT structure are used for each SIP dialog, ie. a call, a registration, a subscribe 00986 00987 One SIP dialog is distinguished from another by these four items (if they exist) 00988 - Call ID 00989 - Remote tag= and local tag= (From: / To: header tags) 00990 - Topmost via header branch ID 00991 */ 00992 struct sip_dialog { 00993 ast_mutex_t lock; /*!< Dialog private lock */ 00994 int method; /*!< SIP method that opened this dialog */ 00995 enum dialogstate state; /*!< Dialog state */ 00996 AST_DECLARE_STRING_FIELDS( 00997 AST_STRING_FIELD(callid); /*!< Dialog ID: Global CallID - the call ID is a unique ID for this SIP dialog, 00998 a string that never changes during the dialog */ 00999 AST_STRING_FIELD(theirtag); /*!< Dialog ID: remote side's tag */ 01000 AST_STRING_FIELD(remotebranch); /*!< Dialog ID: branch tag from topmost via */ 01001 AST_STRING_FIELD(ourbranch); /*!< Dialog ID: branch tag from topmost via */ 01002 AST_STRING_FIELD(randdata); /*!< Random data */ 01003 AST_STRING_FIELD(realm); /*!< Authorization realm for this dialog */ 01004 AST_STRING_FIELD(nonce); /*!< Authorization nonce */ 01005 AST_STRING_FIELD(opaque); /*!< Authorization Opaque string */ 01006 AST_STRING_FIELD(qop); /*!< Quality of Protection for authorization */ 01007 AST_STRING_FIELD(domain); /*!< Authorization domain */ 01008 AST_STRING_FIELD(from); /*!< The From: header */ 01009 AST_STRING_FIELD(useragent); /*!< User agent in SIP request */ 01010 AST_STRING_FIELD(exten); /*!< Extension where to start */ 01011 AST_STRING_FIELD(context); /*!< Context for this call */ 01012 AST_STRING_FIELD(subscribecontext); /*!< Subscribecontext */ 01013 AST_STRING_FIELD(subscribeuri); /*!< Subscribecontext */ 01014 AST_STRING_FIELD(fromdomain); /*!< Domain to show in the from field */ 01015 AST_STRING_FIELD(fromuser); /*!< User to show in the user field */ 01016 AST_STRING_FIELD(fromname); /*!< Name to show as display name */ 01017 AST_STRING_FIELD(tohost); /*!< Host we should put in the "to" field */ 01018 AST_STRING_FIELD(language); /*!< Default language for this call (to select prompts) */ 01019 AST_STRING_FIELD(mohinterpret); /*!< MOH class to use when put on hold */ 01020 AST_STRING_FIELD(mohsuggest); /*!< MOH class to suggest when putting a peer on hold */ 01021 AST_STRING_FIELD(rdnis); /*!< Referring DNIS */ 01022 AST_STRING_FIELD(todnid); /*!< Destination of the call */ 01023 AST_STRING_FIELD(redircause); /*!< Referring cause */ 01024 AST_STRING_FIELD(defaultuser); /*!< Default user name (used with default IP) */ 01025 AST_STRING_FIELD(username); /*!< Username part of URI */ 01026 AST_STRING_FIELD(peername); /*!< [peer] name, not set if [user] */ 01027 AST_STRING_FIELD(authname); /*!< Who we use for authentication */ 01028 AST_STRING_FIELD(uri); /*!< Original requested URI */ 01029 AST_STRING_FIELD(okcontacturi); /*!< URI from the 200 OK on INVITE */ 01030 AST_STRING_FIELD(peersecret); /*!< Password */ 01031 AST_STRING_FIELD(peermd5secret); 01032 AST_STRING_FIELD(cid_num); /*!< Caller*ID number */ 01033 AST_STRING_FIELD(cid_name); /*!< Caller*ID name */ 01034 AST_STRING_FIELD(rpid); /*!< Our RPID header */ 01035 AST_STRING_FIELD(rpid_from); /*!< Our RPID From header */ 01036 AST_STRING_FIELD(via); /*!< Via: header */ 01037 AST_STRING_FIELD(fullcontact); /*!< The Contact: that the UA registers with us */ 01038 AST_STRING_FIELD(our_contact); /*!< Our contact header */ 01039 AST_STRING_FIELD(accountcode); /*!< Account code - only used for billing */ 01040 ); 01041 /* Dialog settings */ 01042 unsigned int ocseq; /*!< Current outgoing seqno */ 01043 unsigned int icseq; /*!< Current incoming seqno */ 01044 int lastinvite; /*!< Last Cseq of invite */ 01045 int timer_t1; /*!< SIP timer T1, ms rtt */ 01046 int timer_t2; /*!< SIP timer T2 */ 01047 int autokillid; /*!< Dialog response timer Auto-kill ID (scheduler) */ 01048 unsigned int sipoptions; /*!< Supported SIP options on the other end */ 01049 int authtries; /*!< Times we've tried to authenticate */ 01050 int expiry; /*!< How long we take to expire */ 01051 char tag[11]; /*!< Dialog ID: Our tag for this session */ 01052 int callingpres; /*!< Caller ID presentation settings */ 01053 int maxforwards; /*!< Max forwards for this dialog */ 01054 struct sip_route *route; /*!< Head of linked list of routing steps (fm Record-Route) */ 01055 int route_persistant; /*!< Is this the "real" route? */ 01056 char lastmsg[256]; /*!< Last Message sent/received */ 01057 int initid; /*!< Invite Auto-congest ID if appropriate (scheduler) */ 01058 int pendinginvite; /*!< Any pending invite ? (seqno of this) */ 01059 struct sip_request *initreq; /*!< Initial request that opened the SIP dialog 01060 Something that keeps getting overwritten 01061 */ 01062 struct sip_request *packets; /*!< Packets scheduled for re-transmission */ 01063 struct sip_history_head *history; /*!< History of this SIP dialog */ 01064 01065 struct ast_flags flags[2]; /*!< SIP_ flags - various flags grouped togheter to save memory */ 01066 01067 /* Authentication */ 01068 struct sip_auth *peerauth; /*!< Realm authentication */ 01069 int noncecount; /*!< Nonce-count */ 01070 01071 /* The grouping below shows that these settings should be allocated in substructures, 01072 depending on the nature of the dialog - the method that opened it. Note that 01073 one dialog can have both INVITE and REFER, but not SUSBCRIBE and REGISTER and INVITE */ 01074 01075 /* INVITE: Media support for this dialog */ 01076 struct ast_codec_pref prefs; /*!< codec prefs */ 01077 int capability; /*!< Special capability (codec) */ 01078 int jointcapability; /*!< Supported capability at both ends (codecs ) */ 01079 int peercapability; /*!< Supported peer capability */ 01080 int prefcodec; /*!< Preferred codec (outbound only) */ 01081 int noncodeccapability; /*!< DTMF RFC2833 telephony-event */ 01082 int jointnoncodeccapability; /*!< DTMF RFC2833 telephony-event */ 01083 int redircodecs; /*!< Redirect codecs */ 01084 int maxcallbitrate; /*!< Maximum Call Bitrate for Video Calls */ 01085 struct ast_rtp *rtp; /*!< RTP Session */ 01086 struct ast_rtp *vrtp; /*!< Video RTP session */ 01087 01088 /* T38 settings - these should be allocated only when needed */ 01089 struct t38properties t38; /*!< T38 settings */ 01090 struct sockaddr_in udptlredirip; /*!< Where our T.38 UDPTL should be going if not to us */ 01091 struct ast_udptl *udptl; /*!< T.38 UDPTL session */ 01092 01093 /* INVITE: SDP/RTP settings - these could also be grouped together and allocated as needed */ 01094 int sessionid; /*!< SDP Session ID */ 01095 int sessionversion; /*!< SDP Session Version */ 01096 struct sockaddr_in sa; /*!< Our peer */ 01097 struct sockaddr_in redirip; /*!< Where our RTP should be going if not to us */ 01098 struct sockaddr_in vredirip; /*!< Where our Video RTP should be going if not to us */ 01099 time_t lastrtprx; /*!< Last RTP received */ 01100 time_t lastrtptx; /*!< Last RTP sent */ 01101 struct ast_dsp *vad; /*!< Inband DTMF Detection dsp */ 01102 int autoframing; /*!< ???? */ 01103 01104 struct sockaddr_in recv; /*!< SIP Received from */ 01105 struct in_addr ourip; /*!< Our IP */ 01106 01107 /* INVITE: PBX interface - this is only needeed for "calls", not for registrations etc */ 01108 struct sip_invite_param *inviteoptions; /*!< Options for INVITE */ 01109 struct ast_channel *owner; /*!< Who owns us (if we have an owner) */ 01110 ast_group_t callgroup; /*!< Call group */ 01111 ast_group_t pickupgroup; /*!< Pickup group */ 01112 int amaflags; /*!< AMA Flags (only for billing) */ 01113 struct ast_variable *chanvars; /*!< Channel variables to set for inbound call */ 01114 01115 01116 /* REFER: */ 01117 enum transfermodes allowtransfer; /*!< REFER: restriction scheme */ 01118 struct sip_refer *refer; /*!< REFER: SIP transfer data structure */ 01119 01120 /* SUBSCRIBE: These need to be allocated only for subscriptions */ 01121 enum subscriptiontype subscribed; /*!< SUBSCRIBE: Is this dialog a subscription? */ 01122 int stateid; /*!< SUBSCRIBE: ID for devicestate subscriptions */ 01123 int laststate; /*!< SUBSCRIBE: Last known extension state */ 01124 int dialogver; /*!< SUBSCRIBE: Version for subscription dialog-info */ 01125 struct sip_device *relatedpeer; /*!< If this dialog is related to a peer, which one 01126 Used in peerpoke, mwi subscriptions */ 01127 01128 /* REGISTER (outbound) */ 01129 struct sip_registry *registry; /*!< If this is a REGISTER dialog, to which registry */ 01130 01131 struct sip_dialog *next; /*!< Next dialog in chain */ 01132 }; 01133 01134 /*!< Information about mailbox subscription */ 01135 struct sip_mwi_mailbox { 01136 AST_DECLARE_STRING_FIELDS( 01137 AST_STRING_FIELD(vmexten); /*!< Dialplan extension for MWI notify message*/ 01138 AST_STRING_FIELD(mailbox); /*!< Mailbox setting for MWI checks */ 01139 ); 01140 int lastmsgssent; /*!< MWI message status */ 01141 time_t lastmsgcheck; /*!< Last time we checked for MWI */ 01142 struct sip_dialog *mwipvt; /*!< Subscription for MWI */ 01143 }; 01144 01145 /*! Extra data about a SIP device, not allocated all of the time */ 01146 struct sip_device_extra { 01147 AST_DECLARE_STRING_FIELDS( 01148 AST_STRING_FIELD(context); /*!< Default context for incoming calls */ 01149 AST_STRING_FIELD(subscribecontext); /*!< Default context for subscriptions */ 01150 AST_STRING_FIELD(regexten); /*!< Extension to register (if regcontext is used) */ 01151 AST_STRING_FIELD(fromuser); /*!< From: user when calling this peer */ 01152 AST_STRING_FIELD(fromdomain); /*!< From: domain when calling this peer */ 01153 ); 01154 char accountcode[AST_MAX_ACCOUNT_CODE]; /*!< Account code */ 01155 int amaflags; /*!< AMA Flags (for billing) */ 01156 char cid_num[80]; /*!< Caller ID num */ 01157 char cid_name[80]; /*!< Caller ID name */ 01158 char mohinterpret[MAX_MUSICCLASS]; /*!< Music on Hold class */ 01159 char mohsuggest[MAX_MUSICCLASS]; /*!< Music on Hold class */ 01160 char tohost[MAXHOSTNAMELEN]; /*!< If not dynamic, dns domain or host name */ 01161 }; 01162 01163 /*! \brief Structure for SIP peer data, we place calls to peers if registered or fixed IP address (host) 01164 \note XXX field 'name' must be first otherwise sip_addrcmp() will fail */ 01165 struct sip_device { 01166 ASTOBJ_COMPONENTS(struct sip_device); /*!< name, refcount, objflags, object pointers 01167 device->name is the unique name of this object */ 01168 /* EXTRAS */ 01169 AST_DECLARE_STRING_FIELDS( 01170 AST_STRING_FIELD(fullcontact); /*!< Contact registered with us (not in sip.conf) */ 01171 AST_STRING_FIELD(useragent); /*!< Contact registered with us (not in sip.conf) */ 01172 /* The following items stay in this struct */ 01173 AST_STRING_FIELD(secret); /*!< Secret (password) */ 01174 AST_STRING_FIELD(md5secret); /*!< Secret (password in md5 digest with realm and username) */ 01175 AST_STRING_FIELD(defaultuser); /*!< Temporary username until registration */ 01176 AST_STRING_FIELD(authuser); /*!< Authentication user name */ 01177 ); 01178 int callingpres; /*!< Calling id presentation */ 01179 unsigned int maxforwards; /*!< Max forwards */ 01180 char language[MAX_LANGUAGE]; /*!< Default language for prompts */ 01181 struct sockaddr_in defaddr; /*!< Default IP address, used until registration */ 01182 /* EXTRAS TO MOVE */ 01183 char domain[MAXHOSTNAMELEN]; /*!< Domain name for this device. The name needs to be unique within 01184 a domain only 01185 For type=phone, the domain needs to be a locally hosted domain */ 01186 enum objecttype type; /*!< SIP_PEER */ 01187 struct sip_device_extra extra; /*!< Data we don't need in memory for realtime (will be allocated at some point) */ 01188 struct sip_mwi_mailbox mailbox; /*!< Mailbox information block (will be allocated at some point) */ 01189 struct rtptimers rtptimer; /*!< RTP timers (will be allocated at some point) */ 01190 struct sip_auth *auth; /*!< Realm authentication list */ 01191 struct sip_registry *registry; /*!< If this is a service, which registration is connected to this device */ 01192 01193 unsigned int inUse; /*!< Number of calls in use */ 01194 unsigned int inRinging; /*!< Number of calls ringing */ 01195 unsigned int onHold; /*!< Peer has someone on hold */ 01196 unsigned int call_limit; /*!< Limit of concurrent calls */ 01197 enum transfermodes allowtransfer; /*! SIP Refer restriction scheme */ 01198 struct ast_codec_pref prefs; /*!< codec prefs */ 01199 unsigned int sipoptions; /*!< Supported SIP options */ 01200 struct ast_flags flags[2]; /*!< SIP_ flags */ 01201 int expire; /*!< When to expire this peer registration */ 01202 int capability; /*!< Codec capability */ 01203 int autoframing; /*!< RTP framing option */ 01204 01205 ast_group_t callgroup; /*!< Call group */ 01206 ast_group_t pickupgroup; /*!< Pickup group */ 01207 struct ast_dnsmgr_entry *dnsmgr;/*!< DNS refresh manager for peer */ 01208 struct sockaddr_in addr; /*!< IP address of peer */ 01209 int maxcallbitrate; /*!< Maximum Bitrate for a video call */ 01210 01211 /* Qualification */ 01212 struct sip_dialog *call; /*!< Call pointer */ 01213 int pokeexpire; /*!< When to expire poke (qualify= checking) */ 01214 int lastms; /*!< How long last response took (in ms), or -1 for no response */ 01215 int maxms; /*!< Max ms we will accept for the host to be up, 0 to not monitor */ 01216 struct timeval ps; /*!< Time when sip_poke_peer() was executed */ 01217 01218 struct ast_ha *ha; /*!< Access control list */ 01219 struct ast_variable *chanvars; /*!< Variables to set for channel created by user */ 01220 }; 01221 01222 01223 /*! \brief Registrations with other SIP proxies */ 01224 struct sip_registry { 01225 ASTOBJ_COMPONENTS_FULL(struct sip_registry,1,1); 01226 AST_DECLARE_STRING_FIELDS( 01227 AST_STRING_FIELD(callid); /*!< Global Call-ID */ 01228 AST_STRING_FIELD(realm); /*!< Authorization realm */ 01229 AST_STRING_FIELD(nonce); /*!< Authorization nonce */ 01230 AST_STRING_FIELD(opaque); /*!< Opaque nonsense */ 01231 AST_STRING_FIELD(qop); /*!< Quality of Protection, since SIP wasn't complicated enough yet. */ 01232 AST_STRING_FIELD(domain); /*!< Authorization domain */ 01233 AST_STRING_FIELD(username); /*!< Who we are registering as */ 01234 AST_STRING_FIELD(authuser); /*!< Who we *authenticate* as */ 01235 AST_STRING_FIELD(hostname); /*!< Domain or host we register to */ 01236 AST_STRING_FIELD(secret); /*!< Password in clear text */ 01237 AST_STRING_FIELD(md5secret); /*!< Password in md5 */ 01238 AST_STRING_FIELD(contact); /*!< Contact extension */ 01239 AST_STRING_FIELD(extension); /*!< Extension for callback */ 01240 AST_STRING_FIELD(random); 01241 ); 01242 int portno; /*!< Optional port override */ 01243 int expire; /*!< Sched ID of expiration */ 01244 int expiry; /*!< Requested value for expiration time */ 01245 int regattempts; /*!< Number of attempts (since the last success) */ 01246 int timeout; /*!< sched id of sip_reg_timeout */ 01247 int refresh; /*!< How often to refresh */ 01248 struct sip_dialog *call; /*!< create a sip_dialog structure for each outbound "registration dialog" in progress */ 01249 enum sipregistrystate regstate; /*!< Registration state (see above) */ 01250 time_t regtime; /*!< Last succesful registration time */ 01251 int callid_valid; /*!< 0 means we haven't chosen callid for this registry yet. */ 01252 unsigned int ocseq; /*!< Sequence number we got to for REGISTERs for this registry */ 01253 struct sockaddr_in us; /*!< Who the server thinks we are */ 01254 int noncecount; /*!< Nonce-count */ 01255 char lastmsg[256]; /*!< Last Message sent/received */ 01256 struct sip_device *peer; /*!< If we have a known peer for this registry entry, use it for incoming calls */ 01257 }; 01258 01259 /*! \brief Network interface settings */ 01260 struct sip_network { 01261 ast_mutex_t lock; /*!< Network private lock */ 01262 int sipsock; /*!< Network socket for this interface */ 01263 struct sockaddr_in bindaddr; /*!< Bind address */ 01264 struct sockaddr_in externip; /*!< External IP address (outside of NAT) */ 01265 char externhost[MAXHOSTNAMELEN]; /*!< Extern host name in case of us being behind NAT */ 01266 time_t externexpire; /*!< Expiration time for DNS resolution of externhost */ 01267 int externrefresh; /*!< How often to re-resolve */ 01268 struct ast_ha *localaddr; /*!< Our local addresses (locanet= ) */ 01269 struct in_addr __ourip; /*!< Our IP */ 01270 int ourport; /*!< Our port */ 01271 struct sockaddr_in outboundproxyip; /*!< First SIP route hop */ 01272 struct sockaddr_in debugaddr; /*!< Debugging ??? */ 01273 int *read_id; /*!< ID of IO entry for sipsock socket FD */ 01274 char outboundproxy[MAXHOSTNAMELEN]; /*!< Outbound proxy name or IP in text */ 01275 char networkbuf[SIP_MSG_BUFSIZE]; /*!< Receive buffer */ 01276 unsigned int req_counter; /*!< Counter of allocated requests */ 01277 }; 01278 01279 /*! \brief Counters for various objects */ 01280 struct channel_counters { 01281 int static_users; 01282 int realtime_users; 01283 int static_peers; 01284 int realtime_peers; 01285 int autocreated_peers; 01286 int registry_objects; 01287 int dialog_objects; 01288 int peers_with_mwi; 01289 }; 01290 01291 /*! @name External objects */ 01292 /*! @{ */ 01293 extern struct sip_network sipnet; /*!< Sockets and networking */ 01294 extern struct expiry_times expiry; /*!< Various expiration times */ 01295 extern struct ast_config *notify_types; /*!< Notification types */ 01296 extern const char notify_config[]; /*!< Configuration file for notifications */ 01297 extern const struct cfsip_methods sip_methods[]; /*!< sip3_parse.c: SIP method table */ 01298 extern struct sip_globals global; /* Defined in chan_sip3.c */ 01299 extern struct sched_context *sched; /*!< The scheduling context */ 01300 extern struct io_context *io; /*!< The IO context */ 01301 extern struct channel_counters sipcounters; /*!< Various object counters */ 01302 extern struct sip_device_list devicelist; /*!< Device list */ 01303 extern struct sip_register_list regl; /*!< Registration list */ 01304 extern struct sip_auth *authl; /*!< Realm authentications */ 01305 extern struct sip_dialog *dialoglist; 01306 /*! @} */ 01307 01308 /*! \page sip3_timer_doc Chan_sip3: Overview of SIP timers 01309 01310 See table 4 in RFC 3261 for reference 01311 01312 - \b T1: 01313 RTT estimate, ranging from 0 to 64 seconds. Default is 500 ms. 01314 If you have qualify turned on for a device, the measured 01315 RTT is used. This timer controls retransmission timers and timeouts 01316 for dialogs. (RFC 3261)\r\r 01317 Settable in sip.conf as "t1default" 01318 01319 - \b T2: 01320 Maximum retransmit interval for non-invite requests. Defaults 01321 to 4 seconds. 01322 \r\r Settable in sip.conf as "t2default" 01323 01324 - \b T4: 01325 Maximum duration for an outstanding transaction. Defaults to 5 01326 seconds (RFC 3261, section 17.1.2 for non-INVITE transactions) 01327 This is the time to keep a transaction in COMPLETED state 01328 open for retransmission on unreliable transports (UDP). 01329 \r Not implemented. 01330 01331 - \b A: 01332 INVITE request retransmit interval on UDP 01333 Initially T1. Implemented in the retransmit function \ref retrans_pkt() 01334 \r Section 17.1.1.2 01335 01336 - \b B: 01337 Invite transaction timeout timer. Defaults to 64*T1 01338 Implemented partially. Section 17.1.1.2 01339 01340 - \b D: 01341 Wait time for UDP retransmits of responses 01342 Section 17.1.1.2 01343 01344 - \b F: 01345 Non-INVITE transaction timeout timer 01346 Section 17.1.2.2 01347 01348 - \b H: 01349 Wait time for ACK receipt - 64*T1 01350 Section 17.2.1 01351 01352 - \b I: 01353 Wait time for ACK UDP retransmits. Defaults to T4 for UDP. 01354 Section 17.2.1 01355 - \b J: 01356 Wait time for non-INVITE request retransmits. Initially 64*T1. 01357 Section 17.2.2 01358 - \b K: 01359 Wait time for response retransmits. Initially T4 for UDP 01360 Section 17.1.2.2 01361 */ 01362 01363 #endif