summaryrefslogtreecommitdiff
path: root/ucspi-tcp-0.88/dns_sortip6.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-29 15:45:38 -0700
committerJohn Denker <jsd@av8n.com>2012-07-29 15:45:38 -0700
commit0d2205555e68f414eec0afa8a6531626f77c4a57 (patch)
treef0e7d3e161f82180e834a6368d41b79272ab013a /ucspi-tcp-0.88/dns_sortip6.c
parent0c7195dea3482bd4c9ac9fbff318c24c502574c6 (diff)
parent01ef1d365e5776b130e8b65772a80b6adcb0ed46 (diff)
Merge branch 'master' of ephedra:usr/src/qmail into e_master
Diffstat (limited to 'ucspi-tcp-0.88/dns_sortip6.c')
-rw-r--r--ucspi-tcp-0.88/dns_sortip6.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/ucspi-tcp-0.88/dns_sortip6.c b/ucspi-tcp-0.88/dns_sortip6.c
new file mode 100644
index 0000000..7e752e9
--- /dev/null
+++ b/ucspi-tcp-0.88/dns_sortip6.c
@@ -0,0 +1,20 @@
+#include "byte.h"
+#include "dns.h"
+
+/* XXX: sort servers by configurable notion of closeness? */
+/* XXX: pay attention to competence of each server? */
+
+void dns_sortip6(char *s,unsigned int n)
+{
+ unsigned int i;
+ char tmp[16];
+
+ n >>= 4;
+ while (n > 1) {
+ i = dns_random(n);
+ --n;
+ byte_copy(tmp,16,s + (i << 4));
+ byte_copy(s + (i << 4),16,s + (n << 4));
+ byte_copy(s + (n << 4),16,tmp);
+ }
+}