netlink_packet_route/tc/qdiscs/
ingress.rs

1// SPDX-License-Identifier: MIT
2
3use netlink_packet_core::ErrorContext;
4// Currently, the qdisc ingress does not have any attribute, kernel
5// just start a empty nla_nest. This is just a place holder
6use netlink_packet_core::{DecodeError, DefaultNla, Nla, NlaBuffer, Parseable};
7
8#[derive(Debug, PartialEq, Eq, Clone)]
9#[non_exhaustive]
10pub struct TcQdiscIngress {}
11
12#[derive(Debug, PartialEq, Eq, Clone)]
13#[non_exhaustive]
14pub enum TcQdiscIngressOption {
15    Other(DefaultNla),
16}
17
18impl TcQdiscIngress {
19    pub(crate) const KIND: &'static str = "ingress";
20}
21
22impl Nla for TcQdiscIngressOption {
23    fn value_len(&self) -> usize {
24        match self {
25            Self::Other(attr) => attr.value_len(),
26        }
27    }
28
29    fn emit_value(&self, buffer: &mut [u8]) {
30        match self {
31            Self::Other(attr) => attr.emit_value(buffer),
32        }
33    }
34
35    fn kind(&self) -> u16 {
36        match self {
37            Self::Other(attr) => attr.kind(),
38        }
39    }
40}
41
42impl<'a, T: AsRef<[u8]> + ?Sized> Parseable<NlaBuffer<&'a T>>
43    for TcQdiscIngressOption
44{
45    fn parse(buf: &NlaBuffer<&'a T>) -> Result<Self, DecodeError> {
46        Ok(Self::Other(
47            DefaultNla::parse(buf).context("failed to parse ingress nla")?,
48        ))
49    }
50}