Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next
Showing
2 changed files
with
34 additions
and
27 deletions
1 | package org.onlab.onos.net.trivial.host.impl; | 1 | package org.onlab.onos.net.trivial.host.impl; |
2 | 2 | ||
3 | +import static org.onlab.onos.net.host.HostEvent.Type.HOST_ADDED; | ||
4 | +import static org.onlab.onos.net.host.HostEvent.Type.HOST_MOVED; | ||
5 | +import static org.onlab.onos.net.host.HostEvent.Type.HOST_REMOVED; | ||
6 | +import static org.onlab.onos.net.host.HostEvent.Type.HOST_UPDATED; | ||
7 | + | ||
8 | +import java.util.Collections; | ||
9 | +import java.util.HashSet; | ||
10 | +import java.util.Map; | ||
11 | +import java.util.Set; | ||
12 | +import java.util.concurrent.ConcurrentHashMap; | ||
13 | + | ||
3 | import org.onlab.onos.net.ConnectPoint; | 14 | import org.onlab.onos.net.ConnectPoint; |
4 | import org.onlab.onos.net.DefaultHost; | 15 | import org.onlab.onos.net.DefaultHost; |
5 | import org.onlab.onos.net.DeviceId; | 16 | import org.onlab.onos.net.DeviceId; |
... | @@ -15,17 +26,6 @@ import com.google.common.collect.HashMultimap; | ... | @@ -15,17 +26,6 @@ import com.google.common.collect.HashMultimap; |
15 | import com.google.common.collect.ImmutableSet; | 26 | import com.google.common.collect.ImmutableSet; |
16 | import com.google.common.collect.Multimap; | 27 | import com.google.common.collect.Multimap; |
17 | 28 | ||
18 | -import java.util.Collections; | ||
19 | -import java.util.HashSet; | ||
20 | -import java.util.Map; | ||
21 | -import java.util.Set; | ||
22 | -import java.util.concurrent.ConcurrentHashMap; | ||
23 | - | ||
24 | -import static org.onlab.onos.net.host.HostEvent.Type.HOST_REMOVED; | ||
25 | -import static org.onlab.onos.net.host.HostEvent.Type.HOST_ADDED; | ||
26 | -import static org.onlab.onos.net.host.HostEvent.Type.HOST_UPDATED; | ||
27 | -import static org.onlab.onos.net.host.HostEvent.Type.HOST_MOVED; | ||
28 | - | ||
29 | /** | 29 | /** |
30 | * Manages inventory of end-station hosts using trivial in-memory | 30 | * Manages inventory of end-station hosts using trivial in-memory |
31 | * implementation. | 31 | * implementation. |
... | @@ -47,7 +47,7 @@ public class SimpleHostStore { | ... | @@ -47,7 +47,7 @@ public class SimpleHostStore { |
47 | * @return appropriate event or null if no change resulted | 47 | * @return appropriate event or null if no change resulted |
48 | */ | 48 | */ |
49 | HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId, | 49 | HostEvent createOrUpdateHost(ProviderId providerId, HostId hostId, |
50 | - HostDescription hostDescription) { | 50 | + HostDescription hostDescription) { |
51 | Host host = hosts.get(hostId); | 51 | Host host = hosts.get(hostId); |
52 | if (host == null) { | 52 | if (host == null) { |
53 | return createHost(providerId, hostId, hostDescription); | 53 | return createHost(providerId, hostId, hostDescription); |
... | @@ -57,12 +57,12 @@ public class SimpleHostStore { | ... | @@ -57,12 +57,12 @@ public class SimpleHostStore { |
57 | 57 | ||
58 | // creates a new host and sends HOST_ADDED | 58 | // creates a new host and sends HOST_ADDED |
59 | private HostEvent createHost(ProviderId providerId, HostId hostId, | 59 | private HostEvent createHost(ProviderId providerId, HostId hostId, |
60 | - HostDescription descr) { | 60 | + HostDescription descr) { |
61 | DefaultHost newhost = new DefaultHost(providerId, hostId, | 61 | DefaultHost newhost = new DefaultHost(providerId, hostId, |
62 | - descr.hwAddress(), | 62 | + descr.hwAddress(), |
63 | - descr.vlan(), | 63 | + descr.vlan(), |
64 | - descr.location(), | 64 | + descr.location(), |
65 | - descr.ipAddresses()); | 65 | + descr.ipAddresses()); |
66 | synchronized (this) { | 66 | synchronized (this) { |
67 | hosts.put(hostId, newhost); | 67 | hosts.put(hostId, newhost); |
68 | locations.put(descr.location(), newhost); | 68 | locations.put(descr.location(), newhost); |
... | @@ -72,22 +72,22 @@ public class SimpleHostStore { | ... | @@ -72,22 +72,22 @@ public class SimpleHostStore { |
72 | 72 | ||
73 | // checks for type of update to host, sends appropriate event | 73 | // checks for type of update to host, sends appropriate event |
74 | private HostEvent updateHost(ProviderId providerId, Host host, | 74 | private HostEvent updateHost(ProviderId providerId, Host host, |
75 | - HostDescription descr) { | 75 | + HostDescription descr) { |
76 | DefaultHost updated; | 76 | DefaultHost updated; |
77 | HostEvent event; | 77 | HostEvent event; |
78 | if (host.location().equals(descr.location())) { | 78 | if (host.location().equals(descr.location())) { |
79 | updated = new DefaultHost(providerId, host.id(), | 79 | updated = new DefaultHost(providerId, host.id(), |
80 | - host.mac(), | 80 | + host.mac(), |
81 | - host.vlan(), | 81 | + host.vlan(), |
82 | - host.location(), | 82 | + host.location(), |
83 | - descr.ipAddresses()); | 83 | + descr.ipAddresses()); |
84 | event = new HostEvent(HOST_UPDATED, updated); | 84 | event = new HostEvent(HOST_UPDATED, updated); |
85 | } else { | 85 | } else { |
86 | updated = new DefaultHost(providerId, host.id(), | 86 | updated = new DefaultHost(providerId, host.id(), |
87 | - host.mac(), | 87 | + host.mac(), |
88 | - host.vlan(), | 88 | + host.vlan(), |
89 | - descr.location(), | 89 | + descr.location(), |
90 | - host.ipAddresses()); | 90 | + host.ipAddresses()); |
91 | event = new HostEvent(HOST_MOVED, updated); | 91 | event = new HostEvent(HOST_MOVED, updated); |
92 | } | 92 | } |
93 | synchronized (this) { | 93 | synchronized (this) { | ... | ... |
... | @@ -7,6 +7,7 @@ import org.projectfloodlight.openflow.protocol.OFPacketIn; | ... | @@ -7,6 +7,7 @@ import org.projectfloodlight.openflow.protocol.OFPacketIn; |
7 | import org.projectfloodlight.openflow.protocol.OFPacketOut; | 7 | import org.projectfloodlight.openflow.protocol.OFPacketOut; |
8 | import org.projectfloodlight.openflow.protocol.action.OFAction; | 8 | import org.projectfloodlight.openflow.protocol.action.OFAction; |
9 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; | 9 | import org.projectfloodlight.openflow.protocol.action.OFActionOutput; |
10 | +import org.projectfloodlight.openflow.protocol.match.MatchField; | ||
10 | import org.projectfloodlight.openflow.types.OFBufferId; | 11 | import org.projectfloodlight.openflow.types.OFBufferId; |
11 | import org.projectfloodlight.openflow.types.OFPort; | 12 | import org.projectfloodlight.openflow.types.OFPort; |
12 | 13 | ||
... | @@ -83,12 +84,18 @@ public final class DefaultPacketContext implements PacketContext { | ... | @@ -83,12 +84,18 @@ public final class DefaultPacketContext implements PacketContext { |
83 | 84 | ||
84 | @Override | 85 | @Override |
85 | public Integer inPort() { | 86 | public Integer inPort() { |
86 | - return pktin.getInPort().getPortNumber(); | 87 | + try { |
88 | + return pktin.getInPort().getPortNumber(); | ||
89 | + } catch (UnsupportedOperationException e) { | ||
90 | + return pktin.getMatch().get(MatchField.IN_PORT).getPortNumber(); | ||
91 | + } | ||
87 | } | 92 | } |
88 | 93 | ||
89 | @Override | 94 | @Override |
90 | public byte[] unparsed() { | 95 | public byte[] unparsed() { |
96 | + | ||
91 | return pktin.getData().clone(); | 97 | return pktin.getData().clone(); |
98 | + | ||
92 | } | 99 | } |
93 | 100 | ||
94 | private OFActionOutput buildOutput(Integer port) { | 101 | private OFActionOutput buildOutput(Integer port) { | ... | ... |
-
Please register or login to post a comment