[asterisk-commits] pcadach: branch pcadach/chan_h323_exts r41047 - /team/pcadach/chan_h323_exts/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Aug 25 03:26:29 MST 2006


Author: pcadach
Date: Fri Aug 25 05:26:29 2006
New Revision: 41047

URL: http://svn.digium.com/view/asterisk?rev=41047&view=rev
Log:
Use bindaddr for outgoing calls too (backport from chan_h323-live)

Modified:
    team/pcadach/chan_h323_exts/channels/h323/ast_h323.cpp
    team/pcadach/chan_h323_exts/channels/h323/ast_h323.h

Modified: team/pcadach/chan_h323_exts/channels/h323/ast_h323.cpp
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323_exts/channels/h323/ast_h323.cpp?rev=41047&r1=41046&r2=41047&view=diff
==============================================================================
--- team/pcadach/chan_h323_exts/channels/h323/ast_h323.cpp (original)
+++ team/pcadach/chan_h323_exts/channels/h323/ast_h323.cpp Fri Aug 25 05:26:29 2006
@@ -433,6 +433,7 @@
 {
 	PString fullAddress;
 	MyH323Connection * connection;
+	H323Transport *transport = NULL;
 
 	/* Determine whether we are using a gatekeeper or not. */
 	if (GetGatekeeper()) {
@@ -445,8 +446,25 @@
 		if (h323debug) {
 			cout << " -- Making call to " << fullAddress << " without gatekeeper." << endl;
 		}
-	}
-	if (!(connection = (MyH323Connection *)H323EndPoint::MakeCallLocked(fullAddress, token, opts))) {
+		/* Use bindaddr for outgoing calls too if we don't use gatekeeper */
+		if (listeners.GetSize() > 0) {
+			H323TransportAddress taddr = listeners[0].GetTransportAddress();
+			PIPSocket::Address addr;
+			WORD port;
+			if (taddr.GetIpAndPort(addr, port)) {
+				if (h323debug)
+					cout << "Using " << addr << " for outbound call" << endl;
+				/* Create own transport for specific addresses only */
+				if (addr) {
+					transport = new H323TransportTCP(*this, addr);
+					if (!transport)
+						cout << "Unable to create transport for outgoing call" << endl;
+				}
+			} else
+				cout << "Unable to get address and port" << endl;
+		}
+	}
+	if (!(connection = (MyH323Connection *)H323EndPoint::MakeCallLocked(fullAddress, token, opts, transport))) {
 		if (h323debug) {
 			cout << "Error making call to \"" << fullAddress << '"' << endl;
 		}
@@ -1452,6 +1470,48 @@
 }
 
 
+BOOL MyH323Connection::StartControlChannel(const H225_TransportAddress & h245Address)
+{
+	// Check that it is an IP address, all we support at the moment
+	if (h245Address.GetTag() != H225_TransportAddress::e_ipAddress
+#if P_HAS_IPV6
+		&& h245Address.GetTag() != H225_TransportAddress::e_ip6Address
+#endif
+	) {
+		PTRACE(1, "H225\tConnect of H245 failed: Unsupported transport");
+		return FALSE;
+	}
+
+	// Already have the H245 channel up.
+	if (controlChannel != NULL)
+		return TRUE;
+
+	PIPSocket::Address addr;
+	WORD port;
+	GetSignallingChannel()->GetLocalAddress().GetIpAndPort(addr, port);
+	if (addr) {
+		if (h323debug)
+			cout << "Using " << addr << " for outbound H.245 transport" << endl;
+		controlChannel = new H323TransportTCP(endpoint, addr);
+	} else
+		controlChannel = new H323TransportTCP(endpoint);
+	if (!controlChannel->SetRemoteAddress(h245Address)) {
+		PTRACE(1, "H225\tCould not extract H245 address");
+		delete controlChannel;
+		controlChannel = NULL;
+		return FALSE;
+	}
+	if (!controlChannel->Connect()) {
+		PTRACE(1, "H225\tConnect of H245 failed: " << controlChannel->GetErrorText());
+		delete controlChannel;
+		controlChannel = NULL;
+		return FALSE;
+	}
+
+	controlChannel->StartControlChannel(*this);
+	return TRUE;
+}
+
 /* MyH323_ExternalRTPChannel */
 BOOL MyH323_ExternalRTPChannel::DetermineLocalRTPAddress(H323Connection & connection)
 {

Modified: team/pcadach/chan_h323_exts/channels/h323/ast_h323.h
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323_exts/channels/h323/ast_h323.h?rev=41047&r1=41046&r2=41047&view=diff
==============================================================================
--- team/pcadach/chan_h323_exts/channels/h323/ast_h323.h (original)
+++ team/pcadach/chan_h323_exts/channels/h323/ast_h323.h Fri Aug 25 05:26:29 2006
@@ -220,6 +220,7 @@
 	BOOL OnReceivedCapabilitySet(const H323Capabilities &, const H245_MultiplexCapability *,
 				     H245_TerminalCapabilitySetReject &);
 	void SetCause(int _cause) { cause = _cause; };
+	virtual BOOL StartControlChannel(const H225_TransportAddress & h245Address);
 
 	PString sourceAliases;
 	PString destAliases;



More information about the asterisk-commits mailing list