00001
00002 using Tamir.SharpSsh.java;
00003 using Tamir.SharpSsh.java.lang;
00004
00005 namespace Tamir.SharpSsh.jsch
00006 {
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 public class RequestSubsystem : Request
00037 {
00038 private bool want_reply=true;
00039 private String subsystem=null;
00040 public void request(Session session, Channel channel, String subsystem, bool want_reply)
00041 {
00042 this.subsystem=subsystem;
00043 this.want_reply=want_reply;
00044 this.request(session, channel);
00045 }
00046 public void request(Session session, Channel channel)
00047 {
00048 Buffer buf=new Buffer();
00049 Packet packet=new Packet(buf);
00050
00051 bool reply=waitForReply();
00052 if(reply)
00053 {
00054 channel.reply=-1;
00055 }
00056
00057 packet.reset();
00058 buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
00059 buf.putInt(channel.getRecipient());
00060 buf.putString( new String( "subsystem" ).getBytes());
00061 buf.putByte((byte)(waitForReply() ? 1 : 0));
00062 buf.putString(subsystem.getBytes());
00063 session.write(packet);
00064
00065 if(reply)
00066 {
00067 while(channel.reply==-1)
00068 {
00069 try{Thread.sleep(10);}
00070 catch
00071 {
00072 }
00073 }
00074 if(channel.reply==0)
00075 {
00076 throw new JSchException("failed to send subsystem request");
00077 }
00078 }
00079 }
00080 public bool waitForReply(){ return want_reply; }
00081 }
00082
00083 }