001: /*
002: * SSHTools - Java SSH2 API
003: *
004: * Copyright (C) 2002-2003 Lee David Painter and Contributors.
005: *
006: * Contributions made by:
007: *
008: * Brett Smith
009: * Richard Pernavas
010: * Erwin Bolwidt
011: *
012: * This program is free software; you can redistribute it and/or
013: * modify it under the terms of the GNU General Public License
014: * as published by the Free Software Foundation; either version 2
015: * of the License, or (at your option) any later version.
016: *
017: * This program is distributed in the hope that it will be useful,
018: * but WITHOUT ANY WARRANTY; without even the implied warranty of
019: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
020: * GNU General Public License for more details.
021: *
022: * You should have received a copy of the GNU General Public License
023: * along with this program; if not, write to the Free Software
024: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
025: */
026: package com.sshtools.j2ssh.connection;
027:
028: import com.sshtools.j2ssh.io.ByteArrayReader;
029: import com.sshtools.j2ssh.io.ByteArrayWriter;
030: import com.sshtools.j2ssh.transport.InvalidMessageException;
031: import com.sshtools.j2ssh.transport.SshMessage;
032:
033: import java.io.IOException;
034:
035: /**
036: *
037: *
038: * @author $author$
039: * @version $Revision: 1.20 $
040: */
041: public class SshMsgChannelClose extends SshMessage {
042: /** */
043: protected final static int SSH_MSG_CHANNEL_CLOSE = 97;
044:
045: // The recipient channel id
046: private long recipientChannel;
047:
048: /**
049: * Creates a new SshMsgChannelClose object.
050: *
051: * @param recipientChannel
052: */
053: public SshMsgChannelClose(long recipientChannel) {
054: super (SSH_MSG_CHANNEL_CLOSE);
055: this .recipientChannel = recipientChannel;
056: }
057:
058: /**
059: * Creates a new SshMsgChannelClose object.
060: */
061: public SshMsgChannelClose() {
062: super (SSH_MSG_CHANNEL_CLOSE);
063: }
064:
065: /**
066: *
067: *
068: * @return
069: */
070: public String getMessageName() {
071: return "SSH_MSG_CHANNEL_CLOSE";
072: }
073:
074: /**
075: *
076: *
077: * @return
078: */
079: public long getRecipientChannel() {
080: return recipientChannel;
081: }
082:
083: /**
084: *
085: *
086: * @param baw
087: *
088: * @throws InvalidMessageException
089: */
090: protected void constructByteArray(ByteArrayWriter baw)
091: throws InvalidMessageException {
092: try {
093: baw.writeInt(recipientChannel);
094: } catch (IOException ioe) {
095: throw new InvalidMessageException("Invalid message data");
096: }
097: }
098:
099: /**
100: *
101: *
102: * @param bar
103: *
104: * @throws InvalidMessageException
105: */
106: protected void constructMessage(ByteArrayReader bar)
107: throws InvalidMessageException {
108: try {
109: recipientChannel = bar.readInt();
110: } catch (IOException ioe) {
111: throw new InvalidMessageException("Invalid message data");
112: }
113: }
114: }
|