273
|
1 /*
|
|
2 * Copyright (c) 2006-2011 Christian Plattner. All rights reserved.
|
|
3 * Please refer to the LICENSE.txt for licensing details.
|
|
4 */
|
|
5 package ch.ethz.ssh2.packets;
|
|
6
|
|
7 import java.io.IOException;
|
|
8
|
|
9 import ch.ethz.ssh2.PacketFormatException;
|
|
10
|
|
11 /**
|
|
12 * @author Christian Plattner
|
|
13 * @version $Id: PacketChannelWindowAdjust.java 160 2014-05-01 14:30:26Z dkocher@sudo.ch $
|
|
14 */
|
|
15 public final class PacketChannelWindowAdjust {
|
|
16
|
|
17 private final byte[] payload;
|
|
18
|
|
19 public PacketChannelWindowAdjust(int recipientChannelID, int windowChange) {
|
|
20 TypesWriter tw = new TypesWriter();
|
|
21 tw.writeByte(Packets.SSH_MSG_CHANNEL_WINDOW_ADJUST);
|
|
22 tw.writeUINT32(recipientChannelID);
|
|
23 tw.writeUINT32(windowChange);
|
|
24 payload = tw.getBytes();
|
|
25 }
|
|
26
|
|
27 public PacketChannelWindowAdjust(byte payload[]) throws IOException {
|
|
28 this.payload = payload;
|
|
29 TypesReader tr = new TypesReader(payload);
|
|
30 int packet_type = tr.readByte();
|
|
31
|
307
|
32 if (packet_type != Packets.SSH_MSG_CHANNEL_WINDOW_ADJUST) {
|
273
|
33 throw new IOException(
|
307
|
34 "This is not a SSH_MSG_CHANNEL_WINDOW_ADJUST! ("
|
|
35 + packet_type + ")"
|
273
|
36 );
|
|
37 }
|
|
38
|
|
39 int recipientChannelID = tr.readUINT32();
|
|
40 int windowChange = tr.readUINT32();
|
|
41
|
307
|
42 if (tr.remain() != 0) {
|
273
|
43 throw new PacketFormatException(String.format("Padding in %s", Packets.getMessageName(packet_type)));
|
|
44 }
|
|
45 }
|
|
46
|
|
47 public byte[] getPayload() {
|
|
48 return payload;
|
|
49 }
|
|
50 }
|