summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYongqin Liu <yongqin.liu@linaro.org>2014-08-15 00:46:44 +0800
committerAmit Pundir <amit.pundir@linaro.org>2014-09-11 13:35:19 +0530
commiteafd44f6305561bf6944de8649eb5a6a7593b0fe (patch)
tree2bc4e6e1adba5bd765b2036105cb1c3b9e561682
parentaae3863e1052cad8140f5214deb9d522f3f58d0e (diff)
downloadbase-linaro-armv8-14.09.tar.gz
svc : add netd sub command for setting dnslinaro-armv8-14.09
add netd command to help to set the default network interface, and set the dns server for it, so that we can make hostname can be resolved successfully when using eth0 interface, which is the normal network interface for development board. steps to enable dns server like this: svc netd setdefaultif eth0 svc netd setifdns eth0 8.8.8.8 or use the single command: svc netd setdefaultifdns eth0 8.8.8.8 Change-Id: I78e953725085bd57bfad184011c9d107e6338395 Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rw-r--r--cmds/svc/src/com/android/commands/svc/NetdCommand.java71
-rw-r--r--cmds/svc/src/com/android/commands/svc/Svc.java1
2 files changed, 72 insertions, 0 deletions
diff --git a/cmds/svc/src/com/android/commands/svc/NetdCommand.java b/cmds/svc/src/com/android/commands/svc/NetdCommand.java
new file mode 100644
index 000000000000..35e7fa70de2e
--- /dev/null
+++ b/cmds/svc/src/com/android/commands/svc/NetdCommand.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.commands.svc;
+
+import android.content.Context;
+import android.os.INetworkManagementService;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.os.SystemClock;
+import android.os.IBinder;
+
+public class NetdCommand extends Svc.Command {
+ public NetdCommand() {
+ super("netd");
+ }
+
+ public String shortHelp() {
+ return "set dns information";
+ }
+
+ public String longHelp() {
+ return shortHelp() + "\n"
+ + "\n"
+ + "usage: svc netd setdefaultif iface\n"
+ + " set default interface for dns\n"
+ + " svc netd setifdns iface nameserver\n"
+ + " set nameserver for interface\n"
+ + " svc netd setdefaultifdns iface nameserver\n"
+ + " set the default interface for dns and nameserver for it\n";
+ }
+
+ public void run(String[] args) {
+ try {
+ if (args.length >= 2) {
+ IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
+ INetworkManagementService netdService = INetworkManagementService.Stub.asInterface(b);
+ if ("setdefaultif".equals(args[1]) && args.length == 3) {
+ netdService.setDefaultInterfaceForDns(args[2]);
+ return;
+ } else if ("setifdns".equals(args[1]) && args.length == 4) {
+ netdService.setDnsServersForInterface(args[2], new String[]{args[3]}, null);
+ return;
+ } else if ("setdefaultifdns".equals(args[1]) && args.length == 4) {
+ netdService.setDefaultInterfaceForDns(args[2]);
+ netdService.setDnsServersForInterface(args[2], new String[]{args[3]}, null);
+ return;
+ } else {
+ System.err.println(longHelp());
+ return;
+ }
+ }
+ }catch(Exception e){
+ System.err.println(e);
+ }
+ System.err.println(longHelp());
+ }
+}
diff --git a/cmds/svc/src/com/android/commands/svc/Svc.java b/cmds/svc/src/com/android/commands/svc/Svc.java
index 0fbba11e927d..1481956e15f9 100644
--- a/cmds/svc/src/com/android/commands/svc/Svc.java
+++ b/cmds/svc/src/com/android/commands/svc/Svc.java
@@ -95,6 +95,7 @@ public class Svc {
new PowerCommand(),
new DataCommand(),
new WifiCommand(),
+ new NetdCommand(),
new UsbCommand()
};
}