route-manager_main.c

Go to the documentation of this file.
00001 /*
00002  * $Id$
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) 2010, Juniper Networks, Inc.
00011  * All rights reserved.
00012  */
00013 
00022 /* The Application and This Daemon's Documentation: */
00023 
00122 #include <stdlib.h>
00123 #include <sys/types.h>
00124 #include <sys/queue.h>
00125 #include <isc/eventlib.h>
00126 #include <jnx/trace.h>
00127 #include <jnx/junos_trace.h>
00128 #include <jnx/junos_init.h>
00129 #include <jnx/ssd_ipc_msg.h>
00130 #include "route-manager.h"
00131 
00132 #include OUT_H
00133 #include SEQUENCE_H
00134 
00135 /*** Constants ***/
00136 
00137 /*** Data Structures ***/
00138 
00139 extern const parse_menu_t master_menu[];
00140 
00141 /*** STATIC/INTERNAL Functions ***/
00142 
00148 static void
00149 main_exit (void)
00150 {
00151     RM_TRACE(TF_NORMAL, "%s: Route Manager exits.", __func__);
00152     ssd_close();
00153     config_clear();
00154     kcom_close();
00155     exit(0);
00156 }
00157 
00165 static void
00166 sigterm (int signo UNUSED)
00167 {
00168     main_exit();
00169 }
00170 
00181 static int
00182 main_init (evContext ctx)
00183 {
00184     RM_TRACE(TF_NORMAL, "%s: Start initializing.", __func__);
00185 
00186     junos_sig_register(SIGTERM, sigterm);
00187     config_init();
00188     kcom_init(ctx);
00189     ssd_open(ctx);
00190 
00191     return 0;
00192 }
00193 
00194 
00195 /*** GLOBAL/EXTERNAL Functions ***/
00196 
00210 int
00211 main (int argc, char **argv)
00212 {
00213     int rc = 0;
00214     junos_sdk_app_ctx_t app_ctx;
00215     const char *config_path[] = { "sync", "route-manager", NULL };
00216 
00217     app_ctx = junos_create_app_ctx(argc, argv, "route-manager", NULL,
00218             PACKAGE_NAME, SEQUENCE_NUMBER);
00219     if (app_ctx == NULL) {
00220         return -1;
00221     }
00222 
00223     rc = junos_set_app_cb_config_read(app_ctx, config_read);
00224     if (rc < 0) {
00225         goto error;
00226     }
00227 
00228     rc = junos_set_app_cb_init(app_ctx, main_init);
00229     if (rc < 0) {
00230         goto error;
00231     }
00232 
00233     rc = junos_set_app_cfg_trace_path(app_ctx, config_path);
00234     if (rc < 0) {
00235         goto error;
00236     }
00237 
00238     rc = junos_app_init(app_ctx);
00239 
00240 error:
00241     /* should not come here unless daemon exiting or init failed,
00242      * destroy context
00243      */
00244     junos_destroy_app_ctx(app_ctx); 
00245     return rc;
00246 }
00247 

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:27:07 2010 for SDK Your Net Corporation Route Manager: route-manager 1.0 by Doxygen 1.5.1