зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1174998 - Part 1: add setMtu() support in NetworkService. r=echen,smaug
--HG-- extra : commitid : HTYjKaoJwgb
This commit is contained in:
Родитель
12125b4b32
Коммит
74cd4ce044
|
@ -801,6 +801,20 @@ NetworkService.prototype = {
|
|||
});
|
||||
});
|
||||
},
|
||||
|
||||
setMtu: function (aInterfaceName, aMtu, aCallback) {
|
||||
debug("Set MTU on " + aInterfaceName + ": " + aMtu);
|
||||
|
||||
let params = {
|
||||
cmd: "setMtu",
|
||||
ifname: aInterfaceName,
|
||||
mtu: aMtu
|
||||
};
|
||||
|
||||
this.controlMessage(params, function(aResult) {
|
||||
aCallback.nativeCommandResult(!aResult.error);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NetworkService]);
|
||||
|
|
|
@ -1438,6 +1438,17 @@ void NetworkUtils::disableIpv6(CommandChain* aChain,
|
|||
setIpv6Enabled(aChain, aCallback, aResult, false);
|
||||
}
|
||||
|
||||
void NetworkUtils::setMtu(CommandChain* aChain,
|
||||
CommandCallback aCallback,
|
||||
NetworkResultOptions& aResult)
|
||||
{
|
||||
char command[MAX_COMMAND_SIZE];
|
||||
PR_snprintf(command, MAX_COMMAND_SIZE - 1, "interface setmtu %s %d",
|
||||
GET_CHAR(mIfname), GET_FIELD(mMtu));
|
||||
|
||||
doCommand(command, aChain, aCallback);
|
||||
}
|
||||
|
||||
#undef GET_CHAR
|
||||
#undef GET_FIELD
|
||||
|
||||
|
@ -1676,6 +1687,7 @@ void NetworkUtils::ExecuteCommand(NetworkParams aOptions)
|
|||
BUILD_ENTRY(createNetwork),
|
||||
BUILD_ENTRY(destroyNetwork),
|
||||
BUILD_ENTRY(getNetId),
|
||||
BUILD_ENTRY(setMtu),
|
||||
|
||||
#undef BUILD_ENTRY
|
||||
};
|
||||
|
@ -2714,6 +2726,23 @@ CommandResult NetworkUtils::getNetId(NetworkParams& aOptions)
|
|||
return result;
|
||||
}
|
||||
|
||||
CommandResult NetworkUtils::setMtu(NetworkParams& aOptions)
|
||||
{
|
||||
// Setting/getting mtu is supported since Kitkat.
|
||||
if (SDK_VERSION < 19) {
|
||||
ERROR("setMtu is not supported in current SDK_VERSION.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static CommandFunc COMMAND_CHAIN[] = {
|
||||
setMtu,
|
||||
defaultAsyncSuccessHandler,
|
||||
};
|
||||
|
||||
runChain(aOptions, COMMAND_CHAIN, defaultAsyncFailureHandler);
|
||||
return CommandResult::Pending();
|
||||
}
|
||||
|
||||
void NetworkUtils::sendBroadcastMessage(uint32_t code, char* reason)
|
||||
{
|
||||
NetworkResultOptions result;
|
||||
|
|
|
@ -144,6 +144,7 @@ public:
|
|||
COPY_OPT_FIELD(mGateway_long, 0)
|
||||
COPY_OPT_FIELD(mDns1_long, 0)
|
||||
COPY_OPT_FIELD(mDns2_long, 0)
|
||||
COPY_OPT_FIELD(mMtu, 0)
|
||||
|
||||
mLoopIndex = 0;
|
||||
|
||||
|
@ -196,6 +197,7 @@ public:
|
|||
long mGateway_long;
|
||||
long mDns1_long;
|
||||
long mDns2_long;
|
||||
long mMtu;
|
||||
|
||||
// Auxiliary information required to carry accros command chain.
|
||||
int mNetId; // A locally defined id per interface.
|
||||
|
@ -312,6 +314,7 @@ private:
|
|||
CommandResult createNetwork(NetworkParams& aOptions);
|
||||
CommandResult destroyNetwork(NetworkParams& aOptions);
|
||||
CommandResult getNetId(NetworkParams& aOptions);
|
||||
CommandResult setMtu(NetworkParams& aOptions);
|
||||
|
||||
CommandResult addHostRouteLegacy(NetworkParams& aOptions);
|
||||
CommandResult removeHostRouteLegacy(NetworkParams& aOptions);
|
||||
|
@ -402,6 +405,7 @@ private:
|
|||
static void modifyRouteOnInterface(PARAMS, bool aDoAdd);
|
||||
static void enableIpv6(PARAMS);
|
||||
static void disableIpv6(PARAMS);
|
||||
static void setMtu(PARAMS);
|
||||
static void setIpv6Enabled(PARAMS, bool aEnabled);
|
||||
static void addRouteToSecondaryTable(PARAMS);
|
||||
static void removeRouteFromSecondaryTable(PARAMS);
|
||||
|
|
|
@ -157,7 +157,7 @@ interface nsIDhcpRequestCallback : nsISupports
|
|||
/**
|
||||
* Provide network services.
|
||||
*/
|
||||
[scriptable, uuid(fcd0abd4-8525-469f-a166-12edb4081f3e)]
|
||||
[scriptable, uuid(8f689d9f-30c0-4809-8bf6-87120e71f3ee)]
|
||||
interface nsINetworkService : nsISupports
|
||||
{
|
||||
const long MODIFY_ROUTE_ADD = 0;
|
||||
|
@ -482,9 +482,9 @@ interface nsINetworkService : nsISupports
|
|||
in nsINativeCommandCallback callback);
|
||||
|
||||
/**
|
||||
* Reset all connections
|
||||
* Reset all connections on a specified network interface.
|
||||
*
|
||||
* @param networkInterface
|
||||
* @param interfaceName
|
||||
* The network interface name which we want to reset.
|
||||
*
|
||||
* @param callback
|
||||
|
@ -494,25 +494,25 @@ interface nsINetworkService : nsISupports
|
|||
in nsINativeCommandCallback callback);
|
||||
|
||||
/**
|
||||
* Create network (required to call prior to any networking operation)
|
||||
* Create network (required to call prior to any networking operation).
|
||||
*
|
||||
* @param networkInterface
|
||||
* The network interface name which we want to reset.
|
||||
* @param interfaceName
|
||||
* The network interface name which we want to create network for.
|
||||
*
|
||||
* @param callback
|
||||
* Callback to notify the result of resetting connections.
|
||||
* Callback to notify the result of creating network.
|
||||
*/
|
||||
void createNetwork(in DOMString interfaceName,
|
||||
in nsINativeCommandCallback callback);
|
||||
|
||||
/**
|
||||
* Destroy network (required to call prior to any networking operation)
|
||||
* Destroy network.
|
||||
*
|
||||
* @param networkInterface
|
||||
* The network interface name which we want to reset.
|
||||
* @param interfaceName
|
||||
* The network interface name of the network we want to destroy.
|
||||
*
|
||||
* @param callback
|
||||
* Callback to notify the result of resetting connections.
|
||||
* Callback to notify the result of destroying network.
|
||||
*/
|
||||
void destroyNetwork(in DOMString interfaceName,
|
||||
in nsINativeCommandCallback callback);
|
||||
|
@ -529,4 +529,18 @@ interface nsINetworkService : nsISupports
|
|||
*
|
||||
*/
|
||||
jsval getNetId(in DOMString interfaceName);
|
||||
|
||||
/**
|
||||
* Set maximum transmission unit on a network interface.
|
||||
*
|
||||
* @param interfaceName
|
||||
* The name of the network interface that we want to set mtu.
|
||||
* @param mtu
|
||||
* Size of maximum tranmission unit.
|
||||
*
|
||||
* @param callback
|
||||
* Callback to notify the result of setting mtu.
|
||||
*/
|
||||
void setMtu(in DOMString interfaceName, in long mtu,
|
||||
in nsINativeCommandCallback callback);
|
||||
};
|
||||
|
|
|
@ -54,6 +54,8 @@ dictionary NetworkCommandOptions
|
|||
long gateway_long; // for "ifc_configure".
|
||||
long dns1_long; // for "ifc_configure".
|
||||
long dns2_long; // for "ifc_configure".
|
||||
|
||||
long mtu; // for "setMtu".
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче