]>
Commit | Line | Data |
---|---|---|
0964ad9c DL |
1 | /* |
2 | * SRC-DEST Routing Table | |
3 | * | |
4 | * Copyright (C) 2017 by David Lamparter & Christian Franke, | |
5 | * Open Source Routing / NetDEF Inc. | |
6 | * | |
7 | * This file is part of FreeRangeRouting (FRR) | |
8 | * | |
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 | |
12 | * later version. | |
13 | * | |
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. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with FRR; see the file COPYING. If not, write to the Free | |
21 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
22 | * 02111-1307, USA. | |
23 | */ | |
24 | ||
25 | #ifndef _ZEBRA_SRC_DEST_TABLE_H | |
26 | #define _ZEBRA_SRC_DEST_TABLE_H | |
27 | ||
28 | /* old/IPv4/non-srcdest: | |
29 | * table -> route_node .info -> [obj] | |
30 | * | |
31 | * new/IPv6/srcdest: | |
32 | * table -...-> srcdest_rnode [prefix = dest] .info -> [obj] | |
33 | * .src_table -> | |
34 | * srcdest table -...-> route_node [prefix = src] .info -> [obj] | |
35 | * | |
36 | * non-srcdest routes (src = ::/0) are treated just like before, their | |
37 | * information being directly there in the info pointer. | |
38 | * | |
39 | * srcdest routes are found by looking up destination first, then looking | |
40 | * up the source in the "src_table". src_table contains normal route_nodes, | |
41 | * whose prefix is the _source_ prefix. | |
42 | * | |
43 | * NB: info can be NULL on the destination rnode, if there are only srcdest | |
44 | * routes for a particular destination prefix. | |
45 | */ | |
46 | ||
47 | #include "prefix.h" | |
48 | #include "table.h" | |
49 | ||
50 | #define SRCDEST2STR_BUFFER (2*PREFIX2STR_BUFFER + sizeof(" from ")) | |
51 | ||
52 | /* extended route node for IPv6 srcdest routing */ | |
53 | struct srcdest_rnode; | |
54 | ||
55 | extern route_table_delegate_t _srcdest_dstnode_delegate; | |
56 | extern route_table_delegate_t _srcdest_srcnode_delegate; | |
57 | ||
58 | extern struct route_table *srcdest_table_init(void); | |
59 | extern struct route_node *srcdest_rnode_get(struct route_table *table, | |
78b81eaa | 60 | union prefixptr dst_pu, |
0964ad9c DL |
61 | struct prefix_ipv6 *src_p); |
62 | extern struct route_node *srcdest_rnode_lookup(struct route_table *table, | |
78b81eaa | 63 | union prefixptr dst_pu, |
0964ad9c DL |
64 | struct prefix_ipv6 *src_p); |
65 | extern void srcdest_rnode_prefixes (struct route_node *rn, struct prefix **p, | |
66 | struct prefix **src_p); | |
67 | extern const char *srcdest_rnode2str(struct route_node *rn, char *str, int size); | |
68 | extern struct route_node *srcdest_route_next(struct route_node *rn); | |
69 | ||
70 | static inline int | |
71 | rnode_is_dstnode (struct route_node *rn) | |
72 | { | |
73 | return rn->table->delegate == &_srcdest_dstnode_delegate; | |
74 | } | |
75 | ||
76 | static inline int | |
77 | rnode_is_srcnode (struct route_node *rn) | |
78 | { | |
79 | return rn->table->delegate == &_srcdest_srcnode_delegate; | |
80 | } | |
81 | ||
82 | static inline struct route_table * | |
83 | srcdest_rnode_table (struct route_node *rn) | |
84 | { | |
85 | if (rnode_is_srcnode (rn)) | |
86 | { | |
87 | struct route_node *dst_rn = rn->table->info; | |
88 | return dst_rn->table; | |
89 | } | |
90 | else | |
91 | { | |
92 | return rn->table; | |
93 | } | |
94 | } | |
95 | static inline void * | |
96 | srcdest_rnode_table_info (struct route_node *rn) | |
97 | { | |
98 | return srcdest_rnode_table(rn)->info; | |
99 | } | |
100 | ||
101 | #endif /* _ZEBRA_SRC_DEST_TABLE_H */ |