1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-13 09:07:33 -05:00

Extend PacketQueue to take PktOut as well.

Some upcoming restructuring I've got planned will need to pass output
packets back and forth on queues, as well as input ones. So here's a
change that arranges that we can have a PktInQueue and a PktOutQueue,
sharing most of their implementation via a PacketQueueBase structure
which links together the PacketQueueNode fields in the two packet
structures.

There's a tricksy bit of macro manoeuvring to get all of this
type-checked, so that I can't accidentally link a PktOut on to a
PktInQueue or vice versa. It works by having the main queue functions
wrapped by macros; when receiving a packet structure on input, they
type-check it against the queue structure and then automatically look
up its qnode field to pass to the underlying PacketQueueBase function;
on output, they translate a returned PacketQueueNode back to its
containing packet type by calling a 'get' function pointer.
This commit is contained in:
Simon Tatham
2018-09-19 21:56:11 +01:00
parent 63a14f26f7
commit 6e24b7d589
3 changed files with 113 additions and 85 deletions

View File

@ -17,7 +17,7 @@ struct BinaryPacketProtocolVtable {
struct BinaryPacketProtocol {
const struct BinaryPacketProtocolVtable *vt;
bufchain *in_raw, *out_raw;
PacketQueue *in_pq;
PktInQueue *in_pq;
PacketLogSettings *pls;
LogContext *logctx;