Line data Source code
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 2623 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 : 72 : /* Inline functions */ 73 0 : static inline unsigned long timeval_elapsed(struct timeval a, struct timeval b) 74 : { 75 0 : return (((a.tv_sec - b.tv_sec) * TIMER_SECOND_MICRO) 76 0 : + (a.tv_usec - b.tv_usec)); 77 : } 78 : 79 : /* 80 : * Remove trailing separator from a string. 81 : * 82 : * str 83 : * A null terminated string. 84 : * 85 : * sep 86 : * Trailing character that needs to be removed. 87 : */ 88 : static inline void mgmt_remove_trailing_separator(char *str, char sep) 89 : { 90 : size_t len; 91 : 92 : len = strlen(str); 93 : if (len && str[len - 1] == sep) 94 : str[len - 1] = '\0'; 95 : } 96 : 97 : /* Prototypes. */ 98 : extern void mgmt_terminate(void); 99 : extern void mgmt_reset(void); 100 : extern time_t mgmt_clock(void); 101 : 102 : extern int mgmt_config_write(struct vty *vty); 103 : extern struct vty *mgmt_vty_read_config(const char *config_file, 104 : char *config_default_dir); 105 : extern void mgmt_master_init(struct event_loop *master, const int buffer_size); 106 : 107 : extern void mgmt_init(void); 108 : extern void mgmt_vty_init(void); 109 : 110 : #endif /* _FRR_MGMTD_H */