1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
foo()6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_P2P_BASE_PORTPROXY_H_
12 #define WEBRTC_P2P_BASE_PORTPROXY_H_
13
14 #include "webrtc/p2p/base/portinterface.h"
15 #include "webrtc/base/sigslot.h"
16
17 namespace rtc {
18 class Network;
19 }
20
21 namespace cricket {
22
main()23 class PortProxy : public PortInterface, public sigslot::has_slots<> {
24 public:
25 PortProxy() {}
26 virtual ~PortProxy() {}
27
28 PortInterface* impl() { return impl_; }
29 void set_impl(PortInterface* port);
30
31 virtual const std::string& Type() const;
32 virtual rtc::Network* Network() const;
33
34 virtual void SetIceProtocolType(IceProtocolType protocol);
35 virtual IceProtocolType IceProtocol() const;
36
37 // Methods to set/get ICE role and tiebreaker values.
38 virtual void SetIceRole(IceRole role);
39 virtual IceRole GetIceRole() const;
40
41 virtual void SetIceTiebreaker(uint64 tiebreaker);
42 virtual uint64 IceTiebreaker() const;
43
44 virtual bool SharedSocket() const;
45
46 // Forwards call to the actual Port.
47 virtual void PrepareAddress();
48 virtual Connection* CreateConnection(const Candidate& remote_candidate,
49 CandidateOrigin origin);
50 virtual Connection* GetConnection(
51 const rtc::SocketAddress& remote_addr);
52
53 virtual int SendTo(const void* data, size_t size,
54 const rtc::SocketAddress& addr,
55 const rtc::PacketOptions& options,
56 bool payload);
57 virtual int SetOption(rtc::Socket::Option opt, int value);
58 virtual int GetOption(rtc::Socket::Option opt, int* value);
59 virtual int GetError();
60
61 virtual const std::vector<Candidate>& Candidates() const;
62
63 virtual void SendBindingResponse(StunMessage* request,
64 const rtc::SocketAddress& addr);
65 virtual void SendBindingErrorResponse(
66 StunMessage* request, const rtc::SocketAddress& addr,
67 int error_code, const std::string& reason);
68
69 virtual void EnablePortPackets();
70 virtual std::string ToString() const;
71
72 private:
73 void OnUnknownAddress(PortInterface *port,
74 const rtc::SocketAddress &addr,
75 ProtocolType proto,
76 IceMessage *stun_msg,
77 const std::string &remote_username,
78 bool port_muxed);
79 void OnRoleConflict(PortInterface* port);
80 void OnPortDestroyed(PortInterface* port);
81
82 PortInterface* impl_;
83 };
84
85 } // namespace cricket
86
87 #endif // WEBRTC_P2P_BASE_PORTPROXY_H_
88