01: package ch.ethz.ssh2.packets;
02:
03: import java.io.IOException;
04:
05: /**
06: * PacketChannelWindowAdjust.
07: *
08: * @author Christian Plattner, plattner@inf.ethz.ch
09: * @version $Id: PacketChannelWindowAdjust.java,v 1.2 2005/08/24 17:54:09 cplattne Exp $
10: */
11: public class PacketChannelWindowAdjust {
12: byte[] payload;
13:
14: public int recipientChannelID;
15: public int windowChange;
16:
17: public PacketChannelWindowAdjust(int recipientChannelID,
18: int windowChange) {
19: this .recipientChannelID = recipientChannelID;
20: this .windowChange = windowChange;
21: }
22:
23: public PacketChannelWindowAdjust(byte payload[], int off, int len)
24: throws IOException {
25: this .payload = new byte[len];
26: System.arraycopy(payload, off, this .payload, 0, len);
27:
28: TypesReader tr = new TypesReader(payload, off, len);
29:
30: int packet_type = tr.readByte();
31:
32: if (packet_type != Packets.SSH_MSG_CHANNEL_WINDOW_ADJUST)
33: throw new IOException(
34: "This is not a SSH_MSG_CHANNEL_WINDOW_ADJUST! ("
35: + packet_type + ")");
36:
37: recipientChannelID = tr.readUINT32();
38: windowChange = tr.readUINT32();
39:
40: if (tr.remain() != 0)
41: throw new IOException(
42: "Padding in SSH_MSG_CHANNEL_WINDOW_ADJUST packet!");
43: }
44:
45: public byte[] getPayload() {
46: if (payload == null) {
47: TypesWriter tw = new TypesWriter();
48: tw.writeByte(Packets.SSH_MSG_CHANNEL_WINDOW_ADJUST);
49: tw.writeUINT32(recipientChannelID);
50: tw.writeUINT32(windowChange);
51: payload = tw.getBytes();
52: }
53: return payload;
54: }
55: }
|