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

Commit 2b017232 authored by Bernie Innocenti's avatar Bernie Innocenti
Browse files

Rename ResState::_flags to ResState::flags

Change-Id: I2f6b634f12bba687be7846abba09da75eef1ab72
parent 983f02ec
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1437,7 +1437,7 @@ static int dns_getaddrinfo(const char* name, const addrinfo* pai,

    ResState res(netcontext, event);

    setMdnsFlag(name, &(res._flags));
    setMdnsFlag(name, &(res.flags));

    int he;
    if (res_searchN(name, &q, &res, &he) < 0) {
@@ -1653,7 +1653,7 @@ QueryResult doQuery(const char* name, res_target* t, ResState* res,
        // if the query choked with EDNS0, retry without EDNS0
        if ((res_temp.netcontext_flags &
             (NET_CONTEXT_FLAG_USE_DNS_OVER_TLS | NET_CONTEXT_FLAG_USE_EDNS)) &&
            (res_temp._flags & RES_F_EDNS0ERR)) {
            (res_temp.flags & RES_F_EDNS0ERR)) {
            LOG(DEBUG) << __func__ << ": retry without EDNS0";
            n = res_nmkquery(QUERY, name, cl, type, /*data=*/nullptr, /*datalen=*/0, buf,
                             sizeof(buf), res_temp.netcontext_flags);
@@ -1780,7 +1780,7 @@ static int res_queryN(const char* name, res_target* target, ResState* res, int*
            // we also has the same symptom if EDNS is enabled.
            if ((res->netcontext_flags &
                 (NET_CONTEXT_FLAG_USE_DNS_OVER_TLS | NET_CONTEXT_FLAG_USE_EDNS)) &&
                (res->_flags & RES_F_EDNS0ERR) && !retried) {
                (res->flags & RES_F_EDNS0ERR) && !retried) {
                LOG(DEBUG) << __func__ << ": retry without EDNS0";
                retried = true;
                goto again;
@@ -1843,7 +1843,7 @@ static int res_searchN(const char* name, res_target* target, ResState* res, int*
     *	 - there is at least one dot and there is no trailing dot.
     * - this is not a .local mDNS lookup.
     */
    if ((!dots || (dots && !trailing_dot)) && !isMdnsResolution(res->_flags)) {
    if ((!dots || (dots && !trailing_dot)) && !isMdnsResolution(res->flags)) {
        int done = 0;

        /* Unfortunately we need to set stuff up before
+1 −1
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ int resolv_gethostbyname(const char* name, int af, hostent* hp, char* buf, size_
    getnamaddr info;
    ResState res(netcontext, event);

    setMdnsFlag(name, &(res._flags));
    setMdnsFlag(name, &(res.flags));

    size_t size;
    switch (af) {
+2 −2
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ again:
        // we also has the same symptom if EDNS is enabled.
        if ((statp->netcontext_flags &
             (NET_CONTEXT_FLAG_USE_DNS_OVER_TLS | NET_CONTEXT_FLAG_USE_EDNS)) &&
            (statp->_flags & RES_F_EDNS0ERR) && !retried) {
            (statp->flags & RES_F_EDNS0ERR) && !retried) {
            LOG(DEBUG) << __func__ << ": retry without EDNS0";
            retried = true;
            goto again;
@@ -240,7 +240,7 @@ int res_nsearch(ResState* statp, const char* name, /* domain name */
     *	- there is no dot, or
     *	- there is at least one dot and there is no trailing dot.
     */
    if ((!dots || (dots && !trailing_dot)) && !isMdnsResolution(statp->_flags)) {
    if ((!dots || (dots && !trailing_dot)) && !isMdnsResolution(statp->flags)) {
        int done = 0;

        /* Unfortunately we need to load network-specific info
+6 −6
Original line number Diff line number Diff line
@@ -457,7 +457,7 @@ int res_nsend(ResState* statp, const uint8_t* buf, int buflen, uint8_t* ans, int
    }

    // MDNS
    if (isMdnsResolution(statp->_flags)) {
    if (isMdnsResolution(statp->flags)) {
        // Use an impossible error code as default value.
        int terrno = ETIME;
        int resplen = 0;
@@ -509,7 +509,7 @@ int res_nsend(ResState* statp, const uint8_t* buf, int buflen, uint8_t* ans, int
    }
    // DoT
    if (!(statp->netcontext_flags & NET_CONTEXT_FLAG_USE_LOCAL_NAMESERVERS) &&
        !isMdnsResolution(statp->_flags)) {
        !isMdnsResolution(statp->flags)) {
        bool fallback = false;
        int resplen = res_tls_send(statp, Slice(const_cast<uint8_t*>(buf), buflen),
                                   Slice(ans, anssiz), rcode, &fallback);
@@ -731,7 +731,7 @@ same_ns:
    struct timespec start_time = evNowTime();

    /* Are we still talking to whom we want to talk to? */
    if (statp->tcp_nssock >= 0 && (statp->_flags & RES_F_VC) != 0) {
    if (statp->tcp_nssock >= 0 && (statp->flags & RES_F_VC) != 0) {
        struct sockaddr_storage peer;
        socklen_t size = sizeof peer;
        unsigned old_mark;
@@ -744,7 +744,7 @@ same_ns:
        }
    }

    if (statp->tcp_nssock < 0 || (statp->_flags & RES_F_VC) == 0) {
    if (statp->tcp_nssock < 0 || (statp->flags & RES_F_VC) == 0) {
        if (statp->tcp_nssock >= 0) statp->closeSockets();

        statp->tcp_nssock.reset(socket(nsap->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0));
@@ -793,7 +793,7 @@ same_ns:
            *rcode = RCODE_TIMEOUT;
            return (0);
        }
        statp->_flags |= RES_F_VC;
        statp->flags |= RES_F_VC;
    }

    /*
@@ -1172,7 +1172,7 @@ static int send_dg(ResState* statp, res_params* params, const uint8_t* buf, int
                LOG(DEBUG) << __func__ << ": server rejected query with EDNS0:";
                res_pquery(ans, (resplen > anssiz) ? anssiz : resplen);
                // record the error
                statp->_flags |= RES_F_EDNS0ERR;
                statp->flags |= RES_F_EDNS0ERR;
                *terrno = EREMOTEIO;
                continue;
            }
+7 −7
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@
#define RES_TIMEOUT 5000 /* min. milliseconds between retries */
#define RES_DFLRETRY 2    /* Default #/tries. */

// Flags for ResState::_flags
// Flags for ResState::flags
#define RES_F_VC 0x00000001        // socket is TCP
#define RES_F_EDNS0ERR 0x00000004  // EDNS0 caused errors
#define RES_F_MDNS 0x00000008      // MDNS packet
@@ -108,7 +108,7 @@ struct ResState {
        copy.nsaddrs = nsaddrs;
        copy.ndots = ndots;
        copy._mark = _mark;
        copy._flags = _flags;
        copy.flags = flags;
        copy.event = (dnsEvent == nullptr) ? event : dnsEvent;
        copy.netcontext_flags = netcontext_flags;
        copy.tc_mode = tc_mode;
@@ -118,7 +118,7 @@ struct ResState {
    }
    void closeSockets() {
        tcp_nssock.reset();
        _flags &= ~RES_F_VC;
        flags &= ~RES_F_VC;

        for (auto& sock : udpsocks) {
            sock.reset();
@@ -133,18 +133,18 @@ struct ResState {
    pid_t pid;                                  // pid of the app that sent the DNS lookup
    std::vector<std::string> search_domains{};  // domains to search
    std::vector<android::netdutils::IPSockAddr> nsaddrs;
    android::base::unique_fd udpsocks[MAXNS];    // UDP sockets to nameservers and mdns responsder
    android::base::unique_fd udpsocks[MAXNS];   // UDP sockets to nameservers
    unsigned ndots : 4 = 1;                     // threshold for initial abs. query
    unsigned _mark;                             // If non-0 SET_MARK to _mark on all request sockets
    android::base::unique_fd tcp_nssock;        // TCP socket (but why not one per nameserver?)
    uint32_t _flags = 0;                        // See RES_F_* defines below
    uint32_t flags = 0;                         // See RES_F_* defines below
    android::net::NetworkDnsEventReported* event;
    uint32_t netcontext_flags;
    int tc_mode = 0;
    bool enforce_dns_uid = false;
    bool sort_nameservers = false;              // A flag to indicate whether nsaddrs has been
                                                // sorted or not.
    bool sort_nameservers = false;              // True if nsaddrs has been sorted.
    // clang-format on

  private:
    ResState() {}
};