コード例 #1
0
 @Override
 public void write(ChannelBuffer bb, OFGroupFeaturesStatsReplyVer12 message) {
   // fixed value property version = 3
   bb.writeByte((byte) 0x3);
   // fixed value property type = 19
   bb.writeByte((byte) 0x13);
   // fixed value property length = 56
   bb.writeShort((short) 0x38);
   bb.writeInt(U32.t(message.xid));
   // fixed value property statsType = 8
   bb.writeShort((short) 0x8);
   OFStatsReplyFlagsSerializerVer12.writeTo(bb, message.flags);
   // pad: 4 bytes
   bb.writeZero(4);
   bb.writeInt(U32.t(message.types));
   bb.writeInt(U32.t(message.capabilities));
   bb.writeInt(U32.t(message.maxGroupsAll));
   bb.writeInt(U32.t(message.maxGroupsSelect));
   bb.writeInt(U32.t(message.maxGroupsIndirect));
   bb.writeInt(U32.t(message.maxGroupsFf));
   bb.writeInt(U32.t(message.actionsAll));
   bb.writeInt(U32.t(message.actionsSelect));
   bb.writeInt(U32.t(message.actionsIndirect));
   bb.writeInt(U32.t(message.actionsFf));
 }
コード例 #2
0
    @Override
    public void write(ChannelBuffer bb, OFBsnGentableEntryAddVer13 message) {
      int startIndex = bb.writerIndex();
      // fixed value property version = 4
      bb.writeByte((byte) 0x4);
      // fixed value property type = 4
      bb.writeByte((byte) 0x4);
      // length is length of variable message, will be updated at the end
      int lengthIndex = bb.writerIndex();
      bb.writeShort(U16.t(0));

      bb.writeInt(U32.t(message.xid));
      // fixed value property experimenter = 0x5c16c7L
      bb.writeInt(0x5c16c7);
      // fixed value property subtype = 0x2eL
      bb.writeInt(0x2e);
      message.tableId.write2Bytes(bb);
      // keyLength is length indicator for key, will be
      // udpated when key has been written
      int keyLengthIndex = bb.writerIndex();
      bb.writeShort(0);
      message.checksum.write16Bytes(bb);
      int keyStartIndex = bb.writerIndex();
      ChannelUtils.writeList(bb, message.key);
      // update field length member keyLength
      int keyLength = bb.writerIndex() - keyStartIndex;
      bb.setShort(keyLengthIndex, keyLength);
      ChannelUtils.writeList(bb, message.value);

      // update length field
      int length = bb.writerIndex() - startIndex;
      bb.setShort(lengthIndex, length);
    }
コード例 #3
0
    @Override
    public void write(ChannelBuffer bb, OFBsnGentableBucketStatsReplyVer13 message) {
      int startIndex = bb.writerIndex();
      // fixed value property version = 4
      bb.writeByte((byte) 0x4);
      // fixed value property type = 19
      bb.writeByte((byte) 0x13);
      // length is length of variable message, will be updated at the end
      int lengthIndex = bb.writerIndex();
      bb.writeShort(U16.t(0));

      bb.writeInt(U32.t(message.xid));
      // fixed value property statsType = 65535
      bb.writeShort((short) 0xffff);
      OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
      // pad: 4 bytes
      bb.writeZero(4);
      // fixed value property experimenter = 0x5c16c7L
      bb.writeInt(0x5c16c7);
      // fixed value property subtype = 0x5L
      bb.writeInt(0x5);
      ChannelUtils.writeList(bb, message.entries);

      // update length field
      int length = bb.writerIndex() - startIndex;
      bb.setShort(lengthIndex, length);
    }
コード例 #4
0
  public void writeTo(ChannelBuffer data) {
    data.writeShort(fieldId);
    data.writeShort(offset);
    data.writeShort(length);
    data.writeShort(0);

    if (value == null) {
      data.writeZero(OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE);
    } else {
      if (value.length > OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE) {
        data.writeBytes(
            value,
            OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE - value.length,
            OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE);
      } else {
        data.writeBytes(value);
        data.writeZero(OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE - value.length);
      }
    }

    if (mask == null) {
      data.writeZero(OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE);
    } else {
      if (mask.length > OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE) {
        data.writeBytes(
            mask,
            OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE - mask.length,
            OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE);
      } else {
        data.writeBytes(mask);
        data.writeZero(OFGlobal.OFP_MAX_FIELD_LENGTH_IN_BYTE - mask.length);
      }
    }
  }
コード例 #5
0
  @Override
  public int write(ChannelBuffer c) {
    int tlvStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    int tlvLenIndex = c.writerIndex();
    hLength = 0;
    c.writeShort(hLength);

    ListIterator<PcepValueType> listIterator = llNodeAttributesSubTLVs.listIterator();

    while (listIterator.hasNext()) {
      PcepValueType tlv = listIterator.next();

      tlv.write(c);

      // need to take care of padding
      int pad = tlv.getLength() % 4;

      if (0 != pad) {
        pad = 4 - pad;
        for (int i = 0; i < pad; ++i) {
          c.writeByte((byte) 0);
        }
      }
    }

    hLength = (short) (c.writerIndex() - tlvStartIndex);
    c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));

    return c.writerIndex() - tlvStartIndex;
  }
コード例 #6
0
 @Override
 public void write(ChannelBuffer bb, OFBsnTlvIcmpTypeVer14 message) {
   // fixed value property type = 0x44
   bb.writeShort((short) 0x44);
   // fixed value property length = 5
   bb.writeShort((short) 0x5);
   bb.writeByte(U8.t(message.value));
 }
コード例 #7
0
 @Override
 public void write(ChannelBuffer bb, OFActionSetNwDstVer11 message) {
   // fixed value property type = 6
   bb.writeShort((short) 0x6);
   // fixed value property length = 8
   bb.writeShort((short) 0x8);
   message.nwAddr.write4Bytes(bb);
 }
コード例 #8
0
 @Override
 public int write(ChannelBuffer c) {
   int iStartIndex = c.writerIndex();
   c.writeShort(TYPE);
   c.writeShort(LENGTH);
   c.writeInt(rawValue);
   return c.writerIndex() - iStartIndex;
 }
コード例 #9
0
 @Override
 public void write(ChannelBuffer bb, OFBsnTlvActorSystemMacVer14 message) {
   // fixed value property type = 0x29
   bb.writeShort((short) 0x29);
   // fixed value property length = 10
   bb.writeShort((short) 0xa);
   message.value.write6Bytes(bb);
 }
コード例 #10
0
 @Override
 public void write(ChannelBuffer bb, OFBsnTlvQueueWeightVer13 message) {
   // fixed value property type = 0x15
   bb.writeShort((short) 0x15);
   // fixed value property length = 8
   bb.writeShort((short) 0x8);
   bb.writeInt(U32.t(message.value));
 }
コード例 #11
0
 @Override
 public int write(ChannelBuffer c) {
   int iLenStartIndex = c.writerIndex();
   c.writeShort(TYPE);
   c.writeShort(hLength);
   c.writeBytes(rawValue);
   return c.writerIndex() - iLenStartIndex;
 }
コード例 #12
0
 private static void sendResponse(
     Channel channel, SocketAddress remoteAddress, long rawId, int index) {
   if (channel != null) {
     ChannelBuffer response = ChannelBuffers.directBuffer(12);
     response.writeShort(0xfe02);
     response.writeLong(rawId);
     response.writeShort(index);
     channel.write(response, remoteAddress);
   }
 }
コード例 #13
0
 @Override
 public ChannelBuffer encode(EncryptionKeyRequestMessage message) {
   ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
   ChannelBufferUtils.writeString(buffer, message.getSessionId());
   byte[] publicKey = message.getSecretArray();
   buffer.writeShort((short) publicKey.length);
   buffer.writeBytes(publicKey);
   buffer.writeShort((short) message.getVerifyTokenArray().length);
   buffer.writeBytes(message.getVerifyTokenArray());
   return buffer;
 }
 @Override
 public void write(ChannelBuffer bb, OFInstructionIdBsnDisableL3Ver14 message) {
   // fixed value property type = 65535
   bb.writeShort((short) 0xffff);
   // fixed value property length = 12
   bb.writeShort((short) 0xc);
   // fixed value property experimenter = 0x5c16c7L
   bb.writeInt(0x5c16c7);
   // fixed value property subtype = 0xdL
   bb.writeInt(0xd);
 }
 @Override
 public void write(ChannelBuffer bb, OFInstructionIdBsnRequireVlanXlateVer13 message) {
   // fixed value property type = 65535
   bb.writeShort((short) 0xffff);
   // fixed value property length = 12
   bb.writeShort((short) 0xc);
   // fixed value property experimenter = 0x5c16c7L
   bb.writeInt(0x5c16c7);
   // fixed value property subtype = 0x8L
   bb.writeInt(0x8);
 }
コード例 #16
0
ファイル: WindowClickCodec.java プロジェクト: NikoMix/Vanilla
 @Override
 public ChannelBuffer encode(WindowClickMessage message) throws IOException {
   ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
   buffer.writeByte(message.getWindowInstanceId());
   buffer.writeShort(message.getSlot());
   buffer.writeByte(message.isRightClick() ? 1 : 0);
   buffer.writeShort(message.getTransaction());
   buffer.writeByte(message.isShift() ? 1 : 0);
   ChannelBufferUtils.writeItemStack(buffer, message.getItem());
   return buffer;
 }
コード例 #17
0
ファイル: BlockActionCodec.java プロジェクト: NikoMix/Vanilla
 @Override
 public ChannelBuffer encode(BlockActionMessage message) throws IOException {
   ChannelBuffer buffer = ChannelBuffers.buffer(14);
   buffer.writeInt(message.getX());
   buffer.writeShort(message.getY());
   buffer.writeInt(message.getZ());
   buffer.writeByte(message.getFirstByte());
   buffer.writeByte(message.getSecondByte());
   buffer.writeShort(message.getBlockId());
   return buffer;
 }
コード例 #18
0
 private void requestArchive(Channel channel) {
   if (lastIndex == 0) {
     lastIndex = newIndex;
   } else if (newIndex > lastIndex) {
     ChannelBuffer request = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 12);
     request.writeShort(MSG_LOG_SYNC);
     request.writeShort(4);
     request.writeInt((int) lastIndex);
     request.writeInt(0);
     channel.write(request);
   }
 }
コード例 #19
0
  @Override
  public int write(ChannelBuffer c) {
    int iLenStartIndex = c.writerIndex();
    c.writeShort(TYPE);
    c.writeShort(LENGTH);
    c.writeInt(ipv4IngressAddress);
    c.writeShort(lspId);
    c.writeShort(tunnelId);
    c.writeInt(extendedTunnelId);
    c.writeInt(ipv4EgressAddress);

    return c.writerIndex() - iLenStartIndex;
  }
コード例 #20
0
  @Override
  public ChannelBuffer encode(PlayerSpawnMessage message) throws IOException {
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();

    buffer.writeByte(message.getPlayerId());
    ChannelBufferUtils.writeString(buffer, message.getName());
    buffer.writeShort((short) (message.getX() * 32));
    buffer.writeShort((short) (message.getY() * 32));
    buffer.writeShort((short) (message.getZ() * 32));
    buffer.writeByte((byte) ((int) (message.getYaw() * 256 / 360) & 255));
    buffer.writeByte((byte) ((int) (message.getPitch() * 256 / 360) & 255));

    return buffer;
  }
コード例 #21
0
    @Override
    public void write(ChannelBuffer bb, OFBsnVlanCounterStatsEntryVer13 message) {
      int startIndex = bb.writerIndex();
      // length is length of variable message, will be updated at the end
      int lengthIndex = bb.writerIndex();
      bb.writeShort(U16.t(0));

      bb.writeShort(U16.t(message.vlanVid));
      // pad: 4 bytes
      bb.writeZero(4);
      ChannelUtils.writeList(bb, message.values);

      // update length field
      int length = bb.writerIndex() - startIndex;
      bb.setShort(lengthIndex, length);
    }
コード例 #22
0
  /*
   * (non-Javadoc)
   *
   * @see org.jboss.netty.handler.codec.oneone.OneToOneEncoder#encode(org.jboss
   * .netty.channel.ChannelHandlerContext, org.jboss.netty.channel.Channel, java.lang.Object)
   */
  @Override
  protected Object encode(final ChannelHandlerContext ctx, final Channel channel, final Object msg)
      throws Exception {

    final ChannelBuffer message = (ChannelBuffer) msg;

    final AuthToClientChannelHandler channelHandler =
        (AuthToClientChannelHandler) ctx.getPipeline().getLast();
    final int opcode = message.readUnsignedByte();
    final int size = message.readableBytes();

    final ChannelBuffer frame = ChannelBuffers.buffer(ByteOrder.LITTLE_ENDIAN, (size + 3));
    frame.writeByte(opcode);
    frame.writeShort(size);

    final byte[] tmpa = new byte[message.readableBytes()];
    message.readBytes(tmpa);
    frame.writeBytes(channelHandler.getCrypt().encrypt(tmpa));

    log.debug(String.format("[SEND PACKET] :  0x%02X", opcode));
    final List<String> d =
        breakStringInChunks(new BigInteger(1, tmpa).toString(16).toUpperCase(), 16);
    for (final String string : d) {
      log.debug(string);
    }
    return frame;
  }
コード例 #23
0
    @Override
    public void write(ChannelBuffer bb, OFBsnPduTxRequestVer10 message) {
      int startIndex = bb.writerIndex();
      // fixed value property version = 1
      bb.writeByte((byte) 0x1);
      // fixed value property type = 4
      bb.writeByte((byte) 0x4);
      // length is length of variable message, will be updated at the end
      int lengthIndex = bb.writerIndex();
      bb.writeShort(U16.t(0));

      bb.writeInt(U32.t(message.xid));
      // fixed value property experimenter = 0x5c16c7L
      bb.writeInt(0x5c16c7);
      // fixed value property subtype = 0x1fL
      bb.writeInt(0x1f);
      bb.writeInt(U32.t(message.txIntervalMs));
      message.portNo.write2Bytes(bb);
      bb.writeByte(U8.t(message.slotNum));
      // pad: 3 bytes
      bb.writeZero(3);
      bb.writeBytes(message.data);

      // update length field
      int length = bb.writerIndex() - startIndex;
      bb.setShort(lengthIndex, length);
    }
コード例 #24
0
 @Override
 public void writeTo(ChannelBuffer data) {
   super.writeTo(data);
   data.writeByte(this.virtualLanPriorityCodePoint);
   data.writeShort((short) 0);
   data.writeByte((byte) 0);
 }
コード例 #25
0
 public GameDownBuffer putString(String src, String encode) throws UnsupportedEncodingException {
   if (src == null) src = "";
   byte[] strData = src.getBytes(encode);
   buffer.writeShort(strData.length);
   buffer.writeBytes(strData);
   return this;
 }
コード例 #26
0
 private void sendReply(Channel channel, int checksum) {
   ChannelBuffer reply = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 3);
   reply.writeByte(0x02);
   reply.writeShort((short) checksum);
   if (channel != null) {
     channel.write(reply);
   }
 }
コード例 #27
0
 @Override
 public ChannelBuffer encode(EntityObjectMessage message) throws IOException {
   ChannelBuffer buffer = ChannelBuffers.buffer(message.getThrowerId() > 0 ? 27 : 21);
   buffer.writeInt(message.getEntityId());
   buffer.writeByte(message.getType());
   buffer.writeInt(message.getX());
   buffer.writeInt(message.getY());
   buffer.writeInt(message.getZ());
   int throwerId = message.getThrowerId();
   buffer.writeInt(throwerId);
   if (throwerId > 0) {
     buffer.writeShort(message.getSpeedX());
     buffer.writeShort(message.getSpeedY());
     buffer.writeShort(message.getSpeedZ());
   }
   return buffer;
 }
コード例 #28
0
ファイル: PlayerListCodec.java プロジェクト: Orcem/Vanilla
 @Override
 public ChannelBuffer encode(PlayerListMessage message) throws IOException {
   ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
   ChannelBufferUtils.writeString(buffer, message.getPlayerName());
   buffer.writeByte(message.playerIsOnline() ? 1 : 0);
   buffer.writeShort(message.getPing());
   return buffer;
 }
コード例 #29
0
    @Override
    public void write(ChannelBuffer bb, OFActionSetFieldVer12 message) {
      int startIndex = bb.writerIndex();
      // fixed value property type = 25
      bb.writeShort((short) 0x19);
      // length is length of variable message, will be updated at the end
      int lengthIndex = bb.writerIndex();
      bb.writeShort(U16.t(0));

      message.field.writeTo(bb);

      // update length field
      int length = bb.writerIndex() - startIndex;
      int alignedLength = ((length + 7) / 8 * 8);
      bb.setShort(lengthIndex, alignedLength);
      // align message to 8 bytes
      bb.writeZero(alignedLength - length);
    }
コード例 #30
0
 @Override
 public void write(ChannelBuffer bb, OFBsnGentableDescStatsRequestVer13 message) {
   // fixed value property version = 4
   bb.writeByte((byte) 0x4);
   // fixed value property type = 18
   bb.writeByte((byte) 0x12);
   // fixed value property length = 24
   bb.writeShort((short) 0x18);
   bb.writeInt(U32.t(message.xid));
   // fixed value property statsType = 65535
   bb.writeShort((short) 0xffff);
   OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
   // pad: 4 bytes
   bb.writeZero(4);
   // fixed value property experimenter = 0x5c16c7L
   bb.writeInt(0x5c16c7);
   // fixed value property subtype = 0x4L
   bb.writeInt(0x4);
 }