Note: We no longer publish the latest version of our code here. We primarily use a kumc-bmi github organization. The heron ETL repository, in particular, is not public. Peers in the informatics community should see MultiSiteDev for details on requesting access.

source: webrtc/talk/p2p/base/portproxy.cc @ 0:4bda6873e34c

pub_scrub_3792 tip
Last change on this file since 0:4bda6873e34c was 0:4bda6873e34c, checked in by Michael Prittie <mprittie@…>, 6 years ago

Scrubbed password for publication.

File size: 5.3 KB
Line 
1/*
2 * libjingle
3 * Copyright 2004--2011, Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
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.
15 *
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.
26 */
27
28#include "talk/p2p/base/portproxy.h"
29
30namespace cricket {
31
32void PortProxy::set_impl(PortInterface* port) {
33  impl_ = port;
34  impl_->SignalUnknownAddress.connect(
35      this, &PortProxy::OnUnknownAddress);
36  impl_->SignalDestroyed.connect(this, &PortProxy::OnPortDestroyed);
37  impl_->SignalRoleConflict.connect(this, &PortProxy::OnRoleConflict);
38}
39
40const std::string& PortProxy::Type() const {
41  ASSERT(impl_ != NULL);
42  return impl_->Type();
43}
44
45talk_base::Network* PortProxy::Network() const {
46  ASSERT(impl_ != NULL);
47  return impl_->Network();
48}
49
50void PortProxy::SetIceProtocolType(IceProtocolType protocol) {
51  ASSERT(impl_ != NULL);
52  impl_->SetIceProtocolType(protocol);
53}
54
55IceProtocolType PortProxy::IceProtocol() const {
56  ASSERT(impl_ != NULL);
57  return impl_->IceProtocol();
58}
59
60// Methods to set/get ICE role and tiebreaker values.
61void PortProxy::SetIceRole(IceRole role) {
62  ASSERT(impl_ != NULL);
63  impl_->SetIceRole(role);
64}
65
66IceRole PortProxy::GetIceRole() const {
67  ASSERT(impl_ != NULL);
68  return impl_->GetIceRole();
69}
70
71void PortProxy::SetIceTiebreaker(uint64 tiebreaker) {
72  ASSERT(impl_ != NULL);
73  impl_->SetIceTiebreaker(tiebreaker);
74}
75
76uint64 PortProxy::IceTiebreaker() const {
77  ASSERT(impl_ != NULL);
78  return impl_->IceTiebreaker();
79}
80
81bool PortProxy::SharedSocket() const {
82  ASSERT(impl_ != NULL);
83  return impl_->SharedSocket();
84}
85
86void PortProxy::PrepareAddress() {
87  ASSERT(impl_ != NULL);
88  impl_->PrepareAddress();
89}
90
91Connection* PortProxy::CreateConnection(const Candidate& remote_candidate,
92                                        CandidateOrigin origin) {
93  ASSERT(impl_ != NULL);
94  return impl_->CreateConnection(remote_candidate, origin);
95}
96
97int PortProxy::SendTo(const void* data,
98                      size_t size,
99                      const talk_base::SocketAddress& addr,
100                      talk_base::DiffServCodePoint dscp,
101                      bool payload) {
102  ASSERT(impl_ != NULL);
103  return impl_->SendTo(data, size, addr, dscp, payload);
104}
105
106int PortProxy::SetOption(talk_base::Socket::Option opt,
107                         int value) {
108  ASSERT(impl_ != NULL);
109  return impl_->SetOption(opt, value);
110}
111
112int PortProxy::GetOption(talk_base::Socket::Option opt,
113                         int* value) {
114  ASSERT(impl_ != NULL);
115  return impl_->GetOption(opt, value);
116}
117
118int PortProxy::GetError() {
119  ASSERT(impl_ != NULL);
120  return impl_->GetError();
121}
122
123const std::vector<Candidate>& PortProxy::Candidates() const {
124  ASSERT(impl_ != NULL);
125  return impl_->Candidates();
126}
127
128void PortProxy::SendBindingResponse(
129    StunMessage* request, const talk_base::SocketAddress& addr) {
130  ASSERT(impl_ != NULL);
131  impl_->SendBindingResponse(request, addr);
132}
133
134Connection* PortProxy::GetConnection(
135    const talk_base::SocketAddress& remote_addr) {
136  ASSERT(impl_ != NULL);
137  return impl_->GetConnection(remote_addr);
138}
139
140void PortProxy::SendBindingErrorResponse(
141    StunMessage* request, const talk_base::SocketAddress& addr,
142    int error_code, const std::string& reason) {
143  ASSERT(impl_ != NULL);
144  impl_->SendBindingErrorResponse(request, addr, error_code, reason);
145}
146
147void PortProxy::EnablePortPackets() {
148  ASSERT(impl_ != NULL);
149  impl_->EnablePortPackets();
150}
151
152std::string PortProxy::ToString() const {
153  ASSERT(impl_ != NULL);
154  return impl_->ToString();
155}
156
157void PortProxy::OnUnknownAddress(
158    PortInterface *port,
159    const talk_base::SocketAddress &addr,
160    ProtocolType proto,
161    IceMessage *stun_msg,
162    const std::string &remote_username,
163    bool port_muxed) {
164  ASSERT(port == impl_);
165  ASSERT(!port_muxed);
166  SignalUnknownAddress(this, addr, proto, stun_msg, remote_username, true);
167}
168
169void PortProxy::OnRoleConflict(PortInterface* port) {
170  ASSERT(port == impl_);
171  SignalRoleConflict(this);
172}
173
174void PortProxy::OnPortDestroyed(PortInterface* port) {
175  ASSERT(port == impl_);
176  // |port| will be destroyed in PortAllocatorSessionMuxer.
177  SignalDestroyed(this);
178}
179
180}  // namespace cricket
Note: See TracBrowser for help on using the repository browser.