Search in sources :

Example 1 with FieldMatchBuilder

use of org.openkilda.rulemanager.match.FieldMatch.FieldMatchBuilder in project open-kilda by telstra.

the class OfMatchConverter method getExact.

private FieldMatch getExact(Match match, MatchField<?> field) {
    FieldMatchBuilder builder = FieldMatch.builder();
    switch(field.id) {
        case ETH_SRC:
            builder.field(Field.ETH_SRC);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.ETH_SRC).getLong());
            break;
        case ETH_DST:
            builder.field(Field.ETH_DST);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.ETH_DST).getLong());
            break;
        case ETH_TYPE:
            builder.field(Field.ETH_TYPE);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.ETH_TYPE).getValue());
            break;
        case IP_PROTO:
            builder.field(Field.IP_PROTO);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.IP_PROTO).getIpProtocolNumber());
            break;
        case UDP_SRC:
            builder.field(Field.UDP_SRC);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.UDP_SRC).getPort());
            break;
        case UDP_DST:
            builder.field(Field.UDP_DST);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.UDP_DST).getPort());
            break;
        case METADATA:
            builder.field(Field.METADATA);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.METADATA).getValue().getValue());
            break;
        case IN_PORT:
            builder.field(Field.IN_PORT);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.IN_PORT).getPortNumber());
            break;
        case VLAN_VID:
            builder.field(Field.VLAN_VID);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.VLAN_VID).getVlan());
            break;
        case TUNNEL_ID:
            builder.field(Field.NOVIFLOW_TUNNEL_ID);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.TUNNEL_ID).getValue());
            break;
        case KILDA_VXLAN_VNI:
            builder.field(Field.OVS_VXLAN_VNI);
            builder.value(match.getWithoutPrerequisitesCheck(MatchField.KILDA_VXLAN_VNI).getValue());
            break;
        default:
            throw new IllegalArgumentException(String.format("Unexpected match field id=%s, for class=%s of a match %s", field.id, field.getClass().getName(), match));
    }
    return builder.build();
}
Also used : FieldMatchBuilder(org.openkilda.rulemanager.match.FieldMatch.FieldMatchBuilder)

Example 2 with FieldMatchBuilder

use of org.openkilda.rulemanager.match.FieldMatch.FieldMatchBuilder in project open-kilda by telstra.

the class OfMatchConverter method getMasked.

private FieldMatch getMasked(Match match, MatchField<?> field) {
    FieldMatchBuilder builder = FieldMatch.builder();
    switch(field.id) {
        case ETH_SRC:
            Masked<MacAddress> ethSrcMasked = match.getMaskedWithoutPrerequisitesCheck(MatchField.ETH_SRC);
            builder.field(Field.ETH_SRC);
            builder.value(ethSrcMasked.getValue().getLong());
            builder.mask(ethSrcMasked.getMask().getLong());
            break;
        case ETH_DST:
            Masked<MacAddress> ethDstMasked = match.getMaskedWithoutPrerequisitesCheck(MatchField.ETH_DST);
            builder.field(Field.ETH_DST);
            builder.value(ethDstMasked.getValue().getLong());
            builder.mask(ethDstMasked.getMask().getLong());
            break;
        case ETH_TYPE:
            Masked<EthType> ethTypeMasked = match.getMaskedWithoutPrerequisitesCheck(MatchField.ETH_TYPE);
            builder.field(Field.ETH_TYPE);
            builder.value(ethTypeMasked.getValue().getValue());
            builder.mask((long) ethTypeMasked.getMask().getValue());
            break;
        case IP_PROTO:
            Masked<IpProtocol> ipProtocolMasked = match.getMaskedWithoutPrerequisitesCheck(MatchField.IP_PROTO);
            builder.field(Field.IP_PROTO);
            builder.value(ipProtocolMasked.getValue().getIpProtocolNumber());
            builder.mask((long) ipProtocolMasked.getMask().getIpProtocolNumber());
            break;
        case UDP_SRC:
            Masked<TransportPort> udpSrcMasked = match.getMaskedWithoutPrerequisitesCheck(MatchField.UDP_SRC);
            builder.field(Field.UDP_SRC);
            builder.value(udpSrcMasked.getValue().getPort());
            builder.mask((long) udpSrcMasked.getMask().getPort());
            break;
        case UDP_DST:
            Masked<TransportPort> udpDstMasked = match.getMaskedWithoutPrerequisitesCheck(MatchField.UDP_DST);
            builder.field(Field.UDP_DST);
            builder.value(udpDstMasked.getValue().getPort());
            builder.mask((long) udpDstMasked.getMask().getPort());
            break;
        case METADATA:
            Masked<OFMetadata> metadataMasked = match.getMaskedWithoutPrerequisitesCheck(MatchField.METADATA);
            builder.field(Field.METADATA);
            builder.value(metadataMasked.getValue().getValue().getValue());
            builder.mask(metadataMasked.getMask().getValue().getValue());
            break;
        case IN_PORT:
            Masked<OFPort> inPortMasked = match.getMaskedWithoutPrerequisitesCheck(MatchField.IN_PORT);
            builder.field(Field.IN_PORT);
            builder.value(inPortMasked.getValue().getPortNumber());
            builder.mask((long) inPortMasked.getMask().getPortNumber());
            break;
        case VLAN_VID:
            Masked<OFVlanVidMatch> vlanVidMasked = match.getMaskedWithoutPrerequisitesCheck(MatchField.VLAN_VID);
            builder.field(Field.VLAN_VID);
            builder.value(vlanVidMasked.getValue().getVlan());
            builder.mask((long) vlanVidMasked.getMask().getVlan());
            break;
        case TUNNEL_ID:
            Masked<U64> tunnelIdMasked = match.getMaskedWithoutPrerequisitesCheck(MatchField.TUNNEL_ID);
            builder.field(Field.NOVIFLOW_TUNNEL_ID);
            builder.value(tunnelIdMasked.getValue().getValue());
            builder.mask(tunnelIdMasked.getMask().getValue());
            break;
        case KILDA_VXLAN_VNI:
            Masked<U32> masked = match.getMaskedWithoutPrerequisitesCheck(MatchField.KILDA_VXLAN_VNI);
            builder.field(Field.OVS_VXLAN_VNI);
            builder.value(masked.getValue().getValue());
            builder.mask(masked.getMask().getValue());
            break;
        default:
            throw new IllegalArgumentException(String.format("Unexpected match field id=%s, for class=%s of a match %s", field.id, field.getClass().getName(), match));
    }
    return builder.build();
}
Also used : OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) MacAddress(org.projectfloodlight.openflow.types.MacAddress) OFMetadata(org.projectfloodlight.openflow.types.OFMetadata) FieldMatchBuilder(org.openkilda.rulemanager.match.FieldMatch.FieldMatchBuilder) EthType(org.projectfloodlight.openflow.types.EthType) U64(org.projectfloodlight.openflow.types.U64) U32(org.projectfloodlight.openflow.types.U32) OFPort(org.projectfloodlight.openflow.types.OFPort) IpProtocol(org.projectfloodlight.openflow.types.IpProtocol) TransportPort(org.projectfloodlight.openflow.types.TransportPort)

Aggregations

FieldMatchBuilder (org.openkilda.rulemanager.match.FieldMatch.FieldMatchBuilder)2 EthType (org.projectfloodlight.openflow.types.EthType)1 IpProtocol (org.projectfloodlight.openflow.types.IpProtocol)1 MacAddress (org.projectfloodlight.openflow.types.MacAddress)1 OFMetadata (org.projectfloodlight.openflow.types.OFMetadata)1 OFPort (org.projectfloodlight.openflow.types.OFPort)1 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)1 TransportPort (org.projectfloodlight.openflow.types.TransportPort)1 U32 (org.projectfloodlight.openflow.types.U32)1 U64 (org.projectfloodlight.openflow.types.U64)1