parseUtpPacket
Parse a datagram into a UtpPacket, walking the extension chain to find a SACK bitmask and to locate the payload. Returns null on any malformed framing (short header, unknown type, truncated extension). These are the same rejects libtorrent applies in incoming_packet().
Faithful to the extension walk:
std::uint8_t extension = ph->extension;
while (extension) {
next_extension = *ptr++; len = *ptr++;
switch (extension) { case utp_sack: ...; }
ptr += len; extension = next_extension;
}Content copied to clipboard
Only UtpExtension.SACK is captured; other extensions (e.g. close_reason) are skipped over, exactly as libtorrent skips bodies it doesn't act on here.