📄 configinfo.java
字号:
if(tempCfg.ipVersionVal == IPv4_VERSION_VAL) tempCfg.ipVersionVal = IPv4_VERSION_VAL; else tempCfg.ipVersionVal = IPv6_VERSION_VAL; // validate ipAddress try { InetAddress adr = InetAddress.getByName(tempCfg.ipAddress); if(tempCfg.ipVersionVal == IPv4_VERSION_VAL) { if(!(adr instanceof Inet4Address)) throw new Exception("must be IPv4"); } else if(tempCfg.ipVersionVal == IPv6_VERSION_VAL) { if(!(adr instanceof Inet6Address)) throw new Exception("must be IPv6"); } else throw new Exception("some inconsistancy"); tempCfg.ipAddress = adr.getHostAddress(); tempCfg.ipAddressVal = adr; } catch(Exception e) { throw new Exception("Invalid ipAddress - " + e); } // validate ifaceName if(tempCfg.ifaceName.trim().length() == 0) throw new Exception("Invalid ifaceName - cannot be blank"); tempCfg.ifaceNameVal = tempCfg.ifaceName; // validate ipAddressGateway try { InetAddress adr = InetAddress.getByName(tempCfg.ipAddressGateway); if(tempCfg.ipVersionVal == IPv4_VERSION_VAL) { if(!(adr instanceof Inet4Address)) throw new Exception("must be IPv4"); } else if(tempCfg.ipVersionVal == IPv6_VERSION_VAL) { if(!(adr instanceof Inet6Address)) throw new Exception("must be IPv6"); } else throw new Exception("some inconsistancy"); tempCfg.ipAddressGateway = adr.getHostAddress(); tempCfg.ipAddressGatewayVal = adr; } catch(Exception e) { throw new Exception("Invalid ipAddressGateway - " + e); } // validate loIfaceName if(tempCfg.loIfaceName.trim().length() == 0) throw new Exception("Invalid loIfaceName - cannot be blank"); tempCfg.loIfaceNameVal = tempCfg.loIfaceName; // validate loggingStatus if(!(tempCfg.loggingStatus.toLowerCase().equals(YES) || tempCfg.loggingStatus.toLowerCase().equals(NO))) throw new Exception("Invalid LoggingStatus - Yes or No"); if(tempCfg.loggingStatus.toLowerCase().equals(YES)) tempCfg.loggingStatusVal = true; else tempCfg.loggingStatusVal = false; // validate loggingLevel if(tempCfg.loggingStatus.toLowerCase().equals(YES)) { try { int num = Integer.parseInt(tempCfg.loggingLevel); if(num < Logging.MIN_LOGGING || num > Logging.MAX_LOGGING) throw new Exception(); tempCfg.loggingLevelVal = num; } catch(Exception e) { throw new Exception("Invalid LoggingLevel - (between " + Logging.MIN_LOGGING + " and " + Logging.MAX_LOGGING + ")"); } } // validate logFile if(tempCfg.loggingStatus.toLowerCase().equals(YES)) { try { if(tempCfg.logFile.trim().length() == 0) throw new Exception(); tempCfg.logFileVal = tempCfg.logFile.trim(); } catch(Exception e) { throw new Exception("Invalid LogFile " + tempCfg.logFile); } } // validate pathToSystemCmds File dir = new File(tempCfg.pathToSystemCmds); if(!dir.isDirectory()) throw new Exception("Invalid PathToSystemCmds"); tempCfg.pathToSystemCmdsVal = tempCfg.pathToSystemCmds; // validate onlyDestination if(!(tempCfg.onlyDestination.toLowerCase().equals(YES) || tempCfg.onlyDestination.toLowerCase().equals(NO))) throw new Exception("Invalid OnlyDestination - Yes or No"); if(tempCfg.onlyDestination.toLowerCase().equals(YES)) tempCfg.onlyDestinationVal = true; else tempCfg.onlyDestinationVal = false; // validate gratuitousRREP if(!(tempCfg.gratuitousRREP.toLowerCase().equals(YES) || tempCfg.gratuitousRREP.toLowerCase().equals(NO))) throw new Exception("Invalid GratuitousRREP - Yes or No"); if(tempCfg.gratuitousRREP.toLowerCase().equals(YES)) tempCfg.gratuitousRREPVal = true; else tempCfg.gratuitousRREPVal = false; // validate RREPAckRequired if(!(tempCfg.RREPAckRequired.toLowerCase().equals(YES) || tempCfg.RREPAckRequired.toLowerCase().equals(NO))) throw new Exception("Invalid RREPAckRequired - Yes or No"); if(tempCfg.RREPAckRequired.toLowerCase().equals(YES)) tempCfg.RREPAckRequiredVal = true; else tempCfg.RREPAckRequiredVal = false; // validate ipAddressMulticast try { InetAddress adr = InetAddress.getByName(tempCfg.ipAddressMulticast); if(tempCfg.ipVersionVal == IPv4_VERSION_VAL) { if(!(adr instanceof Inet4Address)) throw new Exception("must be IPv4"); } else if(tempCfg.ipVersionVal == IPv6_VERSION_VAL) { if(!(adr instanceof Inet6Address)) throw new Exception("must be IPv6"); } else throw new Exception("some inconsistancy"); tempCfg.ipAddressMulticast = adr.getHostAddress(); tempCfg.ipAddressMulticastVal = adr; } catch(Exception e) { throw new Exception("Invalid ipAddressMulticast - " + e); } // validate RERRSendingMode if(tempCfg.RERRSendingMode.toLowerCase().equals(RERR_UNICAST)) { tempCfg.RERRSendingModeVal = RERR_UNICAST_VAL; } else if(tempCfg.RERRSendingMode.toLowerCase().equals(RERR_MULTICAST)) { tempCfg.RERRSendingModeVal = RERR_MULTICAST_VAL; } else { throw new Exception("Invalid RERRSendingMode - should be " + RERR_UNICAST + " or " + RERR_MULTICAST + " "); } // validate deletePeriodMode try { if(tempCfg.deletePeriodMode.toLowerCase().equals(DELETE_MODE_HELLO)) tempCfg.deletePeriodModeVal = DELETE_MODE_HELLO_VAL; else if(tempCfg.deletePeriodMode.toLowerCase().equals(DELETE_MODE_LINKLAYER)) tempCfg.deletePeriodModeVal = DELETE_MODE_LINKLAYER_VAL; else throw new Exception(); } catch(Exception e) { throw new Exception("Invalid DeletePeriodMode (" + DELETE_MODE_HELLO + " or " + DELETE_MODE_LINKLAYER + ")"); } // validate routeDiscoveryMode try { if(tempCfg.routeDiscoveryMode.toLowerCase().equals(ROUTE_DISCOVERY_ERS)) tempCfg.routeDiscoveryModeVal = ROUTE_DISCOVERY_ERS_VAL; else if(tempCfg.routeDiscoveryMode.toLowerCase().equals(ROUTE_DISCOVERY_NON_ERS)) tempCfg.routeDiscoveryModeVal = ROUTE_DISCOVERY_NON_ERS_VAL; else throw new Exception(); } catch(Exception e) { throw new Exception("Invalid RouteDiscoveryMode (" + ROUTE_DISCOVERY_ERS + " or " + ROUTE_DISCOVERY_NON_ERS + ")"); } // validate packetBuffering try { if(tempCfg.packetBuffering.toLowerCase().equals(YES)) tempCfg.packetBufferingVal = true; else if(tempCfg.packetBuffering.toLowerCase().equals(NO)) tempCfg.packetBufferingVal = false; else throw new Exception(); } catch(Exception e) { throw new Exception("Invalid PacketBuffering (" + YES + " or " + NO + ")"); } // validate activeRouteTimeout try { int num = Integer.parseInt(tempCfg.activeRouteTimeout); if(num <= 0) throw new Exception(); tempCfg.activeRouteTimeoutVal = num; } catch(Exception e) { throw new Exception("Invalid activeRouteTimeout"); } // validate allowedHelloLoss try { int num = Integer.parseInt(tempCfg.allowedHelloLoss); if(num <= 0) throw new Exception(); tempCfg.allowedHelloLossVal = num; } catch(Exception e) { throw new Exception("Invalid AllowedHelloLoss"); } // validate helloInterval try { int num = Integer.parseInt(tempCfg.helloInterval); if(num <= 0) throw new Exception(); tempCfg.helloIntervalVal = num; } catch(Exception e) { throw new Exception("Invalid HelloInterval"); } // validate localAddTTL try { int num = Integer.parseInt(tempCfg.localAddTTL); if(num <= 0) throw new Exception(); tempCfg.localAddTTLVal = num; } catch(Exception e) { throw new Exception("Invalid LocalAddTTL"); } // validate netDiameter try { int num = Integer.parseInt(tempCfg.netDiameter); if(num <= 0) throw new Exception(); tempCfg.netDiameterVal = num; } catch(Exception e) { throw new Exception("Invalid NetDiameter"); } // validate nodeTraversalTime try { int num = Integer.parseInt(tempCfg.nodeTraversalTime); if(num <= 0) throw new Exception(); tempCfg.nodeTraversalTimeVal = num; } catch(Exception e) { throw new Exception("Invalid nodeTraversalTime"); } // validate RERRRatelimit try { int num = Integer.parseInt(tempCfg.RERRRatelimit); if(num <= 0) throw new Exception(); tempCfg.RERRRatelimitVal = num; } catch(Exception e) { throw new Exception("Invalid RERRRatelimit"); } // validate RREQRetries try { int num = Integer.parseInt(tempCfg.RREQRetries); if(num <= 0) throw new Exception(); tempCfg.RREQRetriesVal = num; } catch(Exception e) { throw new Exception("Invalid RREQRetries"); } // validate RREQRateLimit try { int num = Integer.parseInt(tempCfg.RREQRateLimit); if(num <= 0) throw new Exception(); tempCfg.RREQRateLimitVal = num; } catch(Exception e) { throw new Exception("Invalid RREQRateLimit"); } // validate timeoutBuffer try { int num = Integer.parseInt(tempCfg.timeoutBuffer); if(num <= 0) throw new Exception(); tempCfg.timeoutBufferVal = num; } catch(Exception e) { throw new Exception("Invalid TimeoutBuffer"); } // validate TTLStart try { int num = Integer.parseInt(tempCfg.TTLStart); if(num <= 0) throw new Exception(); tempCfg.TTLStartVal = num; } catch(Exception e) { throw new Exception("Invalid TTLStart"); } // validate TTLIncrement try { int num = Integer.parseInt(tempCfg.TTLIncrement); if(num <= 0) throw new Exception(); tempCfg.TTLIncrementVal = num; } catch(Exception e) { throw new Exception("Invalid TTLIncrement"); } // validate TTLThreshold try { int num = Integer.parseInt(tempCfg.TTLThreshold); if(num <= 0) throw new Exception(); tempCfg.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; } } /** * Method to get values from a given config object * @param ConfigInfo tempCfg - Config object, from which to * get values */ public void setValuesUsing(ConfigInfo tempCfg) { executionMode = tempCfg.executionMode; osInUse = tempCfg.osInUse; ipVersion = tempCfg.ipVersion; ipAddress = tempCfg.ipAddress; ifaceName = tempCfg.ifaceName; ipAddressGateway = tempCfg.ipAddressGateway; loIfaceName = tempCfg.loIfaceName; loggingStatus = tempCfg.loggingStatus; loggingLevel = tempCfg.loggingLevel; logFile = tempCfg.logFile; pathToSystemCmds = tempCfg.pathToSystemCmds; onlyDestination = tempCfg.onlyDestination; gratuitousRREP = tempCfg.gratuitousRREP; RREPAckRequired = tempCfg.RREPAckRequired; ipAddressMulticast = tempCfg.ipAddressMulticast; RERRSendingMode = tempCfg.RERRSendingMode; deletePeriodMode = tempCfg.deletePeriodMode; routeDiscoveryMode = tempCfg.routeDiscoveryMode; packetBuffering = tempCfg.packetBuffering; activeRouteTimeout = tempCfg.activeRouteTimeout; allowedHelloLoss = tempCfg.allowedHelloLoss; helloInterval = tempCfg.helloInterval; localAddTTL = tempCfg.localAddTTL; netDiameter = tempCfg.netDiameter; nodeTraversalTime = tempCfg.nodeTraversalTime; RERRRatelimit = tempCfg.RERRRatelimit; RREQRetries = tempCfg.RREQRetries; RREQRateLimit = tempCfg.RREQRateLimit; timeoutBuffer = tempCfg.timeoutBuffer; TTLStart = tempCfg.TTLStart; TTLIncrement = tempCfg.TTLIncrement; TTLThreshold = tempCfg.TTLThreshold; // actual data values executionModeVal = tempCfg.executionModeVal; osInUseVal = tempCfg.osInUseVal; ipVersionVal = tempCfg.ipVersionVal; ipAddressVal = tempCfg.ipAddressVal; ifaceNameVal = tempCfg.ifaceNameVal; ipAddressGatewayVal = tempCfg.ipAddressGatewayVal; loIfaceNameVal = tempCfg.loIfaceNameVal; loggingStatusVal = tempCfg.loggingStatusVal; loggingLevelVal = tempCfg.loggingLevelVal; logFileVal = tempCfg.logFileVal; pathToSystemCmdsVal = tempCfg.pathToSystemCmdsVal; onlyDestinationVal = tempCfg.onlyDestinationVal; gratuitousRREPVal = tempCfg.gratuitousRREPVal; RREPAckRequiredVal = tempCfg.RREPAckRequiredVal; ipAddressMulticastVal = tempCfg.ipAddressMulticastVal; RERRSendingModeVal = tempCfg.RERRSendingModeVal; deletePeriodModeVal = tempCfg.deletePeriodModeVal; routeDiscoveryModeVal = tempCfg.routeDiscoveryModeVal; packetBufferingVal = tempCfg.packetBufferingVal; activeRouteTimeoutVal = tempCfg.activeRouteTimeoutVal; allowedHelloLossVal = tempCfg.allowedHelloLossVal; helloIntervalVal = tempCfg.helloIntervalVal; localAddTTLVal = tempCfg.localAddTTLVal; netDiameterVal = tempCfg.netDiameterVal; nodeTraversalTimeVal = tempCfg.nodeTraversalTimeVal; RERRRatelimitVal = tempCfg.RERRRatelimitVal; RREQRetriesVal = tempCfg.RREQRetriesVal; RREQRateLimitVal = tempCfg.RREQRateLimitVal; timeoutBufferVal = tempCfg.timeoutBufferVal; TTLStartVal = tempCfg.TTLStartVal; TTLIncrementVal = tempCfg.TTLIncrementVal; TTLThresholdVal = tempCfg.TTLThresholdVal; 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; } infoChanged = true; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -