Commit 4b9ef7da authored by Daniel Salzman's avatar Daniel Salzman

contrib: move wire_ctx from internal

parent 013b079f
......@@ -53,6 +53,7 @@ src/contrib/ucw/heap.c
src/contrib/ucw/heap.h
src/contrib/ucw/mempool.c
src/contrib/ucw/mempool.h
src/contrib/wire_ctx.h
src/dnssec/Makefile.am
src/dnssec/contrib/gnutls_error.c
src/dnssec/lib/binary.c
......@@ -386,7 +387,6 @@ src/libknot/internal/trie/murmurhash3.c
src/libknot/internal/trie/murmurhash3.h
src/libknot/internal/utils.c
src/libknot/internal/utils.h
src/libknot/internal/wire_ctx.h
src/libknot/libknot.h
src/libknot/packet/compr.c
src/libknot/packet/compr.h
......
......@@ -31,6 +31,7 @@ nobase_libcontrib_la_HEADERS = \
contrib/print.h \
contrib/string.h \
contrib/tolower.h \
contrib/wire_ctx.h \
contrib/openbsd/strlcat.h \
contrib/openbsd/strlcpy.h \
contrib/ucw/array-sort.h \
......@@ -89,8 +90,7 @@ nobase_libknot_internal_la_HEADERS = \
libknot/internal/sockaddr.h \
libknot/internal/trie/hat-trie.h \
libknot/internal/trie/murmurhash3.h \
libknot/internal/utils.h \
libknot/internal/wire_ctx.h
libknot/internal/utils.h
libknot_yparser_ladir = $(includedir)
nobase_libknot_yparser_la_HEADERS = \
......
......@@ -25,12 +25,11 @@
#include "contrib/endian.h"
#include "libknot/internal/errcode.h"
#include "libknot/rdata.h"
/*!
* \brief Struct to keep the wire context.
*/
typedef struct {
typedef struct wire_ctx {
size_t size;
uint8_t *wire;
uint8_t *position;
......@@ -72,16 +71,6 @@ static inline wire_ctx_t wire_ctx_init_const(const uint8_t *data, size_t size)
return result;
}
/*!
* \brief Initialize read only wire context with rdata.
*/
static inline wire_ctx_t wire_ctx_init_rdata(const knot_rdata_t *rdata)
{
assert(rdata);
return wire_ctx_init_const(knot_rdata_data(rdata), knot_rdata_rdlen(rdata));
}
/*!
* \brief Gets actual position.
*
......
......@@ -27,6 +27,7 @@
#include "libknot/internal/sockaddr.h"
#include "libknot/yparser/yptrafo.h"
#include "contrib/string.h"
#include "contrib/wire_ctx.h"
#include "contrib/openbsd/strlcat.h"
/*! Configuration specific logging. */
......
......@@ -29,6 +29,7 @@
#include "libknot/errcode.h"
#include "libknot/yparser/yptrafo.h"
#include "contrib/openbsd/strlcpy.h"
#include "contrib/wire_ctx.h"
/*
* A simple configuration:
......
......@@ -37,6 +37,7 @@
#include "libknot/errcode.h"
#include "libknot/internal/utils.h"
#include "libknot/yparser/yptrafo.h"
#include "contrib/wire_ctx.h"
#define MAX_INCLUDE_DEPTH 5
......
......@@ -18,7 +18,6 @@
#include "dnssec/nsec.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/wire_ctx.h"
#include "knot/dnssec/nsec3-chain.h"
#include "libknot/dname.h"
#include "libknot/packet/wire.h"
......@@ -29,6 +28,7 @@
#include "knot/dnssec/zone-sign.h"
#include "knot/dnssec/zone-nsec.h"
#include "contrib/base32hex.h"
#include "contrib/wire_ctx.h"
/* - NSEC3 node comparison -------------------------------------------------- */
......
......@@ -17,10 +17,10 @@
#include "libknot/dname.h"
#include "libknot/internal/namedb/namedb.h"
#include "libknot/internal/namedb/namedb_lmdb.h"
#include "contrib/string.h"
#include "libknot/internal/wire_ctx.h"
#include "knot/zone/timers.h"
#include "knot/zone/zonedb.h"
#include "contrib/string.h"
#include "contrib/wire_ctx.h"
/* ---- Knot-internal event code to db key lookup tables ------------------ - */
......
......@@ -32,7 +32,7 @@
#include "libknot/packet/wire.h"
#include "libknot/rrset.h"
#include "libknot/rrtype/rrsig.h"
#include "libknot/internal/wire_ctx.h"
#include "contrib/wire_ctx.h"
#define RRSIG_RDATA_SIGNER_OFFSET 18
......
......@@ -26,7 +26,7 @@
#include "libknot/packet/wire.h"
#include "libknot/packet/rrset-wire.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/wire_ctx.h"
#include "contrib/wire_ctx.h"
/*! \brief Packet RR array growth step. */
#define NEXT_RR_ALIGN 16
......
......@@ -30,7 +30,7 @@
#include "libknot/rrset.h"
#include "libknot/rrtype/naptr.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/wire_ctx.h"
#include "contrib/wire_ctx.h"
#define RR_HEADER_SIZE 10
......
......@@ -33,9 +33,9 @@
#include "libknot/errcode.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/utils.h"
#include "libknot/internal/wire_ctx.h"
#include "contrib/base32hex.h"
#include "contrib/base64.h"
#include "contrib/wire_ctx.h"
#define TAB_WIDTH 8
#define BLOCK_WIDTH 40
......
......@@ -17,10 +17,9 @@
#include <assert.h>
#include <stdint.h>
#include "libknot/errcode.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/wire_ctx.h"
#include "libknot/rrtype/naptr.h"
#include "contrib/wire_ctx.h"
_public_
int knot_naptr_header_size(const uint8_t *naptr, const uint8_t *maxp)
......
......@@ -21,10 +21,9 @@
#include "libknot/rrtype/opt.h"
#include "libknot/descriptor.h"
#include "libknot/errcode.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/sockaddr.h"
#include "libknot/internal/wire_ctx.h"
#include "contrib/wire_ctx.h"
/*! \brief Some implementation-related constants. */
enum knot_edns_private_consts {
......@@ -195,7 +194,8 @@ void knot_edns_set_do(knot_rrset_t *opt_rr)
*/
static uint8_t *find_option(knot_rdata_t *rdata, uint16_t opt_code)
{
wire_ctx_t wire = wire_ctx_init_rdata(rdata);
wire_ctx_t wire = wire_ctx_init_const(knot_rdata_data(rdata),
knot_rdata_rdlen(rdata));
while (wire_ctx_available(&wire) > 0) {
uint16_t code = wire_ctx_read_u16(&wire);
......@@ -283,7 +283,8 @@ bool knot_edns_check_record(knot_rrset_t *opt_rr)
return false;
}
wire_ctx_t wire = wire_ctx_init_rdata(rdata);
wire_ctx_t wire = wire_ctx_init_const(knot_rdata_data(rdata),
knot_rdata_rdlen(rdata));
/* RFC2671 4.4: {uint16_t code, uint16_t len, data} */
// read data to the end or error
......
......@@ -29,7 +29,7 @@
#include "libknot/rrset.h"
#include "libknot/internal/macros.h"
#include "libknot/internal/utils.h"
#include "libknot/internal/wire_ctx.h"
#include "contrib/wire_ctx.h"
/*! \brief TSIG field offsets. */
typedef enum tsig_off_t {
......@@ -64,7 +64,8 @@ static uint8_t* rdata_seek(const knot_rrset_t *rr, tsig_off_t id, size_t nb)
return NULL;
}
wire_ctx_t wire = wire_ctx_init_rdata(rr_data);
wire_ctx_t wire = wire_ctx_init_const(knot_rdata_data(rr_data),
knot_rdata_rdlen(rr_data));
/* TSIG RR names should be already sanitized on parse. */
int alg_len = knot_dname_size(wire.wire);
......
......@@ -28,7 +28,6 @@
#include <stdint.h>
#include "libknot/internal/utils.h"
#include "libknot/internal/wire_ctx.h"
#include "libknot/yparser/yparser.h"
/*! Maximal length of item name. */
......@@ -44,8 +43,10 @@
/*! Maximal node stack depth. */
#define YP_MAX_NODE_DEPTH 2
#define YP_TXT_BIN_PARAMS wire_ctx_t *in, wire_ctx_t *out, const uint8_t *stop
#define YP_BIN_TXT_PARAMS wire_ctx_t *in, wire_ctx_t *out
struct wire_ctx;
#define YP_TXT_BIN_PARAMS struct wire_ctx *in, struct wire_ctx *out, const uint8_t *stop
#define YP_BIN_TXT_PARAMS struct wire_ctx *in, struct wire_ctx *out
/*! Helper macros for item variables definition. */
#define YP_VNONE .var.i = { 0 }
......
......@@ -25,6 +25,7 @@
#include "libknot/internal/sockaddr.h"
#include "libknot/libknot.h"
#include "contrib/base64.h"
#include "contrib/wire_ctx.h"
enum {
UNIT_BYTE = 'B',
......
......@@ -26,9 +26,9 @@
#include "libknot/libknot.h"
#include "libknot/internal/lists.h"
#include "libknot/internal/sockaddr.h"
#include "libknot/internal/wire_ctx.h"
#include "contrib/print.h"
#include "contrib/openbsd/strlcat.h"
#include "contrib/wire_ctx.h"
static lookup_table_t rtypes[] = {
{ KNOT_RRTYPE_A, "has IPv4 address" },
......@@ -235,7 +235,9 @@ static void print_section_opt(const knot_rrset_t *rr, const uint8_t rcode)
knot_edns_get_payload(rr),
ext_rcode_str);
wire_ctx_t wire = wire_ctx_init_rdata(knot_rdataset_at(&rr->rrs, 0));
knot_rdata_t *rdata = knot_rdataset_at(&rr->rrs, 0);
wire_ctx_t wire = wire_ctx_init_const(knot_rdata_data(rdata),
knot_rdata_rdlen(rdata));
while (wire_ctx_available(&wire) >= KNOT_EDNS_OPTION_HDRLEN) {
uint16_t opt_code = wire_ctx_read_u16(&wire);
......
......@@ -18,8 +18,8 @@
#include <netinet/in.h>
#include <stdio.h>
#include "libknot/internal/wire_ctx.h"
#include "libknot/internal/errcode.h"
#include "contrib/wire_ctx.h"
#define OK(wire) { \
is_int(KNOT_EOK, (wire)->error, "check for no error"); \
......
Markdown is supported
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