12#ifndef OPENVPN_TRANSPORT_PROTOCOL_H
13#define OPENVPN_TRANSPORT_PROTOCOL_H
129 return (
is_tcp() ||
is_tls()) ?
sizeof(std::uint16_t) : 0;
159 const char *title =
nullptr)
178 if (
str[0] !=
'u' &&
str[0] !=
'U'
179 &&
str[0] !=
'n' &&
str[0] !=
'N')
241 return "UNDEF_PROTO";
270 return "unix-stream";
295 return server ?
"TCPv4_SERVER" :
"TCPv4_CLIENT";
301 return "UNDEF_PROTO";
312 switch (allow_suffix)
318 s = s.substr(0, s.length() - 7);
322 s = s.substr(0, s.length() - 7);
327 if (s ==
"unix-stream")
329 else if (s ==
"unix-dgram")
332 else if (s ==
"named-pipe")
334 else if (s.length() >= 3)
336 const std::string s1 = s.substr(0, 3);
337 const std::string s2 = s.substr(3);
342 else if (s1 ==
"tcp")
344 else if (s1 ==
"tls")
347 else if (s2 ==
"4" || s2 ==
"v4")
351 else if (s1 ==
"tcp")
353 else if (s1 ==
"tls")
356 else if (s2 ==
"6" || s2 ==
"v6")
360 else if (s1 ==
"tcp")
362 else if (s1 ==
"tls")
bool operator==(const Protocol &other) const
const char * protocol_to_string() const
static Type parse_type(const std::string &str, const AllowSuffix allow_suffix)
const char * occ_str(const bool server) const
bool operator!=(const Protocol &other) const
unsigned int extra_transport_bytes() const
static bool is_local_type(const std::string &str)
bool is_named_pipe() const
void mod_addr_version(const IP::Addr::Version ip_version)
int transport_proto() const
static Protocol parse(const std::string &str, const AllowSuffix allow_suffix, const char *title=nullptr)
bool transport_match(const Protocol &other) const
#define OPENVPN_THROW_ARG1(exc, arg, stuff)
int strcasecmp(const char *s1, const char *s2)
void to_lower(std::string &str)
bool starts_with(const STRING &str, const std::string &prefix)
bool ends_with(const STRING &str, const std::string &suffix)