Showing
8 changed files
with
27 additions
and
43 deletions
... | @@ -126,8 +126,8 @@ public class PeerConnectivity { | ... | @@ -126,8 +126,8 @@ public class PeerConnectivity { |
126 | TrafficSelector selector = DefaultTrafficSelector.builder() | 126 | TrafficSelector selector = DefaultTrafficSelector.builder() |
127 | .matchEthType(Ethernet.TYPE_IPV4) | 127 | .matchEthType(Ethernet.TYPE_IPV4) |
128 | .matchIPProtocol(IPv4.PROTOCOL_TCP) | 128 | .matchIPProtocol(IPv4.PROTOCOL_TCP) |
129 | - .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toRealInt(), IPV4_BIT_LENGTH)) | 129 | + .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) |
130 | - .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toRealInt(), IPV4_BIT_LENGTH)) | 130 | + .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) |
131 | .matchTcpDst(BGP_PORT) | 131 | .matchTcpDst(BGP_PORT) |
132 | .build(); | 132 | .build(); |
133 | 133 | ||
... | @@ -147,8 +147,8 @@ public class PeerConnectivity { | ... | @@ -147,8 +147,8 @@ public class PeerConnectivity { |
147 | selector = DefaultTrafficSelector.builder() | 147 | selector = DefaultTrafficSelector.builder() |
148 | .matchEthType(Ethernet.TYPE_IPV4) | 148 | .matchEthType(Ethernet.TYPE_IPV4) |
149 | .matchIPProtocol(IPv4.PROTOCOL_TCP) | 149 | .matchIPProtocol(IPv4.PROTOCOL_TCP) |
150 | - .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toRealInt(), IPV4_BIT_LENGTH)) | 150 | + .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) |
151 | - .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toRealInt(), IPV4_BIT_LENGTH)) | 151 | + .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) |
152 | .matchTcpSrc(BGP_PORT) | 152 | .matchTcpSrc(BGP_PORT) |
153 | .build(); | 153 | .build(); |
154 | 154 | ||
... | @@ -165,8 +165,8 @@ public class PeerConnectivity { | ... | @@ -165,8 +165,8 @@ public class PeerConnectivity { |
165 | selector = DefaultTrafficSelector.builder() | 165 | selector = DefaultTrafficSelector.builder() |
166 | .matchEthType(Ethernet.TYPE_IPV4) | 166 | .matchEthType(Ethernet.TYPE_IPV4) |
167 | .matchIPProtocol(IPv4.PROTOCOL_TCP) | 167 | .matchIPProtocol(IPv4.PROTOCOL_TCP) |
168 | - .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toRealInt(), IPV4_BIT_LENGTH)) | 168 | + .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) |
169 | - .matchIPDst(IpPrefix.valueOf(bgpdAddress.toRealInt(), IPV4_BIT_LENGTH)) | 169 | + .matchIPDst(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) |
170 | .matchTcpDst(BGP_PORT) | 170 | .matchTcpDst(BGP_PORT) |
171 | .build(); | 171 | .build(); |
172 | 172 | ||
... | @@ -183,8 +183,8 @@ public class PeerConnectivity { | ... | @@ -183,8 +183,8 @@ public class PeerConnectivity { |
183 | selector = DefaultTrafficSelector.builder() | 183 | selector = DefaultTrafficSelector.builder() |
184 | .matchEthType(Ethernet.TYPE_IPV4) | 184 | .matchEthType(Ethernet.TYPE_IPV4) |
185 | .matchIPProtocol(IPv4.PROTOCOL_TCP) | 185 | .matchIPProtocol(IPv4.PROTOCOL_TCP) |
186 | - .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toRealInt(), IPV4_BIT_LENGTH)) | 186 | + .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) |
187 | - .matchIPDst(IpPrefix.valueOf(bgpdAddress.toRealInt(), IPV4_BIT_LENGTH)) | 187 | + .matchIPDst(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) |
188 | .matchTcpSrc(BGP_PORT) | 188 | .matchTcpSrc(BGP_PORT) |
189 | .build(); | 189 | .build(); |
190 | 190 | ||
... | @@ -251,8 +251,8 @@ public class PeerConnectivity { | ... | @@ -251,8 +251,8 @@ public class PeerConnectivity { |
251 | TrafficSelector selector = DefaultTrafficSelector.builder() | 251 | TrafficSelector selector = DefaultTrafficSelector.builder() |
252 | .matchEthType(Ethernet.TYPE_IPV4) | 252 | .matchEthType(Ethernet.TYPE_IPV4) |
253 | .matchIPProtocol(IPv4.PROTOCOL_ICMP) | 253 | .matchIPProtocol(IPv4.PROTOCOL_ICMP) |
254 | - .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toRealInt(), IPV4_BIT_LENGTH)) | 254 | + .matchIPSrc(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) |
255 | - .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toRealInt(), IPV4_BIT_LENGTH)) | 255 | + .matchIPDst(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) |
256 | .build(); | 256 | .build(); |
257 | 257 | ||
258 | TrafficTreatment treatment = DefaultTrafficTreatment.builder() | 258 | TrafficTreatment treatment = DefaultTrafficTreatment.builder() |
... | @@ -269,8 +269,8 @@ public class PeerConnectivity { | ... | @@ -269,8 +269,8 @@ public class PeerConnectivity { |
269 | selector = DefaultTrafficSelector.builder() | 269 | selector = DefaultTrafficSelector.builder() |
270 | .matchEthType(Ethernet.TYPE_IPV4) | 270 | .matchEthType(Ethernet.TYPE_IPV4) |
271 | .matchIPProtocol(IPv4.PROTOCOL_ICMP) | 271 | .matchIPProtocol(IPv4.PROTOCOL_ICMP) |
272 | - .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toRealInt(), IPV4_BIT_LENGTH)) | 272 | + .matchIPSrc(IpPrefix.valueOf(bgpdPeerAddress.toInt(), IPV4_BIT_LENGTH)) |
273 | - .matchIPDst(IpPrefix.valueOf(bgpdAddress.toRealInt(), IPV4_BIT_LENGTH)) | 273 | + .matchIPDst(IpPrefix.valueOf(bgpdAddress.toInt(), IPV4_BIT_LENGTH)) |
274 | .build(); | 274 | .build(); |
275 | 275 | ||
276 | PointToPointIntent reversedIntent = new PointToPointIntent( | 276 | PointToPointIntent reversedIntent = new PointToPointIntent( | ... | ... |
... | @@ -58,7 +58,7 @@ public class RouteEntry { | ... | @@ -58,7 +58,7 @@ public class RouteEntry { |
58 | } | 58 | } |
59 | 59 | ||
60 | StringBuilder result = new StringBuilder(ip4Prefix.prefixLength()); | 60 | StringBuilder result = new StringBuilder(ip4Prefix.prefixLength()); |
61 | - long value = ip4Prefix.toRealInt(); | 61 | + long value = ip4Prefix.toInt(); |
62 | for (int i = 0; i < ip4Prefix.prefixLength(); i++) { | 62 | for (int i = 0; i < ip4Prefix.prefixLength(); i++) { |
63 | long mask = 1 << (IpAddress.MAX_INET_MASK - 1 - i); | 63 | long mask = 1 << (IpAddress.MAX_INET_MASK - 1 - i); |
64 | result.append(((value & mask) == 0) ? "0" : "1"); | 64 | result.append(((value & mask) == 0) ? "0" : "1"); | ... | ... |
... | @@ -94,7 +94,7 @@ public class Router implements RouteListener { | ... | @@ -94,7 +94,7 @@ public class Router implements RouteListener { |
94 | private volatile boolean isElectedLeader = false; | 94 | private volatile boolean isElectedLeader = false; |
95 | private volatile boolean isActivatedLeader = false; | 95 | private volatile boolean isActivatedLeader = false; |
96 | 96 | ||
97 | - // For routes announced by local BGP deamon in SDN network, | 97 | + // For routes announced by local BGP daemon in SDN network, |
98 | // the next hop will be 0.0.0.0. | 98 | // the next hop will be 0.0.0.0. |
99 | public static final IpAddress LOCAL_NEXT_HOP = IpAddress.valueOf("0.0.0.0"); | 99 | public static final IpAddress LOCAL_NEXT_HOP = IpAddress.valueOf("0.0.0.0"); |
100 | 100 | ... | ... |
... | @@ -1226,7 +1226,7 @@ public class BgpSession extends SimpleChannelHandler { | ... | @@ -1226,7 +1226,7 @@ public class BgpSession extends SimpleChannelHandler { |
1226 | } | 1226 | } |
1227 | address <<= extraShift; | 1227 | address <<= extraShift; |
1228 | IpPrefix prefix = | 1228 | IpPrefix prefix = |
1229 | - IpPrefix.valueOf(IpAddress.valueOf((int) address).toRealInt(), | 1229 | + IpPrefix.valueOf(IpAddress.valueOf((int) address).toInt(), |
1230 | (short) prefixBitlen); | 1230 | (short) prefixBitlen); |
1231 | result.add(prefix); | 1231 | result.add(prefix); |
1232 | } | 1232 | } |
... | @@ -1600,7 +1600,7 @@ public class BgpSession extends SimpleChannelHandler { | ... | @@ -1600,7 +1600,7 @@ public class BgpSession extends SimpleChannelHandler { |
1600 | message.writeByte(localBgpVersion); | 1600 | message.writeByte(localBgpVersion); |
1601 | message.writeShort((int) localAs); | 1601 | message.writeShort((int) localAs); |
1602 | message.writeShort((int) localHoldtime); | 1602 | message.writeShort((int) localHoldtime); |
1603 | - message.writeInt(bgpSessionManager.getMyBgpId().toRealInt()); | 1603 | + message.writeInt(bgpSessionManager.getMyBgpId().toInt()); |
1604 | message.writeByte(0); // No Optional Parameters | 1604 | message.writeByte(0); // No Optional Parameters |
1605 | return prepareBgpMessage(BgpConstants.BGP_TYPE_OPEN, message); | 1605 | return prepareBgpMessage(BgpConstants.BGP_TYPE_OPEN, message); |
1606 | } | 1606 | } | ... | ... |
... | @@ -355,7 +355,7 @@ public class ProxyArpManager implements ProxyArpService { | ... | @@ -355,7 +355,7 @@ public class ProxyArpManager implements ProxyArpService { |
355 | 355 | ||
356 | arp.setTargetProtocolAddress(((ARP) request.getPayload()) | 356 | arp.setTargetProtocolAddress(((ARP) request.getPayload()) |
357 | .getSenderProtocolAddress()); | 357 | .getSenderProtocolAddress()); |
358 | - arp.setSenderProtocolAddress(srcIp.toRealInt()); | 358 | + arp.setSenderProtocolAddress(srcIp.toInt()); |
359 | eth.setPayload(arp); | 359 | eth.setPayload(arp); |
360 | return eth; | 360 | return eth; |
361 | } | 361 | } | ... | ... |
... | @@ -161,10 +161,10 @@ public class FlowModBuilder { | ... | @@ -161,10 +161,10 @@ public class FlowModBuilder { |
161 | switch (l3m.subtype()) { | 161 | switch (l3m.subtype()) { |
162 | case IP_DST: | 162 | case IP_DST: |
163 | ip = (ModIPInstruction) i; | 163 | ip = (ModIPInstruction) i; |
164 | - return factory.actions().setNwDst(IPv4Address.of(ip.ip().toRealInt())); | 164 | + return factory.actions().setNwDst(IPv4Address.of(ip.ip().toInt())); |
165 | case IP_SRC: | 165 | case IP_SRC: |
166 | ip = (ModIPInstruction) i; | 166 | ip = (ModIPInstruction) i; |
167 | - return factory.actions().setNwSrc(IPv4Address.of(ip.ip().toRealInt())); | 167 | + return factory.actions().setNwSrc(IPv4Address.of(ip.ip().toInt())); |
168 | default: | 168 | default: |
169 | log.warn("Unimplemented action type {}.", l3m.subtype()); | 169 | log.warn("Unimplemented action type {}.", l3m.subtype()); |
170 | break; | 170 | break; |
... | @@ -220,21 +220,21 @@ public class FlowModBuilder { | ... | @@ -220,21 +220,21 @@ public class FlowModBuilder { |
220 | case IPV4_DST: | 220 | case IPV4_DST: |
221 | ip = (IPCriterion) c; | 221 | ip = (IPCriterion) c; |
222 | if (ip.ip().isMasked()) { | 222 | if (ip.ip().isMasked()) { |
223 | - Masked<IPv4Address> maskedIp = Masked.of(IPv4Address.of(ip.ip().toRealInt()), | 223 | + Masked<IPv4Address> maskedIp = Masked.of(IPv4Address.of(ip.ip().toInt()), |
224 | - IPv4Address.of(ip.ip().netmask().toRealInt())); | 224 | + IPv4Address.of(ip.ip().netmask().toInt())); |
225 | mBuilder.setMasked(MatchField.IPV4_DST, maskedIp); | 225 | mBuilder.setMasked(MatchField.IPV4_DST, maskedIp); |
226 | } else { | 226 | } else { |
227 | - mBuilder.setExact(MatchField.IPV4_DST, IPv4Address.of(ip.ip().toRealInt())); | 227 | + mBuilder.setExact(MatchField.IPV4_DST, IPv4Address.of(ip.ip().toInt())); |
228 | } | 228 | } |
229 | break; | 229 | break; |
230 | case IPV4_SRC: | 230 | case IPV4_SRC: |
231 | ip = (IPCriterion) c; | 231 | ip = (IPCriterion) c; |
232 | if (ip.ip().isMasked()) { | 232 | if (ip.ip().isMasked()) { |
233 | - Masked<IPv4Address> maskedIp = Masked.of(IPv4Address.of(ip.ip().toRealInt()), | 233 | + Masked<IPv4Address> maskedIp = Masked.of(IPv4Address.of(ip.ip().toInt()), |
234 | - IPv4Address.of(ip.ip().netmask().toRealInt())); | 234 | + IPv4Address.of(ip.ip().netmask().toInt())); |
235 | mBuilder.setMasked(MatchField.IPV4_SRC, maskedIp); | 235 | mBuilder.setMasked(MatchField.IPV4_SRC, maskedIp); |
236 | } else { | 236 | } else { |
237 | - mBuilder.setExact(MatchField.IPV4_SRC, IPv4Address.of(ip.ip().toRealInt())); | 237 | + mBuilder.setExact(MatchField.IPV4_SRC, IPv4Address.of(ip.ip().toInt())); |
238 | } | 238 | } |
239 | break; | 239 | break; |
240 | case IP_PROTO: | 240 | case IP_PROTO: | ... | ... |
... | @@ -176,14 +176,6 @@ public final class IpAddress implements Comparable<IpAddress> { | ... | @@ -176,14 +176,6 @@ public final class IpAddress implements Comparable<IpAddress> { |
176 | * @return the IP address's value as an integer | 176 | * @return the IP address's value as an integer |
177 | */ | 177 | */ |
178 | public int toInt() { | 178 | public int toInt() { |
179 | - int address = 0; | ||
180 | - for (int i = 0; i < INET_LEN; i++) { | ||
181 | - address |= octets[i] << ((INET_LEN - (i + 1)) * 8); | ||
182 | - } | ||
183 | - return address; | ||
184 | - } | ||
185 | - | ||
186 | - public int toRealInt() { | ||
187 | int val = 0; | 179 | int val = 0; |
188 | for (int i = 0; i < octets.length; i++) { | 180 | for (int i = 0; i < octets.length; i++) { |
189 | val <<= 8; | 181 | val <<= 8; |
... | @@ -292,8 +284,8 @@ public final class IpAddress implements Comparable<IpAddress> { | ... | @@ -292,8 +284,8 @@ public final class IpAddress implements Comparable<IpAddress> { |
292 | 284 | ||
293 | @Override | 285 | @Override |
294 | public int compareTo(IpAddress o) { | 286 | public int compareTo(IpAddress o) { |
295 | - Long lv = ((long) this.toRealInt()) & 0xffffffffL; | 287 | + Long lv = ((long) this.toInt()) & 0xffffffffL; |
296 | - Long rv = ((long) o.toRealInt()) & 0xffffffffL; | 288 | + Long rv = ((long) o.toInt()) & 0xffffffffL; |
297 | return lv.compareTo(rv); | 289 | return lv.compareTo(rv); |
298 | } | 290 | } |
299 | 291 | ... | ... |
... | @@ -173,14 +173,6 @@ public final class IpPrefix { | ... | @@ -173,14 +173,6 @@ public final class IpPrefix { |
173 | * @return the IP address's value as an integer | 173 | * @return the IP address's value as an integer |
174 | */ | 174 | */ |
175 | public int toInt() { | 175 | public int toInt() { |
176 | - int address = 0; | ||
177 | - for (int i = 0; i < INET_LEN; i++) { | ||
178 | - address |= octets[i] << ((INET_LEN - (i + 1)) * 8); | ||
179 | - } | ||
180 | - return address; | ||
181 | - } | ||
182 | - | ||
183 | - public int toRealInt() { | ||
184 | int val = 0; | 176 | int val = 0; |
185 | for (int i = 0; i < octets.length; i++) { | 177 | for (int i = 0; i < octets.length; i++) { |
186 | val <<= 8; | 178 | val <<= 8; | ... | ... |
-
Please register or login to post a comment