sangho
Committed by Gerrit Code Review

Supports UPD and TCP ports for Segment Routing policy add CLI (srpolicy-add).

Change-Id: Ib55701e429bc1080211bcc09adb0dc2b21ee4461
(cherry picked from commit fe4e3086)
......@@ -46,17 +46,32 @@ public class PolicyAddCommand extends AbstractShellCommand {
required = false, multiValued = false)
String srcIp;
@Argument(index = 3, name = "dst IP",
@Argument(index = 3, name = "src port",
description = "src port",
required = false, multiValued = false)
short srcPort;
@Argument(index = 4, name = "dst IP",
description = "dst IP",
required = false, multiValued = false)
String dstIp;
@Argument(index = 4, name = "policy type",
@Argument(index = 5, name = "dst port",
description = "dst port",
required = false, multiValued = false)
short dstPort;
@Argument(index = 6, name = "proto",
description = "proto",
required = false, multiValued = false)
String proto;
@Argument(index = 7, name = "policy type",
description = "policy type",
required = true, multiValued = false)
String policyType;
@Argument(index = 5, name = "tunnel ID",
@Argument(index = 8, name = "tunnel ID",
description = "tunnel ID",
required = false, multiValued = false)
String tunnelId;
......@@ -77,6 +92,15 @@ public class PolicyAddCommand extends AbstractShellCommand {
if (dstIp != null) {
tpb.setDstIp(dstIp);
}
if (srcPort != 0) {
tpb.setSrcPort(srcPort);
}
if (dstPort != 0) {
tpb.setDstPort(dstPort);
}
if (!proto.equals("ip")) {
tpb.setIpProto(proto);
}
if (Policy.Type.valueOf(policyType) == Policy.Type.TUNNEL_FLOW) {
if (tunnelId == null) {
// TODO: handle errors
......
......@@ -29,7 +29,7 @@ import org.onosproject.segmentrouting.TunnelPolicy;
public class PolicyListCommand extends AbstractShellCommand {
private static final String FORMAT_MAPPING_TUNNEL =
" id=%s, type=%s, prio=%d, src=%s, dst=%s, proto=%s, tunnel=%s";
" id=%s, type=%s, prio=%d, src=%s, port=%d, dst=%s, port=%d, proto=%s, tunnel=%s";
@Override
protected void execute() {
......@@ -43,7 +43,8 @@ public class PolicyListCommand extends AbstractShellCommand {
private void printPolicy(Policy policy) {
if (policy.type() == Policy.Type.TUNNEL_FLOW) {
print(FORMAT_MAPPING_TUNNEL, policy.id(), policy.type(), policy.priority(),
policy.srcIp(), policy.dstIp(), (policy.ipProto() == null) ? "" : policy.ipProto(),
policy.srcIp(), policy.srcPort(), policy.dstIp(), policy.dstPort(),
(policy.ipProto() == null) ? "" : policy.ipProto(),
((TunnelPolicy) policy).tunnelId());
}
}
......