fehQlibs
26
Qlibs
Loading...
Searching...
No Matches
fehQlibs-26
src
dnsstub
dns_sortip.c
Go to the documentation of this file.
1
#include "
byte.h
"
2
#include "
ip.h
"
3
#include "
dnsresolv.h
"
4
12
/* XXX: sort servers by configurable notion of closeness? */
13
/* XXX: pay attention to competence of each server? */
14
/* XXX: pay attention to qualification (DNSSec, DNSCurve) of each server? */
15
/* YYY: we use a randomly sorted list of NS; not depending on answer */
16
17
void
dns_sortip4
(
char
*s,
unsigned
int
n)
18
{
19
unsigned
int
i;
20
char
tmp[4];
21
22
n >>= 2;
/* 4 byte per IPv4 address */
23
while
(n > 1) {
24
i =
dns_random
(n);
25
--n;
26
byte_copy
(tmp,4,s + (i << 2));
27
byte_copy
(s + (i << 2),4,s + (n << 2));
28
byte_copy
(s + (n << 2),4,tmp);
29
}
30
}
31
32
void
dns_sortip6
(
char
*s,
unsigned
int
n)
33
{
34
unsigned
int
i;
35
char
tmp[16];
36
37
n >>= 4;
/* 16 byte per IPv4 address */
38
while
(n > 1) {
39
i =
dns_random
(n);
40
--n;
41
byte_copy
(tmp,16,s + (i << 4));
42
byte_copy
(s + (i << 4),16,s + (n << 4));
43
byte_copy
(s + (n << 4),16,tmp);
44
}
45
}
dns_sortip4
void dns_sortip4(char *s, unsigned int n)
Definition:
dns_sortip.c:17
dns_sortip6
void dns_sortip6(char *s, unsigned int n)
Definition:
dns_sortip.c:32
ip.h
byte.h
byte_copy
void byte_copy(void *, unsigned int, const void *)
Definition:
byte.c:20
dnsresolv.h
dns_random
unsigned int dns_random(unsigned int)
Definition:
dns_random.c:59
Generated on Sat Nov 2 2024 13:01:06 for fehQlibs by
1.9.6