当前位置: 首页>>代码示例>>Java>>正文


Java Origin.read方法代码示例

本文整理汇总了Java中org.onosproject.bgpio.types.Origin.read方法的典型用法代码示例。如果您正苦于以下问题:Java Origin.read方法的具体用法?Java Origin.read怎么用?Java Origin.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.onosproject.bgpio.types.Origin的用法示例。


在下文中一共展示了Origin.read方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectionAlgoTest1

import org.onosproject.bgpio.types.Origin; //导入方法依赖的package包/类
/**
 * firstPathAttribute and secondPathAttribute has same AS count and firstPathAttribute
 * has shortest Origin value than secondPathAttribute.
 */
@Test
public void selectionAlgoTest1() throws BgpParseException {
    byte[] peerIp = new byte[] {0x0a, 0x0a, 0x0a, 0x0a };
    LinkedList<BgpValueType> pathAttributes1 = new LinkedList<>();
    BgpValueType pathAttribute1;
    //origin with IGP
    byte[] origin = new byte[] {0x40, 0x01, 0x01, 0x00 };
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(origin);
    pathAttribute1 = Origin.read(buffer);
    pathAttributes1.add(pathAttribute1);
    //AsPath with AS_SEQ with one AS
    byte[] asPath = new byte[] {0x40, 0x02, 0x04, 0x02, 0x01, (byte) 0xfd,
            (byte) 0xea };
    buffer.writeBytes(asPath);
    pathAttribute1 = AsPath.read(buffer);
    pathAttributes1.add(pathAttribute1);

    IpAddress ipAddress = IpAddress.valueOf(Version.INET, peerIp);
    int bgpId = 168427777;
    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[] {0x0b, 0x0b, 0x0b, 0x0b };
    LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
    BgpValueType pathAttribute2;
    //origin with INCOMPLETE
    origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
    buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(origin);
    pathAttribute2 = Origin.read(buffer);
    pathAttributes2.add(pathAttribute2);
    //AsPath with AS_SEQ with one AS
    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);
    bgpId = 536936448;
    locRibAsNum = 200;
    isIbgp = true;
    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(1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:64,代码来源:BgpSelectionAlgoTest.java

示例2: selectionAlgoTest2

import org.onosproject.bgpio.types.Origin; //导入方法依赖的package包/类
/**
 * firstPathAttribute has 1 AS count and secondPathAttribute has 2 AS count
 * and firstPathAttribute has shortest Origin value than secondPathAttribute.
 */
@Test
public void selectionAlgoTest2() 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);
    int bgpId = 168427777;
    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[] {0x0b, 0x0b, 0x0b, 0x0b };
    LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
    BgpValueType pathAttribute2;
    origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
    buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(origin);
    pathAttribute2 = Origin.read(buffer);
    pathAttributes2.add(pathAttribute2);
    asPath = new byte[] {0x40, 0x02, 0x08, 0x02, 0x01, (byte) 0xfd,
            (byte) 0xea, 0x02, 0x01, (byte) 0xfd, (byte) 0xea };
    buffer.writeBytes(asPath);
    pathAttribute2 = AsPath.read(buffer);
    pathAttributes2.add(pathAttribute2);

    ipAddress = IpAddress.valueOf(Version.INET, peerIp);
    bgpId = 536936448;
    locRibAsNum = 200;
    isIbgp = true;
    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(-1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:61,代码来源:BgpSelectionAlgoTest.java

示例3: selectionAlgoTest3

import org.onosproject.bgpio.types.Origin; //导入方法依赖的package包/类
/**
 * firstPathAttribute and secondPathAttribute has same AS value
 * and firstPathAttribute has shortest Origin value than secondPathAttribute.
 */
@Test
public void selectionAlgoTest3() 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);
    int bgpId = 168427777;
    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[] {0x0b, 0x0b, 0x0b, 0x0b };
    LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
    BgpValueType pathAttribute2;
    origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
    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);
    bgpId = 536936448;
    locRibAsNum = 200;
    isIbgp = true;
    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(1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:61,代码来源:BgpSelectionAlgoTest.java

示例4: selectionAlgoTest4

import org.onosproject.bgpio.types.Origin; //导入方法依赖的package包/类
/**
 * firstPathAttribute has lowest med than secondPathAttribute.
 */
@Test
public void selectionAlgoTest4() 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[] med = new byte[] {(byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00,
            0x00 };
    buffer.writeBytes(med);
    pathAttribute1 = Med.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);
    int bgpId = 168427777;
    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[] {0x0b, 0x0b, 0x0b, 0x0b };
    LinkedList<BgpValueType> pathAttributes2 = new LinkedList<>();
    BgpValueType pathAttribute2;
    origin = new byte[] {0x40, 0x01, 0x01, 0x02 };
    buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(origin);
    pathAttribute2 = Origin.read(buffer);
    pathAttributes2.add(pathAttribute2);
    med = new byte[] {(byte) 0x80, 0x04, 0x04, 0x00, 0x00, 0x00, 0x01 };
    buffer.writeBytes(med);
    pathAttribute2 = Med.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);
    bgpId = 536936448;
    locRibAsNum = 200;
    isIbgp = true;
    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(1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:69,代码来源:BgpSelectionAlgoTest.java

示例5: selectionAlgoTest6

import org.onosproject.bgpio.types.Origin; //导入方法依赖的package包/类
/**
 * secondPathAttribute is EBGP than firstPathAttribute is IBGP.
 */
@Test
public void selectionAlgoTest6() 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);
    int bgpId = 168427777;
    short locRibAsNum = 100;
    boolean isIbgp = true;
    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[] {0x0b, 0x0b, 0x0b, 0x0b };
    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);
    bgpId = 536936448;
    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, false, attrList2);
    BgpSelectionAlgo algo = new BgpSelectionAlgo();
    int result = algo.compare(list1, list2);
    assertThat(result, is(-1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:60,代码来源:BgpSelectionAlgoTest.java

示例6: selectionAlgoTest7

import org.onosproject.bgpio.types.Origin; //导入方法依赖的package包/类
/**
 * firstPathAttribute has lower BGPID than secondPathAttribute.
 */
@Test
public void selectionAlgoTest7() 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[] {0x0b, 0x0b, 0x0b, 0x0b };
    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);
    //B0A0A00
    bgpId = 185207296;
    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(1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:62,代码来源:BgpSelectionAlgoTest.java

示例7: selectionAlgoTest8

import org.onosproject.bgpio.types.Origin; //导入方法依赖的package包/类
/**
 * secondPathAttribute has lowest peer address than firstPathAttribute.
 */
@Test
public void selectionAlgoTest8() throws BgpParseException {

    byte[] peerIp = new byte[] {0x0b, 0x0b, 0x0b, 0x0b };
    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(-1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:62,代码来源:BgpSelectionAlgoTest.java

示例8: selectionAlgoTest9

import org.onosproject.bgpio.types.Origin; //导入方法依赖的package包/类
/**
 * 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));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:62,代码来源:BgpSelectionAlgoTest.java

示例9: read

import org.onosproject.bgpio.types.Origin; //导入方法依赖的package包/类
/**
 * Reads from channelBuffer and parses BGP path attributes.
 *
 * @param cb channelBuffer
 * @return object of BgpPathAttributes
 * @throws BgpParseException while parsing BGP path attributes
 */
public static BgpPathAttributes read(ChannelBuffer cb)
        throws BgpParseException {

    BgpValueType pathAttribute = null;
    List<BgpValueType> pathAttributeList = new LinkedList<>();
    boolean isOrigin = false;
    boolean isAsPath = false;
    boolean isNextHop = false;
    boolean isMpReach = false;
    boolean isMpUnReach = false;
    while (cb.readableBytes() > 0) {
        cb.markReaderIndex();
        byte flags = cb.readByte();
        byte typeCode = cb.readByte();
        cb.resetReaderIndex();
        switch (typeCode) {
        case Origin.ORIGIN_TYPE:
            pathAttribute = Origin.read(cb);
            isOrigin = ((Origin) pathAttribute).isOriginSet();
            break;
        case AsPath.ASPATH_TYPE:
            pathAttribute = AsPath.read(cb);
            isAsPath = ((AsPath) pathAttribute).isaspathSet();
            break;
        case As4Path.AS4PATH_TYPE:
            pathAttribute = As4Path.read(cb);
            break;
        case NextHop.NEXTHOP_TYPE:
            pathAttribute = NextHop.read(cb);
            isNextHop = ((NextHop) pathAttribute).isNextHopSet();
            break;
        case Med.MED_TYPE:
            pathAttribute = Med.read(cb);
            break;
        case LocalPref.LOCAL_PREF_TYPE:
            pathAttribute = LocalPref.read(cb);
            break;
        case MpReachNlri.MPREACHNLRI_TYPE:
            pathAttribute = MpReachNlri.read(cb);
            isMpReach = ((MpReachNlri) pathAttribute).isMpReachNlriSet();
            break;
        case MpUnReachNlri.MPUNREACHNLRI_TYPE:
            pathAttribute = MpUnReachNlri.read(cb);
            isMpUnReach = ((MpUnReachNlri) pathAttribute)
                    .isMpUnReachNlriSet();
            break;
        case LINK_STATE_ATTRIBUTE_TYPE:
            pathAttribute = LinkStateAttributes.read(cb);
            break;
        case EXTENDED_COMMUNITY_TYPE:
            pathAttribute = BgpExtendedCommunity.read(cb);
            break;
        case WideCommunity.TYPE:
            pathAttribute = WideCommunity.read(cb);
            break;
        default:
            //skip bytes for unsupported attribute types
            UnSupportedAttribute.read(cb);
        }
        pathAttributeList.add(pathAttribute);
    }

    checkMandatoryAttr(isOrigin, isAsPath, isNextHop, isMpReach, isMpUnReach);
    //TODO:if mp_reach or mp_unreach not present ignore the packet
    return new BgpPathAttributes(pathAttributeList);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:74,代码来源:BgpPathAttributes.java

示例10: read

import org.onosproject.bgpio.types.Origin; //导入方法依赖的package包/类
/**
 * Reads from channelBuffer and parses BGP path attributes.
 *
 * @param cb channelBuffer
 * @return object of BgpPathAttributes
 * @throws BgpParseException while parsing BGP path attributes
 */
public static BgpPathAttributes read(ChannelBuffer cb)
        throws BgpParseException {

    BgpValueType pathAttribute = null;
    List<BgpValueType> pathAttributeList = new LinkedList<>();
    boolean isOrigin = false;
    boolean isAsPath = false;
    boolean isNextHop = false;
    boolean isMpReach = false;
    boolean isMpUnReach = false;
    while (cb.readableBytes() > 0) {
        cb.markReaderIndex();
        byte flags = cb.readByte();
        byte typeCode = cb.readByte();
        cb.resetReaderIndex();
        switch (typeCode) {
        case Origin.ORIGIN_TYPE:
            pathAttribute = Origin.read(cb);
            isOrigin = ((Origin) pathAttribute).isOriginSet();
            break;
        case AsPath.ASPATH_TYPE:
            pathAttribute = AsPath.read(cb);
            isAsPath = ((AsPath) pathAttribute).isaspathSet();
            break;
        case As4Path.AS4PATH_TYPE:
            pathAttribute = As4Path.read(cb);
            break;
        case NextHop.NEXTHOP_TYPE:
            pathAttribute = NextHop.read(cb);
            isNextHop = ((NextHop) pathAttribute).isNextHopSet();
            break;
        case Med.MED_TYPE:
            pathAttribute = Med.read(cb);
            break;
        case LocalPref.LOCAL_PREF_TYPE:
            pathAttribute = LocalPref.read(cb);
            break;
        case MpReachNlri.MPREACHNLRI_TYPE:
            pathAttribute = MpReachNlri.read(cb);
            isMpReach = ((MpReachNlri) pathAttribute).isMpReachNlriSet();
            break;
        case MpUnReachNlri.MPUNREACHNLRI_TYPE:
            pathAttribute = MpUnReachNlri.read(cb);
            isMpUnReach = ((MpUnReachNlri) pathAttribute)
                    .isMpUnReachNlriSet();
            break;
        case LINK_STATE_ATTRIBUTE_TYPE:
            pathAttribute = LinkStateAttributes.read(cb);
            break;
        case EXTENDED_COMMUNITY_TYPE:
            pathAttribute = BgpExtendedCommunity.read(cb);
            break;
        case WideCommunity.TYPE:
            pathAttribute = WideCommunity.read(cb);
            break;
        default:
            log.debug("Skip bytes for unsupported attribute types");
            UnSupportedAttribute.read(cb);
        }
        pathAttributeList.add(pathAttribute);
    }

    checkMandatoryAttr(isOrigin, isAsPath, isNextHop, isMpReach, isMpUnReach);
    //TODO:if mp_reach or mp_unreach not present ignore the packet
    return new BgpPathAttributes(pathAttributeList);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:74,代码来源:BgpPathAttributes.java


注:本文中的org.onosproject.bgpio.types.Origin.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。