4 * OpenH323 Channel Driver for ASTERISK PBX.
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.
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.
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
{
51 int transfer_capability
;
54 int silenceSuppression
;
64 struct ast_codec_pref prefs
;
67 /* structure to hold the valid asterisk users */
69 ASTOBJ_COMPONENTS(struct oh323_user
);
73 char accountcode
[AST_MAX_ACCOUNT_CODE
];
76 struct sockaddr_in addr
;
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 */
84 ASTOBJ_COMPONENTS(struct oh323_peer
);
87 struct sockaddr_in addr
;
89 call_options_t options
;
92 /* structure to hold the H.323 aliases which get registered to
93 the H.323 endpoint and gatekeeper */
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 */
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
;
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
;
117 int transfer_capability
;
121 typedef struct rtp_info
{
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
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
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
;
192 extern int h323debug
;
194 #define H323_DTMF_RFC2833 (1 << 0)
195 #define H323_DTMF_INBAND (1 << 1)
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
,
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
[]);