• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
10  * PacketIgnore.
11  *
12  * @author Christian Plattner
13  * @version 2.50, 03/15/10
14  */
15 public class PacketIgnore
16 {
17 	byte[] payload;
18 
19 	byte[] data;
20 
setData(byte[] data)21 	public void setData(byte[] data)
22 	{
23 		this.data = data;
24 		payload = null;
25 	}
26 
PacketIgnore()27 	public PacketIgnore()
28 	{
29 	}
30 
PacketIgnore(byte payload[], int off, int len)31 	public PacketIgnore(byte payload[], int off, int len) throws IOException
32 	{
33 		this.payload = new byte[len];
34 		System.arraycopy(payload, off, this.payload, 0, len);
35 
36 		TypesReader tr = new TypesReader(payload, off, len);
37 
38 		int packet_type = tr.readByte();
39 
40 		if (packet_type != Packets.SSH_MSG_IGNORE)
41 			throw new IOException("This is not a SSH_MSG_IGNORE packet! (" + packet_type + ")");
42 
43 		/* Could parse String body */
44 	}
45 
getPayload()46 	public byte[] getPayload()
47 	{
48 		if (payload == null)
49 		{
50 			TypesWriter tw = new TypesWriter();
51 			tw.writeByte(Packets.SSH_MSG_IGNORE);
52 
53 			if (data != null)
54 				tw.writeString(data, 0, data.length);
55 			else
56 				tw.writeString("");
57 
58 			payload = tw.getBytes();
59 		}
60 		return payload;
61 	}
62 }
63