1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * SRC-DEST Routing Table
5 * Copyright (C) 2017 by David Lamparter & Christian Franke,
6 * Open Source Routing / NetDEF Inc.
8 * This file is part of FRRouting (FRR)
11 #ifndef _ZEBRA_SRC_DEST_TABLE_H
12 #define _ZEBRA_SRC_DEST_TABLE_H
14 /* old/IPv4/non-srcdest:
15 * table -> route_node .info -> [obj]
18 * table -...-> srcdest_rnode [prefix = dest] .info -> [obj]
20 * srcdest table -...-> route_node [prefix = src] .info -> [obj]
22 * non-srcdest routes (src = ::/0) are treated just like before, their
23 * information being directly there in the info pointer.
25 * srcdest routes are found by looking up destination first, then looking
26 * up the source in the "src_table". src_table contains normal route_nodes,
27 * whose prefix is the _source_ prefix.
29 * NB: info can be NULL on the destination rnode, if there are only srcdest
30 * routes for a particular destination prefix.
40 #define SRCDEST2STR_BUFFER (2*PREFIX2STR_BUFFER + sizeof(" from "))
42 /* extended route node for IPv6 srcdest routing */
45 extern route_table_delegate_t _srcdest_dstnode_delegate
;
46 extern route_table_delegate_t _srcdest_srcnode_delegate
;
48 extern struct route_table
*srcdest_table_init(void);
49 extern struct route_node
*srcdest_rnode_get(struct route_table
*table
,
50 union prefixconstptr dst_pu
,
51 const struct prefix_ipv6
*src_p
);
52 extern struct route_node
*srcdest_rnode_lookup(struct route_table
*table
,
53 union prefixconstptr dst_pu
,
54 const struct prefix_ipv6
*src_p
);
55 extern void srcdest_rnode_prefixes(const struct route_node
*rn
,
56 const struct prefix
**p
,
57 const struct prefix
**src_p
);
58 extern const char *srcdest2str(const struct prefix
*dst_p
,
59 const struct prefix_ipv6
*src_p
,
61 extern const char *srcdest_rnode2str(const struct route_node
*rn
, char *str
,
63 extern struct route_node
*srcdest_route_next(struct route_node
*rn
);
65 static inline int rnode_is_dstnode(const struct route_node
*rn
)
67 return rn
->table
->delegate
== &_srcdest_dstnode_delegate
;
70 static inline int rnode_is_srcnode(const struct route_node
*rn
)
72 return rn
->table
->delegate
== &_srcdest_srcnode_delegate
;
75 static inline struct route_table
*srcdest_rnode_table(struct route_node
*rn
)
77 if (rnode_is_srcnode(rn
)) {
78 struct route_node
*dst_rn
=
79 (struct route_node
*)route_table_get_info(rn
->table
);
85 static inline void *srcdest_rnode_table_info(struct route_node
*rn
)
87 return route_table_get_info(srcdest_rnode_table(rn
));
90 extern struct route_table
*srcdest_srcnode_table(struct route_node
*rn
);
96 #endif /* _ZEBRA_SRC_DEST_TABLE_H */