/** * Sets the source MAC address. * * @param sourceMac the source MAC to set * @return the Ethernet frame */ public Ethernet setSourceMACAddress(final byte[] sourceMac) { this.sourceMACAddress = MacAddress.valueOf(sourceMac); return this; }
/** * Sets the destination MAC address. * * @param destMac the destination MAC to set * @return the Ethernet frame */ public Ethernet setDestinationMACAddress(final String destMac) { this.destinationMACAddress = MacAddress.valueOf(destMac); return this; }
/** * Sets the destination MAC address. * * @param destMac the destination MAC to set * @return the Ethernet frame */ public Ethernet setDestinationMACAddress(final byte[] destMac) { this.destinationMACAddress = MacAddress.valueOf(destMac); return this; }
/** * Sets the source MAC address. * * @param sourceMac the source MAC to set * @return the Ethernet frame */ public Ethernet setSourceMACAddress(final String sourceMac) { this.sourceMACAddress = MacAddress.valueOf(sourceMac); return this; }
/** * Gets of the virtual gateway MAC address. * * @return virtual gateway MAC address */ public MacAddress virtualGatewayMacAddress() { return MacAddress.valueOf( object.get(VIRTUALGATEWAYMACADDRESS).asText()); } }
@Override public LispMacAddress readFrom(ByteBuf byteBuf) throws LispParseError { byte[] macByte = new byte[SIZE_OF_MAC_ADDRESS]; byteBuf.readBytes(macByte); MacAddress macAddress = MacAddress.valueOf(macByte); return new LispMacAddress(macAddress); } }
/** * Accepts a MAC address of the form 00:aa:11:bb:22:cc, case does not * matter, and returns a corresponding byte[]. * * @param macAddress * The MAC address to convert into a byte array * @return The macAddress as a byte array */ public static byte[] toMACAddress(final String macAddress) { return MacAddress.valueOf(macAddress).toBytes(); }
/** * Accepts a MAC address and returns the corresponding long, where the MAC * bytes are set on the lower order bytes of the long. * * @param macAddress MAC address as a byte array * @return a long containing the mac address bytes */ public static long toLong(final byte[] macAddress) { return MacAddress.valueOf(macAddress).toLong(); }
/** * Converts a long MAC address to a byte array. * * @param macAddress MAC address set on the lower order bytes of the long * @return the bytes of the mac address */ public static byte[] toByteArray(final long macAddress) { return MacAddress.valueOf(macAddress).toBytes(); }
@Override public MacAddress read(Kryo kryo, Input input, Class<MacAddress> type) { return MacAddress.valueOf(input.readBytes(MacAddress.MAC_ADDRESS_LENGTH)); }
/** * Convert byte array to MacAddress. * * @param length of MacAddress * @param cb channelBuffer * @return macAddress */ public static MacAddress toMacAddress(int length, ChannelBuffer cb) { byte[] address = new byte[length]; cb.readBytes(address, 0, length); MacAddress macAddress = MacAddress.valueOf(address); return macAddress; } /**
@Override public String toString() { return toStringHelper(getClass()) .add("hardwareType", Short.toString(hardwareType)) .add("protocolType", Short.toString(protocolType)) .add("hardwareAddressLength", Byte.toString(hardwareAddressLength)) .add("protocolAddressLength", Byte.toString(protocolAddressLength)) .add("opCode", Short.toString(opCode)) .add("senderHardwareAddress", MacAddress.valueOf(senderHardwareAddress)) .add("senderProtocolAddress", Ip4Address.valueOf(senderProtocolAddress)) .add("targetHardwareAddress", MacAddress.valueOf(targetHardwareAddress)) .add("targetProtocolAddress", Ip4Address.valueOf(targetProtocolAddress)) .toString(); } }
/** * Returns interface MAC by index. * * @param interfaceIndex interface index * @return interface IP by index */ private MacAddress getInterfaceMac(int interfaceIndex) { MacAddress macAddress = null; try { NetworkInterface networkInterface = NetworkInterface.getByIndex(interfaceIndex); macAddress = MacAddress.valueOf(networkInterface.getHardwareAddress()); } catch (Exception e) { log.debug("Error while getting Interface IP by index"); return macAddress; } return macAddress; }
@Override public Criterion decodeCriterion(ObjectNode json) { MacAddress mac = MacAddress.valueOf(nullIsIllegal(json.get(CriterionCodec.MAC), CriterionCodec.MAC + MISSING_MEMBER_MESSAGE).asText()); return Criteria.matchIPv6NDTargetLinkLayerAddress(mac); } }
@Override public Criterion decodeCriterion(ObjectNode json) { MacAddress mac = MacAddress.valueOf(nullIsIllegal(json.get(CriterionCodec.MAC), CriterionCodec.MAC + MISSING_MEMBER_MESSAGE).asText()); return Criteria.matchIPv6NDSourceLinkLayerAddress(mac); } }
@Override public Criterion decodeCriterion(ObjectNode json) { MacAddress mac = MacAddress.valueOf(nullIsIllegal(json.get(CriterionCodec.MAC), CriterionCodec.MAC + MISSING_MEMBER_MESSAGE).asText()); return Criteria.matchEthDst(mac); } }
@Override public Criterion decodeCriterion(ObjectNode json) { MacAddress mac = MacAddress.valueOf(nullIsIllegal(json.get(CriterionCodec.MAC), CriterionCodec.MAC + MISSING_MEMBER_MESSAGE).asText()); return Criteria.matchEthSrc(mac); } }
/** * Gets the source MAC address from the ethernet header. * * @param ethHeader ethernet header bytes * @return MAC address of the source router */ private MacAddress getSourceMac(ChannelBuffer ethHeader) { //Source MAC is at position 6 to 11 (6 bytes) ethHeader.skipBytes(IsisUtil.SIX_BYTES); MacAddress sourceMac = MacAddress.valueOf(ethHeader.readBytes(IsisUtil.SIX_BYTES).array()); return sourceMac; } }
/** * Gets the source MAC address from the ethernet header. * * @param ethHeader ethernet header bytes * @return MAC address of the source router */ private MacAddress getSourceMac(ChannelBuffer ethHeader) { //Source MAC is at position 6 to 11 (6 bytes) ethHeader.skipBytes(IsisUtil.SIX_BYTES); MacAddress sourceMac = MacAddress.valueOf(ethHeader.readBytes(IsisUtil.SIX_BYTES).array()); return sourceMac; } }
public void setChassisId(final ChassisId chassisId) { MacAddress chassisMac = MacAddress.valueOf(chassisId.value()); byte[] chassis = ArrayUtils.addAll(new byte[] {CHASSIS_TLV_SUBTYPE}, chassisMac.toBytes()); LLDPTLV chassisTLV = new LLDPTLV(); chassisTLV.setLength(CHASSIS_TLV_SIZE); chassisTLV.setType(CHASSIS_TLV_TYPE); chassisTLV.setValue(chassis); this.setChassisId(chassisTLV); }