Reference Guide

Table Of Contents
flow classes also enables the controller to arbitrate flow priorities and therefore minimize conflicts
amongst co-resident SDN applications.
A flow class can be registered with code similar to the following:
import static com.hp.of.ctl.prio.FlowClass.ActionClass.FORWARD;
import static com.hp.of.lib.match.OxmBasicFieldType.*;
private static final String L2_PATH_FWD = "com.foo.app.l2.path";
private static final String PASSWORD = "aPjk57";
private static final String L2_DESC = "Reactive path forwarding flows";
private volatile ControllerService controller = ...; // injected reference
private FlowClass l2Class;
private void init() {
l2Class = new FlowClassRegistrator(L2_PATH_FWD, PASSWORD, L2_DESC)
.fields(ETH_SRC, ETH_DST, ETH_TYPE, IN_PORT)
.actions(FORWARD).register(controller);
}
On creating the Registrator, the first parameter is a logical name for the flow class, the second
parameter is a password used to verify ownership of the flow class (typically via the REST API), and
the third parameter is a short text description of the class (that is displayed in the UI).
“fields” should specify the list of match fields that will be set in the match; “actions” is the class of
actions that will be employed in the actions/instructions of the FlowMod.
Note the use of static imports making the code more concise and easier to read.
The flow class instance created by the controller service is needed to inject both the controller-
assigned priority and controller-assigned base cookie for the class. On creating the flow mod
message, code such as the following might be used:
private static final long MY_COOKIE = 0x00beef00;
private static final ProtocolVersion pv = ProtocolVersion.V_1_3;
OfmMutableFlowMod flow = (OfmMutableFlowMod) MessageFactory.create(pv,
MessageType.FLOW_MOD, FlowModCommand.ADD);
flow.cookie(l2Class.baseCookie() | MY_COOKIE)
.priority(l2Class.priority());
// ... set match fields and actions ...
// ... send flow ...
44