public class Ethernet extends BasePacket
Modifier and Type | Field and Description |
---|---|
static short |
DATALAYER_ADDRESS_LENGTH |
protected MACAddress |
destinationMACAddress |
protected short |
etherType |
static java.util.Map<java.lang.Short,java.lang.Class<? extends IPacket>> |
etherTypeClassMap |
private static java.lang.String |
HEXES |
protected boolean |
pad |
protected byte |
priorityCode |
protected MACAddress |
sourceMACAddress |
static short |
TYPE_ARP |
static short |
TYPE_BSN |
static short |
TYPE_IPv4 |
static short |
TYPE_LLDP |
static short |
TYPE_RARP |
static short |
VLAN_UNTAGGED |
protected short |
vlanID |
parent, payload
Constructor and Description |
---|
Ethernet()
By default, set Ethernet to untagged
|
Modifier and Type | Method and Description |
---|---|
IPacket |
deserialize(byte[] data,
int offset,
int length)
Deserializes this packet layer and all possible payloads
|
boolean |
equals(java.lang.Object obj) |
MACAddress |
getDestinationMAC() |
byte[] |
getDestinationMACAddress() |
short |
getEtherType() |
byte |
getPriorityCode() |
MACAddress |
getSourceMAC() |
byte[] |
getSourceMACAddress() |
short |
getVlanID() |
int |
hashCode() |
boolean |
isBroadcast() |
static boolean |
isMACAddress(java.lang.String macAddress)
Checks to see if a string is a valid MAC address.
|
boolean |
isMulticast() |
boolean |
isPad()
Pad this packet to 60 bytes minimum, filling with zeros?
|
byte[] |
serialize()
Sets all payloads parent packet if applicable, then serializes this
packet and all payloads
|
Ethernet |
setDestinationMACAddress(byte[] destinationMACAddress) |
Ethernet |
setDestinationMACAddress(java.lang.String destinationMACAddress) |
Ethernet |
setEtherType(short etherType) |
Ethernet |
setPad(boolean pad)
Pad this packet to 60 bytes minimum, filling with zeros?
|
Ethernet |
setPriorityCode(byte priorityCode) |
Ethernet |
setSourceMACAddress(byte[] sourceMACAddress) |
Ethernet |
setSourceMACAddress(java.lang.String sourceMACAddress) |
Ethernet |
setVlanID(short vlanID) |
static byte[] |
toByteArray(long macAddress)
Convert a long MAC address to a byte array
|
static long |
toLong(byte[] macAddress)
Accepts a MAC address and returns the corresponding long, where the
MAC bytes are set on the lower order bytes of the long.
|
static byte[] |
toMACAddress(java.lang.String macAddress)
Accepts a MAC address of the form 00:aa:11:bb:22:cc, case does not
matter, and returns a corresponding byte[].
|
java.lang.String |
toString() |
clone, getParent, getPayload, resetChecksum, setParent, setPayload
private static java.lang.String HEXES
public static final short TYPE_ARP
public static final short TYPE_RARP
public static final short TYPE_IPv4
public static final short TYPE_LLDP
public static final short TYPE_BSN
public static final short VLAN_UNTAGGED
public static final short DATALAYER_ADDRESS_LENGTH
public static java.util.Map<java.lang.Short,java.lang.Class<? extends IPacket>> etherTypeClassMap
protected MACAddress destinationMACAddress
protected MACAddress sourceMACAddress
protected byte priorityCode
protected short vlanID
protected short etherType
protected boolean pad
public byte[] getDestinationMACAddress()
public MACAddress getDestinationMAC()
public Ethernet setDestinationMACAddress(byte[] destinationMACAddress)
destinationMACAddress
- the destination MAC to setpublic Ethernet setDestinationMACAddress(java.lang.String destinationMACAddress)
destinationMACAddress
- the destination MAC to setpublic byte[] getSourceMACAddress()
public MACAddress getSourceMAC()
public Ethernet setSourceMACAddress(byte[] sourceMACAddress)
sourceMACAddress
- the source MAC to setpublic Ethernet setSourceMACAddress(java.lang.String sourceMACAddress)
sourceMACAddress
- the source MAC to setpublic byte getPriorityCode()
public Ethernet setPriorityCode(byte priorityCode)
priorityCode
- the priorityCode to setpublic short getVlanID()
public Ethernet setVlanID(short vlanID)
vlanID
- the vlanID to setpublic short getEtherType()
public Ethernet setEtherType(short etherType)
etherType
- the etherType to setpublic boolean isBroadcast()
public boolean isMulticast()
public boolean isPad()
public Ethernet setPad(boolean pad)
pad
- the pad to setpublic byte[] serialize()
IPacket
public IPacket deserialize(byte[] data, int offset, int length)
IPacket
offset
- offset to start deserializing fromlength
- length of the data to deserializepublic static boolean isMACAddress(java.lang.String macAddress)
macAddress
- public static byte[] toMACAddress(java.lang.String macAddress)
macAddress
- The MAC address to convert into a bye arraypublic static long toLong(byte[] macAddress)
macAddress
- public static byte[] toByteArray(long macAddress)
macAddress
- public int hashCode()
hashCode
in class BasePacket
public boolean equals(java.lang.Object obj)
equals
in class BasePacket
public java.lang.String toString()
toString
in class java.lang.Object