public void read(NetworkDataRepresentation ndr) { int length = ndr.readUnsignedShort(); if (length > 0) { NdrBuffer buf = ndr.getBuffer(); char[] portSpec = new char[length - 1]; ndr.readCharacterArray(portSpec, 0, portSpec.length); ndr.readUnsignedSmall(); // null terminator this.portSpec = new String(portSpec); } else { this.portSpec = null; } }
public void read(NetworkDataRepresentation ndr) { ndr.readOctetArray(policyhandle,0,20); //pointer to action taken ndr.readUnsignedLong(); actiontaken = ndr.readUnsignedLong(); int hresult = ndr.readUnsignedLong(); if (hresult != 0) { throw new JIRuntimeException(hresult); } }
@Override public void write ( final NetworkDataRepresentation ndr ) { ndr.setBuffer ( this.buffer ); //this buffer is prepared via read. }
public void write(NetworkDataRepresentation ndr) { char[] spec; if (portSpec != null) { spec = new char[portSpec.length() + 1]; portSpec.getChars(0, portSpec.length(), spec, 0); } else { spec = new char[0]; } ndr.writeUnsignedShort(spec.length); if (spec.length > 0) ndr.writeCharacterArray(spec, 0, spec.length); }
protected void readBody(NetworkDataRepresentation ndr) { setAllocationHint(ndr.readUnsignedLong()); setContextId(ndr.readUnsignedShort()); setCancelCount(ndr.readUnsignedSmall()); setStatus((int) ndr.readUnsignedLong()); }
protected void readHeader(NetworkDataRepresentation ndr) { if (ndr.readUnsignedSmall() != CONNECTION_ORIENTED_MAJOR_VERSION) { throw new IllegalStateException("Version mismatch."); } // read minor version setMinorVersion(ndr.readUnsignedSmall()); if (getType() != ndr.readUnsignedSmall()) { throw new IllegalArgumentException("Incorrect PDU type."); } setFlags(ndr.readUnsignedSmall()); Format format = ndr.readFormat(false); setFormat(format); ndr.setFormat(format); setFragmentLength(ndr.readUnsignedShort()); setAuthenticatorLength(ndr.readUnsignedShort()); this.callId = ((int) ndr.readUnsignedLong()); }
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) { ndr.setBuffer(dst); ndr.setFormat(getFormat()); writePdu(ndr); NdrBuffer buffer = ndr.getBuffer(); int length = buffer.getLength(); setFragmentLength(length); // write the header lengths, now that we know them. buffer.setIndex(FRAG_LENGTH_OFFSET); ndr.writeUnsignedShort(length); ndr.writeUnsignedShort(getAuthenticatorLength()); buffer.setIndex(length); }
/** Returns an Interface Pointer representation from raw bytes. * * @exclude * @param session * @param rawBytes * @return * @throws JIException */ public static IJIComObject instantiateComObject(JISession session,byte[] rawBytes, String ipAddress) throws JIException { NetworkDataRepresentation ndr = new NetworkDataRepresentation(); NdrBuffer ndrBuffer = new NdrBuffer(rawBytes,0); ndr.setBuffer(ndrBuffer); ndrBuffer.length = rawBytes.length; //this is a brand new session. if (session.getStub() == null) { JIComServer comServer = new JIComServer(session,JIInterfacePointer.decode(ndr, new ArrayList(), JIFlags.FLAG_REPRESENTATION_INTERFACEPTR_DECODE2, new HashMap()),ipAddress); return comServer.getInstance(); } else { IJIComObject retval = instantiateComObject(session, JIInterfacePointer.decode(ndr, new ArrayList(), JIFlags.FLAG_REPRESENTATION_INTERFACEPTR_DECODE2, new HashMap())); //increasing the reference count. retval.addRef(); return retval; } }
ndr.readUnsignedLong();//eating max length ndr.readUnsignedLong();//eating length in bytes int actuallength = ndr.readUnsignedLong() * 2; byte[] buffer = new byte[actuallength]; int i = 0; while (i < actuallength) retVal = ndr.readUnsignedSmall(); buffer[i] = (byte)retVal; i++; int actuallength = ndr.readUnsignedLong(); //max length if (actuallength == 0) ndr.readUnsignedLong();//eating offset ndr.readUnsignedLong();//eating actuallength again ndr.readCharacterArray(ret,0,actuallength*2 - 2); if (ret[ret.length - 1] == '0') ndr.readUnsignedShort(); int maxlength = ndr.readUnsignedLong(); if (maxlength == 0) ndr.readUnsignedLong();//eating offset int actuallength = ndr.readUnsignedLong() * 2; byte buffer[] = new byte[actuallength - 2]; int i = 0;
ndr.writeUnsignedLong(strBytes.length/2); ndr.writeUnsignedLong(strBytes.length); ndr.writeUnsignedLong(strBytes.length/2); ndr.writeUnsignedSmall(strBytes[i]); i++; ndr.writeUnsignedLong(strlen + 1); ndr.writeUnsignedLong(0); ndr.writeUnsignedLong(strlen + 1); if (str.length() != 0) ndr.writeCharacterArray(str.toCharArray(),0,str.length()); ndr.writeUnsignedSmall(0); ndr.writeUnsignedShort(0); ndr.writeUnsignedLong(strBytes.length/2 + 1); ndr.writeUnsignedLong(0); ndr.writeUnsignedLong(strBytes.length/2 + 1); ndr.writeUnsignedSmall(strBytes[i]); i++; ndr.writeUnsignedShort(0);
ndr.writeUnsignedLong ( 0 ); ndr.writeCharacterArray ( this.monikerName.toCharArray (), 0, this.monikerName.length () ); // Object Name ndr.writeUnsignedLong ( 0 ); // Minterface pointer ndr.writeUnsignedLong ( this.impersonationLevel ); // impersonation level ndr.writeUnsignedLong ( this.mode ); //mode, when object name , interface pointer are not null , this is passed directly to IPersistFile:Load ndr.writeUnsignedLong ( 2 ); //No. of IIDs requested. ndr.writeUnsignedLong ( new Object ().hashCode () ); ndr.writeUnsignedLong ( 2 ); //Array length ndr.writeUnsignedLong ( 1 ); //Protocol Sequences available ndr.writeUnsignedLong ( 1 ); //Array length ndr.writeUnsignedShort ( 7 ); //TCP ndr.writeUnsignedShort ( address[0] ); ndr.writeUnsignedShort ( address[1] ); ndr.writeUnsignedShort ( address[2] ); ndr.writeUnsignedShort ( address[3] ); ndr.writeUnsignedShort ( 0 );
final NetworkDataRepresentation ndr = new NetworkDataRepresentation (); workerObject.setCurrentIID ( this.currentIID ); if ( request instanceof RequestCoPdu ) ndr.setFormat ( ( (RequestCoPdu)request ).getFormat () ); workerObject.setOpnum ( ( (RequestCoPdu)request ).getOpnum () ); responseCoPdu.setCallId ( ( (RequestCoPdu)request ).getCallId () ); ( (NdrObject)workerObject ).encode ( ndr, null ); final int length = ndr.getBuffer ().length > ndr.getBuffer ().index ? ndr.getBuffer ().length : ndr.getBuffer ().index; System.arraycopy ( ndr.getBuffer ().getBuffer (), 0, responsebytes, 0, responsebytes.length - 4 ); responseCoPdu.setStub ( responsebytes );
protected void readStub(NetworkDataRepresentation ndr) { ndr.getBuffer().align(8); byte[] stub = null; int length = getFragmentLength() - ndr.getBuffer().getIndex(); if (length > 0) { stub = new byte[length]; ndr.readOctetArray(stub, 0, length); } setStub(stub); }
NetworkDataRepresentation ndr = new NetworkDataRepresentation(); ndrobj.encode(ndr, buffer); byte[] stub = new byte[buffer.getLength()]; /* yuk */ ConnectionOrientedPdu reply = receive(); if (reply instanceof ResponseCoPdu) { ndr.setFormat(reply.getFormat());
@Override public void serializeData ( final NetworkDataRepresentation ndr, final Object value, final List defferedPointers, final int FLAG ) { try { ( (UUID)value ).encode ( ndr, ndr.getBuffer () ); } catch ( final NdrException e ) { logger.warn ( "serializeData", e ); } }
public void read(NetworkDataRepresentation ndr) { ndr.getBuffer().align(4); result = ndr.readUnsignedShort(); reason = ndr.readUnsignedShort(); //if (result == ACCEPTANCE) //commenting this since the entire packet should be decoded VRC { transferSyntax = new PresentationSyntax(); try { transferSyntax.decode(ndr, ndr.getBuffer()); } catch (NdrException ne) { } } }
protected void writeStub(NetworkDataRepresentation ndr) { NdrBuffer buf = ndr.getBuffer(); buf.align(8, (byte) 0); byte[] stub = getStub(); if (stub != null) ndr.writeOctetArray(stub, 0, stub.length); }
@Override public Object deserializeData ( final NetworkDataRepresentation ndr, final List defferedPointers, final Map additionalData, final int FLAG ) { final Byte c = new Byte ( (byte)ndr.readUnsignedSmall () ); return c; }
public DefaultConnection(int transmitLength, int receiveLength) { ndr = new NetworkDataRepresentation(); transmitBuffer = new NdrBuffer(new byte[transmitLength], 0); receiveBuffer = new NdrBuffer(new byte[receiveLength], 0); }
public Object deserializeData(NetworkDataRepresentation ndr,List defferedPointers, Map additionalData, int FLAG) { Short s = new Short((short)ndr.readUnsignedShort()); return s; }