| 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 // A toy server, which listens on a specified address for QUIC traffic and | 5 // A toy server, which listens on a specified address for QUIC traffic and |
| 6 // handles incoming responses. | 6 // handles incoming responses. |
| 7 | 7 |
| 8 #ifndef NET_TOOLS_QUIC_QUIC_SERVER_H_ | 8 #ifndef NET_TOOLS_QUIC_QUIC_SERVER_H_ |
| 9 #define NET_TOOLS_QUIC_QUIC_SERVER_H_ | 9 #define NET_TOOLS_QUIC_QUIC_SERVER_H_ |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "net/base/ip_endpoint.h" | 13 #include "net/base/ip_endpoint.h" |
| 14 #include "net/quic/crypto/quic_crypto_server_config.h" | 14 #include "net/quic/crypto/quic_crypto_server_config.h" |
| 15 #include "net/quic/quic_config.h" | 15 #include "net/quic/quic_config.h" |
| 16 #include "net/quic/quic_connection_helper.h" | 16 #include "net/quic/quic_connection_helper.h" |
| 17 #include "net/quic/quic_framer.h" | 17 #include "net/quic/quic_framer.h" |
| 18 #include "net/tools/epoll_server/epoll_server.h" | 18 #include "net/tools/epoll_server/epoll_server.h" |
| 19 #include "net/tools/quic/quic_default_packet_writer.h" | 19 #include "net/tools/quic/quic_default_packet_writer.h" |
| 20 | 20 |
| 21 namespace net { | 21 namespace net { |
| 22 | |
| 23 namespace tools { | 22 namespace tools { |
| 24 | 23 |
| 25 namespace test { | 24 namespace test { |
| 26 class QuicServerPeer; | 25 class QuicServerPeer; |
| 27 } // namespace test | 26 } // namespace test |
| 28 | 27 |
| 29 class ProcessPacketInterface; | 28 class ProcessPacketInterface; |
| 30 class QuicDispatcher; | 29 class QuicDispatcher; |
| 31 class QuicPacketReader; | 30 class QuicPacketReader; |
| 32 | 31 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 | 45 |
| 47 // Server deletion is imminent. Start cleaning up the epoll server. | 46 // Server deletion is imminent. Start cleaning up the epoll server. |
| 48 void Shutdown(); | 47 void Shutdown(); |
| 49 | 48 |
| 50 // From EpollCallbackInterface | 49 // From EpollCallbackInterface |
| 51 void OnRegistration(EpollServer* eps, int fd, int event_mask) override {} | 50 void OnRegistration(EpollServer* eps, int fd, int event_mask) override {} |
| 52 void OnModification(int fd, int event_mask) override {} | 51 void OnModification(int fd, int event_mask) override {} |
| 53 void OnEvent(int fd, EpollEvent* event) override; | 52 void OnEvent(int fd, EpollEvent* event) override; |
| 54 void OnUnregistration(int fd, bool replaced) override {} | 53 void OnUnregistration(int fd, bool replaced) override {} |
| 55 | 54 |
| 56 // Reads a packet from the given fd, and then passes it off to | 55 // Reads a number of packets from the given fd, and then passes them off to |
| 57 // the QuicDispatcher. Returns true if a packet is read, false | 56 // the QuicDispatcher. Returns true if some packets are read, false |
| 58 // otherwise. | 57 // otherwise. |
| 59 // If packets_dropped is non-null, the socket is configured to track | 58 // If packets_dropped is non-null, the socket is configured to track |
| 60 // dropped packets, and some packets are read, it will be set to the number of | 59 // dropped packets, and some packets are read, it will be set to the number of |
| 61 // dropped packets. | 60 // dropped packets. |
| 61 static bool ReadAndDispatchPackets(int fd, int port, |
| 62 ProcessPacketInterface* processor, |
| 63 QuicPacketCount* packets_dropped); |
| 64 // Same as ReadAndDispatchPackets, only does one packet at a time. |
| 62 static bool ReadAndDispatchSinglePacket(int fd, int port, | 65 static bool ReadAndDispatchSinglePacket(int fd, int port, |
| 63 ProcessPacketInterface* processor, | 66 ProcessPacketInterface* processor, |
| 64 QuicPacketCount* packets_dropped); | 67 QuicPacketCount* packets_dropped); |
| 65 | 68 |
| 66 void OnShutdown(EpollServer* eps, int fd) override {} | 69 void OnShutdown(EpollServer* eps, int fd) override {} |
| 67 | 70 |
| 68 void SetStrikeRegisterNoStartupPeriod() { | 71 void SetStrikeRegisterNoStartupPeriod() { |
| 69 crypto_config_.set_strike_register_no_startup_period(); | 72 crypto_config_.set_strike_register_no_startup_period(); |
| 70 } | 73 } |
| 71 | 74 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 143 |
| 141 scoped_ptr<QuicPacketReader> packet_reader_; | 144 scoped_ptr<QuicPacketReader> packet_reader_; |
| 142 | 145 |
| 143 DISALLOW_COPY_AND_ASSIGN(QuicServer); | 146 DISALLOW_COPY_AND_ASSIGN(QuicServer); |
| 144 }; | 147 }; |
| 145 | 148 |
| 146 } // namespace tools | 149 } // namespace tools |
| 147 } // namespace net | 150 } // namespace net |
| 148 | 151 |
| 149 #endif // NET_TOOLS_QUIC_QUIC_SERVER_H_ | 152 #endif // NET_TOOLS_QUIC_QUIC_SERVER_H_ |
| OLD | NEW |