use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.termination.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPOpenObjectParser method parseObject.
@Override
public Object 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 int versionValue = ByteArray.copyBitsRange(bytes.readByte(), VERSION_SF_OFFSET, VERSION_SF_LENGTH);
final OpenBuilder builder = new OpenBuilder();
builder.setVersion(new ProtocolVersion((short) versionValue));
builder.setProcessingRule(header.isProcessingRule());
builder.setIgnore(header.isIgnore());
final short keepalive = bytes.readUnsignedByte();
builder.setKeepalive(keepalive);
final short deadTimer = bytes.readUnsignedByte();
if (keepalive == 0) {
builder.setDeadTimer((short) 0);
} else {
builder.setDeadTimer(deadTimer);
}
builder.setSessionId(bytes.readUnsignedByte());
final TlvsBuilder tbuilder = new TlvsBuilder();
parseTlvs(tbuilder, bytes.slice());
builder.setTlvs(tbuilder.build());
final Open obj = builder.build();
if (versionValue != PCEP_VERSION) {
// TODO: Should we move this check into the negotiator
LOG.debug("Unsupported PCEP version {}", versionValue);
return new UnknownObject(PCEPErrors.PCEP_VERSION_NOT_SUPPORTED, obj);
}
return obj;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.termination.TlvsBuilder in project bgpcep by opendaylight.
the class RouteMirroringMessageHandler method parseMessageBody.
@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
final RouteMirroringMessageBuilder routeMirror = new RouteMirroringMessageBuilder().setPeerHeader(parsePerPeerHeader(bytes));
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parseTlvs(tlvsBuilder, bytes);
return routeMirror.setTlvs(tlvsBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.termination.TlvsBuilder in project bgpcep by opendaylight.
the class StatisticsReportHandler method parseMessageBody.
@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
final StatsReportsMessageBuilder statReport = new StatsReportsMessageBuilder().setPeerHeader(parsePerPeerHeader(bytes));
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
bytes.skipBytes(INT_BYTES_LENGTH);
parseTlvs(tlvsBuilder, bytes);
return statReport.setTlvs(tlvsBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.termination.TlvsBuilder in project bgpcep by opendaylight.
the class TestUtil method createRouteMirrorMsg.
public static RouteMirroringMessage createRouteMirrorMsg(final Ipv4Address bgpId) {
final RouteMirroringMessageBuilder routeMirrorMsgBuilder = new RouteMirroringMessageBuilder().setPeerHeader(createPeerHeader(bgpId));
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.mirror.TlvsBuilder tlvsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.mirror.TlvsBuilder();
tlvsBuilder.setMirrorInformationTlv(new MirrorInformationTlvBuilder().setCode(MirrorInformationCode.forValue(1)).build());
routeMirrorMsgBuilder.setTlvs(tlvsBuilder.build());
return routeMirrorMsgBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.termination.TlvsBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testCloseMsg.
@Test
public void testCloseMsg() throws IOException, PCEPDeserializerException {
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPCloseMessage1.bin"));
final PCEPCloseMessageParser parser = new PCEPCloseMessageParser(this.objectRegistry);
final CloseBuilder builder = new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder().setCClose(new CCloseBuilder().setIgnore(false).setProcessingRule(false).setReason((short) 5).setTlvs(new TlvsBuilder().build()).build()).build());
assertEquals(builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(builder.build(), buf);
assertArrayEquals(result.array(), buf.array());
try {
parser.serializeMessage(new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder().build()).build(), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Close Object must be present in Close Message.", e.getMessage());
}
}
Aggregations