/** * Function to process the node info hdr * * @param dtms_cb stream_sock buffer node_info_hrd buffer_len * * @return NCSCC_RC_SUCCESS * @return NCSCC_RC_FAILURE * */ uint32_t dtm_process_node_info(DTM_INTERNODE_CB * dtms_cb, int stream_sock, uint8_t *buffer, uint8_t *node_info_hrd, int buffer_len) { uint32_t node_id; DTM_NODE_DB *node; uint32_t nodename_len; char nodename[MAX_NAME_LENGTH]; int rc = 0; uint8_t *data = buffer; TRACE_ENTER(); node_id = ncs_decode_32bit(&data); nodename_len = ncs_decode_32bit(&data); strncpy((char *)nodename, (char *)data, nodename_len); node = dtm_node_get_by_comm_socket(stream_sock); if (node == NULL) { rc = NCSCC_RC_FAILURE; goto done; } if (!node->comm_status) { /*****************************************************/ /* nodeinfo data back to the client NODE is still */ /*****************************************************/ if (node->node_id == 0) { node->node_id = node_id; strncpy((char *)&node->node_name, nodename, nodename_len); node->comm_status = true; if (dtm_node_add(node, 0) != NCSCC_RC_SUCCESS) { LOG_ER("DTM: Node already exit in the cluster with smiler configuration , correct the other joining Node configuration "); osafassert(0); } } else if (node->node_id == node_id) { strncpy((char *)&node->node_name, nodename, nodename_len); rc = dtm_comm_socket_send(stream_sock, node_info_hrd, buffer_len); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("DTM: dtm_comm_socket_send() failed rc : %d", rc); rc = NCSCC_RC_FAILURE; goto done; } node->comm_status = true; } else { LOG_ER("DTM: Node already exit in the cluster with smiler configuration , correct the other joining Node configuration "); osafassert(0); } TRACE("DTM: dtm_process_node_info node_ip:%s, node_id:%u i_addr_family:%d ", node->node_ip, node->node_id, node->i_addr_family); rc = dtm_process_node_up_down(node->node_id, node->node_name, node->node_ip , node->i_addr_family, node->comm_status); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("DTM: dtm_process_node_up_down() failed rc : %d ", rc); rc = NCSCC_RC_FAILURE; } } else { LOG_ER("DTM: Node down already received for this node "); osafassert(0); } done: TRACE_LEAVE(); return rc; }
/** * Function to process the node info hdr * * @param dtms_cb stream_sock buffer node_info_hrd buffer_len * * @return NCSCC_RC_SUCCESS * @return NCSCC_RC_FAILURE * */ uns32 dtm_process_node_info(DTM_INTERNODE_CB * dtms_cb, int stream_sock, uns8 *buffer, uns8 *node_info_hrd, int buffer_len) { uns32 node_id; DTM_NODE_DB *node; uns32 nodename_len; char nodename[MAX_NAME_LENGTH]; int rc = 0; uns8 *data = buffer; TRACE_ENTER(); node_id = ncs_decode_32bit(&data); nodename_len = ncs_decode_32bit(&data); strncpy((char *)nodename, (char *)data, nodename_len); node = dtm_node_get_by_comm_socket(stream_sock); if (node == NULL) { rc = NCSCC_RC_FAILURE; goto done; } if (!node->comm_status) { /*****************************************************/ /* nodeinfo data back to the client NODE is still */ /*****************************************************/ if (node->node_id == 0) { node->node_id = node_id; strncpy((char *)&node->node_name, nodename, nodename_len); node->comm_status = TRUE; if (dtm_node_add(node, 0) != NCSCC_RC_SUCCESS) { assert(0); rc = NCSCC_RC_FAILURE; goto done; } } else if (node->node_id == node_id) { strncpy((char *)&node->node_name, nodename, nodename_len); rc = dtm_comm_socket_send(stream_sock, node_info_hrd, buffer_len); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("DTM: dtm_comm_socket_send() failed rc : %d", rc); rc = NCSCC_RC_FAILURE; goto done; } node->comm_status = TRUE; } else assert(0); rc = dtm_process_node_up_down(node->node_id, node->node_name, node->comm_status); if (rc != NCSCC_RC_SUCCESS) { LOG_ER("DTM: dtm_process_node_up_down() failed rc : %d ", rc); rc = NCSCC_RC_FAILURE; } } else { LOG_ER(" conn details msg recd when conn_status is true"); assert(0); } done: TRACE_LEAVE(); return rc; }