From 46c35998db299e38116560e53c00be12d491ed6d Mon Sep 17 00:00:00 2001 From: ViniciosLugli Date: Sun, 22 Sep 2024 23:20:04 -0300 Subject: [PATCH] feat(del_qdisc): :sparkles: Added set parent and ingress to QDiscDelRequest --- src/traffic_control/del_qdisc.rs | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/traffic_control/del_qdisc.rs b/src/traffic_control/del_qdisc.rs index a0fcd8d..aad281a 100644 --- a/src/traffic_control/del_qdisc.rs +++ b/src/traffic_control/del_qdisc.rs @@ -2,7 +2,10 @@ use futures::StreamExt; use netlink_packet_core::{NetlinkMessage, NLM_F_ACK, NLM_F_REQUEST}; -use netlink_packet_route::{tc::TcMessage, RouteNetlinkMessage}; +use netlink_packet_route::{ + tc::{TcAttribute, TcHandle, TcMessage}, + RouteNetlinkMessage, +}; use crate::{try_nl, Error, Handle}; @@ -39,4 +42,32 @@ impl QDiscDelRequest { pub fn message_mut(&mut self) -> &mut TcMessage { &mut self.message } + + /// Set handle + pub fn handle(mut self, major: u16, minor: u16) -> Self { + self.message.header.handle = TcHandle { major, minor }; + self + } + + /// Set parent to root + pub fn root(mut self) -> Self { + self.message.header.parent = TcHandle::ROOT; + self + } + + /// Set parent + pub fn parent(mut self, parent: u32) -> Self { + self.message.header.parent = parent.into(); + self + } + + /// Set ingress qdisc + pub fn ingress(mut self) -> Self { + self.message.header.parent = TcHandle::INGRESS; + self.message.header.handle = TcHandle::from(0xffff0000); + self.message + .attributes + .push(TcAttribute::Kind("ingress".to_string())); + self + } }