2 * SRC-DEST Routing Table
4 * Copyright (C) 2017 by David Lamparter & Christian Franke,
5 * Open Source Routing / NetDEF Inc.
7 * This file is part of FreeRangeRouting (FRR)
9 * FRR is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any
14 * FRR is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; see the file COPYING; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #ifndef _ZEBRA_SRC_DEST_TABLE_H
25 #define _ZEBRA_SRC_DEST_TABLE_H
27 /* old/IPv4/non-srcdest:
28 * table -> route_node .info -> [obj]
31 * table -...-> srcdest_rnode [prefix = dest] .info -> [obj]
33 * srcdest table -...-> route_node [prefix = src] .info -> [obj]
35 * non-srcdest routes (src = ::/0) are treated just like before, their
36 * information being directly there in the info pointer.
38 * srcdest routes are found by looking up destination first, then looking
39 * up the source in the "src_table". src_table contains normal route_nodes,
40 * whose prefix is the _source_ prefix.
42 * NB: info can be NULL on the destination rnode, if there are only srcdest
43 * routes for a particular destination prefix.
53 #define SRCDEST2STR_BUFFER (2*PREFIX2STR_BUFFER + sizeof(" from "))
55 /* extended route node for IPv6 srcdest routing */
58 extern route_table_delegate_t _srcdest_dstnode_delegate
;
59 extern route_table_delegate_t _srcdest_srcnode_delegate
;
61 extern struct route_table
*srcdest_table_init(void);
62 extern struct route_node
*srcdest_rnode_get(struct route_table
*table
,
63 union prefixconstptr dst_pu
,
64 const struct prefix_ipv6
*src_p
);
65 extern struct route_node
*srcdest_rnode_lookup(struct route_table
*table
,
66 union prefixconstptr dst_pu
,
67 const struct prefix_ipv6
*src_p
);
68 extern void srcdest_rnode_prefixes(struct route_node
*rn
,
69 const struct prefix
**p
,
70 const struct prefix
**src_p
);
71 extern const char *srcdest2str(const struct prefix
*dst_p
,
72 const struct prefix_ipv6
*src_p
,
74 extern const char *srcdest_rnode2str(struct route_node
*rn
, char *str
,
76 extern struct route_node
*srcdest_route_next(struct route_node
*rn
);
78 static inline int rnode_is_dstnode(struct route_node
*rn
)
80 return rn
->table
->delegate
== &_srcdest_dstnode_delegate
;
83 static inline int rnode_is_srcnode(struct route_node
*rn
)
85 return rn
->table
->delegate
== &_srcdest_srcnode_delegate
;
88 static inline struct route_table
*srcdest_rnode_table(struct route_node
*rn
)
90 if (rnode_is_srcnode(rn
)) {
91 struct route_node
*dst_rn
=
92 (struct route_node
*)route_table_get_info(rn
->table
);
98 static inline void *srcdest_rnode_table_info(struct route_node
*rn
)
100 return route_table_get_info(srcdest_rnode_table(rn
));
107 #endif /* _ZEBRA_SRC_DEST_TABLE_H */