am c101c56e: Use resetConnections with resetMask.
* commit 'c101c56ecc4d6a0440225ed8550faa09dc4cd81b': Use resetConnections with resetMask.
This commit is contained in:
@@ -38,8 +38,22 @@ public class NetworkUtils {
|
|||||||
/** Bring the named network interface down. */
|
/** Bring the named network interface down. */
|
||||||
public native static int disableInterface(String interfaceName);
|
public native static int disableInterface(String interfaceName);
|
||||||
|
|
||||||
/** Reset any sockets that are connected via the named interface. */
|
/** Setting bit 0 indicates reseting of IPv4 addresses required */
|
||||||
public native static int resetConnections(String interfaceName);
|
public static final int RESET_IPV4_ADDRESSES = 0x01;
|
||||||
|
|
||||||
|
/** Setting bit 1 indicates reseting of IPv4 addresses required */
|
||||||
|
public static final int RESET_IPV6_ADDRESSES = 0x02;
|
||||||
|
|
||||||
|
/** Reset all addresses */
|
||||||
|
public static final int RESET_ALL_ADDRESSES = RESET_IPV4_ADDRESSES | RESET_IPV6_ADDRESSES;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset IPv6 or IPv4 sockets that are connected via the named interface.
|
||||||
|
*
|
||||||
|
* @param interfaceName is the interface to reset
|
||||||
|
* @param mask {@see #RESET_IPV4_ADDRESSES} and {@see #RESET_IPV6_ADDRESSES}
|
||||||
|
*/
|
||||||
|
public native static int resetConnections(String interfaceName, int mask);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the DHCP client daemon, in order to have it request addresses
|
* Start the DHCP client daemon, in order to have it request addresses
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
int ifc_enable(const char *ifname);
|
int ifc_enable(const char *ifname);
|
||||||
int ifc_disable(const char *ifname);
|
int ifc_disable(const char *ifname);
|
||||||
int ifc_reset_connections(const char *ifname);
|
int ifc_reset_connections(const char *ifname, int reset_mask);
|
||||||
|
|
||||||
int dhcp_do_request(const char *ifname,
|
int dhcp_do_request(const char *ifname,
|
||||||
const char *ipaddr,
|
const char *ipaddr,
|
||||||
@@ -91,12 +91,17 @@ static jint android_net_utils_disableInterface(JNIEnv* env, jobject clazz, jstri
|
|||||||
return (jint)result;
|
return (jint)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint android_net_utils_resetConnections(JNIEnv* env, jobject clazz, jstring ifname)
|
static jint android_net_utils_resetConnections(JNIEnv* env, jobject clazz,
|
||||||
|
jstring ifname, jint mask)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
const char *nameStr = env->GetStringUTFChars(ifname, NULL);
|
const char *nameStr = env->GetStringUTFChars(ifname, NULL);
|
||||||
result = ::ifc_reset_connections(nameStr);
|
|
||||||
|
LOGD("android_net_utils_resetConnections in env=%p clazz=%p iface=%s mask=0x%x\n",
|
||||||
|
env, clazz, nameStr, mask);
|
||||||
|
|
||||||
|
result = ::ifc_reset_connections(nameStr, mask);
|
||||||
env->ReleaseStringUTFChars(ifname, nameStr);
|
env->ReleaseStringUTFChars(ifname, nameStr);
|
||||||
return (jint)result;
|
return (jint)result;
|
||||||
}
|
}
|
||||||
@@ -207,7 +212,7 @@ static JNINativeMethod gNetworkUtilMethods[] = {
|
|||||||
|
|
||||||
{ "enableInterface", "(Ljava/lang/String;)I", (void *)android_net_utils_enableInterface },
|
{ "enableInterface", "(Ljava/lang/String;)I", (void *)android_net_utils_enableInterface },
|
||||||
{ "disableInterface", "(Ljava/lang/String;)I", (void *)android_net_utils_disableInterface },
|
{ "disableInterface", "(Ljava/lang/String;)I", (void *)android_net_utils_disableInterface },
|
||||||
{ "resetConnections", "(Ljava/lang/String;)I", (void *)android_net_utils_resetConnections },
|
{ "resetConnections", "(Ljava/lang/String;I)I", (void *)android_net_utils_resetConnections },
|
||||||
{ "runDhcp", "(Ljava/lang/String;Landroid/net/DhcpInfoInternal;)Z", (void *)android_net_utils_runDhcp },
|
{ "runDhcp", "(Ljava/lang/String;Landroid/net/DhcpInfoInternal;)Z", (void *)android_net_utils_runDhcp },
|
||||||
{ "runDhcpRenew", "(Ljava/lang/String;Landroid/net/DhcpInfoInternal;)Z", (void *)android_net_utils_runDhcpRenew },
|
{ "runDhcpRenew", "(Ljava/lang/String;Landroid/net/DhcpInfoInternal;)Z", (void *)android_net_utils_runDhcpRenew },
|
||||||
{ "stopDhcp", "(Ljava/lang/String;)Z", (void *)android_net_utils_stopDhcp },
|
{ "stopDhcp", "(Ljava/lang/String;)Z", (void *)android_net_utils_stopDhcp },
|
||||||
|
|||||||
@@ -1449,8 +1449,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||||||
if (linkProperties != null) {
|
if (linkProperties != null) {
|
||||||
String iface = linkProperties.getInterfaceName();
|
String iface = linkProperties.getInterfaceName();
|
||||||
if (TextUtils.isEmpty(iface) == false) {
|
if (TextUtils.isEmpty(iface) == false) {
|
||||||
if (DBG) log("resetConnections(" + iface + ")");
|
if (DBG) {
|
||||||
NetworkUtils.resetConnections(iface);
|
log("resetConnections(" + iface + ", NetworkUtils.RESET_ALL_ADDRESSES)");
|
||||||
|
}
|
||||||
|
NetworkUtils.resetConnections(iface, NetworkUtils.RESET_ALL_ADDRESSES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user