use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testReqMissingTlv.
@Test
public void testReqMissingTlv() throws PCEPDeserializerException {
final ReqMissingTlvParser parser = new ReqMissingTlvParser();
final ReqMissing tlv = new ReqMissingBuilder().setRequestId(new RequestId(Uint32.valueOf(0xF7823517L))).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(REQ_MISSING_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(REQ_MISSING_BYTES, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId in project bgpcep by opendaylight.
the class PCEPSvecObjectParser method parseObject.
@Override
public Svec 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.");
if (bytes.readableBytes() < MIN_SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: >=" + MIN_SIZE + ".");
}
bytes.skipBytes(FLAGS_F_OFFSET);
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
final List<RequestId> requestIDs = new ArrayList<>();
while (bytes.isReadable()) {
requestIDs.add(new RequestId(ByteBufUtils.readUint32(bytes)));
}
if (requestIDs.isEmpty()) {
throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
}
return new SvecBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setLinkDiverse(flags.get(L_FLAG_OFFSET)).setNodeDiverse(flags.get(N_FLAG_OFFSET)).setSrlgDiverse(flags.get(S_FLAG_OFFSET)).setLinkDirectionDiverse(flags.get(D_FLAG_OFFSET)).setPartialPathDiverse(flags.get(P_FLAG_OFFSET)).setRequestsIds(requestIDs).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId in project bgpcep by opendaylight.
the class ReqMissingTlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
checkArgument(tlv instanceof ReqMissing, "ReqMissingTlv is mandatory.");
final ReqMissing req = (ReqMissing) tlv;
final ByteBuf body = Unpooled.buffer();
final RequestId reqId = req.getRequestId();
checkArgument(reqId != null, "RequestId is mandatory.");
ByteBufUtils.write(body, reqId.getValue());
TlvUtil.formatTlv(TYPE, body, buffer);
}
Aggregations