monitube2-mgmt_kcom.c

Go to the documentation of this file.
00001 /*
00002  * $Id: monitube2-mgmt_kcom.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) 2009, Juniper Networks, Inc.
00011  * All rights reserved.
00012  */
00013 
00022 #include <sync/common.h>
00023 #include <jnx/provider_info.h>
00024 #include "monitube2-mgmt_kcom.h"
00025 #include "monitube2-mgmt_config.h"
00026 #include "monitube2-mgmt_conn.h"
00027 #include "monitube2-mgmt_logging.h"
00028 
00029 #include MONITUBE2_OUT_H
00030 
00031 /*** Constants ***/
00032 
00033 #define MSP_IFD_NAME_PATTERN "ms-"  
00034 
00035 /*** Data Structures ***/
00036 
00037 
00038 /*** STATIC/INTERNAL Functions ***/
00039 
00052 static int
00053 ifd_down_async_handler(kcom_ifdev_t * msg, void * user_info __unused)
00054 {
00055     char * name = msg->ifdev_name;
00056 
00057     if((msg->ifdev_op == KCOM_DELETE || junos_kcom_ifd_down(msg)) &&
00058        strstr(name, MSP_IFD_NAME_PATTERN)) {
00059         
00060         junos_trace(MONITUBE_TRACEFLAG_KCOM,
00061                 "%s: Handling ifd %s going down", __func__, name);
00062         
00063         // An MS PIC is going down and may be one we're connected to
00064         mspic_offline(name);
00065     }
00066     
00067     junos_kcom_msg_free(msg);
00068 
00069     return 0;
00070 }
00071 
00072 
00073 /*** GLOBAL/EXTERNAL Functions ***/
00074 
00075 
00085 int
00086 kcom_init(evContext ctx)
00087 {
00088     int status;
00089     provider_origin_id_t id;
00090 
00091     status = provider_info_get_origin_id(&id);
00092     
00093     if(status != 0) {
00094         LOG(TRACE_LOG_ERR, "%s: Retrieving origin id failed", __func__);
00095         return -1;
00096     }
00097     
00098     status = junos_kcom_init(id, ctx);
00099     INSIST(status == KCOM_OK);
00100 
00101     // Register for IFD notification (listen for ms interfaces going down)
00102     status = junos_kcom_register_ifd_handler(NULL, ifd_down_async_handler);
00103     if(status != KCOM_OK) {
00104         LOG(TRACE_LOG_ERR, "%s: Register ifd handler failed", __func__);
00105     }
00106     
00107     return status;
00108 }
00109 
00110 
00114 void
00115 kcom_shutdown(void)
00116 {
00117     junos_trace(MONITUBE_TRACEFLAG_KCOM, "%s", __func__);
00118 
00119     junos_kcom_shutdown();
00120 }

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:04 2010 for SDK Your Net Corporation Monitube2 IPTV Monitoring Example: monitube2-mgmt 1.0 by Doxygen 1.5.1