当前位置: 首页>>代码示例>>Java>>正文


Java OFParseError类代码示例

本文整理汇总了Java中org.projectfloodlight.openflow.exceptions.OFParseError的典型用法代码示例。如果您正苦于以下问题:Java OFParseError类的具体用法?Java OFParseError怎么用?Java OFParseError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


OFParseError类属于org.projectfloodlight.openflow.exceptions包,在下文中一共展示了OFParseError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readList

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
public static <T> List<T> readList(ChannelBuffer bb, int length, OFMessageReader<T> reader) throws OFParseError {
    int end = bb.readerIndex() + length;
    Builder<T> builder = ImmutableList.<T>builder();
    if(logger.isTraceEnabled())
        logger.trace("readList(length={}, reader={})", length, reader.getClass());
    while(bb.readerIndex() < end) {
        T read = reader.readFrom(bb);
        if(logger.isTraceEnabled())
            logger.trace("readList: read={}, left={}", read, end - bb.readerIndex());
        builder.add(read);
    }
    if(bb.readerIndex() != end) {
        throw new IllegalStateException("Overread length: length="+length + " overread by "+ (bb.readerIndex() - end) + " reader: "+reader);
    }
    return builder.build();
}
 
开发者ID:o3project,项目名称:openflowj-otn,代码行数:17,代码来源:ChannelUtils.java

示例2: readList

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
public static <T> List<T> readList(ByteBuf bb, int length, OFMessageReader<T> reader) throws OFParseError {
    int end = bb.readerIndex() + length;
    Builder<T> builder = ImmutableList.<T>builder();
    if(logger.isTraceEnabled())
        logger.trace("readList(length={}, reader={})", length, reader.getClass());
    while(bb.readerIndex() < end) {
        T read = reader.readFrom(bb);
        if(logger.isTraceEnabled())
            logger.trace("readList: read={}, left={}", read, end - bb.readerIndex());
        builder.add(read);
    }
    if(bb.readerIndex() != end) {
        throw new IllegalStateException("Overread length: length="+length + " overread by "+ (bb.readerIndex() - end) + " reader: "+reader);
    }
    return builder.build();
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:17,代码来源:ChannelUtils.java

示例3: getParsedMessage

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
public Optional<OFMessage> getParsedMessage() {
    OFFactory factory = OFFactories.getFactory(version);
    try {
        OFMessage msg = factory.getReader().readFrom(ChannelBuffers.wrappedBuffer(data));
        if(msg != null)
            return Optional.of(msg);
        else
            return Optional.absent();
    } catch (OFParseError e) {
        logger.debug("Error parsing error cause data as OFMessage: {}", e.getMessage(), e);
        return Optional.absent();
    }
}
 
开发者ID:o3project,项目名称:openflowj-otn,代码行数:14,代码来源:OFErrorCauseData.java

示例4: ConcretizeMessage

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
/**
 * Concretizes the given message to the corresponding convenience class.
 *
 * @param message
 *            the message
 * @return the concretized message (e.g. an instance of OpenFlowMessage)
 */
public static Message ConcretizeMessage(Message message) {
    try {
        switch (message.getHeader().getMessageType()) {
        case HELLO:
            return toHelloMessage(message);
        case ERROR:
            return toErrorMessage(message);
        case OPENFLOW:
            return toOpenFlowMessage(message);
        case NETCONF:
            return toNetconfMessage(message);
        case OPFLEX:
            return toOpFlexMessage(message);
        case MANAGEMENT:
            return toManagementMessage(message);
        case MODULE_ANNOUNCEMENT:
            return toModuleAnnouncementMessage(message);
        case MODULE_ACKNOWLEDGE:
            return toModuleAcknowledgeMessage(message);
        case TOPOLOGY_UPDATE:
            return toTopologyUpdateMessage(message);
        case FENCE:
            return toFenceMessage(message);
        case HEARTBEAT:
            return toHeartbeatMessage(message);
        default:
            throw new IllegalArgumentException("Unknown message type.");
        }
    } catch (OFParseError ofpe) {
        throw new IllegalArgumentException("Could not decode OpenFlow message.", ofpe);
    }
}
 
开发者ID:fp7-netide,项目名称:Engine,代码行数:40,代码来源:NetIPUtils.java

示例5: toOpenFlowMessage

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
/**
 * To open flow message.
 *
 * @param message
 *            the message
 * @return the open flow message
 * @throws OFParseError
 *             the oF parse error
 */
private static OpenFlowMessage toOpenFlowMessage(Message message) throws OFParseError {
    if (message.getHeader().getMessageType() != MessageType.OPENFLOW)
        throw new IllegalArgumentException("Can only convert OPENFLOW messages");
    if (message instanceof OpenFlowMessage)
        return (OpenFlowMessage) message;
    OpenFlowMessage ofm = new OpenFlowMessage();
    ofm.setHeader(message.getHeader());
    ofm.setOfMessage(OFFactories.getGenericReader()
            .readFrom(new ByteBufferBackedChannelBuffer(ByteBuffer.wrap(message.payload))));
    return ofm;
}
 
开发者ID:fp7-netide,项目名称:Engine,代码行数:21,代码来源:NetIPUtils.java

示例6: messageReceived

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
	ChannelBuffer buf = (ChannelBuffer) e.getMessage();

	try {
		OFMessage msg = OFFactories.getGenericReader().readFrom(buf);
		handleMessage(msg);
	} catch (OFParseError e1) {
		logger.error(e1.getMessage());
	} catch (IllegalArgumentException e2) {
		logger.error(e2.getMessage());
	}
}
 
开发者ID:fp7-netide,项目名称:Engine,代码行数:14,代码来源:SwitchChannelHandler.java

示例7: decode

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel,
                        ChannelBuffer buffer) throws Exception {
    if (!channel.isConnected()) {
        // In testing, I see decode being called AFTER decode last.
        // This check avoids that from reading corrupted frames
        return null;
    }

    // Note that a single call to decode results in reading a single
    // OFMessage from the channel buffer, which is passed on to, and processed
    // by, the controller (in OFChannelHandler).
    // This is different from earlier behavior (with the original openflowj),
    // where we parsed all the messages in the buffer, before passing on
    // a list of the parsed messages to the controller.
    // The performance *may or may not* not be as good as before.
    OFMessageReader<OFMessage> reader = OFFactories.getGenericReader();
    OFMessage message = null;
    try {
        message = reader.readFrom(buffer);
    } catch (OFParseError e) {
        OFChannelHandler ofch = (OFChannelHandler) ctx.getPipeline().getLast();
        log.error("Parse failure of incoming message from switch "
                + ofch.getChannelSwitchInfo() + " Index:Byte ==> {}:{}  {}",
                buffer.readerIndex(),
                buffer.getByte(buffer.readerIndex()),
                buffer.array());

        buffer.clear(); // MUST CLEAR BUFFER or next message will be read
                        // incorrectly
        return null;
    }

    return message;
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:36,代码来源:OFMessageDecoder.java

示例8: getParsedMessage

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
public Optional<OFMessage> getParsedMessage() {
    OFFactory factory = OFFactories.getFactory(version);
    try {
        OFMessage msg = factory.getReader().readFrom(Unpooled.wrappedBuffer(data));
        if(msg != null)
            return Optional.of(msg);
        else
            return Optional.absent();
    } catch (OFParseError e) {
        logger.debug("Error parsing error cause data as OFMessage: {}", e.getMessage(), e);
        return Optional.absent();
    }
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:14,代码来源:OFErrorCauseData.java

示例9: testReadFrom

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
@Test
public void testReadFrom() throws OFParseError, UnknownHostException {
    for(int i=0; i < testStrings.length; i++ ) {
        byte[] bytes = Inet6Address.getByName(testStrings[i]).getAddress();
        IPv6Address ip = IPv6Address.read16Bytes(Unpooled.copiedBuffer(bytes));
        assertEquals(testStrings[i], ip.toString());
        assertArrayEquals(bytes, ip.getBytes());
    }
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:10,代码来源:IPv6AddressTest.java

示例10: testInvalidIPs

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
@Test
public void testInvalidIPs() throws OFParseError {
    for(String invalid : invalidIPs) {
        try {
            IPv6Address.of(invalid);
            fail("Invalid IP "+invalid+ " should have raised IllegalArgumentException");
        } catch(IllegalArgumentException e) {
            // ok
        }
    }
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:12,代码来源:IPv6AddressTest.java

示例11: testZeroCompression

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
@Test
public void testZeroCompression() throws OFParseError {
    assertEquals("::", IPv6Address.of("::").toString(true, false));
    assertEquals("0:0:0:0:0:0:0:0", IPv6Address.of("::").toString(false, false));
    assertEquals("0000:0000:0000:0000:0000:0000:0000:0000", IPv6Address.of("::").toString(false, true));
    assertEquals("1::4:5:6:0:8", IPv6Address.of("1:0:0:4:5:6:0:8").toString(true, false));
    assertEquals("1:0:0:4::8", IPv6Address.of("1:0:0:4:0:0:0:8").toString(true, false));
    // Two equal length zero runs; should zero compress the first instance
    assertEquals("1::4:2:0:0:8", IPv6Address.of("1:0:0:4:2:0:0:8").toString(true, false));
    // Shouldn't zero compress a single zero
    assertEquals("1:0:2:4:3:1:0:8", IPv6Address.of("1:0:2:4:3:1:0:8").toString(true, false));
    // Test zero runs at the end of the address since that's a different code path in toString
    assertEquals("1::4:2:8:0:0", IPv6Address.of("1:0:0:4:2:8:0:0").toString(true, false));
    assertEquals("1:3:2:4:3:1:5:0", IPv6Address.of("1:3:2:4:3:1:5:0").toString(true, false));
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:16,代码来源:IPv6AddressTest.java

示例12: testReadFrom

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
@Test
public void testReadFrom() throws OFParseError {
    for(int i=0; i < testAddresses.length; i++ ) {
        IPv4Address ip = IPv4Address.read4Bytes(Unpooled.copiedBuffer(testAddresses[i]));
        assertEquals(testInts[i], ip.getInt());
        assertArrayEquals(testAddresses[i], ip.getBytes());
        assertEquals(testStrings[i], ip.toString());
    }
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:10,代码来源:IPv4AddressTest.java

示例13: testInvalidIPs

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
@Test
public void testInvalidIPs() throws OFParseError {
    for(String invalid : invalidIPs) {
        try {
            IPv4Address.of(invalid);
            fail("Invalid IP "+invalid+ " should have raised IllegalArgumentException");
        } catch(IllegalArgumentException e) {
            // ok
        }
    }
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:12,代码来源:IPv4AddressTest.java

示例14: testOfMasked

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
@Test
public void testOfMasked() throws OFParseError {
    for (int i = 0; i < ipsWithMask.length; i++) {
        IPv4AddressWithMask value = IPv4AddressWithMask.of(ipsWithMask[i]);
        if (!hasMask[i]) {
            IPv4Address ip = value.getValue();
            assertArrayEquals(ipsWithMaskValues[i][0], ip.getBytes());
        }
        IPv4Address mask = value.getMask();
        if (ipsWithMaskLengths[i] == -1) {
            assertFalse(mask.isCidrMask());
            try {
                mask.asCidrMaskLength();
                fail("Expected IllegalStateException not thrown");
            } catch(IllegalStateException e) {
                //expected
            }
        } else {
            assertTrue(mask.isCidrMask());
            assertEquals(ipsWithMaskLengths[i], mask.asCidrMaskLength());
        }
        assertArrayEquals(ipsWithMaskValues[i][1], mask.getBytes());
        byte[] ipBytes = new byte[4];
        System.arraycopy(ipsWithMaskValues[i][0], 0, ipBytes, 0, 4);
        assertEquals(ipBytes.length, value.getValue().getBytes().length);
        for (int j = 0; j < ipBytes.length; j++) {
            ipBytes[j] &= ipsWithMaskValues[i][1][j];
        }

        assertArrayEquals(ipBytes, value.getValue().getBytes());
        assertThat(String.format("Byte comparison for mask of %s (%s)", ipsWithMask[i], value),
                value.getMask().getBytes(), CoreMatchers.equalTo(ipsWithMaskValues[i][1]));
    }
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:35,代码来源:IPv4AddressTest.java

示例15: testReadFrom

import org.projectfloodlight.openflow.exceptions.OFParseError; //导入依赖的package包/类
@Test
public void testReadFrom() throws OFParseError {
    for(int i=0; i < testAddresses.length; i++ ) {
        MacAddress ip = MacAddress.read6Bytes(Unpooled.copiedBuffer(testAddresses[i]));
        assertEquals(testInts[i], ip.getLong());
        assertArrayEquals(testAddresses[i], ip.getBytes());
        assertEquals(testColonStrings[i], ip.toString());
    }
}
 
开发者ID:floodlight,项目名称:loxigen-artifacts,代码行数:10,代码来源:MacAddressTest.java


注:本文中的org.projectfloodlight.openflow.exceptions.OFParseError类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。