]> git.proxmox.com Git - mirror_frr.git/blame - lib/northbound_db.h
Merge pull request #13278 from FRRouting/mergify/bp/stable/8.5/pr-13269
[mirror_frr.git] / lib / northbound_db.h
CommitLineData
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
5e244469
RW
25#ifdef __cplusplus
26extern "C" {
27#endif
28
1c2facd1
RW
29/*
30 * Initialize the northbound database.
31 *
32 * Currently the database is used only for storing and retrieving configuration
33 * transactions.
34 *
35 * Returns:
36 * NB_OK on success, NB_ERR otherwise.
37 */
38int nb_db_init(void);
39
40/*
41 * Save a configuration transaction in the northbound database.
42 *
43 * transaction
44 * Configuration transaction to be saved.
45 *
46 * transaction_id
47 * Output parameter providing the ID of the saved transaction.
48 *
49 * Returns:
50 * NB_OK on success, NB_ERR otherwise.
51 */
52int nb_db_transaction_save(const struct nb_transaction *transaction,
53 uint32_t *transaction_id);
54
55/*
56 * Load a configuration transaction from the transactions log.
57 *
58 * transaction_id
59 * ID of the transaction to be loaded.
60 *
61 * Returns:
62 * Pointer to newly created configuration or NULL in the case of an error.
63 */
64extern struct nb_config *nb_db_transaction_load(uint32_t transaction_id);
65
66/*
67 * Delete the specified number of transactions from the transactions log.
68 *
69 * n_oldest
70 * Number of transactions to delete.
71 *
72 * Returns:
73 * NB_OK on success, NB_ERR otherwise.
74 */
75extern int nb_db_clear_transactions(unsigned int n_oldest);
76
77/*
78 * Specify the maximum number of transactions we want to record in the
79 * transactions log. Note that older transactions can be removed during this
80 * operation.
81 *
82 * max
83 * New upper limit of maximum transactions to log.
84 *
85 * Returns:
86 * NB_OK on success, NB_ERR otherwise.
87 */
88extern int nb_db_set_max_transactions(unsigned int max);
89
90/*
91 * Iterate over all configuration transactions stored in the northbound
92 * database, sorted in descending order.
93 *
94 * func
95 * Function to call with each configuration transaction.
96 *
97 * arg
98 * Arbitrary argument passed as the first parameter in each call to 'func'.
99 *
100 * Returns:
101 * NB_OK on success, NB_ERR otherwise.
102 */
103extern int nb_db_transactions_iterate(
104 void (*func)(void *arg, int transaction_id, const char *client_name,
105 const char *date, const char *comment),
106 void *arg);
107
5e244469
RW
108#ifdef __cplusplus
109}
110#endif
111
1c2facd1 112#endif /* _FRR_NORTHBOUND_DB_H_ */