public static boolean checkMessageFormat(PCEPMessage message) { PCEPCommonMessageHeader messageHeader = message.getMessageHeader(); LinkedList<PCEPObjectFrame> objectsList = message.getObjectsList(); int messageType = messageHeader.getTypeDecimalValue(); switch (messageType) { case 0: { // UNDEFIND MSG return false; } case 1: { if (objectsList.size() > 1) { return false; } PCEPCommonObjectHeader objectHeader = objectsList.get(0).getObjectHeader(); if (objectHeader.getClassDecimalValue() != 1 || objectHeader.getTypeDecimalValue() != 1) { return false; } return true; // TODO } case 2: { // KEEPALIVE MSG return true; // TODO } case 3: { // PATH COMPUTATION REQUEST MSG return true; // TODO } case 4: { // PATH COMPUTATION REPLY MSG return true; // TODO } case 5: { // NOTIFICATION MSG return true; // TODO } case 6: { // ERROR MSG return true; // TODO } case 7: { // CLOSE MSG return true; // TODO } default: { // UNDEFIND MSG return true; } } }
private void enterSessionUPState(PCEPMessage message, ModuleEnum sourceModule) { logger.debug("Entering: enterSessionUPState(PCEPMessage message)"); logger.debug("| message: " + message.contentInformation()); // System.out.println("[StateMachine: " + address.getAddress() + // "] entering Session up State" ); // flushBuffer(); boolean noErrorsDetected = PCEPMessageAnalyser.checkMessageFormat(message); if (noErrorsDetected == false) { logger.info("Message Format Error detected"); sendCloseMessage(); // releaseResources(); closeTCPConnection(); } this.checkMultipleConnections(); logger.debug("Entering: analyzeMessage(PCEPMessage message)"); int messageType = message.getMessageHeader().getTypeDecimalValue(); switch (messageType) { case 1: { logger.info("Received Open Message"); logger.info("Waiting to be implemented. Do something with this Message!"); break; } case 2: { logger.info("Received KeepAlive Message"); restartDeadTimer(); logger.info("Processing Information: " + message.contentInformation()); break; } case 3: { logger.info("Received Path Computation Request Message"); // System.out.println("Received Path Computation Request Message"); restartDeadTimer(); if ((sourceModule.compareTo(ModuleEnum.CLIENT_MODULE) == 0) || (sourceModule.compareTo(ModuleEnum.COMPUTATION_MODULE) == 0)) { lm.getSessionModule().sendMessage(message, ModuleEnum.NETWORK_MODULE); } else { logger.info( "Client State Machine should not receive Path Computation Requests from any module other than Network"); } break; } case 4: { logger.info("Received Path Computation Response Message"); restartDeadTimer(); if (sourceModule.compareTo(ModuleEnum.NETWORK_MODULE) == 0) { // if the state machine is launched in a client, the response should be sent to the // Client module // or else in case of a server it should be sent to the computation module if (lm.isServer() == false) lm.getSessionModule().sendMessage(message, ModuleEnum.CLIENT_MODULE); else lm.getSessionModule().sendMessage(message, ModuleEnum.COMPUTATION_MODULE); } else { logger.info( "Client State Machine should not receive Path Computation Responses from any module other than Network Module"); } break; } case 5: { logger.info("Received Notification Message"); break; } case 6: { logger.info("Received Error Message"); break; } case 7: { logger.info("Received Close Message"); this.closeTCPConnection(); break; } default: { logger.info("ERROR: Unkown Message"); break; } } }