Committed by
Gerrit Code Review
Added some incoming JoinPrune processing
Change-Id: I7c89f05119ffa012b8e79f05d0f5f63744282ffb
Showing
3 changed files
with
104 additions
and
21 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. |
... | @@ -19,10 +19,13 @@ import org.onlab.packet.Ethernet; | ... | @@ -19,10 +19,13 @@ import org.onlab.packet.Ethernet; |
19 | import org.onlab.packet.IPv4; | 19 | import org.onlab.packet.IPv4; |
20 | import org.onlab.packet.Ip4Address; | 20 | import org.onlab.packet.Ip4Address; |
21 | import org.onlab.packet.IpAddress; | 21 | import org.onlab.packet.IpAddress; |
22 | +import org.onlab.packet.IpPrefix; | ||
22 | import org.onlab.packet.MacAddress; | 23 | import org.onlab.packet.MacAddress; |
23 | import org.onlab.packet.PIM; | 24 | import org.onlab.packet.PIM; |
24 | import org.onlab.packet.pim.PIMHello; | 25 | import org.onlab.packet.pim.PIMHello; |
25 | import org.onlab.packet.pim.PIMHelloOption; | 26 | import org.onlab.packet.pim.PIMHelloOption; |
27 | +import org.onlab.packet.pim.PIMJoinPrune; | ||
28 | +import org.onlab.packet.pim.PIMJoinPruneGroup; | ||
26 | import org.onosproject.incubator.net.intf.Interface; | 29 | import org.onosproject.incubator.net.intf.Interface; |
27 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 30 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
28 | import org.onosproject.net.flow.TrafficTreatment; | 31 | import org.onosproject.net.flow.TrafficTreatment; |
... | @@ -348,7 +351,39 @@ public final class PIMInterface { | ... | @@ -348,7 +351,39 @@ public final class PIMInterface { |
348 | * @param ethPkt the Ethernet packet header. | 351 | * @param ethPkt the Ethernet packet header. |
349 | */ | 352 | */ |
350 | public void processJoinPrune(Ethernet ethPkt) { | 353 | public void processJoinPrune(Ethernet ethPkt) { |
351 | - // TODO: add Join/Prune processing code. | 354 | + |
355 | + IPv4 ip = (IPv4) ethPkt.getPayload(); | ||
356 | + checkNotNull(ip); | ||
357 | + | ||
358 | + PIM pim = (PIM) ip.getPayload(); | ||
359 | + checkNotNull(pim); | ||
360 | + | ||
361 | + PIMJoinPrune jpHdr = (PIMJoinPrune) pim.getPayload(); | ||
362 | + checkNotNull(jpHdr); | ||
363 | + | ||
364 | + /* | ||
365 | + * The Join/Prune messages are grouped by Group address. We'll walk each group address | ||
366 | + * where we will possibly have to walk a list of source address for the joins and prunes. | ||
367 | + */ | ||
368 | + Collection<PIMJoinPruneGroup> jpgs = jpHdr.getJoinPrunes(); | ||
369 | + for (PIMJoinPruneGroup jpg : jpgs) { | ||
370 | + IpPrefix gpfx = jpg.getGroup(); | ||
371 | + | ||
372 | + // Walk the joins first. | ||
373 | + for (IpPrefix spfx : jpg.getJoins().values()) { | ||
374 | + | ||
375 | + // We may need | ||
376 | + | ||
377 | + | ||
378 | + } | ||
379 | + | ||
380 | + for (IpPrefix spfx : jpg.getPrunes().values()) { | ||
381 | + | ||
382 | + // TODO: this is where we many need to remove multi-cast state and possibly intents. | ||
383 | + | ||
384 | + } | ||
385 | + } | ||
386 | + | ||
352 | } | 387 | } |
353 | 388 | ||
354 | /** | 389 | /** | ... | ... |
... | @@ -21,6 +21,7 @@ import org.onlab.packet.IPacket; | ... | @@ -21,6 +21,7 @@ import org.onlab.packet.IPacket; |
21 | import org.onlab.packet.IpPrefix; | 21 | import org.onlab.packet.IpPrefix; |
22 | 22 | ||
23 | import java.nio.ByteBuffer; | 23 | import java.nio.ByteBuffer; |
24 | +import java.util.Collection; | ||
24 | import java.util.HashMap; | 25 | import java.util.HashMap; |
25 | 26 | ||
26 | import static com.google.common.base.MoreObjects.toStringHelper; | 27 | import static com.google.common.base.MoreObjects.toStringHelper; |
... | @@ -31,16 +32,7 @@ public class PIMJoinPrune extends BasePacket { | ... | @@ -31,16 +32,7 @@ public class PIMJoinPrune extends BasePacket { |
31 | private PIMAddrUnicast upstreamAddr = new PIMAddrUnicast(); | 32 | private PIMAddrUnicast upstreamAddr = new PIMAddrUnicast(); |
32 | private short holdTime = (short) 0xffff; | 33 | private short holdTime = (short) 0xffff; |
33 | 34 | ||
34 | - private class JoinPruneGroup { | 35 | + private HashMap<IpPrefix, PIMJoinPruneGroup> joinPrunes = new HashMap<>(); |
35 | - protected IpPrefix group; | ||
36 | - protected HashMap<IpPrefix, IpPrefix> joins = new HashMap<>(); | ||
37 | - protected HashMap<IpPrefix, IpPrefix> prunes = new HashMap<>(); | ||
38 | - | ||
39 | - public JoinPruneGroup(IpPrefix grp) { | ||
40 | - group = grp; | ||
41 | - } | ||
42 | - } | ||
43 | - private HashMap<IpPrefix, JoinPruneGroup> joinPrunes = new HashMap<>(); | ||
44 | 36 | ||
45 | /** | 37 | /** |
46 | * Get the J/P hold time. | 38 | * Get the J/P hold time. |
... | @@ -79,6 +71,15 @@ public class PIMJoinPrune extends BasePacket { | ... | @@ -79,6 +71,15 @@ public class PIMJoinPrune extends BasePacket { |
79 | } | 71 | } |
80 | 72 | ||
81 | /** | 73 | /** |
74 | + * Get the JoinPrune Group with all the joins and prunes. | ||
75 | + * | ||
76 | + * @return the joinPruneGroup collection | ||
77 | + */ | ||
78 | + public Collection<PIMJoinPruneGroup> getJoinPrunes() { | ||
79 | + return joinPrunes.values(); | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
82 | * Add the specified s,g to join field. | 83 | * Add the specified s,g to join field. |
83 | * | 84 | * |
84 | * @param saddr the source address of the route | 85 | * @param saddr the source address of the route |
... | @@ -99,13 +100,13 @@ public class PIMJoinPrune extends BasePacket { | ... | @@ -99,13 +100,13 @@ public class PIMJoinPrune extends BasePacket { |
99 | * @param join true for join, false for prune | 100 | * @param join true for join, false for prune |
100 | */ | 101 | */ |
101 | public void addJoinPrune(IpPrefix spfx, IpPrefix gpfx, boolean join) { | 102 | public void addJoinPrune(IpPrefix spfx, IpPrefix gpfx, boolean join) { |
102 | - JoinPruneGroup jpg = joinPrunes.get(gpfx); | 103 | + PIMJoinPruneGroup jpg = joinPrunes.get(gpfx); |
103 | if (jpg == null) { | 104 | if (jpg == null) { |
104 | - jpg = new JoinPruneGroup(gpfx); | 105 | + jpg = new PIMJoinPruneGroup(gpfx); |
105 | joinPrunes.put(gpfx, jpg); | 106 | joinPrunes.put(gpfx, jpg); |
106 | } | 107 | } |
107 | 108 | ||
108 | - HashMap<IpPrefix, IpPrefix> members = (join) ? jpg.joins : jpg.prunes; | 109 | + HashMap<IpPrefix, IpPrefix> members = (join) ? jpg.getJoins() : jpg.getPrunes(); |
109 | if (members.get(spfx) == null) { | 110 | if (members.get(spfx) == null) { |
110 | members.put(spfx, spfx); | 111 | members.put(spfx, spfx); |
111 | } | 112 | } |
... | @@ -151,22 +152,22 @@ public class PIMJoinPrune extends BasePacket { | ... | @@ -151,22 +152,22 @@ public class PIMJoinPrune extends BasePacket { |
151 | bb.putShort(this.holdTime); | 152 | bb.putShort(this.holdTime); |
152 | 153 | ||
153 | // Walk the group list and input all groups | 154 | // Walk the group list and input all groups |
154 | - for (JoinPruneGroup jpg : joinPrunes.values()) { | 155 | + for (PIMJoinPruneGroup jpg : joinPrunes.values()) { |
155 | - PIMAddrGroup grp = new PIMAddrGroup(jpg.group); | 156 | + PIMAddrGroup grp = new PIMAddrGroup(jpg.getGroup()); |
156 | bb.put(grp.serialize()); | 157 | bb.put(grp.serialize()); |
157 | 158 | ||
158 | // put the number of joins and prunes | 159 | // put the number of joins and prunes |
159 | - bb.putShort((short) jpg.joins.size()); | 160 | + bb.putShort((short) jpg.getJoins().size()); |
160 | - bb.putShort((short) jpg.prunes.size()); | 161 | + bb.putShort((short) jpg.getPrunes().size()); |
161 | 162 | ||
162 | // Set all of the joins | 163 | // Set all of the joins |
163 | - for (IpPrefix spfx : jpg.joins.values()) { | 164 | + for (IpPrefix spfx : jpg.getJoins().values()) { |
164 | PIMAddrSource src = new PIMAddrSource(spfx); | 165 | PIMAddrSource src = new PIMAddrSource(spfx); |
165 | bb.put(src.serialize()); | 166 | bb.put(src.serialize()); |
166 | } | 167 | } |
167 | 168 | ||
168 | // Set all of the prunes | 169 | // Set all of the prunes |
169 | - for (IpPrefix spfx : jpg.prunes.values()) { | 170 | + for (IpPrefix spfx : jpg.getPrunes().values()) { |
170 | PIMAddrSource src = new PIMAddrSource(spfx); | 171 | PIMAddrSource src = new PIMAddrSource(spfx); |
171 | bb.put(src.serialize()); | 172 | bb.put(src.serialize()); |
172 | } | 173 | } | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onlab.packet.pim; | ||
17 | + | ||
18 | +import org.onlab.packet.IpPrefix; | ||
19 | + | ||
20 | +import java.util.HashMap; | ||
21 | + | ||
22 | +public class PIMJoinPruneGroup { | ||
23 | + private IpPrefix group; | ||
24 | + private HashMap<IpPrefix, IpPrefix> joins = new HashMap<>(); | ||
25 | + private HashMap<IpPrefix, IpPrefix> prunes = new HashMap<>(); | ||
26 | + | ||
27 | + public PIMJoinPruneGroup(IpPrefix grp) { | ||
28 | + group = grp; | ||
29 | + } | ||
30 | + | ||
31 | + public IpPrefix getGroup() { | ||
32 | + return group; | ||
33 | + } | ||
34 | + | ||
35 | + public void setGroup(IpPrefix g) { | ||
36 | + group = g; | ||
37 | + } | ||
38 | + | ||
39 | + public HashMap<IpPrefix, IpPrefix> getJoins() { | ||
40 | + return joins; | ||
41 | + } | ||
42 | + | ||
43 | + public HashMap<IpPrefix, IpPrefix> getPrunes() { | ||
44 | + return prunes; | ||
45 | + } | ||
46 | + | ||
47 | +} |
-
Please register or login to post a comment