diff --git a/example/example.cpp b/example/example.cpp index 9a575f7f2348effd25c3c916e6aca3f2094bcddc..313f5f38d7823144a288360abd625282a3cc3351 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -5,6 +5,8 @@ // Include the all-in-one headerfile. This will include all other headers #include "netlib.hpp" +using namespace netlib; + void example_IpAddr() { // IpAddr takes an address as string and automatically detects if it is diff --git a/inc/ipaddr.hpp b/inc/ipaddr.hpp index 53c1f33884c1b8e3efead045f1b8641499584391..10b6678b7179c5ff266aca90518f9d407b47d33c 100644 --- a/inc/ipaddr.hpp +++ b/inc/ipaddr.hpp @@ -4,6 +4,10 @@ #include <string> #include <netinet/in.h> +namespace netlib +{ + + /** * @brief The IpAddr class represents an ip address that can either be of type * Ipv4 or of type Ipv6. @@ -129,4 +133,7 @@ public: }; + +} // namespace netlib + #endif // _IPADDR_HPP \ No newline at end of file diff --git a/inc/resolver.hpp b/inc/resolver.hpp index 21cc1a30ee50272ae85edf4c2c94b3f65193670b..2d763e75344ec1d1a45444c1bb41b1e56f429dd7 100644 --- a/inc/resolver.hpp +++ b/inc/resolver.hpp @@ -5,6 +5,10 @@ #include "ipaddr.hpp" +namespace netlib +{ + + /** * @brief Provide multiple ways to resolve hostnames to Ipv4 and/or Ipv6 * addresses. @@ -112,4 +116,6 @@ public: }; +} // namespace netlib + #endif // _RESOLVER_HPP \ No newline at end of file diff --git a/inc/sockaddr.hpp b/inc/sockaddr.hpp index 7b67336e82ff45bdad1a6d56f486d45baf4697be..7ad3be2ff7527db985ca52e0b76231b953ae8b14 100644 --- a/inc/sockaddr.hpp +++ b/inc/sockaddr.hpp @@ -6,6 +6,10 @@ #include "ipaddr.hpp" +namespace netlib +{ + + /** * @brief SockAddr represents the combination of an ip address and a port number. * @@ -134,4 +138,7 @@ public: }; + +} // namespace netlib + #endif // _SOCKADDR_HPP \ No newline at end of file diff --git a/inc/tcplistener.hpp b/inc/tcplistener.hpp index a9e8846fe221fb01856c7453eff13f32d2dfecf5..8a2e8032f895752d14f4eb5abb9c7a1ad67c8fc0 100644 --- a/inc/tcplistener.hpp +++ b/inc/tcplistener.hpp @@ -6,6 +6,10 @@ #include <filesystem> +namespace netlib +{ + + /** * @brief Listen to a local ip address + port and accept incomming connections * as TcpStreams. @@ -113,4 +117,7 @@ public: }; + +} // namespace netlib + #endif // _TCPLISTENER_HPP \ No newline at end of file diff --git a/inc/tcpstream.hpp b/inc/tcpstream.hpp index fb3c5f4f2ba5de00a1a16c3eca3398a3068b11ca..6374870125f1de77f514ac474c8cc1ce70f61f61 100644 --- a/inc/tcpstream.hpp +++ b/inc/tcpstream.hpp @@ -5,6 +5,10 @@ #include "sockaddr.hpp" +namespace netlib +{ + + /** * @brief The TcpStream represents tcp a connection with another endpoint and is * used to send and receive data through that connection. @@ -227,4 +231,6 @@ public: }; +} // namespace netlib + #endif // _TCPSTREAM_HPP \ No newline at end of file diff --git a/inc/udpsocket.hpp b/inc/udpsocket.hpp index 8e0a3640cc349049803b37cc1a1c2c878f3eac9c..62126ff5ca98ac73035940b2308e37c7b1b0f1cd 100644 --- a/inc/udpsocket.hpp +++ b/inc/udpsocket.hpp @@ -3,6 +3,10 @@ #include "sockaddr.hpp" +namespace netlib +{ + + /** * @brief The UdpSocket can be used to receive UDP packets from and send UDP * packets to any target address. @@ -209,4 +213,7 @@ public: }; + +} // namespace netlib + #endif // _UDPSOCKET_HPP \ No newline at end of file diff --git a/src/ipaddr.cpp b/src/ipaddr.cpp index dcef1eb0ad20b46fb9eb1f291b30c02b488655d5..0b525185dbf176dd14f3e95056599e1153595085 100644 --- a/src/ipaddr.cpp +++ b/src/ipaddr.cpp @@ -5,6 +5,8 @@ #include <cstring> #include <arpa/inet.h> +using namespace netlib; + IpAddr::IpAddr() : IpAddr("0.0.0.0") { } diff --git a/src/resolver.cpp b/src/resolver.cpp index c3103d1ed7133a852ad2008eca335c1edad9b849..7e2b178e2ef42d5f3d15115237023e06f928465d 100644 --- a/src/resolver.cpp +++ b/src/resolver.cpp @@ -8,6 +8,7 @@ #include <netdb.h> #include <arpa/inet.h> +using namespace netlib; IpAddr Resolver::resolveHostnameAF(const std::string &hostname, int af) { diff --git a/src/sockaddr.cpp b/src/sockaddr.cpp index 7977198f7c7bc81d07fcf85ecc6278d42f50bcf4..a07ce0e9585dec8d32d4cc90cdd031b3e712614e 100644 --- a/src/sockaddr.cpp +++ b/src/sockaddr.cpp @@ -5,6 +5,8 @@ #include <arpa/inet.h> +using namespace netlib; + SockAddr::SockAddr() : SockAddr{IpAddr::V4("0.0.0.0"), 0} { } diff --git a/src/tcplistener.cpp b/src/tcplistener.cpp index 54f07fb9ac9f0c7e692408794cc66b711c4a6ecc..fd4b87990b4b1b43a56a496e103b9d3b0c8d0f23 100644 --- a/src/tcplistener.cpp +++ b/src/tcplistener.cpp @@ -5,6 +5,8 @@ #include <unistd.h> #include <sys/socket.h> +using namespace netlib; + // TODO: More and better error handling TcpListener::TcpListener(SockAddr _local) diff --git a/src/tcpstream.cpp b/src/tcpstream.cpp index c08d40345a016cf686b0098cdc686d204aa78ff1..f95afbeb2198e275644b929e30d7912d36d0a554 100644 --- a/src/tcpstream.cpp +++ b/src/tcpstream.cpp @@ -7,6 +7,8 @@ #include <netinet/in.h> #include <poll.h> +using namespace netlib; + TcpStream::TcpStream(SockAddr _remote) : remote{_remote}, sockfd{0} { } diff --git a/src/udpsocket.cpp b/src/udpsocket.cpp index 89234e4fbd539c7e57e913bd90d5234e8a26aef5..1f6a323abe496905ea6f4b01ac4dfe29cdee9c03 100644 --- a/src/udpsocket.cpp +++ b/src/udpsocket.cpp @@ -6,6 +6,7 @@ #include <sys/socket.h> #include <poll.h> +using namespace netlib; UdpSocket::UdpSocket() : UdpSocket{"0.0.0.0", 0} diff --git a/test/test.cpp b/test/test.cpp index 2fe4d8382db99da72c2ed408d1b07b7b2feb3153..994ff63504a933e99d371cbcc3b8ee460b78d676 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -7,6 +7,7 @@ #include "netlib.hpp" +using namespace netlib; TEST_CASE("Test IpAddr::V4") {