summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2011-09-14 15:03:21 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-09-14 15:03:21 -0700
commit65969062a94e3a2d15a2536db297492f96a1f0aa (patch)
treed246907fca0f6cffec530488b0155c8140964d83
parent876666947664c718a8d0cae9bbddb06cc91f912c (diff)
parent32a9dc6f484deb3462d11084caca21e3f1f662b2 (diff)
downloadnetd-65969062a94e3a2d15a2536db297492f96a1f0aa.tar.gz
Merge "Netd comand to change IPv6 privacy extensions"
-rw-r--r--CommandListener.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/CommandListener.cpp b/CommandListener.cpp
index 9b0872f9..204565b9 100644
--- a/CommandListener.cpp
+++ b/CommandListener.cpp
@@ -22,6 +22,7 @@
#include <dirent.h>
#include <errno.h>
#include <string.h>
+#include <fcntl.h>
#include <linux/if.h>
@@ -364,6 +365,37 @@ int CommandListener::InterfaceCmd::runCommand(SocketClient *cli,
ifc_close();
cli->sendMsg(ResponseCode::CommandOkay, "Interface IP addresses cleared", false);
return 0;
+ } else if (!strcmp(argv[1], "ipv6privacyextensions")) {
+ if (argc != 4) {
+ cli->sendMsg(ResponseCode::CommandSyntaxError,
+ "Usage: interface ipv6privacyextensions <interface> <enable|disable>",
+ false);
+ return 0;
+ }
+
+ char *tmp = NULL;
+ asprintf(&tmp, "/proc/sys/net/ipv6/conf/%s/use_tempaddr", argv[2]);
+ int fd = open(tmp, O_WRONLY);
+ if (fd < 0) {
+ LOGE("Failed to open %s (%s)", tmp, strerror(errno));
+ free(tmp);
+ cli->sendMsg(ResponseCode::OperationFailed,
+ "Failed to set ipv6 privacy extensions", true);
+ return 0;
+ }
+
+ if (write(fd, (!strncmp(argv[3], "enable", 6) ? "2" : "0"), 1) != 1) {
+ LOGE("Failed to write %s (%s)", tmp, strerror(errno));
+ close(fd);
+ free(tmp);
+ cli->sendMsg(ResponseCode::OperationFailed,
+ "Failed to set ipv6 privacy extensions", true);
+ return 0;
+ }
+ close(fd);
+ free(tmp);
+ cli->sendMsg(ResponseCode::CommandOkay, "IPv6 privacy extensions changed", false);
+ return 0;
} else {
cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown interface cmd", false);
return 0;