32 lines
1.2 KiB
Diff
32 lines
1.2 KiB
Diff
|
diff -u -r ../apt-1.1.3/apt-pkg/contrib/srvrec.cc ./apt-pkg/contrib/srvrec.cc
|
||
|
--- ../apt-1.1.3/apt-pkg/contrib/srvrec.cc 2015-11-30 03:08:24.000000000 -0500
|
||
|
+++ ./apt-pkg/contrib/srvrec.cc 2015-12-03 16:21:54.397715576 -0500
|
||
|
@@ -40,14 +40,27 @@
|
||
|
struct servent *s_ent = nullptr;
|
||
|
std::vector<char> buf(1024);
|
||
|
|
||
|
+#ifdef __ANDROID__
|
||
|
+ s_ent = getservbyport(htons(port), "tcp");
|
||
|
+ if (s_ent == nullptr) return false;
|
||
|
+#else
|
||
|
res = getservbyport_r(htons(port), "tcp", &s_ent_buf, buf.data(), buf.size(), &s_ent);
|
||
|
if (res != 0 || s_ent == nullptr)
|
||
|
return false;
|
||
|
+#endif
|
||
|
|
||
|
strprintf(target, "_%s._tcp.%s", s_ent->s_name, host.c_str());
|
||
|
return GetSrvRecords(target, Result);
|
||
|
}
|
||
|
|
||
|
+/* Bionic has res_init() but it's not in any header */
|
||
|
+#ifdef __ANDROID__
|
||
|
+extern "C" int res_init();
|
||
|
+extern "C" int res_query(const char* dname, int class_, int type_, unsigned char* answer, int anslen);
|
||
|
+extern "C" int __dn_skipname(const unsigned char* comp_dn, const unsigned char* eom);
|
||
|
+static inline int dn_skipname(const unsigned char* a, const unsigned char* b) { return __dn_skipname(a,b); }
|
||
|
+#endif
|
||
|
+
|
||
|
bool GetSrvRecords(std::string name, std::vector<SrvRec> &Result)
|
||
|
{
|
||
|
unsigned char answer[PACKETSZ];
|