KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > ssh2 > packets > PacketChannelWindowAdjust


1 package ch.ethz.ssh2.packets;
2
3 import java.io.IOException JavaDoc;
4
5 /**
6  * PacketChannelWindowAdjust.
7  *
8  * @author Christian Plattner, plattner@inf.ethz.ch
9  * @version $Id: PacketChannelWindowAdjust.java,v 1.2 2005/08/24 17:54:09 cplattne Exp $
10  */

11 public class PacketChannelWindowAdjust
12 {
13     byte[] payload;
14
15     public int recipientChannelID;
16     public int windowChange;
17
18     public PacketChannelWindowAdjust(int recipientChannelID, int windowChange)
19     {
20         this.recipientChannelID = recipientChannelID;
21         this.windowChange = windowChange;
22     }
23
24     public PacketChannelWindowAdjust(byte payload[], int off, int len) throws IOException JavaDoc
25     {
26         this.payload = new byte[len];
27         System.arraycopy(payload, off, this.payload, 0, len);
28
29         TypesReader tr = new TypesReader(payload, off, len);
30
31         int packet_type = tr.readByte();
32
33         if (packet_type != Packets.SSH_MSG_CHANNEL_WINDOW_ADJUST)
34             throw new IOException JavaDoc(
35                     "This is not a SSH_MSG_CHANNEL_WINDOW_ADJUST! ("
36                             + packet_type + ")");
37
38         recipientChannelID = tr.readUINT32();
39         windowChange = tr.readUINT32();
40         
41         if (tr.remain() != 0)
42             throw new IOException JavaDoc("Padding in SSH_MSG_CHANNEL_WINDOW_ADJUST packet!");
43     }
44
45     public byte[] getPayload()
46     {
47         if (payload == null)
48         {
49             TypesWriter tw = new TypesWriter();
50             tw.writeByte(Packets.SSH_MSG_CHANNEL_WINDOW_ADJUST);
51             tw.writeUINT32(recipientChannelID);
52             tw.writeUINT32(windowChange);
53             payload = tw.getBytes();
54         }
55         return payload;
56     }
57 }
58
Popular Tags