зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1121834 - adapt Lollipop netd commands in dun tethering. r=echen
This commit is contained in:
Родитель
5e6e1e70be
Коммит
e5157181f5
|
@ -344,14 +344,16 @@ NetworkManager.prototype = {
|
|||
gNetworkService.removeHostRoutes(network.name);
|
||||
this.setHostRoutes(network);
|
||||
}
|
||||
|
||||
// Remove pre-created default route and let setAndConfigureActive()
|
||||
// to set default route only on preferred network
|
||||
gNetworkService.removeDefaultRoute(network);
|
||||
|
||||
// Dun type is a special case where we add the default route to a
|
||||
// secondary table.
|
||||
if (network.type == Ci.nsINetworkInterface.NETWORK_TYPE_MOBILE_DUN) {
|
||||
this.setSecondaryDefaultRoute(network);
|
||||
}
|
||||
// Remove pre-created default route and let setAndConfigureActive()
|
||||
// to set default route only on preferred network
|
||||
gNetworkService.removeDefaultRoute(network);
|
||||
|
||||
this._addSubnetRoutes(network);
|
||||
this.setAndConfigureActive();
|
||||
|
|
|
@ -1185,6 +1185,57 @@ void NetworkUtils::setDefaultNetwork(CommandChain* aChain,
|
|||
doCommand(command, aChain, aCallback);
|
||||
}
|
||||
|
||||
void NetworkUtils::addRouteToSecondaryTable(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult) {
|
||||
|
||||
char command[MAX_COMMAND_SIZE];
|
||||
|
||||
if (SDK_VERSION >= 20) {
|
||||
snprintf(command, MAX_COMMAND_SIZE - 1,
|
||||
"network route add %d %s %s/%s %s",
|
||||
GET_FIELD(mNetId),
|
||||
GET_CHAR(mIfname),
|
||||
GET_CHAR(mIp),
|
||||
GET_CHAR(mPrefix),
|
||||
GET_CHAR(mGateway));
|
||||
} else {
|
||||
snprintf(command, MAX_COMMAND_SIZE - 1,
|
||||
"interface route add %s secondary %s %s %s",
|
||||
GET_CHAR(mIfname),
|
||||
GET_CHAR(mIp),
|
||||
GET_CHAR(mPrefix),
|
||||
GET_CHAR(mGateway));
|
||||
}
|
||||
|
||||
doCommand(command, aChain, aCallback);
|
||||
}
|
||||
|
||||
void NetworkUtils::removeRouteFromSecondaryTable(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult) {
|
||||
char command[MAX_COMMAND_SIZE];
|
||||
|
||||
if (SDK_VERSION >= 20) {
|
||||
snprintf(command, MAX_COMMAND_SIZE - 1,
|
||||
"network route remove %d %s %s/%s %s",
|
||||
GET_FIELD(mNetId),
|
||||
GET_CHAR(mIfname),
|
||||
GET_CHAR(mIp),
|
||||
GET_CHAR(mPrefix),
|
||||
GET_CHAR(mGateway));
|
||||
} else {
|
||||
snprintf(command, MAX_COMMAND_SIZE - 1,
|
||||
"interface route remove %s secondary %s %s %s",
|
||||
GET_CHAR(mIfname),
|
||||
GET_CHAR(mIp),
|
||||
GET_CHAR(mPrefix),
|
||||
GET_CHAR(mGateway));
|
||||
}
|
||||
|
||||
doCommand(command, aChain, aCallback);
|
||||
}
|
||||
|
||||
void NetworkUtils::setIpv6Enabled(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult,
|
||||
|
@ -2119,30 +2170,40 @@ CommandResult NetworkUtils::removeNetworkRouteLegacy(NetworkParams& aOptions)
|
|||
|
||||
CommandResult NetworkUtils::addSecondaryRoute(NetworkParams& aOptions)
|
||||
{
|
||||
char command[MAX_COMMAND_SIZE];
|
||||
snprintf(command, MAX_COMMAND_SIZE - 1,
|
||||
"interface route add %s secondary %s %s %s",
|
||||
GET_CHAR(mIfname),
|
||||
GET_CHAR(mIp),
|
||||
GET_CHAR(mPrefix),
|
||||
GET_CHAR(mGateway));
|
||||
static CommandFunc COMMAND_CHAIN[] = {
|
||||
addRouteToSecondaryTable,
|
||||
defaultAsyncSuccessHandler
|
||||
};
|
||||
|
||||
doCommand(command, nullptr, nullptr);
|
||||
return SUCCESS;
|
||||
if (SDK_VERSION >= 20) {
|
||||
NetIdManager::NetIdInfo netIdInfo;
|
||||
if (!mNetIdManager.lookup(aOptions.mIfname, &netIdInfo)) {
|
||||
return -1;
|
||||
}
|
||||
aOptions.mNetId = netIdInfo.mNetId;
|
||||
}
|
||||
|
||||
runChain(aOptions, COMMAND_CHAIN, defaultAsyncFailureHandler);
|
||||
return CommandResult::Pending();
|
||||
}
|
||||
|
||||
CommandResult NetworkUtils::removeSecondaryRoute(NetworkParams& aOptions)
|
||||
{
|
||||
char command[MAX_COMMAND_SIZE];
|
||||
snprintf(command, MAX_COMMAND_SIZE - 1,
|
||||
"interface route remove %s secondary %s %s %s",
|
||||
GET_CHAR(mIfname),
|
||||
GET_CHAR(mIp),
|
||||
GET_CHAR(mPrefix),
|
||||
GET_CHAR(mGateway));
|
||||
static CommandFunc COMMAND_CHAIN[] = {
|
||||
removeRouteFromSecondaryTable,
|
||||
defaultAsyncSuccessHandler
|
||||
};
|
||||
|
||||
doCommand(command, nullptr, nullptr);
|
||||
return SUCCESS;
|
||||
if (SDK_VERSION >= 20) {
|
||||
NetIdManager::NetIdInfo netIdInfo;
|
||||
if (!mNetIdManager.lookup(aOptions.mIfname, &netIdInfo)) {
|
||||
return -1;
|
||||
}
|
||||
aOptions.mNetId = netIdInfo.mNetId;
|
||||
}
|
||||
|
||||
runChain(aOptions, COMMAND_CHAIN, defaultAsyncFailureHandler);
|
||||
return CommandResult::Pending();
|
||||
}
|
||||
|
||||
CommandResult NetworkUtils::setNetworkInterfaceAlarm(NetworkParams& aOptions)
|
||||
|
|
|
@ -392,6 +392,8 @@ private:
|
|||
static void enableIpv6(PARAMS);
|
||||
static void disableIpv6(PARAMS);
|
||||
static void setIpv6Enabled(PARAMS, bool aEnabled);
|
||||
static void addRouteToSecondaryTable(PARAMS);
|
||||
static void removeRouteFromSecondaryTable(PARAMS);
|
||||
static void defaultAsyncSuccessHandler(PARAMS);
|
||||
|
||||
#undef PARAMS
|
||||
|
|
Загрузка…
Ссылка в новой задаче