From 080c9a7afecc87c5aa2bafe2a31e73dc267a41fb Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Tue, 23 Apr 2024 13:23:09 +0200 Subject: [PATCH] ospf meta file temp --- yang/show_memory_meta.c | 20 +++++++++ yang/show_ospf.yang | 92 +++++++++++++++++++++-------------------- yang/show_ospf_meta.c | 53 ++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 45 deletions(-) create mode 100644 yang/show_memory_meta.c create mode 100644 yang/show_ospf_meta.c diff --git a/yang/show_memory_meta.c b/yang/show_memory_meta.c new file mode 100644 index 00000000..8d2b6a3b --- /dev/null +++ b/yang/show_memory_meta.c @@ -0,0 +1,20 @@ + +UYTC_MODULE(show_memory) { + UYTC_GROUPING(memory, resmem) { + UYTC_LEAF(effective, resmem.effective); + UYTC_LEAF(overhead, resmem.overhead); + } + + UYTC_CONTAINER(message, msg) { + UYTC_LEAF(header, "BIRD memory usage"); + UYTC_CONTAINER(body, body) { + UYTC_LEAF(routing_tables, rmemsize(rt_table_pool)); + UYTC_LEAF(route_attributes, rmemsize(rta_pool)); + ...; +#ifdef HAVE_MMAP + UYTC_LEAF(standby_memory, (struct resmem) { .overhead = page_size * *pages_kept }); +#endif + UYTC_LEAF(total, rmemsize(&root_pool)); + } + } +} diff --git a/yang/show_ospf.yang b/yang/show_ospf.yang index cf8d808c..b8b32889 100644 --- a/yang/show_ospf.yang +++ b/yang/show_ospf.yang @@ -32,53 +32,55 @@ module show_ospf { uses router; uses distance; - list vlink { - key "vlink"; - leaf vlink { - type int32; - } - uses metric; - } + list rt { + key "dummy_yang_id"; + leaf dummy_yang_id { + type int32; + } + leaf metric { + type int32; + } + choice rt_type { + case vlink { + grouping vlink { + leaf vlink { + type int32; + } + } + } - list router_metric { - key "router"; - uses router; - uses metric; - } + case router { + grouping router_metric { + uses router; + } + } - list network { - key "dummy_yang_id"; - leaf dummy_yang_id { - type int32; - } - leaf network { - type int32; - } - choice len_nif { - case len { - leaf len { - type int32; - } - } - case nif { - leaf nif { - type int32; - } - } - } - leaf metric { - mandatory false; - type int32; - } - list stubnet { - key "stubnet"; - leaf stubnet { - type int32; - } - leaf len { - type int32; - } - uses metric; + case network { + grouping network { + leaf network { + type ipv4; + } + leaf len { + type int32; + mandatory false; + } + leaf nif { + type int32; + mandatory false; + } + } + } + + case stubnet { + grouping stubnet { + leaf stubnet { + type ipv4; + } + leaf len { + type int32; + } + } + } } } } diff --git a/yang/show_ospf_meta.c b/yang/show_ospf_meta.c new file mode 100644 index 00000000..acf3c5b0 --- /dev/null +++ b/yang/show_ospf_meta.c @@ -0,0 +1,53 @@ +static inline void +show_lsa_router_cbor(UYTC_CONTEXT_TYPE UYTC_CONTEXT, struct top_hash_entry *he, int verbose) +{ + UYTC_GROUPING(lsa_router) { + UYTC_ITEM(router, he->lsa.rt); + + ...; + + lsa_walk_rt_init(p, he, &rtl); + int i = 0; + while (lsa_walk_rt(&rtl)) + { + i++; + UYTC_LIST_ITEM(rt) { + UYTC_LEAF(dummy_yang_id, i); + UYTC_LEAF(metric, rtl.metric); + switch (rtl.type) { + case LSART_VLNK: + UYTC_CHOICE_ITEM(rt_type, vlink) { + UYTC_GROUPING(vlink) { + UYTC_LEAF(vlink, rtl.id); + UYTC_LEAF(name, rtl.name); + } + } + break; + + case LSART_PTP: + ...; + } + } + } + } +} + + +for (i = 0; i < j1; i++) { + UYTC_LIST_ITEM(areas) { + struct top_hash_entry *he = hea[i]; + UYTC_LEAF(dummy_yang_id, i); + UYTC_LEAF(area, he->domain); + + switch (he->lsa_type) + { + case LSA_T_RT: + UYTC_CHOICE_ITEM(lsa_type, rt, show_lsa_router_cbor(UYTC_CONTEXT, he)); + break; + + case LSA_T_NET: + UYTC_CHOICE_ITEM(lsa_type, net, show_lsa_network_cbor(UYTC_CONTEXT, he, ospf2)); + break; + } + } +}