use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.subobject.nai.IpAdjacencyBuilder in project bgpcep by opendaylight.
the class SrRroSubobjectParserTest method testSrRroSubobjectIpv4AdjacencyNAI.
@Test
public void testSrRroSubobjectIpv4AdjacencyNAI() throws PCEPDeserializerException {
final SrRroTypeBuilder builder = new SrRroTypeBuilder().setNaiType(NaiType.Ipv4Adjacency).setSid(Uint32.valueOf(123456)).setCFlag(false).setMFlag(false).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.99"))).setRemoteIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.100"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(SR_RRO_SUBOBJECT_WITH_IPV4_ADJ, 2))));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(SR_RRO_SUBOBJECT_WITH_IPV4_ADJ, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.subobject.nai.IpAdjacencyBuilder in project bgpcep by opendaylight.
the class SrRroSubobjectParserTest method testSrRroSubobjectIpv6AdjacencyNAI.
@Test
public void testSrRroSubobjectIpv6AdjacencyNAI() throws PCEPDeserializerException {
final SrRroTypeBuilder builder = new SrRroTypeBuilder().setNaiType(NaiType.Ipv6Adjacency).setSid(Uint32.valueOf(123456)).setCFlag(false).setMFlag(false).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("fe80:cd00::211e:729c"))).setRemoteIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("fe80:cd00::211e:729d"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build());
assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(SR_RRO_SUBOBJECT_WITH_IPV6_ADJ, 2))));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(SR_RRO_SUBOBJECT_WITH_IPV6_ADJ, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.subobject.nai.IpAdjacencyBuilder in project bgpcep by opendaylight.
the class MessagesUtil method getEro.
public static Ero getEro(final List<PathDescription> pathDescriptions) {
/* Prepare ERO */
final EroBuilder eroBuilder = new EroBuilder().setIgnore(false).setProcessingRule(true);
final List<Subobject> eroSubs = new ArrayList<>();
/* Fulfill ERO sublist */
for (PathDescription path : pathDescriptions) {
Subobject sb = null;
if (path.getSid() == null) {
IpPrefix ipPref = null;
/* Prepare SubObject for IPv4 or IPv6 address */
if (path.getIpv4() != null) {
final Ipv4Prefix ipv4Pref = new Ipv4Prefix(path.getIpv4().getValue() + "/32");
ipPref = new IpPrefixBuilder().setIpPrefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix(ipv4Pref)).build();
}
if (path.getIpv6() != null) {
final Ipv6Prefix ipv6Pref = new Ipv6Prefix(path.getIpv6().getValue() + "/128");
ipPref = new IpPrefixBuilder().setIpPrefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix(ipv6Pref)).build();
}
if (ipPref != null) {
final IpPrefixCase ipPrefCase = new IpPrefixCaseBuilder().setIpPrefix(ipPref).build();
sb = new SubobjectBuilder().setSubobjectType(ipPrefCase).setLoose(false).build();
}
} else {
/* Prepare SubObject for Segment Routing */
SrEroType srEro = null;
if (path.getLocalIpv4() != null && path.getRemoteIpv4() != null) {
srEro = new SrEroTypeBuilder().setNaiType(NaiType.Ipv4Adjacency).setSid(path.getSid()).setCFlag(false).setMFlag(true).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(path.getLocalIpv4().getValue()))).setRemoteIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(path.getRemoteIpv4().getValue()))).build()).build();
}
if (path.getLocalIpv6() != null && path.getRemoteIpv6() != null) {
srEro = new SrEroTypeBuilder().setNaiType(NaiType.Ipv6Adjacency).setSid(path.getSid()).setCFlag(false).setMFlag(true).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone(path.getLocalIpv6().getValue()))).setRemoteIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone(path.getRemoteIpv6().getValue()))).build()).build();
}
if (srEro != null) {
sb = new SubobjectBuilder().setSubobjectType(srEro).setLoose(false).build();
}
}
/* Add corresponding SubObject to the ERO List */
if (sb != null) {
eroSubs.add(sb);
}
}
/* Set ERO sublist */
eroBuilder.setSubobject(eroSubs);
return eroBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.subobject.nai.IpAdjacencyBuilder in project bgpcep by opendaylight.
the class SrEroSubobjectParserTest method testSrEroSubobjectIpv6AdjacencyNAI.
@Test
public void testSrEroSubobjectIpv6AdjacencyNAI() throws PCEPDeserializerException {
final SrEroTypeBuilder builder = new SrEroTypeBuilder().setNaiType(NaiType.Ipv6Adjacency).setSid(Uint32.valueOf(123456)).setCFlag(false).setMFlag(false).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("fe80:cd00::211e:729c"))).setRemoteIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("fe80:cd00::211e:729d"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(SR_ERO_SUBOBJECT_WITH_IPV6_ADJ, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(SR_ERO_SUBOBJECT_WITH_IPV6_ADJ, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.subobject.nai.IpAdjacencyBuilder in project bgpcep by opendaylight.
the class SrEroSubobjectParserTest method testSrEroSubobjectIpv4AdjacencyNAI.
@Test
public void testSrEroSubobjectIpv4AdjacencyNAI() throws PCEPDeserializerException {
final SrEroTypeBuilder builder = new SrEroTypeBuilder().setNaiType(NaiType.Ipv4Adjacency).setSid(Uint32.valueOf(123456)).setCFlag(false).setMFlag(false).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.99"))).setRemoteIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("74.125.43.100"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(SR_ERO_SUBOBJECT_WITH_IPV4_ADJ, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(SR_ERO_SUBOBJECT_WITH_IPV4_ADJ, ByteArray.getAllBytes(buffer));
}
Aggregations