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_oh323 driver for Asterisk
13 * chan_oh323 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_oh323 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.
28 #include <arpa/inet.h>
30 static struct sockaddr_in bindaddr;
32 /* structure to hold the valid asterisk users */
42 int noSilenceSuppression;
50 struct sockaddr_in addr;
51 struct oh323_user *next;
54 /* structure to hold the valid asterisk peers
55 All peers are registered to a GK if there is one */
61 int noSilenceSuppression;
67 struct sockaddr_in addr;
69 struct oh323_peer *next;
72 /* structure to hold the H.323 aliases which get registered to
73 the H.323 endpoint and gatekeeper */
76 char e164[20]; /* tells a GK to route this E.164 to this alias */
77 char prefix[500]; /* tells a GK this alias supports these prefixes */
78 char secret[20]; /* the H.235 password to send to the GK for authentication */
80 struct oh323_alias *next;
83 /** call_option struct is filled from the
84 PBX application and passed through make_call
86 typedef struct call_options {
89 int noSilenceSuppression;
94 /** call_details struct call detail records
95 to asterisk for processing and used for matching up
96 asterisk channels to acutal h.323 connections */
97 typedef struct call_details {
98 unsigned int call_reference;
99 const char *call_token;
100 const char *call_source_aliases;
101 const char *call_dest_alias;
102 const char *call_source_e164;
103 const char *call_dest_e164;
104 const char *sourceIp;
107 /* This is a callback prototype function, called pass
108 DTMF down the RTP. */
109 typedef int (*send_digit_cb)(unsigned, char);
110 send_digit_cb on_send_digit;
112 /* This is a callback prototype function, called to collect
113 the external RTP port from Asterisk. */
114 typedef int (*on_connection_cb)(unsigned);
115 on_connection_cb on_create_connection;
117 /* This is a callback prototype function, called upon
118 an incoming call happens. */
119 typedef int (*setup_incoming_cb)(call_details_t);
120 setup_incoming_cb on_incoming_call;
122 /* This is a callback prototype function, called upon
124 typedef int (*setup_outbound_cb)(call_details_t);
125 setup_outbound_cb on_outgoing_call;
127 /* This is a callback prototype function, called when the openh323
128 OnStartLogicalChannel is invoked. */
129 typedef void (*start_logchan_cb)(unsigned int, const char *, int);
130 start_logchan_cb on_start_logical_channel;
132 /* This is a callback protoype function, called when the openh323
133 OnConnectionEstablished is inovked */
134 typedef void (*con_established_cb)(unsigned);
135 con_established_cb on_connection_established;
137 /* This is a callback prototype function, called when the openH323
138 OnConnectionCleared callback is invoked */
139 typedef void (*clear_con_cb)(call_details_t);
140 clear_con_cb on_connection_cleared;
145 #define H323_DTMF_RFC2833 (1 << 0)
146 #define H323_DTMF_INBAND (1 << 1)
152 void h323_gk_urq(void);
153 void h323_end_point_create(void);
154 void h323_end_process(void);
155 int end_point_exist(void);
157 void h323_debug(int, unsigned);
159 /* callback function handler*/
160 void h323_callback_register(setup_incoming_cb, setup_outbound_cb, on_connection_cb, start_logchan_cb, clear_con_cb, con_established_cb, send_digit_cb);
162 int h323_set_capability(int, int);
163 int h323_set_alias(struct oh323_alias *);
164 int h323_set_gk(int, char *, char *);
166 /* H323 listener related funcions */
167 int h323_start_listener(int, struct sockaddr_in, int);
169 void h323_native_bridge(const char *, char *, char *);
171 /* Send a DTMF tone to remote endpoint */
172 void h323_send_tone(const char *call_token, char tone);
174 /* H323 create and destroy sessions */
175 int h323_make_call(char *host, call_details_t *cd, call_options_t);
176 int h323_clear_call(const char *);
177 int h323_answering_call(const char *token, int);
179 int h323_show_codec(int fd, int argc, char *argv[]);