netlink_packet_route/tc/qdiscs/
ingress.rs

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