Commit dc95624b authored by Martti Mela's avatar Martti Mela
Browse files

additional #ifdefs for IPv6 (un)support.

darcs-hash:20051201073210-1b897-dd73814c4ec6a6055cbf5054d41914a84c281f19.gz
parent 48fd3b7e
......@@ -363,10 +363,13 @@ static void sres_init_rr_soa(sres_resolver_t *res, sres_soa_record_t *rr,
sres_message_t *m);
static void sres_init_rr_a(sres_resolver_t *res, sres_a_record_t *rr,
sres_message_t *m);
#if SU_HAVE_IN6
static void sres_init_rr_a6(sres_resolver_t *res, sres_a6_record_t *rr,
sres_message_t *m);
static void sres_init_rr_aaaa(sres_resolver_t *res, sres_aaaa_record_t *rr,
sres_message_t *m);
#endif
static void sres_init_rr_cname(sres_resolver_t *res, sres_cname_record_t *rr,
sres_message_t *m);
static void sres_init_rr_ptr(sres_resolver_t *res, sres_ptr_record_t *rr,
......@@ -1024,6 +1027,7 @@ sres_record_compare(sres_record_t const *aa, sres_record_t const *bb)
sres_a_record_t const *A = aa->sr_a, *B = bb->sr_a;
return memcmp(&A->a_addr, &B->a_addr, sizeof A->a_addr);
}
#if SU_HAVE_IN6
case sres_type_a6:
{
sres_a6_record_t const *A = aa->sr_a6, *B = bb->sr_a6;
......@@ -1036,6 +1040,7 @@ sres_record_compare(sres_record_t const *aa, sres_record_t const *bb)
sres_aaaa_record_t const *A = aa->sr_aaaa, *B = bb->sr_aaaa;
return memcmp(&A->aaaa_addr, &B->aaaa_addr, sizeof A->aaaa_addr);
}
#endif
case sres_type_cname:
{
sres_cname_record_t const *A = aa->sr_cname, *B = bb->sr_cname;
......@@ -2058,10 +2063,12 @@ void sres_log_response(sres_resolver_t const *res,
struct sockaddr_in const *sin = (void *)from;
inet_ntop(AF_INET, &sin->sin_addr, host, sizeof host);
}
#if HAVE_SIN6
else if (from->ss_family == AF_INET6) {
struct sockaddr_in6 const *sin6 = (void *)from;
inet_ntop(AF_INET6, &sin6->sin6_addr, host, sizeof host);
}
#endif
else
strcpy(host, "*");
......@@ -2202,8 +2209,10 @@ sres_alloc_record(sres_resolver_t *res, uint16_t qtype, uint16_t rdlen)
switch (qtype) {
case sres_type_soa: size = sizeof(sres_soa_record_t); break;
case sres_type_a: size = sizeof(sres_a_record_t); break;
#if SU_HAVE_IN6
case sres_type_a6: size = sizeof(sres_a6_record_t); break;
case sres_type_aaaa: size = sizeof(sres_aaaa_record_t); break;
#endif
case sres_type_cname: size = sizeof(sres_cname_record_t); break;
case sres_type_ptr: size = sizeof(sres_ptr_record_t); break;
case sres_type_srv: size = sizeof(sres_srv_record_t); break;
......@@ -2253,12 +2262,14 @@ sres_create_record(sres_resolver_t *res, sres_message_t *m)
case sres_type_a:
sres_init_rr_a(res, rr->sr_a, m);
break;
#if SU_HAVE_IN6
case sres_type_a6:
sres_init_rr_a6(res, rr->sr_a6, m);
break;
case sres_type_aaaa:
sres_init_rr_aaaa(res, rr->sr_aaaa, m);
break;
#endif
case sres_type_cname:
sres_init_rr_cname(res, rr->sr_cname, m);
break;
......@@ -2328,6 +2339,7 @@ sres_init_rr_a(sres_resolver_t *res,
rr->a_addr.s_addr = htonl(m_get_uint32(m));
}
#if SU_HAVE_IN6
static void
sres_init_rr_a6(sres_resolver_t *res,
sres_a6_record_t *rr,
......@@ -2372,6 +2384,7 @@ sres_init_rr_aaaa(sres_resolver_t *res,
m->m_offset += sizeof(rr->aaaa_addr.s6_addr);
}
#endif /* SU_HAVE_IN6 */
static void
sres_init_rr_cname(sres_resolver_t *res,
......
......@@ -121,6 +121,7 @@ struct sres_a_record
struct in_addr a_addr;
};
#if SU_HAVE_IN6
/** Address record for IPv6 (RFC 2874, deprecated). */
struct sres_a6_record
{
......@@ -137,6 +138,7 @@ struct sres_aaaa_record
sres_common_t aaaa_record[1];
struct in6_addr aaaa_addr;
};
#endif /* if SU_HAVE_IN6 */
/** Canonic name record (RFC 1035). */
struct sres_cname_record
......@@ -184,8 +186,10 @@ union sres_record
sres_a_record_t sr_a[1];
sres_cname_record_t sr_cname[1];
sres_ptr_record_t sr_ptr[1];
#if SU_HAVE_IN6
sres_a6_record_t sr_a6[1];
sres_aaaa_record_t sr_aaaa[1];
#endif
sres_srv_record_t sr_srv[1];
sres_naptr_record_t sr_naptr[1];
};
......
......@@ -597,6 +597,7 @@ int test_a(sres_context_t *ctx)
END();
}
#if HAVE_SIN6
int test_a6(sres_context_t *ctx)
{
sres_resolver_t *res = ctx->resolver;
......@@ -729,6 +730,7 @@ int test_aaaa(sres_context_t *ctx)
END();
}
#endif /* HAVE_SIN6 */
int test_srv(sres_context_t *ctx)
{
......@@ -918,6 +920,7 @@ int test_ptr_ipv4_sockaddr(sres_context_t *ctx)
END();
}
#if HAVE_SIN6
int test_ptr_ipv6(sres_context_t *ctx)
{
sres_resolver_t *res = ctx->resolver;
......@@ -981,6 +984,7 @@ int test_ptr_ipv6_sockaddr(sres_context_t *ctx)
END();
}
#endif /* HAVE_SIN6 */
/* Test sres_cached_answers(), sres_sort_answers(), sres_free_answers() */
int test_cache(sres_context_t *ctx)
......@@ -996,7 +1000,9 @@ int test_cache(sres_context_t *ctx)
const sres_aaaa_record_t *rr_aaaa;
const sres_cname_record_t *rr_cname;
const sres_ptr_record_t *rr_ptr;
#if HAVE_SIN6
struct sockaddr_in6 sin6 = {0};
#endif
char const *domain;
char buf[50] = {0};
int i, j;
......@@ -1015,6 +1021,7 @@ int test_cache(sres_context_t *ctx)
sres_query_make(res, test_answer_multi, ctx, s,
sres_qtype_any, "subnet.example.com");
#if HAVE_SIN6
sres_query_make(res, test_answer_multi, ctx, s,
sres_type_aaaa, "mgw02.example.com");
......@@ -1028,6 +1035,7 @@ int test_cache(sres_context_t *ctx)
sres_qtype_any, (struct sockaddr *)&sin6);
TEST_1(query != NULL);
#endif
TEST_RUN(ctx);
......@@ -1211,6 +1219,7 @@ int test_cache(sres_context_t *ctx)
sres_free_answers(res, result);
#if HAVE_SIN6
domain = "subnet.example.com";
result = sres_cached_answers(res,
sres_qtype_any,
......@@ -1255,10 +1264,12 @@ int test_cache(sres_context_t *ctx)
TEST_S(rr_ptr->ptr_domain, "sip01.example.com.");
sres_free_answers(res, result);
#endif /* HAVE_SIN6 */
END();
}
#if HAVE_SIN6
int test_query_one_type(sres_context_t *ctx)
{
sres_resolver_t *res = ctx->resolver;
......@@ -1286,6 +1297,7 @@ int test_query_one_type(sres_context_t *ctx)
END();
}
#endif /* HAVE_SIN6*/
int sink_make(sres_context_t *ctx)
{
......@@ -1931,17 +1943,23 @@ int main(int argc, char **argv)
error |= test_a(ctx);
error |= test_soa(ctx);
error |= test_naptr(ctx);
#if HAVE_SIN6
error |= test_a6(ctx);
error |= test_a6_prefix(ctx);
error |= test_aaaa(ctx);
#endif
error |= test_srv(ctx);
error |= test_cname(ctx);
error |= test_ptr_ipv4(ctx);
error |= test_ptr_ipv4_sockaddr(ctx);
#if HAVE_SIN6
error |= test_ptr_ipv6(ctx);
error |= test_ptr_ipv6_sockaddr(ctx);
#endif
error |= test_cache(ctx);
#if HAVE_SIN6
error |= test_query_one_type(ctx);
#endif
error |= test_expiration(ctx);
}
error |= test_deinit(ctx) | initerror;
......
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