#pragma once
#include "common.hpp"
#include "net.hpp"
#include "nfq.hpp" // for result struct only


class Match {
    private:
        Match* const next;

    protected:
        Match(Match*, size_t, size_t);
        virtual bool is_valid() const = 0;
        virtual void run(packet_t*, size_t, NFQ::result_t&) = 0;
        const size_t mymin, mymax;
        size_t min, max;

    public:
        static Match* parse(Match*, const char*, size_t);
        virtual ~Match();
        bool runall(packet_t*, size_t, NFQ::result_t&); ///< returns false if never to be called again for this stream (neither side)
};


void register_match(const char*, Match*(*)(Match*, const char*, size_t));
#define REGISTER_MATCH(name, getinst) static __attribute__((unused)) int CONCAT(register_match_, __LINE__) = (register_match(name, getinst), 1)