Bug 768394 - Catch up with changes in ifc_reset_connections on ICS. r=gal

This commit is contained in:
Blake Kaplan 2012-08-30 13:01:34 -03:00
parent 04b90daa32
commit a7b316a7a3
2 changed files with 32 additions and 5 deletions

View File

@ -145,10 +145,6 @@ let libnetutils = (function () {
ctypes.default_abi,
ctypes.int,
ctypes.char.ptr),
ifc_reset_connections: library.declare("ifc_reset_connections",
ctypes.default_abi,
ctypes.int,
ctypes.char.ptr),
ifc_configure: library.declare("ifc_configure", ctypes.default_abi,
ctypes.int,
ctypes.char.ptr,
@ -165,8 +161,16 @@ let libnetutils = (function () {
ctypes.char.ptr),
dhcp_get_errmsg: library.declare("dhcp_get_errmsg", ctypes.default_abi,
ctypes.char.ptr),
// Constants for ifc_reset_connections.
// NOTE: Ignored in versions before ICS.
RESET_IPV4_ADDRESSES: 0x01,
RESET_IPV6_ADDRESSES: 0x02,
};
iface.RESET_ALL_ADDRESSES = iface.RESET_IPV4_ADDRESSES |
iface.RESET_IPV6_ADDRESSES
// dhcp_do_request's interface changed in SDK version 15. We try to hide
// this here by implementing the same JS API for both versions.
@ -228,6 +232,17 @@ let libnetutils = (function () {
};
// dhcp_do_request_renew() went away in newer libnetutils.
iface.dhcp_do_request_renew = iface.dhcp_do_request;
// Same deal with ifc_reset_connections.
let c_ifc_reset_connections =
library.declare("ifc_reset_connections",
ctypes.default_abi,
ctypes.int,
ctypes.char.ptr,
ctypes.int);
iface.ifc_reset_connections = function(ifname, reset_mask) {
return c_ifc_reset_connections(ifname, reset_mask) | 0;
}
} else {
let ints = ctypes.int.array(8)();
let c_dhcp_do_request =
@ -279,6 +294,14 @@ let libnetutils = (function () {
};
iface.dhcp_do_request = wrapCFunc(c_dhcp_do_request);
iface.dhcp_do_request_renew = wrapCFunc(c_dhcp_do_request_renew);
let c_ifc_reset_connections =
library.declare("ifc_reset_connections",
ctypes.default_abi,
ctypes.int,
ctypes.char.ptr);
iface.ifc_reset_connections = function(ifname, reset_mask) {
return c_ifc_reset_connections(ifname) | 0;
}
}
return iface;

View File

@ -58,11 +58,15 @@ self.onmessage = function(e) {
var event = cbuf.readString().substr(0, ret.value);
postMessage({ id: id, event: event });
break;
case "ifc_reset_connections":
var ret = libnetutils.ifc_reset_connections(data.ifname,
libnetutils.RESET_ALL_ADDRESSES);
postMessage({ id: id, status: ret });
break;
case "ifc_enable":
case "ifc_disable":
case "ifc_remove_host_routes":
case "ifc_remove_default_route":
case "ifc_reset_connections":
case "dhcp_stop":
case "dhcp_release_lease":
var ret = libnetutils[cmd](data.ifname);