Bug 1165844 - Add 'stopDhcp' to NetworkService. r=vchang

--HG--
extra : rebase_source : 7cbb9815448cf3cedb7da22317abe103e28ef4c3
This commit is contained in:
Henry Chang 2015-05-18 17:41:10 +08:00
parent cffa489f90
commit ccf15ae03e
4 changed files with 31 additions and 1 deletions

View File

@ -649,6 +649,17 @@ NetworkService.prototype = {
});
},
stopDhcp: function(interfaceName, callback) {
let params = {
cmd: "stopDhcp",
ifname: interfaceName
};
this.controlMessage(params, function(result) {
callback.nativeCommandResult(!result.error);
});
},
enableInterface: function(interfaceName, callback) {
let params = {
cmd: "enableInterface",

View File

@ -1615,6 +1615,7 @@ void NetworkUtils::ExecuteCommand(NetworkParams aOptions)
BUILD_ENTRY(updateUpStream),
BUILD_ENTRY(configureInterface),
BUILD_ENTRY(dhcpRequest),
BUILD_ENTRY(stopDhcp),
BUILD_ENTRY(enableInterface),
BUILD_ENTRY(disableInterface),
BUILD_ENTRY(resetConnections),
@ -1833,6 +1834,11 @@ CommandResult NetworkUtils::configureInterface(NetworkParams& aOptions)
);
}
CommandResult NetworkUtils::stopDhcp(NetworkParams& aOptions)
{
return mNetUtils->do_dhcp_stop(GET_CHAR(mIfname));
}
CommandResult NetworkUtils::dhcpRequest(NetworkParams& aOptions) {
mozilla::dom::NetworkResultOptions result;

View File

@ -287,6 +287,7 @@ private:
*/
CommandResult configureInterface(NetworkParams& aOptions);
CommandResult dhcpRequest(NetworkParams& aOptions);
CommandResult stopDhcp(NetworkParams& aOptions);
CommandResult enableInterface(NetworkParams& aOptions);
CommandResult disableInterface(NetworkParams& aOptions);
CommandResult resetConnections(NetworkParams& aOptions);

View File

@ -159,7 +159,7 @@ interface nsIDhcpRequestCallback : nsISupports
/**
* Provide network services.
*/
[scriptable, uuid(8216224c-a4e0-43fa-9662-3f2446b500c6)]
[scriptable, uuid(214c0810-fd41-11e4-b939-0800200c9a66)]
interface nsINetworkService : nsISupports
{
const long MODIFY_ROUTE_ADD = 0;
@ -417,6 +417,18 @@ interface nsINetworkService : nsISupports
void dhcpRequest(in DOMString interfaceName,
in nsIDhcpRequestCallback callback);
/**
* Stop Dhcp daemon.
*
* @param ifname
* Target interface.
*
* @param callback
* Callback to notify the result of stopping dhcp request.
*/
void stopDhcp(in DOMString ifname,
in nsINativeCommandCallback callback);
/**
* Enable a network interface.
*