3 * Copyright 2004--2011, Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef TALK_P2P_BASE_PORTPROXY_H_
29 #define TALK_P2P_BASE_PORTPROXY_H_
31 #include "talk/base/sigslot.h"
32 #include "talk/p2p/base/portinterface.h"
40 class PortProxy : public PortInterface, public sigslot::has_slots<> {
43 virtual ~PortProxy() {}
45 PortInterface* impl() { return impl_; }
46 void set_impl(PortInterface* port);
48 virtual const std::string& Type() const;
49 virtual talk_base::Network* Network() const;
51 virtual void SetIceProtocolType(IceProtocolType protocol);
52 virtual IceProtocolType IceProtocol() const;
54 // Methods to set/get ICE role and tiebreaker values.
55 virtual void SetIceRole(IceRole role);
56 virtual IceRole GetIceRole() const;
58 virtual void SetIceTiebreaker(uint64 tiebreaker);
59 virtual uint64 IceTiebreaker() const;
61 virtual bool SharedSocket() const;
63 // Forwards call to the actual Port.
64 virtual void PrepareAddress();
65 virtual Connection* CreateConnection(const Candidate& remote_candidate,
66 CandidateOrigin origin);
67 virtual Connection* GetConnection(
68 const talk_base::SocketAddress& remote_addr);
70 virtual int SendTo(const void* data, size_t size,
71 const talk_base::SocketAddress& addr,
72 const talk_base::PacketOptions& options,
74 virtual int SetOption(talk_base::Socket::Option opt, int value);
75 virtual int GetOption(talk_base::Socket::Option opt, int* value);
76 virtual int GetError();
78 virtual const std::vector<Candidate>& Candidates() const;
80 virtual void SendBindingResponse(StunMessage* request,
81 const talk_base::SocketAddress& addr);
82 virtual void SendBindingErrorResponse(
83 StunMessage* request, const talk_base::SocketAddress& addr,
84 int error_code, const std::string& reason);
86 virtual void EnablePortPackets();
87 virtual std::string ToString() const;
90 void OnUnknownAddress(PortInterface *port,
91 const talk_base::SocketAddress &addr,
94 const std::string &remote_username,
96 void OnRoleConflict(PortInterface* port);
97 void OnPortDestroyed(PortInterface* port);
102 } // namespace cricket
104 #endif // TALK_P2P_BASE_PORTPROXY_H_