summaryrefslogtreecommitdiff
path: root/ucspi-tcp-0.88/dns_sortip6.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-30 14:34:05 -0700
committerJohn Denker <jsd@av8n.com>2012-07-30 14:34:05 -0700
commit7024dc330299921af649330c45b99c21c3d7f022 (patch)
tree9f747a0423647b016376fe353ceea197a5848cbf /ucspi-tcp-0.88/dns_sortip6.c
parentce0dbe5332d4eb921c09cc48cc52634211d7089a (diff)
parentf8be4baf5a2318363b42f8883f66ed8a976dfc79 (diff)
Merge branch 'master' of ephedra:usr/src/qmail into e_master
Conflicts: tools/makefile
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);
+ }
+}