network/device/
command.rs

1use crate::{InterfaceKind, IpAddress, IpCidr, MacAddress, Route};
2use file_system::{ControlCommand, define_command};
3
4#[repr(C)]
5pub struct WifiClientConfiguration {
6    // TODO: Add fields
7}
8
9define_command!(GET_KIND, Read, b'n', 1, (), InterfaceKind);
10
11#[repr(u8)]
12enum CommandNumber {
13    SetState,
14    GetState,
15    GetHardwareAddress,
16    SetHardwareAddress,
17    GetMtu,
18    GetMaximumBurstSize,
19    IsLinkUp,
20    GetRouteCount,
21    GetRoute,
22    AddRoute,
23    RemoveRoute,
24    GetDnsServerCount,
25    GetDnsServer,
26    AddDnsServer,
27    RemoveDnsServer,
28    SetDhcpState,
29    GetDhcpState,
30    GetIpAddressCount,
31    GetIpAddress,
32    AddIpAddress,
33    RemoveIpAddress,
34}
35
36define_command!(
37    SET_STATE,
38    Write,
39    b'n',
40    CommandNumber::SetState as u8,
41    bool,
42    ()
43);
44define_command!(
45    GET_STATE,
46    Read,
47    b'n',
48    CommandNumber::GetState as u8,
49    (),
50    bool
51);
52define_command!(
53    GET_HARDWARE_ADDRESS,
54    Read,
55    b'n',
56    CommandNumber::GetHardwareAddress as u8,
57    (),
58    MacAddress
59);
60define_command!(
61    SET_HARDWARE_ADDRESS,
62    Write,
63    b'n',
64    CommandNumber::SetHardwareAddress as u8,
65    MacAddress,
66    ()
67);
68define_command!(
69    GET_MAXIMUM_TRANSMISSION_UNIT,
70    Read,
71    b'n',
72    CommandNumber::GetMtu as u8,
73    (),
74    usize
75);
76define_command!(
77    GET_MAXIMUM_BURST_SIZE,
78    Read,
79    b'n',
80    CommandNumber::GetMaximumBurstSize as u8,
81    (),
82    Option<usize>
83);
84define_command!(
85    IS_LINK_UP,
86    Read,
87    b'n',
88    CommandNumber::IsLinkUp as u8,
89    (),
90    bool
91);
92define_command!(
93    GET_ROUTE_COUNT,
94    Read,
95    b'n',
96    CommandNumber::GetRouteCount as u8,
97    (),
98    usize
99);
100define_command!(
101    GET_ROUTE,
102    Read,
103    b'n',
104    CommandNumber::GetRoute as u8,
105    usize,
106    Route
107);
108define_command!(
109    ADD_ROUTE,
110    Write,
111    b'n',
112    CommandNumber::AddRoute as u8,
113    Route,
114    ()
115);
116define_command!(
117    REMOVE_ROUTE,
118    Write,
119    b'n',
120    CommandNumber::RemoveRoute as u8,
121    usize,
122    ()
123);
124define_command!(
125    GET_DNS_SERVER_COUNT,
126    Read,
127    b'n',
128    CommandNumber::GetDnsServerCount as u8,
129    (),
130    usize
131);
132define_command!(
133    GET_DNS_SERVER,
134    Read,
135    b'n',
136    CommandNumber::GetDnsServer as u8,
137    usize,
138    IpAddress
139);
140define_command!(
141    ADD_DNS_SERVER,
142    Write,
143    b'n',
144    CommandNumber::AddDnsServer as u8,
145    IpAddress,
146    ()
147);
148define_command!(
149    REMOVE_DNS_SERVER,
150    Write,
151    b'n',
152    CommandNumber::RemoveDnsServer as u8,
153    usize,
154    ()
155);
156define_command!(
157    SET_DHCP_STATE,
158    Write,
159    b'n',
160    CommandNumber::SetDhcpState as u8,
161    bool,
162    ()
163);
164define_command!(
165    GET_DHCP_STATE,
166    Read,
167    b'n',
168    CommandNumber::GetDhcpState as u8,
169    (),
170    bool
171);
172define_command!(
173    GET_IP_ADDRESS_COUNT,
174    Read,
175    b'n',
176    CommandNumber::GetIpAddressCount as u8,
177    (),
178    usize
179);
180define_command!(
181    GET_IP_ADDRESS,
182    Read,
183    b'n',
184    CommandNumber::GetIpAddress as u8,
185    usize,
186    IpCidr
187);
188define_command!(
189    ADD_IP_ADDRESS,
190    Write,
191    b'n',
192    CommandNumber::AddIpAddress as u8,
193    IpCidr,
194    ()
195);
196define_command!(
197    REMOVE_IP_ADDRESS,
198    Write,
199    b'n',
200    CommandNumber::RemoveIpAddress as u8,
201    usize,
202    ()
203);