]> git.proxmox.com Git - mirror_frr.git/blob - mgmtd/mgmt.c
lib: Remove tests for ipv[4|6]_prefix_table
[mirror_frr.git] / mgmtd / mgmt.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * FRR Management Daemon (MGMTD) program
4 *
5 * Copyright (C) 2021 Vmware, Inc.
6 * Pushpasis Sarkar
7 */
8
9 #include <zebra.h>
10 #include "mgmtd/mgmt.h"
11 #include "mgmtd/mgmt_be_server.h"
12 #include "mgmtd/mgmt_be_adapter.h"
13 #include "mgmtd/mgmt_fe_server.h"
14 #include "mgmtd/mgmt_fe_adapter.h"
15 #include "mgmtd/mgmt_ds.h"
16 #include "mgmtd/mgmt_history.h"
17 #include "mgmtd/mgmt_memory.h"
18
19 bool mgmt_debug_be;
20 bool mgmt_debug_fe;
21 bool mgmt_debug_ds;
22 bool mgmt_debug_txn;
23
24 /* MGMTD process wide configuration. */
25 static struct mgmt_master mgmt_master;
26
27 /* MGMTD process wide configuration pointer to export. */
28 struct mgmt_master *mm;
29
30 void mgmt_master_init(struct thread_master *master, const int buffer_size)
31 {
32 memset(&mgmt_master, 0, sizeof(struct mgmt_master));
33
34 mm = &mgmt_master;
35 mm->master = master;
36 mm->terminating = false;
37 mm->socket_buffer = buffer_size;
38 mm->perf_stats_en = true;
39 }
40
41 void mgmt_init(void)
42 {
43
44 /*
45 * Allocates some vital data structures used by peer commands in
46 * vty_init
47 */
48 vty_init_mgmt_fe();
49
50 /* Initialize datastores */
51 mgmt_ds_init(mm);
52
53 /* Initialize history */
54 mgmt_history_init();
55
56 /* Initialize MGMTD Transaction module */
57 mgmt_txn_init(mm, mm->master);
58
59 /* Initialize the MGMTD Backend Adapter Module */
60 mgmt_be_adapter_init(mm->master);
61
62 /* Initialize the MGMTD Frontend Adapter Module */
63 mgmt_fe_adapter_init(mm->master, mm);
64
65 /* Start the MGMTD Backend Server for clients to connect */
66 mgmt_be_server_init(mm->master);
67
68 /* Start the MGMTD Frontend Server for clients to connect */
69 mgmt_fe_server_init(mm->master);
70
71 /* MGMTD VTY commands installation. */
72 mgmt_vty_init();
73 }
74
75 void mgmt_terminate(void)
76 {
77 mgmt_fe_server_destroy();
78 mgmt_fe_adapter_destroy();
79 mgmt_be_server_destroy();
80 mgmt_be_adapter_destroy();
81 mgmt_txn_destroy();
82 mgmt_history_destroy();
83 mgmt_ds_destroy();
84 }