Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String OFController = (String)configs.get(ConfigConstants.DEST_IP);
- String OFPort = (String)configs.get(ConfigConstants.CUSTOM);
- if (_validateIP(OFController) != true) {
- logger.info("Attempting to resolve <" + OFController +
- "> to a valid IP address");
- try {
- OFController = InetAddress.getByName(OFController).getHostAddress();
- } catch (Exception e) {
- e.printStackTrace();
- logger.error("Invalid Address <" + OFController +
- "> Please enter valid IP-Address");
- return false;
- }
- }
- public boolean _validateIP(String ipAddress) {
- String[] octets = ipAddress.split("\\.");
- if (octets.length != 4) {
- return false;
- }
- for (String octect : octets) {
- int i = Integer.parseInt(octect);
- if ((i < 0) || (i > 255)) {
- return false;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement