Skip to content

Commit

Permalink
Minor updates (#9)
Browse files Browse the repository at this point in the history
* Minor Updates
  • Loading branch information
mortenvp committed Apr 27, 2023
1 parent 7cc0fd8 commit 641ef82
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 52 deletions.
5 changes: 4 additions & 1 deletion src/tunnel/detail/layer_final.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

// Copyright (c) 2017 Steinwurf ApS
// All Rights Reserved
//
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#pragma once

Expand Down
5 changes: 5 additions & 0 deletions src/tunnel/detail/monitor.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Copyright (c) 2017 Steinwurf ApS
// All Rights Reserved
//
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#pragma once

#include <string>
Expand Down
6 changes: 2 additions & 4 deletions src/tunnel/platform_linux/layer_netlink_v4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
#include <asm/types.h>
#include <cstdint>
#include <iostream>
// clang-format off

#include <sys/socket.h>
#include <sys/types.h>

#include <linux/if.h>
// clang-format on

// clang-format off
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
// clang-format on

#include <cstring>
#include <netinet/in.h>
Expand Down
6 changes: 3 additions & 3 deletions src/tunnel/platform_linux/tun_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#pragma once

#include <cassert>
#include <cstring>
#include <string>
Expand All @@ -14,11 +16,9 @@
#include <fcntl.h>
#include <linux/if_tun.h>

// clang-format off
#include <linux/if.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <linux/if.h>
// clang-format on

#include "error.hpp"
#include "layer_linux.hpp"
Expand Down
5 changes: 5 additions & 0 deletions src/tunnel/platform_unsupported/layer_tun.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// Copyright (c) 2017 Steinwurf ApS
// All Rights Reserved
//
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#pragma once

#include "../log_kind.hpp"
#include "../log_level.hpp"
Expand Down
26 changes: 16 additions & 10 deletions src/tunnel/platform_unsupported/tun_interface.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Copyright (c) 2017 Steinwurf ApS
// All Rights Reserved
//
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

#pragma once

#include "layer_tun.hpp"

Expand All @@ -12,18 +18,18 @@ struct tun_interface : public
layer_tun<
detail::layer_monitor<
detail::layer_final<tun_interface>>>
// clang-format on
{
static bool is_platform_supported()
{
return false;
}

static bool is_platform_supported()
{
return false;
}

static auto type() -> std::string
{
return "tunnel::platform_unsupported::tun_interface";
}
static auto type() -> std::string
{
return "tunnel::platform_unsupported::tun_interface";
}
};
// clang-format on

}
}
37 changes: 3 additions & 34 deletions src/tunnel/tun_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,24 @@
//
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.

// clang-format off
#include "throw_if_error.hpp"
#include "tun_interface.hpp"
// clang-format on
#include "throw_if_error.hpp"

#include <cassert>

#include <platform/config.hpp>

// Waf has some problems with this macro which means that
// in the linux/*.hpp files change. If you run
// ./waf build --zone deps you will see that the dependencies
// for this .cpp files does not include the headers if these
// #ifdef are active...
//
// #ifdef PLATFORM_LINUX

#if defined(PLATFORM_LINUX)
#include "platform_linux/tun_interface.hpp"

#include "platform_linux/tun_interface.hpp"
using platform_tun_interface = tunnel::platform_linux::tun_interface;

#else
#include "platform_unsupported/tun_interface.hpp"

#include "platform_unsupported/tun_interface.hpp"
using platform_tun_interface = tunnel::platform_unsupported::tun_interface;

#endif
// #endif

// #ifdef APPLE
// #include "platform_mac/tun_interface.hpp"

// using platform_tun_interface = tunnel::platform_mac::tun_interface;

// #endif

// #ifdef WIN32
// #include "platform_windows/tun_interface.hpp"

// using platform_tun_interface = tunnel::platform_windows::tun_interface;

// #endif

// #else

// #error "Not a supported platform"

// #endif

namespace tunnel
{
Expand Down

0 comments on commit 641ef82

Please sign in to comment.