Source Code Cross Referenced for RdpPacket.java in  » Net » Remote-desktop » org » rdesktop » server » rdp » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Remote desktop » org.rdesktop.server.rdp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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;
022:
023:        import java.io.*;
024:
025:        public class RdpPacket extends RdpAbstractPacket {
026:            private byte[] m_bb = null;
027:            private int m_size = -1;
028:            private int m_position = -1;
029:
030:            public RdpPacket(int capacity) {
031:                m_bb = new byte[capacity];
032:                m_size = capacity;
033:                m_position = 0;
034:            }
035:
036:            public int capacity() {
037:                return m_size;
038:            }
039:
040:            public void set8(int where, int what) {
041:                if (where < 0 || where >= m_size) {
042:                    throw new ArrayIndexOutOfBoundsException(
043:                            "memory accessed out of Range!");
044:                }
045:
046:                m_bb[where] = (byte) what;
047:            }
048:
049:            public void set8(int what) {
050:                if (m_position >= m_size) {
051:                    throw new ArrayIndexOutOfBoundsException(
052:                            "memory accessed out of Range!");
053:                }
054:
055:                m_bb[m_position++] = (byte) what;
056:            }
057:
058:            public int get8(int where) {
059:                if (where < 0 || where >= m_size) {
060:                    throw new ArrayIndexOutOfBoundsException(
061:                            "memory accessed out of Range!");
062:                }
063:
064:                return m_bb[where] & 0xff;
065:            }
066:
067:            public int get8() {
068:                if (m_position >= m_size) {
069:                    throw new ArrayIndexOutOfBoundsException(
070:                            "memory accessed out of Range!");
071:                }
072:
073:                return m_bb[m_position++] & 0xff;
074:            }
075:
076:            public void copyFromByteArray(byte[] array, int array_offset,
077:                    int mem_offset, int len) {
078:                if ((array_offset >= array.length)
079:                        || (array_offset + len > array.length)
080:                        || (mem_offset + len > m_size)) {
081:                    throw new ArrayIndexOutOfBoundsException(
082:                            "memory accessed out of Range!");
083:                }
084:
085:                System.arraycopy(array, array_offset, m_bb, mem_offset, len);
086:            }
087:
088:            public void copyToByteArray(byte[] array, int array_offset,
089:                    int mem_offset, int len) {
090:                if ((array_offset >= array.length)
091:                        || (array_offset + len > array.length)
092:                        || (mem_offset + len > m_size)) {
093:                    throw new ArrayIndexOutOfBoundsException(
094:                            "memory accessed out of Range!");
095:                }
096:
097:                System.arraycopy(m_bb, mem_offset, array, array_offset, len);
098:            }
099:
100:            public void copyToPacket(RdpPacket dst, int srcOffset,
101:                    int dstOffset, int len) {
102:                System.arraycopy(m_bb, srcOffset, dst.m_bb, dstOffset, len);
103:            }
104:
105:            public void copyFromPacket(RdpPacket src, int srcOffset,
106:                    int dstOffset, int len) {
107:                System.arraycopy(src.m_bb, srcOffset, m_bb, dstOffset, len);
108:            }
109:
110:            public int getSize() {
111:                return m_size;
112:            }
113:
114:            public int getPosition() {
115:                return m_position;
116:            }
117:
118:            public int getLittleEndian16(int where) {
119:                return (m_bb[where] & 0xff) + ((m_bb[where + 1] & 0xff) << 8);
120:            }
121:
122:            public int getLittleEndian16() {
123:                return (m_bb[m_position++] & 0xff)
124:                        + ((m_bb[m_position++] & 0xff) << 8);
125:            }
126:
127:            public int getBigEndian16(int where) {
128:                return ((m_bb[where] & 0xff) << 8) + (m_bb[where + 1] & 0xff);
129:            }
130:
131:            public int getBigEndian16() {
132:                return ((m_bb[m_position++] & 0xff) << 8)
133:                        + (m_bb[m_position++] & 0xff);
134:            }
135:
136:            public void setLittleEndian16(int where, int what) {
137:                m_bb[where] = (byte) (what & 0xff);
138:                m_bb[where + 1] = (byte) ((what >> 8) & 0xff);
139:            }
140:
141:            public void setLittleEndian16(int what) {
142:                m_bb[m_position++] = (byte) (what & 0xff);
143:                m_bb[m_position++] = (byte) ((what >> 8) & 0xff);
144:            }
145:
146:            public void setBigEndian16(int where, int what) {
147:                m_bb[where] = (byte) ((what >> 8) & 0xff);
148:                m_bb[where + 1] = (byte) (what & 0xff);
149:            }
150:
151:            public void setBigEndian16(int what) {
152:                m_bb[m_position++] = (byte) ((what >> 8) & 0xff);
153:                m_bb[m_position++] = (byte) (what & 0xff);
154:            }
155:
156:            public int getLittleEndian32(int where) {
157:                return (m_bb[where] & 0xff) + ((m_bb[where + 1] & 0xff) << 8)
158:                        + ((m_bb[where + 2] & 0xff) << 16)
159:                        + ((m_bb[where + 3] & 0xff) << 24);
160:            }
161:
162:            public int getLittleEndian32() {
163:                return (m_bb[m_position++] & 0xff)
164:                        + ((m_bb[m_position++] & 0xff) << 8)
165:                        + ((m_bb[m_position++] & 0xff) << 16)
166:                        + ((m_bb[m_position++] & 0xff) << 24);
167:            }
168:
169:            public int getBigEndian32(int where) {
170:                return ((m_bb[where] & 0xff) << 24)
171:                        + ((m_bb[where + 1] & 0xff) << 16)
172:                        + ((m_bb[where + 2] & 0xff) << 8)
173:                        + (m_bb[where + 3] & 0xff);
174:            }
175:
176:            public int getBigEndian32() {
177:                return ((m_bb[m_position++] & 0xff) << 24)
178:                        + ((m_bb[m_position++] & 0xff) << 16)
179:                        + ((m_bb[m_position++] & 0xff) << 8)
180:                        + (m_bb[m_position++] & 0xff);
181:            }
182:
183:            public void setLittleEndian32(int where, int what) {
184:                m_bb[where] = (byte) (what & 0xff);
185:                m_bb[where + 1] = (byte) ((what >> 8) & 0xff);
186:                m_bb[where + 2] = (byte) ((what >> 16) & 0xff);
187:                m_bb[where + 3] = (byte) ((what >> 24) & 0xff);
188:            }
189:
190:            public void setLittleEndian32(int what) {
191:                m_bb[m_position++] = (byte) (what & 0xff);
192:                m_bb[m_position++] = (byte) ((what >> 8) & 0xff);
193:                m_bb[m_position++] = (byte) ((what >> 16) & 0xff);
194:                m_bb[m_position++] = (byte) ((what >> 24) & 0xff);
195:            }
196:
197:            public void setBigEndian32(int where, int what) {
198:                m_bb[where] = (byte) ((what >> 24) & 0xff);
199:                m_bb[where + 1] = (byte) ((what >> 16) & 0xff);
200:                m_bb[where + 2] = (byte) ((what >> 8) & 0xff);
201:                m_bb[where + 3] = (byte) (what & 0xff);
202:            }
203:
204:            public void setBigEndian32(int what) {
205:                m_bb[m_position++] = (byte) ((what >> 24) & 0xff);
206:                m_bb[m_position++] = (byte) ((what >> 16) & 0xff);
207:                m_bb[m_position++] = (byte) ((what >> 8) & 0xff);
208:                m_bb[m_position++] = (byte) (what & 0xff);
209:            }
210:
211:            public void incrementPosition(int length) {
212:                if ((length > m_size) || (length + m_position > m_size)
213:                        || (length < 0)) {
214:                    throw new ArrayIndexOutOfBoundsException();
215:                }
216:
217:                m_position += length;
218:            }
219:
220:            public void setPosition(int position) {
221:                if ((position > m_size) || (position < 0)) {
222:                    throw new ArrayIndexOutOfBoundsException();
223:                }
224:
225:                m_position = position;
226:            }
227:
228:            public RdpPacket copy() {
229:                RdpPacket dup = new RdpPacket(m_bb.length);
230:                dup.m_mcs = m_mcs;
231:                dup.m_secure = m_secure;
232:                dup.m_rdp = m_rdp;
233:                dup.m_channel = m_channel;
234:                dup.m_start = m_start;
235:                dup.m_end = m_end;
236:                dup.m_size = m_size;
237:                dup.m_position = m_position;
238:                System.arraycopy(m_bb, 0, dup.m_bb, 0, m_bb.length);
239:                return dup;
240:            }
241:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.