public class Ethernet extends BasePacket
Modifier and Type | Field and Description |
---|---|
static short |
DATALAYER_ADDRESS_LENGTH |
protected MacAddress |
destinationMACAddress |
static short |
ETHERNET_HEADER_LENGTH |
protected short |
etherType |
static short |
MPLS_MULTICAST |
static short |
MPLS_UNICAST |
protected boolean |
pad |
protected byte |
priorityCode |
protected byte |
qInQPriorityCode |
protected short |
qinqTPID |
protected short |
qinqVID |
protected MacAddress |
sourceMACAddress |
static short |
TYPE_ARP |
static short |
TYPE_BSN |
static short |
TYPE_IPV4 |
static short |
TYPE_IPV6 |
static short |
TYPE_LLDP |
static short |
TYPE_QINQ |
static short |
TYPE_RARP |
static short |
TYPE_VLAN |
static short |
VLAN_HEADER_LENGTH |
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 |
---|---|
static String |
bytesToHex(byte[] in) |
static Deserializer<Ethernet> |
deserializer()
Deserializer function for Ethernet packets.
|
Ethernet |
duplicate()
Make an exact copy of the ethernet packet.
|
boolean |
equals(Object obj) |
MacAddress |
getDestinationMAC()
Gets the destination MAC address.
|
byte[] |
getDestinationMACAddress()
Gets the destination MAC address.
|
short |
getEtherType()
Gets the Ethernet type.
|
byte |
getPriorityCode()
Gets the priority code.
|
byte |
getQinQPriorityCode()
Gets the QinQ priority code.
|
short |
getQinQTPID()
Gets the QinQ TPID.
|
short |
getQinQVID()
Gets the QinQ VLAN ID.
|
MacAddress |
getSourceMAC()
Gets the source MAC address.
|
byte[] |
getSourceMACAddress()
Gets the source MAC address.
|
short |
getVlanID()
Gets the VLAN ID.
|
int |
hashCode() |
boolean |
isBroadcast() |
static boolean |
isMACAddress(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[] destMac)
Sets the destination MAC address.
|
Ethernet |
setDestinationMACAddress(MacAddress destMac)
Sets the destination MAC address.
|
Ethernet |
setDestinationMACAddress(String destMac)
Sets the destination MAC address.
|
Ethernet |
setEtherType(short ethType)
Sets the Ethernet type.
|
Ethernet |
setPad(boolean pd)
Pad this packet to 60 bytes minimum, filling with zeros?
|
Ethernet |
setPriorityCode(byte priority)
Sets the priority code.
|
Ethernet |
setQinQPriorityCode(byte priority)
Sets the QinQ priority code.
|
Ethernet |
setQinQTPID(short tpId)
Sets the QinQ TPID.
|
Ethernet |
setQinQVID(short vlan)
Sets the QinQ VLAN ID.
|
Ethernet |
setSourceMACAddress(byte[] sourceMac)
Sets the source MAC address.
|
Ethernet |
setSourceMACAddress(MacAddress sourceMac)
Sets the source MAC address.
|
Ethernet |
setSourceMACAddress(String sourceMac)
Sets the source MAC address.
|
Ethernet |
setVlanID(short vlan)
Sets the VLAN ID.
|
static byte[] |
toByteArray(long macAddress)
Converts 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(String macAddress)
Accepts a MAC address of the form 00:aa:11:bb:22:cc, case does not
matter, and returns a corresponding byte[].
|
String |
toString() |
clone, getParent, getPayload, resetChecksum, setParent, setPayload
public static final short TYPE_ARP
public static final short TYPE_RARP
public static final short TYPE_IPV4
public static final short TYPE_IPV6
public static final short TYPE_LLDP
public static final short TYPE_VLAN
public static final short TYPE_QINQ
public static final short TYPE_BSN
public static final short MPLS_UNICAST
public static final short MPLS_MULTICAST
public static final short VLAN_UNTAGGED
public static final short ETHERNET_HEADER_LENGTH
public static final short VLAN_HEADER_LENGTH
public static final short DATALAYER_ADDRESS_LENGTH
protected MacAddress destinationMACAddress
protected MacAddress sourceMACAddress
protected byte priorityCode
protected byte qInQPriorityCode
protected short vlanID
protected short qinqVID
protected short qinqTPID
protected short etherType
protected boolean pad
public byte[] getDestinationMACAddress()
public MacAddress getDestinationMAC()
public Ethernet setDestinationMACAddress(MacAddress destMac)
destMac
- the destination MAC to setpublic Ethernet setDestinationMACAddress(byte[] destMac)
destMac
- the destination MAC to setpublic Ethernet setDestinationMACAddress(String destMac)
destMac
- the destination MAC to setpublic byte[] getSourceMACAddress()
public MacAddress getSourceMAC()
public Ethernet setSourceMACAddress(MacAddress sourceMac)
sourceMac
- the source MAC to setpublic Ethernet setSourceMACAddress(byte[] sourceMac)
sourceMac
- the source MAC to setpublic Ethernet setSourceMACAddress(String sourceMac)
sourceMac
- the source MAC to setpublic byte getPriorityCode()
public Ethernet setPriorityCode(byte priority)
priority
- the priorityCode to setpublic byte getQinQPriorityCode()
public Ethernet setQinQPriorityCode(byte priority)
priority
- the priorityCode to setpublic short getVlanID()
public Ethernet setVlanID(short vlan)
vlan
- the vlanID to setpublic short getQinQVID()
public Ethernet setQinQVID(short vlan)
vlan
- the vlanID to setpublic short getQinQTPID()
public Ethernet setQinQTPID(short tpId)
tpId
- the TPID to setpublic short getEtherType()
public Ethernet setEtherType(short ethType)
ethType
- the etherType to setpublic boolean isBroadcast()
public boolean isMulticast()
public boolean isPad()
public Ethernet setPad(boolean pd)
pd
- the pad to setpublic byte[] serialize()
IPacket
public static boolean isMACAddress(String macAddress)
macAddress
- string to test if it is a valid MACpublic static byte[] toMACAddress(String macAddress)
macAddress
- The MAC address to convert into a byte arraypublic static long toLong(byte[] macAddress)
macAddress
- MAC address as a byte arraypublic static byte[] toByteArray(long macAddress)
macAddress
- MAC address set on the lower order bytes of the longpublic int hashCode()
hashCode
in class BasePacket
public boolean equals(Object obj)
equals
in class BasePacket
public static String bytesToHex(byte[] in)
public static Deserializer<Ethernet> deserializer()
public Ethernet duplicate()