Showing
4 changed files
with
99 additions
and
202 deletions
1 | package org.onlab.onos.of.controller.impl; | 1 | package org.onlab.onos.of.controller.impl; |
2 | 2 | ||
3 | +import static org.onlab.util.Tools.namedThreads; | ||
4 | + | ||
3 | import java.util.HashSet; | 5 | import java.util.HashSet; |
6 | +import java.util.List; | ||
7 | +import java.util.Map; | ||
4 | import java.util.Set; | 8 | import java.util.Set; |
5 | import java.util.concurrent.ConcurrentHashMap; | 9 | import java.util.concurrent.ConcurrentHashMap; |
10 | +import java.util.concurrent.ExecutorService; | ||
11 | +import java.util.concurrent.Executors; | ||
6 | import java.util.concurrent.locks.Lock; | 12 | import java.util.concurrent.locks.Lock; |
7 | import java.util.concurrent.locks.ReentrantLock; | 13 | import java.util.concurrent.locks.ReentrantLock; |
8 | 14 | ||
... | @@ -13,6 +19,7 @@ import org.apache.felix.scr.annotations.Service; | ... | @@ -13,6 +19,7 @@ import org.apache.felix.scr.annotations.Service; |
13 | import org.onlab.onos.of.controller.DefaultOpenFlowPacketContext; | 19 | import org.onlab.onos.of.controller.DefaultOpenFlowPacketContext; |
14 | import org.onlab.onos.of.controller.Dpid; | 20 | import org.onlab.onos.of.controller.Dpid; |
15 | import org.onlab.onos.of.controller.OpenFlowController; | 21 | import org.onlab.onos.of.controller.OpenFlowController; |
22 | +import org.onlab.onos.of.controller.OpenFlowEventListener; | ||
16 | import org.onlab.onos.of.controller.OpenFlowPacketContext; | 23 | import org.onlab.onos.of.controller.OpenFlowPacketContext; |
17 | import org.onlab.onos.of.controller.OpenFlowSwitch; | 24 | import org.onlab.onos.of.controller.OpenFlowSwitch; |
18 | import org.onlab.onos.of.controller.OpenFlowSwitchListener; | 25 | import org.onlab.onos.of.controller.OpenFlowSwitchListener; |
... | @@ -22,10 +29,12 @@ import org.onlab.onos.of.controller.driver.OpenFlowAgent; | ... | @@ -22,10 +29,12 @@ import org.onlab.onos.of.controller.driver.OpenFlowAgent; |
22 | import org.projectfloodlight.openflow.protocol.OFMessage; | 29 | import org.projectfloodlight.openflow.protocol.OFMessage; |
23 | import org.projectfloodlight.openflow.protocol.OFPacketIn; | 30 | import org.projectfloodlight.openflow.protocol.OFPacketIn; |
24 | import org.projectfloodlight.openflow.protocol.OFPortStatus; | 31 | import org.projectfloodlight.openflow.protocol.OFPortStatus; |
32 | +import org.projectfloodlight.openflow.protocol.OFType; | ||
25 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
26 | import org.slf4j.LoggerFactory; | 34 | import org.slf4j.LoggerFactory; |
27 | 35 | ||
28 | import com.google.common.collect.ArrayListMultimap; | 36 | import com.google.common.collect.ArrayListMultimap; |
37 | +import com.google.common.collect.Maps; | ||
29 | import com.google.common.collect.Multimap; | 38 | import com.google.common.collect.Multimap; |
30 | 39 | ||
31 | @Component(immediate = true) | 40 | @Component(immediate = true) |
... | @@ -35,6 +44,10 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -35,6 +44,10 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
35 | private static final Logger log = | 44 | private static final Logger log = |
36 | LoggerFactory.getLogger(OpenFlowControllerImpl.class); | 45 | LoggerFactory.getLogger(OpenFlowControllerImpl.class); |
37 | 46 | ||
47 | + private final ExecutorService executor = Executors.newFixedThreadPool(16, | ||
48 | + namedThreads("of-event-dispatch-%d")); | ||
49 | + | ||
50 | + | ||
38 | protected ConcurrentHashMap<Dpid, OpenFlowSwitch> connectedSwitches = | 51 | protected ConcurrentHashMap<Dpid, OpenFlowSwitch> connectedSwitches = |
39 | new ConcurrentHashMap<Dpid, OpenFlowSwitch>(); | 52 | new ConcurrentHashMap<Dpid, OpenFlowSwitch>(); |
40 | protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeMasterSwitches = | 53 | protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeMasterSwitches = |
... | @@ -43,11 +56,12 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -43,11 +56,12 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
43 | new ConcurrentHashMap<Dpid, OpenFlowSwitch>(); | 56 | new ConcurrentHashMap<Dpid, OpenFlowSwitch>(); |
44 | 57 | ||
45 | protected OpenFlowSwitchAgent agent = new OpenFlowSwitchAgent(); | 58 | protected OpenFlowSwitchAgent agent = new OpenFlowSwitchAgent(); |
46 | - protected Set<OpenFlowSwitchListener> ofEventListener = new HashSet<>(); | 59 | + protected Set<OpenFlowSwitchListener> ofSwitchListener = new HashSet<>(); |
47 | 60 | ||
48 | protected Multimap<Integer, PacketListener> ofPacketListener = | 61 | protected Multimap<Integer, PacketListener> ofPacketListener = |
49 | ArrayListMultimap.create(); | 62 | ArrayListMultimap.create(); |
50 | 63 | ||
64 | + protected Map<OFType, List<OpenFlowEventListener>> ofEventListener = Maps.newHashMap(); | ||
51 | 65 | ||
52 | private final Controller ctrl = new Controller(); | 66 | private final Controller ctrl = new Controller(); |
53 | 67 | ||
... | @@ -93,14 +107,14 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -93,14 +107,14 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
93 | 107 | ||
94 | @Override | 108 | @Override |
95 | public void addListener(OpenFlowSwitchListener listener) { | 109 | public void addListener(OpenFlowSwitchListener listener) { |
96 | - if (!ofEventListener.contains(listener)) { | 110 | + if (!ofSwitchListener.contains(listener)) { |
97 | - this.ofEventListener.add(listener); | 111 | + this.ofSwitchListener.add(listener); |
98 | } | 112 | } |
99 | } | 113 | } |
100 | 114 | ||
101 | @Override | 115 | @Override |
102 | public void removeListener(OpenFlowSwitchListener listener) { | 116 | public void removeListener(OpenFlowSwitchListener listener) { |
103 | - this.ofEventListener.remove(listener); | 117 | + this.ofSwitchListener.remove(listener); |
104 | } | 118 | } |
105 | 119 | ||
106 | @Override | 120 | @Override |
... | @@ -122,7 +136,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -122,7 +136,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
122 | public void processPacket(Dpid dpid, OFMessage msg) { | 136 | public void processPacket(Dpid dpid, OFMessage msg) { |
123 | switch (msg.getType()) { | 137 | switch (msg.getType()) { |
124 | case PORT_STATUS: | 138 | case PORT_STATUS: |
125 | - for (OpenFlowSwitchListener l : ofEventListener) { | 139 | + for (OpenFlowSwitchListener l : ofSwitchListener) { |
126 | l.portChanged(dpid, (OFPortStatus) msg); | 140 | l.portChanged(dpid, (OFPortStatus) msg); |
127 | } | 141 | } |
128 | break; | 142 | break; |
... | @@ -134,6 +148,12 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -134,6 +148,12 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
134 | p.handlePacket(pktCtx); | 148 | p.handlePacket(pktCtx); |
135 | } | 149 | } |
136 | break; | 150 | break; |
151 | + case FLOW_REMOVED: | ||
152 | + case ERROR: | ||
153 | + case STATS_REPLY: | ||
154 | + case BARRIER_REPLY: | ||
155 | + executor.submit(new OFMessageHandler(dpid, msg)); | ||
156 | + break; | ||
137 | default: | 157 | default: |
138 | log.warn("Handling message type {} not yet implemented {}", | 158 | log.warn("Handling message type {} not yet implemented {}", |
139 | msg.getType(), msg); | 159 | msg.getType(), msg); |
... | @@ -164,7 +184,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -164,7 +184,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
164 | } else { | 184 | } else { |
165 | log.error("Added switch {}", dpid); | 185 | log.error("Added switch {}", dpid); |
166 | connectedSwitches.put(dpid, sw); | 186 | connectedSwitches.put(dpid, sw); |
167 | - for (OpenFlowSwitchListener l : ofEventListener) { | 187 | + for (OpenFlowSwitchListener l : ofSwitchListener) { |
168 | l.switchAdded(dpid); | 188 | l.switchAdded(dpid); |
169 | } | 189 | } |
170 | return true; | 190 | return true; |
... | @@ -277,7 +297,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -277,7 +297,7 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
277 | if (sw == null) { | 297 | if (sw == null) { |
278 | sw = activeEqualSwitches.remove(dpid); | 298 | sw = activeEqualSwitches.remove(dpid); |
279 | } | 299 | } |
280 | - for (OpenFlowSwitchListener l : ofEventListener) { | 300 | + for (OpenFlowSwitchListener l : ofSwitchListener) { |
281 | l.switchRemoved(dpid); | 301 | l.switchRemoved(dpid); |
282 | } | 302 | } |
283 | } | 303 | } |
... | @@ -288,5 +308,26 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -288,5 +308,26 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
288 | } | 308 | } |
289 | } | 309 | } |
290 | 310 | ||
311 | + private final class OFMessageHandler implements Runnable { | ||
312 | + | ||
313 | + private final OFMessage msg; | ||
314 | + private final Dpid dpid; | ||
315 | + | ||
316 | + public OFMessageHandler(Dpid dpid, OFMessage msg) { | ||
317 | + this.msg = msg; | ||
318 | + this.dpid = dpid; | ||
319 | + } | ||
320 | + | ||
321 | + @Override | ||
322 | + public void run() { | ||
323 | + List<OpenFlowEventListener> listeners = | ||
324 | + ofEventListener.get(OFType.FLOW_REMOVED); | ||
325 | + for (OpenFlowEventListener listener : listeners) { | ||
326 | + listener.handleMessage(dpid, msg); | ||
327 | + } | ||
328 | + } | ||
329 | + | ||
330 | + } | ||
331 | + | ||
291 | 332 | ||
292 | } | 333 | } | ... | ... |
... | @@ -2,58 +2,29 @@ package org.onlab.onos.provider.of.flow.impl; | ... | @@ -2,58 +2,29 @@ package org.onlab.onos.provider.of.flow.impl; |
2 | 2 | ||
3 | import static org.slf4j.LoggerFactory.getLogger; | 3 | import static org.slf4j.LoggerFactory.getLogger; |
4 | 4 | ||
5 | -import java.util.Collections; | ||
6 | -import java.util.LinkedList; | ||
7 | -import java.util.List; | ||
8 | - | ||
9 | import org.apache.felix.scr.annotations.Activate; | 5 | import org.apache.felix.scr.annotations.Activate; |
10 | import org.apache.felix.scr.annotations.Component; | 6 | import org.apache.felix.scr.annotations.Component; |
11 | import org.apache.felix.scr.annotations.Deactivate; | 7 | import org.apache.felix.scr.annotations.Deactivate; |
12 | import org.apache.felix.scr.annotations.Reference; | 8 | import org.apache.felix.scr.annotations.Reference; |
13 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 9 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
14 | import org.onlab.onos.net.DeviceId; | 10 | import org.onlab.onos.net.DeviceId; |
11 | +import org.onlab.onos.net.flow.DefaultFlowRule; | ||
15 | import org.onlab.onos.net.flow.FlowEntry; | 12 | import org.onlab.onos.net.flow.FlowEntry; |
16 | import org.onlab.onos.net.flow.FlowRule; | 13 | import org.onlab.onos.net.flow.FlowRule; |
17 | import org.onlab.onos.net.flow.FlowRuleProvider; | 14 | import org.onlab.onos.net.flow.FlowRuleProvider; |
18 | import org.onlab.onos.net.flow.FlowRuleProviderRegistry; | 15 | import org.onlab.onos.net.flow.FlowRuleProviderRegistry; |
19 | import org.onlab.onos.net.flow.FlowRuleProviderService; | 16 | import org.onlab.onos.net.flow.FlowRuleProviderService; |
20 | -import org.onlab.onos.net.flow.criteria.Criteria.EthCriterion; | ||
21 | -import org.onlab.onos.net.flow.criteria.Criteria.EthTypeCriterion; | ||
22 | -import org.onlab.onos.net.flow.criteria.Criteria.IPCriterion; | ||
23 | -import org.onlab.onos.net.flow.criteria.Criteria.IPProtocolCriterion; | ||
24 | -import org.onlab.onos.net.flow.criteria.Criteria.PortCriterion; | ||
25 | -import org.onlab.onos.net.flow.criteria.Criteria.VlanIdCriterion; | ||
26 | -import org.onlab.onos.net.flow.criteria.Criteria.VlanPcpCriterion; | ||
27 | -import org.onlab.onos.net.flow.criteria.Criterion; | ||
28 | -import org.onlab.onos.net.flow.instructions.Instruction; | ||
29 | -import org.onlab.onos.net.flow.instructions.Instructions.OutputInstruction; | ||
30 | -import org.onlab.onos.net.flow.instructions.L2ModificationInstruction; | ||
31 | -import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; | ||
32 | -import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction; | ||
33 | -import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModVlanPcpInstruction; | ||
34 | -import org.onlab.onos.net.flow.instructions.L3ModificationInstruction; | ||
35 | -import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; | ||
36 | import org.onlab.onos.net.provider.AbstractProvider; | 17 | import org.onlab.onos.net.provider.AbstractProvider; |
37 | import org.onlab.onos.net.provider.ProviderId; | 18 | import org.onlab.onos.net.provider.ProviderId; |
38 | import org.onlab.onos.net.topology.TopologyService; | 19 | import org.onlab.onos.net.topology.TopologyService; |
39 | import org.onlab.onos.of.controller.Dpid; | 20 | import org.onlab.onos.of.controller.Dpid; |
40 | import org.onlab.onos.of.controller.OpenFlowController; | 21 | import org.onlab.onos.of.controller.OpenFlowController; |
22 | +import org.onlab.onos.of.controller.OpenFlowEventListener; | ||
41 | import org.onlab.onos.of.controller.OpenFlowSwitch; | 23 | import org.onlab.onos.of.controller.OpenFlowSwitch; |
42 | -import org.projectfloodlight.openflow.protocol.OFFactory; | 24 | +import org.onlab.onos.of.controller.OpenFlowSwitchListener; |
43 | -import org.projectfloodlight.openflow.protocol.OFFlowMod; | 25 | +import org.projectfloodlight.openflow.protocol.OFFlowRemoved; |
44 | -import org.projectfloodlight.openflow.protocol.OFFlowModFlags; | 26 | +import org.projectfloodlight.openflow.protocol.OFMessage; |
45 | -import org.projectfloodlight.openflow.protocol.action.OFAction; | 27 | +import org.projectfloodlight.openflow.protocol.OFPortStatus; |
46 | -import org.projectfloodlight.openflow.protocol.match.Match; | ||
47 | -import org.projectfloodlight.openflow.protocol.match.MatchField; | ||
48 | -import org.projectfloodlight.openflow.types.EthType; | ||
49 | -import org.projectfloodlight.openflow.types.IPv4Address; | ||
50 | -import org.projectfloodlight.openflow.types.IpProtocol; | ||
51 | -import org.projectfloodlight.openflow.types.MacAddress; | ||
52 | -import org.projectfloodlight.openflow.types.OFBufferId; | ||
53 | -import org.projectfloodlight.openflow.types.OFPort; | ||
54 | -import org.projectfloodlight.openflow.types.OFVlanVidMatch; | ||
55 | -import org.projectfloodlight.openflow.types.VlanPcp; | ||
56 | -import org.projectfloodlight.openflow.types.VlanVid; | ||
57 | import org.slf4j.Logger; | 28 | import org.slf4j.Logger; |
58 | 29 | ||
59 | /** | 30 | /** |
... | @@ -105,168 +76,10 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -105,168 +76,10 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
105 | 76 | ||
106 | private void applyRule(FlowRule flowRule) { | 77 | private void applyRule(FlowRule flowRule) { |
107 | OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri())); | 78 | OpenFlowSwitch sw = controller.getSwitch(Dpid.dpid(flowRule.deviceId().uri())); |
108 | - Match match = buildMatch(flowRule.selector().criteria(), sw.factory()); | 79 | + sw.sendMsg(new FlowModBuilder(flowRule, sw.factory()).buildFlowMod()); |
109 | - List<OFAction> actions = | ||
110 | - buildActions(flowRule.treatment().instructions(), sw.factory()); | ||
111 | - | ||
112 | - //TODO: what to do without bufferid? do we assume that there will be a pktout as well? | ||
113 | - OFFlowMod fm = sw.factory().buildFlowModify() | ||
114 | - .setBufferId(OFBufferId.NO_BUFFER) | ||
115 | - .setActions(actions) | ||
116 | - .setMatch(match) | ||
117 | - .setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM)) | ||
118 | - .setIdleTimeout(10) | ||
119 | - .setHardTimeout(10) | ||
120 | - .setPriority(flowRule.priority()) | ||
121 | - .build(); | ||
122 | - sw.sendMsg(fm); | ||
123 | - } | ||
124 | - | ||
125 | - private List<OFAction> buildActions(List<Instruction> instructions, OFFactory factory) { | ||
126 | - List<OFAction> acts = new LinkedList<>(); | ||
127 | - for (Instruction i : instructions) { | ||
128 | - switch (i.type()) { | ||
129 | - case DROP: | ||
130 | - log.warn("Saw drop action; assigning drop action"); | ||
131 | - return new LinkedList<>(); | ||
132 | - case L2MODIFICATION: | ||
133 | - acts.add(buildL2Modification(i, factory)); | ||
134 | - case L3MODIFICATION: | ||
135 | - acts.add(buildL3Modification(i, factory)); | ||
136 | - case OUTPUT: | ||
137 | - OutputInstruction out = (OutputInstruction) i; | ||
138 | - acts.add(factory.actions().buildOutput().setPort( | ||
139 | - OFPort.of((int) out.port().toLong())).build()); | ||
140 | - break; | ||
141 | - case GROUP: | ||
142 | - default: | ||
143 | - log.warn("Instruction type {} not yet implemented.", i.type()); | ||
144 | - } | ||
145 | - } | ||
146 | - | ||
147 | - return acts; | ||
148 | } | 80 | } |
149 | 81 | ||
150 | - private OFAction buildL3Modification(Instruction i, OFFactory factory) { | ||
151 | - L3ModificationInstruction l3m = (L3ModificationInstruction) i; | ||
152 | - ModIPInstruction ip; | ||
153 | - switch (l3m.subtype()) { | ||
154 | - case L3_DST: | ||
155 | - ip = (ModIPInstruction) i; | ||
156 | - return factory.actions().setNwDst(IPv4Address.of(ip.ip().toInt())); | ||
157 | - case L3_SRC: | ||
158 | - ip = (ModIPInstruction) i; | ||
159 | - return factory.actions().setNwSrc(IPv4Address.of(ip.ip().toInt())); | ||
160 | - default: | ||
161 | - log.warn("Unimplemented action type {}.", l3m.subtype()); | ||
162 | - break; | ||
163 | - } | ||
164 | - return null; | ||
165 | - } | ||
166 | 82 | ||
167 | - private OFAction buildL2Modification(Instruction i, OFFactory factory) { | ||
168 | - L2ModificationInstruction l2m = (L2ModificationInstruction) i; | ||
169 | - ModEtherInstruction eth; | ||
170 | - switch (l2m.subtype()) { | ||
171 | - case L2_DST: | ||
172 | - eth = (ModEtherInstruction) l2m; | ||
173 | - return factory.actions().setDlDst(MacAddress.of(eth.mac().toLong())); | ||
174 | - case L2_SRC: | ||
175 | - eth = (ModEtherInstruction) l2m; | ||
176 | - return factory.actions().setDlSrc(MacAddress.of(eth.mac().toLong())); | ||
177 | - case VLAN_ID: | ||
178 | - ModVlanIdInstruction vlanId = (ModVlanIdInstruction) l2m; | ||
179 | - return factory.actions().setVlanVid(VlanVid.ofVlan(vlanId.vlanId.toShort())); | ||
180 | - case VLAN_PCP: | ||
181 | - ModVlanPcpInstruction vlanPcp = (ModVlanPcpInstruction) l2m; | ||
182 | - return factory.actions().setVlanPcp(VlanPcp.of(vlanPcp.vlanPcp())); | ||
183 | - default: | ||
184 | - log.warn("Unimplemented action type {}.", l2m.subtype()); | ||
185 | - break; | ||
186 | - } | ||
187 | - return null; | ||
188 | - } | ||
189 | - | ||
190 | - private Match buildMatch(List<Criterion> criteria, OFFactory factory) { | ||
191 | - Match.Builder mBuilder = factory.buildMatch(); | ||
192 | - EthCriterion eth; | ||
193 | - IPCriterion ip; | ||
194 | - for (Criterion c : criteria) { | ||
195 | - switch (c.type()) { | ||
196 | - case IN_PORT: | ||
197 | - PortCriterion inport = (PortCriterion) c; | ||
198 | - mBuilder.setExact(MatchField.IN_PORT, OFPort.of((int) inport.port().toLong())); | ||
199 | - break; | ||
200 | - case ETH_SRC: | ||
201 | - eth = (EthCriterion) c; | ||
202 | - mBuilder.setExact(MatchField.ETH_SRC, MacAddress.of(eth.mac().toLong())); | ||
203 | - break; | ||
204 | - case ETH_DST: | ||
205 | - eth = (EthCriterion) c; | ||
206 | - mBuilder.setExact(MatchField.ETH_DST, MacAddress.of(eth.mac().toLong())); | ||
207 | - break; | ||
208 | - case ETH_TYPE: | ||
209 | - EthTypeCriterion ethType = (EthTypeCriterion) c; | ||
210 | - mBuilder.setExact(MatchField.ETH_TYPE, EthType.of(ethType.ethType())); | ||
211 | - break; | ||
212 | - case IPV4_DST: | ||
213 | - ip = (IPCriterion) c; | ||
214 | - mBuilder.setExact(MatchField.IPV4_DST, IPv4Address.of(ip.ip().toInt())); | ||
215 | - break; | ||
216 | - case IPV4_SRC: | ||
217 | - ip = (IPCriterion) c; | ||
218 | - mBuilder.setExact(MatchField.IPV4_SRC, IPv4Address.of(ip.ip().toInt())); | ||
219 | - break; | ||
220 | - case IP_PROTO: | ||
221 | - IPProtocolCriterion p = (IPProtocolCriterion) c; | ||
222 | - mBuilder.setExact(MatchField.IP_PROTO, IpProtocol.of(p.protocol())); | ||
223 | - break; | ||
224 | - case VLAN_PCP: | ||
225 | - VlanPcpCriterion vpcp = (VlanPcpCriterion) c; | ||
226 | - mBuilder.setExact(MatchField.VLAN_PCP, VlanPcp.of(vpcp.priority())); | ||
227 | - break; | ||
228 | - case VLAN_VID: | ||
229 | - VlanIdCriterion vid = (VlanIdCriterion) c; | ||
230 | - mBuilder.setExact(MatchField.VLAN_VID, | ||
231 | - OFVlanVidMatch.ofVlanVid(VlanVid.ofVlan(vid.vlanId().toShort()))); | ||
232 | - break; | ||
233 | - case ARP_OP: | ||
234 | - case ARP_SHA: | ||
235 | - case ARP_SPA: | ||
236 | - case ARP_THA: | ||
237 | - case ARP_TPA: | ||
238 | - case ICMPV4_CODE: | ||
239 | - case ICMPV4_TYPE: | ||
240 | - case ICMPV6_CODE: | ||
241 | - case ICMPV6_TYPE: | ||
242 | - case IN_PHY_PORT: | ||
243 | - case IPV6_DST: | ||
244 | - case IPV6_EXTHDR: | ||
245 | - case IPV6_FLABEL: | ||
246 | - case IPV6_ND_SLL: | ||
247 | - case IPV6_ND_TARGET: | ||
248 | - case IPV6_ND_TLL: | ||
249 | - case IPV6_SRC: | ||
250 | - case IP_DSCP: | ||
251 | - case IP_ECN: | ||
252 | - case METADATA: | ||
253 | - case MPLS_BOS: | ||
254 | - case MPLS_LABEL: | ||
255 | - case MPLS_TC: | ||
256 | - case PBB_ISID: | ||
257 | - case SCTP_DST: | ||
258 | - case SCTP_SRC: | ||
259 | - case TCP_DST: | ||
260 | - case TCP_SRC: | ||
261 | - case TUNNEL_ID: | ||
262 | - case UDP_DST: | ||
263 | - case UDP_SRC: | ||
264 | - default: | ||
265 | - log.warn("Action type {} not yet implemented.", c.type()); | ||
266 | - } | ||
267 | - } | ||
268 | - return mBuilder.build(); | ||
269 | - } | ||
270 | 83 | ||
271 | @Override | 84 | @Override |
272 | public void removeFlowRule(FlowRule... flowRules) { | 85 | public void removeFlowRule(FlowRule... flowRules) { |
... | @@ -283,6 +96,45 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -283,6 +96,45 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
283 | 96 | ||
284 | //TODO: InternalFlowRuleProvider listening to stats and error and flowremoved. | 97 | //TODO: InternalFlowRuleProvider listening to stats and error and flowremoved. |
285 | // possibly barriers as well. May not be internal at all... | 98 | // possibly barriers as well. May not be internal at all... |
99 | + private class InternalFlowProvider | ||
100 | + implements OpenFlowSwitchListener, OpenFlowEventListener { | ||
101 | + | ||
102 | + | ||
103 | + @Override | ||
104 | + public void switchAdded(Dpid dpid) { | ||
105 | + | ||
106 | + | ||
107 | + } | ||
108 | + | ||
109 | + @Override | ||
110 | + public void switchRemoved(Dpid dpid) { | ||
111 | + | ||
112 | + | ||
113 | + } | ||
114 | + | ||
115 | + @Override | ||
116 | + public void portChanged(Dpid dpid, OFPortStatus status) { | ||
117 | + //TODO: Decide whether to evict flows internal store. | ||
118 | + } | ||
119 | + | ||
120 | + @Override | ||
121 | + public void handleMessage(Dpid dpid, OFMessage msg) { | ||
122 | + switch (msg.getType()) { | ||
123 | + case FLOW_REMOVED: | ||
124 | + OFFlowRemoved removed = (OFFlowRemoved) msg; | ||
125 | + FlowRule fr = new DefaultFlowRule(DeviceId.deviceId(Dpid.uri(dpid)), null, null); | ||
126 | + providerService.flowRemoved(fr); | ||
127 | + break; | ||
128 | + case STATS_REPLY: | ||
129 | + case BARRIER_REPLY: | ||
130 | + case ERROR: | ||
131 | + default: | ||
132 | + log.warn("Unhandled message type: {}", msg.getType()); | ||
133 | + } | ||
134 | + | ||
135 | + } | ||
136 | + | ||
137 | + } | ||
286 | 138 | ||
287 | 139 | ||
288 | } | 140 | } | ... | ... |
... | @@ -46,7 +46,7 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext { | ... | @@ -46,7 +46,7 @@ public class OpenFlowCorePacketContext extends DefaultPacketContext { |
46 | private void sendBufferedPacket() { | 46 | private void sendBufferedPacket() { |
47 | List<Instruction> ins = treatmentBuilder().build().instructions(); | 47 | List<Instruction> ins = treatmentBuilder().build().instructions(); |
48 | OFPort p = null; | 48 | OFPort p = null; |
49 | - //TODO: support arbitrary list of treatments | 49 | + //TODO: support arbitrary list of treatments must be supported in ofPacketContext |
50 | for (Instruction i : ins) { | 50 | for (Instruction i : ins) { |
51 | if (i.type() == Type.OUTPUT) { | 51 | if (i.type() == Type.OUTPUT) { |
52 | p = buildPort(((OutputInstruction) i).port()); | 52 | p = buildPort(((OutputInstruction) i).port()); | ... | ... |
... | @@ -226,6 +226,10 @@ public final class IpAddress { | ... | @@ -226,6 +226,10 @@ public final class IpAddress { |
226 | return new IpAddress(version, host, netmask); | 226 | return new IpAddress(version, host, netmask); |
227 | } | 227 | } |
228 | 228 | ||
229 | + public boolean isMasked() { | ||
230 | + return mask() != 0; | ||
231 | + } | ||
232 | + | ||
229 | @Override | 233 | @Override |
230 | public int hashCode() { | 234 | public int hashCode() { |
231 | final int prime = 31; | 235 | final int prime = 31; | ... | ... |
-
Please register or login to post a comment