Commit 243db75e authored by Mark Karpilovskij's avatar Mark Karpilovskij Committed by Daniel Salzman

libknot: move wire.h from contrib to libknot

parent 8c72abd6
......@@ -61,7 +61,6 @@ src/contrib/ucw/lists.c
src/contrib/ucw/lists.h
src/contrib/ucw/mempool.c
src/contrib/ucw/mempool.h
src/contrib/wire.h
src/contrib/wire_ctx.h
src/dnssec/contrib/gnutls_error.c
src/dnssec/contrib/vpool.c
......@@ -387,6 +386,7 @@ src/libknot/tsig-op.c
src/libknot/tsig-op.h
src/libknot/tsig.c
src/libknot/tsig.h
src/libknot/wire.h
src/libknot/yparser/yparser.c
src/libknot/yparser/yparser.h
src/libknot/yparser/ypbody.c
......@@ -483,7 +483,6 @@ tests/contrib/test_sockaddr.c
tests/contrib/test_string.c
tests/contrib/test_strtonum.c
tests/contrib/test_time.c
tests/contrib/test_wire.c
tests/contrib/test_wire_ctx.c
tests/libknot/test_control.c
tests/libknot/test_cookies.c
......@@ -500,6 +499,7 @@ tests/libknot/test_rdataset.c
tests/libknot/test_rrset-wire.c
tests/libknot/test_rrset.c
tests/libknot/test_tsig.c
tests/libknot/test_wire.c
tests/libknot/test_yparser.c
tests/libknot/test_ypschema.c
tests/libknot/test_yptrafo.c
......
......@@ -63,7 +63,6 @@ libcontrib_la_SOURCES = \
contrib/time.h \
contrib/tolower.h \
contrib/trim.h \
contrib/wire.h \
contrib/wire_ctx.h \
contrib/openbsd/siphash.c \
contrib/openbsd/siphash.h \
......@@ -133,6 +132,7 @@ nobase_libknot_la_HEADERS = \
libknot/rrtype/txt.h \
libknot/tsig-op.h \
libknot/tsig.h \
libknot/wire.h \
libknot/yparser/yparser.h \
libknot/yparser/ypformat.h \
libknot/yparser/ypschema.h \
......
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -18,7 +18,6 @@
#include <stdint.h>
#include "contrib/wire.h"
#include "contrib/wire_ctx.h"
#include "dnssec/random.h"
#include "knot/conf/conf.h"
......
......@@ -62,5 +62,6 @@
#include "libknot/rrtype/soa.h"
#include "libknot/rrtype/tsig.h"
#include "libknot/rrtype/txt.h"
#include "libknot/wire.h"
/*! @} */
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -27,8 +27,8 @@
#include "libknot/tsig-op.h"
#include "libknot/packet/wire.h"
#include "libknot/packet/rrset-wire.h"
#include "libknot/wire.h"
#include "contrib/mempattern.h"
#include "contrib/wire.h"
#include "contrib/wire_ctx.h"
/*! \brief Packet RR array growth step. */
......@@ -459,7 +459,7 @@ uint16_t knot_pkt_qtype(const knot_pkt_t *pkt)
}
unsigned off = KNOT_WIRE_HEADER_SIZE + pkt->qname_size;
return wire_read_u16(pkt->wire + off);
return knot_wire_read_u16(pkt->wire + off);
}
_public_
......@@ -470,7 +470,7 @@ uint16_t knot_pkt_qclass(const knot_pkt_t *pkt)
}
unsigned off = KNOT_WIRE_HEADER_SIZE + pkt->qname_size + sizeof(uint16_t);
return wire_read_u16(pkt->wire + off);
return knot_wire_read_u16(pkt->wire + off);
}
_public_
......
......@@ -31,8 +31,8 @@
#include "libknot/rrset.h"
#include "libknot/rrtype/naptr.h"
#include "libknot/rrtype/rrsig.h"
#include "libknot/wire.h"
#include "contrib/macros.h"
#include "contrib/wire.h"
#include "contrib/wire_ctx.h"
#define RR_HEADER_SIZE 10
......@@ -503,7 +503,7 @@ static int write_rdata(const knot_rrset_t *rrset, uint16_t rrset_index,
/* Write final RDLENGTH */
size_t rdlength = *dst - wire_rdata_begin;
wire_write_u16(wire_rdlength, rdlength);
knot_wire_write_u16(wire_rdlength, rdlength);
return KNOT_EOK;
}
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -18,100 +18,100 @@
#include "libknot/attribute.h"
#include "libknot/packet/wire.h"
#include "contrib/wire.h"
#include "libknot/wire.h"
_public_
uint16_t knot_wire_get_id(const uint8_t *packet)
{
return wire_read_u16(packet + KNOT_WIRE_OFFSET_ID);
return knot_wire_read_u16(packet + KNOT_WIRE_OFFSET_ID);
}
_public_
void knot_wire_set_id(uint8_t *packet, uint16_t id)
{
wire_write_u16(packet + KNOT_WIRE_OFFSET_ID, id);
knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_ID, id);
}
_public_
uint16_t knot_wire_get_qdcount(const uint8_t *packet)
{
return wire_read_u16(packet + KNOT_WIRE_OFFSET_QDCOUNT);
return knot_wire_read_u16(packet + KNOT_WIRE_OFFSET_QDCOUNT);
}
_public_
void knot_wire_set_qdcount(uint8_t *packet, uint16_t qdcount)
{
wire_write_u16(packet + KNOT_WIRE_OFFSET_QDCOUNT, qdcount);
knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_QDCOUNT, qdcount);
}
_public_
void knot_wire_add_qdcount(uint8_t *packet, int16_t n)
{
wire_write_u16(packet + KNOT_WIRE_OFFSET_QDCOUNT,
knot_wire_get_qdcount(packet) + n);
knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_QDCOUNT,
knot_wire_get_qdcount(packet) + n);
}
_public_
uint16_t knot_wire_get_ancount(const uint8_t *packet)
{
return wire_read_u16(packet + KNOT_WIRE_OFFSET_ANCOUNT);
return knot_wire_read_u16(packet + KNOT_WIRE_OFFSET_ANCOUNT);
}
_public_
void knot_wire_set_ancount(uint8_t *packet, uint16_t ancount)
{
wire_write_u16(packet + KNOT_WIRE_OFFSET_ANCOUNT, ancount);
knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_ANCOUNT, ancount);
}
_public_
void knot_wire_add_ancount(uint8_t *packet, int16_t n)
{
wire_write_u16(packet + KNOT_WIRE_OFFSET_ANCOUNT,
knot_wire_get_ancount(packet) + n);
knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_ANCOUNT,
knot_wire_get_ancount(packet) + n);
}
_public_
uint16_t knot_wire_get_nscount(const uint8_t *packet)
{
return wire_read_u16(packet + KNOT_WIRE_OFFSET_NSCOUNT);
return knot_wire_read_u16(packet + KNOT_WIRE_OFFSET_NSCOUNT);
}
_public_
void knot_wire_set_nscount(uint8_t *packet, uint16_t nscount)
{
wire_write_u16(packet + KNOT_WIRE_OFFSET_NSCOUNT, nscount);
knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_NSCOUNT, nscount);
}
_public_
void knot_wire_add_nscount(uint8_t *packet, int16_t n)
{
wire_write_u16(packet + KNOT_WIRE_OFFSET_NSCOUNT,
knot_wire_get_nscount(packet) + n);
knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_NSCOUNT,
knot_wire_get_nscount(packet) + n);
}
_public_
uint16_t knot_wire_get_arcount(const uint8_t *packet)
{
return wire_read_u16(packet + KNOT_WIRE_OFFSET_ARCOUNT);
return knot_wire_read_u16(packet + KNOT_WIRE_OFFSET_ARCOUNT);
}
_public_
void knot_wire_set_arcount(uint8_t *packet, uint16_t arcount)
{
wire_write_u16(packet + KNOT_WIRE_OFFSET_ARCOUNT, arcount);
knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_ARCOUNT, arcount);
}
_public_
void knot_wire_add_arcount(uint8_t *packet, int16_t n)
{
wire_write_u16(packet + KNOT_WIRE_OFFSET_ARCOUNT,
knot_wire_get_arcount(packet) + n);
knot_wire_write_u16(packet + KNOT_WIRE_OFFSET_ARCOUNT,
knot_wire_get_arcount(packet) + n);
}
_public_
void knot_wire_put_pointer(uint8_t *pos, uint16_t ptr)
{
wire_write_u16(pos, ptr); // Write pointer offset.
knot_wire_write_u16(pos, ptr); // Write pointer offset.
assert((pos[0] & KNOT_WIRE_PTR) == 0); // Check for maximal offset.
pos[0] |= KNOT_WIRE_PTR; // Add pointer mark.
}
......@@ -120,7 +120,7 @@ _public_
uint16_t knot_wire_get_pointer(const uint8_t *pos)
{
assert(knot_wire_is_pointer(pos)); // Check pointer.
return (wire_read_u16(pos) - KNOT_WIRE_PTR_BASE); // Return offset.
return (knot_wire_read_u16(pos) - KNOT_WIRE_PTR_BASE); // Return offset.
}
/*! @} */
......@@ -35,10 +35,10 @@
#include "libknot/errcode.h"
#include "libknot/lookup.h"
#include "libknot/rrtype/rrsig.h"
#include "libknot/wire.h"
#include "contrib/base32hex.h"
#include "contrib/base64.h"
#include "contrib/ctype.h"
#include "contrib/wire.h"
#include "contrib/wire_ctx.h"
#define RRSET_DUMP_LIMIT (2 * 1024 * 1024)
......@@ -139,7 +139,7 @@ static void wire_num16_to_str(rrset_dump_params_t *p)
CHECK_INMAX(in_len)
// Fill in input data.
data = wire_read_u16(p->in);
data = knot_wire_read_u16(p->in);
// Write number.
int ret = snprintf(p->out, p->out_max, "%u", data);
......@@ -165,7 +165,7 @@ static void wire_num32_to_str(rrset_dump_params_t *p)
CHECK_INMAX(in_len)
// Fill in input data.
data = wire_read_u32(p->in);
data = knot_wire_read_u32(p->in);
// Write number.
int ret = snprintf(p->out, p->out_max, "%u", data);
......@@ -191,7 +191,7 @@ static void wire_num48_to_str(rrset_dump_params_t *p)
CHECK_INMAX(in_len)
// Fill in input data.
data = wire_read_u48(p->in);
data = knot_wire_read_u48(p->in);
// Write number.
int ret = snprintf(p->out, p->out_max, "%"PRIu64"", data);
......@@ -335,7 +335,7 @@ static int num48_encode(const uint8_t *in,
return -1;
}
uint64_t data = wire_read_u48(in);
uint64_t data = knot_wire_read_u48(in);
int ret = snprintf((char *)out, out_len, "%"PRIu64"", data);
if (ret <= 0 || (size_t)ret >= out_len) {
......@@ -436,10 +436,10 @@ static void wire_len_data_encode_to_str(rrset_dump_params_t *p,
in_len = *(p->in);
break;
case 2:
in_len = wire_read_u16(p->in);
in_len = knot_wire_read_u16(p->in);
break;
case 4:
in_len = wire_read_u32(p->in);
in_len = knot_wire_read_u32(p->in);
break;
default:
p->ret = -1;
......@@ -861,7 +861,7 @@ static void wire_apl_to_str(rrset_dump_params_t *p)
CHECK_INMAX(4)
// Read fixed size values.
uint16_t family = wire_read_u16(p->in);
uint16_t family = knot_wire_read_u16(p->in);
uint8_t prefix = *(p->in + 2);
uint8_t negation = *(p->in + 3) >> 7;
uint8_t afdlen = *(p->in + 3) & 0x7F;
......@@ -1172,7 +1172,7 @@ static void wire_tsig_rcode_to_str(rrset_dump_params_t *p)
CHECK_INMAX(in_len)
// Fill in input data.
data = wire_read_u16(p->in);
data = knot_wire_read_u16(p->in);
// Find RCODE name.
const knot_lookup_t *rcode = NULL;
......
/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -16,11 +16,11 @@
#include "libknot/attribute.h"
#include "libknot/rrtype/dnskey.h"
#include "contrib/wire.h"
#include "libknot/wire.h"
_public_
uint16_t knot_dnskey_flags(const knot_rdataset_t *rrs, size_t pos)
{
KNOT_RDATASET_CHECK(rrs, pos, return 0);
return wire_read_u16(knot_rdata_offset(rrs, pos, 0));
return knot_wire_read_u16(knot_rdata_offset(rrs, pos, 0));
}
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -15,13 +15,13 @@
*/
#include "libknot/rrtype/ds.h"
#include "contrib/wire.h"
#include "libknot/wire.h"
_public_
uint16_t knot_ds_key_tag(const knot_rdataset_t *rrs, size_t pos)
{
KNOT_RDATASET_CHECK(rrs, pos, return 0);
return wire_read_u16(knot_rdata_offset(rrs, pos, 0));
return knot_wire_read_u16(knot_rdata_offset(rrs, pos, 0));
}
_public_
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -18,13 +18,13 @@
#include "libknot/attribute.h"
#include "libknot/rrtype/nsec3.h"
#include "contrib/wire.h"
#include "libknot/wire.h"
_public_
uint16_t knot_nsec3_iterations(const knot_rdataset_t *rrs, size_t pos)
{
KNOT_RDATASET_CHECK(rrs, pos, return 0);
return wire_read_u16(knot_rdata_offset(rrs, pos, 2));
return knot_wire_read_u16(knot_rdata_offset(rrs, pos, 2));
}
_public_
......
/* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -17,8 +17,8 @@
#include "libknot/attribute.h"
#include "libknot/rrtype/nsec3param.h"
#include "libknot/errcode.h"
#include "libknot/wire.h"
#include "contrib/string.h"
#include "contrib/wire.h"
_public_
uint8_t knot_nsec3param_algorithm(const knot_rdataset_t *rrs, size_t pos)
......@@ -38,7 +38,7 @@ _public_
uint16_t knot_nsec3param_iterations(const knot_rdataset_t *rrs, size_t pos)
{
KNOT_RDATASET_CHECK(rrs, pos, return 0);
return wire_read_u16(knot_rdata_offset(rrs, pos, 2));
return knot_wire_read_u16(knot_rdata_offset(rrs, pos, 2));
}
......
......@@ -26,7 +26,7 @@
#include "libknot/descriptor.h"
#include "libknot/rrtype/opt.h"
#include "libknot/packet/pkt.h"
#include "contrib/wire.h"
#include "libknot/wire.h"
#include "contrib/wire_ctx.h"
/*! \brief Some implementation-related constants. */
......@@ -464,7 +464,7 @@ uint16_t knot_edns_opt_get_code(const uint8_t *opt)
{
assert(opt != NULL);
return wire_read_u16(opt);
return knot_wire_read_u16(opt);
}
_public_
......@@ -472,7 +472,7 @@ uint16_t knot_edns_opt_get_length(const uint8_t *opt)
{
assert(opt != NULL);
return wire_read_u16(opt + sizeof(uint16_t));
return knot_wire_read_u16(opt + sizeof(uint16_t));
}
_public_
......
/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -16,39 +16,39 @@
#include "libknot/attribute.h"
#include "libknot/rrtype/rrsig.h"
#include "contrib/wire.h"
#include "libknot/wire.h"
_public_
uint16_t knot_rrsig_type_covered(const knot_rdataset_t *rrs, size_t pos)
{
KNOT_RDATASET_CHECK(rrs, pos, return 0);
return wire_read_u16(knot_rdata_offset(rrs, pos, 0));
return knot_wire_read_u16(knot_rdata_offset(rrs, pos, 0));
}
_public_
uint32_t knot_rrsig_original_ttl(const knot_rdataset_t *rrs, size_t pos)
{
KNOT_RDATASET_CHECK(rrs, pos, return 0);
return wire_read_u32(knot_rdata_offset(rrs, pos, 4));
return knot_wire_read_u32(knot_rdata_offset(rrs, pos, 4));
}
_public_
uint32_t knot_rrsig_sig_expiration(const knot_rdataset_t *rrs, size_t pos)
{
KNOT_RDATASET_CHECK(rrs, pos, return 0);
return wire_read_u32(knot_rdata_offset(rrs, pos, 8));
return knot_wire_read_u32(knot_rdata_offset(rrs, pos, 8));
}
_public_
uint32_t knot_rrsig_sig_inception(const knot_rdataset_t *rrs, size_t pos)
{
KNOT_RDATASET_CHECK(rrs, pos, return 0);
return wire_read_u32(knot_rdata_offset(rrs, pos, 12));
return knot_wire_read_u32(knot_rdata_offset(rrs, pos, 12));
}
_public_
uint16_t knot_rrsig_key_tag(const knot_rdataset_t *rrs, size_t pos)
{
KNOT_RDATASET_CHECK(rrs, pos, return 0);
return wire_read_u16(knot_rdata_offset(rrs, pos, 16));
return knot_wire_read_u16(knot_rdata_offset(rrs, pos, 16));
}
/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -16,14 +16,14 @@
#include "libknot/attribute.h"
#include "libknot/rrtype/soa.h"
#include "contrib/wire.h"
#include "libknot/wire.h"
_public_
uint32_t knot_soa_serial(const knot_rdataset_t *rrs)
{
KNOT_RDATASET_CHECK(rrs, 0, return 0);
return wire_read_u32(knot_rdata_offset(rrs, 0,
knot_soa_names_len(rrs)));
return knot_wire_read_u32(knot_rdata_offset(rrs, 0,
knot_soa_names_len(rrs)));
}
_public_
......@@ -31,38 +31,38 @@ void knot_soa_serial_set(knot_rdataset_t *rrs, uint32_t serial)
{
KNOT_RDATASET_CHECK(rrs, 0, return);
// the number is in network byte order, transform it
wire_write_u32(knot_rdata_offset(rrs, 0, knot_soa_names_len(rrs)),
serial);
knot_wire_write_u32(knot_rdata_offset(rrs, 0, knot_soa_names_len(rrs)),
serial);
}
_public_
uint32_t knot_soa_refresh(const knot_rdataset_t *rrs)
{
KNOT_RDATASET_CHECK(rrs, 0, return 0);
return wire_read_u32(knot_rdata_offset(rrs, 0,
knot_soa_names_len(rrs) + 4));
return knot_wire_read_u32(knot_rdata_offset(rrs, 0,
knot_soa_names_len(rrs) + 4));
}
_public_
uint32_t knot_soa_retry(const knot_rdataset_t *rrs)
{
KNOT_RDATASET_CHECK(rrs, 0, return 0);
return wire_read_u32(knot_rdata_offset(rrs, 0,
knot_soa_names_len(rrs) + 8));
return knot_wire_read_u32(knot_rdata_offset(rrs, 0,
knot_soa_names_len(rrs) + 8));
}
_public_
uint32_t knot_soa_expire(const knot_rdataset_t *rrs)
{
KNOT_RDATASET_CHECK(rrs, 0, return 0);
return wire_read_u32(knot_rdata_offset(rrs, 0,
knot_soa_names_len(rrs) + 12));
return knot_wire_read_u32(knot_rdata_offset(rrs, 0,
knot_soa_names_len(rrs) + 12));
}
_public_
uint32_t knot_soa_minimum(const knot_rdataset_t *rrs)
{
KNOT_RDATASET_CHECK(rrs, 0, return 0);
return wire_read_u32(knot_rdata_offset(rrs, 0,
knot_soa_names_len(rrs) + 16));
return knot_wire_read_u32(knot_rdata_offset(rrs, 0,
knot_soa_names_len(rrs) + 16));
}
......@@ -28,7 +28,7 @@
#include "libknot/dname.h"
#include "libknot/errcode.h"
#include "libknot/rrset.h"
#include "contrib/wire.h"
#include "libknot/wire.h"
#include "contrib/wire_ctx.h"
/*! \brief TSIG field offsets. */
......@@ -124,7 +124,7 @@ static int rdata_set_tsig_error(knot_rrset_t *tsig, uint16_t tsig_error)
return KNOT_ERROR;
}
wire_write_u16(rd, tsig_error);
knot_wire_write_u16(rd, tsig_error);
return KNOT_EOK;
}
......@@ -149,7 +149,7 @@ int knot_tsig_create_rdata(knot_rrset_t *rr, const knot_dname_t *alg,
/* Set MAC variable length in advance. */
size_t offset = alg_len + TSIG_OFF_MACLEN;
wire_write_u16(rd + offset, maclen);
knot_wire_write_u16(rd + offset, maclen);
int ret = knot_rrset_add_rdata(rr, rd, rdlen, NULL);
if (ret != KNOT_EOK) {
......@@ -170,7 +170,7 @@ int knot_tsig_rdata_set_time_signed(knot_rrset_t *tsig, uint64_t time)
return KNOT_ERROR;
}
wire_write_u48(rd, time);
knot_wire_write_u48(rd, time);
return KNOT_EOK;
}
......@@ -182,7 +182,7 @@ int knot_tsig_rdata_set_fudge(knot_rrset_t *tsig, uint16_t fudge)
return KNOT_ERROR;
}
wire_write_u16(rd, fudge);
knot_wire_write_u16(rd, fudge);
return KNOT_EOK;
}
......@@ -210,7 +210,7 @@ int knot_tsig_rdata_set_orig_id(knot_rrset_t *tsig, uint16_t id)
}
/* Write the length - 2. */
wire_write_u16(rd, id);
knot_wire_write_u16(rd, id);
return KNOT_EOK;
}
......@@ -228,7 +228,7 @@ int knot_tsig_rdata_set_other_data(knot_rrset_t *tsig, uint16_t len,
}
/* Write the length. */
wire_write_u16(rd, len);
knot_wire_write_u16(rd, len);
/* Copy the actual data. */
memcpy(rd + sizeof(uint16_t), other_data, len);
......@@ -261,7 +261,7 @@ uint64_t knot_tsig_rdata_time_signed(const knot_rrset_t *tsig)
if (!rd) {
return 0;
}
return wire_read_u48(rd);
return knot_wire_read_u48(rd);
}
_public_
......@@ -271,7 +271,7 @@ uint16_t knot_tsig_rdata_fudge(const knot_rrset_t *tsig)
if (!rd) {
return 0;
}
return wire_read_u16(rd);
return knot_wire_read_u16(rd);
}
_public_
......@@ -291,7 +291,7 @@ size_t knot_tsig_rdata_mac_length(const knot_rrset_t *tsig)
if (!rd) {
return 0;
}
return wire_read_u16(rd);
return knot_wire_read_u16(rd);
}
_public_
......@@ -301,7 +301,7 @@ uint16_t knot_tsig_rdata_orig_id(const knot_rrset_t *tsig)
if (!rd) {
return 0;
}
return wire_read_u16(rd);
return knot_wire_read_u16(rd);
}
_public_
......@@ -311,7 +311,7 @@ uint16_t knot_tsig_rdata_error(const knot_rrset_t *tsig)
if (!rd) {
return 0;
}
return wire_read_u16(rd);
return knot_wire_read_u16(rd);
}
_public_
......@@ -331,7 +331,7 @@ uint16_t knot_tsig_rdata_other_data_length(const knot_rrset_t *tsig)
if (!rd) {
return 0;
}
return wire_read_u16(rd);
return knot_wire_read_u16(rd);
}
_public_
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -29,8 +29,8 @@
#include "libknot/packet/wire.h"
#include "libknot/consts.h"
#include "libknot/packet/rrset-wire.h"
#include "libknot/wire.h"
#include "contrib/string.h"
#include "contrib/wire.h"
const int KNOT_TSIG_MAX_DIGEST_SIZE = 64; // size of HMAC-SHA512 digest
const uint16_t KNOT_TSIG_FUDGE_DEFAULT = 300; // default Fudge value
......@@ -154,11 +154,11 @@ static int write_tsig_variables(uint8_t *wire, const knot_rrset_t *tsig_rr)
/*!< \todo which order? */
/* Copy class. */
wire_write_u16(wire + offset, tsig_rr->rclass);
knot_wire_write_u16(wire + offset, tsig_rr->rclass);
offset += sizeof(uint16_t);
/* Copy TTL - always 0. */
wire_write_u32(wire + offset, tsig_rr->ttl);
knot_wire_write_u32(wire + offset, tsig_rr->ttl);
offset += sizeof(uint32_t);
/* Copy alg name. */
......@@ -176,13 +176,13 @@ static int write_tsig_variables(uint8_t *wire, const knot_rrset_t *tsig_rr)
/* Following data are written in network order. */
/* Time signed. */
wire_write_u48(wire + offset, knot_tsig_rdata_time_signed(tsig_rr));
knot_wire_write_u48(wire + offset, knot_tsig_rdata_time_signed(tsig_rr));
offset += 6;
/* Fudge. */
wire_write_u16(wire + offset, knot_tsig_rdata_fudge(tsig_rr));
knot_wire_write_u16(wire + offset, knot_tsig_rdata_fudge(tsig_rr));
offset += sizeof(uint16_t);
/* TSIG error. */
wire_write_u16(wire + offset, knot_tsig_rdata_error(tsig_rr));
knot_wire_write_u16(wire + offset, knot_tsig_rdata_error(tsig_rr));
offset += sizeof(uint16_t);
/* Get other data length. */
uint16_t other_data_length = knot_tsig_rdata_other_data_length(tsig_rr);
......@@ -196,7 +196,7 @@ static int write_tsig_variables(uint8_t *wire, const knot_rrset_t *tsig_rr)
* We cannot write the whole other_data, as it contains its length in
* machine order.
*/
wire_write_u16(wire + offset, other_data_length);
knot_wire_write_u16(wire + offset, other_data_length);
offset += sizeof(uint16_t);
/* Skip the length. */
......@@ -212,9 +212,9 @@ static int wire_write_timers(uint8_t *wire, const knot_rrset_t *tsig_rr)
}
//write time signed
wire_write_u48(wire, knot_tsig_rdata_time_signed(tsig_rr));
knot_wire_write_u48(wire, knot_tsig_rdata_time_signed(tsig_rr));
//write fudge
wire_write_u16(wire + 6, knot_tsig_rdata_fudge(tsig_rr));
knot_wire_write_u16(wire + 6, knot_tsig_rdata_fudge(tsig_rr));
return KNOT_EOK;
}
......@@ -249,7 +249,7 @@ static int create_sign_wire(const uint8_t *msg, size_t msg_len,
/* Copy the request MAC - should work even if NULL. */
if (request_mac_len > 0) {
wire_write_u16(pos, request_mac_len);
knot_wire_write_u16(pos, request_mac_len);
pos += 2;
memcpy(pos, request_mac, request_mac_len);
}
......@@ -303,7 +303,7 @@ static int create_sign_wire_next(const uint8_t *msg, size_t msg_len,
memset(wire, 0, wire_len);
/* Copy the request MAC - should work even if NULL. */
wire_write_u16(wire, prev_mac_len);