osip.h 41 KB

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