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;
}
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();
}
}
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();
}
Aggregations