hellopics-mgmt_config.c

Go to the documentation of this file.
00001 /*
00002  * $Id: hellopics-mgmt_config.c 358766 2010-01-20 16:37:38Z jamesk $
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 #include <ddl/dax.h>
00022 #include <sys/socket.h>
00023 #include <netdb.h>
00024 #include <jnx/junos_trace.h>
00025 #include <jnx/junos_re_redundancy.h>
00026 #include <jnx/junos_re_info.h>
00027 #include "hellopics-mgmt_logging.h"
00028 #include "hellopics-mgmt_config.h"
00029 #include "hellopics-mgmt_conn.h"
00030 #include "hellopics-mgmt_ha.h"
00031 
00032 #include HELLOPICS_OUT_H
00033 
00034 #define NAME_LENGTH 64
00035 /*** Data Structures ***/
00036 volatile boolean is_master;
00037 
00038 
00039 /*** STATIC/INTERNAL Functions ***/
00040 
00041 
00042 /*** GLOBAL/EXTERNAL Functions ***/
00043 
00044 
00056 int
00057 hellopics_config_read (int check UNUSED)
00058 {
00059     junos_trace(HELLOPICS_TRACEFLAG_NORMAL, 
00060             "%s: Loaded hellopics configuration", __func__);
00061 
00062     return SUCCESS;
00063 }
00064 
00070 void
00071 init_config(void)
00072 {
00073     boolean mastership;
00074     char master_re_name[NAME_LENGTH];
00075     in_addr_t re_addr;
00076     if((mastership = junos_re_redundancy_is_master()) == TRUE) {
00077         LOG(LOG_INFO,
00078             "%s: This is the master: Setting Mastership as MASTER",
00079             __func__);
00080          set_mastership(TRUE,0); 
00081     }
00082     else {
00083         LOG(LOG_INFO,
00084             "%s: This is the slave: Setting Mastership as SLAVE",
00085             __func__);
00086         if(junos_re_info_hostname(JUNOS_ROUTING_ENGINE_MASTER,
00087                                   master_re_name, NAME_LENGTH) == -1){
00088              LOG(LOG_ERR,
00089             "%s: This is the slave: Unable to get the Master RE hostname",
00090             __func__);
00091         }
00092         LOG(LOG_INFO,
00093             "%s: This is the slave: Master RE Name is %s",
00094             __func__, master_re_name);
00095       if(strcmp(master_re_name, "re0") == 0){
00096          re_addr = HELLOPICS_MASTER_ADDR;
00097       }
00098       else {
00099          re_addr = HELLOPICS_MASTER_ADDR+1;
00100       }
00101       set_mastership(FALSE,re_addr); 
00102     }
00103 }
00104 

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 Hellopics Example: hellopics-mgmt 1.0 by Doxygen 1.5.1