Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rwestphal committed Jan 2, 2025
1 parent 7f47776 commit 373a252
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 73 deletions.
78 changes: 58 additions & 20 deletions holo-ospf/src/northbound/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,21 @@ fn load_callbacks_ospfv2() -> Callbacks<Instance<Ospfv2>> {
functional_flag: Some(*flag),
})
})
.path(ospf::database::as_scope_lsa_type::as_scope_lsas::as_scope_lsa::ospfv2::body::opaque::ri_opaque::dynamic_hostname_tlv::PATH)
.get_object(|_instance, args| {
use ospf::database::as_scope_lsa_type::as_scope_lsas::as_scope_lsa::ospfv2::body::opaque::ri_opaque::dynamic_hostname_tlv::DynamicHostnameTlv;
let lse: &LsaEntry<Ospfv2> = args.list_entry.as_as_lsa().unwrap();
let lsa = &lse.data;
let mut hostname = None;
if let Some(lsa_body) = lsa.body.as_opaque_as()
&& let Some(lsa_body) = lsa_body.as_router_info()
&& let Some(info_hostname) = &lsa_body.info_hostname {
hostname = Some(Cow::Borrowed(info_hostname.get()));
}
Box::new(DynamicHostnameTlv {
hostname,
})
})
.path(ospf::database::as_scope_lsa_type::as_scope_lsas::as_scope_lsa::ospfv2::body::opaque::ri_opaque::maximum_sid_depth_tlv::msd_type::PATH)
.get_iterate(|_instance, args| {
let lse: &LsaEntry<Ospfv2> = args.parent_list_entry.as_as_lsa().unwrap();
Expand Down Expand Up @@ -1066,6 +1081,21 @@ fn load_callbacks_ospfv2() -> Callbacks<Instance<Ospfv2>> {
functional_flag: Some(*flag),
})
})
.path(ospf::areas::area::database::area_scope_lsa_type::area_scope_lsas::area_scope_lsa::ospfv2::body::opaque::ri_opaque::dynamic_hostname_tlv::PATH)
.get_object(|_instance, args| {
use ospf::areas::area::database::area_scope_lsa_type::area_scope_lsas::area_scope_lsa::ospfv2::body::opaque::ri_opaque::dynamic_hostname_tlv::DynamicHostnameTlv;
let lse: &LsaEntry<Ospfv2> = args.list_entry.as_area_lsa().unwrap();
let lsa = &lse.data;
let mut hostname = None;
if let Some(lsa_body) = lsa.body.as_opaque_area()
&& let Some(lsa_body) = lsa_body.as_router_info()
&& let Some(info_hostname) = &lsa_body.info_hostname {
hostname = Some(Cow::Borrowed(info_hostname.get()));
}
Box::new(DynamicHostnameTlv {
hostname,
})
})
.path(ospf::areas::area::database::area_scope_lsa_type::area_scope_lsas::area_scope_lsa::ospfv2::body::opaque::ri_opaque::maximum_sid_depth_tlv::msd_type::PATH)
.get_iterate(|_instance, args| {
let lse: &LsaEntry<Ospfv2> = args.parent_list_entry.as_area_lsa().unwrap();
Expand Down Expand Up @@ -1512,26 +1542,6 @@ fn load_callbacks_ospfv2() -> Callbacks<Instance<Ospfv2>> {
msd_value: Some(*msd_value),
})
})
//todo fix me
.path(ospf::areas::area::database::area_scope_lsa_type::area_scope_lsas::area_scope_lsa::ospfv2::body::opaque::ri_opaque::dynamic_hostname_tlv::PATH)
.get_object(|_instance, args| {
use ospf::areas::area::database::area_scope_lsa_type::area_scope_lsas::area_scope_lsa::ospfv2::body::opaque::ri_opaque::dynamic_hostname_tlv::DynamicHostnameTlv;
let lse: &LsaEntry<Ospfv2> = args.list_entry.as_area_lsa().unwrap();
let lsa = &lse.data;
if let Some(lsa_body) = lsa.body.as_opaque_area()
&& let Some(lsa_body) = lsa_body.as_router_info()
&& let Some(hostname) = &lsa_body.info_hostname
{
Box::new(DynamicHostnameTlv {
hostname: Some(Cow::Owned(hostname.get().to_string())),
})
} else {
Box::new(DynamicHostnameTlv {
hostname: None,
})
}

})
.path(ospf::areas::area::interfaces::interface::database::link_scope_lsa_type::link_scope_lsas::link_scope_lsa::ospfv2::body::opaque::ri_opaque::unknown_tlvs::unknown_tlv::PATH)
.get_iterate(|_instance, args| {
let lse: &LsaEntry<Ospfv2> = args.parent_list_entry.as_interface_lsa().unwrap();
Expand Down Expand Up @@ -1803,6 +1813,20 @@ fn load_callbacks_ospfv3() -> Callbacks<Instance<Ospfv3>> {
functional_flag: Some(*flag),
})
})
.path(ospf::database::as_scope_lsa_type::as_scope_lsas::as_scope_lsa::ospfv3::body::router_information::dynamic_hostname_tlv::PATH)
.get_object(|_instance, args| {
use ospf::database::as_scope_lsa_type::as_scope_lsas::as_scope_lsa::ospfv3::body::router_information::dynamic_hostname_tlv::DynamicHostnameTlv;
let lse: &LsaEntry<Ospfv3> = args.list_entry.as_as_lsa().unwrap();
let lsa = &lse.data;
let mut hostname = None;
if let Some(lsa_body) = lsa.body.as_router_info()
&& let Some(info_hostname) = &lsa_body.info_hostname {
hostname = Some(Cow::Borrowed(info_hostname.get()));
}
Box::new(DynamicHostnameTlv {
hostname,
})
})
.path(ospf::database::as_scope_lsa_type::as_scope_lsas::as_scope_lsa::ospfv3::body::router_information::sr_algorithm_tlv::PATH)
.get_object(|_instance, args| {
use ospf::database::as_scope_lsa_type::as_scope_lsas::as_scope_lsa::ospfv3::body::router_information::sr_algorithm_tlv::SrAlgorithmTlv;
Expand Down Expand Up @@ -2270,6 +2294,20 @@ fn load_callbacks_ospfv3() -> Callbacks<Instance<Ospfv3>> {
functional_flag: Some(*flag),
})
})
.path(ospf::areas::area::database::area_scope_lsa_type::area_scope_lsas::area_scope_lsa::ospfv3::body::router_information::dynamic_hostname_tlv::PATH)
.get_object(|_instance, args| {
use ospf::areas::area::database::area_scope_lsa_type::area_scope_lsas::area_scope_lsa::ospfv3::body::router_information::dynamic_hostname_tlv::DynamicHostnameTlv;
let lse: &LsaEntry<Ospfv3> = args.list_entry.as_area_lsa().unwrap();
let lsa = &lse.data;
let mut hostname = None;
if let Some(lsa_body) = lsa.body.as_router_info()
&& let Some(info_hostname) = &lsa_body.info_hostname {
hostname = Some(Cow::Borrowed(info_hostname.get()));
}
Box::new(DynamicHostnameTlv {
hostname,
})
})
.path(ospf::areas::area::database::area_scope_lsa_type::area_scope_lsas::area_scope_lsa::ospfv3::body::router_information::sr_algorithm_tlv::PATH)
.get_object(|_instance, args| {
use ospf::areas::area::database::area_scope_lsa_type::area_scope_lsas::area_scope_lsa::ospfv3::body::router_information::sr_algorithm_tlv::SrAlgorithmTlv;
Expand Down
1 change: 1 addition & 0 deletions holo-ospf/src/ospfv2/packet/lsa_opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pub struct LsaRouterInfo {
pub srlb: Vec<SrLocalBlockTlv>,
pub msds: Option<MsdTlv>,
pub srms_pref: Option<SrmsPrefTlv>,
#[serde(skip)]
pub info_hostname: Option<RouterInfoDynamicHostnameTlv>,
pub unknown_tlvs: Vec<UnknownTlv>,
}
Expand Down
4 changes: 4 additions & 0 deletions holo-ospf/src/ospfv3/packet/lsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ pub struct LsaRouterInfo {
#[new(default)]
pub srms_pref: Option<SrmsPrefTlv>,
#[new(default)]
#[serde(skip)]
pub info_hostname: Option<RouterInfoDynamicHostnameTlv>,
#[new(default)]
pub unknown_tlvs: Vec<UnknownTlv>,
Expand Down Expand Up @@ -2606,6 +2607,9 @@ impl LsaRouterInfo {
if let Some(func_caps) = &self.func_caps {
func_caps.encode(buf);
}
if let Some(info_hostname) = &self.info_hostname {
info_hostname.encode(buf);
}
if let Some(sr_algo) = &self.sr_algo {
sr_algo.encode(buf);
}
Expand Down
28 changes: 19 additions & 9 deletions holo-ospf/src/packet/tlv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bitflags! {
pub struct RouterFuncCapsTlv(RouterFuncCaps);

//
// SR-Algorithm TLV.
// Dynamic Hostname TLV.
//
// Encoding format:
//
Expand All @@ -121,20 +121,30 @@ pub struct RouterFuncCapsTlv(RouterFuncCaps);
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Type | Length |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Algorithm 1 | Algorithm... | Algorithm n | |
// +- -+
// | |
// + +
// | Hostname ... |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//

// RFC 5642

#[derive(Clone, Debug, Default, Eq, new, PartialEq)]
#[derive(Deserialize, Serialize)]
pub struct RouterInfoDynamicHostnameTlv {
pub hostname: String,
}

//
// SR-Algorithm TLV.
//
// Encoding format:
//
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Type | Length |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Algorithm 1 | Algorithm... | Algorithm n | |
// +- -+
// | |
// + +
//
#[derive(Clone, Debug, Default, Eq, new, PartialEq)]
#[derive(Deserialize, Serialize)]
pub struct SrAlgoTlv(BTreeSet<IgpAlgoType>);
Expand Down Expand Up @@ -574,7 +584,7 @@ impl RouterInfoDynamicHostnameTlv {
tlv_encode_end(buf, start_pos);
}

pub(crate) fn get(&self) -> &String {
pub(crate) fn get(&self) -> &str {
&self.hostname
}
}
Expand Down
44 changes: 0 additions & 44 deletions holo-yang/modules/deviations/holo-ietf-ospf-deviations.yang
Original file line number Diff line number Diff line change
Expand Up @@ -736,16 +736,6 @@ module holo-ietf-ospf-deviations {
}
*/

deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:database/ospf:as-scope-lsa-type/ospf:as-scope-lsas/ospf:as-scope-lsa/ospf:version/ospf:ospfv2/ospf:ospfv2/ospf:body/ospf:opaque/ospf:ri-opaque/ospf:dynamic-hostname-tlv" {
deviate not-supported;
}

/*
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:database/ospf:as-scope-lsa-type/ospf:as-scope-lsas/ospf:as-scope-lsa/ospf:version/ospf:ospfv2/ospf:ospfv2/ospf:body/ospf:opaque/ospf:ri-opaque/ospf:dynamic-hostname-tlv/ospf:hostname" {
deviate not-supported;
}
*/

deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:database/ospf:as-scope-lsa-type/ospf:as-scope-lsas/ospf:as-scope-lsa/ospf:version/ospf:ospfv2/ospf:ospfv2/ospf:body/ospf:opaque/ospf:ri-opaque/ospf:sbfd-discriminator-tlv" {
deviate not-supported;
}
Expand Down Expand Up @@ -950,16 +940,6 @@ module holo-ietf-ospf-deviations {
}
*/

deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:database/ospf:as-scope-lsa-type/ospf:as-scope-lsas/ospf:as-scope-lsa/ospf:version/ospf:ospfv3/ospf:ospfv3/ospf:body/ospf:router-information/ospf:dynamic-hostname-tlv" {
deviate not-supported;
}

/*
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:database/ospf:as-scope-lsa-type/ospf:as-scope-lsas/ospf:as-scope-lsa/ospf:version/ospf:ospfv3/ospf:ospfv3/ospf:body/ospf:router-information/ospf:dynamic-hostname-tlv/ospf:hostname" {
deviate not-supported;
}
*/

deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:database/ospf:as-scope-lsa-type/ospf:as-scope-lsas/ospf:as-scope-lsa/ospf:version/ospf:ospfv3/ospf:ospfv3/ospf:body/ospf:router-information/ospf:sbfd-discriminator-tlv" {
deviate not-supported;
}
Expand Down Expand Up @@ -1002,18 +982,6 @@ module holo-ietf-ospf-deviations {
}
*/

/*
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:database/ospf:area-scope-lsa-type/ospf:area-scope-lsas/ospf:area-scope-lsa/ospf:version/ospf:ospfv2/ospf:ospfv2/ospf:body/ospf:opaque/ospf:ri-opaque/ospf:dynamic-hostname-tlv" {
deviate not-supported;
}
/*
/*
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:database/ospf:area-scope-lsa-type/ospf:area-scope-lsas/ospf:area-scope-lsa/ospf:version/ospf:ospfv2/ospf:ospfv2/ospf:body/ospf:opaque/ospf:ri-opaque/ospf:dynamic-hostname-tlv/ospf:hostname" {
deviate not-supported;
}
*/

deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:database/ospf:area-scope-lsa-type/ospf:area-scope-lsas/ospf:area-scope-lsa/ospf:version/ospf:ospfv2/ospf:ospfv2/ospf:body/ospf:opaque/ospf:ri-opaque/ospf:sbfd-discriminator-tlv" {
deviate not-supported;
}
Expand Down Expand Up @@ -1218,16 +1186,6 @@ module holo-ietf-ospf-deviations {
}
*/

deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:database/ospf:area-scope-lsa-type/ospf:area-scope-lsas/ospf:area-scope-lsa/ospf:version/ospf:ospfv3/ospf:ospfv3/ospf:body/ospf:router-information/ospf:dynamic-hostname-tlv" {
deviate not-supported;
}

/*
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:database/ospf:area-scope-lsa-type/ospf:area-scope-lsas/ospf:area-scope-lsa/ospf:version/ospf:ospfv3/ospf:ospfv3/ospf:body/ospf:router-information/ospf:dynamic-hostname-tlv/ospf:hostname" {
deviate not-supported;
}
*/

deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:database/ospf:area-scope-lsa-type/ospf:area-scope-lsas/ospf:area-scope-lsa/ospf:version/ospf:ospfv3/ospf:ospfv3/ospf:body/ospf:router-information/ospf:sbfd-discriminator-tlv" {
deviate not-supported;
}
Expand Down Expand Up @@ -3168,11 +3126,9 @@ module holo-ietf-ospf-deviations {
}
*/

/*
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:interfaces/ospf:interface/ospf:database/ospf:link-scope-lsa-type/ospf:link-scope-lsas/ospf:link-scope-lsa/ospf:version/ospf:ospfv3/ospf:ospfv3/ospf:body/ospf:router-information/ospf:dynamic-hostname-tlv" {
deviate not-supported;
}
*/

/*
deviation "/rt:routing/rt:control-plane-protocols/rt:control-plane-protocol/ospf:ospf/ospf:areas/ospf:area/ospf:interfaces/ospf:interface/ospf:database/ospf:link-scope-lsa-type/ospf:link-scope-lsas/ospf:link-scope-lsa/ospf:version/ospf:ospfv3/ospf:ospfv3/ospf:body/ospf:router-information/ospf:dynamic-hostname-tlv/ospf:hostname" {
Expand Down

0 comments on commit 373a252

Please sign in to comment.