]>
Commit | Line | Data |
---|---|---|
1c2facd1 RW |
1 | /* |
2 | * Copyright (C) 2018 NetDEF, Inc. | |
3 | * Renato Westphal | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU General Public License as published by the Free | |
7 | * Software Foundation; either version 2 of the License, or (at your option) | |
8 | * any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | * more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along | |
16 | * with this program; see the file COPYING; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | */ | |
19 | ||
20 | #ifndef _FRR_NORTHBOUND_DB_H_ | |
21 | #define _FRR_NORTHBOUND_DB_H_ | |
22 | ||
23 | #include "northbound.h" | |
24 | ||
25 | /* | |
26 | * Initialize the northbound database. | |
27 | * | |
28 | * Currently the database is used only for storing and retrieving configuration | |
29 | * transactions. | |
30 | * | |
31 | * Returns: | |
32 | * NB_OK on success, NB_ERR otherwise. | |
33 | */ | |
34 | int nb_db_init(void); | |
35 | ||
36 | /* | |
37 | * Save a configuration transaction in the northbound database. | |
38 | * | |
39 | * transaction | |
40 | * Configuration transaction to be saved. | |
41 | * | |
42 | * transaction_id | |
43 | * Output parameter providing the ID of the saved transaction. | |
44 | * | |
45 | * Returns: | |
46 | * NB_OK on success, NB_ERR otherwise. | |
47 | */ | |
48 | int nb_db_transaction_save(const struct nb_transaction *transaction, | |
49 | uint32_t *transaction_id); | |
50 | ||
51 | /* | |
52 | * Load a configuration transaction from the transactions log. | |
53 | * | |
54 | * transaction_id | |
55 | * ID of the transaction to be loaded. | |
56 | * | |
57 | * Returns: | |
58 | * Pointer to newly created configuration or NULL in the case of an error. | |
59 | */ | |
60 | extern struct nb_config *nb_db_transaction_load(uint32_t transaction_id); | |
61 | ||
62 | /* | |
63 | * Delete the specified number of transactions from the transactions log. | |
64 | * | |
65 | * n_oldest | |
66 | * Number of transactions to delete. | |
67 | * | |
68 | * Returns: | |
69 | * NB_OK on success, NB_ERR otherwise. | |
70 | */ | |
71 | extern int nb_db_clear_transactions(unsigned int n_oldest); | |
72 | ||
73 | /* | |
74 | * Specify the maximum number of transactions we want to record in the | |
75 | * transactions log. Note that older transactions can be removed during this | |
76 | * operation. | |
77 | * | |
78 | * max | |
79 | * New upper limit of maximum transactions to log. | |
80 | * | |
81 | * Returns: | |
82 | * NB_OK on success, NB_ERR otherwise. | |
83 | */ | |
84 | extern int nb_db_set_max_transactions(unsigned int max); | |
85 | ||
86 | /* | |
87 | * Iterate over all configuration transactions stored in the northbound | |
88 | * database, sorted in descending order. | |
89 | * | |
90 | * func | |
91 | * Function to call with each configuration transaction. | |
92 | * | |
93 | * arg | |
94 | * Arbitrary argument passed as the first parameter in each call to 'func'. | |
95 | * | |
96 | * Returns: | |
97 | * NB_OK on success, NB_ERR otherwise. | |
98 | */ | |
99 | extern int nb_db_transactions_iterate( | |
100 | void (*func)(void *arg, int transaction_id, const char *client_name, | |
101 | const char *date, const char *comment), | |
102 | void *arg); | |
103 | ||
104 | #endif /* _FRR_NORTHBOUND_DB_H_ */ |