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


Java BgpId类代码示例

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


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

示例1: disconnectPeer

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
@Override
public boolean disconnectPeer(String routerid) {
    BgpPeerCfg lspeer = this.bgpPeerTree.get(routerid);

    if (lspeer != null) {

        BgpPeer disconnPeer = peerManager.getPeer(BgpId.bgpId(IpAddress.valueOf(routerid)));
        if (disconnPeer != null) {
            // TODO: send notification peer deconfigured
            disconnPeer.disconnectPeer();
        } else if (lspeer.connectPeer() != null) {
            lspeer.connectPeer().disconnectPeer();
        }
        lspeer.setState(BgpPeerCfg.State.IDLE);
        lspeer.setSelfInnitConnection(false);
        log.debug("Disconnected : " + routerid + " successfully");

        return true;
    } else {
        log.debug("Did not find : " + routerid);
        return false;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:BgpConfig.java

示例2: closeConnectedPeers

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
@Override
public void closeConnectedPeers() {
    BgpPeer bgpPeer;
    for (BgpId id : this.connectedPeers.keySet()) {
        bgpPeer = getPeer(id);
        bgpPeer.disconnectPeer();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:BgpControllerImpl.java

示例3: addConnectedPeer

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
@Override
public boolean addConnectedPeer(BgpId bgpId, BgpPeer bgpPeer) {

    if (connectedPeers.get(bgpId) != null) {
        this.log.error("Trying to add connectedPeer but found previous " + "value for bgp ip: {}",
                       bgpId.toString());
        return false;
    } else {
        this.log.debug("Added Peer {}", bgpId.toString());
        connectedPeers.put(bgpId, bgpPeer);
        return true;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:BgpControllerImpl.java

示例4: isPeerConnected

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
@Override
public boolean isPeerConnected(BgpId bgpId) {
    if (connectedPeers.get(bgpId) == null) {
        this.log.error("Is peer connected: bgpIp {}.", bgpId.toString());
        return false;
    }

    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:BgpControllerImpl.java

示例5: BgpSessionInfoImpl

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
/**
 * Initialize session info.
 *
 *@param remoteBgpId remote peer id
 *@param remoteBgpVersion remote peer version
 *@param remoteBgpASNum remote peer AS number
 *@param remoteBgpholdTime remote peer hold time
 *@param remoteBgpIdentifier remote peer identifier
 *@param negotiatedholdTime negotiated hold time
 *@param isIbgpSession session type ibgp/ebgp
 *@param remoteBgpCapability remote peer capabilities
 */
public BgpSessionInfoImpl(BgpId remoteBgpId, BgpVersion remoteBgpVersion, long remoteBgpASNum,
                          short remoteBgpholdTime, int remoteBgpIdentifier, short negotiatedholdTime,
                          boolean isIbgpSession, List<BgpValueType> remoteBgpCapability) {
    this.remoteBgpId = remoteBgpId;
    this.remoteBgpVersion = remoteBgpVersion;
    this.remoteBgpASNum = remoteBgpASNum;
    this.remoteBgpholdTime = remoteBgpholdTime;
    this.remoteBgpIdentifier = remoteBgpIdentifier;
    this.negotiatedholdTime = negotiatedholdTime;
    this.isIbgpSession = isIbgpSession;
    this.remoteBgpCapability = remoteBgpCapability;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:BgpSessionInfoImpl.java

示例6: testBgpUpdateMessage1

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
/**
 * Peer1 has Node NLRI (MpReach).
 */
@Test
public void testBgpUpdateMessage1() throws InterruptedException {
    // Initiate the connections
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;

    short afi = 16388;
    byte res = 0;
    byte safi = 71;

    bgpControllerImpl.getConfig().setLsCapability(true);
    BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
    peer1.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.9", 0));
    TimeUnit.MILLISECONDS.sleep(1000);

    //Get peer1
    BgpId bgpId = new BgpId(IpAddress.valueOf("127.0.0.9"));
    BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);

    LinkedList<BgpValueType> subTlvs = new LinkedList<>();
    BgpValueType tlv = AutonomousSystemTlv.of(2478);
    subTlvs.add(tlv);
    tlv = BgpLSIdentifierTlv.of(33686018);
    subTlvs.add(tlv);
    NodeDescriptors nodeDes = new NodeDescriptors(subTlvs, (short) 0x10, (short) 256);
    BgpNodeLSIdentifier key = new BgpNodeLSIdentifier(nodeDes);
    AdjRibIn adj = peer.adjRib();

    //In Adj-RIB, nodeTree should contains specified key
    assertThat(adj.nodeTree().containsKey(key), is(true));

    BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRib();
    //In Local-RIB, nodeTree should contains specified key
    assertThat(obj.nodeTree().containsKey(key), is(true));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:BgpControllerImplTest.java

示例7: getPeer

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
BgpPeer getPeer(DeviceId deviceId) {
    Device d = deviceService.getDevice(deviceId);
    Annotations a = d != null ? d.annotations() : null;
    String ipAddress = a.value(FLOW_PEER);
    BgpId bgpId = BgpId.bgpId(IpAddress.valueOf(ipAddress));
    BgpPeer peer = bgpController.getPeer(bgpId);
    return peer;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:BgpcepFlowRuleProvider.java

示例8: getPeer

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
@Override
public BgpPeer getPeer(BgpId bgpId) {
    return this.connectedPeers.get(bgpId);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:BgpControllerImpl.java

示例9: writeMsg

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

示例10: processBgpPacket

import org.onosproject.bgp.controller.BgpId; //导入依赖的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

示例11: removeConnectedPeer

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
@Override
public void removeConnectedPeer(BgpId bgpId) {
    connectedPeers.remove(bgpId);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:BgpControllerImpl.java

示例12: connectedPeers

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
@Override
public ConcurrentHashMap<BgpId, BgpPeer> connectedPeers() {
    return connectedPeers;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:BgpControllerImpl.java

示例13: processBgpMessage

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
@Override
void processBgpMessage(BgpChannelHandler h, BgpMessage m) throws IOException, BgpParseException {
    log.debug("Message received in OPENCONFIRM state");
    // check for keep alive message
    if (m.getType() != BgpType.KEEP_ALIVE) {
        // When the message type is not keep alive message handle the wrong packet
        h.processUnknownMsg(BgpErrorType.FINITE_STATE_MACHINE_ERROR,
                            BgpErrorType.RECEIVE_UNEXPECTED_MESSAGE_IN_OPENCONFIRM_STATE,
                            m.getType().getType());
        log.debug("Message is not KEEPALIVE message");
    } else {

        // Set the peer connected status
        h.bgpPacketStats.addInPacket();
        log.debug("Sending keep alive message in OPENCONFIRM state");

        final InetSocketAddress inetAddress = (InetSocketAddress) h.address;
        h.thisbgpId = BgpId.bgpId(IpAddress.valueOf(inetAddress.getAddress()));

        // set session parameters
        h.negotiatedHoldTime = (h.peerHoldTime < h.bgpconfig.getHoldTime()) ? h.peerHoldTime
                                                                            : h.bgpconfig.getHoldTime();
        h.sessionInfo = new BgpSessionInfoImpl(h.thisbgpId, h.bgpVersion, h.peerAsNum, h.peerHoldTime,
                                               h.peerIdentifier, h.negotiatedHoldTime, h.isIbgpSession,
                                               h.remoteBgpCapability);

        h.bgpPeer = h.peerManager.getBgpPeerInstance(h.bgpController, h.sessionInfo, h.bgpPacketStats);
        // set the status of bgp as connected
        h.bgpPeer.setConnected(true);
        h.bgpPeer.setChannel(h.channel);

        /*
         * RFC 4271, When an OPEN message is received, sends a KEEPALIVE message, If the negotiated hold
         * time value is zero, then the HoldTimer and KeepaliveTimer are not started. A reasonable maximum
         * time between KEEPALIVE messages would be one third of the Hold Time interval.
         */

        if (h.negotiatedHoldTime != 0) {
            h.keepAliveTimer = new BgpKeepAliveTimer(h,
                                                    (h.negotiatedHoldTime / BGP_MAX_KEEPALIVE_INTERVAL));
        } else {
            h.sendKeepAliveMessage();
        }

        h.bgpPacketStats.addOutPacket();

        // set the state handshake completion.
        h.setHandshakeComplete(true);

        if (!h.peerManager.addConnectedPeer(h.thisbgpId, h.bgpPeer)) {
            disconnectDuplicate(h);
        } else {
            h.setState(ESTABLISHED);
            h.bgpconfig.setPeerConnState(h.peerAddr, BgpPeerCfg.State.ESTABLISHED);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:58,代码来源:BgpChannelHandler.java

示例14: channelConnected

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {

    channel = e.getChannel();
    log.info("BGP connected from {}", channel.getRemoteAddress());

    address = channel.getRemoteAddress();
    if (!(address instanceof InetSocketAddress)) {
        throw new IOException("Invalid peer connection.");
    }

    // Connection should establish only if local ip and Autonomous system number is configured.
    if (bgpconfig.getState() != BgpCfg.State.IP_AS_CONFIGURED) {
        sendNotification(BgpErrorType.CEASE, BgpErrorType.CONNECTION_REJECTED, null);
        channel.close();
        log.info("BGP local AS and router ID not configured");
        return;
    }

    inetAddress = (InetSocketAddress) address;
    peerAddr = IpAddress.valueOf(inetAddress.getAddress()).toString();

    // if peer is not configured disconnect session
    if (!bgpconfig.isPeerConfigured(peerAddr)) {
        log.debug("Peer is not configured {}", peerAddr);
        sendNotification(BgpErrorType.CEASE, BgpErrorType.CONNECTION_REJECTED, null);
        channel.close();
        return;
    }

    // if connection is already established close channel
    if (peerManager.isPeerConnected(BgpId.bgpId(IpAddress.valueOf(peerAddr)))) {
        log.debug("Duplicate connection received, peer {}", peerAddr);
        channel.close();
        return;
    }

    if (null != channel.getPipeline().get("PassiveHandler")) {
        log.info("BGP handle connection request from peer");
        // Wait for open message from bgp peer
        setState(ChannelState.OPENWAIT);
    } else if (null != channel.getPipeline().get("ActiveHandler")) {
        log.info("BGP handle connection response from peer");

        sendHandshakeOpenMessage();
        bgpPacketStats.addOutPacket();
        setState(ChannelState.OPENSENT);
        bgpconfig.setPeerConnState(peerAddr, BgpPeerCfg.State.OPENSENT);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:51,代码来源:BgpChannelHandler.java

示例15: remoteBgpId

import org.onosproject.bgp.controller.BgpId; //导入依赖的package包/类
@Override
public BgpId remoteBgpId() {
    return remoteBgpId;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:5,代码来源:BgpSessionInfoImpl.java


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