01: /* jcifs smb client library in Java
02: * Copyright (C) 2000 "Michael B. Allen" <jcifs at samba dot org>
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package jcifs.netbios;
20:
21: import java.io.IOException;
22: import java.io.InputStream;
23:
24: class SessionRequestPacket extends SessionServicePacket {
25:
26: private Name calledName, callingName;
27:
28: SessionRequestPacket() {
29: calledName = new Name();
30: callingName = new Name();
31: }
32:
33: SessionRequestPacket(Name calledName, Name callingName) {
34: type = SESSION_REQUEST;
35: this .calledName = calledName;
36: this .callingName = callingName;
37: }
38:
39: int writeTrailerWireFormat(byte[] dst, int dstIndex) {
40: int start = dstIndex;
41: dstIndex += calledName.writeWireFormat(dst, dstIndex);
42: dstIndex += callingName.writeWireFormat(dst, dstIndex);
43: return dstIndex - start;
44: }
45:
46: int readTrailerWireFormat(InputStream in, byte[] buffer,
47: int bufferIndex) throws IOException {
48: int start = bufferIndex;
49: if (in.read(buffer, bufferIndex, length) != length) {
50: throw new IOException("invalid session request wire format");
51: }
52: bufferIndex += calledName.readWireFormat(buffer, bufferIndex);
53: bufferIndex += callingName.readWireFormat(buffer, bufferIndex);
54: return bufferIndex - start;
55: }
56: }
|