本文整理汇总了Java中org.pcap4j.util.ByteArrays类的典型用法代码示例。如果您正苦于以下问题:Java ByteArrays类的具体用法?Java ByteArrays怎么用?Java ByteArrays使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrays类属于org.pcap4j.util包,在下文中一共展示了ByteArrays类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getRawData
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
@Override
public byte[] getRawData() {
byte[] rawData = new byte[length()];
rawData[0] = kind.value();
rawData[1] = length;
int offset = 2;
for (Sack sack: sacks) {
System.arraycopy(
ByteArrays.toByteArray(sack.leftEdge), 0,
rawData, offset, INT_SIZE_IN_BYTES
);
System.arraycopy(
ByteArrays.toByteArray(sack.rightEdge), 0,
rawData, offset + INT_SIZE_IN_BYTES, INT_SIZE_IN_BYTES
);
offset += INT_SIZE_IN_BYTES * 2;
}
return rawData;
}
开发者ID:breakEval13,项目名称:NSS,代码行数:22,代码来源:CustomTcpSackOption.java
示例2: getLinkLayerAddress
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
/**
* IPv6 Neighbor Discovery Source Link Layer Address header
*
* 0 1 2 3
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Type | Length | Link-Layer Address ...
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
private String getLinkLayerAddress(IpV6Packet pkt) {
final int TYPE_OFFSET = 0;
final int TYPE_SIZE = BYTE_SIZE_IN_BYTES;
final int LENGTH_OFFSET = TYPE_OFFSET + TYPE_SIZE;
final int LENGTH_SIZE = BYTE_SIZE_IN_BYTES;
final int LINK_LAYER_ADDRESS_OFFSET = LENGTH_OFFSET + LENGTH_SIZE;
final int LINK_LAYER_ADDRESS_LENGTH = 6; // MAC address
IcmpV6NeighborSolicitationPacket nsPkt = pkt.get(IcmpV6NeighborSolicitationPacket.class);
IpV6NeighborDiscoveryOption linkLayerAddressOption = nsPkt.getHeader().getOptions().get(0);
byte[] linkLayerAddress = ByteArrays.getSubArray(linkLayerAddressOption.getRawData(), LINK_LAYER_ADDRESS_OFFSET, LINK_LAYER_ADDRESS_LENGTH);
return ByteArrays.toHexString(linkLayerAddress, ":");
}
开发者ID:cisco-system-traffic-generator,项目名称:trex-java-sdk,代码行数:26,代码来源:IPv6NeighborDiscoveryService.java
示例3: _getPacketBuilder4IPv4
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
private EthernetPacket.Builder _getPacketBuilder4IPv4(InetAddress remoteAddress, MacAddress localMacAddress, InetAddress
localIpAdress) {
ArpPacket.Builder arpBuilder = new ArpPacket.Builder();
arpBuilder
.hardwareType(ArpHardwareType.ETHERNET)
.protocolType(EtherType.IPV4)
.hardwareAddrLength((byte) MacAddress.SIZE_IN_BYTES)
.protocolAddrLength((byte) ByteArrays.INET4_ADDRESS_SIZE_IN_BYTES)
.srcHardwareAddr(localMacAddress)
.srcProtocolAddr(localIpAdress)
.dstHardwareAddr(MacAddress.ETHER_BROADCAST_ADDRESS)
.operation(ArpOperation.REQUEST)
.dstProtocolAddr(remoteAddress);
EthernetPacket.Builder etherBuilder = new EthernetPacket.Builder();
etherBuilder.dstAddr(MacAddress.ETHER_BROADCAST_ADDRESS)
.srcAddr(localMacAddress)
.type(EtherType.ARP)
.payloadBuilder(arpBuilder)
.paddingAtBuild(true);
return etherBuilder;
}
开发者ID:gaoxingliang,项目名称:mac-address-detector-java,代码行数:25,代码来源:MacAddressHelper.java
示例4: getRawData
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
@Override
public byte[] getRawData() {
byte[] rawData = new byte[length()];
rawData[0] = kind.value();
rawData[1] = length;
int offset = 2;
for (Sack sack : sacks) {
System.arraycopy(
ByteArrays.toByteArray(sack.leftEdge), 0,
rawData, offset, INT_SIZE_IN_BYTES
);
System.arraycopy(
ByteArrays.toByteArray(sack.rightEdge), 0,
rawData, offset + INT_SIZE_IN_BYTES, INT_SIZE_IN_BYTES
);
offset += INT_SIZE_IN_BYTES * 2;
}
return rawData;
}
开发者ID:Bpazy,项目名称:finalspeed,代码行数:22,代码来源:CustomTcpSackOption.java
示例5: generateVirtualMacAddress
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
public MacAddress generateVirtualMacAddress() {
int serialNumber;
synchronized (counterLock) {
if (counter > MAX_SERIAL_NUMBER) {
throw new AssertionError("too many MAC addresses.");
}
serialNumber = counter;
counter++;
}
// TODO IPv6
byte[] rawAddr = new byte[6];
System.arraycopy(
VIRTUAL_MACADDRESS_OUI.valueAsByteArray(), 0, rawAddr, 0, 3
);
System.arraycopy(
ByteArrays.toByteArray(serialNumber), 1, rawAddr, 3, 3
);
MacAddress macAddr = MacAddress.getByAddress(rawAddr);
return macAddr;
}
开发者ID:kaitoy,项目名称:sneo,代码行数:23,代码来源:MacAddressManager.java
示例6: isSameNetwork
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
public static boolean isSameNetwork(
Inet6Address addr1, Inet6Address addr2, int prefixLength
) {
if (prefixLength < 0 || prefixLength > 128) {
throw new IllegalArgumentException(
"Invalid prefix length: " + prefixLength
);
}
if (prefixLength <= 64) {
long addr1Bitmap = ByteArrays.getLong(addr1.getAddress(), 0);
long addr2Bitmap = ByteArrays.getLong(addr2.getAddress(), 0);
return isSamePrefix(addr1Bitmap, addr2Bitmap, prefixLength);
}
else {
long addr1Bitmap1h = ByteArrays.getLong(addr1.getAddress(), 0);
long addr2Bitmap1h = ByteArrays.getLong(addr2.getAddress(), 0);
if (addr1Bitmap1h != addr2Bitmap1h) {
return false;
}
long addr1Bitmap2h = ByteArrays.getLong(addr1.getAddress(), 16);
long addr2Bitmap2h = ByteArrays.getLong(addr2.getAddress(), 16);
return isSamePrefix(addr1Bitmap2h, addr2Bitmap2h, prefixLength - 64);
}
}
开发者ID:kaitoy,项目名称:sneo,代码行数:26,代码来源:IpV6Helper.java
示例7: buildArpPkt
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
private static EthernetPacket buildArpPkt(String srcMac, String srcIp, String dstIp) {
ArpPacket.Builder arpBuilder = new ArpPacket.Builder();
MacAddress srcMacAddress = MacAddress.getByName(srcMac);
try {
arpBuilder
.hardwareType(ArpHardwareType.ETHERNET)
.protocolType(EtherType.IPV4)
.hardwareAddrLength((byte) MacAddress.SIZE_IN_BYTES)
.protocolAddrLength((byte) ByteArrays.INET4_ADDRESS_SIZE_IN_BYTES)
.operation(ArpOperation.REQUEST)
.srcHardwareAddr(srcMacAddress)
.srcProtocolAddr(InetAddress.getByName(srcIp))
.dstHardwareAddr(MacAddress.getByName("00:00:00:00:00:00"))
.dstProtocolAddr(InetAddress.getByName(dstIp));
} catch (UnknownHostException e) {
throw new IllegalArgumentException(e);
}
EthernetPacket.Builder etherBuilder = new EthernetPacket.Builder();
etherBuilder.dstAddr(MacAddress.ETHER_BROADCAST_ADDRESS)
.srcAddr(srcMacAddress)
.type(EtherType.ARP)
.payloadBuilder(arpBuilder)
.paddingAtBuild(true);
return etherBuilder.build();
}
开发者ID:cisco-system-traffic-generator,项目名称:trex-java-sdk,代码行数:28,代码来源:TRexClient.java
示例8: buildArpPkt
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
private static EthernetPacket buildArpPkt() {
ArpPacket.Builder arpBuilder = new ArpPacket.Builder();
MacAddress srcMac = MacAddress.getByName("00:50:56:94:21:df");
try {
String strSrcIpAddress = "192.168.9.27";
String strDstIpAddress = "192.168.9.28";
arpBuilder
.hardwareType(ArpHardwareType.ETHERNET)
.protocolType(EtherType.IPV4)
.hardwareAddrLength((byte) MacAddress.SIZE_IN_BYTES)
.protocolAddrLength((byte) ByteArrays.INET4_ADDRESS_SIZE_IN_BYTES)
.operation(ArpOperation.REQUEST)
.srcHardwareAddr(srcMac)
.srcProtocolAddr(InetAddress.getByName(strSrcIpAddress))
.dstHardwareAddr(MacAddress.ETHER_BROADCAST_ADDRESS)
.dstProtocolAddr(InetAddress.getByName(strDstIpAddress));
} catch (UnknownHostException e) {
throw new IllegalArgumentException(e);
}
EthernetPacket.Builder etherBuilder = new EthernetPacket.Builder();
etherBuilder.dstAddr(MacAddress.ETHER_BROADCAST_ADDRESS)
.srcAddr(srcMac)
.type(EtherType.ARP)
.payloadBuilder(arpBuilder)
.paddingAtBuild(true);
return etherBuilder.build();
}
开发者ID:cisco-system-traffic-generator,项目名称:trex-java-sdk,代码行数:30,代码来源:TRexClientTest.java
示例9: extract
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
public static short extract(byte[] payload, byte[] header) {
if(payload.length < DEAUTH_CONTENT_LENGTH+1) {
return -1;
}
byte[] reasonBytes = {
payload[DEAUTH_CONTENT_LENGTH],
payload[DEAUTH_CONTENT_LENGTH +1]
};
return ByteArrays.getShort(reasonBytes, 0, ByteOrder.LITTLE_ENDIAN);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:13,代码来源:Dot11LeavingReason.java
示例10: compare
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
public int compare(RealNetworkInterfaceConfigurationDto o1, RealNetworkInterfaceConfigurationDto o2) {
byte[] o1Addr = ByteArrays.parseByteArray(o1.getMacAddress(), ":");
byte[] o2Addr = ByteArrays.parseByteArray(o2.getMacAddress(), ":");
for (int i = 0; i < o1Addr.length; i++) {
if (o1Addr[i] != o2Addr[i]) {
return (0xFF & o2Addr[i]) - (0xFF & o1Addr[i]);
}
}
return 0;
}
开发者ID:kaitoy,项目名称:sneo,代码行数:13,代码来源:RealNetworkInterfaceConfigurationGridAction.java
示例11: isSameNetwork
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
public static boolean isSameNetwork(
Inet4Address addr1, Inet4Address addr2, Inet4Address subnetmask
) {
int addr1Bitmap = ByteArrays.getInt(addr1.getAddress(), 0);
int addr2Bitmap = ByteArrays.getInt(addr2.getAddress(), 0);
int subnetmaskBitmap = ByteArrays.getInt(subnetmask.getAddress(), 0);
return (addr1Bitmap & subnetmaskBitmap) == (addr2Bitmap & subnetmaskBitmap);
}
开发者ID:kaitoy,项目名称:sneo,代码行数:9,代码来源:IpV4Helper.java
示例12: getNextHop
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
private Inet4Address getNextHop(Inet4Address dst) {
Collection<IpV4RoutingTableEntry> values = null;
synchronized (entries) {
IpV4RoutingTableEntry justMatchedEntry = entries.get(dst);
if (justMatchedEntry != null) {
return justMatchedEntry.gw;
}
values = entries.values();
}
int dstBitmap = ByteArrays.getInt(dst.getAddress(), 0);
IpV4RoutingTableEntry mostMatchedEntry = null;
for (IpV4RoutingTableEntry entry: values) {
if (
entry.dstBitmap
== (dstBitmap & entry.maskBitmap)
) {
if (mostMatchedEntry == null) {
mostMatchedEntry = entry;
}
else if (entry.prefixLength > mostMatchedEntry.prefixLength) {
mostMatchedEntry = entry;
}
else if (
entry.prefixLength == mostMatchedEntry.prefixLength
&& entry.metric < mostMatchedEntry.metric
) {
mostMatchedEntry = entry;
}
}
}
if (mostMatchedEntry == null) {
return null;
}
return mostMatchedEntry.gw;
}
开发者ID:kaitoy,项目名称:sneo,代码行数:41,代码来源:IpV4Helper.java
示例13: IpV4RoutingTableEntry
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
private IpV4RoutingTableEntry(
Inet4Address dst,
Inet4Address mask,
Inet4Address gw,
int metric
) {
this.dst = dst;
this.dstBitmap = ByteArrays.getInt(dst.getAddress(), 0);
this.mask = mask;
this.maskBitmap = ByteArrays.getInt(mask.getAddress(), 0);
this.prefixLength = getPrefixLengthFrom(mask);
this.gw = gw;
this.metric = metric;
}
开发者ID:kaitoy,项目名称:sneo,代码行数:15,代码来源:IpV4Helper.java
示例14: reply
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
public static void reply(Packet packet, Node node, NetworkInterface nif) {
ArpPacket arpPacket = packet.get(ArpPacket.class);
if (arpPacket == null) {
throw new IllegalArgumentException(packet.toString());
}
InetAddress srcIpAddr
= arpPacket.getHeader().getSrcProtocolAddr();
MacAddress srcMacAddr
= arpPacket.getHeader().getSrcHardwareAddr();
InetAddress dstIpAddr
= arpPacket.getHeader().getDstProtocolAddr();
ArpPacket.Builder arpBuilder = new ArpPacket.Builder();
arpBuilder.hardwareType(ArpHardwareType.ETHERNET)
.protocolType(EtherType.IPV4)
.hardwareAddrLength((byte)MacAddress.SIZE_IN_BYTES)
.protocolAddrLength((byte)ByteArrays.INET4_ADDRESS_SIZE_IN_BYTES)
.operation(ArpOperation.REPLY)
.srcHardwareAddr(nif.getMacAddress())
.srcProtocolAddr(dstIpAddr)
.dstHardwareAddr(srcMacAddr)
.dstProtocolAddr(srcIpAddr);
try {
node.sendL3Packet(arpBuilder.build(), nif);
} catch (SendPacketException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
}
}
开发者ID:kaitoy,项目名称:sneo,代码行数:31,代码来源:ArpHelper.java
示例15: sendRequest
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
public void sendRequest(
InetAddress targetIpAddr,
Node node,
NetworkInterface nif
) {
InetAddress srcIpAddr = null;
for (NifIpAddress addr: nif.getIpAddresses()) {
if (addr.getIpAddr() instanceof Inet4Address) {
srcIpAddr = addr.getIpAddr();
}
}
if (srcIpAddr == null) {
throw new IllegalArgumentException("No IPv4 address is found in " + nif);
}
MacAddress srcMacAddr = nif.getMacAddress();
ArpPacket.Builder arpBuilder = new ArpPacket.Builder();
arpBuilder.hardwareType(ArpHardwareType.ETHERNET)
.protocolType(EtherType.IPV4)
.hardwareAddrLength((byte)MacAddress.SIZE_IN_BYTES)
.protocolAddrLength((byte)ByteArrays.INET4_ADDRESS_SIZE_IN_BYTES)
.operation(ArpOperation.REQUEST)
.srcHardwareAddr(srcMacAddr)
.srcProtocolAddr(srcIpAddr)
.dstHardwareAddr(MacAddress.ETHER_BROADCAST_ADDRESS)
.dstProtocolAddr(targetIpAddr);
try {
node.sendL3Packet(arpBuilder.build(), nif);
} catch (SendPacketException e) {
// TODO 自動生成された catch ブロック
e.printStackTrace();
}
}
开发者ID:kaitoy,项目名称:sneo,代码行数:34,代码来源:ArpHelper.java
示例16: sendFromServer
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
/**
* ������ ������ ����(����ڰ� �Է��� ����)
*
* @param packet
* - ��Ŷ ����Ʈ�迭
* @return - �Ľ̵� ����
*/
public String sendFromServer(byte[] packet) {
String message = null;
String c_Packet = ByteArrays.toHexString(packet, " ").replace(" ", "").replaceAll("00", "");
try {
// ��Ŷ�� UTF-8�� ��ȯ�Ͽ� ���ڿ��� ���Ϲ´�.
String msg = new String(packet, "UTF-8");
// �ʿ���� �κ� �Ľ�
String parseMsg = msg.substring(msg.lastIndexOf("\\"), msg.length()).replace("\\", "").trim();
// ����1: �ѱ�,����,����,Ư���� ���ԵǾ����� üũ�Ѵ�.
Pattern p = Pattern.compile("(^[��-��|��-��|��-�R|0-9|a-z|A-Z|\\s|[email protected]#$%^&*?()+-.]*$)");
Matcher m = p.matcher(parseMsg);
// ����1 �˻�
if (m.find()) {
// ���� ��Ī�� ���� �ߴٸ�
// ����2: ��Ī�� ������ ���� ���ڿ��� �ѱ��� �ݵ�� ���ԵǴ��� üũ
Pattern p1 = Pattern.compile(".*[��-��|��-��|��-�R]");
Matcher m1 = p1.matcher(m.group());
if (m1.find()) {
// �ѱ��� �ݵ�� ���Եȴٸ�
// ���� ���ڴ� ����1 ���ڿ��� �����Ѵ�.
// ������ ������ ��Ƽ�� �δ� ��Ŷ�� �����ϹǷ� ������ ���Ѵ�.
if (c_Packet.indexOf("035c") > -1) {
// FC
message = "[�δ�]<��>: " + convertInlineMsg(m.group()) + "\n";
} else {
// ��Ƽ
message = "[��Ƽ]<��>: " + convertInlineMsg(m.group()) + "\n";
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return message;
}
开发者ID:kimyearho,项目名称:FF14_ScraperChat,代码行数:55,代码来源:PacketSniffing.java
示例17: MacAddressHelper
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
private MacAddressHelper() {
try {
_localPcapNetworkInterfaces = Pcaps.findAllDevs();
_executor = Executors.newScheduledThreadPool(_threadCount);
_IPv6_BROADCAST_IPADDRESS_PREFIX = Inet6Address.getByName("FF02::1:FF00:0000").getAddress();
_IPv6_BROADCAST_MACADDRESS_PREFIX = MacAddress.getByName("33:33:ff:00:00:00").getAddress();
_localAddresse2MacAddress = new HashMap<>();
Enumeration<NetworkInterface> localNetworkInterfaces = NetworkInterface.getNetworkInterfaces();
while (localNetworkInterfaces.hasMoreElements()) {
NetworkInterface nwInterface = localNetworkInterfaces.nextElement();
byte[] mac = nwInterface.getHardwareAddress();
Enumeration<InetAddress> addresses = nwInterface.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress currentIp = addresses.nextElement();
if (mac == null) {
System.out.println("Can't find mac address for local ip=" + currentIp);
_localAddresse2MacAddress.put(currentIp, null);
}
else {
// although jdk said, the returned value is a mac address, but actually this may fail on some local mac address
// the length is NOT 6 bytes
if (mac.length != MacAddress.SIZE_IN_BYTES) {
_localAddresse2MacAddress.put(currentIp, null);
System.out.println(String.format("Found invalid mac address ip=%s,mac=%s", currentIp, ByteArrays.toHexString(mac,
":")));
}
else {
_localAddresse2MacAddress.put(currentIp, MacAddress.getByAddress(mac));
}
}
}
}
System.out.println(String.format("Mac Address helper init done localips=%d, threadPool=%d, readTimeout(ms)=%d, waitResponse(ms)" +
"=%d, waitReceiveTaskStart(ms)=%d",
_localAddresse2MacAddress.size(), _threadCount,
_readTimeoutInMillSeconds, _waitResponseTimeoutInMillSeconds, _waitReceiveTaskStartRunningInSeconds));
_initted = true;
}
catch (Throwable e) {
_initError = e;
}
}
开发者ID:gaoxingliang,项目名称:mac-address-detector-java,代码行数:46,代码来源:MacAddressHelper.java
示例18: newPacket
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
public static Dot11ManagementFrame newPacket(byte[] rawData, int offset, int length) throws IllegalRawDataException {
ByteArrays.validateBounds(rawData, offset, length);
Dot11ManagementFrame.Dot11ManagementFrameHeader h = new Dot11ManagementFrame.Dot11ManagementFrameHeader(rawData, offset, length);
return new Dot11ManagementFrame(rawData, offset, length, h);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:6,代码来源:Dot11ManagementFrame.java
示例19: handle
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
@Override
public void handle(byte[] payload, byte[] header, Dot11MetaInformation meta) throws IllegalRawDataException {
tick();
Dot11ManagementFrame associationResponse = Dot11ManagementFrame.newPacket(payload, 0, payload.length);
// Check bounds for response code field.
try {
ByteArrays.validateBounds(payload, 0, STATUS_CODE_POSITION+STATUS_CODE_LENGTH-1);
} catch(Exception e) {
malformed(meta);
LOG.trace("Payload out of bounds. (1) Ignoring.");
return;
}
// Parse the response code. 0 means success any other value means failure.
short responseCode = ByteArrays.getShort(new byte[]{payload[26], payload[27]}, 0, ByteOrder.LITTLE_ENDIAN);
if(responseCode < 0) {
LOG.trace("Invalid response code <{}>.", responseCode);
return;
}
String response = "refused";
if (responseCode == 0) {
response = "success";
}
String destination = "";
if(associationResponse.getHeader().getAddress1() != null) {
destination = associationResponse.getHeader().getAddress1().toString();
}
String transmitter = "";
if(associationResponse.getHeader().getAddress2() != null) {
transmitter = associationResponse.getHeader().getAddress2().toString();
}
String message = transmitter + " answered association request from " + destination
+ ". Response: " + response.toUpperCase() + " (" + responseCode + ")";
nzyme.notify(
new Notification(message, meta.getChannel())
.addField(FieldNames.TRANSMITTER, transmitter)
.addField(FieldNames.DESTINATION, destination)
.addField(FieldNames.RESPONSE_CODE, responseCode)
.addField(FieldNames.RESPONSE_STRING, response)
.addField(FieldNames.SUBTYPE, "assoc-resp"),
meta
);
LOG.debug(message);
}
开发者ID:lennartkoopmann,项目名称:nzyme,代码行数:54,代码来源:AssociationResponseFrameHandler.java
示例20: isBroadcastAddr
import org.pcap4j.util.ByteArrays; //导入依赖的package包/类
public static boolean isBroadcastAddr(Inet4Address addr, Inet4Address subnetmask) {
int subnetmaskBitmap = ByteArrays.getInt(subnetmask.getAddress(), 0);
int addrBitmap = ByteArrays.getInt(addr.getAddress(), 0);
return ~((addrBitmap & ~subnetmaskBitmap) | subnetmaskBitmap) == 0;
}
开发者ID:kaitoy,项目名称:sneo,代码行数:6,代码来源:IpV4Helper.java
注:本文中的org.pcap4j.util.ByteArrays类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论