[][src]Enum discv5::packet::Packet

pub enum Packet {
    RandomPacket {
        tag: Tag,
        auth_tag: AuthTag,
        data: Vec<u8>,
    },
    WhoAreYou {
        magic: [u8; 32],
        token: AuthTag,
        id_nonce: Nonce,
        enr_seq: u64,
    },
    AuthMessage {
        tag: Tag,
        auth_header: AuthHeader,
        message: Vec<u8>,
    },
    Message {
        tag: Tag,
        auth_tag: AuthTag,
        message: Vec<u8>,
    },
}

Variants

RandomPacket

Packet for establishing handshake.

Fields of RandomPacket

tag: Tag

The XOR(SHA256(dest-node-id), src-node-id).

auth_tag: AuthTag

Random auth_tag formatted as rlp_bytes(bytes).

data: Vec<u8>

At least 44 bytes of random data.

WhoAreYou

Handshake packet to establish identities.

Fields of WhoAreYou

magic: [u8; 32]

SHA256(dest-node-id || "WHOAREYOU").

token: AuthTag

The auth-tag of the request.

id_nonce: Nonce

The id-nonce to prevent handshake replays.

enr_seq: u64

Highest known ENR sequence number of node.

AuthMessage

Message sent with an extended authentication header.

Fields of AuthMessage

tag: Tag

The XOR(SHA256(dest-node-id), src-node-id).

auth_header: AuthHeader

Authentication header.

message: Vec<u8>

The encrypted message including the authentication header.

Message

A standard discv5 message.

Fields of Message

tag: Tag

The XOR(SHA256(dest-node-id), src-node-id).

auth_tag: AuthTag

12 byte Authentication nonce.

message: Vec<u8>

The encrypted message as raw bytes.

Implementations

impl Packet[src]

pub fn random(tag: Tag) -> Packet[src]

Generates a Packet::Random given a tag.

pub fn auth_tag(&self) -> Option<&AuthTag>[src]

The authentication tag for all packets except WHOAREYOU.

pub fn is_whoareyou(&self) -> bool[src]

Returns true if the packet is a WHOAREYOU packet.

pub fn is_random(&self) -> bool[src]

Returns true if the packet is a RANDOM packet.

pub fn encode(&self) -> Vec<u8>[src]

Encodes a packet to bytes.

fn decode_whoareyou(data: &[u8]) -> Result<Self, PacketError>[src]

Decodes a WHOAREYOU packet.

fn decode_standard_message(tag: Tag, data: &[u8]) -> Result<Self, PacketError>[src]

Decodes a regular message (or RandomPacket) into a Packet.

fn decode_auth_header(
    tag: Tag,
    data: &[u8],
    rlp_length: usize
) -> Result<Self, PacketError>
[src]

Decodes a message that contains an authentication header.

pub fn decode(data: &[u8], magic_data: &Magic) -> Result<Self, PacketError>[src]

Decode raw bytes into a packet. The magic value (SHA2256(node-id, b"WHOAREYOU")) is passed as a parameter to check for the magic byte sequence.

Trait Implementations

impl Clone for Packet[src]

impl Debug for Packet[src]

impl PartialEq<Packet> for Packet[src]

impl StructuralPartialEq for Packet[src]

Auto Trait Implementations

impl RefUnwindSafe for Packet

impl Send for Packet

impl Sync for Packet

impl Unpin for Packet

impl UnwindSafe for Packet

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,