/** * @return true if the MAC address represented by this object is a globally unique address; * otherwise false. */ public boolean isGloballyUnique() { return (getAddress()[0] & 2) == 0; } }
/** * @return true if the MAC address represented by this object is a unicast address; otherwise * false. */ public boolean isUnicast() { return (getAddress()[0] & 1) == 0; }
/** * @param value value * @param bo bo * @return byte array */ public static byte[] toByteArray(MacAddress value, ByteOrder bo) { if (bo.equals(LITTLE_ENDIAN)) { return reverse(value.getAddress()); } else { return value.getAddress(); } }
/** * @param macAddr macAddr * @return a string representation of a MAC address for BPF. */ public static String toBpfString(MacAddress macAddr) { if (macAddr == null) { StringBuilder sb = new StringBuilder(); sb.append("macAddr: ").append(macAddr); throw new NullPointerException(sb.toString()); } StringBuilder builder = new StringBuilder(); byte[] address = macAddr.getAddress(); for (int i = 0; i < address.length; i++) { builder.append(String.format("%02x", address[i])); builder.append(":"); } builder.deleteCharAt(builder.length() - 1); return builder.toString(); } }
@Override protected List<byte[]> getRawFields() { List<byte[]> rawFields = new ArrayList<byte[]>(); rawFields.add(frameControl.getRawData()); rawFields.add(ByteArrays.toByteArray(duration, ByteOrder.LITTLE_ENDIAN)); rawFields.add(address1.getAddress()); rawFields.add(address2.getAddress()); rawFields.add(address3.getAddress()); rawFields.add(sequenceControl.getRawData()); if (htControl != null) { rawFields.add(htControl.getRawData()); } return rawFields; }
/** @return OUI */ public Oui getOui() { return Oui.getInstance(ByteArrays.getInt(getAddress(), 0) >>> 8); }
/** * @return true if the MAC address represented by this object is a unicast address; otherwise * false. */ public boolean isUnicast() { return (getAddress()[0] & 1) == 0; }
/** * @return true if the MAC address represented by this object is a globally unique address; * otherwise false. */ public boolean isGloballyUnique() { return (getAddress()[0] & 2) == 0; } }
/** * @param value value * @param bo bo * @return byte array */ public static byte[] toByteArray(MacAddress value, ByteOrder bo) { if (bo.equals(LITTLE_ENDIAN)) { return reverse(value.getAddress()); } else { return value.getAddress(); } }
@Override protected List<byte[]> getRawFields() { List<byte[]> rawFields = new ArrayList<byte[]>(); rawFields.add(frameControl.getRawData()); rawFields.add(ByteArrays.toByteArray(duration, ByteOrder.LITTLE_ENDIAN)); rawFields.add(address1.getAddress()); rawFields.add(address2.getAddress()); rawFields.add(address3.getAddress()); rawFields.add(sequenceControl.getRawData()); if (htControl != null) { rawFields.add(htControl.getRawData()); } return rawFields; }
/** * @param macAddr macAddr * @return a string representation of a MAC address for BPF. */ public static String toBpfString(MacAddress macAddr) { if (macAddr == null) { StringBuilder sb = new StringBuilder(); sb.append("macAddr: ").append(macAddr); throw new NullPointerException(sb.toString()); } StringBuilder builder = new StringBuilder(); byte[] address = macAddr.getAddress(); for (int i = 0; i < address.length; i++) { builder.append(String.format("%02x", address[i])); builder.append(":"); } builder.deleteCharAt(builder.length() - 1); return builder.toString(); } }
public static byte[] convertToEui64(MacAddress macAddr) { byte[] eui64 = new byte[8]; byte[] oui = macAddr.getOui().valueAsByteArray(); oui[0] = (byte)(oui[0] ^ 0x02); System.arraycopy(oui, 0, eui64, 0, 3); eui64[3] = (byte)0xFF; eui64[4] = (byte)0xFE; System.arraycopy(macAddr.getAddress(), 3, eui64, 5, 3); return eui64; }
/** @return OUI */ public Oui getOui() { return Oui.getInstance(ByteArrays.getInt(getAddress(), 0) >>> 8); }
IpV6NeighborDiscoverySourceLinkLayerAddressOption.Builder optBuilder = new IpV6NeighborDiscoverySourceLinkLayerAddressOption.Builder(); optBuilder.linkLayerAddress(nif.getMacAddress().getAddress()) .correctLengthAtBuild(true); opts.add(optBuilder.build());
IpV6NeighborDiscoveryTargetLinkLayerAddressOption.Builder optBuilder = new IpV6NeighborDiscoveryTargetLinkLayerAddressOption.Builder(); optBuilder.linkLayerAddress(nif.getMacAddress().getAddress()) .correctLengthAtBuild(true); opts.add(optBuilder.build());