summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2014-10-30 23:40:34 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-10-30 23:40:34 +0000
commitb15568c8ee15f2bc78b9bff8d4e107b3d4150dc3 (patch)
tree3ab9fabad2e44978dff81d6d63888d42592a59bb
parent9d0a1335b0559224a7c86ae430646b8cd13a4907 (diff)
parent7612916deb5f40a8dcf3a31db8849450e146fc8d (diff)
downloadandroid_external_android-clat-b15568c8ee15f2bc78b9bff8d4e107b3d4150dc3.tar.gz
android_external_android-clat-b15568c8ee15f2bc78b9bff8d4e107b3d4150dc3.tar.bz2
android_external_android-clat-b15568c8ee15f2bc78b9bff8d4e107b3d4150dc3.zip
am 7612916d: Support more than one clatd at a time.
* commit '7612916deb5f40a8dcf3a31db8849450e146fc8d': Support more than one clatd at a time.
-rw-r--r--clatd.c17
-rw-r--r--clatd.h2
2 files changed, 12 insertions, 7 deletions
diff --git a/clatd.c b/clatd.c
index 4b6b8cc..f5d625d 100644
--- a/clatd.c
+++ b/clatd.c
@@ -51,7 +51,7 @@
#include "getaddr.h"
#include "dump.h"
-#define DEVICENAME4 "clat4"
+#define DEVICEPREFIX "v4-"
/* 40 bytes IPv6 header - 20 bytes IPv4 header + 8 bytes fragment header */
#define MTU_DELTA 28
@@ -156,11 +156,11 @@ int configure_packet_socket(int sock) {
*/
void interface_poll(const struct tun_data *tunnel) {
union anyip *interface_ip;
+ char *interface = Global_Clatd_Config.default_pdp_interface;
- interface_ip = getinterface_ip(Global_Clatd_Config.default_pdp_interface, AF_INET6);
+ interface_ip = getinterface_ip(interface, AF_INET6);
if(!interface_ip) {
- logmsg(ANDROID_LOG_WARN,"unable to find an ipv6 ip on interface %s",
- Global_Clatd_Config.default_pdp_interface);
+ logmsg(ANDROID_LOG_WARN,"unable to find an ipv6 ip on interface %s", interface);
return;
}
@@ -441,8 +441,7 @@ int main(int argc, char **argv) {
char *uplink_interface = NULL, *plat_prefix = NULL, *net_id_str = NULL, *mark_str = NULL;
unsigned net_id = NETID_UNSET;
uint32_t mark = MARK_UNSET;
-
- strcpy(tunnel.device4, DEVICENAME4);
+ unsigned len;
while((opt = getopt(argc, argv, "i:p:n:m:h")) != -1) {
switch(opt) {
@@ -482,6 +481,12 @@ int main(int argc, char **argv) {
exit(1);
}
+ len = snprintf(tunnel.device4, sizeof(tunnel.device4), "%s%s", DEVICEPREFIX, uplink_interface);
+ if (len >= sizeof(tunnel.device4)) {
+ logmsg(ANDROID_LOG_FATAL, "interface name too long '%s'", tunnel.device4);
+ exit(1);
+ }
+
logmsg(ANDROID_LOG_INFO, "Starting clat version %s on %s netid=%s mark=%s",
CLATD_VERSION, uplink_interface,
net_id_str ? net_id_str : "(none)",
diff --git a/clatd.h b/clatd.h
index ca7369b..e7cef43 100644
--- a/clatd.h
+++ b/clatd.h
@@ -23,7 +23,7 @@
#define MAXMTU 1500
#define PACKETLEN (MAXMTU+sizeof(struct tun_pi))
-#define CLATD_VERSION "1.3"
+#define CLATD_VERSION "1.4"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))