From 6b286788c724b12da99661eec1d9a40cf82a046b Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Sun, 16 Aug 2020 15:40:25 +0300 Subject: SRV parsing added. --- dns_example.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'dns_example.c') diff --git a/dns_example.c b/dns_example.c index f6efeba..9f16dc0 100644 --- a/dns_example.c +++ b/dns_example.c @@ -10,12 +10,18 @@ int main() for (cur = ans; cur; cur = cur->next) { if (cur->type == dns_type_a) { unsigned char *ip = cur->data; - printf("IP of %s is %d.%d.%d.%d.\n", + printf("IP address of %s is %d.%d.%d.%d.\n", cur->host, ip[0], ip[1], ip[2], ip[3]); } else if (cur->type == dns_type_cname) { printf("Cannonical name of %s is %s.\n", cur->host, cur->data); } else if (cur->type == dns_type_txt) { printf("Text from %s: %s\n", cur->host, cur->data); + } else if (cur->type == dns_type_srv) { + printf("Service %s is located at %s on port %d " + "with priority %d and weight %d.\n", + cur->host, + dns_srv_server(cur->data), dns_srv_port(cur->data), + dns_srv_priority(cur->data), dns_srv_weight(cur->data)); } else if (cur->type == dns_type_mx) { printf("Mail exchange server for %s with preference %d is %s.\n", cur->host, -- cgit v1.2.3