|
SourceForge Jpcap | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.jpcap.net.Packet
net.sourceforge.jpcap.net.EthernetPacket
net.sourceforge.jpcap.net.ARPPacket
public class ARPPacket
An ARP protocol packet.
Extends EthernetPacket, adding ARP header information and an ARP data payload.
Now handles both ARP and RARP.
Field Summary |
---|
Fields inherited from class net.sourceforge.jpcap.net.EthernetPacket |
---|
_byteBuffer, _bytes, _ethOffset, _timeval |
Fields inherited from interface net.sourceforge.jpcap.net.ARPFields |
---|
ARP_ADDR_SIZE_LEN, ARP_ADDR_TYPE_LEN, ARP_ETH_ADDR_CODE, ARP_HEADER_LEN, ARP_HW_LEN_POS, ARP_HW_TYPE_POS, ARP_IP_ADDR_CODE, ARP_OP_LEN, ARP_OP_POS, ARP_OP_REP_CODE, ARP_OP_REQ_CODE, ARP_PR_LEN_POS, ARP_PR_TYPE_POS, ARP_S_HW_ADDR_POS, ARP_S_PR_ADDR_POS, ARP_T_HW_ADDR_POS, ARP_T_PR_ADDR_POS, RARP_OP_REP_CODE, RARP_OP_REQ_CODE |
Fields inherited from interface net.sourceforge.jpcap.net.EthernetFields |
---|
ETH_CODE_LEN, ETH_CODE_POS, ETH_DST_POS, ETH_HEADER_LEN, ETH_SRC_POS |
Constructor Summary | |
---|---|
ARPPacket(int lLen,
byte[] bytes)
Create a new ARP packet. |
|
ARPPacket(int lLen,
byte[] bytes,
Timeval tv)
Create a new ARP packet. |
|
ARPPacket(int lLen,
ByteBuffer bb,
Timeval tv)
Create a new ARP packet. |
Method Summary | |
---|---|
byte[] |
getARPData()
Fetch data portion of the arp packet. |
byte[] |
getARPHeader()
Fetch the arp header, excluding arp data payload. |
String |
getColor()
Fetch ASCII escape sequence of the color associated with this packet type. |
byte[] |
getData()
Fetch the data portion of the packet. This is overridden in derived classes to return successively smaller and smaller amounts of data. For example:
|
String |
getDestinationProtoAddress()
Fetch the destination protocol address. |
byte[] |
getHeader()
Fetch header portion of the packet. This is overridden in derived classes to return the header appropriate to the packet class. For example:
|
int |
getHwAddressLength()
Return the length of the hardware addresses in this packet, usually 6 for ARPFields.ARP_ETH_ADDR_CODE . |
int |
getHwAddressType()
Return the hardware address type in this packet, usually ARPFields.ARP_ETH_ADDR_CODE . |
int |
getOperation()
Fetch the ARP/RARP operation code. |
int |
getProtoAddressLength()
Return the length of the protocol addresses in this packet, usually 4 for ARPFields.ARP_IP_ADDR_CODE . |
int |
getProtoAddressType()
Return the type of the protocol addresses in this packet, usually ARPFields.ARP_IP_ADDR_CODE . |
String |
getSourceProtoAddress()
Fetch the sender protocol address. |
void |
setDestinationMACAddress(MACAddress macAddress)
Set the destination hardware address. |
void |
setDestinationProtoAddress(InetAddress address)
Set the destination protocol address. |
void |
setOperation(int operation)
Set the ARP operation code. |
void |
setSourceMACAddress(MACAddress macAddress)
Set the source hardware address. |
void |
setSourceProtoAddress(InetAddress address)
Set the source protocol address. |
String |
toColoredString(boolean colored)
Generate string with contents describing this packet. |
Methods inherited from class net.sourceforge.jpcap.net.EthernetPacket |
---|
equals, getDestinationHwAddress, getDestinationMACAddress, getEthernetCRC32, getEthernetData, getEthernetHeader, getEthernetHeaderLength, getEthernetProtocol, getHeaderLength, getPacketData, getPacketLength, getProtocol, getSourceHwAddress, getSourceMACAddress, getTimeval, hashCode, setChecksums, setEthernetProtocol, toByteArray, toString |
Methods inherited from class net.sourceforge.jpcap.net.Packet |
---|
getChecksum, ipChecksum, isValidChecksum |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ARPPacket(int lLen, byte[] bytes)
lLen
- link-layer header lengthbytes
- Packet datapublic ARPPacket(int lLen, byte[] bytes, Timeval tv)
lLen
- link-layer header lengthbytes
- Packet datatv
- Timestamppublic ARPPacket(int lLen, ByteBuffer bb, Timeval tv)
lLen
- link-layer header lengthbb
- Packet data wrapped in a ByteBuffertv
- TimestampMethod Detail |
---|
public int getHwAddressType()
ARPFields.ARP_ETH_ADDR_CODE
.
public int getHwAddressLength()
ARPFields.ARP_ETH_ADDR_CODE
.
public int getProtoAddressType()
ARPFields.ARP_IP_ADDR_CODE
.
public int getProtoAddressLength()
ARPFields.ARP_IP_ADDR_CODE
.
public int getOperation()
public void setOperation(int operation)
operation
- New operation code: not checked for validity.public void setSourceMACAddress(MACAddress macAddress)
This method also calls super.setSourceMACAddress()
to set the corresponding field in the Ethernet header.
setSourceMACAddress
in class EthernetPacket
macAddress
- Source MAC address.public String getSourceProtoAddress()
public void setSourceProtoAddress(InetAddress address)
address
- Source IP address.public void setDestinationMACAddress(MACAddress macAddress)
This method also calls super.setDestinationMACAddress()
to set the corresponding field in the Ethernet header.
setDestinationMACAddress
in class EthernetPacket
macAddress
- Destination MAC address.public String getDestinationProtoAddress()
public void setDestinationProtoAddress(InetAddress address)
address
- Destination IP address.public byte[] getARPHeader()
public byte[] getARPData()
public byte[] getHeader()
EthernetPacket.getHeader()
returns the Ethernet header
IP.Packet.getHeader()
returns the IP header, which is in the Ethernet payload
TCPPacket.getHeader()
returns the TCP header, which is in the IP payload
getHeader
in class EthernetPacket
public byte[] getData()
EthernetPacket.getData()
returns the entire Ethernet payload excluding the Ethernet header
IP.Packet.getData()
only returns the IP payload, i.e. excluding the IP header which is in the Ethernet payload
TCPPacket.getData()
only returns the TCP payload, i.e. excluding the TCP header which is in the IP payload
getData
in class EthernetPacket
public String toColoredString(boolean colored)
toColoredString
in class EthernetPacket
colored
- whether or not the string should contain ansi
color escape sequences.public String getColor()
getColor
in class EthernetPacket
|
Copyright © Patrick Charles & Jonas Lehmann, 2001; Esmond Pitt, 2008. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |