Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for SVCB and HTTPS #112

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions include/zone.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ extern "C" {
#define ZONE_CSYNC (62u)
/** Zone message digest @rfc{8976} */
#define ZONE_ZONEMD (63u)
/** Service binding @draft{dnsop,svcb-https} */
/** Service binding @rfc{9460} */
#define ZONE_SVCB (64u)
/** Service binding @draft{dnsop,svcb-https} */
/** Service binding @rfc{9460} */
#define ZONE_HTTPS (65u)
/** Sender Policy Framework @rfc{7208} */
#define ZONE_SPF (99u)
Expand Down Expand Up @@ -314,7 +314,6 @@ struct zone_field_info {
*
* @{
*/
// ZONE_IN (1) can be used too
#define ZONE_ANY (1<<2)
#define ZONE_EXPERIMENTAL (1<<3)
#define ZONE_OBSOLETE (1<<4)
Expand Down Expand Up @@ -347,13 +346,13 @@ struct zone_type_info {

typedef struct zone_name_buffer zone_name_buffer_t;
struct zone_name_buffer {
size_t length; /**< Length of domain name stored in block */
size_t length; /**< Length of domain name stored in buffer */
uint8_t octets[ ZONE_NAME_SIZE + ZONE_PADDING_SIZE ];
};

typedef struct zone_rdata_buffer zone_rdata_buffer_t;
struct zone_rdata_buffer {
size_t length; /**< Length of RDATA stored in block */
size_t length; /**< Length of RDATA stored in buffer */
uint8_t octets[ ZONE_RDATA_SIZE + 4096 /* nsec padding */ ];
};

Expand Down Expand Up @@ -538,7 +537,7 @@ typedef struct {
*/
typedef struct zone_buffers zone_buffers_t;
struct zone_buffers {
size_t size; /**< Number of name and rdata storage blocks available */
size_t size; /**< Number of name and rdata buffers available */
zone_name_buffer_t *owner;
zone_rdata_buffer_t *rdata;
};
Expand Down
1 change: 1 addition & 0 deletions src/fallback/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "generic/loc.h"
#include "generic/gpos.h"
#include "generic/apl.h"
#include "generic/svcb.h"
#include "types.h"
#include "fallback/type.h"
#include "parser.h"
Expand Down
2 changes: 2 additions & 0 deletions src/fallback/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ static zone_really_inline int32_t parse_string(
const uint8_t *ws = w - 1, *we = w + 255;
const char *t = token->data, *te = t + token->length;

// FIXME: SWAR can possibly applied to improve performance and copy
// eight bytes as opposed to one
while ((t < te) & (w < we)) {
*w = (uint8_t)*t;
if (zone_unlikely(*t == '\\')) {
Expand Down
10 changes: 5 additions & 5 deletions src/generic/ip6.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ inet_pton4(const char *src, uint8_t *dst)
saw_digit = 0;
octets = 0;
*(tp = tmp) = 0;
while (contiguous[ (ch = *src++) ] == CONTIGUOUS) {
for (; (ch = *src); src++) {
const char *pch;

if ((pch = strchr(digits, ch)) != NULL) {
Expand Down Expand Up @@ -106,7 +106,7 @@ inet_pton6(const char *src, uint8_t *dst)
curtok = src;
saw_xdigit = 0;
val = 0;
while (contiguous[ (ch = *src++) ] == CONTIGUOUS) {
for (; (ch = *src); src++) {
const char *pch;

if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
Expand All @@ -120,7 +120,7 @@ inet_pton6(const char *src, uint8_t *dst)
continue;
}
if (ch == ':') {
curtok = src;
curtok = src+1;
if (!saw_xdigit) {
if (colonp)
return (0);
Expand All @@ -137,12 +137,12 @@ inet_pton6(const char *src, uint8_t *dst)
}
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
(len = inet_pton4(curtok, tp)) > 0) {
src += len;
src = curtok + len;
tp += NS_INADDRSZ;
saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */
}
return -1;
break;
}
if (saw_xdigit) {
if (tp + NS_INT16SZ > endp)
Expand Down
3 changes: 3 additions & 0 deletions src/generic/number.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef NUMBER_H
#define NUMBER_H

// FIXME: remove in favor of specialized functions, much easier
zone_nonnull_all
static zone_really_inline int32_t parse_symbol8(
zone_parser_t *parser,
Expand All @@ -21,6 +22,7 @@ static zone_really_inline int32_t parse_symbol8(
if ((r = have_contiguous(parser, type, field, token)) < 0)
return r;

// FIXME: implement generic number scanning
uint64_t n = 0;
const char *p = token->data;
for (;; p++) {
Expand All @@ -30,6 +32,7 @@ static zone_really_inline int32_t parse_symbol8(
n = n * 10 + d;
}

// FIXME: replace with simple length check
if (is_contiguous((uint8_t)*p)) {
const zone_symbol_t *s;
if (!(s = lookup_symbol(&field->symbols, token)))
Expand Down
Loading