OSDN Git Service

Removed Throttle Controller as obsolete
authorSasha Levitskiy <sanek@google.com>
Tue, 15 Jan 2013 00:28:54 +0000 (16:28 -0800)
committerSasha Levitskiy <sanek@google.com>
Tue, 15 Jan 2013 00:57:28 +0000 (16:57 -0800)
Change-Id: I1a3c0e1a8690d0d5a8fb1411c49bc6db52ce5ccb

Android.mk
CommandListener.cpp
ThrottleController.cpp [deleted file]
ThrottleController.h [deleted file]

index e4b6ad6..69fd6d2 100644 (file)
@@ -21,7 +21,6 @@ LOCAL_SRC_FILES:=                                      \
                   SecondaryTableController.cpp         \
                   SoftapController.cpp                 \
                   TetherController.cpp                 \
-                  ThrottleController.cpp               \
                   oem_iptables_hook.cpp                \
                   logwrapper.c                         \
                   main.cpp                             \
index a3e4a11..8d113e8 100644 (file)
@@ -35,7 +35,6 @@
 
 #include "CommandListener.h"
 #include "ResponseCode.h"
-#include "ThrottleController.h"
 #include "BandwidthController.h"
 #include "IdletimerController.h"
 #include "SecondaryTableController.h"
@@ -282,44 +281,6 @@ int CommandListener::InterfaceCmd::runCommand(SocketClient *cli,
         cli->sendMsg(ResponseCode::InterfaceTxCounterResult, msg, false);
         free(msg);
         return 0;
-    } else if (!strcmp(argv[1], "getthrottle")) {
-        if (argc != 4 || (argc == 4 && (strcmp(argv[3], "rx") && (strcmp(argv[3], "tx"))))) {
-            cli->sendMsg(ResponseCode::CommandSyntaxError,
-                    "Usage: interface getthrottle <interface> <rx|tx>", false);
-            return 0;
-        }
-        int val = 0;
-        int rc = 0;
-        int voldRc = ResponseCode::InterfaceRxThrottleResult;
-
-        if (!strcmp(argv[3], "rx")) {
-            rc = ThrottleController::getInterfaceRxThrottle(argv[2], &val);
-        } else {
-            rc = ThrottleController::getInterfaceTxThrottle(argv[2], &val);
-            voldRc = ResponseCode::InterfaceTxThrottleResult;
-        }
-        if (rc) {
-            cli->sendMsg(ResponseCode::OperationFailed, "Failed to get throttle", true);
-        } else {
-            char *msg = NULL;
-            asprintf(&msg, "%u", val);
-            cli->sendMsg(voldRc, msg, false);
-            free(msg);
-            return 0;
-        }
-        return 0;
-    } else if (!strcmp(argv[1], "setthrottle")) {
-        if (argc != 5) {
-            cli->sendMsg(ResponseCode::CommandSyntaxError,
-                    "Usage: interface setthrottle <interface> <rx_kbps> <tx_kbps>", false);
-            return 0;
-        }
-        if (ThrottleController::setInterfaceThrottle(argv[2], atoi(argv[3]), atoi(argv[4]))) {
-            cli->sendMsg(ResponseCode::OperationFailed, "Failed to set throttle", true);
-        } else {
-            cli->sendMsg(ResponseCode::CommandOkay, "Interface throttling set", false);
-        }
-        return 0;
     } else if (!strcmp(argv[1], "driver")) {
         int rc;
         char *rbuf;
diff --git a/ThrottleController.cpp b/ThrottleController.cpp
deleted file mode 100644 (file)
index 5bd7ad5..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * 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.
- */
-
-#include <stdlib.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-#include <linux/pkt_sched.h>
-
-#define LOG_TAG "ThrottleController"
-#include <cutils/log.h>
-
-
-#include "ThrottleController.h"
-#include "NetdConstants.h"
-
-extern "C" int system_nosh(const char *command);
-extern "C" int ifc_init(void);
-extern "C" int ifc_up(const char *name);
-extern "C" int ifc_down(const char *name);
-
-int ThrottleController::runTcCmd(const char *cmd) {
-    char *buffer;
-    size_t len = strnlen(cmd, 255);
-    int res;
-
-    if (len == 255) {
-        ALOGE("tc command too long");
-        errno = E2BIG;
-        return -1;
-    }
-
-    asprintf(&buffer, "%s %s", TC_PATH, cmd);
-    res = system_nosh(buffer);
-    free(buffer);
-    return res;
-}
-
-int ThrottleController::setInterfaceThrottle(const char *iface, int rxKbps, int txKbps) {
-    char cmd[512];
-    char ifn[65];
-    int rc;
-
-    memset(ifn, 0, sizeof(ifn));
-    strncpy(ifn, iface, sizeof(ifn)-1);
-
-    if (txKbps == -1) {
-        reset(ifn);
-        return 0;
-    }
-
-    /*
-     *
-     * Target interface configuration
-     *
-     */
-
-    /*
-     * Add root qdisc for the interface
-     */
-    sprintf(cmd, "qdisc add dev %s root handle 1: htb default 1 r2q 1000", ifn);
-    if (runTcCmd(cmd)) {
-        ALOGE("Failed to add root qdisc (%s)", strerror(errno));
-        goto fail;
-    }
-
-    /*
-     * Add our egress throttling class
-     */
-    sprintf(cmd, "class add dev %s parent 1: classid 1:1 htb rate %dkbit", ifn, txKbps);
-    if (runTcCmd(cmd)) {
-        ALOGE("Failed to add egress throttling class (%s)", strerror(errno));
-        goto fail;
-    }
-
-    /*
-     * Bring up the IFD device
-     */
-    ifc_init();
-    if (ifc_up("ifb0")) {
-        ALOGE("Failed to up ifb0 (%s)", strerror(errno));
-        goto fail;
-    }
-
-    /*
-     * Add root qdisc for IFD
-     */
-    sprintf(cmd, "qdisc add dev ifb0 root handle 1: htb default 1 r2q 1000");
-    if (runTcCmd(cmd)) {
-        ALOGE("Failed to add root ifb qdisc (%s)", strerror(errno));
-        goto fail;
-    }
-
-    /*
-     * Add our ingress throttling class
-     */
-    sprintf(cmd, "class add dev ifb0 parent 1: classid 1:1 htb rate %dkbit", rxKbps);
-    if (runTcCmd(cmd)) {
-        ALOGE("Failed to add ingress throttling class (%s)", strerror(errno));
-        goto fail;
-    }
-
-    /*
-     * Add ingress qdisc for pkt redirection
-     */
-    sprintf(cmd, "qdisc add dev %s ingress", ifn);
-    if (runTcCmd(cmd)) {
-        ALOGE("Failed to add ingress qdisc (%s)", strerror(errno));
-        goto fail;
-    }
-
-    /*
-     * Add filter to link <ifn> -> ifb0
-     */
-    sprintf(cmd, "filter add dev %s parent ffff: protocol ip prio 10 u32 match "
-            "u32 0 0 flowid 1:1 action mirred egress redirect dev ifb0", ifn);
-    if (runTcCmd(cmd)) {
-        ALOGE("Failed to add ifb filter (%s)", strerror(errno));
-        goto fail;
-    }
-
-    return 0;
-fail:
-    reset(ifn);
-    return -1;
-}
-
-void ThrottleController::reset(const char *iface) {
-    char cmd[128];
-
-    sprintf(cmd, "qdisc del dev %s root", iface);
-    runTcCmd(cmd);
-    sprintf(cmd, "qdisc del dev %s ingress", iface);
-    runTcCmd(cmd);
-
-    runTcCmd("qdisc del dev ifb0 root");
-}
-
-int ThrottleController::getInterfaceRxThrottle(const char *iface, int *rx) {
-    *rx = 0;
-    return 0;
-}
-
-int ThrottleController::getInterfaceTxThrottle(const char *iface, int *tx) {
-    *tx = 0;
-    return 0;
-}
diff --git a/ThrottleController.h b/ThrottleController.h
deleted file mode 100644 (file)
index 3538e03..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef _THROTTLE_CONTROLLER_H
-#define _THROTTLE_CONTROLLER_H
-
-class ThrottleController {
-public:
-    static int setInterfaceThrottle(const char *iface, int rxKbps, int txKbps);
-    static int getInterfaceRxThrottle(const char *iface, int *rx);
-    static int getInterfaceTxThrottle(const char *iface, int *tx);
-
-private:
-    static int runTcCmd(const char *cmd);
-    static void reset(const char *iface);
-};
-
-#endif