summaryrefslogtreecommitdiff
path: root/jni/iodine/src/util.c
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2014-08-11 23:26:36 +0200
committerYves Fischer <yvesf-git@xapek.org>2014-08-11 23:26:36 +0200
commit5d8801d4687035ae45143f0f3bc3eeaf75dc17ec (patch)
treebf4395fd5938eb1865ba90b6e52e169d727d9404 /jni/iodine/src/util.c
parent1251ce0d7cf2619f9b41637dcb88bebb66e54fb3 (diff)
downloadandiodine-5d8801d4687035ae45143f0f3bc3eeaf75dc17ec.tar.gz
andiodine-5d8801d4687035ae45143f0f3bc3eeaf75dc17ec.zip
Upgrade code to iodine 0.7.0 and improve logging
Diffstat (limited to 'jni/iodine/src/util.c')
-rw-r--r--jni/iodine/src/util.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/jni/iodine/src/util.c b/jni/iodine/src/util.c
index bc5fc8d..f4a538e 100644
--- a/jni/iodine/src/util.c
+++ b/jni/iodine/src/util.c
@@ -1,5 +1,6 @@
/*
- * Copyright (c) 2006-2009 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
+ * Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
+ * 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -25,12 +26,22 @@ get_resolvconf_addr()
#ifndef WINDOWS32
char buf[80];
FILE *fp;
-
+#ifdef ANDROID
+ fp = popen("getprop net.dns1", "r");
+ if (fp == NULL)
+ err(1, "getprop net.dns1 failed");
+ if (fgets(buf, sizeof(buf), fp) == NULL)
+ err(1, "read getprop net.dns1 failed");
+ if (sscanf(buf, "%15s", addr) == 1)
+ rv = addr;
+ pclose(fp);
+#else
+
rv = NULL;
- if ((fp = fopen("/etc/resolv.conf", "r")) == NULL)
+ if ((fp = fopen("/etc/resolv.conf", "r")) == NULL)
err(1, "/etc/resolv.conf");
-
+
while (feof(fp) == 0) {
fgets(buf, sizeof(buf), fp);
@@ -39,8 +50,9 @@ get_resolvconf_addr()
break;
}
}
-
+
fclose(fp);
+#endif
#else /* !WINDOWS32 */
FIXED_INFO *fixed_info;
ULONG buflen;
@@ -67,3 +79,15 @@ get_resolvconf_addr()
return rv;
}
+#ifdef OPENBSD
+void
+socket_setrtable(int fd, int rtable)
+{
+#ifdef SO_RTABLE
+ if (setsockopt (fd, IPPROTO_IP, SO_RTABLE, &rtable, sizeof(rtable)) == -1)
+ err(1, "Failed to set routing table %d", rtable);
+#else
+ fprintf(stderr, "Routing domain support was not available at compile time.\n");
+#endif
+}
+#endif