Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ check_cxx_source_compiles(
HAVE_CRYPTO_EX_DUP_TYPE1
)

set(CMAKE_REQUIRED_INCLUDES netinet/in.h netinet/tcp.h)
set(CMAKE_EXTRA_INCLUDE_FILES netinet/in.h netinet/tcp.h)
check_type_size("struct tcp_info" STRUCT_TCP_INFO)
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_EXTRA_INCLUDE_FILES)

# Since Linux 2.6.12
check_struct_has_member("struct tcp_info" tcpi_total_retrans "linux/tcp.h" HAVE_STRUCT_TCP_INFO_TCPI_TOTAL_RETRANS)
Expand Down
14 changes: 13 additions & 1 deletion include/cripts/Connections.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ class Context;
#include "cripts/Lulu.hpp"
#include "cripts/Matcher.hpp"

// This is figured out in this way because
// this header has to be available to include
// from cripts scripts that won't have access
// to ink_platform.h.
#if __has_include("linux/tcp.h")
#include "linux/tcp.h"
#define HAS_TCP_INFO 1
#elif __has_include("netinet/tcp.h") && !defined(__APPLE__)
#include "netinet/tcp.h"
#define HAS_TCP_INFO 1
#endif

namespace cripts
{
namespace Net
Expand Down Expand Up @@ -220,7 +232,7 @@ class ConnBase
}

// ToDo: Add more member accesses? Tthe underlying info makes it hard to make it cross platform
#if defined(TCP_INFO) && defined(HAVE_STRUCT_TCP_INFO)
#if HAS_TCP_INFO
integer
rtt()
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/header_rewrite/conditions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ ConditionTcpInfo::eval(const Resources &res)
}

void
ConditionTcpInfo::append_value(std::string &s, Resources const & /* res ATS_UNUSED */)
ConditionTcpInfo::append_value(std::string &s, [[maybe_unused]] Resources const &res)
{
#if defined(TCP_INFO) && defined(HAVE_STRUCT_TCP_INFO)
if (TSHttpTxnIsInternal(res.txnp)) {
Expand Down
5 changes: 3 additions & 2 deletions src/cripts/Connections.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "cripts/Lulu.hpp"
#include "cripts/Preamble.hpp"
#include <arpa/inet.h>
#include "tscore/ink_platform.h"

constexpr unsigned NORMALIZED_TIME_QUANTUM = 3600; // 1 hour

Expand Down Expand Up @@ -77,9 +78,9 @@ detail::ConnBase::TcpInfo::Log()
if (_ready) {
// A lot of this is taken verbatim from header_rewrite, may want to rewrite this with sstreams
#if HAVE_STRUCT_TCP_INFO_TCPI_TOTAL_RETRANS
_logging = fmt::format("{};{};{};{}", info.tcpi_rtt, info.tcpi_rto, info.tcpi_snd_cwnd, info.tcpi_retrans);
_logging = cripts::string(format("{};{};{};{}", info.tcpi_rtt, info.tcpi_rto, info.tcpi_snd_cwnd, info.tcpi_retrans));
#elif HAVE_STRUCT_TCP_INFO___TCPI_RETRANS
_logging = fmt::format("{};{};{};{}", info.tcpi_rtt, info.tcpi_rto, info.tcpi_snd_cwnd, info.__tcpi_retrans);
_logging = cripts::string(fmt::format("{};{};{};{}", info.tcpi_rtt, info.tcpi_rto, info.tcpi_snd_cwnd, info.__tcpi_retrans));
#endif
}

Expand Down