0
|
1
|
|
2 package com.trilead.ssh2.packets;
|
|
3
|
|
4 import java.io.IOException;
|
|
5
|
|
6 /**
|
|
7 * PacketIgnore.
|
|
8 *
|
|
9 * @author Christian Plattner, plattner@trilead.com
|
|
10 * @version $Id: PacketIgnore.java,v 1.1 2007/10/15 12:49:55 cplattne Exp $
|
|
11 */
|
|
12 public class PacketIgnore {
|
|
13 byte[] payload;
|
|
14
|
|
15 byte[] data;
|
|
16
|
|
17 public void setData(byte[] data) {
|
|
18 this.data = data;
|
|
19 payload = null;
|
|
20 }
|
|
21
|
|
22 public PacketIgnore() {
|
|
23 }
|
|
24
|
|
25 public PacketIgnore(byte payload[], int off, int len) throws IOException {
|
|
26 this.payload = new byte[len];
|
|
27 System.arraycopy(payload, off, this.payload, 0, len);
|
|
28 TypesReader tr = new TypesReader(payload, off, len);
|
|
29 int packet_type = tr.readByte();
|
|
30
|
|
31 if (packet_type != Packets.SSH_MSG_IGNORE)
|
|
32 throw new IOException("This is not a SSH_MSG_IGNORE packet! (" + packet_type + ")");
|
|
33
|
|
34 /* Could parse String body */
|
|
35 }
|
|
36
|
|
37 public byte[] getPayload() {
|
|
38 if (payload == null) {
|
|
39 TypesWriter tw = new TypesWriter();
|
|
40 tw.writeByte(Packets.SSH_MSG_IGNORE);
|
|
41
|
|
42 if (data != null)
|
|
43 tw.writeString(data, 0, data.length);
|
|
44 else
|
|
45 tw.writeString("");
|
|
46
|
|
47 payload = tw.getBytes();
|
|
48 }
|
|
49
|
|
50 return payload;
|
|
51 }
|
|
52 }
|