chan_h323.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. #ifndef CHAN_H323_H
  29. #define CHAN_H323_H
  30. #include <arpa/inet.h>
  31. #include "asterisk/format.h"
  32. /*
  33. * Enable support for sending/reception of tunnelled Q.SIG messages and
  34. * some sort of IEs (especially RedirectingNumber) which Cisco CallManager
  35. * isn't like to pass in standard Q.931 message.
  36. *
  37. */
  38. #define TUNNELLING
  39. #define H323_TUNNEL_CISCO (1 << 0)
  40. #define H323_TUNNEL_QSIG (1 << 1)
  41. #define H323_HOLD_NOTIFY (1 << 0)
  42. #define H323_HOLD_Q931ONLY (1 << 1)
  43. #define H323_HOLD_H450 (1 << 2)
  44. typedef int64_t h323_format;
  45. /** call_option struct holds various bits
  46. * of information for each call */
  47. typedef struct call_options {
  48. char cid_num[80];
  49. char cid_name[80];
  50. char cid_rdnis[80];
  51. int redirect_reason;
  52. int presentation;
  53. int type_of_number;
  54. int transfer_capability;
  55. int fastStart;
  56. int h245Tunneling;
  57. int silenceSuppression;
  58. int progress_setup;
  59. int progress_alert;
  60. int progress_audio;
  61. int dtmfcodec[2];
  62. int dtmfmode;
  63. h323_format capability;
  64. int bridge;
  65. int nat;
  66. int tunnelOptions;
  67. int holdHandling;
  68. int autoframing; /*!< turn on to override local settings with remote framing length */
  69. struct ast_codec_pref prefs;
  70. } call_options_t;
  71. /* structure to hold the valid asterisk users */
  72. struct oh323_user {
  73. ASTOBJ_COMPONENTS(struct oh323_user);
  74. // char name[80];
  75. char context[80];
  76. char secret[80];
  77. char accountcode[AST_MAX_ACCOUNT_CODE];
  78. int amaflags;
  79. int host;
  80. struct sockaddr_in addr;
  81. struct ast_ha *ha;
  82. call_options_t options;
  83. };
  84. /* structure to hold the valid asterisk peers
  85. All peers are registered to a GK if there is one */
  86. struct oh323_peer {
  87. ASTOBJ_COMPONENTS(struct oh323_peer);
  88. char mailbox[80];
  89. int delme;
  90. struct sockaddr_in addr;
  91. struct ast_ha *ha;
  92. call_options_t options;
  93. };
  94. /* structure to hold the H.323 aliases which get registered to
  95. the H.323 endpoint and gatekeeper */
  96. struct oh323_alias {
  97. ASTOBJ_COMPONENTS(struct oh323_alias);
  98. char e164[20]; /* tells a GK to route this E.164 to this alias */
  99. char prefix[500]; /* tells a GK this alias supports these prefixes */
  100. char secret[20]; /* the H.235 password to send to the GK for authentication */
  101. char context[80];
  102. };
  103. /** call_details struct call detail records
  104. to asterisk for processing and used for matching up
  105. asterisk channels to acutal h.323 connections */
  106. typedef struct call_details {
  107. unsigned int call_reference;
  108. char *call_token;
  109. char *call_source_aliases;
  110. char *call_dest_alias;
  111. char *call_source_name;
  112. char *call_source_e164;
  113. char *call_dest_e164;
  114. char *redirect_number;
  115. int redirect_reason;
  116. int presentation;
  117. int type_of_number;
  118. int transfer_capability;
  119. char *sourceIp;
  120. } call_details_t;
  121. typedef struct rtp_info {
  122. char addr[32];
  123. unsigned int port;
  124. } rtp_info_t;
  125. /* This is a callback prototype function, called pass
  126. DTMF down the RTP. */
  127. typedef int (*receive_digit_cb)(unsigned, char, const char *, int);
  128. extern receive_digit_cb on_receive_digit;
  129. /* This is a callback prototype function, called to collect
  130. the external RTP port from Asterisk. */
  131. typedef rtp_info_t *(*on_rtp_cb)(unsigned, const char *);
  132. extern on_rtp_cb on_external_rtp_create;
  133. /* This is a callback prototype function, called to send
  134. the remote IP and RTP port from H.323 to Asterisk */
  135. typedef void (*start_rtp_cb)(unsigned int, const char *, int, const char *, int);
  136. extern start_rtp_cb on_start_rtp_channel;
  137. /* This is a callback that happens when call progress is
  138. * made, and handles inband progress */
  139. typedef int (*progress_cb)(unsigned, const char *, int);
  140. extern progress_cb on_progress;
  141. /* This is a callback prototype function, called upon
  142. an incoming call happens. */
  143. typedef call_options_t *(*setup_incoming_cb)(call_details_t *);
  144. extern setup_incoming_cb on_incoming_call;
  145. /* This is a callback prototype function, called upon
  146. an outbound call. */
  147. typedef int (*setup_outbound_cb)(call_details_t *);
  148. extern setup_outbound_cb on_outgoing_call;
  149. /* This is a callback prototype function, called when
  150. OnAlerting is invoked */
  151. typedef void (*chan_ringing_cb)(unsigned, const char *);
  152. extern chan_ringing_cb on_chan_ringing;
  153. /* This is a callback protoype function, called when
  154. OnConnectionEstablished is inovked */
  155. typedef void (*con_established_cb)(unsigned, const char *);
  156. extern con_established_cb on_connection_established;
  157. /* This is a callback prototype function, called when
  158. OnConnectionCleared callback is invoked */
  159. typedef void (*clear_con_cb)(unsigned, const char *);
  160. extern clear_con_cb on_connection_cleared;
  161. /* This is a callback prototype function, called when
  162. an H.323 call is answered */
  163. typedef int (*answer_call_cb)(unsigned, const char *);
  164. extern answer_call_cb on_answer_call;
  165. /* This is a callback prototype function, called when
  166. we know which RTP payload type RFC2833 will be
  167. transmitted */
  168. typedef void (*rfc2833_cb)(unsigned, const char *, int, int);
  169. extern rfc2833_cb on_set_rfc2833_payload;
  170. typedef void (*hangup_cb)(unsigned, const char *, int);
  171. extern hangup_cb on_hangup;
  172. typedef void (*setcapabilities_cb)(unsigned, const char *);
  173. extern setcapabilities_cb on_setcapabilities;
  174. typedef void (*setpeercapabilities_cb)(unsigned, const char *, int, struct ast_codec_pref *);
  175. extern setpeercapabilities_cb on_setpeercapabilities;
  176. typedef void (*onhold_cb)(unsigned, const char *, int);
  177. extern onhold_cb on_hold;
  178. /* debug flag */
  179. extern int h323debug;
  180. #define H323_DTMF_RFC2833 (1 << 0)
  181. #define H323_DTMF_CISCO (1 << 1)
  182. #define H323_DTMF_SIGNAL (1 << 2)
  183. #define H323_DTMF_INBAND (1 << 3)
  184. #define H323_DTMF_RFC2833_PT 101
  185. #define H323_DTMF_CISCO_PT 121
  186. #ifdef __cplusplus
  187. extern "C" {
  188. #endif
  189. void h323_gk_urq(void);
  190. void h323_end_point_create(void);
  191. void h323_end_process(void);
  192. int h323_end_point_exist(void);
  193. void h323_debug(int, unsigned);
  194. /* callback function handler*/
  195. void h323_callback_register(setup_incoming_cb,
  196. setup_outbound_cb,
  197. on_rtp_cb,
  198. start_rtp_cb,
  199. clear_con_cb,
  200. chan_ringing_cb,
  201. con_established_cb,
  202. receive_digit_cb,
  203. answer_call_cb,
  204. progress_cb,
  205. rfc2833_cb,
  206. hangup_cb,
  207. setcapabilities_cb,
  208. setpeercapabilities_cb,
  209. onhold_cb);
  210. int h323_set_capabilities(const char *, int, int, struct ast_codec_pref *, int);
  211. int h323_set_alias(struct oh323_alias *);
  212. int h323_set_gk(int, char *, char *);
  213. void h323_set_id(char *);
  214. void h323_show_tokens(void);
  215. void h323_show_version(void);
  216. /* H323 listener related funcions */
  217. int h323_start_listener(int, struct sockaddr_in);
  218. void h323_native_bridge(const char *, const char *, char *);
  219. /* Send a DTMF tone to remote endpoint */
  220. void h323_send_tone(const char *call_token, char tone);
  221. /* H323 create and destroy sessions */
  222. int h323_make_call(char *dest, call_details_t *cd, call_options_t *);
  223. int h323_clear_call(const char *, int cause);
  224. /* H.323 alerting and progress */
  225. int h323_send_alerting(const char *token);
  226. int h323_send_progress(const char *token);
  227. int h323_answering_call(const char *token, int);
  228. int h323_soft_hangup(const char *data);
  229. int h323_show_codec(int fd, int argc, char *argv[]);
  230. int h323_hold_call(const char *token, int);
  231. #ifdef __cplusplus
  232. }
  233. #endif
  234. #endif