use of org.onosproject.bgpio.protocol.ver4.BgpPathAttributes in project onos by opennetworkinglab.
the class BgpUpdateMsgTest method bgpUpdateMessageTest30.
/**
* This test case checks update message with as4 path attribute.
*/
@Test
public void bgpUpdateMessageTest30() 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, 0x3a, 0x02, 0x00, 0x00, 0x00, 0x21, 0x40, 0x01, 0x01, 0x00, (byte) 0xc0, 0x11, 0x0a, 0x02, 0x02, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x28, 0x00, 0x01, 0x40, 0x02, 0x06, 0x02, 0x02, 0x5b, (byte) 0xa0, 0x5b, (byte) 0xa0, 0x40, 0x03, 0x04, (byte) 0xac, 0x10, 0x03, 0x01, 0x08, 0x28 };
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(updateMsg);
BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
BgpMessage message = null;
BgpHeader bgpHeader = new BgpHeader();
message = reader.readFrom(buffer, bgpHeader);
assertThat(message, instanceOf(BgpUpdateMsg.class));
BgpUpdateMsg other = (BgpUpdateMsg) message;
assertThat(other.getHeader().getMarker(), is(MARKER));
assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
assertThat(other.getHeader().getLength(), is((short) 58));
BgpValueType testPathAttribute;
Origin origin;
As4Path as4Path;
AsPath asPath;
NextHop nextHop;
List<BgpValueType> pathAttributes = new LinkedList<>();
BgpPathAttributes actualpathAttribute = other.bgpPathAttributes();
pathAttributes = actualpathAttribute.pathAttributes();
ListIterator<BgpValueType> listIterator = pathAttributes.listIterator();
OriginType originValue = OriginType.IGP;
testPathAttribute = listIterator.next();
origin = (Origin) testPathAttribute;
assertThat(origin.origin(), is(originValue));
testPathAttribute = listIterator.next();
as4Path = (As4Path) testPathAttribute;
ListIterator<Integer> listIterator2 = as4Path.as4PathSeq().listIterator();
assertThat(listIterator2.next(), is(655361));
testPathAttribute = listIterator.next();
asPath = (AsPath) testPathAttribute;
ListIterator<Short> listIterator3 = asPath.asPathSeq().listIterator();
assertThat(listIterator3.next(), is((short) 23456));
testPathAttribute = listIterator.next();
nextHop = (NextHop) testPathAttribute;
byte[] nextHopAddr = new byte[] { (byte) 0xac, 0x10, 0x03, 0x01 };
assertThat(nextHop.nextHop().toOctets(), is(nextHopAddr));
ListIterator<IpPrefix> listIterator1 = other.nlri().listIterator();
byte[] prefix = new byte[] { 0x28, 0x00, 0x00, 0x00 };
IpPrefix testPrefixValue = listIterator1.next();
assertThat(testPrefixValue.prefixLength(), is((int) 8));
assertThat(testPrefixValue.address().toOctets(), is(prefix));
}
Aggregations