当前位置: 首页>>代码示例>>Java>>正文


Java Encdec.dec_uint16be方法代码示例

本文整理汇总了Java中jcifs.util.Encdec.dec_uint16be方法的典型用法代码示例。如果您正苦于以下问题:Java Encdec.dec_uint16be方法的具体用法?Java Encdec.dec_uint16be怎么用?Java Encdec.dec_uint16be使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jcifs.util.Encdec的用法示例。


在下文中一共展示了Encdec.dec_uint16be方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: negotiatePeek

import jcifs.util.Encdec; //导入方法依赖的package包/类
/**
 * @throws SocketException
 * @throws IOException
 */
private void negotiatePeek () throws SocketException, IOException {
    /*
     * Note the Transport thread isn't running yet so we can
     * read from the socket here.
     */
    try {
        this.socket.setSoTimeout(this.transportContext.getConfig().getConnTimeout());
        if ( peekKey() == null ) /* try to read header */
            throw new IOException("transport closed in negotiate");
    }
    finally {
        this.socket.setSoTimeout(this.transportContext.getConfig().getSoTimeout());
    }
    int size = Encdec.dec_uint16be(this.sbuf, 2) & 0xFFFF;
    if ( size < 33 || ( 4 + size ) > this.sbuf.length ) {
        throw new IOException("Invalid payload size: " + size);
    }
    int hdrSize = this.smb2 ? Smb2Constants.SMB2_HEADER_LENGTH : SMB1_HEADER_LENGTH;
    readn(this.in, this.sbuf, 4 + hdrSize, size - hdrSize);
    log.trace("Read negotiate response");
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:26,代码来源:SmbTransportImpl.java

示例2: doSkip

import jcifs.util.Encdec; //导入方法依赖的package包/类
@Override
protected void doSkip ( Long key ) throws IOException {
    synchronized ( this.inLock ) {
        int size = Encdec.dec_uint16be(this.sbuf, 2) & 0xFFFF;
        if ( size < 33 || ( 4 + size ) > this.getContext().getConfig().getRecieveBufferSize() ) {
            /* log message? */
            log.warn("Flusing stream input");
            this.in.skip(this.in.available());
        }
        else {
            Response notification = createNotification(key);
            if ( notification != null ) {
                log.debug("Parsing notification");
                doRecv(notification);
                handleNotification(notification);
                return;
            }
            log.warn("Skipping message " + key);
            this.in.skip(size - 32);
        }
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:23,代码来源:SmbTransportImpl.java

示例3: doSkip

import jcifs.util.Encdec; //导入方法依赖的package包/类
protected void doSkip() throws IOException {
    int size = Encdec.dec_uint16be( sbuf, 2 ) & 0xFFFF;
    if (size < 33 || (4 + size) > rcv_buf_size ) {
        /* log message? */
        in.skip( in.available() );
    } else {
        in.skip( size - 32 );
    }
}
 
开发者ID:jaeksoft,项目名称:jcifs-krb5,代码行数:10,代码来源:SmbTransport.java

示例4: readShort

import jcifs.util.Encdec; //导入方法依赖的package包/类
@Override
public final short readShort () throws SmbException {
    if ( ( read(this.tmp, 0, 2) ) < 0 ) {
        throw new SmbEndOfFileException();
    }
    return Encdec.dec_uint16be(this.tmp, 0);
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:8,代码来源:SmbRandomAccessFile.java

示例5: readUnsignedShort

import jcifs.util.Encdec; //导入方法依赖的package包/类
@Override
public final int readUnsignedShort () throws SmbException {
    if ( ( read(this.tmp, 0, 2) ) < 0 ) {
        throw new SmbEndOfFileException();
    }
    return Encdec.dec_uint16be(this.tmp, 0) & 0xFFFF;
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:8,代码来源:SmbRandomAccessFile.java

示例6: readChar

import jcifs.util.Encdec; //导入方法依赖的package包/类
@Override
public final char readChar () throws SmbException {
    if ( ( read(this.tmp, 0, 2) ) < 0 ) {
        throw new SmbEndOfFileException();
    }
    return (char) Encdec.dec_uint16be(this.tmp, 0);
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:8,代码来源:SmbRandomAccessFile.java

示例7: doRecvSMB1

import jcifs.util.Encdec; //导入方法依赖的package包/类
/**
 * @param resp
 * @throws IOException
 * @throws SMBProtocolDecodingException
 */
private void doRecvSMB1 ( CommonServerMessageBlock resp ) throws IOException, SMBProtocolDecodingException {
    byte[] buffer = getContext().getBufferCache().getBuffer();
    try {
        System.arraycopy(this.sbuf, 0, buffer, 0, 4 + SMB1_HEADER_LENGTH);
        int size = ( Encdec.dec_uint16be(buffer, 2) & 0xFFFF );
        if ( size < ( SMB1_HEADER_LENGTH + 1 ) || ( 4 + size ) > Math.min(0xFFFF, getContext().getConfig().getMaximumBufferSize()) ) {
            throw new IOException("Invalid payload size: " + size);
        }
        int errorCode = Encdec.dec_uint32le(buffer, 9) & 0xFFFFFFFF;
        if ( resp.getCommand() == ServerMessageBlock.SMB_COM_READ_ANDX && ( errorCode == 0 || errorCode == 0x80000005 ) ) {
            // overflow indicator normal for pipe
            SmbComReadAndXResponse r = (SmbComReadAndXResponse) resp;
            int off = SMB1_HEADER_LENGTH;
            /* WordCount thru dataOffset always 27 */
            readn(this.in, buffer, 4 + off, 27);
            off += 27;
            resp.decode(buffer, 4);
            /* EMC can send pad w/o data */
            int pad = r.getDataOffset() - off;
            if ( r.getByteCount() > 0 && pad > 0 && pad < 4 )
                readn(this.in, buffer, 4 + off, pad);

            if ( r.getDataLength() > 0 ) {
                readn(this.in, r.getData(), r.getOffset(), r.getDataLength()); /* read direct */
            }
        }
        else {
            readn(this.in, buffer, 4 + SMB1_HEADER_LENGTH, size - SMB1_HEADER_LENGTH);
            resp.decode(buffer, 4);
        }
    }
    finally {
        getContext().getBufferCache().releaseBuffer(buffer);
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:41,代码来源:SmbTransportImpl.java

示例8: readShort

import jcifs.util.Encdec; //导入方法依赖的package包/类
public final short readShort() throws SmbException {
    if((read( tmp, 0, 2 )) < 0 ) {
        throw new SmbException( "EOF" );
    }
    return Encdec.dec_uint16be( tmp, 0 );
}
 
开发者ID:codelibs,项目名称:jcifs,代码行数:7,代码来源:SmbRandomAccessFile.java

示例9: readUnsignedShort

import jcifs.util.Encdec; //导入方法依赖的package包/类
public final int readUnsignedShort() throws SmbException {
    if((read( tmp, 0, 2 )) < 0 ) {
        throw new SmbException( "EOF" );
    }
    return Encdec.dec_uint16be( tmp, 0 ) & 0xFFFF;
}
 
开发者ID:codelibs,项目名称:jcifs,代码行数:7,代码来源:SmbRandomAccessFile.java

示例10: readChar

import jcifs.util.Encdec; //导入方法依赖的package包/类
public final char readChar() throws SmbException {
    if((read( tmp, 0, 2 )) < 0 ) {
        throw new SmbException( "EOF" );
    }
    return (char)Encdec.dec_uint16be( tmp, 0 );
}
 
开发者ID:codelibs,项目名称:jcifs,代码行数:7,代码来源:SmbRandomAccessFile.java

示例11: negotiate

import jcifs.util.Encdec; //导入方法依赖的package包/类
private void negotiate( int port, ServerMessageBlock resp ) throws IOException {
        /* We cannot use Transport.sendrecv() yet because
         * the Transport thread is not setup until doConnect()
         * returns and we want to supress all communication
         * until we have properly negotiated.
         */
        synchronized (sbuf) {
            if (port == 139) {
                ssn139();
            } else {
                if (port == 0)
                    port = DEFAULT_PORT; // 445
/* These Socket constructors attempt to connect before SO_TIMEOUT can be applied
                if (localAddr == null) {
                    socket = new Socket( address.getHostAddress(), port );
                } else {
                    socket = new Socket( address.getHostAddress(), port, localAddr, localPort );
                }
                socket.setSoTimeout( SO_TIMEOUT );
*/
                socket = new Socket();
                if (localAddr != null)
                    socket.bind(new InetSocketAddress(localAddr, localPort));
                socket.connect(new InetSocketAddress(address.getHostAddress(), port), CONN_TIMEOUT);
                socket.setSoTimeout( SO_TIMEOUT );

                out = socket.getOutputStream();
                in = socket.getInputStream();
            }

            if (++mid == 32000) mid = 1;
            NEGOTIATE_REQUEST.mid = mid;
            int n = NEGOTIATE_REQUEST.encode( sbuf, 4 );
            Encdec.enc_uint32be( n & 0xFFFF, sbuf, 0 ); /* 4 byte ssn msg header */

            if (log.level >= 4) {
                log.println( NEGOTIATE_REQUEST );
                if (log.level >= 6) {
                    Hexdump.hexdump( log, sbuf, 4, n );
                }
            }

            out.write( sbuf, 0, 4 + n );
            out.flush();
            /* Note the Transport thread isn't running yet so we can
             * read from the socket here.
             */
            if (peekKey() == null) /* try to read header */
                throw new IOException( "transport closed in negotiate" );
            int size = Encdec.dec_uint16be( sbuf, 2 ) & 0xFFFF;
            if (size < 33 || (4 + size) > sbuf.length ) {
                throw new IOException( "Invalid payload size: " + size );
            }
            readn( in, sbuf, 4 + 32, size - 32 );
            resp.decode( sbuf, 4 );

            if (log.level >= 4) {
                log.println( resp );
                if (log.level >= 6) {
                    Hexdump.hexdump( log, sbuf, 4, n );
                }
            }
        }
    }
 
开发者ID:jaeksoft,项目名称:jcifs-krb5,代码行数:65,代码来源:SmbTransport.java

示例12: doRecv

import jcifs.util.Encdec; //导入方法依赖的package包/类
protected void doRecv( Response response ) throws IOException {
    ServerMessageBlock resp = (ServerMessageBlock)response;
    resp.useUnicode = useUnicode;
    resp.extendedSecurity = (capabilities & CAP_EXTENDED_SECURITY) == CAP_EXTENDED_SECURITY;

    synchronized (BUF) {
        System.arraycopy( sbuf, 0, BUF, 0, 4 + HEADER_LENGTH );
        int size = Encdec.dec_uint16be( BUF, 2 ) & 0xFFFF;
        if (size < (HEADER_LENGTH + 1) || (4 + size) > rcv_buf_size ) {
            throw new IOException( "Invalid payload size: " + size );
        }
        int errorCode = Encdec.dec_uint32le( BUF, 9 ) & 0xFFFFFFFF;
        if (resp.command == ServerMessageBlock.SMB_COM_READ_ANDX &&
                    (errorCode == 0 ||
                    errorCode == 0x80000005)) { // overflow indicator normal for pipe
            SmbComReadAndXResponse r = (SmbComReadAndXResponse)resp;
            int off = HEADER_LENGTH;
                                /* WordCount thru dataOffset always 27 */
            readn( in, BUF, 4 + off, 27 ); off += 27;
            resp.decode( BUF, 4 );
                                          /* EMC can send pad w/o data */
            int pad = r.dataOffset - off;
            if (r.byteCount > 0 && pad > 0 && pad < 4)
                readn( in, BUF, 4 + off, pad);

            if (r.dataLength > 0)
                readn( in, r.b, r.off, r.dataLength );  /* read direct */
        } else {
            readn( in, BUF, 4 + 32, size - 32 );
            resp.decode( BUF, 4 );
            if (resp instanceof SmbComTransactionResponse) {
                ((SmbComTransactionResponse)resp).nextElement();
            }
        }

        /* Verification fails (w/ W2K3 server at least) if status is not 0. This
         * suggests MS doesn't compute the signature (correctly) for error responses
         * (perhaps for DOS reasons).
         */
        if (digest != null && resp.errorCode == 0) {
            digest.verify( BUF, 4, resp );
        }

        if (log.level >= 4) {
            log.println( response );
            if (log.level >= 6) {
                Hexdump.hexdump( log, BUF, 4, size );
            }
        }
    }
}
 
开发者ID:jaeksoft,项目名称:jcifs-krb5,代码行数:52,代码来源:SmbTransport.java

示例13: doRecvSMB2

import jcifs.util.Encdec; //导入方法依赖的package包/类
/**
 * @param response
 * @throws IOException
 * @throws SMBProtocolDecodingException
 */
private void doRecvSMB2 ( CommonServerMessageBlock response ) throws IOException, SMBProtocolDecodingException {
    int size = ( Encdec.dec_uint16be(this.sbuf, 2) & 0xFFFF ) | ( this.sbuf[ 1 ] & 0xFF ) << 16;
    if ( size < ( Smb2Constants.SMB2_HEADER_LENGTH + 1 ) ) {
        throw new IOException("Invalid payload size: " + size);
    }

    if ( this.sbuf[ 0 ] != (byte) 0x00 || this.sbuf[ 4 ] != (byte) 0xFE || this.sbuf[ 5 ] != (byte) 'S' || this.sbuf[ 6 ] != (byte) 'M'
            || this.sbuf[ 7 ] != (byte) 'B' ) {
        throw new IOException("Houston we have a synchronization problem");
    }

    int nextCommand = Encdec.dec_uint32le(this.sbuf, 4 + 20);
    int maximumBufferSize = getContext().getConfig().getMaximumBufferSize();
    int msgSize = nextCommand != 0 ? nextCommand : size;
    if ( msgSize > maximumBufferSize ) {
        throw new IOException(String.format("Message size %d exceeds maxiumum buffer size %d", msgSize, maximumBufferSize));
    }

    ServerMessageBlock2Response cur = (ServerMessageBlock2Response) response;
    byte[] buffer = getContext().getBufferCache().getBuffer();
    try {
        int rl = nextCommand != 0 ? nextCommand : size;

        // read and decode first
        System.arraycopy(this.sbuf, 4, buffer, 0, Smb2Constants.SMB2_HEADER_LENGTH);
        readn(this.in, buffer, Smb2Constants.SMB2_HEADER_LENGTH, rl - Smb2Constants.SMB2_HEADER_LENGTH);

        int len = cur.decode(buffer, 0);

        if ( len > rl ) {
            throw new IOException(String.format("WHAT? ( read %d decoded %d ): %s", rl, len, cur));
        }
        else if ( nextCommand != 0 && len > nextCommand ) {
            throw new IOException("Overlapping commands");
        }
        size -= rl;

        while ( size > 0 && nextCommand != 0 ) {
            cur = (ServerMessageBlock2Response) cur.getNextResponse();
            if ( cur == null ) {
                log.warn("Response not properly set up");
                this.in.skip(size);
                break;
            }

            // read next header
            readn(this.in, buffer, 0, Smb2Constants.SMB2_HEADER_LENGTH);
            nextCommand = Encdec.dec_uint32le(buffer, 20);

            if ( ( nextCommand != 0 && nextCommand > maximumBufferSize ) || ( nextCommand == 0 && size > maximumBufferSize ) ) {
                throw new IOException(
                    String.format("Message size %d exceeds maxiumum buffer size %d", nextCommand != 0 ? nextCommand : size, maximumBufferSize));
            }

            rl = nextCommand != 0 ? nextCommand : size;

            if ( log.isDebugEnabled() ) {
                log.debug(String.format("Compound next command %d read size %d remain %d", nextCommand, rl, size));
            }

            readn(this.in, buffer, Smb2Constants.SMB2_HEADER_LENGTH, rl - Smb2Constants.SMB2_HEADER_LENGTH);

            len = cur.decode(buffer, 0, true);
            if ( len > rl ) {
                throw new IOException(String.format("WHAT? ( read %d decoded %d ): %s", rl, len, cur));
            }
            else if ( nextCommand != 0 && len > nextCommand ) {
                throw new IOException("Overlapping commands");
            }
            size -= rl;
        }
    }
    finally {
        getContext().getBufferCache().releaseBuffer(buffer);
    }
}
 
开发者ID:AgNO3,项目名称:jcifs-ng,代码行数:82,代码来源:SmbTransportImpl.java


注:本文中的jcifs.util.Encdec.dec_uint16be方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。