use of android.system.PacketSocketAddress in project android_frameworks_base by crdroidandroid.
the class DhcpClient method initInterface.
private boolean initInterface() {
try {
mIface = NetworkInterface.getByName(mIfaceName);
mHwAddr = mIface.getHardwareAddress();
mInterfaceBroadcastAddr = new PacketSocketAddress(mIface.getIndex(), DhcpPacket.ETHER_BROADCAST);
return true;
} catch (SocketException | NullPointerException e) {
Log.e(TAG, "Can't determine ifindex or MAC address for " + mIfaceName, e);
return false;
}
}
use of android.system.PacketSocketAddress in project android_frameworks_base by crdroidandroid.
the class DhcpClient method initPacketSocket.
private boolean initPacketSocket() {
try {
mPacketSock = Os.socket(AF_PACKET, SOCK_RAW, ETH_P_IP);
PacketSocketAddress addr = new PacketSocketAddress((short) ETH_P_IP, mIface.getIndex());
Os.bind(mPacketSock, addr);
NetworkUtils.attachDhcpFilter(mPacketSock);
} catch (SocketException | ErrnoException e) {
Log.e(TAG, "Error creating packet socket", e);
return false;
}
return true;
}
Aggregations