radius/core/rfc4372.rs
1// Code generated by machine generator; DO NOT EDIT.
2
3//! Utility for rfc4372 packet.
4//!
5//! This module handles the packet according to the following definition:
6//! ```text
7//! //! # -*- text -*-
8//! # Copyright (C) 2020 The FreeRADIUS Server project and contributors
9//! # This work is licensed under CC-BY version 4.0 https://creativecommons.org/licenses/by/4.0
10//! # Version $Id$
11//! #
12//! # Attributes and values defined in RFC 4372.
13//! # http://www.ietf.org/rfc/rfc4372.txt
14//! #
15//! # $Id$
16//! #
17//! ATTRIBUTE Chargeable-User-Identity 89 octets
18//! ```
19
20use crate::core::avp::{AVPType, AVP};
21use crate::core::packet::Packet;
22
23pub const CHARGEABLE_USER_IDENTITY_TYPE: AVPType = 89;
24/// Delete all of `chargeable_user_identity` values from a packet.
25pub fn delete_chargeable_user_identity(packet: &mut Packet) {
26 packet.delete(CHARGEABLE_USER_IDENTITY_TYPE);
27}
28/// Add `chargeable_user_identity` octets value to a packet.
29pub fn add_chargeable_user_identity(packet: &mut Packet, value: &[u8]) {
30 packet.add(AVP::from_bytes(CHARGEABLE_USER_IDENTITY_TYPE, value));
31}
32/// Lookup a `chargeable_user_identity` octets value from a packet.
33///
34/// It returns the first looked up value. If there is no associated value with `chargeable_user_identity`, it returns `None`.
35pub fn lookup_chargeable_user_identity(packet: &Packet) -> Option<Vec<u8>> {
36 packet
37 .lookup(CHARGEABLE_USER_IDENTITY_TYPE)
38 .map(|v| v.encode_bytes())
39}
40/// Lookup all of the `chargeable_user_identity` octets value from a packet.
41pub fn lookup_all_chargeable_user_identity(packet: &Packet) -> Vec<Vec<u8>> {
42 let mut vec = Vec::new();
43 for avp in packet.lookup_all(CHARGEABLE_USER_IDENTITY_TYPE) {
44 vec.push(avp.encode_bytes())
45 }
46 vec
47}