Port ranges for PF rules: public port start should be equal to ending port start; the same applies to end ports

This commit is contained in:
Alena Prokharchyk 2012-09-14 11:38:07 -07:00 committed by Edison Su
parent 2392f655b0
commit aa8048aa04
2 changed files with 9 additions and 1 deletions

View File

@ -66,7 +66,6 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
@Parameter(name = ApiConstants.PRIVATE_END_PORT, type = CommandType.INTEGER, required = false, description = "the ending port of port forwarding rule's private port range")
private Integer privateEndPort;
@Parameter(name = ApiConstants.PUBLIC_START_PORT, type = CommandType.INTEGER, required = true,
description = "the starting port of port forwarding rule's public port range")
private Integer publicStartPort;

View File

@ -244,6 +244,15 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
} else {
dstIp = new Ip(guestNic.getIp4Address());
}
//source start port and source dest port should be the same. The same applies to dest ports
if (rule.getSourcePortStart().intValue() != rule.getDestinationPortStart()) {
throw new InvalidParameterValueException("Private port start should be equal to public port start", null);
}
if (rule.getSourcePortEnd().intValue() != rule.getDestinationPortEnd()) {
throw new InvalidParameterValueException("Private port end should be equal to public port end", null);
}
Transaction txn = Transaction.currentTxn();
txn.start();