private byte[] Filter_PacketReceived(byte[] buffer, CapturedPacketArgs args) { NetPacketParser.EthernetPacket packet = new NetPacketParser.EthernetPacket(buffer); var netPacketViewModel = new NetPacketViewModel(packet, _packetIndex++); Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { NetPacketViewModels.Add(netPacketViewModel); }).AsTask(); return(null); }
private byte[] Filter_PacketReceived(byte[] buffer, CapturedPacketArgs args) { NetPacketViewModel netPacketViewModel = new(); for (int i = 0; i < buffer.Length; ++i) { netPacketViewModel.Content += NetPacketViewModel.HexTable[buffer[i]]; } this.Dispatcher.Invoke(() => { NetPacketViewModels.Add(netPacketViewModel); }, DispatcherPriority.Render); return(null); }
private byte[] Filter_PacketReceived(byte[] buffer, CapturedPacketArgs args) { NetPacketViewModel netPacketViewModel = new NetPacketViewModel(); for (int i = 0; i < buffer.Length; ++i) { netPacketViewModel.Content += buffer[i].ToString("X4") + " "; } NetPacketViewModels.Add(netPacketViewModel); byte[] modifiedBuffer = null; switch (args.Layer) { case FilteringLayer.NetworkLayer: IPAddress address; { switch (args.Direction) { case NetPacketDirection.Out: address = IPAddress.Parse("192.168.1.104"); address.GetAddressBytes().CopyTo(buffer, 16); modifiedBuffer = buffer; break; case NetPacketDirection.In: address = IPAddress.Parse("22.22.22.22"); address.GetAddressBytes().CopyTo(buffer, 12); buffer[10] = 0; buffer[11] = 0; var checkSumCalculateBytes = (buffer[0] & 0xf) * 4; var checkSum = CalculateChecksum(buffer, checkSumCalculateBytes); buffer[10] = (byte)((checkSum & 0xff00) >> 8); buffer[11] = (byte)(checkSum & 0xff); modifiedBuffer = buffer; break; } } break; } return(modifiedBuffer); }