Example usage for io.netty.buffer ByteBuf getInt

List of usage examples for io.netty.buffer ByteBuf getInt

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf getInt.

Prototype

public abstract int getInt(int index);

Source Link

Document

Gets a 32-bit integer at the specified absolute index in this buffer.

Usage

From source file:org.dcache.xrootd.protocol.messages.CloseRequest.java

License:Open Source License

public CloseRequest(ByteBuf buffer) {
    super(buffer, kXR_close);
    fileHandle = buffer.getInt(4);
}

From source file:org.dcache.xrootd.protocol.messages.GenericReadRequestMessage.java

License:Open Source License

public GenericReadRequestMessage(ByteBuf buffer, int requestId) {
    super(buffer, requestId);

    int alen = buffer.getInt(20);

    if (alen <= 8) {
        pathid = -1;//  w  ww .  j  av a  2  s . c o m
        readList = new EmbeddedReadRequest[0];
    } else {
        int prefix = 0;
        if (alen % 16 == 0) {
            pathid = -1;
        } else if (alen % 16 != 8) {
            pathid = -1;
            LOGGER.warn("invalid readv request: data doesn't start with 8 byte prefix (pathid)");
        } else {
            pathid = buffer.getUnsignedByte(24);
            prefix = 8;
        }

        int numberOfListEntries = (alen - prefix) / 16;

        readList = new EmbeddedReadRequest[numberOfListEntries];

        for (int i = 0; i < numberOfListEntries; i++) {
            int j = 24 + prefix + i * 16;
            readList[i] = new EmbeddedReadRequest(buffer.getInt(j), buffer.getInt(j + 4),
                    buffer.getLong(j + 8));
        }
    }
}

From source file:org.dcache.xrootd.protocol.messages.LoginRequest.java

License:Open Source License

public LoginRequest(ByteBuf buffer) {
    super(buffer, kXR_login);

    int pos = buffer.indexOf(8, 16, (byte) 0); // User name is padded with '\0'
    if (pos > -1) {
        username = buffer.toString(8, pos - 8, US_ASCII);
    } else {/*from  w w w  .j  av a2  s . c o m*/
        username = buffer.toString(8, 8, US_ASCII);
    }

    pid = buffer.getInt(4);
    capver = buffer.getUnsignedByte(18);
    role = buffer.getUnsignedByte(19);

    int tlen = buffer.getInt(20);
    token = buffer.toString(24, tlen, US_ASCII);
}

From source file:org.dcache.xrootd.protocol.messages.MvRequest.java

License:Open Source License

public MvRequest(ByteBuf buffer) {
    super(buffer, kXR_mv);

    int dlen = buffer.getInt(20);
    int end = 24 + dlen;

    int psep = buffer.indexOf(24, end, (byte) 0x20);

    if (psep == -1) {
        throw new IllegalArgumentException("kXR_mv needs two paths!");
    }/*w  ww  .  ja  v  a 2s .co m*/

    String source = buffer.toString(24, psep - 24, US_ASCII);
    String target = buffer.toString(psep + 1, end - (psep + 1), US_ASCII);

    int osep = source.indexOf("?");

    if (osep > -1) {
        sourcePath = source.substring(0, osep);
        sourceOpaque = source.substring(osep + 1);
    } else {
        sourcePath = source;
    }

    osep = target.indexOf("?");

    if (osep > -1) {
        targetPath = target.substring(0, osep);
        targetOpaque = target.substring(osep + 1);
    } else {
        targetPath = target;
    }
}

From source file:org.dcache.xrootd.protocol.messages.PathRequest.java

License:Open Source License

public PathRequest(ByteBuf buffer, int requestId) {
    super(buffer, requestId);
    setPathAndOpaque(buffer, 24, buffer.getInt(20));
}

From source file:org.dcache.xrootd.protocol.messages.PrepareRequest.java

License:Open Source License

public PrepareRequest(ByteBuf buffer) {
    super(buffer, kXR_prepare);

    options = buffer.getUnsignedShort(4);
    priority = buffer.getUnsignedShort(5);

    int plen = buffer.getInt(20);
    int end = 24 + plen;

    plist = buffer.toString(24, end - 24, US_ASCII).split("\n");
}

From source file:org.dcache.xrootd.protocol.messages.QueryRequest.java

License:Open Source License

public QueryRequest(ByteBuf buffer) {
    super(buffer, kXR_query);
    reqcode = buffer.getUnsignedShort(4);
    fhandle = buffer.getInt(8);
    int alen = buffer.getInt(20);

    /* The protocol spec doesn't state anything about trailing zeros in args,
     * however the xrdfs client sends zero terminated paths.
     *///  w  w  w  . j av  a 2 s  . co  m
    args = NULL_CHARACTER.trimTrailingFrom(buffer.toString(24, alen, US_ASCII));
}

From source file:org.dcache.xrootd.protocol.messages.ReadRequest.java

License:Open Source License

public ReadRequest(ByteBuf buffer) {
    super(buffer, kXR_read);

    fhandle = buffer.getInt(4);
    offset = buffer.getLong(8);
    rlen = buffer.getInt(16);
}

From source file:org.dcache.xrootd.protocol.messages.SetRequest.java

License:Open Source License

public SetRequest(ByteBuf buffer) {
    super(buffer, kXR_set);
    int dlen = buffer.getInt(20);
    data = buffer.toString(24, dlen, US_ASCII);
}

From source file:org.dcache.xrootd.protocol.messages.SigverRequest.java

License:Open Source License

public SigverRequest(ByteBuf buffer) {
    super(buffer, kXR_sigver);

    expectrid = buffer.getShort(4);/*ww  w .  jav  a 2  s. co m*/
    version = buffer.getByte(6);
    flags = buffer.getByte(7); // should == kXR_nodata if this is a write
    seqno = buffer.getLong(8);
    crypto = buffer.getByte(16);

    /*
     * skip reserved [bytes 17-19]
     */

    int dlen = buffer.getInt(20);
    signature = new byte[dlen];
    buffer.getBytes(24, signature);
}