Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot Resolver
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
142
Issues
142
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Knot projects
Knot Resolver
Commits
daa89fe8
Commit
daa89fe8
authored
May 06, 2015
by
Marek Vavruša
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/modules: layer() api now accept module name
module api can now store userdata, e.g. owner
parent
067f4d02
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
24 deletions
+20
-24
lib/layer/iterate.c
lib/layer/iterate.c
+1
-1
lib/layer/iterate.h
lib/layer/iterate.h
+1
-4
lib/layer/pktcache.c
lib/layer/pktcache.c
+1
-1
lib/layer/rrcache.c
lib/layer/rrcache.c
+1
-1
lib/layer/rrcache.h
lib/layer/rrcache.h
+1
-1
lib/module.h
lib/module.h
+2
-2
lib/resolve.c
lib/resolve.c
+1
-1
modules/README.rst
modules/README.rst
+3
-3
modules/gostats/gostats.go
modules/gostats/gostats.go
+1
-1
modules/hints/hints.c
modules/hints/hints.c
+8
-9
No files found.
lib/layer/iterate.c
View file @
daa89fe8
...
...
@@ -442,7 +442,7 @@ static int resolve(knot_layer_t *ctx, knot_pkt_t *pkt)
}
/** Module implementation. */
const
knot_layer_api_t
*
iterate_layer
(
void
)
const
knot_layer_api_t
*
iterate_layer
(
struct
kr_module
*
module
)
{
static
const
knot_layer_api_t
_layer
=
{
.
begin
=
&
begin
,
...
...
lib/layer/iterate.h
View file @
daa89fe8
...
...
@@ -19,9 +19,6 @@
#include "lib/layer.h"
#include "lib/rplan.h"
/* Processing module implementation. */
extern
const
knot_layer_api_t
*
iterate_layer
(
void
);
/* Packet classification. */
enum
{
PKT_NOERROR
=
1
<<
0
,
/* Positive response */
...
...
@@ -34,4 +31,4 @@ enum {
int
kr_response_classify
(
knot_pkt_t
*
pkt
);
/* Processing module implementation. */
const
knot_layer_api_t
*
iterate_layer
(
void
);
\ No newline at end of file
const
knot_layer_api_t
*
iterate_layer
(
struct
kr_module
*
module
);
\ No newline at end of file
lib/layer/pktcache.c
View file @
daa89fe8
...
...
@@ -148,7 +148,7 @@ static int stash(knot_layer_t *ctx)
}
/** Module implementation. */
const
knot_layer_api_t
*
pktcache_layer
(
void
)
const
knot_layer_api_t
*
pktcache_layer
(
struct
kr_module
*
module
)
{
static
const
knot_layer_api_t
_layer
=
{
.
begin
=
&
begin
,
...
...
lib/layer/rrcache.c
View file @
daa89fe8
...
...
@@ -247,7 +247,7 @@ static int stash(knot_layer_t *ctx, knot_pkt_t *pkt)
}
/** Module implementation. */
const
knot_layer_api_t
*
rrcache_layer
(
void
)
const
knot_layer_api_t
*
rrcache_layer
(
struct
kr_module
*
module
)
{
static
const
knot_layer_api_t
_layer
=
{
.
begin
=
&
begin
,
...
...
lib/layer/rrcache.h
View file @
daa89fe8
...
...
@@ -19,4 +19,4 @@
#include "lib/layer.h"
/* Processing module implementation. */
extern
const
knot_layer_api_t
*
rrcache_layer
(
void
);
const
knot_layer_api_t
*
rrcache_layer
(
struct
kr_module
*
module
);
lib/module.h
View file @
daa89fe8
...
...
@@ -34,10 +34,10 @@ typedef uint32_t (module_api_cb)(void);
typedef
int
(
module_init_cb
)(
struct
kr_module
*
);
typedef
int
(
module_deinit_cb
)(
struct
kr_module
*
);
typedef
int
(
module_config_cb
)(
struct
kr_module
*
,
const
char
*
);
typedef
const
knot_layer_api_t
*
(
module_layer_cb
)(
void
);
typedef
const
knot_layer_api_t
*
(
module_layer_cb
)(
struct
kr_module
*
);
typedef
struct
kr_prop
*
(
module_prop_cb
)(
void
);
typedef
char
*
(
kr_prop_cb
)(
void
*
,
struct
kr_module
*
,
const
char
*
);
#define KR_MODULE_API ((uint32_t) 0x2015040
1
)
#define KR_MODULE_API ((uint32_t) 0x2015040
2
)
/* @endcond */
/**
...
...
lib/resolve.c
View file @
daa89fe8
...
...
@@ -61,7 +61,7 @@ static void prepare_layers(struct kr_request *param)
for
(
size_t
i
=
0
;
i
<
ctx
->
modules
->
len
;
++
i
)
{
struct
kr_module
*
mod
=
&
ctx
->
modules
->
at
[
i
];
if
(
mod
->
layer
)
{
knot_overlay_add
(
&
param
->
overlay
,
mod
->
layer
(),
param
);
knot_overlay_add
(
&
param
->
overlay
,
mod
->
layer
(
mod
),
param
);
}
}
}
...
...
modules/README.rst
View file @
daa89fe8
...
...
@@ -30,11 +30,11 @@ A module is a shared library defining specific functions, here's an overview of
.. csv-table::
:header: "C", "Go", "Params", "Comment"
"``X_api()`` [#]_", "``Api()``",
"", "Implemented API (``uint32_t``)"
"``X_api()`` [#]_", "``Api()``", "", "Implemented API (``uint32_t``)"
"``X_init()``", "``Init()``", "``module``", "Constructor"
"``X_deinit()``", "``Deinit()``", "``module, key``", "Destructor"
"``X_config()``", "``Config()``", "``module``", "Configuration"
"``X_layer()``", "``Layer()``", "
",
":ref:`Module layer <lib-layers>`"
"``X_layer()``", "``Layer()``", "
``module``",
":ref:`Module layer <lib-layers>`"
"``X_props()``", "``Props()``", "", "NULL-terminated list of properties"
.. [#] Mandatory symbol.
...
...
@@ -170,7 +170,7 @@ Now we can add the implementations for the ``Begin`` and ``Finish`` functions, a
return 0
}
func Layer() *C.knot_layer_api_t {
func Layer(
module *C.struct_kr_module
) *C.knot_layer_api_t {
// Wrapping the inline trampoline function
return C._layer()
}
...
...
modules/gostats/gostats.go
View file @
daa89fe8
...
...
@@ -41,6 +41,6 @@ func Finish(ctx *C.knot_layer_t) C.int {
return
0
}
func
Layer
()
*
C
.
knot_layer_api_t
{
func
Layer
(
module
*
C
.
struct_kr_module
)
*
C
.
knot_layer_api_t
{
return
C
.
_layer
()
}
modules/hints/hints.c
View file @
daa89fe8
...
...
@@ -36,9 +36,6 @@
#define DEFAULT_FILE "/etc/hosts"
#define DEBUG_MSG(qry, fmt...) QRDEBUG(qry, "hint", fmt)
/** @todo Hack until layers can store userdata. */
static
struct
kr_zonecut
*
g_map
=
NULL
;
static
int
begin
(
knot_layer_t
*
ctx
,
void
*
module_param
)
{
ctx
->
data
=
module_param
;
...
...
@@ -78,7 +75,6 @@ static int answer_query(knot_pkt_t *pkt, pack_t *addr_set, struct kr_request *pa
static
int
query
(
knot_layer_t
*
ctx
,
knot_pkt_t
*
pkt
)
{
assert
(
pkt
&&
ctx
);
struct
kr_request
*
param
=
ctx
->
data
;
struct
kr_query
*
qry
=
kr_rplan_current
(
&
param
->
rplan
);
if
(
!
qry
||
ctx
->
state
&
(
KNOT_STATE_DONE
|
KNOT_STATE_FAIL
))
{
...
...
@@ -89,7 +85,9 @@ static int query(knot_layer_t *ctx, knot_pkt_t *pkt)
}
/* Find a matching name */
pack_t
*
pack
=
kr_zonecut_find
(
g_map
,
qry
->
sname
);
struct
kr_module
*
module
=
ctx
->
api
->
data
;
struct
kr_zonecut
*
hint_map
=
module
->
data
;
pack_t
*
pack
=
kr_zonecut_find
(
hint_map
,
qry
->
sname
);
if
(
!
pack
||
pack
->
len
==
0
)
{
return
ctx
->
state
;
}
...
...
@@ -182,7 +180,6 @@ static int load(struct kr_module *module, const char *path)
struct
kr_zonecut
*
hints
=
mm_alloc
(
pool
,
sizeof
(
*
hints
));
kr_zonecut_init
(
hints
,
(
const
uint8_t
*
)(
""
),
pool
);
module
->
data
=
hints
;
g_map
=
hints
;
return
load_map
(
hints
,
fp
);
}
...
...
@@ -268,12 +265,14 @@ static char* hint_get(void *env, struct kr_module *module, const char *args)
* Module implementation.
*/
const
knot_layer_api_t
*
hints_layer
(
void
)
const
knot_layer_api_t
*
hints_layer
(
struct
kr_module
*
module
)
{
static
const
knot_layer_api_t
_layer
=
{
static
knot_layer_api_t
_layer
=
{
.
begin
=
&
begin
,
.
produce
=
&
query
.
produce
=
&
query
,
};
/* Store module reference */
_layer
.
data
=
module
;
return
&
_layer
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment