use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method serializeMonitoringRequest.
protected void serializeMonitoringRequest(final MonitoringRequest monReq, final ByteBuf out) {
serializeObject(monReq.getMonitoring(), out);
serializeObject(monReq.getPccIdReq(), out);
if (monReq.getPceIdList() != null) {
for (final PceIdList pceId : monReq.getPceIdList()) {
serializeObject(pceId.getPceId(), out);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId in project bgpcep by opendaylight.
the class XROPathKey128SubobjectParser method serializeSubobject.
public static void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
Preconditions.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 = 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());
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId in project bgpcep by opendaylight.
the class XROPathKey128SubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT128_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >" + CONTENT128_LENGTH + ".");
}
final int pathKey = buffer.readUnsignedShort();
final byte[] pceId = ByteArray.readBytes(buffer, PCE128_ID_F_LENGTH);
final SubobjectBuilder builder = new SubobjectBuilder();
final PathKeyBuilder pBuilder = new PathKeyBuilder();
pBuilder.setPceId(new PceId(pceId));
pBuilder.setPathKey(new PathKey(pathKey));
builder.setMandatory(mandatory);
builder.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId in project bgpcep by opendaylight.
the class AbstractPceIdObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof PceId, "Wrong instance of PCEPObject. Passed %s. Needed PccIdReqObject.", object.getClass());
final PceId pceId = (PceId) object;
if (pceId.getIpAddress().getIpv4Address() != null) {
final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH);
ByteBufWriteUtil.writeIpv4Address(pceId.getIpAddress().getIpv4Address(), body);
ObjectUtil.formatSubobject(IPV4_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
} else if (pceId.getIpAddress().getIpv6Address() != null) {
final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH);
ByteBufWriteUtil.writeIpv6Address(pceId.getIpAddress().getIpv6Address(), body);
ObjectUtil.formatSubobject(IPV6_TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId in project bgpcep by opendaylight.
the class RROPathKey32SubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
Preconditions.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();
Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
if (pk.getPceId().getBinary().length == RROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
RROPathKey128SubobjectParser.serializeSubobject(subobject, buffer);
}
Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
writeUnsignedShort(pk.getPathKey().getValue(), body);
Preconditions.checkArgument(pk.getPceId().getBinary().length == PCE_ID_F_LENGTH, "PceId 32 Bit required.");
body.writeBytes(pk.getPceId().getBinary());
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
Aggregations