libnetconf
0.10.0-146_trunk
NETCONF Library
|
Public callbacks for the data store. More...
#include <datastore_custom.h>
Data Fields | |
int(* | copyconfig )(void *data, NC_DATASTORE target, NC_DATASTORE source, char *config, struct nc_err **error) |
Copy config from one data store to another. More... | |
int(* | deleteconfig )(void *data, NC_DATASTORE target, struct nc_err **error) |
Make the given data source empty. More... | |
int(* | editconfig )(void *data, const nc_rpc *rpc, NC_DATASTORE target, const char *config, NC_EDIT_DEFOP_TYPE defop, NC_EDIT_ERROPT_TYPE errop, struct nc_err **error) |
Perform the editconfig operation. More... | |
void(* | free )(void *data) |
Called after the last use of the data store. More... | |
char *(* | getconfig )(void *data, NC_DATASTORE target, struct nc_err **error) |
Get content of the config. More... | |
int(* | init )(void *data) |
Called before the data store is used. More... | |
int(* | is_locked )(void *data, NC_DATASTORE target, const char **session_id, const char **datetime) |
Is datastore currently locked? More... | |
int(* | lock )(void *data, NC_DATASTORE target, const char *session_id, struct nc_err **error) |
Lock the data store from other processes. More... | |
int(* | rollback )(void *data) |
Revert the last change. More... | |
int(* | unlock )(void *data, NC_DATASTORE target, const char *session_id, struct nc_err **error) |
The counter-part of lock. More... | |
int(* | was_changed )(void *data) |
Was the content of data store changed? More... | |
Public callbacks for the data store.
These are the callbacks that need to be provided by the server to be used from the custom data store.
int(* copyconfig)(void *data, NC_DATASTORE target, NC_DATASTORE source, char *config, struct nc_err **error) |
Copy config from one data store to another.
[in] | data | The user data. |
[in] | target | Where to copy. |
[in] | source | From where to copy. |
[in] | config | Custom data if source parameter is NC_DATASTORE_CONFIG |
[out] | error | Set this in case of EXIT_FAILURE, to indicate what went wrong. |
int(* deleteconfig)(void *data, NC_DATASTORE target, struct nc_err **error) |
Make the given data source empty.
[in] | data | The user data. |
[in] | target | Which part (running, startup, candidate) is supposed to be cleaned out. |
[out] | error | Set this in case of EXIT_FAILURE, to indicate what went wrong. |
int(* editconfig)(void *data, const nc_rpc *rpc, NC_DATASTORE target, const char *config, NC_EDIT_DEFOP_TYPE defop, NC_EDIT_ERROPT_TYPE errop, struct nc_err **error) |
Perform the editconfig operation.
[in] | data | The user data. |
[in] | rpc | RPC message with the request. RPC message is used only for access control. If rpc is NULL access control is skipped. |
[in] | target | What datastore part is going to be modified. |
[in] | config | Edit configuration data. |
[in] | defop | Default edit operation. |
[in] | errop | Error-option. |
[out] | error | Set this in case of EXIT_FAILURE, to indicate what went wrong. |
void(* free)(void *data) |
Called after the last use of the data store.
This is called after the library stops using the data store. Use this place to free whatever resources (including data, if it was allocated.
[in] | data | The user data. |
char*(* getconfig)(void *data, NC_DATASTORE target, struct nc_err **error) |
Get content of the config.
The ownership of the returned string is passed onto the caller. So, allocate it and forget.
[in] | data | The user data. |
[in] | target | Where to read data from. |
[out] | error | Set this in case of error, to indicate what went wrong. |
int(* init)(void *data) |
Called before the data store is used.
This callback is called before the data store is used (but after the data has been set).
[in] | data | The user data. |
int(* is_locked)(void *data, NC_DATASTORE target, const char **session_id, const char **datetime) |
Is datastore currently locked?
If function is not implemented, libnetconf will use internal information about the lock. Note, that this information is process specific. If your server runs in multiple processes, libnetconf's information might not be valid. In such a case you should properly implement this function to share lock information.
Note, that session_id and datetime can be NULL when caller does not need this information.
To announce, that this function is not implemented, set it to NULL in callbacks parameter passed to the ncds_custom_set_data() function.
[in] | data | The user data |
[in] | target | Which datastore lock information is required. |
[out] | session_id | Which session has locked the datastore. |
[out] | datatime | When the datastore was locked (RFC 3339 format) |
int(* lock)(void *data, NC_DATASTORE target, const char *session_id, struct nc_err **error) |
Lock the data store from other processes.
[in] | data | The user data. |
[in] | target | Which data store should be locked. |
[in] | session_id | ID of the session requesting the lock. |
[out] | error | Set this in case of EXIT_FAILURE, to indicate what went wrong. |
int(* rollback)(void *data) |
Revert the last change.
[in] | data | The user data. |
int(* unlock)(void *data, NC_DATASTORE target, const char *session_id, struct nc_err **error) |
The counter-part of lock.
Function must check that the datastore was locked by the same session (according to the provided session_id) that is now requesting its unlock.
[in] | data | The user data. |
[in] | target | Which data store should be unlocked. |
[in] | session_id | ID of the session requesting the unlock. |
[out] | error | Set this in case of EXIT_FAILURE, to indicate what went wrong. |
int(* was_changed)(void *data) |
Was the content of data store changed?
[in] | data | The user data. |