]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/layer: avoiding usage of libknot's layer.h
authorGrigorii Demidov <grigorii.demidov@nic.cz>
Fri, 8 Jul 2016 11:38:31 +0000 (13:38 +0200)
committerMarek Vavrusa <marek@vavrusa.com>
Tue, 12 Jul 2016 17:02:48 +0000 (12:02 -0500)
lib/layer.h
lib/layer/pktcache.c
lib/layer/rrcache.c
lib/module.h
lib/resolve.h
lib/rplan.c
lib/zonecut.c
modules/stats/stats.c

index 3d1d536a3e602e7b9b626f64d0252edd3966d383..85f95100cc7345c17690dafaf9fcb992220fd65c 100644 (file)
@@ -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. */
  #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
index 95fcff6c7735df93cf5e0923df646f0af7dc0804..2eb8e652fc25c352d5b1ac32e3b856e7c7c9a76b 100644 (file)
@@ -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)
index 946e704686d2e3529d30bb63e5341fc3d726b11f..358adf380c472ea3bfada8b6527b0481000176ce 100644 (file)
@@ -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 */
index 027201849153a6c79c797d141b4d9bf5bafca2ed..0da311a9d10a1df14e0e507bc3d69e6d9c546ff8 100644 (file)
@@ -16,7 +16,6 @@
 
 #pragma once
 
-#include <libknot/processing/layer.h>
 #include "lib/defines.h"
 #include "lib/utils.h"
 #include "lib/layer.h"
index 563d85219dad8b4c6db1272ec3d43dc932a2365e..b1660a28c53b49a71bf48c7115c791c5a45c3300 100644 (file)
@@ -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"
index 6eb52a0dca747debf0740200cf1dca6f3a0f9301..4c8ca86b887331c5384b37404c05251f4d660b6d 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include <libknot/descriptor.h>
-#include <libknot/processing/layer.h>
 #include <libknot/errcode.h>
 
 #include "lib/rplan.h"
index 2aec10366f48db8ef0b171e18e8ce9f67c82e007..ce11877a86ffb52d8931d7e328e0bf542d1db0a8 100644 (file)
@@ -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. */
index 7cd8b84a5de7f7010b76e8cbe9a9169a4f3fc0d2..777633f78ba82cdea1980529f9d0a6e60476bdb0 100644 (file)
@@ -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