Search in sources :

Example 1 with OFActions

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

the class SwitchManager method actionSetDstMac.

/**
 * Create an action to set the DstMac of a packet
 *
 * @param sw         switch object
 * @param macAddress MacAddress to set
 * @return {@link OFAction}
 */
private OFAction actionSetDstMac(final IOFSwitch sw, final MacAddress macAddress) {
    OFOxms oxms = sw.getOFFactory().oxms();
    OFActions actions = sw.getOFFactory().actions();
    return actions.buildSetField().setField(oxms.buildEthDst().setValue(macAddress).build()).build();
}
Also used : OFOxms(org.projectfloodlight.openflow.protocol.oxm.OFOxms) OFActions(org.projectfloodlight.openflow.protocol.action.OFActions)

Example 2 with OFActions

use of org.projectfloodlight.openflow.protocol.action.OFActions 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)

Aggregations

OFActions (org.projectfloodlight.openflow.protocol.action.OFActions)2 OFOxms (org.projectfloodlight.openflow.protocol.oxm.OFOxms)2 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)1