}
}
+ // Marker
+ grouping c-label;
+
grouping type1-label {
reference "https://tools.ietf.org/html/rfc3209#section-4.1";
+ uses c-label;
+
leaf type1-label {
type uint32;
mandatory true;
grouping generalized-label {
reference "https://tools.ietf.org/html/rfc3473#section-2.3";
+ uses c-label;
+
leaf generalized-label {
type binary;
mandatory true;
grouping waveband-switching-label {
reference "https://tools.ietf.org/html/rfc3473#section-2.4";
+ uses c-label;
+
leaf end-label {
type uint32;
mandatory true;
grouping generalized-channel-set-label {
reference "https://tools.ietf.org/html/rfc6002#section-3.2";
+ uses c-label;
+
list subobjects {
uses label-set;
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.impl;
+
+import org.opendaylight.protocol.concepts.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.LabelHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.LabelParser;
+import org.opendaylight.protocol.pcep.spi.LabelSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CLabel;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+public class SimpleLabelHandlerRegistry implements LabelHandlerRegistry {
+ private final HandlerRegistry<DataContainer, LabelParser, LabelSerializer> handlers = new HandlerRegistry<>();
+
+ @Override
+ public AutoCloseable registerLabelParser(final int cType, final LabelParser parser) {
+ Preconditions.checkArgument(cType >= 0 && cType <= 255);
+ return handlers.registerParser(cType, parser);
+ }
+
+ @Override
+ public LabelParser getLabelParser(final int cType) {
+ Preconditions.checkArgument(cType >= 0 && cType <= 255);
+ return handlers.getParser(cType);
+ }
+
+ @Override
+ public AutoCloseable registerLabelSerializer(final Class<? extends CLabel> labelClass, final LabelSerializer serializer) {
+ return handlers.registerSerializer(labelClass, serializer);
+ }
+
+ @Override
+ public LabelSerializer getLabelSerializer(final CLabel label) {
+ return handlers.getSerializer(label.getImplementedInterface());
+ }
+}
/**
*
*/
-public final class SimpleMessageHandlerFactory implements MessageHandlerRegistry {
+public final class SimpleMessageHandlerRegistry implements MessageHandlerRegistry {
private final HandlerRegistry<DataContainer, MessageParser, MessageSerializer> handlers = new HandlerRegistry<>();
@Override
import javax.annotation.concurrent.ThreadSafe;
+import org.opendaylight.protocol.pcep.spi.LabelHandlerRegistry;
import org.opendaylight.protocol.pcep.spi.MessageHandlerRegistry;
import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPProviderContext;
private static final PCEPProviderContext INSTANCE = new SingletonPCEPProviderContext();
}
- private final MessageHandlerRegistry msgReg = new SimpleMessageHandlerFactory();
+ private final LabelHandlerRegistry labelReg = new SimpleLabelHandlerRegistry();
+ private final MessageHandlerRegistry msgReg = new SimpleMessageHandlerRegistry();
private final ObjectHandlerRegistry objReg = new SimpleObjectHandlerRegistry();
private final SubobjectHandlerRegistry subobjReg = new SimpleSubobjectHandlerFactory();
private final TlvHandlerRegistry tlvReg = new SimpleTlvHandlerRegistry();
return Holder.INSTANCE;
}
+ @Override
+ public LabelHandlerRegistry getHandlerRegistry() {
+ return labelReg;
+ }
+
@Override
public MessageHandlerRegistry getMessageHandlerRegistry() {
return msgReg;
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CLabel;
+
+public interface LabelHandlerRegistry {
+ public AutoCloseable registerLabelParser(int cType, LabelParser parser);
+ public LabelParser getLabelParser(int cType);
+
+ public AutoCloseable registerLabelSerializer(Class<? extends CLabel> labelClass, LabelSerializer serializer);
+ public LabelSerializer getLabelSerializer(CLabel label);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.spi;
+
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CLabel;
+
+public interface LabelParser {
+ public CLabel parseLabel(final byte[] buffer) throws PCEPDeserializerException;
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CLabel;
+
+public interface LabelSerializer {
+
+ @Deprecated
+ public int getType();
+
+ public byte[] serializeSubobject(CLabel subobject);
+}
*
*/
public interface PCEPProviderContext {
+ public LabelHandlerRegistry getHandlerRegistry();
public MessageHandlerRegistry getMessageHandlerRegistry();
public ObjectHandlerRegistry getObjectHandlerRegistry();
public SubobjectHandlerRegistry getSubobjectHandlerRegistry();