apt: apt-pkg/contrib/srvrec.h Source File

apt 2.7.5 commandline package manager

srvrec.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3/* ######################################################################
4
5 SRV record support
6
7 ##################################################################### */
8 /*}}}*/
9#ifndef SRVREC_H
10#define SRVREC_H
11
12#include <string>
13#include <vector>
14#include <arpa/nameser.h>
15#include <sys/types.h>
16
17#include <apt-pkg/macros.h>
18
19 class APT_PUBLIC SrvRec
20{
21 public:
22 std::string target;
23 u_int16_t priority;
24 u_int16_t weight;
25 u_int16_t port;
26
27 // each server is assigned a interval [start, end] in the space of [0, max]
28 int random_number_range_start;
29 int random_number_range_end;
30 int random_number_range_max;
31
32 bool operator<(SrvRec const &other) const {
33 return this->priority < other.priority;
34 }
35 bool operator==(SrvRec const &other) const;
36
37 SrvRec(std::string const Target, u_int16_t const Priority,
38 u_int16_t const Weight, u_int16_t const Port) :
39 target(Target), priority(Priority), weight(Weight), port(Port),
40 random_number_range_start(0), random_number_range_end(0),
41 random_number_range_max(0) {}
42};
43
46APT_PUBLIC bool GetSrvRecords(std::string name, std::vector<SrvRec> &Result);
47
50APT_PUBLIC bool GetSrvRecords(std::string host, int port, std::vector<SrvRec> &Result);
51
55APT_PUBLIC SrvRec PopFromSrvRecs(std::vector<SrvRec> &Recs);
56
57#endif
SrvRec
Definition srvrec.h:20