OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/tools/quic/quic_server.h" | 5 #include "net/tools/quic/quic_server.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <features.h> | 8 #include <features.h> |
9 #include <netinet/in.h> | 9 #include <netinet/in.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 CHECK(address.ToSockAddr(reinterpret_cast<sockaddr*>(&raw_addr), | 124 CHECK(address.ToSockAddr(reinterpret_cast<sockaddr*>(&raw_addr), |
125 &raw_addr_len)); | 125 &raw_addr_len)); |
126 rc = bind(fd_, | 126 rc = bind(fd_, |
127 reinterpret_cast<const sockaddr*>(&raw_addr), | 127 reinterpret_cast<const sockaddr*>(&raw_addr), |
128 sizeof(raw_addr)); | 128 sizeof(raw_addr)); |
129 if (rc < 0) { | 129 if (rc < 0) { |
130 LOG(ERROR) << "Bind failed: " << strerror(errno); | 130 LOG(ERROR) << "Bind failed: " << strerror(errno); |
131 return false; | 131 return false; |
132 } | 132 } |
133 | 133 |
134 LOG(INFO) << "Listening on " << address.ToString(); | 134 VLOG(0) << "Listening on " << address.ToString(); |
135 if (port_ == 0) { | 135 if (port_ == 0) { |
136 SockaddrStorage storage; | 136 SockaddrStorage storage; |
137 IPEndPoint server_address; | 137 IPEndPoint server_address; |
138 if (getsockname(fd_, storage.addr, &storage.addr_len) != 0 || | 138 if (getsockname(fd_, storage.addr, &storage.addr_len) != 0 || |
139 !server_address.FromSockAddr(storage.addr, storage.addr_len)) { | 139 !server_address.FromSockAddr(storage.addr, storage.addr_len)) { |
140 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno); | 140 LOG(ERROR) << "Unable to get self address. Error: " << strerror(errno); |
141 return false; | 141 return false; |
142 } | 142 } |
143 port_ = server_address.port(); | 143 port_ = server_address.port(); |
144 LOG(INFO) << "Kernel assigned port is " << port_; | 144 VLOG(0) << "Kernel assigned port is " << port_; |
145 } | 145 } |
146 | 146 |
147 epoll_server_.RegisterFD(fd_, this, kEpollFlags); | 147 epoll_server_.RegisterFD(fd_, this, kEpollFlags); |
148 dispatcher_.reset(new QuicDispatcher(config_, crypto_config_, | 148 dispatcher_.reset(new QuicDispatcher(config_, crypto_config_, |
149 supported_versions_, | 149 supported_versions_, |
150 fd_, &epoll_server_)); | 150 fd_, &epoll_server_)); |
151 | 151 |
152 return true; | 152 return true; |
153 } | 153 } |
154 | 154 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 QuicEncryptedPacket packet(buf, bytes_read, false); | 226 QuicEncryptedPacket packet(buf, bytes_read, false); |
227 | 227 |
228 IPEndPoint server_address(server_ip, port); | 228 IPEndPoint server_address(server_ip, port); |
229 MaybeDispatchPacket(dispatcher, packet, server_address, client_address); | 229 MaybeDispatchPacket(dispatcher, packet, server_address, client_address); |
230 | 230 |
231 return true; | 231 return true; |
232 } | 232 } |
233 | 233 |
234 } // namespace tools | 234 } // namespace tools |
235 } // namespace net | 235 } // namespace net |
OLD | NEW |