Extraction Options¶
pcapkit.foundation.options contains the options classes
Extractor and
extract() take as dump, reassembly,
traceflow and stream, one per feature. pcapkit and
pcapkit.interface export them.
- class pcapkit.foundation.options.DumpOptions(*, fout, format='tree', files=False, extension=True)[source]¶
Bases:
InfoOutput settings of an
Extractor.- Parameters:
fout (
str) – output file name, or underfilesthe directory the files go informat (
Literal['pcap','cap','pcapng','json','tree','text','txt','plist','xml']) – output file format, a key ofExtractor.__output__files (
bool) – whether each frame is dumped to a file of its ownextension (
bool) – whether the format’s file extension is appended tofoutwhen it lacks one; not underfiles
- Raises:
RegistryError – If
foutis not astr.
Added in version 1.7.0.
- class pcapkit.foundation.options.ReassemblyOptions(*, protocols, strict=True, store=True, timeout=None)[source]¶
Bases:
InfoReassembly settings of an
Extractor.- Parameters:
protocols (
Iterable[str]) – names of the reassemblers to enable, as registered inExtractor.__reassembly__, matched lower-casedstrict (
bool) – whether a datagram not completely reassembled is reported as the tuple of its received runs, rather than as one contiguous payloadstore (
bool) – whether reassembled datagrams are storedtimeout (
float|None) – reassembly timeout in seconds, on the capture’s own clock;Noneselects each protocol’s own default – 60 seconds for IPv4 (RFC 1122 Section 3.3.2) and IPv6 (RFC 8200 Section 4.5), disabled for TCP and DTLS, which no specification gives a deadline (RFC 6347 Section 4.2.3). Passmath.infto disable it everywhere
An
Extractorgiven no names turns the feature off, asNonedoes, and warns that it does.- Raises:
RegistryError – If
protocolsis not a list of names.
Added in version 1.7.0.
- class pcapkit.foundation.options.TraceFlowOptions(*, protocols, fout='./tmp', format='pcap', byteorder=sys.byteorder, nanosecond=False, bidirectional=True, analyze=False)[source]¶
Bases:
InfoFlow tracing settings of an
Extractor.- Parameters:
protocols (
Iterable[str]) – names of the flow tracers to enable, as registered inExtractor.__traceflow__, matched lower-casedfout (
str) – output root pathformat (
str) – output file formatbyteorder (
Literal['big','little']) – output file byte ordernanosecond (
bool) – output nanosecond-resolution file flagbidirectional (
bool) – whether both halves of a conversation are traced as one flow;Falsetraces a flow per directionanalyze (
bool) – whether each traced flow reassembles its application layer, so that itspacketcan be read. Off by default, because it buffers every traced payload – a cost tracing does not otherwise pay. Unavailable on thepysharkengine, which reports dissected fields rather than the octets behind them
An
Extractorgiven no names turns the feature off, asNonedoes, and warns that it does.- Raises:
RegistryError – If
protocolsis not a list of names.
Added in version 1.7.0.
- class pcapkit.foundation.options.StreamOptions(*, buffer_size=io.DEFAULT_BUFFER_SIZE, buffer_save=False, buffer_path=None, no_eof=False)[source]¶
Bases:
InfoInput stream settings of an
Extractor.The buffer settings apply to an input that cannot seek, such as a pipe, which is read through a
SeekableReader.- Parameters:
buffer_size (
int) – buffer size for reading the inputbuffer_save (
bool) – whether the buffered input is saved to a filebuffer_path (
str|None) – path of that file;Noneuses a temporary file, deleted when the input is closedno_eof (
bool) – whether to not raiseEOFErrorat the end of the input but retry instead, which is what a live capture on a pipe or on standard input wants, since a read there blocks until the writer produces more or closes. Retrying stops as soon as one retry finds nothing new, so an exhausted input finishes rather than spinning; on a seekable input, where nothing blocks, that means a file still being appended to ends at the data present when the extraction reached it
Added in version 1.7.0.