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 |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 class ProcessPacketInterface; | 27 class ProcessPacketInterface; |
28 class QuicDispatcher; | 28 class QuicDispatcher; |
29 | 29 |
30 class QuicServer : public EpollCallbackInterface { | 30 class QuicServer : public EpollCallbackInterface { |
31 public: | 31 public: |
32 QuicServer(); | 32 QuicServer(); |
33 QuicServer(const QuicConfig& config, | 33 QuicServer(const QuicConfig& config, |
34 const QuicVersionVector& supported_versions); | 34 const QuicVersionVector& supported_versions); |
35 | 35 |
36 virtual ~QuicServer(); | 36 ~QuicServer() override; |
37 | 37 |
38 // Start listening on the specified address. | 38 // Start listening on the specified address. |
39 bool Listen(const IPEndPoint& address); | 39 bool Listen(const IPEndPoint& address); |
40 | 40 |
41 // Wait up to 50ms, and handle any events which occur. | 41 // Wait up to 50ms, and handle any events which occur. |
42 void WaitForEvents(); | 42 void WaitForEvents(); |
43 | 43 |
44 // Server deletion is imminent. Start cleaning up the epoll server. | 44 // Server deletion is imminent. Start cleaning up the epoll server. |
45 void Shutdown(); | 45 void Shutdown(); |
46 | 46 |
47 // From EpollCallbackInterface | 47 // From EpollCallbackInterface |
48 virtual void OnRegistration(EpollServer* eps, | 48 void OnRegistration(EpollServer* eps, int fd, int event_mask) override {} |
49 int fd, | 49 void OnModification(int fd, int event_mask) override {} |
50 int event_mask) override {} | 50 void OnEvent(int fd, EpollEvent* event) override; |
51 virtual void OnModification(int fd, int event_mask) override {} | 51 void OnUnregistration(int fd, bool replaced) override {} |
52 virtual void OnEvent(int fd, EpollEvent* event) override; | |
53 virtual void OnUnregistration(int fd, bool replaced) override {} | |
54 | 52 |
55 // Reads a packet from the given fd, and then passes it off to | 53 // Reads a packet from the given fd, and then passes it off to |
56 // the QuicDispatcher. Returns true if a packet is read, false | 54 // the QuicDispatcher. Returns true if a packet is read, false |
57 // otherwise. | 55 // otherwise. |
58 // If packets_dropped is non-null, the socket is configured to track | 56 // If packets_dropped is non-null, the socket is configured to track |
59 // dropped packets, and some packets are read, it will be set to the number of | 57 // dropped packets, and some packets are read, it will be set to the number of |
60 // dropped packets. | 58 // dropped packets. |
61 static bool ReadAndDispatchSinglePacket(int fd, int port, | 59 static bool ReadAndDispatchSinglePacket(int fd, int port, |
62 ProcessPacketInterface* processor, | 60 ProcessPacketInterface* processor, |
63 uint32* packets_dropped); | 61 uint32* packets_dropped); |
64 | 62 |
65 virtual void OnShutdown(EpollServer* eps, int fd) override {} | 63 void OnShutdown(EpollServer* eps, int fd) override {} |
66 | 64 |
67 void SetStrikeRegisterNoStartupPeriod() { | 65 void SetStrikeRegisterNoStartupPeriod() { |
68 crypto_config_.set_strike_register_no_startup_period(); | 66 crypto_config_.set_strike_register_no_startup_period(); |
69 } | 67 } |
70 | 68 |
71 // SetProofSource sets the ProofSource that will be used to verify the | 69 // SetProofSource sets the ProofSource that will be used to verify the |
72 // server's certificate, and takes ownership of |source|. | 70 // server's certificate, and takes ownership of |source|. |
73 void SetProofSource(ProofSource* source) { | 71 void SetProofSource(ProofSource* source) { |
74 crypto_config_.SetProofSource(source); | 72 crypto_config_.SetProofSource(source); |
75 } | 73 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // connections. | 135 // connections. |
138 uint32 server_initial_flow_control_receive_window_; | 136 uint32 server_initial_flow_control_receive_window_; |
139 | 137 |
140 DISALLOW_COPY_AND_ASSIGN(QuicServer); | 138 DISALLOW_COPY_AND_ASSIGN(QuicServer); |
141 }; | 139 }; |
142 | 140 |
143 } // namespace tools | 141 } // namespace tools |
144 } // namespace net | 142 } // namespace net |
145 | 143 |
146 #endif // NET_TOOLS_QUIC_QUIC_SERVER_H_ | 144 #endif // NET_TOOLS_QUIC_QUIC_SERVER_H_ |
OLD | NEW |