diff options
Diffstat (limited to 'apt-pkg/contrib/srvrec.cc')
-rw-r--r-- | apt-pkg/contrib/srvrec.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/apt-pkg/contrib/srvrec.cc b/apt-pkg/contrib/srvrec.cc index 352a56970..c473192fc 100644 --- a/apt-pkg/contrib/srvrec.cc +++ b/apt-pkg/contrib/srvrec.cc @@ -8,15 +8,29 @@ /*}}}*/ #include <config.h> +#include <netdb.h> + #include <netinet/in.h> #include <arpa/nameser.h> #include <resolv.h> #include <algorithm> +#include <apt-pkg/strutl.h> #include <apt-pkg/error.h> #include "srvrec.h" +bool GetSrvRecords(std::string host, int port, std::vector<SrvRec> &Result) +{ + std::string target; + struct servent *s_ent = getservbyport(htons(port), "tcp"); + if (s_ent == NULL) + return false; + + strprintf(target, "_%s._tcp.%s", s_ent->s_name, host.c_str()); + return GetSrvRecords(target, Result); +} + bool GetSrvRecords(std::string name, std::vector<SrvRec> &Result) { unsigned char answer[PACKETSZ]; |