First, a user enters the following at the CLI command prompt:
> configure # set sync helloworld message "Hello SDK World!"
To initialize itself on the Routing Engine, the application next begins a series of steps in main()
, culminating in a call to the junos_app_init()
function:
junos_create_app_ctx()
to create a context objectjunos_set_app_cb_config_read()
to set up the callback helloworld_config_read()
, which will read the configuration settingsjunos_set_app_cb_init()
to set up the callback helloworld_init()
, which will perform additional initialization operationsjunos_app_init()
to invoke the initialization process.
int main (int argc, char ** argv) { int ret = 0; junos_sdk_app_ctx_t ctx; /* Create an application context */ ctx = junos_create_app_ctx(argc, argv, DNAME_HELLOWORLDD, master_menu, PACKAGE_NAME, SEQUENCE_NUMBER); if (ctx == NULL) { return -1; } /* Set config read call back */ if ((ret = junos_set_app_cb_config_read(ctx, helloworld_config_read))) { goto cleanup; } /* Set init call back */ if ((ret = junos_set_app_cb_init(ctx, helloworld_init))) { goto cleanup; } /* Calling junos_app_init */ ret = junos_app_init(ctx);
The system next executes the following operations:
helloworld_init()
function to perform additional initialization needed by the daemon. (see Main Function: Performing Setup and Initializing the Daemon)
helloworld_config_read()
function to read and apply the daemon's configuration. (see Creating the Tree and Adding Messages)
The application sets up the menu of commands in the helloworld_ui.c
file, which also includes the code to display the message; this commands menu is the array passed to junos_daemon_init()
in the master_menu parameter. (See Creating the Commands Menu Array).
For more information, see Creating the Tree and Adding Messages.
#exit >show sync helloworld message
The daemon fetches the message (see Reading the Configuration ) and then uses ODL to format and display the message (see Coding, Fetching, and Displaying the Output.)