I thought I was going to be able to leave 1.4 alone, but that was not the case.
[asterisk-bristuff.git] / channels / h323 / chan_h323.h
blob0fd94561fb7081eff11709adc9f08097dc6e509d
1 /*
2 * chan_h323.h
4 * OpenH323 Channel Driver for ASTERISK PBX.
5 * By Jeremy McNamara
6 * For The NuFone Network
8 * This code has been derived from code created by
9 * Michael Manousos and Mark Spencer
11 * This file is part of the chan_h323 driver for Asterisk
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.
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.
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.
26 * Version Info: $Id$
29 #include <arpa/inet.h>
32 * Enable support for sending/reception of tunnelled Q.SIG messages and
33 * some sort of IEs (especially RedirectingNumber) which Cisco CallManager
34 * isn't like to pass in standard Q.931 message.
37 #define TUNNELLING
39 #define H323_TUNNEL_CISCO (1 << 0)
40 #define H323_TUNNEL_QSIG (1 << 1)
42 /** call_option struct holds various bits
43 * of information for each call */
44 typedef struct call_options {
45 char cid_num[80];
46 char cid_name[80];
47 char cid_rdnis[80];
48 int redirect_reason;
49 int presentation;
50 int type_of_number;
51 int transfer_capability;
52 int fastStart;
53 int h245Tunneling;
54 int silenceSuppression;
55 int progress_setup;
56 int progress_alert;
57 int progress_audio;
58 int dtmfcodec;
59 int dtmfmode;
60 int capability;
61 int bridge;
62 int nat;
63 int tunnelOptions;
64 struct ast_codec_pref prefs;
65 } call_options_t;
67 /* structure to hold the valid asterisk users */
68 struct oh323_user {
69 ASTOBJ_COMPONENTS(struct oh323_user);
70 // char name[80];
71 char context[80];
72 char secret[80];
73 char accountcode[AST_MAX_ACCOUNT_CODE];
74 int amaflags;
75 int host;
76 struct sockaddr_in addr;
77 struct ast_ha *ha;
78 call_options_t options;
81 /* structure to hold the valid asterisk peers
82 All peers are registered to a GK if there is one */
83 struct oh323_peer {
84 ASTOBJ_COMPONENTS(struct oh323_peer);
85 char mailbox[80];
86 int delme;
87 struct sockaddr_in addr;
88 struct ast_ha *ha;
89 call_options_t options;
92 /* structure to hold the H.323 aliases which get registered to
93 the H.323 endpoint and gatekeeper */
94 struct oh323_alias {
95 ASTOBJ_COMPONENTS(struct oh323_alias);
96 char e164[20]; /* tells a GK to route this E.164 to this alias */
97 char prefix[500]; /* tells a GK this alias supports these prefixes */
98 char secret[20]; /* the H.235 password to send to the GK for authentication */
99 char context[80];
102 /** call_details struct call detail records
103 to asterisk for processing and used for matching up
104 asterisk channels to acutal h.323 connections */
105 typedef struct call_details {
106 unsigned int call_reference;
107 char *call_token;
108 char *call_source_aliases;
109 char *call_dest_alias;
110 char *call_source_name;
111 char *call_source_e164;
112 char *call_dest_e164;
113 char *redirect_number;
114 int redirect_reason;
115 int presentation;
116 int type_of_number;
117 int transfer_capability;
118 char *sourceIp;
119 } call_details_t;
121 typedef struct rtp_info {
122 char addr[32];
123 unsigned int port;
124 } 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;
131 /* This is a callback prototype function, called to collect
132 the external RTP port from Asterisk. */
133 typedef rtp_info_t *(*on_rtp_cb)(unsigned, const char *);
134 extern on_rtp_cb on_external_rtp_create;
136 /* This is a callback prototype function, called to send
137 the remote IP and RTP port from H.323 to Asterisk */
138 typedef void (*start_rtp_cb)(unsigned int, const char *, int, const char *, int);
139 extern start_rtp_cb on_start_rtp_channel;
141 /* This is a callback that happens when call progress is
142 * made, and handles inband progress */
143 typedef int (*progress_cb)(unsigned, const char *, int);
144 extern progress_cb on_progress;
146 /* This is a callback prototype function, called upon
147 an incoming call happens. */
148 typedef call_options_t *(*setup_incoming_cb)(call_details_t *);
149 extern setup_incoming_cb on_incoming_call;
151 /* This is a callback prototype function, called upon
152 an outbound call. */
153 typedef int (*setup_outbound_cb)(call_details_t *);
154 extern setup_outbound_cb on_outgoing_call;
156 /* This is a callback prototype function, called when
157 OnAlerting is invoked */
158 typedef void (*chan_ringing_cb)(unsigned, const char *);
159 extern chan_ringing_cb on_chan_ringing;
161 /* This is a callback protoype function, called when
162 OnConnectionEstablished is inovked */
163 typedef void (*con_established_cb)(unsigned, const char *);
164 extern con_established_cb on_connection_established;
166 /* This is a callback prototype function, called when
167 OnConnectionCleared callback is invoked */
168 typedef void (*clear_con_cb)(unsigned, const char *);
169 extern clear_con_cb on_connection_cleared;
171 /* This is a callback prototype function, called when
172 an H.323 call is answered */
173 typedef int (*answer_call_cb)(unsigned, const char *);
174 extern answer_call_cb on_answer_call;
176 /* This is a callback prototype function, called when
177 we know which RTP payload type RFC2833 will be
178 transmitted */
179 typedef void (*rfc2833_cb)(unsigned, const char *, int);
180 extern rfc2833_cb on_set_rfc2833_payload;
182 typedef void (*hangup_cb)(unsigned, const char *, int);
183 extern hangup_cb on_hangup;
185 typedef void (*setcapabilities_cb)(unsigned, const char *);
186 extern setcapabilities_cb on_setcapabilities;
188 typedef void (*setpeercapabilities_cb)(unsigned, const char *, int, struct ast_codec_pref *);
189 extern setpeercapabilities_cb on_setpeercapabilities;
191 /* debug flag */
192 extern int h323debug;
194 #define H323_DTMF_RFC2833 (1 << 0)
195 #define H323_DTMF_INBAND (1 << 1)
197 #ifndef BOOL
198 #define BOOL int
199 #endif
201 #ifdef __cplusplus
202 extern "C" {
203 #endif
205 void h323_gk_urq(void);
206 void h323_end_point_create(void);
207 void h323_end_process(void);
208 int h323_end_point_exist(void);
210 void h323_debug(int, unsigned);
212 /* callback function handler*/
213 void h323_callback_register(setup_incoming_cb,
214 setup_outbound_cb,
215 on_rtp_cb,
216 start_rtp_cb,
217 clear_con_cb,
218 chan_ringing_cb,
219 con_established_cb,
220 receive_digit_cb,
221 answer_call_cb,
222 progress_cb,
223 rfc2833_cb,
224 hangup_cb,
225 setcapabilities_cb,
226 setpeercapabilities_cb);
227 int h323_set_capabilities(const char *, int, int, struct ast_codec_pref *, int);
228 int h323_set_alias(struct oh323_alias *);
229 int h323_set_gk(int, char *, char *);
230 void h323_set_id(char *);
231 void h323_show_tokens(void);
233 /* H323 listener related funcions */
234 int h323_start_listener(int, struct sockaddr_in);
236 void h323_native_bridge(const char *, const char *, char *);
238 /* Send a DTMF tone to remote endpoint */
239 void h323_send_tone(const char *call_token, char tone);
241 /* H323 create and destroy sessions */
242 int h323_make_call(char *dest, call_details_t *cd, call_options_t *);
243 int h323_clear_call(const char *, int cause);
245 /* H.323 alerting and progress */
246 int h323_send_alerting(const char *token);
247 int h323_send_progress(const char *token);
248 int h323_answering_call(const char *token, int);
249 int h323_soft_hangup(const char *data);
250 int h323_show_codec(int fd, int argc, char *argv[]);
252 #ifdef __cplusplus
254 #endif