[asterisk-commits] pcadach: branch pcadach/chan_h323-live r41044 - /team/pcadach/chan_h323-live/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Aug 25 02:24:30 MST 2006


Author: pcadach
Date: Fri Aug 25 04:24:29 2006
New Revision: 41044

URL: http://svn.digium.com/view/asterisk?rev=41044&view=rev
Log:
Use bindaddr for outgoing calls too

Modified:
    team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp
    team/pcadach/chan_h323-live/channels/h323/ast_h323.h

Modified: team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp?rev=41044&r1=41043&r2=41044&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp (original)
+++ team/pcadach/chan_h323-live/channels/h323/ast_h323.cpp Fri Aug 25 04:24:29 2006
@@ -384,6 +384,7 @@
 {
 	PString fullAddress;
 	MyH323Connection * connection;
+	H323Transport *transport = NULL;
 
 	/* Determine whether we are using a gatekeeper or not. */
 	if (GetGatekeeper()) {
@@ -396,8 +397,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;
 		}
@@ -1257,6 +1275,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 */
 MyH323_ExternalRTPChannel::MyH323_ExternalRTPChannel(MyH323Connection & connection,
 						     const H323Capability & capability,

Modified: team/pcadach/chan_h323-live/channels/h323/ast_h323.h
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/h323/ast_h323.h?rev=41044&r1=41043&r2=41044&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/h323/ast_h323.h (original)
+++ team/pcadach/chan_h323-live/channels/h323/ast_h323.h Fri Aug 25 04:24:29 2006
@@ -212,6 +212,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