netlink_packet_route/link/
link_flag.rs

1// SPDX-License-Identifier: MIT
2
3use std::fmt;
4
5const IFF_UP: u32 = 1 << 0;
6const IFF_BROADCAST: u32 = 1 << 1;
7const IFF_DEBUG: u32 = 1 << 2;
8const IFF_LOOPBACK: u32 = 1 << 3;
9const IFF_POINTOPOINT: u32 = 1 << 4;
10const IFF_NOTRAILERS: u32 = 1 << 5;
11const IFF_RUNNING: u32 = 1 << 6;
12const IFF_NOARP: u32 = 1 << 7;
13const IFF_PROMISC: u32 = 1 << 8;
14const IFF_ALLMULTI: u32 = 1 << 9;
15// Kernel constant name is IFF_MASTER
16const IFF_CONTROLLER: u32 = 1 << 10;
17// Kernel constant name is IFF_SLAVE
18const IFF_PORT: u32 = 1 << 11;
19const IFF_MULTICAST: u32 = 1 << 12;
20const IFF_PORTSEL: u32 = 1 << 13;
21const IFF_AUTOMEDIA: u32 = 1 << 14;
22const IFF_DYNAMIC: u32 = 1 << 15;
23const IFF_LOWER_UP: u32 = 1 << 16;
24const IFF_DORMANT: u32 = 1 << 17;
25const IFF_ECHO: u32 = 1 << 18;
26
27bitflags! {
28    #[derive(Debug, PartialEq, Eq, Clone, Copy, Default)]
29    #[non_exhaustive]
30    pub struct LinkFlags: u32 {
31        const Up = IFF_UP;
32        const Broadcast = IFF_BROADCAST;
33        const Debug = IFF_DEBUG;
34        const Loopback = IFF_LOOPBACK;
35        const Pointopoint = IFF_POINTOPOINT;
36        const Notrailers = IFF_NOTRAILERS;
37        const Running = IFF_RUNNING;
38        const Noarp = IFF_NOARP;
39        const Promisc = IFF_PROMISC;
40        const Allmulti = IFF_ALLMULTI;
41        const Controller = IFF_CONTROLLER;
42        const Port = IFF_PORT;
43        const Multicast = IFF_MULTICAST;
44        const Portsel = IFF_PORTSEL;
45        const Automedia = IFF_AUTOMEDIA;
46        const Dynamic = IFF_DYNAMIC;
47        const LowerUp = IFF_LOWER_UP;
48        const Dormant = IFF_DORMANT;
49        const Echo = IFF_ECHO;
50        const _ = !0;
51    }
52}
53
54impl fmt::Display for LinkFlags {
55    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56        bitflags::parser::to_writer(self, f)
57    }
58}