]>
git.proxmox.com Git - mirror_frr.git/blob - mgmtd/mgmt_history.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2021 Vmware, Inc.
4 * Pushpasis Sarkar <spushpasis@vmware.com>
5 * Copyright (c) 2023, LabN Consulting, L.L.C.
8 #ifndef _FRR_MGMTD_HISTORY_H_
9 #define _FRR_MGMTD_HISTORY_H_
13 PREDECL_DLIST(mgmt_cmt_infos
);
18 * Rollback specific commit from commit history.
24 * Specific commit id from commit history.
27 * 0 on success, -1 on failure.
29 extern int mgmt_history_rollback_by_id(struct vty
*vty
, const char *cmtid_str
);
32 * Rollback n commits from commit history.
38 * Number of commits to be rolled back.
41 * 0 on success, -1 on failure.
43 extern int mgmt_history_rollback_n(struct vty
*vty
, int num_cmts
);
45 extern void mgmt_history_rollback_complete(bool success
);
48 * Show mgmt commit history.
50 extern void show_mgmt_cmt_history(struct vty
*vty
);
52 extern void mgmt_history_new_record(struct mgmt_ds_ctx
*ds_ctx
);
54 extern void mgmt_history_destroy(void);
55 extern void mgmt_history_init(void);
58 * 012345678901234567890123456789
59 * 2023-12-31T12:12:12,012345678
60 * 20231231121212012345678
62 #define MGMT_LONG_TIME_FMT "%Y-%m-%dT%H:%M:%S"
63 #define MGMT_LONG_TIME_MAX_LEN 30
64 #define MGMT_SHORT_TIME_FMT "%Y%m%d%H%M%S"
65 #define MGMT_SHORT_TIME_MAX_LEN 24
67 static inline const char *
68 mgmt_time_to_string(struct timespec
*tv
, bool long_fmt
, char *buffer
, size_t sz
)
73 localtime_r(&tv
->tv_sec
, &tm
);
76 n
= strftime(buffer
, sz
, MGMT_LONG_TIME_FMT
, &tm
);
77 snprintf(&buffer
[n
], sz
- n
, ",%09lu", tv
->tv_nsec
);
79 n
= strftime(buffer
, sz
, MGMT_SHORT_TIME_FMT
, &tm
);
80 snprintf(&buffer
[n
], sz
- n
, "%09lu", tv
->tv_nsec
);
86 static inline const char *mgmt_realtime_to_string(struct timeval
*tv
, char *buf
,
89 struct timespec ts
= {.tv_sec
= tv
->tv_sec
,
90 .tv_nsec
= tv
->tv_usec
* 1000};
92 return mgmt_time_to_string(&ts
, true, buf
, sz
);
95 #endif /* _FRR_MGMTD_HISTORY_H_ */