Two styles were used: (un)defined and 0/1. We switch to 0/1.
Advantage: it can be used also like `if (ENABLE_FOO)`
(outside preprocessor).
Except for ./meson.build it's sed \
-e 's/#ifdef ENABLE_CAP_NG/#if ENABLE_CAP_NG/g' \
-e 's/#ifdef ENABLE_DOH2/#if ENABLE_DOH2/g' \
-e 's/defined(ENABLE_COOKIES)/ENABLE_COOKIES/g' \
-e 's/#ifdef ENABLE_COOKIES/#if ENABLE_COOKIES/g' \
-i $(git grep -l ENABLE_)
#define LRU_REP_SIZE (LRU_RTT_SIZE / 4) /**< NS reputation cache size */
#endif
#ifndef LRU_COOKIES_SIZE
- #ifdef ENABLE_COOKIES
+ #if ENABLE_COOKIES
#define LRU_COOKIES_SIZE LRU_RTT_SIZE /**< DNS cookies cache size. */
#else
#define LRU_COOKIES_SIZE LRU_ASSOC /* simpler than guards everywhere */
#include <uv.h>
#include <libknot/packet/pkt.h>
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
#include <nghttp2/nghttp2.h>
#endif
ssize_t buf_size;
};
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
struct http_ctx* http_new(struct session *session, http_send_callback send_cb);
ssize_t http_process_input_data(struct session *session, const uint8_t *buf, ssize_t nread);
int http_write(uv_write_t *req, uv_handle_t *handle, knot_pkt_t* pkt, int32_t stream_id,
data = session_wirebuf_get_free_start(s);
data_len = consumed;
}
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
if (session_flags(s)->has_http) {
consumed = http_process_input_data(s, data, data_len);
if (consumed < 0) {
mp_flush(the_worker->pkt_pool.ctx);
}
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
static ssize_t tls_send(const uint8_t *buf, const size_t len, struct session *session)
{
struct tls_ctx *ctx = session_tls_get_server_ctx(session);
session_tls_set_server_ctx(s, ctx);
}
}
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
if (http) {
struct http_ctx *ctx = session_http_get_server_ctx(s);
if (!ctx) {
_tcp_accept(master, status, true, false);
}
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
static void https_accept(uv_stream_t *master, int status)
{
_tcp_accept(master, status, true, true);
if (ret) return ret;
if (has_tls && has_http) {
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
connection = https_accept;
#else
kr_log_error("[ io ] kresd was compiled without libnghttp2 support\n");
#include <sys/resource.h>
#include <unistd.h>
-#ifdef ENABLE_CAP_NG
+#if ENABLE_CAP_NG
#include <cap-ng.h>
#endif
/* Drop POSIX 1003.1e capabilities. */
static void drop_capabilities(void)
{
-#ifdef ENABLE_CAP_NG
+#if ENABLE_CAP_NG
/* Drop all capabilities when running under non-root user. */
if (geteuid() == 0) {
kr_log_verbose("[system] running as root, no capabilities dropped\n");
struct tls_ctx *tls_ctx; /**< server side tls-related data. */
struct tls_client_ctx *tls_client_ctx; /**< client side tls-related data. */
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
struct http_ctx *http_ctx; /**< server side http-related data. */
#endif
queue_deinit(session->waiting);
tls_free(session->tls_ctx);
tls_client_ctx_free(session->tls_client_ctx);
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
http_free(session->http_ctx);
#endif
memset(session, 0, sizeof(*session));
return tls_ctx;
}
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
struct http_ctx *session_http_get_server_ctx(const struct session *session)
{
return session->http_ctx;
wire_buffer_size += TLS_CHUNK_SIZE;
session->sflags.has_tls = true;
}
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
if (has_http) {
/* When decoding large packets,
* HTTP/2 frames can be up to 16 KB by default. */
* server and client. */
struct tls_common_ctx *session_tls_get_common_ctx(const struct session *session);
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
/** Get pointer to server-side http-related data. */
struct http_ctx *session_http_get_server_ctx(const struct session *session);
/** Set pointer to server-side http-related data. */
req->qsource.flags.tls = session_flags(session)->has_tls;
req->qsource.flags.http = session_flags(session)->has_http;
req->qsource.stream_id = -1;
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
if (req->qsource.flags.http) {
struct http_ctx *http_ctx = session_http_get_server_ctx(session);
req->qsource.stream_id = queue_head(http_ctx->streams);
/* Send using given protocol */
assert(!session_flags(session)->closing);
if (session_flags(session)->has_http) {
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
uv_write_t *write_req = (uv_write_t *)ioreq;
write_req->data = task;
ret = http_write(write_req, handle, pkt, ctx->req.qsource.stream_id, &on_write);
const bool is_outgoing = session_flags(session)->outgoing;
struct http_ctx *http_ctx = NULL;
-#ifdef ENABLE_DOH2
+#if ENABLE_DOH2
http_ctx = session_http_get_server_ctx(session);
#endif
#include <netinet/in.h>
#include <stdint.h>
-#if defined(ENABLE_COOKIES)
+#if ENABLE_COOKIES
#include <libknot/rrtype/opt.h>
#include <libknot/rrtype/opt-cookie.h>
#else
#define KNOT_OPT_COOKIE_CLNT 8
#define KNOT_OPT_COOKIE_SRVR_MAX 32
-#endif /* defined(ENABLE_COOKIES) */
+#endif /* ENABLE_COOKIES */
#include "lib/defines.h"
#include "lib/generic/lru.h"
#include "lib/layer/iterate.h"
#include "lib/dnssec/ta.h"
#include "lib/dnssec.h"
-#if defined(ENABLE_COOKIES)
+#if ENABLE_COOKIES
#include "lib/cookies/control.h"
#include "lib/cookies/helper.h"
#include "lib/cookies/nonce.h"
#else /* Define compatibility macros */
#define KNOT_EDNS_OPTION_COOKIE 10
-#endif /* defined(ENABLE_COOKIES) */
+#endif /* ENABLE_COOKIES */
#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), "resl", __VA_ARGS__)
{
pkt->opt_rr = knot_rrset_copy(req->ctx->upstream_opt_rr, &pkt->mm);
size_t wire_size = knot_edns_wire_size(pkt->opt_rr);
-#if defined(ENABLE_COOKIES)
+#if ENABLE_COOKIES
if (req->ctx->cookie_ctx.clnt.enabled ||
req->ctx->cookie_ctx.srvr.enabled) {
wire_size += KR_COOKIE_OPT_MAX_LEN;
}
-#endif /* defined(ENABLE_COOKIES) */
+#endif /* ENABLE_COOKIES */
if (req->qsource.flags.tls) {
if (req->ctx->tls_padding == -1)
/* FIXME: we do not know how to reserve space for the
return request->state;
}
-#if defined(ENABLE_COOKIES)
+#if ENABLE_COOKIES
/** Update DNS cookie data in packet. */
static bool outbound_request_update_cookies(struct kr_request *req,
const struct sockaddr *src,
return true;
}
-#endif /* defined(ENABLE_COOKIES) */
+#endif /* ENABLE_COOKIES */
int kr_resolve_checkout(struct kr_request *request, const struct sockaddr *src,
struct sockaddr *dst, int type, knot_pkt_t *packet)
}
struct kr_query *qry = array_tail(rplan->pending);
-#if defined(ENABLE_COOKIES)
+#if ENABLE_COOKIES
/* Update DNS cookies in request. */
if (type == SOCK_DGRAM) { /* @todo: Add cookies also over TCP? */
/*
return kr_error(EINVAL);
}
}
-#endif /* defined(ENABLE_COOKIES) */
+#endif /* ENABLE_COOKIES */
int ret = query_finalize(request, qry, packet);
if (ret != 0) {
libzscanner.get_pkgconfig_variable('soname'))
conf_data.set_quoted('libknot_SONAME',
libknot.get_pkgconfig_variable('soname'))
-conf_data.set('ENABLE_LIBSYSTEMD', libsystemd.found() ? 1 : 0)
+conf_data.set('ENABLE_LIBSYSTEMD', libsystemd.found().to_int())
conf_data.set('NOVERBOSELOG', not verbose_log)
conf_data.set('ENABLE_SENDMMSG', sendmmsg.to_int())
-conf_data.set('ENABLE_CAP_NG', capng.found())
-conf_data.set('ENABLE_DOH2', nghttp2.found())
+conf_data.set('ENABLE_CAP_NG', capng.found().to_int())
+conf_data.set('ENABLE_DOH2', nghttp2.found().to_int())
kresconfig = configure_file(
output: 'kresconfig.h',