Mercurial > 510Connectbot
comparison src/com/trilead/ssh2/packets/PacketChannelOpenFailure.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 * PacketChannelOpenFailure. | |
7 * | |
8 * @author Christian Plattner, plattner@trilead.com | |
9 * @version $Id: PacketChannelOpenFailure.java,v 1.1 2007/10/15 12:49:55 cplattne Exp $ | |
10 */ | |
11 public class PacketChannelOpenFailure { | |
12 byte[] payload; | |
13 | |
14 public int recipientChannelID; | |
15 public int reasonCode; | |
16 public String description; | |
17 public String languageTag; | |
18 | |
19 public PacketChannelOpenFailure(int recipientChannelID, int reasonCode, String description, | |
20 String languageTag) { | |
21 this.recipientChannelID = recipientChannelID; | |
22 this.reasonCode = reasonCode; | |
23 this.description = description; | |
24 this.languageTag = languageTag; | |
25 } | |
26 | |
27 public PacketChannelOpenFailure(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_FAILURE) | |
34 throw new IOException( | |
35 "This is not a SSH_MSG_CHANNEL_OPEN_FAILURE! (" | |
36 + packet_type + ")"); | |
37 | |
38 recipientChannelID = tr.readUINT32(); | |
39 reasonCode = tr.readUINT32(); | |
40 description = tr.readString(); | |
41 languageTag = tr.readString(); | |
42 | |
43 if (tr.remain() != 0) | |
44 throw new IOException("Padding in SSH_MSG_CHANNEL_OPEN_FAILURE packet!"); | |
45 } | |
46 | |
47 public byte[] getPayload() { | |
48 if (payload == null) { | |
49 TypesWriter tw = new TypesWriter(); | |
50 tw.writeByte(Packets.SSH_MSG_CHANNEL_OPEN_FAILURE); | |
51 tw.writeUINT32(recipientChannelID); | |
52 tw.writeUINT32(reasonCode); | |
53 tw.writeString(description); | |
54 tw.writeString(languageTag); | |
55 payload = tw.getBytes(); | |
56 } | |
57 | |
58 return payload; | |
59 } | |
60 } |