1 | /******************************************************************************
|
---|
2 | *
|
---|
3 | * Copyright (c) 1998,99 by Mindbright Technology AB, Stockholm, Sweden.
|
---|
4 | * www.mindbright.se, [email protected]
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | *****************************************************************************
|
---|
17 | * $Author: mats $
|
---|
18 | * $Date: 1999/10/25 10:47:20 $
|
---|
19 | * $Name: rel1-2-1 $
|
---|
20 | *****************************************************************************/
|
---|
21 | package mindbright.ssh;
|
---|
22 |
|
---|
23 | import java.io.*;
|
---|
24 |
|
---|
25 | public class SSHRxChannel extends SSHChannel {
|
---|
26 |
|
---|
27 | protected InputStream in;
|
---|
28 | protected SSHPdu pduFactory;
|
---|
29 |
|
---|
30 | public SSHRxChannel(InputStream in, int channelId) {
|
---|
31 | super(channelId);
|
---|
32 | this.in = in;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public void setSSHPduFactory(SSHPdu pduFactory) {
|
---|
36 | this.pduFactory = pduFactory;
|
---|
37 | }
|
---|
38 |
|
---|
39 | public void serviceLoop() throws Exception {
|
---|
40 | SSH.logExtra("Starting rx-chan: " + channelId);
|
---|
41 | for(;;) {
|
---|
42 | SSHPdu pdu;
|
---|
43 | pdu = pduFactory.createPdu();
|
---|
44 | pdu = listener.prepare(pdu);
|
---|
45 | // pdu = pdu.preProcess(pdu);
|
---|
46 | pdu.readFrom(in);
|
---|
47 | // pdu = pdu.postProcess();
|
---|
48 | listener.receive(pdu);
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|
52 | public void forceClose() {
|
---|
53 | try {
|
---|
54 | in.close();
|
---|
55 | } catch (IOException e) {
|
---|
56 | // !!!
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | }
|
---|