Add skeleton code for tagged attribute value

This commit is contained in:
moznion
2020-11-29 01:57:21 +09:00
parent 490f1ce622
commit a975e7ca69
+42 -18
View File
@@ -29,6 +29,7 @@ struct RadiusAttribute {
name: String, name: String,
typ: u8, typ: u8,
value_type: RadiusAttributeValueType, value_type: RadiusAttributeValueType,
has_tag: bool,
} }
#[derive(Debug)] #[derive(Debug)]
@@ -41,6 +42,7 @@ struct RadiusValue {
enum RadiusAttributeValueType { enum RadiusAttributeValueType {
String, String,
UserPassword, UserPassword,
TunnelPassword,
Octets, Octets,
IpAddr, IpAddr,
Integer, Integer,
@@ -179,28 +181,43 @@ fn generate_attribute_code(
generate_common_attribute_code(w, &attr_name, &type_identifier, type_value); generate_common_attribute_code(w, &attr_name, &type_identifier, type_value);
match attr.value_type { match attr.value_type {
RadiusAttributeValueType::String => { RadiusAttributeValueType::String => match attr.has_tag {
generate_string_attribute_code(w, &method_identifier, &type_identifier) true => unimplemented!(),
} false => generate_string_attribute_code(w, &method_identifier, &type_identifier),
RadiusAttributeValueType::UserPassword => { },
generate_user_password_attribute_code(w, &method_identifier, &type_identifier) RadiusAttributeValueType::UserPassword => match attr.has_tag {
} true => unimplemented!(),
RadiusAttributeValueType::Octets => { false => generate_user_password_attribute_code(w, &method_identifier, &type_identifier),
generate_octets_attribute_code(w, &method_identifier, &type_identifier) },
} RadiusAttributeValueType::TunnelPassword => match attr.has_tag {
RadiusAttributeValueType::IpAddr => { true => unimplemented!(),
generate_ipaddr_attribute_code(w, &method_identifier, &type_identifier) false => unimplemented!(),
} },
RadiusAttributeValueType::Octets => match attr.has_tag {
true => unimplemented!(),
false => generate_octets_attribute_code(w, &method_identifier, &type_identifier),
},
RadiusAttributeValueType::IpAddr => match attr.has_tag {
true => unimplemented!(),
false => generate_ipaddr_attribute_code(w, &method_identifier, &type_identifier),
},
RadiusAttributeValueType::Integer => { RadiusAttributeValueType::Integer => {
if value_defined_attributes_set.contains(&attr_name) { match value_defined_attributes_set.contains(&attr_name) {
generate_value_defined_integer_attribute_code( true => match attr.has_tag {
true => unimplemented!(),
false => generate_value_defined_integer_attribute_code(
w, w,
&method_identifier, &method_identifier,
&type_identifier, &type_identifier,
&attr_name.to_pascal_case(), &attr_name.to_pascal_case(),
); ),
} else { },
generate_integer_attribute_code(w, &method_identifier, &type_identifier); false => match attr.has_tag {
true => unimplemented!(),
false => {
generate_integer_attribute_code(w, &method_identifier, &type_identifier)
}
},
} }
} }
RadiusAttributeValueType::VSA => generate_vsa_attribute_code(), RadiusAttributeValueType::VSA => generate_vsa_attribute_code(),
@@ -434,6 +451,10 @@ fn parse_dict_file(dict_file_path: &Path) -> Result<DictParsed, String> {
encryption_type = Some(EncryptionType::TunnelPassword); encryption_type = Some(EncryptionType::TunnelPassword);
continue; continue;
} }
if type_opt == HAS_TAG_TYPE_OPT {
has_tag = true;
continue;
}
} }
} }
@@ -444,7 +465,9 @@ fn parse_dict_file(dict_file_path: &Path) -> Result<DictParsed, String> {
Some(EncryptionType::UserPassword) => { Some(EncryptionType::UserPassword) => {
RadiusAttributeValueType::UserPassword RadiusAttributeValueType::UserPassword
} }
Some(EncryptionType::TunnelPassword) => t, // TODO Some(EncryptionType::TunnelPassword) => {
RadiusAttributeValueType::TunnelPassword
}
None => t, None => t,
} }
} else { } else {
@@ -460,6 +483,7 @@ fn parse_dict_file(dict_file_path: &Path) -> Result<DictParsed, String> {
name: items[1].to_string(), name: items[1].to_string(),
typ: items[2].parse().unwrap(), typ: items[2].parse().unwrap(),
value_type: typ, value_type: typ,
has_tag,
}); });
} }
VALUE_KIND => { VALUE_KIND => {