OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 MSG_ID_CONNECT, | 57 MSG_ID_CONNECT, |
58 MSG_ID_DISCONNECT, | 58 MSG_ID_DISCONNECT, |
59 }; | 59 }; |
60 | 60 |
61 // Packets are passed between sockets as messages. We copy the data just like | 61 // Packets are passed between sockets as messages. We copy the data just like |
62 // the kernel does. | 62 // the kernel does. |
63 class Packet : public MessageData { | 63 class Packet : public MessageData { |
64 public: | 64 public: |
65 Packet(const char* data, size_t size, const SocketAddress& from) | 65 Packet(const char* data, size_t size, const SocketAddress& from) |
66 : size_(size), consumed_(0), from_(from) { | 66 : size_(size), consumed_(0), from_(from) { |
67 RTC_DCHECK(NULL != data); | 67 RTC_DCHECK(nullptr != data); |
68 data_ = new char[size_]; | 68 data_ = new char[size_]; |
69 memcpy(data_, data, size_); | 69 memcpy(data_, data, size_); |
70 } | 70 } |
71 | 71 |
72 ~Packet() override { | 72 ~Packet() override { |
73 delete[] data_; | 73 delete[] data_; |
74 } | 74 } |
75 | 75 |
76 const char* data() const { return data_ + consumed_; } | 76 const char* data() const { return data_ + consumed_; } |
77 size_t size() const { return size_ - consumed_; } | 77 size_t size() const { return size_ - consumed_; } |
(...skipping 18 matching lines...) Expand all Loading... |
96 | 96 |
97 VirtualSocket::VirtualSocket(VirtualSocketServer* server, | 97 VirtualSocket::VirtualSocket(VirtualSocketServer* server, |
98 int family, | 98 int family, |
99 int type, | 99 int type, |
100 bool async) | 100 bool async) |
101 : server_(server), | 101 : server_(server), |
102 type_(type), | 102 type_(type), |
103 async_(async), | 103 async_(async), |
104 state_(CS_CLOSED), | 104 state_(CS_CLOSED), |
105 error_(0), | 105 error_(0), |
106 listen_queue_(NULL), | 106 listen_queue_(nullptr), |
107 network_size_(0), | 107 network_size_(0), |
108 recv_buffer_size_(0), | 108 recv_buffer_size_(0), |
109 bound_(false), | 109 bound_(false), |
110 was_any_(false) { | 110 was_any_(false) { |
111 RTC_DCHECK((type_ == SOCK_DGRAM) || (type_ == SOCK_STREAM)); | 111 RTC_DCHECK((type_ == SOCK_DGRAM) || (type_ == SOCK_STREAM)); |
112 RTC_DCHECK(async_ || | 112 RTC_DCHECK(async_ || |
113 (type_ != SOCK_STREAM)); // We only support async streams | 113 (type_ != SOCK_STREAM)); // We only support async streams |
114 server->SignalReadyToSend.connect(this, | 114 server->SignalReadyToSend.connect(this, |
115 &VirtualSocket::OnSocketServerReadyToSend); | 115 &VirtualSocket::OnSocketServerReadyToSend); |
116 } | 116 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // Cancel pending sockets | 177 // Cancel pending sockets |
178 if (listen_queue_) { | 178 if (listen_queue_) { |
179 while (!listen_queue_->empty()) { | 179 while (!listen_queue_->empty()) { |
180 SocketAddress addr = listen_queue_->front(); | 180 SocketAddress addr = listen_queue_->front(); |
181 | 181 |
182 // Disconnect listening socket. | 182 // Disconnect listening socket. |
183 server_->Disconnect(server_->LookupBinding(addr)); | 183 server_->Disconnect(server_->LookupBinding(addr)); |
184 listen_queue_->pop_front(); | 184 listen_queue_->pop_front(); |
185 } | 185 } |
186 delete listen_queue_; | 186 delete listen_queue_; |
187 listen_queue_ = NULL; | 187 listen_queue_ = nullptr; |
188 } | 188 } |
189 // Disconnect stream sockets | 189 // Disconnect stream sockets |
190 if (CS_CONNECTED == state_) { | 190 if (CS_CONNECTED == state_) { |
191 // Disconnect remote socket, check if it is a child of a server socket. | 191 // Disconnect remote socket, check if it is a child of a server socket. |
192 VirtualSocket* socket = | 192 VirtualSocket* socket = |
193 server_->LookupConnection(local_addr_, remote_addr_); | 193 server_->LookupConnection(local_addr_, remote_addr_); |
194 if (!socket) { | 194 if (!socket) { |
195 // Not a server socket child, then see if it is bound. | 195 // Not a server socket child, then see if it is bound. |
196 // TODO(tbd): If this is indeed a server socket that has no | 196 // TODO(tbd): If this is indeed a server socket that has no |
197 // children this will cause the server socket to be | 197 // children this will cause the server socket to be |
198 // closed. This might lead to unexpected results, how to fix this? | 198 // closed. This might lead to unexpected results, how to fix this? |
199 socket = server_->LookupBinding(remote_addr_); | 199 socket = server_->LookupBinding(remote_addr_); |
200 } | 200 } |
201 server_->Disconnect(socket); | 201 server_->Disconnect(socket); |
202 | 202 |
203 // Remove mapping for both directions. | 203 // Remove mapping for both directions. |
204 server_->RemoveConnection(remote_addr_, local_addr_); | 204 server_->RemoveConnection(remote_addr_, local_addr_); |
205 server_->RemoveConnection(local_addr_, remote_addr_); | 205 server_->RemoveConnection(local_addr_, remote_addr_); |
206 } | 206 } |
207 // Cancel potential connects | 207 // Cancel potential connects |
208 MessageList msgs; | 208 MessageList msgs; |
209 if (server_->msg_queue_) { | 209 if (server_->msg_queue_) { |
210 server_->msg_queue_->Clear(this, MSG_ID_CONNECT, &msgs); | 210 server_->msg_queue_->Clear(this, MSG_ID_CONNECT, &msgs); |
211 } | 211 } |
212 for (MessageList::iterator it = msgs.begin(); it != msgs.end(); ++it) { | 212 for (MessageList::iterator it = msgs.begin(); it != msgs.end(); ++it) { |
213 RTC_DCHECK(NULL != it->pdata); | 213 RTC_DCHECK(nullptr != it->pdata); |
214 MessageAddress* data = static_cast<MessageAddress*>(it->pdata); | 214 MessageAddress* data = static_cast<MessageAddress*>(it->pdata); |
215 | 215 |
216 // Lookup remote side. | 216 // Lookup remote side. |
217 VirtualSocket* socket = | 217 VirtualSocket* socket = |
218 server_->LookupConnection(local_addr_, data->addr); | 218 server_->LookupConnection(local_addr_, data->addr); |
219 if (socket) { | 219 if (socket) { |
220 // Server socket, remote side is a socket retreived by | 220 // Server socket, remote side is a socket retreived by |
221 // accept. Accepted sockets are not bound so we will not | 221 // accept. Accepted sockets are not bound so we will not |
222 // find it by looking in the bindings table. | 222 // find it by looking in the bindings table. |
223 server_->Disconnect(socket); | 223 server_->Disconnect(socket); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } else { | 301 } else { |
302 recv_buffer_.pop_front(); | 302 recv_buffer_.pop_front(); |
303 delete packet; | 303 delete packet; |
304 } | 304 } |
305 | 305 |
306 if (SOCK_STREAM == type_) { | 306 if (SOCK_STREAM == type_) { |
307 bool was_full = (recv_buffer_size_ == server_->recv_buffer_capacity_); | 307 bool was_full = (recv_buffer_size_ == server_->recv_buffer_capacity_); |
308 recv_buffer_size_ -= data_read; | 308 recv_buffer_size_ -= data_read; |
309 if (was_full) { | 309 if (was_full) { |
310 VirtualSocket* sender = server_->LookupBinding(remote_addr_); | 310 VirtualSocket* sender = server_->LookupBinding(remote_addr_); |
311 RTC_DCHECK(NULL != sender); | 311 RTC_DCHECK(nullptr != sender); |
312 server_->SendTcp(sender); | 312 server_->SendTcp(sender); |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 return static_cast<int>(data_read); | 316 return static_cast<int>(data_read); |
317 } | 317 } |
318 | 318 |
319 int VirtualSocket::Listen(int backlog) { | 319 int VirtualSocket::Listen(int backlog) { |
320 RTC_DCHECK(SOCK_STREAM == type_); | 320 RTC_DCHECK(SOCK_STREAM == type_); |
321 RTC_DCHECK(CS_CLOSED == state_); | 321 RTC_DCHECK(CS_CLOSED == state_); |
322 if (local_addr_.IsNil()) { | 322 if (local_addr_.IsNil()) { |
323 error_ = EINVAL; | 323 error_ = EINVAL; |
324 return -1; | 324 return -1; |
325 } | 325 } |
326 RTC_DCHECK(NULL == listen_queue_); | 326 RTC_DCHECK(nullptr == listen_queue_); |
327 listen_queue_ = new ListenQueue; | 327 listen_queue_ = new ListenQueue; |
328 state_ = CS_CONNECTING; | 328 state_ = CS_CONNECTING; |
329 return 0; | 329 return 0; |
330 } | 330 } |
331 | 331 |
332 VirtualSocket* VirtualSocket::Accept(SocketAddress* paddr) { | 332 VirtualSocket* VirtualSocket::Accept(SocketAddress* paddr) { |
333 if (NULL == listen_queue_) { | 333 if (nullptr == listen_queue_) { |
334 error_ = EINVAL; | 334 error_ = EINVAL; |
335 return NULL; | 335 return nullptr; |
336 } | 336 } |
337 while (!listen_queue_->empty()) { | 337 while (!listen_queue_->empty()) { |
338 VirtualSocket* socket = new VirtualSocket(server_, AF_INET, type_, async_); | 338 VirtualSocket* socket = new VirtualSocket(server_, AF_INET, type_, async_); |
339 | 339 |
340 // Set the new local address to the same as this server socket. | 340 // Set the new local address to the same as this server socket. |
341 socket->SetLocalAddress(local_addr_); | 341 socket->SetLocalAddress(local_addr_); |
342 // Sockets made from a socket that 'was Any' need to inherit that. | 342 // Sockets made from a socket that 'was Any' need to inherit that. |
343 socket->set_was_any(was_any_); | 343 socket->set_was_any(was_any_); |
344 SocketAddress remote_addr(listen_queue_->front()); | 344 SocketAddress remote_addr(listen_queue_->front()); |
345 int result = socket->InitiateConnect(remote_addr, false); | 345 int result = socket->InitiateConnect(remote_addr, false); |
346 listen_queue_->pop_front(); | 346 listen_queue_->pop_front(); |
347 if (result != 0) { | 347 if (result != 0) { |
348 delete socket; | 348 delete socket; |
349 continue; | 349 continue; |
350 } | 350 } |
351 socket->CompleteConnect(remote_addr, false); | 351 socket->CompleteConnect(remote_addr, false); |
352 if (paddr) { | 352 if (paddr) { |
353 *paddr = remote_addr; | 353 *paddr = remote_addr; |
354 } | 354 } |
355 return socket; | 355 return socket; |
356 } | 356 } |
357 error_ = EWOULDBLOCK; | 357 error_ = EWOULDBLOCK; |
358 return NULL; | 358 return nullptr; |
359 } | 359 } |
360 | 360 |
361 int VirtualSocket::GetError() const { | 361 int VirtualSocket::GetError() const { |
362 return error_; | 362 return error_; |
363 } | 363 } |
364 | 364 |
365 void VirtualSocket::SetError(int error) { | 365 void VirtualSocket::SetError(int error) { |
366 error_ = error; | 366 error_ = error; |
367 } | 367 } |
368 | 368 |
(...skipping 17 matching lines...) Expand all Loading... |
386 | 386 |
387 int VirtualSocket::EstimateMTU(uint16_t* mtu) { | 387 int VirtualSocket::EstimateMTU(uint16_t* mtu) { |
388 if (CS_CONNECTED != state_) | 388 if (CS_CONNECTED != state_) |
389 return ENOTCONN; | 389 return ENOTCONN; |
390 else | 390 else |
391 return 65536; | 391 return 65536; |
392 } | 392 } |
393 | 393 |
394 void VirtualSocket::OnMessage(Message* pmsg) { | 394 void VirtualSocket::OnMessage(Message* pmsg) { |
395 if (pmsg->message_id == MSG_ID_PACKET) { | 395 if (pmsg->message_id == MSG_ID_PACKET) { |
396 RTC_DCHECK(NULL != pmsg->pdata); | 396 RTC_DCHECK(nullptr != pmsg->pdata); |
397 Packet* packet = static_cast<Packet*>(pmsg->pdata); | 397 Packet* packet = static_cast<Packet*>(pmsg->pdata); |
398 | 398 |
399 recv_buffer_.push_back(packet); | 399 recv_buffer_.push_back(packet); |
400 | 400 |
401 if (async_) { | 401 if (async_) { |
402 SignalReadEvent(this); | 402 SignalReadEvent(this); |
403 } | 403 } |
404 } else if (pmsg->message_id == MSG_ID_CONNECT) { | 404 } else if (pmsg->message_id == MSG_ID_CONNECT) { |
405 RTC_DCHECK(NULL != pmsg->pdata); | 405 RTC_DCHECK(nullptr != pmsg->pdata); |
406 MessageAddress* data = static_cast<MessageAddress*>(pmsg->pdata); | 406 MessageAddress* data = static_cast<MessageAddress*>(pmsg->pdata); |
407 if (listen_queue_ != NULL) { | 407 if (listen_queue_ != nullptr) { |
408 listen_queue_->push_back(data->addr); | 408 listen_queue_->push_back(data->addr); |
409 if (async_) { | 409 if (async_) { |
410 SignalReadEvent(this); | 410 SignalReadEvent(this); |
411 } | 411 } |
412 } else if ((SOCK_STREAM == type_) && (CS_CONNECTING == state_)) { | 412 } else if ((SOCK_STREAM == type_) && (CS_CONNECTING == state_)) { |
413 CompleteConnect(data->addr, true); | 413 CompleteConnect(data->addr, true); |
414 } else { | 414 } else { |
415 LOG(LS_VERBOSE) << "Socket at " << local_addr_ << " is not listening"; | 415 LOG(LS_VERBOSE) << "Socket at " << local_addr_ << " is not listening"; |
416 server_->Disconnect(server_->LookupBinding(data->addr)); | 416 server_->Disconnect(server_->LookupBinding(data->addr)); |
417 } | 417 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 RTC_DCHECK(type_ == SOCK_STREAM); | 518 RTC_DCHECK(type_ == SOCK_STREAM); |
519 // This will attempt to empty the full send buffer, and will fire | 519 // This will attempt to empty the full send buffer, and will fire |
520 // SignalWriteEvent if successful. | 520 // SignalWriteEvent if successful. |
521 server_->SendTcp(this); | 521 server_->SendTcp(this); |
522 } | 522 } |
523 } | 523 } |
524 | 524 |
525 VirtualSocketServer::VirtualSocketServer(SocketServer* ss) | 525 VirtualSocketServer::VirtualSocketServer(SocketServer* ss) |
526 : server_(ss), | 526 : server_(ss), |
527 server_owned_(false), | 527 server_owned_(false), |
528 msg_queue_(NULL), | 528 msg_queue_(nullptr), |
529 stop_on_idle_(false), | 529 stop_on_idle_(false), |
530 next_ipv4_(kInitialNextIPv4), | 530 next_ipv4_(kInitialNextIPv4), |
531 next_ipv6_(kInitialNextIPv6), | 531 next_ipv6_(kInitialNextIPv6), |
532 next_port_(kFirstEphemeralPort), | 532 next_port_(kFirstEphemeralPort), |
533 bindings_(new AddressMap()), | 533 bindings_(new AddressMap()), |
534 connections_(new ConnectionMap()), | 534 connections_(new ConnectionMap()), |
535 bandwidth_(0), | 535 bandwidth_(0), |
536 network_capacity_(kDefaultNetworkCapacity), | 536 network_capacity_(kDefaultNetworkCapacity), |
537 send_buffer_capacity_(kDefaultTcpBufferSize), | 537 send_buffer_capacity_(kDefaultTcpBufferSize), |
538 recv_buffer_capacity_(kDefaultTcpBufferSize), | 538 recv_buffer_capacity_(kDefaultTcpBufferSize), |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 socket->SignalCloseEvent(socket, 0); | 663 socket->SignalCloseEvent(socket, 0); |
664 | 664 |
665 // Trigger the remote connection's close event. | 665 // Trigger the remote connection's close event. |
666 socket->Close(); | 666 socket->Close(); |
667 | 667 |
668 return true; | 668 return true; |
669 } | 669 } |
670 | 670 |
671 int VirtualSocketServer::Bind(VirtualSocket* socket, | 671 int VirtualSocketServer::Bind(VirtualSocket* socket, |
672 const SocketAddress& addr) { | 672 const SocketAddress& addr) { |
673 RTC_DCHECK(NULL != socket); | 673 RTC_DCHECK(nullptr != socket); |
674 // Address must be completely specified at this point | 674 // Address must be completely specified at this point |
675 RTC_DCHECK(!IPIsUnspec(addr.ipaddr())); | 675 RTC_DCHECK(!IPIsUnspec(addr.ipaddr())); |
676 RTC_DCHECK(addr.port() != 0); | 676 RTC_DCHECK(addr.port() != 0); |
677 | 677 |
678 // Normalize the address (turns v6-mapped addresses into v4-addresses). | 678 // Normalize the address (turns v6-mapped addresses into v4-addresses). |
679 SocketAddress normalized(addr.ipaddr().Normalized(), addr.port()); | 679 SocketAddress normalized(addr.ipaddr().Normalized(), addr.port()); |
680 | 680 |
681 AddressMap::value_type entry(normalized, socket); | 681 AddressMap::value_type entry(normalized, socket); |
682 return bindings_->insert(entry).second ? 0 : -1; | 682 return bindings_->insert(entry).second ? 0 : -1; |
683 } | 683 } |
684 | 684 |
685 int VirtualSocketServer::Bind(VirtualSocket* socket, SocketAddress* addr) { | 685 int VirtualSocketServer::Bind(VirtualSocket* socket, SocketAddress* addr) { |
686 RTC_DCHECK(NULL != socket); | 686 RTC_DCHECK(nullptr != socket); |
687 | 687 |
688 if (!IPIsUnspec(addr->ipaddr())) { | 688 if (!IPIsUnspec(addr->ipaddr())) { |
689 addr->SetIP(addr->ipaddr().Normalized()); | 689 addr->SetIP(addr->ipaddr().Normalized()); |
690 } else { | 690 } else { |
691 RTC_NOTREACHED(); | 691 RTC_NOTREACHED(); |
692 } | 692 } |
693 | 693 |
694 if (addr->port() == 0) { | 694 if (addr->port() == 0) { |
695 for (int i = 0; i < kEphemeralPortCount; ++i) { | 695 for (int i = 0; i < kEphemeralPortCount; ++i) { |
696 addr->SetPort(GetNextPort()); | 696 addr->SetPort(GetNextPort()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 750 |
751 VirtualSocket* VirtualSocketServer::LookupConnection( | 751 VirtualSocket* VirtualSocketServer::LookupConnection( |
752 const SocketAddress& local, | 752 const SocketAddress& local, |
753 const SocketAddress& remote) { | 753 const SocketAddress& remote) { |
754 SocketAddress local_normalized(local.ipaddr().Normalized(), | 754 SocketAddress local_normalized(local.ipaddr().Normalized(), |
755 local.port()); | 755 local.port()); |
756 SocketAddress remote_normalized(remote.ipaddr().Normalized(), | 756 SocketAddress remote_normalized(remote.ipaddr().Normalized(), |
757 remote.port()); | 757 remote.port()); |
758 SocketAddressPair address_pair(local_normalized, remote_normalized); | 758 SocketAddressPair address_pair(local_normalized, remote_normalized); |
759 ConnectionMap::iterator it = connections_->find(address_pair); | 759 ConnectionMap::iterator it = connections_->find(address_pair); |
760 return (connections_->end() != it) ? it->second : NULL; | 760 return (connections_->end() != it) ? it->second : nullptr; |
761 } | 761 } |
762 | 762 |
763 void VirtualSocketServer::RemoveConnection(const SocketAddress& local, | 763 void VirtualSocketServer::RemoveConnection(const SocketAddress& local, |
764 const SocketAddress& remote) { | 764 const SocketAddress& remote) { |
765 SocketAddress local_normalized(local.ipaddr().Normalized(), | 765 SocketAddress local_normalized(local.ipaddr().Normalized(), |
766 local.port()); | 766 local.port()); |
767 SocketAddress remote_normalized(remote.ipaddr().Normalized(), | 767 SocketAddress remote_normalized(remote.ipaddr().Normalized(), |
768 remote.port()); | 768 remote.port()); |
769 SocketAddressPair address_pair(local_normalized, remote_normalized); | 769 SocketAddressPair address_pair(local_normalized, remote_normalized); |
770 connections_->erase(address_pair); | 770 connections_->erase(address_pair); |
771 } | 771 } |
772 | 772 |
773 static double Random() { | 773 static double Random() { |
774 return static_cast<double>(rand()) / RAND_MAX; | 774 return static_cast<double>(rand()) / RAND_MAX; |
775 } | 775 } |
776 | 776 |
777 int VirtualSocketServer::Connect(VirtualSocket* socket, | 777 int VirtualSocketServer::Connect(VirtualSocket* socket, |
778 const SocketAddress& remote_addr, | 778 const SocketAddress& remote_addr, |
779 bool use_delay) { | 779 bool use_delay) { |
780 uint32_t delay = use_delay ? GetTransitDelay(socket) : 0; | 780 uint32_t delay = use_delay ? GetTransitDelay(socket) : 0; |
781 VirtualSocket* remote = LookupBinding(remote_addr); | 781 VirtualSocket* remote = LookupBinding(remote_addr); |
782 if (!CanInteractWith(socket, remote)) { | 782 if (!CanInteractWith(socket, remote)) { |
783 LOG(LS_INFO) << "Address family mismatch between " | 783 LOG(LS_INFO) << "Address family mismatch between " |
784 << socket->GetLocalAddress() << " and " << remote_addr; | 784 << socket->GetLocalAddress() << " and " << remote_addr; |
785 return -1; | 785 return -1; |
786 } | 786 } |
787 if (remote != NULL) { | 787 if (remote != nullptr) { |
788 SocketAddress addr = socket->GetLocalAddress(); | 788 SocketAddress addr = socket->GetLocalAddress(); |
789 msg_queue_->PostDelayed(RTC_FROM_HERE, delay, remote, MSG_ID_CONNECT, | 789 msg_queue_->PostDelayed(RTC_FROM_HERE, delay, remote, MSG_ID_CONNECT, |
790 new MessageAddress(addr)); | 790 new MessageAddress(addr)); |
791 } else { | 791 } else { |
792 LOG(LS_INFO) << "No one listening at " << remote_addr; | 792 LOG(LS_INFO) << "No one listening at " << remote_addr; |
793 msg_queue_->PostDelayed(RTC_FROM_HERE, delay, socket, MSG_ID_DISCONNECT); | 793 msg_queue_->PostDelayed(RTC_FROM_HERE, delay, socket, MSG_ID_DISCONNECT); |
794 } | 794 } |
795 return 0; | 795 return 0; |
796 } | 796 } |
797 | 797 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 void VirtualSocketServer::SetDefaultRoute(const IPAddress& from_addr) { | 1190 void VirtualSocketServer::SetDefaultRoute(const IPAddress& from_addr) { |
1191 RTC_DCHECK(!IPIsAny(from_addr)); | 1191 RTC_DCHECK(!IPIsAny(from_addr)); |
1192 if (from_addr.family() == AF_INET) { | 1192 if (from_addr.family() == AF_INET) { |
1193 default_route_v4_ = from_addr; | 1193 default_route_v4_ = from_addr; |
1194 } else if (from_addr.family() == AF_INET6) { | 1194 } else if (from_addr.family() == AF_INET6) { |
1195 default_route_v6_ = from_addr; | 1195 default_route_v6_ = from_addr; |
1196 } | 1196 } |
1197 } | 1197 } |
1198 | 1198 |
1199 } // namespace rtc | 1199 } // namespace rtc |
OLD | NEW |