1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * MGMTD Frontend Client Library api interfaces
4 * Copyright (C) 2021 Vmware, Inc.
5 * Pushpasis Sarkar <spushpasis@vmware.com>
8 #ifndef _FRR_MGMTD_FE_CLIENT_H_
9 #define _FRR_MGMTD_FE_CLIENT_H_
17 #include "mgmtd/mgmt_defines.h"
19 /***************************************************************
21 ***************************************************************/
24 * The server port MGMTD daemon is listening for Backend Client
28 #define MGMTD_FE_CLIENT_ERROR_STRING_MAX_LEN 32
30 #define MGMTD_FE_DEFAULT_CONN_RETRY_INTVL_SEC 5
32 #define MGMTD_FE_MSG_PROC_DELAY_USEC 10
33 #define MGMTD_FE_MAX_NUM_MSG_PROC 500
35 #define MGMTD_FE_MSG_WRITE_DELAY_MSEC 1
36 #define MGMTD_FE_MAX_NUM_MSG_WRITE 100
38 #define GMGD_FE_MAX_NUM_REQ_ITEMS 64
40 #define MGMTD_FE_MSG_MAX_LEN 9000
42 #define MGMTD_SOCKET_FE_SEND_BUF_SIZE 65535
43 #define MGMTD_SOCKET_FE_RECV_BUF_SIZE MGMTD_SOCKET_FE_SEND_BUF_SIZE
45 /***************************************************************
47 ***************************************************************/
49 #define MGMTD_SESSION_ID_NONE 0
51 #define MGMTD_CLIENT_ID_NONE 0
53 #define MGMTD_DS_NONE MGMTD__DATASTORE_ID__DS_NONE
54 #define MGMTD_DS_RUNNING MGMTD__DATASTORE_ID__RUNNING_DS
55 #define MGMTD_DS_CANDIDATE MGMTD__DATASTORE_ID__CANDIDATE_DS
56 #define MGMTD_DS_OPERATIONAL MGMTD__DATASTORE_ID__OPERATIONAL_DS
57 #define MGMTD_DS_MAX_ID MGMTD_DS_OPERATIONAL + 1
60 * All the client specific information this library needs to
61 * initialize itself, setup connection with MGMTD FrontEnd interface
62 * and carry on all required procedures appropriately.
64 * FrontEnd clients need to initialise a instance of this structure
65 * with appropriate data and pass it while calling the API
66 * to initialize the library (See mgmt_fe_client_lib_init for
69 struct mgmt_fe_client_params
{
70 char name
[MGMTD_CLIENT_NAME_MAX_LEN
];
72 unsigned long conn_retry_intvl_sec
;
74 void (*client_connect_notify
)(uintptr_t lib_hndl
,
78 void (*client_session_notify
)(uintptr_t lib_hndl
,
81 bool create
, bool success
,
83 uintptr_t user_session_ctx
);
85 void (*lock_ds_notify
)(uintptr_t lib_hndl
, uintptr_t user_data
,
86 uint64_t client_id
, uintptr_t session_id
,
87 uintptr_t user_session_ctx
, uint64_t req_id
,
88 bool lock_ds
, bool success
,
89 Mgmtd__DatastoreId ds_id
, char *errmsg_if_any
);
91 void (*set_config_notify
)(uintptr_t lib_hndl
, uintptr_t user_data
,
92 uint64_t client_id
, uintptr_t session_id
,
93 uintptr_t user_session_ctx
, uint64_t req_id
,
94 bool success
, Mgmtd__DatastoreId ds_id
,
97 void (*commit_config_notify
)(
98 uintptr_t lib_hndl
, uintptr_t user_data
, uint64_t client_id
,
99 uintptr_t session_id
, uintptr_t user_session_ctx
,
100 uint64_t req_id
, bool success
, Mgmtd__DatastoreId src_ds_id
,
101 Mgmtd__DatastoreId dst_ds_id
, bool validate_only
,
102 char *errmsg_if_any
);
104 enum mgmt_result (*get_data_notify
)(
105 uintptr_t lib_hndl
, uintptr_t user_data
, uint64_t client_id
,
106 uintptr_t session_id
, uintptr_t user_session_ctx
,
107 uint64_t req_id
, bool success
, Mgmtd__DatastoreId ds_id
,
108 Mgmtd__YangData
**yang_data
, size_t num_data
, int next_key
,
109 char *errmsg_if_any
);
111 enum mgmt_result (*data_notify
)(
112 uint64_t client_id
, uint64_t session_id
, uintptr_t user_data
,
113 uint64_t req_id
, Mgmtd__DatastoreId ds_id
,
114 Mgmtd__YangData
**yang_data
, size_t num_data
);
117 /***************************************************************
119 ***************************************************************/
122 * Initialize library and try connecting with MGMTD FrontEnd interface.
125 * Frontend client parameters.
131 * Frontend client lib handler (nothing but address of mgmt_fe_client_ctx)
133 extern uintptr_t mgmt_fe_client_lib_init(struct mgmt_fe_client_params
*params
,
134 struct event_loop
*master_thread
);
137 * Create a new Session for a Frontend Client connection.
140 * Client library handler.
143 * Unique identifier of client.
149 * MGMTD_SUCCESS on success, MGMTD_* otherwise.
151 extern enum mgmt_result
mgmt_fe_create_client_session(uintptr_t lib_hndl
,
156 * Delete an existing Session for a Frontend Client connection.
159 * Client library handler.
162 * Unique identifier of client.
165 * MGMTD_SUCCESS on success, MGMTD_* otherwise.
167 extern enum mgmt_result
mgmt_fe_destroy_client_session(uintptr_t lib_hndl
,
171 * Send UN/LOCK_DS_REQ to MGMTD for a specific Datastore DS.
174 * Client library handler.
183 * Datastore ID (Running/Candidate/Oper/Startup)
186 * TRUE for lock request, FALSE for unlock request.
189 * MGMTD_SUCCESS on success, MGMTD_* otherwise.
191 extern enum mgmt_result
192 mgmt_fe_lock_ds(uintptr_t lib_hndl
, uintptr_t session_id
, uint64_t req_id
,
193 Mgmtd__DatastoreId ds_id
, bool lock_ds
);
196 * Send SET_CONFIG_REQ to MGMTD for one or more config data(s).
199 * Client library handler.
208 * Datastore ID (Running/Candidate/Oper/Startup)
211 * Details regarding the SET_CONFIG_REQ.
214 * Number of config requests.
217 * TRUE for implicit commit, FALSE otherwise.
220 * Destination Datastore ID where data needs to be set.
223 * MGMTD_SUCCESS on success, MGMTD_* otherwise.
225 extern enum mgmt_result
226 mgmt_fe_set_config_data(uintptr_t lib_hndl
, uintptr_t session_id
,
227 uint64_t req_id
, Mgmtd__DatastoreId ds_id
,
228 Mgmtd__YangCfgDataReq
**config_req
, int num_req
,
229 bool implicit_commit
, Mgmtd__DatastoreId dst_ds_id
);
232 * Send SET_COMMMIT_REQ to MGMTD for one or more config data(s).
235 * Client library handler.
244 * Source datastore ID from where data needs to be committed from.
247 * Destination datastore ID where data needs to be committed to.
250 * TRUE if data needs to be validated only, FALSE otherwise.
253 * TRUE if need to restore Src DS back to Dest DS, FALSE otherwise.
256 * MGMTD_SUCCESS on success, MGMTD_* otherwise.
258 extern enum mgmt_result
259 mgmt_fe_commit_config_data(uintptr_t lib_hndl
, uintptr_t session_id
,
260 uint64_t req_id
, Mgmtd__DatastoreId src_ds_id
,
261 Mgmtd__DatastoreId dst_ds_id
, bool validate_only
,
265 * Send GET_CONFIG_REQ to MGMTD for one or more config data item(s).
268 * Client library handler.
277 * Datastore ID (Running/Candidate)
280 * Get config requested.
283 * Number of get config requests.
286 * MGMTD_SUCCESS on success, MGMTD_* otherwise.
288 extern enum mgmt_result
289 mgmt_fe_get_config_data(uintptr_t lib_hndl
, uintptr_t session_id
,
290 uint64_t req_id
, Mgmtd__DatastoreId ds_id
,
291 Mgmtd__YangGetDataReq
**data_req
, int num_reqs
);
294 * Send GET_DATA_REQ to MGMTD for one or more data item(s).
296 * Similar to get config request but supports getting data
297 * from operational ds aka backend clients directly.
299 extern enum mgmt_result
300 mgmt_fe_get_data(uintptr_t lib_hndl
, uintptr_t session_id
, uint64_t req_id
,
301 Mgmtd__DatastoreId ds_id
, Mgmtd__YangGetDataReq
**data_req
,
305 * Send NOTIFY_REGISTER_REQ to MGMTD daemon.
308 * Client library handler.
320 * TRUE if registering, FALSE otherwise.
323 * Details of the YANG notification data.
326 * Number of data requests.
329 * MGMTD_SUCCESS on success, MGMTD_* otherwise.
331 extern enum mgmt_result
332 mgmt_fe_register_yang_notify(uintptr_t lib_hndl
, uintptr_t session_id
,
333 uint64_t req_id
, Mgmtd__DatastoreId ds_id
,
335 Mgmtd__YangDataXPath
**data_req
, int num_reqs
);
338 * Destroy library and cleanup everything.
340 extern void mgmt_fe_client_lib_destroy(uintptr_t lib_hndl
);
346 #endif /* _FRR_MGMTD_FE_CLIENT_H_ */