#[non_exhaustive]pub enum CaptureError {
NoInterface {
refused: Vec<(String, CaptureError)>,
},
NoReader {
opened: usize,
source: Error,
},
UnsupportedLinkType {
interface: String,
dlt: i32,
},
Filter {
filter: String,
source: LibraryError,
},
Open {
interface: String,
source: LibraryError,
},
Denied {
interface: String,
source: LibraryError,
},
OutOfDescriptors {
links: Vec<String>,
},
}Expand description
Why a capture could not be started.
An interface that cannot be captured is skipped and logged: a host has several,
most irrelevant to a given probe, and a virtual bridge declining should not stop a
scan. Only every interface failing leaves nowhere to hear an answer, and that is
NoInterface, which carries each link’s own refusal.
Privilege is one cause among several and is named only where it is the cause. A
root process can be refused a capture by a filter the link cannot express, a
framing nothing here parses, or an adapter the capture driver will not bind, and
blaming privilege for those misleads someone who already has it.
is_denied is the question to ask.
#[non_exhaustive] because new platform-specific failures show up first in the
capture layer.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NoInterface
No link could be captured on, so nothing could be heard.
Carries every link’s refusal, since they need not agree and the reason is what
there is to act on. Where every one was Denied the message
says so in one sentence, the ordinary case of an unprivileged process; otherwise
it gives each reason once, naming the link where one link gave it and counting
them where several did.
Fields
refused: Vec<(String, CaptureError)>Each link tried, by name, and why it could not be captured on, in the order tried.
NoReader
Every link opened and none could be given a reader thread.
A runtime condition: a process near its thread limit, or a cgroup capping them.
Separate from NoInterface because the remedy differs and
has nothing to do with privilege.
Fields
UnsupportedLinkType
A link carries frames this crate cannot strip down to an IP packet.
The capture came up, but its data-link type is one nothing here parses. Skipped, since guessing at a framing would report a network that is not there.
Filter
The filter expression would not compile to a BPF program.
Either a mistake in the expression or a link that cannot express it: an
Ethernet address means nothing on a tunnel, and libpcap refuses to compile one
for it. Either way the expression is what to look at, so it is named.
Open
One named link could not be opened, for a reason other than privilege. Unlike
NoInterface this names the link, because the caller asked for that one and
there is nothing to fall back to.
Denied
One named link could not be opened because this process may not capture on it.
Separate from Open because its remedy lies outside the link:
root, or whatever grants the right to capture short of it, such as membership
of access_bpf on macOS or cap_net_raw on Linux. Decided by the status
libpcap activated the handle with, not by its message.
OutOfDescriptors
The process or the system ran out of descriptors partway through the links, so a capture would have been deaf on the links it did not reach.
Not skipped like a link that declines. A declining link is one the scan’s targets do not answer through; these are refused for a local shortage, and any of them may be where the replies arrive. Heard on the rest alone, those replies would read as targets that did not answer.
Implementations§
Source§impl CaptureError
impl CaptureError
Sourcepub fn is_denied(&self) -> bool
pub fn is_denied(&self) -> bool
Whether this failure is a missing privilege and nothing else.
True of a link that Denied this process, and of a capture
with no link because every link did. A capture refused on other grounds, even
alongside links that denied it, answers false: the privilege would not have
made it work.
Trait Implementations§
Source§impl Coded for CaptureError
impl Coded for CaptureError
Source§impl Debug for CaptureError
impl Debug for CaptureError
Source§impl Display for CaptureError
impl Display for CaptureError
Source§impl Error for CaptureError
impl Error for CaptureError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<CaptureError> for StrategyError
impl From<CaptureError> for StrategyError
Source§fn from(source: CaptureError) -> Self
fn from(source: CaptureError) -> Self
Source§impl From<CaptureError> for TransportError
impl From<CaptureError> for TransportError
Source§fn from(source: CaptureError) -> Self
fn from(source: CaptureError) -> Self
Auto Trait Implementations§
impl !RefUnwindSafe for CaptureError
impl !UnwindSafe for CaptureError
impl Freeze for CaptureError
impl Send for CaptureError
impl Sync for CaptureError
impl Unpin for CaptureError
impl UnsafeUnpin for CaptureError
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more