protected override void PutBody(ByteBuffer buf) { // 初始密钥 //buf.Put(user.QQKey.InitKey); buf.PutChar((char)user.QQKey.LoginInfo_Magic_Token.Length); buf.Put(user.QQKey.LoginInfo_Magic_Token); ByteBuffer DecodedBuf = new ByteBuffer(); DecodedBuf.PutChar((char)0x0101); DecodedBuf.PutChar((char)0x0000); DecodedBuf.Put((byte)Client.QQUser.QQKey.LoginInfo_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_Token); DecodedBuf.Put(new byte[]{0x10,0x03,0xC8,0xEC,0xC8,0x96, 0x8B,0xF2,0xB3,0x6B,0x4D,0x0C,0x5C,0xE0,0x6A,0x51,0xCE});//unknown data //Client.QQUser.QQKey.Key = Client.QQUser.QQKey.LoginInfo_Key1;//可能要用到 byte[] EncodedBuf = crypter.Encrypt(DecodedBuf.ToByteArray(), user.QQKey.LoginInfo_Key1); #if DEBUG Client.LogManager.Log(ToString() + " key:" + Utils.Util.ToHex(user.QQKey.LoginInfo_Key1)); Client.LogManager.Log(ToString() + " UnBody:" + Utils.Util.ToHex(DecodedBuf.ToByteArray())); #endif buf.Put(EncodedBuf); #if DEBUG Client.LogManager.Log(ToString() + " EnBody:" + Utils.Util.ToHex(buf.ToByteArray())); #endif }
public void ByteBuffer_GetByteReturnsCorrectData() { var buffer = new byte[1]; buffer[0] = 99; var uut = new ByteBuffer(buffer); Assert.AreEqual((byte)99, uut.Get(0)); }
protected override void PutBody(ByteBuffer buf) { buf.Put(Reply); #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void PutBody(ByteBuffer buf) { buf.PutChar((char)Client.QQUser.QQKey.LoginInfo_Magic_Token.Length); buf.Put(user.QQKey.LoginInfo_Magic_Token); ByteBuffer DecodedBuf = new ByteBuffer(); DecodedBuf.PutChar((char)0x011A); DecodedBuf.PutChar((char)0x0001); DecodedBuf.Put(VersionData.QQ09_LOCALE); DecodedBuf.Put(VersionData.QQ09_VERSION_SPEC); DecodedBuf.Put((byte)0x00); DecodedBuf.Put((byte)Client.QQUser.QQKey.Answer_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.Answer_Token); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_UnknowData2); DecodedBuf.Put(Client.ServerTime); DecodedBuf.Put(Client.ClientIP); DecodedBuf.Position += 4;//00 00 00 00 DecodedBuf.PutChar((char)Client.QQUser.QQKey.LoginInfo_Large_Token.Length); DecodedBuf.Put(Client.QQUser.QQKey.LoginInfo_Large_Token); DecodedBuf.PutUShort(this.Pos); DecodedBuf.Position += 2;// 00 00 DecodedBuf.PutChar((char)0x0071); DecodedBuf.Position += 0x0070;//0x0071 zeros DecodedBuf.Put(0x00); byte[] EncodedBuf = crypter.Encrypt(DecodedBuf.ToByteArray(), user.QQKey.LoginInfo_Key1); #if DEBUG Client.LogManager.Log(ToString() + " QQKey.LoginInfo_Key1:" + Utils.Util.ToHex(user.QQKey.LoginInfo_Key1)); Client.LogManager.Log(ToString() + " pos:"+this.Pos+" UnBody:" + Utils.Util.ToHex(DecodedBuf.ToByteArray())); #endif buf.Put(EncodedBuf); #if DEBUG Client.LogManager.Log(ToString() + " EnBody:" + Utils.Util.ToHex(buf.ToByteArray())); #endif }
protected override void OnDecode(ByteBuffer buffer, int count) { if (count-- > 0) { this.TxnId = AmqpCodec.DecodeBinary(buffer); } }
public void Encode(ByteBuffer buffer) { byte[] bytes = this.uuid.ToByteArray(); buffer.Validate(true, bytes.Length); Buffer.BlockCopy(bytes, 0, buffer.Buffer, buffer.WritePos, bytes.Length); buffer.Append(bytes.Length); }
protected override void PutBody(ByteBuffer buf) { // 命令类型 buf.Put((byte)SubCommand); // 内部ID buf.PutInt(ClusterId); }
private void InitializeSettings() { // TODO: clean this stuff up /*****************************************/ int size = Core.Rom.Length; _size = Core.Rom.Length < 8448 ? 8448 : Core.Rom.Length; //8448 or Rom size, whichever is bigger _numberOfLoadImages = (byte)(_size / 8448); // TODO: why are we making a redundant copy? _loadedImages = new ByteBuffer(_size); for (int i = 0; i < size; i++) { _loadedImages[i] = Core.Rom[i]; } if (size < 8448) { for (int i = size; i < _size; i++) { _loadedImages[i] = DefaultHeader[i]; } } /*****************************************/ InitializeRom(); BankConfiguration(0); }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " Decoded Data:" + Utils.Util.ToHex(buf.ToByteArray())); Client.LogManager.Log(ToString() + ":No use data until now!You can check this dat! It's said it has a key"); #endif }
public void Can_Encode_And_Decode_MulipleValue_Fields_SingleValue_Alt_Format() { var wireFrame = new byte[] { 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xd0, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x09, 0xb1, 0x00, 0x00, 0x00, 0x00, 0x40, 0x70, 0xff, 0xff, 0xff, 0xff, 0x60, 0xff, 0xff, 0x40, 0x40, 0x40, 0x40, 0xa3, 0x24, 0x30, 0x64, 0x36, 0x36, 0x32, 0x65, 0x64, 0x35, 0x2d, 0x33, 0x30, 0x62, 0x38, 0x2d, 0x34, 0x32, 0x62, 0x39, 0x2d, 0x61, 0x61, 0x37, 0x30, 0x2d, 0x66, 0x33, 0x30, 0x66, 0x30, 0x37, 0x66, 0x38, 0x61, 0x34, 0x62, 0x34, 0x40, 0x38, 0x61, 0x34, 0x62, 0x34, }; var buffer = new ByteBuffer(wireFrame); var decodedValue = AmqpCodec.DecodeObject<Open>(buffer); Assert.NotNull(decodedValue.DesiredCapabilities); Assert.AreEqual(1, decodedValue.DesiredCapabilities.Length); Assert.IsNotNullOrEmpty(decodedValue.DesiredCapabilities[0]); }
protected override void PutBody(ByteBuffer buf) { buf.Put((byte)SubCommand); buf.Put((byte)Type); buf.PutInt(ParentClusterId); buf.PutInt(ClusterId); }
public void GetInt32Test_Exception_OutOfRange() { var bytes = new byte[] { 0x00, 0x00, 0x00, 0x01 }; var bb = new ByteBuffer(bytes, ByteOrder.BigEndian); bb.GetInt32(); bb.GetInt32(); }
/// <summary> /// Decode input as a control parameters in NDN-TLV and set the fields of the /// controlResponse object. /// </summary> /// /// <param name="controlResponse"></param> /// <param name="input"></param> /// <param name="copy">unchanged while the Blob values are used.</param> /// <exception cref="EncodingException">For invalid encoding</exception> public override void decodeControlResponse(ControlResponse controlResponse, ByteBuffer input, bool copy) { TlvDecoder decoder = new TlvDecoder(input); int endOffset = decoder .readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.NfdCommand_ControlResponse); controlResponse.setStatusCode((int) decoder .readNonNegativeIntegerTlv(net.named_data.jndn.encoding.tlv.Tlv.NfdCommand_StatusCode)); // Set copy false since we just immediately get a string. Blob statusText = new Blob( decoder.readBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.NfdCommand_StatusText), false); controlResponse.setStatusText(statusText.toString()); // Decode the body. if (decoder .peekType(net.named_data.jndn.encoding.tlv.Tlv.ControlParameters_ControlParameters, endOffset)) { controlResponse.setBodyAsControlParameters(new ControlParameters()); // Decode into the existing ControlParameters to avoid copying. decodeControlParameters( controlResponse.getBodyAsControlParameters(), decoder, copy); } else controlResponse.setBodyAsControlParameters(null); decoder.finishNestedTlvs(endOffset); }
/// <summary> /// </summary> /// <param name="buf">The buf.</param> public void Read(ByteBuffer buf) { // 发送者 Sender = buf.GetInt(); // 未知的4字节 buf.GetInt(); // 昵称 int len = buf.Get() & 0xFF; Nick = Utils.Util.GetString(buf, len); // 群名称 len = buf.Get() & 0xFF; Site = Utils.Util.GetString(buf, len); // 未知的1字节 buf.Get(); // 时间 Time = (long)buf.GetInt() * 1000L; // 后面的内容长度 len = buf.GetUShort(); // 得到字体属性长度,然后得到消息内容 int fontStyleLength = buf.Get(buf.Position + len - 1) & 0xFF; Message = Utils.Util.GetString(buf, len - fontStyleLength); // 字体属性 FontStyle = new FontStyle(); FontStyle.Read(buf); }
public CustomAudioDevice(Context context) { if (!InstanceFieldsInitialized) { InitializeInstanceFields(); InstanceFieldsInitialized = true; } this.m_context = context; try { m_playBuffer = ByteBuffer.allocateDirect(MAX_SAMPLES); m_recBuffer = ByteBuffer.allocateDirect(MAX_SAMPLES); } catch (Exception e) { Log.e(LOG_TAG, e.Message); } m_tempBufPlay = new sbyte[MAX_SAMPLES]; m_tempBufRec = new sbyte[MAX_SAMPLES]; m_captureSettings = new AudioSettings(SAMPLING_RATE, NUM_CHANNELS_CAPTURING); m_rendererSettings = new AudioSettings(SAMPLING_RATE, NUM_CHANNELS_RENDERING); m_audioManager = (AudioManager) m_context.getSystemService(Context.AUDIO_SERVICE); m_audioManager.Mode = AudioManager.MODE_IN_COMMUNICATION; }
public static void DecodeDescriptor(ByteBuffer buffer, out AmqpSymbol name, out ulong code) { name = default(AmqpSymbol); code = 0; FormatCode formatCode = AmqpEncoding.ReadFormatCode(buffer); if (formatCode == FormatCode.Described) { formatCode = AmqpEncoding.ReadFormatCode(buffer); } if (formatCode == FormatCode.Symbol8 || formatCode == FormatCode.Symbol32) { name = SymbolEncoding.Decode(buffer, formatCode); } else if (formatCode == FormatCode.ULong || formatCode == FormatCode.ULong0 || formatCode == FormatCode.SmallULong) { code = ULongEncoding.Decode(buffer, formatCode).Value; } else { throw AmqpEncoding.GetInvalidFormatCodeException(formatCode, buffer.Offset); } }
internal bool OnFrame(ITransport transport, ByteBuffer buffer, out SaslCode code) { ushort channel; DescribedList command; Frame.GetFrame(buffer, out channel, out command); Trace.WriteLine(TraceLevel.Frame, "RECV {0}", command); bool shouldContinue = true; if (command.Descriptor.Code == Codec.SaslOutcome.Code) { code = ((SaslOutcome)command).Code; shouldContinue = false; } else { code = SaslCode.Ok; DescribedList response = this.OnCommand(command); if (response != null) { this.SendCommand(transport, response); shouldContinue = response.Descriptor.Code != Codec.SaslOutcome.Code; } } return shouldContinue; }
public static uint ReadUInt(ByteBuffer buffer) { buffer.Validate(false, FixedWidth.UInt); uint data = ReadUInt(buffer.Buffer, buffer.Offset, buffer.Length); buffer.Complete(FixedWidth.UInt); return data; }
public void Decode(ByteBuffer buffer) { byte[] bytes = new byte[16]; Buffer.BlockCopy(buffer.Buffer, buffer.Offset, bytes, 0, bytes.Length); this.uuid = new Guid(bytes); buffer.Complete(bytes.Length); }
public static sbyte ReadByte(ByteBuffer buffer) { buffer.Validate(false, FixedWidth.Byte); sbyte data = (sbyte)buffer.Buffer[buffer.Offset]; buffer.Complete(FixedWidth.Byte); return data; }
/// <summary> /// Create a generic DER node with the given nodeType. This is a private /// constructor used by one of the public DerNode subclasses defined below. /// </summary> /// /// <param name="nodeType">The DER node type, a value from DerNodeType.</param> private DerNode(int nodeType) { this.parent_ = null; this.header_ = ILOG.J2CsMapping.NIO.ByteBuffer.allocate(0); this.payload_ = new DynamicByteBuffer(0); nodeType_ = nodeType; }
/// <summary> /// </summary> /// <param name="buf">The buf.</param> public void Read(ByteBuffer buf) { ByteBuffer temp = new ByteBuffer(); int i = 0; while (true) { byte b = buf.Get(); if (b != 0x1F) { if (b != 0x1E) { temp.Put(b); } else { if (i == 0) { QQ = Utils.Util.GetInt(Utils.Util.GetString(temp.ToByteArray()), 0000); } else if (i == 1) Nick = Utils.Util.GetString(temp.ToByteArray()); else if (i == 2) Province = Utils.Util.GetString(temp.ToByteArray()); i++; temp.Initialize(); } } else { Face = Utils.Util.GetInt(Utils.Util.GetString(temp.ToByteArray()), 0); break; } } }
void parser_onObjectReceived(int type, uint objId, uint instId, uint timestamp, ByteBuffer data) { UAVObject tobj = _objmgr.getObject(objId); if (tobj == null) { // TODO: Return a NAK since we don't know this object return; } // Make sure this is a data object UAVDataObject dobj = null; try { dobj = (UAVDataObject)tobj; } catch (Exception) { // Failed to cast to a data object return; } // Create a new instance, unpack and register UAVDataObject instobj = dobj.clone(instId); instobj.unpack(data); instobj.timestamp = timestamp; retVal.Add(instobj); }
public static ByteBuffer Encode(FrameType type, ushort channel, DescribedList command) { ByteBuffer buffer = new ByteBuffer(cmdBufferSize, true); EncodeFrame(buffer, type, channel, command); AmqpBitConverter.WriteInt(buffer.Buffer, 0, buffer.Length); return buffer; }
protected override void PutBody(ByteBuffer buf) { buf.Put((byte)SubCommand); buf.PutInt(ClusterId); buf.PutInt(0); buf.PutInt(Start); }
public static ByteBuffer Encode(FrameType type, ushort channel, Transfer transfer, ByteBuffer payload, int maxFrameSize, out int payloadSize) { int bufferSize = cmdBufferSize + payload.Length; if (bufferSize > maxFrameSize) { bufferSize = maxFrameSize; } bool more = false; // estimate it first if (payload.Length > bufferSize - 32) { transfer.More = more = true; } ByteBuffer buffer = new ByteBuffer(bufferSize, false); EncodeFrame(buffer, type, channel, transfer); if (more && payload.Length <= buffer.Size) { // guessed it wrong. correct it transfer.More = false; buffer.Reset(); EncodeFrame(buffer, type, channel, transfer); } payloadSize = Math.Min(payload.Length, buffer.Size); AmqpBitConverter.WriteBytes(buffer, payload.Buffer, payload.Offset, payloadSize); payload.Complete(payloadSize); AmqpBitConverter.WriteInt(buffer.Buffer, 0, buffer.Length); return buffer; }
public static byte ReadUByte(ByteBuffer buffer) { buffer.EnsureLength(FixedWidth.UByte); byte data = buffer.Buffer[buffer.Offset]; buffer.Complete(FixedWidth.UByte); return data; }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " Decoded data:" + Utils.Util.ToHex(buf.ToByteArray())); #endif //byte result = buf.Get(); IsRedirect = false; ReplyCode = (ReplyCode)buf.Get(); if (ReplyCode == ReplyCode.OK) { ServerTime = buf.GetByteArray(4); ClientIP = buf.GetByteArray(4); buf.Position += 9; int len = (int)buf.Get(); Token = buf.GetByteArray(len); byte result=buf.Get(); if (result != 0x00) { IsRedirect = true; Client.LoginRedirect = true; Client.ServerInfo.CSP_wRedirectCount = result; Client.ServerInfo.CSP_cRedirectCount = buf.Get(); Client.ServerInfo.CSP_dwConnIspID = buf.GetByteArray(4); Client.ServerInfo.CSP_dwServerReserve = buf.GetByteArray(4); RedirectIP=buf.GetByteArray(4); Client.ServerInfo.CSP_dwConnIP =RedirectIP ; } } else { Client.LogManager.Log(string.Format(ToString() + " ReplyCode!=ReplyCode.OK: {0:X}", ReplyCode)); } }
protected override void ParseBody(ByteBuffer buf) { #if DEBUG Client.LogManager.Log(ToString() + " " + Utils.Util.ToHex(buf.ToByteArray())); #endif ReplyCode = (ReplyCode)buf.Get(); }
protected override void PutBody(ByteBuffer buf) { buf.Put((byte)SubCommand); buf.PutInt(ClusterId); buf.PutInt(user.QQ); Card.Write(buf); }