-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4ff03a
commit ef69c54
Showing
22 changed files
with
1,448 additions
and
88 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use crate::tracing::error::TracerError; | ||
use crate::tracing::packet::icmp_extension::extension_object::{ClassNum, ExtensionObject}; | ||
use crate::tracing::packet::icmp_extension::extension_structure::ExtensionStructure; | ||
use crate::tracing::packet::icmp_extension::mpls_label_stack::MplsLabelStack; | ||
use crate::tracing::packet::icmp_extension::mpls_label_stack_member::MplsLabelStackMember; | ||
use crate::tracing::probe::{ | ||
MplsExtensionData, MplsExtensionMember, ProbeResponseExtension, ProbeResponseExtensions, | ||
}; | ||
use crate::tracing::util::Required; | ||
|
||
impl TryFrom<&[u8]> for ProbeResponseExtensions { | ||
type Error = TracerError; | ||
|
||
fn try_from(value: &[u8]) -> Result<Self, Self::Error> { | ||
Self::try_from(ExtensionStructure::new_view(value).req()?) | ||
} | ||
} | ||
|
||
impl TryFrom<ExtensionStructure<'_>> for ProbeResponseExtensions { | ||
type Error = TracerError; | ||
|
||
fn try_from(value: ExtensionStructure<'_>) -> Result<Self, Self::Error> { | ||
let extensions = value | ||
.objects() | ||
.flat_map(|obj| ExtensionObject::new_view(obj).req()) | ||
.map(|obj| match obj.get_class_num() { | ||
ClassNum::MultiProtocolLabelSwitchingLabelStack => { | ||
MplsLabelStack::new_view(obj.payload()) | ||
.req() | ||
.map(|mpls| ProbeResponseExtension::Mpls(MplsExtensionData::from(mpls))) | ||
} | ||
_ => Ok(ProbeResponseExtension::Unknown), | ||
}) | ||
.collect::<Result<_, _>>()?; | ||
Ok(Self { extensions }) | ||
} | ||
} | ||
|
||
impl From<MplsLabelStack<'_>> for MplsExtensionData { | ||
fn from(value: MplsLabelStack<'_>) -> Self { | ||
Self { | ||
members: value | ||
.members() | ||
.flat_map(|member| MplsLabelStackMember::new_view(member).req()) | ||
.map(MplsExtensionMember::from) | ||
.collect(), | ||
} | ||
} | ||
} | ||
|
||
impl From<MplsLabelStackMember<'_>> for MplsExtensionMember { | ||
fn from(value: MplsLabelStackMember<'_>) -> Self { | ||
Self { | ||
label: value.get_label(), | ||
exp: value.get_exp(), | ||
bos: value.get_bos(), | ||
ttl: value.get_ttl(), | ||
} | ||
} | ||
} |
Oops, something went wrong.