From bece87091460e2e81cc990387c6eed88e5378c02 Mon Sep 17 00:00:00 2001 From: moznion Date: Sun, 6 Dec 2020 15:39:50 +0900 Subject: [PATCH] Support RFC4372 --- README.md | 2 +- dicts/dictionary.rfc4372 | 11 +++++++++++ radius/src/lib.rs | 1 + radius/src/rfc4372.rs | 24 ++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 dicts/dictionary.rfc4372 create mode 100644 radius/src/rfc4372.rs diff --git a/README.md b/README.md index 7860b3a..cc935c2 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ This supports the following RFC dictionaries at the moment: - [RFC3576](https://tools.ietf.org/html/rfc3576) - [RFC3580](https://tools.ietf.org/html/rfc3580) - [RFC4072](https://tools.ietf.org/html/rfc4072) +- [RFC4372](https://tools.ietf.org/html/rfc4372) - [RFC5090](https://tools.ietf.org/html/rfc5090) - [RFC5607](https://tools.ietf.org/html/rfc5607) - [RFC6519](https://tools.ietf.org/html/rfc6519) @@ -35,7 +36,6 @@ Simple example implementations are here: - retransmission feature on the client - Support the following RFC dictionaries: - - rfc4372 - rfc4603 - rfc4675 - rfc4679 diff --git a/dicts/dictionary.rfc4372 b/dicts/dictionary.rfc4372 new file mode 100644 index 0000000..54b6ccf --- /dev/null +++ b/dicts/dictionary.rfc4372 @@ -0,0 +1,11 @@ +# -*- 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 4372. +# http://www.ietf.org/rfc/rfc4372.txt +# +# $Id$ +# +ATTRIBUTE Chargeable-User-Identity 89 octets diff --git a/radius/src/lib.rs b/radius/src/lib.rs index c6846d0..1be81af 100644 --- a/radius/src/lib.rs +++ b/radius/src/lib.rs @@ -12,6 +12,7 @@ pub mod rfc3162; pub mod rfc3576; pub mod rfc3580; pub mod rfc4072; +pub mod rfc4372; pub mod rfc5090; pub mod rfc5607; pub mod rfc6519; diff --git a/radius/src/rfc4372.rs b/radius/src/rfc4372.rs new file mode 100644 index 0000000..2e886a3 --- /dev/null +++ b/radius/src/rfc4372.rs @@ -0,0 +1,24 @@ +// Code generated by machine generator; DO NOT EDIT. + +use crate::avp::{AVPType, AVP}; +use crate::packet::Packet; + +pub const CHARGEABLE_USER_IDENTITY_TYPE: AVPType = 89; +pub fn delete_chargeable_user_identity(packet: &mut Packet) { + packet.delete(CHARGEABLE_USER_IDENTITY_TYPE); +} +pub fn add_chargeable_user_identity(packet: &mut Packet, value: &[u8]) { + packet.add(AVP::from_bytes(CHARGEABLE_USER_IDENTITY_TYPE, value)); +} +pub fn lookup_chargeable_user_identity(packet: &Packet) -> Option> { + packet + .lookup(CHARGEABLE_USER_IDENTITY_TYPE) + .map(|v| v.encode_bytes()) +} +pub fn lookup_all_chargeable_user_identity(packet: &Packet) -> Vec> { + let mut vec = Vec::new(); + for avp in packet.lookup_all(CHARGEABLE_USER_IDENTITY_TYPE) { + vec.push(avp.encode_bytes()) + } + vec +}