public class EthernetFramer extends Object implements Framer<PCapPacket,MACPacket>
| Modifier and Type | Class and Description |
|---|---|
static class |
EthernetFramer.EtherType |
| Constructor and Description |
|---|
EthernetFramer() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(Buffer data)
Check whether the supplied data could be framed into a frame of this
type.
|
MACPacket |
frame(PCapPacket parent,
Buffer buffer)
Ask the framer to frame the buffer into a packet.
|
static EthernetFramer.EtherType |
getEtherType(byte b1,
byte b2) |
static EthernetFramer.EtherType |
getEtherTypeSafe(byte b1,
byte b2) |
Protocol |
getProtocol() |
public Protocol getProtocol()
getProtocol in interface Framer<PCapPacket,MACPacket>public MACPacket frame(PCapPacket parent, Buffer buffer) throws IOException, FramingException
Packet has not been parsed, just framed.frame in interface Framer<PCapPacket,MACPacket>parent - the parent frame or null if the frame doesn't have one.buffer - the buffer containing all the raw dataIOException - in case something goes wrong when reading data from the
bufferFramingException - in case the data in buffer can't be parsed by the framerpublic static EthernetFramer.EtherType getEtherType(byte b1, byte b2) throws UnknownEtherType
UnknownEtherTypepublic static EthernetFramer.EtherType getEtherTypeSafe(byte b1, byte b2)
public boolean accept(Buffer data)
FramerFramer will read a few bytes in an effort to
figure out if the incoming data may be something it recognizes. E.g., a
HTTP Framer could check if the first bytes match "GET", "POST",
"PUT" and "DELETE" if if so assume that the payload indeed is HTTP and
therefore return true. Of course, you may never really know until you
actually have parsed the entire body but this method should return quick
and if turns out that the data isn't what it thought, throw an exception
and the framework will take care of it.accept in interface Framer<PCapPacket,MACPacket>data - the data to check whether it could be a frame of this typeCopyright © 2021. All Rights Reserved.