32 package org.openkilda.floodlight;
34 import static org.easymock.EasyMock.expect;
36 import net.floodlightcontroller.core.SwitchDescription;
37 import org.easymock.EasyMock;
40 import org.junit.Before;
41 import net.floodlightcontroller.core.FloodlightContext;
42 import net.floodlightcontroller.core.IFloodlightProviderService;
43 import net.floodlightcontroller.core.IOFSwitch;
44 import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
45 import org.projectfloodlight.openflow.protocol.OFFactories;
46 import org.projectfloodlight.openflow.protocol.OFFactory;
47 import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
48 import org.projectfloodlight.openflow.protocol.OFMessage;
49 import org.projectfloodlight.openflow.protocol.OFPacketIn;
50 import org.projectfloodlight.openflow.protocol.OFPortDesc;
51 import org.projectfloodlight.openflow.protocol.OFType;
52 import org.projectfloodlight.openflow.protocol.OFVersion;
53 import org.projectfloodlight.openflow.types.DatapathId;
54 import org.projectfloodlight.openflow.types.MacAddress;
55 import org.projectfloodlight.openflow.types.OFPort;
56 import net.floodlightcontroller.packet.Ethernet;
57 import org.projectfloodlight.openflow.types.U64;
59 import java.net.InetSocketAddress;
71 protected OFFactory
factory = OFFactories.getFactory(OFVersion.OF_13);
86 FloodlightContext bc =
new FloodlightContext();
91 if (OFType.PACKET_IN.equals(m.getType())) {
92 OFPacketIn pi = (OFPacketIn)m;
93 Ethernet eth =
new Ethernet();
94 eth.deserialize(pi.getData(), 0, pi.getData().length);
95 IFloodlightProviderService.bcStore.put(bc,
96 IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
103 public void setUp() throws Exception {
110 OFPortDesc portDesc = sw.getOFFactory().buildPortDesc()
111 .setHwAddr(MacAddress.NONE)
112 .setPortNo(OFPort.of(number))
119 OFDescStatsReply swDesc, InetSocketAddress inetAddr) {
120 IOFSwitch sw = EasyMock.createMock(IOFSwitch.class);
121 expect(sw.getId()).andReturn(DatapathId.of(
id)).anyTimes();
122 expect(sw.getPort(OFPort.of(1))).andReturn(portDesc).anyTimes();
123 expect(sw.getOFFactory()).andReturn(
factory).anyTimes();
124 expect(sw.getBuffers()).andReturn(
swFeatures.getNBuffers()).anyTimes();
125 expect(sw.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(
true).anyTimes();
126 expect(sw.getSwitchDescription()).andReturn(
new SwitchDescription(swDesc)).anyTimes();
127 expect(sw.isActive()).andReturn(
true).anyTimes();
128 expect(sw.getLatency()).andReturn(U64.of(10L)).anyTimes();
129 expect(sw.getInetAddress()).andReturn(inetAddr).anyTimes();
static OFPortDesc createOFPortDesc(IOFSwitch sw, String name, int number)
OFFeaturesReply swFeatures
static FloodlightContext parseAndAnnotate(FloodlightContext bc, OFMessage m)
FloodlightContext parseAndAnnotate(OFMessage m)
void setMockFloodlightProvider(MockFloodlightProvider mockFloodlightProvider)
IOFSwitch buildMockIOFSwitch(Long id, OFPortDesc portDesc, OFFactory factory, OFDescStatsReply swDesc, InetSocketAddress inetAddr)
MockFloodlightProvider getMockFloodlightProvider()
MockSwitchManager mockSwitchManager
MockFloodlightProvider mockFloodlightProvider
MockSwitchManager getMockSwitchService()