swift-nio-extras/Tests/NIOExtrasTests/PCAPRingBufferTest+XCTest.swift
Peter Adams fe17f53108
Capture packets leading upto a user triggered event. (#94)
Motivation:

Capturing all packets is expensive. Recording to a ring buffer and
then outputting on a triggering event allows this cost to be reduced.

Modifications:

Add a new handler - NIOPCAPRingCaptureHandler.
This derives from the existing NIOWritePCAPHandler and generates PCAP recordings.
A ring buffer contained in this handler stores the captured packets until RecordPreviousPackets
is received as a user message at which point they are flushed to the sink.

Result:

There is a new handler capable of outputting packet captured data only in the build up to
a known event.

Co-authored-by: Cory Benfield <lukasa@apple.com>
Co-authored-by: George Barnett <gbrntt@gmail.com>
2020-07-24 13:55:12 +01:00

43 lines
1.4 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
//
// PCAPRingBufferTest+XCTest.swift
//
import XCTest
///
/// NOTE: This file was generated by generate_linux_tests.rb
///
/// Do NOT edit this file directly as it will be regenerated automatically when needed.
///
extension PCAPRingBufferTest {
static var allTests : [(String, (PCAPRingBufferTest) -> () throws -> Void)] {
return [
("testNotLimited", testNotLimited),
("testFragmentLimit", testFragmentLimit),
("testByteLimit", testByteLimit),
("testByteOnLimit", testByteOnLimit),
("testExtremeByteLimit", testExtremeByteLimit),
("testUnusedBuffer", testUnusedBuffer),
("testDoubleEmitZero", testDoubleEmitZero),
("testDoubleEmitSome", testDoubleEmitSome),
("testAsHandlerSink", testAsHandlerSink),
("testHandler", testHandler),
]
}
}