M net/ssh/client.ha => net/ssh/client.ha +5 -16
@@ 120,22 120,11 @@ export fn client_read(client: *client) (packet | io::EOF | error) = {
// XXX: This function is probably useful both for clients and servers,
// we could share it.
- let msglen = types::SIZE_MAX;
- if (len(client.rbuf) >= 5) {
- const pktlen = endian::begetu32(client.rbuf[..4]);
- const maclen = match (client.mac) {
- case null =>
- yield 0z;
- case let mac: *mac =>
- yield mac_digestsz(mac);
- };
- msglen = pktlen + maclen + 4;
- if (msglen >= MAX_PACKETSIZE) {
- return protoerror;
- };
- };
- if (msglen <= len(client.rbuf)) {
- return client_decode(client);
+ match (client_decode(client)) {
+ case errors::again =>
+ yield;
+ case let r: (packet | error) =>
+ return r;
};
let buf: [os::BUFSIZ]u8 = [0...];