The GET2 callback functions use 1 callback per object template. The server will issue “get” and “getnext” requests via this API, and the callback code will return value nodes for the data it is managing. These data nodes are not maintained in the server Data Tree. They are not cached in the server.

These callbacks are expected to return some or all of the terminal child nodes (leaf, leaf-list, anyxml) when invoked.


GET2 callbacks never return child nodes that are complex nodes. Complex child nodes are expected to have their own get2 callbacks registered.
Configuration data is not supported for the GET2 callbacks.
Refer to GET2 All In One (AIO) callback for complex node retrieval at once.


The following function template definition is used for GET2 callback functions:


typedef status_t
    (*getcb_fn2_t) (ses_cb_t *scb,
                    xml_msg_hdr_t *msg,
                    getcb_get2_t *get2cb);


Register GET2 Callback


The following example code illustrates how the GET2 callbacks can be registered. The callbacks registration is getting done during Initialization Phase 1.


extern status_t 
    agt_cb_register_get_callback (const xmlChar *modname,
                                  const xmlChar *defpath,
                                  const xmlChar *version,
                                  getcb_fn2_t get_cbfn);


ParameterDescription
modnameModule name string that defines this object node.
defpathAbsolute path expression string indicating which node the callback function is for.
versionIf non-NULL, indicates the exact module version expected.
get_cbfnAddress of callback function to use for GET callbacks


GET2 Callback Cleanup


extern void
    agt_cb_unregister_callbacks(const xmlChar *modname,
                                const xmlChar *defpath);


ParameterDescription
modnameModule name string that defines this object node.
defpathAbsolute path expression string indicating which node the callback function is for.


If you register a callback for a specific object, your SIL code should unregister it during the cleanup phase, that is being called any time the server is shutting down. Also, it is getting called during a restart and reload procedure.


The unregister function can be called just once for a specific object. It will unregister EDIT1, EDIT2, and even GET2 callbacks for the object. However, if it is called multiple times for the same object, it will return with NO errors. 


For more information on how to use GET2 callbacks refer to the following article:


How do I use GET2 callbacks for a YANG leaf and leaf-list?

How do I use GET2 callbacks for a YANG container?

How do I use GET2 callbacks for a YANG choice?

How do I use GET2 callbacks for a YANG list?

How do I implement get-bulk GET2 callback for a YANG list?

How to create an anyxml or anydata return value for a GET2 callback

GET2 callback differences for Subtree and XPath filtering requests