KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jcifs > dce > rpc


1 package jcifs.dcerpc;
2
3 import jcifs.dcerpc.ndr.*;
4 import jcifs.util.*;
5
6 public class rpc {
7
8     public static class uuid_t extends NdrObject {
9
10         public int time_low;
11         public short time_mid;
12         public short time_hi_and_version;
13         public byte clock_seq_hi_and_reserved;
14         public byte clock_seq_low;
15         public byte[] node;
16
17         public void encode(NdrBuffer _dst) throws NdrException {
18             _dst.align(4);
19             _dst.enc_ndr_long(time_low);
20             _dst.enc_ndr_short(time_mid);
21             _dst.enc_ndr_short(time_hi_and_version);
22             _dst.enc_ndr_small(clock_seq_hi_and_reserved);
23             _dst.enc_ndr_small(clock_seq_low);
24             int _nodes = 6;
25             int _nodei = _dst.index;
26             _dst.advance(1 * _nodes);
27
28             _dst = _dst.derive(_nodei);
29             for (int _i = 0; _i < _nodes; _i++) {
30                 _dst.enc_ndr_small(node[_i]);
31             }
32         }
33         public void decode(NdrBuffer _src) throws NdrException {
34             _src.align(4);
35             time_low = (int)_src.dec_ndr_long();
36             time_mid = (short)_src.dec_ndr_short();
37             time_hi_and_version = (short)_src.dec_ndr_short();
38             clock_seq_hi_and_reserved = (byte)_src.dec_ndr_small();
39             clock_seq_low = (byte)_src.dec_ndr_small();
40             int _nodes = 6;
41             int _nodei = _src.index;
42             _src.advance(1 * _nodes);
43
44             if (node == null) {
45                 if (_nodes < 0 || _nodes > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE );
46                 node = new byte[_nodes];
47             }
48             _src = _src.derive(_nodei);
49             for (int _i = 0; _i < _nodes; _i++) {
50                 node[_i] = (byte)_src.dec_ndr_small();
51             }
52         }
53     }
54     public static class policy_handle extends NdrObject {
55
56         public int type;
57         public uuid_t uuid;
58
59         public void encode(NdrBuffer _dst) throws NdrException {
60             _dst.align(4);
61             _dst.enc_ndr_long(type);
62             _dst.enc_ndr_long(uuid.time_low);
63             _dst.enc_ndr_short(uuid.time_mid);
64             _dst.enc_ndr_short(uuid.time_hi_and_version);
65             _dst.enc_ndr_small(uuid.clock_seq_hi_and_reserved);
66             _dst.enc_ndr_small(uuid.clock_seq_low);
67             int _uuid_nodes = 6;
68             int _uuid_nodei = _dst.index;
69             _dst.advance(1 * _uuid_nodes);
70
71             _dst = _dst.derive(_uuid_nodei);
72             for (int _i = 0; _i < _uuid_nodes; _i++) {
73                 _dst.enc_ndr_small(uuid.node[_i]);
74             }
75         }
76         public void decode(NdrBuffer _src) throws NdrException {
77             _src.align(4);
78             type = (int)_src.dec_ndr_long();
79             _src.align(4);
80             if (uuid == null) {
81                 uuid = new uuid_t();
82             }
83             uuid.time_low = (int)_src.dec_ndr_long();
84             uuid.time_mid = (short)_src.dec_ndr_short();
85             uuid.time_hi_and_version = (short)_src.dec_ndr_short();
86             uuid.clock_seq_hi_and_reserved = (byte)_src.dec_ndr_small();
87             uuid.clock_seq_low = (byte)_src.dec_ndr_small();
88             int _uuid_nodes = 6;
89             int _uuid_nodei = _src.index;
90             _src.advance(1 * _uuid_nodes);
91
92             if (uuid.node == null) {
93                 if (_uuid_nodes < 0 || _uuid_nodes > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE );
94                 uuid.node = new byte[_uuid_nodes];
95             }
96             _src = _src.derive(_uuid_nodei);
97             for (int _i = 0; _i < _uuid_nodes; _i++) {
98                 uuid.node[_i] = (byte)_src.dec_ndr_small();
99             }
100         }
101     }
102     public static class unicode_string extends NdrObject {
103
104         public short length;
105         public short maximum_length;
106         public short[] buffer;
107
108         public void encode(NdrBuffer _dst) throws NdrException {
109             _dst.align(4);
110             _dst.enc_ndr_short(length);
111             _dst.enc_ndr_short(maximum_length);
112             _dst.enc_ndr_referent(buffer, 1);
113
114             if (buffer != null) {
115                 _dst = _dst.deferred;
116                 int _bufferl = length / 2;
117                 int _buffers = maximum_length / 2;
118                 _dst.enc_ndr_long(_buffers);
119                 _dst.enc_ndr_long(0);
120                 _dst.enc_ndr_long(_bufferl);
121                 int _bufferi = _dst.index;
122                 _dst.advance(2 * _bufferl);
123
124                 _dst = _dst.derive(_bufferi);
125                 for (int _i = 0; _i < _bufferl; _i++) {
126                     _dst.enc_ndr_short(buffer[_i]);
127                 }
128             }
129         }
130         public void decode(NdrBuffer _src) throws NdrException {
131             _src.align(4);
132             length = (short)_src.dec_ndr_short();
133             maximum_length = (short)_src.dec_ndr_short();
134             int _bufferp = _src.dec_ndr_long();
135
136             if (_bufferp != 0) {
137                 _src = _src.deferred;
138                 int _buffers = _src.dec_ndr_long();
139                 _src.dec_ndr_long();
140                 int _bufferl = _src.dec_ndr_long();
141                 int _bufferi = _src.index;
142                 _src.advance(2 * _bufferl);
143
144                 if (buffer == null) {
145                     if (_buffers < 0 || _buffers > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE );
146                     buffer = new short[_buffers];
147                 }
148                 _src = _src.derive(_bufferi);
149                 for (int _i = 0; _i < _bufferl; _i++) {
150                     buffer[_i] = (short)_src.dec_ndr_short();
151                 }
152             }
153         }
154     }
155     public static class sid_t extends NdrObject {
156
157         public byte revision;
158         public byte sub_authority_count;
159         public byte[] identifier_authority;
160         public int[] sub_authority;
161
162         public void encode(NdrBuffer _dst) throws NdrException {
163             _dst.align(4);
164             int _sub_authoritys = sub_authority_count;
165             _dst.enc_ndr_long(_sub_authoritys);
166             _dst.enc_ndr_small(revision);
167             _dst.enc_ndr_small(sub_authority_count);
168             int _identifier_authoritys = 6;
169             int _identifier_authorityi = _dst.index;
170             _dst.advance(1 * _identifier_authoritys);
171             int _sub_authorityi = _dst.index;
172             _dst.advance(4 * _sub_authoritys);
173
174             _dst = _dst.derive(_identifier_authorityi);
175             for (int _i = 0; _i < _identifier_authoritys; _i++) {
176                 _dst.enc_ndr_small(identifier_authority[_i]);
177             }
178             _dst = _dst.derive(_sub_authorityi);
179             for (int _i = 0; _i < _sub_authoritys; _i++) {
180                 _dst.enc_ndr_long(sub_authority[_i]);
181             }
182         }
183         public void decode(NdrBuffer _src) throws NdrException {
184             _src.align(4);
185             int _sub_authoritys = _src.dec_ndr_long();
186             revision = (byte)_src.dec_ndr_small();
187             sub_authority_count = (byte)_src.dec_ndr_small();
188             int _identifier_authoritys = 6;
189             int _identifier_authorityi = _src.index;
190             _src.advance(1 * _identifier_authoritys);
191             int _sub_authorityi = _src.index;
192             _src.advance(4 * _sub_authoritys);
193
194             if (identifier_authority == null) {
195                 if (_identifier_authoritys < 0 || _identifier_authoritys > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE );
196                 identifier_authority = new byte[_identifier_authoritys];
197             }
198             _src = _src.derive(_identifier_authorityi);
199             for (int _i = 0; _i < _identifier_authoritys; _i++) {
200                 identifier_authority[_i] = (byte)_src.dec_ndr_small();
201             }
202             if (sub_authority == null) {
203                 if (_sub_authoritys < 0 || _sub_authoritys > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE );
204                 sub_authority = new int[_sub_authoritys];
205             }
206             _src = _src.derive(_sub_authorityi);
207             for (int _i = 0; _i < _sub_authoritys; _i++) {
208                 sub_authority[_i] = (int)_src.dec_ndr_long();
209             }
210         }
211     }
212 }
213
Popular Tags