Java 类org.projectfloodlight.openflow.protocol.OFPortReason 实例源码

项目:onos    文件:AbstractOpenFlowSwitch.java   
/**
 * Handle the message coming from the dataplane.
 *
 * @param m the actual message
 */
@Override
public final void handleMessage(OFMessage m) {
    if (this.role == RoleState.MASTER || m instanceof OFPortStatus) {
        try {
            // TODO revisit states other than ports should
            // also ignore role state.
            if (m.getType() == OFType.PORT_STATUS) {
                OFPortStatus portStatus = (OFPortStatus) m;
                if (portStatus.getReason() == OFPortReason.DELETE) {
                    portDescs.remove(portStatus.getDesc().getPortNo());
                } else {
                    portDescs.put(portStatus.getDesc().getPortNo(), portStatus.getDesc());
                }
            }
            this.agent.processMessage(dpid, m);
        } catch (Exception e) {
            log.warn("Unhandled exception processing {}@{}", m, dpid, e);
        }
    } else {
        log.trace("Dropping received message {}, was not MASTER", m);
    }
}
项目:onos    文件:DefaultOFSwitch.java   
private void sendPortStatus(Port port, OFPortReason ofPortReason) {
    Set<Channel> channels = controllerChannels();
    if (channels.isEmpty()) {
        log.trace("No channels present.  Port status will not be sent.");
        return;
    }
    OFPortDesc ofPortDesc = portDesc(port);
    OFPortStatus ofPortStatus = FACTORY.buildPortStatus()
            .setDesc(ofPortDesc)
            .setReason(ofPortReason)
            .build();
    log.trace("Sending port status {}", ofPortStatus);
    channels.forEach(channel -> {
        channel.writeAndFlush(Collections.singletonList(ofPortStatus));
    });
}
项目:athena    文件:OpenFlowDeviceProvider.java   
private PortDescription buildPortDescription(OFPortStatus status) {
    OFPortDesc port = status.getDesc();
    if (status.getReason() != OFPortReason.DELETE) {
        return buildPortDescription(port);
    } else {
        PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
        Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
        SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
        return new DefaultPortDescription(portNo, false, type,
                portSpeed(port), annotations);
    }
}
项目:athena    文件:OpenFlowDeviceProviderTest.java   
@Test
public void portChanged() {
    OFPortStatus stat = SW1.factory().buildPortStatus()
            .setReason(OFPortReason.ADD)
            .setDesc(PD3)
            .build();
    controller.listener.portChanged(DPID1, stat);
    assertNotNull("never went throught the provider service", registry.descr);
    assertEquals("port status unhandled", 3, registry.ports.get(DID1).size());
}
项目:ravikumaran201504    文件:OpenFlowDeviceProvider.java   
private PortDescription buildPortDescription(OFPortStatus status) {
    OFPortDesc port = status.getDesc();
    if (status.getReason() != OFPortReason.DELETE) {
        return buildPortDescription(port);
    } else {
        PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
        Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
        SparseAnnotations annotations = makePortNameAnnotation(port);
        return new DefaultPortDescription(portNo, false, type,
                                          portSpeed(port), annotations);
    }
}
项目:ravikumaran201504    文件:OpenFlowDeviceProviderTest.java   
@Test
public void portChanged() {
    OFPortStatus stat = SW1.factory().buildPortStatus()
            .setReason(OFPortReason.ADD)
            .setDesc(PD3)
            .build();
    controller.listener.portChanged(DPID1, stat);
    assertNotNull("never went throught the provider service", registry.descr);
    assertEquals("port status unhandled", 3, registry.ports.get(DID1).size());
}
项目:ravikumaran201504    文件:OpenFlowLinkProviderTest.java   
private OFPortStatus portStatus(boolean up, int port) {
    OFPortDesc desc = portDesc(port, up);
    OFPortStatus status = OFFactoryVer10.INSTANCE.buildPortStatus()
            .setDesc(desc)
            .setReason(up ? OFPortReason.ADD : OFPortReason.DELETE).build();
    return status;

}
项目:openflowj-otn    文件:OFPortReasonSerializerVer12.java   
public static OFPortReason readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readByte());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer12.java   
public static OFPortReason ofWireValue(byte val) {
    switch(val) {
        case ADD_VAL:
            return OFPortReason.ADD;
        case DELETE_VAL:
            return OFPortReason.DELETE;
        case MODIFY_VAL:
            return OFPortReason.MODIFY;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.2: " + val);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer12.java   
public static byte toWireValue(OFPortReason e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case DELETE:
            return DELETE_VAL;
        case MODIFY:
            return MODIFY_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.2: " + e);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer13.java   
public static OFPortReason readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readByte());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer13.java   
public static OFPortReason ofWireValue(byte val) {
    switch(val) {
        case ADD_VAL:
            return OFPortReason.ADD;
        case DELETE_VAL:
            return OFPortReason.DELETE;
        case MODIFY_VAL:
            return OFPortReason.MODIFY;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.3: " + val);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer13.java   
public static byte toWireValue(OFPortReason e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case DELETE:
            return DELETE_VAL;
        case MODIFY:
            return MODIFY_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.3: " + e);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer10.java   
public static OFPortReason readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readByte());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer10.java   
public static OFPortReason ofWireValue(byte val) {
    switch(val) {
        case ADD_VAL:
            return OFPortReason.ADD;
        case DELETE_VAL:
            return OFPortReason.DELETE;
        case MODIFY_VAL:
            return OFPortReason.MODIFY;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.0: " + val);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer10.java   
public static byte toWireValue(OFPortReason e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case DELETE:
            return DELETE_VAL;
        case MODIFY:
            return MODIFY_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.0: " + e);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer11.java   
public static OFPortReason readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readByte());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer11.java   
public static OFPortReason ofWireValue(byte val) {
    switch(val) {
        case ADD_VAL:
            return OFPortReason.ADD;
        case DELETE_VAL:
            return OFPortReason.DELETE;
        case MODIFY_VAL:
            return OFPortReason.MODIFY;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.1: " + val);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer11.java   
public static byte toWireValue(OFPortReason e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case DELETE:
            return DELETE_VAL;
        case MODIFY:
            return MODIFY_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.1: " + e);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer14.java   
public static OFPortReason readFrom(ChannelBuffer bb) throws OFParseError {
    try {
        return ofWireValue(bb.readByte());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer14.java   
public static OFPortReason ofWireValue(byte val) {
    switch(val) {
        case ADD_VAL:
            return OFPortReason.ADD;
        case DELETE_VAL:
            return OFPortReason.DELETE;
        case MODIFY_VAL:
            return OFPortReason.MODIFY;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.4: " + val);
    }
}
项目:openflowj-otn    文件:OFPortReasonSerializerVer14.java   
public static byte toWireValue(OFPortReason e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case DELETE:
            return DELETE_VAL;
        case MODIFY:
            return MODIFY_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.4: " + e);
    }
}
项目:Engine    文件:NetIDEDeviceProvider.java   
private PortDescription buildPortDescription(OFPortStatus status) {
    OFPortDesc port = status.getDesc();
    if (status.getReason() != OFPortReason.DELETE) {
        return buildPortDescription(port);
    } else {
        PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
        Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
        SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
        return new DefaultPortDescription(portNo, false, type,
                                          portSpeed(port), annotations);
    }
}
项目:spring-open    文件:LinkDiscoveryManagerTest.java   
@Test
public void testHandlePortStatusForNewPort() throws IOException {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();

    long dpid = 3L;
    IOFSwitch sw = createMockSwitch(dpid);
    getMockFloodlightProvider().getSwitches().put(dpid, sw);

    short portNum = 1;

    OFPortDesc ofPortDesc = createMockPort(portNum);

    OFPortStatus portStatus = factory10.buildPortStatus()
        .setDesc(ofPortDesc)
        .setReason(OFPortReason.ADD)
        .build();

    expect(sw.getPort(portNum)).andReturn(ofPortDesc).once();

    sw.write(matchOutPort(portNum),
            anyObject(FloodlightContext.class));
    sw.flush();

    replay(sw);

    linkDiscovery.handlePortStatus(sw, portStatus);

    verify(sw);
}
项目:spring-open    文件:LinkDiscoveryManagerTest.java   
@Test
public void testHandlePortStatusForDeletePort() {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();

    // Add a link that we can delete later during the test
    Link lt = new Link(1L, 1, 2L, 2);
    LinkInfo info = new LinkInfo(System.currentTimeMillis(),
            System.currentTimeMillis(), EMPTY_PORT_STATE, EMPTY_PORT_STATE);
    linkDiscovery.addOrUpdateLink(lt, info);

    short portNum = 1;

    OFPortDesc srcPortDesc = createMockPort(portNum);
    OFPortStatus srcPortStatus = factory10.buildPortStatus()
            .setDesc(srcPortDesc)
            .setReason(OFPortReason.DELETE)
            .build();

    assertNotNull(linkDiscovery.getLinks().get(lt));

    // Send a delete port status for the source port, which should result
    // in the link being deleted
    linkDiscovery.handlePortStatus(
            getMockFloodlightProvider().getSwitches().get(1L), srcPortStatus);

    assertNull(linkDiscovery.getLinks().get(lt));
}
项目:onos    文件:OpenFlowDeviceProvider.java   
@Override
public void portChanged(Dpid dpid, OFPortStatus status) {
    LOG.debug("portChanged({},{})", dpid, status);
    PortDescription portDescription = buildPortDescription(status);
    if (status.getReason() != OFPortReason.DELETE) {
        providerService.portStatusChanged(deviceId(uri(dpid)), portDescription);
    } else {
        providerService.deletePort(deviceId(uri(dpid)), portDescription);
    }
}
项目:onos    文件:OpenFlowDeviceProvider.java   
private PortDescription buildPortDescription(OFPortStatus status) {
    OFPortDesc port = status.getDesc();
    if (status.getReason() != OFPortReason.DELETE) {
        return buildPortDescription(port);
    } else {
        PortDescription desc = buildPortDescription(port);
        if (desc.isEnabled()) {
            return DefaultPortDescription.builder(desc)
                    .isEnabled(false)
                    .build();
        }
        return desc;
    }
}
项目:onos    文件:OpenFlowDeviceProviderTest.java   
@Test
public void portChanged() {
    OFPortStatus stat = SW1.factory().buildPortStatus()
            .setReason(OFPortReason.ADD)
            .setDesc(PD3)
            .build();
    controller.listener.portChanged(DPID1, stat);
    assertNotNull("never went throught the provider service", registry.descr);
    assertEquals("port status unhandled", 3, registry.ports.get(DID1).size());
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer12.java   
public static OFPortReason readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readByte());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer12.java   
public static OFPortReason ofWireValue(byte val) {
    switch(val) {
        case ADD_VAL:
            return OFPortReason.ADD;
        case DELETE_VAL:
            return OFPortReason.DELETE;
        case MODIFY_VAL:
            return OFPortReason.MODIFY;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.2: " + val);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer12.java   
public static byte toWireValue(OFPortReason e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case DELETE:
            return DELETE_VAL;
        case MODIFY:
            return MODIFY_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.2: " + e);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer13.java   
public static OFPortReason readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readByte());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer13.java   
public static OFPortReason ofWireValue(byte val) {
    switch(val) {
        case ADD_VAL:
            return OFPortReason.ADD;
        case DELETE_VAL:
            return OFPortReason.DELETE;
        case MODIFY_VAL:
            return OFPortReason.MODIFY;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.3: " + val);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer13.java   
public static byte toWireValue(OFPortReason e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case DELETE:
            return DELETE_VAL;
        case MODIFY:
            return MODIFY_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.3: " + e);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer10.java   
public static OFPortReason readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readByte());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer10.java   
public static OFPortReason ofWireValue(byte val) {
    switch(val) {
        case ADD_VAL:
            return OFPortReason.ADD;
        case DELETE_VAL:
            return OFPortReason.DELETE;
        case MODIFY_VAL:
            return OFPortReason.MODIFY;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.0: " + val);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer10.java   
public static byte toWireValue(OFPortReason e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case DELETE:
            return DELETE_VAL;
        case MODIFY:
            return MODIFY_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.0: " + e);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer15.java   
public static OFPortReason readFrom(ByteBuf bb) throws OFParseError {
    try {
        return ofWireValue(bb.readByte());
    } catch (IllegalArgumentException e) {
        throw new OFParseError(e);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer15.java   
public static OFPortReason ofWireValue(byte val) {
    switch(val) {
        case ADD_VAL:
            return OFPortReason.ADD;
        case DELETE_VAL:
            return OFPortReason.DELETE;
        case MODIFY_VAL:
            return OFPortReason.MODIFY;
        default:
            throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.5: " + val);
    }
}
项目:loxigen-artifacts    文件:OFPortReasonSerializerVer15.java   
public static byte toWireValue(OFPortReason e) {
    switch(e) {
        case ADD:
            return ADD_VAL;
        case DELETE:
            return DELETE_VAL;
        case MODIFY:
            return MODIFY_VAL;
        default:
            throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.5: " + e);
    }
}