Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  metadata.rs

  Sprache: Rust
 

// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Enable just this file for logging to just see packets.
// e.g. "RUST_LOG=neqo_transport::dump neqo-client ..."

use std::fmt::{self, Display, Formatter};

use neqo_common::Tos;
use qlog::events::quic::PacketHeader;
use strum::Display;

use crate::{packet, path::PathRef, version::Version};

#[derive(Clone, Copy, Display)]
pub enum Direction {
    #[strum(to_string = "TX ->")]
    Tx,
    #[strum(to_string = "-> RX")]
    Rx,
}

pub struct MetaData<'a> {
    path: &'a PathRef,
    direction: Direction,
    packet_type: packet::Type,
    packet_number: packet::Number,
    version: Version,
    tos: Tos,
    len: usize,
    payload: &'a [u8],
}

impl MetaData<'_> {
    pub fn new_in<'a>(
        path: &'a PathRef,
        tos: Tos,
        len: usize,
        decrypted: &'a packet::Decrypted,
        version: Version,
    ) -> MetaData<'a> {
        MetaData {
            path,
            direction: Direction::Rx,
            packet_type: decrypted.packet_type(),
            packet_number: decrypted.pn(),
            version,
            tos,
            len,
            payload: decrypted,
        }
    }

    pub const fn new_out<'a>(
        path: &'a PathRef,
        packet_type: packet::Type,
        packet_number: packet::Number,
        length: usize,
        payload: &'a [u8],
        tos: Tos,
        version: Version,
    ) -> MetaData<'a> {
        MetaData {
            path,
            direction: Direction::Tx,
            packet_type,
            packet_number,
            version,
            tos,
            len: length,
            payload,
        }
    }

    #[must_use]
    pub const fn direction(&self) -> Direction {
        self.direction
    }

    #[must_use]
    pub const fn length(&self) -> usize {
        self.len
    }

    #[must_use]
    pub const fn payload(&self) -> &[u8] {
        self.payload
    }
}

impl From<MetaData<'_>> for PacketHeader {
    fn from(val: MetaData<'_>) -> Self {
        let path = val.path.borrow();
        // For long-header packets, scid/dcid reflect who sent the packet:
        // on TX we are the source; on RX the peer is the source.
        let (scid, dcid) = match val.direction {
            Direction::Tx => (
                path.local_cid().map(AsRef::as_ref),
                path.remote_cid().map(AsRef::as_ref),
            ),
            Direction::Rx => (
                path.remote_cid().map(AsRef::as_ref),
                path.local_cid().map(AsRef::as_ref),
            ),
        };
        Self::with_type(
            val.packet_type.into(),
            Some(val.packet_number),
            Some(val.version.wire_version()),
            scid,
            dcid,
        )
    }
}

impl Display for MetaData<'_> {
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        write!(
            f,
            "pn={} type={:?} {} {:?} len {}",
            self.packet_number,
            self.packet_type,
            self.path.borrow(),
            self.tos,
            self.len,
        )
    }
}

Messung V0.5 in Prozent
C=97 H=100 G=98

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002