-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add types and de/encoding for SCMP messages
- Loading branch information
Showing
5 changed files
with
878 additions
and
0 deletions.
There are no files selected for viewing
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,15 @@ | ||
//! Types and conversion for the SCION Control Message Protocol. | ||
//! | ||
//! This implements the specification at the [SCION documentation page][scion-doc-scmp] but currently | ||
//! does not cover DRKey-based authentication. | ||
//! | ||
//! [scion-doc-scmp]: https://docs.scion.org/en/latest/protocols/scmp.html | ||
|
||
pub mod error; | ||
pub use error::ScmpDecodeError; | ||
|
||
pub mod messages; | ||
pub use messages::{ScmpMessage, ScmpType}; | ||
|
||
pub mod raw; | ||
pub use raw::ScmpMessageRaw; |
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,24 @@ | ||
//! Errors encountered when handling SCMP messages. | ||
|
||
/// Error encountered when attempting to decode an SCMP message. | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum ScmpDecodeError { | ||
/// The data is shorter than the minimum length of the corresponding SCMP message. | ||
#[error("message is empty or was truncated")] | ||
MessageEmptyOrTruncated, | ||
/// When attempting to decode a specific message type and the data contains a different message | ||
/// type. | ||
#[error("the type of the message does not match the type being decoded")] | ||
MessageTypeMismatch, | ||
/// Informational messages of unknown types need to be dropped. | ||
#[error("unknown info message type {0}")] | ||
UnknownInfoMessage(u8), | ||
/// Depending on the type of SCMP message, only specific values of the `code` field are allowed. | ||
#[error("invalid code for this message type")] | ||
InvalidCode, | ||
/// When decoding a SCION packet presumably containing an SCMP message but the next-header value | ||
/// of the SCION header doesn't match | ||
/// [`ScmpMessageRaw::PROTOCOL_NUMBER`][super::ScmpMessageRaw::PROTOCOL_NUMBER]. | ||
#[error("next-header value of SCION header is not correct")] | ||
WrongProtocolNumber(u8), | ||
} |
Oops, something went wrong.