diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-11-25 23:36:44 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-11-25 23:36:44 +0100 |
commit | 9a3172260987d2fd2b70a90071128d0201cc2e8f (patch) | |
tree | 92774b42cf6b89468f7a1b2663d8587beac8653f /nest/a-path.c | |
parent | f9c422250bd32978c104ffdc2a801be75dbf9068 (diff) | |
parent | 977b82fba49b22d9548546d88b105945921efaed (diff) |
Merge commit '977b82fb' into wireguard-next-tmp7-1
Diffstat (limited to 'nest/a-path.c')
-rw-r--r-- | nest/a-path.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/nest/a-path.c b/nest/a-path.c index c421b41f..aba2c86d 100644 --- a/nest/a-path.c +++ b/nest/a-path.c @@ -670,6 +670,29 @@ as_path_filter(struct linpool *pool, const struct adata *path, const struct f_va } int +as_path_compare(const struct adata *path1, const struct adata *path2) +{ + uint pos1 = 0; + uint pos2 = 0; + uint val1 = 0; + uint val2 = 0; + + while (1) + { + int res1 = as_path_walk(path1, &pos1, &val1); + int res2 = as_path_walk(path2, &pos2, &val2); + + if (res1 == 0 && res2 == 0) + return 0; + + if (val1 == val2) + continue; + + return val1 < val2 ? -1 : 1; + } +} + +int as_path_walk(const struct adata *path, uint *pos, uint *val) { if (!path) |