KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > ssh2 > packets > PacketIgnore


1
2 package ch.ethz.ssh2.packets;
3
4 import java.io.IOException JavaDoc;
5
6 /**
7  * PacketIgnore.
8  *
9  * @author Christian Plattner, plattner@inf.ethz.ch
10  * @version $Id: PacketIgnore.java,v 1.3 2006/11/01 14:20:24 cplattne Exp $
11  */

12 public class PacketIgnore
13 {
14     byte[] payload;
15
16     byte[] data;
17
18     public void setData(byte[] data)
19     {
20         this.data = data;
21         payload = null;
22     }
23
24     public PacketIgnore()
25     {
26     }
27
28     public PacketIgnore(byte payload[], int off, int len) throws IOException JavaDoc
29     {
30         this.payload = new byte[len];
31         System.arraycopy(payload, off, this.payload, 0, len);
32
33         TypesReader tr = new TypesReader(payload, off, len);
34
35         int packet_type = tr.readByte();
36
37         if (packet_type != Packets.SSH_MSG_IGNORE)
38             throw new IOException JavaDoc("This is not a SSH_MSG_IGNORE packet! (" + packet_type + ")");
39
40         /* Could parse String body */
41     }
42
43     public byte[] getPayload()
44     {
45         if (payload == null)
46         {
47             TypesWriter tw = new TypesWriter();
48             tw.writeByte(Packets.SSH_MSG_IGNORE);
49
50             if (data != null)
51                 tw.writeString(data, 0, data.length);
52             else
53                 tw.writeString("");
54
55             payload = tw.getBytes();
56         }
57         return payload;
58     }
59 }
60
Popular Tags