Changes to stub code to add support for BAL2.4
diff --git a/device_simulator/bal_server.c b/device_simulator/bal_server.c
index 38f18ba..9d6402f 100644
--- a/device_simulator/bal_server.c
+++ b/device_simulator/bal_server.c
@@ -22,8 +22,8 @@
 static grpc_c_server_t *test_server;
 
 static void sigint_handler (int x) { 
-        grpc_c_server_destroy(test_server);
-        exit(0);
+	grpc_c_server_destroy(test_server);
+	exit(0);
 }
 
 /*
@@ -31,14 +31,15 @@
  */
 void bal__bal_cfg_get_cb(grpc_c_context_t *context)
 {
-        BalCfg *get_cfg;
+	BalCfg *get_cfg;
 
-        /*
-         * Read incoming message into get_cfg
-         */
-        if (context->gcc_payload) {
-                context->gcc_stream->read(context, (void **)&get_cfg, 0);
-        }
+	/*
+	 * Read incoming message into get_cfg
+	 */
+	if (context->gcc_payload) {
+		context->gcc_stream->read(context, (void **)&get_cfg, 0);
+	}
+
 }
 
 /*
@@ -46,88 +47,133 @@
  */
 void bal__bal_cfg_set_cb(grpc_c_context_t *context)
 {
-        BalCfg *set_cfg;
-        BalErr bal_err;
+	BalCfg *set_cfg;
+	BalErr bal_err;
 
-        /*
-         * Read incoming message into set_cfg
-         */
-        if (context->gcc_payload) {
-                context->gcc_stream->read(context, (void **)&set_cfg, 0);
-        }
+	/*
+	 * Read incoming message into set_cfg
+	 */
+	if (context->gcc_payload) {
+		context->gcc_stream->read(context, (void **)&set_cfg, 0);
+	}
 
-        /*
-         * send it to BAL
-         */
+	/*
+	 * send it to BAL
+	 */
 
-        bal_err__init(&bal_err);
+	bal_err__init(&bal_err);
 
-        bal_err.err= 0;
+	bal_err.err= 0;
 
-        /*
-         * Write reply back to the client
-         */
-        if (!context->gcc_stream->write(context, &bal_err, 0)) {
-        } else {
-                printf("Failed to write\n");
-                exit(1);
-        }
+	/*
+	 * Write reply back to the client
+	 */
+	if (!context->gcc_stream->write(context, &bal_err, 0)) {
+	} else {
+		printf("Failed to write\n");
+		exit(1);
+	}
 
-        grpc_c_status_t status;
-        status.gcs_code = 0;
+	grpc_c_status_t status;
+	status.gcs_code = 0;
 
-        /*
-         * Finish response for RPC
-         */
-        if (context->gcc_stream->finish(context, &status)) {
-                printf("Failed to write status\n");
-                exit(1);
-        }
+	/*
+	 * Finish response for RPC
+	 */
+	if (context->gcc_stream->finish(context, &status)) {
+		printf("Failed to write status\n");
+		exit(1);
+	}
 
 #ifdef BAL_STUB
-        pthread_mutex_lock(&lock);
-        if(set_cfg->hdr->has_obj_type)
-        {
-                enQueue(set_cfg->hdr->obj_type, BAL_ERRNO__BAL_ERR_OK);
-                switch(set_cfg->hdr->obj_type)
-                {
-                        case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL:
+	pthread_mutex_lock(&lock);
+
+	struct QNode *temp = newNode(set_cfg->hdr->obj_type, 
+			BAL_ERRNO__BAL_ERR_OK, 
+			set_cfg->device_id);
+
+	if(set_cfg->hdr->has_obj_type)
+	{
+
+		switch(set_cfg->hdr->obj_type)
+		{
+			case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL:
+				{
+					printf("\n***************************************************\n");  
+					printf("Received Access Terminal Configuration msg\n");
+					printf("***************************************************\n");  
+				}
+				break;
+			case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE:
+				{
+					printf("\n***************************************************\n");  
+					printf("Received PON Interface Configuration msg\n");
+					printf("***************************************************\n");  
+					temp->intf_id = set_cfg->interface->key->intf_id;
+					printf("Pon ID = %d\n", temp->intf_id);
+				}
+				break;
+			case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL:
+				{
+					printf("\n*****************************************************\n");  
+					printf("Received ONU Activation msg\n");
+					printf("*****************************************************\n");  
+					temp->intf_id = set_cfg->terminal->key->intf_id;
+					temp->onu_id = set_cfg->terminal->key->sub_term_id;
+				}
+				break;
+                        case BAL_OBJ_ID__BAL_OBJ_ID_PACKET:
                                 {
-                                        printf("\n***************************************************\n");  
-                                        printf("Received Access Terminal Configuration msg\n");
-                                        printf("***************************************************\n");  
+                                   switch(set_cfg->packet->key->packet_send_dest->type)
+                                   {
+					case BAL_DEST_TYPE__BAL_DEST_TYPE_ITU_OMCI_CHANNEL:
+				        {
+						printf("\n*****************************************************\n");  
+						printf("Received OMCI msg\n");
+						printf("*****************************************************\n");  
+						temp->intf_id = set_cfg->terminal->key->intf_id;
+						temp->onu_id = set_cfg->terminal->key->sub_term_id;
+					}
+					break;
+					default:
+					{
+						("\n*****************************************************\n");  
+						printf("Dest type invalid\n");
+						printf("*****************************************************\n");  
+					}
+					break;
+				   }
                                 }
                                 break;
-                        case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE:
-                                {
-                                        printf("\n***************************************************\n");  
-                                        printf("Received PON Interface Configuration msg\n");
-                                        printf("***************************************************\n");  
-                                }
-                                break;
-                        case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL:
-                                {
-                                        printf("\n*****************************************************\n");  
-                                        printf("Received ONU Activation msg\n");
-                                        printf("*****************************************************\n");  
-                                }
-                        default:
-                                break;
-                }
-        }
-        else
-        {
-                printf("BALSTUB:Cfg Set recevied without object type");
-        }
-        pthread_mutex_unlock(&lock);
-        sleep(2);   
-        pthread_cond_signal(&cv);
-        if(BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE == set_cfg->hdr->obj_type)
-        {
-                sleep(5); 
-                enQueue(BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL, BAL_ERRNO__BAL_ERR_OK);
-                pthread_cond_signal(&cv);
-        }
+			default:
+				{
+				("\n*****************************************************\n");  
+				printf("Received Invalid msg\n");
+				printf("*****************************************************\n");  
+				}
+				break;
+		}
+		enQueue(set_cfg->hdr->obj_type, temp);
+	}
+	else
+	{
+		printf("BALSTUB:Cfg Set recevied without object type");
+	}
+	pthread_mutex_unlock(&lock);
+	sleep(2);   
+	pthread_cond_signal(&cv);
+	if(BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE == set_cfg->hdr->obj_type)
+	{
+		sleep(5); 
+		struct QNode *temp1 = newNode(BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL, 
+				BAL_ERRNO__BAL_ERR_OK, 
+				set_cfg->device_id);
+		temp1->intf_id = set_cfg->interface->key->intf_id;
+		temp1->onu_id = 65535;
+		printf("sending _onu_discovery_indiaction\n");
+		enQueue(BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL, temp1); 
+		pthread_cond_signal(&cv);
+	}
 #endif
 }
 
@@ -137,14 +183,14 @@
  */
 void bal__bal_cfg_clear_cb(grpc_c_context_t *context)
 {
-        BalKey *clear_key;
+	BalKey *clear_key;
 
-        /*
-         * Read incoming message into clear_key 
-         */
-        if (context->gcc_payload) {
-                context->gcc_stream->read(context, (void **)&clear_key, 0);
-        }
+	/*
+	 * Read incoming message into clear_key 
+	 */
+	if (context->gcc_payload) {
+		context->gcc_stream->read(context, (void **)&clear_key, 0);
+	}
 
 }
 
@@ -154,14 +200,48 @@
  */
 void bal__bal_api_init_cb(grpc_c_context_t *context)
 {
-        BalInit *bal_init;
+	BalInit *bal_init;
+	BalErr bal_err;
 
-        /*
-         * Read incoming message into set_cfg
-         */
-        if (context->gcc_payload) {
-                context->gcc_stream->read(context, (void **)&bal_init, 0);
-        }
+	/*
+	 * Read incoming message into set_cfg
+	 */
+	if (context->gcc_payload) {
+		context->gcc_stream->read(context, (void **)&bal_init, 0);
+	}
+
+	/*
+	 * send it to BAL
+	 */
+
+
+	("\n*****************************************************\n");  
+	printf("Received API Init msg\n");
+	printf("*****************************************************\n");  
+
+	bal_err__init(&bal_err);
+
+	bal_err.err= 0;
+
+	/*
+	 * Write reply back to the client
+	 */
+	if (!context->gcc_stream->write(context, &bal_err, 0)) {
+	} else {
+		printf("Failed to write\n");
+		exit(1);
+	}
+
+	grpc_c_status_t status;
+	status.gcs_code = 0;
+
+	/*
+	 * Finish response for RPC
+	 */
+	if (context->gcc_stream->finish(context, &status)) {
+		printf("Failed to write status\n");
+		exit(1);
+	}
 
 }
 
@@ -172,14 +252,14 @@
 void bal__bal_api_finish_cb(grpc_c_context_t *context)
 {
 #if 0
-        void *finish_init;
+	void *finish_init;
 
-        /*
-         * Read incoming message into set_cfg
-         */
-        if (context->gcc_payload) {
-                context->gcc_stream->read(context, (void **)&finish_init);
-        }
+	/*
+	 * Read incoming message into set_cfg
+	 */
+	if (context->gcc_payload) {
+		context->gcc_stream->read(context, (void **)&finish_init);
+	}
 #endif
 }
 
@@ -190,85 +270,74 @@
 void bal_ind__bal_ind_info_cb(grpc_c_context_t *context)
 {
 #if 0
-        void *finish_init;
+	void *finish_init;
 
-        /*
-         * Read incoming message into set_cfg
-         */
-        if (context->gcc_payload) {
-                context->gcc_stream->read(context, (void **)&finish_init);
-        }
+	/*
+	 * Read incoming message into set_cfg
+	 */
+	if (context->gcc_payload) {
+		context->gcc_stream->read(context, (void **)&finish_init);
+	}
 #endif
 }
 
 
 /*
- * This functions gets invoked whenever bal RPC gets called
- */
-void bal__bal_omci_msg_cb(grpc_c_context_t *context)
-{
-        char *omci_msg;
-
-        /*
-         * Read incoming message into omci_msg
-         */
-        if (context->gcc_payload) {
-                context->gcc_stream->read(context, (void **)&omci_msg, 0);
-        }
-}
-
-/*
  * Takes socket path as argument
  */
 int main (int argc, char **argv) 
 {
-        int i = 0;
-        grpc_c_server_t *server = NULL;
+	int i = 0;
+	grpc_c_server_t *server = NULL;
 
-        printf("*************\n");
-        printf("BAL STUB\n");
-        printf("*************\n");
-        if (argc < 2) {
-                fprintf(stderr, "Missing socket path argument\n");
-                exit(1);
-        }
+	printf("*************\n");
+	printf("BAL STUB\n");
+	printf("*************\n");
+	if (argc < 2) {
+		fprintf(stderr, "Missing socket path argument\n");
+		exit(1);
+	}
 
-        signal(SIGINT, sigint_handler);
-        /*
-         * Initialize grpc-c library to be used with vanilla gRPC
-         */
-        grpc_c_init(GRPC_THREADS, NULL);
+	signal(SIGINT, sigint_handler);
+	/*
+	 * Initialize grpc-c library to be used with vanilla gRPC
+	 */
+	grpc_c_init(GRPC_THREADS, NULL);
 
-        /*
-         * Create server object
-         */
-        test_server = grpc_c_server_create(argv[1]); 
-        if (test_server == NULL) {
-                printf("Failed to create server\n");
-                exit(1);
-        }
+	/*
+	 * Create server object
+	 */
+	test_server = grpc_c_server_create(argv[1]);
 
-        /*
-         * Initialize greeter service
-         */
-        printf("\nCreating a test server\n");
-        bal__service_init(test_server);
+	if (test_server == NULL) {
+		printf("Failed to create server\n");
+		exit(1);
+	}
 
-        /*
-         * Start server
-         */
-        grpc_c_server_start(test_server);
+	/*
+	 * Initialize greeter service
+	 */
+	printf("\nCreating a test server\n");
+	bal__service_init(test_server);
+
+	/*
+	 * Start server
+	 */
+	grpc_c_server_start(test_server);
 
 #ifdef BAL_STUB
-        printf("\nCreating a stub thread\n");
-        create_stub_thread();
+	printf("\nCreating a stub thread\n");
+	create_stub_thread();
+#else
+	grpc_c_client_t *client = grpc_c_client_init("172.24.150.114:60001", "bal_client", NULL);
 #endif
 
-        /*
-         * Blocks server to wait to completion
-         */
-        grpc_c_server_wait(test_server);
+	/*
+	 * Blocks server to wait to completion
+	 */
+	grpc_c_server_wait(test_server);
 
-        bal__service_init(server);
+	/* code added for example Makefile to compile grpc-c along with edgecore driver */
+	bal__service_init(server);
 
 }
diff --git a/device_simulator/bal_stub.c b/device_simulator/bal_stub.c
index e6d7945..b169e50 100644
--- a/device_simulator/bal_stub.c
+++ b/device_simulator/bal_stub.c
@@ -15,195 +15,235 @@
 
 void *stub_thread(void *v) 
 {
-   int status;
-   grpc_c_client_t *client = grpc_c_client_init("172.24.150.114:60001", "bal_client", NULL);
-   pthread_mutex_lock(&lock);
-   pthread_cond_wait(&cv, &lock);
-   while(NULL != shared_queue->front)
-   {
-      BalObjId prevObjType;
-      struct QNode *front = deQueue(shared_queue);
-      /* prepare and send rpc response */
-      BalIndications balIndCfg;
-      memset(&balIndCfg, 0, sizeof(BalIndications));
-      bal_indications__init(&balIndCfg);
-      BalObjInd bal_obj_ind;
-      memset(&bal_obj_ind, 0, sizeof(BalObjInd));
-      bal_obj_ind__init(&bal_obj_ind);
-      balIndCfg.u_case = BAL_INDICATIONS__U_BAL_OBJ_INFO;
-      balIndCfg.balobjinfo = &bal_obj_ind;
-      balIndCfg.balobjinfo->has_objtype = 1;
-      balIndCfg.balobjinfo->objtype = front->obj_type;
-      balIndCfg.balobjinfo->has_status = 1;
-      balIndCfg.balobjinfo->status = front->status;
-      char keystr;
-      balIndCfg.balobjinfo->keystr = &keystr;
-      switch(front->obj_type)
-      {
-         case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL:
-            {
-               printf("***************************************************\n");
-               printf("Successful Indication sent for ACCESS_TERMINAL\n");
-               printf("***************************************************\n");
-               balIndCfg.balobjinfo->u_case = BAL_OBJ_IND__U__NOT_SET;
-               prevObjType = front->obj_type;
-            }
-            break;
-         case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE:
-            {
-               printf("***************************************************\n");
-               printf("Successful Indication sent for PON INTERFACE UP\n");
-               printf("***************************************************\n");
-               balIndCfg.balobjinfo->u_case = BAL_OBJ_IND__U__NOT_SET;
-               prevObjType = front->obj_type;
-            }
-            break;
-         case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL:
-            {
-               balIndCfg.balobjinfo->u_case = BAL_OBJ_IND__U_ONU_DISCOVERY_INFO;
-               BalSubscriberTerminalCfg onudiscoveryinfo;
-               memset(&onudiscoveryinfo, 0, sizeof(BalSubscriberTerminalCfg));
-               bal_subscriber_terminal_cfg__init(&onudiscoveryinfo);
-               balIndCfg.balobjinfo->onudiscoveryinfo = &onudiscoveryinfo;
+	int status;
+	grpc_c_client_t *client = grpc_c_client_init("172.24.150.167:60001", "bal_client", NULL);
+	pthread_mutex_lock(&lock);
+	pthread_cond_wait(&cv, &lock);
+	while(NULL != shared_queue->front)
+	{
+		BalObjId prevObjType;
+		char vendor_id[20];
+		char vendor_specific[20];
+		struct QNode *front = deQueue(shared_queue);
+		/* prepare and send rpc response */
+		BalIndications balIndCfg;
+		memset(&balIndCfg, 0, sizeof(BalIndications));
+		bal_indications__init(&balIndCfg);
+		balIndCfg.has_objtype = 1;
+		balIndCfg.objtype = front->obj_type;
+		balIndCfg.device_id = front->device_id;
+		printf("Device Id = %s\n", front->device_id);
+		switch(front->obj_type)
+		{
+			case BAL_OBJ_ID__BAL_OBJ_ID_ACCESS_TERMINAL:
+				{
+					printf("***************************************************\n");
+					printf("Successful Indication sent for ACCESS_TERMINAL\n");
+					printf("***************************************************\n");
+					balIndCfg.u_case = BAL_INDICATIONS__U_ACCESS_TERM_IND;
+					prevObjType = front->obj_type;
+				}
+				break;
+			case BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE:
+				{
+					printf("***************************************************\n");
+					printf("Successful Indication sent for PON INTERFACE UP\n");
+					printf("***************************************************\n");
+					balIndCfg.u_case = BAL_INDICATIONS__U_INTERFACE_IND;
+					prevObjType = front->obj_type;
+				}
+				break;
+			case BAL_OBJ_ID__BAL_OBJ_ID_SUBSCRIBER_TERMINAL:
+				{
+					BalSubscriberTerminalKey subTermKey;
+					memset(&subTermKey, 0, sizeof(BalSubscriberTerminalKey));
+					bal_subscriber_terminal_key__init(&subTermKey);
 
-               BalSubscriberTerminalKey subTermKey;
-               memset(&subTermKey, 0, sizeof(BalSubscriberTerminalKey));
-               bal_subscriber_terminal_key__init(&subTermKey);
-               balIndCfg.balobjinfo->onudiscoveryinfo->key = &subTermKey;
-               balIndCfg.balobjinfo->onudiscoveryinfo->key->has_sub_term_id = 1;
-               balIndCfg.balobjinfo->onudiscoveryinfo->key->sub_term_id = 65535;
-               balIndCfg.balobjinfo->onudiscoveryinfo->key->has_intf_id = 1;
-               balIndCfg.balobjinfo->onudiscoveryinfo->key->intf_id = 0;
-               
-               BalSubscriberTerminalCfgData subTermCfgData;
-               memset(&subTermCfgData, 0, sizeof(BalSubscriberTerminalCfgData));
-               bal_subscriber_terminal_cfg_data__init(&subTermCfgData);
-               balIndCfg.balobjinfo->onudiscoveryinfo->data = &subTermCfgData;
-               if(BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE == prevObjType)
-               {
-                  balIndCfg.balobjinfo->onudiscoveryinfo->data->has_admin_state = 1;
-                  balIndCfg.balobjinfo->onudiscoveryinfo->data->admin_state = BAL_STATE__BAL_STATE_DOWN;
-                  balIndCfg.balobjinfo->onudiscoveryinfo->data->has_oper_status = 1;
-                  balIndCfg.balobjinfo->onudiscoveryinfo->data->oper_status = BAL_STATUS__BAL_STATUS_DOWN;
-                  printf("\n***************************************************\n");
-                  printf("Sending ONU discovery message\n");
-                  printf("***************************************************\n");
-               }
-               else
-               {
-                  balIndCfg.balobjinfo->onudiscoveryinfo->data->has_admin_state = 1;
-                  balIndCfg.balobjinfo->onudiscoveryinfo->data->admin_state = BAL_STATE__BAL_STATE_UP;
-                  balIndCfg.balobjinfo->onudiscoveryinfo->data->has_oper_status = 1;
-                  balIndCfg.balobjinfo->onudiscoveryinfo->data->oper_status = BAL_STATUS__BAL_STATUS_UP;
-                  printf("***************************************************\n");
-                  printf("ONU Activation Successful\n");
-                  printf("***************************************************\n");
-               }
-               BalSerialNumber serial_number;
-               memset(&serial_number, 0, sizeof(BalSerialNumber));
-               bal_serial_number__init(&serial_number);
-               balIndCfg.balobjinfo->onudiscoveryinfo->data->serial_number = &serial_number;
-               char vendor_id[20];
-               memset(&vendor_id, 0, 20);
-               strcpy(vendor_id,"4252434D");
-               balIndCfg.balobjinfo->onudiscoveryinfo->data->serial_number->vendor_id = vendor_id;
-               char vendor_specific[20];
-               memset(&vendor_specific, 0, 20);
-               strcpy(vendor_specific,"12345678");
-               balIndCfg.balobjinfo->onudiscoveryinfo->data->serial_number->vendor_specific = vendor_specific;
+					BalSerialNumber serial_number;
+					memset(&serial_number, 0, sizeof(BalSerialNumber));
+					bal_serial_number__init(&serial_number);
 
-               prevObjType = front->obj_type;
-            }
-            break;
-         case BAL_OBJ_ID__BAL_OBJ_ID_PACKET:
-            {
-               balIndCfg.balobjinfo->u_case = BAL_OBJ_IND__U_PKT_DATA;
-            }
-            break;
-         default:
-            {
-               balIndCfg.balobjinfo->u_case = BAL_OBJ_IND__U__NOT_SET;
-               prevObjType = front->obj_type;
-            }
-            break;
-      }
-      BalErr *output;
-      status = bal_ind__bal_ind_info(client, NULL, &balIndCfg, &output, NULL, 0);
-      free(front);
-      pthread_mutex_unlock(&lock);
-      pthread_mutex_lock(&lock);
-      pthread_cond_wait(&cv, &lock);
-   }
-   return NULL;
+					char vendor_id[20];
+					memset(&vendor_id, 0, 20);
+					strcpy(vendor_id,"4252434D");
+					char vendor_specific[20];
+					memset(&vendor_specific, 0, 20);
+					strcpy(vendor_specific,"12345678");
+
+					if(BAL_OBJ_ID__BAL_OBJ_ID_INTERFACE == prevObjType)
+					{
+						balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_DISC;
+						BalSubscriberTerminalSubTermDisc terminal_disc;
+						memset(&terminal_disc, 0, sizeof(BalSubscriberTerminalSubTermDisc));
+						bal_subscriber_terminal_sub_term_disc__init(&terminal_disc);
+						balIndCfg.terminal_disc = &terminal_disc;
+
+						balIndCfg.terminal_disc->key = &subTermKey;
+						balIndCfg.terminal_disc->key->has_sub_term_id = 1;
+						balIndCfg.terminal_disc->key->sub_term_id = front->onu_id;
+						balIndCfg.terminal_disc->key->has_intf_id = 1;
+						balIndCfg.terminal_disc->key->intf_id = front->intf_id;
+
+						BalSubscriberTerminalSubTermDiscData subTermCfgData;
+						memset(&subTermCfgData, 0, sizeof(BalSubscriberTerminalSubTermDiscData));
+						bal_subscriber_terminal_sub_term_disc_data__init(&subTermCfgData);
+						balIndCfg.terminal_disc->data = &subTermCfgData;
+						balIndCfg.terminal_disc->data->serial_number = &serial_number;
+						balIndCfg.terminal_disc->data->serial_number->vendor_id = vendor_id;
+						printf("\n***************************************************\n");
+						printf("Sending ONU discovery message\n");
+						printf("***************************************************\n");
+					}
+					else
+					{
+						balIndCfg.u_case = BAL_INDICATIONS__U_TERMINAL_IND;
+						BalSubscriberTerminalInd terminal_ind;
+						memset(&terminal_ind, 0, sizeof(BalSubscriberTerminalInd));
+						bal_subscriber_terminal_ind__init(&terminal_ind);
+						balIndCfg.terminal_ind = &terminal_ind;
+
+						balIndCfg.terminal_ind->key = &subTermKey;
+						balIndCfg.terminal_ind->key->has_sub_term_id = 1;
+						balIndCfg.terminal_ind->key->sub_term_id = front->onu_id;
+						balIndCfg.terminal_ind->key->has_intf_id = 1;
+						balIndCfg.terminal_ind->key->intf_id = front->intf_id;
+
+						BalSubscriberTerminalIndData subTermCfgData;
+						memset(&subTermCfgData, 0, sizeof(BalSubscriberTerminalIndData));
+						bal_subscriber_terminal_ind_data__init(&subTermCfgData);
+						balIndCfg.terminal_ind->data = &subTermCfgData;
+						balIndCfg.terminal_ind->data->has_admin_state = 1;
+						balIndCfg.terminal_ind->data->admin_state = BAL_STATE__BAL_STATE_UP;
+						balIndCfg.terminal_ind->data->has_oper_status = 1;
+						balIndCfg.terminal_ind->data->oper_status = BAL_STATUS__BAL_STATUS_UP;
+						balIndCfg.terminal_ind->data->serial_number = &serial_number;
+						balIndCfg.terminal_ind->data->serial_number->vendor_id = vendor_id;
+						balIndCfg.terminal_ind->data->serial_number->vendor_specific = vendor_specific;
+						printf("***************************************************\n");
+						printf("ONU Activation Successful\n");
+						printf("***************************************************\n");
+					}
+					prevObjType = front->obj_type;
+				}
+				break;
+			case BAL_OBJ_ID__BAL_OBJ_ID_PACKET:
+				{
+					balIndCfg.u_case = BAL_INDICATIONS__U_BAL_OMCI_RESP;
+                                        BalPacketItuOmciChannelRx balomciresp;
+			                memset(&balomciresp, 0, sizeof(BalPacketItuOmciChannelRx));
+                                        bal_packet_itu_omci_channel_rx__init(&balomciresp);
+                                              
+                                        BalPacketKey balomcirespkey;
+			                memset(&balomcirespkey, 0, sizeof(BalPacketKey));
+                                        bal_packet_key__init(&balomcirespkey); 
+                                        balomciresp.key = &balomcirespkey;
+
+                                        BalDest balomcirespkeydest;
+			                memset(&balomcirespkeydest, 0, sizeof(BalDest));
+                                        bal_dest__init(&balomcirespkeydest);
+                                        balomciresp.key->packet_send_dest = &balomcirespkeydest;
+                                        balomciresp.key->packet_send_dest->has_type = 1;
+                                        balomciresp.key->packet_send_dest->type = BAL_DEST_TYPE__BAL_DEST_TYPE_ITU_OMCI_CHANNEL;
+                                        balomciresp.key->packet_send_dest->u_case = BAL_DEST__U_ITU_OMCI_CHANNEL;
+                                
+                                        BalItuOmciChannel itu_omci_channel;
+			                memset(&itu_omci_channel, 0, sizeof(BalItuOmciChannel));
+                                        bal_itu_omci_channel__init(&itu_omci_channel);
+                                        balomciresp.key->packet_send_dest->itu_omci_channel = &itu_omci_channel;
+                                        balomciresp.key->packet_send_dest->itu_omci_channel->has_sub_term_id = 1;
+                                        balomciresp.key->packet_send_dest->itu_omci_channel->sub_term_id = front->onu_id;
+                                        balomciresp.key->packet_send_dest->itu_omci_channel->has_int_id = 1;
+                                        balomciresp.key->packet_send_dest->itu_omci_channel->int_id = front->intf_id;
+				}
+				break;
+			default:
+				{
+					balIndCfg.u_case = BAL_INDICATIONS__U__NOT_SET;
+					prevObjType = front->obj_type;
+				}
+				break;
+		}
+		BalErr *output;
+		status = bal_ind__bal_ind_info(client, NULL, &balIndCfg, &output, NULL, 0);
+		free(front);
+		pthread_mutex_unlock(&lock);
+		pthread_mutex_lock(&lock);
+		pthread_cond_wait(&cv, &lock);
+	}
+	return NULL;
 }
 
 void create_stub_thread() 
 {
-   pthread_t threadId = 0;
+	pthread_t threadId = 0;
 
-   /* create shared queue */
-   shared_queue = createQueue();
+	/* create shared queue */
+	shared_queue = createQueue();
 
-   pthread_create(&threadId, NULL, stub_thread, NULL);      
+	pthread_create(&threadId, NULL, stub_thread, NULL);      
 
 }
 
 /* A utility function to create an empty queue */
 bal_queue *createQueue()
 {
-   shared_queue = (struct Queue*)malloc(sizeof(struct Queue));
-   shared_queue->front = shared_queue->rear = NULL;
-   return shared_queue;
+	shared_queue = (struct Queue*)malloc(sizeof(struct Queue));
+	shared_queue->front = shared_queue->rear = NULL;
+	return shared_queue;
 }
 
 /* A utility function to create a new linked list node */
-struct QNode* newNode(int objKey, int status)
+struct QNode* newNode(int objKey, int status, char *device_id)
 {
-   struct QNode *temp = (struct QNode*)malloc(sizeof(struct QNode));
-   temp->obj_type = objKey;
-   temp->status = status;
-   temp->next = NULL;
-   return temp; 
+	struct QNode *temp = (struct QNode*)malloc(sizeof(struct QNode));
+	temp->obj_type = objKey;
+	temp->status = status;
+	if(device_id != NULL)
+	{
+		memset(temp->device_id, 0, BAL_DEVICE_STR_LEN);
+		memcpy(temp->device_id, device_id, strlen(device_id));
+	}
+	temp->next = NULL;
+	return temp; 
 }
 
 /* The function to add data to shared_queue - Add end of the queue */
-void enQueue(int objKey, int status)
+void enQueue(int objKey, struct QNode *temp)
 {
-   /* Create a new LL node */
-   struct QNode *temp = newNode(objKey, status);
+	/* Create a new LL node */
 
-   /* If queue is empty, then new node is front and rear both */
-   if (shared_queue->rear == NULL)
-   {
-      shared_queue->front = shared_queue->rear = temp;
-      return;
-   }
+	/* If queue is empty, then new node is front and rear both */
+	if (shared_queue->rear == NULL)
+	{
+		shared_queue->front = shared_queue->rear = temp;
+		return;
+	}
 
-   /* Add the new node at the end of queue and change rear */
-   shared_queue->rear->next = temp;
-   shared_queue->rear = temp;
+	/* Add the new node at the end of queue and change rear */
+	shared_queue->rear->next = temp;
+	shared_queue->rear = temp;
 }
 
 /* Function to remove data from shared_queue - FIFO */
 struct QNode *deQueue()
 {
-   /* If queue is empty, return NULL */
-   if (shared_queue->front == NULL)
-   {
-      return NULL;
-   }
+	/* If queue is empty, return NULL */
+	if (shared_queue->front == NULL)
+	{
+		return NULL;
+	}
 
-   /* Store previous front and move front one node ahead */
-   struct QNode *temp = shared_queue->front;
-   shared_queue->front = shared_queue->front->next;
+	/* Store previous front and move front one node ahead */
+	struct QNode *temp = shared_queue->front;
+	shared_queue->front = shared_queue->front->next;
 
-   /* If front becomes NULL, then change rear also as NULL */
-   if (shared_queue->front == NULL)
-   {
-      shared_queue->rear = NULL;
-   }
+	/* If front becomes NULL, then change rear also as NULL */
+	if (shared_queue->front == NULL)
+	{
+		shared_queue->rear = NULL;
+	}
 
-   return temp;
+	return temp;
 }
 
 #endif
diff --git a/device_simulator/bal_stub.h b/device_simulator/bal_stub.h
index 0bd30de..8108d6d 100644
--- a/device_simulator/bal_stub.h
+++ b/device_simulator/bal_stub.h
@@ -7,21 +7,25 @@
 #define IND_USR_DAT_VAL  "brcmOLT"
 #define BALCLIENT        "bal_client"
 #define BALSERVER        "bal_server"
+#define BAL_DEVICE_STR_LEN 20
 
 /* A linked list (LL) node to store a queue entry */
 struct QNode
 {
-   int obj_type;
-   int status;
-   struct QNode *next;
+	int obj_type;
+	char device_id[BAL_DEVICE_STR_LEN];
+	int status;
+	int intf_id;
+	int onu_id;
+	struct QNode *next;
 };
 
- 
+
 /* The queue, front stores the front node of LL and rear stores ths
-  last node of LL */
+   last node of LL */
 typedef struct Queue
 {
-   struct QNode *front, *rear;
+	struct QNode *front, *rear;
 }bal_queue;
 
 /* shared queue */
@@ -29,6 +33,6 @@
 
 void create_stub_thread(); 
 bal_queue *createQueue();
-struct QNode* newNode(int objKey, int status);
-void enQueue(int objKey, int status);
+struct QNode* newNode(int objKey, int status, char *device_id);
+void enQueue(int objKey, struct QNode *temp);
 struct QNode *deQueue();