Add ByteBufUtils 00/85100/15
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 14 Oct 2019 08:56:20 +0000 (10:56 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 15 Oct 2019 05:39:32 +0000 (07:39 +0200)
This adds ByteBufUtils, which are an evolution of ByteBufWriteUtils,
covering reads of Uint types as well as writing using various approaches
to nullness.

We also migrate all uint reading tasks to these utility methods, fixing
deprecation warnings in the process.

Change-Id: I8466dbff77f8469278df4eb92a2aaebcbdeeb6b8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
180 files changed:
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/ASGenParser.java
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LacpParser.java
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/LanParser.java
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/MacParser.java
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/esi/types/RouterIdParser.java
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/Layer2AttributesExtCom.java
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/extended/communities/MACMobExtCom.java
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/EthADRParser.java
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/IncMultEthTagRParser.java
bgp/extensions/evpn/src/main/java/org/opendaylight/protocol/bgp/evpn/impl/nlri/MACIpAdvRParser.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FSDscpHandler.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FSIcmpCodeHandler.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FSIcmpTypeHandler.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FSIpProtocolHandler.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/FSIpv6NextHeaderHandler.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/extended/communities/RedirectAsFourOctetEcHandler.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/extended/communities/RedirectAsTwoOctetEcHandler.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/extended/communities/RedirectIpv4EcHandler.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/extended/communities/RedirectIpv6EcHandler.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/extended/communities/TrafficMarkingEcHandler.java
bgp/extensions/flowspec/src/main/java/org/opendaylight/protocol/bgp/flowspec/extended/communities/TrafficRateEcHandler.java
bgp/extensions/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/LabelIndexTlvParser.java
bgp/extensions/labeled-unicast/src/main/java/org/opendaylight/protocol/bgp/labeled/unicast/OriginatorSrgbTlvParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/LinkAttributesParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/NodeAttributesParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/PrefixAttributesParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/sr/BindingSidLabelParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/sr/RangeTlvParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/sr/SidLabelIndexParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/sr/SrLinkAttributesParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/sr/SrNodeAttributesParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/sr/binding/sid/sub/tlvs/EroMetricParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/sr/binding/sid/sub/tlvs/UnnumberedEroParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/nlri/TeLspIpv4NlriParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/nlri/TeLspIpv6NlriParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/tlvs/AreaIdTlvParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/tlvs/AsNumTlvParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/tlvs/DomainIdTlvParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/tlvs/MemAsNumTlvParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/tlvs/MultiTopoIdTlvParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/tlvs/RouterIdTlvParser.java
bgp/extensions/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/spi/AbstractNlriTypeCodec.java
bgp/extensions/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/OpaqueUtil.java
bgp/extensions/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/attributes/tunnel/identifier/RsvpTeP2MpLspParser.java
bgp/extensions/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/CMulticastUtil.java
bgp/extensions/mvpn/src/main/java/org/opendaylight/protocol/bgp/mvpn/impl/nlri/InterASIPmsiADHandler.java
bgp/extensions/route-target/src/main/java/org/opendaylight/protocol/bgp/route/targetcontrain/impl/nlri/RouteTargetConstrainNlriHandler.java
bgp/openconfig-rp-spi/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/spi/RouteEntryBaseAttributes.java
bgp/openconfig-rp-statement/pom.xml
bgp/openconfig-rp-statement/src/main/java/org/opendaylight/protocol/bgp/openconfig/routing/policy/statement/actions/AsPathPrepend.java
bgp/openconfig-state/src/main/java/org/opendaylight/protocol/bgp/state/NeighborUtil.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/AsNumberUtil.java
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPError.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/BGPOpenMessageParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/open/As4CapabilityHandler.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/open/LlGracefulCapabilityHandler.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AggregatorAttributeParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AigpAttributeParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/AsPathSegmentParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/CommunityUtil.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/LocalPreferenceAttributeParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/MultiExitDiscriminatorAttributeParser.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/RouteOriginIpv4EcHandler.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/four/octect/as/specific/SourceAS4OctectHandler.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/message/update/extended/communities/route/target/RouteTargetIpv4Handler.java
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/PathIdUtil.java
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/extended/community/FourOctAsCommonECUtil.java
bgp/parser-spi/src/main/java/org/opendaylight/protocol/bgp/parser/spi/pojo/SimpleAttributeRegistry.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/GracefulRestartUtil.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiatorTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerUtil.java
bgp/rib-mock/pom.xml
bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/EventBusRegistration.java
bgp/testtool/pom.xml
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/Arguments.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/CommunitiesBuilder.java
bgp/testtool/src/main/java/org/opendaylight/protocol/bgp/testtool/PrefixesBuilder.java
bgp/topology-provider/src/main/java/org/opendaylight/bgpcep/bgp/topology/provider/ProtocolUtil.java
bmp/bmp-impl/src/main/java/org/opendaylight/protocol/bmp/impl/app/BmpRibInWriter.java
bmp/bmp-mock/src/main/java/org/opendaylight/protocol/bmp/mock/BmpMockUtil.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/message/PeerDownHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/message/PeerUpHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/tlv/StatType000TlvHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/tlv/StatType001TlvHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/tlv/StatType002TlvHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/tlv/StatType003TlvHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/tlv/StatType004TlvHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/tlv/StatType005TlvHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/tlv/StatType006TlvHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/tlv/StatType011TlvHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/tlv/StatType012TlvHandler.java
bmp/bmp-parser-impl/src/main/java/org/opendaylight/protocol/bmp/parser/tlv/StatType013TlvHandler.java
bmp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/AbstractBmpPerPeerMessageParser.java
data-change-counter/src/main/java/org/opendaylight/protocol/data/change/counter/TopologyDataChangeCounter.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPClassTypeObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPCloseObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPErrorObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPGlobalConstraintsObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPLoadBalancingObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPLspaObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPMetricObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPMonitoringObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPNoPathObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPNotificationObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPObjectiveFunctionObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPOpenObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPOverloadObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPProcTimeObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPRequestParameterObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/object/PCEPSvecObjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/AsNumberCaseParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/EROUnnumberedInterfaceSubobjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/RROPathKey128SubobjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/RROPathKey32SubobjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/RROUnnumberedInterfaceSubobjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/Type1LabelParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/WavebandSwitchingLabelParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/XROIpv4PrefixSubobjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/XROPathKey128SubobjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/XROPathKey32SubobjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/XROSRLGSubobjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/subobject/XROUnnumberedInterfaceSubobjectParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/tlv/OFListTlvParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/tlv/OrderTlvParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/tlv/OverloadedDurationTlvParser.java
pcep/base-parser/src/main/java/org/opendaylight/protocol/pcep/parser/tlv/ReqMissingTlvParser.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/PathBindingTlvParser.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/Stateful07LSPIdentifierIpv4TlvParser.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/Stateful07LSPIdentifierIpv6TlvParser.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/Stateful07LspObjectParser.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/Stateful07LspUpdateErrorTlvParser.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/Stateful07RSVPErrorSpecTlvParser.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/Stateful07SrpObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/BasePCEPSessionProposalFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPDispatcherImpl.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/LabelSubobjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPEROSubobjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPObjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPRROSubobjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPXROSubobjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/TestVendorInformationObjectParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/TestVendorInformationTlvParser.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/PCCTunnelBuilder.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/PCCTunnelManagerImpl.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/spi/MsgBuilderUtil.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/AbstractSrSubobjectParser.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/PCEPSegmentRoutingCapability.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/SrPceCapabilityTlvParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractEROPathKeySubobjectParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractMessageParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPErrorIdentifier.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPErrors.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractTopologySessionListener.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/Stateful07TopologySessionListener.java
programming/api/src/main/java/org/opendaylight/bgpcep/programming/NanotimeUtil.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/AsNumberCaseParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/label/Type1LabelParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/label/WavebandSwitchingLabelParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/rro/RROPathKey128SubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/rro/RROPathKey32SubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/rro/RROUnnumberedInterfaceSubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/subobject/xro/XROSrlgSubobjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/AbstractAssociationParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/FastRerouteObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/FlowSpecObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/InformationalFastRerouteObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/MetricObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/SenderTspecObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/SessionAttributeLspObjectParser.java
rsvp/impl/src/main/java/org/opendaylight/protocol/rsvp/parser/impl/te/SessionAttributeLspRaObjectParser.java
rsvp/impl/src/test/java/org/opendaylight/protocol/rsvp/parser/impl/EROSubobjectParserTest.java
rsvp/impl/src/test/java/org/opendaylight/protocol/rsvp/parser/impl/LabelSubobjectParserTest.java
rsvp/impl/src/test/java/org/opendaylight/protocol/rsvp/parser/impl/RROSubobjectParserTest.java
rsvp/impl/src/test/java/org/opendaylight/protocol/rsvp/parser/impl/XROSubobjectParserTest.java
rsvp/spi/src/main/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/CommonPathKeyParser.java
rsvp/spi/src/main/java/org/opendaylight/protocol/rsvp/parser/spi/subobjects/CommonUnnumberedInterfaceSubobjectParser.java
util/src/main/java/org/opendaylight/protocol/util/ByteBufUtils.java [new file with mode: 0644]
util/src/test/java/org/opendaylight/protocol/util/ByteBufUtilsTest.java [new file with mode: 0644]

index bf63114936bab8674f5a31f81c92d51177518c2e..da03b1a9b4aef5d25fde6f89f2313606bdb3e24a 100644 (file)
@@ -13,6 +13,7 @@ import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.ext
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EsiType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.Esi;
@@ -52,8 +53,8 @@ final class ASGenParser extends AbstractEsiType {
     public Esi parseEsi(final ByteBuf buffer) {
         return new AsGeneratedCaseBuilder()
                 .setAsGenerated(new AsGeneratedBuilder()
-                    .setAs(new AsNumber(buffer.readUnsignedInt()))
-                    .setLocalDiscriminator(buffer.readUnsignedInt())
+                    .setAs(new AsNumber(ByteBufUtils.readUint32(buffer)))
+                    .setLocalDiscriminator(ByteBufUtils.readUint32(buffer))
                     .build())
                 .build();
     }
index 4ee4b0477118e093ecfd843a76e9b8afbee28362..a2bdc2e5a75049a3ed0da6e8b5b1e69a7cf613ee 100644 (file)
@@ -13,6 +13,7 @@ import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.ext
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EsiType;
@@ -56,7 +57,7 @@ final class LacpParser extends AbstractEsiType {
                 .setLacpAutoGenerated(new LacpAutoGeneratedBuilder()
                     .setCeLacpMacAddress(IetfYangUtil.INSTANCE.macAddressFor(
                         ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH)))
-                    .setCeLacpPortKey(buffer.readUnsignedShort())
+                    .setCeLacpPortKey(ByteBufUtils.readUint16(buffer))
                     .build())
                 .build();
     }
index 6f1d3b41d1bed47171ce6462574e300b6a118d44..0065a97ccdfd44bc9eae4d29e9d51c0cd64dd131 100644 (file)
@@ -13,6 +13,7 @@ import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.ext
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EsiType;
@@ -56,7 +57,7 @@ final class LanParser extends AbstractEsiType {
                 .setLanAutoGenerated(new LanAutoGeneratedBuilder()
                     .setRootBridgeMacAddress(IetfYangUtil.INSTANCE.macAddressFor(
                         ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH)))
-                    .setRootBridgePriority(buffer.readUnsignedShort())
+                    .setRootBridgePriority(ByteBufUtils.readUint16(buffer))
                     .build())
                 .build();
     }
index e6135bd668bb4bcdfd2816e4b91562e3f3ad5b80..7aa9adcd8e1c40ef46bf761e8e9f0560bc70340b 100644 (file)
@@ -14,6 +14,7 @@ import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.ext
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EsiType;
@@ -58,7 +59,7 @@ final class MacParser extends AbstractEsiType {
                 .setMacAutoGenerated(new MacAutoGeneratedBuilder()
                     .setSystemMacAddress(IetfYangUtil.INSTANCE.macAddressFor(
                         ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH)))
-                    .setLocalDiscriminator(new Uint24(Long.valueOf(buffer.readUnsignedMedium())))
+                    .setLocalDiscriminator(new Uint24(ByteBufUtils.readUint24(buffer)))
                     .build())
                 .build();
     }
index 81d021b6b9be65dfcfa2f90fa6c5b13ce376541d..6ec1aa5037c3a68d3506ed54a85d4fb14ec01b66 100644 (file)
@@ -12,6 +12,7 @@ import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.ext
 import static org.opendaylight.protocol.bgp.evpn.impl.esi.types.EsiModelUtil.extractRD;
 
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.EsiType;
@@ -54,7 +55,7 @@ final class RouterIdParser extends AbstractEsiType {
         return new RouterIdGeneratedCaseBuilder()
                 .setRouterIdGenerated(new RouterIdGeneratedBuilder()
                     .setRouterId(Ipv4Util.addressForByteBuf(buffer))
-                    .setLocalDiscriminator(buffer.readUnsignedInt())
+                    .setLocalDiscriminator(ByteBufUtils.readUint32(buffer))
                     .build())
                 .build();
     }
index d4e85aacf2323dfbb0e03c20322e92823fa52a89..b70751f02a249bbc0c8989a90494dd093c69a498 100644 (file)
@@ -5,13 +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.bgp.evpn.impl.extended.communities;
 
 import com.google.common.base.Preconditions;
 import com.google.common.primitives.UnsignedBytes;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.NormalizationType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.OperationalMode;
@@ -52,7 +52,7 @@ public class Layer2AttributesExtCom extends AbstractExtendedCommunities {
         builder.setModeOfOperation(OperationalMode.forValue(getFlagShort(flags, MODE_OF_OPERATION)));
         builder.setOperatingPer(NormalizationType.forValue(getFlagShort(flags, NORMALIZATION_TYPE)));
 
-        builder.setL2Mtu(body.readUnsignedShort());
+        builder.setL2Mtu(ByteBufUtils.readUint16(body));
         body.skipBytes(RESERVED);
         return new Layer2AttributesExtendedCommunityCaseBuilder()
                 .setLayer2AttributesExtendedCommunity(builder.build()).build();
index f0672de0153bd448a7bcbcbf9fac11d8437feb70..91683c1981600f4ff471ac262228c7e70a2ed243 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.MacMobilityExtendedCommunityCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.MacMobilityExtendedCommunityCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.mac.mobility.extended.community.MacMobilityExtendedCommunity;
@@ -26,10 +27,12 @@ public final class MACMobExtCom extends AbstractExtendedCommunities {
             throws BGPDocumentedException, BGPParsingException {
         final boolean isStatic = buffer.readBoolean();
         buffer.skipBytes(RESERVED);
-        final long seqNumber = buffer.readUnsignedInt();
         return new MacMobilityExtendedCommunityCaseBuilder()
                 .setMacMobilityExtendedCommunity(new MacMobilityExtendedCommunityBuilder()
-            .setStatic(isStatic).setSeqNumber(seqNumber).build()).build();
+                    .setStatic(isStatic)
+                    .setSeqNumber(ByteBufUtils.readUint32(buffer))
+                    .build())
+                .build();
     }
 
     @Override
index 826f62265d4a92d871dc2f25b1d9de4041ca1020..513c3ba2c5ac34b22675f5148b4ad8f32c381e73 100644 (file)
@@ -17,6 +17,7 @@ import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.bgp.evpn.spi.pojo.SimpleEsiTypeRegistry;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.NlriType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.esi.Esi;
@@ -40,7 +41,7 @@ final class EthADRParser extends AbstractEvpnNlri {
         Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH,
                 "Wrong length of array of bytes. Passed: %s ;", buffer);
         final Esi esi = SimpleEsiTypeRegistry.getInstance().parseEsi(buffer.readSlice(ESI_SIZE));
-        final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(buffer.readUnsignedInt()).build();
+        final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(ByteBufUtils.readUint32(buffer)).build();
         final MplsLabel label = mplsLabelForByteBuf(buffer);
         final EthernetADRouteBuilder builder = new EthernetADRouteBuilder()
                 .setEsi(esi).setEthernetTagId(eti).setMplsLabel(label);
index f6ca9d2bc4fddd97dfc95baaefac18d055065c12..ae151dfced8d6c62b850d0dd1adb55cefa2494cf 100644 (file)
@@ -15,6 +15,7 @@ import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.bgp.concepts.IpAddressUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev180329.NlriType;
@@ -46,7 +47,7 @@ final class IncMultEthTagRParser extends AbstractEvpnNlri {
                         || buffer.readableBytes() == CONTENT_LENGTH2,
                 "Wrong length of array of bytes. Passed: %s ;", buffer);
 
-        final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(buffer.readUnsignedInt()).build();
+        final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(ByteBufUtils.readUint32(buffer)).build();
         IpAddress ip = IpAddressUtil.addressForByteBuf(buffer);
         final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder()
                 .setEthernetTagId(eti).setOrigRouteIp(ip);
index d10e6ef48fc31b9134d1e70bc45daf4952464606..cea7f0d05bff47512641c4938cc61225360c59c8 100644 (file)
@@ -22,6 +22,7 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.bgp.evpn.spi.pojo.SimpleEsiTypeRegistry;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.Ipv6Util;
@@ -48,7 +49,7 @@ final class MACIpAdvRParser extends AbstractEvpnNlri {
     @Override
     public EvpnChoice parseEvpn(final ByteBuf buffer) {
         final Esi esi = SimpleEsiTypeRegistry.getInstance().parseEsi(buffer.readSlice(ESI_SIZE));
-        final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(buffer.readUnsignedInt()).build();
+        final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(ByteBufUtils.readUint32(buffer)).build();
         buffer.skipBytes(1);
         final MacAddress mac = IetfYangUtil.INSTANCE.macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH));
         final IpAddress ip = parseIp(buffer);
index 8ec58f146aad5bc874ae75f2401abb3314ec3723..792026f6d2369a2c11a0aaad9abdf9a7b3304ce6 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.bgp.flowspec.handlers.FlowspecTypeParser;
 import org.opendaylight.protocol.bgp.flowspec.handlers.FlowspecTypeSerializer;
 import org.opendaylight.protocol.bgp.flowspec.handlers.NumericOneByteOperandParser;
 import org.opendaylight.protocol.bgp.flowspec.handlers.Util;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.Dscp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOperand;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.FlowspecType;
@@ -47,7 +48,7 @@ public final class FSDscpHandler implements FlowspecTypeParser, FlowspecTypeSeri
             // RFC does not specify operator
             final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
             builder.setOp(op);
-            builder.setValue(new Dscp(nlri.readUnsignedByte()));
+            builder.setValue(new Dscp(ByteBufUtils.readUint8(nlri)));
             end = op.isEndOfList();
             dscps.add(builder.build());
         }
index e9e6e124a6aaf9426f46aee527be3a5f14629ee4..79977b0d19a7f7905739873d1080fbf33fe8598c 100644 (file)
@@ -16,6 +16,7 @@ import java.util.List;
 import org.opendaylight.protocol.bgp.flowspec.handlers.FlowspecTypeParser;
 import org.opendaylight.protocol.bgp.flowspec.handlers.FlowspecTypeSerializer;
 import org.opendaylight.protocol.bgp.flowspec.handlers.NumericOneByteOperandParser;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOperand;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.FlowspecType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.IcmpCodeCase;
@@ -27,14 +28,14 @@ public final class FSIcmpCodeHandler implements FlowspecTypeParser, FlowspecType
     public static final int ICMP_CODE_VALUE = 8;
 
     @Override
-    public void serializeType(FlowspecType fsType, ByteBuf output) {
+    public void serializeType(final FlowspecType fsType, final ByteBuf output) {
         Preconditions.checkArgument(fsType instanceof IcmpCodeCase, "IcmpCodeCase class is mandatory!");
         output.writeByte(ICMP_CODE_VALUE);
         NumericOneByteOperandParser.INSTANCE.serialize(((IcmpCodeCase) fsType).getCodes(), output);
     }
 
     @Override
-    public FlowspecType parseType(ByteBuf buffer) {
+    public FlowspecType parseType(final ByteBuf buffer) {
         requireNonNull(buffer, "input buffer is null, missing data to parse.");
         return new IcmpCodeCaseBuilder().setCodes(parseIcmpCode(buffer)).build();
     }
@@ -48,7 +49,7 @@ public final class FSIcmpCodeHandler implements FlowspecTypeParser, FlowspecType
             final byte b = nlri.readByte();
             final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
             builder.setOp(op);
-            builder.setValue(nlri.readUnsignedByte());
+            builder.setValue(ByteBufUtils.readUint8(nlri));
             end = op.isEndOfList();
             codes.add(builder.build());
         }
index 758df256c2776271658d96aa7facd652143dec23..8dd1611831ecd783533829a46c3e3b867f954668 100644 (file)
@@ -16,6 +16,7 @@ import java.util.List;
 import org.opendaylight.protocol.bgp.flowspec.handlers.FlowspecTypeParser;
 import org.opendaylight.protocol.bgp.flowspec.handlers.FlowspecTypeSerializer;
 import org.opendaylight.protocol.bgp.flowspec.handlers.NumericOneByteOperandParser;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOperand;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.FlowspecType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.flowspec.type.IcmpTypeCase;
@@ -27,14 +28,14 @@ public final class FSIcmpTypeHandler implements FlowspecTypeParser, FlowspecType
     public static final int ICMP_TYPE_VALUE = 7;
 
     @Override
-    public void serializeType(FlowspecType fsType, ByteBuf output) {
+    public void serializeType(final FlowspecType fsType, final ByteBuf output) {
         Preconditions.checkArgument(fsType instanceof IcmpTypeCase, "IcmpTypeCase class is mandatory!");
         output.writeByte(ICMP_TYPE_VALUE);
         NumericOneByteOperandParser.INSTANCE.serialize(((IcmpTypeCase) fsType).getTypes(), output);
     }
 
     @Override
-    public FlowspecType parseType(ByteBuf buffer) {
+    public FlowspecType parseType(final ByteBuf buffer) {
         requireNonNull(buffer, "input buffer is null, missing data to parse.");
         return new IcmpTypeCaseBuilder().setTypes(parseIcmpType(buffer)).build();
     }
@@ -48,7 +49,7 @@ public final class FSIcmpTypeHandler implements FlowspecTypeParser, FlowspecType
             final byte b = nlri.readByte();
             final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
             builder.setOp(op);
-            builder.setValue(nlri.readUnsignedByte());
+            builder.setValue(ByteBufUtils.readUint8(nlri));
             end = op.isEndOfList();
             icmps.add(builder.build());
         }
index eb4bcf9e2810acc06493380a88f0a9df29f6c5cb..0dbabfc7cb25cfc603fcaeda6a21314979ad6ce3 100644 (file)
@@ -16,6 +16,7 @@ import java.util.List;
 import org.opendaylight.protocol.bgp.flowspec.handlers.FlowspecTypeParser;
 import org.opendaylight.protocol.bgp.flowspec.handlers.FlowspecTypeSerializer;
 import org.opendaylight.protocol.bgp.flowspec.handlers.NumericOneByteOperandParser;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOperand;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.FlowspecType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv4.flowspec.flowspec.type.ProtocolIpCase;
@@ -27,14 +28,14 @@ public final class FSIpProtocolHandler implements FlowspecTypeParser, FlowspecTy
     public static final int IP_PROTOCOL_VALUE = 3;
 
     @Override
-    public void serializeType(FlowspecType fsType, ByteBuf output) {
+    public void serializeType(final FlowspecType fsType, final ByteBuf output) {
         Preconditions.checkArgument(fsType instanceof ProtocolIpCase, "ProtocolIpCase class is mandatory!");
         output.writeByte(IP_PROTOCOL_VALUE);
         NumericOneByteOperandParser.INSTANCE.serialize(((ProtocolIpCase) fsType).getProtocolIps(), output);
     }
 
     @Override
-    public FlowspecType parseType(ByteBuf buffer) {
+    public FlowspecType parseType(final ByteBuf buffer) {
         requireNonNull(buffer, "input buffer is null, missing data to parse.");
         return new ProtocolIpCaseBuilder().setProtocolIps(parseProtocolIp(buffer)).build();
     }
@@ -48,7 +49,7 @@ public final class FSIpProtocolHandler implements FlowspecTypeParser, FlowspecTy
             final byte b = nlri.readByte();
             final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
             builder.setOp(op);
-            builder.setValue(nlri.readUnsignedByte());
+            builder.setValue(ByteBufUtils.readUint8(nlri));
             end = op.isEndOfList();
             ips.add(builder.build());
         }
index ebeb9e4d1e0323f6e525d852bee32609639a26f2..127cd0d13145833c382d1c3565f0362e41213ee9 100644 (file)
@@ -14,6 +14,7 @@ import java.util.List;
 import org.opendaylight.protocol.bgp.flowspec.handlers.FlowspecTypeParser;
 import org.opendaylight.protocol.bgp.flowspec.handlers.FlowspecTypeSerializer;
 import org.opendaylight.protocol.bgp.flowspec.handlers.NumericOneByteOperandParser;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.NumericOperand;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.flowspec.FlowspecType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.destination.group.ipv6.flowspec.flowspec.type.NextHeaderCase;
@@ -25,14 +26,14 @@ public final class FSIpv6NextHeaderHandler implements FlowspecTypeParser, Flowsp
     public static final int NEXT_HEADER_VALUE = 3;
 
     @Override
-    public void serializeType(FlowspecType value, ByteBuf output) {
+    public void serializeType(final FlowspecType value, final ByteBuf output) {
         Preconditions.checkArgument(value instanceof NextHeaderCase, "NextHeaderCase class is mandatory!");
         output.writeByte(NEXT_HEADER_VALUE);
         NumericOneByteOperandParser.INSTANCE.serialize(((NextHeaderCase) value).getNextHeaders(), output);
     }
 
     @Override
-    public FlowspecType parseType(ByteBuf buffer) {
+    public FlowspecType parseType(final ByteBuf buffer) {
         if (buffer == null) {
             return null;
         }
@@ -48,7 +49,7 @@ public final class FSIpv6NextHeaderHandler implements FlowspecTypeParser, Flowsp
             final byte b = nlri.readByte();
             final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
             builder.setOp(op);
-            builder.setValue(nlri.readUnsignedByte());
+            builder.setValue(ByteBufUtils.readUint8(nlri));
             end = op.isEndOfList();
             headers.add(builder.build());
         }
index 5890b2bb7eea1db1632946ff9a32cc310518affb..8775bc5cbfd5921899fd7f1f37f422381edccc6f 100644 (file)
@@ -12,6 +12,7 @@ import static com.google.common.base.Preconditions.checkArgument;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunityParser;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunitySerializer;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.redirect.as4.extended.community.RedirectAs4;
@@ -39,8 +40,8 @@ public final class RedirectAsFourOctetEcHandler implements ExtendedCommunityPars
     @Override
     public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
         final RedirectAs4Builder builder = new RedirectAs4Builder();
-        builder.setGlobalAdministrator(new AsNumber(buffer.readUnsignedInt()));
-        builder.setLocalAdministrator(buffer.readUnsignedShort());
+        builder.setGlobalAdministrator(new AsNumber(ByteBufUtils.readUint32(buffer)));
+        builder.setLocalAdministrator(ByteBufUtils.readUint16(buffer));
         return new RedirectAs4ExtendedCommunityCaseBuilder().setRedirectAs4(builder.build()).build();
     }
 
index 7abd7f897434156ae73b8610966e0de3cc12da4a..50eb738c110d7b51f55f67b0a955cf2aed282781 100644 (file)
@@ -14,12 +14,14 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunityParser;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunitySerializer;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.redirect.extended.community.RedirectExtendedCommunity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.redirect.extended.community.RedirectExtendedCommunityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectExtendedCommunityCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ShortAsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 public class RedirectAsTwoOctetEcHandler implements ExtendedCommunityParser, ExtendedCommunitySerializer {
 
@@ -53,7 +55,7 @@ public class RedirectAsTwoOctetEcHandler implements ExtendedCommunityParser, Ext
 
     @Override
     public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
-        final ShortAsNumber as1 = new ShortAsNumber((long) buffer.readUnsignedShort());
+        final ShortAsNumber as1 = new ShortAsNumber(Uint32.valueOf(ByteBufUtils.readUint16(buffer)));
         final byte[] byteValue = ByteArray.readBytes(buffer, TRAFFIC_RATE_SIZE);
         return new RedirectExtendedCommunityCaseBuilder().setRedirectExtendedCommunity(
                 new RedirectExtendedCommunityBuilder()
index ecafdaf9a7fe2a98139c21688da4d3939a548f66..6bc77768bc5dbd6a016c3ceec955ef2444efddcc 100644 (file)
@@ -12,6 +12,7 @@ import static com.google.common.base.Preconditions.checkArgument;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunityParser;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunitySerializer;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.redirect.ipv4.extended.community.RedirectIpv4;
@@ -40,7 +41,7 @@ public class RedirectIpv4EcHandler implements ExtendedCommunityParser, ExtendedC
     public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
         final RedirectIpv4Builder builder = new RedirectIpv4Builder();
         builder.setGlobalAdministrator(Ipv4Util.addressForByteBuf(buffer));
-        builder.setLocalAdministrator(buffer.readUnsignedShort());
+        builder.setLocalAdministrator(ByteBufUtils.readUint16(buffer));
         return new RedirectIpv4ExtendedCommunityCaseBuilder().setRedirectIpv4(builder.build()).build();
     }
 
index e36ae75aaae5fed123d11407ee55b96d0c2301aa..30655123456114165c62aeac3da8cb82b8d97f83 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunityParser;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunitySerializer;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.protocol.util.Ipv6Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.RedirectIpv6ExtendedCommunity;
@@ -49,7 +50,7 @@ public final class RedirectIpv6EcHandler implements ExtendedCommunityParser, Ext
         return new RedirectIpv6ExtendedCommunityCaseBuilder().setRedirectIpv6(
                 new RedirectIpv6Builder()
                     .setGlobalAdministrator(Ipv6Util.addressForByteBuf(buffer))
-                    .setLocalAdministrator(buffer.readUnsignedShort())
+                    .setLocalAdministrator(ByteBufUtils.readUint16(buffer))
                     .build()).build();
     }
 
index b1d3c1e57a0b0ab2340e817ed12362a0a3afed97..8a272906ed278081032de7038c9564feb4576add 100644 (file)
@@ -12,6 +12,7 @@ import static com.google.common.base.Preconditions.checkArgument;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunityParser;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunitySerializer;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.Dscp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.traffic.marking.extended.community.TrafficMarkingExtendedCommunity;
@@ -53,7 +54,7 @@ public class TrafficMarkingEcHandler implements ExtendedCommunityParser, Extende
     @Override
     public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
         buffer.skipBytes(RESERVED);
-        final Dscp dscp = new Dscp(buffer.readUnsignedByte());
+        final Dscp dscp = new Dscp(ByteBufUtils.readUint8(buffer));
         return new TrafficMarkingExtendedCommunityCaseBuilder().setTrafficMarkingExtendedCommunity(
                 new TrafficMarkingExtendedCommunityBuilder()
                     .setGlobalAdministrator(dscp).build()).build();
index 98fcf7428aac09ae11f78cf007332f74f555ef64..4f7ce52a281818707579168c7037258a408b52d4 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flow
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.ShortAsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 public class TrafficRateEcHandler implements ExtendedCommunityParser, ExtendedCommunitySerializer {
 
@@ -54,7 +55,7 @@ public class TrafficRateEcHandler implements ExtendedCommunityParser, ExtendedCo
 
     @Override
     public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
-        final ShortAsNumber as = new ShortAsNumber((long) buffer.readUnsignedShort());
+        final ShortAsNumber as = new ShortAsNumber(Uint32.valueOf(buffer.readUnsignedShort()));
         final Bandwidth value = new Bandwidth(ByteArray.readBytes(buffer, TRAFFIC_RATE_SIZE));
         return new TrafficRateExtendedCommunityCaseBuilder().setTrafficRateExtendedCommunity(
                 new TrafficRateExtendedCommunityBuilder()
index 8392e4de9f90a71e22d3a83a65f11900dfaf2844..0ffc143045f8e9e5cf9d48a1f94eccc3534e4080 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.spi.BgpPrefixSidTlvParser;
 import org.opendaylight.protocol.bgp.parser.spi.BgpPrefixSidTlvSerializer;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuLabelIndexTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuLabelIndexTlvBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv;
@@ -33,8 +34,7 @@ final class LabelIndexTlvParser implements BgpPrefixSidTlvParser, BgpPrefixSidTl
     public LuLabelIndexTlv parseBgpPrefixSidTlv(final ByteBuf buffer) {
         buffer.readBytes(RESERVED);
         buffer.readBytes(LABEL_INDEX_FLAGS_BYTES);
-        final Long value = buffer.readUnsignedInt();
-        return new LuLabelIndexTlvBuilder().setLabelIndexTlv(value).build();
+        return new LuLabelIndexTlvBuilder().setLabelIndexTlv(ByteBufUtils.readUint32(buffer)).build();
     }
 
     @Override
index 35470da588a35c62222877bc010d7e67dc1ad8ff..a0f49eef992a6761f47f4e67b60b4b833e33fb5e 100644 (file)
@@ -13,6 +13,7 @@ import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.protocol.bgp.parser.spi.BgpPrefixSidTlvParser;
 import org.opendaylight.protocol.bgp.parser.spi.BgpPrefixSidTlvSerializer;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.Srgb;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.originator.srgb.tlv.SrgbValue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.originator.srgb.tlv.SrgbValueBuilder;
@@ -38,8 +39,8 @@ final class OriginatorSrgbTlvParser implements BgpPrefixSidTlvParser, BgpPrefixS
                 "Number of SRGBs does not fit available bytes.");
         final List<SrgbValue> ret = new ArrayList<>();
         while (buffer.isReadable()) {
-            ret.add(new SrgbValueBuilder().setBase(new Srgb((long) buffer.readUnsignedMedium()))
-                .setRange(new Srgb((long) buffer.readUnsignedMedium())).build());
+            ret.add(new SrgbValueBuilder().setBase(new Srgb(ByteBufUtils.readUint24(buffer)))
+                .setRange(new Srgb(ByteBufUtils.readUint24(buffer))).build());
         }
         return ret;
     }
index 805fb3bff2e5be4deae7881b1fbffb0dc8d210d0..349c4f5eb7195ac657e2020f0cbdbe8231fe0a9e 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrLinkAttribute
 import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.Ipv6Util;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
@@ -53,6 +54,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Metric;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.TeMetric;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -142,7 +144,7 @@ public final class LinkAttributesParser {
                     LOG.debug("Parsed IPv6 Router-ID of remote node: {}", builder.getRemoteIpv6RouterId());
                     break;
                 case ADMIN_GROUP:
-                    builder.setAdminGroup(new AdministrativeGroup(value.readUnsignedInt()));
+                    builder.setAdminGroup(new AdministrativeGroup(ByteBufUtils.readUint32(value)));
                     LOG.debug("Parsed Administrative Group {}", builder.getAdminGroup());
                     break;
                 case MAX_BANDWIDTH:
@@ -209,21 +211,22 @@ public final class LinkAttributesParser {
                     break;
                     // Performance Metrics
                 case LINK_DELAY:
-                    builder.setLinkDelay(new Delay(value.readUnsignedInt()));
+                    builder.setLinkDelay(new Delay(ByteBufUtils.readUint32(value)));
                     LOG.debug("Parsed Link Delay {}", builder.getLinkDelay());
                     break;
                 case LINK_MIN_MAX_DELAY:
                     builder.setLinkMinMaxDelay(new LinkMinMaxDelayBuilder()
-                        .setMinDelay(new Delay(value.readUnsignedInt()))
-                        .setMaxDelay(new Delay(value.readUnsignedInt())).build());
+                        .setMinDelay(new Delay(ByteBufUtils.readUint32(value)))
+                        .setMaxDelay(new Delay(ByteBufUtils.readUint32(value)))
+                        .build());
                     LOG.debug("Parsed Link Min/Max Delay {}", builder.getLinkMinMaxDelay());
                     break;
                 case DELAY_VARIATION:
-                    builder.setDelayVariation(new Delay(value.readUnsignedInt()));
+                    builder.setDelayVariation(new Delay(ByteBufUtils.readUint32(value)));
                     LOG.debug("Parsed Delay Variation {}", builder.getDelayVariation());
                     break;
                 case LINK_LOSS:
-                    builder.setLinkLoss(new Loss(value.readUnsignedInt()));
+                    builder.setLinkLoss(new Loss(ByteBufUtils.readUint32(value)));
                     LOG.debug("Parsed Link Loss {}", builder.getLinkLoss());
                     break;
                 case RESIDUAL_BANDWIDTH:
@@ -261,7 +264,7 @@ public final class LinkAttributesParser {
         for (int i = 0; i < UNRESERVED_BW_COUNT; i++) {
             final ByteBuf v = value.readSlice(BANDWIDTH_LENGTH);
             unreservedBandwidth.add(new UnreservedBandwidthBuilder().setBandwidth(
-                new Bandwidth(ByteArray.readAllBytes(v))).setPriority((short) i).build());
+                new Bandwidth(ByteArray.readAllBytes(v))).setPriority(Uint8.valueOf(i)).build());
         }
         builder.setUnreservedBandwidth(unreservedBandwidth);
         LOG.debug("Parsed Unreserved Bandwidth {}", builder.getUnreservedBandwidth());
@@ -270,7 +273,7 @@ public final class LinkAttributesParser {
     private static void parseSrlg(final ByteBuf value, final LinkAttributesBuilder builder) {
         final List<SrlgId> sharedRiskLinkGroups = new ArrayList<>();
         while (value.isReadable()) {
-            sharedRiskLinkGroups.add(new SrlgId(value.readUnsignedInt()));
+            sharedRiskLinkGroups.add(new SrlgId(ByteBufUtils.readUint32(value)));
         }
         builder.setSharedRiskLinkGroups(sharedRiskLinkGroups);
         LOG.debug("Parsed Shared Risk Link Groups {}", builder.getSharedRiskLinkGroups());
index 66ace44af0b702f8c26e9dd1bbd76c79de0f36df..53418d9bb6020782a700350ce3808e516a4bfe39 100644 (file)
@@ -35,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.link
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.node.state.SrAlgorithm;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.node.state.SrCapabilities;
+import org.opendaylight.yangtools.yang.common.Uint16;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -141,7 +142,7 @@ public final class NodeAttributesParser {
     private static void parseTopologyId(final List<TopologyIdentifier> topologyMembership, final ByteBuf value) {
         while (value.isReadable()) {
             final TopologyIdentifier topId = new TopologyIdentifier(
-                value.readUnsignedShort() & TlvUtil.TOPOLOGY_ID_OFFSET);
+                Uint16.valueOf(value.readUnsignedShort() & TlvUtil.TOPOLOGY_ID_OFFSET));
             topologyMembership.add(topId);
             LOG.debug("Parsed Topology Identifier: {}", topId);
         }
index 96c79a2ce589590079ac4d2373f3cc024cdf4736..4e983749fb269a35037e9d252e6c9696031842a7 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrPrefixAttribu
 import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.Ipv6Util;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
@@ -111,7 +112,7 @@ public final class PrefixAttributesParser {
                 parseExtendedRouteTags(exRouteTags, value);
                 break;
             case PREFIX_METRIC:
-                final IgpMetric metric = new IgpMetric(value.readUnsignedInt());
+                final IgpMetric metric = new IgpMetric(ByteBufUtils.readUint32(value));
                 builder.setPrefixMetric(metric);
                 LOG.debug("Parsed Metric: {}", metric);
                 break;
index 9519ea0621e2c935327c77bef40c76d15d36ba82..2d0b52e8eb48f4f871965e1d5ed2ce86aebb2463 100644 (file)
@@ -11,6 +11,7 @@ import io.netty.buffer.ByteBuf;
 import java.util.List;
 import org.opendaylight.protocol.bgp.linkstate.spi.pojo.SimpleBindingSubTlvsRegistry;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.SrBindingSidLabels;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.SrBindingSidLabelsBuilder;
@@ -41,7 +42,7 @@ public final class BindingSidLabelParser {
 
     public static SrBindingSidLabels parseBindingSidLabel(final ByteBuf buffer, final ProtocolId protocolId) {
         final SrBindingSidLabelsBuilder bindingSid = new SrBindingSidLabelsBuilder();
-        bindingSid.setWeight(new Weight(buffer.readUnsignedByte()));
+        bindingSid.setWeight(new Weight(ByteBufUtils.readUint8(buffer)));
         final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
         bindingSid.setFlags(parseBindingSidFlags(flags, protocolId));
         buffer.skipBytes(RESERVED_BINDING_SID);
index b5527fbe0fd682b15e81f585a647e153afb3ae72..84dae0f9fc014889178f0a508f7b9ac27b4c731c 100644 (file)
@@ -19,6 +19,7 @@ import java.util.List;
 import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SidLabelIndexParser.Size;
 import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.SrRange;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.prefix.state.SrRangeBuilder;
@@ -56,7 +57,7 @@ public final class RangeTlvParser {
             range.setInterArea(Boolean.FALSE);
         }
         buffer.skipBytes(RESERVED);
-        range.setRangeSize(buffer.readUnsignedShort());
+        range.setRangeSize(ByteBufUtils.readUint16(buffer));
         range.setSubTlvs(parseRangeSubTlvs(buffer, protocolId));
         return range.build();
     }
index f2f78867cd50ab7fbae4cd1d79e3bd9d906adf5b..55e7ace8720c796f9140a5d35efdcfb1f4c4f0c7 100644 (file)
@@ -14,6 +14,7 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.Map;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv6Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.SidLabelIndex;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.sid.label.index.Ipv6AddressCase;
@@ -23,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segm
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.sid.label.index.SidCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.sid.label.index.sid.label.index.SidCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -83,9 +85,9 @@ public final class SidLabelIndexParser {
         switch (length) {
             case LABEL:
                 return new LocalLabelCaseBuilder()
-                        .setLocalLabel(new MplsLabel(Long.valueOf(buffer.readUnsignedMedium() & LABEL_MASK))).build();
+                        .setLocalLabel(new MplsLabel(Uint32.valueOf(buffer.readUnsignedMedium() & LABEL_MASK))).build();
             case SID:
-                return new SidCaseBuilder().setSid(buffer.readUnsignedInt()).build();
+                return new SidCaseBuilder().setSid(ByteBufUtils.readUint32(buffer)).build();
             case IPV6_ADD:
                 return new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(buffer)).build();
             default:
index ec7c1f97a11f37de4cfca016a5ecc49770eeb107..6071900c0121cc5663a55a28421b5c26ca8b9d56 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SidLabelIndexPa
 import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.attribute.SrAdjIds;
@@ -77,7 +78,7 @@ public final class SrLinkAttributesParser {
         if (buffer.isReadable()) {
             final BitArray flags = BitArray.valueOf(buffer, FLAGS_BITS_SIZE);
             adjFlags = parseFlags(flags, protocolId);
-            weight = new Weight(buffer.readUnsignedByte());
+            weight = new Weight(ByteBufUtils.readUint8(buffer));
             buffer.skipBytes(RESERVED);
             sidValue = SidLabelIndexParser.parseSidLabelIndex(Size.forValue(buffer.readableBytes()), buffer);
         } else {
@@ -93,7 +94,7 @@ public final class SrLinkAttributesParser {
         final SidLabelIndex sidValue;
         if (buffer.isReadable()) {
             buffer.skipBytes(FLAGS_BYTE_SIZE);
-            weight = new Weight(buffer.readUnsignedByte());
+            weight = new Weight(ByteBufUtils.readUint8(buffer));
             buffer.skipBytes(RESERVED);
             sidValue = SidLabelIndexParser.parseSidLabelIndex(Size.forValue(buffer.readableBytes()), buffer);
         } else {
@@ -125,7 +126,7 @@ public final class SrLinkAttributesParser {
         final SrLanAdjIdsBuilder srLanAdjIdBuilder = new SrLanAdjIdsBuilder();
         final BitArray flags = BitArray.valueOf(buffer, FLAGS_BITS_SIZE);
         srLanAdjIdBuilder.setFlags(parseFlags(flags, protocolId));
-        srLanAdjIdBuilder.setWeight(new Weight(buffer.readUnsignedByte()));
+        srLanAdjIdBuilder.setWeight(new Weight(ByteBufUtils.readUint8(buffer)));
         buffer.skipBytes(RESERVED);
         switch (protocolId) {
             case IsisLevel1:
index c0e956ad837be510859c7b63d7c3aca5a92748cd..4a8b7de58d9bdc4739bb5a9d30806a0f3691df74 100644 (file)
@@ -14,6 +14,7 @@ import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.node.state.SrAlgorithm;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.node.state.SrAlgorithmBuilder;
@@ -39,7 +40,7 @@ public final class SrNodeAttributesParser {
         final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
         setFlags(flags, protocol, builder);
         buffer.skipBytes(RESERVERED);
-        builder.setRangeSize((long) buffer.readUnsignedMedium());
+        builder.setRangeSize(ByteBufUtils.readUint24(buffer));
         builder.setSidLabelIndex(SidLabelIndexParser.parseSidSubTlv(buffer));
         return builder.build();
     }
index eb7f164137d02ae0bc9498d7c4ff66cb7654aa70..0a55def424665f8287b9388f41c4271a90c4f8ba 100644 (file)
@@ -14,6 +14,7 @@ import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsParser;
 import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsSerializer;
 import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.BindingSubTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.binding.sub.tlv.EroMetricCase;
@@ -25,7 +26,7 @@ public final class EroMetricParser implements BindingSubTlvsParser, BindingSubTl
 
     @Override
     public BindingSubTlv parseSubTlv(final ByteBuf slice, final ProtocolId protocolId) {
-        return new EroMetricCaseBuilder().setEroMetric(new TeMetric(slice.readUnsignedInt())).build();
+        return new EroMetricCaseBuilder().setEroMetric(new TeMetric(ByteBufUtils.readUint32(slice))).build();
     }
 
     @Override
index 502799fd5cd87961e3c70a6db4d983ee04fa9333..6fc9928ca14ddd315f5c5de0d57b56870984ff43 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsParser;
 import org.opendaylight.protocol.bgp.linkstate.spi.BindingSubTlvsSerializer;
 import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.BindingSubTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.binding.sub.tlvs.binding.sub.tlv.UnnumberedInterfaceIdEroCase;
@@ -51,8 +52,8 @@ public final class UnnumberedEroParser implements BindingSubTlvsParser, BindingS
         final BitArray flags = BitArray.valueOf(buffer, Ipv4EroParser.FLAGS_SIZE);
         builder.setLoose(flags.get(Ipv4EroParser.LOOSE));
         buffer.skipBytes(Ipv4EroParser.RESERVED_ERO);
-        builder.setRouterId(buffer.readUnsignedInt());
-        builder.setInterfaceId(buffer.readUnsignedInt());
+        builder.setRouterId(ByteBufUtils.readUint32(buffer));
+        builder.setInterfaceId(ByteBufUtils.readUint32(buffer));
         return builder.build();
     }
 
index 056e66540e5491bda81f8a6c99d9475b79a0559c..bd045250b9906f1e48ddb35ffa6ede11cb83291a 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.bgp.linkstate.impl.nlri;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.linkstate.spi.AbstractTeLspNlriCodec;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.NlriType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.ObjectType;
@@ -16,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.link
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.te.lsp._case.address.family.Ipv4CaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 public final class TeLspIpv4NlriParser extends AbstractTeLspNlriCodec {
     @Override
@@ -23,8 +25,8 @@ public final class TeLspIpv4NlriParser extends AbstractTeLspNlriCodec {
         final TeLspCaseBuilder builder = new TeLspCaseBuilder();
         final Ipv4CaseBuilder ipv4CaseBuilder = new Ipv4CaseBuilder();
         ipv4CaseBuilder.setIpv4TunnelSenderAddress(Ipv4Util.addressForByteBuf(buffer));
-        builder.setTunnelId(new TunnelId(buffer.readUnsignedShort()));
-        builder.setLspId(new LspId((long) buffer.readUnsignedShort()));
+        builder.setTunnelId(new TunnelId(ByteBufUtils.readUint16(buffer)));
+        builder.setLspId(new LspId(Uint32.valueOf(buffer.readUnsignedShort())));
         ipv4CaseBuilder.setIpv4TunnelEndpointAddress(Ipv4Util.addressForByteBuf(buffer));
         return builder.setAddressFamily(ipv4CaseBuilder.build()).build();
     }
index 9edd5bcfe22ef081ecdd00aee70bd34cb478511c..cb31d8fa62ea267e6e03ab055cedfd7f33950a97 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.bgp.linkstate.impl.nlri;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.linkstate.spi.AbstractTeLspNlriCodec;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv6Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.NlriType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.ObjectType;
@@ -16,6 +17,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.link
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.te.lsp._case.address.family.Ipv6CaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 public final class TeLspIpv6NlriParser extends AbstractTeLspNlriCodec {
     @Override
@@ -23,8 +25,8 @@ public final class TeLspIpv6NlriParser extends AbstractTeLspNlriCodec {
         final TeLspCaseBuilder builder = new TeLspCaseBuilder();
         final Ipv6CaseBuilder ipv6CaseBuilder = new Ipv6CaseBuilder();
         ipv6CaseBuilder.setIpv6TunnelSenderAddress(Ipv6Util.addressForByteBuf(buffer));
-        builder.setTunnelId(new TunnelId(buffer.readUnsignedShort()));
-        builder.setLspId(new LspId((long) buffer.readUnsignedShort()));
+        builder.setTunnelId(new TunnelId(ByteBufUtils.readUint16(buffer)));
+        builder.setLspId(new LspId(Uint32.valueOf(buffer.readUnsignedShort())));
         ipv6CaseBuilder.setIpv6TunnelEndpointAddress(Ipv6Util.addressForByteBuf(buffer));
         return builder.setAddressFamily(ipv6CaseBuilder.build()).build();
     }
index f3115b0875cddac099dceb78cd848de5b7903963..417664bd96b27a1ec46b3c231ef2ece4e0db42c4 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.bgp.linkstate.impl.tlvs;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.linkstate.spi.LinkstateTlvParser;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.AreaIdentifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.node._case.NodeDescriptors;
@@ -28,7 +29,7 @@ public final class AreaIdTlvParser implements LinkstateTlvParser<AreaIdentifier>
 
     @Override
     public AreaIdentifier parseTlvBody(final ByteBuf value) {
-        return new AreaIdentifier(value.readUnsignedInt());
+        return new AreaIdentifier(ByteBufUtils.readUint32(value));
     }
 
     @Override
index 147a4b09b0cc5c2090471b9a940ae07426a60ed7..26f93044509cb91246f997a8c1d9b7561cc18df0 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.bgp.linkstate.impl.tlvs;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.linkstate.spi.LinkstateTlvParser;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.node._case.NodeDescriptors;
@@ -28,7 +29,7 @@ public final class AsNumTlvParser implements LinkstateTlvParser<AsNumber>,
 
     @Override
     public AsNumber parseTlvBody(final ByteBuf value) {
-        return new AsNumber(value.readUnsignedInt());
+        return new AsNumber(ByteBufUtils.readUint32(value));
     }
 
     @Override
index 73c126ea2d0a139127b2eacaeb306c1b4ef2a2ca..4c6fc3b38a3bb87f0cf692961d7e5ff0fa2c4934 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.bgp.linkstate.impl.tlvs;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.linkstate.spi.LinkstateTlvParser;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.DomainIdentifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.linkstate.object.type.node._case.NodeDescriptors;
@@ -28,7 +29,7 @@ public final class DomainIdTlvParser implements LinkstateTlvParser<DomainIdentif
 
     @Override
     public DomainIdentifier parseTlvBody(final ByteBuf value) {
-        return new DomainIdentifier(value.readUnsignedInt());
+        return new DomainIdentifier(ByteBufUtils.readUint32(value));
     }
 
     @Override
index 75fc24fc6e11f30c2de4d18750db154fd6f66aab..3633263d6d571f2bbf3a50d4d4a0b26bb5aa99a4 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.bgp.linkstate.impl.tlvs;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.linkstate.spi.LinkstateTlvParser;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.epe.rev150622.EpeNodeDescriptors;
@@ -28,7 +29,7 @@ public final class MemAsNumTlvParser implements LinkstateTlvParser<AsNumber>,
 
     @Override
     public AsNumber parseTlvBody(final ByteBuf value) {
-        return new AsNumber(value.readUnsignedInt());
+        return new AsNumber(ByteBufUtils.readUint32(value));
     }
 
     @Override
index b0eb0b823ef82c4c4148e7ef5d3f8b72e168a537..3e29dced8b7205285b193fb0da45072d734c49a1 100644 (file)
@@ -35,7 +35,7 @@ public final class MultiTopoIdTlvParser implements LinkstateTlvParser<TopologyId
 
     @Override
     public TopologyIdentifier parseTlvBody(final ByteBuf value) {
-        return new TopologyIdentifier(value.readShort() & TlvUtil.TOPOLOGY_ID_OFFSET);
+        return new TopologyIdentifier(Uint16.valueOf(value.readShort() & TlvUtil.TOPOLOGY_ID_OFFSET));
     }
 
     @Override
index 76f5094ef0c06d4951e4d3c7d64ef8135856fa72..c4a36dcaade02e952232ab99a7dbdbf287af09ef 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.protocol.bgp.linkstate.impl.tlvs;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.linkstate.spi.LinkstateTlvParser;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.OspfInterfaceIdentifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.isis.lan.identifier.IsIsRouterIdentifier;
@@ -73,17 +74,17 @@ public final class RouterIdTlvParser implements LinkstateTlvParser<CRouterIdenti
             final IsIsRouterIdentifier iri = new IsIsRouterIdentifierBuilder().setIsoSystemId(
                     new IsoSystemIdentifier(ByteArray.readBytes(value, ISO_SYSTEM_ID_LENGTH))).build();
             return new IsisPseudonodeCaseBuilder().setIsisPseudonode(new IsisPseudonodeBuilder()
-                .setIsIsRouterIdentifier(iri).setPsn((short) value.readByte()).build()).build();
+                .setIsIsRouterIdentifier(iri).setPsn(ByteBufUtils.readUint8(value)).build()).build();
         }
         if (value.readableBytes() == OSPF_ROUTER_ID_LENGTH) {
             return new OspfNodeCaseBuilder().setOspfNode(
-                    new OspfNodeBuilder().setOspfRouterId(value.readUnsignedInt()).build()).build();
+                    new OspfNodeBuilder().setOspfRouterId(ByteBufUtils.readUint32(value)).build()).build();
 
         }
         if (value.readableBytes() == OSPF_PSEUDONODE_ROUTER_ID_LENGTH) {
             return new OspfPseudonodeCaseBuilder().setOspfPseudonode(
-                    new OspfPseudonodeBuilder().setOspfRouterId(value.readUnsignedInt())
-                    .setLanInterface(new OspfInterfaceIdentifier(value.readUnsignedInt())).build()).build();
+                    new OspfPseudonodeBuilder().setOspfRouterId(ByteBufUtils.readUint32(value))
+                    .setLanInterface(new OspfInterfaceIdentifier(ByteBufUtils.readUint32(value))).build()).build();
         }
         return null;
     }
index a233939526779354290d17a23932cd118bd98420..1383c988f5b778521ea09064fa40bb42d3d7d633 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.protocol.bgp.linkstate.spi;
 
 import io.netty.buffer.ByteBuf;
-import java.math.BigInteger;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.Identifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev180329.ProtocolId;
@@ -21,7 +21,7 @@ public abstract class AbstractNlriTypeCodec implements NlriTypeCaseParser, NlriT
     public final CLinkstateDestination parseTypeNlri(final ByteBuf nlri) {
         final CLinkstateDestinationBuilder builder = new CLinkstateDestinationBuilder();
         builder.setProtocolId(ProtocolId.forValue(nlri.readUnsignedByte()));
-        builder.setIdentifier(new Identifier(BigInteger.valueOf(nlri.readLong())));
+        builder.setIdentifier(new Identifier(ByteBufUtils.readUint64(nlri)));
         builder.setObjectType(parseObjectType(nlri));
         return builder.build();
     }
index a023975851a5d9ad1f42c4256dc3fcf46b0880d3..42e082aab5a5a32059319a124884e99b9334bc4f 100644 (file)
@@ -16,6 +16,7 @@ import java.util.ArrayList;
 import java.util.List;
 import javax.xml.bind.DatatypeConverter;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.Opaque;
@@ -74,9 +75,9 @@ public final class OpaqueUtil {
     }
 
     public static Opaque parseOpaque(final ByteBuf buffer) {
-        final short type = buffer.readUnsignedByte();
+        final Uint8 type = ByteBufUtils.readUint8(buffer);
         final OpaqueValueBuilder builder = new OpaqueValueBuilder();
-        switch (type) {
+        switch (type.toJava()) {
             case GENERIC_LSP_IDENTIFIER:
                 builder.setOpaque(buildOpaqueValue(buffer));
                 break;
@@ -94,7 +95,7 @@ public final class OpaqueUtil {
     }
 
     private static void buildExtended(final OpaqueValueBuilder builder, final ByteBuf buffer) {
-        final int extendedType = buffer.readUnsignedShort();
+        final Uint16 extendedType = ByteBufUtils.readUint16(buffer);
         final HexString opaqueValue = buildOpaqueValue(buffer);
         builder.setOpaqueExtendedType(extendedType).setOpaque(opaqueValue);
     }
index f448c10682e0476b15f3dc764d73d6cce72e1657..fbb89ed5840d79817f2d12bd303ec401ea714768 100644 (file)
@@ -13,6 +13,7 @@ import static org.opendaylight.protocol.bgp.mvpn.impl.attributes.tunnel.identifi
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.mvpn.spi.attributes.tunnel.identifier.AbstractTunnelIdentifier;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.PmsiTunnelType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
@@ -46,9 +47,9 @@ public final class RsvpTeP2MpLspParser extends AbstractTunnelIdentifier<RsvpTeP2
                 .pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLspBuilder rsvpTeP2mpLps
                 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi
                 .tunnel.pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLspBuilder();
-        rsvpTeP2mpLps.setP2mpId(buffer.readUnsignedInt());
-        buffer.skipBytes(2);
-        rsvpTeP2mpLps.setTunnelId(buffer.readUnsignedShort());
+        rsvpTeP2mpLps.setP2mpId(ByteBufUtils.readUint32(buffer));
+        buffer.skipBytes(RESERVED);
+        rsvpTeP2mpLps.setTunnelId(ByteBufUtils.readUint16(buffer));
         final int ipLength = buffer.readableBytes();
         rsvpTeP2mpLps.setExtendedTunnelId(parseIpAddress(ipLength, buffer));
         return new RsvpTeP2mpLspBuilder().setRsvpTeP2mpLsp(rsvpTeP2mpLps.build()).build();
index 4516f0e7541b03deea4662a19b4bf087f0f3d3a0..a9117885f51fd5d16efd548534de593dea3c761a 100644 (file)
@@ -5,13 +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.bgp.mvpn.impl.nlri;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.bgp.concepts.IpAddressUtil;
 import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.c.multicast.grouping.CMulticast;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.c.multicast.grouping.CMulticastBuilder;
@@ -29,7 +29,7 @@ final class CMulticastUtil {
     static CMulticast parseCMulticastGrouping(final ByteBuf buffer) {
         final CMulticastBuilder builder = new CMulticastBuilder();
         builder.setRouteDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(buffer));
-        builder.setSourceAs(new AsNumber(buffer.readUnsignedInt()));
+        builder.setSourceAs(new AsNumber(ByteBufUtils.readUint32(buffer)));
         builder.setMulticastSource(IpAddressUtil.addressForByteBuf(buffer));
         builder.setMulticastGroup(MulticastGroupOpaqueUtil.multicastGroupForByteBuf(buffer));
         return builder.build();
index 2e080c246e6d7cd76046c68ad310df30bad5b6a6..d56003d13cb60037eb62f034efc190092273dc46 100644 (file)
@@ -5,13 +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.bgp.mvpn.impl.nlri;
 
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.NlriType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.inter.as.i.pmsi.a.d.grouping.InterAsIPmsiAD;
@@ -40,7 +40,7 @@ public final class InterASIPmsiADHandler extends AbstractMvpnNlri<InterAsIPmsiAD
         return new InterAsIPmsiADCaseBuilder()
                 .setInterAsIPmsiAD(new InterAsIPmsiADBuilder()
                         .setRouteDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(buffer))
-                        .setSourceAs(new AsNumber(buffer.readUnsignedInt()))
+                        .setSourceAs(new AsNumber(ByteBufUtils.readUint32(buffer)))
                         .build())
                 .build();
     }
index e2bfadbe12c5681b15ee2a6c6d04f3d7c360c635..36d4e16ecd02a9ce92c42014cafd4548e0ec5db6 100644 (file)
@@ -21,6 +21,7 @@ import org.opendaylight.protocol.bgp.parser.spi.NlriParser;
 import org.opendaylight.protocol.bgp.parser.spi.NlriSerializer;
 import org.opendaylight.protocol.bgp.parser.spi.PathIdUtil;
 import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.Attributes1;
@@ -62,7 +63,7 @@ public final class RouteTargetConstrainNlriHandler implements NlriParser, NlriSe
             final ByteBuf nlriBuf = nlri.readSlice(length);
             Integer type = null;
             if (length != 0) {
-                builder.setOriginAs(new AsNumber(nlriBuf.readUnsignedInt()));
+                builder.setOriginAs(new AsNumber(ByteBufUtils.readUint32(nlriBuf)));
                 type = (int) nlriBuf.readUnsignedByte();
                 //Skip Subtype
                 nlriBuf.skipBytes(1);
index 814d90b5e5c16480f05031ba7aaf2e5b02a9eba5..5d6a9641824a71817f9b035171e2af6ac42686d1 100644 (file)
@@ -21,6 +21,7 @@ public interface RouteEntryBaseAttributes {
      *
      * @return RIB AS
      */
+    // FIXME: consider using Uint32 here
     long getLocalAs();
 
     /**
index 2979290268c5a96f84c613a0edf909ae84ea26e9..588d29a680685ee24eb90973d387cab102246f4d 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>concepts</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>yang-binding</artifactId>
index bedd20d49edb082cd2c056283282a376f38e693c..8a7b56c103b954bf6af8c5eab27b14f81c6b0eba 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameter
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.actions.bgp.actions.SetAsPathPrepend;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 /**
  * Prepend local AS, one time(n times not supported yet).
@@ -45,6 +46,6 @@ public final class AsPathPrepend extends AbstractPrependAsPath implements BgpAct
             final BGPRouteEntryExportParameters exportParameters,
             final Attributes attributes,
             final SetAsPathPrepend actions) {
-        return prependAS(attributes, new AsNumber(routeEntryInfo.getLocalAs()));
+        return prependAS(attributes, new AsNumber(Uint32.valueOf(routeEntryInfo.getLocalAs())));
     }
 }
\ No newline at end of file
index 5e92f7334e9b5df24719a3b6ac76ea33b2d319e2..985e40cfedd35465f0a6a578f8c8ff6b752fd0e8 100644 (file)
@@ -81,6 +81,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.open
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Sent;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.SentBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 /**
  * Util for create OpenConfig Neighbor with corresponding openConfig state.
@@ -356,7 +357,7 @@ public final class NeighborUtil {
                         .setReceived(neighbor.isGracefulRestartReceived(tablesKey))
                         .setLlAdvertised(neighbor.isLlGracefulRestartAdvertised(tablesKey))
                         .setLlReceived(neighbor.isLlGracefulRestartReceived(tablesKey))
-                        .setLlStaleTimer((long) neighbor.getLlGracefulRestartTimer(tablesKey)).build();
+                        .setLlStaleTimer(Uint32.valueOf(neighbor.getLlGracefulRestartTimer(tablesKey))).build();
         return new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi
                 .safi.list.afi.safi.GracefulRestartBuilder().setState(new org.opendaylight.yang.gen.v1.http.openconfig
                 .net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.graceful.restart.StateBuilder()
index e0991bcc886783d29a8057731b2e1df977d56d73..b8a7b174b9cb1a923ecab1cc7582b0f58d7dbe37 100644 (file)
@@ -44,7 +44,7 @@ public final class AsNumberUtil {
             }
         }
         // Fallback to whatever is in the header
-        return new AsNumber(open.getMyAsNumber().longValue());
+        return new AsNumber(Uint32.valueOf(open.getMyAsNumber()));
     }
 
     /**
index 0de8bddca3d7840b9fc87b3429198fae9b2b355d..0638df957b44f73e1ef9b9ebcdf828049c8cf790 100644 (file)
@@ -172,10 +172,12 @@ public enum BGPError {
         return e;
     }
 
+    // FIXME: Use Uint8 for this
     public short getCode() {
         return this.errorId.code;
     }
 
+    // FIXME: Use Uint8 for this
     public short getSubcode() {
         return this.errorId.subcode;
     }
@@ -189,6 +191,8 @@ public enum BGPError {
      */
     private static class BGPErrorIdentifier implements Serializable {
         private static final long serialVersionUID = 5722575354944165734L;
+
+        // FIXME: Use Uint8 for these
         final short code;
         final short subcode;
 
index 74400fd62e32faf31ef526091f7716de555d0d47..af07832c45885992151edd64196affdc9876f43f 100644 (file)
@@ -40,6 +40,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.OpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.BgpParameters;
 import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -186,7 +188,7 @@ public final class BGPOpenMessageParser implements MessageParser, MessageSeriali
             throw new BGPDocumentedException("BGP Protocol version " + version + " not supported.",
                     BGPError.VERSION_NOT_SUPPORTED);
         }
-        final AsNumber as = new AsNumber((long) body.readUnsignedShort());
+        final AsNumber as = new AsNumber(Uint32.valueOf(body.readUnsignedShort()));
         final int holdTime = body.readUnsignedShort();
         if (holdTime == 1 || holdTime == 2) {
             throw new BGPDocumentedException("Hold time value not acceptable.", BGPError.HOLD_TIME_NOT_ACC);
@@ -201,7 +203,7 @@ public final class BGPOpenMessageParser implements MessageParser, MessageSeriali
         final List<BgpParameters> optParams = parseParameters(body.slice(), optLength);
         LOG.debug("BGP Open message was parsed: AS = {}, holdTimer = {}, bgpId = {}, optParams = {}", as,
                 holdTime, bgpId, optParams);
-        return new OpenBuilder().setMyAsNumber(as.getValue().intValue()).setHoldTimer(holdTime)
+        return new OpenBuilder().setMyAsNumber(Uint16.valueOf(as.getValue())).setHoldTimer(holdTime)
                 .setBgpIdentifier(bgpId).setBgpParameters(optParams).build();
     }
 
index 0b02cb1f07b9f6e5ad1da8bf0ecac3d898d86974..6fe4e7668e05a5e5f24c72d9244cf538ba08a2f0 100644 (file)
@@ -12,6 +12,7 @@ import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.bgp.parser.spi.CapabilityParser;
 import org.opendaylight.protocol.bgp.parser.spi.CapabilitySerializer;
 import org.opendaylight.protocol.bgp.parser.spi.CapabilityUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.bgp.parameters.optional.capabilities.CParameters;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.bgp.parameters.optional.capabilities.CParametersBuilder;
@@ -24,7 +25,7 @@ public final class As4CapabilityHandler implements CapabilityParser, CapabilityS
     @Override
     public CParameters parseCapability(final ByteBuf buffer) {
         return new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder()
-            .setAsNumber(new AsNumber(buffer.readUnsignedInt())).build()).build();
+            .setAsNumber(new AsNumber(ByteBufUtils.readUint32(buffer))).build()).build();
     }
 
     @Override
index 5dfa4425ac7c6e5f41670a09a36ddf0c64b6c26f..11a991afe49b371c10dfdfad6133fff1daac7be6 100644 (file)
@@ -85,7 +85,7 @@ public final class LlGracefulCapabilityHandler implements CapabilityParser, Capa
                     .setAfi(afi)
                     .setSafi(safi)
                     .setAfiFlags(new Tables.AfiFlags(Boolean.valueOf(afiFlags == AFI_FLAG_FORWARDING_STATE)))
-                    .setLongLivedStaleTime(Long.valueOf(staleTime))
+                    .setLongLivedStaleTime(Uint32.valueOf(staleTime))
                     .build();
             tables.add(table);
         }
index 2e670fa4401e1c0b049e8739c6077f165fc29d54..728cf47419efe7267a347d3b5be5bbbf53bda3b9 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
 import org.opendaylight.protocol.bgp.parser.spi.AttributeUtil;
 import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
 import org.opendaylight.protocol.bgp.parser.spi.RevisedErrorHandling;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.ReferenceCache;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
@@ -52,7 +53,7 @@ public final class AggregatorAttributeParser extends AbstractAttributeParser imp
 
         builder.setAggregator(new AggregatorBuilder()
             // FIXME: above check should be expanded, so we report at least underflow errors
-            .setAsNumber(this.refCache.getSharedReference(new AsNumber(buffer.readUnsignedInt())))
+            .setAsNumber(this.refCache.getSharedReference(new AsNumber(ByteBufUtils.readUint32(buffer))))
             .setNetworkAddress(Ipv4Util.addressForByteBuf(buffer))
             .build());
     }
index bb2ee26fe43f81ba56abd7c58bd03fee72c557ab..e224e06782cc42cd21d269fca0dbe85476994208 100644 (file)
@@ -9,11 +9,11 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
-import java.math.BigInteger;
 import org.opendaylight.protocol.bgp.parser.spi.AttributeParser;
 import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
 import org.opendaylight.protocol.bgp.parser.spi.AttributeUtil;
 import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.Aigp;
@@ -64,7 +64,7 @@ public class AigpAttributeParser implements AttributeParser, AttributeSerializer
             LOG.warn("AIGP attribute contains unknown TLV type {}.", tlvType);
             return null;
         }
-        return new AigpTlvBuilder().setMetric(new AccumulatedIgpMetric(BigInteger.valueOf(buffer.readLong()))).build();
+        return new AigpTlvBuilder().setMetric(new AccumulatedIgpMetric(ByteBufUtils.readUint64(buffer))).build();
     }
 
     /**
index d613c48c4676216f707d4e06b70412aefb1cbaa8..4eb32ea4f78cd9a290f6c21fc820189cb8fae984 100644 (file)
@@ -14,6 +14,7 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableList.Builder;
 import io.netty.buffer.ByteBuf;
 import java.util.List;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ReferenceCache;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 
@@ -66,7 +67,7 @@ public final class AsPathSegmentParser {
 
         final Builder<AsNumber> coll = ImmutableList.builderWithExpectedSize(count);
         for (int i = 0; i < count; i++) {
-            coll.add(refCache.getSharedReference(new AsNumber(buffer.readUnsignedInt())));
+            coll.add(refCache.getSharedReference(new AsNumber(ByteBufUtils.readUint32(buffer))));
         }
         return coll.build();
     }
index e255c2fdf3b199046c588f2f263172dcd08007e5..d7b8c36c1566a9351bf480687925e1cd873d3ec1 100644 (file)
@@ -14,6 +14,8 @@ import org.opendaylight.protocol.util.ReferenceCache;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.CommunitiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Community;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 /**
  * Object representation of a RFC1997 Community tag. Communities are a way for the advertising entity to attach semantic
@@ -81,10 +83,12 @@ public final class CommunityUtil {
      * @param semantics int
      * @return new Community
      */
+    // FIXME: consider using Uint32 for asn
+    // FIXME: consider using Uint16 for semantics
     public static Community create(final ReferenceCache refCache, final long asn, final int semantics) {
         final CommunitiesBuilder builder = new CommunitiesBuilder();
-        builder.setAsNumber(refCache.getSharedReference(new AsNumber(asn)));
-        builder.setSemantics(refCache.getSharedReference(semantics));
+        builder.setAsNumber(refCache.getSharedReference(new AsNumber(Uint32.valueOf(asn))));
+        builder.setSemantics(refCache.getSharedReference(Uint16.valueOf(semantics)));
         return refCache.getSharedReference(builder.build());
     }
 
@@ -108,8 +112,8 @@ public final class CommunityUtil {
     public static Community valueOf(final ReferenceCache refCache, final String string) {
         final String[] parts = string.split(":", 2);
         final CommunitiesBuilder builder = new CommunitiesBuilder();
-        builder.setAsNumber(refCache.getSharedReference(new AsNumber(Long.valueOf(parts[0]))));
-        builder.setSemantics(refCache.getSharedReference(Integer.valueOf(parts[1])));
+        builder.setAsNumber(refCache.getSharedReference(new AsNumber(Uint32.valueOf(parts[0]))));
+        builder.setSemantics(refCache.getSharedReference(Uint16.valueOf(parts[1])));
         return refCache.getSharedReference(builder.build());
     }
 }
index cc1fd27d4226abc332ab616cf369ae51158b884b..44adabd4b6592552c0b72774e7633745410d5365 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
 import org.opendaylight.protocol.bgp.parser.spi.AttributeUtil;
 import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
 import org.opendaylight.protocol.bgp.parser.spi.RevisedErrorHandling;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.LocalPref;
@@ -45,7 +46,7 @@ public final class LocalPreferenceAttributeParser extends AbstractAttributeParse
             throw errorHandling.reportError(BGPError.ATTR_LENGTH_ERROR, "Expected 4 bytes, have %s", readable);
         }
 
-        builder.setLocalPref(new LocalPrefBuilder().setPref(buffer.readUnsignedInt()).build());
+        builder.setLocalPref(new LocalPrefBuilder().setPref(ByteBufUtils.readUint32(buffer)).build());
     }
 
     @Override
index 79412f27d5bf671aa4717514c209ca36194539e2..e16ef84891e38c209c4cd4068f56d404eb9289b0 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
 import org.opendaylight.protocol.bgp.parser.spi.AttributeUtil;
 import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint;
 import org.opendaylight.protocol.bgp.parser.spi.RevisedErrorHandling;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.MultiExitDisc;
@@ -36,7 +37,7 @@ public final class MultiExitDiscriminatorAttributeParser extends AbstractAttribu
             throw errorHandling.reportError(BGPError.ATTR_LENGTH_ERROR,
                 "MULTI_EXIT_DISC has to have length 4, but has %s", readable);
         }
-        builder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(buffer.readUnsignedInt()).build());
+        builder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(ByteBufUtils.readUint32(buffer)).build());
     }
 
     @Override
index a6cda3af3a2aafec350423a514963d4ddc34f960..7516a67755521b218c3b5586d240258f0f2d4eb6 100644 (file)
@@ -13,6 +13,7 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractIpv4ExtendedCommunity;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
@@ -39,7 +40,7 @@ public final class RouteOriginIpv4EcHandler extends AbstractIpv4ExtendedCommunit
             throws BGPDocumentedException, BGPParsingException {
         final RouteOriginIpv4 routeTarget = new RouteOriginIpv4Builder()
             .setGlobalAdministrator(Ipv4Util.addressForByteBuf(buffer))
-            .setLocalAdministrator(buffer.readUnsignedShort())
+            .setLocalAdministrator(ByteBufUtils.readUint16(buffer))
             .build();
         return new RouteOriginIpv4CaseBuilder().setRouteOriginIpv4(routeTarget).build();
     }
index a6ff8343c2b825a91b73dec844ff81f81565006b..5dea91f7a934a87b0fa221c6afa8781ae236d3aa 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.commun
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.bgp.parser.spi.extended.community.Abstract4OctetAsExtendedCommunity;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
@@ -26,7 +27,7 @@ public final class SourceAS4OctectHandler extends Abstract4OctetAsExtendedCommun
     @Override
     public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) {
         final SourceAs4ExtendedCommunityBuilder builder = new SourceAs4ExtendedCommunityBuilder();
-        builder.setGlobalAdministrator(new AsNumber(body.readUnsignedInt()));
+        builder.setGlobalAdministrator(new AsNumber(ByteBufUtils.readUint32(body)));
         body.skipBytes(LOCAL_LENGTH);
         return new SourceAs4ExtendedCommunityCaseBuilder().setSourceAs4ExtendedCommunity(
                 builder.build()).build();
index 90d99f882283cf60a34c73696db8509f7179387a..af996e700b7031e75fa90feee3375c449d46f0e2 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities.route.target;
 
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4;
@@ -32,7 +33,7 @@ public final class RouteTargetIpv4Handler {
     public static RouteTargetIpv4 parse(final ByteBuf buffer) {
         return new RouteTargetIpv4Builder()
                 .setGlobalAdministrator(Ipv4Util.addressForByteBuf(buffer))
-                .setLocalAdministrator(buffer.readUnsignedShort())
+                .setLocalAdministrator(ByteBufUtils.readUint16(buffer))
                 .build();
     }
 }
index 3aa19010644c4e053eb7bc4a0e6212c8ed4a0a75..081226d3fe5b82c9759904ffdeb3cb8990790709 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.protocol.bgp.parser.spi;
 import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import java.util.Optional;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
 import org.opendaylight.yangtools.util.ImmutableOffsetMapTemplate;
@@ -56,7 +57,7 @@ public final class PathIdUtil {
      */
     public static PathId readPathId(final ByteBuf buffer) {
         Preconditions.checkArgument(buffer != null && buffer.isReadable(ByteBufWriteUtil.INT_BYTES_LENGTH));
-        return new PathId(buffer.readUnsignedInt());
+        return new PathId(ByteBufUtils.readUint32(buffer));
     }
 
     /**
index 2bb3ab1af942eeaaca4ed8d0c036c6ca2a800281..f84c2370c3fb8e3de8ee8ad553e7d87a84d802e5 100644 (file)
@@ -5,10 +5,10 @@
  * 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.bgp.parser.spi.extended.community;
 
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.as._4.spec.common.As4SpecificCommon;
@@ -20,8 +20,8 @@ public final class FourOctAsCommonECUtil {
     }
 
     public static As4SpecificCommon parseCommon(final ByteBuf body) {
-        return new As4SpecificCommonBuilder().setAsNumber(new AsNumber(body.readUnsignedInt()))
-            .setLocalAdministrator(body.readUnsignedShort()).build();
+        return new As4SpecificCommonBuilder().setAsNumber(new AsNumber(ByteBufUtils.readUint32(body)))
+            .setLocalAdministrator(ByteBufUtils.readUint16(body)).build();
     }
 
     public static void serializeCommon(final As4SpecificCommon extComm, final ByteBuf body) {
index 2072fdb3e6555e2b34bb149a144da185e2e684bc..d4ea18d9fbdc3e5f7e754589552ea08737c39ceb 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.yangtools.concepts.AbstractRegistration;
 import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -126,11 +127,13 @@ final class SimpleAttributeRegistry implements AttributeRegistry {
             throw new BGPDocumentedException("Well known attribute not recognized.",
                 BGPError.WELL_KNOWN_ATTR_NOT_RECOGNIZED);
         }
+
+        final Uint8 typeVal = Uint8.valueOf(type);
         final UnrecognizedAttributes unrecognizedAttribute = new UnrecognizedAttributesBuilder()
-            .withKey(new UnrecognizedAttributesKey((short) type))
+            .withKey(new UnrecognizedAttributesKey(typeVal))
             .setPartial(flags.get(PARTIAL_BIT))
             .setTransitive(flags.get(TRANSITIVE_BIT))
-            .setType((short) type)
+            .setType(typeVal)
             .setValue(ByteArray.readBytes(buffer, len)).build();
         this.unrecognizedAttributes.add(unrecognizedAttribute);
         LOG.debug("Unrecognized attribute were parsed: {}", unrecognizedAttribute);
index ca46a6406c624fc523f7435c627323f1755bf2c1..a9ab4f49f5c37c0a1edba047ea9c4bcb0433b628 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mess
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Open;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.OpenBuilder;
 import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.common.Uint16;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,7 +50,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter
 
     // <a href="http://tools.ietf.org/html/rfc6793">BGP Support for 4-Octet AS Number Space</a>
     @VisibleForTesting
-    static final int AS_TRANS = 23456;
+    static final Uint16 AS_TRANS = Uint16.valueOf(23456).intern();
     private static final Logger LOG = LoggerFactory.getLogger(AbstractBGPSessionNegotiator.class);
     private final BGPPeerRegistry registry;
     private final Promise<BGPSessionImpl> promise;
@@ -107,7 +108,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter
             }
 
             final BGPSessionPreferences preferences = this.registry.getPeerPreferences(remoteIp);
-            final int as = openASNumber(preferences.getMyAs().getValue().longValue());
+            final Uint16 as = openASNumber(preferences.getMyAs().getValue().longValue());
             sendMessage(new OpenBuilder().setMyAsNumber(as).setHoldTimer(preferences.getHoldTime()).setBgpIdentifier(
                     preferences.getBgpId()).setBgpParameters(preferences.getParams()).build());
             if (this.state != State.FINISHED) {
@@ -306,8 +307,8 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter
     }
 
     @VisibleForTesting
-    static int openASNumber(final long configuredASNumber) {
+    static Uint16 openASNumber(final long configuredASNumber) {
         // Return AS_TRANS if the value is bigger than 2B.
-        return configuredASNumber > Values.UNSIGNED_SHORT_MAX_VALUE ? AS_TRANS : (int) configuredASNumber;
+        return configuredASNumber > Values.UNSIGNED_SHORT_MAX_VALUE ? AS_TRANS : Uint16.valueOf(configuredASNumber);
     }
 }
index a0c78d65fd5d0cacb3b6af010622ca9bd33fec8b..6cca2b2ae7edd7bb4805f8b5311b11aa9df39d4f 100644 (file)
@@ -77,7 +77,7 @@ public final class GracefulRestartUtil {
                         .setAfi(dto.getTableKey().getAfi())
                         .setSafi(dto.getTableKey().getSafi())
                         .setAfiFlags(new AfiFlags(dto.isForwarding()))
-                        .setLongLivedStaleTime((long) dto.getStaleTime())
+                        .setLongLivedStaleTime(Uint32.valueOf(dto.getStaleTime()))
                         .build())
                 .collect(Collectors.toList());
         return new CParametersBuilder().addAugmentation(CParameters1.class,
index 693f331ebd4b138f166084e5707a16f00e0eabb1..412402d2d0b9e1ba1a4090c358e46c4f2fc070a6 100644 (file)
@@ -12,12 +12,13 @@ import static org.opendaylight.protocol.bgp.rib.impl.AbstractBGPSessionNegotiato
 import static org.opendaylight.protocol.bgp.rib.impl.AbstractBGPSessionNegotiator.openASNumber;
 
 import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 public class AbstractBGPSessionNegotiatorTest {
     @Test
     public void testOpenASNumber() {
-        assertEquals(0, openASNumber(0));
-        assertEquals(65535, openASNumber(65535));
+        assertEquals(Uint16.ZERO, openASNumber(0));
+        assertEquals(Uint16.MAX_VALUE, openASNumber(65535));
         assertEquals(AS_TRANS, openASNumber(65536));
         assertEquals(AS_TRANS, openASNumber(Integer.MAX_VALUE));
         assertEquals(AS_TRANS, openASNumber(2147483648L));
index 96c25f895a8b76a2ceb3f1774279c7e1d159ce30..be82db7ed7e1374dff7d651cece29a60fcd9d708 100644 (file)
@@ -67,6 +67,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv6NextHopCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv6.next.hop._case.Ipv6NextHopBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 final class PeerUtil {
 
@@ -114,12 +115,13 @@ final class PeerUtil {
 
     static Update createUpdate(final BgpOrigin bgpOrigin,
                                final List<Segments> pathSegments,
+                               // FIXME: consider using Uint32
                                final long preference,
                                final MpReachNlri mpReach,
                                final MpUnreachNlri mpUnreach) {
         final Origin origin = new OriginBuilder().setValue(bgpOrigin).build();
         final AsPath asPath = new AsPathBuilder().setSegments(pathSegments).build();
-        final LocalPref localPref = new LocalPrefBuilder().setPref(preference).build();
+        final LocalPref localPref = new LocalPrefBuilder().setPref(Uint32.valueOf(preference)).build();
         final AttributesBuilder attributeBuilder = new AttributesBuilder()
                 .setOrigin(origin).setAsPath(asPath).setLocalPref(localPref);
 
index d611163e3a740e157767158e03f8667da16f72c2..b77672da0af6ad91648f73f0d395640c83151678 100644 (file)
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>concepts</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>yang-binding</artifactId>
index 604e0286fffc84673598ba18f9c2bb5e6c0402f5..b9b219653ce78d5fa12b7370958854f0875ab655 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mult
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamilies;
 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -112,7 +113,7 @@ final class EventBusRegistration extends AbstractListenerRegistration<BGPSession
     }
 
     private static class MockBGPSession implements BGPSession {
-        private static final long AS = 30L;
+        private static final Uint32 AS = Uint32.valueOf(30).intern();
 
         private final List<AddressFamilies> addPathAfis;
         private final Set<BgpTableType> tts;
index d07b6cb86d275234aaea29a0bf7968f8ac7072c4..7d7fc07ab9dc082e90d20892bbcbe5c00bf1d98d 100644 (file)
             <groupId>${project.groupId}</groupId>
             <artifactId>testtool-util</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>yang-binding</artifactId>
index 040e3abd920125298ae3283d405c0de9a784494e..19afd9bfdc6f676e8943dcc93ba5cb57906e31b1 100644 (file)
@@ -25,6 +25,7 @@ import net.sourceforge.argparse4j.inf.Namespace;
 import org.opendaylight.protocol.util.ArgumentsInput;
 import org.opendaylight.protocol.util.InetSocketAddressUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 final class Arguments implements ArgumentsInput {
     private static final String PROGRAM_NAME = "BGP testing tool.";
@@ -67,7 +68,9 @@ final class Arguments implements ArgumentsInput {
     }
 
     private interface ArgumentTypeTool<T> extends ArgumentType<T> {
-        default T convert(ArgumentParser var1, Argument var2, String input) throws ArgumentParserException {
+        @Override
+        default T convert(final ArgumentParser var1, final Argument var2, final String input)
+                throws ArgumentParserException {
             return convert(input);
         }
 
@@ -97,8 +100,8 @@ final class Arguments implements ArgumentsInput {
         parser.addArgument("-mp", toArgName(MULTIPATH_PARAMETER)).type(Boolean.class)
                 .setDefault(false).help(MULTIPATH_PARAMETER_HELP);
         parser.addArgument("-" + AS_PARAMETER, toArgName(AS_PARAMETER))
-                .type((ArgumentTypeTool<AsNumber>) as -> new AsNumber(Long.valueOf(as)))
-                .setDefault(new AsNumber(64496L)).help(AS_PARAMETER_HELP);
+                .type((ArgumentTypeTool<AsNumber>) as -> new AsNumber(Uint32.valueOf(as)))
+                .setDefault(new AsNumber(Uint32.valueOf(64496))).help(AS_PARAMETER_HELP);
         parser.addArgument("-ec", toArgName(EXTENDED_COMMUNITIES_PARAMETER))
                 .type((ArgumentTypeTool<List<String>>) extComInput ->
                         Arrays.asList(extComInput.split(","))).setDefault(Collections.emptyList())
index 3d7b94b6f64efa59a007f7a036d62164b6ed4266..b04145cadbe9086344bf8538d8aa8e612d4a8fd0 100644 (file)
@@ -5,12 +5,10 @@
  * 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.bgp.testtool;
 
 import java.util.ArrayList;
 import java.util.List;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.ExtendedCommunities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.ExtendedCommunitiesBuilder;
@@ -42,17 +40,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.route.target.ipv4.grouping.RouteTargetIpv4Builder;
 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.network.concepts.rev131125.Bandwidth;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 final class CommunitiesBuilder {
     private static final Logger LOG = LoggerFactory.getLogger(CommunitiesBuilder.class);
+    private static final ShortAsNumber SHORT_AS = new ShortAsNumber(Uint32.valueOf(20));
     private static final As4SpecificCommon AS_4_COMMON = new As4SpecificCommonBuilder()
-            .setAsNumber(new AsNumber(20L)).setLocalAdministrator(100).build();
+            .setAsNumber(SHORT_AS).setLocalAdministrator(Uint16.valueOf(100)).build();
     private static final Ipv4Address IPV4 = new Ipv4Address("192.168.1.0");
     private static final byte[] BYTE = new byte[]{(byte) 0x4f, (byte) 0x70, (byte) 0x00, (byte) 0x00};
-    private static final int LA = 4660;
-    private static final ShortAsNumber SHORT_AS = new ShortAsNumber(20L);
+    private static final Uint16 LA = Uint16.valueOf(4660).intern();
 
     private CommunitiesBuilder() {
         throw new UnsupportedOperationException();
index 89bba6014fa33ef3d1338b1a5e6a83b38878e498..1fb51c7bd8b43b999412387d321d6f961361d51b 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.Ipv4NextHopCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 final class PrefixesBuilder {
     private static final Ipv4NextHopCase NEXT_HOP;
@@ -73,14 +74,14 @@ final class PrefixesBuilder {
         final AttributesBuilder attBuilder = new AttributesBuilder();
         attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Egp).build());
         attBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
-        attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed((long) 0).build());
-        attBuilder.setLocalPref(new LocalPrefBuilder().setPref(100L).build());
+        attBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed(Uint32.ZERO).build());
+        attBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(100L)).build());
         attBuilder.setExtendedCommunities(createExtComm(extCom));
         attBuilder.setUnrecognizedAttributes(Collections.emptyList());
 
         final Ipv4PrefixesBuilder prefixes = new Ipv4PrefixesBuilder().setPrefix(addressPrefix);
         if (multiPathSupport) {
-            prefixes.setPathId(new PathId(5L));
+            prefixes.setPathId(new PathId(Uint32.valueOf(5)));
         }
         attBuilder.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(
                 new MpReachNlriBuilder().setCNextHop(NEXT_HOP).setAfi(Ipv4AddressFamily.class)
index 99f6cd65015f99aa236fb429fbfe9106abfbf56c..9676a1cda9e8d11a30d9dcda5d792499b1ded101 100644 (file)
@@ -258,7 +258,7 @@ public final class ProtocolUtil {
         final OspfLinkAttributesBuilder ilab = new OspfLinkAttributesBuilder();
         ilab.setTed(tb.build());
         if (topologyIdentifier != null) {
-            ilab.setMultiTopologyId(topologyIdentifier.getValue().shortValue());
+            ilab.setMultiTopologyId(Uint8.valueOf(topologyIdentifier.getValue()));
         }
 
         return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021
@@ -301,7 +301,7 @@ public final class ProtocolUtil {
         final IsisLinkAttributesBuilder ilab = new IsisLinkAttributesBuilder();
         ilab.setTed(tb.build());
         if (topologyIdentifier != null) {
-            ilab.setMultiTopologyId(topologyIdentifier.getValue().shortValue());
+            ilab.setMultiTopologyId(Uint8.valueOf(topologyIdentifier.getValue()));
         }
 
         return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021
index a2b9970325085735786e2353756a72bc2eca3ddf..e1f96f26863ce166991301367c9b4fa18f4e4a0e 100644 (file)
@@ -43,8 +43,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.InstanceIdentifierBuilder;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.slf4j.Logger;
@@ -136,10 +134,8 @@ final class BmpRibInWriter {
                 LOG.warn("No support for table type {}, skipping it", k);
                 continue;
             }
-            final InstanceIdentifierBuilder idb = YangInstanceIdentifier.builder(yangTableRootIId);
-            final NodeIdentifierWithPredicates key = TablesUtil.toYangTablesKey(k);
-            idb.nodeWithKey(key.getNodeType(), key.asMap());
-            final TableContext ctx = new TableContext(rs, idb.build(), tree);
+            final TableContext ctx = new TableContext(rs,
+                yangTableRootIId.node(TablesUtil.toYangTablesKey(k)).toOptimized(), tree);
             ctx.createTable(tx);
 
             tx.put(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(BMP_ATTRIBUTES_QNAME)
index e61653835677d25a27b1e07eee991ff9e61559f6..52ca59687f3a0a5e3f1b0404d75abd439ae3aa43 100755 (executable)
@@ -5,7 +5,6 @@
  * 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.bmp.mock;
 
 import java.net.InetAddress;
@@ -44,16 +43,19 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.mess
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.peer.up.SentOpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.route.monitoring.message.Update;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.route.monitoring.message.UpdateBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 final class BmpMockUtil {
 
     private static final String DESCRIPTION = "OpenDaylight";
     private static final String NAME = "BMP mock";
     private static final int HOLD_TIMER = 180;
-    private static final AsNumber ASN = new AsNumber(65431L);
+    private static final AsNumber ASN = new AsNumber(Uint32.valueOf(65431));
     private static final Ipv4Address NEXT_HOP = new Ipv4Address("1.2.3.4");
-    private static final PortNumber PEER_PORT = new PortNumber(179);
-    private static final ProtocolVersion PROTOCOL_VERSION = new ProtocolVersion((short) 4);
+    private static final PortNumber PEER_PORT = new PortNumber(Uint16.valueOf(179).intern());
+    private static final ProtocolVersion PROTOCOL_VERSION = new ProtocolVersion(Uint8.valueOf(4));
     private static final Origin ORIGIN = new OriginBuilder().setValue(BgpOrigin.Igp).build();
     private static final AsPath AS_PATH = new AsPathBuilder().setSegments(Collections.emptyList()).build();
 
@@ -86,7 +88,7 @@ final class BmpMockUtil {
         final OpenBuilder msgBuilder = new OpenBuilder();
         msgBuilder.setBgpIdentifier(address);
         msgBuilder.setHoldTimer(HOLD_TIMER);
-        msgBuilder.setMyAsNumber(ASN.getValue().intValue());
+        msgBuilder.setMyAsNumber(Uint16.valueOf(ASN.getValue()));
         msgBuilder.setVersion(PROTOCOL_VERSION);
         return msgBuilder.build();
     }
index e322319e1e1c513baba33858645095b6e37fd8ef..dce1470de02ed019d94445706e2dd38f2bc8b25b 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
 import org.opendaylight.protocol.bmp.spi.parser.AbstractBmpPerPeerMessageParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.NotifyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.NotifyMessage;
@@ -86,20 +87,20 @@ public class PeerDownHandler extends AbstractBmpPerPeerMessageParser<PeerDownNot
         if (reason != null) {
             switch (reason) {
                 case REASON_ONE:
-                    peerDown.setLocalSystemClosed(true);
+                    peerDown.setLocalSystemClosed(Boolean.TRUE);
                     peerDown.setData(parseBgpNotificationMessage(bytes));
                     break;
                 case REASON_TWO:
-                    peerDown.setLocalSystemClosed(true);
-                    peerDown.setData(new FsmEventCodeBuilder().setFsmEventCode(bytes.readUnsignedShort()).build());
+                    peerDown.setLocalSystemClosed(Boolean.TRUE);
+                    peerDown.setData(new FsmEventCodeBuilder().setFsmEventCode(ByteBufUtils.readUint16(bytes)).build());
                     break;
                 case REASON_THREE:
                 case REASON_FOUR:
-                    peerDown.setLocalSystemClosed(false);
+                    peerDown.setLocalSystemClosed(Boolean.FALSE);
                     peerDown.setData(parseBgpNotificationMessage(bytes));
                     break;
                 case REASON_FIVE:
-                    peerDown.setLocalSystemClosed(false);
+                    peerDown.setLocalSystemClosed(Boolean.FALSE);
                     break;
                 default:
                     break;
index c0679ad28b51dcc389a4ea568dee892d8aa3ca1b..5bb1a61037b5d99c2cef6c1fa0cbb97c177ba897 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
 import org.opendaylight.protocol.bmp.spi.parser.AbstractBmpPerPeerMessageParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvRegistry;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.Ipv6Util;
@@ -92,8 +93,8 @@ public class PeerUpHandler extends AbstractBmpPerPeerMessageParser<InformationBu
         } else {
             peerUpNot.setLocalAddress(new IpAddress(Ipv6Util.addressForByteBuf(bytes)));
         }
-        peerUpNot.setLocalPort(new PortNumber(bytes.readUnsignedShort()));
-        peerUpNot.setRemotePort(new PortNumber(bytes.readUnsignedShort()));
+        peerUpNot.setLocalPort(new PortNumber(ByteBufUtils.readUint16(bytes)));
+        peerUpNot.setRemotePort(new PortNumber(ByteBufUtils.readUint16(bytes)));
         try {
             final Notification opSent = this.msgRegistry
                     .parseMessage(bytes.readSlice(getBgpMessageLength(bytes)), null);
index 6e7510a5d1fda120bd85f25d8c0ec5a458a30c5d..e1908f7f0f245e9687cc56fda8a7f23298978ddd 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.tlvs.RejectedPrefixesTlv;
@@ -34,7 +35,7 @@ public class StatType000TlvHandler implements BmpTlvParser, BmpTlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new RejectedPrefixesTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();
+        return new RejectedPrefixesTlvBuilder().setCount(new Counter32(ByteBufUtils.readUint32(buffer))).build();
     }
 
 }
index 3ce23c793a81c192f925cc9f5f04fcffe69a3c93..ac4629fb8b4479e16b670e0ecf35980a44de4500 100644 (file)
@@ -5,7 +5,6 @@
  * 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.bmp.parser.tlv;
 
 import com.google.common.base.Preconditions;
@@ -14,6 +13,7 @@ import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.tlvs.DuplicatePrefixAdvertisementsTlv;
@@ -35,7 +35,9 @@ public class StatType001TlvHandler implements BmpTlvParser, BmpTlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new DuplicatePrefixAdvertisementsTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();
+        return new DuplicatePrefixAdvertisementsTlvBuilder()
+                .setCount(new Counter32(ByteBufUtils.readUint32(buffer)))
+                .build();
     }
 
 }
index e695b2aebe05619f1dda1872a8f80b353f1fdd49..3fd882ab389d51a55fb8790d10dfd487734dc575 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.tlvs.DuplicateWithdrawsTlv;
@@ -34,7 +35,7 @@ public class StatType002TlvHandler implements BmpTlvParser, BmpTlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new DuplicateWithdrawsTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();
+        return new DuplicateWithdrawsTlvBuilder().setCount(new Counter32(ByteBufUtils.readUint32(buffer))).build();
     }
 
 }
index 84f2d0909bea2f2a4cfb28ac05d283567d7d252a..4b89ca5e0bc38711f447f32ea21c57f4d23dba35 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.tlvs.InvalidatedClusterListLoopTlv;
@@ -35,7 +36,9 @@ public class StatType003TlvHandler implements BmpTlvParser, BmpTlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new InvalidatedClusterListLoopTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();
+        return new InvalidatedClusterListLoopTlvBuilder()
+                .setCount(new Counter32(ByteBufUtils.readUint32(buffer)))
+                .build();
     }
 
 }
index 6d024311ba25c7af09d1a9194bea71565b3381bb..860c4df5a68264eeb7d25cfbb6a9535c3a226fca 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.tlvs.InvalidatedAsPathLoopTlv;
@@ -34,6 +35,6 @@ public class StatType004TlvHandler implements BmpTlvParser, BmpTlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new InvalidatedAsPathLoopTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();
+        return new InvalidatedAsPathLoopTlvBuilder().setCount(new Counter32(ByteBufUtils.readUint32(buffer))).build();
     }
 }
index a37430f7e5367ad893402412d99761c3b8149c0c..c7a55cf5d689a6337a5e3fb6d7723df9d1b026ad 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.tlvs.InvalidatedOriginatorIdTlv;
@@ -35,7 +36,7 @@ public class StatType005TlvHandler implements BmpTlvParser, BmpTlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new InvalidatedOriginatorIdTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();
+        return new InvalidatedOriginatorIdTlvBuilder().setCount(new Counter32(ByteBufUtils.readUint32(buffer))).build();
     }
 
 }
index 281451014766d11d766150e04bb3a54532d169a5..1f1586e0035e619ca0e1cee40f247a9e83c1abec 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.tlvs.InvalidatedAsConfedLoopTlv;
@@ -35,7 +36,7 @@ public class StatType006TlvHandler implements BmpTlvParser, BmpTlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new InvalidatedAsConfedLoopTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();
+        return new InvalidatedAsConfedLoopTlvBuilder().setCount(new Counter32(ByteBufUtils.readUint32(buffer))).build();
     }
 
 }
index 03deb84ba76d8e00802add6bc27b041092c5edd1..640e6eae20259aec4d5fe011a07840a0f329212b 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.tlvs.UpdatesTreatedAsWithdrawTlv;
@@ -35,6 +36,8 @@ public class StatType011TlvHandler implements BmpTlvParser, BmpTlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new UpdatesTreatedAsWithdrawTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();
+        return new UpdatesTreatedAsWithdrawTlvBuilder()
+                .setCount(new Counter32(ByteBufUtils.readUint32(buffer)))
+                .build();
     }
 }
index 338829b310de9af5a49335118f78cc3f28f656fc..b882299e1f8f932ed52b61b487501798f2d274a3 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.tlvs.PrefixesTreatedAsWithdrawTlv;
@@ -35,6 +36,8 @@ public class StatType012TlvHandler implements BmpTlvParser, BmpTlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new PrefixesTreatedAsWithdrawTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();
+        return new PrefixesTreatedAsWithdrawTlvBuilder()
+                .setCount(new Counter32(ByteBufUtils.readUint32(buffer)))
+                .build();
     }
 }
index b5fcaa92d13fa35995eab04ce9a023eef1cd30e3..faec3b1c4c38897fa2e0186f718eb9177fb36452 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
 import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
 import org.opendaylight.protocol.bmp.spi.parser.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev180329.stat.tlvs.DuplicateUpdatesTlv;
@@ -34,6 +35,6 @@ public class StatType013TlvHandler implements BmpTlvParser, BmpTlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new DuplicateUpdatesTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build();
+        return new DuplicateUpdatesTlvBuilder().setCount(new Counter32(ByteBufUtils.readUint32(buffer))).build();
     }
 }
index 3ee69f33bc045b6f68b808b1f8e3c09237a8f3ff..ba6593a6c48bd6eee341725efbdd7334f487677f 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
 import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.Ipv6Util;
@@ -89,10 +90,10 @@ public abstract class AbstractBmpPerPeerMessageParser<T extends Builder<?>> exte
         } else {
             phBuilder.setAddress(new IpAddress(Ipv6Util.addressForByteBuf(bytes)));
         }
-        phBuilder.setAs(new AsNumber(bytes.readUnsignedInt()));
+        phBuilder.setAs(new AsNumber(ByteBufUtils.readUint32(bytes)));
         phBuilder.setBgpId(Ipv4Util.addressForByteBuf(bytes));
-        phBuilder.setTimestampSec(new Timestamp(bytes.readUnsignedInt()));
-        phBuilder.setTimestampMicro(new Timestamp(bytes.readUnsignedInt()));
+        phBuilder.setTimestampSec(new Timestamp(ByteBufUtils.readUint32(bytes)));
+        phBuilder.setTimestampMicro(new Timestamp(ByteBufUtils.readUint32(bytes)));
         return phBuilder.build();
     }
 
index 0fe99669d07d0e8d22b30de27716b8dbd07b9e79..a2535d0f1a719244c19102ea3b62c9c37bd52bd2 100644 (file)
@@ -34,6 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -88,7 +89,7 @@ final class TopologyDataChangeCounter implements ClusteredDataTreeChangeListener
 
     private void putCount(final long totalCount) {
         final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
-        final Counter counter = new CounterBuilder().setId(this.counterId).setCount(totalCount).build();
+        final Counter counter = new CounterBuilder().setId(this.counterId).setCount(Uint32.valueOf(totalCount)).build();
         wTx.put(LogicalDatastoreType.OPERATIONAL, this.counterInstanceId, counter);
         wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
             @Override
index 11d7f9d6e0f96289f207ab056487f4dd17ca57ce..9348146a004ba31652326d331ae01a877cb907be 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.protocol.pcep.parser.object;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
@@ -55,14 +55,14 @@ public final class PCEPClassTypeObjectParser extends CommonObjectParser implemen
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
-        Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (!header.isProcessingRule()) {
             LOG.debug("Processed bit not set on CLASS TYPE OBJECT, ignoring it");
             return null;
         }
         if (bytes.readableBytes() != SIZE) {
-            throw new PCEPDeserializerException("Size of byte array doesn't match defined size. Expected: " + SIZE + "; Passed: "
-                    + bytes.readableBytes());
+            throw new PCEPDeserializerException("Size of byte array doesn't match defined size. Expected: " + SIZE
+                + "; Passed: " + bytes.readableBytes());
         }
         final ClassTypeBuilder builder = new ClassTypeBuilder();
         builder.setIgnore(header.isIgnore());
@@ -81,11 +81,12 @@ public final class PCEPClassTypeObjectParser extends CommonObjectParser implemen
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof ClassType, "Wrong instance of PCEPObject. Passed %s. Needed ClassTypeObject.", object.getClass());
+        checkArgument(object instanceof ClassType, "Wrong instance of PCEPObject. Passed %s. Needed ClassTypeObject.",
+            object.getClass());
         final ByteBuf body = Unpooled.buffer(SIZE);
         body.writeZero(SIZE - 1);
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType classType = ((ClassType) object).getClassType();
-        Preconditions.checkArgument(classType != null, "ClassType is mandatory.");
+        checkArgument(classType != null, "ClassType is mandatory.");
         writeUnsignedByte(classType.getValue(), body);
         ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
     }
index fa8c3587ebdae10904dd090fccbf730b2c7116e2..91b20afd0b6a0755994258b8a0c7bc3473f8d5b3 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.protocol.pcep.parser.object;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.List;
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CClose;
@@ -47,12 +48,13 @@ public final class PCEPCloseObjectParser extends AbstractObjectWithTlvsParser<Tl
 
     @Override
     public CClose parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
-        Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(bytes != null && bytes.isReadable(),
+                "Array of bytes is mandatory. Cannot be null or empty.");
         final CCloseBuilder builder = new CCloseBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
         bytes.skipBytes(FLAGS_F_LENGTH + RESERVED);
-        builder.setReason(bytes.readUnsignedByte());
+        builder.setReason(ByteBufUtils.readUint8(bytes));
         final TlvsBuilder tlvsBuilder = new TlvsBuilder();
         parseTlvs(tlvsBuilder, bytes.slice());
         builder.setTlvs(tlvsBuilder.build());
@@ -61,11 +63,12 @@ public final class PCEPCloseObjectParser extends AbstractObjectWithTlvsParser<Tl
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof CClose, "Wrong instance of PCEPObject. Passed %s. Needed CCloseObject.", object.getClass());
+        checkArgument(object instanceof CClose, "Wrong instance of PCEPObject. Passed %s. Needed CCloseObject.",
+            object.getClass());
         final CClose obj = (CClose) object;
         final ByteBuf body = Unpooled.buffer();
         body.writeZero(RESERVED + FLAGS_F_LENGTH);
-        Preconditions.checkArgument(obj.getReason() != null, "Reason is mandatory.");
+        checkArgument(obj.getReason() != null, "Reason is mandatory.");
         writeUnsignedByte(obj.getReason(), body);
         serializeTlvs(obj.getTlvs(), body);
         ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
@@ -80,7 +83,7 @@ public final class PCEPCloseObjectParser extends AbstractObjectWithTlvsParser<Tl
 
 
     @Override
-    protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+    protected void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
         if (!tlvs.isEmpty()) {
             builder.setVendorInformationTlv(tlvs);
         }
index f59cf94e86792205ca053d845271e536aae8efb5..bd08548581598aa4c4268047ed8706fc3da09a7a 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
@@ -51,8 +52,8 @@ public final class PCEPErrorObjectParser extends AbstractObjectWithTlvsParser<Er
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
         bytes.skipBytes(FLAGS_F_LENGTH + RESERVED);
-        builder.setType(bytes.readUnsignedByte());
-        builder.setValue(bytes.readUnsignedByte());
+        builder.setType(ByteBufUtils.readUint8(bytes));
+        builder.setValue(ByteBufUtils.readUint8(bytes));
         parseTlvs(builder, bytes.slice());
         return builder.build();
     }
index 9561124f0f74fc166ef4a3a92d6b55bc6f710dd7..6bb425ef7577f5e8a3319c0df504aae951bc819b 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.protocol.pcep.parser.object;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.List;
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.gc.object.Gc;
@@ -40,17 +41,16 @@ public class PCEPGlobalConstraintsObjectParser extends AbstractObjectWithTlvsPar
 
     @Override
     public Gc parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
-        Preconditions.checkArgument(bytes != null && bytes.isReadable(),
-            "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         final GcBuilder builder = new GcBuilder();
 
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
 
-        builder.setMaxHop(bytes.readUnsignedByte());
-        builder.setMaxUtilization(bytes.readUnsignedByte());
-        builder.setMinUtilization(bytes.readUnsignedByte());
-        builder.setOverBookingFactor(bytes.readUnsignedByte());
+        builder.setMaxHop(ByteBufUtils.readUint8(bytes));
+        builder.setMaxUtilization(ByteBufUtils.readUint8(bytes));
+        builder.setMinUtilization(ByteBufUtils.readUint8(bytes));
+        builder.setOverBookingFactor(ByteBufUtils.readUint8(bytes));
         final TlvsBuilder tlvsBuilder = new TlvsBuilder();
         parseTlvs(tlvsBuilder, bytes.slice());
         builder.setTlvs(tlvsBuilder.build());
@@ -59,7 +59,7 @@ public class PCEPGlobalConstraintsObjectParser extends AbstractObjectWithTlvsPar
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Gc,
+        checkArgument(object instanceof Gc,
             "Wrong instance of PCEPObject. Passed %s. Needed GcObject.", object.getClass());
         final Gc specObj = (Gc) object;
         final ByteBuf body = Unpooled.buffer();
index 1be20ef450ffebe223036aececfbfaea0b547e06..57b23efb36fde18aab25ab19f6c620802c5e5101 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
@@ -51,7 +52,7 @@ public final class PCEPLoadBalancingObjectParser extends CommonObjectParser impl
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
         bytes.skipBytes(RESERVED + FLAGS_F_LENGTH);
-        builder.setMaxLsp(bytes.readUnsignedByte());
+        builder.setMaxLsp(ByteBufUtils.readUint8(bytes));
         builder.setMinBandwidth(new Bandwidth(ByteArray.readAllBytes(bytes)));
         return builder.build();
     }
index 0dd6190120f52bd36d5c62af5f5063704594f25f..a254eee6cb15105700c905fff8ac539a360c3755 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.protocol.pcep.parser.object;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.List;
@@ -20,6 +20,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa;
@@ -56,16 +57,16 @@ public class PCEPLspaObjectParser extends AbstractObjectWithTlvsParser<TlvsBuild
 
     @Override
     public Lspa parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
-        Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         final LspaBuilder builder = new LspaBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
 
-        builder.setExcludeAny(new AttributeFilter(bytes.readUnsignedInt()));
-        builder.setIncludeAll(new AttributeFilter(bytes.readUnsignedInt()));
-        builder.setIncludeAny(new AttributeFilter(bytes.readUnsignedInt()));
-        builder.setSetupPriority(bytes.readUnsignedByte());
-        builder.setHoldPriority(bytes.readUnsignedByte());
+        builder.setExcludeAny(new AttributeFilter(ByteBufUtils.readUint32(bytes)));
+        builder.setIncludeAll(new AttributeFilter(ByteBufUtils.readUint32(bytes)));
+        builder.setIncludeAny(new AttributeFilter(ByteBufUtils.readUint32(bytes)));
+        builder.setSetupPriority(ByteBufUtils.readUint8(bytes));
+        builder.setHoldPriority(ByteBufUtils.readUint8(bytes));
 
         final BitArray flags = BitArray.valueOf(bytes.readByte());
         builder.setLocalProtectionDesired(flags.get(L_FLAG_OFFSET));
@@ -78,7 +79,8 @@ public class PCEPLspaObjectParser extends AbstractObjectWithTlvsParser<TlvsBuild
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Lspa, "Wrong instance of PCEPObject. Passed %s. Needed LspaObject.", object.getClass());
+        checkArgument(object instanceof Lspa,
+            "Wrong instance of PCEPObject. Passed %s. Needed LspaObject.", object.getClass());
         final Lspa lspaObj = (Lspa) object;
         final ByteBuf body = Unpooled.buffer();
         writeAttributeFilter(lspaObj.getExcludeAny(), body);
index fa35dfe42d9460fa34a24cb77594f36cdbd5076d..258efc3ab3eed8f5dca9679f6bee935552c708a1 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.protocol.pcep.parser.object;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
@@ -19,6 +19,7 @@ import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 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.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
@@ -58,10 +59,10 @@ public final class PCEPMetricObjectParser extends CommonObjectParser implements
 
     @Override
     public Metric parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
-        Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (bytes.readableBytes() != SIZE) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: " + SIZE
-                    + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes()
+                + "; Expected: " + SIZE + ".");
         }
         bytes.skipBytes(RESERVED);
         final BitArray flags = BitArray.valueOf(bytes.readByte());
@@ -70,14 +71,15 @@ public final class PCEPMetricObjectParser extends CommonObjectParser implements
         builder.setProcessingRule(header.isProcessingRule());
         builder.setBound(flags.get(B_FLAG_OFFSET));
         builder.setComputed(flags.get(C_FLAG_OFFSET));
-        builder.setMetricType(bytes.readUnsignedByte());
+        builder.setMetricType(ByteBufUtils.readUint8(bytes));
         builder.setValue(new Float32(ByteArray.readBytes(bytes, METRIC_VALUE_F_LENGTH)));
         return builder.build();
     }
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Metric, "Wrong instance of PCEPObject. Passed %s. Needed MetricObject.", object.getClass());
+        checkArgument(object instanceof Metric, "Wrong instance of PCEPObject. Passed %s. Needed MetricObject.",
+            object.getClass());
         final Metric mObj = (Metric) object;
         final ByteBuf body = Unpooled.buffer(SIZE);
         body.writeZero(RESERVED);
@@ -85,7 +87,7 @@ public final class PCEPMetricObjectParser extends CommonObjectParser implements
         flags.set(C_FLAG_OFFSET, mObj.isComputed());
         flags.set(B_FLAG_OFFSET, mObj.isBound());
         flags.toByteBuf(body);
-        Preconditions.checkArgument(mObj.getMetricType() != null, "MetricType is mandatory.");
+        checkArgument(mObj.getMetricType() != null, "MetricType is mandatory.");
         writeUnsignedByte(mObj.getMetricType(), body);
         writeFloat32(mObj.getValue(), body);
         ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
index e5e027bc2f52b8efcb21c6c49f8e8059b0582ca6..887da93d104587b999fed45ea002b1026143b560 100644 (file)
@@ -5,10 +5,10 @@
  * 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.parser.object;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.List;
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
@@ -52,14 +53,14 @@ public class PCEPMonitoringObjectParser extends AbstractObjectWithTlvsParser<Tlv
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         final MonitoringBuilder builder = new MonitoringBuilder();
         buffer.readBytes(RESERVED);
         final BitArray flagBits = BitArray.valueOf(buffer, FLAGS_SIZE);
         final Flags flags = new Flags(flagBits.get(G_FLAG_POS), flagBits.get(I_FLAG_POS), flagBits.get(L_FLAG_POS),
                 flagBits.get(C_FLAG_POS), flagBits.get(P_FLAG_POS));
         builder.setFlags(flags);
-        builder.setMonitoringId(buffer.readUnsignedInt());
+        builder.setMonitoringId(ByteBufUtils.readUint32(buffer));
         final TlvsBuilder tbuilder = new TlvsBuilder();
         parseTlvs(tbuilder, buffer.slice());
         builder.setTlvs(tbuilder.build());
@@ -68,7 +69,8 @@ public class PCEPMonitoringObjectParser extends AbstractObjectWithTlvsParser<Tlv
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Monitoring, "Wrong instance of PCEPObject. Passed %s. Needed MonitoringObject.", object.getClass());
+        checkArgument(object instanceof Monitoring, "Wrong instance of PCEPObject. Passed %s. Needed MonitoringObject.",
+            object.getClass());
         final Monitoring monitoring = (Monitoring) object;
         final ByteBuf body = Unpooled.buffer();
         body.writeZero(RESERVED);
index bc7ab38d06b90b3968102778fc6391f799d8ea9d..ede286f7dd3c8218ab4563120c366fabe8bf9fb3 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.protocol.pcep.parser.object;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.List;
@@ -19,6 +19,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
@@ -54,12 +55,12 @@ public class PCEPNoPathObjectParser extends AbstractObjectWithTlvsParser<TlvsBui
 
     @Override
     public NoPath parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
-        Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         final NoPathBuilder builder = new NoPathBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
 
-        builder.setNatureOfIssue(bytes.readUnsignedByte());
+        builder.setNatureOfIssue(ByteBufUtils.readUint8(bytes));
         final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
         builder.setUnsatisfiedConstraints(flags.get(C_FLAG_OFFSET));
         bytes.skipBytes(RESERVED_F_LENGTH);
@@ -78,10 +79,11 @@ public class PCEPNoPathObjectParser extends AbstractObjectWithTlvsParser<TlvsBui
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof NoPath, "Wrong instance of PCEPObject. Passed %s. Needed NoPathObject.", object.getClass());
+        checkArgument(object instanceof NoPath, "Wrong instance of PCEPObject. Passed %s. Needed NoPathObject.",
+            object.getClass());
         final NoPath nPObj = (NoPath) object;
         final ByteBuf body = Unpooled.buffer();
-        Preconditions.checkArgument(nPObj.getNatureOfIssue() != null, "NatureOfIssue is mandatory.");
+        checkArgument(nPObj.getNatureOfIssue() != null, "NatureOfIssue is mandatory.");
         writeUnsignedByte(nPObj.getNatureOfIssue(), body);
         final BitArray flags = new BitArray(FLAGS_SIZE);
         flags.set(C_FLAG_OFFSET, nPObj.isUnsatisfiedConstraints());
index 739647c44c282790e65d0f46254943bd70c7032a..cf0ab0dfeafd05a2ff7374a4f67bd232d8fe6782 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
@@ -53,8 +54,8 @@ public final class PCEPNotificationObjectParser extends AbstractObjectWithTlvsPa
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
         bytes.skipBytes(NT_F_OFFSET);
-        builder.setType(bytes.readUnsignedByte());
-        builder.setValue(bytes.readUnsignedByte());
+        builder.setType(ByteBufUtils.readUint8(bytes));
+        builder.setValue(ByteBufUtils.readUint8(bytes));
         parseTlvs(builder, bytes.slice());
         return builder.build();
     }
index 34972285c595998ed65d04a356e364e1fdd94a14..69961e48156532147dc531a98a73fdb74906a806 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OfId;
@@ -47,7 +48,7 @@ public final class PCEPObjectiveFunctionObjectParser extends AbstractObjectWithT
         final OfBuilder builder = new OfBuilder();
         builder.setIgnore(header.isIgnore());
         builder.setProcessingRule(header.isProcessingRule());
-        builder.setCode(new OfId(bytes.readUnsignedShort()));
+        builder.setCode(new OfId(ByteBufUtils.readUint16(bytes)));
         bytes.readBytes(RESERVED);
         final TlvsBuilder tlvsBuilder = new TlvsBuilder();
         parseTlvs(tlvsBuilder, bytes.slice());
@@ -76,7 +77,7 @@ public final class PCEPObjectiveFunctionObjectParser extends AbstractObjectWithT
     }
 
     @Override
-    protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+    protected void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
         if (!tlvs.isEmpty()) {
             builder.setVendorInformationTlv(tlvs);
         }
index ad4709758fe5bc08093a4c55c701d008b8ccde4c..f2d855883dc4d809bd9742dbb8400e55f4306888 100644 (file)
@@ -5,12 +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.parser.object;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.List;
@@ -22,6 +21,7 @@ import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.UnknownObject;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion;
@@ -32,6 +32,7 @@ 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.rev181109.open.object.open.Tlvs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -62,7 +63,7 @@ public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<TlvsBuild
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
-        Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         final int versionValue = ByteArray.copyBitsRange(bytes.readByte(), VERSION_SF_OFFSET, VERSION_SF_LENGTH);
 
         final OpenBuilder builder = new OpenBuilder();
@@ -73,11 +74,11 @@ public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<TlvsBuild
         builder.setKeepalive(keepalive);
         final short deadTimer = bytes.readUnsignedByte();
         if (keepalive == 0) {
-            builder.setDeadTimer((short) 0);
+            builder.setDeadTimer(Uint8.ZERO);
         } else {
             builder.setDeadTimer(deadTimer);
         }
-        builder.setSessionId(bytes.readUnsignedByte());
+        builder.setSessionId(ByteBufUtils.readUint8(bytes));
 
         final TlvsBuilder tbuilder = new TlvsBuilder();
         parseTlvs(tbuilder, bytes.slice());
@@ -102,13 +103,14 @@ public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<TlvsBuild
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Open, "Wrong instance of PCEPObject. Passed %s. Needed OpenObject.", object.getClass());
+        checkArgument(object instanceof Open, "Wrong instance of PCEPObject. Passed %s. Needed OpenObject.",
+            object.getClass());
         final Open open = (Open) object;
         final ByteBuf body = Unpooled.buffer();
-        writeUnsignedByte((short) (PCEP_VERSION << (Byte.SIZE - VERSION_SF_LENGTH)), body);
+        writeUnsignedByte((short) (PCEP_VERSION << Byte.SIZE - VERSION_SF_LENGTH), body);
         writeUnsignedByte(open.getKeepalive(), body);
         writeUnsignedByte(open.getDeadTimer(), body);
-        Preconditions.checkArgument(open.getSessionId() != null, "SessionId is mandatory.");
+        checkArgument(open.getSessionId() != null, "SessionId is mandatory.");
         writeUnsignedByte(open.getSessionId(), body);
         serializeTlvs(open.getTlvs(), body);
         ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
index fee5b5b41d5851da5e7acdc0aff5fa5336640911..73389036849b9ae6de4acd048c00577186f6f691 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
@@ -50,7 +51,7 @@ public class PCEPOverloadObjectParser extends CommonObjectParser implements Obje
             "Array of bytes is mandatory. Can't be null or empty.");
         final OverloadBuilder builder = new OverloadBuilder();
         buffer.readBytes(RESERVED + FLAGS);
-        builder.setDuration(buffer.readUnsignedShort());
+        builder.setDuration(ByteBufUtils.readUint16(buffer));
         return builder.build();
     }
 }
index 87bf05de1fdfb75b188cb8c21943d2d3aa2a5029..58d5a4e36a7d38cdd99e5a23adc53fa831b45a97 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.protocol.pcep.parser.object;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.INT_BYTES_LENGTH;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
@@ -17,6 +17,7 @@ import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
@@ -43,7 +44,7 @@ public class PCEPProcTimeObjectParser extends CommonObjectParser implements Obje
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof ProcTime,
+        checkArgument(object instanceof ProcTime,
             "Wrong instance of PCEPObject. Passed %s. Needed ProcTimeObject.", object.getClass());
         final ProcTime procTime = (ProcTime) object;
         final ByteBuf body = Unpooled.buffer(BODY_SIZE);
@@ -61,17 +62,18 @@ public class PCEPProcTimeObjectParser extends CommonObjectParser implements Obje
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+        checkArgument(buffer != null && buffer.isReadable(),
             "Array of bytes is mandatory. Can't be null or empty.");
-        final ProcTimeBuilder builder = new ProcTimeBuilder();
         buffer.skipBytes(RESERVED);
         final BitArray flagBits = BitArray.valueOf(buffer, FLAGS);
-        builder.setEstimated(flagBits.get(E_FLAG_POSITION));
-        builder.setCurrentProcTime(buffer.readUnsignedInt());
-        builder.setMinProcTime(buffer.readUnsignedInt());
-        builder.setMaxProcTime(buffer.readUnsignedInt());
-        builder.setAverageProcTime(buffer.readUnsignedInt());
-        builder.setVarianceProcTime(buffer.readUnsignedInt());
-        return builder.build();
+
+        return new ProcTimeBuilder()
+                .setEstimated(flagBits.get(E_FLAG_POSITION))
+                .setCurrentProcTime(ByteBufUtils.readUint32(buffer))
+                .setMinProcTime(ByteBufUtils.readUint32(buffer))
+                .setMaxProcTime(ByteBufUtils.readUint32(buffer))
+                .setAverageProcTime(ByteBufUtils.readUint32(buffer))
+                .setVarianceProcTime(ByteBufUtils.readUint32(buffer))
+                .build();
     }
 }
index 63ad84ab9364ff1adc0344958f611a10704ada5e..6d36264aca85d883363a772c96b4379fa3c65051 100644 (file)
@@ -5,12 +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.parser.object;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.List;
@@ -20,6 +19,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId;
@@ -31,6 +31,7 @@ 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.rev181109.rp.object.rp.Tlvs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 /**
  * Parser for {@link Rp}
@@ -94,7 +95,7 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsPars
 
     @Override
     public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
-        Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
 
         final RpBuilder builder = new RpBuilder();
@@ -106,7 +107,7 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsPars
         priority |= (flags.get(PRI_SF_OFFSET + 1) ? 1 : 0) << 1;
         priority |= (flags.get(PRI_SF_OFFSET) ? 1 : 0) << 2;
         if (priority != 0) {
-            builder.setPriority(priority);
+            builder.setPriority(Uint8.valueOf(priority));
         }
         builder.setFragmentation(flags.get(F_FLAG_OFFSET));
         builder.setP2mp(flags.get(N_FLAG_OFFSET));
@@ -119,7 +120,7 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsPars
         builder.setBiDirectional(flags.get(B_FLAG_OFFSET));
         builder.setReoptimization(flags.get(R_FLAG_OFFSET));
 
-        builder.setRequestId(new RequestId(bytes.readUnsignedInt()));
+        builder.setRequestId(new RequestId(ByteBufUtils.readUint32(bytes)));
         final TlvsBuilder tlvsBuilder = new TlvsBuilder();
         parseTlvs(tlvsBuilder, bytes.slice());
         builder.setTlvs(tlvsBuilder.build());
@@ -138,7 +139,8 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsPars
 
     @Override
     public void serializeObject(final Object object, final ByteBuf buffer) {
-        Preconditions.checkArgument(object instanceof Rp, "Wrong instance of PCEPObject. Passed %s. Needed RPObject.", object.getClass());
+        checkArgument(object instanceof Rp, "Wrong instance of PCEPObject. Passed %s. Needed RPObject.",
+            object.getClass());
         final ByteBuf body = Unpooled.buffer();
         final Rp rpObj = (Rp) object;
         final BitArray flags = new BitArray(FLAGS_SIZE);
@@ -158,7 +160,7 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsPars
             res[res.length - 1] = (byte) (res[res.length - 1] | p);
         }
         body.writeBytes(res);
-        Preconditions.checkArgument(rpObj.getRequestId() != null, "RequestId is mandatory");
+        checkArgument(rpObj.getRequestId() != null, "RequestId is mandatory");
         writeUnsignedInt(rpObj.getRequestId().getValue(), body);
         serializeTlvs(rpObj.getTlvs(), body);
         ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
index fb108722758ba34986ffd609ed7701283b781884..a8205215d187b95b739d17347ade5cd220c51e10 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId;
@@ -74,7 +75,7 @@ public final class PCEPSvecObjectParser extends CommonObjectParser implements Ob
         final List<RequestId> requestIDs = new ArrayList<>();
 
         while (bytes.isReadable()) {
-            requestIDs.add(new RequestId(bytes.readUnsignedInt()));
+            requestIDs.add(new RequestId(ByteBufUtils.readUint32(bytes)));
         }
         if (requestIDs.isEmpty()) {
             throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
@@ -109,7 +110,7 @@ public final class PCEPSvecObjectParser extends CommonObjectParser implements Ob
         flags.toByteBuf(body);
 
         final List<RequestId> requestIDs = svecObj.getRequestsIds();
-        assert !(requestIDs.isEmpty()) : "Empty Svec Object - no request ids.";
+        assert !requestIDs.isEmpty() : "Empty Svec Object - no request ids.";
         for (final RequestId requestId : requestIDs) {
             writeUnsignedInt(requestId.getValue(), body);
         }
index 97e129b385f07fa34822cbb02d6295cf56841d9a..907cba65c73587bc86236d4ea2a102c63ae995c2 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeShort;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -18,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.as.number._case.AsNumberBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 final class AsNumberCaseParser {
 
@@ -28,19 +29,20 @@ final class AsNumberCaseParser {
     private static final int CONTENT_LENGTH = 2;
 
     static AsNumberCase parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: "
-                    + CONTENT_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + "; Expected: " + CONTENT_LENGTH + ".");
         }
-        return new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber((long) buffer.readUnsignedShort())).build()).build();
+        return new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(
+            new AsNumber(Uint32.valueOf(buffer.readUnsignedShort()))).build()).build();
     }
 
 
     static ByteBuf serializeSubobject(final AsNumberCase asCase) {
         final AsNumberSubobject asNumber = asCase.getAsNumber();
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
-        Preconditions.checkArgument(asNumber.getAsNumber() != null, "AsNumber is mandatory.");
+        checkArgument(asNumber.getAsNumber() != null, "AsNumber is mandatory.");
         writeShort(asNumber.getAsNumber().getValue().shortValue(), body);
         return body;
     }
index dc3e08f140a9c8fd27b4f81b0d36e849e637f113..5a57cd2e1488d5fbc9249367aaaf3561eed1fd1b 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
 import org.opendaylight.protocol.pcep.spi.EROSubobjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.UnnumberedSubobject;
@@ -36,30 +37,31 @@ public class EROUnnumberedInterfaceSubobjectParser implements EROSubobjectParser
 
     @Override
     public Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: "
-                    + CONTENT_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + "; Expected: " + CONTENT_LENGTH + ".");
         }
         final SubobjectBuilder builder = new SubobjectBuilder();
         builder.setLoose(loose);
         final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
         buffer.skipBytes(RESERVED);
-        ubuilder.setRouterId(buffer.readUnsignedInt());
-        ubuilder.setInterfaceId(buffer.readUnsignedInt());
+        ubuilder.setRouterId(ByteBufUtils.readUint32(buffer));
+        ubuilder.setInterfaceId(ByteBufUtils.readUint32(buffer));
         builder.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build());
         return builder.build();
     }
 
     @Override
     public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase,
+            "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
         final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
         body.writeZero(RESERVED);
-        Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
+        checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
         writeUnsignedInt(specObj.getRouterId(), body);
-        Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory");
+        checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory");
         writeUnsignedInt(specObj.getInterfaceId(), body);
         EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
     }
index 7e64533730b12d0068c40ae9d22591180d87b4fd..b4d6118048be3be6f300840cf2a3b80baf536cbb 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.RROSubobjectUtil;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey;
@@ -23,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 public class RROPathKey128SubobjectParser implements RROSubobjectParser {
 
@@ -39,12 +41,12 @@ public class RROPathKey128SubobjectParser implements RROSubobjectParser {
 
     @Override
     public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT128_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >"
-                    + CONTENT128_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                    + "; Expected: >" + CONTENT128_LENGTH + ".");
         }
-        final int pathKey = buffer.readUnsignedShort();
+        final Uint16 pathKey = ByteBufUtils.readUint16(buffer);
         final byte[] pceId = ByteArray.readBytes(buffer, PCE128_ID_F_LENGTH);
         final SubobjectBuilder builder = new SubobjectBuilder();
         final PathKeyBuilder pBuilder = new PathKeyBuilder();
@@ -59,9 +61,9 @@ public class RROPathKey128SubobjectParser implements RROSubobjectParser {
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects
             .subobject.type.path.key._case.PathKey pk = pkcase.getPathKey();
         final ByteBuf body = Unpooled.buffer();
-        Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+        checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
         writeUnsignedShort(pk.getPathKey().getValue(), body);
-        Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
+        checkArgument(pk.getPceId() != null, "PceId is mandatory.");
         body.writeBytes(pk.getPceId().getValue());
         RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
     }
index e514ae83dcd6e51147d149f8ea06bf0df2b92c26..bba285a07f71a2c0ea241ae4beb0d58766717b52 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
 
 import com.google.common.base.Preconditions;
@@ -17,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
 import org.opendaylight.protocol.pcep.spi.RROSubobjectUtil;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey;
@@ -24,6 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 public class RROPathKey32SubobjectParser implements RROSubobjectParser, RROSubobjectSerializer {
 
@@ -39,12 +42,13 @@ public class RROPathKey32SubobjectParser implements RROSubobjectParser, RROSubob
 
     @Override
     public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(),
+                "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >"
-                    + CONTENT_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + "; Expected: >" + CONTENT_LENGTH + ".");
         }
-        final int pathKey = buffer.readUnsignedShort();
+        final Uint16 pathKey = ByteBufUtils.readUint16(buffer);
         final byte[] pceId = ByteArray.readBytes(buffer, PCE_ID_F_LENGTH);
         final SubobjectBuilder builder = new SubobjectBuilder();
         final PathKeyBuilder pBuilder = new PathKeyBuilder();
@@ -56,18 +60,19 @@ public class RROPathKey32SubobjectParser implements RROSubobjectParser, RROSubob
 
     @Override
     public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
+            "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
         final PathKeyCase pkcase = (PathKeyCase) subobject.getSubobjectType();
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects
             .subobject.type.path.key._case.PathKey pk = pkcase.getPathKey();
         final ByteBuf body = Unpooled.buffer();
-        Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
+        checkArgument(pk.getPceId() != null, "PceId is mandatory.");
 
         final byte[] pceId = pk.getPceId().getValue();
         if (pceId.length == RROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
             RROPathKey128SubobjectParser.serializeSubobject(subobject,buffer);
         }
-        Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+        checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
         writeUnsignedShort(pk.getPathKey().getValue(), body);
         Preconditions.checkArgument(pceId.length == PCE_ID_F_LENGTH, "PceId 32 Bit required.");
         body.writeBytes(pceId);
index df4ce3f1c2c9809a4d4770c2fa6d0c12cb367e47..8d7b3589ae2173a29959d4a4f214ae01c071e7a9 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -17,6 +17,7 @@ import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
 import org.opendaylight.protocol.pcep.spi.RROSubobjectUtil;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.UnnumberedSubobject;
@@ -41,10 +42,10 @@ public class RROUnnumberedInterfaceSubobjectParser implements RROSubobjectParser
 
     @Override
     public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: "
-                    + CONTENT_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + "; Expected: " + CONTENT_LENGTH + ".");
         }
         final SubobjectBuilder builder = new SubobjectBuilder();
         final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
@@ -52,15 +53,16 @@ public class RROUnnumberedInterfaceSubobjectParser implements RROSubobjectParser
         builder.setProtectionInUse(flags.get(LPIU_F_OFFSET));
         final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
         buffer.skipBytes(RESERVED);
-        ubuilder.setRouterId(buffer.readUnsignedInt());
-        ubuilder.setInterfaceId(buffer.readUnsignedInt());
+        ubuilder.setRouterId(ByteBufUtils.readUint32(buffer));
+        ubuilder.setInterfaceId(ByteBufUtils.readUint32(buffer));
         builder.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build());
         return builder.build();
     }
 
     @Override
     public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase,
+            "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
         final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
         final BitArray flags = new BitArray(FLAGS_SIZE);
         flags.set(LPA_F_OFFSET, subobject.isProtectionAvailable());
@@ -68,9 +70,9 @@ public class RROUnnumberedInterfaceSubobjectParser implements RROSubobjectParser
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
         flags.toByteBuf(body);
         body.writeZero(RESERVED);
-        Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
+        checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
         writeUnsignedInt(specObj.getRouterId(), body);
-        Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
+        checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
         writeUnsignedInt(specObj.getInterfaceId(), body);
         RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
     }
index e7a9053bc0d22a99f9f023fc9af999c4747e2279..d23b0285dfb191961834baf498c06c8f9dc65596 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.LabelParser;
 import org.opendaylight.protocol.pcep.spi.LabelSerializer;
 import org.opendaylight.protocol.pcep.spi.LabelUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCaseBuilder;
@@ -33,20 +34,24 @@ public class Type1LabelParser implements LabelParser, LabelSerializer {
 
     @Override
     public LabelType parseLabel(final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != LABEL_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: "
-                    + LABEL_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + "; Expected: " + LABEL_LENGTH + ".");
         }
-        return new Type1LabelCaseBuilder().setType1Label(new Type1LabelBuilder().setType1Label(buffer.readUnsignedInt()).build()).build();
+        return new Type1LabelCaseBuilder()
+                .setType1Label(new Type1LabelBuilder().setType1Label(ByteBufUtils.readUint32(buffer)).build())
+                .build();
     }
 
     @Override
-    public void serializeLabel(final boolean unidirectional, final boolean global, final LabelType subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject instanceof Type1LabelCase, "Unknown Label Subobject instance. Passed {}. Needed Type1LabelCase.", subobject.getClass());
+    public void serializeLabel(final boolean unidirectional, final boolean global, final LabelType subobject,
+            final ByteBuf buffer) {
+        checkArgument(subobject instanceof Type1LabelCase,
+            "Unknown Label Subobject instance. Passed {}. Needed Type1LabelCase.", subobject.getClass());
         final ByteBuf body = Unpooled.buffer(LABEL_LENGTH);
         final Type1Label type1Label = ((Type1LabelCase) subobject).getType1Label();
-        Preconditions.checkArgument(type1Label != null, "Type1Label is mandatory.");
+        checkArgument(type1Label != null, "Type1Label is mandatory.");
         writeUnsignedInt(type1Label.getType1Label(), body);
         LabelUtil.formatLabel(CTYPE, unidirectional, global, body, buffer);
     }
index 7bcb77b38df271ba4cc2f5f102d858ef3a0eb170..9b1869c66a5a9fa941481c179cf41da289dd829f 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.LabelParser;
 import org.opendaylight.protocol.pcep.spi.LabelSerializer;
 import org.opendaylight.protocol.pcep.spi.LabelUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCaseBuilder;
@@ -37,28 +38,31 @@ public class WavebandSwitchingLabelParser implements LabelParser, LabelSerialize
 
     @Override
     public LabelType parseLabel(final ByteBuf buffer) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: "
-                    + CONTENT_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + "; Expected: " + CONTENT_LENGTH + ".");
         }
-        final WavebandSwitchingLabelBuilder builder = new WavebandSwitchingLabelBuilder();
-        builder.setWavebandId(buffer.readUnsignedInt());
-        builder.setStartLabel(buffer.readUnsignedInt());
-        builder.setEndLabel(buffer.readUnsignedInt());
-        return new WavebandSwitchingLabelCaseBuilder().setWavebandSwitchingLabel(builder.build()).build();
+        return new WavebandSwitchingLabelCaseBuilder()
+                .setWavebandSwitchingLabel(new WavebandSwitchingLabelBuilder()
+                    .setWavebandId(ByteBufUtils.readUint32(buffer))
+                    .setStartLabel(ByteBufUtils.readUint32(buffer))
+                    .setEndLabel(ByteBufUtils.readUint32(buffer))
+                    .build())
+                .build();
     }
 
     @Override
     public void serializeLabel(final boolean unidirectional, final boolean global, final LabelType subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject instanceof WavebandSwitchingLabelCase, "Unknown Label Subobject instance. Passed {}. Needed WavebandSwitchingLabelCase.", subobject.getClass());
+        checkArgument(subobject instanceof WavebandSwitchingLabelCase,
+            "Unknown Label Subobject instance. Passed {}. Needed WavebandSwitchingLabelCase.", subobject.getClass());
         final WavebandSwitchingLabel obj = ((WavebandSwitchingLabelCase) subobject).getWavebandSwitchingLabel();
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
-        Preconditions.checkArgument(obj.getWavebandId() != null, "WavebandId is mandatory.");
+        checkArgument(obj.getWavebandId() != null, "WavebandId is mandatory.");
         writeUnsignedInt(obj.getWavebandId(), body);
-        Preconditions.checkArgument(obj.getStartLabel() != null, "StartLabel is mandatory.");
+        checkArgument(obj.getStartLabel() != null, "StartLabel is mandatory.");
         writeUnsignedInt(obj.getStartLabel(), body);
-        Preconditions.checkArgument(obj.getEndLabel() != null, "EndLabel is mandatory.");
+        checkArgument(obj.getEndLabel() != null, "EndLabel is mandatory.");
         writeUnsignedInt(obj.getEndLabel(), body);
         LabelUtil.formatLabel(CTYPE, unidirectional, global, body, buffer);
     }
index 48e392fdd0b7b1773b11687c0df3bc4838f15a28..1f3641503eca6e60aca9995e6b343bff425ce29e 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv4Prefix;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 
@@ -43,15 +44,17 @@ public class XROIpv4PrefixSubobjectParser implements XROSubobjectParser, XROSubo
 
     @Override
     public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         final SubobjectBuilder builder = new SubobjectBuilder();
         builder.setMandatory(mandatory);
         if (buffer.readableBytes() != CONTENT4_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + ";");
         }
         final int length = buffer.getUnsignedByte(PREFIX4_F_OFFSET);
-        final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.readBytes(buffer,
-                Ipv4Util.IP4_LENGTH), length)));
+        final IpPrefixBuilder prefix = new IpPrefixBuilder()
+                .setIpPrefix(new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.readBytes(buffer, Ipv4Util.IP4_LENGTH),
+                    length)));
         builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
         buffer.skipBytes(PREFIX_F_LENGTH);
         builder.setAttribute(Attribute.forValue(buffer.readUnsignedByte()));
@@ -60,10 +63,12 @@ public class XROIpv4PrefixSubobjectParser implements XROSubobjectParser, XROSubo
 
     @Override
     public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase,
+            "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass());
         final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
         final IpPrefix prefix = specObj.getIpPrefix();
-        Preconditions.checkArgument(prefix.getIpv4Prefix() != null || prefix.getIpv6Prefix() != null, "Unknown AbstractPrefix instance. Passed %s.", prefix.getClass());
+        checkArgument(prefix.getIpv4Prefix() != null || prefix.getIpv6Prefix() != null,
+                "Unknown AbstractPrefix instance. Passed %s.", prefix.getClass());
         if (prefix.getIpv6Prefix() != null) {
             new XROIpv6PrefixSubobjectParser().serializeSubobject(subobject, buffer);
         } else {
index b1f26d56e527d66afdb42b2194c4013189376d7b..8433fb9eaa674f83b037fd7bdf0eba76ab43df84 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectUtil;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.SubobjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey;
@@ -23,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 /**
  * Parser for {@link PathKey}
@@ -37,12 +39,12 @@ public class XROPathKey128SubobjectParser implements XROSubobjectParser {
 
     @Override
     public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT128_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >"
-                    + CONTENT128_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + "; Expected: >" + CONTENT128_LENGTH + ".");
         }
-        final int pathKey = buffer.readUnsignedShort();
+        final Uint16 pathKey = ByteBufUtils.readUint16(buffer);
         final byte[] pceId = ByteArray.readBytes(buffer, PCE128_ID_F_LENGTH);
         final SubobjectBuilder builder = new SubobjectBuilder();
         final PathKeyBuilder pBuilder = new PathKeyBuilder();
@@ -54,13 +56,15 @@ public class XROPathKey128SubobjectParser implements XROSubobjectParser {
     }
 
     public static void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
+            "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
-            .subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
+            .subobjects.subobject.type.path.key._case.PathKey pk =
+                ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
         final ByteBuf body = Unpooled.buffer();
-        Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+        checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
         writeUnsignedShort(pk.getPathKey().getValue(), body);
-        Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
+        checkArgument(pk.getPceId() != null, "PceId is mandatory.");
         body.writeBytes(pk.getPceId().getValue());
         XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
     }
index 59080767b750393a0d8f8bc710b6beab21d8a203..1ccdb4d9f6713d572c6da4cf2ee324e11c08439e 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
@@ -17,6 +17,7 @@ import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectUtil;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.SubobjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey;
@@ -24,6 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 /**
  * Parser for {@link PathKey}
@@ -38,12 +40,12 @@ public class XROPathKey32SubobjectParser implements XROSubobjectParser, XROSubob
 
     @Override
     public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >"
-                    + CONTENT_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+            + "; Expected: >" + CONTENT_LENGTH + ".");
         }
-        final int pathKey = buffer.readUnsignedShort();
+        final Uint16 pathKey = ByteBufUtils.readUint16(buffer);
         final byte[] pceId = ByteArray.readBytes(buffer, PCE_ID_F_LENGTH);
         final SubobjectBuilder builder = new SubobjectBuilder();
         final PathKeyBuilder pBuilder = new PathKeyBuilder();
@@ -56,19 +58,21 @@ public class XROPathKey32SubobjectParser implements XROSubobjectParser, XROSubob
 
     @Override
     public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
+            "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
-            .subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
+            .subobjects.subobject.type.path.key._case.PathKey pk =
+                ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
         final ByteBuf body = Unpooled.buffer();
-        Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
+        checkArgument(pk.getPceId() != null, "PceId is mandatory.");
 
         final byte[] pceId = pk.getPceId().getValue();
         if (pceId.length == XROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
             XROPathKey128SubobjectParser.serializeSubobject(subobject,buffer);
         }
-        Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+        checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
         writeUnsignedShort(pk.getPathKey().getValue(), body);
-        Preconditions.checkArgument(pceId.length == PCE_ID_F_LENGTH, "PceId 32 Bit required.");
+        checkArgument(pceId.length == PCE_ID_F_LENGTH, "PceId 32 Bit required.");
         body.writeBytes(pceId);
         XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
     }
index c58ed4c97adef90affb5b7954bf40493b9c0bd18..4b7d76f7283b01b7ca5b5b095042ebc991a4b7ce 100644 (file)
@@ -7,16 +7,17 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.SubobjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects;
@@ -38,28 +39,32 @@ public class XROSRLGSubobjectParser implements XROSubobjectParser, XROSubobjectS
 
     @Override
     public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: "
-                    + CONTENT_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + "; Expected: " + CONTENT_LENGTH + ".");
         }
-        final SubobjectBuilder builder = new SubobjectBuilder();
-        builder.setMandatory(mandatory);
-
-        builder.setSubobjectType(new SrlgCaseBuilder().setSrlg(new SrlgBuilder().setSrlgId(new SrlgId(buffer.readUnsignedInt())).build()).build());
+        final SubobjectBuilder builder = new SubobjectBuilder()
+                .setMandatory(mandatory)
+                .setSubobjectType(new SrlgCaseBuilder()
+                    .setSrlg(new SrlgBuilder()
+                        .setSrlgId(new SrlgId(ByteBufUtils.readUint32(buffer)))
+                        .build())
+                    .build());
         buffer.readByte();
-        builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()));
-        return builder.build();
+        return builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()))
+                .build();
     }
 
     @Override
     public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof SrlgCase, "Unknown subobject instance. Passed %s. Needed SrlgCase.", subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof SrlgCase,
+            "Unknown subobject instance. Passed %s. Needed SrlgCase.", subobject.getSubobjectType().getClass());
         final SrlgSubobject specObj = ((SrlgCase) subobject.getSubobjectType()).getSrlg();
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
-        Preconditions.checkArgument(specObj.getSrlgId() != null, "SrlgId is mandatory.");
+        checkArgument(specObj.getSrlgId() != null, "SrlgId is mandatory.");
         writeUnsignedInt(specObj.getSrlgId().getValue(), body);
-        Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
+        checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
         writeUnsignedByte((Uint8) null, body);
         writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
         XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
index 59fb28a108b7144bba4b3a96ec9572885496dc47..350a9d35d56f2f1c40115aee3d88eb0558d52e40 100644 (file)
@@ -7,16 +7,17 @@
  */
 package org.opendaylight.protocol.pcep.parser.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.SubobjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute;
@@ -38,32 +39,34 @@ public class XROUnnumberedInterfaceSubobjectParser implements XROSubobjectParser
 
     @Override
     public Subobject parseSubobject(final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: "
-                    + CONTENT_LENGTH + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + "; Expected: " + CONTENT_LENGTH + ".");
         }
         buffer.readerIndex(buffer.readerIndex() + RESERVED);
         final SubobjectBuilder builder = new SubobjectBuilder();
         builder.setMandatory(mandatory);
         builder.setAttribute(Attribute.forValue(buffer.readUnsignedByte()));
         final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
-        ubuilder.setRouterId(buffer.readUnsignedInt());
-        ubuilder.setInterfaceId(buffer.readUnsignedInt());
+        ubuilder.setRouterId(ByteBufUtils.readUint32(buffer));
+        ubuilder.setInterfaceId(ByteBufUtils.readUint32(buffer));
         builder.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build());
         return builder.build();
     }
 
     @Override
     public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase,
+            "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType().getClass());
         final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
         body.writeZero(RESERVED);
-        writeUnsignedByte(subobject.getAttribute() != null ? (short) subobject.getAttribute().getIntValue() : null, body);
-        Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
+        writeUnsignedByte(subobject.getAttribute() != null ? (short) subobject.getAttribute().getIntValue() : null,
+                body);
+        checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
         writeUnsignedInt(specObj.getRouterId(), body);
-        Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
+        checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
         writeUnsignedInt(specObj.getInterfaceId(), body);
         XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
     }
index 054f4817a51d3545968443f5e8b8472c932f372d..a8e575a03980ded898d6ab6f48e9333855fa8e7d 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.protocol.pcep.parser.tlv;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.ArrayList;
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.pcep.spi.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OfId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.list.tlv.OfList;
@@ -38,18 +39,19 @@ public class OFListTlvParser implements TlvParser, TlvSerializer {
             return null;
         }
         if (buffer.readableBytes() % OF_CODE_ELEMENT_LENGTH != 0) {
-            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ".");
+            throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+                + ".");
         }
         final List<OfId> ofCodes = new ArrayList<>();
         while (buffer.isReadable()) {
-            ofCodes.add(new OfId(buffer.readUnsignedShort()));
+            ofCodes.add(new OfId(ByteBufUtils.readUint16(buffer)));
         }
         return new OfListBuilder().setCodes(ofCodes).build();
     }
 
     @Override
     public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
-        Preconditions.checkArgument(tlv instanceof OfList, "OFListTlv is mandatory.");
+        checkArgument(tlv instanceof OfList, "OFListTlv is mandatory.");
         final OfList oft = (OfList) tlv;
         final ByteBuf body = Unpooled.buffer();
         final List<OfId> ofCodes = oft.getCodes();
index abfe6d5e579b808ba56861527c1a9e2fee44ee53..5dff66950ed031bd908923547509d32dc84f76cc 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.protocol.pcep.parser.tlv;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.pcep.spi.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.OrderBuilder;
@@ -32,12 +33,15 @@ public class OrderTlvParser implements TlvParser, TlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new OrderBuilder().setDelete(buffer.readUnsignedInt()).setSetup(buffer.readUnsignedInt()).build();
+        return new OrderBuilder()
+                .setDelete(ByteBufUtils.readUint32(buffer))
+                .setSetup(ByteBufUtils.readUint32(buffer))
+                .build();
     }
 
     @Override
     public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
-        Preconditions.checkArgument(tlv instanceof Order, "OrderTlv is mandatory.");
+        checkArgument(tlv instanceof Order, "OrderTlv is mandatory.");
         final Order otlv = (Order) tlv;
         final ByteBuf body = Unpooled.buffer();
         writeUnsignedInt(otlv.getDelete(), body);
index 731a378ed18cc7ca1203ad94458f9bfd9f99219d..e216fb268a356959d818cbb740e070b57d29b1f7 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.protocol.pcep.parser.tlv;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.pcep.spi.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDuration;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDurationBuilder;
@@ -32,12 +33,12 @@ public class OverloadedDurationTlvParser implements TlvParser, TlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new OverloadDurationBuilder().setDuration(buffer.readUnsignedInt()).build();
+        return new OverloadDurationBuilder().setDuration(ByteBufUtils.readUint32(buffer)).build();
     }
 
     @Override
     public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
-        Preconditions.checkArgument(tlv instanceof OverloadDuration, "OverloadedTlv is mandatory.");
+        checkArgument(tlv instanceof OverloadDuration, "OverloadedTlv is mandatory.");
         final ByteBuf body = Unpooled.buffer();
         writeUnsignedInt(((OverloadDuration) tlv).getDuration(), body);
         TlvUtil.formatTlv(TYPE, body, buffer);
index 558f270d35e83d6ea615c7b6857f0f6cbe671964..93687af9ab4f21f91fa49e6879b02c96ae465176 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.pcep.spi.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.req.missing.tlv.ReqMissing;
@@ -33,7 +34,7 @@ public class ReqMissingTlvParser implements TlvParser, TlvSerializer {
         if (buffer == null) {
             return null;
         }
-        return new ReqMissingBuilder().setRequestId(new RequestId(buffer.readUnsignedInt())).build();
+        return new ReqMissingBuilder().setRequestId(new RequestId(ByteBufUtils.readUint32(buffer))).build();
     }
 
     @Override
index 4b94f73c978eaba238ff21309a8d97deb45e542d..bd13a14d04296db5dfab27c4866880c00130a807 100644 (file)
@@ -28,6 +28,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.iet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.path.binding.tlv.path.binding.binding.type.value.MplsLabelEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
 import org.opendaylight.yangtools.concepts.IllegalArgumentCodec;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 /**
  * Parser for {@link PathBinding}.
@@ -146,9 +148,9 @@ public final class PathBindingTlvParser implements TlvParser, TlvSerializer {
             final MplsLabelEntryBuilder builder = new MplsLabelEntryBuilder();
             final long entry = buffer.readUnsignedInt();
             builder.setLabel(getMplsLabel(entry));
-            builder.setTrafficClass((short) (entry >> TC_SHIFT & TC_MASK));
+            builder.setTrafficClass(Uint8.valueOf(entry >> TC_SHIFT & TC_MASK));
             builder.setBottomOfStack((entry >> S_SHIFT & S_MASK) == 1);
-            builder.setTimeToLive((short) (entry & TTL_MASK));
+            builder.setTimeToLive(Uint8.valueOf(entry & TTL_MASK));
             return builder.build();
         }
 
@@ -167,7 +169,7 @@ public final class PathBindingTlvParser implements TlvParser, TlvSerializer {
     private static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel
         getMplsLabel(final long mplsStackEntry) {
         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125
-                .MplsLabel(mplsStackEntry >> LABEL_SHIFT & LABEL_MASK);
+                .MplsLabel(Uint32.valueOf(mplsStackEntry >> LABEL_SHIFT & LABEL_MASK));
     }
 
     @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
index acfe3d7d515ccc739f73668f217502f0a06c9ab4..4f4443ee0449d4484f415a7f9e3995407cdff7ea 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.pcep.spi.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp.identifiers.tlv.LspIdentifiers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp.identifiers.tlv.LspIdentifiersBuilder;
@@ -31,6 +32,7 @@ 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.rsvp.rev150820.Ipv4ExtendedTunnelId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 /**
  * Parser for {@link LspIdentifiers}.
@@ -50,8 +52,8 @@ public final class Stateful07LSPIdentifierIpv4TlvParser implements TlvParser, Tl
                 buffer.readableBytes());
         final Ipv4Builder builder = new Ipv4Builder();
         builder.setIpv4TunnelSenderAddress(Ipv4Util.noZoneAddressForByteBuf(buffer));
-        final LspId lspId = new LspId((long) buffer.readUnsignedShort());
-        final TunnelId tunnelId = new TunnelId(buffer.readUnsignedShort());
+        final LspId lspId = new LspId(Uint32.valueOf(buffer.readUnsignedShort()));
+        final TunnelId tunnelId = new TunnelId(ByteBufUtils.readUint16(buffer));
         builder.setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(Ipv4Util.noZoneAddressForByteBuf(buffer)));
         builder.setIpv4TunnelEndpointAddress(Ipv4Util.noZoneAddressForByteBuf(buffer));
         final AddressFamily afi = new Ipv4CaseBuilder().setIpv4(builder.build()).build();
index 64346aef77578431ff54fa29d3d9d3514f3f5f02..3a44c328ab1df16a8d848ddfb4c9926698871b45 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.pcep.spi.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv6Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp.identifiers.tlv.LspIdentifiers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp.identifiers.tlv.LspIdentifiersBuilder;
@@ -30,6 +31,7 @@ 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.rsvp.rev150820.Ipv6ExtendedTunnelId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 /**
  * Parser for {@link LspIdentifiers}.
@@ -49,8 +51,8 @@ public final class Stateful07LSPIdentifierIpv6TlvParser implements TlvParser, Tl
                 buffer.readableBytes());
         final Ipv6Builder builder = new Ipv6Builder();
         builder.setIpv6TunnelSenderAddress(Ipv6Util.noZoneAddressForByteBuf(buffer));
-        final LspId lspId = new LspId((long) buffer.readUnsignedShort());
-        final TunnelId tunnelId = new TunnelId(buffer.readUnsignedShort());
+        final LspId lspId = new LspId(Uint32.valueOf(buffer.readUnsignedShort()));
+        final TunnelId tunnelId = new TunnelId(ByteBufUtils.readUint16(buffer));
         builder.setIpv6ExtendedTunnelId(new Ipv6ExtendedTunnelId(Ipv6Util.noZoneAddressForByteBuf(buffer)));
         builder.setIpv6TunnelEndpointAddress(Ipv6Util.noZoneAddressForByteBuf(buffer));
         final AddressFamily afi = new Ipv6CaseBuilder().setIpv6(builder.build()).build();
index 45d333906c3822b07b4823b82a2f6d6ed4ea3a0c..9e9447d8aeb1adbad227a202f651a36ee4525904 100644 (file)
@@ -36,6 +36,7 @@ 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.rev181109.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vs.tlv.VsTlv;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 /**
  * Parser for {@link Lsp}.
@@ -70,7 +71,7 @@ public class Stateful07LspObjectParser extends AbstractObjectWithTlvsParser<Tlvs
         builder.setProcessingRule(header.isProcessingRule());
         final int[] plspIdRaw
             = new int[] { bytes.readUnsignedByte(), bytes.readUnsignedByte(), bytes.getUnsignedByte(2), };
-        builder.setPlspId(new PlspId((long) (plspIdRaw[0] << FLAGS_SIZE | plspIdRaw[1] << FOUR_BITS_SHIFT
+        builder.setPlspId(new PlspId(Uint32.valueOf(plspIdRaw[0] << FLAGS_SIZE | plspIdRaw[1] << FOUR_BITS_SHIFT
             | plspIdRaw[2] >> FOUR_BITS_SHIFT)));
         parseFlags(builder, bytes);
         final TlvsBuilder b = new TlvsBuilder();
index ee7ee20f00b3b53b3077ab6b420c5be67a55675f..f1b686cc6c98c046b9a2beadd7bf0978581308c7 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.pcep.spi.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp.error.code.tlv.LspErrorCode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.lsp.error.code.tlv.LspErrorCodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
@@ -34,7 +35,7 @@ public final class Stateful07LspUpdateErrorTlvParser implements TlvParser, TlvSe
         if (buffer == null) {
             return null;
         }
-        return new LspErrorCodeBuilder().setErrorCode(buffer.readUnsignedInt()).build();
+        return new LspErrorCodeBuilder().setErrorCode(ByteBufUtils.readUint32(buffer)).build();
     }
 
     @Override
index f870009506afd6031223afeb5830a589a304c1a0..65a4499a5214ca9a423db76fecc181ed6100f015 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.pcep.spi.TlvUtil;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.Ipv6Util;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
@@ -97,10 +98,10 @@ public final class Stateful07RSVPErrorSpecTlvParser implements TlvParser, TlvSer
 
     private static UserCase parseUserError(final ByteBuf buffer) {
         final UserErrorBuilder error = new UserErrorBuilder();
-        error.setEnterprise(new EnterpriseNumber(buffer.readUnsignedInt()));
-        error.setSubOrg(buffer.readUnsignedByte());
+        error.setEnterprise(new EnterpriseNumber(ByteBufUtils.readUint32(buffer)));
+        error.setSubOrg(ByteBufUtils.readUint8(buffer));
         final int errDescrLength = buffer.readUnsignedByte();
-        error.setValue(buffer.readUnsignedShort());
+        error.setValue(ByteBufUtils.readUint16(buffer));
         error.setDescription(ByteArray.bytesToHRString(ByteArray.readBytes(buffer, errDescrLength)));
         // if we have any subobjects, place the implementation here
         return new UserCaseBuilder().setUserError(error.build()).build();
@@ -130,10 +131,8 @@ public final class Stateful07RSVPErrorSpecTlvParser implements TlvParser, TlvSer
         }
         final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
         builder.setFlags(new Flags(flags.get(IN_PLACE), flags.get(NOT_GUILTY)));
-        final short errorCode = buffer.readUnsignedByte();
-        builder.setCode(errorCode);
-        final int errorValue = buffer.readUnsignedShort();
-        builder.setValue(errorValue);
+        builder.setCode(ByteBufUtils.readUint8(buffer));
+        builder.setValue(ByteBufUtils.readUint16(buffer));
         return new RsvpCaseBuilder().setRsvpError(builder.build()).build();
     }
 
index 051588dc89ff4d0bd8fb0bbb7deb49e0b49f2e4c..53d61a903c20ba19c5c1c4fd3b42bed48050e077 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.spi.ObjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.SrpIdNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.srp.object.Srp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev181109.srp.object.SrpBuilder;
@@ -55,15 +56,14 @@ public class Stateful07SrpObjectParser extends AbstractObjectWithTlvsParser<Tlvs
             throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes()
                 + "; Expected: >=" + MIN_SIZE + ".");
         }
-        final SrpBuilder builder = new SrpBuilder();
-        builder.setIgnore(header.isIgnore());
-        builder.setProcessingRule(header.isProcessingRule());
+        final SrpBuilder builder = new SrpBuilder()
+                .setIgnore(header.isIgnore())
+                .setProcessingRule(header.isProcessingRule());
         parseFlags(builder, bytes);
-        builder.setOperationId(new SrpIdNumber(bytes.readUnsignedInt()));
+        builder.setOperationId(new SrpIdNumber(ByteBufUtils.readUint32(bytes)));
         final TlvsBuilder tlvsBuilder = new TlvsBuilder();
         parseTlvs(tlvsBuilder, bytes.slice());
-        builder.setTlvs(tlvsBuilder.build());
-        return builder.build();
+        return builder.setTlvs(tlvsBuilder.build()).build();
     }
 
     protected void parseFlags(final SrpBuilder builder, final ByteBuf bytes) {
index 4db785d22453e1e06640f8f5c9c2cf9a6f782c04..88a47f50ed3478763ca3610260999422a649f65a 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,7 +34,7 @@ public final class BasePCEPSessionProposalFactory implements PCEPSessionProposal
             final List<PCEPCapability> capabilities) {
         if (keepAlive != 0) {
             Preconditions.checkArgument(keepAlive >= 1, "Minimum value for keep-alive-timer-value is 1");
-            if (deadTimer != 0 && (deadTimer / keepAlive != KA_TO_DEADTIMER_RATIO)) {
+            if (deadTimer != 0 && deadTimer / keepAlive != KA_TO_DEADTIMER_RATIO) {
                 LOG.warn("dead-timer-value should be {} times greater than keep-alive-timer-value",
                     KA_TO_DEADTIMER_RATIO);
             }
@@ -57,7 +58,7 @@ public final class BasePCEPSessionProposalFactory implements PCEPSessionProposal
         oBuilder.setSessionId((short) sessionId);
         oBuilder.setKeepalive((short) BasePCEPSessionProposalFactory.this.keepAlive);
         if (BasePCEPSessionProposalFactory.this.keepAlive == 0) {
-            oBuilder.setDeadTimer((short) 0);
+            oBuilder.setDeadTimer(Uint8.ZERO);
         } else {
             oBuilder.setDeadTimer((short) BasePCEPSessionProposalFactory.this.deadTimer);
         }
index d89095cfee7feb801aa612ff5311415b2b1c3397..618608b54176dfcd940504a9f7c749eb1614c3f3 100644 (file)
@@ -82,7 +82,7 @@ public class PCEPDispatcherImpl implements PCEPDispatcher, Closeable {
     public final synchronized ChannelFuture createServer(final PCEPDispatcherDependencies dispatcherDependencies) {
         this.keys = dispatcherDependencies.getKeys();
 
-        @SuppressWarnings("unchecked") final ChannelPipelineInitializer initializer = (ch, promise) -> {
+        final ChannelPipelineInitializer initializer = (ch, promise) -> {
             ch.pipeline().addLast(this.hf.getDecoders());
             ch.pipeline().addLast("negotiator", this.snf
                     .getSessionNegotiator(dispatcherDependencies, ch, promise));
index 593a5b58503029392c3685d17957394b02b1c123..34f1c67c9330d606027203d9f85a22c1f4fd573f 100644 (file)
@@ -85,13 +85,13 @@ public class LabelSubobjectParserTest {
             parser.parseLabel(null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseLabel(Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -111,13 +111,13 @@ public class LabelSubobjectParserTest {
             parser.parseLabel(null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseLabel(Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 }
index 441e939e9b3b05e0e127fafd74fe2d98edaf2c8b..f97a13ec8e196e229e9b62901cf5d38ac2a97a90 100644 (file)
@@ -169,13 +169,13 @@ public class PCEPEROSubobjectParserTest {
             parser.parseSubobject(null, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -196,13 +196,13 @@ public class PCEPEROSubobjectParserTest {
             parser.parseSubobject(null, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
index 27e6f5100c14017b90a0a9fc2cb13a2d5a05be6e..ae0c01bb43814288c4b5c21a466abc52a99f9617 100644 (file)
@@ -207,13 +207,13 @@ public class PCEPObjectParserTest {
             parser.parseObject(new ObjectHeaderImpl(true, true), null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -239,13 +239,13 @@ public class PCEPObjectParserTest {
             parser.parseObject(new ObjectHeaderImpl(true, true), null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -780,13 +780,13 @@ public class PCEPObjectParserTest {
             parser.parseObject(new ObjectHeaderImpl(true, true), null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -827,13 +827,13 @@ public class PCEPObjectParserTest {
             parser.parseObject(new ObjectHeaderImpl(true, true), null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -879,13 +879,13 @@ public class PCEPObjectParserTest {
             parser.parseObject(new ObjectHeaderImpl(true, true), null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -989,13 +989,13 @@ public class PCEPObjectParserTest {
             parser.parseObject(new ObjectHeaderImpl(true, true), null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -1081,13 +1081,13 @@ public class PCEPObjectParserTest {
             parser.parseObject(new ObjectHeaderImpl(true, true), null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -1228,13 +1228,13 @@ public class PCEPObjectParserTest {
             parser.parseObject(new ObjectHeaderImpl(true, true), null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
index 94d2b3b6707ac63d4a006f8d4cdc40b5ff8fbac5..3f15b34bc56345deec350642304cfccac1288e43 100644 (file)
@@ -143,13 +143,13 @@ public class PCEPRROSubobjectParserTest {
             parser.parseSubobject(null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -171,13 +171,13 @@ public class PCEPRROSubobjectParserTest {
             parser.parseSubobject(null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -202,13 +202,13 @@ public class PCEPRROSubobjectParserTest {
             parser.parseSubobject(null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
index 5c8aa82fcfe098a9b43ccf2effbde89712f3026f..f11ccd1904b861b410df42872bb80b8d1424d844 100644 (file)
@@ -88,13 +88,13 @@ public class PCEPXROSubobjectParserTest {
             parser.parseSubobject(null, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -151,13 +151,13 @@ public class PCEPXROSubobjectParserTest {
             parser.parseSubobject(null, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -179,13 +179,13 @@ public class PCEPXROSubobjectParserTest {
             parser.parseSubobject(null, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -207,13 +207,13 @@ public class PCEPXROSubobjectParserTest {
             parser.parseSubobject(null, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -236,13 +236,13 @@ public class PCEPXROSubobjectParserTest {
             parser.parseSubobject(null, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -268,13 +268,13 @@ public class PCEPXROSubobjectParserTest {
             parser.parseSubobject(null, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 }
index 346b2783d3037e99d276d8b5f08e086568e7aeba..68430d1178b6ce6c63b48e906c2d4568b2cdf9bf 100644 (file)
@@ -9,15 +9,15 @@
 package org.opendaylight.protocol.pcep.impl;
 
 import io.netty.buffer.ByteBuf;
-
 import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
 import org.opendaylight.protocol.pcep.parser.object.AbstractVendorInformationObjectParser;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.EnterpriseSpecificInformation;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 public class TestVendorInformationObjectParser extends AbstractVendorInformationObjectParser {
 
-    private static final EnterpriseNumber TEST_ENTERPRISE_NUMBER = new EnterpriseNumber(0L);
+    private static final EnterpriseNumber TEST_ENTERPRISE_NUMBER = new EnterpriseNumber(Uint32.ZERO);
 
     public TestVendorInformationObjectParser() {
         super(0, 0);
index cd88de3e2d0e501e668fcc624a8134468770a74b..7243542b28ca0fb010aa91c030bd5442540ec076 100644 (file)
@@ -12,10 +12,11 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.pcep.parser.tlv.AbstractVendorInformationTlvParser;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.EnterpriseSpecificInformation;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 public class TestVendorInformationTlvParser extends AbstractVendorInformationTlvParser {
 
-    private static final EnterpriseNumber TEST_ENTERPRISE_NUMBER = new EnterpriseNumber(0L);
+    private static final EnterpriseNumber TEST_ENTERPRISE_NUMBER = new EnterpriseNumber(Uint32.ZERO);
 
     @Override
     public void serializeEnterpriseSpecificInformation(
index b601aa33fb959bba19e7dc10612390fb7ec598c1..976fe25be69adf39ce48c045927e9f6cf6114bcf 100644 (file)
@@ -39,7 +39,7 @@ final class PCCTunnelBuilder {
         for (int i = 1; i <= lsps; i++) {
             final PCCTunnel tunnel = new PCCTunnel(MsgBuilderUtil.getDefaultPathName(address, Uint32.valueOf(i)),
                     PCC_DELEGATION, LspType.PCC_LSP, createPath(Lists.newArrayList(DEFAULT_ENDPOINT_HOP)));
-            tunnels.put(new PlspId((long) i), tunnel);
+            tunnels.put(new PlspId(Uint32.valueOf(i)), tunnel);
         }
         return tunnels;
     }
index bf2445e02f1fa323031ff8a676ec23d78ea04379..4cffba7181a7153dc95bce84756b11f8320381ba 100644 (file)
@@ -194,7 +194,7 @@ public final class PCCTunnelManagerImpl implements PCCTunnelManager {
     }
 
     protected void addTunnel(final Requests request, final PCCSession session) {
-        final PlspId plspId = new PlspId(this.plspIDsCounter.incrementAndGet());
+        final PlspId plspId = new PlspId(Uint32.valueOf(this.plspIDsCounter.incrementAndGet()));
         final PCCTunnel tunnel = new PCCTunnel(request.getLsp().getTlvs().getSymbolicPathName()
                 .getPathName().getValue(), session.getId(), LspType.PCE_LSP, reqToRptPath(request));
         sendToAll(tunnel, plspId, request.getEro().getSubobject(),
index 6ea2217c923517f0a16b6d963b1aa44d21f1e8e5..320338b157b6a24538792c241da7d3994009f8a9 100644 (file)
@@ -53,6 +53,7 @@ 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.rsvp.rev150820.Ipv4ExtendedTunnelId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId;
+import org.opendaylight.yangtools.yang.common.Uint16;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.common.Uint64;
 
@@ -143,7 +144,7 @@ public final class MsgBuilderUtil {
                                         .setIpv4TunnelSenderAddress(new Ipv4AddressNoZone(tunnelSender))
                                         .setIpv4ExtendedTunnelId(
                                                 new Ipv4ExtendedTunnelId(extendedTunnelAddress))
-                                        .build()).build()).setTunnelId(new TunnelId(lspId.intValue())).build());
+                                        .build()).build()).setTunnelId(new TunnelId(Uint16.valueOf(lspId))).build());
         if (symbolicPathName) {
             if (symbolicName.isPresent()) {
                 tlvs.setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(
index 9f088433178b8ded44a2d008d6075fbc7ecfbe48..cc60ea9d4a5a78791e47c5721ebff9acc885975b 100644 (file)
@@ -17,6 +17,7 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.Ipv6Util;
@@ -170,9 +171,11 @@ public abstract class AbstractSrSubobjectParser {
                         .setLocalIpAddress(new IpAddressNoZone(Ipv6Util.noZoneAddressForByteBuf(buffer)))
                         .setRemoteIpAddress(new IpAddressNoZone(Ipv6Util.noZoneAddressForByteBuf(buffer))).build();
             case Unnumbered:
-                return new UnnumberedAdjacencyBuilder().setLocalNodeId(buffer.readUnsignedInt())
-                        .setLocalInterfaceId(buffer.readUnsignedInt()).setRemoteNodeId(buffer.readUnsignedInt())
-                        .setRemoteInterfaceId(buffer.readUnsignedInt()).build();
+                return new UnnumberedAdjacencyBuilder()
+                        .setLocalNodeId(ByteBufUtils.readUint32(buffer))
+                        .setLocalInterfaceId(ByteBufUtils.readUint32(buffer))
+                        .setRemoteNodeId(ByteBufUtils.readUint32(buffer))
+                        .setRemoteInterfaceId(ByteBufUtils.readUint32(buffer)).build();
             default:
                 return null;
         }
index 4c8b99e39a86fb9e8a6fb30ac352636d464a3876..f7ec904bee47784b42d4c50e7eaccbcaeaecd6d0 100644 (file)
@@ -5,7 +5,6 @@
  * 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.segment.routing;
 
 import java.net.InetSocketAddress;
@@ -14,6 +13,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.seg
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.Tlvs1Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.sr.pce.capability.tlv.SrPceCapabilityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 public class PCEPSegmentRoutingCapability implements PCEPCapability {
 
@@ -27,7 +27,7 @@ public class PCEPSegmentRoutingCapability implements PCEPCapability {
     public void setCapabilityProposal(final InetSocketAddress address, final TlvsBuilder builder) {
         if (this.isSegmentRoutingCapable) {
             builder.addAugmentation(Tlvs1.class,
-                    new Tlvs1Builder().setSrPceCapability(new SrPceCapabilityBuilder().setMsd((short) 0).build())
+                    new Tlvs1Builder().setSrPceCapability(new SrPceCapabilityBuilder().setMsd(Uint8.ZERO).build())
                             .build());
         }
     }
index 02e7b194134da6f194551c753b68839268baea13..e7b52fa9e957fbe8ed2ce57ed423ff31f05fcf9d 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.protocol.pcep.segment.routing;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.pcep.spi.TlvUtil;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.sr.pce.capability.tlv.SrPceCapability;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev181109.sr.pce.capability.tlv.SrPceCapabilityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
@@ -30,7 +31,7 @@ public class SrPceCapabilityTlvParser implements TlvParser, TlvSerializer {
 
     @Override
     public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
-        Preconditions.checkArgument(tlv instanceof SrPceCapability, "SrPceCapability is mandatory.");
+        checkArgument(tlv instanceof SrPceCapability, "SrPceCapability is mandatory.");
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
         body.writerIndex(OFFSET);
         writeUnsignedByte(((SrPceCapability) tlv).getMsd(), body);
@@ -42,7 +43,8 @@ public class SrPceCapabilityTlvParser implements TlvParser, TlvSerializer {
         if (buffer == null) {
             return null;
         }
-        final short msd = buffer.readerIndex(OFFSET).readUnsignedByte();
-        return new SrPceCapabilityBuilder().setMsd(msd).build();
+        return new SrPceCapabilityBuilder()
+                .setMsd(ByteBufUtils.readUint8(buffer.readerIndex(OFFSET)))
+                .build();
     }
 }
index 5bfc1ef9f332ea47264dee45b6604c77ef54e1cd..ceb164f1e10659d7cc7200c03a96f7cfb8ff6df1 100644 (file)
@@ -12,6 +12,7 @@ import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort
 
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey;
@@ -19,6 +20,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 /**
  * Parser for {@link PathKey}.
@@ -41,7 +43,7 @@ public abstract class AbstractEROPathKeySubobjectParser implements EROSubobjectP
         checkArgument(buffer != null && buffer.isReadable(),
                 "Array of bytes is mandatory. Can't be null or empty.");
         checkContentLength(buffer.readableBytes());
-        final int pathKey = buffer.readUnsignedShort();
+        final Uint16 pathKey = ByteBufUtils.readUint16(buffer);
         final byte[] pceId = readPceId(buffer);
         final PathKeyBuilder pBuilder = new PathKeyBuilder();
         pBuilder.setPceId(new PceId(pceId));
index 7b61ee8f4abc5e4c52d101449887a8595371d684..640a26a2be9bc31ee94c8f2e8ec9afa1e969427c 100644 (file)
@@ -18,6 +18,7 @@ import java.util.Optional;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
@@ -89,7 +90,7 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
             final ObjectHeader header = new ObjectHeaderImpl(flags.get(PROCESSED), flags.get(IGNORED));
 
             if (VendorInformationUtil.isVendorInformationObject(objClass, objType)) {
-                final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(bytesToPass.readUnsignedInt());
+                final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(ByteBufUtils.readUint32(bytesToPass));
                 final Optional<? extends Object> obj = this.registry.parseVendorInformationObject(enterpriseNumber,
                     header, bytesToPass);
                 if (obj.isPresent()) {
index 8fd30c66f477605351b371bda16dd6765fbb3960..54414d26f86f8a9d021f450f687e63ff7cd30e7e 100644 (file)
@@ -15,6 +15,7 @@ import io.netty.buffer.ByteBufUtil;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv;
@@ -54,7 +55,7 @@ public abstract class AbstractObjectWithTlvsParser<T> extends CommonObjectParser
             LOG.trace("Parsing PCEP TLV : {}", ByteBufUtil.hexDump(tlvBytes));
 
             if (VendorInformationUtil.isVendorInformationTlv(type)) {
-                final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(tlvBytes.readUnsignedInt());
+                final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(ByteBufUtils.readUint32(tlvBytes));
                 final Optional<VendorInformationTlv> viTlv = this.viTlvReg.parseVendorInformationTlv(enterpriseNumber,
                     tlvBytes);
                 if (viTlv.isPresent()) {
index 0871128d239f94c57322cd4b9f1b04fc4d962cb1..56f67e66a92c909f26f67a1d80c7c7424d873150 100644 (file)
@@ -14,6 +14,8 @@ import java.io.Serializable;
  */
 final class PCEPErrorIdentifier implements Serializable {
     private static final long serialVersionUID = 2434590156751699872L;
+
+    // FIXME: these should be Uint8s
     private final short type;
     private final short value;
 
index 48b8548de73467c8d288c4feb1c8b433a6d5b34e..ee521bb738eca8d0473ca412c5eb23f81219de0b 100644 (file)
@@ -365,6 +365,7 @@ public enum PCEPErrors {
         return this.errorId;
     }
 
+    // FIXME: these should be Uint8s
     public short getErrorType() {
         return this.errorId.getType();
     }
index 71cfb6e76ceb4e28a2b4081872279f6ae98bbb31..ccdab8a7fdfb9e07df096a03bb40266816ae849a 100755 (executable)
@@ -69,6 +69,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,7 +83,7 @@ import org.slf4j.LoggerFactory;
  */
 public abstract class AbstractTopologySessionListener<S, L> implements TopologySessionListener, TopologySessionStats {
     static final MessageHeader MESSAGE_HEADER = new MessageHeader() {
-        private final ProtocolVersion version = new ProtocolVersion((short) 1);
+        private final ProtocolVersion version = new ProtocolVersion(Uint8.ONE);
 
         @Override
         public Class<MessageHeader> implementedInterface() {
index ad28c5b8a077682af7dcde7e017ce1fa1b8a623d..c092700b073c860be6e7f270aea7e5b69334cb27 100644 (file)
@@ -92,11 +92,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.pcep.client.attributes.path.computation.client.reported.lsp.Path;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 class Stateful07TopologySessionListener extends AbstractTopologySessionListener<SrpIdNumber, PlspId> {
     private static final Logger LOG = LoggerFactory.getLogger(Stateful07TopologySessionListener.class);
+    private static final PlspId PLSPID_ZERO = new PlspId(Uint32.ZERO);
 
     private final AtomicLong requestId = new AtomicLong(1L);
 
@@ -202,7 +204,7 @@ class Stateful07TopologySessionListener extends AbstractTopologySessionListener<
     private SrpIdNumber createUpdateMessageSync(final PcupdMessageBuilder pcupdMessageBuilder) {
         final UpdatesBuilder updBuilder = new UpdatesBuilder();
         // LSP mandatory in Upd
-        final Lsp lsp = new LspBuilder().setPlspId(new PlspId(0L)).setSync(Boolean.TRUE).build();
+        final Lsp lsp = new LspBuilder().setPlspId(PLSPID_ZERO).setSync(Boolean.TRUE).build();
         // SRP Mandatory in Upd
         final SrpBuilder srpBuilder = new SrpBuilder();
         // not sue whether use 0 instead of nextRequest() or do not insert srp == SRP-ID-number = 0
@@ -333,7 +335,7 @@ class Stateful07TopologySessionListener extends AbstractTopologySessionListener<
         return true;
     }
 
-    private Path buildPath(final Reports report, final Srp srp, final Lsp lsp) {
+    private static Path buildPath(final Reports report, final Srp srp, final Lsp lsp) {
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.pcep.client
                 .attributes.path.computation.client.reported.lsp.PathBuilder pb = new org.opendaylight.yang.gen.v1
                 .urn.opendaylight.params.xml.ns.yang.topology.pcep.rev181109.pcep.client.attributes.path.computation
@@ -386,7 +388,7 @@ class Stateful07TopologySessionListener extends AbstractTopologySessionListener<
     }
 
     private SrpIdNumber nextRequest() {
-        return new SrpIdNumber(this.requestId.getAndIncrement());
+        return new SrpIdNumber(Uint32.valueOf(this.requestId.getAndIncrement()));
     }
 
     @Override
@@ -734,9 +736,9 @@ class Stateful07TopologySessionListener extends AbstractTopologySessionListener<
                     new SymbolicPathNameBuilder().setPathName(new SymbolicPathName(this.input.getName()
                             .getBytes(StandardCharsets.UTF_8))).build());
 
-            final SrpBuilder srpBuilder = new SrpBuilder();
-            srpBuilder.setOperationId(nextRequest());
-            srpBuilder.setProcessingRule(Boolean.TRUE);
+            final SrpBuilder srpBuilder = new SrpBuilder()
+                    .setOperationId(nextRequest())
+                    .setProcessingRule(Boolean.TRUE);
             if (!PSTUtil.isDefaultPST(args.getPathSetupType())) {
                 srpBuilder.setTlvs(
                         new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf
@@ -745,15 +747,20 @@ class Stateful07TopologySessionListener extends AbstractTopologySessionListener<
             }
             rb.setSrp(srpBuilder.build());
 
-            rb.setLsp(new LspBuilder().setAdministrative(inputLsp.isAdministrative()).setDelegate(
-                    inputLsp.isDelegate()).setPlspId(new PlspId(0L)).setTlvs(tlvsBuilder.build()).build());
-
-            final PcinitiateMessageBuilder ib = new PcinitiateMessageBuilder(MESSAGE_HEADER);
-            ib.setRequests(Collections.singletonList(rb.build()));
+            rb.setLsp(new LspBuilder()
+                .setAdministrative(inputLsp.isAdministrative())
+                .setDelegate(inputLsp.isDelegate())
+                .setPlspId(PLSPID_ZERO)
+                .setTlvs(tlvsBuilder.build())
+                .build());
 
             // Send the message
-            return sendMessage(new PcinitiateBuilder().setPcinitiateMessage(ib.build()).build(),
-                    rb.getSrp().getOperationId(), this.input.getArguments().getMetadata());
+            return sendMessage(new PcinitiateBuilder()
+                .setPcinitiateMessage(new PcinitiateMessageBuilder(MESSAGE_HEADER)
+                    .setRequests(Collections.singletonList(rb.build()))
+                    .build())
+                .build(),
+                rb.getSrp().getOperationId(), this.input.getArguments().getMetadata());
         }
     }
 
index b295c41caa114baad19843268e8e253fd83df44a..b2f500beed87d809e1e329cd95814e72a9bee27d 100644 (file)
@@ -7,8 +7,9 @@
  */
 package org.opendaylight.bgpcep.programming;
 
-import java.math.BigInteger;
+import java.util.concurrent.TimeUnit;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.Nanotime;
+import org.opendaylight.yangtools.yang.common.Uint64;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -17,8 +18,8 @@ import org.slf4j.LoggerFactory;
  */
 public final class NanotimeUtil {
     private static final Logger LOG = LoggerFactory.getLogger(NanotimeUtil.class);
-    private static final BigInteger MILLION = BigInteger.valueOf(1000000);
-    private static volatile BigInteger nanoTimeOffset = null;
+
+    private static volatile Long nanoTimeOffset = null;
 
     private NanotimeUtil() {
         throw new UnsupportedOperationException();
@@ -30,7 +31,8 @@ public final class NanotimeUtil {
      * @return Nanotime object filled with current time in nanoseconds.
      */
     public static Nanotime currentTime() {
-        return new Nanotime(BigInteger.valueOf(System.currentTimeMillis()).multiply(MILLION));
+        final long millis = Uint64.valueOf(System.currentTimeMillis()).longValue();
+        return new Nanotime(Uint64.fromLongBits(TimeUnit.MILLISECONDS.toNanos(millis)));
     }
 
     /**
@@ -42,7 +44,7 @@ public final class NanotimeUtil {
         if (nanoTimeOffset == null) {
             calibrate();
         }
-        return new Nanotime(BigInteger.valueOf(System.nanoTime()).add(nanoTimeOffset));
+        return new Nanotime(Uint64.fromLongBits(System.nanoTime() + nanoTimeOffset.longValue()));
     }
 
     /**
@@ -58,9 +60,9 @@ public final class NanotimeUtil {
 
         LOG.debug("Calibrated currentTime and nanoTime to {}m <= {}n <= {}m <= {}n", tm1, nt1, tm2, nt2);
 
-        final BigInteger tm = BigInteger.valueOf(tm1).add(BigInteger.valueOf(tm2)).divide(BigInteger.valueOf(2));
-        final BigInteger nt = BigInteger.valueOf(nt1).add(BigInteger.valueOf(nt2)).divide(BigInteger.valueOf(2));
+        final long tm = (tm1 + tm2) / 2;
+        final long nt = (nt1 + nt2) / 2;
 
-        nanoTimeOffset = tm.multiply(MILLION).subtract(nt);
+        nanoTimeOffset = Long.valueOf(TimeUnit.MILLISECONDS.toNanos(tm) - nt);
     }
 }
index 66a7be7b1f2f166ee307943ecb6fd9ca84856472..829710dfc9ad84d829e0120f5395e0d62ef52593 100644 (file)
@@ -5,12 +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.rsvp.parser.impl.subobject;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeShort;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
@@ -19,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.as.number._case.AsNumberBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 public final class AsNumberCaseParser {
     private static final int CONTENT_LENGTH = 2;
@@ -28,21 +28,23 @@ public final class AsNumberCaseParser {
     }
 
     public static AsNumberCase parseSubobject(final ByteBuf buffer) throws RSVPParsingException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
-            "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
                 + "; " + "Expected: " + CONTENT_LENGTH + ".");
         }
-        return new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber((long) buffer
-            .readUnsignedShort())).build()).build();
+        return new AsNumberCaseBuilder()
+                .setAsNumber(new AsNumberBuilder()
+                    .setAsNumber(new AsNumber(Uint32.valueOf(buffer.readUnsignedShort())))
+                    .build())
+                .build();
     }
 
 
     public static ByteBuf serializeSubobject(final AsNumberCase asCase) {
         final AsNumberSubobject asNumber = asCase.getAsNumber();
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
-        Preconditions.checkArgument(asNumber.getAsNumber() != null, "AsNumber is mandatory.");
+        checkArgument(asNumber.getAsNumber() != null, "AsNumber is mandatory.");
         writeShort(asNumber.getAsNumber().getValue().shortValue(), body);
         return body;
     }
index 32e147d9425adc42ab29bb6c9f18bfada39962c3..b62c3408d74df36652cd370995d14f1804c8ae9d 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.protocol.rsvp.parser.impl.subobject.label;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
 import com.google.common.base.Preconditions;
@@ -16,6 +17,7 @@ import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.rsvp.parser.spi.LabelParser;
 import org.opendaylight.protocol.rsvp.parser.spi.LabelSerializer;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCaseBuilder;
@@ -33,21 +35,21 @@ public class Type1LabelParser implements LabelParser, LabelSerializer {
 
     @Override
     public LabelType parseLabel(final ByteBuf buffer) throws RSVPParsingException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
-            "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != LABEL_LENGTH) {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; "
                 + "Expected: " + LABEL_LENGTH + ".");
         }
-        return new Type1LabelCaseBuilder().setType1Label(new Type1LabelBuilder().setType1Label(
-            buffer.readUnsignedInt()).build()).build();
+        return new Type1LabelCaseBuilder()
+                .setType1Label(new Type1LabelBuilder().setType1Label(ByteBufUtils.readUint32(buffer)).build())
+                .build();
     }
 
     @Override
     public void serializeLabel(final boolean unidirectional, final boolean global, final LabelType subobject,
         final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject instanceof Type1LabelCase,
-            "Unknown Label Subobject instance. Passed {}. Needed Type1LabelCase.", subobject.getClass());
+        checkArgument(subobject instanceof Type1LabelCase,
+            "Unknown Label Subobject instance. Passed %s. Needed Type1LabelCase.", subobject.getClass());
         final ByteBuf body = Unpooled.buffer(LABEL_LENGTH);
         final Type1Label type1Label = ((Type1LabelCase) subobject).getType1Label();
         Preconditions.checkArgument(type1Label != null, "Type1Label is mandatory.");
index 133844007a8abbf4dbb9696110614e8fcce085ed..48b348088b99a5d7082e4c14946aafeaa8458fe3 100644 (file)
@@ -5,17 +5,17 @@
  * 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.rsvp.parser.impl.subobject.label;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.rsvp.parser.spi.LabelParser;
 import org.opendaylight.protocol.rsvp.parser.spi.LabelSerializer;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCaseBuilder;
@@ -37,32 +37,33 @@ public class WavebandSwitchingLabelParser implements LabelParser, LabelSerialize
 
     @Override
     public final LabelType parseLabel(final ByteBuf buffer) throws RSVPParsingException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
-            "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
                 + "; Expected: " + CONTENT_LENGTH + ".");
         }
-        final WavebandSwitchingLabelBuilder builder = new WavebandSwitchingLabelBuilder();
-        builder.setWavebandId(buffer.readUnsignedInt());
-        builder.setStartLabel(buffer.readUnsignedInt());
-        builder.setEndLabel(buffer.readUnsignedInt());
-        return new WavebandSwitchingLabelCaseBuilder().setWavebandSwitchingLabel(builder.build()).build();
+        return new WavebandSwitchingLabelCaseBuilder()
+                .setWavebandSwitchingLabel(new WavebandSwitchingLabelBuilder()
+                    .setWavebandId(ByteBufUtils.readUint32(buffer))
+                    .setStartLabel(ByteBufUtils.readUint32(buffer))
+                    .setEndLabel(ByteBufUtils.readUint32(buffer))
+                    .build())
+                .build();
     }
 
     @Override
     public final void serializeLabel(final boolean unidirectional, final boolean global, final LabelType subobject,
         final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject instanceof WavebandSwitchingLabelCase,
-            "Unknown Label Subobject instance. Passed {}. Needed WavebandSwitchingLabelCase.",
+        checkArgument(subobject instanceof WavebandSwitchingLabelCase,
+            "Unknown Label Subobject instance. Passed %s. Needed WavebandSwitchingLabelCase.",
             subobject.getClass());
         final WavebandSwitchingLabel obj = ((WavebandSwitchingLabelCase) subobject).getWavebandSwitchingLabel();
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
-        Preconditions.checkArgument(obj.getWavebandId() != null, "WavebandId is mandatory.");
+        checkArgument(obj.getWavebandId() != null, "WavebandId is mandatory.");
         writeUnsignedInt(obj.getWavebandId(), body);
-        Preconditions.checkArgument(obj.getStartLabel() != null, "StartLabel is mandatory.");
+        checkArgument(obj.getStartLabel() != null, "StartLabel is mandatory.");
         writeUnsignedInt(obj.getStartLabel(), body);
-        Preconditions.checkArgument(obj.getEndLabel() != null, "EndLabel is mandatory.");
+        checkArgument(obj.getEndLabel() != null, "EndLabel is mandatory.");
         writeUnsignedInt(obj.getEndLabel(), body);
         LabelUtil.formatLabel(CTYPE, unidirectional, global, body, buffer);
     }
index 07f76dcc6b6ef3af7075ab06cccd1d54f8c0e373..accd2c9fc3168ae367870326fc40486a99844a81 100644 (file)
@@ -15,6 +15,7 @@ import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.rsvp.parser.spi.RROSubobjectParser;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer;
@@ -22,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 public class RROPathKey128SubobjectParser implements RROSubobjectParser {
 
@@ -53,7 +55,7 @@ public class RROPathKey128SubobjectParser implements RROSubobjectParser {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; "
                 + "Expected: >" + CONTENT128_LENGTH + ".");
         }
-        final int pathKey = buffer.readUnsignedShort();
+        final Uint16 pathKey = ByteBufUtils.readUint16(buffer);
         final byte[] pceId = ByteArray.readBytes(buffer, PCE128_ID_F_LENGTH);
         final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
         final PathKeyBuilder pBuilder = new PathKeyBuilder();
index 16cefb96b0047bd44d02126059aef0e2f76a2d1b..a1eaa8248dea4d9a31da4fd8d97df07453131c07 100644 (file)
@@ -7,15 +7,16 @@
  */
 package org.opendaylight.protocol.rsvp.parser.impl.subobject.rro;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.rsvp.parser.spi.RROSubobjectParser;
 import org.opendaylight.protocol.rsvp.parser.spi.RROSubobjectSerializer;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer;
@@ -23,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.PathKeyCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 public class RROPathKey32SubobjectParser implements RROSubobjectParser, RROSubobjectSerializer {
 
@@ -38,13 +40,12 @@ public class RROPathKey32SubobjectParser implements RROSubobjectParser, RROSubob
 
     @Override
     public SubobjectContainer parseSubobject(final ByteBuf buffer) throws RSVPParsingException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
-            "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
                 + "; " + "Expected: >" + CONTENT_LENGTH + ".");
         }
-        final int pathKey = buffer.readUnsignedShort();
+        final Uint16 pathKey = ByteBufUtils.readUint16(buffer);
         final byte[] pceId = ByteArray.readBytes(buffer, PCE_ID_F_LENGTH);
         final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
         final PathKeyBuilder pBuilder = new PathKeyBuilder();
@@ -56,21 +57,21 @@ public class RROPathKey32SubobjectParser implements RROSubobjectParser, RROSubob
 
     @Override
     public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
+        checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
             "Unknown subobject instance.Passed %s. Needed PathKey.",
             subobject.getSubobjectType().getClass());
         final PathKeyCase pkcase = (PathKeyCase) subobject.getSubobjectType();
         final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects
             .subobject.type.path.key._case.PathKey pk = pkcase.getPathKey();
         final ByteBuf body = Unpooled.buffer();
-        Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
+        checkArgument(pk.getPceId() != null, "PceId is mandatory.");
 
         final byte[] pceId = pk.getPceId().getValue();
         if (pceId.length == RROPathKey128SubobjectParser.PCE128_ID_F_LENGTH) {
             RROPathKey128SubobjectParser.serializeSubobject(subobject, buffer);
         }
-        Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
-        Preconditions.checkArgument(pceId.length == PCE_ID_F_LENGTH, "PathKey 32Bit is mandatory.");
+        checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+        checkArgument(pceId.length == PCE_ID_F_LENGTH, "PathKey 32Bit is mandatory.");
         writeUnsignedShort(pk.getPathKey().getValue(), body);
         body.writeBytes(pceId);
         RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
index 5f2dd20c1c661d414f37eec88b1721f70ca3f0c1..b0d8f305e5c605b74c5ba6e9c8c40a84337ed1a9 100644 (file)
@@ -5,18 +5,18 @@
  * 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.rsvp.parser.impl.subobject.rro;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.rsvp.parser.spi.RROSubobjectParser;
 import org.opendaylight.protocol.rsvp.parser.spi.RROSubobjectSerializer;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.util.BitArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.UnnumberedSubobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainerBuilder;
@@ -41,8 +41,7 @@ public class RROUnnumberedInterfaceSubobjectParser implements RROSubobjectParser
 
     @Override
     public SubobjectContainer parseSubobject(final ByteBuf buffer) throws RSVPParsingException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
-            "Array of bytes is mandatory. Can't be null or empty.");
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; "
                 + "Expected: " + CONTENT_LENGTH + ".");
@@ -53,15 +52,15 @@ public class RROUnnumberedInterfaceSubobjectParser implements RROSubobjectParser
         builder.setProtectionInUse(flags.get(LPIU_F_OFFSET));
         final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
         buffer.skipBytes(RESERVED);
-        ubuilder.setRouterId(buffer.readUnsignedInt());
-        ubuilder.setInterfaceId(buffer.readUnsignedInt());
+        ubuilder.setRouterId(ByteBufUtils.readUint32(buffer));
+        ubuilder.setInterfaceId(ByteBufUtils.readUint32(buffer));
         builder.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build());
         return builder.build();
     }
 
     @Override
     public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase,
+        checkArgument(subobject.getSubobjectType() instanceof UnnumberedCase,
             "Unknown subobject instance. Passed %s. Needed UnnumberedCase.",
             subobject.getSubobjectType().getClass());
         final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
@@ -71,9 +70,9 @@ public class RROUnnumberedInterfaceSubobjectParser implements RROSubobjectParser
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
         flags.toByteBuf(body);
         body.writeZero(RESERVED);
-        Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
+        checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
         writeUnsignedInt(specObj.getRouterId(), body);
-        Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
+        checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
         writeUnsignedInt(specObj.getInterfaceId(), body);
         RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
     }
index e99725fb50feda13b8d68fe4de2938423e3ac307..dabc961e851dab743cbc219845e85f5c02c7a739 100644 (file)
@@ -5,18 +5,18 @@
  * 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.rsvp.parser.impl.subobject.xro;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectParser;
 import org.opendaylight.protocol.rsvp.parser.spi.XROSubobjectSerializer;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgSubobject;
@@ -37,33 +37,32 @@ public class XROSrlgSubobjectParser implements XROSubobjectParser, XROSubobjectS
     private static final int CONTENT_LENGTH = 6;
 
     @Override
-    public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory) throws
-        RSVPParsingException {
-        Preconditions.checkArgument(buffer != null && buffer.isReadable(),
-            "Array of bytes is mandatory. Can't be null or empty.");
+    public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory)
+            throws RSVPParsingException {
+        checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
         if (buffer.readableBytes() != CONTENT_LENGTH) {
             throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
                 + "; " + "Expected: " + CONTENT_LENGTH + ".");
         }
-        final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
-        builder.setMandatory(mandatory);
-        builder.setSubobjectType(new SrlgCaseBuilder().setSrlg(new SrlgBuilder().setSrlgId(new SrlgId(buffer
-            .readUnsignedInt())).build()).build());
+        final SubobjectContainerBuilder builder = new SubobjectContainerBuilder()
+                .setMandatory(mandatory)
+                .setSubobjectType(new SrlgCaseBuilder()
+                    .setSrlg(new SrlgBuilder().setSrlgId(new SrlgId(ByteBufUtils.readUint32(buffer))).build())
+                    .build());
         buffer.readByte();
-        builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()));
-        return builder.build();
+        return builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()))
+                .build();
     }
 
     @Override
     public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
-        Preconditions.checkArgument(subobject.getSubobjectType() instanceof SrlgCase,
-            "Unknown subobject instance. Passed %s. Needed SrlgCase.",
-            subobject.getSubobjectType().getClass());
+        checkArgument(subobject.getSubobjectType() instanceof SrlgCase,
+            "Unknown subobject instance. Passed %s. Needed SrlgCase.", subobject.getSubobjectType().getClass());
         final SrlgSubobject specObj = ((SrlgCase) subobject.getSubobjectType()).getSrlg();
         final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
-        Preconditions.checkArgument(specObj.getSrlgId() != null, "SrlgId is mandatory.");
+        checkArgument(specObj.getSrlgId() != null, "SrlgId is mandatory.");
         writeUnsignedInt(specObj.getSrlgId().getValue(), body);
-        Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
+        checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
         writeUnsignedByte((Uint8) null, body);
         writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
         XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
index 003e9640eaca10816782c3b0a27fc4fb433906c3..3f9bd2a5f3959517b2c0c12bac5b8f3851386950 100644 (file)
@@ -5,13 +5,14 @@
  * 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.rsvp.parser.impl.te;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.Ipv4Util;
 import org.opendaylight.protocol.util.Ipv6Util;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
@@ -31,7 +32,7 @@ public abstract class AbstractAssociationParser extends AbstractRSVPObjectParser
 
     @Override
     protected final void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
-        Preconditions.checkArgument(teLspObject instanceof AssociationObject, "AssociationObject is mandatory.");
+        checkArgument(teLspObject instanceof AssociationObject, "AssociationObject is mandatory.");
         final AssociationObject assObject = (AssociationObject) teLspObject;
 
         if (assObject.getIpAddress().getIpv4AddressNoZone() != null) {
@@ -49,10 +50,10 @@ public abstract class AbstractAssociationParser extends AbstractRSVPObjectParser
 
     @Override
     protected final RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
-        final AssociationObjectBuilder asso = new AssociationObjectBuilder();
-        asso.setAssociationType(AssociationType.forValue(byteBuf.readUnsignedShort()));
-        asso.setAssociationId(byteBuf.readUnsignedShort());
-        asso.setIpAddress(parseAssociationIpAddress(byteBuf));
-        return asso.build();
+        return new AssociationObjectBuilder()
+                .setAssociationType(AssociationType.forValue(byteBuf.readUnsignedShort()))
+                .setAssociationId(ByteBufUtils.readUint16(byteBuf))
+                .setIpAddress(parseAssociationIpAddress(byteBuf))
+                .build();
     }
 }
index 3dbb69c1c2da4c16a27385b6f90b429b04b96c36..c4e91ce042ffee983cefcf933a9912967ffe1081 100644 (file)
@@ -12,6 +12,7 @@ import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.FastRerouteFlags;
@@ -26,16 +27,16 @@ public final class FastRerouteObjectParser extends AbstractRSVPObjectParser {
 
     @Override
     protected RsvpTeObject localParseObject(final ByteBuf byteBuf) {
-        final BasicFastRerouteObjectBuilder builder = new BasicFastRerouteObjectBuilder();
-        builder.setSetupPriority(byteBuf.readUnsignedByte());
-        builder.setHoldPriority(byteBuf.readUnsignedByte());
-        builder.setHopLimit(byteBuf.readUnsignedByte());
-        builder.setFlags(FastRerouteFlags.forValue(byteBuf.readUnsignedByte()));
+        final BasicFastRerouteObjectBuilder builder = new BasicFastRerouteObjectBuilder()
+                .setSetupPriority(ByteBufUtils.readUint8(byteBuf))
+                .setHoldPriority(ByteBufUtils.readUint8(byteBuf))
+                .setHopLimit(ByteBufUtils.readUint8(byteBuf))
+                .setFlags(FastRerouteFlags.forValue(byteBuf.readUnsignedByte()));
         final ByteBuf v = byteBuf.readSlice(METRIC_VALUE_F_LENGTH);
         builder.setBandwidth(new Bandwidth(ByteArray.readAllBytes(v)));
-        builder.setIncludeAny(new AttributeFilter(byteBuf.readUnsignedInt()));
-        builder.setExcludeAny(new AttributeFilter(byteBuf.readUnsignedInt()));
-        builder.setIncludeAll(new AttributeFilter(byteBuf.readUnsignedInt()));
+        builder.setIncludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)));
+        builder.setExcludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)));
+        builder.setIncludeAll(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)));
         return builder.build();
     }
 
index 33dac52d7aaa95743276b78aa7b7871b47ac92b0..32a06aa5bf8657d6de2e6ee72f9366e17f37e9fd 100644 (file)
@@ -16,6 +16,7 @@ import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 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.rsvp.rev150820.RsvpTeObject;
@@ -47,18 +48,18 @@ public final class FlowSpecObjectParser extends AbstractRSVPObjectParser {
         byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
         //skip parameter ID 127 and 127 flags
         byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
-        final TspecObjectBuilder tBuilder = new TspecObjectBuilder();
-        tBuilder.setTokenBucketRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
-        tBuilder.setTokenBucketSize(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
-        tBuilder.setPeakDataRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
-        tBuilder.setMinimumPolicedUnit(byteBuf.readUnsignedInt());
-        tBuilder.setMaximumPacketSize(byteBuf.readUnsignedInt());
+        final TspecObjectBuilder tBuilder = new TspecObjectBuilder()
+                .setTokenBucketRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
+                .setTokenBucketSize(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
+                .setPeakDataRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
+                .setMinimumPolicedUnit(ByteBufUtils.readUint32(byteBuf))
+                .setMaximumPacketSize(ByteBufUtils.readUint32(byteBuf));
         builder.setTspecObject(tBuilder.build());
         if (builder.getServiceHeader().getIntValue() == 2) {
             //skip parameter ID 130, flags, lenght
             byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
             builder.setRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
-            builder.setSlackTerm(byteBuf.readUnsignedInt());
+            builder.setSlackTerm(ByteBufUtils.readUint32(byteBuf));
         }
         return builder.build();
     }
index c71661d7eac94d4fa459bcb56664afa76dfcee4f..c4482cf7fac5e02ca68f2cb494e8b1b8df9ff1cb 100644 (file)
@@ -5,15 +5,16 @@
  * 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.rsvp.parser.impl.te;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter;
@@ -29,22 +30,23 @@ public final class InformationalFastRerouteObjectParser extends AbstractRSVPObje
 
     @Override
     protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
-        final LegacyFastRerouteObjectBuilder builder = new LegacyFastRerouteObjectBuilder();
-        builder.setSetupPriority(byteBuf.readUnsignedByte());
-        builder.setHoldPriority(byteBuf.readUnsignedByte());
-        builder.setHopLimit(byteBuf.readUnsignedByte());
+        final LegacyFastRerouteObjectBuilder builder = new LegacyFastRerouteObjectBuilder()
+                .setSetupPriority(ByteBufUtils.readUint8(byteBuf))
+                .setHoldPriority(ByteBufUtils.readUint8(byteBuf))
+                .setHopLimit(ByteBufUtils.readUint8(byteBuf));
+
         //skip reserved
         byteBuf.skipBytes(ByteBufWriteUtil.ONE_BYTE_LENGTH);
         final ByteBuf v = byteBuf.readSlice(METRIC_VALUE_F_LENGTH);
         builder.setBandwidth(new Bandwidth(ByteArray.readAllBytes(v)));
-        builder.setIncludeAny(new AttributeFilter(byteBuf.readUnsignedInt()));
-        builder.setExcludeAny(new AttributeFilter(byteBuf.readUnsignedInt()));
+        builder.setIncludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)));
+        builder.setExcludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)));
         return builder.build();
     }
 
     @Override
     public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf byteAggregator) {
-        Preconditions.checkArgument(teLspObject instanceof LegacyFastRerouteObject, "FastRerouteObject is mandatory.");
+        checkArgument(teLspObject instanceof LegacyFastRerouteObject, "FastRerouteObject is mandatory.");
         final LegacyFastRerouteObject fastRerouteObject = (LegacyFastRerouteObject) teLspObject;
         serializeAttributeHeader(BODY_SIZE_C7, CLASS_NUM, CTYPE, byteAggregator);
 
index 690a611dcd385e572feedfcfb38c37f0cc8f4a4d..39d2abf9b75b25e63d687f22a42e7aee6f90cec7 100644 (file)
@@ -5,17 +5,17 @@
  * 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.rsvp.parser.impl.te;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 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.rsvp.rev150820.RsvpTeObject;
@@ -31,19 +31,20 @@ public final class MetricObjectParser extends AbstractRSVPObjectParser {
 
     @Override
     protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
-        final MetricObjectBuilder builder = new MetricObjectBuilder();
         byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
         final BitArray flags = BitArray.valueOf(byteBuf.readByte());
-        builder.setBound(flags.get(BOUND));
-        builder.setComputed(flags.get(COMPUTED));
-        builder.setMetricType(byteBuf.readUnsignedByte());
-        builder.setValue(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
-        return builder.build();
+
+        return new MetricObjectBuilder()
+                .setBound(flags.get(BOUND))
+                .setComputed(flags.get(COMPUTED))
+                .setMetricType(ByteBufUtils.readUint8(byteBuf))
+                .setValue(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
+                .build();
     }
 
     @Override
     public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
-        Preconditions.checkArgument(teLspObject instanceof MetricObject, "BandwidthObject is mandatory.");
+        checkArgument(teLspObject instanceof MetricObject, "BandwidthObject is mandatory.");
         final MetricObject metric = (MetricObject) teLspObject;
         serializeAttributeHeader(BODY_SIZE, CLASS_NUM, CTYPE, output);
         output.writeZero(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
index b51442560a43fde32a03f8a4f606de4f1e3f8f93..9642c7e2fd0524c83546d241d14d0e2c03c6eddf 100644 (file)
@@ -7,14 +7,15 @@
  */
 package org.opendaylight.protocol.rsvp.parser.impl.te;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 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.rsvp.rev150820.RsvpTeObject;
@@ -29,7 +30,6 @@ public class SenderTspecObjectParser extends AbstractRSVPObjectParser {
 
     @Override
     protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
-        final TspecObjectBuilder builder = new TspecObjectBuilder();
         //skip version number, reserved, Overall length
         byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
         //skip Service header, reserved, Length of service
@@ -37,17 +37,18 @@ public class SenderTspecObjectParser extends AbstractRSVPObjectParser {
         //skip Parameter ID, Parameter 127 flags, Parameter 127 length
         byteBuf.skipBytes(ByteBufWriteUtil.INT_BYTES_LENGTH);
 
-        builder.setTokenBucketRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
-        builder.setTokenBucketSize(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
-        builder.setPeakDataRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)));
-        builder.setMinimumPolicedUnit(byteBuf.readUnsignedInt());
-        builder.setMaximumPacketSize(byteBuf.readUnsignedInt());
-        return builder.build();
+        return new TspecObjectBuilder()
+                .setTokenBucketRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
+                .setTokenBucketSize(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
+                .setPeakDataRate(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
+                .setMinimumPolicedUnit(ByteBufUtils.readUint32(byteBuf))
+                .setMaximumPacketSize(ByteBufUtils.readUint32(byteBuf))
+                .build();
     }
 
     @Override
     public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
-        Preconditions.checkArgument(teLspObject instanceof TspecObject, "SenderTspecObject is mandatory.");
+        checkArgument(teLspObject instanceof TspecObject, "SenderTspecObject is mandatory.");
         final TspecObject tspecObj = (TspecObject) teLspObject;
         serializeAttributeHeader(BODY_SIZE, CLASS_NUM, CTYPE, output);
         output.writeZero(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
index e40c7e3c667d7b09c82da2ef46a4f6b0552c45dd..1a630ba950a01508f7c667a1ea33798aceeb9122 100644 (file)
@@ -5,10 +5,10 @@
  * 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.rsvp.parser.impl.te;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.nio.charset.StandardCharsets;
@@ -16,6 +16,7 @@ import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.BasicSessionAttributeObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.BasicSessionAttributeObjectBuilder;
@@ -35,15 +36,15 @@ public final class SessionAttributeLspObjectParser extends AbstractRSVPObjectPar
 
     @Override
     protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
-        final BasicSessionAttributeObjectBuilder builder = new BasicSessionAttributeObjectBuilder();
-        builder.setSetupPriority(byteBuf.readUnsignedByte());
-        builder.setHoldPriority(byteBuf.readUnsignedByte());
+        final BasicSessionAttributeObjectBuilder builder = new BasicSessionAttributeObjectBuilder()
+                .setSetupPriority(ByteBufUtils.readUint8(byteBuf))
+                .setHoldPriority(ByteBufUtils.readUint8(byteBuf));
         final BitArray bs = BitArray.valueOf(byteBuf.readByte());
         builder.setLocalProtectionDesired(bs.get(LOCAL_PROTECTION));
         builder.setLabelRecordingDesired(bs.get(LABEL_RECORDING));
         builder.setSeStyleDesired(bs.get(SE_STYLE));
-        final short nameLenght = byteBuf.readUnsignedByte();
-        final ByteBuf auxBuf = byteBuf.readSlice(nameLenght);
+        final short nameLength = byteBuf.readUnsignedByte();
+        final ByteBuf auxBuf = byteBuf.readSlice(nameLength);
         final String name = new String(ByteArray.readAllBytes(auxBuf), StandardCharsets.US_ASCII);
         builder.setSessionName(name);
         return builder.build();
@@ -51,8 +52,7 @@ public final class SessionAttributeLspObjectParser extends AbstractRSVPObjectPar
 
     @Override
     public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
-        Preconditions.checkArgument(teLspObject instanceof BasicSessionAttributeObject,
-            "SessionAttributeObject is mandatory.");
+        checkArgument(teLspObject instanceof BasicSessionAttributeObject, "SessionAttributeObject is mandatory.");
 
         final BasicSessionAttributeObject sessionObject = (BasicSessionAttributeObject) teLspObject;
         final ByteBuf sessionName = Unpooled.wrappedBuffer(StandardCharsets.US_ASCII.encode(sessionObject
index dd4356717f532a8797bae6324edd6825b22c4ba5..4f04467093ba2cf3b4787b8e4472b4dfb0d00daf 100644 (file)
@@ -7,7 +7,8 @@
  */
 package org.opendaylight.protocol.rsvp.parser.impl.te;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.nio.charset.StandardCharsets;
@@ -15,6 +16,7 @@ import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
 import org.opendaylight.protocol.rsvp.parser.spi.subobjects.AbstractRSVPObjectParser;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.SessionAttributeObjectWithResourcesAffinities;
@@ -27,13 +29,14 @@ public final class SessionAttributeLspRaObjectParser extends AbstractRSVPObjectP
 
     @Override
     protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
-        final SessionAttributeObjectWithResourcesAffinitiesBuilder builder = new
-            SessionAttributeObjectWithResourcesAffinitiesBuilder();
-        builder.setIncludeAny(new AttributeFilter(byteBuf.readUnsignedInt()));
-        builder.setExcludeAny(new AttributeFilter(byteBuf.readUnsignedInt()));
-        builder.setIncludeAll(new AttributeFilter(byteBuf.readUnsignedInt()));
-        builder.setSetupPriority(byteBuf.readUnsignedByte());
-        builder.setHoldPriority(byteBuf.readUnsignedByte());
+        final SessionAttributeObjectWithResourcesAffinitiesBuilder builder =
+                new SessionAttributeObjectWithResourcesAffinitiesBuilder()
+                    .setIncludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)))
+                    .setExcludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)))
+                    .setIncludeAll(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)))
+                    .setSetupPriority(ByteBufUtils.readUint8(byteBuf))
+                    .setHoldPriority(ByteBufUtils.readUint8(byteBuf));
+
         final BitArray bs = BitArray.valueOf(byteBuf.readByte());
         builder.setLocalProtectionDesired(bs.get(SessionAttributeLspObjectParser.LOCAL_PROTECTION));
         builder.setLabelRecordingDesired(bs.get(SessionAttributeLspObjectParser.LABEL_RECORDING));
@@ -47,7 +50,7 @@ public final class SessionAttributeLspRaObjectParser extends AbstractRSVPObjectP
 
     @Override
     public void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
-        Preconditions.checkArgument(teLspObject instanceof SessionAttributeObjectWithResourcesAffinities,
+        checkArgument(teLspObject instanceof SessionAttributeObjectWithResourcesAffinities,
             "SessionAttributeObject is mandatory.");
 
         final SessionAttributeObjectWithResourcesAffinities sessionObject =
index 377ed5ab8b7b4023a95564b4a65999071486a3a7..96e46efc63345100381d8e6b9851c581e26bc95c 100644 (file)
@@ -158,13 +158,13 @@ public class EROSubobjectParserTest {
             parser.parseSubobject(null, true);
             Assert.fail();
         } catch (final IllegalArgumentException e) {
-            Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            Assert.assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             Assert.fail();
         } catch (final IllegalArgumentException e) {
-            Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            Assert.assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
index 855b88d2b0ed98f3842bbc331dfa8b025655d71a..d23142a93b4eee9fcf7e54258bf4c8e68892c748 100644 (file)
@@ -82,13 +82,13 @@ public class LabelSubobjectParserTest {
             parser.parseLabel(null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseLabel(Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -108,13 +108,13 @@ public class LabelSubobjectParserTest {
             parser.parseLabel(null);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseLabel(Unpooled.EMPTY_BUFFER);
             fail();
         } catch (final IllegalArgumentException e) {
-            assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 }
index 68d405f8ea27fb8c1745752bd53dc2d2778336ab..de42e88510281067698015071f7ec602cacf8ae1 100644 (file)
@@ -132,13 +132,13 @@ public class RROSubobjectParserTest {
             parser.parseSubobject(null);
             Assert.fail();
         } catch (final IllegalArgumentException e) {
-            Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            Assert.assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER);
             Assert.fail();
         } catch (final IllegalArgumentException e) {
-            Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            Assert.assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -160,13 +160,13 @@ public class RROSubobjectParserTest {
             parser.parseSubobject(null);
             Assert.fail();
         } catch (final IllegalArgumentException e) {
-            Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            Assert.assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER);
             Assert.fail();
         } catch (final IllegalArgumentException e) {
-            Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            Assert.assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
index 1247fb1d2c9f406de4292c6c07057eb1621a7278..a93b5edb7f4e4067e2c4db7f3aa8149607b1e2a3 100644 (file)
@@ -139,13 +139,13 @@ public class XROSubobjectParserTest {
             parser.parseSubobject(null, true);
             Assert.fail();
         } catch (final IllegalArgumentException e) {
-            Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            Assert.assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             Assert.fail();
         } catch (final IllegalArgumentException e) {
-            Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            Assert.assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
@@ -194,13 +194,13 @@ public class XROSubobjectParserTest {
             parser.parseSubobject(null, true);
             Assert.fail();
         } catch (final IllegalArgumentException e) {
-            Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            Assert.assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
         try {
             parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
             Assert.fail();
         } catch (final IllegalArgumentException e) {
-            Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+            Assert.assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
         }
     }
 
index ae9b847bfd900e0cb004e29c49a101d0a133dee5..b54dfef179093e36037bb4e5080c4afd5a98e50c 100644 (file)
@@ -5,18 +5,19 @@
  * 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.rsvp.parser.spi.subobjects;
 
+import static com.google.common.base.Preconditions.checkArgument;
 import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
 
-import com.google.common.base.Preconditions;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 public class CommonPathKeyParser {
     protected CommonPathKeyParser() {
@@ -25,7 +26,7 @@ public class CommonPathKeyParser {
 
     public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
         .subobjects.subobject.type.path.key._case.PathKey parsePathKey(final int pceIdFLength, final ByteBuf buffer) {
-        final int pathKey = buffer.readUnsignedShort();
+        final Uint16 pathKey = ByteBufUtils.readUint16(buffer);
         final byte[] pceId = ByteArray.readBytes(buffer, pceIdFLength);
         final PathKeyBuilder pBuilder = new PathKeyBuilder();
         pBuilder.setPceId(new PceId(pceId));
@@ -36,9 +37,9 @@ public class CommonPathKeyParser {
     public static ByteBuf serializePathKey(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
         .rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKey pk) {
         final ByteBuf body = Unpooled.buffer();
-        Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+        checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
         writeUnsignedShort(pk.getPathKey().getValue(), body);
-        Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
+        checkArgument(pk.getPceId() != null, "PceId is mandatory.");
         body.writeBytes(pk.getPceId().getValue());
         return body;
     }
index 66ca6e7863819b86c7db4aecd4f6bc388c55608a..1d7d25b19fea744b6c37b65b2547b3e81ffcb7b6 100644 (file)
@@ -5,11 +5,12 @@
  * 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.rsvp.parser.spi.subobjects;
 
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
 import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.util.ByteBufUtils;
 import org.opendaylight.protocol.util.ByteBufWriteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCaseBuilder;
@@ -22,16 +23,18 @@ public class CommonUnnumberedInterfaceSubobjectParser {
     }
 
     protected static UnnumberedCase parseUnnumeredInterface(final ByteBuf buffer) {
-        final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
-        ubuilder.setRouterId(buffer.readUnsignedInt());
-        ubuilder.setInterfaceId(buffer.readUnsignedInt());
-        return new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build();
+        return new UnnumberedCaseBuilder()
+                .setUnnumbered(new UnnumberedBuilder()
+                    .setRouterId(ByteBufUtils.readUint32(buffer))
+                    .setInterfaceId(ByteBufUtils.readUint32(buffer))
+                    .build())
+                .build();
     }
 
     protected static void serializeUnnumeredInterface(final Unnumbered unnumbered, final ByteBuf body) {
-        Preconditions.checkArgument(unnumbered.getRouterId() != null, "RouterId is mandatory.");
+        checkArgument(unnumbered.getRouterId() != null, "RouterId is mandatory.");
         ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRouterId(), body);
-        Preconditions.checkArgument(unnumbered.getInterfaceId() != null, "InterfaceId is mandatory.");
+        checkArgument(unnumbered.getInterfaceId() != null, "InterfaceId is mandatory.");
         ByteBufWriteUtil.writeUnsignedInt(unnumbered.getInterfaceId(), body);
     }
 }
diff --git a/util/src/main/java/org/opendaylight/protocol/util/ByteBufUtils.java b/util/src/main/java/org/opendaylight/protocol/util/ByteBufUtils.java
new file mode 100644 (file)
index 0000000..8b6dbcf
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.util;
+
+import io.netty.buffer.ByteBuf;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
+
+/**
+ * Utility methods for interacting with {@link ByteBuf}s. These add a number of methods for reading and writing various
+ * data types from/to ByteBufs.
+ */
+public final class ByteBufUtils {
+    private ByteBufUtils() {
+
+    }
+
+    public static @NonNull Uint8 readUint8(final ByteBuf buf) {
+        return Uint8.fromByteBits(buf.readByte());
+    }
+
+    public static @NonNull Uint16 readUint16(final ByteBuf buf) {
+        return Uint16.fromShortBits(buf.readShort());
+    }
+
+    // TODO: this probably wants a dedicated concept
+    public static @NonNull Uint32 readUint24(final ByteBuf buf) {
+        return Uint32.fromIntBits(buf.readMedium());
+    }
+
+    public static @NonNull Uint32 readUint32(final ByteBuf buf) {
+        return Uint32.fromIntBits(buf.readInt());
+    }
+
+    public static @NonNull Uint64 readUint64(final ByteBuf buf) {
+        return Uint64.fromLongBits(buf.readLong());
+    }
+
+    public static void writeMandatory(final ByteBuf buf, final Byte value, final String name) {
+        buf.writeByte(nonNullArgument(value, name).byteValue());
+    }
+
+    public static void writeMandatory(final ByteBuf buf, final Short value, final String name) {
+        buf.writeShort(nonNullArgument(value, name).shortValue());
+    }
+
+    public static void writeMandatory(final ByteBuf buf, final Integer value, final String name) {
+        buf.writeInt(nonNullArgument(value, name).intValue());
+    }
+
+    public static void writeMandatory(final ByteBuf buf, final Long value, final String name) {
+        buf.writeLong(nonNullArgument(value, name).longValue());
+    }
+
+    public static void writeMandatory(final ByteBuf buf, final Uint8 value, final String name) {
+        buf.writeByte(nonNullArgument(value, name).byteValue());
+    }
+
+    public static void writeMandatory(final ByteBuf buf, final Uint16 value, final String name) {
+        buf.writeShort(nonNullArgument(value, name).shortValue());
+    }
+
+    public static void writeMandatory(final ByteBuf buf, final Uint32 value, final String name) {
+        buf.writeInt(nonNullArgument(value, name).intValue());
+    }
+
+    public static void writeMandatory(final ByteBuf buf, final Uint64 value, final String name) {
+        buf.writeLong(nonNullArgument(value, name).longValue());
+    }
+
+    public static void writeOptional(final ByteBuf buf, final @Nullable Byte value) {
+        if (value != null) {
+            buf.writeByte(value.byteValue());
+        }
+    }
+
+    public static void writeOptional(final ByteBuf buf, final @Nullable Short value) {
+        if (value != null) {
+            buf.writeShort(value.shortValue());
+        }
+    }
+
+    public static void writeOptional(final ByteBuf buf, final @Nullable Integer value) {
+        if (value != null) {
+            buf.writeInt(value.intValue());
+        }
+    }
+
+    public static void writeOptional(final ByteBuf buf, final @Nullable Long value) {
+        if (value != null) {
+            buf.writeLong(value.longValue());
+        }
+    }
+
+    public static void writeOptional(final ByteBuf buf, final @Nullable Uint8 value) {
+        if (value != null) {
+            buf.writeByte(value.byteValue());
+        }
+    }
+
+    public static void writeOptional(final ByteBuf buf, final @Nullable Uint16 value) {
+        if (value != null) {
+            buf.writeShort(value.shortValue());
+        }
+    }
+
+    public static void writeOptional(final ByteBuf buf, final @Nullable Uint32 value) {
+        if (value != null) {
+            buf.writeInt(value.intValue());
+        }
+    }
+
+    public static void writeOptional(final ByteBuf buf, final @Nullable Uint64 value) {
+        if (value != null) {
+            buf.writeLong(value.longValue());
+        }
+    }
+
+    public static void writeOrZero(final ByteBuf buf, final @Nullable Byte value) {
+        buf.writeByte(value != null ? value.byteValue() : 0);
+    }
+
+    public static void writeOrZero(final ByteBuf buf, final @Nullable Short value) {
+        buf.writeShort(value != null ? value.shortValue() : (short) 0);
+    }
+
+    public static void writeOrZero(final ByteBuf buf, final @Nullable Integer value) {
+        buf.writeInt(value != null ? value.intValue() : 0);
+    }
+
+    public static void writeOrZero(final ByteBuf buf, final @Nullable Long value) {
+        buf.writeLong(value != null ? value.longValue() : 0L);
+    }
+
+    public static void writeOrZero(final ByteBuf buf, final @Nullable Uint8 value) {
+        buf.writeByte(value != null ? value.byteValue() : 0);
+    }
+
+    public static void writeOrZero(final ByteBuf buf, final @Nullable Uint16 value) {
+        buf.writeShort(value != null ? value.shortValue() : (short) 0);
+    }
+
+    public static void writeOrZero(final ByteBuf buf, final @Nullable Uint32 value) {
+        buf.writeInt(value != null ? value.intValue() : 0);
+    }
+
+    public static void writeOrZero(final ByteBuf buf, final @Nullable Uint64 value) {
+        buf.writeLong(value != null ? value.longValue() : 0L);
+    }
+
+    private static <T> @NonNull T nonNullArgument(final @Nullable T obj, final String name) {
+        if (obj == null) {
+            throw new IllegalArgumentException(name + " is mandatory");
+        }
+        return obj;
+    }
+}
diff --git a/util/src/test/java/org/opendaylight/protocol/util/ByteBufUtilsTest.java b/util/src/test/java/org/opendaylight/protocol/util/ByteBufUtilsTest.java
new file mode 100644 (file)
index 0000000..a6af8c5
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
+
+public class ByteBufUtilsTest {
+
+    @Test
+    public void testByte() {
+        testWrite(Byte.valueOf((byte) 1), 1, ByteBufUtils::writeOptional, ByteBufUtils::writeOrZero,
+            ByteBufUtils::writeMandatory);
+    }
+
+    @Test
+    public void testShort() {
+        testWrite(Short.valueOf((short) 1), 2, ByteBufUtils::writeOptional, ByteBufUtils::writeOrZero,
+            ByteBufUtils::writeMandatory);
+    }
+
+    @Test
+    public void testInteger() {
+        testWrite(Integer.valueOf(1), 4, ByteBufUtils::writeOptional, ByteBufUtils::writeOrZero,
+            ByteBufUtils::writeMandatory);
+    }
+
+    @Test
+    public void testLong() {
+        testWrite(Long.valueOf(1L), 8, ByteBufUtils::writeOptional, ByteBufUtils::writeOrZero,
+            ByteBufUtils::writeMandatory);
+    }
+
+    @Test
+    public void testUint8() {
+        testRead(Uint8.ONE, ByteBufUtils::readUint8, (byte) 1);
+        testWrite(Uint8.ONE, 1, ByteBufUtils::writeOptional, ByteBufUtils::writeOrZero, ByteBufUtils::writeMandatory);
+    }
+
+    @Test
+    public void testUint16() {
+        testRead(Uint16.ONE, ByteBufUtils::readUint16, (byte) 0, (byte) 1);
+        testWrite(Uint16.ONE, 2, ByteBufUtils::writeOptional, ByteBufUtils::writeOrZero, ByteBufUtils::writeMandatory);
+    }
+
+    @Test
+    public void testUint32() {
+        testRead(Uint32.ONE, ByteBufUtils::readUint32, (byte) 0, (byte) 0, (byte) 0, (byte) 1);
+        testWrite(Uint32.ONE, 4, ByteBufUtils::writeOptional, ByteBufUtils::writeOrZero, ByteBufUtils::writeMandatory);
+    }
+
+    @Test
+    public void testUint64() {
+        testRead(Uint64.ONE, ByteBufUtils::readUint64,
+            (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 1);
+        testWrite(Uint64.ONE, 8, ByteBufUtils::writeOptional, ByteBufUtils::writeOrZero, ByteBufUtils::writeMandatory);
+    }
+
+    private static <T> void testRead(final T expected, final Function<ByteBuf, T> readFunc, final byte... bytes) {
+        final ByteBuf buf = Unpooled.wrappedBuffer(bytes);
+        assertEquals(expected, readFunc.apply(buf));
+        assertFalse(buf.isReadable());
+    }
+
+    private static <T> void testWrite(final T obj, final int size, final WriteNullable<T> writeOptional,
+            final WriteNullable<T> writeOrZero, final WriteMandatory<T> writeMandatory) {
+        final ByteBuf buf = Unpooled.buffer(size);
+
+        writeOptional.accept(buf, null);
+        assertEquals(0, buf.writerIndex());
+        writeOptional.accept(buf, obj);
+        assertEquals(size, buf.writerIndex());
+
+        writeOrZero.accept(buf, null);
+        assertEquals(2 * size, buf.writerIndex());
+        writeOrZero.accept(buf, obj);
+        assertEquals(3 * size, buf.writerIndex());
+
+        buf.clear();
+        try {
+            writeMandatory.accept(buf, null, "name");
+            fail("IAE should have been thrown");
+        } catch (IllegalArgumentException e) {
+            assertEquals("name is mandatory", e.getMessage());
+        }
+        assertEquals(0, buf.writerIndex());
+
+        writeMandatory.accept(buf, obj, null);
+        assertEquals(size, buf.writerIndex());
+    }
+
+    @FunctionalInterface
+    interface WriteNullable<T> extends BiConsumer<ByteBuf, T> {
+
+    }
+
+    @FunctionalInterface
+    interface WriteMandatory<T> {
+        void accept(ByteBuf buf, T value, String name);
+    }
+}