001: ///////////////////////////////////////////////////////////////////////////////
002: //
003: // This program is free software; you can redistribute it and/or modify
004: // it under the terms of the GNU General Public License and GNU Library
005: // General Public License as published by the Free Software Foundation;
006: // either version 2, or (at your option) any later version.
007: //
008: // This program is distributed in the hope that it will be useful,
009: // but WITHOUT ANY WARRANTY; without even the implied warranty of
010: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: // GNU General Public License and GNU Library General Public License
012: // for more details.
013: //
014: // You should have received a copy of the GNU General Public License
015: // and GNU Library General Public License along with this program; if
016: // not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
017: // MA 02139, USA.
018: //
019: ///////////////////////////////////////////////////////////////////////////////
020:
021: package org.rdesktop.server.rdp.rdp5;
022:
023: import org.rdesktop.server.rdp.*;
024: import org.rdesktop.server.rdp.crypto.*;
025:
026: public class Rdp5 extends RdpProto {
027: private VChannels m_channels;
028:
029: public Rdp5(VChannels channels) {
030: super (channels);
031: m_channels = channels;
032: }
033:
034: protected void rdp5_process_channel(RdpPacket s, int channelno) {
035: VChannel channel = m_channels
036: .find_channel_by_channelno(channelno);
037: if (channel != null) {
038: try {
039: channel.process(s);
040: } catch (Exception e) {
041: }
042: }
043: }
044:
045: public void rdp5_process(RdpPacket s, boolean e)
046: throws RdpDesktopException, RdpOrderException,
047: CryptoException {
048: rdp5_process(s, e, false);
049: }
050:
051: public void rdp5_process(RdpPacket s, boolean encryption,
052: boolean shortform) throws RdpDesktopException,
053: RdpOrderException, CryptoException {
054: int length;
055: int count;
056: int type;
057: int next;
058:
059: if (encryption == true) {
060: s.incrementPosition(shortform ? 6 : 7 /* XXX HACK */); /* signature */
061: byte[] data = new byte[s.getSize() - s.getPosition()];
062: s.copyToByteArray(data, 0, s.getPosition(), data.length);
063: byte[] packet = m_secureLayer.decrypt(data);
064: }
065:
066: while (s.getPosition() < s.getEnd()) {
067: type = s.get8();
068: length = s.getLittleEndian16();
069: /* next_packet = */next = s.getPosition() + length;
070: switch (type) {
071: case 0: {
072: count = s.getLittleEndian16();
073: m_orders.processOrders(s, next, count);
074: break;
075: }
076: case 1: {
077: s.incrementPosition(2);
078: processBitmapUpdates(s);
079: break;
080: }
081: case 2: {
082: s.incrementPosition(2);
083: processPalette(s);
084: break;
085: }
086: case 3: {
087: break;
088: }
089: case 5: {
090: process_null_system_pointer_pdu(s);
091: break;
092: }
093: case 6: {
094: break;
095: }
096: case 9: {
097: process_colour_pointer_pdu(s);
098: break;
099: }
100: case 10: {
101: process_cached_pointer_pdu(s);
102: break;
103: }
104: default: {
105: break;
106: }
107: }
108:
109: s.setPosition(next);
110: }
111: }
112: }
|