Search in sources :

Example 16 with EndpointsObjBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder in project bgpcep by opendaylight.

the class PCEPEndPointsIpv6ObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final EndpointsObjBuilder builder = new EndpointsObjBuilder();
    if (!header.getProcessingRule()) {
        LOG.debug("Processed bit not set on Endpoints OBJECT, ignoring it.");
        return new UnknownObject(PCEPErrors.P_FLAG_NOT_SET, builder.build());
    }
    if (bytes.readableBytes() != Ipv6Util.IPV6_LENGTH * 2) {
        throw new PCEPDeserializerException("Wrong length of array of bytes.");
    }
    final Ipv6Builder ipv6bldr = new Ipv6Builder().setSourceIpv6Address(Ipv6Util.addressForByteBuf(bytes)).setDestinationIpv6Address(Ipv6Util.addressForByteBuf(bytes));
    return builder.setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setAddressFamily(new Ipv6CaseBuilder().setIpv6(ipv6bldr.build()).build()).build();
}
Also used : Ipv6CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv6CaseBuilder) Ipv6Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv6._case.Ipv6Builder) EndpointsObjBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject)

Example 17 with EndpointsObjBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder in project bgpcep by opendaylight.

the class PCEPP2MPEndPointsIpv4ObjectParser method parseObject.

@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
    checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
    final EndpointsObjBuilder builder = new EndpointsObjBuilder();
    if (!header.getProcessingRule()) {
        LOG.debug("Processed bit not set on Endpoints OBJECT, ignoring it.");
        return new UnknownObject(PCEPErrors.P_FLAG_NOT_SET, builder.build());
    }
    if (bytes.readableBytes() % Ipv4Util.IP4_LENGTH != 0) {
        throw new PCEPDeserializerException("Wrong length of array of bytes.");
    }
    builder.setIgnore(header.getIgnore());
    builder.setProcessingRule(header.getProcessingRule());
    final P2mpIpv4Builder p2mpIpv4Builder = new P2mpIpv4Builder();
    p2mpIpv4Builder.setP2mpLeaves(P2mpLeaves.forValue(bytes.readInt()));
    p2mpIpv4Builder.setSourceIpv4Address(Ipv4Util.addressForByteBuf(bytes));
    List<Ipv4AddressNoZone> dest = new ArrayList<>();
    while (bytes.isReadable()) {
        dest.add(Ipv4Util.addressForByteBuf(bytes));
    }
    p2mpIpv4Builder.setDestinationIpv4Address(dest);
    builder.setAddressFamily(new P2mpIpv4CaseBuilder().setP2mpIpv4(p2mpIpv4Builder.build()).build());
    return builder.build();
}
Also used : P2mpIpv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.p2mp.ipv4._case.P2mpIpv4Builder) P2mpIpv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.P2mpIpv4CaseBuilder) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) ArrayList(java.util.ArrayList) EndpointsObjBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject)

Aggregations

EndpointsObjBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder)13 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)7 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)6 ByteBuf (io.netty.buffer.ByteBuf)5 Test (org.junit.Test)5 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)5 Ipv4CaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4CaseBuilder)5 P2mpIpv4CaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.P2mpIpv4CaseBuilder)5 Ipv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder)5 P2mpIpv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.p2mp.ipv4._case.P2mpIpv4Builder)5 ArrayList (java.util.ArrayList)4 PCEPEndPointsObjectSerializer (org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsObjectSerializer)4 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)4 EndpointsObjBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObjBuilder)4 Collections (java.util.Collections)2 Ipv6AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone)2 NetworkTopologyRef (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyRef)2 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)2 Arguments2Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Arguments2Builder)2 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)2