pub struct V3Message {
pub global_data: MsgGlobalData,
pub security_params: Bytes,
pub data: V3MessageData,
}Expand description
SNMPv3 message.
Fields§
§global_data: MsgGlobalDataGlobal data (header)
security_params: BytesSecurity parameters (opaque, USM-encoded)
data: V3MessageDataMessage data - either plaintext ScopedPdu or encrypted bytes
Implementations§
Source§impl V3Message
impl V3Message
Sourcepub fn new(
global_data: MsgGlobalData,
security_params: Bytes,
scoped_pdu: ScopedPdu,
) -> Self
pub fn new( global_data: MsgGlobalData, security_params: Bytes, scoped_pdu: ScopedPdu, ) -> Self
Create a new V3 message with plaintext data.
Sourcepub fn new_encrypted(
global_data: MsgGlobalData,
security_params: Bytes,
encrypted: Bytes,
) -> Self
pub fn new_encrypted( global_data: MsgGlobalData, security_params: Bytes, encrypted: Bytes, ) -> Self
Create a new V3 message with encrypted data.
Sourcepub fn scoped_pdu(&self) -> Option<&ScopedPdu>
pub fn scoped_pdu(&self) -> Option<&ScopedPdu>
Get the scoped PDU if available (plaintext only).
Sourcepub fn into_scoped_pdu(self) -> Option<ScopedPdu>
pub fn into_scoped_pdu(self) -> Option<ScopedPdu>
Consume and return the scoped PDU if available.
Sourcepub fn security_level(&self) -> SecurityLevel
pub fn security_level(&self) -> SecurityLevel
Get the security level.
Sourcepub fn encode(&self) -> Bytes
pub fn encode(&self) -> Bytes
Encode to BER.
Note: For authenticated messages, the caller must:
- Encode with placeholder auth params (12 zero bytes for HMAC-96)
- Compute HMAC over the entire encoded message
- Replace the placeholder with the actual HMAC
Sourcepub fn decode(data: Bytes) -> Result<Self>
pub fn decode(data: Bytes) -> Result<Self>
Decode from BER.
For encrypted messages, returns V3MessageData::Encrypted with the raw ciphertext.
The caller must decrypt using USM before accessing the scoped PDU.
Sourcepub fn discovery_request(msg_id: i32) -> Self
pub fn discovery_request(msg_id: i32) -> Self
Create a discovery request message.
This is sent to discover the engine ID and time of a remote SNMP engine. Uses empty security parameters and no authentication.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for V3Message
impl RefUnwindSafe for V3Message
impl Send for V3Message
impl Sync for V3Message
impl Unpin for V3Message
impl UnwindSafe for V3Message
Blanket Implementations§
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
Mutably borrows from an owned value. Read more