本文整理汇总了Java中org.onosproject.bgpio.exceptions.BgpParseException类的典型用法代码示例。如果您正苦于以下问题:Java BgpParseException类的具体用法?Java BgpParseException怎么用?Java BgpParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BgpParseException类属于org.onosproject.bgpio.exceptions包,在下文中一共展示了BgpParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* Reads the BGP link attributes Opaque link attribute.
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrOpaqLnkAttrib
* @throws BgpParseException while parsing BgpLinkAttrOpaqLnkAttrib
*/
public static BgpLinkAttrOpaqLnkAttrib read(ChannelBuffer cb)
throws BgpParseException {
byte[] opaqueLinkAttribute;
short lsAttrLength = cb.readShort();
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
opaqueLinkAttribute = new byte[lsAttrLength];
cb.readBytes(opaqueLinkAttribute);
return BgpLinkAttrOpaqLnkAttrib.of(opaqueLinkAttribute);
}
示例2: read
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* Reads the IPv4 Router-ID.
*
* @param cb ChannelBuffer
* @param sType tag type
* @return object of BgpAttrRouterIdV4
* @throws BgpParseException while parsing BgpAttrRouterIdV4
*/
public static BgpAttrRouterIdV4 read(ChannelBuffer cb, short sType)
throws BgpParseException {
short lsAttrLength = cb.readShort();
if ((lsAttrLength != 4) || (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
byte[] ipBytes = new byte[lsAttrLength];
cb.readBytes(ipBytes, 0, lsAttrLength);
Ip4Address ip4RouterId = Ip4Address.valueOf(ipBytes);
return BgpAttrRouterIdV4.of(ip4RouterId, sType);
}
示例3: read
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* Reads the BGP link attributes MPLS protocol mask.
*
* @param cb Channel buffer
* @return object of type BgpLinkAttrMPLSProtocolMask
* @throws BgpParseException while parsing BgpLinkAttrMplsProtocolMask
*/
public static BgpLinkAttrMplsProtocolMask read(ChannelBuffer cb)
throws BgpParseException {
boolean bLdp = false;
boolean bRsvpTe = false;
short lsAttrLength = cb.readShort();
if ((lsAttrLength != MASK_BYTE_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
byte flags = cb.readByte();
bLdp = ((flags & (byte) FIRST_BIT) == FIRST_BIT);
bRsvpTe = ((flags & (byte) SECOND_BIT) == SECOND_BIT);
return BgpLinkAttrMplsProtocolMask.of(bLdp, bRsvpTe);
}
示例4: getValue
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* Returns RouteType.
*
* @return RouteType
* @throws BgpParseException if routeType is not matched
*/
public RouteType getValue() throws BgpParseException {
switch (routeType) {
case INTRA_AREA_TYPE:
return RouteType.Intra_Area;
case INTER_AREA_TYPE:
return RouteType.Inter_Area;
case EXTERNAL_TYPE_1:
return RouteType.External_1;
case EXTERNAL_TYPE_2:
return RouteType.External_2;
case NSSA_TYPE_1:
return RouteType.NSSA_1;
case NSSA_TYPE_2:
return RouteType.NSSA_2;
default:
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
}
}
示例5: read
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* Reads the Prefix Metric.
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrMetric
* @throws BgpParseException while parsing BgpPrefixAttrMetric
*/
public static BgpPrefixAttrMetric read(ChannelBuffer cb)
throws BgpParseException {
int linkPfxMetric;
short lsAttrLength = cb.readShort(); // 4 Bytes
if ((lsAttrLength != ATTR_PREFIX_LEN)
|| (cb.readableBytes() < lsAttrLength)) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
linkPfxMetric = cb.readInt();
return BgpPrefixAttrMetric.of(linkPfxMetric);
}
示例6: bgpUpdateMessageTest25
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* In this test case, Invalid origin value is given as input and expecting
* an exception.
*/
@Test(expected = BgpParseException.class)
public void bgpUpdateMessageTest25() throws BgpParseException {
byte[] updateMsg = 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, 0x29, 0x02, 0x00, 0x00, //withdrawn len
0x00, 0x12, //path attribute len
0x04, 0x01, 0x01, 0x04, //origin
0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
(byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00}; //med
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(updateMsg);
BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
BgpMessage message;
BgpHeader bgpHeader = new BgpHeader();
message = reader.readFrom(buffer, bgpHeader);
assertThat(message, instanceOf(BgpUpdateMsg.class));
}
示例7: openMsgValidation
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* BGP open message validation.
*
* @param h channel handler
* @param openMsg open message
* @return true if valid message, otherwise false
* @throws BgpParseException throw exception
*/
public boolean openMsgValidation(BgpChannelHandler h, BgpOpenMsg openMsg) throws BgpParseException {
boolean result;
// Validate BGP ID
result = bgpIdValidation(openMsg);
if (!result) {
throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.BAD_BGP_IDENTIFIER, null);
}
// Validate AS number
result = asNumberValidation(h, openMsg);
if (!result) {
throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.BAD_PEER_AS, null);
}
// Validate hold timer
if ((openMsg.getHoldTime() != 0) && (openMsg.getHoldTime() < BGP_MIN_HOLDTIME)) {
throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.UNACCEPTABLE_HOLD_TIME, null);
}
// Validate capabilities
result = capabilityValidation(h, openMsg);
return result;
}
示例8: decisionProcess
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* Update VPN local RIB .
*
* @param nlri NLRI to update
* @param routeDistinguisher VPN id to update
* @throws BgpParseException BGP parse exception
*/
public void decisionProcess(BgpLSNlri nlri, RouteDistinguisher routeDistinguisher) throws BgpParseException {
checkNotNull(nlri);
if (nlri instanceof BgpNodeLSNlriVer4) {
if (vpnNodeTree.containsKey(routeDistinguisher)) {
selectionProcessNode(nlri, true);
if (nodeTree.size() == 0) {
vpnNodeTree.remove(routeDistinguisher);
}
}
} else if (nlri instanceof BgpLinkLsNlriVer4) {
if (vpnLinkTree.containsKey(routeDistinguisher)) {
selectionProcessLink(nlri, true);
if (linkTree.size() == 0) {
vpnLinkTree.remove(routeDistinguisher);
}
}
} else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
if (vpnPrefixTree.containsKey(routeDistinguisher)) {
selectionProcessPrefix(nlri, true);
if (prefixTree.size() == 0) {
vpnPrefixTree.remove(routeDistinguisher);
}
}
}
}
示例9: add
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
@Override
public void add(BgpSessionInfo sessionInfo, BgpLSNlri nlri, PathAttrNlriDetails details,
RouteDistinguisher routeDistinguisher) throws BgpParseException {
add(sessionInfo, nlri, details);
if (nlri instanceof BgpNodeLSNlriVer4) {
if (!vpnNodeTree.containsKey(routeDistinguisher)) {
vpnNodeTree.put(routeDistinguisher, nodeTree);
}
} else if (nlri instanceof BgpLinkLsNlriVer4) {
if (!vpnLinkTree.containsKey(routeDistinguisher)) {
vpnLinkTree.put(routeDistinguisher, linkTree);
}
} else if (nlri instanceof BgpPrefixIPv4LSNlriVer4) {
if (!vpnPrefixTree.containsKey(routeDistinguisher)) {
vpnPrefixTree.put(routeDistinguisher, prefixTree);
}
}
}
示例10: read
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* Reads the Opaque Prefix Attribute.
*
* @param cb ChannelBuffer
* @return object of BgpPrefixAttrOpaqueData
* @throws BgpParseException while parsing BgpPrefixAttrOpaqueData
*/
public static BgpPrefixAttrOpaqueData read(ChannelBuffer cb)
throws BgpParseException {
byte[] opaquePrefixAttribute;
short lsAttrLength = cb.readShort();
opaquePrefixAttribute = new byte[lsAttrLength];
if (cb.readableBytes() < lsAttrLength) {
Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
BgpErrorType.ATTRIBUTE_LENGTH_ERROR,
lsAttrLength);
}
cb.readBytes(opaquePrefixAttribute);
return BgpPrefixAttrOpaqueData.of(opaquePrefixAttribute);
}
示例11: write
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
@Override
public void write(ChannelBuffer cb, BgpNotificationMsgVer4 message) throws BgpParseException {
int msgStartIndex = cb.writerIndex();
int headerLenIndex = message.bgpHeader.write(cb);
if (headerLenIndex <= 0) {
throw new BgpParseException(BgpErrorType.MESSAGE_HEADER_ERROR, (byte) 0, null);
}
cb.writeByte(message.errorCode);
cb.writeByte(message.errorSubCode);
if (message.data != null) {
cb.writeBytes(message.data);
}
//Update message length field in notification message
int length = cb.writerIndex() - msgStartIndex;
cb.setShort(headerLenIndex, (short) length);
message.bgpHeader.setLength((short) length);
}
示例12: bgpUpdateMessageTest11
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* In this test case, update message with incorrect path attribute length is given as input and expecting
* an exception.
*/
@Test(expected = BgpParseException.class)
public void bgpUpdateMessageTest11() throws BgpParseException {
byte[] updateMsg = 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, 0x1b, 0x02, 0x00, 0x04, 0x18, 0x0a, 0x01, 0x01, 0x00, 0x01};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(updateMsg);
BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
BgpMessage message;
BgpHeader bgpHeader = new BgpHeader();
message = reader.readFrom(buffer, bgpHeader);
assertThat(message, instanceOf(BgpUpdateMsg.class));
}
示例13: openMessageTest8
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* In this test case, Invalid message type is given as input and expecting
* an exception.
*/
@Test(expected = BgpParseException.class)
public void openMessageTest8() throws BgpParseException {
// OPEN Message with invalid message type.
byte[] openMsg = 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, 0x1d, 0x05, 0X04,
(byte) 0xfe, 0x09, 0x00, (byte) 0xb4, (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, 0x00 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(openMsg);
BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
BgpMessage message;
BgpHeader bgpHeader = new BgpHeader();
message = reader.readFrom(buffer, bgpHeader);
assertThat(message, instanceOf(BgpOpenMsg.class));
}
示例14: bgpUpdateMessageTest04
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* In this test case, Invalid message type is given as input and expecting
* an exception.
*/
@Test(expected = BgpParseException.class)
public void bgpUpdateMessageTest04() throws BgpParseException {
byte[] updateMsg = 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, 0x17, 0x06, 0x00, 0x00, 0x00, 0x00};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(updateMsg);
BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
BgpMessage message;
BgpHeader bgpHeader = new BgpHeader();
message = reader.readFrom(buffer, bgpHeader);
assertThat(message, instanceOf(BgpUpdateMsg.class));
}
示例15: openMessageTest6
import org.onosproject.bgpio.exceptions.BgpParseException; //导入依赖的package包/类
/**
* In this test case, Marker is set as 0 in input and expecting
* an exception.
*/
@Test(expected = BgpParseException.class)
public void openMessageTest6() throws BgpParseException {
// OPEN Message with marker set to 0.
byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0x00, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, (byte) 0xff,
0x00, 0x00, 0x1d, 0x01, 0X04,
(byte) 0xfe, 0x09, 0x00, (byte) 0xb4,
(byte) 0xc0, (byte) 0xa8, 0x00, 0x0f,
0x00};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(openMsg);
BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
BgpMessage message;
BgpHeader bgpHeader = new BgpHeader();
message = reader.readFrom(buffer, bgpHeader);
assertThat(message, instanceOf(BgpOpenMsg.class));
}