return p;
}
-static struct oh323_pvt *find_call(int call_reference)
+static struct oh323_pvt *find_call(int call_reference, const char *token)
{
struct oh323_pvt *p;
while(p) {
if ((signed int)p->cd.call_reference == call_reference) {
- /* Found the call */
- ast_mutex_unlock(&iflock);
- return p;
+ /* Found the call */
+
+
+ if ((token != NULL) && (strcmp(p->cd.call_token, token) == 0)) {
+ ast_mutex_unlock(&iflock);
+ return p;
+ } else if(token == NULL) {
+ ast_log(LOG_DEBUG, "token is NULL, skipping comparition\n");
+ ast_mutex_unlock(&iflock);
+ return p;
+ }
+
}
p = p->next;
}
ast_mutex_unlock(&iflock);
- return NULL;
+ return NULL;
}
* Callback for sending digits from H.323 up to asterisk
*
*/
-int send_digit(unsigned call_reference, char digit)
+int send_digit(unsigned call_reference, char digit, const char *token)
{
struct oh323_pvt *p;
struct ast_frame f;
ast_log(LOG_DEBUG, "Recieved Digit: %c\n", digit);
- p = find_call(call_reference);
+
+ p = find_call(call_reference, token);
if (!p) {
ast_log(LOG_ERROR, "Private structure not found in send_digit.\n");
*
* Returns the local RTP information
*/
-struct rtp_info *create_connection(unsigned call_reference)
+struct rtp_info *create_connection(unsigned call_reference, const char * token)
{
struct oh323_pvt *p;
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
info = (struct rtp_info *) malloc(sizeof(struct rtp_info));
- p = find_call(call_reference);
+ p = find_call(call_reference, token);
if (!p) {
ast_log(LOG_ERROR, "Unable to allocate private structure, this is very bad.\n");
*
* Returns 1 on success
*/
-static int answer_call(unsigned call_reference)
+static int answer_call(unsigned call_reference, const char *token)
{
struct oh323_pvt *p = NULL;
struct ast_channel *c = NULL;
-
+
/* Find the call or allocate a private structure if call not found */
- p = find_call(call_reference);
+ p = find_call(call_reference, token);
if (!p) {
ast_log(LOG_ERROR, "Something is wrong: answer_call\n");
*
* Returns nothing
*/
-void setup_rtp_connection(unsigned call_reference, const char *remoteIp, int remotePort)
+void setup_rtp_connection(unsigned call_reference, const char *remoteIp, int remotePort, const char *token)
{
struct oh323_pvt *p = NULL;
struct sockaddr_in them;
/* Find the call or allocate a private structure if call not found */
- p = find_call(call_reference);
+ p = find_call(call_reference, token);
if (!p) {
ast_log(LOG_ERROR, "Something is wrong: rtp\n");
* Call-back function to signal asterisk that the channel has been answered
* Returns nothing
*/
-void connection_made(unsigned call_reference)
+void connection_made(unsigned call_reference, const char *token)
{
struct ast_channel *c = NULL;
struct oh323_pvt *p = NULL;
- p = find_call(call_reference);
+ p = find_call(call_reference, token);
if (!p) {
ast_log(LOG_ERROR, "Something is wrong: connection\n");
* Call-back function to signal asterisk that the channel is ringing
* Returns nothing
*/
-void chan_ringing(unsigned call_reference)
+void chan_ringing(unsigned call_reference, const char *token)
{
struct ast_channel *c = NULL;
struct oh323_pvt *p = NULL;
- p = find_call(call_reference);
+ p = find_call(call_reference, token);
if (!p) {
ast_log(LOG_ERROR, "Something is wrong: ringing\n");
struct oh323_user *user = NULL;
struct ast_rtp *rtp = NULL;
- p = find_call(cd.call_reference);
+ p = find_call(cd.call_reference, cd.call_token);
if (!p) {
return;
if (h323debug) {
cout << " -- Connection Established with \"" << connection.GetRemotePartyName() << "\"" << endl;
}
- on_connection_established(connection.GetCallReference());
+ on_connection_established(connection.GetCallReference(), (const char *)connection.GetCallToken());
}
/** OnConnectionCleared callback function is called upon the dropping of an established
if (h323debug) {
cout << " == New H.323 Connection created." << endl;
}
+
return;
}
const H323SignalPDU & /*setupPDU*/,
H323SignalPDU & /*connectPDU*/)
{
- if (!on_answer_call(GetCallReference()))
+
+
+ if (!on_answer_call(GetCallReference(), (const char *)GetCallToken()))
return H323Connection::AnswerCallDenied;
/* The call will be answered later with "AnsweringCall()" function.
if (h323debug) {
cout << " -- Ringing phone for \"" << username << "\"" << endl;
}
- on_chan_ringing(GetCallReference());
+ on_chan_ringing(GetCallReference(), (const char *)GetCallToken());
return TRUE;
}
WORD port;
/* Determine the Local (A side) IP Address and port */
- info = on_create_connection(GetCallReference());
+ info = on_create_connection(GetCallReference(), (const char *)GetCallToken());
if (!info) {
return NULL;
GetControlChannel().GetLocalAddress().GetIpAndPort(externalIpAddress, port);
externalPort = info->port;
-
+
if (h323debug) {
cout << " =*= In CreateRealTimeLogicalChannel for call " << GetCallReference() << endl;
cout << " -- externalIpAddress: " << externalIpAddress << endl;
cout << " -- SessionID: " << sessionID << endl;
cout << " -- Direction: " << dir << endl;
}
+
return new MyH323_ExternalRTPChannel(*this, capability, dir, sessionID, externalIpAddress, externalPort);
}
if (H323_ExternalRTPChannel::OnReceivedAckPDU(param)) {
H323_ExternalRTPChannel::GetRemoteAddress(remoteIpAddress, remotePort);
/* Notify Asterisk of remote RTP information */
- on_start_logical_channel(connection.GetCallReference(), (const char *)remoteIpAddress.AsString(), remotePort);
+ on_start_logical_channel(connection.GetCallReference(), (const char *)remoteIpAddress.AsString(), remotePort,
+ (const char *)connection.GetCallToken() );
return TRUE;
}
return FALSE;
/* This is a callback prototype function, called to collect
the external RTP port from Asterisk. */
-typedef rtp_info_t *(*on_connection_cb)(unsigned);
+typedef rtp_info_t *(*on_connection_cb)(unsigned, const char *);
extern on_connection_cb on_create_connection;
/* This is a callback prototype function, called upon
/* This is a callback prototype function, called when the openh323
OnStartLogicalChannel is invoked. */
-typedef void (*start_logchan_cb)(unsigned int, const char *, int);
+typedef void (*start_logchan_cb)(unsigned int, const char *, int, const char *);
extern start_logchan_cb on_start_logical_channel;
/* This is a callback prototype function, called when openh323
OnAlerting is invoked */
-typedef void (*chan_ringing_cb)(unsigned);
+typedef void (*chan_ringing_cb)(unsigned, const char *);
extern chan_ringing_cb on_chan_ringing;
/* This is a callback protoype function, called when the openh323
OnConnectionEstablished is inovked */
-typedef void (*con_established_cb)(unsigned);
+typedef void (*con_established_cb)(unsigned, const char *);
extern con_established_cb on_connection_established;
/* This is a callback prototype function, called when the openH323
typedef void (*clear_con_cb)(call_details_t);
extern clear_con_cb on_connection_cleared;
-typedef int (*answer_call_cb)(unsigned);
+typedef int (*answer_call_cb)(unsigned, const char *);
extern answer_call_cb on_answer_call;
/* debug flag */