private NdrBuffer ServerAlive ( final NetworkDataRepresentation ndr ) { logger.info ( "Oxid Object: ServerAlive" ); final byte[] buffer = new byte[32]; //16 + 16=just in case final NdrBuffer ndrBuffer = new NdrBuffer ( buffer, 0 ); ndrBuffer.enc_ndr_long ( 0 ); ndrBuffer.enc_ndr_long ( 0 ); ndrBuffer.enc_ndr_long ( 0 ); ndrBuffer.enc_ndr_long ( 0 ); return ndrBuffer; }
public void encode ( NetworkDataRepresentation ndr, NdrBuffer dst ) { int padding = dst.align ( 4, (byte)0 ); dst.enc_ndr_small ( authenticationService ); dst.enc_ndr_small ( protectionLevel ); dst.enc_ndr_small ( padding ); dst.enc_ndr_small ( 0 ); //Reserved dst.enc_ndr_long ( contextId ); System.arraycopy ( body, 0, dst.getBuffer (), dst.getIndex (), body.length ); //dst.index += body.length; dst.advance ( body.length ); }
public void receive(NdrBuffer buffer) throws IOException { if (!attached) throw new RpcException("Transport not attached."); if (input == null) input = socket.getInputStream(); buffer.length = (input.read(buffer.getBuffer(), 0, buffer.getCapacity())); }
public void decode(NetworkDataRepresentation ndr, NdrBuffer src) { src.align(4); authenticationService = src.dec_ndr_small(); protectionLevel = src.dec_ndr_small(); src.dec_ndr_small(); // padding count contextId = src.dec_ndr_long(); System.arraycopy(src.getBuffer(), src.getIndex(), body, 0, body.length); src.index += body.length; }
@Override public void serializeData ( final NetworkDataRepresentation ndr, Object value, final List defferedPointers, final int FLAG ) { if ( value == null ) { value = new Double ( Double.NaN ); } ndr.getBuffer ().align ( 8 ); Encdec.enc_doublele ( ( (Double)value ).doubleValue (), ndr.getBuffer ().getBuffer (), ndr.getBuffer ().getIndex () ); ndr.getBuffer ().advance ( 8 ); }
private AuthenticationVerifier detachAuthentication2(NdrBuffer buffer) throws IOException { try { //NdrBuffer buffer = ndr.getBuffer(); buffer.setIndex(ConnectionOrientedPdu.AUTH_LENGTH_OFFSET); int length = buffer.dec_ndr_short();//ndr.readUnsignedShort(); // auth body size int index = 20; buffer.setIndex(index); //exactly at the auth type. AuthenticationVerifier verifier = new AuthenticationVerifier(length); verifier.decode(ndr, buffer); buffer.setIndex(index + 2); // auth padding length = index - buffer.dec_ndr_small();//ndr.readUnsignedSmall(); buffer.setIndex(ConnectionOrientedPdu.FRAG_LENGTH_OFFSET); buffer.enc_ndr_short(length); buffer.enc_ndr_short(0); //ndr.writeUnsignedShort(length); //ndr.writeUnsignedShort(0); buffer.setIndex(length); return verifier; } catch (Exception ex) { throw new IOException("Error stripping authentication from PDU: " + ex); } }
private void attachAuthentication(AuthenticationVerifier verifier) throws IOException { try { NdrBuffer buffer = ndr.getBuffer(); int length = buffer.getLength(); buffer.setIndex(length); verifier.encode(ndr, buffer); length = buffer.getLength(); buffer.setIndex(ConnectionOrientedPdu.FRAG_LENGTH_OFFSET); ndr.writeUnsignedShort(length); ndr.writeUnsignedShort(verifier.body.length); // buffer.setIndex(ConnectionOrientedPdu.FLAGS_OFFSET); // ndr.writeUnsignedSmall(0); } catch (Exception ex) { throw new IOException("Error attaching authentication to PDU: " + ex.getMessage()); } }
public void receive(NdrBuffer buffer) throws IOException { byte[] buf = buffer.getBuffer(); int off = 0, bytes_to_read, n; if (!attached) throw new RpcException("Transport not attached."); if (first) { n = in.read(buf, 0, 1024); /* TransactNamedPipe */ first = false; } else { /* Plain read */ n = (in2).read(buf, off, buf.length); } buffer.setIndex(ConnectionOrientedPdu.FRAG_LENGTH_OFFSET); bytes_to_read = buffer.dec_ndr_short(); off += n; bytes_to_read -= n; while (bytes_to_read > 0) { n = (in2).read(buf, off, bytes_to_read); off += n; bytes_to_read -= n; } buffer.length = off; }
public void encode(NetworkDataRepresentation ndr, NdrBuffer dst) throws NdrException { dst.enc_ndr_long(timeLow); dst.enc_ndr_short(timeMid); dst.enc_ndr_short(timeHighAndVersion); dst.enc_ndr_small(clockSeqHighAndReserved); dst.enc_ndr_small(clockSeqLow); System.arraycopy(node, 0, dst.buf, dst.index, 6); dst.index += 6; } public void decode(NetworkDataRepresentation ndr, NdrBuffer src) throws NdrException {
public NdrBuffer derive(int idx) { NdrBuffer nb = new NdrBuffer(buf, start); nb.index = idx; nb.deferred = deferred; return nb; }
protected void writeBody(NetworkDataRepresentation ndr) { int maxTransmitFragment = getMaxTransmitFragment(); int maxReceiveFragment = getMaxReceiveFragment(); ndr.writeUnsignedShort((maxTransmitFragment == -1) ? ndr.getBuffer().getCapacity() : maxTransmitFragment); ndr.writeUnsignedShort((maxReceiveFragment == -1) ? ndr.getBuffer().getCapacity() : maxReceiveFragment); ndr.writeUnsignedLong(getAssociationGroupId()); Port secondaryAddress = getSecondaryAddress(); if (secondaryAddress == null) secondaryAddress = new Port(); secondaryAddress.write(ndr); ndr.getBuffer().align(4); PresentationResult[] resultList = getResultList(); int count = resultList.length; ndr.writeUnsignedSmall((short) count); for (int i = 0; i < count; i++) { resultList[i].write(ndr); } }
@Override public void decode ( final NetworkDataRepresentation ndr, final NdrBuffer src ) throws NdrException { this.timeLow = src.dec_ndr_long (); this.timeMid = src.dec_ndr_short (); this.timeHighAndVersion = src.dec_ndr_short (); this.clockSeqHighAndReserved = src.dec_ndr_small (); this.clockSeqLow = src.dec_ndr_small (); System.arraycopy ( src.buf, src.index, this.node, 0, 6 ); src.index += 6; }
public void writeUnsignedLong ( int value ) { buf.enc_ndr_long ( value ); }
public void transmit ( ConnectionOrientedPdu pdu, Transport transport ) throws IOException { if ( ! ( pdu instanceof Fragmentable ) ) { transmitFragment ( pdu, transport ); return; } Iterator fragments = ( (Fragmentable)pdu ).fragment ( transmitBuffer.getCapacity () ); while ( fragments.hasNext () ) { transmitFragment ( (ConnectionOrientedPdu)fragments.next (), transport ); } }
protected void writeBody(NetworkDataRepresentation ndr) { NdrBuffer dst = ndr.getBuffer(); dst.enc_ndr_long(getAllocationHint()); dst.enc_ndr_short(getContextId()); dst.enc_ndr_short(getOpnum()); if (getFlag(PFC_OBJECT_UUID)) { try { getObject().encode(ndr, ndr.getBuffer()); } catch (NdrException ne) { }; } }
protected void readBody(NetworkDataRepresentation ndr) { UUID object = null; NdrBuffer src = ndr.getBuffer(); setAllocationHint(src.dec_ndr_long()); setContextId(src.dec_ndr_short()); setOpnum(src.dec_ndr_short()); if (getFlag(PFC_OBJECT_UUID)) { object = new UUID(); try { object.decode(ndr, src); } catch (NdrException ne) { } } setObject(object); }
public String toString () { return "start=" + start + ",index=" + index + ",length=" + getLength (); } }
public int readUnsignedLong() { return buf.dec_ndr_long(); } public void writeUnsignedSmall(int value) {
public void serializeData(NetworkDataRepresentation ndr,Object value,List defferedPointers,int FLAG) { if (value == null) { value = new Float(Float.NaN); } ndr.getBuffer().align(4); Encdec.enc_floatle(((Float)value).floatValue(), ndr.getBuffer().getBuffer(),ndr.getBuffer().getIndex()); ndr.getBuffer().advance(4); } public Object deserializeData(NetworkDataRepresentation ndr,List defferedPointers, Map additionalData, int FLAG)