}
IPv4Address ipv4Address = new IPv4Address(ipAndSubnet[0]);
ipv4Address.setSubnet(Integer.parseInt(ipAndSubnet[1]));
int ipAddressInt = ipv4Address.getIPv4AddressInt();
IPAddress ipAddress = new IPAddress();
ipAddress.setIpAddressValue(ipAddressInt);
ipAddress.setSubnet(Integer.parseInt(ipAndSubnet[1]));
short maskingBits = (short) (ipAddress.getSubnet());
int wildCardSource = OFMatch.OFPFW_ALL
^ OFMatch.OFPFW_DL_TYPE
^ OFMatch.OFPFW_NW_SRC_ALL
^ (((maskingBits) - 1) << OFMatch.OFPFW_NW_SRC_SHIFT);
OFMatch ofMatchSource = new OFMatch();
ofMatchSource.setDataLayerType((short) 0x0800);
ofMatchSource.setNetworkSource(ipAddress
.getIpAddressValue());
ofMatchSource.setWildcards(wildCardSource);
ofMatch = ofMatchSource;
OFFlowMod flowModRule = new OFFlowMod();
flowModRule.setCommand(OFFlowMod.OFPFC_MODIFY_STRICT);
flowModRule.setPriority(changedFlow.getPriority());
flowModRule.setHardTimeout((short) 0);
flowModRule.setIdleTimeout((short) 0);
flowModRule.setBufferId(-1);
flowModRule.setMatch(ofMatch);
OFActionOutput ofAction = new OFActionOutput();
ofAction.setPort(increasedPort);
ArrayList<OFAction> actions = new ArrayList<OFAction>();
actions.add(ofAction);
if (mirroredPorts.get(increasedPort) != null) {
OFActionOutput ofActionMirror = new OFActionOutput();
ofActionMirror
.setPort(mirroredPorts.get(increasedPort));
actions.add(ofActionMirror);
}
flowModRule.setActions(actions);
flowMods.add(flowModRule);
OFMatch ofMatchDest = new OFMatch();
ofMatchDest.setDataLayerType((short) 0x0800);
ofMatchDest.setNetworkDestination(ipAddress
.getIpAddressValue());
int wildCardDest = OFMatch.OFPFW_ALL
^ OFMatch.OFPFW_DL_TYPE
^ OFMatch.OFPFW_NW_DST_ALL
^ (((maskingBits) - 1) << OFMatch.OFPFW_NW_DST_SHIFT);
ofMatchDest.setWildcards(wildCardDest);
OFFlowMod flowModRule1 = new OFFlowMod();
flowModRule1.setCommand(OFFlowMod.OFPFC_MODIFY_STRICT);
flowModRule1.setPriority(changedFlow.getPriority());
flowModRule1.setHardTimeout((short) 0);
flowModRule1.setIdleTimeout((short) 0);
flowModRule1.setBufferId(-1);
flowModRule1.setMatch(ofMatchDest);
flowModRule1.setActions(actions);
flowMods.add(flowModRule1);
}
pattern = Pattern
.compile("nw_dst=([0-9]+.[0-9]+.[0-9]+.[0-9]+)/([0-9]*)");
matcher = pattern.matcher(changedFlow.getFlowString());
while (matcher.find()) {
try {
logger.debug("ip address is {} and subnet is {}",
matcher.group(1), matcher.group(2));
} catch (IndexOutOfBoundsException ioe) {
break;
}
IPv4Address ipv4Address = new IPv4Address(matcher.group(1));
ipv4Address.setSubnet(Integer.parseInt(matcher.group(2)));
int ipAddressInt = ipv4Address.getIPv4AddressInt();
IPAddress ipAddress = new IPAddress();
ipAddress.setIpAddressValue(ipAddressInt);
ipAddress.setSubnet(Integer.parseInt(matcher.group(2)));
short maskingBits = (short) (ipAddress.getSubnet());
int wildCardDestination = OFMatch.OFPFW_ALL
^ OFMatch.OFPFW_DL_TYPE
^ OFMatch.OFPFW_NW_DST_ALL
^ (((maskingBits) - 1) << OFMatch.OFPFW_NW_DST_SHIFT);
OFMatch ofMatchDestination = new OFMatch();
ofMatchDestination.setDataLayerType((short) 0x0800);
ofMatchDestination.setNetworkDestination(ipAddress
.getIpAddressValue());
ofMatchDestination.setWildcards(wildCardDestination);
ofMatch = ofMatchDestination;
OFFlowMod flowModRule = new OFFlowMod();
flowModRule.setCommand(OFFlowMod.OFPFC_MODIFY_STRICT);
flowModRule.setHardTimeout((short) 0);
flowModRule.setIdleTimeout((short) 0);
flowModRule.setBufferId(-1);
flowModRule.setMatch(ofMatch);
flowModRule.setPriority(changedFlow.getPriority());
OFActionOutput ofAction = new OFActionOutput();
ofAction.setPort(increasedPort);
ArrayList<OFAction> actions = new ArrayList<OFAction>();
actions.add(ofAction);
if (mirroredPorts.get(increasedPort) != null) {
OFActionOutput ofActionMirror = new OFActionOutput();
ofActionMirror
.setPort(mirroredPorts.get(increasedPort));
actions.add(ofActionMirror);
}
flowModRule.setActions(actions);
flowMods.add(flowModRule);
OFMatch ofMatchSrc = new OFMatch();
ofMatchSrc.setDataLayerType((short) 0x0800);
ofMatchSrc.setNetworkSource(ipAddress.getIpAddressValue());
int wildCardSrc = OFMatch.OFPFW_ALL
^ OFMatch.OFPFW_DL_TYPE
^ OFMatch.OFPFW_NW_SRC_ALL
^ (((maskingBits) - 1) << OFMatch.OFPFW_NW_SRC_SHIFT);