use of android.net.InterfaceConfiguration in project android_frameworks_base by ParanoidAndroid.
the class Nat464Xlat method interfaceAdded.
@Override
public void interfaceAdded(String iface) {
if (iface.equals(CLAT_INTERFACE_NAME)) {
Slog.i(TAG, "interface " + CLAT_INTERFACE_NAME + " added, mIsRunning = " + mIsRunning + " -> true");
mIsRunning = true;
// it's running on.
try {
InterfaceConfiguration config = mNMService.getInterfaceConfig(iface);
mLP.clear();
mLP.setInterfaceName(iface);
RouteInfo ipv4Default = new RouteInfo(new LinkAddress(Inet4Address.ANY, 0), null, iface);
mLP.addRoute(ipv4Default);
mLP.addLinkAddress(config.getLinkAddress());
mTracker.addStackedLink(mLP);
Slog.i(TAG, "Adding stacked link. tracker LP: " + mTracker.getLinkProperties());
} catch (RemoteException e) {
Slog.e(TAG, "Error getting link properties: " + e);
}
// Inform ConnectivityService that things have changed.
Message msg = mHandler.obtainMessage(NetworkStateTracker.EVENT_CONFIGURATION_CHANGED, mTracker.getNetworkInfo());
Slog.i(TAG, "sending message to ConnectivityService: " + msg);
msg.sendToTarget();
}
}
use of android.net.InterfaceConfiguration in project android_frameworks_base by ParanoidAndroid.
the class WifiStateMachine method stopTethering.
private void stopTethering() {
checkAndSetConnectivityInstance();
/* Clear the interface config to allow dhcp correctly configure new
ip settings */
InterfaceConfiguration ifcg = null;
try {
ifcg = mNwService.getInterfaceConfig(mTetherInterfaceName);
if (ifcg != null) {
ifcg.setLinkAddress(new LinkAddress(NetworkUtils.numericToInetAddress("0.0.0.0"), 0));
mNwService.setInterfaceConfig(mTetherInterfaceName, ifcg);
}
} catch (Exception e) {
loge("Error resetting interface " + mTetherInterfaceName + ", :" + e);
}
if (mCm.untether(mTetherInterfaceName) != ConnectivityManager.TETHER_ERROR_NO_ERROR) {
loge("Untether initiate failed!");
}
}
use of android.net.InterfaceConfiguration in project platform_frameworks_base by android.
the class NetworkManagementService method getInterfaceConfig.
@Override
public InterfaceConfiguration getInterfaceConfig(String iface) {
mContext.enforceCallingOrSelfPermission(CONNECTIVITY_INTERNAL, TAG);
final NativeDaemonEvent event;
try {
event = mConnector.execute("interface", "getcfg", iface);
} catch (NativeDaemonConnectorException e) {
throw e.rethrowAsParcelableException();
}
event.checkCode(InterfaceGetCfgResult);
// Rsp: 213 xx:xx:xx:xx:xx:xx yyy.yyy.yyy.yyy zzz flag1 flag2 flag3
final StringTokenizer st = new StringTokenizer(event.getMessage());
InterfaceConfiguration cfg;
try {
cfg = new InterfaceConfiguration();
cfg.setHardwareAddress(st.nextToken(" "));
InetAddress addr = null;
int prefixLength = 0;
try {
addr = NetworkUtils.numericToInetAddress(st.nextToken());
} catch (IllegalArgumentException iae) {
Slog.e(TAG, "Failed to parse ipaddr", iae);
}
try {
prefixLength = Integer.parseInt(st.nextToken());
} catch (NumberFormatException nfe) {
Slog.e(TAG, "Failed to parse prefixLength", nfe);
}
cfg.setLinkAddress(new LinkAddress(addr, prefixLength));
while (st.hasMoreTokens()) {
cfg.setFlag(st.nextToken());
}
} catch (NoSuchElementException nsee) {
throw new IllegalStateException("Invalid response from daemon: " + event);
}
return cfg;
}
use of android.net.InterfaceConfiguration in project platform_frameworks_base by android.
the class IpManager method clearIPv4Address.
private void clearIPv4Address() {
try {
final InterfaceConfiguration ifcg = new InterfaceConfiguration();
ifcg.setLinkAddress(new LinkAddress("0.0.0.0/0"));
mNwService.setInterfaceConfig(mInterfaceName, ifcg);
} catch (IllegalStateException | RemoteException e) {
Log.e(mTag, "ALERT: Failed to clear IPv4 address on interface " + mInterfaceName, e);
}
}
use of android.net.InterfaceConfiguration in project XobotOS by xamarin.
the class WifiStateMachine method stopTethering.
private void stopTethering() {
checkAndSetConnectivityInstance();
/* Clear the interface config to allow dhcp correctly configure new
ip settings */
InterfaceConfiguration ifcg = null;
try {
ifcg = mNwService.getInterfaceConfig(mInterfaceName);
if (ifcg != null) {
ifcg.addr = new LinkAddress(NetworkUtils.numericToInetAddress("0.0.0.0"), 0);
mNwService.setInterfaceConfig(mInterfaceName, ifcg);
}
} catch (Exception e) {
loge("Error resetting interface " + mInterfaceName + ", :" + e);
}
if (mCm.untether(mInterfaceName) != ConnectivityManager.TETHER_ERROR_NO_ERROR) {
loge("Untether initiate failed!");
}
}
Aggregations