Commit 0c86253a authored by Jan Včelák's avatar Jan Včelák 🚀

libknot: add knot_ prefix to descriptor public API

parent b65a33ac
......@@ -233,7 +233,7 @@ static int knot_zone_diff_rdata_return_changes(const knot_rrset_t *rrset1,
return KNOT_ENOMEM;
}
const rdata_descriptor_t *desc = get_rdata_descriptor(rrset1->type);
const rdata_descriptor_t *desc = knot_get_rdata_descriptor(rrset1->type);
assert(desc);
uint16_t rr1_count = rrset1->rrs.rr_count;
......
......@@ -153,7 +153,7 @@ static const rdata_descriptor_t obsolete_rdata_descriptors[] = {
KNOT_RDATA_WF_END }, "NXT" },
};
const rdata_descriptor_t *get_rdata_descriptor(const uint16_t type)
const rdata_descriptor_t *knot_get_rdata_descriptor(const uint16_t type)
{
if (type <= KNOT_RRTYPE_ANY &&
rdata_descriptors[type].type_name != NULL) {
......@@ -163,7 +163,7 @@ const rdata_descriptor_t *get_rdata_descriptor(const uint16_t type)
}
}
const rdata_descriptor_t *get_obsolete_rdata_descriptor(const uint16_t type)
const rdata_descriptor_t *knot_get_obsolete_rdata_descriptor(const uint16_t type)
{
if (type <= KNOT_RRTYPE_NXT &&
obsolete_rdata_descriptors[type].type_name != NULL) {
......@@ -179,7 +179,7 @@ int knot_rrtype_to_string(const uint16_t rrtype,
{
int ret;
const rdata_descriptor_t *descr = get_rdata_descriptor(rrtype);
const rdata_descriptor_t *descr = knot_get_rdata_descriptor(rrtype);
if (descr->type_name != NULL) {
ret = snprintf(out, out_len, "%s", descr->type_name);
......@@ -277,18 +277,18 @@ int knot_rrclass_from_string(const char *name, uint16_t *num)
return 0;
}
int descriptor_item_is_dname(const int item)
int knot_descriptor_item_is_dname(const int item)
{
return item == KNOT_RDATA_WF_COMPRESSED_DNAME ||
item == KNOT_RDATA_WF_UNCOMPRESSED_DNAME;
}
int descriptor_item_is_compr_dname(const int item)
int knot_descriptor_item_is_compr_dname(const int item)
{
return item == KNOT_RDATA_WF_COMPRESSED_DNAME;
}
int descriptor_item_is_fixed(const int item)
int knot_descriptor_item_is_fixed(const int item)
{
if (item > 0) {
return 1;
......@@ -297,7 +297,7 @@ int descriptor_item_is_fixed(const int item)
}
}
int descriptor_item_is_remainder(const int item)
int knot_descriptor_item_is_remainder(const int item)
{
if (item == KNOT_RDATA_WF_REMAINDER) {
return 1;
......@@ -330,4 +330,3 @@ int knot_rrtype_additional_needed(const uint16_t type)
type == KNOT_RRTYPE_MX ||
type == KNOT_RRTYPE_SRV;
}
......@@ -164,7 +164,7 @@ typedef struct {
* \retval RR descriptor for given name, NULL descriptor if
* unknown type.
*/
const rdata_descriptor_t *get_rdata_descriptor(const uint16_t type);
const rdata_descriptor_t *knot_get_rdata_descriptor(const uint16_t type);
/*!
* \brief Gets rdata descriptor for given RR name (obsolete version).
......@@ -174,7 +174,7 @@ const rdata_descriptor_t *get_rdata_descriptor(const uint16_t type);
* \retval RR descriptor for given name, NULL descriptor if
* unknown type.
*/
const rdata_descriptor_t *get_obsolete_rdata_descriptor(const uint16_t type);
const rdata_descriptor_t *knot_get_obsolete_rdata_descriptor(const uint16_t type);
/*!
* \brief Converts numeric type representation to mnemonic string.
......@@ -234,7 +234,7 @@ int knot_rrclass_from_string(const char *name, uint16_t *num);
* \retval > 0 if YES.
* \retval 0 if NO.
*/
int descriptor_item_is_dname(const int item);
int knot_descriptor_item_is_dname(const int item);
/*!
* \brief Checks if given item is compressible dname.
......@@ -244,7 +244,7 @@ int descriptor_item_is_dname(const int item);
* \retval > 0 if YES.
* \retval 0 if NO.
*/
int descriptor_item_is_compr_dname(const int item);
int knot_descriptor_item_is_compr_dname(const int item);
/*!
* \brief Checks if given item has fixed size.
......@@ -254,7 +254,7 @@ int descriptor_item_is_compr_dname(const int item);
* \retval 1 if YES.
* \retval 0 if NO.
*/
int descriptor_item_is_fixed(const int item);
int knot_descriptor_item_is_fixed(const int item);
/*!
* \brief Checks if given item is remainder.
......@@ -264,7 +264,7 @@ int descriptor_item_is_fixed(const int item);
* \retval 1 if YES.
* \retval 0 if NO.
*/
int descriptor_item_is_remainder(const int item);
int knot_descriptor_item_is_remainder(const int item);
/*!
* \brief Checks if given item is one of metatypes or qtypes.
......
......@@ -180,11 +180,11 @@ static int knot_rrset_rdata_to_wire_one(const knot_rrset_t *rrset,
/* Compression pointer hint. */
uint16_t hint_id = COMPR_HINT_RDATA + rdata_pos;
const rdata_descriptor_t *desc = get_rdata_descriptor(rrset->type);
const rdata_descriptor_t *desc = knot_get_rdata_descriptor(rrset->type);
for (int i = 0; desc->block_types[i] != KNOT_RDATA_WF_END; i++) {
int item = desc->block_types[i];
if (compr && descriptor_item_is_compr_dname(item)) {
if (compr && knot_descriptor_item_is_compr_dname(item)) {
const knot_dname_t *dname = rdata + offset;
int ret = knot_compr_put_dname(dname, *pos,
max_size - size - rdlength,
......@@ -200,7 +200,7 @@ static int knot_rrset_rdata_to_wire_one(const knot_rrset_t *rrset,
rdlength += ret;
offset += knot_dname_size(dname);
compr->wire_pos += ret;
} else if (descriptor_item_is_dname(item)) {
} else if (knot_descriptor_item_is_dname(item)) {
const knot_dname_t *dname = rdata + offset;
// save whole domain name
size_t maxb = max_size - size - rdlength;
......@@ -217,7 +217,7 @@ static int knot_rrset_rdata_to_wire_one(const knot_rrset_t *rrset,
if (compr) {
compr->wire_pos += dname_size;
}
} else if (descriptor_item_is_fixed(item)) {
} else if (knot_descriptor_item_is_fixed(item)) {
/* Fixed length chunk. */
if (size + rdlength + item > max_size) {
return KNOT_ESPACE;
......@@ -229,7 +229,7 @@ static int knot_rrset_rdata_to_wire_one(const knot_rrset_t *rrset,
if (compr) {
compr->wire_pos += item;
}
} else if (descriptor_item_is_remainder(item)) {
} else if (knot_descriptor_item_is_remainder(item)) {
/* Check that the remainder fits to stream. */
size_t remainder_size =
rrset_rdata_remainder_size(rrset, offset,
......@@ -463,11 +463,11 @@ int knot_rrset_rdata_from_wire_one(knot_rrset_t *rrset,
return knot_rrset_add_rdata(rrset, NULL, 0, ttl, mm);
}
const rdata_descriptor_t *desc = get_rdata_descriptor(rrset->type);
const rdata_descriptor_t *desc = knot_get_rdata_descriptor(rrset->type);
/* Check for obsolete record. */
if (desc->type_name == NULL) {
desc = get_obsolete_rdata_descriptor(rrset->type);
desc = knot_get_obsolete_rdata_descriptor(rrset->type);
}
uint8_t rdata_buffer[rdlength + KNOT_DNAME_MAXLEN];
......@@ -480,7 +480,7 @@ int knot_rrset_rdata_from_wire_one(knot_rrset_t *rrset,
for (int i = 0; desc->block_types[i] != KNOT_RDATA_WF_END &&
parsed < rdlength; ++i) {
const int item = desc->block_types[i];
if (descriptor_item_is_dname(item)) {
if (knot_descriptor_item_is_dname(item)) {
int wire_size = knot_dname_wire_check(wire + *pos,
wire + *pos + rdlength,
wire);
......@@ -498,14 +498,14 @@ int knot_rrset_rdata_from_wire_one(knot_rrset_t *rrset,
*pos += wire_size;
offset += unpacked_size;
} else if (descriptor_item_is_fixed(item)) {
} else if (knot_descriptor_item_is_fixed(item)) {
int ret = binary_store(rdata_buffer, &offset, packet_offset,
wire, pos, rdlength, item);
if (ret != KNOT_EOK) {
return ret;
}
parsed += item;
} else if (descriptor_item_is_remainder(item)) {
} else if (knot_descriptor_item_is_remainder(item)) {
/* Item size has to be calculated. */
size_t remainder_size = rdlength - parsed;
int ret = binary_store(rdata_buffer, &offset, packet_offset,
......
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