]>
git.proxmox.com Git - mirror_frr.git/blob - pathd/path_nb_state.c
60f04f45c15b6ef22432422fdb5f82b9ec2c2d96
2 * Copyright (C) 2020 NetDEF, Inc.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along
15 * with this program; see the file COPYING; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "northbound.h"
28 #include "pathd/pathd.h"
29 #include "pathd/path_nb.h"
32 * XPath: /frr-pathd:pathd/srte/segment-list
34 const void *pathd_srte_segment_list_get_next(struct nb_cb_get_next_args
*args
)
36 struct srte_segment_list
*segment_list
=
37 (struct srte_segment_list
*)args
->list_entry
;
39 if (args
->list_entry
== NULL
)
41 RB_MIN(srte_segment_list_head
, &srte_segment_lists
);
43 segment_list
= RB_NEXT(srte_segment_list_head
, segment_list
);
48 int pathd_srte_segment_list_get_keys(struct nb_cb_get_keys_args
*args
)
50 const struct srte_segment_list
*segment_list
=
51 (struct srte_segment_list
*)args
->list_entry
;
54 snprintf(args
->keys
->key
[0], sizeof(args
->keys
->key
[0]), "%s",
61 pathd_srte_segment_list_lookup_entry(struct nb_cb_lookup_entry_args
*args
)
63 return srte_segment_list_find(args
->keys
->key
[0]);
67 * XPath: /frr-pathd:pathd/srte/policy
69 const void *pathd_srte_policy_get_next(struct nb_cb_get_next_args
*args
)
71 struct srte_policy
*policy
= (struct srte_policy
*)args
->list_entry
;
73 if (args
->list_entry
== NULL
)
74 policy
= RB_MIN(srte_policy_head
, &srte_policies
);
76 policy
= RB_NEXT(srte_policy_head
, policy
);
81 int pathd_srte_policy_get_keys(struct nb_cb_get_keys_args
*args
)
83 const struct srte_policy
*policy
=
84 (struct srte_policy
*)args
->list_entry
;
87 snprintf(args
->keys
->key
[0], sizeof(args
->keys
->key
[0]), "%u",
89 ipaddr2str(&policy
->endpoint
, args
->keys
->key
[1],
90 sizeof(args
->keys
->key
[1]));
95 const void *pathd_srte_policy_lookup_entry(struct nb_cb_lookup_entry_args
*args
)
98 struct ipaddr endpoint
;
100 color
= yang_str2uint32(args
->keys
->key
[0]);
101 yang_str2ip(args
->keys
->key
[1], &endpoint
);
103 return srte_policy_find(color
, &endpoint
);
107 * XPath: /frr-pathd:pathd/srte/policy/is-operational
110 pathd_srte_policy_is_operational_get_elem(struct nb_cb_get_elem_args
*args
)
112 struct srte_policy
*policy
= (struct srte_policy
*)args
->list_entry
;
113 bool is_operational
= false;
115 if (policy
->status
== SRTE_POLICY_STATUS_UP
)
116 is_operational
= true;
118 return yang_data_new_bool(args
->xpath
, is_operational
);
122 * XPath: /frr-pathd:pathd/srte/policy/candidate-path
125 pathd_srte_policy_candidate_path_get_next(struct nb_cb_get_next_args
*args
)
127 struct srte_policy
*policy
=
128 (struct srte_policy
*)args
->parent_list_entry
;
129 struct srte_candidate
*candidate
=
130 (struct srte_candidate
*)args
->list_entry
;
132 if (args
->list_entry
== NULL
)
134 RB_MIN(srte_candidate_head
, &policy
->candidate_paths
);
136 candidate
= RB_NEXT(srte_candidate_head
, candidate
);
141 int pathd_srte_policy_candidate_path_get_keys(struct nb_cb_get_keys_args
*args
)
143 const struct srte_candidate
*candidate
=
144 (struct srte_candidate
*)args
->list_entry
;
147 snprintf(args
->keys
->key
[0], sizeof(args
->keys
->key
[0]), "%u",
148 candidate
->preference
);
153 const void *pathd_srte_policy_candidate_path_lookup_entry(
154 struct nb_cb_lookup_entry_args
*args
)
156 struct srte_policy
*policy
=
157 (struct srte_policy
*)args
->parent_list_entry
;
160 preference
= yang_str2uint32(args
->keys
->key
[0]);
162 return srte_candidate_find(policy
, preference
);
166 * XPath: /frr-pathd:pathd/srte/policy/candidate_path/is-best-candidate-path
169 pathd_srte_policy_candidate_path_is_best_candidate_path_get_elem(
170 struct nb_cb_get_elem_args
*args
)
172 struct srte_candidate
*candidate
=
173 (struct srte_candidate
*)args
->list_entry
;
175 return yang_data_new_bool(
176 args
->xpath
, CHECK_FLAG(candidate
->flags
, F_CANDIDATE_BEST
));
180 * XPath: /frr-pathd:pathd/srte/policy/candidate-path/discriminator
182 struct yang_data
*pathd_srte_policy_candidate_path_discriminator_get_elem(
183 struct nb_cb_get_elem_args
*args
)
185 struct srte_candidate
*candidate
=
186 (struct srte_candidate
*)args
->list_entry
;
188 return yang_data_new_uint32(args
->xpath
, candidate
->discriminator
);