From c20004ebf2c73632158d698d0583a3da08b9b978 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Tue, 14 Nov 2017 15:48:59 +0100 Subject: [PATCH] Rename generateXPFPayload() parameters for clarity --- pdns/xpf.cc | 40 ++++++++++++++++++++-------------------- pdns/xpf.hh | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pdns/xpf.cc b/pdns/xpf.cc index 8b093e44c..86d98d75f 100644 --- a/pdns/xpf.cc +++ b/pdns/xpf.cc @@ -22,44 +22,44 @@ #include "xpf.hh" -std::string generateXPFPayload(bool tcp, const ComboAddress& remote, const ComboAddress& local) +std::string generateXPFPayload(bool tcp, const ComboAddress& source, const ComboAddress& destination) { - if (remote.sin4.sin_family != local.sin4.sin_family) { - throw std::runtime_error("The XPF local and remote addresses must be of the same family"); + if (source.sin4.sin_family != destination.sin4.sin_family) { + throw std::runtime_error("The XPF destination and source addresses must be of the same family"); } std::string ret; - const uint8_t version = remote.isIPv4() ? 4 : 6; + const uint8_t version = source.isIPv4() ? 4 : 6; const uint8_t protocol = tcp ? 6 : 17; - const size_t addrSize = remote.isIPv4() ? sizeof(remote.sin4.sin_addr.s_addr) : sizeof(remote.sin6.sin6_addr.s6_addr); - const uint16_t remotePort = remote.sin4.sin_port; - const uint16_t localPort = local.sin4.sin_port; + const size_t addrSize = source.isIPv4() ? sizeof(source.sin4.sin_addr.s_addr) : sizeof(source.sin6.sin6_addr.s6_addr); + const uint16_t sourcePort = source.sin4.sin_port; + const uint16_t destinationPort = destination.sin4.sin_port; - ret.reserve(sizeof(version) + sizeof(protocol) + (addrSize * 2) + sizeof(remotePort) + sizeof(localPort)); + ret.reserve(sizeof(version) + sizeof(protocol) + (addrSize * 2) + sizeof(sourcePort) + sizeof(destinationPort)); ret.append(reinterpret_cast(&version), sizeof(version)); ret.append(reinterpret_cast(&protocol), sizeof(protocol)); - if (remote.isIPv4()) { - assert(addrSize == sizeof(remote.sin4.sin_addr.s_addr)); - ret.append(reinterpret_cast(&remote.sin4.sin_addr.s_addr), addrSize); + if (source.isIPv4()) { + assert(addrSize == sizeof(source.sin4.sin_addr.s_addr)); + ret.append(reinterpret_cast(&source.sin4.sin_addr.s_addr), addrSize); } else { - assert(addrSize == sizeof(remote.sin6.sin6_addr.s6_addr)); - ret.append(reinterpret_cast(&remote.sin6.sin6_addr.s6_addr), addrSize); + assert(addrSize == sizeof(source.sin6.sin6_addr.s6_addr)); + ret.append(reinterpret_cast(&source.sin6.sin6_addr.s6_addr), addrSize); } - if (remote.isIPv4()) { - assert(addrSize == sizeof(local.sin4.sin_addr.s_addr)); - ret.append(reinterpret_cast(&local.sin4.sin_addr.s_addr), addrSize); + if (source.isIPv4()) { + assert(addrSize == sizeof(destination.sin4.sin_addr.s_addr)); + ret.append(reinterpret_cast(&destination.sin4.sin_addr.s_addr), addrSize); } else { - assert(addrSize == sizeof(local.sin6.sin6_addr.s6_addr)); - ret.append(reinterpret_cast(&local.sin6.sin6_addr.s6_addr), addrSize); + assert(addrSize == sizeof(destination.sin6.sin6_addr.s6_addr)); + ret.append(reinterpret_cast(&destination.sin6.sin6_addr.s6_addr), addrSize); } - ret.append(reinterpret_cast(&remotePort), sizeof(remotePort)); - ret.append(reinterpret_cast(&localPort), sizeof(localPort)); + ret.append(reinterpret_cast(&sourcePort), sizeof(sourcePort)); + ret.append(reinterpret_cast(&destinationPort), sizeof(destinationPort)); return ret; } diff --git a/pdns/xpf.hh b/pdns/xpf.hh index e3e18c374..4e8f46679 100644 --- a/pdns/xpf.hh +++ b/pdns/xpf.hh @@ -24,6 +24,6 @@ #include -std::string generateXPFPayload(bool tcp, const ComboAddress& remote, const ComboAddress& local); +std::string generateXPFPayload(bool tcp, const ComboAddress& source, const ComboAddress& destination); bool parseXPFPayload(const char* payload, size_t len, ComboAddress& source, ComboAddress* destination); -- 2.40.0