Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
23
Issues
23
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
96b10e16
Commit
96b10e16
authored
Oct 30, 2015
by
Daniel Salzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conf: add dynamic interface
parent
01e26ce6
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1671 additions
and
3 deletions
+1671
-3
Knot.files
Knot.files
+2
-0
src/Makefile.am
src/Makefile.am
+2
-0
src/knot/conf/confio.c
src/knot/conf/confio.c
+1418
-0
src/knot/conf/confio.h
src/knot/conf/confio.h
+233
-0
src/knot/server/server.c
src/knot/server/server.c
+7
-0
src/libknot/errcode.c
src/libknot/errcode.c
+6
-3
src/libknot/internal/errcode.h
src/libknot/internal/errcode.h
+3
-0
No files found.
Knot.files
View file @
96b10e16
...
...
@@ -197,6 +197,8 @@ src/knot/conf/conf.c
src/knot/conf/conf.h
src/knot/conf/confdb.c
src/knot/conf/confdb.h
src/knot/conf/confio.c
src/knot/conf/confio.h
src/knot/conf/scheme.c
src/knot/conf/scheme.h
src/knot/conf/tools.c
...
...
src/Makefile.am
View file @
96b10e16
...
...
@@ -213,6 +213,8 @@ libknotd_la_SOURCES = \
knot/conf/conf.h
\
knot/conf/confdb.c
\
knot/conf/confdb.h
\
knot/conf/confio.c
\
knot/conf/confio.h
\
knot/conf/scheme.c
\
knot/conf/scheme.h
\
knot/conf/tools.c
\
...
...
src/knot/conf/confio.c
0 → 100644
View file @
96b10e16
This diff is collapsed.
Click to expand it.
src/knot/conf/confio.h
0 → 100644
View file @
96b10e16
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file
*
* Configuration interface.
*
* \addtogroup config
*
* @{
*/
#pragma once
#include "knot/conf/conf.h"
/*! Configuration interface output. */
typedef
struct
conf_io
conf_io_t
;
struct
conf_io
{
/*! Section. */
const
yp_item_t
*
key0
;
/*! Section item. */
const
yp_item_t
*
key1
;
/*! Section identifier. */
const
uint8_t
*
id
;
/*! Section identifier length. */
size_t
id_len
;
/*! Consider item identifier as item data. */
bool
id_as_data
;
enum
{
/*! Default item state. */
NONE
,
/*! New item indicator. */
NEW
,
/*! Old item indicator. */
OLD
}
type
;
struct
{
/*! Section item data (NULL if not used). */
conf_val_t
*
val
;
/*! Index of data value to format (counted from 1, 0 means all). */
size_t
index
;
/*! Binary data value (NULL if not used). */
const
uint8_t
*
bin
;
/*! Length of the binary data value. */
size_t
bin_len
;
}
data
;
struct
{
/*! Edit operation return code. */
int
code
;
/*! Edit operation return error message. */
const
char
*
str
;
}
error
;
/*! Optional processing callback. */
int
(
*
fcn
)(
conf_io_t
*
);
/*! Miscellaneous data useful for the callback. */
void
*
misc
;
};
/*!
* Starts new writing transaction.
*
* \param[in] child Nested transaction indicator.
*
* \return Error code, KNOT_EOK if success.
*/
int
conf_io_begin
(
bool
child
);
/*!
* Commits the current writing transaction.
*
* \param[in] child Nested transaction indicator.
*
* \return Error code, KNOT_EOK if success.
*/
int
conf_io_commit
(
bool
child
);
/*!
* Aborts the current writing transaction.
*
* \param[in] child Nested transaction indicator.
*
* \return Error code, KNOT_EOK if success.
*/
int
conf_io_abort
(
bool
child
);
/*!
* Gets the configuration group item subsection list.
*
* \param[in] key0 Section name (NULL to get section list).
* \param[out] io Operation output.
*
* \return Error code, KNOT_EOK if success.
*/
int
conf_io_desc
(
const
char
*
key0
,
conf_io_t
*
io
);
/*!
* Gets the configuration difference between the current configuration and
* the active transaction.
*
* \param[in] key0 Section name (NULL to diff all sections).
* \param[in] key1 Item name (NULL to diff all section items).
* \param[in] id Section identifier name (NULL to consider all section identifiers).
* \param[out] io Operation output.
*
* \return Error code, KNOT_EOK if success.
*/
int
conf_io_diff
(
const
char
*
key0
,
const
char
*
key1
,
const
char
*
id
,
conf_io_t
*
io
);
/*!
* Gets the configuration item(s) value(s).
*
* \param[in] key0 Section name (NULL to get all sections).
* \param[in] key1 Item name (NULL to get all section items).
* \param[in] id Section identifier name (NULL to consider all section identifiers).
* \param[in] get_current The current configuration or the active transaction switch.
* \param[out] io Operation output.
*
* \return Error code, KNOT_EOK if success.
*/
int
conf_io_get
(
const
char
*
key0
,
const
char
*
key1
,
const
char
*
id
,
bool
get_current
,
conf_io_t
*
io
);
/*!
* Sets the configuration item(s) value.
*
* \param[in] key0 Section name.
* \param[in] key1 Item name (NULL to add identifier only).
* \param[in] id Section identifier name (NULL to consider all section identifiers).
* \param[in] data Item data to set/add.
* \param[out] io Operation output (callback error output).
*
* \return Error code, KNOT_EOK if success.
*/
int
conf_io_set
(
const
char
*
key0
,
const
char
*
key1
,
const
char
*
id
,
const
char
*
data
,
conf_io_t
*
io
);
/*!
* Unsets the configuration item(s) value(s).
*
* \param[in] key0 Section name (NULL to unset all sections).
* \param[in] key1 Item name (NULL to unset the whole section).
* \param[in] id Section identifier name (NULL to consider all section identifiers).
* \param[in] data Item data (NULL to unset all data).
*
* \return Error code, KNOT_EOK if success.
*/
int
conf_io_unset
(
const
char
*
key0
,
const
char
*
key1
,
const
char
*
id
,
const
char
*
data
);
/*!
* Checks the configuration database semantics in the current writing transaction.
*
* \param[out] io Operation output.
*
* \return Error code, KNOT_EOK if success.
*/
int
conf_io_check
(
conf_io_t
*
io
);
/*!
* Returns textual item key part of the operation result.
*
* \note The result must be deallocated.
*
* \param[out] io Operation output.
*
* \return String or NULL.
*/
char
*
conf_io_txt_key
(
conf_io_t
*
io
);
/*!
* Returns textual item data part of the operation result.
*
* \note The result must be deallocated.
*
* \param[out] io Operation output.
*
* \return String or NULL.
*/
char
*
conf_io_txt_data
(
conf_io_t
*
io
);
/*! @} */
src/knot/server/server.c
View file @
96b10e16
...
...
@@ -482,7 +482,14 @@ int server_reload(server_t *server, const char *cf)
}
if
(
cf
!=
NULL
)
{
// Check for no edit mode.
if
(
conf
()
->
io
.
txn
!=
NULL
)
{
log_warning
(
"reload aborted due to active config DB transaction"
);
return
KNOT_CONF_ETXN
;
}
log_info
(
"reloading configuration file '%s'"
,
cf
);
conf_t
*
new_conf
=
NULL
;
int
ret
=
conf_clone
(
&
new_conf
);
if
(
ret
!=
KNOT_EOK
)
{
...
...
src/libknot/errcode.c
View file @
96b10e16
...
...
@@ -133,9 +133,12 @@ static const struct error errors[] = {
{
KNOT_YP_ENOID
,
"missing identifier"
},
/* Configuration errors. */
{
KNOT_CONF_EMPTY
,
"empty configuration database"
},
{
KNOT_CONF_EVERSION
,
"invalid configuration database version"
},
{
KNOT_CONF_EREDEFINE
,
"duplicate identifier"
},
{
KNOT_CONF_EMPTY
,
"empty configuration database"
},
{
KNOT_CONF_EVERSION
,
"invalid configuration database version"
},
{
KNOT_CONF_EREDEFINE
,
"duplicate identifier"
},
{
KNOT_CONF_ETXN
,
"failed to open another config DB transaction"
},
{
KNOT_CONF_ENOTXN
,
"no active config DB transaction"
},
{
KNOT_CONF_EMANYTXN
,
"too many nested config DB transactions"
},
/* Processing errors. */
{
KNOT_LAYER_ERROR
,
"processing layer error"
},
...
...
src/libknot/internal/errcode.h
View file @
96b10e16
...
...
@@ -140,6 +140,9 @@ enum knot_error {
KNOT_CONF_EMPTY
,
KNOT_CONF_EVERSION
,
KNOT_CONF_EREDEFINE
,
KNOT_CONF_ETXN
,
KNOT_CONF_ENOTXN
,
KNOT_CONF_EMANYTXN
,
/* Processing error. */
KNOT_LAYER_ERROR
,
...
...
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