summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/srvrec.h
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2015-08-20 12:05:49 +0200
committerMichael Vogt <mvo@debian.org>2015-08-20 12:05:49 +0200
commitf5c0ab925fdceb1bc0ef0e958cae7d0fafb28caf (patch)
tree959633a2debcd3572ff578558916243461a0e0f2 /apt-pkg/contrib/srvrec.h
parentdefe3231c7bafc4d789219a3250be9ccfbc51914 (diff)
parentc29dbdffcb6f67812f823f1f844b87320cf6b437 (diff)
Merge remote-tracking branch 'mvo/feature/srv-records' into debian/experimental
Diffstat (limited to 'apt-pkg/contrib/srvrec.h')
-rw-r--r--apt-pkg/contrib/srvrec.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/apt-pkg/contrib/srvrec.h b/apt-pkg/contrib/srvrec.h
new file mode 100644
index 000000000..e07edc683
--- /dev/null
+++ b/apt-pkg/contrib/srvrec.h
@@ -0,0 +1,47 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+/* ######################################################################
+
+ SRV record support
+
+ ##################################################################### */
+ /*}}}*/
+#ifndef SRVREC_H
+#define SRVREC_H
+
+#include <arpa/nameser.h>
+#include <vector>
+#include <string>
+
+class SrvRec
+{
+ public:
+ std::string target;
+ u_int16_t priority;
+ u_int16_t weight;
+ u_int16_t port;
+
+ // each server is assigned a interval [start, end] in the space of [0, max]
+ int random_number_range_start;
+ int random_number_range_end;
+ int random_number_range_max;
+
+ bool operator<(SrvRec const &other) const {
+ return this->priority < other.priority;
+ }
+};
+
+/** \brief Get SRV records from host/port (builds the query string internally)
+ */
+bool GetSrvRecords(std::string name, std::vector<SrvRec> &Result);
+
+/** \brief Get SRV records for query string like: _http._tcp.example.com
+ */
+bool GetSrvRecords(std::string host, int port, std::vector<SrvRec> &Result);
+
+/** \brief Pop a single SRV record from the vector of SrvRec taking
+ * priority and weight into account
+ */
+SrvRec PopFromSrvRecs(std::vector<SrvRec> &Recs);
+
+#endif