diff --git a/mio/lib/main.c b/mio/lib/main.c index 4ec0c20..a86b30c 100644 --- a/mio/lib/main.c +++ b/mio/lib/main.c @@ -811,11 +811,23 @@ for (i = 0; i < 5; i++) mio_dnsc_t* dnsc; dnsc = mio_dnsc_start (mio/*, "8.8.8.8:53,1.1.1.1:53"*/); /* option - send to all, send one by one */ { - mio_dns_bqrr_t qrr; - qrr.name = "code.miflux.com"; - qrr.qclass = MIO_DNS_QCLASS_IN; - qrr.qtype = MIO_DNS_QTYPE_A; - mio_dnsc_sendreq (dnsc, &qrr, 1); + mio_dns_bqrr_t qrrs[] = + { + { "code.miflux.com", MIO_DNS_QTYPE_A, MIO_DNS_QCLASS_IN }, + { "code.miflux.com", MIO_DNS_QTYPE_AAAA, MIO_DNS_QCLASS_IN }, + { "code.abiyo.net", MIO_DNS_QTYPE_A, MIO_DNS_QCLASS_IN }, + { "code6.abiyo.net", MIO_DNS_QTYPE_AAAA, MIO_DNS_QCLASS_IN }, + { "abiyo.net", MIO_DNS_QTYPE_MX, MIO_DNS_QCLASS_IN } + }; + mio_dns_brrr_t rrrs[] = + { + { MIO_DNS_RRR_PART_ANSWER, "code.miflux.com", MIO_DNS_QTYPE_A, MIO_DNS_QCLASS_IN, 86400, 0, MIO_NULL }, + { MIO_DNS_RRR_PART_ANSWER, "code.miflux.com", MIO_DNS_QTYPE_AAAA, MIO_DNS_QCLASS_IN, 86400, 0, MIO_NULL }, + { MIO_DNS_RRR_PART_AUTHORITY, "dns.miflux.com", MIO_DNS_QTYPE_NS, MIO_DNS_QCLASS_IN, 86400, 0, MIO_NULL } + }; + + mio_dnsc_sendreq (dnsc, qrrs, MIO_COUNTOF(qrrs)); + mio_dnsc_sendrep (dnsc, qrrs, MIO_COUNTOF(qrrs), rrrs, MIO_COUNTOF(rrrs)); } mio_loop (mio); diff --git a/mio/lib/mio-dns.h b/mio/lib/mio-dns.h index 736f32c..3c7d912 100644 --- a/mio/lib/mio-dns.h +++ b/mio/lib/mio-dns.h @@ -127,12 +127,19 @@ struct mio_dns_msg_t #endif mio_uint16_t qdcount; /* number of questions */ - mio_uint16_t ancount; /* number of answers (answer section) */ - mio_uint16_t nscount; /* number of name servers (authority section. only NS types) */ - mio_uint16_t arcount; /* number of additional resource (additional section) */ + mio_uint16_t ancount; /* number of answers (answer part) */ + mio_uint16_t nscount; /* number of name servers (authority part. only NS types) */ + mio_uint16_t arcount; /* number of additional resource (additional part) */ }; typedef struct mio_dns_msg_t mio_dns_msg_t; +struct mio_dns_msg_alt_t +{ + mio_uint16_t id; + mio_uint16_t flags; + mio_uint16_t rrcount[4]; +}; +typedef struct mio_dns_msg_alt_t mio_dns_msg_alt_t; /* question * name, qtype, qclass * answer @@ -149,7 +156,7 @@ struct mio_dns_qrrtr_t typedef struct mio_dns_qrrtr_t mio_dns_qrrtr_t; /* trailing part after the domain name in a resource record in an answer */ -struct mio_dns_arrtr_t +struct mio_dns_rrrtr_t { /* qname upto 64 bytes */ mio_uint16_t qtype; @@ -158,7 +165,7 @@ struct mio_dns_arrtr_t mio_uint16_t dlen; /* data length */ /* actual data if if dlen > 0 */ }; -typedef struct mio_dns_arrtr_t mio_dns_arrtr_t; +typedef struct mio_dns_rrrtr_t mio_dns_rrrtr_t; #include @@ -168,12 +175,32 @@ typedef struct mio_dnsc_t mio_dnsc_t; struct mio_dns_bqrr_t { - mio_bch_t* name; + mio_bch_t* qname; mio_uint16_t qtype; mio_uint16_t qclass; }; typedef struct mio_dns_bqrr_t mio_dns_bqrr_t; +enum mio_dns_rrr_part_t +{ + MIO_DNS_RRR_PART_ANSWER, + MIO_DNS_RRR_PART_AUTHORITY, + MIO_DNS_RRR_PART_ADDITIONAL +}; +typedef enum mio_dns_rrr_part_t mio_dns_rrr_part_t; + +struct mio_dns_brrr_t +{ + mio_dns_rrr_part_t part; + mio_bch_t* qname; + mio_uint16_t qtype; + mio_uint16_t qclass; + mio_uint32_t ttl; + mio_uint16_t dlen; + void* dptr; +}; +typedef struct mio_dns_brrr_t mio_dns_brrr_t; + #if defined(__cplusplus) extern "C" { #endif @@ -189,7 +216,15 @@ MIO_EXPORT void mio_dnsc_stop ( MIO_EXPORT int mio_dnsc_sendreq ( mio_dnsc_t* dnsc, mio_dns_bqrr_t* qrr, - mio_oow_t count + mio_oow_t qrr_count +); + +MIO_EXPORT int mio_dnsc_sendrep ( + mio_dnsc_t* dnsc, + mio_dns_bqrr_t* qrr, + mio_oow_t qrr_count, + mio_dns_brrr_t* rrr, + mio_oow_t rrr_count ); #if defined(__cplusplus)