2022-07-28 16:07:38 +00:00
|
|
|
#pragma once
|
|
|
|
#include <functional>
|
|
|
|
#include <vector>
|
|
|
|
#include <llarp/util/types.hpp>
|
|
|
|
|
|
|
|
namespace llarp::vpn
|
|
|
|
{
|
|
|
|
using PacketSendFunc_t = std::function<void(std::vector<byte_t>)>;
|
|
|
|
using PacketInterceptFunc_t = std::function<void(std::vector<byte_t>, PacketSendFunc_t)>;
|
|
|
|
|
2022-09-13 15:04:53 +00:00
|
|
|
class I_PacketInterceptor
|
2022-07-28 16:07:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-09-13 15:04:53 +00:00
|
|
|
virtual ~I_PacketInterceptor() = default;
|
2022-07-28 16:07:38 +00:00
|
|
|
|
|
|
|
/// start intercepting packets and call a callback for each one we get
|
|
|
|
/// the callback passes in an ip packet and a function that we can use to send an ip packet to
|
|
|
|
/// its origin
|
|
|
|
virtual void
|
|
|
|
start(PacketInterceptFunc_t f) = 0;
|
|
|
|
|
|
|
|
/// stop intercepting packets
|
|
|
|
virtual void
|
|
|
|
stop() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace llarp::vpn
|