mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-15 10:07:39 -05:00
Give the BPP an input and output packet queue.
Now, instead of writing each packet straight on to the raw output bufchain by calling the BPP's format_packet function, the higher protocol layers will put the packets on to a queue, which will automatically trigger a callback (using the new mechanism for embedding a callback in any packet queue) to make the BPP format its queue on to the raw-output bufchain. That in turn triggers a second callback which moves the data to the socket. This means in particular that the CBC ignore-message workaround can be moved into the new BPP routine to process the output queue, which is a good place for it because then it can easily arrange to only put an ignore message at the start of any sequence of packets that are being formatted as a single output blob.
This commit is contained in:
@ -22,14 +22,14 @@ struct ssh2_bare_bpp_state {
|
||||
|
||||
static void ssh2_bare_bpp_free(BinaryPacketProtocol *bpp);
|
||||
static void ssh2_bare_bpp_handle_input(BinaryPacketProtocol *bpp);
|
||||
static void ssh2_bare_bpp_handle_output(BinaryPacketProtocol *bpp);
|
||||
static PktOut *ssh2_bare_bpp_new_pktout(int type);
|
||||
static void ssh2_bare_bpp_format_packet(BinaryPacketProtocol *bpp, PktOut *);
|
||||
|
||||
static const struct BinaryPacketProtocolVtable ssh2_bare_bpp_vtable = {
|
||||
ssh2_bare_bpp_free,
|
||||
ssh2_bare_bpp_handle_input,
|
||||
ssh2_bare_bpp_handle_output,
|
||||
ssh2_bare_bpp_new_pktout,
|
||||
ssh2_bare_bpp_format_packet,
|
||||
};
|
||||
|
||||
BinaryPacketProtocol *ssh2_bare_bpp_new(void)
|
||||
@ -37,6 +37,7 @@ BinaryPacketProtocol *ssh2_bare_bpp_new(void)
|
||||
struct ssh2_bare_bpp_state *s = snew(struct ssh2_bare_bpp_state);
|
||||
memset(s, 0, sizeof(*s));
|
||||
s->bpp.vt = &ssh2_bare_bpp_vtable;
|
||||
ssh_bpp_common_setup(&s->bpp);
|
||||
return &s->bpp;
|
||||
}
|
||||
|
||||
@ -120,7 +121,7 @@ static void ssh2_bare_bpp_handle_input(BinaryPacketProtocol *bpp)
|
||||
continue;
|
||||
}
|
||||
|
||||
pq_push(s->bpp.in_pq, s->pktin);
|
||||
pq_push(&s->bpp.in_pq, s->pktin);
|
||||
|
||||
{
|
||||
int type = s->pktin->type;
|
||||
@ -142,11 +143,9 @@ static PktOut *ssh2_bare_bpp_new_pktout(int pkt_type)
|
||||
return pkt;
|
||||
}
|
||||
|
||||
static void ssh2_bare_bpp_format_packet(BinaryPacketProtocol *bpp, PktOut *pkt)
|
||||
static void ssh2_bare_bpp_format_packet(struct ssh2_bare_bpp_state *s,
|
||||
PktOut *pkt)
|
||||
{
|
||||
struct ssh2_bare_bpp_state *s =
|
||||
FROMFIELD(bpp, struct ssh2_bare_bpp_state, bpp);
|
||||
|
||||
if (s->bpp.logctx) {
|
||||
ptrlen pktdata = make_ptrlen(pkt->data + 5, pkt->length - 5);
|
||||
logblank_t blanks[MAX_BLANKS];
|
||||
@ -164,6 +163,16 @@ static void ssh2_bare_bpp_format_packet(BinaryPacketProtocol *bpp, PktOut *pkt)
|
||||
|
||||
PUT_32BIT(pkt->data, pkt->length - 4);
|
||||
bufchain_add(s->bpp.out_raw, pkt->data, pkt->length);
|
||||
|
||||
ssh_free_pktout(pkt);
|
||||
}
|
||||
|
||||
static void ssh2_bare_bpp_handle_output(BinaryPacketProtocol *bpp)
|
||||
{
|
||||
struct ssh2_bare_bpp_state *s =
|
||||
FROMFIELD(bpp, struct ssh2_bare_bpp_state, bpp);
|
||||
PktOut *pkt;
|
||||
|
||||
while ((pkt = pq_pop(&s->bpp.out_pq)) != NULL) {
|
||||
ssh2_bare_bpp_format_packet(s, pkt);
|
||||
ssh_free_pktout(pkt);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user