bool ReclassifyAllSuspects() { Ticket ticket = MessageManager::Instance().StartConversation(IPCSocketFD); ControlMessage reclassifyRequest(CONTROL_RECLASSIFY_ALL_REQUEST); if(!MessageManager::Instance().WriteMessage(ticket, &reclassifyRequest)) { LOG(ERROR, "Error sending command to NOVAD (CONTROL_RECLASSIFY_ALL_REQUEST)", ""); return false; } Message *reply = MessageManager::Instance().ReadMessage(ticket); if(reply->m_messageType == ERROR_MESSAGE && ((ErrorMessage*)reply)->m_errorType == ERROR_TIMEOUT) { LOG(ERROR, "Timeout error when waiting for message reply", ""); reply->DeleteContents(); delete reply; return false; } if(reply->m_messageType != CONTROL_MESSAGE ) { LOG(ERROR, "Received the wrong kind of reply message", ""); reply->DeleteContents(); delete reply; return false; } ControlMessage *reclassifyReply = (ControlMessage*)reply; if( reclassifyReply->m_controlType != CONTROL_RECLASSIFY_ALL_REPLY ) { LOG(ERROR, "Received the wrong kind of control message", ""); reply->DeleteContents(); delete reply; return false; } bool retSuccess = reclassifyReply->m_success; delete reclassifyReply; return retSuccess; }
bool ReclassifyAllSuspects() { Lock lock = MessageManager::Instance().UseSocket(IPCSocketFD); ControlMessage reclassifyRequest(CONTROL_RECLASSIFY_ALL_REQUEST, DIRECTION_TO_NOVAD); if(!Message::WriteMessage(&reclassifyRequest, IPCSocketFD) ) { //There was an error in sending the message //TODO: Log this fact return false; } Message *reply = Message::ReadMessage(IPCSocketFD, DIRECTION_TO_NOVAD); if(reply->m_messageType == ERROR_MESSAGE && ((ErrorMessage*)reply)->m_errorType == ERROR_TIMEOUT) { LOG(ERROR, "Timeout error when waiting for message reply", ""); delete ((ErrorMessage*)reply); return false; } if(reply->m_messageType != CONTROL_MESSAGE ) { //Received the wrong kind of message delete reply; return false; } ControlMessage *reclassifyReply = (ControlMessage*)reply; if( reclassifyReply->m_controlType != CONTROL_RECLASSIFY_ALL_REPLY ) { //Received the wrong kind of control message delete reclassifyReply; return false; } bool retSuccess = reclassifyReply->m_success; delete reclassifyReply; return retSuccess; }