Search in sources :

Example 11 with OFFactory

use of org.projectfloodlight.openflow.protocol.OFFactory in project open-kilda by telstra.

the class SwitchManager method dumpMeters.

/**
 * {@inheritDoc}
 */
@Override
public OFMeterConfigStatsReply dumpMeters(final DatapathId dpid) throws SwitchOperationException {
    OFMeterConfigStatsReply values = null;
    IOFSwitch sw = lookupSwitch(dpid);
    if (sw == null) {
        throw new IllegalArgumentException(String.format("Switch %s was not found", dpid.toString()));
    }
    OFFactory ofFactory = sw.getOFFactory();
    OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest().setMeterId(0xffffffff).build();
    try {
        ListenableFuture<OFMeterConfigStatsReply> future = sw.writeRequest(meterRequest);
        values = future.get(5, TimeUnit.SECONDS);
    } catch (ExecutionException | InterruptedException | TimeoutException e) {
        logger.error("Could not get meter config stats: {}", e.getMessage());
    }
    return values;
}
Also used : OFMeterConfigStatsRequest(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsRequest) OFMeterConfigStatsReply(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Example 12 with OFFactory

use of org.projectfloodlight.openflow.protocol.OFFactory in project open-kilda by telstra.

the class SwitchManager method actionReplaceVlan.

/**
 * Create an OFAction to change the outer most vlan.
 *
 * @param sw      switch object
 * @param newVlan final VLAN to be set on the packet
 * @return {@link OFAction}
 */
private OFAction actionReplaceVlan(final IOFSwitch sw, final int newVlan) {
    OFFactory factory = sw.getOFFactory();
    OFOxms oxms = factory.oxms();
    OFActions actions = factory.actions();
    if (OF_12.compareTo(factory.getVersion()) == 0) {
        return actions.buildSetField().setField(oxms.buildVlanVid().setValue(OFVlanVidMatch.ofRawVid((short) newVlan)).build()).build();
    } else {
        return actions.buildSetField().setField(oxms.buildVlanVid().setValue(OFVlanVidMatch.ofVlan(newVlan)).build()).build();
    }
}
Also used : OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFOxms(org.projectfloodlight.openflow.protocol.oxm.OFOxms) OFActions(org.projectfloodlight.openflow.protocol.action.OFActions)

Example 13 with OFFactory

use of org.projectfloodlight.openflow.protocol.OFFactory in project open-kilda by telstra.

the class PacketFactory method DhcpDiscoveryRequestOFPacketIn.

/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw, MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder.setInPort(OFPort.of(1)).setData(serializedPacket).setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder.setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build()).setData(serializedPacket).setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
Also used : OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn)

Aggregations

OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)13 OFFlowDelete (org.projectfloodlight.openflow.protocol.OFFlowDelete)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 OFFlowStatsReply (org.projectfloodlight.openflow.protocol.OFFlowStatsReply)2 OFFlowStatsRequest (org.projectfloodlight.openflow.protocol.OFFlowStatsRequest)2 OFLegacyMeterMod (org.projectfloodlight.openflow.protocol.OFLegacyMeterMod)2 OFMeterMod (org.projectfloodlight.openflow.protocol.OFMeterMod)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 TimeUnit (java.util.concurrent.TimeUnit)1 Function (java.util.function.Function)1 Collectors.toList (java.util.stream.Collectors.toList)1 IFloodlightProviderService (net.floodlightcontroller.core.IFloodlightProviderService)1