Search in sources :

Example 36 with Subobject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject in project bgpcep by opendaylight.

the class RROIpv6PrefixSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    Preconditions.checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass());
    final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
    final IpPrefix prefix = specObj.getIpPrefix();
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable());
    flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
    final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
    Preconditions.checkArgument(prefix.getIpv6Prefix() != null, "Ipv6Prefix is mandatory.");
    writeIpv6Prefix(prefix.getIpv6Prefix(), body);
    flags.toByteBuf(body);
    RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
Also used : IpPrefixSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCase) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf)

Example 37 with Subobject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject in project bgpcep by opendaylight.

the class RROLabelSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    requireNonNull(subobject.getSubobjectType(), "Subobject type cannot be empty.");
    final Label label = ((LabelCase) subobject.getSubobjectType()).getLabel();
    final ByteBuf body = Unpooled.buffer();
    this.registry.serializeLabel(label.isUniDirectional(), label.isGlobal(), label.getLabelType(), body);
    RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
Also used : LabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.LabelCase) Label(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.label._case.Label) ByteBuf(io.netty.buffer.ByteBuf)

Example 38 with Subobject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject in project bgpcep by opendaylight.

the class RROPathKey128SubobjectParser method serializeSubobject.

public static void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    final PathKeyCase pkcase = (PathKeyCase) subobject.getSubobjectType();
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.path.key._case.PathKey pk = pkcase.getPathKey();
    final ByteBuf body = Unpooled.buffer();
    Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
    writeUnsignedShort(pk.getPathKey().getValue(), body);
    Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
    body.writeBytes(pk.getPceId().getBinary());
    RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) PathKeyCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCase)

Example 39 with Subobject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject in project bgpcep by opendaylight.

the class RROUnnumberedInterfaceSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
    final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
    final BitArray flags = new BitArray(FLAGS_SIZE);
    flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable());
    flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
    final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
    flags.toByteBuf(body);
    body.writeZero(RESERVED);
    Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
    writeUnsignedInt(specObj.getRouterId(), body);
    Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
    writeUnsignedInt(specObj.getInterfaceId(), body);
    RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
Also used : UnnumberedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.UnnumberedCase) BitArray(org.opendaylight.protocol.util.BitArray) ByteBuf(io.netty.buffer.ByteBuf) UnnumberedSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.UnnumberedSubobject)

Example 40 with Subobject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject in project bgpcep by opendaylight.

the class XROAsNumberSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    Preconditions.checkArgument(subobject.getSubobjectType() instanceof AsNumberCase, "Unknown subobject instance. Passed %s. Needed AsNumberCase.", subobject.getSubobjectType().getClass());
    final ByteBuf body = AsNumberCaseParser.serializeSubobject((AsNumberCase) subobject.getSubobjectType());
    XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
Also used : AsNumberCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)61 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)21 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)20 ArrayList (java.util.ArrayList)16 BitArray (org.opendaylight.protocol.util.BitArray)15 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder)14 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject)12 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)12 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase)9 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.SubobjectBuilder)7 EroBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder)7 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)7 IpPrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder)7 IpPrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder)7 Preconditions (com.google.common.base.Preconditions)6 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)5 PathKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey)5 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId)5 Test (org.junit.Test)4 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)4