示例#1
0
  InitChunk(byte[] buf, int off) {
    super(buf, off);

    if (_type != Chunk.CHUNK_TYPE_INIT) throw new RuntimeException("This is not an INIT chunk!");

    if (_len != INIT_CHUNK_LENGTH)
      throw new RuntimeException("Invalid chunk length field for INIT chunk!");

    _validation = ByteConverter.from4BytesToUnsignedInt(_buf, _off + Chunk.CHUNK_HEADER_SIZE);
    _initialControlTSN =
        ByteConverter.from4BytesToUnsignedInt(_buf, _off + Chunk.CHUNK_HEADER_SIZE + 4);
    _initialRelSeqTSN =
        ByteConverter.from4BytesToUnsignedInt(_buf, _off + Chunk.CHUNK_HEADER_SIZE + 8);
    _initialUnrelSeqTSN =
        ByteConverter.from4BytesToUnsignedInt(_buf, _off + Chunk.CHUNK_HEADER_SIZE + 12);
    _initialRelUnseqID =
        ByteConverter.from4BytesToUnsignedInt(_buf, _off + Chunk.CHUNK_HEADER_SIZE + 16);
    _initialUnrelUnseqID =
        ByteConverter.from4BytesToUnsignedInt(_buf, _off + Chunk.CHUNK_HEADER_SIZE + 20);
  }
示例#2
0
  void write(byte[] buf, int off) {
    if (_buf != null) throw new RuntimeException("Can write only locally built INIT chunks!");

    if (buf == null) throw new IllegalArgumentException("Invalid argument!");

    if (buf.length < off + INIT_CHUNK_LENGTH)
      throw new RuntimeException("Not enough space in destination buffer!");

    writeHeader(buf, off);

    ByteConverter.fromUnsignedIntTo4Bytes(_validation, buf, off + Chunk.CHUNK_HEADER_SIZE);
    ByteConverter.fromUnsignedIntTo4Bytes(
        _initialControlTSN, buf, off + Chunk.CHUNK_HEADER_SIZE + 4);
    ByteConverter.fromUnsignedIntTo4Bytes(
        _initialRelSeqTSN, buf, off + Chunk.CHUNK_HEADER_SIZE + 8);
    ByteConverter.fromUnsignedIntTo4Bytes(
        _initialUnrelSeqTSN, buf, off + Chunk.CHUNK_HEADER_SIZE + 12);
    ByteConverter.fromUnsignedIntTo4Bytes(
        _initialRelUnseqID, buf, off + Chunk.CHUNK_HEADER_SIZE + 16);
    ByteConverter.fromUnsignedIntTo4Bytes(
        _initialUnrelUnseqID, buf, off + Chunk.CHUNK_HEADER_SIZE + 20);
  }