Commit 48cecedb authored by Marek Vavrusa's avatar Marek Vavrusa

Renamed this and that related to packet (enums).

parent fc08b7c0
......@@ -503,7 +503,7 @@ int remote_recv(int r, sockaddr_t *a, uint8_t* buf, size_t *buflen)
int remote_parse(knot_pkt_t* pkt)
{
return knot_pkt_parse(pkt, KNOT_PACKET_DUPL_NO_MERGE);
return knot_pkt_parse(pkt, KNOT_PF_NO_MERGE);
}
static int remote_send_chunk(int c, knot_pkt_t *query, const char* d, uint16_t len)
......
......@@ -566,7 +566,7 @@ static int xfr_task_resp(xfrhandler_t *xfr, knot_ns_xfr_t *rq)
return KNOT_ENOMEM;
}
knot_packet_type_t rt = KNOT_RESPONSE_NORMAL;
knot_pkt_type_t rt = KNOT_RESPONSE_NORMAL;
int ret = knot_ns_parse_packet(re, &rt);
if (ret != KNOT_EOK) {
knot_pkt_free(&re);
......@@ -584,7 +584,7 @@ static int xfr_task_resp(xfrhandler_t *xfr, knot_ns_xfr_t *rq)
return KNOT_EOK; /* Ignore */
}
ret = knot_pkt_parse_payload(re, KNOT_PACKET_DUPL_NO_MERGE);
ret = knot_pkt_parse_payload(re, KNOT_PF_NO_MERGE);
if (ret != KNOT_EOK) {
knot_pkt_free(&re);
return KNOT_EOK; /* Ignore */
......
......@@ -82,27 +82,6 @@ typedef enum {
KNOT_RCODE_BADTRUNC = 22 /*!< Bad truncation. */
} knot_rcode_t;
/*!
* \brief DNS query types (internal use only).
*
* This type encompasses the different query types distinguished by both the
* OPCODE and the QTYPE.
*/
typedef enum {
KNOT_QUERY_INVALID = 1 << 1, /*!< Invalid query. */
KNOT_QUERY_NORMAL = 1 << 2, /*!< Normal query. */
KNOT_QUERY_AXFR = 1 << 3, /*!< Request for AXFR transfer. */
KNOT_QUERY_IXFR = 1 << 4, /*!< Request for IXFR transfer. */
KNOT_QUERY_NOTIFY = 1 << 5, /*!< NOTIFY query. */
KNOT_QUERY_UPDATE = 1 << 6, /*!< Dynamic update. */
KNOT_RESPONSE = 1 << 0, /*!< Is response. */
KNOT_RESPONSE_NORMAL = KNOT_RESPONSE|KNOT_QUERY_NORMAL,/*!< Normal response. */
KNOT_RESPONSE_AXFR = KNOT_RESPONSE|KNOT_QUERY_AXFR, /*!< AXFR transfer response. */
KNOT_RESPONSE_IXFR = KNOT_RESPONSE|KNOT_QUERY_IXFR, /*!< IXFR transfer response. */
KNOT_RESPONSE_NOTIFY = KNOT_RESPONSE|KNOT_QUERY_NOTIFY,/*!< NOTIFY response. */
KNOT_RESPONSE_UPDATE = KNOT_RESPONSE|KNOT_QUERY_UPDATE /*!< Dynamic update response. */
} knot_packet_type_t;
/*!
* \brief DNS packet section identifiers.
*/
......
......@@ -108,7 +108,7 @@ knot_nameserver_t *knot_ns_create()
/*----------------------------------------------------------------------------*/
int knot_ns_parse_packet(knot_pkt_t *packet, knot_packet_type_t *type)
int knot_ns_parse_packet(knot_pkt_t *packet, knot_pkt_type_t *type)
{
dbg_ns("%s(%p, %p)\n", __func__, packet, type);
if (packet == NULL || type == NULL) {
......@@ -125,7 +125,7 @@ int knot_ns_parse_packet(knot_pkt_t *packet, knot_packet_type_t *type)
// 2) determine the query type
*type = knot_pkt_type(packet);
if (*type & KNOT_QUERY_INVALID) {
if (*type == KNOT_QUERY_INVALID) {
return KNOT_RCODE_NOTIMPL;
}
......
......@@ -217,7 +217,7 @@ knot_nameserver_t *knot_ns_create();
* ns_error_response() with \a rcode set to this
* value to get proper error response.
*/
int knot_ns_parse_packet(knot_pkt_t *packet, knot_packet_type_t *type);
int knot_ns_parse_packet(knot_pkt_t *packet, knot_pkt_type_t *type);
/*!
* \brief Compares two zone serials.
......
......@@ -625,7 +625,7 @@ static int knot_pkt_merge_rr(knot_pkt_t *pkt, knot_rrset_t *rr, unsigned flags)
assert(rr);
/* Don't want to merge, okay. */
if (flags & KNOT_PACKET_DUPL_NO_MERGE) {
if (flags & KNOT_PF_NO_MERGE) {
return KNOT_ENOENT;
}
......
......@@ -45,6 +45,27 @@
/* Number of maximum RRs in packet. */
#define KNOT_PKT_MAX_RRS (KNOT_WIRE_MAX_PAYLOAD / KNOT_WIRE_RR_MIN_SIZE)
/*!
* \brief DNS query types (internal use only).
*
* This type encompasses the different query types distinguished by both the
* OPCODE and the QTYPE.
*/
typedef enum {
KNOT_QUERY_INVALID = 0, /*!< Invalid query. */
KNOT_QUERY_NORMAL = 1 << 1, /*!< Normal query. */
KNOT_QUERY_AXFR = 1 << 2, /*!< Request for AXFR transfer. */
KNOT_QUERY_IXFR = 1 << 3, /*!< Request for IXFR transfer. */
KNOT_QUERY_NOTIFY = 1 << 4, /*!< NOTIFY query. */
KNOT_QUERY_UPDATE = 1 << 5, /*!< Dynamic update. */
KNOT_RESPONSE = 1 << 0, /*!< Is response. */
KNOT_RESPONSE_NORMAL = KNOT_RESPONSE|KNOT_QUERY_NORMAL,/*!< Normal response. */
KNOT_RESPONSE_AXFR = KNOT_RESPONSE|KNOT_QUERY_AXFR, /*!< AXFR transfer response. */
KNOT_RESPONSE_IXFR = KNOT_RESPONSE|KNOT_QUERY_IXFR, /*!< IXFR transfer response. */
KNOT_RESPONSE_NOTIFY = KNOT_RESPONSE|KNOT_QUERY_NOTIFY,/*!< NOTIFY response. */
KNOT_RESPONSE_UPDATE = KNOT_RESPONSE|KNOT_QUERY_UPDATE /*!< Dynamic update response. */
} knot_pkt_type_t;
/*!
* \brief Packet flags.
*/
......@@ -54,7 +75,7 @@ enum {
KNOT_PF_FREE = 1 << 2, /*!< Free with packet. */
KNOT_PF_NOTRUNC = 1 << 3, /*!< Don't truncate. */
KNOT_PF_CHECKDUP = 1 << 4, /*!< Check for duplicates. */
KNOT_PACKET_DUPL_NO_MERGE = 1 << 5 /* Don't add duplicate rdata to rrset. */
KNOT_PF_NO_MERGE = 1 << 5 /* Don't add duplicate rdata to rrset. */
};
/*!
......@@ -137,7 +158,7 @@ void knot_pkt_clear(knot_pkt_t *pkt);
void knot_pkt_free(knot_pkt_t **pkt);
/*! \brief Classify packet according to the question.
* \return see enum knot_packet_type_t
* \return see enum knot_pkt_type_t
*/
uint16_t knot_pkt_type(const knot_pkt_t *pkt);
......
......@@ -369,7 +369,7 @@ static int xfrin_parse(knot_pkt_t **dst, uint8_t *wire, size_t wire_size)
/* This is important, don't merge RRs together. The SOAs are ordered
* in a special way for a reason. */
ret = knot_pkt_parse(pkt, KNOT_PACKET_DUPL_NO_MERGE);
ret = knot_pkt_parse(pkt, KNOT_PF_NO_MERGE);
if (ret != KNOT_EOK) {
knot_pkt_free(&pkt);
return ret;
......
......@@ -324,7 +324,7 @@ static int process_query_packet(const knot_pkt_t *query,
}
// Parse reply to the packet structure.
if (knot_pkt_parse(reply, KNOT_PACKET_DUPL_NO_MERGE) != KNOT_EOK) {
if (knot_pkt_parse(reply, KNOT_PF_NO_MERGE) != KNOT_EOK) {
ERR("malformed reply packet from %s\n", net->remote_str);
knot_pkt_free(&reply);
net_close(net);
......@@ -543,7 +543,7 @@ static int process_packet_xfr(const knot_pkt_t *query,
}
// Parse reply to the packet structure.
if (knot_pkt_parse(reply, KNOT_PACKET_DUPL_NO_MERGE) != KNOT_EOK) {
if (knot_pkt_parse(reply, KNOT_PF_NO_MERGE) != KNOT_EOK) {
ERR("malformed reply packet from %s\n", net->remote_str);
knot_pkt_free(&reply);
net_close(net);
......
......@@ -733,7 +733,7 @@ int cmd_send(const char* lp, nsupdate_params_t *params)
free_sign_context(&sign_ctx);
return KNOT_ENOMEM;
}
ret = knot_pkt_parse(params->resp, KNOT_PACKET_DUPL_NO_MERGE);
ret = knot_pkt_parse(params->resp, KNOT_PF_NO_MERGE);
if (ret != KNOT_EOK) {
ERR("failed to parse response, %s\n", knot_strerror(ret));
free_sign_context(&sign_ctx);
......
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