-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
753c794
commit 4118634
Showing
22 changed files
with
1,432 additions
and
89 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,58 @@ | ||
use crate::tracing::error::TracerError; | ||
use crate::tracing::packet::icmp_extension::extension_object::{ClassNum, ExtensionObjectPacket}; | ||
use crate::tracing::packet::icmp_extension::extension_structure::ExtensionsPacket; | ||
use crate::tracing::packet::icmp_extension::mpls_label_stack::MplsLabelStackPacket; | ||
use crate::tracing::packet::icmp_extension::mpls_label_stack_member::MplsLabelStackMemberPacket; | ||
use crate::tracing::probe::{Extension, Extensions, MplsLabelStack, MplsLabelStackMember}; | ||
use crate::tracing::util::Required; | ||
|
||
impl TryFrom<&[u8]> for Extensions { | ||
type Error = TracerError; | ||
|
||
fn try_from(value: &[u8]) -> Result<Self, Self::Error> { | ||
Self::try_from(ExtensionsPacket::new_view(value).req()?) | ||
} | ||
} | ||
|
||
impl TryFrom<ExtensionsPacket<'_>> for Extensions { | ||
type Error = TracerError; | ||
|
||
fn try_from(value: ExtensionsPacket<'_>) -> Result<Self, Self::Error> { | ||
let extensions = value | ||
.objects() | ||
.flat_map(|obj| ExtensionObjectPacket::new_view(obj).req()) | ||
.map(|obj| match obj.get_class_num() { | ||
ClassNum::MultiProtocolLabelSwitchingLabelStack => { | ||
MplsLabelStackPacket::new_view(obj.payload()) | ||
.req() | ||
.map(|mpls| Extension::Mpls(MplsLabelStack::from(mpls))) | ||
} | ||
_ => Ok(Extension::Unknown), | ||
}) | ||
.collect::<Result<_, _>>()?; | ||
Ok(Self { extensions }) | ||
} | ||
} | ||
|
||
impl From<MplsLabelStackPacket<'_>> for MplsLabelStack { | ||
fn from(value: MplsLabelStackPacket<'_>) -> Self { | ||
Self { | ||
members: value | ||
.members() | ||
.flat_map(|member| MplsLabelStackMemberPacket::new_view(member).req()) | ||
.map(MplsLabelStackMember::from) | ||
.collect(), | ||
} | ||
} | ||
} | ||
|
||
impl From<MplsLabelStackMemberPacket<'_>> for MplsLabelStackMember { | ||
fn from(value: MplsLabelStackMemberPacket<'_>) -> Self { | ||
Self { | ||
label: value.get_label(), | ||
exp: value.get_exp(), | ||
bos: value.get_bos(), | ||
ttl: value.get_ttl(), | ||
} | ||
} | ||
} |
Oops, something went wrong.