clean up code and remove install directive in h323/ Makefile

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1924 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jeremy McNamara
2004-01-11 02:22:32 +00:00
parent 3f0477868a
commit 6b6ff098eb
4 changed files with 118 additions and 231 deletions

View File

@@ -38,22 +38,6 @@ CFLAGS += -I$(OPENH323DIR)/include -Wno-missing-prototypes -Wno-missing-declarat
all: libchanh323.a all: libchanh323.a
install: all
install -m 755 chan_h323.so $(ASTERISKDIR)
@echo " + ---- chan_h323 Installation Complete ----- +"
@echo " + +"
@echo " + chan_h323 has successfully been installed. +"
@echo " + If you would like to install the sample +"
@echo " + configuration file (overwriting existing +"
@echo " + config file), run: +"
@echo " + +"
@echo " + $(MAKE) samples +"
@echo " + +"
@echo " + ------------------------------------------ +"
@echo " "
samples: samples:
if [ -f $(ASTETCDIR)/h323.conf ]; then \ if [ -f $(ASTETCDIR)/h323.conf ]; then \
mv -f $(ASTETCDIR)/h323.conf $(ASTETCDIR)/h323.conf.old ; \ mv -f $(ASTETCDIR)/h323.conf $(ASTETCDIR)/h323.conf.old ; \

View File

@@ -26,12 +26,10 @@
* Version Info: $Id$ * Version Info: $Id$
*/ */
#include "ast_h323.h" #include "ast_h323.h"
#include "h323t38.h"
/* PWlib Required Components */ /* PWlib Required Components */
#define MAJOR_VERSION 0 #define MAJOR_VERSION 1
#define MINOR_VERSION 1 #define MINOR_VERSION 0
#define BUILD_TYPE ReleaseCode #define BUILD_TYPE ReleaseCode
#define BUILD_NUMBER 0 #define BUILD_NUMBER 0
@@ -63,13 +61,6 @@ MyProcess::MyProcess(): PProcess("The NuFone Network's", "H.323 Channel Driver f
Resume(); Resume();
} }
MyProcess::~MyProcess()
{
cout << " == PWLib proces going down." << endl;
delete endPoint;
endPoint = NULL;
}
void MyProcess::Main() void MyProcess::Main()
{ {
cout << " == Creating H.323 Endpoint" << endl; cout << " == Creating H.323 Endpoint" << endl;
@@ -289,8 +280,9 @@ H323Capabilities MyH323EndPoint::GetCapabilities(void)
BOOL MyH323EndPoint::ClearCall(const PString & token) BOOL MyH323EndPoint::ClearCall(const PString & token)
{ {
if (h323debug) if (h323debug) {
cout << " -- ClearCall: Request to clear call with token " << token << endl; cout << " -- ClearCall: Request to clear call with token " << token << endl;
}
return H323EndPoint::ClearCall(token); return H323EndPoint::ClearCall(token);
} }
@@ -317,24 +309,27 @@ BOOL MyH323EndPoint::OnConnectionForwarded(H323Connection & connection,
const PString & forwardParty, const PString & forwardParty,
const H323SignalPDU & pdu) const H323SignalPDU & pdu)
{ {
if (h323debug) if (h323debug) {
cout << " -- Call Forwarded to " << forwardParty << endl; cout << " -- Call Forwarded to " << forwardParty << endl;
return FALSE; }
return FALSE;
} }
BOOL MyH323EndPoint::ForwardConnection(H323Connection & connection, BOOL MyH323EndPoint::ForwardConnection(H323Connection & connection,
const PString & forwardParty, const PString & forwardParty,
const H323SignalPDU & pdu) const H323SignalPDU & pdu)
{ {
if (h323debug) if (h323debug) {
cout << " -- Forwarding call to " << forwardParty << endl; cout << " -- Forwarding call to " << forwardParty << endl;
return H323EndPoint::ForwardConnection(connection, forwardParty, pdu); }
return H323EndPoint::ForwardConnection(connection, forwardParty, pdu);
} }
void MyH323EndPoint::OnConnectionEstablished(H323Connection & connection, const PString & estCallToken) void MyH323EndPoint::OnConnectionEstablished(H323Connection & connection, const PString & estCallToken)
{ {
if (h323debug) if (h323debug) {
cout << " -- Connection Established with \"" << connection.GetRemotePartyName() << "\"" << endl; cout << " -- Connection Established with \"" << connection.GetRemotePartyName() << "\"" << endl;
}
on_connection_established(connection.GetCallReference()); on_connection_established(connection.GetCallReference());
} }
@@ -353,7 +348,7 @@ void MyH323EndPoint::OnConnectionCleared(H323Connection & connection, const PStr
/* Convert complex strings */ /* Convert complex strings */
char *s; char *s;
if ((s = strchr(cd.call_source_aliases, ' ')) != NULL) if ((s = strchr(cd.call_source_aliases, ' ')) != NULL)
*s = '\0'; *s = '\0';
/* Invoke the PBX application registered callback */ /* Invoke the PBX application registered callback */
@@ -434,9 +429,6 @@ void MyH323EndPoint::OnConnectionCleared(H323Connection & connection, const PStr
} }
cout << " -- Call with " << remoteName << " completed (" << connection.GetCallEndReason() << ")" << endl;
if(connection.IsEstablished()) if(connection.IsEstablished())
if (h323debug) if (h323debug)
cout << " -- Call duration " << setprecision(0) << setw(5) << (PTime() - connection.GetConnectionStartTime()) << endl; cout << " -- Call duration " << setprecision(0) << setw(5) << (PTime() - connection.GetConnectionStartTime()) << endl;
@@ -457,29 +449,28 @@ H323Connection * MyH323EndPoint::CreateConnection(unsigned callReference, void *
} }
/* MyH323Connection */ /* MyH323Connection */
MyH323Connection::MyH323Connection(MyH323EndPoint & ep, MyH323Connection::MyH323Connection(MyH323EndPoint & ep, unsigned callReference,
unsigned callReference, unsigned options)
unsigned options) : H323Connection(ep, callReference, options)
: H323Connection(ep,
callReference,
options)
{ {
remoteIpAddress = 0; // IP Address of remote endpoint remoteIpAddress = 0; // IP Address of remote endpoint
remotePort = 0; // remote endpoint Data port (control is dataPort+1) remotePort = 0; // remote endpoint Data port (control is dataPort+1)
if (h323debug) if (h323debug) {
cout << " == New H.323 Connection created." << endl; cout << " == New H.323 Connection created." << endl;
}
return; return;
} }
MyH323Connection::~MyH323Connection() MyH323Connection::~MyH323Connection()
{ {
if (h323debug) if (h323debug) {
cout << " == H.323 Connection deleted." << endl; cout << " == H.323 Connection deleted." << endl;
}
return; return;
} }
H323Connection::AnswerCallResponse MyH323Connection::OnAnswerCall(const PString & caller, H323Connection::AnswerCallResponse MyH323Connection::OnAnswerCall(const PString & caller,
const H323SignalPDU & /*setupPDU*/, const H323SignalPDU & /*setupPDU*/,
H323SignalPDU & /*connectPDU*/) H323SignalPDU & /*connectPDU*/)
{ {
@@ -491,27 +482,27 @@ H323Connection::AnswerCallResponse MyH323Connection::OnAnswerCall(const PString
BOOL MyH323Connection::OnAlerting(const H323SignalPDU & /*alertingPDU*/, const PString & username) BOOL MyH323Connection::OnAlerting(const H323SignalPDU & /*alertingPDU*/, const PString & username)
{ {
if (h323debug) if (h323debug) {
cout << " -- Ringing phone for \"" << username << "\"" << endl; cout << " -- Ringing phone for \"" << username << "\"" << endl;
}
return TRUE; return TRUE;
} }
BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU) BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
{ {
if (h323debug) if (h323debug) {
cout << " -- Received SETUP message..." << endl; cout << " -- Received SETUP message..." << endl;
}
call_details_t cd; call_details_t cd;
PString sourceE164; PString sourceE164;
PString destE164; PString destE164;
PString sourceAliases; PString sourceAliases;
PString destAliases; PString destAliases;
PString sourceIp; PString sourceIp;
PIPSocket::Address Ip; PIPSocket::Address Ip;
WORD sourcePort; WORD sourcePort;
sourceAliases = setupPDU.GetSourceAliases(); sourceAliases = setupPDU.GetSourceAliases();
destAliases = setupPDU.GetDestinationAlias(); destAliases = setupPDU.GetDestinationAlias();
@@ -524,15 +515,15 @@ BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
/* Convert complex strings */ /* Convert complex strings */
// FIXME: deal more than one source alias // FIXME: deal more than one source alias
char *s; char *s;
if ((s = strchr(sourceAliases, ' ')) != NULL) if ((s = strchr(sourceAliases, ' ')) != NULL)
*s = '\0'; *s = '\0';
if ((s = strchr(sourceAliases, '\t')) != NULL) if ((s = strchr(sourceAliases, '\t')) != NULL)
*s = '\0'; *s = '\0';
char *s1; char *s1;
if ((s1 = strchr(destAliases, ' ')) != NULL) if ((s1 = strchr(destAliases, ' ')) != NULL)
*s1 = '\0'; *s1 = '\0';
if ((s1 = strchr(destAliases, '\t')) != NULL) if ((s1 = strchr(destAliases, '\t')) != NULL)
*s1 = '\0'; *s1 = '\0';
GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort); GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort);
@@ -550,8 +541,9 @@ BOOL MyH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU)
int res = on_incoming_call(cd); int res = on_incoming_call(cd);
if (!res) { if (!res) {
if (h323debug) if (h323debug) {
cout << " -- Call Failed" << endl; cout << " -- Call Failed" << endl;
}
return FALSE; return FALSE;
} }
@@ -562,9 +554,9 @@ BOOL MyH323Connection::OnSendSignalSetup(H323SignalPDU & setupPDU)
{ {
call_details_t cd; call_details_t cd;
if (h323debug) if (h323debug) {
cout << " -- Sending SETUP message" << endl; cout << " -- Sending SETUP message" << endl;
}
sourceAliases = setupPDU.GetSourceAliases(); sourceAliases = setupPDU.GetSourceAliases();
destAliases = setupPDU.GetDestinationAlias(); destAliases = setupPDU.GetDestinationAlias();
@@ -576,15 +568,15 @@ BOOL MyH323Connection::OnSendSignalSetup(H323SignalPDU & setupPDU)
/* Convert complex strings */ /* Convert complex strings */
// FIXME: deal more than one source alias // FIXME: deal more than one source alias
char *s; char *s;
if ((s = strchr(sourceAliases, ' ')) != NULL) if ((s = strchr(sourceAliases, ' ')) != NULL)
*s = '\0'; *s = '\0';
if ((s = strchr(sourceAliases, '\t')) != NULL) if ((s = strchr(sourceAliases, '\t')) != NULL)
*s = '\0'; *s = '\0';
char *s1; char *s1;
if ((s1 = strchr(destAliases, ' ')) != NULL) if ((s1 = strchr(destAliases, ' ')) != NULL)
*s1 = '\0'; *s1 = '\0';
if ((s1 = strchr(destAliases, '\t')) != NULL) if ((s1 = strchr(destAliases, '\t')) != NULL)
*s1 = '\0'; *s1 = '\0';
cd.call_reference = GetCallReference(); cd.call_reference = GetCallReference();
cd.call_token = (const char *)GetCallToken(); cd.call_token = (const char *)GetCallToken();
@@ -596,8 +588,9 @@ BOOL MyH323Connection::OnSendSignalSetup(H323SignalPDU & setupPDU)
int res = on_outgoing_call(cd); int res = on_outgoing_call(cd);
if (!res) { if (!res) {
if (h323debug) if (h323debug) {
cout << " -- Call Failed" << endl; cout << " -- Call Failed" << endl;
}
return FALSE; return FALSE;
} }
@@ -606,49 +599,52 @@ BOOL MyH323Connection::OnSendSignalSetup(H323SignalPDU & setupPDU)
BOOL MyH323Connection::OnSendReleaseComplete(H323SignalPDU & releaseCompletePDU) BOOL MyH323Connection::OnSendReleaseComplete(H323SignalPDU & releaseCompletePDU)
{ {
if (h323debug) if (h323debug) {
cout << " -- Sending RELEASE COMPLETE" << endl; cout << " -- Sending RELEASE COMPLETE" << endl;
}
return H323Connection::OnSendReleaseComplete(releaseCompletePDU); return H323Connection::OnSendReleaseComplete(releaseCompletePDU);
} }
BOOL MyH323Connection::OnReceivedFacility(const H323SignalPDU & pdu) BOOL MyH323Connection::OnReceivedFacility(const H323SignalPDU & pdu)
{ {
if (h323debug) if (h323debug) {
cout << " -- Received Facility message... " << endl; cout << " -- Received Facility message... " << endl;
}
return H323Connection::OnReceivedFacility(pdu); return H323Connection::OnReceivedFacility(pdu);
} }
void MyH323Connection::OnReceivedReleaseComplete(const H323SignalPDU & pdu) void MyH323Connection::OnReceivedReleaseComplete(const H323SignalPDU & pdu)
{ {
if (h323debug) if (h323debug) {
cout << " -- Received RELEASE COMPLETE message..." << endl; cout << " -- Received RELEASE COMPLETE message..." << endl;
}
return H323Connection::OnReceivedReleaseComplete(pdu); return H323Connection::OnReceivedReleaseComplete(pdu);
} }
BOOL MyH323Connection::OnClosingLogicalChannel(H323Channel & channel) BOOL MyH323Connection::OnClosingLogicalChannel(H323Channel & channel)
{ {
if (h323debug) if (h323debug) {
cout << " -- Closing logical channel..." << endl; cout << " -- Closing logical channel..." << endl;
}
return H323Connection::OnClosingLogicalChannel(channel); return H323Connection::OnClosingLogicalChannel(channel);
} }
void MyH323Connection::SendUserInputTone(char tone, unsigned duration) void MyH323Connection::SendUserInputTone(char tone, unsigned duration)
{ {
if (h323debug) if (h323debug) {
cout << " -- Sending user input tone (" << tone << ") to remote" << endl; cout << " -- Sending user input tone (" << tone << ") to remote" << endl;
}
on_send_digit(GetCallReference(), tone); on_send_digit(GetCallReference(), tone);
H323Connection::SendUserInputTone(tone, duration); H323Connection::SendUserInputTone(tone, duration);
} }
void MyH323Connection::OnUserInputTone(char tone, unsigned duration, unsigned logicalChannel, unsigned rtpTimestamp) void MyH323Connection::OnUserInputTone(char tone, unsigned duration, unsigned logicalChannel, unsigned rtpTimestamp)
{ {
if (mode == H323_DTMF_INBAND) { if (mode == H323_DTMF_INBAND) {
if (h323debug) if (h323debug) {
cout << " -- Received user input tone (" << tone << ") from remote" << endl; cout << " -- Received user input tone (" << tone << ") from remote" << endl;
}
on_send_digit(GetCallReference(), tone); on_send_digit(GetCallReference(), tone);
} }
H323Connection::OnUserInputTone(tone, duration, logicalChannel, rtpTimestamp); H323Connection::OnUserInputTone(tone, duration, logicalChannel, rtpTimestamp);
@@ -657,30 +653,34 @@ void MyH323Connection::OnUserInputTone(char tone, unsigned duration, unsigned lo
void MyH323Connection::OnUserInputString(const PString &value) void MyH323Connection::OnUserInputString(const PString &value)
{ {
if (mode == H323_DTMF_RFC2833) { if (mode == H323_DTMF_RFC2833) {
if (h323debug) if (h323debug) {
cout << " -- Received user input string (" << value << ") from remote." << endl; cout << " -- Received user input string (" << value << ") from remote." << endl;
}
on_send_digit(GetCallReference(), value[0]); on_send_digit(GetCallReference(), value[0]);
} }
} }
H323Channel * MyH323Connection::CreateRealTimeLogicalChannel(const H323Capability & capability, H323Channel * MyH323Connection::CreateRealTimeLogicalChannel(const H323Capability & capability,
H323Channel::Directions dir, H323Channel::Directions dir,
unsigned sessionID, unsigned sessionID,
const H245_H2250LogicalChannelParameters * /*param*/) const H245_H2250LogicalChannelParameters * /*param*/)
{ {
struct rtp_info *info; struct rtp_info *info;
WORD port;
/* Determine the Local (A side) IP Address and port */ /* Determine the Local (A side) IP Address and port */
info = on_create_connection(GetCallReference()); info = on_create_connection(GetCallReference());
// if (bridging) { #if 0
// externalIpAddress = PIPSocket::Address(info->addr); WORD port;
// } else {
GetControlChannel().GetLocalAddress().GetIpAndPort(externalIpAddress, port);
// }
// externalIpAddress = PIPSocket::Address("192.168.1.50"); if (bridging) {
externalIpAddress = PIPSocket::Address(info->addr);
} else {
GetControlChannel().GetLocalAddress().GetIpAndPort(externalIpAddress, port);
}
externalIpAddress = PIPSocket::Address("192.168.1.50");
#endif
externalPort = info->port; externalPort = info->port;
@@ -706,11 +706,11 @@ BOOL MyH323Connection::OnStartLogicalChannel(H323Channel & channel)
} }
// adjust the count of channels we have open // adjust the count of channels we have open
channelsOpen++; channelsOpen++;
if (h323debug) if (h323debug) {
cout << " -- channelsOpen = " << channelsOpen << endl; cout << " -- channelsOpen = " << channelsOpen << endl;
}
H323_ExternalRTPChannel & external = (H323_ExternalRTPChannel &)channel; H323_ExternalRTPChannel & external = (H323_ExternalRTPChannel &)channel;
external.GetRemoteAddress(remoteIpAddress, remotePort); external.GetRemoteAddress(remoteIpAddress, remotePort);
if (h323debug) { if (h323debug) {
cout << " -- remoteIpAddress: " << remoteIpAddress << endl; cout << " -- remoteIpAddress: " << remoteIpAddress << endl;
@@ -724,34 +724,6 @@ BOOL MyH323Connection::OnStartLogicalChannel(H323Channel & channel)
return TRUE; return TRUE;
} }
#if 0
MyGatekeeperServer::MyGatekeeperServer(MyH323EndPoint & ep)
: H323GatekeeperServer(ep),
endpoint(ep)
{
}
BOOL MyGatekeeperServer::Initialise()
{
PINDEX i;
PWaitAndSignal mutex(reconfigurationMutex);
SetGatekeeperIdentifier("TESTIES");
// Interfaces to listen on
H323TransportAddressArray interfaces;
interfaces.Append(new H323TransportAddress(0.0.0.0);
AddListeners(interfaces);
// lots more to come
return TRUE;
}
#endif
/** IMPLEMENTATION OF C FUNCTIONS */ /** IMPLEMENTATION OF C FUNCTIONS */
@@ -782,31 +754,34 @@ void h323_gk_urq(void)
cout << " ERROR: [h323_gk_urq] No Endpoint, this is bad" << endl; cout << " ERROR: [h323_gk_urq] No Endpoint, this is bad" << endl;
return; return;
} }
endPoint->RemoveGatekeeper(); endPoint->RemoveGatekeeper();
} }
void h323_end_process(void) void h323_end_process(void)
{ {
endPoint->ClearAllCalls();
endPoint->RemoveListener(NULL);
delete endPoint;
delete localProcess; delete localProcess;
} }
void h323_debug(int flag, unsigned level) void h323_debug(int flag, unsigned level)
{ {
if (flag) if (flag) {
PTrace:: SetLevel(level); PTrace:: SetLevel(level);
else } else {
PTrace:: SetLevel(0); PTrace:: SetLevel(0);
}
} }
/** Installs the callback functions on behalf of the PBX application */ /** Installs the callback functions on behalf of the PBX application */
void h323_callback_register(setup_incoming_cb ifunc, void h323_callback_register(setup_incoming_cb ifunc,
setup_outbound_cb sfunc, setup_outbound_cb sfunc,
on_connection_cb confunc, on_connection_cb confunc,
start_logchan_cb lfunc, start_logchan_cb lfunc,
clear_con_cb clfunc, clear_con_cb clfunc,
con_established_cb efunc, con_established_cb efunc,
send_digit_cb dfunc) send_digit_cb dfunc)
{ {
on_incoming_call = ifunc; on_incoming_call = ifunc;
on_outgoing_call = sfunc; on_outgoing_call = sfunc;
@@ -823,8 +798,7 @@ void h323_callback_register(setup_incoming_cb ifunc,
int h323_set_capability(int cap, int dtmfMode) int h323_set_capability(int cap, int dtmfMode)
{ {
int g711Frames = 30; int g711Frames = 30;
int gsmFrames = 4; int gsmFrames = 4;
if (!h323_end_point_exist()) { if (!h323_end_point_exist()) {
cout << " ERROR: [h323_set_capablity] No Endpoint, this is bad" << endl; cout << " ERROR: [h323_set_capablity] No Endpoint, this is bad" << endl;
@@ -832,17 +806,11 @@ int h323_set_capability(int cap, int dtmfMode)
} }
mode = dtmfMode; mode = dtmfMode;
if (dtmfMode == H323_DTMF_INBAND) if (dtmfMode == H323_DTMF_INBAND) {
endPoint->SetSendUserInputMode(H323Connection::SendUserInputAsTone); endPoint->SetSendUserInputMode(H323Connection::SendUserInputAsTone);
else } else {
endPoint->SetSendUserInputMode(H323Connection::SendUserInputAsInlineRFC2833); endPoint->SetSendUserInputMode(H323Connection::SendUserInputAsInlineRFC2833);
}
/* Hardcode this for now (Someone tell me if T.38 works now
or provide me with some debug so we can make this work */
// endPoint->SetCapability(0, 0, new H323_T38Capability(H323_T38Capability::e_UDP));
if (cap & AST_FORMAT_SPEEX) { if (cap & AST_FORMAT_SPEEX) {
/* Not real sure if Asterisk acutally supports all /* Not real sure if Asterisk acutally supports all
of the various different bit rates so add them of the various different bit rates so add them
@@ -869,14 +837,13 @@ int h323_set_capability(int cap, int dtmfMode)
if (cap & AST_FORMAT_GSM) { if (cap & AST_FORMAT_GSM) {
H323_GSM0610Capability *gsmCap; H323_GSM0610Capability *gsmCap;
endPoint->SetCapability(0, 0, gsmCap = new H323_GSM0610Capability); endPoint->SetCapability(0, 0, gsmCap = new H323_GSM0610Capability);
gsmCap->SetTxFramesInPacket(gsmFrames); gsmCap->SetTxFramesInPacket(gsmFrames);
} }
if (cap & AST_FORMAT_ULAW) { if (cap & AST_FORMAT_ULAW) {
H323_G711Capability *g711uCap; H323_G711Capability *g711uCap;
endPoint->SetCapability(0, 0, g711uCap = new H323_G711Capability(H323_G711Capability::muLaw)); endPoint->SetCapability(0, 0, g711uCap = new H323_G711Capability(H323_G711Capability::muLaw));
g711uCap->SetTxFramesInPacket(g711Frames); g711uCap->SetTxFramesInPacket(g711Frames);
} }
@@ -900,8 +867,9 @@ int h323_start_listener(int listenPort, struct sockaddr_in bindaddr)
PIPSocket::Address interfaceAddress(bindaddr.sin_addr); PIPSocket::Address interfaceAddress(bindaddr.sin_addr);
if (!listenPort) if (!listenPort) {
listenPort = 1720; listenPort = 1720;
}
/** H.323 listener */ /** H.323 listener */
H323ListenerTCP *tcpListener; H323ListenerTCP *tcpListener;
@@ -914,8 +882,6 @@ int h323_start_listener(int listenPort, struct sockaddr_in bindaddr)
return 1; return 1;
} }
// cout << " == H.323 listener started on " << ((H323ListenerTCP *) tcpListener)->GetTransportAddress() << endl;
cout << " == H.323 listener started" << endl; cout << " == H.323 listener started" << endl;
return 0; return 0;
@@ -936,7 +902,6 @@ int h323_set_alias(struct oh323_alias *alias)
cout << " == Adding alias \"" << h323id << "\" to endpoint" << endl; cout << " == Adding alias \"" << h323id << "\" to endpoint" << endl;
endPoint->AddAliasName(h323id); endPoint->AddAliasName(h323id);
endPoint->RemoveAliasName(localProcess->GetUserName()); endPoint->RemoveAliasName(localProcess->GetUserName());
if (!e164.IsEmpty()) { if (!e164.IsEmpty()) {
@@ -998,7 +963,6 @@ int h323_set_gk(int gatekeeper_discover, char *gatekeeper, char *secret)
endPoint->SetGatekeeperPassword(pass); endPoint->SetGatekeeperPassword(pass);
} }
if (gatekeeper_discover) { if (gatekeeper_discover) {
/* discover the gk using multicast */ /* discover the gk using multicast */
if (endPoint->DiscoverGatekeeper(new H323TransportUDP(*endPoint))) { if (endPoint->DiscoverGatekeeper(new H323TransportUDP(*endPoint))) {
@@ -1009,20 +973,21 @@ int h323_set_gk(int gatekeeper_discover, char *gatekeeper, char *secret)
} }
} else { } else {
/* Gatekeeper operations */ /* Gatekeeper operations */
H323TransportUDP *rasChannel = new H323TransportUDP(*endPoint); if (endPoint->rasChannel) {
delete endPoint->rasChannel;
}
endPoint->rasChannel = new H323TransportUDP(*endPoint);
if (!rasChannel) { if (!endPoint->rasChannel) {
cout << " *** No RAS Channel, this is bad" << endl; cout << " *** No RAS Channel, this is bad" << endl;
return 1; return 1;
} }
if (endPoint->SetGatekeeper(gkName, rasChannel)) { if (endPoint->SetGatekeeper(gkName, endPoint->rasChannel)) {
cout << " == Using " << (endPoint->GetGatekeeper())->GetName() << " as our Gatekeeper." << endl; cout << " == Using " << (endPoint->GetGatekeeper())->GetName() << " as our Gatekeeper." << endl;
} else { } else {
cout << " *** Error registering with gatekeeper \"" << gkName << "\". " << endl; cout << " *** Error registering with gatekeeper \"" << gkName << "\". " << endl;
/* XXX Maybe we should fire a new thread to attempt to re-register later and not kill asterisk here? */ /* XXX Maybe we should fire a new thread to attempt to re-register later and not kill asterisk here? */
// delete rasChannel;
return 1; return 1;
} }
} }
@@ -1070,7 +1035,6 @@ int h323_clear_call(const char *call_token)
} }
endPoint->ClearCall(PString(call_token)); endPoint->ClearCall(PString(call_token));
return 0; return 0;
}; };
@@ -1079,7 +1043,6 @@ int h323_clear_call(const char *call_token)
int h323_answering_call(const char *token, int busy) int h323_answering_call(const char *token, int busy)
{ {
const PString currentToken(token); const PString currentToken(token);
H323Connection * connection; H323Connection * connection;
connection = endPoint->FindConnectionWithLock(currentToken); connection = endPoint->FindConnectionWithLock(currentToken);
@@ -1105,7 +1068,6 @@ int h323_answering_call(const char *token, int busy)
int h323_show_codec(int fd, int argc, char *argv[]) int h323_show_codec(int fd, int argc, char *argv[])
{ {
cout << "Allowed Codecs:\n\t" << setprecision(2) << endPoint->GetCapabilities() << endl; cout << "Allowed Codecs:\n\t" << setprecision(2) << endPoint->GetCapabilities() << endl;
return 0; return 0;
} }

View File

@@ -213,12 +213,13 @@ class MyH323EndPoint : public H323EndPoint {
PStringArray SupportedPrefixes; PStringArray SupportedPrefixes;
void SetEndpointTypeInfo( H225_EndpointType & info ) const; void SetEndpointTypeInfo( H225_EndpointType & info ) const;
void SetGateway(void); void SetGateway(void);
H323TransportUDP *rasChannel;
}; };
class MyH323Connection : public H323Connection { class MyH323Connection : public H323Connection {
PCLASSINFO(MyH323Connection, H323Connection); PCLASSINFO(MyH323Connection, H323Connection);
@@ -248,70 +249,13 @@ class MyH323Connection : public H323Connection {
PString destE164; PString destE164;
PIPSocket::Address externalIpAddress; // IP address of media server PIPSocket::Address externalIpAddress; // IP address of media server
PIPSocket::Address remoteIpAddress; // IP Address of remote endpoint PIPSocket::Address remoteIpAddress; // IP Address of remote endpoint
WORD externalPort; // local media server Data port (control is dataPort+1) WORD externalPort; // local media server Data port (control is dataPort+1)
WORD remotePort; // remote endpoint Data port (control is dataPort+1) WORD remotePort; // remote endpoint Data port (control is dataPort+1)
WORD sessionId; WORD sessionId;
BOOL bridging; // Used to help determine which IP to use BOOL bridging; // Used to help determine which IP to use
}; };
#if 0
class MyGatekeeperServer : public H323GatekeeperServer
{
PCLASSINFO(MyGatekeeperServer, H323GatekeeperServer);
public:
MyGatekeeperServer(MyH323EndPoint & ep);
// Overrides
virtual H323GatekeeperCall * CreateCall(
const OpalGloballyUniqueID & callIdentifier,
H323GatekeeperCall::Direction direction
);
virtual BOOL TranslateAliasAddressToSignalAddress(
const H225_AliasAddress & alias,
H323TransportAddress & address
);
// new functions
BOOL Initialise();
private:
class RouteMap : public PObject {
PCLASSINFO(RouteMap, PObject);
public:
RouteMap(
const PString & alias,
const PString & host
);
RouteMap(
const RouteMap & map
) : alias(map.alias), regex(map.alias), host(map.host) { }
void PrintOn(
ostream & strm
) const;
BOOL IsValid() const;
BOOL IsMatch(
const PString & alias
) const;
const H323TransportAddress & GetHost() const { return host; }
private:
PString alias;
PRegularExpression regex;
H323TransportAddress host;
};
PList<RouteMap> routes;
PMutex reconfigurationMutex;
};
#endif
/** /**
* The MyProcess is a necessary descendant PProcess class so that the H323EndPoint * The MyProcess is a necessary descendant PProcess class so that the H323EndPoint
* objected to be created from within that class. (Who owns main() problem). * objected to be created from within that class. (Who owns main() problem).
@@ -322,7 +266,6 @@ class MyProcess : public PProcess {
public: public:
MyProcess(); MyProcess();
~MyProcess();
void Main(); void Main();

View File

@@ -28,8 +28,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
static struct sockaddr_in bindaddr;
/* structure to hold the valid asterisk users */ /* structure to hold the valid asterisk users */
struct oh323_user { struct oh323_user {
char name[80]; char name[80];