1 // -*- mode: cpp; mode: fold -*-
3 /* ######################################################################
7 ##################################################################### */
12 #include <arpa/nameser.h>
24 // each server is assigned a interval [start, end] in the space of [0, max]
25 int random_number_range_start
;
26 int random_number_range_end
;
27 int random_number_range_max
;
29 bool operator<(SrvRec
const &other
) const {
30 return this->priority
< other
.priority
;
32 bool operator==(SrvRec
const &other
) const;
34 SrvRec(std::string
const Target
, u_int16_t
const Priority
,
35 u_int16_t
const Weight
, u_int16_t
const Port
) :
36 target(Target
), priority(Priority
), weight(Weight
), port(Port
),
37 random_number_range_start(0), random_number_range_end(0),
38 random_number_range_max(0) {}
41 /** \brief Get SRV records from host/port (builds the query string internally)
43 bool GetSrvRecords(std::string name
, std::vector
<SrvRec
> &Result
);
45 /** \brief Get SRV records for query string like: _http._tcp.example.com
47 bool GetSrvRecords(std::string host
, int port
, std::vector
<SrvRec
> &Result
);
49 /** \brief Pop a single SRV record from the vector of SrvRec taking
50 * priority and weight into account
52 SrvRec
PopFromSrvRecs(std::vector
<SrvRec
> &Recs
);