[Asterisk-cvs] asterisk/channels chan_h323.c,1.78,1.79
jeremy at lists.digium.com
jeremy at lists.digium.com
Sun Oct 10 08:19:30 CDT 2004
- Previous message: [Asterisk-cvs] asterisk/channels/h323 Makefile, 1.18,
1.19 ast_h323.cpp, 1.61, 1.62 ast_h323.h, 1.26,
1.27 chan_h323.h, 1.29, 1.30
- Next message: [Asterisk-cvs] asterisk/channels/h323 README,1.27,1.28
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv17155
Modified Files:
chan_h323.c
Log Message:
finish implementing type=peer, implement setting of FastStart and H.245 Tunneling per user/peer, update External RTP implemenation, fixed compile process/other buglets to operate with Open H.323 v1.14.4 and PWLib v1.7.5, and massive code clean up. All of the above is untested, please test and report
Index: chan_h323.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_h323.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- chan_h323.c 4 Oct 2004 10:13:01 -0000 1.78
+++ chan_h323.c 10 Oct 2004 12:20:18 -0000 1.79
@@ -72,10 +72,10 @@
#include "h323/chan_h323.h"
send_digit_cb on_send_digit;
-on_connection_cb on_create_connection;
+on_rtp_cb on_external_rtp_create;
+start_rtp_cb on_start_rtp_channel;
setup_incoming_cb on_incoming_call;
setup_outbound_cb on_outgoing_call;
-start_logchan_cb on_start_logical_channel;
chan_ringing_cb on_chan_ringing;
con_established_cb on_connection_established;
clear_con_cb on_connection_cleared;
@@ -426,7 +426,6 @@
int res = 0;
struct oh323_pvt *pvt = (struct oh323_pvt *)c->pvt->pvt;
char called_addr[256];
- char *cid, *cidname, oldcid[256];
char iabuf[INET_ADDRSTRLEN];
if ((c->_state != AST_STATE_DOWN) && (c->_state != AST_STATE_RESERVED)) {
@@ -448,49 +447,6 @@
/* indicate that this is an outgoing call */
pvt->outgoing = 1;
ast_log(LOG_DEBUG, "Outgoing call to %s:%d\n", called_addr, pvt->options.port);
-
- /* Copy callerid, if there is any */
- if (!ast_strlen_zero(c->callerid)) {
- memset(oldcid, 0, sizeof(oldcid));
- memcpy(oldcid, c->callerid, strlen(c->callerid));
- oldcid[sizeof(oldcid)-1] = '\0';
- ast_callerid_parse(oldcid, &cidname, &cid);
- if (!ast_strlen_zero(pvt->options.callerid)) {
- free(pvt->options.callerid);
- pvt->options.callerid = NULL;
- }
- if (!ast_strlen_zero(pvt->options.callername)) {
- free(pvt->options.callername);
- pvt->options.callername = NULL;
- }
- pvt->options.callerid = (char*)malloc(256);
- if (!pvt->options.callerid) {
- ast_log(LOG_ERROR, "Not enough memory to allocate callerid\n");
- return(-1);
- }
- memset(pvt->options.callerid, 0, 256);
- if ((!ast_strlen_zero(cid)) && (!ast_strlen_zero(cid))) {
- strncpy(pvt->options.callerid, cid, sizeof(pvt->options.callerid) - 1);
- }
- pvt->options.callername = (char*)malloc(256);
- if (!pvt->options.callername) {
- ast_log(LOG_ERROR, "Not enough memory.\n");
- return(-1);
- }
- memset(pvt->options.callername, 0, 256);
- if ((!ast_strlen_zero(cidname)) && (!ast_strlen_zero(cidname))) {
- strncpy(pvt->options.callername, cidname, sizeof(pvt->options.callername) - 1);
- }
- } else {
- if (!ast_strlen_zero(pvt->options.callerid)) {
- free(pvt->options.callerid);
- pvt->options.callerid = NULL;
- }
- if (!ast_strlen_zero(pvt->options.callername)) {
- free(pvt->options.callername);
- pvt->options.callername = NULL;
- }
- }
res = h323_make_call(called_addr, &(pvt->cd), pvt->options);
if (res) {
ast_log(LOG_NOTICE, "h323_make_call failed(%s)\n", c->name);
@@ -752,8 +708,6 @@
strncpy(ch->context, pvt->context, sizeof(ch->context) - 1);
strncpy(ch->exten, pvt->exten, sizeof(ch->exten) - 1);
ch->priority = 1;
- if (!ast_strlen_zero(pvt->callerid))
- ch->callerid = strdup(pvt->callerid);
if (!ast_strlen_zero(pvt->accountcode))
strncpy(ch->accountcode, pvt->accountcode, sizeof(ch->accountcode) - 1);
if (pvt->amaflags)
@@ -1071,51 +1025,91 @@
}
/**
- * Call-back function that gets called when any H.323 connection is made
+ * Callback function used to inform the H.323 stack of the local rtp ip/port details
*
* Returns the local RTP information
*/
-struct rtp_info *create_connection(unsigned call_reference, const char * token)
+struct rtp_info *external_rtp_create(unsigned call_reference, const char * token)
{
struct oh323_pvt *pvt;
struct sockaddr_in us;
- struct sockaddr_in them;
struct rtp_info *info;
-
- /* XXX This is sooooo bugus. inet_ntoa is not reentrant
- but this function wants to return a static variable so
- the only way to do this will be to declare iabuf within
- the oh323_pvt structure XXX */
- static char iabuf[INET_ADDRSTRLEN];
-
- info = (struct rtp_info *) malloc(sizeof(struct rtp_info));
+ static char iabuf[INET_ADDRSTRLEN];
+ info = (struct rtp_info *)malloc(sizeof(struct rtp_info));
+ if (!info) {
+ ast_log(LOG_ERROR, "Unable to allocated info structure, this is very bad\n");
+ return NULL;
+ }
pvt = find_call(call_reference, token);
-
if (!pvt) {
- ast_log(LOG_ERROR, "Unable to allocate private structure, this is very bad.\n");
+ ast_log(LOG_ERROR, "Unable to find call %s(%d)\n", token, call_reference);
return NULL;
}
-
/* figure out our local RTP port and tell the H.323 stack about it*/
ast_rtp_get_us(pvt->rtp, &us);
- ast_rtp_get_peer(pvt->rtp, &them);
-
info->addr = ast_inet_ntoa(iabuf, sizeof(iabuf), us.sin_addr);
info->port = ntohs(us.sin_port);
-
return info;
}
/**
+ * Call-back function passing remote ip/port information from H.323 to asterisk
+ *
+ * Returns nothing
+ */
+void setup_rtp_connection(unsigned call_reference, const char *remoteIp, int remotePort, const char *token)
+{
+ struct oh323_pvt *pvt = NULL;
+ struct sockaddr_in them;
+
+ /* Find the call or allocate a private structure if call not found */
+ pvt = find_call(call_reference, token);
+ if (!pvt) {
+ ast_log(LOG_ERROR, "Something is wrong: rtp\n");
+ return;
+ }
+ them.sin_family = AF_INET;
+ them.sin_addr.s_addr = inet_addr(remoteIp); // only works for IPv4
+ them.sin_port = htons(remotePort);
+ ast_rtp_set_peer(pvt->rtp, &them);
+ return;
+}
+
+/**
+ * Call-back function to signal asterisk that the channel has been answered
+ * Returns nothing
+ */
+void connection_made(unsigned call_reference, const char *token)
+{
+ struct ast_channel *c = NULL;
+ struct oh323_pvt *pvt = NULL;
+
+ pvt = find_call(call_reference, token);
+
+ if (!pvt) {
+ ast_log(LOG_ERROR, "Something is wrong: connection\n");
+ return;
+ }
+
+ if (!pvt->owner) {
+ ast_log(LOG_ERROR, "Channel has no owner\n");
+ return;
+ }
+ c = pvt->owner;
+
+ ast_setstate(c, AST_STATE_UP);
+ ast_queue_control(c, AST_CONTROL_ANSWER);
+ return;
+}
+
+/**
* Call-back function for incoming calls
*
* Returns 1 on success
*/
-
int setup_incoming_call(call_details_t cd)
{
-
struct oh323_pvt *pvt = NULL;
struct oh323_user *user = NULL;
struct oh323_alias *alias = NULL;
@@ -1269,56 +1263,6 @@
}
/**
- * Call-back function that gets called for each rtp channel opened
- *
- * Returns nothing
- */
-void setup_rtp_connection(unsigned call_reference, const char *remoteIp, int remotePort, const char *token)
-{
- struct oh323_pvt *pvt = NULL;
- struct sockaddr_in them;
-
- /* Find the call or allocate a private structure if call not found */
- pvt = find_call(call_reference, token);
- if (!pvt) {
- ast_log(LOG_ERROR, "Something is wrong: rtp\n");
- return;
- }
- them.sin_family = AF_INET;
- them.sin_addr.s_addr = inet_addr(remoteIp); // only works for IPv4
- them.sin_port = htons(remotePort);
- ast_rtp_set_peer(pvt->rtp, &them);
- return;
-}
-
-/**
- * Call-back function to signal asterisk that the channel has been answered
- * Returns nothing
- */
-void connection_made(unsigned call_reference, const char *token)
-{
- struct ast_channel *c = NULL;
- struct oh323_pvt *pvt = NULL;
-
- pvt = find_call(call_reference, token);
-
- if (!pvt) {
- ast_log(LOG_ERROR, "Something is wrong: connection\n");
- return;
- }
-
- if (!pvt->owner) {
- ast_log(LOG_ERROR, "Channel has no owner\n");
- return;
- }
- c = pvt->owner;
-
- ast_setstate(c, AST_STATE_UP);
- ast_queue_control(c, AST_CONTROL_ANSWER);
- return;
-}
-
-/**
* Call-back function to signal asterisk that the channel is ringing
* Returns nothing
*/
@@ -1979,7 +1923,7 @@
/* Register our callback functions */
h323_callback_register(setup_incoming_call,
setup_outgoing_call,
- create_connection,
+ external_rtp_create,
setup_rtp_connection,
cleanup_connection,
chan_ringing,
- Previous message: [Asterisk-cvs] asterisk/channels/h323 Makefile, 1.18,
1.19 ast_h323.cpp, 1.61, 1.62 ast_h323.h, 1.26,
1.27 chan_h323.h, 1.29, 1.30
- Next message: [Asterisk-cvs] asterisk/channels/h323 README,1.27,1.28
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the svn-commits
mailing list