Search in sources :

Example 91 with PortNumber

use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.

the class CriteriaTest method testMatchInPortMethod.

// PortCriterion class
/**
 * Test the matchInPort method.
 */
@Test
public void testMatchInPortMethod() {
    PortNumber p1 = portNumber(1);
    Criterion matchInPort = Criteria.matchInPort(p1);
    PortCriterion portCriterion = checkAndConvert(matchInPort, Criterion.Type.IN_PORT, PortCriterion.class);
    assertThat(portCriterion.port(), is(equalTo(p1)));
}
Also used : PortNumber(org.onosproject.net.PortNumber) Test(org.junit.Test)

Example 92 with PortNumber

use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.

the class LinkDiscoveryAristaImpl method findDestinationPortByName.

private Optional<Port> findDestinationPortByName(String remotePortName, DeviceService deviceService, Device remoteDevice) {
    Optional<Port> remotePort = deviceService.getPorts(remoteDevice.id()).stream().filter(port -> remotePortName.equals(port.annotations().value(AnnotationKeys.PORT_NAME))).findAny();
    if (remotePort.isPresent()) {
        return remotePort;
    } else {
        int portNumber = Integer.valueOf(remotePortName.replaceAll("\\D+", ""));
        DefaultAnnotations.Builder annotations = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, remotePortName);
        return Optional.of(new DefaultPort(remoteDevice, PortNumber.portNumber(portNumber, remotePortName), true, annotations.build()));
    }
}
Also used : Tools(org.onlab.util.Tools) Supplier(com.google.common.base.Supplier) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) AnnotationKeys(org.onosproject.net.AnnotationKeys) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) Link(org.onosproject.net.Link) ConnectPoint(org.onosproject.net.ConnectPoint) AbstractHandlerBehaviour(org.onosproject.net.driver.AbstractHandlerBehaviour) Port(org.onosproject.net.Port) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) StreamSupport(java.util.stream.StreamSupport) LinkDescription(org.onosproject.net.link.LinkDescription) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) DefaultPort(org.onosproject.net.DefaultPort) Device(org.onosproject.net.Device) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Set(java.util.Set) Sets(com.google.common.collect.Sets) LinkDiscovery(org.onosproject.net.behaviour.LinkDiscovery) Objects(java.util.Objects) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) List(java.util.List) DriverHandler(org.onosproject.net.driver.DriverHandler) Stream(java.util.stream.Stream) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Optional(java.util.Optional) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Port(org.onosproject.net.Port) DefaultPort(org.onosproject.net.DefaultPort) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultPort(org.onosproject.net.DefaultPort)

Example 93 with PortNumber

use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.

the class Ofdpa3ExtensionSelectorInterpreter method mapOxm.

@Override
public ExtensionSelector mapOxm(OFOxm<?> oxm) {
    if (oxm.getMatchField().equals(MatchField.OFDPA_OVID)) {
        VlanId vlanId;
        if (oxm.isMasked()) {
            throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
        } else {
            OFOxmOfdpaOvid ovid = ((OFOxmOfdpaOvid) oxm);
            short mask = (short) 0x0FFF;
            short oVid = (short) (mask & ovid.getValue().getRaw());
            vlanId = VlanId.vlanId(oVid);
        }
        return new Ofdpa3MatchOvid(vlanId);
    } else if (oxm.getMatchField().equals(MatchField.OFDPA_MPLS_L2_PORT)) {
        Integer mplsL2Port;
        /*
             * Supported but not used for now.
             */
        if (oxm.isMasked()) {
            throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
        } else {
            OFOxmOfdpaMplsL2Port mplsl2port = ((OFOxmOfdpaMplsL2Port) oxm);
            mplsL2Port = mplsl2port.getValue().getRaw();
            /*
                 * 0x0000XXXX UNI Interface.
                 * 0x0002XXXX NNI Interface
                 */
            if ((mplsL2Port >= 0 && mplsL2Port <= 0x0000FFFF) || (mplsL2Port >= 0x00020000 && mplsL2Port <= 0x0002FFFF)) {
                return new Ofdpa3MatchMplsL2Port(mplsL2Port);
            }
            throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
        }
    } else if (oxm.getMatchField().equals(MatchField.OFDPA_ACTSET_OUTPUT)) {
        U32 portNumberU32 = ((OFOxmOfdpaActsetOutput) oxm).getValue();
        PortNumber portNumber = PortNumber.portNumber(portNumberU32.getValue());
        return new OfdpaMatchActsetOutput(portNumber);
    } else if (oxm.getMatchField().equals(MatchField.OFDPA_ALLOW_VLAN_TRANSLATION)) {
        U8 value = ((OFOxmOfdpaAllowVlanTranslation) oxm).getValue();
        return new OfdpaMatchAllowVlanTranslation(value.getValue());
    }
    throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
}
Also used : OFOxmOfdpaOvid(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaOvid) OFOxmOfdpaActsetOutput(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaActsetOutput) U8(org.projectfloodlight.openflow.types.U8) U32(org.projectfloodlight.openflow.types.U32) OFOxmOfdpaMplsL2Port(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaMplsL2Port) PortNumber(org.onosproject.net.PortNumber) VlanId(org.onlab.packet.VlanId)

Example 94 with PortNumber

use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.

the class NiciraResubmitTableCodec method decode.

@Override
public NiciraResubmitTable decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    // parse in port number
    long portNumberLong = nullIsIllegal(json.get(RESUBMIT_PORT), RESUBMIT_PORT + MISSING_MEMBER_MESSAGE).asLong();
    PortNumber portNumber = PortNumber.portNumber(portNumberLong);
    // parse table id
    short tableId = (short) nullIsIllegal(json.get(RESUBMIT_TABLE), RESUBMIT_TABLE + MISSING_MEMBER_MESSAGE).asInt();
    return new NiciraResubmitTable(portNumber, tableId);
}
Also used : PortNumber(org.onosproject.net.PortNumber) NiciraResubmitTable(org.onosproject.driver.extensions.NiciraResubmitTable)

Example 95 with PortNumber

use of org.onosproject.net.PortNumber in project onos by opennetworkinglab.

the class OfdpaExtensionSelectorInterpreter method mapOxm.

@Override
public ExtensionSelector mapOxm(OFOxm<?> oxm) {
    VlanId vlanId;
    if (oxm.getMatchField().equals(MatchField.VLAN_VID)) {
        if (oxm.isMasked()) {
            OFVlanVidMatch vid = ((OFOxmVlanVidMasked) oxm).getValue();
            OFVlanVidMatch mask = ((OFOxmVlanVidMasked) oxm).getMask();
            if (vid.equals(OFVlanVidMatch.ofRawVid((short) 0))) {
                vlanId = VlanId.NONE;
            } else if (vid.equals(OFVlanVidMatch.PRESENT) && mask.equals(OFVlanVidMatch.PRESENT)) {
                vlanId = VlanId.ANY;
            } else {
                vlanId = VlanId.vlanId(vid.getVlan());
            }
        } else {
            OFVlanVidMatch vid = ((OFOxmVlanVid) oxm).getValue();
            if (!vid.isPresentBitSet()) {
                vlanId = VlanId.NONE;
            } else {
                vlanId = VlanId.vlanId(vid.getVlan());
            }
        }
        return new OfdpaMatchVlanVid(vlanId);
    } else if (oxm.getMatchField().equals(MatchField.OFDPA_ACTSET_OUTPUT)) {
        U32 portNumberU32 = ((OFOxmOfdpaActsetOutput) oxm).getValue();
        PortNumber portNumber = PortNumber.portNumber(portNumberU32.getValue());
        return new OfdpaMatchActsetOutput(portNumber);
    } else if (oxm.getMatchField().equals(MatchField.OFDPA_ALLOW_VLAN_TRANSLATION)) {
        U8 value = ((OFOxmOfdpaAllowVlanTranslation) oxm).getValue();
        return new OfdpaMatchAllowVlanTranslation(value.getValue());
    }
    throw new UnsupportedOperationException("Unexpected OXM: " + oxm.toString());
}
Also used : OFOxmOfdpaAllowVlanTranslation(org.projectfloodlight.openflow.protocol.oxm.OFOxmOfdpaAllowVlanTranslation) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch) U8(org.projectfloodlight.openflow.types.U8) OFOxmVlanVidMasked(org.projectfloodlight.openflow.protocol.oxm.OFOxmVlanVidMasked) U32(org.projectfloodlight.openflow.types.U32) OFOxmVlanVid(org.projectfloodlight.openflow.protocol.oxm.OFOxmVlanVid) PortNumber(org.onosproject.net.PortNumber) VlanId(org.onlab.packet.VlanId)

Aggregations

PortNumber (org.onosproject.net.PortNumber)336 DeviceId (org.onosproject.net.DeviceId)136 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)109 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)103 ConnectPoint (org.onosproject.net.ConnectPoint)82 TrafficSelector (org.onosproject.net.flow.TrafficSelector)80 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)74 Port (org.onosproject.net.Port)67 ArrayList (java.util.ArrayList)64 Set (java.util.Set)64 List (java.util.List)59 Logger (org.slf4j.Logger)58 Collectors (java.util.stream.Collectors)51 DeviceService (org.onosproject.net.device.DeviceService)49 VlanId (org.onlab.packet.VlanId)42 MacAddress (org.onlab.packet.MacAddress)41 Device (org.onosproject.net.Device)40 FlowRule (org.onosproject.net.flow.FlowRule)40 Optional (java.util.Optional)39 Sets (com.google.common.collect.Sets)35