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 SshMsgChannelFailure extends SshMessage {
042: /** */
043: protected final static int SSH_MSG_CHANNEL_FAILURE = 100;
044: private long channelId;
045:
046: /**
047: * Creates a new SshMsgChannelFailure object.
048: *
049: * @param recipientChannelId
050: */
051: public SshMsgChannelFailure(long recipientChannelId) {
052: super (SSH_MSG_CHANNEL_FAILURE);
053: channelId = recipientChannelId;
054: }
055:
056: /**
057: * Creates a new SshMsgChannelFailure object.
058: */
059: public SshMsgChannelFailure() {
060: super (SSH_MSG_CHANNEL_FAILURE);
061: }
062:
063: /**
064: *
065: *
066: * @return
067: */
068: public String getMessageName() {
069: return "SSH_MSG_CHANNEL_FAILURE";
070: }
071:
072: /**
073: *
074: *
075: * @return
076: */
077: public long getRecipientChannelId() {
078: return channelId;
079: }
080:
081: /**
082: *
083: *
084: * @param baw
085: *
086: * @throws InvalidMessageException
087: */
088: protected void constructByteArray(ByteArrayWriter baw)
089: throws InvalidMessageException {
090: try {
091: baw.writeInt(channelId);
092: } catch (IOException ioe) {
093: throw new InvalidMessageException("Invalid message data");
094: }
095: }
096:
097: /**
098: *
099: *
100: * @param bar
101: *
102: * @throws InvalidMessageException
103: */
104: protected void constructMessage(ByteArrayReader bar)
105: throws InvalidMessageException {
106: try {
107: channelId = bar.readInt();
108: } catch (IOException ioe) {
109: throw new InvalidMessageException("Invalid message data");
110: }
111: }
112: }
|