Java Code Examples for org.jboss.netty.buffer.ChannelBuffers#dynamicBuffer()

The following examples show how to use org.jboss.netty.buffer.ChannelBuffers#dynamicBuffer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BgpUpdateMsgTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * In this test case, update message without path attribute is given as input and expecting
 * an exception.
 */
@Test(expected = BgpParseException.class)
public void bgpUpdateMessageTest10() 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, 0x1a, 0x02, 0x00, 0x04, 0x18, 0x0a, 0x01, 0x01, 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));
}
 
Example 2
Source File: PcepReportMsgTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * This test case checks for SRP Object,LSP Object,ERO Object,Metric-list,RRO Object
 * in PcRpt message.
 */
@Test
public void reportMessageTest19() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6C,
            0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
            0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
            0x07, 0x10, 0x00, 0x14, //ERO Object
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
            0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
            0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
            0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};

    byte[] testReportMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepReportMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testReportMsg = new byte[readLen];
    buf.readBytes(testReportMsg, 0, readLen);

    assertThat(testReportMsg, is(reportMsg));
}
 
Example 3
Source File: PcepLSReportMsgTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * This test case checks for LS Object (Routing Universe TLV,Local Node Descriptors TLV)
 * in PcLSRpt message.
 */
@Test
public void lsReportMessageTest8() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, 0x24, // common header
            (byte) 0xE0, 0x10, 0x00, 0x20, // LS Object Header
            0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
            (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
            0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x01,
            (byte) 0xFF, 0x02, 0x00, 0x00 // Local Node Descriptors TLV
    };

    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(lsReportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    byte[] testReportMsg = {0};
    assertThat(message, instanceOf(PcepLSReportMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testReportMsg = new byte[readLen];
    buf.readBytes(testReportMsg, 0, readLen);

    assertThat(testReportMsg, is(lsReportMsg));
}
 
Example 4
Source File: PcepErrorMsgTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * This test case checks for
 * RP Object, PCEP-ERROR Object
 * in PcepErrorMsg message.
 */
@Test
public void errorMessageTest12() throws PcepParseException, PcepOutOfBoundMessageException {

    //RP Object, PCEP-ERROR Object
    byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header
            0x02, 0x10, 0x00, 0x0C, // RP Object Header
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
            0x00, 0x00, 0x01, 0x01};

    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(errorMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    byte[] testErrorMsg = {0};
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    assertThat(message, instanceOf(PcepErrorMsg.class));
    message.writeTo(buf);
    int iReadLen = buf.writerIndex();
    testErrorMsg = new byte[iReadLen];
    buf.readBytes(testErrorMsg, 0, iReadLen);

    assertThat(testErrorMsg, is(errorMsg));
}
 
Example 5
Source File: PcepUpdateMsgExtTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * This test case is for SRP object, LSP object, ERO object,LSPA
 * metric object in PcepUpdate message.
 */
@Test
public void pcepUpdateMsgTest15() throws PcepParseException, PcepOutOfBoundMessageException {
    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
            0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //lspa object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}
 
Example 6
Source File: PcepUpdateMsgExtTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
 * lspa object in PcepUpdate message.
 */
@Test
public void pcepUpdateMsgTest29() throws PcepParseException, PcepOutOfBoundMessageException {
    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
            0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}
 
Example 7
Source File: PcepUpdateMsgExtTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
 * Bandwidth , metric object in PcepUpdate message.
 */
@Test
public void pcepUpdateMsgTest20() throws PcepParseException, PcepOutOfBoundMessageException {
    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
            0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00,
            0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}
 
Example 8
Source File: PcepUpdateMsgExtTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
 * LSPA, Bandwidth object in PcepUpdate message.
 */
@Test
public void pcepUpdateMsgTest2() throws PcepParseException, PcepOutOfBoundMessageException {
    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
            0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSP object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
            0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}
 
Example 9
Source File: PcepUpdateMsgExtTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * This test case is for SRP object, LSP object, ERO object, LSPA, bandwidth object
 * Metric object in PcepUpdate message.
 */
@Test
public void pcepUpdateMsgTest3() throws PcepParseException, PcepOutOfBoundMessageException {
    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
            0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
            0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}
 
Example 10
Source File: PcepUpdateMsgTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
 * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
 */
@Test
public void pcepUpdateMsgTest13() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
            0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}
 
Example 11
Source File: BgpNotificationMsgTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * 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));
}
 
Example 12
Source File: BgpUpdateMsgTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * This test case checks update message with node NLRI.
 */
@Test
public void bgpUpdateMessageTest18() 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, 0x60, 0x02, 0x00, 0x00, //withdrawn len
            0x00, 0x49, //path attribute len
            0x04, 0x01, 0x01, 0x00, //origin
            0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd, (byte) 0xe9, //as_path
            (byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, //med
            (byte) 0x80, 0x0e, 0x34, 0x40, 0x04, 0x47, //mpreach with safi = 71
            0x04, 0x04, 0x00, 0x00, 0x01, //nexthop
            0x00, //reserved
            0x00, 0x01, 0x00,
            0x27, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1a, 0x02, 0x00,
            0x00, 0x04, 0x00, 0x00, 0x08, (byte) 0xae, 0x02, 0x01, 0x00, 0x04, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
            0x00, 0x06, 0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; //node nlri

    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));
    BgpUpdateMsg other = (BgpUpdateMsg) message;

    assertThat(other.getHeader().getMarker(), is(MARKER));
    assertThat(other.getHeader().getType(), is(UPDATE_MSG_TYPE));
    assertThat(other.getHeader().getLength(), is((short) 96));

    BgpValueType testPathAttribute;
    Origin origin;
    AsPath asPath;
    Med med;
    MpReachNlri mpReach;
    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();
    asPath = (AsPath) testPathAttribute;
    ListIterator<Short> listIterator2 = asPath.asPathSeq().listIterator();
    assertThat(listIterator2.next(), is((short) 65001));

    testPathAttribute = listIterator.next();
    med = (Med) testPathAttribute;
    assertThat(med.med(), is(0));

    testPathAttribute = listIterator.next();
    mpReach = (MpReachNlri) testPathAttribute;
    assertThat(mpReach.mpReachNlriLen(), is((int) 52));
    assertThat(mpReach.getType(), is((short) 14));

    List<BgpLSNlri> testMpReachNlri = new LinkedList<>();
    testMpReachNlri = mpReach.mpReachNlri();

    ListIterator<BgpLSNlri> list1 = testMpReachNlri.listIterator();
    BgpLSNlri testnlri =  list1.next();
    NlriType nlriType = org.onosproject.bgpio.protocol.NlriType.NODE;
    ProtocolType protocolId = org.onosproject.bgpio.protocol.linkstate.
    BgpNodeLSNlriVer4.ProtocolType.ISIS_LEVEL_TWO;
    assertThat(testnlri.getIdentifier(), is((long) 0));
    assertThat(testnlri.getNlriType(), is(nlriType));
    assertThat(testnlri.getProtocolId(), is(protocolId));

    BgpNodeLSNlriVer4 testNodenlri = (BgpNodeLSNlriVer4) testnlri;

    BgpNodeLSIdentifier testLocalNodeDescriptors = testNodenlri.getLocalNodeDescriptors();

    List<BgpValueType> testSubTlvs = new LinkedList<>();
    NodeDescriptors localNodeDescriptors = testLocalNodeDescriptors.getNodedescriptors();
    testSubTlvs = localNodeDescriptors.getSubTlvs();
    ListIterator<BgpValueType> subtlvlist1 = testSubTlvs.listIterator();

    AutonomousSystemTlv testAutonomousSystemTlv = (AutonomousSystemTlv) subtlvlist1.next();
    assertThat(testAutonomousSystemTlv.getAsNum(), is(2222));
    assertThat(testAutonomousSystemTlv.getType(), is((short) 512));

    BgpLSIdentifierTlv testBgpLsIdentifierTlv = (BgpLSIdentifierTlv) subtlvlist1.next();
    assertThat(testBgpLsIdentifierTlv.getBgpLsIdentifier(), is(33686018));
    assertThat(testBgpLsIdentifierTlv.getType(), is((short) 513));

    IsIsNonPseudonode testIsIsNonPseudonode = (IsIsNonPseudonode) subtlvlist1.next();
    byte[] expIsoNodeId = new byte[] {0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58};
    assertThat(testIsIsNonPseudonode.getIsoNodeId(), is(expIsoNodeId));
    assertThat(testIsIsNonPseudonode.getType(), is((short) 515));

}
 
Example 13
Source File: BgpSelectionAlgoTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * firstPathAttribute and secondPathAttribute are same.
 */
@Test
public void selectionAlgoTest9() throws BgpParseException {

    byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
    LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
    BgpValueType pathAttribute1;
    byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(origin);
    pathAttribute1 = Origin.read(buffer);
    pathAttributes1.add(pathAttribute1);
    byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
            (byte) 0xe9 };
    buffer.writeBytes(asPath);
    pathAttribute1 = AsPath.read(buffer);
    pathAttributes1.add(pathAttribute1);

    IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
    //A0A0A00
    Integer bgpId = 168430080;
    short locRibAsNum = 100;
    boolean isIbgp = false;
    PathAttrNlriDetails attrList1 = new PathAttrNlriDetails();
    attrList1.setIdentifier(0);
    attrList1.setPathAttribute(pathAttributes1);
    attrList1.setProtocolID(ProtocolType.ISIS_LEVEL_ONE);
    PathAttrNlriDetailsLocalRib list1 = new PathAttrNlriDetailsLocalRib(
            ipAddress, bgpId, locRibAsNum, isIbgp, attrList1);

    peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
    LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
    BgpValueType pathAttribute2;
    origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
    buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(origin);
    pathAttribute2 = Origin.read(buffer);
    pathAttributes2.add(pathAttribute2);
    asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
            (byte) 0xe9 };
    buffer.writeBytes(asPath);
    pathAttribute2 = AsPath.read(buffer);
    pathAttributes2.add(pathAttribute2);

    ipAddress = IpAddress.valueOf(Version.INET, peerIp);
    //A0A0A00
    bgpId = 168430080;
    locRibAsNum = 200;
    isIbgp = false;
    PathAttrNlriDetails attrList2 = new PathAttrNlriDetails();
    attrList2.setIdentifier(0);
    attrList2.setPathAttribute(pathAttributes2);
    attrList2.setProtocolID(ProtocolType.OSPF_V2);
    PathAttrNlriDetailsLocalRib list2 = new PathAttrNlriDetailsLocalRib(
            ipAddress, bgpId, locRibAsNum, isIbgp, attrList2);
    BgpSelectionAlgo algo = new BgpSelectionAlgo();
    int result = algo.compare(list1, list2);
    assertThat(result, is(0));
}
 
Example 14
Source File: PcepLSReportMsgTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * This test case checks for
 * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv,
 * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv,
 * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv,
 * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv), NodeAttributesTlv(NodeFlagBitsSubTlv,
 * OpaqueNodePropertiesSubTlv, NodeNameSubTlv, ISISAreaIdentifierSubTlv, IPv4RouterIdOfLocalNodeSubTlv),
 * LinkAttributesTlv(IPv4RouterIdOfRemoteNodeSubTlv, IPv6LSRouterIdofRemoteNodeTlv, AdministrativeGroupSubTlv,
 * MaximumLinkBandwidthSubTlv, MaximumReservableLinkBandwidthSubTlv, UnreservedBandwidthSubTlv,
 * TEDefaultMetricSubTlv, LinkProtectionTypeSubTlv, MPLSProtocolMaskSubTlv, IgpMetricSubTlv))
 * in PcLSRpt message.
 */
@Test
public void lsReportMessageTest25() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0xFC, // common header
            (byte) 0xE0, 0x10, 0x00, (byte) 0xF8, // LS Object Header
            0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
            (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
            0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x01,
            (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
            0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x00, 0x00, 0x11,
            (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
            0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x00, 0x00, 0x11,
            (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
            0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
            0x01, 0x11, 0x00, 0x09,
            0x01, 0x21, 0x00, 0x09,
            0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
            0x01, 0x01, 0x01, 0x01,
            0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
            0x01, 0x011, 0x01, 0x10,
            (byte) 0xFF, 0x05, 0x00, 0x1C, //NodeAttributesTlv
            0x00, 0x0E, 0x00, 0x04, //OpaqueNodePropertiesSubTlv
            0x01, 0x011, 0x01, 0x10,
            0x00, 0x10, 0x00, 0x08, //ISISAreaIdentifierSubTlv
            0x20, 0x01, 0x22, 0x01,
            0x20, 0x01, 0x22, 0x01,
            0x00, 0x11, 0x00, 0x04, //IPv4RouterIdOfLocalNodeSubTlv
            0x00, 0x01, 0x01, 0x02,
            (byte) 0xFF, 0x06, 0x00, 0x48, //LinkAttributesTlv
            0x00, 0x13, 0x00, 0x04, //IPv4RouterIdOfRemoteNodeSubTlv
            0x00, 0x07, 0x08, 0x00,
            0x00, 0x16, 0x00, 0x04, //AdministrativeGroupSubTlv
            0x00, 0x09, 0x08, 0x00,
            0x00, 0x17, 0x00, 0x04, //MaximumLinkBandwidthSubTlv
            0x00, 0x09, 0x00, 0x00,
            0x00, 0x18, 0x00, 0x04, //MaximumReservableLinkBandwidthSubTlv
            0x00, 0x10, 0x00, 0x00,
            0x00, 0x19, 0x00, 0x04, //UnreservedBandwidthSubTlv
            0x00, 0x00, (byte) 0x90, 0x00,
            0x00, 0x1A, 0x00, 0x04, //TEDefaultMetricSubTlv
            0x00, (byte) 0x99, 0x09, 0x00,
            0x00, 0x1B, 0x00, 0x02, //LinkProtectionTypeSubTlv
            0x09, 0x00, 0x00, 0x00,
            0x00, 0x1C, 0x00, 0x01, //MPLSProtocolMaskSubTlv
            (byte) 0x80, 0x00, 0x00, 0x00,
            0x00, 0x1D, 0x00, 0x04, //IgpMetricSubTlv
            0x09, (byte) 0x89, 0x07, 0x00
    };

    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(lsReportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    byte[] testReportMsg = {0};

    assertThat(message, instanceOf(PcepLSReportMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testReportMsg = new byte[readLen];
    buf.readBytes(testReportMsg, 0, readLen);

    assertThat(testReportMsg, is(lsReportMsg));
}
 
Example 15
Source File: PcepLSReportMsgTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * This test case checks for
 * LS Object (Routing Universe TLV,Local Node Descriptors TLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
 * OSPFareaIDsubTlv, IgpRouterIdSubTlv), RemoteNodeDescriptorsTLV(AutonomousSystemSubTlv, BGPLSidentifierSubTlv
 * OSPFareaIDsubTlv, IgpRouterIdSubTlv), LinkDescriptorsTLV(LinkLocalRemoteIdentifiersSubTlv
 * IPv4InterfaceAddressSubTlv, IPv4NeighborAddressSubTlv))
 * in PcLSRpt message.
 */
@Test
public void lsReportMessageTest18() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] lsReportMsg = new byte[]{0x20, (byte) 0xE0, 0x00, (byte) 0xC4, // common header
            (byte) 0xE0, 0x10, 0x00, (byte) 0xC0, // LS Object Header
            0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, // LS-ID
            (byte) 0xFF, 0x01, 0x00, 0x08, // Routing Universe TLV
            0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x01,
            (byte) 0xFF, 0x02, 0x00, 0x24, // Local Node Descriptors TLV
            0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x00, 0x00, 0x11,
            (byte) 0xFF, 0x03, 0x00, 0x24, //RemoteNodeDescriptorsTLV
            0x00, 0x01, 0x00, 0x04, //AutonomousSystemSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x02, 0x00, 0x04, //BGPLSidentifierSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x03, 0x00, 0x04, //OSPFareaIDsubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x04, 0x00, 0x08, //IgpRouterIdSubTlv
            0x00, 0x00, 0x00, 0x11,
            0x00, 0x00, 0x00, 0x11,
            (byte) 0xFF, 0x04, 0x00, 0x1C, //LinkDescriptorsTLV
            0x00, 0x06, 0x00, 0x08, //LinkLocalRemoteIdentifiersSubTlv
            0x01, 0x11, 0x00, 0x09,
            0x01, 0x21, 0x00, 0x09,
            0x00, 0x07, 0x00, 0x04, //IPv4InterfaceAddressSubTlv
            0x01, 0x01, 0x01, 0x01,
            0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressSubTlv
            0x01, 0x011, 0x01, 0x10,
            (byte) 0xFF, 0x05, 0x00, 0x30, //NodeAttributesTlv
            0x00, 0x0D, 0x00, 0x01, //NodeFlagBitsSubTlv
            (byte) 0x90, 0x00, 0x00, 0x00,
            0x00, 0x0E, 0x00, 0x04, //OpaqueNodePropertiesSubTlv
            0x01, 0x011, 0x01, 0x10,
            0x00, 0x0F, 0x00, 0x08, //NodeNameSubTlv
            0x08, 0x00, 0x01, 0x09,
            0x08, 0x00, 0x01, 0x09,
            0x00, 0x10, 0x00, 0x08, //ISISAreaIdentifierSubTlv
            0x20, 0x01, 0x22, 0x01,
            0x20, 0x01, 0x22, 0x01,
            0x00, 0x11, 0x00, 0x04, //IPv4RouterIdOfLocalNodeSubTlv
            0x00, 0x01, 0x01, 0x02
    };

    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(lsReportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    byte[] testReportMsg = {0};
    assertThat(message, instanceOf(PcepLSReportMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testReportMsg = new byte[readLen];
    buf.readBytes(testReportMsg, 0, readLen);

    assertThat(testReportMsg, is(lsReportMsg));
}
 
Example 16
Source File: PcepInitiateMsgTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
 * END-POINT, ERO objects in PcInitiate message.
 */
@Test
public void initiateMessageTest5() throws PcepParseException, PcepOutOfBoundMessageException {

    /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
     * END-POINT, ERO.
     */
    byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5c,
            0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
            0x07, 0x10, 0x00, 0x14, //ERO object
            0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
            0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};

    byte[] testInitiateCreationMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(initiateCreationMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepInitiateMsg.class));

    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();

    message.writeTo(buf);

    testInitiateCreationMsg = buf.array();

    int iReadLen = buf.writerIndex();
    testInitiateCreationMsg = new byte[iReadLen];
    buf.readBytes(testInitiateCreationMsg, 0, iReadLen);

    assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
}
 
Example 17
Source File: NettyBackedChannelBufferFactory.java    From dubbox with Apache License 2.0 4 votes vote down vote up
@Override
public ChannelBuffer getBuffer(byte[] array, int offset, int length) {
    org.jboss.netty.buffer.ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(length);
    buffer.writeBytes(array, offset, length);
    return new NettyBackedChannelBuffer(buffer);
}
 
Example 18
Source File: PcepReportMsgTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * This test case checks for SRP Object,LSP Object)Symbolic path tlv),ERO Object,SRP Object
 * LSP Object(symbolic path tlv) ERO Object,LSPA Object, BandWidth Object,Metric-list
 * in PcRpt message.
 */
@Test
public void reportMessageTest35() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8C,
            0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
            0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
            0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x07, 0x10, 0x00, 0x14, //ERO Object
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
            0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
            0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
            0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x07, 0x10, 0x00, 0x14, //ERO Object
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, //LSPA Object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object

    byte[] testReportMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepReportMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testReportMsg = new byte[readLen];
    buf.readBytes(testReportMsg, 0, readLen);

    assertThat(testReportMsg, is(reportMsg));
}
 
Example 19
Source File: PcepInitiateMsgExtTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
 * ERO, LSPA OBJECT objects in PcInitiate message.
 */
@Test
public void initiateMessageTest35() throws PcepParseException, PcepOutOfBoundMessageException {

    // SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
    // ERO, LSPA OBJECT.
    //
    byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
            0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
            0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
            0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};

    byte[] testInitiateCreationMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(initiateCreationMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepInitiateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();

    message.writeTo(buf);

    testInitiateCreationMsg = buf.array();

    int iReadLen = buf.writerIndex();
    testInitiateCreationMsg = new byte[iReadLen];
    buf.readBytes(testInitiateCreationMsg, 0, iReadLen);

    assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
}
 
Example 20
Source File: PcepUpdateMsgTest.java    From onos with Apache License 2.0 4 votes vote down vote up
/**
 * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
 * StatefulLspErrorCodeTlv),ERO (IPv4SubObject, IPv4SubObject),LSPA, Bandwidth, Metric objects in PcUpd message.
 */
@Test
public void pcepUpdateMsgTest20() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
            0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
            0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = null;

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}