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 { ...@@ -46,17 +46,32 @@ public class PolicyAddCommand extends AbstractShellCommand {
46 required = false, multiValued = false) 46 required = false, multiValued = false)
47 String srcIp; 47 String srcIp;
48 48
49 - @Argument(index = 3, name = "dst IP", 49 + @Argument(index = 3, name = "src port",
50 + description = "src port",
51 + required = false, multiValued = false)
52 + short srcPort;
53 +
54 + @Argument(index = 4, name = "dst IP",
50 description = "dst IP", 55 description = "dst IP",
51 required = false, multiValued = false) 56 required = false, multiValued = false)
52 String dstIp; 57 String dstIp;
53 58
54 - @Argument(index = 4, name = "policy type", 59 + @Argument(index = 5, name = "dst port",
60 + description = "dst port",
61 + required = false, multiValued = false)
62 + short dstPort;
63 +
64 + @Argument(index = 6, name = "proto",
65 + description = "proto",
66 + required = false, multiValued = false)
67 + String proto;
68 +
69 + @Argument(index = 7, name = "policy type",
55 description = "policy type", 70 description = "policy type",
56 required = true, multiValued = false) 71 required = true, multiValued = false)
57 String policyType; 72 String policyType;
58 73
59 - @Argument(index = 5, name = "tunnel ID", 74 + @Argument(index = 8, name = "tunnel ID",
60 description = "tunnel ID", 75 description = "tunnel ID",
61 required = false, multiValued = false) 76 required = false, multiValued = false)
62 String tunnelId; 77 String tunnelId;
...@@ -77,6 +92,15 @@ public class PolicyAddCommand extends AbstractShellCommand { ...@@ -77,6 +92,15 @@ public class PolicyAddCommand extends AbstractShellCommand {
77 if (dstIp != null) { 92 if (dstIp != null) {
78 tpb.setDstIp(dstIp); 93 tpb.setDstIp(dstIp);
79 } 94 }
95 + if (srcPort != 0) {
96 + tpb.setSrcPort(srcPort);
97 + }
98 + if (dstPort != 0) {
99 + tpb.setDstPort(dstPort);
100 + }
101 + if (!proto.equals("ip")) {
102 + tpb.setIpProto(proto);
103 + }
80 if (Policy.Type.valueOf(policyType) == Policy.Type.TUNNEL_FLOW) { 104 if (Policy.Type.valueOf(policyType) == Policy.Type.TUNNEL_FLOW) {
81 if (tunnelId == null) { 105 if (tunnelId == null) {
82 // TODO: handle errors 106 // TODO: handle errors
......
...@@ -29,7 +29,7 @@ import org.onosproject.segmentrouting.TunnelPolicy; ...@@ -29,7 +29,7 @@ import org.onosproject.segmentrouting.TunnelPolicy;
29 public class PolicyListCommand extends AbstractShellCommand { 29 public class PolicyListCommand extends AbstractShellCommand {
30 30
31 private static final String FORMAT_MAPPING_TUNNEL = 31 private static final String FORMAT_MAPPING_TUNNEL =
32 - " id=%s, type=%s, prio=%d, src=%s, dst=%s, proto=%s, tunnel=%s"; 32 + " id=%s, type=%s, prio=%d, src=%s, port=%d, dst=%s, port=%d, proto=%s, tunnel=%s";
33 33
34 @Override 34 @Override
35 protected void execute() { 35 protected void execute() {
...@@ -43,7 +43,8 @@ public class PolicyListCommand extends AbstractShellCommand { ...@@ -43,7 +43,8 @@ public class PolicyListCommand extends AbstractShellCommand {
43 private void printPolicy(Policy policy) { 43 private void printPolicy(Policy policy) {
44 if (policy.type() == Policy.Type.TUNNEL_FLOW) { 44 if (policy.type() == Policy.Type.TUNNEL_FLOW) {
45 print(FORMAT_MAPPING_TUNNEL, policy.id(), policy.type(), policy.priority(), 45 print(FORMAT_MAPPING_TUNNEL, policy.id(), policy.type(), policy.priority(),
46 - policy.srcIp(), policy.dstIp(), (policy.ipProto() == null) ? "" : policy.ipProto(), 46 + policy.srcIp(), policy.srcPort(), policy.dstIp(), policy.dstPort(),
47 + (policy.ipProto() == null) ? "" : policy.ipProto(),
47 ((TunnelPolicy) policy).tunnelId()); 48 ((TunnelPolicy) policy).tunnelId());
48 } 49 }
49 } 50 }
......