chan_h323.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * chan_h323.h
  3. *
  4. * OpenH323 Channel Driver for ASTERISK PBX.
  5. * By Jeremy McNamara
  6. * For The NuFone Network
  7. *
  8. * This code has been derived from code created by
  9. * Michael Manousos and Mark Spencer
  10. *
  11. * This file is part of the chan_h323 driver for Asterisk
  12. *
  13. * chan_h323 is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * chan_h323 is distributed WITHOUT ANY WARRANTY; without even
  19. * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  20. * PURPOSE. See the GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25. *
  26. * Version Info: $Id$
  27. */
  28. #include <arpa/inet.h>
  29. static struct sockaddr_in bindaddr;
  30. /* structure to hold the valid asterisk users */
  31. struct oh323_user {
  32. char name[80];
  33. char context[80];
  34. char secret[80];
  35. char callerid[80];
  36. char accountcode[20];
  37. int amaflags;
  38. int noFastStart;
  39. int noH245Tunneling;
  40. int noSilenceSuppression;
  41. int inUse;
  42. int incominglimit;
  43. int bridge;
  44. int nat;
  45. int dtmfmode;
  46. int host;
  47. struct ast_ha *ha;
  48. struct sockaddr_in addr;
  49. struct oh323_user *next;
  50. };
  51. /* structure to hold the valid asterisk peers
  52. All peers are registered to a GK if there is one */
  53. struct oh323_peer {
  54. char name[80];
  55. char context[80];
  56. int noFastStart;
  57. int noH245Tunneling;
  58. int noSilenceSuppression;
  59. int inUse;
  60. int outgoinglimit;
  61. int bridge;
  62. int nat;
  63. int dtmfmode;
  64. int delme;
  65. struct sockaddr_in addr;
  66. struct oh323_peer *next;
  67. };
  68. /* structure to hold the H.323 aliases which get registered to
  69. the H.323 endpoint and gatekeeper */
  70. struct oh323_alias {
  71. char name[80];
  72. char e164[20]; /* tells a GK to route this E.164 to this alias */
  73. char prefix[500]; /* tells a GK this alias supports these prefixes */
  74. char secret[20]; /* the H.235 password to send to the GK for authentication */
  75. char context[80];
  76. struct oh323_alias *next;
  77. };
  78. /** call_option struct is filled from the
  79. PBX application and passed through make_call
  80. function*/
  81. typedef struct call_options {
  82. char *callerid;
  83. char *callername;
  84. int noFastStart;
  85. int noH245Tunneling;
  86. int noSilenceSuppression;
  87. unsigned int port;
  88. } call_options_t;
  89. /** call_details struct call detail records
  90. to asterisk for processing and used for matching up
  91. asterisk channels to acutal h.323 connections */
  92. typedef struct call_details {
  93. unsigned int call_reference;
  94. char *call_token;
  95. char *call_source_aliases;
  96. char *call_dest_alias;
  97. char *call_source_name;
  98. char *call_source_e164;
  99. char *call_dest_e164;
  100. char *sourceIp;
  101. } call_details_t;
  102. typedef struct rtp_info {
  103. const char *addr;
  104. unsigned int port;
  105. } rtp_info_t;
  106. /* This is a callback prototype function, called pass
  107. DTMF down the RTP. */
  108. typedef int (*send_digit_cb)(unsigned, char, const char *);
  109. extern send_digit_cb on_send_digit;
  110. /* This is a callback prototype function, called to collect
  111. the external RTP port from Asterisk. */
  112. typedef rtp_info_t *(*on_connection_cb)(unsigned, const char *);
  113. extern on_connection_cb on_create_connection;
  114. /* This is a callback prototype function, called upon
  115. an incoming call happens. */
  116. typedef int (*setup_incoming_cb)(call_details_t);
  117. extern setup_incoming_cb on_incoming_call;
  118. /* This is a callback prototype function, called upon
  119. an outbound call. */
  120. typedef int (*setup_outbound_cb)(call_details_t);
  121. extern setup_outbound_cb on_outgoing_call;
  122. /* This is a callback prototype function, called when the openh323
  123. OnStartLogicalChannel is invoked. */
  124. typedef void (*start_logchan_cb)(unsigned int, const char *, int, const char *);
  125. extern start_logchan_cb on_start_logical_channel;
  126. /* This is a callback prototype function, called when openh323
  127. OnAlerting is invoked */
  128. typedef void (*chan_ringing_cb)(unsigned, const char *);
  129. extern chan_ringing_cb on_chan_ringing;
  130. /* This is a callback protoype function, called when the openh323
  131. OnConnectionEstablished is inovked */
  132. typedef void (*con_established_cb)(unsigned, const char *);
  133. extern con_established_cb on_connection_established;
  134. /* This is a callback prototype function, called when the openH323
  135. OnConnectionCleared callback is invoked */
  136. typedef void (*clear_con_cb)(call_details_t);
  137. extern clear_con_cb on_connection_cleared;
  138. typedef int (*answer_call_cb)(unsigned, const char *);
  139. extern answer_call_cb on_answer_call;
  140. /* debug flag */
  141. extern int h323debug;
  142. #define H323_DTMF_RFC2833 (1 << 0)
  143. #define H323_DTMF_INBAND (1 << 1)
  144. #ifdef __cplusplus
  145. extern "C" {
  146. #endif
  147. void h323_gk_urq(void);
  148. void h323_end_point_create(int, int);
  149. void h323_end_process(void);
  150. int h323_end_point_exist(void);
  151. void h323_debug(int, unsigned);
  152. /* callback function handler*/
  153. void h323_callback_register(setup_incoming_cb,
  154. setup_outbound_cb,
  155. on_connection_cb,
  156. start_logchan_cb,
  157. clear_con_cb,
  158. chan_ringing_cb,
  159. con_established_cb,
  160. send_digit_cb,
  161. answer_call_cb);
  162. int h323_set_capability(int, int);
  163. int h323_set_alias(struct oh323_alias *);
  164. int h323_set_gk(int, char *, char *);
  165. void h323_set_id(char *);
  166. void h323_show_tokens(void);
  167. /* H323 listener related funcions */
  168. int h323_start_listener(int, struct sockaddr_in);
  169. void h323_native_bridge(const char *, const char *, char *);
  170. /* Send a DTMF tone to remote endpoint */
  171. void h323_send_tone(const char *call_token, char tone);
  172. /* H323 create and destroy sessions */
  173. int h323_make_call(char *host, call_details_t *cd, call_options_t);
  174. int h323_clear_call(const char *);
  175. void h323_set_options(int nofs, int noh245tun);
  176. /* H.323 alerting and progress */
  177. int h323_send_alerting(const char *token);
  178. int h323_send_progress(const char *token);
  179. int h323_answering_call(const char *token, int);
  180. int h323_soft_hangup(const char *data);
  181. int h323_show_codec(int fd, int argc, char *argv[]);
  182. #ifdef __cplusplus
  183. }
  184. #endif