BUG-47 : switched subobjects to generated source code. 42/1942/2
authorDana Kutenicsova <dkutenic@cisco.com>
Wed, 16 Oct 2013 12:14:36 +0000 (14:14 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Wed, 16 Oct 2013 20:53:30 +0000 (22:53 +0200)
Change-Id: I993fcc806e58dc472b36b15806908afe9b33205f
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
125 files changed:
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPOFCodes.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROAsNumberSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROExplicitExclusionRouteSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROGeneralizedLabelSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROIPPrefixSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROLabelSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROPathKeyWith128PCEIDSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROPathKeyWith32PCEIDSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROType1LabelSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROUnnumberedInterfaceSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROWavebandSwitchingLabelSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/ExcludeRouteSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/ExplicitRouteSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROAsNumberSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROAttributesSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROGeneralizedLabelSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROIPAddressSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROLabelSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROPathKeyWith128PCEIDSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROPathKeyWith32PCEIDSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROType1LabelSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROUnnumberedInterfaceSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROWavebandSwitchingLabelSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/ReportedRouteSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROAsNumberSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROIPPrefixSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROSRLGSubobject.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROSubobjectAttribute.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROUnnumberedInterfaceSubobject.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractMessageParser.java [moved from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractMessageParser.java with 92% similarity]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPEROSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPImplActivator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPOFCodesMapping.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPRROSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPXROSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleEROSubobjectHandlerFactory.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleMessageHandlerRegistry.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleRROSubobjectHandlerFactory.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleSubobjectHandlerFactory.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleXROSubobjectHandlerFactory.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SingletonPCEPProviderContext.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/AbstractObjectWithTlvsParser.java [moved from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java with 92% similarity]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCCreateMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPCloseMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPErrorMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPKeepAliveMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPNotificationMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPOpenMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPReplyMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPReportMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPRequestMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPUpdateRequestMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/AbstractEROWithSubobjectsParser.java [moved from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithSubobjectsParser.java with 70% similarity]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/AbstractRROWithSubobjectsParser.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/AbstractXROWithSubobjectsParser.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPBandwidthObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPClassTypeObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPCloseObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPEndPointsObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPErrorObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPExcludeRouteObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPExplicitRouteObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPGlobalConstraintsObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPIncludeRouteObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPLoadBalancingObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPLspObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPLspaObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPMetricObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPNoPathObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPNotificationObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPObjectiveFunctionObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPOpenObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPPathKeyObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPReportedRouteObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPRequestParameterObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPSrpObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPSvecObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROAsNumberSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROExplicitExclusionRouteSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROIpPrefixSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROLabelSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKeySubobjectParser.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKeyWith128PCEIDSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKeyWith32PCEIDSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROUnnumberedInterfaceSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/GeneralizedLabelParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROAsNumberSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROAttributesSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROGeneralizedLabelSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROIPv4AddressSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROIPv6AddressSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROIpPrefixSubobjectParser.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROLabelSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKeySubobjectParser.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKeyWith128PCEIDSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKeyWith32PCEIDSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROType1LabelSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROUnnumberedInterfaceSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROWavebandSwitchingLabelSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/Type1LabelParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/WavebandSwitchingLabelParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROAsNumberSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIPv4PrefixSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIPv6PrefixSubobjectParser.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIpPrefixSubobjectParser.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROPathKeySubobjectParser.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROSRLGSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROSubobjectAttributeMapping.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROUnnumberedInterfaceSubobjectParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPSubobjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPXROSubobjectParserTest.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/EROSubobjectHandlerRegistry.java [moved from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/SubobjectHandlerRegistry.java with 58% similarity]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/EROSubobjectParser.java [moved from pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROLabelParser.java with 54% similarity]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/EROSubobjectSerializer.java [new file with mode: 0644]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/LabelParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPProviderContext.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectHandlerRegistry.java [new file with mode: 0644]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectParser.java [moved from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/SubobjectParser.java with 75% similarity]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectSerializer.java [new file with mode: 0644]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RawMessage.java [deleted file]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/XROSubobjectHandlerRegistry.java [new file with mode: 0644]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/XROSubobjectParser.java [moved from pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROLabelParser.java with 53% similarity]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/XROSubobjectSerializer.java [moved from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/SubobjectSerializer.java with 73% similarity]
rsvp/.project [new file with mode: 0644]
rsvp/api/.project [new file with mode: 0644]

diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPOFCodes.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPOFCodes.java
deleted file mode 100644 (file)
index 7bcedbd..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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;
-
-/**
- * Enumerable representing ObjectiveFunction codes. Defined in RFC5541.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc5541#section-4">Objective
- *      Functions Definition</a>
- * @see <a href="http://tools.ietf.org/html/rfc6006#section-3.6.1">New Objective
- *      Functions [RFC6006]</a>
- */
-public enum PCEPOFCodes {
-       /**
-        * Minimum Cost Path
-        */
-       MCP,
-       /**
-        * Minimum Load Path
-        */
-       MLP,
-       /**
-        * Maximum residual Bandwidth Path
-        */
-       MBP,
-       /**
-        * Minimize aggregate Bandwidth Consumption
-        */
-       MBC,
-       /**
-        * Minimize the load of the Most Loaded Link
-        */
-       MLL,
-       /**
-        * Minimize Cumulative Cost of a set of paths
-        */
-       MCC,
-       /**
-        * Name: Shortest Path Tree (SPT)
-        * 
-        * Description: Minimize the maximum source-to-leaf cost with respect to a
-        * specific metric or to the TE metric used as the default metric when the
-        * metric is not specified (e.g., TE or IGP metric).
-        */
-       SPT,
-       /**
-        * Name: Minimum Cost Tree (MCT)
-        * 
-        * Description: Minimize the total cost of the tree, that is the sum of the
-        * costs of tree links, with respect to a specific metric or to the TE
-        * metric used as the default metric when the metric is not specified.
-        */
-       MCT;
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROAsNumberSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROAsNumberSubobject.java
deleted file mode 100644 (file)
index ed67457..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Structure of Autonomous System Number Subobject.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.4">Section 4.3.3.4.: Subobject 32: Autonomous System
- *      Number</a>
- */
-public class EROAsNumberSubobject extends ExplicitRouteSubobject {
-
-       private final AsNumber asnumber;
-
-       /**
-        * Constructs new ASNumber Subobject.
-        * 
-        * @param asnumber ASNumber
-        * @param loose boolean
-        */
-       public EROAsNumberSubobject(final AsNumber asnumber, final boolean loose) {
-               super(loose);
-               this.asnumber = asnumber;
-       }
-
-       /**
-        * Gets {@link AsNumber}.
-        * 
-        * @return ASNumber
-        */
-       public AsNumber getASNumber() {
-               return this.asnumber;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + ((this.asnumber == null) ? 0 : this.asnumber.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final EROAsNumberSubobject other = (EROAsNumberSubobject) obj;
-               if (this.asnumber == null) {
-                       if (other.asnumber != null)
-                               return false;
-               } else if (!this.asnumber.equals(other.asnumber))
-                       return false;
-               return true;
-       }
-
-       @Override
-       protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-               toStringHelper.add("asnumber", this.asnumber);
-               return super.addToStringAttributes(toStringHelper);
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROExplicitExclusionRouteSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROExplicitExclusionRouteSubobject.java
deleted file mode 100644 (file)
index a9515fe..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.List;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-public class EROExplicitExclusionRouteSubobject extends ExplicitRouteSubobject {
-    private final List<ExcludeRouteSubobject> xroSubobjets;
-
-    public EROExplicitExclusionRouteSubobject(List<ExcludeRouteSubobject> xroSubobjets) {
-       super();
-       this.xroSubobjets = xroSubobjets;
-    }
-
-    public List<ExcludeRouteSubobject> getXroSubobjets() {
-       return this.xroSubobjets;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + ((this.xroSubobjets == null) ? 0 : this.xroSubobjets.hashCode());
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final EROExplicitExclusionRouteSubobject other = (EROExplicitExclusionRouteSubobject) obj;
-       if (this.xroSubobjets == null) {
-           if (other.xroSubobjets != null)
-               return false;
-       } else if (!this.xroSubobjets.equals(other.xroSubobjets))
-           return false;
-       return true;
-    }
-
-    @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("xroSubobjets", this.xroSubobjets);
-               return super.addToStringAttributes(toStringHelper);
-       }
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROGeneralizedLabelSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROGeneralizedLabelSubobject.java
deleted file mode 100644 (file)
index f9c9b4a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Structure of Generalized Label subobject
- *
- * @see <a href="http://tools.ietf.org/html/rfc3471#section-3.2">3.2.
- *      Generalized Label</a>
- */
-public class EROGeneralizedLabelSubobject extends EROLabelSubobject {
-
-    private final byte[] label;
-
-    public EROGeneralizedLabelSubobject(byte[] label, boolean upStream, boolean loose) {
-       super(upStream);
-
-       if (label.length % 4 != 0)
-           throw new IllegalArgumentException("Length of label is not multiple of 4.");
-
-       this.label = label;
-    }
-
-    public byte[] getLabel() {
-       return this.label;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + Arrays.hashCode(this.label);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final EROGeneralizedLabelSubobject other = (EROGeneralizedLabelSubobject) obj;
-       if (!Arrays.equals(this.label, other.label))
-           return false;
-       return true;
-    }
-
-    @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("label", this.label);
-               return super.addToStringAttributes(toStringHelper);
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROIPPrefixSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROIPPrefixSubobject.java
deleted file mode 100644 (file)
index 6f4f9c8..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Parametrized structure of IP Prefix Subobject.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.2">Section 4.3.3.2.: Subobject 1: IPv4 prefix</a> and
- *      <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.3">Section 4.3.3.2.: Subobject 2: IPv6 prefix</a>
- * 
- * @param <T> subtype of Prefix
- */
-public class EROIPPrefixSubobject extends ExplicitRouteSubobject {
-
-       private final IpPrefix prefix;
-
-       /**
-        * Constructs IPPrefix Subobject.
-        * 
-        * @param prefix T
-        * @param loose boolean
-        */
-       public EROIPPrefixSubobject(final IpPrefix prefix, final boolean loose) {
-               super(loose);
-               this.prefix = prefix;
-       }
-
-       /**
-        * Gets specific {@link Prefix}.
-        * 
-        * @return prefix T
-        */
-       public IpPrefix getPrefix() {
-               return this.prefix;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + ((this.prefix == null) ? 0 : this.prefix.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final EROIPPrefixSubobject other = (EROIPPrefixSubobject) obj;
-               if (this.prefix == null) {
-                       if (other.prefix != null)
-                               return false;
-               } else if (!this.prefix.equals(other.prefix))
-                       return false;
-               return true;
-       }
-
-       @Override
-       protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-               toStringHelper.add("prefix", this.prefix);
-               return super.addToStringAttributes(toStringHelper);
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROLabelSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROLabelSubobject.java
deleted file mode 100644 (file)
index e2712ca..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.subobject;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Structure of Label subobject.
- *
- * @see <a href="http://tools.ietf.org/html/rfc3473#section-5.1">Label ERO
- *      subobject</a>
- */
-
-public abstract class EROLabelSubobject extends ExplicitRouteSubobject {
-
-    private final boolean upStream;
-
-    /**
-     * Constructs new Label subobject.
-     *
-     * @param upStream
-     *            if set label is upstream
-     * @param label
-     *            Label
-     * @param loose
-     *            boolean
-     */
-    public EROLabelSubobject(boolean upStream) {
-       super(false);
-       this.upStream = upStream;
-    }
-
-    public boolean isUpStream() {
-       return this.upStream;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + (this.upStream ? 1231 : 1237);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final EROLabelSubobject other = (EROLabelSubobject) obj;
-       if (this.upStream != other.upStream)
-           return false;
-       return true;
-    }
-
-    @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("upStream", this.upStream);
-               return super.addToStringAttributes(toStringHelper);
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROPathKeyWith128PCEIDSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROPathKeyWith128PCEIDSubobject.java
deleted file mode 100644 (file)
index 1efb310..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-public class EROPathKeyWith128PCEIDSubobject extends ExplicitRouteSubobject {
-
-    private final int pathKey;
-
-    private final byte[] pceId;
-
-    public EROPathKeyWith128PCEIDSubobject(int pathKey, byte[] pceId, boolean loose) {
-       super(loose);
-       this.pathKey = pathKey;
-       if (pceId == null)
-           throw new IllegalArgumentException("PCE ID can't be null.");
-
-       if (pceId.length != 16)
-           throw new IllegalArgumentException("PCE ID is not 16 bytes long.");
-
-       this.pceId = pceId;
-    }
-
-    public int getPathKey() {
-       return this.pathKey;
-    }
-
-    public byte[] getPceId() {
-       return this.pceId;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + this.pathKey;
-       result = prime * result + Arrays.hashCode(this.pceId);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final EROPathKeyWith128PCEIDSubobject other = (EROPathKeyWith128PCEIDSubobject) obj;
-       if (this.pathKey != other.pathKey)
-           return false;
-       if (!Arrays.equals(this.pceId, other.pceId))
-           return false;
-       return true;
-    }
-
-    @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("pathKey", this.pathKey);
-               toStringHelper.add("pceId", this.pceId);
-               return super.addToStringAttributes(toStringHelper);
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROPathKeyWith32PCEIDSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROPathKeyWith32PCEIDSubobject.java
deleted file mode 100644 (file)
index d2976cb..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-public class EROPathKeyWith32PCEIDSubobject extends ExplicitRouteSubobject {
-
-    private final int pathKey;
-
-    private final byte[] pceId;
-
-    public EROPathKeyWith32PCEIDSubobject(int pathKey, byte[] pceId, boolean loose) {
-       super(loose);
-       this.pathKey = pathKey;
-       if (pceId == null)
-           throw new IllegalArgumentException("PCE ID can't be null.");
-
-       if (pceId.length != 4)
-           throw new IllegalArgumentException("PCE ID is not 4 bytes long.");
-
-       this.pceId = pceId;
-    }
-
-    public int getPathKey() {
-       return this.pathKey;
-    }
-
-    public byte[] getPceId() {
-       return this.pceId;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + this.pathKey;
-       result = prime * result + Arrays.hashCode(this.pceId);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final EROPathKeyWith32PCEIDSubobject other = (EROPathKeyWith32PCEIDSubobject) obj;
-       if (this.pathKey != other.pathKey)
-           return false;
-       if (!Arrays.equals(this.pceId, other.pceId))
-           return false;
-       return true;
-    }
-
-    @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("pathKey", this.pathKey);
-               toStringHelper.add("pceId", this.pceId);
-               return super.addToStringAttributes(toStringHelper);
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROType1LabelSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROType1LabelSubobject.java
deleted file mode 100644 (file)
index 926791a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.subobject;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Structure of Type 1 Label subobject
- *
- * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.1">4.1. Label
- *      Object</a>
- */
-public class EROType1LabelSubobject extends EROLabelSubobject {
-
-    private final long label;
-
-    public EROType1LabelSubobject(long label, boolean upStream, boolean loose) {
-       super(upStream);
-       this.label = label;
-    }
-
-    public long getLabel() {
-       return this.label;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + (int) (this.label ^ (this.label >>> 32));
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final EROType1LabelSubobject other = (EROType1LabelSubobject) obj;
-       if (this.label != other.label)
-           return false;
-       return true;
-    }
-
-    @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("label", this.label);
-               return super.addToStringAttributes(toStringHelper);
-       }
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROUnnumberedInterfaceSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROUnnumberedInterfaceSubobject.java
deleted file mode 100644 (file)
index 33aa8f3..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.UnnumberedSubobject;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Structure of unnumbered Interface Subobject.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc3477">Section 4: Signalling Unnumbered Links in EROs</a>
- */
-public class EROUnnumberedInterfaceSubobject extends ExplicitRouteSubobject {
-       private final UnnumberedSubobject interfaceID;
-       private final Ipv4Address routerID;
-
-       /**
-        * Constructs new Unnumbered Interface Subobject.
-        * 
-        * @param routerID IPv4Address
-        * @param interfaceID UnnumberedInterfaceIdentifier
-        * @param loose boolean
-        */
-       public EROUnnumberedInterfaceSubobject(final Ipv4Address routerID, final UnnumberedSubobject interfaceID, final boolean loose) {
-               super(loose);
-               this.routerID = routerID;
-               this.interfaceID = interfaceID;
-       }
-
-       /**
-        * Gets {@link IPv4Address} representation of router ID.
-        * 
-        * @return IPv4Address
-        */
-       public Ipv4Address getRouterID() {
-               return this.routerID;
-       }
-
-       /**
-        * Gets {@link UnnumberedSubobject} representation of Interface ID.
-        * 
-        * @return UnnumberedSubobject
-        */
-       public UnnumberedSubobject getInterfaceID() {
-               return this.interfaceID;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + ((this.interfaceID == null) ? 0 : this.interfaceID.hashCode());
-               result = prime * result + ((this.routerID == null) ? 0 : this.routerID.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final EROUnnumberedInterfaceSubobject other = (EROUnnumberedInterfaceSubobject) obj;
-               if (this.interfaceID == null) {
-                       if (other.interfaceID != null)
-                               return false;
-               } else if (!this.interfaceID.equals(other.interfaceID))
-                       return false;
-               if (this.routerID == null) {
-                       if (other.routerID != null)
-                               return false;
-               } else if (!this.routerID.equals(other.routerID))
-                       return false;
-               return true;
-       }
-
-       @Override
-       public String toString() {
-               final StringBuilder builder = new StringBuilder();
-               builder.append("EROUnnumberedInterfaceSubobject [interfaceID=");
-               builder.append(this.interfaceID);
-               builder.append(", routerID=");
-               builder.append(this.routerID);
-               builder.append(", loose=");
-               builder.append(this.loose);
-               builder.append("]");
-               return builder.toString();
-       }
-
-       @Override
-       protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-               toStringHelper.add("interfaceID", this.interfaceID);
-               toStringHelper.add("routerID", this.routerID);
-               toStringHelper.add("loose", this.loose);
-               return super.addToStringAttributes(toStringHelper);
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROWavebandSwitchingLabelSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROWavebandSwitchingLabelSubobject.java
deleted file mode 100644 (file)
index 0ca4fc4..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.subobject;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Structure of Generalized Label subobject
- *
- * @see <a href="http://tools.ietf.org/html/rfc3473#section-2.4">2.4. Waveband
- *      Switching Object </a>
- */
-public class EROWavebandSwitchingLabelSubobject extends EROLabelSubobject {
-
-    private final long wavebandId;
-
-    private final long startLabel;
-
-    private final long endLabel;
-
-    public EROWavebandSwitchingLabelSubobject(long wavebandId, long startLabel, long endLabel, boolean upStream, boolean loose) {
-       super(upStream);
-       this.wavebandId = wavebandId;
-       this.startLabel = startLabel;
-       this.endLabel = endLabel;
-    }
-
-    public long getWavebandId() {
-       return this.wavebandId;
-    }
-
-    public long getStartLabel() {
-       return this.startLabel;
-    }
-
-    public long getEndLabel() {
-       return this.endLabel;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + (int) (this.endLabel ^ (this.endLabel >>> 32));
-       result = prime * result + (int) (this.startLabel ^ (this.startLabel >>> 32));
-       result = prime * result + (int) (this.wavebandId ^ (this.wavebandId >>> 32));
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final EROWavebandSwitchingLabelSubobject other = (EROWavebandSwitchingLabelSubobject) obj;
-       if (this.endLabel != other.endLabel)
-           return false;
-       if (this.startLabel != other.startLabel)
-           return false;
-       if (this.wavebandId != other.wavebandId)
-           return false;
-       return true;
-    }
-
-    @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("wavebandId", this.wavebandId);
-               toStringHelper.add("startLabel", this.startLabel);
-               toStringHelper.add("endLabel", this.endLabel);
-               return super.addToStringAttributes(toStringHelper);
-       }
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/ExcludeRouteSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/ExcludeRouteSubobject.java
deleted file mode 100644 (file)
index 644115c..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.subobject;
-
-public abstract class ExcludeRouteSubobject {
-
-       protected final boolean mandatory;
-
-       public ExcludeRouteSubobject(boolean mandatory) {
-               this.mandatory = mandatory;
-       }
-
-       public boolean isMandatory() {
-               return this.mandatory;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + (this.mandatory ? 1231 : 1237);
-               return result;
-       }
-
-       @Override
-       public boolean equals(Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final ExcludeRouteSubobject other = (ExcludeRouteSubobject) obj;
-               if (this.mandatory != other.mandatory)
-                       return false;
-               return true;
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/ExplicitRouteSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/ExplicitRouteSubobject.java
deleted file mode 100644 (file)
index 4ac1cef..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.subobject;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Base class for Explicit route subobjects.
- *
- * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3">4.3. Explicit
- *      Route Object</a>
- */
-public abstract class ExplicitRouteSubobject {
-    protected final boolean loose;
-
-    protected ExplicitRouteSubobject() {
-       this.loose = false;
-    }
-
-    protected ExplicitRouteSubobject(boolean loose) {
-       this.loose = loose;
-    }
-
-    /**
-     * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.1">Strict
-     *      and Loose Subobjects</a>
-     *
-     * @return true if L flag is set and false if is not.
-     */
-    public boolean isLoose() {
-       return this.loose;
-    }
-
-       @Override
-       public String toString(){
-               return this.addToStringAttributes(Objects.toStringHelper(this)).toString();
-       }
-
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("loose", this.loose);
-               return toStringHelper;
-       }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = 1;
-       result = prime * result + (this.loose ? 1231 : 1237);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (obj == null)
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final ExplicitRouteSubobject other = (ExplicitRouteSubobject) obj;
-       if (this.loose != other.loose)
-           return false;
-       return true;
-    }
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROAsNumberSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROAsNumberSubobject.java
deleted file mode 100644 (file)
index ba5dd02..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-
-/**
- * Structure of Autonomous System Number Subobject.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.4">Section 4.3.3.4.: Subobject 32: Autonomous System
- *      Number</a>
- */
-public class RROAsNumberSubobject extends ReportedRouteSubobject {
-
-       private final AsNumber asnumber;
-
-       /**
-        * Constructs new ASNumber Subobject.
-        * 
-        * @param asnumber ASNumber
-        */
-       public RROAsNumberSubobject(final AsNumber asnumber) {
-               super();
-               this.asnumber = asnumber;
-       }
-
-       /**
-        * Gets {@link AsNumber}.
-        * 
-        * @return ASNumber
-        */
-       public AsNumber getASNumber() {
-               return this.asnumber;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + ((this.asnumber == null) ? 0 : this.asnumber.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final RROAsNumberSubobject other = (RROAsNumberSubobject) obj;
-               if (this.asnumber == null) {
-                       if (other.asnumber != null)
-                               return false;
-               } else if (!this.asnumber.equals(other.asnumber))
-                       return false;
-               return true;
-       }
-
-       @Override
-       public String toString() {
-               final StringBuilder builder = new StringBuilder();
-               builder.append("RROAsNumberSubobject [asnumber=");
-               builder.append(this.asnumber);
-               builder.append("]");
-               return builder.toString();
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROAttributesSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROAttributesSubobject.java
deleted file mode 100644 (file)
index 5020094..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-public class RROAttributesSubobject extends ReportedRouteSubobject {
-
-    private final byte[] attributes;
-
-    public RROAttributesSubobject(byte[] attributes) {
-       super();
-
-       if (attributes.length % 4 != 0)
-           throw new IllegalArgumentException("Attributes have to be multiple of 4.");
-
-       this.attributes = attributes;
-    }
-
-    public byte[] getAttributes() {
-       return this.attributes;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = 1;
-       result = prime * result + Arrays.hashCode(this.attributes);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (obj == null)
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final RROAttributesSubobject other = (RROAttributesSubobject) obj;
-       if (!Arrays.equals(this.attributes, other.attributes))
-           return false;
-       return true;
-    }
-
-    @Override
-    public String toString() {
-       final StringBuilder builder = new StringBuilder();
-       builder.append("RROAttributesSubobject [attributes=");
-       builder.append(Arrays.toString(this.attributes));
-       builder.append("]");
-       return builder.toString();
-    }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROGeneralizedLabelSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROGeneralizedLabelSubobject.java
deleted file mode 100644 (file)
index a7ad497..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Structure of Generalized Label subobject
- *
- * @see <a href="http://tools.ietf.org/html/rfc3471#section-3.2">3.2.
- *      Generalized Label</a>
- */
-public class RROGeneralizedLabelSubobject extends RROLabelSubobject {
-
-    private final byte[] label;
-
-    public RROGeneralizedLabelSubobject(byte[] label, boolean upStream) {
-       super(upStream);
-
-       if (label.length % 4 != 0)
-           throw new IllegalArgumentException("Length of label is not multiple of 4.");
-
-       this.label = label;
-    }
-
-    public byte[] getLabel() {
-       return this.label;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + Arrays.hashCode(this.label);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final RROGeneralizedLabelSubobject other = (RROGeneralizedLabelSubobject) obj;
-       if (!Arrays.equals(this.label, other.label))
-           return false;
-       return true;
-    }
-
-       @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("label", this.label);
-               return super.addToStringAttributes(toStringHelper);
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROIPAddressSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROIPAddressSubobject.java
deleted file mode 100644 (file)
index 90a75b7..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-
-/**
- * Parametrized structure of RRO IP Address Subobject.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.4.1.1">Section 4.4.1.1: Subobject 1: IPv4 address</a> and
- *      <a href="http://tools.ietf.org/html/rfc3209#section-4.4.1.2">Section 4.4.1.2: Subobject 2: IPv6 address</a>
- * 
- * @param <T> subtype of Prefix
- */
-public class RROIPAddressSubobject extends ReportedRouteSubobject {
-
-       private final IpPrefix prefix;
-
-       /**
-        * Local protection available
-        */
-       private final boolean localProtectionAvailable;
-
-       /**
-        * Local protection in use
-        */
-       private final boolean localProtectionInUse;
-
-       /**
-        * Constructs IPPrefix Subobject.
-        * 
-        * @param prefix T
-        * @param localProtectionAvailable boolean
-        * @param localProtectionInUse boolean
-        */
-       public RROIPAddressSubobject(final IpPrefix prefix, final boolean localProtectionAvailable, final boolean localProtectionInUse) {
-               super();
-               this.prefix = prefix;
-               this.localProtectionAvailable = localProtectionAvailable;
-               this.localProtectionInUse = localProtectionInUse;
-       }
-
-       /**
-        * Gets specific {@link Prefix}.
-        * 
-        * @return prefix T
-        */
-       public IpPrefix getPrefix() {
-               return this.prefix;
-       }
-
-       /**
-        * Returns tru if local protection is available.
-        * 
-        * @return boolean
-        */
-       public boolean isLocalProtectionAvailable() {
-               return this.localProtectionAvailable;
-       }
-
-       /**
-        * Returns true if local protection is in use
-        * 
-        * @return boolean
-        */
-       public boolean isLocalProtectionInUse() {
-               return this.localProtectionInUse;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + (this.localProtectionAvailable ? 1231 : 1237);
-               result = prime * result + (this.localProtectionInUse ? 1231 : 1237);
-               result = prime * result + ((this.prefix == null) ? 0 : this.prefix.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final RROIPAddressSubobject other = (RROIPAddressSubobject) obj;
-               if (this.localProtectionAvailable != other.localProtectionAvailable)
-                       return false;
-               if (this.localProtectionInUse != other.localProtectionInUse)
-                       return false;
-               if (this.prefix == null) {
-                       if (other.prefix != null)
-                               return false;
-               } else if (!this.prefix.equals(other.prefix))
-                       return false;
-               return true;
-       }
-
-       @Override
-       public String toString() {
-               final StringBuilder builder = new StringBuilder();
-               builder.append("RROIPAddressSubobject [prefix=");
-               builder.append(this.prefix);
-               builder.append(", lpa=");
-               builder.append(this.localProtectionAvailable);
-               builder.append(", lpiu=");
-               builder.append(this.localProtectionInUse);
-               builder.append("]");
-               return builder.toString();
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROLabelSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROLabelSubobject.java
deleted file mode 100644 (file)
index 781faf7..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.subobject;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Structure of Label subobject.
- *
- * @see <a href="http://tools.ietf.org/html/rfc3473#section-5.1">Label ERO
- *      subobject</a>
- */
-public abstract class RROLabelSubobject extends ReportedRouteSubobject {
-
-    private final boolean upStream;
-
-    /**
-     * Constructs new Label subobject.
-     *
-     * @param upStream
-     *            if set label is upstream
-     * @param label
-     *            Label
-     * @param loose
-     *            boolean
-     */
-    public RROLabelSubobject(boolean upStream) {
-       this.upStream = upStream;
-    }
-
-    public boolean isUpStream() {
-       return this.upStream;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + (this.upStream ? 1231 : 1237);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final RROLabelSubobject other = (RROLabelSubobject) obj;
-       if (this.upStream != other.upStream)
-           return false;
-       return true;
-    }
-
-    @Override
-       public String toString(){
-               return this.addToStringAttributes(Objects.toStringHelper(this)).toString();
-       }
-
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("upStream", this.upStream);
-               return toStringHelper;
-       }
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROPathKeyWith128PCEIDSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROPathKeyWith128PCEIDSubobject.java
deleted file mode 100644 (file)
index f9eed59..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-public class RROPathKeyWith128PCEIDSubobject extends ReportedRouteSubobject {
-
-    private final int pathKey;
-
-    private final byte[] pceId;
-
-    public RROPathKeyWith128PCEIDSubobject(int pathKey, byte[] pceId) {
-       super();
-       this.pathKey = pathKey;
-       if (pceId == null)
-           throw new IllegalArgumentException("PCE ID can't be null.");
-
-       if (pceId.length != 16)
-           throw new IllegalArgumentException("PCE ID is not 16 bytes long.");
-
-       this.pceId = pceId;
-    }
-
-    public int getPathKey() {
-       return this.pathKey;
-    }
-
-    public byte[] getPceId() {
-       return this.pceId;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = 1;
-       result = prime * result + this.pathKey;
-       result = prime * result + Arrays.hashCode(this.pceId);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (obj == null)
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final RROPathKeyWith128PCEIDSubobject other = (RROPathKeyWith128PCEIDSubobject) obj;
-       if (this.pathKey != other.pathKey)
-           return false;
-       if (!Arrays.equals(this.pceId, other.pceId))
-           return false;
-       return true;
-    }
-
-    @Override
-    public String toString() {
-       final StringBuilder builder = new StringBuilder();
-       builder.append("RROPathKeyWith128PCEIDSubobject [pathKey=");
-       builder.append(this.pathKey);
-       builder.append(", pceId=");
-       builder.append(Arrays.toString(this.pceId));
-       builder.append("]");
-       return builder.toString();
-    }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROPathKeyWith32PCEIDSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROPathKeyWith32PCEIDSubobject.java
deleted file mode 100644 (file)
index b78a3b2..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-public class RROPathKeyWith32PCEIDSubobject extends ReportedRouteSubobject {
-
-    private final int pathKey;
-
-    private final byte[] pceId;
-
-    public RROPathKeyWith32PCEIDSubobject(int pathKey, byte[] pceId) {
-       super();
-       this.pathKey = pathKey;
-       if (pceId == null)
-           throw new IllegalArgumentException("PCE ID can't be null.");
-
-       if (pceId.length != 4)
-           throw new IllegalArgumentException("PCE ID is not 4 bytes long.");
-
-       this.pceId = pceId;
-    }
-
-    public int getPathKey() {
-       return this.pathKey;
-    }
-
-    public byte[] getPceId() {
-       return this.pceId;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = 1;
-       result = prime * result + this.pathKey;
-       result = prime * result + Arrays.hashCode(this.pceId);
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (obj == null)
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final RROPathKeyWith32PCEIDSubobject other = (RROPathKeyWith32PCEIDSubobject) obj;
-       if (this.pathKey != other.pathKey)
-           return false;
-       if (!Arrays.equals(this.pceId, other.pceId))
-           return false;
-       return true;
-    }
-
-    @Override
-    public String toString() {
-       final StringBuilder builder = new StringBuilder();
-       builder.append("RROPathKeyWith32PCEIDSubobject [pathKey=");
-       builder.append(this.pathKey);
-       builder.append(", pceId=");
-       builder.append(Arrays.toString(this.pceId));
-       builder.append("]");
-       return builder.toString();
-    }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROType1LabelSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROType1LabelSubobject.java
deleted file mode 100644 (file)
index 60ea64b..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.subobject;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Structure of Type 1 Label subobject
- *
- * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.1">4.1. Label
- *      Object</a>
- */
-public class RROType1LabelSubobject extends RROLabelSubobject {
-
-    private final long label;
-
-    public RROType1LabelSubobject(long label, boolean upStream) {
-       super(upStream);
-       this.label = label;
-    }
-
-    public long getLabel() {
-       return this.label;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + (int) (this.label ^ (this.label >>> 32));
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final RROType1LabelSubobject other = (RROType1LabelSubobject) obj;
-       if (this.label != other.label)
-           return false;
-       return true;
-    }
-
-       @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("label", this.label);
-               return super.addToStringAttributes(toStringHelper);
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROUnnumberedInterfaceSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROUnnumberedInterfaceSubobject.java
deleted file mode 100644 (file)
index ed19636..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.UnnumberedSubobject;
-
-/**
- * Structure of unnumbered Iterface Subobject.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc3477">Section 4: Signalling Unnumbered Links in EROs</a>
- */
-public class RROUnnumberedInterfaceSubobject extends ReportedRouteSubobject {
-       private final UnnumberedSubobject interfaceID;
-       private final Ipv4Address routerID;
-
-       /**
-        * Constructs new Unnumbered Interface Subobject.
-        * 
-        * @param routerID IPv4Address
-        * @param interfaceID UnnumberedInterfaceIdentifier
-        */
-       public RROUnnumberedInterfaceSubobject(final Ipv4Address routerID, final UnnumberedSubobject interfaceID) {
-               super();
-               this.routerID = routerID;
-               this.interfaceID = interfaceID;
-       }
-
-       /**
-        * Gets {@link IPv4Address} representation of router ID.
-        * 
-        * @return IPv4Address
-        */
-       public Ipv4Address getRouterID() {
-               return this.routerID;
-       }
-
-       /**
-        * Gets {@link UnnumberedSubobject} representation of Interface ID.
-        * 
-        * @return UnnumberedSubobject
-        */
-       public UnnumberedSubobject getInterfaceID() {
-               return this.interfaceID;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + ((this.interfaceID == null) ? 0 : this.interfaceID.hashCode());
-               result = prime * result + ((this.routerID == null) ? 0 : this.routerID.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final RROUnnumberedInterfaceSubobject other = (RROUnnumberedInterfaceSubobject) obj;
-               if (this.interfaceID == null) {
-                       if (other.interfaceID != null)
-                               return false;
-               } else if (!this.interfaceID.equals(other.interfaceID))
-                       return false;
-               if (this.routerID == null) {
-                       if (other.routerID != null)
-                               return false;
-               } else if (!this.routerID.equals(other.routerID))
-                       return false;
-               return true;
-       }
-
-       @Override
-       public String toString() {
-               final StringBuilder builder = new StringBuilder();
-               builder.append("RROUnnumberedInterfaceSubobject [interfaceID=");
-               builder.append(this.interfaceID);
-               builder.append(", routerID=");
-               builder.append(this.routerID);
-               builder.append("]");
-               return builder.toString();
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROWavebandSwitchingLabelSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROWavebandSwitchingLabelSubobject.java
deleted file mode 100644 (file)
index b07ee8d..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.subobject;
-
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Structure of Generalized Label subobject
- *
- * @see <a href="http://tools.ietf.org/html/rfc3473#section-2.4">2.4. Waveband
- *      Switching Object </a>
- */
-public class RROWavebandSwitchingLabelSubobject extends RROLabelSubobject {
-
-    private final long wavebandId;
-
-    private final long startLabel;
-
-    private final long endLabel;
-
-    public RROWavebandSwitchingLabelSubobject(long wavebandId, long startLabel, long endLabel, boolean upStream) {
-       super(upStream);
-       this.wavebandId = wavebandId;
-       this.startLabel = startLabel;
-       this.endLabel = endLabel;
-    }
-
-    public long getWavebandId() {
-       return this.wavebandId;
-    }
-
-    public long getStartLabel() {
-       return this.startLabel;
-    }
-
-    public long getEndLabel() {
-       return this.endLabel;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       int result = super.hashCode();
-       result = prime * result + (int) (this.endLabel ^ (this.endLabel >>> 32));
-       result = prime * result + (int) (this.startLabel ^ (this.startLabel >>> 32));
-       result = prime * result + (int) (this.wavebandId ^ (this.wavebandId >>> 32));
-       return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (!super.equals(obj))
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       final RROWavebandSwitchingLabelSubobject other = (RROWavebandSwitchingLabelSubobject) obj;
-       if (this.endLabel != other.endLabel)
-           return false;
-       if (this.startLabel != other.startLabel)
-           return false;
-       if (this.wavebandId != other.wavebandId)
-           return false;
-       return true;
-    }
-
-       @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
-               toStringHelper.add("wavebandId", this.wavebandId);
-               toStringHelper.add("startLabel", this.startLabel);
-               toStringHelper.add("endLabel", this.endLabel);
-               return super.addToStringAttributes(toStringHelper);
-       }
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/ReportedRouteSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/ReportedRouteSubobject.java
deleted file mode 100644 (file)
index f2294db..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.subobject;
-
-public abstract class ReportedRouteSubobject {
-    protected ReportedRouteSubobject() {
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-       if (this == obj)
-           return true;
-       if (obj == null)
-           return false;
-       if (this.getClass() != obj.getClass())
-           return false;
-       return true;
-    }
-
-    @Override
-    public int hashCode() {
-       final int prime = 31;
-       return prime;
-    }
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROAsNumberSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROAsNumberSubobject.java
deleted file mode 100644 (file)
index f6ce3f5..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-
-/**
- * Structure of Autonomous System Number Subobject. Defined in RFC5521.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route Object definition</a>
- */
-public class XROAsNumberSubobject extends ExcludeRouteSubobject {
-
-       private final AsNumber asnumber;
-
-       /**
-        * Constructs new ASNumber Subobject.
-        * 
-        * @param asnumber ASNumber
-        * @param mandatory boolean
-        */
-       public XROAsNumberSubobject(final AsNumber asnumber, final boolean mandatory) {
-               super(mandatory);
-               this.asnumber = asnumber;
-       }
-
-       /**
-        * Gets {@link AsNumber}.
-        * 
-        * @return ASNumber
-        */
-       public AsNumber getASNumber() {
-               return this.asnumber;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + ((this.asnumber == null) ? 0 : this.asnumber.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final XROAsNumberSubobject other = (XROAsNumberSubobject) obj;
-               if (this.asnumber == null) {
-                       if (other.asnumber != null)
-                               return false;
-               } else if (!this.asnumber.equals(other.asnumber))
-                       return false;
-               return true;
-       }
-
-       @Override
-       public String toString() {
-               final StringBuilder builder = new StringBuilder();
-               builder.append("XROAsNumberSubobject [asnumber=");
-               builder.append(this.asnumber);
-               builder.append(", mandatory=");
-               builder.append(this.mandatory);
-               builder.append("]");
-               return builder.toString();
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROIPPrefixSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROIPPrefixSubobject.java
deleted file mode 100644 (file)
index 04946b0..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-
-/**
- * Parametrized structure of IP Prefix Subobject. Defined in RFC5521.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route Object definition</a>
- * 
- * @param <T> subtype of Prefix
- */
-public class XROIPPrefixSubobject extends ExcludeRouteSubobject {
-
-       private final XROSubobjectAttribute attribute;
-
-       private final IpPrefix prefix;
-
-       /**
-        * Constructs IPPrefix Subobject.
-        * 
-        * @param prefix T
-        * @param mandatory boolean
-        * @param attribute XROSubobjectAttribute
-        */
-       public XROIPPrefixSubobject(final IpPrefix prefix, final boolean mandatory, final XROSubobjectAttribute attribute) {
-               super(mandatory);
-               this.attribute = attribute;
-               this.prefix = prefix;
-       }
-
-       /**
-        * Gets specific {@link Prefix}.
-        * 
-        * @return prefix T
-        */
-       public IpPrefix getPrefix() {
-               return this.prefix;
-       }
-
-       /**
-        * Gets the attribute of the subobject
-        * 
-        * @return the attribute
-        */
-       public XROSubobjectAttribute getAttribute() {
-               return this.attribute;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = super.hashCode();
-               result = prime * result + ((this.attribute == null) ? 0 : this.attribute.hashCode());
-               result = prime * result + ((this.prefix == null) ? 0 : this.prefix.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (!super.equals(obj))
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final XROIPPrefixSubobject other = (XROIPPrefixSubobject) obj;
-               if (this.attribute != other.attribute)
-                       return false;
-               if (this.prefix == null) {
-                       if (other.prefix != null)
-                               return false;
-               } else if (!this.prefix.equals(other.prefix))
-                       return false;
-               return true;
-       }
-
-       @Override
-       public String toString() {
-               final StringBuilder builder = new StringBuilder();
-               builder.append("XROIPPrefixSubobject [attribute=");
-               builder.append(this.attribute);
-               builder.append(", prefix=");
-               builder.append(this.prefix);
-               builder.append(", mandatory=");
-               builder.append(this.mandatory);
-               builder.append("]");
-               return builder.toString();
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROSRLGSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROSRLGSubobject.java
deleted file mode 100644 (file)
index 1a0e90e..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.subobject;
-
-/**
- * Structure of Shared Risk Link Group Subobject. Defined in RFC5521.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route Object definition</a>
- */
-public class XROSRLGSubobject extends ExcludeRouteSubobject {
-
-       private final XROSubobjectAttribute attribute;
-
-       // private final SharedRiskLinkGroup srlgId;
-
-       /**
-        * Constructs new Shared Risk Link Group Subobject.
-        * 
-        * @param srlgId SharedRiskLinkGroup
-        * @param mandatory boolean
-        */
-       public XROSRLGSubobject(final boolean mandatory) {
-               super(mandatory);
-               this.attribute = XROSubobjectAttribute.SRLG;
-               // this.srlgId = srlgId;
-       }
-
-       /**
-        * Gets the Shared Risk Link Group.
-        * 
-        * @return SharedRiskLinkGroup
-        */
-       // public SharedRiskLinkGroup getSrlgId() {
-       // return this.srlgId;
-       // }
-
-       /**
-        * Gets the attribute of the subobject
-        * 
-        * @return the attribute
-        */
-       public XROSubobjectAttribute getAttribute() {
-               return this.attribute;
-       }
-
-       @Override
-       public String toString() {
-               final StringBuilder builder = new StringBuilder();
-               builder.append("XROSRLGSubobject [attribute=");
-               builder.append(this.attribute);
-               builder.append(", mandatory=");
-               builder.append(this.mandatory);
-               builder.append("]");
-               return builder.toString();
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = super.hashCode();
-               result = prime * result + ((this.attribute == null) ? 0 : this.attribute.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (!super.equals(obj))
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final XROSRLGSubobject other = (XROSRLGSubobject) obj;
-               if (this.attribute != other.attribute)
-                       return false;
-               return true;
-       }
-
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROSubobjectAttribute.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROSubobjectAttribute.java
deleted file mode 100644 (file)
index 259227c..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.subobject;
-
-/**
- * Enumerable for attributes of subobjects. Defined in 5521.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route
- *      Object definition</a>
- */
-public enum XROSubobjectAttribute {
-       /**
-        * The subobject is to be interpreted as an interface or set of interfaces.
-        */
-       INTERFACE,
-       /**
-        * The subobject is to be interpreted as a node or set of nodes.
-        */
-       NODE,
-       /**
-        * The subobject identifies an SRLG explicitly or indicates all of the SRLGs
-        * associated with the resource or resources identified by the subobject.
-        */
-       SRLG;
-}
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROUnnumberedInterfaceSubobject.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROUnnumberedInterfaceSubobject.java
deleted file mode 100644 (file)
index 8e11d16..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.UnnumberedSubobject;
-
-/**
- * Structure of unnumbered Interface Subobject. Defined in RFC5521.
- * 
- * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route Object definition</a>
- */
-public class XROUnnumberedInterfaceSubobject extends ExcludeRouteSubobject {
-
-       private final XROSubobjectAttribute attribute;
-
-       private final UnnumberedSubobject interfaceID;
-
-       private final Ipv4Address routerID;
-
-       /**
-        * Constructs new Unnumbered Interface Subobject.
-        * 
-        * @param routerID IPv4Address
-        * @param interfaceID UnnumberedInterfaceIdentifier
-        * @param mandatory boolean
-        * @param attribute XROSubobjectAttribute
-        */
-       public XROUnnumberedInterfaceSubobject(final Ipv4Address routerID, final UnnumberedSubobject interfaceID, final boolean mandatory,
-                       final XROSubobjectAttribute attribute) {
-               super(mandatory);
-               this.attribute = attribute;
-               this.routerID = routerID;
-               this.interfaceID = interfaceID;
-       }
-
-       /**
-        * Gets the attribute of the subobject
-        * 
-        * @return the attribute
-        */
-       public XROSubobjectAttribute getAttribute() {
-               return this.attribute;
-       }
-
-       /**
-        * Gets {@link IPv4Address} representation of router ID.
-        * 
-        * @return IPv4Address
-        */
-       public Ipv4Address getRouterID() {
-               return this.routerID;
-       }
-
-       /**
-        * Gets {@link UnnumberedInterfaceIdentifier} representation of Interface ID.
-        * 
-        * @return UnnumberedInterfaceIdentifier
-        */
-       public UnnumberedSubobject getInterfaceID() {
-               return this.interfaceID;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = super.hashCode();
-               result = prime * result + ((this.attribute == null) ? 0 : this.attribute.hashCode());
-               result = prime * result + ((this.interfaceID == null) ? 0 : this.interfaceID.hashCode());
-               result = prime * result + ((this.routerID == null) ? 0 : this.routerID.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (!super.equals(obj))
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final XROUnnumberedInterfaceSubobject other = (XROUnnumberedInterfaceSubobject) obj;
-               if (this.attribute != other.attribute)
-                       return false;
-               if (this.interfaceID == null) {
-                       if (other.interfaceID != null)
-                               return false;
-               } else if (!this.interfaceID.equals(other.interfaceID))
-                       return false;
-               if (this.routerID == null) {
-                       if (other.routerID != null)
-                               return false;
-               } else if (!this.routerID.equals(other.routerID))
-                       return false;
-               return true;
-       }
-
-       @Override
-       public String toString() {
-               final StringBuilder builder = new StringBuilder();
-               builder.append("XROUnnumberedInterfaceSubobject [attribute=");
-               builder.append(this.attribute);
-               builder.append(", interfaceID=");
-               builder.append(this.interfaceID);
-               builder.append(", routerID=");
-               builder.append(this.routerID);
-               builder.append(", mandatory=");
-               builder.append(this.mandatory);
-               builder.append("]");
-               return builder.toString();
-       }
-
-}
similarity index 92%
rename from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractMessageParser.java
rename to pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractMessageParser.java
index bb431c72498ecc79be859df24f3357c2c11409ee..81eca718830a5520ee28b4d478712330f7a73492 100644 (file)
@@ -1,4 +1,4 @@
-package org.opendaylight.protocol.pcep.spi;
+package org.opendaylight.protocol.pcep.impl;
 
 import java.util.Arrays;
 import java.util.BitSet;
@@ -8,6 +8,12 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.UnknownObject;
+import org.opendaylight.protocol.pcep.spi.MessageParser;
+import org.opendaylight.protocol.pcep.spi.MessageSerializer;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 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;
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPEROSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPEROSubobjectParser.java
deleted file mode 100644 (file)
index 3632dcd..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.impl.subobject.EROExplicitExclusionRouteSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.EROLabelSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.EROPathKeyWith128PCEIDSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.EROPathKeyWith32PCEIDSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.EROUnnumberedInterfaceSubobjectParser;
-import org.opendaylight.protocol.pcep.subobject.EROAsNumberSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROExplicitExclusionRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROPathKeyWith128PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROPathKeyWith32PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROUnnumberedInterfaceSubobject;
-import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Parser for {@link org.opendaylight.protocol.pcep.PCEPSubobject PCEPSubobject}
- */
-public class PCEPEROSubobjectParser {
-
-       private static final Logger logger = LoggerFactory.getLogger(PCEPEROSubobjectParser.class);
-
-       /**
-        * Type identifier for {@link org.opendaylight.protocol.pcep.PCEPSubobject PCEPSubobject}
-        */
-       public enum PCEPSubobjectType {
-               IPv4_PREFIX(1), IPv6_PREFIX(2), LABEL(3), UNNUMBERED_INTERFACE_ID(4), AS_NUMBER(32), EXRS(33), PROTECTION(37), PK_32(64), PK_128(65);
-
-               private final int indicator;
-
-               PCEPSubobjectType(final int indicator) {
-                       this.indicator = indicator;
-               }
-
-               public int getIndicator() {
-                       return this.indicator;
-               }
-
-               public static PCEPSubobjectType getFromInt(final int type) throws PCEPDeserializerException {
-
-                       for (final PCEPSubobjectType type_e : PCEPSubobjectType.values()) {
-                               if (type_e.getIndicator() == type) {
-                                       return type_e;
-                               }
-                       }
-
-                       throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + "; Known: " + PCEPSubobjectType.values() + ".");
-               }
-       }
-
-       /*
-        * Fields lengths in Bytes
-        */
-       public static final int TYPE_FLAG_F_LENGTH = 1;
-       public static final int LENGTH_F_LENGTH = 1;
-
-       /*
-        * Fields offsets in Bytes
-        */
-       public static final int TYPE_FLAG_F_OFFSET = 0;
-       public static final int LENGTH_F_OFFSET = TYPE_FLAG_F_OFFSET + TYPE_FLAG_F_LENGTH;
-       public static final int SO_CONTENTS_OFFSET = LENGTH_F_OFFSET + LENGTH_F_LENGTH;
-
-       public static List<ExplicitRouteSubobject> parse(final byte[] bytes) throws PCEPDeserializerException {
-               if (bytes == null) {
-                       throw new IllegalArgumentException("Byte array is mandatory.");
-               }
-
-               final List<ExplicitRouteSubobject> subobjsList = new ArrayList<ExplicitRouteSubobject>();
-               boolean loose_flag;
-               PCEPSubobjectType type;
-               byte[] soContentsBytes;
-               int length;
-               int offset = 0;
-
-               while (offset < bytes.length) {
-
-                       loose_flag = ((bytes[offset + TYPE_FLAG_F_OFFSET] & (1 << 7)) != 0) ? true : false;
-                       length = ByteArray.bytesToInt(ByteArray.subByte(bytes, offset + LENGTH_F_OFFSET, LENGTH_F_LENGTH));
-
-                       type = PCEPSubobjectType.getFromInt((bytes[offset + TYPE_FLAG_F_OFFSET] & 0xff) & ~(1 << 7));
-
-                       if (length > bytes.length - offset) {
-                               throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
-                                               + (bytes.length - offset));
-                       }
-
-                       soContentsBytes = new byte[length - SO_CONTENTS_OFFSET];
-                       System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
-
-                       logger.debug("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
-                       final ExplicitRouteSubobject subObj = parseSpecificSubobject(type, soContentsBytes, loose_flag);
-                       logger.debug("Subobject was parsed. {}", subObj);
-
-                       subobjsList.add(subObj);
-
-                       offset += length;
-               }
-
-               return subobjsList;
-       }
-
-       public static byte[] put(final List<ExplicitRouteSubobject> objsToSerialize) {
-               final List<byte[]> bytesList = new ArrayList<byte[]>(objsToSerialize.size());
-
-               int length = 0;
-               for (final ExplicitRouteSubobject obj : objsToSerialize) {
-                       final byte[] bytes = put(obj);
-                       length += bytes.length;
-                       bytesList.add(bytes);
-               }
-
-               final byte[] retBytes = new byte[length];
-
-               int offset = 0;
-               for (final byte[] bytes : bytesList) {
-                       System.arraycopy(bytes, 0, retBytes, offset, bytes.length);
-                       offset += bytes.length;
-               }
-
-               return retBytes;
-       }
-
-       public static byte[] put(final ExplicitRouteSubobject objToSerialize) {
-               int typeIndicator = 0;
-
-               byte[] soContentsBytes = null;
-
-               // if (objToSerialize instanceof EROIPPrefixSubobject<?>
-               // && ((EROIPPrefixSubobject<?>) objToSerialize).getPrefix() instanceof IPv4Prefix) {
-               // typeIndicator = PCEPSubobjectType.IPv4_PREFIX.getIndicator();
-               // // soContentsBytes = EROIpPrefixSubobjectParser.put(objToSerialize);
-               // } else if (objToSerialize instanceof EROIPPrefixSubobject<?>
-               // && ((EROIPPrefixSubobject<?>) objToSerialize).getPrefix() instanceof IPv6Prefix) {
-               // typeIndicator = PCEPSubobjectType.IPv6_PREFIX.getIndicator();
-               // // soContentsBytes = EROIPv6PrefixSubobjectParser.put(objToSerialize);
-               // } else
-               if (objToSerialize instanceof EROAsNumberSubobject) {
-                       typeIndicator = PCEPSubobjectType.AS_NUMBER.getIndicator();
-                       // soContentsBytes = EROAsNumberSubobjectParser.put(objToSerialize);
-               } else if (objToSerialize instanceof EROUnnumberedInterfaceSubobject) {
-                       typeIndicator = PCEPSubobjectType.UNNUMBERED_INTERFACE_ID.getIndicator();
-                       soContentsBytes = EROUnnumberedInterfaceSubobjectParser.put(objToSerialize);
-               } else if (objToSerialize instanceof EROLabelSubobject) {
-                       typeIndicator = PCEPSubobjectType.LABEL.getIndicator();
-                       soContentsBytes = EROLabelSubobjectParser.put((EROLabelSubobject) objToSerialize);
-               } else if (objToSerialize instanceof EROExplicitExclusionRouteSubobject) {
-                       typeIndicator = PCEPSubobjectType.EXRS.getIndicator();
-                       soContentsBytes = EROExplicitExclusionRouteSubobjectParser.put((EROExplicitExclusionRouteSubobject) objToSerialize);
-               } else if (objToSerialize instanceof EROPathKeyWith32PCEIDSubobject) {
-                       typeIndicator = PCEPSubobjectType.PK_32.getIndicator();
-                       soContentsBytes = EROPathKeyWith32PCEIDSubobjectParser.put((EROPathKeyWith32PCEIDSubobject) objToSerialize);
-               } else if (objToSerialize instanceof EROPathKeyWith128PCEIDSubobject) {
-                       typeIndicator = PCEPSubobjectType.PK_128.getIndicator();
-                       soContentsBytes = EROPathKeyWith128PCEIDSubobjectParser.put((EROPathKeyWith128PCEIDSubobject) objToSerialize);
-               } else {
-                       throw new IllegalArgumentException("Unknown instance of PCEPSubobject. Passed: " + objToSerialize.getClass() + ".");
-               }
-
-               final byte[] bytes = new byte[SO_CONTENTS_OFFSET + soContentsBytes.length];
-
-               bytes[TYPE_FLAG_F_OFFSET] = (byte) (ByteArray.cutBytes(ByteArray.intToBytes(typeIndicator), (Integer.SIZE / 8) - TYPE_FLAG_F_LENGTH)[0] | (objToSerialize.isLoose() ? 1 << 7
-                               : 0));
-               bytes[LENGTH_F_OFFSET] = ByteArray.cutBytes(ByteArray.intToBytes(soContentsBytes.length + SO_CONTENTS_OFFSET), (Integer.SIZE / 8)
-                               - LENGTH_F_LENGTH)[0];
-
-               System.arraycopy(soContentsBytes, 0, bytes, SO_CONTENTS_OFFSET, soContentsBytes.length);
-
-               return bytes;
-       }
-
-       private static ExplicitRouteSubobject parseSpecificSubobject(final PCEPSubobjectType type, final byte[] soContentsBytes,
-                       final boolean loose_flag) throws PCEPDeserializerException {
-
-               switch (type) {
-               case IPv4_PREFIX:
-                       // return EROIpPrefixSubobjectParser.parse(soContentsBytes, loose_flag);
-               case IPv6_PREFIX:
-                       // return EROIPv6PrefixSubobjectParser.parse(soContentsBytes, loose_flag);
-               case UNNUMBERED_INTERFACE_ID:
-                       return EROUnnumberedInterfaceSubobjectParser.parse(soContentsBytes, loose_flag);
-               case AS_NUMBER:
-                       // return EROAsNumberSubobjectParser.parse(soContentsBytes, loose_flag);
-               case LABEL:
-                       return EROLabelSubobjectParser.parse(soContentsBytes, loose_flag);
-               case EXRS:
-                       return EROExplicitExclusionRouteSubobjectParser.parse(soContentsBytes, loose_flag);
-               case PK_32:
-                       return EROPathKeyWith32PCEIDSubobjectParser.parse(soContentsBytes, loose_flag);
-               case PK_128:
-                       return EROPathKeyWith128PCEIDSubobjectParser.parse(soContentsBytes, loose_flag);
-               default:
-                       throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + ".");
-               }
-       }
-}
index 3e78d319198f97c8721dde2df2625382b229d182..6772c4ae8d6b4fdaea3f530a39068dcd9aa69e8d 100644 (file)
@@ -10,11 +10,22 @@ package org.opendaylight.protocol.pcep.impl;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.opendaylight.protocol.pcep.impl.message.PCCreateMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPErrorMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPKeepAliveMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPNotificationMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPOpenMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPReplyMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPReportMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPRequestMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPUpdateRequestMessageParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPBandwidthObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPEndPointsObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPErrorObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPExcludeRouteObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPExplicitRouteObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPGlobalConstraintsObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPIncludeRouteObjectParser;
@@ -32,6 +43,24 @@ import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectPars
 import org.opendaylight.protocol.pcep.impl.object.PCEPSrpObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.EROAsNumberSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.EROIpPrefixSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.EROLabelSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.EROPathKeySubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.EROUnnumberedInterfaceSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.GeneralizedLabelChannelSetParser;
+import org.opendaylight.protocol.pcep.impl.subobject.GeneralizedLabelParser;
+import org.opendaylight.protocol.pcep.impl.subobject.RROAsNumberSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.RROIpPrefixSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.RROLabelSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.RROPathKeySubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.RROUnnumberedInterfaceSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.Type1LabelParser;
+import org.opendaylight.protocol.pcep.impl.subobject.WavebandSwitchingLabelParser;
+import org.opendaylight.protocol.pcep.impl.subobject.XROAsNumberSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.XROIpPrefixSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.XROPathKeySubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.XROSRLGSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.XROUnnumberedInterfaceSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierIPv4TlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierIPv6TlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.LspDbVersionTlvParser;
@@ -45,19 +74,25 @@ import org.opendaylight.protocol.pcep.impl.tlv.PCEStatefulCapabilityTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.PredundancyGroupTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.RSVPErrorSpecTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.ReqMissingTlvParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectHandlerRegistry;
+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.PCEPProviderActivator;
 import org.opendaylight.protocol.pcep.spi.PCEPProviderContext;
-import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectHandlerRegistry;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.BandwidthObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClasstypeObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.EndpointsObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExcludeRouteObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExplicitRouteObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.GcObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LoadBalancingObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspErrorCodeTlv;
@@ -70,11 +105,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfListTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OrderTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OverloadDurationTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeyObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeySubobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcepErrorObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcinitiateMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcntfMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrepMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcreqMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrptMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcupdMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReqMissingTlv;
@@ -85,6 +129,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SvecObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SymbolicPathNameTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AsNumberSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.GeneralizedChannelSetLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.GeneralizedLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.IpPrefixSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.LabelSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.SrlgSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.Type1Label;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.UnnumberedSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.WavebandSwitchingLabel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -96,12 +148,64 @@ public final class PCEPImplActivator implements PCEPProviderActivator {
 
        @Override
        public void start(final PCEPProviderContext context) {
-               Preconditions.checkState(registrations == null);
+               Preconditions.checkState(this.registrations == null);
                final List<AutoCloseable> regs = new ArrayList<>();
 
-               final SubobjectHandlerRegistry eroSubReg = context.getEROSubobjectHandlerRegistry();
+               final LabelHandlerRegistry labelReg = context.getLabelHandlerRegistry();
+               labelReg.registerLabelParser(Type1LabelParser.CTYPE, new Type1LabelParser());
+               labelReg.registerLabelParser(GeneralizedLabelParser.CTYPE, new GeneralizedLabelParser());
+               labelReg.registerLabelParser(WavebandSwitchingLabelParser.CTYPE, new WavebandSwitchingLabelParser());
+               labelReg.registerLabelParser(GeneralizedLabelChannelSetParser.CTYPE, new GeneralizedLabelChannelSetParser());
+
+               labelReg.registerLabelSerializer(Type1Label.class, new Type1LabelParser());
+               labelReg.registerLabelSerializer(GeneralizedLabel.class, new GeneralizedLabelParser());
+               labelReg.registerLabelSerializer(WavebandSwitchingLabel.class, new WavebandSwitchingLabelParser());
+               labelReg.registerLabelSerializer(GeneralizedChannelSetLabel.class, new GeneralizedLabelChannelSetParser());
+
+               final EROSubobjectHandlerRegistry eroSubReg = context.getEROSubobjectHandlerRegistry();
+               eroSubReg.registerSubobjectParser(EROIpPrefixSubobjectParser.TYPE, new EROIpPrefixSubobjectParser());
+               eroSubReg.registerSubobjectParser(EROIpPrefixSubobjectParser.TYPE6, new EROIpPrefixSubobjectParser());
                eroSubReg.registerSubobjectParser(EROAsNumberSubobjectParser.TYPE, new EROAsNumberSubobjectParser());
+               eroSubReg.registerSubobjectParser(EROLabelSubobjectParser.TYPE, new EROLabelSubobjectParser(labelReg));
+               eroSubReg.registerSubobjectParser(EROUnnumberedInterfaceSubobjectParser.TYPE, new EROUnnumberedInterfaceSubobjectParser());
+               eroSubReg.registerSubobjectParser(EROPathKeySubobjectParser.TYPE, new EROPathKeySubobjectParser());
+               eroSubReg.registerSubobjectParser(EROPathKeySubobjectParser.TYPE128, new EROPathKeySubobjectParser());
+
+               eroSubReg.registerSubobjectSerializer(IpPrefixSubobject.class, new EROIpPrefixSubobjectParser());
                eroSubReg.registerSubobjectSerializer(AsNumberSubobject.class, new EROAsNumberSubobjectParser());
+               eroSubReg.registerSubobjectSerializer(LabelSubobject.class, new EROLabelSubobjectParser(labelReg));
+               eroSubReg.registerSubobjectSerializer(UnnumberedSubobject.class, new EROUnnumberedInterfaceSubobjectParser());
+               eroSubReg.registerSubobjectSerializer(PathKeySubobject.class, new EROPathKeySubobjectParser());
+
+               final RROSubobjectHandlerRegistry rroSubReg = context.getRROSubobjectHandlerRegistry();
+               rroSubReg.registerSubobjectParser(RROIpPrefixSubobjectParser.TYPE, new RROIpPrefixSubobjectParser());
+               rroSubReg.registerSubobjectParser(RROIpPrefixSubobjectParser.TYPE6, new RROIpPrefixSubobjectParser());
+               rroSubReg.registerSubobjectParser(RROLabelSubobjectParser.TYPE, new RROLabelSubobjectParser(labelReg));
+               rroSubReg.registerSubobjectParser(RROAsNumberSubobjectParser.TYPE, new RROAsNumberSubobjectParser());
+               rroSubReg.registerSubobjectParser(RROUnnumberedInterfaceSubobjectParser.TYPE, new RROUnnumberedInterfaceSubobjectParser());
+               rroSubReg.registerSubobjectParser(RROPathKeySubobjectParser.TYPE, new RROPathKeySubobjectParser());
+               rroSubReg.registerSubobjectParser(RROPathKeySubobjectParser.TYPE128, new RROPathKeySubobjectParser());
+
+               rroSubReg.registerSubobjectSerializer(IpPrefixSubobject.class, new RROIpPrefixSubobjectParser());
+               rroSubReg.registerSubobjectSerializer(LabelSubobject.class, new RROLabelSubobjectParser(labelReg));
+               rroSubReg.registerSubobjectSerializer(AsNumberSubobject.class, new RROAsNumberSubobjectParser());
+               rroSubReg.registerSubobjectSerializer(UnnumberedSubobject.class, new RROUnnumberedInterfaceSubobjectParser());
+               rroSubReg.registerSubobjectSerializer(PathKeySubobject.class, new RROPathKeySubobjectParser());
+
+               final XROSubobjectHandlerRegistry xroSubReg = context.getXROSubobjectHandlerRegistry();
+               xroSubReg.registerSubobjectParser(XROIpPrefixSubobjectParser.TYPE, new XROIpPrefixSubobjectParser());
+               xroSubReg.registerSubobjectParser(XROIpPrefixSubobjectParser.TYPE6, new XROIpPrefixSubobjectParser());
+               xroSubReg.registerSubobjectParser(XROAsNumberSubobjectParser.TYPE, new XROAsNumberSubobjectParser());
+               xroSubReg.registerSubobjectParser(XROSRLGSubobjectParser.TYPE, new XROSRLGSubobjectParser());
+               xroSubReg.registerSubobjectParser(XROUnnumberedInterfaceSubobjectParser.TYPE, new XROUnnumberedInterfaceSubobjectParser());
+               xroSubReg.registerSubobjectParser(XROPathKeySubobjectParser.TYPE, new XROPathKeySubobjectParser());
+               xroSubReg.registerSubobjectParser(XROPathKeySubobjectParser.TYPE128, new XROPathKeySubobjectParser());
+
+               xroSubReg.registerSubobjectSerializer(IpPrefixSubobject.class, new XROIpPrefixSubobjectParser());
+               xroSubReg.registerSubobjectSerializer(AsNumberSubobject.class, new XROAsNumberSubobjectParser());
+               xroSubReg.registerSubobjectSerializer(SrlgSubobject.class, new XROSRLGSubobjectParser());
+               xroSubReg.registerSubobjectSerializer(UnnumberedSubobject.class, new XROUnnumberedInterfaceSubobjectParser());
+               xroSubReg.registerSubobjectSerializer(PathKeySubobject.class, new XROPathKeySubobjectParser());
 
                final TlvHandlerRegistry tlvReg = context.getTlvHandlerRegistry();
                tlvReg.registerTlvParser(NoPathVectorTlvParser.TYPE, new NoPathVectorTlvParser());
@@ -137,17 +241,20 @@ public final class PCEPImplActivator implements PCEPProviderActivator {
                                new PCEPRequestParameterObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, new PCEPNoPathObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPEndPointsObjectParser.CLASS, PCEPEndPointsObjectParser.TYPE, new PCEPEndPointsObjectParser(tlvReg));
-               objReg.registerObjectParser(PCEPEndPointsObjectParser.CLASS_6, PCEPEndPointsObjectParser.TYPE_6, new PCEPEndPointsObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPEndPointsObjectParser.CLASS_6, PCEPEndPointsObjectParser.TYPE_6,
+                               new PCEPEndPointsObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, new PCEPBandwidthObjectParser(tlvReg));
-               objReg.registerObjectParser(PCEPBandwidthObjectParser.E_CLASS, PCEPBandwidthObjectParser.E_TYPE, new PCEPBandwidthObjectParser(tlvReg));
+               objReg.registerObjectParser(PCEPBandwidthObjectParser.E_CLASS, PCEPBandwidthObjectParser.E_TYPE,
+                               new PCEPBandwidthObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, new PCEPMetricObjectParser(tlvReg));
+
                objReg.registerObjectParser(PCEPExplicitRouteObjectParser.CLASS, PCEPExplicitRouteObjectParser.TYPE,
-                               new PCEPExplicitRouteObjectParser(context.getEROSubobjectHandlerRegistry()));
+                               new PCEPExplicitRouteObjectParser(eroSubReg));
                objReg.registerObjectParser(PCEPReportedRouteObjectParser.CLASS, PCEPReportedRouteObjectParser.TYPE,
-                               new PCEPReportedRouteObjectParser(context.getRROSubobjectHandlerRegistry()));
-               objReg.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, new PCEPLspaObjectParser( tlvReg));
+                               new PCEPReportedRouteObjectParser(rroSubReg));
+               objReg.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, new PCEPLspaObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPIncludeRouteObjectParser.CLASS, PCEPIncludeRouteObjectParser.TYPE,
-                               new PCEPIncludeRouteObjectParser(context.getEROSubobjectHandlerRegistry()));
+                               new PCEPIncludeRouteObjectParser(eroSubReg));
                objReg.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, new PCEPSvecObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPNotificationObjectParser.CLASS, PCEPNotificationObjectParser.TYPE,
                                new PCEPNotificationObjectParser(tlvReg));
@@ -159,12 +266,13 @@ public final class PCEPImplActivator implements PCEPProviderActivator {
                objReg.registerObjectParser(PCEPObjectiveFunctionObjectParser.CLASS, PCEPObjectiveFunctionObjectParser.TYPE,
                                new PCEPObjectiveFunctionObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, new PCEPClassTypeObjectParser(tlvReg));
+
                objReg.registerObjectParser(PCEPGlobalConstraintsObjectParser.CLASS, PCEPGlobalConstraintsObjectParser.TYPE,
                                new PCEPGlobalConstraintsObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPLspObjectParser.CLASS, PCEPLspObjectParser.TYPE, new PCEPLspObjectParser(tlvReg));
                objReg.registerObjectParser(PCEPSrpObjectParser.CLASS, PCEPSrpObjectParser.TYPE, new PCEPSrpObjectParser(tlvReg));
-               // objReg.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE, new
-               // PCEPExcludeRouteObjectParser(context.getXROSubobjectHandlerRegistry()));
+               objReg.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE,
+                               new PCEPExcludeRouteObjectParser(xroSubReg));
 
                objReg.registerObjectSerializer(OpenObject.class, new PCEPOpenObjectParser(tlvReg));
                objReg.registerObjectSerializer(RpObject.class, new PCEPRequestParameterObjectParser(tlvReg));
@@ -172,10 +280,10 @@ public final class PCEPImplActivator implements PCEPProviderActivator {
                objReg.registerObjectSerializer(EndpointsObject.class, new PCEPEndPointsObjectParser(tlvReg));
                objReg.registerObjectSerializer(BandwidthObject.class, new PCEPBandwidthObjectParser(tlvReg));
                objReg.registerObjectSerializer(MetricObject.class, new PCEPMetricObjectParser(tlvReg));
-               objReg.registerObjectSerializer(ExplicitRouteObject.class, new PCEPExplicitRouteObjectParser(context.getEROSubobjectHandlerRegistry()));
-               objReg.registerObjectSerializer(ReportedRouteObject.class, new PCEPReportedRouteObjectParser(context.getRROSubobjectHandlerRegistry()));
+               objReg.registerObjectSerializer(ExplicitRouteObject.class, new PCEPExplicitRouteObjectParser(eroSubReg));
+               objReg.registerObjectSerializer(ReportedRouteObject.class, new PCEPReportedRouteObjectParser(rroSubReg));
                objReg.registerObjectSerializer(LspaObject.class, new PCEPLspaObjectParser(tlvReg));
-               objReg.registerObjectSerializer(IncludeRouteObject.class, new PCEPIncludeRouteObjectParser(context.getEROSubobjectHandlerRegistry()));
+               objReg.registerObjectSerializer(IncludeRouteObject.class, new PCEPIncludeRouteObjectParser(eroSubReg));
                objReg.registerObjectSerializer(SvecObject.class, new PCEPSvecObjectParser(tlvReg));
                objReg.registerObjectSerializer(NotificationObject.class, new PCEPNotificationObjectParser(tlvReg));
                objReg.registerObjectSerializer(PcepErrorObject.class, new PCEPErrorObjectParser(tlvReg));
@@ -187,36 +295,45 @@ public final class PCEPImplActivator implements PCEPProviderActivator {
                objReg.registerObjectSerializer(GcObject.class, new PCEPGlobalConstraintsObjectParser(tlvReg));
                objReg.registerObjectSerializer(LspObject.class, new PCEPLspObjectParser(tlvReg));
                objReg.registerObjectSerializer(SrpObject.class, new PCEPSrpObjectParser(tlvReg));
-               // reg.registerObjectSerializer(ExcludeRouteObject.class, new PCEPExcludeRouteObjectParser(reg));
+               objReg.registerObjectSerializer(ExcludeRouteObject.class, new PCEPExcludeRouteObjectParser(xroSubReg));
 
                final MessageHandlerRegistry msgReg = context.getMessageHandlerRegistry();
-               // FIXME: finish this
-               // msgReg.registerMessageHandler(PCEPOpenMessage.class, 1, new PCEPOpenMessageParser());
-               // msgReg.registerMessageHandler(PCEPNotificationMessage.class, 5, new PCEPNotificationMessageParser());
-               // msgReg.registerMessageHandler(PCEPKeepAliveMessage.class, 2, new PCEPKeepAliveMessageParser());
-               // msgReg.registerMessageHandler(PCEPReplyMessage.class, 4, new PCEPReplyMessageParser());
-               // msgReg.registerMessageHandler(PCEPRequestMessage.class, 3, new PCEPRequestMessageParser());
-               // msgReg.registerMessageHandler(PCEPErrorMessage.class, 6, new PCEPErrorMessageParser());
-               // msgReg.registerMessageHandler(PCEPCloseMessage.class, 7, new PCEPCloseMessageParser());
-               // msgReg.registerMessageHandler(PCEPUpdateRequestMessage.class, 11, new PCEPUpdateRequestMessageParser());
-               // msgReg.registerMessageHandler(PCEPReportMessage.class, 10, new PCEPReportMessageParser());
-               // msgReg.registerMessageHandler(PCCreateMessage.class, 12, new PCCreateMessageParser());
-
-               registrations = regs;
+               msgReg.registerMessageParser(PCEPOpenMessageParser.TYPE, new PCEPOpenMessageParser(objReg));
+               msgReg.registerMessageParser(PCEPKeepAliveMessageParser.TYPE, new PCEPKeepAliveMessageParser(objReg));
+               msgReg.registerMessageParser(PCEPReplyMessageParser.TYPE, new PCEPReplyMessageParser(objReg));
+               msgReg.registerMessageParser(PCEPRequestMessageParser.TYPE, new PCEPRequestMessageParser(objReg));
+               msgReg.registerMessageParser(PCEPErrorMessageParser.TYPE, new PCEPErrorMessageParser(objReg));
+               msgReg.registerMessageParser(PCEPCloseMessageParser.TYPE, new PCEPCloseMessageParser(objReg));
+               msgReg.registerMessageParser(PCEPUpdateRequestMessageParser.TYPE, new PCEPUpdateRequestMessageParser(objReg));
+               msgReg.registerMessageParser(PCEPReportMessageParser.TYPE, new PCEPReportMessageParser(objReg));
+               msgReg.registerMessageParser(PCCreateMessageParser.TYPE, new PCCreateMessageParser(objReg));
+
+               msgReg.registerMessageSerializer(OpenMessage.class, new PCEPOpenMessageParser(objReg));
+               msgReg.registerMessageSerializer(PcntfMessage.class, new PCEPNotificationMessageParser(objReg));
+               msgReg.registerMessageSerializer(KeepaliveMessage.class, new PCEPKeepAliveMessageParser(objReg));
+               msgReg.registerMessageSerializer(PcrepMessage.class, new PCEPReplyMessageParser(objReg));
+               msgReg.registerMessageSerializer(PcreqMessage.class, new PCEPRequestMessageParser(objReg));
+               msgReg.registerMessageSerializer(PcerrMessage.class, new PCEPErrorMessageParser(objReg));
+               msgReg.registerMessageSerializer(CloseMessage.class, new PCEPCloseMessageParser(objReg));
+               msgReg.registerMessageSerializer(PcupdMessage.class, new PCEPUpdateRequestMessageParser(objReg));
+               msgReg.registerMessageSerializer(PcrptMessage.class, new PCEPReportMessageParser(objReg));
+               msgReg.registerMessageSerializer(PcinitiateMessage.class, new PCCreateMessageParser(objReg));
+
+               this.registrations = regs;
        }
 
        @Override
        public void stop() {
-               Preconditions.checkState(registrations != null);
+               Preconditions.checkState(this.registrations != null);
 
-               for (AutoCloseable r : registrations) {
+               for (final AutoCloseable r : this.registrations) {
                        try {
                                r.close();
-                       } catch (Exception e) {
+                       } catch (final Exception e) {
                                logger.warn("Failed to close registration", e);
                        }
                }
 
-               registrations = null;
+               this.registrations = null;
        }
 }
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPOFCodesMapping.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPOFCodesMapping.java
deleted file mode 100644 (file)
index d93e810..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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 java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import org.opendaylight.protocol.pcep.PCEPOFCodes;
-
-/**
- * Mapping of enumerable objective function codes to integral identifiers and
- * vice-versa.
- */
-public class PCEPOFCodesMapping {
-       private static final PCEPOFCodesMapping instance = new PCEPOFCodesMapping();
-
-       private final Map<PCEPOFCodes, Integer> ofCodesMap = new EnumMap<PCEPOFCodes, Integer>(PCEPOFCodes.class);
-       private final Map<Integer, PCEPOFCodes> ofCodeIdsMap = new HashMap<Integer, PCEPOFCodes>();
-
-       private PCEPOFCodesMapping() {
-               this.fillIn();
-       }
-
-       private void fillIn() {
-               this.fillIn(1, PCEPOFCodes.MCP);
-               this.fillIn(2, PCEPOFCodes.MLP);
-               this.fillIn(3, PCEPOFCodes.MBP);
-               this.fillIn(4, PCEPOFCodes.MBC);
-               this.fillIn(5, PCEPOFCodes.MLL);
-               this.fillIn(6, PCEPOFCodes.MCC);
-               this.fillIn(7, PCEPOFCodes.SPT);
-               this.fillIn(8, PCEPOFCodes.MCT);
-       }
-
-       private void fillIn(int identifier, PCEPOFCodes ofCode) {
-               this.ofCodesMap.put(ofCode, identifier);
-               this.ofCodeIdsMap.put(identifier, ofCode);
-       }
-
-       public int getFromOFCodesEnum(PCEPOFCodes ofCode) {
-               final Integer ofci = this.ofCodesMap.get(ofCode);
-               if (ofci == null)
-                       throw new NoSuchElementException("Unknown PCEPOFCodes type: " + ofCode);
-               return ofci;
-       }
-
-       public PCEPOFCodes getFromCodeIdentifier(int identifier) {
-               final PCEPOFCodes ofc = this.ofCodeIdsMap.get(identifier);
-               if (ofc == null)
-                       throw new NoSuchElementException("Unknown PCEPOFCode identifier.");
-               return ofc;
-       }
-
-       public static PCEPOFCodesMapping getInstance() {
-               return instance;
-       }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPRROSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPRROSubobjectParser.java
deleted file mode 100644 (file)
index 3cc42ff..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.impl.subobject.RROAttributesSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.RROIPv4AddressSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.RROIPv6AddressSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.RROLabelSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.RROPathKeyWith128PCEIDSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.RROPathKeyWith32PCEIDSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.RROUnnumberedInterfaceSubobjectParser;
-import org.opendaylight.protocol.pcep.subobject.RROAttributesSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROIPAddressSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROPathKeyWith128PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROPathKeyWith32PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROUnnumberedInterfaceSubobject;
-import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Parser for {@link org.opendaylight.protocol.pcep.PCEPSubobject PCEPSubobject}
- */
-public class PCEPRROSubobjectParser {
-
-       private static final Logger logger = LoggerFactory.getLogger(PCEPRROSubobjectParser.class);
-
-       /**
-        * Type identifier for {@link org.opendaylight.protocol.pcep.PCEPSubobject PCEPSubobject}
-        */
-       public enum PCEPSubobjectType {
-               IPv4_PREFIX(1), IPv6_PREFIX(2), LABEL(3), UNNUMBERED_INTERFACE_ID(4), ATTRIBUTES(5), PROTECTION(37), PK_32(64), PK_128(65);
-
-               private final int indicator;
-
-               PCEPSubobjectType(final int indicator) {
-                       this.indicator = indicator;
-               }
-
-               public int getIndicator() {
-                       return this.indicator;
-               }
-
-               public static PCEPSubobjectType getFromInt(final int type) throws PCEPDeserializerException {
-
-                       for (final PCEPSubobjectType type_e : PCEPSubobjectType.values()) {
-                               if (type_e.getIndicator() == type)
-                                       return type_e;
-                       }
-
-                       throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + "; Known: " + PCEPSubobjectType.values() + ".");
-               }
-       }
-
-       /*
-        * Fields lengths in Bytes
-        */
-       public static final int TYPE_F_LENGTH = 1;
-       public static final int LENGTH_F_LENGTH = 1;
-
-       /*
-        * Fields offsets in Bytes
-        */
-       public static final int TYPE_F_OFFSET = 0;
-       public static final int LENGTH_F_OFFSET = TYPE_F_OFFSET + TYPE_F_LENGTH;
-       public static final int SO_CONTENTS_OFFSET = LENGTH_F_OFFSET + LENGTH_F_LENGTH;
-
-       public static List<ReportedRouteSubobject> parse(final byte[] bytes) throws PCEPDeserializerException {
-               if (bytes == null)
-                       throw new IllegalArgumentException("Byte array is mandatory.");
-
-               final List<ReportedRouteSubobject> subobjsList = new ArrayList<ReportedRouteSubobject>();
-               PCEPSubobjectType type;
-               byte[] soContentsBytes;
-               int length;
-               int offset = 0;
-
-               while (offset < bytes.length) {
-                       length = ByteArray.bytesToInt(ByteArray.subByte(bytes, offset + LENGTH_F_OFFSET, LENGTH_F_LENGTH));
-
-                       type = PCEPSubobjectType.getFromInt(bytes[offset + TYPE_F_OFFSET] & 0xff);
-
-                       if (length > bytes.length - offset)
-                               throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
-                                               + (bytes.length - offset));
-
-                       soContentsBytes = new byte[length - SO_CONTENTS_OFFSET];
-                       System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
-
-                       logger.trace("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
-                       final ReportedRouteSubobject subObj = parseSpecificSubobject(type, soContentsBytes);
-                       logger.trace("Subobject was parsed. {}", subObj);
-
-                       subobjsList.add(subObj);
-
-                       offset += length;
-               }
-
-               return subobjsList;
-       }
-
-       public static byte[] put(final List<ReportedRouteSubobject> objsToSerialize) {
-               final List<byte[]> bytesList = new ArrayList<byte[]>(objsToSerialize.size());
-
-               int length = 0;
-               for (final ReportedRouteSubobject obj : objsToSerialize) {
-                       final byte[] bytes = put(obj);
-                       length += bytes.length;
-                       bytesList.add(bytes);
-               }
-
-               final byte[] retBytes = new byte[length];
-
-               int offset = 0;
-               for (final byte[] bytes : bytesList) {
-                       System.arraycopy(bytes, 0, retBytes, offset, bytes.length);
-                       offset += bytes.length;
-               }
-
-               return retBytes;
-       }
-
-       public static byte[] put(final ReportedRouteSubobject objToSerialize) {
-               int typeIndicator = 0;
-
-               final byte[] soContentsBytes;
-
-               if (objToSerialize instanceof RROIPAddressSubobject && ((RROIPAddressSubobject) objToSerialize).getPrefix().getIpv4Prefix() != null) {
-                       typeIndicator = PCEPSubobjectType.IPv4_PREFIX.getIndicator();
-                       soContentsBytes = RROIPv4AddressSubobjectParser.put(objToSerialize);
-               } else if (objToSerialize instanceof RROIPAddressSubobject
-                               && ((RROIPAddressSubobject) objToSerialize).getPrefix().getIpv6Prefix() != null) {
-                       typeIndicator = PCEPSubobjectType.IPv6_PREFIX.getIndicator();
-                       soContentsBytes = RROIPv6AddressSubobjectParser.put(objToSerialize);
-               } else if (objToSerialize instanceof RROUnnumberedInterfaceSubobject) {
-                       typeIndicator = PCEPSubobjectType.UNNUMBERED_INTERFACE_ID.getIndicator();
-                       soContentsBytes = RROUnnumberedInterfaceSubobjectParser.put(objToSerialize);
-               } else if (objToSerialize instanceof RROLabelSubobject) {
-                       typeIndicator = PCEPSubobjectType.LABEL.getIndicator();
-                       soContentsBytes = RROLabelSubobjectParser.put((RROLabelSubobject) objToSerialize);
-               } else if (objToSerialize instanceof RROPathKeyWith32PCEIDSubobject) {
-                       typeIndicator = PCEPSubobjectType.PK_32.getIndicator();
-                       soContentsBytes = RROPathKeyWith32PCEIDSubobjectParser.put((RROPathKeyWith32PCEIDSubobject) objToSerialize);
-               } else if (objToSerialize instanceof RROPathKeyWith128PCEIDSubobject) {
-                       typeIndicator = PCEPSubobjectType.PK_128.getIndicator();
-                       soContentsBytes = RROPathKeyWith128PCEIDSubobjectParser.put((RROPathKeyWith128PCEIDSubobject) objToSerialize);
-               } else if (objToSerialize instanceof RROAttributesSubobject) {
-                       typeIndicator = PCEPSubobjectType.ATTRIBUTES.getIndicator();
-                       soContentsBytes = RROAttributesSubobjectParser.put((RROAttributesSubobject) objToSerialize);
-               } else
-                       throw new IllegalArgumentException("Unknown instance of PCEPSubobject. Passed: " + objToSerialize.getClass() + ".");
-
-               final byte[] bytes = new byte[SO_CONTENTS_OFFSET + soContentsBytes.length];
-
-               bytes[TYPE_F_OFFSET] = ByteArray.cutBytes(ByteArray.intToBytes(typeIndicator), (Integer.SIZE / 8) - TYPE_F_LENGTH)[0];
-               bytes[LENGTH_F_OFFSET] = ByteArray.cutBytes(ByteArray.intToBytes(soContentsBytes.length + SO_CONTENTS_OFFSET), (Integer.SIZE / 8)
-                               - LENGTH_F_LENGTH)[0];
-
-               System.arraycopy(soContentsBytes, 0, bytes, SO_CONTENTS_OFFSET, soContentsBytes.length);
-
-               return bytes;
-       }
-
-       private static ReportedRouteSubobject parseSpecificSubobject(final PCEPSubobjectType type, final byte[] soContentsBytes)
-                       throws PCEPDeserializerException {
-
-               switch (type) {
-               case IPv4_PREFIX:
-                       return RROIPv4AddressSubobjectParser.parse(soContentsBytes);
-               case IPv6_PREFIX:
-                       return RROIPv6AddressSubobjectParser.parse(soContentsBytes);
-               case UNNUMBERED_INTERFACE_ID:
-                       return RROUnnumberedInterfaceSubobjectParser.parse(soContentsBytes);
-               case LABEL:
-                       return RROLabelSubobjectParser.parse(soContentsBytes);
-               case PK_32:
-                       return RROPathKeyWith32PCEIDSubobjectParser.parse(soContentsBytes);
-               case PK_128:
-                       return RROPathKeyWith128PCEIDSubobjectParser.parse(soContentsBytes);
-               case ATTRIBUTES:
-                       return RROAttributesSubobjectParser.parse(soContentsBytes);
-               default:
-                       throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + ".");
-               }
-       }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPXROSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPXROSubobjectParser.java
deleted file mode 100644 (file)
index ddd2533..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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 java.util.ArrayList;
-import java.util.List;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.impl.subobject.XROAsNumberSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.XROIPv4PrefixSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.XROIPv6PrefixSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.XROSRLGSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.XROUnnumberedInterfaceSubobjectParser;
-import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROIPPrefixSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROSRLGSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROUnnumberedInterfaceSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Parser for {@link org.opendaylight.protocol.pcep.PCEPXROSubobject PCEPXROSubobject}
- */
-public class PCEPXROSubobjectParser {
-
-       private static final Logger logger = LoggerFactory.getLogger(PCEPXROSubobjectParser.class);
-
-       /**
-        * Type identifier for {@link org.opendaylight.protocol.pcep.PCEPXROSubobject PCEPXROSubobject}
-        */
-       public enum PCEPXROSubobjectType {
-               IPv4_PREFIX(1), IPv6_PREFIX(2), UNNUMBERED_INTERFACE_ID(4), AS_NUMBER(32), SRLG(34);
-
-               private final int indicator;
-
-               PCEPXROSubobjectType(final int indicator) {
-                       this.indicator = indicator;
-               }
-
-               public int getIndicator() {
-                       return this.indicator;
-               }
-
-               public static PCEPXROSubobjectType getFromInt(final int type) throws PCEPDeserializerException {
-
-                       for (final PCEPXROSubobjectType type_e : PCEPXROSubobjectType.values()) {
-                               if (type_e.getIndicator() == type)
-                                       return type_e;
-                       }
-
-                       throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + "; Known: " + PCEPXROSubobjectType.values()
-                                       + ".");
-               }
-       }
-
-       /*
-        * Fields lengths in Bytes
-        */
-       public static final int TYPE_FLAG_F_LENGTH = 1;
-       public static final int LENGTH_F_LENGTH = 1;
-
-       /*
-        * Fields offsets in Bytes
-        */
-       public static final int TYPE_FLAG_F_OFFSET = 0;
-       public static final int LENGTH_F_OFFSET = TYPE_FLAG_F_OFFSET + TYPE_FLAG_F_LENGTH;
-       public static final int SO_CONTENTS_OFFSET = LENGTH_F_OFFSET + LENGTH_F_LENGTH;
-
-       public static List<ExcludeRouteSubobject> parse(final byte[] bytes) throws PCEPDeserializerException {
-               if (bytes == null)
-                       throw new IllegalArgumentException("Byte array is mandatory.");
-
-               final List<ExcludeRouteSubobject> subobjsList = new ArrayList<ExcludeRouteSubobject>();
-               boolean mandatoryFlag;
-               PCEPXROSubobjectType type;
-               byte[] soContentsBytes;
-               int length;
-               int offset = 0;
-
-               while (offset < bytes.length) {
-
-                       mandatoryFlag = ((bytes[offset + TYPE_FLAG_F_OFFSET] & (1 << 7)) != 0);
-                       length = ByteArray.bytesToInt(ByteArray.subByte(bytes, offset + LENGTH_F_OFFSET, LENGTH_F_LENGTH));
-
-                       type = PCEPXROSubobjectType.getFromInt((bytes[offset + TYPE_FLAG_F_OFFSET] & 0xff) & ~(1 << 7));
-
-                       if (length > bytes.length - offset)
-                               throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
-                                               + (bytes.length - offset));
-
-                       soContentsBytes = new byte[length - SO_CONTENTS_OFFSET];
-                       System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
-
-                       logger.debug("Attempt to parse exclude route objects subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
-                       final ExcludeRouteSubobject subObj = parseSpecificSubobject(type, soContentsBytes, mandatoryFlag);
-                       logger.debug("Subobject was parsed. {}", subObj);
-
-                       subobjsList.add(subObj);
-
-                       offset += length;
-               }
-
-               return subobjsList;
-       }
-
-       public static byte[] put(final List<ExcludeRouteSubobject> objsToSerialize) {
-               final List<byte[]> bytesList = new ArrayList<byte[]>(objsToSerialize.size());
-
-               int length = 0;
-               for (final ExcludeRouteSubobject obj : objsToSerialize) {
-                       final byte[] bytes = put(obj);
-                       length += bytes.length;
-                       bytesList.add(bytes);
-               }
-
-               final byte[] retBytes = new byte[length];
-
-               int offset = 0;
-               for (final byte[] bytes : bytesList) {
-                       System.arraycopy(bytes, 0, retBytes, offset, bytes.length);
-                       offset += bytes.length;
-               }
-
-               return retBytes;
-       }
-
-       public static byte[] put(final ExcludeRouteSubobject objToSerialize) {
-               int typeIndicator = 0;
-
-               final byte[] soContentsBytes;
-
-               if (objToSerialize instanceof XROIPPrefixSubobject && ((XROIPPrefixSubobject) objToSerialize).getPrefix().getIpv4Prefix() != null) {
-                       typeIndicator = PCEPXROSubobjectType.IPv4_PREFIX.getIndicator();
-                       soContentsBytes = XROIPv4PrefixSubobjectParser.put(objToSerialize);
-               } else if (objToSerialize instanceof XROIPPrefixSubobject
-                               && ((XROIPPrefixSubobject) objToSerialize).getPrefix().getIpv6Prefix() != null) {
-                       typeIndicator = PCEPXROSubobjectType.IPv6_PREFIX.getIndicator();
-                       soContentsBytes = XROIPv6PrefixSubobjectParser.put(objToSerialize);
-               } else if (objToSerialize instanceof XROAsNumberSubobject) {
-                       typeIndicator = PCEPXROSubobjectType.AS_NUMBER.getIndicator();
-                       soContentsBytes = XROAsNumberSubobjectParser.put(objToSerialize);
-               } else if (objToSerialize instanceof XROUnnumberedInterfaceSubobject) {
-                       typeIndicator = PCEPXROSubobjectType.UNNUMBERED_INTERFACE_ID.getIndicator();
-                       soContentsBytes = XROUnnumberedInterfaceSubobjectParser.put(objToSerialize);
-               } else if (objToSerialize instanceof XROSRLGSubobject) {
-                       typeIndicator = PCEPXROSubobjectType.SRLG.getIndicator();
-                       soContentsBytes = XROSRLGSubobjectParser.put(objToSerialize);
-               } else
-                       throw new IllegalArgumentException("Unknown instance of PCEPXROSubobject. Passed: " + objToSerialize.getClass() + ".");
-
-               final byte[] bytes = new byte[SO_CONTENTS_OFFSET + soContentsBytes.length];
-
-               bytes[TYPE_FLAG_F_OFFSET] = (byte) (ByteArray.cutBytes(ByteArray.intToBytes(typeIndicator), (Integer.SIZE / 8) - TYPE_FLAG_F_LENGTH)[0] | (objToSerialize.isMandatory() ? 1 << 7
-                               : 0));
-               bytes[LENGTH_F_OFFSET] = ByteArray.cutBytes(ByteArray.intToBytes(soContentsBytes.length + SO_CONTENTS_OFFSET), (Integer.SIZE / 8)
-                               - LENGTH_F_LENGTH)[0];
-
-               System.arraycopy(soContentsBytes, 0, bytes, SO_CONTENTS_OFFSET, soContentsBytes.length);
-
-               return bytes;
-       }
-
-       private static ExcludeRouteSubobject parseSpecificSubobject(final PCEPXROSubobjectType type, final byte[] soContentsBytes,
-                       final boolean mandatory) throws PCEPDeserializerException {
-
-               switch (type) {
-               case IPv4_PREFIX:
-                       return XROIPv4PrefixSubobjectParser.parse(soContentsBytes, mandatory);
-               case IPv6_PREFIX:
-                       return XROIPv6PrefixSubobjectParser.parse(soContentsBytes, mandatory);
-               case UNNUMBERED_INTERFACE_ID:
-                       return XROUnnumberedInterfaceSubobjectParser.parse(soContentsBytes, mandatory);
-               case AS_NUMBER:
-                       return XROAsNumberSubobjectParser.parse(soContentsBytes, mandatory);
-               case SRLG:
-                       return XROSRLGSubobjectParser.parse(soContentsBytes, mandatory);
-               default:
-                       throw new PCEPDeserializerException("Unknown Subobject type. Passed: " + type + ".");
-               }
-       }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleEROSubobjectHandlerFactory.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleEROSubobjectHandlerFactory.java
new file mode 100644 (file)
index 0000000..f0aeb62
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.EROSubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+public final class SimpleEROSubobjectHandlerFactory implements EROSubobjectHandlerRegistry {
+       private final HandlerRegistry<DataContainer, EROSubobjectParser, EROSubobjectSerializer> handlers = new HandlerRegistry<>();
+
+       @Override
+       public AutoCloseable registerSubobjectParser(final int subobjectType, final EROSubobjectParser parser) {
+               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
+               return this.handlers.registerParser(subobjectType, parser);
+       }
+
+       @Override
+       public EROSubobjectParser getSubobjectParser(final int subobjectType) {
+               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
+               return this.handlers.getParser(subobjectType);
+       }
+
+       @Override
+       public AutoCloseable registerSubobjectSerializer(final Class<? extends CSubobject> subobjectClass,
+                       final EROSubobjectSerializer serializer) {
+               return this.handlers.registerSerializer(subobjectClass, serializer);
+       }
+
+       @Override
+       public EROSubobjectSerializer getSubobjectSerializer(final Subobjects subobject) {
+               return this.handlers.getSerializer(subobject.getImplementedInterface());
+       }
+}
index f35ec11664333e31c723d2c85fcdbf976de4b188..e64697d5c28af0674243569398432594a3d480f4 100644 (file)
@@ -8,67 +8,15 @@
 package org.opendaylight.protocol.pcep.impl;
 
 import org.opendaylight.protocol.concepts.HandlerRegistry;
-import org.opendaylight.protocol.pcep.impl.message.PCCreateMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPErrorMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPKeepAliveMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPNotificationMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPOpenMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPReplyMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPReportMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPRequestMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPUpdateRequestMessageParser;
 import org.opendaylight.protocol.pcep.spi.MessageHandlerRegistry;
 import org.opendaylight.protocol.pcep.spi.MessageParser;
 import org.opendaylight.protocol.pcep.spi.MessageSerializer;
-import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcinitiateMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcntfMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrepMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcreqMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrptMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcupdMessage;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 import com.google.common.base.Preconditions;
 
 public final class SimpleMessageHandlerRegistry implements MessageHandlerRegistry {
-       public static final MessageHandlerRegistry INSTANCE;
-
-       static {
-               final MessageHandlerRegistry reg = new SimpleMessageHandlerRegistry();
-
-               final ObjectHandlerRegistry objReg = new SimpleObjectHandlerRegistry();
-
-               reg.registerMessageParser(PCEPOpenMessageParser.TYPE, new PCEPOpenMessageParser(objReg));
-               reg.registerMessageParser(PCEPNotificationMessageParser.TYPE, new PCEPNotificationMessageParser(objReg));
-               reg.registerMessageParser(PCEPKeepAliveMessageParser.TYPE, new PCEPKeepAliveMessageParser(objReg));
-               reg.registerMessageParser(PCEPReplyMessageParser.TYPE, new PCEPReplyMessageParser(objReg));
-               reg.registerMessageParser(PCEPRequestMessageParser.TYPE, new PCEPRequestMessageParser(objReg));
-               reg.registerMessageParser(PCEPErrorMessageParser.TYPE, new PCEPErrorMessageParser(objReg));
-               reg.registerMessageParser(PCEPCloseMessageParser.TYPE, new PCEPCloseMessageParser(objReg));
-               reg.registerMessageParser(PCEPUpdateRequestMessageParser.TYPE, new PCEPUpdateRequestMessageParser(objReg));
-               reg.registerMessageParser(PCEPReportMessageParser.TYPE, new PCEPReportMessageParser(objReg));
-               reg.registerMessageParser(PCCreateMessageParser.TYPE, new PCCreateMessageParser(objReg));
-
-               reg.registerMessageSerializer(OpenMessage.class, new PCEPOpenMessageParser(objReg));
-               reg.registerMessageSerializer(PcntfMessage.class, new PCEPNotificationMessageParser(objReg));
-               reg.registerMessageSerializer(KeepaliveMessage.class, new PCEPKeepAliveMessageParser(objReg));
-               reg.registerMessageSerializer(PcrepMessage.class, new PCEPReplyMessageParser(objReg));
-               reg.registerMessageSerializer(PcreqMessage.class, new PCEPRequestMessageParser(objReg));
-               reg.registerMessageSerializer(PcerrMessage.class, new PCEPErrorMessageParser(objReg));
-               reg.registerMessageSerializer(CloseMessage.class, new PCEPCloseMessageParser(objReg));
-               reg.registerMessageSerializer(PcupdMessage.class, new PCEPUpdateRequestMessageParser(objReg));
-               reg.registerMessageSerializer(PcrptMessage.class, new PCEPReportMessageParser(objReg));
-               reg.registerMessageSerializer(PcinitiateMessage.class, new PCCreateMessageParser(objReg));
-
-               INSTANCE = reg;
-       }
 
        private final HandlerRegistry<DataContainer, MessageParser, MessageSerializer> handlers = new HandlerRegistry<>();
 
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleRROSubobjectHandlerFactory.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleRROSubobjectHandlerFactory.java
new file mode 100644 (file)
index 0000000..8252929
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.RROSubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+public final class SimpleRROSubobjectHandlerFactory implements RROSubobjectHandlerRegistry {
+       private final HandlerRegistry<DataContainer, RROSubobjectParser, RROSubobjectSerializer> handlers = new HandlerRegistry<>();
+
+       @Override
+       public AutoCloseable registerSubobjectParser(final int subobjectType, final RROSubobjectParser parser) {
+               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
+               return this.handlers.registerParser(subobjectType, parser);
+       }
+
+       @Override
+       public RROSubobjectParser getSubobjectParser(final int subobjectType) {
+               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
+               return this.handlers.getParser(subobjectType);
+       }
+
+       @Override
+       public AutoCloseable registerSubobjectSerializer(final Class<? extends CSubobject> subobjectClass,
+                       final RROSubobjectSerializer serializer) {
+               return this.handlers.registerSerializer(subobjectClass, serializer);
+       }
+
+       @Override
+       public RROSubobjectSerializer getSubobjectSerializer(final Subobjects subobject) {
+               return this.handlers.getSerializer(subobject.getImplementedInterface());
+       }
+}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleSubobjectHandlerFactory.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleSubobjectHandlerFactory.java
deleted file mode 100644 (file)
index ebe4707..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.SubobjectHandlerRegistry;
-import org.opendaylight.protocol.pcep.spi.SubobjectParser;
-import org.opendaylight.protocol.pcep.spi.SubobjectSerializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-
-import com.google.common.base.Preconditions;
-
-public final class SimpleSubobjectHandlerFactory implements SubobjectHandlerRegistry {
-       private final HandlerRegistry<DataContainer, SubobjectParser, SubobjectSerializer> handlers = new HandlerRegistry<>();
-
-       @Override
-       public AutoCloseable registerSubobjectParser(final int subobjectType, final SubobjectParser parser) {
-               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
-               return handlers.registerParser(subobjectType, parser);
-       }
-
-       @Override
-       public SubobjectParser getSubobjectParser(final int subobjectType) {
-               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
-               return handlers.getParser(subobjectType);
-       }
-
-       @Override
-       public AutoCloseable registerSubobjectSerializer(final Class<? extends CSubobject> subobjectClass, final SubobjectSerializer serializer) {
-               return handlers.registerSerializer(subobjectClass, serializer);
-       }
-
-       @Override
-       public SubobjectSerializer getSubobjectSerializer(final CSubobject subobject) {
-               return handlers.getSerializer(subobject.getImplementedInterface());
-       }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleXROSubobjectHandlerFactory.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/SimpleXROSubobjectHandlerFactory.java
new file mode 100644 (file)
index 0000000..9ef5b9d
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.XROSubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+public final class SimpleXROSubobjectHandlerFactory implements XROSubobjectHandlerRegistry {
+       private final HandlerRegistry<DataContainer, XROSubobjectParser, XROSubobjectSerializer> handlers = new HandlerRegistry<>();
+
+       @Override
+       public AutoCloseable registerSubobjectParser(final int subobjectType, final XROSubobjectParser parser) {
+               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
+               return this.handlers.registerParser(subobjectType, parser);
+       }
+
+       @Override
+       public XROSubobjectParser getSubobjectParser(final int subobjectType) {
+               Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
+               return this.handlers.getParser(subobjectType);
+       }
+
+       @Override
+       public AutoCloseable registerSubobjectSerializer(final Class<? extends CSubobject> subobjectClass,
+                       final XROSubobjectSerializer serializer) {
+               return this.handlers.registerSerializer(subobjectClass, serializer);
+       }
+
+       @Override
+       public XROSubobjectSerializer getSubobjectSerializer(final Subobjects subobject) {
+               return this.handlers.getSerializer(subobject.getImplementedInterface());
+       }
+}
index fcded2e917483c9f86b289a4b0eeacfdb289baa9..59b3867b033943320e6f1e2821425ad0ddc49ae2 100644 (file)
@@ -9,12 +9,14 @@ package org.opendaylight.protocol.pcep.impl;
 
 import javax.annotation.concurrent.ThreadSafe;
 
+import org.opendaylight.protocol.pcep.spi.EROSubobjectHandlerRegistry;
 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;
-import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectHandlerRegistry;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectHandlerRegistry;
 
 /**
  *
@@ -34,9 +36,9 @@ public final class SingletonPCEPProviderContext implements PCEPProviderContext {
        private final LabelHandlerRegistry labelReg = new SimpleLabelHandlerRegistry();
        private final MessageHandlerRegistry msgReg = new SimpleMessageHandlerRegistry();
        private final ObjectHandlerRegistry objReg = new SimpleObjectHandlerRegistry();
-       private final SubobjectHandlerRegistry eroSubReg =  new SimpleSubobjectHandlerFactory();
-       private final SubobjectHandlerRegistry rroSubReg =  new SimpleSubobjectHandlerFactory();
-       private final SubobjectHandlerRegistry xroSubReg =  new SimpleSubobjectHandlerFactory();
+       private final EROSubobjectHandlerRegistry eroSubReg = new SimpleEROSubobjectHandlerFactory();
+       private final RROSubobjectHandlerRegistry rroSubReg = new SimpleRROSubobjectHandlerFactory();
+       private final XROSubobjectHandlerRegistry xroSubReg = new SimpleXROSubobjectHandlerFactory();
        private final TlvHandlerRegistry tlvReg = new SimpleTlvHandlerRegistry();
 
        private SingletonPCEPProviderContext() {
@@ -48,37 +50,37 @@ public final class SingletonPCEPProviderContext implements PCEPProviderContext {
        }
 
        @Override
-       public LabelHandlerRegistry getHandlerRegistry() {
+       public LabelHandlerRegistry getLabelHandlerRegistry() {
                return labelReg;
        }
 
        @Override
        public MessageHandlerRegistry getMessageHandlerRegistry() {
-               return msgReg;
+               return this.msgReg;
        }
 
        @Override
        public ObjectHandlerRegistry getObjectHandlerRegistry() {
-               return objReg;
+               return this.objReg;
        }
 
        @Override
-       public SubobjectHandlerRegistry getEROSubobjectHandlerRegistry() {
-               return eroSubReg;
+       public EROSubobjectHandlerRegistry getEROSubobjectHandlerRegistry() {
+               return this.eroSubReg;
        }
 
        @Override
-       public SubobjectHandlerRegistry getRROSubobjectHandlerRegistry() {
-               return rroSubReg;
+       public RROSubobjectHandlerRegistry getRROSubobjectHandlerRegistry() {
+               return this.rroSubReg;
        }
 
        @Override
-       public SubobjectHandlerRegistry getXROSubobjectHandlerRegistry() {
-               return xroSubReg;
+       public XROSubobjectHandlerRegistry getXROSubobjectHandlerRegistry() {
+               return this.xroSubReg;
        }
 
        @Override
        public TlvHandlerRegistry getTlvHandlerRegistry() {
-               return tlvReg;
+               return this.tlvReg;
        }
 }
similarity index 92%
rename from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java
rename to pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/AbstractObjectWithTlvsParser.java
index b4ec3f75b6e057ee0e005f5fe27c133027c99bd0..625841d33126fc525d0bfaf1c0885c9f3e918646 100644 (file)
@@ -5,9 +5,13 @@
  * 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;
+package org.opendaylight.protocol.pcep.impl.message;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
 import org.slf4j.Logger;
index db158e3f73c88502bfd4e24608a18e0aeff6bed8..49157897cc830e09f09fb1beeaf593268418dbc6 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.pcep.impl.message;
 import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
+import org.opendaylight.protocol.pcep.impl.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcinitiateMessage;
index 5fd81073bbede711c36651600807dc5798391358..b54e773a817165ca0848c3e0d3cfee9f7537d12d 100644 (file)
@@ -13,7 +13,7 @@ import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
+import org.opendaylight.protocol.pcep.impl.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Close;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.CloseBuilder;
index bc3192f3ee4ab5bc4acbad8522064dfdf579cea9..e458ed414e7124c79eef96c27ce8d663a9492a84 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrorMapping;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.UnknownObject;
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
+import org.opendaylight.protocol.pcep.impl.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
index baf317e8011acf14d5200d68e9482222f74ba58c..22ebf6e7b661d2938f20037d7b6b34d4ccb4ed35 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.protocol.pcep.impl.message;
 
 import io.netty.buffer.ByteBuf;
 
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
+import org.opendaylight.protocol.pcep.impl.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
index 23732fd9bc873eb1efa731f71c049864f844a81a..a157b1e703af38c1db81fbbe96791beabf4c5cc4 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrorMapping;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.UnknownObject;
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
+import org.opendaylight.protocol.pcep.impl.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcntfBuilder;
index 90731f71210bb67af803c890736bc35795ab0de0..270e7cbf770cb4bf2062bdac1d0877c469a719d3 100644 (file)
@@ -13,7 +13,7 @@ import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
+import org.opendaylight.protocol.pcep.impl.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
index 2e69e6885577ac60ec11040e77f37c33601e18ea..ee351680ed12d7632d2f7f31b7c4a6278ad48298 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.pcep.impl.message;
 import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
+import org.opendaylight.protocol.pcep.impl.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrepMessage;
index 304fec1c9e66fd564cdb659897e66fdb22386b20..88d3cfeaca38a7b69e83b3f1c925bcf4a3f58f39 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.pcep.impl.message;
 import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
+import org.opendaylight.protocol.pcep.impl.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrptMessage;
index 8cf2f499b08e7aca8ed3db4f3643bb1e4860d83e..ee6b934297f26799b8454b7916377ca82bec2bc5 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.pcep.impl.message;
 import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
+import org.opendaylight.protocol.pcep.impl.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrepMessage;
index 530c4eb9d525278b9ff81f2c795ec3504e43a013..3892c72f6e874f5ef1815d4bdd760d18c8add50a 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.pcep.impl.message;
 import io.netty.buffer.ByteBuf;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
+import org.opendaylight.protocol.pcep.impl.AbstractMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcupdMessage;
similarity index 70%
rename from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithSubobjectsParser.java
rename to pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/AbstractEROWithSubobjectsParser.java
index 7daaf988dd1c6779eb9573bec6fb8f1d013748a9..8265e8e4de74167810d38761cb63c26a8d17d5f5 100644 (file)
@@ -5,25 +5,26 @@
  * 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;
+package org.opendaylight.protocol.pcep.impl.object;
 
 import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 
-public abstract class AbstractObjectWithSubobjectsParser<BUILDER> implements ObjectParser, ObjectSerializer {
+public abstract class AbstractEROWithSubobjectsParser implements ObjectParser, ObjectSerializer {
 
-       private static final Logger logger = LoggerFactory.getLogger(AbstractObjectWithSubobjectsParser.class);
+       private static final Logger logger = LoggerFactory.getLogger(AbstractEROWithSubobjectsParser.class);
 
        private static final int SUB_TYPE_FLAG_F_LENGTH = 1;
        private static final int SUB_LENGTH_F_LENGTH = 1;
@@ -35,13 +36,13 @@ public abstract class AbstractObjectWithSubobjectsParser<BUILDER> implements Obj
 
        protected static final int PADDED_TO = 4;
 
-       private final SubobjectHandlerRegistry subobjReg;
+       private final EROSubobjectHandlerRegistry subobjReg;
 
-       protected AbstractObjectWithSubobjectsParser(final SubobjectHandlerRegistry subobjReg) {
+       protected AbstractEROWithSubobjectsParser(final EROSubobjectHandlerRegistry subobjReg) {
                this.subobjReg = Preconditions.checkNotNull(subobjReg);
        }
 
-       protected final void parseSubobjects(final BUILDER builder, final byte[] bytes) throws PCEPDeserializerException {
+       protected List<Subobjects> parseSubobjects(final byte[] bytes) throws PCEPDeserializerException {
                if (bytes == null) {
                        throw new IllegalArgumentException("Byte array is mandatory.");
                }
@@ -49,12 +50,12 @@ public abstract class AbstractObjectWithSubobjectsParser<BUILDER> implements Obj
                boolean loose_flag = false;
                int type;
 
-               final Map<CSubobject, Boolean> subs = Maps.newHashMap();
-
                byte[] soContentsBytes;
                int length;
                int offset = 0;
 
+               final List<Subobjects> subs = Lists.newArrayList();
+
                while (offset < bytes.length) {
 
                        loose_flag = ((bytes[offset + TYPE_FLAG_F_OFFSET] & (1 << 7)) != 0) ? true : false;
@@ -71,33 +72,31 @@ public abstract class AbstractObjectWithSubobjectsParser<BUILDER> implements Obj
                        System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
 
                        logger.debug("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
-                       final CSubobject subObj = this.subobjReg.getSubobjectParser(type).parseSubobject(soContentsBytes);
-                       logger.debug("Subobject was parsed. {}", subObj);
+                       final Subobjects sub = this.subobjReg.getSubobjectParser(type).parseSubobject(soContentsBytes, loose_flag);
+                       logger.debug("Subobject was parsed. {}", sub);
 
-                       subs.put(subObj, loose_flag);
+                       subs.add(sub);
 
                        offset += length;
                }
-               // addSubobject(builder, subs);
+               return subs;
        }
 
-       protected final byte[] serializeSubobject(final Map<CSubobject, Boolean> subobjects) {
+       protected final byte[] serializeSubobject(final List<Subobjects> subobjects) {
 
                final List<byte[]> result = Lists.newArrayList();
 
                int finalLength = 0;
 
-               for (final Entry<CSubobject, Boolean> entry : subobjects.entrySet()) {
-
-                       final CSubobject subobject = entry.getKey();
+               for (final Subobjects subobject : subobjects) {
 
-                       final SubobjectSerializer serializer = this.subobjReg.getSubobjectSerializer(subobject);
+                       final EROSubobjectSerializer serializer = this.subobjReg.getSubobjectSerializer(subobject);
 
                        final byte[] valueBytes = serializer.serializeSubobject(subobject);
 
                        final byte[] bytes = new byte[SUB_HEADER_LENGTH + valueBytes.length];
 
-                       final byte typeBytes = (byte) (ByteArray.cutBytes(ByteArray.intToBytes(serializer.getType()), (Integer.SIZE / 8) - 1)[0] | (entry.getValue() ? 1 << 7
+                       final byte typeBytes = (byte) (ByteArray.cutBytes(ByteArray.intToBytes(serializer.getType()), (Integer.SIZE / 8) - 1)[0] | (subobject.isLoose() ? 1 << 7
                                        : 0));
                        final byte lengthBytes = ByteArray.cutBytes(ByteArray.intToBytes(valueBytes.length), (Integer.SIZE / 8) - 1)[0];
 
@@ -117,7 +116,4 @@ public abstract class AbstractObjectWithSubobjectsParser<BUILDER> implements Obj
                }
                return resultBytes;
        }
-
-       // public abstract void addSubobject(final BUILDER builder, final Map<CSubobject, Boolean> subobjects);
-
 }
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/AbstractRROWithSubobjectsParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/AbstractRROWithSubobjectsParser.java
new file mode 100644 (file)
index 0000000..49fbf18
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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.object;
+
+import java.util.List;
+
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Subobjects;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+
+public abstract class AbstractRROWithSubobjectsParser implements ObjectParser, ObjectSerializer {
+
+       private static final Logger logger = LoggerFactory.getLogger(AbstractRROWithSubobjectsParser.class);
+
+       private static final int SUB_TYPE_FLAG_F_LENGTH = 1;
+       private static final int SUB_LENGTH_F_LENGTH = 1;
+       private static final int SUB_HEADER_LENGTH = SUB_TYPE_FLAG_F_LENGTH + SUB_LENGTH_F_LENGTH;
+
+       public static final int TYPE_FLAG_F_OFFSET = 0;
+       public static final int LENGTH_F_OFFSET = TYPE_FLAG_F_OFFSET + SUB_TYPE_FLAG_F_LENGTH;
+       public static final int SO_CONTENTS_OFFSET = LENGTH_F_OFFSET + SUB_LENGTH_F_LENGTH;
+
+       protected static final int PADDED_TO = 4;
+
+       private final RROSubobjectHandlerRegistry subobjReg;
+
+       protected AbstractRROWithSubobjectsParser(final RROSubobjectHandlerRegistry subobjReg) {
+               this.subobjReg = Preconditions.checkNotNull(subobjReg);
+       }
+
+       protected List<Subobjects> parseSubobjects(final byte[] bytes) throws PCEPDeserializerException {
+               if (bytes == null) {
+                       throw new IllegalArgumentException("Byte array is mandatory.");
+               }
+
+               int type;
+
+               byte[] soContentsBytes;
+               int length;
+               int offset = 0;
+
+               final List<Subobjects> subs = Lists.newArrayList();
+
+               while (offset < bytes.length) {
+
+                       length = ByteArray.bytesToInt(ByteArray.subByte(bytes, offset + LENGTH_F_OFFSET, SUB_LENGTH_F_LENGTH));
+
+                       type = bytes[offset + TYPE_FLAG_F_OFFSET];
+
+                       if (length > bytes.length - offset) {
+                               throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
+                                               + (bytes.length - offset));
+                       }
+
+                       soContentsBytes = new byte[length - SO_CONTENTS_OFFSET];
+                       System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
+
+                       logger.debug("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
+                       final Subobjects sub = this.subobjReg.getSubobjectParser(type).parseSubobject(soContentsBytes);
+                       logger.debug("Subobject was parsed. {}", sub);
+
+                       subs.add(sub);
+
+                       offset += length;
+               }
+               return subs;
+       }
+
+       protected final byte[] serializeSubobject(final List<Subobjects> subobjects) {
+
+               final List<byte[]> result = Lists.newArrayList();
+
+               int finalLength = 0;
+
+               for (final Subobjects subobject : subobjects) {
+
+                       final RROSubobjectSerializer serializer = this.subobjReg.getSubobjectSerializer(subobject);
+
+                       final byte[] valueBytes = serializer.serializeSubobject(subobject);
+
+                       final byte[] bytes = new byte[SUB_HEADER_LENGTH + valueBytes.length];
+
+                       final byte typeBytes = (ByteArray.cutBytes(ByteArray.intToBytes(serializer.getType()), (Integer.SIZE / 8) - 1)[0]);
+                       final byte lengthBytes = ByteArray.cutBytes(ByteArray.intToBytes(valueBytes.length), (Integer.SIZE / 8) - 1)[0];
+
+                       bytes[0] = typeBytes;
+                       bytes[1] = lengthBytes;
+                       System.arraycopy(valueBytes, 0, bytes, SUB_HEADER_LENGTH, valueBytes.length);
+
+                       finalLength += bytes.length;
+                       result.add(bytes);
+               }
+
+               final byte[] resultBytes = new byte[finalLength];
+               int byteOffset = 0;
+               for (final byte[] b : result) {
+                       System.arraycopy(b, 0, resultBytes, byteOffset, b.length);
+                       byteOffset += b.length;
+               }
+               return resultBytes;
+       }
+}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/AbstractXROWithSubobjectsParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/AbstractXROWithSubobjectsParser.java
new file mode 100644 (file)
index 0000000..89309c9
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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.object;
+
+import java.util.List;
+
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+
+public abstract class AbstractXROWithSubobjectsParser implements ObjectParser, ObjectSerializer {
+
+       private static final Logger logger = LoggerFactory.getLogger(AbstractXROWithSubobjectsParser.class);
+
+       private static final int SUB_TYPE_FLAG_F_LENGTH = 1;
+       private static final int SUB_LENGTH_F_LENGTH = 1;
+       private static final int SUB_HEADER_LENGTH = SUB_TYPE_FLAG_F_LENGTH + SUB_LENGTH_F_LENGTH;
+
+       public static final int TYPE_FLAG_F_OFFSET = 0;
+       public static final int LENGTH_F_OFFSET = TYPE_FLAG_F_OFFSET + SUB_TYPE_FLAG_F_LENGTH;
+       public static final int SO_CONTENTS_OFFSET = LENGTH_F_OFFSET + SUB_LENGTH_F_LENGTH;
+
+       protected static final int PADDED_TO = 4;
+
+       private final XROSubobjectHandlerRegistry subobjReg;
+
+       protected AbstractXROWithSubobjectsParser(final XROSubobjectHandlerRegistry subobjReg) {
+               this.subobjReg = Preconditions.checkNotNull(subobjReg);
+       }
+
+       protected List<Subobjects> parseSubobjects(final byte[] bytes) throws PCEPDeserializerException {
+               if (bytes == null) {
+                       throw new IllegalArgumentException("Byte array is mandatory.");
+               }
+
+               int type;
+
+               byte[] soContentsBytes;
+               int length;
+               int offset = 0;
+
+               final List<Subobjects> subs = Lists.newArrayList();
+
+               while (offset < bytes.length) {
+
+                       length = ByteArray.bytesToInt(ByteArray.subByte(bytes, offset + LENGTH_F_OFFSET, SUB_LENGTH_F_LENGTH));
+
+                       type = bytes[offset + TYPE_FLAG_F_OFFSET];
+
+                       if (length > bytes.length - offset) {
+                               throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
+                                               + (bytes.length - offset));
+                       }
+
+                       soContentsBytes = new byte[length - SO_CONTENTS_OFFSET];
+                       System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
+
+                       logger.debug("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
+                       final Subobjects sub = this.subobjReg.getSubobjectParser(type).parseSubobject(soContentsBytes, false);
+                       logger.debug("Subobject was parsed. {}", sub);
+
+                       subs.add(sub);
+
+                       offset += length;
+               }
+               return subs;
+       }
+
+       protected final byte[] serializeSubobject(final List<Subobjects> subobjects) {
+
+               final List<byte[]> result = Lists.newArrayList();
+
+               int finalLength = 0;
+
+               for (final Subobjects subobject : subobjects) {
+
+                       final XROSubobjectSerializer serializer = this.subobjReg.getSubobjectSerializer(subobject);
+
+                       final byte[] valueBytes = serializer.serializeSubobject(subobject);
+
+                       final byte[] bytes = new byte[SUB_HEADER_LENGTH + valueBytes.length];
+
+                       final byte typeBytes = (ByteArray.cutBytes(ByteArray.intToBytes(serializer.getType()), (Integer.SIZE / 8) - 1)[0]);
+                       final byte lengthBytes = ByteArray.cutBytes(ByteArray.intToBytes(valueBytes.length), (Integer.SIZE / 8) - 1)[0];
+
+                       bytes[0] = typeBytes;
+                       bytes[1] = lengthBytes;
+                       System.arraycopy(valueBytes, 0, bytes, SUB_HEADER_LENGTH, valueBytes.length);
+
+                       finalLength += bytes.length;
+                       result.add(bytes);
+               }
+
+               final byte[] resultBytes = new byte[finalLength];
+               int byteOffset = 0;
+               for (final byte[] b : result) {
+                       System.arraycopy(b, 0, resultBytes, byteOffset, b.length);
+                       byteOffset += b.length;
+               }
+               return resultBytes;
+       }
+}
index 5d0eda91b47c0534e5661d774ce3db4e8c588f09..dee802b16391f7a949563707f022a9a926140c27 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.BandwidthObject;
index 088dfd027de53d5f6dfa58402d9beff0d41b72cd..c8f88cbf33224591eff6a7e24bed637d62246088 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClasstypeObject;
index 6eac2708da6336347be79ca0b6603dd9beeddf59..f02047d064c4e1c0dac80f43516157da3b423372 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.Util;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseObject;
index 59ecbd4802e96e7a4c13515c1e5ad61f91fe9ffc..72a957fc7d51e55869bae5d3a14c534a9e9b19a7 100644 (file)
@@ -12,7 +12,7 @@ import org.opendaylight.protocol.concepts.Ipv6Util;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.EndpointsObject;
index 5612f81f9045cdae4a699c62e2f0366dbfc71b60..a2700cae8a3162b5214e024b3b6b0dc0b6a8955e 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.Util;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
index 0617e315ec50b6b46a62b9133cd61a988f3ec67c..b911a880437be7bc02268cc60340cb5e02530780 100644 (file)
@@ -1,69 +1,63 @@
 /*
- * 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
- */
+* 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.object;
 
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.PCEPDocumentedException;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExcludeRouteObject;
+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.pcreq.message.pcreq.message.svec.XroBuilder;
 
 /**
  * Parser for {@link ExcludeRouteObject}
  */
-// FIXME: fix model, this object is not used in a message
-public final class PCEPExcludeRouteObjectParser { // extends AbstractObjectParser<ExcludeRouterBuilder> {
+public final class PCEPExcludeRouteObjectParser extends AbstractXROWithSubobjectsParser {
 
        public static final int CLASS = 7; // FIXME: to actual value
 
        public static final int TYPE = 1;
 
-       // public PCEPExcludeRouteObjectParser(final HandlerRegistry registry) {
-       // super(registry);
-       // }
-       //
-       // @Override
-       // public ExcludeRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws
-       // PCEPDeserializerException,
-       // PCEPDocumentedException {
-       // if (bytes == null || bytes.length == 0)
-       // throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
-       //
-       // final ExcludeRouterBuilder builder = new ExcludeRouterBuilder();
-       //
-       // builder.setIgnore(header.isIgnore());
-       // builder.setProcessingRule(header.isProcessingRule());
-       // // FIXME: add subobjects
-       // return builder.build();
-       // }
-       //
-       // @Override
-       // public void addTlv(final ExcludeRouterBuilder builder, final Tlv tlv) {
-       // // No tlvs defined
-       // }
-       //
-       // @Override
-       // public byte[] serializeObject(final Object object) {
-       // if (!(object instanceof ExcludeRouteObject))
-       // throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() +
-       // ". Needed ExcludeRouteObject.");
-       //
-       // assert !(((ExcludeRouteObject) object).getSubobjects().isEmpty()) : "Empty Excluded Route Object.";
-       //
-       // // return PCEPEROSubobjectParser.put(((ExplicitRouteObject) obj).getSubobjects());
-       //
-       // // FIXME: add subobjects
-       // return null;
-       // }
-       //
-       // @Override
-       // public int getObjectType() {
-       // return TYPE;
-       // }
-       //
-       // @Override
-       // public int getObjectClass() {
-       // return CLASS;
-       // }
+       public PCEPExcludeRouteObjectParser(final XROSubobjectHandlerRegistry registry) {
+               super(registry);
+       }
+
+       @Override
+       public ExcludeRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
+                       PCEPDocumentedException {
+               if (bytes == null || bytes.length == 0)
+                       throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
+
+               final XroBuilder builder = new XroBuilder();
+
+               builder.setIgnore(header.isIgnore());
+               builder.setProcessingRule(header.isProcessingRule());
+               builder.setSubobjects(parseSubobjects(bytes));
+               return builder.build();
+       }
+
+       @Override
+       public byte[] serializeObject(final Object object) {
+               if (!(object instanceof ExcludeRouteObject))
+                       throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed ExcludeRouteObject.");
+               final ExcludeRouteObject obj = (ExcludeRouteObject) object;
+               assert !(obj.getSubobjects().isEmpty()) : "Empty Excluded Route Object.";
+               return serializeSubobject(obj.getSubobjects());
+       }
+
+       @Override
+       public int getObjectType() {
+               return TYPE;
+       }
+
+       @Override
+       public int getObjectClass() {
+               return CLASS;
+       }
 }
index dc8e3362c2f09e1a7d91bbde1e3d441c2e45b79b..2eb4fd3d05592c3e8f2d7c78da746f4687d64263 100644 (file)
@@ -7,47 +7,37 @@
  */
 package org.opendaylight.protocol.pcep.impl.object;
 
-import java.util.Map;
-
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithSubobjectsParser;
-import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExplicitRouteObject;
 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.explicit.route.object.Subobjects;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.definition.ExplicitRouteBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
-
-import com.google.common.collect.Maps;
 
 /**
  * Parser for {@link ExplicitRouteObject}
  */
-public class PCEPExplicitRouteObjectParser extends AbstractObjectWithSubobjectsParser<ExplicitRouteBuilder> {
+public class PCEPExplicitRouteObjectParser extends AbstractEROWithSubobjectsParser {
 
        public static final int CLASS = 7;
 
        public static final int TYPE = 1;
 
-       public PCEPExplicitRouteObjectParser(final SubobjectHandlerRegistry subobjReg) {
+       public PCEPExplicitRouteObjectParser(final EROSubobjectHandlerRegistry subobjReg) {
                super(subobjReg);
        }
 
        @Override
        public ExplicitRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-       PCEPDocumentedException {
+                       PCEPDocumentedException {
                if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
                }
-
                final ExplicitRouteBuilder builder = new ExplicitRouteBuilder();
-
                builder.setIgnore(header.isIgnore());
                builder.setProcessingRule(header.isProcessingRule());
-
-               parseSubobjects(builder, bytes);
+               builder.setSubobjects(parseSubobjects(bytes));
                return builder.build();
        }
 
@@ -62,38 +52,9 @@ public class PCEPExplicitRouteObjectParser extends AbstractObjectWithSubobjectsP
 
                assert !(ero.getSubobjects().isEmpty()) : "Empty Explicit Route Object.";
 
-               final Map<CSubobject, Boolean> subs = Maps.newHashMap();
-               for (final Subobjects s : ero.getSubobjects()) {
-                       subs.put((CSubobject) s, s.isLoose());
-               }
-               return serializeSubobject(subs);
+               return serializeSubobject(ero.getSubobjects());
        }
 
-       // @Override
-       // public void addSubobject(ExplicitRouteBuilder builder, Map<CSubobject, Boolean> subobjects) {
-       // List<Subobjects> subs = Lists.newArrayList();
-       // for (Entry<CSubobject, Boolean> entry : subobjects.entrySet()) {
-       // SubobjectsBuilder b = new SubobjectsBuilder();
-       // b.setLoose(entry.getValue());
-       // CSubobject sub = entry.getKey();
-       // if (sub instanceof IpPrefixSubobject) {
-       // b.setSubobjectType(new IpPrefixBuilder().setIpPrefix(((IpPrefix)sub).getIpPrefix()).build());
-       // subs.add(b.build());
-       // } else if (sub instanceof AsNumberSubobject) {
-       // b.setSubobjectType(new AsNumberBuilder().setAsNumber((AsNumber)sub).build());
-       // subs.add(b.build());
-       // } else if (sub instanceof LabelSubobject) {
-       // b.setSubobjectType(new LabelBuilder().setLabels(((Label)sub).getLabels()).build());
-       // subs.add(b.build());
-       // } else if (sub instanceof UnnumberedSubobject) {
-       // b.setSubobjectType(new
-       // UnnumberedBuilder().setInterfaceId(((Unnumbered)sub).getInterfaceId()).setRouterId(((Unnumbered)sub).getRouterId()).build());
-       // subs.add(b.build());
-       // }
-       // }
-       // builder.setSubobjects(subs);
-       // }
-
        @Override
        public int getObjectType() {
                return TYPE;
index c088927df2a09f24697b636159dc3968bd954cd3..add8e19bfe02739226a28c7e22eb67f7bab781c6 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.GcObject;
index 77e994c3b014f160bac4539937fa1c87e576b69d..214314132da9266c88900a0197be626a6a38c278 100644 (file)
@@ -7,31 +7,36 @@
  */
 package org.opendaylight.protocol.pcep.impl.object;
 
+import java.util.List;
+
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithSubobjectsParser;
-import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectHandlerRegistry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
 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.include.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.SubobjectsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.IncludeRouteBuilder;
 
+import com.google.common.collect.Lists;
+
 /**
  * Parser for {@link IncludeRouteObject}
  */
-public class PCEPIncludeRouteObjectParser extends AbstractObjectWithSubobjectsParser<IncludeRouteBuilder> {
+public class PCEPIncludeRouteObjectParser extends AbstractEROWithSubobjectsParser {
 
        public static final int CLASS = 10;
 
        public static final int TYPE = 1;
 
-       public PCEPIncludeRouteObjectParser(final SubobjectHandlerRegistry subobjReg) {
+       public PCEPIncludeRouteObjectParser(final EROSubobjectHandlerRegistry subobjReg) {
                super(subobjReg);
        }
 
        @Override
        public IncludeRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-       PCEPDocumentedException {
+                       PCEPDocumentedException {
                if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
                }
@@ -40,7 +45,12 @@ public class PCEPIncludeRouteObjectParser extends AbstractObjectWithSubobjectsPa
 
                builder.setIgnore(header.isIgnore());
                builder.setProcessingRule(header.isProcessingRule());
-               // FIXME: add subobjects
+
+               final List<Subobjects> subs = Lists.newArrayList();
+               for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects s : parseSubobjects(bytes)) {
+                       subs.add(new SubobjectsBuilder().setSubobjectType(s.getSubobjectType()).build());
+               }
+               builder.setSubobjects(subs);
                return builder.build();
        }
 
@@ -49,12 +59,18 @@ public class PCEPIncludeRouteObjectParser extends AbstractObjectWithSubobjectsPa
                if (!(object instanceof IncludeRouteObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed IncludeRouteObject.");
                }
+               final IncludeRouteObject iro = ((IncludeRouteObject) object);
 
-               assert !(((IncludeRouteObject) object).getSubobjects().isEmpty()) : "Empty Include Route Object.";
+               assert !(iro.getSubobjects().isEmpty()) : "Empty Include Route Object.";
+
+               final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects> subs = Lists.newArrayList();
+
+               for (final Subobjects s : iro.getSubobjects()) {
+                       subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.SubobjectsBuilder().setLoose(
+                                       false).setSubobjectType(s.getSubobjectType()).build());
+               }
 
-               // return PCEPEROSubobjectParser.put(((PCEPIncludeRouteObject) object).getSubobjects());
-               // FIXME add subobjects
-               return null;
+               return serializeSubobject(subs);
        }
 
        @Override
index 2508adae57c4b965b00e2b74b515f01868b1efd1..8eb1d4035b3b7b38a3d68b9fd5c634d887f2d014 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
index 0a236ff104fd66c8e40562584bf79c605af8038f..9b8461010700b77e3f5abfeac1590f11e7372f65 100644 (file)
@@ -11,7 +11,7 @@ import java.util.BitSet;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspObject;
index 1a0edc317186ab3ba9effb5c7b08f6dd89ad223a..6745c01f29a8162c212d9d0430f4e0a3864b3c2d 100644 (file)
@@ -11,7 +11,7 @@ import java.util.BitSet;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspaObject;
index 21d534877183424f17e8f8c61aed3b08031c474b..bef8f5710eda1e0090dab906f813629490250e5b 100644 (file)
@@ -11,7 +11,7 @@ import java.util.BitSet;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
index a565b635205976dc9bd87fa616315e95936418d4..66102e1ef9b96fb425c08f1d04bb35d0042b81f9 100644 (file)
@@ -12,7 +12,7 @@ import java.util.BitSet;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.Util;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.pcrep.pcrep.message.replies.result.failure.NoPath;
index cfe395b28b642d7c478542128437f2133908070f..4168ca0017edeaf91a634d33d4a950affd327b17 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.Util;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
index 0d9f03324f63a8095b4b06c136f7ec1db392ca0d..9654b0691bb5de635b3ffe724eeb40893a0fd4f4 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
index 8c2e063368028089b111b421a5872b7dcbfc59d2..29444baa4fbad0e1f103a83c579d0477b6c43cd7 100644 (file)
@@ -12,7 +12,7 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.impl.Util;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
index d47b78bb537be3463c40a10c9127505217280908..570f054cfea6ba9c9363660e47924a7630821c85 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 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;
index a9bcb769d91df984515648898b139df97fbc3843..ec3aa7d61e1d22c362a8b8b0f3d11a972f2a7dcf 100644 (file)
@@ -9,8 +9,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithSubobjectsParser;
-import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectHandlerRegistry;
 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.ReportedRouteObject;
@@ -19,28 +18,27 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 /**
  * Parser for {@link ReportedRouteObject}
  */
-public class PCEPReportedRouteObjectParser extends AbstractObjectWithSubobjectsParser<ReportedRouteBuilder> {
+public class PCEPReportedRouteObjectParser extends AbstractRROWithSubobjectsParser {
 
        public static final int CLASS = 8;
 
        public static final int TYPE = 1;
 
-       public PCEPReportedRouteObjectParser(final SubobjectHandlerRegistry subobjReg) {
+       public PCEPReportedRouteObjectParser(final RROSubobjectHandlerRegistry subobjReg) {
                super(subobjReg);
        }
 
        @Override
        public ReportedRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
-       PCEPDocumentedException {
+                       PCEPDocumentedException {
                if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
                }
-
                final ReportedRouteBuilder builder = new ReportedRouteBuilder();
 
                builder.setIgnore(header.isIgnore());
                builder.setProcessingRule(header.isProcessingRule());
-               // FIXME: add subobjects
+               builder.setSubobjects(parseSubobjects(bytes));
                return builder.build();
        }
 
@@ -51,10 +49,9 @@ public class PCEPReportedRouteObjectParser extends AbstractObjectWithSubobjectsP
                                        + ". Needed ReportedRouteObject.");
                }
 
-               assert !(((ReportedRouteObject) object).getSubobjects().isEmpty()) : "Empty Reported Route Object.";
-               // FIXME add subobjects
-               // return PCEPRROSubobjectParser.put(((ReportedRouteObject) object).getSubobjects());
-               return null;
+               final ReportedRouteObject obj = (ReportedRouteObject) object;
+               assert !(obj.getSubobjects().isEmpty()) : "Empty Reported Route Object.";
+               return serializeSubobject(obj.getSubobjects());
        }
 
        @Override
index acc5b1eecde4ea8f37b204dae0a7ef073331d4c4..3e174c3caf397b859375f0e4bd7277932e419c87 100644 (file)
@@ -14,7 +14,7 @@ import java.util.BitSet;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.Util;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
index a606587aac3f4bdb6d0a6755f8ce83de37ad69c3..1daac5fb191273730c96d08658d92835e4dc9da0 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 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;
index 2dfd0dd8abb359126c7a91dcd819785cdc06074d..c3f6b142761d30b2856a3af69e274c82ec7bb79b 100644 (file)
@@ -12,7 +12,7 @@ import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
+import org.opendaylight.protocol.pcep.impl.message.AbstractObjectWithTlvsParser;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
index 23b74fd78cb37fa1c180cdcd6c5ea7c4b0c3630b..09a5affb03061df1d81ae8b00c60d95e29745cad 100644 (file)
@@ -8,19 +8,20 @@
 package org.opendaylight.protocol.pcep.impl.subobject;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.SubobjectParser;
-import org.opendaylight.protocol.pcep.spi.SubobjectSerializer;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.SubobjectsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AsNumberSubobject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.SubobjectType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.AsNumberBuilder;
 
 /**
  * Parser for {@link AsNumberSubobject}
  */
-
-public class EROAsNumberSubobjectParser implements SubobjectParser, SubobjectSerializer {
+public class EROAsNumberSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
 
        public static final int TYPE = 32;
 
@@ -31,7 +32,7 @@ public class EROAsNumberSubobjectParser implements SubobjectParser, SubobjectSer
        public static final int CONTENT_LENGTH = AS_NUMBER_LENGTH + AS_NUMBER_OFFSET;
 
        @Override
-       public AsNumberSubobject parseSubobject(final byte[] buffer) throws PCEPDeserializerException {
+       public Subobjects parseSubobject(final byte[] buffer, final boolean loose) throws PCEPDeserializerException {
                if (buffer == null || buffer.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                }
@@ -40,20 +41,23 @@ public class EROAsNumberSubobjectParser implements SubobjectParser, SubobjectSer
                                        + CONTENT_LENGTH + ".");
                }
 
-               return new AsNumberBuilder().setAsNumber(new AsNumber(ByteArray.bytesToLong(buffer))).build();
+               return new SubobjectsBuilder().setLoose(loose).setSubobjectType(
+                               new AsNumberBuilder().setAsNumber(new AsNumber(ByteArray.bytesToLong(buffer))).build()).build();
        }
 
        @Override
-       public byte[] serializeSubobject(final CSubobject subobject) {
-               if (!(subobject instanceof AsNumberSubobject)) {
-                       throw new IllegalArgumentException("Unknown subobject instance. Passed " + subobject.getClass()
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               if (!(subobject.getSubobjectType() instanceof AsNumberSubobject)) {
+                       throw new IllegalArgumentException("Unknown subobject instance. Passed " + subobject.getSubobjectType().getClass()
                                        + ". Needed AsNumberSubobject.");
                }
 
                final byte[] retBytes = new byte[CONTENT_LENGTH];
 
-               System.arraycopy(ByteArray.longToBytes(((AsNumberSubobject) subobject).getAsNumber().getValue()), Long.SIZE / Byte.SIZE
-                               - AS_NUMBER_LENGTH, retBytes, AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
+               final SubobjectType s = subobject.getSubobjectType();
+
+               System.arraycopy(ByteArray.longToBytes(((AsNumberSubobject) s).getAsNumber().getValue()), Long.SIZE / Byte.SIZE - AS_NUMBER_LENGTH,
+                               retBytes, AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
 
                return retBytes;
        }
index 0a2ad69cd9914b8ef8d2935aef67c026200e5d79..3da789766a4d5f2a6d173e25e0b4e259874f9766 100644 (file)
@@ -8,19 +8,31 @@
 package org.opendaylight.protocol.pcep.impl.subobject;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.impl.PCEPXROSubobjectParser;
-import org.opendaylight.protocol.pcep.subobject.EROExplicitExclusionRouteSubobject;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects;
 
-public class EROExplicitExclusionRouteSubobjectParser {
-    public static EROExplicitExclusionRouteSubobject parse(byte[] cutBytes, boolean loose) throws PCEPDeserializerException {
-       if (cutBytes == null || cutBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+public class EROExplicitExclusionRouteSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
 
-       return new EROExplicitExclusionRouteSubobject(PCEPXROSubobjectParser.parse(cutBytes));
-    }
+       public static final int TYPE = 33;
 
-    public static byte[] put(EROExplicitExclusionRouteSubobject objToSerialize) {
-       return PCEPXROSubobjectParser.put(objToSerialize.getXroSubobjets());
-    }
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer, final boolean loose) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
+                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
 
+               // return new EROExplicitExclusionRouteSubobject(PCEPXROSubobjectParser.parse(cutBytes));
+               return null;
+       }
+
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               // return PCEPXROSubobjectParser.put(subobject.getXroSubobjets());
+               return new byte[0];
+       }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
 }
index 85ca26e0549e47c2b51ab2c1756599165a22e4f4..097c8dd315184abd49f59698b853380773a09fe4 100644 (file)
@@ -10,11 +10,12 @@ package org.opendaylight.protocol.pcep.impl.subobject;
 import org.opendaylight.protocol.concepts.Ipv4Util;
 import org.opendaylight.protocol.concepts.Ipv6Util;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.spi.SubobjectParser;
-import org.opendaylight.protocol.pcep.spi.SubobjectSerializer;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.SubobjectsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.IpPrefixSubobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.IpPrefixBuilder;
 
@@ -23,16 +24,18 @@ import com.google.common.primitives.UnsignedBytes;
 /**
  * Parser for {@link IpPrefixSubobject}
  */
-public class EROIpPrefixSubobjectParser implements SubobjectParser, SubobjectSerializer {
+public class EROIpPrefixSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
 
-       public static final int TYPE = 32;
+       public static final int TYPE = 1;
+
+       public static final int TYPE6 = 2;
 
        public static final int IP4_F_LENGTH = 4;
        public static final int PREFIX4_F_LENGTH = 1;
 
        public static final int PREFIX4_F_OFFSET = IP4_F_LENGTH;
 
-       public static final int CONTENT4_LENGTH = PREFIX4_F_OFFSET + PREFIX4_F_LENGTH + 1; //added reserved field of size 1 byte
+       public static final int CONTENT4_LENGTH = PREFIX4_F_OFFSET + PREFIX4_F_LENGTH + 1; // added reserved field of size 1
 
        public static final int IP_F_LENGTH = 16;
        public static final int PREFIX_F_LENGTH = 1;
@@ -40,50 +43,62 @@ public class EROIpPrefixSubobjectParser implements SubobjectParser, SubobjectSer
        public static final int IP_F_OFFSET = 0;
        public static final int PREFIX_F_OFFSET = IP_F_OFFSET + IP_F_LENGTH;
 
-       public static final int CONTENT_LENGTH = PREFIX_F_OFFSET + PREFIX_F_LENGTH + 1; // added reserved field of size 1 byte
+       public static final int CONTENT_LENGTH = PREFIX_F_OFFSET + PREFIX_F_LENGTH + 1; // added reserved field of size 1
+                                                                                                                                                                       // byte
 
        @Override
-       public IpPrefixSubobject parseSubobject(final byte[] buffer) throws PCEPDeserializerException {
+       public Subobjects parseSubobject(final byte[] buffer, final boolean loose) throws PCEPDeserializerException {
                if (buffer == null || buffer.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                }
 
+               final SubobjectsBuilder builder = new SubobjectsBuilder();
+               builder.setLoose(loose);
+
                if (buffer.length == CONTENT4_LENGTH) {
                        final int length = UnsignedBytes.toInt(buffer[PREFIX4_F_OFFSET]);
-                       return new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.subByte(buffer, 0, IP4_F_LENGTH), length))).build();
+                       builder.setSubobjectType(new IpPrefixBuilder().setIpPrefix(
+                                       new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.subByte(buffer, 0, IP4_F_LENGTH), length))).build());
+                       return builder.build();
                } else if (buffer.length == CONTENT_LENGTH) {
                        final int length = UnsignedBytes.toInt(buffer[PREFIX_F_OFFSET]);
-                       return new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(ByteArray.subByte(buffer, 0, IP_F_LENGTH), length))).build();
+                       builder.setSubobjectType(new IpPrefixBuilder().setIpPrefix(
+                                       new IpPrefix(Ipv6Util.prefixForBytes(ByteArray.subByte(buffer, 0, IP_F_LENGTH), length))).build());
+                       return builder.build();
                } else {
                        throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + ";");
                }
        }
 
        @Override
-       public byte[] serializeSubobject(final CSubobject subobject) {
-               if (!(subobject instanceof IpPrefixSubobject)) {
-                       throw new IllegalArgumentException("Unknown subobject instance. Passed " + subobject.getClass()
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               if (!(subobject.getSubobjectType() instanceof IpPrefixSubobject)) {
+                       throw new IllegalArgumentException("Unknown subobject instance. Passed " + subobject.getSubobjectType().getClass()
                                        + ". Needed IpPrefixSubobject.");
                }
-
-               final IpPrefixSubobject specObj = (IpPrefixSubobject) subobject;
+               final IpPrefixSubobject specObj = (IpPrefixSubobject) subobject.getSubobjectType();
                final IpPrefix prefix = specObj.getIpPrefix();
 
                if (prefix.getIpv4Prefix() != null) {
                        final byte[] retBytes = new byte[CONTENT4_LENGTH];
                        ByteArray.copyWhole(prefix.getIpv4Prefix().getValue().getBytes(), retBytes, 0);
+                       retBytes[PREFIX_F_OFFSET] = ByteArray.intToBytes(Ipv4Util.getPrefixLength(prefix))[Integer.SIZE / Byte.SIZE - 1];
                        return retBytes;
                } else if (prefix.getIpv6Prefix() != null) {
-                       final byte[] retBytes = new byte[CONTENT4_LENGTH];
-                       ByteArray.copyWhole(prefix.getIpv4Prefix().getValue().getBytes(), retBytes, 0);
+                       final byte[] retBytes = new byte[CONTENT_LENGTH];
+                       ByteArray.copyWhole(prefix.getIpv6Prefix().getValue().getBytes(), retBytes, 0);
+                       retBytes[PREFIX_F_OFFSET] = ByteArray.intToBytes(Ipv4Util.getPrefixLength(prefix))[Integer.SIZE / Byte.SIZE - 1];
                        return retBytes;
-                       //retBytes[PREFIX_F_OFFSET] = ByteArray.intToBytes(prefix.getLength())[Integer.SIZE / Byte.SIZE - 1];
                }
-               return new byte[0];
+               throw new IllegalArgumentException("No valid IpPrefix");
        }
 
        @Override
        public int getType() {
                return TYPE;
        }
+
+       public int getType6() {
+               return TYPE6;
+       }
 }
index 175439f260bb4a86a39f10dfb31a8cabfeebefcb..89499ab3de5347c2af4580c8fa84a4c132db71ee 100644 (file)
@@ -11,79 +11,94 @@ import java.util.Arrays;
 import java.util.BitSet;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.impl.Util.BiParsersMap;
-import org.opendaylight.protocol.pcep.subobject.EROLabelSubobject;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
+import org.opendaylight.protocol.pcep.spi.LabelHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.LabelParser;
+import org.opendaylight.protocol.pcep.spi.LabelSerializer;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.SubobjectsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.LabelSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.LabelBuilder;
 
-public class EROLabelSubobjectParser {
+import com.google.common.base.Preconditions;
 
-       public static final int RES_F_LENGTH = 1;
+public class EROLabelSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
 
-       public static final int C_TYPE_F_LENGTH = 1;
+       public static final int TYPE = 3;
 
-       public static final int RES_F_OFFSET = 0;
+       private static final int RES_F_LENGTH = 1;
 
-       public static final int C_TYPE_F_OFFSET = RES_F_OFFSET + RES_F_LENGTH;
+       private static final int C_TYPE_F_LENGTH = 1;
 
-       public static final int HEADER_LENGTH = C_TYPE_F_OFFSET + C_TYPE_F_LENGTH;
+       private static final int RES_F_OFFSET = 0;
 
-       public static final int U_FLAG_OFFSET = 0;
+       private static final int C_TYPE_F_OFFSET = RES_F_OFFSET + RES_F_LENGTH;
 
-       private static class MapOfParsers extends BiParsersMap<Class<? extends EROLabelSubobject>, Integer, EROLabelParser> {
-               private final static MapOfParsers instance = new MapOfParsers();
+       private static final int HEADER_LENGTH = C_TYPE_F_OFFSET + C_TYPE_F_LENGTH;
 
-               private MapOfParsers() {
-                       this.fillInMap();
-               }
-
-               private void fillInMap() {
+       private static final int U_FLAG_OFFSET = 0;
 
-               }
+       private final LabelHandlerRegistry registry;
 
-               public static MapOfParsers getInstance() {
-                       return instance;
-               }
+       public EROLabelSubobjectParser(final LabelHandlerRegistry labelReg) {
+               this.registry = Preconditions.checkNotNull(labelReg);
        }
 
-       public static EROLabelSubobject parse(final byte[] soContentsBytes, final boolean loose) throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer, final boolean loose) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length < HEADER_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: >"
+               if (buffer.length < HEADER_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: >"
                                        + HEADER_LENGTH + ".");
 
-               final BitSet reserved = ByteArray.bytesToBitSet(Arrays.copyOfRange(soContentsBytes, RES_F_OFFSET, RES_F_LENGTH));
+               final BitSet reserved = ByteArray.bytesToBitSet(Arrays.copyOfRange(buffer, RES_F_OFFSET, RES_F_LENGTH));
 
-               final int c_type = soContentsBytes[C_TYPE_F_OFFSET] & 0xFF;
+               final short c_type = (short) (buffer[C_TYPE_F_OFFSET] & 0xFF);
 
-               final EROLabelParser parser = MapOfParsers.getInstance().getValueFromKeyValue(c_type);
+               final LabelParser parser = this.registry.getLabelParser(c_type);
 
                if (parser == null) {
                        throw new PCEPDeserializerException("Unknown C-TYPE for ero label subobject. Passed: " + c_type);
                }
 
-               return parser.parse(ByteArray.cutBytes(soContentsBytes, HEADER_LENGTH), reserved.get(U_FLAG_OFFSET), loose);
+               final LabelBuilder builder = new LabelBuilder();
+               builder.setUniDirectional(reserved.get(U_FLAG_OFFSET));
+               builder.setLabelType(parser.parseLabel(ByteArray.cutBytes(buffer, HEADER_LENGTH)));
+               return new SubobjectsBuilder().setLoose(loose).setSubobjectType(builder.build()).build();
        }
 
-       public static byte[] put(final EROLabelSubobject objToSerialize) {
-               final Integer c_type = MapOfParsers.getInstance().getKeyValueFromKey(objToSerialize.getClass());
-               final EROLabelParser parser = MapOfParsers.getInstance().getValueFromKeyValue(c_type);
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               Preconditions.checkNotNull(subobject.getSubobjectType(), "Subobject type cannot be empty.");
 
-               if (c_type == null || parser == null)
-                       throw new IllegalArgumentException("Unknown EROLabelSubobject instance. Passed " + objToSerialize.getClass());
+               final LabelSubobject label = (LabelSubobject) subobject.getSubobjectType();
 
-               final byte[] labelbytes = parser.put(objToSerialize);
+               final LabelSerializer serializer = this.registry.getLabelSerializer((CLabel) label);
+
+               if (serializer == null)
+                       throw new IllegalArgumentException("Unknown EROLabelSubobject instance. Passed " + label.getClass());
+
+               final byte[] labelbytes = serializer.serializeSubobject((CLabel) label);
 
                final byte[] retBytes = new byte[labelbytes.length + HEADER_LENGTH];
 
                System.arraycopy(labelbytes, 0, retBytes, HEADER_LENGTH, labelbytes.length);
 
                final BitSet reserved = new BitSet();
-               reserved.set(U_FLAG_OFFSET, objToSerialize.isUpStream());
+               reserved.set(U_FLAG_OFFSET, label.isUniDirectional());
                System.arraycopy(ByteArray.bitSetToBytes(reserved, RES_F_LENGTH), 0, retBytes, RES_F_OFFSET, RES_F_LENGTH);
 
-               retBytes[C_TYPE_F_OFFSET] = (byte) c_type.intValue();
+               retBytes[C_TYPE_F_OFFSET] = (byte) serializer.getType();
 
                return retBytes;
        }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
 }
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKeySubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKeySubobjectParser.java
new file mode 100644 (file)
index 0000000..34f6c99
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * 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.subobject;
+
+import java.util.Arrays;
+
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.SubobjectsBuilder;
+
+public class EROPathKeySubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
+
+       public static final int TYPE = 64;
+
+       public static final int TYPE128 = 65;
+
+       public static final int PK_F_LENGTH = 2;
+       public static final int PCE_ID_F_LENGTH = 4;
+
+       public static final int PCE128_ID_F_LENGTH = 16;
+
+       public static final int PK_F_OFFSET = 0;
+       public static final int PCE_ID_F_OFFSET = PK_F_OFFSET + PK_F_LENGTH;
+
+       public static final int CONTENT_LENGTH = PCE_ID_F_OFFSET + PCE_ID_F_LENGTH;
+
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer, final boolean loose) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
+                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               if (buffer.length != CONTENT_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: >"
+                                       + CONTENT_LENGTH + ".");
+
+               final int pathKey = ByteArray.bytesToShort(Arrays.copyOfRange(buffer, PK_F_OFFSET, PCE_ID_F_OFFSET)) & 0xFFFF;
+
+               final byte[] pceId = Arrays.copyOfRange(buffer, PCE_ID_F_OFFSET, CONTENT_LENGTH);
+
+               final SubobjectsBuilder builder = new SubobjectsBuilder();
+               builder.setLoose(loose);
+               // builder.setSubobjectType(value);
+               return builder.build();
+       }
+
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               final byte[] retBytes = new byte[CONTENT_LENGTH];
+
+               // System.arraycopy(ByteArray.shortToBytes((short) objToSerialize.getPathKey()), 0, retBytes, PK_F_OFFSET,
+               // PK_F_LENGTH);
+               //
+               // if (objToSerialize.getPceId().length != PCE_ID_F_LENGTH)
+               // throw new IllegalArgumentException("Wrong length of pce id. Passed: " + objToSerialize.getPceId().length +
+               // ". Expected: ="
+               // + PCE_ID_F_LENGTH);
+               // System.arraycopy(objToSerialize.getPceId(), 0, retBytes, PCE_ID_F_OFFSET, PCE_ID_F_LENGTH);
+
+               return retBytes;
+       }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
+
+       public int getType128() {
+               return TYPE128;
+       }
+}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKeyWith128PCEIDSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKeyWith128PCEIDSubobjectParser.java
deleted file mode 100644 (file)
index 8c8bd43..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.EROPathKeyWith128PCEIDSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-
-public class EROPathKeyWith128PCEIDSubobjectParser {
-
-    public static final int PK_F_LENGTH = 2;
-    public static final int PCE_ID_F_LENGTH = 16;
-
-    public static final int PK_F_OFFSET = 0;
-    public static final int PCE_ID_F_OFFSET = PK_F_OFFSET + PK_F_LENGTH;
-
-    public static final int CONTENT_LENGTH = PCE_ID_F_OFFSET + PCE_ID_F_LENGTH;
-
-    public static EROPathKeyWith128PCEIDSubobject parse(byte[] soContentsBytes, boolean loose) throws PCEPDeserializerException {
-       if (soContentsBytes == null || soContentsBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (soContentsBytes.length != CONTENT_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: >" + CONTENT_LENGTH + ".");
-
-       final int pathKey = ByteArray.bytesToShort(Arrays.copyOfRange(soContentsBytes, PK_F_OFFSET, PCE_ID_F_OFFSET)) & 0xFFFF;
-
-       final byte[] pceId = Arrays.copyOfRange(soContentsBytes, PCE_ID_F_OFFSET, CONTENT_LENGTH);
-
-       return new EROPathKeyWith128PCEIDSubobject(pathKey, pceId, loose);
-    }
-
-    public static byte[] put(EROPathKeyWith128PCEIDSubobject objToSerialize) {
-       final byte[] retBytes = new byte[CONTENT_LENGTH];
-
-       System.arraycopy(ByteArray.shortToBytes((short) objToSerialize.getPathKey()), 0, retBytes, PK_F_OFFSET, PK_F_LENGTH);
-
-       if (objToSerialize.getPceId().length != PCE_ID_F_LENGTH)
-           throw new IllegalArgumentException("Wrong length of pce id. Passed: " + objToSerialize.getPceId().length + ". Expected: =" + PCE_ID_F_LENGTH);
-       System.arraycopy(objToSerialize.getPceId(), 0, retBytes, PCE_ID_F_OFFSET, PCE_ID_F_LENGTH);
-
-       return retBytes;
-    }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKeyWith32PCEIDSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROPathKeyWith32PCEIDSubobjectParser.java
deleted file mode 100644 (file)
index ffbb7da..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.EROPathKeyWith32PCEIDSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-
-public class EROPathKeyWith32PCEIDSubobjectParser {
-
-    public static final int PK_F_LENGTH = 2;
-    public static final int PCE_ID_F_LENGTH = 4;
-
-    public static final int PK_F_OFFSET = 0;
-    public static final int PCE_ID_F_OFFSET = PK_F_OFFSET + PK_F_LENGTH;
-
-    public static final int CONTENT_LENGTH = PCE_ID_F_OFFSET + PCE_ID_F_LENGTH;
-
-    public static EROPathKeyWith32PCEIDSubobject parse(byte[] soContentsBytes, boolean loose) throws PCEPDeserializerException {
-       if (soContentsBytes == null || soContentsBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (soContentsBytes.length != CONTENT_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: >" + CONTENT_LENGTH + ".");
-
-       final int pathKey = ByteArray.bytesToShort(Arrays.copyOfRange(soContentsBytes, PK_F_OFFSET, PCE_ID_F_OFFSET)) & 0xFFFF;
-
-       final byte[] pceId = Arrays.copyOfRange(soContentsBytes, PCE_ID_F_OFFSET, CONTENT_LENGTH);
-
-       return new EROPathKeyWith32PCEIDSubobject(pathKey, pceId, loose);
-    }
-
-    public static byte[] put(EROPathKeyWith32PCEIDSubobject objToSerialize) {
-       final byte[] retBytes = new byte[CONTENT_LENGTH];
-
-       System.arraycopy(ByteArray.shortToBytes((short) objToSerialize.getPathKey()), 0, retBytes, PK_F_OFFSET, PK_F_LENGTH);
-
-       if (objToSerialize.getPceId().length != PCE_ID_F_LENGTH)
-           throw new IllegalArgumentException("Wrong length of pce id. Passed: " + objToSerialize.getPceId().length + ". Expected: =" + PCE_ID_F_LENGTH);
-       System.arraycopy(objToSerialize.getPceId(), 0, retBytes, PCE_ID_F_OFFSET, PCE_ID_F_LENGTH);
-
-       return retBytes;
-    }
-}
index 477731e6f0f11760f007716ffd7ac114670817a5..b597bfb7b4ccdc1124f47c3890799fac26346d3b 100644 (file)
@@ -8,15 +8,23 @@
 package org.opendaylight.protocol.pcep.impl.subobject;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.EROUnnumberedInterfaceSubobject;
-import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.SubobjectsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.UnnumberedSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.UnnumberedBuilder;
+
+import com.google.common.primitives.UnsignedInts;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.EROUnnumberedInterfaceSubobject
- * EROUnnumberedInterfaceSubobject}
+ * Parser for {@link UnnumberedSubobject}
  */
-public class EROUnnumberedInterfaceSubobjectParser {
+public class EROUnnumberedInterfaceSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
+
+       public static final int TYPE = 4;
+
        public static final int ROUTER_ID_NUMBER_LENGTH = 4;
        public static final int INTERFACE_ID_NUMBER_LENGTH = 4;
 
@@ -25,33 +33,42 @@ public class EROUnnumberedInterfaceSubobjectParser {
 
        public static final int CONTENT_LENGTH = INTERFACE_ID_NUMBER_OFFSET + INTERFACE_ID_NUMBER_LENGTH;
 
-       public static EROUnnumberedInterfaceSubobject parse(final byte[] soContentsBytes, final boolean loose) throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer, final boolean loose) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
+               if (buffer.length != CONTENT_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: "
                                        + CONTENT_LENGTH + ".");
-
-               // return new EROUnnumberedInterfaceSubobject(new IPv4Address(ByteArray.subByte(soContentsBytes,
-               // ROUTER_ID_NUMBER_OFFSET, ROUTER_ID_NUMBER_LENGTH)), new UnnumberedInterfaceIdentifier(
-               // UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(soContentsBytes, INTERFACE_ID_NUMBER_OFFSET,
-               // INTERFACE_ID_NUMBER_LENGTH)))), loose);
-               return null;
+               final SubobjectsBuilder builder = new SubobjectsBuilder();
+               builder.setLoose(loose);
+               final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
+               ubuilder.setRouterId(ByteArray.bytesToLong(ByteArray.subByte(buffer, ROUTER_ID_NUMBER_OFFSET, ROUTER_ID_NUMBER_LENGTH)));
+               ubuilder.setInterfaceId(UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(buffer, INTERFACE_ID_NUMBER_OFFSET,
+                               INTERFACE_ID_NUMBER_LENGTH))));
+               builder.setSubobjectType(ubuilder.build());
+               return builder.build();
        }
 
-       public static byte[] put(final ExplicitRouteSubobject objToSerialize) {
-               if (!(objToSerialize instanceof EROUnnumberedInterfaceSubobject))
-                       throw new IllegalArgumentException("Unknown ExplicitRouteSubobject instance. Passed " + objToSerialize.getClass()
-                                       + ". Needed EROUnnumberedInterfaceSubobject.");
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               if (!(subobject.getSubobjectType() instanceof UnnumberedSubobject))
+                       throw new IllegalArgumentException("Unknown ExplicitRouteSubobject instance. Passed " + subobject.getSubobjectType().getClass()
+                                       + ". Needed UnnumberedSubobject.");
 
                byte[] retBytes;
                retBytes = new byte[CONTENT_LENGTH];
-               final EROUnnumberedInterfaceSubobject specObj = (EROUnnumberedInterfaceSubobject) objToSerialize;
+               final UnnumberedSubobject specObj = (UnnumberedSubobject) subobject.getSubobjectType();
 
-               ByteArray.copyWhole(specObj.getRouterID().getValue().getBytes(), retBytes, ROUTER_ID_NUMBER_OFFSET);
-               System.arraycopy(ByteArray.longToBytes(specObj.getInterfaceID().getInterfaceId()), Long.SIZE / Byte.SIZE
-                               - INTERFACE_ID_NUMBER_LENGTH, retBytes, INTERFACE_ID_NUMBER_OFFSET, INTERFACE_ID_NUMBER_LENGTH);
+               ByteArray.copyWhole(ByteArray.longToBytes(specObj.getRouterId()), retBytes, ROUTER_ID_NUMBER_OFFSET);
+               System.arraycopy(ByteArray.longToBytes(specObj.getInterfaceId()), Long.SIZE / Byte.SIZE - INTERFACE_ID_NUMBER_LENGTH, retBytes,
+                               INTERFACE_ID_NUMBER_OFFSET, INTERFACE_ID_NUMBER_LENGTH);
 
                return retBytes;
        }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
 }
index 7c26fd43a065c5efacf6bfe8992796a3c0ad6910..f46eccb89f2add46759408ec3cc5808db8fe2eca 100644 (file)
@@ -12,6 +12,7 @@ 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.GeneralizedLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.GeneralizedLabelBuilder;
 
 public class GeneralizedLabelParser implements LabelParser, LabelSerializer {
@@ -19,7 +20,7 @@ public class GeneralizedLabelParser implements LabelParser, LabelSerializer {
        public static final int CTYPE = 2;
 
        @Override
-       public GeneralizedLabel parseLabel(final byte[] buffer) throws PCEPDeserializerException {
+       public LabelType parseLabel(final byte[] buffer) throws PCEPDeserializerException {
                if (buffer == null || buffer.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
 
index 99227d39b0abeba3ecbbbeef42ed7947d07b4232..9bebc3a82b9edad7caa284d5bbeaa8f635a6c7a1 100644 (file)
@@ -8,42 +8,60 @@
 package org.opendaylight.protocol.pcep.impl.subobject;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROAsNumberSubobject;
-import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.SubobjectsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AsNumberSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.AsNumberBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.SubobjectType;
 
 /**
  * Parser for {@link org.opendaylight.protocol.pcep.subobject.RROAsNumberSubobject RROAsNumberSubobject}
  */
 
-public class RROAsNumberSubobjectParser {
+public class RROAsNumberSubobjectParser implements RROSubobjectParser, RROSubobjectSerializer {
+
+       public static final int TYPE = 32;
+
        public static final int AS_NUMBER_LENGTH = 2;
 
        public static final int AS_NUMBER_OFFSET = 0;
 
        public static final int CONTENT_LENGTH = AS_NUMBER_LENGTH + AS_NUMBER_OFFSET;
 
-       public static RROAsNumberSubobject parse(final byte[] soContentsBytes) throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
+               if (buffer.length != CONTENT_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: "
                                        + CONTENT_LENGTH + ".");
 
-               return new RROAsNumberSubobject(new AsNumber((long) (ByteArray.bytesToShort(soContentsBytes) & 0xFFFF)));
+               return new SubobjectsBuilder().setSubobjectType(
+                               (SubobjectType) new AsNumberBuilder().setAsNumber(new AsNumber(ByteArray.bytesToLong(buffer))).build()).build();
        }
 
-       public static byte[] put(final ReportedRouteSubobject objToSerialize) {
-               if (!(objToSerialize instanceof RROAsNumberSubobject))
-                       throw new IllegalArgumentException("Unknown ReportedRouteSubobject instance. Passed " + objToSerialize.getClass()
-                                       + ". Needed RROAsNumberSubobject.");
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               if (!(subobject.getSubobjectType() instanceof AsNumberSubobject))
+                       throw new IllegalArgumentException("Unknown ReportedRouteSubobject instance. Passed " + subobject.getSubobjectType().getClass()
+                                       + ". Needed AsNumberSubobject.");
 
                final byte[] retBytes = new byte[CONTENT_LENGTH];
 
-               System.arraycopy(ByteArray.longToBytes(((RROAsNumberSubobject) objToSerialize).getASNumber().getValue()), Long.SIZE / Byte.SIZE
-                               - AS_NUMBER_LENGTH, retBytes, AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
+               final AsNumberSubobject obj = (AsNumberSubobject) subobject.getSubobjectType();
+
+               System.arraycopy(ByteArray.longToBytes(obj.getAsNumber().getValue()), Long.SIZE / Byte.SIZE - AS_NUMBER_LENGTH, retBytes,
+                               AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
 
                return retBytes;
        }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
 }
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROAttributesSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROAttributesSubobjectParser.java
deleted file mode 100644 (file)
index c418a37..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROAttributesSubobject;
-
-public class RROAttributesSubobjectParser {
-
-    public static final int RES_F_LENGTH = 2;
-
-    public static final int RES_F_OFFSET = 0;
-    public static final int ATTRS_F_OFFSET = RES_F_OFFSET + RES_F_LENGTH;
-
-    public static RROAttributesSubobject parse(byte[] soContentsBytes) throws PCEPDeserializerException {
-       if (soContentsBytes == null || soContentsBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (soContentsBytes.length <= RES_F_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: >" + RES_F_LENGTH + ".");
-
-       final byte[] attributes = Arrays.copyOfRange(soContentsBytes, ATTRS_F_OFFSET, soContentsBytes.length);
-
-       return new RROAttributesSubobject(attributes);
-    }
-
-    public static byte[] put(RROAttributesSubobject objToSerialize) {
-       final byte[] retBytes = new byte[RES_F_LENGTH + objToSerialize.getAttributes().length];
-
-       final byte[] attrs = objToSerialize.getAttributes();
-
-       System.arraycopy(attrs, 0, retBytes, ATTRS_F_OFFSET, attrs.length);
-
-       return retBytes;
-    }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROGeneralizedLabelSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROGeneralizedLabelSubobjectParser.java
deleted file mode 100644 (file)
index 2780813..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROGeneralizedLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROLabelSubobject;
-
-public class RROGeneralizedLabelSubobjectParser implements RROLabelParser {
-
-    @Override
-    public RROLabelSubobject parse(byte[] cutBytes, boolean upStream) throws PCEPDeserializerException {
-       if (cutBytes == null || cutBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-
-       return new RROGeneralizedLabelSubobject(cutBytes, upStream);
-    }
-
-    @Override
-    public byte[] put(RROLabelSubobject objToSerialize) {
-       if (!(objToSerialize instanceof RROGeneralizedLabelSubobject))
-           throw new IllegalArgumentException("Unknown RROLabelSubobject instance. Passed " + objToSerialize.getClass()
-                   + ". Needed RROGeneralizedLabelSubobject.");
-       final byte[] retBytes = ((RROGeneralizedLabelSubobject) objToSerialize).getLabel();
-
-       return retBytes;
-    }
-
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROIPv4AddressSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROIPv4AddressSubobjectParser.java
deleted file mode 100644 (file)
index 3b09f23..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-import java.util.BitSet;
-
-import org.opendaylight.protocol.concepts.Ipv4Util;
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROIPAddressSubobject;
-import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-
-import com.google.common.primitives.UnsignedBytes;
-
-/**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.RROIPAddressSubobject RROIPAddressSubobject<IPv4Prefix>}
- */
-public class RROIPv4AddressSubobjectParser {
-       public static final int IP_F_LENGTH = 4;
-       public static final int PREFIX_F_LENGTH = 1;
-       public static final int FLAGS_F_LENGTH = 1;
-
-       public static final int IP_F_OFFSET = 0;
-       public static final int PREFIX_F_OFFSET = IP_F_OFFSET + IP_F_LENGTH;
-       public static final int FLAGS_F_OFFSET = PREFIX_F_OFFSET + PREFIX_F_LENGTH;
-
-       public static final int CONTENT_LENGTH = FLAGS_F_OFFSET + FLAGS_F_LENGTH;
-
-       /*
-        * flags offset in bits
-        */
-       public static final int LPA_F_OFFSET = 7;
-       public static final int LPIU_F_OFFSET = 6;
-
-       public static RROIPAddressSubobject parse(final byte[] soContentsBytes) throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
-                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
-                                       + CONTENT_LENGTH + ".");
-
-               final int length = UnsignedBytes.toInt(soContentsBytes[PREFIX_F_OFFSET]);
-
-               final BitSet flags = ByteArray.bytesToBitSet(Arrays.copyOfRange(soContentsBytes, FLAGS_F_OFFSET, FLAGS_F_OFFSET + FLAGS_F_LENGTH));
-
-               return new RROIPAddressSubobject(new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.subByte(soContentsBytes, IP_F_OFFSET, IP_F_LENGTH),
-                               length)), flags.get(LPA_F_OFFSET), flags.get(LPIU_F_OFFSET));
-       }
-
-       public static byte[] put(final ReportedRouteSubobject objToSerialize) {
-               if (!(objToSerialize instanceof RROIPAddressSubobject))
-                       throw new IllegalArgumentException("Unknown ReportedRouteSubobject instance. Passed " + objToSerialize.getClass()
-                                       + ". Needed RROIPAddressSubobject.");
-
-               final RROIPAddressSubobject specObj = (RROIPAddressSubobject) objToSerialize;
-               final IpPrefix prefix = specObj.getPrefix();
-
-               if (prefix.getIpv4Prefix() != null)
-                       throw new IllegalArgumentException("Unknown AbstractPrefix instance. Passed " + prefix.getClass() + ". Needed IPv4Prefix.");
-
-               final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
-
-               flags.set(LPA_F_OFFSET, specObj.isLocalProtectionAvailable());
-               flags.set(LPIU_F_OFFSET, specObj.isLocalProtectionInUse());
-
-               final byte[] retBytes = new byte[CONTENT_LENGTH];
-               ByteArray.copyWhole(prefix.getIpv4Prefix().getValue().getBytes(), retBytes, IP_F_OFFSET);
-               // retBytes[PREFIX_F_OFFSET] = ByteArray.intToBytes(prefix.getLength())[Integer.SIZE / Byte.SIZE - 1];
-               ByteArray.copyWhole(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH), retBytes, FLAGS_F_OFFSET);
-
-               return retBytes;
-       }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROIPv6AddressSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROIPv6AddressSubobjectParser.java
deleted file mode 100644 (file)
index 14a9a9f..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-import java.util.BitSet;
-
-import org.opendaylight.protocol.concepts.Ipv6Util;
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROIPAddressSubobject;
-import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-
-import com.google.common.primitives.UnsignedBytes;
-
-/**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.RROIPAddressSubobject RROIPAddressSubobject<IPv6Prefix>}
- */
-public class RROIPv6AddressSubobjectParser {
-       public static final int IP_F_LENGTH = 16;
-       public static final int PREFIX_F_LENGTH = 1;
-       public static final int FLAGS_F_LENGTH = 1;
-
-       public static final int IP_F_OFFSET = 0;
-       public static final int PREFIX_F_OFFSET = IP_F_OFFSET + IP_F_LENGTH;
-       public static final int FLAGS_F_OFFSET = PREFIX_F_OFFSET + PREFIX_F_LENGTH;
-
-       public static final int CONTENT_LENGTH = FLAGS_F_OFFSET + FLAGS_F_LENGTH;
-
-       /*
-        * flags offset in bits
-        */
-       public static final int LPA_F_OFFSET = 7;
-       public static final int LPIU_F_OFFSET = 6;
-
-       public static RROIPAddressSubobject parse(final byte[] soContentsBytes) throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
-                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
-                                       + CONTENT_LENGTH + ".");
-
-               final int length = UnsignedBytes.toInt(soContentsBytes[PREFIX_F_OFFSET]);
-
-               final BitSet flags = ByteArray.bytesToBitSet(Arrays.copyOfRange(soContentsBytes, FLAGS_F_OFFSET, FLAGS_F_OFFSET + FLAGS_F_LENGTH));
-
-               return new RROIPAddressSubobject(new IpPrefix(Ipv6Util.prefixForBytes(ByteArray.subByte(soContentsBytes, IP_F_OFFSET, IP_F_LENGTH),
-                               length)), flags.get(LPA_F_OFFSET), flags.get(LPIU_F_OFFSET));
-       }
-
-       public static byte[] put(final ReportedRouteSubobject objToSerialize) {
-               if (!(objToSerialize instanceof RROIPAddressSubobject))
-                       throw new IllegalArgumentException("Unknown ReportedRouteSubobject instance. Passed " + objToSerialize.getClass()
-                                       + ". Needed RROIPAddressSubobject.");
-
-               final RROIPAddressSubobject specObj = (RROIPAddressSubobject) objToSerialize;
-               final IpPrefix prefix = specObj.getPrefix();
-
-               if (prefix.getIpv4Prefix() != null)
-                       throw new IllegalArgumentException("Unknown AbstractPrefix instance. Passed " + prefix.getClass() + ". Needed IPv6Prefix.");
-
-               final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
-
-               flags.set(LPA_F_OFFSET, specObj.isLocalProtectionAvailable());
-               flags.set(LPIU_F_OFFSET, specObj.isLocalProtectionInUse());
-
-               final byte[] retBytes = new byte[CONTENT_LENGTH];
-               ByteArray.copyWhole(prefix.getIpv4Prefix().getValue().getBytes(), retBytes, IP_F_OFFSET);
-               // retBytes[PREFIX_F_OFFSET] = ByteArray.intToBytes(prefix.getLength())[Integer.SIZE / Byte.SIZE - 1];
-               ByteArray.copyWhole(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH), retBytes, FLAGS_F_OFFSET);
-
-               return retBytes;
-       }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROIpPrefixSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROIpPrefixSubobjectParser.java
new file mode 100644 (file)
index 0000000..96bdbaf
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * 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.subobject;
+
+import java.util.Arrays;
+import java.util.BitSet;
+
+import org.opendaylight.protocol.concepts.Ipv4Util;
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.SubobjectsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.IpPrefixSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.subobject.type.IpPrefixBuilder;
+
+import com.google.common.primitives.UnsignedBytes;
+
+/**
+ * Parser for {@link org.opendaylight.protocol.pcep.subobject.RROIPAddressSubobject RROIPAddressSubobject<IPv4Prefix>}
+ */
+public class RROIpPrefixSubobjectParser implements RROSubobjectParser, RROSubobjectSerializer {
+
+       public static final int TYPE = 1;
+
+       public static final int TYPE6 = 2;
+
+       public static final int IP4_F_LENGTH = 4;
+       public static final int PREFIX4_F_LENGTH = 1;
+       public static final int FLAGS4_F_LENGTH = 1;
+
+       public static final int IP4_F_OFFSET = 0;
+       public static final int PREFIX4_F_OFFSET = IP4_F_OFFSET + IP4_F_LENGTH;
+       public static final int FLAGS4_F_OFFSET = PREFIX4_F_OFFSET + PREFIX4_F_LENGTH;
+
+       public static final int CONTENT4_LENGTH = FLAGS4_F_OFFSET + FLAGS4_F_LENGTH;
+
+       public static final int IP_F_LENGTH = 16;
+       public static final int PREFIX_F_LENGTH = 1;
+       public static final int FLAGS_F_LENGTH = 1;
+
+       public static final int IP_F_OFFSET = 0;
+       public static final int PREFIX_F_OFFSET = IP_F_OFFSET + IP_F_LENGTH;
+       public static final int FLAGS_F_OFFSET = PREFIX_F_OFFSET + PREFIX_F_LENGTH;
+
+       public static final int CONTENT_LENGTH = FLAGS_F_OFFSET + FLAGS_F_LENGTH;
+
+       /*
+        * flags offset in bits
+        */
+       public static final int LPA_F_OFFSET = 7;
+       public static final int LPIU_F_OFFSET = 6;
+
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
+                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               if (buffer.length != CONTENT4_LENGTH || buffer.length != CONTENT_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + ";");
+
+               final int length = UnsignedBytes.toInt(buffer[PREFIX4_F_OFFSET]);
+
+               final BitSet flags = ByteArray.bytesToBitSet(Arrays.copyOfRange(buffer, FLAGS4_F_OFFSET, FLAGS4_F_OFFSET + FLAGS4_F_LENGTH));
+
+               final SubobjectsBuilder builder = new SubobjectsBuilder();
+               builder.setProtectionAvailable(flags.get(LPA_F_OFFSET));
+               builder.setProtectionInUse(flags.get(LPIU_F_OFFSET));
+               builder.setSubobjectType(new IpPrefixBuilder().setIpPrefix(
+                               new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.subByte(buffer, IP4_F_OFFSET, IP4_F_LENGTH), length))).build());
+
+               return builder.build();
+       }
+
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               if (!(subobject instanceof IpPrefixSubobject))
+                       throw new IllegalArgumentException("Unknown ReportedRouteSubobject instance. Passed " + subobject.getClass()
+                                       + ". Needed RROIPAddressSubobject.");
+
+               final IpPrefixSubobject specObj = (IpPrefixSubobject) subobject;
+               final IpPrefix prefix = specObj.getIpPrefix();
+
+               if (prefix.getIpv4Prefix() == null && prefix.getIpv6Prefix() == null)
+                       throw new IllegalArgumentException("Unknown AbstractPrefix instance. Passed " + prefix.getClass() + ".");
+
+               final BitSet flags = new BitSet(FLAGS4_F_LENGTH * Byte.SIZE);
+
+               flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable());
+               flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
+
+               final byte[] retBytes = new byte[CONTENT4_LENGTH];
+
+               if (prefix.getIpv4Prefix() != null) {
+                       ByteArray.copyWhole(prefix.getIpv4Prefix().getValue().getBytes(), retBytes, IP4_F_OFFSET);
+                       retBytes[PREFIX4_F_OFFSET] = ByteArray.intToBytes(Ipv4Util.getPrefixLength(prefix))[Integer.SIZE / Byte.SIZE - 1];
+                       ByteArray.copyWhole(ByteArray.bitSetToBytes(flags, FLAGS4_F_LENGTH), retBytes, FLAGS4_F_OFFSET);
+               } else {
+                       ByteArray.copyWhole(prefix.getIpv6Prefix().getValue().getBytes(), retBytes, IP_F_OFFSET);
+                       retBytes[PREFIX_F_OFFSET] = ByteArray.intToBytes(Ipv4Util.getPrefixLength(prefix))[Integer.SIZE / Byte.SIZE - 1];
+                       ByteArray.copyWhole(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH), retBytes, FLAGS_F_OFFSET);
+               }
+               return retBytes;
+       }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
+
+       public int getType6() {
+               return TYPE6;
+       }
+}
index 407c57b8bc98d57baef8ceb4b7465880cbb23a00..4f14c274788fe454f6ecc63c6c179a3558707851 100644 (file)
@@ -11,83 +11,91 @@ import java.util.Arrays;
 import java.util.BitSet;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.impl.Util.BiParsersMap;
-import org.opendaylight.protocol.pcep.subobject.RROGeneralizedLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROType1LabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROWavebandSwitchingLabelSubobject;
+import org.opendaylight.protocol.pcep.spi.LabelHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.LabelParser;
+import org.opendaylight.protocol.pcep.spi.LabelSerializer;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.SubobjectsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.LabelSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.subobject.type.LabelBuilder;
 
-public class RROLabelSubobjectParser {
+import com.google.common.base.Preconditions;
 
-    public static final int RES_F_LENGTH = 1;
+public class RROLabelSubobjectParser implements RROSubobjectParser, RROSubobjectSerializer {
 
-    public static final int C_TYPE_F_LENGTH = 1;
+       public static final int TYPE = 3;
 
-    public static final int RES_F_OFFSET = 0;
+       public static final int RES_F_LENGTH = 1;
 
-    public static final int C_TYPE_F_OFFSET = RES_F_OFFSET + RES_F_LENGTH;
+       public static final int C_TYPE_F_LENGTH = 1;
 
-    public static final int HEADER_LENGTH = C_TYPE_F_OFFSET + C_TYPE_F_LENGTH;
+       public static final int RES_F_OFFSET = 0;
 
-    public static final int U_FLAG_OFFSET = 0;
+       public static final int C_TYPE_F_OFFSET = RES_F_OFFSET + RES_F_LENGTH;
 
-    private static class MapOfParsers extends BiParsersMap<Class<? extends RROLabelSubobject>, Integer, RROLabelParser> {
-       private final static MapOfParsers instance = new MapOfParsers();
+       public static final int HEADER_LENGTH = C_TYPE_F_OFFSET + C_TYPE_F_LENGTH;
 
-       private MapOfParsers() {
-           this.fillInMap();
-       }
+       public static final int U_FLAG_OFFSET = 0;
 
-       private void fillInMap() {
-           this.put(RROType1LabelSubobject.class, 1, new RROType1LabelSubobjectParser());
-           this.put(RROGeneralizedLabelSubobject.class, 2, new RROGeneralizedLabelSubobjectParser());
-           this.put(RROWavebandSwitchingLabelSubobject.class, 3, new RROWavebandSwitchingLabelSubobjectParser());
-       }
+       private final LabelHandlerRegistry registry;
 
-       public static MapOfParsers getInstance() {
-           return instance;
+       public RROLabelSubobjectParser(final LabelHandlerRegistry labelReg) {
+               this.registry = Preconditions.checkNotNull(labelReg);
        }
-    }
 
-    public static RROLabelSubobject parse(byte[] soContentsBytes) throws PCEPDeserializerException {
-       if (soContentsBytes == null || soContentsBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (soContentsBytes.length < HEADER_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: >" + HEADER_LENGTH + ".");
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
+                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               if (buffer.length < HEADER_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: >"
+                                       + HEADER_LENGTH + ".");
+
+               final BitSet reserved = ByteArray.bytesToBitSet(Arrays.copyOfRange(buffer, RES_F_OFFSET, RES_F_LENGTH));
 
-       final BitSet reserved = ByteArray.bytesToBitSet(Arrays.copyOfRange(soContentsBytes, RES_F_OFFSET, RES_F_LENGTH));
+               final short c_type = (short) (buffer[C_TYPE_F_OFFSET] & 0xFF);
 
-       final int c_type = soContentsBytes[C_TYPE_F_OFFSET] & 0xFF;
+               final LabelParser parser = this.registry.getLabelParser(c_type);
 
-       final RROLabelParser parser = MapOfParsers.getInstance().getValueFromKeyValue(c_type);
+               if (parser == null) {
+                       throw new PCEPDeserializerException("Unknown C-TYPE for ero label subobject. Passed: " + c_type);
+               }
 
-       if (parser == null) {
-           throw new PCEPDeserializerException("Unknown C-TYPE for ero label subobject. Passed: " + c_type);
+               final LabelBuilder builder = new LabelBuilder();
+               builder.setUniDirectional(reserved.get(U_FLAG_OFFSET));
+               builder.setLabelType(parser.parseLabel(ByteArray.cutBytes(buffer, HEADER_LENGTH)));
+               return new SubobjectsBuilder().setSubobjectType(builder.build()).build();
        }
 
-       return parser.parse(ByteArray.cutBytes(soContentsBytes, HEADER_LENGTH), reserved.get(U_FLAG_OFFSET));
-    }
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               final LabelSubobject label = (LabelSubobject) subobject.getSubobjectType();
+               final LabelSerializer parser = this.registry.getLabelSerializer((CLabel) label);
 
-    public static byte[] put(RROLabelSubobject objToSerialize) {
-       final Integer c_type = MapOfParsers.getInstance().getKeyValueFromKey(objToSerialize.getClass());
-       final RROLabelParser parser = MapOfParsers.getInstance().getValueFromKeyValue(c_type);
+               if (parser == null)
+                       throw new IllegalArgumentException("Unknown RROLabelSubobject instance. Passed " + subobject.getSubobjectType().getClass());
 
-       if (c_type == null || parser == null)
-           throw new IllegalArgumentException("Unknown RROLabelSubobject instance. Passed " + objToSerialize.getClass());
+               final byte[] labelbytes = parser.serializeSubobject((CLabel) label);
 
-       final byte[] labelbytes = parser.put(objToSerialize);
+               final byte[] retBytes = new byte[labelbytes.length + HEADER_LENGTH];
 
-       final byte[] retBytes = new byte[labelbytes.length + HEADER_LENGTH];
+               System.arraycopy(labelbytes, 0, retBytes, HEADER_LENGTH, labelbytes.length);
 
-       System.arraycopy(labelbytes, 0, retBytes, HEADER_LENGTH, labelbytes.length);
+               final BitSet reserved = new BitSet();
+               reserved.set(U_FLAG_OFFSET, label.isUniDirectional());
+               System.arraycopy(ByteArray.bitSetToBytes(reserved, RES_F_LENGTH), 0, retBytes, RES_F_OFFSET, RES_F_LENGTH);
 
-       final BitSet reserved = new BitSet();
-       reserved.set(U_FLAG_OFFSET, objToSerialize.isUpStream());
-       System.arraycopy(ByteArray.bitSetToBytes(reserved, RES_F_LENGTH), 0, retBytes, RES_F_OFFSET, RES_F_LENGTH);
+               retBytes[C_TYPE_F_OFFSET] = (byte) parser.getType();
 
-       retBytes[C_TYPE_F_OFFSET] = (byte) c_type.intValue();
+               return retBytes;
+       }
 
-       return retBytes;
-    }
+       @Override
+       public int getType() {
+               return TYPE;
+       }
 }
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKeySubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKeySubobjectParser.java
new file mode 100644 (file)
index 0000000..6176929
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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.subobject;
+
+import java.util.Arrays;
+
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.SubobjectsBuilder;
+
+public class RROPathKeySubobjectParser implements RROSubobjectParser, RROSubobjectSerializer {
+
+       public static final int TYPE = 64;
+
+       public static final int TYPE128 = 65;
+
+       public static final int PK_F_LENGTH = 2;
+       public static final int PCE_ID_F_LENGTH = 4;
+
+       public static final int PCE128_ID_F_LENGTH = 16;
+
+       public static final int PK_F_OFFSET = 0;
+       public static final int PCE_ID_F_OFFSET = PK_F_OFFSET + PK_F_LENGTH;
+
+       public static final int CONTENT_LENGTH = PCE_ID_F_OFFSET + PCE_ID_F_LENGTH;
+
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
+                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               if (buffer.length != CONTENT_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: >"
+                                       + CONTENT_LENGTH + ".");
+
+               final int pathKey = ByteArray.bytesToShort(Arrays.copyOfRange(buffer, PK_F_OFFSET, PCE_ID_F_OFFSET)) & 0xFFFF;
+
+               final byte[] pceId = Arrays.copyOfRange(buffer, PCE_ID_F_OFFSET, CONTENT_LENGTH);
+
+               final SubobjectsBuilder builder = new SubobjectsBuilder();
+               // builder.setSubobjectType(value);
+               return builder.build();
+       }
+
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               final byte[] retBytes = new byte[CONTENT_LENGTH];
+
+               // System.arraycopy(ByteArray.shortToBytes((short) objToSerialize.getPathKey()), 0, retBytes, PK_F_OFFSET,
+               // PK_F_LENGTH);
+               //
+               // if (objToSerialize.getPceId().length != PCE_ID_F_LENGTH)
+               // throw new IllegalArgumentException("Wrong length of pce id. Passed: " + objToSerialize.getPceId().length +
+               // ". Expected: ="
+               // + PCE_ID_F_LENGTH);
+               // System.arraycopy(objToSerialize.getPceId(), 0, retBytes, PCE_ID_F_OFFSET, PCE_ID_F_LENGTH);
+
+               return retBytes;
+       }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
+
+       public int getType128() {
+               return TYPE128;
+       }
+}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKeyWith128PCEIDSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKeyWith128PCEIDSubobjectParser.java
deleted file mode 100644 (file)
index edc0cbb..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROPathKeyWith128PCEIDSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-
-public class RROPathKeyWith128PCEIDSubobjectParser {
-
-    public static final int PK_F_LENGTH = 2;
-    public static final int PCE_ID_F_LENGTH = 16;
-
-    public static final int PK_F_OFFSET = 0;
-    public static final int PCE_ID_F_OFFSET = PK_F_OFFSET + PK_F_LENGTH;
-
-    public static final int CONTENT_LENGTH = PCE_ID_F_OFFSET + PCE_ID_F_LENGTH;
-
-    public static RROPathKeyWith128PCEIDSubobject parse(byte[] soContentsBytes) throws PCEPDeserializerException {
-       if (soContentsBytes == null || soContentsBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (soContentsBytes.length != CONTENT_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: >" + CONTENT_LENGTH + ".");
-
-       final int pathKey = ByteArray.bytesToShort(Arrays.copyOfRange(soContentsBytes, PK_F_OFFSET, PCE_ID_F_OFFSET)) & 0xFFFF;
-
-       final byte[] pceId = Arrays.copyOfRange(soContentsBytes, PCE_ID_F_OFFSET, CONTENT_LENGTH);
-
-       return new RROPathKeyWith128PCEIDSubobject(pathKey, pceId);
-    }
-
-    public static byte[] put(RROPathKeyWith128PCEIDSubobject objToSerialize) {
-       final byte[] retBytes = new byte[CONTENT_LENGTH];
-
-       System.arraycopy(ByteArray.shortToBytes((short) objToSerialize.getPathKey()), 0, retBytes, PK_F_OFFSET, PK_F_LENGTH);
-
-       if (objToSerialize.getPceId().length != PCE_ID_F_LENGTH)
-           throw new IllegalArgumentException("Wrong length of pce id. Passed: " + objToSerialize.getPceId().length + ". Expected: =" + PCE_ID_F_LENGTH);
-       System.arraycopy(objToSerialize.getPceId(), 0, retBytes, PCE_ID_F_OFFSET, PCE_ID_F_LENGTH);
-
-       return retBytes;
-    }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKeyWith32PCEIDSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROPathKeyWith32PCEIDSubobjectParser.java
deleted file mode 100644 (file)
index 2668d79..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROPathKeyWith32PCEIDSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-
-public class RROPathKeyWith32PCEIDSubobjectParser {
-
-    public static final int PK_F_LENGTH = 2;
-    public static final int PCE_ID_F_LENGTH = 4;
-
-    public static final int PK_F_OFFSET = 0;
-    public static final int PCE_ID_F_OFFSET = PK_F_OFFSET + PK_F_LENGTH;
-
-    public static final int CONTENT_LENGTH = PCE_ID_F_OFFSET + PCE_ID_F_LENGTH;
-
-    public static RROPathKeyWith32PCEIDSubobject parse(byte[] soContentsBytes) throws PCEPDeserializerException {
-       if (soContentsBytes == null || soContentsBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (soContentsBytes.length != CONTENT_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: =" + CONTENT_LENGTH + ".");
-
-       final int pathKey = ByteArray.bytesToShort(Arrays.copyOfRange(soContentsBytes, PK_F_OFFSET, PCE_ID_F_OFFSET)) & 0xFFFF;
-
-       final byte[] pceId = Arrays.copyOfRange(soContentsBytes, PCE_ID_F_OFFSET, CONTENT_LENGTH);
-
-       return new RROPathKeyWith32PCEIDSubobject(pathKey, pceId);
-    }
-
-    public static byte[] put(RROPathKeyWith32PCEIDSubobject objToSerialize) {
-       final byte[] retBytes = new byte[CONTENT_LENGTH];
-
-       System.arraycopy(ByteArray.shortToBytes((short) objToSerialize.getPathKey()), 0, retBytes, PK_F_OFFSET, PK_F_LENGTH);
-
-       if (objToSerialize.getPceId().length != PCE_ID_F_LENGTH)
-           throw new IllegalArgumentException("Wrong length of pce id. Passed: " + objToSerialize.getPceId().length + ". Expected: =" + PCE_ID_F_LENGTH);
-       System.arraycopy(objToSerialize.getPceId(), 0, retBytes, PCE_ID_F_OFFSET, PCE_ID_F_LENGTH);
-
-       return retBytes;
-    }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROType1LabelSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROType1LabelSubobjectParser.java
deleted file mode 100644 (file)
index ed81e66..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROType1LabelSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-import com.google.common.primitives.UnsignedInts;
-
-public class RROType1LabelSubobjectParser implements RROLabelParser {
-
-    public static final int LABEL_LENGTH = 4;
-
-    @Override
-    public RROLabelSubobject parse(byte[] cutBytes, boolean upStream) throws PCEPDeserializerException {
-       if (cutBytes == null || cutBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-       if (cutBytes.length != LABEL_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + cutBytes.length + "; Expected: " + LABEL_LENGTH + ".");
-
-       return new RROType1LabelSubobject(UnsignedInts.toLong(ByteArray.bytesToInt(cutBytes)), upStream);
-    }
-
-    @Override
-    public byte[] put(RROLabelSubobject objToSerialize) {
-       if (!(objToSerialize instanceof RROType1LabelSubobject))
-           throw new IllegalArgumentException("Unknown RROLabelSubobject instance. Passed " + objToSerialize.getClass() + ". Needed RROType1LabelSubobject.");
-
-       return ByteArray.intToBytes((int) ((RROType1LabelSubobject) objToSerialize).getLabel());
-    }
-
-}
index 6c5708b1afcdb4004b0e6f3dd64eceedd9244f52..d67be93d870b891c7c2be69052f8b4e359b8e19a 100644 (file)
@@ -8,15 +8,24 @@
 package org.opendaylight.protocol.pcep.impl.subobject;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROUnnumberedInterfaceSubobject;
-import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.SubobjectsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.UnnumberedSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.subobject.type.UnnumberedBuilder;
+
+import com.google.common.primitives.UnsignedInts;
 
 /**
  * Parser for {@link org.opendaylight.protocol.pcep.subobject.RROUnnumberedInterfaceSubobject
  * RROUnnumberedInterfaceSubobject}
  */
-public class RROUnnumberedInterfaceSubobjectParser {
+public class RROUnnumberedInterfaceSubobjectParser implements RROSubobjectParser, RROSubobjectSerializer {
+
+       public static final int TYPE = 4;
+
        public static final int ROUTER_ID_NUMBER_LENGTH = 4;
        public static final int INTERFACE_ID_NUMBER_LENGTH = 4;
 
@@ -25,34 +34,42 @@ public class RROUnnumberedInterfaceSubobjectParser {
 
        public static final int CONTENT_LENGTH = INTERFACE_ID_NUMBER_OFFSET + INTERFACE_ID_NUMBER_LENGTH;
 
-       public static RROUnnumberedInterfaceSubobject parse(final byte[] soContentsBytes) throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
+               if (buffer.length != CONTENT_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: "
                                        + CONTENT_LENGTH + ".");
 
-               // return new RROUnnumberedInterfaceSubobject(new IPv4Address(
-               // ByteArray.subByte(soContentsBytes, ROUTER_ID_NUMBER_OFFSET, ROUTER_ID_NUMBER_LENGTH)), new
-               // UnnumberedInterfaceIdentifier(
-               // UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(soContentsBytes, INTERFACE_ID_NUMBER_OFFSET,
-               // INTERFACE_ID_NUMBER_LENGTH)))));
-               return null;
+               final SubobjectsBuilder builder = new SubobjectsBuilder();
+               final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
+               ubuilder.setRouterId(ByteArray.bytesToLong(ByteArray.subByte(buffer, ROUTER_ID_NUMBER_OFFSET, ROUTER_ID_NUMBER_LENGTH)));
+               ubuilder.setInterfaceId(UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(buffer, INTERFACE_ID_NUMBER_OFFSET,
+                               INTERFACE_ID_NUMBER_LENGTH))));
+               builder.setSubobjectType(ubuilder.build());
+               return builder.build();
        }
 
-       public static byte[] put(final ReportedRouteSubobject objToSerialize) {
-               if (!(objToSerialize instanceof RROUnnumberedInterfaceSubobject))
-                       throw new IllegalArgumentException("Unknown ReportedRouteSubobject instance. Passed " + objToSerialize.getClass()
-                                       + ". Needed RROUnnumberedInterfaceSubobject.");
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               if (!(subobject.getSubobjectType() instanceof UnnumberedSubobject))
+                       throw new IllegalArgumentException("Unknown ReportedRouteSubobject instance. Passed " + subobject.getSubobjectType().getClass()
+                                       + ". Needed UnnumberedSubobject.");
 
                byte[] retBytes;
                retBytes = new byte[CONTENT_LENGTH];
-               final RROUnnumberedInterfaceSubobject specObj = (RROUnnumberedInterfaceSubobject) objToSerialize;
+               final UnnumberedSubobject specObj = (UnnumberedSubobject) subobject.getSubobjectType();
 
-               ByteArray.copyWhole(specObj.getRouterID().getValue().getBytes(), retBytes, ROUTER_ID_NUMBER_OFFSET);
-               System.arraycopy(ByteArray.longToBytes(specObj.getInterfaceID().getInterfaceId()), Long.SIZE / Byte.SIZE
-                               - INTERFACE_ID_NUMBER_LENGTH, retBytes, INTERFACE_ID_NUMBER_OFFSET, INTERFACE_ID_NUMBER_LENGTH);
+               ByteArray.copyWhole(ByteArray.longToBytes(specObj.getRouterId()), retBytes, ROUTER_ID_NUMBER_OFFSET);
+               System.arraycopy(ByteArray.longToBytes(specObj.getInterfaceId()), Long.SIZE / Byte.SIZE - INTERFACE_ID_NUMBER_LENGTH, retBytes,
+                               INTERFACE_ID_NUMBER_OFFSET, INTERFACE_ID_NUMBER_LENGTH);
 
                return retBytes;
        }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
 }
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROWavebandSwitchingLabelSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROWavebandSwitchingLabelSubobjectParser.java
deleted file mode 100644 (file)
index b002970..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.Arrays;
-
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROWavebandSwitchingLabelSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-import com.google.common.primitives.UnsignedInts;
-
-public class RROWavebandSwitchingLabelSubobjectParser implements RROLabelParser {
-
-    public static int WAVEB_F_LENGTH = 4;
-    public static int START_F_LENGTH = 4;
-    public static int END_F_LENGTH = 4;
-
-    public static int WAVEB_F_OFFSET = 0;
-    public static int START_F_OFFSET = WAVEB_F_OFFSET + WAVEB_F_LENGTH;
-    public static int END_F_OFFSET = START_F_OFFSET + START_F_LENGTH;
-
-    public static int CONTENT_LENGTH = END_F_OFFSET + END_F_LENGTH;
-
-    @Override
-    public RROLabelSubobject parse(byte[] cutBytes, boolean upStream) throws PCEPDeserializerException {
-       if (cutBytes == null || cutBytes.length == 0)
-           throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-
-       if (cutBytes.length != CONTENT_LENGTH)
-           throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + cutBytes.length + "; Expected: " + CONTENT_LENGTH + ".");
-
-       return new RROWavebandSwitchingLabelSubobject(UnsignedInts.toLong(ByteArray.bytesToInt(Arrays.copyOfRange(cutBytes, WAVEB_F_OFFSET, START_F_OFFSET))),
-               UnsignedInts.toLong(ByteArray.bytesToInt(Arrays.copyOfRange(cutBytes, START_F_OFFSET, END_F_OFFSET))), UnsignedInts.toLong(ByteArray
-                       .bytesToInt(Arrays.copyOfRange(cutBytes, END_F_OFFSET, CONTENT_LENGTH))), upStream);
-    }
-
-    @Override
-    public byte[] put(RROLabelSubobject objToSerialize) {
-       if (!(objToSerialize instanceof RROWavebandSwitchingLabelSubobject))
-           throw new IllegalArgumentException("Unknown RROLabelSubobject instance. Passed " + objToSerialize.getClass()
-                   + ". Needed RROWavebandSwitchingLabelSubobject.");
-       final byte[] retBytes = new byte[CONTENT_LENGTH];
-
-       final RROWavebandSwitchingLabelSubobject obj = (RROWavebandSwitchingLabelSubobject) objToSerialize;
-
-       System.arraycopy(ByteArray.intToBytes((int) obj.getWavebandId()), 0, retBytes, WAVEB_F_OFFSET, WAVEB_F_LENGTH);
-       System.arraycopy(ByteArray.intToBytes((int) obj.getStartLabel()), 0, retBytes, START_F_OFFSET, START_F_LENGTH);
-       System.arraycopy(ByteArray.intToBytes((int) obj.getEndLabel()), 0, retBytes, END_F_OFFSET, END_F_LENGTH);
-
-       return retBytes;
-    }
-
-}
index d6b51e705dde5d6437a9a84fb018afe02c94496b..fff52fdb4ed7533ceb089a2051d9997fb06f79b7 100644 (file)
@@ -13,6 +13,7 @@ import org.opendaylight.protocol.pcep.spi.LabelSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CLabel;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.Type1Label;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.Type1LabelBuilder;
 
 import com.google.common.primitives.UnsignedInts;
@@ -24,7 +25,7 @@ public class Type1LabelParser implements LabelParser, LabelSerializer {
        public static final int LABEL_LENGTH = 4;
 
        @Override
-       public Type1Label parseLabel(final byte[] buffer) throws PCEPDeserializerException {
+       public LabelType parseLabel(final byte[] buffer) throws PCEPDeserializerException {
                if (buffer == null || buffer.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                if (buffer.length != LABEL_LENGTH)
index a653ca823110088ea7b168daade8ba6388255c70..8d612d2024222681470f89f1e114955f79b78e37 100644 (file)
@@ -13,6 +13,7 @@ import org.opendaylight.protocol.pcep.spi.LabelSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CLabel;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.WavebandSwitchingLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.WavebandSwitchingLabelBuilder;
 
 public class WavebandSwitchingLabelParser implements LabelParser, LabelSerializer {
@@ -26,7 +27,7 @@ public class WavebandSwitchingLabelParser implements LabelParser, LabelSerialize
        private static int CONTENT_LENGTH = WAVEB_F_LENGTH + START_F_LENGTH + END_F_LENGTH;
 
        @Override
-       public WavebandSwitchingLabel parseLabel(final byte[] buffer) throws PCEPDeserializerException {
+       public LabelType parseLabel(final byte[] buffer) throws PCEPDeserializerException {
                if (buffer == null || buffer.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
 
index 0d84bbffdc3dee24b78686a2cc53cbd07d519abe..c406f15c60011cdac1768a7472ff893d6c1986b8 100644 (file)
@@ -8,42 +8,59 @@
 package org.opendaylight.protocol.pcep.impl.subobject;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.SubobjectsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AsNumberSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.AsNumberBuilder;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject XROAsNumberSubobject}
+ * Parser for {@link AsNumberSubobject}
  */
 
-public class XROAsNumberSubobjectParser {
+public class XROAsNumberSubobjectParser implements XROSubobjectParser, XROSubobjectSerializer {
+
+       public static final int TYPE = 32;
+
        public static final int AS_NUMBER_LENGTH = 2;
 
        public static final int AS_NUMBER_OFFSET = 0;
 
        public static final int CONTENT_LENGTH = AS_NUMBER_LENGTH + AS_NUMBER_OFFSET;
 
-       public static XROAsNumberSubobject parse(final byte[] soContentsBytes, final boolean mandatory) throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer, final boolean mandatory) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
+               if (buffer.length != CONTENT_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: "
                                        + CONTENT_LENGTH + ".");
 
-               return new XROAsNumberSubobject(new AsNumber((long) (ByteArray.bytesToShort(soContentsBytes) & 0xFFFF)), mandatory);
+               return new SubobjectsBuilder().setMandatory(mandatory).setSubobjectType(
+                               new AsNumberBuilder().setAsNumber(new AsNumber(ByteArray.bytesToLong(buffer))).build()).build();
        }
 
-       public static byte[] put(final ExcludeRouteSubobject objToSerialize) {
-               if (!(objToSerialize instanceof XROAsNumberSubobject))
-                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + objToSerialize.getClass()
-                                       + ". Needed XROAsNumberSubobject.");
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               if (!(subobject.getSubobjectType() instanceof AsNumberSubobject))
+                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + subobject.getSubobjectType().getClass()
+                                       + ". Needed AsNumberSubobject.");
 
                final byte[] retBytes = new byte[CONTENT_LENGTH];
 
-               System.arraycopy(ByteArray.longToBytes(((XROAsNumberSubobject) objToSerialize).getASNumber().getValue()), Long.SIZE / Byte.SIZE
-                               - AS_NUMBER_LENGTH, retBytes, AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
+               final AsNumberSubobject obj = (AsNumberSubobject) subobject.getSubobjectType();
+
+               System.arraycopy(ByteArray.longToBytes(obj.getAsNumber().getValue()), Long.SIZE / Byte.SIZE - AS_NUMBER_LENGTH, retBytes,
+                               AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
 
                return retBytes;
        }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
 }
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIPv4PrefixSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIPv4PrefixSubobjectParser.java
deleted file mode 100644 (file)
index 6032795..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.protocol.concepts.Ipv4Util;
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROIPPrefixSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-
-import com.google.common.primitives.UnsignedBytes;
-
-/**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.XROIPPrefixSubobject XROIPPrefixSubobject<IPv4Prefix>}
- */
-public class XROIPv4PrefixSubobjectParser {
-       public static final int IP_F_LENGTH = 4;
-       public static final int PREFIX_F_LENGTH = 1;
-       public static final int ATTRIBUTE_LENGTH = 1;
-
-       public static final int IP_F_OFFSET = 0;
-       public static final int PREFIX_F_OFFSET = IP_F_OFFSET + IP_F_LENGTH;
-       public static final int ATTRIBUTE_OFFSET = PREFIX_F_OFFSET + PREFIX_F_LENGTH;
-
-       public static final int CONTENT_LENGTH = ATTRIBUTE_OFFSET + ATTRIBUTE_LENGTH;
-
-       public static XROIPPrefixSubobject parse(final byte[] soContentsBytes, final boolean mandatory) throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
-                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
-                                       + CONTENT_LENGTH + ".");
-
-               final int length = UnsignedBytes.toInt(soContentsBytes[PREFIX_F_OFFSET]);
-
-               return new XROIPPrefixSubobject(new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.subByte(soContentsBytes, IP_F_OFFSET, IP_F_LENGTH),
-                               length)), mandatory, XROSubobjectAttributeMapping.getInstance().getFromAttributeIdentifier(
-                               (short) (soContentsBytes[ATTRIBUTE_OFFSET] & 0xFF)));
-       }
-
-       public static byte[] put(final ExcludeRouteSubobject objToSerialize) {
-               if (!(objToSerialize instanceof XROIPPrefixSubobject))
-                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + objToSerialize.getClass()
-                                       + ". Needed XROIPPrefixSubobject.");
-
-               final XROIPPrefixSubobject specObj = (XROIPPrefixSubobject) objToSerialize;
-               final IpPrefix prefix = specObj.getPrefix();
-
-               if (prefix.getIpv4Prefix() == null)
-                       throw new IllegalArgumentException("Unknown AbstractPrefix instance. Passed " + prefix.getClass() + ". Needed IPv4Prefix.");
-
-               final byte[] retBytes = new byte[CONTENT_LENGTH];
-               ByteArray.copyWhole(prefix.getIpv4Prefix().getValue().getBytes(), retBytes, IP_F_OFFSET);
-               // sretBytes[PREFIX_F_OFFSET] = (byte) prefix.getIpv4Prefix().;
-               retBytes[ATTRIBUTE_OFFSET] = (byte) XROSubobjectAttributeMapping.getInstance().getFromAttributeEnum(specObj.getAttribute());
-
-               return retBytes;
-       }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIPv6PrefixSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIPv6PrefixSubobjectParser.java
deleted file mode 100644 (file)
index ad0bf22..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.subobject;
-
-import org.opendaylight.protocol.concepts.Ipv6Util;
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROIPPrefixSubobject;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-
-import com.google.common.primitives.UnsignedBytes;
-
-/**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.XROIPPrefixSubobject XROIPPrefixSubobject<IPv6Prefix>}
- */
-public class XROIPv6PrefixSubobjectParser {
-       public static final int IP_F_LENGTH = 16;
-       public static final int PREFIX_F_LENGTH = 1;
-       public static final int ATTRIBUTE_LENGTH = 1;
-
-       public static final int IP_F_OFFSET = 0;
-       public static final int PREFIX_F_OFFSET = IP_F_OFFSET + IP_F_LENGTH;
-       public static final int ATTRIBUTE_OFFSET = PREFIX_F_OFFSET + PREFIX_F_LENGTH;
-
-       public static final int CONTENT_LENGTH = ATTRIBUTE_OFFSET + ATTRIBUTE_LENGTH;
-
-       public static XROIPPrefixSubobject parse(final byte[] soContentsBytes, final boolean mandatory) throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
-                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
-                                       + CONTENT_LENGTH + ".");
-
-               final int length = UnsignedBytes.toInt(soContentsBytes[PREFIX_F_OFFSET]);
-
-               return new XROIPPrefixSubobject(new IpPrefix(Ipv6Util.prefixForBytes(ByteArray.subByte(soContentsBytes, IP_F_OFFSET, IP_F_LENGTH),
-                               length)), mandatory, XROSubobjectAttributeMapping.getInstance().getFromAttributeIdentifier(
-                               (short) (soContentsBytes[ATTRIBUTE_OFFSET] & 0xFF)));
-       }
-
-       public static byte[] put(final ExcludeRouteSubobject objToSerialize) {
-               if (!(objToSerialize instanceof XROIPPrefixSubobject))
-                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + objToSerialize.getClass()
-                                       + ". Needed XROIPPrefixSubobject.");
-
-               final XROIPPrefixSubobject specObj = (XROIPPrefixSubobject) objToSerialize;
-               final IpPrefix prefix = specObj.getPrefix();
-
-               if (prefix.getIpv4Prefix() != null)
-                       throw new IllegalArgumentException("Unknown AbstractPrefix instance. Passed " + prefix.getClass() + ". Needed IPv6Prefix.");
-
-               final byte[] retBytes = new byte[CONTENT_LENGTH];
-
-               ByteArray.copyWhole(prefix.getIpv4Prefix().getValue().getBytes(), retBytes, IP_F_OFFSET);
-               // retBytes[PREFIX_F_OFFSET] = (byte) prefix.getLength();
-               retBytes[ATTRIBUTE_OFFSET] = (byte) XROSubobjectAttributeMapping.getInstance().getFromAttributeEnum(specObj.getAttribute());
-
-               return retBytes;
-       }
-}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIpPrefixSubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIpPrefixSubobjectParser.java
new file mode 100644 (file)
index 0000000..d4983b9
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * 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.subobject;
+
+import org.opendaylight.protocol.concepts.Ipv4Util;
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.SubobjectsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.ExcludeRouteSubobjects.Attribute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.IpPrefixSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.IpPrefixBuilder;
+
+import com.google.common.primitives.UnsignedBytes;
+
+/**
+ * Parser for {@link IpPrefixSubobject}
+ */
+public class XROIpPrefixSubobjectParser implements XROSubobjectParser, XROSubobjectSerializer {
+
+       public static final int TYPE = 1;
+
+       public static final int TYPE6 = 2;
+
+       public static final int IP4_F_LENGTH = 4;
+       public static final int PREFIX_F_LENGTH = 1;
+       public static final int ATTRIBUTE_LENGTH = 1;
+
+       public static final int IP_F_OFFSET = 0;
+       public static final int PREFIX4_F_OFFSET = IP_F_OFFSET + IP4_F_LENGTH;
+       public static final int ATTRIBUTE4_OFFSET = PREFIX4_F_OFFSET + PREFIX_F_LENGTH;
+
+       public static final int CONTENT4_LENGTH = ATTRIBUTE4_OFFSET + ATTRIBUTE_LENGTH;
+
+       public static final int IP6_F_LENGTH = 16;
+       public static final int PREFIX6_F_OFFSET = IP_F_OFFSET + IP6_F_LENGTH;
+       public static final int ATTRIBUTE6_OFFSET = PREFIX6_F_OFFSET + PREFIX_F_LENGTH;
+
+       public static final int CONTENT6_LENGTH = ATTRIBUTE6_OFFSET + ATTRIBUTE_LENGTH;
+
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer, final boolean mandatory) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
+                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               if (buffer.length != CONTENT4_LENGTH && buffer.length != CONTENT6_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + ";");
+
+               final int length = UnsignedBytes.toInt(buffer[PREFIX4_F_OFFSET]);
+
+               final SubobjectsBuilder builder = new SubobjectsBuilder();
+               builder.setMandatory(mandatory);
+               builder.setAttribute(Attribute.forValue(buffer[ATTRIBUTE4_OFFSET] & 0xFF));
+               builder.setSubobjectType(new IpPrefixBuilder().setIpPrefix(
+                               new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.subByte(buffer, IP_F_OFFSET, IP4_F_LENGTH), length))).build());
+               return builder.build();
+       }
+
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               if (!(subobject.getSubobjectType() instanceof IpPrefixSubobject))
+                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + subobject.getSubobjectType().getClass()
+                                       + ". Needed IpPrefixSubobject.");
+
+               final IpPrefixSubobject specObj = (IpPrefixSubobject) subobject.getSubobjectType();
+               final IpPrefix prefix = specObj.getIpPrefix();
+
+               if (prefix.getIpv4Prefix() == null && prefix.getIpv6Prefix() == null)
+                       throw new IllegalArgumentException("Unknown AbstractPrefix instance. Passed " + prefix.getClass() + ".");
+
+               if (prefix.getIpv4Prefix() != null) {
+                       final byte[] retBytes = new byte[CONTENT4_LENGTH];
+                       ByteArray.copyWhole(prefix.getIpv4Prefix().getValue().getBytes(), retBytes, IP_F_OFFSET);
+                       retBytes[PREFIX4_F_OFFSET] = ByteArray.intToBytes(Ipv4Util.getPrefixLength(prefix))[Integer.SIZE / Byte.SIZE - 1];
+                       return retBytes;
+               } else {
+                       final byte[] retBytes = new byte[CONTENT6_LENGTH];
+                       ByteArray.copyWhole(prefix.getIpv6Prefix().getValue().getBytes(), retBytes, IP_F_OFFSET);
+                       retBytes[PREFIX6_F_OFFSET] = ByteArray.intToBytes(Ipv4Util.getPrefixLength(prefix))[Integer.SIZE / Byte.SIZE - 1];
+                       return retBytes;
+               }
+       }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
+
+       public int getType6() {
+               return TYPE6;
+       }
+}
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROPathKeySubobjectParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROPathKeySubobjectParser.java
new file mode 100644 (file)
index 0000000..809871c
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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.subobject;
+
+import java.util.Arrays;
+
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.SubobjectsBuilder;
+
+public class XROPathKeySubobjectParser implements XROSubobjectParser, XROSubobjectSerializer {
+
+       public static final int TYPE = 64;
+
+       public static final int TYPE128 = 65;
+
+       public static final int PK_F_LENGTH = 2;
+       public static final int PCE_ID_F_LENGTH = 4;
+
+       public static final int PCE128_ID_F_LENGTH = 16;
+
+       public static final int PK_F_OFFSET = 0;
+       public static final int PCE_ID_F_OFFSET = PK_F_OFFSET + PK_F_LENGTH;
+
+       public static final int CONTENT_LENGTH = PCE_ID_F_OFFSET + PCE_ID_F_LENGTH;
+
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer, final boolean mandatory) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
+                       throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+               if (buffer.length != CONTENT_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: >"
+                                       + CONTENT_LENGTH + ".");
+
+               final int pathKey = ByteArray.bytesToShort(Arrays.copyOfRange(buffer, PK_F_OFFSET, PCE_ID_F_OFFSET)) & 0xFFFF;
+
+               final byte[] pceId = Arrays.copyOfRange(buffer, PCE_ID_F_OFFSET, CONTENT_LENGTH);
+
+               final SubobjectsBuilder builder = new SubobjectsBuilder();
+               // builder.setSubobjectType(value);
+               return builder.build();
+       }
+
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               final byte[] retBytes = new byte[CONTENT_LENGTH];
+
+               // System.arraycopy(ByteArray.shortToBytes((short) objToSerialize.getPathKey()), 0, retBytes, PK_F_OFFSET,
+               // PK_F_LENGTH);
+               //
+               // if (objToSerialize.getPceId().length != PCE_ID_F_LENGTH)
+               // throw new IllegalArgumentException("Wrong length of pce id. Passed: " + objToSerialize.getPceId().length +
+               // ". Expected: ="
+               // + PCE_ID_F_LENGTH);
+               // System.arraycopy(objToSerialize.getPceId(), 0, retBytes, PCE_ID_F_OFFSET, PCE_ID_F_LENGTH);
+
+               return retBytes;
+       }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
+
+       public int getType128() {
+               return TYPE128;
+       }
+}
index 1688ce3093cf47cf747425d6dbd8a2ad4468551d..306ff013684295b0a82b694949b1ea7766252848 100644 (file)
@@ -8,13 +8,23 @@
 package org.opendaylight.protocol.pcep.impl.subobject;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROSRLGSubobject;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.SubobjectsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.ExcludeRouteSubobjects.Attribute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.SrlgId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.SrlgSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.SrlgBuilder;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject. XROSRLGSubobject XROSRLGSubobject}
+ * Parser for {@link SrlgSubobject}
  */
-public class XROSRLGSubobjectParser {
+public class XROSRLGSubobjectParser implements XROSubobjectParser, XROSubobjectSerializer {
+
+       public static final int TYPE = 34;
+
        public static final int SRLG_ID_NUMBER_LENGTH = 4;
        public static final int ATTRIBUTE_LENGTH = 1;
 
@@ -24,33 +34,40 @@ public class XROSRLGSubobjectParser {
 
        public static final int CONTENT_LENGTH = ATTRIBUTE_OFFSET + ATTRIBUTE_LENGTH;
 
-       public static XROSRLGSubobject parse(final byte[] soContentsBytes, final boolean mandatory) throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer, final boolean mandatory) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
+               if (buffer.length != CONTENT_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: "
                                        + CONTENT_LENGTH + ".");
 
-               // return new XROSRLGSubobject(new
-               // SharedRiskLinkGroup(UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(soContentsBytes,
-               // SRLG_ID_NUMBER_OFFSET,
-               // SRLG_ID_NUMBER_LENGTH)))), mandatory);
-               return null;
+               final SubobjectsBuilder builder = new SubobjectsBuilder();
+               builder.setMandatory(mandatory);
+               builder.setAttribute(Attribute.Srlg);
+               builder.setSubobjectType(new SrlgBuilder().setSrlgId(
+                               new SrlgId(ByteArray.bytesToLong(ByteArray.subByte(buffer, SRLG_ID_NUMBER_OFFSET, SRLG_ID_NUMBER_LENGTH)))).build());
+               return builder.build();
        }
 
-       public static byte[] put(final ExcludeRouteSubobject objToSerialize) {
-               if (!(objToSerialize instanceof XROSRLGSubobject))
-                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + objToSerialize.getClass()
-                                       + ". Needed XROSRLGSubobject.");
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               if (!(subobject.getSubobjectType() instanceof SrlgSubobject))
+                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + subobject.getSubobjectType().getClass()
+                                       + ". Needed SrlgSubobject.");
 
                byte[] retBytes;
                retBytes = new byte[CONTENT_LENGTH];
-               final XROSRLGSubobject specObj = (XROSRLGSubobject) objToSerialize;
+               final SrlgSubobject specObj = (SrlgSubobject) subobject.getSubobjectType();
 
-               // ByteArray.copyWhole(ByteArray.intToBytes((int) specObj.getSrlgId().getValue()), retBytes,
-               // SRLG_ID_NUMBER_OFFSET);
-               retBytes[ATTRIBUTE_OFFSET] = (byte) XROSubobjectAttributeMapping.getInstance().getFromAttributeEnum(specObj.getAttribute());
+               ByteArray.copyWhole(ByteArray.longToBytes(specObj.getSrlgId().getValue()), retBytes, SRLG_ID_NUMBER_OFFSET);
+               retBytes[ATTRIBUTE_OFFSET] = (byte) subobject.getAttribute().getIntValue();
 
                return retBytes;
        }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
 }
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROSubobjectAttributeMapping.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROSubobjectAttributeMapping.java
deleted file mode 100644 (file)
index 0e993ef..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.subobject;
-
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import org.opendaylight.protocol.pcep.subobject.XROSubobjectAttribute;
-
-/**
- * Bidirectional mapping for XROSubobjectAttribute and appropriate identifier.
- */
-public class XROSubobjectAttributeMapping {
-       private static final XROSubobjectAttributeMapping instance = new XROSubobjectAttributeMapping();
-
-       private final Map<XROSubobjectAttribute, Integer> ofCodesMap = new EnumMap<XROSubobjectAttribute, Integer>(XROSubobjectAttribute.class);
-       private final Map<Integer, XROSubobjectAttribute> ofCodeIdsMap = new HashMap<Integer, XROSubobjectAttribute>();
-
-       private XROSubobjectAttributeMapping() {
-               this.fillIn();
-       }
-
-       private void fillIn() {
-               this.fillIn(0, XROSubobjectAttribute.INTERFACE);
-               this.fillIn(1, XROSubobjectAttribute.NODE);
-               this.fillIn(2, XROSubobjectAttribute.SRLG);
-       }
-
-       private void fillIn(int identifier, XROSubobjectAttribute ofCode) {
-               this.ofCodesMap.put(ofCode, identifier);
-               this.ofCodeIdsMap.put(identifier, ofCode);
-       }
-
-       public int getFromAttributeEnum(XROSubobjectAttribute ofCode) {
-               final Integer ofci = this.ofCodesMap.get(ofCode);
-               if (ofci == null)
-                       throw new NoSuchElementException("Unknown XROSubobjectAttribute type: " + ofCode);
-               return ofci;
-       }
-
-       public XROSubobjectAttribute getFromAttributeIdentifier(int identifier) {
-               final XROSubobjectAttribute ofc = this.ofCodeIdsMap.get(identifier);
-               if (ofc == null)
-                       throw new NoSuchElementException("Unknown XROSubobjectAttribute identifier.");
-               return ofc;
-       }
-
-       public static XROSubobjectAttributeMapping getInstance() {
-               return instance;
-       }
-}
index f2f96e0471b986691b0811135779655d71153ad1..ada6e0dee599872b37f4ca46780c0a16f122a962 100644 (file)
@@ -8,15 +8,24 @@
 package org.opendaylight.protocol.pcep.impl.subobject;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROUnnumberedInterfaceSubobject;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.SubobjectsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.ExcludeRouteSubobjects.Attribute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.UnnumberedSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.UnnumberedBuilder;
+
+import com.google.common.primitives.UnsignedInts;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.XROUnnumberedInterfaceSubobject
- * XROUnnumberedInterfaceSubobject}
+ * Parser for {@link UnnumberedSubobject}
  */
-public class XROUnnumberedInterfaceSubobjectParser {
+public class XROUnnumberedInterfaceSubobjectParser implements XROSubobjectParser, XROSubobjectSerializer {
+
+       public static final int TYPE = 4;
+
        public static final int ATTRIBUTE_LENGTH = 1;
        public static final int ROUTER_ID_NUMBER_LENGTH = 4;
        public static final int INTERFACE_ID_NUMBER_LENGTH = 4;
@@ -27,38 +36,44 @@ public class XROUnnumberedInterfaceSubobjectParser {
 
        public static final int CONTENT_LENGTH = INTERFACE_ID_NUMBER_OFFSET + INTERFACE_ID_NUMBER_LENGTH;
 
-       public static XROUnnumberedInterfaceSubobject parse(final byte[] soContentsBytes, final boolean mandatory)
-                       throws PCEPDeserializerException {
-               if (soContentsBytes == null || soContentsBytes.length == 0)
+       @Override
+       public Subobjects parseSubobject(final byte[] buffer, final boolean mandatory) throws PCEPDeserializerException {
+               if (buffer == null || buffer.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
-               if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
+               if (buffer.length != CONTENT_LENGTH)
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.length + "; Expected: "
                                        + CONTENT_LENGTH + ".");
 
-               // return new XROUnnumberedInterfaceSubobject(new IPv4Address(
-               // ByteArray.subByte(soContentsBytes, ROUTER_ID_NUMBER_OFFSET, ROUTER_ID_NUMBER_LENGTH)), new
-               // UnnumberedInterfaceIdentifier(
-               // UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(soContentsBytes, INTERFACE_ID_NUMBER_OFFSET,
-               // INTERFACE_ID_NUMBER_LENGTH)))),
-               // mandatory, XROSubobjectAttributeMapping.getInstance().getFromAttributeIdentifier((short)
-               // (soContentsBytes[ATTRIBUTE_OFFSET] & 0xFF)));
-               return null;
+               final SubobjectsBuilder builder = new SubobjectsBuilder();
+               final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
+               ubuilder.setRouterId(ByteArray.bytesToLong(ByteArray.subByte(buffer, ROUTER_ID_NUMBER_OFFSET, ROUTER_ID_NUMBER_LENGTH)));
+               ubuilder.setInterfaceId(UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(buffer, INTERFACE_ID_NUMBER_OFFSET,
+                               INTERFACE_ID_NUMBER_LENGTH))));
+               builder.setSubobjectType(ubuilder.build());
+               builder.setMandatory(mandatory);
+               builder.setAttribute(Attribute.forValue(buffer[ATTRIBUTE_OFFSET] & 0xFF));
+               return builder.build();
        }
 
-       public static byte[] put(final ExcludeRouteSubobject objToSerialize) {
-               if (!(objToSerialize instanceof XROUnnumberedInterfaceSubobject))
-                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + objToSerialize.getClass()
-                                       + ". Needed XROUnnumberedInterfaceSubobject.");
+       @Override
+       public byte[] serializeSubobject(final Subobjects subobject) {
+               if (!(subobject.getSubobjectType() instanceof UnnumberedSubobject))
+                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + subobject.getSubobjectType().getClass()
+                                       + ". Needed UnnumberedSubobject.");
 
                byte[] retBytes;
                retBytes = new byte[CONTENT_LENGTH];
-               final XROUnnumberedInterfaceSubobject specObj = (XROUnnumberedInterfaceSubobject) objToSerialize;
-
-               retBytes[ATTRIBUTE_OFFSET] = (byte) XROSubobjectAttributeMapping.getInstance().getFromAttributeEnum(specObj.getAttribute());
-               ByteArray.copyWhole(specObj.getRouterID().getValue().getBytes(), retBytes, ROUTER_ID_NUMBER_OFFSET);
-               System.arraycopy(ByteArray.longToBytes(specObj.getInterfaceID().getInterfaceId()), Long.SIZE / Byte.SIZE
-                               - INTERFACE_ID_NUMBER_LENGTH, retBytes, INTERFACE_ID_NUMBER_OFFSET, INTERFACE_ID_NUMBER_LENGTH);
+               final UnnumberedSubobject specObj = (UnnumberedSubobject) subobject.getSubobjectType();
 
+               retBytes[ATTRIBUTE_OFFSET] = (byte) subobject.getAttribute().getIntValue();
+               ByteArray.copyWhole(ByteArray.longToBytes(specObj.getRouterId()), retBytes, ROUTER_ID_NUMBER_OFFSET);
+               System.arraycopy(ByteArray.longToBytes(specObj.getInterfaceId()), Long.SIZE / Byte.SIZE - INTERFACE_ID_NUMBER_LENGTH, retBytes,
+                               INTERFACE_ID_NUMBER_OFFSET, INTERFACE_ID_NUMBER_LENGTH);
                return retBytes;
        }
+
+       @Override
+       public int getType() {
+               return TYPE;
+       }
 }
index a719a7425c394a6e6c4184835045cbfb34eace8a..d4fc894e65a046c2c60206b97912aecda71a3060 100644 (file)
@@ -7,46 +7,16 @@
  */
 package org.opendaylight.protocol.pcep.impl;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 
 import org.junit.Ignore;
 import org.junit.Test;
-import org.opendaylight.protocol.concepts.Ipv4Util;
-import org.opendaylight.protocol.concepts.Ipv6Util;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.impl.subobject.EROAsNumberSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.EROIpPrefixSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.EROUnnumberedInterfaceSubobjectParser;
-import org.opendaylight.protocol.pcep.subobject.EROExplicitExclusionRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROGeneralizedLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROPathKeyWith128PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROPathKeyWith32PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROType1LabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.EROWavebandSwitchingLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROAttributesSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROGeneralizedLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROIPAddressSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROPathKeyWith128PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROPathKeyWith32PCEIDSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROType1LabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.RROWavebandSwitchingLabelSubobject;
-import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROIPPrefixSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROSubobjectAttribute;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.AsNumberBuilder;
 
 /**
  * Tests for subobjects
@@ -69,10 +39,10 @@ public class PCEPSubobjectParserTest {
                //
                // assertEquals(8, objsToTest.size());
 
-               final EROAsNumberSubobjectParser parser = new EROAsNumberSubobjectParser();
-               final CSubobject s = parser.parseSubobject(ByteArray.cutBytes(this.asnumber, 2));
-
-               assertEquals(s, new AsNumberBuilder().setAsNumber(new AsNumber((long) 0x64)).build());
+               // final EROAsNumberSubobjectParser parser = new EROAsNumberSubobjectParser();
+               // final CSubobject s = parser.parseSubobject(ByteArray.cutBytes(this.asnumber, 2));
+               //
+               // assertEquals(s, new AsNumberBuilder().setAsNumber(new AsNumber((long) 0x64)).build());
                // assertEquals(objsToTest.get(1), new AsNumberBuilder().setAsNumber(new AsNumber(0x0010L)).build());
 
                // assertEquals(objsToTest.get(2), new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new
@@ -102,46 +72,61 @@ public class PCEPSubobjectParserTest {
        @Test
        @Ignore
        public void testEROSubojectsSerDeserWithoutBin() throws PCEPDeserializerException {
-               final List<ExplicitRouteSubobject> objsToTest = new ArrayList<ExplicitRouteSubobject>();
-               objsToTest.add(new EROType1LabelSubobject(0xFFFF51F2L, true, false));
-               objsToTest.add(new EROType1LabelSubobject(0x12345648L, false, true));
-               objsToTest.add(new EROGeneralizedLabelSubobject(new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte) 0xFF }, true, true));
-               objsToTest.add(new EROWavebandSwitchingLabelSubobject(0x12345678L, 0x87654321L, 0xFFFFFFFFL, false, false));
-               objsToTest.add(new EROPathKeyWith32PCEIDSubobject(0x1235, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }, true));
-               objsToTest.add(new EROPathKeyWith128PCEIDSubobject(0x5432, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1,
-                               (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00,
-                               (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }, true));
-               objsToTest.add(new EROExplicitExclusionRouteSubobject(Arrays.asList((ExcludeRouteSubobject) new XROAsNumberSubobject(new AsNumber((long) 2588), true))));
-
-               assertEquals(objsToTest, PCEPEROSubobjectParser.parse(PCEPEROSubobjectParser.put(objsToTest)));
+               // final List<ExplicitRouteSubobject> objsToTest = new ArrayList<ExplicitRouteSubobject>();
+               // objsToTest.add(new EROType1LabelSubobject(0xFFFF51F2L, true, false));
+               // objsToTest.add(new EROType1LabelSubobject(0x12345648L, false, true));
+               // objsToTest.add(new EROGeneralizedLabelSubobject(new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte)
+               // 0xFF }, true, true));
+               // objsToTest.add(new EROWavebandSwitchingLabelSubobject(0x12345678L, 0x87654321L, 0xFFFFFFFFL, false, false));
+               // objsToTest.add(new EROPathKeyWith32PCEIDSubobject(0x1235, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF,
+               // (byte) 0xF1 }, true));
+               // objsToTest.add(new EROPathKeyWith128PCEIDSubobject(0x5432, new byte[] { (byte) 0x00, (byte) 0x55, (byte)
+               // 0xFF, (byte) 0xF1,
+               // (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1,
+               // (byte) 0x00,
+               // (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }, true));
+               // objsToTest.add(new EROExplicitExclusionRouteSubobject(Arrays.asList((ExcludeRouteSubobject) new
+               // XROAsNumberSubobject(new AsNumber((long) 2588), true))));
+
+               // assertEquals(objsToTest, PCEPEROSubobjectParser.parse(PCEPEROSubobjectParser.put(objsToTest)));
        }
 
        @Test
        public void testRROSubojectsSerDeserWithoutBin() throws PCEPDeserializerException {
-               final List<ReportedRouteSubobject> objsToTest = new ArrayList<ReportedRouteSubobject>();
-               objsToTest.add(new RROIPAddressSubobject(new IpPrefix(Ipv6Util.prefixForBytes(this.ipv6bytes2, 0x16)), true, false));
-               objsToTest.add(new RROIPAddressSubobject(new IpPrefix(Ipv4Util.prefixForBytes(this.ipv4bytes1, 0x16)), true, false));
-               objsToTest.add(new RROType1LabelSubobject(0xFFFF51F2L, true));
-               objsToTest.add(new RROType1LabelSubobject(0x12345648L, false));
-               objsToTest.add(new RROGeneralizedLabelSubobject(new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte) 0xFF }, true));
-               objsToTest.add(new RROWavebandSwitchingLabelSubobject(0x12345678L, 0x87654321L, 0xFFFFFFFFL, false));
-               objsToTest.add(new RROPathKeyWith32PCEIDSubobject(0x1235, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }));
-               objsToTest.add(new RROPathKeyWith128PCEIDSubobject(0x5432, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1,
-                               (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00,
-                               (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }));
-               objsToTest.add(new RROAttributesSubobject(new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00,
-                               (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55,
-                               (byte) 0xFF, (byte) 0xF1 }));
+               // final List<ReportedRouteSubobject> objsToTest = new ArrayList<ReportedRouteSubobject>();
+               // objsToTest.add(new RROIPAddressSubobject(new IpPrefix(Ipv6Util.prefixForBytes(this.ipv6bytes2, 0x16)), true,
+               // false));
+               // objsToTest.add(new RROIPAddressSubobject(new IpPrefix(Ipv4Util.prefixForBytes(this.ipv4bytes1, 0x16)), true,
+               // false));
+               // objsToTest.add(new RROType1LabelSubobject(0xFFFF51F2L, true));
+               // objsToTest.add(new RROType1LabelSubobject(0x12345648L, false));
+               // objsToTest.add(new RROGeneralizedLabelSubobject(new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte)
+               // 0xFF }, true));
+               // objsToTest.add(new RROWavebandSwitchingLabelSubobject(0x12345678L, 0x87654321L, 0xFFFFFFFFL, false));
+               // objsToTest.add(new RROPathKeyWith32PCEIDSubobject(0x1235, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF,
+               // (byte) 0xF1 }));
+               // objsToTest.add(new RROPathKeyWith128PCEIDSubobject(0x5432, new byte[] { (byte) 0x00, (byte) 0x55, (byte)
+               // 0xFF, (byte) 0xF1,
+               // (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1,
+               // (byte) 0x00,
+               // (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }));
+               // objsToTest.add(new RROAttributesSubobject(new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1,
+               // (byte) 0x00,
+               // (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00,
+               // (byte) 0x55,
+               // (byte) 0xFF, (byte) 0xF1 }));
 
                // assertEquals(objsToTest, PCEPRROSubobjectParser.parse(PCEPRROSubobjectParser.put(objsToTest)));
        }
 
        @Test
        public void testXROSubojectsSerDeserWithoutBin() throws PCEPDeserializerException {
-               final List<ExcludeRouteSubobject> objsToTest = new ArrayList<ExcludeRouteSubobject>();
-               objsToTest.add(new XROIPPrefixSubobject(new IpPrefix(Ipv6Util.prefixForBytes(this.ipv6bytes2, 0x16)), true, XROSubobjectAttribute.INTERFACE));
-               objsToTest.add(new XROIPPrefixSubobject(new IpPrefix(Ipv4Util.prefixForBytes(this.ipv4bytes1, 0x16)), false, XROSubobjectAttribute.INTERFACE));
-               objsToTest.add(new XROAsNumberSubobject(new AsNumber((long) 0x1234), true));
+               // final List<ExcludeRouteSubobject> objsToTest = new ArrayList<ExcludeRouteSubobject>();
+               // objsToTest.add(new XROIPPrefixSubobject(new IpPrefix(Ipv6Util.prefixForBytes(this.ipv6bytes2, 0x16)), true,
+               // XROSubobjectAttribute.INTERFACE));
+               // objsToTest.add(new XROIPPrefixSubobject(new IpPrefix(Ipv4Util.prefixForBytes(this.ipv4bytes1, 0x16)), false,
+               // XROSubobjectAttribute.INTERFACE));
+               // objsToTest.add(new XROAsNumberSubobject(new AsNumber((long) 0x1234), true));
                // objsToTest.add(new XROUnnumberedInterfaceSubobject(new IPv4Address(this.ipv4bytes1), new
                // UnnumberedInterfaceIdentifier(0xFFFFFFFFL), true, XROSubobjectAttribute.SRLG));
                // objsToTest.add(new XROSRLGSubobject(new SharedRiskLinkGroup(0x12345678L), false));
@@ -180,19 +165,19 @@ public class PCEPSubobjectParserTest {
                // subobjects
 
                try {
-                       new EROAsNumberSubobjectParser().parseSubobject(bytes);
+                       new EROAsNumberSubobjectParser().parseSubobject(bytes, false);
                        fail("");
                } catch (final IllegalArgumentException e) {
                }
 
                try {
-                       EROUnnumberedInterfaceSubobjectParser.parse(bytes, true);
+                       new EROUnnumberedInterfaceSubobjectParser().parseSubobject(bytes, false);
                        fail("");
                } catch (final IllegalArgumentException e) {
                }
 
                try {
-                       new EROIpPrefixSubobjectParser().parseSubobject(bytes);
+                       new EROIpPrefixSubobjectParser().parseSubobject(bytes, false);
                        fail("");
                } catch (final IllegalArgumentException e) {
                }
@@ -201,20 +186,20 @@ public class PCEPSubobjectParserTest {
        @Test
        public void testUnknownInstanceExceptions() {
 
-               final ExplicitRouteSubobject instance = new ExplicitRouteSubobject() {
-               };
+               // final ExplicitRouteSubobject instance = new ExplicitRouteSubobject() {
+               // };
 
                // try {
                // new EROAsNumberSubobjectParser().serializeSubobject(instance);
                // fail("");
                // } catch (final IllegalArgumentException e) {
                // }
-
-               try {
-                       EROUnnumberedInterfaceSubobjectParser.put(instance);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
+               //
+               // try {
+               // EROUnnumberedInterfaceSubobjectParser.put(instance);
+               // fail("");
+               // } catch (final IllegalArgumentException e) {
+               // }
 
                // try {
                // EROIpPrefixSubobjectParser.put(instance);
index 74f645ae6126731b422d3788c0bf5fac1de4e6d0..7c8350c469aaf5d4ee752ac58f9ef02166682541 100644 (file)
@@ -7,49 +7,40 @@
  */
 package org.opendaylight.protocol.pcep.impl;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
-import java.util.List;
 
 import org.junit.Test;
-import org.opendaylight.protocol.concepts.Ipv4Util;
-import org.opendaylight.protocol.concepts.Ipv6Util;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.impl.subobject.XROAsNumberSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.XROIPv4PrefixSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.XROIPv6PrefixSubobjectParser;
+import org.opendaylight.protocol.pcep.impl.subobject.XROIpPrefixSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.XROUnnumberedInterfaceSubobjectParser;
-import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROIPPrefixSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROSubobjectAttribute;
 import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
 
 public class PCEPXROSubobjectParserTest {
 
        @Test
        public void testSerDeser() throws PCEPDeserializerException, IOException {
                final byte[] bytesFromFile = ByteArray.fileToBytes("src/test/resources/PackOfXROSubobjects.bin");
-               final List<ExcludeRouteSubobject> objsToTest = PCEPXROSubobjectParser.parse(bytesFromFile);
-
-               assertEquals(5, objsToTest.size());
-
-               assertEquals(
-                               objsToTest.get(0),
-                               new XROIPPrefixSubobject(new IpPrefix(Ipv4Util.prefixForBytes(new byte[] { (byte) 192, (byte) 168, (byte) 0, (byte) 0 }, 16)), true, XROSubobjectAttribute.NODE));
-               assertEquals(
-                               objsToTest.get(1),
-                               new XROIPPrefixSubobject(new IpPrefix(Ipv6Util.prefixForBytes(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56,
-                                               (byte) 0x78, (byte) 0x90, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x90, (byte) 0x12,
-                                               (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0, (byte) 0 }, 112)), true, XROSubobjectAttribute.INTERFACE));
+               // final List<ExcludeRouteSubobject> objsToTest = PCEPXROSubobjectParser.parse(bytesFromFile);
+
+               // assertEquals(5, objsToTest.size());
+               //
+               // assertEquals(
+               // objsToTest.get(0),
+               // new XROIPPrefixSubobject(new IpPrefix(Ipv4Util.prefixForBytes(new byte[] { (byte) 192, (byte) 168, (byte) 0,
+               // (byte) 0 }, 16)), true, XROSubobjectAttribute.NODE));
+               // assertEquals(
+               // objsToTest.get(1),
+               // new XROIPPrefixSubobject(new IpPrefix(Ipv6Util.prefixForBytes(new byte[] { (byte) 0x12, (byte) 0x34, (byte)
+               // 0x56,
+               // (byte) 0x78, (byte) 0x90, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x90, (byte) 0x12,
+               // (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0, (byte) 0 }, 112)), true, XROSubobjectAttribute.INTERFACE));
                // assertEquals(objsToTest.get(2), new XROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] { (byte) 0,
                // (byte) 0, (byte) 0,
                // (byte) 0x20 }), new UnnumberedInterfaceIdentifier(0x1234L), false, XROSubobjectAttribute.SRLG));
-               assertEquals(objsToTest.get(3), new XROAsNumberSubobject(new AsNumber((long) 0x1234), false));
+               // assertEquals(objsToTest.get(3), new XROAsNumberSubobject(new AsNumber((long) 0x1234), false));
                // assertEquals(objsToTest.get(4), new XROSRLGSubobject(new SharedRiskLinkGroup(0x12345678L), false));
 
                // assertArrayEquals(bytesFromFile, PCEPXROSubobjectParser.put(objsToTest));
@@ -61,133 +52,21 @@ public class PCEPXROSubobjectParserTest {
                final byte[] bytes = { (byte) 0x00 }; // not empty but not enought data for parsing subobjects
 
                try {
-                       XROAsNumberSubobjectParser.parse(bytes, true);
-                       fail("");
-               } catch (final PCEPDeserializerException e) {
-               }
-
-               try {
-                       XROUnnumberedInterfaceSubobjectParser.parse(bytes, true);
+                       new XROAsNumberSubobjectParser().parseSubobject(bytes, true);
                        fail("");
                } catch (final PCEPDeserializerException e) {
                }
 
                try {
-                       XROIPv4PrefixSubobjectParser.parse(bytes, true);
+                       new XROUnnumberedInterfaceSubobjectParser().parseSubobject(bytes, true);
                        fail("");
                } catch (final PCEPDeserializerException e) {
                }
 
                try {
-                       XROIPv6PrefixSubobjectParser.parse(bytes, true);
+                       new XROIpPrefixSubobjectParser().parseSubobject(bytes, true);
                        fail("");
                } catch (final PCEPDeserializerException e) {
                }
        }
-
-       @Test
-       public void testNullExceptions() throws PCEPDeserializerException {
-               final byte[] bytes = null; // not empty but not enought data for parsing subobjects
-
-               try {
-                       XROAsNumberSubobjectParser.parse(bytes, true);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       XROUnnumberedInterfaceSubobjectParser.parse(bytes, true);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       XROIPv4PrefixSubobjectParser.parse(bytes, true);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       XROIPv6PrefixSubobjectParser.parse(bytes, true);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-       }
-
-       @Test
-       public void testUnknownInstanceExceptions() {
-
-               final ExcludeRouteSubobject instance = new ExcludeRouteSubobject(true) {
-               };
-
-               try {
-                       XROAsNumberSubobjectParser.put(instance);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       XROUnnumberedInterfaceSubobjectParser.put(instance);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       XROIPv4PrefixSubobjectParser.put(instance);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       final byte[] ipv6addr = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
-                                       (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
-                       XROIPv4PrefixSubobjectParser.put(new XROIPPrefixSubobject(new IpPrefix(Ipv6Util.prefixForBytes(ipv6addr, 1)), false, XROSubobjectAttribute.INTERFACE));
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       XROIPv6PrefixSubobjectParser.put(instance);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       final byte[] ipv4addr = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
-                       XROIPv6PrefixSubobjectParser.put(new XROIPPrefixSubobject(new IpPrefix(Ipv4Util.prefixForBytes(ipv4addr, 1)), false, XROSubobjectAttribute.INTERFACE));
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-       }
-
-       @Test
-       public void testEmptyExceptions() throws PCEPDeserializerException {
-               final byte[] bytes = {}; // not empty but not enought data for parsing subobjects
-
-               try {
-                       XROAsNumberSubobjectParser.parse(bytes, true);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       XROUnnumberedInterfaceSubobjectParser.parse(bytes, true);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       XROIPv4PrefixSubobjectParser.parse(bytes, true);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-
-               try {
-                       XROIPv6PrefixSubobjectParser.parse(bytes, true);
-                       fail("");
-               } catch (final IllegalArgumentException e) {
-               }
-       }
-
 }
similarity index 58%
rename from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/SubobjectHandlerRegistry.java
rename to pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/EROSubobjectHandlerRegistry.java
index ba50021766b1a3b49f4f6ec2b332ef634469607e..f50b8baced77dd99d9209100afe3bfb23f720334 100644 (file)
@@ -7,12 +7,15 @@
  */
 package org.opendaylight.protocol.pcep.spi;
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
 
-public interface SubobjectHandlerRegistry {
-       public AutoCloseable registerSubobjectParser(int subobjectType, SubobjectParser parser);
-       public SubobjectParser getSubobjectParser(int subobjectType);
+public interface EROSubobjectHandlerRegistry {
+       public AutoCloseable registerSubobjectParser(int subobjectType, EROSubobjectParser parser);
 
-       public AutoCloseable registerSubobjectSerializer(Class<? extends CSubobject> subobjectClass, SubobjectSerializer serializer);
-       public SubobjectSerializer getSubobjectSerializer(CSubobject subobject);
+       public EROSubobjectParser getSubobjectParser(int subobjectType);
+
+       public AutoCloseable registerSubobjectSerializer(Class<? extends CSubobject> subobjectClass, EROSubobjectSerializer serializer);
+
+       public EROSubobjectSerializer getSubobjectSerializer(Subobjects subobject);
 }
similarity index 54%
rename from pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/RROLabelParser.java
rename to pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/EROSubobjectParser.java
index a283ec916cda9e275aea85f019b6953bbc263943..a37b296e6199e6bd166469495ff06e637d4ab9f5 100644 (file)
@@ -5,14 +5,11 @@
  * 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.subobject;
+package org.opendaylight.protocol.pcep.spi;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.RROLabelSubobject;
-
-public interface RROLabelParser {
-    RROLabelSubobject parse(byte[] cutBytes, boolean upStream) throws PCEPDeserializerException;
-
-    byte[] put(RROLabelSubobject objToSerialize);
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Subobjects;
 
+public interface EROSubobjectParser {
+       public Subobjects parseSubobject(final byte[] buffer, final boolean loose) throws PCEPDeserializerException;
 }
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/EROSubobjectSerializer.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/EROSubobjectSerializer.java
new file mode 100644 (file)
index 0000000..f53d4d4
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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.pcep.types.rev131005.explicit.route.object.Subobjects;
+
+public interface EROSubobjectSerializer {
+
+       @Deprecated
+       public int getType();
+
+       public byte[] serializeSubobject(Subobjects subobject);
+}
index 8ecd17107283e07225788ddd77c99d9001fa8aef..1c8ce5a2810615aa53d2f6eb7ebdf31efb956e67 100644 (file)
@@ -8,8 +8,8 @@
 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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
 
 public interface LabelParser {
-       public CLabel parseLabel(final byte[] buffer) throws PCEPDeserializerException;
+       public LabelType parseLabel(final byte[] buffer) throws PCEPDeserializerException;
 }
index a15204760f9cd240a18df3a40a46741e60a0f5e8..45b8f44d9cff71ecf36b3bbc1600fb94e877a674 100644 (file)
@@ -7,15 +7,19 @@
  */
 package org.opendaylight.protocol.pcep.spi;
 
-/**
- *
- */
 public interface PCEPProviderContext {
-       public LabelHandlerRegistry getHandlerRegistry();
+
+       public LabelHandlerRegistry getLabelHandlerRegistry();
+       
        public MessageHandlerRegistry getMessageHandlerRegistry();
+
        public ObjectHandlerRegistry getObjectHandlerRegistry();
-       public SubobjectHandlerRegistry getEROSubobjectHandlerRegistry();
-       public SubobjectHandlerRegistry getRROSubobjectHandlerRegistry();
-       public SubobjectHandlerRegistry getXROSubobjectHandlerRegistry();
+
+       public EROSubobjectHandlerRegistry getEROSubobjectHandlerRegistry();
+
+       public RROSubobjectHandlerRegistry getRROSubobjectHandlerRegistry();
+
+       public XROSubobjectHandlerRegistry getXROSubobjectHandlerRegistry();
+
        public TlvHandlerRegistry getTlvHandlerRegistry();
 }
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectHandlerRegistry.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectHandlerRegistry.java
new file mode 100644 (file)
index 0000000..34194f1
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * 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.pcep.types.rev131005.reported.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+
+public interface RROSubobjectHandlerRegistry {
+       public AutoCloseable registerSubobjectParser(int subobjectType, RROSubobjectParser parser);
+
+       public RROSubobjectParser getSubobjectParser(int subobjectType);
+
+       public AutoCloseable registerSubobjectSerializer(Class<? extends CSubobject> subobjectClass, RROSubobjectSerializer serializer);
+
+       public RROSubobjectSerializer getSubobjectSerializer(Subobjects subobject);
+}
similarity index 75%
rename from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/SubobjectParser.java
rename to pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectParser.java
index ba9044f94a5e185d3a88cb8f1168524f5352f46d..96b3548c44fe6f11cc0ec88c19f7c5aef9a98f3a 100644 (file)
@@ -8,8 +8,8 @@
 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.CSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Subobjects;
 
-public interface SubobjectParser {
-       public CSubobject parseSubobject(final byte[] buffer) throws PCEPDeserializerException;
+public interface RROSubobjectParser {
+       public Subobjects parseSubobject(final byte[] buffer) throws PCEPDeserializerException;
 }
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectSerializer.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RROSubobjectSerializer.java
new file mode 100644 (file)
index 0000000..8dd9b77
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * 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.pcep.types.rev131005.reported.route.object.Subobjects;
+
+public interface RROSubobjectSerializer {
+
+       @Deprecated
+       public int getType();
+
+       public byte[] serializeSubobject(Subobjects subobject);
+}
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RawMessage.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RawMessage.java
deleted file mode 100644 (file)
index 51c8df5..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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 java.util.List;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-
-/**
- * Class representing raw message.
- */
-public class RawMessage implements Message {
-       private final PCEPMessageType msgType;
-       private final List<Object> objects;
-
-       public RawMessage(final List<Object> objects, final PCEPMessageType msgType) {
-               this.msgType = msgType;
-               if (objects.contains(null)) {
-                       throw new IllegalArgumentException("Object list contains null element at offset " + objects.indexOf(null));
-               }
-               this.objects = objects;
-       }
-
-       public PCEPMessageType getMsgType() {
-               return this.msgType;
-       }
-
-       public List<Object> getAllObjects() {
-               return this.objects;
-       }
-
-       @Override
-       public Class<Message> getImplementedInterface() {
-               return Message.class;
-       }
-}
diff --git a/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/XROSubobjectHandlerRegistry.java b/pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/XROSubobjectHandlerRegistry.java
new file mode 100644 (file)
index 0000000..cca8615
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * 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.pcep.types.rev131005.exclude.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+
+public interface XROSubobjectHandlerRegistry {
+
+       public AutoCloseable registerSubobjectParser(int subobjectType, XROSubobjectParser parser);
+
+       public XROSubobjectParser getSubobjectParser(int subobjectType);
+
+       public AutoCloseable registerSubobjectSerializer(Class<? extends CSubobject> subobjectClass, XROSubobjectSerializer serializer);
+
+       public XROSubobjectSerializer getSubobjectSerializer(Subobjects subobject);
+}
similarity index 53%
rename from pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROLabelParser.java
rename to pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/XROSubobjectParser.java
index b70d7de9b59b8414cbd0345321a867c816047147..bca2e90941f6c71081b64a7fb7519023a0f7fe1f 100644 (file)
@@ -5,15 +5,11 @@
  * 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.subobject;
+package org.opendaylight.protocol.pcep.spi;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.subobject.EROLabelSubobject;
-
-public interface EROLabelParser {
-
-    EROLabelSubobject parse(byte[] cutBytes, boolean upStream, boolean loose) throws PCEPDeserializerException;
-
-    byte[] put(EROLabelSubobject objToSerialize);
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
 
+public interface XROSubobjectParser {
+       public Subobjects parseSubobject(final byte[] buffer, final boolean mandatory) throws PCEPDeserializerException;
 }
similarity index 73%
rename from pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/SubobjectSerializer.java
rename to pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/XROSubobjectSerializer.java
index ed3dee0c38f294d182f064724302f7cef6f0c87a..f3b1efd5c475739947ed5f44327e41946bb78e9c 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.protocol.pcep.spi;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
+
+public interface XROSubobjectSerializer {
 
-public interface SubobjectSerializer {
-       
        @Deprecated
        public int getType();
 
-       public byte[] serializeSubobject(CSubobject subobject);
+       public byte[] serializeSubobject(Subobjects subobject);
 }
diff --git a/rsvp/.project b/rsvp/.project
new file mode 100644 (file)
index 0000000..e845c88
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>rsvp-parent</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
+       </natures>
+</projectDescription>
diff --git a/rsvp/api/.project b/rsvp/api/.project
new file mode 100644 (file)
index 0000000..eb51072
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>rsvp-api</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
+       </natures>
+</projectDescription>