1use abol_core::{attribute::ToRadiusAttribute, packet::Packet};
2use std::time::SystemTime;
3pub const ACCT_INPUT_GIGAWORDS_TYPE: u8 = 52u8;
4pub const ACCT_OUTPUT_GIGAWORDS_TYPE: u8 = 53u8;
5pub const EVENT_TIMESTAMP_TYPE: u8 = 55u8;
6pub const ARAP_PASSWORD_TYPE: u8 = 70u8;
7pub const ARAP_FEATURES_TYPE: u8 = 71u8;
8pub const ARAP_ZONE_ACCESS_TYPE: u8 = 72u8;
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10#[repr(u32)]
11pub enum ArapZoneAccess {
12 DefaultZone,
13 ZoneFilterInclusive,
14 ZoneFilterExclusive,
15 Unknown(u32),
16}
17impl From<u32> for ArapZoneAccess {
18 fn from(v: u32) -> Self {
19 match v {
20 1u32 => Self::DefaultZone,
21 2u32 => Self::ZoneFilterInclusive,
22 4u32 => Self::ZoneFilterExclusive,
23 other => Self::Unknown(other),
24 }
25 }
26}
27impl From<ArapZoneAccess> for u32 {
28 fn from(e: ArapZoneAccess) -> Self {
29 match e {
30 ArapZoneAccess::DefaultZone => 1u32,
31 ArapZoneAccess::ZoneFilterInclusive => 2u32,
32 ArapZoneAccess::ZoneFilterExclusive => 4u32,
33 ArapZoneAccess::Unknown(v) => v,
34 }
35 }
36}
37pub const ARAP_SECURITY_TYPE: u8 = 73u8;
38pub const ARAP_SECURITY_DATA_TYPE: u8 = 74u8;
39pub const PASSWORD_RETRY_TYPE: u8 = 75u8;
40pub const PROMPT_TYPE: u8 = 76u8;
41#[derive(Debug, Clone, Copy, PartialEq, Eq)]
42#[repr(u32)]
43pub enum Prompt {
44 NoEcho,
45 Echo,
46 Unknown(u32),
47}
48impl From<u32> for Prompt {
49 fn from(v: u32) -> Self {
50 match v {
51 0u32 => Self::NoEcho,
52 1u32 => Self::Echo,
53 other => Self::Unknown(other),
54 }
55 }
56}
57impl From<Prompt> for u32 {
58 fn from(e: Prompt) -> Self {
59 match e {
60 Prompt::NoEcho => 0u32,
61 Prompt::Echo => 1u32,
62 Prompt::Unknown(v) => v,
63 }
64 }
65}
66pub const CONNECT_INFO_TYPE: u8 = 77u8;
67pub const CONFIGURATION_TOKEN_TYPE: u8 = 78u8;
68pub const EAP_MESSAGE_TYPE: u8 = 79u8;
69pub const MESSAGE_AUTHENTICATOR_TYPE: u8 = 80u8;
70pub const ARAP_CHALLENGE_RESPONSE_TYPE: u8 = 84u8;
71pub const ACCT_INTERIM_INTERVAL_TYPE: u8 = 85u8;
72pub const NAS_PORT_ID_TYPE: u8 = 87u8;
73pub const FRAMED_POOL_TYPE: u8 = 88u8;
74pub trait Rfc2869Ext {
75 fn get_acct_input_gigawords(&self) -> Option<u32>;
76 fn set_acct_input_gigawords(&mut self, value: u32);
77 fn get_acct_output_gigawords(&self) -> Option<u32>;
78 fn set_acct_output_gigawords(&mut self, value: u32);
79 fn get_event_timestamp(&self) -> Option<SystemTime>;
80 fn set_event_timestamp(&mut self, value: SystemTime);
81 fn get_arap_password(&self) -> Option<Vec<u8>>;
82 fn set_arap_password(&mut self, value: impl Into<Vec<u8>>);
83 fn get_arap_features(&self) -> Option<Vec<u8>>;
84 fn set_arap_features(&mut self, value: impl Into<Vec<u8>>);
85 fn get_arap_zone_access(&self) -> Option<ArapZoneAccess>;
86 fn set_arap_zone_access(&mut self, value: ArapZoneAccess);
87 fn get_arap_security(&self) -> Option<u32>;
88 fn set_arap_security(&mut self, value: u32);
89 fn get_arap_security_data(&self) -> Option<String>;
90 fn set_arap_security_data(&mut self, value: impl Into<String>);
91 fn get_password_retry(&self) -> Option<u32>;
92 fn set_password_retry(&mut self, value: u32);
93 fn get_prompt(&self) -> Option<Prompt>;
94 fn set_prompt(&mut self, value: Prompt);
95 fn get_connect_info(&self) -> Option<String>;
96 fn set_connect_info(&mut self, value: impl Into<String>);
97 fn get_configuration_token(&self) -> Option<String>;
98 fn set_configuration_token(&mut self, value: impl Into<String>);
99 fn get_eap_message(&self) -> Option<Vec<u8>>;
100 fn set_eap_message(&mut self, value: impl Into<Vec<u8>>);
101 fn get_message_authenticator(&self) -> Option<Vec<u8>>;
102 fn set_message_authenticator(&mut self, value: impl Into<Vec<u8>>);
103 fn get_arap_challenge_response(&self) -> Option<Vec<u8>>;
104 fn set_arap_challenge_response(&mut self, value: impl Into<Vec<u8>>);
105 fn get_acct_interim_interval(&self) -> Option<u32>;
106 fn set_acct_interim_interval(&mut self, value: u32);
107 fn get_nas_port_id(&self) -> Option<String>;
108 fn set_nas_port_id(&mut self, value: impl Into<String>);
109 fn get_framed_pool(&self) -> Option<String>;
110 fn set_framed_pool(&mut self, value: impl Into<String>);
111}
112impl Rfc2869Ext for Packet {
113 fn get_acct_input_gigawords(&self) -> Option<u32> {
114 self.get_attribute_as::<u32>(ACCT_INPUT_GIGAWORDS_TYPE)
115 }
116 fn set_acct_input_gigawords(&mut self, value: u32) {
117 let wire_val = value;
118 self.set_attribute_as::<u32>(ACCT_INPUT_GIGAWORDS_TYPE, wire_val);
119 }
120 fn get_acct_output_gigawords(&self) -> Option<u32> {
121 self.get_attribute_as::<u32>(ACCT_OUTPUT_GIGAWORDS_TYPE)
122 }
123 fn set_acct_output_gigawords(&mut self, value: u32) {
124 let wire_val = value;
125 self.set_attribute_as::<u32>(ACCT_OUTPUT_GIGAWORDS_TYPE, wire_val);
126 }
127 fn get_event_timestamp(&self) -> Option<SystemTime> {
128 self.get_attribute_as::<SystemTime>(EVENT_TIMESTAMP_TYPE)
129 }
130 fn set_event_timestamp(&mut self, value: SystemTime) {
131 let wire_val = value;
132 self.set_attribute_as::<SystemTime>(EVENT_TIMESTAMP_TYPE, wire_val);
133 }
134 fn get_arap_password(&self) -> Option<Vec<u8>> {
135 self.get_attribute_as::<Vec<u8>>(ARAP_PASSWORD_TYPE)
136 }
137 fn set_arap_password(&mut self, value: impl Into<Vec<u8>>) {
138 let wire_val: Vec<u8> = value.into();
139 if ToRadiusAttribute::to_bytes(&wire_val).len() != 16u32 as usize {
140 return;
141 }
142 self.set_attribute_as::<Vec<u8>>(ARAP_PASSWORD_TYPE, wire_val);
143 }
144 fn get_arap_features(&self) -> Option<Vec<u8>> {
145 self.get_attribute_as::<Vec<u8>>(ARAP_FEATURES_TYPE)
146 }
147 fn set_arap_features(&mut self, value: impl Into<Vec<u8>>) {
148 let wire_val: Vec<u8> = value.into();
149 if ToRadiusAttribute::to_bytes(&wire_val).len() != 14u32 as usize {
150 return;
151 }
152 self.set_attribute_as::<Vec<u8>>(ARAP_FEATURES_TYPE, wire_val);
153 }
154 fn get_arap_zone_access(&self) -> Option<ArapZoneAccess> {
155 self.get_attribute_as::<u32>(ARAP_ZONE_ACCESS_TYPE)
156 .map(ArapZoneAccess::from)
157 }
158 fn set_arap_zone_access(&mut self, value: ArapZoneAccess) {
159 let wire_val: u32 = value.into();
160 self.set_attribute_as::<u32>(ARAP_ZONE_ACCESS_TYPE, wire_val);
161 }
162 fn get_arap_security(&self) -> Option<u32> {
163 self.get_attribute_as::<u32>(ARAP_SECURITY_TYPE)
164 }
165 fn set_arap_security(&mut self, value: u32) {
166 let wire_val = value;
167 self.set_attribute_as::<u32>(ARAP_SECURITY_TYPE, wire_val);
168 }
169 fn get_arap_security_data(&self) -> Option<String> {
170 self.get_attribute_as::<String>(ARAP_SECURITY_DATA_TYPE)
171 }
172 fn set_arap_security_data(&mut self, value: impl Into<String>) {
173 let wire_val: String = value.into();
174 self.set_attribute_as::<String>(ARAP_SECURITY_DATA_TYPE, wire_val);
175 }
176 fn get_password_retry(&self) -> Option<u32> {
177 self.get_attribute_as::<u32>(PASSWORD_RETRY_TYPE)
178 }
179 fn set_password_retry(&mut self, value: u32) {
180 let wire_val = value;
181 self.set_attribute_as::<u32>(PASSWORD_RETRY_TYPE, wire_val);
182 }
183 fn get_prompt(&self) -> Option<Prompt> {
184 self.get_attribute_as::<u32>(PROMPT_TYPE).map(Prompt::from)
185 }
186 fn set_prompt(&mut self, value: Prompt) {
187 let wire_val: u32 = value.into();
188 self.set_attribute_as::<u32>(PROMPT_TYPE, wire_val);
189 }
190 fn get_connect_info(&self) -> Option<String> {
191 self.get_attribute_as::<String>(CONNECT_INFO_TYPE)
192 }
193 fn set_connect_info(&mut self, value: impl Into<String>) {
194 let wire_val: String = value.into();
195 self.set_attribute_as::<String>(CONNECT_INFO_TYPE, wire_val);
196 }
197 fn get_configuration_token(&self) -> Option<String> {
198 self.get_attribute_as::<String>(CONFIGURATION_TOKEN_TYPE)
199 }
200 fn set_configuration_token(&mut self, value: impl Into<String>) {
201 let wire_val: String = value.into();
202 self.set_attribute_as::<String>(CONFIGURATION_TOKEN_TYPE, wire_val);
203 }
204 fn get_eap_message(&self) -> Option<Vec<u8>> {
205 self.get_attribute_as::<Vec<u8>>(EAP_MESSAGE_TYPE)
206 }
207 fn set_eap_message(&mut self, value: impl Into<Vec<u8>>) {
208 let wire_val: Vec<u8> = value.into();
209 self.set_attribute_as::<Vec<u8>>(EAP_MESSAGE_TYPE, wire_val);
210 }
211 fn get_message_authenticator(&self) -> Option<Vec<u8>> {
212 self.get_attribute_as::<Vec<u8>>(MESSAGE_AUTHENTICATOR_TYPE)
213 }
214 fn set_message_authenticator(&mut self, value: impl Into<Vec<u8>>) {
215 let wire_val: Vec<u8> = value.into();
216 self.set_attribute_as::<Vec<u8>>(MESSAGE_AUTHENTICATOR_TYPE, wire_val);
217 }
218 fn get_arap_challenge_response(&self) -> Option<Vec<u8>> {
219 self.get_attribute_as::<Vec<u8>>(ARAP_CHALLENGE_RESPONSE_TYPE)
220 }
221 fn set_arap_challenge_response(&mut self, value: impl Into<Vec<u8>>) {
222 let wire_val: Vec<u8> = value.into();
223 if ToRadiusAttribute::to_bytes(&wire_val).len() != 8u32 as usize {
224 return;
225 }
226 self.set_attribute_as::<Vec<u8>>(ARAP_CHALLENGE_RESPONSE_TYPE, wire_val);
227 }
228 fn get_acct_interim_interval(&self) -> Option<u32> {
229 self.get_attribute_as::<u32>(ACCT_INTERIM_INTERVAL_TYPE)
230 }
231 fn set_acct_interim_interval(&mut self, value: u32) {
232 let wire_val = value;
233 self.set_attribute_as::<u32>(ACCT_INTERIM_INTERVAL_TYPE, wire_val);
234 }
235 fn get_nas_port_id(&self) -> Option<String> {
236 self.get_attribute_as::<String>(NAS_PORT_ID_TYPE)
237 }
238 fn set_nas_port_id(&mut self, value: impl Into<String>) {
239 let wire_val: String = value.into();
240 self.set_attribute_as::<String>(NAS_PORT_ID_TYPE, wire_val);
241 }
242 fn get_framed_pool(&self) -> Option<String> {
243 self.get_attribute_as::<String>(FRAMED_POOL_TYPE)
244 }
245 fn set_framed_pool(&mut self, value: impl Into<String>) {
246 let wire_val: String = value.into();
247 self.set_attribute_as::<String>(FRAMED_POOL_TYPE, wire_val);
248 }
249}