summaryrefslogtreecommitdiffstats
path: root/lib/libc/asr/asr_utils.c
diff options
context:
space:
mode:
authorjca <jca@openbsd.org>2017-02-18 19:23:05 +0000
committerjca <jca@openbsd.org>2017-02-18 19:23:05 +0000
commit2aa4cd219b1fae15f061ec9753d5a6990ec2ba48 (patch)
tree77639f64821e8dabbde640015c5277782230015d /lib/libc/asr/asr_utils.c
parentAdd a regress test for the chflags problem analogous to the chmod bug (diff)
downloadwireguard-openbsd-2aa4cd219b1fae15f061ec9753d5a6990ec2ba48.tar.xz
wireguard-openbsd-2aa4cd219b1fae15f061ec9753d5a6990ec2ba48.zip
Add EDNS0 support.
EDNS allows for various DNS extensions, among which UDP DNS packets size bigger than 512 bytes. The default is still to not advertize anything. ok eric@
Diffstat (limited to 'lib/libc/asr/asr_utils.c')
-rw-r--r--lib/libc/asr/asr_utils.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/libc/asr/asr_utils.c b/lib/libc/asr/asr_utils.c
index 835d5dfb448..e540aae9ab6 100644
--- a/lib/libc/asr/asr_utils.c
+++ b/lib/libc/asr/asr_utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asr_utils.c,v 1.14 2017/02/17 22:24:45 eric Exp $ */
+/* $OpenBSD: asr_utils.c,v 1.15 2017/02/18 19:23:05 jca Exp $ */
/*
* Copyright (c) 2009-2012 Eric Faurot <eric@faurot.net>
*
@@ -381,6 +381,14 @@ pack_u16(struct asr_pack *p, uint16_t v)
}
static int
+pack_u32(struct asr_pack *p, uint32_t v)
+{
+ v = htonl(v);
+
+ return (pack_data(p, &v, 4));
+}
+
+static int
pack_dname(struct asr_pack *p, const char *dname)
{
/* dname compression would be nice to have here.
@@ -415,6 +423,18 @@ _asr_pack_query(struct asr_pack *p, uint16_t type, uint16_t class, const char *d
}
int
+_asr_pack_edns0(struct asr_pack *p, uint16_t pktsz)
+{
+ pack_dname(p, ""); /* root */
+ pack_u16(p, 41); /* OPT */
+ pack_u16(p, pktsz); /* UDP payload size */
+ pack_u32(p, 0); /* extended RCODE and flags */
+ pack_u16(p, 0); /* RDATA len */
+
+ return (p->err) ? (-1) : (0);
+}
+
+int
_asr_sockaddr_from_str(struct sockaddr *sa, int family, const char *str)
{
struct in_addr ina;