| diff --git a/system/netd/server/BandwidthController.cpp b/system/netd/server/BandwidthController.cpp |
| index d71ce3b..0ab5418 100644 |
| --- a/system/netd/server/BandwidthController.cpp |
| +++ b/system/netd/server/BandwidthController.cpp |
| @@ -43,7 +43,7 @@ |
| |
| #define LOG_TAG "BandwidthController" |
| #include <cutils/log.h> |
| -#include <cutils/properties.h> |
| +//#include <cutils/properties.h> |
| #include <logwrap/logwrap.h> |
| |
| #include "NetdConstants.h" |
| @@ -253,10 +253,10 @@ int BandwidthController::setupIptablesHooks(void) { |
| |
| int BandwidthController::enableBandwidthControl(bool force) { |
| int res; |
| - char value[PROPERTY_VALUE_MAX]; |
| + char value[20]; |
| |
| if (!force) { |
| - property_get("persist.bandwidth.enable", value, "1"); |
| + //property_get("persist.bandwidth.enable", value, "1"); |
| if (!strcmp(value, "0")) |
| return 0; |
| } |
| diff --git a/system/netd/server/CommandListener.cpp b/system/netd/server/CommandListener.cpp |
| index 7ecbffc..956dc0d 100644 |
| --- a/system/netd/server/CommandListener.cpp |
| +++ b/system/netd/server/CommandListener.cpp |
| @@ -49,6 +49,8 @@ |
| #include <string> |
| #include <vector> |
| |
| +#define UID_MAX 0xffffffffU |
| + |
| namespace { |
| |
| const unsigned NUM_OEM_IDS = NetworkController::MAX_OEM_ID - NetworkController::MIN_OEM_ID + 1; |
| @@ -83,7 +85,7 @@ unsigned stringToNetId(const char* arg) { |
| |
| NetworkController *CommandListener::sNetCtrl = NULL; |
| TetherController *CommandListener::sTetherCtrl = NULL; |
| -NatController *CommandListener::sNatCtrl = NULL; |
| +//NatController *CommandListener::sNatCtrl = NULL; |
| PppController *CommandListener::sPppCtrl = NULL; |
| SoftapController *CommandListener::sSoftapCtrl = NULL; |
| BandwidthController * CommandListener::sBandwidthCtrl = NULL; |
| @@ -91,7 +93,7 @@ IdletimerController * CommandListener::sIdletimerCtrl = NULL; |
| InterfaceController *CommandListener::sInterfaceCtrl = NULL; |
| ResolverController *CommandListener::sResolverCtrl = NULL; |
| FirewallController *CommandListener::sFirewallCtrl = NULL; |
| -ClatdController *CommandListener::sClatdCtrl = NULL; |
| +//ClatdController *CommandListener::sClatdCtrl = NULL; |
| StrictController *CommandListener::sStrictCtrl = NULL; |
| |
| /** |
| @@ -110,7 +112,7 @@ static const char* FILTER_FORWARD[] = { |
| OEM_IPTABLES_FILTER_FORWARD, |
| FirewallController::LOCAL_FORWARD, |
| BandwidthController::LOCAL_FORWARD, |
| - NatController::LOCAL_FORWARD, |
| + //NatController::LOCAL_FORWARD, |
| NULL, |
| }; |
| |
| @@ -135,7 +137,7 @@ static const char* MANGLE_POSTROUTING[] = { |
| }; |
| |
| static const char* MANGLE_FORWARD[] = { |
| - NatController::LOCAL_MANGLE_FORWARD, |
| + //NatController::LOCAL_MANGLE_FORWARD, |
| NULL, |
| }; |
| |
| @@ -145,7 +147,7 @@ static const char* NAT_PREROUTING[] = { |
| }; |
| |
| static const char* NAT_POSTROUTING[] = { |
| - NatController::LOCAL_NAT_POSTROUTING, |
| + //NatController::LOCAL_NAT_POSTROUTING, |
| NULL, |
| }; |
| |
| @@ -174,7 +176,7 @@ CommandListener::CommandListener() : |
| registerCmd(new InterfaceCmd()); |
| registerCmd(new IpFwdCmd()); |
| registerCmd(new TetherCmd()); |
| - registerCmd(new NatCmd()); |
| + //registerCmd(new NatCmd()); |
| registerCmd(new ListTtysCmd()); |
| registerCmd(new PppdCmd()); |
| registerCmd(new SoftapCmd()); |
| @@ -182,7 +184,7 @@ CommandListener::CommandListener() : |
| registerCmd(new IdletimerControlCmd()); |
| registerCmd(new ResolverCmd()); |
| registerCmd(new FirewallCmd()); |
| - registerCmd(new ClatdCmd()); |
| + //registerCmd(new ClatdCmd()); |
| registerCmd(new NetworkCommand()); |
| registerCmd(new StrictCmd()); |
| |
| @@ -190,8 +192,8 @@ CommandListener::CommandListener() : |
| sNetCtrl = new NetworkController(); |
| if (!sTetherCtrl) |
| sTetherCtrl = new TetherController(); |
| - if (!sNatCtrl) |
| - sNatCtrl = new NatController(); |
| + /*if (!sNatCtrl) |
| + sNatCtrl = new NatController();*/ |
| if (!sPppCtrl) |
| sPppCtrl = new PppController(); |
| if (!sSoftapCtrl) |
| @@ -206,8 +208,10 @@ CommandListener::CommandListener() : |
| sFirewallCtrl = new FirewallController(); |
| if (!sInterfaceCtrl) |
| sInterfaceCtrl = new InterfaceController(); |
| + #if 0 |
| if (!sClatdCtrl) |
| sClatdCtrl = new ClatdController(sNetCtrl); |
| + #endif |
| if (!sStrictCtrl) |
| sStrictCtrl = new StrictController(); |
| |
| @@ -232,13 +236,13 @@ CommandListener::CommandListener() : |
| createChildChains(V4, "nat", "POSTROUTING", NAT_POSTROUTING); |
| |
| // Let each module setup their child chains |
| - setupOemIptablesHook(); |
| + //setupOemIptablesHook(); |
| |
| /* When enabled, DROPs all packets except those matching rules. */ |
| sFirewallCtrl->setupIptablesHooks(); |
| |
| /* Does DROPs in FORWARD by default */ |
| - sNatCtrl->setupIptablesHooks(); |
| + //sNatCtrl->setupIptablesHooks(); |
| /* |
| * Does REJECT in INPUT, OUTPUT. Does counting also. |
| * No DROP/REJECT allowed later in netfilter-flow hook order. |
| @@ -673,6 +677,7 @@ int CommandListener::TetherCmd::runCommand(SocketClient *cli, |
| return 0; |
| } |
| |
| +#if 0 |
| CommandListener::NatCmd::NatCmd() : |
| NetdCommand("nat") { |
| } |
| @@ -712,6 +717,7 @@ int CommandListener::NatCmd::runCommand(SocketClient *cli, |
| |
| return 0; |
| } |
| +#endif |
| |
| CommandListener::PppdCmd::PppdCmd() : |
| NetdCommand("pppd") { |
| @@ -831,7 +837,7 @@ int CommandListener::ResolverCmd::runCommand(SocketClient *cli, int argc, char * |
| if (!strcmp(argv[1], "setnetdns")) { |
| // "resolver setnetdns <netId> <domains> <dns1> <dns2> ..." |
| if (argc >= 5) { |
| - rc = sResolverCtrl->setDnsServers(netId, argv[3], &argv[4], argc - 4); |
| + rc = sResolverCtrl->setDnsServers(netId, "", &argv[4], argc - 4); |
| } else { |
| cli->sendMsg(ResponseCode::CommandSyntaxError, |
| "Wrong number of arguments to resolver setnetdns", false); |
| @@ -1169,6 +1175,7 @@ int CommandListener::BandwidthControlCmd::runCommand(SocketClient *cli, int argc |
| return 0; |
| |
| } |
| + #if 0 |
| if (!strcmp(argv[1], "gettetherstats") || !strcmp(argv[1], "gts")) { |
| BandwidthController::TetherStats tetherStats; |
| std::string extraProcessingInfo = ""; |
| @@ -1192,7 +1199,7 @@ int CommandListener::BandwidthControlCmd::runCommand(SocketClient *cli, int argc |
| return 0; |
| |
| } |
| - |
| + #endif |
| cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown bandwidth cmd", false); |
| return 0; |
| } |
| @@ -1432,6 +1439,7 @@ int CommandListener::FirewallCmd::runCommand(SocketClient *cli, int argc, |
| return 0; |
| } |
| |
| +#if 0 |
| CommandListener::ClatdCmd::ClatdCmd() : NetdCommand("clatd") { |
| } |
| |
| @@ -1467,6 +1475,7 @@ int CommandListener::ClatdCmd::runCommand(SocketClient *cli, int argc, |
| |
| return 0; |
| } |
| +#endif |
| |
| CommandListener::StrictCmd::StrictCmd() : |
| NetdCommand("strict") { |
| @@ -1601,7 +1610,9 @@ int CommandListener::NetworkCommand::runCommand(SocketClient* client, int argc, |
| |
| int ret; |
| if (add) { |
| + ALOGI("[zy]before addRoute"); |
| ret = sNetCtrl->addRoute(netId, interface, destination, nexthop, legacy, uid); |
| + ALOGI("[zy]after addRoute"); |
| } else { |
| ret = sNetCtrl->removeRoute(netId, interface, destination, nexthop, legacy, uid); |
| } |
| diff --git a/system/netd/server/CommandListener.h b/system/netd/server/CommandListener.h |
| index 72f4da1..e8a88d7 100644 |
| --- a/system/netd/server/CommandListener.h |
| +++ b/system/netd/server/CommandListener.h |
| @@ -22,7 +22,7 @@ |
| #include "NetdCommand.h" |
| #include "NetworkController.h" |
| #include "TetherController.h" |
| -#include "NatController.h" |
| +//#include "NatController.h" |
| #include "PppController.h" |
| #include "SoftapController.h" |
| #include "BandwidthController.h" |
| @@ -35,7 +35,7 @@ |
| |
| class CommandListener : public FrameworkListener { |
| static TetherController *sTetherCtrl; |
| - static NatController *sNatCtrl; |
| + //static NatController *sNatCtrl; |
| static PppController *sPppCtrl; |
| static SoftapController *sSoftapCtrl; |
| static BandwidthController *sBandwidthCtrl; |
| diff --git a/system/netd/server/DnsProxyListener.cpp b/system/netd/server/DnsProxyListener.cpp |
| index 6c71c5b..1aa3676 100644 |
| --- a/system/netd/server/DnsProxyListener.cpp |
| +++ b/system/netd/server/DnsProxyListener.cpp |
| @@ -26,7 +26,7 @@ |
| #include <string.h> |
| #include <pthread.h> |
| #include <resolv_netid.h> |
| -#include <net/if.h> |
| +//#include <net/if.h> |
| |
| #define LOG_TAG "DnsProxyListener" |
| #define DBG 0 |
| @@ -155,12 +155,12 @@ static bool sendaddrinfo(SocketClient* c, struct addrinfo* ai) { |
| } |
| |
| void DnsProxyListener::GetAddrInfoHandler::run() { |
| - if (DBG) { |
| - ALOGD("GetAddrInfoHandler, now for %s / %s / {%u,%u,%u,%u,%u}", mHost, mService, |
| + |
| + ALOGI("[libdns]GetAddrInfoHandler, now for %s / %s / {%u,%u,%u,%u,%u}", mHost, mService, |
| mNetContext.app_netid, mNetContext.app_mark, |
| mNetContext.dns_netid, mNetContext.dns_mark, |
| mNetContext.uid); |
| - } |
| + |
| |
| struct addrinfo* result = NULL; |
| uint32_t rv = android_getaddrinfofornetcontext(mHost, mService, mHints, &mNetContext, &result); |
| @@ -176,11 +176,11 @@ void DnsProxyListener::GetAddrInfoHandler::run() { |
| } |
| success = success && sendBE32(mClient, 0); |
| if (!success) { |
| - ALOGW("Error writing DNS result to client"); |
| + ALOGI("[libdns]Error writing DNS result to client"); |
| } |
| } |
| if (result) { |
| - freeaddrinfo(result); |
| + android_freeaddrinfo(result); |
| } |
| mClient->decRef(); |
| } |
| diff --git a/system/netd/server/FwmarkServer.cpp b/system/netd/server/FwmarkServer.cpp |
| index 530e96a..9d533e6 100644 |
| --- a/system/netd/server/FwmarkServer.cpp |
| +++ b/system/netd/server/FwmarkServer.cpp |
| @@ -23,6 +23,7 @@ |
| |
| #include <sys/socket.h> |
| #include <unistd.h> |
| +#include <string.h> |
| |
| FwmarkServer::FwmarkServer(NetworkController* networkController) : |
| SocketListener("fwmarkd", true), mNetworkController(networkController) { |
| diff --git a/system/netd/server/IdletimerController.cpp b/system/netd/server/IdletimerController.cpp |
| index e6306fd..c222018 100644 |
| --- a/system/netd/server/IdletimerController.cpp |
| +++ b/system/netd/server/IdletimerController.cpp |
| @@ -104,7 +104,7 @@ |
| #include <netinet/in.h> |
| #include <arpa/inet.h> |
| #include <string.h> |
| -#include <cutils/properties.h> |
| +//#include <cutils/properties.h> |
| |
| #define LOG_TAG "IdletimerController" |
| #include <cutils/log.h> |
| diff --git a/system/netd/server/InterfaceController.cpp b/system/netd/server/InterfaceController.cpp |
| index 3882bcc..e1125fe 100644 |
| --- a/system/netd/server/InterfaceController.cpp |
| +++ b/system/netd/server/InterfaceController.cpp |
| @@ -17,10 +17,11 @@ |
| #include <dirent.h> |
| #include <errno.h> |
| #include <malloc.h> |
| +#include <string.h> |
| |
| #define LOG_TAG "InterfaceController" |
| -#include <base/file.h> |
| -#include <base/stringprintf.h> |
| +#include <android-base/file.h> |
| +#include <android-base/stringprintf.h> |
| #include <cutils/log.h> |
| #include <logwrap/logwrap.h> |
| |
| diff --git a/system/netd/server/NatController.cpp b/system/netd/server/NatController.cpp |
| index 19d19c7..f455b6f 100644 |
| --- a/system/netd/server/NatController.cpp |
| +++ b/system/netd/server/NatController.cpp |
| @@ -25,7 +25,7 @@ |
| #include <netinet/in.h> |
| #include <arpa/inet.h> |
| #include <string.h> |
| -#include <cutils/properties.h> |
| +//#include <cutils/properties.h> |
| |
| #define LOG_TAG "NatController" |
| #include <cutils/log.h> |
| diff --git a/system/netd/server/NatController.h b/system/netd/server/NatController.h |
| index f23bf84..6bd4f64 100644 |
| --- a/system/netd/server/NatController.h |
| +++ b/system/netd/server/NatController.h |
| @@ -17,7 +17,7 @@ |
| #ifndef _NAT_CONTROLLER_H |
| #define _NAT_CONTROLLER_H |
| |
| -#include <linux/in.h> |
| +//#include <linux/in.h> |
| #include <list> |
| #include <string> |
| |
| diff --git a/system/netd/server/NetdConstants.cpp b/system/netd/server/NetdConstants.cpp |
| index c86538b..54f1344 100644 |
| --- a/system/netd/server/NetdConstants.cpp |
| +++ b/system/netd/server/NetdConstants.cpp |
| @@ -19,7 +19,6 @@ |
| #include <fcntl.h> |
| #include <netdb.h> |
| #include <net/if.h> |
| -#include <netinet/in.h> |
| #include <stdlib.h> |
| #include <string.h> |
| #include <sys/wait.h> |
| @@ -32,10 +31,10 @@ |
| #include "NetdConstants.h" |
| |
| const char * const OEM_SCRIPT_PATH = "/system/bin/oem-iptables-init.sh"; |
| -const char * const IPTABLES_PATH = "/system/bin/iptables"; |
| -const char * const IP6TABLES_PATH = "/system/bin/ip6tables"; |
| -const char * const TC_PATH = "/system/bin/tc"; |
| -const char * const IP_PATH = "/system/bin/ip"; |
| +const char * const IPTABLES_PATH = "/usr/sbin/iptables"; |
| +const char * const IP6TABLES_PATH = "/usr/sbin/ip6tables"; |
| +const char * const TC_PATH = "/sbin/tc"; |
| +const char * const IP_PATH = "/sbin/ip"; |
| const char * const ADD = "add"; |
| const char * const DEL = "del"; |
| |
| @@ -172,6 +171,7 @@ int parsePrefix(const char *prefix, uint8_t *family, void *address, int size, ui |
| addrinfo hints = { |
| .ai_flags = AI_NUMERICHOST, |
| }; |
| + ALOGI("[zy]addressString.c_str(%s)", addressString.c_str()); |
| int ret = getaddrinfo(addressString.c_str(), NULL, &hints, &res); |
| if (ret || !res) { |
| return -EINVAL; // getaddrinfo return values are not errno values. |
| @@ -211,7 +211,9 @@ int parsePrefix(const char *prefix, uint8_t *family, void *address, int size, ui |
| } |
| |
| *family = res[0].ai_family; |
| + ALOGI("[zy]parsePrefix address[%p], rawAddress[%p], rawLength[%d]", address, rawAddress, rawLength); |
| memcpy(address, rawAddress, rawLength); |
| + ALOGI("[zy]after"); |
| freeaddrinfo(res); |
| |
| return rawLength; |
| diff --git a/system/netd/server/NetlinkManager.cpp b/system/netd/server/NetlinkManager.cpp |
| index 76af46f..853bf47 100644 |
| --- a/system/netd/server/NetlinkManager.cpp |
| +++ b/system/netd/server/NetlinkManager.cpp |
| @@ -44,7 +44,7 @@ |
| #include "NetlinkManager.h" |
| #include "NetlinkHandler.h" |
| |
| -#include "pcap-netfilter-linux-android.h" |
| +//#include "pcap-netfilter-linux-android.h" |
| |
| const int NetlinkManager::NFLOG_QUOTA_GROUP = 1; |
| const int NetlinkManager::NETFILTER_STRICT_GROUP = 2; |
| @@ -98,7 +98,7 @@ NetlinkHandler *NetlinkManager::setupSocket(int *sock, int netlinkFamily, |
| close(*sock); |
| return NULL; |
| } |
| - |
| + #if 0 |
| if (configNflog) { |
| if (android_nflog_send_config_cmd(*sock, 0, NFULNL_CFG_CMD_PF_UNBIND, AF_INET) < 0) { |
| ALOGE("Failed NFULNL_CFG_CMD_PF_UNBIND: %s", strerror(errno)); |
| @@ -113,7 +113,7 @@ NetlinkHandler *NetlinkManager::setupSocket(int *sock, int netlinkFamily, |
| return NULL; |
| } |
| } |
| - |
| + #endif |
| NetlinkHandler *handler = new NetlinkHandler(this, *sock, format); |
| if (handler->start()) { |
| ALOGE("Unable to start NetlinkHandler: %s", strerror(errno)); |
| diff --git a/system/netd/server/PppController.cpp b/system/netd/server/PppController.cpp |
| index 581b9c6..4b9f79c 100644 |
| --- a/system/netd/server/PppController.cpp |
| +++ b/system/netd/server/PppController.cpp |
| @@ -26,7 +26,6 @@ |
| |
| #include <dirent.h> |
| |
| -#include <netinet/in.h> |
| #include <arpa/inet.h> |
| |
| #define LOG_TAG "PppController" |
| diff --git a/system/netd/server/PppController.h b/system/netd/server/PppController.h |
| index cc74c8c..3f45262 100644 |
| --- a/system/netd/server/PppController.h |
| +++ b/system/netd/server/PppController.h |
| @@ -17,7 +17,6 @@ |
| #ifndef _PPP_CONTROLLER_H |
| #define _PPP_CONTROLLER_H |
| |
| -#include <linux/in.h> |
| |
| #include "List.h" |
| |
| diff --git a/system/netd/server/ResolverController.h b/system/netd/server/ResolverController.h |
| index 39f002d..049bae1 100644 |
| --- a/system/netd/server/ResolverController.h |
| +++ b/system/netd/server/ResolverController.h |
| @@ -18,7 +18,7 @@ |
| #define _RESOLVER_CONTROLLER_H_ |
| |
| #include <netinet/in.h> |
| -#include <linux/in.h> |
| +//#include <linux/in.h> |
| |
| class ResolverController { |
| public: |
| diff --git a/system/netd/server/RouteController.cpp b/system/netd/server/RouteController.cpp |
| index 889779d..1d9f1e4 100644 |
| --- a/system/netd/server/RouteController.cpp |
| +++ b/system/netd/server/RouteController.cpp |
| @@ -21,7 +21,8 @@ |
| #include <fcntl.h> |
| #include <linux/fib_rules.h> |
| #include <net/if.h> |
| -#include <sys/stat.h> |
| +#include <sys/stat.h> |
| +#include <string.h> |
| |
| #include <private/android_filesystem_config.h> |
| |
| @@ -31,7 +32,7 @@ |
| #include "UidRanges.h" |
| #include "DummyNetwork.h" |
| |
| -#include "base/file.h" |
| +#include "android-base/file.h" |
| #define LOG_TAG "Netd" |
| #include "log/log.h" |
| #include "logwrap/logwrap.h" |
| @@ -99,7 +100,7 @@ const bool ACTION_ADD = true; |
| const bool ACTION_DEL = false; |
| const bool MODIFY_NON_UID_BASED_RULES = true; |
| |
| -const char* const RT_TABLES_PATH = "/data/misc/net/rt_tables"; |
| +const char* const RT_TABLES_PATH = "/etc/iproute2/rt_tables"; |
| const mode_t RT_TABLES_MODE = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; // mode 0644, rw-r--r-- |
| |
| const unsigned ROUTE_FLUSH_ATTEMPTS = 2; |
| @@ -181,10 +182,17 @@ void updateTableNamesFile() { |
| // The netlink header is generated by this function based on |action| and |flags|. |
| // Returns -errno if there was an error or if the kernel reported an error. |
| WARN_UNUSED_RESULT int sendNetlinkRequest(uint16_t action, uint16_t flags, iovec* iov, int iovlen) { |
| + #if 0 |
| nlmsghdr nlmsg = { |
| - .nlmsg_type = action, |
| - .nlmsg_flags = flags, |
| + nlmsg_type : action, |
| + nlmsg_flags : flags, |
| }; |
| + #else |
| + nlmsghdr nlmsg = {}; |
| + nlmsg.nlmsg_type = action; |
| + nlmsg.nlmsg_flags = flags; |
| + #endif |
| + |
| iov[0].iov_base = &nlmsg; |
| iov[0].iov_len = sizeof(nlmsg); |
| for (int i = 0; i < iovlen; ++i) { |
| @@ -231,11 +239,12 @@ int padInterfaceName(const char* input, char* name, size_t* length, uint16_t* pa |
| *padding = 0; |
| return 0; |
| } |
| - *length = strlcpy(name, input, IFNAMSIZ) + 1; |
| + strncpy(name, input, IFNAMSIZ) + 1; |
| + /* *length = strlcpy(name, input, IFNAMSIZ) + 1; |
| if (*length > IFNAMSIZ) { |
| ALOGE("interface name too long (%zu > %u)", *length, IFNAMSIZ); |
| return -ENAMETOOLONG; |
| - } |
| + }*/ |
| *padding = RTA_SPACE(*length) - RTA_LENGTH(*length); |
| return 0; |
| } |
| @@ -283,13 +292,17 @@ WARN_UNUSED_RESULT int modifyIpRule(uint16_t action, uint32_t priority, uint32_t |
| bool isUidRule = (uidStart != INVALID_UID); |
| |
| // Assemble a rule request and put it in an array of iovec structures. |
| + #if 0 |
| fib_rule_hdr rule = { |
| .action = static_cast<uint8_t>(priority != RULE_PRIORITY_UNREACHABLE ? FR_ACT_TO_TBL : |
| FR_ACT_UNREACHABLE), |
| // Note that here we're implicitly setting rule.table to 0. When we want to specify a |
| // non-zero table, we do this via the FRATTR_TABLE attribute. |
| }; |
| - |
| + #else |
| + fib_rule_hdr rule = {}; |
| + rule.action = static_cast<uint8_t>(priority != RULE_PRIORITY_UNREACHABLE ? FR_ACT_TO_TBL : FR_ACT_UNREACHABLE); |
| + #endif |
| // Don't ever create a rule that looks up table 0, because table 0 is the local table. |
| // It's OK to specify a table ID of 0 when deleting a rule, because that doesn't actually select |
| // table 0, it's a wildcard that matches anything. |
| @@ -355,8 +368,10 @@ WARN_UNUSED_RESULT int modifyIpRoute(uint16_t action, uint32_t table, const char |
| uint8_t rawAddress[sizeof(in6_addr)]; |
| uint8_t family; |
| uint8_t prefixLength; |
| + ALOGI("[zy]modifyIpRoute before parsePrefix"); |
| int rawLength = parsePrefix(destination, &family, rawAddress, sizeof(rawAddress), |
| &prefixLength); |
| + ALOGI("[zy]modifyIpRoute after parsePrefix"); |
| if (rawLength < 0) { |
| ALOGE("parsePrefix failed for destination %s (%s)", destination, strerror(-rawLength)); |
| return rawLength; |
| @@ -400,6 +415,7 @@ WARN_UNUSED_RESULT int modifyIpRoute(uint16_t action, uint32_t table, const char |
| } |
| |
| // Assemble a rtmsg and put it in an array of iovec structures. |
| + #if 0 |
| rtmsg route = { |
| .rtm_protocol = RTPROT_STATIC, |
| .rtm_type = type, |
| @@ -407,7 +423,16 @@ WARN_UNUSED_RESULT int modifyIpRoute(uint16_t action, uint32_t table, const char |
| .rtm_dst_len = prefixLength, |
| .rtm_scope = static_cast<uint8_t>(nexthop ? RT_SCOPE_UNIVERSE : RT_SCOPE_LINK), |
| }; |
| - |
| + #else |
| + rtmsg route = {}; |
| + route.rtm_protocol = RTPROT_STATIC; |
| + route.rtm_type = type; |
| + route.rtm_family = family; |
| + route.rtm_dst_len = prefixLength; |
| + route.rtm_scope = static_cast<uint8_t>(nexthop ? RT_SCOPE_UNIVERSE : RT_SCOPE_LINK); |
| + |
| + #endif |
| + |
| rtattr rtaDst = { U16_RTA_LENGTH(rawLength), RTA_DST }; |
| rtattr rtaGateway = { U16_RTA_LENGTH(rawLength), RTA_GATEWAY }; |
| |
| @@ -740,17 +765,22 @@ WARN_UNUSED_RESULT int modifyPhysicalNetwork(unsigned netId, const char* interfa |
| return -ESRCH; |
| } |
| |
| + ALOGE("PhysicalNetwork"); |
| if (int ret = modifyIncomingPacketMark(netId, interface, permission, add)) { |
| + ALOGE("modifyIncomingPacketMark ret[%d]", ret); |
| return ret; |
| } |
| if (int ret = modifyExplicitNetworkRule(netId, table, permission, INVALID_UID, INVALID_UID, |
| add)) { |
| + ALOGE("modifyExplicitNetworkRule ret[%d]", ret); |
| return ret; |
| } |
| + #if 0 |
| if (int ret = modifyOutputInterfaceRules(interface, table, permission, INVALID_UID, INVALID_UID, |
| add)) { |
| return ret; |
| } |
| + #endif |
| return modifyImplicitNetworkRule(netId, table, permission, add); |
| } |
| |
| @@ -867,7 +897,7 @@ WARN_UNUSED_RESULT int modifyRoute(uint16_t action, const char* interface, const |
| break; |
| } |
| } |
| - |
| + ALOGI("[zy]modifyRoute"); |
| int ret = modifyIpRoute(action, table, interface, destination, nexthop); |
| // Trying to add a route that already exists shouldn't cause an error. |
| if (ret && !(action == RTM_NEWROUTE && ret == -EEXIST)) { |
| @@ -986,14 +1016,20 @@ int RouteController::addInterfaceToPhysicalNetwork(unsigned netId, const char* i |
| int RouteController::removeInterfaceFromPhysicalNetwork(unsigned netId, const char* interface, |
| Permission permission) { |
| if (int ret = modifyPhysicalNetwork(netId, interface, permission, ACTION_DEL)) { |
| + ALOGE("modifyPhysicalNetwork ret[%d]", ret); |
| return ret; |
| } |
| if (int ret = flushRoutes(interface)) { |
| + ALOGE("flushRoutes ret[%d]", ret); |
| return ret; |
| } |
| + |
| + #if 0 |
| if (int ret = clearTetheringRules(interface)) { |
| + ALOGE("clearTetheringRules ret[%d]", ret); |
| return ret; |
| } |
| + #endif |
| updateTableNamesFile(); |
| return 0; |
| } |
| diff --git a/system/netd/server/SoftapController.cpp b/system/netd/server/SoftapController.cpp |
| index d9e40a4..cc9c63e 100644 |
| --- a/system/netd/server/SoftapController.cpp |
| +++ b/system/netd/server/SoftapController.cpp |
| @@ -34,8 +34,8 @@ |
| #include <openssl/sha.h> |
| |
| #define LOG_TAG "SoftapController" |
| -#include <base/file.h> |
| -#include <base/stringprintf.h> |
| +#include <android-base/file.h> |
| +#include <android-base/stringprintf.h> |
| #include <cutils/log.h> |
| #include <netutils/ifc.h> |
| #include <private/android_filesystem_config.h> |
| diff --git a/system/netd/server/SoftapController.h b/system/netd/server/SoftapController.h |
| index 7063067..bad1a32 100644 |
| --- a/system/netd/server/SoftapController.h |
| +++ b/system/netd/server/SoftapController.h |
| @@ -17,8 +17,8 @@ |
| #ifndef _SOFTAP_CONTROLLER_H |
| #define _SOFTAP_CONTROLLER_H |
| |
| -#include <linux/in.h> |
| -#include <net/if.h> |
| +//#include <linux/in.h> |
| +//#include <net/if.h> |
| |
| #define SOFTAP_MAX_BUFFER_SIZE 4096 |
| #define AP_BSS_START_DELAY 200000 |
| diff --git a/system/netd/server/TetherController.cpp b/system/netd/server/TetherController.cpp |
| index 88baa31..d32ea0e 100644 |
| --- a/system/netd/server/TetherController.cpp |
| +++ b/system/netd/server/TetherController.cpp |
| @@ -29,7 +29,7 @@ |
| |
| #define LOG_TAG "TetherController" |
| #include <cutils/log.h> |
| -#include <cutils/properties.h> |
| +//#include <cutils/properties.h> |
| |
| #include "Fwmark.h" |
| #include "NetdConstants.h" |
| @@ -61,9 +61,13 @@ bool writeToFile(const char* filename, const char* value) { |
| |
| bool inBpToolsMode() { |
| // In BP tools mode, do not disable IP forwarding |
| + #if 0 |
| char bootmode[PROPERTY_VALUE_MAX] = {0}; |
| property_get("ro.bootmode", bootmode, "unknown"); |
| return !strcmp(BP_TOOLS_MODE, bootmode); |
| + #else |
| + return false; |
| + #endif |
| } |
| |
| } // namespace |
| diff --git a/system/netd/server/UidRanges.cpp b/system/netd/server/UidRanges.cpp |
| index 10e445a..cd9ac1a 100644 |
| --- a/system/netd/server/UidRanges.cpp |
| +++ b/system/netd/server/UidRanges.cpp |
| @@ -19,6 +19,7 @@ |
| #include "NetdConstants.h" |
| |
| #include <stdlib.h> |
| +#include <algorithm> |
| |
| bool UidRanges::hasUid(uid_t uid) const { |
| auto iter = std::lower_bound(mRanges.begin(), mRanges.end(), Range(uid, uid)); |
| diff --git a/system/netd/server/main.cpp b/system/netd/server/main.cpp |
| index 5e189cc..3feb10d 100644 |
| --- a/system/netd/server/main.cpp |
| +++ b/system/netd/server/main.cpp |
| @@ -33,7 +33,6 @@ |
| #include "CommandListener.h" |
| #include "NetlinkManager.h" |
| #include "DnsProxyListener.h" |
| -#include "MDnsSdListener.h" |
| #include "FwmarkServer.h" |
| |
| static void blockSigpipe(); |
| @@ -49,7 +48,7 @@ int main() { |
| CommandListener *cl; |
| NetlinkManager *nm; |
| DnsProxyListener *dpl; |
| - MDnsSdListener *mdnsl; |
| + //MDnsSdListener *mdnsl; |
| FwmarkServer* fwmarkServer; |
| |
| ALOGI("Netd 1.0 starting"); |
| @@ -78,19 +77,19 @@ int main() { |
| ALOGE("Unable to start DnsProxyListener (%s)", strerror(errno)); |
| exit(1); |
| } |
| - |
| - mdnsl = new MDnsSdListener(); |
| - if (mdnsl->startListener()) { |
| + //mdnsl = new MDnsSdListener(); |
| + /*if (mdnsl->startListener()) { |
| ALOGE("Unable to start MDnsSdListener (%s)", strerror(errno)); |
| exit(1); |
| - } |
| + }*/ |
| |
| + #if 0 |
| fwmarkServer = new FwmarkServer(CommandListener::sNetCtrl); |
| if (fwmarkServer->startListener()) { |
| ALOGE("Unable to start FwmarkServer (%s)", strerror(errno)); |
| exit(1); |
| } |
| - |
| + #endif |
| /* |
| * Now that we're up, we can respond to commands |
| */ |