Commit 8ad9b946 authored by Daniel Salzman's avatar Daniel Salzman

libknot/dname: remove unused knot_dname_cmp_wire

parent ef2fa0de
......@@ -654,39 +654,35 @@ void knot_dname_free(knot_dname_t **name, knot_mm_t *mm)
/*----------------------------------------------------------------------------*/
_public_
int knot_dname_cmp(const knot_dname_t *d1, const knot_dname_t *d2)
{
return knot_dname_cmp_wire(d1, d2, NULL);
}
/*----------------------------------------------------------------------------*/
_public_
int knot_dname_cmp_wire(const knot_dname_t *d1, const knot_dname_t *d2,
const uint8_t *pkt)
{
/* This would be hard to catch since -1 is a good result, assert instead. */
assert(d1 != NULL || d2 != NULL);
/* Convert to lookup format. */
uint8_t d1_lf[KNOT_DNAME_MAXLEN], d2_lf[KNOT_DNAME_MAXLEN];
if (knot_dname_lf(d1_lf, d1, pkt) < 0 || knot_dname_lf(d2_lf, d2, pkt) < 0) {
if (knot_dname_lf(d1_lf, d1, NULL) < 0 || knot_dname_lf(d2_lf, d2, NULL) < 0) {
assert(0); /* This must not happened as the d1, d2 are checked. */
return KNOT_EINVAL;
}
/* Compare common part. */
uint8_t common = d1_lf[0];
if (common > d2_lf[0])
if (common > d2_lf[0]) {
common = d2_lf[0];
int ret = memcmp(d1_lf+1, d2_lf+1, common);
if (ret != 0)
}
int ret = memcmp(d1_lf + 1, d2_lf + 1, common);
if (ret != 0) {
return ret;
}
/* If they match, compare lengths. */
if (d1_lf[0] < d2_lf[0])
if (d1_lf[0] < d2_lf[0]) {
return -1;
if (d1_lf[0] > d2_lf[0])
} else if (d1_lf[0] > d2_lf[0]) {
return 1;
return 0;
} else {
return 0;
}
}
/*----------------------------------------------------------------------------*/
......
......@@ -281,7 +281,11 @@ knot_dname_t *knot_dname_replace_suffix(const knot_dname_t *name, unsigned label
void knot_dname_free(knot_dname_t **name, knot_mm_t *mm);
/*!
* \brief Compares two domain names (case sensitive).
* \brief Compares two domain names by labels (case sensitive).
*
* \warning Since it would be hard to catch errors, because negative value
* is also a good result, there are assertions that expect neither
* d1 or d2 to be NULL.
*
* \param d1 First domain name.
* \param d2 Second domain name.
......@@ -293,27 +297,6 @@ void knot_dname_free(knot_dname_t **name, knot_mm_t *mm);
_pure_
int knot_dname_cmp(const knot_dname_t *d1, const knot_dname_t *d2);
/*!
* \brief Compare domain name by labels.
*
* \todo No case insensitivity, flags...
*
* \warning Since it would be hard to catch errors, because negative value
* is also a good result, there are assertions that expect neither
* d1 or d2 to be NULL.
*
* \param d1 Domain name.
* \param d2 Domain name.
* \param pkt Packet wire related to names (or NULL).
*
* \retval 0 if they are identical
* \retval 1 if d1 > d2
* \retval -1 if d1 < d2
*/
_pure_
int knot_dname_cmp_wire(const knot_dname_t *d1, const knot_dname_t *d2,
const uint8_t *pkt);
/*!
* \brief Compares two domain names (case sensitive).
*
......
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