Search in sources :

Example 26 with OriginType

use of org.onosproject.bgpio.types.Origin.OriginType 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));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) Origin(org.onosproject.bgpio.types.Origin) OriginType(org.onosproject.bgpio.types.Origin.OriginType) NextHop(org.onosproject.bgpio.types.NextHop) BgpHeader(org.onosproject.bgpio.types.BgpHeader) LinkedList(java.util.LinkedList) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) IpPrefix(org.onlab.packet.IpPrefix) AsPath(org.onosproject.bgpio.types.AsPath) BgpPathAttributes(org.onosproject.bgpio.protocol.ver4.BgpPathAttributes) As4Path(org.onosproject.bgpio.types.As4Path) Test(org.junit.Test)

Aggregations

LinkedList (java.util.LinkedList)26 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)26 Test (org.junit.Test)26 BgpPathAttributes (org.onosproject.bgpio.protocol.ver4.BgpPathAttributes)26 AsPath (org.onosproject.bgpio.types.AsPath)26 BgpHeader (org.onosproject.bgpio.types.BgpHeader)26 BgpValueType (org.onosproject.bgpio.types.BgpValueType)26 Origin (org.onosproject.bgpio.types.Origin)26 OriginType (org.onosproject.bgpio.types.Origin.OriginType)26 Med (org.onosproject.bgpio.types.Med)25 ProtocolType (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType)24 MpReachNlri (org.onosproject.bgpio.types.MpReachNlri)23 IpPrefix (org.onlab.packet.IpPrefix)21 LinkStateAttributes (org.onosproject.bgpio.types.LinkStateAttributes)20 Ip4Address (org.onlab.packet.Ip4Address)12 NodeDescriptors (org.onosproject.bgpio.protocol.linkstate.NodeDescriptors)4 AutonomousSystemTlv (org.onosproject.bgpio.types.AutonomousSystemTlv)4 BgpLSIdentifierTlv (org.onosproject.bgpio.types.BgpLSIdentifierTlv)4 IsIsNonPseudonode (org.onosproject.bgpio.types.IsIsNonPseudonode)4 BgpNodeLSIdentifier (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier)2