Skip to content
Snippets Groups Projects
Commit 246238fe authored by Grigorii Demidov's avatar Grigorii Demidov Committed by Marek Vavruša
Browse files

lib/layer: avoiding usage of libknot's layer.h

parent 4fe20368
Branches
Tags
No related merge requests found
......@@ -18,7 +18,6 @@
#include "lib/defines.h"
#include "lib/utils.h"
#include "lib/resolve.h"
#ifndef NDEBUG
/** @internal Print a debug message related to resolution. */
......@@ -31,6 +30,42 @@
#define QRDEBUG(query, cls, fmt, ...)
#endif
/*! Layer processing states.
* Each state represents the state machine transition,
* and determines readiness for the next action.
*/
enum knot_layer_state {
KNOT_STATE_NOOP = 0, /*!< N/A */
KNOT_STATE_CONSUME = 1 << 0, /*!< Consume data. */
KNOT_STATE_PRODUCE = 1 << 1, /*!< Produce data. */
KNOT_STATE_DONE = 1 << 2, /*!< Finished. */
KNOT_STATE_FAIL = 1 << 3 /*!< Error. */
};
/* Forward declarations. */
struct knot_layer_api;
/*! \brief Packet processing context. */
typedef struct knot_layer {
knot_mm_t *mm; /* Processing memory context. */
uint16_t state; /* Bitmap of enum knot_layer_state. */
void *data; /* Module specific. */
const struct knot_layer_api *api;
} knot_layer_t;
/*! \brief Packet processing module API. */
struct knot_layer_api {
int (*begin)(knot_layer_t *ctx, void *module_param);
int (*reset)(knot_layer_t *ctx);
int (*finish)(knot_layer_t *ctx);
int (*consume)(knot_layer_t *ctx, knot_pkt_t *pkt);
int (*produce)(knot_layer_t *ctx, knot_pkt_t *pkt);
int (*fail)(knot_layer_t *ctx, knot_pkt_t *pkt);
void *data;
};
typedef struct knot_layer_api knot_layer_api_t;
/** Pickled layer state (api, input, state). */
struct kr_layer_pickle {
struct kr_layer_pickle *next;
......@@ -40,4 +75,4 @@ struct kr_layer_pickle {
};
/* Repurpose layer states. */
#define KNOT_STATE_YIELD KNOT_STATE_NOOP
\ No newline at end of file
#define KNOT_STATE_YIELD KNOT_STATE_NOOP
......@@ -22,6 +22,7 @@
#include "lib/layer/iterate.h"
#include "lib/cache.h"
#include "lib/module.h"
#include "lib/resolve.h"
#define DEBUG_MSG(qry, fmt...) QRDEBUG((qry), " pc ", fmt)
#define DEFAULT_MAXTTL (15 * 60)
......
......@@ -28,6 +28,7 @@
#include "lib/cache.h"
#include "lib/module.h"
#include "lib/utils.h"
#include "lib/resolve.h"
#define DEBUG_MSG(qry, fmt...) QRDEBUG((qry), " rc ", fmt)
#define DEFAULT_MINTTL (5) /* Short-time "no data" retention to avoid bursts */
......
......@@ -16,7 +16,6 @@
#pragma once
#include <libknot/processing/layer.h>
#include "lib/defines.h"
#include "lib/utils.h"
#include "lib/layer.h"
......
......@@ -17,9 +17,9 @@
#pragma once
#include <netinet/in.h>
#include <libknot/processing/layer.h>
#include <libknot/packet/pkt.h>
#include "lib/layer.h"
#include "lib/generic/map.h"
#include "lib/generic/array.h"
#include "lib/nsrep.h"
......
......@@ -15,7 +15,6 @@
*/
#include <libknot/descriptor.h>
#include <libknot/processing/layer.h>
#include <libknot/errcode.h>
#include "lib/rplan.h"
......
......@@ -24,6 +24,7 @@
#include "lib/rplan.h"
#include "lib/defines.h"
#include "lib/layer.h"
#include "lib/resolve.h"
#include "lib/generic/pack.h"
/* Root hint descriptor. */
......
......@@ -32,6 +32,7 @@
#include "lib/rplan.h"
#include "lib/module.h"
#include "lib/layer.h"
#include "lib/resolve.h"
/** @internal Compatibility wrapper for Lua < 5.2 */
#if LUA_VERSION_NUM < 502
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment