use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp in project bgpcep by opendaylight.
the class SrAttributeParserTest method testSrAdjId.
// tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.2.1
@Test
public void testSrAdjId() {
final byte[] tested = { (byte) 0x60, 10, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final byte[] testedOspf = { (byte) 0xc0, 10, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final byte[] sidLabel = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final SrAdjIds srAdjId = new SrAdjIdsBuilder().setFlags(ISIS_ADJ_FLAGS).setWeight(new Weight((short) 10)).setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
final SrAdjIds ospfAdj = new SrAdjIdsBuilder().setFlags(OSPF_ADJ_FLAGS).setWeight(new Weight((short) 10)).setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
assertEquals(srAdjId, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1)).build());
assertEquals(ospfAdj, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(testedOspf), ProtocolId.Ospf)).build());
final ByteBuf serializedData = SrLinkAttributesParser.serializeAdjacencySegmentIdentifier(srAdjId);
final ByteBuf serializedOspf = SrLinkAttributesParser.serializeAdjacencySegmentIdentifier(ospfAdj);
assertArrayEquals(tested, ByteArray.readAllBytes(serializedData));
assertArrayEquals(testedOspf, ByteArray.readAllBytes(serializedOspf));
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp in project bgpcep by opendaylight.
the class SrAttributeParserTest method testIpv6SrPrefix.
// https://tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-02#section-2.3.2
@Test
public void testIpv6SrPrefix() {
final byte[] bytes = { 0, 0, 0 };
final Ipv6SrPrefix prefix = new Ipv6SrPrefixBuilder().setAlgorithm(Algorithm.ShortestPathFirst).build();
assertEquals(prefix, Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(Unpooled.wrappedBuffer(bytes)));
final ByteBuf serializedPrefix = Unpooled.buffer();
Ipv6SrPrefixAttributesParser.serializeIpv6SrPrefix(prefix, serializedPrefix);
assertArrayEquals(bytes, ByteArray.readAllBytes(serializedPrefix));
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp in project bgpcep by opendaylight.
the class MatchBgpNeighborSetTest method testMatchFromBgpNeighborInvert.
@Test
public void testMatchFromBgpNeighborInvert() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("reject-from-neighbor-invert-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
doReturn(new PeerId("bgp://42.42.42.42")).when(this.exportParameters).getFromPeerId();
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getFromPeerId();
result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp in project bgpcep by opendaylight.
the class MatchBgpNeighborSetTest method testMatchToBgpNeighborInvert.
@Test
public void testMatchToBgpNeighborInvert() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("reject-to-neighbor-invert-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
doReturn(new PeerId("bgp://127.0.0.2")).when(this.exportParameters).getFromPeerId();
doReturn(new PeerId("bgp://42.42.42.42")).when(this.exportParameters).getToPeerId();
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getToPeerId();
result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp in project bgpcep by opendaylight.
the class MatchBgpNeighborSetTest method testMatchToBgpNeighborAny.
@Test
public void testMatchToBgpNeighborAny() {
Statement statement = this.basicStatements.stream().filter(st -> st.getName().equals("reject-to-neighbor-test")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder().build());
doReturn(new PeerId("bgp://127.0.0.2")).when(this.exportParameters).getFromPeerId();
doReturn(new PeerId("bgp://42.42.42.42")).when(this.exportParameters).getToPeerId();
RouteAttributeContainer result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
assertNotNull(result.getAttributes());
doReturn(new PeerId("bgp://127.0.0.1")).when(this.exportParameters).getToPeerId();
result = this.statementRegistry.applyExportStatement(this.baseAttributes, this.exportParameters, attributeContainer, statement);
assertNull(result.getAttributes());
}
Aggregations