diff --git a/README.md b/README.md index 8ab03b8..cdd3047 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ This supports the following RFC dictionaries at the moment: - [RFC2866](https://tools.ietf.org/html/rfc2866) - [RFC2867](https://tools.ietf.org/html/rfc2867) - [RFC2868](https://tools.ietf.org/html/rfc2868) +- [RFC3576](https://tools.ietf.org/html/rfc3576) ## Usage @@ -29,7 +30,6 @@ Simple example implementations are here: - Support the following RFC dictionaries: - rfc2869 - rfc3162 - - rfc3576 - rfc3580 - rfc4072 - rfc4372 diff --git a/dicts/dictionary.rfc3576 b/dicts/dictionary.rfc3576 new file mode 100644 index 0000000..0060e00 --- /dev/null +++ b/dicts/dictionary.rfc3576 @@ -0,0 +1,33 @@ +# -*- text -*- +# Copyright (C) 2020 The FreeRADIUS Server project and contributors +# This work is licensed under CC-BY version 4.0 https://creativecommons.org/licenses/by/4.0 +# Version $Id$ +# +# Attributes and values defined in RFC 3576. +# http://www.ietf.org/rfc/rfc3576.txt +# +# $Id$ +# +ATTRIBUTE Error-Cause 101 integer + +# Service Types + +VALUE Service-Type Authorize-Only 17 + +# Error causes + +VALUE Error-Cause Residual-Context-Removed 201 +VALUE Error-Cause Invalid-EAP-Packet 202 +VALUE Error-Cause Unsupported-Attribute 401 +VALUE Error-Cause Missing-Attribute 402 +VALUE Error-Cause NAS-Identification-Mismatch 403 +VALUE Error-Cause Invalid-Request 404 +VALUE Error-Cause Unsupported-Service 405 +VALUE Error-Cause Unsupported-Extension 406 +VALUE Error-Cause Administratively-Prohibited 501 +VALUE Error-Cause Proxy-Request-Not-Routable 502 +VALUE Error-Cause Session-Context-Not-Found 503 +VALUE Error-Cause Session-Context-Not-Removable 504 +VALUE Error-Cause Proxy-Processing-Error 505 +VALUE Error-Cause Resources-Unavailable 506 +VALUE Error-Cause Request-Initiated 507 diff --git a/radius/src/lib.rs b/radius/src/lib.rs index 1027757..cd8b92f 100644 --- a/radius/src/lib.rs +++ b/radius/src/lib.rs @@ -7,4 +7,5 @@ pub mod rfc2865; pub mod rfc2866; pub mod rfc2867; pub mod rfc2868; +pub mod rfc3576; pub mod tag; diff --git a/radius/src/rfc3576.rs b/radius/src/rfc3576.rs new file mode 100644 index 0000000..494c4a3 --- /dev/null +++ b/radius/src/rfc3576.rs @@ -0,0 +1,44 @@ +// Code generated by machine generator; DO NOT EDIT. + +use crate::avp::{AVPError, AVPType, AVP}; +use crate::packet::Packet; + +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 type ServiceType = u32; +pub const SERVICE_TYPE_AUTHORIZE_ONLY: ServiceType = 17; + +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> { + packet + .lookup(ERROR_CAUSE_TYPE) + .map(|v| Ok(v.encode_u32()? as ErrorCause)) +} +pub fn lookup_all_error_cause(packet: &Packet) -> Result, AVPError> { + let mut vec = Vec::new(); + for avp in packet.lookup_all(ERROR_CAUSE_TYPE) { + vec.push(avp.encode_u32()? as ErrorCause) + } + Ok(vec) +}