The following article illustrates how to utilize the Transaction Complete callback in examples.


The Transaction Complete function is the user/system callback that is invoked after the transactions has been processed.

The following function template definition is used for Transaction Complete callback functions:


/* Typedef of the trans_complete callback */ 
typedef void 
    (*agt_cb_trans_complete_t)(agt_cfg_transaction_t *txcb)


Register Callback


The register function is used to declare a specific callback function for Transaction Complete callbacks. 

The registration is done during the Initialization Phase 1 before the startup configuration is loaded into the running configuration database and before running configurations are loaded.

The Transaction Complete callback function is hooked into the server with the agt_cb_trans_complete_register function, described below. 


extern void
    agt_cb_trans_complete_register (agt_cb_trans_complete_t cbfn);


Callback Cleanup

The Transaction Complete callback function clean up is hooked into the server with the agt_cb_trans_complete_unregister function, described below. 


extern void
    agt_cb_trans_complete_unregister (agt_cb_trans_complete_t cbfn);



In this example, the Transaction Complete callback function applies multiple actions prior the transaction is actually completed. The purpose of this function is to provide more validation options and more flexible and easier development. This callback function may send a custom notifications, or write a system or other log entries.


Also, it can clean up pointers that were created during the Transaction Start callback.


The following example code illustrates how the Transaction Complete callback may look like.


/******************************************************************** 
* FUNCTION transaction_complete
* 
* Complete Transaction callback
* The Transaction Complete function is the
* user/system callback that is invoked after
* the transactions has been processed. 
* 
* INPUTS: 
*   txcb == transaction control block in progress 
* 
* RETURNS:
*   none
********************************************************************/ 
static void
    transaction_complete (agt_cfg_transaction_t *txcb) 
{ 

    log_debug("\nEnter transaction_complete callback"); 

    /* send custom notifications */
    /* write a sys, audit, vendor specific, etc log entries */

    return; 

}  /* transaction_complete */