diff --git a/.clang-format b/.clang-format index 7d5686f..f0a4e8d 100644 --- a/.clang-format +++ b/.clang-format @@ -8,14 +8,14 @@ AlignConsecutiveMacros: false AlignEscapedNewlines: DontAlign AlignOperands: true AlignTrailingComments: false -AllowAllArgumentsOnNextLine: false -AllowAllConstructorInitializersOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: false +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLambdasOnASingleLine: true +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All AllowShortLoopsOnASingleLine: false AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false @@ -37,7 +37,6 @@ ContinuationIndentWidth: 8 Cpp11BracedListStyle: true DerivePointerAlignment: false FixNamespaceComments: false -ForEachMacros: [] IncludeBlocks: Merge IncludeCategories: # C Standard library @@ -67,7 +66,7 @@ IncludeCategories: # All custom headers - Regex: '^".*"' Priority: 8 -IncludeIsMainRegex: "$" +IncludeIsMainRegex: '$' IndentCaseLabels: true IndentPPDirectives: None IndentWidth: 4 @@ -77,7 +76,6 @@ MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: All -NamespaceMacros: [] PointerAlignment: Middle ReflowComments: false SortIncludes: true @@ -99,7 +97,5 @@ SpacesInContainerLiterals: false SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Cpp11 -StatementMacros: [] TabWidth: 4 -TypenameMacros: [] UseTab: Never diff --git a/CMakeLists.txt b/CMakeLists.txt index 53a5c41..af36249 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -project(Traceroute VERSION 1.0.191124) +project(Traceroute VERSION 1.1.200119) # COMPILER set(CMAKE_CXX_STANDARD 14) @@ -9,9 +9,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unknown-pragmas") include_directories(include) set(SOURCES src/IPAddress.cpp - src/ICMPReceiver.cpp - src/ICMPSender.cpp src/ICMPController.cpp + src/SocketReceiver.cpp + src/SocketSender.cpp src/traceroute.cpp) # OUTPUT diff --git a/include/ICMPController.hpp b/include/ICMPController.hpp index ad5e229..e6a9cb5 100644 --- a/include/ICMPController.hpp +++ b/include/ICMPController.hpp @@ -4,18 +4,19 @@ #include #include #include -#include "ICMPReceiver.hpp" -#include "ICMPSender.hpp" +#include "SocketReceiver.hpp" +#include "SocketSender.hpp" class ICMPController { +private: const RawSocket & socket; - ICMPSender sender; - ICMPReceiver receiver; + SocketSender sender; + SocketReceiver receiver; public: explicit ICMPController(RawSocket & s) - : socket{s}, sender{ICMPSender(s)}, receiver{ICMPReceiver(s)} + : socket{s}, sender{SocketSender(s)}, receiver{SocketReceiver(s)} { } diff --git a/include/ICMPReceiver.hpp b/include/SocketReceiver.hpp similarity index 67% rename from include/ICMPReceiver.hpp rename to include/SocketReceiver.hpp index 1357d75..8603e18 100644 --- a/include/ICMPReceiver.hpp +++ b/include/SocketReceiver.hpp @@ -1,5 +1,5 @@ -#ifndef ICMP_RECEIVER_HPP_ -#define ICMP_RECEIVER_HPP_ +#ifndef SOCKET_RECEIVER_HPP_ +#define SOCKET_RECEIVER_HPP_ #include #include @@ -8,14 +8,14 @@ #include "IPAddress.hpp" #include "RawSocket.hpp" -class ICMPReceiver +class SocketReceiver { private: const RawSocket & socket; sockaddr_in sender_address; public: - explicit ICMPReceiver(RawSocket & s) : socket{s}, sender_address{} + explicit SocketReceiver(RawSocket & s) : socket{s}, sender_address{} { } diff --git a/include/ICMPSender.hpp b/include/SocketSender.hpp similarity index 71% rename from include/ICMPSender.hpp rename to include/SocketSender.hpp index 259673f..63e15ca 100644 --- a/include/ICMPSender.hpp +++ b/include/SocketSender.hpp @@ -1,5 +1,5 @@ -#ifndef ICMP_SENDER_HPP_ -#define ICMP_SENDER_HPP_ +#ifndef SOCKET_SENDER_HPP_ +#define SOCKET_SENDER_HPP_ #include #include @@ -8,14 +8,14 @@ #include "IPAddress.hpp" #include "RawSocket.hpp" -class ICMPSender +class SocketSender { private: const RawSocket & socket; sockaddr_in receiver_address; public: - explicit ICMPSender(RawSocket & s) : socket{s}, receiver_address{} + explicit SocketSender(RawSocket & s) : socket{s}, receiver_address{} { } diff --git a/src/ICMPReceiver.cpp b/src/SocketReceiver.cpp similarity index 86% rename from src/ICMPReceiver.cpp rename to src/SocketReceiver.cpp index 6fd2952..2c69427 100644 --- a/src/ICMPReceiver.cpp +++ b/src/SocketReceiver.cpp @@ -1,10 +1,10 @@ -#include "ICMPReceiver.hpp" +#include "SocketReceiver.hpp" #include #include #include #include -std::vector ICMPReceiver::receive() +std::vector SocketReceiver::receive() { socklen_t sender_size = sizeof(sender_address); uint8_t msg_buf[IP_MAXPACKET]; @@ -18,7 +18,7 @@ std::vector ICMPReceiver::receive() return std::vector(std::begin(msg_buf), std::begin(msg_buf) + msg_size); } -IPAddress ICMPReceiver::take_address() +IPAddress SocketReceiver::take_address() { char ip_str[32]; diff --git a/src/ICMPSender.cpp b/src/SocketSender.cpp similarity index 78% rename from src/ICMPSender.cpp rename to src/SocketSender.cpp index 8086cdf..7ef14d0 100644 --- a/src/ICMPSender.cpp +++ b/src/SocketSender.cpp @@ -1,9 +1,9 @@ -#include "ICMPSender.hpp" +#include "SocketSender.hpp" #include #include #include -void ICMPSender::send(const void * msg_buf, int msg_size, uint16_t ttl) +void SocketSender::send(const void * msg_buf, int msg_size, uint16_t ttl) { setsockopt(socket.descriptor(), IPPROTO_IP, IP_TTL, &ttl, sizeof(uint16_t)); @@ -14,7 +14,7 @@ void ICMPSender::send(const void * msg_buf, int msg_size, uint16_t ttl) throw SocketException(strerror(errno)); } -void ICMPSender::set_receiver(const IPAddress & addr) +void SocketSender::set_receiver(const IPAddress & addr) { receiver_address.sin_family = AF_INET;