Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
haga-rak committed Jan 20, 2024
1 parent c70de74 commit 941dc27
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 56 deletions.
20 changes: 8 additions & 12 deletions src/Fluxzy.Core.Pcap/Pcapng/Merge/PcapBlockWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ private PcapngStreamWriter InternalCreateWriter()
return result;
}

public void Write(ref DataBlock content)
private void InternalWrite(ReadOnlySpan<byte> data)
{
if (_writer == null)
{
_writer = InternalCreateWriter();
}
_writer ??= InternalCreateWriter();
_outStream.Write(data);
}

_outStream.Write(content.Data.Span);
public void Write(ref DataBlock content)
{
InternalWrite(content.Data.Span);
}

public bool NotifyNewBlock(uint blockType, ReadOnlySpan<byte> buffer)
Expand Down Expand Up @@ -81,12 +82,7 @@ public bool NotifyNewBlock(uint blockType, ReadOnlySpan<byte> buffer)
|| blockType == InterfaceDescriptionBlock.BlockTypeValue
)
{
if (_writer == null)
{
_writer = InternalCreateWriter();
}

_outStream.Write(buffer);
InternalWrite(buffer);
}

return true;
Expand Down
10 changes: 1 addition & 9 deletions src/Fluxzy.Core.Pcap/Pcapng/Merge/SleepyStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Fluxzy.Core.Pcap.Pcapng.Merge
/// It saves the last offset read and allows closing the file descriptor
/// in between reads.
/// </summary>
internal class SleepyStream : IDisposable, IAsyncDisposable
internal class SleepyStream : IDisposable
{
private readonly Func<Stream> _streamFactory;
private long _offset;
Expand Down Expand Up @@ -89,13 +89,5 @@ public void Dispose()
{
_pendingStream?.Dispose();
}

public async ValueTask DisposeAsync()
{
if (_pendingStream != null)
{
await _pendingStream.DisposeAsync();
}
}
}
}
7 changes: 1 addition & 6 deletions src/Fluxzy.Core.Pcap/Pcapng/Merge/SleepyStreamBlockReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Fluxzy.Core.Pcap.Pcapng.Merge
{
internal abstract class SleepyStreamBlockReader : IBlockReader, IAsyncDisposable
internal abstract class SleepyStreamBlockReader : IBlockReader
{
private readonly SleepyStream _sleepyStream;
private Option _nextBlockOption = new();
Expand Down Expand Up @@ -96,11 +96,6 @@ public void Dispose()
{
_sleepyStream.Dispose();
}

public async ValueTask DisposeAsync()
{
await _sleepyStream.DisposeAsync();
}
}


Expand Down
10 changes: 0 additions & 10 deletions src/Fluxzy.Core.Pcap/Pcapng/Structs/IfMacAddressOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,5 @@ public int Write(Span<byte> buffer)

return OnWireLength;
}

public static IfMacAddressOption Parse(ReadOnlySpan<byte> buffer)
{
return new IfMacAddressOption(buffer.Slice(4, 6).ToArray());
}

public static int DirectWrite(Span<byte> buffer)
{
return new IfMacAddressOption().Write(buffer);
}
}
}
9 changes: 0 additions & 9 deletions src/Fluxzy.Core.Pcap/Pcapng/Structs/StringOptionBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,5 @@ public int Write(Span<byte> buffer)

return OnWireLength;
}

public static StringOptionBlock Parse(ReadOnlySpan<byte> buffer)
{
var optionLength = BinaryPrimitives.ReadUInt16LittleEndian(buffer.Slice(2));
var valueBuffer = buffer.Slice(4, optionLength);
string value = Encoding.UTF8.GetString(valueBuffer);

return new StringOptionBlock(BinaryPrimitives.ReadUInt16LittleEndian(buffer), value);
}
}
}
10 changes: 0 additions & 10 deletions src/Fluxzy.Core.Pcap/Pcapng/Structs/TsResolOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,5 @@ public int Write(Span<byte> buffer)

return 8;
}

public static TsResolOption Parse(ReadOnlySpan<byte> buffer)
{
return new TsResolOption(buffer[4]);
}

public static int DirectWrite(Span<byte> buffer)
{
return new TsResolOption().Write(buffer);
}
}
}

0 comments on commit 941dc27

Please sign in to comment.