Commit 2ee19a2e authored by Vladimír Čunát's avatar Vladimír Čunát

nsrep: eradicate kr_nsrep_inaddr*

They're just useless when we have kr_inaddr*.
parent cd2755bf
......@@ -269,8 +269,8 @@ int kr_nsrep_update_rtt(struct kr_nsrep *ns, const struct sockaddr *addr,
return kr_error(EINVAL);
}
const char *addr_in = kr_nsrep_inaddr(ns->addr[0]);
size_t addr_len = kr_nsrep_inaddr_len(ns->addr[0]);
const char *addr_in = kr_inaddr(&ns->addr[0].ip);
size_t addr_len = kr_inaddr_len(&ns->addr[0].ip);
if (addr) { /* Caller provided specific address */
if (addr->sa_family == AF_INET) {
addr_in = (const char *)&((struct sockaddr_in *)addr)->sin_addr;
......
......@@ -81,13 +81,6 @@ struct kr_nsrep
union inaddr addr[KR_NSREP_MAXADDR]; /**< NS address(es) */
};
/** @internal Address bytes for given family. */
#define kr_nsrep_inaddr(addr) \
((addr).ip.sa_family == AF_INET ? (void *)&((addr).ip4.sin_addr) : (void *)&((addr).ip6.sin6_addr))
/** @internal Address length for given family. */
#define kr_nsrep_inaddr_len(addr) \
((addr).ip.sa_family == AF_INET ? sizeof(struct in_addr) : sizeof(struct in6_addr))
/**
* Set given NS address.
* @param qry updated query
......
......@@ -149,11 +149,11 @@ static void randomized_qname_case(knot_dname_t * restrict qname, uint32_t secret
static int invalidate_ns(struct kr_rplan *rplan, struct kr_query *qry)
{
if (qry->ns.addr[0].ip.sa_family != AF_UNSPEC) {
uint8_t *addr = kr_nsrep_inaddr(qry->ns.addr[0]);
size_t addr_len = kr_nsrep_inaddr_len(qry->ns.addr[0]);
const char *addr = kr_inaddr(&qry->ns.addr[0].ip);
size_t addr_len = kr_inaddr_len(&qry->ns.addr[0].ip);
/* @warning _NOT_ thread-safe */
static knot_rdata_t rdata_arr[RDATA_ARR_MAX];
knot_rdata_init(rdata_arr, addr_len, addr, 0);
knot_rdata_init(rdata_arr, addr_len, (const uint8_t *)addr, 0);
return kr_zonecut_del(&qry->zone_cut, qry->ns.name, rdata_arr);
} else {
return kr_zonecut_del_all(&qry->zone_cut, qry->ns.name);
......@@ -1508,7 +1508,7 @@ int kr_resolve_checkout(struct kr_request *request, struct sockaddr *src,
if (!kr_inaddr_equal(dst, addr)) {
continue;
}
inet_ntop(addr->sa_family, kr_nsrep_inaddr(qry->ns.addr[i]), ns_str, sizeof(ns_str));
inet_ntop(addr->sa_family, kr_inaddr(&qry->ns.addr[i].ip), ns_str, sizeof(ns_str));
VERBOSE_MSG(qry, "=> querying: '%s' score: %u zone cut: '%s' m12n: '%s' type: '%s' proto: '%s'\n",
ns_str, qry->ns.score, zonecut_str, qname_str, type_str, (qry->flags & QUERY_TCP) ? "tcp" : "udp");
break;
......
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