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
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
use crate::core::rfc2865;
pub const ERROR_CAUSE_TYPE: AVPType = 101;
pub fn delete_error_cause(packet: &mut Packet) {
packet.delete(ERROR_CAUSE_TYPE);
}
pub fn add_error_cause(packet: &mut Packet, value: ErrorCause) {
packet.add(AVP::from_u32(ERROR_CAUSE_TYPE, value as u32));
}
pub fn lookup_error_cause(packet: &Packet) -> Option<Result<ErrorCause, AVPError>> {
packet
.lookup(ERROR_CAUSE_TYPE)
.map(|v| Ok(v.encode_u32()? as ErrorCause))
}
pub fn lookup_all_error_cause(packet: &Packet) -> Result<Vec<ErrorCause>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ERROR_CAUSE_TYPE) {
vec.push(avp.encode_u32()? as ErrorCause)
}
Ok(vec)
}
pub type ErrorCause = u32;
pub const ERROR_CAUSE_RESIDUAL_CONTEXT_REMOVED: ErrorCause = 201;
pub const ERROR_CAUSE_INVALID_EAP_PACKET: ErrorCause = 202;
pub const ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE: ErrorCause = 401;
pub const ERROR_CAUSE_MISSING_ATTRIBUTE: ErrorCause = 402;
pub const ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH: ErrorCause = 403;
pub const ERROR_CAUSE_INVALID_REQUEST: ErrorCause = 404;
pub const ERROR_CAUSE_UNSUPPORTED_SERVICE: ErrorCause = 405;
pub const ERROR_CAUSE_UNSUPPORTED_EXTENSION: ErrorCause = 406;
pub const ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED: ErrorCause = 501;
pub const ERROR_CAUSE_PROXY_REQUEST_NOT_ROUTABLE: ErrorCause = 502;
pub const ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND: ErrorCause = 503;
pub const ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE: ErrorCause = 504;
pub const ERROR_CAUSE_PROXY_PROCESSING_ERROR: ErrorCause = 505;
pub const ERROR_CAUSE_RESOURCES_UNAVAILABLE: ErrorCause = 506;
pub const ERROR_CAUSE_REQUEST_INITIATED: ErrorCause = 507;
pub const SERVICE_TYPE_AUTHORIZE_ONLY: rfc2865::ServiceType = 17;