Search in sources :

Example 46 with BgpHeader

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

the class BgpNotificationMsgTest method bgpNotificationMessageTest1.

/**
 * Notification message with error code, error subcode and data.
 *
 * @throws BgpParseException while decoding and encoding notification message
 */
@Test
public void bgpNotificationMessageTest1() throws BgpParseException {
    byte[] notificationMsg = 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, 0x03, 0x02, 0x02, (byte) 0xfe, (byte) 0xb0 };
    byte[] testNotificationMsg = { 0 };
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(notificationMsg);
    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    BgpMessage message = null;
    BgpHeader bgpHeader = new BgpHeader();
    message = reader.readFrom(buffer, bgpHeader);
    assertThat(message, instanceOf(BgpNotificationMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testNotificationMsg = buf.array();
    int iReadLen = buf.writerIndex() - 0;
    testNotificationMsg = new byte[iReadLen];
    buf.readBytes(testNotificationMsg, 0, iReadLen);
    assertThat(testNotificationMsg, is(notificationMsg));
}
Also used : BgpHeader(org.onosproject.bgpio.types.BgpHeader) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) Test(org.junit.Test)

Example 47 with BgpHeader

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

the class BgpNotificationMsgTest method bgpNotificationMessageTest4.

/**
 * Notification message without error subcode.
 *
 * @throws BgpParseException while decoding and encoding notification message
 */
@Test(expected = BgpParseException.class)
public void bgpNotificationMessageTest4() throws BgpParseException {
    byte[] notificationMsg = 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, 0x14, 0x03, 0x02 };
    byte[] testNotificationMsg = { 0 };
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(notificationMsg);
    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    BgpMessage message = null;
    BgpHeader bgpHeader = new BgpHeader();
    message = reader.readFrom(buffer, bgpHeader);
    assertThat(message, instanceOf(BgpNotificationMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testNotificationMsg = buf.array();
    int iReadLen = buf.writerIndex() - 0;
    testNotificationMsg = new byte[iReadLen];
    buf.readBytes(testNotificationMsg, 0, iReadLen);
    assertThat(testNotificationMsg, is(notificationMsg));
}
Also used : BgpHeader(org.onosproject.bgpio.types.BgpHeader) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) Test(org.junit.Test)

Example 48 with BgpHeader

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

the class BgpNotificationMsgTest method bgpNotificationMessageTest5.

/**
 * Notification message with wrong message length.
 *
 * @throws BgpParseException while decoding and encoding notification message
 */
@Test(expected = BgpParseException.class)
public void bgpNotificationMessageTest5() throws BgpParseException {
    byte[] notificationMsg = 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, 0x14, 0x03, 0x02, 0x02 };
    byte[] testNotificationMsg = { 0 };
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(notificationMsg);
    BgpMessageReader<BgpMessage> reader = BgpFactories.getGenericReader();
    BgpMessage message = null;
    BgpHeader bgpHeader = new BgpHeader();
    message = reader.readFrom(buffer, bgpHeader);
    assertThat(message, instanceOf(BgpNotificationMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testNotificationMsg = buf.array();
    int iReadLen = buf.writerIndex() - 0;
    testNotificationMsg = new byte[iReadLen];
    buf.readBytes(testNotificationMsg, 0, iReadLen);
    assertThat(testNotificationMsg, is(notificationMsg));
}
Also used : BgpHeader(org.onosproject.bgpio.types.BgpHeader) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) Test(org.junit.Test)

Example 49 with BgpHeader

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

the class BgpOpenMsgTest method openMessageTest1.

/**
 * This test case checks open message without optional parameter.
 */
@Test
public void openMessageTest1() throws BgpParseException {
    // Open message without optional parameter
    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, 0x01, 0X04, (byte) 0xfe, 0x09, 0x00, (byte) 0xb4, (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, 0x00 };
    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 50 with BgpHeader

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

the class BgpOpenMsgTest method openMessageTest3.

/**
 * This test case checks open message with Four-octet AS number
 * capability.
 */
@Test
public void openMessageTest3() throws BgpParseException {
    // OPEN Message (Four-Octet AS number capability).
    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, 0x25, // BGPHeader
    0x01, // Version
    0X04, // AS Number
    (byte) 0x00, // AS Number
    (byte) 0xc8, // Hold Time
    0x00, // Hold Time
    (byte) 0xb4, (byte) 0xb6, (byte) 0x02, 0x5d, // BGP Identifier
    (byte) 0xc8, // Opt Parameter Length
    0x08, // Opt Parameter Length
    0x02, // Opt Parameter Length
    0x06, 0x41, 0x04, 0x00, 0x01, 0x00, // Four Octet AS Number-CAPABILITY-TLV
    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)

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