import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
-import org.opendaylight.protocol.pcep.spi.VendorInformationObjectRegistry;
import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Close;
registerObjectParsers(regs, context);
final ObjectRegistry objReg = context.getObjectHandlerRegistry();
- final VendorInformationObjectRegistry viObjReg = context.getVendorInformationObjectRegistry();
final PCEPOpenMessageParser openParser = new PCEPOpenMessageParser(objReg);
regs.add(context.registerMessageParser(PCEPOpenMessageParser.TYPE, openParser));
regs.add(context.registerMessageSerializer(
regs.add(context.registerMessageParser(PCEPKeepAliveMessageParser.TYPE, kaParser));
regs.add(context.registerMessageSerializer(Keepalive.class, kaParser));
- final PCEPRequestMessageParser reqParser = new PCEPRequestMessageParser(objReg, viObjReg);
+ final PCEPRequestMessageParser reqParser = new PCEPRequestMessageParser(objReg);
regs.add(context.registerMessageParser(PCEPRequestMessageParser.TYPE, reqParser));
regs.add(context.registerMessageSerializer(Pcreq.class, reqParser));
- final PCEPReplyMessageParser repParser = new PCEPReplyMessageParser(objReg, viObjReg);
+ final PCEPReplyMessageParser repParser = new PCEPReplyMessageParser(objReg);
regs.add(context.registerMessageParser(PCEPReplyMessageParser.TYPE, repParser));
regs.add(context.registerMessageSerializer(Pcrep.class, repParser));
regs.add(context.registerMessageParser(PCEPMonitoringReplyMessageParser.TYPE, monRepParser));
regs.add(context.registerMessageSerializer(Pcmonrep.class, monRepParser));
- final PCEPMonitoringRequestMessageParser monReqParser = new PCEPMonitoringRequestMessageParser(objReg, viObjReg);
+ final PCEPMonitoringRequestMessageParser monReqParser = new PCEPMonitoringRequestMessageParser(objReg);
regs.add(context.registerMessageParser(PCEPMonitoringRequestMessageParser.TYPE, monReqParser));
regs.add(context.registerMessageSerializer(Pcmonreq.class, monReqParser));
import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.protocol.pcep.spi.VendorInformationObjectRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcmonreq;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcmonreqBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
public static final int TYPE = 8;
- public PCEPMonitoringRequestMessageParser(final ObjectRegistry registry, final VendorInformationObjectRegistry viRegistry) {
- super(registry, viRegistry);
+ public PCEPMonitoringRequestMessageParser(final ObjectRegistry registry) {
+ super(registry);
}
@Override
import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.protocol.pcep.spi.VendorInformationObjectRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcrep;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcrepBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
public static final int TYPE = 4;
- public PCEPReplyMessageParser(final ObjectRegistry registry, final VendorInformationObjectRegistry viRegistry) {
- super(registry, viRegistry);
+ public PCEPReplyMessageParser(final ObjectRegistry registry) {
+ super(registry);
}
@Override
import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.protocol.pcep.spi.VendorInformationObjectRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcreq;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcreqBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
public static final int TYPE = 3;
- public PCEPRequestMessageParser(final ObjectRegistry registry, final VendorInformationObjectRegistry viRegistry) {
- super(registry, viRegistry);
+ public PCEPRequestMessageParser(final ObjectRegistry registry) {
+ super(registry);
}
@Override
import org.opendaylight.protocol.pcep.impl.message.PCEPStartTLSMessageParser;
import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.VendorInformationObjectRegistry;
import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
public class PCEPValidatorTest {
private ObjectRegistry objectRegistry;
- private VendorInformationObjectRegistry viObjRegistry;
private Open open;
private Rp rpTrue;
this.act.start(this.ctx);
this.viObjAct.start(this.ctx);
this.objectRegistry = this.ctx.getObjectHandlerRegistry();
- this.viObjRegistry = this.ctx.getVendorInformationObjectRegistry();
final RpBuilder rpBuilder = new RpBuilder();
rpBuilder.setProcessingRule(true);
rpBuilder.setIgnore(false);
public void testRequestMsg() throws IOException, PCEPDeserializerException {
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRequestMessage1.bin"));
- final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry, this.viObjRegistry);
+ final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry);
final PcreqMessageBuilder builder = new PcreqMessageBuilder();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests> reqs1 = Lists.newArrayList();
// only RP
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.1.bin"));
- final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry, this.viObjRegistry);
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder rBuilder = new RepliesBuilder();
@Test
public void testReqMsgWithVendorInfoObjects() throws IOException, PCEPDeserializerException {
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.7.bin"));
- final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry, this.viObjRegistry);
+ final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry);
final PcreqMessageBuilder builder = new PcreqMessageBuilder();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests> reqs1 = Lists.newArrayList();
@Test
public void testRepMsgWithVendorInforObjects() throws IOException, PCEPDeserializerException {
- final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry, this.viObjRegistry);
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder rBuilder = new RepliesBuilder();
@Test
public void testRepWithMonitoring() throws IOException, PCEPDeserializerException {
- final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry, this.viObjRegistry);
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder rBuilder = new RepliesBuilder();
public void testReqWithMonitoring() throws IOException, PCEPDeserializerException {
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.8.bin"));
- final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry, this.viObjRegistry);
+ final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry);
final PcreqMessageBuilder builder = new PcreqMessageBuilder();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.Requests> reqs1 = Lists.newArrayList();
@Test
public void testMonReqMsg() throws PCEPDeserializerException, IOException {
- final PCEPMonitoringRequestMessageParser parser = new PCEPMonitoringRequestMessageParser(this.objectRegistry, this.viObjRegistry);
+ final PCEPMonitoringRequestMessageParser parser = new PCEPMonitoringRequestMessageParser(this.objectRegistry);
final PcreqMessageBuilder builder = new PcreqMessageBuilder();
final MonitoringRequestBuilder monReqBuilder = new MonitoringRequestBuilder();
private static final int IGNORED = 7;
private final ObjectRegistry registry;
- private final VendorInformationObjectRegistry viRegistry;
protected AbstractMessageParser(final ObjectRegistry registry) {
this.registry = Preconditions.checkNotNull(registry);
- this.viRegistry = null;
- }
-
- protected AbstractMessageParser(final ObjectRegistry registry, final VendorInformationObjectRegistry viRegistry) {
- this.registry = Preconditions.checkNotNull(registry);
- this.viRegistry = Preconditions.checkNotNull(viRegistry);
}
/**
final ObjectHeader header = new ObjectHeaderImpl(flags.get(PROCESSED), flags.get(IGNORED));
if (VendorInformationUtil.isVendorInformationObject(objClass, objType)) {
- Preconditions.checkState(this.viRegistry != null);
final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(bytesToPass.readUnsignedInt());
- final Optional<? extends Object> obj = this.viRegistry.parseVendorInformationObject(enterpriseNumber, header, bytesToPass);
+ final Optional<? extends Object> obj = this.registry.parseVendorInformationObject(enterpriseNumber, header, bytesToPass);
if (obj.isPresent()) {
objs.add(obj.get());
}
protected final void serializeVendorInformationObjects(final List<VendorInformationObject> viObjects, final ByteBuf buffer) {
if (viObjects != null) {
for (final VendorInformationObject viObject : viObjects) {
- this.viRegistry.serializeVendorInformationObject(viObject, buffer);
+ this.registry.serializeVendorInformationObject(viObject, buffer);
}
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
-public interface ObjectRegistry {
+public interface ObjectRegistry extends VendorInformationObjectRegistry {
/**
* Finds parser for given object type and class in the registry. Delegates parsing to found parser.
*
*/
package org.opendaylight.protocol.pcep.spi.pojo;
+import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
import org.opendaylight.protocol.pcep.spi.UnknownObject;
+import org.opendaylight.protocol.pcep.spi.VendorInformationObjectRegistry;
import org.opendaylight.protocol.util.Values;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject;
import org.opendaylight.yangtools.yang.binding.DataContainer;
/**
private static final int MAX_OBJECT_TYPE = 15;
private static final int MAX_OBJECT_CLASS = 4;
+ private final VendorInformationObjectRegistry viRegistry;
+
+ public SimpleObjectRegistry(final VendorInformationObjectRegistry viRegistry) {
+ this.viRegistry = viRegistry;
+
+ }
+
private static int createKey(final int objectClass, final int objectType) {
Preconditions.checkArgument(objectClass >= 0 && objectClass <= Values.UNSIGNED_BYTE_MAX_VALUE);
Preconditions.checkArgument(objectType >= 0 && objectType <= MAX_OBJECT_TYPE);
}
serializer.serializeObject(object, buffer);
}
+
+ @Override
+ public Optional<? extends Object> parseVendorInformationObject(final EnterpriseNumber enterpriseNumber,
+ final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
+ return this.viRegistry.parseVendorInformationObject(enterpriseNumber, header, buffer);
+ }
+
+ @Override
+ public void serializeVendorInformationObject(final VendorInformationObject viObject, final ByteBuf buffer) {
+ this.viRegistry.serializeVendorInformationObject(viObject, buffer);
+ }
}
package org.opendaylight.protocol.pcep.spi.pojo;
import javax.annotation.concurrent.ThreadSafe;
-
import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
public class SimplePCEPExtensionProviderContext implements PCEPExtensionProviderContext {
private final SimpleLabelRegistry labelReg = new SimpleLabelRegistry();
private final SimpleMessageRegistry msgReg = new SimpleMessageRegistry();
- private final SimpleObjectRegistry objReg = new SimpleObjectRegistry();
+ private final SimpleVendorInformationObjectRegistry viObjReg = new SimpleVendorInformationObjectRegistry();
+ private final SimpleObjectRegistry objReg = new SimpleObjectRegistry(this.viObjReg);
private final SimpleEROSubobjectRegistry eroSubReg = new SimpleEROSubobjectRegistry();
private final SimpleRROSubobjectRegistry rroSubReg = new SimpleRROSubobjectRegistry();
private final SimpleXROSubobjectRegistry xroSubReg = new SimpleXROSubobjectRegistry();
private final SimpleTlvRegistry tlvReg = new SimpleTlvRegistry();
private final SimpleVendorInformationTlvRegistry viTlvReg = new SimpleVendorInformationTlvRegistry();
- private final SimpleVendorInformationObjectRegistry viObjReg = new SimpleVendorInformationObjectRegistry();
@Override
public final LabelRegistry getLabelHandlerRegistry() {
@Mock
private ObjectRegistry registry;
- @Mock
- private VendorInformationObjectRegistry viRegistry;
-
private class Abs extends AbstractMessageParser {
protected Abs(final ObjectRegistry registry) {
super(registry);
}
- protected Abs(final ObjectRegistry registry, final VendorInformationObjectRegistry viRegistry) {
- super(registry, viRegistry);
- }
-
@Override
public void serializeMessage(final Message message, final ByteBuf buffer) {
}
MockitoAnnotations.initMocks(this);
this.object = new ErrorObjectBuilder().setType((short) 1).setValue((short) 1).build();
this.viObject = new VendorInformationObjectBuilder().setEnterpriseNumber(EN).build();
- Mockito.doNothing().when(this.viRegistry).serializeVendorInformationObject(Mockito.any(VendorInformationObject.class), Mockito.any(ByteBuf.class));
- Mockito.doReturn(Optional.of(this.viObject)).when(this.viRegistry).parseVendorInformationObject(Mockito.eq(EN), Mockito.eq(new ObjectHeaderImpl(true, true)), Mockito.any(ByteBuf.class));
+ Mockito.doNothing().when(this.registry).serializeVendorInformationObject(Mockito.any(VendorInformationObject.class), Mockito.any(ByteBuf.class));
+ Mockito.doReturn(Optional.of(this.viObject)).when(this.registry).parseVendorInformationObject(Mockito.eq(EN), Mockito.eq(new ObjectHeaderImpl(true, true)), Mockito.any(ByteBuf.class));
Mockito.doNothing().when(this.registry).serializeObject(Mockito.any(Object.class), Mockito.any(ByteBuf.class));
Mockito.doReturn(this.object).when(this.registry).parseObject(13, 1, new ObjectHeaderImpl(true, true), Unpooled.wrappedBuffer(new byte[] { 0, 0, 1, 1 }));
}
@Test
public void testParseVendorInformationObject() throws PCEPDeserializerException {
- final Abs parser = new Abs(this.registry, this.viRegistry);
+ final Abs parser = new Abs(this.registry);
final ByteBuf buffer = Unpooled.buffer();
parser.serializeVendorInformationObjects(Lists.newArrayList(this.viObject), buffer);
- Mockito.verify(this.viRegistry, Mockito.only()).serializeVendorInformationObject(Mockito.any(VendorInformationObject.class), Mockito.any(ByteBuf.class));
+ Mockito.verify(this.registry, Mockito.only()).serializeVendorInformationObject(Mockito.any(VendorInformationObject.class), Mockito.any(ByteBuf.class));
final Message msg = parser.parseMessage(Unpooled.wrappedBuffer(new byte[] {0x22, 0x13, 0x00, 0x08, 0, 0, 0, 0 }), Collections.<Message> emptyList());