org.apache.sshd.common.util.buffer.Buffer.putInt()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(175)

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

Buffer.putInt介绍

[英]Writes 32 bits
[中]写入32位

代码示例

代码示例来源:origin: org.apache.sshd/sshd-core

@Override
public void init(Session s, byte[] v_s, byte[] v_c, byte[] i_s, byte[] i_c) throws Exception {
  super.init(s, v_s, v_c, i_s, i_c);
  if (log.isDebugEnabled()) {
    log.debug("init({}) Send SSH_MSG_KEX_DH_GEX_REQUEST", s);
  }
  Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_KEX_DH_GEX_REQUEST, Integer.SIZE);
  buffer.putInt(min);
  buffer.putInt(prf);
  buffer.putInt(max);
  s.writePacket(buffer);
  expected = SshConstants.SSH_MSG_KEX_DH_GEX_GROUP;
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

public void putMPInt(byte[] foo) {
  if ((foo[0] & 0x80) != 0) {
    putInt(foo.length + 1 /* padding */);
    putByte((byte) 0);
  } else {
    putInt(foo.length);
  }
  putRawBytes(foo);
}

代码示例来源:origin: org.apache.sshd/sshd-core

protected void newBuffer(int size) {
  Channel channel = getChannel();
  Session session = channel.getSession();
  buffer = session.createBuffer(cmd, size <= 0 ? 12 : 12 + size);
  buffer.putInt(channel.getRecipient());
  if (cmd == SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA) {
    buffer.putInt(SshConstants.SSH_EXTENDED_DATA_STDERR);
  }
  buffer.putInt(0);
  bufferLength = 0;
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

protected void newBuffer(int size) {
  Channel channel = getChannel();
  Session session = channel.getSession();
  buffer = session.createBuffer(cmd, size <= 0 ? 12 : 12 + size);
  buffer.putInt(channel.getRecipient());
  if (cmd == SshConstants.SSH_MSG_CHANNEL_EXTENDED_DATA) {
    buffer.putInt(SshConstants.SSH_EXTENDED_DATA_STDERR);
  }
  buffer.putInt(0);
  bufferLength = 0;
}

代码示例来源:origin: org.apache.sshd/sshd-core

protected void sendWindowAdjust(long len) throws IOException {
  if (log.isDebugEnabled()) {
    log.debug("sendWindowAdjust({}) SSH_MSG_CHANNEL_WINDOW_ADJUST len={}", this, len);
  }
  Session s = getSession();
  Buffer buffer = s.createBuffer(SshConstants.SSH_MSG_CHANNEL_WINDOW_ADJUST, Short.SIZE);
  buffer.putInt(getRecipient());
  buffer.putInt(len);
  writePacket(buffer);
}

代码示例来源:origin: org.apache.sshd/sshd-core

protected Buffer createBuffer(byte cmd, int extraLen) {
  Buffer buffer = new ByteArrayBuffer((extraLen <= 0) ? ByteArrayBuffer.DEFAULT_SIZE : extraLen + Byte.SIZE, false);
  buffer.putInt(0);
  buffer.putByte(cmd);
  return buffer;
}

代码示例来源:origin: org.apache.sshd/sshd-core

/**
 * Sends a {@code SSH_MSG_UNIMPLEMENTED} message
 *
 * @param seqNoValue The referenced sequence number
 * @return An {@link IoWriteFuture} that can be used to wait for packet write completion
 * @throws IOException if an error occurred sending the packet
 */
protected IoWriteFuture sendNotImplemented(long seqNoValue) throws IOException {
  Buffer buffer = createBuffer(SshConstants.SSH_MSG_UNIMPLEMENTED, Byte.SIZE);
  buffer.putInt(seqNoValue);
  return writePacket(buffer);
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

protected Buffer createBuffer(byte cmd, int extraLen) {
  Buffer buffer = new ByteArrayBuffer((extraLen <= 0) ? ByteArrayBuffer.DEFAULT_SIZE : extraLen + Byte.SIZE, false);
  buffer.putInt(0);
  buffer.putByte(cmd);
  return buffer;
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

/**
 * Sends a {@code SSH_MSG_UNIMPLEMENTED} message
 *
 * @param seqNoValue The referenced sequence number
 * @return An {@link IoWriteFuture} that can be used to wait for packet write completion
 * @throws IOException if an error occurred sending the packet
 */
protected IoWriteFuture sendNotImplemented(long seqNoValue) throws IOException {
  Buffer buffer = createBuffer(SshConstants.SSH_MSG_UNIMPLEMENTED, Byte.SIZE);
  buffer.putInt(seqNoValue);
  return writePacket(buffer);
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

protected IoWriteFuture sendFailureResponse(ConnectionService service, byte cmd, int channelId) throws IOException {
    Session session = service.getSession();
    // Use DEBUG level to avoid log overflow due to invalid messages flood
    if (log.isDebugEnabled()) {
      log.debug("sendFailureResponse({}) send SSH_MSG_CHANNEL_FAILURE for {} command on unknown channel: {}",
          session, SshConstants.getCommandMessageName(cmd), channelId);
    }

    Buffer rsp = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_FAILURE, Integer.BYTES);
    rsp.putInt(channelId);
    return session.writePacket(rsp);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-core

protected IoWriteFuture sendFailureResponse(ConnectionService service, byte cmd, int channelId) throws IOException {
    Session session = service.getSession();
    // Use DEBUG level to avoid log overflow due to invalid messages flood
    if (log.isDebugEnabled()) {
      log.debug("sendFailureResponse({}) send SSH_MSG_CHANNEL_FAILURE for {} command on unknown channel: {}",
          session, SshConstants.getCommandMessageName(cmd), channelId);
    }

    Buffer rsp = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_FAILURE, Integer.BYTES);
    rsp.putInt(channelId);
    return session.writePacket(rsp);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

public static <B extends Buffer> B writeAclEntry(B buffer, AclEntry acl) {
  Objects.requireNonNull(acl, "No ACL");
  AclEntryType type = acl.type();
  int aclType = encodeAclEntryType(type);
  ValidateUtils.checkTrue(aclType >= 0, "Unknown ACL type: %s", type);
  buffer.putInt(aclType);
  buffer.putInt(encodeAclFlags(acl.flags()));
  buffer.putInt(encodeAclMask(acl.permissions()));
  Principal user = acl.principal();
  buffer.putString(user.getName());
  return buffer;
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

protected void sendHandle(Buffer buffer, int id, String handle) throws IOException {
  buffer.putByte((byte) SftpConstants.SSH_FXP_HANDLE);
  buffer.putInt(id);
  buffer.putString(handle);
  send(buffer);
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

public static <B extends Buffer> B writeACLs(B buffer, int version, Collection<? extends AclEntry> acl) {
  int lenPos = buffer.wpos();
  buffer.putInt(0);   // length placeholder
  buffer = encodeACLs(buffer, version, acl);
  BufferUtils.updateLengthPlaceholder(buffer, lenPos);
  return buffer;
}

代码示例来源:origin: org.apache.sshd/sshd-common

public void putPublicKey(PublicKey key) {
  int ow = wpos();
  putInt(0);
  int ow1 = wpos();
  putRawPublicKey(key);
  int ow2 = wpos();
  wpos(ow);
  putInt(ow2 - ow1);
  wpos(ow2);
}

代码示例来源:origin: org.apache.sshd/sshd-core

protected Buffer prepare(Buffer buffer) {
  int wpos = buffer.wpos();
  buffer.wpos(0);
  buffer.putInt(wpos - 4);
  buffer.wpos(wpos);
  return buffer;
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

public void putPublicKey(PublicKey key) {
  int ow = wpos();
  putInt(0);
  int ow1 = wpos();
  putRawPublicKey(key);
  int ow2 = wpos();
  wpos(ow);
  putInt(ow2 - ow1);
  wpos(ow2);
}

代码示例来源:origin: org.apache.sshd/sshd-osgi

protected Buffer prepare(Buffer buffer) {
  int wpos = buffer.wpos();
  buffer.wpos(0);
  buffer.putInt(wpos - 4);
  buffer.wpos(wpos);
  return buffer;
}

代码示例来源:origin: org.apache.sshd/sshd-sftp

public static void encode(Buffer buffer, SpaceAvailableExtensionInfo info) {
    buffer.putLong(info.bytesOnDevice);
    buffer.putLong(info.unusedBytesOnDevice);
    buffer.putLong(info.bytesAvailableToUser);
    buffer.putLong(info.unusedBytesAvailableToUser);
    buffer.putInt(info.bytesPerAllocationUnit & 0xFFFFFFFFL);
  }
}

代码示例来源:origin: org.apache.sshd/sshd-core

protected Buffer prepare(Buffer buf) {
  int len = buf.available();
  int rpos = buf.rpos();
  int wpos = buf.wpos();
  buf.rpos(rpos - 4);
  buf.wpos(rpos - 4);
  buf.putInt(len);
  buf.wpos(wpos);
  return buf;
}

相关文章