本文整理汇总了Java中org.onosproject.bgpio.protocol.BgpUpdateMsg类的典型用法代码示例。如果您正苦于以下问题:Java BgpUpdateMsg类的具体用法?Java BgpUpdateMsg怎么用?Java BgpUpdateMsg使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BgpUpdateMsg类属于org.onosproject.bgpio.protocol包,在下文中一共展示了BgpUpdateMsg类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processBgpPacket
import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的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: readFrom
import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
@Override
public BgpUpdateMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
throws BgpParseException {
if (cb.readableBytes() != (bgpHeader.getLength() - MINIMUM_COMMON_HEADER_LENGTH)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.BAD_MESSAGE_LENGTH, bgpHeader.getLength());
}
LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
LinkedList<IpPrefix> nlri = new LinkedList<>();
BgpPathAttributes bgpPathAttributes = new BgpPathAttributes();
// Reading Withdrawn Routes Length
Short withDrwLen = cb.readShort();
if (cb.readableBytes() < withDrwLen) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
cb.readableBytes());
}
ChannelBuffer tempCb = cb.readBytes(withDrwLen);
if (withDrwLen != 0) {
// Parsing WithdrawnRoutes
withDrwRoutes = parseWithdrawnRoutes(tempCb);
}
if (cb.readableBytes() < MIN_LEN_AFTER_WITHDRW_ROUTES) {
log.debug("Bgp Path Attribute len field not present");
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
// Reading Total Path Attribute Length
short totPathAttrLen = cb.readShort();
int len = withDrwLen + totPathAttrLen + PACKET_MINIMUM_LENGTH;
if (len > bgpHeader.getLength()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
if (totPathAttrLen != 0) {
// Parsing BGPPathAttributes
if (cb.readableBytes() < totPathAttrLen) {
Validation
.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
cb.readableBytes());
}
tempCb = cb.readBytes(totPathAttrLen);
bgpPathAttributes = BgpPathAttributes.read(tempCb);
}
if (cb.readableBytes() > 0) {
// Parsing NLRI
nlri = parseNlri(cb);
}
return new BgpUpdateMsgVer4(bgpHeader, withDrwRoutes,
bgpPathAttributes, nlri);
}
示例3: build
import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
@Override
public BgpUpdateMsg build() {
BgpHeader bgpMsgHeader = DEFAULT_UPDATE_HEADER;
return new BgpUpdateMsgVer4(bgpMsgHeader, withdrawnRoutes, bgpPathAttributes, nlri);
}
示例4: updateMessageBuilder
import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
@Override
public BgpUpdateMsg.Builder updateMessageBuilder() {
return new BgpUpdateMsgVer4.Builder();
}
示例5: processBgpPacket
import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的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;
}
}
示例6: readFrom
import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
@Override
public BgpUpdateMsg readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
throws BgpParseException {
if (cb.readableBytes() != (bgpHeader.getLength() - MINIMUM_COMMON_HEADER_LENGTH)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.BAD_MESSAGE_LENGTH, bgpHeader.getLength());
}
LinkedList<IpPrefix> withDrwRoutes = new LinkedList<>();
LinkedList<IpPrefix> nlri = new LinkedList<>();
BgpPathAttributes bgpPathAttributes = new BgpPathAttributes();
Short withDrwLen = cb.readShort();
if (cb.readableBytes() < withDrwLen) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
cb.readableBytes());
}
log.debug("Reading withdrawn routes length");
ChannelBuffer tempCb = cb.readBytes(withDrwLen);
if (withDrwLen != 0) {
// Parsing WithdrawnRoutes
withDrwRoutes = parseWithdrawnRoutes(tempCb);
log.debug("Withdrawn routes parsed");
}
if (cb.readableBytes() < MIN_LEN_AFTER_WITHDRW_ROUTES) {
log.debug("Bgp path attribute len field not present");
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
// Reading Total Path Attribute Length
short totPathAttrLen = cb.readShort();
int len = withDrwLen + totPathAttrLen + PACKET_MINIMUM_LENGTH;
if (len > bgpHeader.getLength()) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MALFORMED_ATTRIBUTE_LIST, null);
}
log.debug("Total path attribute length read");
if (totPathAttrLen != 0) {
// Parsing BGPPathAttributes
if (cb.readableBytes() < totPathAttrLen) {
Validation
.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.MALFORMED_ATTRIBUTE_LIST,
cb.readableBytes());
}
tempCb = cb.readBytes(totPathAttrLen);
bgpPathAttributes = BgpPathAttributes.read(tempCb);
}
if (cb.readableBytes() > 0) {
// Parsing NLRI
nlri = parseNlri(cb);
}
return new BgpUpdateMsgVer4(bgpHeader, withDrwRoutes,
bgpPathAttributes, nlri);
}
示例7: processRoute
import org.onosproject.bgpio.protocol.BgpUpdateMsg; //导入依赖的package包/类
/**
* Notify that got an update message and operate route.
*
* @param bgpId bgp identifier
* @param msg BGP update message
*/
void processRoute(BgpId bgpId, BgpUpdateMsg msg);