ped_main.c

Go to the documentation of this file.
00001 /*
00002  * $Id: ped_main.c 366303 2010-03-05 13:14:01Z taoliu $
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) 2007-2008, Juniper Networks, Inc.
00011  * All rights reserved.
00012  */
00013  
00021 /* The Application and This Daemon's Documentation: */
00022 
00706 #include <sync/common.h>
00707 #include "ped_config.h"
00708 #include "ped_conn.h"
00709 #include "ped_daemon_name.h"
00710 #include "ped_kcom.h"
00711 #include "ped_schedule.h"
00712 #include "ped_policy_table.h"
00713 #include "ped_ssd.h"
00714 #include "ped_snmp.h"
00715 #include "ped_service_route.h"
00716 #include "ped_filter.h"
00717 
00718 #include PE_SEQUENCE_H
00719 
00720 /*** Constants ***/
00721 
00722 
00723 /*** Data Structures ***/
00724 
00729 extern const parse_menu_t master_menu[];
00730 
00734 extern const char *ped_top_config[];
00735 
00736 evContext ped_ctx;  
00737 
00738 /*** STATIC/INTERNAL Functions ***/
00739 
00749 static int
00750 ped_init(evContext ctx)
00751 {
00752     ped_ctx = ctx;
00753     init_config(); // init configuration storage
00754     init_table();  // init table of managed interfaces
00755     ped_ssd_init(); // connect to SSD and init our SSD module
00756     init_dfw(ctx);
00757     service_route_init(ctx); // connect to SSD and init our service route module
00758 
00759     if(ped_kcom_init()) { // init KCOM
00760         ERRMSG(PED, TRACE_LOG_ERR,
00761                 "%s: Initialize kcom FAILED!", __func__);
00762     } else if(ped_schedule_init()) {  // init SCHEDULER
00763         ERRMSG(PED, TRACE_LOG_ERR,
00764                 "%s: Initialize scheduler FAILED!", __func__);
00765     } else if(init_server(ctx)) {  // init peer connection (CPD/PFD) server    
00766         ERRMSG(PED, TRACE_LOG_ERR,
00767                 "%s: Initialize peer connection server FAILED!", __func__);        
00768     } else {
00769         netsnmp_subagent_init();
00770         ped_schedule_reset(); // start SCHEDULER
00771         return SUCCESS;
00772     }
00773     return EFAIL;
00774 }
00775 
00776 /*** GLOBAL/EXTERNAL Functions ***/
00777 
00789 int
00790 main (int argc, char **argv)
00791 {
00792     int ret = 0;
00793     junos_sdk_app_ctx_t ctx;
00794 
00795     /* Create an application context */
00796     ctx = junos_create_app_ctx(argc, argv, DNAME_PED,
00797                                master_menu, PACKAGE_NAME, SEQUENCE_NUMBER);
00798     if (ctx == NULL) {
00799         return -1;
00800     }
00801 
00802     /* Set config read call back */
00803     if ((ret = junos_set_app_cb_config_read(ctx, ped_config_read))) {
00804         goto cleanup;
00805     }
00806 
00807     /* Set init call back */
00808     if ((ret = junos_set_app_cb_init(ctx, ped_init))) {
00809         goto cleanup;
00810     }
00811     
00812     /* set trace options DDL path */
00813     if ((ret = junos_set_app_cfg_trace_path(ctx, ped_top_config)) < 0) {
00814         goto cleanup;
00815     }
00816 
00817     /* Calling junos_app_init */
00818     ret = junos_app_init(ctx);
00819 
00820 cleanup:
00821     /* Destroying context if daemon init/exit failed */
00822     junos_destroy_app_ctx(ctx);
00823     return ret;
00824 
00825 }

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:06 2010 for SDK Your Net Corporation Policy Manager Example: Policy Enforcement Daemon 1.0 by Doxygen 1.5.1