Add documentation for generated RFC utilities

This commit is contained in:
moznion
2021-01-03 15:03:00 +09:00
parent b395f51fdd
commit eaa171ec48
28 changed files with 1903 additions and 31 deletions

View File

@@ -135,7 +135,7 @@ fn main() {
let mut attribute_name_to_rfc_name: HashMap<String, String> = HashMap::new();
for dict_file_path in dict_file_paths {
let (radius_attributes, radius_attribute_to_values_map) =
let ((radius_attributes, radius_attribute_to_values_map), dict_file_lines) =
parse_dict_file(dict_file_path).unwrap();
let value_defined_attributes_set = radius_attribute_to_values_map
@@ -145,7 +145,7 @@ fn main() {
let rfc_name = dict_file_path.extension().unwrap().to_str().unwrap();
let mut w = BufWriter::new(File::create(out_dir.join(format!("{}.rs", rfc_name))).unwrap());
generate_header(&mut w, &rfc_names);
generate_header(&mut w, &rfc_names, rfc_name, dict_file_lines);
generate_attributes_code(&mut w, &radius_attributes, &value_defined_attributes_set);
generate_values_code(
&mut w,
@@ -160,20 +160,39 @@ fn main() {
}
}
fn generate_header(w: &mut BufWriter<File>, rfc_names: &[String]) {
let code = b"// Code generated by machine generator; DO NOT EDIT.
fn generate_header(
w: &mut BufWriter<File>,
rfc_names: &[String],
rfc_name: &str,
dict_file_lines: io::Lines<io::BufReader<File>>,
) {
let code = format!(
"// Code generated by machine generator; DO NOT EDIT.
use std::net::{Ipv4Addr, Ipv6Addr};
//! Utility for {rfc_name} packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! {dict_file_contents}
//! ```
use chrono::{DateTime, Utc};
use std::net::{{Ipv4Addr, Ipv6Addr}};
use crate::core::avp::{AVP, AVPType, AVPError};
use chrono::{{DateTime, Utc}};
use crate::core::avp::{{AVP, AVPType, AVPError}};
use crate::core::packet::Packet;
use crate::core::tag::Tag;
";
",
rfc_name = rfc_name,
dict_file_contents = dict_file_lines
.map(|line| format!("//! {}", line.unwrap()))
.collect::<Vec<_>>()
.join("\n"),
);
w.write_all(code).unwrap();
w.write_all(code.as_bytes()).unwrap();
for rfc_name in rfc_names {
w.write_all(format!("use crate::core::{};\n", rfc_name).as_bytes())
@@ -331,7 +350,7 @@ fn generate_attribute_code(
RadiusAttributeValueType::Integer => {
match value_defined_attributes_set.contains(&attr_name) {
true => match attr.has_tag {
true => generate_value_tagged_defined_integer_attribute_code(
true => generate_tagged_value_defined_integer_attribute_code(
w,
&method_identifier,
&type_identifier,
@@ -373,6 +392,7 @@ fn generate_common_attribute_code(
let code = format!(
"
pub const {type_identifier}: AVPType = {type_value};
/// Delete all of `{method_identifier}` values from a packet.
pub fn delete_{method_identifier}(packet: &mut Packet) {{
packet.delete({type_identifier});
}}
@@ -390,12 +410,17 @@ fn generate_string_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: &str) {{
"/// Add `{method_identifier}` string value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: &str) {{
packet.add(AVP::from_string({type_identifier}, value));
}}
/// Lookup a `{method_identifier}` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<String, AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_string())
}}
/// Lookup all of the `{method_identifier}` string value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<String>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -416,12 +441,17 @@ fn generate_tagged_string_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, tag: Option<&Tag>, value: &str) {{
"/// Add `{method_identifier}` tagged string value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, tag: Option<&Tag>, value: &str) {{
packet.add(AVP::from_tagged_string({type_identifier}, tag, value));
}}
/// Lookup a `{method_identifier}` tagged string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<(String, Option<Tag>), AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_tagged_string())
}}
/// Lookup all of the `{method_identifier}` tagged string value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<(String, Option<Tag>)>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -442,13 +472,18 @@ fn generate_user_password_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {{
"/// Add `{method_identifier}` user-password value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {{
packet.add(AVP::from_user_password({type_identifier}, value, packet.get_secret(), packet.get_authenticator())?);
Ok(())
}}
/// Lookup a `{method_identifier}` user-password value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<Vec<u8>, AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_user_password(packet.get_secret(), packet.get_authenticator()))
}}
/// Lookup all of the `{method_identifier}` user-password value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<Vec<u8>>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -469,13 +504,18 @@ fn generate_tunnel_password_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, tag: Option<&Tag>, value: &[u8]) -> Result<(), AVPError> {{
"/// Add `{method_identifier}` tunnel-password value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, tag: Option<&Tag>, value: &[u8]) -> Result<(), AVPError> {{
packet.add(AVP::from_tunnel_password({type_identifier}, tag, value, packet.get_secret(), packet.get_authenticator())?);
Ok(())
}}
/// Lookup a `{method_identifier}` tunnel-password value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<(Vec<u8>, Tag), AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_tunnel_password(packet.get_secret(), packet.get_authenticator()))
}}
/// Lookup all of the `{method_identifier}` tunnel-password value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<(Vec<u8>, Tag)>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -496,12 +536,17 @@ fn generate_octets_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: &[u8]) {{
"/// Add `{method_identifier}` octets value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: &[u8]) {{
packet.add(AVP::from_bytes({type_identifier}, value));
}}
/// Lookup a `{method_identifier}` octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Vec<u8>> {{
packet.lookup({type_identifier}).map(|v| v.encode_bytes())
}}
/// Lookup all of the `{method_identifier}` octets value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Vec<Vec<u8>> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -554,16 +599,21 @@ fn generate_fixed_length_octets_attribute_code(
fixed_octets_length: usize,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {{
"/// Add `{method_identifier}` fixed-length octets value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {{
if value.len() != {fixed_octets_length} {{
return Err(AVPError::InvalidAttributeLengthError(\"{fixed_octets_length} bytes\".to_owned(), value.len()));
}}
packet.add(AVP::from_bytes({type_identifier}, value));
Ok(())
}}
/// Lookup a `{method_identifier}` fixed-length octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Vec<u8>> {{
packet.lookup({type_identifier}).map(|v| v.encode_bytes())
}}
/// Lookup all of the `{method_identifier}` fixed-length octets value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Vec<Vec<u8>> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -585,12 +635,17 @@ fn generate_ipaddr_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: &Ipv4Addr) {{
"/// Add `{method_identifier}` ipaddr value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: &Ipv4Addr) {{
packet.add(AVP::from_ipv4({type_identifier}, value));
}}
/// Lookup a `{method_identifier}` ipaddr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<Ipv4Addr, AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_ipv4())
}}
/// Lookup all of the `{method_identifier}` ipaddr value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<Ipv4Addr>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -611,13 +666,18 @@ fn generate_ipv4_prefix_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {{
"/// Add `{method_identifier}` ipv4 prefix value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {{
packet.add(AVP::from_ipv4_prefix({type_identifier}, value)?);
Ok(())
}}
/// Lookup a `{method_identifier}` ipv4 prefix value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<Vec<u8>, AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_ipv4_prefix())
}}
/// Lookup all of the `{method_identifier}` ipv4 prefix value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<Vec<u8>>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -638,12 +698,17 @@ fn generate_ipv6addr_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: &Ipv6Addr) {{
"/// Add `{method_identifier}` ipv6addr value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: &Ipv6Addr) {{
packet.add(AVP::from_ipv6({type_identifier}, value));
}}
/// Lookup a `{method_identifier}` ipv6addr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<Ipv6Addr, AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_ipv6())
}}
/// Lookup all of the `{method_identifier}` ipv6addr value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<Ipv6Addr>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -664,13 +729,18 @@ fn generate_ipv6_prefix_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {{
"/// Add `{method_identifier}` ipv6 prefix value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {{
packet.add(AVP::from_ipv6_prefix({type_identifier}, value)?);
Ok(())
}}
/// Lookup a `{method_identifier}` ipv6 prefix value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<Vec<u8>, AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_ipv6_prefix())
}}
/// Lookup all of the `{method_identifier}` ipv6 prefix value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<Vec<u8>>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -691,12 +761,17 @@ fn generate_date_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: &DateTime<Utc>) {{
"/// Add `{method_identifier}` date value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: &DateTime<Utc>) {{
packet.add(AVP::from_date({type_identifier}, value));
}}
/// Lookup a `{method_identifier}` date value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<DateTime<Utc>, AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_date())
}}
/// Lookup all of the `{method_identifier}` date value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<DateTime<Utc>>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -717,12 +792,17 @@ fn generate_integer_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: u32) {{
"/// Add `{method_identifier}` integer value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: u32) {{
packet.add(AVP::from_u32({type_identifier}, value));
}}
/// Lookup a `{method_identifier}` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<u32, AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_u32())
}}
/// Lookup all of the `{method_identifier}` integer value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<u32>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -743,12 +823,17 @@ fn generate_tagged_integer_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, tag: Option<&Tag>, value: u32) {{
"/// Add `{method_identifier}` tagged integer value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, tag: Option<&Tag>, value: u32) {{
packet.add(AVP::from_tagged_u32({type_identifier}, tag, value));
}}
/// Lookup a `{method_identifier}` tagged integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<(u32, Tag), AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_tagged_u32())
}}
/// Lookup all of the `{method_identifier}` tagged integer value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<(u32, Tag)>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -770,12 +855,17 @@ fn generate_value_defined_integer_attribute_code(
value_type: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: {value_type}) {{
"/// Add `{method_identifier}` value-defined integer value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: {value_type}) {{
packet.add(AVP::from_u32({type_identifier}, value as u32));
}}
/// Lookup a `{method_identifier}` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<{value_type}, AVPError>> {{
packet.lookup({type_identifier}).map(|v| Ok(v.encode_u32()? as {value_type}))
}}
/// Lookup all of the `{method_identifier}` value-defined integer value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<{value_type}>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -791,22 +881,27 @@ pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<{value_type
w.write_all(code.as_bytes()).unwrap();
}
fn generate_value_tagged_defined_integer_attribute_code(
fn generate_tagged_value_defined_integer_attribute_code(
w: &mut BufWriter<File>,
method_identifier: &str,
type_identifier: &str,
value_type: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, tag: Option<&Tag>, value: {value_type}) {{
"/// Add `{method_identifier}` tagged value-defined integer value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, tag: Option<&Tag>, value: {value_type}) {{
packet.add(AVP::from_tagged_u32({type_identifier}, tag, value as u32));
}}
/// Lookup a `{method_identifier}` tagged value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<({value_type}, Tag), AVPError>> {{
packet.lookup({type_identifier}).map(|v| {{
let (v, t) = v.encode_tagged_u32()?;
Ok((v as {value_type}, t))
}})
}}
/// Lookup all of the `{method_identifier}` tagged value-defined integer value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<({value_type}, Tag)>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -829,12 +924,17 @@ fn generate_short_attribute_code(
type_identifier: &str,
) {
let code = format!(
"pub fn add_{method_identifier}(packet: &mut Packet, value: u16) {{
"/// Add `{method_identifier}` short integer value to a packet.
pub fn add_{method_identifier}(packet: &mut Packet, value: u16) {{
packet.add(AVP::from_u16({type_identifier}, value));
}}
/// Lookup a `{method_identifier}` short integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `{method_identifier}`, it returns `None`.
pub fn lookup_{method_identifier}(packet: &Packet) -> Option<Result<u16, AVPError>> {{
packet.lookup({type_identifier}).map(|v| v.encode_u16())
}}
/// Lookup all of the `{method_identifier}` short integer value from a packet.
pub fn lookup_all_{method_identifier}(packet: &Packet) -> Result<Vec<u16>, AVPError> {{
let mut vec = Vec::new();
for avp in packet.lookup_all({type_identifier}) {{
@@ -855,7 +955,9 @@ fn generate_vsa_attribute_code() {
type DictParsed = (Vec<RadiusAttribute>, BTreeMap<String, Vec<RadiusValue>>);
fn parse_dict_file(dict_file_path: &Path) -> Result<DictParsed, String> {
fn parse_dict_file(
dict_file_path: &Path,
) -> Result<(DictParsed, io::Lines<io::BufReader<File>>), String> {
let line_filter_re = Regex::new(r"^(?:#.*|)$").unwrap();
let tabs_re = Regex::new(r"\t+").unwrap();
let trailing_comment_re = Regex::new(r"\s*?#.+?$").unwrap();
@@ -937,8 +1039,6 @@ fn parse_dict_file(dict_file_path: &Path) -> Result<DictParsed, String> {
}
};
// TODO
radius_attributes.push(RadiusAttribute {
name: items[1].to_string(),
typ: items[2].parse().unwrap(),
@@ -972,5 +1072,8 @@ fn parse_dict_file(dict_file_path: &Path) -> Result<DictParsed, String> {
}
}
Ok((radius_attributes, radius_attribute_to_values))
Ok((
(radius_attributes, radius_attribute_to_values),
read_lines(dict_file_path).unwrap(),
))
}

View File

@@ -1,3 +1,5 @@
//! RADIUS client implementation.
use std::net::SocketAddr;
use std::time::Duration;

View File

@@ -1,3 +1,5 @@
//! RADIUS core implementation for server, client and application.
pub(crate) mod attributes;
pub mod avp;
pub mod code;

File diff suppressed because it is too large Load Diff

View File

@@ -1,20 +1,92 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc2866 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 2866.
//! # http://www.ietf.org/rfc/rfc2866.txt
//! #
//! # $Id$
//! #
//! ATTRIBUTE Acct-Status-Type 40 integer
//! ATTRIBUTE Acct-Delay-Time 41 integer
//! ATTRIBUTE Acct-Input-Octets 42 integer
//! ATTRIBUTE Acct-Output-Octets 43 integer
//! ATTRIBUTE Acct-Session-Id 44 string
//! ATTRIBUTE Acct-Authentic 45 integer
//! ATTRIBUTE Acct-Session-Time 46 integer
//! ATTRIBUTE Acct-Input-Packets 47 integer
//! ATTRIBUTE Acct-Output-Packets 48 integer
//! ATTRIBUTE Acct-Terminate-Cause 49 integer
//! ATTRIBUTE Acct-Multi-Session-Id 50 string
//! ATTRIBUTE Acct-Link-Count 51 integer
//!
//! # Accounting Status Types
//!
//! VALUE Acct-Status-Type Start 1
//! VALUE Acct-Status-Type Stop 2
//! VALUE Acct-Status-Type Alive 3 # dup
//! VALUE Acct-Status-Type Interim-Update 3
//! VALUE Acct-Status-Type Accounting-On 7
//! VALUE Acct-Status-Type Accounting-Off 8
//! VALUE Acct-Status-Type Failed 15
//!
//! # Authentication Types
//!
//! VALUE Acct-Authentic RADIUS 1
//! VALUE Acct-Authentic Local 2
//! VALUE Acct-Authentic Remote 3
//! VALUE Acct-Authentic Diameter 4
//!
//! # Acct Terminate Causes
//!
//! VALUE Acct-Terminate-Cause User-Request 1
//! VALUE Acct-Terminate-Cause Lost-Carrier 2
//! VALUE Acct-Terminate-Cause Lost-Service 3
//! VALUE Acct-Terminate-Cause Idle-Timeout 4
//! VALUE Acct-Terminate-Cause Session-Timeout 5
//! VALUE Acct-Terminate-Cause Admin-Reset 6
//! VALUE Acct-Terminate-Cause Admin-Reboot 7
//! VALUE Acct-Terminate-Cause Port-Error 8
//! VALUE Acct-Terminate-Cause NAS-Error 9
//! VALUE Acct-Terminate-Cause NAS-Request 10
//! VALUE Acct-Terminate-Cause NAS-Reboot 11
//! VALUE Acct-Terminate-Cause Port-Unneeded 12
//! VALUE Acct-Terminate-Cause Port-Preempted 13
//! VALUE Acct-Terminate-Cause Port-Suspended 14
//! VALUE Acct-Terminate-Cause Service-Unavailable 15
//! VALUE Acct-Terminate-Cause Callback 16
//! VALUE Acct-Terminate-Cause User-Error 17
//! VALUE Acct-Terminate-Cause Host-Request 18
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const ACCT_STATUS_TYPE_TYPE: AVPType = 40;
/// Delete all of `acct_status_type` values from a packet.
pub fn delete_acct_status_type(packet: &mut Packet) {
packet.delete(ACCT_STATUS_TYPE_TYPE);
}
/// Add `acct_status_type` value-defined integer value to a packet.
pub fn add_acct_status_type(packet: &mut Packet, value: AcctStatusType) {
packet.add(AVP::from_u32(ACCT_STATUS_TYPE_TYPE, value as u32));
}
/// Lookup a `acct_status_type` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_status_type`, it returns `None`.
pub fn lookup_acct_status_type(packet: &Packet) -> Option<Result<AcctStatusType, AVPError>> {
packet
.lookup(ACCT_STATUS_TYPE_TYPE)
.map(|v| Ok(v.encode_u32()? as AcctStatusType))
}
/// Lookup all of the `acct_status_type` value-defined integer value from a packet.
pub fn lookup_all_acct_status_type(packet: &Packet) -> Result<Vec<AcctStatusType>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_STATUS_TYPE_TYPE) {
@@ -24,15 +96,21 @@ pub fn lookup_all_acct_status_type(packet: &Packet) -> Result<Vec<AcctStatusType
}
pub const ACCT_DELAY_TIME_TYPE: AVPType = 41;
/// Delete all of `acct_delay_time` values from a packet.
pub fn delete_acct_delay_time(packet: &mut Packet) {
packet.delete(ACCT_DELAY_TIME_TYPE);
}
/// Add `acct_delay_time` integer value to a packet.
pub fn add_acct_delay_time(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_DELAY_TIME_TYPE, value));
}
/// Lookup a `acct_delay_time` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_delay_time`, it returns `None`.
pub fn lookup_acct_delay_time(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet.lookup(ACCT_DELAY_TIME_TYPE).map(|v| v.encode_u32())
}
/// Lookup all of the `acct_delay_time` integer value from a packet.
pub fn lookup_all_acct_delay_time(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_DELAY_TIME_TYPE) {
@@ -42,17 +120,23 @@ pub fn lookup_all_acct_delay_time(packet: &Packet) -> Result<Vec<u32>, AVPError>
}
pub const ACCT_INPUT_OCTETS_TYPE: AVPType = 42;
/// Delete all of `acct_input_octets` values from a packet.
pub fn delete_acct_input_octets(packet: &mut Packet) {
packet.delete(ACCT_INPUT_OCTETS_TYPE);
}
/// Add `acct_input_octets` integer value to a packet.
pub fn add_acct_input_octets(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_INPUT_OCTETS_TYPE, value));
}
/// Lookup a `acct_input_octets` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_input_octets`, it returns `None`.
pub fn lookup_acct_input_octets(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet
.lookup(ACCT_INPUT_OCTETS_TYPE)
.map(|v| v.encode_u32())
}
/// Lookup all of the `acct_input_octets` integer value from a packet.
pub fn lookup_all_acct_input_octets(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_INPUT_OCTETS_TYPE) {
@@ -62,17 +146,23 @@ pub fn lookup_all_acct_input_octets(packet: &Packet) -> Result<Vec<u32>, AVPErro
}
pub const ACCT_OUTPUT_OCTETS_TYPE: AVPType = 43;
/// Delete all of `acct_output_octets` values from a packet.
pub fn delete_acct_output_octets(packet: &mut Packet) {
packet.delete(ACCT_OUTPUT_OCTETS_TYPE);
}
/// Add `acct_output_octets` integer value to a packet.
pub fn add_acct_output_octets(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_OUTPUT_OCTETS_TYPE, value));
}
/// Lookup a `acct_output_octets` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_output_octets`, it returns `None`.
pub fn lookup_acct_output_octets(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet
.lookup(ACCT_OUTPUT_OCTETS_TYPE)
.map(|v| v.encode_u32())
}
/// Lookup all of the `acct_output_octets` integer value from a packet.
pub fn lookup_all_acct_output_octets(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_OUTPUT_OCTETS_TYPE) {
@@ -82,17 +172,23 @@ pub fn lookup_all_acct_output_octets(packet: &Packet) -> Result<Vec<u32>, AVPErr
}
pub const ACCT_SESSION_ID_TYPE: AVPType = 44;
/// Delete all of `acct_session_id` values from a packet.
pub fn delete_acct_session_id(packet: &mut Packet) {
packet.delete(ACCT_SESSION_ID_TYPE);
}
/// Add `acct_session_id` string value to a packet.
pub fn add_acct_session_id(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(ACCT_SESSION_ID_TYPE, value));
}
/// Lookup a `acct_session_id` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_session_id`, it returns `None`.
pub fn lookup_acct_session_id(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(ACCT_SESSION_ID_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `acct_session_id` string value from a packet.
pub fn lookup_all_acct_session_id(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_SESSION_ID_TYPE) {
@@ -102,17 +198,23 @@ pub fn lookup_all_acct_session_id(packet: &Packet) -> Result<Vec<String>, AVPErr
}
pub const ACCT_AUTHENTIC_TYPE: AVPType = 45;
/// Delete all of `acct_authentic` values from a packet.
pub fn delete_acct_authentic(packet: &mut Packet) {
packet.delete(ACCT_AUTHENTIC_TYPE);
}
/// Add `acct_authentic` value-defined integer value to a packet.
pub fn add_acct_authentic(packet: &mut Packet, value: AcctAuthentic) {
packet.add(AVP::from_u32(ACCT_AUTHENTIC_TYPE, value as u32));
}
/// Lookup a `acct_authentic` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_authentic`, it returns `None`.
pub fn lookup_acct_authentic(packet: &Packet) -> Option<Result<AcctAuthentic, AVPError>> {
packet
.lookup(ACCT_AUTHENTIC_TYPE)
.map(|v| Ok(v.encode_u32()? as AcctAuthentic))
}
/// Lookup all of the `acct_authentic` value-defined integer value from a packet.
pub fn lookup_all_acct_authentic(packet: &Packet) -> Result<Vec<AcctAuthentic>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_AUTHENTIC_TYPE) {
@@ -122,17 +224,23 @@ pub fn lookup_all_acct_authentic(packet: &Packet) -> Result<Vec<AcctAuthentic>,
}
pub const ACCT_SESSION_TIME_TYPE: AVPType = 46;
/// Delete all of `acct_session_time` values from a packet.
pub fn delete_acct_session_time(packet: &mut Packet) {
packet.delete(ACCT_SESSION_TIME_TYPE);
}
/// Add `acct_session_time` integer value to a packet.
pub fn add_acct_session_time(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_SESSION_TIME_TYPE, value));
}
/// Lookup a `acct_session_time` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_session_time`, it returns `None`.
pub fn lookup_acct_session_time(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet
.lookup(ACCT_SESSION_TIME_TYPE)
.map(|v| v.encode_u32())
}
/// Lookup all of the `acct_session_time` integer value from a packet.
pub fn lookup_all_acct_session_time(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_SESSION_TIME_TYPE) {
@@ -142,17 +250,23 @@ pub fn lookup_all_acct_session_time(packet: &Packet) -> Result<Vec<u32>, AVPErro
}
pub const ACCT_INPUT_PACKETS_TYPE: AVPType = 47;
/// Delete all of `acct_input_packets` values from a packet.
pub fn delete_acct_input_packets(packet: &mut Packet) {
packet.delete(ACCT_INPUT_PACKETS_TYPE);
}
/// Add `acct_input_packets` integer value to a packet.
pub fn add_acct_input_packets(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_INPUT_PACKETS_TYPE, value));
}
/// Lookup a `acct_input_packets` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_input_packets`, it returns `None`.
pub fn lookup_acct_input_packets(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet
.lookup(ACCT_INPUT_PACKETS_TYPE)
.map(|v| v.encode_u32())
}
/// Lookup all of the `acct_input_packets` integer value from a packet.
pub fn lookup_all_acct_input_packets(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_INPUT_PACKETS_TYPE) {
@@ -162,17 +276,23 @@ pub fn lookup_all_acct_input_packets(packet: &Packet) -> Result<Vec<u32>, AVPErr
}
pub const ACCT_OUTPUT_PACKETS_TYPE: AVPType = 48;
/// Delete all of `acct_output_packets` values from a packet.
pub fn delete_acct_output_packets(packet: &mut Packet) {
packet.delete(ACCT_OUTPUT_PACKETS_TYPE);
}
/// Add `acct_output_packets` integer value to a packet.
pub fn add_acct_output_packets(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_OUTPUT_PACKETS_TYPE, value));
}
/// Lookup a `acct_output_packets` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_output_packets`, it returns `None`.
pub fn lookup_acct_output_packets(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet
.lookup(ACCT_OUTPUT_PACKETS_TYPE)
.map(|v| v.encode_u32())
}
/// Lookup all of the `acct_output_packets` integer value from a packet.
pub fn lookup_all_acct_output_packets(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_OUTPUT_PACKETS_TYPE) {
@@ -182,12 +302,17 @@ pub fn lookup_all_acct_output_packets(packet: &Packet) -> Result<Vec<u32>, AVPEr
}
pub const ACCT_TERMINATE_CAUSE_TYPE: AVPType = 49;
/// Delete all of `acct_terminate_cause` values from a packet.
pub fn delete_acct_terminate_cause(packet: &mut Packet) {
packet.delete(ACCT_TERMINATE_CAUSE_TYPE);
}
/// Add `acct_terminate_cause` value-defined integer value to a packet.
pub fn add_acct_terminate_cause(packet: &mut Packet, value: AcctTerminateCause) {
packet.add(AVP::from_u32(ACCT_TERMINATE_CAUSE_TYPE, value as u32));
}
/// Lookup a `acct_terminate_cause` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_terminate_cause`, it returns `None`.
pub fn lookup_acct_terminate_cause(
packet: &Packet,
) -> Option<Result<AcctTerminateCause, AVPError>> {
@@ -195,6 +320,7 @@ pub fn lookup_acct_terminate_cause(
.lookup(ACCT_TERMINATE_CAUSE_TYPE)
.map(|v| Ok(v.encode_u32()? as AcctTerminateCause))
}
/// Lookup all of the `acct_terminate_cause` value-defined integer value from a packet.
pub fn lookup_all_acct_terminate_cause(
packet: &Packet,
) -> Result<Vec<AcctTerminateCause>, AVPError> {
@@ -206,17 +332,23 @@ pub fn lookup_all_acct_terminate_cause(
}
pub const ACCT_MULTI_SESSION_ID_TYPE: AVPType = 50;
/// Delete all of `acct_multi_session_id` values from a packet.
pub fn delete_acct_multi_session_id(packet: &mut Packet) {
packet.delete(ACCT_MULTI_SESSION_ID_TYPE);
}
/// Add `acct_multi_session_id` string value to a packet.
pub fn add_acct_multi_session_id(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(ACCT_MULTI_SESSION_ID_TYPE, value));
}
/// Lookup a `acct_multi_session_id` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_multi_session_id`, it returns `None`.
pub fn lookup_acct_multi_session_id(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(ACCT_MULTI_SESSION_ID_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `acct_multi_session_id` string value from a packet.
pub fn lookup_all_acct_multi_session_id(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_MULTI_SESSION_ID_TYPE) {
@@ -226,15 +358,21 @@ pub fn lookup_all_acct_multi_session_id(packet: &Packet) -> Result<Vec<String>,
}
pub const ACCT_LINK_COUNT_TYPE: AVPType = 51;
/// Delete all of `acct_link_count` values from a packet.
pub fn delete_acct_link_count(packet: &mut Packet) {
packet.delete(ACCT_LINK_COUNT_TYPE);
}
/// Add `acct_link_count` integer value to a packet.
pub fn add_acct_link_count(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_LINK_COUNT_TYPE, value));
}
/// Lookup a `acct_link_count` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_link_count`, it returns `None`.
pub fn lookup_acct_link_count(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet.lookup(ACCT_LINK_COUNT_TYPE).map(|v| v.encode_u32())
}
/// Lookup all of the `acct_link_count` integer value from a packet.
pub fn lookup_all_acct_link_count(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_LINK_COUNT_TYPE) {

View File

@@ -1,22 +1,53 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc2867 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 2867.
//! # http://www.ietf.org/rfc/rfc2867.txt
//! #
//! # $Id$
//! #
//! ATTRIBUTE Acct-Tunnel-Connection 68 string
//! ATTRIBUTE Acct-Tunnel-Packets-Lost 86 integer
//!
//! VALUE Acct-Status-Type Tunnel-Start 9
//! VALUE Acct-Status-Type Tunnel-Stop 10
//! VALUE Acct-Status-Type Tunnel-Reject 11
//! VALUE Acct-Status-Type Tunnel-Link-Start 12
//! VALUE Acct-Status-Type Tunnel-Link-Stop 13
//! VALUE Acct-Status-Type Tunnel-Link-Reject 14
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
use crate::core::rfc2866;
pub const ACCT_TUNNEL_CONNECTION_TYPE: AVPType = 68;
/// Delete all of `acct_tunnel_connection` values from a packet.
pub fn delete_acct_tunnel_connection(packet: &mut Packet) {
packet.delete(ACCT_TUNNEL_CONNECTION_TYPE);
}
/// Add `acct_tunnel_connection` string value to a packet.
pub fn add_acct_tunnel_connection(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(ACCT_TUNNEL_CONNECTION_TYPE, value));
}
/// Lookup a `acct_tunnel_connection` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_tunnel_connection`, it returns `None`.
pub fn lookup_acct_tunnel_connection(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(ACCT_TUNNEL_CONNECTION_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `acct_tunnel_connection` string value from a packet.
pub fn lookup_all_acct_tunnel_connection(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_TUNNEL_CONNECTION_TYPE) {
@@ -26,17 +57,23 @@ pub fn lookup_all_acct_tunnel_connection(packet: &Packet) -> Result<Vec<String>,
}
pub const ACCT_TUNNEL_PACKETS_LOST_TYPE: AVPType = 86;
/// Delete all of `acct_tunnel_packets_lost` values from a packet.
pub fn delete_acct_tunnel_packets_lost(packet: &mut Packet) {
packet.delete(ACCT_TUNNEL_PACKETS_LOST_TYPE);
}
/// Add `acct_tunnel_packets_lost` integer value to a packet.
pub fn add_acct_tunnel_packets_lost(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_TUNNEL_PACKETS_LOST_TYPE, value));
}
/// Lookup a `acct_tunnel_packets_lost` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_tunnel_packets_lost`, it returns `None`.
pub fn lookup_acct_tunnel_packets_lost(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet
.lookup(ACCT_TUNNEL_PACKETS_LOST_TYPE)
.map(|v| v.encode_u32())
}
/// Lookup all of the `acct_tunnel_packets_lost` integer value from a packet.
pub fn lookup_all_acct_tunnel_packets_lost(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_TUNNEL_PACKETS_LOST_TYPE) {

View File

@@ -1,22 +1,91 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc2868 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 2868.
//! # http://www.ietf.org/rfc/rfc2868.txt
//! #
//! # $Id$
//! #
//! ATTRIBUTE Tunnel-Type 64 integer has_tag
//! ATTRIBUTE Tunnel-Medium-Type 65 integer has_tag
//! ATTRIBUTE Tunnel-Client-Endpoint 66 string has_tag
//! ATTRIBUTE Tunnel-Server-Endpoint 67 string has_tag
//!
//! ATTRIBUTE Tunnel-Password 69 string has_tag,encrypt=2
//!
//! ATTRIBUTE Tunnel-Private-Group-Id 81 string has_tag
//! ATTRIBUTE Tunnel-Assignment-Id 82 string has_tag
//! ATTRIBUTE Tunnel-Preference 83 integer has_tag
//!
//! ATTRIBUTE Tunnel-Client-Auth-Id 90 string has_tag
//! ATTRIBUTE Tunnel-Server-Auth-Id 91 string has_tag
//!
//! # Tunnel Type
//!
//! VALUE Tunnel-Type PPTP 1
//! VALUE Tunnel-Type L2F 2
//! VALUE Tunnel-Type L2TP 3
//! VALUE Tunnel-Type ATMP 4
//! VALUE Tunnel-Type VTP 5
//! VALUE Tunnel-Type AH 6
//! VALUE Tunnel-Type IP 7
//! VALUE Tunnel-Type MIN-IP 8
//! VALUE Tunnel-Type ESP 9
//! VALUE Tunnel-Type GRE 10
//! VALUE Tunnel-Type DVS 11
//! VALUE Tunnel-Type IP-in-IP 12
//!
//! # Tunnel Medium Type
//!
//! VALUE Tunnel-Medium-Type IP 1
//! VALUE Tunnel-Medium-Type IPv4 1
//! VALUE Tunnel-Medium-Type IPv6 2
//! VALUE Tunnel-Medium-Type NSAP 3
//! VALUE Tunnel-Medium-Type HDLC 4
//! VALUE Tunnel-Medium-Type BBN-1822 5
//! VALUE Tunnel-Medium-Type IEEE-802 6
//! VALUE Tunnel-Medium-Type E.163 7
//! VALUE Tunnel-Medium-Type E.164 8
//! VALUE Tunnel-Medium-Type F.69 9
//! VALUE Tunnel-Medium-Type X.121 10
//! VALUE Tunnel-Medium-Type IPX 11
//! VALUE Tunnel-Medium-Type Appletalk 12
//! VALUE Tunnel-Medium-Type DecNet-IV 13
//! VALUE Tunnel-Medium-Type Banyan-Vines 14
//! VALUE Tunnel-Medium-Type E.164-NSAP 15
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
use crate::core::tag::Tag;
pub const TUNNEL_TYPE_TYPE: AVPType = 64;
/// Delete all of `tunnel_type` values from a packet.
pub fn delete_tunnel_type(packet: &mut Packet) {
packet.delete(TUNNEL_TYPE_TYPE);
}
/// Add `tunnel_type` tagged value-defined integer value to a packet.
pub fn add_tunnel_type(packet: &mut Packet, tag: Option<&Tag>, value: TunnelType) {
packet.add(AVP::from_tagged_u32(TUNNEL_TYPE_TYPE, tag, value as u32));
}
/// Lookup a `tunnel_type` tagged value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `tunnel_type`, it returns `None`.
pub fn lookup_tunnel_type(packet: &Packet) -> Option<Result<(TunnelType, Tag), AVPError>> {
packet.lookup(TUNNEL_TYPE_TYPE).map(|v| {
let (v, t) = v.encode_tagged_u32()?;
Ok((v as TunnelType, t))
})
}
/// Lookup all of the `tunnel_type` tagged value-defined integer value from a packet.
pub fn lookup_all_tunnel_type(packet: &Packet) -> Result<Vec<(TunnelType, Tag)>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(TUNNEL_TYPE_TYPE) {
@@ -27,9 +96,11 @@ pub fn lookup_all_tunnel_type(packet: &Packet) -> Result<Vec<(TunnelType, Tag)>,
}
pub const TUNNEL_MEDIUM_TYPE_TYPE: AVPType = 65;
/// Delete all of `tunnel_medium_type` values from a packet.
pub fn delete_tunnel_medium_type(packet: &mut Packet) {
packet.delete(TUNNEL_MEDIUM_TYPE_TYPE);
}
/// Add `tunnel_medium_type` tagged value-defined integer value to a packet.
pub fn add_tunnel_medium_type(packet: &mut Packet, tag: Option<&Tag>, value: TunnelMediumType) {
packet.add(AVP::from_tagged_u32(
TUNNEL_MEDIUM_TYPE_TYPE,
@@ -37,6 +108,9 @@ pub fn add_tunnel_medium_type(packet: &mut Packet, tag: Option<&Tag>, value: Tun
value as u32,
));
}
/// Lookup a `tunnel_medium_type` tagged value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `tunnel_medium_type`, it returns `None`.
pub fn lookup_tunnel_medium_type(
packet: &Packet,
) -> Option<Result<(TunnelMediumType, Tag), AVPError>> {
@@ -45,6 +119,7 @@ pub fn lookup_tunnel_medium_type(
Ok((v as TunnelMediumType, t))
})
}
/// Lookup all of the `tunnel_medium_type` tagged value-defined integer value from a packet.
pub fn lookup_all_tunnel_medium_type(
packet: &Packet,
) -> Result<Vec<(TunnelMediumType, Tag)>, AVPError> {
@@ -57,9 +132,11 @@ pub fn lookup_all_tunnel_medium_type(
}
pub const TUNNEL_CLIENT_ENDPOINT_TYPE: AVPType = 66;
/// Delete all of `tunnel_client_endpoint` values from a packet.
pub fn delete_tunnel_client_endpoint(packet: &mut Packet) {
packet.delete(TUNNEL_CLIENT_ENDPOINT_TYPE);
}
/// Add `tunnel_client_endpoint` tagged string value to a packet.
pub fn add_tunnel_client_endpoint(packet: &mut Packet, tag: Option<&Tag>, value: &str) {
packet.add(AVP::from_tagged_string(
TUNNEL_CLIENT_ENDPOINT_TYPE,
@@ -67,6 +144,9 @@ pub fn add_tunnel_client_endpoint(packet: &mut Packet, tag: Option<&Tag>, value:
value,
));
}
/// Lookup a `tunnel_client_endpoint` tagged string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `tunnel_client_endpoint`, it returns `None`.
pub fn lookup_tunnel_client_endpoint(
packet: &Packet,
) -> Option<Result<(String, Option<Tag>), AVPError>> {
@@ -74,6 +154,7 @@ pub fn lookup_tunnel_client_endpoint(
.lookup(TUNNEL_CLIENT_ENDPOINT_TYPE)
.map(|v| v.encode_tagged_string())
}
/// Lookup all of the `tunnel_client_endpoint` tagged string value from a packet.
pub fn lookup_all_tunnel_client_endpoint(
packet: &Packet,
) -> Result<Vec<(String, Option<Tag>)>, AVPError> {
@@ -85,9 +166,11 @@ pub fn lookup_all_tunnel_client_endpoint(
}
pub const TUNNEL_SERVER_ENDPOINT_TYPE: AVPType = 67;
/// Delete all of `tunnel_server_endpoint` values from a packet.
pub fn delete_tunnel_server_endpoint(packet: &mut Packet) {
packet.delete(TUNNEL_SERVER_ENDPOINT_TYPE);
}
/// Add `tunnel_server_endpoint` tagged string value to a packet.
pub fn add_tunnel_server_endpoint(packet: &mut Packet, tag: Option<&Tag>, value: &str) {
packet.add(AVP::from_tagged_string(
TUNNEL_SERVER_ENDPOINT_TYPE,
@@ -95,6 +178,9 @@ pub fn add_tunnel_server_endpoint(packet: &mut Packet, tag: Option<&Tag>, value:
value,
));
}
/// Lookup a `tunnel_server_endpoint` tagged string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `tunnel_server_endpoint`, it returns `None`.
pub fn lookup_tunnel_server_endpoint(
packet: &Packet,
) -> Option<Result<(String, Option<Tag>), AVPError>> {
@@ -102,6 +188,7 @@ pub fn lookup_tunnel_server_endpoint(
.lookup(TUNNEL_SERVER_ENDPOINT_TYPE)
.map(|v| v.encode_tagged_string())
}
/// Lookup all of the `tunnel_server_endpoint` tagged string value from a packet.
pub fn lookup_all_tunnel_server_endpoint(
packet: &Packet,
) -> Result<Vec<(String, Option<Tag>)>, AVPError> {
@@ -113,9 +200,11 @@ pub fn lookup_all_tunnel_server_endpoint(
}
pub const TUNNEL_PASSWORD_TYPE: AVPType = 69;
/// Delete all of `tunnel_password` values from a packet.
pub fn delete_tunnel_password(packet: &mut Packet) {
packet.delete(TUNNEL_PASSWORD_TYPE);
}
/// Add `tunnel_password` tunnel-password value to a packet.
pub fn add_tunnel_password(
packet: &mut Packet,
tag: Option<&Tag>,
@@ -130,11 +219,15 @@ pub fn add_tunnel_password(
)?);
Ok(())
}
/// Lookup a `tunnel_password` tunnel-password value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `tunnel_password`, it returns `None`.
pub fn lookup_tunnel_password(packet: &Packet) -> Option<Result<(Vec<u8>, Tag), AVPError>> {
packet
.lookup(TUNNEL_PASSWORD_TYPE)
.map(|v| v.encode_tunnel_password(packet.get_secret(), packet.get_authenticator()))
}
/// Lookup all of the `tunnel_password` tunnel-password value from a packet.
pub fn lookup_all_tunnel_password(packet: &Packet) -> Result<Vec<(Vec<u8>, Tag)>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(TUNNEL_PASSWORD_TYPE) {
@@ -144,9 +237,11 @@ pub fn lookup_all_tunnel_password(packet: &Packet) -> Result<Vec<(Vec<u8>, Tag)>
}
pub const TUNNEL_PRIVATE_GROUP_ID_TYPE: AVPType = 81;
/// Delete all of `tunnel_private_group_id` values from a packet.
pub fn delete_tunnel_private_group_id(packet: &mut Packet) {
packet.delete(TUNNEL_PRIVATE_GROUP_ID_TYPE);
}
/// Add `tunnel_private_group_id` tagged string value to a packet.
pub fn add_tunnel_private_group_id(packet: &mut Packet, tag: Option<&Tag>, value: &str) {
packet.add(AVP::from_tagged_string(
TUNNEL_PRIVATE_GROUP_ID_TYPE,
@@ -154,6 +249,9 @@ pub fn add_tunnel_private_group_id(packet: &mut Packet, tag: Option<&Tag>, value
value,
));
}
/// Lookup a `tunnel_private_group_id` tagged string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `tunnel_private_group_id`, it returns `None`.
pub fn lookup_tunnel_private_group_id(
packet: &Packet,
) -> Option<Result<(String, Option<Tag>), AVPError>> {
@@ -161,6 +259,7 @@ pub fn lookup_tunnel_private_group_id(
.lookup(TUNNEL_PRIVATE_GROUP_ID_TYPE)
.map(|v| v.encode_tagged_string())
}
/// Lookup all of the `tunnel_private_group_id` tagged string value from a packet.
pub fn lookup_all_tunnel_private_group_id(
packet: &Packet,
) -> Result<Vec<(String, Option<Tag>)>, AVPError> {
@@ -172,9 +271,11 @@ pub fn lookup_all_tunnel_private_group_id(
}
pub const TUNNEL_ASSIGNMENT_ID_TYPE: AVPType = 82;
/// Delete all of `tunnel_assignment_id` values from a packet.
pub fn delete_tunnel_assignment_id(packet: &mut Packet) {
packet.delete(TUNNEL_ASSIGNMENT_ID_TYPE);
}
/// Add `tunnel_assignment_id` tagged string value to a packet.
pub fn add_tunnel_assignment_id(packet: &mut Packet, tag: Option<&Tag>, value: &str) {
packet.add(AVP::from_tagged_string(
TUNNEL_ASSIGNMENT_ID_TYPE,
@@ -182,6 +283,9 @@ pub fn add_tunnel_assignment_id(packet: &mut Packet, tag: Option<&Tag>, value: &
value,
));
}
/// Lookup a `tunnel_assignment_id` tagged string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `tunnel_assignment_id`, it returns `None`.
pub fn lookup_tunnel_assignment_id(
packet: &Packet,
) -> Option<Result<(String, Option<Tag>), AVPError>> {
@@ -189,6 +293,7 @@ pub fn lookup_tunnel_assignment_id(
.lookup(TUNNEL_ASSIGNMENT_ID_TYPE)
.map(|v| v.encode_tagged_string())
}
/// Lookup all of the `tunnel_assignment_id` tagged string value from a packet.
pub fn lookup_all_tunnel_assignment_id(
packet: &Packet,
) -> Result<Vec<(String, Option<Tag>)>, AVPError> {
@@ -200,17 +305,23 @@ pub fn lookup_all_tunnel_assignment_id(
}
pub const TUNNEL_PREFERENCE_TYPE: AVPType = 83;
/// Delete all of `tunnel_preference` values from a packet.
pub fn delete_tunnel_preference(packet: &mut Packet) {
packet.delete(TUNNEL_PREFERENCE_TYPE);
}
/// Add `tunnel_preference` tagged integer value to a packet.
pub fn add_tunnel_preference(packet: &mut Packet, tag: Option<&Tag>, value: u32) {
packet.add(AVP::from_tagged_u32(TUNNEL_PREFERENCE_TYPE, tag, value));
}
/// Lookup a `tunnel_preference` tagged integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `tunnel_preference`, it returns `None`.
pub fn lookup_tunnel_preference(packet: &Packet) -> Option<Result<(u32, Tag), AVPError>> {
packet
.lookup(TUNNEL_PREFERENCE_TYPE)
.map(|v| v.encode_tagged_u32())
}
/// Lookup all of the `tunnel_preference` tagged integer value from a packet.
pub fn lookup_all_tunnel_preference(packet: &Packet) -> Result<Vec<(u32, Tag)>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(TUNNEL_PREFERENCE_TYPE) {
@@ -220,9 +331,11 @@ pub fn lookup_all_tunnel_preference(packet: &Packet) -> Result<Vec<(u32, Tag)>,
}
pub const TUNNEL_CLIENT_AUTH_ID_TYPE: AVPType = 90;
/// Delete all of `tunnel_client_auth_id` values from a packet.
pub fn delete_tunnel_client_auth_id(packet: &mut Packet) {
packet.delete(TUNNEL_CLIENT_AUTH_ID_TYPE);
}
/// Add `tunnel_client_auth_id` tagged string value to a packet.
pub fn add_tunnel_client_auth_id(packet: &mut Packet, tag: Option<&Tag>, value: &str) {
packet.add(AVP::from_tagged_string(
TUNNEL_CLIENT_AUTH_ID_TYPE,
@@ -230,6 +343,9 @@ pub fn add_tunnel_client_auth_id(packet: &mut Packet, tag: Option<&Tag>, value:
value,
));
}
/// Lookup a `tunnel_client_auth_id` tagged string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `tunnel_client_auth_id`, it returns `None`.
pub fn lookup_tunnel_client_auth_id(
packet: &Packet,
) -> Option<Result<(String, Option<Tag>), AVPError>> {
@@ -237,6 +353,7 @@ pub fn lookup_tunnel_client_auth_id(
.lookup(TUNNEL_CLIENT_AUTH_ID_TYPE)
.map(|v| v.encode_tagged_string())
}
/// Lookup all of the `tunnel_client_auth_id` tagged string value from a packet.
pub fn lookup_all_tunnel_client_auth_id(
packet: &Packet,
) -> Result<Vec<(String, Option<Tag>)>, AVPError> {
@@ -248,9 +365,11 @@ pub fn lookup_all_tunnel_client_auth_id(
}
pub const TUNNEL_SERVER_AUTH_ID_TYPE: AVPType = 91;
/// Delete all of `tunnel_server_auth_id` values from a packet.
pub fn delete_tunnel_server_auth_id(packet: &mut Packet) {
packet.delete(TUNNEL_SERVER_AUTH_ID_TYPE);
}
/// Add `tunnel_server_auth_id` tagged string value to a packet.
pub fn add_tunnel_server_auth_id(packet: &mut Packet, tag: Option<&Tag>, value: &str) {
packet.add(AVP::from_tagged_string(
TUNNEL_SERVER_AUTH_ID_TYPE,
@@ -258,6 +377,9 @@ pub fn add_tunnel_server_auth_id(packet: &mut Packet, tag: Option<&Tag>, value:
value,
));
}
/// Lookup a `tunnel_server_auth_id` tagged string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `tunnel_server_auth_id`, it returns `None`.
pub fn lookup_tunnel_server_auth_id(
packet: &Packet,
) -> Option<Result<(String, Option<Tag>), AVPError>> {
@@ -265,6 +387,7 @@ pub fn lookup_tunnel_server_auth_id(
.lookup(TUNNEL_SERVER_AUTH_ID_TYPE)
.map(|v| v.encode_tagged_string())
}
/// Lookup all of the `tunnel_server_auth_id` tagged string value from a packet.
pub fn lookup_all_tunnel_server_auth_id(
packet: &Packet,
) -> Result<Vec<(String, Option<Tag>)>, AVPError> {

View File

@@ -1,22 +1,76 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc2869 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 2869.
//! # http://www.ietf.org/rfc/rfc2869.txt
//! #
//! # $Id$
//! #
//! ATTRIBUTE Acct-Input-Gigawords 52 integer
//! ATTRIBUTE Acct-Output-Gigawords 53 integer
//!
//! ATTRIBUTE Event-Timestamp 55 date
//!
//! ATTRIBUTE ARAP-Password 70 octets[16]
//! ATTRIBUTE ARAP-Features 71 octets[14]
//! ATTRIBUTE ARAP-Zone-Access 72 integer
//! ATTRIBUTE ARAP-Security 73 integer
//! ATTRIBUTE ARAP-Security-Data 74 string
//! ATTRIBUTE Password-Retry 75 integer
//! ATTRIBUTE Prompt 76 integer
//! ATTRIBUTE Connect-Info 77 string
//! ATTRIBUTE Configuration-Token 78 string
//! ATTRIBUTE EAP-Message 79 octets concat
//! ATTRIBUTE Message-Authenticator 80 octets
//!
//! ATTRIBUTE ARAP-Challenge-Response 84 octets[8]
//! ATTRIBUTE Acct-Interim-Interval 85 integer
//! # 86: RFC 2867
//! ATTRIBUTE NAS-Port-Id 87 string
//! ATTRIBUTE Framed-Pool 88 string
//!
//! # ARAP Zone Access
//!
//! VALUE ARAP-Zone-Access Default-Zone 1
//! VALUE ARAP-Zone-Access Zone-Filter-Inclusive 2
//! VALUE ARAP-Zone-Access Zone-Filter-Exclusive 4
//!
//! # Prompt
//! VALUE Prompt No-Echo 0
//! VALUE Prompt Echo 1
//! ```
use chrono::{DateTime, Utc};
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const ACCT_INPUT_GIGAWORDS_TYPE: AVPType = 52;
/// Delete all of `acct_input_gigawords` values from a packet.
pub fn delete_acct_input_gigawords(packet: &mut Packet) {
packet.delete(ACCT_INPUT_GIGAWORDS_TYPE);
}
/// Add `acct_input_gigawords` integer value to a packet.
pub fn add_acct_input_gigawords(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_INPUT_GIGAWORDS_TYPE, value));
}
/// Lookup a `acct_input_gigawords` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_input_gigawords`, it returns `None`.
pub fn lookup_acct_input_gigawords(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet
.lookup(ACCT_INPUT_GIGAWORDS_TYPE)
.map(|v| v.encode_u32())
}
/// Lookup all of the `acct_input_gigawords` integer value from a packet.
pub fn lookup_all_acct_input_gigawords(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_INPUT_GIGAWORDS_TYPE) {
@@ -26,17 +80,23 @@ pub fn lookup_all_acct_input_gigawords(packet: &Packet) -> Result<Vec<u32>, AVPE
}
pub const ACCT_OUTPUT_GIGAWORDS_TYPE: AVPType = 53;
/// Delete all of `acct_output_gigawords` values from a packet.
pub fn delete_acct_output_gigawords(packet: &mut Packet) {
packet.delete(ACCT_OUTPUT_GIGAWORDS_TYPE);
}
/// Add `acct_output_gigawords` integer value to a packet.
pub fn add_acct_output_gigawords(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_OUTPUT_GIGAWORDS_TYPE, value));
}
/// Lookup a `acct_output_gigawords` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_output_gigawords`, it returns `None`.
pub fn lookup_acct_output_gigawords(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet
.lookup(ACCT_OUTPUT_GIGAWORDS_TYPE)
.map(|v| v.encode_u32())
}
/// Lookup all of the `acct_output_gigawords` integer value from a packet.
pub fn lookup_all_acct_output_gigawords(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_OUTPUT_GIGAWORDS_TYPE) {
@@ -46,15 +106,21 @@ pub fn lookup_all_acct_output_gigawords(packet: &Packet) -> Result<Vec<u32>, AVP
}
pub const EVENT_TIMESTAMP_TYPE: AVPType = 55;
/// Delete all of `event_timestamp` values from a packet.
pub fn delete_event_timestamp(packet: &mut Packet) {
packet.delete(EVENT_TIMESTAMP_TYPE);
}
/// Add `event_timestamp` date value to a packet.
pub fn add_event_timestamp(packet: &mut Packet, value: &DateTime<Utc>) {
packet.add(AVP::from_date(EVENT_TIMESTAMP_TYPE, value));
}
/// Lookup a `event_timestamp` date value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `event_timestamp`, it returns `None`.
pub fn lookup_event_timestamp(packet: &Packet) -> Option<Result<DateTime<Utc>, AVPError>> {
packet.lookup(EVENT_TIMESTAMP_TYPE).map(|v| v.encode_date())
}
/// Lookup all of the `event_timestamp` date value from a packet.
pub fn lookup_all_event_timestamp(packet: &Packet) -> Result<Vec<DateTime<Utc>>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(EVENT_TIMESTAMP_TYPE) {
@@ -64,9 +130,11 @@ pub fn lookup_all_event_timestamp(packet: &Packet) -> Result<Vec<DateTime<Utc>>,
}
pub const ARAP_PASSWORD_TYPE: AVPType = 70;
/// Delete all of `arap_password` values from a packet.
pub fn delete_arap_password(packet: &mut Packet) {
packet.delete(ARAP_PASSWORD_TYPE);
}
/// Add `arap_password` fixed-length octets value to a packet.
pub fn add_arap_password(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
if value.len() != 16 {
return Err(AVPError::InvalidAttributeLengthError(
@@ -77,9 +145,13 @@ pub fn add_arap_password(packet: &mut Packet, value: &[u8]) -> Result<(), AVPErr
packet.add(AVP::from_bytes(ARAP_PASSWORD_TYPE, value));
Ok(())
}
/// Lookup a `arap_password` fixed-length octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `arap_password`, it returns `None`.
pub fn lookup_arap_password(packet: &Packet) -> Option<Vec<u8>> {
packet.lookup(ARAP_PASSWORD_TYPE).map(|v| v.encode_bytes())
}
/// Lookup all of the `arap_password` fixed-length octets value from a packet.
pub fn lookup_all_arap_password(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ARAP_PASSWORD_TYPE) {
@@ -89,9 +161,11 @@ pub fn lookup_all_arap_password(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const ARAP_FEATURES_TYPE: AVPType = 71;
/// Delete all of `arap_features` values from a packet.
pub fn delete_arap_features(packet: &mut Packet) {
packet.delete(ARAP_FEATURES_TYPE);
}
/// Add `arap_features` fixed-length octets value to a packet.
pub fn add_arap_features(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
if value.len() != 14 {
return Err(AVPError::InvalidAttributeLengthError(
@@ -102,9 +176,13 @@ pub fn add_arap_features(packet: &mut Packet, value: &[u8]) -> Result<(), AVPErr
packet.add(AVP::from_bytes(ARAP_FEATURES_TYPE, value));
Ok(())
}
/// Lookup a `arap_features` fixed-length octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `arap_features`, it returns `None`.
pub fn lookup_arap_features(packet: &Packet) -> Option<Vec<u8>> {
packet.lookup(ARAP_FEATURES_TYPE).map(|v| v.encode_bytes())
}
/// Lookup all of the `arap_features` fixed-length octets value from a packet.
pub fn lookup_all_arap_features(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ARAP_FEATURES_TYPE) {
@@ -114,17 +192,23 @@ pub fn lookup_all_arap_features(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const ARAP_ZONE_ACCESS_TYPE: AVPType = 72;
/// Delete all of `arap_zone_access` values from a packet.
pub fn delete_arap_zone_access(packet: &mut Packet) {
packet.delete(ARAP_ZONE_ACCESS_TYPE);
}
/// Add `arap_zone_access` value-defined integer value to a packet.
pub fn add_arap_zone_access(packet: &mut Packet, value: ArapZoneAccess) {
packet.add(AVP::from_u32(ARAP_ZONE_ACCESS_TYPE, value as u32));
}
/// Lookup a `arap_zone_access` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `arap_zone_access`, it returns `None`.
pub fn lookup_arap_zone_access(packet: &Packet) -> Option<Result<ArapZoneAccess, AVPError>> {
packet
.lookup(ARAP_ZONE_ACCESS_TYPE)
.map(|v| Ok(v.encode_u32()? as ArapZoneAccess))
}
/// Lookup all of the `arap_zone_access` value-defined integer value from a packet.
pub fn lookup_all_arap_zone_access(packet: &Packet) -> Result<Vec<ArapZoneAccess>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ARAP_ZONE_ACCESS_TYPE) {
@@ -134,15 +218,21 @@ pub fn lookup_all_arap_zone_access(packet: &Packet) -> Result<Vec<ArapZoneAccess
}
pub const ARAP_SECURITY_TYPE: AVPType = 73;
/// Delete all of `arap_security` values from a packet.
pub fn delete_arap_security(packet: &mut Packet) {
packet.delete(ARAP_SECURITY_TYPE);
}
/// Add `arap_security` integer value to a packet.
pub fn add_arap_security(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ARAP_SECURITY_TYPE, value));
}
/// Lookup a `arap_security` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `arap_security`, it returns `None`.
pub fn lookup_arap_security(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet.lookup(ARAP_SECURITY_TYPE).map(|v| v.encode_u32())
}
/// Lookup all of the `arap_security` integer value from a packet.
pub fn lookup_all_arap_security(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ARAP_SECURITY_TYPE) {
@@ -152,17 +242,23 @@ pub fn lookup_all_arap_security(packet: &Packet) -> Result<Vec<u32>, AVPError> {
}
pub const ARAP_SECURITY_DATA_TYPE: AVPType = 74;
/// Delete all of `arap_security_data` values from a packet.
pub fn delete_arap_security_data(packet: &mut Packet) {
packet.delete(ARAP_SECURITY_DATA_TYPE);
}
/// Add `arap_security_data` string value to a packet.
pub fn add_arap_security_data(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(ARAP_SECURITY_DATA_TYPE, value));
}
/// Lookup a `arap_security_data` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `arap_security_data`, it returns `None`.
pub fn lookup_arap_security_data(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(ARAP_SECURITY_DATA_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `arap_security_data` string value from a packet.
pub fn lookup_all_arap_security_data(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ARAP_SECURITY_DATA_TYPE) {
@@ -172,15 +268,21 @@ pub fn lookup_all_arap_security_data(packet: &Packet) -> Result<Vec<String>, AVP
}
pub const PASSWORD_RETRY_TYPE: AVPType = 75;
/// Delete all of `password_retry` values from a packet.
pub fn delete_password_retry(packet: &mut Packet) {
packet.delete(PASSWORD_RETRY_TYPE);
}
/// Add `password_retry` integer value to a packet.
pub fn add_password_retry(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(PASSWORD_RETRY_TYPE, value));
}
/// Lookup a `password_retry` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `password_retry`, it returns `None`.
pub fn lookup_password_retry(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet.lookup(PASSWORD_RETRY_TYPE).map(|v| v.encode_u32())
}
/// Lookup all of the `password_retry` integer value from a packet.
pub fn lookup_all_password_retry(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PASSWORD_RETRY_TYPE) {
@@ -190,17 +292,23 @@ pub fn lookup_all_password_retry(packet: &Packet) -> Result<Vec<u32>, AVPError>
}
pub const PROMPT_TYPE: AVPType = 76;
/// Delete all of `prompt` values from a packet.
pub fn delete_prompt(packet: &mut Packet) {
packet.delete(PROMPT_TYPE);
}
/// Add `prompt` value-defined integer value to a packet.
pub fn add_prompt(packet: &mut Packet, value: Prompt) {
packet.add(AVP::from_u32(PROMPT_TYPE, value as u32));
}
/// Lookup a `prompt` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `prompt`, it returns `None`.
pub fn lookup_prompt(packet: &Packet) -> Option<Result<Prompt, AVPError>> {
packet
.lookup(PROMPT_TYPE)
.map(|v| Ok(v.encode_u32()? as Prompt))
}
/// Lookup all of the `prompt` value-defined integer value from a packet.
pub fn lookup_all_prompt(packet: &Packet) -> Result<Vec<Prompt>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PROMPT_TYPE) {
@@ -210,15 +318,21 @@ pub fn lookup_all_prompt(packet: &Packet) -> Result<Vec<Prompt>, AVPError> {
}
pub const CONNECT_INFO_TYPE: AVPType = 77;
/// Delete all of `connect_info` values from a packet.
pub fn delete_connect_info(packet: &mut Packet) {
packet.delete(CONNECT_INFO_TYPE);
}
/// Add `connect_info` string value to a packet.
pub fn add_connect_info(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(CONNECT_INFO_TYPE, value));
}
/// Lookup a `connect_info` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `connect_info`, it returns `None`.
pub fn lookup_connect_info(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(CONNECT_INFO_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `connect_info` string value from a packet.
pub fn lookup_all_connect_info(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(CONNECT_INFO_TYPE) {
@@ -228,17 +342,23 @@ pub fn lookup_all_connect_info(packet: &Packet) -> Result<Vec<String>, AVPError>
}
pub const CONFIGURATION_TOKEN_TYPE: AVPType = 78;
/// Delete all of `configuration_token` values from a packet.
pub fn delete_configuration_token(packet: &mut Packet) {
packet.delete(CONFIGURATION_TOKEN_TYPE);
}
/// Add `configuration_token` string value to a packet.
pub fn add_configuration_token(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(CONFIGURATION_TOKEN_TYPE, value));
}
/// Lookup a `configuration_token` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `configuration_token`, it returns `None`.
pub fn lookup_configuration_token(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(CONFIGURATION_TOKEN_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `configuration_token` string value from a packet.
pub fn lookup_all_configuration_token(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(CONFIGURATION_TOKEN_TYPE) {
@@ -248,6 +368,7 @@ pub fn lookup_all_configuration_token(packet: &Packet) -> Result<Vec<String>, AV
}
pub const EAP_MESSAGE_TYPE: AVPType = 79;
/// Delete all of `eap_message` values from a packet.
pub fn delete_eap_message(packet: &mut Packet) {
packet.delete(EAP_MESSAGE_TYPE);
}
@@ -271,17 +392,23 @@ pub fn lookup_eap_message(packet: &Packet) -> Option<Vec<u8>> {
}
pub const MESSAGE_AUTHENTICATOR_TYPE: AVPType = 80;
/// Delete all of `message_authenticator` values from a packet.
pub fn delete_message_authenticator(packet: &mut Packet) {
packet.delete(MESSAGE_AUTHENTICATOR_TYPE);
}
/// Add `message_authenticator` octets value to a packet.
pub fn add_message_authenticator(packet: &mut Packet, value: &[u8]) {
packet.add(AVP::from_bytes(MESSAGE_AUTHENTICATOR_TYPE, value));
}
/// Lookup a `message_authenticator` octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `message_authenticator`, it returns `None`.
pub fn lookup_message_authenticator(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(MESSAGE_AUTHENTICATOR_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `message_authenticator` octets value from a packet.
pub fn lookup_all_message_authenticator(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(MESSAGE_AUTHENTICATOR_TYPE) {
@@ -291,9 +418,11 @@ pub fn lookup_all_message_authenticator(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const ARAP_CHALLENGE_RESPONSE_TYPE: AVPType = 84;
/// Delete all of `arap_challenge_response` values from a packet.
pub fn delete_arap_challenge_response(packet: &mut Packet) {
packet.delete(ARAP_CHALLENGE_RESPONSE_TYPE);
}
/// Add `arap_challenge_response` fixed-length octets value to a packet.
pub fn add_arap_challenge_response(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
if value.len() != 8 {
return Err(AVPError::InvalidAttributeLengthError(
@@ -304,11 +433,15 @@ pub fn add_arap_challenge_response(packet: &mut Packet, value: &[u8]) -> Result<
packet.add(AVP::from_bytes(ARAP_CHALLENGE_RESPONSE_TYPE, value));
Ok(())
}
/// Lookup a `arap_challenge_response` fixed-length octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `arap_challenge_response`, it returns `None`.
pub fn lookup_arap_challenge_response(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(ARAP_CHALLENGE_RESPONSE_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `arap_challenge_response` fixed-length octets value from a packet.
pub fn lookup_all_arap_challenge_response(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ARAP_CHALLENGE_RESPONSE_TYPE) {
@@ -318,17 +451,23 @@ pub fn lookup_all_arap_challenge_response(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const ACCT_INTERIM_INTERVAL_TYPE: AVPType = 85;
/// Delete all of `acct_interim_interval` values from a packet.
pub fn delete_acct_interim_interval(packet: &mut Packet) {
packet.delete(ACCT_INTERIM_INTERVAL_TYPE);
}
/// Add `acct_interim_interval` integer value to a packet.
pub fn add_acct_interim_interval(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(ACCT_INTERIM_INTERVAL_TYPE, value));
}
/// Lookup a `acct_interim_interval` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `acct_interim_interval`, it returns `None`.
pub fn lookup_acct_interim_interval(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet
.lookup(ACCT_INTERIM_INTERVAL_TYPE)
.map(|v| v.encode_u32())
}
/// Lookup all of the `acct_interim_interval` integer value from a packet.
pub fn lookup_all_acct_interim_interval(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ACCT_INTERIM_INTERVAL_TYPE) {
@@ -338,15 +477,21 @@ pub fn lookup_all_acct_interim_interval(packet: &Packet) -> Result<Vec<u32>, AVP
}
pub const NAS_PORT_ID_TYPE: AVPType = 87;
/// Delete all of `nas_port_id` values from a packet.
pub fn delete_nas_port_id(packet: &mut Packet) {
packet.delete(NAS_PORT_ID_TYPE);
}
/// Add `nas_port_id` string value to a packet.
pub fn add_nas_port_id(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(NAS_PORT_ID_TYPE, value));
}
/// Lookup a `nas_port_id` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `nas_port_id`, it returns `None`.
pub fn lookup_nas_port_id(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(NAS_PORT_ID_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `nas_port_id` string value from a packet.
pub fn lookup_all_nas_port_id(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(NAS_PORT_ID_TYPE) {
@@ -356,15 +501,21 @@ pub fn lookup_all_nas_port_id(packet: &Packet) -> Result<Vec<String>, AVPError>
}
pub const FRAMED_POOL_TYPE: AVPType = 88;
/// Delete all of `framed_pool` values from a packet.
pub fn delete_framed_pool(packet: &mut Packet) {
packet.delete(FRAMED_POOL_TYPE);
}
/// Add `framed_pool` string value to a packet.
pub fn add_framed_pool(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(FRAMED_POOL_TYPE, value));
}
/// Lookup a `framed_pool` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `framed_pool`, it returns `None`.
pub fn lookup_framed_pool(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(FRAMED_POOL_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `framed_pool` string value from a packet.
pub fn lookup_all_framed_pool(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(FRAMED_POOL_TYPE) {

View File

@@ -1,22 +1,50 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc3162 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 3162.
//! # http://www.ietf.org/rfc/rfc3162.txt
//! #
//! # $Id$
//! #
//! ATTRIBUTE NAS-IPV6-Address 95 ipv6addr
//! ATTRIBUTE Framed-Interface-Id 96 ifid
//! ATTRIBUTE Framed-IPV6-Prefix 97 ipv6prefix
//! ATTRIBUTE Login-IPV6-Host 98 ipv6addr
//! ATTRIBUTE Framed-IPV6-Route 99 string
//! ATTRIBUTE Framed-IPV6-Pool 100 string
//! ```
use std::net::Ipv6Addr;
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const NAS_IPV6_ADDRESS_TYPE: AVPType = 95;
/// Delete all of `nas_ipv6_address` values from a packet.
pub fn delete_nas_ipv6_address(packet: &mut Packet) {
packet.delete(NAS_IPV6_ADDRESS_TYPE);
}
/// Add `nas_ipv6_address` ipv6addr value to a packet.
pub fn add_nas_ipv6_address(packet: &mut Packet, value: &Ipv6Addr) {
packet.add(AVP::from_ipv6(NAS_IPV6_ADDRESS_TYPE, value));
}
/// Lookup a `nas_ipv6_address` ipv6addr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `nas_ipv6_address`, it returns `None`.
pub fn lookup_nas_ipv6_address(packet: &Packet) -> Option<Result<Ipv6Addr, AVPError>> {
packet
.lookup(NAS_IPV6_ADDRESS_TYPE)
.map(|v| v.encode_ipv6())
}
/// Lookup all of the `nas_ipv6_address` ipv6addr value from a packet.
pub fn lookup_all_nas_ipv6_address(packet: &Packet) -> Result<Vec<Ipv6Addr>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(NAS_IPV6_ADDRESS_TYPE) {
@@ -26,9 +54,11 @@ pub fn lookup_all_nas_ipv6_address(packet: &Packet) -> Result<Vec<Ipv6Addr>, AVP
}
pub const FRAMED_INTERFACE_ID_TYPE: AVPType = 96;
/// Delete all of `framed_interface_id` values from a packet.
pub fn delete_framed_interface_id(packet: &mut Packet) {
packet.delete(FRAMED_INTERFACE_ID_TYPE);
}
/// Add `framed_interface_id` fixed-length octets value to a packet.
pub fn add_framed_interface_id(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
if value.len() != 8 {
return Err(AVPError::InvalidAttributeLengthError(
@@ -39,11 +69,15 @@ pub fn add_framed_interface_id(packet: &mut Packet, value: &[u8]) -> Result<(),
packet.add(AVP::from_bytes(FRAMED_INTERFACE_ID_TYPE, value));
Ok(())
}
/// Lookup a `framed_interface_id` fixed-length octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `framed_interface_id`, it returns `None`.
pub fn lookup_framed_interface_id(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(FRAMED_INTERFACE_ID_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `framed_interface_id` fixed-length octets value from a packet.
pub fn lookup_all_framed_interface_id(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(FRAMED_INTERFACE_ID_TYPE) {
@@ -53,18 +87,24 @@ pub fn lookup_all_framed_interface_id(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const FRAMED_IPV6_PREFIX_TYPE: AVPType = 97;
/// Delete all of `framed_ipv6_prefix` values from a packet.
pub fn delete_framed_ipv6_prefix(packet: &mut Packet) {
packet.delete(FRAMED_IPV6_PREFIX_TYPE);
}
/// Add `framed_ipv6_prefix` ipv6 prefix value to a packet.
pub fn add_framed_ipv6_prefix(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
packet.add(AVP::from_ipv6_prefix(FRAMED_IPV6_PREFIX_TYPE, value)?);
Ok(())
}
/// Lookup a `framed_ipv6_prefix` ipv6 prefix value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `framed_ipv6_prefix`, it returns `None`.
pub fn lookup_framed_ipv6_prefix(packet: &Packet) -> Option<Result<Vec<u8>, AVPError>> {
packet
.lookup(FRAMED_IPV6_PREFIX_TYPE)
.map(|v| v.encode_ipv6_prefix())
}
/// Lookup all of the `framed_ipv6_prefix` ipv6 prefix value from a packet.
pub fn lookup_all_framed_ipv6_prefix(packet: &Packet) -> Result<Vec<Vec<u8>>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(FRAMED_IPV6_PREFIX_TYPE) {
@@ -74,15 +114,21 @@ pub fn lookup_all_framed_ipv6_prefix(packet: &Packet) -> Result<Vec<Vec<u8>>, AV
}
pub const LOGIN_IPV6_HOST_TYPE: AVPType = 98;
/// Delete all of `login_ipv6_host` values from a packet.
pub fn delete_login_ipv6_host(packet: &mut Packet) {
packet.delete(LOGIN_IPV6_HOST_TYPE);
}
/// Add `login_ipv6_host` ipv6addr value to a packet.
pub fn add_login_ipv6_host(packet: &mut Packet, value: &Ipv6Addr) {
packet.add(AVP::from_ipv6(LOGIN_IPV6_HOST_TYPE, value));
}
/// Lookup a `login_ipv6_host` ipv6addr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `login_ipv6_host`, it returns `None`.
pub fn lookup_login_ipv6_host(packet: &Packet) -> Option<Result<Ipv6Addr, AVPError>> {
packet.lookup(LOGIN_IPV6_HOST_TYPE).map(|v| v.encode_ipv6())
}
/// Lookup all of the `login_ipv6_host` ipv6addr value from a packet.
pub fn lookup_all_login_ipv6_host(packet: &Packet) -> Result<Vec<Ipv6Addr>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(LOGIN_IPV6_HOST_TYPE) {
@@ -92,17 +138,23 @@ pub fn lookup_all_login_ipv6_host(packet: &Packet) -> Result<Vec<Ipv6Addr>, AVPE
}
pub const FRAMED_IPV6_ROUTE_TYPE: AVPType = 99;
/// Delete all of `framed_ipv6_route` values from a packet.
pub fn delete_framed_ipv6_route(packet: &mut Packet) {
packet.delete(FRAMED_IPV6_ROUTE_TYPE);
}
/// Add `framed_ipv6_route` string value to a packet.
pub fn add_framed_ipv6_route(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(FRAMED_IPV6_ROUTE_TYPE, value));
}
/// Lookup a `framed_ipv6_route` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `framed_ipv6_route`, it returns `None`.
pub fn lookup_framed_ipv6_route(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(FRAMED_IPV6_ROUTE_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `framed_ipv6_route` string value from a packet.
pub fn lookup_all_framed_ipv6_route(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(FRAMED_IPV6_ROUTE_TYPE) {
@@ -112,17 +164,23 @@ pub fn lookup_all_framed_ipv6_route(packet: &Packet) -> Result<Vec<String>, AVPE
}
pub const FRAMED_IPV6_POOL_TYPE: AVPType = 100;
/// Delete all of `framed_ipv6_pool` values from a packet.
pub fn delete_framed_ipv6_pool(packet: &mut Packet) {
packet.delete(FRAMED_IPV6_POOL_TYPE);
}
/// Add `framed_ipv6_pool` string value to a packet.
pub fn add_framed_ipv6_pool(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(FRAMED_IPV6_POOL_TYPE, value));
}
/// Lookup a `framed_ipv6_pool` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `framed_ipv6_pool`, it returns `None`.
pub fn lookup_framed_ipv6_pool(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(FRAMED_IPV6_POOL_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `framed_ipv6_pool` string value from a packet.
pub fn lookup_all_framed_ipv6_pool(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(FRAMED_IPV6_POOL_TYPE) {

View File

@@ -1,22 +1,67 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc3576 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
use crate::core::rfc2865;
pub const ERROR_CAUSE_TYPE: AVPType = 101;
/// Delete all of `error_cause` values from a packet.
pub fn delete_error_cause(packet: &mut Packet) {
packet.delete(ERROR_CAUSE_TYPE);
}
/// Add `error_cause` value-defined integer value to a packet.
pub fn add_error_cause(packet: &mut Packet, value: ErrorCause) {
packet.add(AVP::from_u32(ERROR_CAUSE_TYPE, value as u32));
}
/// Lookup a `error_cause` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `error_cause`, it returns `None`.
pub fn lookup_error_cause(packet: &Packet) -> Option<Result<ErrorCause, AVPError>> {
packet
.lookup(ERROR_CAUSE_TYPE)
.map(|v| Ok(v.encode_u32()? as ErrorCause))
}
/// Lookup all of the `error_cause` value-defined integer value from a packet.
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) {

View File

@@ -1,5 +1,30 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc3580 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 3580.
//! # http://www.ietf.org/rfc/rfc3580.txt
//! #
//! # $Id$
//! #
//! VALUE Acct-Terminate-Cause Supplicant-Restart 19
//! VALUE Acct-Terminate-Cause Reauthentication-Failure 20
//! VALUE Acct-Terminate-Cause Port-Reinit 21
//! VALUE Acct-Terminate-Cause Port-Disabled 22
//!
//! VALUE NAS-Port-Type Token-Ring 20
//! VALUE NAS-Port-Type FDDI 21
//!
//! VALUE Tunnel-Type VLAN 13
//! ```
use crate::core::rfc2865;
use crate::core::rfc2866;

View File

@@ -1,18 +1,42 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc4072 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 4072
//! # http://www.ietf.org/rfc/rfc4072.txt
//! #
//! # $Id$
//! #
//!
//! ATTRIBUTE EAP-Key-Name 102 octets
//! ```
use crate::core::avp::{AVPType, AVP};
use crate::core::packet::Packet;
pub const EAP_KEY_NAME_TYPE: AVPType = 102;
/// Delete all of `eap_key_name` values from a packet.
pub fn delete_eap_key_name(packet: &mut Packet) {
packet.delete(EAP_KEY_NAME_TYPE);
}
/// Add `eap_key_name` octets value to a packet.
pub fn add_eap_key_name(packet: &mut Packet, value: &[u8]) {
packet.add(AVP::from_bytes(EAP_KEY_NAME_TYPE, value));
}
/// Lookup a `eap_key_name` octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `eap_key_name`, it returns `None`.
pub fn lookup_eap_key_name(packet: &Packet) -> Option<Vec<u8>> {
packet.lookup(EAP_KEY_NAME_TYPE).map(|v| v.encode_bytes())
}
/// Lookup all of the `eap_key_name` octets value from a packet.
pub fn lookup_all_eap_key_name(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(EAP_KEY_NAME_TYPE) {

View File

@@ -1,20 +1,43 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc4372 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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
//! ```
use crate::core::avp::{AVPType, AVP};
use crate::core::packet::Packet;
pub const CHARGEABLE_USER_IDENTITY_TYPE: AVPType = 89;
/// Delete all of `chargeable_user_identity` values from a packet.
pub fn delete_chargeable_user_identity(packet: &mut Packet) {
packet.delete(CHARGEABLE_USER_IDENTITY_TYPE);
}
/// Add `chargeable_user_identity` octets value to a packet.
pub fn add_chargeable_user_identity(packet: &mut Packet, value: &[u8]) {
packet.add(AVP::from_bytes(CHARGEABLE_USER_IDENTITY_TYPE, value));
}
/// Lookup a `chargeable_user_identity` octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `chargeable_user_identity`, it returns `None`.
pub fn lookup_chargeable_user_identity(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(CHARGEABLE_USER_IDENTITY_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `chargeable_user_identity` octets value from a packet.
pub fn lookup_all_chargeable_user_identity(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(CHARGEABLE_USER_IDENTITY_TYPE) {

View File

@@ -1,5 +1,30 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc4603 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 4603.
//! # http://www.ietf.org/rfc/rfc4603.txt
//! #
//! # $Id$
//! #
//! ##############################################################################
//!
//! VALUE NAS-Port-Type PPPoA 30
//! VALUE NAS-Port-Type PPPoEoA 31
//! VALUE NAS-Port-Type PPPoEoE 32
//! VALUE NAS-Port-Type PPPoEoVLAN 33
//! VALUE NAS-Port-Type PPPoEoQinQ 34
//!
//! ```
use crate::core::rfc2865;
pub const NAS_PORT_TYPE_PP_PO_A: rfc2865::NasPortType = 30;

View File

@@ -1,18 +1,61 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc4675 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 4675.
//! # http://www.ietf.org/rfc/rfc4675.txt
//! #
//! # $Id$
//! #
//!
//! #
//! # High byte = '1' (0x31) means the frames are tagged.
//! # High byte = '2' (0x32) means the frames are untagged.
//! #
//! # Next 12 bits MUST be zero.
//! #
//! # Lower 12 bits is the IEEE-802.1Q VLAN VID.
//! #
//! ATTRIBUTE Egress-VLANID 56 integer
//! ATTRIBUTE Ingress-Filters 57 integer
//!
//! #
//! # First byte == '1' (0x31) means that the frames are tagged.
//! # First byte == '2' (0x32) means that the frames are untagged.
//! #
//! ATTRIBUTE Egress-VLAN-Name 58 string
//! ATTRIBUTE User-Priority-Table 59 octets
//!
//! VALUE Ingress-Filters Enabled 1
//! VALUE Ingress-Filters Disabled 2
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const EGRESS_VLANID_TYPE: AVPType = 56;
/// Delete all of `egress_vlanid` values from a packet.
pub fn delete_egress_vlanid(packet: &mut Packet) {
packet.delete(EGRESS_VLANID_TYPE);
}
/// Add `egress_vlanid` integer value to a packet.
pub fn add_egress_vlanid(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(EGRESS_VLANID_TYPE, value));
}
/// Lookup a `egress_vlanid` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `egress_vlanid`, it returns `None`.
pub fn lookup_egress_vlanid(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet.lookup(EGRESS_VLANID_TYPE).map(|v| v.encode_u32())
}
/// Lookup all of the `egress_vlanid` integer value from a packet.
pub fn lookup_all_egress_vlanid(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(EGRESS_VLANID_TYPE) {
@@ -22,17 +65,23 @@ pub fn lookup_all_egress_vlanid(packet: &Packet) -> Result<Vec<u32>, AVPError> {
}
pub const INGRESS_FILTERS_TYPE: AVPType = 57;
/// Delete all of `ingress_filters` values from a packet.
pub fn delete_ingress_filters(packet: &mut Packet) {
packet.delete(INGRESS_FILTERS_TYPE);
}
/// Add `ingress_filters` value-defined integer value to a packet.
pub fn add_ingress_filters(packet: &mut Packet, value: IngressFilters) {
packet.add(AVP::from_u32(INGRESS_FILTERS_TYPE, value as u32));
}
/// Lookup a `ingress_filters` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `ingress_filters`, it returns `None`.
pub fn lookup_ingress_filters(packet: &Packet) -> Option<Result<IngressFilters, AVPError>> {
packet
.lookup(INGRESS_FILTERS_TYPE)
.map(|v| Ok(v.encode_u32()? as IngressFilters))
}
/// Lookup all of the `ingress_filters` value-defined integer value from a packet.
pub fn lookup_all_ingress_filters(packet: &Packet) -> Result<Vec<IngressFilters>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(INGRESS_FILTERS_TYPE) {
@@ -42,17 +91,23 @@ pub fn lookup_all_ingress_filters(packet: &Packet) -> Result<Vec<IngressFilters>
}
pub const EGRESS_VLAN_NAME_TYPE: AVPType = 58;
/// Delete all of `egress_vlan_name` values from a packet.
pub fn delete_egress_vlan_name(packet: &mut Packet) {
packet.delete(EGRESS_VLAN_NAME_TYPE);
}
/// Add `egress_vlan_name` string value to a packet.
pub fn add_egress_vlan_name(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(EGRESS_VLAN_NAME_TYPE, value));
}
/// Lookup a `egress_vlan_name` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `egress_vlan_name`, it returns `None`.
pub fn lookup_egress_vlan_name(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(EGRESS_VLAN_NAME_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `egress_vlan_name` string value from a packet.
pub fn lookup_all_egress_vlan_name(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(EGRESS_VLAN_NAME_TYPE) {
@@ -62,17 +117,23 @@ pub fn lookup_all_egress_vlan_name(packet: &Packet) -> Result<Vec<String>, AVPEr
}
pub const USER_PRIORITY_TABLE_TYPE: AVPType = 59;
/// Delete all of `user_priority_table` values from a packet.
pub fn delete_user_priority_table(packet: &mut Packet) {
packet.delete(USER_PRIORITY_TABLE_TYPE);
}
/// Add `user_priority_table` octets value to a packet.
pub fn add_user_priority_table(packet: &mut Packet, value: &[u8]) {
packet.add(AVP::from_bytes(USER_PRIORITY_TABLE_TYPE, value));
}
/// Lookup a `user_priority_table` octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `user_priority_table`, it returns `None`.
pub fn lookup_user_priority_table(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(USER_PRIORITY_TABLE_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `user_priority_table` octets value from a packet.
pub fn lookup_all_user_priority_table(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(USER_PRIORITY_TABLE_TYPE) {

View File

@@ -1,21 +1,47 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc4818 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 4818.
//! # http://www.ietf.org/rfc/rfc4818.txt
//! #
//! # $Id$
//! #
//! ##############################################################################
//!
//! ATTRIBUTE Delegated-IPV6-Prefix 123 ipv6prefix
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const DELEGATED_IPV6_PREFIX_TYPE: AVPType = 123;
/// Delete all of `delegated_ipv6_prefix` values from a packet.
pub fn delete_delegated_ipv6_prefix(packet: &mut Packet) {
packet.delete(DELEGATED_IPV6_PREFIX_TYPE);
}
/// Add `delegated_ipv6_prefix` ipv6 prefix value to a packet.
pub fn add_delegated_ipv6_prefix(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
packet.add(AVP::from_ipv6_prefix(DELEGATED_IPV6_PREFIX_TYPE, value)?);
Ok(())
}
/// Lookup a `delegated_ipv6_prefix` ipv6 prefix value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `delegated_ipv6_prefix`, it returns `None`.
pub fn lookup_delegated_ipv6_prefix(packet: &Packet) -> Option<Result<Vec<u8>, AVPError>> {
packet
.lookup(DELEGATED_IPV6_PREFIX_TYPE)
.map(|v| v.encode_ipv6_prefix())
}
/// Lookup all of the `delegated_ipv6_prefix` ipv6 prefix value from a packet.
pub fn lookup_all_delegated_ipv6_prefix(packet: &Packet) -> Result<Vec<Vec<u8>>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DELEGATED_IPV6_PREFIX_TYPE) {

View File

@@ -1,20 +1,43 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc4849 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 4849.
//! # http://www.ietf.org/rfc/rfc4849.txt
//! #
//! # $Id$
//! #
//! ATTRIBUTE NAS-Filter-Rule 92 string
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const NAS_FILTER_RULE_TYPE: AVPType = 92;
/// Delete all of `nas_filter_rule` values from a packet.
pub fn delete_nas_filter_rule(packet: &mut Packet) {
packet.delete(NAS_FILTER_RULE_TYPE);
}
/// Add `nas_filter_rule` string value to a packet.
pub fn add_nas_filter_rule(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(NAS_FILTER_RULE_TYPE, value));
}
/// Lookup a `nas_filter_rule` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `nas_filter_rule`, it returns `None`.
pub fn lookup_nas_filter_rule(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(NAS_FILTER_RULE_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `nas_filter_rule` string value from a packet.
pub fn lookup_all_nas_filter_rule(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(NAS_FILTER_RULE_TYPE) {

View File

@@ -1,20 +1,62 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc5090 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 5090.
//! # http://www.ietf.org/rfc/rfc5090.txt
//! #
//! # $Id$
//! #
//! ATTRIBUTE Digest-Response 103 string
//! ATTRIBUTE Digest-Realm 104 string
//! ATTRIBUTE Digest-Nonce 105 string
//! ATTRIBUTE Digest-Response-Auth 106 string
//! ATTRIBUTE Digest-Nextnonce 107 string
//! ATTRIBUTE Digest-Method 108 string
//! ATTRIBUTE Digest-URI 109 string
//! ATTRIBUTE Digest-Qop 110 string
//! ATTRIBUTE Digest-Algorithm 111 string
//! ATTRIBUTE Digest-Entity-Body-Hash 112 string
//! ATTRIBUTE Digest-CNonce 113 string
//! ATTRIBUTE Digest-Nonce-Count 114 string
//! ATTRIBUTE Digest-Username 115 string
//! ATTRIBUTE Digest-Opaque 116 string
//! ATTRIBUTE Digest-Auth-Param 117 string
//! ATTRIBUTE Digest-AKA-Auts 118 string
//! ATTRIBUTE Digest-Domain 119 string
//! ATTRIBUTE Digest-Stale 120 string
//! ATTRIBUTE Digest-HA1 121 string
//! ATTRIBUTE SIP-AOR 122 string
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const DIGEST_RESPONSE_TYPE: AVPType = 103;
/// Delete all of `digest_response` values from a packet.
pub fn delete_digest_response(packet: &mut Packet) {
packet.delete(DIGEST_RESPONSE_TYPE);
}
/// Add `digest_response` string value to a packet.
pub fn add_digest_response(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_RESPONSE_TYPE, value));
}
/// Lookup a `digest_response` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_response`, it returns `None`.
pub fn lookup_digest_response(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DIGEST_RESPONSE_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `digest_response` string value from a packet.
pub fn lookup_all_digest_response(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_RESPONSE_TYPE) {
@@ -24,15 +66,21 @@ pub fn lookup_all_digest_response(packet: &Packet) -> Result<Vec<String>, AVPErr
}
pub const DIGEST_REALM_TYPE: AVPType = 104;
/// Delete all of `digest_realm` values from a packet.
pub fn delete_digest_realm(packet: &mut Packet) {
packet.delete(DIGEST_REALM_TYPE);
}
/// Add `digest_realm` string value to a packet.
pub fn add_digest_realm(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_REALM_TYPE, value));
}
/// Lookup a `digest_realm` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_realm`, it returns `None`.
pub fn lookup_digest_realm(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(DIGEST_REALM_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `digest_realm` string value from a packet.
pub fn lookup_all_digest_realm(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_REALM_TYPE) {
@@ -42,15 +90,21 @@ pub fn lookup_all_digest_realm(packet: &Packet) -> Result<Vec<String>, AVPError>
}
pub const DIGEST_NONCE_TYPE: AVPType = 105;
/// Delete all of `digest_nonce` values from a packet.
pub fn delete_digest_nonce(packet: &mut Packet) {
packet.delete(DIGEST_NONCE_TYPE);
}
/// Add `digest_nonce` string value to a packet.
pub fn add_digest_nonce(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_NONCE_TYPE, value));
}
/// Lookup a `digest_nonce` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_nonce`, it returns `None`.
pub fn lookup_digest_nonce(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(DIGEST_NONCE_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `digest_nonce` string value from a packet.
pub fn lookup_all_digest_nonce(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_NONCE_TYPE) {
@@ -60,17 +114,23 @@ pub fn lookup_all_digest_nonce(packet: &Packet) -> Result<Vec<String>, AVPError>
}
pub const DIGEST_RESPONSE_AUTH_TYPE: AVPType = 106;
/// Delete all of `digest_response_auth` values from a packet.
pub fn delete_digest_response_auth(packet: &mut Packet) {
packet.delete(DIGEST_RESPONSE_AUTH_TYPE);
}
/// Add `digest_response_auth` string value to a packet.
pub fn add_digest_response_auth(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_RESPONSE_AUTH_TYPE, value));
}
/// Lookup a `digest_response_auth` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_response_auth`, it returns `None`.
pub fn lookup_digest_response_auth(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DIGEST_RESPONSE_AUTH_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `digest_response_auth` string value from a packet.
pub fn lookup_all_digest_response_auth(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_RESPONSE_AUTH_TYPE) {
@@ -80,17 +140,23 @@ pub fn lookup_all_digest_response_auth(packet: &Packet) -> Result<Vec<String>, A
}
pub const DIGEST_NEXTNONCE_TYPE: AVPType = 107;
/// Delete all of `digest_nextnonce` values from a packet.
pub fn delete_digest_nextnonce(packet: &mut Packet) {
packet.delete(DIGEST_NEXTNONCE_TYPE);
}
/// Add `digest_nextnonce` string value to a packet.
pub fn add_digest_nextnonce(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_NEXTNONCE_TYPE, value));
}
/// Lookup a `digest_nextnonce` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_nextnonce`, it returns `None`.
pub fn lookup_digest_nextnonce(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DIGEST_NEXTNONCE_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `digest_nextnonce` string value from a packet.
pub fn lookup_all_digest_nextnonce(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_NEXTNONCE_TYPE) {
@@ -100,15 +166,21 @@ pub fn lookup_all_digest_nextnonce(packet: &Packet) -> Result<Vec<String>, AVPEr
}
pub const DIGEST_METHOD_TYPE: AVPType = 108;
/// Delete all of `digest_method` values from a packet.
pub fn delete_digest_method(packet: &mut Packet) {
packet.delete(DIGEST_METHOD_TYPE);
}
/// Add `digest_method` string value to a packet.
pub fn add_digest_method(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_METHOD_TYPE, value));
}
/// Lookup a `digest_method` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_method`, it returns `None`.
pub fn lookup_digest_method(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(DIGEST_METHOD_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `digest_method` string value from a packet.
pub fn lookup_all_digest_method(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_METHOD_TYPE) {
@@ -118,15 +190,21 @@ pub fn lookup_all_digest_method(packet: &Packet) -> Result<Vec<String>, AVPError
}
pub const DIGEST_URI_TYPE: AVPType = 109;
/// Delete all of `digest_uri` values from a packet.
pub fn delete_digest_uri(packet: &mut Packet) {
packet.delete(DIGEST_URI_TYPE);
}
/// Add `digest_uri` string value to a packet.
pub fn add_digest_uri(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_URI_TYPE, value));
}
/// Lookup a `digest_uri` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_uri`, it returns `None`.
pub fn lookup_digest_uri(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(DIGEST_URI_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `digest_uri` string value from a packet.
pub fn lookup_all_digest_uri(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_URI_TYPE) {
@@ -136,15 +214,21 @@ pub fn lookup_all_digest_uri(packet: &Packet) -> Result<Vec<String>, AVPError> {
}
pub const DIGEST_QOP_TYPE: AVPType = 110;
/// Delete all of `digest_qop` values from a packet.
pub fn delete_digest_qop(packet: &mut Packet) {
packet.delete(DIGEST_QOP_TYPE);
}
/// Add `digest_qop` string value to a packet.
pub fn add_digest_qop(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_QOP_TYPE, value));
}
/// Lookup a `digest_qop` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_qop`, it returns `None`.
pub fn lookup_digest_qop(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(DIGEST_QOP_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `digest_qop` string value from a packet.
pub fn lookup_all_digest_qop(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_QOP_TYPE) {
@@ -154,17 +238,23 @@ pub fn lookup_all_digest_qop(packet: &Packet) -> Result<Vec<String>, AVPError> {
}
pub const DIGEST_ALGORITHM_TYPE: AVPType = 111;
/// Delete all of `digest_algorithm` values from a packet.
pub fn delete_digest_algorithm(packet: &mut Packet) {
packet.delete(DIGEST_ALGORITHM_TYPE);
}
/// Add `digest_algorithm` string value to a packet.
pub fn add_digest_algorithm(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_ALGORITHM_TYPE, value));
}
/// Lookup a `digest_algorithm` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_algorithm`, it returns `None`.
pub fn lookup_digest_algorithm(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DIGEST_ALGORITHM_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `digest_algorithm` string value from a packet.
pub fn lookup_all_digest_algorithm(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_ALGORITHM_TYPE) {
@@ -174,17 +264,23 @@ pub fn lookup_all_digest_algorithm(packet: &Packet) -> Result<Vec<String>, AVPEr
}
pub const DIGEST_ENTITY_BODY_HASH_TYPE: AVPType = 112;
/// Delete all of `digest_entity_body_hash` values from a packet.
pub fn delete_digest_entity_body_hash(packet: &mut Packet) {
packet.delete(DIGEST_ENTITY_BODY_HASH_TYPE);
}
/// Add `digest_entity_body_hash` string value to a packet.
pub fn add_digest_entity_body_hash(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_ENTITY_BODY_HASH_TYPE, value));
}
/// Lookup a `digest_entity_body_hash` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_entity_body_hash`, it returns `None`.
pub fn lookup_digest_entity_body_hash(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DIGEST_ENTITY_BODY_HASH_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `digest_entity_body_hash` string value from a packet.
pub fn lookup_all_digest_entity_body_hash(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_ENTITY_BODY_HASH_TYPE) {
@@ -194,17 +290,23 @@ pub fn lookup_all_digest_entity_body_hash(packet: &Packet) -> Result<Vec<String>
}
pub const DIGEST_C_NONCE_TYPE: AVPType = 113;
/// Delete all of `digest_c_nonce` values from a packet.
pub fn delete_digest_c_nonce(packet: &mut Packet) {
packet.delete(DIGEST_C_NONCE_TYPE);
}
/// Add `digest_c_nonce` string value to a packet.
pub fn add_digest_c_nonce(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_C_NONCE_TYPE, value));
}
/// Lookup a `digest_c_nonce` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_c_nonce`, it returns `None`.
pub fn lookup_digest_c_nonce(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DIGEST_C_NONCE_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `digest_c_nonce` string value from a packet.
pub fn lookup_all_digest_c_nonce(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_C_NONCE_TYPE) {
@@ -214,17 +316,23 @@ pub fn lookup_all_digest_c_nonce(packet: &Packet) -> Result<Vec<String>, AVPErro
}
pub const DIGEST_NONCE_COUNT_TYPE: AVPType = 114;
/// Delete all of `digest_nonce_count` values from a packet.
pub fn delete_digest_nonce_count(packet: &mut Packet) {
packet.delete(DIGEST_NONCE_COUNT_TYPE);
}
/// Add `digest_nonce_count` string value to a packet.
pub fn add_digest_nonce_count(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_NONCE_COUNT_TYPE, value));
}
/// Lookup a `digest_nonce_count` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_nonce_count`, it returns `None`.
pub fn lookup_digest_nonce_count(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DIGEST_NONCE_COUNT_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `digest_nonce_count` string value from a packet.
pub fn lookup_all_digest_nonce_count(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_NONCE_COUNT_TYPE) {
@@ -234,17 +342,23 @@ pub fn lookup_all_digest_nonce_count(packet: &Packet) -> Result<Vec<String>, AVP
}
pub const DIGEST_USERNAME_TYPE: AVPType = 115;
/// Delete all of `digest_username` values from a packet.
pub fn delete_digest_username(packet: &mut Packet) {
packet.delete(DIGEST_USERNAME_TYPE);
}
/// Add `digest_username` string value to a packet.
pub fn add_digest_username(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_USERNAME_TYPE, value));
}
/// Lookup a `digest_username` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_username`, it returns `None`.
pub fn lookup_digest_username(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DIGEST_USERNAME_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `digest_username` string value from a packet.
pub fn lookup_all_digest_username(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_USERNAME_TYPE) {
@@ -254,15 +368,21 @@ pub fn lookup_all_digest_username(packet: &Packet) -> Result<Vec<String>, AVPErr
}
pub const DIGEST_OPAQUE_TYPE: AVPType = 116;
/// Delete all of `digest_opaque` values from a packet.
pub fn delete_digest_opaque(packet: &mut Packet) {
packet.delete(DIGEST_OPAQUE_TYPE);
}
/// Add `digest_opaque` string value to a packet.
pub fn add_digest_opaque(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_OPAQUE_TYPE, value));
}
/// Lookup a `digest_opaque` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_opaque`, it returns `None`.
pub fn lookup_digest_opaque(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(DIGEST_OPAQUE_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `digest_opaque` string value from a packet.
pub fn lookup_all_digest_opaque(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_OPAQUE_TYPE) {
@@ -272,17 +392,23 @@ pub fn lookup_all_digest_opaque(packet: &Packet) -> Result<Vec<String>, AVPError
}
pub const DIGEST_AUTH_PARAM_TYPE: AVPType = 117;
/// Delete all of `digest_auth_param` values from a packet.
pub fn delete_digest_auth_param(packet: &mut Packet) {
packet.delete(DIGEST_AUTH_PARAM_TYPE);
}
/// Add `digest_auth_param` string value to a packet.
pub fn add_digest_auth_param(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_AUTH_PARAM_TYPE, value));
}
/// Lookup a `digest_auth_param` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_auth_param`, it returns `None`.
pub fn lookup_digest_auth_param(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DIGEST_AUTH_PARAM_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `digest_auth_param` string value from a packet.
pub fn lookup_all_digest_auth_param(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_AUTH_PARAM_TYPE) {
@@ -292,17 +418,23 @@ pub fn lookup_all_digest_auth_param(packet: &Packet) -> Result<Vec<String>, AVPE
}
pub const DIGEST_AKA_AUTS_TYPE: AVPType = 118;
/// Delete all of `digest_aka_auts` values from a packet.
pub fn delete_digest_aka_auts(packet: &mut Packet) {
packet.delete(DIGEST_AKA_AUTS_TYPE);
}
/// Add `digest_aka_auts` string value to a packet.
pub fn add_digest_aka_auts(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_AKA_AUTS_TYPE, value));
}
/// Lookup a `digest_aka_auts` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_aka_auts`, it returns `None`.
pub fn lookup_digest_aka_auts(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DIGEST_AKA_AUTS_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `digest_aka_auts` string value from a packet.
pub fn lookup_all_digest_aka_auts(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_AKA_AUTS_TYPE) {
@@ -312,15 +444,21 @@ pub fn lookup_all_digest_aka_auts(packet: &Packet) -> Result<Vec<String>, AVPErr
}
pub const DIGEST_DOMAIN_TYPE: AVPType = 119;
/// Delete all of `digest_domain` values from a packet.
pub fn delete_digest_domain(packet: &mut Packet) {
packet.delete(DIGEST_DOMAIN_TYPE);
}
/// Add `digest_domain` string value to a packet.
pub fn add_digest_domain(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_DOMAIN_TYPE, value));
}
/// Lookup a `digest_domain` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_domain`, it returns `None`.
pub fn lookup_digest_domain(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(DIGEST_DOMAIN_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `digest_domain` string value from a packet.
pub fn lookup_all_digest_domain(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_DOMAIN_TYPE) {
@@ -330,15 +468,21 @@ pub fn lookup_all_digest_domain(packet: &Packet) -> Result<Vec<String>, AVPError
}
pub const DIGEST_STALE_TYPE: AVPType = 120;
/// Delete all of `digest_stale` values from a packet.
pub fn delete_digest_stale(packet: &mut Packet) {
packet.delete(DIGEST_STALE_TYPE);
}
/// Add `digest_stale` string value to a packet.
pub fn add_digest_stale(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_STALE_TYPE, value));
}
/// Lookup a `digest_stale` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_stale`, it returns `None`.
pub fn lookup_digest_stale(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(DIGEST_STALE_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `digest_stale` string value from a packet.
pub fn lookup_all_digest_stale(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_STALE_TYPE) {
@@ -348,15 +492,21 @@ pub fn lookup_all_digest_stale(packet: &Packet) -> Result<Vec<String>, AVPError>
}
pub const DIGEST_HA1_TYPE: AVPType = 121;
/// Delete all of `digest_ha1` values from a packet.
pub fn delete_digest_ha1(packet: &mut Packet) {
packet.delete(DIGEST_HA1_TYPE);
}
/// Add `digest_ha1` string value to a packet.
pub fn add_digest_ha1(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DIGEST_HA1_TYPE, value));
}
/// Lookup a `digest_ha1` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `digest_ha1`, it returns `None`.
pub fn lookup_digest_ha1(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(DIGEST_HA1_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `digest_ha1` string value from a packet.
pub fn lookup_all_digest_ha1(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DIGEST_HA1_TYPE) {
@@ -366,15 +516,21 @@ pub fn lookup_all_digest_ha1(packet: &Packet) -> Result<Vec<String>, AVPError> {
}
pub const SIP_AOR_TYPE: AVPType = 122;
/// Delete all of `sip_aor` values from a packet.
pub fn delete_sip_aor(packet: &mut Packet) {
packet.delete(SIP_AOR_TYPE);
}
/// Add `sip_aor` string value to a packet.
pub fn add_sip_aor(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(SIP_AOR_TYPE, value));
}
/// Lookup a `sip_aor` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `sip_aor`, it returns `None`.
pub fn lookup_sip_aor(packet: &Packet) -> Option<Result<String, AVPError>> {
packet.lookup(SIP_AOR_TYPE).map(|v| v.encode_string())
}
/// Lookup all of the `sip_aor` string value from a packet.
pub fn lookup_all_sip_aor(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(SIP_AOR_TYPE) {

View File

@@ -1,5 +1,23 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc5176 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 5176.
//! # http://www.ietf.org/rfc/rfc5176.txt
//! #
//! # $Id$
//! #
//! VALUE Error-Cause Invalid-Attribute-Value 407
//! VALUE Error-Cause Multiple-Session-Selection-Unsupported 508
//! ```
use crate::core::rfc3576;
pub const ERROR_CAUSE_INVALID_ATTRIBUTE_VALUE: rfc3576::ErrorCause = 407;

View File

@@ -1,22 +1,67 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc5607 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 5607.
//! # http://www.ietf.org/rfc/rfc5607.txt
//! #
//! # $Id$
//! #
//!
//! VALUE Service-Type Framed-Management 18
//!
//! ATTRIBUTE Framed-Management 133 integer
//!
//! VALUE Framed-Management SNMP 1
//! VALUE Framed-Management Web-Based 2
//! VALUE Framed-Management Netconf 3
//! VALUE Framed-Management FTP 4
//! VALUE Framed-Management TFTP 5
//! VALUE Framed-Management SFTP 6
//! VALUE Framed-Management RCP 7
//! VALUE Framed-Management SCP 8
//!
//! ATTRIBUTE Management-Transport-Protection 134 integer
//!
//! VALUE Management-Transport-Protection No-Protection 1
//! VALUE Management-Transport-Protection Integrity-Protection 2
//! VALUE Management-Transport-Protection Integrity-Confidentiality-Protection 3
//!
//! ATTRIBUTE Management-Policy-Id 135 string
//!
//! ATTRIBUTE Management-Privilege-Level 136 integer
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
use crate::core::rfc2865;
pub const FRAMED_MANAGEMENT_TYPE: AVPType = 133;
/// Delete all of `framed_management` values from a packet.
pub fn delete_framed_management(packet: &mut Packet) {
packet.delete(FRAMED_MANAGEMENT_TYPE);
}
/// Add `framed_management` value-defined integer value to a packet.
pub fn add_framed_management(packet: &mut Packet, value: FramedManagement) {
packet.add(AVP::from_u32(FRAMED_MANAGEMENT_TYPE, value as u32));
}
/// Lookup a `framed_management` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `framed_management`, it returns `None`.
pub fn lookup_framed_management(packet: &Packet) -> Option<Result<FramedManagement, AVPError>> {
packet
.lookup(FRAMED_MANAGEMENT_TYPE)
.map(|v| Ok(v.encode_u32()? as FramedManagement))
}
/// Lookup all of the `framed_management` value-defined integer value from a packet.
pub fn lookup_all_framed_management(packet: &Packet) -> Result<Vec<FramedManagement>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(FRAMED_MANAGEMENT_TYPE) {
@@ -26,9 +71,11 @@ pub fn lookup_all_framed_management(packet: &Packet) -> Result<Vec<FramedManagem
}
pub const MANAGEMENT_TRANSPORT_PROTECTION_TYPE: AVPType = 134;
/// Delete all of `management_transport_protection` values from a packet.
pub fn delete_management_transport_protection(packet: &mut Packet) {
packet.delete(MANAGEMENT_TRANSPORT_PROTECTION_TYPE);
}
/// Add `management_transport_protection` value-defined integer value to a packet.
pub fn add_management_transport_protection(
packet: &mut Packet,
value: ManagementTransportProtection,
@@ -38,6 +85,9 @@ pub fn add_management_transport_protection(
value as u32,
));
}
/// Lookup a `management_transport_protection` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `management_transport_protection`, it returns `None`.
pub fn lookup_management_transport_protection(
packet: &Packet,
) -> Option<Result<ManagementTransportProtection, AVPError>> {
@@ -45,6 +95,7 @@ pub fn lookup_management_transport_protection(
.lookup(MANAGEMENT_TRANSPORT_PROTECTION_TYPE)
.map(|v| Ok(v.encode_u32()? as ManagementTransportProtection))
}
/// Lookup all of the `management_transport_protection` value-defined integer value from a packet.
pub fn lookup_all_management_transport_protection(
packet: &Packet,
) -> Result<Vec<ManagementTransportProtection>, AVPError> {
@@ -56,17 +107,23 @@ pub fn lookup_all_management_transport_protection(
}
pub const MANAGEMENT_POLICY_ID_TYPE: AVPType = 135;
/// Delete all of `management_policy_id` values from a packet.
pub fn delete_management_policy_id(packet: &mut Packet) {
packet.delete(MANAGEMENT_POLICY_ID_TYPE);
}
/// Add `management_policy_id` string value to a packet.
pub fn add_management_policy_id(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(MANAGEMENT_POLICY_ID_TYPE, value));
}
/// Lookup a `management_policy_id` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `management_policy_id`, it returns `None`.
pub fn lookup_management_policy_id(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(MANAGEMENT_POLICY_ID_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `management_policy_id` string value from a packet.
pub fn lookup_all_management_policy_id(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(MANAGEMENT_POLICY_ID_TYPE) {
@@ -76,17 +133,23 @@ pub fn lookup_all_management_policy_id(packet: &Packet) -> Result<Vec<String>, A
}
pub const MANAGEMENT_PRIVILEGE_LEVEL_TYPE: AVPType = 136;
/// Delete all of `management_privilege_level` values from a packet.
pub fn delete_management_privilege_level(packet: &mut Packet) {
packet.delete(MANAGEMENT_PRIVILEGE_LEVEL_TYPE);
}
/// Add `management_privilege_level` integer value to a packet.
pub fn add_management_privilege_level(packet: &mut Packet, value: u32) {
packet.add(AVP::from_u32(MANAGEMENT_PRIVILEGE_LEVEL_TYPE, value));
}
/// Lookup a `management_privilege_level` integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `management_privilege_level`, it returns `None`.
pub fn lookup_management_privilege_level(packet: &Packet) -> Option<Result<u32, AVPError>> {
packet
.lookup(MANAGEMENT_PRIVILEGE_LEVEL_TYPE)
.map(|v| v.encode_u32())
}
/// Lookup all of the `management_privilege_level` integer value from a packet.
pub fn lookup_all_management_privilege_level(packet: &Packet) -> Result<Vec<u32>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(MANAGEMENT_PRIVILEGE_LEVEL_TYPE) {

View File

@@ -1,9 +1,41 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc5904 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 5904.
//! # http://www.ietf.org/rfc/rfc5904.txt
//! #
//! # $Id$
//! #
//!
//! # The next two attributes are continued, like EAP-Message
//! ATTRIBUTE PKM-SS-Cert 137 octets concat
//! ATTRIBUTE PKM-CA-Cert 138 octets concat
//!
//! # 28 bytes of data, 7 integers
//! ATTRIBUTE PKM-Config-Settings 139 octets
//! ATTRIBUTE PKM-Cryptosuite-List 140 octets
//! ATTRIBUTE PKM-SAID 141 short
//!
//! # 6 bytes of data: SAID, 1 byte of type, 3 of cryptosuite
//! ATTRIBUTE PKM-SA-Descriptor 142 octets
//!
//! # 133 bytes of data: integer lifetime, 1 byte sequence, 128 bytes of key
//! ATTRIBUTE PKM-Auth-Key 143 octets
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const PKM_SS_CERT_TYPE: AVPType = 137;
/// Delete all of `pkm_ss_cert` values from a packet.
pub fn delete_pkm_ss_cert(packet: &mut Packet) {
packet.delete(PKM_SS_CERT_TYPE);
}
@@ -27,6 +59,7 @@ pub fn lookup_pkm_ss_cert(packet: &Packet) -> Option<Vec<u8>> {
}
pub const PKM_CA_CERT_TYPE: AVPType = 138;
/// Delete all of `pkm_ca_cert` values from a packet.
pub fn delete_pkm_ca_cert(packet: &mut Packet) {
packet.delete(PKM_CA_CERT_TYPE);
}
@@ -50,17 +83,23 @@ pub fn lookup_pkm_ca_cert(packet: &Packet) -> Option<Vec<u8>> {
}
pub const PKM_CONFIG_SETTINGS_TYPE: AVPType = 139;
/// Delete all of `pkm_config_settings` values from a packet.
pub fn delete_pkm_config_settings(packet: &mut Packet) {
packet.delete(PKM_CONFIG_SETTINGS_TYPE);
}
/// Add `pkm_config_settings` octets value to a packet.
pub fn add_pkm_config_settings(packet: &mut Packet, value: &[u8]) {
packet.add(AVP::from_bytes(PKM_CONFIG_SETTINGS_TYPE, value));
}
/// Lookup a `pkm_config_settings` octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pkm_config_settings`, it returns `None`.
pub fn lookup_pkm_config_settings(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(PKM_CONFIG_SETTINGS_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `pkm_config_settings` octets value from a packet.
pub fn lookup_all_pkm_config_settings(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PKM_CONFIG_SETTINGS_TYPE) {
@@ -70,17 +109,23 @@ pub fn lookup_all_pkm_config_settings(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const PKM_CRYPTOSUITE_LIST_TYPE: AVPType = 140;
/// Delete all of `pkm_cryptosuite_list` values from a packet.
pub fn delete_pkm_cryptosuite_list(packet: &mut Packet) {
packet.delete(PKM_CRYPTOSUITE_LIST_TYPE);
}
/// Add `pkm_cryptosuite_list` octets value to a packet.
pub fn add_pkm_cryptosuite_list(packet: &mut Packet, value: &[u8]) {
packet.add(AVP::from_bytes(PKM_CRYPTOSUITE_LIST_TYPE, value));
}
/// Lookup a `pkm_cryptosuite_list` octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pkm_cryptosuite_list`, it returns `None`.
pub fn lookup_pkm_cryptosuite_list(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(PKM_CRYPTOSUITE_LIST_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `pkm_cryptosuite_list` octets value from a packet.
pub fn lookup_all_pkm_cryptosuite_list(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PKM_CRYPTOSUITE_LIST_TYPE) {
@@ -90,15 +135,21 @@ pub fn lookup_all_pkm_cryptosuite_list(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const PKM_SAID_TYPE: AVPType = 141;
/// Delete all of `pkm_said` values from a packet.
pub fn delete_pkm_said(packet: &mut Packet) {
packet.delete(PKM_SAID_TYPE);
}
/// Add `pkm_said` short integer value to a packet.
pub fn add_pkm_said(packet: &mut Packet, value: u16) {
packet.add(AVP::from_u16(PKM_SAID_TYPE, value));
}
/// Lookup a `pkm_said` short integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pkm_said`, it returns `None`.
pub fn lookup_pkm_said(packet: &Packet) -> Option<Result<u16, AVPError>> {
packet.lookup(PKM_SAID_TYPE).map(|v| v.encode_u16())
}
/// Lookup all of the `pkm_said` short integer value from a packet.
pub fn lookup_all_pkm_said(packet: &Packet) -> Result<Vec<u16>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PKM_SAID_TYPE) {
@@ -108,17 +159,23 @@ pub fn lookup_all_pkm_said(packet: &Packet) -> Result<Vec<u16>, AVPError> {
}
pub const PKM_SA_DESCRIPTOR_TYPE: AVPType = 142;
/// Delete all of `pkm_sa_descriptor` values from a packet.
pub fn delete_pkm_sa_descriptor(packet: &mut Packet) {
packet.delete(PKM_SA_DESCRIPTOR_TYPE);
}
/// Add `pkm_sa_descriptor` octets value to a packet.
pub fn add_pkm_sa_descriptor(packet: &mut Packet, value: &[u8]) {
packet.add(AVP::from_bytes(PKM_SA_DESCRIPTOR_TYPE, value));
}
/// Lookup a `pkm_sa_descriptor` octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pkm_sa_descriptor`, it returns `None`.
pub fn lookup_pkm_sa_descriptor(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(PKM_SA_DESCRIPTOR_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `pkm_sa_descriptor` octets value from a packet.
pub fn lookup_all_pkm_sa_descriptor(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PKM_SA_DESCRIPTOR_TYPE) {
@@ -128,15 +185,21 @@ pub fn lookup_all_pkm_sa_descriptor(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const PKM_AUTH_KEY_TYPE: AVPType = 143;
/// Delete all of `pkm_auth_key` values from a packet.
pub fn delete_pkm_auth_key(packet: &mut Packet) {
packet.delete(PKM_AUTH_KEY_TYPE);
}
/// Add `pkm_auth_key` octets value to a packet.
pub fn add_pkm_auth_key(packet: &mut Packet, value: &[u8]) {
packet.add(AVP::from_bytes(PKM_AUTH_KEY_TYPE, value));
}
/// Lookup a `pkm_auth_key` octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pkm_auth_key`, it returns `None`.
pub fn lookup_pkm_auth_key(packet: &Packet) -> Option<Vec<u8>> {
packet.lookup(PKM_AUTH_KEY_TYPE).map(|v| v.encode_bytes())
}
/// Lookup all of the `pkm_auth_key` octets value from a packet.
pub fn lookup_all_pkm_auth_key(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PKM_AUTH_KEY_TYPE) {

View File

@@ -1,20 +1,44 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc6519 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 6519.
//! # http://www.ietf.org/rfc/rfc6519.txt
//! #
//! # $Id$
//! #
//!
//! ATTRIBUTE DS-Lite-Tunnel-Name 144 string
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const DS_LITE_TUNNEL_NAME_TYPE: AVPType = 144;
/// Delete all of `ds_lite_tunnel_name` values from a packet.
pub fn delete_ds_lite_tunnel_name(packet: &mut Packet) {
packet.delete(DS_LITE_TUNNEL_NAME_TYPE);
}
/// Add `ds_lite_tunnel_name` string value to a packet.
pub fn add_ds_lite_tunnel_name(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DS_LITE_TUNNEL_NAME_TYPE, value));
}
/// Lookup a `ds_lite_tunnel_name` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `ds_lite_tunnel_name`, it returns `None`.
pub fn lookup_ds_lite_tunnel_name(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DS_LITE_TUNNEL_NAME_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `ds_lite_tunnel_name` string value from a packet.
pub fn lookup_all_ds_lite_tunnel_name(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DS_LITE_TUNNEL_NAME_TYPE) {

View File

@@ -1,22 +1,63 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc6572 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 6572.
//! # http://www.ietf.org/rfc/rfc6572.txt
//! #
//! # $Id$
//! #
//!
//! ATTRIBUTE Mobile-Node-Identifier 145 octets
//! ATTRIBUTE Service-Selection 146 string
//! ATTRIBUTE PMIP6-Home-LMA-IPV6-Address 147 ipv6addr
//! ATTRIBUTE PMIP6-Visited-LMA-IPV6-Address 148 ipv6addr
//! ATTRIBUTE PMIP6-Home-LMA-IPV4-Address 149 ipaddr
//! ATTRIBUTE PMIP6-Visited-LMA-IPV4-Address 150 ipaddr
//! ATTRIBUTE PMIP6-Home-HN-Prefix 151 ipv6prefix
//! ATTRIBUTE PMIP6-Visited-HN-Prefix 152 ipv6prefix
//! ATTRIBUTE PMIP6-Home-Interface-ID 153 ifid
//! ATTRIBUTE PMIP6-Visited-Interface-ID 154 ifid
//! ATTRIBUTE PMIP6-Home-IPV4-HoA 155 ipv4prefix
//! ATTRIBUTE PMIP6-Visited-IPV4-HoA 156 ipv4prefix
//! ATTRIBUTE PMIP6-Home-DHCP4-Server-Address 157 ipaddr
//! ATTRIBUTE PMIP6-Visited-DHCP4-Server-Address 158 ipaddr
//! ATTRIBUTE PMIP6-Home-DHCP6-Server-Address 159 ipv6addr
//! ATTRIBUTE PMIP6-Visited-DHCP6-Server-Address 160 ipv6addr
//! ATTRIBUTE PMIP6-Home-IPV4-Gateway 161 ipaddr
//! ATTRIBUTE PMIP6-Visited-IPV4-Gateway 162 ipaddr
//! ```
use std::net::{Ipv4Addr, Ipv6Addr};
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const MOBILE_NODE_IDENTIFIER_TYPE: AVPType = 145;
/// Delete all of `mobile_node_identifier` values from a packet.
pub fn delete_mobile_node_identifier(packet: &mut Packet) {
packet.delete(MOBILE_NODE_IDENTIFIER_TYPE);
}
/// Add `mobile_node_identifier` octets value to a packet.
pub fn add_mobile_node_identifier(packet: &mut Packet, value: &[u8]) {
packet.add(AVP::from_bytes(MOBILE_NODE_IDENTIFIER_TYPE, value));
}
/// Lookup a `mobile_node_identifier` octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `mobile_node_identifier`, it returns `None`.
pub fn lookup_mobile_node_identifier(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(MOBILE_NODE_IDENTIFIER_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `mobile_node_identifier` octets value from a packet.
pub fn lookup_all_mobile_node_identifier(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(MOBILE_NODE_IDENTIFIER_TYPE) {
@@ -26,17 +67,23 @@ pub fn lookup_all_mobile_node_identifier(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const SERVICE_SELECTION_TYPE: AVPType = 146;
/// Delete all of `service_selection` values from a packet.
pub fn delete_service_selection(packet: &mut Packet) {
packet.delete(SERVICE_SELECTION_TYPE);
}
/// Add `service_selection` string value to a packet.
pub fn add_service_selection(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(SERVICE_SELECTION_TYPE, value));
}
/// Lookup a `service_selection` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `service_selection`, it returns `None`.
pub fn lookup_service_selection(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(SERVICE_SELECTION_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `service_selection` string value from a packet.
pub fn lookup_all_service_selection(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(SERVICE_SELECTION_TYPE) {
@@ -46,17 +93,23 @@ pub fn lookup_all_service_selection(packet: &Packet) -> Result<Vec<String>, AVPE
}
pub const PMIP6_HOME_LMA_IPV6_ADDRESS_TYPE: AVPType = 147;
/// Delete all of `pmip6_home_lma_ipv6_address` values from a packet.
pub fn delete_pmip6_home_lma_ipv6_address(packet: &mut Packet) {
packet.delete(PMIP6_HOME_LMA_IPV6_ADDRESS_TYPE);
}
/// Add `pmip6_home_lma_ipv6_address` ipv6addr value to a packet.
pub fn add_pmip6_home_lma_ipv6_address(packet: &mut Packet, value: &Ipv6Addr) {
packet.add(AVP::from_ipv6(PMIP6_HOME_LMA_IPV6_ADDRESS_TYPE, value));
}
/// Lookup a `pmip6_home_lma_ipv6_address` ipv6addr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_home_lma_ipv6_address`, it returns `None`.
pub fn lookup_pmip6_home_lma_ipv6_address(packet: &Packet) -> Option<Result<Ipv6Addr, AVPError>> {
packet
.lookup(PMIP6_HOME_LMA_IPV6_ADDRESS_TYPE)
.map(|v| v.encode_ipv6())
}
/// Lookup all of the `pmip6_home_lma_ipv6_address` ipv6addr value from a packet.
pub fn lookup_all_pmip6_home_lma_ipv6_address(packet: &Packet) -> Result<Vec<Ipv6Addr>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PMIP6_HOME_LMA_IPV6_ADDRESS_TYPE) {
@@ -66,12 +119,17 @@ pub fn lookup_all_pmip6_home_lma_ipv6_address(packet: &Packet) -> Result<Vec<Ipv
}
pub const PMIP6_VISITED_LMA_IPV6_ADDRESS_TYPE: AVPType = 148;
/// Delete all of `pmip6_visited_lma_ipv6_address` values from a packet.
pub fn delete_pmip6_visited_lma_ipv6_address(packet: &mut Packet) {
packet.delete(PMIP6_VISITED_LMA_IPV6_ADDRESS_TYPE);
}
/// Add `pmip6_visited_lma_ipv6_address` ipv6addr value to a packet.
pub fn add_pmip6_visited_lma_ipv6_address(packet: &mut Packet, value: &Ipv6Addr) {
packet.add(AVP::from_ipv6(PMIP6_VISITED_LMA_IPV6_ADDRESS_TYPE, value));
}
/// Lookup a `pmip6_visited_lma_ipv6_address` ipv6addr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_visited_lma_ipv6_address`, it returns `None`.
pub fn lookup_pmip6_visited_lma_ipv6_address(
packet: &Packet,
) -> Option<Result<Ipv6Addr, AVPError>> {
@@ -79,6 +137,7 @@ pub fn lookup_pmip6_visited_lma_ipv6_address(
.lookup(PMIP6_VISITED_LMA_IPV6_ADDRESS_TYPE)
.map(|v| v.encode_ipv6())
}
/// Lookup all of the `pmip6_visited_lma_ipv6_address` ipv6addr value from a packet.
pub fn lookup_all_pmip6_visited_lma_ipv6_address(
packet: &Packet,
) -> Result<Vec<Ipv6Addr>, AVPError> {
@@ -90,17 +149,23 @@ pub fn lookup_all_pmip6_visited_lma_ipv6_address(
}
pub const PMIP6_HOME_LMA_IPV4_ADDRESS_TYPE: AVPType = 149;
/// Delete all of `pmip6_home_lma_ipv4_address` values from a packet.
pub fn delete_pmip6_home_lma_ipv4_address(packet: &mut Packet) {
packet.delete(PMIP6_HOME_LMA_IPV4_ADDRESS_TYPE);
}
/// Add `pmip6_home_lma_ipv4_address` ipaddr value to a packet.
pub fn add_pmip6_home_lma_ipv4_address(packet: &mut Packet, value: &Ipv4Addr) {
packet.add(AVP::from_ipv4(PMIP6_HOME_LMA_IPV4_ADDRESS_TYPE, value));
}
/// Lookup a `pmip6_home_lma_ipv4_address` ipaddr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_home_lma_ipv4_address`, it returns `None`.
pub fn lookup_pmip6_home_lma_ipv4_address(packet: &Packet) -> Option<Result<Ipv4Addr, AVPError>> {
packet
.lookup(PMIP6_HOME_LMA_IPV4_ADDRESS_TYPE)
.map(|v| v.encode_ipv4())
}
/// Lookup all of the `pmip6_home_lma_ipv4_address` ipaddr value from a packet.
pub fn lookup_all_pmip6_home_lma_ipv4_address(packet: &Packet) -> Result<Vec<Ipv4Addr>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PMIP6_HOME_LMA_IPV4_ADDRESS_TYPE) {
@@ -110,12 +175,17 @@ pub fn lookup_all_pmip6_home_lma_ipv4_address(packet: &Packet) -> Result<Vec<Ipv
}
pub const PMIP6_VISITED_LMA_IPV4_ADDRESS_TYPE: AVPType = 150;
/// Delete all of `pmip6_visited_lma_ipv4_address` values from a packet.
pub fn delete_pmip6_visited_lma_ipv4_address(packet: &mut Packet) {
packet.delete(PMIP6_VISITED_LMA_IPV4_ADDRESS_TYPE);
}
/// Add `pmip6_visited_lma_ipv4_address` ipaddr value to a packet.
pub fn add_pmip6_visited_lma_ipv4_address(packet: &mut Packet, value: &Ipv4Addr) {
packet.add(AVP::from_ipv4(PMIP6_VISITED_LMA_IPV4_ADDRESS_TYPE, value));
}
/// Lookup a `pmip6_visited_lma_ipv4_address` ipaddr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_visited_lma_ipv4_address`, it returns `None`.
pub fn lookup_pmip6_visited_lma_ipv4_address(
packet: &Packet,
) -> Option<Result<Ipv4Addr, AVPError>> {
@@ -123,6 +193,7 @@ pub fn lookup_pmip6_visited_lma_ipv4_address(
.lookup(PMIP6_VISITED_LMA_IPV4_ADDRESS_TYPE)
.map(|v| v.encode_ipv4())
}
/// Lookup all of the `pmip6_visited_lma_ipv4_address` ipaddr value from a packet.
pub fn lookup_all_pmip6_visited_lma_ipv4_address(
packet: &Packet,
) -> Result<Vec<Ipv4Addr>, AVPError> {
@@ -134,18 +205,24 @@ pub fn lookup_all_pmip6_visited_lma_ipv4_address(
}
pub const PMIP6_HOME_HN_PREFIX_TYPE: AVPType = 151;
/// Delete all of `pmip6_home_hn_prefix` values from a packet.
pub fn delete_pmip6_home_hn_prefix(packet: &mut Packet) {
packet.delete(PMIP6_HOME_HN_PREFIX_TYPE);
}
/// Add `pmip6_home_hn_prefix` ipv6 prefix value to a packet.
pub fn add_pmip6_home_hn_prefix(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
packet.add(AVP::from_ipv6_prefix(PMIP6_HOME_HN_PREFIX_TYPE, value)?);
Ok(())
}
/// Lookup a `pmip6_home_hn_prefix` ipv6 prefix value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_home_hn_prefix`, it returns `None`.
pub fn lookup_pmip6_home_hn_prefix(packet: &Packet) -> Option<Result<Vec<u8>, AVPError>> {
packet
.lookup(PMIP6_HOME_HN_PREFIX_TYPE)
.map(|v| v.encode_ipv6_prefix())
}
/// Lookup all of the `pmip6_home_hn_prefix` ipv6 prefix value from a packet.
pub fn lookup_all_pmip6_home_hn_prefix(packet: &Packet) -> Result<Vec<Vec<u8>>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PMIP6_HOME_HN_PREFIX_TYPE) {
@@ -155,18 +232,24 @@ pub fn lookup_all_pmip6_home_hn_prefix(packet: &Packet) -> Result<Vec<Vec<u8>>,
}
pub const PMIP6_VISITED_HN_PREFIX_TYPE: AVPType = 152;
/// Delete all of `pmip6_visited_hn_prefix` values from a packet.
pub fn delete_pmip6_visited_hn_prefix(packet: &mut Packet) {
packet.delete(PMIP6_VISITED_HN_PREFIX_TYPE);
}
/// Add `pmip6_visited_hn_prefix` ipv6 prefix value to a packet.
pub fn add_pmip6_visited_hn_prefix(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
packet.add(AVP::from_ipv6_prefix(PMIP6_VISITED_HN_PREFIX_TYPE, value)?);
Ok(())
}
/// Lookup a `pmip6_visited_hn_prefix` ipv6 prefix value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_visited_hn_prefix`, it returns `None`.
pub fn lookup_pmip6_visited_hn_prefix(packet: &Packet) -> Option<Result<Vec<u8>, AVPError>> {
packet
.lookup(PMIP6_VISITED_HN_PREFIX_TYPE)
.map(|v| v.encode_ipv6_prefix())
}
/// Lookup all of the `pmip6_visited_hn_prefix` ipv6 prefix value from a packet.
pub fn lookup_all_pmip6_visited_hn_prefix(packet: &Packet) -> Result<Vec<Vec<u8>>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PMIP6_VISITED_HN_PREFIX_TYPE) {
@@ -176,9 +259,11 @@ pub fn lookup_all_pmip6_visited_hn_prefix(packet: &Packet) -> Result<Vec<Vec<u8>
}
pub const PMIP6_HOME_INTERFACE_ID_TYPE: AVPType = 153;
/// Delete all of `pmip6_home_interface_id` values from a packet.
pub fn delete_pmip6_home_interface_id(packet: &mut Packet) {
packet.delete(PMIP6_HOME_INTERFACE_ID_TYPE);
}
/// Add `pmip6_home_interface_id` fixed-length octets value to a packet.
pub fn add_pmip6_home_interface_id(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
if value.len() != 8 {
return Err(AVPError::InvalidAttributeLengthError(
@@ -189,11 +274,15 @@ pub fn add_pmip6_home_interface_id(packet: &mut Packet, value: &[u8]) -> Result<
packet.add(AVP::from_bytes(PMIP6_HOME_INTERFACE_ID_TYPE, value));
Ok(())
}
/// Lookup a `pmip6_home_interface_id` fixed-length octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_home_interface_id`, it returns `None`.
pub fn lookup_pmip6_home_interface_id(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(PMIP6_HOME_INTERFACE_ID_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `pmip6_home_interface_id` fixed-length octets value from a packet.
pub fn lookup_all_pmip6_home_interface_id(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PMIP6_HOME_INTERFACE_ID_TYPE) {
@@ -203,9 +292,11 @@ pub fn lookup_all_pmip6_home_interface_id(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const PMIP6_VISITED_INTERFACE_ID_TYPE: AVPType = 154;
/// Delete all of `pmip6_visited_interface_id` values from a packet.
pub fn delete_pmip6_visited_interface_id(packet: &mut Packet) {
packet.delete(PMIP6_VISITED_INTERFACE_ID_TYPE);
}
/// Add `pmip6_visited_interface_id` fixed-length octets value to a packet.
pub fn add_pmip6_visited_interface_id(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
if value.len() != 8 {
return Err(AVPError::InvalidAttributeLengthError(
@@ -216,11 +307,15 @@ pub fn add_pmip6_visited_interface_id(packet: &mut Packet, value: &[u8]) -> Resu
packet.add(AVP::from_bytes(PMIP6_VISITED_INTERFACE_ID_TYPE, value));
Ok(())
}
/// Lookup a `pmip6_visited_interface_id` fixed-length octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_visited_interface_id`, it returns `None`.
pub fn lookup_pmip6_visited_interface_id(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(PMIP6_VISITED_INTERFACE_ID_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `pmip6_visited_interface_id` fixed-length octets value from a packet.
pub fn lookup_all_pmip6_visited_interface_id(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PMIP6_VISITED_INTERFACE_ID_TYPE) {
@@ -230,18 +325,24 @@ pub fn lookup_all_pmip6_visited_interface_id(packet: &Packet) -> Vec<Vec<u8>> {
}
pub const PMIP6_HOME_IPV4_HO_A_TYPE: AVPType = 155;
/// Delete all of `pmip6_home_ipv4_ho_a` values from a packet.
pub fn delete_pmip6_home_ipv4_ho_a(packet: &mut Packet) {
packet.delete(PMIP6_HOME_IPV4_HO_A_TYPE);
}
/// Add `pmip6_home_ipv4_ho_a` ipv4 prefix value to a packet.
pub fn add_pmip6_home_ipv4_ho_a(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
packet.add(AVP::from_ipv4_prefix(PMIP6_HOME_IPV4_HO_A_TYPE, value)?);
Ok(())
}
/// Lookup a `pmip6_home_ipv4_ho_a` ipv4 prefix value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_home_ipv4_ho_a`, it returns `None`.
pub fn lookup_pmip6_home_ipv4_ho_a(packet: &Packet) -> Option<Result<Vec<u8>, AVPError>> {
packet
.lookup(PMIP6_HOME_IPV4_HO_A_TYPE)
.map(|v| v.encode_ipv4_prefix())
}
/// Lookup all of the `pmip6_home_ipv4_ho_a` ipv4 prefix value from a packet.
pub fn lookup_all_pmip6_home_ipv4_ho_a(packet: &Packet) -> Result<Vec<Vec<u8>>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PMIP6_HOME_IPV4_HO_A_TYPE) {
@@ -251,18 +352,24 @@ pub fn lookup_all_pmip6_home_ipv4_ho_a(packet: &Packet) -> Result<Vec<Vec<u8>>,
}
pub const PMIP6_VISITED_IPV4_HO_A_TYPE: AVPType = 156;
/// Delete all of `pmip6_visited_ipv4_ho_a` values from a packet.
pub fn delete_pmip6_visited_ipv4_ho_a(packet: &mut Packet) {
packet.delete(PMIP6_VISITED_IPV4_HO_A_TYPE);
}
/// Add `pmip6_visited_ipv4_ho_a` ipv4 prefix value to a packet.
pub fn add_pmip6_visited_ipv4_ho_a(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
packet.add(AVP::from_ipv4_prefix(PMIP6_VISITED_IPV4_HO_A_TYPE, value)?);
Ok(())
}
/// Lookup a `pmip6_visited_ipv4_ho_a` ipv4 prefix value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_visited_ipv4_ho_a`, it returns `None`.
pub fn lookup_pmip6_visited_ipv4_ho_a(packet: &Packet) -> Option<Result<Vec<u8>, AVPError>> {
packet
.lookup(PMIP6_VISITED_IPV4_HO_A_TYPE)
.map(|v| v.encode_ipv4_prefix())
}
/// Lookup all of the `pmip6_visited_ipv4_ho_a` ipv4 prefix value from a packet.
pub fn lookup_all_pmip6_visited_ipv4_ho_a(packet: &Packet) -> Result<Vec<Vec<u8>>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PMIP6_VISITED_IPV4_HO_A_TYPE) {
@@ -272,12 +379,17 @@ pub fn lookup_all_pmip6_visited_ipv4_ho_a(packet: &Packet) -> Result<Vec<Vec<u8>
}
pub const PMIP6_HOME_DHCP4_SERVER_ADDRESS_TYPE: AVPType = 157;
/// Delete all of `pmip6_home_dhcp4_server_address` values from a packet.
pub fn delete_pmip6_home_dhcp4_server_address(packet: &mut Packet) {
packet.delete(PMIP6_HOME_DHCP4_SERVER_ADDRESS_TYPE);
}
/// Add `pmip6_home_dhcp4_server_address` ipaddr value to a packet.
pub fn add_pmip6_home_dhcp4_server_address(packet: &mut Packet, value: &Ipv4Addr) {
packet.add(AVP::from_ipv4(PMIP6_HOME_DHCP4_SERVER_ADDRESS_TYPE, value));
}
/// Lookup a `pmip6_home_dhcp4_server_address` ipaddr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_home_dhcp4_server_address`, it returns `None`.
pub fn lookup_pmip6_home_dhcp4_server_address(
packet: &Packet,
) -> Option<Result<Ipv4Addr, AVPError>> {
@@ -285,6 +397,7 @@ pub fn lookup_pmip6_home_dhcp4_server_address(
.lookup(PMIP6_HOME_DHCP4_SERVER_ADDRESS_TYPE)
.map(|v| v.encode_ipv4())
}
/// Lookup all of the `pmip6_home_dhcp4_server_address` ipaddr value from a packet.
pub fn lookup_all_pmip6_home_dhcp4_server_address(
packet: &Packet,
) -> Result<Vec<Ipv4Addr>, AVPError> {
@@ -296,15 +409,20 @@ pub fn lookup_all_pmip6_home_dhcp4_server_address(
}
pub const PMIP6_VISITED_DHCP4_SERVER_ADDRESS_TYPE: AVPType = 158;
/// Delete all of `pmip6_visited_dhcp4_server_address` values from a packet.
pub fn delete_pmip6_visited_dhcp4_server_address(packet: &mut Packet) {
packet.delete(PMIP6_VISITED_DHCP4_SERVER_ADDRESS_TYPE);
}
/// Add `pmip6_visited_dhcp4_server_address` ipaddr value to a packet.
pub fn add_pmip6_visited_dhcp4_server_address(packet: &mut Packet, value: &Ipv4Addr) {
packet.add(AVP::from_ipv4(
PMIP6_VISITED_DHCP4_SERVER_ADDRESS_TYPE,
value,
));
}
/// Lookup a `pmip6_visited_dhcp4_server_address` ipaddr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_visited_dhcp4_server_address`, it returns `None`.
pub fn lookup_pmip6_visited_dhcp4_server_address(
packet: &Packet,
) -> Option<Result<Ipv4Addr, AVPError>> {
@@ -312,6 +430,7 @@ pub fn lookup_pmip6_visited_dhcp4_server_address(
.lookup(PMIP6_VISITED_DHCP4_SERVER_ADDRESS_TYPE)
.map(|v| v.encode_ipv4())
}
/// Lookup all of the `pmip6_visited_dhcp4_server_address` ipaddr value from a packet.
pub fn lookup_all_pmip6_visited_dhcp4_server_address(
packet: &Packet,
) -> Result<Vec<Ipv4Addr>, AVPError> {
@@ -323,12 +442,17 @@ pub fn lookup_all_pmip6_visited_dhcp4_server_address(
}
pub const PMIP6_HOME_DHCP6_SERVER_ADDRESS_TYPE: AVPType = 159;
/// Delete all of `pmip6_home_dhcp6_server_address` values from a packet.
pub fn delete_pmip6_home_dhcp6_server_address(packet: &mut Packet) {
packet.delete(PMIP6_HOME_DHCP6_SERVER_ADDRESS_TYPE);
}
/// Add `pmip6_home_dhcp6_server_address` ipv6addr value to a packet.
pub fn add_pmip6_home_dhcp6_server_address(packet: &mut Packet, value: &Ipv6Addr) {
packet.add(AVP::from_ipv6(PMIP6_HOME_DHCP6_SERVER_ADDRESS_TYPE, value));
}
/// Lookup a `pmip6_home_dhcp6_server_address` ipv6addr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_home_dhcp6_server_address`, it returns `None`.
pub fn lookup_pmip6_home_dhcp6_server_address(
packet: &Packet,
) -> Option<Result<Ipv6Addr, AVPError>> {
@@ -336,6 +460,7 @@ pub fn lookup_pmip6_home_dhcp6_server_address(
.lookup(PMIP6_HOME_DHCP6_SERVER_ADDRESS_TYPE)
.map(|v| v.encode_ipv6())
}
/// Lookup all of the `pmip6_home_dhcp6_server_address` ipv6addr value from a packet.
pub fn lookup_all_pmip6_home_dhcp6_server_address(
packet: &Packet,
) -> Result<Vec<Ipv6Addr>, AVPError> {
@@ -347,15 +472,20 @@ pub fn lookup_all_pmip6_home_dhcp6_server_address(
}
pub const PMIP6_VISITED_DHCP6_SERVER_ADDRESS_TYPE: AVPType = 160;
/// Delete all of `pmip6_visited_dhcp6_server_address` values from a packet.
pub fn delete_pmip6_visited_dhcp6_server_address(packet: &mut Packet) {
packet.delete(PMIP6_VISITED_DHCP6_SERVER_ADDRESS_TYPE);
}
/// Add `pmip6_visited_dhcp6_server_address` ipv6addr value to a packet.
pub fn add_pmip6_visited_dhcp6_server_address(packet: &mut Packet, value: &Ipv6Addr) {
packet.add(AVP::from_ipv6(
PMIP6_VISITED_DHCP6_SERVER_ADDRESS_TYPE,
value,
));
}
/// Lookup a `pmip6_visited_dhcp6_server_address` ipv6addr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_visited_dhcp6_server_address`, it returns `None`.
pub fn lookup_pmip6_visited_dhcp6_server_address(
packet: &Packet,
) -> Option<Result<Ipv6Addr, AVPError>> {
@@ -363,6 +493,7 @@ pub fn lookup_pmip6_visited_dhcp6_server_address(
.lookup(PMIP6_VISITED_DHCP6_SERVER_ADDRESS_TYPE)
.map(|v| v.encode_ipv6())
}
/// Lookup all of the `pmip6_visited_dhcp6_server_address` ipv6addr value from a packet.
pub fn lookup_all_pmip6_visited_dhcp6_server_address(
packet: &Packet,
) -> Result<Vec<Ipv6Addr>, AVPError> {
@@ -374,17 +505,23 @@ pub fn lookup_all_pmip6_visited_dhcp6_server_address(
}
pub const PMIP6_HOME_IPV4_GATEWAY_TYPE: AVPType = 161;
/// Delete all of `pmip6_home_ipv4_gateway` values from a packet.
pub fn delete_pmip6_home_ipv4_gateway(packet: &mut Packet) {
packet.delete(PMIP6_HOME_IPV4_GATEWAY_TYPE);
}
/// Add `pmip6_home_ipv4_gateway` ipaddr value to a packet.
pub fn add_pmip6_home_ipv4_gateway(packet: &mut Packet, value: &Ipv4Addr) {
packet.add(AVP::from_ipv4(PMIP6_HOME_IPV4_GATEWAY_TYPE, value));
}
/// Lookup a `pmip6_home_ipv4_gateway` ipaddr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_home_ipv4_gateway`, it returns `None`.
pub fn lookup_pmip6_home_ipv4_gateway(packet: &Packet) -> Option<Result<Ipv4Addr, AVPError>> {
packet
.lookup(PMIP6_HOME_IPV4_GATEWAY_TYPE)
.map(|v| v.encode_ipv4())
}
/// Lookup all of the `pmip6_home_ipv4_gateway` ipaddr value from a packet.
pub fn lookup_all_pmip6_home_ipv4_gateway(packet: &Packet) -> Result<Vec<Ipv4Addr>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PMIP6_HOME_IPV4_GATEWAY_TYPE) {
@@ -394,17 +531,23 @@ pub fn lookup_all_pmip6_home_ipv4_gateway(packet: &Packet) -> Result<Vec<Ipv4Add
}
pub const PMIP6_VISITED_IPV4_GATEWAY_TYPE: AVPType = 162;
/// Delete all of `pmip6_visited_ipv4_gateway` values from a packet.
pub fn delete_pmip6_visited_ipv4_gateway(packet: &mut Packet) {
packet.delete(PMIP6_VISITED_IPV4_GATEWAY_TYPE);
}
/// Add `pmip6_visited_ipv4_gateway` ipaddr value to a packet.
pub fn add_pmip6_visited_ipv4_gateway(packet: &mut Packet, value: &Ipv4Addr) {
packet.add(AVP::from_ipv4(PMIP6_VISITED_IPV4_GATEWAY_TYPE, value));
}
/// Lookup a `pmip6_visited_ipv4_gateway` ipaddr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `pmip6_visited_ipv4_gateway`, it returns `None`.
pub fn lookup_pmip6_visited_ipv4_gateway(packet: &Packet) -> Option<Result<Ipv4Addr, AVPError>> {
packet
.lookup(PMIP6_VISITED_IPV4_GATEWAY_TYPE)
.map(|v| v.encode_ipv4())
}
/// Lookup all of the `pmip6_visited_ipv4_gateway` ipaddr value from a packet.
pub fn lookup_all_pmip6_visited_ipv4_gateway(packet: &Packet) -> Result<Vec<Ipv4Addr>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(PMIP6_VISITED_IPV4_GATEWAY_TYPE) {

View File

@@ -1,20 +1,52 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc6677 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 6677
//! # http://www.ietf.org/rfc/rfc6677.txt
//! #
//!
//! ATTRIBUTE EAP-Lower-Layer 163 integer
//!
//! VALUE EAP-Lower-Layer Wired-IEEE-802.1X 1
//! VALUE EAP-Lower-Layer IEEE-802.1X-No-Preauth 2
//! VALUE EAP-Lower-Layer IEEE-802.1X-Preauth 3
//! VALUE EAP-Lower-Layer IEEE-802.16e 4
//! VALUE EAP-Lower-Layer IKEv2 5
//! VALUE EAP-Lower-Layer PPP 6
//! VALUE EAP-Lower-Layer PANA-No-Preauth 7
//! VALUE EAP-Lower-Layer GSS-API 8
//! VALUE EAP-Lower-Layer PANA-Preauth 9
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const EAP_LOWER_LAYER_TYPE: AVPType = 163;
/// Delete all of `eap_lower_layer` values from a packet.
pub fn delete_eap_lower_layer(packet: &mut Packet) {
packet.delete(EAP_LOWER_LAYER_TYPE);
}
/// Add `eap_lower_layer` value-defined integer value to a packet.
pub fn add_eap_lower_layer(packet: &mut Packet, value: EapLowerLayer) {
packet.add(AVP::from_u32(EAP_LOWER_LAYER_TYPE, value as u32));
}
/// Lookup a `eap_lower_layer` value-defined integer value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `eap_lower_layer`, it returns `None`.
pub fn lookup_eap_lower_layer(packet: &Packet) -> Option<Result<EapLowerLayer, AVPError>> {
packet
.lookup(EAP_LOWER_LAYER_TYPE)
.map(|v| Ok(v.encode_u32()? as EapLowerLayer))
}
/// Lookup all of the `eap_lower_layer` value-defined integer value from a packet.
pub fn lookup_all_eap_lower_layer(packet: &Packet) -> Result<Vec<EapLowerLayer>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(EAP_LOWER_LAYER_TYPE) {

View File

@@ -1,22 +1,48 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc6911 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 6911
//! # http://www.ietf.org/rfc/rfc6911.txt
//! #
//!
//! ATTRIBUTE Framed-IPV6-Address 168 ipv6addr
//! ATTRIBUTE DNS-Server-IPV6-Address 169 ipv6addr
//! ATTRIBUTE Route-IPV6-Information 170 ipv6prefix
//! ATTRIBUTE Delegated-IPV6-Prefix-Pool 171 string
//! ATTRIBUTE Stateful-IPV6-Address-Pool 172 string
//! ```
use std::net::Ipv6Addr;
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const FRAMED_IPV6_ADDRESS_TYPE: AVPType = 168;
/// Delete all of `framed_ipv6_address` values from a packet.
pub fn delete_framed_ipv6_address(packet: &mut Packet) {
packet.delete(FRAMED_IPV6_ADDRESS_TYPE);
}
/// Add `framed_ipv6_address` ipv6addr value to a packet.
pub fn add_framed_ipv6_address(packet: &mut Packet, value: &Ipv6Addr) {
packet.add(AVP::from_ipv6(FRAMED_IPV6_ADDRESS_TYPE, value));
}
/// Lookup a `framed_ipv6_address` ipv6addr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `framed_ipv6_address`, it returns `None`.
pub fn lookup_framed_ipv6_address(packet: &Packet) -> Option<Result<Ipv6Addr, AVPError>> {
packet
.lookup(FRAMED_IPV6_ADDRESS_TYPE)
.map(|v| v.encode_ipv6())
}
/// Lookup all of the `framed_ipv6_address` ipv6addr value from a packet.
pub fn lookup_all_framed_ipv6_address(packet: &Packet) -> Result<Vec<Ipv6Addr>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(FRAMED_IPV6_ADDRESS_TYPE) {
@@ -26,17 +52,23 @@ pub fn lookup_all_framed_ipv6_address(packet: &Packet) -> Result<Vec<Ipv6Addr>,
}
pub const DNS_SERVER_IPV6_ADDRESS_TYPE: AVPType = 169;
/// Delete all of `dns_server_ipv6_address` values from a packet.
pub fn delete_dns_server_ipv6_address(packet: &mut Packet) {
packet.delete(DNS_SERVER_IPV6_ADDRESS_TYPE);
}
/// Add `dns_server_ipv6_address` ipv6addr value to a packet.
pub fn add_dns_server_ipv6_address(packet: &mut Packet, value: &Ipv6Addr) {
packet.add(AVP::from_ipv6(DNS_SERVER_IPV6_ADDRESS_TYPE, value));
}
/// Lookup a `dns_server_ipv6_address` ipv6addr value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `dns_server_ipv6_address`, it returns `None`.
pub fn lookup_dns_server_ipv6_address(packet: &Packet) -> Option<Result<Ipv6Addr, AVPError>> {
packet
.lookup(DNS_SERVER_IPV6_ADDRESS_TYPE)
.map(|v| v.encode_ipv6())
}
/// Lookup all of the `dns_server_ipv6_address` ipv6addr value from a packet.
pub fn lookup_all_dns_server_ipv6_address(packet: &Packet) -> Result<Vec<Ipv6Addr>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DNS_SERVER_IPV6_ADDRESS_TYPE) {
@@ -46,18 +78,24 @@ pub fn lookup_all_dns_server_ipv6_address(packet: &Packet) -> Result<Vec<Ipv6Add
}
pub const ROUTE_IPV6_INFORMATION_TYPE: AVPType = 170;
/// Delete all of `route_ipv6_information` values from a packet.
pub fn delete_route_ipv6_information(packet: &mut Packet) {
packet.delete(ROUTE_IPV6_INFORMATION_TYPE);
}
/// Add `route_ipv6_information` ipv6 prefix value to a packet.
pub fn add_route_ipv6_information(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
packet.add(AVP::from_ipv6_prefix(ROUTE_IPV6_INFORMATION_TYPE, value)?);
Ok(())
}
/// Lookup a `route_ipv6_information` ipv6 prefix value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `route_ipv6_information`, it returns `None`.
pub fn lookup_route_ipv6_information(packet: &Packet) -> Option<Result<Vec<u8>, AVPError>> {
packet
.lookup(ROUTE_IPV6_INFORMATION_TYPE)
.map(|v| v.encode_ipv6_prefix())
}
/// Lookup all of the `route_ipv6_information` ipv6 prefix value from a packet.
pub fn lookup_all_route_ipv6_information(packet: &Packet) -> Result<Vec<Vec<u8>>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ROUTE_IPV6_INFORMATION_TYPE) {
@@ -67,17 +105,23 @@ pub fn lookup_all_route_ipv6_information(packet: &Packet) -> Result<Vec<Vec<u8>>
}
pub const DELEGATED_IPV6_PREFIX_POOL_TYPE: AVPType = 171;
/// Delete all of `delegated_ipv6_prefix_pool` values from a packet.
pub fn delete_delegated_ipv6_prefix_pool(packet: &mut Packet) {
packet.delete(DELEGATED_IPV6_PREFIX_POOL_TYPE);
}
/// Add `delegated_ipv6_prefix_pool` string value to a packet.
pub fn add_delegated_ipv6_prefix_pool(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(DELEGATED_IPV6_PREFIX_POOL_TYPE, value));
}
/// Lookup a `delegated_ipv6_prefix_pool` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `delegated_ipv6_prefix_pool`, it returns `None`.
pub fn lookup_delegated_ipv6_prefix_pool(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(DELEGATED_IPV6_PREFIX_POOL_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `delegated_ipv6_prefix_pool` string value from a packet.
pub fn lookup_all_delegated_ipv6_prefix_pool(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(DELEGATED_IPV6_PREFIX_POOL_TYPE) {
@@ -87,17 +131,23 @@ pub fn lookup_all_delegated_ipv6_prefix_pool(packet: &Packet) -> Result<Vec<Stri
}
pub const STATEFUL_IPV6_ADDRESS_POOL_TYPE: AVPType = 172;
/// Delete all of `stateful_ipv6_address_pool` values from a packet.
pub fn delete_stateful_ipv6_address_pool(packet: &mut Packet) {
packet.delete(STATEFUL_IPV6_ADDRESS_POOL_TYPE);
}
/// Add `stateful_ipv6_address_pool` string value to a packet.
pub fn add_stateful_ipv6_address_pool(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(STATEFUL_IPV6_ADDRESS_POOL_TYPE, value));
}
/// Lookup a `stateful_ipv6_address_pool` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `stateful_ipv6_address_pool`, it returns `None`.
pub fn lookup_stateful_ipv6_address_pool(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(STATEFUL_IPV6_ADDRESS_POOL_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `stateful_ipv6_address_pool` string value from a packet.
pub fn lookup_all_stateful_ipv6_address_pool(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(STATEFUL_IPV6_ADDRESS_POOL_TYPE) {

View File

@@ -1,20 +1,45 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc7055 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 7055
//! # http://www.ietf.org/rfc/rfc7055.txt
//! #
//!
//! ATTRIBUTE GSS-Acceptor-Service-Name 164 string
//! ATTRIBUTE GSS-Acceptor-Host-Name 165 string
//! ATTRIBUTE GSS-Acceptor-Service-Specifics 166 string
//! ATTRIBUTE GSS-Acceptor-Realm-Name 167 string
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const GSS_ACCEPTOR_SERVICE_NAME_TYPE: AVPType = 164;
/// Delete all of `gss_acceptor_service_name` values from a packet.
pub fn delete_gss_acceptor_service_name(packet: &mut Packet) {
packet.delete(GSS_ACCEPTOR_SERVICE_NAME_TYPE);
}
/// Add `gss_acceptor_service_name` string value to a packet.
pub fn add_gss_acceptor_service_name(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(GSS_ACCEPTOR_SERVICE_NAME_TYPE, value));
}
/// Lookup a `gss_acceptor_service_name` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `gss_acceptor_service_name`, it returns `None`.
pub fn lookup_gss_acceptor_service_name(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(GSS_ACCEPTOR_SERVICE_NAME_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `gss_acceptor_service_name` string value from a packet.
pub fn lookup_all_gss_acceptor_service_name(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(GSS_ACCEPTOR_SERVICE_NAME_TYPE) {
@@ -24,17 +49,23 @@ pub fn lookup_all_gss_acceptor_service_name(packet: &Packet) -> Result<Vec<Strin
}
pub const GSS_ACCEPTOR_HOST_NAME_TYPE: AVPType = 165;
/// Delete all of `gss_acceptor_host_name` values from a packet.
pub fn delete_gss_acceptor_host_name(packet: &mut Packet) {
packet.delete(GSS_ACCEPTOR_HOST_NAME_TYPE);
}
/// Add `gss_acceptor_host_name` string value to a packet.
pub fn add_gss_acceptor_host_name(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(GSS_ACCEPTOR_HOST_NAME_TYPE, value));
}
/// Lookup a `gss_acceptor_host_name` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `gss_acceptor_host_name`, it returns `None`.
pub fn lookup_gss_acceptor_host_name(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(GSS_ACCEPTOR_HOST_NAME_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `gss_acceptor_host_name` string value from a packet.
pub fn lookup_all_gss_acceptor_host_name(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(GSS_ACCEPTOR_HOST_NAME_TYPE) {
@@ -44,17 +75,23 @@ pub fn lookup_all_gss_acceptor_host_name(packet: &Packet) -> Result<Vec<String>,
}
pub const GSS_ACCEPTOR_SERVICE_SPECIFICS_TYPE: AVPType = 166;
/// Delete all of `gss_acceptor_service_specifics` values from a packet.
pub fn delete_gss_acceptor_service_specifics(packet: &mut Packet) {
packet.delete(GSS_ACCEPTOR_SERVICE_SPECIFICS_TYPE);
}
/// Add `gss_acceptor_service_specifics` string value to a packet.
pub fn add_gss_acceptor_service_specifics(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(GSS_ACCEPTOR_SERVICE_SPECIFICS_TYPE, value));
}
/// Lookup a `gss_acceptor_service_specifics` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `gss_acceptor_service_specifics`, it returns `None`.
pub fn lookup_gss_acceptor_service_specifics(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(GSS_ACCEPTOR_SERVICE_SPECIFICS_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `gss_acceptor_service_specifics` string value from a packet.
pub fn lookup_all_gss_acceptor_service_specifics(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(GSS_ACCEPTOR_SERVICE_SPECIFICS_TYPE) {
@@ -64,17 +101,23 @@ pub fn lookup_all_gss_acceptor_service_specifics(packet: &Packet) -> Result<Vec<
}
pub const GSS_ACCEPTOR_REALM_NAME_TYPE: AVPType = 167;
/// Delete all of `gss_acceptor_realm_name` values from a packet.
pub fn delete_gss_acceptor_realm_name(packet: &mut Packet) {
packet.delete(GSS_ACCEPTOR_REALM_NAME_TYPE);
}
/// Add `gss_acceptor_realm_name` string value to a packet.
pub fn add_gss_acceptor_realm_name(packet: &mut Packet, value: &str) {
packet.add(AVP::from_string(GSS_ACCEPTOR_REALM_NAME_TYPE, value));
}
/// Lookup a `gss_acceptor_realm_name` string value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `gss_acceptor_realm_name`, it returns `None`.
pub fn lookup_gss_acceptor_realm_name(packet: &Packet) -> Option<Result<String, AVPError>> {
packet
.lookup(GSS_ACCEPTOR_REALM_NAME_TYPE)
.map(|v| v.encode_string())
}
/// Lookup all of the `gss_acceptor_realm_name` string value from a packet.
pub fn lookup_all_gss_acceptor_realm_name(packet: &Packet) -> Result<Vec<String>, AVPError> {
let mut vec = Vec::new();
for avp in packet.lookup_all(GSS_ACCEPTOR_REALM_NAME_TYPE) {

View File

@@ -1,12 +1,33 @@
// Code generated by machine generator; DO NOT EDIT.
//! Utility for rfc7155 packet.
//!
//! This module handles the packet according to the following definition:
//! ```text
//! //! # -*- 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 7155
//! # http://www.ietf.org/rfc/rfc7155.txt
//! #
//!
//! # The Value field contains two octets (00 - 99). ANSI T1.113 and
//! # BELLCORE 394 can be used for additional information about these
//! # values and their use.
//! ATTRIBUTE Originating-Line-Info 94 octets[2]
//! ```
use crate::core::avp::{AVPError, AVPType, AVP};
use crate::core::packet::Packet;
pub const ORIGINATING_LINE_INFO_TYPE: AVPType = 94;
/// Delete all of `originating_line_info` values from a packet.
pub fn delete_originating_line_info(packet: &mut Packet) {
packet.delete(ORIGINATING_LINE_INFO_TYPE);
}
/// Add `originating_line_info` fixed-length octets value to a packet.
pub fn add_originating_line_info(packet: &mut Packet, value: &[u8]) -> Result<(), AVPError> {
if value.len() != 2 {
return Err(AVPError::InvalidAttributeLengthError(
@@ -17,11 +38,15 @@ pub fn add_originating_line_info(packet: &mut Packet, value: &[u8]) -> Result<()
packet.add(AVP::from_bytes(ORIGINATING_LINE_INFO_TYPE, value));
Ok(())
}
/// Lookup a `originating_line_info` fixed-length octets value from a packet.
///
/// It returns the first looked up value. If there is no associated value with `originating_line_info`, it returns `None`.
pub fn lookup_originating_line_info(packet: &Packet) -> Option<Vec<u8>> {
packet
.lookup(ORIGINATING_LINE_INFO_TYPE)
.map(|v| v.encode_bytes())
}
/// Lookup all of the `originating_line_info` fixed-length octets value from a packet.
pub fn lookup_all_originating_line_info(packet: &Packet) -> Vec<Vec<u8>> {
let mut vec = Vec::new();
for avp in packet.lookup_all(ORIGINATING_LINE_INFO_TYPE) {

View File

@@ -1,3 +1,5 @@
//! RADIUS server implementation.
use async_trait::async_trait;
use std::borrow::Borrow;
use std::collections::HashSet;