Committed by
Gerrit Code Review
Remove deprecated openflow host and link providers
Change-Id: I9dbaa28a70998b6265a178bb459a56221f458b75
Showing
11 changed files
with
0 additions
and
681 deletions
providers/openflow/host/pom.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!-- | ||
3 | - ~ Copyright 2014 Open Networking Laboratory | ||
4 | - ~ | ||
5 | - ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | - ~ you may not use this file except in compliance with the License. | ||
7 | - ~ You may obtain a copy of the License at | ||
8 | - ~ | ||
9 | - ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | - ~ | ||
11 | - ~ Unless required by applicable law or agreed to in writing, software | ||
12 | - ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | - ~ See the License for the specific language governing permissions and | ||
15 | - ~ limitations under the License. | ||
16 | - --> | ||
17 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
18 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
19 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
20 | - <modelVersion>4.0.0</modelVersion> | ||
21 | - | ||
22 | - <parent> | ||
23 | - <groupId>org.onosproject</groupId> | ||
24 | - <artifactId>onos-of-providers</artifactId> | ||
25 | - <version>1.2.0-SNAPSHOT</version> | ||
26 | - <relativePath>../pom.xml</relativePath> | ||
27 | - </parent> | ||
28 | - | ||
29 | - <artifactId>onos-of-provider-host</artifactId> | ||
30 | - <packaging>bundle</packaging> | ||
31 | - | ||
32 | - <description>ONOS OpenFlow protocol host provider</description> | ||
33 | - | ||
34 | -</project> |
1 | -/* | ||
2 | - * Copyright 2014 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.onosproject.provider.of.host.impl; | ||
17 | - | ||
18 | -import org.apache.felix.scr.annotations.Activate; | ||
19 | -import org.apache.felix.scr.annotations.Component; | ||
20 | -import org.apache.felix.scr.annotations.Deactivate; | ||
21 | -import org.apache.felix.scr.annotations.Reference; | ||
22 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
23 | -import org.onlab.packet.ARP; | ||
24 | -import org.onlab.packet.Ethernet; | ||
25 | -import org.onlab.packet.IPv4; | ||
26 | -import org.onlab.packet.IpAddress; | ||
27 | -import org.onlab.packet.VlanId; | ||
28 | -import org.onosproject.net.ConnectPoint; | ||
29 | -import org.onosproject.net.Host; | ||
30 | -import org.onosproject.net.HostId; | ||
31 | -import org.onosproject.net.HostLocation; | ||
32 | -import org.onosproject.net.host.DefaultHostDescription; | ||
33 | -import org.onosproject.net.host.HostDescription; | ||
34 | -import org.onosproject.net.host.HostProvider; | ||
35 | -import org.onosproject.net.host.HostProviderRegistry; | ||
36 | -import org.onosproject.net.host.HostProviderService; | ||
37 | -import org.onosproject.net.provider.AbstractProvider; | ||
38 | -import org.onosproject.net.provider.ProviderId; | ||
39 | -import org.onosproject.net.topology.Topology; | ||
40 | -import org.onosproject.net.topology.TopologyService; | ||
41 | -import org.onosproject.openflow.controller.Dpid; | ||
42 | -import org.onosproject.openflow.controller.OpenFlowController; | ||
43 | -import org.onosproject.openflow.controller.OpenFlowPacketContext; | ||
44 | -import org.onosproject.openflow.controller.PacketListener; | ||
45 | -import org.slf4j.Logger; | ||
46 | - | ||
47 | -import static org.onosproject.net.DeviceId.deviceId; | ||
48 | -import static org.onosproject.net.PortNumber.portNumber; | ||
49 | -import static org.slf4j.LoggerFactory.getLogger; | ||
50 | - | ||
51 | -/** | ||
52 | - * Provider which uses an OpenFlow controller to detect network | ||
53 | - * end-station hosts. | ||
54 | - */ | ||
55 | -@Component(immediate = true) | ||
56 | -@Deprecated | ||
57 | -public class OpenFlowHostProvider extends AbstractProvider implements HostProvider { | ||
58 | - | ||
59 | - private final Logger log = getLogger(getClass()); | ||
60 | - | ||
61 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
62 | - protected HostProviderRegistry providerRegistry; | ||
63 | - | ||
64 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
65 | - protected OpenFlowController controller; | ||
66 | - | ||
67 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
68 | - protected TopologyService topologyService; | ||
69 | - | ||
70 | - private HostProviderService providerService; | ||
71 | - | ||
72 | - private final InternalHostProvider listener = new InternalHostProvider(); | ||
73 | - | ||
74 | - private boolean ipLearn = true; | ||
75 | - | ||
76 | - /** | ||
77 | - * Creates an OpenFlow host provider. | ||
78 | - */ | ||
79 | - public OpenFlowHostProvider() { | ||
80 | - super(new ProviderId("of", "org.onosproject.provider.openflow")); | ||
81 | - } | ||
82 | - | ||
83 | - @Activate | ||
84 | - public void activate() { | ||
85 | - providerService = providerRegistry.register(this); | ||
86 | - controller.addPacketListener(10, listener); | ||
87 | - log.info("Started"); | ||
88 | - } | ||
89 | - | ||
90 | - @Deactivate | ||
91 | - public void deactivate() { | ||
92 | - providerRegistry.unregister(this); | ||
93 | - controller.removePacketListener(listener); | ||
94 | - providerService = null; | ||
95 | - log.info("Stopped"); | ||
96 | - } | ||
97 | - | ||
98 | - @Override | ||
99 | - public void triggerProbe(Host host) { | ||
100 | - log.info("Triggering probe on device {}", host); | ||
101 | - } | ||
102 | - | ||
103 | - private class InternalHostProvider implements PacketListener { | ||
104 | - | ||
105 | - @Override | ||
106 | - public void handlePacket(OpenFlowPacketContext pktCtx) { | ||
107 | - Ethernet eth = pktCtx.parsed(); | ||
108 | - | ||
109 | - if (eth == null) { | ||
110 | - return; | ||
111 | - } | ||
112 | - | ||
113 | - VlanId vlan = VlanId.vlanId(eth.getVlanID()); | ||
114 | - ConnectPoint heardOn = new ConnectPoint(deviceId(Dpid.uri(pktCtx.dpid())), | ||
115 | - portNumber(pktCtx.inPort())); | ||
116 | - | ||
117 | - // If this is not an edge port, bail out. | ||
118 | - Topology topology = topologyService.currentTopology(); | ||
119 | - if (topologyService.isInfrastructure(topology, heardOn)) { | ||
120 | - return; | ||
121 | - } | ||
122 | - | ||
123 | - HostLocation hloc = new HostLocation(deviceId(Dpid.uri(pktCtx.dpid())), | ||
124 | - portNumber(pktCtx.inPort()), | ||
125 | - System.currentTimeMillis()); | ||
126 | - | ||
127 | - HostId hid = HostId.hostId(eth.getSourceMAC(), vlan); | ||
128 | - | ||
129 | - // Potentially a new or moved host | ||
130 | - if (eth.getEtherType() == Ethernet.TYPE_ARP) { | ||
131 | - ARP arp = (ARP) eth.getPayload(); | ||
132 | - IpAddress ip = | ||
133 | - IpAddress.valueOf(IpAddress.Version.INET, | ||
134 | - arp.getSenderProtocolAddress()); | ||
135 | - HostDescription hdescr = | ||
136 | - new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ip); | ||
137 | - providerService.hostDetected(hid, hdescr); | ||
138 | - | ||
139 | - } else if (ipLearn && eth.getEtherType() == Ethernet.TYPE_IPV4) { | ||
140 | - IPv4 pip = (IPv4) eth.getPayload(); | ||
141 | - IpAddress ip = | ||
142 | - IpAddress.valueOf(pip.getSourceAddress()); | ||
143 | - HostDescription hdescr = | ||
144 | - new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ip); | ||
145 | - providerService.hostDetected(hid, hdescr); | ||
146 | - | ||
147 | - } | ||
148 | - | ||
149 | - } | ||
150 | - | ||
151 | - } | ||
152 | -} |
1 | -/* | ||
2 | - * Copyright 2014 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 | - | ||
17 | -/** | ||
18 | - * Provider that uses OpenFlow controller as a means of host discovery and tracking. | ||
19 | - */ | ||
20 | -package org.onosproject.provider.of.host.impl; |
1 | -/* | ||
2 | - * Copyright 2014 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.onosproject.provider.of.host.impl; | ||
17 | - | ||
18 | -import static org.junit.Assert.assertEquals; | ||
19 | -import static org.junit.Assert.assertNotNull; | ||
20 | -import static org.junit.Assert.assertNull; | ||
21 | - | ||
22 | -import java.util.Set; | ||
23 | - | ||
24 | -import org.junit.After; | ||
25 | -import org.junit.Before; | ||
26 | -import org.junit.Test; | ||
27 | -import org.onosproject.net.ConnectPoint; | ||
28 | -import org.onosproject.net.HostId; | ||
29 | -import org.onosproject.net.host.HostDescription; | ||
30 | -import org.onosproject.net.host.HostProvider; | ||
31 | -import org.onosproject.net.host.HostProviderRegistry; | ||
32 | -import org.onosproject.net.host.HostProviderService; | ||
33 | -import org.onosproject.net.provider.AbstractProviderService; | ||
34 | -import org.onosproject.net.provider.ProviderId; | ||
35 | -import org.onosproject.net.topology.Topology; | ||
36 | -import org.onosproject.net.topology.TopologyServiceAdapter; | ||
37 | -import org.onosproject.openflow.controller.Dpid; | ||
38 | -import org.onosproject.openflow.controller.OpenFlowPacketContext; | ||
39 | -import org.onosproject.openflow.controller.OpenflowControllerAdapter; | ||
40 | -import org.onosproject.openflow.controller.PacketListener; | ||
41 | -import org.onlab.packet.ARP; | ||
42 | -import org.onlab.packet.Ethernet; | ||
43 | -import org.onlab.packet.MacAddress; | ||
44 | -import org.onlab.packet.VlanId; | ||
45 | -import org.projectfloodlight.openflow.protocol.OFMessage; | ||
46 | -import org.projectfloodlight.openflow.types.OFPort; | ||
47 | - | ||
48 | -public class OpenFlowHostProviderTest { | ||
49 | - | ||
50 | - private static final Integer INPORT = 10; | ||
51 | - private static final Dpid DPID1 = new Dpid(100); | ||
52 | - private static final Dpid DPID2 = new Dpid(200); | ||
53 | - private static final Dpid DPID3 = new Dpid(300); | ||
54 | - | ||
55 | - private static final VlanId VLAN = VlanId.vlanId(); | ||
56 | - private static final MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01"); | ||
57 | - private static final MacAddress BCMAC = MacAddress.valueOf("ff:ff:ff:ff:ff:ff"); | ||
58 | - private static final byte[] IP = new byte[]{10, 0, 0, 1}; | ||
59 | - | ||
60 | - private final OpenFlowHostProvider provider = new OpenFlowHostProvider(); | ||
61 | - private final TestHostRegistry hostService = new TestHostRegistry(); | ||
62 | - private final TestController controller = new TestController(); | ||
63 | - private final TestTopologyService topoService = new TestTopologyService(); | ||
64 | - private TestHostProviderService providerService; | ||
65 | - | ||
66 | - @Before | ||
67 | - public void setUp() { | ||
68 | - provider.providerRegistry = hostService; | ||
69 | - provider.controller = controller; | ||
70 | - provider.topologyService = topoService; | ||
71 | - provider.activate(); | ||
72 | - } | ||
73 | - | ||
74 | - @Test | ||
75 | - public void basics() { | ||
76 | - assertNotNull("registration expected", providerService); | ||
77 | - assertEquals("incorrect provider", provider, providerService.provider()); | ||
78 | - } | ||
79 | - | ||
80 | - @Test | ||
81 | - public void events() { | ||
82 | - // new host | ||
83 | - controller.processPacket(DPID1, null); | ||
84 | - assertNotNull("new host expected", providerService.added); | ||
85 | - assertNull("host motion unexpected", providerService.moved); | ||
86 | - | ||
87 | - // the host moved to new switch | ||
88 | - controller.processPacket(DPID2, null); | ||
89 | - assertNotNull("host motion expected", providerService.moved); | ||
90 | - | ||
91 | - // the host was misheard on a spine | ||
92 | - controller.processPacket(DPID3, null); | ||
93 | - assertNull("host misheard on spine switch", providerService.spine); | ||
94 | - } | ||
95 | - | ||
96 | - @After | ||
97 | - public void tearDown() { | ||
98 | - provider.deactivate(); | ||
99 | - provider.providerRegistry = null; | ||
100 | - provider.controller = null; | ||
101 | - } | ||
102 | - | ||
103 | - private class TestHostRegistry implements HostProviderRegistry { | ||
104 | - | ||
105 | - @Override | ||
106 | - public HostProviderService register(HostProvider provider) { | ||
107 | - providerService = new TestHostProviderService(provider); | ||
108 | - return providerService; | ||
109 | - } | ||
110 | - | ||
111 | - @Override | ||
112 | - public void unregister(HostProvider provider) { | ||
113 | - } | ||
114 | - | ||
115 | - @Override | ||
116 | - public Set<ProviderId> getProviders() { | ||
117 | - return null; | ||
118 | - } | ||
119 | - | ||
120 | - } | ||
121 | - | ||
122 | - private class TestHostProviderService | ||
123 | - extends AbstractProviderService<HostProvider> | ||
124 | - implements HostProviderService { | ||
125 | - | ||
126 | - Dpid added = null; | ||
127 | - Dpid moved = null; | ||
128 | - Dpid spine = null; | ||
129 | - | ||
130 | - protected TestHostProviderService(HostProvider provider) { | ||
131 | - super(provider); | ||
132 | - } | ||
133 | - | ||
134 | - @Override | ||
135 | - public void hostDetected(HostId hostId, HostDescription hostDescription) { | ||
136 | - Dpid descr = Dpid.dpid(hostDescription.location().deviceId().uri()); | ||
137 | - if (added == null) { | ||
138 | - added = descr; | ||
139 | - } else if ((moved == null) && !descr.equals(added)) { | ||
140 | - moved = descr; | ||
141 | - } else { | ||
142 | - spine = descr; | ||
143 | - } | ||
144 | - } | ||
145 | - | ||
146 | - @Override | ||
147 | - public void hostVanished(HostId hostId) { | ||
148 | - } | ||
149 | - | ||
150 | - } | ||
151 | - | ||
152 | - private class TestController extends OpenflowControllerAdapter { | ||
153 | - PacketListener pktListener; | ||
154 | - | ||
155 | - @Override | ||
156 | - public void addPacketListener(int priority, PacketListener listener) { | ||
157 | - pktListener = listener; | ||
158 | - } | ||
159 | - | ||
160 | - @Override | ||
161 | - public void processPacket(Dpid dpid, OFMessage msg) { | ||
162 | - OpenFlowPacketContext ctx = new TestPacketContext(dpid); | ||
163 | - pktListener.handlePacket(ctx); | ||
164 | - } | ||
165 | - } | ||
166 | - | ||
167 | - private class TestTopologyService extends TopologyServiceAdapter { | ||
168 | - @Override | ||
169 | - public boolean isInfrastructure(Topology topology, | ||
170 | - ConnectPoint connectPoint) { | ||
171 | - //simulate DPID3 as an infrastructure switch | ||
172 | - if (Dpid.dpid(connectPoint.deviceId().uri()).equals(DPID3)) { | ||
173 | - return true; | ||
174 | - } | ||
175 | - return false; | ||
176 | - } | ||
177 | - } | ||
178 | - | ||
179 | - private class TestPacketContext implements OpenFlowPacketContext { | ||
180 | - | ||
181 | - protected Dpid swid; | ||
182 | - | ||
183 | - public TestPacketContext(Dpid dpid) { | ||
184 | - swid = dpid; | ||
185 | - } | ||
186 | - | ||
187 | - @Override | ||
188 | - public boolean block() { | ||
189 | - return false; | ||
190 | - } | ||
191 | - | ||
192 | - @Override | ||
193 | - public void send() { | ||
194 | - } | ||
195 | - | ||
196 | - @Override | ||
197 | - public void build(OFPort outPort) { | ||
198 | - } | ||
199 | - | ||
200 | - @Override | ||
201 | - public void build(Ethernet ethFrame, OFPort outPort) { | ||
202 | - } | ||
203 | - | ||
204 | - @Override | ||
205 | - public Ethernet parsed() { | ||
206 | - // just things we (and serializers) need | ||
207 | - ARP arp = new ARP(); | ||
208 | - arp.setSenderProtocolAddress(IP) | ||
209 | - .setSenderHardwareAddress(MAC.toBytes()) | ||
210 | - .setTargetHardwareAddress(BCMAC.toBytes()) | ||
211 | - .setTargetProtocolAddress(IP); | ||
212 | - | ||
213 | - Ethernet eth = new Ethernet(); | ||
214 | - eth.setEtherType(Ethernet.TYPE_ARP) | ||
215 | - .setVlanID(VLAN.toShort()) | ||
216 | - .setSourceMACAddress(MAC) | ||
217 | - .setDestinationMACAddress(BCMAC) | ||
218 | - .setPayload(arp); | ||
219 | - | ||
220 | - return eth; | ||
221 | - } | ||
222 | - | ||
223 | - @Override | ||
224 | - public byte[] unparsed() { | ||
225 | - return null; | ||
226 | - } | ||
227 | - | ||
228 | - @Override | ||
229 | - public Dpid dpid() { | ||
230 | - return swid; | ||
231 | - } | ||
232 | - | ||
233 | - @Override | ||
234 | - public Integer inPort() { | ||
235 | - return INPORT; | ||
236 | - } | ||
237 | - | ||
238 | - @Override | ||
239 | - public boolean isHandled() { | ||
240 | - return false; | ||
241 | - } | ||
242 | - | ||
243 | - @Override | ||
244 | - public boolean isBuffered() { | ||
245 | - return false; | ||
246 | - } | ||
247 | - | ||
248 | - } | ||
249 | -} |
providers/openflow/link/pom.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!-- | ||
3 | - ~ Copyright 2014 Open Networking Laboratory | ||
4 | - ~ | ||
5 | - ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | - ~ you may not use this file except in compliance with the License. | ||
7 | - ~ You may obtain a copy of the License at | ||
8 | - ~ | ||
9 | - ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | - ~ | ||
11 | - ~ Unless required by applicable law or agreed to in writing, software | ||
12 | - ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | - ~ See the License for the specific language governing permissions and | ||
15 | - ~ limitations under the License. | ||
16 | - --> | ||
17 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
18 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
19 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
20 | - <modelVersion>4.0.0</modelVersion> | ||
21 | - | ||
22 | - <parent> | ||
23 | - <groupId>org.onosproject</groupId> | ||
24 | - <artifactId>onos-of-providers</artifactId> | ||
25 | - <version>1.2.0-SNAPSHOT</version> | ||
26 | - <relativePath>../pom.xml</relativePath> | ||
27 | - </parent> | ||
28 | - | ||
29 | - <artifactId>onos-of-provider-link</artifactId> | ||
30 | - <packaging>bundle</packaging> | ||
31 | - | ||
32 | - <description>ONOS OpenFlow protocol link provider</description> | ||
33 | - | ||
34 | -</project> |
This diff is collapsed. Click to expand it.
1 | -/* | ||
2 | - * Copyright 2014 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.onosproject.provider.of.link.impl; | ||
17 | - | ||
18 | -import static org.slf4j.LoggerFactory.getLogger; | ||
19 | - | ||
20 | -import java.util.Map; | ||
21 | -import java.util.concurrent.ConcurrentHashMap; | ||
22 | - | ||
23 | -import org.apache.felix.scr.annotations.Activate; | ||
24 | -import org.apache.felix.scr.annotations.Component; | ||
25 | -import org.apache.felix.scr.annotations.Deactivate; | ||
26 | -import org.apache.felix.scr.annotations.Reference; | ||
27 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
28 | -import org.onosproject.net.DeviceId; | ||
29 | -import org.onosproject.net.link.LinkProvider; | ||
30 | -import org.onosproject.net.link.LinkProviderRegistry; | ||
31 | -import org.onosproject.net.link.LinkProviderService; | ||
32 | -import org.onosproject.net.provider.AbstractProvider; | ||
33 | -import org.onosproject.net.provider.ProviderId; | ||
34 | -import org.onosproject.openflow.controller.Dpid; | ||
35 | -import org.onosproject.openflow.controller.OpenFlowController; | ||
36 | -import org.onosproject.openflow.controller.OpenFlowPacketContext; | ||
37 | -import org.onosproject.openflow.controller.OpenFlowSwitch; | ||
38 | -import org.onosproject.openflow.controller.OpenFlowSwitchListener; | ||
39 | -import org.onosproject.openflow.controller.PacketListener; | ||
40 | -import org.onosproject.openflow.controller.RoleState; | ||
41 | -import org.projectfloodlight.openflow.protocol.OFPortConfig; | ||
42 | -import org.projectfloodlight.openflow.protocol.OFPortDesc; | ||
43 | -import org.projectfloodlight.openflow.protocol.OFPortState; | ||
44 | -import org.projectfloodlight.openflow.protocol.OFPortStatus; | ||
45 | -import org.slf4j.Logger; | ||
46 | - | ||
47 | - | ||
48 | -/** | ||
49 | - * Provider which uses an OpenFlow controller to detect network | ||
50 | - * infrastructure links. | ||
51 | - */ | ||
52 | -@Component(immediate = true) | ||
53 | -@Deprecated | ||
54 | -public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvider { | ||
55 | - | ||
56 | - private final Logger log = getLogger(getClass()); | ||
57 | - | ||
58 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
59 | - protected LinkProviderRegistry providerRegistry; | ||
60 | - | ||
61 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
62 | - protected OpenFlowController controller; | ||
63 | - | ||
64 | - private LinkProviderService providerService; | ||
65 | - | ||
66 | - private final boolean useBDDP = true; | ||
67 | - | ||
68 | - private final InternalLinkProvider listener = new InternalLinkProvider(); | ||
69 | - | ||
70 | - protected final Map<Dpid, LinkDiscovery> discoverers = new ConcurrentHashMap<>(); | ||
71 | - | ||
72 | - /** | ||
73 | - * Creates an OpenFlow link provider. | ||
74 | - */ | ||
75 | - public OpenFlowLinkProvider() { | ||
76 | - super(new ProviderId("of", "org.onosproject.provider.openflow")); | ||
77 | - } | ||
78 | - | ||
79 | - @Activate | ||
80 | - public void activate() { | ||
81 | - providerService = providerRegistry.register(this); | ||
82 | - controller.addListener(listener); | ||
83 | - controller.addPacketListener(0, listener); | ||
84 | - for (OpenFlowSwitch sw : controller.getSwitches()) { | ||
85 | - listener.switchAdded(new Dpid(sw.getId())); | ||
86 | - } | ||
87 | - log.info("Started"); | ||
88 | - } | ||
89 | - | ||
90 | - @Deactivate | ||
91 | - public void deactivate() { | ||
92 | - for (LinkDiscovery ld : discoverers.values()) { | ||
93 | - ld.stop(); | ||
94 | - } | ||
95 | - providerRegistry.unregister(this); | ||
96 | - controller.removeListener(listener); | ||
97 | - controller.removePacketListener(listener); | ||
98 | - providerService = null; | ||
99 | - | ||
100 | - log.info("Stopped"); | ||
101 | - } | ||
102 | - | ||
103 | - | ||
104 | - private class InternalLinkProvider implements PacketListener, OpenFlowSwitchListener { | ||
105 | - | ||
106 | - | ||
107 | - @Override | ||
108 | - public void handlePacket(OpenFlowPacketContext pktCtx) { | ||
109 | - LinkDiscovery ld = discoverers.get(pktCtx.dpid()); | ||
110 | - if (ld == null) { | ||
111 | - return; | ||
112 | - } | ||
113 | - if (ld.handleLLDP(pktCtx.unparsed(), pktCtx.inPort())) { | ||
114 | - pktCtx.block(); | ||
115 | - } | ||
116 | - | ||
117 | - } | ||
118 | - | ||
119 | - @Override | ||
120 | - public void switchAdded(Dpid dpid) { | ||
121 | - discoverers.put(dpid, new LinkDiscovery(controller.getSwitch(dpid), | ||
122 | - controller, providerService, useBDDP)); | ||
123 | - | ||
124 | - } | ||
125 | - | ||
126 | - @Override | ||
127 | - public void switchRemoved(Dpid dpid) { | ||
128 | - LinkDiscovery ld = discoverers.remove(dpid); | ||
129 | - if (ld != null) { | ||
130 | - ld.removeAllPorts(); | ||
131 | - } | ||
132 | - providerService.linksVanished( | ||
133 | - DeviceId.deviceId("of:" + Long.toHexString(dpid.value()))); | ||
134 | - } | ||
135 | - | ||
136 | - | ||
137 | - @Override | ||
138 | - public void switchChanged(Dpid dpid) { | ||
139 | - //might not need to do anything since DeviceManager is notified | ||
140 | - } | ||
141 | - | ||
142 | - @Override | ||
143 | - public void portChanged(Dpid dpid, OFPortStatus status) { | ||
144 | - LinkDiscovery ld = discoverers.get(dpid); | ||
145 | - if (ld == null) { | ||
146 | - return; | ||
147 | - } | ||
148 | - final OFPortDesc port = status.getDesc(); | ||
149 | - final boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) && | ||
150 | - !port.getConfig().contains(OFPortConfig.PORT_DOWN); | ||
151 | - if (enabled) { | ||
152 | - ld.addPort(port); | ||
153 | - } else { | ||
154 | - /* | ||
155 | - * remove port calls linkVanished | ||
156 | - */ | ||
157 | - ld.removePort(port); | ||
158 | - } | ||
159 | - | ||
160 | - } | ||
161 | - | ||
162 | - @Override | ||
163 | - public void receivedRoleReply(Dpid dpid, RoleState requested, | ||
164 | - RoleState response) { | ||
165 | - // do nothing for this. | ||
166 | - } | ||
167 | - | ||
168 | - } | ||
169 | - | ||
170 | -} |
1 | -/* | ||
2 | - * Copyright 2014 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 | - | ||
17 | -/** | ||
18 | - * Provider that uses OpenFlow controller as a means of infrastructure link inference. | ||
19 | - */ | ||
20 | -package org.onosproject.provider.of.link.impl; |
This diff is collapsed. Click to expand it.
... | @@ -33,8 +33,6 @@ | ... | @@ -33,8 +33,6 @@ |
33 | 33 | ||
34 | <modules> | 34 | <modules> |
35 | <module>device</module> | 35 | <module>device</module> |
36 | - <module>link</module> | ||
37 | - <module>host</module> | ||
38 | <module>packet</module> | 36 | <module>packet</module> |
39 | <module>flow</module> | 37 | <module>flow</module> |
40 | <module>group</module> | 38 | <module>group</module> | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment