Commit 2ce13812 authored by Lubos Slovak's avatar Lubos Slovak

AXFR query creating.

- Query creating separated to private function
  axfrin_create_query().

TODO: made the function part of some API - probably query.

refs #800 @15m, #788
parent 536035ad
......@@ -11,15 +11,8 @@
/*----------------------------------------------------------------------------*/
static uint32_t axfrin_serial_difference(uint32_t local, uint32_t remote)
{
return (((int64_t)remote - local) % ((int64_t)1 << 32));
}
/*----------------------------------------------------------------------------*/
int axfrin_create_soa_query(const dnslib_dname_t *zone_name, uint8_t *buffer,
size_t *size)
static int axfrin_create_query(const dnslib_dname_t *qname, uint16_t qtype,
uint16_t qclass, uint8_t *buffer, size_t *size)
{
dnslib_packet_t *pkt = dnslib_packet_new(DNSLIB_PACKET_PREALLOC_QUERY);
CHECK_ALLOC_LOG(pkt, KNOT_ENOMEM);
......@@ -40,9 +33,9 @@ int axfrin_create_soa_query(const dnslib_dname_t *zone_name, uint8_t *buffer,
dnslib_question_t question;
// this is ugly!!
question.qname = (dnslib_dname_t *)zone_name;
question.qtype = DNSLIB_RRTYPE_SOA;
question.qclass = DNSLIB_CLASS_IN;
question.qname = (dnslib_dname_t *)qname;
question.qtype = qtype;
question.qclass = qclass;
rc = dnslib_query_set_question(pkt, &question);
if (rc != DNSLIB_EOK) {
......@@ -50,6 +43,8 @@ int axfrin_create_soa_query(const dnslib_dname_t *zone_name, uint8_t *buffer,
return rc;
}
/*! \todo Set some random ID!! */
/*! \todo OPT RR ?? */
uint8_t *wire = NULL;
......@@ -77,6 +72,22 @@ int axfrin_create_soa_query(const dnslib_dname_t *zone_name, uint8_t *buffer,
/*----------------------------------------------------------------------------*/
static uint32_t axfrin_serial_difference(uint32_t local, uint32_t remote)
{
return (((int64_t)remote - local) % ((int64_t)1 << 32));
}
/*----------------------------------------------------------------------------*/
int axfrin_create_soa_query(const dnslib_dname_t *zone_name, uint8_t *buffer,
size_t *size)
{
return axfrin_create_query(zone_name, DNSLIB_RRTYPE_SOA,
DNSLIB_CLASS_IN, buffer, size);
}
/*----------------------------------------------------------------------------*/
int axfrin_transfer_needed(const dnslib_zone_t *zone,
const dnslib_packet_t *soa_response)
{
......@@ -126,5 +137,6 @@ int axfrin_transfer_needed(const dnslib_zone_t *zone,
int axfrin_create_axfr_query(const dnslib_dname_t *zone_name, uint8_t *buffer,
size_t *size)
{
return KNOT_ERROR;
return axfrin_create_query(zone_name, DNSLIB_RRTYPE_AXFR,
DNSLIB_CLASS_IN, buffer, size);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment