chan_h323.h 8.0 KB

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