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 SshMsgChannelOpenFailure extends SshMessage {
042: /** */
043: protected final static int SSH_MSG_CHANNEL_OPEN_FAILURE = 92;
044:
045: /** */
046: protected final static long SSH_OPEN_ADMINISTRATIVELY_PROHIBITED = 1;
047:
048: /** */
049: protected final static long SSH_OPEN_CONNECT_FAILED = 2;
050:
051: /** */
052: protected final static long SSH_OPEN_UNKNOWN_CHANNEL_TYPE = 3;
053:
054: /** */
055: protected final static long SSH_OPEN_RESOURCE_SHORTAGE = 4;
056: private String additional;
057: private String languageTag;
058: private long reasonCode;
059: private long recipientChannel;
060:
061: /**
062: * Creates a new SshMsgChannelOpenFailure object.
063: *
064: * @param recipientChannel
065: * @param reasonCode
066: * @param additional
067: * @param languageTag
068: */
069: public SshMsgChannelOpenFailure(long recipientChannel,
070: long reasonCode, String additional, String languageTag) {
071: super (SSH_MSG_CHANNEL_OPEN_FAILURE);
072: this .recipientChannel = recipientChannel;
073: this .reasonCode = reasonCode;
074: this .additional = additional;
075: this .languageTag = languageTag;
076: }
077:
078: /**
079: * Creates a new SshMsgChannelOpenFailure object.
080: */
081: public SshMsgChannelOpenFailure() {
082: super (SSH_MSG_CHANNEL_OPEN_FAILURE);
083: }
084:
085: /**
086: *
087: *
088: * @return
089: */
090: public String getAdditionalText() {
091: return additional;
092: }
093:
094: /**
095: *
096: *
097: * @return
098: */
099: public String getLanguageTag() {
100: return languageTag;
101: }
102:
103: /**
104: *
105: *
106: * @return
107: */
108: public String getMessageName() {
109: return "SSH_MSG_CHANNEL_OPEN_FAILURE";
110: }
111:
112: /**
113: *
114: *
115: * @return
116: */
117: public long getReasonCode() {
118: return reasonCode;
119: }
120:
121: /**
122: *
123: *
124: * @return
125: */
126: public long getRecipientChannel() {
127: return recipientChannel;
128: }
129:
130: /**
131: *
132: *
133: * @param baw
134: *
135: * @throws InvalidMessageException
136: */
137: protected void constructByteArray(ByteArrayWriter baw)
138: throws InvalidMessageException {
139: try {
140: baw.writeInt(recipientChannel);
141: baw.writeInt(reasonCode);
142: baw.writeString(additional);
143: baw.writeString(languageTag);
144: } catch (IOException ioe) {
145: throw new InvalidMessageException("Invalid message data");
146: }
147: }
148:
149: /**
150: *
151: *
152: * @param bar
153: *
154: * @throws InvalidMessageException
155: */
156: protected void constructMessage(ByteArrayReader bar)
157: throws InvalidMessageException {
158: try {
159: recipientChannel = bar.readInt();
160: reasonCode = bar.readInt();
161: additional = bar.readString();
162: languageTag = bar.readString();
163: } catch (IOException ioe) {
164: throw new InvalidMessageException("Invalid message data");
165: }
166: }
167: }
|