From e63291850fd0795c5700e25e67e5dee89ba54c5f Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Tue, 1 Dec 2015 05:49:27 -0800 Subject: onos commit hash c2999f30c69e50df905a9d175ef80b3f23a98514 Change-Id: I2bb8562c4942b6d6a6d60b663db2e17540477b81 Signed-off-by: Ashlee Young --- framework/src/onos/protocols/pcep/api/pom.xml | 99 ++ .../org/onosproject/pcep/controller/PccId.java | 120 ++ .../onosproject/pcep/controller/PcepClient.java | 110 ++ .../pcep/controller/PcepClientController.java | 93 ++ .../pcep/controller/PcepClientListener.java | 36 + .../pcep/controller/PcepEventListener.java | 31 + .../pcep/controller/PcepPacketStats.java | 50 + .../pcep/controller/driver/PcepAgent.java | 63 + .../pcep/controller/driver/PcepClientDriver.java | 110 ++ .../controller/driver/PcepClientDriverFactory.java | 38 + .../pcep/controller/driver/package-info.java | 20 + .../onosproject/pcep/controller/package-info.java | 20 + framework/src/onos/protocols/pcep/ctl/pom.xml | 65 + .../pcep/controller/impl/Controller.java | 188 +++ .../pcep/controller/impl/PcepChannelHandler.java | 652 ++++++++ .../controller/impl/PcepClientControllerImpl.java | 222 +++ .../pcep/controller/impl/PcepClientImpl.java | 220 +++ .../pcep/controller/impl/PcepMessageDecoder.java | 68 + .../pcep/controller/impl/PcepMessageEncoder.java | 58 + .../pcep/controller/impl/PcepPacketStatsImpl.java | 105 ++ .../pcep/controller/impl/PcepPipelineFactory.java | 66 + .../pcep/controller/impl/package-info.java | 20 + framework/src/onos/protocols/pcep/pcepio/pom.xml | 77 + .../pcepio/exceptions/PcepParseException.java | 92 ++ .../exceptions/PcepTunnelAttributeException.java | 60 + .../pcepio/exceptions/package-info.java | 20 + .../pcepio/protocol/PcInitiatedLspRequest.java | 185 +++ .../onosproject/pcepio/protocol/PcepAttribute.java | 166 ++ .../pcepio/protocol/PcepBandwidthObject.java | 109 ++ .../onosproject/pcepio/protocol/PcepCloseMsg.java | 143 ++ .../pcepio/protocol/PcepEndPointsObject.java | 139 ++ .../onosproject/pcepio/protocol/PcepEroObject.java | 112 ++ .../org/onosproject/pcepio/protocol/PcepError.java | 136 ++ .../onosproject/pcepio/protocol/PcepErrorInfo.java | 93 ++ .../onosproject/pcepio/protocol/PcepErrorMsg.java | 109 ++ .../pcepio/protocol/PcepErrorObject.java | 169 ++ .../onosproject/pcepio/protocol/PcepFactories.java | 98 ++ .../onosproject/pcepio/protocol/PcepFactory.java | 255 +++ .../onosproject/pcepio/protocol/PcepFecObject.java | 49 + .../pcepio/protocol/PcepFecObjectIPv4.java | 104 ++ .../protocol/PcepFecObjectIPv4Adjacency.java | 133 ++ .../PcepFecObjectIPv4UnnumberedAdjacency.java | 191 +++ .../pcepio/protocol/PcepFecObjectIPv6.java | 104 ++ .../protocol/PcepFecObjectIPv6Adjacency.java | 133 ++ .../pcepio/protocol/PcepInitiateMsg.java | 81 + .../pcepio/protocol/PcepInterLayerObject.java | 137 ++ .../onosproject/pcepio/protocol/PcepIroObject.java | 110 ++ .../pcepio/protocol/PcepKeepaliveMsg.java | 49 + .../pcepio/protocol/PcepLabelObject.java | 171 ++ .../pcepio/protocol/PcepLabelRange.java | 65 + .../pcepio/protocol/PcepLabelRangeObject.java | 182 +++ .../pcepio/protocol/PcepLabelRangeResvMsg.java | 79 + .../pcepio/protocol/PcepLabelUpdate.java | 108 ++ .../pcepio/protocol/PcepLabelUpdateMsg.java | 81 + .../onosproject/pcepio/protocol/PcepLspObject.java | 286 ++++ .../pcepio/protocol/PcepLspaObject.java | 286 ++++ .../onosproject/pcepio/protocol/PcepMessage.java | 67 + .../pcepio/protocol/PcepMessageReader.java | 36 + .../pcepio/protocol/PcepMessageWriter.java | 35 + .../pcepio/protocol/PcepMetricObject.java | 225 +++ .../onosproject/pcepio/protocol/PcepMsgPath.java | 117 ++ .../org/onosproject/pcepio/protocol/PcepNai.java | 40 + .../onosproject/pcepio/protocol/PcepObject.java | 30 + .../onosproject/pcepio/protocol/PcepOpenMsg.java | 73 + .../pcepio/protocol/PcepOpenObject.java | 221 +++ .../onosproject/pcepio/protocol/PcepRPObject.java | 256 +++ .../onosproject/pcepio/protocol/PcepReportMsg.java | 81 + .../onosproject/pcepio/protocol/PcepRroObject.java | 111 ++ .../onosproject/pcepio/protocol/PcepSrpObject.java | 171 ++ .../pcepio/protocol/PcepStateReport.java | 207 +++ .../onosproject/pcepio/protocol/PcepTEObject.java | 241 +++ .../pcepio/protocol/PcepTEReportMsg.java | 81 + .../org/onosproject/pcepio/protocol/PcepType.java | 49 + .../onosproject/pcepio/protocol/PcepUpdateMsg.java | 81 + .../pcepio/protocol/PcepUpdateRequest.java | 126 ++ .../onosproject/pcepio/protocol/PcepVersion.java | 46 + .../org/onosproject/pcepio/protocol/Writeable.java | 35 + .../onosproject/pcepio/protocol/package-info.java | 20 + .../protocol/ver1/PcInitiatedLspRequestVer1.java | 291 ++++ .../pcepio/protocol/ver1/PcepAttributeVer1.java | 431 +++++ .../protocol/ver1/PcepBandwidthObjectVer1.java | 233 +++ .../pcepio/protocol/ver1/PcepCloseMsgVer1.java | 351 ++++ .../protocol/ver1/PcepEndPointsObjectVer1.java | 256 +++ .../pcepio/protocol/ver1/PcepEroObjectVer1.java | 407 +++++ .../pcepio/protocol/ver1/PcepErrorInfoVer1.java | 204 +++ .../pcepio/protocol/ver1/PcepErrorMsgVer1.java | 383 +++++ .../pcepio/protocol/ver1/PcepErrorObjectVer1.java | 341 ++++ .../pcepio/protocol/ver1/PcepErrorVer1.java | 399 +++++ .../pcepio/protocol/ver1/PcepFactoryVer1.java | 226 +++ .../ver1/PcepFecObjectIPv4AdjacencyVer1.java | 253 +++ .../PcepFecObjectIPv4UnnumberedAdjacencyVer1.java | 334 ++++ .../protocol/ver1/PcepFecObjectIPv4Ver1.java | 217 +++ .../ver1/PcepFecObjectIPv6AdjacencyVer1.java | 249 +++ .../protocol/ver1/PcepFecObjectIPv6Ver1.java | 220 +++ .../pcepio/protocol/ver1/PcepInitiateMsgVer1.java | 332 ++++ .../protocol/ver1/PcepInterLayerObjectVer1.java | 263 +++ .../pcepio/protocol/ver1/PcepIroObjectVer1.java | 299 ++++ .../pcepio/protocol/ver1/PcepKeepaliveMsgVer1.java | 154 ++ .../pcepio/protocol/ver1/PcepLabelObjectVer1.java | 370 +++++ .../protocol/ver1/PcepLabelRangeObjectVer1.java | 377 +++++ .../protocol/ver1/PcepLabelRangeResvMsgVer1.java | 198 +++ .../pcepio/protocol/ver1/PcepLabelRangeVer1.java | 168 ++ .../protocol/ver1/PcepLabelUpdateMsgVer1.java | 239 +++ .../pcepio/protocol/ver1/PcepLabelUpdateVer1.java | 356 +++++ .../pcepio/protocol/ver1/PcepLspObjectVer1.java | 575 +++++++ .../pcepio/protocol/ver1/PcepLspaObjectVer1.java | 529 ++++++ .../pcepio/protocol/ver1/PcepMessageVer1.java | 132 ++ .../pcepio/protocol/ver1/PcepMetricObjectVer1.java | 376 +++++ .../pcepio/protocol/ver1/PcepMsgPathVer1.java | 187 +++ .../pcepio/protocol/ver1/PcepOpenMsgVer1.java | 204 +++ .../pcepio/protocol/ver1/PcepOpenObjectVer1.java | 491 ++++++ .../pcepio/protocol/ver1/PcepRPObjectVer1.java | 445 ++++++ .../pcepio/protocol/ver1/PcepReportMsgVer1.java | 309 ++++ .../pcepio/protocol/ver1/PcepRroObjectVer1.java | 345 ++++ .../pcepio/protocol/ver1/PcepSrpObjectVer1.java | 392 +++++ .../pcepio/protocol/ver1/PcepStateReportVer1.java | 421 +++++ .../pcepio/protocol/ver1/PcepTEObjectVer1.java | 506 ++++++ .../pcepio/protocol/ver1/PcepTEReportMsgVer1.java | 225 +++ .../pcepio/protocol/ver1/PcepUpdateMsgVer1.java | 300 ++++ .../protocol/ver1/PcepUpdateRequestVer1.java | 199 +++ .../pcepio/protocol/ver1/package-info.java | 20 + .../pcepio/types/AdministrativeGroupTlv.java | 136 ++ .../pcepio/types/AutonomousSystemTlv.java | 136 ++ .../pcepio/types/BGPLSidentifierTlv.java | 136 ++ .../pcepio/types/ErrorObjListWithOpen.java | 160 ++ .../pcepio/types/GmplsCapabilityTlv.java | 138 ++ .../org/onosproject/pcepio/types/IGPMetricTlv.java | 150 ++ .../pcepio/types/IPv4InterfaceAddressTlv.java | 137 ++ .../pcepio/types/IPv4NeighborAddressTlv.java | 137 ++ .../onosproject/pcepio/types/IPv4SubObject.java | 180 +++ .../pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java | 136 ++ .../types/IPv4TERouterIdOfRemoteNodeTlv.java | 137 ++ .../pcepio/types/IPv6InterfaceAddressTlv.java | 181 +++ .../pcepio/types/IPv6NeighborAddressTlv.java | 179 +++ .../onosproject/pcepio/types/IPv6SubObject.java | 222 +++ .../pcepio/types/IPv6TERouterIdofLocalNodeTlv.java | 179 +++ .../types/IPv6TERouterIdofRemoteNodeTlv.java | 171 ++ .../pcepio/types/ISISAreaIdentifierTlv.java | 155 ++ .../onosproject/pcepio/types/LabelSubObject.java | 171 ++ .../types/LinkLocalRemoteIdentifiersTlv.java | 155 ++ .../org/onosproject/pcepio/types/LinkNameTlv.java | 155 ++ .../pcepio/types/LinkProtectionTypeTlv.java | 142 ++ .../pcepio/types/LocalTENodeDescriptorsTlv.java | 246 +++ .../pcepio/types/MPLSProtocolMaskTlv.java | 200 +++ .../pcepio/types/MaximumLinkBandwidthTlv.java | 137 ++ .../types/MaximumReservableLinkBandwidthTlv.java | 136 ++ .../pcepio/types/NexthopIPv4addressTlv.java | 143 ++ .../pcepio/types/NexthopIPv6addressTlv.java | 190 +++ .../pcepio/types/NexthopUnnumberedIPv4IDTlv.java | 163 ++ .../onosproject/pcepio/types/NodeFlagBitsTlv.java | 233 +++ .../org/onosproject/pcepio/types/NodeNameTlv.java | 154 ++ .../onosproject/pcepio/types/OSPFareaIDsubTlv.java | 135 ++ .../pcepio/types/OpaqueLinkAttributeTlv.java | 155 ++ .../pcepio/types/OpaqueNodeAttributeTlv.java | 154 ++ .../onosproject/pcepio/types/PathKeySubObject.java | 159 ++ .../onosproject/pcepio/types/PathSetupTypeTlv.java | 164 ++ .../pcepio/types/PceccCapabilityTlv.java | 194 +++ .../pcepio/types/PcepErrorDetailInfo.java | 83 + .../pcepio/types/PcepLabelDbVerTlv.java | 137 ++ .../pcepio/types/PcepLabelDownload.java | 105 ++ .../org/onosproject/pcepio/types/PcepLabelMap.java | 103 ++ .../pcepio/types/PcepNaiIpv4Adjacency.java | 107 ++ .../pcepio/types/PcepNaiIpv4NodeId.java | 99 ++ .../pcepio/types/PcepNaiIpv6Adjacency.java | 113 ++ .../pcepio/types/PcepNaiIpv6NodeId.java | 102 ++ .../types/PcepNaiUnnumberedAdjacencyIpv4.java | 131 ++ .../onosproject/pcepio/types/PcepObjectHeader.java | 224 +++ .../pcepio/types/PcepRsvpErrorSpec.java | 46 + .../pcepio/types/PcepRsvpIpv4ErrorSpec.java | 160 ++ .../pcepio/types/PcepRsvpIpv6ErrorSpec.java | 165 ++ .../pcepio/types/PcepRsvpObjectHeader.java | 161 ++ .../pcepio/types/PcepRsvpSpecObjHeader.java | 156 ++ .../pcepio/types/PcepRsvpUserErrorSpec.java | 220 +++ .../onosproject/pcepio/types/PcepValueType.java | 55 + .../pcepio/types/RemoteTENodeDescriptorsTlv.java | 250 +++ .../onosproject/pcepio/types/RouterIDSubTlv.java | 154 ++ .../pcepio/types/RoutingUniverseTlv.java | 147 ++ .../pcepio/types/SharedRiskLinkGroupTlv.java | 167 ++ .../onosproject/pcepio/types/SrEroSubObject.java | 324 ++++ .../types/StatefulIPv4LspIdentidiersTlv.java | 210 +++ .../pcepio/types/StatefulLspDbVerTlv.java | 142 ++ .../pcepio/types/StatefulLspErrorCodeTlv.java | 142 ++ .../pcepio/types/StatefulPceCapabilityTlv.java | 269 ++++ .../pcepio/types/StatefulRsvpErrorSpecTlv.java | 216 +++ .../pcepio/types/SymbolicPathNameTlv.java | 159 ++ .../pcepio/types/TEDefaultMetricTlv.java | 137 ++ .../pcepio/types/TELinkAttributesTlv.java | 292 ++++ .../pcepio/types/TELinkDescriptorsTlv.java | 251 +++ .../pcepio/types/TENodeAttributesTlv.java | 250 +++ .../onosproject/pcepio/types/TedCapabilityTlv.java | 181 +++ .../pcepio/types/UnreservedBandwidthTlv.java | 136 ++ .../org/onosproject/pcepio/types/package-info.java | 20 + .../java/org/onosproject/pcepio/util/HexDump.java | 56 + .../org/onosproject/pcepio/util/package-info.java | 20 + .../pcepio/protocol/PcepCloseMsgTest.java | 56 + .../pcepio/protocol/PcepErrorMsgTest.java | 735 +++++++++ .../pcepio/protocol/PcepInitiateMsgExtTest.java | 1683 ++++++++++++++++++++ .../pcepio/protocol/PcepInitiateMsgTest.java | 1331 ++++++++++++++++ .../pcepio/protocol/PcepKeepaliveMsgTest.java | 59 + .../pcepio/protocol/PcepLabelUpdateMsgTest.java | 402 +++++ .../pcepio/protocol/PcepOpenMsgTest.java | 558 +++++++ .../pcepio/protocol/PcepReportMsgExtTest.java | 218 +++ .../pcepio/protocol/PcepReportMsgTest.java | 1597 +++++++++++++++++++ .../pcepio/protocol/PcepTEReportMsgTest.java | 1596 +++++++++++++++++++ .../pcepio/protocol/PcepUpdateMsgExtTest.java | 1269 +++++++++++++++ .../pcepio/protocol/PcepUpdateMsgTest.java | 1423 +++++++++++++++++ .../pcepio/types/AdministrativeGroupTlvTest.java | 36 + .../pcepio/types/AutonomousSystemTlvTest.java | 36 + .../pcepio/types/BGPLSidentifierTlvTest.java | 36 + .../pcepio/types/GmplsCapabilityTlvTest.java | 36 + .../onosproject/pcepio/types/IGPMetricTlvTest.java | 38 + .../pcepio/types/IPv4InterfaceAddressTlvTest.java | 37 + .../pcepio/types/IPv4NeighborAddressTlvTest.java | 37 + .../pcepio/types/IPv4SubObjectTest.java | 37 + .../types/IPv4TERouterIdOfLocalNodeTlvTest.java | 37 + .../types/IPv4TERouterIdOfRemoteNodeTlvTest.java | 37 + .../pcepio/types/IPv6InterfaceAddressTlvTest.java | 42 + .../pcepio/types/IPv6NeighborAddressTlvTest.java | 42 + .../pcepio/types/IPv6SubObjectTest.java | 39 + .../types/IPv6TERouterIdofLocalNodeTlvTest.java | 42 + .../types/IPv6TERouterIdofRemoteNodeTlvTest.java | 42 + .../pcepio/types/ISISAreaIdentifierTlvTest.java | 40 + .../pcepio/types/LabelSubObjectTest.java | 37 + .../types/LinkLocalRemoteIdentifiersTlvTest.java | 37 + .../onosproject/pcepio/types/LinkNameTlvTest.java | 39 + .../pcepio/types/LinkProtectionTypeTlvTest.java | 39 + .../types/LocalTENodeDescriptorsTlvTest.java | 50 + .../pcepio/types/MPLSProtocolMaskTlvTest.java | 39 + .../pcepio/types/MaximumLinkBandwidthTlvTest.java | 39 + .../MaximumReservableLinkBandwidthTlvTest.java | 39 + .../pcepio/types/NexthopIPv4addressTlvTest.java | 37 + .../pcepio/types/NexthopIPv6addressTlvTest.java | 41 + .../types/NexthopUnnumberedIPv4IDTlvTest.java | 37 + .../pcepio/types/NodeFlagBitsTlvTest.java | 39 + .../onosproject/pcepio/types/NodeNameTlvTest.java | 39 + .../pcepio/types/OSPFareaIDsubTlvTest.java | 36 + .../pcepio/types/OpaqueLinkAttributeTlvTest.java | 39 + .../pcepio/types/PathKeySubObjectTest.java | 37 + .../pcepio/types/PathSetupTypeTlvTest.java | 34 + .../pcepio/types/PceccCapabilityTlvTest.java | 39 + .../pcepio/types/PcepNaiIpv4AdjacencyTest.java | 36 + .../pcepio/types/PcepNaiIpv4NodeIdTest.java | 34 + .../pcepio/types/PcepNaiIpv6AdjacencyTest.java | 37 + .../pcepio/types/PcepNaiIpv6NodeIdTest.java | 43 + .../types/PcepNaiUnnumberedAdjacencyIpv4Test.java | 49 + .../types/RemoteTENodeDescriptorsTlvTest.java | 52 + .../pcepio/types/RouterIDSubTlvTest.java | 42 + .../pcepio/types/RoutingUniverseTlvTest.java | 35 + .../pcepio/types/SharedRiskLinkGroupTlvTest.java | 41 + .../pcepio/types/SrEroSubObjectTest.java | 59 + .../types/StatefulIPv4LspIdentidiersTlvTest.java | 55 + .../pcepio/types/StatefulLspDbVerTlvTest.java | 35 + .../pcepio/types/StatefulLspErrorCodeTlvTest.java | 31 + .../pcepio/types/StatefulPceCapabilityTlvTest.java | 34 + .../pcepio/types/SymbolicPathNameTlvTest.java | 43 + .../pcepio/types/TEDefaultMetricTlvTest.java | 34 + .../pcepio/types/TELinkAttributesTlvTest.java | 54 + .../pcepio/types/TELinkDescriptorsTlvTest.java | 52 + .../pcepio/types/TENodeAttributesTlvTest.java | 54 + .../pcepio/types/TedCapabilityTlvTest.java | 34 + .../pcepio/types/UnreservedBandwidthTlvTest.java | 36 + framework/src/onos/protocols/pcep/pom.xml | 60 + 262 files changed, 47056 insertions(+) create mode 100644 framework/src/onos/protocols/pcep/api/pom.xml create mode 100755 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PccId.java create mode 100755 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClient.java create mode 100644 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientController.java create mode 100755 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientListener.java create mode 100644 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepEventListener.java create mode 100644 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepPacketStats.java create mode 100755 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepAgent.java create mode 100755 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepClientDriver.java create mode 100755 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepClientDriverFactory.java create mode 100644 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/package-info.java create mode 100644 framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/package-info.java create mode 100644 framework/src/onos/protocols/pcep/ctl/pom.xml create mode 100644 framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/Controller.java create mode 100644 framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java create mode 100644 framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java create mode 100644 framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java create mode 100644 framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepMessageDecoder.java create mode 100644 framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepMessageEncoder.java create mode 100644 framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepPacketStatsImpl.java create mode 100644 framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepPipelineFactory.java create mode 100644 framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/package-info.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/pom.xml create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepParseException.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepTunnelAttributeException.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/package-info.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcInitiatedLspRequest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepAttribute.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepBandwidthObject.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepCloseMsg.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEndPointsObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEroObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepError.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorInfo.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorMsg.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorObject.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactories.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactory.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4Adjacency.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4UnnumberedAdjacency.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6Adjacency.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInitiateMsg.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInterLayerObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepIroObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsg.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRange.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeResvMsg.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdate.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsg.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspaObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessage.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageReader.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageWriter.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMetricObject.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMsgPath.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepNai.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepObject.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenMsg.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRPObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepReportMsg.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRroObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepSrpObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepStateReport.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepTEObject.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepTEReportMsg.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepType.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateMsg.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateRequest.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepVersion.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/Writeable.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/package-info.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcInitiatedLspRequestVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepAttributeVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepBandwidthObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepCloseMsgVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEndPointsObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEroObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorInfoVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFactoryVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4AdjacencyVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4UnnumberedAdjacencyVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4Ver1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6AdjacencyVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6Ver1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInitiateMsgVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInterLayerObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepIroObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepKeepaliveMsgVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeResvMsgVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateMsgVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspaObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMessageVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMetricObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenMsgVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRPObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRroObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepStateReportVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepTEObjectVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepTEReportMsgVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateMsgVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateRequestVer1.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/package-info.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java create mode 100755 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/package-info.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepTEReportMsgTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BGPLSidentifierTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IGPMetricTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OSPFareaIDsubTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RouterIDSubTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkAttributesTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkDescriptorsTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TENodeAttributesTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TedCapabilityTlvTest.java create mode 100644 framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthTlvTest.java create mode 100755 framework/src/onos/protocols/pcep/pom.xml (limited to 'framework/src/onos/protocols/pcep') diff --git a/framework/src/onos/protocols/pcep/api/pom.xml b/framework/src/onos/protocols/pcep/api/pom.xml new file mode 100644 index 00000000..4588ad6f --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + + org.onosproject + onos-pcep-controller + 1.4.0-SNAPSHOT + ../pom.xml + + + onos-pcep-controller-api + bundle + + ONOS Pcep client controller subsystem API + + + + org.onosproject + onos-app-pcep-api + + + org.onosproject + onos-pcepio + + + io.netty + netty + + + org.onosproject + onos-api + + + org.onosproject + onlab-misc + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.3 + + + + io.netty:netty + com.google.guava:guava + org.slf4j:slfj-api + ch.qos.logback:logback-core + ch.qos.logback:logback-classic + com.google.code.findbugs:annotations + + + + + + package + + shade + + + + + + org.apache.felix + maven-bundle-plugin + + + + org.onosproject.pcep.*,org.onosproject.pcepio.* + + + + + + + + diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PccId.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PccId.java new file mode 100755 index 00000000..3ff622bf --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PccId.java @@ -0,0 +1,120 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller; + +import static com.google.common.base.Preconditions.checkArgument; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Objects; + +import org.onlab.packet.IpAddress; + +/** + * The class representing a network client pc ip. + * This class is immutable. + */ +public final class PccId { + + private static final String SCHEME = "pcep"; + private static final long UNKNOWN = 0; + private final IpAddress ipAddress; + + /** + * Private constructor. + */ + private PccId(IpAddress ipAddress) { + this.ipAddress = ipAddress; + } + + /** + * Create a PccId from ip address. + * + * @param ipAddress IP address + * @return ipAddress + */ + public static PccId pccId(IpAddress ipAddress) { + return new PccId(ipAddress); + } + + /** + * Returns the ip address. + * + * @return ipAddress + */ + public IpAddress ipAddress() { + return ipAddress; + } + + /** + * Convert the PccId value to a ':' separated hexadecimal string. + * + * @return the PccId value as a ':' separated hexadecimal string. + */ + @Override + public String toString() { + return ipAddress.toString(); + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof PccId)) { + return false; + } + + PccId otherPccid = (PccId) other; + return Objects.equals(ipAddress, otherPccid.ipAddress); + } + + @Override + public int hashCode() { + return Objects.hash(ipAddress); + } + + /** + * Returns PccId created from the given client URI. + * + * @param uri device URI + * @return pccid + */ + public static PccId pccid(URI uri) { + checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme"); + return new PccId(IpAddress.valueOf(uri.getSchemeSpecificPart())); + } + + /** + * Produces client URI from the given DPID. + * + * @param pccid client pccid + * @return client URI + */ + public static URI uri(PccId pccid) { + return uri(pccid.ipAddress()); + } + + /** + * Produces client URI from the given ip address. + * + * @param ipAddress ip of client + * @return client URI + */ + public static URI uri(IpAddress ipAddress) { + try { + return new URI(SCHEME, ipAddress.toString(), null); + } catch (URISyntaxException e) { + return null; + } + } +} diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClient.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClient.java new file mode 100755 index 00000000..95e7789f --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClient.java @@ -0,0 +1,110 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller; + +import java.util.List; + +import org.onosproject.pcepio.protocol.PcepFactory; +import org.onosproject.pcepio.protocol.PcepMessage; + +/** + * Represents to provider facing side of a path computation client(pcc). + */ +public interface PcepClient { + + /** + * Writes the message to the driver. + * + * @param msg the message to write + */ + void sendMessage(PcepMessage msg); + + /** + * Writes the PcepMessage list to the driver. + * + * @param msgs the messages to be written + */ + void sendMessage(List msgs); + + /** + * Handle a message from the pcc. + * + * @param fromClient the message to handle + */ + void handleMessage(PcepMessage fromClient); + + /** + * Provides the factory for this PCEP version. + * + * @return PCEP version specific factory. + */ + PcepFactory factory(); + + /** + * Gets a string version of the ID for this pcc. + * + * @return string version of the ID + */ + String getStringId(); + + /** + * Gets the ipAddress of the client. + * + * @return the client pccId in IPAddress format + */ + PccId getPccId(); + + /** + * Checks if the pcc is still connected. + * + * @return true if client is connected, false otherwise + */ + boolean isConnected(); + + /** + * Disconnects the pcc by closing the TCP connection. Results in a call + * to the channel handler's channelDisconnected method for cleanup. + */ + void disconnectClient(); + + /** + * Indicates if this pcc is optical. + * + * @return true if optical + */ + boolean isOptical(); + + /** + * Identifies the channel used to communicate with the pcc. + * + * @return string representation of the connection to the client + */ + String channelId(); + + /** + * To set the status of state synchronization. + * + * @param value to set the synchronization status + */ + void setIsSyncComplete(boolean value); + + /** + * Indicates the state synchronization status of this pcc. + * + * @return true/false if the synchronization is completed/not completed + */ + boolean isSyncComplete(); +} diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientController.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientController.java new file mode 100644 index 00000000..37453eac --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientController.java @@ -0,0 +1,93 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller; + +import java.util.Collection; + +import org.onosproject.pcepio.protocol.PcepMessage; + +/** + * Abstraction of an Pcep client controller. Serves as a one stop + * shop for obtaining Pcep devices and (un)register listeners + * on pcep events + */ +public interface PcepClientController { + + /** + * Returns list of pcc clients connected to this Pcep controller. + * + * @return list of PcepClient elements + */ + Collection getClients(); + + /** + * Returns the actual pcc client for the given ip address. + * + * @param pccId the id of the pcc client to fetch + * @return the interface to this pcc client + */ + PcepClient getClient(PccId pccId); + + /** + * Register a listener for meta events that occur to pcep + * devices. + * + * @param listener the listener to notify + */ + void addListener(PcepClientListener listener); + + /** + * Unregister a listener. + * + * @param listener the listener to unregister + */ + void removeListener(PcepClientListener listener); + + /** + * Register a listener for OF msg events. + * + * @param listener the listener to notify + */ + void addEventListener(PcepEventListener listener); + + /** + * Unregister a listener. + * + * @param listener the listener to unregister + */ + void removeEventListener(PcepEventListener listener); + + /** + * Send a message to a particular pcc client. + * + * @param pccId the id of the client to send message. + * @param msg the message to send + */ + void writeMessage(PccId pccId, PcepMessage msg); + + /** + * Process a message and notify the appropriate listeners. + * + * @param pccId id of the client the message arrived on + * @param msg the message to process. + */ + void processClientMessage(PccId pccId, PcepMessage msg); + + /** + * Close all connected PCC clients. + */ + void closeConnectedClients(); +} diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientListener.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientListener.java new file mode 100755 index 00000000..e7e0a736 --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientListener.java @@ -0,0 +1,36 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller; + +/** + * Allows for providers interested in PCC client events to be notified. + */ +public interface PcepClientListener { + + /** + * Notify that the PCC was connected. + * + * @param pccId the id of the client that connected + */ + void clientConnected(PccId pccId); + + /** + * Notify that the PCC was disconnected. + * + * @param pccId the id of the client that disconnected. + */ + void clientDisconnected(PccId pccId); +} diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepEventListener.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepEventListener.java new file mode 100644 index 00000000..f7de215a --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepEventListener.java @@ -0,0 +1,31 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller; + +import org.onosproject.pcepio.protocol.PcepMessage; +/** + * Notifies providers about PCEP message events. + */ +public interface PcepEventListener { + + /** + * Handles the message event. + * + * @param pccId id of the pcc + * @param msg the message + */ + void handleMessage(PccId pccId, PcepMessage msg); +} diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepPacketStats.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepPacketStats.java new file mode 100644 index 00000000..d00cd5a8 --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepPacketStats.java @@ -0,0 +1,50 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller; + +/** + * The representation for PCEP packet statistics. + */ +public interface PcepPacketStats { + + /** + * Returns the count for no of packets sent out. + * + * @return int value of no of packets sent + */ + int outPacketCount(); + + /** + * Returns the count for no of packets received. + * + * @return int value of no of packets sent + */ + int inPacketCount(); + + /** + * Returns the count for no of wrong packets received. + * + * @return int value of no of wrong packets received + */ + int wrongPacketCount(); + + /** + * Returns the time value. + * + * @return long value of time + */ + long getTime(); +} diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepAgent.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepAgent.java new file mode 100755 index 00000000..4810417c --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepAgent.java @@ -0,0 +1,63 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller.driver; + +import org.onosproject.pcep.controller.PccId; +import org.onosproject.pcep.controller.PcepClient; +import org.onosproject.pcepio.protocol.PcepMessage; + +/** + * Responsible for keeping track of the current set Pcep clients + * connected to the system. + * + */ +public interface PcepAgent { + + /** + * Add a pcc client that has just connected to the system. + * + * @param pccId the id of pcc client to add + * @param pc the actual pce client object. + * @return true if added, false otherwise. + */ + boolean addConnectedClient(PccId pccId, PcepClient pc); + + /** + * Checks if the activation for this pcc client is valid. + * + * @param pccId the id of pcc client to check + * @return true if valid, false otherwise + */ + boolean validActivation(PccId pccId); + + /** + * Clear all state in controller client maps for a pcc client that has + * disconnected from the local controller. Also release control for + * that pccIds client from the global repository. Notify client listeners. + * + * @param pccIds the id of pcc client to remove. + */ + void removeConnectedClient(PccId pccIds); + + /** + * Process a message coming from a pcc client. + * + * @param pccId the id of pcc client the message was received. + * @param m the message to process + */ + void processPcepMessage(PccId pccId, PcepMessage m); + +} diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepClientDriver.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepClientDriver.java new file mode 100755 index 00000000..f728de54 --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepClientDriver.java @@ -0,0 +1,110 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller.driver; + +import org.jboss.netty.channel.Channel; +import org.onosproject.pcep.controller.PccId; +import org.onosproject.pcep.controller.PcepClient; +import org.onosproject.pcep.controller.PcepPacketStats; +import org.onosproject.pcepio.protocol.PcepVersion; + + +/** + * Represents the driver side of an Path computation client(pcc). + * + */ +public interface PcepClientDriver extends PcepClient { + + /** + * Sets the Pcep agent to be used. This method + * can only be called once. + * + * @param agent the agent to set. + */ + void setAgent(PcepAgent agent); + + /** + * Announce to the Pcep agent that this pcc client has connected. + * + * @return true if successful, false if duplicate switch. + */ + boolean connectClient(); + + /** + * Remove this pcc client from the Pcep agent. + */ + void removeConnectedClient(); + + /** + * Sets the PCEP version for this pcc. + * + * @param pcepVersion the version to set. + */ + void setPcVersion(PcepVersion pcepVersion); + + /** + * Sets the associated Netty channel for this pcc. + * + * @param channel the Netty channel + */ + void setChannel(Channel channel); + + + /** + * Sets the keep alive time for this pcc. + * + * @param keepAliveTime the keep alive time to set. + */ + void setPcKeepAliveTime(byte keepAliveTime); + + /** + * Sets the dead time for this pcc. + * + * @param deadTime the dead timer value to set. + */ + void setPcDeadTime(byte deadTime); + + /** + * Sets the session id for this pcc. + * + * @param sessionId the session id value to set. + */ + void setPcSessionId(byte sessionId); + + /** + * Sets whether the pcc is connected. + * + * @param connected whether the pcc is connected + */ + void setConnected(boolean connected); + + /** + * Initializes the behavior. + * + * @param pccId id of pcc + * @param pcepVersion Pcep version + * @param pktStats Pcep Packet Stats + */ + void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats); + + /** + * Checks whether the handshake is complete. + * + * @return true is finished, false if not. + */ + boolean isHandshakeComplete(); + +} diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepClientDriverFactory.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepClientDriverFactory.java new file mode 100755 index 00000000..6ce75bca --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepClientDriverFactory.java @@ -0,0 +1,38 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller.driver; + +import org.onlab.packet.IpAddress; +import org.onosproject.pcepio.protocol.PcepVersion; + +/** + * Pcc Client factory which returns concrete pcc client objects for the + * physical pcc client in use. + * + */ +public interface PcepClientDriverFactory { + + + /** + * Constructs the real Pcep Client representation. + * + * @param pccIpAddress the ip address for this pcc client. + * @param pcepVersion the Pcep version in use + * @return the Pcep client representation. + */ + PcepClientDriver getPcepClientImpl(IpAddress pccIpAddress, + PcepVersion pcepVersion); +} diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/package-info.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/package-info.java new file mode 100644 index 00000000..9d105ff2 --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PCEP client controller driver API. + */ +package org.onosproject.pcep.controller.driver; diff --git a/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/package-info.java b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/package-info.java new file mode 100644 index 00000000..a0cb2482 --- /dev/null +++ b/framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PCEP client controller API. + */ +package org.onosproject.pcep.controller; diff --git a/framework/src/onos/protocols/pcep/ctl/pom.xml b/framework/src/onos/protocols/pcep/ctl/pom.xml new file mode 100644 index 00000000..f0ed5c2f --- /dev/null +++ b/framework/src/onos/protocols/pcep/ctl/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + + org.onosproject + onos-pcep-controller + 1.4.0-SNAPSHOT + ../pom.xml + + + onos-pcep-controller-impl + bundle + + ONOS PCEP client controller subsystem API implementation + + + + org.onosproject + onos-pcep-controller-api + + + io.netty + netty + + + org.apache.felix + org.apache.felix.scr.annotations + + + org.osgi + org.osgi.compendium + + + org.onosproject + onlab-misc + + + + + + + org.apache.felix + maven-scr-plugin + + + + + diff --git a/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/Controller.java b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/Controller.java new file mode 100644 index 00000000..9c27810c --- /dev/null +++ b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/Controller.java @@ -0,0 +1,188 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller.impl; + +import static org.onlab.util.Tools.groupedThreads; + +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.net.InetSocketAddress; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.Executors; + +import org.jboss.netty.bootstrap.ServerBootstrap; +import org.jboss.netty.channel.ChannelPipelineFactory; +import org.jboss.netty.channel.group.ChannelGroup; +import org.jboss.netty.channel.group.DefaultChannelGroup; +import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory; +import org.onosproject.pcep.controller.PccId; +import org.onosproject.pcep.controller.PcepPacketStats; +import org.onosproject.pcep.controller.driver.PcepAgent; +import org.onosproject.pcep.controller.driver.PcepClientDriver; +import org.onosproject.pcepio.protocol.PcepFactories; +import org.onosproject.pcepio.protocol.PcepFactory; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The main controller class. Handles all setup and network listeners - + * Distributed ownership control of pcc through IControllerRegistryService + */ +public class Controller { + + private static final Logger log = LoggerFactory.getLogger(Controller.class); + + private static final PcepFactory FACTORY1 = PcepFactories.getFactory(PcepVersion.PCEP_1); + + private ChannelGroup cg; + + // Configuration options + private int pcepPort = 4189; + private int workerThreads = 10; + + // Start time of the controller + private long systemStartTime; + + private PcepAgent agent; + + private NioServerSocketChannelFactory execFactory; + + // Perf. related configuration + private static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024; + + /** + * Returns factory version for processing pcep messages. + * + * @return instance of factory version + */ + public PcepFactory getPcepMessageFactory1() { + return FACTORY1; + } + + /** + * To get system start time. + * + * @return system start time in milliseconds + */ + public long getSystemStartTime() { + return (this.systemStartTime); + } + + /** + * Tell controller that we're ready to accept pcc connections. + */ + public void run() { + try { + final ServerBootstrap bootstrap = createServerBootStrap(); + + bootstrap.setOption("reuseAddr", true); + bootstrap.setOption("child.keepAlive", true); + bootstrap.setOption("child.tcpNoDelay", true); + bootstrap.setOption("child.sendBufferSize", Controller.SEND_BUFFER_SIZE); + + ChannelPipelineFactory pfact = new PcepPipelineFactory(this); + + bootstrap.setPipelineFactory(pfact); + InetSocketAddress sa = new InetSocketAddress(pcepPort); + cg = new DefaultChannelGroup(); + cg.add(bootstrap.bind(sa)); + log.info("Listening for PCC connection on {}", sa); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Creates server boot strap. + * + * @return ServerBootStrap + */ + private ServerBootstrap createServerBootStrap() { + if (workerThreads == 0) { + execFactory = new NioServerSocketChannelFactory( + Executors.newCachedThreadPool(groupedThreads("onos/pcep", "boss-%d")), + Executors.newCachedThreadPool(groupedThreads("onos/pcep", "worker-%d"))); + return new ServerBootstrap(execFactory); + } else { + execFactory = new NioServerSocketChannelFactory( + Executors.newCachedThreadPool(groupedThreads("onos/pcep", "boss-%d")), + Executors.newCachedThreadPool(groupedThreads("onos/pcep", "worker-%d")), workerThreads); + return new ServerBootstrap(execFactory); + } + } + + /** + * Initialize internal data structures. + */ + public void init() { + // These data structures are initialized here because other + // module's startUp() might be called before ours + this.systemStartTime = System.currentTimeMillis(); + } + + public Map getMemory() { + Map m = new HashMap<>(); + Runtime runtime = Runtime.getRuntime(); + m.put("total", runtime.totalMemory()); + m.put("free", runtime.freeMemory()); + return m; + } + + public Long getUptime() { + RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean(); + return rb.getUptime(); + } + + /** + * Creates instance of Pcep client. + * + * @param pccId pcc identifier + * @param sessionID session id + * @param pv pcep version + * @param pktStats pcep packet statistics + * @return instance of PcepClient + */ + protected PcepClientDriver getPcepClientInstance(PccId pccId, int sessionID, PcepVersion pv, + PcepPacketStats pktStats) { + PcepClientDriver pcepClientDriver = new PcepClientImpl(); + pcepClientDriver.init(pccId, pv, pktStats); + pcepClientDriver.setAgent(agent); + return pcepClientDriver; + } + + /** + * Starts the pcep controller. + * + * @param ag Pcep agent + */ + public void start(PcepAgent ag) { + log.info("Started"); + this.agent = ag; + this.init(); + this.run(); + } + + /** + * Stops the pcep controller. + */ + public void stop() { + log.info("Stopped"); + execFactory.shutdown(); + cg.close(); + } +} diff --git a/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java new file mode 100644 index 00000000..bc8721d7 --- /dev/null +++ b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java @@ -0,0 +1,652 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcep.controller.impl; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.nio.channels.ClosedChannelException; +import java.util.Collections; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.concurrent.RejectedExecutionException; + +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.channel.ChannelStateEvent; +import org.jboss.netty.channel.ExceptionEvent; +import org.jboss.netty.channel.MessageEvent; +import org.jboss.netty.handler.timeout.IdleState; +import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler; +import org.jboss.netty.handler.timeout.IdleStateEvent; +import org.jboss.netty.handler.timeout.IdleStateHandler; +import org.jboss.netty.handler.timeout.ReadTimeoutException; +import org.onlab.packet.IpAddress; +import org.onosproject.pcep.controller.PccId; +import org.onosproject.pcep.controller.driver.PcepClientDriver; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepError; +import org.onosproject.pcepio.protocol.PcepErrorInfo; +import org.onosproject.pcepio.protocol.PcepErrorMsg; +import org.onosproject.pcepio.protocol.PcepErrorObject; +import org.onosproject.pcepio.protocol.PcepFactory; +import org.onosproject.pcepio.protocol.PcepMessage; +import org.onosproject.pcepio.protocol.PcepOpenMsg; +import org.onosproject.pcepio.protocol.PcepOpenObject; +import org.onosproject.pcepio.protocol.PcepType; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.onosproject.pcepio.types.ErrorObjListWithOpen; +import org.onosproject.pcepio.types.PceccCapabilityTlv; +import org.onosproject.pcepio.types.StatefulPceCapabilityTlv; +import org.onosproject.pcepio.types.PcepErrorDetailInfo; +import org.onosproject.pcepio.types.PcepValueType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Channel handler deals with the pcc client connection and dispatches + * messages from client to the appropriate locations. + */ +class PcepChannelHandler extends IdleStateAwareChannelHandler { + static final byte DEADTIMER_MAXIMUM_VALUE = (byte) 0xFF; + static final byte KEEPALIVE_MULTIPLE_FOR_DEADTIMER = 4; + private static final Logger log = LoggerFactory.getLogger(PcepChannelHandler.class); + private final Controller controller; + private PcepClientDriver pc; + private PccId thispccId; + private Channel channel; + private byte sessionId = 0; + private byte keepAliveTime; + private byte deadTime; + private PcepPacketStatsImpl pcepPacketStats; + static final int MAX_WRONG_COUNT_PACKET = 5; + static final int BYTE_MASK = 0xFF; + + // State needs to be volatile because the HandshakeTimeoutHandler + // needs to check if the handshake is complete + private volatile ChannelState state; + + // When a pcc client with a ip addresss is found (i.e we already have a + // connected client with the same ip), the new client is immediately + // disconnected. At that point netty callsback channelDisconnected() which + // proceeds to cleaup client state - we need to ensure that it does not cleanup + // client state for the older (still connected) client + private volatile Boolean duplicatePccIdFound; + + //Indicates the pcep version used by this pcc client + protected PcepVersion pcepVersion; + protected PcepFactory factory1; + + /** + * Create a new unconnected PcepChannelHandler. + * @param controller parent controller + */ + PcepChannelHandler(Controller controller) { + this.controller = controller; + this.state = ChannelState.INIT; + factory1 = controller.getPcepMessageFactory1(); + duplicatePccIdFound = Boolean.FALSE; + pcepPacketStats = new PcepPacketStatsImpl(); + } + + /** + * To disconnect a PCC. + */ + public void disconnectClient() { + pc.disconnectClient(); + } + + //************************* + // Channel State Machine + //************************* + + /** + * The state machine for handling the client/channel state. All state + * transitions should happen from within the state machine (and not from other + * parts of the code) + */ + enum ChannelState { + /** + * Initial state before channel is connected. + */ + INIT(false) { + + }, + /** + * Once the session is established, wait for open message. + */ + OPENWAIT(false) { + @Override + void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException { + + log.debug("Message received in OPEN WAIT State"); + + //check for open message + if (m.getType() != PcepType.OPEN) { + // When the message type is not open message increment the wrong packet statistics + h.processUnknownMsg(); + log.debug("message is not OPEN message"); + } else { + + h.pcepPacketStats.addInPacket(); + PcepOpenMsg pOpenmsg = (PcepOpenMsg) m; + // do Capability validation. + if (h.capabilityValidation(pOpenmsg)) { + log.debug("Sending handshake OPEN message"); + h.sessionId = pOpenmsg.getPcepOpenObject().getSessionId(); + h.pcepVersion = pOpenmsg.getPcepOpenObject().getVersion(); + + //setting keepalive and deadTimer + byte yKeepalive = pOpenmsg.getPcepOpenObject().getKeepAliveTime(); + byte yDeadTimer = pOpenmsg.getPcepOpenObject().getDeadTime(); + h.keepAliveTime = yKeepalive; + if (yKeepalive < yDeadTimer) { + h.deadTime = yDeadTimer; + } else { + if (DEADTIMER_MAXIMUM_VALUE > (yKeepalive * KEEPALIVE_MULTIPLE_FOR_DEADTIMER)) { + h.deadTime = (byte) (yKeepalive * KEEPALIVE_MULTIPLE_FOR_DEADTIMER); + } else { + h.deadTime = DEADTIMER_MAXIMUM_VALUE; + } + } + h.sendHandshakeOpenMessage(); + h.pcepPacketStats.addOutPacket(); + h.setState(KEEPWAIT); + } else { + log.debug("Capability validation failed. Sending PCEP-ERROR message to PCC."); + // Send PCEP-ERROR message. + PcepErrorMsg errMsg = h.getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_2, + PcepErrorDetailInfo.ERROR_VALUE_2); + h.channel.write(Collections.singletonList(errMsg)); + } + } + } + }, + /** + * Once the open messages are exchanged, wait for keep alive message. + */ + KEEPWAIT(false) { + @Override + void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException { + log.debug("message received in KEEPWAIT state"); + //check for keep alive message + if (m.getType() != PcepType.KEEP_ALIVE) { + // When the message type is not keep alive message increment the wrong packet statistics + h.processUnknownMsg(); + log.debug("message is not KEEPALIVE message"); + } else { + // Set the client connected status + h.pcepPacketStats.addInPacket(); + final SocketAddress address = h.channel.getRemoteAddress(); + if (!(address instanceof InetSocketAddress)) { + throw new IOException("Invalid client connection. Pcc is indentifed based on IP"); + } + log.debug("sending keep alive message in KEEPWAIT state"); + + final InetSocketAddress inetAddress = (InetSocketAddress) address; + h.thispccId = PccId.pccId(IpAddress.valueOf(inetAddress.getAddress())); + h.pc = h.controller.getPcepClientInstance(h.thispccId, h.sessionId, h.pcepVersion, + h.pcepPacketStats); + // set the status of pcc as connected + h.pc.setConnected(true); + h.pc.setChannel(h.channel); + + // set any other specific parameters to the pcc + h.pc.setPcVersion(h.pcepVersion); + h.pc.setPcSessionId(h.sessionId); + h.pc.setPcKeepAliveTime(h.keepAliveTime); + h.pc.setPcDeadTime(h.deadTime); + int keepAliveTimer = h.keepAliveTime & BYTE_MASK; + int deadTimer = h.deadTime & BYTE_MASK; + if (0 == h.keepAliveTime) { + h.deadTime = 0; + } + // handle keep alive and dead time + if (keepAliveTimer != PcepPipelineFactory.DEFAULT_KEEP_ALIVE_TIME + || deadTimer != PcepPipelineFactory.DEFAULT_DEAD_TIME) { + + h.channel.getPipeline().replace("idle", "idle", + new IdleStateHandler(PcepPipelineFactory.TIMER, deadTimer, keepAliveTimer, 0)); + } + log.debug("Dead timer : " + deadTimer); + log.debug("Keep alive time : " + keepAliveTimer); + + //set the state handshake completion. + h.sendKeepAliveMessage(); + h.pcepPacketStats.addOutPacket(); + h.setHandshakeComplete(true); + + if (!h.pc.connectClient()) { + disconnectDuplicate(h); + } else { + h.setState(ESTABLISHED); + } + } + } + }, + /** + * Once the keep alive messages are exchanged, the state is established. + */ + ESTABLISHED(true) { + @Override + void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException { + + //h.channel.getPipeline().remove("waittimeout"); + log.debug("Message received in established state " + m.getType()); + //dispatch the message + h.dispatchMessage(m); + } + }; + private boolean handshakeComplete; + + ChannelState(boolean handshakeComplete) { + this.handshakeComplete = handshakeComplete; + } + + void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException { + // do nothing + } + + /** + * Is this a state in which the handshake has completed. + * + * @return true if the handshake is complete + */ + public boolean isHandshakeComplete() { + return this.handshakeComplete; + } + + protected void disconnectDuplicate(PcepChannelHandler h) { + log.error("Duplicated Pcc IP or incompleted cleanup - " + "disconnecting channel {}", + h.getClientInfoString()); + h.duplicatePccIdFound = Boolean.TRUE; + h.channel.disconnect(); + } + + /** + * Sets handshake complete status. + * + * @param handshakeComplete status of handshake + */ + public void setHandshakeComplete(boolean handshakeComplete) { + this.handshakeComplete = handshakeComplete; + } + + } + + @Override + public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { + channel = e.getChannel(); + log.info("PCC connected from {}", channel.getRemoteAddress()); + + // Wait for open message from pcc client + setState(ChannelState.OPENWAIT); + } + + @Override + public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { + log.info("Pcc disconnected callback for pc:{}. Cleaning up ...", getClientInfoString()); + if (thispccId != null) { + if (!duplicatePccIdFound) { + // if the disconnected client (on this ChannelHandler) + // was not one with a duplicate-dpid, it is safe to remove all + // state for it at the controller. Notice that if the disconnected + // client was a duplicate-ip, calling the method below would clear + // all state for the original client (with the same ip), + // which we obviously don't want. + log.debug("{}:removal called", getClientInfoString()); + if (pc != null) { + pc.removeConnectedClient(); + } + } else { + // A duplicate was disconnected on this ChannelHandler, + // this is the same client reconnecting, but the original state was + // not cleaned up - XXX check liveness of original ChannelHandler + log.debug("{}:duplicate found", getClientInfoString()); + duplicatePccIdFound = Boolean.FALSE; + } + } else { + log.warn("no pccip in channelHandler registered for " + "disconnected client {}", getClientInfoString()); + } + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { + PcepErrorMsg errMsg; + log.info("exceptionCaught: " + e.toString()); + + if (e.getCause() instanceof ReadTimeoutException) { + if (ChannelState.OPENWAIT == state) { + // When ReadTimeout timer is expired in OPENWAIT state, it is considered + // OpenWait timer. + errMsg = getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_2); + log.debug("Sending PCEP-ERROR message to PCC."); + channel.write(Collections.singletonList(errMsg)); + channel.close(); + state = ChannelState.INIT; + return; + } else if (ChannelState.KEEPWAIT == state) { + // When ReadTimeout timer is expired in KEEPWAIT state, is is considered + // KeepWait timer. + errMsg = getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_7); + log.debug("Sending PCEP-ERROR message to PCC."); + channel.write(Collections.singletonList(errMsg)); + channel.close(); + state = ChannelState.INIT; + return; + } + } else if (e.getCause() instanceof ClosedChannelException) { + log.debug("Channel for pc {} already closed", getClientInfoString()); + } else if (e.getCause() instanceof IOException) { + log.error("Disconnecting client {} due to IO Error: {}", getClientInfoString(), e.getCause().getMessage()); + if (log.isDebugEnabled()) { + // still print stack trace if debug is enabled + log.debug("StackTrace for previous Exception: ", e.getCause()); + } + channel.close(); + } else if (e.getCause() instanceof PcepParseException) { + PcepParseException errMsgParse = (PcepParseException) e.getCause(); + byte errorType = errMsgParse.getErrorType(); + byte errorValue = errMsgParse.getErrorValue(); + + if ((errorType == (byte) 0x0) && (errorValue == (byte) 0x0)) { + processUnknownMsg(); + } else { + errMsg = getErrorMsg(errorType, errorValue); + log.debug("Sending PCEP-ERROR message to PCC."); + channel.write(Collections.singletonList(errMsg)); + } + } else if (e.getCause() instanceof RejectedExecutionException) { + log.warn("Could not process message: queue full"); + } else { + log.error("Error while processing message from client " + getClientInfoString() + "state " + this.state); + channel.close(); + } + } + + @Override + public String toString() { + return getClientInfoString(); + } + + @Override + public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception { + if (!isHandshakeComplete()) { + return; + } + + if (e.getState() == IdleState.READER_IDLE) { + // When no message is received on channel for read timeout, then close + // the channel + log.info("Disconnecting client {} due to read timeout", getClientInfoString()); + ctx.getChannel().close(); + } else if (e.getState() == IdleState.WRITER_IDLE) { + // Send keep alive message + log.debug("Sending keep alive message due to IdleState timeout " + pc.toString()); + pc.sendMessage(Collections.singletonList(pc.factory().buildKeepaliveMsg().build())); + } + } + + @Override + public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { + if (e.getMessage() instanceof List) { + @SuppressWarnings("unchecked") + List msglist = (List) e.getMessage(); + for (PcepMessage pm : msglist) { + // Do the actual packet processing + state.processPcepMessage(this, pm); + } + } else { + state.processPcepMessage(this, (PcepMessage) e.getMessage()); + } + } + + /** + * To set the handshake status. + * + * @param handshakeComplete value is handshake status + */ + public void setHandshakeComplete(boolean handshakeComplete) { + this.state.setHandshakeComplete(handshakeComplete); + } + + /** + * Is this a state in which the handshake has completed. + * + * @return true if the handshake is complete + */ + public boolean isHandshakeComplete() { + return this.state.isHandshakeComplete(); + } + + /** + * To handle the pcep message. + * + * @param m pcep message + */ + private void dispatchMessage(PcepMessage m) { + pc.handleMessage(m); + } + + /** + * Return a string describing this client based on the already available + * information (ip address and/or remote socket). + * + * @return display string + */ + private String getClientInfoString() { + if (pc != null) { + return pc.toString(); + } + String channelString; + if (channel == null || channel.getRemoteAddress() == null) { + channelString = "?"; + } else { + channelString = channel.getRemoteAddress().toString(); + } + String pccIpString; + // TODO : implement functionality to get pcc id string + pccIpString = "?"; + return String.format("[%s PCCIP[%s]]", channelString, pccIpString); + } + + /** + * Update the channels state. Only called from the state machine. + * + * @param state + */ + private void setState(ChannelState state) { + this.state = state; + } + + /** + * Send handshake open message. + * + * @throws IOException,PcepParseException + */ + private void sendHandshakeOpenMessage() throws IOException, PcepParseException { + PcepOpenObject pcepOpenobj = factory1.buildOpenObject() + .setSessionId(sessionId) + .setKeepAliveTime(keepAliveTime) + .setDeadTime(deadTime) + .build(); + PcepMessage msg = factory1.buildOpenMsg() + .setPcepOpenObj(pcepOpenobj) + .build(); + log.debug("Sending OPEN message to {}", channel.getRemoteAddress()); + channel.write(Collections.singletonList(msg)); + } + + /** + * Capability Validation. + * + * @param pOpenmsg pcep open message + * @return success or failure + */ + private boolean capabilityValidation(PcepOpenMsg pOpenmsg) { + LinkedList tlvList = pOpenmsg.getPcepOpenObject().getOptionalTlv(); + boolean bFoundPceccCapability = false; + boolean bFoundStatefulPceCapability = false; + boolean bFoundPcInstantiationCapability = false; + + ListIterator listIterator = tlvList.listIterator(); + while (listIterator.hasNext()) { + PcepValueType tlv = listIterator.next(); + + switch (tlv.getType()) { + case PceccCapabilityTlv.TYPE: + bFoundPceccCapability = true; + break; + case StatefulPceCapabilityTlv.TYPE: + bFoundStatefulPceCapability = true; + StatefulPceCapabilityTlv stetefulPcCapTlv = (StatefulPceCapabilityTlv) tlv; + if (stetefulPcCapTlv.getIFlag()) { + bFoundPcInstantiationCapability = true; + } + break; + default: + continue; + } + } + + return (bFoundPceccCapability && bFoundStatefulPceCapability && bFoundPcInstantiationCapability); + } + + /** + * Send keep alive message. + * + * @throws IOException when channel is disconnected + * @throws PcepParseException while building keep alive message + */ + private void sendKeepAliveMessage() throws IOException, PcepParseException { + PcepMessage msg = factory1.buildKeepaliveMsg().build(); + log.debug("Sending KEEPALIVE message to {}", channel.getRemoteAddress()); + channel.write(Collections.singletonList(msg)); + } + + /** + * Send error message and close channel with pcc. + */ + private void sendErrMsgAndCloseChannel() { + // TODO send error message + channel.close(); + } + + /** + * Send error message when an invalid message is received. + * + * @throws PcepParseException while building error message + */ + private void sendErrMsgForInvalidMsg() throws PcepParseException { + byte errorType = 0x02; + byte errorValue = 0x00; + PcepErrorMsg errMsg = getErrorMsg(errorType, errorValue); + channel.write(Collections.singletonList(errMsg)); + } + + /** + * Builds pcep error message based on error value and error type. + * + * @param errorType pcep error type + * @param errorValue pcep error value + * @return pcep error message + * @throws PcepParseException while bulding error message + */ + public PcepErrorMsg getErrorMsg(byte errorType, byte errorValue) throws PcepParseException { + LinkedList llerrObj = new LinkedList<>(); + PcepErrorMsg errMsg; + + PcepErrorObject errObj = factory1.buildPcepErrorObject() + .setErrorValue(errorValue) + .setErrorType(errorType) + .build(); + + llerrObj.add(errObj); + + if (state == ChannelState.OPENWAIT) { + //If Error caught in Openmessage + PcepOpenObject openObj = null; + ErrorObjListWithOpen errorObjListWithOpen = null; + + if (0 != sessionId) { + openObj = factory1.buildOpenObject().setSessionId(sessionId).build(); + errorObjListWithOpen = new ErrorObjListWithOpen(llerrObj, openObj); + } else { + errorObjListWithOpen = new ErrorObjListWithOpen(llerrObj, null); + } + + errMsg = factory1.buildPcepErrorMsg() + .setErrorObjListWithOpen(errorObjListWithOpen) + .build(); + } else { + + //If Error caught in other than Openmessage + LinkedList llPcepErr = new LinkedList<>(); + + PcepError pcepErr = factory1.buildPcepError() + .setErrorObjList(llerrObj) + .build(); + + llPcepErr.add(pcepErr); + + PcepErrorInfo errInfo = factory1.buildPcepErrorInfo() + .setPcepErrorList(llPcepErr) + .build(); + + errMsg = factory1.buildPcepErrorMsg() + .setPcepErrorInfo(errInfo) + .build(); + } + return errMsg; + } + + /** + * Process unknown pcep message received. + * + * @throws PcepParseException while building pcep error message + */ + public void processUnknownMsg() throws PcepParseException { + Date now = null; + if (pcepPacketStats.wrongPacketCount() == 0) { + now = new Date(); + pcepPacketStats.setTime(now.getTime()); + pcepPacketStats.addWrongPacket(); + sendErrMsgForInvalidMsg(); + } + + if (pcepPacketStats.wrongPacketCount() > 1) { + Date lastest = new Date(); + pcepPacketStats.addWrongPacket(); + //converting to seconds + if (((lastest.getTime() - pcepPacketStats.getTime()) / 1000) > 60) { + now = lastest; + pcepPacketStats.setTime(now.getTime()); + pcepPacketStats.resetWrongPacket(); + pcepPacketStats.addWrongPacket(); + } else if (((int) (lastest.getTime() - now.getTime()) / 1000) < 60) { + if (MAX_WRONG_COUNT_PACKET <= pcepPacketStats.wrongPacketCount()) { + //reset once wrong packet count reaches MAX_WRONG_COUNT_PACKET + pcepPacketStats.resetWrongPacket(); + // max wrong packets received send error message and close the session + sendErrMsgAndCloseChannel(); + } + } + } + } +} diff --git a/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java new file mode 100644 index 00000000..00c8c694 --- /dev/null +++ b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java @@ -0,0 +1,222 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller.impl; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Service; +import org.onosproject.pcep.controller.PccId; +import org.onosproject.pcep.controller.PcepClient; +import org.onosproject.pcep.controller.PcepClientController; +import org.onosproject.pcep.controller.PcepClientListener; +import org.onosproject.pcep.controller.PcepEventListener; +import org.onosproject.pcep.controller.driver.PcepAgent; +import org.onosproject.pcepio.protocol.PcepMessage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.collect.Sets; + +/** + * Implementation of PCEP client controller. + */ +@Component(immediate = true) +@Service +public class PcepClientControllerImpl implements PcepClientController { + + private static final Logger log = LoggerFactory.getLogger(PcepClientControllerImpl.class); + + protected ConcurrentHashMap connectedClients = + new ConcurrentHashMap<>(); + + protected PcepClientAgent agent = new PcepClientAgent(); + protected Set pcepClientListener = new HashSet<>(); + + protected Set pcepEventListener = Sets.newHashSet(); + + private final Controller ctrl = new Controller(); + + @Activate + public void activate() { + ctrl.start(agent); + log.info("Started"); + } + + @Deactivate + public void deactivate() { + // Close all connected clients + closeConnectedClients(); + ctrl.stop(); + log.info("Stopped"); + } + + @Override + public Collection getClients() { + return connectedClients.values(); + } + + @Override + public PcepClient getClient(PccId pccId) { + return connectedClients.get(pccId); + } + + @Override + public void addListener(PcepClientListener listener) { + if (!pcepClientListener.contains(listener)) { + this.pcepClientListener.add(listener); + } + } + + @Override + public void removeListener(PcepClientListener listener) { + this.pcepClientListener.remove(listener); + } + + @Override + public void addEventListener(PcepEventListener listener) { + pcepEventListener.add(listener); + } + + @Override + public void removeEventListener(PcepEventListener listener) { + pcepEventListener.remove(listener); + } + + @Override + public void writeMessage(PccId pccId, PcepMessage msg) { + this.getClient(pccId).sendMessage(msg); + } + + @Override + public void processClientMessage(PccId pccId, PcepMessage msg) { + PcepClient pc = getClient(pccId); + + switch (msg.getType()) { + case NONE: + break; + case OPEN: + break; + case KEEP_ALIVE: + break; + case PATH_COMPUTATION_REQUEST: + break; + case PATH_COMPUTATION_REPLY: + break; + case NOTIFICATION: + break; + case ERROR: + break; + case CLOSE: + log.info("Sending Close Message to {" + pccId.toString() + "}"); + pc.sendMessage(Collections.singletonList(pc.factory().buildCloseMsg().build())); + //now disconnect client + pc.disconnectClient(); + break; + case REPORT: + for (PcepEventListener l : pcepEventListener) { + l.handleMessage(pccId, msg); + } + break; + case UPDATE: + for (PcepEventListener l : pcepEventListener) { + l.handleMessage(pccId, msg); + } + break; + case INITIATE: + for (PcepEventListener l : pcepEventListener) { + l.handleMessage(pccId, msg); + } + break; + case LABEL_UPDATE: + break; + case MAX: + break; + case END: + break; + default: + break; + } + } + + @Override + public void closeConnectedClients() { + PcepClient pc; + for (PccId id : connectedClients.keySet()) { + pc = getClient(id); + pc.disconnectClient(); + } + } + + /** + * Implementation of an Pcep Agent which is responsible for + * keeping track of connected clients and the state in which + * they are. + */ + public class PcepClientAgent implements PcepAgent { + + private final Logger log = LoggerFactory.getLogger(PcepClientAgent.class); + + @Override + public boolean addConnectedClient(PccId pccId, PcepClient pc) { + + if (connectedClients.get(pccId) != null) { + log.error("Trying to add connectedClient but found a previous " + + "value for pcc ip: {}", pccId.toString()); + return false; + } else { + log.debug("Added Client {}", pccId.toString()); + connectedClients.put(pccId, pc); + for (PcepClientListener l : pcepClientListener) { + l.clientConnected(pccId); + } + return true; + } + } + + @Override + public boolean validActivation(PccId pccId) { + if (connectedClients.get(pccId) == null) { + log.error("Trying to activate client but is not in " + + "connected client: pccIp {}. Aborting ..", pccId.toString()); + return false; + } + + return true; + } + + @Override + public void removeConnectedClient(PccId pccId) { + + connectedClients.remove(pccId); + for (PcepClientListener l : pcepClientListener) { + log.warn("removal for {}", pccId.toString()); + l.clientDisconnected(pccId); + } + } + + @Override + public void processPcepMessage(PccId pccId, PcepMessage m) { + processClientMessage(pccId, m); + } + } +} diff --git a/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java new file mode 100644 index 00000000..a10ff5c8 --- /dev/null +++ b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java @@ -0,0 +1,220 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcep.controller.impl; + +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.RejectedExecutionException; + +import org.jboss.netty.channel.Channel; +import org.onlab.packet.IpAddress; +import org.onosproject.pcep.controller.PccId; +import org.onosproject.pcep.controller.PcepPacketStats; +import org.onosproject.pcep.controller.driver.PcepAgent; +import org.onosproject.pcep.controller.driver.PcepClientDriver; +import org.onosproject.pcepio.protocol.PcepFactories; +import org.onosproject.pcepio.protocol.PcepFactory; +import org.onosproject.pcepio.protocol.PcepMessage; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * An abstract representation of an OpenFlow switch. Can be extended by others + * to serve as a base for their vendor specific representation of a switch. + */ +public class PcepClientImpl implements PcepClientDriver { + + protected final Logger log = LoggerFactory.getLogger(PcepClientImpl.class); + + private static final String SHUTDOWN_MSG = "Worker has already been shutdown"; + + private Channel channel; + protected String channelId; + + private boolean connected; + protected boolean startDriverHandshakeCalled = false; + protected boolean isHandShakeComplete = false; + protected boolean isSyncComplete = false; + private PccId pccId; + private PcepAgent agent; + + private PcepVersion pcepVersion; + private byte keepAliveTime; + private byte deadTime; + private byte sessionId; + private PcepPacketStatsImpl pktStats; + + @Override + public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) { + this.pccId = pccId; + this.pcepVersion = pcepVersion; + this.pktStats = (PcepPacketStatsImpl) pktStats; + } + + @Override + public final void disconnectClient() { + this.channel.close(); + } + + @Override + public final void sendMessage(PcepMessage m) { + log.debug("Sending message to {}", channel.getRemoteAddress()); + try { + channel.write(Collections.singletonList(m)); + this.pktStats.addOutPacket(); + } catch (RejectedExecutionException e) { + log.warn(e.getMessage()); + if (!e.getMessage().contains(SHUTDOWN_MSG)) { + throw e; + } + } + } + + @Override + public final void sendMessage(List msgs) { + try { + channel.write(msgs); + this.pktStats.addOutPacket(msgs.size()); + } catch (RejectedExecutionException e) { + log.warn(e.getMessage()); + if (!e.getMessage().contains(SHUTDOWN_MSG)) { + throw e; + } + } + } + + @Override + public final boolean isConnected() { + return this.connected; + } + + @Override + public final void setConnected(boolean connected) { + this.connected = connected; + }; + + @Override + public final void setChannel(Channel channel) { + this.channel = channel; + final SocketAddress address = channel.getRemoteAddress(); + if (address instanceof InetSocketAddress) { + final InetSocketAddress inetAddress = (InetSocketAddress) address; + final IpAddress ipAddress = IpAddress.valueOf(inetAddress.getAddress()); + if (ipAddress.isIp4()) { + channelId = ipAddress.toString() + ':' + inetAddress.getPort(); + } else { + channelId = '[' + ipAddress.toString() + "]:" + inetAddress.getPort(); + } + } + }; + + @Override + public String channelId() { + return channelId; + } + + @Override + public final PccId getPccId() { + return this.pccId; + } + + @Override + public final String getStringId() { + return this.pccId.toString(); + } + + @Override + public final void setPcVersion(PcepVersion pcepVersion) { + this.pcepVersion = pcepVersion; + } + + @Override + public void setPcKeepAliveTime(byte keepAliveTime) { + this.keepAliveTime = keepAliveTime; + } + + @Override + public void setPcDeadTime(byte deadTime) { + this.deadTime = deadTime; + } + + @Override + public void setPcSessionId(byte sessionId) { + this.sessionId = sessionId; + } + + @Override + public void setIsSyncComplete(boolean value) { + this.isSyncComplete = value; + } + + @Override + public boolean isSyncComplete() { + return isSyncComplete; + } + + @Override + public final void handleMessage(PcepMessage m) { + this.pktStats.addInPacket(); + this.agent.processPcepMessage(pccId, m); + } + + @Override + public final boolean connectClient() { + return this.agent.addConnectedClient(pccId, this); + } + + @Override + public final void removeConnectedClient() { + this.agent.removeConnectedClient(pccId); + } + + @Override + public PcepFactory factory() { + return PcepFactories.getFactory(pcepVersion); + } + + @Override + public boolean isHandshakeComplete() { + return isHandShakeComplete; + } + + @Override + public final void setAgent(PcepAgent ag) { + if (this.agent == null) { + this.agent = ag; + } + } + + @Override + public boolean isOptical() { + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("channel", channelId()) + .add("pccId", getPccId()) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepMessageDecoder.java b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepMessageDecoder.java new file mode 100644 index 00000000..b1065891 --- /dev/null +++ b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepMessageDecoder.java @@ -0,0 +1,68 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller.impl; + +import java.util.LinkedList; +import java.util.List; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.handler.codec.frame.FrameDecoder; +import org.onosproject.pcepio.protocol.PcepFactories; +import org.onosproject.pcepio.protocol.PcepMessage; +import org.onosproject.pcepio.protocol.PcepMessageReader; +import org.onosproject.pcepio.util.HexDump; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Decode an pcep message from a Channel, for use in a netty pipeline. + */ +public class PcepMessageDecoder extends FrameDecoder { + + protected static final Logger log = LoggerFactory.getLogger(PcepMessageDecoder.class); + + @Override + protected Object decode(ChannelHandlerContext ctx, Channel channel, + ChannelBuffer buffer) throws Exception { + log.debug("Message received."); + if (!channel.isConnected()) { + log.info("Channel is not connected."); + // In testing, I see decode being called AFTER decode last. + // This check avoids that from reading corrupted frames + return null; + } + + HexDump.pcepHexDump(buffer); + + // Note that a single call to decode results in reading a single + // PcepMessage from the channel buffer, which is passed on to, and processed + // by, the controller (in PcepChannelHandler). + // This is different from earlier behavior (with the original pcepIO), + // where we parsed all the messages in the buffer, before passing on + // a list of the parsed messages to the controller. + // The performance *may or may not* not be as good as before. + PcepMessageReader reader = PcepFactories.getGenericReader(); + List msgList = new LinkedList<>(); + + while (buffer.readableBytes() > 0) { + PcepMessage message = reader.readFrom(buffer); + msgList.add(message); + } + return msgList; + } +} diff --git a/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepMessageEncoder.java b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepMessageEncoder.java new file mode 100644 index 00000000..ae97221e --- /dev/null +++ b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepMessageEncoder.java @@ -0,0 +1,58 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller.impl; + +import java.util.List; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.handler.codec.oneone.OneToOneEncoder; +import org.onosproject.pcepio.protocol.PcepMessage; +import org.onosproject.pcepio.util.HexDump; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Encode an pcep message for output into a ChannelBuffer, for use in a + * netty pipeline. + */ +public class PcepMessageEncoder extends OneToOneEncoder { + protected static final Logger log = LoggerFactory.getLogger(PcepMessageEncoder.class); + + @Override + protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { + log.debug("Sending message"); + if (!(msg instanceof List)) { + log.debug("Invalid msg."); + return msg; + } + + @SuppressWarnings("unchecked") + List msglist = (List) msg; + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + for (PcepMessage pm : msglist) { + pm.writeTo(buf); + } + + HexDump.pcepHexDump(buf); + + return buf; + } +} diff --git a/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepPacketStatsImpl.java b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepPacketStatsImpl.java new file mode 100644 index 00000000..f2bc51eb --- /dev/null +++ b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepPacketStatsImpl.java @@ -0,0 +1,105 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcep.controller.impl; + +import org.onosproject.pcep.controller.PcepPacketStats; + +/** + * The implementation for PCEP packet statistics. + */ +public class PcepPacketStatsImpl implements PcepPacketStats { + + private int inPacketCount; + private int outPacketCount; + private int wrongPacketCount; + private long time; + + /** + * Default constructor. + */ + public PcepPacketStatsImpl() { + this.inPacketCount = 0; + this.outPacketCount = 0; + this.wrongPacketCount = 0; + this.time = 0; + } + + @Override + public int outPacketCount() { + return outPacketCount; + } + + @Override + public int inPacketCount() { + return inPacketCount; + } + + @Override + public int wrongPacketCount() { + return wrongPacketCount; + } + + /** + * Increments the received packet counter. + */ + public void addInPacket() { + this.inPacketCount++; + } + + /** + * Increments the sent packet counter. + */ + public void addOutPacket() { + this.outPacketCount++; + } + + /** + * Increments the sent packet counter by specified value. + * + * @param value of no of packets sent + */ + public void addOutPacket(int value) { + this.outPacketCount = this.outPacketCount + value; + } + + /** + * Increments the wrong packet counter. + */ + public void addWrongPacket() { + this.wrongPacketCount++; + } + + /** + * Resets wrong packet count. + */ + public void resetWrongPacket() { + this.wrongPacketCount = 0; + } + + @Override + public long getTime() { + return this.time; + } + + /** + * Sets the time value. + * + * @param time long value of time + */ + public void setTime(long time) { + this.time = time; + } +} diff --git a/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepPipelineFactory.java b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepPipelineFactory.java new file mode 100644 index 00000000..f32b87a8 --- /dev/null +++ b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepPipelineFactory.java @@ -0,0 +1,66 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcep.controller.impl; + +import org.jboss.netty.channel.ChannelPipeline; +import org.jboss.netty.channel.ChannelPipelineFactory; +import org.jboss.netty.channel.Channels; +import org.jboss.netty.handler.timeout.IdleStateHandler; +import org.jboss.netty.handler.timeout.ReadTimeoutHandler; +import org.jboss.netty.util.ExternalResourceReleasable; +import org.jboss.netty.util.HashedWheelTimer; +import org.jboss.netty.util.Timer; + +/** + * Creates a ChannelPipeline for a server-side pcep channel. + */ +public class PcepPipelineFactory + implements ChannelPipelineFactory, ExternalResourceReleasable { + + protected Controller controller; + static final Timer TIMER = new HashedWheelTimer(); + protected IdleStateHandler idleHandler; + protected ReadTimeoutHandler readTimeoutHandler; + static final int DEFAULT_KEEP_ALIVE_TIME = 30; + static final int DEFAULT_DEAD_TIME = 120; + static final int DEFAULT_WAIT_TIME = 60; + + public PcepPipelineFactory(Controller controller) { + super(); + this.controller = controller; + this.idleHandler = new IdleStateHandler(TIMER, DEFAULT_DEAD_TIME, DEFAULT_KEEP_ALIVE_TIME, 0); + this.readTimeoutHandler = new ReadTimeoutHandler(TIMER, DEFAULT_WAIT_TIME); + } + + @Override + public ChannelPipeline getPipeline() throws Exception { + PcepChannelHandler handler = new PcepChannelHandler(controller); + + ChannelPipeline pipeline = Channels.pipeline(); + pipeline.addLast("pcepmessagedecoder", new PcepMessageDecoder()); + pipeline.addLast("pcepmessageencoder", new PcepMessageEncoder()); + pipeline.addLast("idle", idleHandler); + pipeline.addLast("waittimeout", readTimeoutHandler); + pipeline.addLast("handler", handler); + return pipeline; + } + + @Override + public void releaseExternalResources() { + TIMER.stop(); + } +} diff --git a/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/package-info.java b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/package-info.java new file mode 100644 index 00000000..d86eefc3 --- /dev/null +++ b/framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Implementation of the PCEP client controller subsystem. + */ +package org.onosproject.pcep.controller.impl; diff --git a/framework/src/onos/protocols/pcep/pcepio/pom.xml b/framework/src/onos/protocols/pcep/pcepio/pom.xml new file mode 100755 index 00000000..d121a83e --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + + + org.onosproject + onos-pcep-controller + 1.4.0-SNAPSHOT + ../pom.xml + + + onos-pcepio + bundle + + ONOS Pcepio Protocol subsystem + + + + + org.onosproject + onos-api + + + org.onosproject + onlab-osgi + + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + + org.osgi + org.osgi.core + + + org.apache.karaf.shell + org.apache.karaf.shell.console + + + org.apache.felix + org.apache.felix.scr.annotations + + + + + + + org.apache.felix + maven-bundle-plugin + + + + + diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepParseException.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepParseException.java new file mode 100755 index 00000000..85bc33fb --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepParseException.java @@ -0,0 +1,92 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.exceptions; + +/** + * Custom Exception for PCEP IO. + */ +public class PcepParseException extends Exception { + + private static final long serialVersionUID = 7960991379951448423L; + private byte errType = 0; + private byte errValue = 0; + + /** + * Default constructor to create a new exception. + */ + public PcepParseException() { + super(); + } + + /** + * Constructor to create exception from message and cause. + * + * @param message the detail of exception in string + * @param cause underlying cause of the error + */ + public PcepParseException(final String message, final Throwable cause) { + super(message, cause); + } + + /** + * Constructor to create exception from message. + * + * @param message the detail of exception in string + */ + public PcepParseException(final String message) { + super(message); + } + + /** + * Constructor to create exception from error type and error value. + * + * @param errType error type of pcep + * @param errValue error value of pcep + */ + public PcepParseException(final byte errType, final byte errValue) { + super(); + this.errType = errType; + this.errValue = errValue; + } + + /** + * Constructor to create exception from cause. + * + * @param cause underlying cause of the error + */ + public PcepParseException(final Throwable cause) { + super(cause); + } + + /** + * Returns error type for this exception. + * + * @return ErrorType + */ + public byte getErrorType() { + return this.errType; + } + + /** + * Returns error value for this exception. + * + * @return ErrorValue + */ + public byte getErrorValue() { + return this.errValue; + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepTunnelAttributeException.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepTunnelAttributeException.java new file mode 100755 index 00000000..25bdf5b6 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepTunnelAttributeException.java @@ -0,0 +1,60 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.exceptions; + +/** + * Custom exception for Tunnel Attributes. + */ +public class PcepTunnelAttributeException extends Exception { + + private static final long serialVersionUID = 7860981378961458434L; + + /** + * Default constructor to create a new exception. + */ + public PcepTunnelAttributeException() { + super(); + } + + /** + * Constructor to create exception from message and cause. + * + * @param message the detail of exception in string + * @param cause underlying cause of the error + */ + public PcepTunnelAttributeException(final String message, final Throwable cause) { + super(message, cause); + } + + /** + * Constructor to create exception from message. + * + * @param message the detail of exception in string + */ + public PcepTunnelAttributeException(final String message) { + super(message); + } + + /** + * Constructor to create exception from cause. + * + * @param cause underlying cause of the error + */ + public PcepTunnelAttributeException(final Throwable cause) { + super(cause); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/package-info.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/package-info.java new file mode 100644 index 00000000..44d09f0d --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PCEP custom exceptions. + */ +package org.onosproject.pcepio.exceptions; diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcInitiatedLspRequest.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcInitiatedLspRequest.java new file mode 100755 index 00000000..6a2fdc88 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcInitiatedLspRequest.java @@ -0,0 +1,185 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity Provides PcInitiatedLspRequest for PCEP Initiate message. + * Reference : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03. + */ +public interface PcInitiatedLspRequest { + + /** + * Returns object of PcepSrpObject. + * + * @return srpObject PCEP SRP object + */ + PcepSrpObject getSrpObject(); + + /** + * Returns object of PcepLspObject. + * + * @return lspObject PCEP LSP object + */ + PcepLspObject getLspObject(); + + /** + * Returns object of PcepEndPointsObject. + * + * @return endPointsObject PCEP EndPoints object + */ + PcepEndPointsObject getEndPointsObject(); + + /** + * Returns object of PcepEroObject. + * + * @return eroObject PCEP ERO object + */ + PcepEroObject getEroObject(); + + /** + * Returns object of PcepAttribute. + * + * @return pcepAttribute PCEP Attributes + */ + PcepAttribute getPcepAttribute(); + + /** + * Sets PcepSrpObject. + * + * @param srpobj PCEP SRP object + */ + void setSrpObject(PcepSrpObject srpobj); + + /** + * Sets PcepLspObject. + * + * @param lspObject PCEP LSP object + */ + void setLspObject(PcepLspObject lspObject); + + /** + * Sets PcepEndPointsObject. + * + * @param endPointsObject PCEP EndPoints object + */ + void setEndPointsObject(PcepEndPointsObject endPointsObject); + + /** + * Sets PcepEroObject. + * + * @param eroObject PCEP ERO object + */ + void setEroObject(PcepEroObject eroObject); + + /** + * Sets PcepAttribute. + * + * @param pcepAttribute PCEP Attributes + */ + void setPcepAttribute(PcepAttribute pcepAttribute); + + /** + * Builder interface with get and set functions to build PcInitiatedLspRequest. + */ + interface Builder { + + /** + * Builds PcInitiatedLspRequest. + * + * @return PcInitiatedLspRequest + * @throws PcepParseException when mandatory object is not set + */ + PcInitiatedLspRequest build() throws PcepParseException; + + /** + * Returns object of PcepSrpObject. + * + * @return srpObject + */ + PcepSrpObject getSrpObject(); + + /** + * Returns object of PcepLspObject. + * + * @return lspObject + */ + PcepLspObject getLspObject(); + + /** + * Returns object of PcepEndPointsObject. + * + * @return endPointsObject + */ + PcepEndPointsObject getEndPointsObject(); + + /** + * Returns object of PcepEroObject. + * + * @return eroObject + */ + PcepEroObject getEroObject(); + + /** + * Returns object of PcepAttribute. + * + * @return pcepAttribute + */ + PcepAttribute getPcepAttribute(); + + /** + * Sets PcepSrpObject. + * + * @param srpobj PCEP SRP Object + * @return builder by setting PcepSrpObject + */ + Builder setSrpObject(PcepSrpObject srpobj); + + /** + * Sets PcepLspObject. + * + * @param lspObject PCEP LSP Object + * @return builder by setting PcepLspObject + */ + Builder setLspObject(PcepLspObject lspObject); + + /** + * Sets PcepEndPointsObject. + * + * @param endPointsObject EndPoints Object + * @return builder by setting PcepEndPointsObject + */ + Builder setEndPointsObject(PcepEndPointsObject endPointsObject); + + /** + * Sets PcepEroObject. + * + * @param eroObject PCEP ERO Object + * @return builder by setting PcepEroObject + */ + Builder setEroObject(PcepEroObject eroObject); + + /** + * Sets PcepAttribute. + * + * @param pcepAttribute PCEP Attributes + * @return builder by setting PcepAttribute + */ + Builder setPcepAttribute(PcepAttribute pcepAttribute); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepAttribute.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepAttribute.java new file mode 100644 index 00000000..122b943f --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepAttribute.java @@ -0,0 +1,166 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity which Provides List of PCEP Attributes. + */ +public interface PcepAttribute { + + /** + * writes lspa , bandwidth , Metriclist and Iro objects to the channel. + * + * @param bb of type channel buffer. + * @return object length index. + * @throws PcepParseException while writing objects to channel buffer + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Returns PcepLspaObject. + * + * @return LspaObject + */ + PcepLspaObject getLspaObject(); + + /** + * Returns PcepBandwidthObject. + * + * @return BandwidthObject + */ + PcepBandwidthObject getBandwidthObject(); + + /** + * Returns PcepIroObject. + * + * @return iroObject + */ + PcepIroObject getIroObject(); + + /** + * Sets the PcepBandwidthObject. + * + * @param bandwidthObject bandwidth object + */ + void setBandwidthObject(PcepBandwidthObject bandwidthObject); + + /** + * Sets the PcepLspaObject. + * + * @param lspaObject lspa object + */ + void setLspaObject(PcepLspaObject lspaObject); + + /** + * Sets the PcepIroObject. + * + * @param iroObject iro object + */ + void setIroObject(PcepIroObject iroObject); + + /** + * Returns PcepMetricObject List. + * + * @return list of metric objects + */ + LinkedList getMetricObjectList(); + + /** + * Sets PcepMetricObject List. + * + * @param llMetricList list of metric objects + */ + void setMetricObjectList(LinkedList llMetricList); + + /** + * Builder interface with get and set functions to build PcepAttribute. + */ + interface Builder { + + /** + * Builds PcepAttribute. + * + * @return PcepAttribute + */ + PcepAttribute build(); + + /** + * Returns PcepLspaObject. + * + * @return LspaObject + */ + PcepLspaObject getLspaObject(); + + /** + * Returns PcepBandwidthObject. + * + * @return BandwidthObject + */ + PcepBandwidthObject getBandwidthObject(); + + /** + * Returns PcepIroObject. + * + * @return iroObject + */ + PcepIroObject getIroObject(); + + /** + * Sets the PcepBandwidthObject. + * + * @param bandwidthObject bandwidth object + * @return Builder object for PcepAttrubute + */ + Builder setBandwidthObject(PcepBandwidthObject bandwidthObject); + + /** + * Sets the PcepLspaObject. + * + * @param lspaObject lspa object + * @return Builder object for PcepAttrubute + */ + Builder setLspaObject(PcepLspaObject lspaObject); + + /** + * Sets the PcepIroObject. + * + * @param iroObject iro object + * @return Builder object for PcepAttrubute + */ + Builder setIroObject(PcepIroObject iroObject); + + /** + * Returns PcepMetricObject List. + * + * @return list of metric objects + */ + LinkedList getMetricObjectList(); + + /** + * Sets PcepMetricObject List. + * + * @param llMetricList list of metric objects + * @return Builder object for PcepAttrubute + */ + Builder setMetricObjectList(LinkedList llMetricList); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepBandwidthObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepBandwidthObject.java new file mode 100755 index 00000000..58d05821 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepBandwidthObject.java @@ -0,0 +1,109 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; + +/** + * Abstraction of an entity providing PCEP Bandwidth Object. + */ +public interface PcepBandwidthObject { + + /** + * Returns bandwidth value. + * + * @return bandwidth value + */ + int getBandwidth(); + + /** + * Sets bandwidth with specified value. + * + * @param iBandwidth Bandwidth's value + */ + void setBandwidth(int iBandwidth); + + /** + * Writes the BandwidthObject into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException if bandwidth object header fails to write in channel buffer + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build bandwidth object. + */ + interface Builder { + + /** + * Builds BandwidthObject. + * + * @return BandwidthObject + * @throws PcepParseException if build fails while creating PcepBandwidthObject + */ + PcepBandwidthObject build() throws PcepParseException; + + /** + * Returns bandwidth object header. + * + * @return bandwidth object header + */ + PcepObjectHeader getBandwidthObjHeader(); + + /** + * Sets bandwidth object header and returns its builder. + * + * @param obj Bandwidth object header + * @return Builder by setting Bandwidth object header + */ + Builder setBandwidthObjHeader(PcepObjectHeader obj); + + /** + * Returns bandwidth value. + * + * @return bandwidth + */ + int getBandwidth(); + + /** + * Sets bandwidth value and return its builder. + * + * @param iBandwidth bandwidth value + * @return Builder by setting bandwidth + */ + Builder setBandwidth(int iBandwidth); + + /** + * Sets P flag in Bandwidth object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in Bandwidth object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepCloseMsg.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepCloseMsg.java new file mode 100644 index 00000000..00fad800 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepCloseMsg.java @@ -0,0 +1,143 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP Close Message. + */ +public interface PcepCloseMsg extends PcepObject, PcepMessage { + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns reason field in Close message. + * + * @return reason field + */ + byte getReason(); + + /** + * Sets reason field in Close message with specified value. + * + * @param value of Reason field + */ + void setReason(byte value); + + /** + * Returns LinkedList of Optional Tlv in Close Message. + * + * @return list of optional tlv + */ + LinkedList getOptionalTlv(); + + /** + * Sets LinkedList of Optional Tlvs in Close Message. + * + * @param llOptionalTlv LinkedList of type PcepValueType + */ + void setOptionalTlv(LinkedList llOptionalTlv); + + @Override + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException; + + /** + * Builder interface with get and set functions to build Close message. + */ + interface Builder extends PcepMessage.Builder { + + @Override + PcepCloseMsg build(); + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns Close Object header. + * + * @return Close Object header + */ + PcepObjectHeader getCloseObjHeader(); + + /** + * Sets close object header and returns its builder. + * + * @param obj close object header + * @return Builder by setting Close object header + */ + Builder setCloseObjHeader(PcepObjectHeader obj); + + /** + * Returns reason field in Close message. + * + * @return reason field in Close message + */ + byte getReason(); + + /** + * Sets reason field and return its builder. + * + * @param value of Reason field + * @return builder by setting reason field + */ + Builder setReason(byte value); + + /** + * Returns LinkedList of Optional Tlvs. + * + * @return list of optional tlv + */ + LinkedList getOptionalTlv(); + + /** + * Sets LinkedList of Optional Tlvs in Close Message. + * + * @param llOptionalTlv list of optional tlv + * @return Builder by setting Optional Tlvs + */ + Builder setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Sets P flag in Close object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in Close object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEndPointsObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEndPointsObject.java new file mode 100755 index 00000000..92d43874 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEndPointsObject.java @@ -0,0 +1,139 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; + +/** + * Abstraction of an entity providing PCEP End Points Object. + */ +public interface PcepEndPointsObject { + + /** + * Returns Source IpAddress from End Points Object. + * + * @return Source IpAddress from End Points Object + */ + int getSourceIpAddress(); + + /** + * Sets Source IpAddress in End Points Object. + * + * @param sourceIpAddress Source IP Address + */ + void setSourceIpAddress(int sourceIpAddress); + + /** + * Returns Destination IpAddress from End Points Object. + * + * @return Destination IpAddress from End Points Object + */ + int getDestIpAddress(); + + /** + * Sets Destination IpAddress in End Points Object. + * + * @param destIpAddress Destination IP Address + */ + void setDestIpAddress(int destIpAddress); + + /** + * Writes the EndPointsObject into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing EndPointObject into ChannelBuffer + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build EndPoints object. + */ + interface Builder { + + /** + * Builds End Points Object. + * + * @return End Points Object + * @throws PcepParseException while building EndPointObject + */ + PcepEndPointsObject build() throws PcepParseException; + + /** + * Returns End Points Object header. + * + * @return End Points Object header + */ + PcepObjectHeader getEndPointsObjHeader(); + + /** + * Sets End Points Object header and returns its builder. + * + * @param obj End Points Object header + * @return Builder by setting End Points Object header + */ + Builder setEndPointsObjHeader(PcepObjectHeader obj); + + /** + * Returns Source IpAddress from End Points Object. + * + * @return Source IpAddress from End Points Object + */ + int getSourceIpAddress(); + + /** + * Sets Source IpAddress in End Points Object and returns builder. + * + * @param sourceIpAddress Source IP Address + * @return Builder by setting Source IpAddress in End Points Object + */ + Builder setSourceIpAddress(int sourceIpAddress); + + /** + * Returns Destination IpAddress from End Points Object. + * + * @return Destination IpAddress from End Points Object + */ + int getDestIpAddress(); + + /** + * Sets Destination IpAddress in End Points Object. + * + * @param destIpAddress Destination IP Address + * @return Builder by setting Destination IpAddress in End Points Object + */ + Builder setDestIpAddress(int destIpAddress); + + /** + * Sets P flag in Bandwidth object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in Bandwidth object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEroObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEroObject.java new file mode 100755 index 00000000..3af6b759 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEroObject.java @@ -0,0 +1,112 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP ERO Object. + */ +public interface PcepEroObject { + + /** + * Return LinkedList of SubObjects of ERO Object. + * + * @return list of subobjects + */ + LinkedList getSubObjects(); + + /** + * Sets LinkedList of SubObjects in ERO Object. + * + * @param llSubObjects list of subobjects + */ + void setSubObjects(LinkedList llSubObjects); + + /** + * Writes the ERO Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing ERO Object into ChannelBuffer + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build ERO object. + */ + interface Builder { + + /** + * Builds ERO Object. + * + * @return ERO Object + */ + PcepEroObject build(); + + /** + * Returns ERO Object Header. + * + * @return ERO Object Header + */ + PcepObjectHeader getEroObjHeader(); + + /** + * Sets ERO Object header and returns its builder. + * + * @param obj ERO Object header + * @return Builder by setting ERO Object header + */ + Builder setEroObjHeader(PcepObjectHeader obj); + + /** + * Returns LinkedList of SubObjects in ERO Objects. + * + * @return list of subobjects + */ + LinkedList getSubObjects(); + + /** + * Sets LinkedList of SubObjects and returns its builder. + * + * @param llSubObjects list of SubObjects + * @return Builder by setting list of SubObjects + */ + Builder setSubObjects(LinkedList llSubObjects); + + /** + * Sets P flag in ERO object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in ERO object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepError.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepError.java new file mode 100755 index 00000000..b61bfb9f --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepError.java @@ -0,0 +1,136 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity which provides PCEP error for PCEP error message. + */ +public interface PcepError { + + /** + * Returns the PcepRPObject List. + * + * @return list of type PcepRPObject + */ + LinkedList getRPObjList(); + + /** + * Sets the RP Objects lists. + * + * @param llRPObjList list of type PcepRPObject + */ + void setRPObjList(LinkedList llRPObjList); + + /** + * Returns the PcepTEObject List. + * + * @return list of type PcepTEObject + */ + LinkedList getTEObjList(); + + /** + * Sets the TE Objects lists. + * + * @param llTEObjList list of type PcepTEObject + */ + void setTEObjList(LinkedList llTEObjList); + + /** + * Returns the PcepErrorObject. + * + * @return list of type PcepErrorObject + */ + LinkedList getErrorObjList(); + + /** + * Sets the Error Objects lists. + * + * @param llErrorObjList list of type PcepErrorObject + */ + void setErrorObjList(LinkedList llErrorObjList); + + /** + * Writes the byte stream of PCEP error to the channel buffer. + * + * @param bb of type channel buffer + * @return object length index + * @throws PcepParseException while writing Error part into ChannelBuffer + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build PcepError. + */ + interface Builder { + + /** + * Builds PcepError Object. + * + * @return PcepError Object + */ + PcepError build(); + + /** + * Returns the PcepRPObject. + * + * @return list of type PcepRPObject + */ + LinkedList getRPObjList(); + + /** + * Sets RP Object lists and returns its builder. + * + * @param llRPObjList list of type PcepRpObject + * @return builder by setting Linked list of RP Object + */ + Builder setRPObjList(LinkedList llRPObjList); + + /** + * Returns the PcepTEObject. + * + * @return llTEObjList of type PcepTEObject + */ + LinkedList getTEObjList(); + + /** + * Sets TE Object lists and returns its builder. + * + * @param llTEObjList list of type PcepTEObject + * @return builder by setting list of type PcepTEObject + */ + Builder setTEObjList(LinkedList llTEObjList); + + /** + * Returns the PcepErrorObject. + * + * @return list of type PcepErrorObject + */ + LinkedList getErrorObjList(); + + /** + * Sets Error Object lists and returns its builder. + * + * @param llErrorObjList list of type PcepErrorObject + * @return builder by setting list of type PcepErrorObject + */ + Builder setErrorObjList(LinkedList llErrorObjList); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorInfo.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorInfo.java new file mode 100755 index 00000000..0c625a03 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorInfo.java @@ -0,0 +1,93 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity which provides PCEP Error Info. + * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02. + */ +public interface PcepErrorInfo { + + /** + * Returns whether error info list is present or not. + * + * @return true if error info present, false otherwise + */ + boolean isErrorInfoPresent(); + + /** + * Reads from channel buffer for TE and RP objects. + * + * @param bb of channel buffer + * @throws PcepParseException while parsing Error info part. + */ + void read(ChannelBuffer bb) throws PcepParseException; + + /** + * Writes byte stream of PCEP error info to channel buffer. + * + * @param bb of type channel buffer + * @throws PcepParseException while writing Error info part into Channel Buffer. + */ + void write(ChannelBuffer bb) throws PcepParseException; + + /** + * Returns Error Value in PCEP-ERROR Object. + * + * @return list of Error Value in PCEP-ERROR Object + */ + LinkedList getErrorValue(); + + /** + * Returns Error Type in PCEP-ERROR Object. + * + * @return list of Error Type in PCEP-ERROR Object + */ + LinkedList getErrorType(); + + /** + * Builder interface with get and set functions to build ErrorInfo. + */ + interface Builder { + + /** + * Builds ErrorInfo Object. + * + * @return ErrorInfo Object. + */ + PcepErrorInfo build(); + + /** + * Returns list of PcepError. + * + * @return list of PcepError + */ + LinkedList getPcepErrorList(); + + /** + * Sets PcepError lists and returns its builder. + * + * @param llPcepErrorList list of PcepError + * @return builder by setting list of PcepError. + */ + Builder setPcepErrorList(LinkedList llPcepErrorList); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorMsg.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorMsg.java new file mode 100644 index 00000000..ff06885d --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorMsg.java @@ -0,0 +1,109 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.ErrorObjListWithOpen; + +/** + * Abstraction of an entity providing PCEP Error Message. + */ +public interface PcepErrorMsg extends PcepMessage { + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns Object of ErrorObjListWithOpen. + * + * @return Object of ErrorObjListWithOpen + */ + ErrorObjListWithOpen getErrorObjListWithOpen(); + + /** + * Sets errObjListWithOpen object. + * + * @param errObjListWithOpen error object List with open object + */ + void setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen); + + /** + * Returns Object of PcepErrorInfo. + * + * @return Object of PcepErrorInfo + */ + PcepErrorInfo getPcepErrorInfo(); + + /** + * Sets errInfo Object. + * + * @param errInfo error information + */ + void setPcepErrorInfo(PcepErrorInfo errInfo); + + @Override + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException; + + /** + * Builder interface with get and set functions to build PCEP Error message. + */ + interface Builder extends PcepMessage.Builder { + + @Override + PcepErrorMsg build(); + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns Object of ErrorObjListWithOpen. + * + * @return Object of ErrorObjListWithOpen + */ + ErrorObjListWithOpen getErrorObjListWithOpen(); + + /** + * Sets errObjListWithOpen object. + * + * @param errObjListWithOpen error object with open object + * @return builder by setting Object of ErrorObjListWithOpen + */ + Builder setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen); + + /** + * Returns Object of PcepErrorInfo. + * + * @return Object of PcepErrorInfo + */ + PcepErrorInfo getPcepErrorInfo(); + + /** + * Sets errInfo Object. + * + * @param errInfo error information + * @return builder by getting Object of PcepErrorInfo + */ + Builder setPcepErrorInfo(PcepErrorInfo errInfo); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorObject.java new file mode 100644 index 00000000..16374d5b --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorObject.java @@ -0,0 +1,169 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP Error Object. + */ +public interface PcepErrorObject { + + /** + * Returns Error Type in Error Object. + * + * @return Error Type in Error Object + */ + int getErrorType(); + + /** + * Sets Error Type in Error Object. + * + * @param value Error Type + */ + void setErrorType(byte value); + + /** + * Returns Error Value in Error Object. + * + * @return Error Value + */ + byte getErrorValue(); + + /** + * Sets Error Value in Error Object. + * + * @param value Error Value + */ + void setErrorValue(byte value); + + /** + * Returns Optional Tlvs in Error Object. + * + * @return list of Optional Tlvs in Error Object + */ + LinkedList getOptionalTlv(); + + /** + * Sets Optional Tlvs in Error Object. + * + * @param llOptionalTlv list of Optional Tlvs + */ + void setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Writes the Error Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing Error Object into ChannelBuffer + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build Error object. + */ + interface Builder { + + /** + * Builds Error Object. + * + * @return Error Object. + */ + PcepErrorObject build(); + + /** + * Returns Error Object header. + * + * @return Error Object header + */ + PcepObjectHeader getErrorObjHeader(); + + /** + * Sets Error Object header and returns its Builder. + * + * @param obj Error Object header + * @return Builder by setting Error Object header + */ + Builder setErrorObjHeader(PcepObjectHeader obj); + + /** + * Returns Error Type in Error Object. + * + * @return Error Type in Error Object + */ + int getErrorType(); + + /** + * Sets Error Type and returns its builder. + * + * @param value of Error-Type field + * @return builder by setting Error Type field. + */ + Builder setErrorType(byte value); + + /** + * Returns Error Value in Error Object. + * + * @return Error Value + */ + byte getErrorValue(); + + /** + * Sets Error Value and returns its builder. + * + * @param value of Error-Value field + * @return Builder by setting Error Value field. + */ + Builder setErrorValue(byte value); + + /** + * Returns list of Optional Tlvs of Error Object. + * + * @return list of Optional Tlvs of Error Object + */ + LinkedList getOptionalTlv(); + + /** + * Sets Optional Tlvs of Error Object and returns its Builder. + * + * @param llOptionalTlv Optional Tlvs of Error Object + * @return Builder by setting Optional Tlvs. + */ + Builder setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Sets P flag in Error object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in Error object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactories.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactories.java new file mode 100644 index 00000000..85416f98 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactories.java @@ -0,0 +1,98 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.ver1.PcepFactoryVer1; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Abstraction to provide the version for PCEP. + */ +public final class PcepFactories { + + protected static final Logger log = LoggerFactory.getLogger(PcepFactories.class); + + private static final GenericReader GENERIC_READER = new GenericReader(); + + public static final byte SHIFT_FLAG = 5; + + private PcepFactories() { + } + + /** + * Returns the instance of PCEP Version. + * + * @param version PCEP version + * @return PCEP version + */ + public static PcepFactory getFactory(PcepVersion version) { + switch (version) { + case PCEP_1: + return PcepFactoryVer1.INSTANCE; + default: + throw new IllegalArgumentException("Unknown version: " + version); + } + } + + private static class GenericReader implements PcepMessageReader { + + @Override + public PcepMessage readFrom(ChannelBuffer bb) throws PcepParseException { + + if (!bb.readable()) { + throw new PcepParseException("Empty message received"); + } + + /* + * 0 1 2 3 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * | Ver | Flags | | + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * + * Currently Version 1 is supported + * Currently no flags are used, it is all ignored + */ + + byte packetVersion = bb.getByte(bb.readerIndex()); + packetVersion = (byte) (packetVersion >> SHIFT_FLAG); + PcepFactory factory; + + switch (packetVersion) { + + case 1: + factory = org.onosproject.pcepio.protocol.ver1.PcepFactoryVer1.INSTANCE; + break; + default: + throw new PcepParseException("Unknown Packet version: " + packetVersion); + } + return factory.getReader().readFrom(bb); + } + } + + /** + * Returns GENERIC_READER. + * + * @return GENERIC_READER + */ + public static PcepMessageReader getGenericReader() { + return GENERIC_READER; + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactory.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactory.java new file mode 100755 index 00000000..1a31e0a3 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactory.java @@ -0,0 +1,255 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +/** + * Abstraction of an Message factory providing Builder functions to PCEP Messages and Objects. + * + */ +public interface PcepFactory { + + /** + * To get Builder Object for Open Message. + * + * @return Builder Object for Open Message + */ + PcepOpenMsg.Builder buildOpenMsg(); + + /** + * To get Builder Object for Open Object. + * + * @return Builder Object for Open Object + */ + PcepOpenObject.Builder buildOpenObject(); + + /** + * To get Builder Object for Keepalive Message. + * + * @return Builder Object for Keepalive Message + */ + PcepKeepaliveMsg.Builder buildKeepaliveMsg(); + + /** + * To get Builder Object for Close Message. + * + * @return Builder Object for Close Message + */ + PcepCloseMsg.Builder buildCloseMsg(); + + /** + * To get Builder Object for Report Message. + * + * @return Builder Object for Report Message + */ + PcepReportMsg.Builder buildReportMsg(); + + /** + * To get Builder Object for Update Message. + * + * @return Builder Object for Update Message + */ + PcepUpdateMsg.Builder buildUpdateMsg(); + + /** + * To get Builder Object for Initiate Message. + * + * @return Builder Object for Initiate Message + */ + PcepInitiateMsg.Builder buildPcepInitiateMsg(); + + /** + * To get Builder Object for LSP Object. + * + * @return Builder Object for LSP Object + */ + PcepLspObject.Builder buildLspObject(); + + /** + * To get Builder Object for SRP Object. + * + * @return Builder Object for SRP Object + */ + PcepSrpObject.Builder buildSrpObject(); + + /** + * To get Builder Object for EndPoints Object. + * + * @return Builder Object for EndPoints Object + */ + PcepEndPointsObject.Builder buildEndPointsObject(); + + /** + * To get Builder Object for ERO Object. + * + * @return Builder Object for ERO Object + */ + PcepEroObject.Builder buildEroObject(); + + /** + * To get Builder Object for RRO Object. + * + * @return Builder Object for RRO Object + */ + PcepRroObject.Builder buildRroObject(); + + /** + * To get Builder Object for LSPA Object. + * + * @return Builder Object for LSPA Object + */ + PcepLspaObject.Builder buildLspaObject(); + + /** + * To get Builder Object for IRO Object. + * + * @return Builder Object for IRO Object + */ + PcepIroObject.Builder buildIroObject(); + + /** + * To get Builder Object for METRIC Object. + * + * @return Builder Object for METRIC Object + */ + PcepMetricObject.Builder buildMetricObject(); + + /** + * To get Builder Object for Bandwidth Object. + * + * @return Builder Object for Bandwidth Object + */ + PcepBandwidthObject.Builder buildBandwidthObject(); + + /** + * Returns PCEP Message Reader. + * + * @return PCEP Message Reader + */ + PcepMessageReader getReader(); + + /** + * Returns PCEP version. + * + * @return PCEP version + */ + PcepVersion getVersion(); + + /** + * Returns PcepStateReport. + * + * @return PcepStateReport + */ + PcepStateReport.Builder buildPcepStateReport(); + + /** + * Returns PcepUpdateRequest. + * + * @return PcepUpdateRequest + */ + PcepUpdateRequest.Builder buildPcepUpdateRequest(); + + /** + * Returns PcInitiatedLspRequest. + * + * @return PcInitiatedLspRequest + */ + PcInitiatedLspRequest.Builder buildPcInitiatedLspRequest(); + + /** + * Returns PcepMsgPath. + * + * @return PcepMsgPath + */ + PcepMsgPath.Builder buildPcepMsgPath(); + + /** + * Return PcepAttribute list. + * + * @return PcepAttribute + */ + PcepAttribute.Builder buildPcepAttribute(); + + /** + * To get Builder Object for LabelUpdate message. + * + * @return Builder Object for LabelUpdate message + */ + PcepLabelUpdateMsg.Builder buildPcepLabelUpdateMsg(); + + /** + * To get Builder Object for PcepLabelUpdate Object. + * + * @return Builder Object for PcepLabelUpdate Object + */ + PcepLabelUpdate.Builder buildPcepLabelUpdateObject(); + + /** + * To get Builder Object for PcepLabel Object. + * + * @return Builder Object for PcepLabel Object + */ + PcepLabelObject.Builder buildLabelObject(); + + /** + * To get Builder Object for Error Message. + * + * @return Builder Object for Error Message + */ + PcepErrorMsg.Builder buildPcepErrorMsg(); + + /** + * To get Builder Object for Error Object. + * + * @return Builder Object for Error Object + */ + PcepErrorObject.Builder buildPcepErrorObject(); + + /** + * To get Builder Object for FecIpv4Adjacency. + * + * @return Builder Object for FecIpv4Adjacency + */ + PcepFecObjectIPv4Adjacency.Builder buildFecIpv4Adjacency(); + + /** + * To get Builder Object for ErrorInfo. + * + * @return Builder Object for ErrorInfo + */ + PcepErrorInfo.Builder buildPcepErrorInfo(); + + /** + * To get Builder Object for PcepError. + * + * @return Builder Object for PcepError + */ + PcepError.Builder buildPcepError(); + + /** + * To get Builder Object for PcepLabelRangeObject. + * + * @return Builder Object for PcepLabelRangeObject + */ + PcepLabelRangeObject.Builder buildPcepLabelRangeObject(); + + /** + * To get Builder Object for PcepLabelRangeResvMsg. + * + * @return Builder Object for PcepLabelRangeResvMsg + */ + PcepLabelRangeResvMsg.Builder buildPcepLabelRangeResvMsg(); +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObject.java new file mode 100755 index 00000000..2df7cc9c --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObject.java @@ -0,0 +1,49 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP FEC Object. + */ +public interface PcepFecObject { + + /** + * Returns PCEP Version of FEC Object. + * + * @return PCEP Version of FEC Object + */ + PcepVersion getVersion(); + + /** + * Returns FEC Object type. + * + * @return FEC Object type + */ + int getType(); + + /** + * Writes the FEC into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing FEC Object into Channel Buffer. + */ + int write(ChannelBuffer bb) throws PcepParseException; +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4.java new file mode 100755 index 00000000..5ed4e1e3 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4.java @@ -0,0 +1,104 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; + +/** + * Abstraction of an entity providing PCEP FEC Object of Type 1 IPv4 Node ID. + */ +public interface PcepFecObjectIPv4 extends PcepFecObject { + + /** + * Returns NodeID of FEC Object. + * + * @return NodeID of FEC Object + */ + int getNodeID(); + + /** + * Sets NodeID with specified value. + * + * @param value node id + */ + void setNodeID(int value); + + @Override + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build FEC object. + */ + interface Builder { + + /** + * Builds FEC Object IPv4. + * + * @return FEC Object IPv4 + * @throws PcepParseException while creating FEC IPv4 Object. + */ + PcepFecObjectIPv4 build() throws PcepParseException; + + /** + * Returns FEC Object IPv4 header. + * + * @return FEC Object IPv4 header + */ + PcepObjectHeader getFecIpv4ObjHeader(); + + /** + * Sets FEC Object IPv4 header and returns its builder. + * + * @param obj FEC Object IPv4 header + * @return Builder by setting FEC Object IPv4 header + */ + Builder setFecIpv4ObjHeader(PcepObjectHeader obj); + + /** + * Returns NodeID of FEC Object. + * + * @return NodeID of FEC Object + */ + int getNodeID(); + + /** + * Sets NodeID and returns its builder. + * + * @param value node id + * @return builder by setting NodeID + */ + Builder setNodeID(int value); + + /** + * Sets P flag in FEC object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in FEC object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4Adjacency.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4Adjacency.java new file mode 100755 index 00000000..55205299 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4Adjacency.java @@ -0,0 +1,133 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; + +/** + * Abstraction of an entity providing FEC Object of Type 3 IPv4 Adjacency. + */ +public interface PcepFecObjectIPv4Adjacency extends PcepFecObject { + + /** + * Returns Local IPv4Address of FEC Object. + * + * @return Local IPv4Address of FEC Object + */ + int getLocalIPv4Address(); + + /** + * Sets Local IPv4Address with specified value. + * + * @param value Local IPv4Address + */ + void seLocalIPv4Address(int value); + + /** + * Returns Remote IPv4Address of FEC Object. + * + * @return Remote IPv4Address of FEC Object + */ + int getRemoteIPv4Address(); + + /** + * Sets Remote IPv4Address with specified value. + * + * @param value Remote IPv4Address + */ + void seRemoteIPv4Address(int value); + + @Override + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build FEC object. + */ + interface Builder { + + /** + * Builds FEC Object IPv4 Adjacency. + * + * @return FEC Object IPv4 Adjacency + * @throws PcepParseException while building FEC IPv4 Adjacency object. + */ + PcepFecObjectIPv4Adjacency build() throws PcepParseException; + + /** + * Returns FEC Object IPv4 Adjacency header. + * + * @return FEC Object IPv4 Adjacency header + */ + PcepObjectHeader getFecIpv4AdjacencyObjHeader(); + + /** + * Sets FEC Object IPv4 Adjacency header and returns its builder. + * + * @param obj FEC Object IPv4 Adjacency header + * @return Builder by setting FEC Object IPv4 header + */ + Builder setFecIpv4AdjacencyObjHeader(PcepObjectHeader obj); + + /** + * Returns Local IPv4Address of FEC Object. + * + * @return Local IPv4Address of FEC Object + */ + int getLocalIPv4Address(); + + /** + * Sets Local IPv4Address and returns its builder. + * + * @param value Local IPv4Address + * @return Builder by setting Local IPv4Address + */ + Builder seLocalIPv4Address(int value); + + /** + * Sets Remote IPv4Address with specified value. + * + * @return Remote IPv4 Address + */ + int getRemoteIPv4Address(); + + /** + * Sets Remote IPv4Address and returns its builder. + * + * @param value Remote IPv4Address + * @return Builder by setting Remote IPv4Address + */ + Builder seRemoteIPv4Address(int value); + + /** + * Sets P flag in FEC object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in FEC object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4UnnumberedAdjacency.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4UnnumberedAdjacency.java new file mode 100755 index 00000000..d240445e --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4UnnumberedAdjacency.java @@ -0,0 +1,191 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; + +/** + * Abstraction of an entity providing PCEP FEC Object of Type is 5 Unnumbered Adjacency with IPv4 NodeIDs. + */ +public interface PcepFecObjectIPv4UnnumberedAdjacency extends PcepFecObject { + + /** + * Returns Local NodeID of FEC Object. + * + * @return Local NodeID of FEC Object + */ + int getLocalNodeID(); + + /** + * Sets Local NodeID with specified value. + * + * @param value Local NodeID + */ + void setLocalNodeID(int value); + + /** + * Returns Local InterfaceID of FEC Object. + * + * @return Local InterfaceID of FEC Object + */ + int getLocalInterfaceID(); + + /** + * Sets Local InterfaceID with specified value. + * + * @param value Local InterfaceID + */ + void setLocalInterfaceID(int value); + + /** + * Returns Remote NodeID of FEC Object. + * + * @return Remote NodeID of FEC Object + */ + int getRemoteNodeID(); + + /** + * Sets Remote NodeID with specified value. + * + * @param value Remote NodeID + */ + void setRemoteNodeID(int value); + + /** + * Returns Remote InterfaceID of FEC Object. + * + * @return Remote InterfaceID of FEC Object + */ + int getRemoteInterfaceID(); + + /** + * Sets Remote InterfaceID with specified value. + * + * @param value Remote InterfaceID + */ + void setRemoteInterfaceID(int value); + + @Override + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build bandwidth object. + */ + interface Builder { + + /** + * Builds FEC Unnumbered Adjacency with IPv4 Object. + * + * @return FEC Unnumbered Adjacency with IPv4 Object + * @throws PcepParseException when building FEC IPv4 Unnumbered Adjacency object. + */ + PcepFecObjectIPv4UnnumberedAdjacency build() throws PcepParseException; + + /** + * Returns FEC Unnumbered Adjacency with IPv4 header. + * + * @return FEC Unnumbered Adjacency with IPv4 header + */ + PcepObjectHeader getFecIpv4UnnumberedAdjacencyObjHeader(); + + /** + * Sets FEC Unnumbered Adjacency with IPv4 header and returns its builder. + * + * @param obj FEC Unnumbered Adjacency with IPv4 header + * @return Builder by setting FEC Unnumbered Adjacency with IPv4 header + */ + Builder setFecIpv4UnnumberedAdjacencyObjHeader(PcepObjectHeader obj); + + /** + * Returns Local NodeID of FEC Object. + * + * @return Local NodeID of FEC Object + */ + int getLocalNodeID(); + + /** + * Sets Local NodeID and returns its builder. + * + * @param value Local NodeID + * @return Builder by setting Local NodeID + */ + Builder setLocalNodeID(int value); + + /** + * Returns Local InterfaceID of FEC Object. + * + * @return Local InterfaceID of FEC Object + */ + int getLocalInterfaceID(); + + /** + * Sets Local InterfaceID and returns its builder. + * + * @param value Local InterfaceID + * @return Builder by setting Local InterfaceID + */ + Builder setLocalInterfaceID(int value); + + /** + * Returns Remote NodeID of FEC Object. + * + * @return Remote NodeID of FEC Object + */ + int getRemoteNodeID(); + + /** + * Sets Remote NodeID and returns its builder. + * + * @param value Remote NodeID + * @return Builder by setting Remote NodeID + */ + Builder setRemoteNodeID(int value); + + /** + * Returns Remote InterfaceID of FEC Object. + * + * @return Remote InterfaceID of FEC Object + */ + int getRemoteInterfaceID(); + + /** + * Sets Remote InterfaceID and returns its builder. + * + * @param value Remote InterfaceID + * @return Builder by setting Remote InterfaceID + */ + Builder setRemoteInterfaceID(int value); + + /** + * Sets P flag in FEC object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in FEC object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6.java new file mode 100755 index 00000000..1c29b76a --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6.java @@ -0,0 +1,104 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; + +/** + * Abstraction of an entity providing FEC Object of Type is 2 IPv6 Node ID. + */ +public interface PcepFecObjectIPv6 extends PcepFecObject { + + /** + * Returns NodeID of FEC Object. + * + * @return NodeID of FEC Object + */ + byte[] getNodeID(); + + /** + * Sets NodeID with specified value. + * + * @param value node id + */ + void setNodeID(byte[] value); + + @Override + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build FEC object. + */ + interface Builder { + + /** + * Builds FEC Object IPv6. + * + * @return FEC Object IPv6 + * @throws PcepParseException while building FEC IPv6 Object. + */ + PcepFecObjectIPv6 build() throws PcepParseException; + + /** + * Returns FEC Object IPv6 header. + * + * @return FEC Object IPv6 header + */ + PcepObjectHeader getFecIpv6ObjHeader(); + + /** + * Sets FEC Object IPv6 header and returns its builder. + * + * @param obj FEC Object IPv6 header + * @return Builder by setting FEC Object IPv6 header + */ + Builder setFecIpv6ObjHeader(PcepObjectHeader obj); + + /** + * Returns NodeID of FEC Object. + * + * @return NodeID of FEC Object + */ + byte[] getNodeID(); + + /** + * Sets NodeID and returns its builder. + * + * @param value node id + * @return Builder by setting NodeID + */ + Builder setNodeID(byte[] value); + + /** + * Sets P flag in FEC object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in FEC object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6Adjacency.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6Adjacency.java new file mode 100755 index 00000000..ef802780 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6Adjacency.java @@ -0,0 +1,133 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; + +/** + * Abstraction of an entity providing FEC Object of Type is 4 IPv6 Adjacency. + */ +public interface PcepFecObjectIPv6Adjacency extends PcepFecObject { + + /** + * Returns Local IPv6Address of FEC Object. + * + * @return Local IPv6Address of FEC Object + */ + byte[] getLocalIPv6Address(); + + /** + * Sets Local IPv6Address with specified value. + * + * @param value Local IPv6Address + */ + void seLocalIPv6Address(byte[] value); + + /** + * Returns Remote IPv6Address of FEC Object. + * + * @return Remote IPv6Address of FEC Object + */ + byte[] getRemoteIPv6Address(); + + /** + * Sets Remote IPv6Address with specified value. + * + * @param value Remote IPv6Address + */ + void seRemoteIPv6Address(byte[] value); + + @Override + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build FEC object. + */ + interface Builder { + + /** + * Builds FEC Object IPv6 Adjacency. + * + * @return FEC Object IPv6 Adjacency + * @throws PcepParseException while building FEC IPv6 Adjacency object. + */ + PcepFecObjectIPv6Adjacency build() throws PcepParseException; + + /** + * Returns FEC Object IPv6 Adjacency header. + * + * @return FEC Object IPv6 Adjacency header + */ + PcepObjectHeader getFecIpv6AdjacencyObjHeader(); + + /** + * Sets FEC Object IPv6 Adjacency header and returns its builder. + * + * @param obj FEC Object IPv6 Adjacency header + * @return Builder by setting FEC Object IPv6 Adjacency header + */ + Builder setFecIpv6AdjacencyObjHeader(PcepObjectHeader obj); + + /** + * Returns Local IPv6Address of FEC Object. + * + * @return Local IPv6Address of FEC Object + */ + byte[] getLocalIPv6Address(); + + /** + * Sets Local IPv6Address and returns its builder. + * + * @param value Local IPv6Address + * @return Builder by setting Local IPv6Address + */ + Builder setLocalIPv6Address(byte[] value); + + /** + * Returns Remote IPv6Address of FEC Object. + * + * @return Remote IPv6Address of FEC Object + */ + byte[] getRemoteIPv6Address(); + + /** + * Sets Remote IPv6Address and returns its builder. + * + * @param value Remote IPv6Address + * @return Builder by setting Remote IPv6Address + */ + Builder setRemoteIPv6Address(byte[] value); + + /** + * Sets P flag in FEC object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in FEC object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInitiateMsg.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInitiateMsg.java new file mode 100755 index 00000000..2b061430 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInitiateMsg.java @@ -0,0 +1,81 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Initiate Message. + */ +public interface PcepInitiateMsg extends PcepObject, PcepMessage { + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns list of PcInitiatedLspRequestList. + * + * @return list of PcInitiatedLspRequestList + */ + LinkedList getPcInitiatedLspRequestList(); + + /** + * Sets list of PcInitiatedLspRequestList. + * + * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequestList + */ + void setPcInitiatedLspRequestList(LinkedList llPcInitiatedLspRequestList); + + @Override + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException; + + /** + * Builder interface with get and set functions to build Initiate message. + */ + interface Builder extends PcepMessage.Builder { + + @Override + PcepInitiateMsg build(); + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns list of PcInitiatedLspRequestList. + * + * @return list of PcInitiatedLspRequestList + */ + LinkedList getPcInitiatedLspRequestList(); + + /** + * Sets PcInitiatedLspRequestList. + * + * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequestList + * @return builder by setting list of PcInitiatedLspRequestList + */ + Builder setPcInitiatedLspRequestList(LinkedList llPcInitiatedLspRequestList); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInterLayerObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInterLayerObject.java new file mode 100755 index 00000000..675e0557 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInterLayerObject.java @@ -0,0 +1,137 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; + +/** + * Abstraction of an entity providing PCEP INTER Layer Object. + */ +public interface PcepInterLayerObject { + + /** + * Returns N Flag in INTER Layer Object. + * + * @return N Flag in INTER Layer Object + */ + boolean getbNFlag(); + + /** + * Sets N Flag in INTER Layer Object with specified value. + * + * @param value N Flag + */ + void setbNFlag(boolean value); + + /** + * Returns I Flag in INTER Layer Object. + * + * @return I Flag in INTER Layer Object + */ + boolean getbIFlag(); + + /** + * Sets I Flag in INTER Layer Object with specified value. + * + * @param value I Flag + */ + void setbIFlag(boolean value); + + /** + * Writes the INTER Layer Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing Inter Layer Object. + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build INTER Layer object. + */ + interface Builder { + + /** + * Builds INTER Layer object. + * + * @return INTER Layer object + */ + PcepInterLayerObject build(); + + /** + * Returns INTER Layer object header. + * + * @return INTER Layer object header + */ + PcepObjectHeader getInterLayerObjHeader(); + + /** + * Sets INTER Layer object header and returns its builder. + * + * @param obj INTER Layer object header + * @return Builder by setting INTER Layer object header + */ + Builder setInterLayerObjHeader(PcepObjectHeader obj); + + /** + * Returns N Flag in INTER Layer Object. + * + * @return N Flag in INTER Layer Object + */ + boolean getbNFlag(); + + /** + * Sets N flag and return its builder. + * + * @param value N flag + * @return Builder by setting N flag + */ + Builder setbNFlag(boolean value); + + /** + * Returns I Flag in INTER Layer Object. + * + * @return I Flag in INTER Layer Object + */ + boolean getbIFlag(); + + /** + * Sets I flag and return its builder. + * + * @param value I flag + * @return Builder by setting N flag + */ + Builder setbIFlag(boolean value); + + /** + * Sets P flag in INTER Layer object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in INTER Layer object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepIroObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepIroObject.java new file mode 100755 index 00000000..a1c1fc59 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepIroObject.java @@ -0,0 +1,110 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP IRO Object. + */ +public interface PcepIroObject { + + /** + * Returns list of SubObjects. + * + * @return list of SubObjects + */ + LinkedList getSubObjects(); + + /** + * Sets list of SubObjects. + * + * @param llSubObjects list of SubObjects + */ + void setSubObjects(LinkedList llSubObjects); + + /** + * Writes the IRO into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing IRO object. + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build IRO object. + */ + interface Builder { + + /** + * Builds IRO Object. + * + * @return IRO Object + */ + PcepIroObject build(); + + /** + * Returns IRO object header. + * + * @return IRO object header + */ + PcepObjectHeader getIroObjHeader(); + + /** + * Sets IRO object header and returns its builder. + * + * @param obj IRO object header + * @return Builder by setting IRO object header + */ + Builder setIroObjHeader(PcepObjectHeader obj); + + /** + * Returns list of SubObjects. + * + * @return list of SubObjects + */ + LinkedList getSubObjects(); + + /** + * Sets list of SubObjects in IRO Object and returns its builder. + * + * @param llSubObjects list of SubObjects + * @return Builder by setting list of SubObjects + */ + Builder setSubObjects(LinkedList llSubObjects); + + /** + * Sets P flag in IRO object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in IRO object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsg.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsg.java new file mode 100755 index 00000000..160f0a2a --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsg.java @@ -0,0 +1,49 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; + +/** + * Abstraction of an entity providing PCEP Keepalive Message. + */ +public interface PcepKeepaliveMsg extends PcepObject, PcepMessage { + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + @Override + void writeTo(ChannelBuffer channelBuffer); + + /** + * Builder interface with get and set functions to build Keepalive message. + */ + interface Builder extends PcepMessage.Builder { + + @Override + PcepKeepaliveMsg build(); + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelObject.java new file mode 100755 index 00000000..b64c21e0 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelObject.java @@ -0,0 +1,171 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP Label Object. + */ +public interface PcepLabelObject { + + /** + * Returns O flag in Label Object. + * + * @return Boolean value + */ + boolean getOFlag(); + + /** + * Sets O flag in Label Object with specified value. + * + * @param value O flag + */ + void setOFlag(boolean value); + + /** + * Returns Label from Label Object. + * + * @return Label value + */ + int getLabel(); + + /** + * Sets Label field in Label Object with specified value. + * + * @param value Label + */ + void setLabel(int value); + + /** + * Returns list of Optional Tlvs. + * + * @return list of Optional Tlvs + */ + LinkedList getOptionalTlv(); + + /** + * Sets Optional Tlvs in Label Object. + * + * @param llOptionalTlv list of Optional Tlvs + */ + void setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Writes the Label Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing LABEL object into Channel Buffer. + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build Label object. + */ + interface Builder { + + /** + * Builds Label Object. + * + * @return Label Object + * @throws PcepParseException while building LABEL object. + */ + PcepLabelObject build() throws PcepParseException; + + /** + * Returns Label object header. + * + * @return Label object header + */ + PcepObjectHeader getLabelObjHeader(); + + /** + * Sets Label object header and returns its builder. + * + * @param obj Label object header + * @return Builder by setting Label object header + */ + Builder setLabelObjHeader(PcepObjectHeader obj); + + /** + * Returns O flag in Label Object. + * + * @return Label value + */ + boolean getOFlag(); + + /** + * Sets O flag and return its builder. + * + * @param value O flag + * @return Builder by setting O flag + */ + Builder setOFlag(boolean value); + + /** + * Returns Label from Label Object. + * + * @return Label value + */ + int getLabel(); + + /** + * Sets Label field and return its builder. + * + * @param value Label field + * @return Builder by setting Label field + */ + Builder setLabel(int value); + + /** + * Returns list of Optional Tlvs. + * + * @return list of Optional Tlvs + */ + LinkedList getOptionalTlv(); + + /** + * Sets list of Optional Tlvs and return its builder. + * + * @param llOptionalTlv list of Optional Tlvs + * @return Builder by setting list of Optional Tlvs + */ + Builder setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Sets P flag in Label object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in Label object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRange.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRange.java new file mode 100755 index 00000000..72d0a38e --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRange.java @@ -0,0 +1,65 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Label Range. + */ +public interface PcepLabelRange { + + /** + * Returns object of PCEP SRP Object. + * + * @return srpObject + */ + PcepSrpObject getSrpObject(); + + /** + * Sets PCEP SRP Object. + * + * @param srpObject SRP object. + */ + void setSrpObject(PcepSrpObject srpObject); + + /** + * Returns list of PcepLabelRangeObject. + * + * @return Label Range List + */ + LinkedList getLabelRangeList(); + + /** + * Sets list of PcepLabelRangeObject. + * + * @param llLabelRangeList Label Range List + */ + void setLabelRangeList(LinkedList llLabelRangeList); + + /** + * Write the byte stream of PcepLabelRange to channel buffer. + * + * @param bb of type channel buffer + * @return object length index + * @throws PcepParseException while writing LABEL RANGE into Channel Buffer. + */ + int write(ChannelBuffer bb) throws PcepParseException; +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeObject.java new file mode 100755 index 00000000..9155434e --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeObject.java @@ -0,0 +1,182 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; + +/** + * Abstraction of an entity providing PCEP LabelRange Object. + */ +public interface PcepLabelRangeObject { + + /** + * Sets LabelRange Object header. + * + * @param obj LabelRange Object header + */ + void setLabelRangeObjHeader(PcepObjectHeader obj); + + /** + * Sets LabelType in LabelRange Object. + * + * @param labelType label type value + */ + void setLabelType(byte labelType); + + /** + * Sets RangeSize in LabelRange Object. + * + * @param rangeSize range size value + */ + void setRangeSize(int rangeSize); + + /** + * Sets LabelBase in LabelRange Object. + * + * @param labelBase label base value + */ + void setLabelBase(int labelBase); + + /** + * Returns LabelRange object header. + * + * @return LabelRange object header + */ + PcepObjectHeader getLabelRangeObjHeader(); + + /** + * Returns LabelType field in LabelRange object. + * + * @return LabelType field in LabelRange object + */ + byte getLabelType(); + + /** + * Returns RangeSize field in LabelRange object. + * + * @return RangeSize field in LabelRange object + */ + int getRangeSize(); + + /** + * Returns LabelBase field in LabelRange object. + * + * @return LabelBase field in LabelRange object + */ + int getLabelBase(); + + /** + * Writes the LabelRange Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing LABEL RANGE object into Channel Buffer. + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build LabelRange object. + */ + interface Builder { + + /** + * Builds LabelRange Object. + * + * @return LabelRange Object + * @throws PcepParseException while building LABEL RANGE object. + */ + PcepLabelRangeObject build() throws PcepParseException; + + /** + * Returns LabelRange object header. + * + * @return LabelRange object header + */ + PcepObjectHeader getLabelRangeObjHeader(); + + /** + * Sets LabelRange object header and returns its builder. + * + * @param obj LabelRange object header + * @return Builder by setting LabelRange object header + */ + Builder setLabelRangeObjHeader(PcepObjectHeader obj); + + /** + * Returns LabelType field in LabelRange object. + * + * @return LabelType field in LabelRange object + */ + byte getLabelType(); + + /** + * Sets LabelType field and returns its builder. + * + * @param labelType LabelType field + * @return Builder by setting LabelType field + */ + Builder setLabelType(byte labelType); + + /** + * Returns RangeSize field in LabelRange object. + * + * @return RangeSize field in LabelRange object + */ + int getRangeSize(); + + /** + * Sets RangeSize field and returns its builder. + * + * @param rangeSize RangeSize field + * @return Builder by setting RangeSize field + */ + Builder setRangeSize(int rangeSize); + + /** + * Returns LabelBase field in LabelRange object. + * + * @return LabelBase field in LabelRange object + */ + int getLabelBase(); + + /** + * Sets LabelBase field and returns its builder. + * + * @param labelBase LabelBase field + * @return Builder by setting LabelBase field + */ + Builder setLabelBase(int labelBase); + + /** + * Sets P flag in TE object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in TE object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeResvMsg.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeResvMsg.java new file mode 100755 index 00000000..3e2a3a95 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeResvMsg.java @@ -0,0 +1,79 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Label Range Reservation Message. + */ +public interface PcepLabelRangeResvMsg extends PcepObject, PcepMessage { + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns LabelRange field in Label Range Reservation message. + * + * @return LabelRange field + */ + PcepLabelRange getLabelRange(); + + /** + * Sets LabelRange field in Label Range Reservation message with specified value. + * + * @param lR label range object + */ + void setLabelRange(PcepLabelRange lR); + + @Override + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException; + + /** + * Builder interface with get and set functions to build Label Range Reservation message. + */ + interface Builder extends PcepMessage.Builder { + + @Override + PcepLabelRangeResvMsg build(); + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns LabelRange field in Label Range Reservation message. + * + * @return LabelRange object + */ + PcepLabelRange getLabelRange(); + + /** + * Sets LabelRange field and returns its Builder. + * + * @param lR label range object + * @return builder by setting LabelRange field + */ + Builder setLabelRange(PcepLabelRange lR); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdate.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdate.java new file mode 100644 index 00000000..5ef870d4 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdate.java @@ -0,0 +1,108 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepLabelDownload; +import org.onosproject.pcepio.types.PcepLabelMap; + +/*** + * Abstraction to provide PCEP Label Updates. + */ +public interface PcepLabelUpdate { + + /** + * Writes the byte stream of PcepLabelUpdate into channel buffer. + * + * @param bb of type channel buffer + * @throws PcepParseException while writing LABEL UPDATE. + */ + void write(ChannelBuffer bb) throws PcepParseException; + + /** + * Sets the Label Download object. + * + * @param labelDownload PCEP Label Download object + */ + void setLabelDownload(PcepLabelDownload labelDownload); + + /** + * Returns the PcepLabelDownload object. + * + * @return labelDownload PCEP Label Download + */ + PcepLabelDownload getLabelDownload(); + + /** + * Sets the Label map object. + * + * @param labelMap PCEP Label Map object + */ + void setLabelMap(PcepLabelMap labelMap); + + /** + * Returns the PcepLabelMap object. + * + * @return labelMap PCEP Label Map + */ + PcepLabelMap getLabelMap(); + + /** + * Builder interface with get and set functions to build Label Update message. + */ + interface Builder { + + /** + * Builds PcepLableUpdate Object. + * + * @return PcepLableUpdate Object + * @throws PcepParseException while building LABEL-UPDATE. + */ + PcepLabelUpdate build() throws PcepParseException; + + /** + * Sets the Label Download object. + * + * @param labelDownload PCEP Label Download object + * @return Builder by setting labelDownload object + */ + Builder setLabelDownload(PcepLabelDownload labelDownload); + + /** + * Returns the PcepLabelDownload object. + * + * @return labelDownload PCEP Label Download + */ + PcepLabelDownload getLabelDownload(); + + /** + * Sets the Label map object. + * + * @param labelMap PCEP Label Map object + * @return Builder by setting PcepLabelMap object + */ + Builder setLabelMap(PcepLabelMap labelMap); + + /** + * Returns the PcepLabelMap object. + * + * @return labelMap PCEP Label Map + */ + PcepLabelMap getLabelMap(); + } + +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsg.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsg.java new file mode 100755 index 00000000..3740df3b --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsg.java @@ -0,0 +1,81 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Label Update Message. + */ +public interface PcepLabelUpdateMsg extends PcepObject, PcepMessage { + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns list of PcLabelUpdateList. + * + * @return list of PcLabelUpdateList. + */ + LinkedList getPcLabelUpdateList(); + + /** + * Sets list of PcLabelUpdateList. + * + * @param llPcLabelUpdateList list of PcLabelUpdateList + */ + void setPcLabelUpdateList(LinkedList llPcLabelUpdateList); + + @Override + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException; + + /** + * Builder interface with get and set functions to build Label Update message. + */ + interface Builder extends PcepMessage.Builder { + + @Override + PcepLabelUpdateMsg build(); + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns list of PcLabelUpdateList. + * + * @return list of PcLabelUpdateList. + */ + LinkedList getPcLabelUpdateList(); + + /** + * Sets list of PcLabelUpdateList. + * + * @param llPcLabelUpdateList list of PcLabelUpdateList. + * @return Builder by setting list of PcLabelUpdateList. + */ + Builder setPcLabelUpdateList(LinkedList llPcLabelUpdateList); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspObject.java new file mode 100755 index 00000000..5d55250a --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspObject.java @@ -0,0 +1,286 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP LSP Object. + */ +public interface PcepLspObject { + + /** + * Returns PlspId of LSP Object. + * + * @return PlspId of LSP Object + */ + int getPlspId(); + + /** + * Sets PlspId with specified value. + * + * @param value PlspId + */ + void setPlspId(int value); + + /** + * Returns O flag in LSP Object. + * + * @return O flag in LSP Object + */ + byte getOFlag(); + + /** + * Sets O flag with specified value. + * + * @param value O flag + */ + void setOFlag(byte value); + + /** + * Returns A flag in LSP Object. + * + * @return A flag in LSP Object + */ + boolean getAFlag(); + + /** + * Sets A flag with specified value. + * + * @param value A flag + */ + void setAFlag(boolean value); + + /** + * Returns R flag in LSP Object. + * + * @return R flag in LSP Object + */ + boolean getRFlag(); + + /** + * Sets R flag with specified value. + * + * @param value R flag + */ + void setRFlag(boolean value); + + /** + * Returns S flag in LSP Object. + * + * @return S flag in LSP Object + */ + boolean getSFlag(); + + /** + * Sets S flag with specified value. + * + * @param value S flag + */ + void setSFlag(boolean value); + + /** + * Returns D flag in LSP Object. + * + * @return D flag in LSP Object + */ + boolean getDFlag(); + + /** + * Sets D flag with specified value. + * + * @param value D flag + */ + void setDFlag(boolean value); + + /** + * Returns list of Optional Tlvs in LSP Object. + * + * @return list of Optional Tlvs + */ + LinkedList getOptionalTlv(); + + /** + * Sets list of Optional Tlvs in LSP Object. + * + * @param llOptionalTlv list of Optional Tlvs + */ + void setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Writes the LSP Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing LSP object into Channel Buffer. + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build LSP object. + */ + interface Builder { + + /** + * Builds LSP Object. + * + * @return LSP Object + */ + PcepLspObject build(); + + /** + * Returns LSP object header. + * + * @return LSP object header + */ + PcepObjectHeader getLspObjHeader(); + + /** + * Sets LSP object header and returns its builder. + * + * @param obj LSP object header + * @return Builder by setting LSP object header + */ + Builder setLspObjHeader(PcepObjectHeader obj); + + /** + * Returns PlspId of LSP Object. + * + * @return PlspId of LSP Object + */ + int getPlspId(); + + /** + * Sets PlspId with specific value and return its builder. + * + * @param value PlspId + * @return Builder by setting PlspId + */ + Builder setPlspId(int value); + + /** + * Returns O flag in LSP Object. + * + * @return O flag in LSP Object + */ + byte getOFlag(); + + /** + * Sets O flag with specific value and return its builder. + * + * @param value O flag + * @return Builder by setting O flag + */ + Builder setOFlag(byte value); + + /** + * Returns A flag in LSP Object. + * + * @return A flag in LSP Object + */ + boolean getAFlag(); + + /** + * Sets A flag with specific value and return its builder. + * + * @param value A flag + * @return Builder by setting A flag + */ + Builder setAFlag(boolean value); + + /** + * Returns A flag in LSP Object. + * + * @return A flag in LSP Object + */ + boolean getRFlag(); + + /** + * Sets R flag with specific value and return its builder. + * + * @param value r flag + * @return Builder by setting r flag + */ + Builder setRFlag(boolean value); + + /** + * Returns S flag in LSP Object. + * + * @return S flag in LSP Object + */ + boolean getSFlag(); + + /** + * Sets S flag with specific value and return its builder. + * + * @param value s flag + * @return Builder by setting S flag + */ + Builder setSFlag(boolean value); + + /** + * Returns D flag in LSP Object. + * + * @return D flag in LSP Object + */ + boolean getDFlag(); + + /** + * Sets D flag with specific value and return its builder. + * + * @param value D flag + * @return Builder by setting D flag + */ + Builder setDFlag(boolean value); + + /** + * Returns list of Optional Tlvs in LSP Object. + * + * @return list of Optional Tlvs in LSP Object + */ + LinkedList getOptionalTlv(); + + /** + * Sets list of Optional Tlvs and return its builder. + * + * @param llOptionalTlv list of Optional Tlvs + * @return Builder by setting list of Optional Tlvs + */ + Builder setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Sets P flag in LSP object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in LSP object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspaObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspaObject.java new file mode 100755 index 00000000..d541e92b --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspaObject.java @@ -0,0 +1,286 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP LSPA Object. + */ +public interface PcepLspaObject { + + /** + * Returns L flag in LSPA Object. + * + * @return L flag in LSPA Object + */ + boolean getLFlag(); + + /** + * Sets L flag in LSPA Object. + * + * @param value L flag + */ + void setLFlag(boolean value); + + /** + * Returns Exclude Any field in LSPA Object. + * + * @return Exclude Any field in LSPA Object + */ + int getExcludeAny(); + + /** + * Sets Exclude Any field in LSPA Object. + * + * @param value Exclude Any field + */ + void setExcludeAny(int value); + + /** + * Returns Include Any field in LSPA Object. + * + * @return Include Any field in LSPA Object + */ + int getIncludeAny(); + + /** + * Sets Include Any field in LSPA Object. + * + * @param value Include Any field + */ + void setIncludeAny(int value); + + /** + * Returns Include All field in LSPA Object. + * + * @return Include All field in LSPA Object + */ + int getIncludeAll(); + + /** + * Sets Include All field in LSPA Object. + * + * @param value Include All field + */ + void setIncludeAll(int value); + + /** + * Returns Setup Priority field in LSPA Object. + * + * @return Setup Priority field in LSPA Object + */ + byte getSetupPriority(); + + /** + * Sets Setup Priority field in LSPA Object. + * + * @param value Setup Priority field + */ + void setSetupPriority(byte value); + + /** + * Returns Hold Priority field in LSPA Object. + * + * @return Hold Priority field in LSPA Object + */ + byte getHoldPriority(); + + /** + * Sets Hold Priority field in LSPA Object. + * + * @param value Hold Priority field + */ + void setHoldPriority(byte value); + + /** + * Returns list of Optional Tlvs in LSPA Object. + * + * @return list of Optional Tlvs in LSPA Object + */ + LinkedList getOptionalTlv(); + + /** + * Sets Optional Tlvs in LSPA Object. + * + * @param llOptionalTlv Optional Tlvs in LSPA Object + */ + void setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Writes the LSPA Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing LSPA object into Channel Buffer. + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build bandwidth object. + */ + interface Builder { + + /** + * Builds LSPA Object. + * + * @return LSPA Object + * @throws PcepParseException while building LSPA object. + */ + PcepLspaObject build() throws PcepParseException; + + /** + * Returns LSPA object header. + * + * @return LSPA object header + */ + PcepObjectHeader getLspaObjHeader(); + + /** + * Sets LSPA object header and returns its builder. + * + * @param obj LSPA object header + * @return Builder by setting LSPA object header + */ + Builder setLspaObjHeader(PcepObjectHeader obj); + + /** + * Returns L flag in LSPA Object. + * + * @return L flag in LSPA Object + */ + boolean getLFlag(); + + /** + * Sets L flag in LSPA Object and return its builder. + * + * @param value L flag in LSPA Object + * @return Builder by setting L flag + */ + Builder setLFlag(boolean value); + + /** + * Returns Exclude Any field in LSPA Object. + * + * @return Exclude Any field in LSPA Object + */ + int getExcludeAny(); + + /** + * Sets Exclude Any field in LSPA Object and return its builder. + * + * @param value Exclude Any field in LSPA Object + * @return Builder by setting Exclude Any field + */ + Builder setExcludeAny(int value); + + /** + * Returns Include Any field in LSPA Object. + * + * @return Include Any field in LSPA Object + */ + int getIncludeAny(); + + /** + * Sets Include Any field in LSPA Object and return its builder. + * + * @param value Include Any field in LSPA Object + * @return Builder by setting Include Any field + */ + Builder setIncludeAny(int value); + + /** + * Returns Include All field in LSPA Object. + * + * @return Include All field in LSPA Object + */ + int getIncludeAll(); + + /** + * Sets Include All field in LSPA Object and return its builder. + * + * @param value Include All field in LSPA Object + * @return Builder by setting Include All field + */ + Builder setIncludeAll(int value); + + /** + * Returns Setup Priority field in LSPA Object. + * + * @return Setup Priority field in LSPA Object + */ + byte getSetupPriority(); + + /** + * Sets Setup Priority field in LSPA Object and return its builder. + * + * @param value Setup Priority field in LSPA Object + * @return Builder by setting Setup Priority field + */ + Builder setSetupPriority(byte value); + + /** + * Returns Hold Priority field in LSPA Object. + * + * @return Hold Priority field in LSPA Object + */ + byte getHoldPriority(); + + /** + * Sets Hold Priority field in LSPA Object and return its builder. + * + * @param value Hold Priority field in LSPA Object + * @return Builder by setting Hold Priority field + */ + Builder setHoldPriority(byte value); + + /** + * Returns list of Optional Tlvs in LSPA Object. + * + * @return list of Optional Tlvs in LSPA Object + */ + LinkedList getOptionalTlv(); + + /** + * Sets list of Optional Tlvs in LSPA Object. + * + * @param llOptionalTlv list of Optional Tlvs + * @return builder by setting list of Optional Tlvs + */ + Builder setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Sets P flag in LSPA object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in LSPA object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessage.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessage.java new file mode 100755 index 00000000..7de07169 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessage.java @@ -0,0 +1,67 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Messages. + */ +public interface PcepMessage extends PcepObject { + + @Override + PcepVersion getVersion(); + + /** + * Returns Type of PCEP Message. + * + * @return Type of PCEP Message + */ + PcepType getType(); + + @Override + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException; + + /** + * Builder interface with get and set functions to build PCEP Message. + */ + interface Builder { + + /** + * Builds PCEP Message. + * + * @return PCEP Message + * @throws PcepParseException when build fails to create PCEP message + */ + PcepMessage build() throws PcepParseException; + + /** + * Returns Version of PCEP Message. + * + * @return Version of PCEP Message + */ + PcepVersion getVersion(); + + /** + * Returns Type of PCEP Message. + * + * @return Type of PCEP Message + */ + PcepType getType(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageReader.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageReader.java new file mode 100755 index 00000000..591a033d --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageReader.java @@ -0,0 +1,36 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Message Reader. + */ +public interface PcepMessageReader { + + /** + * Reads the Objects in the PCEP Message and Returns PCEP Message. + * + * @param bb Channel Buffer + * @return PCEP Message + * @throws PcepParseException while parsing PCEP message. + * @throws PcepParseException when received message is empty + */ + T readFrom(ChannelBuffer bb) throws PcepParseException; +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageWriter.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageWriter.java new file mode 100755 index 00000000..e7477b51 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageWriter.java @@ -0,0 +1,35 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Message Writer. + */ +public interface PcepMessageWriter { + + /** + * Writes the Objects of the PCEP Message into Channel Buffer. + * + * @param bb Channel Buffer + * @param message PCEP Message + * @throws PcepParseException while writing PCEP message. + */ + void write(ChannelBuffer bb, T message) throws PcepParseException; +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMetricObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMetricObject.java new file mode 100755 index 00000000..380fb42e --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMetricObject.java @@ -0,0 +1,225 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; + +/** + * Abstraction of an entity providing PCEP Metric Object. + */ +public interface PcepMetricObject { + + /** + * Returns Metric value in Metric Object. + * + * @return Metric value + */ + int getMetricVal(); + + /** + * Sets Metric value in Metric Object with specified value. + * + * @param value Metric value + */ + void setMetricVal(int value); + + /** + * Returns Y flag in Metric Object. + * + * @return Y flag in Metric Object + */ + byte getYFlag(); + + /** + * Sets Y flag in Metric Object with specified value. + * + * @param value Y flag + */ + void setYFlag(byte value); + + /** + * Returns C flag in Metric Object. + * + * @return C flag in Metric Object + */ + boolean getCFlag(); + + /** + * Sets C flag in Metric Object with specified value. + * + * @param value C flag + */ + void setCFlag(boolean value); + + /** + * Returns B flag in Metric Object. + * + * @return B flag in Metric Object + */ + boolean getBFlag(); + + /** + * Sets B flag in Metric Object with specified value. + * + * @param value B flag + */ + void setBFlag(boolean value); + + /** + * Returns BType field in Metric Object. + * + * @return BType field in Metric Object + */ + byte getBType(); + + /** + * Sets BType field in Metric Object with specified value. + * + * @param value BType field + */ + void setBType(byte value); + + /** + * Writes the Metric Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing METRIC object into Channel Buffer. + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build Metric object. + */ + interface Builder { + + /** + * Builds Metric Object. + * + * @return Metric Object + * @throws PcepParseException when mandatory object is not set + */ + PcepMetricObject build() throws PcepParseException; + + /** + * Returns Metric object header. + * + * @return Metric object header + */ + PcepObjectHeader getMetricObjHeader(); + + /** + * Sets Metric object header and returns its builder. + * + * @param obj Metric object header + * @return Builder by setting Metric object header + */ + Builder setMetricObjHeader(PcepObjectHeader obj); + + /** + * Returns Metric value in Metric Object. + * + * @return Metric value + */ + int getMetricVal(); + + /** + * Sets Metric Value in Metric Object and returns its builder. + * + * @param value Metric Value + * @return Builder by setting Metric Value + */ + Builder setMetricVal(int value); + + /** + * Returns Flags in Metric Object. + * + * @return Flags in Metric Object + */ + byte getYFlag(); + + /** + * Sets Flags in Metric Object and returns its builder. + * + * @param value Flags + * @return Builder by setting Flags + */ + Builder setYFlag(byte value); + + /** + * Returns C flag in Metric Object. + * + * @return C flag in Metric Object + */ + boolean getCFlag(); + + /** + * Sets C flag in Metric Object and returns its builder. + * + * @param value C flag + * @return Builder by setting C flag + */ + Builder setCFlag(boolean value); + + /** + * Returns B flag in Metric Object. + * + * @return B flag in Metric Object + */ + boolean getBFlag(); + + /** + * Sets B flag in Metric Object and returns its builder. + * + * @param value B flag + * @return Builder by setting B flag + */ + Builder setBFlag(boolean value); + + /** + * Returns BType field in Metric Object. + * + * @return BType field in Metric Object + */ + byte getBType(); + + /** + * Sets B Type field in Metric Object and returns its builder. + * + * @param value B Type field + * @return Builder by setting B Type field + */ + Builder setBType(byte value); + + /** + * Sets P flag in Metric object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in Metric object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMsgPath.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMsgPath.java new file mode 100644 index 00000000..4b1d50a5 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMsgPath.java @@ -0,0 +1,117 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity Provides PCEP Message PAth for update message. + * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10. + */ +public interface PcepMsgPath { + + /** + * Returns object of PcepEroObject. + * + * @return eroObject + */ + PcepEroObject getEroObject(); + + /** + * Returns object of PcepAttribute. + * + * @return pcepAttribute + */ + PcepAttribute getPcepAttribute(); + + /** + * Sets PcepEroObject. + * + * @param eroObject PCEP ERO Object. + */ + void setEroObject(PcepEroObject eroObject); + + /** + * Sets PcepAttribute. + * + * @param pcepAttribute PCEP-Attribute. + */ + void setPcepAttribute(PcepAttribute pcepAttribute); + + /** + * reads ERO object and attribute list. + * + * @param bb of type channel buffer + * @return PcepMsgPath + * @throws PcepParseException while parsing Message Path from Channel Buffer. + */ + PcepMsgPath read(ChannelBuffer bb) throws PcepParseException; + + /** + * writes ERO object and attribute list to channel. + * + * @param bb of type channel buffer + * @return object length index + * @throws PcepParseException while writing Message Path into Channel Buffer. + */ + + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build PcepMsgPath. + */ + interface Builder { + + /** + * Builds PcepMsgPath. + * + * @return PcepMsgPath + * @throws PcepParseException when mandatory object is not set + */ + PcepMsgPath build() throws PcepParseException; + + /** + * Returns object of PcepEroObject. + * + * @return PcepEroObject + */ + PcepEroObject getEroObject(); + + /** + * Returns object of PcepAttribute. + * + * @return pcepAttribute + */ + PcepAttribute getPcepAttribute(); + + /** + * Sets PcepEroObject. + * + * @param eroObject PcepEroObject + * @return Builder by setting ERO object. + */ + Builder setEroObject(PcepEroObject eroObject); + + /** + * Sets PcepAttribute. + * + * @param pcepAttribute PCEP-Attribute + * @return Builder by setting PCEP-Attribute. + */ + Builder setPcepAttribute(PcepAttribute pcepAttribute); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepNai.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepNai.java new file mode 100755 index 00000000..6be8c65a --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepNai.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; + +/** + * Abstraction of an entity provides NAI information in SR ERO Object. + */ +public interface PcepNai { + + /** + * To get the ST type of the NAI information. + * + * @return type of ST info + */ + byte getType(); + + /** + * To write the object information to channelBuffer. + * + * @param cb of type channel buffer + * @return length of written bytes. + */ + int write(ChannelBuffer cb); +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepObject.java new file mode 100755 index 00000000..26dad566 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepObject.java @@ -0,0 +1,30 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +/** + * Abstraction of an entity providing PCEP Object. + */ +public interface PcepObject extends Writeable { + + /** + * Returns Version of PCEP Object. + * + * @return Version of PCEP Object + */ + PcepVersion getVersion(); +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenMsg.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenMsg.java new file mode 100644 index 00000000..904156f0 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenMsg.java @@ -0,0 +1,73 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Open Message. + */ +public interface PcepOpenMsg extends PcepObject, PcepMessage { + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Sets OpenObject in Open Message with Specified Obj. + * + * @param obj OpenObject + */ + void setPcepOpenObject(PcepOpenObject obj); + + /** + * Returns OpenObject in Open Message. + * + * @return OpenObject in Open Message + */ + PcepOpenObject getPcepOpenObject(); + + @Override + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException; + + /** + * Builder interface with get and set functions to build Open message. + */ + interface Builder extends PcepMessage.Builder { + + @Override + PcepOpenMsg build() throws PcepParseException; + + /** + * Sets Open Object in Open Message and return its builder. + * + * @param obj Open Object + * @return builder by setting Open Object + */ + Builder setPcepOpenObj(PcepOpenObject obj); + + /** + * Returns OpenObject in Open Message. + * + * @return OpenObject in Open Message + */ + PcepOpenObject getPcepOpenObj(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenObject.java new file mode 100755 index 00000000..13dd2fa8 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenObject.java @@ -0,0 +1,221 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP Open Object. + */ +public interface PcepOpenObject { + + /** + * Returns Open object header. + * + * @return Open object header + */ + PcepObjectHeader getOpenObjHeader(); + + /** + * Sets Open object header in Open Object. + * + * @param obj Open object header + */ + void setOpenObjHeader(PcepObjectHeader obj); + + /** + * Returns version of Open Object. + * + * @return Version of Open Object + */ + PcepVersion getVersion(); + + /** + * Returns KeepAlive Time in Open Object. + * + * @return KeepAlive Time in Open Object + */ + byte getKeepAliveTime(); + + /** + * Sets KeepAlive Time in Open Object with specified value. + * + * @param value KeepAlive Time + */ + void setKeepAliveTime(byte value); + + /** + * Returns Dead Time in Open Object. + * + * @return Dead Time in Open Object + */ + byte getDeadTime(); + + /** + * Sets Dead Time in Open Object with specified value. + * + * @param value Dead Time + */ + void setDeadTime(byte value); + + /** + * Returns SessionId in Open Object. + * + * @return SessionId in Open Object + */ + byte getSessionId(); + + /** + * Sets SessionId in Open Object with specified value. + * + * @param value SessionId + */ + void setSessionId(byte value); + + /** + * Returns list of Optional Tlvs in Open Object. + * + * @return list of Optional Tlvs + */ + LinkedList getOptionalTlv(); + + /** + * Sets list of Optional Tlvs in Open Object. + * + * @param llOptionalTlv list of Optional Tlvs + */ + void setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Writes the Open into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing Open Object into Channel Buffer. + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build Open object. + */ + interface Builder { + + /** + * Builds Open Object. + * + * @return Open Object + * @throws PcepParseException while building PCEP-Open object + */ + PcepOpenObject build() throws PcepParseException; + + /** + * Returns Open object header. + * + * @return Open object header + */ + PcepObjectHeader getOpenObjHeader(); + + /** + * Sets Open object header and returns its builder. + * + * @param obj Open object header + * @return Builder by setting Open object header + */ + Builder setOpenObjHeader(PcepObjectHeader obj); + + /** + * Returns KeepAlive Time in Open Object. + * + * @return KeepAlive Time in Open Object + */ + byte getKeepAliveTime(); + + /** + * Sets KeepAlive Time and returns its builder. + * + * @param value KeepAlive Time + * @return Builder by setting KeepAlive Time + */ + Builder setKeepAliveTime(byte value); + + /** + * Returns Dead Time in Open Object. + * + * @return Dead Time in Open Object + */ + byte getDeadTime(); + + /** + * Sets Dead Time and returns its builder. + * + * @param value Dead Time + * @return Builder by setting Dead Time + */ + Builder setDeadTime(byte value); + + /** + * Returns SessionId in Open Object. + * + * @return SessionId in Open Object + */ + byte getSessionId(); + + /** + * Sets SessionId and returns its builder. + * + * @param value SessionId + * @return Builder by setting SessionId + */ + Builder setSessionId(byte value); + + /** + * Returns list of Optional Tlvs in Open Object. + * + * @return list of Optional Tlvs in Open Object + */ + LinkedList getOptionalTlv(); + + /** + * Sets list of Optional Tlvs and return its Builder. + * + * @param llOptionalTlv list of Optional Tlvs + * @return builder by setting list of Optional Tlvs + */ + Builder setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Sets P flag in Open object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in Open object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRPObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRPObject.java new file mode 100755 index 00000000..c6993c3a --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRPObject.java @@ -0,0 +1,256 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP RP Object. + */ +public interface PcepRPObject { + + /** + * Returns RequestId Number in RP Object. + * + * @return RequestId Number in RP Object + */ + int getRequestIdNum(); + + /** + * Sets RequestId Number with specified value. + * + * @param value RequestId Number + */ + void setRequestIdNum(int value); + + /** + * Returns O flag in RP Object. + * + * @return O flag in RP Object + */ + boolean getOFlag(); + + /** + * Sets O flag with specified value. + * + * @param value O flag + */ + void setOFlag(boolean value); + + /** + * Returns B flag in RP Object. + * + * @return B flag in RP Object + */ + boolean getBFlag(); + + /** + * Sets B flag with specified value. + * + * @param value B flag + */ + void setBFlag(boolean value); + + /** + * Returns R flag in RP Object. + * + * @return R flag in RP Object + */ + boolean getRFlag(); + + /** + * Sets R flag with specified value. + * + * @param value R flag + */ + void setRFlag(boolean value); + + /** + * Returns Priority Flag in RP Object. + * + * @return Priority Flag in RP Object + */ + byte getPriFlag(); + + /** + * Sets Priority Flag with specified value. + * + * @param value Priority Flag + */ + void setPriFlag(byte value); + + /** + * Returns list of Optional Tlvs in RP Object. + * + * @return list of Optional Tlvs in RP Object + */ + LinkedList getOptionalTlv(); + + /** + * Sets list of Optional Tlvs in RP Object and returns its builder. + * + * @param llOptionalTlv list of Optional Tlvs + */ + void setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Writes the RP Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException while writing RP object into Channel Buffer. + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build bandwidth object. + */ + interface Builder { + + /** + * Builds RP Object. + * + * @return RP Object + */ + PcepRPObject build(); + + /** + * Returns RP object header. + * + * @return RP object header + */ + PcepObjectHeader getRPObjHeader(); + + /** + * Sets RP object header and returns its builder. + * + * @param obj RP object header + * @return Builder by setting RP object header + */ + Builder setRPObjHeader(PcepObjectHeader obj); + + /** + * Returns Request Id Number in RP Object. + * + * @return Request Id Number in RP Object + */ + int getRequestIdNum(); + + /** + * Sets Request Id Number and returns its builder. + * + * @param value Request Id Number + * @return Builder by setting Request Id Number + */ + Builder setRequestIdNum(int value); + + /** + * Returns O flag in RP Object. + * + * @return O flag in RP Object + */ + boolean getOFlag(); + + /** + * Sets O flag and returns its builder. + * + * @param value O flag + * @return Builder by setting O flag + */ + Builder setOFlag(boolean value); + + /** + * Returns B flag in RP Object. + * + * @return B flag in RP Object + */ + boolean getBFlag(); + + /** + * Sets B flag and returns its builder. + * + * @param value B flag + * @return Builder by setting B flag + */ + Builder setBFlag(boolean value); + + /** + * Returns R flag in RP Object. + * + * @return R flag in RP Object + */ + boolean getRFlag(); + + /** + * Sets R flag and returns its builder. + * + * @param value R flag + * @return Builder by setting R flag + */ + Builder setRFlag(boolean value); + + /** + * Returns Priority Flag in RP Object. + * + * @return Priority Flag in RP Object + */ + byte getPriFlag(); + + /** + * Sets Priority Flag and returns its builder. + * + * @param value Priority Flag + * @return Builder by setting Priority Flag + */ + Builder setPriFlag(byte value); + + /** + * Returns list of Optional Tlvs in RP Object. + * + * @return list of Optional Tlvs + */ + LinkedList getOptionalTlv(); + + /** + * Sets list of Optional Tlvs and returns its builder. + * + * @param llOptionalTlv list of Optional Tlvs + * @return Builder by setting list of Optional Tlvs + */ + Builder setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Sets P flag in RP object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in RP object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepReportMsg.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepReportMsg.java new file mode 100755 index 00000000..f4355206 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepReportMsg.java @@ -0,0 +1,81 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Report Message. + */ +public interface PcepReportMsg extends PcepObject, PcepMessage { + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns PcepStateReport list. + * + * @return list of PcepStateReport + */ + LinkedList getStateReportList(); + + /** + * Sets StateReportList. + * + * @param llStateReportList list of PcepStateReport. + */ + void setStateReportList(LinkedList llStateReportList); + + @Override + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException; + + /** + * Builder interface with get and set functions to build Report message. + */ + interface Builder extends PcepMessage.Builder { + + @Override + PcepReportMsg build(); + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns StateReportList. + * + * @return StateReportList. + */ + LinkedList getStateReportList(); + + /** + * Sets list of PcepStateReport and returns builder. + * + * @param llStateReportList list of PcepStateReport. + * @return Builder by setting list of PcepStateReport. + */ + Builder setStateReportList(LinkedList llStateReportList); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRroObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRroObject.java new file mode 100755 index 00000000..928ce1a6 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRroObject.java @@ -0,0 +1,111 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP RRO Object. + */ +public interface PcepRroObject { + + /** + * Returns list of SubObjects. + * + * @return list of SubObjects + */ + LinkedList getSubObjects(); + + /** + * Sets list of SubObjects and return its builder. + * + * @param llSubObjects list of SubObjects + */ + void setSubObjects(LinkedList llSubObjects); + + /** + * Writes the RRO Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException when object header failed to write in channel buffer + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build RRO object. + */ + interface Builder { + + /** + * Builds RRO Object. + * + * @return RRO Object + */ + PcepRroObject build(); + + /** + * Returns RRO object header. + * + * @return RRO object header + */ + PcepObjectHeader getRroObjHeader(); + + /** + * Sets RRO object header and returns its builder. + * + * @param obj RRO object header + * @return Builder by setting RRO object header + */ + Builder setRroObjHeader(PcepObjectHeader obj); + + /** + * Returns list of SubObjects. + * + * @return list of SubObjects + */ + LinkedList getSubObjects(); + + /** + * Sets list of SubObjects in RRO Object and returns its builder. + * + * @param llSubObjects list of SubObjects + * @return Builder by setting list of SubObjects + */ + Builder setSubObjects(LinkedList llSubObjects); + + /** + * Sets P flag in RRO object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in RRO object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepSrpObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepSrpObject.java new file mode 100755 index 00000000..e4816efd --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepSrpObject.java @@ -0,0 +1,171 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP SRP Object. + */ +public interface PcepSrpObject { + + /** + * Returns SRP ID of SRP Object. + * + * @return SRP ID of SRP Object + */ + int getSrpID(); + + /** + * Sets SRP ID with specified value. + * + * @param srpID SRP ID of SRP Object + */ + void setSrpID(int srpID); + + /** + * Returns R flag of SRP Object. + * + * @return R flag of SRP Object + */ + boolean getRFlag(); + + /** + * Sets R flag with specified value. + * + * @param bRFlag R Flag of SRP Object + */ + void setRFlag(boolean bRFlag); + + /** + * sets the optional TLvs. + * + * @param llOptionalTlv list of optional tlvs + */ + void setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Returns list of optional tlvs. + * + * @return llOptionalTlv list of optional tlvs + */ + LinkedList getOptionalTlv(); + + /** + * Writes the SRP Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException when tlv is null + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build SRP object. + */ + interface Builder { + + /** + * Builds SRP Object. + * + * @return SRP Object + * @throws PcepParseException when mandatory object is not set + */ + PcepSrpObject build() throws PcepParseException; + + /** + * Returns SRP object header. + * + * @return SRP object header + */ + PcepObjectHeader getSrpObjHeader(); + + /** + * Sets SRP object header and returns its builder. + * + * @param obj SRP object header + * @return Builder by setting SRP object header + */ + Builder setSrpObjHeader(PcepObjectHeader obj); + + /** + * Returns SRP ID of SRP Object. + * + * @return SRP ID of SRP Object + */ + int getSrpID(); + + /** + * Sets SRP ID and returns its builder. + * + * @param srpID SRP ID + * @return Builder by setting SRP ID + */ + Builder setSrpID(int srpID); + + /** + * Returns R flag of SRP Object. + * + * @return R flag of SRP Object + */ + boolean getRFlag(); + + /** + * Sets R flag and returns its builder. + * + * @param bRFlag R flag + * @return Builder by setting R flag + */ + Builder setRFlag(boolean bRFlag); + + /** + * Returns list of optional tlvs. + * + * @return llOptionalTlv list of optional tlvs + */ + LinkedList getOptionalTlv(); + + /** + * sets the optional TLvs. + * + * @param llOptionalTlv List of optional tlv + * @return builder by setting list of optional tlv. + */ + Builder setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Sets P flag in SRP object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in SRP object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepStateReport.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepStateReport.java new file mode 100755 index 00000000..b8ab9ec8 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepStateReport.java @@ -0,0 +1,207 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity provides State Report for PCEP Report Message. + */ +public interface PcepStateReport { + + /** + * Provides PCEP Message path for report message. + */ + interface PcepMsgPath { + + /** + * Returns PcepEroObject. + * + * @return eroObj + */ + PcepEroObject getEroObject(); + + /** + * Sets PcepEroObject. + * + * @param eroObject Ero Object + */ + void setEroObject(PcepEroObject eroObject); + + /** + * Returns PcepAttribute. + * + * @return attrList + */ + PcepAttribute getPcepAttribute(); + + /** + * Sets PcepAttribute. + * + * @param pcepAttribute Pcep Attribute object + */ + void setPcepAttribute(PcepAttribute pcepAttribute); + + /** + * Returns PcepRroObject. + * + * @return rroObj + */ + PcepRroObject getRroObject(); + + /** + * Sets PcepRroObject. + * + * @param rroObject Rro object + */ + void setRroObject(PcepRroObject rroObject); + + /** + * Returns PcepBandwidthObject. + * + * @return bandwidth object + */ + PcepBandwidthObject getBandwidthObject(); + + /** + * Sets PcepBandwidthObject. + * + * @param bandwidth bandwidth object + */ + void setBandwidthObject(PcepBandwidthObject bandwidth); + + /** + * Reads all the Objects for PCEP Message Path. + * + * @param bb of type channel buffer + * @return PCEP Message path + * @throws PcepParseException when invalid buffer received + */ + PcepMsgPath read(ChannelBuffer bb) throws PcepParseException; + + /** + * Writes all the objects for pcep message path. + * + * @param bb of type channel buffer. + * @return object length index + * @throws PcepParseException when mandatory object is not set + */ + int write(ChannelBuffer bb) throws PcepParseException; + } + + /** + * Returns PcepSrpObject. + * + * @return srpObject + */ + PcepSrpObject getSrpObject(); + + /** + * Returns PcepLspObject. + * + * @return lspObject + */ + PcepLspObject getLspObject(); + + /** + * Returns PcepMsgPath. + * + * @return msgPath + */ + PcepMsgPath getMsgPath(); + + /** + * Sets the SRP Object. + * + * @param srpObj Pcep Srp Object + */ + void setSrpObject(PcepSrpObject srpObj); + + /** + * Sets the LSP Object. + * + * @param lspObject Pcep Lsp Object + */ + void setLspObject(PcepLspObject lspObject); + + /** + * Sets the Path Object. + * + * @param msgPath Pcep MsgPath object + */ + void setMsgPath(PcepMsgPath msgPath); + + /** + * Builder interface with get and set functions to build PcepStateReport. + */ + interface Builder { + + /** + * Builds PcepStateReport. + * + * @return PcepStateReport + * @throws PcepParseException when mandatory object is not set + */ + PcepStateReport build() throws PcepParseException; + + /** + * Returns PcepSrpObject. + * + * @return srpObject + */ + PcepSrpObject getSrpObject(); + + /** + * Returns PcepLspObject. + * + * @return lspObject + */ + PcepLspObject getLspObject(); + + /** + * Returns PcepMsgPath. + * + * @return msgPath + */ + PcepMsgPath getMsgPath(); + + /** + * Sets the SRP Object. + * + * @param srpObj Pcep Srp Object + * @return builder by setting PcepSrpObject + */ + Builder setSrpObject(PcepSrpObject srpObj); + + /** + * Sets the LSP Object. + * + * @param lspObject Pcep Lsp Object + * @return builder by setting PcepLspObject + */ + Builder setLspObject(PcepLspObject lspObject); + + /** + * Sets the Path Object. + * + * @param msgPath Pcep MsgPath object + * @return builder by setting PcepMsgPath + */ + Builder setMsgPath(PcepMsgPath msgPath); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepTEObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepTEObject.java new file mode 100755 index 00000000..21f6c71c --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepTEObject.java @@ -0,0 +1,241 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; + +/** + * Abstraction of an entity providing PCEP TE Object. + */ +public interface PcepTEObject { + + /** + * Returns TE object header. + * + * @return TE object header + */ + PcepObjectHeader getTEObjHeader(); + + /** + * Sets TE Object header. + * + * @param obj TE Object header + */ + void setTEObjHeader(PcepObjectHeader obj); + + /** + * Returns ProtocolId in TE Object. + * + * @return ProtocolId in TE Object + */ + byte getProtocolId(); + + /** + * Sets ProtocolId in TE Object. + * + * @param yProtId ProtocolId in TE Object + */ + void setProtocolId(byte yProtId); + + /** + * Returns R flag in TE Object. + * + * @return R flag in TE Object + */ + boolean getRFlag(); + + /** + * Sets R flag in TE Object. + * + * @param bRFlag R flag in TE Object + */ + void setRFlag(boolean bRFlag); + + /** + * Returns S flag in TE Object. + * + * @return S flag in TE Object + */ + boolean getSFlag(); + + /** + * Sets S flag in TE Object. + * + * @param bSFlag S flag in TE Object + */ + void setSFlag(boolean bSFlag); + + /** + * Returns TE ID in TE Object. + * + * @return TE ID in TE Object + */ + int getTEId(); + + /** + * Sets TE ID in TE Object. + * + * @param iTEId TE ID in TE Object + */ + void setTEId(int iTEId); + + /** + * Returns list of Optional Tlvs in TE Object. + * + * @return list of Optional Tlvs + */ + LinkedList getOptionalTlv(); + + /** + * Sets list of Optional Tlvs in TE Object. + * + * @param llOptionalTlv list of Optional Tlvs + */ + void setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Writes the TE Object into channel buffer. + * + * @param bb channel buffer + * @return Returns the writerIndex of this buffer + * @throws PcepParseException when obj header is not written to channel buffer + */ + int write(ChannelBuffer bb) throws PcepParseException; + + /** + * Builder interface with get and set functions to build TE object. + */ + interface Builder { + + /** + * Builds TE Object. + * + * @return TE Object + */ + PcepTEObject build(); + + /** + * Returns TE object header. + * + * @return TE object header + */ + PcepObjectHeader getTEObjHeader(); + + /** + * Sets TE object header and returns its builder. + * + * @param obj TE object header + * @return Builder by setting TE object header + */ + Builder setTEObjHeader(PcepObjectHeader obj); + + /** + * Returns ProtocolId in TE Object. + * + * @return ProtocolId in TE Object + */ + byte getProtocolId(); + + /** + * Sets ProtocolId in TE Object and returns its builder. + * + * @param yProtId ProtocolId in TE Object + * @return Builder by setting ProtocolId + */ + Builder setProtocolId(byte yProtId); + + /** + * Returns R flag in TE Object. + * + * @return R flag in TE Object + */ + boolean getRFlag(); + + /** + * Sets R flag in TE Object and returns its builder. + * + * @param bRFlag R flag in TE Object + * @return Builder by setting R flag + */ + Builder setRFlag(boolean bRFlag); + + /** + * Returns S flag in TE Object. + * + * @return S flag in TE Object + */ + boolean getSFlag(); + + /** + * Sets S flag in TE Object and returns its builder. + * + * @param bSFlag S flag in TE Object + * @return Builder by setting S flag + */ + Builder setSFlag(boolean bSFlag); + + /** + * Returns TE ID in TE Object. + * + * @return TE ID in TE Object + */ + int getTEId(); + + /** + * Sets TE ID in TE Object and returns its builder. + * + * @param iTEId TE ID in TE Object + * @return Builder by setting TE ID + */ + Builder setTEId(int iTEId); + + /** + * Returns list of Optional Tlvs in TE Object. + * + * @return list of Optional Tlvs + */ + LinkedList getOptionalTlv(); + + /** + * Sets list of Optional Tlvs in TE Object and returns its builder. + * + * @param llOptionalTlv list of Optional Tlvs + * @return Builder by setting list of Optional Tlvs + */ + Builder setOptionalTlv(LinkedList llOptionalTlv); + + /** + * Sets P flag in TE object header and returns its builder. + * + * @param value boolean value to set P flag + * @return Builder by setting P flag + */ + Builder setPFlag(boolean value); + + /** + * Sets I flag in TE object header and returns its builder. + * + * @param value boolean value to set I flag + * @return Builder by setting I flag + */ + Builder setIFlag(boolean value); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepTEReportMsg.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepTEReportMsg.java new file mode 100755 index 00000000..3bc5034e --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepTEReportMsg.java @@ -0,0 +1,81 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP TE Report Message. + */ +public interface PcepTEReportMsg extends PcepObject, PcepMessage { + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns list of PCEP TE Objects. + * + * @return list of PCEP TE Objects + */ + LinkedList getTEReportList(); + + /** + * Sets list of Optional Tlvs in TE Report Message. + * + * @param llTEReportList list of optional Tlvs + */ + void setTEReportList(LinkedList llTEReportList); + + @Override + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException; + + /** + * Builder interface with get and set functions to build TE Report message. + */ + interface Builder extends PcepMessage.Builder { + + @Override + PcepTEReportMsg build(); + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns list of Optional Tlv in TE Report Message. + * + * @return list of Optional Tlv + */ + LinkedList getTEReportList(); + + /** + * Sets list of Optional Tlvs and returns its builder. + * + * @param llTEReportList list of Optional Tlvs + * @return Builder object for TE report message + */ + Builder setTEReportList(LinkedList llTEReportList); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepType.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepType.java new file mode 100755 index 00000000..450fdfac --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepType.java @@ -0,0 +1,49 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +/** + * Enum to Provide the Different types of PCEP messages. + */ +public enum PcepType { + + NONE(0), OPEN(1), KEEP_ALIVE(2), PATH_COMPUTATION_REQUEST(3), PATH_COMPUTATION_REPLY(4), + NOTIFICATION(5), ERROR(6), CLOSE(7), REPORT(10), UPDATE(11), INITIATE(12), LABEL_UPDATE(13), + TE_REPORT(14), LABEL_RANGE_RESERV(15), MAX(16), END(17); + + int iValue; + + /** + * Assign iValue with the value iVal as the types of PCEP message. + * + * @param iVal type of pcep message + */ + PcepType(int iVal) { + + iValue = iVal; + } + + /** + * Returns iValue as type of PCEP message. + * + * @return iValue type of pcep message + */ + public byte getType() { + + return (byte) iValue; + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateMsg.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateMsg.java new file mode 100755 index 00000000..dc2ac3a8 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateMsg.java @@ -0,0 +1,81 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Update Message. + */ +public interface PcepUpdateMsg extends PcepObject, PcepMessage { + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns the update request list for PCEP Update Message. + * + * @return list of Update Requests + */ + LinkedList getUpdateRequestList(); + + /** + * Sets the update request list for PCEP update message. + * + * @param llUpdateRequestList is a list of PCEP Update Requests + */ + void setUpdateRequestList(LinkedList llUpdateRequestList); + + @Override + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException; + + /** + * Builder interface with Get and Set Functions to build the PCEP update Message. + */ + interface Builder extends PcepMessage.Builder { + + @Override + PcepUpdateMsg build(); + + @Override + PcepVersion getVersion(); + + @Override + PcepType getType(); + + /** + * Returns the update request list for the PCEP update message. + * + * @return list of Update Requests + */ + LinkedList getUpdateRequestList(); + + /** + * Sets the update request list for the PCEP update message. + * + * @param llUpdateRequestList list of Update requests + * @return builder by setting list llUpdateRequestList of PcepUpdateRequest. + */ + Builder setUpdateRequestList(LinkedList llUpdateRequestList); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateRequest.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateRequest.java new file mode 100755 index 00000000..8d1c89e2 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateRequest.java @@ -0,0 +1,126 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing PCEP Update Request List. + */ +public interface PcepUpdateRequest { + + /** + * Returns object of PCEP SRP Object. + * + * @return srpObject of type PCEP SRP Object + */ + PcepSrpObject getSrpObject(); + + /** + * Returns object of PCEP LSP Object. + * + * @return lspObject of type PCEP LSP Object + */ + PcepLspObject getLspObject(); + + /** + * Returns object of PCEP MSG PATH. + * + * @return msgPath of type PCEP MSG PATH + */ + PcepMsgPath getMsgPath(); + + /** + * Sets the PCEP SRP Object. + * + * @param srpObject object of type PCEP SRP Object + */ + void setSrpObject(PcepSrpObject srpObject); + + /** + * Sets the PCEP LSP Object. + * + * @param lspObject object of type PCEP LSP Object + */ + void setLspObject(PcepLspObject lspObject); + + /** + * sets the PCEP MSG PATH. + * + * @param msgPath object of type PCEP MSG PATH + */ + void setMsgPath(PcepMsgPath msgPath); + + /** + * Builder interface with get and set functions to build PcepUpdateRequest. + */ + interface Builder { + + /** + * Builds PcepUpdateRequest. + * + * @return PcepUpdateRequest + * @throws PcepParseException if mandatory object is not set + */ + PcepUpdateRequest build() throws PcepParseException; + + /** + * Returns PcepSrpObject. + * + * @return srpObject + */ + PcepSrpObject getSrpObject(); + + /** + * Returns PcepLspObject. + * + * @return lspObject + */ + PcepLspObject getLspObject(); + + /** + * Returns PcepMsgPath. + * + * @return msgPath + */ + PcepMsgPath getMsgPath(); + + /** + * Sets the SRP Object. + * + * @param srpObj of type PcepSrpObject + * @return builder by setting PcepSrpObject + */ + Builder setSrpObject(PcepSrpObject srpObj); + + /** + * Sets the LSP Object. + * + * @param lspObject of type PcepLspObject + * @return builder by setting PcepLspObject + */ + Builder setLspObject(PcepLspObject lspObject); + + /** + * Sets the Path Object. + * + * @param msgPath of type PcepMsgPath + * @return builder by setting PcepMsgPath + */ + Builder setMsgPath(PcepMsgPath msgPath); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepVersion.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepVersion.java new file mode 100755 index 00000000..c761ed08 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepVersion.java @@ -0,0 +1,46 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +/** + * Enum to provide PCEP Message Version. + */ +public enum PcepVersion { + + PCEP_1(1); + + public final int packetVersion; + + /** + * Assign PCEP PacketVersion with WireVersion. + * + * @param wireVersion version of pcep + */ + PcepVersion(final int wireVersion) { + + this.packetVersion = wireVersion; + } + + /** + * Returns Wire version of PCEP Message. + * + * @return packetVersion + */ + public int getWireVersion() { + return packetVersion; + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/Writeable.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/Writeable.java new file mode 100755 index 00000000..37aef58d --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/Writeable.java @@ -0,0 +1,35 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; + +/** + * Abstraction of an entity providing functionality to write byte streams of + * Messages to channel buffer. + */ +public interface Writeable { + + /** + * Writes byte streams of messages to channel buffer. + * + * @param bb parameter of type channel buffer + * @throws PcepParseException when error occurs while writing pcep message to channel buffer + */ + void writeTo(ChannelBuffer bb) throws PcepParseException; +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/package-info.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/package-info.java new file mode 100644 index 00000000..53ee5934 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Abstraction of an entity providing PCEP messages. + */ +package org.onosproject.pcepio.protocol; diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcInitiatedLspRequestVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcInitiatedLspRequestVer1.java new file mode 100644 index 00000000..d61f7319 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcInitiatedLspRequestVer1.java @@ -0,0 +1,291 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; +import org.onosproject.pcepio.protocol.PcepAttribute; +import org.onosproject.pcepio.protocol.PcepEndPointsObject; +import org.onosproject.pcepio.protocol.PcepEroObject; +import org.onosproject.pcepio.protocol.PcepLspObject; +import org.onosproject.pcepio.protocol.PcepSrpObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PcInitiatedLspRequest for PCEP Initiate message. + * Reference : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03. + */ +public class PcInitiatedLspRequestVer1 implements PcInitiatedLspRequest { + + /* + * ::= (|) + ::= + + + + [] + ::= + + */ + + protected static final Logger log = LoggerFactory.getLogger(PcInitiatedLspRequestVer1.class); + + //PCEP SRP Object + private PcepSrpObject srpObject; + //PCEP LSP Object + private PcepLspObject lspObject; + //PCEP End Point Object + private PcepEndPointsObject endPointsObject; + //PCEP ERO Object + private PcepEroObject eroObject; + //PCEP Attribute list + private PcepAttribute pcepAttribute; + + /** + * Default constructor. + */ + public PcInitiatedLspRequestVer1() { + srpObject = null; + lspObject = null; + endPointsObject = null; + eroObject = null; + pcepAttribute = null; + + } + + /** + * Constructor to initialize all parameters of PC initiated lsp request. + * + * @param srpObject PCEP srp Object + * @param lspObject PCEP lsp object + * @param endPointsObject PCPE endpoints object + * @param eroObject PCEP ero object + * @param pcepAttribute PCEP attribute + */ + public PcInitiatedLspRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject, + PcepEndPointsObject endPointsObject, PcepEroObject eroObject, PcepAttribute pcepAttribute) { + this.srpObject = srpObject; + this.lspObject = lspObject; + this.endPointsObject = endPointsObject; + this.eroObject = eroObject; + this.pcepAttribute = pcepAttribute; + + } + + @Override + public PcepSrpObject getSrpObject() { + return srpObject; + } + + @Override + public PcepLspObject getLspObject() { + return lspObject; + } + + @Override + public PcepEndPointsObject getEndPointsObject() { + return endPointsObject; + } + + @Override + public PcepEroObject getEroObject() { + return eroObject; + } + + @Override + public PcepAttribute getPcepAttribute() { + return pcepAttribute; + } + + @Override + public void setSrpObject(PcepSrpObject srpobj) { + this.srpObject = srpobj; + + } + + @Override + public void setLspObject(PcepLspObject lspObject) { + this.lspObject = lspObject; + } + + @Override + public void setEndPointsObject(PcepEndPointsObject endPointsObject) { + this.endPointsObject = endPointsObject; + } + + @Override + public void setEroObject(PcepEroObject eroObject) { + this.eroObject = eroObject; + } + + @Override + public void setPcepAttribute(PcepAttribute pcepAttribute) { + this.pcepAttribute = pcepAttribute; + } + + /** + * Builder class for PC initiated lsp reuqest. + */ + public static class Builder implements PcInitiatedLspRequest.Builder { + + private boolean bIsSRPObjectSet = false; + private boolean bIsLSPObjectSet = false; + private boolean bIsEndPointsObjectSet = false; + private boolean bIsEROObjectSet = false; + private boolean bIsPcepAttributeSet = false; + private boolean bIsbRFlagSet = false; + + //PCEP SRP Object + private PcepSrpObject srpObject; + //PCEP LSP Object + private PcepLspObject lspObject; + //PCEP End Point Object + private PcepEndPointsObject endPointsObject; + //PCEP ERO Object + private PcepEroObject eroObject; + //PCEP Attribute list + private PcepAttribute pcepAttribute; + + @Override + public PcInitiatedLspRequest build() throws PcepParseException { + + //PCEP SRP Object + PcepSrpObject srpObject = null; + //PCEP LSP Object + PcepLspObject lspObject = null; + //PCEP End Point Object + PcepEndPointsObject endPointsObject = null; + //PCEP ERO Object + PcepEroObject eroObject = null; + //PCEP Attribute list + PcepAttribute pcepAttribute = null; + boolean bRFlag = false; + + if (!this.bIsSRPObjectSet) { + throw new PcepParseException("Srp object NOT Set while building PcInitiatedLspRequest"); + } else { + srpObject = this.srpObject; + bRFlag = srpObject.getRFlag(); + } + + if (bRFlag) { + this.bIsbRFlagSet = true; + } else { + this.bIsbRFlagSet = false; + } + + if (!this.bIsLSPObjectSet) { + throw new PcepParseException("LSP Object NOT Set while building PcInitiatedLspRequest"); + } else { + lspObject = this.lspObject; + } + if (!this.bIsbRFlagSet) { + + if (!this.bIsEndPointsObjectSet) { + throw new PcepParseException("EndPoints Object NOT Set while building PcInitiatedLspRequest"); + } else { + endPointsObject = this.endPointsObject; + } + if (!this.bIsEROObjectSet) { + throw new PcepParseException("ERO Object NOT Set while building PcInitiatedLspRequest"); + } else { + eroObject = this.eroObject; + } + if (bIsPcepAttributeSet) { + pcepAttribute = this.pcepAttribute; + } + } + return new PcInitiatedLspRequestVer1(srpObject, lspObject, endPointsObject, eroObject, pcepAttribute); + } + + @Override + public PcepSrpObject getSrpObject() { + return this.srpObject; + } + + @Override + public PcepLspObject getLspObject() { + return this.lspObject; + } + + @Override + public PcepEndPointsObject getEndPointsObject() { + return this.endPointsObject; + } + + @Override + public PcepEroObject getEroObject() { + return this.eroObject; + } + + @Override + public PcepAttribute getPcepAttribute() { + return this.pcepAttribute; + } + + @Override + public Builder setSrpObject(PcepSrpObject srpobj) { + this.srpObject = srpobj; + this.bIsSRPObjectSet = true; + return this; + + } + + @Override + public Builder setLspObject(PcepLspObject lspObject) { + this.lspObject = lspObject; + this.bIsLSPObjectSet = true; + return this; + } + + @Override + public Builder setEndPointsObject(PcepEndPointsObject endPointsObject) { + this.endPointsObject = endPointsObject; + this.bIsEndPointsObjectSet = true; + return this; + } + + @Override + public Builder setEroObject(PcepEroObject eroObject) { + this.eroObject = eroObject; + this.bIsEROObjectSet = true; + return this; + } + + @Override + public Builder setPcepAttribute(PcepAttribute pcepAttribute) { + this.pcepAttribute = pcepAttribute; + this.bIsPcepAttributeSet = true; + return this; + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .omitNullValues() + .add("SrpObject", srpObject) + .add("LspObject", lspObject) + .add("EndPointObject", endPointsObject) + .add("EroObject", eroObject) + .add("PcepAttribute", pcepAttribute) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepAttributeVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepAttributeVer1.java new file mode 100644 index 00000000..65a844c2 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepAttributeVer1.java @@ -0,0 +1,431 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepAttribute; +import org.onosproject.pcepio.protocol.PcepBandwidthObject; +import org.onosproject.pcepio.protocol.PcepIroObject; +import org.onosproject.pcepio.protocol.PcepLspaObject; +import org.onosproject.pcepio.protocol.PcepMetricObject; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP Attribute List. + */ +public class PcepAttributeVer1 implements PcepAttribute { + + /* Reference : RFC5440 + * where: + * ::=[] + * [] + * [] + * [] + * + * ::=[] + */ + protected static final Logger log = LoggerFactory.getLogger(PcepAttributeVer1.class); + + public static final int OBJECT_HEADER_LENGTH = 4; + + //PCEP LSPA Object + private PcepLspaObject lspaObject; + private boolean isLspaObjectSet; + + //PCEP Bandwidth Object + private PcepBandwidthObject bandwidthObject; + private boolean isBandwidthObjectSet; + + //PCEP Metric list + private LinkedList llMetricList; + private boolean isMetricListSet; + + //PCEP IRO object + private PcepIroObject iroObject; + private boolean isIroObjectSet; + + /** + * Default constructor to initialize member variables. + */ + public PcepAttributeVer1() { + + lspaObject = null; + bandwidthObject = null; + llMetricList = null; + iroObject = null; + this.isLspaObjectSet = false; + this.isBandwidthObjectSet = false; + this.isMetricListSet = false; + this.isIroObjectSet = false; + } + + /** + * Constructor to initialize all parameters for PCEP attribute. + * + * @param lspaObject PCEP lspa Object. + * @param bandwidthObject PCEP bandwidth object. + * @param llMetricList list of PCEP metric objects. + * @param iroObject PCEP iro object. + */ + public PcepAttributeVer1(PcepLspaObject lspaObject, PcepBandwidthObject bandwidthObject, + LinkedList llMetricList, PcepIroObject iroObject) { + + this.lspaObject = lspaObject; + this.bandwidthObject = bandwidthObject; + this.llMetricList = llMetricList; + this.iroObject = iroObject; + if (lspaObject == null) { + this.isLspaObjectSet = false; + } else { + this.isLspaObjectSet = true; + } + if (bandwidthObject == null) { + this.isBandwidthObjectSet = false; + } else { + this.isBandwidthObjectSet = true; + } + if (llMetricList == null) { + this.isMetricListSet = false; + } else { + this.isMetricListSet = true; + } + if (iroObject == null) { + this.isIroObjectSet = false; + } else { + this.isIroObjectSet = true; + } + } + + /** + * constructor to initialize bandwidthObject. + * + * @param bandwidthObject bandwidth object + */ + public PcepAttributeVer1(PcepBandwidthObject bandwidthObject) { + this.isLspaObjectSet = false; + + this.bandwidthObject = bandwidthObject; + this.isBandwidthObjectSet = true; + + this.isMetricListSet = false; + + this.isIroObjectSet = false; + } + + /** + * Parse list for MeticObject. + * + * @param cb of type channel buffer + * @return true if parsing metric list is success + * @throws PcepParseException when a non metric object is received + */ + public boolean parseMetricList(ChannelBuffer cb) throws PcepParseException { + + if (llMetricList == null) { + llMetricList = new LinkedList<>(); + } + + PcepMetricObject metriclist; + + //caller should verify for metric object + byte yObjClass = PcepMetricObjectVer1.METRIC_OBJ_CLASS; + byte yObjType = PcepMetricObjectVer1.METRIC_OBJ_TYPE; + + while ((yObjClass == PcepMetricObjectVer1.METRIC_OBJ_CLASS) + && (yObjType == PcepMetricObjectVer1.METRIC_OBJ_TYPE)) { + + metriclist = PcepMetricObjectVer1.read(cb); + llMetricList.add(metriclist); + yObjClass = 0; + yObjType = 0; + + if (cb.readableBytes() > OBJECT_HEADER_LENGTH) { + cb.markReaderIndex(); + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + yObjClass = tempObjHeader.getObjClass(); + yObjType = tempObjHeader.getObjType(); + } + } + return true; + } + + /** + * Reads lspa , bandwidth , Metriclist and Iro objects and sets the objects. + * + * @param cb of type channel buffer + * @return instance of Pcep Attribute + * @throws PcepParseException while parsing Pcep Attributes from channel buffer + */ + + public static PcepAttribute read(ChannelBuffer cb) throws PcepParseException { + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { + return null; + } + //check whether any pcep attribute is present + cb.markReaderIndex(); + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + byte yObjClass = tempObjHeader.getObjClass(); + + if (PcepLspaObjectVer1.LSPA_OBJ_CLASS != yObjClass && PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS != yObjClass + && PcepMetricObjectVer1.METRIC_OBJ_CLASS != yObjClass && PcepIroObjectVer1.IRO_OBJ_CLASS != yObjClass) { + //No PCEP attribute is present + return null; + } + + PcepAttributeVer1 pcepAttribute = new PcepAttributeVer1(); + + //If LSPA present then store it.LSPA is optional + if (yObjClass == PcepLspaObjectVer1.LSPA_OBJ_CLASS) { + pcepAttribute.setLspaObject(PcepLspaObjectVer1.read(cb)); + yObjClass = checkNextObject(cb); + } + + //If BANDWIDTH present then store it.BANDWIDTH is optional + if (yObjClass == PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS) { + pcepAttribute.setBandwidthObject(PcepBandwidthObjectVer1.read(cb)); + yObjClass = checkNextObject(cb); + } + + //If Metric list present then store it.MetricList is optional + if (yObjClass == PcepMetricObjectVer1.METRIC_OBJ_CLASS) { + pcepAttribute.parseMetricList(cb); + yObjClass = checkNextObject(cb); + } + + //If IRO present then store it.IRO is optional + if (yObjClass == PcepIroObjectVer1.IRO_OBJ_CLASS) { + pcepAttribute.setIroObject(PcepIroObjectVer1.read(cb)); + } + + PcepLspaObject lspaObject = pcepAttribute.getLspaObject(); + PcepBandwidthObject bandwidthObject = pcepAttribute.getBandwidthObject(); + LinkedList metriclist = pcepAttribute.llMetricList; + PcepIroObject iroObject = pcepAttribute.getIroObject(); + + return new PcepAttributeVer1(lspaObject, bandwidthObject, metriclist, iroObject); + } + + /** + * Checks whether there is a more object or not. + * + * @param cb of type channel buffer + * @return instance of object header + */ + private static byte checkNextObject(ChannelBuffer cb) { + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { + return 0; + } + cb.markReaderIndex(); + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + return tempObjHeader.getObjClass(); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + int iLenStartIndex = cb.writerIndex(); + //PCEP LSPA object is optional + if (this.isLspaObjectSet) { + this.lspaObject.write(cb); + } + + //PCEP BANDWIDTH object is optional + if (this.isBandwidthObjectSet) { + this.bandwidthObject.write(cb); + } + + //PCEP Metric list is optional + if (this.isMetricListSet) { + ListIterator listIterator = this.llMetricList.listIterator(); + while (listIterator.hasNext()) { + listIterator.next().write(cb); + } + } + + //PCEP IRO object is optional + if (this.isIroObjectSet) { + this.iroObject.write(cb); + } + return cb.writerIndex() - iLenStartIndex; + } + + @Override + public PcepLspaObject getLspaObject() { + return lspaObject; + } + + @Override + public PcepBandwidthObject getBandwidthObject() { + return bandwidthObject; + } + + @Override + public LinkedList getMetricObjectList() { + return llMetricList; + } + + @Override + public PcepIroObject getIroObject() { + return iroObject; + } + + @Override + public void setBandwidthObject(PcepBandwidthObject bandwidthObject) { + this.isBandwidthObjectSet = true; + this.bandwidthObject = bandwidthObject; + } + + @Override + public void setMetricObjectList(LinkedList llMetricList) { + this.isMetricListSet = true; + this.llMetricList = llMetricList; + + } + + @Override + public void setLspaObject(PcepLspaObject lspaObject) { + this.isLspaObjectSet = true; + this.lspaObject = lspaObject; + } + + @Override + public void setIroObject(PcepIroObject iroObject) { + this.isIroObjectSet = true; + this.iroObject = iroObject; + } + + /** + * Builder class for PCEP attributes. + */ + public static class Builder implements PcepAttribute.Builder { + + //PCEP LSPA Object + private PcepLspaObject lspaObject; + private boolean isLspaObjectSet; + + //PCEP BANDWIDTH Object + private PcepBandwidthObject bandwidthObject; + private boolean isBandwidthObjectSet; + + //PCEP Metric list + private LinkedList llMetricList; + private boolean isMetricListSet; + + //PCEP IRO object + private PcepIroObject iroObject; + private boolean isIroObjectSet; + + @Override + public PcepAttribute build() { + + //PCEP LSPA Object + PcepLspaObject lspaObject = null; + + //PCEP BANDWIDTH Object + PcepBandwidthObject bandwidthObject = null; + + //PCEP Metric list + LinkedList llMetricList = null; + + //PCEP IRO object + PcepIroObject iroObject = null; + + if (this.isLspaObjectSet) { + lspaObject = this.lspaObject; + } + if (this.isBandwidthObjectSet) { + bandwidthObject = this.bandwidthObject; + } + if (this.isMetricListSet) { + llMetricList = this.llMetricList; + } + if (this.isIroObjectSet) { + iroObject = this.iroObject; + } + return new PcepAttributeVer1(lspaObject, bandwidthObject, llMetricList, iroObject); + } + + @Override + public PcepLspaObject getLspaObject() { + return this.lspaObject; + } + + @Override + public PcepBandwidthObject getBandwidthObject() { + return this.bandwidthObject; + } + + @Override + public LinkedList getMetricObjectList() { + return this.llMetricList; + } + + @Override + public PcepIroObject getIroObject() { + return this.iroObject; + } + + @Override + public Builder setBandwidthObject(PcepBandwidthObject bandwidthObject) { + this.isBandwidthObjectSet = true; + this.bandwidthObject = bandwidthObject; + return this; + } + + @Override + public Builder setMetricObjectList(LinkedList llMetricList) { + this.isMetricListSet = true; + this.llMetricList = llMetricList; + return this; + } + + @Override + public Builder setLspaObject(PcepLspaObject lspaObject) { + this.isLspaObjectSet = true; + this.lspaObject = lspaObject; + return this; + } + + @Override + public Builder setIroObject(PcepIroObject iroObject) { + this.isIroObjectSet = true; + this.iroObject = iroObject; + return this; + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .omitNullValues() + .add("lspaObject", lspaObject) + .add("bandwidthObject", bandwidthObject) + .add("MetricObjectList", llMetricList) + .add("IroObject", iroObject) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepBandwidthObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepBandwidthObjectVer1.java new file mode 100644 index 00000000..1c78d5b4 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepBandwidthObjectVer1.java @@ -0,0 +1,233 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepBandwidthObject; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PcepBandwidthObject. + */ +public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { + + /* + * RFC : 5440 , section : 7.7. + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Bandwidth | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + The BANDWIDTH Object format + */ + + protected static final Logger log = LoggerFactory.getLogger(PcepBandwidthObjectVer1.class); + /* + * Requested bandwidth: BANDWIDTH Object-Type is 1. + Bandwidth of an existing TE LSP for which a re-optimization is + requested. BANDWIDTH Object-Type is 2. + */ + //Right now handling type 1 + public static final byte BANDWIDTH_OBJ_TYPE = 1; + public static final byte BANDWIDTH_OBJ_CLASS = 5; + public static final byte BANDWIDTH_OBJECT_VERSION = 1; + public static final short BANDWIDTH_OBJ_MINIMUM_LENGTH = 8; + + static final PcepObjectHeader DEFAULT_BANDWIDTH_OBJECT_HEADER = new PcepObjectHeader(BANDWIDTH_OBJ_CLASS, + BANDWIDTH_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, + BANDWIDTH_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader bandwidthObjHeader; + private int iBandwidth; + + /** + * Constructor to bandwidth object header and bandwidth. + * + * @param bandwidthObjHeader bandwidth object header + * @param iBandwidth bandwidth value + */ + public PcepBandwidthObjectVer1(PcepObjectHeader bandwidthObjHeader, int iBandwidth) { + this.bandwidthObjHeader = bandwidthObjHeader; + this.iBandwidth = iBandwidth; + } + + /** + * Constructor to initialize bandwidth. + * + * @param iBandwidth bandwidth value + */ + public PcepBandwidthObjectVer1(int iBandwidth) { + this.bandwidthObjHeader = DEFAULT_BANDWIDTH_OBJECT_HEADER; + this.iBandwidth = iBandwidth; + } + + /** + * Returns Object Header. + * + * @return bandwidthObjHeader + */ + public PcepObjectHeader getBandwidthObjHeader() { + return this.bandwidthObjHeader; + } + + /** + * Sets Object Header. + * + * @param obj bandwidth object header + */ + public void setBandwidthObjHeader(PcepObjectHeader obj) { + this.bandwidthObjHeader = obj; + } + + @Override + public int getBandwidth() { + return this.iBandwidth; + } + + @Override + public void setBandwidth(int iBandwidth) { + this.iBandwidth = iBandwidth; + } + + /** + * Reads from channel buffer and returns object of PcepBandwidthObject. + * + * @param cb channel buffer to parse + * @return object of PcepBandwidthObject + * @throws PcepParseException while parsing channel buffer + */ + public static PcepBandwidthObject read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader bandwidthObjHeader; + int iBandwidth; + + bandwidthObjHeader = PcepObjectHeader.read(cb); + iBandwidth = cb.readInt(); + + return new PcepBandwidthObjectVer1(bandwidthObjHeader, iBandwidth); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + //write Object header + int objStartIndex = cb.writerIndex(); + int objLenIndex = bandwidthObjHeader.write(cb); + + if (objLenIndex <= 0) { + throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex); + } + + cb.writeInt(iBandwidth); + short hLength = (short) (cb.writerIndex() - objStartIndex); + cb.setShort(objLenIndex, hLength); + //will be helpful during print(). + bandwidthObjHeader.setObjLen(hLength); + + return cb.writerIndex() - objStartIndex; + } + + /** + * builder class for PCEP bandwidth object. + */ + public static class Builder implements PcepBandwidthObject.Builder { + + private PcepObjectHeader bandwidthObjHeader; + private boolean bIsHeaderSet = false; + + private int iBandwidth; + private boolean bIsBandwidthSet = false; + + private boolean bPFlag; + private boolean bIsPFlagSet = false; + + private boolean bIFlag; + private boolean bIsIFlagSet = false; + + @Override + public PcepBandwidthObject build() throws PcepParseException { + + PcepObjectHeader bandwidthObjHeader = this.bIsHeaderSet ? this.bandwidthObjHeader + : DEFAULT_BANDWIDTH_OBJECT_HEADER; + + if (bIsPFlagSet) { + bandwidthObjHeader.setPFlag(bPFlag); + } + + if (bIsIFlagSet) { + bandwidthObjHeader.setIFlag(bIFlag); + } + + if (!this.bIsBandwidthSet) { + throw new PcepParseException("bandwidth not Set while building Bandwidth Object."); + } + + return new PcepBandwidthObjectVer1(bandwidthObjHeader, iBandwidth); + } + + @Override + public int getBandwidth() { + return this.iBandwidth; + } + + @Override + public PcepObjectHeader getBandwidthObjHeader() { + return this.bandwidthObjHeader; + } + + @Override + public Builder setBandwidthObjHeader(PcepObjectHeader obj) { + this.bandwidthObjHeader = obj; + return this; + } + + @Override + public Builder setBandwidth(int iBandwidth) { + this.iBandwidth = iBandwidth; + this.bIsBandwidthSet = true; + return this; + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("BandwidthObjectHeader", bandwidthObjHeader) + .add("Bandwidth", iBandwidth).toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepCloseMsgVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepCloseMsgVer1.java new file mode 100644 index 00000000..bcc679d3 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepCloseMsgVer1.java @@ -0,0 +1,351 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepCloseMsg; +import org.onosproject.pcepio.protocol.PcepMessageReader; +import org.onosproject.pcepio.protocol.PcepMessageWriter; +import org.onosproject.pcepio.protocol.PcepType; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP Close Message. + */ +class PcepCloseMsgVer1 implements PcepCloseMsg { + + /* + * RFC : 5440 , section : 6.8 + * ::= + * + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Ver | Flags | Message-Type | Message-Length | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Object-Class | OT |Res|P|I| Object Length (bytes) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Reserved | Flags | Reason | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + // Optional TLVs // + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + protected static final Logger log = LoggerFactory.getLogger(PcepCloseMsgVer1.class); + + // Pcep version: 1 + public static final byte PACKET_VERSION = 1; + public static final int PACKET_MINIMUM_LENGTH = 12; + public static final PcepType MSG_TYPE = PcepType.CLOSE; + public static final byte CLOSE_OBJ_TYPE = 1; + public static final byte CLOSE_OBJ_CLASS = 15; + public static final byte CLOSE_OBJECT_VERSION = 1; + public static final byte DEFAULT_REASON = 1; // Default reason to close + public static final short CLOSE_OBJ_MINIMUM_LENGTH = 8; + public static final int SHIFT_FLAG = 5; + static final PcepObjectHeader DEFAULT_CLOSE_HEADER = new PcepObjectHeader(CLOSE_OBJ_CLASS, CLOSE_OBJ_TYPE, + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, CLOSE_OBJ_MINIMUM_LENGTH); + + private final PcepObjectHeader closeObjHeader; + private byte yReason; + private LinkedList llOptionalTlv; + + public static final PcepCloseMsgVer1.Reader READER = new Reader(); + + /** + * Reader class for reading close message for channel buffer. + */ + static class Reader implements PcepMessageReader { + PcepObjectHeader closeObjHeader; + byte yReason; + // Optional TLV + private LinkedList llOptionalTlv; + + @Override + public PcepCloseMsg readFrom(ChannelBuffer cb) throws PcepParseException { + + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) { + throw new PcepParseException("Packet size is less than the minimum length."); + } + // fixed value property version == 1 + byte version = cb.readByte(); + version = (byte) (version >> SHIFT_FLAG); + if (version != PACKET_VERSION) { + throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), got=" + version); + } + // fixed value property type == 7 + byte type = cb.readByte(); + if (type != MSG_TYPE.getType()) { + throw new PcepParseException("Wrong type. Expected=PcepType.CLOSE(7), got=" + type); + } + short length = cb.readShort(); + if (length < PACKET_MINIMUM_LENGTH) { + throw new PcepParseException("Wrong length. Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: " + + length); + } + closeObjHeader = PcepObjectHeader.read(cb); + // Reserved + cb.readShort(); + // Flags + cb.readByte(); + // Reason + yReason = cb.readByte(); + // parse optional TLV + llOptionalTlv = parseOptionalTlv(cb); + return new PcepCloseMsgVer1(closeObjHeader, yReason, llOptionalTlv); + } + } + + /** + * Parse the list of Optional Tlvs. + * + * @param cb channel buffer + * @return list of Optional Tlvs + * @throws PcepParseException when fails to parse optional tlvs + */ + public static LinkedList parseOptionalTlv(ChannelBuffer cb) throws PcepParseException { + + LinkedList llOptionalTlv = new LinkedList<>(); + /* + rfc 5440: + Optional TLVs may be included within the CLOSE object body. The + specification of such TLVs is outside the scope of this document. + */ + return llOptionalTlv; + } + + /** + * constructor to initialize PCEP close Message with all the parameters. + * + * @param closeObjHeader object header for close message + * @param yReason reason for closing the channel + * @param llOptionalTlv list of optional tlvs + */ + PcepCloseMsgVer1(PcepObjectHeader closeObjHeader, byte yReason, LinkedList llOptionalTlv) { + + this.closeObjHeader = closeObjHeader; + this.yReason = yReason; + this.llOptionalTlv = llOptionalTlv; + } + + /** + * Builder class for PCEP close message. + */ + static class Builder implements PcepCloseMsg.Builder { + + // PCEP Close message fields + private boolean bIsHeaderSet = false; + private PcepObjectHeader closeObjHeader; + private boolean bIsReasonSet = false; + private byte yReason; + private LinkedList llOptionalTlv = new LinkedList<>(); + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepType getType() { + return PcepType.CLOSE; + } + + @Override + public PcepCloseMsg build() { + + PcepObjectHeader closeObjHeader = this.bIsHeaderSet ? this.closeObjHeader : DEFAULT_CLOSE_HEADER; + byte yReason = this.bIsReasonSet ? this.yReason : DEFAULT_REASON; + + if (bIsPFlagSet) { + closeObjHeader.setPFlag(bPFlag); + } + + if (bIsIFlagSet) { + closeObjHeader.setIFlag(bIFlag); + } + return new PcepCloseMsgVer1(closeObjHeader, yReason, this.llOptionalTlv); + } + + @Override + public PcepObjectHeader getCloseObjHeader() { + return this.closeObjHeader; + } + + @Override + public Builder setCloseObjHeader(PcepObjectHeader obj) { + this.closeObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public byte getReason() { + return this.yReason; + } + + @Override + public Builder setReason(byte value) { + this.yReason = value; + this.bIsReasonSet = true; + return this; + } + + @Override + public Builder setOptionalTlv(LinkedList llOptionalTlv) { + this.llOptionalTlv = llOptionalTlv; + return this; + } + + @Override + public LinkedList getOptionalTlv() { + return this.llOptionalTlv; + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + } + + @Override + public void writeTo(ChannelBuffer cb) throws PcepParseException { + WRITER.write(cb, this); + } + + static final Writer WRITER = new Writer(); + + /** + * Writer class for writing close message to channel buffer. + */ + static class Writer implements PcepMessageWriter { + + @Override + public void write(ChannelBuffer cb, PcepCloseMsgVer1 message) throws PcepParseException { + int startIndex = cb.writerIndex(); + // first 3 bits set to version + cb.writeByte((byte) (PACKET_VERSION << SHIFT_FLAG)); + // message type + cb.writeByte(MSG_TYPE.getType()); + // length is length of variable message, will be updated at the end + // Store the position of message + // length in buffer + int msgLenIndex = cb.writerIndex(); + cb.writeShort((short) 0); + int objStartIndex = cb.writerIndex(); + int objLenIndex = message.closeObjHeader.write(cb); + if (objLenIndex <= 0) { + throw new PcepParseException("Failed to write Close object header."); + } + // first 3 bits set to version + cb.writeShort(0); // Reserved + cb.writeByte(0); // Flags + cb.writeByte(message.yReason); + // Pack optional TLV + packOptionalTlv(cb, message); + int length = cb.writerIndex() - objStartIndex; + cb.setShort(objLenIndex, (short) length); + // will be helpful during print(). + message.closeObjHeader.setObjLen((short) length); + // As per RFC the length of object should be + // multiples of 4 + int pad = length % 4; + if (pad != 0) { + pad = 4 - pad; + for (int i = 0; i < pad; i++) { + cb.writeByte((byte) 0); + } + length = length + pad; + } + // update message length field + length = cb.writerIndex() - startIndex; + cb.setShort(msgLenIndex, (short) length); + } + + public void packOptionalTlv(ChannelBuffer cb, PcepCloseMsgVer1 message) { + + LinkedList llOptionalTlv = message.llOptionalTlv; + ListIterator listIterator = llOptionalTlv.listIterator(); + while (listIterator.hasNext()) { + listIterator.next().write(cb); + } + } + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepType getType() { + return MSG_TYPE; + } + + @Override + public byte getReason() { + return this.yReason; + } + + @Override + public void setReason(byte value) { + this.yReason = value; + } + + @Override + public LinkedList getOptionalTlv() { + return this.llOptionalTlv; + } + + @Override + public void setOptionalTlv(LinkedList llOptionalTlv) { + this.llOptionalTlv = llOptionalTlv; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("closeObjectHeader", closeObjHeader).add("Reason", yReason) + .add("OptionalTlvlist", llOptionalTlv).toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEndPointsObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEndPointsObjectVer1.java new file mode 100644 index 00000000..08dc0c9b --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEndPointsObjectVer1.java @@ -0,0 +1,256 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepEndPointsObject; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP Endpoints Object. + */ +public class PcepEndPointsObjectVer1 implements PcepEndPointsObject { + + /* + * RFC : 5440 , section : 7.6 + * An End point is defined as follows: + END-POINTS Object-Class is 4. + + END-POINTS Object-Type is 1 for IPv4 and 2 for IPv6. + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Object-Class | OT |Res|P|I| Object Length (bytes) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Source IPv4 address | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Destination IPv4 address | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + */ + protected static final Logger log = LoggerFactory.getLogger(PcepEndPointsObjectVer1.class); + + static final byte END_POINTS_OBJ_TYPE = 1; + static final byte END_POINTS_OBJ_CLASS = 4; + static final byte END_POINTS_OBJECT_VERSION = 1; + static final short END_POINTS_OBJ_MINIMUM_LENGTH = 12; + public static byte endPointObjType; + + static final PcepObjectHeader DEFAULT_END_POINTS_OBJECT_HEADER = new PcepObjectHeader(END_POINTS_OBJ_CLASS, + END_POINTS_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, + END_POINTS_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader endPointsObjHeader; + public int sourceIpAddress; + public int destIpAddress; + + /** + * Constructor to initialize all variables. + * + * @param endPointsObjHeader end points object header + * @param sourceIpAddress source IP address + * @param destIpAddress destination IP address + */ + public PcepEndPointsObjectVer1(PcepObjectHeader endPointsObjHeader, int sourceIpAddress, int destIpAddress) { + + this.endPointsObjHeader = endPointsObjHeader; + this.sourceIpAddress = sourceIpAddress; + this.destIpAddress = destIpAddress; + } + + /** + * Sets End Points Object Header. + * + * @param obj of PcepObjectHeader + */ + public void setEndPointsObjHeader(PcepObjectHeader obj) { + this.endPointsObjHeader = obj; + } + + @Override + public void setSourceIpAddress(int sourceIpAddress) { + this.sourceIpAddress = sourceIpAddress; + } + + @Override + public void setDestIpAddress(int destIpAddress) { + this.destIpAddress = destIpAddress; + } + + @Override + public int getSourceIpAddress() { + return this.sourceIpAddress; + } + + @Override + public int getDestIpAddress() { + return this.destIpAddress; + } + + /** + * Reads from channel buffer and returns object of PcepEndPointsObject. + * + * @param cb of channel buffer + * @return object of PcepEndPointsObject + * @throws PcepParseException while parsing channel buffer + */ + public static PcepEndPointsObject read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader endPointsObjHeader; + int sourceIpAddress; + int destIpAddress; + + endPointsObjHeader = PcepObjectHeader.read(cb); + if (endPointsObjHeader.getObjType() == END_POINTS_OBJ_TYPE + && endPointsObjHeader.getObjClass() == END_POINTS_OBJ_CLASS) { + sourceIpAddress = cb.readInt(); + destIpAddress = cb.readInt(); + } else { + throw new PcepParseException("Expected PcepEndPointsObject."); + } + return new PcepEndPointsObjectVer1(endPointsObjHeader, sourceIpAddress, destIpAddress); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + int objStartIndex = cb.writerIndex(); + //write common header + int objLenIndex = endPointsObjHeader.write(cb); + + //write source IPv4 IP + cb.writeInt(sourceIpAddress); + //write destination IPv4 IP + cb.writeInt(destIpAddress); + + int length = cb.writerIndex() - objStartIndex; + //now write EndPoints Object Length + cb.setShort(objLenIndex, (short) length); + //will be helpful during print(). + endPointsObjHeader.setObjLen((short) length); + + return cb.writerIndex(); + + } + + /** + * Builder class for PCEP end points objects. + */ + public static class Builder implements PcepEndPointsObject.Builder { + + private boolean bIsHeaderSet = false; + private boolean bIsSourceIpAddressset = false; + private boolean bIsDestIpAddressset = false; + private PcepObjectHeader endpointsObjHeader; + private int sourceIpAddress; + private int destIpAddress; + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + @Override + public PcepEndPointsObject build() throws PcepParseException { + + PcepObjectHeader endpointsObjHeader = this.bIsHeaderSet ? this.endpointsObjHeader + : DEFAULT_END_POINTS_OBJECT_HEADER; + + if (bIsPFlagSet) { + endpointsObjHeader.setPFlag(bPFlag); + } + + if (bIsIFlagSet) { + endpointsObjHeader.setIFlag(bIFlag); + } + + if (!this.bIsSourceIpAddressset) { + throw new PcepParseException("SourceIpAddress not set while building EndPoints object"); + } + + if (!this.bIsDestIpAddressset) { + throw new PcepParseException("DestIpAddress not set while building EndPoints object"); + } + + return new PcepEndPointsObjectVer1(endpointsObjHeader, this.sourceIpAddress, this.destIpAddress); + } + + @Override + public PcepObjectHeader getEndPointsObjHeader() { + return this.endpointsObjHeader; + } + + @Override + public Builder setEndPointsObjHeader(PcepObjectHeader obj) { + this.endpointsObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public int getSourceIpAddress() { + return this.sourceIpAddress; + } + + @Override + public Builder setSourceIpAddress(int sourceIpAddress) { + this.sourceIpAddress = sourceIpAddress; + this.bIsSourceIpAddressset = true; + return this; + } + + @Override + public int getDestIpAddress() { + return this.destIpAddress; + } + + @Override + public Builder setDestIpAddress(int destIpAddress) { + this.destIpAddress = destIpAddress; + this.bIsDestIpAddressset = true; + return this; + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("sourceIpAddress", sourceIpAddress) + .add("destIpAddress", destIpAddress).toString(); + } + +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEroObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEroObjectVer1.java new file mode 100644 index 00000000..4d7cb16e --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEroObjectVer1.java @@ -0,0 +1,407 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepEroObject; +import org.onosproject.pcepio.types.AutonomousSystemTlv; +import org.onosproject.pcepio.types.IPv4SubObject; +import org.onosproject.pcepio.types.IPv6SubObject; +import org.onosproject.pcepio.types.PathKeySubObject; +import org.onosproject.pcepio.types.PcepErrorDetailInfo; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; +import org.onosproject.pcepio.types.SrEroSubObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP Ero Object. + */ +public class PcepEroObjectVer1 implements PcepEroObject { + /* + * rfc3209 + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Object-Class | OT |Res|P|I| Object Length (bytes) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + // (Subobjects) // + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + If a Path message contains multiple EXPLICIT_ROUTE objects, only the + first object is meaningful. Subsequent EXPLICIT_ROUTE objects MAY be + ignored and SHOULD NOT be propagated. + + In current implementation, only strict hops are supported. So, + empty ERO with no sub-objects is considered illegal. + + Subobjects: + 0 1 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------//----------------+ + |L| Type | Length | (Subobject contents) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------//----------------+ + + L + + The L bit is an attribute of the subobject. The L bit is set + if the subobject represents a loose hop in the explicit route. + If the bit is not set, the subobject represents a strict hop in + the explicit route. + + Type + + The Type indicates the type of contents of the subobject. + + + Subobject 1: IPv4 address + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |L| Type | Length | IPv4 address (4 bytes) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | IPv4 address (continued) | Prefix Length | Resvd | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Subobject 2: IPv6 Prefix + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |L| Type | Length | IPv6 address (16 bytes) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | IPv6 address (continued) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | IPv6 address (continued) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | IPv6 address (continued) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | IPv6 address (continued) | Prefix Length | Resvd | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Subobject 3: Autonomous System Number + + The contents of an Autonomous System (AS) number subobject are a 2- + octet AS number. The abstract node represented by this subobject is + the set of nodes belonging to the autonomous system. + + The length of the AS number subobject is 4 octets. + + Subobject 4: PATH_KEY_32_BIT_SUB_OBJ_TYPE: + + Pathkey subobject(RFC 5520): + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |L| Type | Length | Path-Key | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | PCE ID (4 bytes) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Subobject 5: SR_ERO_SUB_OBJ_TYPE: + + SR-ERO subobject: (draft-ietf-pce-segment-routing-00) + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |L| Type | Length | ST | Flags |F|S|C|M| + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | SID | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + // NAI (variable) // + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + protected static final Logger log = LoggerFactory.getLogger(PcepEroObjectVer1.class); + + public static final byte ERO_OBJ_TYPE = 1; + public static final byte ERO_OBJ_CLASS = 7; + public static final byte ERO_OBJECT_VERSION = 1; + public static final short ERO_OBJ_MINIMUM_LENGTH = 12; + public static final byte IPV4_TYPE = 1; + public static final byte PATH_KEY_32_BIT_SUB_OBJ_TYPE = 64; + public static final int LABEL_SUB_OBJ_TYPE = 3; + public static final int SR_ERO_SUB_OBJ_TYPE = 96; + public static final int OBJECT_HEADER_LENGTH = 4; + public static final int YTYPE_SHIFT_VALUE = 0x7F; + + static final PcepObjectHeader DEFAULT_ERO_OBJECT_HEADER = new PcepObjectHeader(ERO_OBJ_CLASS, ERO_OBJ_TYPE, + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, ERO_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader eroObjHeader; + private LinkedList llSubObjects = new LinkedList<>(); + + /** + * reset variables. + */ + public PcepEroObjectVer1() { + this.eroObjHeader = null; + this.llSubObjects = null; + } + + /** + * Constructor to initialize parameters of ERO object. + * + * @param eroObjHeader ERO object header + * @param llSubObjects list of sub objects. + */ + public PcepEroObjectVer1(PcepObjectHeader eroObjHeader, LinkedList llSubObjects) { + + this.eroObjHeader = eroObjHeader; + this.llSubObjects = llSubObjects; + } + + /** + * Returns ERO object header. + * + * @return eroObjHeader ERO object header + */ + public PcepObjectHeader getEroObjHeader() { + return this.eroObjHeader; + } + + /** + * Sets Object Header. + * + * @param obj ERO object header + */ + public void setEroObjHeader(PcepObjectHeader obj) { + this.eroObjHeader = obj; + } + + @Override + public LinkedList getSubObjects() { + return this.llSubObjects; + } + + @Override + public void setSubObjects(LinkedList llSubObjects) { + this.llSubObjects = llSubObjects; + } + + /** + * Reads from channel buffer and returns object of PcepEroObject. + * + * @param cb channel buffer. + * @return object of PcepEroObject + * @throws PcepParseException when ERO object is not present in channel buffer + */ + public static PcepEroObject read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader eroObjHeader; + LinkedList llSubObjects = new LinkedList<>(); + + eroObjHeader = PcepObjectHeader.read(cb); + + if (eroObjHeader.getObjClass() != PcepEroObjectVer1.ERO_OBJ_CLASS) { + log.debug("ErrorType:" + PcepErrorDetailInfo.ERROR_TYPE_6 + " ErrorValue:" + + PcepErrorDetailInfo.ERROR_VALUE_9); + throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_6, PcepErrorDetailInfo.ERROR_VALUE_9); + } + + if (eroObjHeader.getObjLen() > OBJECT_HEADER_LENGTH) { + ChannelBuffer tempCb = cb.readBytes(eroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); + llSubObjects = parseSubObjects(tempCb); + } + return new PcepEroObjectVer1(eroObjHeader, llSubObjects); + } + + /** + * Parse list of Sub Objects. + * + * @param cb channel buffer + * @return list of Sub Objects + * @throws PcepParseException when fails to parse sub object list + */ + protected static LinkedList parseSubObjects(ChannelBuffer cb) throws PcepParseException { + + LinkedList llSubObjects = new LinkedList<>(); + + while (0 < cb.readableBytes()) { + + //check the Type of the TLV + byte yType = cb.readByte(); + yType = (byte) (yType & (YTYPE_SHIFT_VALUE)); + byte hLength = cb.readByte(); + + PcepValueType subObj; + + switch (yType) { + + case IPv4SubObject.TYPE: + subObj = IPv4SubObject.read(cb); + break; + case IPv6SubObject.TYPE: + byte[] ipv6Value = new byte[IPv6SubObject.VALUE_LENGTH]; + cb.readBytes(ipv6Value, 0, IPv6SubObject.VALUE_LENGTH); + subObj = new IPv6SubObject(ipv6Value); + break; + case AutonomousSystemTlv.TYPE: + subObj = AutonomousSystemTlv.read(cb); + break; + case PathKeySubObject.TYPE: + subObj = PathKeySubObject.read(cb); + break; + case SrEroSubObject.TYPE: + subObj = SrEroSubObject.read(cb); + break; + default: + throw new PcepParseException("Unexpected sub object. Type: " + (int) yType); + } + // Check for the padding + int pad = hLength % 4; + if (0 < pad) { + pad = 4 - pad; + if (pad <= cb.readableBytes()) { + cb.skipBytes(pad); + } + } + + llSubObjects.add(subObj); + } + if (0 < cb.readableBytes()) { + throw new PcepParseException("Subobject parsing error. Extra bytes received."); + } + return llSubObjects; + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + //write Object header + int objStartIndex = cb.writerIndex(); + + int objLenIndex = eroObjHeader.write(cb); + + if (objLenIndex <= 0) { + throw new PcepParseException("Failed to write ERO object header. Index " + objLenIndex); + } + + ListIterator listIterator = llSubObjects.listIterator(); + + while (listIterator.hasNext()) { + listIterator.next().write(cb); + } + + //Update object length now + int length = cb.writerIndex() - objStartIndex; + cb.setShort(objLenIndex, (short) length); + //will be helpful during print(). + eroObjHeader.setObjLen((short) length); + + //As per RFC the length of object should be multiples of 4 + int pad = length % 4; + + if (pad != 0) { + pad = 4 - pad; + for (int i = 0; i < pad; i++) { + cb.writeByte((byte) 0); + } + length = length + pad; + } + + objLenIndex = cb.writerIndex(); + return objLenIndex; + } + + /** + * Builder class for PCEP ERO object. + */ + public static class Builder implements PcepEroObject.Builder { + + private boolean bIsHeaderSet = false; + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + private PcepObjectHeader eroObjHeader; + LinkedList llSubObjects = new LinkedList<>(); + + @Override + public PcepEroObject build() { + + PcepObjectHeader eroObjHeader = this.bIsHeaderSet ? this.eroObjHeader : DEFAULT_ERO_OBJECT_HEADER; + + if (bIsPFlagSet) { + eroObjHeader.setPFlag(bPFlag); + } + + if (bIsIFlagSet) { + eroObjHeader.setIFlag(bIFlag); + } + + return new PcepEroObjectVer1(eroObjHeader, this.llSubObjects); + } + + @Override + public PcepObjectHeader getEroObjHeader() { + return this.eroObjHeader; + } + + @Override + public Builder setEroObjHeader(PcepObjectHeader obj) { + this.eroObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public LinkedList getSubObjects() { + return this.llSubObjects; + } + + @Override + public Builder setSubObjects(LinkedList llSubObjects) { + this.llSubObjects = llSubObjects; + return this; + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("EroObjHeader", eroObjHeader).add("SubObjects", llSubObjects) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorInfoVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorInfoVer1.java new file mode 100644 index 00000000..594e40c1 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorInfoVer1.java @@ -0,0 +1,204 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepError; +import org.onosproject.pcepio.protocol.PcepErrorInfo; +import org.onosproject.pcepio.protocol.PcepErrorObject; +import org.onosproject.pcepio.protocol.PcepRPObject; +import org.onosproject.pcepio.protocol.PcepTEObject; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP Error Info. + * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02. + */ +public class PcepErrorInfoVer1 implements PcepErrorInfo { + + protected static final Logger log = LoggerFactory.getLogger(PcepErrorInfoVer1.class); + //Error list is optional + private LinkedList errList; + + /** + * Constructor to add PCEP error object to the list. + * + * @param llRPObjList list of PCEP RP object + * @param llTEObjList list of PCEP TE object + * @param llErrObjList list of PCEP error object + */ + public PcepErrorInfoVer1(LinkedList llRPObjList, LinkedList llTEObjList, + LinkedList llErrObjList) { + this.errList = new LinkedList<>(); + if ((llErrObjList != null) && (!llErrObjList.isEmpty())) { + this.errList.add(new PcepErrorVer1(llRPObjList, llTEObjList, llErrObjList)); + } + } + + /** + * Constructor to initialize error info. + * + * @param errll linked list or pcep error + */ + public PcepErrorInfoVer1(LinkedList errll) { + this.errList = errll; + } + + @Override + public boolean isErrorInfoPresent() { + return !this.errList.isEmpty(); + } + + @Override + public void read(ChannelBuffer cb) throws PcepParseException { + PcepObjectHeader tempObjHeader; + + while (0 < cb.readableBytes()) { + cb.markReaderIndex(); + tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + byte yObjClass = tempObjHeader.getObjClass(); + if ((yObjClass != PcepRPObjectVer1.RP_OBJ_CLASS) && (yObjClass != PcepTEObjectVer1.TE_OBJ_CLASS) + && (yObjClass != PcepErrorObjectVer1.ERROR_OBJ_CLASS)) { + throw new PcepParseException("Unknown Object is present in PCEP-ERROR. Object Class: " + yObjClass); + } + + this.errList.add(PcepErrorVer1.read(cb)); + } + } + + @Override + public void write(ChannelBuffer cb) throws PcepParseException { + //write + ListIterator listIterator = errList.listIterator(); + while (listIterator.hasNext()) { + PcepError pcepError = listIterator.next(); + + //RP Object list is optional + LinkedList llRPObjList = pcepError.getRPObjList(); + if (llRPObjList != null) { + ListIterator rpListIterator = llRPObjList.listIterator(); + while (rpListIterator.hasNext()) { + rpListIterator.next().write(cb); + } + } + + //TE Object list is optional + LinkedList llTEObjList = pcepError.getTEObjList(); + if (llTEObjList != null) { + ListIterator teListIterator = llTEObjList.listIterator(); + while (teListIterator.hasNext()) { + teListIterator.next().write(cb); + } + } + + // is mandatory + boolean bIsErrorObjListFound = false; + + LinkedList llErrObjList = pcepError.getErrorObjList(); + if (llErrObjList != null) { + ListIterator errObjListIterator = llErrObjList.listIterator(); + while (errObjListIterator.hasNext()) { + errObjListIterator.next().write(cb); + bIsErrorObjListFound = true; + } + } + + if (!bIsErrorObjListFound) { + throw new PcepParseException(" is mandatory."); + } + } + } + + @Override + public LinkedList getErrorType() { + LinkedList errorType = new LinkedList<>(); + ListIterator listIterator = errList.listIterator(); + PcepErrorObject errObj; + int error; + while (listIterator.hasNext()) { + PcepError pcepError = listIterator.next(); + LinkedList llErrObjList = pcepError.getErrorObjList(); + if (llErrObjList != null) { + ListIterator errObjListIterator = llErrObjList.listIterator(); + while (errObjListIterator.hasNext()) { + errObj = errObjListIterator.next(); + error = errObj.getErrorType(); + errorType.add(error); + } + } + } + return errorType; + } + + @Override + public LinkedList getErrorValue() { + LinkedList errorValue = new LinkedList<>(); + ListIterator listIterator = errList.listIterator(); + PcepErrorObject errObj; + int error; + while (listIterator.hasNext()) { + PcepError pcepError = listIterator.next(); + LinkedList llErrObjList = pcepError.getErrorObjList(); + if (llErrObjList != null) { + ListIterator errObjListIterator = llErrObjList.listIterator(); + while (errObjListIterator.hasNext()) { + errObj = errObjListIterator.next(); + error = errObj.getErrorValue(); + errorValue.add(error); + } + } + } + return errorValue; + } + + /** + * Builder class for PCEP error info. + */ + public static class Builder implements PcepErrorInfo.Builder { + private LinkedList errll; + + @Override + public PcepErrorInfo build() { + return new PcepErrorInfoVer1(errll); + } + + @Override + public LinkedList getPcepErrorList() { + return this.errll; + } + + @Override + public Builder setPcepErrorList(LinkedList errll) { + this.errll = errll; + return this; + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("ErrorList", errList).toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java new file mode 100644 index 00000000..927d83d6 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java @@ -0,0 +1,383 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepErrorInfo; +import org.onosproject.pcepio.protocol.PcepErrorMsg; +import org.onosproject.pcepio.protocol.PcepErrorObject; +import org.onosproject.pcepio.protocol.PcepMessageReader; +import org.onosproject.pcepio.protocol.PcepMessageWriter; +import org.onosproject.pcepio.protocol.PcepOpenObject; +import org.onosproject.pcepio.protocol.PcepType; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.onosproject.pcepio.types.ErrorObjListWithOpen; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; + +/** + * Provides PCEP Error Message. + */ +public class PcepErrorMsgVer1 implements PcepErrorMsg { + + /* + * PCE Error message format. + + ::= + ( [] ) | + [] + + ::=[] + + ::=[ | ] + + + ::=[] + + ::=[] + + ::=[] + */ + + protected static final Logger log = LoggerFactory.getLogger(PcepOpenMsgVer1.class); + public static final byte PACKET_VERSION = 1; + public static final int PACKET_MINIMUM_LENGTH = 12; + public static final PcepType MSG_TYPE = PcepType.ERROR; + + //Below either one should be present. + private ErrorObjListWithOpen errObjListWithOpen; //optional ( [] ) + private PcepErrorInfo errInfo; //optional [] + + public static final PcepErrorMsgVer1.Reader READER = new Reader(); + + /** + * constructor to initialize variables. + */ + public PcepErrorMsgVer1() { + errObjListWithOpen = null; + errInfo = null; + } + + /** + * Constructor to initialize variables. + * + * @param errObjListWithOpen error-object-list with open object + * @param errInfo error information + */ + public PcepErrorMsgVer1(ErrorObjListWithOpen errObjListWithOpen, PcepErrorInfo errInfo) { + this.errObjListWithOpen = errObjListWithOpen; + this.errInfo = errInfo; + } + + /** + * Reader class for reading PCEP error Message from channel buffer. + */ + public static class Reader implements PcepMessageReader { + + ErrorObjListWithOpen errObjListWithOpen; + PcepErrorInfo errInfo; + PcepObjectHeader tempObjHeader; + + @Override + public PcepErrorMsg readFrom(ChannelBuffer cb) throws PcepParseException { + + errObjListWithOpen = null; + errInfo = null; + tempObjHeader = null; + + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) { + throw new PcepParseException("Packet size is less than the minimum length."); + } + + byte version = cb.readByte(); + version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG); + if (version != PACKET_VERSION) { + throw new PcepParseException("Wrong version: Expected=PcepVersion.PCEP_1(1), got=" + version); + } + // fixed value property type == 1 + byte type = cb.readByte(); + if (type != MSG_TYPE.getType()) { + throw new PcepParseException("Wrong type: Expected=PcepType.ERROR(6), got=" + type); + } + int length = cb.readShort(); + if (length < PACKET_MINIMUM_LENGTH) { + throw new PcepParseException( + "Wrong length: Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: " + length); + } + + //parse + parsePCErrMsg(cb); + + // If other than RP or TE or PCEP-ERROR present then it is error. + if (0 < cb.readableBytes()) { + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); + throw new PcepParseException("Unexpected Object found. Object Class : " + tempObjHeader.getObjClass()); + } + + return new PcepErrorMsgVer1(errObjListWithOpen, errInfo); + } + + /** + * Parsing PCErr Message. + * + * @param cb channel buffer. + * @throws PcepParseException if mandatory fields are missing + * output: this.errObjListWithOpen, this.errInfo + */ + public void parsePCErrMsg(ChannelBuffer cb) throws PcepParseException { + //If PCEP-ERROR list is followed by OPEN Object then store into ErrorObjListWithOpen. + // ( [] + //If PCEP-ERROR list is followed by RP or TE Object then store into errInfo. [] + //If only PCEP-ERROR list is present then store into ErrorObjListWithOpen. + PcepObjectHeader tempObjHeader; + LinkedList llErrObjList; + + if (0 >= cb.readableBytes()) { + throw new PcepParseException("PCEP-ERROR message came with empty objects."); + } + + //parse PCEP-ERROR list + llErrObjList = new LinkedList<>(); + tempObjHeader = parseErrorObjectList(llErrObjList, cb); + + //check whether OPEN-OBJECT is present. + if ((tempObjHeader != null) + && (tempObjHeader.getObjClass() == PcepOpenObjectVer1.OPEN_OBJ_CLASS)) { + + if (llErrObjList.isEmpty()) { + throw new PcepParseException(" should be present if OPEN-OBJECT exists"); + } + + PcepOpenObject pcepOpenObj = PcepOpenObjectVer1.read(cb); + this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList, pcepOpenObj); + + } else if ((tempObjHeader != null) //check whether RP or TE Object is present. + && ((tempObjHeader.getObjClass() == PcepRPObjectVer1.RP_OBJ_CLASS) + || (tempObjHeader.getObjClass() == PcepTEObjectVer1.TE_OBJ_CLASS))) { + + this.errInfo = new PcepErrorInfoVer1(null, null, llErrObjList); + this.errInfo.read(cb); + + } else if (!llErrObjList.isEmpty()) { + //If only PCEP-ERROR list is present then store it in errObjListWithOpen. + this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList); + } else { + throw new PcepParseException("Empty PCEP-ERROR message."); + } + } + + /** + * Parse error-obj-list. + * + * @param llErrObjList error object list output + * @param cb channel buffer input + * @throws PcepParseException if mandatory fields are missing + * @return error object header + */ + public PcepObjectHeader parseErrorObjectList(LinkedList llErrObjList, ChannelBuffer cb) + throws PcepParseException { + PcepObjectHeader tempObjHeader = null; + + while (0 < cb.readableBytes()) { + cb.markReaderIndex(); + tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + if (tempObjHeader.getObjClass() == PcepErrorObjectVer1.ERROR_OBJ_CLASS) { + llErrObjList.add(PcepErrorObjectVer1.read(cb)); + } else { + break; + } + } + return tempObjHeader; + } + } + + /** + * Builder class for PCEP error message. + */ + public static class Builder implements PcepErrorMsg.Builder { + // Pcep error message fields + + private ErrorObjListWithOpen errObjListWithOpen = null; //optional ( [] ) + private PcepErrorInfo errInfo = null; //optional [] + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepType getType() { + return PcepType.ERROR; + } + + @Override + public PcepErrorMsg build() { + return new PcepErrorMsgVer1(this.errObjListWithOpen, this.errInfo); + } + + @Override + public ErrorObjListWithOpen getErrorObjListWithOpen() { + return this.errObjListWithOpen; + } + + @Override + public Builder setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen) { + this.errObjListWithOpen = errObjListWithOpen; + return this; + } + + @Override + public PcepErrorInfo getPcepErrorInfo() { + return this.errInfo; + } + + @Override + public Builder setPcepErrorInfo(PcepErrorInfo errInfo) { + this.errInfo = errInfo; + return this; + } + } + + @Override + public void writeTo(ChannelBuffer cb) throws PcepParseException { + WRITER.write(cb, this); + } + + public static final Writer WRITER = new Writer(); + + /** + * Writer class for writing PCEP error Message to channel buffer. + */ + static class Writer implements PcepMessageWriter { + @Override + public void write(ChannelBuffer cb, PcepErrorMsgVer1 message) throws PcepParseException { + int startIndex = cb.writerIndex(); + // first 3 bits set to version + cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG)); + // message type 0xC + cb.writeByte(MSG_TYPE.getType()); + // length is length of variable message, will be updated at the end + // Store the position of message + // length in buffer + int msgLenIndex = cb.writerIndex(); + cb.writeShort(0); + ErrorObjListWithOpen errObjListWithOpen = message.getErrorObjListWithOpen(); + PcepErrorInfo errInfo = message.getPcepErrorInfo(); + + // write ( [] ) if exists. + // otherwise write [] + + if ((errObjListWithOpen != null) + && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { + errObjListWithOpen.write(cb); + } else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) { + errInfo.write(cb); + } else { + throw new PcepParseException("Empty PCEP-ERROR message."); + } + // PcepErrorMessage message length field + int length = cb.writerIndex() - startIndex; + cb.setShort(msgLenIndex, (short) length); + } + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepType getType() { + return MSG_TYPE; + } + + @Override + public ErrorObjListWithOpen getErrorObjListWithOpen() { + return this.errObjListWithOpen; + } + + @Override + public void setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen) { + this.errObjListWithOpen = errObjListWithOpen; + } + + @Override + public PcepErrorInfo getPcepErrorInfo() { + return this.errInfo; + } + + @Override + public void setPcepErrorInfo(PcepErrorInfo errInfo) { + this.errInfo = errInfo; + } + + /** + * Return list of Error types. + * + * @return error types list + */ + public LinkedList getErrorType() { + LinkedList llErrorType = new LinkedList<>(); + if ((errObjListWithOpen != null) + && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { + llErrorType = errObjListWithOpen.getErrorType(); + } else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) { + llErrorType = errInfo.getErrorType(); + } + + return llErrorType; + } + + /** + * Return list of Error values. + * + * @return error value list + */ + public LinkedList getErrorValue() { + LinkedList llErrorValue = new LinkedList<>(); + if ((errObjListWithOpen != null) + && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { + llErrorValue = errObjListWithOpen.getErrorValue(); + } else if ((errInfo != null) && (errInfo.isErrorInfoPresent())) { + llErrorValue = errInfo.getErrorValue(); + } + + return llErrorValue; + } + + @Override + public String toString() { + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); + + if ((errObjListWithOpen != null) + && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { + toStrHelper.add("ErrorObjectListWithOpen", errObjListWithOpen); + } + if ((errInfo != null) && (errInfo.isErrorInfoPresent())) { + toStrHelper.add("ErrorInfo", errInfo); + } + + return toStrHelper.toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java new file mode 100644 index 00000000..48a337f4 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java @@ -0,0 +1,341 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepErrorObject; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP Error Object. + */ +public class PcepErrorObjectVer1 implements PcepErrorObject { + + /* + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Object-Class | OT |Res|P|I| Object Length (bytes) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Reserved | Flags | Error-Type | Error-value | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + // Optional TLVs // + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + protected static final Logger log = LoggerFactory.getLogger(PcepErrorObjectVer1.class); + + public static final byte ERROR_OBJ_TYPE = 1; + public static final byte ERROR_OBJ_CLASS = 13; + public static final byte ERROR_OBJECT_VERSION = 1; + //ERROR_OBJ_MINIMUM_LENGTH = CommonHeaderLen(4)+ErrorObjectHeaderLen(4) + public static final short ERROR_OBJ_MINIMUM_LENGTH = 8; + public static final int OBJECT_HEADER_LENGTH = 4; + + public static final PcepObjectHeader DEFAULT_ERROR_OBJECT_HEADER = new PcepObjectHeader(ERROR_OBJ_CLASS, + ERROR_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, + ERROR_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader errorObjHeader; + private byte yErrorType; + private byte yErrorValue; + private LinkedList llOptionalTlv; // Optional TLV + + /** + * Constructor to initialize variables. + * + * @param errorObjHeader ERROR Object header + * @param yErrorType Error Type + * @param yErrorValue Error Value + * @param llOptionalTlv list of optional TLV + */ + + public PcepErrorObjectVer1(PcepObjectHeader errorObjHeader, byte yErrorType, byte yErrorValue, + LinkedList llOptionalTlv) { + this.errorObjHeader = errorObjHeader; + this.yErrorType = yErrorType; + this.yErrorValue = yErrorValue; + this.llOptionalTlv = llOptionalTlv; + } + + /** + * sets Object Header. + * + * @param obj Error-Object header + */ + public void setLspObjHeader(PcepObjectHeader obj) { + this.errorObjHeader = obj; + } + + @Override + public void setErrorType(byte yErrorType) { + this.yErrorType = yErrorType; + } + + @Override + public void setErrorValue(byte yErrorValue) { + this.yErrorValue = yErrorValue; + } + + /** + * returns object header. + * + * @return errorObjHeader Error-Object header + */ + public PcepObjectHeader getErrorObjHeader() { + return this.errorObjHeader; + } + + @Override + public int getErrorType() { + return this.yErrorType; + } + + @Override + public byte getErrorValue() { + return this.yErrorValue; + } + + @Override + public LinkedList getOptionalTlv() { + return this.llOptionalTlv; + } + + @Override + public void setOptionalTlv(LinkedList llOptionalTlv) { + this.llOptionalTlv = llOptionalTlv; + } + + /** + * Reads from channel buffer and returns object of PcepErrorObject. + * + * @param cb of channel buffer. + * @return object of PCEP-ERROR-OBJECT + */ + public static PcepErrorObject read(ChannelBuffer cb) { + + PcepObjectHeader errorObjHeader; + byte yErrorType; + byte yErrorValue; + LinkedList llOptionalTlv; + + errorObjHeader = PcepObjectHeader.read(cb); + + //take only ErrorObject buffer. + ChannelBuffer tempCb = cb.readBytes(errorObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); + tempCb.readByte(); //ignore Reserved + tempCb.readByte(); //ignore Flags + yErrorType = tempCb.readByte(); + yErrorValue = tempCb.readByte(); + + llOptionalTlv = parseOptionalTlv(tempCb); + + return new PcepErrorObjectVer1(errorObjHeader, yErrorType, yErrorValue, llOptionalTlv); + } + + /** + * returns Linked list of optional tlvs. + * + * @param cb channel buffer. + * @return Linked list of optional tlvs + */ + protected static LinkedList parseOptionalTlv(ChannelBuffer cb) { + + LinkedList llOutOptionalTlv = new LinkedList<>(); + + byte[] yTemp = new byte[cb.readableBytes()]; + cb.readBytes(yTemp); + + return llOutOptionalTlv; + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + //write Object header + int objStartIndex = cb.writerIndex(); + + int objLenIndex = errorObjHeader.write(cb); + + if (objLenIndex <= 0) { + throw new PcepParseException("While writing Error Object Header."); + } + + //write Reserved + cb.writeByte(0); + //write Flags + cb.writeByte(0); + //write ErrorType and ErrorValue + cb.writeByte(this.yErrorType); + cb.writeByte(this.yErrorValue); + + // Add optional TLV + packOptionalTlv(cb); + + //Update object length now + int length = cb.writerIndex() - objStartIndex; + //will be helpful during print(). + errorObjHeader.setObjLen((short) length); + // As per RFC the length of object should be + // multiples of 4 + int pad = length % 4; + if (pad != 0) { + pad = 4 - pad; + for (int i = 0; i < pad; i++) { + cb.writeByte((byte) 0); + } + length = length + pad; + } + + cb.setShort(objLenIndex, (short) length); + return length; + } + + /** + * Pack the Optional tlvs. + * + * @param cb channel buffer. + * @return writer index. + */ + protected int packOptionalTlv(ChannelBuffer cb) { + + ListIterator listIterator = llOptionalTlv.listIterator(); + int startIndex = cb.writerIndex(); + while (listIterator.hasNext()) { + PcepValueType tlv = listIterator.next(); + + if (tlv == null) { + log.debug("TLV is null from OptionalTlv list"); + continue; + } + tlv.write(cb); + } + + return cb.writerIndex() - startIndex; + } + + /** + * Builder class for PCEP error object. + */ + public static class Builder implements PcepErrorObject.Builder { + + private boolean bIsHeaderSet = false; + + private PcepObjectHeader errorObjHeader; + private byte yErrorType; + private byte yErrorValue; + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + private LinkedList llOptionalTlv = new LinkedList<>(); + + @Override + public PcepErrorObject build() { + + PcepObjectHeader errorObjHeader = this.bIsHeaderSet ? this.errorObjHeader : DEFAULT_ERROR_OBJECT_HEADER; + + if (bIsPFlagSet) { + errorObjHeader.setPFlag(bPFlag); + } + + if (bIsIFlagSet) { + errorObjHeader.setIFlag(bIFlag); + } + + return new PcepErrorObjectVer1(errorObjHeader, yErrorType, yErrorValue, llOptionalTlv); + } + + @Override + public PcepObjectHeader getErrorObjHeader() { + return this.errorObjHeader; + } + + @Override + public Builder setErrorObjHeader(PcepObjectHeader obj) { + this.errorObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public int getErrorType() { + return this.yErrorType; + } + + @Override + public Builder setErrorType(byte value) { + this.yErrorType = value; + return this; + } + + @Override + public byte getErrorValue() { + return this.yErrorValue; + } + + @Override + public Builder setErrorValue(byte value) { + this.yErrorValue = value; + return this; + } + + @Override + public Builder setOptionalTlv(LinkedList llOptionalTlv) { + this.llOptionalTlv = llOptionalTlv; + return this; + } + + @Override + public LinkedList getOptionalTlv() { + return this.llOptionalTlv; + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("ObjectHeader", errorObjHeader).add("ErrorType", yErrorType) + .add("ErrorValue", yErrorValue).add("OptionalTlv", llOptionalTlv).toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorVer1.java new file mode 100644 index 00000000..0ea51410 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorVer1.java @@ -0,0 +1,399 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepError; +import org.onosproject.pcepio.protocol.PcepErrorObject; +import org.onosproject.pcepio.protocol.PcepRPObject; +import org.onosproject.pcepio.protocol.PcepTEObject; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PcepError list which contains RP or TE objects. + * Reference:PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02. + */ +public class PcepErrorVer1 implements PcepError { + + /* + ::=[ | ] + + + ::=[] + + ::=[] + */ + + protected static final Logger log = LoggerFactory.getLogger(PcepErrorVer1.class); + + private boolean isErroInfoSet; + //PcepErrorObject list + private LinkedList llErrObjList; + //PcepRPObject list + private LinkedList llRPObjList; + //PcepTEObject list + private LinkedList llTEObjList; + private boolean isTEObjListSet; + + public static final int OBJECT_HEADER_LENGTH = 4; + + /** + * Constructor to initialize variable. + */ + public PcepErrorVer1() { + this.llRPObjList = null; + this.llTEObjList = null; + this.llErrObjList = null; + } + + /** + * Constructor to initialize variable. + * + * @param llRPObjList list of PcepRPObject + * @param llTEObjList list of PcepTEObject + * @param llErrObjListObjList list of PcepErrorObject + */ + public PcepErrorVer1(LinkedList llRPObjList, LinkedList llTEObjList, + LinkedList llErrObjListObjList) { + this.llRPObjList = llRPObjList; + this.llTEObjList = llTEObjList; + this.llErrObjList = llErrObjListObjList; + } + + /** + * Constructor to initialize PcepError. + * + * @param llErrObjList list of PcepErrorObject + */ + public PcepErrorVer1(LinkedList llErrObjList) { + this.llRPObjList = null; + this.llTEObjList = null; + this.llErrObjList = llErrObjList; + } + + @Override + public LinkedList getRPObjList() { + return this.llRPObjList; + } + + @Override + public LinkedList getTEObjList() { + return this.llTEObjList; + } + + @Override + public LinkedList getErrorObjList() { + return this.llErrObjList; + } + + /** + * Parse RP List from the channel buffer. + * + * @param cb of type channel buffer + * @throws PcepParseException if mandatory fields are missing + */ + public void parseRPList(ChannelBuffer cb) throws PcepParseException { + byte yObjClass; + byte yObjType; + + llRPObjList = new LinkedList<>(); + + // caller should verify for RP object + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { + log.debug("Unable to find RP Object"); + return; + } + + cb.markReaderIndex(); + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + yObjClass = tempObjHeader.getObjClass(); + yObjType = tempObjHeader.getObjType(); + PcepRPObject rpObj; + while ((yObjClass == PcepRPObjectVer1.RP_OBJ_CLASS) && (yObjType == PcepRPObjectVer1.RP_OBJ_TYPE)) { + rpObj = PcepRPObjectVer1.read(cb); + llRPObjList.add(rpObj); + + if (cb.readableBytes() > OBJECT_HEADER_LENGTH) { + cb.markReaderIndex(); + tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + yObjClass = tempObjHeader.getObjClass(); + yObjType = tempObjHeader.getObjType(); + } else { + break; + } + } + } + + /** + * Parse TE List from the channel buffer. + * + * @param cb of type channel buffer + * @throws PcepParseException if mandatory fields are missing + */ + public void parseTEList(ChannelBuffer cb) throws PcepParseException { + byte yObjClass; + byte yObjType; + + llTEObjList = new LinkedList<>(); + + // caller should verify for TE object + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { + log.debug("Unable to find TE Object"); + return; + } + + cb.markReaderIndex(); + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + yObjClass = tempObjHeader.getObjClass(); + yObjType = tempObjHeader.getObjType(); + PcepTEObject teObj; + while ((yObjClass == PcepTEObjectVer1.TE_OBJ_CLASS) && ((yObjType == PcepTEObjectVer1.TE_OBJ_TYPE_NODE_VALUE) + || (yObjType == PcepTEObjectVer1.TE_OBJ_TYPE_LINK_VALUE))) { + teObj = PcepTEObjectVer1.read(cb); + llTEObjList.add(teObj); + + if (cb.readableBytes() > OBJECT_HEADER_LENGTH) { + cb.markReaderIndex(); + tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + yObjClass = tempObjHeader.getObjClass(); + yObjType = tempObjHeader.getObjType(); + } else { + break; + } + } + } + + /** + * parseErrObjList from the channel buffer. + * + * @param cb of type channel buffer + * @throws PcepParseException if mandatory fields are missing + */ + public void parseErrObjList(ChannelBuffer cb) throws PcepParseException { + byte yObjClass; + byte yObjType; + boolean bIsErrorObjFound = false; + + llErrObjList = new LinkedList<>(); + + // caller should verify for RP object + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { + throw new PcepParseException("Unable to find PCEP-ERROR Object"); + } + + cb.markReaderIndex(); + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + yObjClass = tempObjHeader.getObjClass(); + yObjType = tempObjHeader.getObjType(); + PcepErrorObject errorObject; + while ((yObjClass == PcepErrorObjectVer1.ERROR_OBJ_CLASS) && (yObjType == PcepErrorObjectVer1.ERROR_OBJ_TYPE)) { + errorObject = PcepErrorObjectVer1.read(cb); + llErrObjList.add(errorObject); + bIsErrorObjFound = true; + + if (cb.readableBytes() > OBJECT_HEADER_LENGTH) { + cb.markReaderIndex(); + tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + yObjClass = tempObjHeader.getObjClass(); + yObjType = tempObjHeader.getObjType(); + } else { + break; + } + } + + if (!bIsErrorObjFound) { + throw new PcepParseException("At least one PCEP-ERROR Object should be present."); + } + } + + /** + * Reads the byte stream of PcepError from channel buffer. + * + * @param cb of type channel buffer + * @return PcepError error part of PCEP-ERROR + * @throws PcepParseException if mandatory fields are missing + */ + public static PcepErrorVer1 read(ChannelBuffer cb) throws PcepParseException { + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { + throw new PcepParseException("Unknown Object"); + } + + PcepErrorVer1 pcepError = new PcepErrorVer1(); + // check whether any PCEP Error Info is present + cb.markReaderIndex(); + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + byte yObjClass = tempObjHeader.getObjClass(); + + //If RPlist present then store it.RPList and TEList are optional + if (yObjClass == PcepRPObjectVer1.RP_OBJ_CLASS) { + log.debug("RP_LIST"); + pcepError.parseRPList(cb); + yObjClass = checkNextObject(cb); + } else if (yObjClass == PcepTEObjectVer1.TE_OBJ_CLASS) { + log.debug("TE_LIST"); + pcepError.parseTEList(cb); + yObjClass = checkNextObject(cb); + } + + if (yObjClass == PcepErrorObjectVer1.ERROR_OBJ_CLASS) { + log.debug("PCEP-ERROR obj list"); + pcepError.parseErrObjList(cb); + yObjClass = checkNextObject(cb); + } + + return pcepError; + } + + /** + * Checks Next Object. + * + * @param cb of type channel buffer. + * @return object type class. + */ + private static byte checkNextObject(ChannelBuffer cb) { + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { + return 0; + } + cb.markReaderIndex(); + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); + cb.resetReaderIndex(); + return tempObjHeader.getObjClass(); + } + + /** + * Writes the byte stream of PCEP error to the channel buffer. + * + * @param cb of type channel buffer + * @return object length index + * @throws PcepParseException if mandatory fields are missing + */ + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + int iLenStartIndex = cb.writerIndex(); + + // RPlist is optional + if (this.isErroInfoSet) { + ListIterator rpObjlistIterator = this.llRPObjList.listIterator(); + while (rpObjlistIterator.hasNext()) { + rpObjlistIterator.next().write(cb); + } + } + + // TElist is optional + if (this.isTEObjListSet) { + ListIterator teObjlistIterator = this.llTEObjList.listIterator(); + while (teObjlistIterator.hasNext()) { + teObjlistIterator.next().write(cb); + } + } + //ErrList is mandatory + ListIterator errlistIterator = this.llErrObjList.listIterator(); + while (errlistIterator.hasNext()) { + errlistIterator.next().write(cb); + } + + return cb.writerIndex() - iLenStartIndex; + } + + /** + * Builder for error part of PCEP-ERROR. + */ + public static class Builder implements PcepError.Builder { + + private LinkedList llRPObjList; + private LinkedList llTEObjList; + private LinkedList llErrObjList; + + @Override + public PcepError build() { + return new PcepErrorVer1(llRPObjList, llTEObjList, llErrObjList); + } + + @Override + public LinkedList getRPObjList() { + return this.llRPObjList; + } + + @Override + public Builder setRPObjList(LinkedList llRPObjList) { + this.llRPObjList = llRPObjList; + return this; + } + + @Override + public LinkedList getTEObjList() { + return this.llTEObjList; + } + + @Override + public Builder setTEObjList(LinkedList llTEObjList) { + this.llTEObjList = llTEObjList; + return this; + } + + @Override + public LinkedList getErrorObjList() { + return this.llErrObjList; + } + + @Override + public Builder setErrorObjList(LinkedList llErrObjList) { + this.llErrObjList = llErrObjList; + return this; + } + + } + + @Override + public void setRPObjList(LinkedList llRPObjList) { + this.llRPObjList = llRPObjList; + } + + @Override + public void setTEObjList(LinkedList llTEObjList) { + this.llTEObjList = llTEObjList; + } + + @Override + public void setErrorObjList(LinkedList llErrObjList) { + this.llErrObjList = llErrObjList; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .omitNullValues() + .add("RpObjectList", llRPObjList) + .add("TeObjectList", llTEObjList) + .add("ErrorObjectList", llErrObjList) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFactoryVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFactoryVer1.java new file mode 100644 index 00000000..6b5d450a --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFactoryVer1.java @@ -0,0 +1,226 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; +import org.onosproject.pcepio.protocol.PcepAttribute; +import org.onosproject.pcepio.protocol.PcepBandwidthObject; +import org.onosproject.pcepio.protocol.PcepCloseMsg; +import org.onosproject.pcepio.protocol.PcepEndPointsObject; +import org.onosproject.pcepio.protocol.PcepEroObject; +import org.onosproject.pcepio.protocol.PcepErrorInfo; +import org.onosproject.pcepio.protocol.PcepError; +import org.onosproject.pcepio.protocol.PcepErrorMsg; +import org.onosproject.pcepio.protocol.PcepErrorObject; +import org.onosproject.pcepio.protocol.PcepFactory; +import org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency; +import org.onosproject.pcepio.protocol.PcepInitiateMsg; +import org.onosproject.pcepio.protocol.PcepIroObject; +import org.onosproject.pcepio.protocol.PcepKeepaliveMsg; +import org.onosproject.pcepio.protocol.PcepLabelObject; +import org.onosproject.pcepio.protocol.PcepLabelRangeObject; +import org.onosproject.pcepio.protocol.PcepLabelRangeResvMsg; +import org.onosproject.pcepio.protocol.PcepLabelUpdate; +import org.onosproject.pcepio.protocol.PcepLabelUpdateMsg; +import org.onosproject.pcepio.protocol.PcepLspObject; +import org.onosproject.pcepio.protocol.PcepLspaObject; +import org.onosproject.pcepio.protocol.PcepMessage; +import org.onosproject.pcepio.protocol.PcepMessageReader; +import org.onosproject.pcepio.protocol.PcepMetricObject; +import org.onosproject.pcepio.protocol.PcepMsgPath; +import org.onosproject.pcepio.protocol.PcepOpenMsg; +import org.onosproject.pcepio.protocol.PcepOpenObject; +import org.onosproject.pcepio.protocol.PcepReportMsg; +import org.onosproject.pcepio.protocol.PcepRroObject; +import org.onosproject.pcepio.protocol.PcepSrpObject; +import org.onosproject.pcepio.protocol.PcepStateReport; +import org.onosproject.pcepio.protocol.PcepUpdateMsg; +import org.onosproject.pcepio.protocol.PcepUpdateRequest; +import org.onosproject.pcepio.protocol.PcepVersion; + +/** + * Provides PCEP Factory and returns builder classes for all objects and messages. + */ +public class PcepFactoryVer1 implements PcepFactory { + + public static final PcepFactoryVer1 INSTANCE = new PcepFactoryVer1(); + + @Override + public PcepOpenMsg.Builder buildOpenMsg() { + return new PcepOpenMsgVer1.Builder(); + } + + @Override + public PcepOpenObject.Builder buildOpenObject() { + return new PcepOpenObjectVer1.Builder(); + } + + @Override + public PcepKeepaliveMsg.Builder buildKeepaliveMsg() { + return new PcepKeepaliveMsgVer1.Builder(); + } + + @Override + public PcepCloseMsg.Builder buildCloseMsg() { + return new PcepCloseMsgVer1.Builder(); + } + + @Override + public PcepUpdateMsg.Builder buildUpdateMsg() { + return new PcepUpdateMsgVer1.Builder(); + } + + @Override + public PcepReportMsg.Builder buildReportMsg() { + return new PcepReportMsgVer1.Builder(); + } + + @Override + public PcepInitiateMsg.Builder buildPcepInitiateMsg() { + return new PcepInitiateMsgVer1.Builder(); + } + + @Override + public PcepLspObject.Builder buildLspObject() { + return new PcepLspObjectVer1.Builder(); + } + + @Override + public PcepMessageReader getReader() { + return PcepMessageVer1.READER; + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepSrpObject.Builder buildSrpObject() { + return new PcepSrpObjectVer1.Builder(); + } + + @Override + public PcepEndPointsObject.Builder buildEndPointsObject() { + return new PcepEndPointsObjectVer1.Builder(); + } + + @Override + public PcepEroObject.Builder buildEroObject() { + return new PcepEroObjectVer1.Builder(); + } + + @Override + public PcepRroObject.Builder buildRroObject() { + return new PcepRroObjectVer1.Builder(); + } + + @Override + public PcepLspaObject.Builder buildLspaObject() { + return new PcepLspaObjectVer1.Builder(); + } + + @Override + public PcepIroObject.Builder buildIroObject() { + return new PcepIroObjectVer1.Builder(); + } + + @Override + public PcepMetricObject.Builder buildMetricObject() { + return new PcepMetricObjectVer1.Builder(); + } + + @Override + public PcepBandwidthObject.Builder buildBandwidthObject() { + return new PcepBandwidthObjectVer1.Builder(); + } + + @Override + public PcepMsgPath.Builder buildPcepMsgPath() { + return new PcepMsgPathVer1.Builder(); + } + + @Override + public PcepStateReport.Builder buildPcepStateReport() { + return new PcepStateReportVer1.Builder(); + } + + @Override + public PcepUpdateRequest.Builder buildPcepUpdateRequest() { + return new PcepUpdateRequestVer1.Builder(); + } + + @Override + public PcInitiatedLspRequest.Builder buildPcInitiatedLspRequest() { + return new PcInitiatedLspRequestVer1.Builder(); + } + + @Override + public PcepAttribute.Builder buildPcepAttribute() { + return new PcepAttributeVer1.Builder(); + } + + @Override + public PcepLabelUpdateMsg.Builder buildPcepLabelUpdateMsg() { + return new PcepLabelUpdateMsgVer1.Builder(); + } + + @Override + public PcepLabelUpdate.Builder buildPcepLabelUpdateObject() { + return new PcepLabelUpdateVer1.Builder(); + } + + @Override + public PcepLabelObject.Builder buildLabelObject() { + return new PcepLabelObjectVer1.Builder(); + } + + @Override + public PcepErrorMsg.Builder buildPcepErrorMsg() { + return new PcepErrorMsgVer1.Builder(); + } + + @Override + public PcepErrorObject.Builder buildPcepErrorObject() { + return new PcepErrorObjectVer1.Builder(); + } + + @Override + public PcepFecObjectIPv4Adjacency.Builder buildFecIpv4Adjacency() { + return new PcepFecObjectIPv4AdjacencyVer1.Builder(); + } + + @Override + public PcepErrorInfo.Builder buildPcepErrorInfo() { + return new PcepErrorInfoVer1.Builder(); + } + + @Override + public PcepError.Builder buildPcepError() { + return new PcepErrorVer1.Builder(); + } + + @Override + public PcepLabelRangeObject.Builder buildPcepLabelRangeObject() { + return new PcepLabelRangeObjectVer1.Builder(); + } + + @Override + public PcepLabelRangeResvMsg.Builder buildPcepLabelRangeResvMsg() { + return new PcepLabelRangeResvMsgVer1.Builder(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4AdjacencyVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4AdjacencyVer1.java new file mode 100644 index 00000000..51c672d3 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4AdjacencyVer1.java @@ -0,0 +1,253 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP fec Object IPv4 Adjacency object. + */ +public class PcepFecObjectIPv4AdjacencyVer1 implements PcepFecObjectIPv4Adjacency { + + /* + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5 + * + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Local IPv4 address | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Remote IPv4 address | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + FEC Object-Type is 3 IPv4 Adjacency + */ + protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4AdjacencyVer1.class); + + public static final byte FEC_OBJ_TYPE = 3; + public static final byte FEC_OBJ_CLASS = 36; //to be defined + public static final byte FEC_OBJECT_VERSION = 1; + public static final short FEC_OBJ_MINIMUM_LENGTH = 12; + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; + + static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE, + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader fecObjHeader; + private int localIPv4Address; + private int remoteIPv4Address; + + /** + * Constructor to initialize parameters for PCEP fec object . + * + * @param fecObjHeader FEC Object header + * @param localIPv4Address Local IPv4 Address + * @param remoteIPv4Address Remote IPv4 Address + */ + public PcepFecObjectIPv4AdjacencyVer1(PcepObjectHeader fecObjHeader, int localIPv4Address, int remoteIPv4Address) { + this.fecObjHeader = fecObjHeader; + this.localIPv4Address = localIPv4Address; + this.remoteIPv4Address = remoteIPv4Address; + } + + /** + * Sets Object header. + * + * @param obj Pcep fec Object Header + */ + public void setFecIpv4ObjHeader(PcepObjectHeader obj) { + this.fecObjHeader = obj; + } + + @Override + public int getLocalIPv4Address() { + return this.localIPv4Address; + } + + @Override + public void seLocalIPv4Address(int value) { + this.localIPv4Address = value; + } + + @Override + public int getRemoteIPv4Address() { + return this.remoteIPv4Address; + } + + @Override + public void seRemoteIPv4Address(int value) { + this.remoteIPv4Address = value; + } + + /** + * Reads from channel buffer and Returns object of PcepFecObjectIPv4Adjacency. + * + * @param cb of channel buffer. + * @return object of PcepFecObjectIPv4Adjacency + * @throws PcepParseException when fails to read from channel buffer + */ + public static PcepFecObjectIPv4Adjacency read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader fecObjHeader; + int localIPv4Address; + int remoteIPv4Address; + + fecObjHeader = PcepObjectHeader.read(cb); + + //take only FEC IPv4 Adjacency Object buffer. + ChannelBuffer tempCb = cb.readBytes(fecObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH); + localIPv4Address = tempCb.readInt(); + remoteIPv4Address = tempCb.readInt(); + + return new PcepFecObjectIPv4AdjacencyVer1(fecObjHeader, localIPv4Address, remoteIPv4Address); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + int objStartIndex = cb.writerIndex(); + + //Write common header + int objLenIndex = fecObjHeader.write(cb); + cb.writeInt(localIPv4Address); + cb.writeInt(remoteIPv4Address); + + //Now write FEC IPv4 Adjacency Object Length + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); + return cb.writerIndex(); + } + + /** + * Builder class for PCEP fec object IPv4 Adjacency. + */ + public static class Builder implements PcepFecObjectIPv4Adjacency.Builder { + private boolean bIsHeaderSet = false; + private boolean bIsLocalIPv4Addressset = false; + private boolean bIsRemoteIPv4Addressset = false; + + private PcepObjectHeader fecObjHeader; + int localIPv4Address; + int remoteIPv4Address; + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + @Override + public PcepFecObjectIPv4Adjacency build() throws PcepParseException { + PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER; + + if (!this.bIsLocalIPv4Addressset) { + throw new PcepParseException( + "Local IPv4 Address not set while building PcepFecObjectIPv4Adjacency object."); + } + + if (!this.bIsRemoteIPv4Addressset) { + throw new PcepParseException( + " Remote IPv4 Address not set while building PcepFecObjectIPv4Adjacency object."); + } + + if (bIsPFlagSet) { + fecObjHeader.setPFlag(bPFlag); + } + + if (bIsIFlagSet) { + fecObjHeader.setIFlag(bIFlag); + } + return new PcepFecObjectIPv4AdjacencyVer1(fecObjHeader, this.localIPv4Address, this.remoteIPv4Address); + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + + @Override + public PcepObjectHeader getFecIpv4AdjacencyObjHeader() { + return this.fecObjHeader; + } + + @Override + public Builder setFecIpv4AdjacencyObjHeader(PcepObjectHeader obj) { + this.fecObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public int getLocalIPv4Address() { + return this.localIPv4Address; + } + + @Override + public Builder seLocalIPv4Address(int value) { + this.localIPv4Address = value; + this.bIsLocalIPv4Addressset = true; + return this; + } + + @Override + public int getRemoteIPv4Address() { + return this.remoteIPv4Address; + } + + @Override + public Builder seRemoteIPv4Address(int value) { + this.remoteIPv4Address = value; + this.bIsRemoteIPv4Addressset = true; + return this; + } + + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public int getType() { + return FEC_OBJ_TYPE; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("fecObjHeader", fecObjHeader) + .add("localIPv4Address", localIPv4Address) + .add("remoteIPv4Address", remoteIPv4Address).toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4UnnumberedAdjacencyVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4UnnumberedAdjacencyVer1.java new file mode 100644 index 00000000..f2f54cda --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4UnnumberedAdjacencyVer1.java @@ -0,0 +1,334 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepFecObjectIPv4UnnumberedAdjacency; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides Pcep Fec Object IPv4 Unnumbered Adjacency object. + */ +public class PcepFecObjectIPv4UnnumberedAdjacencyVer1 implements PcepFecObjectIPv4UnnumberedAdjacency { + + /* + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5 + * + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Local Node-ID | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Local Interface ID | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Remote Node-ID | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Remote Interface ID | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + FEC Object-Type is 5, Unnumbered Adjacency with IPv4 NodeIDs + */ + protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4UnnumberedAdjacencyVer1.class); + + public static final byte FEC_OBJ_TYPE = 5; + public static final byte FEC_OBJ_CLASS = 63; //to be defined + public static final byte FEC_OBJECT_VERSION = 1; + public static final short FEC_OBJ_MINIMUM_LENGTH = 20; + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; + + static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE, + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader fecObjHeader; + private int localNodeID; + private int localInterfaceID; + private int remoteNodeID; + private int remoteInterfaceID; + + /** + * Constructor to initialize parameter for PCEP fec object. + * + * @param fecObjHeader fec object header + * @param localNodeID local node ID + * @param localInterfaceID local interface ID + * @param remoteNodeID remote node ID + * @param remoteInterfaceID remote interface ID + */ + public PcepFecObjectIPv4UnnumberedAdjacencyVer1(PcepObjectHeader fecObjHeader, int localNodeID, + int localInterfaceID, int remoteNodeID, int remoteInterfaceID) { + this.fecObjHeader = fecObjHeader; + this.localNodeID = localNodeID; + this.localInterfaceID = localInterfaceID; + this.remoteNodeID = remoteNodeID; + this.remoteInterfaceID = remoteInterfaceID; + } + + /** + * Sets Object Header. + * + * @param obj object header + */ + public void setFecIpv4UnnumberedAdjacencyObjHeader(PcepObjectHeader obj) { + this.fecObjHeader = obj; + } + + @Override + public void setLocalNodeID(int localNodeID) { + this.localNodeID = localNodeID; + } + + /** + * Returns Object Header. + * + * @return fecObjHeader fec object header + */ + public PcepObjectHeader getFecIpv4UnnumberedAdjacencyObjHeader() { + return this.fecObjHeader; + } + + @Override + public int getLocalNodeID() { + return this.localNodeID; + } + + @Override + public int getLocalInterfaceID() { + return this.localInterfaceID; + } + + @Override + public void setLocalInterfaceID(int localInterfaceID) { + this.localInterfaceID = localInterfaceID; + } + + @Override + public int getRemoteNodeID() { + return this.remoteNodeID; + } + + @Override + public void setRemoteNodeID(int remoteNodeID) { + this.remoteNodeID = remoteNodeID; + } + + @Override + public int getRemoteInterfaceID() { + return this.remoteInterfaceID; + } + + @Override + public void setRemoteInterfaceID(int remoteInterfaceID) { + this.remoteInterfaceID = remoteInterfaceID; + } + + /** + * Reads from channel buffer and returns object of PcepFecObjectIPv4UnnumberedAdjacency. + * + * @param cb of channel buffer + * @return object of PcepFecObjectIPv4UnnumberedAdjacency + * @throws PcepParseException when fails to read from channel buffer + */ + public static PcepFecObjectIPv4UnnumberedAdjacency read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader fecObjHeader; + int localNodeID; + int localInterfaceID; + int remoteNodeID; + int remoteInterfaceID; + + fecObjHeader = PcepObjectHeader.read(cb); + + //take only FEC IPv4 Unnumbered Adjacency Object buffer. + ChannelBuffer tempCb = cb.readBytes(fecObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH); + localNodeID = tempCb.readInt(); + localInterfaceID = tempCb.readInt(); + remoteNodeID = tempCb.readInt(); + remoteInterfaceID = tempCb.readInt(); + + return new PcepFecObjectIPv4UnnumberedAdjacencyVer1(fecObjHeader, localNodeID, localInterfaceID, remoteNodeID, + remoteInterfaceID); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + int objStartIndex = cb.writerIndex(); + + //Write common header + int objLenIndex = fecObjHeader.write(cb); + cb.writeInt(localNodeID); + cb.writeInt(localInterfaceID); + cb.writeInt(remoteNodeID); + cb.writeInt(remoteInterfaceID); + + //Now write FEC IPv4 Unnumbered Adjacency Object Length + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); + + return cb.writerIndex(); + } + + /** + * Builder class for PCEP Fec object IPv4 unnumbered Adjacency. + */ + public static class Builder implements PcepFecObjectIPv4UnnumberedAdjacency.Builder { + private boolean bIsHeaderSet = false; + private boolean bIsLocalNodeIDset = false; + private boolean bIsLocalInterfaceIDset = false; + private boolean bIsRemoteNodeIDset = false; + private boolean bIsRemoteInterfaceIDset = false; + + private PcepObjectHeader fecObjHeader; + private int localNodeID; + private int localInterfaceID; + private int remoteNodeID; + private int remoteInterfaceID; + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + @Override + public PcepFecObjectIPv4UnnumberedAdjacency build() throws PcepParseException { + PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER; + + if (!this.bIsLocalNodeIDset) { + throw new PcepParseException( + " Local Node ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object."); + } + if (!this.bIsLocalInterfaceIDset) { + throw new PcepParseException( + " Local Interface ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object."); + } + if (!this.bIsRemoteNodeIDset) { + throw new PcepParseException( + " Remote Node ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object."); + } + if (!this.bIsRemoteInterfaceIDset) { + throw new PcepParseException( + " Remote Interface ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object."); + } + if (bIsPFlagSet) { + fecObjHeader.setPFlag(bPFlag); + } + if (bIsIFlagSet) { + fecObjHeader.setIFlag(bIFlag); + } + return new PcepFecObjectIPv4UnnumberedAdjacencyVer1(fecObjHeader, this.localNodeID, this.localInterfaceID, + this.remoteNodeID, this.remoteInterfaceID); + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + + @Override + public PcepObjectHeader getFecIpv4UnnumberedAdjacencyObjHeader() { + return this.fecObjHeader; + } + + @Override + public Builder setFecIpv4UnnumberedAdjacencyObjHeader(PcepObjectHeader obj) { + this.fecObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public int getLocalNodeID() { + return this.localNodeID; + } + + @Override + public Builder setLocalNodeID(int value) { + this.localNodeID = value; + this.bIsLocalNodeIDset = true; + return this; + } + + @Override + public int getLocalInterfaceID() { + return this.localInterfaceID; + } + + @Override + public Builder setLocalInterfaceID(int value) { + this.localInterfaceID = value; + this.bIsLocalInterfaceIDset = true; + return this; + } + + @Override + public int getRemoteNodeID() { + return this.remoteNodeID; + } + + @Override + public Builder setRemoteNodeID(int value) { + this.remoteNodeID = value; + this.bIsRemoteNodeIDset = true; + return this; + } + + @Override + public int getRemoteInterfaceID() { + return this.remoteInterfaceID; + } + + @Override + public Builder setRemoteInterfaceID(int value) { + this.remoteInterfaceID = value; + this.bIsRemoteInterfaceIDset = true; + return this; + } + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public int getType() { + return FEC_OBJ_TYPE; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("LocalNodeID: ", localNodeID) + .add("LocalInterfaceID: ", localInterfaceID).add("RemoteNodeID: ", remoteNodeID) + .add("RemoteInterfaceID: ", remoteInterfaceID).toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4Ver1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4Ver1.java new file mode 100644 index 00000000..354547a1 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4Ver1.java @@ -0,0 +1,217 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepFecObjectIPv4; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides Pcep Fec Object IPv4 object. + */ +public class PcepFecObjectIPv4Ver1 implements PcepFecObjectIPv4 { + + /* + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5 + * + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | IPv4 Node ID | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + FEC Object-Type is 1 IPv4 Node ID + */ + protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4Ver1.class); + + public static final byte FEC_OBJ_TYPE = 1; + public static final byte FEC_OBJ_CLASS = 63; //to be defined + public static final byte FEC_OBJECT_VERSION = 1; + public static final short FEC_OBJ_MINIMUM_LENGTH = 8; + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; + + static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE, + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader fecObjHeader; + private int nodeID; + + /** + * Constructor to initialize parameters for PCEP fec object. + * + * @param fecObjHeader fec object header + * @param nodeID node id + */ + public PcepFecObjectIPv4Ver1(PcepObjectHeader fecObjHeader, int nodeID) { + this.fecObjHeader = fecObjHeader; + this.nodeID = nodeID; + } + + /** + * Sets the Object Header. + * + * @param obj object header + */ + public void setFecIpv4ObjHeader(PcepObjectHeader obj) { + this.fecObjHeader = obj; + } + + @Override + public void setNodeID(int nodeID) { + this.nodeID = nodeID; + } + + /** + * Returns Object Header. + * + * @return fecObjHeader fec object header + */ + public PcepObjectHeader getFecIpv4ObjHeader() { + return this.fecObjHeader; + } + + @Override + public int getNodeID() { + return this.nodeID; + } + + /** + * Reads from channel buffer and returns object of PcepFecObjectIPv4. + * + * @param cb of channel buffer + * @return object of PcepFecObjectIPv4 + * @throws PcepParseException when fails to read from channel buffer + */ + public static PcepFecObjectIPv4 read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader fecObjHeader; + int nodeID; + fecObjHeader = PcepObjectHeader.read(cb); + nodeID = cb.readInt(); + return new PcepFecObjectIPv4Ver1(fecObjHeader, nodeID); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + int objStartIndex = cb.writerIndex(); + + //write common header + int objLenIndex = fecObjHeader.write(cb); + cb.writeInt(nodeID); + + //now write FEC IPv4 Object Length + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); + return cb.writerIndex(); + } + + /** + * Builder class for PCEP fec pobject IPv4. + */ + public static class Builder implements PcepFecObjectIPv4.Builder { + private boolean bIsHeaderSet = false; + private boolean bIsNodeIdset = false; + + private PcepObjectHeader fecObjHeader; + private int nodeID; + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + @Override + public PcepFecObjectIPv4 build() throws PcepParseException { + PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER; + + if (!this.bIsNodeIdset) { + throw new PcepParseException("NodeID not set while building PcepFecObjectIPv4 object."); + } + if (bIsPFlagSet) { + fecObjHeader.setPFlag(bPFlag); + } + if (bIsIFlagSet) { + fecObjHeader.setIFlag(bIFlag); + } + return new PcepFecObjectIPv4Ver1(fecObjHeader, this.nodeID); + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + + @Override + public PcepObjectHeader getFecIpv4ObjHeader() { + return this.fecObjHeader; + } + + @Override + public Builder setFecIpv4ObjHeader(PcepObjectHeader obj) { + this.fecObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public int getNodeID() { + return this.nodeID; + } + + @Override + public Builder setNodeID(int value) { + this.nodeID = value; + this.bIsNodeIdset = true; + return this; + } + + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public int getType() { + return FEC_OBJ_TYPE; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("fecObjHeader", fecObjHeader) + .add("nodeID: ", nodeID) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6AdjacencyVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6AdjacencyVer1.java new file mode 100644 index 00000000..f8ea7869 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6AdjacencyVer1.java @@ -0,0 +1,249 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepFecObjectIPv6Adjacency; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides Pcep Fec Object IPv6 Adjacency object. + */ +public class PcepFecObjectIPv6AdjacencyVer1 implements PcepFecObjectIPv6Adjacency { + + /* + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5 + * + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + // Local IPv6 address (16 bytes) // + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + // Remote IPv6 address (16 bytes) // + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + FEC Object-Type is 4 IPv6 Adjacency + */ + protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv6AdjacencyVer1.class); + + public static final byte FEC_OBJ_TYPE = 4; + public static final byte FEC_OBJ_CLASS = 63; //to be defined + public static final byte FEC_OBJECT_VERSION = 1; + public static final short FEC_OBJ_MINIMUM_LENGTH = 36; + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; + public static final int IPV6_ADDRESS_LENGTH = 16; + + static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE, + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader fecObjHeader; + private byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; + private byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; + + /** + * Constructor to initialize parameters for PCEP fec object. + * + * @param fecObjHeader fec object header + * @param localIPv6Address local IPv6 address + * @param remoteIPv6Address remote IPv6 address + */ + public PcepFecObjectIPv6AdjacencyVer1(PcepObjectHeader fecObjHeader, byte[] localIPv6Address, + byte[] remoteIPv6Address) { + this.fecObjHeader = fecObjHeader; + this.localIPv6Address = localIPv6Address; + this.remoteIPv6Address = remoteIPv6Address; + } + + /** + * Sets Object Header. + * + * @param obj object header + */ + public void setFecIpv4ObjHeader(PcepObjectHeader obj) { + this.fecObjHeader = obj; + } + + @Override + public byte[] getLocalIPv6Address() { + return this.localIPv6Address; + } + + @Override + public void seLocalIPv6Address(byte[] value) { + this.localIPv6Address = value; + } + + @Override + public byte[] getRemoteIPv6Address() { + return this.remoteIPv6Address; + } + + @Override + public void seRemoteIPv6Address(byte[] value) { + this.remoteIPv6Address = value; + } + + /** + * Reads channel buffer and Returns object of PcepFecObjectIPv6Adjacency. + * + * @param cb of channel buffer + * @return object of PcepFecObjectIPv6Adjacency + * @throws PcepParseException when fails tp read from channel buffer + */ + public static PcepFecObjectIPv6Adjacency read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader fecObjHeader; + byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; + byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; + fecObjHeader = PcepObjectHeader.read(cb); + cb.readBytes(localIPv6Address, 0, IPV6_ADDRESS_LENGTH); + cb.readBytes(remoteIPv6Address, 0, IPV6_ADDRESS_LENGTH); + return new PcepFecObjectIPv6AdjacencyVer1(fecObjHeader, localIPv6Address, remoteIPv6Address); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + int objStartIndex = cb.writerIndex(); + + //write common header + int objLenIndex = fecObjHeader.write(cb); + cb.writeBytes(localIPv6Address); + cb.writeBytes(remoteIPv6Address); + //now write FEC IPv6 Adjacency Object Length + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); + return cb.writerIndex(); + } + + /** + * Builder class for PCEP fec object IPv6 Adjacency. + */ + public static class Builder implements PcepFecObjectIPv6Adjacency.Builder { + private boolean bIsHeaderSet = false; + private boolean bIsLocalIPv6Addressset = false; + private boolean bIsRemoteIPv6Addressset = false; + + private PcepObjectHeader fecObjHeader; + byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; + byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + @Override + public PcepFecObjectIPv6Adjacency build() throws PcepParseException { + PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER; + + if (!this.bIsLocalIPv6Addressset) { + throw new PcepParseException( + "Local IPv6 Address not set while building PcepFecObjectIPv6Adjacency object."); + } + if (!this.bIsRemoteIPv6Addressset) { + throw new PcepParseException( + "Remote IPv6 Address not set while building PcepFecObjectIPv6Adjacency object."); + } + if (bIsPFlagSet) { + fecObjHeader.setPFlag(bPFlag); + } + if (bIsIFlagSet) { + fecObjHeader.setIFlag(bIFlag); + } + return new PcepFecObjectIPv6AdjacencyVer1(fecObjHeader, this.localIPv6Address, this.remoteIPv6Address); + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + + @Override + public PcepObjectHeader getFecIpv6AdjacencyObjHeader() { + return this.fecObjHeader; + } + + @Override + public Builder setFecIpv6AdjacencyObjHeader(PcepObjectHeader obj) { + this.fecObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public byte[] getLocalIPv6Address() { + return this.localIPv6Address; + } + + @Override + public Builder setLocalIPv6Address(byte[] value) { + this.localIPv6Address = value; + this.bIsLocalIPv6Addressset = true; + return this; + } + + @Override + public byte[] getRemoteIPv6Address() { + return this.remoteIPv6Address; + } + + @Override + public Builder setRemoteIPv6Address(byte[] value) { + this.remoteIPv6Address = value; + this.bIsRemoteIPv6Addressset = true; + return this; + } + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public int getType() { + return FEC_OBJ_TYPE; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("localIPv6Address", localIPv6Address) + .add("remoteIPv6Address: ", remoteIPv6Address) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6Ver1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6Ver1.java new file mode 100644 index 00000000..240a96f7 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6Ver1.java @@ -0,0 +1,220 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepFecObjectIPv6; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides Pcep Fec Object IPv6 object. + */ +public class PcepFecObjectIPv6Ver1 implements PcepFecObjectIPv6 { + + /* + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5 + * + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + // IPv6 Node ID (16 bytes) // + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + FEC Object-Type is 2 IPv6 Node ID + */ + protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv6Ver1.class); + + public static final byte FEC_OBJ_TYPE = 2; + public static final byte FEC_OBJ_CLASS = 63; //to be defined + public static final byte FEC_OBJECT_VERSION = 1; + public static final short FEC_OBJ_MINIMUM_LENGTH = 20; + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; + public static final int IPV6_ADDRESS_LENGTH = 16; + + static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE, + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader fecObjHeader; + private byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH]; + + /** + * Constructor to initialize parameters for PCEP fec object. + * + * @param fecObjHeader Fec object header + * @param nodeID node ID + */ + public PcepFecObjectIPv6Ver1(PcepObjectHeader fecObjHeader, byte[] nodeID) { + this.fecObjHeader = fecObjHeader; + this.nodeID = nodeID; + } + + /** + * Sets the Object header. + * + * @param obj object header + */ + public void setFecIpv6ObjHeader(PcepObjectHeader obj) { + this.fecObjHeader = obj; + } + + @Override + public void setNodeID(byte[] nodeID) { + this.nodeID = nodeID; + } + + /** + * Returns object header. + * + * @return fec Object Header + */ + public PcepObjectHeader getFecIpv6ObjHeader() { + return this.fecObjHeader; + } + + @Override + public byte[] getNodeID() { + return this.nodeID; + } + + /** + * reads the channel buffer and returns object of PcepFecObjectIPv6. + * + * @param cb of channel buffer. + * @return object of PcepFecObjectIPv6 + * @throws PcepParseException when fails to read from channel buffer + */ + public static PcepFecObjectIPv6 read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader fecObjHeader; + byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH]; + fecObjHeader = PcepObjectHeader.read(cb); + cb.readBytes(nodeID, 0, IPV6_ADDRESS_LENGTH); + return new PcepFecObjectIPv6Ver1(fecObjHeader, nodeID); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + int objStartIndex = cb.writerIndex(); + + //write common header + int objLenIndex = fecObjHeader.write(cb); + cb.writeBytes(nodeID); + + //now write FEC IPv4 Object Length + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); + return cb.writerIndex(); + } + + /** + * Builder class for PCEP fec object IPv6. + */ + public static class Builder implements PcepFecObjectIPv6.Builder { + private boolean bIsHeaderSet = false; + private boolean bIsNodeIdset = false; + + private PcepObjectHeader fecObjHeader; + private byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH]; + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + @Override + public PcepFecObjectIPv6 build() throws PcepParseException { + PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER; + + if (!this.bIsNodeIdset) { + throw new PcepParseException(" NodeID not set while building PcepFecObjectIPv6 object."); + } + if (bIsPFlagSet) { + fecObjHeader.setPFlag(bPFlag); + } + if (bIsIFlagSet) { + fecObjHeader.setIFlag(bIFlag); + } + return new PcepFecObjectIPv6Ver1(fecObjHeader, this.nodeID); + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + + @Override + public PcepObjectHeader getFecIpv6ObjHeader() { + return this.fecObjHeader; + } + + @Override + public Builder setFecIpv6ObjHeader(PcepObjectHeader obj) { + this.fecObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public byte[] getNodeID() { + return this.nodeID; + } + + @Override + public Builder setNodeID(byte[] value) { + this.nodeID = value; + this.bIsNodeIdset = true; + return this; + } + + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public int getType() { + return FEC_OBJ_TYPE; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("fecObjHeader", fecObjHeader) + .add("NodeID: ", nodeID) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInitiateMsgVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInitiateMsgVer1.java new file mode 100644 index 00000000..60d14b07 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInitiateMsgVer1.java @@ -0,0 +1,332 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; +import org.onosproject.pcepio.protocol.PcepAttribute; +import org.onosproject.pcepio.protocol.PcepEndPointsObject; +import org.onosproject.pcepio.protocol.PcepEroObject; +import org.onosproject.pcepio.protocol.PcepInitiateMsg; +import org.onosproject.pcepio.protocol.PcepLspObject; +import org.onosproject.pcepio.protocol.PcepMessageReader; +import org.onosproject.pcepio.protocol.PcepMessageWriter; +import org.onosproject.pcepio.protocol.PcepSrpObject; +import org.onosproject.pcepio.protocol.PcepType; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP initiate message. + */ +class PcepInitiateMsgVer1 implements PcepInitiateMsg { + + protected static final Logger log = LoggerFactory.getLogger(PcepInitiateMsgVer1.class); + + // Ref : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03, section 5.1 + /* ::= + * + * Where: + * ::= [] + * ::= (|) + * ::= + * + * + * + * [] + * ::= + * + */ + + static final byte PACKET_VERSION = 1; + /* considering LspDelete Request PcInitiate msg will contain + * common header + * srp object + * lsp object + * so min length for this can be + * PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+SrpObjectMinLen(12)+LspObjectMinLen(8) + */ + public static final short PACKET_MINIMUM_LENGTH = 24; + public static final short MINIMUM_COMMON_HEADER_LENGTH = 4; + public static final PcepType MSG_TYPE = PcepType.INITIATE; + private LinkedList llPcInitiatedLspRequestList; + public static final PcepInitiateMsgVer1.Reader READER = new Reader(); + + /** + * Reader class for reading of Pcep initiate message from channel buffer. + */ + static class Reader implements PcepMessageReader { + + LinkedList llPcInitiatedLspRequestList; + + @Override + public PcepInitiateMsg readFrom(ChannelBuffer cb) throws PcepParseException { + + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) { + return null; + } + + llPcInitiatedLspRequestList = new LinkedList<>(); + + byte version = cb.readByte(); + version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG); + if (version != PACKET_VERSION) { + throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), received=" + version); + } + byte type = cb.readByte(); + if (type != MSG_TYPE.getType()) { + throw new PcepParseException("Wrong type. Expected=PcepType.INITIATE(12), recived=" + type); + } + short length = cb.readShort(); + + if (length < PACKET_MINIMUM_LENGTH) { + throw new PcepParseException("Wrong length. Initiate message length expected to be >= " + + PACKET_MINIMUM_LENGTH + ", but received=" + length); + } + + log.debug("reading PcInitiate message of length " + length); + + // parse Start initiate/deletion list + if (!parsePcInitiatedLspRequestList(cb)) { + throw new PcepParseException("Parsing PCE-initiated-lsp-Request-list failed"); + } + + return new PcepInitiateMsgVer1(llPcInitiatedLspRequestList); + } + + /** + * To parse PcInitiatedLspRequestList from PcInitiate Message. + * + * @param cb of type channel buffer + * @return true if parsing PcInitiatedLspRequestList is success, false otherwise + * @throws PcepParseException while parsing from channel buffer + */ + public boolean parsePcInitiatedLspRequestList(ChannelBuffer cb) throws PcepParseException { + + boolean isDelLspRequest = false; + + if (cb == null) { + throw new PcepParseException("Channel buffer is empty"); + } + + while (0 < cb.readableBytes()) { + PcInitiatedLspRequest pceInitLspReq = new PcInitiatedLspRequestVer1(); + + //store SRP object + PcepSrpObject srpObj; + srpObj = PcepSrpObjectVer1.read(cb); + pceInitLspReq.setSrpObject(srpObj); + isDelLspRequest = srpObj.getRFlag(); + + //store LSP object + PcepLspObject lspObj; + lspObj = PcepLspObjectVer1.read(cb); + pceInitLspReq.setLspObject(lspObj); + + /* if R bit will be set then pcInitiate msg will contain only LSp and SRP objects + * so if R bit is not set then we should read for Ero and EndPoint objects also. + */ + if (!isDelLspRequest) { + + //store EndPoint object + PcepEndPointsObject endPointObj; + endPointObj = PcepEndPointsObjectVer1.read(cb); + pceInitLspReq.setEndPointsObject(endPointObj); + + //store ERO object + PcepEroObject eroObj; + eroObj = PcepEroObjectVer1.read(cb); + pceInitLspReq.setEroObject(eroObj); + + if (cb.readableBytes() > MINIMUM_COMMON_HEADER_LENGTH) { + pceInitLspReq.setPcepAttribute(PcepAttributeVer1.read(cb)); + } + } + llPcInitiatedLspRequestList.add(pceInitLspReq); + } + return true; + } + } + + /** + * Constructor to initialize PcInitiatedLspRequest. + * + * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequest + */ + PcepInitiateMsgVer1(LinkedList llPcInitiatedLspRequestList) { + + if (llPcInitiatedLspRequestList == null) { + throw new NullPointerException("PcInitiatedLspRequestList cannot be null."); + } + this.llPcInitiatedLspRequestList = llPcInitiatedLspRequestList; + } + + /** + * Builder class for PCEP initiate message. + */ + static class Builder implements PcepInitiateMsg.Builder { + + // Pcep initiate message fields + LinkedList llPcInitiatedLspRequestList; + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepType getType() { + return PcepType.INITIATE; + } + + @Override + public PcepInitiateMsg build() { + return new PcepInitiateMsgVer1(this.llPcInitiatedLspRequestList); + } + + @Override + public LinkedList getPcInitiatedLspRequestList() { + return this.llPcInitiatedLspRequestList; + } + + @Override + public Builder setPcInitiatedLspRequestList(LinkedList ll) { + this.llPcInitiatedLspRequestList = ll; + return this; + } + } + + @Override + public void writeTo(ChannelBuffer cb) throws PcepParseException { + WRITER.write(cb, this); + } + + static final Writer WRITER = new Writer(); + + /** + * Writer class for writing pcep initiate message to channel buffer. + */ + static class Writer implements PcepMessageWriter { + + @Override + public void write(ChannelBuffer cb, PcepInitiateMsgVer1 message) throws PcepParseException { + + boolean isDelLspRequest = false; + int startIndex = cb.writerIndex(); + // first 3 bits set to version + cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG)); + // message type 0xC + cb.writeByte(MSG_TYPE.getType()); + // length is length of variable message, will be updated at the end + // Store the position of message + // length in buffer + int msgLenIndex = cb.writerIndex(); + cb.writeShort(0); + + ListIterator listIterator = message.llPcInitiatedLspRequestList.listIterator(); + + while (listIterator.hasNext()) { + + PcInitiatedLspRequest listReq = listIterator.next(); + + //Srp Object is mandatory + PcepSrpObject srpObj = listReq.getSrpObject(); + if (srpObj != null) { + isDelLspRequest = srpObj.getRFlag(); + srpObj.write(cb); + } else { + throw new PcepParseException("SRP Object is mandatory for PcInitiate message."); + } + + //LSP Object is mandatory + PcepLspObject lspObj = listReq.getLspObject(); + if (lspObj != null) { + lspObj.write(cb); + } else { + throw new PcepParseException("LSP Object is mandatory for PcInitiate message."); + } + + /* if R bit will be set then pcInitiate msg will contain only LSp and SRP objects + * so if R bit is not set then we should read for Ero and EndPoint objects also. + */ + + if (!isDelLspRequest) { + + //EndPoints object is mandatory + PcepEndPointsObject endPointObj = listReq.getEndPointsObject(); + if (endPointObj != null) { + endPointObj.write(cb); + } else { + throw new PcepParseException("End points Object is mandatory for PcInitiate message."); + } + + //Ero object is mandatory + PcepEroObject eroObj = listReq.getEroObject(); + if (eroObj != null) { + eroObj.write(cb); + } else { + throw new PcepParseException("ERO Object is mandatory for PcInitiate message."); + } + + //PcepAttribute is optional + PcepAttribute pcepAttribute = listReq.getPcepAttribute(); + if (pcepAttribute != null) { + pcepAttribute.write(cb); + } + } + } + + // PCInitiate message length field + int length = cb.writerIndex() - startIndex; + cb.setShort(msgLenIndex, (short) length); + } + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepType getType() { + return MSG_TYPE; + } + + @Override + public LinkedList getPcInitiatedLspRequestList() { + return this.llPcInitiatedLspRequestList; + } + + @Override + public void setPcInitiatedLspRequestList(LinkedList ll) { + this.llPcInitiatedLspRequestList = ll; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("PcInitiaitedLspRequestList", llPcInitiatedLspRequestList) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInterLayerObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInterLayerObjectVer1.java new file mode 100644 index 00000000..5130d9e9 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInterLayerObjectVer1.java @@ -0,0 +1,263 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.pcepio.protocol.ver1; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepInterLayerObject; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP inter layer object. + */ +public class PcepInterLayerObjectVer1 implements PcepInterLayerObject { + + /* + * 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Reserved |N|I| + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + protected static final Logger log = LoggerFactory.getLogger(PcepInterLayerObjectVer1.class); + + public static final byte INTER_LAYER_OBJ_TYPE = 1; + public static final byte INTER_LAYER_OBJ_CLASS = 18; + public static final byte INTER_LAYER_OBJECT_VERSION = 1; + public static final short INTER_LAYER_OBJ_MINIMUM_LENGTH = 8; + public static final boolean DEFAULT_IFLAG = false; + public static final boolean DEFAULT_NFLAG = false; + public static final int OBJECT_HEADER_LENGTH = 4; + public static final int NFLAG_SHIFT_VALUE = 0x02; + public static final int IFLAG_SHIFT_VALUE = 0x01; + + static final PcepObjectHeader DEFAULT_INTER_LAYER_OBJECT_HEADER = new PcepObjectHeader(INTER_LAYER_OBJ_CLASS, + INTER_LAYER_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, + INTER_LAYER_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader interLayerObjHeader; + private boolean bNFlag; + private boolean bIFlag; + + /** + * Constructor to initialize all parameters for Pcep Inter Layer Object. + * + * @param interLayerObjHeader inter layer object header + * @param bNFlag N flag + * @param bIFlag I flag + */ + public PcepInterLayerObjectVer1(PcepObjectHeader interLayerObjHeader, boolean bNFlag, boolean bIFlag) { + + this.interLayerObjHeader = interLayerObjHeader; + this.bNFlag = bNFlag; + this.bIFlag = bIFlag; + } + + /** + * Sets Object Header. + * + * @param obj object header + */ + public void setInterLayerObjHeader(PcepObjectHeader obj) { + this.interLayerObjHeader = obj; + } + + @Override + public void setbNFlag(boolean bNFlag) { + this.bNFlag = bNFlag; + } + + @Override + public void setbIFlag(boolean bIFlag) { + this.bIFlag = bIFlag; + } + + /** + * Returns object header. + * + * @return inter Layer Object Header + */ + public PcepObjectHeader getInterLayerObjHeader() { + return this.interLayerObjHeader; + } + + @Override + public boolean getbNFlag() { + return this.bNFlag; + } + + @Override + public boolean getbIFlag() { + return this.bIFlag; + } + + /** + * Reads channel buffer and returns object of PcepInterLayerObject. + * + * @param cb of type channel buffer + * @return object of PcepInterLayerObject + * @throws PcepParseException when fails to read from channel buffer + */ + public static PcepInterLayerObject read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader interLayerObjHeader; + boolean bNFlag; + boolean bIFlag; + + interLayerObjHeader = PcepObjectHeader.read(cb); + + //take only InterLayerObject buffer. + ChannelBuffer tempCb = cb.readBytes(interLayerObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); + + int iTemp = tempCb.readInt(); + bIFlag = ((iTemp & (byte) IFLAG_SHIFT_VALUE) == IFLAG_SHIFT_VALUE); + bNFlag = ((iTemp & (byte) NFLAG_SHIFT_VALUE) == NFLAG_SHIFT_VALUE); + + return new PcepInterLayerObjectVer1(interLayerObjHeader, bNFlag, bIFlag); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + //write Object header + int objStartIndex = cb.writerIndex(); + + int objLenIndex = interLayerObjHeader.write(cb); + + if (objLenIndex <= 0) { + throw new PcepParseException(" ObjectLength Index is " + objLenIndex); + } + + int iTemp = 0; + + if (bIFlag) { + iTemp = iTemp | (byte) IFLAG_SHIFT_VALUE; + } + if (bNFlag) { + iTemp = iTemp | (byte) NFLAG_SHIFT_VALUE; + } + + cb.writeInt(iTemp); + + //Update object length now + int length = cb.writerIndex() - objStartIndex; + //will be helpful during print(). + interLayerObjHeader.setObjLen((short) length); + cb.setShort(objLenIndex, (short) length); + + objLenIndex = cb.writerIndex(); + return objLenIndex; + } + + /** + * Builder class for PCEP inter layer object. + */ + public static class Builder implements PcepInterLayerObject.Builder { + + private boolean bIsHeaderSet = false; + private boolean bIsNFlagset = false; + private boolean bIsIFlagset = false; + + private PcepObjectHeader interLayerObjHeader; + private boolean bNFlag; + private boolean bIFlag; + + private boolean bIsPFlagSet = false; + private boolean bPFalg; + + private boolean bIsIFlagSet = false; + private boolean iFlag; + + @Override + public PcepInterLayerObject build() { + PcepObjectHeader interLayerObjHeader = this.bIsHeaderSet ? this.interLayerObjHeader + : DEFAULT_INTER_LAYER_OBJECT_HEADER; + + boolean bNFlag = this.bIsNFlagset ? this.bNFlag : DEFAULT_NFLAG; + boolean bIFlag = this.bIsIFlagset ? this.bIFlag : DEFAULT_IFLAG; + + if (bIsPFlagSet) { + interLayerObjHeader.setPFlag(bPFalg); + } + + if (bIsIFlagSet) { + interLayerObjHeader.setIFlag(iFlag); + } + return new PcepInterLayerObjectVer1(interLayerObjHeader, bNFlag, bIFlag); + } + + @Override + public PcepObjectHeader getInterLayerObjHeader() { + return this.interLayerObjHeader; + } + + @Override + public Builder setInterLayerObjHeader(PcepObjectHeader obj) { + this.interLayerObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public boolean getbNFlag() { + return this.bNFlag; + } + + @Override + public Builder setbNFlag(boolean value) { + this.bNFlag = value; + this.bIsNFlagset = true; + return this; + } + + @Override + public boolean getbIFlag() { + return this.bIFlag; + } + + @Override + public Builder setbIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagset = true; + return this; + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFalg = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.iFlag = value; + this.bIsIFlagSet = true; + return this; + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("IFlag", bIFlag) + .add("NFlag", bNFlag).toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepIroObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepIroObjectVer1.java new file mode 100644 index 00000000..2e01bdaa --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepIroObjectVer1.java @@ -0,0 +1,299 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepIroObject; +import org.onosproject.pcepio.types.IPv4SubObject; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP iro object. + */ +public class PcepIroObjectVer1 implements PcepIroObject { + + /* + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + // (Sub-objects) // + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + The IRO Object format + + Each IPV4 suboject + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |L| Type | Length | IPv4 address (4 bytes) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | IPv4 address (continued) | Prefix Length | Resvd | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + protected static final Logger log = LoggerFactory.getLogger(PcepIroObjectVer1.class); + + public static final byte IRO_OBJ_TYPE = 1; + public static final byte IRO_OBJ_CLASS = 10; + public static final byte IRO_OBJECT_VERSION = 1; + public static final short IRO_OBJ_MINIMUM_LENGTH = 12; + public static final int OBJECT_HEADER_LENGTH = 4; + public static final int YTYPE_SHIFT_VALUE = 0x7F; + + public static final PcepObjectHeader DEFAULT_IRO_OBJECT_HEADER = new PcepObjectHeader(IRO_OBJ_CLASS, IRO_OBJ_TYPE, + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, IRO_OBJ_MINIMUM_LENGTH); + + private short iroObjType = 0; + private byte yLength; + private byte yPrefixLength; + private byte yResvd; + private PcepObjectHeader iroObjHeader; + private LinkedList llSubObjects = new LinkedList<>(); + + /** + * Default constructor. + */ + public PcepIroObjectVer1() { + this.iroObjHeader = null; + this.iroObjType = 0; + this.yLength = 0; + } + + /** + * Constructor to initialize member variables. + * + * @param iroObjHeader IRO object header + * @param llSubObjects list of sub-objects + */ + public PcepIroObjectVer1(PcepObjectHeader iroObjHeader, LinkedList llSubObjects) { + this.iroObjHeader = iroObjHeader; + this.llSubObjects = llSubObjects; + } + + /** + * Returns object header. + * + * @return iroObjHeader IRO object header + */ + public PcepObjectHeader getIroObjHeader() { + return this.iroObjHeader; + } + + /** + * Sets IRO Object Header. + * + * @param obj IRO object header + */ + public void setIroObjHeader(PcepObjectHeader obj) { + this.iroObjHeader = obj; + } + + @Override + public LinkedList getSubObjects() { + return this.llSubObjects; + } + + @Override + public void setSubObjects(LinkedList llSubObjects) { + this.llSubObjects = llSubObjects; + } + + /** + * Reads from channel buffer and return object of PcepIroObject. + * + * @param cb of type channel buffer + * @return object of PcepIroObject + * @throws PcepParseException while parsing from channel buffer + */ + public static PcepIroObject read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader iroObjHeader; + LinkedList llSubObjects; + + iroObjHeader = PcepObjectHeader.read(cb); + + //take only IroObject buffer. + ChannelBuffer tempCb = cb.readBytes(iroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); + llSubObjects = parseSubObjects(tempCb); + return new PcepIroObjectVer1(iroObjHeader, llSubObjects); + } + + /** + * Returns linked list of sub objects. + * + * @param cb of type channel buffer + * @return linked list of sub objects + * @throws PcepParseException while parsing subobjects from channel buffer + */ + protected static LinkedList parseSubObjects(ChannelBuffer cb) throws PcepParseException { + + LinkedList llSubObjects = new LinkedList<>(); + + while (0 < cb.readableBytes()) { + + //check the Type of the Subobjects. + byte yType = cb.readByte(); + yType = (byte) (yType & (YTYPE_SHIFT_VALUE)); + byte hLength = cb.readByte(); + + PcepValueType subObj; + switch (yType) { + + case IPv4SubObject.TYPE: + subObj = IPv4SubObject.read(cb); + break; + + default: + throw new PcepParseException("Invalid sub object. Type: " + (int) yType); + } + + // Check for the padding + int pad = hLength % 4; + if (0 < pad) { + pad = 4 - pad; + if (pad <= cb.readableBytes()) { + cb.skipBytes(pad); + } + } + llSubObjects.add(subObj); + } + return llSubObjects; + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + //write Object header + int objStartIndex = cb.writerIndex(); + + int objLenIndex = iroObjHeader.write(cb); + + if (objLenIndex <= 0) { + throw new PcepParseException(" ObjectLength is " + objLenIndex); + } + + ListIterator listIterator = llSubObjects.listIterator(); + while (listIterator.hasNext()) { + listIterator.next().write(cb); + } + + //Update object length now + int length = cb.writerIndex() - objStartIndex; + //will be helpful during print(). + iroObjHeader.setObjLen((short) length); + // As per RFC the length of object should be + // multiples of 4 + int pad = length % 4; + if (pad != 0) { + pad = 4 - pad; + for (int i = 0; i < pad; i++) { + cb.writeByte((byte) 0); + } + length = length + pad; + } + cb.setShort(objLenIndex, (short) length); + objLenIndex = cb.writerIndex(); + return objLenIndex; + } + + /** + * Builder class for PCEP iro object. + */ + public static class Builder implements PcepIroObject.Builder { + + private boolean bIsHeaderSet = false; + + private PcepObjectHeader iroObjHeader; + LinkedList llSubObjects = new LinkedList<>(); + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + @Override + public PcepIroObject build() { + + PcepObjectHeader iroObjHeader = this.bIsHeaderSet ? this.iroObjHeader : DEFAULT_IRO_OBJECT_HEADER; + + if (bIsPFlagSet) { + iroObjHeader.setPFlag(bPFlag); + } + + if (bIsIFlagSet) { + iroObjHeader.setIFlag(bIFlag); + } + + return new PcepIroObjectVer1(iroObjHeader, this.llSubObjects); + } + + @Override + public PcepObjectHeader getIroObjHeader() { + return this.iroObjHeader; + } + + @Override + public Builder setIroObjHeader(PcepObjectHeader obj) { + this.iroObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public LinkedList getSubObjects() { + return this.llSubObjects; + } + + @Override + public Builder setSubObjects(LinkedList llSubObjects) { + this.llSubObjects = llSubObjects; + return this; + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("IroObjectHeader", iroObjHeader) + .add("SubObjects", llSubObjects).toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepKeepaliveMsgVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepKeepaliveMsgVer1.java new file mode 100644 index 00000000..8b6e9382 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepKeepaliveMsgVer1.java @@ -0,0 +1,154 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepKeepaliveMsg; +import org.onosproject.pcepio.protocol.PcepMessageReader; +import org.onosproject.pcepio.protocol.PcepMessageWriter; +import org.onosproject.pcepio.protocol.PcepType; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP keep alive message. + */ +class PcepKeepaliveMsgVer1 implements PcepKeepaliveMsg { + + /* + ::= + + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Ver | Flags | Message-Type | Message-Length | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + */ + + protected static final Logger log = LoggerFactory.getLogger(PcepKeepaliveMsgVer1.class); + // Pcep version: 1 + public static final byte PACKET_VERSION = 1; + public static final int PACKET_MINIMUM_LENGTH = 4; + public static final PcepType MSG_TYPE = PcepType.KEEP_ALIVE; + + public static final PcepKeepaliveMsgVer1.Reader READER = new Reader(); + + /** + * Reader class for reading PCEP keepalive message from channel buffer. + */ + static class Reader implements PcepMessageReader { + + @Override + public PcepKeepaliveMsg readFrom(ChannelBuffer cb) throws PcepParseException { + + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) { + throw new PcepParseException("Packet size is less than the minimum required length."); + } + // fixed value property version == 1 + byte version = cb.readByte(); + version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG); + if (version != PACKET_VERSION) { + throw new PcepParseException("Wrong version: Expected=PcepVersion.KEEP_ALIVE_1(2), got=" + version); + } + // fixed value property type == 2 + byte type = cb.readByte(); + if (type != MSG_TYPE.getType()) { + throw new PcepParseException("Wrong type: Expected=PcepType.KEEP_ALIVE_1(2), got=" + type); + } + short length = cb.readShort(); + if (length < PACKET_MINIMUM_LENGTH) { + throw new PcepParseException("Wrong length: Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: " + + length); + } + return new PcepKeepaliveMsgVer1(); + } + } + + /** + * Default constructor. + */ + PcepKeepaliveMsgVer1() { + } + + /** + * Builder class for PCEP keepalive message. + */ + static class Builder implements PcepKeepaliveMsg.Builder { + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepType getType() { + return PcepType.KEEP_ALIVE; + } + + @Override + public PcepKeepaliveMsg build() { + return new PcepKeepaliveMsgVer1(); + } + } + + @Override + public void writeTo(ChannelBuffer cb) { + WRITER.write(cb, this); + } + + static final Writer WRITER = new Writer(); + + /** + * Writer class for writing the PCEP keepalive message to channel buffer. + */ + static class Writer implements PcepMessageWriter { + + @Override + public void write(ChannelBuffer cb, PcepKeepaliveMsgVer1 message) { + int startIndex = cb.writerIndex(); + // first 3 bits set to version + cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG)); + // message type + cb.writeByte(MSG_TYPE.getType()); + // length is length of variable message, will be updated at the end + // Store the position of message + // length in buffer + int msgLenIndex = cb.writerIndex(); + cb.writeShort((short) 0); + // update message length field + int length = cb.writerIndex() - startIndex; + cb.setShort(msgLenIndex, (short) length); + } + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepType getType() { + return MSG_TYPE; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()).toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java new file mode 100644 index 00000000..a4ac87c3 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java @@ -0,0 +1,370 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepLabelObject; +import org.onosproject.pcepio.types.NexthopIPv4addressTlv; +import org.onosproject.pcepio.types.NexthopIPv6addressTlv; +import org.onosproject.pcepio.types.NexthopUnnumberedIPv4IDTlv; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP label object. + */ +public class PcepLabelObjectVer1 implements PcepLabelObject { + + /* + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.4. + + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Reserved | Flags |O| + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Label | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + // Optional TLV // + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + The LABEL Object format + */ + protected static final Logger log = LoggerFactory.getLogger(PcepLspObjectVer1.class); + + public static final byte LABEL_OBJ_TYPE = 1; + public static final byte LABEL_OBJ_CLASS = 35; //TBD : to be defined + public static final byte LABEL_OBJECT_VERSION = 1; + public static final byte OBJECT_HEADER_LENGTH = 4; + public static final boolean DEFAULT_OFLAG = false; + + // LSP_OBJ_MINIMUM_LENGTH = CommonHeaderLen(4)+ LspObjectHeaderLen(8) + public static final short LABEL_OBJ_MINIMUM_LENGTH = 12; + + public static final int OFLAG_SET = 1; + public static final int OFLAG_RESET = 0; + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; + + static final PcepObjectHeader DEFAULT_LABEL_OBJECT_HEADER = new PcepObjectHeader(LABEL_OBJ_CLASS, LABEL_OBJ_TYPE, + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LABEL_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader labelObjHeader; + private boolean bOFlag; + private int label; + // Optional TLV + private LinkedList llOptionalTlv; + + /** + * Constructor to initialize parameters for PCEP label object. + * + * @param labelObjHeader label object header + * @param bOFlag O flag + * @param label label + * @param llOptionalTlv list of optional tlvs + */ + public PcepLabelObjectVer1(PcepObjectHeader labelObjHeader, boolean bOFlag, int label, + LinkedList llOptionalTlv) { + this.labelObjHeader = labelObjHeader; + this.bOFlag = bOFlag; + this.label = label; + this.llOptionalTlv = llOptionalTlv; + } + + @Override + public LinkedList getOptionalTlv() { + return this.llOptionalTlv; + } + + @Override + public void setOptionalTlv(LinkedList llOptionalTlv) { + this.llOptionalTlv = llOptionalTlv; + } + + @Override + public boolean getOFlag() { + return this.bOFlag; + } + + @Override + public void setOFlag(boolean value) { + this.bOFlag = value; + } + + @Override + public int getLabel() { + return this.label; + } + + @Override + public void setLabel(int value) { + this.label = value; + } + + /** + * Reads form channel buffer and returns objects of PcepLabelObject. + * + * @param cb of type channel buffer + * @return objects of PcepLabelObject + * @throws PcepParseException when fails to read from channel buffer + */ + public static PcepLabelObject read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader labelObjHeader; + + boolean bOFlag; + int label; + + // Optional TLV + LinkedList llOptionalTlv = new LinkedList<>(); + labelObjHeader = PcepObjectHeader.read(cb); + + //take only LspObject buffer. + ChannelBuffer tempCb = cb.readBytes(labelObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); + + int iTemp = tempCb.readInt(); + bOFlag = (iTemp & (byte) 0x01) == 1; + label = tempCb.readInt(); + + // parse optional TLV + llOptionalTlv = parseOptionalTlv(tempCb); + return new PcepLabelObjectVer1(labelObjHeader, bOFlag, label, llOptionalTlv); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + //write Object header + int objStartIndex = cb.writerIndex(); + int objLenIndex = labelObjHeader.write(cb); + + if (objLenIndex <= 0) { + throw new PcepParseException(" ObjectLength Index is " + objLenIndex); + } + + byte oFlag; + + oFlag = (byte) ((bOFlag) ? OFLAG_SET : OFLAG_RESET); + cb.writeInt(oFlag); + cb.writeInt(label); + + // Add optional TLV + packOptionalTlv(cb); + + //Update object length now + int length = cb.writerIndex() - objStartIndex; + + //will be helpful during print(). + labelObjHeader.setObjLen((short) length); + cb.setShort(objLenIndex, (short) length); + return cb.writerIndex(); + } + + /** + * Returns list of optional tlvs. + * + * @param cb of type channel buffer + * @return list of optional tlvs. + * @throws PcepParseException when fails to parse list of optional tlvs + */ + protected static LinkedList parseOptionalTlv(ChannelBuffer cb) throws PcepParseException { + + LinkedList llOutOptionalTlv = new LinkedList<>(); + + while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) { + + PcepValueType tlv; + short hType = cb.readShort(); + short hLength = cb.readShort(); + int iValue = 0; + + switch (hType) { + + case NexthopIPv4addressTlv.TYPE: + iValue = cb.readInt(); + tlv = new NexthopIPv4addressTlv(iValue); + break; + case NexthopIPv6addressTlv.TYPE: + byte[] ipv6Value = new byte[NexthopIPv6addressTlv.VALUE_LENGTH]; + cb.readBytes(ipv6Value, 0, NexthopIPv6addressTlv.VALUE_LENGTH); + tlv = new NexthopIPv6addressTlv(ipv6Value); + break; + case NexthopUnnumberedIPv4IDTlv.TYPE: + tlv = NexthopUnnumberedIPv4IDTlv.read(cb); + break; + default: + throw new PcepParseException("Unsupported TLV type :" + hType); + } + + // Check for the padding + int pad = hLength % 4; + if (0 < pad) { + pad = 4 - pad; + if (pad <= cb.readableBytes()) { + cb.skipBytes(pad); + } + } + + llOutOptionalTlv.add(tlv); + } + + if (0 < cb.readableBytes()) { + + throw new PcepParseException("Optional Tlv parsing error. Extra bytes received."); + } + return llOutOptionalTlv; + } + + /** + * Returns the writer index. + * + * @param cb of channel buffer. + * @return writer index + */ + protected int packOptionalTlv(ChannelBuffer cb) { + + ListIterator listIterator = llOptionalTlv.listIterator(); + + while (listIterator.hasNext()) { + PcepValueType tlv = listIterator.next(); + + if (tlv == null) { + log.debug("tlv is null from OptionalTlv list"); + continue; + } + tlv.write(cb); + } + return cb.writerIndex(); + } + + /** + * Builder class for PCEP label object. + */ + public static class Builder implements PcepLabelObject.Builder { + + private boolean bIsHeaderSet = false; + private boolean bIsOFlagSet = false; + private boolean bIsLabelSet = false; + + private PcepObjectHeader labelObjHeader; + private boolean bOFlag; + private int label; + + LinkedList llOptionalTlv = new LinkedList<>(); + + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + + @Override + public PcepLabelObject build() throws PcepParseException { + PcepObjectHeader labelObjHeader = this.bIsHeaderSet ? this.labelObjHeader : DEFAULT_LABEL_OBJECT_HEADER; + boolean bOFlag = this.bIsOFlagSet ? this.bOFlag : DEFAULT_OFLAG; + + if (!this.bIsLabelSet) { + throw new PcepParseException(" Label NOT Set while building PcepLabelObject."); + } + if (bIsPFlagSet) { + labelObjHeader.setPFlag(bPFlag); + } + if (bIsIFlagSet) { + labelObjHeader.setIFlag(bIFlag); + } + return new PcepLabelObjectVer1(labelObjHeader, bOFlag, this.label, this.llOptionalTlv); + } + + @Override + public PcepObjectHeader getLabelObjHeader() { + return this.labelObjHeader; + } + + @Override + public Builder setLabelObjHeader(PcepObjectHeader obj) { + this.labelObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public boolean getOFlag() { + return this.bOFlag; + } + + @Override + public Builder setOFlag(boolean value) { + this.bOFlag = value; + this.bIsOFlagSet = true; + return this; + } + + @Override + public int getLabel() { + return this.label; + } + + @Override + public Builder setLabel(int value) { + this.label = value; + this.bIsLabelSet = true; + return this; + } + + @Override + public LinkedList getOptionalTlv() { + return this.llOptionalTlv; + } + + @Override + public Builder setOptionalTlv(LinkedList llOptionalTlv) { + this.llOptionalTlv = llOptionalTlv; + return this; + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("OFlag", bOFlag) + .add("label", label) + .add("OptionalTlvList", llOptionalTlv) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeObjectVer1.java new file mode 100644 index 00000000..9e4be911 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeObjectVer1.java @@ -0,0 +1,377 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepLabelRangeObject; +import org.onosproject.pcepio.types.PathSetupTypeTlv; +import org.onosproject.pcepio.types.PcepObjectHeader; +import org.onosproject.pcepio.types.PcepValueType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP label range object. + */ +public class PcepLabelRangeObjectVer1 implements PcepLabelRangeObject { + + /* + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01, section : 7.2 + 0 1 2 3 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | label type | range size | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | label base | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + // Optional TLVs // + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + LABEL-RANGE Object + */ + protected static final Logger log = LoggerFactory.getLogger(PcepLabelRangeObjectVer1.class); + + public static final byte LABEL_RANGE_OBJ_TYPE = 1; + public static final byte LABEL_RANGE_OBJ_CLASS = 60; //to be defined + public static final byte LABEL_RANGE_OBJECT_VERSION = 1; + public static final short LABEL_RANGE_OBJ_MINIMUM_LENGTH = 12; + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; + //P flag and I flag must be set to 0 + static final PcepObjectHeader DEFAULT_LABELRANGE_OBJECT_HEADER = new PcepObjectHeader(LABEL_RANGE_OBJ_CLASS, + LABEL_RANGE_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, + LABEL_RANGE_OBJ_MINIMUM_LENGTH); + + private PcepObjectHeader labelRangeObjHeader; + private byte labelType; + private int rangeSize; + private int labelBase; + //Optional TLV + private LinkedList llOptionalTlv; + + /** + * Constructor to initialize parameters for PCEP label range object. + * + * @param labelRangeObjHeader label range object header + * @param labelType label type + * @param rangeSize range size + * @param labelBase label base + * @param llOptionalTlv list of optional tlvs + */ + public PcepLabelRangeObjectVer1(PcepObjectHeader labelRangeObjHeader, byte labelType, int rangeSize, int labelBase, + LinkedList llOptionalTlv) { + this.labelRangeObjHeader = labelRangeObjHeader; + this.labelType = labelType; + this.rangeSize = rangeSize; + this.llOptionalTlv = llOptionalTlv; + this.labelBase = labelBase; + } + + @Override + public void setLabelRangeObjHeader(PcepObjectHeader obj) { + this.labelRangeObjHeader = obj; + } + + @Override + public void setLabelType(byte labelType) { + this.labelType = labelType; + } + + @Override + public void setRangeSize(int rangeSize) { + this.rangeSize = rangeSize; + } + + @Override + public void setLabelBase(int labelBase) { + this.labelBase = labelBase; + } + + @Override + public PcepObjectHeader getLabelRangeObjHeader() { + return this.labelRangeObjHeader; + } + + @Override + public byte getLabelType() { + return this.labelType; + } + + @Override + public int getRangeSize() { + return this.rangeSize; + } + + @Override + public int getLabelBase() { + return this.labelBase; + } + + /** + * Reads from the channel buffer and returns object of PcepLabelRangeObject. + * + * @param cb of type channel buffer + * @return object of PcepLabelRangeObject + * @throws PcepParseException when fails to read from channel buffer + */ + public static PcepLabelRangeObject read(ChannelBuffer cb) throws PcepParseException { + + PcepObjectHeader labelRangeObjHeader; + byte labelType; + int rangeSize; + int labelBase; + + LinkedList llOptionalTlv = new LinkedList<>(); + + labelRangeObjHeader = PcepObjectHeader.read(cb); + + //take only LabelRangeObject buffer. + ChannelBuffer tempCb = cb.readBytes(labelRangeObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH); + int temp = 0; + temp = tempCb.readInt(); + rangeSize = temp & 0x00FFFFFF; + labelType = (byte) (temp >> 24); + labelBase = tempCb.readInt(); + llOptionalTlv = parseOptionalTlv(tempCb); + return new PcepLabelRangeObjectVer1(labelRangeObjHeader, labelType, rangeSize, labelBase, llOptionalTlv); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + + int objStartIndex = cb.writerIndex(); + + //write common header + int objLenIndex = labelRangeObjHeader.write(cb); + int temp = 0; + temp = labelType; + temp = temp << 24; + temp = temp | rangeSize; + cb.writeInt(temp); + + // Add optional TLV + if (!packOptionalTlv(cb)) { + throw new PcepParseException("Error while writing Optional tlv."); + } + + //now write LabelRange Object Length + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); + return cb.writerIndex() - objStartIndex; + } + + /** + * Returns list of optional tlvs. + * + * @param cb of type channle buffer + * @return list of optional tlvs + * @throws PcepParseException whne fails to parse list of optional tlvs + */ + public static LinkedList parseOptionalTlv(ChannelBuffer cb) throws PcepParseException { + + LinkedList llOutOptionalTlv = new LinkedList<>(); + + while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) { + + PcepValueType tlv; + int iValue; + short hType = cb.readShort(); + short hLength = cb.readShort(); + + switch (hType) { + + case PathSetupTypeTlv.TYPE: + iValue = cb.readInt(); + tlv = new PathSetupTypeTlv(iValue); + break; + + default: + throw new PcepParseException("Unsupported TLV in LabelRange Object."); + } + + // Check for the padding + int pad = hLength % 4; + if (0 < pad) { + pad = 4 - pad; + if (pad <= cb.readableBytes()) { + cb.skipBytes(pad); + } + } + llOutOptionalTlv.add(tlv); + } + return llOutOptionalTlv; + } + + /** + * Pack optional tlvs. + * + * @param cb of channel buffer + * @return true + */ + protected boolean packOptionalTlv(ChannelBuffer cb) { + + ListIterator listIterator = llOptionalTlv.listIterator(); + + while (listIterator.hasNext()) { + PcepValueType tlv = listIterator.next(); + + if (tlv == null) { + log.debug("tlv is null from OptionalTlv list"); + continue; + } + tlv.write(cb); + + // need to take care of padding + int pad = tlv.getLength() % 4; + if (0 != pad) { + pad = 4 - pad; + for (int i = 0; i < pad; ++i) { + cb.writeByte((byte) 0); + } + } + } + return true; + } + + /** + * Builder class for PCEP label range object. + */ + public static class Builder implements PcepLabelRangeObject.Builder { + private boolean bIsHeaderSet = false; + private boolean bIsLabelType = false; + private boolean bIsRangeSize = false; + private boolean bIsLabelBase = false; + + byte labelType; + int rangeSize; + int labelBase; + private boolean bIsPFlagSet = false; + private boolean bPFlag; + + private boolean bIsIFlagSet = false; + private boolean bIFlag; + private PcepObjectHeader labelRangeObjHeader; + + LinkedList llOptionalTlv = new LinkedList<>(); + + @Override + public PcepLabelRangeObject build() throws PcepParseException { + PcepObjectHeader labelRangeObjHeader = this.bIsHeaderSet ? this.labelRangeObjHeader + : DEFAULT_LABELRANGE_OBJECT_HEADER; + + if (!this.bIsLabelType) { + throw new PcepParseException("LabelType NOT Set while building label range object."); + } + + if (!this.bIsRangeSize) { + throw new PcepParseException("RangeSize NOT Set while building label range object."); + } + + if (!this.bIsLabelBase) { + throw new PcepParseException("LabelBase NOT Set while building label range object."); + } + + if (bIsPFlagSet) { + labelRangeObjHeader.setPFlag(bPFlag); + } + + if (bIsIFlagSet) { + labelRangeObjHeader.setIFlag(bIFlag); + } + return new PcepLabelRangeObjectVer1(labelRangeObjHeader, this.labelType, this.rangeSize, this.labelBase, + this.llOptionalTlv); + } + + @Override + public PcepObjectHeader getLabelRangeObjHeader() { + return this.labelRangeObjHeader; + } + + @Override + public Builder setLabelRangeObjHeader(PcepObjectHeader obj) { + this.labelRangeObjHeader = obj; + this.bIsHeaderSet = true; + return this; + } + + @Override + public byte getLabelType() { + return this.labelType; + } + + @Override + public Builder setLabelType(byte labelType) { + this.labelType = labelType; + this.bIsLabelType = true; + return this; + } + + @Override + public int getRangeSize() { + return this.rangeSize; + } + + @Override + public Builder setRangeSize(int rangeSize) { + this.rangeSize = rangeSize; + this.bIsRangeSize = true; + return this; + } + + @Override + public int getLabelBase() { + return this.labelBase; + } + + @Override + public Builder setLabelBase(int labelBase) { + this.labelBase = labelBase; + this.bIsLabelBase = true; + return this; + } + + @Override + public Builder setPFlag(boolean value) { + this.bPFlag = value; + this.bIsPFlagSet = true; + return this; + } + + @Override + public Builder setIFlag(boolean value) { + this.bIFlag = value; + this.bIsIFlagSet = true; + return this; + } + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("LabelType", labelType) + .add("rangeSize", rangeSize) + .add("labelBase", labelBase) + .add("optionalTlvList", llOptionalTlv) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeResvMsgVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeResvMsgVer1.java new file mode 100644 index 00000000..6f3648af --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeResvMsgVer1.java @@ -0,0 +1,198 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepLabelRange; +import org.onosproject.pcepio.protocol.PcepLabelRangeResvMsg; +import org.onosproject.pcepio.protocol.PcepMessageReader; +import org.onosproject.pcepio.protocol.PcepMessageWriter; +import org.onosproject.pcepio.protocol.PcepType; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP label range reserve message. + */ +class PcepLabelRangeResvMsgVer1 implements PcepLabelRangeResvMsg { + + // Pcep version: 1 + + /* + The format of a PCLRResv message is as follows: + + PCLRResv Message>::= + + Where: + + ::= + + + Where + ::=[] + */ + protected static final Logger log = LoggerFactory.getLogger(PcepLabelRangeResvMsgVer1.class); + + public static final byte PACKET_VERSION = 1; + // LabelRangeResvMsgMinLength = COMMON-HEADER(4)+SrpObjMinLentgh(12)+LABEL-RANGE-MIN-LENGTH(12) + public static final int PACKET_MINIMUM_LENGTH = 28; + public static final PcepType MSG_TYPE = PcepType.LABEL_RANGE_RESERV; + // + PcepLabelRange labelRange; + + public static final PcepLabelRangeResvMsgVer1.Reader READER = new Reader(); + + /** + * Reader reads LabelRangeResv Message from the channel. + */ + static class Reader implements PcepMessageReader { + + @Override + public PcepLabelRangeResvMsg readFrom(ChannelBuffer cb) throws PcepParseException { + + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) { + throw new PcepParseException("Channel buffer has less readable bytes than Packet minimum length."); + } + // fixed value property version == 1 + byte version = cb.readByte(); + version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG); + if (version != PACKET_VERSION) { + throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), got=" + version); + } + // fixed value property type == 15 + byte type = cb.readByte(); + if (type != MSG_TYPE.getType()) { + throw new PcepParseException("Wrong type. Expected=PcepType.LABEL_RANGE_RESERV(15), got=" + type); + } + short length = cb.readShort(); + if (length < PACKET_MINIMUM_LENGTH) { + throw new PcepParseException("Wrong length.Expected to be >= " + PACKET_MINIMUM_LENGTH + ", is: " + + length); + } + // parse + PcepLabelRange labelRange = PcepLabelRangeVer1.read(cb); + return new PcepLabelRangeResvMsgVer1(labelRange); + } + } + + /** + * Constructor to initialize PCEP label range. + * + * @param labelRange PCEP label range + */ + PcepLabelRangeResvMsgVer1(PcepLabelRange labelRange) { + this.labelRange = labelRange; + } + + /** + * Builder class for PCEP label range reserve message. + */ + static class Builder implements PcepLabelRangeResvMsg.Builder { + + PcepLabelRange labelRange = new PcepLabelRangeVer1(); + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepType getType() { + return PcepType.LABEL_RANGE_RESERV; + } + + @Override + public PcepLabelRangeResvMsg build() { + return new PcepLabelRangeResvMsgVer1(this.labelRange); + } + + @Override + public PcepLabelRange getLabelRange() { + return this.labelRange; + } + + @Override + public Builder setLabelRange(PcepLabelRange labelRange) { + this.labelRange = labelRange; + return this; + } + } + + @Override + public void writeTo(ChannelBuffer cb) throws PcepParseException { + WRITER.write(cb, this); + } + + static final Writer WRITER = new Writer(); + + /** + * Writer writes LabelRangeResv Message to the channel. + */ + static class Writer implements PcepMessageWriter { + + @Override + public void write(ChannelBuffer cb, PcepLabelRangeResvMsgVer1 message) throws PcepParseException { + + int startIndex = cb.writerIndex(); + // first 3 bits set to version + cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG)); + // message type + cb.writeByte(MSG_TYPE.getType()); + // Length will be set after calculating length, but currently set it as 0. + int msgLenIndex = cb.writerIndex(); + + cb.writeShort((short) 0); + //write Label Range + message.labelRange.write(cb); + + // update message length field + int length = cb.writerIndex() - startIndex; + cb.setShort(msgLenIndex, (short) length); + } + } + + @Override + public PcepVersion getVersion() { + return PcepVersion.PCEP_1; + } + + @Override + public PcepType getType() { + return MSG_TYPE; + } + + @Override + public PcepLabelRange getLabelRange() { + return this.labelRange; + } + + @Override + public void setLabelRange(PcepLabelRange lr) { + this.labelRange = lr; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("labelRange", labelRange) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeVer1.java new file mode 100644 index 00000000..411c9604 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeVer1.java @@ -0,0 +1,168 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepLabelRange; +import org.onosproject.pcepio.protocol.PcepLabelRangeObject; +import org.onosproject.pcepio.protocol.PcepSrpObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP Label Range. + */ +public class PcepLabelRangeVer1 implements PcepLabelRange { + + protected static final Logger log = LoggerFactory.getLogger(PcepLabelRangeVer1.class); + + /* + ::= + + Where + ::=[] + */ + + // PCEP SRP Object + private PcepSrpObject srpObject; + // of type PcepLabelRangeObject. + private LinkedList llLabelRangeList; + + /** + * Default Constructor. + */ + public PcepLabelRangeVer1() { + srpObject = null; + llLabelRangeList = null; + } + + /** + * Constructor to initialize objects. + * + * @param srpObj PCEP Srp object. + * @param llLabelRangeList list of PcepLabelRangeObject. + */ + PcepLabelRangeVer1(PcepSrpObject srpObj, LinkedList llLabelRangeList) { + this.srpObject = srpObj; + this.llLabelRangeList = llLabelRangeList; + } + + @Override + public PcepSrpObject getSrpObject() { + return srpObject; + } + + @Override + public void setSrpObject(PcepSrpObject srpObject) { + this.srpObject = srpObject; + + } + + @Override + public LinkedList getLabelRangeList() { + return llLabelRangeList; + } + + @Override + public void setLabelRangeList(LinkedList ll) { + this.llLabelRangeList = ll; + } + + /** + * Reads channel buffer and returns object of PcepLabelRange. + * + * @param cb of type channel buffer. + * @return object of PcepLabelRange + * @throws PcepParseException when fails to read from channel buffer + */ + public static PcepLabelRange read(ChannelBuffer cb) throws PcepParseException { + + //parse and store SRP mandatory object + PcepSrpObject srpObj = null; + srpObj = PcepSrpObjectVer1.read(cb); + if (srpObj == null) { + throw new PcepParseException("Exception while parsing srp object"); + } + + LinkedList llLabelRangeList = new LinkedList<>(); + boolean bFoundLabelRangeObj = false; + while (0 < cb.readableBytes()) { + //parse and store + PcepLabelRangeObject lrObj; + lrObj = PcepLabelRangeObjectVer1.read(cb); + if (lrObj == null) { + throw new PcepParseException("Exception while parsing label range object"); + } else { + llLabelRangeList.add(lrObj); + bFoundLabelRangeObj = true; + } + } + + if (!bFoundLabelRangeObj) { + throw new PcepParseException("At least one LABEL-RANGE MUST be present."); + } + return new PcepLabelRangeVer1(srpObj, llLabelRangeList); + } + + @Override + public int write(ChannelBuffer cb) throws PcepParseException { + //write Object header + int objStartIndex = cb.writerIndex(); + + //write + int objLenIndex = srpObject.write(cb); + + if (objLenIndex <= 0) { + throw new PcepParseException("bjectLength is " + objLenIndex); + } + + //write + ListIterator listIterator = llLabelRangeList.listIterator(); + while (listIterator.hasNext()) { + listIterator.next().write(cb); + } + + //Update object length now + int length = cb.writerIndex() - objStartIndex; + // As per RFC the length of object should be + // multiples of 4 + int pad = length % 4; + if (pad != 0) { + pad = 4 - pad; + for (int i = 0; i < pad; i++) { + cb.writeByte((byte) 0); + } + length = length + pad; + } + cb.setShort(objLenIndex, (short) length); + return length; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("srpObject", srpObject) + .add("LabelRangeList", llLabelRangeList) + .toString(); + } +} diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateMsgVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateMsgVer1.java new file mode 100644 index 00000000..89347f42 --- /dev/null +++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateMsgVer1.java @@ -0,0 +1,239 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onosproject.pcepio.protocol.ver1; + +import java.util.LinkedList; +import java.util.ListIterator; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.pcepio.exceptions.PcepParseException; +import org.onosproject.pcepio.protocol.PcepLabelUpdate; +import org.onosproject.pcepio.protocol.PcepLabelUpdateMsg; +import org.onosproject.pcepio.protocol.PcepMessageReader; +import org.onosproject.pcepio.protocol.PcepMessageWriter; +import org.onosproject.pcepio.protocol.PcepType; +import org.onosproject.pcepio.protocol.PcepVersion; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides PCEP lable update message. + */ +class PcepLabelUpdateMsgVer1 implements PcepLabelUpdateMsg { + + // Pcep version: 1 + + /* + The format of the PCLabelUpd message: + + ::= + + Where: + + ::= + [] + ::= (|) + + Where: + ::= + + + + ::= +