本文整理匯總了Java中org.onosproject.bgpio.protocol.BgpMessage.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java BgpMessage.getType方法的具體用法?Java BgpMessage.getType怎麽用?Java BgpMessage.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.onosproject.bgpio.protocol.BgpMessage
的用法示例。
在下文中一共展示了BgpMessage.getType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
}
示例2: 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);
}
}
示例3: 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;
boolean isEvpn = false;
while (listIterator.hasNext()) {
BgpValueType attr = listIterator.next();
if (attr instanceof MpReachNlri) {
MpReachNlri mpReach = (MpReachNlri) attr;
if (mpReach.bgpFlowSpecNlri() == null
&& mpReach.bgpEvpnNlri() == null) {
isLinkstate = true;
}
if (mpReach.bgpEvpnNlri() != null) {
isEvpn = true;
}
} else if (attr instanceof MpUnReachNlri) {
MpUnReachNlri mpUnReach = (MpUnReachNlri) attr;
if (mpUnReach.bgpFlowSpecNlri() == null
&& mpUnReach.bgpEvpnNlri() == null) {
isLinkstate = true;
}
if (mpUnReach.bgpEvpnNlri() != null) {
isEvpn = true;
}
}
}
if (isLinkstate) {
peer.buildAdjRibIn(pathAttr);
}
if (isEvpn) {
for (BgpRouteListener listener : bgpRouteListener) {
listener.processRoute(bgpId, updateMsg);
}
}
break;
default:
// TODO: Process other message
break;
}
}
示例4: 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();
h.minHoldTime = (short) Math.min(h.bgpconfig.getHoldTime(), pOpenmsg.getHoldTime());
h.restartHoldTimeoutTimer();
log.info("Hold Time : " + h.minHoldTime);
// 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);
}
}