public abstract class AbstractPacket extends Object implements Packet
AbstractPacket.| Constructor and Description |
|---|
AbstractPacket(Protocol p,
Packet parent,
Buffer payload) |
| Modifier and Type | Method and Description |
|---|---|
Packet |
checkParent(Protocol p) |
abstract Packet |
clone() |
String |
getName()
Get the name of the packet.
|
Packet |
getPacket(Protocol p)
Find the packet for protocol p.
|
Packet |
getParentPacket()
Almost all packets have a parent, which is the encapsulating protocol.
|
Buffer |
getPayload()
Get the payload of the frame.
|
Protocol |
getProtocol()
Get the protocol of this frame.
|
boolean |
hasProtocol(Protocol p)
Check whether this packet contains a particular protocol.
|
void |
verify()
Calling this method will force the packet to completely parse its data
and check so that all the information conforms to whatever rules this
packet needs to follow.
|
void |
write(OutputStream out)
The write strategy is fairly simple.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetArrivalTime, getNextPacket, writepublic AbstractPacket(Protocol p, Packet parent, Buffer payload)
p - the protocol that this Packet is representing.parent - all Packet have a parent, this is it.payload - the payload of the packet, which may be null. Note, this is
the actual payload of this packet. For an IPPacket
that would typically be TransportPacket (such as udp
or tcp). For a UDPPacket, the payload could really be
anything, such as a SipPacket.public void verify()
PacketIPPacket, hardly does anything
in this method but more complex protocols such as SIP (once again), HTTP
etc can spend quite some time verifying everything, which is why you
don't want to do it unless you really have to.
In general, yajpcap has the philosophy of
"assume that everything is ok until things blow up and then deal with it"public final void write(OutputStream out) throws IOException
write in interface PacketIOExceptionpublic abstract Packet clone()
public Packet getParentPacket()
PacketSipPacket is typically a
TransportPacket such as UDPPacket or a TCPPacket.
The parent of a TransportPacket is usually a IPPacket and
so on.getParentPacket in interface Packetpublic boolean hasProtocol(Protocol p) throws IOException
PackethasProtocol in interface PacketIOException - in case something goes wrong when framing the rest of the
protocol stackpublic Protocol getProtocol()
PacketgetProtocol in interface Packetpublic Packet getPacket(Protocol p) throws IOException, PacketParseException
PacketgetPacket in interface PacketIOException - in case something goes wrong when framing the rest of the
protocol stackPacketParseException - if the next packet can't be parsed by the
framerpublic String getName()
Packetpublic Buffer getPayload()
PacketgetPayload in interface PacketCopyright © 2021. All Rights Reserved.