]> git.saurik.com Git - apt.git/blame - apt-pkg/contrib/srvrec.h
add support for Build-Depends/Conflicts-Arch
[apt.git] / apt-pkg / contrib / srvrec.h
CommitLineData
f106fecc
MV
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 SRV record support
cdeb54d4 6
f106fecc
MV
7 ##################################################################### */
8 /*}}}*/
9#ifndef SRVREC_H
10#define SRVREC_H
11
12#include <arpa/nameser.h>
13#include <vector>
14#include <string>
15
16class SrvRec
17{
18 public:
19 std::string target;
20 u_int16_t priority;
21 u_int16_t weight;
22 u_int16_t port;
23
e5f34ad3
MV
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;
28
76abe9a5
DK
29 bool operator<(SrvRec const &other) const {
30 return this->priority < other.priority;
8194f976 31 }
3129bd50 32 bool operator==(SrvRec const &other) const;
76abe9a5
DK
33
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) {}
f106fecc
MV
39};
40
a01695e8
MV
41/** \brief Get SRV records from host/port (builds the query string internally)
42 */
f106fecc
MV
43bool GetSrvRecords(std::string name, std::vector<SrvRec> &Result);
44
a01695e8
MV
45/** \brief Get SRV records for query string like: _http._tcp.example.com
46 */
47bool GetSrvRecords(std::string host, int port, std::vector<SrvRec> &Result);
48
c29dbdff
MV
49/** \brief Pop a single SRV record from the vector of SrvRec taking
50 * priority and weight into account
51 */
52SrvRec PopFromSrvRecs(std::vector<SrvRec> &Recs);
53
f106fecc 54#endif