VOL-791:Support for OLT disable/enable on ASFvOLT16

Change-Id: I274b984685dacf1e94ad7cc7cfa5ca68c0168ed3
diff --git a/src/bal_access_terminal_hdlr.c b/src/bal_access_terminal_hdlr.c
index cebd418..153fcf9 100755
--- a/src/bal_access_terminal_hdlr.c
+++ b/src/bal_access_terminal_hdlr.c
@@ -42,7 +42,8 @@
     BCMBAL_CFG_INIT(&acc_term_obj, access_terminal, key);
 
     /* decode API parameters from CLI */
-    ASFVOLT_CFG_PROP_SET(acc_term_obj, access_terminal, admin_state, BCMOS_TRUE, BCMBAL_STATE_UP);
+    ASFVOLT_CFG_PROP_SET(acc_term_obj, access_terminal, admin_state, BCMOS_TRUE,
+                         access_term_cfg->data->admin_state);
 
     err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(acc_term_obj.hdr));
 
@@ -52,7 +53,7 @@
         return BAL_ERRNO__BAL_ERR_INTERNAL;
     }
 
-    ASFVOLT_LOG(ASFVOLT_INFO, "Access Terminal UP configuration sent to OLT");
+    ASFVOLT_LOG(ASFVOLT_INFO, "Access Terminal %d sent to OLT", access_term_cfg->data->admin_state);
     return BAL_ERRNO__BAL_ERR_OK;
 }
 
diff --git a/src/bal_indications_hdlr.c b/src/bal_indications_hdlr.c
index 312c5a6..fdd9bf3 100755
--- a/src/bal_indications_hdlr.c
+++ b/src/bal_indications_hdlr.c
@@ -1366,7 +1366,8 @@
 		      sub_ind->data.serial_number.vendor_id[2],
 		      sub_ind->data.serial_number.vendor_id[3]);
       balIndCfg->terminal_ind->data->serial_number->vendor_id = vendor_id;
-      ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Activation:After decoding:Vendor id is %s", balIndCfg->terminal_ind->data->serial_number->vendor_id);
+      ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Activation:After decoding:Vendor id is %s",
+                  balIndCfg->terminal_ind->data->serial_number->vendor_id);
       char *vendor_specific = malloc(sizeof(char)*MAX_CHAR_LENGTH);
       memset(vendor_specific, 0, MAX_CHAR_LENGTH);
       sprintf(vendor_specific,"%1X%1X%1X%1X%1X%1X%1X%1X",
@@ -1379,7 +1380,10 @@
 		      sub_ind->data.serial_number.vendor_specific[3]>>4 & 0x0f,
 		      sub_ind->data.serial_number.vendor_specific[3] & 0x0f);
       balIndCfg->terminal_ind->data->serial_number->vendor_specific = vendor_specific;
-      ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Activation:After decoding:Vendor specific is %s", balIndCfg->terminal_ind->data->serial_number->vendor_specific);
+      ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Activation:After decoding:Vendor specific is %s",
+                  balIndCfg->terminal_ind->data->serial_number->vendor_specific);
+      ASFVOLT_LOG(ASFVOLT_DEBUG, "ONU Activation:After decoding:Registration ID is %s",
+                  balIndCfg->terminal_ind->data->registration_id);
 
       BalIdList *balAggportList;
       balAggportList = malloc(sizeof(BalIdList));
diff --git a/src/bal_interface_hdlr.c b/src/bal_interface_hdlr.c
index 707f3fd..f59be37 100755
--- a/src/bal_interface_hdlr.c
+++ b/src/bal_interface_hdlr.c
@@ -36,62 +36,59 @@
     intf_key.intf_id = interface_cfg->key->intf_id;
     intf_key.intf_type = interface_cfg->key->intf_type;
 
+    ASFVOLT_LOG(ASFVOLT_DEBUG, "Setting Interface ID(%d) Interface Type(%d) to Admin state(%d)",
+                                intf_key.intf_id, intf_key.intf_type,
+                                interface_cfg->data->admin_state);
 
     /*
      * Set the key in the interface object and initialize the object itself
      */
     BCMBAL_CFG_INIT(&interface_obj, interface, intf_key);
 
-    bcmbal_cfg_get(DEFAULT_ATERM_ID, &(interface_obj.hdr));
+    ASFVOLT_CFG_PROP_SET(interface_obj, interface, admin_state, BCMOS_TRUE,
+                         interface_cfg->data->admin_state);
 
-    if(BCMBAL_STATUS_UP != ((bcmbal_interface_cfg *)&interface_obj.hdr)->data.oper_status)
+    ASFVOLT_CFG_PROP_SET(interface_obj, interface, min_data_agg_port_id,
+                         interface_cfg->data->has_min_data_svc_port_id,
+                         interface_cfg->data->min_data_agg_port_id);
+
+    ASFVOLT_CFG_PROP_SET(interface_obj, interface, min_data_svc_port_id,
+                         interface_cfg->data->has_min_data_svc_port_id,
+                         interface_cfg->data->min_data_svc_port_id);
+
+    ASFVOLT_CFG_PROP_SET(interface_obj, interface, transceiver_type,
+                         BCMOS_TRUE,
+                         interface_cfg->data->transceiver_type);
+    ASFVOLT_LOG(ASFVOLT_INFO, "Setting transceiver_type to : %d", interface_cfg->data->transceiver_type);
+
+    ASFVOLT_CFG_PROP_SET(interface_obj, interface, ds_miss_mode,
+                         interface_cfg->data->has_ds_miss_mode,
+                         interface_cfg->data->ds_miss_mode);
+
+    ASFVOLT_CFG_PROP_SET(interface_obj, interface, mtu,
+                         interface_cfg->data->has_mtu,
+                         interface_cfg->data->mtu);
+
+    ASFVOLT_CFG_PROP_SET(interface_obj, interface, flow_control,
+                         interface_cfg->data->has_flow_control,
+                         interface_cfg->data->flow_control);
+
+    ASFVOLT_CFG_PROP_SET(interface_obj, interface, ds_tm,
+                         interface_cfg->data->has_ds_tm,
+                         interface_cfg->data->ds_tm);
+
+    ASFVOLT_CFG_PROP_SET(interface_obj, interface, us_tm,
+                         interface_cfg->data->has_us_tm,
+                         interface_cfg->data->us_tm);
+
+    ASFVOLT_LOG(ASFVOLT_INFO, "Bringing up the interface No: %d", intf_key.intf_id);
+
+    err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
+
+    if(BCM_ERR_OK != err)
     {
-        BCMBAL_CFG_INIT(&interface_obj, interface, intf_key);
-
-        ASFVOLT_CFG_PROP_SET(interface_obj, interface, admin_state, BCMOS_TRUE, BCMBAL_STATE_UP);
-
-        ASFVOLT_CFG_PROP_SET(interface_obj, interface, min_data_agg_port_id,
-                               interface_cfg->data->has_min_data_svc_port_id,
-                               interface_cfg->data->min_data_agg_port_id);
-
-        ASFVOLT_CFG_PROP_SET(interface_obj, interface, min_data_svc_port_id,
-                               interface_cfg->data->has_min_data_svc_port_id,
-                               interface_cfg->data->min_data_svc_port_id);
-
-        ASFVOLT_CFG_PROP_SET(interface_obj, interface, transceiver_type,
-                               BCMOS_TRUE,
-                               interface_cfg->data->transceiver_type);
-        ASFVOLT_LOG(ASFVOLT_INFO, "Setting transceiver_type to : %d", interface_cfg->data->transceiver_type);
-
-        ASFVOLT_CFG_PROP_SET(interface_obj, interface, ds_miss_mode,
-                               interface_cfg->data->has_ds_miss_mode,
-                               interface_cfg->data->ds_miss_mode);
-
-        ASFVOLT_CFG_PROP_SET(interface_obj, interface, mtu,
-                               interface_cfg->data->has_mtu,
-                               interface_cfg->data->mtu);
-
-        ASFVOLT_CFG_PROP_SET(interface_obj, interface, flow_control,
-                               interface_cfg->data->has_flow_control,
-                               interface_cfg->data->flow_control);
-
-        ASFVOLT_CFG_PROP_SET(interface_obj, interface, ds_tm,
-                               interface_cfg->data->has_ds_tm,
-                               interface_cfg->data->ds_tm);
-
-        ASFVOLT_CFG_PROP_SET(interface_obj, interface, us_tm,
-                               interface_cfg->data->has_us_tm,
-                               interface_cfg->data->us_tm);
-
-        ASFVOLT_LOG(ASFVOLT_INFO, "Bringing up the interface No: %d", intf_key.intf_id);
-
-        err = bcmbal_cfg_set(DEFAULT_ATERM_ID, &(interface_obj.hdr));
-
-        if(BCM_ERR_OK != err)
-        {
-            ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the interface object to ADMIN-UP");
-            return BAL_ERRNO__BAL_ERR_INTERNAL;
-        }
+        ASFVOLT_LOG(ASFVOLT_ERROR, "Failed to configure the interface object to ADMIN-UP");
+        return BAL_ERRNO__BAL_ERR_INTERNAL;
     }
     ASFVOLT_LOG(ASFVOLT_DEBUG, "Set Interface configuration sent to OLT.Interface ID(%d) Interface Type(%d)",
                                 intf_key.intf_id, intf_key.intf_type);
diff --git a/src/bal_tmqueue_hdlr.c b/src/bal_tmqueue_hdlr.c
index 0e7e03b..eb52db9 100755
--- a/src/bal_tmqueue_hdlr.c
+++ b/src/bal_tmqueue_hdlr.c
@@ -54,24 +54,26 @@
     /* init the API struct */
     BCMBAL_CFG_INIT(&tm_queue_obj, tm_queue, key);
 
-    /* decode API parameters from GRPC */
-    ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, priority,
-                         tm_queue_cfg->data->has_priority,
-                         tm_queue_cfg->data->priority);
-    ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, weight,
-                         tm_queue_cfg->data->has_weight,
-                         tm_queue_cfg->data->weight);
-    ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, creation_mode,
-                         tm_queue_cfg->data->has_creation_mode,
-                         tm_queue_cfg->data->creation_mode);
-    ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, ref_count,
-                         tm_queue_cfg->data->has_ref_count,
-                         tm_queue_cfg->data->ref_count);
-
+    if (NULL != tm_queue_cfg->data)
+    {
+	    /* decode API parameters from GRPC */
+	    ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, priority,
+			    tm_queue_cfg->data->has_priority,
+			    tm_queue_cfg->data->priority);
+	    ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, weight,
+			    tm_queue_cfg->data->has_weight,
+			    tm_queue_cfg->data->weight);
+	    ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, creation_mode,
+			    tm_queue_cfg->data->has_creation_mode,
+			    tm_queue_cfg->data->creation_mode);
+	    ASFVOLT_CFG_PROP_SET(tm_queue_obj, tm_queue, ref_count,
+			    tm_queue_cfg->data->has_ref_count,
+			    tm_queue_cfg->data->ref_count);
+    }
     /* rating/shaping */
     BalTmShaping *balShaping = (BalTmShaping *)tm_queue_cfg->data->rate;
     bcmbal_tm_shaping val = {};
-    if (balShaping->has_presence_mask)
+    if ((NULL != balShaping) && (balShaping->has_presence_mask))
     {
        val.presence_mask = balShaping->presence_mask;
        if (balShaping->has_cir)
@@ -92,7 +94,7 @@
     /* bac - Buffer addmission Control */
     BalTmBac *balBac = (BalTmBac *)tm_queue_cfg->data->bac;
     bcmbal_tm_bac valBac = {};
-    if(balBac->has_type)
+    if((NULL != balBac) && (balBac->has_type))
     {
        valBac.type = balBac->type;
        switch(valBac.type)