use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader in project bgpcep by opendaylight.
the class PCEPExplicitRouteObjectParser method parseObject.
@Override
public Ero parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
// Explicit approval of empty ERO
Preconditions.checkArgument(buffer != null, "Array of bytes is mandatory. Can't be null.");
final EroBuilder builder = new EroBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
builder.setSubobject(parseSubobjects(buffer));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader in project bgpcep by opendaylight.
the class PCEPLoadBalancingObjectParser method parseObject.
@Override
public LoadBalancing 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.");
if (bytes.readableBytes() != SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: " + SIZE + ".");
}
final LoadBalancingBuilder builder = new LoadBalancingBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
bytes.skipBytes(RESERVED + FLAGS_F_LENGTH);
builder.setMaxLsp(bytes.readUnsignedByte());
builder.setMinBandwidth(new Bandwidth(ByteArray.readAllBytes(bytes)));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader in project bgpcep by opendaylight.
the class PCCEndPointIpv4ObjectParserTest method testParseObject.
@Test
public void testParseObject() throws PCEPDeserializerException {
final ObjectHeader header = new ObjectHeaderImpl(false, false);
final ByteBuf bytes = Unpooled.buffer();
bytes.writeBytes(Ipv4Util.bytesForAddress(new Ipv4Address(IP1)));
bytes.writeBytes(Ipv4Util.bytesForAddress(new Ipv4Address(IP2)));
final EndpointsObj output = (EndpointsObj) new PCCEndPointIpv4ObjectParser().parseObject(header, bytes);
assertEquals(IP1, ((Ipv4Case) output.getAddressFamily()).getIpv4().getSourceIpv4Address().getValue());
assertEquals(IP2, ((Ipv4Case) output.getAddressFamily()).getIpv4().getDestinationIpv4Address().getValue());
assertFalse(output.isIgnore());
assertFalse(output.isProcessingRule());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader in project bgpcep by opendaylight.
the class PCCEndPointIpv4ObjectParserTest method testParseEmptyObject.
@Test(expected = PCEPDeserializerException.class)
public void testParseEmptyObject() throws PCEPDeserializerException {
final ObjectHeader header = new ObjectHeaderImpl(false, false);
final ByteBuf bytes = Unpooled.buffer();
bytes.writeByte(4);
new PCCEndPointIpv4ObjectParser().parseObject(header, bytes);
}
Aggregations