use of org.onosproject.net.pi.runtime.PiAction in project onos by opennetworkinglab.
the class P4RuntimeGroupTest method outputMember.
private static PiActionProfileMember outputMember(short portNum) {
PiActionParam param = new PiActionParam(PORT_PARAM_ID, ImmutableByteSequence.copyFrom(portNum));
PiAction piAction = PiAction.builder().withId(EGRESS_PORT_ACTION_ID).withParameter(param).build();
return PiActionProfileMember.builder().forActionProfile(ACT_PROF_ID).withAction(piAction).withId(PiActionProfileMemberId.of(BASE_MEM_ID + portNum)).build();
}
use of org.onosproject.net.pi.runtime.PiAction in project onos by opennetworkinglab.
the class ActionCodec method decode.
@Override
protected PiAction decode(P4RuntimeOuterClass.Action message, Object ignored, PiPipeconf pipeconf, P4InfoBrowser browser) throws P4InfoBrowser.NotFoundException, CodecException {
final P4InfoBrowser.EntityBrowser<P4InfoOuterClass.Action.Param> paramInfo = browser.actionParams(message.getActionId());
final String actionName = browser.actions().getById(message.getActionId()).getPreamble().getName();
final PiAction.Builder builder = PiAction.builder().withId(PiActionId.of(actionName));
for (P4RuntimeOuterClass.Action.Param p : message.getParamsList()) {
final P4InfoOuterClass.Action.Param actionParam = paramInfo.getById(p.getParamId());
final ImmutableByteSequence value;
if (browser.isTypeString(actionParam.getTypeName())) {
value = copyFrom(new String(p.getValue().toByteArray()));
} else {
try {
value = copyAndFit(p.getValue().asReadOnlyByteBuffer(), actionParam.getBitwidth());
} catch (ImmutableByteSequence.ByteSequenceTrimException e) {
throw new CodecException(e.getMessage());
}
}
builder.withParameter(new PiActionParam(PiActionParamId.of(actionParam.getName()), value));
}
return builder.build();
}
Aggregations