Committed by
Gerrit Code Review
Remove duplicated multicast prefix declaration
(Following #7957) Also, Update copyright Few documentation improvements Change-Id: If4a6b9f168e9d7587976f1f2b59c2b59b81c6c2f
Showing
7 changed files
with
49 additions
and
20 deletions
1 | /* | 1 | /* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015-2016 Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
... | @@ -97,11 +97,10 @@ public class IgmpSnoop { | ... | @@ -97,11 +97,10 @@ public class IgmpSnoop { |
97 | 97 | ||
98 | private static final int DEFAULT_QUERY_PERIOD_SECS = 60; | 98 | private static final int DEFAULT_QUERY_PERIOD_SECS = 60; |
99 | private static final byte DEFAULT_IGMP_RESP_CODE = 100; | 99 | private static final byte DEFAULT_IGMP_RESP_CODE = 100; |
100 | - private static final String DEFAULT_MCAST_ADDR = "224.0.0.0/4"; | ||
101 | 100 | ||
102 | @Property(name = "multicastAddress", | 101 | @Property(name = "multicastAddress", |
103 | label = "Define the multicast base range to listen to") | 102 | label = "Define the multicast base range to listen to") |
104 | - private String multicastAddress = DEFAULT_MCAST_ADDR; | 103 | + private String multicastAddress = IpPrefix.IPV4_MULTICAST_PREFIX.toString(); |
105 | 104 | ||
106 | @Property(name = "queryPeriod", intValue = DEFAULT_QUERY_PERIOD_SECS, | 105 | @Property(name = "queryPeriod", intValue = DEFAULT_QUERY_PERIOD_SECS, |
107 | label = "Delay in seconds between successive query runs") | 106 | label = "Delay in seconds between successive query runs") |
... | @@ -243,6 +242,7 @@ public class IgmpSnoop { | ... | @@ -243,6 +242,7 @@ public class IgmpSnoop { |
243 | protected void modified(ComponentContext context) { | 242 | protected void modified(ComponentContext context) { |
244 | Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties(); | 243 | Dictionary<?, ?> properties = context != null ? context.getProperties() : new Properties(); |
245 | 244 | ||
245 | + // TODO read multicastAddress from config | ||
246 | String strQueryPeriod = Tools.get(properties, "queryPeriod"); | 246 | String strQueryPeriod = Tools.get(properties, "queryPeriod"); |
247 | String strResponseCode = Tools.get(properties, "maxRespCode"); | 247 | String strResponseCode = Tools.get(properties, "maxRespCode"); |
248 | try { | 248 | try { |
... | @@ -419,11 +419,11 @@ public class IgmpSnoop { | ... | @@ -419,11 +419,11 @@ public class IgmpSnoop { |
419 | 419 | ||
420 | 420 | ||
421 | if (ip.getProtocol() != IPv4.PROTOCOL_IGMP || | 421 | if (ip.getProtocol() != IPv4.PROTOCOL_IGMP || |
422 | - !IpPrefix.IPV4_MULTICAST_RANGE.contains(gaddr)) { | 422 | + !IpPrefix.IPV4_MULTICAST_PREFIX.contains(gaddr)) { |
423 | return; | 423 | return; |
424 | } | 424 | } |
425 | 425 | ||
426 | - if (IpPrefix.IPV4_MULTICAST_RANGE.contains(saddr)) { | 426 | + if (IpPrefix.IPV4_MULTICAST_PREFIX.contains(saddr)) { |
427 | log.debug("IGMP Picked up a packet with a multicast source address."); | 427 | log.debug("IGMP Picked up a packet with a multicast source address."); |
428 | return; | 428 | return; |
429 | } | 429 | } | ... | ... |
1 | /* | 1 | /* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015-2016 Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
... | @@ -67,7 +67,6 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -67,7 +67,6 @@ import static org.slf4j.LoggerFactory.getLogger; |
67 | public class McastForwarding { | 67 | public class McastForwarding { |
68 | 68 | ||
69 | private final Logger log = getLogger(getClass()); | 69 | private final Logger log = getLogger(getClass()); |
70 | - private final IpPrefix mcast = IpPrefix.valueOf("224.0.0.0/4"); | ||
71 | 70 | ||
72 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 71 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
73 | protected PacketService packetService; | 72 | protected PacketService packetService; |
... | @@ -101,7 +100,7 @@ public class McastForwarding { | ... | @@ -101,7 +100,7 @@ public class McastForwarding { |
101 | // Build a traffic selector for all multicast traffic | 100 | // Build a traffic selector for all multicast traffic |
102 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 101 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
103 | selector.matchEthType(Ethernet.TYPE_IPV4); | 102 | selector.matchEthType(Ethernet.TYPE_IPV4); |
104 | - selector.matchIPDst(mcast); | 103 | + selector.matchIPDst(IpPrefix.IPV4_MULTICAST_PREFIX); |
105 | 104 | ||
106 | packetService.requestPackets(selector.build(), PacketPriority.REACTIVE, appId); | 105 | packetService.requestPackets(selector.build(), PacketPriority.REACTIVE, appId); |
107 | 106 | ... | ... |
1 | /* | 1 | /* |
2 | - * Copyright 2015 Open Networking Laboratory | 2 | + * Copyright 2015-2016 Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
... | @@ -25,7 +25,6 @@ import org.apache.commons.lang3.tuple.Pair; | ... | @@ -25,7 +25,6 @@ import org.apache.commons.lang3.tuple.Pair; |
25 | import org.onlab.osgi.ServiceDirectory; | 25 | import org.onlab.osgi.ServiceDirectory; |
26 | import org.onlab.packet.EthType; | 26 | import org.onlab.packet.EthType; |
27 | import org.onlab.packet.IPv4; | 27 | import org.onlab.packet.IPv4; |
28 | -import org.onlab.packet.IpPrefix; | ||
29 | import org.onlab.packet.VlanId; | 28 | import org.onlab.packet.VlanId; |
30 | import org.onlab.util.KryoNamespace; | 29 | import org.onlab.util.KryoNamespace; |
31 | import org.onosproject.core.ApplicationId; | 30 | import org.onosproject.core.ApplicationId; |
... | @@ -102,7 +101,8 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner { | ... | @@ -102,7 +101,8 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner { |
102 | 101 | ||
103 | private DeviceId deviceId; | 102 | private DeviceId deviceId; |
104 | private ApplicationId appId; | 103 | private ApplicationId appId; |
105 | - private IpPrefix mcastPrefix = IpPrefix.valueOf("224.0.0.0/4"); | 104 | + // NOTE: OLT currently has some issue with cookie 0. Pick something larger |
105 | + // to avoid collision | ||
106 | private AtomicLong counter = new AtomicLong(123); | 106 | private AtomicLong counter = new AtomicLong(123); |
107 | 107 | ||
108 | protected FlowObjectiveStore flowObjectiveStore; | 108 | protected FlowObjectiveStore flowObjectiveStore; |
... | @@ -348,7 +348,7 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner { | ... | @@ -348,7 +348,7 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner { |
348 | return false; | 348 | return false; |
349 | } | 349 | } |
350 | 350 | ||
351 | - return mcastPrefix.contains(ip.ip()); | 351 | + return ip.ip().isMulticast(); |
352 | 352 | ||
353 | } | 353 | } |
354 | 354 | ... | ... |
1 | /* | 1 | /* |
2 | - * Copyright 2014-2015 Open Networking Laboratory | 2 | + * Copyright 2014-2016 Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
... | @@ -321,8 +321,8 @@ public class IpAddress implements Comparable<IpAddress> { | ... | @@ -321,8 +321,8 @@ public class IpAddress implements Comparable<IpAddress> { |
321 | */ | 321 | */ |
322 | public boolean isMulticast() { | 322 | public boolean isMulticast() { |
323 | return isIp4() ? | 323 | return isIp4() ? |
324 | - Ip4Prefix.IPV4_MULTICAST_RANGE.contains(this.getIp4Address()) : | 324 | + Ip4Prefix.IPV4_MULTICAST_PREFIX.contains(this.getIp4Address()) : |
325 | - Ip6Prefix.IPV6_MULTICAST_RANGE.contains(this.getIp6Address()); | 325 | + Ip6Prefix.IPV6_MULTICAST_PREFIX.contains(this.getIp6Address()); |
326 | } | 326 | } |
327 | 327 | ||
328 | @Override | 328 | @Override | ... | ... |
1 | /* | 1 | /* |
2 | - * Copyright 2014-2015 Open Networking Laboratory | 2 | + * Copyright 2014-2016 Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
... | @@ -43,11 +43,11 @@ public class IpPrefix { | ... | @@ -43,11 +43,11 @@ public class IpPrefix { |
43 | /** | 43 | /** |
44 | * An IpPrefix that contains all IPv4 multicast addresses. | 44 | * An IpPrefix that contains all IPv4 multicast addresses. |
45 | */ | 45 | */ |
46 | - public static final IpPrefix IPV4_MULTICAST_RANGE = IpPrefix.valueOf("224.0.0.0/4"); | 46 | + public static final IpPrefix IPV4_MULTICAST_PREFIX = IpPrefix.valueOf("224.0.0.0/4"); |
47 | /** | 47 | /** |
48 | * An IpPrefix that contains all IPv6 multicast addresses. | 48 | * An IpPrefix that contains all IPv6 multicast addresses. |
49 | */ | 49 | */ |
50 | - public static final IpPrefix IPV6_MULTICAST_RANGE = IpPrefix.valueOf("ff00::/8"); | 50 | + public static final IpPrefix IPV6_MULTICAST_PREFIX = IpPrefix.valueOf("ff00::/8"); |
51 | 51 | ||
52 | private final IpAddress address; | 52 | private final IpAddress address; |
53 | private final short prefixLength; | 53 | private final short prefixLength; |
... | @@ -93,6 +93,17 @@ public class IpPrefix { | ... | @@ -93,6 +93,17 @@ public class IpPrefix { |
93 | } | 93 | } |
94 | 94 | ||
95 | /** | 95 | /** |
96 | + * Check if this IP prefix is a multicast prefix. | ||
97 | + * | ||
98 | + * @return true if this prefix a multicast prefix | ||
99 | + */ | ||
100 | + public boolean isMulticast() { | ||
101 | + return isIp4() ? | ||
102 | + IPV4_MULTICAST_PREFIX.contains(this.getIp4Prefix()) : | ||
103 | + IPV6_MULTICAST_PREFIX.contains(this.getIp6Prefix()); | ||
104 | + } | ||
105 | + | ||
106 | + /** | ||
96 | * Returns the IP address value of the prefix. | 107 | * Returns the IP address value of the prefix. |
97 | * | 108 | * |
98 | * @return the IP address value of the prefix | 109 | * @return the IP address value of the prefix | ... | ... |
1 | /* | 1 | /* |
2 | - * Copyright 2014-2015 Open Networking Laboratory | 2 | + * Copyright 2014-2016 Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. | ... | ... |
1 | /* | 1 | /* |
2 | - * Copyright 2014-2015 Open Networking Laboratory | 2 | + * Copyright 2014-2016 Open Networking Laboratory |
3 | * | 3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
... | @@ -97,6 +97,25 @@ public class IpPrefixTest { | ... | @@ -97,6 +97,25 @@ public class IpPrefixTest { |
97 | } | 97 | } |
98 | 98 | ||
99 | /** | 99 | /** |
100 | + * Tests if the prefix is a multicast prefix. | ||
101 | + */ | ||
102 | + @Test | ||
103 | + public void testIsMulticast() { | ||
104 | + IpPrefix v4Unicast = IpPrefix.valueOf("10.0.0.1/16"); | ||
105 | + IpPrefix v4Multicast = IpPrefix.valueOf("224.0.0.1/4"); | ||
106 | + IpPrefix v4Overlap = IpPrefix.valueOf("192.0.0.0/2"); | ||
107 | + IpPrefix v6Unicast = IpPrefix.valueOf("1000::1/8"); | ||
108 | + IpPrefix v6Multicast = IpPrefix.valueOf("ff02::1/8"); | ||
109 | + IpPrefix v6Overlap = IpPrefix.valueOf("ff00::1/4"); | ||
110 | + assertFalse(v4Unicast.isMulticast()); | ||
111 | + assertTrue(v4Multicast.isMulticast()); | ||
112 | + assertFalse(v4Overlap.isMulticast()); | ||
113 | + assertFalse(v6Unicast.isMulticast()); | ||
114 | + assertTrue(v6Multicast.isMulticast()); | ||
115 | + assertFalse(v6Overlap.isMulticast()); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
100 | * Tests returning the IP address value and IP address prefix length of | 119 | * Tests returning the IP address value and IP address prefix length of |
101 | * an IPv4 prefix. | 120 | * an IPv4 prefix. |
102 | */ | 121 | */ | ... | ... |
-
Please register or login to post a comment