libnetconf  0.10.0-146_trunk
NETCONF Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ncds_custom_funcs Struct Reference

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...
 

Detailed Description

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.

Field Documentation

int(* copyconfig)(void *data, NC_DATASTORE target, NC_DATASTORE source, char *config, struct nc_err **error)

Copy config from one data store to another.

Parameters
[in]dataThe user data.
[in]targetWhere to copy.
[in]sourceFrom where to copy.
[in]configCustom data if source parameter is NC_DATASTORE_CONFIG
[out]errorSet this in case of EXIT_FAILURE, to indicate what went wrong.
Returns
EXIT_SUCCESS or EXIT_FAILURE.
int(* deleteconfig)(void *data, NC_DATASTORE target, struct nc_err **error)

Make the given data source empty.

Parameters
[in]dataThe user data.
[in]targetWhich part (running, startup, candidate) is supposed to be cleaned out.
[out]errorSet this in case of EXIT_FAILURE, to indicate what went wrong.
Returns
EXIT_SUCCESS or EXIT_FAILURE.
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.

Parameters
[in]dataThe user data.
[in]rpcRPC message with the request. RPC message is used only for access control. If rpc is NULL access control is skipped.
[in]targetWhat datastore part is going to be modified.
[in]configEdit configuration data.
[in]defopDefault edit operation.
[in]erropError-option.
[out]errorSet this in case of EXIT_FAILURE, to indicate what went wrong.
Returns
EXIT_SUCCESS or EXIT_FAILURE.
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.

Parameters
[in]dataThe 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.

Parameters
[in]dataThe user data.
[in]targetWhere to read data from.
[out]errorSet this in case of error, to indicate what went wrong.
Returns
Serialized content of the datastore, NULL on error
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).

Parameters
[in]dataThe user data.
Returns
0 for success, 1 for failure.
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.

Parameters
[in]dataThe user data
[in]targetWhich datastore lock information is required.
[out]session_idWhich session has locked the datastore.
[out]datatimeWhen the datastore was locked (RFC 3339 format)
Returns
  • 0 datastore is not locked
  • 1 datastore is locked
  • negative value - error
int(* lock)(void *data, NC_DATASTORE target, const char *session_id, struct nc_err **error)

Lock the data store from other processes.

Parameters
[in]dataThe user data.
[in]targetWhich data store should be locked.
[in]session_idID of the session requesting the lock.
[out]errorSet this in case of EXIT_FAILURE, to indicate what went wrong.
Returns
EXIT_SUCCESS or EXIT_FAILURE.
int(* rollback)(void *data)

Revert the last change.

Parameters
[in]dataThe user data.
Returns
0 for success, 1 for error.
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.

Parameters
[in]dataThe user data.
[in]targetWhich data store should be unlocked.
[in]session_idID of the session requesting the unlock.
[out]errorSet this in case of EXIT_FAILURE, to indicate what went wrong.
Returns
EXIT_SUCCESS or EXIT_FAILURE.
int(* was_changed)(void *data)

Was the content of data store changed?

Parameters
[in]dataThe user data.
Returns
0 if content not changed, non-zero else

The documentation for this struct was generated from the following file: