common.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. #if !defined(TINYDEMO_COMMON_H)
  23. #define TINYDEMO_COMMON_H
  24. #include "demo_config.h"
  25. #include "cmd.h"
  26. #include "tinysip.h" /* 3GPP IMS/LTE API */
  27. _BEGIN_DECLS
  28. typedef enum session_type_e {
  29. st_none,
  30. st_invite,
  31. st_message,
  32. st_options,
  33. st_publish,
  34. st_register,
  35. st_subscribe,
  36. }
  37. session_type_t;
  38. typedef struct session_s {
  39. TSK_DECLARE_OBJECT;
  40. tsip_ssession_handle_t* handle;
  41. session_type_t type;
  42. char* from;
  43. char* to;
  44. tsk_bool_t connected;
  45. }
  46. session_t;
  47. typedef tsk_list_t sessions_L_t;
  48. #define SESSION(self) ((session_t*)(self))
  49. typedef struct ctx_s {
  50. TSK_DECLARE_OBJECT;
  51. tsip_stack_handle_t *stack;
  52. /* Identity */
  53. struct {
  54. char* display_name;
  55. char *impu;
  56. char *preferred;
  57. char *impi;
  58. char *password;
  59. } identity;
  60. /* Network */
  61. struct {
  62. char *local_ip;
  63. tnet_port_t local_port;
  64. char *proxy_cscf;
  65. tnet_port_t proxy_cscf_port;
  66. char* proxy_cscf_trans;
  67. char *realm;
  68. tsk_bool_t ipv6;
  69. tsk_bool_t naptr;
  70. tsk_bool_t dhcp;
  71. } network;
  72. /* Security */
  73. struct {
  74. tsk_bool_t earlyIMS;
  75. char* operator_id;
  76. uint16_t amf;
  77. } security;
  78. sessions_L_t* sessions;
  79. tsk_params_L_t* params;
  80. TSK_DECLARE_SAFEOBJ; /* For thread-safeness */
  81. }
  82. ctx_t;
  83. ctx_t* ctx_create();
  84. int stack_dump();
  85. int stack_config(const opts_L_t* opts);
  86. int stack_run(const opts_L_t* opts);
  87. session_t* session_create(session_type_t, tsip_ssession_handle_t* );
  88. #define session_client_create(type) session_create(type, tsk_null)
  89. #define session_server_create(type, handle) session_create(type, handle)
  90. const session_t* session_get_by_sid(const sessions_L_t* , tsip_ssession_id_t );
  91. int session_tostring(const session_t* );
  92. int session_hangup(tsip_ssession_id_t sid);
  93. tsip_action_handle_t* action_get_config(const opts_L_t* opts);
  94. const tsk_object_def_t *session_def_t;
  95. const tsk_object_def_t *ctx_def_t;
  96. _END_DECLS
  97. #endif /* TINYDEMO_COMMON_H */