public class Ethernet extends BasePacket
Modifier and Type | Field and Description |
---|---|
static short |
DATALAYER_ADDRESS_LENGTH |
protected MACAddress |
destinationMACAddress |
protected short |
etherType |
static Map<Short,Class<? extends IPacket>> |
etherTypeClassMap |
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(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.
|
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[] destinationMACAddress)
Sets the destination MAC address.
|
Ethernet |
setDestinationMACAddress(String destinationMACAddress)
Sets the destination MAC address.
|
Ethernet |
setEtherType(short etherType)
Sets the Ethernet type.
|
Ethernet |
setPad(boolean pad)
Pad this packet to 60 bytes minimum, filling with zeros?
|
Ethernet |
setPriorityCode(byte priorityCode)
Sets the priority code.
|
Ethernet |
setSourceMACAddress(byte[] sourceMACAddress)
Sets the source MAC address.
|
Ethernet |
setSourceMACAddress(String sourceMACAddress)
Sets the source MAC address.
|
Ethernet |
setVlanID(short vlanID)
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_LLDP
public static final short TYPE_BSN
public static final short VLAN_UNTAGGED
public static final short DATALAYER_ADDRESS_LENGTH
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(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(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(String macAddress)
macAddress
- public static byte[] toMACAddress(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(Object obj)
equals
in class BasePacket
Copyright © 2014. All rights reserved.