]> git.proxmox.com Git - mirror_frr.git/blob - mgmtd/mgmt.h
zebra: accept LSP entries with an mpls-less outgoing interface
[mirror_frr.git] / mgmtd / mgmt.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * MGMTD message definition header.
4 *
5 * Copyright (C) 2021 Vmware, Inc.
6 * Pushpasis Sarkar <spushpasis@vmware.com>
7 */
8
9 #ifndef _FRR_MGMTD_H
10 #define _FRR_MGMTD_H
11
12 #include "debug.h"
13 #include "vrf.h"
14 #include "defaults.h"
15 #include "stream.h"
16
17 #include "mgmtd/mgmt_memory.h"
18 #include "mgmtd/mgmt_defines.h"
19 #include "mgmtd/mgmt_history.h"
20 #include "mgmtd/mgmt_txn.h"
21 #include "mgmtd/mgmt_ds.h"
22
23 #define MGMTD_VTY_PORT 2622
24 #define MGMTD_SOCKET_BUF_SIZE 65535
25 #define MGMTD_MAX_COMMIT_LIST 10
26
27 extern struct debug mgmt_debug_be;
28 extern struct debug mgmt_debug_ds;
29 extern struct debug mgmt_debug_fe;
30 extern struct debug mgmt_debug_txn;
31
32 #define MGMT_DEBUG_BE_CHECK() DEBUG_MODE_CHECK(&mgmt_debug_be, DEBUG_MODE_ALL)
33 #define MGMT_DEBUG_DS_CHECK() DEBUG_MODE_CHECK(&mgmt_debug_ds, DEBUG_MODE_ALL)
34 #define MGMT_DEBUG_FE_CHECK() DEBUG_MODE_CHECK(&mgmt_debug_fe, DEBUG_MODE_ALL)
35 #define MGMT_DEBUG_TXN_CHECK() DEBUG_MODE_CHECK(&mgmt_debug_tx, DEBUG_MODE_ALL)
36
37 struct mgmt_txn_ctx;
38
39 /*
40 * MGMTD master for system wide configurations and variables.
41 */
42 struct mgmt_master {
43 struct event_loop *master;
44
45 /* How big should we set the socket buffer size */
46 uint32_t socket_buffer;
47
48 /* The single instance of config transaction allowed at any time */
49 struct mgmt_txns_head txn_list;
50
51 /* Map of Transactions and its ID */
52 struct hash *txn_hash;
53 uint64_t next_txn_id;
54
55 /* The single instance of config transaction allowed at any time */
56 struct mgmt_txn_ctx *cfg_txn;
57
58 /* Datastores */
59 struct mgmt_ds_ctx *running_ds;
60 struct mgmt_ds_ctx *candidate_ds;
61 struct mgmt_ds_ctx *oper_ds;
62
63 bool terminating; /* global flag that sigint terminate seen */
64 bool perf_stats_en; /* to enable performance stats measurement */
65
66 /* List of commit infos */
67 struct mgmt_cmt_infos_head cmts; /* List of last 10 commits executed. */
68 };
69
70 extern struct mgmt_master *mm;
71 extern char const *const mgmt_daemons[];
72 extern uint mgmt_daemons_count;
73
74 /* Inline functions */
75 static inline unsigned long timeval_elapsed(struct timeval a, struct timeval b)
76 {
77 return (((a.tv_sec - b.tv_sec) * TIMER_SECOND_MICRO)
78 + (a.tv_usec - b.tv_usec));
79 }
80
81 /*
82 * Remove trailing separator from a string.
83 *
84 * str
85 * A null terminated string.
86 *
87 * sep
88 * Trailing character that needs to be removed.
89 */
90 static inline void mgmt_remove_trailing_separator(char *str, char sep)
91 {
92 size_t len;
93
94 len = strlen(str);
95 if (len && str[len - 1] == sep)
96 str[len - 1] = '\0';
97 }
98
99 /* Prototypes. */
100 extern void mgmt_terminate(void);
101 extern void mgmt_reset(void);
102 extern time_t mgmt_clock(void);
103
104 extern int mgmt_config_write(struct vty *vty);
105
106 extern void mgmt_master_init(struct event_loop *master, const int buffer_size);
107
108 extern void mgmt_init(void);
109 extern void mgmt_vty_init(void);
110
111 #endif /* _FRR_MGMTD_H */