The information about the current datastore configuration in progress can be found by accessing Transaction Control Block.
If your callback provides msg == incoming rpc_msg_t, for example RPC or EDIT callbacks, then it can provide information about current transaction (agt_cfg_transaction_t, look into agt_cfg.h) and what datastore is currently in progress.
To get the transaction control block and find out what datastore is in progress, for example:
... ********************************************************************/ static status_t test_edit2_callback2 (ses_cb_t *scb, rpc_msg_t *msg, agt_cbtyp_t cbtyp, op_editop_t editop, val_value_t *newval, val_value_t *curval) { agt_cfg_transaction_t *txcb = msg->rpc_txcb; ncx_cfg_t cfg_id = txcb->cfg_id; if (cfg_id == NCX_CFGID_RUNNING) { /* invoke your code here */ } .... }
If your callback directly provides Transaction Control Block, for example Set Hook and Transaction Hook callbacks, then the current datastore information can be found right away with no need to perform the first step above.
... *********************************************************************/ static status_t test_sethook_edit (ses_cb_t *scb, rpc_msg_t *msg, agt_cfg_transaction_t *txcb, op_editop_t editop, val_value_t *newval, val_value_t *curval) { ncx_cfg_t cfg_id = txcb->cfg_id; if (cfg_id == NCX_CFGID_CANDIDATE) { /* invoke your code here */ } .... }
There are only 3 possible datastore configurations available:
/* the 3 standard configs */ typedef enum ncx_cfg_t_ { NCX_CFGID_RUNNING, NCX_CFGID_CANDIDATE, NCX_CFGID_STARTUP } ncx_cfg_t;