Search in sources :

Example 51 with BgpHeader

use of org.onosproject.bgpio.types.BgpHeader in project onos by opennetworkinglab.

the class BgpOpenMsgTest method openMessageTest7.

/**
 * In this test case, Invalid message length is given as input and expecting
 * an exception.
 */
@Test(expected = BgpParseException.class)
public void openMessageTest7() throws BgpParseException {
    // OPEN Message with invalid header length.
    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, 0x1e, 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));
}
Also used : BgpHeader(org.onosproject.bgpio.types.BgpHeader) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) Test(org.junit.Test)

Example 52 with BgpHeader

use of org.onosproject.bgpio.types.BgpHeader in project onos by opennetworkinglab.

the class BgpOpenMsgTest method openMessageTest8.

/**
 * 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, 0x06, 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));
}
Also used : BgpHeader(org.onosproject.bgpio.types.BgpHeader) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) Test(org.junit.Test)

Example 53 with BgpHeader

use of org.onosproject.bgpio.types.BgpHeader in project onos by opennetworkinglab.

the class BgpOpenMsgTest method openMessageTest9.

/**
 * This test case checks open message with route policy distribution capability.
 */
@Test
public void openMessageTest9() throws BgpParseException {
    // OPEN Message with capabilities.
    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, 0x3d, 0x01, 0x04, 0x00, (byte) 0xc8, 0x00, (byte) 0xb4, (byte) 0xc0, (byte) 0xa8, 0x07, 0x35, 0x20, 0x02, 0x1e, 0x01, 0x04, 00, 0x01, 0x00, 0x01, 0x41, 0x04, 0x00, 0x00, 0x00, (byte) 0xc8, 0x01, 0x04, 0x40, 0x04, 0x00, 0x47, 0x01, 0x04, 0x00, 0x01, 0x00, (byte) 0x85, (byte) 0x81, 0x04, 0x00, 0x01, (byte) 0x85, // RPD capability
    0x01 };
    byte[] testOpenMsg;
    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));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    int readLen = buf.writerIndex();
    testOpenMsg = new byte[readLen];
    buf.readBytes(testOpenMsg, 0, readLen);
    assertThat(testOpenMsg, is(openMsg));
}
Also used : BgpHeader(org.onosproject.bgpio.types.BgpHeader) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) Test(org.junit.Test)

Example 54 with BgpHeader

use of org.onosproject.bgpio.types.BgpHeader in project onos by opennetworkinglab.

the class BgpOpenMsgTest method openMessageTest6.

/**
 * 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));
}
Also used : BgpHeader(org.onosproject.bgpio.types.BgpHeader) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) Test(org.junit.Test)

Example 55 with BgpHeader

use of org.onosproject.bgpio.types.BgpHeader in project onos by opennetworkinglab.

the class BgpRouteRefreshMsgTest method routeRefreshMessageTest1.

/**
 * This test case checks BGP Route Refresh message.
 */
@Test
public void routeRefreshMessageTest1() throws BgpParseException {
    // BGP RouteRefresh Message
    byte[] rrMsg = 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, 0x05, 0x00, 0x02, 0x00, 0x01 };
    byte[] testRouteRefreshMsg;
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(rrMsg);
    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    BgpMessage message;
    BgpHeader bgpHeader = new BgpHeader();
    message = reader.readFrom(buffer, bgpHeader);
    assertThat(message, instanceOf(BgpRouteRefreshMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    int readLen = buf.writerIndex();
    testRouteRefreshMsg = new byte[readLen];
    buf.readBytes(testRouteRefreshMsg, 0, readLen);
    assertThat(testRouteRefreshMsg, is(rrMsg));
}
Also used : BgpHeader(org.onosproject.bgpio.types.BgpHeader) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) Test(org.junit.Test)

Aggregations

BgpHeader (org.onosproject.bgpio.types.BgpHeader)84 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)83 Test (org.junit.Test)83 BgpValueType (org.onosproject.bgpio.types.BgpValueType)33 LinkedList (java.util.LinkedList)27 BgpPathAttributes (org.onosproject.bgpio.protocol.ver4.BgpPathAttributes)26 AsPath (org.onosproject.bgpio.types.AsPath)26 MpReachNlri (org.onosproject.bgpio.types.MpReachNlri)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 LinkStateAttributes (org.onosproject.bgpio.types.LinkStateAttributes)23 IpPrefix (org.onlab.packet.IpPrefix)22 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 BgpAttrNodeMultiTopologyId (org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId)4