use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.PathKeyCase in project bgpcep by opendaylight.
the class XROPathKey32SubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance.Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
final ByteBuf body = serializePathKey(pk);
final byte[] pceId = pk.getPceId().getValue();
if (pceId.length == PCE_ID_F_LENGTH) {
XROSubobjectUtil.formatSubobject(TYPE, subobject.getMandatory(), body, buffer);
} else if (pceId.length == XROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
XROSubobjectUtil.formatSubobject(XROPathKey128SubobjectParser.TYPE, subobject.getMandatory(), body, buffer);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.PathKeyCase in project bgpcep by opendaylight.
the class AbstractEROPathKeySubobjectParser method serializeSubobject.
@Override
public final void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
final SubobjectType type = subobject.getSubobjectType();
checkArgument(type instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", type.getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) type).getPathKey();
final PathKey pathKey = pk.getPathKey();
checkArgument(pathKey != null, "PathKey is mandatory.");
final byte[] pceID = pk.getPceId().getValue();
checkArgument(pceID.length == PCE_ID_F_LENGTH || pceID.length == PCE128_ID_F_LENGTH, "PceId 32/128 Bit required.");
final ByteBuf body = Unpooled.buffer();
ByteBufUtils.write(body, pathKey.getValue());
body.writeBytes(pceID);
EROSubobjectUtil.formatSubobject(pceID.length == PCE_ID_F_LENGTH ? TYPE_32 : TYPE_128, subobject.getLoose(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.PathKeyCase in project bgpcep by opendaylight.
the class XROPathKey128SubobjectParser method serializeSubobject.
public static void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
final SubobjectType type = subobject.getSubobjectType();
checkArgument(type instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", type.getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) type).getPathKey();
final ByteBuf body = Unpooled.buffer();
final PathKey pathKey = pk.getPathKey();
checkArgument(pathKey != null, "PathKey is mandatory.");
ByteBufUtils.write(body, pathKey.getValue());
final PceId pceId = pk.getPceId();
checkArgument(pceId != null, "PceId is mandatory.");
body.writeBytes(pceId.getValue());
XROSubobjectUtil.formatSubobject(TYPE, subobject.getMandatory(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.PathKeyCase in project bgpcep by opendaylight.
the class PCEPPathKeyObjectParser method parseObject.
@Override
public PathKey parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final List<PathKeys> pk = new ArrayList<>();
final List<Subobject> subs = parseSubobjects(bytes);
for (final Subobject sub : subs) {
final PathKeyCase pkc = (PathKeyCase) sub.getSubobjectType();
pk.add(new PathKeysBuilder().setLoose(sub.getLoose()).setPceId(pkc.getPathKey().getPceId()).setPathKey(pkc.getPathKey().getPathKey()).build());
}
return new PathKeyBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setPathKeys(pk).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.PathKeyCase in project bgpcep by opendaylight.
the class RROPathKey32SubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
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();
final PceId pceId = pk.getPceId();
checkArgument(pceId != null, "PceId is mandatory.");
final byte[] idBytes = pceId.getValue();
if (idBytes.length == RROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
RROPathKey128SubobjectParser.serializeSubobject(subobject, buffer);
}
final PathKey pathKey = pk.getPathKey();
checkArgument(pathKey != null, "PathKey is mandatory.");
ByteBufUtils.write(body, pathKey.getValue());
checkArgument(idBytes.length == PCE_ID_F_LENGTH, "PceId 32 Bit required.");
body.writeBytes(idBytes);
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
Aggregations