equilibrium2-mgmt_ui.c

Go to the documentation of this file.
00001 /*
00002  * $Id: equilibrium2-mgmt_ui.c 346460 2009-11-14 05:06:47Z ssiano $
00003  *
00004  * This code is provided as is by Juniper Networks SDK Developer Support.
00005  * It is provided with no warranties or guarantees, and Juniper Networks
00006  * will not provide support or maintenance of this code in any fashion.
00007  * The code is provided only to help a developer better understand how
00008  * the SDK can be used.
00009  * 
00010  * Copyright (c) 2008, Juniper Networks, Inc.
00011  * All rights reserved.
00012  */
00013 
00021 #include <sync/equilibrium2.h>
00022 #include "equilibrium2-mgmt.h"
00023 
00024 #include <arpa/inet.h>
00025 #include <jnx/aux_types.h>
00026 #include <jnx/mgmt_sock_pub.h>
00027 #include <jnx/ms_parse.h>
00028 #include <jnx/pconn.h>
00029 #include <junoscript/xmllib_pub.h>
00030 #include <junoscript/xmlrpc.h>
00031 #include <junoscript/xmlstr.h>
00032 #include <ddl/defs.h>
00033 
00034 #include EQUILIBRIUM2_ODL_H
00035 
00036 /*** Constants ***/
00037 
00038 /*** Data Structures ***/
00039 
00040 /*** STATIC/INTERNAL Functions ***/
00041 
00057 static int32_t
00058 eq2_show_status (mgmt_sock_t *msp UNUSED, parse_status_t* csb UNUSED,
00059         char *unparsed UNUSED)
00060 {
00061     client_t *client;
00062     msg_svr_group_t *group;
00063     msg_svr_addr_t *addr;
00064     struct in_addr addr_tmp;
00065     int group_count;
00066     int addr_count;
00067 
00068     XML_OPEN(msp, ODCI_EQUILIBRIUM2_STATUS);
00069     client = client_get_next(NULL);
00070     if (client == NULL) {
00071         XML_ELT(msp, ODCI_GET_STATUS, "%s", "No service running.");
00072         XML_CLOSE(msp, ODCI_EQUILIBRIUM2_STATUS);
00073         return 0;
00074     }
00075 
00076     while (client) {
00077         group_count = ntohl(*((uint32_t *)client->msg));
00078         XML_OPEN(msp, ODCI_SERVICE_INFO);
00079 
00080         XML_OPEN(msp, ODCI_SERVICE_LOCATION);
00081         XML_ELT(msp, ODCI_FPC_SLOT, "%d", client->info.ppi_fpc_slot);
00082         XML_ELT(msp, ODCI_PIC_SLOT, "%d", client->info.ppi_pic_slot);
00083         XML_CLOSE(msp, ODCI_SERVICE_LOCATION);
00084 
00085         XML_OPEN(msp, ODCI_SERVER_GROUP);
00086         group = (msg_svr_group_t *)(client->msg + sizeof(uint32_t));
00087         while (group_count--) {
00088             XML_ELT(msp, ODCI_SERVER_GROUP_NAME, "%s", group->group_name);
00089 
00090             XML_OPEN(msp, ODCI_ADDRESS_LIST);
00091             addr = (msg_svr_addr_t *)group->group_addr;
00092             addr_count = ntohs(group->group_addr_count);
00093             while (addr_count--) {
00094                 addr_tmp.s_addr = addr->addr;
00095                 XML_ELT(msp, ODCI_ADDRESS, "%s", inet_ntoa(addr_tmp));
00096                 XML_ELT(msp, ODCI_SESSION_COUNT, "%d",
00097                         ntohs(addr->addr_ssn_count));
00098                 addr++;
00099             }
00100             XML_CLOSE(msp, ODCI_ADDRESS_LIST);
00101             group = (msg_svr_group_t *)addr;
00102         }
00103         XML_CLOSE(msp, ODCI_SERVER_GROUP);
00104 
00105         XML_CLOSE(msp, ODCI_SERVICE_INFO);
00106         client = client_get_next(client);
00107     }
00108     XML_CLOSE(msp, ODCI_EQUILIBRIUM2_STATUS);
00109     return 0;
00110 }
00111 
00128 static int
00129 eq2_quit (mgmt_sock_t *msp, parse_status_t *csb UNUSED, char *unparsed UNUSED)
00130 {
00131     XML_SEND_SUCCESS_TAG(msp);
00132     return 1;        /* 1 = terminate */
00133 }
00134 
00135 /*** GLOBAL/EXTERNAL Functions ***/
00136 
00137 /******************************************************************************
00138  *                        Menu Structure
00139  *****************************************************************************/
00140 
00141 /*
00142  * format (from libjuniper's ms_parse.h):
00143  *   command,
00144  *   help desc (or NULL),
00145  *   user data arg block (or 0),
00146  *   child (next) menu (or NULL),
00147  *   handler for command(or 0)
00148  */
00149 
00150 
00154 static const parse_menu_t show_sync_eq2_menu[] = {
00155     { "status", NULL, 0, NULL, eq2_show_status },
00156     { NULL, NULL, 0, NULL, NULL }
00157 };
00158 
00162 static const parse_menu_t show_sync_menu[] = {
00163     { "equilibrium2", NULL, 0, show_sync_eq2_menu, NULL },
00164     { NULL, NULL, 0, NULL, NULL }
00165 };
00166 
00170 static const parse_menu_t show_menu[] = {
00171     { "sync", NULL, 0, show_sync_menu, NULL },
00172     { NULL, NULL, 0, NULL, NULL }
00173 };
00174 
00178 const parse_menu_t master_menu[] = {
00179     { "show", NULL, 0, show_menu, NULL }, 
00180     { "quit", NULL, 0, NULL, eq2_quit },
00181     { NULL, NULL, 0, NULL, NULL }
00182 };
00183 

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:58 2010 for SDK Your Net Corporation Equilibrium II: equilibrium2-mgmt 1.0 by Doxygen 1.5.1