summaryrefslogtreecommitdiff
path: root/src/libs6dns/s6dns_debug_dumpdt_post_send.c
blob: 5e7b60ccace770d3376e90eeaf3a3801838c4747 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* ISC license */

#include <sys/types.h>
#include <stdint.h>
#include <skalibs/uint16.h>
#include <skalibs/djbtime.h>
#include <skalibs/genwrite.h>
#include <s6-dns/s6dns-engine.h>
#include <s6-dns/s6dns-debug.h>

int s6dns_debug_dumpdt_post_send (s6dns_engine_t const *dt, void *data)
{
  genwrite_t *gp = data ;
  size_t len ;
  char buf[LOCALTMN_FMT] ;
  if ((*gp->put)(gp->target, "Sent query ", 11) < 11) return 0 ;
  {
    uint16_t id ;
    uint16_unpack_big(dt->sa.s + 2, &id) ;
    len = uint16_fmt(buf, id) ;
  }
  if ((*gp->put)(gp->target, buf, len) < (ssize_t)len) return 0 ;
  if ((*gp->put)(gp->target, " - next recv deadline is ", 25) < 25) return 0 ;
  {
    localtmn_t l ;
    if (!localtmn_from_tain(&l, &dt->localdeadline, 0)) return 0 ;
    len = localtmn_fmt(buf, &l) ;
  }
  if ((*gp->put)(gp->target, buf, len) < (ssize_t)len) return 0 ;
  if ((*gp->put)(gp->target, "\n\n", 2) < 2) return 0 ;
  return (*gp->flush)(gp->target) ;
}