1 unstable release

0.1.0 Aug 28, 2020

#8 in #snmp

Download history 8/week @ 2024-02-11 14/week @ 2024-02-18 19/week @ 2024-02-25 6/week @ 2024-03-03 4/week @ 2024-03-10 57/week @ 2024-03-17 1/week @ 2024-03-24 21/week @ 2024-03-31

84 downloads per month
Used in msnmp

MIT/Apache

79KB
1K SLoC

SNMPv3 Message Processing

SNMP Message Processing implements the primitives for preparing messages for sending, and extracting data from received messages.

Supported PDU types:

  • GetRequest
  • GetNextRequest
  • GetBulkRequest
  • Response
  • SetRequest
  • SNMPv2-Trap
  • InformRequest

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Primitives to send and receive SNMP messages.

Supported PDU types:

  • GetRequest
  • GetNextRequest
  • GetBulkRequest
  • Response
  • SetRequest
  • SNMPv2-Trap
  • InformRequest

Examples

use snmp_mp::{ObjectIdent, SnmpMsg, VarBind};

let mut msg = SnmpMsg::new(1);
msg.set_reportable_flag();

if let Some(scoped_pdu) = msg.scoped_pdu_data.plaintext_mut() {
    let sys_desc = ObjectIdent::from_slice(&[0x01, 0x03, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00]);
    let var_bind = VarBind::new(sys_desc);

    scoped_pdu
        .set_request_id(1)
        .set_engine_id(b"context_engine_id")
        .push_var_bind(var_bind);
}

let encoded_msg = msg.encode();
// Send the encoded message over the network.

encrypt_scoped_pdu and decrypt_scoped_pdu are provided to make it easy to use a security model:

msg.encrypt_scoped_pdu(|encoded_scoped_pdu| {
    // A security model encrypts and returns the scoped PDU.
    // let (encrypted_scoped_pdu, priv_params) =
    //     priv_key.encrypt(encoded_scoped_pdu, &security_params, salt);
    // security_params.set_priv_params(&priv_params);

    # let encrypted_scoped_pdu = encoded_scoped_pdu;
    encrypted_scoped_pdu
});

msg.decrypt_scoped_pdu(|encrypted_scoped_pdu| {
    // A security model returns the decrypted scoped PDU wrapped in an `Option`.
    // priv_key
    //     .decrypt(encrypted_scoped_pdu, &security_params)
    //     .ok()
    # None
});

Dependencies

~345KB