wub | f975eac | 2019-08-19 19:41:01 -0700 | [diff] [blame] | 1 | // Copyright (c) 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef QUICHE_QUIC_QBONE_BONNET_TUN_DEVICE_INTERFACE_H_ |
| 6 | #define QUICHE_QUIC_QBONE_BONNET_TUN_DEVICE_INTERFACE_H_ |
| 7 | |
| 8 | #include <vector> |
| 9 | |
| 10 | namespace quic { |
| 11 | |
| 12 | // An interface with methods for interacting with a TUN device. |
| 13 | class TunDeviceInterface { |
| 14 | public: |
| 15 | virtual ~TunDeviceInterface() {} |
| 16 | |
| 17 | // Actually creates/reopens and configures the device. |
| 18 | virtual bool Init() = 0; |
| 19 | |
| 20 | // Marks the interface up to start receiving packets. |
| 21 | virtual bool Up() = 0; |
| 22 | |
| 23 | // Marks the interface down to stop receiving packets. |
| 24 | virtual bool Down() = 0; |
| 25 | |
| 26 | // Gets the file descriptor that can be used to send/receive packets. |
| 27 | // This returns -1 when the TUN device is in an invalid state. |
| 28 | virtual int GetFileDescriptor() const = 0; |
| 29 | }; |
| 30 | |
| 31 | } // namespace quic |
| 32 | |
| 33 | #endif // QUICHE_QUIC_QBONE_BONNET_TUN_DEVICE_INTERFACE_H_ |