Ethernet extends BasePacket { public static long toLong(byte[] macAddress) { return MacAddress.of(macAddress).getLong(); } Ethernet(); MacAddress getDestinationMACAddress(); Ethernet setDestinationMACAddress(byte[] destinationMACAddress); Ethernet setDestinationMACAddress(MacAddress destinationMACAddress); Ethernet setDestinationMACAddress(String destinationMACAddress); MacAddress getSourceMACAddress(); Ethernet setSourceMACAddress(byte[] sourceMACAddress); Ethernet setSourceMACAddress(MacAddress sourceMACAddress); Ethernet setSourceMACAddress(String sourceMACAddress); byte getPriorityCode(); Ethernet setPriorityCode(byte priorityCode); short getVlanID(); Ethernet setVlanID(short vlanID); EthType getEtherType(); Ethernet setEtherType(EthType etherType); boolean isBroadcast(); boolean isMulticast(); boolean isPad(); Ethernet setPad(boolean pad); byte[] serialize(); @Override IPacket deserialize(byte[] data, int offset, int length); static boolean isMACAddress(String macAddress); static byte[] toMACAddress(String macAddress); static long toLong(byte[] macAddress); static byte[] toByteArray(long macAddress); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static final short TYPE_ARP; static final short TYPE_RARP; static final short TYPE_IPv4; static final short TYPE_LLDP; static final short TYPE_BSN; static final short VLAN_UNTAGGED; static final short DATALAYER_ADDRESS_LENGTH; static Map<Short, Class<? extends IPacket>> etherTypeClassMap; }
@Test public void testToLong() { assertEquals( 281474976710655L, Ethernet.toLong(new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff })); assertEquals( 1103823438081L, Ethernet.toLong(new byte[] { (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01 })); assertEquals( 141289400074368L, Ethernet.toLong(new byte[] { (byte) 0x80, (byte) 0x80, (byte) 0x80, (byte) 0x80, (byte) 0x80, (byte) 0x80 })); }