[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH 2/2] nslookup: implement support for SRV records
From:       Jo-Philipp Wich <jo () mein ! io>
Date:       2019-06-27 15:27:29
Message-ID: 20190627152729.6861-2-jo () mein ! io
[Download RAW message or body]

Add support for querying and parsing SRV DNS records.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
---
 networking/nslookup.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/networking/nslookup.c b/networking/nslookup.c
index f7fd1d377..f6fb1672a 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -283,6 +283,7 @@ static const struct {
 	{ ns_t_cname, "CNAME" },
 	{ ns_t_mx,    "MX"    },
 	{ ns_t_txt,   "TXT"   },
+	{ ns_t_srv,   "SRV"   },
 	{ ns_t_ptr,   "PTR"   },
 	{ ns_t_any,   "ANY"   },
 };
@@ -435,6 +436,25 @@ static int parse_reply(const unsigned char *msg, size_t len)
 			}
 			break;
 
+		case ns_t_srv:
+			if (rdlen < 6) {
+				//printf("SRV record too short\n");
+				return -1;
+			}
+
+			cp = ns_rr_rdata(rr);
+			n = ns_name_uncompress(ns_msg_base(handle), ns_msg_end(handle),
+			                       cp + 6, dname, sizeof(dname));
+
+			if (n < 0) {
+				//printf("Unable to uncompress domain: %s\n", strerror(errno));
+				return -1;
+			}
+
+			printf("%s\tservice = %hu %hu %hu %s\n", ns_rr_name(rr),
+				ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), dname);
+			break;
+
 		case ns_t_soa:
 			if (rdlen < 20) {
 				dbg("SOA record too short:%d\n", rdlen);
-- 
2.11.0

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic