Mercurial > 510Connectbot
comparison src/ch/ethz/ssh2/packets/PacketOpenSessionChannel.java @ 273:91a31873c42a ganymed
start conversion from trilead to ganymed
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 18 Jul 2014 11:21:46 -0700 |
parents | |
children | 071eccdff8ea |
comparison
equal
deleted
inserted
replaced
272:ce2f4e397703 | 273:91a31873c42a |
---|---|
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 import ch.ethz.ssh2.PacketTypeException; | |
11 | |
12 /** | |
13 * @author Christian Plattner | |
14 * @version $Id: PacketOpenSessionChannel.java 160 2014-05-01 14:30:26Z dkocher@sudo.ch $ | |
15 */ | |
16 public final class PacketOpenSessionChannel { | |
17 private final byte[] payload; | |
18 | |
19 public PacketOpenSessionChannel(int channelID, int initialWindowSize, int maxPacketSize) { | |
20 TypesWriter tw = new TypesWriter(); | |
21 tw.writeByte(Packets.SSH_MSG_CHANNEL_OPEN); | |
22 tw.writeString("session"); | |
23 tw.writeUINT32(channelID); | |
24 tw.writeUINT32(initialWindowSize); | |
25 tw.writeUINT32(maxPacketSize); | |
26 payload = tw.getBytes(); | |
27 } | |
28 | |
29 public PacketOpenSessionChannel(byte payload[]) throws IOException { | |
30 this.payload = payload; | |
31 | |
32 TypesReader tr = new TypesReader(payload); | |
33 | |
34 int packet_type = tr.readByte(); | |
35 | |
36 if(packet_type != Packets.SSH_MSG_CHANNEL_OPEN) { | |
37 throw new PacketTypeException(packet_type); | |
38 } | |
39 | |
40 int channelID = tr.readUINT32(); | |
41 int initialWindowSize = tr.readUINT32(); | |
42 int maxPacketSize = tr.readUINT32(); | |
43 | |
44 if(tr.remain() != 0) { | |
45 throw new PacketFormatException(String.format("Padding in %s", Packets.getMessageName(packet_type))); | |
46 } | |
47 } | |
48 | |
49 public byte[] getPayload() { | |
50 return payload; | |
51 } | |
52 } |