Search in sources :

Example 1 with PiPacketMetadataModel

use of org.onosproject.net.pi.model.PiPacketMetadataModel in project onos by opennetworkinglab.

the class P4InfoParser method parseCtrlPktMetadatas.

private static Map<PiPacketOperationType, PiPacketOperationModel> parseCtrlPktMetadatas(P4Info p4info) throws P4InfoParserException {
    final Map<PiPacketOperationType, PiPacketOperationModel> packetOpMap = Maps.newHashMap();
    for (ControllerPacketMetadata ctrlPktMetaMsg : p4info.getControllerPacketMetadataList()) {
        final ImmutableList.Builder<PiPacketMetadataModel> metadataListBuilder = ImmutableList.builder();
        ctrlPktMetaMsg.getMetadataList().forEach(metadataMsg -> metadataListBuilder.add(new P4PacketMetadataModel(PiPacketMetadataId.of(metadataMsg.getName()), isFieldString(p4info, metadataMsg.getTypeName().getName()) ? P4PacketMetadataModel.BIT_WIDTH_UNDEFINED : metadataMsg.getBitwidth())));
        packetOpMap.put(mapPacketOpType(ctrlPktMetaMsg.getPreamble().getName()), new P4PacketOperationModel(mapPacketOpType(ctrlPktMetaMsg.getPreamble().getName()), metadataListBuilder.build()));
    }
    return packetOpMap;
}
Also used : PiPacketOperationType(org.onosproject.net.pi.model.PiPacketOperationType) ImmutableList(com.google.common.collect.ImmutableList) PiPacketOperationModel(org.onosproject.net.pi.model.PiPacketOperationModel) ControllerPacketMetadata(p4.config.v1.P4InfoOuterClass.ControllerPacketMetadata) PiPacketMetadataModel(org.onosproject.net.pi.model.PiPacketMetadataModel)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 PiPacketMetadataModel (org.onosproject.net.pi.model.PiPacketMetadataModel)1 PiPacketOperationModel (org.onosproject.net.pi.model.PiPacketOperationModel)1 PiPacketOperationType (org.onosproject.net.pi.model.PiPacketOperationType)1 ControllerPacketMetadata (p4.config.v1.P4InfoOuterClass.ControllerPacketMetadata)1