Mercurial > 510Connectbot
comparison src/com/trilead/ssh2/packets/PacketServiceRequest.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 * PacketServiceRequest. | |
7 * | |
8 * @author Christian Plattner, plattner@trilead.com | |
9 * @version $Id: PacketServiceRequest.java,v 1.1 2007/10/15 12:49:55 cplattne Exp $ | |
10 */ | |
11 public class PacketServiceRequest { | |
12 byte[] payload; | |
13 | |
14 String serviceName; | |
15 | |
16 public PacketServiceRequest(String serviceName) { | |
17 this.serviceName = serviceName; | |
18 } | |
19 | |
20 public PacketServiceRequest(byte payload[], int off, int len) throws IOException { | |
21 this.payload = new byte[len]; | |
22 System.arraycopy(payload, off, this.payload, 0, len); | |
23 TypesReader tr = new TypesReader(payload, off, len); | |
24 int packet_type = tr.readByte(); | |
25 | |
26 if (packet_type != Packets.SSH_MSG_SERVICE_REQUEST) | |
27 throw new IOException("This is not a SSH_MSG_SERVICE_REQUEST! (" | |
28 + packet_type + ")"); | |
29 | |
30 serviceName = tr.readString(); | |
31 | |
32 if (tr.remain() != 0) | |
33 throw new IOException("Padding in SSH_MSG_SERVICE_REQUEST packet!"); | |
34 } | |
35 | |
36 public byte[] getPayload() { | |
37 if (payload == null) { | |
38 TypesWriter tw = new TypesWriter(); | |
39 tw.writeByte(Packets.SSH_MSG_SERVICE_REQUEST); | |
40 tw.writeString(serviceName); | |
41 payload = tw.getBytes(); | |
42 } | |
43 | |
44 return payload; | |
45 } | |
46 } |