10e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org/* 20e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * libjingle 30e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Copyright 2004--2005, Google Inc. 40e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 50e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * Redistribution and use in source and binary forms, with or without 60e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * modification, are permitted provided that the following conditions are met: 70e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 80e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 1. Redistributions of source code must retain the above copyright notice, 90e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * this list of conditions and the following disclaimer. 100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 2. Redistributions in binary form must reproduce the above copyright notice, 110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * this list of conditions and the following disclaimer in the documentation 120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * and/or other materials provided with the distribution. 130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 3. The name of the author may not be used to endorse or promote products 140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * derived from this software without specific prior written permission. 150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * 160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 180e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 190e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 200e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 210e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org */ 270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#ifndef TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_ 290e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#define TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_ 300e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 310e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include <string> 320e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/p2p/base/transport.h" 330e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#include "talk/p2p/base/transportchannel.h" 340e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 350e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgnamespace buzz { class XmlElement; } 360e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 370e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgnamespace cricket { 380e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 390e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass Candidate; 400e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 410e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// Base class for real implementations of TransportChannel. This includes some 420e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// methods called only by Transport, which do not need to be exposed to the 430e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org// client. 440e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.orgclass TransportChannelImpl : public TransportChannel { 450e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org public: 460e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org explicit TransportChannelImpl(const std::string& content_name, int component) 470e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org : TransportChannel(content_name, component) {} 480e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 490e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Returns the transport that created this channel. 500e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual Transport* GetTransport() = 0; 510e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 520e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // For ICE channels. 53a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org virtual IceRole GetIceRole() const = 0; 54e560834da4ee5a5f38a96a8cb9290c5ce1096989mallinath@webrtc.org virtual void SetIceRole(IceRole role) = 0; 55e560834da4ee5a5f38a96a8cb9290c5ce1096989mallinath@webrtc.org virtual void SetIceTiebreaker(uint64 tiebreaker) = 0; 56f5e5b3a9ce372d0e3cc594bf0036dda64a57d81dmallinath@webrtc.org virtual size_t GetConnectionCount() const = 0; 570e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // To toggle G-ICE/ICE. 58b881d27f23e9a8f52dc6a60fc66ebd75f9c2f15cmallinath@webrtc.org virtual bool GetIceProtocolType(IceProtocolType* type) const = 0; 590e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void SetIceProtocolType(IceProtocolType type) = 0; 600e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // SetIceCredentials only need to be implemented by the ICE 610e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // transport channels. Non-ICE transport channels can just ignore. 620e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // The ufrag and pwd should be set before the Connect() is called. 630e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void SetIceCredentials(const std::string& ice_ufrag, 640e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& ice_pwd) = 0; 650e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // SetRemoteIceCredentials only need to be implemented by the ICE 660e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // transport channels. Non-ICE transport channels can just ignore. 670e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void SetRemoteIceCredentials(const std::string& ice_ufrag, 680e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const std::string& ice_pwd) = 0; 690e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 700e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // SetRemoteIceMode must be implemented only by the ICE transport channels. 710e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void SetRemoteIceMode(IceMode mode) = 0; 720e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 730e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Begins the process of attempting to make a connection to the other client. 740e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void Connect() = 0; 750e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 760e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Resets this channel back to the initial state (i.e., not connecting). 770e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void Reset() = 0; 780e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 790e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Allows an individual channel to request signaling and be notified when it 800e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // is ready. This is useful if the individual named channels have need to 810e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // send their own transport-info stanzas. 820e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org sigslot::signal1<TransportChannelImpl*> SignalRequestSignaling; 830e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnSignalingReady() = 0; 840e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 850e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Handles sending and receiving of candidates. The Transport 860e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // receives the candidates and may forward them to the relevant 870e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // channel. 880e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // 890e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Note: Since candidates are delivered asynchronously to the 900e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // channel, they cannot return an error if the message is invalid. 910e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // It is assumed that the Transport will have checked validity 920e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // before forwarding. 930e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org sigslot::signal2<TransportChannelImpl*, 940e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const Candidate&> SignalCandidateReady; 950e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual void OnCandidate(const Candidate& candidate) = 0; 960e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 970e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // DTLS methods 9862fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org // Set DTLS local identity. The identity object is not copied, but the caller 9962fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org // retains ownership and must delete it after this TransportChannelImpl is 10062fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org // destroyed. 10162fe97f10a7a3200c9724851f6a18537ed270cddwu@webrtc.org // TODO(bemasc): Fix the ownership semantics of this method. 1022a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org virtual bool SetLocalIdentity(rtc::SSLIdentity* identity) = 0; 1030e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1040e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Set DTLS Remote fingerprint. Must be after local identity set. 1050e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org virtual bool SetRemoteFingerprint(const std::string& digest_alg, 1060e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org const uint8* digest, 107a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org size_t digest_len) = 0; 108a487db2aeda23ade81f0b2e5fd4d50f874d06a9csergeyu@chromium.org 1092a86ce22ccc387dfa6f8a98ce3eba5c1e6f9e538buildbot@webrtc.org virtual bool SetSslRole(rtc::SSLRole role) = 0; 1100e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1110e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // TransportChannel is forwarding this signal from PortAllocatorSession. 1120e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org sigslot::signal1<TransportChannelImpl*> SignalCandidatesAllocationDone; 1130e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1140e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // Invoked when there is conflict in the ICE role between local and remote 1150e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org // agents. 1160e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org sigslot::signal1<TransportChannelImpl*> SignalRoleConflict; 1170e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 118f5e5b3a9ce372d0e3cc594bf0036dda64a57d81dmallinath@webrtc.org // Emitted whenever the number of connections available to the transport 119f5e5b3a9ce372d0e3cc594bf0036dda64a57d81dmallinath@webrtc.org // channel decreases. 120f5e5b3a9ce372d0e3cc594bf0036dda64a57d81dmallinath@webrtc.org sigslot::signal1<TransportChannelImpl*> SignalConnectionRemoved; 121f5e5b3a9ce372d0e3cc594bf0036dda64a57d81dmallinath@webrtc.org 1220e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org private: 1230e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org DISALLOW_EVIL_CONSTRUCTORS(TransportChannelImpl); 1240e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org}; 1250e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1260e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org} // namespace cricket 1270e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org 1280e118e7129884fbea117e78d6f2068139a414dbhenrike@webrtc.org#endif // TALK_P2P_BASE_TRANSPORTCHANNELIMPL_H_ 129