1 /* 2 The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-) 3 Copyright (C) 2001-2020 Aymeric MOIZARD amoizard@antisip.com 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 19 20 #ifndef _OSIP_H_ 21 #define _OSIP_H_ 22 23 #include <osipparser2/osip_const.h> 24 25 /* Time-related functions and data types */ 26 #include <osip2/osip_time.h> 27 28 #ifdef __sun 29 #include <sys/types.h> 30 #endif 31 32 #include <osipparser2/osip_parser.h> 33 #include <osip2/osip_fifo.h> 34 35 /** 36 * @file osip.h 37 * @brief oSIP fsm Routines 38 * 39 */ 40 41 /** 42 * @defgroup oSIP_FSM oSIP fsm Handling 43 * @ingroup osip2_fsm 44 * @{ 45 */ 46 47 #ifdef __cplusplus 48 extern "C" { 49 #endif 50 51 /** 52 * Enumeration for transaction state. 53 * Those states are extracted from the diagram found in rfc3261.txt 54 * 55 */ 56 typedef enum _state_t { 57 /* STATES for invite client transaction */ 58 ICT_PRE_CALLING, 59 ICT_CALLING, 60 ICT_PROCEEDING, 61 ICT_COMPLETED, 62 ICT_TERMINATED, 63 64 /* STATES for invite server transaction */ 65 IST_PRE_PROCEEDING, 66 IST_PROCEEDING, 67 IST_COMPLETED, 68 IST_CONFIRMED, 69 IST_TERMINATED, 70 71 /* STATES for NON-invite client transaction */ 72 NICT_PRE_TRYING, 73 NICT_TRYING, 74 NICT_PROCEEDING, 75 NICT_COMPLETED, 76 NICT_TERMINATED, 77 78 /* STATES for NON-invite server transaction */ 79 NIST_PRE_TRYING, 80 NIST_TRYING, 81 NIST_PROCEEDING, 82 NIST_COMPLETED, 83 NIST_TERMINATED, 84 85 #ifndef DOXYGEN 86 DIALOG_EARLY, 87 DIALOG_CONFIRMED, 88 DIALOG_CLOSE /* ?? */ 89 #endif 90 } state_t; 91 92 /** 93 * Enumeration for event type. 94 * <BR>The list of values that you need to know is reduced to this: 95 * <BR> RCV_REQINVITE, 96 * <BR> RCV_REQACK, 97 * <BR> RCV_REQUEST, 98 * <BR> RCV_STATUS_1XX, 99 * <BR> RCV_STATUS_2XX, 100 * <BR> RCV_STATUS_3456XX, 101 *<BR> 102 * <BR> SND_REQINVITE, 103 * <BR> SND_REQACK, 104 * <BR> SND_REQUEST, 105 * <BR> SND_STATUS_1XX, 106 * <BR> SND_STATUS_2XX, 107 * <BR> SND_STATUS_3456XX, 108 */ 109 typedef enum type_t { 110 /* TIMEOUT EVENTS for ICT */ 111 TIMEOUT_A, /**< Timer A */ 112 TIMEOUT_B, /**< Timer B */ 113 TIMEOUT_D, /**< Timer D */ 114 115 /* TIMEOUT EVENTS for NICT */ 116 TIMEOUT_E, /**< Timer E */ 117 TIMEOUT_F, /**< Timer F */ 118 TIMEOUT_K, /**< Timer K */ 119 120 /* TIMEOUT EVENTS for IST */ 121 TIMEOUT_G, /**< Timer G */ 122 TIMEOUT_H, /**< Timer H */ 123 TIMEOUT_I, /**< Timer I */ 124 125 /* TIMEOUT EVENTS for NIST */ 126 TIMEOUT_J, /**< Timer J */ 127 128 /* FOR INCOMING MESSAGE */ 129 RCV_REQINVITE, /**< Event is an incoming INVITE request */ 130 RCV_REQACK, /**< Event is an incoming ACK request */ 131 RCV_REQUEST, /**< Event is an incoming NON-INVITE and NON-ACK request */ 132 RCV_STATUS_1XX, /**< Event is an incoming informational response */ 133 RCV_STATUS_2XX, /**< Event is an incoming 2XX response */ 134 RCV_STATUS_3456XX, /**< Event is an incoming final response (not 2XX) */ 135 136 /* FOR OUTGOING MESSAGE */ 137 SND_REQINVITE, /**< Event is an outgoing INVITE request */ 138 SND_REQACK, /**< Event is an outgoing ACK request */ 139 SND_REQUEST, /**< Event is an outgoing NON-INVITE and NON-ACK request */ 140 SND_STATUS_1XX, /**< Event is an outgoing informational response */ 141 SND_STATUS_2XX, /**< Event is an outgoing 2XX response */ 142 SND_STATUS_3456XX, /**< Event is an outgoing final response (not 2XX) */ 143 144 KILL_TRANSACTION, /**< Event to 'kill' the transaction before termination */ 145 UNKNOWN_EVT /**< Max event */ 146 } type_t; 147 148 /** 149 * Enumeration for transaction type. 150 * A transaction can be either of: 151 * ICT, 152 * IST, 153 * NICT, 154 * NIST, 155 */ 156 typedef enum osip_fsm_type_t { 157 ICT, /**< Invite Client (outgoing) Transaction */ 158 IST, /**< Invite Server (incoming) Transaction */ 159 NICT, /**< Non-Invite Client (outgoing) Transaction */ 160 NIST /**< Non-Invite Server (incoming) Transaction */ 161 } osip_fsm_type_t; 162 163 #ifndef DEFAULT_T1 164 /** 165 * You can re-define the default value for T1. (T1 is defined in rfcxxxx) 166 * The default value is 500ms. 167 */ 168 #define DEFAULT_T1 500 /* 500 ms */ 169 #endif 170 #ifndef DEFAULT_T1_TCP_PROGRESS 171 /** 172 * [OBSOLETE] 173 * You can re-define the default value for T1_TCP_PROGRESS. 174 * This is a trick to use non blocking socke for reliable protocol 175 * On first attempt, the connection is not ready and the next 176 * osip retransmission are used to check the progress of the connection 177 * in order to send the message. 178 * The default value is 500ms. 179 */ 180 #define DEFAULT_T1_TCP_PROGRESS 500 /* 500ms */ 181 #endif 182 #ifndef DEFAULT_T2 183 /** 184 * You can re-define the default value for T2. (T2 is defined in rfcxxxx) 185 * The default value is 4000ms. 186 */ 187 #define DEFAULT_T2 4000 /* 4s */ 188 #endif 189 #ifndef DEFAULT_T4 190 /** 191 * You can re-define the default value for T4. (T1 is defined in rfcxxxx) 192 * The default value is 5000ms. 193 */ 194 #define DEFAULT_T4 5000 /* 5s */ 195 #endif 196 197 /** 198 * Structure for INVITE CLIENT TRANSACTION (outgoing INVITE transaction). 199 * @var osip_ict_t 200 */ 201 typedef struct osip_ict osip_ict_t; 202 203 /** 204 * Structure for INVITE CLIENT TRANSACTION. 205 * @struct osip_ict 206 */ 207 struct osip_ict { 208 int timer_a_length; /**< Timer A A=T1, A=2xT1... (unreliable only) */ 209 struct timeval timer_a_start; /**< Timer A (retransmission) */ 210 int timer_b_length; /**< Timer B B = 64* T1 */ 211 struct timeval timer_b_start; /**< Timer B (fire when transaction timeout) */ 212 int timer_d_length; /**< Timer D D >= 32s for unreliable tr (or 0) */ 213 struct timeval timer_d_start; /**< Timer D */ 214 char *destination; /**< IP used to send requests */ 215 int port; /**< port of next hop */ 216 }; 217 218 /** 219 * Structure for NON-INVITE CLIENT TRANSACTION (outgoing NON-INVITE transaction). 220 * @var osip_nict_t 221 */ 222 typedef struct osip_nict osip_nict_t; 223 224 /** 225 * Structure for NON-INVITE CLIENT TRANSACTION. 226 * @struct osip_nict 227 */ 228 struct osip_nict { 229 int timer_e_length; /**< Timer E A=T1, A=2xT1... (unreliable only) */ 230 struct timeval timer_e_start; /**< Timer E (retransmission) */ 231 int timer_f_length; /**< Timer F B = 64* T1 */ 232 struct timeval timer_f_start; /**< Timer F (fire when transaction timeout) */ 233 int timer_k_length; /**< Timer K K = T4 (else = 0) */ 234 struct timeval timer_k_start; /**< Timer K */ 235 char *destination; /**< IP used to send requests */ 236 int port; /**< port of next hop */ 237 }; 238 239 /** 240 * Structure for INVITE SERVER TRANSACTION (incoming INVITE transaction). 241 * @var osip_ist_t 242 */ 243 typedef struct osip_ist osip_ist_t; 244 245 /** 246 * Structure for INVITE SERVER TRANSACTION. 247 * @struct osip_ist 248 */ 249 struct osip_ist { 250 int timer_g_length; /**< Timer G G=MIN(T1*2,T2) for unreliable trans. */ 251 struct timeval timer_g_start; /**< Timer G (0 when reliable transport is used) */ 252 int timer_h_length; /**< Timer H H = 64* T1 */ 253 struct timeval timer_h_start; /**< Timer H (fire if no ACK is received) */ 254 int timer_i_length; /**< Timer I I = T4 for unreliable (or 0) */ 255 struct timeval timer_i_start; /**< Timer I (absorb all ACK) */ 256 }; 257 258 /** 259 * Structure for NON-INVITE SERVER TRANSACTION (incoming SERVER transaction). 260 * @var osip_nist_t 261 */ 262 typedef struct osip_nist osip_nist_t; 263 264 /** 265 * Structure for NON-INVITE SERVER TRANSACTION. 266 * @struct osip_nist 267 */ 268 struct osip_nist { 269 int timer_j_length; /**< Timer J = 64*T1 (else 0) */ 270 struct timeval timer_j_start; /**< Timer J */ 271 }; 272 273 /** 274 * Structure for SRV record entry. 275 * @var osip_srv_entry_t 276 */ 277 typedef struct osip_srv_entry osip_srv_entry_t; 278 279 /** 280 * Structure for SRV record entry. 281 * @struct osip_srv_entry 282 */ 283 284 struct osip_srv_entry { 285 char srv[512]; /**< srv */ 286 int priority; /**< priority */ 287 int weight; /**< weight */ 288 int rweight; /**< rweight */ 289 int port; /**< port */ 290 char ipaddress[512]; /**< ipaddress result */ 291 struct timeval srv_is_broken; /**< time when we considered SRV entry broken */ 292 }; 293 294 #define OSIP_SRV_STATE_UNKNOWN 0 /**< unknown */ 295 #define OSIP_SRV_STATE_RETRYLATER 2 /**< retry later */ 296 #define OSIP_SRV_STATE_COMPLETED 3 /**< completed */ 297 #define OSIP_SRV_STATE_NOTSUPPORTED 4 /**< not supported */ 298 299 /** 300 * Structure for SRV record. 301 * @var osip_srv_record_t 302 */ 303 typedef struct osip_srv_record osip_srv_record_t; 304 305 /** 306 * Structure for SRV record entry. 307 * @struct osip_srv_record 308 */ 309 struct osip_srv_record { 310 char name[1024]; /**< name */ 311 int srv_state; /**< srv state */ 312 char flag[256]; /**< flag: "S" (SRV), "A" (A or AAAA), "U" (URI), and "P" (ignore), are defined. */ 313 char protocol[1024]; /**< transport protocol*/ 314 char regexp[1024]; /**< regexp */ 315 char replacement[1024]; /**< replacement */ 316 int order; /**< order */ 317 int preference; /**< preference */ 318 int index; /**< index */ 319 osip_srv_entry_t srventry[10]; /**< result table */ 320 }; 321 322 #define OSIP_NAPTR_STATE_UNKNOWN 0 /**< unknown */ 323 #define OSIP_NAPTR_STATE_INPROGRESS 1 /**< in progress */ 324 #define OSIP_NAPTR_STATE_NAPTRDONE 2 /**< naptr done */ 325 #define OSIP_NAPTR_STATE_SRVINPROGRESS 3 /**< srv in progress */ 326 #define OSIP_NAPTR_STATE_SRVDONE 4 /**< srv done */ 327 #define OSIP_NAPTR_STATE_RETRYLATER 5 /**< retry later */ 328 #define OSIP_NAPTR_STATE_NOTSUPPORTED 6 /**< not supported */ 329 330 /** 331 * Structure for NAPTR record. 332 * @var osip_naptr_t 333 */ 334 typedef struct osip_naptr osip_naptr_t; 335 336 /** 337 * Structure for NAPTR record entry. 338 * @struct osip_naptr 339 */ 340 struct osip_naptr { 341 char domain[512]; /**< domain */ 342 char AUS[64]; /**< UAS (User Application String) used for Enum */ 343 int naptr_state; /**< naptr state */ 344 void *arg; /**< arg */ 345 int keep_in_cache; /**< keep in cache value */ 346 struct osip_srv_record sipudp_record; /**< udp NAPTR result */ 347 struct osip_srv_record siptcp_record; /**< tcp NAPTR result */ 348 struct osip_srv_record siptls_record; /**< tls NAPTR result */ 349 struct osip_srv_record sipdtls_record; /**< dtls NAPTR result */ 350 struct osip_srv_record sipsctp_record; /**< sctp NAPTR result */ 351 struct osip_srv_record sipenum_record; /**< enum NAPTR result */ 352 }; 353 354 /** 355 * Structure for transaction handling. 356 * @var osip_transaction_t 357 */ 358 typedef struct osip_transaction osip_transaction_t; 359 360 /** 361 * Structure for transaction handling 362 * @struct osip_transaction 363 */ 364 struct osip_transaction { 365 void *your_instance; /**< User Defined Pointer. */ 366 int transactionid; /**< Internal Transaction Identifier. */ 367 osip_fifo_t *transactionff; /**< events must be added in this fifo */ 368 369 osip_via_t *topvia; /**< CALL-LEG definition (Top Via) */ 370 osip_from_t *from; /**< CALL-LEG definition (From) */ 371 osip_to_t *to; /**< CALL-LEG definition (To) */ 372 osip_call_id_t *callid; /**< CALL-LEG definition (Call-ID) */ 373 osip_cseq_t *cseq; /**< CALL-LEG definition (CSeq) */ 374 375 osip_message_t *orig_request; /**< Initial request */ 376 osip_message_t *last_response; /**< Last response */ 377 osip_message_t *ack; /**< ack request sent */ 378 379 state_t state; /**< Current state of the transaction */ 380 381 time_t birth_time; /**< birth date of transaction */ 382 time_t completed_time; /**< end date of transaction */ 383 struct timeval created_time; /**< created time of transaction */ 384 struct timeval destroyed_time; /**< destroyed time of transaction */ 385 386 int in_socket; /**< Optional socket for incoming message */ 387 int out_socket; /**< Optional place for outgoing message */ 388 389 void *config; /**< (internal) transaction is managed by osip_t */ 390 391 osip_fsm_type_t ctx_type; /**< Type of the transaction */ 392 osip_ict_t *ict_context; /**< internal ict context */ 393 osip_ist_t *ist_context; /**< internal ist context */ 394 osip_nict_t *nict_context; /**< internal nict context */ 395 osip_nist_t *nist_context; /**< internal nist context */ 396 397 osip_srv_record_t record; /**< memory space for SRV record */ 398 osip_naptr_t *naptr_record; /**< memory space for NAPTR record */ 399 void *reserved1; /**< User Defined Pointer. */ 400 void *reserved2; /**< User Defined Pointer. */ 401 void *reserved3; /**< User Defined Pointer. */ 402 void *reserved4; /**< User Defined Pointer. */ 403 void *reserved5; /**< User Defined Pointer. */ 404 void *reserved6; /**< User Defined Pointer. */ 405 }; 406 407 /** 408 * Enumeration for callback type. 409 */ 410 typedef enum osip_message_callback_type { 411 OSIP_ICT_INVITE_SENT = 0, /**< INVITE MESSAGE SENT */ 412 OSIP_ICT_INVITE_SENT_AGAIN, /**< INVITE MESSAGE RETRANSMITTED */ 413 OSIP_ICT_ACK_SENT, /**< ACK MESSAGE SENT */ 414 OSIP_ICT_ACK_SENT_AGAIN, /**< ACK MESSAGE RETRANSMITTED */ 415 OSIP_ICT_STATUS_1XX_RECEIVED, /**< 1XX FOR INVITE RECEIVED */ 416 OSIP_ICT_STATUS_2XX_RECEIVED, /**< 2XX FOR INVITE RECEIVED */ 417 OSIP_ICT_STATUS_2XX_RECEIVED_AGAIN, /**< 2XX FOR INVITE RECEIVED AGAIN */ 418 OSIP_ICT_STATUS_3XX_RECEIVED, /**< 3XX FOR INVITE RECEIVED */ 419 OSIP_ICT_STATUS_4XX_RECEIVED, /**< 4XX FOR INVITE RECEIVED */ 420 OSIP_ICT_STATUS_5XX_RECEIVED, /**< 5XX FOR INVITE RECEIVED */ 421 OSIP_ICT_STATUS_6XX_RECEIVED, /**< 6XX FOR INVITE RECEIVED */ 422 OSIP_ICT_STATUS_3456XX_RECEIVED_AGAIN, /**< RESPONSE RECEIVED AGAIN */ 423 424 OSIP_IST_INVITE_RECEIVED, /**< INVITE MESSAGE RECEIVED */ 425 OSIP_IST_INVITE_RECEIVED_AGAIN, /**< INVITE MESSAGE RECEIVED AGAN */ 426 OSIP_IST_ACK_RECEIVED, /**< ACK MESSAGE RECEIVED */ 427 OSIP_IST_ACK_RECEIVED_AGAIN, /**< ACK MESSAGE RECEIVED AGAIN */ 428 OSIP_IST_STATUS_1XX_SENT, /**< 1XX FOR INVITE SENT */ 429 OSIP_IST_STATUS_2XX_SENT, /**< 2XX FOR INVITE SENT */ 430 OSIP_IST_STATUS_2XX_SENT_AGAIN, /**< 2XX FOR INVITE RETRANSMITTED */ 431 OSIP_IST_STATUS_3XX_SENT, /**< 3XX FOR INVITE SENT */ 432 OSIP_IST_STATUS_4XX_SENT, /**< 4XX FOR INVITE SENT */ 433 OSIP_IST_STATUS_5XX_SENT, /**< 5XX FOR INVITE SENT */ 434 OSIP_IST_STATUS_6XX_SENT, /**< 6XX FOR INVITE SENT */ 435 OSIP_IST_STATUS_3456XX_SENT_AGAIN, /**< RESPONSE RETRANSMITTED */ 436 437 OSIP_NICT_REGISTER_SENT, /**< REGISTER MESSAGE SENT */ 438 OSIP_NICT_BYE_SENT, /**< BYE MESSAGE SENT */ 439 OSIP_NICT_OPTIONS_SENT, /**< OPTIONS MESSAGE SENT */ 440 OSIP_NICT_INFO_SENT, /**< INFO MESSAGE SENT */ 441 OSIP_NICT_CANCEL_SENT, /**< CANCEL MESSAGE SENT */ 442 OSIP_NICT_NOTIFY_SENT, /**< NOTIFY MESSAGE SENT */ 443 OSIP_NICT_SUBSCRIBE_SENT, /**< SUBSCRIBE MESSAGE SENT */ 444 OSIP_NICT_UNKNOWN_REQUEST_SENT, /**< UNKNOWN REQUEST MESSAGE SENT */ 445 OSIP_NICT_REQUEST_SENT_AGAIN, /**< REQUEST MESSAGE RETRANMITTED */ 446 OSIP_NICT_STATUS_1XX_RECEIVED, /**< 1XX FOR MESSAGE RECEIVED */ 447 OSIP_NICT_STATUS_2XX_RECEIVED, /**< 2XX FOR MESSAGE RECEIVED */ 448 OSIP_NICT_STATUS_2XX_RECEIVED_AGAIN, /**< 2XX FOR MESSAGE RECEIVED AGAIN */ 449 OSIP_NICT_STATUS_3XX_RECEIVED, /**< 3XX FOR MESSAGE RECEIVED */ 450 OSIP_NICT_STATUS_4XX_RECEIVED, /**< 4XX FOR MESSAGE RECEIVED */ 451 OSIP_NICT_STATUS_5XX_RECEIVED, /**< 5XX FOR MESSAGE RECEIVED */ 452 OSIP_NICT_STATUS_6XX_RECEIVED, /**< 6XX FOR MESSAGE RECEIVED */ 453 OSIP_NICT_STATUS_3456XX_RECEIVED_AGAIN, /**< RESPONSE RECEIVED AGAIN */ 454 455 OSIP_NIST_REGISTER_RECEIVED, /**< REGISTER RECEIVED */ 456 OSIP_NIST_BYE_RECEIVED, /**< BYE RECEIVED */ 457 OSIP_NIST_OPTIONS_RECEIVED, /**< OPTIONS RECEIVED */ 458 OSIP_NIST_INFO_RECEIVED, /**< INFO RECEIVED */ 459 OSIP_NIST_CANCEL_RECEIVED, /**< CANCEL RECEIVED */ 460 OSIP_NIST_NOTIFY_RECEIVED, /**< NOTIFY RECEIVED */ 461 OSIP_NIST_SUBSCRIBE_RECEIVED, /**< SUBSCRIBE RECEIVED */ 462 463 OSIP_NIST_UNKNOWN_REQUEST_RECEIVED, /**< UNKNWON REQUEST RECEIVED */ 464 OSIP_NIST_REQUEST_RECEIVED_AGAIN, /**< UNKNWON REQUEST RECEIVED AGAIN */ 465 OSIP_NIST_STATUS_1XX_SENT, /**< 1XX FOR MESSAGE SENT */ 466 OSIP_NIST_STATUS_2XX_SENT, /**< 2XX FOR MESSAGE SENT */ 467 OSIP_NIST_STATUS_2XX_SENT_AGAIN, /**< 2XX FOR MESSAGE RETRANSMITTED */ 468 OSIP_NIST_STATUS_3XX_SENT, /**< 3XX FOR MESSAGE SENT */ 469 OSIP_NIST_STATUS_4XX_SENT, /**< 4XX FOR MESSAGE SENT */ 470 OSIP_NIST_STATUS_5XX_SENT, /**< 5XX FOR MESSAGE SENT */ 471 OSIP_NIST_STATUS_6XX_SENT, /**< 6XX FOR MESSAGE SENT */ 472 OSIP_NIST_STATUS_3456XX_SENT_AGAIN, /**< RESPONSE RETRANSMITTED */ 473 474 OSIP_ICT_STATUS_TIMEOUT, /**< TIMER B EXPIRATION: NO REMOTE ANSWER */ 475 OSIP_NICT_STATUS_TIMEOUT, /**< TIMER F EXPIRATION: NO REMOTE ANSWER */ 476 477 OSIP_MESSAGE_CALLBACK_COUNT /**< END OF ENUM */ 478 } osip_message_callback_type_t; 479 480 /** 481 * Enumeration for callback type used when transaction is over. 482 */ 483 typedef enum osip_kill_callback_type { 484 OSIP_ICT_KILL_TRANSACTION, /**< end of Client INVITE transaction */ 485 OSIP_IST_KILL_TRANSACTION, /**< end of Server INVITE transaction */ 486 OSIP_NICT_KILL_TRANSACTION, /**< end of Client Non-INVITE transaction */ 487 OSIP_NIST_KILL_TRANSACTION, /**< end of Server Non-INVITE transaction */ 488 489 OSIP_KILL_CALLBACK_COUNT /**< END OF ENUM */ 490 } osip_kill_callback_type_t; 491 492 /** 493 * Enumeration for callback type used when a transport error is detected. 494 */ 495 typedef enum osip_transport_error_callback_type { 496 OSIP_ICT_TRANSPORT_ERROR, /**< transport error for ICT */ 497 OSIP_IST_TRANSPORT_ERROR, /**< transport error for IST */ 498 OSIP_NICT_TRANSPORT_ERROR, /**< transport error for NICT */ 499 OSIP_NIST_TRANSPORT_ERROR, /**< transport error for NIST */ 500 501 OSIP_TRANSPORT_ERROR_CALLBACK_COUNT /**< END OF ENUM */ 502 } osip_transport_error_callback_type_t; 503 504 /** 505 * Callback definition for message announcements. 506 * @var osip_message_cb_t 507 */ 508 typedef void (*osip_message_cb_t)(int type, osip_transaction_t *, osip_message_t *); 509 /** 510 * Callback definition for end of transaction announcements. 511 * @var osip_kill_transaction_cb_t 512 */ 513 typedef void (*osip_kill_transaction_cb_t)(int type, osip_transaction_t *); 514 /** 515 * Callback definition for transport error announcements. 516 * @var osip_transport_error_cb_t 517 */ 518 typedef void (*osip_transport_error_cb_t)(int type, osip_transaction_t *, int error); 519 520 struct osip_dialog; 521 522 /** 523 * Structure for 2XX retransmission management. 524 * @var ixt_t 525 */ 526 typedef struct ixt ixt_t; 527 528 /** 529 * Structure for 2XX retransmission management. 530 * @struct ixt 531 */ 532 struct ixt { 533 /* any ACK received that match this context will set counter to -1 */ 534 struct osip_dialog *dialog; /**< related dialog */ 535 osip_message_t *msg2xx; /**< buffer to retransmit */ 536 osip_message_t *ack; /**< ack message if needed */ 537 struct timeval start; /**< Time of first retransmission */ 538 int interval; /**< delay between retransmission, in ms */ 539 char *dest; /**< destination host */ 540 int port; /**< destination port */ 541 int sock; /**< socket to use */ 542 int counter; /**< start at 7 */ 543 }; 544 545 /** 546 * Structure for osip handling. 547 * In order to use osip, you have to manage at least one global instance 548 * of an osip_t element. Then, you'll register a set of required callbacks 549 * and a set of optional ones. 550 * @var osip_t 551 */ 552 typedef struct osip osip_t; 553 554 /** 555 * Structure for osip handling. 556 * @struct osip 557 */ 558 struct osip { 559 void *application_context; /**< User defined Pointer */ 560 561 void *ict_fastmutex; /**< mutex for ICT transaction */ 562 void *ist_fastmutex; /**< mutex for IST transaction */ 563 void *nict_fastmutex; /**< mutex for NICT transaction */ 564 void *nist_fastmutex; /**< mutex for NIST transaction */ 565 void *ixt_fastmutex; /**< mutex for IXT transaction */ 566 void *id_mutex; /**< mutex for unique transaction id generation */ 567 int transactionid; /**< previous unique transaction id generation */ 568 569 /* list of transactions for ict, ist, nict, nist */ 570 osip_list_t osip_ict_transactions; /**< list of ict transactions */ 571 osip_list_t osip_ist_transactions; /**< list of ist transactions */ 572 osip_list_t osip_nict_transactions; /**< list of nict transactions */ 573 osip_list_t osip_nist_transactions; /**< list of nist transactions */ 574 575 osip_list_t ixt_retransmissions; /**< list of ixt elements */ 576 577 osip_message_cb_t msg_callbacks[OSIP_MESSAGE_CALLBACK_COUNT]; /**< message callbacks */ 578 osip_kill_transaction_cb_t kill_callbacks[OSIP_KILL_CALLBACK_COUNT]; /**< kill callbacks */ 579 osip_transport_error_cb_t tp_error_callbacks[OSIP_TRANSPORT_ERROR_CALLBACK_COUNT]; /**< transport error callback */ 580 581 int (*cb_send_message)(osip_transaction_t *, osip_message_t *, char *, int, int); /**< callback to send message */ 582 583 void *osip_ict_hastable; /**< htable of ict transactions */ 584 void *osip_ist_hastable; /**< htable of ist transactions */ 585 void *osip_nict_hastable; /**< htable of nict transactions */ 586 void *osip_nist_hastable; /**< htable of nist transactions */ 587 }; 588 589 /** 590 * Set a callback for each transaction operation. 591 * @param osip The element to work on. 592 * @param type The event type to hook on. 593 * @param cb The method to be called upon the event. 594 */ 595 int osip_set_message_callback(osip_t *osip, int type, osip_message_cb_t cb); 596 597 /** 598 * Set a callback for transaction operation related to the end of transactions. 599 * @param osip The element to work on. 600 * @param type The event type to hook on. 601 * @param cb The method to be called upon the event. 602 */ 603 int osip_set_kill_transaction_callback(osip_t *osip, int type, osip_kill_transaction_cb_t cb); 604 605 /** 606 * Set a callback for each transaction operation related to network error. 607 * @param osip The element to work on. 608 * @param type The event type to hook on. 609 * @param cb The method to be called upon the event. 610 */ 611 int osip_set_transport_error_callback(osip_t *osip, int type, osip_transport_error_cb_t cb); 612 613 /** 614 * Structure for osip event handling. 615 * A osip_event_t element will have a type and will be related 616 * to a transaction. In the general case, it is used by the 617 * application layer to give SIP messages to the oSIP finite 618 * state machine. 619 * @var osip_event_t 620 */ 621 typedef struct osip_event osip_event_t; 622 623 /** 624 * Structure for osip event handling. 625 * @struct osip_event 626 */ 627 struct osip_event { 628 type_t type; /**< Event Type */ 629 int transactionid; /**< identifier of the related osip transaction */ 630 osip_message_t *sip; /**< SIP message (optional) */ 631 }; 632 633 /** 634 * Allocate an osip_transaction_t element. 635 * @param transaction The element to allocate. 636 * @param ctx_type The type of transaction. (ICT, IST, NICT, NIST) 637 * @param osip The global instance of oSIP. 638 * @param request The SIP request that initiate the transaction. 639 */ 640 int osip_transaction_init(osip_transaction_t **transaction, osip_fsm_type_t ctx_type, osip_t *osip, osip_message_t *request); 641 /** 642 * Free all resource in a osip_transaction_t element. 643 * @param transaction The element to free. 644 */ 645 int osip_transaction_free(osip_transaction_t *transaction); 646 /** 647 * Free all resource in a osip_transaction_t element. 648 * This method does the same than osip_transaction_free() but it assumes 649 * that the transaction is already removed from the list of transaction 650 * in the osip stack. (to remove it use osip_xixt_remove(osip, transaction); 651 * @param transaction The element to free. 652 */ 653 int osip_transaction_free2(osip_transaction_t *transaction); 654 655 /** 656 * Search in a SIP response the destination where the message 657 * should be sent. 658 * @param response the message to work on. 659 * @param address a pointer to receive the allocated host address. 660 * @param portnum a pointer to receive the host port. 661 */ 662 void osip_response_get_destination(osip_message_t *response, char **address, int *portnum); 663 /** 664 * Set the host and port destination used for sending the SIP message. 665 * This can be useful for an application with 'DIRECT ROOTING MODE' 666 * NOTE: Instead, you should use the 'Route' header facility which 667 * leads to the same behaviour. 668 * @param ict The element to work on. 669 * @param destination The destination host. 670 * @param port The destination port. 671 */ 672 int osip_ict_set_destination(osip_ict_t *ict, char *destination, int port); 673 674 /** 675 * Set the host and port destination used for sending the SIP message. 676 * This can be useful for an application with 'DIRECT ROOTING MODE' 677 * NOTE: Instead, you should use the 'Route' header facility which 678 * leads to the same behaviour. 679 * @param nict The element to work on. 680 * @param destination The destination host. 681 * @param port The destination port. 682 */ 683 int osip_nict_set_destination(osip_nict_t *nict, char *destination, int port); 684 685 /** 686 * Add a SIP event in the fifo of a osip_transaction_t element. 687 * @param transaction The element to work on. 688 * @param evt The event to add. 689 */ 690 int osip_transaction_add_event(osip_transaction_t *transaction, osip_event_t *evt); 691 /** 692 * Consume one osip_event_t element previously added in the fifo. 693 * NOTE: This method MUST NEVER be called within another call 694 * of this method. (For example, you can't call osip_transaction_execute() 695 * in a callback registered in the osip_t element.) 696 * @param transaction The element to free. 697 * @param evt The element to consume. 698 */ 699 int osip_transaction_execute(osip_transaction_t *transaction, osip_event_t *evt); 700 /** 701 * Set a pointer to your personal context associated with this transaction. 702 * OBSOLETE: see osip_transaction_set_reserved1... 703 * NOTE: this is a very useful method that allow you to avoid searching 704 * for your personal context inside the registered callbacks. 705 * You can initialise this pointer to your context right after 706 * the creation of the osip_transaction_t element. Then, you'll be 707 * able to get the address of your context by calling 708 * osip_transaction_get_your_instance(). 709 * @param transaction The element to work on. 710 * @param ptr The address of your context. 711 */ 712 int osip_transaction_set_your_instance(osip_transaction_t *transaction, void *ptr); 713 714 /** 715 * Set a pointer to your personal context associated with this transaction. 716 * NOTE: this is a very useful method that allow you to avoid searching 717 * for your personal context inside the registered callbacks. 718 * You can initialise this pointer to your context right after 719 * the creation of the osip_transaction_t element. Then, you'll be 720 * able to get the address of your context by calling 721 * osip_transaction_get_reserved1(). 722 * @param transaction The element to work on. 723 * @param ptr The address of your context. 724 */ 725 int osip_transaction_set_reserved1(osip_transaction_t *transaction, void *ptr); 726 /** 727 * Set a pointer to your personal context associated with this transaction. 728 * NOTE: see osip_transaction_set_reserved1 729 * @param transaction The element to work on. 730 * @param ptr The address of your context. 731 */ 732 int osip_transaction_set_reserved2(osip_transaction_t *transaction, void *ptr); 733 734 /** 735 * Set a pointer to your personal context associated with this transaction. 736 * NOTE: see osip_transaction_set_reserved1 737 * @param transaction The element to work on. 738 * @param ptr The address of your context. 739 */ 740 int osip_transaction_set_reserved3(osip_transaction_t *transaction, void *ptr); 741 742 /** 743 * Set a pointer to your personal context associated with this transaction. 744 * NOTE: see osip_transaction_set_reserved1 745 * @param transaction The element to work on. 746 * @param ptr The address of your context. 747 */ 748 int osip_transaction_set_reserved4(osip_transaction_t *transaction, void *ptr); 749 750 /** 751 * Set a pointer to your personal context associated with this transaction. 752 * NOTE: see osip_transaction_set_reserved1 753 * @param transaction The element to work on. 754 * @param ptr The address of your context. 755 */ 756 int osip_transaction_set_reserved5(osip_transaction_t *transaction, void *ptr); 757 758 /** 759 * Set a pointer to your personal context associated with this transaction. 760 * NOTE: see osip_transaction_set_reserved1 761 * @param transaction The element to work on. 762 * @param ptr The address of your context. 763 */ 764 int osip_transaction_set_reserved6(osip_transaction_t *transaction, void *ptr); 765 766 /** 767 * Get a pointer to your personal context associated with this transaction. 768 * OBSOLETE: see osip_transaction_get_reserved1... 769 * @param transaction The element to work on. 770 */ 771 void *osip_transaction_get_your_instance(osip_transaction_t *transaction); 772 773 /** 774 * Get a pointer to your personal context associated with this transaction. 775 * @param transaction The element to work on. 776 */ 777 void *osip_transaction_get_reserved1(osip_transaction_t *transaction); 778 779 /** 780 * Get a pointer to your personal context associated with this transaction. 781 * @param transaction The element to work on. 782 */ 783 void *osip_transaction_get_reserved2(osip_transaction_t *transaction); 784 785 /** 786 * Get a pointer to your personal context associated with this transaction. 787 * @param transaction The element to work on. 788 */ 789 void *osip_transaction_get_reserved3(osip_transaction_t *transaction); 790 791 /** 792 * Get a pointer to your personal context associated with this transaction. 793 * @param transaction The element to work on. 794 */ 795 void *osip_transaction_get_reserved4(osip_transaction_t *transaction); 796 797 /** 798 * Get a pointer to your personal context associated with this transaction. 799 * @param transaction The element to work on. 800 */ 801 void *osip_transaction_get_reserved5(osip_transaction_t *transaction); 802 803 /** 804 * Get a pointer to your personal context associated with this transaction. 805 * @param transaction The element to work on. 806 */ 807 void *osip_transaction_get_reserved6(osip_transaction_t *transaction); 808 809 /** 810 * Get target ip and port for this request. 811 * (automaticly set by osip_transaction_init() for ict and nict) 812 * @param transaction The element to work on. 813 * @param ip The ip of host where to send initial request. 814 * @param port The port where to send initial request. 815 */ 816 int osip_transaction_get_destination(osip_transaction_t *transaction, char **ip, int *port); 817 818 /** 819 * Set SRV lookup information to be used by state machine. 820 * 821 * @param transaction The element to work on. 822 * @param record The SRV lookup results for this transaction. 823 */ 824 int osip_transaction_set_srv_record(osip_transaction_t *transaction, osip_srv_record_t *record); 825 826 /** 827 * Set NAPTR lookup information to be used by state machine. 828 * 829 * @param transaction The element to work on. 830 * @param record The NAPTR lookup results for this transaction. 831 */ 832 int osip_transaction_set_naptr_record(osip_transaction_t *transaction, osip_naptr_t *record); 833 834 /** 835 * Set the socket for incoming message. 836 * 837 * @param transaction The element to work on. 838 * @param sock The socket for incoming message. 839 */ 840 int osip_transaction_set_in_socket(osip_transaction_t *transaction, int sock); 841 /** 842 * Set the socket for outgoing message. 843 * 844 * @param transaction The element to work on. 845 * @param sock The socket for outgoing message. 846 */ 847 int osip_transaction_set_out_socket(osip_transaction_t *transaction, int sock); 848 849 /** 850 * Allocate an osip_t element. 851 * @param osip the element to allocate. 852 */ 853 int osip_init(osip_t **osip); 854 /** 855 * Free all resource in a osip_t element. 856 * @param osip The element to release. 857 */ 858 void osip_release(osip_t *osip); 859 860 /** 861 * Set a pointer in a osip_t element. 862 * This help to find your application layer in callbacks. 863 * @param osip The element to work on. 864 * @param pointer The element to set. 865 */ 866 void osip_set_application_context(osip_t *osip, void *pointer); 867 868 /** 869 * Get a pointer in a osip_t element. 870 * This help to find your application layer in callbacks. 871 * @param osip The element to work on. 872 */ 873 void *osip_get_application_context(osip_t *osip); 874 875 /** 876 * Remove a transaction from the osip stack. 877 * @param osip The element to work on. 878 * @param ict The transaction to add. 879 */ 880 int osip_remove_transaction(osip_t *osip, osip_transaction_t *ict); 881 882 /** 883 * Consume ALL pending osip_event_t previously added in the fifos of ict transactions. 884 * @param osip The element to work on. 885 */ 886 int osip_ict_execute(osip_t *osip); 887 /** 888 * Consume ALL pending osip_event_t previously added in the fifos of ist transactions. 889 * @param osip The element to work on. 890 */ 891 int osip_ist_execute(osip_t *osip); 892 /** 893 * Consume ALL pending osip_event_t previously added in the fifos of nict transactions. 894 * @param osip The element to work on. 895 */ 896 int osip_nict_execute(osip_t *osip); 897 /** 898 * Consume ALL pending osip_event_t previously added in the fifos of nist transactions. 899 * @param osip The element to work on. 900 */ 901 int osip_nist_execute(osip_t *osip); 902 903 /** 904 * Retreive the minimum timer value to be used by an application 905 * so that the osip_timer_*_execute method don't have to be called 906 * often. 907 * 908 * @param osip The element to work on. 909 * @param lower_tv The minimum timer when the application should wake up. 910 */ 911 void osip_timers_gettimeout(osip_t *osip, struct timeval *lower_tv); 912 913 /** 914 * Check if an ict transactions needs a timer event. 915 * @param osip The element to work on. 916 */ 917 void osip_timers_ict_execute(osip_t *osip); 918 /** 919 * Check if an ist transactions needs a timer event. 920 * @param osip The element to work on. 921 */ 922 void osip_timers_ist_execute(osip_t *osip); 923 /** 924 * Check if a nict transactions needs a timer event. 925 * @param osip The element to work on. 926 */ 927 void osip_timers_nict_execute(osip_t *osip); 928 /** 929 * Check if a nist transactions needs a timer event. 930 * @param osip The element to work on. 931 */ 932 void osip_timers_nist_execute(osip_t *osip); 933 934 /* Take care of mutlithreading issuewhile using this method */ 935 /** 936 * Search for a transaction that match this event (MUST be a MESSAGE event). 937 * @param transactions The list of transactions to work on. 938 * @param evt The element representing the SIP MESSAGE. 939 */ 940 osip_transaction_t *osip_transaction_find(osip_list_t *transactions, osip_event_t *evt); 941 942 #ifndef DOXYGEN 943 /** 944 * Some race conditions can happen in multi threaded applications. 945 * Use this method carefully. 946 * <BR>Search for a transaction that match this event (MUST be a MESSAGE event). 947 * @param osip The element to work on. 948 * @param evt The element representing the SIP MESSAGE. 949 */ 950 #ifdef OSIP_MONOTHREAD 951 osip_transaction_t *osip_find_transaction(osip_t *osip, osip_event_t *evt); 952 #endif 953 954 osip_transaction_t *__osip_find_transaction(osip_t *osip, osip_event_t *evt, int consume); 955 #endif 956 957 /** 958 * Search for a transaction that match this event (MUST be a MESSAGE event) 959 * and add this event if a transaction is found.. 960 * @param osip The element to work on. 961 * @param evt The element representing the SIP MESSAGE. 962 */ 963 int osip_find_transaction_and_add_event(osip_t *osip, osip_event_t *evt); 964 965 /** 966 * Create a transaction for this event (MUST be a SIP REQUEST event). 967 * @param osip The element to work on. 968 * @param evt The element representing the new SIP REQUEST. 969 */ 970 osip_transaction_t *osip_create_transaction(osip_t *osip, osip_event_t *evt); 971 972 /** 973 * Create a sipevent from a SIP message string. 974 * @param buf The SIP message as a string. 975 * @param length The length of the buffer to parse. 976 */ 977 osip_event_t *osip_parse(const char *buf, size_t length); 978 979 /** 980 * Send required retransmissions 981 * @param osip The element to work on. 982 */ 983 void osip_retransmissions_execute(osip_t *osip); 984 985 /** 986 * Start out of fsm 200 Ok retransmissions. This is usefull for user-agents. 987 * @param osip The osip_t structure. 988 * @param dialog The dialog the 200 Ok is part of. 989 * @param msg200ok The 200 ok response. 990 * @param sock The socket to be used to send the message. (optional). 991 */ 992 void osip_start_200ok_retransmissions(osip_t *osip, struct osip_dialog *dialog, osip_message_t *msg200ok, int sock); 993 994 /** 995 * Start out of fsm ACK retransmissions. This is usefull for user-agents. 996 * @param osip The osip_t structure. 997 * @param dialog The dialog the ACK is part of. 998 * @param ack The ACK that has just been sent in response to a 200 Ok. 999 * @param dest The destination host. 1000 * @param port The destination port. 1001 * @param sock The socket to be used to send the message. (optional). 1002 */ 1003 void osip_start_ack_retransmissions(osip_t *osip, struct osip_dialog *dialog, osip_message_t *ack, char *dest, int port, int sock); 1004 1005 /** 1006 * Stop the out of fsm 200 Ok retransmissions matching an incoming ACK. 1007 * @param osip The osip_t structure. 1008 * @param ack The ack that has just been received. 1009 */ 1010 struct osip_dialog *osip_stop_200ok_retransmissions(osip_t *osip, osip_message_t *ack); 1011 1012 /** 1013 * Stop out of fsm retransmissions (ACK or 200 Ok) associated to a given dialog. 1014 * This function must be called before freeing a dialog if out of fsm retransmissions 1015 * have been scheduled. 1016 * @param osip The osip_t structure 1017 * @param dialog The dialog. 1018 */ 1019 void osip_stop_retransmissions_from_dialog(osip_t *osip, struct osip_dialog *dialog); 1020 1021 /** 1022 * Allocate a sipevent (we know this message is an OUTGOING SIP message). 1023 * @param sip The SIP message we want to send. 1024 */ 1025 osip_event_t *osip_new_outgoing_sipmessage(osip_message_t *sip); 1026 1027 /** 1028 * Free all resource in a sipevent. 1029 * @param event The event to free. 1030 */ 1031 void osip_event_free(osip_event_t *event); 1032 1033 /** 1034 * Register the callback used to send SIP message. 1035 * @param cf The osip element attached to the transaction. 1036 * @param cb The method we want to register. 1037 */ 1038 void osip_set_cb_send_message(osip_t *cf, int (*cb)(osip_transaction_t *, osip_message_t *, char *, int, int)); 1039 1040 /* FOR INCOMING TRANSACTION */ 1041 /** 1042 * Check if the sipevent is of type RCV_REQINVITE. 1043 * @param event the event to check. 1044 */ 1045 #define EVT_IS_RCV_INVITE(event) (event->type == RCV_REQINVITE) 1046 /** 1047 * Check if the sipevent is of type RCV_REQACK. 1048 * @param event the event to check. 1049 */ 1050 #define EVT_IS_RCV_ACK(event) (event->type == RCV_REQACK) 1051 /** 1052 * Check if the sipevent is of type RCV_REQUEST. 1053 * @param event the event to check. 1054 */ 1055 #define EVT_IS_RCV_REQUEST(event) (event->type == RCV_REQUEST) 1056 /** 1057 * Check if the sipevent is of type RCV_STATUS_1XX. 1058 * @param event the event to check. 1059 */ 1060 #define EVT_IS_RCV_STATUS_1XX(event) (event->type == RCV_STATUS_1XX) 1061 /** 1062 * Check if the sipevent is of type RCV_STATUS_2XX. 1063 * @param event the event to check. 1064 */ 1065 #define EVT_IS_RCV_STATUS_2XX(event) (event->type == RCV_STATUS_2XX) 1066 /** 1067 * Check if the sipevent is of type RCV_STATUS_3456XX. 1068 * @param event the event to check. 1069 */ 1070 #define EVT_IS_RCV_STATUS_3456XX(event) (event->type == RCV_STATUS_3456XX) 1071 1072 /* FOR OUTGOING TRANSACTION */ 1073 /** 1074 * Check if the sipevent is of type SND_REQINVITE. 1075 * @param event the event to check. 1076 */ 1077 #define EVT_IS_SND_INVITE(event) (event->type == SND_REQINVITE) 1078 /** 1079 * Check if the sipevent is of type SND_REQACK. 1080 * @param event the event to check. 1081 */ 1082 #define EVT_IS_SND_ACK(event) (event->type == SND_REQACK) 1083 /** 1084 * Check if the sipevent is of type SND_REQUEST. 1085 * @param event the event to check. 1086 */ 1087 #define EVT_IS_SND_REQUEST(event) (event->type == SND_REQUEST) 1088 /** 1089 * Check if the sipevent is of type SND_STATUS_1XX. 1090 * @param event the event to check. 1091 */ 1092 #define EVT_IS_SND_STATUS_1XX(event) (event->type == SND_STATUS_1XX) 1093 /** 1094 * Check if the sipevent is of type SND_STATUS_2XX. 1095 * @param event the event to check. 1096 */ 1097 #define EVT_IS_SND_STATUS_2XX(event) (event->type == SND_STATUS_2XX) 1098 /** 1099 * Check if the sipevent is of type SND_STATUS_3456XX. 1100 * @param event the event to check. 1101 */ 1102 #define EVT_IS_SND_STATUS_3456XX(event) (event->type == SND_STATUS_3456XX) 1103 /** 1104 * Check if the sipevent is of an incoming SIP MESSAGE. 1105 * @param event the event to check. 1106 */ 1107 #define EVT_IS_INCOMINGMSG(event) (event->type >= RCV_REQINVITE && event->type <= RCV_STATUS_3456XX) 1108 /** 1109 * Check if the sipevent is of an incoming SIP REQUEST. 1110 * @param event the event to check. 1111 */ 1112 #define EVT_IS_INCOMINGREQ(event) (EVT_IS_RCV_INVITE(event) || EVT_IS_RCV_ACK(event) || EVT_IS_RCV_REQUEST(event)) 1113 /** 1114 * Check if the sipevent is of an incoming SIP RESPONSE. 1115 * @param event the event to check. 1116 */ 1117 #define EVT_IS_INCOMINGRESP(event) (EVT_IS_RCV_STATUS_1XX(event) || EVT_IS_RCV_STATUS_2XX(event) || EVT_IS_RCV_STATUS_3456XX(event)) 1118 /** 1119 * Check if the sipevent is of an outgoing SIP MESSAGE. 1120 * @param event the event to check. 1121 */ 1122 #define EVT_IS_OUTGOINGMSG(event) (event->type >= SND_REQINVITE && event->type <= SND_STATUS_3456XX) 1123 /** 1124 * Check if the sipevent is of an outgoing SIP REQUEST. 1125 * @param event the event to check. 1126 */ 1127 #define EVT_IS_OUTGOINGREQ(event) (EVT_IS_SND_INVITE(event) || EVT_IS_SND_ACK(event) || EVT_IS_SND_REQUEST(event)) 1128 /** 1129 * Check if the sipevent is of an outgoing SIP RESPONSE. 1130 * @param event the event to check. 1131 */ 1132 #define EVT_IS_OUTGOINGRESP(event) (EVT_IS_SND_STATUS_1XX(event) || EVT_IS_SND_STATUS_2XX(event) || EVT_IS_SND_STATUS_3456XX(event)) 1133 1134 /** 1135 * Check if the sipevent is a SIP MESSAGE. 1136 * @param event the event to check. 1137 */ 1138 #define EVT_IS_MSG(event) (event->type >= RCV_REQINVITE && event->type <= SND_STATUS_3456XX) 1139 /** 1140 * Check if the sipevent is of type KILL_TRANSACTION. 1141 * NOTE: THIS IS AN INTERNAL METHOD ONLY 1142 * @param event the event to check. 1143 */ 1144 #define EVT_IS_KILL_TRANSACTION(event) (event->type == KILL_TRANSACTION) 1145 1146 #ifdef __cplusplus 1147 } 1148 #endif 1149 /** @} */ 1150 #endif 1151