]> git.proxmox.com Git - mirror_frr.git/blame - mgmtd/mgmt.h
Merge pull request #13611 from donaldsharp/logger_warn
[mirror_frr.git] / mgmtd / mgmt.h
CommitLineData
1c84efe4
CH
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
cfa0facb 12#include "debug.h"
1c84efe4 13#include "vrf.h"
1c84efe4 14#include "defaults.h"
ef43a632 15#include "stream.h"
1c84efe4
CH
16
17#include "mgmtd/mgmt_memory.h"
74335ceb
YR
18#include "mgmtd/mgmt_defines.h"
19#include "mgmtd/mgmt_history.h"
20#include "mgmtd/mgmt_txn.h"
1c84efe4
CH
21#include "mgmtd/mgmt_ds.h"
22
23#define MGMTD_VTY_PORT 2622
24#define MGMTD_SOCKET_BUF_SIZE 65535
74335ceb 25#define MGMTD_MAX_COMMIT_LIST 10
1c84efe4 26
cfa0facb
CH
27extern struct debug mgmt_debug_be;
28extern struct debug mgmt_debug_ds;
29extern struct debug mgmt_debug_fe;
30extern 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)
1c84efe4 36
74335ceb
YR
37struct mgmt_txn_ctx;
38
1c84efe4
CH
39/*
40 * MGMTD master for system wide configurations and variables.
41 */
42struct mgmt_master {
cd9d0537 43 struct event_loop *master;
1c84efe4
CH
44
45 /* How big should we set the socket buffer size */
46 uint32_t socket_buffer;
47
74335ceb
YR
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
1c84efe4
CH
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 */
74335ceb
YR
65
66 /* List of commit infos */
67 struct mgmt_cmt_infos_head cmts; /* List of last 10 commits executed. */
1c84efe4
CH
68};
69
70extern struct mgmt_master *mm;
8033bf39
CH
71extern char const *const mgmt_daemons[];
72extern uint mgmt_daemons_count;
1c84efe4 73
ef43a632
CH
74/* Inline functions */
75static 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
1c84efe4
CH
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 */
90static 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. */
100extern void mgmt_terminate(void);
101extern void mgmt_reset(void);
102extern time_t mgmt_clock(void);
103
104extern int mgmt_config_write(struct vty *vty);
105
cd9d0537 106extern void mgmt_master_init(struct event_loop *master, const int buffer_size);
1c84efe4
CH
107
108extern void mgmt_init(void);
109extern void mgmt_vty_init(void);
110
1c84efe4 111#endif /* _FRR_MGMTD_H */