aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/shibari_packet_begin.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-12-10 11:48:01 +0000
committerLaurent Bercot <ska@appnovation.com>2023-12-10 11:48:01 +0000
commitb8d0f83e6cea9640a7ee4402c163ad812237355d (patch)
tree57a64ac8aa0e98c40db8c36e96e7379490e44dbf /src/server/shibari_packet_begin.c
downloadshibari-b8d0f83e6cea9640a7ee4402c163ad812237355d.tar.gz
Initial commit
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/server/shibari_packet_begin.c')
-rw-r--r--src/server/shibari_packet_begin.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/server/shibari_packet_begin.c b/src/server/shibari_packet_begin.c
new file mode 100644
index 0000000..5ea7b16
--- /dev/null
+++ b/src/server/shibari_packet_begin.c
@@ -0,0 +1,32 @@
+/* ISC license. */
+
+#include <string.h>
+
+#include <skalibs/uint16.h>
+
+#include <shibari/constants.h>
+#include <shibari/packet.h>
+
+void shibari_packet_begin (shibari_packet *p, uint16_t id, s6dns_domain_t const *q, uint16_t qtype)
+{
+ p->hdr.id = id ;
+ p->hdr.qr = 1 ;
+ p->hdr.opcode = 0 ;
+ p->hdr.aa = 0 ;
+ p->hdr.tc = 0 ;
+ p->hdr.rd = 0 ;
+ p->hdr.ra = 0 ;
+ p->hdr.z = 0 ;
+ p->hdr.rcode = 0 ;
+ p->hdr.counts.qd = 1 ;
+ p->hdr.counts.an = 0 ;
+ p->hdr.counts.ns = 0 ;
+ p->hdr.counts.nr = 0 ;
+ p->pos = 12 ;
+ memcpy(p->buf + p->pos, q->s, q->len) ;
+ p->pos += q->len ;
+ uint16_pack_big(p->buf + p->pos, qtype) ;
+ p->pos += 2 ;
+ uint16_pack_big(p->buf + p->pos, SHIBARI_C_IN) ;
+ p->pos += 2 ;
+}