Class PacketBuffer
One IP packet on its way through the tunnel.
These are REUSED
The transport hands the same buffers back round rather than allocating
per packet, because a packet loop allocating at line rate is the fastest
way to exhaust the memory a tunnel host is given. A packet you
want after VpnTunnel.onPacket(PacketBuffer) returns has to be copied, with
toByteArray(); the buffer itself belongs to the transport again the
moment that call ends.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIPv4, as reported bygetFamily().static final intIPv6, as reported bygetFamily(). -
Method Summary
-
Field Details
-
FAMILY_IPV4
-
FAMILY_IPV6
-
-
Method Details
-
getData
public byte[] getData()The bytes this packet lives in, which extend beyond it.
Read between
getOffset()andgetOffset() + getLength(); the rest is whatever the previous packet left. -
getOffset
public int getOffset()Where this packet starts ingetData(). -
getLength
public int getLength()How many bytes this packet occupies. -
getFamily
public int getFamily()FAMILY_IPV4orFAMILY_IPV6.Android does not report it alongside the packet, so there it is read from the header's version nibble; a host that does report it says so directly. Either way it is the same answer, which is why it is a field here rather than something each tunnel works out again.
-
toByteArray
public byte[] toByteArray()A copy of just this packet, for keeping pastonPacket.
-