📄 configinfo.java
字号:
RREPAckRequiredVal = true; else RREPAckRequiredVal = false; } else if(strTag.equals(ipAddressMulticastStr)) { InetAddress adr = InetAddress.getByName(strValue); if(ipVersionVal == IPv4_VERSION_VAL) { if(!(adr instanceof Inet4Address)) throw new Exception("Invalid ipAddressMulticast - must be IPv4"); } else if(ipVersionVal == IPv6_VERSION_VAL) { if(!(adr instanceof Inet6Address)) throw new Exception("Invalid ipAddressMulticast - must be IPv6"); } else throw new Exception("Invalid ipAddressMulticast - some inconsistancy"); ipAddressMulticast = adr.getHostAddress(); ipAddressMulticastVal = adr; } else if(strTag.equals(RERRSendingModeStr)) { if(RERRSendingMode.toLowerCase().equals(RERR_UNICAST)) { RERRSendingModeVal = RERR_UNICAST_VAL; } else if(RERRSendingMode.toLowerCase().equals(RERR_MULTICAST)) { RERRSendingModeVal = RERR_MULTICAST_VAL; } else { throw new Exception("Invalid RERRSendingMode - should be " + RERR_UNICAST + " or " + RERR_MULTICAST + " "); } } else if(strTag.equals(deletePeriodModeStr)) { try { if(strValue.toLowerCase().equals(DELETE_MODE_HELLO)) deletePeriodModeVal = DELETE_MODE_HELLO_VAL; else if(strValue.toLowerCase().equals(DELETE_MODE_LINKLAYER)) deletePeriodModeVal = DELETE_MODE_LINKLAYER_VAL; else throw new Exception(); deletePeriodMode = strValue; } catch(Exception e) { throw new Exception("Invalid DeletePeriodMode (" + DELETE_MODE_HELLO + " or " + DELETE_MODE_LINKLAYER + ")"); } } else if(strTag.equals(routeDiscoveryModeStr)) { try { if(strValue.toLowerCase().equals(ROUTE_DISCOVERY_ERS)) routeDiscoveryModeVal = ROUTE_DISCOVERY_ERS_VAL; else if(strValue.toLowerCase().equals(ROUTE_DISCOVERY_NON_ERS)) routeDiscoveryModeVal = ROUTE_DISCOVERY_NON_ERS_VAL; else throw new Exception(); routeDiscoveryMode = strValue; } catch(Exception e) { throw new Exception("Invalid RouteDiscoveryMode (" + ROUTE_DISCOVERY_ERS + " or " + ROUTE_DISCOVERY_NON_ERS + ")"); } } else if(strTag.equals(packetBufferingStr)) { try { if(strValue.toLowerCase().equals(YES)) packetBufferingVal = true; else if(strValue.toLowerCase().equals(NO)) packetBufferingVal = false; else throw new Exception(); packetBuffering = strValue; } catch(Exception e) { throw new Exception("Invalid PacketBuffering (" + YES + " or " + NO + ")"); } } else if(strTag.equals(activeRouteTimeoutStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); activeRouteTimeout = strValue; activeRouteTimeoutVal = num; } catch(Exception e) { throw new Exception("Invalid activeRouteTimeout"); } } else if(strTag.equals(allowedHelloLossStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); allowedHelloLoss = strValue; allowedHelloLossVal = num; } catch(Exception e) { throw new Exception("Invalid AllowedHelloLoss"); } } else if(strTag.equals(helloIntervalStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); helloInterval = strValue; helloIntervalVal = num; } catch(Exception e) { throw new Exception("Invalid HelloInterval"); } } else if(strTag.equals(localAddTTLStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); localAddTTL = strValue; localAddTTLVal = num; } catch(Exception e) { throw new Exception("Invalid LocalAddTTL"); } } else if(strTag.equals(netDiameterStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); netDiameter = strValue; netDiameterVal = num; } catch(Exception e) { throw new Exception("Invalid NetDiameter"); } } else if(strTag.equals(nodeTraversalTimeStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); nodeTraversalTime = strValue; nodeTraversalTimeVal = num; } catch(Exception e) { throw new Exception("Invalid nodeTraversalTime"); } } else if(strTag.equals(RERRRatelimitStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); RERRRatelimit = strValue; RERRRatelimitVal = num; } catch(Exception e) { throw new Exception("Invalid RERRRatelimit"); } } else if(strTag.equals(RREQRetriesStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); RREQRetries = strValue; RREQRetriesVal = num; } catch(Exception e) { throw new Exception("Invalid RREQRetries"); } } else if(strTag.equals(RREQRateLimitStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); RREQRateLimit = strValue; RREQRateLimitVal = num; } catch(Exception e) { throw new Exception("Invalid RREQRateLimit"); } } else if(strTag.equals(timeoutBufferStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); timeoutBuffer = strValue; timeoutBufferVal = num; } catch(Exception e) { throw new Exception("Invalid TimeoutBuffer"); } } else if(strTag.equals(TTLStartStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); TTLStart = strValue; TTLStartVal = num; } catch(Exception e) { throw new Exception("Invalid TTLStart"); } } else if(strTag.equals(TTLIncrementStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); TTLIncrement = strValue; TTLIncrementVal = num; } catch(Exception e) { throw new Exception("Invalid TTLIncrement"); } } else if(strTag.equals(TTLThresholdStr)) { try { int num = Integer.parseInt(strValue); if(num <= 0) throw new Exception(); TTLThreshold = strValue; TTLThresholdVal = num; } catch(Exception e) { throw new Exception("Invalid TTLThreshold"); } } netTraversalTimeVal = 2 * nodeTraversalTimeVal * netDiameterVal; blacklistTimeoutVal = RREQRetriesVal * netTraversalTimeVal; maxRepairTTLVal = (int) (0.3 * netDiameterVal); myRouteTimeoutVal = 2 * activeRouteTimeoutVal; nextHopWaitVal = nodeTraversalTimeVal + 10; pathDiscoveryTimeVal = 2 * netTraversalTimeVal; if(deletePeriodModeVal == 1) { deletePeriodVal = allowedHelloLossVal * helloIntervalVal; } else { deletePeriodVal = activeRouteTimeoutVal; } } catch(Exception e) { throw new Exception("Problem in line " + lineNo + ": Error reported - " + e); } } infoChanged = true; } /** * Method to update configuration info. It creates a * file, if no file is available and if the file is * available, then cxlears the file, before writing * */ public void updateInfo() throws Exception { BufferedWriter w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(cfgFileName))); w.write("# ", 0, 2); w.newLine(); w.write("#Read the sample-jadhoc.cfg for details ", 0, 40); w.newLine(); w.write("# ", 0, 2); w.newLine(); w.write(executionModeStr + "=", 0, executionModeStr.length() + 1); w.write(executionMode, 0, executionMode.length()); w.newLine(); w.write(osInUseStr + "=", 0, osInUseStr.length() + 1); w.write(osInUse, 0, osInUse.length()); w.newLine(); w.write(ipVersionStr + "=", 0, ipVersionStr.length() + 1); w.write(ipVersion, 0, ipVersion.length()); w.newLine(); w.write(ipAddressStr + "=", 0, ipAddressStr.length() + 1); w.write(ipAddress, 0, ipAddress.length()); w.newLine(); w.write(ifaceNameStr + "=", 0, ifaceNameStr.length() + 1); w.write(ifaceName, 0, ifaceName.length()); w.newLine(); w.write(ipAddressGatewayStr + "=", 0, ipAddressGatewayStr.length() + 1); w.write(ipAddressGateway, 0, ipAddressGateway.length()); w.newLine(); w.write(loIfaceNameStr + "=", 0, loIfaceNameStr.length() + 1); w.write(loIfaceName, 0, loIfaceName.length()); w.newLine(); w.write(loggingStatusStr + "=", 0, loggingStatusStr.length() + 1); w.write(loggingStatus, 0, loggingStatus.length()); w.newLine(); w.write(loggingLevelStr + "=", 0, loggingLevelStr.length() + 1); w.write(loggingLevel, 0, loggingLevel.length()); w.newLine(); w.write(logFileStr + "=", 0, logFileStr.length() + 1); w.write(logFile, 0, logFile.length()); w.newLine(); w.write(pathToSystemCmdsStr + "=", 0, pathToSystemCmdsStr.length() + 1); w.write(pathToSystemCmds, 0, pathToSystemCmds.length()); w.newLine(); w.write(onlyDestinationStr + "=", 0, onlyDestinationStr.length() + 1); w.write(onlyDestination, 0, onlyDestination.length()); w.newLine(); w.write(gratuitousRREPStr + "=", 0, gratuitousRREPStr.length() + 1); w.write(gratuitousRREP, 0, gratuitousRREP.length()); w.newLine(); w.write(RREPAckRequiredStr + "=", 0, RREPAckRequiredStr.length() + 1); w.write(RREPAckRequired, 0, RREPAckRequired.length()); w.newLine(); w.write(ipAddressMulticastStr + "=", 0, ipAddressMulticastStr.length() + 1); w.write(ipAddressMulticast, 0, ipAddressMulticast.length()); w.newLine(); w.write(RERRSendingModeStr + "=", 0, RERRSendingModeStr.length() + 1); w.write(RERRSendingMode, 0, RERRSendingMode.length()); w.newLine(); w.write(deletePeriodModeStr + "=", 0, deletePeriodModeStr.length() + 1); w.write(deletePeriodMode, 0, deletePeriodMode.length()); w.newLine(); w.write(routeDiscoveryModeStr + "=", 0, routeDiscoveryModeStr.length() + 1); w.write(routeDiscoveryMode, 0, routeDiscoveryMode.length()); w.newLine(); w.write(packetBufferingStr + "=", 0, packetBufferingStr.length() + 1); w.write(packetBuffering, 0, packetBuffering.length()); w.newLine(); w.write(activeRouteTimeoutStr + "=", 0, activeRouteTimeoutStr.length() + 1); w.write(activeRouteTimeout, 0, activeRouteTimeout.length()); w.newLine(); w.write(allowedHelloLossStr + "=", 0, allowedHelloLossStr.length() + 1); w.write(allowedHelloLoss, 0, allowedHelloLoss.length()); w.newLine(); w.write(helloIntervalStr + "=", 0, helloIntervalStr.length() + 1); w.write(helloInterval, 0, helloInterval.length()); w.newLine(); w.write(localAddTTLStr + "=", 0, localAddTTLStr.length() + 1); w.write(localAddTTL, 0, localAddTTL.length()); w.newLine(); w.write(netDiameterStr + "=", 0, netDiameterStr.length() + 1); w.write(netDiameter, 0, netDiameter.length()); w.newLine(); w.write(nodeTraversalTimeStr + "=", 0, nodeTraversalTimeStr.length() + 1); w.write(nodeTraversalTime, 0, nodeTraversalTime.length()); w.newLine(); w.write(RERRRatelimitStr + "=", 0, RERRRatelimitStr.length() + 1); w.write(RERRRatelimit, 0, RERRRatelimit.length()); w.newLine(); w.write(RREQRetriesStr + "=", 0, RREQRetriesStr.length() + 1); w.write(RREQRetries, 0, RREQRetries.length()); w.newLine(); w.write(RREQRateLimitStr + "=", 0, RREQRateLimitStr.length() + 1); w.write(RREQRateLimit, 0, RREQRateLimit.length()); w.newLine(); w.write(timeoutBufferStr + "=", 0, timeoutBufferStr.length() + 1); w.write(timeoutBuffer, 0, timeoutBuffer.length()); w.newLine(); w.write(TTLStartStr + "=", 0, TTLStartStr.length() + 1); w.write(TTLStart, 0, TTLStart.length()); w.newLine(); w.write(TTLIncrementStr + "=", 0, TTLIncrementStr.length() + 1); w.write(TTLIncrement, 0, TTLIncrement.length()); w.newLine(); w.write(TTLThresholdStr + "=", 0, TTLThresholdStr.length() + 1); w.write(TTLThreshold, 0, TTLThreshold.length()); w.newLine(); w.close(); infoChanged = true; } /** * Method to validate the config information given in the * passed parameter. * @param ConfigInfo tempCfg - Confdig object with parameters * */ public void validateInfo(ConfigInfo tempCfg) throws Exception { if(!tempCfg.executionMode.toLowerCase().equals(NON_GUI_MODE) && !tempCfg.executionMode.toLowerCase().equals(GUI_MODE)) { throw new Exception("Invalid Execution mode (" + GUI_MODE + " or " + NON_GUI_MODE + ")"); } tempCfg.executionModeVal = tempCfg.executionMode; if(!tempCfg.osInUse.toLowerCase().equals(WINDOWS_OS) && !tempCfg.osInUse.toLowerCase().equals(LINUX_OS)) { throw new Exception("Invalid osInUse - (" + WINDOWS_OS + " or " + LINUX_OS + ")"); } tempCfg.osInUseVal = tempCfg.osInUse; if(tempCfg.ipVersionVal != IPv4_VERSION_VAL && tempCfg.ipVersionVal != IPv6_VERSION_VAL) { throw new Exception("Invalid ipVersion - (" + IPv4_VERSION + " or " + IPv6_VERSION + ")"); } ///////////// temporary code if(tempCfg.ipVersion.toLowerCase().equals(IPv6_VERSION)) { throw new Exception("IPv6 not supported at this time"); } ///////////// end of temprorary code
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -