Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36ffe43e authored by Hungming Chen's avatar Hungming Chen Committed by Nucca Chen
Browse files

Expose rfc6724 sorting function

A preparation for sorting the DNS64 results.

Bug: 159305929
Test: atest ResolverTest
Change-Id: I7e5e5c450b870f1ac37e96b8f7d3ab24ef74f451
parent 5d4650ff
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1344,7 +1344,9 @@ static int _find_src_addr(const struct sockaddr* addr, struct sockaddr* src_addr
 * Will leave the list unchanged if an error occurs.
 */

static void _rfc6724_sort(struct addrinfo* list_sentinel, unsigned mark, uid_t uid) {
void resolv_rfc6724_sort(struct addrinfo* list_sentinel, unsigned mark, uid_t uid) {
    if (list_sentinel == nullptr) return;

    struct addrinfo* cur;
    int nelem = 0, i;
    struct addrinfo_sort_elem* elems;
@@ -1464,7 +1466,7 @@ static int dns_getaddrinfo(const char* name, const addrinfo* pai,
        return herrnoToAiErrno(he);
    }

    _rfc6724_sort(&sentinel, netcontext->app_mark, netcontext->uid);
    resolv_rfc6724_sort(&sentinel, netcontext->app_mark, netcontext->uid);

    *rv = sentinel.ai_next;
    return 0;
+3 −0
Original line number Diff line number Diff line
@@ -29,3 +29,6 @@ int android_getaddrinfofornetcontext(const char* hostname, const char* servname,
int resolv_getaddrinfo(const char* hostname, const char* servname, const addrinfo* hints,
                       const android_net_context* netcontext, addrinfo** res,
                       android::net::NetworkDnsEventReported*);

// Sort the linked list starting at sentinel->ai_next in RFC6724 order.
void resolv_rfc6724_sort(struct addrinfo* list_sentinel, unsigned mark, uid_t uid);