00001 using System; 00002 using Tamir.SharpSsh.java.lang; 00003 using Str = Tamir.SharpSsh.java.String; 00004 00005 namespace Tamir.SharpSsh.jsch 00006 { 00007 /* -*-mode:java; c-basic-offset:2; -*- */ 00008 /* 00009 Copyright (c) 2002,2003,2004 ymnk, JCraft,Inc. All rights reserved. 00010 00011 Redistribution and use in source and binary forms, with or without 00012 modification, are permitted provided that the following conditions are met: 00013 00014 1. Redistributions of source code must retain the above copyright notice, 00015 this list of conditions and the following disclaimer. 00016 00017 2. Redistributions in binary form must reproduce the above copyright 00018 notice, this list of conditions and the following disclaimer in 00019 the documentation and/or other materials provided with the distribution. 00020 00021 3. The names of the authors may not be used to endorse or promote products 00022 derived from this software without specific prior written permission. 00023 00024 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00025 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00026 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 00027 INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00030 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00031 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00032 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00033 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 */ 00035 public class ChannelSession : Channel 00036 { 00037 private static byte[] _session=new Str("session").getBytes(); 00038 public ChannelSession():base() 00039 { 00040 type=_session; 00041 io=new IO(); 00042 } 00043 00044 public override void run() 00045 { 00046 //System.out.println(this+":run >"); 00047 /* 00048 if(thread!=null){ return; } 00049 thread=Thread.currentThread(); 00050 */ 00051 00052 // Buffer buf=new Buffer(); 00053 Buffer buf=new Buffer(rmpsize); 00054 Packet packet=new Packet(buf); 00055 int i=-1; 00056 try 00057 { 00058 while(isConnected() && 00059 thread!=null && 00060 io!=null && 00061 io.ins!=null) 00062 { 00063 i=io.ins.Read(buf.buffer, 00064 14, 00065 buf.buffer.Length-14 00066 -32 -20 // padding and mac 00067 ); 00068 if(i==0)continue; 00069 if(i==-1) 00070 { 00071 eof(); 00072 break; 00073 } 00074 if(_close)break; 00075 packet.reset(); 00076 buf.putByte((byte)Session.SSH_MSG_CHANNEL_DATA); 00077 buf.putInt(recipient); 00078 buf.putInt(i); 00079 buf.skip(i); 00080 session.write(packet, this, i); 00081 } 00082 } 00083 catch(Exception e) 00084 { 00085 Console.WriteLine("# ChannelSession.run"); 00086 Console.WriteLine(e); 00087 } 00088 if(thread!=null) 00089 { 00090 //lock(thread){ System.Threading.Monitor.PulseAll(this);/*thread.notifyAll();*/ } 00091 } 00092 thread=null; 00093 //System.out.println(this+":run <"); 00094 } 00095 } 00096 }
1.5.9