4  yp-yangcli-show Library

The yp-yangcli-show library contains vendor code for global APIs that are not specific to 1 YANG module.

The libshow/src directory contains the file example-show.c and example-show.h. These contain empty callbacks that can be filled in.

The mandatory to implement callback functions for yangcli application initialization and cleanup are described in this section.

4.1  Copy and Setup libshow subtree

The default library created by building libshow is libyp_show-example.so. This is not the correct filename, in order to prevent the real yp-yangcli application library from being overwritten by the empty example library, if “make install” is run.

The libshow subtree should be copied to your own development area and modified.

Instructions are in the src/Makefile:

 

#

# to make a real library, copy this directory contents

# to a new location and change yp-show-example to yp_show

# in the SUBDIR_NM macro below

#

#  SUBDIR_NM=yp_show

#

SUBDIR_NM=yp_show-example

 

 

Change the string yp-show-example to yp-show in the src/Makefile in the copy of libshow.

If vendors add foo-bar to the show commands, then there has to be a YANG module.

They have to make this YANG module and then they have to also load the module in their init function.

The function ncxmod_load_module() is called to load the new YANG module.

 

 

Example template like this:

 

static ncx_module_t *mymod = NULL;

status_t foo_init (void)

{

    status_t res = ncxmod_load_module(mod_name,

                              mod_revision, NULL, &mymod);

   ...

   ...

}

 

4.2  yp_show_init

This function is used to initialize the yangcli application during yangcli-pro initialization.

 

 

/* yangcli show init callback

 *

 * INPUTS:

 *

 * RETURNS:

 *  status; error will abort startup

 */

extern status_t yp_show_init (void);

 

 

This initialization function should load vendor's own YANG module, register the show callback functions, and setup the yangcli show in yp_show_init

4.3  yp_show_cleanup

This function is used to cleanup the yangcli show when the yangcli application is shutting down or restarting.

 

 

/* yangcli show cleanup callback

 * this callback is invoked once during yangcli_cleanup

 */

extern void yp_show_cleanup (void);

 

 

Example yangcli show Cleanup Function

 

 

/* yangcli show cleanup callback

 * this callback is invoked once during yangcli_cleanup

 */

void yp_show_cleanup (void)

{

    log_debug("\nyp_show cleanup\n");

}