]>
Commit | Line | Data |
---|---|---|
50261279 PG |
1 | /* zebra table Manager for routing table identifier management |
2 | * Copyright (C) 2018 6WIND | |
3 | * | |
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) | |
7 | * any later version. | |
8 | * | |
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 | |
12 | * more details. | |
13 | * | |
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 | |
17 | */ | |
18 | ||
19 | #ifndef _TABLE_MANAGER_H | |
20 | #define _TABLE_MANAGER_H | |
21 | ||
22 | #include <stdint.h> | |
23 | ||
24 | #include "lib/linklist.h" | |
25 | #include "lib/thread.h" | |
bf094f69 QY |
26 | #include "lib/ns.h" |
27 | ||
28 | #include "zebra/zserv.h" | |
50261279 | 29 | |
51e94aa7 EDP |
30 | #ifdef __cplusplus |
31 | extern "C" { | |
32 | #endif | |
33 | ||
50261279 PG |
34 | /* |
35 | * Table chunk struct | |
36 | * Client daemon which the chunk belongs to can be identified by either | |
37 | * proto (daemon protocol) + instance + VRF. | |
38 | * If the client then passes a non-empty value to keep field when it requests | |
39 | * for chunks, the chunks won't be garbage collected and the client will be | |
40 | * responsible of its release. | |
41 | * Otherwise, if the keep field is not set (value 0) for the chunk, it will be | |
42 | * automatically released when the client disconnects or when it reconnects | |
43 | * (in case it died unexpectedly, we can know it's the same because it will have | |
44 | * the same proto and instance values) | |
45 | */ | |
46 | struct table_manager_chunk { | |
47 | vrf_id_t vrf_id; | |
48 | uint8_t proto; | |
49 | uint16_t instance; | |
50 | uint32_t start; /* First table RT ID of the chunk */ | |
51 | uint32_t end; /* Last table RT ID of the chunk */ | |
52 | }; | |
53 | ||
54 | /* | |
55 | * Main table manager struct | |
56 | * Holds a linked list of table chunks. | |
57 | */ | |
58 | struct table_manager { | |
59 | struct list *lc_list; | |
42d4b30e PG |
60 | uint32_t start; |
61 | uint32_t end; | |
50261279 PG |
62 | }; |
63 | ||
42d4b30e | 64 | void table_manager_enable(struct zebra_vrf *zvrf); |
50261279 | 65 | struct table_manager_chunk *assign_table_chunk(uint8_t proto, uint16_t instance, |
42d4b30e PG |
66 | uint32_t size, |
67 | struct zebra_vrf *zvrf); | |
50261279 | 68 | int release_table_chunk(uint8_t proto, uint16_t instance, uint32_t start, |
42d4b30e | 69 | uint32_t end, struct zebra_vrf *zvrf); |
453844ab | 70 | int release_daemon_table_chunks(struct zserv *client); |
42d4b30e PG |
71 | void table_manager_disable(struct zebra_vrf *zvrf); |
72 | int table_manager_range(struct vty *vty, bool add, struct zebra_vrf *zvrf, | |
73 | const char *min, const char *max); | |
50261279 | 74 | |
51e94aa7 EDP |
75 | #ifdef __cplusplus |
76 | } | |
77 | #endif | |
78 | ||
50261279 | 79 | #endif /* _TABLE_MANAGER_H */ |