]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
1c2facd1 RW |
2 | /* |
3 | * Copyright (C) 2018 NetDEF, Inc. | |
4 | * Renato Westphal | |
1c2facd1 RW |
5 | */ |
6 | ||
7 | #ifndef _FRR_NORTHBOUND_DB_H_ | |
8 | #define _FRR_NORTHBOUND_DB_H_ | |
9 | ||
10 | #include "northbound.h" | |
11 | ||
5e244469 RW |
12 | #ifdef __cplusplus |
13 | extern "C" { | |
14 | #endif | |
15 | ||
1c2facd1 RW |
16 | /* |
17 | * Initialize the northbound database. | |
18 | * | |
19 | * Currently the database is used only for storing and retrieving configuration | |
20 | * transactions. | |
21 | * | |
22 | * Returns: | |
23 | * NB_OK on success, NB_ERR otherwise. | |
24 | */ | |
25 | int nb_db_init(void); | |
26 | ||
27 | /* | |
28 | * Save a configuration transaction in the northbound database. | |
29 | * | |
30 | * transaction | |
31 | * Configuration transaction to be saved. | |
32 | * | |
33 | * transaction_id | |
34 | * Output parameter providing the ID of the saved transaction. | |
35 | * | |
36 | * Returns: | |
37 | * NB_OK on success, NB_ERR otherwise. | |
38 | */ | |
39 | int nb_db_transaction_save(const struct nb_transaction *transaction, | |
40 | uint32_t *transaction_id); | |
41 | ||
42 | /* | |
43 | * Load a configuration transaction from the transactions log. | |
44 | * | |
45 | * transaction_id | |
46 | * ID of the transaction to be loaded. | |
47 | * | |
48 | * Returns: | |
49 | * Pointer to newly created configuration or NULL in the case of an error. | |
50 | */ | |
51 | extern struct nb_config *nb_db_transaction_load(uint32_t transaction_id); | |
52 | ||
53 | /* | |
54 | * Delete the specified number of transactions from the transactions log. | |
55 | * | |
56 | * n_oldest | |
57 | * Number of transactions to delete. | |
58 | * | |
59 | * Returns: | |
60 | * NB_OK on success, NB_ERR otherwise. | |
61 | */ | |
62 | extern int nb_db_clear_transactions(unsigned int n_oldest); | |
63 | ||
64 | /* | |
65 | * Specify the maximum number of transactions we want to record in the | |
66 | * transactions log. Note that older transactions can be removed during this | |
67 | * operation. | |
68 | * | |
69 | * max | |
70 | * New upper limit of maximum transactions to log. | |
71 | * | |
72 | * Returns: | |
73 | * NB_OK on success, NB_ERR otherwise. | |
74 | */ | |
75 | extern int nb_db_set_max_transactions(unsigned int max); | |
76 | ||
77 | /* | |
78 | * Iterate over all configuration transactions stored in the northbound | |
79 | * database, sorted in descending order. | |
80 | * | |
81 | * func | |
82 | * Function to call with each configuration transaction. | |
83 | * | |
84 | * arg | |
85 | * Arbitrary argument passed as the first parameter in each call to 'func'. | |
86 | * | |
87 | * Returns: | |
88 | * NB_OK on success, NB_ERR otherwise. | |
89 | */ | |
90 | extern int nb_db_transactions_iterate( | |
91 | void (*func)(void *arg, int transaction_id, const char *client_name, | |
92 | const char *date, const char *comment), | |
93 | void *arg); | |
94 | ||
5e244469 RW |
95 | #ifdef __cplusplus |
96 | } | |
97 | #endif | |
98 | ||
1c2facd1 | 99 | #endif /* _FRR_NORTHBOUND_DB_H_ */ |