diff options
author | CNlucius <lukai1@huawei.com> | 2016-09-13 11:40:12 +0800 |
---|---|---|
committer | CNlucius <lukai1@huawei.com> | 2016-09-13 11:41:53 +0800 |
commit | b731e2f1dd0972409b136aebc7b463dd72c9cfad (patch) | |
tree | 5107d7d80c19ad8076c2c97c2b5ef8d1cf3ab903 /framework/src/onos/providers/openflow/packet | |
parent | ee93993458266114c29271a481ef9ce7ce621b2a (diff) |
ONOSFW-171
O/S-SFC-ONOS scenario documentation
Change-Id: I51ae1cf736ea24ab6680f8edca1b2bf5dd598365
Signed-off-by: CNlucius <lukai1@huawei.com>
Diffstat (limited to 'framework/src/onos/providers/openflow/packet')
5 files changed, 0 insertions, 761 deletions
diff --git a/framework/src/onos/providers/openflow/packet/pom.xml b/framework/src/onos/providers/openflow/packet/pom.xml deleted file mode 100644 index b8dbb689..00000000 --- a/framework/src/onos/providers/openflow/packet/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Copyright 2014 Open Networking Laboratory - ~ - ~ Licensed under the Apache License, Version 2.0 (the "License"); - ~ you may not use this file except in compliance with the License. - ~ You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.onosproject</groupId> - <artifactId>onos-of-providers</artifactId> - <version>1.4.0-rc1</version> - <relativePath>../pom.xml</relativePath> - </parent> - - <artifactId>onos-of-provider-packet</artifactId> - <packaging>bundle</packaging> - - <description>ONOS OpenFlow protocol packet provider</description> - -</project> diff --git a/framework/src/onos/providers/openflow/packet/src/main/java/org/onosproject/provider/of/packet/impl/OpenFlowCorePacketContext.java b/framework/src/onos/providers/openflow/packet/src/main/java/org/onosproject/provider/of/packet/impl/OpenFlowCorePacketContext.java deleted file mode 100644 index 6d153103..00000000 --- a/framework/src/onos/providers/openflow/packet/src/main/java/org/onosproject/provider/of/packet/impl/OpenFlowCorePacketContext.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.provider.of.packet.impl; - -import org.onlab.packet.DeserializationException; -import org.onlab.packet.Ethernet; -import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.instructions.Instruction; -import org.onosproject.net.flow.instructions.Instruction.Type; -import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; -import org.onosproject.net.packet.DefaultPacketContext; -import org.onosproject.net.packet.InboundPacket; -import org.onosproject.net.packet.OutboundPacket; -import org.onosproject.openflow.controller.OpenFlowPacketContext; -import org.projectfloodlight.openflow.types.OFPort; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; - -/** - * Packet context used with the OpenFlow providers. - */ -public class OpenFlowCorePacketContext extends DefaultPacketContext { - - private static final Logger log = LoggerFactory.getLogger(OpenFlowCorePacketContext.class); - - private final OpenFlowPacketContext ofPktCtx; - - /** - * Creates a new OpenFlow core packet context. - * - * @param time creation time - * @param inPkt inbound packet - * @param outPkt outbound packet - * @param block whether the context is blocked or not - * @param ofPktCtx OpenFlow packet context - */ - protected OpenFlowCorePacketContext(long time, InboundPacket inPkt, - OutboundPacket outPkt, boolean block, - OpenFlowPacketContext ofPktCtx) { - super(time, inPkt, outPkt, block); - this.ofPktCtx = ofPktCtx; - } - - @Override - public void send() { - if (!this.block()) { - if (outPacket() == null) { - sendPacket(null); - } else { - try { - Ethernet eth = Ethernet.deserializer() - .deserialize(outPacket().data().array(), 0, - outPacket().data().array().length); - sendPacket(eth); - } catch (DeserializationException e) { - log.warn("Unable to deserialize packet"); - } - } - } - } - - private void sendPacket(Ethernet eth) { - List<Instruction> ins = treatmentBuilder().build().allInstructions(); - OFPort p = null; - //TODO: support arbitrary list of treatments must be supported in ofPacketContext - for (Instruction i : ins) { - if (i.type() == Type.OUTPUT) { - p = buildPort(((OutputInstruction) i).port()); - break; //for now... - } - } - if (eth == null) { - ofPktCtx.build(p); - } else { - ofPktCtx.build(eth, p); - } - ofPktCtx.send(); - } - - private OFPort buildPort(PortNumber port) { - return OFPort.of((int) port.toLong()); - } - -} diff --git a/framework/src/onos/providers/openflow/packet/src/main/java/org/onosproject/provider/of/packet/impl/OpenFlowPacketProvider.java b/framework/src/onos/providers/openflow/packet/src/main/java/org/onosproject/provider/of/packet/impl/OpenFlowPacketProvider.java deleted file mode 100644 index dc79feff..00000000 --- a/framework/src/onos/providers/openflow/packet/src/main/java/org/onosproject/provider/of/packet/impl/OpenFlowPacketProvider.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.provider.of.packet.impl; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.onosproject.net.ConnectPoint; -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.instructions.Instruction; -import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; -import org.onosproject.net.packet.DefaultInboundPacket; -import org.onosproject.net.packet.DefaultOutboundPacket; -import org.onosproject.net.packet.OutboundPacket; -import org.onosproject.net.packet.PacketProvider; -import org.onosproject.net.packet.PacketProviderRegistry; -import org.onosproject.net.packet.PacketProviderService; -import org.onosproject.net.provider.AbstractProvider; -import org.onosproject.net.provider.ProviderId; -import org.onosproject.openflow.controller.Dpid; -import org.onosproject.openflow.controller.OpenFlowController; -import org.onosproject.openflow.controller.OpenFlowPacketContext; -import org.onosproject.openflow.controller.OpenFlowSwitch; -import org.onosproject.openflow.controller.PacketListener; -import org.projectfloodlight.openflow.protocol.OFPacketOut; -import org.projectfloodlight.openflow.protocol.OFPortDesc; -import org.projectfloodlight.openflow.protocol.action.OFAction; -import org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10; -import org.projectfloodlight.openflow.types.OFBufferId; -import org.projectfloodlight.openflow.types.OFPort; -import org.slf4j.Logger; - -import java.nio.ByteBuffer; -import java.util.Collections; - -import static org.slf4j.LoggerFactory.getLogger; - - -/** - * Provider which uses an OpenFlow controller to detect network - * infrastructure links. - */ -@Component(immediate = true) -public class OpenFlowPacketProvider extends AbstractProvider implements PacketProvider { - - private final Logger log = getLogger(getClass()); - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected PacketProviderRegistry providerRegistry; - - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) - protected OpenFlowController controller; - - private PacketProviderService providerService; - - private final InternalPacketProvider listener = new InternalPacketProvider(); - - /** - * Creates an OpenFlow link provider. - */ - public OpenFlowPacketProvider() { - super(new ProviderId("of", "org.onosproject.provider.openflow")); - } - - @Activate - public void activate() { - providerService = providerRegistry.register(this); - controller.addPacketListener(20, listener); - log.info("Started"); - } - - @Deactivate - public void deactivate() { - providerRegistry.unregister(this); - controller.removePacketListener(listener); - providerService = null; - log.info("Stopped"); - } - - @Override - public void emit(OutboundPacket packet) { - DeviceId devId = packet.sendThrough(); - String scheme = devId.toString().split(":")[0]; - - if (!scheme.equals(this.id().scheme())) { - throw new IllegalArgumentException( - "Don't know how to handle Device with scheme " + scheme); - } - - Dpid dpid = Dpid.dpid(devId.uri()); - OpenFlowSwitch sw = controller.getSwitch(dpid); - if (sw == null) { - log.warn("Device {} isn't available?", devId); - return; - } - - //Ethernet eth = new Ethernet(); - //eth.deserialize(packet.data().array(), 0, packet.data().array().length); - OFPortDesc p = null; - for (Instruction inst : packet.treatment().allInstructions()) { - if (inst.type().equals(Instruction.Type.OUTPUT)) { - p = portDesc(((OutputInstruction) inst).port()); - OFPacketOut po = packetOut(sw, packet.data().array(), p.getPortNo()); - sw.sendMsg(po); - } - } - - } - - private OFPortDesc portDesc(PortNumber port) { - OFPortDesc.Builder builder = OFFactoryVer10.INSTANCE.buildPortDesc(); - builder.setPortNo(OFPort.of((int) port.toLong())); - - return builder.build(); - } - - private OFPacketOut packetOut(OpenFlowSwitch sw, byte[] eth, OFPort out) { - OFPacketOut.Builder builder = sw.factory().buildPacketOut(); - OFAction act = sw.factory().actions() - .buildOutput() - .setPort(out) - .build(); - return builder - .setBufferId(OFBufferId.NO_BUFFER) - .setInPort(OFPort.CONTROLLER) - .setActions(Collections.singletonList(act)) - .setData(eth) - .build(); - } - - /** - * Internal Packet Provider implementation. - * - */ - private class InternalPacketProvider implements PacketListener { - - @Override - public void handlePacket(OpenFlowPacketContext pktCtx) { - DeviceId id = DeviceId.deviceId(Dpid.uri(pktCtx.dpid().value())); - - DefaultInboundPacket inPkt = new DefaultInboundPacket( - new ConnectPoint(id, PortNumber.portNumber(pktCtx.inPort())), - pktCtx.parsed(), ByteBuffer.wrap(pktCtx.unparsed())); - - DefaultOutboundPacket outPkt = null; - if (!pktCtx.isBuffered()) { - outPkt = new DefaultOutboundPacket(id, null, - ByteBuffer.wrap(pktCtx.unparsed())); - } - - OpenFlowCorePacketContext corePktCtx = - new OpenFlowCorePacketContext(System.currentTimeMillis(), - inPkt, outPkt, pktCtx.isHandled(), pktCtx); - providerService.processPacket(corePktCtx); - } - - } - - -} diff --git a/framework/src/onos/providers/openflow/packet/src/main/java/org/onosproject/provider/of/packet/impl/package-info.java b/framework/src/onos/providers/openflow/packet/src/main/java/org/onosproject/provider/of/packet/impl/package-info.java deleted file mode 100644 index dd1130c0..00000000 --- a/framework/src/onos/providers/openflow/packet/src/main/java/org/onosproject/provider/of/packet/impl/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2014 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Provider that uses OpenFlow controller as a means of intercepting and - * emitting packets. - */ -package org.onosproject.provider.of.packet.impl; diff --git a/framework/src/onos/providers/openflow/packet/src/test/java/org/onosproject/provider/of/packet/impl/OpenFlowPacketProviderTest.java b/framework/src/onos/providers/openflow/packet/src/test/java/org/onosproject/provider/of/packet/impl/OpenFlowPacketProviderTest.java deleted file mode 100644 index 5fded926..00000000 --- a/framework/src/onos/providers/openflow/packet/src/test/java/org/onosproject/provider/of/packet/impl/OpenFlowPacketProviderTest.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.provider.of.packet.impl; - -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onlab.packet.ARP; -import org.onlab.packet.Ethernet; -import org.onosproject.net.Device; -import org.onosproject.net.DeviceId; -import org.onosproject.net.PortNumber; -import org.onosproject.net.flow.DefaultTrafficTreatment; -import org.onosproject.net.flow.TrafficTreatment; -import org.onosproject.net.flow.instructions.Instruction; -import org.onosproject.net.flow.instructions.Instructions; -import org.onosproject.net.packet.DefaultOutboundPacket; -import org.onosproject.net.packet.OutboundPacket; -import org.onosproject.net.packet.PacketContext; -import org.onosproject.net.packet.PacketProvider; -import org.onosproject.net.packet.PacketProviderRegistry; -import org.onosproject.net.packet.PacketProviderService; -import org.onosproject.net.provider.ProviderId; -import org.onosproject.openflow.controller.DefaultOpenFlowPacketContext; -import org.onosproject.openflow.controller.Dpid; -import org.onosproject.openflow.controller.OpenFlowController; -import org.onosproject.openflow.controller.OpenFlowEventListener; -import org.onosproject.openflow.controller.OpenFlowPacketContext; -import org.onosproject.openflow.controller.OpenFlowSwitch; -import org.onosproject.openflow.controller.OpenFlowSwitchListener; -import org.onosproject.openflow.controller.PacketListener; -import org.onosproject.openflow.controller.RoleState; -import org.projectfloodlight.openflow.protocol.OFFactory; -import org.projectfloodlight.openflow.protocol.OFMessage; -import org.projectfloodlight.openflow.protocol.OFPacketIn; -import org.projectfloodlight.openflow.protocol.OFPacketInReason; -import org.projectfloodlight.openflow.protocol.OFPortDesc; -import org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10; -import org.projectfloodlight.openflow.types.MacAddress; -import org.projectfloodlight.openflow.types.OFBufferId; -import org.projectfloodlight.openflow.types.OFPort; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import static org.junit.Assert.*; - - -public class OpenFlowPacketProviderTest { - - private static final int PN1 = 100; - private static final int PN2 = 200; - private static final int PN3 = 300; - private static final short VLANID = (short) 100; - - private static final DeviceId DID = DeviceId.deviceId("of:1"); - private static final DeviceId DID_MISSING = DeviceId.deviceId("of:2"); - private static final DeviceId DID_WRONG = DeviceId.deviceId("test:1"); - private static final PortNumber P1 = PortNumber.portNumber(PN1); - private static final PortNumber P2 = PortNumber.portNumber(PN2); - private static final PortNumber P3 = PortNumber.portNumber(PN3); - - private static final Instruction INST1 = Instructions.createOutput(P1); - private static final Instruction INST2 = Instructions.createOutput(P2); - private static final Instruction INST3 = Instructions.createOutput(P3); - - private static final OFPortDesc PD1 = portDesc(PN1); - private static final OFPortDesc PD2 = portDesc(PN2); - - private static final List<OFPortDesc> PLIST = Lists.newArrayList(PD1, PD2); - private static final TrafficTreatment TR = treatment(INST1, INST2); - private static final TrafficTreatment TR_MISSING = treatment(INST1, INST3); - - private static final byte[] ANY = new byte [] {0, 0, 0, 0}; - - private final OpenFlowPacketProvider provider = new OpenFlowPacketProvider(); - private final TestPacketRegistry registry = new TestPacketRegistry(); - private final TestController controller = new TestController(); - - private final TestOpenFlowSwitch sw = new TestOpenFlowSwitch(); - - @Before - public void startUp() { - provider.providerRegistry = registry; - provider.controller = controller; - provider.activate(); - assertNotNull("listener should be registered", registry.listener); - } - - @After - public void teardown() { - provider.deactivate(); - assertNull("listeners shouldn't be registered", registry.listener); - provider.controller = null; - provider.providerRegistry = null; - } - - @Test(expected = IllegalArgumentException.class) - public void wrongScheme() { - sw.setRole(RoleState.MASTER); - OutboundPacket schemeFailPkt = outPacket(DID_WRONG, TR, null); - provider.emit(schemeFailPkt); - assertEquals("message sent incorrectly", 0, sw.sent.size()); - } - - @Test - public void emit() { - - MacAddress mac1 = MacAddress.of("00:00:00:11:00:01"); - MacAddress mac2 = MacAddress.of("00:00:00:22:00:02"); - - ARP arp = new ARP(); - arp.setSenderProtocolAddress(ANY) - .setSenderHardwareAddress(mac1.getBytes()) - .setTargetHardwareAddress(mac2.getBytes()) - .setTargetProtocolAddress(ANY) - .setHardwareType((short) 0) - .setProtocolType((short) 0) - .setHardwareAddressLength((byte) 6) - .setProtocolAddressLength((byte) 4) - .setOpCode((byte) 0); - - Ethernet eth = new Ethernet(); - eth.setVlanID(VLANID) - .setEtherType(Ethernet.TYPE_ARP) - .setSourceMACAddress("00:00:00:11:00:01") - .setDestinationMACAddress("00:00:00:22:00:02") - .setPayload(arp); - - //the should-be working setup. - OutboundPacket passPkt = outPacket(DID, TR, eth); - sw.setRole(RoleState.MASTER); - provider.emit(passPkt); - assertEquals("invalid switch", sw, controller.current); - assertEquals("message not sent", PLIST.size(), sw.sent.size()); - sw.sent.clear(); - - //wrong Role - //sw.setRole(RoleState.SLAVE); - //provider.emit(passPkt); - //assertEquals("invalid switch", sw, controller.current); - //assertEquals("message sent incorrectly", 0, sw.sent.size()); - - //sw.setRole(RoleState.MASTER); - - //missing switch - OutboundPacket swFailPkt = outPacket(DID_MISSING, TR, eth); - provider.emit(swFailPkt); - assertNull("invalid switch", controller.current); - assertEquals("message sent incorrectly", 0, sw.sent.size()); - - //to missing port - //OutboundPacket portFailPkt = outPacket(DID, TR_MISSING, eth); - //provider.emit(portFailPkt); - //assertEquals("extra message sent", 1, sw.sent.size()); - - } - - @Test - public void handlePacket() { - OFPacketIn pkt = sw.factory().buildPacketIn() - .setBufferId(OFBufferId.NO_BUFFER) - .setInPort(OFPort.NO_MASK) - .setReason(OFPacketInReason.INVALID_TTL) - .build(); - - controller.processPacket(null, pkt); - assertNotNull("message unprocessed", registry.ctx); - - } - - private static OFPortDesc portDesc(int port) { - OFPortDesc.Builder builder = OFFactoryVer10.INSTANCE.buildPortDesc(); - builder.setPortNo(OFPort.of(port)); - - return builder.build(); - } - - private static TrafficTreatment treatment(Instruction ... insts) { - TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder(); - for (Instruction i : insts) { - builder.add(i); - } - return builder.build(); - } - - private static OutboundPacket outPacket( - DeviceId d, TrafficTreatment t, Ethernet e) { - ByteBuffer buf = null; - if (e != null) { - buf = ByteBuffer.wrap(e.serialize()); - } - return new DefaultOutboundPacket(d, t, buf); - } - - private class TestPacketRegistry implements PacketProviderRegistry { - - PacketProvider listener = null; - PacketContext ctx = null; - - @Override - public PacketProviderService register(PacketProvider provider) { - listener = provider; - return new TestPacketProviderService(); - } - - @Override - public void unregister(PacketProvider provider) { - listener = null; - } - - @Override - public Set<ProviderId> getProviders() { - return Sets.newHashSet(listener.id()); - } - - private class TestPacketProviderService implements PacketProviderService { - - @Override - public PacketProvider provider() { - return null; - } - - @Override - public void processPacket(PacketContext context) { - ctx = context; - } - - } - } - - private class TestController implements OpenFlowController { - - PacketListener pktListener; - OpenFlowSwitch current; - - @Override - public Iterable<OpenFlowSwitch> getSwitches() { - return null; - } - - @Override - public Iterable<OpenFlowSwitch> getMasterSwitches() { - return null; - } - - @Override - public Iterable<OpenFlowSwitch> getEqualSwitches() { - return null; - } - - @Override - public OpenFlowSwitch getSwitch(Dpid dpid) { - if (dpid.equals(Dpid.dpid(DID.uri()))) { - current = sw; - } else { - current = null; - } - return current; - } - - @Override - public OpenFlowSwitch getMasterSwitch(Dpid dpid) { - return null; - } - - @Override - public OpenFlowSwitch getEqualSwitch(Dpid dpid) { - return null; - } - - @Override - public void addListener(OpenFlowSwitchListener listener) { - } - - @Override - public void removeListener(OpenFlowSwitchListener listener) { - } - - @Override - public void addPacketListener(int priority, PacketListener listener) { - pktListener = listener; - } - - @Override - public void removePacketListener(PacketListener listener) { - } - - @Override - public void addEventListener(OpenFlowEventListener listener) { - } - - @Override - public void removeEventListener(OpenFlowEventListener listener) { - } - - @Override - public void write(Dpid dpid, OFMessage msg) { - } - - @Override - public void processPacket(Dpid dpid, OFMessage msg) { - OpenFlowPacketContext pktCtx = - DefaultOpenFlowPacketContext. - packetContextFromPacketIn(sw, (OFPacketIn) msg); - pktListener.handlePacket(pktCtx); - } - - @Override - public void setRole(Dpid dpid, RoleState role) { - } - - } - - private class TestOpenFlowSwitch implements OpenFlowSwitch { - - RoleState state; - List<OFMessage> sent = new ArrayList<OFMessage>(); - OFFactory factory = OFFactoryVer10.INSTANCE; - - @Override - public void sendMsg(OFMessage msg) { - sent.add(msg); - } - - @Override - public void sendMsg(List<OFMessage> msgs) { - } - - @Override - public void handleMessage(OFMessage fromSwitch) { - } - - @Override - public void setRole(RoleState role) { - state = role; - } - - @Override - public RoleState getRole() { - return state; - } - - @Override - public List<OFPortDesc> getPorts() { - return PLIST; - } - - @Override - public OFFactory factory() { - return factory; - } - - @Override - public String getStringId() { - return null; - } - - @Override - public long getId() { - return 0; - } - - @Override - public String manufacturerDescription() { - return null; - } - - @Override - public String datapathDescription() { - return null; - } - - @Override - public String hardwareDescription() { - return null; - } - - @Override - public String softwareDescription() { - return null; - } - - @Override - public String serialNumber() { - return null; - } - - @Override - public boolean isConnected() { - return true; - } - - @Override - public void disconnectSwitch() { - } - - @Override - public void returnRoleReply(RoleState requested, RoleState reponse) { - } - @Override - public Device.Type deviceType() { - return Device.Type.SWITCH; - } - - @Override - public String channelId() { - return "1.2.3.4:1"; - } - - - } - -} |