Creating the Commands Menu Array

To represent the commands expected by your daemon, you must define menu arrays to specify the command hierarchy, the arguments a command can take, and the code that is executed to retrieve the data required by the command.

Your daemon should have a file named daemon-name/_ui.c that contains several arrays defined according to the typedef parse_menu_t, which is defined in the ms_parse.h file in libjuniper. The system uses these arrays to build a tree of tokens used to respond to commands sent from the management daemon (mgd) to your daemon.

For details about creating the main menu, see the programming task, Creating a Commands Menu Array.

The Menu in Hello World

The Hello World application initializes its particular version of the master commands menu as follows. The show sync helloworld messages command has a sub-level definition for each of the helloworld and messages tokens, while the quit command, which has no additional tokens, executes the function helloworld_quit().

For the show command, the following sequence occurs:

The DDL is:

const parse_menu_t master_menu[] = {
     { "show", NULL, 0, show_menu, NULL }, 
     { "quit", NULL, 0, NULL, helloworld_quit },
     { NULL, NULL, 0, NULL, NULL }
 };

/**
 *  show ... commands
 */
static const parse_menu_t show_menu[] = {
    { "sync", NULL, 0, show_sync_menu, NULL },
    { NULL, NULL, 0, NULL, NULL }
};

/**
 *  show sync ... commands
 */
static const parse_menu_t show_sync_menu[] = {
    { "helloworld", NULL, 0, show_sync_helloworld_menu, NULL },
    { NULL, NULL, 0, NULL, NULL }
};
 
/**
 *  show sync helloworld ... commands
 */
static const parse_menu_t show_sync_helloworld_menu[] = {
    { "message", NULL, 0, NULL, helloworld_show_message },
    { NULL, NULL, 0, NULL, NULL }
};

Defining the Input Command Hierarchy, Reading the Configuration, and Adding the Message


2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:26:47 2010 for Juniper Networks Partner Solution Development Platform JUNOS SDK 10.2R1 by Doxygen 1.4.5