[][src]Crate cjdns_ctrl

Parsing/serializing CTRL messages

Cjdns contains a set of low level messages which are not encrypted. If you send a packet and it cannot be forwarded, the switch, which knows it is not possible to forward, will notify you with a CTRL message, these are not encrypted because, obviously, the switch doesn't know who you are and can't reasonably encrypt anything to you.

CTRL message types

Error message types

Example

use cjdns_ctrl::*;

let test_bytes = hex_to_bytes("994b00050123456700000012a331ebbed8d92ac03b10efed3e389cd0c6ec7331a72dbde198476c5eb4d14a1f02e29842b42aedb6bce2ead3");
let test_message_inst = CtrlMessage {
    msg_type: CtrlMessageType::KeyPing,
    msg_data: CtrlMessageData::PingData(PingData {
        version: 18,
        key: Some(
            CJDNSPublicKey::try_from("3fdqgz2vtqb0wx02hhvx3wjmjqktyt567fcuvj3m72vw5u6ubu70.k").expect("invalid key string")
        ),
        content: hex_to_bytes("02e29842b42aedb6bce2ead3"),
    }),
};

let parsed_msg = CtrlMessage::parse(&test_bytes).expect("invalid message bytes");
let serialized_msg = parsed_msg.serialize().expect("invalid message instance");
assert_eq!(parsed_msg, test_message_inst);
assert_eq!(serialized_msg, test_bytes)

Structs

CtrlMessage

Serialized control message

ErrorData

Body data for error type messages

PingData

Body data for ping type control messages

Enums

CtrlMessageData

Control message serialized body data

CtrlMessageType

Control message type, which is considered as message header

ErrorMessageType

Concrete types of error for control error message