1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// This file is part of linux-support. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-support/master/COPYRIGHT. No part of linux-support, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
// Copyright © 2020 The developers of linux-support. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-support/master/COPYRIGHT.
/// Used for `RTM_NEWADDR`, `RTM_DELADDR` and `RTM_GETADDR`.
///
/// See Linux header `if_addr.h`.
#[non_exhaustive]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u16)]
pub(crate) enum IFA
{
#[allow(dead_code)]
IFA_UNSPEC = 0,
/// `IFA_ADDRESS` is a prefix address, rather than local interface address.
/// It makes no difference for normally configured broadcast interfaces, but for point-to-point `IFA_ADDRESS` is destination address, local address is supplied in the `IFA_LOCAL` attribute.
///
/// Valid for get address for:-
/// * IPv4
/// * IPv6
///
/// Valid for delete address for:-
// * IPv4.
// * IPv6.
#[allow(dead_code)]
IFA_ADDRESS = 1,
///
/// Valid for get address for:-
/// * IPv4
/// * IPv6
///
/// Valid for delete address for:-
// * IPv4.
// * IPv6.
#[allow(dead_code)]
IFA_LOCAL = 2,
///
/// Valid for get address for:-
/// * IPv4
///
/// Valid for delete address for:-
// * IPv4.
#[allow(dead_code)]
IFA_LABEL = 3,
///
/// Valid for get address for:-
/// * IPv4
///
/// Valid for delete address for:-
// * IPv4.
#[allow(dead_code)]
IFA_BROADCAST = 4,
/// Only valid for `RTM_GETANYCAST` for Internet Protocol version 6.
///
/// See `inet6_fill_ifacaddr()` in Linux source `addrconf.c`.
///
/// If present, then the only other attributes present will be `IFA_CACHEINFO` and optionally `IFA_TARGET_NETNSID`.
#[allow(dead_code)]
IFA_ANYCAST = 5,
/// Valid for get address for:-
/// * IPv4
///
/// Valid for delete address for:-
// * IPv4.
// * IPv6.
#[allow(dead_code)]
IFA_CACHEINFO = 6,
/// Only valid for `RTM_GETMULTICAST` for Internet Protocol version 6.
///
/// See `inet6_fill_ifmcaddr()` in Linux source `addrconf.c`.
///
/// If present, then the only other attributes present will be `IFA_CACHEINFO` and optionally `IFA_TARGET_NETNSID`.
#[allow(dead_code)]
IFA_MULTICAST = 7,
/// `IFA_FLAGS` is a `u32` attribute that replaces the `u8` field `ifa_flags` in `ifaddrmsg`.
/// If present, the field `ifa_flags` in the struct `ifaddrmsg` will be ignored by the Linux kernel.
///
/// Valid for get address for:-
/// * IPv4
///
/// Valid for delete address for:-
// * IPv4.
// * IPv6.
IFA_FLAGS = 8,
/// Priority or metric for prefix route.
///
/// `NonZeroU32`.
///
/// Valid for get address for:-
/// * IPv4
/// * IPv6
///
/// Valid for delete address for:-
// * IPv4.
// * IPv6.
#[allow(dead_code)]
IFA_RT_PRIORITY = 9,
/// Valid for get address for:-
/// * IPv4
/// * IPv6
///
/// Valid for delete address for:-
// * IPv4.
// * IPv6.
#[allow(dead_code)]
IFA_TARGET_NETNSID = 10,
}
impl From<u16> for IFA
{
#[inline(always)]
fn from(value: u16) -> Self
{
unsafe { transmute(value) }
}
}
impl NetlinkAttributeType for IFA
{
#[inline(always)]
fn to_u16(self) -> u16
{
self as u16
}
}
impl IFA
{
const __IFA_MAX: u16 = IFA::IFA_TARGET_NETNSID as u16 + 1;
#[allow(dead_code)]
pub(crate) const IFA_MAX: Self = unsafe { transmute(Self::__IFA_MAX - 1) };
}