Exemple #1
0
uint8_t			query_is_compressed(char *buffer, uint16_t len)
{
  char			*name;
  struct dns_hdr	*hdr;

  hdr = (struct dns_hdr *) buffer;
  if (!(name  = jump_end_query(buffer, GET_16(&hdr->qdcount), len)))
    return (0);
  return ((*name & COMPRESS_FLAG_CHAR) == COMPRESS_FLAG_CHAR);
}
Exemple #2
0
static int		build_ressources_reply(t_conf *conf, void *buffer, 
					       int  max_len)
{
  struct dns_hdr	*hdr;
  t_list		*list;
  void			*where;
  char			buffer2[MAX_REQ_LEN];

  hdr = buffer;
  hdr->ra = 1;
  hdr->qr = 1;

  if (!(where = jump_end_query(buffer, GET_16(&hdr->qdcount), max_len)))
    return (-1);
  for (list = conf->ressources; list; list = list->next)
    {
      base64_encode(list->data, buffer2, (strchr(list->data, ':') - list->data));
      where = add_reply(hdr, where, TYPE_KEY, buffer2);
    }
  return (where - buffer);
}
Exemple #3
0
int			build_error_reply(t_conf *conf, void *req, int max_len, char *error)
{

  struct dns_hdr	*hdr;
  void			*where;
  t_packet		*packet;
  char			buffer[BASE64_SIZE(MAX_ERROR_SIZE) + PACKET_LEN];
  char			buffer2[BASE64_SIZE(MAX_ERROR_SIZE) + PACKET_LEN];
  int			len;

  hdr = req;
  hdr->ra = 1;
  hdr->qr = 1;
 if (!(where = jump_end_query(req, GET_16(&hdr->qdcount), max_len)))
      return (-1);
  packet = (t_packet *) memset(buffer, 0, PACKET_LEN);
  packet->type = ERR;
  len = strlen(error);
  memcpy(buffer+PACKET_LEN, error, len+1);
  base64_encode(buffer, buffer2, PACKET_LEN + len);
  where = add_reply(hdr, where, TYPE_KEY, buffer2);
  return (where - req);
}