Fix for ONOS-607 - controller port displayed incorrectly in CLI
CONTROLLER ports were displayed as 18446744073709551613 for output instructions. Change-Id: Id62f7ebe9e140a0a2c3c2387fbabfb3305f4273d
Showing
1 changed file
with
39 additions
and
8 deletions
... | @@ -31,13 +31,21 @@ public final class PortNumber { | ... | @@ -31,13 +31,21 @@ public final class PortNumber { |
31 | private static final long MAX_NUMBER = (2L * Integer.MAX_VALUE) + 1; | 31 | private static final long MAX_NUMBER = (2L * Integer.MAX_VALUE) + 1; |
32 | 32 | ||
33 | 33 | ||
34 | - public static final PortNumber IN_PORT = new PortNumber(-8); | 34 | + static final long IN_PORT_NUMBER = -8L; |
35 | - public static final PortNumber TABLE = new PortNumber(-7); | 35 | + static final long TABLE_NUMBER = -7L; |
36 | - public static final PortNumber NORMAL = new PortNumber(-6); | 36 | + static final long NORMAL_NUMBER = -6L; |
37 | - public static final PortNumber FLOOD = new PortNumber(-5); | 37 | + static final long FLOOD_NUMBER = -5L; |
38 | - public static final PortNumber ALL = new PortNumber(-4); | 38 | + static final long ALL_NUMBER = -4L; |
39 | - public static final PortNumber LOCAL = new PortNumber(-2); | 39 | + static final long LOCAL_NUMBER = -2L; |
40 | - public static final PortNumber CONTROLLER = new PortNumber(-3); | 40 | + static final long CONTROLLER_NUMBER = -3L; |
41 | + | ||
42 | + public static final PortNumber IN_PORT = new PortNumber(IN_PORT_NUMBER); | ||
43 | + public static final PortNumber TABLE = new PortNumber(TABLE_NUMBER); | ||
44 | + public static final PortNumber NORMAL = new PortNumber(NORMAL_NUMBER); | ||
45 | + public static final PortNumber FLOOD = new PortNumber(FLOOD_NUMBER); | ||
46 | + public static final PortNumber ALL = new PortNumber(ALL_NUMBER); | ||
47 | + public static final PortNumber LOCAL = new PortNumber(LOCAL_NUMBER); | ||
48 | + public static final PortNumber CONTROLLER = new PortNumber(CONTROLLER_NUMBER); | ||
41 | 49 | ||
42 | private final long number; | 50 | private final long number; |
43 | 51 | ||
... | @@ -85,9 +93,32 @@ public final class PortNumber { | ... | @@ -85,9 +93,32 @@ public final class PortNumber { |
85 | return number; | 93 | return number; |
86 | } | 94 | } |
87 | 95 | ||
96 | + private String decodeLogicalPort() { | ||
97 | + if (number == CONTROLLER_NUMBER) { | ||
98 | + return "CONTROLLER"; | ||
99 | + } else if (number == LOCAL_NUMBER) { | ||
100 | + return "LOCAL"; | ||
101 | + } else if (number == ALL_NUMBER) { | ||
102 | + return "ALL"; | ||
103 | + } else if (number == FLOOD_NUMBER) { | ||
104 | + return "FLOOD"; | ||
105 | + } else if (number == NORMAL_NUMBER) { | ||
106 | + return "NORMAL"; | ||
107 | + } else if (number == TABLE_NUMBER) { | ||
108 | + return "TABLE"; | ||
109 | + } else if (number == IN_PORT_NUMBER) { | ||
110 | + return "IN_PORT"; | ||
111 | + } | ||
112 | + return "UNKNOWN"; | ||
113 | + } | ||
114 | + | ||
88 | @Override | 115 | @Override |
89 | public String toString() { | 116 | public String toString() { |
90 | - return UnsignedLongs.toString(number); | 117 | + if (!isLogical()) { |
118 | + return UnsignedLongs.toString(number); | ||
119 | + } else { | ||
120 | + return decodeLogicalPort(); | ||
121 | + } | ||
91 | } | 122 | } |
92 | 123 | ||
93 | @Override | 124 | @Override | ... | ... |
-
Please register or login to post a comment