private void W_PopPacket(object sender, byte[] e) { if (DebugLogger.LogNeeded()) { var _ = DebugLogger.LogPacketWithTimestamp(e); } PacketPoped?.Invoke(sender, e); }
public void PushPacket([ReadOnlyArray] byte[] packet) { // Packets must contain valid IPv4 headers if (packet.Length < 20 || packet[0] >> 4 != 4) { return; } var proto = packet[9]; switch (proto) { case 6: // TCP break; case 17: // UDP break; default: return; } if (DebugLogger.LogNeeded()) { var _ = DebugLogger.LogPacketWithTimestamp(packet); } if (proto == 6) { _ = executeLwipTask(() => wintun.PushPacket(packet)); } else { try { TunDatagramAdapter.ProcessIpPayload(packet, this); } catch (Exception ex) { DebugLogger.Log("Error processing udp ip packet: " + ex.ToString()); } } }