diff --git a/include/ICMPController.hpp b/include/ICMPController.hpp index e6a9cb5..08373e2 100644 --- a/include/ICMPController.hpp +++ b/include/ICMPController.hpp @@ -9,11 +9,6 @@ class ICMPController { -private: - const RawSocket & socket; - SocketSender sender; - SocketReceiver receiver; - public: explicit ICMPController(RawSocket & s) : socket{s}, sender{SocketSender(s)}, receiver{SocketReceiver(s)} @@ -25,6 +20,10 @@ class ICMPController private: IPAddress recv_echo(uint16_t id, uint16_t ttl); + + const RawSocket & socket; + SocketSender sender; + SocketReceiver receiver; }; #endif diff --git a/include/IPAddress.hpp b/include/IPAddress.hpp index ab5588d..0844d46 100644 --- a/include/IPAddress.hpp +++ b/include/IPAddress.hpp @@ -9,10 +9,9 @@ class IPAddress { -private: +public: using addr_t = uint32_t; -public: explicit IPAddress(addr_t a) : address{a} { } diff --git a/include/RawSocket.hpp b/include/RawSocket.hpp index 9241484..159361a 100644 --- a/include/RawSocket.hpp +++ b/include/RawSocket.hpp @@ -8,9 +8,8 @@ #include #include -class SocketException : public std::logic_error +struct SocketException : public std::logic_error { -public: explicit SocketException(const char * s) : std::logic_error(s) { } diff --git a/include/SocketReceiver.hpp b/include/SocketReceiver.hpp index 8603e18..5dc3985 100644 --- a/include/SocketReceiver.hpp +++ b/include/SocketReceiver.hpp @@ -10,10 +10,6 @@ class SocketReceiver { -private: - const RawSocket & socket; - sockaddr_in sender_address; - public: explicit SocketReceiver(RawSocket & s) : socket{s}, sender_address{} { @@ -21,6 +17,10 @@ class SocketReceiver std::vector receive(); IPAddress take_address(); + +private: + const RawSocket & socket; + sockaddr_in sender_address; }; #endif diff --git a/include/SocketSender.hpp b/include/SocketSender.hpp index 63e15ca..c2fd445 100644 --- a/include/SocketSender.hpp +++ b/include/SocketSender.hpp @@ -10,10 +10,6 @@ class SocketSender { -private: - const RawSocket & socket; - sockaddr_in receiver_address; - public: explicit SocketSender(RawSocket & s) : socket{s}, receiver_address{} { @@ -21,6 +17,10 @@ class SocketSender void send(const void * msg_buf, int msg_size, uint16_t ttl); void set_receiver(const IPAddress & addr); + +private: + const RawSocket & socket; + sockaddr_in receiver_address; }; #endif