Mercurial > 510Connectbot
comparison src/com/trilead/ssh2/packets/PacketChannelOpenConfirmation.java @ 0:0ce5cc452d02
initial version
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Thu, 22 May 2014 10:41:19 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0ce5cc452d02 |
---|---|
1 package com.trilead.ssh2.packets; | |
2 | |
3 import java.io.IOException; | |
4 | |
5 /** | |
6 * PacketChannelOpenConfirmation. | |
7 * | |
8 * @author Christian Plattner, plattner@trilead.com | |
9 * @version $Id: PacketChannelOpenConfirmation.java,v 1.1 2007/10/15 12:49:55 cplattne Exp $ | |
10 */ | |
11 public class PacketChannelOpenConfirmation { | |
12 byte[] payload; | |
13 | |
14 public int recipientChannelID; | |
15 public int senderChannelID; | |
16 public int initialWindowSize; | |
17 public int maxPacketSize; | |
18 | |
19 public PacketChannelOpenConfirmation(int recipientChannelID, int senderChannelID, int initialWindowSize, | |
20 int maxPacketSize) { | |
21 this.recipientChannelID = recipientChannelID; | |
22 this.senderChannelID = senderChannelID; | |
23 this.initialWindowSize = initialWindowSize; | |
24 this.maxPacketSize = maxPacketSize; | |
25 } | |
26 | |
27 public PacketChannelOpenConfirmation(byte payload[], int off, int len) throws IOException { | |
28 this.payload = new byte[len]; | |
29 System.arraycopy(payload, off, this.payload, 0, len); | |
30 TypesReader tr = new TypesReader(payload, off, len); | |
31 int packet_type = tr.readByte(); | |
32 | |
33 if (packet_type != Packets.SSH_MSG_CHANNEL_OPEN_CONFIRMATION) | |
34 throw new IOException( | |
35 "This is not a SSH_MSG_CHANNEL_OPEN_CONFIRMATION! (" | |
36 + packet_type + ")"); | |
37 | |
38 recipientChannelID = tr.readUINT32(); | |
39 senderChannelID = tr.readUINT32(); | |
40 initialWindowSize = tr.readUINT32(); | |
41 maxPacketSize = tr.readUINT32(); | |
42 | |
43 if (tr.remain() != 0) | |
44 throw new IOException("Padding in SSH_MSG_CHANNEL_OPEN_CONFIRMATION packet!"); | |
45 } | |
46 | |
47 public byte[] getPayload() { | |
48 if (payload == null) { | |
49 TypesWriter tw = new TypesWriter(); | |
50 tw.writeByte(Packets.SSH_MSG_CHANNEL_OPEN_CONFIRMATION); | |
51 tw.writeUINT32(recipientChannelID); | |
52 tw.writeUINT32(senderChannelID); | |
53 tw.writeUINT32(initialWindowSize); | |
54 tw.writeUINT32(maxPacketSize); | |
55 payload = tw.getBytes(); | |
56 } | |
57 | |
58 return payload; | |
59 } | |
60 } |