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


Java BgpMessage类代码示例

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


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

示例1: encode

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
@Override
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
    log.debug("BGPMessageEncoder::encode");
    if (!(msg instanceof List)) {
        log.debug("Invalid msg.");
        return msg;
    }

    @SuppressWarnings("unchecked")
    List<BgpMessage> msglist = (List<BgpMessage>) msg;

    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();

    log.debug("SENDING MESSAGE");
    for (BgpMessage pm : msglist) {
        pm.writeTo(buf);
    }

    HexDump.dump(buf);

    return buf;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:BgpMessageEncoder.java

示例2: sendMessage

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
@Override
public final void sendMessage(BgpMessage m) {
    log.debug("Sending message to {}", channel.getRemoteAddress());
    try {
        channel.write(Collections.singletonList(m));
        this.pktStats.addOutPacket();
    } catch (RejectedExecutionException e) {
        log.warn(e.getMessage());
        if (!e.getMessage().contains(SHUTDOWN_MSG)) {
            throw e;
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:BgpPeerImpl.java

示例3: decode

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
    log.debug("MESSAGE IS RECEIVED.");
    if (!channel.isConnected()) {
        log.info("Channel is not connected.");
        return null;
    }

    HexDump.dump(buffer);

    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    List<BgpMessage> msgList = (List<BgpMessage>) ctx.getAttachment();

    if (msgList == null) {
        msgList = new LinkedList<>();
    }

    try {
        while (buffer.readableBytes() > 0) {
            buffer.markReaderIndex();
            BgpHeader bgpHeader = new BgpHeader();
            BgpMessage message = reader.readFrom(buffer, bgpHeader);
            msgList.add(message);
        }

        return msgList;
    } catch (Exception e) {
        log.debug("Bgp protocol message decode error");
        buffer.resetReaderIndex();
        buffer.discardReadBytes();
        ctx.setAttachment(msgList);
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:BgpMessageDecoder.java

示例4: messageReceived

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    if (e.getMessage() instanceof List) {
        @SuppressWarnings("Unchecked")
        List<BgpMessage> msglist = (List<BgpMessage>) e.getMessage();
        for (BgpMessage pm : msglist) {
            // Do the actual packet processing
            state.processBgpMessage(this, pm);
        }
    } else {
        state.processBgpMessage(this, (BgpMessage) e.getMessage());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:BgpChannelHandler.java

示例5: sendHandshakeOpenMessage

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
/**
 * Send handshake open message to the peer.
 *
 * @throws IOException, BgpParseException
 */
private void sendHandshakeOpenMessage() throws IOException, BgpParseException {
    int bgpId;
    BgpCfg.FlowSpec flowSpec = bgpconfig.flowSpecCapability();
    boolean flowSpecStatus = false;
    boolean vpnFlowSpecStatus = false;

    bgpId = Ip4Address.valueOf(bgpconfig.getRouterId()).toInt();

    if (flowSpec == BgpCfg.FlowSpec.IPV4) {
        flowSpecStatus = true;
    } else if (flowSpec == BgpCfg.FlowSpec.VPNV4) {
        vpnFlowSpecStatus = true;
    } else if (flowSpec == BgpCfg.FlowSpec.IPV4_VPNV4) {
        flowSpecStatus = true;
        vpnFlowSpecStatus = true;
    }

    BgpMessage msg = factory4.openMessageBuilder().setAsNumber((short) bgpconfig.getAsNumber())
            .setHoldTime(bgpconfig.getHoldTime()).setBgpId(bgpId)
            .setLsCapabilityTlv(bgpconfig.getLsCapability())
            .setLargeAsCapabilityTlv(bgpconfig.getLargeASCapability())
            .setFlowSpecCapabilityTlv(flowSpecStatus)
            .setVpnFlowSpecCapabilityTlv(vpnFlowSpecStatus)
            .setFlowSpecRpdCapabilityTlv(bgpconfig.flowSpecRpdCapability()).build();
    log.debug("Sending open message to {}", channel.getRemoteAddress());
    channel.write(Collections.singletonList(msg));

}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:BgpChannelHandler.java

示例6: sendKeepAliveMessage

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
/**
 * Send keep alive message.
 *
 * @throws IOException when channel is disconnected
 * @throws BgpParseException while building keep alive message
 */
synchronized void sendKeepAliveMessage() throws IOException, BgpParseException {

    BgpMessage msg = factory4.keepaliveMessageBuilder().build();
    log.debug("Sending keepalive message to {}", channel.getRemoteAddress());
    channel.write(Collections.singletonList(msg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:BgpChannelHandler.java

示例7: mpUnReachNlriTest

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
/**
 * This testcase checks BGP update message.
 */
@Test
public void mpUnReachNlriTest() throws BgpParseException {

    // BGP flow spec  Message
    byte[] flowSpecMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
            (byte) 0xff, 0x00, 0x2b, 0x02, 0x00, 0x00, 0x00, 0x14,
            (byte) 0x90, 0x0f, 0x00, 0x10, 0x00, 0x01, (byte) 0x85,
            0x0c, 0x02, 0x20, (byte) 0xc0, (byte) 0xa8, 0x07, 0x36,
            0x03, (byte) 0x81, 0x67, 0x04, (byte) 0x81, 0x01};

    byte[] testFsMsg;
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(flowSpecMsg);

    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    BgpMessage message;
    BgpHeader bgpHeader = new BgpHeader();

    message = reader.readFrom(buffer, bgpHeader);

    assertThat(message, instanceOf(BgpUpdateMsgVer4.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testFsMsg = new byte[readLen];
    buf.readBytes(testFsMsg, 0, readLen);

    assertThat(testFsMsg, is(flowSpecMsg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:37,代码来源:MpUnReachNlriTest.java

示例8: mpReachNlriTest1

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
/**
 * This testcase checks BGP update message.
 */
@Test
public void mpReachNlriTest1() throws BgpParseException {

    // BGP flow spec Message
    byte[] flowSpecMsg = new byte[] {(byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, 0x00, 0x4a, 0x02, 0x00, 0x00, 0x00,
            0x33, 0x40, 0x01, 0x01, 0x00, 0x40, 0x02, 0x04, 0x02, 0x01,
            0x00, 0x64, (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,
            (byte) 0xc0, 0x10, 0x08, (byte) 0x80, 0x06, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, (byte) 0x90, 0x0e, 0x00, 0x12, 0x00, 0x01,
            (byte) 0x85, 0x00, 0x00, 0x0c, 0x02, 0x20, (byte) 0xc0,
            (byte) 0xa8, 0x07, 0x36, 0x03, (byte) 0x81, 0x67, 0x04,
            (byte) 0x81, 0x01 };

    byte[] testFsMsg;
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(flowSpecMsg);

    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    BgpMessage message;
    BgpHeader bgpHeader = new BgpHeader();

    message = reader.readFrom(buffer, bgpHeader);

    assertThat(message, instanceOf(BgpUpdateMsgVer4.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testFsMsg = new byte[readLen];
    buf.readBytes(testFsMsg, 0, readLen);

    assertThat(testFsMsg, is(flowSpecMsg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:MpReachNlriTest.java

示例9: mpReachNlriTest2

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
/**
 * This testcase checks BGP update message.
 */
@Test
public void mpReachNlriTest2() throws BgpParseException {

    // BGP flow spec Message
    byte[] flowSpecMsg = new byte[] {(byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
            (byte) 0xff, (byte) 0xff, 0x00, 0x52, 0x02, 0x00, 0x00, 0x00,
            0x3b, 0x40, 0x01, 0x01, 0x01, 0x40, 0x02, 0x04, 0x02, 0x01,
            0x00, (byte) 0xc8, (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00,
            0x00, (byte) 0xc0, 0x10, 0x10, (byte) 0x80, 0x06, 0x00, 0x7b,
            0x40, 0x60, 0x00, 0x00, (byte) 0x80, 0x09, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x0f, (byte) 0x90, 0x0e, 0x00, 0x12, 0x00, 0x01,
            (byte) 0x85, 0x00, 0x00, 0x0c, 0x01, 0x1e, (byte) 0xc0,
            (byte) 0xa8, 0x02, 0x00, 0x02, 0x1e, (byte) 0xc0, (byte) 0xa8,
            0x01, 0x00 };

    byte[] testFsMsg;
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(flowSpecMsg);

    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    BgpMessage message;
    BgpHeader bgpHeader = new BgpHeader();

    message = reader.readFrom(buffer, bgpHeader);

    assertThat(message, instanceOf(BgpUpdateMsgVer4.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testFsMsg = new byte[readLen];
    buf.readBytes(testFsMsg, 0, readLen);

    assertThat(testFsMsg, is(flowSpecMsg));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:42,代码来源:MpReachNlriTest.java

示例10: decode

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception {
    log.debug("MESSAGE IS RECEIVED.");
    if (!channel.isConnected()) {
        log.info("Channel is not connected.");
        return null;
    }

    HexDump.dump(buffer);

    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    List<BgpMessage> msgList = (List<BgpMessage>) ctx.getAttachment();

    if (msgList == null) {
        msgList = new LinkedList<>();
    }

    try {
        while (buffer.readableBytes() > 0) {
            buffer.markReaderIndex();
            BgpHeader bgpHeader = new BgpHeader();
            BgpMessage message = reader.readFrom(buffer, bgpHeader);
            msgList.add(message);
        }
        ctx.setAttachment(null);
        return msgList;
    } catch (Exception e) {
        log.debug("Bgp protocol message decode error");
        buffer.resetReaderIndex();
        buffer.discardReadBytes();
        ctx.setAttachment(msgList);
    }
    return null;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:35,代码来源:BgpMessageDecoder.java

示例11: processBgpMessage

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
@Override
void processBgpMessage(BgpChannelHandler h, BgpMessage m) throws IOException, BgpParseException {
    log.debug("Message received in established state " + m.getType());
    // dispatch the message
    h.restartHoldTimeoutTimer();
    h.dispatchMessage(m);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:8,代码来源:BgpChannelHandler.java

示例12: sendHandshakeOpenMessage

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
/**
 * Send handshake open message to the peer.
 *
 * @throws IOException, BgpParseException
 */
private void sendHandshakeOpenMessage() throws IOException, BgpParseException {
    int bgpId;
    BgpCfg.FlowSpec flowSpec = bgpconfig.flowSpecCapability();
    boolean flowSpecStatus = false;
    boolean vpnFlowSpecStatus = false;

    bgpId = Ip4Address.valueOf(bgpconfig.getRouterId()).toInt();

    boolean evpnCapability = bgpconfig.getEvpnCapability();

    if (flowSpec == BgpCfg.FlowSpec.IPV4) {
        flowSpecStatus = true;
    } else if (flowSpec == BgpCfg.FlowSpec.VPNV4) {
        vpnFlowSpecStatus = true;
    } else if (flowSpec == BgpCfg.FlowSpec.IPV4_VPNV4) {
        flowSpecStatus = true;
        vpnFlowSpecStatus = true;
    }

    BgpMessage msg = factory4.openMessageBuilder().setAsNumber((short) bgpconfig.getAsNumber())
            .setHoldTime(bgpconfig.getHoldTime()).setBgpId(bgpId)
            .setLsCapabilityTlv(bgpconfig.getLsCapability())
            .setLargeAsCapabilityTlv(bgpconfig.getLargeASCapability())
            .setFlowSpecCapabilityTlv(flowSpecStatus)
            .setVpnFlowSpecCapabilityTlv(vpnFlowSpecStatus)
            .setEvpnCapabilityTlv(evpnCapability)
            .setFlowSpecRpdCapabilityTlv(bgpconfig.flowSpecRpdCapability()).build();
    log.debug("Sending open message to {}", channel.getRemoteAddress());
    channel.write(Collections.singletonList(msg));

}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:37,代码来源:BgpChannelHandler.java

示例13: writeMsg

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
@Override
public void writeMsg(BgpId bgpId, BgpMessage msg) {
    this.getPeer(bgpId).sendMessage(msg);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:BgpControllerImpl.java

示例14: processBgpPacket

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
@Override
public void processBgpPacket(BgpId bgpId, BgpMessage msg) throws BgpParseException {

    BgpPeer peer = getPeer(bgpId);

    switch (msg.getType()) {
    case OPEN:
        // TODO: Process Open message
        break;
    case KEEP_ALIVE:
        // TODO: Process keepalive message
        break;
    case NOTIFICATION:
        // TODO: Process notificatoin message
        break;
    case UPDATE:
        BgpUpdateMsg updateMsg = (BgpUpdateMsg) msg;
        List<BgpValueType> pathAttr = updateMsg.bgpPathAttributes().pathAttributes();
        if (pathAttr == null) {
           log.debug("llPathAttr is null, cannot process update message");
           break;
        }
        Iterator<BgpValueType> listIterator = pathAttr.iterator();
        boolean isLinkstate = false;

        while (listIterator.hasNext()) {
            BgpValueType attr = listIterator.next();
            if (attr instanceof MpReachNlri) {
                MpReachNlri mpReach = (MpReachNlri) attr;
                if (mpReach.bgpFlowSpecNlri() == null) {
                    isLinkstate = true;
                }
            } else if (attr instanceof MpUnReachNlri) {
                MpUnReachNlri mpUnReach = (MpUnReachNlri) attr;
                if (mpUnReach.bgpFlowSpecNlri() == null) {
                    isLinkstate = true;
                }
            }
        }
        if (isLinkstate) {
            peer.buildAdjRibIn(pathAttr);
        }
        break;
    default:
        // TODO: Process other message
        break;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:49,代码来源:BgpControllerImpl.java

示例15: processBgpMessage

import org.onosproject.bgpio.protocol.BgpMessage; //导入依赖的package包/类
@Override
void processBgpMessage(BgpChannelHandler h, BgpMessage m) throws IOException, BgpParseException {
    log.debug("message received in OPENSENT state");
    // check for OPEN message
    if (m.getType() != BgpType.OPEN) {
        // When the message type is not keep alive message increment the wrong packet statistics
        h.processUnknownMsg(BgpErrorType.FINITE_STATE_MACHINE_ERROR,
                            BgpErrorType.RECEIVE_UNEXPECTED_MESSAGE_IN_OPENSENT_STATE,
                            m.getType().getType());
        log.debug("Message is not OPEN message");
    } else {
        log.debug("Sending keep alive message in OPENSENT state");
        h.bgpPacketStats.addInPacket();

        BgpOpenMsg pOpenmsg = (BgpOpenMsg) m;
        h.peerIdentifier = pOpenmsg.getBgpId();

        // validate capabilities and open msg
        if (h.openMsgValidation(h, pOpenmsg)) {
            if (h.connectionCollisionDetection(BgpPeerCfg.State.OPENCONFIRM,
                                               h.peerIdentifier, h.peerAddr)) {
                h.channel.close();
                return;
            }
            log.debug("Sending handshake OPEN message");
            h.remoteBgpCapability = pOpenmsg.getCapabilityTlv();

            /*
             * RFC 4271, section 4.2: Upon receipt of an OPEN message, a BGP speaker MUST calculate the
             * value of the Hold Timer by using the smaller of its configured Hold Time and the Hold Time
             * received in the OPEN message
             */
            h.peerHoldTime = pOpenmsg.getHoldTime();
            if (h.peerHoldTime < h.bgpconfig.getHoldTime()) {
                h.channel.getPipeline().replace("holdTime",
                                                "holdTime",
                                                new ReadTimeoutHandler(BgpPipelineFactory.TIMER,
                                                                       h.peerHoldTime));
            }

            log.info("Hold Time : " + h.peerHoldTime);

            // update AS number
            h.peerAsNum = pOpenmsg.getAsNumber();
        }

        // Send keepalive message to peer.
        h.sendKeepAliveMessage();
        h.bgpPacketStats.addOutPacket();
        h.setState(OPENCONFIRM);
        h.bgpconfig.setPeerConnState(h.peerAddr, BgpPeerCfg.State.OPENCONFIRM);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:54,代码来源:BgpChannelHandler.java


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