smaller (char *buf, unsigned int len, unsigned int pos1, unsigned int pos2)
{
    int r = 0;
    char header1[12], header2[12];
    unsigned int len1 = 0, len2 = 0;

    pos1 = dns_packet_getname (buf, len, pos1, &t1);
    dns_packet_copy (buf, len, pos1, header1, 10);
    pos2 = dns_packet_getname (buf, len, pos2, &t2);
    dns_packet_copy (buf, len, pos2, header2, 10);

    r = byte_diff (header1, 4, header2);
    if (r < 0)
        return 1;
    if (r > 0)
        return 0;

    len1 = dns_domain_length (t1);
    len2 = dns_domain_length (t2);
    if (len1 < len2)
        return 1;
    if (len1 > len2)
        return 0;

    r = case_diffb (t1, len1, t2);
    if (r < 0)
        return 1;
    if (r > 0)
        return 0;

    if (pos1 < pos2)
        return 1;

    return 0;
}
smaller (char *buf, unsigned int len, unsigned int pos1, unsigned int pos2)
{
    int r = 0;
    char header1[12], header2[12];
    unsigned int len1 = 0, len2 = 0;

    pos1 = dns_packet_getname (buf, len, pos1, &t1);
    dns_packet_copy (buf, len, pos1, header1, 10);
    pos2 = dns_packet_getname (buf, len, pos2, &t2);
    dns_packet_copy (buf, len, pos2, header2, 10);

    r = byte_diff (header1, 4, header2);
    if (r < 0)
        return 1;
    if (r > 0)
        return 0;

    len1 = dns_domain_length (t1);
    len2 = dns_domain_length (t2);
    if (len1 < len2)
        return 1;
    if (len1 > len2)
        return 0;

    r = case_diffb (t1, len1, t2);
    if (r < 0)
        return 1;
    if (r > 0)
        return 0;

    if (pos1 < pos2)
        return 1;

    return 0;
}