1 // Copyright 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_MASQUE_MASQUE_UTILS_H_ 6 #define QUICHE_QUIC_MASQUE_MASQUE_UTILS_H_ 7 8 #include "quiche/quic/core/quic_config.h" 9 #include "quiche/quic/core/quic_types.h" 10 #include "quiche/quic/core/quic_versions.h" 11 12 namespace quic { 13 14 // List of QUIC versions that support MASQUE. Currently restricted to IETF QUIC. 15 QUIC_NO_EXPORT ParsedQuicVersionVector MasqueSupportedVersions(); 16 17 // Default QuicConfig for use with MASQUE. Sets a custom max_packet_size. 18 QUIC_NO_EXPORT QuicConfig MasqueEncapsulatedConfig(); 19 20 // Maximum packet size for encapsulated connections. 21 enum : QuicByteCount { 22 kMasqueMaxEncapsulatedPacketSize = 1250, 23 kMasqueMaxOuterPacketSize = 1350, 24 kMasqueIpPacketBufferSize = 1501, 25 // Enough for a VLAN tag, but not Stacked VLANs. 26 kMasqueEthernetFrameBufferSize = 1523, 27 }; 28 29 // Mode that MASQUE is operating in. 30 enum class MasqueMode : uint8_t { 31 kInvalid = 0, // Should never be used. 32 kOpen = 2, // Open mode uses the MASQUE HTTP CONNECT-UDP method as documented 33 // in <https://www.rfc-editor.org/rfc/rfc9298.html>. This mode allows 34 // unauthenticated clients (a more restricted mode will be added to this enum 35 // at a later date). 36 kConnectIp = 37 1, // ConnectIp mode uses MASQUE HTTP CONNECT-IP as documented in 38 // <https://datatracker.ietf.org/doc/html/draft-ietf-masque-connect-ip>. This 39 // mode also allows unauthenticated clients. 40 kConnectEthernet = 41 3, // ConnectEthernet mode uses MASQUE HTTP CONNECT-ETHERNET. 42 // <https://datatracker.ietf.org/doc/draft-asedeno-masque-connect-ethernet/> 43 // This mode also allows unauthenticated clients. 44 }; 45 46 QUIC_NO_EXPORT std::string MasqueModeToString(MasqueMode masque_mode); 47 QUIC_NO_EXPORT std::ostream& operator<<(std::ostream& os, 48 const MasqueMode& masque_mode); 49 50 // Create a TUN interface, with the specified `client_address`. Requires root. 51 int CreateTunInterface(const QuicIpAddress& client_address, bool server = true); 52 53 // Create a TAP interface. Requires root. 54 int CreateTapInterface(); 55 56 } // namespace quic 57 58 #endif // QUICHE_QUIC_MASQUE_MASQUE_UTILS_H_ 59