io.netty.handler.ssl.OpenSsl.memoryAddress()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(193)

本文整理了Java中io.netty.handler.ssl.OpenSsl.memoryAddress()方法的一些代码示例,展示了OpenSsl.memoryAddress()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OpenSsl.memoryAddress()方法的具体详情如下:
包路径:io.netty.handler.ssl.OpenSsl
类名称:OpenSsl
方法名:memoryAddress

OpenSsl.memoryAddress介绍

暂无

代码示例

代码示例来源:origin: redisson/redisson

private static long newBIO(ByteBuf buffer) throws Exception {
  try {
    long bio = SSL.newMemBIO();
    int readable = buffer.readableBytes();
    if (SSL.bioWrite(bio, OpenSsl.memoryAddress(buffer) + buffer.readerIndex(), readable) != readable) {
      SSL.freeBIO(bio);
      throw new IllegalStateException("Could not write data to memory BIO");
    }
    return bio;
  } finally {
    buffer.release();
  }
}

代码示例来源:origin: wildfly/wildfly

private static long newBIO(ByteBuf buffer) throws Exception {
  try {
    long bio = SSL.newMemBIO();
    int readable = buffer.readableBytes();
    if (SSL.bioWrite(bio, OpenSsl.memoryAddress(buffer) + buffer.readerIndex(), readable) != readable) {
      SSL.freeBIO(bio);
      throw new IllegalStateException("Could not write data to memory BIO");
    }
    return bio;
  } finally {
    buffer.release();
  }
}

代码示例来源:origin: redisson/redisson

/**
 * Write encrypted data to the OpenSSL network BIO.
 */
private ByteBuf writeEncryptedData(final ByteBuffer src, int len) {
  final int pos = src.position();
  if (src.isDirect()) {
    SSL.bioSetByteBuffer(networkBIO, bufferAddress(src) + pos, len, false);
  } else {
    final ByteBuf buf = alloc.directBuffer(len);
    try {
      final int limit = src.limit();
      src.limit(pos + len);
      buf.writeBytes(src);
      // Restore the original position and limit because we don't want to consume from `src`.
      src.position(pos);
      src.limit(limit);
      SSL.bioSetByteBuffer(networkBIO, memoryAddress(buf), len, false);
      return buf;
    } catch (Throwable cause) {
      buf.release();
      PlatformDependent.throwException(cause);
    }
  }
  return null;
}

代码示例来源:origin: redisson/redisson

src.limit(limit);
sslWrote = SSL.writeToSSL(ssl, memoryAddress(buf), len);
if (sslWrote > 0) {
  src.position(pos + sslWrote);

代码示例来源:origin: redisson/redisson

/**
 * Read plaintext data from the OpenSSL internal BIO
 */
private int readPlaintextData(final ByteBuffer dst) {
  final int sslRead;
  final int pos = dst.position();
  if (dst.isDirect()) {
    sslRead = SSL.readFromSSL(ssl, bufferAddress(dst) + pos, dst.limit() - pos);
    if (sslRead > 0) {
      dst.position(pos + sslRead);
    }
  } else {
    final int limit = dst.limit();
    final int len = min(maxEncryptedPacketLength0(), limit - pos);
    final ByteBuf buf = alloc.directBuffer(len);
    try {
      sslRead = SSL.readFromSSL(ssl, memoryAddress(buf), len);
      if (sslRead > 0) {
        dst.limit(pos + sslRead);
        buf.getBytes(buf.readerIndex(), dst);
        dst.limit(limit);
      }
    } finally {
      buf.release();
    }
  }
  return sslRead;
}

代码示例来源:origin: wildfly/wildfly

/**
 * Write encrypted data to the OpenSSL network BIO.
 */
private ByteBuf writeEncryptedData(final ByteBuffer src, int len) {
  final int pos = src.position();
  if (src.isDirect()) {
    SSL.bioSetByteBuffer(networkBIO, bufferAddress(src) + pos, len, false);
  } else {
    final ByteBuf buf = alloc.directBuffer(len);
    try {
      final int limit = src.limit();
      src.limit(pos + len);
      buf.writeBytes(src);
      // Restore the original position and limit because we don't want to consume from `src`.
      src.position(pos);
      src.limit(limit);
      SSL.bioSetByteBuffer(networkBIO, memoryAddress(buf), len, false);
      return buf;
    } catch (Throwable cause) {
      buf.release();
      PlatformDependent.throwException(cause);
    }
  }
  return null;
}

代码示例来源:origin: wildfly/wildfly

src.limit(limit);
sslWrote = SSL.writeToSSL(ssl, memoryAddress(buf), len);
if (sslWrote > 0) {
  src.position(pos + sslWrote);

代码示例来源:origin: wildfly/wildfly

/**
 * Read plaintext data from the OpenSSL internal BIO
 */
private int readPlaintextData(final ByteBuffer dst) {
  final int sslRead;
  final int pos = dst.position();
  if (dst.isDirect()) {
    sslRead = SSL.readFromSSL(ssl, bufferAddress(dst) + pos, dst.limit() - pos);
    if (sslRead > 0) {
      dst.position(pos + sslRead);
    }
  } else {
    final int limit = dst.limit();
    final int len = min(maxEncryptedPacketLength0(), limit - pos);
    final ByteBuf buf = alloc.directBuffer(len);
    try {
      sslRead = SSL.readFromSSL(ssl, memoryAddress(buf), len);
      if (sslRead > 0) {
        dst.limit(pos + sslRead);
        buf.getBytes(buf.readerIndex(), dst);
        dst.limit(limit);
      }
    } finally {
      buf.release();
    }
  }
  return sslRead;
}

代码示例来源:origin: redisson/redisson

} else {
  bioReadCopyBuf = alloc.directBuffer(dst.remaining());
  SSL.bioSetByteBuffer(networkBIO, memoryAddress(bioReadCopyBuf), bioReadCopyBuf.writableBytes(),
      true);

代码示例来源:origin: wildfly/wildfly

} else {
  bioReadCopyBuf = alloc.directBuffer(dst.remaining());
  SSL.bioSetByteBuffer(networkBIO, memoryAddress(bioReadCopyBuf), bioReadCopyBuf.writableBytes(),
      true);

代码示例来源:origin: io.netty/netty-handler

private static long newBIO(ByteBuf buffer) throws Exception {
  try {
    long bio = SSL.newMemBIO();
    int readable = buffer.readableBytes();
    if (SSL.bioWrite(bio, OpenSsl.memoryAddress(buffer) + buffer.readerIndex(), readable) != readable) {
      SSL.freeBIO(bio);
      throw new IllegalStateException("Could not write data to memory BIO");
    }
    return bio;
  } finally {
    buffer.release();
  }
}

代码示例来源:origin: io.netty/netty-handler

/**
 * Write encrypted data to the OpenSSL network BIO.
 */
private ByteBuf writeEncryptedData(final ByteBuffer src, int len) {
  final int pos = src.position();
  if (src.isDirect()) {
    SSL.bioSetByteBuffer(networkBIO, bufferAddress(src) + pos, len, false);
  } else {
    final ByteBuf buf = alloc.directBuffer(len);
    try {
      final int limit = src.limit();
      src.limit(pos + len);
      buf.writeBytes(src);
      // Restore the original position and limit because we don't want to consume from `src`.
      src.position(pos);
      src.limit(limit);
      SSL.bioSetByteBuffer(networkBIO, memoryAddress(buf), len, false);
      return buf;
    } catch (Throwable cause) {
      buf.release();
      PlatformDependent.throwException(cause);
    }
  }
  return null;
}

代码示例来源:origin: io.netty/netty-handler

src.limit(limit);
sslWrote = SSL.writeToSSL(ssl, memoryAddress(buf), len);
if (sslWrote > 0) {
  src.position(pos + sslWrote);

代码示例来源:origin: io.netty/netty-handler

/**
 * Read plaintext data from the OpenSSL internal BIO
 */
private int readPlaintextData(final ByteBuffer dst) {
  final int sslRead;
  final int pos = dst.position();
  if (dst.isDirect()) {
    sslRead = SSL.readFromSSL(ssl, bufferAddress(dst) + pos, dst.limit() - pos);
    if (sslRead > 0) {
      dst.position(pos + sslRead);
    }
  } else {
    final int limit = dst.limit();
    final int len = min(maxEncryptedPacketLength0(), limit - pos);
    final ByteBuf buf = alloc.directBuffer(len);
    try {
      sslRead = SSL.readFromSSL(ssl, memoryAddress(buf), len);
      if (sslRead > 0) {
        dst.limit(pos + sslRead);
        buf.getBytes(buf.readerIndex(), dst);
        dst.limit(limit);
      }
    } finally {
      buf.release();
    }
  }
  return sslRead;
}

代码示例来源:origin: io.netty/netty-handler

} else {
  bioReadCopyBuf = alloc.directBuffer(dst.remaining());
  SSL.bioSetByteBuffer(networkBIO, memoryAddress(bioReadCopyBuf), bioReadCopyBuf.writableBytes(),
      true);

代码示例来源:origin: apache/activemq-artemis

private static long newBIO(ByteBuf buffer) throws Exception {
  try {
    long bio = SSL.newMemBIO();
    int readable = buffer.readableBytes();
    if (SSL.bioWrite(bio, OpenSsl.memoryAddress(buffer) + buffer.readerIndex(), readable) != readable) {
      SSL.freeBIO(bio);
      throw new IllegalStateException("Could not write data to memory BIO");
    }
    return bio;
  } finally {
    buffer.release();
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

private static long newBIO(ByteBuf buffer) throws Exception {
    try {
      long bio = SSL.newMemBIO();
      int readable = buffer.readableBytes();
      if (SSL.bioWrite(bio, OpenSsl.memoryAddress(buffer) + buffer.readerIndex(), readable) != readable) {
        SSL.freeBIO(bio);
        throw new IllegalStateException("Could not write data to memory BIO");
      }
      return bio;
    } finally {
      buffer.release();
    }
  }
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

private static long newBIO(ByteBuf buffer) throws Exception {
    try {
      long bio = SSL.newMemBIO();
      int readable = buffer.readableBytes();
      if (SSL.bioWrite(bio, OpenSsl.memoryAddress(buffer) + buffer.readerIndex(), readable) != readable) {
        SSL.freeBIO(bio);
        throw new IllegalStateException("Could not write data to memory BIO");
      }
      return bio;
    } finally {
      buffer.release();
    }
  }
}

代码示例来源:origin: apache/activemq-artemis

/**
 * Write encrypted data to the OpenSSL network BIO.
 */
private ByteBuf writeEncryptedData(final ByteBuffer src, int len) {
  final int pos = src.position();
  if (src.isDirect()) {
    SSL.bioSetByteBuffer(networkBIO, bufferAddress(src) + pos, len, false);
  } else {
    final ByteBuf buf = alloc.directBuffer(len);
    try {
      final int limit = src.limit();
      src.limit(pos + len);
      buf.writeBytes(src);
      // Restore the original position and limit because we don't want to consume from `src`.
      src.position(pos);
      src.limit(limit);
      SSL.bioSetByteBuffer(networkBIO, memoryAddress(buf), len, false);
      return buf;
    } catch (Throwable cause) {
      buf.release();
      PlatformDependent.throwException(cause);
    }
  }
  return null;
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

/**
 * Write encrypted data to the OpenSSL network BIO.
 */
private ByteBuf writeEncryptedData(final ByteBuffer src, int len) {
  final int pos = src.position();
  if (src.isDirect()) {
    SSL.bioSetByteBuffer(networkBIO, bufferAddress(src) + pos, len, false);
  } else {
    final ByteBuf buf = alloc.directBuffer(len);
    try {
      final int limit = src.limit();
      src.limit(pos + len);
      buf.writeBytes(src);
      // Restore the original position and limit because we don't want to consume from `src`.
      src.position(pos);
      src.limit(limit);
      SSL.bioSetByteBuffer(networkBIO, memoryAddress(buf), len, false);
      return buf;
    } catch (Throwable cause) {
      buf.release();
      PlatformDependent.throwException(cause);
    }
  }
  return null;
}

相关文章