transaction.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2012 Smile Communications, [email protected]
  5. * Copyright (C) 2012 Smile Communications, [email protected]
  6. *
  7. * The initial version of this code was written by Dragos Vingarzan
  8. * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
  9. * Fruanhofer Institute. It was and still is maintained in a separate
  10. * branch of the original SER. We are therefore migrating it to
  11. * Kamailio/SR and look forward to maintaining it from here on out.
  12. * 2011/2012 Smile Communications, Pty. Ltd.
  13. * ported/maintained/improved by
  14. * Jason Penton (jason(dot)penton(at)smilecoms.com and
  15. * Richard Good (richard(dot)good(at)smilecoms.com) as part of an
  16. * effort to add full IMS support to Kamailio/SR using a new and
  17. * improved architecture
  18. *
  19. * NB: Alot of this code was originally part of OpenIMSCore,
  20. * FhG Fokus.
  21. * Copyright (C) 2004-2006 FhG Fokus
  22. * Thanks for great work! This is an effort to
  23. * break apart the various CSCF functions into logically separate
  24. * components. We hope this will drive wider use. We also feel
  25. * that in this way the architecture is more complete and thereby easier
  26. * to manage in the Kamailio/SR environment
  27. *
  28. * This file is part of Kamailio, a free SIP server.
  29. *
  30. * Kamailio is free software; you can redistribute it and/or modify
  31. * it under the terms of the GNU General Public License as published by
  32. * the Free Software Foundation; either version 2 of the License, or
  33. * (at your option) any later version
  34. *
  35. * Kamailio is distributed in the hope that it will be useful,
  36. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  37. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  38. * GNU General Public License for more details.
  39. *
  40. * You should have received a copy of the GNU General Public License
  41. * along with this program; if not, write to the Free Software
  42. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  43. *
  44. */
  45. #ifndef __TRANSACTION_H_
  46. #define __TRANSACTION_H_
  47. #include <time.h>
  48. #include "statistics.h"
  49. #include "utils.h"
  50. #include "diameter.h"
  51. #include "diameter_api.h"
  52. /** Diameter Transaction representation */
  53. typedef struct _cdp_trans_t{
  54. struct timeval started; /**< Time the transaction was created - used to measure response times */
  55. AAAMsgIdentifier endtoendid; /**< End-to-end id of the messages */
  56. AAAMsgIdentifier hopbyhopid; /**< Hop-by-hop id of the messages */
  57. AAATransactionCallback_f *cb; /**< transactional callback function */
  58. void **ptr; /**< generic pointer to pass to the callback */
  59. AAAMessage *ans; /**< answer for the transaction */
  60. time_t expires; /**< time of expiration, when a time-out event will happen */
  61. int auto_drop; /**< if to drop automatically the transaction on event or to let the app do it later */
  62. struct _cdp_trans_t *next; /**< the next transaction in the transaction list */
  63. struct _cdp_trans_t *prev; /**< the previous transaction in the transaction list */
  64. } cdp_trans_t;
  65. /** Diameter Transaction list */
  66. typedef struct {
  67. gen_lock_t *lock; /**< lock for list operations */
  68. cdp_trans_t *head,*tail; /**< first, last transactions in the list */
  69. } cdp_trans_list_t;
  70. int cdp_trans_init();
  71. int cdp_trans_destroy();
  72. inline cdp_trans_t* cdp_add_trans(AAAMessage *msg,AAATransactionCallback_f *cb, void *ptr,int timeout,int auto_drop);
  73. void del_trans(AAAMessage *msg);
  74. inline cdp_trans_t* cdp_take_trans(AAAMessage *msg);
  75. inline void cdp_free_trans(cdp_trans_t *x);
  76. int cdp_trans_timer(time_t now, void* ptr);
  77. /* API Exported */
  78. /** Timeout for Diameter transactions (this is quite big,
  79. * but increase in case that you have a slow peer) */
  80. AAATransaction *AAACreateTransaction(AAAApplicationId app_id,AAACommandCode cmd_code);
  81. typedef AAATransaction * (*AAACreateTransaction_f)(AAAApplicationId app_id,AAACommandCode cmd_code);
  82. int AAADropTransaction(AAATransaction *trans);
  83. typedef int (*AAADropTransaction_f)(AAATransaction *trans);
  84. #endif /*TRANSACTION_H_*/