aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/protocols')
-rw-r--r--framework/src/onos/protocols/netconf/api/pom.xml45
-rw-r--r--framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfController.java84
-rw-r--r--framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDevice.java51
-rw-r--r--framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java173
-rw-r--r--framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceListener.java37
-rw-r--r--framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java129
-rw-r--r--framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/package-info.java20
-rw-r--r--framework/src/onos/protocols/netconf/ctl/pom.xml91
-rw-r--r--framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java143
-rw-r--r--framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceImpl.java66
-rw-r--r--framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java396
-rw-r--r--framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/package-info.java20
-rw-r--r--framework/src/onos/protocols/netconf/pom.xml83
-rw-r--r--framework/src/onos/protocols/netconf/rfc/pom.xml30
-rw-r--r--framework/src/onos/protocols/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/Foo.java7
-rw-r--r--framework/src/onos/protocols/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/package-info.java20
-rw-r--r--framework/src/onos/protocols/openflow/api/pom.xml93
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/DefaultOpenFlowPacketContext.java182
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/Dpid.java132
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionTreatmentInterpreter.java58
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowController.java130
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowEventListener.java33
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowOpticalSwitch.java23
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowPacketContext.java90
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java160
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitchListener.java58
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/PacketListener.java29
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/PortDescPropertyType.java39
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/RoleState.java40
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ThirdPartyMessage.java74
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/WithTypedPorts.java45
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java493
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowAgent.java102
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowSwitchDriver.java221
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowSwitchDriverFactory.java39
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleHandler.java114
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleRecvStatus.java52
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleReplyInfo.java48
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeAlreadyStarted.java29
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeCompleted.java34
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeException.java41
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeNotStarted.java30
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeStateException.java30
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchStateException.java49
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/package-info.java20
-rw-r--r--framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/package-info.java20
-rw-r--r--framework/src/onos/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/OpenflowControllerAdapter.java89
-rw-r--r--framework/src/onos/protocols/openflow/ctl/pom.xml65
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java328
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/HandshakeTimeoutException.java28
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/HandshakeTimeoutHandler.java93
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java1320
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageDecoder.java55
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java59
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java633
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenflowPipelineFactory.java93
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/RoleManager.java406
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/package-info.java20
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java159
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelHandlerContextAdapter.java77
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverAdapter.java104
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverServiceAdapter.java59
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ExecutorServiceAdapter.java99
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfFeaturesReply.java81
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfPacketIn.java84
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfPortStatus.java45
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OFDescStatsReplyAdapter.java97
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OfMessageAdapter.java62
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OpenFlowSwitchListenerAdapter.java77
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OpenflowSwitchDriverAdapter.java302
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/ControllerTest.java219
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java84
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageEncoderTest.java90
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplPacketsTest.java167
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplTest.java283
-rw-r--r--framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/RoleManagerTest.java130
-rw-r--r--framework/src/onos/protocols/openflow/drivers/src/main/java/org/onosproject/openflow/drivers/OFSwitchImplSpringOpenTTPDellOSR.java65
-rw-r--r--framework/src/onos/protocols/openflow/pom.xml86
-rw-r--r--framework/src/onos/protocols/ovsdb/api/pom.xml60
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/DefaultEventSubject.java126
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/EventSubject.java22
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridge.java88
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridgeName.java72
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java301
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbConstant.java68
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbController.java79
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbDatapathId.java69
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEvent.java74
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEventListener.java28
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEventSubject.java75
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbIfaceId.java69
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java83
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeListener.java36
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPort.java86
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortName.java71
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortNumber.java69
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortType.java71
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbRowStore.java69
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbStore.java71
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTableStore.java67
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnel.java126
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnelName.java70
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java1503
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/OvsdbAgent.java42
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/OvsdbProviderService.java81
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java225
-rw-r--r--framework/src/onos/protocols/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbControllerAdapter.java75
-rw-r--r--framework/src/onos/protocols/ovsdb/ctl/pom.xml65
-rw-r--r--framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/ChannelConnectionListener.java43
-rw-r--r--framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/Controller.java299
-rw-r--r--framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/MessageDecoder.java55
-rw-r--r--framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbControllerImpl.java418
-rw-r--r--framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbJsonRpcHandler.java131
-rw-r--r--framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/pom.xml69
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/pom.xml49
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/AbnormalJsonNodeException.java41
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/BridgeCreateException.java53
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/ColumnSchemaNotFoundException.java55
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/TableSchemaNotFoundException.java56
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/UnsupportedException.java41
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/VersionMismatchException.java66
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/Callback.java50
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonReadContext.java86
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonRpcRequest.java111
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonRpcResponse.java122
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/OvsdbRPC.java74
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/MonitorRequest.java101
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/MonitorSelect.java106
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/OperationResult.java158
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/RowUpdate.java97
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdate.java107
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdates.java89
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/UpdateNotification.java90
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Column.java81
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Condition.java123
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Mutation.java124
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbMap.java83
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbSet.java85
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/RefTableRow.java84
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Row.java159
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/UUID.java84
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/ConditionSerializer.java41
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/MutationSerializer.java41
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/OvsdbMapSerializer.java49
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/OvsdbSetSerializer.java46
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UUIDConverter.java32
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UUIDSerializer.java43
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UpdateNotificationConverter.java46
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Abort.java43
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Assert.java57
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Comment.java57
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Commit.java57
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Delete.java77
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Insert.java110
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Mutate.java91
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Operation.java60
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Select.java89
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Update.java111
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/ColumnSchema.java83
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/DatabaseSchema.java135
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/TableSchema.java129
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/AtomicColumnType.java104
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseType.java24
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseTypeFactory.java214
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BooleanBaseType.java33
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnType.java24
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnTypeFactory.java123
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/IntegerBaseType.java103
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/KeyValuedColumnType.java108
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/RealBaseType.java103
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/StringBaseType.java103
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/UuidBaseType.java110
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Bridge.java560
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Controller.java556
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/FlowSampleCollectorSet.java151
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/FlowTable.java196
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Interface.java1024
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Ipfix.java220
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Manager.java243
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Mirror.java277
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Netflow.java197
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OpenVSwitch.java466
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OvsdbTable.java41
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Port.java590
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Qos.java149
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Queue.java126
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Sflow.java193
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Ssl.java172
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/TableGenerator.java103
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/VersionNum.java47
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/AbstractOvsdbTableService.java284
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/ColumnDescription.java117
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/OvsdbTableService.java70
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/TableDescription.java108
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/package-info.java20
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ConditionUtil.java122
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/FromJsonUtil.java319
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/JsonRpcReaderUtil.java165
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/JsonRpcWriterUtil.java114
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/MutationUtil.java107
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ObjectMapperUtil.java98
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ParamUtil.java86
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/StringEncoderUtil.java42
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/TransValueUtil.java172
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/VersionUtil.java69
-rw-r--r--framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/package-info.java20
-rw-r--r--framework/src/onos/protocols/pcep/api/pom.xml99
-rwxr-xr-xframework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PccId.java120
-rwxr-xr-xframework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClient.java110
-rw-r--r--framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientController.java93
-rwxr-xr-xframework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepClientListener.java36
-rw-r--r--framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepEventListener.java31
-rw-r--r--framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/PcepPacketStats.java50
-rwxr-xr-xframework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepAgent.java63
-rwxr-xr-xframework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepClientDriver.java110
-rwxr-xr-xframework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepClientDriverFactory.java38
-rw-r--r--framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/package-info.java20
-rw-r--r--framework/src/onos/protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/package-info.java20
-rw-r--r--framework/src/onos/protocols/pcep/ctl/pom.xml65
-rw-r--r--framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/Controller.java188
-rw-r--r--framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepChannelHandler.java652
-rw-r--r--framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java222
-rw-r--r--framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java220
-rw-r--r--framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepMessageDecoder.java68
-rw-r--r--framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepMessageEncoder.java58
-rw-r--r--framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepPacketStatsImpl.java105
-rw-r--r--framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepPipelineFactory.java66
-rw-r--r--framework/src/onos/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/package-info.java20
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/pom.xml77
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepParseException.java92
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/PcepTunnelAttributeException.java60
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/exceptions/package-info.java20
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcInitiatedLspRequest.java185
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepAttribute.java166
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepBandwidthObject.java109
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepCloseMsg.java143
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEndPointsObject.java139
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepEroObject.java112
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepError.java136
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorInfo.java93
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorMsg.java109
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepErrorObject.java169
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactories.java98
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactory.java255
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObject.java49
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4.java104
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4Adjacency.java133
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv4UnnumberedAdjacency.java191
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6.java104
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFecObjectIPv6Adjacency.java133
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInitiateMsg.java81
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepInterLayerObject.java137
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepIroObject.java110
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsg.java49
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelObject.java171
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRange.java65
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeObject.java182
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelRangeResvMsg.java79
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdate.java108
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsg.java81
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspObject.java286
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepLspaObject.java286
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessage.java67
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageReader.java36
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMessageWriter.java35
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMetricObject.java225
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepMsgPath.java117
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepNai.java40
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepObject.java30
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenMsg.java73
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepOpenObject.java221
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRPObject.java256
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepReportMsg.java81
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepRroObject.java111
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepSrpObject.java171
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepStateReport.java207
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepTEObject.java241
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepTEReportMsg.java81
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepType.java49
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateMsg.java81
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepUpdateRequest.java126
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepVersion.java46
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/Writeable.java35
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/package-info.java20
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcInitiatedLspRequestVer1.java291
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepAttributeVer1.java431
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepBandwidthObjectVer1.java233
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepCloseMsgVer1.java351
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEndPointsObjectVer1.java256
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepEroObjectVer1.java407
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorInfoVer1.java204
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorMsgVer1.java383
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorObjectVer1.java341
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepErrorVer1.java399
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFactoryVer1.java226
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4AdjacencyVer1.java253
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4UnnumberedAdjacencyVer1.java334
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv4Ver1.java217
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6AdjacencyVer1.java249
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepFecObjectIPv6Ver1.java220
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInitiateMsgVer1.java332
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepInterLayerObjectVer1.java263
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepIroObjectVer1.java299
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepKeepaliveMsgVer1.java154
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java370
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeObjectVer1.java377
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeResvMsgVer1.java198
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelRangeVer1.java168
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateMsgVer1.java239
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateVer1.java356
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java575
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspaObjectVer1.java529
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMessageVer1.java132
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMetricObjectVer1.java376
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java187
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenMsgVer1.java204
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java491
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRPObjectVer1.java445
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java309
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRroObjectVer1.java345
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java392
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepStateReportVer1.java421
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepTEObjectVer1.java506
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepTEReportMsgVer1.java225
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateMsgVer1.java300
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateRequestVer1.java199
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/package-info.java20
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java160
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java138
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java150
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java180
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java181
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java179
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java222
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java179
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.java171
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java155
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.java171
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java155
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java155
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java142
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlv.java246
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java200
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java143
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java190
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java163
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java233
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.java154
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java135
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java155
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.java154
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java159
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java164
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java194
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java83
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java105
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java103
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java107
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java99
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java113
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java102
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java131
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java224
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java46
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java160
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java165
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java161
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java156
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java220
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java55
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlv.java250
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.java154
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java147
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java167
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java324
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java210
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java142
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java142
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java269
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java216
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java159
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java292
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTlv.java251
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java250
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java181
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java20
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java56
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/package-info.java20
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java56
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java735
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java1683
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java1331
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java59
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java402
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java558
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java218
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java1597
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepTEReportMsgTest.java1596
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java1269
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java1423
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupTlvTest.java36
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemTlvTest.java36
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BGPLSidentifierTlvTest.java36
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java36
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IGPMetricTlvTest.java38
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlvTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlvTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlvTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlvTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlvTest.java42
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlvTest.java42
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java39
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlvTest.java42
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlvTest.java42
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlvTest.java40
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlvTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameTlvTest.java39
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeTlvTest.java39
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlvTest.java50
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlvTest.java39
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlvTest.java39
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlvTest.java39
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java41
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsTlvTest.java39
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameTlvTest.java39
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OSPFareaIDsubTlvTest.java36
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlvTest.java39
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java34
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java39
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java36
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java34
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java37
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java43
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.java49
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlvTest.java52
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RouterIDSubTlvTest.java42
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java35
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlvTest.java41
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java59
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java55
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java35
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java31
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java34
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java43
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricTlvTest.java34
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkAttributesTlvTest.java54
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkDescriptorsTlvTest.java52
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TENodeAttributesTlvTest.java54
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TedCapabilityTlvTest.java34
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthTlvTest.java36
-rwxr-xr-xframework/src/onos/protocols/pcep/pom.xml60
-rw-r--r--framework/src/onos/protocols/pom.xml60
481 files changed, 73819 insertions, 0 deletions
diff --git a/framework/src/onos/protocols/netconf/api/pom.xml b/framework/src/onos/protocols/netconf/api/pom.xml
new file mode 100644
index 00000000..ed8a5302
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/api/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+ ~ 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.
+ -->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-netconf</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>onos-netconf-api</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS NETCONF plugin API</description>
+ <dependencies>
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-transport</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-transport-native-epoll</artifactId>
+ <version>${netty4.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfController.java b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfController.java
new file mode 100644
index 00000000..6411c011
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfController.java
@@ -0,0 +1,84 @@
+/*
+ * 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.netconf;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.DeviceId;
+
+import java.util.Map;
+
+/**
+ * Abstraction of an NETCONF controller. Serves as a one stop shop for obtaining
+ * NetconfDevice and (un)register listeners on NETCONF device events.
+ */
+public interface NetconfController {
+
+ /**
+ * Adds Device Event Listener.
+ *
+ * @param listener node listener
+ */
+ void addDeviceListener(NetconfDeviceListener listener);
+
+ /**
+ * Removes Device Listener.
+ *
+ * @param listener node listener
+ */
+ void removeDeviceListener(NetconfDeviceListener listener);
+
+ /**
+ * Tries to connect to a specific NETCONF device, if the connection is succesful
+ * it creates and adds the device to the ONOS core as a NetconfDevice.
+ *
+ * @param deviceInfo info about the device to add
+ * @return NetconfDevice Netconf device
+ */
+ NetconfDevice connectDevice(NetconfDeviceInfo deviceInfo);
+
+ /**
+ * Removes a Netconf device.
+ *
+ * @param deviceInfo info about the device to remove
+ */
+ void removeDevice(NetconfDeviceInfo deviceInfo);
+
+ /**
+ * Gets all the nodes information.
+ *
+ * @return map of devices
+ */
+ Map<DeviceId, NetconfDevice> getDevicesMap();
+
+ /**
+ * Gets a Netconf Device by node identifier.
+ *
+ * @param deviceInfo node identifier
+ * @return NetconfDevice Netconf device
+ */
+ NetconfDevice getNetconfDevice(DeviceId deviceInfo);
+
+ /**
+ * Gets a Netconf Device by node identifier.
+ *
+ * @param ip device ip
+ * @param port device port
+ * @return NetconfDevice Netconf device
+ */
+ NetconfDevice getNetconfDevice(IpAddress ip, int port);
+
+}
diff --git a/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDevice.java b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDevice.java
new file mode 100644
index 00000000..1974782b
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDevice.java
@@ -0,0 +1,51 @@
+/*
+ * 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.netconf;
+
+/**
+ * Interface representing a NETCONF device.
+ */
+public interface NetconfDevice {
+
+
+ /**
+ * Returns whether a device is a NETCONF device with a capabilities list
+ * and is accessible.
+ *
+ * @return true if device is accessible, false otherwise
+ */
+ boolean isActive();
+
+ /**
+ * Returns a NETCONF session context for this device.
+ *
+ * @return netconf session
+ */
+ NetconfSession getSession();
+
+ /**
+ * Ensures that all sessions are closed.
+ * A device cannot be used after disconnect is called.
+ */
+ void disconnect();
+
+ /**
+ * return all the info associated with this device.
+ * @return NetconfDeviceInfo
+ */
+ NetconfDeviceInfo getDeviceInfo();
+} \ No newline at end of file
diff --git a/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
new file mode 100644
index 00000000..cb0e240a
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceInfo.java
@@ -0,0 +1,173 @@
+/*
+ * 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.netconf;
+
+import com.google.common.base.Preconditions;
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.DeviceId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Objects;
+
+/**
+ * Represents a Netconf device information.
+ */
+public class NetconfDeviceInfo {
+
+ public static final Logger log = LoggerFactory
+ .getLogger(NetconfDeviceInfo.class);
+
+ private String name;
+ private String password;
+ private IpAddress ipAddress;
+ private int port;
+ private File keyFile;
+
+
+ /**
+ * Information for contacting the controller.
+ *
+ * @param name the connection type
+ * @param password the password for the device
+ * @param ipAddress the ip address
+ * @param port the tcp port
+ */
+ public NetconfDeviceInfo(String name, String password, IpAddress ipAddress,
+ int port) {
+ Preconditions.checkArgument(!name.equals(""), "Empty device name");
+ Preconditions.checkNotNull(port > 0, "Negative port");
+ Preconditions.checkNotNull(ipAddress, "Null ip address");
+ this.name = name;
+ this.password = password;
+ this.ipAddress = ipAddress;
+ this.port = port;
+ }
+
+ /**
+ * Information for contacting the controller.
+ *
+ * @param name the connection type
+ * @param password the password for the device
+ * @param ipAddress the ip address
+ * @param port the tcp port
+ * @param keyString the string cointaing the key.
+ */
+ public NetconfDeviceInfo(String name, String password, IpAddress ipAddress,
+ int port, String keyString) {
+ Preconditions.checkArgument(!name.equals(""), "Empty device name");
+ Preconditions.checkNotNull(port > 0, "Negative port");
+ Preconditions.checkNotNull(ipAddress, "Null ip address");
+ this.name = name;
+ this.password = password;
+ this.ipAddress = ipAddress;
+ this.port = port;
+ this.keyFile = new File(keyString);
+ }
+
+ /**
+ * Exposes the name of the controller.
+ *
+ * @return String name
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * Exposes the password of the controller.
+ *
+ * @return String password
+ */
+ public String password() {
+ return password;
+ }
+
+ /**
+ * Exposes the ip address of the controller.
+ *
+ * @return IpAddress ip address
+ */
+ public IpAddress ip() {
+ return ipAddress;
+ }
+
+ /**
+ * Exposes the port of the controller.
+ *
+ * @return int port address
+ */
+ public int port() {
+ return port;
+ }
+
+ /**
+ * Exposes the keyFile of the controller.
+ *
+ * @return int port address
+ */
+ public File getKeyFile() {
+ return keyFile;
+ }
+
+ /**
+ * Return the info about the device in a string.
+ * String format: "netconf:name@ip:port"
+ *
+ * @return String device info
+ */
+ public String toString() {
+ return "netconf:" + name + "@" + ipAddress + ":" + port;
+ }
+
+ /**
+ * Return the DeviceId about the device containing the URI.
+ *
+ * @return DeviceId
+ */
+ public DeviceId getDeviceId() {
+
+ try {
+ return DeviceId.deviceId(new URI(this.toString()));
+ } catch (URISyntaxException e) {
+ log.debug("Unable to build deviceID for device {} ", this, e);
+ }
+ return null;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ipAddress, port, name);
+ }
+
+ @Override
+ public boolean equals(Object toBeCompared) {
+ if (toBeCompared instanceof NetconfDeviceInfo) {
+ NetconfDeviceInfo netconfDeviceInfo = (NetconfDeviceInfo) toBeCompared;
+ if (netconfDeviceInfo.name().equals(name)
+ && netconfDeviceInfo.ip().equals(ipAddress)
+ && netconfDeviceInfo.port() == port
+ && netconfDeviceInfo.password().equals(password)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceListener.java b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceListener.java
new file mode 100644
index 00000000..9c46d4f6
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfDeviceListener.java
@@ -0,0 +1,37 @@
+/*
+ * 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.netconf;
+
+/**
+ * Allows for providers interested in node events to be notified.
+ */
+public interface NetconfDeviceListener {
+
+ /**
+ * Notifies that the node was added.
+ *
+ * @param nodeId the node where the event occurred
+ */
+ void deviceAdded(NetconfDeviceInfo nodeId);
+
+ /**
+ * Notifies that the node was removed.
+ *
+ * @param nodeId the node where the event occurred
+ */
+ void deviceRemoved(NetconfDeviceInfo nodeId);
+}
diff --git a/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
new file mode 100644
index 00000000..73c435f6
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/NetconfSession.java
@@ -0,0 +1,129 @@
+/*
+ * 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.netconf;
+
+import java.util.List;
+
+/**
+ * NETCONF session object that allows NETCONF operations on top with the physical
+ * device on top of an SSH connection.
+ */
+// TODO change return type of methdos to <Capability, XMLdoc, string or yang obj>
+public interface NetconfSession {
+
+ /**
+ * Retrives the requested configuration, different from get-config.
+ * @param request the XML containing the request to the server.
+ * @return device running configuration
+ */
+ String get(String request);
+
+ /**
+ * Executes an RPC to the server.
+ * @param request the XML containing the RPC for the server.
+ * @return Server response or ERROR
+ */
+ String doRPC(String request);
+
+ /**
+ * Retrives the specified configuration.
+ *
+ * @param targetConfiguration the type of configuration to retrieve.
+ * @return specified configuration.
+ */
+ String getConfig(String targetConfiguration);
+
+ /**
+ * Retrives part of the specivied configuration based on the filterSchema.
+ *
+ * @param targetConfiguration the type of configuration to retrieve.
+ * @param configurationFilterSchema XML schema to filter the configuration
+ * elements we are interested in
+ * @return device running configuration.
+ */
+ String getConfig(String targetConfiguration, String configurationFilterSchema);
+
+ /**
+ * Retrives part of the specified configuration based on the filterSchema.
+ *
+ * @param newConfiguration configuration to set
+ * @return true if the configuration was edited correctly
+ */
+
+ boolean editConfig(String newConfiguration);
+
+ /**
+ * Copies the new configuration, an Url or a complete configuration xml tree
+ * to the target configuration.
+ * The target configuration can't be the running one
+ *
+ * @param targetConfiguration the type of configuration to retrieve.
+ * @param newConfiguration configuration to set
+ * @return true if the configuration was copied correctly
+ */
+ boolean copyConfig(String targetConfiguration, String newConfiguration);
+
+ /**
+ * Deletes part of the specified configuration based on the filterSchema.
+ *
+ * @param targetConfiguration the name of the configuration to delete
+ * @return true if the configuration was copied correctly
+ */
+ boolean deleteConfig(String targetConfiguration);
+
+ /**
+ * Locks the candidate configuration.
+ *
+ * @return true if successful.
+ */
+ boolean lock();
+
+ /**
+ * Unlocks the candidate configuration.
+ *
+ * @return true if successful.
+ */
+ boolean unlock();
+
+ /**
+ * Closes the Netconf session with the device.
+ * the first time it tries gracefully, then kills it forcefully
+ * @return true if closed
+ */
+ boolean close();
+
+ /**
+ * Gets the session ID of the Netconf session.
+ *
+ * @return Session ID as a string.
+ */
+ String getSessionId();
+
+ /**
+ * Gets the capabilities of the Netconf server associated to this session.
+ *
+ * @return Network capabilities as a string.
+ */
+ String getServerCapabilities();
+
+ /**
+ * Sets the device capabilities.
+ * @param capabilities list of capabilities the device has.
+ */
+ void setDeviceCapabilities(List<String> capabilities);
+
+}
diff --git a/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/package-info.java b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/package-info.java
new file mode 100644
index 00000000..5562bd33
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/api/src/main/java/org/onosproject/netconf/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.
+ */
+
+/**
+ * Created by ray on 10/30/15.
+ */
+package org.onosproject.netconf;
diff --git a/framework/src/onos/protocols/netconf/ctl/pom.xml b/framework/src/onos/protocols/netconf/ctl/pom.xml
new file mode 100644
index 00000000..e022acba
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/ctl/pom.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-netconf</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-netconf-ctl</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-netconf-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ch.ethz.ganymed</groupId>
+ <artifactId>ganymed-ssh2</artifactId>
+ <version>262</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!--plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <filters>
+ <filter>
+ <artifact>ch.ethz.ganymed:ganymed-ssh2</artifact>
+ <includes>
+ <include>ch/ethz/ssh2/**</include>
+ </includes>
+ </filter>
+ <filter>
+ <artifact>org.jdom:jdom2</artifact>
+ <includes>
+ <include>org/jdom2/**</include>
+ </includes>
+ </filter>
+ </filters>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin-->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Private-Package>ch.ethz.ssh2.*</Private-Package>
+ <Embed-Dependecy>ganymed-ssh2</Embed-Dependecy>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java b/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.java
new file mode 100644
index 00000000..a572a2bc
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfControllerImpl.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.netconf.ctl;
+
+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.onlab.packet.IpAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.netconf.NetconfController;
+import org.onosproject.netconf.NetconfDevice;
+import org.onosproject.netconf.NetconfDeviceInfo;
+import org.onosproject.netconf.NetconfDeviceListener;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+
+/**
+ * The implementation of NetconfController.
+ */
+@Component(immediate = true)
+@Service
+public class NetconfControllerImpl implements NetconfController {
+
+ public static final Logger log = LoggerFactory
+ .getLogger(NetconfControllerImpl.class);
+
+ public Map<DeviceId, NetconfDevice> netconfDeviceMap = new ConcurrentHashMap<>();
+
+ protected Set<NetconfDeviceListener> netconfDeviceListeners = new CopyOnWriteArraySet<>();
+
+ @Activate
+ public void activate(ComponentContext context) {
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ netconfDeviceMap.clear();
+ log.info("Stopped");
+ }
+
+ @Override
+ public void addDeviceListener(NetconfDeviceListener listener) {
+ if (!netconfDeviceListeners.contains(listener)) {
+ netconfDeviceListeners.add(listener);
+ }
+ }
+
+ @Override
+ public void removeDeviceListener(NetconfDeviceListener listener) {
+ netconfDeviceListeners.remove(listener);
+ }
+
+ @Override
+ public NetconfDevice getNetconfDevice(DeviceId deviceInfo) {
+ return netconfDeviceMap.get(deviceInfo);
+ }
+
+ @Override
+ public NetconfDevice getNetconfDevice(IpAddress ip, int port) {
+ NetconfDevice device = null;
+ for (DeviceId info : netconfDeviceMap.keySet()) {
+ if (IpAddress.valueOf(info.uri().getHost()).equals(ip) &&
+ info.uri().getPort() == port) {
+ return netconfDeviceMap.get(info);
+ }
+ }
+ return device;
+ }
+
+ @Override
+ public NetconfDevice connectDevice(NetconfDeviceInfo deviceInfo) {
+ if (netconfDeviceMap.containsKey(deviceInfo.getDeviceId())) {
+ log.warn("Device {} is already present");
+ return netconfDeviceMap.get(deviceInfo.getDeviceId());
+ } else {
+ log.info("Creating NETCONF device {}", deviceInfo);
+ return createDevice(deviceInfo);
+ }
+ }
+
+ @Override
+ public void removeDevice(NetconfDeviceInfo deviceInfo) {
+ if (netconfDeviceMap.containsKey(deviceInfo.getDeviceId())) {
+ log.warn("Device {} is not present");
+ } else {
+ stopDevice(deviceInfo);
+ }
+ }
+
+ private NetconfDevice createDevice(NetconfDeviceInfo deviceInfo) {
+ NetconfDevice netconfDevice = null;
+ try {
+ netconfDevice = new NetconfDeviceImpl(deviceInfo);
+ for (NetconfDeviceListener l : netconfDeviceListeners) {
+ l.deviceAdded(deviceInfo);
+ }
+ netconfDeviceMap.put(deviceInfo.getDeviceId(), netconfDevice);
+ } catch (IOException e) {
+ throw new IllegalStateException("Cannot create NETCONF device " +
+ "with device Info: " +
+ deviceInfo + " \n" + e);
+ }
+ return netconfDevice;
+ }
+
+ private void stopDevice(NetconfDeviceInfo deviceInfo) {
+ netconfDeviceMap.get(deviceInfo.getDeviceId()).disconnect();
+ netconfDeviceMap.remove(deviceInfo.getDeviceId());
+ for (NetconfDeviceListener l : netconfDeviceListeners) {
+ l.deviceRemoved(deviceInfo);
+ }
+ }
+
+ @Override
+ public Map<DeviceId, NetconfDevice> getDevicesMap() {
+ return netconfDeviceMap;
+ }
+
+
+}
diff --git a/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceImpl.java b/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceImpl.java
new file mode 100644
index 00000000..3141aafc
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfDeviceImpl.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.netconf.ctl;
+
+import org.onosproject.netconf.NetconfDevice;
+import org.onosproject.netconf.NetconfDeviceInfo;
+import org.onosproject.netconf.NetconfSession;
+
+import java.io.IOException;
+
+/**
+ * Implementation of a NETCONF device.
+ */
+public class NetconfDeviceImpl implements NetconfDevice {
+
+ private NetconfDeviceInfo netconfDeviceInfo;
+ private boolean deviceState = false;
+ private NetconfSession netconfSession;
+ //private String config;
+
+ public NetconfDeviceImpl(NetconfDeviceInfo deviceInfo) throws IOException {
+ netconfDeviceInfo = deviceInfo;
+ try {
+ netconfSession = new NetconfSessionImpl(netconfDeviceInfo);
+ } catch (IOException e) {
+ throw new IOException("Cannot create connection and session", e);
+ }
+ deviceState = true;
+ //config = netconfSession.getConfig("running");
+ }
+
+ @Override
+ public boolean isActive() {
+ return deviceState;
+ }
+
+ @Override
+ public NetconfSession getSession() {
+ return netconfSession;
+ }
+
+ @Override
+ public void disconnect() {
+ deviceState = false;
+ netconfSession.close();
+ }
+
+ @Override
+ public NetconfDeviceInfo getDeviceInfo() {
+ return netconfDeviceInfo;
+ }
+}
diff --git a/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java b/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
new file mode 100644
index 00000000..8619abc0
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/NetconfSessionImpl.java
@@ -0,0 +1,396 @@
+/*
+ * 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.netconf.ctl;
+
+import ch.ethz.ssh2.Connection;
+import ch.ethz.ssh2.Session;
+import com.google.common.base.Preconditions;
+import org.onosproject.netconf.NetconfDeviceInfo;
+import org.onosproject.netconf.NetconfSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Implementation of a NETCONF session to talk to a device.
+ */
+public class NetconfSessionImpl implements NetconfSession {
+
+ public static final Logger log = LoggerFactory
+ .getLogger(NetconfSessionImpl.class);
+ private static final int CONNECTION_TIMEOUT = 0;
+
+
+ private Connection netconfConnection;
+ private NetconfDeviceInfo deviceInfo;
+ private Session sshSession;
+ private boolean connectionActive;
+ private BufferedReader bufferReader = null;
+ private PrintWriter out = null;
+ private int messageID = 0;
+
+ private List<String> deviceCapabilities =
+ new ArrayList<>(
+ Arrays.asList("urn:ietf:params:netconf:base:1.0"));
+
+ private String serverCapabilities;
+ private String endpattern = "]]>]]>";
+
+
+ public NetconfSessionImpl(NetconfDeviceInfo deviceInfo) throws IOException {
+ this.deviceInfo = deviceInfo;
+ connectionActive = false;
+ startConnection();
+ }
+
+
+ private void startConnection() throws IOException {
+ if (!connectionActive) {
+ netconfConnection = new Connection(deviceInfo.ip().toString(), deviceInfo.port());
+ netconfConnection.connect(null, CONNECTION_TIMEOUT, 0);
+ boolean isAuthenticated;
+ try {
+ if (deviceInfo.getKeyFile() != null) {
+ isAuthenticated = netconfConnection.authenticateWithPublicKey(
+ deviceInfo.name(), deviceInfo.getKeyFile(),
+ deviceInfo.password());
+ } else {
+ log.info("authenticate with username {} and password {}",
+ deviceInfo.name(), deviceInfo.password());
+ isAuthenticated = netconfConnection.authenticateWithPassword(
+ deviceInfo.name(), deviceInfo.password());
+ }
+ } catch (IOException e) {
+ throw new IOException("Authentication connection failed:" +
+ e.getMessage());
+ }
+
+ connectionActive = true;
+ Preconditions.checkArgument(isAuthenticated,
+ "Authentication password and username failed");
+ startSshSession();
+ }
+ }
+
+ private void startSshSession() throws IOException {
+ try {
+ sshSession = netconfConnection.openSession();
+ sshSession.startSubSystem("netconf");
+ bufferReader = new BufferedReader(new InputStreamReader(
+ sshSession.getStdout()));
+ out = new PrintWriter(sshSession.getStdin());
+ sendHello();
+ } catch (IOException e) {
+ throw new IOException("Failed to create ch.ethz.ssh2.Session session:" +
+ e.getMessage());
+ }
+ }
+
+ private void sendHello() throws IOException {
+ serverCapabilities = doRequest(createHelloString());
+ }
+
+ private String createHelloString() {
+ StringBuilder hellobuffer = new StringBuilder();
+ hellobuffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ hellobuffer.append("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
+ hellobuffer.append(" <capabilities>\n");
+ deviceCapabilities.forEach(
+ cap -> hellobuffer.append(" <capability>" + cap + "</capability>\n"));
+ hellobuffer.append(" </capabilities>\n");
+ hellobuffer.append("</hello>\n");
+ hellobuffer.append(endpattern);
+ return hellobuffer.toString();
+
+ }
+
+ @Override
+ public String doRPC(String request) {
+ String reply = "ERROR";
+ try {
+ reply = doRequest(request);
+ if (checkReply(reply)) {
+ return reply;
+ } else {
+ return "ERROR " + reply;
+ }
+ } catch (IOException e) {
+ log.error("Problem in the reading from the SSH connection " + e);
+ }
+ return reply;
+ }
+
+ private String doRequest(String request) throws IOException {
+ log.info("sshState " + sshSession.getState() + "request" + request);
+ if (sshSession.getState() != 2) {
+ try {
+ startSshSession();
+ } catch (IOException e) {
+ log.info("the connection had to be reopened");
+ startConnection();
+ }
+ sendHello();
+ }
+ log.info("sshState after" + sshSession.getState());
+ out.print(request);
+ out.flush();
+ messageID++;
+ return readOne();
+ }
+
+ @Override
+ public String get(String request) {
+ return doRPC(request);
+ }
+
+ @Override
+ public String getConfig(String targetConfiguration) {
+ return getConfig(targetConfiguration, null);
+ }
+
+ @Override
+ public String getConfig(String targetConfiguration, String configurationSchema) {
+ StringBuilder rpc = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ rpc.append("<rpc message-id=\"" + messageID + "\" "
+ + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n");
+ rpc.append("<get-config>\n");
+ rpc.append("<source>\n");
+ rpc.append("<" + targetConfiguration + "/>");
+ rpc.append("</source>");
+ if (configurationSchema != null) {
+ rpc.append("<filter type=\"subtree\">\n");
+ rpc.append(configurationSchema + "\n");
+ rpc.append("</filter>\n");
+ }
+ rpc.append("</get-config>\n");
+ rpc.append("</rpc>\n");
+ rpc.append(endpattern);
+ String reply = null;
+ try {
+ reply = doRequest(rpc.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return checkReply(reply) ? reply : null;
+ }
+
+ @Override
+ public boolean editConfig(String newConfiguration) {
+ newConfiguration = newConfiguration + endpattern;
+ String reply = null;
+ try {
+ reply = doRequest(newConfiguration);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return checkReply(reply);
+ }
+
+ @Override
+ public boolean copyConfig(String targetConfiguration, String newConfiguration) {
+ newConfiguration = newConfiguration.trim();
+ if (!newConfiguration.startsWith("<configuration>")) {
+ newConfiguration = "<configuration>" + newConfiguration
+ + "</configuration>";
+ }
+ StringBuilder rpc = new StringBuilder("<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\"?>");
+ rpc.append("<rpc>");
+ rpc.append("<copy-config>");
+ rpc.append("<target>");
+ rpc.append("<" + targetConfiguration + "/>");
+ rpc.append("</target>");
+ rpc.append("<source>");
+ rpc.append("<" + newConfiguration + "/>");
+ rpc.append("</source>");
+ rpc.append("</copy-config>");
+ rpc.append("</rpc>");
+ rpc.append(endpattern);
+ String reply = null;
+ try {
+ reply = doRequest(rpc.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return checkReply(reply);
+ }
+
+ @Override
+ public boolean deleteConfig(String targetConfiguration) {
+ if (targetConfiguration.equals("running")) {
+ log.warn("Target configuration for delete operation can't be \"running\"",
+ targetConfiguration);
+ return false;
+ }
+ StringBuilder rpc = new StringBuilder("<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\"?>");
+ rpc.append("<rpc>");
+ rpc.append("<delete-config>");
+ rpc.append("<target>");
+ rpc.append("<" + targetConfiguration + "/>");
+ rpc.append("</target>");
+ rpc.append("</delete-config>");
+ rpc.append("</rpc>");
+ rpc.append(endpattern);
+ String reply = null;
+ try {
+ reply = doRequest(rpc.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return checkReply(reply);
+ }
+
+ @Override
+ public boolean lock() {
+ StringBuilder rpc = new StringBuilder("<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\"?>");
+ rpc.append("<rpc>");
+ rpc.append("<lock>");
+ rpc.append("<target>");
+ rpc.append("<candidate/>");
+ rpc.append("</target>");
+ rpc.append("</lock>");
+ rpc.append("</rpc>");
+ rpc.append(endpattern);
+ String reply = null;
+ try {
+ reply = doRequest(rpc.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return checkReply(reply);
+ }
+
+ @Override
+ public boolean unlock() {
+ StringBuilder rpc = new StringBuilder("<?xml version=\"1.0\" " +
+ "encoding=\"UTF-8\"?>");
+ rpc.append("<rpc>");
+ rpc.append("<unlock>");
+ rpc.append("<target>");
+ rpc.append("<candidate/>");
+ rpc.append("</target>");
+ rpc.append("</unlock>");
+ rpc.append("</rpc>");
+ rpc.append(endpattern);
+ String reply = null;
+ try {
+ reply = doRequest(rpc.toString());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return checkReply(reply);
+ }
+
+ @Override
+ public boolean close() {
+ return close(false);
+ }
+
+ private boolean close(boolean force) {
+ StringBuilder rpc = new StringBuilder();
+ rpc.append("<rpc>");
+ if (force) {
+ rpc.append("<kill-configuration/>");
+ } else {
+ rpc.append("<close-configuration/>");
+ }
+ rpc.append("<close-configuration/>");
+ rpc.append("</rpc>");
+ rpc.append(endpattern);
+ return checkReply(rpc.toString()) ? true : close(true);
+ }
+
+ @Override
+ public String getSessionId() {
+ if (serverCapabilities.contains("<session-id>")) {
+ String[] outer = serverCapabilities.split("<session-id>");
+ Preconditions.checkArgument(outer.length != 1,
+ "Error in retrieving the session id");
+ String[] value = outer[1].split("</session-id>");
+ Preconditions.checkArgument(value.length != 1,
+ "Error in retrieving the session id");
+ return value[0];
+ } else {
+ return String.valueOf(-1);
+ }
+ }
+
+ @Override
+ public String getServerCapabilities() {
+ return serverCapabilities;
+ }
+
+ @Override
+ public void setDeviceCapabilities(List<String> capabilities) {
+ deviceCapabilities = capabilities;
+ }
+
+ private boolean checkReply(String reply) {
+ if (reply != null) {
+ if (!reply.contains("<rpc-error>")) {
+ return true;
+ } else if (reply.contains("<ok/>")
+ || (reply.contains("<rpc-error>")
+ && reply.contains("warning"))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private String readOne() throws IOException {
+ //TODO try a simple string
+ final StringWriter reply = new StringWriter();
+ while (true) {
+ int charRead = bufferReader.read();
+ if (charRead == -1) {
+ throw new IOException("Session closed");
+ }
+
+ for (int i = 0; i < endpattern.length(); i++) {
+ if (charRead == endpattern.charAt(i)) {
+ if (i < endpattern.length() - 1) {
+ charRead = bufferReader.read();
+ } else {
+ return reply.getBuffer().toString();
+ }
+ } else {
+ String s = endpattern.substring(0, i);
+ for (int j = 0; i < s.length(); j++) {
+ reply.write(s.charAt(j));
+ }
+ reply.write(charRead);
+ break;
+ }
+ }
+ }
+ }
+
+}
diff --git a/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/package-info.java b/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/package-info.java
new file mode 100644
index 00000000..84992bf2
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/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.
+ */
+
+/**
+ * Created by ray on 10/30/15.
+ */
+package org.onosproject.netconf.ctl;
diff --git a/framework/src/onos/protocols/netconf/pom.xml b/framework/src/onos/protocols/netconf/pom.xml
new file mode 100644
index 00000000..d2f5c432
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-protocols</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-netconf</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>api</module>
+ <module>rfc</module>
+ <module>ctl</module>
+ </modules>
+
+ <description>ONOS NETCONF southbound libraries</description>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-misc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-buffer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-handler</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-net</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/framework/src/onos/protocols/netconf/rfc/pom.xml b/framework/src/onos/protocols/netconf/rfc/pom.xml
new file mode 100644
index 00000000..832937bc
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/rfc/pom.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-netconf</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-netconf-rfc</artifactId>
+ <packaging>bundle</packaging>
+</project>
diff --git a/framework/src/onos/protocols/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/Foo.java b/framework/src/onos/protocols/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/Foo.java
new file mode 100644
index 00000000..06963b0c
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/Foo.java
@@ -0,0 +1,7 @@
+package org.onosproject.netconf.rfc;
+
+/**
+ * Created by tom on 10/19/15.
+ */
+public class Foo {
+}
diff --git a/framework/src/onos/protocols/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/package-info.java b/framework/src/onos/protocols/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/package-info.java
new file mode 100644
index 00000000..616a7ce5
--- /dev/null
+++ b/framework/src/onos/protocols/netconf/rfc/src/main/java/org/onosproject/netconf/rfc/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.
+ */
+
+/**
+ * Created by ray on 10/30/15.
+ */
+package org.onosproject.netconf.rfc;
diff --git a/framework/src/onos/protocols/openflow/api/pom.xml b/framework/src/onos/protocols/openflow/api/pom.xml
new file mode 100644
index 00000000..e535ac64
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/pom.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-of-api</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS OpenFlow controller subsystem API</description>
+
+ <dependencies>
+ <dependency>
+ <!-- FIXME once experimenter gets merged to upstream -->
+ <groupId>org.onosproject</groupId>
+ <artifactId>openflowj</artifactId>
+ <version>${openflowj.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <artifactSet>
+ <excludes>
+ <exclude>io.netty:netty</exclude>
+ <exclude>com.google.guava:guava</exclude>
+ <exclude>org.slf4j:slfj-api</exclude>
+ <exclude>ch.qos.logback:logback-core</exclude>
+ <exclude>ch.qos.logback:logback-classic</exclude>
+ <exclude>com.google.code.findbugs:annotations</exclude>
+ </excludes>
+ </artifactSet>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.onosproject.openflow.*,org.projectfloodlight.openflow.*
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/DefaultOpenFlowPacketContext.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/DefaultOpenFlowPacketContext.java
new file mode 100644
index 00000000..af92a1d0
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/DefaultOpenFlowPacketContext.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2014-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.openflow.controller;
+
+import org.onlab.packet.DeserializationException;
+import org.onlab.packet.Ethernet;
+import org.projectfloodlight.openflow.protocol.OFPacketIn;
+import org.projectfloodlight.openflow.protocol.OFPacketOut;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+import org.projectfloodlight.openflow.protocol.action.OFAction;
+import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
+import org.projectfloodlight.openflow.protocol.match.MatchField;
+import org.projectfloodlight.openflow.types.OFBufferId;
+import org.projectfloodlight.openflow.types.OFPort;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.BufferUnderflowException;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import static org.onosproject.security.AppGuard.checkPermission;
+import static org.onosproject.security.AppPermission.Type.*;
+
+
+/**
+ * Default implementation of an OpenFlowPacketContext.
+ */
+public final class DefaultOpenFlowPacketContext implements OpenFlowPacketContext {
+
+ private final AtomicBoolean free = new AtomicBoolean(true);
+ private final AtomicBoolean isBuilt = new AtomicBoolean(false);
+ private final OpenFlowSwitch sw;
+ private final OFPacketIn pktin;
+ private OFPacketOut pktout = null;
+
+ private final boolean isBuffered;
+
+ private DefaultOpenFlowPacketContext(OpenFlowSwitch s, OFPacketIn pkt) {
+ this.sw = s;
+ this.pktin = pkt;
+ this.isBuffered = pktin.getBufferId() != OFBufferId.NO_BUFFER;
+ }
+
+ @Override
+ public void send() {
+ checkPermission(PACKET_WRITE);
+
+ if (block() && isBuilt.get()) {
+ sw.sendMsg(pktout);
+ }
+ }
+
+ @Override
+ public void build(OFPort outPort) {
+ if (isBuilt.getAndSet(true)) {
+ return;
+ }
+ OFPacketOut.Builder builder = sw.factory().buildPacketOut();
+ OFAction act = buildOutput(outPort.getPortNumber());
+ pktout = builder.setXid(pktin.getXid())
+ .setInPort(pktinInPort())
+ .setBufferId(OFBufferId.NO_BUFFER)
+ .setData(pktin.getData())
+// .setBufferId(pktin.getBufferId())
+ .setActions(Collections.singletonList(act))
+ .build();
+ }
+
+ @Override
+ public void build(Ethernet ethFrame, OFPort outPort) {
+ if (isBuilt.getAndSet(true)) {
+ return;
+ }
+ OFPacketOut.Builder builder = sw.factory().buildPacketOut();
+ OFAction act = buildOutput(outPort.getPortNumber());
+ pktout = builder.setXid(pktin.getXid())
+ .setBufferId(OFBufferId.NO_BUFFER)
+ .setInPort(pktinInPort())
+ .setActions(Collections.singletonList(act))
+ .setData(ethFrame.serialize())
+ .build();
+ }
+
+ @Override
+ public Ethernet parsed() {
+ checkPermission(PACKET_READ);
+
+ try {
+ return Ethernet.deserializer().deserialize(pktin.getData(), 0, pktin.getData().length);
+ } catch (BufferUnderflowException | NullPointerException |
+ DeserializationException e) {
+ Logger log = LoggerFactory.getLogger(getClass());
+ log.error("packet deserialization problem : {}", e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public Dpid dpid() {
+ checkPermission(PACKET_READ);
+
+ return new Dpid(sw.getId());
+ }
+
+ /**
+ * Creates an OpenFlow packet context based on a packet-in.
+ *
+ * @param s OpenFlow switch
+ * @param pkt OpenFlow packet-in
+ * @return the OpenFlow packet context
+ */
+ public static OpenFlowPacketContext packetContextFromPacketIn(OpenFlowSwitch s,
+ OFPacketIn pkt) {
+ return new DefaultOpenFlowPacketContext(s, pkt);
+ }
+
+ @Override
+ public Integer inPort() {
+ checkPermission(PACKET_READ);
+
+ return pktinInPort().getPortNumber();
+ }
+
+ private OFPort pktinInPort() {
+ if (pktin.getVersion() == OFVersion.OF_10) {
+ return pktin.getInPort();
+ }
+ return pktin.getMatch().get(MatchField.IN_PORT);
+ }
+
+ @Override
+ public byte[] unparsed() {
+ checkPermission(PACKET_READ);
+
+ return pktin.getData().clone();
+
+ }
+
+ private OFActionOutput buildOutput(Integer port) {
+ OFActionOutput act = sw.factory().actions()
+ .buildOutput()
+ .setPort(OFPort.of(port))
+ .build();
+ return act;
+ }
+
+ @Override
+ public boolean block() {
+ checkPermission(PACKET_WRITE);
+
+ return free.getAndSet(false);
+ }
+
+ @Override
+ public boolean isHandled() {
+ checkPermission(PACKET_READ);
+
+ return !free.get();
+ }
+
+ @Override
+ public boolean isBuffered() {
+ checkPermission(PACKET_READ);
+
+ return isBuffered;
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/Dpid.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/Dpid.java
new file mode 100644
index 00000000..6e0f65be
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/Dpid.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2014 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.openflow.controller;
+
+import org.projectfloodlight.openflow.util.HexString;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.onlab.util.Tools.fromHex;
+import static org.onlab.util.Tools.toHex;
+
+/**
+ * The class representing a network switch DPID.
+ * This class is immutable.
+ */
+public final class Dpid {
+
+ private static final String SCHEME = "of";
+ private static final long UNKNOWN = 0;
+ private final long value;
+
+ /**
+ * Default constructor.
+ */
+ public Dpid() {
+ this.value = Dpid.UNKNOWN;
+ }
+
+ /**
+ * Constructor from a long value.
+ *
+ * @param value the value to use.
+ */
+ public Dpid(long value) {
+ this.value = value;
+ }
+
+ /**
+ * Constructor from a string.
+ *
+ * @param value the value to use.
+ */
+ public Dpid(String value) {
+ this.value = HexString.toLong(value);
+ }
+
+ /**
+ * Get the value of the DPID.
+ *
+ * @return the value of the DPID.
+ */
+ public long value() {
+ return value;
+ }
+
+ /**
+ * Convert the DPID value to a ':' separated hexadecimal string.
+ *
+ * @return the DPID value as a ':' separated hexadecimal string.
+ */
+ @Override
+ public String toString() {
+ return HexString.toHexString(this.value);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof Dpid)) {
+ return false;
+ }
+
+ Dpid otherDpid = (Dpid) other;
+
+ return value == otherDpid.value;
+ }
+
+ @Override
+ public int hashCode() {
+ return Long.hashCode(value);
+ }
+
+ /**
+ * Returns DPID created from the given device URI.
+ *
+ * @param uri device URI
+ * @return dpid
+ */
+ public static Dpid dpid(URI uri) {
+ checkArgument(uri.getScheme().equals(SCHEME), "Unsupported URI scheme");
+ return new Dpid(fromHex(uri.getSchemeSpecificPart()));
+ }
+
+ /**
+ * Produces device URI from the given DPID.
+ *
+ * @param dpid device dpid
+ * @return device URI
+ */
+ public static URI uri(Dpid dpid) {
+ return uri(dpid.value);
+ }
+
+ /**
+ * Produces device URI from the given DPID long.
+ *
+ * @param value device dpid as long
+ * @return device URI
+ */
+ public static URI uri(long value) {
+ try {
+ return new URI(SCHEME, toHex(value), null);
+ } catch (URISyntaxException e) {
+ return null;
+ }
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionTreatmentInterpreter.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionTreatmentInterpreter.java
new file mode 100644
index 00000000..dc57977f
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ExtensionTreatmentInterpreter.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.openflow.controller;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.net.driver.HandlerBehaviour;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
+import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
+import org.projectfloodlight.openflow.protocol.OFFactory;
+import org.projectfloodlight.openflow.protocol.action.OFAction;
+
+/**
+ * Interprets extension instructions and converts them to/from OpenFlow objects.
+ */
+@Beta
+public interface ExtensionTreatmentInterpreter extends HandlerBehaviour {
+
+ /**
+ * Returns true if the given extension instruction is supported by this
+ * driver.
+ *
+ * @param extensionTreatmentType extension instruction type
+ * @return true if the instruction is supported, otherwise false
+ */
+ boolean supported(ExtensionTreatmentType extensionTreatmentType);
+
+ /**
+ * Maps an extension instruction to an OpenFlow action.
+ *
+ * @param factory OpenFlow factory
+ * @param extensionTreatment extension instruction
+ * @return OpenFlow action
+ */
+ OFAction mapInstruction(OFFactory factory, ExtensionTreatment extensionTreatment);
+
+ /**
+ * Maps an OpenFlow action to an extension instruction.
+ *
+ * @param action OpenFlow action
+ * @return extension instruction
+ */
+ ExtensionTreatment mapAction(OFAction action);
+
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowController.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowController.java
new file mode 100644
index 00000000..2c68fa0b
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowController.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2014 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.openflow.controller;
+
+import org.projectfloodlight.openflow.protocol.OFMessage;
+
+/**
+ * Abstraction of an OpenFlow controller. Serves as a one stop
+ * shop for obtaining OpenFlow devices and (un)register listeners
+ * on OpenFlow events
+ */
+public interface OpenFlowController {
+
+ /**
+ * Returns all switches known to this OF controller.
+ * @return Iterable of dpid elements
+ */
+ Iterable<OpenFlowSwitch> getSwitches();
+
+ /**
+ * Returns all master switches known to this OF controller.
+ * @return Iterable of dpid elements
+ */
+ Iterable<OpenFlowSwitch> getMasterSwitches();
+
+ /**
+ * Returns all equal switches known to this OF controller.
+ * @return Iterable of dpid elements
+ */
+ Iterable<OpenFlowSwitch> getEqualSwitches();
+
+
+ /**
+ * Returns the actual switch for the given Dpid.
+ * @param dpid the switch to fetch
+ * @return the interface to this switch
+ */
+ OpenFlowSwitch getSwitch(Dpid dpid);
+
+ /**
+ * Returns the actual master switch for the given Dpid, if one exists.
+ * @param dpid the switch to fetch
+ * @return the interface to this switch
+ */
+ OpenFlowSwitch getMasterSwitch(Dpid dpid);
+
+ /**
+ * Returns the actual equal switch for the given Dpid, if one exists.
+ * @param dpid the switch to fetch
+ * @return the interface to this switch
+ */
+ OpenFlowSwitch getEqualSwitch(Dpid dpid);
+
+ /**
+ * Register a listener for meta events that occur to OF
+ * devices.
+ * @param listener the listener to notify
+ */
+ void addListener(OpenFlowSwitchListener listener);
+
+ /**
+ * Unregister a listener.
+ *
+ * @param listener the listener to unregister
+ */
+ void removeListener(OpenFlowSwitchListener listener);
+
+ /**
+ * Register a listener for packet events.
+ * @param priority the importance of this listener, lower values are more important
+ * @param listener the listener to notify
+ */
+ void addPacketListener(int priority, PacketListener listener);
+
+ /**
+ * Unregister a listener.
+ *
+ * @param listener the listener to unregister
+ */
+ void removePacketListener(PacketListener listener);
+
+ /**
+ * Register a listener for OF msg events.
+ *
+ * @param listener the listener to notify
+ */
+ void addEventListener(OpenFlowEventListener listener);
+
+ /**
+ * Unregister a listener.
+ *
+ * @param listener the listener to unregister
+ */
+ void removeEventListener(OpenFlowEventListener listener);
+
+ /**
+ * Send a message to a particular switch.
+ * @param dpid the switch to send to.
+ * @param msg the message to send
+ */
+ void write(Dpid dpid, OFMessage msg);
+
+ /**
+ * Process a message and notify the appropriate listeners.
+ *
+ * @param dpid the dpid the message arrived on
+ * @param msg the message to process.
+ */
+ void processPacket(Dpid dpid, OFMessage msg);
+
+ /**
+ * Sets the role for a given switch.
+ * @param role the desired role
+ * @param dpid the switch to set the role for.
+ */
+ void setRole(Dpid dpid, RoleState role);
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowEventListener.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowEventListener.java
new file mode 100644
index 00000000..5deccf5e
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowEventListener.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2014 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.openflow.controller;
+
+import org.projectfloodlight.openflow.protocol.OFMessage;
+
+
+/**
+ * Notifies providers about openflow msg events.
+ */
+public interface OpenFlowEventListener {
+
+ /**
+ * Handles the message event.
+ *
+ * @param dpid switch data path identifier
+ * @param msg the message
+ */
+ void handleMessage(Dpid dpid, OFMessage msg);
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowOpticalSwitch.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowOpticalSwitch.java
new file mode 100644
index 00000000..af678d63
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowOpticalSwitch.java
@@ -0,0 +1,23 @@
+/*
+ * 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.openflow.controller;
+
+/**
+ * A marker interface for optical switches, which require the ability to pass
+ * port information to a Device provider.
+ */
+public interface OpenFlowOpticalSwitch extends OpenFlowSwitch, WithTypedPorts {
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowPacketContext.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowPacketContext.java
new file mode 100644
index 00000000..740d89d0
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowPacketContext.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2014 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.openflow.controller;
+
+import org.onlab.packet.Ethernet;
+import org.projectfloodlight.openflow.types.OFPort;
+
+/**
+ * A representation of a packet context which allows any provider
+ * to view a packet in event, but may block the response to the
+ * event if blocked has been called. This packet context can be used
+ * to react to the packet in event with a packet out.
+ */
+public interface OpenFlowPacketContext {
+
+ /**
+ * Blocks further responses (ie. send() calls) on this
+ * packet in event.
+ * @return true if blocks
+ */
+ boolean block();
+
+ /**
+ * Checks whether the packet has been handled.
+ * @return true if handled, false otherwise.
+ */
+ boolean isHandled();
+
+ /**
+ * Provided build has been called send the packet
+ * out the switch it came in on.
+ */
+ void send();
+
+ /**
+ * Build the packet out in response to this packet in event.
+ * @param outPort the out port to send to packet out of.
+ */
+ void build(OFPort outPort);
+
+ /**
+ * Build the packet out in response to this packet in event.
+ * @param ethFrame the actual packet to send out.
+ * @param outPort the out port to send to packet out of.
+ */
+ void build(Ethernet ethFrame, OFPort outPort);
+
+ /**
+ * Provided a handle onto the parsed payload.
+ * @return the parsed form of the payload.
+ */
+ Ethernet parsed();
+
+ /**
+ * Provide an unparsed copy of the data.
+ * @return the unparsed form of the payload.
+ */
+ byte[] unparsed();
+
+ /**
+ * Provide the dpid of the switch where the packet in arrived.
+ * @return the dpid of the switch.
+ */
+ Dpid dpid();
+
+ /**
+ * Provide the port on which the packet arrived.
+ * @return the port
+ */
+ Integer inPort();
+
+ /**
+ * Indicates that this packet is buffered at the switch.
+ * @return buffer indication
+ */
+ boolean isBuffered();
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java
new file mode 100644
index 00000000..b6ec5744
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2014-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.openflow.controller;
+
+import org.onosproject.net.Device;
+import org.projectfloodlight.openflow.protocol.OFFactory;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFPortDesc;
+
+import java.util.List;
+
+/**
+ * Represents to provider facing side of a switch.
+ */
+public interface OpenFlowSwitch {
+
+ /**
+ * Writes the message to the driver.
+ * <p>
+ * Note: Messages may be silently dropped/lost due to IOExceptions or
+ * role. If this is a concern, then a caller should use barriers.
+ * </p>
+ *
+ * @param msg the message to write
+ */
+ void sendMsg(OFMessage msg);
+
+ /**
+ * Writes the OFMessage list to the driver.
+ * <p>
+ * Note: Messages may be silently dropped/lost due to IOExceptions or
+ * role. If this is a concern, then a caller should use barriers.
+ * </p>
+ *
+ * @param msgs the messages to be written
+ */
+ void sendMsg(List<OFMessage> msgs);
+
+ /**
+ * Handle a message from the switch.
+ * @param fromSwitch the message to handle
+ */
+ void handleMessage(OFMessage fromSwitch);
+
+ /**
+ * Sets the role for this switch.
+ * @param role the role to set.
+ */
+ void setRole(RoleState role);
+
+ /**
+ * Fetch the role for this switch.
+ * @return the role.
+ */
+ RoleState getRole();
+
+ /**
+ * Fetches the ports of this switch.
+ * @return unmodifiable list of the ports.
+ */
+ List<OFPortDesc> getPorts();
+
+ /**
+ * Provides the factory for this OF version.
+ * @return OF version specific factory.
+ */
+ OFFactory factory();
+
+ /**
+ * Gets a string version of the ID for this switch.
+ *
+ * @return string version of the ID
+ */
+ String getStringId();
+
+ /**
+ * Gets the datapathId of the switch.
+ *
+ * @return the switch dpid in long format
+ */
+ long getId();
+
+ /**
+ * fetch the manufacturer description.
+ * @return the description
+ */
+ String manufacturerDescription();
+
+ /**
+ * fetch the datapath description.
+ * @return the description
+ */
+ String datapathDescription();
+
+ /**
+ * fetch the hardware description.
+ * @return the description
+ */
+ String hardwareDescription();
+
+ /**
+ * fetch the software description.
+ * @return the description
+ */
+ String softwareDescription();
+
+ /**
+ * fetch the serial number.
+ * @return the serial
+ */
+ String serialNumber();
+
+ /**
+ * Checks if the switch is still connected.
+ *
+ * @return whether the switch is still connected
+ */
+ boolean isConnected();
+
+ /**
+ * Disconnects the switch by closing the TCP connection. Results in a call
+ * to the channel handler's channelDisconnected method for cleanup
+ */
+ void disconnectSwitch();
+
+ /**
+ * Notifies the controller that the device has responded to a set-role request.
+ *
+ * @param requested the role requested by the controller
+ * @param response the role set at the device
+ */
+ void returnRoleReply(RoleState requested, RoleState response);
+
+ /**
+ * Returns the switch device type.
+ *
+ * @return device type
+ */
+ Device.Type deviceType();
+
+ /**
+ * Identifies the channel used to communicate with the switch.
+ *
+ * @return string representation of the connection to the device
+ */
+ String channelId();
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitchListener.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitchListener.java
new file mode 100644
index 00000000..2da41335
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitchListener.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2014 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.openflow.controller;
+
+import org.projectfloodlight.openflow.protocol.OFPortStatus;
+
+/**
+ * Allows for providers interested in Switch events to be notified.
+ */
+public interface OpenFlowSwitchListener {
+
+ /**
+ * Notify that the switch was added.
+ * @param dpid the switch where the event occurred
+ */
+ void switchAdded(Dpid dpid);
+
+ /**
+ * Notify that the switch was removed.
+ * @param dpid the switch where the event occurred.
+ */
+ void switchRemoved(Dpid dpid);
+
+ /**
+ * Notify that the switch has changed in some way.
+ * @param dpid the switch that changed
+ */
+ void switchChanged(Dpid dpid);
+
+ /**
+ * Notify that a port has changed.
+ * @param dpid the switch on which the change happened.
+ * @param status the new state of the port.
+ */
+ void portChanged(Dpid dpid, OFPortStatus status);
+
+ /**
+ * Notify that a role imposed on a switch failed to take hold.
+ *
+ * @param dpid the switch that failed role assertion
+ * @param requested the role controller requested
+ * @param response role reply from the switch
+ */
+ void receivedRoleReply(Dpid dpid, RoleState requested, RoleState response);
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/PacketListener.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/PacketListener.java
new file mode 100644
index 00000000..817a6cdf
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/PacketListener.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2014 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.openflow.controller;
+
+/**
+ * Notifies providers about Packet in events.
+ */
+public interface PacketListener {
+
+ /**
+ * Handles the packet.
+ *
+ * @param pktCtx the packet context
+ */
+ void handlePacket(OpenFlowPacketContext pktCtx);
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/PortDescPropertyType.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/PortDescPropertyType.java
new file mode 100644
index 00000000..3a0f1a0d
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/PortDescPropertyType.java
@@ -0,0 +1,39 @@
+/*
+ * 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.openflow.controller;
+
+/**
+ * Port description property types (OFPPDPT enums) in OF 1.3 &lt;.
+ */
+public enum PortDescPropertyType {
+ ETHERNET(0), /* Ethernet port */
+ OPTICAL(1), /* Optical port */
+ OPTICAL_TRANSPORT(2), /* OF1.3 Optical transport extension */
+ PIPELINE_INPUT(2), /* Ingress pipeline */
+ PIPELINE_OUTPUT(3), /* Egress pipeline */
+ RECIRCULATE(4), /* Recirculation */
+ EXPERIMENTER(0xffff); /* Experimenter-implemented */
+
+ private final int value;
+
+ PortDescPropertyType(int v) {
+ value = v;
+ }
+
+ public int valueOf() {
+ return value;
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/RoleState.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/RoleState.java
new file mode 100644
index 00000000..b8304f39
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/RoleState.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2014 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.openflow.controller;
+
+import org.projectfloodlight.openflow.protocol.OFControllerRole;
+
+/**
+ * The role of the controller as it pertains to a particular switch.
+ * Note that this definition of the role enum is different from the
+ * OF1.3 definition. It is maintained here to be backward compatible to
+ * earlier versions of the controller code. This enum is translated
+ * to the OF1.3 enum, before role messages are sent to the switch.
+ * See sendRoleRequestMessage method in OFSwitchImpl
+ */
+public enum RoleState {
+ EQUAL(OFControllerRole.ROLE_EQUAL),
+ MASTER(OFControllerRole.ROLE_MASTER),
+ SLAVE(OFControllerRole.ROLE_SLAVE);
+
+ private RoleState(OFControllerRole nxRole) {
+ nxRole.ordinal();
+ }
+
+}
+
+
+
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ThirdPartyMessage.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ThirdPartyMessage.java
new file mode 100644
index 00000000..59ef33cf
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/ThirdPartyMessage.java
@@ -0,0 +1,74 @@
+/*
+ * 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.openflow.controller;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+
+import com.google.common.hash.PrimitiveSink;
+/**
+ * Used to support for the third party privacy flow rule.
+ * it implements OFMessage interface to use exist adapter API.
+ */
+public class ThirdPartyMessage implements OFMessage {
+
+ private final byte[] payLoad; //privacy flow rule
+
+ public ThirdPartyMessage(byte[] payLoad) {
+ this.payLoad = payLoad;
+ }
+
+ public byte[] payLoad() {
+ return payLoad;
+ }
+
+ @Override
+ public void putTo(PrimitiveSink sink) {
+ // Do nothing here for now.
+ }
+
+ @Override
+ public OFVersion getVersion() {
+ // Do nothing here for now.
+ return null;
+ }
+
+ @Override
+ public OFType getType() {
+ // Do nothing here for now.
+ return null;
+ }
+
+ @Override
+ public long getXid() {
+ // Do nothing here for now.
+ return 0;
+ }
+
+ @Override
+ public void writeTo(ChannelBuffer channelBuffer) {
+ // Do nothing here for now.
+ }
+
+ @Override
+ public Builder createBuilder() {
+ // Do nothing here for now.
+ return null;
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/WithTypedPorts.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/WithTypedPorts.java
new file mode 100644
index 00000000..8b82b4a7
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/WithTypedPorts.java
@@ -0,0 +1,45 @@
+/*
+ * 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.openflow.controller;
+
+import java.util.List;
+import java.util.Set;
+
+import org.projectfloodlight.openflow.protocol.OFObject;
+
+/**
+ * An interface implemented by OpenFlow devices that enables providers to
+ * retrieve ports based on port property.
+ */
+public interface WithTypedPorts {
+
+ /**
+ * Return a list of interfaces (ports) of the type associated with this
+ * OpenFlow switch.
+ *
+ * @param type The port description property type of requested ports
+ * @return A potentially empty list of ports.
+ */
+ List<? extends OFObject> getPortsOf(PortDescPropertyType type);
+
+ /**
+ * Returns the port property types supported by the driver implementing this
+ * interface.
+ *
+ * @return A set of port property types
+ */
+ Set<PortDescPropertyType> getPortTypes();
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java
new file mode 100644
index 00000000..c7174192
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java
@@ -0,0 +1,493 @@
+/*
+ * Copyright 2014-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.openflow.controller.driver;
+
+import com.google.common.collect.Lists;
+import org.jboss.netty.channel.Channel;
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.Device;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.openflow.controller.Dpid;
+import org.onosproject.openflow.controller.RoleState;
+import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFErrorMsg;
+import org.projectfloodlight.openflow.protocol.OFExperimenter;
+import org.projectfloodlight.openflow.protocol.OFFactories;
+import org.projectfloodlight.openflow.protocol.OFFactory;
+import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFNiciraControllerRoleRequest;
+import org.projectfloodlight.openflow.protocol.OFPortDesc;
+import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFPortStatus;
+import org.projectfloodlight.openflow.protocol.OFRoleReply;
+import org.projectfloodlight.openflow.protocol.OFRoleRequest;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+
+/**
+ * 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 abstract class AbstractOpenFlowSwitch extends AbstractHandlerBehaviour
+ implements OpenFlowSwitchDriver {
+
+ protected final Logger log = LoggerFactory.getLogger(getClass());
+
+ private Channel channel;
+ protected String channelId;
+
+ private boolean connected;
+ protected boolean startDriverHandshakeCalled = false;
+ private Dpid dpid;
+ private OpenFlowAgent agent;
+ private final AtomicInteger xidCounter = new AtomicInteger(0);
+
+ private OFVersion ofVersion;
+
+ protected List<OFPortDescStatsReply> ports = new ArrayList<>();
+
+ protected boolean tableFull;
+
+ private RoleHandler roleMan;
+
+ // TODO this is accessed from multiple threads, but volatile may have performance implications
+ protected volatile RoleState role;
+
+ protected OFFeaturesReply features;
+ protected OFDescStatsReply desc;
+
+ private final AtomicReference<List<OFMessage>> messagesPendingMastership
+ = new AtomicReference<>();
+
+ @Override
+ public void init(Dpid dpid, OFDescStatsReply desc, OFVersion ofv) {
+ this.dpid = dpid;
+ this.desc = desc;
+ this.ofVersion = ofv;
+ }
+
+ //************************
+ // Channel related
+ //************************
+
+ @Override
+ public final void disconnectSwitch() {
+ this.channel.close();
+ }
+
+ @Override
+ public void sendMsg(OFMessage msg) {
+ this.sendMsg(Collections.singletonList(msg));
+ }
+
+ @Override
+ public final void sendMsg(List<OFMessage> msgs) {
+ /*
+ It is possible that in this block, we transition to SLAVE/EQUAL.
+ If this is the case, the supplied messages will race with the
+ RoleRequest message, and they could be rejected by the switch.
+ In the interest of performance, we will not protect this block with
+ a synchronization primitive, because the message would have just been
+ dropped anyway.
+ */
+ if (role == RoleState.MASTER) {
+ // fast path send when we are master
+
+ sendMsgsOnChannel(msgs);
+ return;
+ }
+ // check to see if mastership transition is in progress
+ synchronized (messagesPendingMastership) {
+ /*
+ messagesPendingMastership is used as synchronization variable for
+ all mastership related changes. In this block, mastership (including
+ role update) will have either occurred or not.
+ */
+ if (role == RoleState.MASTER) {
+ // transition to MASTER complete, send messages
+ sendMsgsOnChannel(msgs);
+ return;
+ }
+
+ List<OFMessage> messages = messagesPendingMastership.get();
+ if (messages != null) {
+ // we are transitioning to MASTER, so add messages to queue
+ messages.addAll(msgs);
+ log.debug("Enqueue message for switch {}. queue size after is {}",
+ dpid, messages.size());
+ } else {
+ // not transitioning to MASTER
+ log.warn("Dropping message for switch {} (role: {}, connected: {}): {}",
+ dpid, role, channel.isConnected(), msgs);
+ }
+ }
+ }
+
+ private void sendMsgsOnChannel(List<OFMessage> msgs) {
+ if (channel.isConnected()) {
+ channel.write(msgs);
+ } else {
+ log.warn("Dropping messages for switch {} because channel is not connected: {}",
+ dpid, msgs);
+ }
+ }
+
+ @Override
+ public final void sendRoleRequest(OFMessage msg) {
+ if (msg instanceof OFRoleRequest ||
+ msg instanceof OFNiciraControllerRoleRequest) {
+ sendMsgsOnChannel(Collections.singletonList(msg));
+ return;
+ }
+ throw new IllegalArgumentException("Someone is trying to send " +
+ "a non role request message");
+ }
+
+ @Override
+ public final void sendHandshakeMessage(OFMessage message) {
+ if (!this.isDriverHandshakeComplete()) {
+ sendMsgsOnChannel(Collections.singletonList(message));
+ }
+ }
+
+ @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;
+ }
+
+ //************************
+ // Switch features related
+ //************************
+
+ @Override
+ public final long getId() {
+ return this.dpid.value();
+ }
+
+ @Override
+ public final String getStringId() {
+ return this.dpid.toString();
+ }
+
+ @Override
+ public final void setOFVersion(OFVersion ofV) {
+ this.ofVersion = ofV;
+ }
+
+ @Override
+ public void setTableFull(boolean full) {
+ this.tableFull = full;
+ }
+
+ @Override
+ public void setFeaturesReply(OFFeaturesReply featuresReply) {
+ this.features = featuresReply;
+ }
+
+ @Override
+ public abstract Boolean supportNxRole();
+
+ //************************
+ // Message handling
+ //************************
+ /**
+ * Handle the message coming from the dataplane.
+ *
+ * @param m the actual message
+ */
+ @Override
+ public final void handleMessage(OFMessage m) {
+ if (this.role == RoleState.MASTER || m instanceof OFPortStatus) {
+ this.agent.processMessage(dpid, m);
+ }
+ }
+
+ @Override
+ public RoleState getRole() {
+ return role;
+ }
+
+ @Override
+ public final boolean connectSwitch() {
+ return this.agent.addConnectedSwitch(dpid, this);
+ }
+
+ @Override
+ public final boolean activateMasterSwitch() {
+ return this.agent.addActivatedMasterSwitch(dpid, this);
+ }
+
+ @Override
+ public final boolean activateEqualSwitch() {
+ return this.agent.addActivatedEqualSwitch(dpid, this);
+ }
+
+ @Override
+ public final void transitionToEqualSwitch() {
+ this.agent.transitionToEqualSwitch(dpid);
+ }
+
+ @Override
+ public final void transitionToMasterSwitch() {
+ this.agent.transitionToMasterSwitch(dpid);
+ synchronized (messagesPendingMastership) {
+ List<OFMessage> messages = messagesPendingMastership.get();
+ if (messages != null) {
+ this.sendMsg(messages);
+ log.debug("Sending {} pending messages to switch {}",
+ messages.size(), dpid);
+ messagesPendingMastership.set(null);
+ }
+ // perform role transition after clearing messages queue
+ this.role = RoleState.MASTER;
+ }
+ }
+
+ @Override
+ public final void removeConnectedSwitch() {
+ this.agent.removeConnectedSwitch(dpid);
+ }
+
+ @Override
+ public OFFactory factory() {
+ return OFFactories.getFactory(ofVersion);
+ }
+
+ @Override
+ public void setPortDescReply(OFPortDescStatsReply portDescReply) {
+ this.ports.add(portDescReply);
+ }
+
+ @Override
+ public void setPortDescReplies(List<OFPortDescStatsReply> portDescReplies) {
+ this.ports.addAll(portDescReplies);
+ }
+
+ @Override
+ public void returnRoleReply(RoleState requested, RoleState response) {
+ this.agent.returnRoleReply(dpid, requested, response);
+ }
+
+ @Override
+ public abstract void startDriverHandshake();
+
+ @Override
+ public abstract boolean isDriverHandshakeComplete();
+
+ @Override
+ public abstract void processDriverHandshakeMessage(OFMessage m);
+
+
+ // Role Handling
+
+ @Override
+ public void setRole(RoleState role) {
+ try {
+ if (role == RoleState.SLAVE || role == RoleState.EQUAL) {
+ // perform role transition to SLAVE/EQUAL before sending role request
+ this.role = role;
+ }
+ if (this.roleMan.sendRoleRequest(role, RoleRecvStatus.MATCHED_SET_ROLE)) {
+ log.debug("Sending role {} to switch {}", role, getStringId());
+ if (role == RoleState.MASTER) {
+ synchronized (messagesPendingMastership) {
+ if (messagesPendingMastership.get() == null) {
+ log.debug("Initializing new message queue for switch {}", dpid);
+ /*
+ The presence of messagesPendingMastership indicates that
+ a switch is currently transitioning to MASTER, but
+ is still awaiting role reply from switch.
+ */
+ messagesPendingMastership.set(Lists.newArrayList());
+ }
+ }
+ }
+ } else if (role == RoleState.MASTER) {
+ // role request not support; transition switch to MASTER
+ this.role = role;
+ }
+ } catch (IOException e) {
+ log.error("Unable to write to switch {}.", this.dpid);
+ }
+ }
+
+ @Override
+ public void reassertRole() {
+ // TODO should messages be sent directly or queue during reassertion?
+ if (this.getRole() == RoleState.MASTER) {
+ log.warn("Received permission error from switch {} while " +
+ "being master. Reasserting master role.",
+ this.getStringId());
+ this.setRole(RoleState.MASTER);
+ }
+ }
+
+ @Override
+ public void handleRole(OFMessage m) throws SwitchStateException {
+ RoleReplyInfo rri = roleMan.extractOFRoleReply((OFRoleReply) m);
+ RoleRecvStatus rrs = roleMan.deliverRoleReply(rri);
+ if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
+ if (rri.getRole() == RoleState.MASTER) {
+ this.transitionToMasterSwitch();
+ } else if (rri.getRole() == RoleState.EQUAL ||
+ rri.getRole() == RoleState.SLAVE) {
+ this.transitionToEqualSwitch();
+ }
+ } else {
+ log.warn("Failed to set role for {}", this.getStringId());
+ }
+ }
+
+ @Override
+ public void handleNiciraRole(OFMessage m) throws SwitchStateException {
+ RoleState r = this.roleMan.extractNiciraRoleReply((OFExperimenter) m);
+ if (r == null) {
+ // The message wasn't really a Nicira role reply. We just
+ // dispatch it to the OFMessage listeners in this case.
+ this.handleMessage(m);
+ return;
+ }
+
+ RoleRecvStatus rrs = this.roleMan.deliverRoleReply(
+ new RoleReplyInfo(r, null, m.getXid()));
+ if (rrs == RoleRecvStatus.MATCHED_SET_ROLE) {
+ if (r == RoleState.MASTER) {
+ this.transitionToMasterSwitch();
+ } else if (r == RoleState.EQUAL ||
+ r == RoleState.SLAVE) {
+ this.transitionToEqualSwitch();
+ }
+ } else {
+ this.disconnectSwitch();
+ }
+ }
+
+ @Override
+ public boolean handleRoleError(OFErrorMsg error) {
+ try {
+ return RoleRecvStatus.OTHER_EXPECTATION != this.roleMan.deliverError(error);
+ } catch (SwitchStateException e) {
+ this.disconnectSwitch();
+ }
+ return true;
+ }
+
+ @Override
+ public final void setAgent(OpenFlowAgent ag) {
+ if (this.agent == null) {
+ this.agent = ag;
+ }
+ }
+
+ @Override
+ public final void setRoleHandler(RoleHandler roleHandler) {
+ if (this.roleMan == null) {
+ this.roleMan = roleHandler;
+ }
+ }
+
+ @Override
+ public void setSwitchDescription(OFDescStatsReply d) {
+ this.desc = d;
+ }
+
+ @Override
+ public int getNextTransactionId() {
+ return this.xidCounter.getAndIncrement();
+ }
+
+ @Override
+ public List<OFPortDesc> getPorts() {
+ return this.ports.stream()
+ .flatMap(portReply -> portReply.getEntries().stream())
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public String manufacturerDescription() {
+ return this.desc.getMfrDesc();
+ }
+
+ @Override
+ public String datapathDescription() {
+ return this.desc.getDpDesc();
+ }
+
+ @Override
+ public String hardwareDescription() {
+ return this.desc.getHwDesc();
+ }
+
+ @Override
+ public String softwareDescription() {
+ return this.desc.getSwDesc();
+ }
+
+ @Override
+ public String serialNumber() {
+ return this.desc.getSerialNum();
+ }
+
+ @Override
+ public Device.Type deviceType() {
+ return Device.Type.SWITCH;
+ }
+
+ @Override
+ public String toString() {
+ return this.getClass().getName() + " [" + ((channel != null)
+ ? channel.getRemoteAddress() : "?")
+ + " DPID[" + ((getStringId() != null) ? getStringId() : "?") + "]]";
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowAgent.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowAgent.java
new file mode 100644
index 00000000..ad6dede1
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowAgent.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+import org.onosproject.openflow.controller.Dpid;
+import org.onosproject.openflow.controller.OpenFlowSwitch;
+import org.onosproject.openflow.controller.RoleState;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+
+/**
+ * Responsible for keeping track of the current set of switches
+ * connected to the system. As well as whether they are in Master
+ * role or not.
+ *
+ */
+public interface OpenFlowAgent {
+
+ /**
+ * Add a switch that has just connected to the system.
+ * @param dpid the dpid to add
+ * @param sw the actual switch object.
+ * @return true if added, false otherwise.
+ */
+ boolean addConnectedSwitch(Dpid dpid, OpenFlowSwitch sw);
+
+ /**
+ * Checks if the activation for this switch is valid.
+ * @param dpid the dpid to check
+ * @return true if valid, false otherwise
+ */
+ boolean validActivation(Dpid dpid);
+
+ /**
+ * Called when a switch is activated, with this controller's role as MASTER.
+ * @param dpid the dpid to add.
+ * @param sw the actual switch
+ * @return true if added, false otherwise.
+ */
+ boolean addActivatedMasterSwitch(Dpid dpid, OpenFlowSwitch sw);
+
+ /**
+ * Called when a switch is activated, with this controller's role as EQUAL.
+ * @param dpid the dpid to add.
+ * @param sw the actual switch
+ * @return true if added, false otherwise.
+ */
+ boolean addActivatedEqualSwitch(Dpid dpid, OpenFlowSwitch sw);
+
+ /**
+ * Called when this controller's role for a switch transitions from equal
+ * to master. For 1.0 switches, we internally refer to the role 'slave' as
+ * 'equal' - so this transition is equivalent to 'addActivatedMasterSwitch'.
+ * @param dpid the dpid to transistion.
+ */
+ void transitionToMasterSwitch(Dpid dpid);
+
+ /**
+ * Called when this controller's role for a switch transitions to equal.
+ * For 1.0 switches, we internally refer to the role 'slave' as
+ * 'equal'.
+ * @param dpid the dpid to transistion.
+ */
+ void transitionToEqualSwitch(Dpid dpid);
+
+ /**
+ * Clear all state in controller switch maps for a switch that has
+ * disconnected from the local controller. Also release control for
+ * that switch from the global repository. Notify switch listeners.
+ * @param dpid the dpid to remove.
+ */
+ void removeConnectedSwitch(Dpid dpid);
+
+ /**
+ * Process a message coming from a switch.
+ *
+ * @param dpid the dpid the message came on.
+ * @param m the message to process
+ */
+ void processMessage(Dpid dpid, OFMessage m);
+
+ /**
+ * Notifies the controller that role assertion has failed.
+ *
+ * @param dpid the switch that failed role assertion
+ * @param requested the role controller requested
+ * @param response role reply from the switch
+ */
+ void returnRoleReply(Dpid dpid, RoleState requested, RoleState response);
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowSwitchDriver.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowSwitchDriver.java
new file mode 100644
index 00000000..b259388c
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowSwitchDriver.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+import org.jboss.netty.channel.Channel;
+import org.onosproject.net.driver.HandlerBehaviour;
+import org.onosproject.openflow.controller.Dpid;
+import org.onosproject.openflow.controller.OpenFlowSwitch;
+import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFErrorMsg;
+import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+
+import java.util.List;
+
+/**
+ * Represents the driver side of an OpenFlow switch.
+ * This interface should never be exposed to consumers.
+ *
+ */
+public interface OpenFlowSwitchDriver extends OpenFlowSwitch, HandlerBehaviour {
+
+ /**
+ * Sets the OpenFlow agent to be used. This method
+ * can only be called once.
+ * @param agent the agent to set.
+ */
+ void setAgent(OpenFlowAgent agent);
+
+ /**
+ * Sets the Role handler object.
+ * This method can only be called once.
+ * @param roleHandler the roleHandler class
+ */
+ void setRoleHandler(RoleHandler roleHandler);
+
+ /**
+ * Reasserts this controllers role to the switch.
+ * Useful in cases where the switch no longer agrees
+ * that this controller has the role it claims.
+ */
+ void reassertRole();
+
+ /**
+ * Handle the situation where the role request triggers an error.
+ * @param error the error to handle.
+ * @return true if handled, false if not.
+ */
+ boolean handleRoleError(OFErrorMsg error);
+
+ /**
+ * If this driver know of Nicira style role messages, these should
+ * be handled here.
+ * @param m the role message to handle.
+ * @throws SwitchStateException if the message received was
+ * not a nicira role or was malformed.
+ */
+ void handleNiciraRole(OFMessage m) throws SwitchStateException;
+
+ /**
+ * Handle OF 1.x (where x &gt; 0) role messages.
+ * @param m the role message to handle
+ * @throws SwitchStateException if the message received was
+ * not a nicira role or was malformed.
+ */
+ void handleRole(OFMessage m) throws SwitchStateException;
+
+ /**
+ * Announce to the OpenFlow agent that this switch has connected.
+ * @return true if successful, false if duplicate switch.
+ */
+ boolean connectSwitch();
+
+ /**
+ * Activate this MASTER switch-controller relationship in the OF agent.
+ * @return true is successful, false is switch has not
+ * connected or is unknown to the system.
+ */
+ boolean activateMasterSwitch();
+
+ /**
+ * Activate this EQUAL switch-controller relationship in the OF agent.
+ * @return true is successful, false is switch has not
+ * connected or is unknown to the system.
+ */
+ boolean activateEqualSwitch();
+
+ /**
+ * Transition this switch-controller relationship to an EQUAL state.
+ */
+ void transitionToEqualSwitch();
+
+ /**
+ * Transition this switch-controller relationship to an Master state.
+ */
+ void transitionToMasterSwitch();
+
+ /**
+ * Remove this switch from the openflow agent.
+ */
+ void removeConnectedSwitch();
+
+ /**
+ * Sets the ports on this switch.
+ * @param portDescReply the port set and descriptions
+ */
+ void setPortDescReply(OFPortDescStatsReply portDescReply);
+
+ /**
+ * Sets the ports on this switch.
+ * @param portDescReplies list of port set and descriptions
+ */
+ void setPortDescReplies(List<OFPortDescStatsReply> portDescReplies);
+
+ /**
+ * Sets the features reply for this switch.
+ * @param featuresReply the features to set.
+ */
+ void setFeaturesReply(OFFeaturesReply featuresReply);
+
+ /**
+ * Sets the switch description.
+ * @param desc the descriptions
+ */
+ void setSwitchDescription(OFDescStatsReply desc);
+
+ /**
+ * Gets the next transaction id to use.
+ * @return the xid
+ */
+ int getNextTransactionId();
+
+
+ /**
+ * Sets the OF version for this switch.
+ * @param ofV the version to set.
+ */
+ void setOFVersion(OFVersion ofV);
+
+ /**
+ * Sets this switch has having a full flowtable.
+ * @param full true if full, false otherswise.
+ */
+ void setTableFull(boolean full);
+
+ /**
+ * Sets the associated Netty channel for this switch.
+ * @param channel the Netty channel
+ */
+ void setChannel(Channel channel);
+
+ /**
+ * Sets whether the switch is connected.
+ *
+ * @param connected whether the switch is connected
+ */
+ void setConnected(boolean connected);
+
+ /**
+ * Initialises the behaviour.
+ * @param dpid a dpid
+ * @param desc a switch description
+ * @param ofv OpenFlow version
+ */
+ void init(Dpid dpid, OFDescStatsReply desc, OFVersion ofv);
+
+ /**
+ * Does this switch support Nicira Role messages.
+ * @return true if supports, false otherwise.
+ */
+ Boolean supportNxRole();
+
+
+ /**
+ * Starts the driver specific handshake process.
+ */
+ void startDriverHandshake();
+
+ /**
+ * Checks whether the driver specific handshake is complete.
+ * @return true is finished, false if not.
+ */
+ boolean isDriverHandshakeComplete();
+
+ /**
+ * Process a message during the driver specific handshake.
+ * @param m the message to process.
+ */
+ void processDriverHandshakeMessage(OFMessage m);
+
+ /**
+ * Sends only role request messages.
+ *
+ * @param message a role request message.
+ */
+ void sendRoleRequest(OFMessage message);
+
+ /**
+ * Allows the handshaker behaviour to send messages during the
+ * handshake phase only.
+ *
+ * @param message an OpenFlow message
+ */
+ void sendHandshakeMessage(OFMessage message);
+
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowSwitchDriverFactory.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowSwitchDriverFactory.java
new file mode 100644
index 00000000..a0d8f18f
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/OpenFlowSwitchDriverFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+import org.onosproject.openflow.controller.Dpid;
+import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+
+/**
+ * Switch factory which returns concrete switch objects for the
+ * physical openflow switch in use.
+ *
+ */
+public interface OpenFlowSwitchDriverFactory {
+
+
+ /**
+ * Constructs the real openflow switch representation.
+ * @param dpid the dpid for this switch.
+ * @param desc its description.
+ * @param ofv the OF version in use
+ * @return the openflow switch representation.
+ */
+ OpenFlowSwitchDriver getOFSwitchImpl(Dpid dpid,
+ OFDescStatsReply desc, OFVersion ofv);
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleHandler.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleHandler.java
new file mode 100644
index 00000000..b4068886
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleHandler.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+import java.io.IOException;
+
+import org.onosproject.openflow.controller.RoleState;
+import org.projectfloodlight.openflow.protocol.OFErrorMsg;
+import org.projectfloodlight.openflow.protocol.OFExperimenter;
+import org.projectfloodlight.openflow.protocol.OFRoleReply;
+
+/**
+ * Role handling.
+ *
+ */
+public interface RoleHandler {
+
+ /**
+ * Extract the role from an OFVendor message.
+ *
+ * Extract the role from an OFVendor message if the message is a
+ * Nicira role reply. Otherwise return null.
+ *
+ * @param experimenterMsg The vendor message to parse.
+ * @return The role in the message if the message is a Nicira role
+ * reply, null otherwise.
+ * @throws SwitchStateException If the message is a Nicira role reply
+ * but the numeric role value is unknown.
+ */
+ RoleState extractNiciraRoleReply(OFExperimenter experimenterMsg)
+ throws SwitchStateException;
+
+ /**
+ * Send a role request with the given role to the switch and update
+ * the pending request and timestamp.
+ * Sends an OFPT_ROLE_REQUEST to an OF1.3 switch, OR
+ * Sends an NX_ROLE_REQUEST to an OF1.0 switch if configured to support it
+ * in the IOFSwitch driver. If not supported, this method sends nothing
+ * and returns 'false'. The caller should take appropriate action.
+ *
+ * One other optimization we do here is that for OF1.0 switches with
+ * Nicira role message support, we force the Role.EQUAL to become
+ * Role.SLAVE, as there is no defined behavior for the Nicira role OTHER.
+ * We cannot expect it to behave like SLAVE. We don't have this problem with
+ * OF1.3 switches, because Role.EQUAL is well defined and we can simulate
+ * SLAVE behavior by using ASYNC messages.
+ *
+ * @param role role to request
+ * @param exp expectation
+ * @throws IOException when I/O exception of some sort has occurred
+ * @return false if and only if the switch does not support role-request
+ * messages, according to the switch driver; true otherwise.
+ */
+ boolean sendRoleRequest(RoleState role, RoleRecvStatus exp)
+ throws IOException;
+
+ /**
+ * Extract the role information from an OF1.3 Role Reply Message.
+ * @param rrmsg role reply message
+ * @return RoleReplyInfo object
+ * @throws SwitchStateException If unknown role encountered
+ */
+ RoleReplyInfo extractOFRoleReply(OFRoleReply rrmsg)
+ throws SwitchStateException;
+
+ /**
+ * Deliver a received role reply.
+ *
+ * Check if a request is pending and if the received reply matches the
+ * the expected pending reply (we check both role and xid) we set
+ * the role for the switch/channel.
+ *
+ * If a request is pending but doesn't match the reply we ignore it, and
+ * return
+ *
+ * If no request is pending we disconnect with a SwitchStateException
+ *
+ * @param rri information about role-reply in format that
+ * controller can understand.
+ * @return result comparing expected and received reply
+ * @throws SwitchStateException if no request is pending
+ */
+ RoleRecvStatus deliverRoleReply(RoleReplyInfo rri)
+ throws SwitchStateException;
+
+
+ /**
+ * Called if we receive an error message. If the xid matches the
+ * pending request we handle it otherwise we ignore it.
+ *
+ * Note: since we only keep the last pending request we might get
+ * error messages for earlier role requests that we won't be able
+ * to handle
+ * @param error error message
+ * @return result comparing expected and received reply
+ * @throws SwitchStateException if switch did not support requested role
+ */
+ RoleRecvStatus deliverError(OFErrorMsg error)
+ throws SwitchStateException;
+
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleRecvStatus.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleRecvStatus.java
new file mode 100644
index 00000000..88c4cc70
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleRecvStatus.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+/**
+ * When we remove a pending role request we use this enum to indicate how we
+ * arrived at the decision. When we send a role request to the switch, we
+ * also use this enum to indicate what we expect back from the switch, so the
+ * role changer can match the reply to our expectation.
+ */
+public enum RoleRecvStatus {
+ /** The switch returned an error indicating that roles are not.
+ * supported*/
+ UNSUPPORTED,
+ /** The request timed out. */
+ NO_REPLY,
+ /** The reply was old, there is a newer request pending. */
+ OLD_REPLY,
+ /**
+ * The reply's role matched the role that this controller set in the
+ * request message - invoked either initially at startup or to reassert
+ * current role.
+ */
+ MATCHED_CURRENT_ROLE,
+ /**
+ * The reply's role matched the role that this controller set in the
+ * request message - this is the result of a callback from the
+ * global registry, followed by a role request sent to the switch.
+ */
+ MATCHED_SET_ROLE,
+ /**
+ * The reply's role was a response to the query made by this controller.
+ */
+ REPLY_QUERY,
+ /** We received a role reply message from the switch
+ * but the expectation was unclear, or there was no expectation.
+ */
+ OTHER_EXPECTATION,
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleReplyInfo.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleReplyInfo.java
new file mode 100644
index 00000000..dc9b6bad
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/RoleReplyInfo.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+import org.onosproject.openflow.controller.RoleState;
+import org.projectfloodlight.openflow.types.U64;
+
+/**
+ * Helper class returns role reply information in the format understood
+ * by the controller.
+ */
+public class RoleReplyInfo {
+ private final RoleState role;
+ private final U64 genId;
+ private final long xid;
+
+ public RoleReplyInfo(RoleState role, U64 genId, long xid) {
+ this.role = role;
+ this.genId = genId;
+ this.xid = xid;
+ }
+ public RoleState getRole() {
+ return role;
+ }
+ public U64 getGenId() {
+ return genId;
+ }
+ public long getXid() {
+ return xid;
+ }
+ @Override
+ public String toString() {
+ return "[Role:" + role + " GenId:" + genId + " Xid:" + xid + "]";
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeAlreadyStarted.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeAlreadyStarted.java
new file mode 100644
index 00000000..96b4bd73
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeAlreadyStarted.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+/**
+ * Thrown when IOFSwitch.startDriverHandshake() is called more than once.
+ *
+ */
+public class SwitchDriverSubHandshakeAlreadyStarted extends
+ SwitchDriverSubHandshakeException {
+ private static final long serialVersionUID = -5491845708752443501L;
+
+ public SwitchDriverSubHandshakeAlreadyStarted() {
+ super();
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeCompleted.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeCompleted.java
new file mode 100644
index 00000000..b0f59fe5
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeCompleted.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+import org.projectfloodlight.openflow.protocol.OFMessage;
+
+
+/**
+ * Indicates that a message was passed to a switch driver's subhandshake
+ * handling code but the driver has already completed the sub-handshake.
+ *
+ */
+public class SwitchDriverSubHandshakeCompleted
+ extends SwitchDriverSubHandshakeException {
+ private static final long serialVersionUID = -8817822245846375995L;
+
+ public SwitchDriverSubHandshakeCompleted(OFMessage m) {
+ super("Sub-Handshake is already complete but received message "
+ + m.getType());
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeException.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeException.java
new file mode 100644
index 00000000..1bc750ab
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeException.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+/**
+ * Base class for exception thrown by switch driver sub-handshake processing.
+ *
+ */
+public class SwitchDriverSubHandshakeException extends RuntimeException {
+ private static final long serialVersionUID = -6257836781419604438L;
+
+ protected SwitchDriverSubHandshakeException() {
+ super();
+ }
+
+ protected SwitchDriverSubHandshakeException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ protected SwitchDriverSubHandshakeException(String arg0) {
+ super(arg0);
+ }
+
+ protected SwitchDriverSubHandshakeException(Throwable arg0) {
+ super(arg0);
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeNotStarted.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeNotStarted.java
new file mode 100644
index 00000000..a073683c
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeNotStarted.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+/**
+ * Thrown when a switch driver's sub-handshake has not been started but an
+ * operation requiring the sub-handshake has been attempted.
+ *
+ */
+public class SwitchDriverSubHandshakeNotStarted extends
+ SwitchDriverSubHandshakeException {
+ private static final long serialVersionUID = -5491845708752443501L;
+
+ public SwitchDriverSubHandshakeNotStarted() {
+ super();
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeStateException.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeStateException.java
new file mode 100644
index 00000000..3f4be813
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchDriverSubHandshakeStateException.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+/**
+ * Thrown when a switch driver's sub-handshake state-machine receives an
+ * unexpected OFMessage and/or is in an invald state.
+ *
+ */
+public class SwitchDriverSubHandshakeStateException extends
+ SwitchDriverSubHandshakeException {
+ private static final long serialVersionUID = -8249926069195147051L;
+
+ public SwitchDriverSubHandshakeStateException(String msg) {
+ super(msg);
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchStateException.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchStateException.java
new file mode 100644
index 00000000..30c4e917
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/SwitchStateException.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2014 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.openflow.controller.driver;
+
+/**
+ * This exception indicates an error or unexpected message during
+ * message handling. E.g., if an OFMessage is received that is illegal or
+ * unexpected given the current handshake state.
+ *
+ * We don't allow wrapping other exception in a switch state exception. We
+ * only log the SwitchStateExceptions message so the causing exceptions
+ * stack trace is generally not available.
+ *
+ */
+public class SwitchStateException extends Exception {
+
+ private static final long serialVersionUID = 9153954512470002631L;
+
+ public SwitchStateException() {
+ super();
+ }
+
+ public SwitchStateException(String arg0, Throwable arg1) {
+ super(arg0, arg1);
+ }
+
+ public SwitchStateException(String arg0) {
+ super(arg0);
+ }
+
+ public SwitchStateException(Throwable arg0) {
+ super(arg0);
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/package-info.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/package-info.java
new file mode 100644
index 00000000..c03a5840
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014 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.
+ */
+
+/**
+ * OpenFlow controller switch driver API.
+ */
+package org.onosproject.openflow.controller.driver;
diff --git a/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/package-info.java b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/package-info.java
new file mode 100644
index 00000000..54778426
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/main/java/org/onosproject/openflow/controller/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014 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.
+ */
+
+/**
+ * OpenFlow controller API.
+ */
+package org.onosproject.openflow.controller;
diff --git a/framework/src/onos/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/OpenflowControllerAdapter.java b/framework/src/onos/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/OpenflowControllerAdapter.java
new file mode 100644
index 00000000..f4fe490f
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/api/src/test/java/org/onosproject/openflow/controller/OpenflowControllerAdapter.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2014 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.openflow.controller;
+
+import org.projectfloodlight.openflow.protocol.OFMessage;
+
+/**
+ * Test adapter for the OpenFlow controller interface.
+ */
+public class OpenflowControllerAdapter implements OpenFlowController {
+ @Override
+ public Iterable<OpenFlowSwitch> getSwitches() {
+ return null;
+ }
+
+ @Override
+ public Iterable<OpenFlowSwitch> getMasterSwitches() {
+ return null;
+ }
+
+ @Override
+ public Iterable<OpenFlowSwitch> getEqualSwitches() {
+ return null;
+ }
+
+ @Override
+ public OpenFlowSwitch getSwitch(Dpid dpid) {
+ return null;
+ }
+
+ @Override
+ public OpenFlowSwitch getMasterSwitch(Dpid dpid) {
+ return null;
+ }
+
+ @Override
+ public OpenFlowSwitch getEqualSwitch(Dpid dpid) {
+ return null;
+ }
+
+ @Override
+ public void addListener(OpenFlowSwitchListener listener) {
+ }
+
+ @Override
+ public void removeListener(OpenFlowSwitchListener listener) {
+ }
+
+ @Override
+ public void addPacketListener(int priority, PacketListener listener) {
+ }
+
+ @Override
+ public void removePacketListener(PacketListener listener) {
+ }
+
+ @Override
+ public void write(Dpid dpid, OFMessage msg) {
+ }
+
+ @Override
+ public void processPacket(Dpid dpid, OFMessage msg) {
+ }
+
+ @Override
+ public void setRole(Dpid dpid, RoleState role) {
+ }
+
+ @Override
+ public void addEventListener(OpenFlowEventListener listener) {
+ }
+
+ @Override
+ public void removeEventListener(OpenFlowEventListener listener) {
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/pom.xml b/framework/src/onos/protocols/openflow/ctl/pom.xml
new file mode 100644
index 00000000..56d48550
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/pom.xml
@@ -0,0 +1,65 @@
+<!--
+ ~ Copyright 2014 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-of-ctl</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS OpenFlow controller subsystem API</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-of-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java
new file mode 100644
index 00000000..56b3a99c
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java
@@ -0,0 +1,328 @@
+/*
+ * Copyright 2014-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.openflow.controller.impl;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
+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.onlab.util.ItemNotFoundException;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.driver.DefaultDriverData;
+import org.onosproject.net.driver.DefaultDriverHandler;
+import org.onosproject.net.driver.Driver;
+import org.onosproject.net.driver.DriverService;
+import org.onosproject.openflow.controller.Dpid;
+import org.onosproject.openflow.controller.driver.OpenFlowAgent;
+import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
+import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFFactories;
+import org.projectfloodlight.openflow.protocol.OFFactory;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.TrustManagerFactory;
+import java.io.FileInputStream;
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.net.InetSocketAddress;
+import java.security.KeyStore;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.onlab.util.Tools.get;
+import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.net.DeviceId.deviceId;
+import static org.onosproject.openflow.controller.Dpid.uri;
+
+
+/**
+ * The main controller class. Handles all setup and network listeners
+ * - Distributed ownership control of switch through IControllerRegistryService
+ */
+public class Controller {
+
+ protected static final Logger log = LoggerFactory.getLogger(Controller.class);
+
+ protected static final OFFactory FACTORY13 = OFFactories.getFactory(OFVersion.OF_13);
+ protected static final OFFactory FACTORY10 = OFFactories.getFactory(OFVersion.OF_10);
+ private static final boolean TLS_DISABLED = false;
+ private static final short MIN_KS_LENGTH = 6;
+
+ protected HashMap<String, String> controllerNodeIPsCache;
+
+ private ChannelGroup cg;
+
+ // Configuration options
+ protected List<Integer> openFlowPorts = ImmutableList.of(6633, 6653);
+ protected int workerThreads = 16;
+
+ // Start time of the controller
+ protected long systemStartTime;
+
+ private OpenFlowAgent agent;
+
+ private NioServerSocketChannelFactory execFactory;
+
+ protected String ksLocation;
+ protected String tsLocation;
+ protected char[] ksPwd;
+ protected char[] tsPwd;
+ protected SSLEngine serverSslEngine;
+
+ // Perf. related configuration
+ protected static final int SEND_BUFFER_SIZE = 4 * 1024 * 1024;
+ private DriverService driverService;
+ private boolean enableOfTls = TLS_DISABLED;
+
+ // ***************
+ // Getters/Setters
+ // ***************
+
+ public OFFactory getOFMessageFactory10() {
+ return FACTORY10;
+ }
+
+
+ public OFFactory getOFMessageFactory13() {
+ return FACTORY13;
+ }
+
+ // **************
+ // Initialization
+ // **************
+
+ /**
+ * Tell controller that we're ready to accept switches loop.
+ */
+ 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 OpenflowPipelineFactory(this, null, serverSslEngine);
+ bootstrap.setPipelineFactory(pfact);
+ cg = new DefaultChannelGroup();
+ openFlowPorts.forEach(port -> {
+ InetSocketAddress sa = new InetSocketAddress(port);
+ cg.add(bootstrap.bind(sa));
+ log.info("Listening for switch connections on {}", sa);
+ });
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ private ServerBootstrap createServerBootStrap() {
+
+ if (workerThreads == 0) {
+ execFactory = new NioServerSocketChannelFactory(
+ Executors.newCachedThreadPool(groupedThreads("onos/of", "boss-%d")),
+ Executors.newCachedThreadPool(groupedThreads("onos/of", "worker-%d")));
+ return new ServerBootstrap(execFactory);
+ } else {
+ execFactory = new NioServerSocketChannelFactory(
+ Executors.newCachedThreadPool(groupedThreads("onos/of", "boss-%d")),
+ Executors.newCachedThreadPool(groupedThreads("onos/of", "worker-%d")), workerThreads);
+ return new ServerBootstrap(execFactory);
+ }
+ }
+
+ public void setConfigParams(Dictionary<?, ?> properties) {
+ String ports = get(properties, "openflowPorts");
+ if (!Strings.isNullOrEmpty(ports)) {
+ this.openFlowPorts = Stream.of(ports.split(","))
+ .map(s -> Integer.parseInt(s))
+ .collect(Collectors.toList());
+ }
+ log.debug("OpenFlow ports set to {}", this.openFlowPorts);
+
+ String threads = get(properties, "workerThreads");
+ if (!Strings.isNullOrEmpty(threads)) {
+ this.workerThreads = Integer.parseInt(threads);
+ }
+ log.debug("Number of worker threads set to {}", this.workerThreads);
+ }
+
+ /**
+ * Initialize internal data structures.
+ */
+ public void init() {
+ // These data structures are initialized here because other
+ // module's startUp() might be called before ours
+ this.controllerNodeIPsCache = new HashMap<>();
+
+ this.systemStartTime = System.currentTimeMillis();
+
+ try {
+ getTlsParameters();
+ if (enableOfTls) {
+ initSsl();
+ }
+ } catch (Exception ex) {
+ log.error("SSL init failed: {}", ex.getMessage());
+ }
+
+ }
+
+ private void getTlsParameters() {
+ String tempString = System.getProperty("enableOFTLS");
+ enableOfTls = Strings.isNullOrEmpty(tempString) ? TLS_DISABLED : Boolean.parseBoolean(tempString);
+ log.info("OpenFlow Security is {}", enableOfTls ? "enabled" : "disabled");
+ if (enableOfTls) {
+ ksLocation = System.getProperty("javax.net.ssl.keyStore");
+ if (Strings.isNullOrEmpty(ksLocation)) {
+ enableOfTls = TLS_DISABLED;
+ return;
+ }
+ tsLocation = System.getProperty("javax.net.ssl.trustStore");
+ if (Strings.isNullOrEmpty(tsLocation)) {
+ enableOfTls = TLS_DISABLED;
+ return;
+ }
+ ksPwd = System.getProperty("javax.net.ssl.keyStorePassword").toCharArray();
+ if (MIN_KS_LENGTH > ksPwd.length) {
+ enableOfTls = TLS_DISABLED;
+ return;
+ }
+ tsPwd = System.getProperty("javax.net.ssl.trustStorePassword").toCharArray();
+ if (MIN_KS_LENGTH > tsPwd.length) {
+ enableOfTls = TLS_DISABLED;
+ return;
+ }
+ }
+ }
+
+ private void initSsl() throws Exception {
+
+ TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ KeyStore ts = KeyStore.getInstance("JKS");
+ ts.load(new FileInputStream(tsLocation), tsPwd);
+ tmFactory.init(ts);
+
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ KeyStore ks = KeyStore.getInstance("JKS");
+ ks.load(new FileInputStream(ksLocation), ksPwd);
+ kmf.init(ks, ksPwd);
+
+ SSLContext serverContext = SSLContext.getInstance("TLS");
+ serverContext.init(kmf.getKeyManagers(), tmFactory.getTrustManagers(), null);
+
+ serverSslEngine = serverContext.createSSLEngine();
+
+ serverSslEngine.setNeedClientAuth(true);
+ serverSslEngine.setUseClientMode(false);
+ serverSslEngine.setEnabledProtocols(serverSslEngine.getSupportedProtocols());
+ serverSslEngine.setEnabledCipherSuites(serverSslEngine.getSupportedCipherSuites());
+ serverSslEngine.setEnableSessionCreation(true);
+ }
+
+ // **************
+ // Utility methods
+ // **************
+
+ public Map<String, Long> getMemory() {
+ Map<String, Long> m = new HashMap<>();
+ Runtime runtime = Runtime.getRuntime();
+ m.put("total", runtime.totalMemory());
+ m.put("free", runtime.freeMemory());
+ return m;
+ }
+
+
+ public Long getSystemUptime() {
+ RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
+ return rb.getUptime();
+ }
+
+ public long getSystemStartTime() {
+ return (this.systemStartTime);
+ }
+
+ /**
+ * Forward to the driver-manager to get an IOFSwitch instance.
+ *
+ * @param dpid data path id
+ * @param desc switch description
+ * @param ofv OpenFlow version
+ * @return switch instance
+ */
+ protected OpenFlowSwitchDriver getOFSwitchInstance(long dpid,
+ OFDescStatsReply desc,
+ OFVersion ofv) {
+ Dpid dpidObj = new Dpid(dpid);
+
+ Driver driver;
+ try {
+ driver = driverService.getDriver(DeviceId.deviceId(Dpid.uri(dpidObj)));
+ } catch (ItemNotFoundException e) {
+ driver = driverService.getDriver(desc.getMfrDesc(), desc.getHwDesc(), desc.getSwDesc());
+ }
+
+ if (driver != null && driver.hasBehaviour(OpenFlowSwitchDriver.class)) {
+ Dpid did = new Dpid(dpid);
+ DefaultDriverHandler handler =
+ new DefaultDriverHandler(new DefaultDriverData(driver, deviceId(uri(did))));
+ OpenFlowSwitchDriver ofSwitchDriver =
+ driver.createBehaviour(handler, OpenFlowSwitchDriver.class);
+ ofSwitchDriver.init(did, desc, ofv);
+ ofSwitchDriver.setAgent(agent);
+ ofSwitchDriver.setRoleHandler(new RoleManager(ofSwitchDriver));
+ log.info("OpenFlow handshaker found for device {}: {}", dpid, ofSwitchDriver);
+ return ofSwitchDriver;
+ }
+ log.error("No OpenFlow driver for {} : {}", dpid, desc);
+ return null;
+
+ }
+
+ public void start(OpenFlowAgent ag, DriverService driverService) {
+ log.info("Starting OpenFlow IO");
+ this.agent = ag;
+ this.driverService = driverService;
+ this.init();
+ this.run();
+ }
+
+
+ public void stop() {
+ log.info("Stopping OpenFlow IO");
+ cg.close();
+ execFactory.shutdown();
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/HandshakeTimeoutException.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/HandshakeTimeoutException.java
new file mode 100644
index 00000000..bbe307be
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/HandshakeTimeoutException.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2014 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.openflow.controller.impl;
+
+/**
+ * Exception is thrown when the handshake fails to complete.
+ * before a specified time
+ *
+ */
+public class HandshakeTimeoutException extends Exception {
+
+ private static final long serialVersionUID = 6859880268940337312L;
+
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/HandshakeTimeoutHandler.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/HandshakeTimeoutHandler.java
new file mode 100644
index 00000000..fbbe3428
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/HandshakeTimeoutHandler.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2014 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.openflow.controller.impl;
+
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelStateEvent;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
+import org.jboss.netty.util.Timeout;
+import org.jboss.netty.util.Timer;
+import org.jboss.netty.util.TimerTask;
+
+/**
+ * Trigger a timeout if a switch fails to complete handshake soon enough.
+ */
+public class HandshakeTimeoutHandler
+ extends SimpleChannelUpstreamHandler {
+ static final HandshakeTimeoutException EXCEPTION =
+ new HandshakeTimeoutException();
+
+ final OFChannelHandler channelHandler;
+ final Timer timer;
+ final long timeoutNanos;
+ volatile Timeout timeout;
+
+ public HandshakeTimeoutHandler(OFChannelHandler channelHandler,
+ Timer timer,
+ long timeoutSeconds) {
+ super();
+ this.channelHandler = channelHandler;
+ this.timer = timer;
+ this.timeoutNanos = TimeUnit.SECONDS.toNanos(timeoutSeconds);
+
+ }
+
+ @Override
+ public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
+ throws Exception {
+ if (timeoutNanos > 0) {
+ timeout = timer.newTimeout(new HandshakeTimeoutTask(ctx),
+ timeoutNanos, TimeUnit.NANOSECONDS);
+ }
+ ctx.sendUpstream(e);
+ }
+
+ @Override
+ public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e)
+ throws Exception {
+ if (timeout != null) {
+ timeout.cancel();
+ timeout = null;
+ }
+ }
+
+ private final class HandshakeTimeoutTask implements TimerTask {
+
+ private final ChannelHandlerContext ctx;
+
+ HandshakeTimeoutTask(ChannelHandlerContext ctx) {
+ this.ctx = ctx;
+ }
+
+ @Override
+ public void run(Timeout t) throws Exception {
+ if (t.isCancelled()) {
+ return;
+ }
+
+ if (!ctx.getChannel().isOpen()) {
+ return;
+ }
+ if (!channelHandler.isHandshakeComplete()) {
+ Channels.fireExceptionCaught(ctx, EXCEPTION);
+ }
+ }
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java
new file mode 100644
index 00000000..ff92b77e
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java
@@ -0,0 +1,1320 @@
+/*
+ * Copyright 2014-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.
+ */
+
+//CHECKSTYLE:OFF
+package org.onosproject.openflow.controller.impl;
+
+import java.io.IOException;
+import java.nio.channels.ClosedChannelException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+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.IdleStateAwareChannelHandler;
+import org.jboss.netty.handler.timeout.IdleStateEvent;
+import org.jboss.netty.handler.timeout.ReadTimeoutException;
+import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
+import org.onosproject.openflow.controller.driver.SwitchStateException;
+import org.projectfloodlight.openflow.exceptions.OFParseError;
+import org.projectfloodlight.openflow.protocol.OFAsyncGetReply;
+import org.projectfloodlight.openflow.protocol.OFBadRequestCode;
+import org.projectfloodlight.openflow.protocol.OFBarrierReply;
+import org.projectfloodlight.openflow.protocol.OFBarrierRequest;
+import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFDescStatsRequest;
+import org.projectfloodlight.openflow.protocol.OFEchoReply;
+import org.projectfloodlight.openflow.protocol.OFEchoRequest;
+import org.projectfloodlight.openflow.protocol.OFErrorMsg;
+import org.projectfloodlight.openflow.protocol.OFErrorType;
+import org.projectfloodlight.openflow.protocol.OFExperimenter;
+import org.projectfloodlight.openflow.protocol.OFFactory;
+import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
+import org.projectfloodlight.openflow.protocol.OFFlowModFailedCode;
+import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
+import org.projectfloodlight.openflow.protocol.OFGetConfigReply;
+import org.projectfloodlight.openflow.protocol.OFGetConfigRequest;
+import org.projectfloodlight.openflow.protocol.OFHello;
+import org.projectfloodlight.openflow.protocol.OFHelloElem;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFPacketIn;
+import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFPortDescStatsRequest;
+import org.projectfloodlight.openflow.protocol.OFPortStatus;
+import org.projectfloodlight.openflow.protocol.OFQueueGetConfigReply;
+import org.projectfloodlight.openflow.protocol.OFRoleReply;
+import org.projectfloodlight.openflow.protocol.OFSetConfig;
+import org.projectfloodlight.openflow.protocol.OFStatsReply;
+import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
+import org.projectfloodlight.openflow.protocol.OFStatsType;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg;
+import org.projectfloodlight.openflow.protocol.errormsg.OFFlowModFailedErrorMsg;
+import org.projectfloodlight.openflow.types.U32;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Channel handler deals with the switch connection and dispatches
+ * switch messages to the appropriate locations.
+ */
+class OFChannelHandler extends IdleStateAwareChannelHandler {
+ private static final Logger log = LoggerFactory.getLogger(OFChannelHandler.class);
+
+ private static final String RESET_BY_PEER = "Connection reset by peer";
+ private static final String BROKEN_PIPE = "Broken pipe";
+
+ private final Controller controller;
+ private OpenFlowSwitchDriver sw;
+ private long thisdpid; // channelHandler cached value of connected switch id
+ private Channel channel;
+ // State needs to be volatile because the HandshakeTimeoutHandler
+ // needs to check if the handshake is complete
+ private volatile ChannelState state;
+
+ // When a switch with a duplicate dpid is found (i.e we already have a
+ // connected switch with the same dpid), the new switch is immediately
+ // disconnected. At that point netty callsback channelDisconnected() which
+ // proceeds to cleaup switch state - we need to ensure that it does not cleanup
+ // switch state for the older (still connected) switch
+ private volatile Boolean duplicateDpidFound;
+
+ // Temporary storage for switch-features and port-description
+ private OFFeaturesReply featuresReply;
+ private List<OFPortDescStatsReply> portDescReplies;
+ //private OFPortDescStatsReply portDescReply;
+ // a concurrent ArrayList to temporarily store port status messages
+ // before we are ready to deal with them
+ private final CopyOnWriteArrayList<OFPortStatus> pendingPortStatusMsg;
+
+ //Indicates the openflow version used by this switch
+ protected OFVersion ofVersion;
+ protected OFFactory factory13;
+ protected OFFactory factory10;
+
+ /** transaction Ids to use during handshake. Since only one thread
+ * calls into an OFChannelHandler instance, we don't need atomic.
+ * We will count down
+ */
+ private int handshakeTransactionIds = -1;
+
+ /**
+ * Create a new unconnected OFChannelHandler.
+ * @param controller parent controller
+ */
+ OFChannelHandler(Controller controller) {
+ this.controller = controller;
+ this.state = ChannelState.INIT;
+ this.pendingPortStatusMsg = new CopyOnWriteArrayList<OFPortStatus>();
+ this.portDescReplies = new ArrayList<OFPortDescStatsReply>();
+ factory13 = controller.getOFMessageFactory13();
+ factory10 = controller.getOFMessageFactory10();
+ duplicateDpidFound = Boolean.FALSE;
+ }
+
+
+
+ // XXX S consider if necessary
+ public void disconnectSwitch() {
+ sw.disconnectSwitch();
+ }
+
+
+
+ //*************************
+ // Channel State Machine
+ //*************************
+
+ /**
+ * The state machine for handling the switch/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) {
+ @Override
+ void processOFMessage(OFChannelHandler h, OFMessage m)
+ throws IOException, SwitchStateException {
+ illegalMessageReceived(h, m);
+ }
+
+ @Override
+ void processOFError(OFChannelHandler h, OFErrorMsg m)
+ throws IOException {
+ // need to implement since its abstract but it will never
+ // be called
+ }
+
+ @Override
+ void processOFPortStatus(OFChannelHandler h, OFPortStatus m)
+ throws IOException {
+ unhandledMessageReceived(h, m);
+ }
+ },
+
+ /**
+ * We send a OF 1.3 HELLO to the switch and wait for a Hello from the switch.
+ * Once we receive the reply, we decide on OF 1.3 or 1.0 switch - no other
+ * protocol version is accepted.
+ * We send an OFFeaturesRequest depending on the protocol version selected
+ * Next state is WAIT_FEATURES_REPLY
+ */
+ WAIT_HELLO(false) {
+ @Override
+ void processOFHello(OFChannelHandler h, OFHello m)
+ throws IOException {
+ // TODO We could check for the optional bitmap, but for now
+ // we are just checking the version number.
+ if (m.getVersion().getWireVersion() >= OFVersion.OF_13.getWireVersion()) {
+ log.debug("Received {} Hello from {} - switching to OF "
+ + "version 1.3", m.getVersion(),
+ h.channel.getRemoteAddress());
+ h.sendHandshakeHelloMessage();
+ h.ofVersion = OFVersion.OF_13;
+ } else if (m.getVersion().getWireVersion() >= OFVersion.OF_10.getWireVersion()) {
+ log.debug("Received {} Hello from {} - switching to OF "
+ + "version 1.0", m.getVersion(),
+ h.channel.getRemoteAddress());
+ OFHello hi =
+ h.factory10.buildHello()
+ .setXid(h.handshakeTransactionIds--)
+ .build();
+ h.channel.write(Collections.singletonList(hi));
+ h.ofVersion = OFVersion.OF_10;
+ } else {
+ log.error("Received Hello of version {} from switch at {}. "
+ + "This controller works with OF1.0 and OF1.3 "
+ + "switches. Disconnecting switch ...",
+ m.getVersion(), h.channel.getRemoteAddress());
+ h.channel.disconnect();
+ return;
+ }
+ h.sendHandshakeFeaturesRequestMessage();
+ h.setState(WAIT_FEATURES_REPLY);
+ }
+ @Override
+ void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
+ throws IOException, SwitchStateException {
+ illegalMessageReceived(h, m);
+ }
+ @Override
+ void processOFStatisticsReply(OFChannelHandler h,
+ OFStatsReply m)
+ throws IOException, SwitchStateException {
+ illegalMessageReceived(h, m);
+ }
+ @Override
+ void processOFError(OFChannelHandler h, OFErrorMsg m) {
+ logErrorDisconnect(h, m);
+ }
+
+ @Override
+ void processOFPortStatus(OFChannelHandler h, OFPortStatus m)
+ throws IOException {
+ unhandledMessageReceived(h, m);
+ }
+ },
+
+
+ /**
+ * We are waiting for a features reply message. Once we receive it, the
+ * behavior depends on whether this is a 1.0 or 1.3 switch. For 1.0,
+ * we send a SetConfig request, barrier, and GetConfig request and the
+ * next state is WAIT_CONFIG_REPLY. For 1.3, we send a Port description
+ * request and the next state is WAIT_PORT_DESC_REPLY.
+ */
+ WAIT_FEATURES_REPLY(false) {
+ @Override
+ void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
+ throws IOException {
+ h.thisdpid = m.getDatapathId().getLong();
+ log.debug("Received features reply for switch at {} with dpid {}",
+ h.getSwitchInfoString(), h.thisdpid);
+
+ h.featuresReply = m; //temp store
+ if (h.ofVersion == OFVersion.OF_10) {
+ h.sendHandshakeSetConfig();
+ h.setState(WAIT_CONFIG_REPLY);
+ } else {
+ //version is 1.3, must get switchport information
+ h.sendHandshakeOFPortDescRequest();
+ h.setState(WAIT_PORT_DESC_REPLY);
+ }
+ }
+ @Override
+ void processOFStatisticsReply(OFChannelHandler h,
+ OFStatsReply m)
+ throws IOException, SwitchStateException {
+ illegalMessageReceived(h, m);
+ }
+ @Override
+ void processOFError(OFChannelHandler h, OFErrorMsg m) {
+ logErrorDisconnect(h, m);
+ }
+
+ @Override
+ void processOFPortStatus(OFChannelHandler h, OFPortStatus m)
+ throws IOException {
+ h.pendingPortStatusMsg.add(m);
+ }
+ },
+
+ /**
+ * We are waiting for a description of the 1.3 switch ports.
+ * Once received, we send a SetConfig request
+ * Next State is WAIT_CONFIG_REPLY
+ */
+ WAIT_PORT_DESC_REPLY(false) {
+
+ @Override
+ void processOFStatisticsReply(OFChannelHandler h, OFStatsReply m)
+ throws SwitchStateException {
+ // Read port description
+ if (m.getStatsType() != OFStatsType.PORT_DESC) {
+ log.warn("Expecting port description stats but received stats "
+ + "type {} from {}. Ignoring ...", m.getStatsType(),
+ h.channel.getRemoteAddress());
+ return;
+ }
+ if (m.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+ log.debug("Stats reply indicates more stats from sw {} for "
+ + "port description",
+ h.getSwitchInfoString());
+ h.portDescReplies.add((OFPortDescStatsReply)m);
+ return;
+ }
+ else {
+ h.portDescReplies.add((OFPortDescStatsReply)m);
+ }
+ //h.portDescReply = (OFPortDescStatsReply) m; // temp store
+ log.info("Received port desc reply for switch at {}",
+ h.getSwitchInfoString());
+ try {
+ h.sendHandshakeSetConfig();
+ } catch (IOException e) {
+ log.error("Unable to send setConfig after PortDescReply. "
+ + "Error: {}", e.getMessage());
+ }
+ h.setState(WAIT_CONFIG_REPLY);
+ }
+
+ @Override
+ void processOFError(OFChannelHandler h, OFErrorMsg m)
+ throws IOException, SwitchStateException {
+ logErrorDisconnect(h, m);
+
+ }
+
+ @Override
+ void processOFPortStatus(OFChannelHandler h, OFPortStatus m)
+ throws IOException, SwitchStateException {
+ h.pendingPortStatusMsg.add(m);
+
+ }
+ },
+
+ /**
+ * We are waiting for a config reply message. Once we receive it
+ * we send a DescriptionStatsRequest to the switch.
+ * Next state: WAIT_DESCRIPTION_STAT_REPLY
+ */
+ WAIT_CONFIG_REPLY(false) {
+ @Override
+ void processOFGetConfigReply(OFChannelHandler h, OFGetConfigReply m)
+ throws IOException {
+ if (m.getMissSendLen() == 0xffff) {
+ log.trace("Config Reply from switch {} confirms "
+ + "miss length set to 0xffff",
+ h.getSwitchInfoString());
+ } else {
+ // FIXME: we can't really deal with switches that don't send
+ // full packets. Shouldn't we drop the connection here?
+ log.warn("Config Reply from switch {} has"
+ + "miss length set to {}",
+ h.getSwitchInfoString(),
+ m.getMissSendLen());
+ }
+ h.sendHandshakeDescriptionStatsRequest();
+ h.setState(WAIT_DESCRIPTION_STAT_REPLY);
+ }
+
+ @Override
+ void processOFBarrierReply(OFChannelHandler h, OFBarrierReply m) {
+ // do nothing;
+ }
+
+ @Override
+ void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
+ throws IOException, SwitchStateException {
+ illegalMessageReceived(h, m);
+ }
+ @Override
+ void processOFStatisticsReply(OFChannelHandler h,
+ OFStatsReply m)
+ throws IOException, SwitchStateException {
+ log.error("Received multipart(stats) message sub-type {}",
+ m.getStatsType());
+ illegalMessageReceived(h, m);
+ }
+
+ @Override
+ void processOFError(OFChannelHandler h, OFErrorMsg m) {
+ logErrorDisconnect(h, m);
+ }
+
+ @Override
+ void processOFPortStatus(OFChannelHandler h, OFPortStatus m)
+ throws IOException {
+ h.pendingPortStatusMsg.add(m);
+ }
+ },
+
+
+ /**
+ * We are waiting for a OFDescriptionStat message from the switch.
+ * Once we receive any stat message we try to parse it. If it's not
+ * a description stats message we disconnect. If its the expected
+ * description stats message, we:
+ * - use the switch driver to bind the switch and get an IOFSwitch instance
+ * - setup the IOFSwitch instance
+ * - add switch controller and send the initial role
+ * request to the switch.
+ * Next state: WAIT_INITIAL_ROLE
+ * In the typical case, where switches support role request messages
+ * the next state is where we expect the role reply message.
+ * In the special case that where the switch does not support any kind
+ * of role request messages, we don't send a role message, but we do
+ * request mastership from the registry service. This controller
+ * should become master once we hear back from the registry service.
+ * All following states will have a h.sw instance!
+ */
+ WAIT_DESCRIPTION_STAT_REPLY(false) {
+ @Override
+ void processOFStatisticsReply(OFChannelHandler h, OFStatsReply m)
+ throws SwitchStateException {
+ // Read description, if it has been updated
+ if (m.getStatsType() != OFStatsType.DESC) {
+ log.warn("Expecting Description stats but received stats "
+ + "type {} from {}. Ignoring ...", m.getStatsType(),
+ h.channel.getRemoteAddress());
+ return;
+ }
+ OFDescStatsReply drep = (OFDescStatsReply) m;
+ log.info("Received switch description reply {} from switch at {}",
+ drep, h.channel.getRemoteAddress());
+ // Here is where we differentiate between different kinds of switches
+ h.sw = h.controller.getOFSwitchInstance(h.thisdpid, drep, h.ofVersion);
+
+ h.sw.setOFVersion(h.ofVersion);
+ h.sw.setFeaturesReply(h.featuresReply);
+ //h.sw.setPortDescReply(h.portDescReply);
+ h.sw.setPortDescReplies(h.portDescReplies);
+ h.sw.setConnected(true);
+ h.sw.setChannel(h.channel);
+// boolean success = h.sw.connectSwitch();
+//
+// if (!success) {
+// disconnectDuplicate(h);
+// return;
+// }
+ // set switch information
+
+
+
+ log.debug("Switch {} bound to class {}, description {}",
+ h.sw, h.sw.getClass(), drep);
+ //Put switch in EQUAL mode until we hear back from the global registry
+ //log.debug("Setting new switch {} to EQUAL and sending Role request",
+ // h.sw.getStringId());
+ //h.sw.activateEqualSwitch();
+ //h.setSwitchRole(RoleState.EQUAL);
+
+ h.sw.startDriverHandshake();
+ if (h.sw.isDriverHandshakeComplete()) {
+ if (!h.sw.connectSwitch()) {
+ disconnectDuplicate(h);
+ }
+ handlePendingPortStatusMessages(h);
+ h.setState(ACTIVE);
+ } else {
+ h.setState(WAIT_SWITCH_DRIVER_SUB_HANDSHAKE);
+ }
+
+ }
+
+ @Override
+ void processOFError(OFChannelHandler h, OFErrorMsg m) {
+ logErrorDisconnect(h, m);
+ }
+
+ @Override
+ void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
+ throws IOException, SwitchStateException {
+ illegalMessageReceived(h, m);
+ }
+
+ @Override
+ void processOFPortStatus(OFChannelHandler h, OFPortStatus m)
+ throws IOException {
+ h.pendingPortStatusMsg.add(m);
+ }
+ },
+
+
+ /**
+ * We are waiting for the respective switch driver to complete its
+ * configuration. Notice that we do not consider this to be part of the main
+ * switch-controller handshake. But we do consider it as a step that comes
+ * before we declare the switch as available to the controller.
+ * Next State: depends on the role of this controller for this switch - either
+ * MASTER or EQUAL.
+ */
+ WAIT_SWITCH_DRIVER_SUB_HANDSHAKE(true) {
+
+ @Override
+ void processOFError(OFChannelHandler h, OFErrorMsg m)
+ throws IOException {
+ // will never be called. We override processOFMessage
+ }
+
+
+
+ @Override
+ void processOFMessage(OFChannelHandler h, OFMessage m)
+ throws IOException, SwitchStateException {
+
+ if (h.sw.isDriverHandshakeComplete()) {
+ moveToActive(h);
+ h.state.processOFMessage(h, m);
+ return;
+
+ }
+
+ if (m.getType() == OFType.ECHO_REQUEST) {
+ processOFEchoRequest(h, (OFEchoRequest) m);
+ } else if (m.getType() == OFType.ECHO_REPLY) {
+ processOFEchoReply(h, (OFEchoReply) m);
+ } else if (m.getType() == OFType.ROLE_REPLY) {
+ h.sw.handleRole(m);
+ } else if (m.getType() == OFType.ERROR) {
+ if (!h.sw.handleRoleError((OFErrorMsg)m)) {
+ h.sw.processDriverHandshakeMessage(m);
+ if (h.sw.isDriverHandshakeComplete()) {
+ moveToActive(h);
+ }
+ }
+ } else {
+ if (m.getType() == OFType.EXPERIMENTER &&
+ ((OFExperimenter) m).getExperimenter() ==
+ RoleManager.NICIRA_EXPERIMENTER) {
+ h.sw.handleNiciraRole(m);
+ } else {
+ h.sw.processDriverHandshakeMessage(m);
+ if (h.sw.isDriverHandshakeComplete()) {
+ moveToActive(h);
+ }
+ }
+ }
+ }
+
+ @Override
+ void processOFPortStatus(OFChannelHandler h, OFPortStatus m)
+ throws IOException, SwitchStateException {
+ h.pendingPortStatusMsg.add(m);
+ }
+
+ private void moveToActive(OFChannelHandler h) {
+ boolean success = h.sw.connectSwitch();
+ handlePendingPortStatusMessages(h);
+ h.setState(ACTIVE);
+ if (!success) {
+ disconnectDuplicate(h);
+ }
+ }
+
+ },
+
+
+ /**
+ * This controller is in MASTER role for this switch. We enter this state
+ * after requesting and winning control from the global registry.
+ * The main handshake as well as the switch-driver sub-handshake
+ * is complete at this point.
+ * // XXX S reconsider below
+ * In the (near) future we may deterministically assign controllers to
+ * switches at startup.
+ * We only leave this state if the switch disconnects or
+ * if we send a role request for SLAVE /and/ receive the role reply for
+ * SLAVE.
+ */
+ ACTIVE(true) {
+ @Override
+ void processOFError(OFChannelHandler h, OFErrorMsg m)
+ throws IOException, SwitchStateException {
+ // if we get here, then the error message is for something else
+ if (m.getErrType() == OFErrorType.BAD_REQUEST &&
+ ((OFBadRequestErrorMsg) m).getCode() ==
+ OFBadRequestCode.EPERM) {
+ // We are the master controller and the switch returned
+ // a permission error. This is a likely indicator that
+ // the switch thinks we are slave. Reassert our
+ // role
+ // FIXME: this could be really bad during role transitions
+ // if two controllers are master (even if its only for
+ // a brief period). We might need to see if these errors
+ // persist before we reassert
+
+ h.sw.reassertRole();
+ } else if (m.getErrType() == OFErrorType.FLOW_MOD_FAILED &&
+ ((OFFlowModFailedErrorMsg) m).getCode() ==
+ OFFlowModFailedCode.ALL_TABLES_FULL) {
+ h.sw.setTableFull(true);
+ } else {
+ logError(h, m);
+ }
+ h.dispatchMessage(m);
+ }
+
+ @Override
+ void processOFStatisticsReply(OFChannelHandler h,
+ OFStatsReply m) {
+ if (m.getStatsType().equals(OFStatsType.PORT_DESC)) {
+ h.sw.setPortDescReply((OFPortDescStatsReply) m);
+ }
+ h.dispatchMessage(m);
+ }
+
+ @Override
+ void processOFExperimenter(OFChannelHandler h, OFExperimenter m)
+ throws SwitchStateException {
+ h.sw.handleNiciraRole(m);
+ }
+
+ @Override
+ void processOFRoleReply(OFChannelHandler h, OFRoleReply m)
+ throws SwitchStateException {
+ h.sw.handleRole(m);
+ }
+
+ @Override
+ void processOFPortStatus(OFChannelHandler h, OFPortStatus m)
+ throws SwitchStateException {
+ handlePortStatusMessage(h, m, true);
+ //h.dispatchMessage(m);
+ }
+
+ @Override
+ void processOFPacketIn(OFChannelHandler h, OFPacketIn m) {
+// OFPacketOut out =
+// h.sw.factory().buildPacketOut()
+// .setXid(m.getXid())
+// .setBufferId(m.getBufferId()).build();
+// h.sw.sendMsg(out);
+ h.dispatchMessage(m);
+ }
+
+ @Override
+ void processOFFlowRemoved(OFChannelHandler h,
+ OFFlowRemoved m) {
+ h.dispatchMessage(m);
+ }
+
+ @Override
+ void processOFBarrierReply(OFChannelHandler h, OFBarrierReply m) {
+ h.dispatchMessage(m);
+ }
+
+ @Override
+ void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m) {
+ h.sw.setFeaturesReply(m);
+ h.dispatchMessage(m);
+ }
+
+ };
+
+ private final boolean handshakeComplete;
+ ChannelState(boolean handshakeComplete) {
+ this.handshakeComplete = handshakeComplete;
+ }
+
+ /**
+ * Is this a state in which the handshake has completed?
+ * @return true if the handshake is complete
+ */
+ public boolean isHandshakeComplete() {
+ return handshakeComplete;
+ }
+
+ /**
+ * Get a string specifying the switch connection, state, and
+ * message received. To be used as message for SwitchStateException
+ * or log messages
+ * @param h The channel handler (to get switch information_
+ * @param m The OFMessage that has just been received
+ * @param details A string giving more details about the exact nature
+ * of the problem.
+ * @return display string
+ */
+ // needs to be protected because enum members are actually subclasses
+ protected String getSwitchStateMessage(OFChannelHandler h,
+ OFMessage m,
+ String details) {
+ return String.format("Switch: [%s], State: [%s], received: [%s]"
+ + ", details: %s",
+ h.getSwitchInfoString(),
+ this.toString(),
+ m.getType().toString(),
+ details);
+ }
+
+ /**
+ * We have an OFMessage we didn't expect given the current state and
+ * we want to treat this as an error.
+ * We currently throw an exception that will terminate the connection
+ * However, we could be more forgiving
+ * @param h the channel handler that received the message
+ * @param m the message
+ * @throws SwitchStateException we always throw the exception
+ */
+ // needs to be protected because enum members are actually subclasses
+ protected void illegalMessageReceived(OFChannelHandler h, OFMessage m)
+ throws SwitchStateException {
+ String msg = getSwitchStateMessage(h, m,
+ "Switch should never send this message in the current state");
+ throw new SwitchStateException(msg);
+
+ }
+
+ /**
+ * We have an OFMessage we didn't expect given the current state and
+ * we want to ignore the message.
+ * @param h the channel handler the received the message
+ * @param m the message
+ */
+ protected void unhandledMessageReceived(OFChannelHandler h,
+ OFMessage m) {
+ if (log.isDebugEnabled()) {
+ String msg = getSwitchStateMessage(h, m,
+ "Ignoring unexpected message");
+ log.debug(msg);
+ }
+ }
+
+ /**
+ * Log an OpenFlow error message from a switch.
+ * @param h The switch that sent the error
+ * @param error The error message
+ */
+ protected void logError(OFChannelHandler h, OFErrorMsg error) {
+ log.error("{} from switch {} in state {}",
+ error,
+ h.getSwitchInfoString(),
+ this.toString());
+ }
+
+ /**
+ * Log an OpenFlow error message from a switch and disconnect the
+ * channel.
+ *
+ * @param h the IO channel for this switch.
+ * @param error The error message
+ */
+ protected void logErrorDisconnect(OFChannelHandler h, OFErrorMsg error) {
+ logError(h, error);
+ h.channel.disconnect();
+ }
+
+ /**
+ * log an error message for a duplicate dpid and disconnect this channel.
+ * @param h the IO channel for this switch.
+ */
+ protected void disconnectDuplicate(OFChannelHandler h) {
+ log.error("Duplicated dpid or incompleted cleanup - "
+ + "disconnecting channel {}", h.getSwitchInfoString());
+ h.duplicateDpidFound = Boolean.TRUE;
+ h.channel.disconnect();
+ }
+
+
+
+ /**
+ * Handles all pending port status messages before a switch is declared
+ * activated in MASTER or EQUAL role. Note that since this handling
+ * precedes the activation (and therefore notification to IOFSwitchListerners)
+ * the changes to ports will already be visible once the switch is
+ * activated. As a result, no notifications are sent out for these
+ * pending portStatus messages.
+ *
+ * @param h the channel handler that received the message
+ */
+ protected void handlePendingPortStatusMessages(OFChannelHandler h) {
+ try {
+ handlePendingPortStatusMessages(h, 0);
+ } catch (SwitchStateException e) {
+ log.error(e.getMessage());
+ }
+ }
+
+ private void handlePendingPortStatusMessages(OFChannelHandler h, int index)
+ throws SwitchStateException {
+ if (h.sw == null) {
+ String msg = "State machine error: switch is null. Should never " +
+ "happen";
+ throw new SwitchStateException(msg);
+ }
+ log.info("Processing {} pending port status messages for {}",
+ h.pendingPortStatusMsg.size(), h.sw.getStringId());
+
+ ArrayList<OFPortStatus> temp = new ArrayList<OFPortStatus>();
+ for (OFPortStatus ps: h.pendingPortStatusMsg) {
+ temp.add(ps);
+ handlePortStatusMessage(h, ps, false);
+ }
+ // expensive but ok - we don't expect too many port-status messages
+ // note that we cannot use clear(), because of the reasons below
+ h.pendingPortStatusMsg.removeAll(temp);
+ temp.clear();
+ // the iterator above takes a snapshot of the list - so while we were
+ // dealing with the pending port-status messages, we could have received
+ // newer ones. Handle them recursively, but break the recursion after
+ // five steps to avoid an attack.
+ if (!h.pendingPortStatusMsg.isEmpty() && ++index < 5) {
+ handlePendingPortStatusMessages(h, index);
+ }
+ }
+
+ /**
+ * Handle a port status message.
+ *
+ * Handle a port status message by updating the port maps in the
+ * IOFSwitch instance and notifying Controller about the change so
+ * it can dispatch a switch update.
+ *
+ * @param h The OFChannelHhandler that received the message
+ * @param m The PortStatus message we received
+ * @param doNotify if true switch port changed events will be
+ * dispatched
+ * @throws SwitchStateException if the switch is not bound to the channel
+ *
+ */
+ protected void handlePortStatusMessage(OFChannelHandler h, OFPortStatus m,
+ boolean doNotify) throws SwitchStateException {
+ if (h.sw == null) {
+ String msg = getSwitchStateMessage(h, m,
+ "State machine error: switch is null. Should never " +
+ "happen");
+ throw new SwitchStateException(msg);
+ }
+
+ h.sw.handleMessage(m);
+ }
+
+
+ /**
+ * Process an OF message received on the channel and
+ * update state accordingly.
+ *
+ * The main "event" of the state machine. Process the received message,
+ * send follow up message if required and update state if required.
+ *
+ * Switches on the message type and calls more specific event handlers
+ * for each individual OF message type. If we receive a message that
+ * is supposed to be sent from a controller to a switch we throw
+ * a SwitchStateExeption.
+ *
+ * The more specific handlers can also throw SwitchStateExceptions
+ *
+ * @param h The OFChannelHandler that received the message
+ * @param m The message we received.
+ * @throws SwitchStateException if the switch is not bound to the channel
+ * @throws IOException if unable to send message back to the switch
+ */
+ void processOFMessage(OFChannelHandler h, OFMessage m)
+ throws IOException, SwitchStateException {
+ switch(m.getType()) {
+ case HELLO:
+ processOFHello(h, (OFHello) m);
+ break;
+ case BARRIER_REPLY:
+ processOFBarrierReply(h, (OFBarrierReply) m);
+ break;
+ case ECHO_REPLY:
+ processOFEchoReply(h, (OFEchoReply) m);
+ break;
+ case ECHO_REQUEST:
+ processOFEchoRequest(h, (OFEchoRequest) m);
+ break;
+ case ERROR:
+ processOFError(h, (OFErrorMsg) m);
+ break;
+ case FEATURES_REPLY:
+ processOFFeaturesReply(h, (OFFeaturesReply) m);
+ break;
+ case FLOW_REMOVED:
+ processOFFlowRemoved(h, (OFFlowRemoved) m);
+ break;
+ case GET_CONFIG_REPLY:
+ processOFGetConfigReply(h, (OFGetConfigReply) m);
+ break;
+ case PACKET_IN:
+ processOFPacketIn(h, (OFPacketIn) m);
+ break;
+ case PORT_STATUS:
+ processOFPortStatus(h, (OFPortStatus) m);
+ break;
+ case QUEUE_GET_CONFIG_REPLY:
+ processOFQueueGetConfigReply(h, (OFQueueGetConfigReply) m);
+ break;
+ case STATS_REPLY: // multipart_reply in 1.3
+ processOFStatisticsReply(h, (OFStatsReply) m);
+ break;
+ case EXPERIMENTER:
+ processOFExperimenter(h, (OFExperimenter) m);
+ break;
+ case ROLE_REPLY:
+ processOFRoleReply(h, (OFRoleReply) m);
+ break;
+ case GET_ASYNC_REPLY:
+ processOFGetAsyncReply(h, (OFAsyncGetReply) m);
+ break;
+
+ // The following messages are sent to switches. The controller
+ // should never receive them
+ case SET_CONFIG:
+ case GET_CONFIG_REQUEST:
+ case PACKET_OUT:
+ case PORT_MOD:
+ case QUEUE_GET_CONFIG_REQUEST:
+ case BARRIER_REQUEST:
+ case STATS_REQUEST: // multipart request in 1.3
+ case FEATURES_REQUEST:
+ case FLOW_MOD:
+ case GROUP_MOD:
+ case TABLE_MOD:
+ case GET_ASYNC_REQUEST:
+ case SET_ASYNC:
+ case METER_MOD:
+ default:
+ illegalMessageReceived(h, m);
+ break;
+ }
+ }
+
+ /*-----------------------------------------------------------------
+ * Default implementation for message handlers in any state.
+ *
+ * Individual states must override these if they want a behavior
+ * that differs from the default.
+ *
+ * In general, these handlers simply ignore the message and do
+ * nothing.
+ *
+ * There are some exceptions though, since some messages really
+ * are handled the same way in every state (e.g., ECHO_REQUST) or
+ * that are only valid in a single state (e.g., HELLO, GET_CONFIG_REPLY
+ -----------------------------------------------------------------*/
+
+ void processOFHello(OFChannelHandler h, OFHello m)
+ throws IOException, SwitchStateException {
+ // we only expect hello in the WAIT_HELLO state
+ log.warn("Received Hello outside WAIT_HELLO state; switch {} is not complaint.",
+ h.channel.getRemoteAddress());
+ }
+
+ void processOFBarrierReply(OFChannelHandler h, OFBarrierReply m)
+ throws IOException {
+ // Silently ignore.
+ }
+
+ void processOFEchoRequest(OFChannelHandler h, OFEchoRequest m)
+ throws IOException {
+ if (h.ofVersion == null) {
+ log.error("No OF version set for {}. Not sending Echo REPLY",
+ h.channel.getRemoteAddress());
+ return;
+ }
+ OFFactory factory = (h.ofVersion == OFVersion.OF_13) ?
+ h.controller.getOFMessageFactory13() : h.controller.getOFMessageFactory10();
+ OFEchoReply reply = factory
+ .buildEchoReply()
+ .setXid(m.getXid())
+ .setData(m.getData())
+ .build();
+ h.channel.write(Collections.singletonList(reply));
+ }
+
+ void processOFEchoReply(OFChannelHandler h, OFEchoReply m)
+ throws IOException {
+ // Do nothing with EchoReplies !!
+ }
+
+ // no default implementation for OFError
+ // every state must override it
+ abstract void processOFError(OFChannelHandler h, OFErrorMsg m)
+ throws IOException, SwitchStateException;
+
+
+ void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m)
+ throws IOException, SwitchStateException {
+ unhandledMessageReceived(h, m);
+ }
+
+ void processOFFlowRemoved(OFChannelHandler h, OFFlowRemoved m)
+ throws IOException {
+ unhandledMessageReceived(h, m);
+ }
+
+ void processOFGetConfigReply(OFChannelHandler h, OFGetConfigReply m)
+ throws IOException, SwitchStateException {
+ // we only expect config replies in the WAIT_CONFIG_REPLY state
+ illegalMessageReceived(h, m);
+ }
+
+ void processOFPacketIn(OFChannelHandler h, OFPacketIn m)
+ throws IOException {
+ unhandledMessageReceived(h, m);
+ }
+
+ // no default implementation. Every state needs to handle it.
+ abstract void processOFPortStatus(OFChannelHandler h, OFPortStatus m)
+ throws IOException, SwitchStateException;
+
+ void processOFQueueGetConfigReply(OFChannelHandler h,
+ OFQueueGetConfigReply m)
+ throws IOException {
+ unhandledMessageReceived(h, m);
+ }
+
+ void processOFStatisticsReply(OFChannelHandler h, OFStatsReply m)
+ throws IOException, SwitchStateException {
+ unhandledMessageReceived(h, m);
+ }
+
+ void processOFExperimenter(OFChannelHandler h, OFExperimenter m)
+ throws IOException, SwitchStateException {
+ // TODO: it might make sense to parse the vendor message here
+ // into the known vendor messages we support and then call more
+ // specific event handlers
+ unhandledMessageReceived(h, m);
+ }
+
+ void processOFRoleReply(OFChannelHandler h, OFRoleReply m)
+ throws SwitchStateException, IOException {
+ unhandledMessageReceived(h, m);
+ }
+
+ void processOFGetAsyncReply(OFChannelHandler h,
+ OFAsyncGetReply m) {
+ unhandledMessageReceived(h, m);
+ }
+
+ }
+
+
+
+ //*************************
+ // Channel handler methods
+ //*************************
+
+ @Override
+ public void channelConnected(ChannelHandlerContext ctx,
+ ChannelStateEvent e) throws Exception {
+ channel = e.getChannel();
+ log.info("New switch connection from {}",
+ channel.getRemoteAddress());
+ /*
+ hack to wait for the switch to tell us what it's
+ max version is. This is not spec compliant and should
+ be removed as soon as switches behave better.
+ */
+ //sendHandshakeHelloMessage();
+ setState(ChannelState.WAIT_HELLO);
+ }
+
+ @Override
+ public void channelDisconnected(ChannelHandlerContext ctx,
+ ChannelStateEvent e) throws Exception {
+ log.info("Switch disconnected callback for sw:{}. Cleaning up ...",
+ getSwitchInfoString());
+ if (thisdpid != 0) {
+ if (!duplicateDpidFound) {
+ // if the disconnected switch (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
+ // switch was a duplicate-dpid, calling the method below would clear
+ // all state for the original switch (with the same dpid),
+ // which we obviously don't want.
+ log.info("{}:removal called", getSwitchInfoString());
+ if (sw != null) {
+ sw.removeConnectedSwitch();
+ }
+ } else {
+ // A duplicate was disconnected on this ChannelHandler,
+ // this is the same switch reconnecting, but the original state was
+ // not cleaned up - XXX check liveness of original ChannelHandler
+ log.info("{}:duplicate found", getSwitchInfoString());
+ duplicateDpidFound = Boolean.FALSE;
+ }
+ } else {
+ log.warn("no dpid in channelHandler registered for "
+ + "disconnected switch {}", getSwitchInfoString());
+ }
+ }
+
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
+ throws Exception {
+ if (e.getCause() instanceof ReadTimeoutException) {
+ // switch timeout
+ log.error("Disconnecting switch {} due to read timeout",
+ getSwitchInfoString());
+ ctx.getChannel().close();
+ } else if (e.getCause() instanceof HandshakeTimeoutException) {
+ log.error("Disconnecting switch {}: failed to complete handshake",
+ getSwitchInfoString());
+ ctx.getChannel().close();
+ } else if (e.getCause() instanceof ClosedChannelException) {
+ log.debug("Channel for sw {} already closed", getSwitchInfoString());
+ } else if (e.getCause() instanceof IOException) {
+ if (!e.getCause().getMessage().equals(RESET_BY_PEER) &&
+ !e.getCause().getMessage().equals(BROKEN_PIPE)) {
+ log.error("Disconnecting switch {} due to IO Error: {}",
+ getSwitchInfoString(), e.getCause().getMessage());
+ if (log.isDebugEnabled()) {
+ // still print stack trace if debug is enabled
+ log.debug("StackTrace for previous Exception: ", e.getCause());
+ }
+ }
+ ctx.getChannel().close();
+ } else if (e.getCause() instanceof SwitchStateException) {
+ log.error("Disconnecting switch {} due to switch state error: {}",
+ getSwitchInfoString(), e.getCause().getMessage());
+ if (log.isDebugEnabled()) {
+ // still print stack trace if debug is enabled
+ log.debug("StackTrace for previous Exception: ", e.getCause());
+ }
+ ctx.getChannel().close();
+ } else if (e.getCause() instanceof OFParseError) {
+ log.error("Disconnecting switch "
+ + getSwitchInfoString() +
+ " due to message parse failure",
+ e.getCause());
+ ctx.getChannel().close();
+ } else if (e.getCause() instanceof RejectedExecutionException) {
+ log.warn("Could not process message: queue full");
+ } else {
+ log.error("Error while processing message from switch "
+ + getSwitchInfoString()
+ + "state " + this.state, e.getCause());
+ ctx.getChannel().close();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getSwitchInfoString();
+ }
+
+ @Override
+ public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e)
+ throws Exception {
+ OFFactory factory = (ofVersion == OFVersion.OF_13) ? factory13 : factory10;
+ OFMessage m = factory.buildEchoRequest().build();
+ log.debug("Sending Echo Request on idle channel: {}",
+ e.getChannel().getPipeline().getLast().toString());
+ e.getChannel().write(Collections.singletonList(m));
+ // XXX S some problems here -- echo request has no transaction id, and
+ // echo reply is not correlated to the echo request.
+ }
+
+ @Override
+ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
+ throws Exception {
+ if (e.getMessage() instanceof List) {
+ @SuppressWarnings("unchecked")
+ List<OFMessage> msglist = (List<OFMessage>) e.getMessage();
+
+
+ for (OFMessage ofm : msglist) {
+ // Do the actual packet processing
+ state.processOFMessage(this, ofm);
+ }
+ } else {
+ state.processOFMessage(this, (OFMessage) e.getMessage());
+ }
+ }
+
+
+
+ //*************************
+ // Channel utility methods
+ //*************************
+
+ /**
+ * Is this a state in which the handshake has completed?
+ * @return true if the handshake is complete
+ */
+ public boolean isHandshakeComplete() {
+ return this.state.isHandshakeComplete();
+ }
+
+ private void dispatchMessage(OFMessage m) {
+ sw.handleMessage(m);
+ }
+
+ /**
+ * Return a string describing this switch based on the already available
+ * information (DPID and/or remote socket).
+ * @return display string
+ */
+ private String getSwitchInfoString() {
+ if (sw != null) {
+ return sw.toString();
+ }
+ String channelString;
+ if (channel == null || channel.getRemoteAddress() == null) {
+ channelString = "?";
+ } else {
+ channelString = channel.getRemoteAddress().toString();
+ }
+ String dpidString;
+ if (featuresReply == null) {
+ dpidString = "?";
+ } else {
+ dpidString = featuresReply.getDatapathId().toString();
+ }
+ return String.format("[%s DPID[%s]]", channelString, dpidString);
+ }
+
+ /**
+ * Update the channels state. Only called from the state machine.
+ * TODO: enforce restricted state transitions
+ * @param state
+ */
+ private void setState(ChannelState state) {
+ this.state = state;
+ }
+
+ /**
+ * Send hello message to the switch using the handshake transactions ids.
+ * @throws IOException
+ */
+ private void sendHandshakeHelloMessage() throws IOException {
+ // The OF protocol requires us to start things off by sending the highest
+ // version of the protocol supported.
+
+ // bitmap represents OF1.0 (ofp_version=0x01) and OF1.3 (ofp_version=0x04)
+ // see Sec. 7.5.1 of the OF1.3.4 spec
+ U32 bitmap = U32.ofRaw(0x00000012);
+ OFHelloElem hem = factory13.buildHelloElemVersionbitmap()
+ .setBitmaps(Collections.singletonList(bitmap))
+ .build();
+ OFMessage.Builder mb = factory13.buildHello()
+ .setXid(this.handshakeTransactionIds--)
+ .setElements(Collections.singletonList(hem));
+ log.info("Sending OF_13 Hello to {}", channel.getRemoteAddress());
+ channel.write(Collections.singletonList(mb.build()));
+ }
+
+ /**
+ * Send featuresRequest msg to the switch using the handshake transactions ids.
+ * @throws IOException
+ */
+ private void sendHandshakeFeaturesRequestMessage() throws IOException {
+ OFFactory factory = (ofVersion == OFVersion.OF_13) ? factory13 : factory10;
+ OFMessage m = factory.buildFeaturesRequest()
+ .setXid(this.handshakeTransactionIds--)
+ .build();
+ channel.write(Collections.singletonList(m));
+ }
+
+ /**
+ * Send the configuration requests to tell the switch we want full
+ * packets.
+ * @throws IOException
+ */
+ private void sendHandshakeSetConfig() throws IOException {
+ OFFactory factory = (ofVersion == OFVersion.OF_13) ? factory13 : factory10;
+ //log.debug("Sending CONFIG_REQUEST to {}", channel.getRemoteAddress());
+ List<OFMessage> msglist = new ArrayList<OFMessage>(3);
+
+ // Ensure we receive the full packet via PacketIn
+ // FIXME: We don't set the reassembly flags.
+ // Only send config to switches to send full packets, if they have a buffer.
+ // Saves a packet & OFSetConfig can't be handled by certain switches.
+ if(this.featuresReply.getNBuffers() > 0) {
+ OFSetConfig sc = factory
+ .buildSetConfig()
+ .setMissSendLen((short) 0xffff)
+ .setXid(this.handshakeTransactionIds--)
+ .build();
+ msglist.add(sc);
+ }
+
+ // Barrier
+ OFBarrierRequest br = factory
+ .buildBarrierRequest()
+ .setXid(this.handshakeTransactionIds--)
+ .build();
+ msglist.add(br);
+
+ // Verify (need barrier?)
+ OFGetConfigRequest gcr = factory
+ .buildGetConfigRequest()
+ .setXid(this.handshakeTransactionIds--)
+ .build();
+ msglist.add(gcr);
+ channel.write(msglist);
+ }
+
+ /**
+ * send a description state request.
+ * @throws IOException
+ */
+ private void sendHandshakeDescriptionStatsRequest() throws IOException {
+ // Get Description to set switch-specific flags
+ OFFactory factory = (ofVersion == OFVersion.OF_13) ? factory13 : factory10;
+ OFDescStatsRequest dreq = factory
+ .buildDescStatsRequest()
+ .setXid(handshakeTransactionIds--)
+ .build();
+ channel.write(Collections.singletonList(dreq));
+ }
+
+ private void sendHandshakeOFPortDescRequest() throws IOException {
+ // Get port description for 1.3 switch
+ OFPortDescStatsRequest preq = factory13
+ .buildPortDescStatsRequest()
+ .setXid(handshakeTransactionIds--)
+ .build();
+ channel.write(Collections.singletonList(preq));
+ }
+
+ ChannelState getStateForTesting() {
+ return state;
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageDecoder.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageDecoder.java
new file mode 100644
index 00000000..f52d27e5
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageDecoder.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2014 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.openflow.controller.impl;
+
+
+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.projectfloodlight.openflow.protocol.OFFactories;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFMessageReader;
+
+/**
+ * Decode an openflow message from a Channel, for use in a netty pipeline.
+ */
+public class OFMessageDecoder extends FrameDecoder {
+
+ @Override
+ protected Object decode(ChannelHandlerContext ctx, Channel channel,
+ ChannelBuffer buffer) throws Exception {
+ if (!channel.isConnected()) {
+ // In testing, I see decode being called AFTER decode last.
+ // This check avoids that from reading corrupted frames
+ return null;
+ }
+
+ // Note that a single call to decode results in reading a single
+ // OFMessage from the channel buffer, which is passed on to, and processed
+ // by, the controller (in OFChannelHandler).
+ // This is different from earlier behavior (with the original openflowj),
+ // 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.
+ OFMessageReader<OFMessage> reader = OFFactories.getGenericReader();
+ OFMessage message = reader.readFrom(buffer);
+
+ return message;
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java
new file mode 100644
index 00000000..4c1b16fe
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2014 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.openflow.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.projectfloodlight.openflow.protocol.OFMessage;
+
+/**
+ * Encode an openflow message for output into a ChannelBuffer, for use in a
+ * netty pipeline.
+ */
+public class OFMessageEncoder extends OneToOneEncoder {
+
+ @Override
+ protected Object encode(ChannelHandlerContext ctx, Channel channel,
+ Object msg) throws Exception {
+ if (!(msg instanceof List)) {
+ return msg;
+ }
+
+ @SuppressWarnings("unchecked")
+ List<OFMessage> msglist = (List<OFMessage>) msg;
+ /* XXX S can't get length of OFMessage in loxigen's openflowj??
+ int size = 0;
+ for (OFMessage ofm : msglist) {
+ size += ofm.getLengthU();
+ }*/
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ for (OFMessage ofm : msglist) {
+ if (ofm != null) {
+ ofm.writeTo(buf);
+ }
+ }
+ return buf;
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
new file mode 100644
index 00000000..b97c3362
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImpl.java
@@ -0,0 +1,633 @@
+/*
+ * Copyright 2014-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.openflow.controller.impl;
+
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+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.Modified;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.Service;
+import org.onosproject.cfg.ComponentConfigService;
+import org.onosproject.net.driver.DefaultDriverProviderService;
+import org.onosproject.net.driver.DriverService;
+import org.onosproject.openflow.controller.DefaultOpenFlowPacketContext;
+import org.onosproject.openflow.controller.Dpid;
+import org.onosproject.openflow.controller.OpenFlowController;
+import org.onosproject.openflow.controller.OpenFlowEventListener;
+import org.onosproject.openflow.controller.OpenFlowPacketContext;
+import org.onosproject.openflow.controller.OpenFlowSwitch;
+import org.onosproject.openflow.controller.OpenFlowSwitchListener;
+import org.onosproject.openflow.controller.PacketListener;
+import org.onosproject.openflow.controller.RoleState;
+import org.onosproject.openflow.controller.driver.OpenFlowAgent;
+import org.osgi.service.component.ComponentContext;
+import org.projectfloodlight.openflow.protocol.OFCalientFlowStatsEntry;
+import org.projectfloodlight.openflow.protocol.OFCalientFlowStatsReply;
+import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus;
+import org.projectfloodlight.openflow.protocol.OFExperimenter;
+import org.projectfloodlight.openflow.protocol.OFFactories;
+import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry;
+import org.projectfloodlight.openflow.protocol.OFFlowStatsReply;
+import org.projectfloodlight.openflow.protocol.OFTableStatsEntry;
+import org.projectfloodlight.openflow.protocol.OFTableStatsReply;
+import org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry;
+import org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFGroupStatsEntry;
+import org.projectfloodlight.openflow.protocol.OFGroupStatsReply;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFPacketIn;
+import org.projectfloodlight.openflow.protocol.OFPortDesc;
+import org.projectfloodlight.openflow.protocol.OFPortStatsEntry;
+import org.projectfloodlight.openflow.protocol.OFPortStatsReply;
+import org.projectfloodlight.openflow.protocol.OFPortStatus;
+import org.projectfloodlight.openflow.protocol.OFStatsReply;
+import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
+import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
+import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+
+import static org.onlab.util.Tools.groupedThreads;
+
+@Component(immediate = true)
+@Service
+public class OpenFlowControllerImpl implements OpenFlowController {
+ private static final String DEFAULT_OFPORT = "6633,6653";
+ private static final int DEFAULT_WORKER_THREADS = 16;
+
+ private static final Logger log =
+ LoggerFactory.getLogger(OpenFlowControllerImpl.class);
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DriverService driverService;
+
+ // References exists merely for sequencing purpose to assure drivers are loaded
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DefaultDriverProviderService defaultDriverProviderService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ComponentConfigService cfgService;
+
+ @Property(name = "openflowPorts", value = DEFAULT_OFPORT,
+ label = "Port numbers (comma separated) used by OpenFlow protocol; default is 6633,6653")
+ private String openflowPorts = DEFAULT_OFPORT;
+
+ @Property(name = "workerThreads", intValue = DEFAULT_WORKER_THREADS,
+ label = "Number of controller worker threads; default is 16")
+ private int workerThreads = DEFAULT_WORKER_THREADS;
+
+ protected ExecutorService executorMsgs =
+ Executors.newFixedThreadPool(32, groupedThreads("onos/of", "event-stats-%d"));
+
+ private final ExecutorService executorBarrier =
+ Executors.newFixedThreadPool(4, groupedThreads("onos/of", "event-barrier-%d"));
+
+ protected ConcurrentHashMap<Dpid, OpenFlowSwitch> connectedSwitches =
+ new ConcurrentHashMap<>();
+ protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeMasterSwitches =
+ new ConcurrentHashMap<>();
+ protected ConcurrentHashMap<Dpid, OpenFlowSwitch> activeEqualSwitches =
+ new ConcurrentHashMap<>();
+
+ protected OpenFlowSwitchAgent agent = new OpenFlowSwitchAgent();
+ protected Set<OpenFlowSwitchListener> ofSwitchListener = new CopyOnWriteArraySet<>();
+
+ protected Multimap<Integer, PacketListener> ofPacketListener =
+ ArrayListMultimap.create();
+
+ protected Set<OpenFlowEventListener> ofEventListener = new CopyOnWriteArraySet<>();
+
+ protected Multimap<Dpid, OFFlowStatsEntry> fullFlowStats =
+ ArrayListMultimap.create();
+
+ protected Multimap<Dpid, OFTableStatsEntry> fullTableStats =
+ ArrayListMultimap.create();
+
+ protected Multimap<Dpid, OFGroupStatsEntry> fullGroupStats =
+ ArrayListMultimap.create();
+
+ protected Multimap<Dpid, OFGroupDescStatsEntry> fullGroupDescStats =
+ ArrayListMultimap.create();
+
+ protected Multimap<Dpid, OFPortStatsEntry> fullPortStats =
+ ArrayListMultimap.create();
+
+ private final Controller ctrl = new Controller();
+
+ @Activate
+ public void activate(ComponentContext context) {
+ cfgService.registerProperties(getClass());
+ ctrl.setConfigParams(context.getProperties());
+ ctrl.start(agent, driverService);
+ }
+
+ @Deactivate
+ public void deactivate() {
+ cfgService.unregisterProperties(getClass(), false);
+ ctrl.stop();
+ }
+
+ @Modified
+ public void modified(ComponentContext context) {
+ ctrl.stop();
+ ctrl.setConfigParams(context.getProperties());
+ ctrl.start(agent, driverService);
+ }
+
+ @Override
+ public Iterable<OpenFlowSwitch> getSwitches() {
+ return connectedSwitches.values();
+ }
+
+ @Override
+ public Iterable<OpenFlowSwitch> getMasterSwitches() {
+ return activeMasterSwitches.values();
+ }
+
+ @Override
+ public Iterable<OpenFlowSwitch> getEqualSwitches() {
+ return activeEqualSwitches.values();
+ }
+
+ @Override
+ public OpenFlowSwitch getSwitch(Dpid dpid) {
+ return connectedSwitches.get(dpid);
+ }
+
+ @Override
+ public OpenFlowSwitch getMasterSwitch(Dpid dpid) {
+ return activeMasterSwitches.get(dpid);
+ }
+
+ @Override
+ public OpenFlowSwitch getEqualSwitch(Dpid dpid) {
+ return activeEqualSwitches.get(dpid);
+ }
+
+ @Override
+ public void addListener(OpenFlowSwitchListener listener) {
+ if (!ofSwitchListener.contains(listener)) {
+ this.ofSwitchListener.add(listener);
+ }
+ }
+
+ @Override
+ public void removeListener(OpenFlowSwitchListener listener) {
+ this.ofSwitchListener.remove(listener);
+ }
+
+ @Override
+ public void addPacketListener(int priority, PacketListener listener) {
+ ofPacketListener.put(priority, listener);
+ }
+
+ @Override
+ public void removePacketListener(PacketListener listener) {
+ ofPacketListener.values().remove(listener);
+ }
+
+ @Override
+ public void addEventListener(OpenFlowEventListener listener) {
+ ofEventListener.add(listener);
+ }
+
+ @Override
+ public void removeEventListener(OpenFlowEventListener listener) {
+ ofEventListener.remove(listener);
+ }
+
+ @Override
+ public void write(Dpid dpid, OFMessage msg) {
+ this.getSwitch(dpid).sendMsg(msg);
+ }
+
+ @Override
+ public void processPacket(Dpid dpid, OFMessage msg) {
+ Collection<OFFlowStatsEntry> flowStats;
+ Collection<OFTableStatsEntry> tableStats;
+ Collection<OFGroupStatsEntry> groupStats;
+ Collection<OFGroupDescStatsEntry> groupDescStats;
+ Collection<OFPortStatsEntry> portStats;
+
+ switch (msg.getType()) {
+ case PORT_STATUS:
+ for (OpenFlowSwitchListener l : ofSwitchListener) {
+ l.portChanged(dpid, (OFPortStatus) msg);
+ }
+ break;
+ case FEATURES_REPLY:
+ for (OpenFlowSwitchListener l : ofSwitchListener) {
+ l.switchChanged(dpid);
+ }
+ break;
+ case PACKET_IN:
+ OpenFlowPacketContext pktCtx = DefaultOpenFlowPacketContext
+ .packetContextFromPacketIn(this.getSwitch(dpid),
+ (OFPacketIn) msg);
+ for (PacketListener p : ofPacketListener.values()) {
+ p.handlePacket(pktCtx);
+ }
+ break;
+ // TODO: Consider using separate threadpool for sensitive messages.
+ // ie. Back to back error could cause us to starve.
+ case FLOW_REMOVED:
+ case ERROR:
+ executorMsgs.submit(new OFMessageHandler(dpid, msg));
+ break;
+ case STATS_REPLY:
+ OFStatsReply reply = (OFStatsReply) msg;
+ switch (reply.getStatsType()) {
+ case PORT_DESC:
+ for (OpenFlowSwitchListener l : ofSwitchListener) {
+ l.switchChanged(dpid);
+ }
+ break;
+ case FLOW:
+ flowStats = publishFlowStats(dpid, (OFFlowStatsReply) reply);
+ if (flowStats != null) {
+ OFFlowStatsReply.Builder rep =
+ OFFactories.getFactory(msg.getVersion()).buildFlowStatsReply();
+ rep.setEntries(Lists.newLinkedList(flowStats));
+ rep.setXid(reply.getXid());
+ executorMsgs.submit(new OFMessageHandler(dpid, rep.build()));
+ }
+ break;
+ case TABLE:
+ tableStats = publishTableStats(dpid, (OFTableStatsReply) reply);
+ if (tableStats != null) {
+ OFTableStatsReply.Builder rep =
+ OFFactories.getFactory(msg.getVersion()).buildTableStatsReply();
+ rep.setEntries(Lists.newLinkedList(tableStats));
+ executorMsgs.submit(new OFMessageHandler(dpid, rep.build()));
+ }
+ break;
+ case GROUP:
+ groupStats = publishGroupStats(dpid, (OFGroupStatsReply) reply);
+ if (groupStats != null) {
+ OFGroupStatsReply.Builder rep =
+ OFFactories.getFactory(msg.getVersion()).buildGroupStatsReply();
+ rep.setEntries(Lists.newLinkedList(groupStats));
+ rep.setXid(reply.getXid());
+ executorMsgs.submit(new OFMessageHandler(dpid, rep.build()));
+ }
+ break;
+ case GROUP_DESC:
+ groupDescStats = publishGroupDescStats(dpid,
+ (OFGroupDescStatsReply) reply);
+ if (groupDescStats != null) {
+ OFGroupDescStatsReply.Builder rep =
+ OFFactories.getFactory(msg.getVersion()).buildGroupDescStatsReply();
+ rep.setEntries(Lists.newLinkedList(groupDescStats));
+ rep.setXid(reply.getXid());
+ executorMsgs.submit(new OFMessageHandler(dpid, rep.build()));
+ }
+ break;
+ case PORT:
+ executorMsgs.submit(new OFMessageHandler(dpid, reply));
+ break;
+ case METER:
+ executorMsgs.submit(new OFMessageHandler(dpid, reply));
+ break;
+ case EXPERIMENTER:
+ if (reply instanceof OFCalientFlowStatsReply) {
+ // Convert Calient flow statistics to regular flow stats
+ // TODO: parse remaining fields such as power levels etc. when we have proper monitoring API
+ OFFlowStatsReply.Builder fsr = getSwitch(dpid).factory().buildFlowStatsReply();
+ List<OFFlowStatsEntry> entries = new LinkedList<>();
+ for (OFCalientFlowStatsEntry entry : ((OFCalientFlowStatsReply) msg).getEntries()) {
+
+ // Single instruction, i.e., output to port
+ OFActionOutput action = OFFactories
+ .getFactory(msg.getVersion())
+ .actions()
+ .buildOutput()
+ .setPort(entry.getOutPort())
+ .build();
+ OFInstruction instruction = OFFactories
+ .getFactory(msg.getVersion())
+ .instructions()
+ .applyActions(Collections.singletonList(action));
+ OFFlowStatsEntry fs = getSwitch(dpid).factory().buildFlowStatsEntry()
+ .setMatch(entry.getMatch())
+ .setTableId(entry.getTableId())
+ .setDurationSec(entry.getDurationSec())
+ .setDurationNsec(entry.getDurationNsec())
+ .setPriority(entry.getPriority())
+ .setIdleTimeout(entry.getIdleTimeout())
+ .setHardTimeout(entry.getHardTimeout())
+ .setFlags(entry.getFlags())
+ .setCookie(entry.getCookie())
+ .setInstructions(Collections.singletonList(instruction))
+ .build();
+ entries.add(fs);
+ }
+ fsr.setEntries(entries);
+
+ flowStats = publishFlowStats(dpid, fsr.build());
+ if (flowStats != null) {
+ OFFlowStatsReply.Builder rep =
+ OFFactories.getFactory(msg.getVersion()).buildFlowStatsReply();
+ rep.setEntries(Lists.newLinkedList(flowStats));
+ executorMsgs.submit(new OFMessageHandler(dpid, rep.build()));
+ }
+ } else {
+ executorMsgs.submit(new OFMessageHandler(dpid, reply));
+ }
+ break;
+ default:
+ log.warn("Discarding unknown stats reply type {}", reply.getStatsType());
+ break;
+ }
+ break;
+ case BARRIER_REPLY:
+ executorBarrier.submit(new OFMessageHandler(dpid, msg));
+ break;
+ case EXPERIMENTER:
+ long experimenter = ((OFExperimenter) msg).getExperimenter();
+ if (experimenter == 0x748771) {
+ // LINC-OE port stats
+ OFCircuitPortStatus circuitPortStatus = (OFCircuitPortStatus) msg;
+ OFPortStatus.Builder portStatus = this.getSwitch(dpid).factory().buildPortStatus();
+ OFPortDesc.Builder portDesc = this.getSwitch(dpid).factory().buildPortDesc();
+ portDesc.setPortNo(circuitPortStatus.getPortNo())
+ .setHwAddr(circuitPortStatus.getHwAddr())
+ .setName(circuitPortStatus.getName())
+ .setConfig(circuitPortStatus.getConfig())
+ .setState(circuitPortStatus.getState());
+ portStatus.setReason(circuitPortStatus.getReason()).setDesc(portDesc.build());
+ for (OpenFlowSwitchListener l : ofSwitchListener) {
+ l.portChanged(dpid, portStatus.build());
+ }
+ } else {
+ log.warn("Handling experimenter type {} not yet implemented",
+ ((OFExperimenter) msg).getExperimenter(), msg);
+ }
+ break;
+ default:
+ log.warn("Handling message type {} not yet implemented {}",
+ msg.getType(), msg);
+ }
+ }
+
+ private synchronized Collection<OFFlowStatsEntry> publishFlowStats(Dpid dpid,
+ OFFlowStatsReply reply) {
+ //TODO: Get rid of synchronized
+ fullFlowStats.putAll(dpid, reply.getEntries());
+ if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+ return fullFlowStats.removeAll(dpid);
+ }
+ return null;
+ }
+
+ private synchronized Collection<OFTableStatsEntry> publishTableStats(Dpid dpid,
+ OFTableStatsReply reply) {
+ //TODO: Get rid of synchronized
+ fullTableStats.putAll(dpid, reply.getEntries());
+ if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+ return fullTableStats.removeAll(dpid);
+ }
+ return null;
+ }
+
+ private synchronized Collection<OFGroupStatsEntry> publishGroupStats(Dpid dpid,
+ OFGroupStatsReply reply) {
+ //TODO: Get rid of synchronized
+ fullGroupStats.putAll(dpid, reply.getEntries());
+ if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+ return fullGroupStats.removeAll(dpid);
+ }
+ return null;
+ }
+
+ private synchronized Collection<OFGroupDescStatsEntry> publishGroupDescStats(Dpid dpid,
+ OFGroupDescStatsReply reply) {
+ //TODO: Get rid of synchronized
+ fullGroupDescStats.putAll(dpid, reply.getEntries());
+ if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+ return fullGroupDescStats.removeAll(dpid);
+ }
+ return null;
+ }
+
+ private synchronized Collection<OFPortStatsEntry> publishPortStats(Dpid dpid,
+ OFPortStatsReply reply) {
+ fullPortStats.putAll(dpid, reply.getEntries());
+ if (!reply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+ return fullPortStats.removeAll(dpid);
+ }
+ return null;
+ }
+
+ @Override
+ public void setRole(Dpid dpid, RoleState role) {
+ final OpenFlowSwitch sw = getSwitch(dpid);
+ if (sw == null) {
+ log.debug("Switch not connected. Ignoring setRole({}, {})", dpid, role);
+ return;
+ }
+ sw.setRole(role);
+ }
+
+ /**
+ * Implementation of an OpenFlow Agent which is responsible for
+ * keeping track of connected switches and the state in which
+ * they are.
+ */
+ public class OpenFlowSwitchAgent implements OpenFlowAgent {
+
+ private final Logger log = LoggerFactory.getLogger(OpenFlowSwitchAgent.class);
+ private final Lock switchLock = new ReentrantLock();
+
+ @Override
+ public boolean addConnectedSwitch(Dpid dpid, OpenFlowSwitch sw) {
+
+ if (connectedSwitches.get(dpid) != null) {
+ log.error("Trying to add connectedSwitch but found a previous "
+ + "value for dpid: {}", dpid);
+ return false;
+ } else {
+ log.info("Added switch {}", dpid);
+ connectedSwitches.put(dpid, sw);
+ for (OpenFlowSwitchListener l : ofSwitchListener) {
+ l.switchAdded(dpid);
+ }
+ return true;
+ }
+ }
+
+ @Override
+ public boolean validActivation(Dpid dpid) {
+ if (connectedSwitches.get(dpid) == null) {
+ log.error("Trying to activate switch but is not in "
+ + "connected switches: dpid {}. Aborting ..",
+ dpid);
+ return false;
+ }
+ if (activeMasterSwitches.get(dpid) != null ||
+ activeEqualSwitches.get(dpid) != null) {
+ log.error("Trying to activate switch but it is already "
+ + "activated: dpid {}. Found in activeMaster: {} "
+ + "Found in activeEqual: {}. Aborting ..",
+ dpid,
+ (activeMasterSwitches.get(dpid) == null) ? 'N' : 'Y',
+ (activeEqualSwitches.get(dpid) == null) ? 'N' : 'Y');
+ return false;
+ }
+ return true;
+ }
+
+
+ @Override
+ public boolean addActivatedMasterSwitch(Dpid dpid, OpenFlowSwitch sw) {
+ switchLock.lock();
+ try {
+ if (!validActivation(dpid)) {
+ return false;
+ }
+ activeMasterSwitches.put(dpid, sw);
+ return true;
+ } finally {
+ switchLock.unlock();
+ }
+ }
+
+ @Override
+ public boolean addActivatedEqualSwitch(Dpid dpid, OpenFlowSwitch sw) {
+ switchLock.lock();
+ try {
+ if (!validActivation(dpid)) {
+ return false;
+ }
+ activeEqualSwitches.put(dpid, sw);
+ log.info("Added Activated EQUAL Switch {}", dpid);
+ return true;
+ } finally {
+ switchLock.unlock();
+ }
+ }
+
+ @Override
+ public void transitionToMasterSwitch(Dpid dpid) {
+ switchLock.lock();
+ try {
+ if (activeMasterSwitches.containsKey(dpid)) {
+ return;
+ }
+ OpenFlowSwitch sw = activeEqualSwitches.remove(dpid);
+ if (sw == null) {
+ sw = getSwitch(dpid);
+ if (sw == null) {
+ log.error("Transition to master called on sw {}, but switch "
+ + "was not found in controller-cache", dpid);
+ return;
+ }
+ }
+ log.info("Transitioned switch {} to MASTER", dpid);
+ activeMasterSwitches.put(dpid, sw);
+ } finally {
+ switchLock.unlock();
+ }
+ }
+
+
+ @Override
+ public void transitionToEqualSwitch(Dpid dpid) {
+ switchLock.lock();
+ try {
+ if (activeEqualSwitches.containsKey(dpid)) {
+ return;
+ }
+ OpenFlowSwitch sw = activeMasterSwitches.remove(dpid);
+ if (sw == null) {
+ sw = getSwitch(dpid);
+ if (sw == null) {
+ log.error("Transition to equal called on sw {}, but switch "
+ + "was not found in controller-cache", dpid);
+ return;
+ }
+ }
+ log.info("Transitioned switch {} to EQUAL", dpid);
+ activeEqualSwitches.put(dpid, sw);
+ } finally {
+ switchLock.unlock();
+ }
+
+ }
+
+ @Override
+ public void removeConnectedSwitch(Dpid dpid) {
+ connectedSwitches.remove(dpid);
+ OpenFlowSwitch sw = activeMasterSwitches.remove(dpid);
+ if (sw == null) {
+ log.debug("sw was null for {}", dpid);
+ sw = activeEqualSwitches.remove(dpid);
+ }
+ for (OpenFlowSwitchListener l : ofSwitchListener) {
+ l.switchRemoved(dpid);
+ }
+ }
+
+ @Override
+ public void processMessage(Dpid dpid, OFMessage m) {
+ processPacket(dpid, m);
+ }
+
+ @Override
+ public void returnRoleReply(Dpid dpid, RoleState requested, RoleState response) {
+ for (OpenFlowSwitchListener l : ofSwitchListener) {
+ l.receivedRoleReply(dpid, requested, response);
+ }
+ }
+ }
+
+ protected final class OFMessageHandler implements Runnable {
+
+ protected final OFMessage msg;
+ protected final Dpid dpid;
+
+ public OFMessageHandler(Dpid dpid, OFMessage msg) {
+ this.msg = msg;
+ this.dpid = dpid;
+ }
+
+ @Override
+ public void run() {
+ for (OpenFlowEventListener listener : ofEventListener) {
+ listener.handleMessage(dpid, msg);
+ }
+ }
+
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenflowPipelineFactory.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenflowPipelineFactory.java
new file mode 100644
index 00000000..1467520d
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OpenflowPipelineFactory.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2014 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.openflow.controller.impl;
+
+import java.util.concurrent.ThreadPoolExecutor;
+
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.handler.execution.ExecutionHandler;
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.SSLEngine;
+
+/**
+ * Creates a ChannelPipeline for a server-side openflow channel.
+ */
+public class OpenflowPipelineFactory
+ implements ChannelPipelineFactory, ExternalResourceReleasable {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private final SSLEngine sslEngine;
+ protected Controller controller;
+ protected ThreadPoolExecutor pipelineExecutor;
+ protected Timer timer;
+ protected IdleStateHandler idleHandler;
+ protected ReadTimeoutHandler readTimeoutHandler;
+
+ public OpenflowPipelineFactory(Controller controller,
+ ThreadPoolExecutor pipelineExecutor,
+ SSLEngine sslEngine) {
+ super();
+ this.controller = controller;
+ this.pipelineExecutor = pipelineExecutor;
+ this.timer = new HashedWheelTimer();
+ this.idleHandler = new IdleStateHandler(timer, 20, 25, 0);
+ this.readTimeoutHandler = new ReadTimeoutHandler(timer, 30);
+ this.sslEngine = sslEngine;
+ }
+
+ @Override
+ public ChannelPipeline getPipeline() throws Exception {
+ OFChannelHandler handler = new OFChannelHandler(controller);
+
+ ChannelPipeline pipeline = Channels.pipeline();
+ if (sslEngine != null) {
+ log.info("OpenFlow SSL enabled.");
+ pipeline.addLast("ssl",
+ new org.jboss.netty.handler.ssl.SslHandler(sslEngine));
+ } else {
+ log.info("OpenFlow SSL disabled");
+ }
+ pipeline.addLast("ofmessagedecoder", new OFMessageDecoder());
+ pipeline.addLast("ofmessageencoder", new OFMessageEncoder());
+ pipeline.addLast("idle", idleHandler);
+ pipeline.addLast("timeout", readTimeoutHandler);
+ // XXX S ONOS: was 15 increased it to fix Issue #296
+ pipeline.addLast("handshaketimeout",
+ new HandshakeTimeoutHandler(handler, timer, 60));
+ if (pipelineExecutor != null) {
+ pipeline.addLast("pipelineExecutor",
+ new ExecutionHandler(pipelineExecutor));
+ }
+ pipeline.addLast("handler", handler);
+ return pipeline;
+ }
+
+ @Override
+ public void releaseExternalResources() {
+ timer.stop();
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/RoleManager.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/RoleManager.java
new file mode 100644
index 00000000..bd4875cf
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/RoleManager.java
@@ -0,0 +1,406 @@
+/*
+ * Copyright 2014 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.openflow.controller.impl;
+
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import org.onosproject.openflow.controller.RoleState;
+import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
+import org.onosproject.openflow.controller.driver.RoleHandler;
+import org.onosproject.openflow.controller.driver.RoleRecvStatus;
+import org.onosproject.openflow.controller.driver.RoleReplyInfo;
+import org.onosproject.openflow.controller.driver.SwitchStateException;
+import org.projectfloodlight.openflow.protocol.OFControllerRole;
+import org.projectfloodlight.openflow.protocol.OFErrorMsg;
+import org.projectfloodlight.openflow.protocol.OFErrorType;
+import org.projectfloodlight.openflow.protocol.OFExperimenter;
+import org.projectfloodlight.openflow.protocol.OFFactories;
+import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole;
+import org.projectfloodlight.openflow.protocol.OFNiciraControllerRoleReply;
+import org.projectfloodlight.openflow.protocol.OFRoleReply;
+import org.projectfloodlight.openflow.protocol.OFRoleRequest;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+import org.projectfloodlight.openflow.protocol.errormsg.OFBadRequestErrorMsg;
+import org.projectfloodlight.openflow.protocol.errormsg.OFRoleRequestFailedErrorMsg;
+import org.projectfloodlight.openflow.types.U64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * A utility class to handle role requests and replies for this channel.
+ * After a role request is submitted the role changer keeps track of the
+ * pending request, collects the reply (if any) and times out the request
+ * if necessary.
+ */
+class RoleManager implements RoleHandler {
+ protected static final long NICIRA_EXPERIMENTER = 0x2320;
+
+ private static Logger log = LoggerFactory.getLogger(RoleManager.class);
+
+ // The time until cached XID is evicted. Arbitrary for now.
+ private final int pendingXidTimeoutSeconds = 60;
+
+ // The cache for pending expected RoleReplies keyed on expected XID
+ private Cache<Integer, RoleState> pendingReplies =
+ CacheBuilder.newBuilder()
+ .expireAfterWrite(pendingXidTimeoutSeconds, TimeUnit.SECONDS)
+ .build();
+
+ // the expectation set by the caller for the returned role
+ private RoleRecvStatus expectation;
+ private final OpenFlowSwitchDriver sw;
+
+
+ public RoleManager(OpenFlowSwitchDriver sw) {
+ this.expectation = RoleRecvStatus.MATCHED_CURRENT_ROLE;
+ this.sw = sw;
+ }
+
+ /**
+ * Send NX role request message to the switch requesting the specified
+ * role.
+ *
+ * @param role role to request
+ */
+ private int sendNxRoleRequest(RoleState role) throws IOException {
+ // Convert the role enum to the appropriate role to send
+ OFNiciraControllerRole roleToSend = OFNiciraControllerRole.ROLE_OTHER;
+ switch (role) {
+ case MASTER:
+ roleToSend = OFNiciraControllerRole.ROLE_MASTER;
+ break;
+ case SLAVE:
+ case EQUAL:
+ default:
+ // ensuring that the only two roles sent to 1.0 switches with
+ // Nicira role support, are MASTER and SLAVE
+ roleToSend = OFNiciraControllerRole.ROLE_OTHER;
+ log.debug("Sending Nx Role.SLAVE to switch {}.", sw);
+ }
+ int xid = sw.getNextTransactionId();
+ OFExperimenter roleRequest = OFFactories.getFactory(OFVersion.OF_10)
+ .buildNiciraControllerRoleRequest()
+ .setXid(xid)
+ .setRole(roleToSend)
+ .build();
+ sw.sendRoleRequest(roleRequest);
+ return xid;
+ }
+
+ private int sendOF13RoleRequest(RoleState role) throws IOException {
+ // Convert the role enum to the appropriate role to send
+ OFControllerRole roleToSend = OFControllerRole.ROLE_NOCHANGE;
+ switch (role) {
+ case EQUAL:
+ roleToSend = OFControllerRole.ROLE_EQUAL;
+ break;
+ case MASTER:
+ roleToSend = OFControllerRole.ROLE_MASTER;
+ break;
+ case SLAVE:
+ roleToSend = OFControllerRole.ROLE_SLAVE;
+ break;
+ default:
+ log.warn("Sending default role.noChange to switch {}."
+ + " Should only be used for queries.", sw);
+ }
+
+ int xid = sw.getNextTransactionId();
+ OFRoleRequest rrm = OFFactories.getFactory(OFVersion.OF_13)
+ .buildRoleRequest()
+ .setRole(roleToSend)
+ .setXid(xid)
+ //FIXME fix below when we actually use generation ids
+ .setGenerationId(U64.ZERO)
+ .build();
+
+ sw.sendRoleRequest(rrm);
+ return xid;
+ }
+
+ @Override
+ public synchronized boolean sendRoleRequest(RoleState role, RoleRecvStatus exp)
+ throws IOException {
+ this.expectation = exp;
+
+ if (sw.factory().getVersion() == OFVersion.OF_10) {
+ Boolean supportsNxRole = sw.supportNxRole();
+ if (!supportsNxRole) {
+ log.debug("Switch driver indicates no support for Nicira "
+ + "role request messages. Not sending ...");
+ handleUnsentRoleMessage(role,
+ expectation);
+ return false;
+ }
+ // OF1.0 switch with support for NX_ROLE_REQUEST vendor extn.
+ // make Role.EQUAL become Role.SLAVE
+ RoleState roleToSend = (role == RoleState.EQUAL) ? RoleState.SLAVE : role;
+ pendingReplies.put(sendNxRoleRequest(roleToSend), role);
+ } else {
+ // OF1.3 switch, use OFPT_ROLE_REQUEST message
+ pendingReplies.put(sendOF13RoleRequest(role), role);
+ }
+ return true;
+ }
+
+ private void handleUnsentRoleMessage(RoleState role,
+ RoleRecvStatus exp) throws IOException {
+ // typically this is triggered for a switch where role messages
+ // are not supported - we confirm that the role being set is
+ // master
+ if (exp != RoleRecvStatus.MATCHED_SET_ROLE) {
+
+ log.error("Expected MASTER role from registry for switch "
+ + "which has no support for role-messages."
+ + "Received {}. It is possible that this switch "
+ + "is connected to other controllers, in which "
+ + "case it should support role messages - not "
+ + "moving forward.", role);
+
+ }
+
+ }
+
+
+ @Override
+ public synchronized RoleRecvStatus deliverRoleReply(RoleReplyInfo rri)
+ throws SwitchStateException {
+ int xid = (int) rri.getXid();
+ RoleState receivedRole = rri.getRole();
+ RoleState expectedRole = pendingReplies.getIfPresent(xid);
+
+ if (expectedRole == null) {
+ RoleState currentRole = (sw != null) ? sw.getRole() : null;
+ if (currentRole != null) {
+ if (currentRole == rri.getRole()) {
+ // Don't disconnect if the role reply we received is
+ // for the same role we are already in.
+ // FIXME: but we do from the caller anyways.
+ log.debug("Received unexpected RoleReply from "
+ + "Switch: {}. "
+ + "Role in reply is same as current role of this "
+ + "controller for this sw. Ignoring ...",
+ sw.getStringId());
+ return RoleRecvStatus.OTHER_EXPECTATION;
+ } else {
+ String msg = String.format("Switch: [%s], "
+ + "received unexpected RoleReply[%s]. "
+ + "No roles are pending, and this controller's "
+ + "current role:[%s] does not match reply. "
+ + "Disconnecting switch ... ",
+ sw.getStringId(),
+ rri, currentRole);
+ throw new SwitchStateException(msg);
+ }
+ }
+ log.debug("Received unexpected RoleReply {} from "
+ + "Switch: {}. "
+ + "This controller has no current role for this sw. "
+ + "Ignoring ...",
+ rri,
+ sw == null ? "(null)" : sw.getStringId());
+ return RoleRecvStatus.OTHER_EXPECTATION;
+ }
+
+ // XXX Should check generation id meaningfully and other cases of expectations
+ //if (pendingXid != xid) {
+ // log.info("Received older role reply from " +
+ // "switch {} ({}). Ignoring. " +
+ // "Waiting for {}, xid={}",
+ // new Object[] {sw.getStringId(), rri,
+ // pendingRole, pendingXid });
+ // return RoleRecvStatus.OLD_REPLY;
+ //}
+ sw.returnRoleReply(expectedRole, receivedRole);
+
+ if (expectedRole == receivedRole) {
+ log.debug("Received role reply message from {} that matched "
+ + "expected role-reply {} with expectations {}",
+ sw.getStringId(), receivedRole, expectation);
+
+ // Done with this RoleReply; Invalidate
+ pendingReplies.invalidate(xid);
+ if (expectation == RoleRecvStatus.MATCHED_CURRENT_ROLE ||
+ expectation == RoleRecvStatus.MATCHED_SET_ROLE) {
+ return expectation;
+ } else {
+ return RoleRecvStatus.OTHER_EXPECTATION;
+ }
+ }
+
+ pendingReplies.invalidate(xid);
+ // if xids match but role's don't, perhaps its a query (OF1.3)
+ if (expectation == RoleRecvStatus.REPLY_QUERY) {
+ return expectation;
+ }
+
+ return RoleRecvStatus.OTHER_EXPECTATION;
+ }
+
+ /**
+ * Called if we receive an error message. If the xid matches the
+ * pending request we handle it otherwise we ignore it.
+ *
+ * Note: since we only keep the last pending request we might get
+ * error messages for earlier role requests that we won't be able
+ * to handle
+ */
+ @Override
+ public synchronized RoleRecvStatus deliverError(OFErrorMsg error)
+ throws SwitchStateException {
+ RoleState errorRole = pendingReplies.getIfPresent(error.getXid());
+ if (errorRole == null) {
+ if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) {
+ log.debug("Received an error msg from sw {} for a role request,"
+ + " but not for pending request in role-changer; "
+ + " ignoring error {} ...",
+ sw.getStringId(), error);
+ } else {
+ log.debug("Received an error msg from sw {}, but no pending "
+ + "requests in role-changer; not handling ...",
+ sw.getStringId());
+ }
+ return RoleRecvStatus.OTHER_EXPECTATION;
+ }
+ // it is an error related to a currently pending role request message
+ if (error.getErrType() == OFErrorType.BAD_REQUEST) {
+ log.error("Received a error msg {} from sw {} for "
+ + "pending role request {}. Switch driver indicates "
+ + "role-messaging is supported. Possible issues in "
+ + "switch driver configuration?",
+ ((OFBadRequestErrorMsg) error).toString(),
+ sw.getStringId(),
+ errorRole);
+ return RoleRecvStatus.UNSUPPORTED;
+ }
+
+ if (error.getErrType() == OFErrorType.ROLE_REQUEST_FAILED) {
+ OFRoleRequestFailedErrorMsg rrerr =
+ (OFRoleRequestFailedErrorMsg) error;
+ switch (rrerr.getCode()) {
+ case BAD_ROLE:
+ // switch says that current-role-req has bad role?
+ // for now we disconnect
+ // fall-thru
+ case STALE:
+ // switch says that current-role-req has stale gen-id?
+ // for now we disconnect
+ // fall-thru
+ case UNSUP:
+ // switch says that current-role-req has role that
+ // cannot be supported? for now we disconnect
+ String msgx = String.format("Switch: [%s], "
+ + "received Error to for pending role request [%s]. "
+ + "Error:[%s]. Disconnecting switch ... ",
+ sw.getStringId(),
+ errorRole, rrerr);
+ throw new SwitchStateException(msgx);
+ default:
+ break;
+ }
+ }
+
+ // This error message was for a role request message but we dont know
+ // how to handle errors for nicira role request messages
+ return RoleRecvStatus.OTHER_EXPECTATION;
+ }
+
+ /**
+ * Extract the role from an OFVendor message.
+ *
+ * Extract the role from an OFVendor message if the message is a
+ * Nicira role reply. Otherwise return null.
+ *
+ * @param experimenterMsg message
+ * @return The role in the message if the message is a Nicira role
+ * reply, null otherwise.
+ * @throws SwitchStateException If the message is a Nicira role reply
+ * but the numeric role value is unknown.
+ */
+ @Override
+ public RoleState extractNiciraRoleReply(OFExperimenter experimenterMsg)
+ throws SwitchStateException {
+ int vendor = (int) experimenterMsg.getExperimenter();
+ if (vendor != 0x2320) {
+ return null;
+ }
+ OFNiciraControllerRoleReply nrr =
+ (OFNiciraControllerRoleReply) experimenterMsg;
+
+ RoleState role = null;
+ OFNiciraControllerRole ncr = nrr.getRole();
+ switch (ncr) {
+ case ROLE_MASTER:
+ role = RoleState.MASTER;
+ break;
+ case ROLE_OTHER:
+ role = RoleState.EQUAL;
+ break;
+ case ROLE_SLAVE:
+ role = RoleState.SLAVE;
+ break;
+ default: //handled below
+ }
+
+ if (role == null) {
+ String msg = String.format("Switch: [%s], "
+ + "received NX_ROLE_REPLY with invalid role "
+ + "value %s",
+ sw.getStringId(),
+ nrr.getRole());
+ throw new SwitchStateException(msg);
+ }
+ return role;
+ }
+
+ /**
+ * Extract the role information from an OF1.3 Role Reply Message.
+ *
+ * @param rrmsg the role message
+ * @return RoleReplyInfo object
+ * @throws SwitchStateException if the role information could not be extracted.
+ */
+ @Override
+ public RoleReplyInfo extractOFRoleReply(OFRoleReply rrmsg)
+ throws SwitchStateException {
+ OFControllerRole cr = rrmsg.getRole();
+ RoleState role = null;
+ switch (cr) {
+ case ROLE_EQUAL:
+ role = RoleState.EQUAL;
+ break;
+ case ROLE_MASTER:
+ role = RoleState.MASTER;
+ break;
+ case ROLE_SLAVE:
+ role = RoleState.SLAVE;
+ break;
+ case ROLE_NOCHANGE: // switch should send current role
+ default:
+ String msg = String.format("Unknown controller role %s "
+ + "received from switch %s", cr, sw);
+ throw new SwitchStateException(msg);
+ }
+
+ return new RoleReplyInfo(role, rrmsg.getGenerationId(), rrmsg.getXid());
+ }
+
+}
+
diff --git a/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/package-info.java b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/package-info.java
new file mode 100644
index 00000000..a5d9f274
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014 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 OpenFlow controller IO subsystem.
+ */
+package org.onosproject.openflow.controller.impl;
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java
new file mode 100644
index 00000000..75260a1d
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java
@@ -0,0 +1,159 @@
+/*
+ * 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.openflow;
+
+import java.net.SocketAddress;
+
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelConfig;
+import org.jboss.netty.channel.ChannelFactory;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelPipeline;
+
+/**
+ * Adapter for testing against a netty channel.
+ */
+public class ChannelAdapter implements Channel {
+ @Override
+ public Integer getId() {
+ return null;
+ }
+
+ @Override
+ public ChannelFactory getFactory() {
+ return null;
+ }
+
+ @Override
+ public Channel getParent() {
+ return null;
+ }
+
+ @Override
+ public ChannelConfig getConfig() {
+ return null;
+ }
+
+ @Override
+ public ChannelPipeline getPipeline() {
+ return null;
+ }
+
+ @Override
+ public boolean isOpen() {
+ return false;
+ }
+
+ @Override
+ public boolean isBound() {
+ return false;
+ }
+
+ @Override
+ public boolean isConnected() {
+ return false;
+ }
+
+ @Override
+ public SocketAddress getLocalAddress() {
+ return null;
+ }
+
+ @Override
+ public SocketAddress getRemoteAddress() {
+ return null;
+ }
+
+ @Override
+ public ChannelFuture write(Object o) {
+ return null;
+ }
+
+ @Override
+ public ChannelFuture write(Object o, SocketAddress socketAddress) {
+ return null;
+ }
+
+ @Override
+ public ChannelFuture bind(SocketAddress socketAddress) {
+ return null;
+ }
+
+ @Override
+ public ChannelFuture connect(SocketAddress socketAddress) {
+ return null;
+ }
+
+ @Override
+ public ChannelFuture disconnect() {
+ return null;
+ }
+
+ @Override
+ public ChannelFuture unbind() {
+ return null;
+ }
+
+ @Override
+ public ChannelFuture close() {
+ return null;
+ }
+
+ @Override
+ public ChannelFuture getCloseFuture() {
+ return null;
+ }
+
+ @Override
+ public int getInterestOps() {
+ return 0;
+ }
+
+ @Override
+ public boolean isReadable() {
+ return false;
+ }
+
+ @Override
+ public boolean isWritable() {
+ return false;
+ }
+
+ @Override
+ public ChannelFuture setInterestOps(int i) {
+ return null;
+ }
+
+ @Override
+ public ChannelFuture setReadable(boolean b) {
+ return null;
+ }
+
+ @Override
+ public Object getAttachment() {
+ return null;
+ }
+
+ @Override
+ public void setAttachment(Object o) {
+
+ }
+
+ @Override
+ public int compareTo(Channel o) {
+ return 0;
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelHandlerContextAdapter.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelHandlerContextAdapter.java
new file mode 100644
index 00000000..5b6c2a36
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelHandlerContextAdapter.java
@@ -0,0 +1,77 @@
+/*
+ * 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.openflow;
+
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelEvent;
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipeline;
+
+/**
+ * Adapter for testing against a netty channel handler context.
+ */
+public class ChannelHandlerContextAdapter implements ChannelHandlerContext {
+ @Override
+ public Channel getChannel() {
+ return null;
+ }
+
+ @Override
+ public ChannelPipeline getPipeline() {
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ return null;
+ }
+
+ @Override
+ public ChannelHandler getHandler() {
+ return null;
+ }
+
+ @Override
+ public boolean canHandleUpstream() {
+ return false;
+ }
+
+ @Override
+ public boolean canHandleDownstream() {
+ return false;
+ }
+
+ @Override
+ public void sendUpstream(ChannelEvent channelEvent) {
+
+ }
+
+ @Override
+ public void sendDownstream(ChannelEvent channelEvent) {
+
+ }
+
+ @Override
+ public Object getAttachment() {
+ return null;
+ }
+
+ @Override
+ public void setAttachment(Object o) {
+
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverAdapter.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverAdapter.java
new file mode 100644
index 00000000..57becf94
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverAdapter.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.openflow;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.net.driver.Behaviour;
+import org.onosproject.net.driver.Driver;
+import org.onosproject.net.driver.DriverData;
+import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
+
+/**
+ * Created by ray on 11/4/15.
+ */
+public class DriverAdapter implements Driver {
+ @Override
+ public String name() {
+ return null;
+ }
+
+ @Override
+ public Driver parent() {
+ return null;
+ }
+
+ @Override
+ public String manufacturer() {
+ return null;
+ }
+
+ @Override
+ public String hwVersion() {
+ return null;
+ }
+
+ @Override
+ public String swVersion() {
+ return null;
+ }
+
+ @Override
+ public Set<Class<? extends Behaviour>> behaviours() {
+ return null;
+ }
+
+ @Override
+ public Class<? extends Behaviour> implementation(Class<? extends Behaviour> behaviour) {
+ return null;
+ }
+
+ @Override
+ public boolean hasBehaviour(Class<? extends Behaviour> behaviourClass) {
+ return true;
+ }
+
+ @Override
+ public <T extends Behaviour> T createBehaviour(DriverData data, Class<T> behaviourClass) {
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T extends Behaviour> T createBehaviour(DriverHandler handler, Class<T> behaviourClass) {
+ if (behaviourClass == OpenFlowSwitchDriver.class) {
+ return (T) new OpenflowSwitchDriverAdapter();
+ }
+ return null;
+ }
+
+ @Override
+ public Map<String, String> properties() {
+ return null;
+ }
+
+ @Override
+ public Driver merge(Driver other) {
+ return null;
+ }
+
+ @Override
+ public Set<String> keys() {
+ return null;
+ }
+
+ @Override
+ public String value(String key) {
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverServiceAdapter.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverServiceAdapter.java
new file mode 100644
index 00000000..25596ada
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/DriverServiceAdapter.java
@@ -0,0 +1,59 @@
+/*
+ * 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.openflow;
+
+import java.util.Set;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.driver.Behaviour;
+import org.onosproject.net.driver.Driver;
+import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.net.driver.DriverService;
+
+/**
+ * Created by ray on 11/4/15.
+ */
+public class DriverServiceAdapter implements DriverService {
+ @Override
+ public Set<Driver> getDrivers() {
+ return null;
+ }
+
+ @Override
+ public Set<Driver> getDrivers(Class<? extends Behaviour> withBehaviour) {
+ return null;
+ }
+
+ @Override
+ public Driver getDriver(String mfr, String hw, String sw) {
+ return null;
+ }
+
+ @Override
+ public Driver getDriver(DeviceId deviceId) {
+ return null;
+ }
+
+ @Override
+ public DriverHandler createHandler(DeviceId deviceId, String... credentials) {
+ return null;
+ }
+
+ @Override
+ public Driver getDriver(String driverName) {
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ExecutorServiceAdapter.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ExecutorServiceAdapter.java
new file mode 100644
index 00000000..54c9c94b
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/ExecutorServiceAdapter.java
@@ -0,0 +1,99 @@
+/*
+ * 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.openflow;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Test harness adapter for the ExecutorService.
+ */
+public class ExecutorServiceAdapter implements ExecutorService {
+ @Override
+ public void shutdown() {
+
+ }
+
+ @Override
+ public List<Runnable> shutdownNow() {
+ return null;
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return false;
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return false;
+ }
+
+ @Override
+ public boolean awaitTermination(long timeout, TimeUnit unit)
+ throws InterruptedException {
+ return false;
+ }
+
+ @Override
+ public <T> Future<T> submit(Callable<T> task) {
+ return null;
+ }
+
+ @Override
+ public <T> Future<T> submit(Runnable task, T result) {
+ return null;
+ }
+
+ @Override
+ public Future<?> submit(Runnable task) {
+ return null;
+ }
+
+ @Override
+ public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
+ throws InterruptedException {
+ return null;
+ }
+
+ @Override
+ public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
+ throws InterruptedException {
+ return null;
+ }
+
+ @Override
+ public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
+ return null;
+ }
+
+ @Override
+ public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
+ throws InterruptedException, ExecutionException, TimeoutException {
+ return null;
+ }
+
+ @Override
+ public void execute(Runnable command) {
+
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfFeaturesReply.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfFeaturesReply.java
new file mode 100644
index 00000000..e280d56e
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfFeaturesReply.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.openflow;
+
+import java.util.List;
+import java.util.Set;
+
+import org.projectfloodlight.openflow.protocol.OFActionType;
+import org.projectfloodlight.openflow.protocol.OFCapabilities;
+import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
+import org.projectfloodlight.openflow.protocol.OFPortDesc;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.projectfloodlight.openflow.types.DatapathId;
+import org.projectfloodlight.openflow.types.OFAuxId;
+
+/**
+ * Mock of the Open FLow features reply message.
+ */
+public class MockOfFeaturesReply extends OfMessageAdapter implements OFFeaturesReply {
+ public MockOfFeaturesReply() {
+ super(OFType.FEATURES_REPLY);
+ }
+
+ @Override
+ public DatapathId getDatapathId() {
+ return null;
+ }
+
+ @Override
+ public long getNBuffers() {
+ return 0;
+ }
+
+ @Override
+ public short getNTables() {
+ return 0;
+ }
+
+ @Override
+ public Set<OFCapabilities> getCapabilities() {
+ return null;
+ }
+
+ @Override
+ public long getReserved() {
+ return 0;
+ }
+
+ @Override
+ public List<OFPortDesc> getPorts() {
+ return null;
+ }
+
+ @Override
+ public Set<OFActionType> getActions() {
+ return null;
+ }
+
+ @Override
+ public OFAuxId getAuxiliaryId() {
+ return null;
+ }
+
+ @Override
+ public OFFeaturesReply.Builder createBuilder() {
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfPacketIn.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfPacketIn.java
new file mode 100644
index 00000000..8e2069b0
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfPacketIn.java
@@ -0,0 +1,84 @@
+/*
+ * 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.openflow;
+
+import org.projectfloodlight.openflow.protocol.OFPacketIn;
+import org.projectfloodlight.openflow.protocol.OFPacketInReason;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.projectfloodlight.openflow.protocol.match.Match;
+import org.projectfloodlight.openflow.types.OFBufferId;
+import org.projectfloodlight.openflow.types.OFPort;
+import org.projectfloodlight.openflow.types.TableId;
+import org.projectfloodlight.openflow.types.U64;
+
+/**
+ * Mock of the Open Flow packet in message.
+ */
+public class MockOfPacketIn extends OfMessageAdapter implements OFPacketIn {
+ public MockOfPacketIn() {
+ super(OFType.PACKET_IN);
+ }
+
+ @Override
+ public OFBufferId getBufferId() {
+ return null;
+ }
+
+ @Override
+ public int getTotalLen() {
+ return 0;
+ }
+
+ @Override
+ public OFPacketInReason getReason() {
+ return null;
+ }
+
+ @Override
+ public TableId getTableId() {
+ return null;
+ }
+
+ @Override
+ public Match getMatch() {
+ return null;
+ }
+
+ @Override
+ public byte[] getData() {
+ return new byte[0];
+ }
+
+ @Override
+ public OFPort getInPort() {
+ return null;
+ }
+
+ @Override
+ public OFPort getInPhyPort() {
+ return null;
+ }
+
+ @Override
+ public U64 getCookie() {
+ return null;
+ }
+
+ @Override
+ public OFPacketIn.Builder createBuilder() {
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfPortStatus.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfPortStatus.java
new file mode 100644
index 00000000..2e26542f
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/MockOfPortStatus.java
@@ -0,0 +1,45 @@
+/*
+ * 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.openflow;
+
+import org.projectfloodlight.openflow.protocol.OFPortDesc;
+import org.projectfloodlight.openflow.protocol.OFPortReason;
+import org.projectfloodlight.openflow.protocol.OFPortStatus;
+import org.projectfloodlight.openflow.protocol.OFType;
+
+/**
+ * Mocked open flow port status message.
+ */
+public class MockOfPortStatus extends OfMessageAdapter implements OFPortStatus {
+ public MockOfPortStatus() {
+ super(OFType.PORT_STATUS);
+ }
+
+ @Override
+ public OFPortReason getReason() {
+ return null;
+ }
+
+ @Override
+ public OFPortDesc getDesc() {
+ return null;
+ }
+
+ @Override
+ public OFPortStatus.Builder createBuilder() {
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OFDescStatsReplyAdapter.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OFDescStatsReplyAdapter.java
new file mode 100644
index 00000000..1e866413
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OFDescStatsReplyAdapter.java
@@ -0,0 +1,97 @@
+/*
+ * 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.openflow;
+
+import java.util.Set;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
+import org.projectfloodlight.openflow.protocol.OFStatsType;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+
+import com.google.common.hash.PrimitiveSink;
+
+/**
+ * Created by ray on 11/4/15.
+ */
+public class OFDescStatsReplyAdapter implements OFDescStatsReply {
+ @Override
+ public OFVersion getVersion() {
+ return null;
+ }
+
+ @Override
+ public OFType getType() {
+ return null;
+ }
+
+ @Override
+ public long getXid() {
+ return 0;
+ }
+
+ @Override
+ public OFStatsType getStatsType() {
+ return null;
+ }
+
+ @Override
+ public Set<OFStatsReplyFlags> getFlags() {
+ return null;
+ }
+
+ @Override
+ public String getMfrDesc() {
+ return null;
+ }
+
+ @Override
+ public String getHwDesc() {
+ return null;
+ }
+
+ @Override
+ public String getSwDesc() {
+ return null;
+ }
+
+ @Override
+ public String getSerialNum() {
+ return null;
+ }
+
+ @Override
+ public String getDpDesc() {
+ return null;
+ }
+
+ @Override
+ public void writeTo(ChannelBuffer channelBuffer) {
+
+ }
+
+ @Override
+ public Builder createBuilder() {
+ return null;
+ }
+
+ @Override
+ public void putTo(PrimitiveSink sink) {
+
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OfMessageAdapter.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OfMessageAdapter.java
new file mode 100644
index 00000000..b7446eb9
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OfMessageAdapter.java
@@ -0,0 +1,62 @@
+/*
+ * 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.openflow;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+
+import com.google.common.hash.PrimitiveSink;
+
+/**
+ * Adapter for testing against an OpenFlow message.
+ */
+public class OfMessageAdapter implements OFMessage {
+ OFType type;
+
+ private OfMessageAdapter() {}
+
+ public OfMessageAdapter(OFType type) {
+ this.type = type;
+ }
+
+ @Override
+ public OFType getType() {
+ return type;
+ }
+
+ @Override
+ public OFVersion getVersion() {
+ return null;
+ }
+
+ @Override
+ public long getXid() {
+ return 0;
+ }
+
+ @Override
+ public void writeTo(ChannelBuffer channelBuffer) { }
+
+ @Override
+ public Builder createBuilder() {
+ return null;
+ }
+
+ @Override
+ public void putTo(PrimitiveSink sink) { }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OpenFlowSwitchListenerAdapter.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OpenFlowSwitchListenerAdapter.java
new file mode 100644
index 00000000..b018f42a
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OpenFlowSwitchListenerAdapter.java
@@ -0,0 +1,77 @@
+/*
+ * 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.openflow;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onosproject.openflow.controller.Dpid;
+import org.onosproject.openflow.controller.OpenFlowSwitchListener;
+import org.onosproject.openflow.controller.RoleState;
+import org.projectfloodlight.openflow.protocol.OFPortStatus;
+
+/**
+ * Test harness for a switch listener.
+ */
+public class OpenFlowSwitchListenerAdapter implements OpenFlowSwitchListener {
+ final List<Dpid> removedDpids = new ArrayList<>();
+ final List<Dpid> addedDpids = new ArrayList<>();
+ final List<Dpid> changedDpids = new ArrayList<>();
+ final Map<Dpid, OFPortStatus> portChangedDpids = new HashMap<>();
+
+ @Override
+ public void switchAdded(Dpid dpid) {
+ addedDpids.add(dpid);
+ }
+
+ @Override
+ public void switchRemoved(Dpid dpid) {
+ removedDpids.add(dpid);
+ }
+
+ @Override
+ public void switchChanged(Dpid dpid) {
+ changedDpids.add(dpid);
+ }
+
+ @Override
+ public void portChanged(Dpid dpid, OFPortStatus status) {
+ portChangedDpids.put(dpid, status);
+ }
+
+ @Override
+ public void receivedRoleReply(Dpid dpid, RoleState requested, RoleState response) {
+ // Stub
+ }
+
+ public List<Dpid> removedDpids() {
+ return removedDpids;
+ }
+
+ public List<Dpid> addedDpids() {
+ return addedDpids;
+ }
+
+ public List<Dpid> changedDpids() {
+ return changedDpids;
+ }
+
+ public Map<Dpid, OFPortStatus> portChangedDpids() {
+ return portChangedDpids;
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OpenflowSwitchDriverAdapter.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OpenflowSwitchDriverAdapter.java
new file mode 100644
index 00000000..9b899a67
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/OpenflowSwitchDriverAdapter.java
@@ -0,0 +1,302 @@
+/*
+ * 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.openflow;
+
+import java.util.List;
+
+import org.jboss.netty.channel.Channel;
+import org.onosproject.net.Device;
+import org.onosproject.net.driver.DriverData;
+import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.openflow.controller.Dpid;
+import org.onosproject.openflow.controller.RoleState;
+import org.onosproject.openflow.controller.driver.OpenFlowAgent;
+import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
+import org.onosproject.openflow.controller.driver.RoleHandler;
+import org.onosproject.openflow.controller.driver.SwitchStateException;
+import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFErrorMsg;
+import org.projectfloodlight.openflow.protocol.OFFactories;
+import org.projectfloodlight.openflow.protocol.OFFactory;
+import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFPortDesc;
+import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFVersion;
+
+/**
+ * Testing adapter for the OpenFlow switch driver class.
+ */
+public class OpenflowSwitchDriverAdapter implements OpenFlowSwitchDriver {
+
+ RoleState role = RoleState.MASTER;
+
+ @Override
+ public void setAgent(OpenFlowAgent agent) {
+
+ }
+
+ @Override
+ public void setRoleHandler(RoleHandler roleHandler) {
+
+ }
+
+ @Override
+ public void reassertRole() {
+
+ }
+
+ @Override
+ public boolean handleRoleError(OFErrorMsg error) {
+ return false;
+ }
+
+ @Override
+ public void handleNiciraRole(OFMessage m) throws SwitchStateException {
+
+ }
+
+ @Override
+ public void handleRole(OFMessage m) throws SwitchStateException {
+
+ }
+
+ @Override
+ public boolean connectSwitch() {
+ return false;
+ }
+
+ @Override
+ public boolean activateMasterSwitch() {
+ return false;
+ }
+
+ @Override
+ public boolean activateEqualSwitch() {
+ return false;
+ }
+
+ @Override
+ public void transitionToEqualSwitch() {
+
+ }
+
+ @Override
+ public void transitionToMasterSwitch() {
+
+ }
+
+ @Override
+ public void removeConnectedSwitch() {
+
+ }
+
+ @Override
+ public void setPortDescReply(OFPortDescStatsReply portDescReply) {
+
+ }
+
+ @Override
+ public void setPortDescReplies(List<OFPortDescStatsReply> portDescReplies) {
+
+ }
+
+ @Override
+ public void setFeaturesReply(OFFeaturesReply featuresReply) {
+
+ }
+
+ @Override
+ public void setSwitchDescription(OFDescStatsReply desc) {
+
+ }
+
+ @Override
+ public int getNextTransactionId() {
+ return 0;
+ }
+
+ @Override
+ public void setOFVersion(OFVersion ofV) {
+
+ }
+
+ @Override
+ public void setTableFull(boolean full) {
+
+ }
+
+ @Override
+ public void setChannel(Channel channel) {
+
+ }
+
+ @Override
+ public void setConnected(boolean connected) {
+
+ }
+
+ @Override
+ public void init(Dpid dpid, OFDescStatsReply desc, OFVersion ofv) {
+
+ }
+
+ @Override
+ public Boolean supportNxRole() {
+ return true;
+ }
+
+ @Override
+ public void startDriverHandshake() {
+
+ }
+
+ @Override
+ public boolean isDriverHandshakeComplete() {
+ return false;
+ }
+
+ @Override
+ public void processDriverHandshakeMessage(OFMessage m) {
+
+ }
+
+ @Override
+ public void sendRoleRequest(OFMessage message) {
+
+ }
+
+ @Override
+ public void sendHandshakeMessage(OFMessage message) {
+
+ }
+
+ @Override
+ public DriverHandler handler() {
+ return null;
+ }
+
+ @Override
+ public void setHandler(DriverHandler handler) {
+
+ }
+
+ @Override
+ public DriverData data() {
+ return null;
+ }
+
+ @Override
+ public void setData(DriverData data) {
+
+ }
+
+ @Override
+ public void sendMsg(OFMessage msg) {
+
+ }
+
+ @Override
+ public void sendMsg(List<OFMessage> msgs) {
+
+ }
+
+ @Override
+ public void handleMessage(OFMessage fromSwitch) {
+
+ }
+
+ @Override
+ public void setRole(RoleState role) {
+ this.role = role;
+ }
+
+ @Override
+ public RoleState getRole() {
+ return role;
+ }
+
+ @Override
+ public List<OFPortDesc> getPorts() {
+ return null;
+ }
+
+ @Override
+ public OFFactory factory() {
+ // return what-ever triggers requestPending = true
+ return OFFactories.getFactory(OFVersion.OF_10);
+ }
+
+ @Override
+ public String getStringId() {
+ return "100";
+ }
+
+ @Override
+ public long getId() {
+ return 0;
+ }
+
+ @Override
+ public String manufacturerDescription() {
+ return null;
+ }
+
+ @Override
+ public String datapathDescription() {
+ return null;
+ }
+
+ @Override
+ public String hardwareDescription() {
+ return null;
+ }
+
+ @Override
+ public String softwareDescription() {
+ return null;
+ }
+
+ @Override
+ public String serialNumber() {
+ return null;
+ }
+
+ @Override
+ public boolean isConnected() {
+ return false;
+ }
+
+ @Override
+ public void disconnectSwitch() {
+
+ }
+
+ @Override
+ public void returnRoleReply(RoleState requested, RoleState response) {
+
+ }
+
+ @Override
+ public Device.Type deviceType() {
+ return Device.Type.SWITCH;
+ }
+
+ @Override
+ public String channelId() {
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/ControllerTest.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/ControllerTest.java
new file mode 100644
index 00000000..dddea328
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/ControllerTest.java
@@ -0,0 +1,219 @@
+/*
+ * 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.openflow.controller.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.stream.IntStream;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.junit.TestTools;
+import org.onlab.util.ItemNotFoundException;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.driver.Driver;
+import org.onosproject.openflow.DriverAdapter;
+import org.onosproject.openflow.DriverServiceAdapter;
+import org.onosproject.openflow.OFDescStatsReplyAdapter;
+import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
+import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.io.Files;
+
+import static com.google.common.io.ByteStreams.toByteArray;
+import static com.google.common.io.Files.write;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThan;
+import static org.hamcrest.Matchers.not;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
+
+/**
+ * Unit tests for the OpenFlow controller class.
+ */
+public class ControllerTest {
+
+ Controller controller;
+ protected static final Logger log = LoggerFactory.getLogger(ControllerTest.class);
+
+ static final File TEST_DIR = Files.createTempDir();
+
+ /*
+ * Writes the necessary file for the tests in the temporary directory
+ */
+ static File stageTestResource(String name) throws IOException {
+ File file = new File(TEST_DIR, name);
+ byte[] bytes = toByteArray(ControllerTest.class.getResourceAsStream(name));
+ write(bytes, file);
+ return file;
+ }
+
+ class MockDriverService extends DriverServiceAdapter {
+ static final int NO_SUCH_DRIVER_ID = 1;
+ static final int ITEM_NOT_FOUND_DRIVER_ID = 2;
+ static final int DRIVER_EXISTS_ID = 3;
+
+ static final String BASE_DRIVER_NAME = "of:000000000000000";
+
+ static final String NO_SUCH_DRIVER = BASE_DRIVER_NAME
+ + NO_SUCH_DRIVER_ID;
+ static final String ITEM_NOT_FOUND_DRIVER = BASE_DRIVER_NAME
+ + ITEM_NOT_FOUND_DRIVER_ID;
+ static final String DRIVER_EXISTS = BASE_DRIVER_NAME
+ + DRIVER_EXISTS_ID;
+
+ @Override
+ public Driver getDriver(DeviceId deviceId) {
+ switch (deviceId.toString()) {
+ case NO_SUCH_DRIVER:
+ return null;
+ case ITEM_NOT_FOUND_DRIVER:
+ throw new ItemNotFoundException();
+ case DRIVER_EXISTS:
+ return new DriverAdapter();
+ default:
+ throw new AssertionError();
+ }
+ }
+ }
+
+ /**
+ * Creates and initializes a new controller.
+ */
+ @Before
+ public void setUp() {
+ controller = new Controller();
+ Dictionary<String, String> properties = new Hashtable<>();
+ properties.put("openflowPorts",
+ Integer.toString(TestTools.findAvailablePort(0)));
+ controller.setConfigParams(properties);
+ }
+
+ /**
+ * Tests fetching a driver that does not exist.
+ */
+ @Test
+ public void switchInstanceNotFoundTest() {
+ controller.start(null, new MockDriverService());
+ OpenFlowSwitchDriver driver =
+ controller.getOFSwitchInstance(MockDriverService.NO_SUCH_DRIVER_ID,
+ null,
+ null);
+ assertThat(driver, nullValue());
+ controller.stop();
+ }
+
+ /**
+ * Tests fetching a driver that throws an ItemNotFoundException.
+ */
+ @Test
+ public void switchItemNotFoundTest() {
+ controller.start(null, new MockDriverService());
+ OFDescStatsReply stats =
+ new OFDescStatsReplyAdapter();
+ OpenFlowSwitchDriver driver =
+ controller.getOFSwitchInstance(MockDriverService.ITEM_NOT_FOUND_DRIVER_ID,
+ stats,
+ null);
+ assertThat(driver, nullValue());
+ controller.stop();
+ }
+
+ /**
+ * Tests fetching a driver that throws an ItemNotFoundException.
+ */
+ @Test
+ public void driverExistsTest() {
+ controller.start(null, new MockDriverService());
+ OFDescStatsReply stats =
+ new OFDescStatsReplyAdapter();
+ OpenFlowSwitchDriver driver =
+ controller.getOFSwitchInstance(MockDriverService.DRIVER_EXISTS_ID,
+ stats,
+ null);
+ assertThat(driver, notNullValue());
+ controller.stop();
+ }
+
+ /**
+ * Tests configuring the controller.
+ */
+ @Test
+ public void testConfiguration() {
+ Dictionary<String, String> properties = new Hashtable<>();
+ properties.put("openflowPorts", "1,2,3,4,5");
+ properties.put("workerThreads", "5");
+
+ controller.setConfigParams(properties);
+ IntStream.rangeClosed(1, 5)
+ .forEach(i -> assertThat(controller.openFlowPorts, hasItem(i)));
+ assertThat(controller.workerThreads, is(5));
+ }
+
+ /**
+ * Tests the SSL/TLS methods in the controller.
+ */
+ @Test
+ public void testSsl() throws IOException {
+ File keystore = stageTestResource("ControllerTestKeystore.jks");
+ String keystoreName = keystore.getAbsolutePath();
+
+ System.setProperty("enableOFTLS", Boolean.toString(Boolean.TRUE));
+ System.setProperty("javax.net.ssl.keyStore", keystoreName);
+ System.setProperty("javax.net.ssl.trustStore", keystoreName);
+ System.setProperty("javax.net.ssl.keyStorePassword", "password");
+ System.setProperty("javax.net.ssl.trustStorePassword", "password");
+ Dictionary<String, String> properties = new Hashtable<>();
+ properties.put("openflowPorts",
+ Integer.toString(TestTools.findAvailablePort(0)));
+ properties.put("workerThreads", "0");
+
+ controller.setConfigParams(properties);
+ controller.start(null, new MockDriverService());
+
+ assertThat(controller.serverSslEngine, notNullValue());
+
+ controller.stop();
+ boolean removed = keystore.delete();
+ if (!removed) {
+ log.warn("Could not remove temporary file");
+ }
+ }
+
+ /**
+ * Tests controll utility health methods.
+ */
+ @Test
+ public void testHealth() {
+ Map<String, Long> memory = controller.getMemory();
+ assertThat(memory.size(), is(2));
+ assertThat(memory.get("total"), is(not(0)));
+ assertThat(memory.get("free"), is(not(0)));
+
+ long startTime = controller.getSystemStartTime();
+ assertThat(startTime, lessThan(System.currentTimeMillis()));
+
+ long upTime = controller.getSystemUptime();
+ assertThat(upTime, lessThan(30L * 1000));
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java
new file mode 100644
index 00000000..ed1db238
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.openflow.controller.impl;
+
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.openflow.ChannelAdapter;
+import org.onosproject.openflow.ChannelHandlerContextAdapter;
+import org.projectfloodlight.openflow.protocol.OFHello;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.Matchers.nullValue;
+
+/**
+ * Tests for the OpenFlow message decoder.
+ */
+public class OFMessageDecoderTest {
+
+ static class ConnectedChannel extends ChannelAdapter {
+ @Override
+ public boolean isConnected() {
+ return true;
+ }
+ }
+
+ private ChannelBuffer getHelloMessageBuffer() {
+ // OFHello, OF version 1, xid of 0, total of 8 bytes
+ byte[] messageData = {0x1, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0};
+ ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer();
+ channelBuffer.writeBytes(messageData);
+ return channelBuffer;
+ }
+
+ /**
+ * Tests decoding a message on a closed channel.
+ *
+ * @throws Exception when an exception is thrown from the decoder
+ */
+ @Test
+ public void testDecodeNoChannel() throws Exception {
+ OFMessageDecoder decoder = new OFMessageDecoder();
+ ChannelBuffer channelBuffer = getHelloMessageBuffer();
+ Object message =
+ decoder.decode(new ChannelHandlerContextAdapter(),
+ new ChannelAdapter(),
+ channelBuffer);
+ assertThat(message, nullValue());
+ }
+
+ /**
+ * Tests decoding a message.
+ *
+ * @throws Exception when an exception is thrown from the decoder
+ */
+ @Test
+ public void testDecode() throws Exception {
+ OFMessageDecoder decoder = new OFMessageDecoder();
+ ChannelBuffer channelBuffer = getHelloMessageBuffer();
+ Object message =
+ decoder.decode(new ChannelHandlerContextAdapter(),
+ new ConnectedChannel(),
+ channelBuffer);
+ assertThat(message, notNullValue());
+ assertThat(message, instanceOf(OFHello.class));
+ }
+
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageEncoderTest.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageEncoderTest.java
new file mode 100644
index 00000000..d09e5661
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageEncoderTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.openflow.controller.impl;
+
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.junit.Test;
+import org.onosproject.openflow.OfMessageAdapter;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFType;
+
+import com.google.common.collect.ImmutableList;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Tests for the OpenFlow message encoder.
+ */
+public class OFMessageEncoderTest {
+
+ static class MockOfMessage extends OfMessageAdapter {
+ static int nextId = 1;
+ final int id;
+
+ MockOfMessage() {
+ super(OFType.ERROR);
+ id = nextId++;
+ }
+
+ @Override
+ public void writeTo(ChannelBuffer channelBuffer) {
+ String message = "message" + Integer.toString(id) + " ";
+ channelBuffer.writeBytes(message.getBytes(StandardCharsets.UTF_8));
+ }
+ }
+
+ /**
+ * Tests that encoding a non-list returns the object specified.
+ *
+ * @throws Exception on exception in the encoder
+ */
+ @Test
+ public void testNoList() throws Exception {
+ OFMessageEncoder encoder = new OFMessageEncoder();
+ MockOfMessage message = new MockOfMessage();
+ OFMessage returnedMessage =
+ (OFMessage) encoder.encode(null, null, message);
+ assertThat(message, is(returnedMessage));
+ }
+
+ /**
+ * Tests that encoding a list returns the proper encoded payload.
+ *
+ * @throws Exception on exception in the encoder
+ */
+ @Test
+ public void testList() throws Exception {
+ OFMessageEncoder encoder = new OFMessageEncoder();
+ MockOfMessage message1 = new MockOfMessage();
+ MockOfMessage message2 = new MockOfMessage();
+ MockOfMessage message3 = new MockOfMessage();
+ List<MockOfMessage> messages = ImmutableList.of(message1, message2, message3);
+ ChannelBuffer returnedChannel =
+ (ChannelBuffer) encoder.encode(null, null, messages);
+ assertThat(returnedChannel, notNullValue());
+ byte[] channelBytes = returnedChannel.array();
+ String expectedListMessage = "message1 message2 message3 ";
+ String listMessage =
+ (new String(channelBytes, StandardCharsets.UTF_8))
+ .substring(0, expectedListMessage.length());
+ assertThat(listMessage, is(expectedListMessage));
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplPacketsTest.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplPacketsTest.java
new file mode 100644
index 00000000..13086ca7
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplPacketsTest.java
@@ -0,0 +1,167 @@
+/*
+ * 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.openflow.controller.impl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.openflow.ExecutorServiceAdapter;
+import org.onosproject.openflow.MockOfFeaturesReply;
+import org.onosproject.openflow.MockOfPacketIn;
+import org.onosproject.openflow.MockOfPortStatus;
+import org.onosproject.openflow.OfMessageAdapter;
+import org.onosproject.openflow.OpenFlowSwitchListenerAdapter;
+import org.onosproject.openflow.OpenflowSwitchDriverAdapter;
+import org.onosproject.openflow.controller.Dpid;
+import org.onosproject.openflow.controller.OpenFlowPacketContext;
+import org.onosproject.openflow.controller.OpenFlowSwitch;
+import org.onosproject.openflow.controller.PacketListener;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFType;
+
+import static junit.framework.TestCase.fail;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Tests for packet processing in the open flow controller impl class.
+ */
+public class OpenFlowControllerImplPacketsTest {
+ OpenFlowControllerImpl controller;
+ OpenFlowControllerImpl.OpenFlowSwitchAgent agent;
+ Dpid dpid1;
+ OpenFlowSwitch switch1;
+ OpenFlowSwitchListenerAdapter switchListener;
+ TestPacketListener packetListener;
+ TestExecutorService executorService;
+
+ /**
+ * Mock packet listener that accumulates packets.
+ */
+ class TestPacketListener implements PacketListener {
+ List<OpenFlowPacketContext> contexts = new ArrayList<>();
+
+ @Override
+ public void handlePacket(OpenFlowPacketContext pktCtx) {
+ contexts.add(pktCtx);
+ }
+
+ List<OpenFlowPacketContext> contexts() {
+ return contexts;
+ }
+ }
+
+
+ /**
+ * Mock executor service that tracks submits.
+ */
+ static class TestExecutorService extends ExecutorServiceAdapter {
+ private List<OFMessage> submittedMessages = new ArrayList<>();
+
+ List<OFMessage> submittedMessages() {
+ return submittedMessages;
+ }
+
+ @Override
+ public Future<?> submit(Runnable task) {
+ OpenFlowControllerImpl.OFMessageHandler handler =
+ (OpenFlowControllerImpl.OFMessageHandler) task;
+ submittedMessages.add(handler.msg);
+ return null;
+ }
+ }
+
+ /**
+ * Sets up switches to use as data, mocks and launches a controller instance.
+ */
+ @Before
+ public void setUp() {
+ try {
+ switch1 = new OpenflowSwitchDriverAdapter();
+ dpid1 = Dpid.dpid(new URI("of:0000000000000111"));
+ } catch (URISyntaxException ex) {
+ // Does not happen
+ fail();
+ }
+
+ controller = new OpenFlowControllerImpl();
+ agent = controller.agent;
+ switchListener = new OpenFlowSwitchListenerAdapter();
+ controller.addListener(switchListener);
+
+ packetListener = new TestPacketListener();
+ controller.addPacketListener(100, packetListener);
+
+ executorService = new TestExecutorService();
+ controller.executorMsgs = executorService;
+ }
+
+ /**
+ * Tests a port status operation.
+ */
+ @Test
+ public void testPortStatus() {
+ OFMessage portStatusPacket = new MockOfPortStatus();
+ controller.processPacket(dpid1, portStatusPacket);
+ assertThat(switchListener.portChangedDpids().size(), is(1));
+ assertThat(switchListener.portChangedDpids().containsKey(dpid1),
+ is(true));
+ assertThat(switchListener.portChangedDpids().get(dpid1),
+ equalTo(portStatusPacket));
+ }
+
+ /**
+ * Tests a features reply operation.
+ */
+ @Test
+ public void testFeaturesReply() {
+ OFMessage ofFeaturesReplyPacket = new MockOfFeaturesReply();
+ controller.processPacket(dpid1, ofFeaturesReplyPacket);
+ assertThat(switchListener.changedDpids(), hasSize(1));
+ assertThat(switchListener.changedDpids().get(0),
+ equalTo(dpid1));
+ }
+
+ /**
+ * Tests a packet in operation.
+ */
+ @Test
+ public void testPacketIn() {
+ agent.addConnectedSwitch(dpid1, switch1);
+ OFMessage packetInPacket = new MockOfPacketIn();
+ controller.processPacket(dpid1, packetInPacket);
+ assertThat(packetListener.contexts(), hasSize(1));
+ }
+
+ /**
+ * Tests an error operation.
+ */
+ @Test
+ public void testError() {
+ agent.addConnectedSwitch(dpid1, switch1);
+ OfMessageAdapter errorPacket = new OfMessageAdapter(OFType.ERROR);
+ controller.processPacket(dpid1, errorPacket);
+ assertThat(executorService.submittedMessages(), hasSize(1));
+ assertThat(executorService.submittedMessages().get(0), is(errorPacket));
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplTest.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplTest.java
new file mode 100644
index 00000000..e079c590
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OpenFlowControllerImplTest.java
@@ -0,0 +1,283 @@
+/*
+ * 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.openflow.controller.impl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+
+import org.easymock.EasyMock;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.junit.TestTools;
+import org.onosproject.cfg.ComponentConfigService;
+import org.onosproject.openflow.OpenflowSwitchDriverAdapter;
+import org.onosproject.openflow.controller.Dpid;
+import org.onosproject.openflow.controller.OpenFlowSwitch;
+import org.onosproject.openflow.controller.OpenFlowSwitchListener;
+import org.onosproject.openflow.controller.RoleState;
+import org.osgi.service.component.ComponentContext;
+import org.projectfloodlight.openflow.protocol.OFPortStatus;
+
+import com.google.common.collect.ImmutableSet;
+
+import static junit.framework.TestCase.fail;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+
+/**
+ * Unit tests for the open flow controller implementation test.
+ */
+public class OpenFlowControllerImplTest {
+
+ OpenFlowSwitch switch1;
+ Dpid dpid1;
+ OpenFlowSwitch switch2;
+ Dpid dpid2;
+ OpenFlowSwitch switch3;
+ Dpid dpid3;
+
+ OpenFlowControllerImpl controller;
+ OpenFlowControllerImpl.OpenFlowSwitchAgent agent;
+ TestSwitchListener switchListener;
+
+ /**
+ * Test harness for a switch listener.
+ */
+ static class TestSwitchListener implements OpenFlowSwitchListener {
+ final List<Dpid> removedDpids = new ArrayList<>();
+ final List<Dpid> addedDpids = new ArrayList<>();
+ final List<Dpid> changedDpids = new ArrayList<>();
+
+ @Override
+ public void switchAdded(Dpid dpid) {
+ addedDpids.add(dpid);
+ }
+
+ @Override
+ public void switchRemoved(Dpid dpid) {
+ removedDpids.add(dpid);
+ }
+
+ @Override
+ public void switchChanged(Dpid dpid) {
+ changedDpids.add(dpid);
+ }
+
+ @Override
+ public void portChanged(Dpid dpid, OFPortStatus status) {
+ // Stub
+ }
+
+ @Override
+ public void receivedRoleReply(Dpid dpid, RoleState requested, RoleState response) {
+ // Stub
+ }
+ }
+
+
+ /**
+ * Sets up switches to use as data, mocks and launches a controller instance.
+ */
+ @Before
+ public void setUp() {
+ try {
+ switch1 = new OpenflowSwitchDriverAdapter();
+ dpid1 = Dpid.dpid(new URI("of:0000000000000111"));
+ switch2 = new OpenflowSwitchDriverAdapter();
+ dpid2 = Dpid.dpid(new URI("of:0000000000000222"));
+ switch3 = new OpenflowSwitchDriverAdapter();
+ dpid3 = Dpid.dpid(new URI("of:0000000000000333"));
+ } catch (URISyntaxException ex) {
+ // Does not happen
+ fail();
+ }
+
+ controller = new OpenFlowControllerImpl();
+ agent = controller.agent;
+
+ switchListener = new TestSwitchListener();
+ controller.addListener(switchListener);
+
+ ComponentConfigService mockConfigService =
+ EasyMock.createMock(ComponentConfigService.class);
+ expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
+ mockConfigService.registerProperties(controller.getClass());
+ expectLastCall();
+ mockConfigService.unregisterProperties(controller.getClass(), false);
+ expectLastCall();
+ expect(mockConfigService.getProperties(anyObject())).andReturn(ImmutableSet.of());
+ controller.cfgService = mockConfigService;
+ replay(mockConfigService);
+
+ ComponentContext mockContext = EasyMock.createMock(ComponentContext.class);
+ Dictionary<String, String> properties = new Hashtable<>();
+ properties.put("openflowPorts",
+ Integer.toString(TestTools.findAvailablePort(0)));
+ expect(mockContext.getProperties()).andReturn(properties);
+ replay(mockContext);
+ controller.activate(mockContext);
+ }
+
+ @After
+ public void tearDown() {
+ controller.removeListener(switchListener);
+ controller.deactivate();
+ }
+
+ /**
+ * Converts an Iterable of some type into a stream of that type.
+ *
+ * @param items Iterable of objects
+ * @param <T> type of the items in the iterable
+ * @return stream of objects of type T
+ */
+ private <T> Stream<T> makeIntoStream(Iterable<T> items) {
+ return StreamSupport.stream(
+ Spliterators.spliteratorUnknownSize(
+ items.iterator(), Spliterator.ORDERED), false);
+ }
+
+
+ /**
+ * Tests adding and removing connected switches.
+ */
+ @Test
+ public void testAddRemoveConnectedSwitch() {
+
+ // test adding connected switches
+ boolean addSwitch1 = agent.addConnectedSwitch(dpid1, switch1);
+ assertThat(addSwitch1, is(true));
+ boolean addSwitch2 = agent.addConnectedSwitch(dpid2, switch2);
+ assertThat(addSwitch2, is(true));
+ boolean addSwitch3 = agent.addConnectedSwitch(dpid3, switch3);
+ assertThat(addSwitch3, is(true));
+
+ // Make sure the listener add callbacks fired
+ assertThat(switchListener.addedDpids, hasSize(3));
+ assertThat(switchListener.addedDpids, hasItems(dpid1, dpid2, dpid3));
+
+ // Test adding a switch twice - it should fail
+ boolean addBadSwitch1 = agent.addConnectedSwitch(dpid1, switch1);
+ assertThat(addBadSwitch1, is(false));
+
+ assertThat(controller.connectedSwitches.size(), is(3));
+
+ // test querying the switch list
+ Stream<OpenFlowSwitch> fetchedSwitches =
+ makeIntoStream(controller.getSwitches());
+ long switchCount = fetchedSwitches.count();
+ assertThat(switchCount, is(3L));
+
+ // test querying the individual switch
+ OpenFlowSwitch queriedSwitch = controller.getSwitch(dpid1);
+ assertThat(queriedSwitch, is(switch1));
+
+ // Remove a switch
+ agent.removeConnectedSwitch(dpid3);
+ Stream<OpenFlowSwitch> fetchedSwitchesAfterRemove =
+ makeIntoStream(controller.getSwitches());
+ long switchCountAfterRemove = fetchedSwitchesAfterRemove.count();
+ assertThat(switchCountAfterRemove, is(2L));
+
+ // Make sure the listener delete callbacks fired
+ assertThat(switchListener.removedDpids, hasSize(1));
+ assertThat(switchListener.removedDpids, hasItems(dpid3));
+
+ // test querying the removed switch
+ OpenFlowSwitch queriedSwitchAfterRemove = controller.getSwitch(dpid3);
+ assertThat(queriedSwitchAfterRemove, nullValue());
+ }
+
+ /**
+ * Tests adding master switches.
+ */
+ @Test
+ public void testMasterSwitch() {
+ agent.addConnectedSwitch(dpid1, switch1);
+ agent.transitionToMasterSwitch(dpid1);
+
+ Stream<OpenFlowSwitch> fetchedMasterSwitches =
+ makeIntoStream(controller.getMasterSwitches());
+ assertThat(fetchedMasterSwitches.count(), is(1L));
+ Stream<OpenFlowSwitch> fetchedActivatedSwitches =
+ makeIntoStream(controller.getEqualSwitches());
+ assertThat(fetchedActivatedSwitches.count(), is(0L));
+ OpenFlowSwitch fetchedSwitch1 = controller.getMasterSwitch(dpid1);
+ assertThat(fetchedSwitch1, is(switch1));
+
+ agent.addConnectedSwitch(dpid2, switch2);
+ boolean addSwitch2 = agent.addActivatedMasterSwitch(dpid2, switch2);
+ assertThat(addSwitch2, is(true));
+ OpenFlowSwitch fetchedSwitch2 = controller.getMasterSwitch(dpid2);
+ assertThat(fetchedSwitch2, is(switch2));
+ }
+
+ /**
+ * Tests adding equal switches.
+ */
+ @Test
+ public void testEqualSwitch() {
+ agent.addConnectedSwitch(dpid1, switch1);
+ agent.transitionToEqualSwitch(dpid1);
+
+ Stream<OpenFlowSwitch> fetchedEqualSwitches =
+ makeIntoStream(controller.getEqualSwitches());
+ assertThat(fetchedEqualSwitches.count(), is(1L));
+ Stream<OpenFlowSwitch> fetchedActivatedSwitches =
+ makeIntoStream(controller.getMasterSwitches());
+ assertThat(fetchedActivatedSwitches.count(), is(0L));
+ OpenFlowSwitch fetchedSwitch1 = controller.getEqualSwitch(dpid1);
+ assertThat(fetchedSwitch1, is(switch1));
+
+ agent.addConnectedSwitch(dpid2, switch2);
+ boolean addSwitch2 = agent.addActivatedEqualSwitch(dpid2, switch2);
+ assertThat(addSwitch2, is(true));
+ OpenFlowSwitch fetchedSwitch2 = controller.getEqualSwitch(dpid2);
+ assertThat(fetchedSwitch2, is(switch2));
+ }
+
+ /**
+ * Tests changing switch role.
+ */
+ @Test
+ public void testRoleSetting() {
+ agent.addConnectedSwitch(dpid2, switch2);
+
+ // check that state can be changed for a connected switch
+ assertThat(switch2.getRole(), is(RoleState.MASTER));
+ controller.setRole(dpid2, RoleState.EQUAL);
+ assertThat(switch2.getRole(), is(RoleState.EQUAL));
+
+ // check that changing state on an unconnected switch does not crash
+ controller.setRole(dpid3, RoleState.SLAVE);
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/RoleManagerTest.java b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/RoleManagerTest.java
new file mode 100644
index 00000000..4b594383
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/RoleManagerTest.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2014-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.openflow.controller.impl;
+
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onosproject.openflow.OpenflowSwitchDriverAdapter;
+import org.onosproject.openflow.controller.RoleState;
+import org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver;
+import org.onosproject.openflow.controller.driver.RoleRecvStatus;
+import org.onosproject.openflow.controller.driver.RoleReplyInfo;
+import org.onosproject.openflow.controller.driver.SwitchStateException;
+import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFFeaturesReply;
+import org.projectfloodlight.openflow.types.U64;
+
+import static org.junit.Assert.assertEquals;
+import static org.onosproject.openflow.controller.RoleState.MASTER;
+import static org.onosproject.openflow.controller.RoleState.SLAVE;
+import static org.onosproject.openflow.controller.driver.RoleRecvStatus.MATCHED_CURRENT_ROLE;
+import static org.onosproject.openflow.controller.driver.RoleRecvStatus.OTHER_EXPECTATION;
+
+public class RoleManagerTest {
+
+ private static final U64 GID = U64.of(10L);
+ private static final long XID = 1L;
+
+ private OpenFlowSwitchDriver sw;
+ private RoleManager manager;
+
+ @Before
+ public void setUp() {
+ sw = new TestSwitchDriver();
+ manager = new RoleManager(sw);
+ }
+
+ @After
+ public void tearDown() {
+ manager = null;
+ sw = null;
+ }
+
+ @Test
+ public void deliverRoleReply() {
+ RoleRecvStatus status;
+
+ RoleReplyInfo asserted = new RoleReplyInfo(MASTER, GID, XID);
+ RoleReplyInfo unasserted = new RoleReplyInfo(SLAVE, GID, XID);
+
+ try {
+ //call without sendRoleReq() for requestPending = false
+ //first, sw.role == null
+ status = manager.deliverRoleReply(asserted);
+ assertEquals("expectation wrong", OTHER_EXPECTATION, status);
+
+ sw.setRole(MASTER);
+ assertEquals("expectation wrong", OTHER_EXPECTATION, status);
+ sw.setRole(SLAVE);
+
+ //match to pendingRole = MASTER, requestPending = true
+ manager.sendRoleRequest(MASTER, MATCHED_CURRENT_ROLE);
+ status = manager.deliverRoleReply(asserted);
+ assertEquals("expectation wrong", MATCHED_CURRENT_ROLE, status);
+
+ //requestPending never gets reset -- this might be a bug.
+ status = manager.deliverRoleReply(unasserted);
+ assertEquals("expectation wrong", OTHER_EXPECTATION, status);
+ assertEquals("pending role mismatch", MASTER, ((TestSwitchDriver) sw).failed);
+
+ } catch (IOException | SwitchStateException e) {
+ assertEquals("unexpected error thrown",
+ SwitchStateException.class, e.getClass());
+ }
+ }
+
+ private class TestSwitchDriver extends OpenflowSwitchDriverAdapter {
+
+ RoleState failed = null;
+ RoleState current = null;
+
+ @Override
+ public void setRole(RoleState role) {
+ current = role;
+ }
+
+ @Override
+ public RoleState getRole() {
+ return current;
+ }
+
+ @Override
+ public void setFeaturesReply(OFFeaturesReply featuresReply) {
+ }
+
+ @Override
+ public void setSwitchDescription(OFDescStatsReply desc) {
+ }
+
+ @Override
+ public int getNextTransactionId() {
+ return (int) XID;
+ }
+
+ @Override
+ public void returnRoleReply(RoleState requested, RoleState response) {
+ failed = requested;
+ }
+
+ @Override
+ public String channelId() {
+ return "1.2.3.4:1";
+ }
+ }
+}
diff --git a/framework/src/onos/protocols/openflow/drivers/src/main/java/org/onosproject/openflow/drivers/OFSwitchImplSpringOpenTTPDellOSR.java b/framework/src/onos/protocols/openflow/drivers/src/main/java/org/onosproject/openflow/drivers/OFSwitchImplSpringOpenTTPDellOSR.java
new file mode 100644
index 00000000..783a37e6
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/drivers/src/main/java/org/onosproject/openflow/drivers/OFSwitchImplSpringOpenTTPDellOSR.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.openflow.drivers;
+
+import org.onosproject.openflow.controller.Dpid;
+import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
+import org.projectfloodlight.openflow.types.TableId;
+
+/**
+ * OFDescriptionStatistics Vendor (Manufacturer Desc.): Dell Make (Hardware
+ * Desc.) : OpenFlow 1.3 Reference Userspace Switch Model (Datapath Desc.) :
+ * None Software : Serial : None.
+ */
+//TODO: Knock-off this class as we don't need any switch/app specific
+//drivers in the south bound layers.
+public class OFSwitchImplSpringOpenTTPDellOSR extends OFSwitchImplSpringOpenTTP {
+
+ /* Table IDs to be used for Dell Open Segment Routers*/
+ private static final int DELL_TABLE_VLAN = 17;
+ private static final int DELL_TABLE_TMAC = 18;
+ private static final int DELL_TABLE_IPV4_UNICAST = 30;
+ private static final int DELL_TABLE_MPLS = 25;
+ private static final int DELL_TABLE_ACL = 40;
+
+ public OFSwitchImplSpringOpenTTPDellOSR(Dpid dpid, OFDescStatsReply desc) {
+ super(dpid, desc);
+ vlanTableId = DELL_TABLE_VLAN;
+ tmacTableId = DELL_TABLE_TMAC;
+ ipv4UnicastTableId = DELL_TABLE_IPV4_UNICAST;
+ mplsTableId = DELL_TABLE_MPLS;
+ aclTableId = DELL_TABLE_ACL;
+ }
+
+ @Override
+ public TableType getTableType(TableId tid) {
+ switch (tid.getValue()) {
+ case DELL_TABLE_IPV4_UNICAST:
+ return TableType.IP;
+ case DELL_TABLE_MPLS:
+ return TableType.MPLS;
+ case DELL_TABLE_ACL:
+ return TableType.ACL;
+ case DELL_TABLE_VLAN:
+ return TableType.VLAN;
+ case DELL_TABLE_TMAC:
+ return TableType.ETHER;
+ default:
+ log.error("Table type for Table id {} is not supported in the driver", tid);
+ return TableType.NONE;
+ }
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/protocols/openflow/pom.xml b/framework/src/onos/protocols/openflow/pom.xml
new file mode 100644
index 00000000..5a136a19
--- /dev/null
+++ b/framework/src/onos/protocols/openflow/pom.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-protocols</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-of</artifactId>
+ <packaging>pom</packaging>
+
+ <description>ONOS OpenFlow Protocol subsystem</description>
+
+ <modules>
+ <module>api</module>
+ <module>ctl</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-misc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/framework/src/onos/protocols/ovsdb/api/pom.xml b/framework/src/onos/protocols/ovsdb/api/pom.xml
new file mode 100644
index 00000000..c264ae97
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+<!--
+ ~ 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.
+ -->
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>onos-ovsdb-api</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS OVSDB plugin API</description>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-pool</groupId>
+ <artifactId>commons-pool</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-transport</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-transport-native-epoll</artifactId>
+ <version>${netty4.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-rfc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/DefaultEventSubject.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/DefaultEventSubject.java
new file mode 100644
index 00000000..5d9134b4
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/DefaultEventSubject.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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+import java.util.Set;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+
+/**
+ * This class is default event subject that implements OvsdbEventSubject.
+ */
+public class DefaultEventSubject implements OvsdbEventSubject {
+ private final MacAddress mac;
+ private final Set<IpAddress> ips;
+ private final OvsdbPortName portname;
+ private final OvsdbPortNumber portnumber;
+ private final OvsdbDatapathId dpid;
+ private final OvsdbPortType portType;
+ private final OvsdbIfaceId ifaceid;
+
+ /**
+ * Creates an end-station event subject using the supplied information.
+ *
+ * @param mac host MAC address
+ * @param ips host MAC ips
+ * @param portname port name
+ * @param portnumber port number
+ * @param dpid ovs dpid
+ * @param portType port type
+ * @param ifaceid vm ifaceid
+ */
+ public DefaultEventSubject(MacAddress mac, Set<IpAddress> ips,
+ OvsdbPortName portname, OvsdbPortNumber portnumber, OvsdbDatapathId dpid,
+ OvsdbPortType portType, OvsdbIfaceId ifaceid) {
+ super();
+ this.mac = mac;
+ this.ips = ips;
+ this.portname = portname;
+ this.portnumber = portnumber;
+ this.dpid = dpid;
+ this.portType = portType;
+ this.ifaceid = ifaceid;
+ }
+
+ @Override
+ public MacAddress hwAddress() {
+ return mac;
+ }
+
+ @Override
+ public Set<IpAddress> ipAddress() {
+ return ips;
+ }
+
+ @Override
+ public OvsdbPortName portName() {
+ return portname;
+ }
+
+ @Override
+ public OvsdbPortNumber portNumber() {
+ return portnumber;
+ }
+
+ @Override
+ public OvsdbPortType portType() {
+ return portType;
+ }
+
+ @Override
+ public OvsdbDatapathId dpid() {
+ return dpid;
+ }
+
+ @Override
+ public OvsdbIfaceId ifaceid() {
+ return ifaceid;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mac, portname, portnumber, dpid, portType, ifaceid);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultEventSubject) {
+ final DefaultEventSubject other = (DefaultEventSubject) obj;
+ return Objects.equals(this.mac, other.mac)
+ && Objects.equals(this.portname, other.portname)
+ && Objects.equals(this.portnumber, other.portnumber)
+ && Objects.equals(this.dpid, other.dpid)
+ && Objects.equals(this.portType, other.portType)
+ && Objects.equals(this.ifaceid, other.ifaceid);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("mac", mac).add("portname", portname)
+ .add("portnumber", portnumber).add("portType", portType)
+ .add("ipAddresses", ips).add("dpid", dpid).add("ifaceid", ifaceid)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/EventSubject.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/EventSubject.java
new file mode 100644
index 00000000..d8aaef65
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/EventSubject.java
@@ -0,0 +1,22 @@
+/*
+ * 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.ovsdb.controller;
+
+/**
+ * Representation for an entity that carries important information for a listener.
+ */
+public interface EventSubject {
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridge.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridge.java
new file mode 100644
index 00000000..18c59e14
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridge.java
@@ -0,0 +1,88 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * The class representing an ovsdb bridge.
+ * This class is immutable.
+ */
+public final class OvsdbBridge {
+
+ private final OvsdbBridgeName bridgeName;
+ private final OvsdbDatapathId datapathId;
+
+ /**
+ * Constructor from an OvsdbBridgeName bridgeName and an OvsdbDatapathId
+ * datapathId.
+ *
+ * @param bridgeName the bridgeName to use
+ * @param datapathId the datapathId to use
+ */
+ public OvsdbBridge(OvsdbBridgeName bridgeName, OvsdbDatapathId datapathId) {
+ checkNotNull(bridgeName, "bridgeName is not null");
+ checkNotNull(datapathId, "datapathId is not null");
+ this.bridgeName = bridgeName;
+ this.datapathId = datapathId;
+ }
+
+ /**
+ * Gets the bridge name of bridge.
+ *
+ * @return the bridge name of bridge
+ */
+ public OvsdbBridgeName bridgeName() {
+ return bridgeName;
+ }
+
+ /**
+ * Gets the datapathId of bridge.
+ *
+ * @return datapathId the datapathId to use
+ */
+ public OvsdbDatapathId datapathId() {
+ return datapathId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(bridgeName, datapathId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbBridge) {
+ final OvsdbBridge otherOvsdbBridge = (OvsdbBridge) obj;
+ return Objects.equals(this.bridgeName, otherOvsdbBridge.bridgeName)
+ && Objects.equals(this.datapathId,
+ otherOvsdbBridge.datapathId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("bridgeName", bridgeName.value())
+ .add("datapathId", datapathId.value()).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridgeName.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridgeName.java
new file mode 100644
index 00000000..759ec499
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridgeName.java
@@ -0,0 +1,72 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * The class representing a bridge name.
+ * This class is immutable.
+ */
+public final class OvsdbBridgeName {
+
+ private final String value;
+
+ /**
+ * Constructor from a String.
+ *
+ * @param value the bridge name to use
+ */
+ public OvsdbBridgeName(String value) {
+ checkNotNull(value, "value is not null");
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of bridge name.
+ *
+ * @return the value of the bridge name
+ */
+ public String value() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbBridgeName) {
+ final OvsdbBridgeName otherBridgeName = (OvsdbBridgeName) obj;
+ return Objects.equals(this.value, otherBridgeName.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("value", value).toString();
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java
new file mode 100644
index 00000000..a35fa6cf
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbClientService.java
@@ -0,0 +1,301 @@
+/*
+ * 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.ovsdb.controller;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.behaviour.ControllerInfo;
+import org.onosproject.ovsdb.rfc.jsonrpc.OvsdbRPC;
+import org.onosproject.ovsdb.rfc.message.OperationResult;
+import org.onosproject.ovsdb.rfc.message.TableUpdates;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.operations.Operation;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Represents to provider facing side of a node.
+ */
+public interface OvsdbClientService extends OvsdbRPC {
+ /**
+ * Gets the node identifier.
+ *
+ * @return node identifier
+ */
+ OvsdbNodeId nodeId();
+
+ /**
+ * Creates the configuration for tunnel.
+ *
+ * @param srcIp source IP address
+ * @param dstIp destination IP address
+ */
+ @Deprecated
+ void createTunnel(IpAddress srcIp, IpAddress dstIp);
+
+ /**
+ * Creates a tunnel port with given options.
+ *
+ * @param bridgeName bridge name
+ * @param portName port name
+ * @param tunnelType tunnel type
+ * @param options tunnel options
+ * @return true if tunnel creation is successful, false otherwise
+ */
+ boolean createTunnel(String bridgeName, String portName, String tunnelType, Map<String, String> options);
+
+ /**
+ * Drops the configuration for tunnel.
+ *
+ * @param srcIp source IP address
+ * @param dstIp destination IP address
+ */
+ void dropTunnel(IpAddress srcIp, IpAddress dstIp);
+
+ /**
+ * Gets tunnels of node.
+ *
+ * @return set of tunnels; empty if no tunnel is find
+ */
+ Set<OvsdbTunnel> getTunnels();
+
+ /**
+ * Creates a bridge.
+ *
+ * @param bridgeName bridge name
+ */
+ void createBridge(String bridgeName);
+
+ /**
+ * Creates a bridge.
+ *
+ * @param bridgeName bridge name
+ * @param dpid data path id
+ * @param exPortName external port name
+ */
+ void createBridge(String bridgeName, String dpid, String exPortName);
+
+ /**
+ * Creates a bridge with given name and dpid.
+ * Sets the bridge's controller with given controllers.
+ *
+ * @param bridgeName bridge name
+ * @param dpid data path id
+ * @param controllers controllers
+ * @return true if bridge creation is successful, false otherwise
+ */
+ boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers);
+
+ /**
+ * Drops a bridge.
+ *
+ * @param bridgeName bridge name
+ */
+ void dropBridge(String bridgeName);
+
+ /**
+ * Gets bridges of node.
+ *
+ * @return set of bridges; empty if no bridge is find
+ */
+ Set<OvsdbBridge> getBridges();
+
+ /**
+ * Gets controllers of node.
+ *
+ * @param openflowDeviceId target device id
+ * @return set of controllers; empty if no controller is find
+ */
+ Set<ControllerInfo> getControllers(DeviceId openflowDeviceId);
+
+ /**
+ * Sets the Controllers for the specified bridge.
+ * <p>
+ * This method will replace the existing controller list with the new controller
+ * list.
+ *
+ * @param bridgeUuid bridge uuid
+ * @param controllers list of controllers
+ */
+ void setControllersWithUUID(UUID bridgeUuid, List<ControllerInfo> controllers);
+
+ /**
+ * Sets the Controllers for the specified device.
+ * <p>
+ * This method will replace the existing controller list with the new controller
+ * list.
+ *
+ * @param deviceId device id (likely Openflow device)
+ * @param controllers list of controllers
+ */
+ void setControllersWithDeviceId(DeviceId deviceId, List<ControllerInfo> controllers);
+
+ /**
+ * Creates a port.
+ *
+ * @param bridgeName bridge name
+ * @param portName port name
+ */
+ void createPort(String bridgeName, String portName);
+
+ /**
+ * Drops a port.
+ *
+ * @param bridgeName bridge name
+ * @param portName port name
+ */
+ void dropPort(String bridgeName, String portName);
+
+ /**
+ * Gets ports of bridge.
+ *
+ * @return set of ports; empty if no ports is find
+ */
+ Set<OvsdbPort> getPorts();
+
+ /**
+ * Checks if the node is still connected.
+ *
+ * @return true if the node is still connected
+ */
+ boolean isConnected();
+
+ /**
+ * Gets the Bridge uuid.
+ *
+ * @param bridgeName bridge name
+ * @return bridge uuid, empty if no uuid is find
+ */
+ String getBridgeUuid(String bridgeName);
+
+ /**
+ * Gets the Port uuid.
+ *
+ * @param portName port name
+ * @param bridgeUuid bridge uuid
+ * @return port uuid, empty if no uuid is find
+ */
+ String getPortUuid(String portName, String bridgeUuid);
+
+ /**
+ * Gets the Interface uuid.
+ *
+ * @param portUuid port uuid
+ * @param portName port name
+ * @return interface uuid, empty if no uuid is find
+ */
+ String getInterfaceUuid(String portUuid, String portName);
+
+ /**
+ * Gets the Controller uuid.
+ *
+ * @param controllerName controller name
+ * @param controllerTarget controller target
+ * @return controller uuid, empty if no uuid is find
+ */
+ String getControllerUuid(String controllerName, String controllerTarget);
+
+ /**
+ * Gets the OVS uuid.
+ *
+ * @param dbName database name
+ * @return ovs uuid, empty if no uuid is find
+ */
+ String getOvsUuid(String dbName);
+
+ /**
+ * Gets the OVSDB database schema.
+ *
+ * @param dbName database name
+ * @return database schema
+ */
+ ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName);
+
+ /**
+ * Gets the OVSDB table updates.
+ *
+ * @param dbName database name
+ * @param id random uuid
+ * @return table updates
+ */
+ ListenableFuture<TableUpdates> monitorTables(String dbName, String id);
+
+ /**
+ * Gets the OVSDB config operation result.
+ *
+ * @param dbName database name
+ * @param operations the list of operations
+ * @return operation results
+ */
+ ListenableFuture<List<OperationResult>> transactConfig(String dbName,
+ List<Operation> operations);
+
+ /**
+ * Gets the OVSDB database schema from local.
+ *
+ * @param dbName database name
+ * @return database schema
+ */
+ DatabaseSchema getDatabaseSchema(String dbName);
+
+ /**
+ * Gets the OVSDB row from local OVSDB store.
+ *
+ * @param dbName database name
+ * @param tableName table name
+ * @param uuid row uuid
+ * @return row OVSDB row
+ */
+ Row getRow(String dbName, String tableName, String uuid);
+
+ /**
+ * Removes the OVSDB row from local OVSDB store.
+ *
+ * @param dbName database name
+ * @param tableName table name
+ * @param uuid row uuid
+ */
+ void removeRow(String dbName, String tableName, String uuid);
+
+ /**
+ * Updates the local OVSDB store.
+ *
+ * @param dbName database name
+ * @param tableName table name
+ * @param uuid row uuid
+ * @param row OVSDB row
+ */
+ void updateOvsdbStore(String dbName, String tableName, String uuid, Row row);
+
+ /**
+ * Gets OVSDB local ports.
+ *
+ * @param ifaceids the ifaceid that needed
+ * @return OVSDB ports
+ */
+ Set<OvsdbPort> getLocalPorts(Iterable<String> ifaceids);
+
+ /**
+ * Disconnects the OVSDB server.
+ */
+ void disconnect();
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbConstant.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbConstant.java
new file mode 100644
index 00000000..e91c928a
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbConstant.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.ovsdb.controller;
+
+/**
+ * Ovsdb related constants.
+ */
+public final class OvsdbConstant {
+
+ /**
+ * Default constructor.
+ *
+ * The constructor is private to prevent creating an instance of this
+ * utility class.
+ */
+ private OvsdbConstant() {
+ }
+
+ /** Ovsdb database Open_vSwitch. */
+ public static final String DATABASENAME = "Open_vSwitch";
+
+ /** Ovsdb table Bridge. */
+ public static final String BRIDGE = "Bridge";
+
+ /** Ovsdb table Interface. */
+ public static final String INTERFACE = "Interface";
+
+ /** Ovsdb table Controller. */
+ public static final String CONTROLLER = "Controller";
+
+ /** Ovsdb table Port. */
+ public static final String PORT = "Port";
+
+ /** Ovsdb bridge name. */
+ public static final String INTEGRATION_BRIDGE = "br-int";
+
+ /** Ovsdb vxlan tunnel type. */
+ public static final String TYPEVXLAN = "vxlan";
+
+ /** Openflow version. */
+ public static final String OPENFLOW13 = "OpenFlow13";
+
+ /** Ovsdb external_id_interface_id.. */
+ public static final String EXTERNAL_ID_INTERFACE_ID = "iface-id";
+
+ /** Ovsdb external_id_vm_mac. */
+ public static final String EXTERNAL_ID_VM_MAC = "attached-mac";
+
+ /** Openflow port. */
+ public static final int OFPORT = 6653;
+
+ /** Ovsdb port. */
+ public static final int OVSDBPORT = 6640;
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbController.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbController.java
new file mode 100644
index 00000000..f22a5787
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbController.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.ovsdb.controller;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+
+import java.util.List;
+
+/**
+ * Abstraction of an ovsdb controller. Serves as an one stop shop for obtaining
+ * OvsdbNode and (un)register listeners on ovsdb events and ovsdb node events.
+ */
+public interface OvsdbController {
+
+ /**
+ * Adds Node Event Listener.
+ *
+ * @param listener node listener
+ */
+ void addNodeListener(OvsdbNodeListener listener);
+
+ /**
+ * Removes Node Event Listener.
+ *
+ * @param listener node listener
+ */
+ void removeNodeListener(OvsdbNodeListener listener);
+
+ /**
+ * Adds ovsdb event listener.
+ *
+ * @param listener event listener
+ */
+ void addOvsdbEventListener(OvsdbEventListener listener);
+
+ /**
+ * Removes ovsdb event listener.
+ *
+ * @param listener event listener
+ */
+ void removeOvsdbEventListener(OvsdbEventListener listener);
+
+ /**
+ * Gets all the nodes information.
+ *
+ * @return the list of node id
+ */
+ List<OvsdbNodeId> getNodeIds();
+
+ /**
+ * Gets an ovsdb client by node identifier.
+ *
+ * @param nodeId node identifier
+ * @return OvsdbClient ovsdb node information
+ */
+ OvsdbClientService getOvsdbClient(OvsdbNodeId nodeId);
+
+ /**
+ * Connect to the ovsdb server with given ip address and port number.
+ *
+ * @param ip ip address
+ * @param port port number
+ */
+ void connect(IpAddress ip, TpPort port);
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbDatapathId.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbDatapathId.java
new file mode 100644
index 00000000..02989afa
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbDatapathId.java
@@ -0,0 +1,69 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.Objects;
+
+/**
+ * The class representing a datapathid.
+ * This class is immutable.
+ */
+public final class OvsdbDatapathId {
+ private final String value;
+
+ /**
+ * Constructor from a String.
+ *
+ * @param value the datapathid to use
+ */
+ public OvsdbDatapathId(String value) {
+ checkNotNull(value, "value is not null");
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of datapathid.
+ *
+ * @return the value of datapathid
+ */
+ public String value() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbDatapathId) {
+ final OvsdbDatapathId otherDatapathId = (OvsdbDatapathId) obj;
+ return Objects.equals(this.value, otherDatapathId.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("value", value).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEvent.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEvent.java
new file mode 100644
index 00000000..f68b3c8a
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEvent.java
@@ -0,0 +1,74 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * The abstract event of ovsdb.
+ */
+public final class OvsdbEvent<S> {
+
+ public enum Type {
+ /**
+ * Signifies that a new ovs port update has been detected.
+ */
+ PORT_ADDED,
+ /**
+ * Signifies that a ovs port has been removed.
+ */
+ PORT_REMOVED
+ }
+
+ private final Type type;
+ private final S subject;
+
+ /**
+ * Creates an event of a given type and for the specified event subject.
+ *
+ * @param type event type
+ * @param subject event subject
+ */
+ public OvsdbEvent(Type type, S subject) {
+ this.type = type;
+ this.subject = subject;
+ }
+
+ /**
+ * Returns the type of event.
+ *
+ * @return event type
+ */
+ public Type type() {
+ return type;
+ }
+
+ /**
+ * Returns the subject of event.
+ *
+ * @return subject to which this event pertains
+ */
+ public S subject() {
+ return subject;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("type", type())
+ .add("subject", subject()).toString();
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEventListener.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEventListener.java
new file mode 100644
index 00000000..b7bf2b55
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEventListener.java
@@ -0,0 +1,28 @@
+/*
+ * 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.ovsdb.controller;
+
+/**
+ * Allows for providers interested in ovsdb events to be notified.
+ */
+public interface OvsdbEventListener {
+ /**
+ * Handles the ovsdb event.
+ *
+ * @param event ovsdb event
+ */
+ void handle(OvsdbEvent<EventSubject> event);
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEventSubject.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEventSubject.java
new file mode 100644
index 00000000..226a26e6
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEventSubject.java
@@ -0,0 +1,75 @@
+/*
+ * 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.ovsdb.controller;
+
+import java.util.Set;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+
+/**
+ * Represents for an entity that carry important information for listener.
+ */
+public interface OvsdbEventSubject extends EventSubject {
+ /**
+ * Returns the MAC address associated with this host (NIC).
+ *
+ * @return the MAC address of this host
+ */
+ MacAddress hwAddress();
+
+ /**
+ * Returns the IP address associated with this host's MAC.
+ *
+ * @return host IP address
+ */
+ Set<IpAddress> ipAddress();
+
+ /**
+ * Returns the Port name associated with the host.
+ *
+ * @return port name
+ */
+ OvsdbPortName portName();
+
+ /**
+ * Returns the Port number associated with the host.
+ *
+ * @return port number
+ */
+ OvsdbPortNumber portNumber();
+
+ /**
+ * Returns the Port type associated with the host.
+ *
+ * @return port type
+ */
+ OvsdbPortType portType();
+
+ /**
+ * Returns the Ovs dpid associated with the host.
+ *
+ * @return Ovs dpid
+ */
+ OvsdbDatapathId dpid();
+
+ /**
+ * Returns the vm ifaceid associated with the host.
+ *
+ * @return vm ifaceid
+ */
+ OvsdbIfaceId ifaceid();
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbIfaceId.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbIfaceId.java
new file mode 100644
index 00000000..bf724fa4
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbIfaceId.java
@@ -0,0 +1,69 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.Objects;
+
+/**
+ * The class representing an ifaceid.
+ * This class is immutable.
+ */
+public class OvsdbIfaceId {
+ private final String value;
+
+ /**
+ * Constructor from a String.
+ *
+ * @param value the ifaceid to use
+ */
+ public OvsdbIfaceId(String value) {
+ checkNotNull(value, "value is not null");
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of ifaceid.
+ *
+ * @return the value of ifaceid
+ */
+ public String value() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbIfaceId) {
+ final OvsdbIfaceId otherIfaceId = (OvsdbIfaceId) obj;
+ return Objects.equals(this.value, otherIfaceId.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("value", value).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java
new file mode 100644
index 00000000..60146c85
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java
@@ -0,0 +1,83 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * The class representing a nodeId of node which using ovsdb connection.
+ * This class is immutable.
+ */
+public final class OvsdbNodeId {
+ private static final String SCHEME = "ovsdb";
+ private final String nodeId;
+ private final String ipAddress;
+
+ /**
+ * Creates a new node identifier from an IpAddress ipAddress, a long port.
+ *
+ * @param ipAddress node IP address
+ * @param port node port
+ */
+ public OvsdbNodeId(IpAddress ipAddress, long port) {
+ checkNotNull(ipAddress, "ipAddress is not null");
+ this.ipAddress = ipAddress.toString();
+ this.nodeId = ipAddress.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return nodeId.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof OvsdbNodeId)) {
+ return false;
+ }
+
+ OvsdbNodeId otherNodeId = (OvsdbNodeId) other;
+
+ return Objects.equals(otherNodeId.nodeId, this.nodeId);
+ }
+
+ @Override
+ public String toString() {
+ return SCHEME + ":" + nodeId;
+ }
+
+ /**
+ * Gets the value of the NodeId.
+ *
+ * @return the value of the NodeId.
+ */
+ public String nodeId() {
+ return SCHEME + ":" + nodeId;
+ }
+
+ /**
+ * Get the IP address of the node.
+ *
+ * @return the IP address of the node
+ */
+ public String getIpAddress() {
+ return ipAddress;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeListener.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeListener.java
new file mode 100644
index 00000000..ca732ef9
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeListener.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.ovsdb.controller;
+
+/**
+ * Allows for providers interested in node events to be notified.
+ */
+public interface OvsdbNodeListener {
+
+ /**
+ * Notifies that the node was added.
+ *
+ * @param nodeId the node where the event occurred
+ */
+ void nodeAdded(OvsdbNodeId nodeId);
+
+ /**
+ * Notifies that the node was removed.
+ *
+ * @param nodeId the node where the event occurred
+ */
+ void nodeRemoved(OvsdbNodeId nodeId);
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPort.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPort.java
new file mode 100644
index 00000000..deea42d7
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPort.java
@@ -0,0 +1,86 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * The class representing a ovsdb port. This class is immutable.
+ */
+public final class OvsdbPort {
+
+ private final OvsdbPortNumber portNumber;
+ private final OvsdbPortName portName;
+
+ /**
+ * Constructor from OvsdbPortNumber portNumber, OvsdbPortName portName.
+ *
+ * @param portNumber the portNumber to use
+ * @param portName the portName to use
+ */
+ public OvsdbPort(OvsdbPortNumber portNumber, OvsdbPortName portName) {
+ checkNotNull(portNumber, "portNumber is not null");
+ checkNotNull(portName, "portName is not null");
+ this.portNumber = portNumber;
+ this.portName = portName;
+ }
+
+ /**
+ * Gets the port number of port.
+ *
+ * @return the port number of port
+ */
+ public OvsdbPortNumber portNumber() {
+ return portNumber;
+ }
+
+ /**
+ * Gets the port name of port.
+ *
+ * @return the port name of port
+ */
+ public OvsdbPortName portName() {
+ return portName;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(portNumber, portName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbPort) {
+ final OvsdbPort otherOvsdbPort = (OvsdbPort) obj;
+ return Objects.equals(this.portNumber, otherOvsdbPort.portNumber)
+ && Objects.equals(this.portName, otherOvsdbPort.portName);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("portNumber", String.valueOf(portNumber.value()))
+ .add("portName", portName.value()).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortName.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortName.java
new file mode 100644
index 00000000..7d40e99f
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortName.java
@@ -0,0 +1,71 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * The class representing a port number.
+ * This class is immutable.
+ */
+public final class OvsdbPortName {
+
+ private final String value;
+
+ /**
+ * Constructor from a String.
+ *
+ * @param value the port name to use
+ */
+ public OvsdbPortName(String value) {
+ checkNotNull(value, "value is not null");
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of port name.
+ *
+ * @return the value of port name
+ */
+ public String value() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbPortName) {
+ final OvsdbPortName otherOvsdbPortName = (OvsdbPortName) obj;
+ return Objects.equals(this.value, otherOvsdbPortName.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("value", value).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortNumber.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortNumber.java
new file mode 100644
index 00000000..86fc887a
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortNumber.java
@@ -0,0 +1,69 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+/**
+ * The class representing a port number.
+ * This class is immutable.
+ */
+public final class OvsdbPortNumber {
+
+ private final long value;
+
+ /**
+ * Constructor from a long value.
+ *
+ * @param value the port number to use
+ */
+ public OvsdbPortNumber(long value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of port number.
+ *
+ * @return the value of port number
+ */
+ public long value() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(value);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbPortNumber) {
+ final OvsdbPortNumber ovsdbPortNumber = (OvsdbPortNumber) obj;
+ return Objects.equals(this.value, ovsdbPortNumber.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("value", value).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortType.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortType.java
new file mode 100644
index 00000000..fb7cdb00
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortType.java
@@ -0,0 +1,71 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * The class representing a port type.
+ * This class is immutable.
+ */
+public class OvsdbPortType {
+
+ private final String value;
+
+ /**
+ * Constructor from a String.
+ *
+ * @param value the port type to use
+ */
+ public OvsdbPortType(String value) {
+ checkNotNull(value, "value is not null");
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of port type.
+ *
+ * @return the value of port type
+ */
+ public String value() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbPortType) {
+ final OvsdbPortType otherOvsdbPortType = (OvsdbPortType) obj;
+ return Objects.equals(this.value, otherOvsdbPortType.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("value", value).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbRowStore.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbRowStore.java
new file mode 100644
index 00000000..bec0e2e9
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbRowStore.java
@@ -0,0 +1,69 @@
+/*
+ * 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.ovsdb.controller;
+
+import java.util.concurrent.ConcurrentMap;
+
+import org.onosproject.ovsdb.rfc.notation.Row;
+
+import com.google.common.collect.Maps;
+
+/**
+ * The class representing a table data.
+ */
+public class OvsdbRowStore {
+
+ private final ConcurrentMap<String, Row> rowStore = Maps.newConcurrentMap();
+
+ /**
+ * Gets the row.
+ *
+ * @param uuid the key of the rowStore
+ * @return row the row of the rowStore
+ */
+ public Row getRow(String uuid) {
+ return rowStore.get(uuid);
+ }
+
+ /**
+ * Inserts a row to rowStore.
+ *
+ * @param uuid key of the row
+ * @param row a row of the table
+ */
+ public void insertRow(String uuid, Row row) {
+ rowStore.put(uuid, row);
+ }
+
+ /**
+ * Deletes a row to rowStore.
+ *
+ * @param uuid key of the row
+ */
+ public void deleteRow(String uuid) {
+ rowStore.remove(uuid);
+ }
+
+ /**
+ * Gets the rowStore.
+ *
+ * @return rowStore
+ */
+ public ConcurrentMap<String, Row> getRowStore() {
+ return rowStore;
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbStore.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbStore.java
new file mode 100644
index 00000000..56704908
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbStore.java
@@ -0,0 +1,71 @@
+/*
+ * 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.ovsdb.controller;
+
+import java.util.concurrent.ConcurrentMap;
+
+import com.google.common.collect.Maps;
+
+/**
+ * The cache for local ovsdb database.
+ */
+public class OvsdbStore {
+
+ private final ConcurrentMap<String, OvsdbTableStore> ovsdbStore = Maps.newConcurrentMap();
+
+ /**
+ * Gets the OvsdbTableStore.
+ *
+ * @param dbName ovsdb database name
+ * @return tableStore OvsdbTableStore
+ */
+ public OvsdbTableStore getOvsdbTableStore(String dbName) {
+ OvsdbTableStore tableStore = ovsdbStore.get(dbName);
+ if (tableStore == null) {
+ return null;
+ }
+ return tableStore;
+ }
+
+ /**
+ * Create or Update a value to ovsdbStore.
+ *
+ * @param dbName ovsdb database name
+ * @param tableStore a database tableStore.
+ */
+ public void createOrUpdateOvsdbStore(String dbName, OvsdbTableStore tableStore) {
+ ovsdbStore.put(dbName, tableStore);
+ }
+
+ /**
+ * Drops a value to rowStore.
+ *
+ * @param dbName ovsdb database name
+ */
+ public void dropOvsdbStore(String dbName) {
+ ovsdbStore.remove(dbName);
+ }
+
+ /**
+ * Gets the ovsdbStore.
+ *
+ * @return ovsdbStore
+ */
+ public ConcurrentMap<String, OvsdbTableStore> getOvsdbStore() {
+ return ovsdbStore;
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTableStore.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTableStore.java
new file mode 100644
index 00000000..72b64f32
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTableStore.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.ovsdb.controller;
+
+import java.util.concurrent.ConcurrentMap;
+
+import com.google.common.collect.Maps;
+
+/**
+ * The class representing a database data.
+ */
+public class OvsdbTableStore {
+
+ private final ConcurrentMap<String, OvsdbRowStore> tableStore = Maps.newConcurrentMap();
+
+ /**
+ * Gets the ovsdbRowStore.
+ *
+ * @param tableName an ovsdb table name
+ * @return OvsdbRowStore the data of table
+ */
+ public OvsdbRowStore getRows(String tableName) {
+ return tableStore.get(tableName);
+ }
+
+ /**
+ * Creates or updates a value to tableStore.
+ *
+ * @param tableName key of tableName
+ * @param rowStore a row of table
+ */
+ public void createOrUpdateTable(String tableName, OvsdbRowStore rowStore) {
+ tableStore.put(tableName, rowStore);
+ }
+
+ /**
+ * Drops a value to table data.
+ *
+ * @param tableName key of tableName
+ */
+ public void dropTable(String tableName) {
+ tableStore.remove(tableName);
+ }
+
+ /**
+ * Gets tableStore.
+ *
+ * @return tableStore
+ */
+ public ConcurrentMap<String, OvsdbRowStore> getTableStore() {
+ return tableStore;
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnel.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnel.java
new file mode 100644
index 00000000..8c857da4
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnel.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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * The class representing an ovsdb tunnel.
+ * This class is immutable.
+ */
+public final class OvsdbTunnel {
+
+ private final IpAddress localIp;
+ private final IpAddress remoteIp;
+
+ public enum Type {
+ VXLAN, GRE
+ }
+
+ private final Type tunnelType;
+ private final OvsdbTunnelName tunnelName;
+
+ /**
+ * Constructor from an IpAddress localIp, IpAddress remoteIp Type tunnelType,
+ * OvsdbTunnelName tunnelName.
+ *
+ * @param localIp the localIp to use
+ * @param remoteIp the remoteIp to use
+ * @param tunnelType the tunnelType to use
+ * @param tunnelName the tunnelName to use
+ */
+ public OvsdbTunnel(IpAddress localIp, IpAddress remoteIp, Type tunnelType,
+ OvsdbTunnelName tunnelName) {
+ checkNotNull(localIp, "portName is not null");
+ checkNotNull(remoteIp, "portName is not null");
+ checkNotNull(tunnelName, "portName is not null");
+ this.localIp = localIp;
+ this.remoteIp = remoteIp;
+ this.tunnelType = tunnelType;
+ this.tunnelName = tunnelName;
+ }
+
+ /**
+ * Gets the local IP of tunnel.
+ *
+ * @return the local IP of tunnel
+ */
+ public IpAddress localIp() {
+ return localIp;
+ }
+
+ /**
+ * Gets the remote IP of tunnel.
+ *
+ * @return the remote IP of tunnel
+ */
+ public IpAddress remoteIp() {
+ return remoteIp;
+ }
+
+ /**
+ * Gets the tunnel type of tunnel.
+ *
+ * @return the tunnel type of tunnel
+ */
+ public Type tunnelType() {
+ return tunnelType;
+ }
+
+ /**
+ * Gets the tunnel name of tunnel.
+ *
+ * @return the tunnel name of tunnel
+ */
+ public OvsdbTunnelName tunnelName() {
+ return tunnelName;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localIp, remoteIp, tunnelType, tunnelName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbTunnel) {
+ final OvsdbTunnel otherOvsdbTunnel = (OvsdbTunnel) obj;
+ return Objects.equals(this.localIp, otherOvsdbTunnel.localIp)
+ && Objects.equals(this.remoteIp, otherOvsdbTunnel.remoteIp)
+ && Objects.equals(this.tunnelType,
+ otherOvsdbTunnel.tunnelType)
+ && Objects.equals(this.tunnelName,
+ otherOvsdbTunnel.tunnelName);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("localIp", localIp.toString())
+ .add("remoteIp", remoteIp.toString())
+ .add("tunnelType", tunnelType).add("tunnelName", tunnelName)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnelName.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnelName.java
new file mode 100644
index 00000000..490d640b
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnelName.java
@@ -0,0 +1,70 @@
+/*
+ * 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.ovsdb.controller;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * The class representing a tunnel name.
+ * This class is immutable.
+ */
+public final class OvsdbTunnelName {
+ private final String value;
+
+ /**
+ * Constructor from a String.
+ *
+ * @param value the tunnel name to use
+ */
+ public OvsdbTunnelName(String value) {
+ checkNotNull(value, "value is not null");
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of tunnel name.
+ *
+ * @return the value of tunnel name
+ */
+ public String value() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbTunnelName) {
+ final OvsdbTunnelName otherOvsdbTunnelName = (OvsdbTunnelName) obj;
+ return Objects.equals(this.value, otherOvsdbTunnelName.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("value", value).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
new file mode 100644
index 00000000..8a661ab9
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
@@ -0,0 +1,1503 @@
+/*
+ * 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.ovsdb.controller.driver;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+
+import io.netty.channel.Channel;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.behaviour.ControllerInfo;
+import org.onosproject.ovsdb.controller.OvsdbBridge;
+import org.onosproject.ovsdb.controller.OvsdbBridgeName;
+import org.onosproject.ovsdb.controller.OvsdbClientService;
+import org.onosproject.ovsdb.controller.OvsdbConstant;
+import org.onosproject.ovsdb.controller.OvsdbDatapathId;
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
+import org.onosproject.ovsdb.controller.OvsdbPort;
+import org.onosproject.ovsdb.controller.OvsdbPortName;
+import org.onosproject.ovsdb.controller.OvsdbPortNumber;
+import org.onosproject.ovsdb.controller.OvsdbRowStore;
+import org.onosproject.ovsdb.controller.OvsdbStore;
+import org.onosproject.ovsdb.controller.OvsdbTableStore;
+import org.onosproject.ovsdb.controller.OvsdbTunnel;
+import org.onosproject.ovsdb.rfc.exception.BridgeCreateException;
+import org.onosproject.ovsdb.rfc.jsonrpc.Callback;
+import org.onosproject.ovsdb.rfc.message.OperationResult;
+import org.onosproject.ovsdb.rfc.message.TableUpdates;
+import org.onosproject.ovsdb.rfc.notation.Condition;
+import org.onosproject.ovsdb.rfc.notation.Mutation;
+import org.onosproject.ovsdb.rfc.notation.OvsdbMap;
+import org.onosproject.ovsdb.rfc.notation.OvsdbSet;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.operations.Delete;
+import org.onosproject.ovsdb.rfc.operations.Insert;
+import org.onosproject.ovsdb.rfc.operations.Mutate;
+import org.onosproject.ovsdb.rfc.operations.Operation;
+import org.onosproject.ovsdb.rfc.operations.Update;
+import org.onosproject.ovsdb.rfc.schema.ColumnSchema;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+import org.onosproject.ovsdb.rfc.table.Bridge;
+import org.onosproject.ovsdb.rfc.table.Controller;
+import org.onosproject.ovsdb.rfc.table.Interface;
+import org.onosproject.ovsdb.rfc.table.OvsdbTable;
+import org.onosproject.ovsdb.rfc.table.Port;
+import org.onosproject.ovsdb.rfc.table.TableGenerator;
+import org.onosproject.ovsdb.rfc.utils.ConditionUtil;
+import org.onosproject.ovsdb.rfc.utils.FromJsonUtil;
+import org.onosproject.ovsdb.rfc.utils.JsonRpcWriterUtil;
+import org.onosproject.ovsdb.rfc.utils.MutationUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+
+/**
+ * An representation of an ovsdb client.
+ */
+public class DefaultOvsdbClient
+ implements OvsdbProviderService, OvsdbClientService {
+
+ private final Logger log = LoggerFactory
+ .getLogger(DefaultOvsdbClient.class);
+
+ private Channel channel;
+
+ private OvsdbAgent agent;
+ private boolean connected;
+ private OvsdbNodeId nodeId;
+ private Callback monitorCallBack;
+
+ private OvsdbStore ovsdbStore = new OvsdbStore();
+
+ private final Map<String, String> requestMethod = Maps.newHashMap();
+ private final Map<String, SettableFuture<? extends Object>> requestResult = Maps
+ .newHashMap();
+
+ private final Map<String, DatabaseSchema> schema = Maps.newHashMap();
+ private final Set<OvsdbTunnel> ovsdbTunnels = new HashSet<OvsdbTunnel>();
+
+ /**
+ * Creates an OvsdbClient.
+ *
+ * @param nodeId ovsdb node id
+ */
+ public DefaultOvsdbClient(OvsdbNodeId nodeId) {
+ this.nodeId = nodeId;
+ }
+
+ @Override
+ public OvsdbNodeId nodeId() {
+ return nodeId;
+ }
+
+ @Override
+ public void setAgent(OvsdbAgent agent) {
+ if (this.agent == null) {
+ this.agent = agent;
+ }
+ }
+
+ @Override
+ public void setChannel(Channel channel) {
+ this.channel = channel;
+ }
+
+ @Override
+ public void setConnection(boolean connected) {
+ this.connected = connected;
+ }
+
+ @Override
+ public boolean isConnected() {
+ return this.connected;
+ }
+
+ @Override
+ public void nodeAdded() {
+ this.agent.addConnectedNode(nodeId, this);
+ }
+
+ @Override
+ public void nodeRemoved() {
+ this.agent.removeConnectedNode(nodeId);
+ channel.disconnect();
+ }
+
+ /**
+ * Gets the ovsdb table store.
+ *
+ * @param dbName the ovsdb database name
+ * @return ovsTableStore, empty if table store is find
+ */
+ private OvsdbTableStore getTableStore(String dbName) {
+ if (ovsdbStore == null) {
+ return null;
+ }
+ return ovsdbStore.getOvsdbTableStore(dbName);
+ }
+
+ /**
+ * Gets the ovsdb row store.
+ *
+ * @param dbName the ovsdb database name
+ * @param tableName the ovsdb table name
+ * @return ovsRowStore, empty store if no rows exist in the table
+ */
+ private OvsdbRowStore getRowStore(String dbName, String tableName) {
+ OvsdbTableStore tableStore = getTableStore(dbName);
+ if (tableStore == null) {
+ return null;
+ }
+
+ OvsdbRowStore rowStore = tableStore.getRows(tableName);
+ if (rowStore == null) {
+ rowStore = new OvsdbRowStore();
+ }
+ return rowStore;
+ }
+
+ /**
+ * Gets the ovsdb row.
+ *
+ * @param dbName the ovsdb database name
+ * @param tableName the ovsdb table name
+ * @param uuid the key of the row
+ * @return row, empty if row is find
+ */
+ @Override
+ public Row getRow(String dbName, String tableName, String uuid) {
+ OvsdbTableStore tableStore = getTableStore(dbName);
+ if (tableStore == null) {
+ return null;
+ }
+ OvsdbRowStore rowStore = tableStore.getRows(tableName);
+ if (rowStore == null) {
+ return null;
+ }
+ return rowStore.getRow(uuid);
+ }
+
+ @Override
+ public void removeRow(String dbName, String tableName, String uuid) {
+ OvsdbTableStore tableStore = getTableStore(dbName);
+ if (tableStore == null) {
+ return;
+ }
+ OvsdbRowStore rowStore = tableStore.getRows(tableName);
+ if (rowStore == null) {
+ return;
+ }
+ rowStore.deleteRow(uuid);
+ }
+
+ @Override
+ public void updateOvsdbStore(String dbName, String tableName, String uuid,
+ Row row) {
+ OvsdbTableStore tableStore = ovsdbStore.getOvsdbTableStore(dbName);
+ if (tableStore == null) {
+ tableStore = new OvsdbTableStore();
+ }
+ OvsdbRowStore rowStore = tableStore.getRows(tableName);
+ if (rowStore == null) {
+ rowStore = new OvsdbRowStore();
+ }
+ rowStore.insertRow(uuid, row);
+ tableStore.createOrUpdateTable(tableName, rowStore);
+ ovsdbStore.createOrUpdateOvsdbStore(dbName, tableStore);
+ }
+
+ @Override
+ public String getPortUuid(String portName, String bridgeUuid) {
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+
+ Row bridgeRow = getRow(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.BRIDGE, bridgeUuid);
+
+ Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow,
+ OvsdbTable.BRIDGE);
+ if (bridge != null) {
+ OvsdbSet setPorts = (OvsdbSet) bridge.getPortsColumn().data();
+ @SuppressWarnings("unchecked")
+ Set<UUID> ports = setPorts.set();
+ if (ports == null || ports.size() == 0) {
+ log.warn("The port uuid is null");
+ return null;
+ }
+
+ for (UUID uuid : ports) {
+ Row portRow = getRow(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.PORT, uuid.value());
+ Port port = (Port) TableGenerator.getTable(dbSchema, portRow,
+ OvsdbTable.PORT);
+ if (port != null && portName.equalsIgnoreCase(port.getName())) {
+ return uuid.value();
+ }
+ }
+
+ }
+ return null;
+ }
+
+ @Override
+ public String getInterfaceUuid(String portUuid, String portName) {
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+
+ Row portRow = getRow(OvsdbConstant.DATABASENAME, OvsdbConstant.PORT,
+ portUuid);
+ Port port = (Port) TableGenerator.getTable(dbSchema, portRow,
+ OvsdbTable.PORT);
+
+ if (port != null) {
+ OvsdbSet setInterfaces = (OvsdbSet) port.getInterfacesColumn().data();
+ @SuppressWarnings("unchecked")
+ Set<UUID> interfaces = setInterfaces.set();
+
+ if (interfaces == null || interfaces.size() == 0) {
+ log.warn("The interface uuid is null");
+ return null;
+ }
+
+ for (UUID uuid : interfaces) {
+ Row intfRow = getRow(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.INTERFACE, uuid.value());
+ Interface intf = (Interface) TableGenerator
+ .getTable(dbSchema, intfRow, OvsdbTable.INTERFACE);
+ if (intf != null && portName.equalsIgnoreCase(intf.getName())) {
+ return uuid.value();
+ }
+ }
+
+ }
+
+ return null;
+ }
+
+ @Override
+ public String getBridgeUuid(String bridgeName) {
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+
+ OvsdbRowStore rowStore = getRowStore(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.BRIDGE);
+ if (rowStore == null) {
+ log.debug("The bridge uuid is null");
+ return null;
+ }
+
+ ConcurrentMap<String, Row> bridgeTableRows = rowStore.getRowStore();
+ if (bridgeTableRows == null) {
+ log.debug("The bridge uuid is null");
+ return null;
+ }
+
+ for (String uuid : bridgeTableRows.keySet()) {
+ Bridge bridge = (Bridge) TableGenerator
+ .getTable(dbSchema, bridgeTableRows.get(uuid),
+ OvsdbTable.BRIDGE);
+
+ if (bridge.getName().equals(bridgeName)) {
+ return uuid;
+ }
+
+ }
+ return null;
+ }
+
+ @Override
+ public String getControllerUuid(String controllerName,
+ String controllerTarget) {
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ OvsdbRowStore rowStore = getRowStore(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.CONTROLLER);
+ if (rowStore == null) {
+ log.debug("The controller uuid is null");
+ return null;
+ }
+
+ ConcurrentMap<String, Row> controllerTableRows = rowStore.getRowStore();
+ if (controllerTableRows != null) {
+ for (String uuid : controllerTableRows.keySet()) {
+
+ Controller controller = (Controller) TableGenerator
+ .getTable(dbSchema, controllerTableRows.get(uuid),
+ OvsdbTable.CONTROLLER);
+ String target = (String) controller.getTargetColumn().data();
+ if (target.equalsIgnoreCase(controllerTarget)) {
+ return uuid;
+ }
+
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getOvsUuid(String dbName) {
+ OvsdbRowStore rowStore = getRowStore(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.DATABASENAME);
+ if (rowStore == null) {
+ log.debug("The bridge uuid is null");
+ return null;
+ }
+ ConcurrentMap<String, Row> ovsTableRows = rowStore.getRowStore();
+ if (ovsTableRows != null) {
+ for (String uuid : ovsTableRows.keySet()) {
+ Row row = ovsTableRows.get(uuid);
+ String tableName = row.tableName();
+ if (tableName.equals(dbName)) {
+ return uuid;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void createPort(String bridgeName, String portName) {
+ String bridgeUuid = getBridgeUuid(bridgeName);
+ if (bridgeUuid == null) {
+ log.error("Can't find bridge {} in {}", bridgeName,
+ nodeId.getIpAddress());
+ return;
+ }
+
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ String portUuid = getPortUuid(portName, bridgeUuid);
+
+ Port port = (Port) TableGenerator
+ .createTable(dbSchema, OvsdbTable.PORT);
+
+ port.setName(portName);
+ if (portUuid == null) {
+ insertConfig(OvsdbConstant.PORT, "_uuid", OvsdbConstant.BRIDGE,
+ "ports", bridgeUuid, port.getRow());
+ } else {
+ updateConfig(OvsdbConstant.PORT, "_uuid", portUuid, port.getRow());
+ }
+
+ return;
+ }
+
+ @Override
+ public void dropPort(String bridgeName, String portName) {
+ String bridgeUuid = getBridgeUuid(bridgeName);
+ if (bridgeUuid == null) {
+ log.error("Could not find Bridge {} in {}", bridgeName, nodeId);
+ return;
+ }
+
+ String portUuid = getPortUuid(portName, bridgeUuid);
+ if (portUuid != null) {
+ log.info("Port {} delete", portName);
+ deleteConfig(OvsdbConstant.PORT, "_uuid", portUuid,
+ OvsdbConstant.BRIDGE, "ports");
+ }
+ }
+
+ @Override
+ public void createBridge(String bridgeName) {
+ log.debug("create bridge {}", bridgeName);
+
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ if (dbSchema == null) {
+ log.warn("The schema is null");
+ return;
+ }
+
+ Bridge bridge = (Bridge) TableGenerator.createTable(dbSchema,
+ OvsdbTable.BRIDGE);
+ if (bridge == null) {
+ log.debug("Can not create bridge");
+ return;
+ }
+
+ Set<String> failModes = new HashSet<>();
+ failModes.add("secure");
+ bridge.setFailMode(failModes);
+
+ Set<String> protocols = new HashSet<>();
+ protocols.add(OvsdbConstant.OPENFLOW13);
+ bridge.setProtocols(protocols);
+
+ String ovsUuid = getOvsUuid(OvsdbConstant.DATABASENAME);
+ if (ovsUuid == null) {
+ log.warn("The Open_vSwitch is null");
+ return;
+ }
+
+ String bridgeUuid = getBridgeUuid(bridgeName);
+ if (bridgeUuid == null) {
+ log.debug("Create a new bridge");
+
+ bridge.setName(bridgeName);
+ bridgeUuid = insertConfig(OvsdbConstant.BRIDGE, "_uuid",
+ OvsdbConstant.DATABASENAME, "bridges",
+ ovsUuid, bridge.getRow());
+
+ if (bridgeUuid != null) {
+ Port port = (Port) TableGenerator.createTable(dbSchema,
+ OvsdbTable.PORT);
+ if (port != null) {
+ log.debug("the port is not null");
+ port.setName(bridgeName);
+
+ insertConfig(OvsdbConstant.PORT, "_uuid", "Bridge", "ports", bridgeUuid,
+ port.getRow());
+ }
+ } else {
+ String message = BridgeCreateException.createMessage(ovsUuid);
+ throw new BridgeCreateException(message);
+ }
+
+ } else {
+ log.info("Update a bridge");
+ updateConfig(OvsdbConstant.BRIDGE, "_uuid", bridgeUuid, bridge.getRow());
+ }
+
+ setControllerAuto(bridgeUuid);
+ log.info("Create bridge success");
+ }
+
+ @Override
+ public void createBridge(String bridgeName, String dpid, String exPortName) {
+ log.debug("create bridge {}", bridgeName);
+
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ if (dbSchema == null) {
+ log.warn("The schema is null");
+ return;
+ }
+
+ Bridge bridge = (Bridge) TableGenerator.createTable(dbSchema,
+ OvsdbTable.BRIDGE);
+ if (bridge == null) {
+ log.debug("Can not create bridge");
+ return;
+ }
+
+ Set<String> failModes = new HashSet<>();
+ failModes.add("secure");
+ bridge.setFailMode(failModes);
+
+ Set<String> protocols = new HashSet<>();
+ protocols.add(OvsdbConstant.OPENFLOW13);
+ bridge.setProtocols(protocols);
+
+ String ovsUuid = getOvsUuid(OvsdbConstant.DATABASENAME);
+ if (ovsUuid == null) {
+ log.warn("The Open_vSwitch is null");
+ return;
+ }
+
+ String bridgeUuid = getBridgeUuid(bridgeName);
+ if (bridgeUuid == null) {
+ log.debug("Create a new bridge");
+
+ bridge.setName(bridgeName);
+ if (dpid != null) {
+ Map<String, String> options = new HashMap<>();
+ options.put("datapath-id", dpid);
+ bridge.setOtherConfig(options);
+ }
+ bridgeUuid = insertConfig(OvsdbConstant.BRIDGE, "_uuid",
+ OvsdbConstant.DATABASENAME, "bridges",
+ ovsUuid, bridge.getRow());
+
+ if (bridgeUuid != null) {
+ Port port = (Port) TableGenerator.createTable(dbSchema,
+ OvsdbTable.PORT);
+ if (port != null) {
+ log.debug("the port is not null");
+ port.setName(bridgeName);
+
+ insertConfig(OvsdbConstant.PORT, "_uuid", "Bridge", "ports", bridgeUuid,
+ port.getRow());
+ }
+ } else {
+ String message = BridgeCreateException.createMessage(ovsUuid);
+ throw new BridgeCreateException(message);
+ }
+
+ } else {
+ log.info("Update a bridge");
+ updateConfig(OvsdbConstant.BRIDGE, "_uuid", bridgeUuid, bridge.getRow());
+ }
+ // Create external port
+ if (exPortName != null) {
+ createPort(bridgeName, exPortName);
+ }
+
+ setControllerAuto(bridgeUuid);
+ log.info("Create bridge success");
+ }
+
+ @Override
+ public boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers) {
+
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ String ovsUuid = getOvsUuid(OvsdbConstant.DATABASENAME);
+
+ if (dbSchema == null || ovsUuid == null) {
+ log.warn("Couldn't find database Open_vSwitch");
+ return false;
+ }
+
+ String bridgeUuid = getBridgeUuid(bridgeName);
+ if (bridgeUuid != null) {
+ log.warn("Bridge {} is already exist", bridgeName);
+ // remove existing one and re-create?
+ return false;
+ }
+
+ Bridge bridge = (Bridge) TableGenerator.createTable(dbSchema, OvsdbTable.BRIDGE);
+ bridge.setName(bridgeName);
+
+ Set<String> failMode = new HashSet<>(Arrays.asList("secure"));
+ bridge.setFailMode(failMode);
+
+ Set<String> protocols = new HashSet<>(Arrays.asList(OvsdbConstant.OPENFLOW13));
+ bridge.setProtocols(protocols);
+
+ Map<String, String> options = new HashMap<>();
+ options.put("datapath-id", dpid);
+ bridge.setOtherConfig(options);
+
+ bridgeUuid = insertConfig(OvsdbConstant.BRIDGE, "_uuid",
+ OvsdbConstant.DATABASENAME, "bridges",
+ ovsUuid, bridge.getRow());
+
+ if (bridgeUuid != null) {
+ createPort(bridgeName, bridgeName);
+ } else {
+ log.warn("Failed to create bridge {} on {}", bridgeName, nodeId.toString());
+ return false;
+ }
+
+ setControllersWithUUID(UUID.uuid(bridgeUuid), controllers);
+ return true;
+ }
+
+ /**
+ * Sets the bridge's controller automatically.
+ * <p/>
+ * The connection is a TCP connection to the local ONOS instance's IP
+ * and the default OpenFlow port.
+ *
+ * @param bridgeUuid bridge uuid
+ */
+ private void setControllerAuto(String bridgeUuid) {
+ IpAddress ipAddress = IpAddress.valueOf(((InetSocketAddress) channel.localAddress()).getAddress());
+ ControllerInfo controllerInfo = new ControllerInfo(ipAddress, OvsdbConstant.OFPORT, "tcp");
+ log.debug("Automatically setting controller for bridge {} to {}",
+ bridgeUuid, controllerInfo.target());
+ setControllersWithUUID(UUID.uuid(bridgeUuid), ImmutableList.of(controllerInfo));
+ }
+
+ @Override
+ public void setControllersWithUUID(UUID bridgeUuid, List<ControllerInfo> controllers) {
+
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ if (dbSchema == null) {
+ log.debug("There is no schema");
+ return;
+ }
+ List<Controller> oldControllers = getControllers(bridgeUuid);
+ if (oldControllers == null) {
+ log.warn("There are no controllers");
+ return;
+ }
+
+ Set<UUID> newControllerUuids = new HashSet<>();
+
+ Set<ControllerInfo> newControllers = new HashSet<>(controllers);
+ List<Controller> removeControllers = new ArrayList<>();
+ oldControllers.forEach(controller -> {
+ ControllerInfo controllerInfo = new ControllerInfo((String) controller.getTargetColumn().data());
+ if (newControllers.contains(controllerInfo)) {
+ newControllers.remove(controllerInfo);
+ newControllerUuids.add(controller.getRow().uuid());
+ } else {
+ removeControllers.add(controller);
+ }
+ });
+ OvsdbRowStore controllerRowStore = getRowStore(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.CONTROLLER);
+ if (controllerRowStore == null) {
+ log.debug("There is no controller table");
+ return;
+ }
+
+ removeControllers.forEach(c -> deleteConfig(OvsdbConstant.CONTROLLER, "_uuid", c.getRow().uuid().value(),
+ OvsdbConstant.BRIDGE, "controller"));
+
+ newControllers.stream().map(c -> {
+ Controller controller = (Controller) TableGenerator
+ .createTable(dbSchema, OvsdbTable.CONTROLLER);
+ controller.setTarget(c.target());
+ return controller;
+ }).forEach(c -> {
+ String uuid = insertConfig(OvsdbConstant.CONTROLLER, "_uuid",
+ OvsdbConstant.BRIDGE, "controller", bridgeUuid.value(),
+ c.getRow());
+ newControllerUuids.add(UUID.uuid(uuid));
+
+ });
+
+ OvsdbRowStore rowStore = getRowStore(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.BRIDGE);
+ if (rowStore == null) {
+ log.debug("There is no bridge table");
+ return;
+ }
+
+ Row bridgeRow = rowStore.getRow(bridgeUuid.value());
+ Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
+ bridge.setController(OvsdbSet.ovsdbSet(newControllerUuids));
+ updateConfig(OvsdbConstant.BRIDGE, "_uuid", bridgeUuid.value(), bridge.getRow());
+ }
+
+ @Override
+ public void setControllersWithDeviceId(DeviceId deviceId, List<ControllerInfo> controllers) {
+ setControllersWithUUID(getBridgeUUID(deviceId), controllers);
+ }
+
+ @Override
+ public void dropBridge(String bridgeName) {
+ String bridgeUUID = getBridgeUuid(bridgeName);
+ if (bridgeUUID == null) {
+ log.warn("Could not find bridge in node", nodeId.getIpAddress());
+ return;
+ }
+ deleteConfig(OvsdbConstant.BRIDGE, "_uuid", bridgeUUID,
+ OvsdbConstant.DATABASENAME, "bridges");
+ }
+
+ @Override
+ public void createTunnel(IpAddress srcIp, IpAddress dstIp) {
+ String bridgeUuid = getBridgeUuid(OvsdbConstant.INTEGRATION_BRIDGE);
+ if (bridgeUuid == null) {
+ log.warn("Could not find bridge {} and Could not create tunnel. ",
+ OvsdbConstant.INTEGRATION_BRIDGE);
+ return;
+ }
+
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ String portName = getTunnelName(OvsdbConstant.TYPEVXLAN, dstIp);
+ String portUuid = getPortUuid(portName, bridgeUuid);
+
+ Port port = (Port) TableGenerator
+ .createTable(dbSchema, OvsdbTable.PORT);
+ if (port != null) {
+ port.setName(portName);
+ }
+
+ if (portUuid == null) {
+ portUuid = insertConfig(OvsdbConstant.PORT, "_uuid", OvsdbConstant.BRIDGE,
+ "ports", bridgeUuid, port.getRow());
+ } else {
+ updateConfig(OvsdbConstant.PORT, "_uuid", portUuid, port.getRow());
+ }
+
+ // When a tunnel is created, A row is inserted into port table and
+ // interface table of the ovsdb node.
+ // and the following step is to get the interface uuid from local store
+ // in controller node.
+ // but it need spend some time synchronising data between node and
+ // controller.
+ // so loop to judge if interfaceUUid is null is necessary.
+ String interfaceUuid = null;
+ for (int i = 0; i < 10; i++) {
+ interfaceUuid = getInterfaceUuid(portUuid, portName);
+ if (interfaceUuid == null) {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ log.warn("Interrupted while waiting to get interfaceUuid");
+ Thread.currentThread().interrupt();
+ }
+ } else {
+ break;
+ }
+ }
+
+ if (interfaceUuid != null) {
+
+ Interface tunInterface = (Interface) TableGenerator
+ .createTable(dbSchema, OvsdbTable.INTERFACE);
+
+ if (tunInterface != null) {
+
+ tunInterface.setType(OvsdbConstant.TYPEVXLAN);
+ Map<String, String> options = Maps.newHashMap();
+ options.put("key", "flow");
+ options.put("local_ip", srcIp.toString());
+ options.put("remote_ip", dstIp.toString());
+ tunInterface.setOptions(options);
+ updateConfig(OvsdbConstant.INTERFACE, "_uuid", interfaceUuid,
+ tunInterface.getRow());
+ log.info("Tunnel added success", tunInterface);
+
+ }
+ }
+
+ return;
+ }
+
+ @Override
+ public boolean createTunnel(String bridgeName, String portName, String tunnelType, Map<String, String> options) {
+
+ String bridgeUuid = getBridgeUuid(bridgeName);
+ if (bridgeUuid == null) {
+ log.warn("Couldn't find bridge {} in {}", bridgeName, nodeId.getIpAddress());
+ return false;
+ }
+
+ if (getPortUuid(portName, bridgeUuid) != null) {
+ log.warn("Port {} already exists", portName);
+ // remove existing one and re-create?
+ return false;
+ }
+
+ ArrayList<Operation> operations = Lists.newArrayList();
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+
+ // insert a new port to the port table
+ Port port = (Port) TableGenerator.createTable(dbSchema, OvsdbTable.PORT);
+ port.setName(portName);
+ Insert portInsert = new Insert(dbSchema.getTableSchema("Port"), "Port", port.getRow());
+ portInsert.getRow().put("interfaces", UUID.uuid("Interface"));
+ operations.add(portInsert);
+
+ // update the bridge table
+ Condition condition = ConditionUtil.equals("_uuid", UUID.uuid(bridgeUuid));
+ Mutation mutation = MutationUtil.insert("ports", UUID.uuid("Port"));
+ List<Condition> conditions = new ArrayList<>(Arrays.asList(condition));
+ List<Mutation> mutations = new ArrayList<>(Arrays.asList(mutation));
+ operations.add(new Mutate(dbSchema.getTableSchema("Bridge"), conditions, mutations));
+
+ // insert a tunnel interface
+ Interface intf = (Interface) TableGenerator.createTable(dbSchema, OvsdbTable.INTERFACE);
+ intf.setName(portName);
+ intf.setType(tunnelType);
+ intf.setOptions(options);
+ Insert intfInsert = new Insert(dbSchema.getTableSchema("Interface"), "Interface", intf.getRow());
+ operations.add(intfInsert);
+
+ transactConfig(OvsdbConstant.DATABASENAME, operations);
+ return true;
+ }
+
+ @Override
+ public void dropTunnel(IpAddress srcIp, IpAddress dstIp) {
+ String bridgeName = OvsdbConstant.INTEGRATION_BRIDGE;
+ String portName = getTunnelName(OvsdbConstant.TYPEVXLAN, dstIp);
+ String bridgeUuid = getBridgeUuid(OvsdbConstant.INTEGRATION_BRIDGE);
+ if (bridgeUuid == null) {
+ log.warn("Could not find bridge {} in {}", bridgeName,
+ nodeId.getIpAddress());
+ return;
+ }
+
+ String portUUID = getPortUuid(portName, bridgeUuid);
+ if (portUUID != null) {
+ log.info("Delete tunnel");
+ deleteConfig(OvsdbConstant.PORT, "_uuid", portUUID,
+ OvsdbConstant.BRIDGE, "ports");
+ }
+
+ return;
+ }
+
+ /**
+ * Delete transact config.
+ *
+ * @param childTableName child table name
+ * @param childColumnName child column name
+ * @param childUuid child row uuid
+ * @param parentTableName parent table name
+ * @param parentColumnName parent column
+ */
+ private void deleteConfig(String childTableName, String childColumnName,
+ String childUuid, String parentTableName,
+ String parentColumnName) {
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ TableSchema childTableSchema = dbSchema.getTableSchema(childTableName);
+
+ ArrayList<Operation> operations = Lists.newArrayList();
+ if (parentTableName != null && parentColumnName != null) {
+ TableSchema parentTableSchema = dbSchema
+ .getTableSchema(parentTableName);
+ ColumnSchema parentColumnSchema = parentTableSchema
+ .getColumnSchema(parentColumnName);
+ List<Mutation> mutations = Lists.newArrayList();
+ Mutation mutation = MutationUtil.delete(parentColumnSchema.name(),
+ UUID.uuid(childUuid));
+ mutations.add(mutation);
+ List<Condition> conditions = Lists.newArrayList();
+ Condition condition = ConditionUtil.includes(parentColumnName,
+ UUID.uuid(childUuid));
+ conditions.add(condition);
+ Mutate op = new Mutate(parentTableSchema, conditions, mutations);
+ operations.add(op);
+ }
+
+ List<Condition> conditions = Lists.newArrayList();
+ Condition condition = ConditionUtil.equals(childColumnName, UUID.uuid(childUuid));
+ conditions.add(condition);
+ Delete del = new Delete(childTableSchema, conditions);
+ operations.add(del);
+ transactConfig(OvsdbConstant.DATABASENAME, operations);
+
+ return;
+ }
+
+ /**
+ * Update transact config.
+ *
+ * @param tableName table name
+ * @param columnName column name
+ * @param uuid uuid
+ * @param row the config data
+ */
+ private void updateConfig(String tableName, String columnName, String uuid,
+ Row row) {
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ TableSchema tableSchema = dbSchema.getTableSchema(tableName);
+
+ List<Condition> conditions = Lists.newArrayList();
+ Condition condition = ConditionUtil.equals(columnName, UUID.uuid(uuid));
+ conditions.add(condition);
+
+ Update update = new Update(tableSchema, row, conditions);
+
+ ArrayList<Operation> operations = Lists.newArrayList();
+ operations.add(update);
+
+ transactConfig(OvsdbConstant.DATABASENAME, operations);
+ }
+
+ /**
+ * Insert transact config.
+ *
+ * @param childTableName child table name
+ * @param childColumnName child column name
+ * @param parentTableName parent table name
+ * @param parentColumnName parent column
+ * @param parentUuid parent uuid
+ * @param row the config data
+ * @return uuid, empty if no uuid is find
+ */
+ private String insertConfig(String childTableName, String childColumnName,
+ String parentTableName, String parentColumnName,
+ String parentUuid, Row row) {
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ TableSchema tableSchema = dbSchema.getTableSchema(childTableName);
+
+ String namedUuid = childTableName;
+ Insert insert = new Insert(tableSchema, namedUuid, row);
+
+ ArrayList<Operation> operations = Lists.newArrayList();
+ operations.add(insert);
+
+ if (parentTableName != null && parentColumnName != null) {
+ TableSchema parentTableSchema = dbSchema
+ .getTableSchema(parentTableName);
+ ColumnSchema parentColumnSchema = parentTableSchema
+ .getColumnSchema(parentColumnName);
+
+ List<Mutation> mutations = Lists.newArrayList();
+ Mutation mutation = MutationUtil.insert(parentColumnSchema.name(),
+ UUID.uuid(namedUuid));
+ mutations.add(mutation);
+
+ List<Condition> conditions = Lists.newArrayList();
+ Condition condition = ConditionUtil.equals("_uuid",
+ UUID.uuid(parentUuid));
+ conditions.add(condition);
+
+ Mutate op = new Mutate(parentTableSchema, conditions, mutations);
+ operations.add(op);
+ }
+ if (childTableName.equalsIgnoreCase(OvsdbConstant.PORT)) {
+ log.info("Handle port insert");
+ Insert intfInsert = handlePortInsertTable(OvsdbConstant.INTERFACE,
+ row);
+
+ if (intfInsert != null) {
+ operations.add(intfInsert);
+ }
+
+ Insert ins = (Insert) operations.get(0);
+ ins.getRow().put("interfaces",
+ UUID.uuid(OvsdbConstant.INTERFACE));
+ }
+
+ List<OperationResult> results;
+ try {
+ results = transactConfig(OvsdbConstant.DATABASENAME, operations)
+ .get();
+
+ return results.get(0).getUuid().value();
+ } catch (InterruptedException e) {
+ log.warn("Interrupted while waiting to get result");
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ log.error("Exception thrown while to get result");
+ }
+
+ return null;
+ }
+
+ /**
+ * Handles port insert.
+ *
+ * @param tableName ovsdb table interface
+ * @param portRow row of port
+ * @return insert, empty if null
+ */
+ private Insert handlePortInsertTable(String tableName, Row portRow) {
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+
+ TableSchema portTableSchema = dbSchema
+ .getTableSchema(OvsdbConstant.PORT);
+ ColumnSchema portColumnSchema = portTableSchema.getColumnSchema("name");
+
+ String portName = (String) portRow.getColumn(portColumnSchema.name()).data();
+
+ Interface inf = (Interface) TableGenerator
+ .createTable(dbSchema, OvsdbTable.INTERFACE);
+
+ inf.setName(portName);
+
+ TableSchema intfTableSchema = dbSchema
+ .getTableSchema(OvsdbConstant.INTERFACE);
+ Insert insert = new Insert(intfTableSchema, OvsdbConstant.INTERFACE,
+ inf.getRow());
+ return insert;
+ }
+
+ /**
+ * Gets tunnel name.
+ *
+ * @param tunnelType
+ * @param dstIp the remote ip address
+ * @return tunnel name
+ */
+ private String getTunnelName(String tunnelType, IpAddress dstIp) {
+ return tunnelType + "-" + dstIp.toString();
+ }
+
+ @Override
+ public ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName) {
+ if (dbName == null) {
+ return null;
+ }
+ DatabaseSchema databaseSchema = schema.get(dbName);
+ if (databaseSchema == null) {
+ List<String> dbNames = new ArrayList<String>();
+ dbNames.add(dbName);
+ Function<JsonNode, DatabaseSchema> rowFunction = new Function<JsonNode, DatabaseSchema>() {
+ @Override
+ public DatabaseSchema apply(JsonNode input) {
+ log.info("Get ovsdb database schema {}", dbName);
+ DatabaseSchema dbSchema = FromJsonUtil
+ .jsonNodeToDbSchema(dbName, input);
+ if (dbSchema == null) {
+ log.debug("Get ovsdb database schema error");
+ return null;
+ }
+ schema.put(dbName, dbSchema);
+
+ return dbSchema;
+ }
+ };
+
+ ListenableFuture<JsonNode> input = getSchema(dbNames);
+ if (input != null) {
+ return Futures.transform(input, rowFunction);
+ }
+ return null;
+ } else {
+ return Futures.immediateFuture(databaseSchema);
+ }
+ }
+
+ @Override
+ public ListenableFuture<TableUpdates> monitorTables(String dbName, String id) {
+ if (dbName == null) {
+ return null;
+ }
+ DatabaseSchema dbSchema = schema.get(dbName);
+ if (dbSchema != null) {
+ Function<JsonNode, TableUpdates> rowFunction = new Function<JsonNode, TableUpdates>() {
+ @Override
+ public TableUpdates apply(JsonNode input) {
+ log.info("Get table updates");
+ TableUpdates updates = FromJsonUtil
+ .jsonNodeToTableUpdates(input, dbSchema);
+ if (updates == null) {
+ log.debug("Get table updates error");
+ return null;
+ }
+ return updates;
+ }
+ };
+ return Futures.transform(monitor(dbSchema, id), rowFunction);
+ }
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<List<OperationResult>> transactConfig(String dbName,
+ List<Operation> operations) {
+ if (dbName == null) {
+ return null;
+ }
+ DatabaseSchema dbSchema = schema.get(dbName);
+ if (dbSchema != null) {
+ Function<List<JsonNode>, List<OperationResult>> rowFunction = (input -> {
+ log.info("Get ovsdb operation result");
+ List<OperationResult> result = FromJsonUtil
+ .jsonNodeToOperationResult(input, operations);
+
+ if (result == null) {
+ log.debug("The operation result is null");
+ return null;
+ }
+ return result;
+ });
+ return Futures.transform(transact(dbSchema, operations),
+ rowFunction);
+ }
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<JsonNode> getSchema(List<String> dbnames) {
+ String id = java.util.UUID.randomUUID().toString();
+ String getSchemaString = JsonRpcWriterUtil.getSchemaStr(id, dbnames);
+
+ SettableFuture<JsonNode> sf = SettableFuture.create();
+ requestResult.put(id, sf);
+ requestMethod.put(id, "getSchema");
+
+ channel.writeAndFlush(getSchemaString);
+ return sf;
+
+ }
+
+ @Override
+ public ListenableFuture<List<String>> echo() {
+ String id = java.util.UUID.randomUUID().toString();
+ String echoString = JsonRpcWriterUtil.echoStr(id);
+
+ SettableFuture<List<String>> sf = SettableFuture.create();
+ requestResult.put(id, sf);
+ requestMethod.put(id, "echo");
+
+ channel.writeAndFlush(echoString);
+ return sf;
+
+ }
+
+ @Override
+ public ListenableFuture<JsonNode> monitor(DatabaseSchema dbSchema,
+ String monitorId) {
+ String id = java.util.UUID.randomUUID().toString();
+ String monitorString = JsonRpcWriterUtil.monitorStr(id, monitorId,
+ dbSchema);
+
+ SettableFuture<JsonNode> sf = SettableFuture.create();
+ requestResult.put(id, sf);
+ requestMethod.put(id, "monitor");
+
+ channel.writeAndFlush(monitorString);
+ return sf;
+
+ }
+
+ @Override
+ public ListenableFuture<List<String>> listDbs() {
+ String id = java.util.UUID.randomUUID().toString();
+ String listDbsString = JsonRpcWriterUtil.listDbsStr(id);
+
+ SettableFuture<List<String>> sf = SettableFuture.create();
+ requestResult.put(id, sf);
+ requestMethod.put(id, "listDbs");
+
+ channel.writeAndFlush(listDbsString);
+ return sf;
+
+ }
+
+ @Override
+ public ListenableFuture<List<JsonNode>> transact(DatabaseSchema dbSchema,
+ List<Operation> operations) {
+ String id = java.util.UUID.randomUUID().toString();
+ String transactString = JsonRpcWriterUtil.transactStr(id, dbSchema,
+ operations);
+
+ SettableFuture<List<JsonNode>> sf = SettableFuture.create();
+ requestResult.put(id, sf);
+ requestMethod.put(id, "transact");
+
+ channel.writeAndFlush(transactString);
+ return sf;
+
+ }
+
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ @Override
+ public void processResult(JsonNode response) {
+ log.debug("Handle result");
+ String requestId = response.get("id").asText();
+ SettableFuture sf = requestResult.get(requestId);
+ if (sf == null) {
+ log.debug("No such future to process");
+ return;
+ }
+ String methodName = requestMethod.get(requestId);
+
+ Object result;
+ result = FromJsonUtil.jsonResultParser(response, methodName);
+
+ sf.set(result);
+ return;
+ }
+
+ @Override
+ public void processRequest(JsonNode requestJson) {
+ log.debug("Handle request");
+ if (requestJson.get("method").asText().equalsIgnoreCase("echo")) {
+ log.debug("handle echo request");
+
+ String replyString = FromJsonUtil.getEchoRequestStr(requestJson);
+ channel.writeAndFlush(replyString);
+
+ return;
+ } else {
+ FromJsonUtil
+ .jsonCallbackRequestParser(requestJson, monitorCallBack);
+ return;
+ }
+ }
+
+ @Override
+ public void setCallback(Callback monitorCallback) {
+ this.monitorCallBack = monitorCallback;
+ }
+
+ @Override
+ public Set<OvsdbTunnel> getTunnels() {
+ return ovsdbTunnels;
+ }
+
+ @Override
+ public Set<OvsdbBridge> getBridges() {
+ Set<OvsdbBridge> ovsdbBridges = new HashSet<OvsdbBridge>();
+ OvsdbTableStore tableStore = getTableStore(OvsdbConstant.DATABASENAME);
+ if (tableStore == null) {
+ return null;
+ }
+ OvsdbRowStore rowStore = tableStore.getRows(OvsdbConstant.BRIDGE);
+ if (rowStore == null) {
+ return null;
+ }
+ ConcurrentMap<String, Row> rows = rowStore.getRowStore();
+ for (String uuid : rows.keySet()) {
+ Row row = getRow(OvsdbConstant.DATABASENAME, OvsdbConstant.BRIDGE,
+ uuid);
+ OvsdbBridge ovsdbBridge = getOvsdbBridge(row);
+ if (ovsdbBridge != null) {
+ ovsdbBridges.add(ovsdbBridge);
+ }
+ }
+ return ovsdbBridges;
+ }
+
+ @Override
+ public Set<ControllerInfo> getControllers(DeviceId openflowDeviceId) {
+ UUID bridgeUuid = getBridgeUUID(openflowDeviceId);
+ if (bridgeUuid == null) {
+ log.warn("bad bridge Uuid");
+ return null;
+ }
+ List<Controller> controllers = getControllers(bridgeUuid);
+ if (controllers == null) {
+ log.warn("bad list of controllers");
+ return null;
+ }
+ return controllers.stream().
+ map(controller -> new ControllerInfo(
+ (String) controller.getTargetColumn()
+ .data())).collect(Collectors.toSet());
+ }
+
+ private List<Controller> getControllers(UUID bridgeUuid) {
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ if (dbSchema == null) {
+ return null;
+ }
+ OvsdbRowStore rowStore = getRowStore(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.BRIDGE);
+ if (rowStore == null) {
+ log.debug("There is no bridge table");
+ return null;
+ }
+
+ Row bridgeRow = rowStore.getRow(bridgeUuid.value());
+ Bridge bridge = (Bridge) TableGenerator.
+ getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
+
+ //FIXME remove log
+ log.warn("type of controller column", bridge.getControllerColumn()
+ .data().getClass());
+ Set<UUID> controllerUuids = (Set<UUID>) ((OvsdbSet) bridge
+ .getControllerColumn().data()).set();
+// Set<String> controllerUuidStrings = (Set<String>) bridge.getControllerColumn().data();
+
+ OvsdbRowStore controllerRowStore = getRowStore(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.CONTROLLER);
+ if (controllerRowStore == null) {
+ log.debug("There is no controller table");
+ return null;
+ }
+
+ List<Controller> ovsdbControllers = new ArrayList<>();
+ ConcurrentMap<String, Row> controllerTableRows = controllerRowStore.getRowStore();
+ controllerTableRows.forEach((key, row) -> {
+ if (!controllerUuids.contains(UUID.uuid(key))) {
+ return;
+ }
+ Controller controller = (Controller) TableGenerator
+ .getTable(dbSchema, row, OvsdbTable.CONTROLLER);
+ ovsdbControllers.add(controller);
+ });
+ return ovsdbControllers;
+ }
+
+
+ private UUID getBridgeUUID(DeviceId openflowDeviceId) {
+ DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
+ if (dbSchema == null) {
+ return null;
+ }
+ OvsdbRowStore rowStore = getRowStore(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.BRIDGE);
+ if (rowStore == null) {
+ log.debug("There is no bridge table");
+ return null;
+ }
+
+ ConcurrentMap<String, Row> bridgeTableRows = rowStore.getRowStore();
+ final AtomicReference<UUID> uuid = new AtomicReference<>();
+ for (Map.Entry<String, Row> entry : bridgeTableRows.entrySet()) {
+ Bridge b = (Bridge) TableGenerator.getTable(dbSchema,
+ entry.getValue(),
+ OvsdbTable.BRIDGE);
+ if (matchesDpid(b, openflowDeviceId)) {
+ uuid.set(UUID.uuid(entry.getKey()));
+ break;
+ }
+ }
+ if (uuid.get() == null) {
+ log.debug("There is no bridge for {}", openflowDeviceId);
+ }
+ return uuid.get();
+
+ }
+
+ private static boolean matchesDpid(Bridge b, DeviceId deviceId) {
+ String ofDpid = deviceId.toString().replace("of:", "");
+ Set ofDeviceIds = ((OvsdbSet) b.getDatapathIdColumn().data()).set();
+ //TODO Set<String>
+ return ofDeviceIds.contains(ofDpid);
+ }
+
+ @Override
+ public Set<OvsdbPort> getPorts() {
+ Set<OvsdbPort> ovsdbPorts = new HashSet<OvsdbPort>();
+ OvsdbTableStore tableStore = getTableStore(OvsdbConstant.DATABASENAME);
+ if (tableStore == null) {
+ return null;
+ }
+ OvsdbRowStore rowStore = tableStore.getRows(OvsdbConstant.INTERFACE);
+ if (rowStore == null) {
+ return null;
+ }
+ ConcurrentMap<String, Row> rows = rowStore.getRowStore();
+ for (String uuid : rows.keySet()) {
+ Row row = getRow(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.INTERFACE, uuid);
+ OvsdbPort ovsdbPort = getOvsdbPort(row);
+ if (ovsdbPort != null) {
+ ovsdbPorts.add(ovsdbPort);
+ }
+ }
+ return ovsdbPorts;
+ }
+
+ @Override
+ public DatabaseSchema getDatabaseSchema(String dbName) {
+ return schema.get(dbName);
+ }
+
+ //Gets ovsdb port.
+ private OvsdbPort getOvsdbPort(Row row) {
+ DatabaseSchema dbSchema = getDatabaseSchema(OvsdbConstant.DATABASENAME);
+ Interface intf = (Interface) TableGenerator
+ .getTable(dbSchema, row, OvsdbTable.INTERFACE);
+ if (intf == null) {
+ return null;
+ }
+ long ofPort = getOfPort(intf);
+ String portName = intf.getName();
+ if ((ofPort < 0) || (portName == null)) {
+ return null;
+ }
+
+ OvsdbPort ovsdbPort = new OvsdbPort(new OvsdbPortNumber(ofPort),
+ new OvsdbPortName(portName));
+ return ovsdbPort;
+ }
+
+ ////Gets ovsdb bridge.
+ private OvsdbBridge getOvsdbBridge(Row row) {
+ DatabaseSchema dbSchema = getDatabaseSchema(OvsdbConstant.DATABASENAME);
+ Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, row,
+ OvsdbTable.BRIDGE);
+ if (bridge == null) {
+ return null;
+ }
+
+ OvsdbSet datapathIdSet = (OvsdbSet) bridge.getDatapathIdColumn().data();
+ @SuppressWarnings("unchecked")
+ Set<String> datapathIds = datapathIdSet.set();
+ if (datapathIds == null || datapathIds.size() == 0) {
+ return null;
+ }
+ String datapathId = (String) datapathIds.toArray()[0];
+ String bridgeName = bridge.getName();
+ if ((datapathId == null) || (bridgeName == null)) {
+ return null;
+ }
+
+ OvsdbBridge ovsdbBridge = new OvsdbBridge(new OvsdbBridgeName(bridgeName),
+ new OvsdbDatapathId(datapathId));
+ return ovsdbBridge;
+ }
+
+ //Gets ofPort in the interface.
+ private long getOfPort(Interface intf) {
+ OvsdbSet ofPortSet = (OvsdbSet) intf.getOpenFlowPortColumn().data();
+ @SuppressWarnings("unchecked")
+ Set<Integer> ofPorts = ofPortSet.set();
+ while (ofPorts == null || ofPorts.size() <= 0) {
+ log.debug("The ofport is null in {}", intf.getName());
+ return -1;
+ }
+ // return (long) ofPorts.toArray()[0];
+ Iterator<Integer> it = ofPorts.iterator();
+ return Long.parseLong(it.next().toString());
+ }
+
+ @Override
+ public Set<OvsdbPort> getLocalPorts(Iterable<String> ifaceids) {
+ Set<OvsdbPort> ovsdbPorts = new HashSet<OvsdbPort>();
+ OvsdbTableStore tableStore = getTableStore(OvsdbConstant.DATABASENAME);
+ if (tableStore == null) {
+ return null;
+ }
+ OvsdbRowStore rowStore = tableStore.getRows(OvsdbConstant.INTERFACE);
+ if (rowStore == null) {
+ return null;
+ }
+ ConcurrentMap<String, Row> rows = rowStore.getRowStore();
+ for (String uuid : rows.keySet()) {
+ Row row = getRow(OvsdbConstant.DATABASENAME,
+ OvsdbConstant.INTERFACE, uuid);
+ DatabaseSchema dbSchema = getDatabaseSchema(OvsdbConstant.DATABASENAME);
+ Interface intf = (Interface) TableGenerator
+ .getTable(dbSchema, row, OvsdbTable.INTERFACE);
+ if (intf == null || getIfaceid(intf) == null) {
+ continue;
+ }
+ String portName = intf.getName();
+ Set<String> ifaceidSet = Sets.newHashSet(ifaceids);
+ if (portName.startsWith("vxlan")
+ || !ifaceidSet.contains(getIfaceid(intf))) {
+ continue;
+ }
+ long ofPort = getOfPort(intf);
+ if ((ofPort < 0) || (portName == null)) {
+ continue;
+ }
+
+ OvsdbPort ovsdbPort = new OvsdbPort(new OvsdbPortNumber(ofPort),
+ new OvsdbPortName(portName));
+ if (ovsdbPort != null) {
+ ovsdbPorts.add(ovsdbPort);
+ }
+ }
+ return ovsdbPorts;
+ }
+
+ private String getIfaceid(Interface intf) {
+ OvsdbMap ovsdbMap = (OvsdbMap) intf.getExternalIdsColumn().data();
+ @SuppressWarnings("unchecked")
+ Map<String, String> externalIds = ovsdbMap.map();
+ if (externalIds.isEmpty()) {
+ log.warn("The external_ids is null");
+ return null;
+ }
+ String ifaceid = externalIds
+ .get(OvsdbConstant.EXTERNAL_ID_INTERFACE_ID);
+ if (ifaceid == null) {
+ log.warn("The ifaceid is null");
+ return null;
+ }
+ return ifaceid;
+ }
+
+ @Override
+ public void disconnect() {
+ channel.disconnect();
+ this.agent.removeConnectedNode(nodeId);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/OvsdbAgent.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/OvsdbAgent.java
new file mode 100644
index 00000000..70ffae8b
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/OvsdbAgent.java
@@ -0,0 +1,42 @@
+/*
+ * 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.ovsdb.controller.driver;
+
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
+import org.onosproject.ovsdb.controller.OvsdbClientService;
+
+/**
+ * Responsible for keeping track of the current set of nodes connected to the
+ * system.
+ */
+public interface OvsdbAgent {
+ /**
+ * Add a node that has just connected to the system.
+ *
+ * @param nodeId the nodeId to add
+ * @param ovsdbClient the actual node object.
+ */
+ void addConnectedNode(OvsdbNodeId nodeId, OvsdbClientService ovsdbClient);
+
+ /**
+ * Clear all state in controller node maps for a node that has disconnected
+ * from the local controller. Also release control for that node from the
+ * global repository. Notify node listeners.
+ *
+ * @param nodeId the node id to be removed.
+ */
+ void removeConnectedNode(OvsdbNodeId nodeId);
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/OvsdbProviderService.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/OvsdbProviderService.java
new file mode 100644
index 00000000..48f58d02
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/OvsdbProviderService.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.ovsdb.controller.driver;
+
+import io.netty.channel.Channel;
+
+import org.onosproject.ovsdb.rfc.jsonrpc.Callback;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * Represents the driver side of an ovsdb node. This interface should never be
+ * exposed to consumers.
+ */
+public interface OvsdbProviderService {
+ /**
+ * Sets the ovsdb agent to be used. This method can only be called once.
+ *
+ * @param agent the agent to set.
+ */
+ void setAgent(OvsdbAgent agent);
+
+ /**
+ * Sets the associated Netty channel for this node.
+ *
+ * @param channel the Netty channel
+ */
+ void setChannel(Channel channel);
+
+ /**
+ * Announces to the ovsdb agent that this node has added.
+ */
+ void nodeAdded();
+
+ /**
+ * Announces to the ovsdb agent that this node has removed.
+ */
+ void nodeRemoved();
+
+ /**
+ * Sets whether the node is connected.
+ *
+ * @param connected whether the node is connected
+ */
+ void setConnection(boolean connected);
+
+ /**
+ * Processes result from ovsdb.
+ *
+ * @param response JsonNode response from ovsdb
+ */
+ void processResult(JsonNode response);
+
+ /**
+ * processes request from ovsdb.
+ *
+ * @param request JsonNode request from ovsdb
+ */
+ void processRequest(JsonNode request);
+
+ /**
+ * Sets call back.
+ *
+ * @param monitorCallback the callback to set
+ */
+ void setCallback(Callback monitorCallback);
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/package-info.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/package-info.java
new file mode 100644
index 00000000..b14afdfb
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/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.
+ */
+
+/**
+ * Ovsdb controller node driver API.
+ */
+package org.onosproject.ovsdb.controller.driver; \ No newline at end of file
diff --git a/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/package-info.java b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/package-info.java
new file mode 100644
index 00000000..d6fb434c
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/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.
+ */
+
+/**
+ * Ovsdb controller API.
+ */
+package org.onosproject.ovsdb.controller; \ No newline at end of file
diff --git a/framework/src/onos/protocols/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java b/framework/src/onos/protocols/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.java
new file mode 100644
index 00000000..5d80a7bf
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbClientServiceAdapter.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.ovsdb.controller.driver;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.util.concurrent.ListenableFuture;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.behaviour.ControllerInfo;
+import org.onosproject.ovsdb.controller.OvsdbBridge;
+import org.onosproject.ovsdb.controller.OvsdbClientService;
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
+import org.onosproject.ovsdb.controller.OvsdbPort;
+import org.onosproject.ovsdb.controller.OvsdbTunnel;
+import org.onosproject.ovsdb.rfc.message.OperationResult;
+import org.onosproject.ovsdb.rfc.message.TableUpdates;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.operations.Operation;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Test Adapter for OvsdbClientService.
+ */
+public class OvsdbClientServiceAdapter implements OvsdbClientService {
+
+ @Override
+ public OvsdbNodeId nodeId() {
+ return null;
+ }
+
+ @Override
+ public void createTunnel(IpAddress srcIp, IpAddress dstIp) {
+
+ }
+
+ @Override
+ public boolean createTunnel(String bridgeName, String portName, String tunnelType, Map<String, String> options) {
+ return true;
+ }
+
+ @Override
+ public void dropTunnel(IpAddress srcIp, IpAddress dstIp) {
+
+ }
+
+ @Override
+ public Set<OvsdbTunnel> getTunnels() {
+ return null;
+ }
+
+ @Override
+ public void createBridge(String bridgeName) {
+
+ }
+
+ @Override
+ public boolean createBridge(String bridgeName, String dpid, List<ControllerInfo> controllers) {
+ return true;
+ }
+
+ @Override
+ public void dropBridge(String bridgeName) {
+
+ }
+
+ @Override
+ public Set<OvsdbBridge> getBridges() {
+ return null;
+ }
+
+ @Override
+ public Set<ControllerInfo> getControllers(DeviceId openflowDeviceId) {
+ return null;
+ }
+
+ @Override
+ public void setControllersWithUUID(UUID bridgeUuid, List<ControllerInfo> controllers) {
+
+ }
+
+ @Override
+ public void setControllersWithDeviceId(DeviceId deviceId, List<ControllerInfo> controllers) {
+
+ }
+
+ @Override
+ public void createPort(String bridgeName, String portName) {
+
+ }
+
+ @Override
+ public void dropPort(String bridgeName, String portName) {
+
+ }
+
+ @Override
+ public Set<OvsdbPort> getPorts() {
+ return null;
+ }
+
+ @Override
+ public boolean isConnected() {
+ return false;
+ }
+
+ @Override
+ public String getBridgeUuid(String bridgeName) {
+ return null;
+ }
+
+ @Override
+ public String getPortUuid(String portName, String bridgeUuid) {
+ return null;
+ }
+
+ @Override
+ public String getInterfaceUuid(String portUuid, String portName) {
+ return null;
+ }
+
+ @Override
+ public String getControllerUuid(String controllerName, String controllerTarget) {
+ return null;
+ }
+
+ @Override
+ public String getOvsUuid(String dbName) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<DatabaseSchema> getOvsdbSchema(String dbName) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<TableUpdates> monitorTables(String dbName, String id) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<List<OperationResult>> transactConfig(String dbName, List<Operation> operations) {
+ return null;
+ }
+
+ @Override
+ public DatabaseSchema getDatabaseSchema(String dbName) {
+ return null;
+ }
+
+ @Override
+ public Row getRow(String dbName, String tableName, String uuid) {
+ return null;
+ }
+
+ @Override
+ public void removeRow(String dbName, String tableName, String uuid) {
+
+ }
+
+ @Override
+ public void updateOvsdbStore(String dbName, String tableName, String uuid, Row row) {
+
+ }
+
+ @Override
+ public Set<OvsdbPort> getLocalPorts(Iterable<String> ifaceids) {
+ return null;
+ }
+
+ @Override
+ public void disconnect() {
+
+ }
+
+ @Override
+ public ListenableFuture<JsonNode> getSchema(List<String> dbnames) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<List<String>> echo() {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<JsonNode> monitor(DatabaseSchema dbSchema, String monitorId) {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<List<String>> listDbs() {
+ return null;
+ }
+
+ @Override
+ public ListenableFuture<List<JsonNode>> transact(DatabaseSchema dbSchema, List<Operation> operations) {
+ return null;
+ }
+
+ @Override
+ public void createBridge(String bridgeName, String dpid, String exPortName) {
+
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbControllerAdapter.java b/framework/src/onos/protocols/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbControllerAdapter.java
new file mode 100644
index 00000000..902113aa
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/api/src/test/java/org/onosproject/ovsdb/controller/driver/OvsdbControllerAdapter.java
@@ -0,0 +1,75 @@
+/*
+ * 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.ovsdb.controller.driver;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.ovsdb.controller.OvsdbClientService;
+import org.onosproject.ovsdb.controller.OvsdbController;
+import org.onosproject.ovsdb.controller.OvsdbEventListener;
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
+import org.onosproject.ovsdb.controller.OvsdbNodeListener;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Test Adapter for OvsdbController.
+ */
+public class OvsdbControllerAdapter implements OvsdbController {
+ protected ConcurrentHashMap<OvsdbNodeId, OvsdbClientServiceAdapter> ovsdbClients =
+ new ConcurrentHashMap<OvsdbNodeId, OvsdbClientServiceAdapter>();
+
+ @Override
+ public void addNodeListener(OvsdbNodeListener listener) {
+
+ }
+
+ @Override
+ public void removeNodeListener(OvsdbNodeListener listener) {
+
+ }
+
+ @Override
+ public void addOvsdbEventListener(OvsdbEventListener listener) {
+
+ }
+
+ @Override
+ public void removeOvsdbEventListener(OvsdbEventListener listener) {
+
+ }
+
+ @Override
+ public List<OvsdbNodeId> getNodeIds() {
+ long port = 6653;
+ return new ArrayList<OvsdbNodeId>(Arrays.asList(
+ new OvsdbNodeId(IpAddress.valueOf("127.0.0.1"), port)));
+ }
+
+ @Override
+ public OvsdbClientService getOvsdbClient(OvsdbNodeId nodeId) {
+ return ovsdbClients.get(nodeId);
+ }
+
+ @Override
+ public void connect(IpAddress ip, TpPort port) {
+
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/ctl/pom.xml b/framework/src/onos/protocols/ovsdb/ctl/pom.xml
new file mode 100644
index 00000000..b8366296
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/ctl/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-ovsdb-ctl</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-rfc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/ChannelConnectionListener.java b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/ChannelConnectionListener.java
new file mode 100644
index 00000000..f17c25f7
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/ChannelConnectionListener.java
@@ -0,0 +1,43 @@
+/*
+ * 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.ovsdb.controller.impl;
+
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+
+import org.onosproject.ovsdb.controller.driver.OvsdbProviderService;
+
+/**
+ * The listener class. Handles when the node disconnect.
+ */
+public class ChannelConnectionListener implements ChannelFutureListener {
+
+ private final OvsdbProviderService providerService;
+
+ /**
+ * Constructor from a OvsdbProviderService providerService.
+ *
+ * @param providerService the providerService to use
+ */
+ public ChannelConnectionListener(OvsdbProviderService providerService) {
+ this.providerService = providerService;
+ }
+
+ @Override
+ public void operationComplete(ChannelFuture arg0) {
+ providerService.nodeRemoved();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/Controller.java b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/Controller.java
new file mode 100644
index 00000000..fcbbff8e
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/Controller.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.ovsdb.controller.impl;
+
+import io.netty.bootstrap.Bootstrap;
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.buffer.PooledByteBufAllocator;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.EventLoop;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.ServerChannel;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.SocketChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import io.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.timeout.IdleState;
+import io.netty.handler.timeout.IdleStateEvent;
+import io.netty.handler.timeout.IdleStateHandler;
+import io.netty.util.CharsetUtil;
+
+import java.net.InetSocketAddress;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.ovsdb.controller.OvsdbConstant;
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
+import org.onosproject.ovsdb.controller.driver.DefaultOvsdbClient;
+import org.onosproject.ovsdb.controller.driver.OvsdbAgent;
+import org.onosproject.ovsdb.controller.driver.OvsdbProviderService;
+import org.onosproject.ovsdb.rfc.jsonrpc.Callback;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The main controller class. Handles all setup and network listeners -
+ * distributed OVSDBClient.
+ */
+public class Controller {
+ protected static final Logger log = LoggerFactory
+ .getLogger(Controller.class);
+
+ private int ovsdbPort = OvsdbConstant.OVSDBPORT;
+
+ private OvsdbAgent agent;
+ private Callback monitorCallback;
+
+ private final ExecutorService executorService = Executors
+ .newFixedThreadPool(10);
+
+ private EventLoopGroup bossGroup;
+ private EventLoopGroup workerGroup;
+ private Class<? extends ServerChannel> serverChannelClass;
+
+ private static final int MAX_RETRY = 5;
+ private static final int IDLE_TIMEOUT_SEC = 10;
+
+ /**
+ * Initialization.
+ */
+ private void initEventLoopGroup() {
+ bossGroup = new NioEventLoopGroup();
+ workerGroup = new NioEventLoopGroup();
+ serverChannelClass = NioServerSocketChannel.class;
+ }
+
+ /**
+ * Accepts incoming connections.
+ */
+ private void startAcceptingConnections() throws InterruptedException {
+ ServerBootstrap b = new ServerBootstrap();
+
+ b.group(bossGroup, workerGroup).channel(serverChannelClass)
+ .childHandler(new OnosCommunicationChannelInitializer());
+ b.option(ChannelOption.SO_BACKLOG, 128);
+ b.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 32 * 1024);
+ b.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024);
+ b.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
+ b.childOption(ChannelOption.SO_KEEPALIVE, true);
+ b.bind(ovsdbPort).sync();
+ }
+
+ /**
+ * Tells controller that we're ready to accept OVSDB node loop.
+ * @throws InterruptedException if thread is interrupted
+ */
+ public void run() throws InterruptedException {
+ initEventLoopGroup();
+ startAcceptingConnections();
+ }
+
+ /**
+ * Adds channel pipeline to handle a new connected node.
+ */
+ private class OnosCommunicationChannelInitializer
+ extends ChannelInitializer<SocketChannel> {
+ protected void initChannel(SocketChannel channel) throws Exception {
+ log.info("New channel created");
+ channel.pipeline().addLast(new StringEncoder(CharsetUtil.UTF_8));
+ channel.pipeline().addLast(new MessageDecoder());
+ handleNewNodeConnection(channel);
+
+ }
+ }
+
+ /**
+ * Handles the new connection of node.
+ *
+ * @param channel the channel to use.
+ */
+ private void handleNewNodeConnection(final Channel channel) {
+ executorService.execute(new Runnable() {
+ @Override
+ public void run() {
+ log.info("Handle new node connection");
+
+ IpAddress ipAddress = IpAddress
+ .valueOf(((InetSocketAddress) channel.remoteAddress())
+ .getAddress().getHostAddress());
+ long port = ((InetSocketAddress) channel.remoteAddress())
+ .getPort();
+
+ log.info("Get connection from ip address {} : {}",
+ ipAddress.toString(), port);
+
+ OvsdbNodeId nodeId = new OvsdbNodeId(ipAddress, port);
+ OvsdbProviderService ovsdbProviderService = getNodeInstance(nodeId,
+ agent,
+ monitorCallback,
+ channel);
+ ovsdbProviderService.setConnection(true);
+ OvsdbJsonRpcHandler ovsdbJsonRpcHandler = new OvsdbJsonRpcHandler(
+ nodeId);
+ ovsdbJsonRpcHandler
+ .setOvsdbProviderService(ovsdbProviderService);
+ channel.pipeline().addLast(ovsdbJsonRpcHandler);
+
+ ovsdbProviderService.nodeAdded();
+ ChannelFuture closeFuture = channel.closeFuture();
+ closeFuture
+ .addListener(new ChannelConnectionListener(
+ ovsdbProviderService));
+ }
+ });
+ }
+
+ /**
+ * Gets an OVSDB client instance.
+ *
+ * @param nodeId data OVSDB node id
+ * @param agent OvsdbAgent
+ * @param monitorCallback Callback
+ * @param channel Channel
+ * @return OvsdbProviderService instance
+ */
+ protected OvsdbProviderService getNodeInstance(OvsdbNodeId nodeId,
+ OvsdbAgent agent,
+ Callback monitorCallback,
+ Channel channel) {
+ OvsdbProviderService ovsdbProviderService = new DefaultOvsdbClient(
+ nodeId);
+ ovsdbProviderService.setAgent(agent);
+ ovsdbProviderService.setCallback(monitorCallback);
+ ovsdbProviderService.setChannel(channel);
+ return ovsdbProviderService;
+ }
+
+ /**
+ * Starts controller.
+ *
+ * @param agent OvsdbAgent
+ * @param monitorCallback Callback
+ */
+ public void start(OvsdbAgent agent, Callback monitorCallback) {
+ this.agent = agent;
+ this.monitorCallback = monitorCallback;
+ try {
+ this.run();
+ } catch (InterruptedException e) {
+ log.warn("Interrupted while waiting to start");
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ /**
+ * Stops controller.
+ *
+ */
+ public void stop() {
+ workerGroup.shutdownGracefully();
+ bossGroup.shutdownGracefully();
+ }
+
+ /**
+ * Connect to the ovsdb server with given ip address and port number.
+ *
+ * @param ip ip address
+ * @param port port number
+ */
+ public void connect(IpAddress ip, TpPort port) {
+ ChannelFutureListener listener = new ConnectionListener(this, ip, port);
+ connectRetry(ip, port, listener);
+ }
+
+ private void connectRetry(IpAddress ip, TpPort port, ChannelFutureListener listener) {
+ try {
+ Bootstrap b = new Bootstrap();
+ b.group(workerGroup)
+ .channel(NioSocketChannel.class)
+ .option(ChannelOption.TCP_NODELAY, true)
+ .handler(new ChannelInitializer<SocketChannel>() {
+
+ @Override
+ protected void initChannel(SocketChannel channel) throws Exception {
+ ChannelPipeline p = channel.pipeline();
+ p.addLast(new MessageDecoder(),
+ new StringEncoder(CharsetUtil.UTF_8),
+ new IdleStateHandler(IDLE_TIMEOUT_SEC, 0, 0),
+ new ConnectionHandler());
+ }
+ });
+ b.remoteAddress(ip.toString(), port.toInt());
+ b.connect().addListener(listener);
+ } catch (Exception e) {
+ log.warn("Connection to the ovsdb server {}:{} failed", ip.toString(), port.toString());
+ }
+ }
+
+ private class ConnectionListener implements ChannelFutureListener {
+ private Controller controller;
+ private IpAddress ip;
+ private TpPort port;
+ private AtomicInteger count = new AtomicInteger();
+
+ public ConnectionListener(Controller controller,
+ IpAddress ip,
+ TpPort port) {
+ this.controller = controller;
+ this.ip = ip;
+ this.port = port;
+ }
+
+ @Override
+ public void operationComplete(ChannelFuture channelFuture) throws Exception {
+ if (!channelFuture.isSuccess()) {
+ channelFuture.channel().close();
+
+ if (count.incrementAndGet() < MAX_RETRY) {
+ final EventLoop loop = channelFuture.channel().eventLoop();
+
+ loop.schedule(() -> {
+ controller.connectRetry(this.ip, this.port, this);
+ }, 1L, TimeUnit.SECONDS);
+ } else {
+ log.info("Connection to the ovsdb {}:{} failed",
+ this.ip.toString(), this.port.toString());
+ }
+ } else {
+ handleNewNodeConnection(channelFuture.channel());
+ }
+ }
+ }
+
+ private class ConnectionHandler extends ChannelDuplexHandler {
+
+ @Override
+ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
+ IdleStateEvent e = (IdleStateEvent) evt;
+
+ if (e.state() == IdleState.READER_IDLE) {
+ ctx.close();
+ }
+ }
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/MessageDecoder.java b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/MessageDecoder.java
new file mode 100644
index 00000000..e0e22753
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/MessageDecoder.java
@@ -0,0 +1,55 @@
+/*
+ * 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.ovsdb.controller.impl;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
+import java.util.List;
+
+import org.onosproject.ovsdb.rfc.jsonrpc.JsonReadContext;
+import org.onosproject.ovsdb.rfc.utils.JsonRpcReaderUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Decoder for inbound messages.
+ */
+public class MessageDecoder extends ByteToMessageDecoder {
+
+ private final Logger log = LoggerFactory.getLogger(MessageDecoder.class);
+ private final JsonReadContext context = new JsonReadContext();
+
+ /**
+ * Default constructor.
+ */
+ public MessageDecoder() {
+ }
+
+ @Override
+ protected void decode(ChannelHandlerContext ctx, ByteBuf buf,
+ List<Object> out) throws Exception {
+ log.debug("Message decoder");
+ JsonRpcReaderUtil.readToJsonNode(buf, out, context);
+ }
+
+ @Override
+ public void exceptionCaught(ChannelHandlerContext context, Throwable cause) {
+ log.error("Exception inside channel handling pipeline.", cause);
+ context.close();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbControllerImpl.java b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbControllerImpl.java
new file mode 100644
index 00000000..c2cbbf8b
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbControllerImpl.java
@@ -0,0 +1,418 @@
+/*
+ * 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.ovsdb.controller.impl;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.ImmutableList;
+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.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.ovsdb.controller.DefaultEventSubject;
+import org.onosproject.ovsdb.controller.EventSubject;
+import org.onosproject.ovsdb.controller.OvsdbClientService;
+import org.onosproject.ovsdb.controller.OvsdbConstant;
+import org.onosproject.ovsdb.controller.OvsdbController;
+import org.onosproject.ovsdb.controller.OvsdbDatapathId;
+import org.onosproject.ovsdb.controller.OvsdbEvent;
+import org.onosproject.ovsdb.controller.OvsdbEvent.Type;
+import org.onosproject.ovsdb.controller.OvsdbEventListener;
+import org.onosproject.ovsdb.controller.OvsdbIfaceId;
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
+import org.onosproject.ovsdb.controller.OvsdbNodeListener;
+import org.onosproject.ovsdb.controller.OvsdbPortName;
+import org.onosproject.ovsdb.controller.OvsdbPortNumber;
+import org.onosproject.ovsdb.controller.OvsdbPortType;
+import org.onosproject.ovsdb.controller.driver.OvsdbAgent;
+import org.onosproject.ovsdb.rfc.jsonrpc.Callback;
+import org.onosproject.ovsdb.rfc.message.TableUpdate;
+import org.onosproject.ovsdb.rfc.message.TableUpdates;
+import org.onosproject.ovsdb.rfc.message.UpdateNotification;
+import org.onosproject.ovsdb.rfc.notation.OvsdbMap;
+import org.onosproject.ovsdb.rfc.notation.OvsdbSet;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.table.Bridge;
+import org.onosproject.ovsdb.rfc.table.Interface;
+import org.onosproject.ovsdb.rfc.table.OvsdbTable;
+import org.onosproject.ovsdb.rfc.table.TableGenerator;
+import org.onosproject.ovsdb.rfc.utils.FromJsonUtil;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.concurrent.ExecutionException;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * The implementation of OvsdbController.
+ */
+@Component(immediate = true)
+@Service
+public class OvsdbControllerImpl implements OvsdbController {
+
+ public static final Logger log = LoggerFactory
+ .getLogger(OvsdbControllerImpl.class);
+
+ protected ConcurrentHashMap<OvsdbNodeId, OvsdbClientService> ovsdbClients =
+ new ConcurrentHashMap<OvsdbNodeId, OvsdbClientService>();
+
+ protected OvsdbAgent agent = new InternalOvsdbNodeAgent();
+ protected InternalMonitorCallBack updateCallback = new InternalMonitorCallBack();
+
+ protected Set<OvsdbNodeListener> ovsdbNodeListener = new CopyOnWriteArraySet<>();
+ protected Set<OvsdbEventListener> ovsdbEventListener = new CopyOnWriteArraySet<>();
+
+ protected ConcurrentHashMap<String, OvsdbClientService> requestNotification =
+ new ConcurrentHashMap<String, OvsdbClientService>();
+
+ protected ConcurrentHashMap<String, String> requestDbName = new ConcurrentHashMap<String, String>();
+
+ private final Controller controller = new Controller();
+
+ @Activate
+ public void activate(ComponentContext context) {
+ controller.start(agent, updateCallback);
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ controller.stop();
+ log.info("Stoped");
+ }
+
+ @Override
+ public void addNodeListener(OvsdbNodeListener listener) {
+ if (!ovsdbNodeListener.contains(listener)) {
+ this.ovsdbNodeListener.add(listener);
+ }
+ }
+
+ @Override
+ public void removeNodeListener(OvsdbNodeListener listener) {
+ this.ovsdbNodeListener.remove(listener);
+ }
+
+ @Override
+ public void addOvsdbEventListener(OvsdbEventListener listener) {
+ if (!ovsdbEventListener.contains(listener)) {
+ this.ovsdbEventListener.add(listener);
+ }
+ }
+
+ @Override
+ public void removeOvsdbEventListener(OvsdbEventListener listener) {
+ this.ovsdbEventListener.remove(listener);
+ }
+
+ @Override
+ public List<OvsdbNodeId> getNodeIds() {
+ return ImmutableList.copyOf(ovsdbClients.keySet());
+ }
+
+ @Override
+ public OvsdbClientService getOvsdbClient(OvsdbNodeId nodeId) {
+ return ovsdbClients.get(nodeId);
+ }
+
+ @Override
+ public void connect(IpAddress ip, TpPort port) {
+ controller.connect(ip, port);
+ }
+
+ /**
+ * Implementation of an Ovsdb Agent which is responsible for keeping track
+ * of connected node and the state in which they are.
+ */
+ private class InternalOvsdbNodeAgent implements OvsdbAgent {
+ @Override
+ public void addConnectedNode(OvsdbNodeId nodeId,
+ OvsdbClientService ovsdbClient) {
+
+ if (ovsdbClients.get(nodeId) != null) {
+ return;
+ } else {
+ ovsdbClients.put(nodeId, ovsdbClient);
+
+ try {
+ List<String> dbNames = ovsdbClient.listDbs().get();
+ for (String dbName : dbNames) {
+ DatabaseSchema dbSchema;
+ dbSchema = ovsdbClient.getOvsdbSchema(dbName).get();
+
+ log.debug("Begin to monitor tables");
+ String id = java.util.UUID.randomUUID().toString();
+ TableUpdates updates = ovsdbClient
+ .monitorTables(dbName, id).get();
+
+ requestDbName.put(id, dbName);
+ requestNotification.put(id, ovsdbClient);
+
+ if (updates != null) {
+ processTableUpdates(ovsdbClient, updates,
+ dbSchema.name());
+ }
+ }
+ } catch (InterruptedException e) {
+ log.warn("Interrupted while waiting to get message from ovsdb");
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ log.error("Exception thrown while to get message from ovsdb");
+ }
+
+ log.debug("Add node to north");
+ for (OvsdbNodeListener l : ovsdbNodeListener) {
+ l.nodeAdded(nodeId);
+ }
+ return;
+ }
+ }
+
+ @Override
+ public void removeConnectedNode(OvsdbNodeId nodeId) {
+ ovsdbClients.remove(nodeId);
+ log.debug("Node connection is removed");
+ for (OvsdbNodeListener l : ovsdbNodeListener) {
+ l.nodeRemoved(nodeId);
+ }
+ }
+ }
+
+ /**
+ * Processes table updates.
+ *
+ * @param clientService OvsdbClientService instance
+ * @param updates TableUpdates instance
+ * @param dbName ovsdb database name
+ */
+ private void processTableUpdates(OvsdbClientService clientService,
+ TableUpdates updates, String dbName)
+ throws InterruptedException {
+ checkNotNull(clientService, "OvsdbClientService is not null");
+
+ DatabaseSchema dbSchema = clientService.getDatabaseSchema(dbName);
+
+ for (String tableName : updates.result().keySet()) {
+ TableUpdate update = updates.result().get(tableName);
+ for (UUID uuid : (Set<UUID>) update.rows().keySet()) {
+ log.debug("Begin to process table updates uuid: {}, databaseName: {}, tableName: {}",
+ uuid.value(), dbName, tableName);
+
+ Row newRow = update.getNew(uuid);
+ if (newRow != null) {
+ clientService.updateOvsdbStore(dbName, tableName,
+ uuid.value(), newRow);
+
+ if (OvsdbConstant.INTERFACE.equals(tableName)) {
+ dispatchInterfaceEvent(clientService,
+ newRow,
+ OvsdbEvent.Type.PORT_ADDED,
+ dbSchema);
+ }
+ } else if (update.getOld(uuid) != null) {
+ if (OvsdbConstant.INTERFACE.equals(tableName)) {
+ Row row = clientService.getRow(OvsdbConstant.DATABASENAME, tableName, uuid.value());
+ dispatchInterfaceEvent(clientService,
+ row,
+ OvsdbEvent.Type.PORT_REMOVED,
+ dbSchema);
+ }
+ clientService.removeRow(dbName, tableName, uuid.value());
+ }
+ }
+ }
+ }
+
+ /**
+ * Dispatches event to the north.
+ *
+ * @param clientService OvsdbClientService instance
+ * @param newRow a new row
+ * @param oldRow an old row
+ * @param eventType type of event
+ * @param dbSchema ovsdb database schema
+ */
+ private void dispatchInterfaceEvent(OvsdbClientService clientService,
+ Row row,
+ Type eventType,
+ DatabaseSchema dbSchema) {
+
+ long dpid = getDataPathid(clientService, dbSchema);
+ Interface intf = (Interface) TableGenerator
+ .getTable(dbSchema, row, OvsdbTable.INTERFACE);
+ if (intf == null) {
+ return;
+ }
+
+ String portType = (String) intf.getTypeColumn().data();
+ long localPort = getOfPort(intf);
+ if (localPort < 0) {
+ return;
+ }
+ String[] macAndIfaceId = getMacAndIfaceid(intf);
+ if (macAndIfaceId == null) {
+ return;
+ }
+
+ EventSubject eventSubject = new DefaultEventSubject(MacAddress.valueOf(
+ macAndIfaceId[0]),
+ new HashSet<IpAddress>(),
+ new OvsdbPortName(intf
+ .getName()),
+ new OvsdbPortNumber(localPort),
+ new OvsdbDatapathId(Long
+ .toString(dpid)),
+ new OvsdbPortType(portType),
+ new OvsdbIfaceId(macAndIfaceId[1]));
+ for (OvsdbEventListener listener : ovsdbEventListener) {
+ listener.handle(new OvsdbEvent<EventSubject>(eventType,
+ eventSubject));
+ }
+ }
+
+ /**
+ * Gets mac and iface from the table Interface.
+ *
+ * @param intf Interface instance
+ * @return attachedMac, ifaceid
+ */
+ private String[] getMacAndIfaceid(Interface intf) {
+ OvsdbMap ovsdbMap = (OvsdbMap) intf.getExternalIdsColumn().data();
+ @SuppressWarnings("unchecked")
+ Map<String, String> externalIds = ovsdbMap.map();
+ if (externalIds == null) {
+ log.warn("The external_ids is null");
+ return null;
+ }
+
+ String attachedMac = externalIds.get(OvsdbConstant.EXTERNAL_ID_VM_MAC);
+ if (attachedMac == null) {
+ log.debug("The attachedMac is null"); //FIXME why always null?
+ return null;
+ }
+ String ifaceid = externalIds
+ .get(OvsdbConstant.EXTERNAL_ID_INTERFACE_ID);
+ if (ifaceid == null) {
+ log.warn("The ifaceid is null");
+ return null;
+ }
+ return new String[]{attachedMac, ifaceid};
+ }
+
+ /**
+ * Gets ofPorts number from table Interface.
+ *
+ * @param intf Interface instance
+ * @return ofport the ofport number
+ */
+ private long getOfPort(Interface intf) {
+ OvsdbSet ofPortSet = (OvsdbSet) intf.getOpenFlowPortColumn().data();
+ @SuppressWarnings("unchecked")
+ Set<Integer> ofPorts = ofPortSet.set();
+ while (ofPorts == null || ofPorts.size() <= 0) {
+ log.debug("The ofport is null in {}", intf.getName());
+ return -1;
+ }
+ Iterator<Integer> it = ofPorts.iterator();
+ return Long.parseLong(it.next().toString());
+ }
+
+ /**
+ * Gets datapathid from table bridge.
+ *
+ * @param clientService OvsdbClientService instance
+ * @param dbSchema ovsdb database schema
+ * @return datapathid the bridge datapathid
+ */
+ private long getDataPathid(OvsdbClientService clientService,
+ DatabaseSchema dbSchema) {
+ String bridgeUuid = clientService
+ .getBridgeUuid(OvsdbConstant.INTEGRATION_BRIDGE);
+ if (bridgeUuid == null) {
+ log.debug("Unable to spot bridge uuid for {} in {}",
+ OvsdbConstant.INTEGRATION_BRIDGE, clientService);
+ return 0;
+ }
+
+ Row bridgeRow = clientService.getRow(OvsdbConstant.DATABASENAME,
+ "Bridge", bridgeUuid);
+ Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow,
+ OvsdbTable.BRIDGE);
+ OvsdbSet dpidSet = (OvsdbSet) bridge.getDatapathIdColumn().data();
+ @SuppressWarnings("unchecked")
+ Set<String> dpids = dpidSet.set();
+ if (dpids == null || dpids.size() == 0) {
+ return 0;
+ }
+ return stringToLong((String) dpids.toArray()[0]);
+ }
+
+ private long stringToLong(String values) {
+ long value = (new BigInteger(values.replaceAll(":", ""), 16))
+ .longValue();
+ return value;
+ }
+
+ /**
+ * Implementation of an Callback which is responsible for receiving request
+ * infomation from ovsdb.
+ */
+ private class InternalMonitorCallBack implements Callback {
+ @Override
+ public void update(UpdateNotification updateNotification) {
+ Object key = updateNotification.jsonValue();
+ OvsdbClientService ovsdbClient = requestNotification.get(key);
+
+ String dbName = requestDbName.get(key);
+ JsonNode updatesJson = updateNotification.tbUpdatesJsonNode();
+ DatabaseSchema dbSchema = ovsdbClient.getDatabaseSchema(dbName);
+ TableUpdates updates = FromJsonUtil
+ .jsonNodeToTableUpdates(updatesJson, dbSchema);
+ try {
+ processTableUpdates(ovsdbClient, updates, dbName);
+ } catch (InterruptedException e) {
+ log.warn("Interrupted while processing table updates");
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ @Override
+ public void locked(List<String> ids) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void stolen(List<String> ids) {
+ // TODO Auto-generated method stub
+ }
+
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbJsonRpcHandler.java b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbJsonRpcHandler.java
new file mode 100644
index 00000000..1956a1eb
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/OvsdbJsonRpcHandler.java
@@ -0,0 +1,131 @@
+/*
+ * 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.ovsdb.controller.impl;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
+import org.onosproject.ovsdb.controller.driver.OvsdbProviderService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.base.Strings;
+
+/**
+ * Channel handler deals with the node connection and dispatches
+ * ovsdb messages to the appropriate locations.
+ */
+public final class OvsdbJsonRpcHandler extends ChannelInboundHandlerAdapter {
+ protected static final Logger log = LoggerFactory
+ .getLogger(OvsdbJsonRpcHandler.class);
+ private OvsdbNodeId ovsdbNodeId;
+ private OvsdbProviderService ovsdbProviderService;
+
+ /**
+ * Constructor from a OvsdbNodeId ovsdbNodeId.
+ *
+ * @param ovsdbNodeId the ovsdbNodeId to use
+ */
+ public OvsdbJsonRpcHandler(OvsdbNodeId ovsdbNodeId) {
+ super();
+ this.ovsdbNodeId = ovsdbNodeId;
+ }
+
+ /**
+ * Gets the ovsdbProviderService instance.
+ *
+ * @return the instance of the ovsdbProviderService
+ */
+ public OvsdbProviderService getOvsdbProviderService() {
+ return ovsdbProviderService;
+ }
+
+ /**
+ * Sets the ovsdbProviderService instance.
+ *
+ * @param ovsdbNodeDriver the ovsdbNodeDriver to use
+ */
+ public void setOvsdbProviderService(OvsdbProviderService ovsdbNodeDriver) {
+ this.ovsdbProviderService = ovsdbNodeDriver;
+ }
+
+ /**
+ * Gets the OvsdbNodeId instance.
+ *
+ * @return the instance of the OvsdbNodeId
+ */
+ public OvsdbNodeId getNodeId() {
+ return ovsdbNodeId;
+ }
+
+ /**
+ * Sets the ovsdb node id.
+ *
+ * @param ovsdbNodeId the ovsdbNodeId to use
+ */
+ public void setNodeId(OvsdbNodeId ovsdbNodeId) {
+ this.ovsdbNodeId = ovsdbNodeId;
+ }
+
+ /**
+ * Processes an JsonNode message received on the channel.
+ *
+ * @param jsonNode The OvsdbJsonRpcHandler that received the message
+ */
+ private void processOvsdbMessage(JsonNode jsonNode) {
+
+ log.debug("Handle ovsdb message");
+
+ if (jsonNode.has("result")) {
+
+ log.debug("Handle ovsdb result");
+ ovsdbProviderService.processResult(jsonNode);
+
+ } else if (jsonNode.hasNonNull("method")) {
+
+ log.debug("Handle ovsdb request");
+ if (jsonNode.has("id")
+ && !Strings.isNullOrEmpty(jsonNode.get("id").asText())) {
+ ovsdbProviderService.processRequest(jsonNode);
+ }
+
+ }
+ return;
+ }
+
+ @Override
+ public void channelRead(ChannelHandlerContext ctx, Object msg)
+ throws Exception {
+ log.debug("Receive message from ovsdb");
+ if (msg instanceof JsonNode) {
+ JsonNode jsonNode = (JsonNode) msg;
+ processOvsdbMessage(jsonNode);
+ }
+ }
+
+ @Override
+ public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+ ctx.flush();
+ }
+
+ @Override
+ public void exceptionCaught(ChannelHandlerContext context, Throwable cause) {
+ log.error("Exception inside channel handling pipeline.", cause);
+ context.close();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/package-info.java b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/controller/impl/package-info.java
new file mode 100644
index 00000000..379e947a
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/ctl/src/main/java/org/onosproject/ovsdb/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 OVSDB controller IO subsystem.
+ */
+package org.onosproject.ovsdb.controller.impl; \ No newline at end of file
diff --git a/framework/src/onos/protocols/ovsdb/pom.xml b/framework/src/onos/protocols/ovsdb/pom.xml
new file mode 100644
index 00000000..930978a4
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/pom.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>onos-ovsdb</artifactId>
+ <name>onos-ovsdb</name>
+ <packaging>pom</packaging>
+
+ <description>ONOS OVSDB southbound plugin</description>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-misc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-buffer</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-handler</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <modules>
+ <module>api</module>
+ <module>rfc</module>
+ <module>ctl</module>
+ </modules>
+</project> \ No newline at end of file
diff --git a/framework/src/onos/protocols/ovsdb/rfc/pom.xml b/framework/src/onos/protocols/ovsdb/rfc/pom.xml
new file mode 100644
index 00000000..d4d37587
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/pom.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>onos-ovsdb-rfc</artifactId>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/AbnormalJsonNodeException.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/AbnormalJsonNodeException.java
new file mode 100644
index 00000000..d6c3357e
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/AbnormalJsonNodeException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.ovsdb.rfc.exception;
+
+/**
+ * AbnormalJsonNodeException exception is thrown when the received JsonNode is invalid.
+ */
+public class AbnormalJsonNodeException extends RuntimeException {
+ private static final long serialVersionUID = 8328377718334680368L;
+
+ /**
+ * Constructs a AbnormalJsonNodeException object.
+ * @param message error message
+ */
+ public AbnormalJsonNodeException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a AbnormalJsonNodeException object.
+ * @param message error message
+ * @param cause Throwable
+ */
+ public AbnormalJsonNodeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/BridgeCreateException.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/BridgeCreateException.java
new file mode 100644
index 00000000..986b50a3
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/BridgeCreateException.java
@@ -0,0 +1,53 @@
+/*
+ * 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.ovsdb.rfc.exception;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * This exception is thrown when Bridge creation fails.
+ */
+public class BridgeCreateException extends RuntimeException {
+ private static final long serialVersionUID = 1377521646616825676L;
+
+ /**
+ * Constructs a BridgeCreateException object.
+ * @param message error message
+ */
+ public BridgeCreateException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a BridgeCreateException object.
+ * @param message error message
+ * @param cause Throwable
+ */
+ public BridgeCreateException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Create error message.
+ * @param ovsUuid ovs uuid name
+ * @return message
+ */
+ public static String createMessage(String ovsUuid) {
+ String message = toStringHelper("BridgeCreateException")
+ .addValue("Create new bridge failed for " + ovsUuid).toString();
+ return message;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/ColumnSchemaNotFoundException.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/ColumnSchemaNotFoundException.java
new file mode 100644
index 00000000..6fa0580f
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/ColumnSchemaNotFoundException.java
@@ -0,0 +1,55 @@
+/*
+ * 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.ovsdb.rfc.exception;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * This exception is thrown when a ColumnSchema cannot be found.
+ */
+public class ColumnSchemaNotFoundException extends RuntimeException {
+ private static final long serialVersionUID = -4325190659387339524L;
+
+ /**
+ * Constructs a ColumnSchemaNotFoundException object.
+ * @param message error message
+ */
+ public ColumnSchemaNotFoundException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a ColumnSchemaNotFoundException object.
+ * @param message error message
+ * @param cause Throwable
+ */
+ public ColumnSchemaNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Create error message.
+ * @param columnName column name
+ * @param tableName table name
+ * @return message
+ */
+ public static String createMessage(String columnName, String tableName) {
+ String message = toStringHelper("ColumnSchemaNotFoundException")
+ .addValue("Could not find ColumnSchema for " + columnName
+ + " in " + tableName).toString();
+ return message;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/TableSchemaNotFoundException.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/TableSchemaNotFoundException.java
new file mode 100644
index 00000000..423cabb0
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/TableSchemaNotFoundException.java
@@ -0,0 +1,56 @@
+/*
+ * 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.ovsdb.rfc.exception;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * This exception is thrown when a TableSchema cannot be found.
+ */
+public class TableSchemaNotFoundException extends RuntimeException {
+ private static final long serialVersionUID = 8431894450061740838L;
+
+ /**
+ * Constructs a TableSchemaNotFoundException object.
+ * @param message error message
+ */
+ public TableSchemaNotFoundException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a TableSchemaNotFoundException object.
+ * @param message error message
+ * @param cause Throwable
+ */
+ public TableSchemaNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Create error message.
+ * @param tableName table name
+ * @param schemaName database name
+ * @return message
+ */
+ public static String createMessage(String tableName, String schemaName) {
+ String message = toStringHelper("TableSchemaNotFoundException")
+ .addValue("Can not find TableSchema for " + tableName + " in "
+ + schemaName).toString();
+ return message;
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/UnsupportedException.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/UnsupportedException.java
new file mode 100644
index 00000000..2c44ad37
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/UnsupportedException.java
@@ -0,0 +1,41 @@
+/*
+ * 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.ovsdb.rfc.exception;
+
+/**
+ * This exception is thrown when the caller invoke the unsupported method or
+ * use the encoding is not supported.
+ */
+public class UnsupportedException extends RuntimeException {
+ private static final long serialVersionUID = 1377011546616825375L;
+
+ /**
+ * Constructs a UnsupportedException object.
+ * @param message error message
+ */
+ public UnsupportedException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a UnsupportedException object.
+ * @param message error message
+ * @param cause Throwable
+ */
+ public UnsupportedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/VersionMismatchException.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/VersionMismatchException.java
new file mode 100644
index 00000000..ad54938e
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/VersionMismatchException.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.ovsdb.rfc.exception;
+
+
+/**
+ * This exception is used when the a table or row is accessed though a typed
+ * interface and the version requirements are not met.
+ */
+public class VersionMismatchException extends RuntimeException {
+ private static final long serialVersionUID = -8439624321110133595L;
+
+ /**
+ * Constructs a VersionMismatchException object.
+ * @param message error message
+ */
+ public VersionMismatchException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a VersionMismatchException object.
+ * @param message error message
+ * @param cause Throwable
+ */
+ public VersionMismatchException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Create error message.
+ * @param actualVersion the actual version
+ * @param fromVersion the initial version
+ * @return message
+ */
+ public static String createFromMessage(String actualVersion, String fromVersion) {
+ String message = "The fromVersion should less than the actualVersion.\n fromVersion: "
+ + fromVersion + ".\n" + "actualVersion: " + actualVersion;
+ return message;
+ }
+
+ /**
+ * Create error message.
+ * @param actualVersion the actual version
+ * @param toVersion the end version
+ * @return message
+ */
+ public static String createToMessage(String actualVersion, String toVersion) {
+ String message = "The toVersion should greater than the actualVersion.\n"
+ + "toVersion: " + toVersion + ".\n" + " actualVersion: " + actualVersion;
+ return message;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/package-info.java
new file mode 100644
index 00000000..274c8d43
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/exception/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.
+ */
+
+/**
+ * Exceptions used by the OVSDB implementation.
+ */
+package org.onosproject.ovsdb.rfc.exception;
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/Callback.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/Callback.java
new file mode 100644
index 00000000..f7ec8b67
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/Callback.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.ovsdb.rfc.jsonrpc;
+
+import java.util.List;
+
+import org.onosproject.ovsdb.rfc.message.UpdateNotification;
+
+/**
+ * The callback function interface will be used when the server send to the
+ * client report changes.
+ */
+public interface Callback {
+ /**
+ * The "update" notification is sent by the server to the client to report
+ * changes in tables that are being monitored following a "*monitor"
+ * request.
+ * @param updateNotification the information of the update
+ */
+ void update(UpdateNotification updateNotification);
+
+ /**
+ * The "locked" notification is provided to notify a client that it has been
+ * granted a lock that it had previously requested with the "lock" method.
+ * @param ids the locked ids
+ */
+ void locked(List<String> ids);
+
+ /**
+ * The "stolen" notification is provided to notify a client, which had
+ * previously obtained a lock, that another client has stolen ownership of
+ * that lock.
+ * @param ids the stolen ids
+ */
+ void stolen(List<String> ids);
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonReadContext.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonReadContext.java
new file mode 100644
index 00000000..8033f653
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonReadContext.java
@@ -0,0 +1,86 @@
+/*
+ * 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.ovsdb.rfc.jsonrpc;
+
+import java.util.Stack;
+
+/**
+ * Context for decode parameters.
+ */
+public class JsonReadContext {
+ private Stack<Byte> bufStack;
+ private boolean isStartMatch;
+ private int lastReadBytes;
+
+ /**
+ * Constructs a JsonReadContext object. This class only need initial
+ * parameter value for the readToJsonNode method of JsonRpcReaderUtil
+ * entity.
+ */
+ public JsonReadContext() {
+ bufStack = new Stack<Byte>();
+ isStartMatch = false;
+ lastReadBytes = 0;
+ }
+
+ /**
+ * Return bufStack.
+ * @return bufStack
+ */
+ public Stack<Byte> getBufStack() {
+ return bufStack;
+ }
+
+ /**
+ * Set bufStack, used for match the braces and double quotes.
+ * @param bufStack Stack of Byte
+ */
+ public void setBufStack(Stack<Byte> bufStack) {
+ this.bufStack = bufStack;
+ }
+
+ /**
+ * Return isStartMatch.
+ * @return isStartMatch
+ */
+ public boolean isStartMatch() {
+ return isStartMatch;
+ }
+
+ /**
+ * Set isStartMatch.
+ * @param isStartMatch mark whether the matching has started
+ */
+ public void setStartMatch(boolean isStartMatch) {
+ this.isStartMatch = isStartMatch;
+ }
+
+ /**
+ * Return lastReadBytes.
+ * @return lastReadBytes
+ */
+ public int getLastReadBytes() {
+ return lastReadBytes;
+ }
+
+ /**
+ * Set lastReadBytes.
+ * @param lastReadBytes the bytes for last decoding incomplete record
+ */
+ public void setLastReadBytes(int lastReadBytes) {
+ this.lastReadBytes = lastReadBytes;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonRpcRequest.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonRpcRequest.java
new file mode 100644
index 00000000..ecff096b
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonRpcRequest.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.ovsdb.rfc.jsonrpc;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+import java.util.Objects;
+
+import com.google.common.collect.Lists;
+
+/**
+ * Json Rpc Request information that include id,method,params.
+ */
+public class JsonRpcRequest {
+
+ private final String id;
+ private final String method;
+ private final List<Object> params;
+
+ /**
+ * JsonRpcRequest Constructor.
+ * @param id the id node of request information
+ * @param method the method node of request information
+ */
+ public JsonRpcRequest(String id, String method) {
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(method, "method cannot be null");
+ this.id = id;
+ this.method = method;
+ this.params = Lists.newArrayList();
+ }
+
+ /**
+ * JsonRpcRequest Constructor.
+ * @param id the id node of request information
+ * @param method the method node of request information
+ * @param params the params node of request information
+ */
+ public JsonRpcRequest(String id, String method, List<Object> params) {
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(method, "method cannot be null");
+ checkNotNull(params, "params cannot be null");
+ this.id = id;
+ this.method = method;
+ this.params = params;
+ }
+
+ /**
+ * Returns id.
+ * @return id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Returns method.
+ * @return method
+ */
+ public String getMethod() {
+ return method;
+ }
+
+ /**
+ * Returns params.
+ * @return params
+ */
+ public List<Object> getParams() {
+ return params;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, method, params);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof JsonRpcRequest) {
+ final JsonRpcRequest other = (JsonRpcRequest) obj;
+ return Objects.equals(this.id, other.id)
+ && Objects.equals(this.method, other.method)
+ && Objects.equals(this.params, other.params);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("id", id).add("method", method)
+ .add("params", params).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonRpcResponse.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonRpcResponse.java
new file mode 100644
index 00000000..a2f45414
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/JsonRpcResponse.java
@@ -0,0 +1,122 @@
+/*
+ * 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.ovsdb.rfc.jsonrpc;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+import java.util.Objects;
+
+import com.google.common.collect.Lists;
+
+/**
+ * Json Rpc Response information that include id,error,result.
+ */
+public class JsonRpcResponse {
+
+ private final String id;
+ private final String error;
+ private final List<Object> result;
+
+ /**
+ * JsonRpcResponse Constructor.
+ * @param id the id node of response information
+ */
+ public JsonRpcResponse(String id) {
+ checkNotNull(id, "id cannot be null");
+ this.id = id;
+ this.error = null;
+ this.result = Lists.newArrayList();
+ }
+
+ /**
+ * JsonRpcResponse Constructor.
+ * @param id the id node of response information
+ * @param error the error node of response information
+ */
+ public JsonRpcResponse(String id, String error) {
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(error, "error cannot be null");
+ this.id = id;
+ this.error = error;
+ this.result = Lists.newArrayList();
+ }
+
+ /**
+ * JsonRpcResponse Constructor.
+ * @param id the id node of response information
+ * @param error the error node of response information
+ * @param result the result node of response information
+ */
+ public JsonRpcResponse(String id, String error, List<Object> result) {
+ checkNotNull(id, "id cannot be null");
+ checkNotNull(error, "error cannot be null");
+ checkNotNull(result, "result cannot be null");
+ this.id = id;
+ this.error = error;
+ this.result = result;
+ }
+
+ /**
+ * Returns id.
+ * @return id
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Returns error.
+ * @return error
+ */
+ public String getError() {
+ return error;
+ }
+
+ /**
+ * Returns result.
+ * @return result
+ */
+ public List<Object> getResult() {
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, error, result);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof JsonRpcResponse) {
+ final JsonRpcResponse other = (JsonRpcResponse) obj;
+ return Objects.equals(this.id, other.id)
+ && Objects.equals(this.error, other.error)
+ && Objects.equals(this.result, other.result);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("id", id).add("error", error)
+ .add("result", result).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/OvsdbRPC.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/OvsdbRPC.java
new file mode 100644
index 00000000..5d08b143
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/OvsdbRPC.java
@@ -0,0 +1,74 @@
+/*
+ * 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.ovsdb.rfc.jsonrpc;
+
+import java.util.List;
+
+import org.onosproject.ovsdb.rfc.operations.Operation;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * The following interface describe the RPC7047's methods that are supported.
+ */
+public interface OvsdbRPC {
+
+ /**
+ * This operation retrieves a database-schema that describes hosted database
+ * db-name.
+ * @param dbnames database name
+ * @return ListenableFuture of JsonNode
+ */
+ ListenableFuture<JsonNode> getSchema(List<String> dbnames);
+
+ /**
+ * The "echo" method can be used by both clients and servers to verify the
+ * liveness of a database connection.
+ * @return return info
+ */
+ ListenableFuture<List<String>> echo();
+
+ /**
+ * The "monitor" request enables a client to replicate tables or subsets of
+ * tables within an OVSDB database by requesting notifications of changes to
+ * those tables and by receiving the complete initial state of a table or a
+ * subset of a table.
+ * @param dbSchema databse schema
+ * @param monitorId a id for monitor
+ * @return ListenableFuture of JsonNode
+ */
+ ListenableFuture<JsonNode> monitor(DatabaseSchema dbSchema, String monitorId);
+
+ /**
+ * This operation retrieves an array whose elements are the names of the
+ * databases that can be accessed over this management protocol connection.
+ * @return database names
+ */
+ ListenableFuture<List<String>> listDbs();
+
+ /**
+ * This RPC method causes the database server to execute a series of
+ * operations in the specified order on a given database.
+ * @param dbSchema database schema
+ * @param operations the operations to execute
+ * @return result the transact result
+ */
+ ListenableFuture<List<JsonNode>> transact(DatabaseSchema dbSchema,
+ List<Operation> operations);
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/package-info.java
new file mode 100644
index 00000000..7edf5b46
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/jsonrpc/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.
+ */
+
+/**
+ * RFC 7047 implementation.
+ */
+package org.onosproject.ovsdb.rfc.jsonrpc;
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/MonitorRequest.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/MonitorRequest.java
new file mode 100644
index 00000000..e7f5eaee
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/MonitorRequest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.ovsdb.rfc.message;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+import java.util.Set;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+/**
+ * Monitor Requst information that need to monitor table.
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public final class MonitorRequest {
+ @JsonIgnore
+ private final String tableName;
+ private final Set<String> columns;
+ private final MonitorSelect select;
+
+ /**
+ * Constructs a MonitorRequest object.
+ * @param tableName table name
+ * @param columns a set of column name
+ * @param select monitor action
+ */
+ public MonitorRequest(String tableName, Set<String> columns,
+ MonitorSelect select) {
+ checkNotNull(tableName, "table name cannot be null");
+ checkNotNull(columns, "columns cannot be null");
+ checkNotNull(select, "select cannot be null");
+ this.tableName = tableName;
+ this.columns = columns;
+ this.select = select;
+ }
+
+ /**
+ * Returns tableName.
+ * @return tableName
+ */
+ public String getTableName() {
+ return tableName;
+ }
+
+ /**
+ * Returns select.
+ * @return select
+ */
+ public MonitorSelect getSelect() {
+ return select;
+ }
+
+ /**
+ * Returns columns.
+ * @return columns
+ */
+ public Set<String> getColumns() {
+ return columns;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tableName, select, columns);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MonitorRequest) {
+ final MonitorRequest other = (MonitorRequest) obj;
+ return Objects.equals(this.tableName, other.tableName)
+ && Objects.equals(this.select, other.select)
+ && Objects.equals(this.columns, other.columns);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("tableName", tableName)
+ .add("select", select).add("columns", columns).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/MonitorSelect.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/MonitorSelect.java
new file mode 100644
index 00000000..502fc4de
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/MonitorSelect.java
@@ -0,0 +1,106 @@
+/*
+ * 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.ovsdb.rfc.message;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+/**
+ * The contents of this object specify how the columns or table are to be
+ * monitored.
+ */
+public final class MonitorSelect {
+
+ private final boolean initial;
+ private final boolean insert;
+ private final boolean delete;
+ private final boolean modify;
+
+ /**
+ * Constructs a MonitorSelect object.
+ * @param initial whether monitor the initial action
+ * @param insert whether monitor the insert action
+ * @param delete whether monitor the delete action
+ * @param modify whether monitor the modify action
+ */
+ public MonitorSelect(boolean initial, boolean insert, boolean delete,
+ boolean modify) {
+ this.initial = initial;
+ this.insert = insert;
+ this.delete = delete;
+ this.modify = modify;
+ }
+
+ /**
+ * Returns initial.
+ * @return initial
+ */
+ public boolean isInitial() {
+ return initial;
+ }
+
+ /**
+ * Returns insert.
+ * @return insert
+ */
+ public boolean isInsert() {
+ return insert;
+ }
+
+ /**
+ * Returns delete.
+ * @return delete
+ */
+ public boolean isDelete() {
+ return delete;
+ }
+
+ /**
+ * Returns modify.
+ * @return modify
+ */
+ public boolean isModify() {
+ return modify;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(initial, insert, delete, modify);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MonitorSelect) {
+ final MonitorSelect other = (MonitorSelect) obj;
+ return Objects.equals(this.initial, other.initial)
+ && Objects.equals(this.insert, other.insert)
+ && Objects.equals(this.delete, other.delete)
+ && Objects.equals(this.modify, other.modify);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("initial", initial)
+ .add("insert", insert).add("delete", delete)
+ .add("modify", modify).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/OperationResult.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/OperationResult.java
new file mode 100644
index 00000000..99807355
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/OperationResult.java
@@ -0,0 +1,158 @@
+/*
+ * 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.ovsdb.rfc.message;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * All results of ovs table operations. refer to RFC7047 5.2.
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public final class OperationResult {
+ private int count;
+ private UUID uuid;
+ private List<Row> rows;
+ private String error;
+ private String details;
+
+ /**
+ * Constructs a OperationResult object. When JsonNode is converted into
+ * OperationResult, need this constructor and also need setter method.
+ */
+ public OperationResult() {
+ }
+
+ /**
+ * Constructs a OperationResult object.
+ * @param rows List of Row entity
+ */
+ public OperationResult(List<Row> rows) {
+ checkNotNull(rows, "rows cannot be null");
+ this.rows = rows;
+ }
+
+ /**
+ * Constructs a OperationResult object.
+ * @param count the count node of result
+ * @param uuid UUID entity
+ * @param rows List of Row entity
+ * @param error error message
+ * @param details details of error message
+ */
+ public OperationResult(int count, UUID uuid, List<Row> rows, String error,
+ String details) {
+ checkNotNull(uuid, "uuid cannot be null");
+ checkNotNull(rows, "rows cannot be null");
+ checkNotNull(error, "error cannot be null");
+ checkNotNull(details, "details cannot be null");
+ this.count = count;
+ this.uuid = uuid;
+ this.rows = rows;
+ this.error = error;
+ this.details = details;
+ }
+
+ /**
+ * Return count.
+ * @return count
+ */
+ public int getCount() {
+ return count;
+ }
+
+ /**
+ * Set count value.
+ * @param count the Operation message of count
+ */
+ public void setCount(int count) {
+ this.count = count;
+ }
+
+ /**
+ * Return uuid.
+ * @return uuid
+ */
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Set uuid value.
+ * @param uuid the Operation message of uuid
+ */
+ public void setUuid(UUID uuid) {
+ checkNotNull(uuid, "uuid cannot be null");
+ this.uuid = uuid;
+ }
+
+ /**
+ * Return rows.
+ * @return List of Row
+ */
+ public List<Row> getRows() {
+ return rows;
+ }
+
+ /**
+ * Set rows value.
+ * @param rows the Operation message of rows
+ */
+ public void setRows(List<Row> rows) {
+ checkNotNull(rows, "rows cannot be null");
+ this.rows = rows;
+ }
+
+ /**
+ * Return error.
+ * @return error
+ */
+ public String getError() {
+ return error;
+ }
+
+ /**
+ * Set error value.
+ * @param error the Operation message of error
+ */
+ public void setError(String error) {
+ checkNotNull(error, "error cannot be null");
+ this.error = error;
+ }
+
+ /**
+ * Return details.
+ * @return details
+ */
+ public String getDetails() {
+ return details;
+ }
+
+ /**
+ * Set details value.
+ * @param details the Operation message of details
+ */
+ public void setDetails(String details) {
+ checkNotNull(details, "details cannot be null");
+ this.details = details;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/RowUpdate.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/RowUpdate.java
new file mode 100644
index 00000000..221206ef
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/RowUpdate.java
@@ -0,0 +1,97 @@
+/*
+ * 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.ovsdb.rfc.message;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+
+/**
+ * A TableUpdate is an object that maps from the row's UUID to a RowUpdate object.
+ * A RowUpdate is an object with the following members: "old": row, "new": row.
+ * Refer to RFC 7047 Section 4.1.6.
+ */
+public final class RowUpdate {
+ private final UUID uuid;
+ private final Row oldRow;
+ private final Row newRow;
+
+ /**
+ * Constructs a RowUpdate object.
+ * @param uuid UUID
+ * @param oldRow present for "delete" and "modify" updates
+ * @param newRow present for "initial", "insert", and "modify" updates
+ */
+ public RowUpdate(UUID uuid, Row oldRow, Row newRow) {
+ checkNotNull(uuid, "uuid cannot be null");
+ this.uuid = uuid;
+ this.oldRow = oldRow;
+ this.newRow = newRow;
+ }
+
+ /**
+ * Return uuid.
+ * @return uuid
+ */
+ public UUID uuid() {
+ return this.uuid;
+ }
+
+ /**
+ * Return oldRow.
+ * @return oldRow
+ */
+ public Row oldRow() {
+ return oldRow;
+ }
+
+ /**
+ * Return newRow.
+ * @return newRow
+ */
+ public Row newRow() {
+ return newRow;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(uuid, oldRow, newRow);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof RowUpdate) {
+ final RowUpdate other = (RowUpdate) obj;
+ return Objects.equals(this.uuid, other.uuid)
+ && Objects.equals(this.oldRow, other.oldRow)
+ && Objects.equals(this.newRow, other.newRow);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("uuid", uuid).add("oldRow", oldRow)
+ .add("newRow", newRow).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdate.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdate.java
new file mode 100644
index 00000000..0673b79e
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdate.java
@@ -0,0 +1,107 @@
+/*
+ * 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.ovsdb.rfc.message;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+import java.util.Objects;
+
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+
+/**
+ * TableUpdate is an object that maps from the row's UUID to a RowUpdate object.
+ */
+public final class TableUpdate {
+
+ private final Map<UUID, RowUpdate> rows;
+
+ /**
+ * Constructs a TableUpdate object.
+ * @param rows the parameter of TableUpdate entity
+ */
+ private TableUpdate(Map<UUID, RowUpdate> rows) {
+ this.rows = rows;
+ }
+
+ /**
+ * Get TableUpdate entity.
+ * @param rows the parameter of TableUpdate entity
+ * @return TableUpdate entity
+ */
+ public static TableUpdate tableUpdate(Map<UUID, RowUpdate> rows) {
+ checkNotNull(rows, "rows cannot be null");
+ return new TableUpdate(rows);
+ }
+
+ /**
+ * Return old row.
+ * @param uuid the key of rows
+ * @return Row old row
+ */
+ public Row getOld(UUID uuid) {
+ RowUpdate rowUpdate = rows.get(uuid);
+ if (rowUpdate == null) {
+ return null;
+ }
+ return rowUpdate.oldRow();
+ }
+
+ /**
+ * Return new row.
+ * @param uuid the key of rows
+ * @return Row new row
+ */
+ public Row getNew(UUID uuid) {
+ RowUpdate rowUpdate = rows.get(uuid);
+ if (rowUpdate == null) {
+ return null;
+ }
+ return rowUpdate.newRow();
+ }
+
+ /**
+ * Return rows.
+ * @return rows
+ */
+ public Map<UUID, RowUpdate> rows() {
+ return rows;
+ }
+
+ @Override
+ public int hashCode() {
+ return rows.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TableUpdate) {
+ final TableUpdate other = (TableUpdate) obj;
+ return Objects.equals(this.rows, other.rows);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("rows", rows).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdates.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdates.java
new file mode 100644
index 00000000..e161016b
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdates.java
@@ -0,0 +1,89 @@
+/*
+ * 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.ovsdb.rfc.message;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+import java.util.Objects;
+
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+
+/**
+ * TableUpdates is an object that maps from a table name to a TableUpdate.
+ */
+public final class TableUpdates {
+
+ private final Map<String, TableUpdate> result;
+
+ /**
+ * Constructs a TableUpdates object.
+ * @param result the parameter of TableUpdates entity
+ */
+ private TableUpdates(Map<String, TableUpdate> result) {
+ this.result = result;
+ }
+
+ /**
+ * Get TableUpdates.
+ * @param result the parameter of TableUpdates entity
+ * @return TableUpdates
+ */
+ public static TableUpdates tableUpdates(Map<String, TableUpdate> result) {
+ checkNotNull(result, "result cannot be null");
+ return new TableUpdates(result);
+ }
+
+ /**
+ * Return TableUpdate.
+ * @param table the TableSchema of TableUpdates
+ * @return TableUpdate
+ */
+ public TableUpdate tableUpdate(TableSchema table) {
+ return this.result.get(table.name());
+ }
+
+ /**
+ * Return the map of TableUpdate.
+ * @return result
+ */
+ public Map<String, TableUpdate> result() {
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ return result.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TableUpdates) {
+ final TableUpdates other = (TableUpdates) obj;
+ return Objects.equals(this.result, other.result);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("result", result).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/UpdateNotification.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/UpdateNotification.java
new file mode 100644
index 00000000..d4f0513d
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/UpdateNotification.java
@@ -0,0 +1,90 @@
+/*
+ * 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.ovsdb.rfc.message;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.ovsdb.rfc.notation.json.UpdateNotificationConverter;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+
+/**
+ * The "update" notification is sent by the server to the client to report
+ * changes in tables that are being monitored following a "monitor" request. The
+ * "params" of the result JsonNode.
+ */
+@JsonDeserialize(converter = UpdateNotificationConverter.class)
+public final class UpdateNotification {
+ private final Object jsonValue;
+ private final JsonNode tbUpdatesJsonNode;
+
+ /**
+ * Constructs a UpdateNotification object.
+ * @param jsonValue the "json-value" in "params" of the result JsonNode
+ * @param tbUpdatesJsonNode the "table-updates" in "params" of the result JsonNode
+ */
+ public UpdateNotification(Object jsonValue, JsonNode tbUpdatesJsonNode) {
+ checkNotNull(jsonValue, "jsonValue cannot be null");
+ checkNotNull(tbUpdatesJsonNode, "tablebUpdates JsonNode cannot be null");
+ this.jsonValue = jsonValue;
+ this.tbUpdatesJsonNode = tbUpdatesJsonNode;
+ }
+
+ /**
+ * Return context.
+ * @return context
+ */
+ public Object jsonValue() {
+ return jsonValue;
+ }
+
+ /**
+ * Return tbUpdatesJsonNode.
+ * @return tbUpdatesJsonNode
+ */
+ public JsonNode tbUpdatesJsonNode() {
+ return tbUpdatesJsonNode;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(jsonValue, tbUpdatesJsonNode);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof UpdateNotification) {
+ final UpdateNotification other = (UpdateNotification) obj;
+ return Objects.equals(this.jsonValue, other.jsonValue)
+ && Objects.equals(this.tbUpdatesJsonNode,
+ other.tbUpdatesJsonNode);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("jsonValue", jsonValue)
+ .add("tbUpdatesJsonNode", tbUpdatesJsonNode).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/package-info.java
new file mode 100644
index 00000000..1b301262
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/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.
+ */
+
+/**
+ * OVSDB message definitions.
+ */
+package org.onosproject.ovsdb.rfc.message;
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Column.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Column.java
new file mode 100644
index 00000000..60f49442
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Column.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.ovsdb.rfc.notation;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * Column is the basic element of the OpenVswitch database.
+ */
+public final class Column {
+ private final String columnName;
+ private final Object data;
+
+ /**
+ * Column constructor.
+ * @param columnName the column name
+ * @param obj the data of the column
+ */
+ public Column(String columnName, Object obj) {
+ checkNotNull(columnName, "columnName cannot be null");
+ checkNotNull(obj, "data cannot be null");
+ this.columnName = columnName;
+ this.data = obj;
+ }
+
+ /**
+ * Returns column data.
+ * @return column data
+ */
+ public Object data() {
+ return data;
+ }
+
+ /**
+ * Returns columnName.
+ * @return columnName
+ */
+ public String columnName() {
+ return columnName;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(columnName, data);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Column) {
+ final Column other = (Column) obj;
+ return Objects.equals(this.columnName, other.columnName)
+ && Objects.equals(this.data, other.data);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("columnName", columnName)
+ .add("data", data).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Condition.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Condition.java
new file mode 100644
index 00000000..cbf35424
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Condition.java
@@ -0,0 +1,123 @@
+/*
+ * 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.ovsdb.rfc.notation;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.ovsdb.rfc.notation.json.ConditionSerializer;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+/**
+ * Condition is a 3-element JSON array of the form [column, function, value]
+ * that represents a test on a column value.
+ */
+@JsonSerialize(using = ConditionSerializer.class)
+public final class Condition {
+ /**
+ * Function of Notation. Refer to RFC 7047 Section 5.1.
+ */
+ public enum Function {
+ LESS_THAN("<"), LESS_THAN_OR_EQUALS("<="), EQUALS("=="),
+ NOT_EQUALS("!="), GREATER_THAN(">"), GREATER_THAN_OR_EQUALS(">="),
+ INCLUDES("includes"), EXCLUDES("excludes");
+
+ private final String function;
+
+ private Function(String function) {
+ this.function = function;
+ }
+
+ /**
+ * Returns the function for Function.
+ * @return the function
+ */
+ public String function() {
+ return function;
+ }
+ }
+
+ private final String column;
+ private final Function function;
+ private final Object value;
+
+ /**
+ * Constructs a Condition object.
+ * @param column the column name
+ * @param function Function
+ * @param value column data
+ */
+ public Condition(String column, Function function, Object value) {
+ checkNotNull(column, "column cannot be null");
+ checkNotNull(function, "function cannot be null");
+ checkNotNull(value, "value cannot be null");
+ this.column = column;
+ this.function = function;
+ this.value = value;
+ }
+
+ /**
+ * Returns column name.
+ * @return column name
+ */
+ public String getColumn() {
+ return column;
+ }
+
+ /**
+ * Returns Function.
+ * @return Function
+ */
+ public Function getFunction() {
+ return function;
+ }
+
+ /**
+ * Returns column data.
+ * @return column data
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(column, function, value);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Condition) {
+ final Condition other = (Condition) obj;
+ return Objects.equals(this.column, other.column)
+ && Objects.equals(this.function, other.function)
+ && Objects.equals(this.value, other.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("column", column)
+ .add("function", function).add("value", value).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Mutation.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Mutation.java
new file mode 100644
index 00000000..5b5293c2
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Mutation.java
@@ -0,0 +1,124 @@
+/*
+ * 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.ovsdb.rfc.notation;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.ovsdb.rfc.notation.json.MutationSerializer;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+/**
+ * Mutation is s 3-element JSON array of the form [column, mutator, value] that
+ * represents a change to a column value.
+ */
+@JsonSerialize(using = MutationSerializer.class)
+public final class Mutation {
+ /**
+ * Mutator must be "+=", "-=", "*=", "/=", or (integer only) "%=". The value
+ * of column is changed to the sum, difference, product, quotient, or
+ * remainder, respectively, of column and value.
+ */
+ public enum Mutator {
+ SUM("+="), DIFFERENCE("-="), PRODUCT("*="), QUOTIENT("/="),
+ REMAINDER("%="), INSERT("insert"), DELETE("delete");
+
+ private final String mutator;
+
+ private Mutator(String mutator) {
+ this.mutator = mutator;
+ }
+
+ /**
+ * Returns the mutator for Mutator.
+ * @return the mutator
+ */
+ public String mutator() {
+ return mutator;
+ }
+ }
+
+ private final String column;
+ private final Mutator mutator;
+ private final Object value;
+
+ /**
+ * Mutation constructor.
+ * @param column the column name
+ * @param mutator Mutator
+ * @param value column data
+ */
+ public Mutation(String column, Mutator mutator, Object value) {
+ checkNotNull(column, "column cannot be null");
+ checkNotNull(mutator, "mutator cannot be null");
+ checkNotNull(value, "value cannot be null");
+ this.column = column;
+ this.mutator = mutator;
+ this.value = value;
+ }
+
+ /**
+ * Returns column name.
+ * @return column name
+ */
+ public String getColumn() {
+ return column;
+ }
+
+ /**
+ * Returns Mutator.
+ * @return Mutator
+ */
+ public Mutator getMutator() {
+ return mutator;
+ }
+
+ /**
+ * Returns column data.
+ * @return column data
+ */
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(column, mutator, value);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Mutation) {
+ final Mutation other = (Mutation) obj;
+ return Objects.equals(this.column, other.column)
+ && Objects.equals(this.mutator, other.mutator)
+ && Objects.equals(this.value, other.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("column", column)
+ .add("mutator", mutator).add("value", value).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbMap.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbMap.java
new file mode 100644
index 00000000..a62ab0db
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbMap.java
@@ -0,0 +1,83 @@
+/*
+ * 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.ovsdb.rfc.notation;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+import java.util.Objects;
+
+import org.onosproject.ovsdb.rfc.notation.json.OvsdbMapSerializer;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+/**
+ * OvsdbMap is a 2-element JSON array that represents a database map value.
+ */
+@JsonSerialize(using = OvsdbMapSerializer.class)
+public final class OvsdbMap {
+
+ private final Map map;
+
+ /**
+ * OvsdbMap constructor.
+ * @param map java.util.Map
+ */
+ private OvsdbMap(Map map) {
+ checkNotNull(map, "map cannot be null");
+ this.map = map;
+ }
+
+ /**
+ * Returns map.
+ * @return map
+ */
+ public Map map() {
+ return map;
+ }
+
+ /**
+ * convert Map into OvsdbMap.
+ * @param map java.util.Map
+ * @return OvsdbMap
+ */
+ public static OvsdbMap ovsdbMap(Map map) {
+ return new OvsdbMap(map);
+ }
+
+ @Override
+ public int hashCode() {
+ return map.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbMap) {
+ final OvsdbMap other = (OvsdbMap) obj;
+ return Objects.equals(this.map, other.map);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("map", map).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbSet.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbSet.java
new file mode 100644
index 00000000..21f0b72b
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbSet.java
@@ -0,0 +1,85 @@
+/*
+ * 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.ovsdb.rfc.notation;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.json.OvsdbSetSerializer;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+/**
+ * OvsdbSet is either an atom, representing a set with exactly one element, or
+ * a 2-element JSON array that represents a database set value.
+ *
+ */
+@JsonSerialize(using = OvsdbSetSerializer.class)
+public final class OvsdbSet {
+
+ private final Set set;
+
+ /**
+ * OvsdbSet constructor.
+ * @param set java.util.Set
+ */
+ private OvsdbSet(Set set) {
+ checkNotNull(set, "set cannot be null");
+ this.set = set;
+ }
+
+ /**
+ * Returns set.
+ * @return set
+ */
+ public Set set() {
+ return set;
+ }
+
+ /**
+ * convert Set into OvsdbSet.
+ * @param set java.util.Set
+ * @return OvsdbSet
+ */
+ public static OvsdbSet ovsdbSet(Set set) {
+ return new OvsdbSet(set);
+ }
+
+ @Override
+ public int hashCode() {
+ return set.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OvsdbSet) {
+ final OvsdbSet other = (OvsdbSet) obj;
+ return Objects.equals(this.set, other.set);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("set", set).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/RefTableRow.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/RefTableRow.java
new file mode 100644
index 00000000..1b22a426
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/RefTableRow.java
@@ -0,0 +1,84 @@
+/*
+ * 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.ovsdb.rfc.notation;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * The RefTable type that can be expanded to Row. Refer to RFC 7047 Section 3.2.
+ */
+public final class RefTableRow {
+
+ private final String refTable;
+ private final JsonNode jsonNode;
+
+ /**
+ * RefTableRow constructor.
+ * @param refTable the refTable value of JsonNode
+ * @param jsonNode JsonNode
+ */
+ public RefTableRow(String refTable, JsonNode jsonNode) {
+ checkNotNull(refTable, "refTable cannot be null");
+ checkNotNull(jsonNode, "jsonNode cannot be null");
+ this.refTable = refTable;
+ this.jsonNode = jsonNode;
+ }
+
+ /**
+ * Returns JsonNode.
+ * @return JsonNode
+ */
+ public JsonNode jsonNode() {
+ return jsonNode;
+ }
+
+ /**
+ * Returns refTable.
+ * @return refTable
+ */
+ public String refTable() {
+ return refTable;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(refTable, jsonNode);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof RefTableRow) {
+ final RefTableRow other = (RefTableRow) obj;
+ return Objects.equals(this.refTable, other.refTable)
+ && Objects.equals(this.jsonNode, other.jsonNode);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("refTable", refTable)
+ .add("jsonNode", jsonNode).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Row.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Row.java
new file mode 100644
index 00000000..09088766
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/Row.java
@@ -0,0 +1,159 @@
+/*
+ * 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.ovsdb.rfc.notation;
+
+import com.google.common.collect.Maps;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Row is the basic element of the OpenVswitch's table.
+ */
+public final class Row {
+ private String tableName;
+ private UUID uuid;
+ private Map<String, Column> columns;
+
+ /**
+ * Row constructor.
+ */
+ public Row() {
+ this.columns = Maps.newHashMap();
+ }
+
+ /**
+ * Row constructor.
+ *
+ * @param tableName table name
+ * @deprecated in Emu Release
+ */
+ @Deprecated
+ private Row(String tableName) {
+ checkNotNull(tableName, "tableName cannot be null");
+ this.tableName = tableName;
+ this.columns = Maps.newHashMap();
+ }
+
+ /**
+ * Row constructor.
+ *
+ * @param tableName table name
+ * @param columns Map of Column entity
+ * @param uuid UUID of the row
+ */
+ public Row(String tableName, UUID uuid, Map<String, Column> columns) {
+ checkNotNull(tableName, "table name cannot be null");
+ checkNotNull(uuid, "uuid cannot be null");
+ checkNotNull(columns, "columns cannot be null");
+ this.tableName = tableName;
+ this.uuid = uuid;
+ this.columns = columns;
+ }
+
+ /**
+ * Returns tableName.
+ *
+ * @return tableName
+ */
+ public String tableName() {
+ return tableName;
+ }
+
+ /**
+ * Set tableName value.
+ *
+ * @param tableName table name
+ */
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ /**
+ * Returns uuid.
+ *
+ * @return uuid
+ */
+ public UUID uuid() {
+ return uuid;
+ }
+
+ /**
+ * Sets uuid value.
+ *
+ * @param uuid new uuid
+ */
+ public void setUuid(UUID uuid) {
+ this.uuid = uuid;
+ }
+
+ /**
+ * Returns Column by ColumnSchema.
+ *
+ * @param columnName column name
+ * @return Column
+ */
+ public Column getColumn(String columnName) {
+ return columns.get(columnName);
+ }
+
+ /**
+ * Returns Collection of Column.
+ *
+ * @return Collection of Column
+ */
+ public Collection<Column> getColumns() {
+ return columns.values();
+ }
+
+ /**
+ * add Column.
+ *
+ * @param columnName column name
+ * @param data Column entity
+ */
+ public void addColumn(String columnName, Column data) {
+ this.columns.put(columnName, data);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tableName, columns);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Row) {
+ final Row other = (Row) obj;
+ return Objects.equals(this.tableName, other.tableName)
+ && Objects.equals(this.columns, other.columns);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("tableName", tableName)
+ .add("columns", columns).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/UUID.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/UUID.java
new file mode 100644
index 00000000..0177eea3
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/UUID.java
@@ -0,0 +1,84 @@
+/*
+ * 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.ovsdb.rfc.notation;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.ovsdb.rfc.notation.json.UUIDConverter;
+import org.onosproject.ovsdb.rfc.notation.json.UUIDSerializer;
+
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+/**
+ * Handles both uuid and named-uuid.
+ */
+@JsonSerialize(using = UUIDSerializer.class)
+@JsonDeserialize(converter = UUIDConverter.class)
+public final class UUID {
+ private final String value;
+
+ /**
+ * UUID constructor.
+ * @param value UUID value
+ */
+ private UUID(String value) {
+ checkNotNull(value, "value cannot be null");
+ this.value = value;
+ }
+
+ /**
+ * Get UUID.
+ * @param value UUID value
+ * @return UUID
+ */
+ public static UUID uuid(String value) {
+ return new UUID(value);
+ }
+
+ /**
+ * Returns value.
+ * @return value
+ */
+ public String value() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof UUID) {
+ final UUID other = (UUID) obj;
+ return Objects.equals(this.value, other.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("value", value).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/ConditionSerializer.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/ConditionSerializer.java
new file mode 100644
index 00000000..551a66a4
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/ConditionSerializer.java
@@ -0,0 +1,41 @@
+/*
+ * 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.ovsdb.rfc.notation.json;
+
+import java.io.IOException;
+
+import org.onosproject.ovsdb.rfc.notation.Condition;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+/**
+ * Condition Serializer.
+ */
+public class ConditionSerializer extends JsonSerializer<Condition> {
+ @Override
+ public void serialize(Condition condition, JsonGenerator generator,
+ SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+ generator.writeStartArray();
+ generator.writeString(condition.getColumn());
+ generator.writeString(condition.getFunction().function());
+ generator.writeObject(condition.getValue());
+ generator.writeEndArray();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/MutationSerializer.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/MutationSerializer.java
new file mode 100644
index 00000000..a18b9e72
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/MutationSerializer.java
@@ -0,0 +1,41 @@
+/*
+ * 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.ovsdb.rfc.notation.json;
+
+import java.io.IOException;
+
+import org.onosproject.ovsdb.rfc.notation.Mutation;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+/**
+ * Mutation Serializer.
+ */
+public class MutationSerializer extends JsonSerializer<Mutation> {
+ @Override
+ public void serialize(Mutation condition, JsonGenerator generator,
+ SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+ generator.writeStartArray();
+ generator.writeString(condition.getColumn());
+ generator.writeString(condition.getMutator().mutator());
+ generator.writeObject(condition.getValue());
+ generator.writeEndArray();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/OvsdbMapSerializer.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/OvsdbMapSerializer.java
new file mode 100644
index 00000000..60fd3349
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/OvsdbMapSerializer.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.ovsdb.rfc.notation.json;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.onosproject.ovsdb.rfc.notation.OvsdbMap;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+/**
+ * OvsdbMap Serializer.
+ */
+public class OvsdbMapSerializer extends JsonSerializer<OvsdbMap> {
+ @Override
+ public void serialize(OvsdbMap map, JsonGenerator generator,
+ SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+ generator.writeStartArray();
+ generator.writeString("map");
+ generator.writeStartArray();
+ Map javaMap = map.map();
+ for (Object key : javaMap.keySet()) {
+ generator.writeStartArray();
+ generator.writeObject(key);
+ generator.writeObject(javaMap.get(key));
+ generator.writeEndArray();
+ }
+ generator.writeEndArray();
+ generator.writeEndArray();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/OvsdbSetSerializer.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/OvsdbSetSerializer.java
new file mode 100644
index 00000000..509b2c53
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/OvsdbSetSerializer.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.ovsdb.rfc.notation.json;
+
+import java.io.IOException;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.OvsdbSet;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+/**
+ * OvsdbSet Serializer.
+ */
+public class OvsdbSetSerializer extends JsonSerializer<OvsdbSet> {
+ @Override
+ public void serialize(OvsdbSet set, JsonGenerator generator,
+ SerializerProvider provider)
+ throws IOException, JsonProcessingException {
+ generator.writeStartArray();
+ generator.writeString("set");
+ generator.writeStartArray();
+ Set javaSet = set.set();
+ for (Object key : javaSet) {
+ generator.writeObject(key);
+ }
+ generator.writeEndArray();
+ generator.writeEndArray();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UUIDConverter.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UUIDConverter.java
new file mode 100644
index 00000000..66a86633
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UUIDConverter.java
@@ -0,0 +1,32 @@
+/*
+ * 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.ovsdb.rfc.notation.json;
+
+import org.onosproject.ovsdb.rfc.notation.UUID;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.util.StdConverter;
+
+/**
+ * UUIDConverter Converter.
+ */
+public class UUIDConverter extends StdConverter<JsonNode, UUID> {
+
+ @Override
+ public UUID convert(JsonNode json) {
+ return UUID.uuid(json.get(1).asText());
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UUIDSerializer.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UUIDSerializer.java
new file mode 100644
index 00000000..8fb5c49c
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UUIDSerializer.java
@@ -0,0 +1,43 @@
+/*
+ * 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.ovsdb.rfc.notation.json;
+
+import java.io.IOException;
+
+import org.onosproject.ovsdb.rfc.notation.UUID;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+/**
+ * UUID Serializer.
+ */
+public class UUIDSerializer extends JsonSerializer<UUID> {
+ @Override
+ public void serialize(UUID value, JsonGenerator generator,
+ SerializerProvider provider) throws IOException {
+ generator.writeStartArray();
+ String reg = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$";
+ if (value.value().matches(reg)) {
+ generator.writeString("uuid");
+ } else {
+ generator.writeString("named-uuid");
+ }
+ generator.writeString(value.value());
+ generator.writeEndArray();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UpdateNotificationConverter.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UpdateNotificationConverter.java
new file mode 100644
index 00000000..2bb1b633
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/UpdateNotificationConverter.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.ovsdb.rfc.notation.json;
+
+import org.onosproject.ovsdb.rfc.message.UpdateNotification;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.util.StdConverter;
+
+/**
+ * UpdateNotificationDeser Converter.
+ */
+public class UpdateNotificationConverter
+ extends StdConverter<JsonNode, UpdateNotification> {
+
+ @Override
+ public UpdateNotification convert(JsonNode value) {
+ return deserialize(value);
+ }
+
+ /**
+ * JsonNode convert into UpdateNotification.
+ * @param node the "params" node of UpdateNotification JsonNode
+ */
+ private UpdateNotification deserialize(JsonNode node) {
+ if (node.isArray()) {
+ if (node.size() == 2) {
+ return new UpdateNotification(node.get(0).asText(), node.get(1));
+ }
+ }
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/package-info.java
new file mode 100644
index 00000000..eb2e7c66
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/json/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.
+ */
+
+/**
+ * OVSDB JSON utilities.
+ */
+package org.onosproject.ovsdb.rfc.notation.json;
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/package-info.java
new file mode 100644
index 00000000..1900dfef
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/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.
+ */
+
+/**
+ * OVSDB primitives.
+ */
+package org.onosproject.ovsdb.rfc.notation;
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Abort.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Abort.java
new file mode 100644
index 00000000..8751f70e
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Abort.java
@@ -0,0 +1,43 @@
+/*
+ * 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.ovsdb.rfc.operations;
+
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+
+/**
+ * assert operation.Refer to RFC 7047 Section 5.2.
+ */
+public final class Abort implements Operation {
+
+ private final String op;
+
+ /**
+ * Constructs a Abort object.
+ */
+ public Abort() {
+ this.op = Operations.ABORT.op();
+ }
+
+ @Override
+ public String getOp() {
+ return op;
+ }
+
+ @Override
+ public TableSchema getTableSchema() {
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Assert.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Assert.java
new file mode 100644
index 00000000..92a63361
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Assert.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ovsdb.rfc.operations;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+
+/**
+ * assert operation.Refer to RFC 7047 Section 5.2.
+ */
+public final class Assert implements Operation {
+
+ private final String op;
+ private final String lock;
+
+ /**
+ * Constructs a Assert object.
+ * @param lock the lock member of assert operation
+ */
+ public Assert(String lock) {
+ checkNotNull(lock, "lock cannot be null");
+ this.op = Operations.ASSERT.op();
+ this.lock = lock;
+ }
+
+ /**
+ * Returns the lock member of assert operation.
+ * @return the lock member of assert operation
+ */
+ public String getLock() {
+ return lock;
+ }
+
+ @Override
+ public String getOp() {
+ return op;
+ }
+
+ @Override
+ public TableSchema getTableSchema() {
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Comment.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Comment.java
new file mode 100644
index 00000000..2853e1ff
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Comment.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ovsdb.rfc.operations;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+
+/**
+ * comment operation.Refer to RFC 7047 Section 5.2.
+ */
+public final class Comment implements Operation {
+
+ private final String op;
+ private final String comment;
+
+ /**
+ * Constructs a Comment object.
+ * @param comment the comment member of comment operation
+ */
+ public Comment(String comment) {
+ checkNotNull(comment, "comment cannot be null");
+ this.op = Operations.COMMENT.op();
+ this.comment = comment;
+ }
+
+ /**
+ * Returns the comment member of comment operation.
+ * @return the comment member of comment operation
+ */
+ public String getComment() {
+ return comment;
+ }
+
+ @Override
+ public String getOp() {
+ return op;
+ }
+
+ @Override
+ public TableSchema getTableSchema() {
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Commit.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Commit.java
new file mode 100644
index 00000000..c87fb6e9
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Commit.java
@@ -0,0 +1,57 @@
+/*
+ * 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.ovsdb.rfc.operations;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+
+/**
+ * commit operation.Refer to RFC 7047 Section 5.2.
+ */
+public final class Commit implements Operation {
+
+ private final String op;
+ private final Boolean durable;
+
+ /**
+ * Constructs a Commit object.
+ * @param durable the durable member of commit operation
+ */
+ public Commit(Boolean durable) {
+ checkNotNull(durable, "durable cannot be null");
+ this.op = Operations.COMMIT.op();
+ this.durable = durable;
+ }
+
+ /**
+ * Returns the durable member of commit operation.
+ * @return the durable member of commit operation
+ */
+ public Boolean isDurable() {
+ return durable;
+ }
+
+ @Override
+ public String getOp() {
+ return op;
+ }
+
+ @Override
+ public TableSchema getTableSchema() {
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Delete.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Delete.java
new file mode 100644
index 00000000..08b5e522
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Delete.java
@@ -0,0 +1,77 @@
+/*
+ * 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.ovsdb.rfc.operations;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+import org.onosproject.ovsdb.rfc.notation.Condition;
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * delete operation.Refer to RFC 7047 Section 5.2.
+ */
+public final class Delete implements Operation {
+
+ @JsonIgnore
+ private final TableSchema tableSchema;
+ private final String op;
+ private final List<Condition> where;
+
+ /**
+ * Constructs a Delete object.
+ * @param schema TableSchema entity
+ * @param where the List of Condition entity
+ */
+ public Delete(TableSchema schema, List<Condition> where) {
+ checkNotNull(schema, "TableSchema cannot be null");
+ checkNotNull(where, "where is not null");
+ this.tableSchema = schema;
+ this.op = Operations.DELETE.op();
+ this.where = where;
+ }
+
+ /**
+ * Returns the where member of delete operation.
+ * @return the where member of delete operation
+ */
+ public List<Condition> getWhere() {
+ return where;
+ }
+
+ @Override
+ public String getOp() {
+ return op;
+ }
+
+ @Override
+ public TableSchema getTableSchema() {
+ return tableSchema;
+ }
+
+ /**
+ * For the use of serialization.
+ * @return the table member of update operation
+ */
+ @JsonProperty
+ public String getTable() {
+ return tableSchema.name();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Insert.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Insert.java
new file mode 100644
index 00000000..8545b43a
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Insert.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.ovsdb.rfc.operations;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+import org.onosproject.ovsdb.rfc.utils.TransValueUtil;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.Maps;
+
+/**
+ * insert operation.Refer to RFC 7047 Section 5.2.
+ */
+public final class Insert implements Operation {
+
+ @JsonIgnore
+ private final TableSchema tableSchema;
+ private final String op;
+ @JsonProperty("uuid-name")
+ private final String uuidName;
+ private final Map<String, Object> row;
+
+ /**
+ * Constructs a Insert object.
+ * @param schema TableSchema entity
+ * @param uuidName uuid-name
+ * @param row Row entity
+ */
+ public Insert(TableSchema schema, String uuidName, Row row) {
+ checkNotNull(schema, "TableSchema cannot be null");
+ checkNotNull(uuidName, "uuid name cannot be null");
+ checkNotNull(row, "row cannot be null");
+ this.tableSchema = schema;
+ this.op = Operations.INSERT.op();
+ this.uuidName = uuidName;
+ this.row = Maps.newHashMap();
+ generateOperationRow(row);
+ }
+
+ /**
+ * Row entity convert into the row format of insert operation. Refer to RFC
+ * 7047 Section 5.2.
+ * @param row Row entity
+ */
+ private void generateOperationRow(Row row) {
+ Collection<Column> columns = row.getColumns();
+ for (Column column : columns) {
+ String columnName = column.columnName();
+ Object value = column.data();
+ Object formatValue = TransValueUtil.getFormatData(value);
+ this.row.put(columnName, formatValue);
+ }
+ }
+
+ /**
+ * Returns the uuid-name member of insert operation.
+ * @return the uuid-name member of insert operation
+ */
+ public String getUuidName() {
+ return uuidName;
+ }
+
+ /**
+ * Returns the row member of insert operation.
+ * @return the row member of insert operation
+ */
+ public Map<String, Object> getRow() {
+ return row;
+ }
+
+ @Override
+ public String getOp() {
+ return op;
+ }
+
+ @Override
+ public TableSchema getTableSchema() {
+ return tableSchema;
+ }
+
+ /**
+ * For the use of serialization.
+ * @return the table member of update operation
+ */
+ @JsonProperty
+ public String getTable() {
+ return tableSchema.name();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Mutate.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Mutate.java
new file mode 100644
index 00000000..b2827797
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Mutate.java
@@ -0,0 +1,91 @@
+/*
+ * 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.ovsdb.rfc.operations;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+import org.onosproject.ovsdb.rfc.notation.Condition;
+import org.onosproject.ovsdb.rfc.notation.Mutation;
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * mutate operation.Refer to RFC 7047 Section 5.2.
+ */
+public final class Mutate implements Operation {
+
+ @JsonIgnore
+ private final TableSchema tableSchema;
+ private final String op;
+ private final List<Condition> where;
+ private final List<Mutation> mutations;
+
+ /**
+ * Constructs a Mutate object.
+ * @param schema TableSchema entity
+ * @param where the List of Condition entity
+ * @param mutations the List of Mutation entity
+ */
+ public Mutate(TableSchema schema, List<Condition> where,
+ List<Mutation> mutations) {
+ checkNotNull(schema, "TableSchema cannot be null");
+ checkNotNull(mutations, "mutations cannot be null");
+ checkNotNull(where, "where cannot be null");
+ this.tableSchema = schema;
+ this.op = Operations.MUTATE.op();
+ this.where = where;
+ this.mutations = mutations;
+ }
+
+ /**
+ * Returns the mutations member of mutate operation.
+ * @return the mutations member of mutate operation
+ */
+ public List<Mutation> getMutations() {
+ return mutations;
+ }
+
+ /**
+ * Returns the where member of mutate operation.
+ * @return the where member of mutate operation
+ */
+ public List<Condition> getWhere() {
+ return where;
+ }
+
+ @Override
+ public String getOp() {
+ return op;
+ }
+
+ @Override
+ public TableSchema getTableSchema() {
+ return tableSchema;
+ }
+
+ /**
+ * For the use of serialization.
+ * @return the table member of update operation
+ */
+ @JsonProperty
+ public String getTable() {
+ return tableSchema.name();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Operation.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Operation.java
new file mode 100644
index 00000000..3e2dff1f
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Operation.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.ovsdb.rfc.operations;
+
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+
+/**
+ * Operation interface.
+ */
+public interface Operation {
+
+ /**
+ * Returns the op member of update operation.
+ * @return the op member of update operation
+ */
+ String getOp();
+
+ /**
+ * Returns TableSchema entity.
+ * @return TableSchema entity
+ */
+ TableSchema getTableSchema();
+
+ /**
+ * Operations must be "insert", "select", "update", "mutate", "delete",
+ * "commit", "abort", "comment", "assert". Refer to RFC 7047 Section 5.2.
+ */
+ public enum Operations {
+ INSERT("insert"), SELECT("select"), UPDATE("update"), MUTATE("mutate"),
+ DELETE("delete"), COMMIT("commit"), ABORT("abort"), COMMENT("comment"),
+ ASSERT("assert");
+
+ private String op;
+
+ private Operations(String op) {
+ this.op = op;
+ }
+
+ /**
+ * Returns the op for Operations.
+ * @return the op
+ */
+ public String op() {
+ return op;
+ }
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Select.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Select.java
new file mode 100644
index 00000000..ba1ec74f
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Select.java
@@ -0,0 +1,89 @@
+/*
+ * 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.ovsdb.rfc.operations;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+import org.onosproject.ovsdb.rfc.notation.Condition;
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * select operation.Refer to RFC 7047 Section 5.2.
+ */
+public final class Select implements Operation {
+
+ @JsonIgnore
+ private final TableSchema tableSchema;
+ private final String op;
+ private final List<Condition> where;
+ private final List<String> columns;
+
+ /**
+ * Constructs a Select object.
+ * @param schema TableSchema entity
+ * @param where the List of Condition entity
+ * @param columns the List of column name
+ */
+ public Select(TableSchema schema, List<Condition> where, List<String> columns) {
+ checkNotNull(schema, "TableSchema cannot be null");
+ checkNotNull(where, "where cannot be null");
+ checkNotNull(columns, "columns cannot be null");
+ this.tableSchema = schema;
+ this.op = Operations.SELECT.op();
+ this.where = where;
+ this.columns = columns;
+ }
+
+ /**
+ * Returns the columns member of select operation.
+ * @return the columns member of select operation
+ */
+ public List<String> getColumns() {
+ return columns;
+ }
+
+ /**
+ * Returns the where member of select operation.
+ * @return the where member of select operation
+ */
+ public List<Condition> getWhere() {
+ return where;
+ }
+
+ @Override
+ public String getOp() {
+ return op;
+ }
+
+ @Override
+ public TableSchema getTableSchema() {
+ return tableSchema;
+ }
+
+ /**
+ * For the use of serialization.
+ * @return the table member of update operation
+ */
+ @JsonProperty
+ public String getTable() {
+ return tableSchema.name();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Update.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Update.java
new file mode 100644
index 00000000..81a1cab1
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/Update.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.ovsdb.rfc.operations;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Condition;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+import org.onosproject.ovsdb.rfc.utils.TransValueUtil;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.collect.Maps;
+
+/**
+ * update operation.Refer to RFC 7047 Section 5.2.
+ */
+public final class Update implements Operation {
+
+ @JsonIgnore
+ private final TableSchema tableSchema;
+ private final String op;
+ private final Map<String, Object> row;
+ private final List<Condition> where;
+
+ /**
+ * Constructs a Update object.
+ * @param schema TableSchema entity
+ * @param row Row entity
+ * @param where the List of Condition entity
+ */
+ public Update(TableSchema schema, Row row, List<Condition> where) {
+ checkNotNull(schema, "TableSchema cannot be null");
+ checkNotNull(row, "row cannot be null");
+ checkNotNull(where, "where cannot be null");
+ this.tableSchema = schema;
+ this.op = Operations.UPDATE.op();
+ this.row = Maps.newHashMap();
+ this.where = where;
+ generateOperationRow(row);
+ }
+
+ /**
+ * Row entity convert into the row format of update operation. Refer to RFC
+ * 7047 Section 5.2.
+ * @param row Row entity
+ */
+ private void generateOperationRow(Row row) {
+ Collection<Column> columns = row.getColumns();
+ for (Column column : columns) {
+ String columnName = column.columnName();
+ Object value = column.data();
+ Object formatValue = TransValueUtil.getFormatData(value);
+ this.row.put(columnName, formatValue);
+ }
+ }
+
+ /**
+ * Returns the row member of update operation.
+ * @return the row member of update operation
+ */
+ public Map<String, Object> getRow() {
+ return row;
+ }
+
+ /**
+ * Returns the where member of update operation.
+ * @return the where member of update operation
+ */
+ public List<Condition> getWhere() {
+ return where;
+ }
+
+ @Override
+ public String getOp() {
+ return op;
+ }
+
+ @Override
+ public TableSchema getTableSchema() {
+ return tableSchema;
+ }
+
+ /**
+ * For the use of serialization.
+ * @return the table member of update operation
+ */
+ @JsonProperty
+ public String getTable() {
+ return tableSchema.name();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/package-info.java
new file mode 100644
index 00000000..77fb9f3c
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/operations/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.
+ */
+
+/**
+ * OVSDB operations.
+ */
+package org.onosproject.ovsdb.rfc.operations;
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/ColumnSchema.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/ColumnSchema.java
new file mode 100644
index 00000000..23eb2be7
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/ColumnSchema.java
@@ -0,0 +1,83 @@
+/*
+ * 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.ovsdb.rfc.schema;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.ovsdb.rfc.schema.type.ColumnType;
+
+/**
+ * A schema for the column represented by column-schema.
+ */
+public final class ColumnSchema {
+ private final String name;
+ private final ColumnType type;
+
+ /**
+ * Constructs a ColumnSchema object.
+ * @param name the column name
+ * @param columnType the column type
+ */
+ public ColumnSchema(String name, ColumnType columnType) {
+ checkNotNull(name, "name cannot be null");
+ checkNotNull(columnType, "column type cannot be null");
+ this.name = name;
+ this.type = columnType;
+ }
+
+ /**
+ * Returns the name of column.
+ * @return the name of column
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * Returns the type of column.
+ * @return the type of column
+ */
+ public ColumnType type() {
+ return type;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, type);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof ColumnSchema) {
+ final ColumnSchema other = (ColumnSchema) obj;
+ return Objects.equals(this.name, other.name)
+ && Objects.equals(this.type, other.type);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("name", name).add("type", type)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/DatabaseSchema.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/DatabaseSchema.java
new file mode 100644
index 00000000..298afc68
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/DatabaseSchema.java
@@ -0,0 +1,135 @@
+/*
+ * 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.ovsdb.rfc.schema;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * A schema for the database represented by database-schema, which consists of
+ * a set of tables.
+ */
+public final class DatabaseSchema {
+
+ private final String name;
+ private final String version;
+ private final Map<String, TableSchema> tableSchemas;
+
+ /**
+ * Constructs a DatabaseSchema object.
+ * @param name the name of database
+ * @param version the version of database
+ * @param tableSchemas a map of TableSchema
+ */
+ public DatabaseSchema(String name, String version,
+ Map<String, TableSchema> tableSchemas) {
+ checkNotNull(name, "name cannot be null");
+ checkNotNull(version, "version cannot be null");
+ checkNotNull(tableSchemas, "tableSchemas cannot be null");
+ this.name = name;
+ this.version = version;
+ this.tableSchemas = tableSchemas;
+ }
+
+ /**
+ * Returns the name of database.
+ * @return the name of database
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * Returns the version of database.
+ * @return the version of database
+ */
+ public String version() {
+ return version;
+ }
+
+ /**
+ * Returns a map of TableSchema.
+ * @return a map of TableSchema
+ */
+ public Map<String, TableSchema> tableSchemas() {
+ return tableSchemas;
+ }
+
+ /**
+ * Returns a set of table name.
+ * @return a set of table name
+ */
+ public Set<String> getTableNames() {
+ return this.tableSchemas.keySet();
+ }
+
+ /**
+ * Determine whether contain the table.
+ * @param tableName table name
+ * @return boolean
+ */
+ public boolean hasTable(String tableName) {
+ return this.getTableNames().contains(tableName);
+ }
+
+ /**
+ * Returns the TableSchema whose name is the tableName.
+ * @param tableName table name
+ * @return TableSchema
+ */
+ public TableSchema getTableSchema(String tableName) {
+ TableSchema table = tableSchemas.get(tableName);
+ return table;
+ }
+
+ /**
+ * generate initialization columns in each table namely _uuid and _version.
+ */
+ public void generateInitializationColumns() {
+ for (TableSchema tableSchema : tableSchemas.values()) {
+ tableSchema.generateInitializationColumns();
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, version, tableSchemas);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DatabaseSchema) {
+ final DatabaseSchema other = (DatabaseSchema) obj;
+ return Objects.equals(this.name, other.name)
+ && Objects.equals(this.version, other.version)
+ && Objects.equals(this.tableSchemas, other.tableSchemas);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("name", name).add("version", version)
+ .add("tableSchemas", tableSchemas).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/TableSchema.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/TableSchema.java
new file mode 100644
index 00000000..248745dd
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/TableSchema.java
@@ -0,0 +1,129 @@
+/*
+ * 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.ovsdb.rfc.schema;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.schema.type.AtomicColumnType;
+import org.onosproject.ovsdb.rfc.schema.type.UuidBaseType;
+
+/**
+ * A schema for the table represented by table-schema, which consists of a set
+ * of columns.
+ */
+public final class TableSchema {
+
+ private final String name;
+ private final Map<String, ColumnSchema> columnSchemas;
+
+ /**
+ * Constructs a TableSchema object.
+ * @param name the name of table
+ * @param columnSchemas a map of ColumnSchema
+ */
+ public TableSchema(String name, Map<String, ColumnSchema> columnSchemas) {
+ checkNotNull(name, "name cannot be null");
+ checkNotNull(columnSchemas, "columnSchemas cannot be null");
+ this.name = name;
+ this.columnSchemas = columnSchemas;
+ }
+
+ /**
+ * Returns the name of table.
+ * @return the name of table
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * Returns a map of ColumnSchema.
+ * @return a map of ColumnSchema
+ */
+ public Map<String, ColumnSchema> columnSchemas() {
+ return this.columnSchemas;
+ }
+
+ /**
+ * Returns a set of column name.
+ * @return a set of column name
+ */
+ public Set<String> getColumnNames() {
+ return this.columnSchemas.keySet();
+ }
+
+ /**
+ * Determine whether contain the column.
+ * @param columnName column name
+ * @return boolean
+ */
+ public boolean hasColumn(String columnName) {
+ return this.getColumnNames().contains(columnName);
+ }
+
+ /**
+ * Returns the ColumnSchema whose name is the columnName.
+ * @param columnName column name
+ * @return ColumnSchema
+ */
+ public ColumnSchema getColumnSchema(String columnName) {
+ return this.columnSchemas.get(columnName);
+ }
+
+ /**
+ * Refer to RFC 7047 Section 3.2. generate initialization columns in each
+ * table namely _uuid and _version.
+ */
+ public void generateInitializationColumns() {
+ columnSchemas
+ .put("_uuid",
+ new ColumnSchema("_uuid",
+ new AtomicColumnType(new UuidBaseType())));
+ columnSchemas
+ .put("_version",
+ new ColumnSchema("_version",
+ new AtomicColumnType(new UuidBaseType())));
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, columnSchemas);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TableSchema) {
+ final TableSchema other = (TableSchema) obj;
+ return Objects.equals(this.name, other.name)
+ && Objects.equals(this.columnSchemas, other.columnSchemas);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("name", name)
+ .add("columnSchemas", columnSchemas).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/package-info.java
new file mode 100644
index 00000000..9a27037c
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/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.
+ */
+
+/**
+ * OVSDB schema.
+ */
+package org.onosproject.ovsdb.rfc.schema;
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/AtomicColumnType.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/AtomicColumnType.java
new file mode 100644
index 00000000..881755ae
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/AtomicColumnType.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.ovsdb.rfc.schema.type;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * The "atomic-type" specifies the type of data stored in this column. Refer
+ * to RFC 7047 Section 3.2.
+ */
+public final class AtomicColumnType implements ColumnType {
+ private final BaseType baseType;
+ private final int min;
+ private final int max;
+
+ /**
+ * Constructs a AtomicColumnType object.
+ * @param baseType BaseType entity
+ */
+ public AtomicColumnType(BaseType baseType) {
+ checkNotNull(baseType, "BaseType cannot be null");
+ this.baseType = baseType;
+ this.min = 1;
+ this.max = 1;
+ }
+
+ /**
+ * Constructs a AtomicColumnType object.
+ * @param baseType BaseType entity
+ * @param min min constraint
+ * @param max max constraint
+ */
+ public AtomicColumnType(BaseType baseType, int min, int max) {
+ checkNotNull(baseType, "BaseType cannot be null");
+ this.baseType = baseType;
+ this.min = min;
+ this.max = max;
+ }
+
+ /**
+ * Get baseType.
+ * @return baseType
+ */
+ public BaseType baseType() {
+ return baseType;
+ }
+
+ /**
+ * Get min.
+ * @return min
+ */
+ public int min() {
+ return min;
+ }
+
+ /**
+ * Get max.
+ * @return max
+ */
+ public int max() {
+ return max;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(baseType, min, max);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof AtomicColumnType) {
+ final AtomicColumnType other = (AtomicColumnType) obj;
+ return Objects.equals(this.baseType, other.baseType)
+ && Objects.equals(this.min, other.min)
+ && Objects.equals(this.max, other.max);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("baseType", baseType).add("min", min)
+ .add("max", max).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseType.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseType.java
new file mode 100644
index 00000000..d2614c12
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseType.java
@@ -0,0 +1,24 @@
+/*
+ * 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.ovsdb.rfc.schema.type;
+
+/**
+ * One of the strings "integer", "real", "boolean", "string", or "uuid",
+ * representing the specified scalar type. Refer to RFC 7047 Section 3.2.
+ */
+public interface BaseType {
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseTypeFactory.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseTypeFactory.java
new file mode 100644
index 00000000..86dbb2e6
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BaseTypeFactory.java
@@ -0,0 +1,214 @@
+/*
+ * 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.ovsdb.rfc.schema.type;
+
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.exception.AbnormalJsonNodeException;
+import org.onosproject.ovsdb.rfc.schema.type.UuidBaseType.RefType;
+import org.onosproject.ovsdb.rfc.utils.ObjectMapperUtil;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Sets;
+
+/**
+ * BaseType Factory class.
+ */
+public final class BaseTypeFactory {
+
+ /**
+ * Constructs a BaseTypeFactory object. This class should not be
+ * instantiated.
+ */
+ private BaseTypeFactory() {
+ }
+
+ /**
+ * Create a BaseType from the JsonNode.
+ * @param baseTypeJson the BaseType JsonNode
+ * @param keyorval the key node or value node
+ * @return BaseType
+ */
+ public static BaseType getBaseTypeFromJson(JsonNode baseTypeJson, String keyorval) {
+ if (baseTypeJson.isValueNode()) {
+ String type = baseTypeJson.asText().trim();
+ return fromTypeStr(type);
+ } else {
+ if (!baseTypeJson.has(keyorval)) {
+ String message = "Abnormal BaseType JsonNode, it should contain 'key' or 'value' node but was not found"
+ + ObjectMapperUtil.convertToString(baseTypeJson);
+ throw new AbnormalJsonNodeException(message);
+ }
+ return fromJsonNode(baseTypeJson.get(keyorval));
+ }
+ }
+
+ /**
+ * Get BaseType by the type value of JsonNode.
+ * @param type the type value of JsonNode
+ * @return BaseType
+ */
+ private static BaseType fromTypeStr(String type) {
+ switch (type) {
+ case "boolean":
+ return new BooleanBaseType();
+ case "integer":
+ return new IntegerBaseType();
+ case "real":
+ return new RealBaseType();
+ case "string":
+ return new StringBaseType();
+ case "uuid":
+ return new UuidBaseType();
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * json like "string" or json like {"type" : "string", "enum": ["set",
+ * ["access", "native-tagged"]]}" for key or value.
+ * @param type JsonNode
+ */
+ private static BaseType fromJsonNode(JsonNode type) {
+ if (type.isTextual()) {
+ return fromTypeStr(type.asText());
+ } else if (type.isObject() && type.has("type")) {
+ String typeStr = type.get("type").asText();
+ switch (typeStr) {
+ case "boolean":
+ return new BooleanBaseType();
+ case "integer":
+ return getIntegerBaseType(type);
+ case "real":
+ return getRealBaseType(type);
+ case "string":
+ return getStringBaseType(type);
+ case "uuid":
+ return getUuidBaseType(type);
+ default:
+ return null;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get IntegerBaseType by the type value of JsonNode which contains the
+ * constraints.
+ * @param type the type value of JsonNode
+ * @return IntegerBaseType
+ */
+ private static IntegerBaseType getIntegerBaseType(JsonNode type) {
+ int min = Integer.MIN_VALUE;
+ int max = Integer.MAX_VALUE;
+ Set<Integer> enums = Sets.newHashSet();
+ JsonNode node = type.get("minInteger");
+ if (node != null) {
+ min = node.asInt();
+ }
+ node = type.get("maxInteger");
+ if (node != null) {
+ max = node.asInt();
+ }
+ if (type.has("enum")) {
+ JsonNode anEnum = type.get("enum").get(1);
+ for (JsonNode n : anEnum) {
+ enums.add(n.asInt());
+ }
+ }
+ return new IntegerBaseType(min, max, enums);
+ }
+
+ /**
+ * Get RealBaseType by the type value of JsonNode which contains the
+ * constraints.
+ * @param type the type value of JsonNode
+ * @return RealBaseType
+ */
+ private static RealBaseType getRealBaseType(JsonNode type) {
+ double min = Double.MIN_VALUE;
+ double max = Double.MAX_VALUE;
+ Set<Double> enums = Sets.newHashSet();
+ JsonNode node = type.get("minReal");
+ if (node != null) {
+ min = node.asDouble();
+ }
+ node = type.get("maxReal");
+ if (node != null) {
+ max = node.asDouble();
+ }
+ if (type.has("enum")) {
+ JsonNode anEnum = type.get("enum").get(1);
+ for (JsonNode n : anEnum) {
+ enums.add(n.asDouble());
+ }
+ }
+ return new RealBaseType(min, max, enums);
+ }
+
+ /**
+ * Get StringBaseType by the type value of JsonNode which contains the
+ * constraints.
+ * @param type the type value of JsonNode
+ * @return StringBaseType
+ */
+ private static StringBaseType getStringBaseType(JsonNode type) {
+ int minLength = Integer.MIN_VALUE;
+ int maxLength = Integer.MAX_VALUE;
+ Set<String> enums = Sets.newHashSet();
+ JsonNode node = type.get("minLength");
+ if (node != null) {
+ minLength = node.asInt();
+ }
+ node = type.get("maxLength");
+ if (node != null) {
+ maxLength = node.asInt();
+ }
+ if (type.has("enum")) {
+ JsonNode enumVal = type.get("enum");
+ if (enumVal.isArray()) {
+ JsonNode anEnum = enumVal.get(1);
+ for (JsonNode n : anEnum) {
+ enums.add(n.asText());
+ }
+ } else if (enumVal.isTextual()) {
+ enums.add(enumVal.asText());
+ }
+ }
+ return new StringBaseType(minLength, maxLength, enums);
+ }
+
+ /**
+ * Get UuidBaseType by the type value of JsonNode which contains the
+ * constraints.
+ * @param type the type value of JsonNode
+ * @return UuidBaseType
+ */
+ private static UuidBaseType getUuidBaseType(JsonNode type) {
+ String refTable = null;
+ String refType = RefType.STRONG.refType();
+ JsonNode node = type.get("refTable");
+ if (node != null) {
+ refTable = node.asText();
+ }
+ node = type.get("refType");
+ if (node != null) {
+ refType = node.asText();
+ }
+ return new UuidBaseType(refTable, refType);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BooleanBaseType.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BooleanBaseType.java
new file mode 100644
index 00000000..d42337a5
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/BooleanBaseType.java
@@ -0,0 +1,33 @@
+/*
+ * 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.ovsdb.rfc.schema.type;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * One of the strings "integer", "real", "boolean", "string", or "uuid",
+ * representing the specified scalar type. Refer to RFC 7047 Section 3.2.
+ * Because BooleanBaseType has no constraint conditions, and in order to be
+ * consistent with other BaseType, so this class is empty except for the
+ * toString method.
+ */
+public final class BooleanBaseType implements BaseType {
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnType.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnType.java
new file mode 100644
index 00000000..20f1bbac
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnType.java
@@ -0,0 +1,24 @@
+/*
+ * 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.ovsdb.rfc.schema.type;
+
+/**
+ * The "type" specifies the type of data stored in this column. Refer to RFC
+ * 7047 Section 3.2.
+ */
+public interface ColumnType {
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnTypeFactory.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnTypeFactory.java
new file mode 100644
index 00000000..47b34a6b
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/ColumnTypeFactory.java
@@ -0,0 +1,123 @@
+/*
+ * 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.ovsdb.rfc.schema.type;
+
+import org.onosproject.ovsdb.rfc.exception.AbnormalJsonNodeException;
+import org.onosproject.ovsdb.rfc.utils.ObjectMapperUtil;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+/**
+ * ColumnType Factory class.
+ */
+public final class ColumnTypeFactory {
+
+ /**
+ * Constructs a ColumnTypeFactory object. This class should not be
+ * instantiated.
+ */
+ private ColumnTypeFactory() {
+ }
+
+ /**
+ * Those Json's key/value pairs.
+ */
+ public enum Type {
+ KEY("key"), VALUE("value");
+
+ private final String type;
+
+ private Type(String type) {
+ this.type = type;
+ }
+
+ /**
+ * Returns the type for Type.
+ * @return the type
+ */
+ public String type() {
+ return type;
+ }
+ }
+
+ /**
+ * JsonNode like
+ * "flow_tables":{"type":{"key":{"maxInteger":254,"minInteger":0,"type":
+ * "integer"},"min":0,"value":{"type":"uuid","refTable":"Flow_Table"},"max":
+ * "unlimited"}}.
+ * @param columnTypeJson the ColumnType JsonNode
+ * @return ColumnType
+ */
+ public static ColumnType getColumnTypeFromJson(JsonNode columnTypeJson) {
+ if (!columnTypeJson.isObject() || !columnTypeJson.has(Type.VALUE.type())) {
+ return createAtomicColumnType(columnTypeJson);
+ } else if (!columnTypeJson.isValueNode() && columnTypeJson.has(Type.VALUE.type())) {
+ return createKeyValuedColumnType(columnTypeJson);
+ }
+ String message = "Abnormal ColumnType JsonNode, it should be AtomicColumnType or KeyValuedColumnType"
+ + ObjectMapperUtil.convertToString(columnTypeJson);
+ throw new AbnormalJsonNodeException(message);
+ }
+
+ /**
+ * Create AtomicColumnType entity.
+ * @param json JsonNode
+ * @return AtomicColumnType entity
+ */
+ private static AtomicColumnType createAtomicColumnType(JsonNode json) {
+ BaseType baseType = BaseTypeFactory.getBaseTypeFromJson(json, Type.KEY.type());
+ int min = 1;
+ int max = 1;
+ JsonNode node = json.get("min");
+ if (node != null && node.isNumber()) {
+ min = node.asInt();
+ }
+ node = json.get("max");
+ if (node != null) {
+ if (node.isNumber()) {
+ max = node.asInt();
+ } else if (node.isTextual() && "unlimited".equals(node.asText())) {
+ max = Integer.MAX_VALUE;
+ }
+ }
+ return new AtomicColumnType(baseType, min, max);
+ }
+
+ /**
+ * Create KeyValuedColumnType entity.
+ * @param json JsonNode
+ * @return KeyValuedColumnType entity
+ */
+ private static KeyValuedColumnType createKeyValuedColumnType(JsonNode json) {
+ BaseType keyType = BaseTypeFactory.getBaseTypeFromJson(json, Type.KEY.type());
+ BaseType valueType = BaseTypeFactory.getBaseTypeFromJson(json, Type.VALUE.type());
+ int min = 1;
+ int max = 1;
+ JsonNode node = json.get("min");
+ if (node != null && node.isNumber()) {
+ min = node.asInt();
+ }
+ node = json.get("max");
+ if (node != null) {
+ if (node.isNumber()) {
+ max = node.asInt();
+ } else if (node.isTextual() && "unlimited".equals(node.asText())) {
+ max = Integer.MAX_VALUE;
+ }
+ }
+ return new KeyValuedColumnType(keyType, valueType, min, max);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/IntegerBaseType.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/IntegerBaseType.java
new file mode 100644
index 00000000..91939515
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/IntegerBaseType.java
@@ -0,0 +1,103 @@
+/*
+ * 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.ovsdb.rfc.schema.type;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+import java.util.Set;
+
+import com.google.common.collect.Sets;
+
+/**
+ * One of the strings "integer", "real", "boolean", "string", or "uuid",
+ * representing the specified scalar type. Refer to RFC 7047 Section 3.2.
+ */
+public final class IntegerBaseType implements BaseType {
+ private final int min;
+ private final int max;
+ private final Set<Integer> enums;
+
+ /**
+ * Constructs a IntegerBaseType object.
+ */
+ public IntegerBaseType() {
+ this.min = Integer.MIN_VALUE;
+ this.max = Integer.MAX_VALUE;
+ this.enums = Sets.newHashSet();
+ }
+
+ /**
+ * Constructs a IntegerBaseType object.
+ * @param min min constraint
+ * @param max max constraint
+ * @param enums enums constraint
+ */
+ public IntegerBaseType(int min, int max, Set<Integer> enums) {
+ this.min = min;
+ this.max = max;
+ this.enums = enums;
+ }
+
+ /**
+ * Get min.
+ * @return min
+ */
+ public int min() {
+ return min;
+ }
+
+ /**
+ * Get max.
+ * @return max
+ */
+ public int max() {
+ return max;
+ }
+
+ /**
+ * Get enums.
+ * @return enums
+ */
+ public Set<Integer> enums() {
+ return enums;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(min, max, enums);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IntegerBaseType) {
+ final IntegerBaseType other = (IntegerBaseType) obj;
+ return Objects.equals(this.enums, other.enums)
+ && Objects.equals(this.min, other.min)
+ && Objects.equals(this.max, other.max);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("min", min).add("max", max)
+ .add("enums", enums).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/KeyValuedColumnType.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/KeyValuedColumnType.java
new file mode 100644
index 00000000..8407457a
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/KeyValuedColumnType.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.ovsdb.rfc.schema.type;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * a JSON object that describes the type of a database column, with key and
+ * value. Refer to RFC 7047 Section 3.2.
+ */
+public final class KeyValuedColumnType implements ColumnType {
+ private final BaseType keyType;
+ private final BaseType valueType;
+ private final int min;
+ private final int max;
+
+ /**
+ * Constructs a KeyValuedColumnType object.
+ * @param keyType BaseType entity
+ * @param valueType BaseType entity
+ * @param min min constraint
+ * @param max max constraint
+ */
+ public KeyValuedColumnType(BaseType keyType, BaseType valueType, int min,
+ int max) {
+ checkNotNull(keyType, "keyType cannot be null");
+ checkNotNull(valueType, "valueType cannot be null");
+ this.keyType = keyType;
+ this.valueType = valueType;
+ this.min = min;
+ this.max = max;
+ }
+
+ /**
+ * Get keyType.
+ * @return keyType
+ */
+ public BaseType keyType() {
+ return keyType;
+ }
+
+ /**
+ * Get valueType.
+ * @return valueType
+ */
+ public BaseType valueType() {
+ return valueType;
+ }
+
+ /**
+ * Get min.
+ * @return min
+ */
+ public int min() {
+ return min;
+ }
+
+ /**
+ * Get max.
+ * @return max
+ */
+ public int max() {
+ return max;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(keyType, valueType, min, max);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof KeyValuedColumnType) {
+ final KeyValuedColumnType other = (KeyValuedColumnType) obj;
+ return Objects.equals(this.keyType, other.keyType)
+ && Objects.equals(this.valueType, other.valueType)
+ && Objects.equals(this.min, other.min)
+ && Objects.equals(this.max, other.max);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("keyType", keyType)
+ .add("valueType", valueType).add("min", min).add("max", max)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/RealBaseType.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/RealBaseType.java
new file mode 100644
index 00000000..6704e30a
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/RealBaseType.java
@@ -0,0 +1,103 @@
+/*
+ * 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.ovsdb.rfc.schema.type;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+import java.util.Set;
+
+import com.google.common.collect.Sets;
+
+/**
+ * One of the strings "integer", "real", "boolean", "string", or "uuid",
+ * representing the specified scalar type. Refer to RFC 7047 Section 3.2.
+ */
+public final class RealBaseType implements BaseType {
+ private final double min;
+ private final double max;
+ private final Set<Double> enums;
+
+ /**
+ * Constructs a RealBaseType object.
+ */
+ public RealBaseType() {
+ this.min = Double.MIN_VALUE;
+ this.max = Double.MAX_VALUE;
+ this.enums = Sets.newHashSet();
+ }
+
+ /**
+ * Constructs a RealBaseType object.
+ * @param min min constraint
+ * @param max max constraint
+ * @param enums enums constraint
+ */
+ public RealBaseType(double min, double max, Set<Double> enums) {
+ this.min = min;
+ this.max = max;
+ this.enums = enums;
+ }
+
+ /**
+ * Get min.
+ * @return min
+ */
+ public double getMin() {
+ return min;
+ }
+
+ /**
+ * Get max.
+ * @return max
+ */
+ public double getMax() {
+ return max;
+ }
+
+ /**
+ * Get enums.
+ * @return enums
+ */
+ public Set<Double> getEnums() {
+ return enums;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(min, max, enums);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof RealBaseType) {
+ final RealBaseType other = (RealBaseType) obj;
+ return Objects.equals(this.enums, other.enums)
+ && Objects.equals(this.min, other.min)
+ && Objects.equals(this.max, other.max);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("min", min).add("max", max)
+ .add("enums", enums).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/StringBaseType.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/StringBaseType.java
new file mode 100644
index 00000000..96d2f739
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/StringBaseType.java
@@ -0,0 +1,103 @@
+/*
+ * 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.ovsdb.rfc.schema.type;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+import java.util.Set;
+
+import com.google.common.collect.Sets;
+
+/**
+ * One of the strings "integer", "real", "boolean", "string", or "uuid",
+ * representing the specified scalar type. Refer to RFC 7047 Section 3.2.
+ */
+public final class StringBaseType implements BaseType {
+ private final int minLength;
+ private final int maxLength;
+ private final Set<String> enums;
+
+ /**
+ * Constructs a StringBaseType object.
+ */
+ public StringBaseType() {
+ this.minLength = Integer.MIN_VALUE;
+ this.maxLength = Integer.MAX_VALUE;
+ this.enums = Sets.newHashSet();
+ }
+
+ /**
+ * Constructs a StringBaseType object.
+ * @param minLength minLength constraint
+ * @param maxLength maxLength constraint
+ * @param enums enums constraint
+ */
+ public StringBaseType(int minLength, int maxLength, Set<String> enums) {
+ this.minLength = minLength;
+ this.maxLength = maxLength;
+ this.enums = enums;
+ }
+
+ /**
+ * Get minLength.
+ * @return minLength
+ */
+ public int getMinLength() {
+ return minLength;
+ }
+
+ /**
+ * Get maxLength.
+ * @return maxLength
+ */
+ public int getMaxLength() {
+ return maxLength;
+ }
+
+ /**
+ * Get enums.
+ * @return enums
+ */
+ public Set<String> getEnums() {
+ return enums;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(minLength, maxLength, enums);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof StringBaseType) {
+ final StringBaseType other = (StringBaseType) obj;
+ return Objects.equals(this.enums, other.enums)
+ && Objects.equals(this.minLength, other.minLength)
+ && Objects.equals(this.maxLength, other.maxLength);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("minLength", minLength)
+ .add("maxLength", maxLength).add("enums", enums).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/UuidBaseType.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/UuidBaseType.java
new file mode 100644
index 00000000..46e0d9fa
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/UuidBaseType.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.ovsdb.rfc.schema.type;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * One of the strings "integer", "real", "boolean", "string", or "uuid",
+ * representing the specified scalar type. Refer to RFC 7047 Section 3.2.
+ */
+public final class UuidBaseType implements BaseType {
+ /**
+ * RefType is strong or weak. refer to base-type of RFC 7047 Section 3.2.
+ */
+ public enum RefType {
+ STRONG("strong"), WEAK("weak");
+
+ private String refType;
+
+ private RefType(String refType) {
+ this.refType = refType;
+ }
+
+ /**
+ * Returns the refType for RefType.
+ * @return the refType
+ */
+ public String refType() {
+ return refType;
+ }
+ }
+
+ private final String refTable;
+ private final String refType;
+
+ /**
+ * Constructs a UuidBaseType object.
+ */
+ public UuidBaseType() {
+ this.refTable = null;
+ this.refType = RefType.STRONG.refType();
+ }
+
+ /**
+ * Constructs a UuidBaseType object.
+ * @param refTable refTable constraint
+ * @param refType refType constraint
+ */
+ public UuidBaseType(String refTable, String refType) {
+ checkNotNull(refType, "refType cannot be null");
+ this.refTable = refTable;
+ this.refType = refType;
+ }
+
+ /**
+ * Get refTable.
+ * @return refTable
+ */
+ public String getRefTable() {
+ return refTable;
+ }
+
+ /**
+ * Get refType.
+ * @return refType
+ */
+ public String getRefType() {
+ return refType;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(refTable, refType);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof UuidBaseType) {
+ final UuidBaseType other = (UuidBaseType) obj;
+ return Objects.equals(this.refTable, other.refTable)
+ && Objects.equals(this.refType, other.refType);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("refTable", refTable)
+ .add("refType", refType).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/package-info.java
new file mode 100644
index 00000000..eade2e28
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/schema/type/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.
+ */
+
+/**
+ * OVSDB schema types.
+ */
+package org.onosproject.ovsdb.rfc.schema.type;
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Bridge.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Bridge.java
new file mode 100644
index 00000000..0b5ffeff
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Bridge.java
@@ -0,0 +1,560 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.OvsdbSet;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This class provides operations of Bridge Table.
+ */
+public class Bridge extends AbstractOvsdbTableService {
+
+ /**
+ * Bridge table column name.
+ */
+ public enum BridgeColumn {
+ NAME("name"), DATAPATHTYPE("datapath_type"), DATAPATHID("datapath_id"),
+ STPENABLE("stpenable"), PORTS("ports"), MIRRORS("mirrors"),
+ NETFLOW("netflow"), SFLOW("sflow"), IPFIX("ipfix"),
+ CONTROLLER("controller"), PROTOCOLS("protocols"),
+ FAILMODE("fail_mode"), STATUS("status"), OTHERCONFIG("other_config"),
+ EXTERNALIDS("external_ids"), FLOODVLANS("flood_vlans"),
+ FLOWTABLES("flow_tables");
+
+ private final String columnName;
+
+ private BridgeColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for BridgeColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Bridge object. Generate Bridge Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Bridge(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.BRIDGE, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "name" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "name"
+ */
+ public Column getNameColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.NAME
+ .columnName(),
+ "getNameColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "name" to the Row entity of
+ * attributes.
+ * @param name the column data which column name is "name"
+ */
+ public void setName(String name) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.NAME
+ .columnName(),
+ "setName",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, name);
+ }
+
+ /**
+ * Get the column data which column name is "name" from the Row entity of
+ * attributes.
+ * @return the column data which column name is "name"
+ */
+ public String getName() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.NAME
+ .columnName(),
+ "getName",
+ VersionNum.VERSION100);
+ return (String) super.getDataHandler(columndesc);
+ }
+
+ /**
+ * Get the Column entity which column name is "datapath_type" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "datapath_type"
+ */
+ public Column getDatapathTypeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.DATAPATHTYPE
+ .columnName(),
+ "getDatapathTypeColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "datapath_type" to the Row
+ * entity of attributes.
+ * @param datapathType the column data which column name is "datapath_type"
+ */
+ public void setDatapathType(String datapathType) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.DATAPATHTYPE
+ .columnName(),
+ "setDatapathType",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, datapathType);
+ }
+
+ /**
+ * Get the Column entity which column name is "datapath_id" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "datapath_id"
+ */
+ public Column getDatapathIdColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.DATAPATHID
+ .columnName(),
+ "getDatapathIdColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "datapath_id" to the Row entity
+ * of attributes.
+ * @param datapathId the column data which column name is "datapath_id"
+ */
+ public void setDatapathId(Set<String> datapathId) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.DATAPATHID
+ .columnName(),
+ "setDatapathId",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, datapathId);
+ }
+
+ /**
+ * Get the Column entity which column name is "stpenable" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "stpenable"
+ */
+ public Column getStpEnableColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.STPENABLE
+ .columnName(),
+ "getStpEnableColumn",
+ VersionNum.VERSION620);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "stpenable" to the Row entity of
+ * attributes.
+ * @param stpenable the column data which column name is "stpenable"
+ */
+ public void setStpEnable(Boolean stpenable) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.STPENABLE
+ .columnName(),
+ "setStpEnable",
+ VersionNum.VERSION620);
+ super.setDataHandler(columndesc, stpenable);
+ }
+
+ /**
+ * Get the Column entity which column name is "ports" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "ports"
+ */
+ public Column getPortsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.PORTS
+ .columnName(),
+ "getPortsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ports" to the Row entity of
+ * attributes.
+ * @param ports the column data which column name is "ports"
+ */
+ public void setPorts(Set<UUID> ports) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.PORTS
+ .columnName(),
+ "setPorts",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, ports);
+ }
+
+ /**
+ * Get the Column entity which column name is "mirrors" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "mirrors"
+ */
+ public Column getMirrorsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.MIRRORS
+ .columnName(),
+ "getMirrorsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "mirrors" to the Row entity of
+ * attributes.
+ * @param mirrors the column data which column name is "mirrors"
+ */
+ public void setMirrors(Set<UUID> mirrors) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.MIRRORS
+ .columnName(),
+ "setMirrors",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, mirrors);
+ }
+
+ /**
+ * Get the Column entity which column name is "netflow" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "netflow"
+ */
+ public Column getNetflowColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.NETFLOW
+ .columnName(),
+ "getNetflowColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "netflow" to the Row entity of
+ * attributes.
+ * @param netflow the column data which column name is "netflow"
+ */
+ public void setNetflow(Set<UUID> netflow) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.NETFLOW
+ .columnName(),
+ "setNetflow",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, netflow);
+ }
+
+ /**
+ * Get the Column entity which column name is "sflow" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "sflow"
+ */
+ public Column getSflowColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.SFLOW
+ .columnName(),
+ "getSflowColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "sflow" to the Row entity of
+ * attributes.
+ * @param sflow the column data which column name is "sflow"
+ */
+ public void setSflow(Set<UUID> sflow) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.SFLOW
+ .columnName(),
+ "setSflow",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, sflow);
+ }
+
+ /**
+ * Get the Column entity which column name is "ipfix" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "ipfix"
+ */
+ public Column getIpfixColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.IPFIX
+ .columnName(),
+ "getIpfixColumn",
+ VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ipfix" to the Row entity of
+ * attributes.
+ * @param ipfix the column data which column name is "ipfix"
+ */
+ public void setIpfix(Set<UUID> ipfix) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.IPFIX
+ .columnName(),
+ "setIpfix",
+ VersionNum.VERSION710);
+ super.setDataHandler(columndesc, ipfix);
+ }
+
+ /**
+ * Get the Column entity which column name is "controller" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "controller"
+ */
+ public Column getControllerColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.CONTROLLER
+ .columnName(),
+ "getControllerColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "controller" to the Row entity
+ * of attributes.
+ * @param controller the column data which column name is "controller"
+ */
+ public void setController(OvsdbSet controller) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.CONTROLLER
+ .columnName(),
+ "setController",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, controller);
+ }
+
+ /**
+ * Get the Column entity which column name is "protocols" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "protocols"
+ */
+ public Column getProtocolsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.PROTOCOLS
+ .columnName(),
+ "getProtocolsColumn",
+ VersionNum.VERSION6111);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "protocols" to the Row entity of
+ * attributes.
+ * @param protocols the column data which column name is "protocols"
+ */
+ public void setProtocols(Set<String> protocols) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.PROTOCOLS
+ .columnName(),
+ "setProtocols",
+ VersionNum.VERSION6111);
+ super.setDataHandler(columndesc, protocols);
+ }
+
+ /**
+ * Get the Column entity which column name is "fail_mode" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "fail_mode"
+ */
+ public Column getFailModeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.FAILMODE
+ .columnName(),
+ "getFailModeColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "fail_mode" to the Row entity of
+ * attributes.
+ * @param failMode the column data which column name is "fail_mode"
+ */
+ public void setFailMode(Set<String> failMode) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.FAILMODE
+ .columnName(),
+ "setFailMode",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, failMode);
+ }
+
+ /**
+ * Get the Column entity which column name is "status" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "status"
+ */
+ public Column getStatusColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.STATUS
+ .columnName(),
+ "getStatusColumn",
+ VersionNum.VERSION620);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "status" to the Row entity of
+ * attributes.
+ * @param status the column data which column name is "status"
+ */
+ public void setStatus(Map<String, String> status) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.STATUS
+ .columnName(),
+ "setStatus",
+ VersionNum.VERSION620);
+ super.setDataHandler(columndesc, status);
+ }
+
+ /**
+ * Get the Column entity which column name is "other_config" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "other_config"
+ */
+ public Column getOtherConfigColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.OTHERCONFIG
+ .columnName(),
+ "getOtherConfigColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "other_config" to the Row entity
+ * of attributes.
+ * @param otherConfig the column data which column name is "other_config"
+ */
+ public void setOtherConfig(Map<String, String> otherConfig) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.OTHERCONFIG
+ .columnName(),
+ "setOtherConfig",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, otherConfig);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "external_ids"
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.EXTERNALIDS
+ .columnName(),
+ "getExternalIdsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.EXTERNALIDS
+ .columnName(),
+ "setExternalIds",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+ /**
+ * Get the Column entity which column name is "flood_vlans" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "flood_vlans"
+ */
+ public Column getFloodVlansColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.FLOODVLANS
+ .columnName(),
+ "getFloodVlansColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "flood_vlans" to the Row entity
+ * of attributes.
+ * @param vlans the column data which column name is "flood_vlans"
+ */
+ public void setFloodVlans(Set<Long> vlans) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.FLOODVLANS
+ .columnName(),
+ "setFloodVlans",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, vlans);
+ }
+
+ /**
+ * Get the Column entity which column name is "flow_tables" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "flow_tables"
+ */
+ public Column getFlowTablesColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.FLOWTABLES
+ .columnName(),
+ "getFlowTablesColumn",
+ VersionNum.VERSION650);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "flow_tables" to the Row entity
+ * of attributes.
+ * @param flowTables the column data which column name is "flow_tables"
+ */
+ public void setFlowTables(Map<Long, UUID> flowTables) {
+ ColumnDescription columndesc = new ColumnDescription(
+ BridgeColumn.FLOWTABLES
+ .columnName(),
+ "setFlowTables",
+ VersionNum.VERSION650);
+ super.setDataHandler(columndesc, flowTables);
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Controller.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Controller.java
new file mode 100644
index 00000000..912526cc
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Controller.java
@@ -0,0 +1,556 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Controller Table.
+ */
+public class Controller extends AbstractOvsdbTableService {
+
+ /**
+ * Controller table column name.
+ */
+ public enum ControllerColumn {
+ TARGET("target"), BURSTLIMIT("controller_burst_limit"),
+ RATELIMIT("controller_rate_limit"), CONNECTIONMODE("connection_mode"),
+ ENABLEASYNCMESSAGES("enable_async_messages"),
+ EXTERNALIDS("external_ids"), LOCALNETMASK("local_netmask"),
+ LOCALGATEWAY("local_gateway"), STATUS("status"), ROLE("role"),
+ INACTIVITYPROBE("inactivity_probe"), ISCONNECTED("is_connected"),
+ OTHERCONFIG("other_config"), MAXBACKOFF("max_backoff"),
+ LOCALIP("local_ip"),
+ DISCOVERUPDATERESOLVCONF("discover_update_resolv_conf"),
+ DISCOVERACCEPTREGEX("discover_accept_regex");
+
+ private final String columnName;
+
+ private ControllerColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for ControllerColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Controller object. Generate Controller Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Controller(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.CONTROLLER, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "target" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "target"
+ */
+ public Column getTargetColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.TARGET
+ .columnName(),
+ "getTargetColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "target" to the Row entity of
+ * attributes.
+ * @param target the column data which column name is "target"
+ */
+ public void setTarget(String target) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.TARGET
+ .columnName(),
+ "setTarget",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, target);
+ }
+
+ /**
+ * Get the Column entity which column name is "controller_burst_limit" from
+ * the Row entity of attributes.
+ * @return the Column entity which column name is "controller_burst_limit"
+ */
+ public Column getBurstLimitColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.BURSTLIMIT
+ .columnName(),
+ "getBurstLimitColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "controller_burst_limit" to the
+ * Row entity of attributes.
+ * @param burstLimit the column data which column name is
+ * "controller_burst_limit"
+ */
+ public void setBurstLimit(Long burstLimit) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.BURSTLIMIT
+ .columnName(),
+ "setBurstLimit",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, burstLimit);
+ }
+
+ /**
+ * Get the Column entity which column name is "controller_rate_limit" from
+ * the Row entity of attributes.
+ * @return the Column entity which column name is "controller_rate_limit"
+ */
+ public Column getRateLimitColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.RATELIMIT
+ .columnName(),
+ "getRateLimitColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "controller_rate_limit" to the
+ * Row entity of attributes.
+ * @param rateLimit the column data which column name is
+ * "controller_rate_limit"
+ */
+ public void setRateLimit(Long rateLimit) {
+ ColumnDescription columndesc = new ColumnDescription(
+ "controller_rate_limit",
+ "setRateLimit",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, rateLimit);
+ }
+
+ /**
+ * Get the Column entity which column name is "connection_mode" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "connection_mode"
+ */
+ public Column getConnectionModeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ "connection_mode",
+ "getConnectionModeColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "connection_mode" to the Row
+ * entity of attributes.
+ * @param connectionMode the column data which column name is
+ * "connection_mode"
+ */
+ public void setConnectionMode(Set<String> connectionMode) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.RATELIMIT
+ .columnName(),
+ "setConnectionMode",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, connectionMode);
+ }
+
+ /**
+ * Get the Column entity which column name is "enable_async_messages" from
+ * the Row entity of attributes.
+ * @return the Column entity which column name is "enable_async_messages"
+ */
+ public Column getEnableAsyncMessagesColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.ENABLEASYNCMESSAGES
+ .columnName(),
+ "getEnableAsyncMessagesColumn",
+ VersionNum.VERSION670);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "enable_async_messages" to the
+ * Row entity of attributes.
+ * @param enableAsyncMessages the column data which column name is
+ * "enable_async_messages"
+ */
+ public void setEnableAsyncMessages(Set<Boolean> enableAsyncMessages) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.ENABLEASYNCMESSAGES
+ .columnName(),
+ "setEnableAsyncMessages",
+ VersionNum.VERSION670);
+ super.setDataHandler(columndesc, enableAsyncMessages);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "external_ids"
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.EXTERNALIDS
+ .columnName(),
+ "getExternalIdsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.EXTERNALIDS
+ .columnName(),
+ "setExternalIds",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+ /**
+ * Get the Column entity which column name is "local_netmask" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "local_netmask"
+ */
+ public Column getLocalNetmaskColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.LOCALNETMASK
+ .columnName(),
+ "getLocalNetmaskColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "local_netmask" to the Row
+ * entity of attributes.
+ * @param localNetmask the column data which column name is "local_netmask"
+ */
+ public void setLocalNetmask(Set<String> localNetmask) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.LOCALNETMASK
+ .columnName(),
+ "setLocalNetmask",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, localNetmask);
+ }
+
+ /**
+ * Get the Column entity which column name is "local_gateway" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "local_gateway"
+ */
+ public Column getLocalGatewayColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.LOCALGATEWAY
+ .columnName(),
+ "getLocalGatewayColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "local_gateway" to the Row
+ * entity of attributes.
+ * @param localGateway the column data which column name is "local_gateway"
+ */
+ public void setLocalGateway(Set<String> localGateway) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.LOCALGATEWAY
+ .columnName(),
+ "setLocalGateway",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, localGateway);
+ }
+
+ /**
+ * Get the Column entity which column name is "status" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "status"
+ */
+ public Column getStatusColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.STATUS
+ .columnName(),
+ "getStatusColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "status" to the Row entity of
+ * attributes.
+ * @param status the column data which column name is "status"
+ */
+ public void setStatus(Map<String, String> status) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.STATUS
+ .columnName(),
+ "setStatus",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, status);
+ }
+
+ /**
+ * Get the Column entity which column name is "role" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "role"
+ */
+ public Column getRoleColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.ROLE
+ .columnName(),
+ "getRoleColumn",
+ VersionNum.VERSION110);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "role" to the Row entity of
+ * attributes.
+ * @param role the column data which column name is "role"
+ */
+ public void setRole(Set<String> role) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.ROLE
+ .columnName(),
+ "setRole",
+ VersionNum.VERSION110);
+ super.setDataHandler(columndesc, role);
+ }
+
+ /**
+ * Get the Column entity which column name is "inactivity_probe" from the
+ * Row entity of attributes.
+ * @return the Column entity which column name is "inactivity_probe"
+ */
+ public Column getInactivityProbeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.INACTIVITYPROBE
+ .columnName(),
+ "getInactivityProbeColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "inactivity_probe" to the Row
+ * entity of attributes.
+ * @param inactivityProbe the column data which column name is
+ * "inactivity_probe"
+ */
+ public void setInactivityProbe(Set<Long> inactivityProbe) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.INACTIVITYPROBE
+ .columnName(),
+ "setInactivityProbe",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, inactivityProbe);
+ }
+
+ /**
+ * Get the Column entity which column name is "is_connected" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "is_connected"
+ */
+ public Column getIsConnectedColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.ISCONNECTED
+ .columnName(),
+ "getIsConnectedColumn",
+ VersionNum.VERSION110);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "is_connected" to the Row entity
+ * of attributes.
+ * @param isConnected the column data which column name is "is_connected"
+ */
+ public void setIsConnected(Boolean isConnected) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.ISCONNECTED
+ .columnName(),
+ "setIsConnected",
+ VersionNum.VERSION110);
+ super.setDataHandler(columndesc, isConnected);
+ }
+
+ /**
+ * Get the Column entity which column name is "other_config" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "other_config"
+ */
+ public Column getOtherConfigColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.OTHERCONFIG
+ .columnName(),
+ "getOtherConfigColumn",
+ VersionNum.VERSION680);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "other_config" to the Row entity
+ * of attributes.
+ * @param otherConfig the column data which column name is "other_config"
+ */
+ public void setOtherConfig(Map<String, String> otherConfig) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.OTHERCONFIG
+ .columnName(),
+ "setOtherConfig",
+ VersionNum.VERSION680);
+ super.setDataHandler(columndesc, otherConfig);
+ }
+
+ /**
+ * Get the Column entity which column name is "max_backoff" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "max_backoff"
+ */
+ public Column getMaxBackoffColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.MAXBACKOFF
+ .columnName(),
+ "getMaxBackoffColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "max_backoff" to the Row entity
+ * of attributes.
+ * @param maxBackoff the column data which column name is "max_backoff"
+ */
+ public void setMaxBackoff(Long maxBackoff) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.MAXBACKOFF
+ .columnName(),
+ "setMaxBackoff",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, maxBackoff);
+ }
+
+ /**
+ * Get the Column entity which column name is "local_ip" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "local_ip"
+ */
+ public Column getLocalIpColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.LOCALIP
+ .columnName(),
+ "getLocalIpColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "local_ip" to the Row entity of
+ * attributes.
+ * @param localIp the column data which column name is "local_ip"
+ */
+ public void setLocalIp(Set<String> localIp) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.LOCALIP
+ .columnName(),
+ "setLocalIp",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, localIp);
+ }
+
+ /**
+ * Get the Column entity which column name is "discover_update_resolv_conf"
+ * from the Row entity of attributes.
+ * @return the Column entity which column name is
+ * "discover_update_resolv_conf"
+ */
+ public Column getDiscoverUpdateResolvConfColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.DISCOVERUPDATERESOLVCONF
+ .columnName(),
+ "getDiscoverUpdateResolvConfColumn",
+ VersionNum.VERSION100,
+ VersionNum.VERSION300);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "discover_update_resolv_conf" to
+ * the Row entity of attributes.
+ * @param discoverUpdateResolvConf the column data which column name is
+ * "discover_update_resolv_conf"
+ */
+ public void setDiscoverUpdateResolvConf(Set<String> discoverUpdateResolvConf) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.DISCOVERUPDATERESOLVCONF
+ .columnName(),
+ "setDiscoverUpdateResolvConf",
+ VersionNum.VERSION100,
+ VersionNum.VERSION300);
+ super.setDataHandler(columndesc, discoverUpdateResolvConf);
+ }
+
+ /**
+ * Get the Column entity which column name is "discover_accept_regex" from
+ * the Row entity of attributes.
+ * @return the Column entity which column name is "discover_accept_regex"
+ */
+ public Column getDiscoverAcceptRegexColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.DISCOVERACCEPTREGEX
+ .columnName(),
+ "getDiscoverAcceptRegexColumn",
+ VersionNum.VERSION100,
+ VersionNum.VERSION300);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "discover_accept_regex" to the
+ * Row entity of attributes.
+ * @param discoverAcceptRegex the column data which column name is
+ * "discover_accept_regex"
+ */
+ public void setDiscoverAcceptRegex(Set<String> discoverAcceptRegex) {
+ ColumnDescription columndesc = new ColumnDescription(
+ ControllerColumn.DISCOVERACCEPTREGEX
+ .columnName(),
+ "setDiscoverAcceptRegex",
+ VersionNum.VERSION100,
+ VersionNum.VERSION300);
+ super.setDataHandler(columndesc, discoverAcceptRegex);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/FlowSampleCollectorSet.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/FlowSampleCollectorSet.java
new file mode 100644
index 00000000..05a0354f
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/FlowSampleCollectorSet.java
@@ -0,0 +1,151 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of FlowSampleCollectorSet Table.
+ */
+public class FlowSampleCollectorSet extends AbstractOvsdbTableService {
+ /**
+ * FlowSampleCollectorSet table column name.
+ */
+ public enum FlowSampleCollectorSetColumn {
+ ID("id"), BRIDGE("bridge"), IPFIX("ipfix"), EXTERNALIDS("external_ids");
+
+ private final String columnName;
+
+ private FlowSampleCollectorSetColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for FlowSampleCollectorSetColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a FlowSampleCollectorSet object. Generate
+ * FlowSampleCollectorSet Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public FlowSampleCollectorSet(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.FLOWSAMPLECOLLECTORSET, VersionNum.VERSION710);
+ }
+
+ /**
+ * Get the Column entity which column name is "id" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "id"
+ */
+ public Column getIdColumn() {
+ ColumnDescription columndesc = new ColumnDescription(FlowSampleCollectorSetColumn.ID.columnName(),
+ "getIdColumn", VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "id" to the Row entity of
+ * attributes.
+ * @param id the column data which column name is "id"
+ */
+ public void setId(Long id) {
+ ColumnDescription columndesc = new ColumnDescription(FlowSampleCollectorSetColumn.ID.columnName(),
+ "setId", VersionNum.VERSION710);
+ super.setDataHandler(columndesc, id);
+ }
+
+ /**
+ * Get the Column entity which column name is "bridge" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "bridge"
+ */
+ public Column getBridgeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(FlowSampleCollectorSetColumn.BRIDGE.columnName(),
+ "getBridgeColumn", VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "bridge" to the Row entity of
+ * attributes.
+ * @param bridge the column data which column name is "bridge"
+ */
+ public void setBridge(UUID bridge) {
+ ColumnDescription columndesc = new ColumnDescription(FlowSampleCollectorSetColumn.BRIDGE.columnName(),
+ "setBridge", VersionNum.VERSION710);
+ super.setDataHandler(columndesc, bridge);
+ }
+
+ /**
+ * Get the Column entity which column name is "ipfix" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "ipfix"
+ */
+ public Column getIpfixColumn() {
+ ColumnDescription columndesc = new ColumnDescription(FlowSampleCollectorSetColumn.IPFIX.columnName(),
+ "getIpfixColumn", VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ipfix" to the Row entity of
+ * attributes.
+ * @param ipfix the column data which column name is "ipfix"
+ */
+ public void setIpfix(UUID ipfix) {
+ ColumnDescription columndesc = new ColumnDescription(FlowSampleCollectorSetColumn.IPFIX.columnName(),
+ "setIpfix", VersionNum.VERSION710);
+ super.setDataHandler(columndesc, ipfix);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "external_ids"
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(FlowSampleCollectorSetColumn.EXTERNALIDS
+ .columnName(),
+ "getExternalIdsColumn", VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(FlowSampleCollectorSetColumn.EXTERNALIDS
+ .columnName(),
+ "setExternalIds", VersionNum.VERSION710);
+ super.setDataHandler(columndesc, externalIds);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/FlowTable.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/FlowTable.java
new file mode 100644
index 00000000..ed1c217a
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/FlowTable.java
@@ -0,0 +1,196 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of FlowTable Table.
+ */
+public class FlowTable extends AbstractOvsdbTableService {
+ /**
+ * FlowTable table column name.
+ */
+ public enum FlowTableColumn {
+ FLOWLIMIT("flow_limit"), OVERFLOWPOLICY("overflow_policy"), GROUPS("groups"), NAME("name"),
+ PREFIXES("prefixes"), EXTERNALIDS("external_ids");
+
+ private final String columnName;
+
+ private FlowTableColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for FlowTableColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a FlowTable object. Generate FlowTable Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public FlowTable(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.FLWTABLE, VersionNum.VERSION650);
+ }
+
+ /**
+ * Get the Column entity which column name is "flow_limit" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "flow_limit"
+ */
+ public Column getFlowLimitColumn() {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.FLOWLIMIT.columnName(),
+ "getFlowLimitColumn", VersionNum.VERSION650);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "flow_limit" to the Row entity
+ * of attributes.
+ * @param flowLimit the column data which column name is "flow_limit"
+ */
+ public void setFlowLimit(Set<Long> flowLimit) {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.FLOWLIMIT.columnName(),
+ "setFlowLimit", VersionNum.VERSION650);
+ super.setDataHandler(columndesc, flowLimit);
+ }
+
+ /**
+ * Get the Column entity which column name is "overflow_policy" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "overflow_policy"
+ */
+ public Column getOverflowPolicyColumn() {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.OVERFLOWPOLICY.columnName(),
+ "getOverflowPolicyColumn", VersionNum.VERSION650);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "overflow_policy" to the Row
+ * entity of attributes.
+ * @param overflowPolicy the column data which column name is
+ * "overflow_policy"
+ */
+ public void setOverflowPolicy(Set<String> overflowPolicy) {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.OVERFLOWPOLICY.columnName(),
+ "setOverflowPolicy", VersionNum.VERSION650);
+ super.setDataHandler(columndesc, overflowPolicy);
+ }
+
+ /**
+ * Get the Column entity which column name is "groups" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "groups"
+ */
+ public Column getGroupsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.GROUPS.columnName(),
+ "getGroupsColumn", VersionNum.VERSION650);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "groups" to the Row entity of
+ * attributes.
+ * @param groups the column data which column name is "groups"
+ */
+ public void setGroups(Set<String> groups) {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.GROUPS.columnName(),
+ "setGroups", VersionNum.VERSION650);
+ super.setDataHandler(columndesc, groups);
+ }
+
+ /**
+ * Get the Column entity which column name is "name" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "name"
+ */
+ public Column getNameColumn() {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.NAME.columnName(),
+ "getNameColumn", VersionNum.VERSION650);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "name" to the Row entity of
+ * attributes.
+ * @param name the column data which column name is "name"
+ */
+ public void setName(Set<String> name) {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.NAME.columnName(),
+ "setName",
+ VersionNum.VERSION650);
+ super.setDataHandler(columndesc, name);
+ }
+
+ /**
+ * Get the Column entity which column name is "prefixes" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "prefixes"
+ */
+ public Column getPrefixesColumn() {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.PREFIXES.columnName(),
+ "getPrefixesColumn", VersionNum.VERSION740);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "prefixes" to the Row entity of
+ * attributes.
+ * @param prefixes the column data which column name is "prefixes"
+ */
+ public void setPrefixes(Set<String> prefixes) {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.PREFIXES.columnName(),
+ "setPrefixes", VersionNum.VERSION740);
+ super.setDataHandler(columndesc, prefixes);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "external_ids"
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.EXTERNALIDS.columnName(),
+ "getExternalIdsColumn", VersionNum.VERSION750);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(FlowTableColumn.EXTERNALIDS.columnName(),
+ "setExternalIds", VersionNum.VERSION750);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Interface.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Interface.java
new file mode 100644
index 00000000..ee946287
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Interface.java
@@ -0,0 +1,1024 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Interface Table.
+ */
+public class Interface extends AbstractOvsdbTableService {
+
+ /**
+ * Interface table column name.
+ */
+ public enum InterfaceColumn {
+ NAME("name"), TYPE("type"), OPTIONS("options"),
+ INGRESSPOLICINGRATE("ingress_policing_rate"),
+ INGRESSPOLICINGBURST("ingress_policing_burst"), MACINUSE("mac_in_use"),
+ MAC("mac"), IFINDEX("ifindex"), EXTERNALIDS("external_ids"),
+ OFPORT("ofport"), OFPORTREQUEST("ofport_request"), BFD("bfd"),
+ BFDSTATUS("bfd_status"), MONITOR("monitor"), CFMMPID("cfm_mpid"),
+ CFMREMOTEMPID("cfm_remote_mpid"), CFMREMOTEMPIDS("cfm_remote_mpids"),
+ CFMFLAPCOUNT("cfm_flap_count"), CFMFAULT("cfm_fault"),
+ CFMFAULTSTATUS("cfm_fault_status"),
+ CFMREMOTEOPSTATE("cfm_remote_opstate"), CFMHEALTH("cfm_health"),
+ LACPCURRENT("lacp_current"), OTHERCONFIG("other_config"),
+ STATISTICS("statistics"), STATUS("status"), ADMINSTATE("admin_state"),
+ LINKSTATE("link_state"), LINKRESETS("link_resets"),
+ LINKSPEED("link_speed"), DUPLEX("duplex"), MTU("mtu"), ERROR("error");
+
+ private final String columnName;
+
+ private InterfaceColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for InterfaceColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Interface object. Generate Interface Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Interface(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.INTERFACE, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "name" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "name"
+ */
+ public Column getNameColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.NAME
+ .columnName(),
+ "getNameColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "name" to the Row entity of
+ * attributes.
+ * @param name the column data which column name is "name"
+ */
+ public void setName(String name) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.NAME
+ .columnName(),
+ "setName",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, name);
+ }
+
+ /**
+ * Get the column data which column name is "name" from the Row entity of
+ * attributes.
+ * @return the column data which column name is "name"
+ */
+ public String getName() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.NAME
+ .columnName(),
+ "getName",
+ VersionNum.VERSION100);
+ return (String) super.getDataHandler(columndesc);
+ }
+
+ /**
+ * Get the Column entity which column name is "type" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "type"
+ */
+ public Column getTypeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.TYPE
+ .columnName(),
+ "getTypeColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "type" to the Row entity of
+ * attributes.
+ * @param type the column data which column name is "type"
+ */
+ public void setType(String type) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.TYPE
+ .columnName(),
+ "setType",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, type);
+ }
+
+ /**
+ * Get the Column entity which column name is "options" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "options"
+ */
+ public Column getOptionsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.OPTIONS
+ .columnName(),
+ "getOptionsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "options" to the Row entity of
+ * attributes.
+ * @param options the column data which column name is "options"
+ */
+ public void setOptions(Map<String, String> options) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.OPTIONS
+ .columnName(),
+ "setOptions",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, options);
+ }
+
+ /**
+ * Get the Column entity which column name is "ingress_policing_rate" from
+ * the Row entity of attributes.
+ * @return the Column entity which column name is "ingress_policing_rate"
+ */
+ public Column getIngressPolicingRateColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.INGRESSPOLICINGRATE
+ .columnName(),
+ "getIngressPolicingRateColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ingress_policing_rate" to the
+ * Row entity of attributes.
+ * @param ingressPolicingRate the column data which column name is
+ * "ingress_policing_rate"
+ */
+ public void setIngressPolicingRate(Set<Long> ingressPolicingRate) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.INGRESSPOLICINGRATE
+ .columnName(),
+ "setIngressPolicingRate",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, ingressPolicingRate);
+ }
+
+ /**
+ * Get the Column entity which column name is "ingress_policing_burst" from
+ * the Row entity of attributes.
+ * @return the Column entity which column name is "ingress_policing_burst"
+ */
+ public Column getIngressPolicingBurstColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.INGRESSPOLICINGBURST
+ .columnName(),
+ "getIngressPolicingBurstColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ingress_policing_burst" to the
+ * Row entity of attributes.
+ * @param ingressPolicingBurst the column data which column name is
+ * "ingress_policing_burst"
+ */
+ public void setIngressPolicingBurst(Set<Long> ingressPolicingBurst) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.INGRESSPOLICINGBURST
+ .columnName(),
+ "setIngressPolicingBurst",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, ingressPolicingBurst);
+ }
+
+ /**
+ * Get the Column entity which column name is "mac_in_use" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "mac_in_use"
+ */
+ public Column getMacInUseColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.MACINUSE
+ .columnName(),
+ "getMacInUseColumn",
+ VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "mac_in_use" to the Row entity
+ * of attributes.
+ * @param macInUse the column data which column name is "mac_in_use"
+ */
+ public void setMacInUse(Set<String> macInUse) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.MACINUSE
+ .columnName(),
+ "setMacInUse",
+ VersionNum.VERSION710);
+ super.setDataHandler(columndesc, macInUse);
+ }
+
+ /**
+ * Get the Column entity which column name is "mac" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "mac"
+ */
+ public Column getMacColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.MAC
+ .columnName(),
+ "getMacColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "mac" to the Row entity of
+ * attributes.
+ * @param mac the column data which column name is "mac"
+ */
+ public void setMac(Set<String> mac) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.MAC
+ .columnName(),
+ "setMac",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, mac);
+ }
+
+ /**
+ * Get the Column entity which column name is "ifindex" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "ifindex"
+ */
+ public Column getIfIndexColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.IFINDEX
+ .columnName(),
+ "getIfIndexColumn",
+ VersionNum.VERSION721);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ifindex" to the Row entity of
+ * attributes.
+ * @param ifIndex the column data which column name is "ifindex"
+ */
+ public void setIfIndex(Long ifIndex) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.IFINDEX
+ .columnName(),
+ "setIfIndex",
+ VersionNum.VERSION721);
+ super.setDataHandler(columndesc, ifIndex);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "external_ids"
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.EXTERNALIDS
+ .columnName(),
+ "getExternalIdsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.EXTERNALIDS
+ .columnName(),
+ "setExternalIds",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+ /**
+ * Get the Column entity which column name is "ofport" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "ofport"
+ */
+ public Column getOpenFlowPortColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.OFPORT
+ .columnName(),
+ "getOpenFlowPortColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ofport" to the Row entity of
+ * attributes.
+ * @param openFlowPort the column data which column name is "ofport"
+ */
+ public void setOpenFlowPort(Set<Long> openFlowPort) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.OFPORT
+ .columnName(),
+ "setOpenFlowPort",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, openFlowPort);
+ }
+
+ /**
+ * Get the Column entity which column name is "ofport_request" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "ofport_request"
+ */
+ public Column getOpenFlowPortRequestColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.OFPORTREQUEST
+ .columnName(),
+ "getOpenFlowPortRequestColumn",
+ VersionNum.VERSION620);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ofport_request" to the Row
+ * entity of attributes.
+ * @param openFlowPortRequest the column data which column name is
+ * "ofport_request"
+ */
+ public void setOpenFlowPortRequest(String openFlowPortRequest) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.OFPORTREQUEST
+ .columnName(),
+ "setOpenFlowPortRequest",
+ VersionNum.VERSION620);
+ super.setDataHandler(columndesc, openFlowPortRequest);
+ }
+
+ /**
+ * Get the Column entity which column name is "bfd" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "bfd"
+ */
+ public Column getBfdColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.BFD
+ .columnName(),
+ "getBfdColumn",
+ VersionNum.VERSION720);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "bfd" to the Row entity of
+ * attributes.
+ * @param bfd the column data which column name is "bfd"
+ */
+ public void setBfd(Map<String, String> bfd) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.BFD
+ .columnName(),
+ "setBfd",
+ VersionNum.VERSION720);
+ super.setDataHandler(columndesc, bfd);
+ }
+
+ /**
+ * Get the Column entity which column name is "bfd_status" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "bfd_status"
+ */
+ public Column getBfdStatusColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.BFDSTATUS
+ .columnName(),
+ "getBfdStatusColumn",
+ VersionNum.VERSION720);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "bfd_status" to the Row entity
+ * of attributes.
+ * @param bfdStatus the column data which column name is "bfd_status"
+ */
+ public void setBfdStatus(Map<String, String> bfdStatus) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.BFDSTATUS
+ .columnName(),
+ "setBfdStatus",
+ VersionNum.VERSION720);
+ super.setDataHandler(columndesc, bfdStatus);
+ }
+
+ /**
+ * Get the Column entity which column name is "monitor" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "monitor"
+ */
+ public Column getMonitorColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.MONITOR
+ .columnName(),
+ "getMonitorColumn",
+ VersionNum.VERSION100,
+ VersionNum.VERSION350);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "monitor" to the Row entity of
+ * attributes.
+ * @param monitor the column data which column name is "monitor"
+ */
+ public void setMonitor(String monitor) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.MONITOR
+ .columnName(),
+ "setMonitor",
+ VersionNum.VERSION100,
+ VersionNum.VERSION350);
+ super.setDataHandler(columndesc, monitor);
+ }
+
+ /**
+ * Get the Column entity which column name is "cfm_mpid" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "cfm_mpid"
+ */
+ public Column getCfmMpidColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMMPID
+ .columnName(),
+ "getCfmMpidColumn",
+ VersionNum.VERSION400);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cfm_mpid" to the Row entity of
+ * attributes.
+ * @param cfmMpid the column data which column name is "cfm_mpid"
+ */
+ public void setCfmMpid(Set<Long> cfmMpid) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMMPID
+ .columnName(),
+ "setCfmMpid",
+ VersionNum.VERSION400);
+ super.setDataHandler(columndesc, cfmMpid);
+ }
+
+ /**
+ * Get the Column entity which column name is "cfm_remote_mpid" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "cfm_remote_mpid"
+ */
+ public Column getCfmRemoteMpidColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMREMOTEMPID
+ .columnName(),
+ "getCfmRemoteMpidColumn",
+ VersionNum.VERSION400,
+ VersionNum.VERSION520);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cfm_remote_mpid" to the Row
+ * entity of attributes.
+ * @param cfmRemoteMpid the column data which column name is
+ * "cfm_remote_mpid"
+ */
+ public void setCfmRemoteMpid(Set<Long> cfmRemoteMpid) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMREMOTEMPID
+ .columnName(),
+ "setCfmRemoteMpid",
+ VersionNum.VERSION400,
+ VersionNum.VERSION520);
+ super.setDataHandler(columndesc, cfmRemoteMpid);
+ }
+
+ /**
+ * Get the Column entity which column name is "cfm_remote_mpids" from the
+ * Row entity of attributes.
+ * @return the Column entity which column name is "cfm_remote_mpids"
+ */
+ public Column getCfmRemoteMpidsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMREMOTEMPIDS
+ .columnName(),
+ "getCfmRemoteMpidsColumn",
+ VersionNum.VERSION600);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cfm_remote_mpids" to the Row
+ * entity of attributes.
+ * @param cfmRemoteMpids the column data which column name is
+ * "cfm_remote_mpids"
+ */
+ public void setCfmRemoteMpids(Set<Long> cfmRemoteMpids) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMREMOTEMPIDS
+ .columnName(),
+ "setCfmRemoteMpids",
+ VersionNum.VERSION600);
+ super.setDataHandler(columndesc, cfmRemoteMpids);
+ }
+
+ /**
+ * Get the Column entity which column name is "cfm_flap_count" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "cfm_flap_count"
+ */
+ public Column getCfmFlapCountColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMFLAPCOUNT
+ .columnName(),
+ "getCfmFlapCountColumn",
+ VersionNum.VERSION730);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cfm_flap_count" to the Row
+ * entity of attributes.
+ * @param cfmFlapCount the column data which column name is "cfm_flap_count"
+ */
+ public void setCfmFlapCount(Set<Long> cfmFlapCount) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMFLAPCOUNT
+ .columnName(),
+ "setCfmFlapCount",
+ VersionNum.VERSION730);
+ super.setDataHandler(columndesc, cfmFlapCount);
+ }
+
+ /**
+ * Get the Column entity which column name is "cfm_fault" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "cfm_fault"
+ */
+ public Column getCfmFaultColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMFAULT
+ .columnName(),
+ "getCfmFaultColumn",
+ VersionNum.VERSION400);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cfm_fault" to the Row entity of
+ * attributes.
+ * @param cfmFault the column data which column name is "cfm_fault"
+ */
+ public void setCfmFault(Set<Boolean> cfmFault) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMFAULT
+ .columnName(),
+ "setCfmFault",
+ VersionNum.VERSION400);
+ super.setDataHandler(columndesc, cfmFault);
+ }
+
+ /**
+ * Get the Column entity which column name is "cfm_fault_status" from the
+ * Row entity of attributes.
+ * @return the Column entity which column name is "cfm_fault_status"
+ */
+ public Column getCfmFaultStatusColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMFAULTSTATUS
+ .columnName(),
+ "getCfmFaultStatusColumn",
+ VersionNum.VERSION660);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cfm_fault_status" to the Row
+ * entity of attributes.
+ * @param cfmFaultStatus the column data which column name is
+ * "cfm_fault_status"
+ */
+ public void setCfmFaultStatus(Set<String> cfmFaultStatus) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMFAULTSTATUS
+ .columnName(),
+ "setCfmFaultStatus",
+ VersionNum.VERSION660);
+ super.setDataHandler(columndesc, cfmFaultStatus);
+ }
+
+ /**
+ * Get the Column entity which column name is "cfm_remote_opstate" from the
+ * Row entity of attributes.
+ * @return the Column entity which column name is "cfm_remote_opstate"
+ */
+ public Column getCfmRemoteOpStateColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMREMOTEOPSTATE
+ .columnName(),
+ "getCfmRemoteOpStateColumn",
+ VersionNum.VERSION6100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cfm_remote_opstate" to the Row
+ * entity of attributes.
+ * @param cfmRemoteOpState the column data which column name is
+ * "cfm_remote_opstate"
+ */
+ public void setCfmRemoteOpState(Set<String> cfmRemoteOpState) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMREMOTEOPSTATE
+ .columnName(),
+ "setCfmRemoteOpState",
+ VersionNum.VERSION6100);
+ super.setDataHandler(columndesc, cfmRemoteOpState);
+ }
+
+ /**
+ * Get the Column entity which column name is "cfm_health" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "cfm_health"
+ */
+ public Column getCfmHealthColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMHEALTH
+ .columnName(),
+ "getCfmHealthColumn",
+ VersionNum.VERSION690);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cfm_health" to the Row entity
+ * of attributes.
+ * @param cfmHealth the column data which column name is "cfm_health"
+ */
+ public void setCfmHealth(Set<Long> cfmHealth) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.CFMHEALTH
+ .columnName(),
+ "setCfmHealth",
+ VersionNum.VERSION690);
+ super.setDataHandler(columndesc, cfmHealth);
+ }
+
+ /**
+ * Get the Column entity which column name is "lacp_current" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "lacp_current"
+ */
+ public Column getLacpCurrentColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.LACPCURRENT
+ .columnName(),
+ "getLacpCurrentColumn",
+ VersionNum.VERSION330);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "lacp_current" to the Row entity
+ * of attributes.
+ * @param lacpCurrent the column data which column name is "lacp_current"
+ */
+ public void setLacpCurrent(Set<Boolean> lacpCurrent) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.LACPCURRENT
+ .columnName(),
+ "setLacpCurrent",
+ VersionNum.VERSION330);
+ super.setDataHandler(columndesc, lacpCurrent);
+ }
+
+ /**
+ * Get the Column entity which column name is "other_config" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "other_config"
+ */
+ public Column getOtherConfigColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.OTHERCONFIG
+ .columnName(),
+ "getOtherConfigColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "other_config" to the Row entity
+ * of attributes.
+ * @param otherConfig the column data which column name is "other_config"
+ */
+ public void setOtherConfig(Map<String, String> otherConfig) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.OTHERCONFIG
+ .columnName(),
+ "setOtherConfig",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, otherConfig);
+ }
+
+ /**
+ * Get the Column entity which column name is "statistics" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "statistics"
+ */
+ public Column getStatisticsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.STATISTICS
+ .columnName(),
+ "getStatisticsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "statistics" to the Row entity
+ * of attributes.
+ * @param statistics the column data which column name is "statistics"
+ */
+ public void setStatistics(Map<String, Long> statistics) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.STATISTICS
+ .columnName(),
+ "setStatistics",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, statistics);
+ }
+
+ /**
+ * Get the Column entity which column name is "status" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "status"
+ */
+ public Column getStatusColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.STATUS
+ .columnName(),
+ "getStatusColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "status" to the Row entity of
+ * attributes.
+ * @param status the column data which column name is "status"
+ */
+ public void setStatus(Map<String, String> status) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.STATUS
+ .columnName(),
+ "setStatus",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, status);
+ }
+
+ /**
+ * Get the Column entity which column name is "admin_state" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "admin_state"
+ */
+ public Column getAdminStateColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.ADMINSTATE
+ .columnName(),
+ "getAdminStateColumn",
+ VersionNum.VERSION106);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "admin_state" to the Row entity
+ * of attributes.
+ * @param adminState the column data which column name is "admin_state"
+ */
+ public void setAdminState(Set<String> adminState) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.ADMINSTATE
+ .columnName(),
+ "setAdminState",
+ VersionNum.VERSION106);
+ super.setDataHandler(columndesc, adminState);
+ }
+
+ /**
+ * Get the Column entity which column name is "link_state" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "link_state"
+ */
+ public Column getLinkStateColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.LINKSTATE
+ .columnName(),
+ "getLinkStateColumn",
+ VersionNum.VERSION106);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "link_state" to the Row entity
+ * of attributes.
+ * @param linkState the column data which column name is "link_state"
+ */
+ public void setLinkState(Map<String, String> linkState) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.LINKSTATE
+ .columnName(),
+ "setLinkState",
+ VersionNum.VERSION106);
+ super.setDataHandler(columndesc, linkState);
+ }
+
+ /**
+ * Get the Column entity which column name is "link_resets" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "link_resets"
+ */
+ public Column getLinkResetsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.LINKRESETS
+ .columnName(),
+ "getLinkResetsColumn",
+ VersionNum.VERSION620);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "link_resets" to the Row entity
+ * of attributes.
+ * @param linkResets the column data which column name is "link_resets"
+ */
+ public void setLinkResets(Set<String> linkResets) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.LINKRESETS
+ .columnName(),
+ "setLinkResets",
+ VersionNum.VERSION620);
+ super.setDataHandler(columndesc, linkResets);
+ }
+
+ /**
+ * Get the Column entity which column name is "link_speed" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "link_speed"
+ */
+ public Column getLinkSpeedColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.LINKSPEED
+ .columnName(),
+ "getLinkSpeedColumn",
+ VersionNum.VERSION106);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "link_speed" to the Row entity
+ * of attributes.
+ * @param linkSpeed the column data which column name is "link_speed"
+ */
+ public void setLinkSpeed(Set<Long> linkSpeed) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.LINKSPEED
+ .columnName(),
+ "setLinkSpeed",
+ VersionNum.VERSION106);
+ super.setDataHandler(columndesc, linkSpeed);
+ }
+
+ /**
+ * Get the Column entity which column name is "duplex" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "duplex"
+ */
+ public Column getDuplexColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.DUPLEX
+ .columnName(),
+ "getDuplexColumn",
+ VersionNum.VERSION106);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "duplex" to the Row entity of
+ * attributes.
+ * @param duplex the column data which column name is "duplex"
+ */
+ public void setDuplex(Set<Long> duplex) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.DUPLEX
+ .columnName(),
+ "setDuplex",
+ VersionNum.VERSION106);
+ super.setDataHandler(columndesc, duplex);
+ }
+
+ /**
+ * Get the Column entity which column name is "mtu" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "mtu"
+ */
+ public Column getMtuColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.MTU
+ .columnName(),
+ "getMtuColumn",
+ VersionNum.VERSION106);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "mtu" to the Row entity of
+ * attributes.
+ * @param mtu the column data which column name is "mtu"
+ */
+ public void setMtu(Set<Long> mtu) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.MTU
+ .columnName(),
+ "setMtu",
+ VersionNum.VERSION106);
+ super.setDataHandler(columndesc, mtu);
+ }
+
+ /**
+ * Get the Column entity which column name is "error" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "error"
+ */
+ public Column getErrorColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.ERROR
+ .columnName(),
+ "getErrorColumn",
+ VersionNum.VERSION770);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "error" to the Row entity of
+ * attributes.
+ * @param error the column data which column name is "error"
+ */
+ public void setError(Set<String> error) {
+ ColumnDescription columndesc = new ColumnDescription(
+ InterfaceColumn.ERROR
+ .columnName(),
+ "setError",
+ VersionNum.VERSION770);
+ super.setDataHandler(columndesc, error);
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Ipfix.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Ipfix.java
new file mode 100644
index 00000000..c29f2e01
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Ipfix.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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Ipfix Table.
+ */
+public class Ipfix extends AbstractOvsdbTableService {
+ /**
+ * Ipfix table column name.
+ */
+ public enum IpfixColumn {
+ TARGETS("targets"), SAMPLING("sampling"), OBSDOMAINID("obs_domain_id"), OBSPOINTID("obs_point_id"),
+ CACHEACTIVETIMEOUT("cache_active_timeout"), EXTERNALIDS("external_ids"),
+ CACHEMAXFLOWS("cache_max_flows");
+
+ private final String columnName;
+
+ private IpfixColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for IpfixColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Ipfix object. Generate Ipfix Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Ipfix(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.IPFIX, VersionNum.VERSION710);
+ }
+
+ /**
+ * Get the Column entity which column name is "targets" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "targets"
+ */
+ public Column getTargetsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.TARGETS.columnName(),
+ "getTargetsColumn", VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "targets" to the Row entity of
+ * attributes.
+ * @param targets the column data which column name is "targets"
+ */
+ public void setTargets(Set<String> targets) {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.TARGETS.columnName(),
+ "setTargets",
+ VersionNum.VERSION710);
+ super.setDataHandler(columndesc, targets);
+ }
+
+ /**
+ * Get the Column entity which column name is "sampling" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "sampling"
+ */
+ public Column getSamplingColumn() {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.SAMPLING.columnName(),
+ "getSamplingColumn", VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "sampling" to the Row entity of
+ * attributes.
+ * @param sampling the column data which column name is "sampling"
+ */
+ public void setSampling(Set<Long> sampling) {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.SAMPLING.columnName(),
+ "setSampling", VersionNum.VERSION710);
+ super.setDataHandler(columndesc, sampling);
+ }
+
+ /**
+ * Get the Column entity which column name is "obs_domain_id" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "obs_domain_id"
+ */
+ public Column getObsDomainIdColumn() {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.OBSDOMAINID.columnName(),
+ "getObsDomainIdColumn", VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "obs_domain_id" to the Row
+ * entity of attributes.
+ * @param obsdomainid the column data which column name is "obs_domain_id"
+ */
+ public void setObsDomainId(Set<Long> obsdomainid) {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.OBSDOMAINID.columnName(),
+ "setObsDomainId", VersionNum.VERSION710);
+ super.setDataHandler(columndesc, obsdomainid);
+ }
+
+ /**
+ * Get the Column entity which column name is "obs_point_id" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "obs_point_id"
+ */
+ public Column getObsPointIdColumn() {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.OBSPOINTID.columnName(),
+ "getObsPointIdColumn", VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "obs_point_id" to the Row entity
+ * of attributes.
+ * @param obsPointId the column data which column name is "obs_point_id"
+ */
+ public void setObsPointId(Set<Long> obsPointId) {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.OBSPOINTID.columnName(),
+ "setObsPointId", VersionNum.VERSION710);
+ super.setDataHandler(columndesc, obsPointId);
+ }
+
+ /**
+ * Get the Column entity which column name is "cache_active_timeout" from
+ * the Row entity of attributes.
+ * @return the Column entity which column name is "cache_active_timeout"
+ */
+ public Column getCacheActiveTimeoutColumn() {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.CACHEACTIVETIMEOUT.columnName(),
+ "getCacheActiveTimeoutColumn",
+ VersionNum.VERSION730);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cache_active_timeout" to the
+ * Row entity of attributes.
+ * @param cacheActiveTimeout the column data which column name is
+ * "cache_active_timeout"
+ */
+ public void setCacheActiveTimeout(Set<Long> cacheActiveTimeout) {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.CACHEACTIVETIMEOUT.columnName(),
+ "setCacheActiveTimeout", VersionNum.VERSION730);
+ super.setDataHandler(columndesc, cacheActiveTimeout);
+ }
+
+ /**
+ * Get the Column entity which column name is "cache_max_flows" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "cache_max_flows"
+ */
+ public Column getCacheMaxFlowsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.CACHEMAXFLOWS.columnName(),
+ "getCacheMaxFlowsColumn", VersionNum.VERSION730);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cache_max_flows" to the Row
+ * entity of attributes.
+ * @param cacheMaxFlows the column data which column name is
+ * "cache_max_flows"
+ */
+ public void setCacheMaxFlows(Set<Long> cacheMaxFlows) {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.CACHEMAXFLOWS.columnName(),
+ "setCacheMaxFlows", VersionNum.VERSION730);
+ super.setDataHandler(columndesc, cacheMaxFlows);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "external_ids"
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.EXTERNALIDS.columnName(),
+ "getExternalIdsColumn", VersionNum.VERSION710);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(IpfixColumn.EXTERNALIDS.columnName(),
+ "setExternalIds", VersionNum.VERSION710);
+ super.setDataHandler(columndesc, externalIds);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Manager.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Manager.java
new file mode 100644
index 00000000..d0c2638f
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Manager.java
@@ -0,0 +1,243 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Manager Table.
+ */
+public class Manager extends AbstractOvsdbTableService {
+ /**
+ * Manager table column name.
+ */
+ public enum ManagerColumn {
+ TARGET("target"), ISCONNECTED("is_connected"), CONNECTIONMODE("connection_mode"),
+ EXTERNALIDS("external_ids"), STATUS("status"), INACTIVITYPROBE("inactivity_probe"),
+ OTHERCONFIG("other_config"), MAXBACKOFF("max_backoff");
+
+ private final String columnName;
+
+ private ManagerColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for ManagerColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Manager object. Generate Manager Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Manager(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.MANAGER, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "target" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "target"
+ */
+ public Column getTargetColumn() {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.TARGET.columnName(),
+ "getTargetColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "target" to the Row entity of
+ * attributes.
+ * @param target the column data which column name is "target"
+ */
+ public void setTarget(Set<String> target) {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.TARGET.columnName(),
+ "setTarget",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, target);
+ }
+
+ /**
+ * Get the Column entity which column name is "is_connected" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "is_connected"
+ */
+ public Column getIsConnectedColumn() {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.ISCONNECTED.columnName(),
+ "getIsConnectedColumn", VersionNum.VERSION110);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "is_connected" to the Row entity
+ * of attributes.
+ * @param isConnected the column data which column name is "is_connected"
+ */
+ public void setIsConnected(Boolean isConnected) {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.ISCONNECTED.columnName(),
+ "setIsConnected", VersionNum.VERSION110);
+ super.setDataHandler(columndesc, isConnected);
+ }
+
+ /**
+ * Get the Column entity which column name is "other_config" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "other_config"
+ */
+ public Column getOtherConfigColumn() {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.OTHERCONFIG.columnName(),
+ "getOtherConfigColumn", VersionNum.VERSION680);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "other_config" to the Row entity
+ * of attributes.
+ * @param otherConfig the column data which column name is "other_config"
+ */
+ public void setOtherConfig(Map<String, String> otherConfig) {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.OTHERCONFIG.columnName(),
+ "setOtherConfig", VersionNum.VERSION680);
+ super.setDataHandler(columndesc, otherConfig);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "external_ids"
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.EXTERNALIDS.columnName(),
+ "getExternalIdsColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.EXTERNALIDS.columnName(),
+ "setExternalIds", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+ /**
+ * Get the Column entity which column name is "max_backoff" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "max_backoff"
+ */
+ public Column getMaxBackoffColumn() {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.MAXBACKOFF.columnName(),
+ "getMaxBackoffColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "max_backoff" to the Row entity
+ * of attributes.
+ * @param maxBackoff the column data which column name is "max_backoff"
+ */
+ public void setMaxBackoff(Set<Long> maxBackoff) {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.MAXBACKOFF.columnName(),
+ "setMaxBackoff", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, maxBackoff);
+ }
+
+ /**
+ * Get the Column entity which column name is "status" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "status"
+ */
+ public Column getStatusColumn() {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.STATUS.columnName(),
+ "getStatusColumn", VersionNum.VERSION110);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "status" to the Row entity of
+ * attributes.
+ * @param status the column data which column name is "status"
+ */
+ public void setStatus(Map<String, String> status) {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.STATUS.columnName(),
+ "setStatus",
+ VersionNum.VERSION110);
+ super.setDataHandler(columndesc, status);
+ }
+
+ /**
+ * Get the Column entity which column name is "inactivity_probe" from the
+ * Row entity of attributes.
+ * @return the Column entity which column name is "inactivity_probe"
+ */
+ public Column getInactivityProbeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.INACTIVITYPROBE.columnName(),
+ "getInactivityProbeColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "inactivity_probe" to the Row
+ * entity of attributes.
+ * @param inactivityProbe the column data which column name is
+ * "inactivity_probe"
+ */
+ public void setInactivityProbe(Set<Long> inactivityProbe) {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.INACTIVITYPROBE.columnName(),
+ "setInactivityProbe", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, inactivityProbe);
+ }
+
+ /**
+ * Get the Column entity which column name is "connection_mode" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "connection_mode"
+ */
+ public Column getConnectionModeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.CONNECTIONMODE.columnName(),
+ "getConnectionModeColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "connection_mode" to the Row
+ * entity of attributes.
+ * @param connectionMode the column data which column name is
+ * "connection_mode"
+ */
+ public void setConnectionMode(Set<String> connectionMode) {
+ ColumnDescription columndesc = new ColumnDescription(ManagerColumn.CONNECTIONMODE.columnName(),
+ "setConnectionMode", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, connectionMode);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Mirror.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Mirror.java
new file mode 100644
index 00000000..ec022fee
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Mirror.java
@@ -0,0 +1,277 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Mirror Table.
+ */
+public class Mirror extends AbstractOvsdbTableService {
+ /**
+ * Mirror table column name.
+ */
+ public enum MirrorColumn {
+ NAME("name"), SELECTSRCPORT("select_src_port"), SELECTDSTPORT("select_dst_port"),
+ SELECTVLAN("select_vlan"), OUTPUTPORT("output_port"), EXTERNALIDS("external_ids"),
+ OUTPUTVLAN("output_vlan"), STATISTICS("statistics"), SELECTALL("select_all");
+
+ private final String columnName;
+
+ private MirrorColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for MirrorColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Mirror object. Generate Mirror Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Mirror(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.MIRROR, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "name" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "name"
+ */
+ public Column getNameColumn() {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.NAME.columnName(),
+ "getNameColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "name" to the Row entity of
+ * attributes.
+ * @param name the column data which column name is "name"
+ */
+ public void setName(Set<String> name) {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.NAME.columnName(),
+ "setName",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, name);
+ }
+
+ /**
+ * Get the column data which column name is "name" from the Row entity of
+ * attributes.
+ * @return the column data which column name is "name"
+ */
+ public Set<String> getName() {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.NAME.columnName(),
+ "getName",
+ VersionNum.VERSION100);
+ return (Set<String>) super.getDataHandler(columndesc);
+ }
+
+ /**
+ * Get the Column entity which column name is "select_src_port" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "select_src_port"
+ */
+ public Column getSelectSrcPortColumn() {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.SELECTSRCPORT.columnName(),
+ "getSelectSrcPortColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "select_src_port" to the Row
+ * entity of attributes.
+ * @param selectSrcPort the column data which column name is
+ * "select_src_port"
+ */
+ public void setSelectSrcPort(Set<UUID> selectSrcPort) {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.SELECTSRCPORT.columnName(),
+ "setSelectSrcPort", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, selectSrcPort);
+ }
+
+ /**
+ * Get the Column entity which column name is "select_dst_port" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "select_dst_port"
+ */
+ public Column getSelectDstPortColumn() {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.SELECTDSTPORT.columnName(),
+ "getSelectDstPortColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "select_dst_port" to the Row
+ * entity of attributes.
+ * @param selectDstPrt the column data which column name is
+ * "select_dst_port"
+ */
+ public void setSelectDstPort(Set<UUID> selectDstPrt) {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.SELECTDSTPORT.columnName(),
+ "setSelectDstPort", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, selectDstPrt);
+ }
+
+ /**
+ * Get the Column entity which column name is "select_vlan" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "select_vlan"
+ */
+ public Column getSelectVlanColumn() {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.SELECTVLAN.columnName(),
+ "getSelectVlanColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "select_vlan" to the Row entity
+ * of attributes.
+ * @param selectVlan the column data which column name is "select_vlan"
+ */
+ public void setSelectVlan(Set<Long> selectVlan) {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.SELECTVLAN.columnName(),
+ "setSelectVlan", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, selectVlan);
+ }
+
+ /**
+ * Get the Column entity which column name is "output_port" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "output_port"
+ */
+ public Column getOutputPortColumn() {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.OUTPUTPORT.columnName(),
+ "getOutputPortColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "output_port" to the Row entity
+ * of attributes.
+ * @param outputPort the column data which column name is "output_port"
+ */
+ public void setOutputPort(Set<UUID> outputPort) {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.OUTPUTPORT.columnName(),
+ "setOutputPort", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, outputPort);
+ }
+
+ /**
+ * Get the Column entity which column name is "output_vlan" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "output_vlan"
+ */
+ public Column getOutputVlanColumn() {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.OUTPUTVLAN.columnName(),
+ "getOutputVlanColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "output_vlan" to the Row entity
+ * of attributes.
+ * @param outputVlan the column data which column name is "output_vlan"
+ */
+ public void setOutputVlan(Set<Long> outputVlan) {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.OUTPUTVLAN.columnName(),
+ "setOutputVlan", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, outputVlan);
+ }
+
+ /**
+ * Get the Column entity which column name is "statistics" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "statistics"
+ */
+ public Column getStatisticsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.STATISTICS.columnName(),
+ "getStatisticsColumn", VersionNum.VERSION640);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "statistics" to the Row entity
+ * of attributes.
+ * @param statistics the column data which column name is "statistics"
+ */
+ public void setStatistics(Map<String, Long> statistics) {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.STATISTICS.columnName(),
+ "setStatistics", VersionNum.VERSION640);
+ super.setDataHandler(columndesc, statistics);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "external_ids"
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.EXTERNALIDS.columnName(),
+ "getExternalIdsColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.EXTERNALIDS.columnName(),
+ "setExternalIds", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+ /**
+ * Get the Column entity which column name is "select_all" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "select_all"
+ */
+ public Column getSelectAllColumn() {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.SELECTALL.columnName(),
+ "getSelectAllColumn", VersionNum.VERSION620);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "select_all" to the Row entity
+ * of attributes.
+ * @param selectAll the column data which column name is "select_all"
+ */
+ public void setSelectAll(Boolean selectAll) {
+ ColumnDescription columndesc = new ColumnDescription(MirrorColumn.SELECTALL.columnName(),
+ "setSelectAll", VersionNum.VERSION620);
+ super.setDataHandler(columndesc, selectAll);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Netflow.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Netflow.java
new file mode 100644
index 00000000..98c3de55
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Netflow.java
@@ -0,0 +1,197 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Netflow Table.
+ */
+public class Netflow extends AbstractOvsdbTableService {
+ /**
+ * Netflow table column name.
+ */
+ public enum NetflowColumn {
+ TARGETS("targets"), ACTIVETIMEOUT("active_timeout"), ENGINETYPE("engine_type"),
+ EXTERNALIDS("external_ids"), ADDIDTOINTERFACE("add_id_to_interface"), ENGINEID("engine_id");
+
+ private final String columnName;
+
+ private NetflowColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for NetflowColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a NetFlow object. Generate Netflow Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Netflow(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.NETFLOW, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "targets" from the Row entity
+ * of attributes.
+ * @return the Column entity
+ */
+ public Column getTargetsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.TARGETS.columnName(),
+ "getTargetsColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "targets" to the Row entity of
+ * attributes.
+ * @param targets the column data which column name is "targets"
+ */
+ public void setTargets(Set<String> targets) {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.TARGETS.columnName(),
+ "setTargets", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, targets);
+ }
+
+ /**
+ * Get the Column entity which column name is "active_timeout" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getActiveTimeoutColumn() {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.ACTIVETIMEOUT.columnName(),
+ "getActiveTimeoutColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "active_timeout" to the Row
+ * entity of attributes.
+ * @param activeTimeout the column data which column name is
+ * "active_timeout"
+ */
+ public void setActiveTimeout(Long activeTimeout) {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.ACTIVETIMEOUT.columnName(),
+ "setActiveTimeout", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, activeTimeout);
+ }
+
+ /**
+ * Get the Column entity which column name is "engine_type" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getEngineTypeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.ENGINETYPE.columnName(),
+ "getEngineTypeColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "engine_type" to the Row entity
+ * of attributes.
+ * @param engineType the column data which column name is "engine_type"
+ */
+ public void setEngineType(Set<Long> engineType) {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.ENGINETYPE.columnName(),
+ "setEngineType", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, engineType);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.EXTERNALIDS.columnName(),
+ "getExternalIdsColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.EXTERNALIDS.columnName(),
+ "setExternalIds", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+ /**
+ * Get the Column entity which column name is "add_id_to_interface" from the
+ * Row entity of attributes.
+ * @return the Column entity
+ */
+ public Column getAddIdToInterfaceColumn() {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.ADDIDTOINTERFACE.columnName(),
+ "getAddIdToInterfaceColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "add_id_to_interface" to the Row
+ * entity of attributes.
+ * @param addIdToInterface the column data which column name is
+ * "add_id_to_interface"
+ */
+ public void setAddIdToInterface(Boolean addIdToInterface) {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.ADDIDTOINTERFACE.columnName(),
+ "setAddIdToInterface", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, addIdToInterface);
+ }
+
+ /**
+ * Get the Column entity which column name is "engine_id" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getEngineIdColumn() {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.ENGINETYPE.columnName(),
+ "getEngineIdColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "engine_id" to the Row entity of
+ * attributes.
+ * @param engineId the column data which column name is "engine_id"
+ */
+ public void setEngineId(Set<Long> engineId) {
+ ColumnDescription columndesc = new ColumnDescription(NetflowColumn.ENGINETYPE.columnName(),
+ "setEngineId", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, engineId);
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OpenVSwitch.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OpenVSwitch.java
new file mode 100644
index 00000000..9d20b982
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OpenVSwitch.java
@@ -0,0 +1,466 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Open_vSwitch Table.
+ */
+public class OpenVSwitch extends AbstractOvsdbTableService {
+
+ /**
+ * OpenVSwitch table column name.
+ */
+ public enum OpenVSwitchColumn {
+ BRIDGES("bridges"), MANAGERS("managers"),
+ MANAGEROPTIONS("manager_options"), SSL("ssl"),
+ OTHERCONFIG("other_config"), EXTERNALIDS("external_ids"),
+ NEXTCFG("next_cfg"), CURCFG("cur_cfg"), CAPABILITIES("capabilities"),
+ STATISTICS("statistics"), OVSVERSION("ovs_version"),
+ DBVERSION("db_version"), SYSTEMTYPE("system_type"),
+ SYSTEMVERSION("system_version");
+
+ private final String columnName;
+
+ private OpenVSwitchColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for OpenVSwitchColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a OpenVSwitch object. Generate Open_vSwitch Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public OpenVSwitch(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.OPENVSWITCH, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "bridges" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "bridges"
+ */
+ public Column getBridgesColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.BRIDGES
+ .columnName(),
+ "getBridgesColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "bridges" to the Row entity of
+ * attributes.
+ * @param bridges the column data which column name is "bridges"
+ */
+ public void setBridges(Set<UUID> bridges) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.BRIDGES
+ .columnName(),
+ "setBridges",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, bridges);
+ }
+
+ /**
+ * Get the Column entity which column name is "managers" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "managers"
+ */
+ public Column getManagersColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.MANAGERS
+ .columnName(),
+ "getManagersColumn",
+ VersionNum.VERSION100,
+ VersionNum.VERSION200);
+ return (Column) super.getDataHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "managers" to the Row entity of
+ * attributes.
+ * @param managers the column data which column name is "managers"
+ */
+ public void setManagers(Set<UUID> managers) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.MANAGERS
+ .columnName(),
+ "setManagers",
+ VersionNum.VERSION100,
+ VersionNum.VERSION200);
+ super.setDataHandler(columndesc, managers);
+ }
+
+ /**
+ * Get the Column entity which column name is "manager_options" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "manager_options"
+ */
+ public Column getManagerOptionsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.MANAGEROPTIONS
+ .columnName(),
+ "getManagerOptionsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getDataHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "manager_options" to the Row
+ * entity of attributes.
+ * @param managerOptions the column data which column name is
+ * "manager_options"
+ */
+ public void setManagerOptions(Set<UUID> managerOptions) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.MANAGEROPTIONS
+ .columnName(),
+ "setManagerOptions",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, managerOptions);
+ }
+
+ /**
+ * Get the Column entity which column name is "ssl" from the Row entity of
+ * attributes.
+ * @return the Column entity which column name is "ssl"
+ */
+ public Column getSslColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.SSL
+ .columnName(),
+ "getSslColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getDataHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ssl" to the Row entity of
+ * attributes.
+ * @param ssl the column data which column name is "ssl"
+ */
+ public void setSsl(Set<UUID> ssl) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.SSL
+ .columnName(),
+ "setSsl",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, ssl);
+ }
+
+ /**
+ * Get the Column entity which column name is "other_config" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "other_config"
+ */
+ public Column getOtherConfigColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.OTHERCONFIG
+ .columnName(),
+ "getOtherConfigColumn",
+ VersionNum.VERSION510);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "other_config" to the Row entity
+ * of attributes.
+ * @param otherConfig the column data which column name is "other_config"
+ */
+ public void setOtherConfig(Map<String, String> otherConfig) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.OTHERCONFIG
+ .columnName(),
+ "setOtherConfig",
+ VersionNum.VERSION510);
+ super.setDataHandler(columndesc, otherConfig);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "external_ids"
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.EXTERNALIDS
+ .columnName(),
+ "getExternalIdsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.EXTERNALIDS
+ .columnName(),
+ "setExternalIds",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+ /**
+ * Get the Column entity which column name is "next_cfg" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "next_cfg"
+ */
+ public Column getNextConfigColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.NEXTCFG
+ .columnName(),
+ "getNextConfigColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "next_cfg" to the Row entity of
+ * attributes.
+ * @param nextConfig the column data which column name is "next_cfg"
+ */
+ public void setNextConfig(Long nextConfig) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.NEXTCFG
+ .columnName(),
+ "setNextConfig",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, nextConfig);
+ }
+
+ /**
+ * Get the Column entity which column name is "cur_cfg" from the Row entity
+ * of attributes.
+ * @return the Column entity which column name is "cur_cfg"
+ */
+ public Column getCurrentConfigColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.CURCFG
+ .columnName(),
+ "getCurrentConfigColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "cur_cfg" to the Row entity of
+ * attributes.
+ * @param currentConfig the column data which column name is "cur_cfg"
+ */
+ public void setCurrentConfig(Long currentConfig) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.CURCFG
+ .columnName(),
+ "setCurrentConfig",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, currentConfig);
+ }
+
+ /**
+ * Get the Column entity which column name is "capabilities" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "capabilities"
+ */
+ public Column getCapabilitiesColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.CAPABILITIES
+ .columnName(),
+ "getCapabilitiesColumn",
+ VersionNum.VERSION100,
+ VersionNum.VERSION670);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "capabilities" to the Row entity
+ * of attributes.
+ * @param capabilities the column data which column name is "capabilities"
+ */
+ public void setCapabilities(Map<String, UUID> capabilities) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.CAPABILITIES
+ .columnName(),
+ "setCapabilities",
+ VersionNum.VERSION100,
+ VersionNum.VERSION670);
+ super.setDataHandler(columndesc, capabilities);
+ }
+
+ /**
+ * Get the Column entity which column name is "statistics" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "statistics"
+ */
+ public Column getStatisticsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.STATISTICS
+ .columnName(),
+ "getStatisticsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "statistics" to the Row entity
+ * of attributes.
+ * @param statistics the column data which column name is "statistics"
+ */
+ public void setStatistics(Map<String, Long> statistics) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.STATISTICS
+ .columnName(),
+ "setStatistics",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, statistics);
+ }
+
+ /**
+ * Get the Column entity which column name is "ovs_version" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "ovs_version"
+ */
+ public Column getOvsVersionColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.OVSVERSION
+ .columnName(),
+ "getOvsVersionColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ovs_version" to the Row entity
+ * of attributes.
+ * @param ovsVersion the column data which column name is "ovs_version"
+ */
+ public void setOvsVersion(Set<String> ovsVersion) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.OVSVERSION
+ .columnName(),
+ "setOvsVersion",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, ovsVersion);
+ }
+
+ /**
+ * Get the Column entity which column name is "db_version" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "db_version"
+ */
+ public Column getDbVersionColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.DBVERSION
+ .columnName(),
+ "getDbVersionColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "db_version" to the Row entity
+ * of attributes.
+ * @param dbVersion the column data which column name is "db_version"
+ */
+ public void setDbVersion(Set<String> dbVersion) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.DBVERSION
+ .columnName(),
+ "setDbVersion",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, dbVersion);
+ }
+
+ /**
+ * Get the Column entity which column name is "system_type" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "system_type"
+ */
+ public Column getSystemTypeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.SYSTEMTYPE
+ .columnName(),
+ "getSystemTypeColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "system_type" to the Row entity
+ * of attributes.
+ * @param systemType the column data which column name is "system_type"
+ */
+ public void setSystemType(Set<String> systemType) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.SYSTEMTYPE
+ .columnName(),
+ "setSystemType",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, systemType);
+ }
+
+ /**
+ * Get the Column entity which column name is "system_version" from the Row
+ * entity of attributes.
+ * @return the Column entity which column name is "system_version"
+ */
+ public Column getSystemVersionColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.SYSTEMVERSION
+ .columnName(),
+ "getSystemVersionColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "system_version" to the Row
+ * entity of attributes.
+ * @param systemVersion the column data which column name is
+ * "system_version"
+ */
+ public void setSystemVersion(Set<String> systemVersion) {
+ ColumnDescription columndesc = new ColumnDescription(
+ OpenVSwitchColumn.SYSTEMVERSION
+ .columnName(),
+ "setSystemVersion",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, systemVersion);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OvsdbTable.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OvsdbTable.java
new file mode 100644
index 00000000..2bfe2e79
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/OvsdbTable.java
@@ -0,0 +1,41 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+/**
+ * Ovsdb table name. Refer to RFC7047's Section 9.2.
+ */
+public enum OvsdbTable {
+ INTERFACE("Interface"), BRIDGE("Bridge"), CONTROLLER("Controller"),
+ PORT("Port"), OPENVSWITCH("Open_vSwitch"), FLWTABLE("Flow_Table"),
+ QOS("Qos"), QUEUE("Queue"), MIRROR("Mirror"), MANAGER("Manager"),
+ NETFLOW("NetFlow"), SSL("SSL"), SFLOW("sFlow"), IPFIX("IPFIX"),
+ FLOWSAMPLECOLLECTORSET("Flow_Sample_Collector_Set");
+
+ private final String tableName;
+
+ private OvsdbTable(String tableName) {
+ this.tableName = tableName;
+ }
+
+ /**
+ * Returns the table name for OvsdbTable.
+ * @return the table name
+ */
+ public String tableName() {
+ return tableName;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Port.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Port.java
new file mode 100644
index 00000000..1e1ab7d7
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Port.java
@@ -0,0 +1,590 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Port Table.
+ */
+public class Port extends AbstractOvsdbTableService {
+
+ /**
+ * Port table column name.
+ */
+ public enum PortColumn {
+ NAME("name"), INTERFACES("interfaces"), TRUNKS("trunks"), TAG("tag"),
+ VLANMODE("vlan_mode"), QOS("qos"), MAC("mac"), BONDTYPE("bond_type"),
+ BONDMODE("bond_mode"), LACP("lacp"), BONDUPDELAY("bond_updelay"),
+ BONDDOWNDELAY("bond_downdelay"), BONDFAKEIFACE("bond_fake_iface"),
+ FAKEBRIDGE("fake_bridge"), STATUS("status"), STATISTICS("statistics"),
+ OTHERCONFIG("other_config"), EXTERNALIDS("external_ids");
+
+ private final String columnName;
+
+ private PortColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for PortColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Port object. Generate Port Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Port(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.PORT, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "name" from the Row entity of
+ * attributes.
+ * @return the Column entity
+ */
+ public Column getNameColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.NAME
+ .columnName(),
+ "getNameColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "name" to the Row entity of
+ * attributes.
+ * @param name the column data which column name is "name"
+ */
+ public void setName(String name) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.NAME
+ .columnName(),
+ "setName",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, name);
+ }
+
+ /**
+ * Get the Column entity which column name is "name" from the Row entity of
+ * attributes.
+ * @return the Column entity
+ */
+ public String getName() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.NAME
+ .columnName(),
+ "getName",
+ VersionNum.VERSION100);
+ return (String) super.getDataHandler(columndesc);
+ }
+
+ /**
+ * Get the Column entity which column name is "interfaces" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getInterfacesColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.INTERFACES
+ .columnName(),
+ "getInterfacesColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "interfaces" to the Row entity
+ * of attributes.
+ * @param interfaces the column data which column name is "interfaces"
+ */
+ public void setInterfaces(Set<UUID> interfaces) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.INTERFACES
+ .columnName(),
+ "setInterfaces",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, interfaces);
+ }
+
+ /**
+ * Get the Column entity which column name is "trunks" from the Row entity
+ * of attributes.
+ * @return the Column entity
+ */
+ public Column getTrunksColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.TRUNKS
+ .columnName(),
+ "getTrunksColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "trunks" to the Row entity of
+ * attributes.
+ * @param trunks the column data which column name is "trunks"
+ */
+ public void setTrunks(Set<Long> trunks) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.TRUNKS
+ .columnName(),
+ "setTrunks",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, trunks);
+ }
+
+ /**
+ * Get the Column entity which column name is "tag" from the Row entity of
+ * attributes.
+ * @return the Column entity
+ */
+ public Column getTagColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.TAG
+ .columnName(),
+ "getTagColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "tag" to the Row entity of
+ * attributes.
+ * @param tag the column data which column name is "tag"
+ */
+ public void setTag(Set<Long> tag) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.TAG
+ .columnName(),
+ "setTag",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, tag);
+ }
+
+ /**
+ * Get the Column entity which column name is "vlan_mode" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getVlanModeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.VLANMODE
+ .columnName(),
+ "getVlanModeColumn",
+ VersionNum.VERSION610);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "vlan_mode" to the Row entity of
+ * attributes.
+ * @param vlanMode the column data which column name is "vlan_mode"
+ */
+ public void setVlanMode(Set<String> vlanMode) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.VLANMODE
+ .columnName(),
+ "setVlanMode",
+ VersionNum.VERSION610);
+ super.setDataHandler(columndesc, vlanMode);
+ }
+
+ /**
+ * Get the Column entity which column name is "qos" from the Row entity of
+ * attributes.
+ * @return the Column entity
+ */
+ public Column getQosColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.QOS
+ .columnName(),
+ "getQosColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "qos" to the Row entity of
+ * attributes.
+ * @param qos the column data which column name is "qos"
+ */
+ public void setQos(Set<UUID> qos) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.QOS
+ .columnName(),
+ "setQos",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, qos);
+ }
+
+ /**
+ * Get the Column entity which column name is "mac" from the Row entity of
+ * attributes.
+ * @return the Column entity
+ */
+ public Column getMacColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.MAC
+ .columnName(),
+ "getMacColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "mac" to the Row entity of
+ * attributes.
+ * @param mac the column data which column name is "mac"
+ */
+ public void setMac(Set<String> mac) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.MAC
+ .columnName(),
+ "setMac",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, mac);
+ }
+
+ /**
+ * Get the Column entity which column name is "bond_type" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getBondTypeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.BONDTYPE
+ .columnName(),
+ "getBondTypeColumn",
+ VersionNum.VERSION102,
+ VersionNum.VERSION103);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "bond_type" to the Row entity of
+ * attributes.
+ * @param bondtype the column data which column name is "bond_type"
+ */
+ public void setBondType(Set<String> bondtype) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.BONDTYPE
+ .columnName(),
+ "setBondType",
+ VersionNum.VERSION102,
+ VersionNum.VERSION103);
+ super.setDataHandler(columndesc, bondtype);
+ }
+
+ /**
+ * Get the Column entity which column name is "bond_mode" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getBondModeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.BONDMODE
+ .columnName(),
+ "getBondModeColumn",
+ VersionNum.VERSION104);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "bond_mode" to the Row entity of
+ * attributes.
+ * @param bondmode the column data which column name is "bond_mode"
+ */
+ public void setBondMode(Set<String> bondmode) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.BONDMODE
+ .columnName(),
+ "setBondMode",
+ VersionNum.VERSION104);
+ super.setDataHandler(columndesc, bondmode);
+ }
+
+ /**
+ * Get the Column entity which column name is "lacp" from the Row entity of
+ * attributes.
+ * @return the Column entity
+ */
+ public Column getLacpColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.LACP
+ .columnName(),
+ "getLacpColumn",
+ VersionNum.VERSION130);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "lacp" to the Row entity of
+ * attributes.
+ * @param lacp the column data which column name is "lacp"
+ */
+ public void setLacp(Set<String> lacp) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.LACP
+ .columnName(),
+ "setLacp",
+ VersionNum.VERSION130);
+ super.setDataHandler(columndesc, lacp);
+ }
+
+ /**
+ * Get the Column entity which column name is "bond_updelay" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getBondUpDelayColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.BONDUPDELAY
+ .columnName(),
+ "getBondUpDelayColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "bond_updelay" to the Row entity
+ * of attributes.
+ * @param bondUpDelay the column data which column name is "bond_updelay"
+ */
+ public void setBondUpDelay(Set<Long> bondUpDelay) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.BONDUPDELAY
+ .columnName(),
+ "setBondUpDelay",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, bondUpDelay);
+ }
+
+ /**
+ * Get the Column entity which column name is "bond_downdelay" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getBondDownDelayColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.BONDDOWNDELAY
+ .columnName(),
+ "getBondDownDelayColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "bond_downdelay" to the Row
+ * entity of attributes.
+ * @param bondDownDelay the column data which column name is
+ * "bond_downdelay"
+ */
+ public void setBondDownDelay(Set<Long> bondDownDelay) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.BONDDOWNDELAY
+ .columnName(),
+ "setBondDownDelay",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, bondDownDelay);
+ }
+
+ /**
+ * Get the Column entity which column name is "bond_fake_iface" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getBondFakeInterfaceColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.BONDFAKEIFACE
+ .columnName(),
+ "getBondFakeInterfaceColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "bond_fake_iface" to the Row
+ * entity of attributes.
+ * @param bondFakeInterface the column data which column name is
+ * "bond_fake_iface"
+ */
+ public void setBondFakeInterface(Set<Boolean> bondFakeInterface) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.BONDFAKEIFACE
+ .columnName(),
+ "setBondFakeInterface",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, bondFakeInterface);
+ }
+
+ /**
+ * Get the Column entity which column name is "fake_bridge" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getFakeBridgeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.FAKEBRIDGE
+ .columnName(),
+ "getFakeBridgeColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "fake_bridge" to the Row entity
+ * of attributes.
+ * @param fakeBridge the column data which column name is "fake_bridge"
+ */
+ public void setFakeBridge(Set<Boolean> fakeBridge) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.FAKEBRIDGE
+ .columnName(),
+ "setFakeBridge",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, fakeBridge);
+ }
+
+ /**
+ * Get the Column entity which column name is "status" from the Row entity
+ * of attributes.
+ * @return the Column entity
+ */
+ public Column getStatusColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.STATUS
+ .columnName(),
+ "getStatusColumn",
+ VersionNum.VERSION620);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "status" to the Row entity of
+ * attributes.
+ * @param status the column data which column name is "status"
+ */
+ public void setStatus(Map<String, String> status) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.STATUS
+ .columnName(),
+ "setStatus",
+ VersionNum.VERSION620);
+ super.setDataHandler(columndesc, status);
+ }
+
+ /**
+ * Get the Column entity which column name is "statistics" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getStatisticsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.STATISTICS
+ .columnName(),
+ "getStatisticsColumn",
+ VersionNum.VERSION630);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "statistics" to the Row entity
+ * of attributes.
+ * @param statistics the column data which column name is "statistics"
+ */
+ public void setStatistics(Map<String, Long> statistics) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.STATISTICS
+ .columnName(),
+ "setStatistics",
+ VersionNum.VERSION630);
+ super.setDataHandler(columndesc, statistics);
+ }
+
+ /**
+ * Get the Column entity which column name is "other_config" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getOtherConfigColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.OTHERCONFIG
+ .columnName(),
+ "getOtherConfigColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "other_config" to the Row entity
+ * of attributes.
+ * @param otherConfig the column data which column name is "other_config"
+ */
+ public void setOtherConfig(Map<String, String> otherConfig) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.OTHERCONFIG
+ .columnName(),
+ "setOtherConfig",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, otherConfig);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.EXTERNALIDS
+ .columnName(),
+ "getExternalIdsColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(
+ PortColumn.EXTERNALIDS
+ .columnName(),
+ "setExternalIds",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Qos.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Qos.java
new file mode 100644
index 00000000..a40aa30c
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Qos.java
@@ -0,0 +1,149 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Qos Table.
+ */
+public class Qos extends AbstractOvsdbTableService {
+ /**
+ * Qos table column name.
+ */
+ public enum QosColumn {
+ QUEUES("queues"), TYPE("type"), OTHERCONFIG("other_config"), EXTERNALIDS("external_ids");
+
+ private final String columnName;
+
+ private QosColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for QosColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Qos object. Generate Qos Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Qos(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.QOS, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "queues" from the Row entity
+ * of attributes.
+ * @return the Column entity
+ */
+ public Column getQueuesColumn() {
+ ColumnDescription columndesc = new ColumnDescription(QosColumn.QUEUES.columnName(),
+ "getQueuesColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "queues" to the Row entity of
+ * attributes.
+ * @param queues the column data which column name is "queues"
+ */
+ public void setQueues(Map<Long, UUID> queues) {
+ ColumnDescription columndesc = new ColumnDescription(QosColumn.QUEUES.columnName(), "setQueues",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, queues);
+ }
+
+ /**
+ * Get the Column entity which column name is "type" from the Row entity of
+ * attributes.
+ * @return the Column entity
+ */
+ public Column getTypeColumn() {
+ ColumnDescription columndesc = new ColumnDescription(QosColumn.TYPE.columnName(), "getTypeColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "type" to the Row entity of
+ * attributes.
+ * @param type the column data which column name is "type"
+ */
+ public void setType(Set<String> type) {
+ ColumnDescription columndesc = new ColumnDescription(QosColumn.TYPE.columnName(), "setType",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, type);
+ }
+
+ /**
+ * Get the Column entity which column name is "other_config" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getOtherConfigColumn() {
+ ColumnDescription columndesc = new ColumnDescription(QosColumn.OTHERCONFIG.columnName(),
+ "getOtherConfigColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "other_config" to the Row entity
+ * of attributes.
+ * @param otherConfig the column data which column name is "other_config"
+ */
+ public void setOtherConfig(Map<String, String> otherConfig) {
+ ColumnDescription columndesc = new ColumnDescription(QosColumn.OTHERCONFIG.columnName(),
+ "setOtherConfig", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, otherConfig);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(QosColumn.EXTERNALIDS.columnName(),
+ "getExternalIdsColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(QosColumn.EXTERNALIDS.columnName(),
+ "setExternalIds", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Queue.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Queue.java
new file mode 100644
index 00000000..a89abafc
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Queue.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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Queue Table.
+ */
+public class Queue extends AbstractOvsdbTableService {
+ /**
+ * Queue table column name.
+ */
+ public enum QueueColumn {
+ DSCP("dscp"), OTHERCONFIG("other_config"), EXTERNALIDS("external_ids");
+
+ private final String columnName;
+
+ private QueueColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for QueueColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Queue object. Generate Queue Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Queue(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.QUEUE, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "dscp" from the Row entity of
+ * attributes.
+ * @return the Column entity
+ */
+ public Column getDscpColumn() {
+ ColumnDescription columndesc = new ColumnDescription(QueueColumn.DSCP.columnName(), "getDscpColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "dscp" to the Row entity of
+ * attributes.
+ * @param dscp the column data which column name is "dscp"
+ */
+ public void setDscp(Set<Long> dscp) {
+ ColumnDescription columndesc = new ColumnDescription(QueueColumn.DSCP.columnName(), "setDscp",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, dscp);
+ }
+
+ /**
+ * Get the Column entity which column name is "other_config" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getOtherConfigColumn() {
+ ColumnDescription columndesc = new ColumnDescription(QueueColumn.OTHERCONFIG.columnName(),
+ "getOtherConfigColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "other_config" to the Row entity
+ * of attributes.
+ * @param otherConfig the column data which column name is "other_config"
+ */
+ public void setOtherConfig(Map<String, String> otherConfig) {
+ ColumnDescription columndesc = new ColumnDescription(QueueColumn.OTHERCONFIG.columnName(),
+ "setOtherConfig", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, otherConfig);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(QueueColumn.EXTERNALIDS.columnName(),
+ "getExternalIdsColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(QueueColumn.EXTERNALIDS.columnName(),
+ "setExternalIds", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Sflow.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Sflow.java
new file mode 100644
index 00000000..142f66e3
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Sflow.java
@@ -0,0 +1,193 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Sflow Table.
+ */
+public class Sflow extends AbstractOvsdbTableService {
+ /**
+ * Sflow table column name.
+ */
+ public enum SflowColumn {
+ TARGETS("targets"), AGENT("agent"), EXTERNALIDS("external_ids"), HAEDER("header"),
+ POLLING("polling"), SAMPLING("sampling");
+
+ private final String columnName;
+
+ private SflowColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for SflowColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Sflow object. Generate Sflow Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Sflow(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.SFLOW, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "targets" from the Row entity
+ * of attributes.
+ * @return the Column entity
+ */
+ public Column getTargetsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.TARGETS.columnName(),
+ "getTargetsColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "targets" to the Row entity of
+ * attributes.
+ * @param targets the column data which column name is "targets"
+ */
+ public void setTargets(Set<String> targets) {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.TARGETS.columnName(), "setTargets",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, targets);
+ }
+
+ /**
+ * Get the Column entity which column name is "agent" from the Row entity of
+ * attributes.
+ * @return the Column entity
+ */
+ public Column getAgentColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.AGENT.columnName(),
+ "getAgentColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "agent" to the Row entity of
+ * attributes.
+ * @param agent the column data which column name is "agent"
+ */
+ public void setAgent(Set<String> agent) {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.AGENT.columnName(), "setAgent",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, agent);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.EXTERNALIDS.columnName(),
+ "getExternalIdsColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.EXTERNALIDS.columnName(),
+ "setExternalIds", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+ /**
+ * Get the Column entity which column name is "header" from the Row entity
+ * of attributes.
+ * @return the Column entity
+ */
+ public Column getHeaderColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.HAEDER.columnName(),
+ "getHeaderColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "header" to the Row entity of
+ * attributes.
+ * @param header the column data which column name is "header"
+ */
+ public void setHeader(Set<Long> header) {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.HAEDER.columnName(), "setHeader",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, header);
+ }
+
+ /**
+ * Get the Column entity which column name is "polling" from the Row entity
+ * of attributes.
+ * @return the Column entity
+ */
+ public Column getPollingColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.POLLING.columnName(),
+ "getPollingColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "polling" to the Row entity of
+ * attributes.
+ * @param polling the column data which column name is "polling"
+ */
+ public void setPolling(Set<Long> polling) {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.POLLING.columnName(), "setPolling",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, polling);
+ }
+
+ /**
+ * Get the Column entity which column name is "sampling" from the Row entity
+ * of attributes.
+ * @return the Column entity
+ */
+ public Column getSamplingColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.SAMPLING.columnName(),
+ "getSamplingColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "sampling" to the Row entity of
+ * attributes.
+ * @param sampling the column data which column name is "sampling"
+ */
+ public void setSampling(Set<Long> sampling) {
+ ColumnDescription columndesc = new ColumnDescription(SflowColumn.SAMPLING.columnName(),
+ "setSampling", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, sampling);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Ssl.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Ssl.java
new file mode 100644
index 00000000..188dee52
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/Ssl.java
@@ -0,0 +1,172 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import java.util.Map;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.tableservice.AbstractOvsdbTableService;
+import org.onosproject.ovsdb.rfc.tableservice.ColumnDescription;
+
+/**
+ * This class provides operations of Ssl Table.
+ */
+public class Ssl extends AbstractOvsdbTableService {
+ /**
+ * Ssl table column name.
+ */
+ public enum SslColumn {
+ CACERT("ca_cert"), EXTERNALIDS("external_ids"), BOOTSTRAPCACERT("bootstrap_ca_cert"),
+ CERTIFICATE("certificate"), PRIVATEKEY("private_key");
+
+ private final String columnName;
+
+ private SslColumn(String columnName) {
+ this.columnName = columnName;
+ }
+
+ /**
+ * Returns the table column name for SslColumn.
+ * @return the table column name
+ */
+ public String columnName() {
+ return columnName;
+ }
+ }
+
+ /**
+ * Constructs a Ssl object. Generate Ssl Table Description.
+ * @param dbSchema DatabaseSchema
+ * @param row Row
+ */
+ public Ssl(DatabaseSchema dbSchema, Row row) {
+ super(dbSchema, row, OvsdbTable.SSL, VersionNum.VERSION100);
+ }
+
+ /**
+ * Get the Column entity which column name is "ca_cert" from the Row entity
+ * of attributes.
+ * @return the Column entity
+ */
+ public Column getCaCertColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SslColumn.CACERT.columnName(),
+ "getCaCertColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "ca_cert" to the Row entity of
+ * attributes.
+ * @param caCert the column data which column name is "ca_cert"
+ */
+ public void setCaCert(String caCert) {
+ ColumnDescription columndesc = new ColumnDescription(SslColumn.CACERT.columnName(), "setCaCert",
+ VersionNum.VERSION100);
+ super.setDataHandler(columndesc, caCert);
+ }
+
+ /**
+ * Get the Column entity which column name is "external_ids" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getExternalIdsColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SslColumn.EXTERNALIDS.columnName(),
+ "getExternalIdsColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "external_ids" to the Row entity
+ * of attributes.
+ * @param externalIds the column data which column name is "external_ids"
+ */
+ public void setExternalIds(Map<String, String> externalIds) {
+ ColumnDescription columndesc = new ColumnDescription(SslColumn.EXTERNALIDS.columnName(),
+ "setExternalIds", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, externalIds);
+ }
+
+ /**
+ * Get the Column entity which column name is "bootstrap_ca_cert" from the
+ * Row entity of attributes.
+ * @return the Column entity
+ */
+ public Column getBootstrapCaCertColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SslColumn.BOOTSTRAPCACERT.columnName(),
+ "getBootstrapCaCertColumn",
+ VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "bootstrap_ca_cert" to the Row
+ * entity of attributes.
+ * @param bootstrapCaCert the column data which column name is
+ * "bootstrap_ca_cert"
+ */
+ public void setBootstrapCaCert(Boolean bootstrapCaCert) {
+ ColumnDescription columndesc = new ColumnDescription(SslColumn.BOOTSTRAPCACERT.columnName(),
+ "setBootstrapCaCert", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, bootstrapCaCert);
+ }
+
+ /**
+ * Get the Column entity which column name is "certificate" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getCertificateColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SslColumn.CERTIFICATE.columnName(),
+ "getCertificateColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "certificate" to the Row entity
+ * of attributes.
+ * @param certificate the column data which column name is "certificate"
+ */
+ public void setCertificate(String certificate) {
+ ColumnDescription columndesc = new ColumnDescription(SslColumn.CERTIFICATE.columnName(),
+ "setCertificate", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, certificate);
+ }
+
+ /**
+ * Get the Column entity which column name is "private_key" from the Row
+ * entity of attributes.
+ * @return the Column entity
+ */
+ public Column getPrivateKeyColumn() {
+ ColumnDescription columndesc = new ColumnDescription(SslColumn.PRIVATEKEY.columnName(),
+ "getPrivateKeyColumn", VersionNum.VERSION100);
+ return (Column) super.getColumnHandler(columndesc);
+ }
+
+ /**
+ * Add a Column entity which column name is "private_key" to the Row entity
+ * of attributes.
+ * @param privatekey the column data which column name is "private_key"
+ */
+ public void setPrivateKey(String privatekey) {
+ ColumnDescription columndesc = new ColumnDescription(SslColumn.PRIVATEKEY.columnName(),
+ "setPrivateKey", VersionNum.VERSION100);
+ super.setDataHandler(columndesc, privatekey);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/TableGenerator.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/TableGenerator.java
new file mode 100644
index 00000000..f5bd860d
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/TableGenerator.java
@@ -0,0 +1,103 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+
+/**
+ * Table generator.
+ */
+public final class TableGenerator {
+
+ /**
+ * Constructs a TableGenerator object. Utility classes should not have a
+ * public or default constructor, otherwise it will compile failed. This
+ * class should not be instantiated.
+ */
+ private TableGenerator() {
+ }
+
+ /**
+ * Create table.
+ * @param dbSchema DatabaseSchema entity
+ * @param tableName table name
+ * @return Object table entity
+ */
+ //FIXME change the name, it creates a row object, such as a controller.
+ public static Object createTable(DatabaseSchema dbSchema,
+ OvsdbTable tableName) {
+ Row row = new Row();
+ return generateTable(dbSchema, row, tableName);
+ }
+
+ /**
+ * Get table from Row.
+ * @param dbSchema DatabaseSchema entity
+ * @param row Row entity
+ * @param tableName table name
+ * @return Object table entity
+ */
+ public static Object getTable(DatabaseSchema dbSchema, Row row,
+ OvsdbTable tableName) {
+ return generateTable(dbSchema, row, tableName);
+ }
+
+ /**
+ * Generate the table by table name.
+ * @param dbSchema DatabaseSchema entity
+ * @param row Row entity
+ * @param tableName table name
+ * @return Object Table entity
+ */
+ private static Object generateTable(DatabaseSchema dbSchema, Row row,
+ OvsdbTable tableName) {
+ switch (tableName) {
+ case INTERFACE:
+ return new Interface(dbSchema, row);
+ case BRIDGE:
+ return new Bridge(dbSchema, row);
+ case CONTROLLER:
+ return new Controller(dbSchema, row);
+ case OPENVSWITCH:
+ return new OpenVSwitch(dbSchema, row);
+ case PORT:
+ return new Port(dbSchema, row);
+ case FLWTABLE:
+ return new FlowTable(dbSchema, row);
+ case QOS:
+ return new Qos(dbSchema, row);
+ case QUEUE:
+ return new Queue(dbSchema, row);
+ case MIRROR:
+ return new Mirror(dbSchema, row);
+ case MANAGER:
+ return new Manager(dbSchema, row);
+ case NETFLOW:
+ return new Netflow(dbSchema, row);
+ case SSL:
+ return new Ssl(dbSchema, row);
+ case SFLOW:
+ return new Sflow(dbSchema, row);
+ case IPFIX:
+ return new Ipfix(dbSchema, row);
+ case FLOWSAMPLECOLLECTORSET:
+ return new FlowSampleCollectorSet(dbSchema, row);
+ default:
+ return null;
+ }
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/VersionNum.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/VersionNum.java
new file mode 100644
index 00000000..8b356420
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/VersionNum.java
@@ -0,0 +1,47 @@
+/*
+ * 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.ovsdb.rfc.table;
+
+/**
+ * The version number of tables and columns.
+ */
+public enum VersionNum {
+ VERSION100("1.0.0"), VERSION102("1.0.2"), VERSION103("1.0.3"),
+ VERSION104("1.0.4"), VERSION106("1.0.6"), VERSION110("1.1.0"),
+ VERSION130("1.3.0"), VERSION200("2.0.0"), VERSION300("3.0.0"),
+ VERSION330("3.3.0"), VERSION350("3.5.0"), VERSION400("4.0.0"),
+ VERSION510("5.1.0"), VERSION520("5.2.0"), VERSION600("6.0.0"),
+ VERSION610("6.1.0"), VERSION620("6.2.0"), VERSION630("6.3.0"),
+ VERSION640("6.4.0"), VERSION650("6.5.0"), VERSION660("6.6.0"),
+ VERSION670("6.7.0"), VERSION680("6.8.0"), VERSION690("6.9.0"),
+ VERSION6100("6.10.0"), VERSION6111("6.11.1"), VERSION710("7.1.0"),
+ VERSION720("7.2.0"), VERSION721("7.2.1"), VERSION730("7.3.0"),
+ VERSION740("7.4.0"), VERSION750("7.5.0"), VERSION770("7.7.0");
+
+ private final String versionNum;
+
+ private VersionNum(String versionNum) {
+ this.versionNum = versionNum;
+ }
+
+ /**
+ * Returns the version number for VersionNum.
+ * @return the version number
+ */
+ public String versionNum() {
+ return versionNum;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/package-info.java
new file mode 100644
index 00000000..e235b168
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/table/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.
+ */
+
+/**
+ * OVSDB table definitions.
+ */
+package org.onosproject.ovsdb.rfc.table;
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/AbstractOvsdbTableService.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/AbstractOvsdbTableService.java
new file mode 100644
index 00000000..af1a01d6
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/AbstractOvsdbTableService.java
@@ -0,0 +1,284 @@
+/*
+ * 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.ovsdb.rfc.tableservice;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.ovsdb.rfc.exception.ColumnSchemaNotFoundException;
+import org.onosproject.ovsdb.rfc.exception.TableSchemaNotFoundException;
+import org.onosproject.ovsdb.rfc.exception.VersionMismatchException;
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.schema.ColumnSchema;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+import org.onosproject.ovsdb.rfc.table.OvsdbTable;
+import org.onosproject.ovsdb.rfc.table.VersionNum;
+import org.onosproject.ovsdb.rfc.utils.VersionUtil;
+
+/**
+ * Representation of conversion between Ovsdb table and Row.
+ */
+public abstract class AbstractOvsdbTableService implements OvsdbTableService {
+
+ private final DatabaseSchema dbSchema;
+ private final Row row;
+ private final TableDescription tableDesc;
+
+ /**
+ * Constructs a AbstractOvsdbTableService object.
+ * @param dbSchema DatabaseSchema entity
+ * @param row Row entity
+ * @param table table name
+ * @param formVersion the initial version
+ */
+ public AbstractOvsdbTableService(DatabaseSchema dbSchema, Row row, OvsdbTable table,
+ VersionNum formVersion) {
+ checkNotNull(dbSchema, "database schema cannot be null");
+ checkNotNull(row, "row cannot be null");
+ checkNotNull(table, "table cannot be null");
+ checkNotNull(formVersion, "the initial version cannot be null");
+ this.dbSchema = dbSchema;
+ row.setTableName(table.tableName());
+ this.row = row;
+ TableDescription tableDesc = new TableDescription(table, formVersion);
+ this.tableDesc = tableDesc;
+ }
+
+ /**
+ * Check whether the parameter of dbSchema is valid and check whether the
+ * table is existent in Database Schema.
+ */
+ private boolean isValid() {
+ if (dbSchema == null) {
+ return false;
+ }
+ if (!dbSchema.name().equalsIgnoreCase(tableDesc.database())) {
+ return false;
+ }
+ checkTableSchemaVersion();
+ return true;
+ }
+
+ /**
+ * Check the table version.
+ */
+ private void checkTableSchemaVersion() {
+ String fromVersion = tableDesc.fromVersion();
+ String untilVersion = tableDesc.untilVersion();
+ String schemaVersion = dbSchema.version();
+ checkVersion(schemaVersion, fromVersion, untilVersion);
+ }
+
+ /**
+ * Check the column version.
+ * @param columnDesc ColumnDescription entity
+ */
+ private void checkColumnSchemaVersion(ColumnDescription columnDesc) {
+ String fromVersion = columnDesc.fromVersion();
+ String untilVersion = columnDesc.untilVersion();
+ String schemaVersion = dbSchema.version();
+ checkVersion(schemaVersion, fromVersion, untilVersion);
+ }
+
+ /**
+ * Check whether the DatabaseSchema version between the initial version and
+ * the end of the version.
+ * @param schemaVersion DatabaseSchema version
+ * @param fromVersion The initial version
+ * @param untilVersion The end of the version
+ * @throws VersionMismatchException this is a version mismatch exception
+ */
+ private void checkVersion(String schemaVersion, String fromVersion, String untilVersion) {
+ VersionUtil.versionMatch(fromVersion);
+ VersionUtil.versionMatch(untilVersion);
+ if (!fromVersion.equals(VersionUtil.DEFAULT_VERSION_STRING)) {
+ if (VersionUtil.versionCompare(schemaVersion, fromVersion) < 0) {
+ String message = VersionMismatchException.createFromMessage(schemaVersion,
+ fromVersion);
+ throw new VersionMismatchException(message);
+ }
+ }
+ if (!untilVersion.equals(VersionUtil.DEFAULT_VERSION_STRING)) {
+ if (VersionUtil.versionCompare(untilVersion, schemaVersion) < 0) {
+ String message = VersionMismatchException.createToMessage(schemaVersion,
+ untilVersion);
+ throw new VersionMismatchException(message);
+ }
+ }
+ }
+
+ /**
+ * Returns TableSchema from dbSchema by table name.
+ * @return TableSchema
+ */
+ private TableSchema getTableSchema() {
+ String tableName = tableDesc.name();
+ return dbSchema.getTableSchema(tableName);
+ }
+
+ /**
+ * Returns ColumnSchema from TableSchema by column name.
+ * @param columnName column name
+ * @return ColumnSchema
+ */
+ private ColumnSchema getColumnSchema(String columnName) {
+ TableSchema tableSchema = getTableSchema();
+ if (tableSchema == null) {
+ String message = TableSchemaNotFoundException.createMessage(tableDesc.name(),
+ dbSchema.name());
+ throw new TableSchemaNotFoundException(message);
+ }
+ ColumnSchema columnSchema = tableSchema.getColumnSchema(columnName);
+ if (columnSchema == null) {
+ String message = ColumnSchemaNotFoundException.createMessage(columnName,
+ tableSchema.name());
+ throw new ColumnSchemaNotFoundException(message);
+ }
+ return columnSchema;
+ }
+
+ @Override
+ public Column getColumnHandler(ColumnDescription columnDesc) {
+ if (!isValid()) {
+ return null;
+ }
+ String columnName = columnDesc.name();
+ checkColumnSchemaVersion(columnDesc);
+ ColumnSchema columnSchema = getColumnSchema(columnName);
+ if (row == null) {
+ return null;
+ }
+ return row.getColumn(columnSchema.name());
+ }
+
+ @Override
+ public Object getDataHandler(ColumnDescription columnDesc) {
+ if (!isValid()) {
+ return null;
+ }
+ String columnName = columnDesc.name();
+ checkColumnSchemaVersion(columnDesc);
+ ColumnSchema columnSchema = getColumnSchema(columnName);
+ if (row == null || row.getColumn(columnSchema.name()) == null) {
+ return null;
+ }
+ return row.getColumn(columnSchema.name()).data();
+ }
+
+ @Override
+ public void setDataHandler(ColumnDescription columnDesc, Object obj) {
+ if (!isValid()) {
+ return;
+ }
+ String columnName = columnDesc.name();
+ checkColumnSchemaVersion(columnDesc);
+ ColumnSchema columnSchema = getColumnSchema(columnName);
+ Column column = new Column(columnSchema.name(), obj);
+ row.addColumn(columnName, column);
+ }
+
+ @Override
+ public UUID getTableUuid() {
+ if (!isValid()) {
+ return null;
+ }
+ ColumnDescription columnDesc = new ColumnDescription("_uuid", "getTableUuid");
+ return (UUID) getDataHandler(columnDesc);
+ }
+
+ @Override
+ public Column getTableUuidColumn() {
+ if (!isValid()) {
+ return null;
+ }
+ ColumnDescription columnDesc = new ColumnDescription("_uuid", "getTableUuidColumn");
+ return getColumnHandler(columnDesc);
+ }
+
+ @Override
+ public UUID getTableVersion() {
+ if (!isValid()) {
+ return null;
+ }
+ ColumnDescription columnDesc = new ColumnDescription("_version", "getTableVersion");
+ return (UUID) getDataHandler(columnDesc);
+ }
+
+ @Override
+ public Column getTableVersionColumn() {
+ if (!isValid()) {
+ return null;
+ }
+ ColumnDescription columnDesc = new ColumnDescription("_version", "getTableVersionColumn");
+ return getColumnHandler(columnDesc);
+ }
+
+ /**
+ * Get DatabaseSchema entity.
+ * @return DatabaseSchema entity
+ */
+ public DatabaseSchema dbSchema() {
+ return dbSchema;
+ }
+
+ /**
+ * Get Row entity.
+ * @return Row entity
+ */
+ public Row getRow() {
+ if (!isValid()) {
+ return null;
+ }
+ return this.row;
+ }
+
+ /**
+ * Get TableDescription entity.
+ * @return TableDescription entity
+ */
+ public TableDescription tableDesc() {
+ return tableDesc;
+ }
+
+ @Override
+ public int hashCode() {
+ return row.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof AbstractOvsdbTableService) {
+ final AbstractOvsdbTableService other = (AbstractOvsdbTableService) obj;
+ return Objects.equals(this.row, other.row);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ TableSchema schema = getTableSchema();
+ String tableName = schema.name();
+ return toStringHelper(this).add("tableName", tableName).add("row", row).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/ColumnDescription.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/ColumnDescription.java
new file mode 100644
index 00000000..910b3296
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/ColumnDescription.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.ovsdb.rfc.tableservice;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.ovsdb.rfc.table.VersionNum;
+import org.onosproject.ovsdb.rfc.utils.VersionUtil;
+
+/**
+ * Column description.
+ */
+public class ColumnDescription {
+
+ // The column name
+ private final String name;
+ // The method name
+ private final String method;
+ // The initial version
+ private final String fromVersion;
+ // The end of the version
+ private final String untilVersion;
+
+ /**
+ * Constructs a MonitorRequest object.
+ * @param name column name
+ * @param method method name
+ */
+ public ColumnDescription(String name, String method) {
+ checkNotNull(name, "name cannot be null");
+ checkNotNull(method, "method cannot be null");
+ this.name = name;
+ this.method = method;
+ this.fromVersion = VersionUtil.DEFAULT_VERSION_STRING;
+ this.untilVersion = VersionUtil.DEFAULT_VERSION_STRING;
+ }
+
+ /**
+ * Constructs a MonitorRequest object.
+ * @param name column name
+ * @param method method name
+ * @param fromVersion the initial version
+ */
+ public ColumnDescription(String name, String method, VersionNum fromVersion) {
+ checkNotNull(name, "name cannot be null");
+ checkNotNull(method, "method cannot be null");
+ checkNotNull(fromVersion, "the initial version cannot be null");
+ this.name = name;
+ this.method = method;
+ this.fromVersion = fromVersion.versionNum();
+ this.untilVersion = VersionUtil.DEFAULT_VERSION_STRING;
+ }
+
+ /**
+ * Constructs a MonitorRequest object.
+ * @param name column name
+ * @param method method name
+ * @param fromVersion the initial version
+ * @param untilVersion the end of the version
+ */
+ public ColumnDescription(String name, String method, VersionNum fromVersion,
+ VersionNum untilVersion) {
+ checkNotNull(name, "name cannot be null");
+ checkNotNull(method, "method cannot be null");
+ checkNotNull(fromVersion, "the initial version cannot be null");
+ checkNotNull(untilVersion, "the end of the version cannot be null");
+ this.name = name;
+ this.method = method;
+ this.fromVersion = fromVersion.versionNum();
+ this.untilVersion = untilVersion.versionNum();
+ }
+
+ /**
+ * Returns the column name.
+ * @return the column name
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * Returns the method name.
+ * @return the method name
+ */
+ public String method() {
+ return method;
+ }
+
+ /**
+ * Returns the initial version.
+ * @return the initial version
+ */
+ public String fromVersion() {
+ return fromVersion;
+ }
+
+ /**
+ * Returns the end of the version.
+ * @return the end of the version
+ */
+ public String untilVersion() {
+ return untilVersion;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/OvsdbTableService.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/OvsdbTableService.java
new file mode 100644
index 00000000..58b656ef
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/OvsdbTableService.java
@@ -0,0 +1,70 @@
+/*
+ * 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.ovsdb.rfc.tableservice;
+
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+
+/**
+ * Representation of conversion between Ovsdb table and Row.
+ */
+public interface OvsdbTableService {
+
+ /**
+ * Get Column from row.
+ * @param columndesc Column description
+ * @return Column
+ */
+ public Column getColumnHandler(ColumnDescription columndesc);
+
+ /**
+ * Get Data from row.
+ * @param columndesc Column description
+ * @return Object column data
+ */
+ public Object getDataHandler(ColumnDescription columndesc);
+
+ /**
+ * Set column data of row.
+ * @param columndesc Column description
+ * @param obj column data
+ */
+ public void setDataHandler(ColumnDescription columndesc, Object obj);
+
+ /**
+ * Returns UUID which column name is _uuid.
+ * @return UUID
+ */
+ public UUID getTableUuid();
+
+ /**
+ * Returns UUID Column which column name is _uuid.
+ * @return UUID Column
+ */
+ public Column getTableUuidColumn();
+
+ /**
+ * Returns UUID which column name is _version.
+ * @return UUID
+ */
+ public UUID getTableVersion();
+
+ /**
+ * Returns UUID Column which column name is _version.
+ * @return UUID Column
+ */
+ public Column getTableVersionColumn();
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/TableDescription.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/TableDescription.java
new file mode 100644
index 00000000..d120cab8
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/TableDescription.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.ovsdb.rfc.tableservice;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.ovsdb.rfc.table.OvsdbTable;
+import org.onosproject.ovsdb.rfc.table.VersionNum;
+import org.onosproject.ovsdb.rfc.utils.VersionUtil;
+
+/**
+ * Table description.
+ */
+public class TableDescription {
+
+ // The table name
+ private final String name;
+ // The database name
+ private final String database = "Open_vSwitch";
+ // The initial version
+ private final String fromVersion;
+ // The end of the version
+ private final String untilVersion;
+
+ /**
+ * Constructs a MonitorRequest object.
+ * @param table OvsdbTable entity
+ */
+ public TableDescription(OvsdbTable table) {
+ checkNotNull(table, "table cannot be null");
+ this.name = table.tableName();
+ this.fromVersion = VersionUtil.DEFAULT_VERSION_STRING;
+ this.untilVersion = VersionUtil.DEFAULT_VERSION_STRING;
+ }
+
+ /**
+ * Constructs a MonitorRequest object.
+ * @param table OvsdbTable entity
+ * @param fromVersion the initial version
+ */
+ public TableDescription(OvsdbTable table, VersionNum fromVersion) {
+ checkNotNull(table, "table cannot be null");
+ checkNotNull(fromVersion, "the initial version cannot be null");
+ this.name = table.tableName();
+ this.fromVersion = fromVersion.versionNum();
+ this.untilVersion = VersionUtil.DEFAULT_VERSION_STRING;
+ }
+
+ /**
+ * Constructs a MonitorRequest object.
+ * @param table OvsdbTable entity
+ * @param fromVersion the initial version
+ * @param untilVersion the end of the version
+ */
+ public TableDescription(OvsdbTable table, VersionNum fromVersion, VersionNum untilVersion) {
+ checkNotNull(table, "table cannot be null");
+ checkNotNull(fromVersion, "the initial version cannot be null");
+ checkNotNull(untilVersion, "the end of the version cannot be null");
+ this.name = table.tableName();
+ this.fromVersion = fromVersion.versionNum();
+ this.untilVersion = untilVersion.versionNum();
+ }
+
+ /**
+ * Returns the column name.
+ * @return the column name
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * Returns the database name.
+ * @return the database name
+ */
+ public String database() {
+ return database;
+ }
+
+ /**
+ * Returns the initial version.
+ * @return the initial version
+ */
+ public String fromVersion() {
+ return fromVersion;
+ }
+
+ /**
+ * Returns the end of the version.
+ * @return the end of the version
+ */
+ public String untilVersion() {
+ return untilVersion;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/package-info.java
new file mode 100644
index 00000000..cc607da7
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/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.
+ */
+
+/**
+ * OVSDB table service definitions.
+ */
+package org.onosproject.ovsdb.rfc.tableservice;
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ConditionUtil.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ConditionUtil.java
new file mode 100644
index 00000000..527b8bfe
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ConditionUtil.java
@@ -0,0 +1,122 @@
+/*
+ * 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.ovsdb.rfc.utils;
+
+import org.onosproject.ovsdb.rfc.notation.Condition;
+import org.onosproject.ovsdb.rfc.notation.Condition.Function;
+
+/**
+ * Condition utility class.
+ */
+public final class ConditionUtil {
+
+ /**
+ * Constructs a ConditionUtil object. Utility classes should not have a
+ * public or default constructor, otherwise IDE will compile unsuccessfully. This
+ * class should not be instantiated.
+ */
+ private ConditionUtil() {
+ }
+
+ /**
+ * Returns a Condition that means Function.EQUALS .
+ * @param columnName column name
+ * @param data column value
+ * @return Condition
+ */
+ public static Condition equals(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Condition(columnName, Function.EQUALS, value);
+ }
+
+ /**
+ * Returns a Condition that means Function.NOT_EQUALS .
+ * @param columnName column name
+ * @param data column value
+ * @return Condition
+ */
+ public static Condition unEquals(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Condition(columnName, Function.NOT_EQUALS, value);
+ }
+
+ /**
+ * Returns a Condition that means Function.GREATER_THAN .
+ * @param columnName column name
+ * @param data column value
+ * @return Condition
+ */
+ public static Condition greaterThan(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Condition(columnName, Function.GREATER_THAN, value);
+ }
+
+ /**
+ * Returns a Condition that means Function.GREATER_THAN_OR_EQUALS .
+ * @param columnName column name
+ * @param data column value
+ * @return Condition
+ */
+ public static Condition greaterThanOrEquals(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Condition(columnName, Function.GREATER_THAN_OR_EQUALS, value);
+ }
+
+ /**
+ * Returns a Condition that means Function.LESS_THAN .
+ * @param columnName column name
+ * @param data column value
+ * @return Condition
+ */
+ public static Condition lesserThan(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Condition(columnName, Function.LESS_THAN, value);
+ }
+
+ /**
+ * Returns a Condition that means Function.LESS_THAN_OR_EQUALS .
+ * @param columnName column name
+ * @param data column value
+ * @return Condition
+ */
+ public static Condition lesserThanOrEquals(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Condition(columnName, Function.LESS_THAN_OR_EQUALS, value);
+ }
+
+ /**
+ * Returns a Condition that means Function.INCLUDES .
+ * @param columnName column name
+ * @param data column value
+ * @return Condition
+ */
+ public static Condition includes(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Condition(columnName, Function.INCLUDES, value);
+ }
+
+ /**
+ * Returns a Condition that means Function.EXCLUDES .
+ * @param columnName column name
+ * @param data column value
+ * @return Condition
+ */
+ public static Condition excludes(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Condition(columnName, Function.EXCLUDES, value);
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/FromJsonUtil.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/FromJsonUtil.java
new file mode 100644
index 00000000..1dcf48f3
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/FromJsonUtil.java
@@ -0,0 +1,319 @@
+/*
+ * 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.ovsdb.rfc.utils;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.onosproject.ovsdb.rfc.exception.AbnormalJsonNodeException;
+import org.onosproject.ovsdb.rfc.exception.UnsupportedException;
+import org.onosproject.ovsdb.rfc.jsonrpc.Callback;
+import org.onosproject.ovsdb.rfc.jsonrpc.JsonRpcResponse;
+import org.onosproject.ovsdb.rfc.message.OperationResult;
+import org.onosproject.ovsdb.rfc.message.RowUpdate;
+import org.onosproject.ovsdb.rfc.message.TableUpdate;
+import org.onosproject.ovsdb.rfc.message.TableUpdates;
+import org.onosproject.ovsdb.rfc.message.UpdateNotification;
+import org.onosproject.ovsdb.rfc.notation.Column;
+import org.onosproject.ovsdb.rfc.notation.Row;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.operations.Operation;
+import org.onosproject.ovsdb.rfc.schema.ColumnSchema;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+import org.onosproject.ovsdb.rfc.schema.type.ColumnTypeFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * JsonNode utility class. convert JsonNode into Object.
+ */
+public final class FromJsonUtil {
+
+ private static final Logger log = LoggerFactory.getLogger(FromJsonUtil.class);
+
+ /**
+ * Constructs a FromJsonUtil object. Utility classes should not have a
+ * public or default constructor, otherwise IDE will compile unsuccessfully.
+ * This class should not be instantiated.
+ */
+ private FromJsonUtil() {
+ }
+
+ /**
+ * Verify whether the jsonNode is normal.
+ * @param jsonNode JsonNode
+ * @param nodeStr the node name of JsonNode
+ */
+ private static void validateJsonNode(JsonNode jsonNode, String nodeStr) {
+ if (!jsonNode.isObject() || !jsonNode.has(nodeStr)) {
+ String message = "Abnormal DatabaseSchema JsonNode, it should contain " + nodeStr
+ + " node but was not found";
+ throw new AbnormalJsonNodeException(message);
+ }
+ }
+
+ /**
+ * convert JsonNode into DatabaseSchema.
+ * @param dbName database name
+ * @param dbJson the JsonNode of get_schema result
+ * @return DatabaseSchema
+ * @throws AbnormalJsonNodeException this is an abnormal JsonNode exception
+ */
+ public static DatabaseSchema jsonNodeToDbSchema(String dbName, JsonNode dbJson) {
+ validateJsonNode(dbJson, "tables");
+ validateJsonNode(dbJson, "version");
+ String dbVersion = dbJson.get("version").asText();
+ Map<String, TableSchema> tables = new HashMap<>();
+ Iterator<Map.Entry<String, JsonNode>> tablesIter = dbJson.get("tables").fields();
+ while (tablesIter.hasNext()) {
+ Map.Entry<String, JsonNode> table = tablesIter.next();
+ tables.put(table.getKey(), jsonNodeToTableSchema(table.getKey(), table.getValue()));
+ }
+ return new DatabaseSchema(dbName, dbVersion, tables);
+ }
+
+ /**
+ * convert JsonNode into TableSchema.
+ * @param tableName table name
+ * @param tableJson table JsonNode
+ * @return TableSchema
+ * @throws AbnormalJsonNodeException this is an abnormal JsonNode exception
+ */
+ private static TableSchema jsonNodeToTableSchema(String tableName, JsonNode tableJson) {
+ validateJsonNode(tableJson, "columns");
+ Map<String, ColumnSchema> columns = new HashMap<>();
+ Iterator<Map.Entry<String, JsonNode>> columnsIter = tableJson.get("columns").fields();
+ while (columnsIter.hasNext()) {
+ Map.Entry<String, JsonNode> column = columnsIter.next();
+ columns.put(column.getKey(), jsonNodeToColumnSchema(column.getKey(), column.getValue()));
+ }
+ return new TableSchema(tableName, columns);
+ }
+
+ /**
+ * convert JsonNode into ColumnSchema.
+ * @param name column name
+ * @param columnJson column JsonNode
+ * @return ColumnSchema
+ * @throws AbnormalJsonNodeException this is an abnormal JsonNode exception
+ */
+ private static ColumnSchema jsonNodeToColumnSchema(String name, JsonNode columnJson) {
+ validateJsonNode(columnJson, "type");
+ return new ColumnSchema(name, ColumnTypeFactory.getColumnTypeFromJson(columnJson
+ .get("type")));
+ }
+
+ /**
+ * convert JsonNode into the returnType of methods in OvsdbRPC class.
+ * @param resultJsonNode the result JsonNode
+ * @param methodName the method name of methods in OvsdbRPC class
+ * @param objectMapper ObjectMapper entity
+ * @return Object
+ * @throws UnsupportedException this is an unsupported exception
+ */
+ private static Object convertResultType(JsonNode resultJsonNode, String methodName,
+ ObjectMapper objectMapper) {
+ switch (methodName) {
+ case "getSchema":
+ case "monitor":
+ return resultJsonNode;
+ case "echo":
+ case "listDbs":
+ return objectMapper.convertValue(resultJsonNode, objectMapper.getTypeFactory()
+ .constructParametricType(List.class, String.class));
+ case "transact":
+ return objectMapper.convertValue(resultJsonNode, objectMapper.getTypeFactory()
+ .constructParametricType(List.class, JsonNode.class));
+ default:
+ throw new UnsupportedException("does not support this rpc method" + methodName);
+ }
+ }
+
+ /**
+ * convert JsonNode into the returnType of methods in OvsdbRPC class.
+ * @param jsonNode the result JsonNode
+ * @param methodName the method name of methods in OvsdbRPC class
+ * @return Object
+ */
+ public static Object jsonResultParser(JsonNode jsonNode, String methodName) {
+ ObjectMapper objectMapper = ObjectMapperUtil.getObjectMapper();
+ JsonNode error = jsonNode.get("error");
+ if (error != null && !error.isNull()) {
+ log.error("jsonRpcResponse error : {}", error.toString());
+ }
+ JsonNode resultJsonNode = jsonNode.get("result");
+ Object result = convertResultType(resultJsonNode, methodName, objectMapper);
+ return result;
+ }
+
+ /**
+ * When monitor the ovsdb tables, if a table update, ovs send update
+ * notification, then call callback function.
+ * @param jsonNode the result JsonNode
+ * @param callback the callback function
+ * @throws UnsupportedException this is an unsupported exception
+ */
+ public static void jsonCallbackRequestParser(JsonNode jsonNode, Callback callback) {
+ ObjectMapper objectMapper = ObjectMapperUtil.getObjectMapper();
+ JsonNode params = jsonNode.get("params");
+ Object param = null;
+ String methodName = jsonNode.get("method").asText();
+ switch (methodName) {
+ case "update":
+ param = objectMapper.convertValue(params, UpdateNotification.class);
+ callback.update((UpdateNotification) param);
+ break;
+ default:
+ throw new UnsupportedException("does not support this callback method: " + methodName);
+ }
+ }
+
+ /**
+ * Ovs send echo request to keep the heart, need we return echo result.
+ * @param jsonNode the result JsonNode
+ * @return JsonRpcResponse String
+ */
+ public static String getEchoRequestStr(JsonNode jsonNode) {
+ ObjectMapper objectMapper = ObjectMapperUtil.getObjectMapper();
+ String str = null;
+ if (jsonNode.get("method").asText().equals("echo")) {
+ JsonRpcResponse response = new JsonRpcResponse(jsonNode.get("id").asText());
+ try {
+ str = objectMapper.writeValueAsString(response);
+ } catch (JsonProcessingException e) {
+ log.error("JsonProcessingException while converting JsonNode into string: ", e);
+ }
+ }
+ return str;
+ }
+
+ /**
+ * Convert the List of Operation result into List of OperationResult .
+ * @param input the List of JsonNode
+ * @param operations the List of Operation
+ * @return the List of OperationResult
+ */
+ public static List<OperationResult> jsonNodeToOperationResult(List<JsonNode> input,
+ List<Operation> operations) {
+ ObjectMapper objectMapper = ObjectMapperUtil.getObjectMapper(false);
+ List<OperationResult> operationResults = new ArrayList<OperationResult>();
+ for (int i = 0; i < input.size(); i++) {
+ JsonNode jsonNode = input.get(i);
+ Operation operation = operations.get(i);
+ if (jsonNode != null && jsonNode.size() > 0) {
+ if (i >= operations.size() || operation.getOp() != "select") {
+ OperationResult or = objectMapper.convertValue(jsonNode, OperationResult.class);
+ operationResults.add(or);
+ } else {
+ List<Row> rows = createRows(operation.getTableSchema(), jsonNode);
+ OperationResult or = new OperationResult(rows);
+ operationResults.add(or);
+ }
+ }
+ }
+ return operationResults;
+ }
+
+ /**
+ * Convert Operation JsonNode into Rows.
+ * @param tableSchema TableSchema entity
+ * @param rowsNode JsonNode
+ * @return ArrayList<Row> the List of Row
+ */
+ private static ArrayList<Row> createRows(TableSchema tableSchema, JsonNode rowsNode) {
+ validateJsonNode(rowsNode, "rows");
+ ArrayList<Row> rows = Lists.newArrayList();
+ for (JsonNode rowNode : rowsNode.get("rows")) {
+ rows.add(createRow(tableSchema, null, rowNode)); //FIXME null will throw exception
+ }
+ return rows;
+ }
+
+ /**
+ * convert the params of Update Notification into TableUpdates.
+ * @param updatesJson the params of Update Notification
+ * @param dbSchema DatabaseSchema entity
+ * @return TableUpdates
+ */
+ public static TableUpdates jsonNodeToTableUpdates(JsonNode updatesJson, DatabaseSchema dbSchema) {
+ Map<String, TableUpdate> tableUpdateMap = Maps.newHashMap();
+ Iterator<Map.Entry<String, JsonNode>> tableUpdatesItr = updatesJson.fields();
+ while (tableUpdatesItr.hasNext()) {
+ Map.Entry<String, JsonNode> entry = tableUpdatesItr.next();
+ TableSchema tableSchema = dbSchema.getTableSchema(entry.getKey());
+ TableUpdate tableUpdate = jsonNodeToTableUpdate(tableSchema, entry.getValue());
+ tableUpdateMap.put(entry.getKey(), tableUpdate);
+ }
+ return TableUpdates.tableUpdates(tableUpdateMap);
+ }
+
+ /**
+ * convert the params of Update Notification into TableUpdate.
+ * @param tableSchema TableSchema entity
+ * @param updateJson the table-update in params of Update Notification
+ * @return TableUpdate
+ */
+ public static TableUpdate jsonNodeToTableUpdate(TableSchema tableSchema, JsonNode updateJson) {
+ Map<UUID, RowUpdate> rows = Maps.newHashMap();
+ Iterator<Map.Entry<String, JsonNode>> tableUpdateItr = updateJson.fields();
+ while (tableUpdateItr.hasNext()) {
+ Map.Entry<String, JsonNode> oldNewRow = tableUpdateItr.next();
+ String uuidStr = oldNewRow.getKey();
+ UUID uuid = UUID.uuid(uuidStr);
+ JsonNode newR = oldNewRow.getValue().get("new");
+ JsonNode oldR = oldNewRow.getValue().get("old");
+ Row newRow = newR != null ? createRow(tableSchema, uuid, newR) : null;
+ Row oldRow = oldR != null ? createRow(tableSchema, uuid, oldR) : null;
+ RowUpdate rowUpdate = new RowUpdate(uuid, oldRow, newRow);
+ rows.put(uuid, rowUpdate);
+ }
+ return TableUpdate.tableUpdate(rows);
+ }
+
+ /**
+ * Convert Operation JsonNode into Row.
+ * @param tableSchema TableSchema entity
+ * @param rowNode JsonNode
+ * @return Row
+ */
+ private static Row createRow(TableSchema tableSchema, UUID uuid, JsonNode rowNode) {
+ if (tableSchema == null) {
+ return null;
+ }
+ Map<String, Column> columns = Maps.newHashMap();
+ Iterator<Map.Entry<String, JsonNode>> rowIter = rowNode.fields();
+ while (rowIter.hasNext()) {
+ Map.Entry<String, JsonNode> next = rowIter.next();
+ ColumnSchema columnSchema = tableSchema.getColumnSchema(next.getKey());
+ if (columnSchema != null) {
+ String columnName = columnSchema.name();
+ Object obj = TransValueUtil.getValueFromJson(next.getValue(), columnSchema.type());
+ columns.put(columnName, new Column(columnName, obj));
+ }
+ }
+ return new Row(tableSchema.name(), uuid, columns);
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/JsonRpcReaderUtil.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/JsonRpcReaderUtil.java
new file mode 100644
index 00000000..2a88199d
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/JsonRpcReaderUtil.java
@@ -0,0 +1,165 @@
+/*
+ * 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.ovsdb.rfc.utils;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufInputStream;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Stack;
+
+import org.onosproject.ovsdb.rfc.exception.UnsupportedException;
+import org.onosproject.ovsdb.rfc.jsonrpc.JsonReadContext;
+
+import com.fasterxml.jackson.core.JsonEncoding;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.io.IOContext;
+import com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper;
+import com.fasterxml.jackson.core.util.BufferRecycler;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.MappingJsonFactory;
+
+/**
+ * Decoder utility class.
+ */
+public final class JsonRpcReaderUtil {
+
+ /**
+ * Constructs a JsonRpcReaderUtil object. Utility classes should not have a
+ * public or default constructor, otherwise IDE will compile unsuccessfully.
+ * This class should not be instantiated.
+ */
+ private JsonRpcReaderUtil() {
+ }
+
+ /**
+ * Decode the bytes to Json object.
+ * @param in input of bytes
+ * @param out ouput of Json object list
+ * @param jrContext context for the last decoding process
+ * @throws IOException IOException
+ * @throws JsonParseException JsonParseException
+ */
+ public static void readToJsonNode(ByteBuf in, List<Object> out, JsonReadContext jrContext)
+ throws JsonParseException, IOException {
+ int lastReadBytes = jrContext.getLastReadBytes();
+ if (lastReadBytes == 0) {
+ if (in.readableBytes() < 4) {
+ return;
+ }
+ checkEncoding(in);
+ }
+
+ int i = lastReadBytes + in.readerIndex();
+ Stack<Byte> bufStack = jrContext.getBufStack();
+ for (; i < in.writerIndex(); i++) {
+ byte b = in.getByte(i);
+ switch (b) {
+ case '{':
+ if (!isDoubleQuote(bufStack)) {
+ bufStack.push(b);
+ jrContext.setStartMatch(true);
+ }
+ break;
+ case '}':
+ if (!isDoubleQuote(bufStack)) {
+ bufStack.pop();
+ }
+ break;
+ case '"':
+ if (in.getByte(i - 1) != '\\') {
+ if (!bufStack.isEmpty() && bufStack.peek() != '"') {
+ bufStack.push(b);
+ } else {
+ bufStack.pop();
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (jrContext.isStartMatch() && bufStack.isEmpty()) {
+ ByteBuf buf = in.readSlice(i - in.readerIndex() + 1);
+ JsonParser jf = new MappingJsonFactory().createParser(new ByteBufInputStream(buf));
+ JsonNode jsonNode = jf.readValueAsTree();
+ out.add(jsonNode);
+ lastReadBytes = 0;
+ jrContext.setLastReadBytes(lastReadBytes);
+ break;
+ }
+ }
+
+ if (i >= in.writerIndex()) {
+ lastReadBytes = in.readableBytes();
+ jrContext.setLastReadBytes(lastReadBytes);
+ }
+ }
+
+ /**
+ * Filter the invalid characters before decoding.
+ * @param in input of bytes
+ * @param lastReadBytes the bytes for last decoding incomplete record
+ */
+ private static void fliterCharaters(ByteBuf in) {
+ while (in.isReadable()) {
+ int ch = in.getByte(in.readerIndex());
+ if ((ch != ' ') && (ch != '\n') && (ch != '\t') && (ch != '\r')) {
+ break;
+ } else {
+ in.readByte();
+ }
+ }
+ }
+
+ /**
+ * Check whether the peek of the stack element is double quote.
+ * @param jrContext context for the last decoding process
+ * @return boolean
+ */
+ private static boolean isDoubleQuote(Stack<Byte> bufStack) {
+ if (!bufStack.isEmpty() && bufStack.peek() == '"') {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check whether the encoding is valid.
+ * @param in input of bytes
+ * @throws IOException this is an IO exception
+ * @throws UnsupportedException this is an unsupported exception
+ */
+ private static void checkEncoding(ByteBuf in) throws IOException {
+ int inputStart = 0;
+ int inputLength = 4;
+ fliterCharaters(in);
+ byte[] buff = new byte[4];
+ in.getBytes(in.readerIndex(), buff);
+ ByteSourceJsonBootstrapper strapper = new ByteSourceJsonBootstrapper(new IOContext(new BufferRecycler(),
+ null,
+ false),
+ buff, inputStart,
+ inputLength);
+ JsonEncoding jsonEncoding = strapper.detectEncoding();
+ if (!JsonEncoding.UTF8.equals(jsonEncoding)) {
+ throw new UnsupportedException("Only UTF-8 encoding is supported.");
+ }
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/JsonRpcWriterUtil.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/JsonRpcWriterUtil.java
new file mode 100644
index 00000000..7511c36e
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/JsonRpcWriterUtil.java
@@ -0,0 +1,114 @@
+/*
+ * 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.ovsdb.rfc.utils;
+
+import java.util.List;
+
+import org.onosproject.ovsdb.rfc.jsonrpc.JsonRpcRequest;
+import org.onosproject.ovsdb.rfc.operations.Operation;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+
+/**
+ * RPC Methods request utility class. Refer to RFC7047's Section 4.1.
+ */
+public final class JsonRpcWriterUtil {
+
+ /**
+ * Constructs a JsonRpcWriterUtil object. Utility classes should not have a
+ * public or default constructor, otherwise IDE will compile unsuccessfully.
+ * This class should not be instantiated.
+ */
+ private JsonRpcWriterUtil() {
+ }
+
+ /**
+ * Returns string of RPC request.
+ * @param uuid id of request object
+ * @param methodName method of request object
+ * @param params params of request object
+ * @return RPC Request String
+ */
+ private static String getRequestStr(String uuid, String methodName,
+ List params) {
+ JsonRpcRequest request;
+ if (params != null) {
+ request = new JsonRpcRequest(uuid, methodName, params);
+ } else {
+ request = new JsonRpcRequest(uuid, methodName);
+ }
+ String str = ObjectMapperUtil.convertToString(request);
+ return str;
+ }
+
+ /**
+ * Returns string of get_schema request.
+ * @param uuid id of get_schema request
+ * @param dbnames params of get_schema request
+ * @return get_schema Request String
+ */
+ public static String getSchemaStr(String uuid, List<String> dbnames) {
+ String methodName = "get_schema";
+ return getRequestStr(uuid, methodName, dbnames);
+ }
+
+ /**
+ * Returns string of echo request.
+ * @param uuid id of echo request
+ * @return echo Request String
+ */
+ public static String echoStr(String uuid) {
+ String methodName = "echo";
+ return getRequestStr(uuid, methodName, null);
+ }
+
+ /**
+ * Returns string of monitor request.
+ * @param uuid id of monitor request
+ * @param monotorId json-value in params of monitor request
+ * @param dbSchema DatabaseSchema entity
+ * @return monitor Request String
+ */
+ public static String monitorStr(String uuid, String monotorId,
+ DatabaseSchema dbSchema) {
+ String methodName = "monitor";
+ return getRequestStr(uuid, methodName,
+ ParamUtil.getMonitorParams(monotorId, dbSchema));
+ }
+
+ /**
+ * Returns string of list_dbs request.
+ * @param uuid id of list_dbs request
+ * @return list_dbs Request String
+ */
+ public static String listDbsStr(String uuid) {
+ String methodName = "list_dbs";
+ return getRequestStr(uuid, methodName, null);
+ }
+
+ /**
+ * Returns string of transact request.
+ * @param uuid id of transact request
+ * @param dbSchema DatabaseSchema entity
+ * @param operations operation* in params of transact request
+ * @return transact Request String
+ */
+ public static String transactStr(String uuid, DatabaseSchema dbSchema,
+ List<Operation> operations) {
+ String methodName = "transact";
+ return getRequestStr(uuid, methodName,
+ ParamUtil.getTransactParams(dbSchema, operations));
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/MutationUtil.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/MutationUtil.java
new file mode 100644
index 00000000..9ec62d31
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/MutationUtil.java
@@ -0,0 +1,107 @@
+/*
+ * 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.ovsdb.rfc.utils;
+
+import org.onosproject.ovsdb.rfc.notation.Mutation;
+import org.onosproject.ovsdb.rfc.notation.Mutation.Mutator;
+
+public final class MutationUtil {
+
+ /**
+ * Constructs a MutationUtil object. Utility classes should not have a
+ * public or default constructor, otherwise IDE will compile unsuccessfully. This
+ * class should not be instantiated.
+ */
+ private MutationUtil() {
+ }
+
+ /**
+ * Returns a Mutation that means += .
+ * @param columnName column name
+ * @param data column value
+ * @return Mutation
+ */
+ public static Mutation sum(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Mutation(columnName, Mutator.SUM, value);
+ }
+
+ /**
+ * Returns a Mutation that means -= .
+ * @param columnName column name
+ * @param data column value
+ * @return Mutation
+ */
+ public static Mutation difference(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Mutation(columnName, Mutator.DIFFERENCE, value);
+ }
+
+ /**
+ * Returns a Mutation that means *= .
+ * @param columnName column name
+ * @param data column value
+ * @return Mutation
+ */
+ public static Mutation product(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Mutation(columnName, Mutator.PRODUCT, value);
+ }
+
+ /**
+ * Returns a Mutation that means /= .
+ * @param columnName column name
+ * @param data column value
+ * @return Mutation
+ */
+ public static Mutation quotient(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Mutation(columnName, Mutator.QUOTIENT, value);
+ }
+
+ /**
+ * Returns a Mutation that means %= .
+ * @param columnName column name
+ * @param data column value
+ * @return Mutation
+ */
+ public static Mutation remainder(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Mutation(columnName, Mutator.REMAINDER, value);
+ }
+
+ /**
+ * Returns a Mutation that means insert .
+ * @param columnName column name
+ * @param data column value
+ * @return Mutation
+ */
+ public static Mutation insert(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Mutation(columnName, Mutator.INSERT, value);
+ }
+
+ /**
+ * Returns a Mutation that means delete .
+ * @param columnName column name
+ * @param data column value
+ * @return Mutation
+ */
+ public static Mutation delete(String columnName, Object data) {
+ Object value = TransValueUtil.getFormatData(data);
+ return new Mutation(columnName, Mutator.DELETE, value);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ObjectMapperUtil.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ObjectMapperUtil.java
new file mode 100644
index 00000000..e80a52bc
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ObjectMapperUtil.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.ovsdb.rfc.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ * ObjectMapper utility class.
+ */
+public final class ObjectMapperUtil {
+
+ private static final Logger log = LoggerFactory
+ .getLogger(ObjectMapperUtil.class);
+
+ /**
+ * Constructs a ObjectMapperUtil object. Utility classes should not have a
+ * public or default constructor, otherwise IDE will compile unsuccessfully. This
+ * class should not be instantiated.
+ */
+ private ObjectMapperUtil() {
+ }
+
+ /**
+ * get ObjectMapper entity.
+ * @return ObjectMapper entity
+ */
+ public static ObjectMapper getObjectMapper() {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
+ false);
+ objectMapper.setSerializationInclusion(Include.NON_NULL);
+ return objectMapper;
+ }
+
+ /**
+ * get ObjectMapper entity.
+ * @param flag configure
+ * @return ObjectMapper entity
+ */
+ public static ObjectMapper getObjectMapper(boolean flag) {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
+ flag);
+ return objectMapper;
+ }
+
+ /**
+ * get ObjectMapper entity.
+ * @param flag configure
+ * @param incl setSerializationInclusion
+ * @return ObjectMapper entity
+ */
+ public static ObjectMapper getObjectMapper(boolean flag, Include incl) {
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
+ flag);
+ objectMapper.setSerializationInclusion(incl);
+ return objectMapper;
+ }
+
+ /**
+ * convert Object into String.
+ * @param obj Object
+ * @return String
+ */
+ public static String convertToString(Object obj) {
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ return objectMapper.writeValueAsString(obj);
+ } catch (JsonProcessingException e) {
+ log.error("JsonProcessingException while converting Entity into string", e);
+ }
+ return null;
+ }
+
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ParamUtil.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ParamUtil.java
new file mode 100644
index 00000000..486b39b8
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/ParamUtil.java
@@ -0,0 +1,86 @@
+/*
+ * 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.ovsdb.rfc.utils;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.message.MonitorRequest;
+import org.onosproject.ovsdb.rfc.message.MonitorSelect;
+import org.onosproject.ovsdb.rfc.operations.Operation;
+import org.onosproject.ovsdb.rfc.schema.DatabaseSchema;
+import org.onosproject.ovsdb.rfc.schema.TableSchema;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+/**
+ * Params utility class. Params of the request object, refer to RFC7047's
+ * Section 4.1.
+ */
+public final class ParamUtil {
+
+ /**
+ * Constructs a ParamUtil object. Utility classes should not have a public
+ * or default constructor, otherwise IDE will compile unsuccessfully. This
+ * class should not be instantiated.
+ */
+ private ParamUtil() {
+ }
+
+ /**
+ * Returns MonitorRequest, refer to RFC7047's Section 4.1.5.
+ * @param tableSchema entity
+ * @return MonitorRequest
+ */
+ private static MonitorRequest getAllColumnsMonitorRequest(TableSchema tableSchema) {
+ String tableName = tableSchema.name();
+ Set<String> columns = tableSchema.getColumnNames();
+ MonitorSelect select = new MonitorSelect(true, true, true, true);
+ MonitorRequest monitorRequest = new MonitorRequest(tableName, columns, select);
+ return monitorRequest;
+ }
+
+ /**
+ * Returns params of monitor method, refer to RFC7047's Section 4.1.5.
+ * @param monotorId json-value, refer to RFC7047's Section 4.1.5.
+ * @param dbSchema DatabaseSchema entity
+ * @return List of Object, the params of monitor request
+ */
+ public static List<Object> getMonitorParams(String monotorId, DatabaseSchema dbSchema) {
+ Set<String> tables = dbSchema.getTableNames();
+ Map<String, MonitorRequest> mrMap = Maps.newHashMap();
+ for (String tableName : tables) {
+ TableSchema tableSchema = dbSchema.getTableSchema(tableName);
+ MonitorRequest monitorRequest = getAllColumnsMonitorRequest(tableSchema);
+ mrMap.put(tableName, monitorRequest);
+ }
+ return Lists.newArrayList(dbSchema.name(), monotorId, mrMap);
+ }
+
+ /**
+ * Returns params of transact method, refer to RFC7047's Section 4.1.3.
+ * @param dbSchema DatabaseSchema entity
+ * @param operations operation*, refer to RFC7047's Section 4.1.3.
+ * @return List of Object, the params of transact request
+ */
+ public static List<Object> getTransactParams(DatabaseSchema dbSchema, List<Operation> operations) {
+ List<Object> lists = Lists.newArrayList(dbSchema.name());
+ lists.addAll(operations);
+ return lists;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/StringEncoderUtil.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/StringEncoderUtil.java
new file mode 100644
index 00000000..0e414d8b
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/StringEncoderUtil.java
@@ -0,0 +1,42 @@
+/*
+ * 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.ovsdb.rfc.utils;
+
+import io.netty.handler.codec.string.StringEncoder;
+import io.netty.util.CharsetUtil;
+
+/**
+ * StringEncoder utility class.Only UTF-8 encoding is supported refer to
+ * RFC7047's Section 3.1.
+ */
+public final class StringEncoderUtil {
+
+ /**
+ * Constructs a StringEncoderUtil object. Utility classes should not have a
+ * public or default constructor, otherwise IDE will compile unsuccessfully. This
+ * class should not be instantiated.
+ */
+ private StringEncoderUtil() {
+ }
+
+ /**
+ * Returns StringEncoder of UTF_8 .
+ * @return StringEncoder
+ */
+ public static StringEncoder getEncoder() {
+ return new StringEncoder(CharsetUtil.UTF_8);
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/TransValueUtil.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/TransValueUtil.java
new file mode 100644
index 00000000..49fbd375
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/TransValueUtil.java
@@ -0,0 +1,172 @@
+/*
+ * 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.ovsdb.rfc.utils;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.onosproject.ovsdb.rfc.notation.OvsdbMap;
+import org.onosproject.ovsdb.rfc.notation.OvsdbSet;
+import org.onosproject.ovsdb.rfc.notation.RefTableRow;
+import org.onosproject.ovsdb.rfc.notation.UUID;
+import org.onosproject.ovsdb.rfc.schema.type.AtomicColumnType;
+import org.onosproject.ovsdb.rfc.schema.type.BaseType;
+import org.onosproject.ovsdb.rfc.schema.type.BooleanBaseType;
+import org.onosproject.ovsdb.rfc.schema.type.ColumnType;
+import org.onosproject.ovsdb.rfc.schema.type.IntegerBaseType;
+import org.onosproject.ovsdb.rfc.schema.type.KeyValuedColumnType;
+import org.onosproject.ovsdb.rfc.schema.type.RealBaseType;
+import org.onosproject.ovsdb.rfc.schema.type.StringBaseType;
+import org.onosproject.ovsdb.rfc.schema.type.UuidBaseType;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * Object value utility class.
+ */
+public final class TransValueUtil {
+
+ /**
+ * Constructs a TransValueUtil object. Utility classes should not have a
+ * public or default constructor, otherwise IDE will compile unsuccessfully.
+ * This class should not be instantiated.
+ */
+ private TransValueUtil() {
+ }
+
+ /**
+ * if the type is Set, convert into OvsdbSet, if Map, convert into OvsdbMap.
+ * @param value Object
+ * @return Object
+ */
+ public static Object getFormatData(Object value) {
+ if (value instanceof Map) {
+ return OvsdbMap.ovsdbMap((Map) value);
+ } else if (value instanceof Set) {
+ return OvsdbSet.ovsdbSet((Set) value);
+ } else {
+ return value;
+ }
+ }
+
+ /**
+ * Transform JsonNode to corresponding value.
+ * @param json the ColumnType JsonNode
+ * @param columnType AtomicColumnType or KeyValuedColumnType
+ * @return Object OvsdbMap or OvsdbSet
+ */
+ public static Object getValueFromJson(JsonNode json, ColumnType columnType) {
+ if (columnType instanceof AtomicColumnType) {
+ AtomicColumnType atoType = (AtomicColumnType) columnType;
+ return getValueFromAtoType(json, atoType);
+ } else if (columnType instanceof KeyValuedColumnType) {
+ KeyValuedColumnType kvType = (KeyValuedColumnType) columnType;
+ return getValueFromKvType(json, kvType);
+ }
+ return null;
+ }
+
+ /**
+ * Convert AtomicColumnType JsonNode into OvsdbSet value.
+ * @param json AtomicColumnType JsonNode
+ * @param atoType AtomicColumnType entity
+ * @return Object OvsdbSet or the value of JsonNode
+ */
+ private static Object getValueFromAtoType(JsonNode json, AtomicColumnType atoType) {
+ BaseType baseType = atoType.baseType();
+ // If "min" or "max" is not specified, If "min" is not 1 or "max" is not
+ // 1, or both, and "value" is not specified, the type is a set of scalar
+ // type "key". Refer to RFC 7047, Section 3.2 <type>.
+ if (atoType.min() != atoType.max()) {
+ Set set = Sets.newHashSet();
+ if (json.isArray()) {
+ if (json.size() == 2) {
+ if (json.get(0).isTextual() && "set".equals(json.get(0).asText())) {
+ for (JsonNode node : json.get(1)) {
+ set.add(transToValue(node, baseType));
+ }
+ } else {
+ set.add(transToValue(json, baseType));
+ }
+ }
+ } else {
+ set.add(transToValue(json, baseType));
+ }
+ return OvsdbSet.ovsdbSet(set);
+ } else {
+ return transToValue(json, baseType);
+ }
+ }
+
+ /**
+ * Convert KeyValuedColumnType JsonNode into OvsdbMap value.
+ * @param json KeyValuedColumnType JsonNode
+ * @param kvType KeyValuedColumnType entity
+ * @return Object OvsdbMap
+ */
+ private static Object getValueFromKvType(JsonNode json, KeyValuedColumnType kvType) {
+ if (json.isArray()) {
+ if (json.size() == 2) {
+ if (json.get(0).isTextual() && "map".equals(json.get(0).asText())) {
+ Map map = Maps.newHashMap();
+ for (JsonNode pairNode : json.get(1)) {
+ if (pairNode.isArray() && json.size() == 2) {
+ Object key = transToValue(pairNode.get(0), kvType.keyType());
+ Object value = transToValue(pairNode.get(1), kvType.valueType());
+ map.put(key, value);
+ }
+ }
+ return OvsdbMap.ovsdbMap(map);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * convert into value.
+ * @param valueNode the BaseType JsonNode
+ * @param baseType BooleanBaseType or IntegerBaseType or RealBaseType or
+ * StringBaseType or UuidBaseType
+ * @return Object the value of JsonNode
+ */
+ public static Object transToValue(JsonNode valueNode, BaseType baseType) {
+ if (baseType instanceof BooleanBaseType) {
+ return valueNode.asBoolean();
+ } else if (baseType instanceof IntegerBaseType) {
+ return valueNode.asInt();
+ } else if (baseType instanceof RealBaseType) {
+ return valueNode.asDouble();
+ } else if (baseType instanceof StringBaseType) {
+ return valueNode.asText();
+ } else if (baseType instanceof UuidBaseType) {
+ if (valueNode.isArray()) {
+ if (valueNode.size() == 2) {
+ if (valueNode.get(0).isTextual()
+ && ("uuid".equals(valueNode.get(0).asText()) || "named-uuid"
+ .equals(valueNode.get(0).asText()))) {
+ return UUID.uuid(valueNode.get(1).asText());
+ }
+ }
+ } else {
+ return new RefTableRow(((UuidBaseType) baseType).getRefTable(), valueNode);
+ }
+ }
+ return null;
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/VersionUtil.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/VersionUtil.java
new file mode 100644
index 00000000..d05d90ed
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/VersionUtil.java
@@ -0,0 +1,69 @@
+/*
+ * 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.ovsdb.rfc.utils;
+
+/**
+ * Version utility class.
+ */
+public final class VersionUtil {
+
+ /**
+ * Constructs a VersionUtil object. Utility classes should not have a public
+ * or default constructor, otherwise IDE will compile unsuccessfully. This
+ * class should not be instantiated.
+ */
+ private VersionUtil() {
+ }
+
+ public static final String DEFAULT_VERSION_STRING = "0.0.0";
+ private static final String FORMAT = "(\\d+)\\.(\\d+)\\.(\\d+)";
+
+ /**
+ * Match version by the format.
+ * @param version the version String
+ * @throws IllegalArgumentException this is an illegal argument exception
+ */
+ public static void versionMatch(String version) {
+ if (!version.matches(FORMAT)) {
+ throw new IllegalArgumentException("<" + version
+ + "> does not match format " + FORMAT);
+ }
+ }
+
+ /**
+ * Compare fromVersion and toVersion.
+ * @param fromVersion the initial version
+ * @param toVersion the end of the version
+ * @return an int number
+ */
+ public static int versionCompare(String fromVersion, String toVersion) {
+ String[] fromArr = fromVersion.split("\\.");
+ String[] toArr = toVersion.split("\\.");
+ int fromFirst = Integer.parseInt(fromArr[0]);
+ int fromMiddle = Integer.parseInt(fromArr[1]);
+ int fromEnd = Integer.parseInt(fromArr[2]);
+ int toFirst = Integer.parseInt(toArr[0]);
+ int toMiddle = Integer.parseInt(toArr[1]);
+ int toEnd = Integer.parseInt(toArr[2]);
+ if (fromFirst - toFirst != 0) {
+ return fromFirst - toFirst;
+ } else if (fromMiddle - toMiddle != 0) {
+ return fromMiddle - toMiddle;
+ } else {
+ return fromEnd - toEnd;
+ }
+ }
+}
diff --git a/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/package-info.java b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/package-info.java
new file mode 100644
index 00000000..0a0a4f78
--- /dev/null
+++ b/framework/src/onos/protocols/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/utils/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.
+ */
+
+/**
+ * OVSDB utilities.
+ */
+package org.onosproject.ovsdb.rfc.utils;
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-pcep-controller</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-pcep-controller-api</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS Pcep client controller subsystem API</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-pcep-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-pcepio</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-misc</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <artifactSet>
+ <excludes>
+ <exclude>io.netty:netty</exclude>
+ <exclude>com.google.guava:guava</exclude>
+ <exclude>org.slf4j:slfj-api</exclude>
+ <exclude>ch.qos.logback:logback-core</exclude>
+ <exclude>ch.qos.logback:logback-classic</exclude>
+ <exclude>com.google.code.findbugs:annotations</exclude>
+ </excludes>
+ </artifactSet>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.onosproject.pcep.*,org.onosproject.pcepio.*
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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<PcepMessage> 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<PcepClient> 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 @@
+<!--
+ ~ Copyright 2014 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-pcep-controller</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-pcep-controller-impl</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS PCEP client controller subsystem API implementation</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-pcep-controller-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-misc</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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<String, Long> getMemory() {
+ Map<String, Long> 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<PcepMessage> msglist = (List<PcepMessage>) 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<PcepValueType> tlvList = pOpenmsg.getPcepOpenObject().getOptionalTlv();
+ boolean bFoundPceccCapability = false;
+ boolean bFoundStatefulPceCapability = false;
+ boolean bFoundPcInstantiationCapability = false;
+
+ ListIterator<PcepValueType> 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<PcepErrorObject> 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<PcepError> 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<PccId, PcepClient> connectedClients =
+ new ConcurrentHashMap<>();
+
+ protected PcepClientAgent agent = new PcepClientAgent();
+ protected Set<PcepClientListener> pcepClientListener = new HashSet<>();
+
+ protected Set<PcepEventListener> 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<PcepClient> 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<PcepMessage> 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<PcepMessage> reader = PcepFactories.getGenericReader();
+ List<PcepMessage> 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<PcepMessage> msglist = (List<PcepMessage>) 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-pcep-controller</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-pcepio</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS Pcepio Protocol subsystem</description>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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<PcepMetricObject> getMetricObjectList();
+
+ /**
+ * Sets PcepMetricObject List.
+ *
+ * @param llMetricList list of metric objects
+ */
+ void setMetricObjectList(LinkedList<PcepMetricObject> 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<PcepMetricObject> getMetricObjectList();
+
+ /**
+ * Sets PcepMetricObject List.
+ *
+ * @param llMetricList list of metric objects
+ * @return Builder object for PcepAttrubute
+ */
+ Builder setMetricObjectList(LinkedList<PcepMetricObject> 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<PcepValueType> getOptionalTlv();
+
+ /**
+ * Sets LinkedList of Optional Tlvs in Close Message.
+ *
+ * @param llOptionalTlv LinkedList of type PcepValueType
+ */
+ void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> getOptionalTlv();
+
+ /**
+ * Sets LinkedList of Optional Tlvs in Close Message.
+ *
+ * @param llOptionalTlv list of optional tlv
+ * @return Builder by setting Optional Tlvs
+ */
+ Builder setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> getSubObjects();
+
+ /**
+ * Sets LinkedList of SubObjects in ERO Object.
+ *
+ * @param llSubObjects list of subobjects
+ */
+ void setSubObjects(LinkedList<PcepValueType> 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<PcepValueType> getSubObjects();
+
+ /**
+ * Sets LinkedList of SubObjects and returns its builder.
+ *
+ * @param llSubObjects list of SubObjects
+ * @return Builder by setting list of SubObjects
+ */
+ Builder setSubObjects(LinkedList<PcepValueType> 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<PcepRPObject> getRPObjList();
+
+ /**
+ * Sets the RP Objects lists.
+ *
+ * @param llRPObjList list of type PcepRPObject
+ */
+ void setRPObjList(LinkedList<PcepRPObject> llRPObjList);
+
+ /**
+ * Returns the PcepTEObject List.
+ *
+ * @return list of type PcepTEObject
+ */
+ LinkedList<PcepTEObject> getTEObjList();
+
+ /**
+ * Sets the TE Objects lists.
+ *
+ * @param llTEObjList list of type PcepTEObject
+ */
+ void setTEObjList(LinkedList<PcepTEObject> llTEObjList);
+
+ /**
+ * Returns the PcepErrorObject.
+ *
+ * @return list of type PcepErrorObject
+ */
+ LinkedList<PcepErrorObject> getErrorObjList();
+
+ /**
+ * Sets the Error Objects lists.
+ *
+ * @param llErrorObjList list of type PcepErrorObject
+ */
+ void setErrorObjList(LinkedList<PcepErrorObject> 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<PcepRPObject> 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<PcepRPObject> llRPObjList);
+
+ /**
+ * Returns the PcepTEObject.
+ *
+ * @return llTEObjList of type PcepTEObject
+ */
+ LinkedList<PcepTEObject> 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<PcepTEObject> llTEObjList);
+
+ /**
+ * Returns the PcepErrorObject.
+ *
+ * @return list of type PcepErrorObject
+ */
+ LinkedList<PcepErrorObject> 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<PcepErrorObject> 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<Integer> getErrorValue();
+
+ /**
+ * Returns Error Type in PCEP-ERROR Object.
+ *
+ * @return list of Error Type in PCEP-ERROR Object
+ */
+ LinkedList<Integer> 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<PcepError> getPcepErrorList();
+
+ /**
+ * Sets PcepError lists and returns its builder.
+ *
+ * @param llPcepErrorList list of PcepError
+ * @return builder by setting list of PcepError.
+ */
+ Builder setPcepErrorList(LinkedList<PcepError> 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<PcepValueType> getOptionalTlv();
+
+ /**
+ * Sets Optional Tlvs in Error Object.
+ *
+ * @param llOptionalTlv list of Optional Tlvs
+ */
+ void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepMessage> {
+
+ @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<PcepMessage> 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<PcepMessage> 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<PcInitiatedLspRequest> getPcInitiatedLspRequestList();
+
+ /**
+ * Sets list of PcInitiatedLspRequestList.
+ *
+ * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequestList
+ */
+ void setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> 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<PcInitiatedLspRequest> getPcInitiatedLspRequestList();
+
+ /**
+ * Sets PcInitiatedLspRequestList.
+ *
+ * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequestList
+ * @return builder by setting list of PcInitiatedLspRequestList
+ */
+ Builder setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> 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<PcepValueType> getSubObjects();
+
+ /**
+ * Sets list of SubObjects.
+ *
+ * @param llSubObjects list of SubObjects
+ */
+ void setSubObjects(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> getOptionalTlv();
+
+ /**
+ * Sets Optional Tlvs in Label Object.
+ *
+ * @param llOptionalTlv list of Optional Tlvs
+ */
+ void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepLabelRangeObject> getLabelRangeList();
+
+ /**
+ * Sets list of PcepLabelRangeObject.
+ *
+ * @param llLabelRangeList Label Range List
+ */
+ void setLabelRangeList(LinkedList<PcepLabelRangeObject> 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<PcepLabelUpdate> getPcLabelUpdateList();
+
+ /**
+ * Sets list of PcLabelUpdateList.
+ *
+ * @param llPcLabelUpdateList list of PcLabelUpdateList
+ */
+ void setPcLabelUpdateList(LinkedList<PcepLabelUpdate> 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<PcepLabelUpdate> getPcLabelUpdateList();
+
+ /**
+ * Sets list of PcLabelUpdateList.
+ *
+ * @param llPcLabelUpdateList list of PcLabelUpdateList.
+ * @return Builder by setting list of PcLabelUpdateList.
+ */
+ Builder setPcLabelUpdateList(LinkedList<PcepLabelUpdate> 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<PcepValueType> getOptionalTlv();
+
+ /**
+ * Sets list of Optional Tlvs in LSP Object.
+ *
+ * @param llOptionalTlv list of Optional Tlvs
+ */
+ void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> getOptionalTlv();
+
+ /**
+ * Sets Optional Tlvs in LSPA Object.
+ *
+ * @param llOptionalTlv Optional Tlvs in LSPA Object
+ */
+ void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<T> {
+
+ /**
+ * 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<T> {
+
+ /**
+ * 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<PcepValueType> getOptionalTlv();
+
+ /**
+ * Sets list of Optional Tlvs in Open Object.
+ *
+ * @param llOptionalTlv list of Optional Tlvs
+ */
+ void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> getOptionalTlv();
+
+ /**
+ * Sets list of Optional Tlvs in RP Object and returns its builder.
+ *
+ * @param llOptionalTlv list of Optional Tlvs
+ */
+ void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepStateReport> getStateReportList();
+
+ /**
+ * Sets StateReportList.
+ *
+ * @param llStateReportList list of PcepStateReport.
+ */
+ void setStateReportList(LinkedList<PcepStateReport> 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<PcepStateReport> getStateReportList();
+
+ /**
+ * Sets list of PcepStateReport and returns builder.
+ *
+ * @param llStateReportList list of PcepStateReport.
+ * @return Builder by setting list of PcepStateReport.
+ */
+ Builder setStateReportList(LinkedList<PcepStateReport> 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<PcepValueType> getSubObjects();
+
+ /**
+ * Sets list of SubObjects and return its builder.
+ *
+ * @param llSubObjects list of SubObjects
+ */
+ void setSubObjects(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> llOptionalTlv);
+
+ /**
+ * Returns list of optional tlvs.
+ *
+ * @return llOptionalTlv list of optional tlvs
+ */
+ LinkedList<PcepValueType> 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<PcepValueType> getOptionalTlv();
+
+ /**
+ * sets the optional TLvs.
+ *
+ * @param llOptionalTlv List of optional tlv
+ * @return builder by setting list of optional tlv.
+ */
+ Builder setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> getOptionalTlv();
+
+ /**
+ * Sets list of Optional Tlvs in TE Object.
+ *
+ * @param llOptionalTlv list of Optional Tlvs
+ */
+ void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepTEObject> getTEReportList();
+
+ /**
+ * Sets list of Optional Tlvs in TE Report Message.
+ *
+ * @param llTEReportList list of optional Tlvs
+ */
+ void setTEReportList(LinkedList<PcepTEObject> 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<PcepTEObject> 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<PcepTEObject> 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<PcepUpdateRequest> getUpdateRequestList();
+
+ /**
+ * Sets the update request list for PCEP update message.
+ *
+ * @param llUpdateRequestList is a list of PCEP Update Requests
+ */
+ void setUpdateRequestList(LinkedList<PcepUpdateRequest> 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<PcepUpdateRequest> 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<PcepUpdateRequest> 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 {
+
+ /*
+ * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>)
+ <PCE-initiated-lsp-instantiation> ::= <SRP>
+ <LSP>
+ <END-POINTS>
+ <ERO>
+ [<attribute-list>]
+ <PCE-initiated-lsp-deletion> ::= <SRP>
+ <LSP>
+ */
+
+ 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:
+ * <attribute-list> ::=[<LSPA>]
+ * [<BANDWIDTH>]
+ * [<metric-list>]
+ * [<IRO>]
+ *
+ * <metric-list> ::=<METRIC>[<metric-list>]
+ */
+ 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<PcepMetricObject> 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<PcepMetricObject> 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<PcepMetricObject> 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<PcepMetricObject> 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<PcepMetricObject> 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<PcepMetricObject> 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<PcepMetricObject> 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<PcepMetricObject> 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<PcepMetricObject> 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<PcepMetricObject> 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
+ * <Close Message> ::= <Common Header> <CLOSE>
+ *
+ 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<PcepValueType> llOptionalTlv;
+
+ public static final PcepCloseMsgVer1.Reader READER = new Reader();
+
+ /**
+ * Reader class for reading close message for channel buffer.
+ */
+ static class Reader implements PcepMessageReader<PcepCloseMsg> {
+ PcepObjectHeader closeObjHeader;
+ byte yReason;
+ // Optional TLV
+ private LinkedList<PcepValueType> 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<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> 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<PcepCloseMsgVer1> {
+
+ @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<PcepValueType> llOptionalTlv = message.llOptionalTlv;
+ ListIterator<PcepValueType> 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<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> getSubObjects() {
+ return this.llSubObjects;
+ }
+
+ @Override
+ public void setSubObjects(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> getSubObjects() {
+ return this.llSubObjects;
+ }
+
+ @Override
+ public Builder setSubObjects(LinkedList<PcepValueType> 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<PcepError> 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<PcepRPObject> llRPObjList, LinkedList<PcepTEObject> llTEObjList,
+ LinkedList<PcepErrorObject> 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<PcepError> 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 <error>
+ ListIterator<PcepError> listIterator = errList.listIterator();
+ while (listIterator.hasNext()) {
+ PcepError pcepError = listIterator.next();
+
+ //RP Object list is optional
+ LinkedList<PcepRPObject> llRPObjList = pcepError.getRPObjList();
+ if (llRPObjList != null) {
+ ListIterator<PcepRPObject> rpListIterator = llRPObjList.listIterator();
+ while (rpListIterator.hasNext()) {
+ rpListIterator.next().write(cb);
+ }
+ }
+
+ //TE Object list is optional
+ LinkedList<PcepTEObject> llTEObjList = pcepError.getTEObjList();
+ if (llTEObjList != null) {
+ ListIterator<PcepTEObject> teListIterator = llTEObjList.listIterator();
+ while (teListIterator.hasNext()) {
+ teListIterator.next().write(cb);
+ }
+ }
+
+ // <error-obj-list> is mandatory
+ boolean bIsErrorObjListFound = false;
+
+ LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
+ if (llErrObjList != null) {
+ ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
+ while (errObjListIterator.hasNext()) {
+ errObjListIterator.next().write(cb);
+ bIsErrorObjListFound = true;
+ }
+ }
+
+ if (!bIsErrorObjListFound) {
+ throw new PcepParseException("<error-obj-list> is mandatory.");
+ }
+ }
+ }
+
+ @Override
+ public LinkedList<Integer> getErrorType() {
+ LinkedList<Integer> errorType = new LinkedList<>();
+ ListIterator<PcepError> listIterator = errList.listIterator();
+ PcepErrorObject errObj;
+ int error;
+ while (listIterator.hasNext()) {
+ PcepError pcepError = listIterator.next();
+ LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
+ if (llErrObjList != null) {
+ ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
+ while (errObjListIterator.hasNext()) {
+ errObj = errObjListIterator.next();
+ error = errObj.getErrorType();
+ errorType.add(error);
+ }
+ }
+ }
+ return errorType;
+ }
+
+ @Override
+ public LinkedList<Integer> getErrorValue() {
+ LinkedList<Integer> errorValue = new LinkedList<>();
+ ListIterator<PcepError> listIterator = errList.listIterator();
+ PcepErrorObject errObj;
+ int error;
+ while (listIterator.hasNext()) {
+ PcepError pcepError = listIterator.next();
+ LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
+ if (llErrObjList != null) {
+ ListIterator<PcepErrorObject> 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<PcepError> errll;
+
+ @Override
+ public PcepErrorInfo build() {
+ return new PcepErrorInfoVer1(errll);
+ }
+
+ @Override
+ public LinkedList<PcepError> getPcepErrorList() {
+ return this.errll;
+ }
+
+ @Override
+ public Builder setPcepErrorList(LinkedList<PcepError> 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.
+
+ <PCErr Message> ::= <Common Header>
+ ( <error-obj-list> [<Open>] ) | <error>
+ [<error-list>]
+
+ <error-obj-list> ::=<PCEP-ERROR>[<error-obj-list>]
+
+ <error> ::=[<request-id-list> | <te-id-list>]
+ <error-obj-list>
+
+ <request-id-list> ::=<RP>[<request-id-list>]
+
+ <te-id-list> ::=<TE>[<te-id-list>]
+
+ <error-list> ::=<error>[<error-list>]
+ */
+
+ 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 ( <error-obj-list> [<Open>] )
+ private PcepErrorInfo errInfo; //optional <error> [<error-list>]
+
+ 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<PcepErrorMsg> {
+
+ 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 <PCErr Message>
+ 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.
+ // ( <error-obj-list> [<Open>]
+ //If PCEP-ERROR list is followed by RP or TE Object then store into errInfo. <error> [<error-list>]
+ //If only PCEP-ERROR list is present then store into ErrorObjListWithOpen.
+ PcepObjectHeader tempObjHeader;
+ LinkedList<PcepErrorObject> 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("<error-obj-list> 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<PcepErrorObject> 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 ( <error-obj-list> [<Open>] )
+ private PcepErrorInfo errInfo = null; //optional <error> [<error-list>]
+
+ @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<PcepErrorMsgVer1> {
+ @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 ( <error-obj-list> [<Open>] ) if exists.
+ // otherwise write <error> [<error-list>]
+
+ 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<Integer> getErrorType() {
+ LinkedList<Integer> 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<Integer> getErrorValue() {
+ LinkedList<Integer> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> parseOptionalTlv(ChannelBuffer cb) {
+
+ LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> 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 {
+
+ /*
+ <error>::=[<request-id-list> | <te-id-list>]
+ <error-obj-list>
+
+ <request-id-list>::=<RP>[<request-id-list>]
+
+ <te-id-list>::=<TE>[<te-id-list>]
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepErrorVer1.class);
+
+ private boolean isErroInfoSet;
+ //PcepErrorObject list
+ private LinkedList<PcepErrorObject> llErrObjList;
+ //PcepRPObject list
+ private LinkedList<PcepRPObject> llRPObjList;
+ //PcepTEObject list
+ private LinkedList<PcepTEObject> 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<PcepRPObject> llRPObjList, LinkedList<PcepTEObject> llTEObjList,
+ LinkedList<PcepErrorObject> llErrObjListObjList) {
+ this.llRPObjList = llRPObjList;
+ this.llTEObjList = llTEObjList;
+ this.llErrObjList = llErrObjListObjList;
+ }
+
+ /**
+ * Constructor to initialize PcepError.
+ *
+ * @param llErrObjList list of PcepErrorObject
+ */
+ public PcepErrorVer1(LinkedList<PcepErrorObject> llErrObjList) {
+ this.llRPObjList = null;
+ this.llTEObjList = null;
+ this.llErrObjList = llErrObjList;
+ }
+
+ @Override
+ public LinkedList<PcepRPObject> getRPObjList() {
+ return this.llRPObjList;
+ }
+
+ @Override
+ public LinkedList<PcepTEObject> getTEObjList() {
+ return this.llTEObjList;
+ }
+
+ @Override
+ public LinkedList<PcepErrorObject> 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<PcepRPObject> rpObjlistIterator = this.llRPObjList.listIterator();
+ while (rpObjlistIterator.hasNext()) {
+ rpObjlistIterator.next().write(cb);
+ }
+ }
+
+ // TElist is optional
+ if (this.isTEObjListSet) {
+ ListIterator<PcepTEObject> teObjlistIterator = this.llTEObjList.listIterator();
+ while (teObjlistIterator.hasNext()) {
+ teObjlistIterator.next().write(cb);
+ }
+ }
+ //ErrList is mandatory
+ ListIterator<PcepErrorObject> 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<PcepRPObject> llRPObjList;
+ private LinkedList<PcepTEObject> llTEObjList;
+ private LinkedList<PcepErrorObject> llErrObjList;
+
+ @Override
+ public PcepError build() {
+ return new PcepErrorVer1(llRPObjList, llTEObjList, llErrObjList);
+ }
+
+ @Override
+ public LinkedList<PcepRPObject> getRPObjList() {
+ return this.llRPObjList;
+ }
+
+ @Override
+ public Builder setRPObjList(LinkedList<PcepRPObject> llRPObjList) {
+ this.llRPObjList = llRPObjList;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepTEObject> getTEObjList() {
+ return this.llTEObjList;
+ }
+
+ @Override
+ public Builder setTEObjList(LinkedList<PcepTEObject> llTEObjList) {
+ this.llTEObjList = llTEObjList;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepErrorObject> getErrorObjList() {
+ return this.llErrObjList;
+ }
+
+ @Override
+ public Builder setErrorObjList(LinkedList<PcepErrorObject> llErrObjList) {
+ this.llErrObjList = llErrObjList;
+ return this;
+ }
+
+ }
+
+ @Override
+ public void setRPObjList(LinkedList<PcepRPObject> llRPObjList) {
+ this.llRPObjList = llRPObjList;
+ }
+
+ @Override
+ public void setTEObjList(LinkedList<PcepTEObject> llTEObjList) {
+ this.llTEObjList = llTEObjList;
+ }
+
+ @Override
+ public void setErrorObjList(LinkedList<PcepErrorObject> 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<PcepMessage> 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
+ /* <PCInitiate Message> ::= <Common Header>
+ * <PCE-initiated-lsp-list>
+ * Where:
+ * <PCE-initiated-lsp-list> ::= <PCE-initiated-lsp-request>[<PCE-initiated-lsp-list>]
+ * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>)
+ * <PCE-initiated-lsp-instantiation> ::= <SRP>
+ * <LSP>
+ * <END-POINTS>
+ * <ERO>
+ * [<attribute-list>]
+ * <PCE-initiated-lsp-deletion> ::= <SRP>
+ * <LSP>
+ */
+
+ 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<PcInitiatedLspRequest> 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<PcepInitiateMsg> {
+
+ LinkedList<PcInitiatedLspRequest> 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<PcInitiatedLspRequest> 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<PcInitiatedLspRequest> 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<PcInitiatedLspRequest> getPcInitiatedLspRequestList() {
+ return this.llPcInitiatedLspRequestList;
+ }
+
+ @Override
+ public Builder setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> 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<PcepInitiateMsgVer1> {
+
+ @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<PcInitiatedLspRequest> 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<PcInitiatedLspRequest> getPcInitiatedLspRequestList() {
+ return this.llPcInitiatedLspRequestList;
+ }
+
+ @Override
+ public void setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> getSubObjects() {
+ return this.llSubObjects;
+ }
+
+ @Override
+ public void setSubObjects(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> getSubObjects() {
+ return this.llSubObjects;
+ }
+
+ @Override
+ public Builder setSubObjects(LinkedList<PcepValueType> 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 {
+
+ /*
+ <Keepalive Message>::= <Common Header>
+
+ 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<PcepKeepaliveMsg> {
+
+ @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<PcepKeepaliveMsgVer1> {
+
+ @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<PcepValueType> 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<PcepValueType> llOptionalTlv) {
+ this.labelObjHeader = labelObjHeader;
+ this.bOFlag = bOFlag;
+ this.label = label;
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public void setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public Builder setOptionalTlv(LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> 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<PcepValueType> 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<PcepValueType> 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>::= <Common Header>
+ <label-range>
+ Where:
+
+ <label-range> ::= <SRP>
+ <labelrange-list>
+
+ Where
+ <labelrange-list>::=<LABEL-RANGE>[<labelrange-list>]
+ */
+ 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;
+ //<label-range>
+ PcepLabelRange labelRange;
+
+ public static final PcepLabelRangeResvMsgVer1.Reader READER = new Reader();
+
+ /**
+ * Reader reads LabelRangeResv Message from the channel.
+ */
+ static class Reader implements PcepMessageReader<PcepLabelRangeResvMsg> {
+
+ @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 <label-range>
+ 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<PcepLabelRangeResvMsgVer1> {
+
+ @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);
+
+ /*
+ <label-range> ::= <SRP>
+ <labelrange-list>
+ Where
+ <labelrange-list>::=<LABEL-RANGE>[<labelrange-list>]
+ */
+
+ // PCEP SRP Object
+ private PcepSrpObject srpObject;
+ //<labelrange-list> of type PcepLabelRangeObject.
+ private LinkedList<PcepLabelRangeObject> 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<PcepLabelRangeObject> 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<PcepLabelRangeObject> getLabelRangeList() {
+ return llLabelRangeList;
+ }
+
+ @Override
+ public void setLabelRangeList(LinkedList<PcepLabelRangeObject> 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<PcepLabelRangeObject> llLabelRangeList = new LinkedList<>();
+ boolean bFoundLabelRangeObj = false;
+ while (0 < cb.readableBytes()) {
+ //parse and store <labelrange-list>
+ 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 <SRP>
+ int objLenIndex = srpObject.write(cb);
+
+ if (objLenIndex <= 0) {
+ throw new PcepParseException("bjectLength is " + objLenIndex);
+ }
+
+ //write <labelrange-list>
+ ListIterator<PcepLabelRangeObject> 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:
+
+ <PCLabelUpd Message> ::= <Common Header>
+ <pce-label-update-list>
+ Where:
+
+ <pce-label-update-list> ::= <pce-label-update>
+ [<pce-label-update-list>]
+ <pce-label-update> ::= (<pce-label-download>|<pce-label-map>)
+
+ Where:
+ <pce-label-download> ::= <SRP>
+ <LSP>
+ <label-list>
+
+ <pce-label-map> ::= <SRP>
+ <LABEL>
+ <FEC>
+
+ <label-list > ::= <LABEL>
+ [<label-list>]
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PcepLabelUpdateMsgVer1.class);
+
+ public static final byte PACKET_VERSION = 1;
+
+ //LabelUpdateMsgMinLength = COMMON-HEADER(4)+SrpObjMinLentgh(12)+LabelObjectMinLength(12)+FECType1Object(8)
+ public static final int PACKET_MINIMUM_LENGTH = 36;
+ public static final PcepType MSG_TYPE = PcepType.LABEL_UPDATE;
+ //pce-label-update-list
+ private LinkedList<PcepLabelUpdate> llPcLabelUpdateList;
+
+ static final PcepLabelUpdateMsgVer1.Reader READER = new Reader();
+
+ /**
+ * Reader reads LabelUpdate Message from the channel.
+ */
+ static class Reader implements PcepMessageReader<PcepLabelUpdateMsg> {
+
+ @Override
+ public PcepLabelUpdateMsg readFrom(ChannelBuffer cb) throws PcepParseException {
+
+ if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
+ throw new PcepParseException("Readable bytes are less 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 == 13
+ byte type = cb.readByte();
+ if (type != MSG_TYPE.getType()) {
+ throw new PcepParseException("Wrong type. Expected=PcepType.LABEL_UPDATE(13), 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 <pce-label-download> / <pce-label-map>
+ LinkedList<PcepLabelUpdate> llPcLabelUpdateList = parsePcLabelUpdateList(cb);
+ return new PcepLabelUpdateMsgVer1(llPcLabelUpdateList);
+ }
+
+ /**
+ * Returns list of PCEP Label Update object.
+ *
+ * @param cb of type channel buffer
+ * @return llPcLabelUpdateList list of PCEP label update object
+ * @throws PcepParseException when fails to parse list of PCEP label update object
+ */
+ public LinkedList<PcepLabelUpdate> parsePcLabelUpdateList(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepLabelUpdate> llPcLabelUpdateList;
+ llPcLabelUpdateList = new LinkedList<>();
+
+ while (0 < cb.readableBytes()) {
+ llPcLabelUpdateList.add(PcepLabelUpdateVer1.read(cb));
+ }
+ return llPcLabelUpdateList;
+ }
+ }
+
+ /**
+ * Constructor to initialize PCEP Label Update List.
+ *
+ * @param llPcLabelUpdateList list of PCEP Label Update object
+ */
+ PcepLabelUpdateMsgVer1(LinkedList<PcepLabelUpdate> llPcLabelUpdateList) {
+ this.llPcLabelUpdateList = llPcLabelUpdateList;
+ }
+
+ /**
+ * Builder class for PCEP label update message.
+ */
+ static class Builder implements PcepLabelUpdateMsg.Builder {
+
+ LinkedList<PcepLabelUpdate> llPcLabelUpdateList;
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public PcepType getType() {
+ return PcepType.LABEL_UPDATE;
+ }
+
+ @Override
+ public PcepLabelUpdateMsg build() {
+ return new PcepLabelUpdateMsgVer1(this.llPcLabelUpdateList);
+ }
+
+ @Override
+ public LinkedList<PcepLabelUpdate> getPcLabelUpdateList() {
+ return this.llPcLabelUpdateList;
+ }
+
+ @Override
+ public Builder setPcLabelUpdateList(LinkedList<PcepLabelUpdate> ll) {
+ this.llPcLabelUpdateList = ll;
+ return this;
+ }
+ }
+
+ @Override
+ public void writeTo(ChannelBuffer cb) throws PcepParseException {
+ WRITER.write(cb, this);
+ }
+
+ static final Writer WRITER = new Writer();
+
+ /**
+ * Writer writes LabelUpdate Message to the channel.
+ */
+ static class Writer implements PcepMessageWriter<PcepLabelUpdateMsgVer1> {
+
+ @Override
+ public void write(ChannelBuffer cb, PcepLabelUpdateMsgVer1 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);
+ ListIterator<PcepLabelUpdate> listIterator = message.llPcLabelUpdateList.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepLabelUpdate labelUpdate = listIterator.next();
+ labelUpdate.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 LinkedList<PcepLabelUpdate> getPcLabelUpdateList() {
+ return this.llPcLabelUpdateList;
+ }
+
+ @Override
+ public void setPcLabelUpdateList(LinkedList<PcepLabelUpdate> ll) {
+ this.llPcLabelUpdateList = ll;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("PcLabelUpdateList", llPcLabelUpdateList)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateVer1.java
new file mode 100644
index 00000000..a2293d35
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelUpdateVer1.java
@@ -0,0 +1,356 @@
+/*
+ * 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.PcepFecObject;
+import org.onosproject.pcepio.protocol.PcepLabelObject;
+import org.onosproject.pcepio.protocol.PcepLabelUpdate;
+import org.onosproject.pcepio.protocol.PcepLspObject;
+import org.onosproject.pcepio.protocol.PcepSrpObject;
+import org.onosproject.pcepio.types.PcepLabelDownload;
+import org.onosproject.pcepio.types.PcepLabelMap;
+import org.onosproject.pcepio.types.PcepObjectHeader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP LABEL update .
+ * Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
+ */
+public class PcepLabelUpdateVer1 implements PcepLabelUpdate {
+
+ /*
+ * <pce-label-update> ::= (<pce-label-download>|<pce-label-map>)
+
+ Where:
+ <pce-label-download> ::= <SRP>
+ <LSP>
+ <label-list>
+
+ <pce-label-map> ::= <SRP>
+ <LABEL>
+ <FEC>
+
+ <label-list > ::= <LABEL>
+ [<label-list>]
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PcepLabelUpdateVer1.class);
+
+ //Either PceLabelDownload or PceLabelMap is mandatory.
+ //label Download
+ private PcepLabelDownload labelDownload;
+ private boolean isLabelDownloadSet;
+ //label Map
+ private PcepLabelMap labelMap;
+ private boolean isLabelMapSet;
+
+ /**
+ * Constructor to reset parameters.
+ */
+ public PcepLabelUpdateVer1() {
+ this.labelDownload = null;
+ this.isLabelDownloadSet = false;
+ this.labelMap = null;
+ this.isLabelMapSet = false;
+ }
+
+ /**
+ * Constructor to initialize PCEP label download.
+ *
+ * @param labelDownload PCEP label download
+ */
+ public PcepLabelUpdateVer1(PcepLabelDownload labelDownload) {
+ this.labelDownload = labelDownload;
+ this.isLabelDownloadSet = true;
+ this.labelMap = null;
+ this.isLabelMapSet = false;
+ }
+
+ /**
+ * Constructor to initialize PCEP label map.
+ *
+ * @param labelMap PCEP label map
+ */
+ public PcepLabelUpdateVer1(PcepLabelMap labelMap) {
+ this.labelDownload = null;
+ this.isLabelDownloadSet = false;
+ this.labelMap = labelMap;
+ this.isLabelMapSet = true;
+ }
+
+ /**
+ * builder class for PCEP label update.
+ */
+ static class Builder implements PcepLabelUpdate.Builder {
+
+ private PcepLabelDownload labelDownload;
+ private boolean isLabelDownloadSet;
+ private PcepLabelMap labelMap;
+ private boolean isLabelMapSet;
+
+ @Override
+ public PcepLabelUpdate build() throws PcepParseException {
+
+ if (isLabelDownloadSet) {
+ return new PcepLabelUpdateVer1(labelDownload);
+ }
+ if (isLabelMapSet) {
+ return new PcepLabelUpdateVer1(labelMap);
+ }
+ if (!isLabelDownloadSet && !isLabelMapSet) {
+ throw new PcepParseException(
+ "Label Download or Label Map is not set while building PcepLabelUpdate Message");
+ }
+ return new PcepLabelUpdateVer1();
+ }
+
+ @Override
+ public Builder setLabelDownload(PcepLabelDownload labelDownload) {
+ this.labelDownload = labelDownload;
+ this.isLabelDownloadSet = true;
+ return this;
+ }
+
+ @Override
+ public PcepLabelDownload getLabelDownload() {
+ return labelDownload;
+ }
+
+ @Override
+ public Builder setLabelMap(PcepLabelMap labelMap) {
+ this.labelMap = labelMap;
+ this.isLabelMapSet = true;
+ return this;
+ }
+
+ @Override
+ public PcepLabelMap getLabelMap() {
+ return labelMap;
+ }
+ }
+
+ /**
+ * Reads PcepLabels from the byte stream received from channel buffer.
+ *
+ * @param cb of type channel buffer.
+ * @return PcepLabelUpdate object.
+ * @throws PcepParseException when fails to read from channel buffer
+ */
+ public static PcepLabelUpdate read(ChannelBuffer cb) throws PcepParseException {
+
+ PcepLabelUpdateVer1 pceLabelUpdate = new PcepLabelUpdateVer1();
+
+ PcepSrpObject srpObject;
+ PcepObjectHeader tempObjHeader;
+
+ //read SRP mandatory Object
+ srpObject = PcepSrpObjectVer1.read(cb);
+
+ //checking next object
+ cb.markReaderIndex();
+
+ tempObjHeader = PcepObjectHeader.read(cb);
+ cb.resetReaderIndex();
+
+ if (tempObjHeader.getObjClass() == PcepLspObjectVer1.LSP_OBJ_CLASS) {
+
+ //now it is belong to <pce-label-download>
+ PcepLabelDownload labelDownload = new PcepLabelDownload();
+
+ //set SRP
+ labelDownload.setSrpObject(srpObject);
+
+ //read and set LSP
+ labelDownload.setLspObject(PcepLspObjectVer1.read(cb));
+
+ //<label-list>
+ LinkedList<PcepLabelObject> llLabelList = new LinkedList<>();
+ PcepLabelObject labelObject;
+
+ while (0 < cb.readableBytes()) {
+
+ cb.markReaderIndex();
+ tempObjHeader = PcepObjectHeader.read(cb);
+ cb.resetReaderIndex();
+
+ if (tempObjHeader.getObjClass() != PcepLabelObjectVer1.LABEL_OBJ_CLASS) {
+ break;
+ }
+ labelObject = PcepLabelObjectVer1.read(cb);
+ llLabelList.add(labelObject);
+ }
+ labelDownload.setLabelList(llLabelList);
+ pceLabelUpdate.setLabelDownload(labelDownload);
+ } else if (tempObjHeader.getObjClass() == PcepLabelObjectVer1.LABEL_OBJ_CLASS) {
+ //belong to <pce-label-map>
+ PcepLabelMap labelMap = new PcepLabelMap();
+
+ //set SRP Object
+ labelMap.setSrpObject(srpObject);
+
+ //read and set Label Object
+ labelMap.setLabelObject(PcepLabelObjectVer1.read(cb));
+
+ cb.markReaderIndex();
+ tempObjHeader = PcepObjectHeader.read(cb);
+ cb.resetReaderIndex();
+
+ PcepFecObject fecObject = null;
+ switch (tempObjHeader.getObjType()) {
+ case PcepFecObjectIPv4Ver1.FEC_OBJ_TYPE:
+ fecObject = PcepFecObjectIPv4Ver1.read(cb);
+ break;
+ case PcepFecObjectIPv6Ver1.FEC_OBJ_TYPE:
+ fecObject = PcepFecObjectIPv6Ver1.read(cb);
+ break;
+ case PcepFecObjectIPv4AdjacencyVer1.FEC_OBJ_TYPE:
+ fecObject = PcepFecObjectIPv4AdjacencyVer1.read(cb);
+ break;
+ case PcepFecObjectIPv6AdjacencyVer1.FEC_OBJ_TYPE:
+ fecObject = PcepFecObjectIPv6AdjacencyVer1.read(cb);
+ break;
+ case PcepFecObjectIPv4UnnumberedAdjacencyVer1.FEC_OBJ_TYPE:
+ fecObject = PcepFecObjectIPv4UnnumberedAdjacencyVer1.read(cb);
+ break;
+ default:
+ throw new PcepParseException("Unkown FEC object type " + tempObjHeader.getObjType());
+ }
+ labelMap.setFECObject(fecObject);
+ pceLabelUpdate.setLabelMap(labelMap);
+ } else {
+ throw new PcepParseException(
+ "Either <pce-label-download> or <pce-label-map> should be present. Received Class: "
+ + tempObjHeader.getObjClass());
+ }
+ return pceLabelUpdate;
+ }
+
+ @Override
+ public void write(ChannelBuffer cb) throws PcepParseException {
+
+ if ((labelDownload != null) && (labelMap != null)) {
+ throw new PcepParseException("Label Download and Label Map both can't be present.");
+ }
+
+ if ((labelDownload == null) && (labelMap == null)) {
+ throw new PcepParseException("Either Label Download or Label Map should be present.");
+ }
+
+ if (labelDownload != null) {
+
+ PcepLspObject lspObject;
+ PcepSrpObject srpObject;
+ PcepLabelObject labelObject;
+ LinkedList<PcepLabelObject> llLabelList;
+
+ srpObject = labelDownload.getSrpObject();
+ if (srpObject == null) {
+ throw new PcepParseException("SRP Object is mandatory object for Label Download.");
+ } else {
+ srpObject.write(cb);
+ }
+
+ lspObject = labelDownload.getLspObject();
+ if (lspObject == null) {
+ throw new PcepParseException("LSP Object is mandatory object for Label Download.");
+ } else {
+ lspObject.write(cb);
+ }
+
+ llLabelList = labelDownload.getLabelList();
+ if (llLabelList == null) {
+ throw new PcepParseException("Label list is mandatory object for Label Download.");
+ } else {
+ ListIterator<PcepLabelObject> listIterator = llLabelList.listIterator();
+ while (listIterator.hasNext()) {
+ labelObject = listIterator.next();
+ labelObject.write(cb);
+ }
+ }
+ }
+
+ if (labelMap != null) {
+
+ PcepSrpObject srpObject;
+ PcepLabelObject labelObject;
+ PcepFecObject fecObject;
+
+ srpObject = labelMap.getSrpObject();
+ if (srpObject == null) {
+ throw new PcepParseException("SRP Object is mandatory object for Label map.");
+ } else {
+ srpObject.write(cb);
+ }
+ labelObject = labelMap.getLabelObject();
+ if (labelObject == null) {
+ throw new PcepParseException("label Object is mandatory object for Label map.");
+ } else {
+ labelObject.write(cb);
+ }
+ fecObject = labelMap.getFECObject();
+ if (fecObject == null) {
+ throw new PcepParseException("fec Object is mandatory object for Label map.");
+ } else {
+ fecObject.write(cb);
+ }
+ }
+ }
+
+ @Override
+ public void setLabelDownload(PcepLabelDownload labelDownload) {
+ if (this.isLabelMapSet) {
+ return;
+ }
+ this.labelDownload = labelDownload;
+ this.isLabelDownloadSet = true;
+ }
+
+ @Override
+ public PcepLabelDownload getLabelDownload() {
+ return this.labelDownload;
+ }
+
+ @Override
+ public void setLabelMap(PcepLabelMap labelMap) {
+ if (this.isLabelDownloadSet) {
+ return;
+ }
+ this.labelMap = labelMap;
+ this.isLabelMapSet = true;
+ }
+
+ @Override
+ public PcepLabelMap getLabelMap() {
+ return this.labelMap;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("LabelDownload", labelDownload)
+ .add("LabelMap", labelMap)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java
new file mode 100644
index 00000000..2b319c12
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java
@@ -0,0 +1,575 @@
+/*
+ * 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.PcepLspObject;
+import org.onosproject.pcepio.types.PcepErrorDetailInfo;
+import org.onosproject.pcepio.types.PcepObjectHeader;
+import org.onosproject.pcepio.types.PcepValueType;
+import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
+import org.onosproject.pcepio.types.StatefulLspDbVerTlv;
+import org.onosproject.pcepio.types.StatefulLspErrorCodeTlv;
+import org.onosproject.pcepio.types.StatefulRsvpErrorSpecTlv;
+import org.onosproject.pcepio.types.SymbolicPathNameTlv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP lsp object.
+ */
+public class PcepLspObjectVer1 implements PcepLspObject {
+
+ /*
+ message format.
+ Reference : draft-ietf-pce-stateful-pce-11, section 7.3.
+ 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) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | PLSP-ID | Flag | O|A|R|S|D|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // TLVs //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ The LSP Object format
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PcepLspObjectVer1.class);
+
+ public static final byte LSP_OBJ_TYPE = 1;
+ public static final byte LSP_OBJ_CLASS = 32;
+ public static final byte LSP_OBJECT_VERSION = 1;
+
+ // LSP_OBJ_MINIMUM_LENGTH = CommonHeaderLen(4)+ LspObjectHeaderLen(4)+TlvAssumedMinLength(8)
+ public static final short LSP_OBJ_MINIMUM_LENGTH = 16;
+
+ public static final int DEFAULT_PLSPID = 0;
+ public static final byte DEFAULT_OFLAG = 1;
+ public static final boolean DEFAULT_AFLAG = false;
+ public static final boolean DEFAULT_RFLAG = false;
+ public static final boolean DEFAULT_SFLAG = false;
+ public static final boolean DEFAULT_DFLAG = false;
+ public static final int OBJECT_HEADER_LENGTH = 4;
+ public static final int PLSPID_SHIFT_VALUE = 12;
+ public static final int OFLAG_SHIFT_VALUE = 4;
+ public static final int AFLAG_SHIFT_VALUE = 3;
+ public static final int RFLAG_SHIFT_VALUE = 2;
+ public static final int SFLAG_SHIFT_VALUE = 1;
+ public static final int PLSPID_TEMP_SHIFT_VALUE = 0xFFFFF000;
+ public static final int OFLAG_TEMP_SHIFT_VALUE = 0x70;
+ public static final int AFLAG_TEMP_SHIFT_VALUE = 0x08;
+ public static final int RFLAG_TEMP_SHIFT_VALUE = 0x04;
+ public static final int SFLAG_TEMP_SHIFT_VALUE = 0x02;
+ public static final int DFLAG_TEMP_SHIFT_VALUE = 0x01;
+ public static final int BIT_SET = 1;
+ public static final int BIT_RESET = 0;
+ public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
+
+ static final PcepObjectHeader DEFAULT_LSP_OBJECT_HEADER = new PcepObjectHeader(LSP_OBJ_CLASS, LSP_OBJ_TYPE,
+ PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LSP_OBJ_MINIMUM_LENGTH);
+
+ private PcepObjectHeader lspObjHeader;
+ private int iPlspId;
+ // 3-bits
+ private byte yOFlag;
+ private boolean bAFlag;
+ private boolean bRFlag;
+ private boolean bSFlag;
+ private boolean bDFlag;
+
+ // Optional TLV
+ private LinkedList<PcepValueType> llOptionalTlv;
+
+ /**
+ * Constructor to initialize all the member variables.
+ *
+ * @param lspObjHeader lsp object header
+ * @param iPlspId plsp id
+ * @param yOFlag O flag
+ * @param bAFlag A flag
+ * @param bRFlag R flag
+ * @param bSFlag S flag
+ * @param bDFlag D flag
+ * @param llOptionalTlv list of optional tlv
+ */
+ public PcepLspObjectVer1(PcepObjectHeader lspObjHeader, int iPlspId, byte yOFlag, boolean bAFlag, boolean bRFlag,
+ boolean bSFlag, boolean bDFlag, LinkedList<PcepValueType> llOptionalTlv) {
+
+ this.lspObjHeader = lspObjHeader;
+ this.iPlspId = iPlspId;
+ this.yOFlag = yOFlag;
+ this.bAFlag = bAFlag;
+ this.bRFlag = bRFlag;
+ this.bSFlag = bSFlag;
+ this.bDFlag = bDFlag;
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ /**
+ * Sets lsp Object Header.
+ *
+ * @param obj lsp object header
+ */
+ public void setLspObjHeader(PcepObjectHeader obj) {
+ this.lspObjHeader = obj;
+ }
+
+ @Override
+ public void setPlspId(int iPlspId) {
+ this.iPlspId = iPlspId;
+ }
+
+ @Override
+ public void setOFlag(byte yOFlag) {
+ this.yOFlag = yOFlag;
+ }
+
+ @Override
+ public void setAFlag(boolean bAFlag) {
+ this.bAFlag = bAFlag;
+ }
+
+ @Override
+ public void setRFlag(boolean bRFlag) {
+ this.bRFlag = bRFlag;
+ }
+
+ @Override
+ public void setSFlag(boolean bSFlag) {
+ this.bSFlag = bSFlag;
+ }
+
+ @Override
+ public void setDFlag(boolean bDFlag) {
+ this.bDFlag = bDFlag;
+ }
+
+ /**
+ * Returns lsp object header.
+ *
+ * @return lspObjHeader
+ */
+ public PcepObjectHeader getLspObjHeader() {
+ return this.lspObjHeader;
+ }
+
+ @Override
+ public int getPlspId() {
+ return this.iPlspId;
+ }
+
+ @Override
+ public byte getOFlag() {
+ return this.yOFlag;
+ }
+
+ @Override
+ public boolean getAFlag() {
+ return this.bAFlag;
+ }
+
+ @Override
+ public boolean getRFlag() {
+ return this.bRFlag;
+ }
+
+ @Override
+ public boolean getSFlag() {
+ return this.bSFlag;
+ }
+
+ @Override
+ public boolean getDFlag() {
+ return this.bDFlag;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ /**
+ * Parse channel buffer and returns object of PcepLspObject.
+ *
+ * @param cb of type channel buffer
+ * @return object of PcepLspObject
+ * @throws PcepParseException when lsp object is not present in channel buffer
+ */
+ public static PcepLspObject read(ChannelBuffer cb) throws PcepParseException {
+
+ PcepObjectHeader lspObjHeader;
+ int iPlspId;
+ // 3-bits
+ byte yOFlag;
+ boolean bAFlag;
+ boolean bRFlag;
+ boolean bSFlag;
+ boolean bDFlag;
+
+ // Optional TLV
+ LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
+
+ lspObjHeader = PcepObjectHeader.read(cb);
+
+ if (lspObjHeader.getObjClass() != PcepLspObjectVer1.LSP_OBJ_CLASS) {
+ throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_6, PcepErrorDetailInfo.ERROR_VALUE_8);
+ }
+ //take only LspObject buffer.
+ ChannelBuffer tempCb = cb.readBytes(lspObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
+
+ Integer iTemp = tempCb.readInt();
+ iPlspId = (iTemp & PLSPID_TEMP_SHIFT_VALUE) >> PLSPID_SHIFT_VALUE;
+ Integer iX = (iTemp & OFLAG_TEMP_SHIFT_VALUE) >> OFLAG_SHIFT_VALUE;
+ yOFlag = iX.byteValue();
+ iX = (iTemp & AFLAG_TEMP_SHIFT_VALUE) >> AFLAG_SHIFT_VALUE;
+ bAFlag = iX > 0;
+ iX = (iTemp & RFLAG_TEMP_SHIFT_VALUE) >> RFLAG_SHIFT_VALUE;
+ bRFlag = iX > 0;
+ iX = (iTemp & SFLAG_TEMP_SHIFT_VALUE) >> SFLAG_SHIFT_VALUE;
+ bSFlag = iX > 0;
+ iX = iTemp & DFLAG_TEMP_SHIFT_VALUE;
+ bDFlag = iX > 0;
+
+ // parse optional TLV
+ llOptionalTlv = parseOptionalTlv(tempCb);
+
+ return new PcepLspObjectVer1(lspObjHeader, iPlspId, yOFlag, bAFlag, bRFlag, bSFlag, bDFlag, llOptionalTlv);
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) throws PcepParseException {
+
+ //write Object header
+ int objStartIndex = cb.writerIndex();
+
+ int objLenIndex = lspObjHeader.write(cb);
+
+ if (objLenIndex <= 0) {
+ throw new PcepParseException("Failed to write lsp object header. Index " + objLenIndex);
+ }
+
+ int iTemp = iPlspId << PLSPID_SHIFT_VALUE;
+ iTemp = iTemp | (yOFlag << OFLAG_SHIFT_VALUE);
+ byte bFlag;
+ iTemp = bAFlag ? (iTemp | AFLAG_TEMP_SHIFT_VALUE) : iTemp;
+
+ bFlag = (bRFlag) ? (byte) BIT_SET : BIT_RESET;
+ iTemp = iTemp | (bFlag << RFLAG_SHIFT_VALUE);
+ bFlag = (bSFlag) ? (byte) BIT_SET : BIT_RESET;
+ iTemp = iTemp | (bFlag << SFLAG_SHIFT_VALUE);
+ bFlag = (bDFlag) ? (byte) BIT_SET : BIT_RESET;
+ iTemp = iTemp | bFlag;
+ cb.writeInt(iTemp);
+
+ // Add optional TLV
+ packOptionalTlv(cb);
+
+ //Update object length now
+ int length = cb.writerIndex() - objStartIndex;
+ //will be helpful during print().
+ lspObjHeader.setObjLen((short) length);
+ // As per RFC the length of object should be
+ // multiples of 4
+
+ cb.setShort(objLenIndex, (short) length);
+
+ return length;
+ }
+
+ /**
+ * Returns Linked list of optional tlvs.
+ *
+ * @param cb of channel buffer.
+ * @return list of optional tlvs
+ * @throws PcepParseException when unsupported tlv is received
+ */
+ protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> llOutOptionalTlv;
+
+ 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 StatefulIPv4LspIdentidiersTlv.TYPE:
+ tlv = StatefulIPv4LspIdentidiersTlv.read(cb);
+ break;
+ case StatefulLspErrorCodeTlv.TYPE:
+ iValue = cb.readInt();
+ tlv = new StatefulLspErrorCodeTlv(iValue);
+ break;
+ case StatefulRsvpErrorSpecTlv.TYPE:
+ tlv = StatefulRsvpErrorSpecTlv.read(cb);
+ break;
+ case SymbolicPathNameTlv.TYPE:
+ tlv = SymbolicPathNameTlv.read(cb, hLength);
+ break;
+ case StatefulLspDbVerTlv.TYPE:
+ tlv = StatefulLspDbVerTlv.read(cb);
+ break;
+ default:
+ throw new PcepParseException("Received 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 writer index.
+ *
+ * @param cb of type channel buffer
+ * @return length of bytes written to channel buffer
+ */
+ protected int packOptionalTlv(ChannelBuffer cb) {
+
+ ListIterator<PcepValueType> 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);
+
+ // 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 cb.writerIndex() - startIndex;
+ }
+
+ /**
+ * Builder class for PCEP lsp Object.
+ */
+ public static class Builder implements PcepLspObject.Builder {
+
+ private boolean bIsHeaderSet = false;
+ private boolean bIsPlspIdSet = false;
+ private boolean bIsOFlagSet = false;
+ private boolean bIsRFlagSet = false;
+ private boolean bIsAFlagSet = false;
+ private boolean bIsDFlagSet = false;
+ private boolean bIsSFlagSet = false;
+
+ private PcepObjectHeader lspObjHeader;
+ private byte yOFlag;
+ private boolean bAFlag;
+ private boolean bDFlag;
+ private boolean bSFlag;
+ private boolean bRFlag;
+ LinkedList<PcepValueType> llOptionalTlv = null;
+
+ private int plspId;
+
+ private boolean bIsPFlagSet = false;
+ private boolean bPFlag;
+
+ private boolean bIsIFlagSet = false;
+ private boolean bIFlag;
+
+ @Override
+ public PcepLspObject build() {
+ PcepObjectHeader lspObjHeader = this.bIsHeaderSet ? this.lspObjHeader : DEFAULT_LSP_OBJECT_HEADER;
+
+ int plspId = this.bIsPlspIdSet ? this.plspId : DEFAULT_PLSPID;
+ byte yOFlag = this.bIsOFlagSet ? this.yOFlag : DEFAULT_OFLAG;
+ boolean bAFlag = this.bIsAFlagSet ? this.bAFlag : DEFAULT_AFLAG;
+ boolean bRFlag = this.bIsRFlagSet ? this.bRFlag : DEFAULT_RFLAG;
+ boolean bSFlag = this.bIsSFlagSet ? this.bSFlag : DEFAULT_SFLAG;
+ boolean bDFlag = this.bIsDFlagSet ? this.bDFlag : DEFAULT_DFLAG;
+
+ if (bIsPFlagSet) {
+ lspObjHeader.setPFlag(bPFlag);
+ }
+
+ if (bIsIFlagSet) {
+ lspObjHeader.setIFlag(bIFlag);
+ }
+
+ return new PcepLspObjectVer1(lspObjHeader, plspId, yOFlag, bAFlag, bRFlag, bSFlag, bDFlag, llOptionalTlv);
+ }
+
+ @Override
+ public PcepObjectHeader getLspObjHeader() {
+ return this.lspObjHeader;
+ }
+
+ @Override
+ public Builder setLspObjHeader(PcepObjectHeader obj) {
+ this.lspObjHeader = obj;
+ this.bIsHeaderSet = true;
+ return this;
+ }
+
+ @Override
+ public int getPlspId() {
+ return this.plspId;
+ }
+
+ @Override
+ public Builder setPlspId(int value) {
+ this.plspId = value;
+ this.bIsPlspIdSet = true;
+ return this;
+ }
+
+ @Override
+ public byte getOFlag() {
+ return this.yOFlag;
+ }
+
+ @Override
+ public Builder setOFlag(byte value) {
+ this.yOFlag = value;
+ this.bIsOFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public boolean getAFlag() {
+ return this.bAFlag;
+ }
+
+ @Override
+ public Builder setAFlag(boolean value) {
+ this.bAFlag = value;
+ this.bIsAFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public boolean getRFlag() {
+ return this.bRFlag;
+ }
+
+ @Override
+ public Builder setRFlag(boolean value) {
+ this.bRFlag = value;
+ this.bIsRFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public boolean getSFlag() {
+ return this.bSFlag;
+ }
+
+ @Override
+ public Builder setSFlag(boolean value) {
+ this.bSFlag = value;
+ this.bIsSFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public boolean getDFlag() {
+ return this.bDFlag;
+ }
+
+ @Override
+ public Builder setDFlag(boolean value) {
+ this.bDFlag = value;
+ this.bIsDFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> 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("PlspIDValue", iPlspId)
+ .add("OFlag", yOFlag)
+ .add("AFlag", bAFlag)
+ .add("RFlag", bRFlag)
+ .add("SFlag", bSFlag)
+ .add("DFlag", bDFlag)
+ .add("OptionalTlvList", llOptionalTlv)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspaObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspaObjectVer1.java
new file mode 100644
index 00000000..f4000509
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspaObjectVer1.java
@@ -0,0 +1,529 @@
+/*
+ * 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.PcepLspaObject;
+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 PcepLspaObjectVer1 implements PcepLspaObject {
+
+ /* LSPA Object Body Format
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Exclude-any |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Include-any |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Include-all |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Setup Prio | Holding Prio | Flags |L| Reserved |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ | Optional TLVs |
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepLspaObjectVer1.class);
+
+ public static final byte LSPA_OBJ_TYPE = 1;
+ public static final byte LSPA_OBJ_CLASS = 9;
+ public static final byte LSPA_OBJECT_VERSION = 1;
+ public static final short LSPA_OBJ_MINIMUM_LENGTH = 20;
+ public static final int OBJECT_HEADER_LENGTH = 4;
+
+ static final PcepObjectHeader DEFAULT_LSPA_OBJECT_HEADER = new PcepObjectHeader(LSPA_OBJ_CLASS, LSPA_OBJ_TYPE,
+ PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LSPA_OBJ_MINIMUM_LENGTH);
+
+ public static final int SETUP_PRIORITY_SHIFT_VALUE = 24;
+ public static final int HOLD_PRIORITY_SHIFT_VALUE = 16;
+ public static final int BFLAG_SHIFT_VALUE = 8;
+ public static final int LFLAG_SET = 1;
+ public static final int LFLAG_RESET = 0;
+ private PcepObjectHeader lspaObjHeader;
+ private int iExcludeAny;
+ private int iIncludeAny;
+ private int iIncludeAll;
+ private byte cSetupPriority;
+ private byte cHoldPriority;
+ private boolean bLFlag;
+ private LinkedList<PcepValueType> llOptionalTlv; //Optional TLV
+
+ /**
+ * Constructor to initialize member variables.
+ *
+ * @param lspaObjHeader lspa object header
+ * @param bLFlag b l flag
+ * @param iExcludeAny excludeAny value
+ * @param iIncludeAny includeAny value
+ * @param iIncludeAll includeAll value
+ * @param cSetupPriority setup priority value
+ * @param cHoldPriority hold priority value
+ * @param llOptionalTlv list of optional tlv
+ */
+ public PcepLspaObjectVer1(PcepObjectHeader lspaObjHeader, boolean bLFlag, int iExcludeAny, int iIncludeAny,
+ int iIncludeAll, byte cSetupPriority, byte cHoldPriority, LinkedList<PcepValueType> llOptionalTlv) {
+
+ this.lspaObjHeader = lspaObjHeader;
+ this.bLFlag = bLFlag;
+ this.iExcludeAny = iExcludeAny;
+ this.iIncludeAny = iIncludeAny;
+ this.iIncludeAll = iIncludeAll;
+ this.cSetupPriority = cSetupPriority;
+ this.cHoldPriority = cHoldPriority;
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ /**
+ * Sets Object Header.
+ *
+ * @param obj lspa object header
+ */
+ public void setLspaObjHeader(PcepObjectHeader obj) {
+ this.lspaObjHeader = obj;
+ }
+
+ @Override
+ public void setExcludeAny(int iExcludeAny) {
+ this.iExcludeAny = iExcludeAny;
+ }
+
+ @Override
+ public void setIncludeAny(int iIncludeAny) {
+ this.iIncludeAny = iIncludeAny;
+ }
+
+ @Override
+ public void setSetupPriority(byte cSetupPriority) {
+ this.cSetupPriority = cSetupPriority;
+ }
+
+ @Override
+ public void setHoldPriority(byte cHoldPriority) {
+ this.cHoldPriority = cHoldPriority;
+ }
+
+ @Override
+ public void setLFlag(boolean bLFlag) {
+ this.bLFlag = bLFlag;
+ }
+
+ /**
+ * Returns lspa Object Header.
+ *
+ * @return lspa Object Header
+ */
+ public PcepObjectHeader getLspaObjHeader() {
+ return this.lspaObjHeader;
+ }
+
+ @Override
+ public int getExcludeAny() {
+ return this.iExcludeAny;
+ }
+
+ @Override
+ public int getIncludeAny() {
+ return this.iIncludeAny;
+ }
+
+ @Override
+ public int getIncludeAll() {
+ return this.iIncludeAll;
+ }
+
+ @Override
+ public byte getSetupPriority() {
+ return this.cSetupPriority;
+ }
+
+ @Override
+ public byte getHoldPriority() {
+ return this.cHoldPriority;
+ }
+
+ @Override
+ public boolean getLFlag() {
+ return this.bLFlag;
+ }
+
+ @Override
+ public void setIncludeAll(int value) {
+ this.iIncludeAll = value;
+
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+
+ }
+
+ /**
+ * Reads channel buffer and returns object of PcepLspaObject.
+ *
+ * @param cb of type channel buffer.
+ * @return object of PcepLspaObject
+ * @throws PcepParseException while parsing lspa object from channel buffer
+ */
+ public static PcepLspaObject read(ChannelBuffer cb) throws PcepParseException {
+
+ log.debug("LspaObject::read");
+ PcepObjectHeader lspaObjHeader;
+ int iExcludeAny;
+ int iIncludeAny;
+ int iIncludeAll;
+ byte cSetupPriority;
+ byte cHoldPriority;
+ boolean bLFlag;
+ byte flags;
+
+ // Optional TLV
+ LinkedList<PcepValueType> llOptionalTlv;
+
+ lspaObjHeader = PcepObjectHeader.read(cb);
+
+ //take only Lspa Object buffer.
+ ChannelBuffer tempCb = cb.readBytes(lspaObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
+ iExcludeAny = tempCb.readInt();
+ iIncludeAny = tempCb.readInt();
+ iIncludeAll = tempCb.readInt();
+ cSetupPriority = tempCb.readByte();
+ cHoldPriority = tempCb.readByte();
+ flags = tempCb.readByte();
+ tempCb.readByte();
+
+ bLFlag = (flags & (byte) LFLAG_SET) == LFLAG_SET;
+
+ llOptionalTlv = parseOptionalTlv(tempCb);
+
+ return new PcepLspaObjectVer1(lspaObjHeader, bLFlag, iExcludeAny, iIncludeAny, iIncludeAll, cSetupPriority,
+ cHoldPriority, llOptionalTlv);
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) throws PcepParseException {
+
+ //write Object header
+ int objStartIndex = cb.writerIndex();
+
+ int objLenIndex = lspaObjHeader.write(cb);
+
+ if (objLenIndex <= 0) {
+ throw new PcepParseException("Failed to write lspa object header. Index " + objLenIndex);
+ }
+
+ cb.writeInt(iExcludeAny);
+ cb.writeInt(iIncludeAny);
+ cb.writeInt(iIncludeAll);
+
+ int iTemp = cSetupPriority << SETUP_PRIORITY_SHIFT_VALUE;
+ iTemp = iTemp | (cHoldPriority << HOLD_PRIORITY_SHIFT_VALUE);
+ byte bFlag;
+ bFlag = (bLFlag) ? (byte) LFLAG_SET : LFLAG_RESET;
+ iTemp = iTemp | (bFlag << BFLAG_SHIFT_VALUE);
+ cb.writeInt(iTemp);
+
+ // Add optional TLV
+ if (!packOptionalTlv(cb)) {
+ throw new PcepParseException("Faild to write lspa objects tlv to channel buffer");
+ }
+
+ short length = (short) (cb.writerIndex() - objStartIndex);
+
+ lspaObjHeader.setObjLen(length); //will be helpful during print().
+
+ //As per RFC the length of object should be multiples of 4
+ short pad = (short) (length % 4);
+
+ if (pad != 0) {
+ pad = (short) (4 - pad);
+ for (int i = 0; i < pad; i++) {
+ cb.writeByte((byte) 0);
+ }
+ length = (short) (length + pad);
+ }
+ cb.setShort(objLenIndex, length);
+ return cb.writerIndex();
+ }
+
+ /**
+ * Parse list of optional tlvs.
+ *
+ * @param cb channel buffer
+ * @return list of optional tlvs.
+ * @throws PcepParseException when fails to parse optional tlv list.
+ */
+ public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<>();
+
+ return llOutOptionalTlv;
+ }
+
+ /**
+ * Writes optional tlvs to channel buffer.
+ *
+ * @param cb channel buffer
+ * @return true
+ */
+ protected boolean packOptionalTlv(ChannelBuffer cb) {
+ int hTlvType;
+ int hTlvLength;
+
+ ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+ if (tlv == null) {
+ log.debug("Warning: tlv is null from OptionalTlv list");
+ continue;
+ }
+ hTlvType = tlv.getType();
+ hTlvLength = tlv.getLength();
+ if (0 == hTlvLength) {
+ log.debug("Warning: invalid length in tlv of OptionalTlv list");
+ continue;
+ }
+
+ cb.writeShort(hTlvType);
+ cb.writeShort(hTlvLength);
+
+ switch (hTlvType) {
+ //TODO: optional TLV for LSPA to be added
+
+ default:
+ log.debug("Warning: PcepLspaObject: unknown tlv");
+ }
+
+ // As per RFC the length of object should
+ // be multiples of 4
+ int pad = hTlvLength % 4;
+
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= cb.readableBytes()) {
+ cb.skipBytes(pad);
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Builder class for PCEP lspa object.
+ */
+ public static class Builder implements PcepLspaObject.Builder {
+ private boolean bIsHeaderSet = false;
+
+ private PcepObjectHeader lspaObjHeader;
+
+ private boolean bLFlag;
+ private int iExcludeAny;
+ private boolean bIsExcludeAnySet = false;
+ private int iIncludeAny;
+ private boolean bIsIncludeAnySet = false;
+ private int iIncludeAll;
+ private boolean bIsIncludeAllSet = false;
+ private byte cSetupPriority;
+ private boolean bIsSetupPrioritySet = false;
+ private byte cHoldPriority;
+ private boolean bIsHoldPrioritySet = false;
+ private LinkedList<PcepValueType> llOptionalTlv;
+
+ private boolean bIsPFlagSet = false;
+ private boolean bPFlag;
+
+ private boolean bIsIFlagSet = false;
+ private boolean bIFlag;
+
+ @Override
+ public PcepLspaObject build() throws PcepParseException {
+
+ PcepObjectHeader lspaObjHeader = this.bIsHeaderSet ? this.lspaObjHeader : DEFAULT_LSPA_OBJECT_HEADER;
+
+ if (!this.bIsExcludeAnySet) {
+ throw new PcepParseException("ExcludeAny NOT Set while building PcepLspaObject.");
+ }
+ if (!this.bIsIncludeAnySet) {
+ throw new PcepParseException("IncludeAny NOT Set while building PcepLspaObject.");
+ }
+ if (!this.bIsIncludeAllSet) {
+ throw new PcepParseException("IncludeAll NOT Set while building PcepLspaObject.");
+ }
+ if (!this.bIsSetupPrioritySet) {
+ throw new PcepParseException("Setup Priority NOT Set while building PcepLspaObject.");
+ }
+ if (!this.bIsHoldPrioritySet) {
+ throw new PcepParseException("Hold Priority NOT Set while building PcepLspaObject.");
+ }
+
+ if (bIsPFlagSet) {
+ lspaObjHeader.setPFlag(bPFlag);
+ }
+
+ if (bIsIFlagSet) {
+ lspaObjHeader.setIFlag(bIFlag);
+ }
+
+ return new PcepLspaObjectVer1(lspaObjHeader, bLFlag, iExcludeAny, iIncludeAny, iIncludeAll, cSetupPriority,
+ cHoldPriority, llOptionalTlv);
+ }
+
+ @Override
+ public PcepObjectHeader getLspaObjHeader() {
+ return this.lspaObjHeader;
+ }
+
+ @Override
+ public Builder setLspaObjHeader(PcepObjectHeader obj) {
+ this.lspaObjHeader = obj;
+ this.bIsHeaderSet = true;
+ return this;
+ }
+
+ @Override
+ public boolean getLFlag() {
+ return this.bLFlag;
+ }
+
+ @Override
+ public Builder setLFlag(boolean value) {
+ this.bLFlag = value;
+ return this;
+ }
+
+ @Override
+ public int getExcludeAny() {
+ return this.iExcludeAny;
+ }
+
+ @Override
+ public Builder setExcludeAny(int value) {
+ this.iExcludeAny = value;
+ this.bIsExcludeAnySet = true;
+ return this;
+ }
+
+ @Override
+ public int getIncludeAny() {
+ return this.iIncludeAny;
+ }
+
+ @Override
+ public Builder setIncludeAny(int value) {
+ this.iIncludeAny = value;
+ this.bIsIncludeAnySet = true;
+ return this;
+ }
+
+ @Override
+ public int getIncludeAll() {
+ return this.iIncludeAll;
+ }
+
+ @Override
+ public Builder setIncludeAll(int value) {
+ this.iIncludeAll = value;
+ this.bIsIncludeAllSet = true;
+ return this;
+ }
+
+ @Override
+ public byte getSetupPriority() {
+ return this.cSetupPriority;
+ }
+
+ @Override
+ public Builder setSetupPriority(byte value) {
+ this.cSetupPriority = value;
+ this.bIsSetupPrioritySet = true;
+ return this;
+ }
+
+ @Override
+ public byte getHoldPriority() {
+ return this.cHoldPriority;
+ }
+
+ @Override
+ public Builder setHoldPriority(byte value) {
+ this.cHoldPriority = value;
+ this.bIsHoldPrioritySet = true;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public Builder setOptionalTlv(LinkedList<PcepValueType> 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("LFlag", bLFlag)
+ .add("SetupPriority", cSetupPriority)
+ .add("HoldPriority", cHoldPriority)
+ .add("IncludeAll", iIncludeAll)
+ .add("IncludeAny", iIncludeAny)
+ .add("ExcludeAny", iExcludeAny)
+ .add("OptionalTlvList", llOptionalTlv)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMessageVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMessageVer1.java
new file mode 100644
index 00000000..2169a673
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMessageVer1.java
@@ -0,0 +1,132 @@
+/*
+ * 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.PcepFactories;
+import org.onosproject.pcepio.protocol.PcepMessage;
+import org.onosproject.pcepio.protocol.PcepMessageReader;
+import org.onosproject.pcepio.types.PcepErrorDetailInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provides PCEP messages.
+ */
+public abstract class PcepMessageVer1 {
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepFactories.class);
+
+ // version: 1.0
+ static final byte WIRE_VERSION = 1;
+ static final int MINIMUM_LENGTH = 4;
+ static final int PACKET_VERSION = 1;
+ static final byte OPEN_MSG_TYPE = 0x1;
+ static final byte KEEPALIVE_MSG_TYPE = 0x2;
+ static final byte REPORT_MSG_TYPE = 0xa;
+ static final byte TE_REPORT_MSG_TYPE = 0xe;
+ static final byte UPDATE_MSG_TYPE = 0xb;
+ static final byte INITIATE_MSG_TYPE = 0xc;
+ static final byte CLOSE_MSG_TYPE = 0x7;
+ static final byte ERROR_MSG_TYPE = 0x6;
+ static final byte LABEL_UPDATE_MSG_TYPE = 0xD;
+ static final byte LABEL_RANGE_RESV_MSG_TYPE = 0xF;
+ public static final int SHIFT_FLAG = 5;
+ static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
+
+ public static final PcepMessageVer1.Reader READER = new Reader();
+
+ /**
+ * Reader class for reading PCEP messages from channel buffer.
+ */
+ static class Reader implements PcepMessageReader<PcepMessage> {
+ @Override
+ public PcepMessage readFrom(ChannelBuffer cb) throws PcepParseException {
+
+ if (cb.readableBytes() < MINIMUM_LENGTH) {
+ throw new PcepParseException("Packet should have minimum length: " + MINIMUM_LENGTH);
+ }
+
+ try {
+ int start = cb.readerIndex();
+ // fixed value property version == 1
+ byte version = cb.readByte();
+ version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
+ if (version != (byte) PACKET_VERSION) {
+ throw new PcepParseException("Wrong version. Expected=PcepVersion.Message_1(1), got=" + version);
+ }
+
+ byte type = cb.readByte();
+ short length = cb.readShort();
+ cb.readerIndex(start);
+
+ switch (type) {
+
+ case OPEN_MSG_TYPE:
+ log.debug("OPEN MESSAGE is received");
+ // message type value 1 means it is open message
+ return PcepOpenMsgVer1.READER.readFrom(cb.readBytes(length));
+ case KEEPALIVE_MSG_TYPE:
+ log.debug("KEEPALIVE MESSAGE is received");
+ // message type value 2 means it is Keepalive message
+ return PcepKeepaliveMsgVer1.READER.readFrom(cb.readBytes(length));
+ case ERROR_MSG_TYPE:
+ log.debug("ERROR MESSAGE is received");
+ // message type value 6 means it is error message
+ return PcepErrorMsgVer1.READER.readFrom(cb.readBytes(length));
+ case REPORT_MSG_TYPE:
+ log.debug("REPORT MESSAGE is received");
+ // message type value 10 means it is Report message
+ // return
+ return PcepReportMsgVer1.READER.readFrom(cb.readBytes(length));
+ case UPDATE_MSG_TYPE:
+ log.debug("UPDATE MESSAGE is received");
+ //message type value 11 means it is Update message
+ return PcepUpdateMsgVer1.READER.readFrom(cb.readBytes(length));
+ case INITIATE_MSG_TYPE:
+ log.debug("INITIATE MESSAGE is received");
+ //message type value 12 means it is PcInitiate message
+ return PcepInitiateMsgVer1.READER.readFrom(cb.readBytes(length));
+ case CLOSE_MSG_TYPE:
+ log.debug("CLOSE MESSAGE is received");
+ // message type value 7 means it is Close message
+ return PcepCloseMsgVer1.READER.readFrom(cb.readBytes(length));
+ case TE_REPORT_MSG_TYPE:
+ log.debug("TE REPORT MESSAGE is received");
+ // message type value 14 means it is TE REPORT message
+ // return
+ return PcepTEReportMsgVer1.READER.readFrom(cb.readBytes(length));
+ case LABEL_UPDATE_MSG_TYPE:
+ log.debug("LABEL UPDATE MESSAGE is received");
+ // message type value 13 means it is LABEL UPDATE message
+ // return
+ return PcepLabelUpdateMsgVer1.READER.readFrom(cb.readBytes(length));
+ case LABEL_RANGE_RESV_MSG_TYPE:
+ log.debug("LABEL RANGE RESERVE MESSAGE is received");
+ // message type value 15 means it is LABEL RANGE RESERVE message
+ // return
+ return PcepLabelRangeResvMsgVer1.READER.readFrom(cb.readBytes(length));
+ default:
+ throw new PcepParseException("ERROR: UNKNOWN MESSAGE is received. Msg Type: " + type);
+ }
+ } catch (IndexOutOfBoundsException e) {
+ throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_1);
+ }
+ }
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMetricObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMetricObjectVer1.java
new file mode 100644
index 00000000..31c27870
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMetricObjectVer1.java
@@ -0,0 +1,376 @@
+/*
+ * 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.PcepMetricObject;
+import org.onosproject.pcepio.types.PcepObjectHeader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP metric object.
+ */
+public class PcepMetricObjectVer1 implements PcepMetricObject {
+
+ /*
+ METRIC Object Body Format.
+
+ 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 |C|B| T |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | metric-value |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepMetricObjectVer1.class);
+
+ public static final byte METRIC_OBJ_TYPE = 1;
+ public static final byte METRIC_OBJ_CLASS = 6;
+ public static final byte METRIC_OBJECT_VERSION = 1;
+ public static final short METRIC_OBJ_MINIMUM_LENGTH = 12;
+ public static final int OBJECT_HEADER_LENGTH = 4;
+ public static final int IFLAG_SHIFT_VALUE = 9;
+ public static final int BTYPE_SHIFT_VALUE = 8;
+ public static final int CFLAG_SET = 1;
+ public static final int CFLAG_RESET = 0;
+ public static final int BFLAG_SET = 1;
+ public static final int BFLAG_RESET = 0;
+ public static final byte CFLAG_CHECK = 0x02;
+
+ static final PcepObjectHeader DEFAULT_METRIC_OBJECT_HEADER = new PcepObjectHeader(METRIC_OBJ_CLASS,
+ METRIC_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
+ METRIC_OBJ_MINIMUM_LENGTH);
+
+ private PcepObjectHeader metricObjHeader;
+ private int iMetricVal;
+ private byte yFlag; // 6-flags
+ private boolean bCFlag;
+ private boolean bBFlag;
+ private byte bType;
+
+ /**
+ * Default constructor.
+ */
+ public PcepMetricObjectVer1() {
+ this.metricObjHeader = null;
+ this.iMetricVal = 0;
+ this.yFlag = 0;
+ this.bCFlag = false;
+ this.bBFlag = false;
+ this.bType = 0;
+
+ }
+
+ /**
+ * Constructor to initialize all member variables.
+ *
+ * @param metricObjHeader metric object header
+ * @param iMetricVal metric value
+ * @param yFlag Y flag
+ * @param bCFlag C flag
+ * @param bBFlag B flag
+ * @param bType Type value
+ */
+ public PcepMetricObjectVer1(PcepObjectHeader metricObjHeader, int iMetricVal, byte yFlag, boolean bCFlag,
+ boolean bBFlag, byte bType) {
+
+ this.metricObjHeader = metricObjHeader;
+ this.iMetricVal = iMetricVal;
+ this.yFlag = yFlag;
+ this.bCFlag = bCFlag;
+ this.bBFlag = bBFlag;
+ this.bType = bType;
+
+ }
+
+ @Override
+ public void setMetricVal(int value) {
+ this.iMetricVal = value;
+
+ }
+
+ @Override
+ public int getMetricVal() {
+ return this.iMetricVal;
+ }
+
+ @Override
+ public byte getYFlag() {
+ return this.yFlag;
+ }
+
+ @Override
+ public void setYFlag(byte value) {
+ this.yFlag = value;
+ }
+
+ @Override
+ public boolean getCFlag() {
+ return this.bCFlag;
+ }
+
+ @Override
+ public void setCFlag(boolean value) {
+ this.bCFlag = value;
+ }
+
+ @Override
+ public boolean getBFlag() {
+ return this.bBFlag;
+ }
+
+ @Override
+ public void setBFlag(boolean value) {
+ this.bBFlag = value;
+ }
+
+ @Override
+ public byte getBType() {
+ return this.bType;
+ }
+
+ @Override
+ public void setBType(byte value) {
+ this.bType = value;
+ }
+
+ /**
+ * Sets metric Object Header.
+ *
+ * @param obj metric object header
+ */
+ public void setMetricObjHeader(PcepObjectHeader obj) {
+ this.metricObjHeader = obj;
+ }
+
+ /**
+ * Returns metric Object Header.
+ *
+ * @return metricObjHeader
+ */
+ public PcepObjectHeader getMetricObjHeader() {
+ return this.metricObjHeader;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of PcepMetricObject.
+ *
+ * @param cb of channel buffer.
+ * @return object of PcepMetricObject
+ * @throws PcepParseException when metric object is not present in channel buffer
+ */
+ public static PcepMetricObject read(ChannelBuffer cb) throws PcepParseException {
+
+ log.debug("MetricObject::read");
+ PcepObjectHeader metricObjHeader;
+ int iMetricVal;
+ byte yFlag; // 6-flags
+ boolean bCFlag;
+ boolean bBFlag;
+ byte bType;
+
+ metricObjHeader = PcepObjectHeader.read(cb);
+
+ if (metricObjHeader.getObjClass() != METRIC_OBJ_CLASS) {
+ throw new PcepParseException("This object is not a Metric Object. Object Class: "
+ + metricObjHeader.getObjClass());
+ }
+
+ //take only metric buffer.
+ ChannelBuffer tempCb = cb.readBytes(metricObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
+
+ tempCb.readShort();
+ yFlag = tempCb.readByte();
+ bType = tempCb.readByte();
+ bCFlag = (yFlag & CFLAG_CHECK) == CFLAG_CHECK;
+ bBFlag = (yFlag & BFLAG_SET) == BFLAG_SET;
+ iMetricVal = tempCb.readInt();
+
+ return new PcepMetricObjectVer1(metricObjHeader, iMetricVal, yFlag, bCFlag, bBFlag, bType);
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) throws PcepParseException {
+ //write Object header
+ int objStartIndex = cb.writerIndex();
+
+ int objLenIndex = metricObjHeader.write(cb);
+
+ if (objLenIndex <= 0) {
+ throw new PcepParseException("Error: ObjectLength is " + objLenIndex);
+ }
+
+ int iFlag = (bCFlag) ? CFLAG_SET : CFLAG_RESET;
+ int iTemp = iFlag << IFLAG_SHIFT_VALUE;
+ iFlag = (bBFlag) ? BFLAG_SET : BFLAG_RESET;
+ iTemp = iTemp | (iFlag << BTYPE_SHIFT_VALUE);
+ iTemp = iTemp | bType;
+ cb.writeInt(iTemp);
+ cb.writeInt(iMetricVal);
+
+ short hLength = (short) (cb.writerIndex() - objStartIndex);
+ cb.setShort(objLenIndex, hLength);
+ //will be helpful during print().
+ metricObjHeader.setObjLen(hLength);
+ return hLength;
+ }
+
+ /**
+ * Builder class for PCEP metric object.
+ */
+ public static class Builder implements PcepMetricObject.Builder {
+
+ private boolean bIsHeaderSet = false;
+ private PcepObjectHeader metricObjHeader;
+ private int iMetricVal;
+ private boolean bIsMetricValSet = false;
+ private byte yFlag; // 6-flags
+ private boolean bCFlag;
+ private boolean bBFlag;
+ private byte bType;
+ private boolean bIsbTypeSet = false;
+
+ private boolean bIsPFlagSet = false;
+ private boolean bPFlag;
+
+ private boolean bIsIFlagSet = false;
+ private boolean bIFlag;
+
+ @Override
+ public PcepMetricObject build() throws PcepParseException {
+
+ PcepObjectHeader metricObjHeader = this.bIsHeaderSet ? this.metricObjHeader : DEFAULT_METRIC_OBJECT_HEADER;
+
+ if (!this.bIsMetricValSet) {
+ throw new PcepParseException(" Metric Value NOT Set while building PcepMetricObject.");
+ }
+ if (!this.bIsbTypeSet) {
+ throw new PcepParseException(" Type NOT Set while building PcepMetricObject.");
+ }
+
+ if (bIsPFlagSet) {
+ metricObjHeader.setPFlag(bPFlag);
+ }
+
+ if (bIsIFlagSet) {
+ metricObjHeader.setIFlag(bIFlag);
+ }
+
+ return new PcepMetricObjectVer1(metricObjHeader, iMetricVal, yFlag, bCFlag, bBFlag, bType);
+ }
+
+ @Override
+ public PcepObjectHeader getMetricObjHeader() {
+ return this.metricObjHeader;
+ }
+
+ @Override
+ public Builder setMetricObjHeader(PcepObjectHeader obj) {
+ this.metricObjHeader = obj;
+ this.bIsHeaderSet = true;
+ return this;
+ }
+
+ @Override
+ public int getMetricVal() {
+ return this.iMetricVal;
+ }
+
+ @Override
+ public Builder setMetricVal(int value) {
+ this.iMetricVal = value;
+ this.bIsMetricValSet = true;
+ return this;
+ }
+
+ @Override
+ public byte getYFlag() {
+ return this.yFlag;
+ }
+
+ @Override
+ public Builder setYFlag(byte value) {
+ this.yFlag = value;
+ return this;
+ }
+
+ @Override
+ public boolean getCFlag() {
+ return this.bCFlag;
+ }
+
+ @Override
+ public Builder setCFlag(boolean value) {
+ this.bCFlag = value;
+ return this;
+ }
+
+ @Override
+ public boolean getBFlag() {
+ return this.bBFlag;
+ }
+
+ @Override
+ public Builder setBFlag(boolean value) {
+ this.bBFlag = value;
+ return this;
+ }
+
+ @Override
+ public byte getBType() {
+ return this.bType;
+ }
+
+ @Override
+ public Builder setBType(byte value) {
+ this.bType = value;
+ this.bIsbTypeSet = 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("MetricValue", iMetricVal)
+ .add("BFlag", bBFlag)
+ .add("CFlag", bCFlag)
+ .add("BType", bType)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java
new file mode 100644
index 00000000..49c738fc
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepMsgPathVer1.java
@@ -0,0 +1,187 @@
+/*
+ * 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.PcepAttribute;
+import org.onosproject.pcepio.protocol.PcepEroObject;
+import org.onosproject.pcepio.protocol.PcepMsgPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP Message PAth for update message.
+ * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10.
+ */
+public class PcepMsgPathVer1 implements PcepMsgPath {
+
+ /*
+ * <path> ::= <ERO><attribute-list>
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepMsgPathVer1.class);
+ //PcepEroObject
+ private PcepEroObject eroObj;
+ private boolean isEroObjectSet;
+ // PcepAttribute
+ private PcepAttribute attrList;
+ private boolean isAttributeListSet;
+
+ /**
+ * constructor to initialize objects.
+ */
+ public PcepMsgPathVer1() {
+ eroObj = null;
+ attrList = null;
+ isEroObjectSet = false;
+ isAttributeListSet = false;
+ }
+
+ @Override
+ public PcepEroObject getEroObject() {
+ return eroObj;
+ }
+
+ @Override
+ public PcepAttribute getPcepAttribute() {
+ return attrList;
+ }
+
+ @Override
+ public void setEroObject(PcepEroObject eroObj) {
+ this.eroObj = eroObj;
+ }
+
+ @Override
+ public void setPcepAttribute(PcepAttribute attrList) {
+ this.attrList = attrList;
+ }
+
+ /**
+ * constructor to initialize member variables.
+ *
+ * @param eroObj pcep ero object
+ * @param attrList pcep attribute
+ */
+ public PcepMsgPathVer1(PcepEroObject eroObj, PcepAttribute attrList) {
+ this.eroObj = eroObj;
+ isEroObjectSet = true;
+ this.attrList = attrList;
+ if (attrList == null) {
+ isAttributeListSet = false;
+ } else {
+ isAttributeListSet = true;
+ }
+ }
+
+ @Override
+ public PcepMsgPath read(ChannelBuffer cb) throws PcepParseException {
+ PcepEroObject eroObj;
+ PcepAttribute attrList;
+
+ eroObj = PcepEroObjectVer1.read(cb);
+ attrList = PcepAttributeVer1.read(cb);
+
+ return new PcepMsgPathVer1(eroObj, attrList);
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) throws PcepParseException {
+ int iLenStartIndex = cb.writerIndex();
+
+ //write Object header
+ if (this.isEroObjectSet) {
+ this.eroObj.write(cb);
+ }
+ if (this.isAttributeListSet) {
+ attrList.write(cb);
+ }
+
+ return cb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Builder class for PCEP Message path.
+ */
+ public static class Builder implements PcepMsgPath.Builder {
+
+ private boolean bIsEROObjectSet = false;
+ private boolean bIsPcepAttributeSet = false;
+
+ //PCEP ERO Object
+ private PcepEroObject eroObject;
+ //PCEP Attribute list
+ private PcepAttribute pcepAttribute;
+
+ @Override
+ public PcepMsgPath build() throws PcepParseException {
+
+ //PCEP ERO Object
+ PcepEroObject eroObject = null;
+ //PCEP Attribute list
+ PcepAttribute pcepAttribute = null;
+
+ if (!this.bIsEROObjectSet) {
+ throw new PcepParseException("ERO Object NOT Set while building PcepMsgPath.");
+ } else {
+ eroObject = this.eroObject;
+ }
+ if (!this.bIsPcepAttributeSet) {
+ throw new PcepParseException("Pcep Attributes NOT Set while building PcepMsgPath.");
+ } else {
+ pcepAttribute = this.pcepAttribute;
+ }
+
+ return new PcepMsgPathVer1(eroObject, pcepAttribute);
+ }
+
+ @Override
+ public PcepEroObject getEroObject() {
+ return this.eroObject;
+ }
+
+ @Override
+ public PcepAttribute getPcepAttribute() {
+ return this.pcepAttribute;
+ }
+
+ @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())
+ .add("EroObject", eroObj)
+ .add("AttributeList", attrList)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenMsgVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenMsgVer1.java
new file mode 100644
index 00000000..902226e9
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenMsgVer1.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 org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepMessageReader;
+import org.onosproject.pcepio.protocol.PcepMessageWriter;
+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.PcepErrorDetailInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP open message.
+ */
+public class PcepOpenMsgVer1 implements PcepOpenMsg {
+
+ /*
+ * <Open Message>::= <Common Header> <OPEN>
+ 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) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Ver | Flags | Keepalive | DeadTimer | SID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Optional TLVs //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ 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.OPEN;
+ private PcepOpenObject pcepOpenObj;
+
+ public static final PcepOpenMsgVer1.Reader READER = new Reader();
+
+ /**
+ * Constructor to initialize PcepOpenObject.
+ *
+ * @param pcepOpenObj PCEP-OPEN-OBJECT
+ */
+ public PcepOpenMsgVer1(PcepOpenObject pcepOpenObj) {
+ this.pcepOpenObj = pcepOpenObj;
+ }
+
+ @Override
+ public PcepOpenObject getPcepOpenObject() {
+ return this.pcepOpenObj;
+ }
+
+ @Override
+ public void setPcepOpenObject(PcepOpenObject pcepOpenObj) {
+ this.pcepOpenObj = pcepOpenObj;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public PcepType getType() {
+ return MSG_TYPE;
+ }
+
+ /**
+ * Reader class for reading PCEP open message from channel buffer.
+ */
+ public static class Reader implements PcepMessageReader<PcepOpenMsg> {
+
+ @Override
+ public PcepOpenMsg readFrom(ChannelBuffer cb) throws PcepParseException {
+
+ 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) {
+ log.error("[readFrom] Invalid version: " + version);
+ throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_1);
+ }
+ // fixed value property type == 1
+ byte type = cb.readByte();
+
+ if (type != MSG_TYPE.getType()) {
+ log.error("[readFrom] Unexpected type: " + type);
+ throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_1);
+ }
+ int length = cb.readShort();
+ if (length < PACKET_MINIMUM_LENGTH) {
+ throw new PcepParseException(
+ "Wrong length: Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: " + length);
+ }
+ return new PcepOpenMsgVer1(PcepOpenObjectVer1.read(cb));
+ }
+ }
+
+ /**
+ * Builder class for PCEP open message.
+ */
+ static class Builder implements PcepOpenMsg.Builder {
+
+ private PcepOpenObject pcepOpenObj;
+
+ @Override
+ public PcepOpenMsg build() throws PcepParseException {
+ if (!(pcepOpenObj instanceof PcepOpenObjectVer1)) {
+ throw new NullPointerException("PcepOpenObject is null.");
+ }
+ return new PcepOpenMsgVer1(pcepOpenObj);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public PcepType getType() {
+ return PcepType.OPEN;
+ }
+
+ @Override
+ public PcepOpenObject getPcepOpenObj() {
+ return this.pcepOpenObj;
+ }
+
+ @Override
+ public Builder setPcepOpenObj(PcepOpenObject obj) {
+ this.pcepOpenObj = obj;
+ 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 opne message to channel buffer.
+ */
+ public static class Writer implements PcepMessageWriter<PcepOpenMsgVer1> {
+
+ @Override
+ public void write(ChannelBuffer cb, PcepOpenMsgVer1 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 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);
+
+ message.getPcepOpenObject().write(cb);
+
+ // update message length field
+ int iLength = cb.writerIndex() - startIndex;
+ cb.setShort(msgLenIndex, (short) iLength);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("OpenObject", pcepOpenObj)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java
new file mode 100644
index 00000000..d5e58694
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java
@@ -0,0 +1,491 @@
+/*
+ * 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.PcepOpenObject;
+import org.onosproject.pcepio.protocol.PcepType;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.onosproject.pcepio.types.GmplsCapabilityTlv;
+import org.onosproject.pcepio.types.PceccCapabilityTlv;
+import org.onosproject.pcepio.types.PcepLabelDbVerTlv;
+import org.onosproject.pcepio.types.PcepObjectHeader;
+import org.onosproject.pcepio.types.PcepValueType;
+import org.onosproject.pcepio.types.StatefulLspDbVerTlv;
+import org.onosproject.pcepio.types.StatefulPceCapabilityTlv;
+import org.onosproject.pcepio.types.TedCapabilityTlv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP open object.
+ */
+public class PcepOpenObjectVer1 implements PcepOpenObject {
+
+ /*
+ message format.
+ 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) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Ver | Flags | Keepalive | DeadTimer | SID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Optional TLVs //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ The OPEN Object format
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PcepOpenObjectVer1.class);
+
+ public static final PcepType MSG_TYPE = PcepType.OPEN;
+ public static final byte OPEN_OBJECT_VERSION = 1;
+ public static final byte OPEN_OBJ_TYPE = 1;
+ public static final byte OPEN_OBJ_CLASS = 1;
+ public static final byte DEFAULT_KEEPALIVE_TIME = 30;
+ public static final byte DEFAULT_DEAD_TIME = 120;
+ public static final short OPEN_OBJ_MINIMUM_LENGTH = 8;
+ public static final int DEFAULT_GMPLS_CAPABILITY_TLV_IVALUE = 0X0;
+ public static final int DEFAULT_STATEFUL_PCE_CAPABILITY_TLV_IVALUE = 0xf;
+ public static final int DEFAULT_PCECC_CAPABILITY_TLV_IVALUE = 0x7;
+ public static final int DEFAULT_PCEP_LABEL_DB_VER_TLV_IVALUE = 0X0;
+
+ public static final PcepObjectHeader DEFAULT_OPEN_HEADER = new PcepObjectHeader(OPEN_OBJ_CLASS, OPEN_OBJ_TYPE,
+ PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, OPEN_OBJ_MINIMUM_LENGTH);
+
+ private PcepObjectHeader openObjHeader;
+ private byte keepAliveTime;
+ private byte deadTime;
+ private byte sessionId;
+ private LinkedList<PcepValueType> llOptionalTlv;
+
+ /**
+ * Default constructor.
+ */
+ public PcepOpenObjectVer1() {
+ this.openObjHeader = null;
+ this.keepAliveTime = 0;
+ this.deadTime = 0;
+ this.sessionId = 0;
+ this.llOptionalTlv = null;
+ }
+
+ /**
+ * Constructor to initialize all member variables.
+ *
+ * @param openObjHeader Open Object Header
+ * @param keepAliveTime Keepalive timer value
+ * @param deadTime Dead timer value
+ * @param sessionID session id
+ * @param llOptionalTlv Optional TLV
+ */
+ public PcepOpenObjectVer1(PcepObjectHeader openObjHeader, byte keepAliveTime, byte deadTime, byte sessionID,
+ LinkedList<PcepValueType> llOptionalTlv) {
+ this.openObjHeader = openObjHeader;
+ this.keepAliveTime = keepAliveTime;
+ this.deadTime = deadTime;
+ this.sessionId = sessionID;
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ @Override
+ public PcepObjectHeader getOpenObjHeader() {
+ return this.openObjHeader;
+ }
+
+ @Override
+ public void setOpenObjHeader(PcepObjectHeader obj) {
+ this.openObjHeader = obj;
+ }
+
+ @Override
+ public byte getKeepAliveTime() {
+ return this.keepAliveTime;
+ }
+
+ @Override
+ public void setKeepAliveTime(byte value) {
+ this.keepAliveTime = value;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public byte getDeadTime() {
+ return this.deadTime;
+ }
+
+ @Override
+ public void setDeadTime(byte value) {
+ this.deadTime = value;
+ }
+
+ @Override
+ public byte getSessionId() {
+ return this.sessionId;
+ }
+
+ @Override
+ public void setSessionId(byte value) {
+ this.sessionId = value;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of PcepOpenObject.
+ *
+ * @param cb of type channel buffer
+ * @return object of PcepOpenObject
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepOpenObject read(ChannelBuffer cb) throws PcepParseException {
+
+ PcepObjectHeader openObjHeader;
+ byte version;
+ byte keepAliveTime;
+ byte deadTime;
+ byte sessionID;
+ LinkedList<PcepValueType> llOptionalTlv;
+
+ openObjHeader = PcepObjectHeader.read(cb);
+ version = cb.readByte();
+ version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
+ if (version != OPEN_OBJECT_VERSION) {
+ throw new PcepParseException("Wrong version: Expected=PcepVersion.PCEP_1(1), got=" + version);
+ }
+ /* Keepalive */
+ keepAliveTime = cb.readByte();
+
+ /* DeadTimer */
+ deadTime = cb.readByte();
+
+ /* SID */
+ sessionID = cb.readByte();
+
+ // Optional TLV
+ llOptionalTlv = parseOptionalTlv(cb);
+
+ return new PcepOpenObjectVer1(openObjHeader, keepAliveTime, deadTime, sessionID, llOptionalTlv);
+ }
+
+ /**
+ * Returns linkedlist of optional tlvs.
+ *
+ * @param cb of type channel buffer
+ * @return llOptionalTlv Optional TLV
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> llOptionalTlv;
+
+ llOptionalTlv = new LinkedList<>();
+
+ while (4 <= cb.readableBytes()) {
+ PcepValueType tlv;
+ short hType = cb.readShort();
+ short hLength = cb.readShort();
+
+ switch (hType) {
+ case GmplsCapabilityTlv.TYPE:
+ log.debug("GmplsCapabilityTlv");
+ if (GmplsCapabilityTlv.LENGTH != hLength) {
+ throw new PcepParseException("Invalid length received for Gmpls_Capability_Tlv.");
+ }
+ int iValue = cb.readInt();
+ tlv = new GmplsCapabilityTlv(iValue);
+ break;
+ case StatefulPceCapabilityTlv.TYPE:
+ log.debug("StatefulPceCapabilityTlv");
+ if (StatefulPceCapabilityTlv.LENGTH != hLength) {
+ throw new PcepParseException("Invalid length received for StatefulPceCapabilityTlv.");
+ }
+ tlv = StatefulPceCapabilityTlv.read(cb);
+ break;
+ case PceccCapabilityTlv.TYPE:
+ log.debug("PceccCapabilityTlv");
+ if (PceccCapabilityTlv.LENGTH != hLength) {
+ throw new PcepParseException("Invalid length for PceccCapabilityTlv.");
+ }
+ iValue = cb.readInt();
+ tlv = new PceccCapabilityTlv(iValue);
+ break;
+ case StatefulLspDbVerTlv.TYPE:
+ log.debug("StatefulLspDbVerTlv");
+ if (StatefulLspDbVerTlv.LENGTH != hLength) {
+ throw new PcepParseException("Invalid length received for StatefulLspDbVerTlv.");
+ }
+ long lValue = cb.readLong();
+ tlv = new StatefulLspDbVerTlv(lValue);
+ break;
+ case TedCapabilityTlv.TYPE:
+ log.debug("TedCapabilityTlv");
+ if (TedCapabilityTlv.LENGTH != hLength) {
+ throw new PcepParseException("Invalid length received for TedCapabilityTlv.");
+ }
+ iValue = cb.readInt();
+ tlv = new TedCapabilityTlv(iValue);
+ break;
+ case PcepLabelDbVerTlv.TYPE:
+ log.debug("PcepLabelDbVerTlv");
+ if (PcepLabelDbVerTlv.LENGTH != hLength) {
+ throw new PcepParseException("Invalid length received for PcepLabelDbVerTlv.");
+ }
+ lValue = cb.readLong();
+ tlv = new PcepLabelDbVerTlv(lValue);
+ break;
+ default:
+ log.debug("Unsupported TLV: " + hType);
+ cb.skipBytes(hLength);
+ continue;
+ }
+
+ llOptionalTlv.add(tlv);
+ }
+
+ if (0 < cb.readableBytes()) {
+ throw new PcepParseException("Optional Tlv parsing error. Extra bytes received.");
+ }
+
+ return llOptionalTlv;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) throws PcepParseException {
+
+ int objStartIndex = cb.writerIndex();
+
+ //write common header
+ int objLenIndex = openObjHeader.write(cb);
+
+ if (objLenIndex <= 0) {
+ throw new PcepParseException("Unable to write Open object header.");
+ }
+
+ cb.writeByte((byte) (OPEN_OBJECT_VERSION << PcepMessageVer1.SHIFT_FLAG));
+ cb.writeByte(this.keepAliveTime);
+ cb.writeByte(this.deadTime);
+ cb.writeByte(this.sessionId);
+
+ //Pack optional TLV
+ packOptionalTlv(cb);
+
+ //now write OPEN Object Length
+ int length = cb.writerIndex() - objStartIndex;
+ cb.setShort(objLenIndex, (short) length);
+ //will be helpful during print().
+ this.openObjHeader.setObjLen((short) length);
+
+ return length;
+ }
+
+ /**
+ * Returns writer index.
+ *
+ * @param cb of type channel buffer.
+ * @return writer index
+ */
+ protected int packOptionalTlv(ChannelBuffer cb) {
+ int startIndex = cb.writerIndex();
+
+ LinkedList<PcepValueType> llOptionalTlv = this.llOptionalTlv;
+ ListIterator<PcepValueType> 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 cb.writerIndex() - startIndex;
+ }
+
+ /**
+ * Builder class for PCPE open object.
+ */
+ public static class Builder implements PcepOpenObject.Builder {
+ // Pcep open message fields
+ private boolean bIsHeaderSet = false;
+ private PcepObjectHeader openObjHeader;
+ private boolean bIsKeepAliveTimeSet = false;
+ private byte keepAliveTime;
+ private boolean bIsDeadTimeSet = false;
+ private byte deadTime;
+ private boolean bIsSessionIDSet = false;
+ private byte sessionID;
+ private boolean bIsOptionalTlvSet = false;
+ private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
+
+ private boolean bIsPFlagSet = false;
+ private boolean bPFlag;
+
+ private boolean bIsIFlagSet = false;
+ private boolean bIFlag;
+
+ @Override
+ public PcepOpenObject build() throws PcepParseException {
+ PcepObjectHeader openObjHeader = this.bIsHeaderSet ? this.openObjHeader : DEFAULT_OPEN_HEADER;
+ byte keepAliveTime = this.bIsKeepAliveTimeSet ? this.keepAliveTime : DEFAULT_KEEPALIVE_TIME;
+ byte deadTime = this.bIsDeadTimeSet ? this.deadTime : DEFAULT_DEAD_TIME;
+
+ if (!this.bIsSessionIDSet) {
+ throw new PcepParseException("SessionID is not set (mandatory)");
+ }
+ if (!this.bIsOptionalTlvSet) {
+ //Add tlv to list
+ //Add GmplsCapabilityTlv
+ PcepValueType tlv;
+ int iValue = DEFAULT_GMPLS_CAPABILITY_TLV_IVALUE;
+ tlv = new GmplsCapabilityTlv(iValue);
+ this.llOptionalTlv.add(tlv);
+
+ //Add StatefulPceCapabilityTlv
+ iValue = DEFAULT_STATEFUL_PCE_CAPABILITY_TLV_IVALUE;
+ tlv = new StatefulPceCapabilityTlv(iValue);
+ this.llOptionalTlv.add(tlv);
+
+ }
+
+ if (bIsPFlagSet) {
+ openObjHeader.setPFlag(bPFlag);
+ }
+
+ if (bIsIFlagSet) {
+ openObjHeader.setIFlag(bIFlag);
+ }
+
+ return new PcepOpenObjectVer1(openObjHeader, keepAliveTime, deadTime, this.sessionID, this.llOptionalTlv);
+ }
+
+ @Override
+ public PcepObjectHeader getOpenObjHeader() {
+ return this.openObjHeader;
+ }
+
+ @Override
+ public Builder setOpenObjHeader(PcepObjectHeader obj) {
+ this.openObjHeader = obj;
+ this.bIsHeaderSet = true;
+ return this;
+ }
+
+ @Override
+ public byte getKeepAliveTime() {
+ return this.keepAliveTime;
+ }
+
+ @Override
+ public Builder setKeepAliveTime(byte value) {
+ this.keepAliveTime = value;
+ this.bIsKeepAliveTimeSet = true;
+ return this;
+ }
+
+ @Override
+ public byte getDeadTime() {
+ return this.deadTime;
+ }
+
+ @Override
+ public Builder setDeadTime(byte value) {
+ this.deadTime = value;
+ this.bIsDeadTimeSet = true;
+ return this;
+ }
+
+ @Override
+ public byte getSessionId() {
+ return this.sessionID;
+ }
+
+ @Override
+ public Builder setSessionId(byte value) {
+ this.sessionID = value;
+ this.bIsSessionIDSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+ this.bIsOptionalTlvSet = true;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> 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", openObjHeader)
+ .add("Keepalive", keepAliveTime)
+ .add("DeadTimer", deadTime)
+ .add("SessionId", sessionId)
+ .add("OptionalTlv", llOptionalTlv)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRPObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRPObjectVer1.java
new file mode 100644
index 00000000..7234a467
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRPObjectVer1.java
@@ -0,0 +1,445 @@
+/*
+ * 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.PcepRPObject;
+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 RP object.
+ */
+public class PcepRPObjectVer1 implements PcepRPObject {
+
+ /*
+ * RP Object.
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Flags |O|B|R| Pri |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Request-ID-number |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Optional TLVs //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepRPObjectVer1.class);
+
+ public static final byte RP_OBJ_TYPE = 1;
+ public static final byte RP_OBJ_CLASS = 2;
+ public static final byte RP_OBJECT_VERSION = 1;
+ public static final short RP_OBJ_MINIMUM_LENGTH = 12;
+
+ public static final int DEFAULT_REQUEST_ID_NUM = 0;
+ //Signalled , all default values to be checked.
+ public static final boolean DEFAULT_OFLAG = false;
+ public static final boolean DEFAULT_BFLAG = false;
+ public static final boolean DEFAULT_RFLAG = false;
+ public static final byte DEFAULT_PRIFLAG = 0;
+ public static final int OBJECT_HEADER_LENGTH = 4;
+ public static final int OFLAG_SHIFT_VALUE = 5;
+ public static final int BFLAG_SHIFT_VALUE = 4;
+ public static final int RFLAG_SHIFT_VALUE = 3;
+ public static final int OFLAG_TEMP_SHIFT_VALUE = 0x20;
+ public static final int BFLAG_TEMP_SHIFT_VALUE = 0x10;
+ public static final int RFLAG_TEMP_SHIFT_VALUE = 0x08;
+ public static final int PRIFLAG_TEMP_SHIFT_VALUE = 0x07;
+ public static final int BIT_SET = 1;
+ public static final int BIT_RESET = 0;
+ public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
+
+ public static final PcepObjectHeader DEFAULT_RP_OBJECT_HEADER = new PcepObjectHeader(RP_OBJ_CLASS, RP_OBJ_TYPE,
+ PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, RP_OBJ_MINIMUM_LENGTH);
+
+ private PcepObjectHeader rpObjHeader;
+ private int iRequestIdNum;
+ private boolean bOFlag;
+ private boolean bBFlag;
+ private boolean bRFlag;
+ private byte yPriFlag; // 3bytes
+ private LinkedList<PcepValueType> llOptionalTlv;
+
+ /**
+ * Constructor to initialize variables.
+ *
+ * @param rpObjHeader RP-OBJECT header
+ * @param iRequestIdNum Request-ID-number
+ * @param bOFlag O-flag
+ * @param bBFlag B-flag
+ * @param bRFlag R-flag
+ * @param yPriFlag Pri-flag
+ * @param llOptionalTlv linked list of Optional TLV
+ */
+ public PcepRPObjectVer1(PcepObjectHeader rpObjHeader, int iRequestIdNum, boolean bOFlag, boolean bBFlag,
+ boolean bRFlag, byte yPriFlag, LinkedList<PcepValueType> llOptionalTlv) {
+ this.rpObjHeader = rpObjHeader;
+ this.iRequestIdNum = iRequestIdNum;
+ this.bOFlag = bOFlag;
+ this.bBFlag = bBFlag;
+ this.bRFlag = bRFlag;
+ this.yPriFlag = yPriFlag;
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ /**
+ * Sets RP Object header.
+ *
+ * @param obj RP Object header
+ */
+ public void setRPObjHeader(PcepObjectHeader obj) {
+ this.rpObjHeader = obj;
+ }
+
+ @Override
+ public void setRequestIdNum(int iRequestIdNum) {
+ this.iRequestIdNum = iRequestIdNum;
+ }
+
+ @Override
+ public void setOFlag(boolean bOFlag) {
+ this.bOFlag = bOFlag;
+ }
+
+ @Override
+ public void setBFlag(boolean bBFlag) {
+ this.bBFlag = bBFlag;
+ }
+
+ @Override
+ public void setRFlag(boolean bRFlag) {
+ this.bRFlag = bRFlag;
+ }
+
+ @Override
+ public void setPriFlag(byte yPriFlag) {
+ this.yPriFlag = yPriFlag;
+ }
+
+ /**
+ * Returns RP Object header.
+ *
+ * @return rpObjHeader
+ */
+ public PcepObjectHeader getRPObjHeader() {
+ return this.rpObjHeader;
+ }
+
+ @Override
+ public int getRequestIdNum() {
+ return this.iRequestIdNum;
+ }
+
+ @Override
+ public boolean getOFlag() {
+ return this.bOFlag;
+ }
+
+ @Override
+ public boolean getBFlag() {
+ return this.bBFlag;
+ }
+
+ @Override
+ public boolean getRFlag() {
+ return this.bRFlag;
+ }
+
+ @Override
+ public byte getPriFlag() {
+ return this.yPriFlag;
+ }
+
+ /**
+ * Reads the channel buffer and returns the object of PcepRPObject.
+ *
+ * @param cb of type channel buffer
+ * @return the object of PcepRPObject
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepRPObject read(ChannelBuffer cb) throws PcepParseException {
+ log.debug("read");
+ PcepObjectHeader rpObjHeader;
+ int iRequestIdNum;
+ boolean bOFlag;
+ boolean bBFlag;
+ boolean bRFlag;
+ byte yPriFlag; // 3bytes
+ LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
+
+ rpObjHeader = PcepObjectHeader.read(cb);
+
+ //take only LspObject buffer.
+ ChannelBuffer tempCb = cb.readBytes(rpObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
+
+ int iTemp = tempCb.readInt();
+ yPriFlag = (byte) (iTemp & PRIFLAG_TEMP_SHIFT_VALUE);
+ bOFlag = (iTemp & OFLAG_TEMP_SHIFT_VALUE) == OFLAG_TEMP_SHIFT_VALUE;
+ bBFlag = (iTemp & BFLAG_TEMP_SHIFT_VALUE) == BFLAG_TEMP_SHIFT_VALUE;
+ bRFlag = (iTemp & RFLAG_TEMP_SHIFT_VALUE) == RFLAG_TEMP_SHIFT_VALUE;
+
+ iRequestIdNum = tempCb.readInt();
+
+ // parse optional TLV
+ llOptionalTlv = parseOptionalTlv(tempCb);
+
+ return new PcepRPObjectVer1(rpObjHeader, iRequestIdNum, bOFlag, bBFlag, bRFlag, yPriFlag, llOptionalTlv);
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) throws PcepParseException {
+
+ //write Object header
+ int objStartIndex = cb.writerIndex();
+
+ int objLenIndex = rpObjHeader.write(cb);
+
+ if (objLenIndex <= 0) {
+ throw new PcepParseException("ObjectLength Index is " + objLenIndex);
+ }
+ int iTemp;
+ iTemp = (yPriFlag);
+
+ iTemp = (bOFlag) ? (iTemp | OFLAG_SHIFT_VALUE) : iTemp;
+ iTemp = (bBFlag) ? (iTemp | BFLAG_SHIFT_VALUE) : iTemp;
+ iTemp = (bRFlag) ? (iTemp | RFLAG_SHIFT_VALUE) : iTemp;
+
+ cb.writeInt(iTemp);
+ cb.writeInt(iRequestIdNum);
+
+ // Add optional TLV
+ packOptionalTlv(cb);
+
+ //Update object length now
+ int length = cb.writerIndex() - objStartIndex;
+
+ //will be helpful during print().
+ rpObjHeader.setObjLen((short) length);
+
+ cb.setShort(objLenIndex, (short) length);
+ return cb.writerIndex();
+ }
+
+ /**
+ * Returns list of optional tlvs.
+ *
+ * @param cb of type channel buffer.
+ * @return llOutOptionalTlv linked list of Optional TLV
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<>();
+ //Currently no optional TLvs, will be added based on requirements.
+ return llOutOptionalTlv;
+ }
+
+ /**
+ * Returns optional tlvs.
+ *
+ * @param cb of type channel buffer
+ * @return llOptionalTlv linked list of Optional TLV
+ */
+ protected int packOptionalTlv(ChannelBuffer cb) {
+
+ ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
+ while (listIterator.hasNext()) {
+ listIterator.next().write(cb);
+ }
+
+ return cb.writerIndex();
+ }
+
+ /**
+ * Builder class for PCEP rp object.
+ */
+ public static class Builder implements PcepRPObject.Builder {
+
+ private boolean bIsHeaderSet = false;
+ private boolean bIsRequestIdNumSet = false;
+ private boolean bIsOFlagSet = false;
+ private boolean bIsRFlagset = false;
+ private boolean bIsBFlagSet = false;
+ private boolean bIsPriFlagSet = false;
+
+ private PcepObjectHeader rpObjHeader;
+ private int requestIdNum;
+ private boolean bOFlag;
+ private boolean bBFlag;
+ private boolean bRFlag;
+ private byte yPriFlag;
+ private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
+
+ private boolean bIsPFlagSet = false;
+ private boolean bPFlag;
+
+ private boolean bIsIFlagSet = false;
+ private boolean bIFlag;
+
+ @Override
+ public PcepRPObject build() {
+ PcepObjectHeader lspObjHeader = this.bIsHeaderSet ? this.rpObjHeader : DEFAULT_RP_OBJECT_HEADER;
+
+ int requestIdNum = this.bIsRequestIdNumSet ? this.requestIdNum : DEFAULT_REQUEST_ID_NUM;
+ boolean bOFlag = this.bIsOFlagSet ? this.bOFlag : DEFAULT_OFLAG;
+ boolean bBFlag = this.bIsBFlagSet ? this.bBFlag : DEFAULT_BFLAG;
+ boolean bRFlag = this.bIsRFlagset ? this.bRFlag : DEFAULT_RFLAG;
+ byte yPriFlag = this.bIsPriFlagSet ? this.yPriFlag : DEFAULT_PRIFLAG;
+
+ if (bIsPFlagSet) {
+ lspObjHeader.setPFlag(bPFlag);
+ }
+
+ if (bIsIFlagSet) {
+ lspObjHeader.setIFlag(bIFlag);
+ }
+
+ return new PcepRPObjectVer1(lspObjHeader, requestIdNum, bOFlag, bBFlag, bRFlag, yPriFlag, llOptionalTlv);
+ }
+
+ @Override
+ public PcepObjectHeader getRPObjHeader() {
+ return this.rpObjHeader;
+ }
+
+ @Override
+ public Builder setRPObjHeader(PcepObjectHeader obj) {
+ this.rpObjHeader = obj;
+ this.bIsHeaderSet = true;
+ return this;
+ }
+
+ @Override
+ public int getRequestIdNum() {
+ return this.requestIdNum;
+ }
+
+ @Override
+ public Builder setRequestIdNum(int value) {
+ this.requestIdNum = value;
+ this.bIsRequestIdNumSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setOFlag(boolean value) {
+ this.bOFlag = value;
+ this.bIsOFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public boolean getBFlag() {
+ return this.bBFlag;
+ }
+
+ @Override
+ public Builder setBFlag(boolean value) {
+ this.bBFlag = value;
+ this.bIsBFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public boolean getRFlag() {
+ return this.bRFlag;
+ }
+
+ @Override
+ public Builder setRFlag(boolean value) {
+ this.bRFlag = value;
+ this.bIsRFlagset = true;
+ return this;
+ }
+
+ @Override
+ public byte getPriFlag() {
+ return this.yPriFlag;
+ }
+
+ @Override
+ public Builder setPriFlag(byte value) {
+ this.yPriFlag = value;
+ this.bIsPriFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> 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 boolean getOFlag() {
+ return this.bOFlag;
+ }
+
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("ObjectHeader", rpObjHeader)
+ .add("OFlag", (bOFlag) ? 1 : 0)
+ .add("BFlag", (bBFlag) ? 1 : 0)
+ .add("RFlag", (bRFlag) ? 1 : 0)
+ .add("PriFlag", yPriFlag)
+ .add("RequestIdNumber", iRequestIdNum)
+ .add("OptionalTlv", llOptionalTlv)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java
new file mode 100644
index 00000000..26e48dbd
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java
@@ -0,0 +1,309 @@
+/*
+ * 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.PcepLspObject;
+import org.onosproject.pcepio.protocol.PcepMessageReader;
+import org.onosproject.pcepio.protocol.PcepMessageWriter;
+import org.onosproject.pcepio.protocol.PcepReportMsg;
+import org.onosproject.pcepio.protocol.PcepSrpObject;
+import org.onosproject.pcepio.protocol.PcepStateReport;
+import org.onosproject.pcepio.protocol.PcepType;
+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 report message.
+ */
+class PcepReportMsgVer1 implements PcepReportMsg {
+
+ // Pcep version: 1
+
+ /*
+ * The format of the PCRpt message is as follows:
+ * <PCRpt Message> ::= <Common Header>
+ * <state-report-list>
+ *Where:
+ * <state-report-list> ::= <state-report>[<state-report-list>]
+ * <state-report> ::= [<SRP>]
+ * <LSP>
+ * <path>
+ * Where:
+ * <path> ::= <ERO><attribute-list>[<RRO>]
+ * Where:
+ * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
+ * where:
+ * <attribute-list> ::=[<LSPA>]
+ * [<BANDWIDTH>]
+ * [<metric-list>]
+ * [<IRO>]
+ * <metric-list> ::=<METRIC>[<metric-list>]
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PcepReportMsgVer1.class);
+
+ public static final byte PACKET_VERSION = 1;
+ //PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+LspObjMinLen(8)+EroObjMinLen(12)
+ public static final int PACKET_MINIMUM_LENGTH = 24;
+ public static final PcepType MSG_TYPE = PcepType.REPORT;
+ public static final byte REPORT_OBJ_TYPE = 1;
+ //Optional TLV
+ private LinkedList<PcepStateReport> llStateReportList;
+
+ public static final PcepReportMsgVer1.Reader READER = new Reader();
+
+ /**
+ * Reader class for reading PCEP report message from channel buffer.
+ */
+ static class Reader implements PcepMessageReader<PcepReportMsg> {
+
+ LinkedList<PcepStateReport> llStateReportList;
+
+ @Override
+ public PcepReportMsg readFrom(ChannelBuffer cb) throws PcepParseException {
+
+ if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
+ throw new PcepParseException("Received packet size " + cb.readableBytes()
+ + " is less than the expected size: " + PACKET_MINIMUM_LENGTH);
+ }
+ llStateReportList = new LinkedList<>();
+ byte version = cb.readByte();
+ version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
+
+ if (version != PACKET_VERSION) {
+ throw new PcepParseException(" Invalid version: " + version);
+ }
+
+ byte type = cb.readByte();
+
+ if (type != MSG_TYPE.getType()) {
+ throw new PcepParseException("Unexpected type: " + type);
+ }
+
+ short length = cb.readShort();
+
+ if (length < PACKET_MINIMUM_LENGTH) {
+ throw new PcepParseException("Wrong length. Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: "
+ + length);
+ }
+ // parse state report list
+ parseStateReportList(cb);
+ return new PcepReportMsgVer1(llStateReportList);
+ }
+
+ // Parse State Report list
+ public void parseStateReportList(ChannelBuffer cb) throws PcepParseException {
+
+ /*
+ <state-report-list>
+ Where:
+ <state-report-list> ::= <state-report>[<state-report-list>]
+ <state-report> ::= [<SRP>]
+ <LSP>
+ <path>
+ Where:
+ <path> ::= <ERO><attribute-list>[<RRO>]
+ Where:
+ <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
+
+ */
+
+ while (0 < cb.readableBytes()) {
+
+ PcepStateReport pcestateReq = new PcepStateReportVer1();
+
+ /*
+ * SRP is optional
+ * Check whether SRP Object is available, if yes store it.
+ * First read common object header and check the Object Class whether it is SRP or LSP
+ * If it is LSP then store only LSP. So, SRP is optional. then read path and store.
+ * If it is SRP then store SRP and then read LSP, path and store them.
+ */
+
+ //mark the reader index to reset
+ cb.markReaderIndex();
+ PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
+
+ byte yObjectClass = tempObjHeader.getObjClass();
+ byte yObjectType = tempObjHeader.getObjType();
+
+ //reset reader index
+ cb.resetReaderIndex();
+ //If SRP present then store it.
+ if ((PcepSrpObjectVer1.SRP_OBJ_CLASS == yObjectClass)
+ && (PcepSrpObjectVer1.SRP_OBJ_TYPE == yObjectType)) {
+ PcepSrpObject srpObj;
+ srpObj = PcepSrpObjectVer1.read(cb);
+ pcestateReq.setSrpObject(srpObj);
+ }
+
+ //store LSP object
+ PcepLspObject lspObj;
+ lspObj = PcepLspObjectVer1.read(cb);
+ pcestateReq.setLspObject(lspObj);
+
+ //store path
+ PcepStateReport.PcepMsgPath msgPath = new PcepStateReportVer1().new PcepMsgPath().read(cb);
+ pcestateReq.setMsgPath(msgPath);
+
+ llStateReportList.add(pcestateReq);
+ }
+ }
+ }
+
+ /**
+ * Constructor to initialize State Report List.
+ *
+ * @param llStateReportList list of type Pcep state report
+ */
+ PcepReportMsgVer1(LinkedList<PcepStateReport> llStateReportList) {
+ this.llStateReportList = llStateReportList;
+ }
+
+ /**
+ * Builder class for PCEP Report message.
+ */
+ static class Builder implements PcepReportMsg.Builder {
+ // Pcep report message fields
+ LinkedList<PcepStateReport> llStateReportList;
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public PcepType getType() {
+ return PcepType.REPORT;
+ }
+
+ @Override
+ public PcepReportMsg build() {
+ return new PcepReportMsgVer1(this.llStateReportList);
+ }
+
+ @Override
+ public LinkedList<PcepStateReport> getStateReportList() {
+ return this.llStateReportList;
+ }
+
+ @Override
+ public Builder setStateReportList(LinkedList<PcepStateReport> ll) {
+ this.llStateReportList = 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 report message to channel buffer.
+ */
+ static class Writer implements PcepMessageWriter<PcepReportMsgVer1> {
+
+ @Override
+ public void write(ChannelBuffer cb, PcepReportMsgVer1 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 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);
+ ListIterator<PcepStateReport> listIterator = message.llStateReportList.listIterator();
+
+ while (listIterator.hasNext()) {
+
+ PcepStateReport stateRpt = listIterator.next();
+ PcepSrpObject srpObj = stateRpt.getSrpObject();
+
+ //SRP object is optional
+ if (srpObj != null) {
+ srpObj.write(cb);
+ }
+
+ //LSP object is mandatory
+ PcepLspObject lspObj = stateRpt.getLspObject();
+ if (lspObj == null) {
+ throw new PcepParseException("LSP Object is mandatory object for PcRpt message.");
+ } else {
+ lspObj.write(cb);
+ }
+
+ //path is mandatory
+ PcepStateReport.PcepMsgPath msgPath = stateRpt.getMsgPath();
+ if (msgPath == null) {
+ throw new PcepParseException("Message path is mandatory object for PcRpt message.");
+ } else {
+ msgPath.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 LinkedList<PcepStateReport> getStateReportList() {
+ return this.llStateReportList;
+ }
+
+ @Override
+ public void setStateReportList(LinkedList<PcepStateReport> ll) {
+ this.llStateReportList = ll;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("StateReportList", llStateReportList)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRroObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRroObjectVer1.java
new file mode 100644
index 00000000..4df42e05
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepRroObjectVer1.java
@@ -0,0 +1,345 @@
+/*
+ * 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.PcepRroObject;
+import org.onosproject.pcepio.types.IPv4SubObject;
+import org.onosproject.pcepio.types.IPv6SubObject;
+import org.onosproject.pcepio.types.LabelSubObject;
+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 RRO object.
+ */
+public class PcepRroObjectVer1 implements PcepRroObject {
+
+ /*
+ * 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) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Each subobject has its own Length
+ field. The length contains the total length of the subobject in
+ bytes, including the Type and Length fields. The length MUST always
+ be a multiple of 4, and at least 4.
+
+ An empty RRO with no subobjects is considered illegal.
+ Three kinds of subobjects are currently defined.
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type | Length | IPv4 address (4 bytes) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 address (continued) | Prefix Length | Flags |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Subobject 2: IPv6 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type | Length | IPv6 address (16 bytes) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) | Prefix Length | Flags |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Subobject 3, Label
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type | Length | Flags | C-Type |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Contents of Label Object |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PcepRroObjectVer1.class);
+
+ public static final byte RRO_OBJ_TYPE = 1;
+ public static final byte RRO_OBJ_CLASS = 8;
+ public static final byte RRO_OBJECT_VERSION = 1;
+ public static final short RRO_OBJ_MINIMUM_LENGTH = 12;
+ public static final int OBJECT_HEADER_LENGTH = 4;
+ public static final int YTYPE_SHIFT_VALUE = 0x7F;
+
+ static final PcepObjectHeader DEFAULT_RRO_OBJECT_HEADER = new PcepObjectHeader(RRO_OBJ_CLASS, RRO_OBJ_TYPE,
+ PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, RRO_OBJ_MINIMUM_LENGTH);
+
+ private short rroObjType = 0;
+ private byte length;
+ private byte prefixLength;
+ private byte resvd;
+ PcepObjectHeader rroObjHeader;
+ private LinkedList<PcepValueType> llSubObjects = new LinkedList<>();
+
+ /**
+ * Reset variables.
+ */
+ public PcepRroObjectVer1() {
+ this.rroObjHeader = null;
+ this.rroObjType = 0;
+ this.length = 0;
+ }
+
+ /**
+ * constructor to initialize parameters for RRO object.
+ *
+ * @param rroObjHeader RRO object header
+ * @param llSubObjects list of sub objects
+ */
+ public PcepRroObjectVer1(PcepObjectHeader rroObjHeader, LinkedList<PcepValueType> llSubObjects) {
+ this.rroObjHeader = rroObjHeader;
+ this.llSubObjects = llSubObjects;
+ }
+
+ /**
+ * Returns PCEP RRO Object Header.
+ *
+ * @return rroObjHeader RRO Object header
+ */
+ public PcepObjectHeader getRroObjHeader() {
+ return this.rroObjHeader;
+ }
+
+ /**
+ * Sets PCEP RRO Object Header.
+ *
+ * @param obj Object header
+ */
+ public void setRroObjHeader(PcepObjectHeader obj) {
+ this.rroObjHeader = obj;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getSubObjects() {
+ return this.llSubObjects;
+ }
+
+ @Override
+ public void setSubObjects(LinkedList<PcepValueType> llSubObjects) {
+ this.llSubObjects = llSubObjects;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of PcepRroObject.
+ *
+ * @param cb of type channel buffer
+ * @return object of PcepRroObject
+ * @throws PcepParseException when fails to read from channel buffer
+ */
+ public static PcepRroObject read(ChannelBuffer cb) throws PcepParseException {
+
+ PcepObjectHeader rroObjHeader;
+ LinkedList<PcepValueType> llSubObjects;
+ rroObjHeader = PcepObjectHeader.read(cb);
+
+ //take only RroObject buffer.
+ ChannelBuffer tempCb = cb.readBytes(rroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
+ llSubObjects = parseSubObjects(tempCb);
+
+ return new PcepRroObjectVer1(rroObjHeader, llSubObjects);
+ }
+
+ /**
+ * Returns list of sub objects.
+ *
+ * @param cb of type channel buffer
+ * @return list of sub objects
+ * @throws PcepParseException when fails to parse list of sub objects
+ */
+ protected static LinkedList<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> llSubObjects = new LinkedList<>();
+
+ while (0 < cb.readableBytes()) {
+
+ //check the Type of the Sub objects
+ 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 LabelSubObject.TYPE:
+ subObj = LabelSubObject.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);
+ }
+
+ return llSubObjects;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) throws PcepParseException {
+ //write Object header
+ int objStartIndex = cb.writerIndex();
+
+ int objLenIndex = rroObjHeader.write(cb);
+
+ if (objLenIndex <= 0) {
+ throw new PcepParseException(" object Length Index" + objLenIndex);
+ }
+
+ ListIterator<PcepValueType> 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().
+ rroObjHeader.setObjLen((short) length);
+
+ //As per RFC the length of object should be multiples of 4
+ int pad = length % 4;
+
+ if (0 != pad) {
+ 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 RRO object.
+ */
+ public static class Builder implements PcepRroObject.Builder {
+ private boolean bIsHeaderSet = false;
+
+ private PcepObjectHeader rroObjHeader;
+ LinkedList<PcepValueType> llSubObjects = new LinkedList<>();
+
+ private boolean bIsPFlagSet = false;
+ private boolean bPFlag;
+
+ private boolean bIsIFlagSet = false;
+ private boolean bIFlag;
+
+ @Override
+ public PcepRroObject build() {
+
+ PcepObjectHeader rroObjHeader = this.bIsHeaderSet ? this.rroObjHeader : DEFAULT_RRO_OBJECT_HEADER;
+
+ if (bIsPFlagSet) {
+ rroObjHeader.setPFlag(bPFlag);
+ }
+
+ if (bIsIFlagSet) {
+ rroObjHeader.setIFlag(bIFlag);
+ }
+ return new PcepRroObjectVer1(rroObjHeader, this.llSubObjects);
+ }
+
+ @Override
+ public PcepObjectHeader getRroObjHeader() {
+ return this.rroObjHeader;
+ }
+
+ @Override
+ public Builder setRroObjHeader(PcepObjectHeader obj) {
+ this.rroObjHeader = obj;
+ this.bIsHeaderSet = true;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getSubObjects() {
+ return this.llSubObjects;
+ }
+
+ @Override
+ public Builder setSubObjects(LinkedList<PcepValueType> 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("SubObjects", llSubObjects)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java
new file mode 100644
index 00000000..9c75b3a6
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java
@@ -0,0 +1,392 @@
+/*
+ * 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.PcepSrpObject;
+import org.onosproject.pcepio.types.PcepObjectHeader;
+import org.onosproject.pcepio.types.PcepValueType;
+import org.onosproject.pcepio.types.SymbolicPathNameTlv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP SRP obejct.
+ */
+public class PcepSrpObjectVer1 implements PcepSrpObject {
+
+ /*
+ * ref : draft-ietf-pce-stateful-pce-10, 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Object-Class | OT |Res|P|I| Object Length (bytes) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Flags |R|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | SRP-ID-number |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Optional TLVs //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PcepSrpObjectVer1.class);
+
+ public static final byte SRP_OBJ_TYPE = 1;
+ public static final byte SRP_OBJ_CLASS = 33;
+ public static final byte SRP_OBJECT_VERSION = 1;
+ public static final short SRP_OBJ_MINIMUM_LENGTH = 12;
+ public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
+ public static final boolean DEFAULT_RFLAG = false;
+
+ static final PcepObjectHeader DEFAULT_SRP_OBJECT_HEADER = new PcepObjectHeader(SRP_OBJ_CLASS, SRP_OBJ_TYPE,
+ PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, SRP_OBJ_MINIMUM_LENGTH);
+
+ private PcepObjectHeader srpObjHeader;
+ private static int flags;
+ private boolean bRFlag;
+ private int srpId;
+
+ //Optional TLV
+ private LinkedList<PcepValueType> llOptionalTlv;
+ public static final byte BBIT_SET = 1;
+ public static final byte BBIT_RESET = 0;
+
+ /**
+ * Constructor to initialize member variables.
+ *
+ * @param srpObjHeader srp object header
+ * @param bRFlag R flag
+ * @param srpID srp Id
+ * @param llOptionalTlv list of optional tlv
+ */
+ public PcepSrpObjectVer1(PcepObjectHeader srpObjHeader, boolean bRFlag, int srpID,
+ LinkedList<PcepValueType> llOptionalTlv) {
+
+ this.srpObjHeader = srpObjHeader;
+ this.bRFlag = bRFlag;
+ this.srpId = srpID;
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ /**
+ * sets the SRP object header.
+ *
+ * @param obj srp object header
+ */
+ public void setSrpObjHeader(PcepObjectHeader obj) {
+ this.srpObjHeader = obj;
+ }
+
+ @Override
+ public void setSrpID(int srpID) {
+ this.srpId = srpID;
+ }
+
+ @Override
+ public void setRFlag(boolean bRFlag) {
+ this.bRFlag = bRFlag;
+ }
+
+ /**
+ * Returns SRP object header.
+ *
+ * @return srpObjHeader
+ */
+ public PcepObjectHeader getSrpObjHeader() {
+ return this.srpObjHeader;
+ }
+
+ @Override
+ public int getSrpID() {
+ return this.srpId;
+ }
+
+ @Override
+ public boolean getRFlag() {
+ return this.bRFlag;
+ }
+
+ @Override
+ public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ /**
+ * Reads from channel buffer and returns instance of PCEP SRP object.
+ *
+ * @param cb of channel buffer.
+ * @return PCEP SRP object
+ * @throws PcepParseException when srp object is not received in channel buffer
+ */
+ public static PcepSrpObject read(ChannelBuffer cb) throws PcepParseException {
+
+ log.debug("SrpObject::read");
+ PcepObjectHeader srpObjHeader;
+ boolean bRFlag;
+
+ int srpID;
+ int flags;
+ LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
+
+ srpObjHeader = PcepObjectHeader.read(cb);
+
+ if (srpObjHeader.getObjClass() != SRP_OBJ_CLASS) {
+ throw new PcepParseException("SRP object expected. But received " + srpObjHeader.getObjClass());
+ }
+
+ //take only SrpObject buffer.
+ ChannelBuffer tempCb = cb.readBytes(srpObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
+ flags = tempCb.readInt();
+ bRFlag = 0 < flags;
+ srpID = tempCb.readInt();
+
+ llOptionalTlv = parseOptionalTlv(tempCb);
+
+ return new PcepSrpObjectVer1(srpObjHeader, bRFlag, srpID, llOptionalTlv);
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) throws PcepParseException {
+
+ int objStartIndex = cb.writerIndex();
+
+ //write common header
+ int objLenIndex = srpObjHeader.write(cb);
+
+ //write Flags
+ byte bFlag;
+
+ bFlag = (bRFlag) ? BBIT_SET : BBIT_RESET;
+
+ cb.writeInt(bFlag);
+
+ //write SrpId
+ cb.writeInt(srpId);
+
+ // Add optional TLV
+ if (!packOptionalTlv(cb)) {
+ throw new PcepParseException("Failed to write srp tlv to channel buffer.");
+ }
+
+ //now write SRP Object Length
+ cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
+
+ return cb.writerIndex();
+ }
+
+ /**
+ * Parse Optional TLvs from the channel buffer.
+ *
+ * @param cb of type channel buffer
+ * @return list of optional tlvs
+ * @throws PcepParseException when unsupported tlv is received in srp object
+ */
+ public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<>();
+
+ while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) {
+
+ PcepValueType tlv;
+ short hType = cb.readShort();
+ short hLength = cb.readShort();
+
+ switch (hType) {
+
+ case SymbolicPathNameTlv.TYPE:
+ tlv = SymbolicPathNameTlv.read(cb, hLength);
+ cb.skipBytes(hLength);
+ break;
+
+ default:
+ throw new PcepParseException("Unsupported TLV received in SRP 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;
+ }
+
+ /**
+ * Writes optional tlvs to channel buffer.
+ *
+ * @param cb of type channel buffer
+ * @return true if writing optional tlv to channel buffer is success.
+ */
+ protected boolean packOptionalTlv(ChannelBuffer cb) {
+
+ ListIterator<PcepValueType> 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 srp Object.
+ */
+ public static class Builder implements PcepSrpObject.Builder {
+ private boolean bIsHeaderSet = false;
+ private boolean bIsSrpIdset = false;
+ private boolean bIsRFlagSet = false;
+
+ private PcepObjectHeader srpObjHeader;
+ private int srpId;
+ private boolean bRFlag;
+ LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
+
+ private boolean bIsPFlagSet = false;
+ private boolean bPFlag;
+
+ private boolean bIsIFlagSet = false;
+ private boolean bIFlag;
+
+ @Override
+ public PcepSrpObject build() throws PcepParseException {
+ PcepObjectHeader srpObjHeader = this.bIsHeaderSet ? this.srpObjHeader : DEFAULT_SRP_OBJECT_HEADER;
+
+ boolean bRFlag = this.bIsRFlagSet ? this.bRFlag : DEFAULT_RFLAG;
+
+ if (!this.bIsSrpIdset) {
+ throw new PcepParseException("SrpID not set while building SRP Object.");
+ }
+
+ if (bIsPFlagSet) {
+ srpObjHeader.setPFlag(bPFlag);
+ }
+
+ if (bIsIFlagSet) {
+ srpObjHeader.setIFlag(bIFlag);
+ }
+
+ return new PcepSrpObjectVer1(srpObjHeader, bRFlag, this.srpId, this.llOptionalTlv);
+ }
+
+ @Override
+ public PcepObjectHeader getSrpObjHeader() {
+ return this.srpObjHeader;
+ }
+
+ @Override
+ public Builder setSrpObjHeader(PcepObjectHeader obj) {
+ this.srpObjHeader = obj;
+ this.bIsHeaderSet = true;
+ return this;
+ }
+
+ @Override
+ public int getSrpID() {
+ return this.srpId;
+ }
+
+ @Override
+ public Builder setSrpID(int srpID) {
+ this.srpId = srpID;
+ this.bIsSrpIdset = true;
+ return this;
+ }
+
+ @Override
+ public boolean getRFlag() {
+ return this.bRFlag;
+ }
+
+ @Override
+ public Builder setRFlag(boolean bRFlag) {
+ this.bRFlag = bRFlag;
+ this.bIsRFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> 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("RFlag", bRFlag)
+ .add("SRPID", srpId)
+ .add("OptionalTlvList", llOptionalTlv)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepStateReportVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepStateReportVer1.java
new file mode 100644
index 00000000..ce589bc0
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepStateReportVer1.java
@@ -0,0 +1,421 @@
+/*
+ * 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.PcepAttribute;
+import org.onosproject.pcepio.protocol.PcepBandwidthObject;
+import org.onosproject.pcepio.protocol.PcepEroObject;
+import org.onosproject.pcepio.protocol.PcepLspObject;
+import org.onosproject.pcepio.protocol.PcepRroObject;
+import org.onosproject.pcepio.protocol.PcepSrpObject;
+import org.onosproject.pcepio.protocol.PcepStateReport;
+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;
+
+/**
+ * Provide the State Report for the Pcep Report Message.
+ * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10.
+ */
+public class PcepStateReportVer1 implements PcepStateReport {
+ /*
+ * <state-report> ::= [<SRP>]
+ <LSP>
+ <path>
+ Where:
+ <path> ::= <ERO><attribute-list>[<RRO>]
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepStateReport.class);
+
+ public static final int OBJECT_HEADER_LENGTH = 4;
+
+ /**
+ * Provides PCEP Message path for report message.
+ */
+ public class PcepMsgPath implements PcepStateReport.PcepMsgPath {
+
+ /*
+ * <path> ::= <ERO><attribute-list>[<RRO>]
+ */
+
+ //PcepEroObject
+ private PcepEroObject eroObj;
+ private boolean isEroObjectSet;
+ //PcepAttribute List
+ private PcepAttribute attrList;
+ private boolean isAttributeListSet;
+ //PcepRroObject
+ private PcepRroObject rroObj;
+ private boolean isRroObjectSet;
+ private PcepBandwidthObject bandwidth;
+ private boolean isBandwidthObjectSet;
+
+ /**
+ * Constructor to reset the parameters.
+ */
+ public PcepMsgPath() {
+ eroObj = null;
+ attrList = null;
+ rroObj = null;
+ this.isEroObjectSet = false;
+ this.isAttributeListSet = false;
+ this.isRroObjectSet = false;
+ this.isBandwidthObjectSet = false;
+ }
+
+ /**
+ * Constructor to initialize the parameters from PCEP Message path.
+ *
+ * @param eroObj PCEP ERO Object
+ * @param attrList PCEP Attribute
+ * @param rroObj PCEP Rro Object
+ * @param bandwidth PCEP bandwidth object
+ */
+ public PcepMsgPath(PcepEroObject eroObj, PcepAttribute attrList, PcepRroObject rroObj,
+ PcepBandwidthObject bandwidth) {
+
+ this.eroObj = eroObj;
+ this.attrList = attrList;
+ this.rroObj = rroObj;
+ this.bandwidth = bandwidth;
+ if (rroObj == null) {
+ this.isRroObjectSet = false;
+ } else {
+ this.isRroObjectSet = true;
+ }
+ if (eroObj == null) {
+ this.isEroObjectSet = false;
+ } else {
+ this.isEroObjectSet = true;
+ }
+ if (attrList == null) {
+ this.isAttributeListSet = false;
+ } else {
+ this.isAttributeListSet = true;
+ }
+ if (bandwidth == null) {
+ this.isBandwidthObjectSet = false;
+ } else {
+ this.isBandwidthObjectSet = true;
+ }
+ }
+
+ /**
+ * Returns PcepEroObject.
+ *
+ * @return eroObj PCEP ERO Object
+ */
+ @Override
+ public PcepEroObject getEroObject() {
+ return this.eroObj;
+ }
+
+ /**
+ * Returns PCEP Attribute.
+ *
+ * @return attrList Attribute list
+ */
+ @Override
+ public PcepAttribute getPcepAttribute() {
+ return this.attrList;
+ }
+
+ /**
+ * Returns PcepRroObject.
+ *
+ * @return rroObj PCEP RRO Object
+ */
+ @Override
+ public PcepRroObject getRroObject() {
+ return this.rroObj;
+ }
+
+ @Override
+ public PcepBandwidthObject getBandwidthObject() {
+ return this.bandwidth;
+ }
+
+ @Override
+ public void setEroObject(PcepEroObject eroObj) {
+ this.eroObj = eroObj;
+ }
+
+ @Override
+ public void setPcepAttribute(PcepAttribute attrList) {
+ this.attrList = attrList;
+ }
+
+ @Override
+ public void setRroObject(PcepRroObject rroObj) {
+ this.rroObj = rroObj;
+ }
+
+ @Override
+ public void setBandwidthObject(PcepBandwidthObject bandwidth) {
+ this.bandwidth = bandwidth;
+ }
+
+ /**
+ * Reads all the Objects for PCEP Message Path.
+ *
+ * @param bb of type channel buffer
+ * @return PCEP Message path
+ * @throws PcepParseException when fails to read pcep message path
+ */
+ @Override
+ public PcepMsgPath read(ChannelBuffer bb) throws PcepParseException {
+
+ PcepEroObject eroObj;
+ PcepAttribute attrList;
+ PcepRroObject rroObj = null;
+ PcepBandwidthObject bandwidth = null;
+
+ eroObj = PcepEroObjectVer1.read(bb);
+ attrList = PcepAttributeVer1.read(bb);
+
+ boolean bBreakWhile = false;
+ while (0 < bb.readableBytes()) {
+
+ if (bb.readableBytes() < OBJECT_HEADER_LENGTH) {
+ break;
+ }
+ bb.markReaderIndex();
+ PcepObjectHeader tempObjHeader = PcepObjectHeader.read(bb);
+ bb.resetReaderIndex();
+ byte yObjClass = tempObjHeader.getObjClass();
+
+ switch (yObjClass) {
+ case PcepRroObjectVer1.RRO_OBJ_CLASS:
+ rroObj = PcepRroObjectVer1.read(bb);
+ break;
+ case PcepInterLayerObjectVer1.INTER_LAYER_OBJ_CLASS:
+ bb.skipBytes(tempObjHeader.getObjLen());
+ break;
+ case PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS:
+ bandwidth = PcepBandwidthObjectVer1.read(bb);
+ break;
+ default:
+ //Otherthan above objects handle those objects in caller.
+ bBreakWhile = true;
+ break;
+ }
+ if (bBreakWhile) {
+ break;
+ }
+ }
+ return new PcepMsgPath(eroObj, attrList, rroObj, bandwidth);
+ }
+
+ /**
+ * Writes all the objects for PCEP message path.
+ *
+ * @param bb of type channel buffer.
+ * @return object length index
+ * @throws PcepParseException when fails to write to channel buffer
+ */
+ @Override
+ public int write(ChannelBuffer bb) throws PcepParseException {
+ int iLenStartIndex = bb.writerIndex();
+
+ //write Object header
+ if (this.isEroObjectSet) {
+ this.eroObj.write(bb);
+ } else {
+ throw new PcepParseException("Ero object is not set in path");
+ }
+
+ if (this.isAttributeListSet) {
+ this.attrList.write(bb);
+ }
+
+ // RRO is optional check and read
+ if (this.isRroObjectSet) {
+ this.rroObj.write(bb);
+ // bandwidth should come along with RRO.
+ if (this.isBandwidthObjectSet) {
+ this.bandwidth.write(bb);
+ }
+ }
+ return bb.writerIndex() - iLenStartIndex;
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ if (attrList != null) {
+ toStrHelper.add("AttributeList", attrList);
+ }
+ if (rroObj instanceof PcepRroObjectVer1) {
+ toStrHelper.add("RroObject", rroObj);
+ }
+ if (bandwidth instanceof PcepBandwidthObjectVer1) {
+ toStrHelper.add("bandwidthObject", bandwidth);
+ }
+ return toStrHelper.toString();
+ }
+ }
+
+ //SRP Object
+ private PcepSrpObject srpObject;
+ //LSP Object
+ private PcepLspObject lspObject;
+ //PcepMsgPath
+ private PcepStateReport.PcepMsgPath msgPath;
+
+ /**
+ * Constructor to reset objects.
+ */
+ public PcepStateReportVer1() {
+ this.srpObject = null;
+ this.lspObject = null;
+ this.msgPath = null;
+ }
+
+ public PcepStateReportVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepStateReport.PcepMsgPath msgPath) {
+ this.srpObject = srpObject;
+ this.lspObject = lspObject;
+ this.msgPath = msgPath;
+ }
+
+ @Override
+ public PcepSrpObject getSrpObject() {
+ return srpObject;
+ }
+
+ @Override
+ public PcepLspObject getLspObject() {
+ return lspObject;
+ }
+
+ @Override
+ public PcepStateReport.PcepMsgPath getMsgPath() {
+ return msgPath;
+ }
+
+ @Override
+ public void setSrpObject(PcepSrpObject srpObj) {
+ this.srpObject = srpObj;
+ }
+
+ @Override
+ public void setLspObject(PcepLspObject lspObject) {
+ this.lspObject = lspObject;
+ }
+
+ @Override
+ public void setMsgPath(PcepStateReport.PcepMsgPath msgPath) {
+ this.msgPath = msgPath;
+ }
+
+ /**
+ * Builder class for PCEP state report.
+ */
+ public static class Builder implements PcepStateReport.Builder {
+
+ private boolean bIsSRPObjectSet = false;
+ private boolean bIsLSPObjectSet = false;
+ private boolean bIsPcepMsgPathSet = false;
+
+ //PCEP SRP Object
+ private PcepSrpObject srpObject;
+ //PCEP LSP Object
+ private PcepLspObject lspObject;
+ //PCEP Attribute list
+ private PcepStateReport.PcepMsgPath msgPath;
+
+ @Override
+ public PcepStateReport build() throws PcepParseException {
+
+ //PCEP SRP Object
+ PcepSrpObject srpObject = null;
+ //PCEP LSP Object
+ PcepLspObject lspObject = null;
+ //PCEP Attribute list
+ PcepStateReport.PcepMsgPath msgPath = null;
+
+ if (this.bIsSRPObjectSet) {
+ srpObject = this.srpObject;
+ }
+
+ if (!this.bIsLSPObjectSet) {
+ throw new PcepParseException(" LSP Object NOT Set while building PcepStateReport.");
+ } else {
+ lspObject = this.lspObject;
+ }
+ if (!this.bIsPcepMsgPathSet) {
+ throw new PcepParseException(" Message Path NOT Set while building PcepStateReport.");
+ } else {
+ msgPath = this.msgPath;
+ }
+
+ return new PcepStateReportVer1(srpObject, lspObject, msgPath);
+ }
+
+ @Override
+ public PcepSrpObject getSrpObject() {
+ return this.srpObject;
+ }
+
+ @Override
+ public PcepLspObject getLspObject() {
+ return this.lspObject;
+ }
+
+ @Override
+ public PcepStateReport.PcepMsgPath getMsgPath() {
+ return this.msgPath;
+ }
+
+ @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 setMsgPath(PcepStateReport.PcepMsgPath msgPath) {
+ this.msgPath = msgPath;
+ this.bIsPcepMsgPathSet = true;
+ return this;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("SrpObject", srpObject)
+ .add("LspObject", lspObject)
+ .add("MsgPath", msgPath)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepTEObjectVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepTEObjectVer1.java
new file mode 100644
index 00000000..b1c69406
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepTEObjectVer1.java
@@ -0,0 +1,506 @@
+/*
+ * 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.PcepTEObject;
+import org.onosproject.pcepio.types.LocalTENodeDescriptorsTlv;
+import org.onosproject.pcepio.types.PcepObjectHeader;
+import org.onosproject.pcepio.types.PcepValueType;
+import org.onosproject.pcepio.types.RemoteTENodeDescriptorsTlv;
+import org.onosproject.pcepio.types.RoutingUniverseTlv;
+import org.onosproject.pcepio.types.TELinkAttributesTlv;
+import org.onosproject.pcepio.types.TELinkDescriptorsTlv;
+import org.onosproject.pcepio.types.TENodeAttributesTlv;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP TE Object.
+ */
+public class PcepTEObjectVer1 implements PcepTEObject {
+ /*
+ *
+ reference: PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02.
+ TE Object-Class is [TBD6].
+
+ Two Object-Type values are defined for the TE object:
+
+ o TE Node: TE Object-Type is 1.
+
+ o TE Link: TE Object-Type is 2.
+
+ The format of the TE object body is as follows:
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Protocol-ID | Flag |R|S|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | TE-ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // TLVs //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepTEObjectVer1.class);
+
+ public static final byte TE_OBJ_TYPE_NODE_VALUE = 1;
+ public static final byte TE_OBJ_TYPE_LINK_VALUE = 2;
+
+ public static final byte TE_OBJ_CLASS = 101; //TBD6 in RFC.
+ public static final byte TE_OBJECT_VERSION = 1;
+
+ // TE_OBJ_MINIMUM_LENGTH = TEObjectHeaderLen(4)+ TEObjectLen(8)
+ public static final short TE_OBJ_MINIMUM_LENGTH = 12;
+
+ // Signaled ,all default values to be checked.
+ public static final byte DEFAULT_PROTOCOL_ID = 1; //IS-IS Level 1
+ public static final boolean DEFAULT_R_FLAG = false;
+ public static final boolean DEFAULT_S_FLAG = false;
+ public static final int DEFAULT_TE_ID = 0;
+
+ public static final int OBJECT_HEADER_LENGTH = 4;
+ public static final int RIGHT_SHIFT_ONE = 1;
+ public static final int RIGHT_FIRST_FLAG = 0x1;
+ public static final int FLAG_SET_R_FLAG = 0x2;
+ public static final int FLAG_SET_S_FLAG = 0x1;
+ public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
+ public static final int MINIMUM_TLV_HEADER_LENGTH = 4;
+
+ public static final PcepObjectHeader DEFAULT_TE_OBJECT_HEADER = new PcepObjectHeader(TE_OBJ_CLASS,
+ TE_OBJ_TYPE_NODE_VALUE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
+ TE_OBJ_MINIMUM_LENGTH);
+
+ private PcepObjectHeader teObjHeader;
+ private byte yProtocolId;
+ // 2-flags
+ private boolean bRFlag;
+ private boolean bSFlag;
+ private int iTEId;
+ // Optional TLV
+ private LinkedList<PcepValueType> llOptionalTlv;
+
+ /**
+ * Constructor to initialize variables.
+ *
+ * @param teObjHeader TE Object header
+ * @param yProtocolId Protocol-ID
+ * @param bRFlag R-flag
+ * @param bSFlag S-flag
+ * @param iTEId TE-ID
+ * @param llOptionalTlv linked list of Optional TLV
+ */
+ public PcepTEObjectVer1(PcepObjectHeader teObjHeader, byte yProtocolId, boolean bRFlag, boolean bSFlag, int iTEId,
+ LinkedList<PcepValueType> llOptionalTlv) {
+
+ this.teObjHeader = teObjHeader;
+ this.yProtocolId = yProtocolId;
+ this.bRFlag = bRFlag;
+ this.bSFlag = bSFlag;
+ this.iTEId = iTEId;
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ @Override
+ public PcepObjectHeader getTEObjHeader() {
+ return this.teObjHeader;
+ }
+
+ @Override
+ public void setTEObjHeader(PcepObjectHeader obj) {
+ this.teObjHeader = obj;
+ }
+
+ @Override
+ public byte getProtocolId() {
+ return this.yProtocolId;
+ }
+
+ @Override
+ public void setProtocolId(byte yProtId) {
+ this.yProtocolId = yProtId;
+ }
+
+ @Override
+ public boolean getRFlag() {
+ return this.bRFlag;
+ }
+
+ @Override
+ public void setRFlag(boolean bRFlag) {
+ this.bRFlag = bRFlag;
+ }
+
+ @Override
+ public boolean getSFlag() {
+ return this.bSFlag;
+ }
+
+ @Override
+ public void setSFlag(boolean bSFlag) {
+ this.bSFlag = bSFlag;
+ }
+
+ @Override
+ public int getTEId() {
+ return this.iTEId;
+ }
+
+ @Override
+ public void setTEId(int iTEId) {
+ this.iTEId = iTEId;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
+ this.llOptionalTlv = llOptionalTlv;
+ }
+
+ /**
+ * Reads from the channel buffer and returns Object of PcepTEObject.
+ *
+ * @param cb of type channel buffer
+ * @return Object of PcepTEObject
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepTEObject read(ChannelBuffer cb) throws PcepParseException {
+ log.debug("read");
+
+ PcepObjectHeader teObjHeader;
+ byte yProtocolId;
+ // 2-flags
+ boolean bRFlag;
+ boolean bSFlag;
+ int iTEId;
+ LinkedList<PcepValueType> llOptionalTlv;
+
+ teObjHeader = PcepObjectHeader.read(cb);
+
+ //take only TEObject buffer.
+ ChannelBuffer tempCb = cb.readBytes(teObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
+
+ yProtocolId = tempCb.readByte();
+ //ignore first two bytes of Flags
+ tempCb.readShort();
+
+ Integer iTemp = (int) tempCb.readByte(); //read 3rd byte Flag
+ bSFlag = (iTemp & FLAG_SET_S_FLAG) == FLAG_SET_S_FLAG;
+ bRFlag = (iTemp & FLAG_SET_R_FLAG) == FLAG_SET_R_FLAG;
+
+ iTEId = tempCb.readInt();
+
+ // parse optional TLV
+ llOptionalTlv = parseOptionalTlv(tempCb);
+
+ return new PcepTEObjectVer1(teObjHeader, yProtocolId, bRFlag, bSFlag, iTEId, llOptionalTlv);
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) throws PcepParseException {
+
+ //write Object header
+ int objStartIndex = cb.writerIndex();
+ int objLenIndex = teObjHeader.write(cb);
+
+ if (objLenIndex <= 0) {
+ throw new PcepParseException("ObjectLength Index is " + objLenIndex);
+ }
+
+ //write Protocol ID
+ cb.writeByte(this.yProtocolId);
+
+ //write Flag
+ cb.writeShort(0);
+
+ byte bTemp = 0;
+ if (bSFlag) {
+ bTemp = FLAG_SET_S_FLAG;
+ }
+
+ if (bRFlag) {
+ bTemp = (byte) (bTemp | FLAG_SET_R_FLAG);
+ }
+ cb.writeByte(bTemp);
+
+ //write TEId
+ cb.writeInt(iTEId);
+
+ // Add optional TLV
+ packOptionalTlv(cb);
+
+ //Update object length now
+ int length = cb.writerIndex() - objStartIndex;
+
+ //will be helpful during print().
+ teObjHeader.setObjLen((short) length);
+
+ cb.setShort(objLenIndex, (short) length);
+
+ return cb.writerIndex();
+ }
+
+ /**
+ * Returns Linked list of PCEP Value Type.
+ *
+ * @param cb of channel buffer
+ * @return Linked list of PCEP Value Type
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
+
+ LinkedList<PcepValueType> llOutOptionalTlv;
+
+ llOutOptionalTlv = new LinkedList<>();
+
+ while (MINIMUM_TLV_HEADER_LENGTH <= cb.readableBytes()) {
+
+ PcepValueType tlv;
+ short hType = cb.readShort();
+ short hLength = cb.readShort();
+ long lValue = 0;
+
+ switch (hType) {
+
+ case RoutingUniverseTlv.TYPE:
+ lValue = cb.readLong();
+ tlv = new RoutingUniverseTlv(lValue);
+ break;
+ case LocalTENodeDescriptorsTlv.TYPE:
+ tlv = LocalTENodeDescriptorsTlv.read(cb, hLength);
+ break;
+ case RemoteTENodeDescriptorsTlv.TYPE:
+ tlv = RemoteTENodeDescriptorsTlv.read(cb, hLength);
+ break;
+ case TELinkDescriptorsTlv.TYPE:
+ tlv = TELinkDescriptorsTlv.read(cb, hLength);
+ break;
+ case TENodeAttributesTlv.TYPE:
+ tlv = TENodeAttributesTlv.read(cb, hLength);
+ break;
+ case TELinkAttributesTlv.TYPE:
+ tlv = TELinkAttributesTlv.read(cb, hLength);
+ 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 type channel buffer
+ * @return the writer index.
+ */
+ protected int packOptionalTlv(ChannelBuffer cb) {
+
+ ListIterator<PcepValueType> 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 cb.writerIndex();
+ }
+
+ /**
+ * Builder class for PCEP te object.
+ */
+ public static class Builder implements PcepTEObject.Builder {
+ private boolean bIsHeaderSet = false;
+ private boolean bIsProtocolIdSet = false;
+ private boolean bIsRFlagSet = false;
+ private boolean bIsSFlagSet = false;
+ private boolean bIsTEIdSet = false;
+
+ private PcepObjectHeader teObjHeader;
+ private byte yProtocolId;
+ private boolean bRFlag;
+ private boolean bSFlag;
+ private int iTEId;
+ private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
+
+ private boolean bIsPFlagSet = false;
+ private boolean bPFlag;
+
+ private boolean bIsIFlagSet = false;
+ private boolean bIFlag;
+
+ @Override
+ public PcepTEObject build() {
+ PcepObjectHeader teObjHeader = this.bIsHeaderSet ? this.teObjHeader : DEFAULT_TE_OBJECT_HEADER;
+
+ byte yProtocolId = this.bIsProtocolIdSet ? this.yProtocolId : DEFAULT_PROTOCOL_ID;
+ boolean bRFlag = this.bIsRFlagSet ? this.bRFlag : DEFAULT_R_FLAG;
+ boolean bSFlag = this.bIsSFlagSet ? this.bSFlag : DEFAULT_S_FLAG;
+ int iTEId = this.bIsTEIdSet ? this.iTEId : DEFAULT_TE_ID;
+
+ if (bIsPFlagSet) {
+ teObjHeader.setPFlag(bPFlag);
+ }
+
+ if (bIsIFlagSet) {
+ teObjHeader.setIFlag(bIFlag);
+ }
+
+ return new PcepTEObjectVer1(teObjHeader, yProtocolId, bRFlag, bSFlag, iTEId, llOptionalTlv);
+
+ }
+
+ @Override
+ public PcepObjectHeader getTEObjHeader() {
+ return this.teObjHeader;
+ }
+
+ @Override
+ public Builder setTEObjHeader(PcepObjectHeader obj) {
+ this.teObjHeader = obj;
+ this.bIsHeaderSet = true;
+ return this;
+ }
+
+ @Override
+ public byte getProtocolId() {
+ return this.yProtocolId;
+ }
+
+ @Override
+ public Builder setProtocolId(byte yProtId) {
+ this.yProtocolId = yProtId;
+ this.bIsProtocolIdSet = true;
+ return this;
+ }
+
+ @Override
+ public boolean getRFlag() {
+ return this.bRFlag;
+ }
+
+ @Override
+ public Builder setRFlag(boolean bRFlag) {
+ this.bRFlag = bRFlag;
+ this.bIsRFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public boolean getSFlag() {
+ return this.bSFlag;
+ }
+
+ @Override
+ public Builder setSFlag(boolean bSFlag) {
+ this.bSFlag = bSFlag;
+ this.bIsSFlagSet = true;
+ return this;
+ }
+
+ @Override
+ public int getTEId() {
+ return this.iTEId;
+ }
+
+ @Override
+ public Builder setTEId(int iTEId) {
+ this.iTEId = iTEId;
+ this.bIsTEIdSet = true;
+ return this;
+ }
+
+ @Override
+ public LinkedList<PcepValueType> getOptionalTlv() {
+ return this.llOptionalTlv;
+ }
+
+ @Override
+ public Builder setOptionalTlv(LinkedList<PcepValueType> 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("ObjectHeader", teObjHeader)
+ .add("ProtocolId", yProtocolId)
+ .add("RFlag", (bRFlag) ? 1 : 0)
+ .add("SFlag", (bSFlag) ? 1 : 0)
+ .add("TeId", iTEId)
+ .add("OptionalTlv", llOptionalTlv)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepTEReportMsgVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepTEReportMsgVer1.java
new file mode 100644
index 00000000..92833080
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepTEReportMsgVer1.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.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.PcepMessageReader;
+import org.onosproject.pcepio.protocol.PcepMessageWriter;
+import org.onosproject.pcepio.protocol.PcepTEObject;
+import org.onosproject.pcepio.protocol.PcepTEReportMsg;
+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 TE Report Message.
+ */
+class PcepTEReportMsgVer1 implements PcepTEReportMsg {
+
+ /*
+ * Ref : draft-dhodylee-pce-pcep-te-data-extn-02, section 8.1
+
+ <TERpt Message> ::= <Common Header>
+ <te-report-list>
+ Where:
+ <te-report-list> ::= <TE>[<te-report-list>]
+ */
+
+ private static final Logger log = LoggerFactory.getLogger(PcepTEReportMsgVer1.class);
+ //PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+TEObjMinLen(12)
+ public static final int PACKET_MINIMUM_LENGTH = 16;
+ public static final PcepType MSG_TYPE = PcepType.TE_REPORT;
+ // <te-report-list>
+ private LinkedList<PcepTEObject> teReportList;
+
+ public static final PcepTEReportMsgVer1.Reader READER = new Reader();
+
+ /**
+ * Reader class for reading PCPE te report message form channel buffer.
+ */
+ static class Reader implements PcepMessageReader<PcepTEReportMsg> {
+
+ LinkedList<PcepTEObject> teReportList;
+
+ @Override
+ public PcepTEReportMsg readFrom(ChannelBuffer cb) throws PcepParseException {
+
+ if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
+ return null;
+ }
+
+ teReportList = new LinkedList<>();
+
+ byte version = cb.readByte();
+ version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
+ if (version != PcepMessageVer1.PACKET_VERSION) {
+ throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), got=" + version);
+ }
+
+ byte type = cb.readByte();
+ if (type != MSG_TYPE.getType()) {
+ throw new PcepParseException("Wrong type. Expected=PcepType.TE_REPORT(14), 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 state report list
+ parseTEReportList(cb);
+
+ return new PcepTEReportMsgVer1(teReportList);
+ }
+
+ /**
+ * Parse te-report-list.
+ *
+ * @param cb input Channel Buffer
+ * @throws PcepParseException when fails to parse TE Report list.
+ */
+ public void parseTEReportList(ChannelBuffer cb) throws PcepParseException {
+ // <te-report-list> ::= <TE>[<te-report-list>]
+
+ while (0 < cb.readableBytes()) {
+ //store TE objectS
+ if (!teReportList.add(PcepTEObjectVer1.read(cb))) {
+ throw new PcepParseException("Failed to add TE object to TE report list");
+ }
+ }
+ }
+ }
+
+ /**
+ * Constructor to initialize TE Report List.
+ *
+ * @param teReportList list of PCEP TE Object
+ */
+ PcepTEReportMsgVer1(LinkedList<PcepTEObject> teReportList) {
+ this.teReportList = teReportList;
+ }
+
+ /**
+ * Builder class for PCEP te report message.
+ */
+ static class Builder implements PcepTEReportMsg.Builder {
+ // PCEP TE Report message fields
+ LinkedList<PcepTEObject> teReportList;
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public PcepType getType() {
+ return PcepType.TE_REPORT;
+ }
+
+ @Override
+ public PcepTEReportMsg build() {
+ return new PcepTEReportMsgVer1(this.teReportList);
+ }
+
+ @Override
+ public LinkedList<PcepTEObject> getTEReportList() {
+ return this.teReportList;
+ }
+
+ @Override
+ public Builder setTEReportList(LinkedList<PcepTEObject> ll) {
+ this.teReportList = ll;
+ return this;
+ }
+ }
+
+ @Override
+ public void writeTo(ChannelBuffer bb) throws PcepParseException {
+ WRITER.write(bb, this);
+ }
+
+ static final Writer WRITER = new Writer();
+
+ /**
+ * Writer class for writing PCEP te report message to channel buffer.
+ */
+ static class Writer implements PcepMessageWriter<PcepTEReportMsgVer1> {
+
+ @Override
+ public void write(ChannelBuffer bb, PcepTEReportMsgVer1 message) throws PcepParseException {
+
+ int startIndex = bb.writerIndex();
+
+ // first 3 bits set to version
+ bb.writeByte((byte) (PcepMessageVer1.PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
+
+ // message type
+ bb.writeByte(MSG_TYPE.getType());
+
+ // Length of the message will be updated at the end
+ // First write with 0s
+ int msgLenIndex = bb.writerIndex();
+ bb.writeShort((short) 0);
+
+ ListIterator<PcepTEObject> listIterator = message.teReportList.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepTEObject teObj = listIterator.next();
+ teObj.write(bb);
+ }
+
+ // update message length field
+ int length = bb.writerIndex() - startIndex;
+ bb.setShort(msgLenIndex, (short) length);
+ }
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public PcepType getType() {
+ return MSG_TYPE;
+ }
+
+ @Override
+ public LinkedList<PcepTEObject> getTEReportList() {
+ return this.teReportList;
+ }
+
+ @Override
+ public void setTEReportList(LinkedList<PcepTEObject> ll) {
+ this.teReportList = ll;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("TeReportList", teReportList)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateMsgVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateMsgVer1.java
new file mode 100644
index 00000000..53c66872
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateMsgVer1.java
@@ -0,0 +1,300 @@
+/*
+ * 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.PcepLspObject;
+import org.onosproject.pcepio.protocol.PcepMessageReader;
+import org.onosproject.pcepio.protocol.PcepMessageWriter;
+import org.onosproject.pcepio.protocol.PcepMsgPath;
+import org.onosproject.pcepio.protocol.PcepSrpObject;
+import org.onosproject.pcepio.protocol.PcepType;
+import org.onosproject.pcepio.protocol.PcepUpdateMsg;
+import org.onosproject.pcepio.protocol.PcepUpdateRequest;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP update message.
+ */
+
+class PcepUpdateMsgVer1 implements PcepUpdateMsg {
+
+ // Pcep version: 1
+
+ /* The format of the PCUpd message is as follows:
+ * <PCUpd Message> ::= <Common Header>
+ * <update-request-list>
+ * Where:
+ * <update-request-list> ::= <update-request>[<update-request-list>]
+ * <update-request> ::= <SRP>
+ * <LSP>
+ * <path>
+ * Where:
+ * <path> ::= <ERO><attribute-list>
+ * Where:
+ * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
+ * where:
+ * <attribute-list> ::=[<LSPA>]
+ * [<BANDWIDTH>]
+ * [<metric-list>]
+ * [<IRO>]
+ * <metric-list> ::=<METRIC>[<metric-list>]
+ *
+ * 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 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | |
+ * // UPDATE REQUEST LIST //
+ * | |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * Reference:Internet-Draft-PCEP Extensions-for-Stateful-PCE-10
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepUpdateMsgVer1.class);
+
+ public static final byte PACKET_VERSION = 1;
+ // UpdateMsgMinLength = SrpObjMinLentgh(12)+LspObjMinLength(8)+EroObjMinLength(12)+ CommonHeaderLength(4)
+ public static final short PACKET_MINIMUM_LENGTH = 36;
+ public static final PcepType MSG_TYPE = PcepType.UPDATE;
+ //Update Request List
+ private LinkedList<PcepUpdateRequest> llUpdateRequestList;
+
+ public static final PcepUpdateMsgVer1.Reader READER = new Reader();
+
+ /**
+ * Reader reads UpdateMessage from the channel.
+ */
+ static class Reader implements PcepMessageReader<PcepUpdateMsg> {
+
+ LinkedList<PcepUpdateRequest> llUpdateRequestList;
+
+ @Override
+ public PcepUpdateMsg readFrom(ChannelBuffer cb) throws PcepParseException {
+
+ if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
+ throw new PcepParseException("Readable bytes is less than update message minimum length");
+ }
+
+ llUpdateRequestList = new LinkedList<>();
+
+ // 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 == 11
+ byte type = cb.readByte();
+ if (type != MSG_TYPE.getType()) {
+ throw new PcepParseException("Wrong type. Expected=PcepType.UPDATE(11), got=" + type);
+ }
+ short length = cb.readShort();
+ if (length < PACKET_MINIMUM_LENGTH) {
+ throw new PcepParseException("Wrong length. Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: "
+ + length);
+ }
+
+ log.debug("reading update message of length " + length);
+
+ // parse Update Request list
+ if (!parseUpdateRequestList(cb)) {
+ throw new PcepParseException("parsing Update Request List Failed.");
+ }
+
+ return new PcepUpdateMsgVer1(llUpdateRequestList);
+ }
+
+ /**
+ * Parse update request list.
+ *
+ * @param cb of type channel buffer
+ * @return true after parsing Update Request List
+ * @throws PcepParseException while parsing update request list from channel buffer
+ */
+ public boolean parseUpdateRequestList(ChannelBuffer cb) throws PcepParseException {
+
+ /* <update-request-list>
+ * Where:
+ * <update-request-list> ::= <update-request>[<update-request-list>]
+ * <update-request> ::= <SRP>
+ * <LSP>
+ * <path>
+ * Where:
+ * <path> ::= <ERO><attribute-list>
+ * Where:
+ * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
+ */
+
+ while (0 < cb.readableBytes()) {
+
+ PcepUpdateRequest pceUpdateReq = new PcepUpdateRequestVer1();
+
+ //Read SRP Object and Store it.
+ PcepSrpObject srpObj;
+ srpObj = PcepSrpObjectVer1.read(cb);
+ pceUpdateReq.setSrpObject(srpObj);
+
+ //Read LSP object and Store it.
+ PcepLspObject lspObj;
+ lspObj = PcepLspObjectVer1.read(cb);
+ pceUpdateReq.setLspObject(lspObj);
+
+ // Read Msg Path and store it.
+ PcepMsgPath msgPath = new PcepMsgPathVer1().read(cb);
+ pceUpdateReq.setMsgPath(msgPath);
+
+ llUpdateRequestList.add(pceUpdateReq);
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Constructor to initialize llUpdateRequestList.
+ *
+ * @param llUpdateRequestList list of PcepUpdateRequest.
+ */
+ PcepUpdateMsgVer1(LinkedList<PcepUpdateRequest> llUpdateRequestList) {
+ this.llUpdateRequestList = llUpdateRequestList;
+ }
+
+ /**
+ * Builder class for PCPE update message.
+ */
+ static class Builder implements PcepUpdateMsg.Builder {
+
+ // PCEP report message fields
+ LinkedList<PcepUpdateRequest> llUpdateRequestList;
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public PcepType getType() {
+ return PcepType.UPDATE;
+ }
+
+ @Override
+ public PcepUpdateMsg build() {
+ return new PcepUpdateMsgVer1(this.llUpdateRequestList);
+ }
+
+ @Override
+ public LinkedList<PcepUpdateRequest> getUpdateRequestList() {
+ return this.llUpdateRequestList;
+ }
+
+ @Override
+ public Builder setUpdateRequestList(LinkedList<PcepUpdateRequest> llUpdateRequestList) {
+ this.llUpdateRequestList = llUpdateRequestList;
+ return this;
+ }
+
+ }
+
+ @Override
+ public void writeTo(ChannelBuffer cb) throws PcepParseException {
+ WRITER.write(cb, this);
+ }
+
+ static final Writer WRITER = new Writer();
+
+ /**
+ * Writer writes UpdateMessage to the channel buffer.
+ */
+ static class Writer implements PcepMessageWriter<PcepUpdateMsgVer1> {
+
+ @Override
+ public void write(ChannelBuffer cb, PcepUpdateMsgVer1 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 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);
+ ListIterator<PcepUpdateRequest> listIterator = message.llUpdateRequestList.listIterator();
+
+ while (listIterator.hasNext()) {
+
+ PcepUpdateRequest updateReq = listIterator.next();
+
+ //SRP object is mandatory
+ PcepSrpObject srpObj = updateReq.getSrpObject();
+ srpObj.write(cb);
+
+ //LSP object is mandatory
+ PcepLspObject lspObj = updateReq.getLspObject();
+ lspObj.write(cb);
+
+ //PATH object is mandatory
+ PcepMsgPath msgPath = updateReq.getMsgPath();
+ msgPath.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 LinkedList<PcepUpdateRequest> getUpdateRequestList() {
+ return this.llUpdateRequestList;
+ }
+
+ @Override
+ public void setUpdateRequestList(LinkedList<PcepUpdateRequest> llUpdateRequestList) {
+ this.llUpdateRequestList = llUpdateRequestList;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("UpdateRequestList", llUpdateRequestList)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateRequestVer1.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateRequestVer1.java
new file mode 100644
index 00000000..0bcc2907
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepUpdateRequestVer1.java
@@ -0,0 +1,199 @@
+/*
+ * 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.PcepLspObject;
+import org.onosproject.pcepio.protocol.PcepMsgPath;
+import org.onosproject.pcepio.protocol.PcepSrpObject;
+import org.onosproject.pcepio.protocol.PcepUpdateRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP Update Request List.
+ */
+public class PcepUpdateRequestVer1 implements PcepUpdateRequest {
+
+ /* <update-request-list>
+ * Where:
+ * <update-request-list> ::= <update-request>[<update-request-list>]
+ * <update-request> ::= <SRP>
+ * <LSP>
+ * <path>
+ * Where:
+ * <path> ::= <ERO><attribute-list>
+ * Where:
+ * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepUpdateRequestVer1.class);
+
+ //PCEP SRP Object
+ private PcepSrpObject srpObject;
+ //PCEP LSP Object
+ private PcepLspObject lspObject;
+ //PCEP Message path
+ private PcepMsgPath msgPath;
+
+ /**
+ * Default constructor.
+ */
+ public PcepUpdateRequestVer1() {
+ srpObject = null;
+ lspObject = null;
+ msgPath = null;
+ }
+
+ /**
+ * Constructor to initialize all member variables.
+ *
+ * @param srpObject srp object
+ * @param lspObject lsp object
+ * @param msgPath message path object
+ */
+ public PcepUpdateRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepMsgPath msgPath) {
+ this.srpObject = srpObject;
+ this.lspObject = lspObject;
+ this.msgPath = msgPath;
+ }
+
+ @Override
+ public PcepSrpObject getSrpObject() {
+ return srpObject;
+ }
+
+ @Override
+ public PcepLspObject getLspObject() {
+ return lspObject;
+ }
+
+ @Override
+ public PcepMsgPath getMsgPath() {
+ return msgPath;
+ }
+
+ @Override
+ public void setSrpObject(PcepSrpObject srpObject) {
+ this.srpObject = srpObject;
+
+ }
+
+ @Override
+ public void setLspObject(PcepLspObject lspObject) {
+ this.lspObject = lspObject;
+ }
+
+ @Override
+ public void setMsgPath(PcepMsgPath msgPath) {
+ this.msgPath = msgPath;
+ }
+
+ /**
+ * Builder class for PCEP update request.
+ */
+ public static class Builder implements PcepUpdateRequest.Builder {
+
+ private boolean bIsSRPObjectSet = false;
+ private boolean bIsLSPObjectSet = false;
+ private boolean bIsPcepMsgPathSet = false;
+
+ //PCEP SRP Object
+ private PcepSrpObject srpObject;
+ //PCEP LSP Object
+ private PcepLspObject lspObject;
+ //PCEP Attribute list
+ private PcepMsgPath msgPath;
+
+ @Override
+ public PcepUpdateRequest build() throws PcepParseException {
+
+ //PCEP SRP Object
+ PcepSrpObject srpObject = null;
+ //PCEP LSP Object
+ PcepLspObject lspObject = null;
+ //PCEP Attribute list
+ PcepMsgPath msgPath = null;
+
+ if (!this.bIsSRPObjectSet) {
+ throw new PcepParseException(" SRP Object NOT Set while building PcepUpdateRequest.");
+ } else {
+ srpObject = this.srpObject;
+ }
+ if (!this.bIsLSPObjectSet) {
+ throw new PcepParseException(" LSP Object NOT Set while building PcepUpdateRequest.");
+ } else {
+ lspObject = this.lspObject;
+ }
+ if (!this.bIsPcepMsgPathSet) {
+ throw new PcepParseException(" Msg Path NOT Set while building PcepUpdateRequest.");
+ } else {
+ msgPath = this.msgPath;
+ }
+
+ return new PcepUpdateRequestVer1(srpObject, lspObject, msgPath);
+ }
+
+ @Override
+ public PcepSrpObject getSrpObject() {
+ return this.srpObject;
+ }
+
+ @Override
+ public PcepLspObject getLspObject() {
+ return this.lspObject;
+ }
+
+ @Override
+ public PcepMsgPath getMsgPath() {
+ return this.msgPath;
+ }
+
+ @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 setMsgPath(PcepMsgPath msgPath) {
+ this.msgPath = msgPath;
+ this.bIsPcepMsgPathSet = true;
+ return this;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("SrpObject", srpObject)
+ .add("LspObject", lspObject)
+ .add("MsgPath", msgPath)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/package-info.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/package-info.java
new file mode 100644
index 00000000..32d49ec9
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/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 PCEP messages.
+ */
+package org.onosproject.pcepio.protocol.ver1;
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java
new file mode 100644
index 00000000..62ed4e7f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Administrative Group Tlv which contains value (32 Bit ).
+ */
+public class AdministrativeGroupTlv implements PcepValueType {
+
+ /* REFERENCE :[RFC5305]/3.1
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TDB33] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | value (32 Bit ) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(AdministrativeGroupTlv.class);
+
+ public static final short TYPE = 3; //TDB33
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue of Administrative-Group-Tlv.
+ */
+ public AdministrativeGroupTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created AdministrativeGroupTlv object.
+ *
+ * @param raw value.
+ * @return object of Administrative-Group-Tlv
+ */
+ public static AdministrativeGroupTlv of(final int raw) {
+ return new AdministrativeGroupTlv(raw);
+ }
+
+ /**
+ * Returns raw value.
+ *
+ * @return rawValue raw value
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof AdministrativeGroupTlv) {
+ AdministrativeGroupTlv other = (AdministrativeGroupTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of Administrative-Group-Tlv.
+ *
+ * @param c input channel buffer
+ * @return object of Administrative-Group-Tlv
+ */
+ public static AdministrativeGroupTlv read(ChannelBuffer c) {
+ return AdministrativeGroupTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemTlv.java
new file mode 100644
index 00000000..3f213191
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Autonomous-System-Tlv which contains opaque value (32 Bit AS Number).
+ */
+public class AutonomousSystemTlv implements PcepValueType {
+
+ /* Reference :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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD10] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value (32 Bit AS Number) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(AutonomousSystemTlv.class);
+
+ public static final short TYPE = 100; //TODD:change this TBD10
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue Autonomous-System-Tlv
+ */
+ public AutonomousSystemTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created AutonomousSystemTlv object.
+ *
+ * @param raw value of opaque.
+ * @return object of Autonomous-System-Tlv
+ */
+ public static AutonomousSystemTlv of(final int raw) {
+ return new AutonomousSystemTlv(raw);
+ }
+
+ /**
+ * Returns opaque value.
+ *
+ * @return rawValue opaque value.
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof AutonomousSystemTlv) {
+ AutonomousSystemTlv other = (AutonomousSystemTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of AutonomousSystemTlv.
+ *
+ * @param c input channel buffer
+ * @return object of Autonomous-System-Tlv
+ */
+ public static AutonomousSystemTlv read(ChannelBuffer c) {
+ return AutonomousSystemTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("TYPE", TYPE)
+ .add("Length", LENGTH)
+ .add("value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java
new file mode 100644
index 00000000..4981649f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides BGP LS identifier which contains opaque value (32 Bit ID).
+ */
+public class BGPLSidentifierTlv implements PcepValueType {
+
+ /* Reference :draft-ietf-idr-ls-distribution-10
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD11] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value (32 Bit ID). |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(BGPLSidentifierTlv.class);
+
+ public static final short TYPE = 17; //TODD:change this TBD11
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue BGP LS identifier Tlv
+ */
+ public BGPLSidentifierTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created BGPLSidentifierTlv object.
+ *
+ * @param raw value
+ * @return object of BGPLSidentifierTlv
+ */
+ public static BGPLSidentifierTlv of(final int raw) {
+ return new BGPLSidentifierTlv(raw);
+ }
+
+ /**
+ * Returns opaque value.
+ *
+ * @return rawValue opaque value
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof BGPLSidentifierTlv) {
+ BGPLSidentifierTlv other = (BGPLSidentifierTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of BGPLSidentifierTlv.
+ *
+ * @param c input channel buffer
+ * @return object of BGP LS identifier Tlv
+ */
+ public static BGPLSidentifierTlv read(ChannelBuffer c) {
+ return BGPLSidentifierTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java
new file mode 100644
index 00000000..40f89f4c
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java
@@ -0,0 +1,160 @@
+/*
+ * 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.types;
+
+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.protocol.PcepOpenObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provide the error object list with open object.
+ */
+public class ErrorObjListWithOpen {
+ //errorObjList is mandatory
+ private LinkedList<PcepErrorObject> llerrorObjList;
+ // openObject is optional
+ private PcepOpenObject openObject;
+ // flag to check if open object is set or not
+ private boolean isOpenObjectSet;
+ protected static final Logger log = LoggerFactory.getLogger(ErrorObjListWithOpen.class);
+
+ /**
+ * Constructor to initialize Error and OPEN object.
+ *
+ * @param errObj ERROR object list
+ * @param openObj OPEN object
+ */
+ public ErrorObjListWithOpen(LinkedList<PcepErrorObject> errObj, PcepOpenObject openObj) {
+ this.llerrorObjList = errObj;
+ this.openObject = openObj;
+ if (openObj != null) {
+ isOpenObjectSet = true;
+ } else {
+ isOpenObjectSet = false;
+ }
+ }
+
+ /**
+ * Constructor to initialize ERROR Object.
+ *
+ * @param errObj ERROR Object list
+ */
+ public ErrorObjListWithOpen(LinkedList<PcepErrorObject> errObj) {
+ this.llerrorObjList = errObj;
+ this.openObject = null;
+ isOpenObjectSet = false;
+ }
+
+ /**
+ * Return list of Error Types.
+ *
+ * @return error types list
+ */
+ public LinkedList<Integer> getErrorType() {
+ LinkedList<Integer> errorType = new LinkedList<>();
+ if (llerrorObjList != null) {
+ ListIterator<PcepErrorObject> errObjListIterator = llerrorObjList.listIterator();
+ int error;
+ PcepErrorObject errorObj;
+ while (errObjListIterator.hasNext()) {
+ errorObj = errObjListIterator.next();
+ error = errorObj.getErrorType();
+ errorType.add(error);
+ }
+ }
+ return errorType;
+ }
+
+ /**
+ * Return list of Error Values.
+ *
+ * @return error values list
+ */
+ public LinkedList<Integer> getErrorValue() {
+ LinkedList<Integer> errorValue = new LinkedList<>();
+ if (llerrorObjList != null) {
+ ListIterator<PcepErrorObject> errObjListIterator = llerrorObjList.listIterator();
+ int error;
+ PcepErrorObject errorObj;
+ while (errObjListIterator.hasNext()) {
+ errorObj = errObjListIterator.next();
+ error = errorObj.getErrorValue();
+ errorValue.add(error);
+ }
+ }
+ return errorValue;
+ }
+
+ /**
+ * Checks whether ERROR Object list is empty or not.
+ *
+ * @return true if ERROR Object list is empty otherwise false
+ */
+ public boolean isErrorObjListWithOpenPresent() {
+ // ( <error-obj-list> [<Open>]
+ // At least in this case <error-obj-list> should be present.
+ return !this.llerrorObjList.isEmpty();
+ }
+
+ /**
+ * Write Error Object List and Open Object to channel buffer.
+ *
+ * @param cb output channel buffer
+ * @return length of written Error object list with open
+ * @throws PcepParseException when mandatory fields are not set
+ */
+ public int write(ChannelBuffer cb) throws PcepParseException {
+ int iLenStartIndex = cb.writerIndex();
+ boolean bIsErrObjListFound = false;
+
+ //<error-obj-list> is mandatory , if not present throw exception.
+ if (llerrorObjList != null) {
+ ListIterator<PcepErrorObject> errObjListIterator = llerrorObjList.listIterator();
+ while (errObjListIterator.hasNext()) {
+ errObjListIterator.next().write(cb);
+ bIsErrObjListFound = true;
+ }
+ }
+
+ if (!bIsErrObjListFound) {
+ throw new PcepParseException("<error-obj-list> is mandatory.");
+ }
+
+ //Open Object is optional , if present write.
+ if (openObject != null) {
+ openObject.write(cb);
+ }
+
+ return cb.writerIndex() - iLenStartIndex;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("ErrorObjList", llerrorObjList)
+ .add("Open", openObject)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java
new file mode 100644
index 00000000..212aa3d3
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java
@@ -0,0 +1,138 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides GMPLS Capability Tlv.
+ */
+public class GmplsCapabilityTlv implements PcepValueType {
+
+ /*
+ * GMPLS-CAPABILITY TLV format
+ * reference :draft-ietf-pce-gmpls-pcep-extensions -2.1.1
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=14 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Flags |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(GmplsCapabilityTlv.class);
+
+ public static final short TYPE = 14;
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize raw value.
+ *
+ * @param rawValue of Gmpls-Capability-Tlv
+ */
+ public GmplsCapabilityTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created GmplsCapabilityTlv object.
+ *
+ * @param raw Flags value
+ * @return object of Gmpls-Capability-Tlv
+ */
+ public static GmplsCapabilityTlv of(final int raw) {
+ return new GmplsCapabilityTlv(raw);
+ }
+
+ /**
+ * Returns value of Flags.
+ *
+ * @return rawValue Flags
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof GmplsCapabilityTlv) {
+ GmplsCapabilityTlv other = (GmplsCapabilityTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of Gmpls-Capability-Tlv.
+ *
+ * @param c input channel buffer
+ * @return object of Gmpls-Capability-Tlv
+ */
+ public static GmplsCapabilityTlv read(ChannelBuffer c) {
+ return GmplsCapabilityTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java
new file mode 100644
index 00000000..07cfea7f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java
@@ -0,0 +1,150 @@
+/*
+ * 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.types;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IGP Link Metric .
+ */
+public class IGPMetricTlv implements PcepValueType {
+
+ /* Reference :[I-D.ietf-idr-ls-distribution] /3.3.2.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TDB40 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // IGP Link Metric (variable length) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IGPMetricTlv.class);
+
+ public static final short TYPE = 1095; //TODO:NEED TO HANDLE TDB40
+ private short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize raw value.
+ *
+ * @param rawValue IGP Link Metric
+ * @param hLength length
+ */
+ public IGPMetricTlv(byte[] rawValue, short hLength) {
+ this.rawValue = rawValue;
+ this.hLength = hLength;
+ }
+
+ /**
+ * Returns newly created IGPMetricTlv object.
+ *
+ * @param raw value of IGP Link Metric
+ * @param hLength length
+ * @return object of IGPMetricTlv
+ */
+ public static IGPMetricTlv of(final byte[] raw, short hLength) {
+ return new IGPMetricTlv(raw, hLength);
+ }
+
+ /**
+ * Returns value of IGP Link Metric.
+ *
+ * @return rawValue of IGP Link Metric
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IGPMetricTlv) {
+ IGPMetricTlv other = (IGPMetricTlv) obj;
+ return Arrays.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IGPMetricTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of IGPMetricTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iIGPMetric = new byte[hLength];
+ c.readBytes(iIGPMetric, 0, hLength);
+ return new IGPMetricTlv(iIGPMetric, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java
new file mode 100644
index 00000000..d1a30157
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides IPv4 Interface Address .
+ */
+public class IPv4InterfaceAddressTlv implements PcepValueType {
+
+ /*
+ * reference :[RFC5305]/3.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=6 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 Interface Address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IPv4InterfaceAddressTlv.class);
+
+ public static final short TYPE = 6;
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue of IPv4-Interface-Address.
+ */
+ public IPv4InterfaceAddressTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv4InterfaceAddressTlv object.
+ *
+ * @param raw value of IPv4-Interface-Address
+ * @return object of IPv4-Interface-Address-Tlv
+ */
+ public static IPv4InterfaceAddressTlv of(final int raw) {
+ return new IPv4InterfaceAddressTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv4 Interface Address.
+ *
+ * @return rawValue IPv4 Interface Address
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv4InterfaceAddressTlv) {
+ IPv4InterfaceAddressTlv other = (IPv4InterfaceAddressTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv4InterfaceAddressTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv4-Interface-Address-Tlv
+ */
+ public static IPv4InterfaceAddressTlv read(ChannelBuffer c) {
+ return IPv4InterfaceAddressTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java
new file mode 100644
index 00000000..0f98777f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides IPv4 Neighbor Address .
+ */
+public class IPv4NeighborAddressTlv implements PcepValueType {
+
+ /* Reference :[RFC5305]/3.3
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=8 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 Neighbor Address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IPv4NeighborAddressTlv.class);
+
+ public static final short TYPE = 8;
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv4-Neighbor-Address-Tlv
+ */
+ public IPv4NeighborAddressTlv(int rawValue) {
+ log.debug("IPv4NeighborAddressTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv4NeighborAddressTlv object.
+ *
+ * @param raw value of IPv4-Neighbor-Address
+ * @return object of IPv4NeighborAddressTlv
+ */
+ public static IPv4NeighborAddressTlv of(final int raw) {
+ return new IPv4NeighborAddressTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv4 Neighbor Address.
+ *
+ * @return rawValue IPv4 Neighbor Address
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv4NeighborAddressTlv) {
+ IPv4NeighborAddressTlv other = (IPv4NeighborAddressTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv4-Neighbor-Address-Tlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv4-Neighbor-Address-Tlv
+ */
+ public static IPv4NeighborAddressTlv read(ChannelBuffer c) {
+ return IPv4NeighborAddressTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java
new file mode 100644
index 00000000..031b5db6
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+
+/**
+ * @author b00295750
+ *
+ */
+package org.onosproject.pcepio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides IPv4 Sub Object.
+ */
+public class IPv4SubObject implements PcepValueType {
+
+ /*Reference : RFC 4874:3.1.1
+ * 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(IPv4SubObject.class);
+
+ public static final byte TYPE = 0x01;
+ public static final byte LENGTH = 8;
+ public static final byte VALUE_LENGTH = 6;
+ public static final byte OBJ_LENGTH = 8;
+ public static final byte LBIT = 0;
+ public static final int SHIFT_LBIT_POSITION = 7;
+ private int ipAddress;
+ private byte prefixLen;
+ private byte resvd;
+
+ /**
+ * Constructor to initialize ipv4 address.
+ *
+ * @param ipAddr ipv4 address
+ */
+ public IPv4SubObject(int ipAddr) {
+ this.ipAddress = ipAddr;
+ }
+
+ /**
+ * constructor to initialize ipAddress, prefixLen and resvd.
+ *
+ * @param ipAddress ipv4 address
+ * @param prefixLen prefix length
+ * @param resvd reserved flags value
+ */
+ public IPv4SubObject(int ipAddress, byte prefixLen, byte resvd) {
+ this.ipAddress = ipAddress;
+ this.prefixLen = prefixLen;
+ this.resvd = resvd;
+ }
+
+ /**
+ * Returns a new instance of IPv4SubObject.
+ *
+ * @param ipAddress ipv4 address
+ * @param prefixLen prefix length
+ * @param resvd reserved flags value
+ * @return object of IPv4SubObject
+ */
+ public static IPv4SubObject of(int ipAddress, byte prefixLen, byte resvd) {
+ return new IPv4SubObject(ipAddress, prefixLen, resvd);
+ }
+
+ /**
+ * Returns prefixLen of IPv4 IP address.
+ *
+ * @return byte value of rawValue
+ */
+ public byte getPrefixLen() {
+ return prefixLen;
+ }
+
+ /**
+ * Returns value of IPv4 IP address.
+ *
+ * @return int value of ipv4 address
+ */
+ public int getIpAddress() {
+ return ipAddress;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ipAddress, prefixLen, resvd);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv4SubObject) {
+ IPv4SubObject other = (IPv4SubObject) obj;
+ return Objects.equals(this.ipAddress, other.ipAddress) && Objects.equals(this.prefixLen, other.prefixLen)
+ && Objects.equals(this.resvd, other.resvd);
+ }
+ return false;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv4SubObject.
+ *
+ * @param c type of channel buffer
+ * @return object of IPv4SubObject
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ int ipAddess = c.readInt();
+ byte prefixLen = c.readByte();
+ byte resvd = c.readByte();
+ return new IPv4SubObject(ipAddess, prefixLen, resvd);
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ byte bValue = LBIT;
+ bValue = (byte) (bValue << SHIFT_LBIT_POSITION);
+ bValue = (byte) (bValue | TYPE);
+ c.writeByte(bValue);
+ c.writeByte(OBJ_LENGTH);
+ c.writeInt(ipAddress);
+ c.writeByte(prefixLen);
+ c.writeByte(resvd);
+
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("IPv4Address", ipAddress)
+ .add("PrefixLength", prefixLen)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java
new file mode 100644
index 00000000..2abf4cdc
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides IPv4 TE Router Id Of Local Node.
+ */
+public class IPv4TERouterIdOfLocalNodeTlv implements PcepValueType {
+
+ /* Reference:[RFC5305]/4.3
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TDB25] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 TE Router Id Of Local Node |
+ +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IPv4TERouterIdOfLocalNodeTlv.class);
+
+ public static final short TYPE = 134; //TDB25
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv4-TE-RouterId-Of-Local-Node-Tlv
+ */
+ public IPv4TERouterIdOfLocalNodeTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv4TERouterIdOfLocalNodeTlv object.
+ *
+ * @param raw value of IPv4-TE-RouterId-Of-Local-Node
+ * @return object of IPv4TERouterIdOfLocalNodeTlv
+ */
+ public static IPv4TERouterIdOfLocalNodeTlv of(final int raw) {
+ return new IPv4TERouterIdOfLocalNodeTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv4 TE Router Id Of Local Node.
+ *
+ * @return rawValue IPv4 TE Router Id Of Local Node
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv4TERouterIdOfLocalNodeTlv) {
+ IPv4TERouterIdOfLocalNodeTlv other = (IPv4TERouterIdOfLocalNodeTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv4TERouterIdOfLocalNodeTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv4TERouterIdOfLocalNodeTlv
+ */
+ public static IPv4TERouterIdOfLocalNodeTlv read(ChannelBuffer c) {
+ return IPv4TERouterIdOfLocalNodeTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java
new file mode 100644
index 00000000..21e09890
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides IPv4 TE Router Id Of Remote Node.
+ */
+public class IPv4TERouterIdOfRemoteNodeTlv implements PcepValueType {
+
+ /* Reference :[RFC5305]/4.3
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TDB28] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 TE Router Id Of Remote Node |
+ +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IPv4TERouterIdOfRemoteNodeTlv.class);
+
+ public static final short TYPE = 1340; //TDB28
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv4 TE RouterId Of Remote Node Tlv
+ */
+ public IPv4TERouterIdOfRemoteNodeTlv(int rawValue) {
+ log.debug("IPv4TERouterIdOfRemoteNodeTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv4TERouterIdOfRemoteNodeTlv object.
+ *
+ * @param raw IPv4 TE RouterId Of Remote Node
+ * @return object of IPv4TERouterIdOfRemoteNodeTlv
+ */
+ public static IPv4TERouterIdOfRemoteNodeTlv of(final int raw) {
+ return new IPv4TERouterIdOfRemoteNodeTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv4 TE Router Id Of Remote Node.
+ *
+ * @return rawValue IPv4 TE Router Id Of Remote Node
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv4TERouterIdOfRemoteNodeTlv) {
+ IPv4TERouterIdOfRemoteNodeTlv other = (IPv4TERouterIdOfRemoteNodeTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv4TERouterIdOfRemoteNodeTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv4TERouterIdOfRemoteNodeTlv
+ */
+ public static IPv4TERouterIdOfRemoteNodeTlv read(ChannelBuffer c) {
+ return IPv4TERouterIdOfRemoteNodeTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java
new file mode 100644
index 00000000..62a5588d
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java
@@ -0,0 +1,181 @@
+/*
+ * 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.types;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IPv6 Interface Address. REFERENCE :[RFC6119]/4.2.
+ */
+public class IPv6InterfaceAddressTlv implements PcepValueType {
+
+ protected static final Logger log = LoggerFactory.getLogger(IPv6InterfaceAddressTlv.class);
+
+ public static final short TYPE = 12; //TDB18
+ public static final short LENGTH = 20;
+ public static final byte VALUE_LENGTH = 18;
+
+ private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ public static final IPv6InterfaceAddressTlv NONE = new IPv6InterfaceAddressTlv(NONE_VAL);
+
+ private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
+ public static final IPv6InterfaceAddressTlv NO_MASK = new IPv6InterfaceAddressTlv(NO_MASK_VAL);
+ public static final IPv6InterfaceAddressTlv FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv6 Interface Address Tlv
+ */
+ public IPv6InterfaceAddressTlv(byte[] rawValue) {
+ log.debug("IPv6InterfaceAddressTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv6InterfaceAddressTlv object.
+ *
+ * @param raw IPv6 Interface Address
+ * @return object of IPv6InterfaceAddressTlv
+ */
+ public static IPv6InterfaceAddressTlv of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (NONE_VAL[i] != raw[i]) {
+ bFoundNONE = false;
+ }
+ }
+
+ if (bFoundNONE) {
+ return NONE;
+ }
+
+ //check NO_MASK_VAL
+ boolean bFoundNoMask = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+
+ return new IPv6InterfaceAddressTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv6 Interface Address.
+ *
+ * @return rawValue raw value
+ */
+ public byte[] getBytes() {
+ return rawValue;
+ }
+
+ /**
+ * Returns value of IPv6 Interface Address.
+ *
+ * @return rawValue raw value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6InterfaceAddressTlv) {
+ IPv6InterfaceAddressTlv other = (IPv6InterfaceAddressTlv) obj;
+ return Arrays.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv6InterfaceAddressTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv6InterfaceAddressTlv
+ */
+ public static IPv6InterfaceAddressTlv read20Bytes(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return IPv6InterfaceAddressTlv.of(yTemp);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", LENGTH);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java
new file mode 100644
index 00000000..fb9b98ac
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java
@@ -0,0 +1,179 @@
+/*
+ * 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.types;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IPv6 Neighbor Address. Reference :[RFC6119]/4.3.
+ */
+public class IPv6NeighborAddressTlv implements PcepValueType {
+ protected static final Logger log = LoggerFactory.getLogger(IPv6NeighborAddressTlv.class);
+
+ public static final short TYPE = 13; // TDB19
+ public static final short LENGTH = 20;
+ public static final byte VALUE_LENGTH = 18;
+
+ private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ public static final IPv6NeighborAddressTlv NONE = new IPv6NeighborAddressTlv(NONE_VAL);
+
+ private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
+ public static final IPv6NeighborAddressTlv NO_MASK = new IPv6NeighborAddressTlv(NO_MASK_VAL);
+ public static final IPv6NeighborAddressTlv FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv6 Neighbor Address Tlv
+ */
+ public IPv6NeighborAddressTlv(byte[] rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv6NeighborAddressTlv object.
+ *
+ * @param raw IPv6 Neighbor Address
+ * @return object of IPv6 Neighbor Address Tlv
+ */
+ public static IPv6NeighborAddressTlv of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (NONE_VAL[i] != raw[i]) {
+ bFoundNONE = false;
+ }
+ }
+
+ if (bFoundNONE) {
+ return NONE;
+ }
+
+ //check NO_MASK_VAL
+ boolean bFoundNoMask = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+
+ return new IPv6NeighborAddressTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv6 Neighbor Address.
+ *
+ * @return rawValue raw value
+ */
+ public byte[] getBytes() {
+ return rawValue;
+ }
+
+ /**
+ * Returns value of IPv6 Neighbor Address.
+ *
+ * @return rawValue raw value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6NeighborAddressTlv) {
+ IPv6NeighborAddressTlv other = (IPv6NeighborAddressTlv) obj;
+ return Arrays.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv6NeighborAddressTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv6NeighborAddressTlv
+ */
+ public static IPv6NeighborAddressTlv read20Bytes(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return IPv6NeighborAddressTlv.of(yTemp);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", LENGTH);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java
new file mode 100644
index 00000000..b3164f26
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.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.pcepio.types;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IPv6 Sub Object.
+ */
+public class IPv6SubObject implements PcepValueType {
+
+ /* reference :RFC 4874.
+ Subobject : IPv6 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type | Length | IPv6 address (16 bytes) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) | Prefix Length | Flags |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Type
+
+ 0x02 IPv6 address
+
+ Length
+
+ The Length contains the total length of the subobject in bytes,
+ including the Type and Length fields. The Length is always 20.
+
+ IPv6 address
+
+ A 128-bit unicast host address.
+
+ Prefix length
+
+ 128
+
+ Flags
+
+ 0x01 Local protection available
+
+ Indicates that the link downstream of this node is
+ protected via a local repair mechanism. This flag can
+ only be set if the Local protection flag was set in the
+ SESSION_ATTRIBUTE object of the corresponding Path
+ message.
+
+ 0x02 Local protection in use
+
+ Indicates that a local repair mechanism is in use to
+ maintain this tunnel (usually in the face of an outage
+ of the link it was previously routed over).
+ */
+ protected static final Logger log = LoggerFactory.getLogger(IPv6SubObject.class);
+
+ public static final short TYPE = 0x02;
+ public static final short LENGTH = 20;
+ public static final byte VALUE_LENGTH = 18;
+
+ private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ public static final IPv6SubObject NONE = new IPv6SubObject(NONE_VAL);
+
+ private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+ public static final IPv6SubObject NO_MASK = new IPv6SubObject(NO_MASK_VAL);
+ public static final IPv6SubObject FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue with ipv6 address.
+ *
+ * @param rawValue ipv6 address
+ */
+ public IPv6SubObject(byte[] rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * To create instance of IPv6SubObject.
+ *
+ * @param raw byte array of ipv6 address
+ * @return object of IPv6SubObject
+ */
+ public static IPv6SubObject of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (NONE_VAL[i] != raw[i]) {
+ bFoundNONE = false;
+ }
+ }
+
+ if (bFoundNONE) {
+ return NONE;
+ }
+
+ //check NO_MASK_VAL
+ boolean bFoundNoMask = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+
+ return new IPv6SubObject(raw);
+ }
+
+ /**
+ * Returns value of IPv6 Sub Object.
+ *
+ * @return byte array of ipv6 address
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6SubObject) {
+ IPv6SubObject other = (IPv6SubObject) obj;
+ return Arrays.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv6SubObject.
+ *
+ * @param c type of channel buffer
+ * @return object of IPv6SubObject
+ */
+ public static IPv6SubObject read20Bytes(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return IPv6SubObject.of(yTemp);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", LENGTH);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java
new file mode 100644
index 00000000..f10d5e31
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java
@@ -0,0 +1,179 @@
+/*
+ * 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.types;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IPv6 TE Router Id of Local Node. Reference :[RFC6119]/4.1.
+ */
+public class IPv6TERouterIdofLocalNodeTlv implements PcepValueType {
+ protected static final Logger log = LoggerFactory.getLogger(IPv6TERouterIdofLocalNodeTlv.class);
+
+ public static final short TYPE = 140; //TDB26
+ public static final short LENGTH = 20;
+ public static final byte VALUE_LENGTH = 18;
+
+ private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ public static final IPv6TERouterIdofLocalNodeTlv NONE = new IPv6TERouterIdofLocalNodeTlv(NONE_VAL);
+
+ private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+ public static final IPv6TERouterIdofLocalNodeTlv NO_MASK = new IPv6TERouterIdofLocalNodeTlv(NO_MASK_VAL);
+ public static final IPv6TERouterIdofLocalNodeTlv FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv6TERouterIdofLocalNodeTlv
+ */
+ public IPv6TERouterIdofLocalNodeTlv(byte[] rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv6TERouterIdofLocalNodeTlv object.
+ *
+ * @param raw IPv6 TE Router Id of Local Node
+ * @return object of IPv6TERouterIdofLocalNodeTlv
+ */
+ public static IPv6TERouterIdofLocalNodeTlv of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (NONE_VAL[i] != raw[i]) {
+ bFoundNONE = false;
+ }
+ }
+
+ if (bFoundNONE) {
+ return NONE;
+ }
+
+ //check NO_MASK_VAL
+ boolean bFoundNoMask = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+
+ return new IPv6TERouterIdofLocalNodeTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv6 TE Router Id of Local Node.
+ *
+ * @return byte array value of rawValue
+ */
+ public byte[] getBytes() {
+ return rawValue;
+ }
+
+ /**
+ * Returns value of IPv6 TE Router Id of Local Node.
+ *
+ * @return byte array value of rawValue
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6TERouterIdofLocalNodeTlv) {
+ IPv6TERouterIdofLocalNodeTlv other = (IPv6TERouterIdofLocalNodeTlv) obj;
+ return Arrays.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv6TERouterIdofLocalNodeTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv6TERouterIdofLocalNodeTlv
+ */
+ public static IPv6TERouterIdofLocalNodeTlv read20Bytes(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return IPv6TERouterIdofLocalNodeTlv.of(yTemp);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", LENGTH);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.java
new file mode 100644
index 00000000..bf1d475e
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.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.types;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IPv6 TE Router Id of Remote Node. Reference :[RFC6119]/4.1.
+ */
+public class IPv6TERouterIdofRemoteNodeTlv implements PcepValueType {
+ protected static final Logger log = LoggerFactory.getLogger(IPv6TERouterIdofRemoteNodeTlv.class);
+
+ public static final short TYPE = 1400; //TDB29
+ public static final short LENGTH = 20;
+ public static final byte VALUE_LENGTH = 18;
+
+ private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ public static final IPv6TERouterIdofRemoteNodeTlv NONE = new IPv6TERouterIdofRemoteNodeTlv(NONE_VAL);
+
+ private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
+ public static final IPv6TERouterIdofRemoteNodeTlv NO_MASK = new IPv6TERouterIdofRemoteNodeTlv(NO_MASK_VAL);
+ public static final IPv6TERouterIdofRemoteNodeTlv FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue IPv6TERouterIdofRemoteNodeTlv
+ */
+ public IPv6TERouterIdofRemoteNodeTlv(byte[] rawValue) {
+ log.debug("IPv6TERouterIdofRemoteNodeTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv6TERouterIdofRemoteNodeTlv object.
+ *
+ * @param raw IPv6 TE Router Id of RemoteNode
+ * @return object of IPv6TERouterIdofRemoteNodeTlv
+ */
+ public static IPv6TERouterIdofRemoteNodeTlv of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (NONE_VAL[i] != raw[i]) {
+ bFoundNONE = false;
+ }
+ }
+
+ if (bFoundNONE) {
+ return NONE;
+ }
+
+ //check NO_MASK_VAL
+ boolean bFoundNoMask = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+
+ return new IPv6TERouterIdofRemoteNodeTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv6 TE Router Id of Remote Node.
+ *
+ * @return byte array value of rawValue
+ */
+ public byte[] getBytes() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6TERouterIdofRemoteNodeTlv) {
+ IPv6TERouterIdofRemoteNodeTlv other = (IPv6TERouterIdofRemoteNodeTlv) obj;
+ return Arrays.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv6TERouterIdofRemoteNodeTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv6TERouterIdofRemoteNodeTlv
+ */
+ public static IPv6TERouterIdofRemoteNodeTlv read20Bytes(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return IPv6TERouterIdofRemoteNodeTlv.of(yTemp);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", LENGTH);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java
new file mode 100644
index 00000000..648dbb66
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java
@@ -0,0 +1,155 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides ISIS Area Identifier.
+ */
+public class ISISAreaIdentifierTlv implements PcepValueType {
+
+ /* Reference :[I-D.ietf-idr- ls-distribution]/3.3.1.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD24] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Area Identifier (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(ISISAreaIdentifierTlv.class);
+
+ public static final short TYPE = 107; //TODO:NEED TO HANDLE TBD24
+ private short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue ISIS-Area-Identifier
+ * @param hLength length
+ */
+ public ISISAreaIdentifierTlv(byte[] rawValue, short hLength) {
+ log.debug("ISISAreaIdentifierTlv");
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns newly created ISISAreaIdentifierTlv object.
+ *
+ * @param raw ISIS-Area-Identifier
+ * @param hLength length
+ * @return object of ISISAreaIdentifierTlv
+ */
+ public static ISISAreaIdentifierTlv of(final byte[] raw, short hLength) {
+ return new ISISAreaIdentifierTlv(raw, hLength);
+ }
+
+ /**
+ * Returns value of ISIS-Area-Identifier.
+ *
+ * @return byte array of rawValue
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof ISISAreaIdentifierTlv) {
+ ISISAreaIdentifierTlv other = (ISISAreaIdentifierTlv) obj;
+ return Objects.equals(hLength, other.hLength) && Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of ISISAreaIdentifierTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of ISISAreaIdentifierTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iISISAreaIdentifier = new byte[hLength];
+ c.readBytes(iISISAreaIdentifier, 0, hLength);
+ return new ISISAreaIdentifierTlv(iISISAreaIdentifier, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.java
new file mode 100644
index 00000000..5b1c2438
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * LabelSubObject: Provides a LabelSubObject.
+ */
+public class LabelSubObject implements PcepValueType {
+
+ /* Reference : RFC 3209
+ * LABEL Sub Object
+ *
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type | Length | Flags | C-Type |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Contents of Label Object |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(LabelSubObject.class);
+
+ public static final short TYPE = 0x03;
+ public static final short LENGTH = 8;
+ private final byte flags;
+ private final byte cType;
+ private final int contents;
+
+ /**
+ * constructor to initialize parameters for LabelSubObject.
+ *
+ * @param flags flags
+ * @param cType C-Type
+ * @param contents Contents of label object
+ */
+ public LabelSubObject(byte flags, byte cType, int contents) {
+ this.flags = flags;
+ this.cType = cType;
+ this.contents = contents;
+ }
+
+ /**
+ * Return an object of LabelSubObject.
+ *
+ * @param flags flags
+ * @param cType C-type
+ * @param contents contents of label objects
+ * @return object of LabelSubObject
+ */
+ public static LabelSubObject of(byte flags, byte cType, int contents) {
+ return new LabelSubObject(flags, cType, contents);
+ }
+
+ /**
+ * Returns Flags.
+ *
+ * @return flags
+ */
+ public byte getFlags() {
+ return flags;
+ }
+
+ /**
+ * Returns cType.
+ *
+ * @return cType
+ */
+ public byte getCtype() {
+ return cType;
+ }
+
+ /**
+ * Returns contents.
+ *
+ * @return contents
+ */
+ public int getContents() {
+ return contents;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(flags, cType, contents);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof LabelSubObject) {
+ LabelSubObject other = (LabelSubObject) obj;
+ return Objects.equals(this.flags, other.flags) && Objects.equals(this.cType, other.cType)
+ && Objects.equals(this.contents, other.contents);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeByte(flags);
+ c.writeByte(cType);
+ c.writeByte(contents);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of LabelSubObject.
+ *
+ * @param c type of channel buffer
+ * @return object of LabelSubObject
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ byte flags = c.readByte();
+ byte cType = c.readByte();
+ int contents = c.readInt();
+ return new LabelSubObject(flags, cType, contents);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("type", TYPE)
+ .add("Length", LENGTH)
+ .add("flags", flags)
+ .add("C-type", cType)
+ .add("contents", contents)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java
new file mode 100644
index 00000000..5fa0a4c6
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java
@@ -0,0 +1,155 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Local and remote Link Identifiers.
+ */
+public class LinkLocalRemoteIdentifiersTlv implements PcepValueType {
+
+ /* Reference :RFC5307
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=4 | Length=8 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Link Local Identifier |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Link Remote Identifier |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(LinkLocalRemoteIdentifiersTlv.class);
+
+ public static final short TYPE = 4;
+ public static final short LENGTH = 8;
+ private final int iLinkLocalIdentifier;
+ private final int iLinkRemoteIdentifier;
+
+ /**
+ * Constructor to initialize iLinkLocalIdentifier , iLinkRemoteIdentifier.
+ *
+ * @param iLinkLocalIdentifier Link Local identifier
+ * @param iLinkRemoteIdentifier Link Remote identifier
+ */
+ public LinkLocalRemoteIdentifiersTlv(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) {
+ this.iLinkLocalIdentifier = iLinkLocalIdentifier;
+ this.iLinkRemoteIdentifier = iLinkRemoteIdentifier;
+ }
+
+ /**
+ * Retruns an object of Link Local Remote Identifiers Tlv.
+ *
+ * @param iLinkLocalIdentifier Link Local identifier
+ * @param iLinkRemoteIdentifier Link Remote identifier
+ * @return object of LinkLocalRemoteIdentifiersTlv
+ */
+ public static LinkLocalRemoteIdentifiersTlv of(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) {
+ return new LinkLocalRemoteIdentifiersTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier);
+ }
+
+ /**
+ * Returns Link-Local-Identifier.
+ *
+ * @return iLinkLocalIdentifier Link Local Identifier
+ */
+ public int getLinkLocalIdentifier() {
+ return iLinkLocalIdentifier;
+ }
+
+ /**
+ * Returns Link-Remote-Identifier.
+ *
+ * @return iLinkRemoteIdentifier Link Remote Identifier.
+ */
+ public int getLinkRemoteIdentifier() {
+ return iLinkRemoteIdentifier;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(iLinkLocalIdentifier, iLinkRemoteIdentifier);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof LinkLocalRemoteIdentifiersTlv) {
+ LinkLocalRemoteIdentifiersTlv other = (LinkLocalRemoteIdentifiersTlv) obj;
+ return Objects.equals(iLinkLocalIdentifier, other.iLinkLocalIdentifier)
+ && Objects.equals(iLinkRemoteIdentifier, other.iLinkRemoteIdentifier);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(iLinkLocalIdentifier);
+ c.writeInt(iLinkRemoteIdentifier);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of LinkLocalRemoteIdentifiersTlv.
+ *
+ * @param c input channel buffer
+ * @return object of LinkLocalRemoteIdentifiersTlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ int iLinkLocalIdentifier = c.readInt();
+ int iLinkRemoteIdentifier = c.readInt();
+ return new LinkLocalRemoteIdentifiersTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("LinkLocalIdentifier", iLinkLocalIdentifier)
+ .add("LinkRemoteIdentifier", iLinkRemoteIdentifier)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java
new file mode 100644
index 00000000..aa0f11a7
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java
@@ -0,0 +1,155 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides the Link Name.
+ */
+public class LinkNameTlv implements PcepValueType {
+
+ /* Reference :[I-D.ietf-idr- ls-distribution] /3.3.2.7
+ * Link name tlv format.
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TDB43 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Link Name (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(LinkNameTlv.class);
+
+ public static final short TYPE = 1098; //TODO:NEED TO HANDLE TDB43
+ private short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue Link-Name
+ * @param hLength length
+ */
+ public LinkNameTlv(byte[] rawValue, short hLength) {
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns newly created LinkNameTlv object.
+ *
+ * @param raw Link-Name
+ * @param hLength length
+ * @return object of LinkNameTlv
+ */
+ public static LinkNameTlv of(final byte[] raw, short hLength) {
+ return new LinkNameTlv(raw, hLength);
+ }
+
+ /**
+ * Returns value of Link-Name.
+ *
+ * @return raw value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof LinkNameTlv) {
+ LinkNameTlv other = (LinkNameTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of LinkNameTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of LinkNameTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] linkName = new byte[hLength];
+ c.readBytes(linkName, 0, hLength);
+ return new LinkNameTlv(linkName, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java
new file mode 100644
index 00000000..a802d577
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java
@@ -0,0 +1,142 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provide Link Protection Type.
+ */
+
+public class LinkProtectionTypeTlv implements PcepValueType {
+
+ /* Reference :[RFC5307]/1.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TDB38] | Length=2 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ |Protection Cap | Reserved |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(LinkProtectionTypeTlv.class);
+
+ public static final short TYPE = 20; //TDB38
+ public static final short LENGTH = 2;
+ private final byte protectionCap;
+ private final byte reserved;
+
+ /**
+ * Constructor to initialize protectionCap.
+ *
+ * @param protectionCap Protection Cap
+ */
+ public LinkProtectionTypeTlv(byte protectionCap) {
+ this.protectionCap = protectionCap;
+ this.reserved = 0;
+ }
+
+ /**
+ * Constructor to initialize protectionCap, reserved.
+ *
+ * @param protectionCap Protection Cap
+ * @param reserved Reserved value
+ */
+ public LinkProtectionTypeTlv(byte protectionCap, byte reserved) {
+ this.protectionCap = protectionCap;
+ this.reserved = reserved;
+ }
+
+ /**
+ * Returns Protection Cap.
+ *
+ * @return protectionCap Protection Cap
+ */
+ public byte getProtectionCap() {
+ return protectionCap;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(protectionCap, reserved);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof LinkProtectionTypeTlv) {
+ LinkProtectionTypeTlv other = (LinkProtectionTypeTlv) obj;
+ return Objects.equals(protectionCap, other.protectionCap) && Objects.equals(reserved, other.reserved);
+ }
+
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeByte(protectionCap);
+ c.writeByte(reserved);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of LinkProtectionTypeTlv.
+ *
+ * @param c input channel buffer
+ * @return object of LinkProtectionTypeTlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ byte protectionCap = c.readByte();
+ byte reserved = c.readByte();
+ return new LinkProtectionTypeTlv(protectionCap, reserved);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("ProtectionCap", protectionCap)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlv.java
new file mode 100644
index 00000000..b31dac2c
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlv.java
@@ -0,0 +1,246 @@
+/*
+ * 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.types;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Local TE Node Descriptors TLV which contains Node Descriptor Sub-TLVs.
+ */
+public class LocalTENodeDescriptorsTlv implements PcepValueType {
+
+ /* REFERENCE :draft-ietf-idr-ls-distribution-10
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD8] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Node Descriptor Sub-TLVs (variable) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ Note: Length is including header here. Refer Routing Universe TLV.
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(LocalTENodeDescriptorsTlv.class);
+
+ public static final short TYPE = 1637; //TODD:change this TBD8
+ public short hLength;
+
+ public static final int TLV_HEADER_LENGTH = 4;
+ // Node Descriptor Sub-TLVs (variable)
+ private LinkedList<PcepValueType> llNodeDescriptorSubTLVs;
+
+ /**
+ * Constructor to initialize llNodeDescriptorSubTLVs.
+ *
+ * @param llNodeDescriptorSubTLVs LinkedList of PcepValueType
+ */
+ public LocalTENodeDescriptorsTlv(LinkedList<PcepValueType> llNodeDescriptorSubTLVs) {
+ this.llNodeDescriptorSubTLVs = llNodeDescriptorSubTLVs;
+ }
+
+ /**
+ * Returns a new object of LocalTENodeDescriptorsTLV.
+ *
+ * @param llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLVs
+ * @return object of LocalTENodeDescriptorsTLV
+ */
+ public static LocalTENodeDescriptorsTlv of(final LinkedList<PcepValueType> llNodeDescriptorSubTLVs) {
+ return new LocalTENodeDescriptorsTlv(llNodeDescriptorSubTLVs);
+ }
+
+ /**
+ * Returns Linked List of tlvs.
+ *
+ * @return llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLV
+ */
+ public LinkedList<PcepValueType> getllNodeDescriptorSubTLVs() {
+ return llNodeDescriptorSubTLVs;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(llNodeDescriptorSubTLVs.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ /*
+ * Here we have a list of Tlv so to compare each sub tlv between the object
+ * we have to take a list iterator so one by one we can get each sub tlv object
+ * and can compare them.
+ * it may be possible that the size of 2 lists is not equal so we have to first check
+ * the size, if both are same then we should check for the subtlv objects otherwise
+ * we should return false.
+ */
+ if (obj instanceof LocalTENodeDescriptorsTlv) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ LocalTENodeDescriptorsTlv other = (LocalTENodeDescriptorsTlv) obj;
+ Iterator<PcepValueType> objListIterator = ((LocalTENodeDescriptorsTlv) obj).llNodeDescriptorSubTLVs
+ .iterator();
+ countObjSubTlv = ((LocalTENodeDescriptorsTlv) obj).llNodeDescriptorSubTLVs.size();
+ countOtherSubTlv = other.llNodeDescriptorSubTLVs.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ PcepValueType subTlv = objListIterator.next();
+ isCommonSubTlv = Objects.equals(llNodeDescriptorSubTLVs.contains(subTlv),
+ other.llNodeDescriptorSubTLVs.contains(subTlv));
+ }
+ return isCommonSubTlv;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int tlvStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(0);
+
+ ListIterator<PcepValueType> listIterator = llNodeDescriptorSubTLVs.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+ if (tlv == null) {
+ log.debug("TLV is null from subTlv list");
+ continue;
+ }
+ tlv.write(c);
+
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ c.writeByte((byte) 0);
+ }
+ }
+ }
+ hLength = (short) (c.writerIndex() - tlvStartIndex);
+ c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of AutonomousSystemTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length of subtlvs.
+ * @return object of AutonomousSystemTlv
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llNodeDescriptorSubTLVs = new LinkedList<>();
+
+ ChannelBuffer tempCb = c.readBytes(hLength);
+
+ while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
+
+ PcepValueType tlv;
+ short hType = tempCb.readShort();
+ int iValue = 0;
+ short length = tempCb.readShort();
+
+ switch (hType) {
+
+ case AutonomousSystemTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new AutonomousSystemTlv(iValue);
+ break;
+ case BGPLSidentifierTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new BGPLSidentifierTlv(iValue);
+ break;
+ case OSPFareaIDsubTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new OSPFareaIDsubTlv(iValue);
+ break;
+ case RouterIDSubTlv.TYPE:
+ tlv = RouterIDSubTlv.read(tempCb, length);
+ break;
+
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type :" + hType);
+ }
+
+ // Check for the padding
+ int pad = length % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= tempCb.readableBytes()) {
+ tempCb.skipBytes(pad);
+ }
+ }
+
+ llNodeDescriptorSubTLVs.add(tlv);
+ }
+
+ if (0 < tempCb.readableBytes()) {
+ throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
+ }
+ return new LocalTENodeDescriptorsTlv(llNodeDescriptorSubTLVs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", hLength)
+ .add("NodeDescriptorSubTLVs", llNodeDescriptorSubTLVs)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java
new file mode 100644
index 00000000..fc0f8771
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java
@@ -0,0 +1,200 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides MPLS Protocol Mask.
+ */
+public class MPLSProtocolMaskTlv implements PcepValueType {
+
+ /* Reference :[I-D.ietf-idr-ls-distribution]/3.3.2.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TDB39 | Length =1 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ |L|R| Reserved |
+ +-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(MPLSProtocolMaskTlv.class);
+
+ public static final short TYPE = 1094; //TDB39
+ public static final short LENGTH = 1;
+ public static final byte LFLAG_SET = (byte) 0x80;
+ public static final byte RFLAG_SET = 0x40;
+
+ private final byte rawValue;
+ private final boolean bLFlag;
+ private final boolean bRFlag;
+ private final boolean isRawValueSet;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue MPLS Protocol Mask Flag Bits
+ */
+ public MPLSProtocolMaskTlv(byte rawValue) {
+ this.rawValue = rawValue;
+ this.isRawValueSet = true;
+ this.bLFlag = (rawValue & LFLAG_SET) == LFLAG_SET;
+ this.bRFlag = (rawValue & RFLAG_SET) == RFLAG_SET;
+ }
+
+ /**
+ * constructor to initialize different Flags.
+ *
+ * @param bLFlag L-flag
+ * @param bRFlag R-flag
+ */
+ public MPLSProtocolMaskTlv(boolean bLFlag, boolean bRFlag) {
+ this.bLFlag = bLFlag;
+ this.bRFlag = bRFlag;
+ this.rawValue = 0;
+ isRawValueSet = false;
+ }
+
+ /**
+ * Returns newly created MPLSProtocolMaskTlv object.
+ *
+ * @param raw MPLS Protocol Mask Tlv
+ * @return new object of MPLS Protocol Mask Tlv
+ */
+ public static MPLSProtocolMaskTlv of(final byte raw) {
+ return new MPLSProtocolMaskTlv(raw);
+ }
+
+ /**
+ * Returns L-flag.
+ *
+ * @return bLFlag L-flag
+ */
+ public boolean getbLFlag() {
+ return bLFlag;
+ }
+
+ /**
+ * Returns R-flag.
+ *
+ * @return bRFlag R-flag
+ */
+ public boolean getbRFlag() {
+ return bRFlag;
+ }
+
+ /**
+ * Returns raw value.
+ *
+ * @return rawValue raw value
+ */
+ public byte getByte() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ if (isRawValueSet) {
+ return Objects.hash(rawValue);
+ } else {
+ return Objects.hash(bLFlag, bRFlag);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MPLSProtocolMaskTlv) {
+ MPLSProtocolMaskTlv other = (MPLSProtocolMaskTlv) obj;
+ if (isRawValueSet) {
+ return Objects.equals(this.rawValue, other.rawValue);
+ } else {
+ return Objects.equals(this.bLFlag, other.bLFlag) && Objects.equals(this.bRFlag, other.bRFlag);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ if (isRawValueSet) {
+ c.writeByte(rawValue);
+ } else {
+ byte temp = 0;
+ if (bLFlag) {
+ temp = (byte) (temp | LFLAG_SET);
+ }
+ if (bRFlag) {
+ temp = (byte) (temp | RFLAG_SET);
+ }
+ c.writeByte(temp);
+ }
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of MPLS Protocol Mask Tlv.
+ *
+ * @param c input channel buffer
+ * @return object of MPLS Protocol Mask Tlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ byte temp = c.readByte();
+ boolean bLFlag;
+ boolean bRFlag;
+
+ bLFlag = (temp & LFLAG_SET) == LFLAG_SET;
+ bRFlag = (temp & RFLAG_SET) == RFLAG_SET;
+
+ return new MPLSProtocolMaskTlv(bLFlag, bRFlag);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java
new file mode 100644
index 00000000..db1acf09
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provide the Maximum Link Bandwidth.
+ */
+public class MaximumLinkBandwidthTlv implements PcepValueType {
+
+ /* Reference :[RFC5305]/3.3.
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TDB34] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Maximum Link Bandwidth |
+ +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(MaximumLinkBandwidthTlv.class);
+
+ public static final short TYPE = 9; //TDB34
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue Maximum-Link-Bandwidth
+ */
+
+ public MaximumLinkBandwidthTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created MaximumLinkBandwidthTlv object.
+ *
+ * @param raw value of Maximum-Link-Bandwidth
+ * @return object of MaximumLinkBandwidthTlv
+ */
+ public static MaximumLinkBandwidthTlv of(final int raw) {
+ return new MaximumLinkBandwidthTlv(raw);
+ }
+
+ /**
+ * Returns value of Maximum Link Bandwidth.
+ *
+ * @return rawValue Maximum Link Bandwidth
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MaximumLinkBandwidthTlv) {
+ MaximumLinkBandwidthTlv other = (MaximumLinkBandwidthTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of MaximumLinkBandwidthTlv.
+ *
+ * @param c input channel buffer
+ * @return object of MaximumLinkBandwidthTlv
+ */
+ public static MaximumLinkBandwidthTlv read(ChannelBuffer c) {
+ return MaximumLinkBandwidthTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java
new file mode 100644
index 00000000..01d08cae
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provide the Maximum Reservable Link Bandwidth.
+ */
+public class MaximumReservableLinkBandwidthTlv implements PcepValueType {
+
+ /* Reference :[RFC5305]/3.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TDB35] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Maximum Reservable Link Bandwidth |
+ +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(MaximumReservableLinkBandwidthTlv.class);
+
+ public static final short TYPE = 10; // TDB35
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue MaximumReservableLinkBandwidth
+ */
+ public MaximumReservableLinkBandwidthTlv(int rawValue) {
+ log.debug("MaximumReservableLinkBandwidthTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created MaximumReservableLinkBandwidth object.
+ *
+ * @param raw MaximumReservableLinkBandwidth
+ * @return object of MaximumReservableLinkBandwidthTlv
+ */
+ public static MaximumReservableLinkBandwidthTlv of(final int raw) {
+ return new MaximumReservableLinkBandwidthTlv(raw);
+ }
+
+ /**
+ * Returns value of Maximum Reservable Link Bandwidth.
+ * @return rawValue Maximum Reservable Link Bandwidth
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MaximumReservableLinkBandwidthTlv) {
+ MaximumReservableLinkBandwidthTlv other = (MaximumReservableLinkBandwidthTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of MaximumReservableLinkBandwidthTlv.
+ *
+ * @param c input channel buffer
+ * @return object of MaximumReservableLinkBandwidthTlv
+ */
+ public static MaximumReservableLinkBandwidthTlv read(ChannelBuffer c) {
+ return MaximumReservableLinkBandwidthTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java
new file mode 100644
index 00000000..6f193384
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * NexthopIPv6addressTlv provides Ipv4 address of next hop.
+ */
+public class NexthopIPv4addressTlv implements PcepValueType {
+
+ /*
+ Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TBD | Length = 8 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | nexthop IPv4 address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NEXTHOP-IPV4-ADDRESS TLV
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(NexthopIPv4addressTlv.class);
+
+ public static final short TYPE = 2; //to be defined
+ //Length is header + value
+ public static final short LENGTH = 8;
+ public static final short VALUE_LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize next hop IPv4 address.
+ *
+ * @param rawValue next hop IPv4 address
+ */
+ public NexthopIPv4addressTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Return next hop IPv4 address tlv.
+ *
+ * @param raw of next hop IPv4 address
+ * @return object of NexthopIPv4addressTlv
+ */
+ public static NexthopIPv4addressTlv of(final int raw) {
+ return new NexthopIPv4addressTlv(raw);
+ }
+
+ /**
+ * Returns next hop IPv4 address.
+ *
+ * @return next hop IPv4 address
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof NexthopIPv4addressTlv) {
+ NexthopIPv4addressTlv other = (NexthopIPv4addressTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of NexthopIPv4addressTlv.
+ *
+ * @param c type of channel buffer
+ * @return object of NexthopIPv4addressTlv
+ */
+ public static NexthopIPv4addressTlv read(ChannelBuffer c) {
+ return NexthopIPv4addressTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Ipv4Address ", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java
new file mode 100644
index 00000000..45bf7ac5
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java
@@ -0,0 +1,190 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * NexthopIPv6addressTlv provides Ipv6 address of next hop.
+ */
+public class NexthopIPv6addressTlv implements PcepValueType {
+
+ /*
+ Reference: draft-zhao-pce-pcep-extension-for-pce-controller-01.
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TBD | Length = 20 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // nexthop IPv6 address (16 bytes) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NEXTHOP-IPV6-ADDRESS TLV:
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(NexthopIPv6addressTlv.class);
+
+ public static final short TYPE = 100; //to be defined
+ //Length is header + value
+ public static final short LENGTH = 20;
+ public static final short VALUE_LENGTH = 16;
+
+ private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ public static final NexthopIPv6addressTlv NONE = new NexthopIPv6addressTlv(NONE_VAL);
+
+ private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+ public static final NexthopIPv6addressTlv NO_MASK = new NexthopIPv6addressTlv(NO_MASK_VAL);
+ public static final NexthopIPv6addressTlv FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize IP address for next hop IPv6 address tlv.
+ *
+ * @param rawValue value of Next hop ipAddress
+ */
+ public NexthopIPv6addressTlv(byte[] rawValue) {
+ log.debug("NexthopIPv6addressTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Creates next hop IPv6 address tlv.
+ *
+ * @param raw value of Next hop ipAddress
+ * @return object of NexthopIPv6addressTlv
+ */
+ //logic to be checked
+ public static NexthopIPv6addressTlv of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 5; i < 20; ++i) {
+ if (NONE_VAL[i] != raw[i]) {
+ bFoundNONE = false;
+ }
+ }
+
+ if (bFoundNONE) {
+ return NONE;
+ }
+
+ //check NO_MASK_VAL
+ boolean bFoundNoMask = true;
+ //value starts from 3rd byte.
+ for (int i = 5; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+ return new NexthopIPv6addressTlv(raw);
+ }
+
+ /**
+ * Returns next hop IPv6 address.
+ *
+ * @return next hop IPv6 address
+ */
+ public byte[] getBytes() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof NexthopIPv6addressTlv) {
+ NexthopIPv6addressTlv other = (NexthopIPv6addressTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of NexthopIPv6addressTlv.
+ *
+ * @param c type of channel buffer
+ * @return object of NexthopIPv6addressTlv
+ */
+ public static NexthopIPv6addressTlv read(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return NexthopIPv6addressTlv.of(yTemp);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", LENGTH);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("IpAddress", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java
new file mode 100644
index 00000000..fb4ceeff
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java
@@ -0,0 +1,163 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * NexthopUnnumberedIPv4IDTlv provides the next node's ID and Interface ID.
+ */
+public class NexthopUnnumberedIPv4IDTlv implements PcepValueType {
+
+ /*
+ Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01.
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TBD | Length = 12 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Node-ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Interface ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NEXTHOP-UNNUMBERED-IPV4-ID TLV
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(NexthopUnnumberedIPv4IDTlv.class);
+
+ public static final short TYPE = 1; //to be defined
+ //Length is header + value
+ public static final short LENGTH = 12;
+
+ private final int nodeID;
+ private final int interfaceID;
+
+ /**
+ * constructor to initialize nodeID and interfaceID.
+ *
+ * @param nodeID node ID
+ * @param interfaceID interface ID
+ */
+ public NexthopUnnumberedIPv4IDTlv(int nodeID, int interfaceID) {
+ this.nodeID = nodeID;
+ this.interfaceID = interfaceID;
+ }
+
+ /**
+ * Returns new object of NexthopUnnumberedIPv4IDTlv.
+ *
+ * @param nodeID node ID
+ * @param interfaceID interface ID
+ * @return NexthopUnnumberedIPv4IDTlv
+ */
+ public static NexthopUnnumberedIPv4IDTlv of(int nodeID, int interfaceID) {
+ return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID);
+ }
+
+ /**
+ * Returns Node Id.
+ *
+ * @return node ID
+ */
+ public int getNodeID() {
+ return nodeID;
+ }
+
+ /**
+ * Returns Interface Id.
+ *
+ * @return interface ID
+ */
+ public int getInterfaceID() {
+ return interfaceID;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nodeID, interfaceID);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof NexthopUnnumberedIPv4IDTlv) {
+ NexthopUnnumberedIPv4IDTlv other = (NexthopUnnumberedIPv4IDTlv) obj;
+ return Objects.equals(this.nodeID, other.nodeID) && Objects.equals(this.interfaceID, other.interfaceID);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+
+ c.writeInt(nodeID);
+ c.writeInt(interfaceID);
+
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of NexthopUnnumberedIPv4IDTlv.
+ *
+ * @param cb type of channel buffer
+ * @return object of NexthopUnnumberedIPv4IDTlv
+ */
+ public static NexthopUnnumberedIPv4IDTlv read(ChannelBuffer cb) {
+ int nodeID = cb.readInt();
+ int interfaceID = cb.readInt();
+ return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("NodeId", nodeID)
+ .add("InterfaceId", interfaceID)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java
new file mode 100644
index 00000000..019daa14
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.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.types;
+
+import java.util.Objects;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provide node Flags bits.
+ */
+public class NodeFlagBitsTlv implements PcepValueType {
+
+ /* Reference :[I-D.ietf-idr- ls-distribution] /3.3.1.1
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD21] | Length=1 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ |O|T|E|B| Reserved|
+ +-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(NodeFlagBitsTlv.class);
+
+ public static final short TYPE = 14;
+ public static final short LENGTH = 1;
+ public static final int SET = 1;
+ public static final byte OFLAG_SET = (byte) 0x80;
+ public static final byte TFLAG_SET = 0x40;
+ public static final byte EFLAG_SET = 0x20;
+ public static final byte BFLAG_SET = 0x10;
+
+ private final byte rawValue;
+ private final boolean bOFlag;
+ private final boolean bTFlag;
+ private final boolean bEFlag;
+ private final boolean bBFlag;
+ private final boolean isRawValueSet;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue of Node Flag Bits TLV
+ */
+ public NodeFlagBitsTlv(byte rawValue) {
+ this.rawValue = rawValue;
+ isRawValueSet = true;
+ this.bOFlag = (rawValue & OFLAG_SET) == OFLAG_SET;
+ this.bTFlag = (rawValue & TFLAG_SET) == TFLAG_SET;
+ this.bEFlag = (rawValue & EFLAG_SET) == EFLAG_SET;
+ this.bBFlag = (rawValue & BFLAG_SET) == BFLAG_SET;
+ }
+
+ /**
+ * constructor to initialize different Flags.
+ *
+ * @param bOFlag O-flag
+ * @param bTFlag T-flag
+ * @param bEFlag E-flag
+ * @param bBFlag B-flag
+ */
+ public NodeFlagBitsTlv(boolean bOFlag, boolean bTFlag, boolean bEFlag, boolean bBFlag) {
+ this.bOFlag = bOFlag;
+ this.bTFlag = bTFlag;
+ this.bEFlag = bEFlag;
+ this.bBFlag = bBFlag;
+ this.rawValue = 0;
+ this.isRawValueSet = false;
+ }
+
+ /**
+ * Returns newly created NodeFlagBitsTlv object.
+ *
+ * @param raw of Node Flag Bits TLV
+ * @return new object of NodeFlagBitsTlv
+ */
+ public static NodeFlagBitsTlv of(final byte raw) {
+ return new NodeFlagBitsTlv(raw);
+ }
+
+ /**
+ * Returns raw value of NodeFlagBitsTlv.
+ *
+ * @return rawValue raw value
+ */
+ public byte getbyte() {
+ return rawValue;
+ }
+
+ /**
+ * Returns O-flag.
+ *
+ * @return bOFlag O-flag
+ */
+ public boolean getOFlag() {
+ return bOFlag;
+ }
+
+ /**
+ * Returns T-flag.
+ *
+ * @return bTFlag T-flag
+ */
+ public boolean getTFlag() {
+ return bTFlag;
+ }
+
+ /**
+ * Returns E-flag.
+ *
+ * @return bEFlag E-flag
+ */
+ public boolean getEFlag() {
+ return bEFlag;
+ }
+
+ /**
+ * Returns B-flag.
+ *
+ * @return bBFlag B-flag
+ */
+ public boolean getBFlag() {
+ return bBFlag;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ if (isRawValueSet) {
+ return Objects.hash(rawValue);
+ } else {
+ return Objects.hash(bOFlag, bTFlag, bEFlag, bBFlag);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof NodeFlagBitsTlv) {
+ NodeFlagBitsTlv other = (NodeFlagBitsTlv) obj;
+ if (isRawValueSet) {
+ return Objects.equals(this.rawValue, other.rawValue);
+ } else {
+ return Objects.equals(this.bOFlag, other.bOFlag) && Objects.equals(this.bTFlag, other.bTFlag)
+ && Objects.equals(this.bEFlag, other.bEFlag) && Objects.equals(this.bBFlag, other.bBFlag);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ if (isRawValueSet) {
+ c.writeByte(rawValue);
+ } else {
+ byte temp = 0;
+ if (bOFlag) {
+ temp = (byte) (temp | OFLAG_SET);
+ }
+ if (bTFlag) {
+ temp = (byte) (temp | TFLAG_SET);
+ }
+ if (bEFlag) {
+ temp = (byte) (temp | EFLAG_SET);
+ }
+ if (bBFlag) {
+ temp = (byte) (temp | BFLAG_SET);
+ }
+ c.writeByte(temp);
+ }
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of NodeFlagBitsTlv.
+ *
+ * @param c input channel buffer
+ * @return object of NodeFlagBitsTlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+
+ return NodeFlagBitsTlv.of(c.readByte());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("OFlag", (bOFlag) ? 1 : 0)
+ .add("TFlag", (bTFlag) ? 1 : 0)
+ .add("EFlag", (bEFlag) ? 1 : 0)
+ .add("BFlag", (bBFlag) ? 1 : 0)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.java
new file mode 100644
index 00000000..e535a358
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.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.types;
+
+import java.util.Objects;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provide the name for the node.
+ */
+public class NodeNameTlv implements PcepValueType {
+
+ /* reference :[I-D.ietf-idr-ls-distribution]/3.3.1.3
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD23] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Node Name (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(NodeNameTlv.class);
+
+ public static final short TYPE = 1007; //TODO:check and change TBD23
+ public final short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue of Node Name
+ * @param hLength length
+ */
+ public NodeNameTlv(byte[] rawValue, short hLength) {
+ log.debug("NodeNameTlv");
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns newly created NodeNameTlv object.
+ *
+ * @param raw of NodeName
+ * @param hLength length
+ * @return new object of Node Name Tlv
+ */
+ public static NodeNameTlv of(final byte[] raw, short hLength) {
+ return new NodeNameTlv(raw, hLength);
+ }
+
+ /**
+ * Returns RawValue for NodeName.
+ *
+ * @return rawValue raw value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof NodeNameTlv) {
+ NodeNameTlv other = (NodeNameTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of NodeNameTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of Node Name TLV
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iNodeName = new byte[hLength];
+ c.readBytes(iNodeName, 0, hLength);
+ return new NodeNameTlv(iNodeName, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java
new file mode 100644
index 00000000..2233ab0d
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java
@@ -0,0 +1,135 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides area ID for OSPF area.
+ */
+public class OSPFareaIDsubTlv implements PcepValueType {
+
+ /* Reference :draft-ietf-idr-ls-distribution-10.
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD12] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value (32 Bit AS Number) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(OSPFareaIDsubTlv.class);
+
+ public static final short TYPE = 600; //TODD:change this TBD12
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue area ID for OSPF area.
+ */
+ public OSPFareaIDsubTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created OSPFareaIDsubTlv object.
+ *
+ * @param raw opaque value of AreaID
+ * @return new object of OSPF area ID sub TLV
+ */
+ public static OSPFareaIDsubTlv of(final int raw) {
+ return new OSPFareaIDsubTlv(raw);
+ }
+
+ /**
+ * Returns RawValue opaque value of AreaID.
+ *
+ * @return rawValue Area ID
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OSPFareaIDsubTlv) {
+ OSPFareaIDsubTlv other = (OSPFareaIDsubTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of OSPFAreaIdSubTlv.
+ *
+ * @param c input channel buffer
+ * @return object of OSPFAreaIdSubTlv
+ */
+ public static OSPFareaIDsubTlv read(ChannelBuffer c) {
+ return OSPFareaIDsubTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java
new file mode 100644
index 00000000..1af332eb
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java
@@ -0,0 +1,155 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides Opaque Link Attribute.
+ */
+public class OpaqueLinkAttributeTlv implements PcepValueType {
+
+ /*
+ * TLV format.
+ * Reference :[I-D.ietf-idr-attributesls-distribution] /3.3.2.6
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TBD42 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Opaque link attributes (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(OpaqueLinkAttributeTlv.class);
+
+ public static final short TYPE = 1097; //TODO:NEED TO HANDLE TDB42
+ private final short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue of Opaque Link Attribute
+ * @param hLength length
+ */
+ public OpaqueLinkAttributeTlv(byte[] rawValue, short hLength) {
+ log.debug("OpaqueLinkAttributeTlv");
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns newly created OpaqueLinkAttributeTlv object.
+ *
+ * @param raw of Opaque Link Attribute
+ * @param hLength length
+ * @return new object of OpaqueLinkAttributeTlv
+ */
+ public static OpaqueLinkAttributeTlv of(final byte[] raw, short hLength) {
+ return new OpaqueLinkAttributeTlv(raw, hLength);
+ }
+
+ /**
+ * Returns raw value of Opaque Link Attribute Tlv.
+ * @return rawValue raw value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OpaqueLinkAttributeTlv) {
+ OpaqueLinkAttributeTlv other = (OpaqueLinkAttributeTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of OpaqueLinkAttributeTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of Opaque Link Attribute Tlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iOpaqueValue = new byte[hLength];
+ c.readBytes(iOpaqueValue, 0, hLength);
+ return new OpaqueLinkAttributeTlv(iOpaqueValue, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.java
new file mode 100644
index 00000000..26e8c8bf
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.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.types;
+
+import java.util.Objects;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides Opaque node attributes.
+ */
+public class OpaqueNodeAttributeTlv implements PcepValueType {
+ /*
+ * Reference [I-D.ietf-idr-Properties ls-distribution] /3.3.1.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD22] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Opaque node attributes (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(OpaqueNodeAttributeTlv.class);
+
+ public static final short TYPE = 1001;
+ private final short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue Opaque Node Attribute
+ * @param hLength length
+ */
+ public OpaqueNodeAttributeTlv(byte[] rawValue, short hLength) {
+
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns newly created OpaqueNodeAttributeTlv object.
+ *
+ * @param raw value of Opaque Node Attribute
+ * @param hLength length
+ * @return new object of Opaque Node Attribute Tlv
+ */
+ public static OpaqueNodeAttributeTlv of(final byte[] raw, short hLength) {
+ return new OpaqueNodeAttributeTlv(raw, hLength);
+ }
+
+ /**
+ * Returns raw value of Opaque Node Attribute Tlv.
+ *
+ * @return rawValue of Opaque Node Attribute
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OpaqueNodeAttributeTlv) {
+ OpaqueNodeAttributeTlv other = (OpaqueNodeAttributeTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of Opaque Node Attribute Tlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of OpaqueNodeAttributeTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iOpaqueValue = new byte[hLength];
+ c.readBytes(iOpaqueValue, 0, hLength);
+ return new OpaqueNodeAttributeTlv(iOpaqueValue, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java
new file mode 100644
index 00000000..86ad042a
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java
@@ -0,0 +1,159 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Path Key SubObject: When a PCC needs to expand a path-key in order to expand a CPS, it
+ * issues a Path Computation Request (PCReq) to the PCE identified in
+ * the PKS in the RSVP-TE ERO that it is processing. The PCC supplies
+ * the PKS to be expanded in a PATH-KEY SubObject in the PCReq message.
+ */
+public class PathKeySubObject implements PcepValueType {
+
+ /*
+ 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) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PathKeySubObject.class);
+
+ public static final byte TYPE = 0x40;
+ public static final byte LENGTH = 8;
+ private final short pathKey;
+ private final int pceID;
+
+ /**
+ * Constructor for Path Key sub Object which initializes pathKey and pceId.
+ *
+ * @param pathKey path key provided by PCC
+ * @param pceID ID for the PCE
+ */
+ public PathKeySubObject(short pathKey, int pceID) {
+ this.pathKey = pathKey;
+ this.pceID = pceID;
+ }
+
+ /**
+ * Creates Path Key sub Object which initializes pathKey and pceId.
+ *
+ * @param pathKey path key provided by PCC
+ * @param pceID PCE id
+ * @return new object of type path key sub object
+ */
+ public static PathKeySubObject of(short pathKey, int pceID) {
+ return new PathKeySubObject(pathKey, pceID);
+ }
+
+ /**
+ * Returns Path Key.
+ *
+ * @return pathKey
+ */
+ public short getPathKey() {
+ return pathKey;
+ }
+
+ /**
+ * Returns pceID.
+ *
+ * @return pceID
+ */
+ public int getPceId() {
+ return pceID;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pathKey, pceID);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PathKeySubObject) {
+ PathKeySubObject other = (PathKeySubObject) obj;
+ return Objects.equals(this.pathKey, other.pathKey) && Objects.equals(this.pceID, other.pceID);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+
+ c.writeShort(pathKey);
+ c.writeInt(pceID);
+
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns new path key sub objects.
+ *
+ * @param c of type channel buffer
+ * @return object of type path key sub object
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ Short pathKey = c.readShort();
+ int pceID = c.readInt();
+ return new PathKeySubObject(pathKey, pceID);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("PathKey", pathKey)
+ .add("PceID", pceID)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java
new file mode 100644
index 00000000..3e8f9676
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java
@@ -0,0 +1,164 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PcepSetup type tlv.
+ */
+public class PathSetupTypeTlv implements PcepValueType {
+
+ /*
+ Reference : draft-sivabalan-pce-lsp-setup-type-02.
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Reserved | PST |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Figure 1: PATH-SETUP-TYPE TLV
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PathSetupTypeTlv.class);
+
+ public static final short TYPE = 0; //TODO : need to reassign the value as per RFC
+ public static final short LENGTH = 4;
+
+ private final byte pst;
+ private final int rawValue;
+ private final boolean isRawValueSet;
+
+ /**
+ * Constructor to initialize parameters for path setup type tlv.
+ *
+ * @param rawValue parameter for path setup type tlv
+ */
+ public PathSetupTypeTlv(final int rawValue) {
+ this.rawValue = rawValue;
+ this.isRawValueSet = true;
+ this.pst = (byte) rawValue;
+ }
+
+ /**
+ * Constructor to initialize pst.
+ *
+ * @param pst PST
+ */
+ public PathSetupTypeTlv(byte pst) {
+ this.pst = pst;
+ this.rawValue = 0;
+ this.isRawValueSet = false;
+ }
+
+ /**
+ * Returns Object of path setup type tlv.
+ *
+ * @param raw parameter for path setup type tlv
+ * @return object of PathSetupTypeTlv
+ */
+ public static PathSetupTypeTlv of(final int raw) {
+ return new PathSetupTypeTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns parameters for path setup type tlv.
+ *
+ * @return parameters for path setup type tlv
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ /**
+ * Returns the pst value.
+ *
+ * @return pst value
+ */
+ public byte getPst() {
+ return pst;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pst);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PathSetupTypeTlv) {
+ PathSetupTypeTlv other = (PathSetupTypeTlv) obj;
+ return Objects.equals(this.pst, other.pst);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(pst);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Returns the object of type PathSetupTypeTlv.
+ *
+ * @param c is type Channel buffer
+ * @return object of PathSetupTypeTlv
+ */
+ public static PathSetupTypeTlv read(ChannelBuffer c) {
+ return PathSetupTypeTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("PST", pst)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
new file mode 100644
index 00000000..b8ae1e87
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
@@ -0,0 +1,194 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PceccCapabilityTlv.
+ */
+public class PceccCapabilityTlv implements PcepValueType {
+
+ /* PCECC CAPABILITY TLV
+ * Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01, section-7.1.1
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=32 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Flags |G|L|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PceccCapabilityTlv.class);
+
+ public static final short TYPE = 32;
+ public static final short LENGTH = 4;
+ public static final int SET = 1;
+ public static final byte LFLAG_CHECK = 0x01;
+ public static final byte GFLAG_CHECK = 0x02;
+
+ private final boolean bGFlag;
+ private final boolean bLFlag;
+
+ private final int rawValue;
+ private final boolean isRawValueSet;
+
+ /**
+ * Constructor to initialize raw Value.
+ *
+ * @param rawValue raw value
+ */
+ public PceccCapabilityTlv(final int rawValue) {
+ this.rawValue = rawValue;
+ this.isRawValueSet = true;
+
+ bLFlag = (rawValue & LFLAG_CHECK) == LFLAG_CHECK;
+ bGFlag = (rawValue & GFLAG_CHECK) == GFLAG_CHECK;
+ }
+
+ /**
+ * Constructor to initialize G-flag L-flag.
+ * @param bGFlag G-flag
+ * @param bLFlag L-flag
+ */
+ public PceccCapabilityTlv(boolean bGFlag, boolean bLFlag) {
+ this.bGFlag = bGFlag;
+ this.bLFlag = bLFlag;
+ this.rawValue = 0;
+ this.isRawValueSet = false;
+ }
+
+ /**
+ * Returns newly created PceccCapabilityTlv object.
+ *
+ * @param raw value
+ * @return object of Pcecc Capability Tlv
+ */
+ public static PceccCapabilityTlv of(final int raw) {
+ return new PceccCapabilityTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns G-flag.
+ * @return bGFlag G-flag
+ */
+ public boolean getGFlag() {
+ return bGFlag;
+ }
+
+ /**
+ * Returns L-flag.
+ * @return bLFlag L-flag
+ */
+ public boolean getLFlag() {
+ return bLFlag;
+ }
+
+ /**
+ * Returns the raw value.
+ * @return rawValue Flags
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ if (isRawValueSet) {
+ return Objects.hash(rawValue);
+ } else {
+ return Objects.hash(bLFlag, bGFlag);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PceccCapabilityTlv) {
+ PceccCapabilityTlv other = (PceccCapabilityTlv) obj;
+ if (isRawValueSet) {
+ return Objects.equals(this.rawValue, other.rawValue);
+ } else {
+ return Objects.equals(this.bGFlag, other.bGFlag) && Objects.equals(this.bLFlag, other.bLFlag);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ int temp = 0;
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ if (isRawValueSet) {
+ c.writeInt(rawValue);
+ } else {
+ if (bGFlag) {
+ temp = temp | GFLAG_CHECK;
+ }
+ if (bLFlag) {
+ temp = temp | LFLAG_CHECK;
+ }
+ c.writeInt(temp);
+ }
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of PceccCapabilityTlv.
+ *
+ * @param c input channel buffer
+ * @return object of PceccCapabilityTlv
+ */
+ public static PceccCapabilityTlv read(ChannelBuffer c) {
+ return PceccCapabilityTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java
new file mode 100644
index 00000000..83a62103
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java
@@ -0,0 +1,83 @@
+/*
+ * 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.types;
+
+/**
+ * Provide the PCEP Error Info Details.
+ */
+public final class PcepErrorDetailInfo {
+
+ private PcepErrorDetailInfo() {
+ }
+
+ // Error Types
+ /**
+ Error- Meaning Reference:RFC 5440
+ Type
+ 1 PCEP session establishment failure
+ Error-value=1: reception of an invalid Open message or a non Open message.
+ Error-value=2: no Open message received before the expiration of the OpenWait timer
+ Error-value=3: unacceptable and non-negotiable session characteristics
+ Error-value=4: unacceptable but negotiable session characteristics
+ Error-value=5: reception of a second Open message with still unacceptable session characteristics
+ Error-value=6: reception of a PCErr message proposing unacceptable session characteristics
+ Error-value=7: No Keepalive or PCErr message received before the expiration of the KeepWait timer
+ Error-value=8: PCEP version not supported
+ 2 Capability not supported
+ 3 Unknown Object
+ Error-value=1: Unrecognized object class
+ Error-value=2: Unrecognized object Type
+ 4 Not supported object
+ Error-value=1: Not supported object class
+ Error-value=2: Not supported object Type
+ 5 Policy violation
+ Error-value=1: C bit of the METRIC object set (request rejected)
+ Error-value=2: O bit of the RP object cleared (request rejected)
+ 6 Mandatory Object missing
+ Error-value=1: RP object missing
+ Error-value=2: RRO missing for a re-optimization request (R bit of the RP object set)
+ Error-value=3: END-POINTS object missing
+ 7 Synchronized path computation request missing
+ 8 Unknown request reference
+ 9 Attempt to establish a second PCEP session
+ 10 Reception of an invalid object
+ Error-value=1: reception of an object with P flag not set although the P flag must be
+ set according to this specification.
+ */
+ public static final byte ERROR_TYPE_1 = 1;
+ public static final byte ERROR_TYPE_2 = 2;
+ public static final byte ERROR_TYPE_3 = 3;
+ public static final byte ERROR_TYPE_4 = 4;
+ public static final byte ERROR_TYPE_5 = 5;
+ public static final byte ERROR_TYPE_6 = 6;
+ public static final byte ERROR_TYPE_7 = 7;
+ public static final byte ERROR_TYPE_8 = 8;
+ public static final byte ERROR_TYPE_9 = 9;
+ public static final byte ERROR_TYPE_10 = 10;
+
+ // Error Values
+ public static final byte ERROR_VALUE_1 = 1;
+ public static final byte ERROR_VALUE_2 = 2;
+ public static final byte ERROR_VALUE_3 = 3;
+ public static final byte ERROR_VALUE_4 = 4;
+ public static final byte ERROR_VALUE_5 = 5;
+ public static final byte ERROR_VALUE_6 = 6;
+ public static final byte ERROR_VALUE_7 = 7;
+ public static final byte ERROR_VALUE_8 = 8;
+ public static final byte ERROR_VALUE_9 = 9;
+ public static final byte ERROR_VALUE_10 = 10;
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java
new file mode 100644
index 00000000..97eedcfd
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.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.types;
+
+import java.util.Objects;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides CEP LABEL DB VERSION TLV which contains LSP State DB Version (32 Bit ).
+ */
+public class PcepLabelDbVerTlv implements PcepValueType {
+
+ /* PCEP LABEL DB VERSION TLV format
+
+ Reference : draft-ietf-pce-stateful-sync-optimizations-02, section 3.3.1
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=23 | Length=8 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | LSP State DB Version |
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PcepLabelDbVerTlv.class);
+
+ public static final short TYPE = 34;
+ public static final short LENGTH = 8;
+ private final long rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue of Pcep Label Db Version Tlv
+ */
+ public PcepLabelDbVerTlv(final long rawValue) {
+ log.debug("PcepLabelDbVerTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created PcepLabelDbVerTlv object.
+ *
+ * @param raw LSP State DB Version
+ * @return object of PcepLabelDbVerTlv
+ */
+ public static PcepLabelDbVerTlv of(final long raw) {
+ return new PcepLabelDbVerTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns LSP State DB Version.
+ * @return raw value
+ */
+ public long getLong() {
+ return rawValue;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepLabelDbVerTlv) {
+ PcepLabelDbVerTlv other = (PcepLabelDbVerTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeLong(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of PcepLabelDbVerTlv.
+ *
+ * @param c input channel buffer
+ * @return object of PcepLabelDbVerTlv
+ */
+ public static PcepLabelDbVerTlv read(ChannelBuffer c) {
+ return PcepLabelDbVerTlv.of(c.readLong());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java
new file mode 100644
index 00000000..e2ad069c
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.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.pcepio.types;
+
+import java.util.LinkedList;
+
+import org.onosproject.pcepio.protocol.PcepLabelObject;
+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 Pcep Label.
+ * REference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
+ */
+public class PcepLabelDownload {
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepLabelDownload.class);
+
+ //PCEP SPR Object
+ private PcepSrpObject srpObject;
+ //PCEP LSP Object
+ private PcepLspObject lspObject;
+ //LinkList of Labels
+ private LinkedList<PcepLabelObject> llLabelList;
+
+ /**
+ * Returns SRP Object.
+ *
+ * @return PCEP SRP Object
+ */
+ public PcepSrpObject getSrpObject() {
+ return srpObject;
+ }
+
+ /**
+ * Sets the Pcep SRP Object.
+ *
+ * @param srpobj PCEP SRP Object
+ */
+ public void setSrpObject(PcepSrpObject srpobj) {
+ this.srpObject = srpobj;
+ }
+
+ /**
+ * Returns LSP Object.
+ *
+ * @return PCEP LSP Object
+ */
+ public PcepLspObject getLspObject() {
+ return lspObject;
+ }
+
+ /**
+ * Sets the Pcep LSP Object.
+ *
+ * @param lspObject PCEP LSP Object
+ */
+ public void setLspObject(PcepLspObject lspObject) {
+ this.lspObject = lspObject;
+ }
+
+ /**
+ * Returns a list of labels.
+ *
+ * @return llLabelList list of pcep label objects
+ */
+ public LinkedList<PcepLabelObject> getLabelList() {
+ return llLabelList;
+ }
+
+ /**
+ * set the llLabelList list of type PcepLableObject.
+ *
+ * @param llLabelList list of pcep label objects
+ */
+ public void setLabelList(LinkedList<PcepLabelObject> llLabelList) {
+ this.llLabelList = llLabelList;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("SrpObject", srpObject)
+ .add("LspObject", lspObject)
+ .add("LabelObjectList", llLabelList)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java
new file mode 100644
index 00000000..2d3a953f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java
@@ -0,0 +1,103 @@
+/*
+ * 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.types;
+
+import org.onosproject.pcepio.protocol.PcepFecObject;
+import org.onosproject.pcepio.protocol.PcepLabelObject;
+import org.onosproject.pcepio.protocol.PcepSrpObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provide PCEP Label Map.
+ * Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
+ */
+public class PcepLabelMap {
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepLabelMap.class);
+ //PCEP SRP Object
+ private PcepSrpObject srpObject;
+ //PCEP Label Object
+ private PcepLabelObject labelObject;
+ //PCEP FEC Object
+ private PcepFecObject fecObject;
+
+ /**
+ * Sets Fec Object.
+ *
+ * @param fecObject PCEP fec object
+ */
+ public void setFECObject(PcepFecObject fecObject) {
+ this.fecObject = fecObject;
+ }
+
+ /**
+ * Returns the PcepFecObject.
+ *
+ * @return PCEP fec object
+ */
+ public PcepFecObject getFECObject() {
+ return this.fecObject;
+ }
+
+ /**
+ * Returns SRP Object.
+ *
+ * @return PCEP SRP Object
+ */
+ public PcepSrpObject getSrpObject() {
+ return srpObject;
+ }
+
+ /**
+ * Sets the PCEP Srp Object.
+ *
+ * @param srpObject PCEP SRP Object
+ */
+ public void setSrpObject(PcepSrpObject srpObject) {
+ this.srpObject = srpObject;
+ }
+
+ /**
+ * Returns labelObject.
+ *
+ * @return PCEP label object
+ */
+ public PcepLabelObject getLabelObject() {
+ return labelObject;
+ }
+
+ /**
+ * Sets the Pcep labelObject.
+ *
+ * @param labelObject PCEP label object
+ */
+ public void setLabelObject(PcepLabelObject labelObject) {
+ this.labelObject = labelObject;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("SrpObject", srpObject)
+ .add("LabelObject", labelObject)
+ .add("FecObject", fecObject)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
new file mode 100644
index 00000000..1ed0ab14
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
@@ -0,0 +1,107 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepNai;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Nai Ipv4 Adjacency.
+ */
+public class PcepNaiIpv4Adjacency implements PcepNai {
+
+ public static final byte ST_TYPE = 0x03;
+ private final int localIpv4Addr;
+ private final int remoteIpv4Addr;
+
+ /**
+ * Constructor to initialize variables.
+ *
+ * @param localIpv4 local ipv4 address
+ * @param remoteIpv4 remote ipv4 address
+ */
+ public PcepNaiIpv4Adjacency(int localIpv4, int remoteIpv4) {
+ this.localIpv4Addr = localIpv4;
+ this.remoteIpv4Addr = remoteIpv4;
+ }
+
+ /**
+ * Returns Object of Pcep nai Ipv4 Adjacency.
+ *
+ * @param localIpv4Addr local ipv4 address
+ * @param remoteIpv4Addr remote ipv4 address
+ * @return Object of Pcep nai Ipv4 Adjacency
+ */
+ public static PcepNaiIpv4Adjacency of(int localIpv4Addr, int remoteIpv4Addr) {
+ return new PcepNaiIpv4Adjacency(localIpv4Addr, remoteIpv4Addr);
+ }
+
+ @Override
+ public byte getType() {
+ return ST_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer bb) {
+ int iLenStartIndex = bb.writerIndex();
+ bb.writeInt(localIpv4Addr);
+ bb.writeInt(remoteIpv4Addr);
+ return bb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of PcepNAIIpv4AdjacencyVer1.
+ *
+ * @param cb of channel buffer
+ * @return object of PcepNAIIpv4Adjacency
+ */
+ public static PcepNaiIpv4Adjacency read(ChannelBuffer cb) {
+ int localIpv4 = cb.readInt();
+ int remoteIpv4 = cb.readInt();
+ return new PcepNaiIpv4Adjacency(localIpv4, remoteIpv4);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localIpv4Addr, remoteIpv4Addr);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepNaiIpv4Adjacency) {
+ PcepNaiIpv4Adjacency other = (PcepNaiIpv4Adjacency) obj;
+ return Objects.equals(this.localIpv4Addr, other.localIpv4Addr)
+ && Objects.equals(this.remoteIpv4Addr, other.remoteIpv4Addr);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("localIPv4Address", localIpv4Addr)
+ .add("remoteIPv4Address", remoteIpv4Addr)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java
new file mode 100644
index 00000000..1d4ce5d4
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java
@@ -0,0 +1,99 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepNai;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Nai Ipv4 Node Id.
+ */
+public class PcepNaiIpv4NodeId implements PcepNai {
+
+ public static final byte ST_TYPE = 0x01;
+
+ private final int ipv4NodeId;
+
+ /**
+ * Constructor to initialize ipv4NodeId.
+ *
+ * @param value ipv4 node id
+ */
+ public PcepNaiIpv4NodeId(int value) {
+ this.ipv4NodeId = value;
+ }
+
+ /**
+ * Returns an object of PcepNaiIpv4NodeId.
+ *
+ * @param value ipv4 node id
+ * @return object of PcepNaiIpv4NodeId
+ */
+ public static PcepNaiIpv4NodeId of(int value) {
+ return new PcepNaiIpv4NodeId(value);
+ }
+
+ @Override
+ public byte getType() {
+ return ST_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer bb) {
+ int iLenStartIndex = bb.writerIndex();
+ bb.writeInt(ipv4NodeId);
+ return bb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from the channel buffer and returns object of PcepNAIIpv4NodeIdVer1.
+ *
+ * @param bb of channel buffer.
+ * @return object of PcepNAIIpv4NodeIdVer1
+ */
+ public static PcepNaiIpv4NodeId read(ChannelBuffer bb) {
+ return new PcepNaiIpv4NodeId(bb.readInt());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ipv4NodeId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepNaiIpv4NodeId) {
+ PcepNaiIpv4NodeId other = (PcepNaiIpv4NodeId) obj;
+ return Objects.equals(this.ipv4NodeId, other.ipv4NodeId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("IPv4NodeId", ipv4NodeId)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java
new file mode 100644
index 00000000..3a177d99
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java
@@ -0,0 +1,113 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepNai;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Nai Ipv6 Adjacency.
+ */
+public class PcepNaiIpv6Adjacency implements PcepNai {
+
+ public static final byte ST_TYPE = 0x04;
+ public static final byte IPV6_LEN = 0x10;
+
+ private final byte[] localIpv6Addr;
+ private final byte[] remoteIpv6Addr;
+
+ /**
+ * Constructor to initialize local ipv6 and remote ipv6.
+ *
+ * @param localIpv6 local ipv6 address
+ * @param remoteIpv6 remote ipv6 address
+ */
+ public PcepNaiIpv6Adjacency(byte[] localIpv6, byte[] remoteIpv6) {
+ this.localIpv6Addr = localIpv6;
+ this.remoteIpv6Addr = remoteIpv6;
+ }
+
+ @Override
+ public byte getType() {
+ return ST_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer bb) {
+ int iLenStartIndex = bb.writerIndex();
+ bb.writeBytes(localIpv6Addr);
+ bb.writeBytes(remoteIpv6Addr);
+ return bb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of PcepNAIIpv6AdjacencyVer1.
+ *
+ * @param bb of type channel buffer
+ * @return object of PcepNAIIpv6AdjacencyVer1
+ */
+ public static PcepNaiIpv6Adjacency read(ChannelBuffer bb) {
+ byte[] localIpv6 = new byte[IPV6_LEN];
+ bb.readBytes(localIpv6, 0, IPV6_LEN);
+ byte[] remoteIpv6 = new byte[IPV6_LEN];
+ bb.readBytes(remoteIpv6, 0, IPV6_LEN);
+ return new PcepNaiIpv6Adjacency(localIpv6, remoteIpv6);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localIpv6Addr, remoteIpv6Addr);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepNaiIpv6Adjacency) {
+ PcepNaiIpv6Adjacency other = (PcepNaiIpv6Adjacency) obj;
+ return Objects.equals(this.localIpv6Addr, other.localIpv6Addr)
+ && Objects.equals(this.remoteIpv6Addr, other.remoteIpv6Addr);
+ }
+ return false;
+ }
+
+ /**
+ * Creates object of PcepNaiIpv6Adjacency with local ipv6 address and remote ipv6 address.
+ *
+ * @param localIpv6Addr local ipv6 address
+ * @param remoteIpv6Addr remote ipv6 address
+ * @return object of PcepNaiIpv6Adjacency
+ */
+
+ public static PcepNaiIpv6Adjacency of(final byte[] localIpv6Addr, final byte[] remoteIpv6Addr) {
+ return new PcepNaiIpv6Adjacency(localIpv6Addr, remoteIpv6Addr);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("localIPV6Address", localIpv6Addr)
+ .add("remoteIPV6Address", remoteIpv6Addr)
+ .toString();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java
new file mode 100644
index 00000000..3b7d52fd
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java
@@ -0,0 +1,102 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepNai;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Nai Ipv6 Node Id.
+ */
+public class PcepNaiIpv6NodeId implements PcepNai {
+
+ public static final byte ST_TYPE = 0x02;
+ public static final byte IPV6_LEN = 0x10;
+
+ private final byte[] ipv6NodeId;
+
+ /**
+ * Constructor to initialize ipv6NodeId.
+ *
+ * @param value ipv6 node id
+ */
+ public PcepNaiIpv6NodeId(byte[] value) {
+ this.ipv6NodeId = value;
+ }
+
+ /**
+ * Return object of Pcep Nai Ipv6 Node ID.
+ *
+ * @param ipv6NodeId Ipv6 node ID.
+ * @return object of Pcep Nai Ipv6 Node ID.
+ */
+ public static PcepNaiIpv6NodeId of(byte[] ipv6NodeId) {
+ return new PcepNaiIpv6NodeId(ipv6NodeId);
+ }
+
+ @Override
+ public byte getType() {
+ return ST_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int iLenStartIndex = cb.writerIndex();
+ cb.writeBytes(ipv6NodeId);
+ return cb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from the channel buffer and returns object of PcepNAIIpv6NodeId.
+ *
+ * @param cb of type channel buffer.
+ * @return object of PcepNAIIpv6NodeId
+ */
+ public static PcepNaiIpv6NodeId read(ChannelBuffer cb) {
+ byte[] ipv6NodeId = new byte[IPV6_LEN];
+ cb.readBytes(ipv6NodeId, 0, IPV6_LEN);
+ return new PcepNaiIpv6NodeId(ipv6NodeId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ipv6NodeId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepNaiIpv6NodeId) {
+ PcepNaiIpv6NodeId other = (PcepNaiIpv6NodeId) obj;
+ return Objects.equals(this.ipv6NodeId, other.ipv6NodeId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("IPV6NodeID", ipv6NodeId)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java
new file mode 100644
index 00000000..4e8926cf
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java
@@ -0,0 +1,131 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepNai;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Nai Unnumbered Adjacency Ipv4.
+ */
+public class PcepNaiUnnumberedAdjacencyIpv4 implements PcepNai {
+ /**
+ * draft-ietf-pce-segment-routing-03 section 5.3.2.
+ */
+ public static final byte ST_TYPE = 0x05;
+
+ private final int localNodeId;
+ private final int localInterfaceId;
+ private final int remoteNodeId;
+ private final int remoteInterfaceId;
+
+ /**
+ * Constructor to initialize all the member variables.
+ *
+ * @param localNodeId local node id
+ * @param localInterfaceId local interface id
+ * @param remoteNodeId remote node id
+ * @param remoteInterfaceId remote interface id
+ */
+ public PcepNaiUnnumberedAdjacencyIpv4(int localNodeId, int localInterfaceId, int remoteNodeId,
+ int remoteInterfaceId) {
+ this.localNodeId = localNodeId;
+ this.localInterfaceId = localInterfaceId;
+ this.remoteNodeId = remoteNodeId;
+ this.remoteInterfaceId = remoteInterfaceId;
+ }
+
+ /**
+ * Returns PCEP Nai Unnumbered Adjacency Ipv4 object.
+ *
+ * @param localNodeId local node id
+ * @param localInterfaceId local interface if
+ * @param remoteNodeId remote node id
+ * @param remoteInterfaceId remote interface id
+ * @return PCEP Nai Unnumbered Adjacency Ipv4 object
+ */
+ public static PcepNaiUnnumberedAdjacencyIpv4 of(int localNodeId, int localInterfaceId, int remoteNodeId,
+ int remoteInterfaceId) {
+ return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
+ }
+
+ @Override
+ public byte getType() {
+ return ST_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer bb) {
+ int iLenStartIndex = bb.writerIndex();
+ bb.writeInt(localNodeId);
+ bb.writeInt(localInterfaceId);
+ bb.writeInt(remoteNodeId);
+ bb.writeInt(remoteInterfaceId);
+ return bb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and return object of PcepNAIUnnumberedAdjacencyIpv4.
+ *
+ * @param bb of type channel buffer
+ * @return object of PcepNAIUnnumberedAdjacencyIpv4
+ */
+ public static PcepNaiUnnumberedAdjacencyIpv4 read(ChannelBuffer bb) {
+ int localNodeId;
+ int localInterfaceId;
+ int remoteNodeId;
+ int remoteInterfaceId;
+ localNodeId = bb.readInt();
+ localInterfaceId = bb.readInt();
+ remoteNodeId = bb.readInt();
+ remoteInterfaceId = bb.readInt();
+ return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepNaiUnnumberedAdjacencyIpv4) {
+ PcepNaiUnnumberedAdjacencyIpv4 other = (PcepNaiUnnumberedAdjacencyIpv4) obj;
+ return Objects.equals(this.localNodeId, other.localNodeId)
+ && Objects.equals(this.localInterfaceId, other.localInterfaceId)
+ && Objects.equals(this.remoteNodeId, other.remoteNodeId)
+ && Objects.equals(this.remoteInterfaceId, other.remoteInterfaceId);
+ }
+ return false;
+ }
+
+ @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/types/PcepObjectHeader.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java
new file mode 100644
index 00000000..a4af6746
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java
@@ -0,0 +1,224 @@
+/*
+ * 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.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP Object Header which is common for all the objects.
+ * Reference : RFC 5440.
+ */
+
+public class PcepObjectHeader {
+
+ /*
+ 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) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // (Object body) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ PCEP Common Object Header
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepObjectHeader.class);
+
+ public static final boolean REQ_OBJ_MUST_PROCESS = true;
+ public static final boolean REQ_OBJ_OPTIONAL_PROCESS = false;
+ public static final boolean RSP_OBJ_IGNORED = true;
+ public static final boolean RSP_OBJ_PROCESSED = false;
+ public static final int OBJECT_TYPE_SHIFT_VALUE = 4;
+ public static final byte PFLAG_SET = 0x02;
+ public static final byte IFLAG_SET = 0x01;
+ public static final int SET = 1;
+ private byte objClass;
+ private byte objType;
+ private boolean bPFlag;
+ private boolean bIFlag;
+ private short objLen;
+
+ /**
+ * Constructor to initialize all the variables in object header.
+ *
+ * @param objClass PCEP Object class
+ * @param objType PCEP Object type
+ * @param bPFlag P flag
+ * @param bIFlag I flag
+ * @param objLen PCEP object length
+ */
+
+ public PcepObjectHeader(byte objClass, byte objType, boolean bPFlag, boolean bIFlag, short objLen) {
+ this.objClass = objClass;
+ this.objType = objType;
+ this.bPFlag = bPFlag;
+ this.bIFlag = bIFlag;
+ this.objLen = objLen;
+ }
+
+ /**
+ * Sets the Object class.
+ *
+ * @param value object class
+ */
+ public void setObjClass(byte value) {
+ this.objClass = value;
+ }
+
+ /**
+ * Sets the Object TYPE.
+ *
+ * @param value object type
+ */
+ public void setObjType(byte value) {
+ this.objType = value;
+ }
+
+ /**
+ * Sets the Object P flag.
+ *
+ * @param value p flag
+ */
+ public void setPFlag(boolean value) {
+ this.bPFlag = value;
+ }
+
+ /**
+ * Sets the Object I flag.
+ *
+ * @param value I flag
+ */
+ public void setIFlag(boolean value) {
+ this.bIFlag = value;
+ }
+
+ /**
+ * Sets the Object Length.
+ *
+ * @param value object length
+ */
+ public void setObjLen(short value) {
+ this.objLen = value;
+ }
+
+ /**
+ * Returns Object's P flag.
+ *
+ * @return bPFlag P flag
+ */
+ public boolean getPFlag() {
+ return this.bPFlag;
+ }
+
+ /**
+ * Returns Object's i flag.
+ *
+ * @return bIFlag I flag
+ */
+ public boolean getIFlag() {
+ return this.bIFlag;
+ }
+
+ /**
+ * Returns Object Length.
+ *
+ * @return objLen object length
+ */
+ public short getObjLen() {
+ return this.objLen;
+ }
+
+ /**
+ * Returns Object class.
+ *
+ * @return objClass object class
+ */
+ public byte getObjClass() {
+ return this.objClass;
+ }
+
+ /**
+ * Returns Object Type.
+ *
+ * @return objType object type
+ */
+ public byte getObjType() {
+ return this.objType;
+ }
+
+ /**
+ * Writes Byte stream of PCEP object header to channel buffer.
+ *
+ * @param cb output channel buffer
+ * @return objLenIndex object length index in channel buffer
+ */
+ public int write(ChannelBuffer cb) {
+
+ cb.writeByte(this.objClass);
+ byte temp = (byte) (this.objType << OBJECT_TYPE_SHIFT_VALUE);
+ if (this.bPFlag) {
+ temp = (byte) (temp | PFLAG_SET);
+ }
+ if (this.bIFlag) {
+ temp = (byte) (temp | IFLAG_SET);
+ }
+ cb.writeByte(temp);
+ int objLenIndex = cb.writerIndex();
+ cb.writeShort((short) 0);
+ return objLenIndex;
+ }
+
+ /**
+ * Read from channel buffer and Returns PCEP Objects header.
+ *
+ * @param cb of type channel buffer
+ * @return PCEP Object header
+ */
+ public static PcepObjectHeader read(ChannelBuffer cb) {
+
+ byte objClass;
+ byte objType;
+ boolean bPFlag;
+ boolean bIFlag;
+ short objLen;
+ objClass = cb.readByte();
+ byte temp = cb.readByte();
+ bIFlag = (temp & IFLAG_SET) == IFLAG_SET;
+ bPFlag = (temp & PFLAG_SET) == PFLAG_SET;
+ objType = (byte) (temp >> OBJECT_TYPE_SHIFT_VALUE);
+ objLen = cb.readShort();
+ return new PcepObjectHeader(objClass, objType, bPFlag, bIFlag, objLen);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("ObjectClass", objClass)
+ .add("ObjectType", objType)
+ .add("ObjectLength", objLen)
+ .add("PFlag", (bPFlag) ? 1 : 0)
+ .add("IFlag", (bIFlag) ? 1 : 0)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java
new file mode 100644
index 00000000..8d3c67a7
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.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.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+/**
+ * Abstraction of an entity which provides PCPE RSVP error spec.
+ */
+public interface PcepRsvpErrorSpec extends PcepValueType {
+
+ /**
+ * To write the object information to channelBuffer.
+ *
+ * @param cb of type channel buffer
+ */
+ @Override
+ int write(ChannelBuffer cb);
+
+ /**
+ * Returns class number.
+ *
+ * @return class number
+ */
+ byte getClassNum();
+
+ /**
+ * Returns class type.
+ *
+ * @return class type
+ */
+ byte getClassType();
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java
new file mode 100644
index 00000000..326b66b7
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java
@@ -0,0 +1,160 @@
+/*
+ * 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.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Rsvp Ipv4 Error Spec.
+ */
+public class PcepRsvpIpv4ErrorSpec implements PcepRsvpErrorSpec {
+
+ /*
+ RSVP error spec object header.
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ Ref : ERROR_SPEC @ RFC2205
+
+ IPv4 ERROR_SPEC object: Class = 6, C-Type = 1
+ +-------------+-------------+-------------+-------------+
+ | IPv4 Error Node Address (4 bytes) |
+ +-------------+-------------+-------------+-------------+
+ | Flags | Error Code | Error Value |
+ +-------------+-------------+-------------+-------------+
+
+ */
+
+ PcepRsvpSpecObjHeader objHeader;
+ public static final byte CLASS_NUM = 0x06;
+ public static final byte CLASS_TYPE = 0x01;
+ public static final byte CLASS_LENGTH = 0x0c;
+ private int ipv4Addr;
+ private byte flags;
+ private byte errCode;
+ private short errValue;
+
+ /**
+ * Constructor to initialize obj header, ipv4 addr, flags, err code and err value.
+ *
+ * @param objHeader rsvp ipv4 error spec object header
+ * @param ipv4Addr ipv4 address
+ * @param flags flags value
+ * @param errCode error code value
+ * @param errValue error value
+ */
+ public PcepRsvpIpv4ErrorSpec(PcepRsvpSpecObjHeader objHeader, int ipv4Addr, byte flags, byte errCode,
+ short errValue) {
+ this.objHeader = objHeader;
+ this.ipv4Addr = ipv4Addr;
+ this.flags = flags;
+ this.errCode = errCode;
+ this.errValue = errValue;
+ }
+
+ /**
+ * Constructor to initialize ipv4 address, flags, err code and err value.
+ *
+ * @param ipv4Addr ipv4 address
+ * @param flags flags value
+ * @param errCode error code
+ * @param errValue error value
+ */
+ public PcepRsvpIpv4ErrorSpec(int ipv4Addr, byte flags, byte errCode, short errValue) {
+ this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE);
+ this.ipv4Addr = ipv4Addr;
+ this.flags = flags;
+ this.errCode = errCode;
+ this.errValue = errValue;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int objLenIndex = objHeader.write(cb);
+ cb.writeInt(ipv4Addr);
+ cb.writeByte(flags);
+ cb.writeByte(errCode);
+ cb.writeShort(errValue);
+ short objLen = (short) (cb.writerIndex() - objLenIndex);
+ cb.setShort(objLenIndex, objLen);
+ return objLen;
+ }
+
+ /**
+ * Reads PCPE RSVP error spec from channel buffer and returns PCEP rsvp IPv4 error spec object.
+ *
+ * @param cb channel buffer
+ * @return PCEP rsvp IPv4 error spec object
+ */
+ public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
+ PcepRsvpSpecObjHeader objHeader;
+ int ipv4Addr;
+ byte flags;
+ byte errCode;
+ short errValue;
+
+ objHeader = PcepRsvpSpecObjHeader.read(cb);
+ ipv4Addr = cb.readInt();
+ flags = cb.readByte();
+ errCode = cb.readByte();
+ errValue = cb.readShort();
+ return new PcepRsvpIpv4ErrorSpec(objHeader, ipv4Addr, flags, errCode, errValue);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return StatefulRsvpErrorSpecTlv.TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return CLASS_LENGTH;
+ }
+
+ @Override
+ public byte getClassNum() {
+ return CLASS_NUM;
+ }
+
+ @Override
+ public byte getClassType() {
+ return CLASS_TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("IPv4Address", ipv4Addr)
+ .add("flags", flags)
+ .add("errorCode", errCode)
+ .add("errorValue", errValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java
new file mode 100644
index 00000000..4da1ec6d
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java
@@ -0,0 +1,165 @@
+/*
+ * 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.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Rsvp Ipv6 Error Spec.
+ */
+public class PcepRsvpIpv6ErrorSpec implements PcepRsvpErrorSpec {
+
+ /*
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ Ref : ERROR_SPEC @ RFC2205
+
+ IPv6 ERROR_SPEC object: Class = 6, C-Type = 2
+ +-------------+-------------+-------------+-------------+
+ | |
+ + +
+ | |
+ + IPv6 Error Node Address (16 bytes) +
+ | |
+ + +
+ | |
+ +-------------+-------------+-------------+-------------+
+ | Flags | Error Code | Error Value |
+ +-------------+-------------+-------------+-------------+ */
+
+ PcepRsvpSpecObjHeader objHeader;
+ public static final byte CLASS_NUM = 0x06;
+ public static final byte CLASS_TYPE = 0x02;
+ public static final byte CLASS_LENGTH = 0x18;
+ public static final byte IPV6_LEN = 0x10;
+
+ private byte[] ipv6Addr;
+ private byte flags;
+ private byte errCode;
+ private short errValue;
+
+ /**
+ * Constructor to initialize obj header, ipv6 addr, flags, err code and err value.
+ *
+ * @param objHeader rsvp ipv6 error spec object header
+ * @param ipv6Addr ipv6 address
+ * @param flags flags value
+ * @param errCode error code
+ * @param errValue error value
+ */
+ public PcepRsvpIpv6ErrorSpec(PcepRsvpSpecObjHeader objHeader, byte[] ipv6Addr, byte flags, byte errCode,
+ short errValue) {
+ this.objHeader = objHeader;
+ this.ipv6Addr = ipv6Addr;
+ this.flags = flags;
+ this.errCode = errCode;
+ this.errValue = errValue;
+ }
+
+ /**
+ * Constructor to initialize ipv6 addr, flags, err code and err value.
+ *
+ * @param ipv6Addr ipv6 address
+ * @param flags flags value
+ * @param errCode error code
+ * @param errValue error value
+ */
+ public PcepRsvpIpv6ErrorSpec(byte[] ipv6Addr, byte flags, byte errCode, short errValue) {
+ this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE);
+ this.ipv6Addr = ipv6Addr;
+ this.flags = flags;
+ this.errCode = errCode;
+ this.errValue = errValue;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int objLenIndex = objHeader.write(cb);
+ cb.writeBytes(ipv6Addr);
+ cb.writeByte(flags);
+ cb.writeByte(errCode);
+ cb.writeShort(errValue);
+ short objLen = (short) (cb.writerIndex() - objLenIndex);
+ cb.setShort(objLenIndex, objLen);
+ return objLen;
+ }
+
+ /**
+ * Returns PCEP rsvp IPv6 error spce object.
+ *
+ * @param cb channel buffer
+ * @return PCEP rsvp IPv6 error spce object
+ */
+ public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
+ PcepRsvpSpecObjHeader objHeader;
+ byte[] ipv6Addr = new byte[IPV6_LEN];
+ byte flags;
+ byte errCode;
+ short errValue;
+
+ objHeader = PcepRsvpSpecObjHeader.read(cb);
+ cb.readBytes(ipv6Addr, 0, IPV6_LEN);
+ flags = cb.readByte();
+ errCode = cb.readByte();
+ errValue = cb.readShort();
+ return new PcepRsvpIpv6ErrorSpec(objHeader, ipv6Addr, flags, errCode, errValue);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return StatefulRsvpErrorSpecTlv.TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return CLASS_LENGTH;
+ }
+
+ @Override
+ public byte getClassNum() {
+ return CLASS_NUM;
+ }
+
+ @Override
+ public byte getClassType() {
+ return CLASS_TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("IPv6Address", ipv6Addr)
+ .add("flags", flags)
+ .add("errorCode", errCode)
+ .add("errorValue", errValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java
new file mode 100644
index 00000000..bddcb898
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java
@@ -0,0 +1,161 @@
+/*
+ * 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.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PcepRsvpObjectHeader.
+ */
+public class PcepRsvpObjectHeader {
+
+ /*
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ ERROR_SPEC object Header
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepRsvpObjectHeader.class);
+
+ public static final boolean REQ_OBJ_MUST_PROCESS = true;
+ public static final boolean REQ_OBJ_OPTIONAL_PROCESS = false;
+ public static final boolean RSP_OBJ_IGNORED = true;
+ public static final boolean RSP_OBJ_PROCESSED = false;
+ public static final int OBJECT_TYPE_SHIFT_VALUE = 4;
+ private byte objClassNum;
+ private byte objClassType;
+ private short objLen;
+
+ /**
+ * Constructor to initialize class num, length and type.
+ *
+ * @param objClassNum object class number
+ * @param objClassType object class type
+ * @param objLen object length
+ */
+ public PcepRsvpObjectHeader(byte objClassNum, byte objClassType, short objLen) {
+ this.objClassNum = objClassNum;
+ this.objClassType = objClassType;
+ this.objLen = objLen;
+ }
+
+ /**
+ * Sets the Class-Num.
+ *
+ * @param value object class number
+ */
+ public void setObjClassNum(byte value) {
+ this.objClassNum = value;
+ }
+
+ /**
+ * Sets the Class type.
+ *
+ * @param value object class type
+ */
+ public void setObjClassType(byte value) {
+ this.objClassType = value;
+ }
+
+ /**
+ * Sets the Class Length.
+ *
+ * @param value object length
+ */
+ public void setObjLen(short value) {
+ this.objLen = value;
+ }
+
+ /**
+ * Returns Object Length.
+ *
+ * @return objLen
+ */
+ public short getObjLen() {
+ return this.objLen;
+ }
+
+ /**
+ * Returns Object num.
+ *
+ * @return objClassNum
+ */
+ public byte getObjClassNum() {
+ return this.objClassNum;
+ }
+
+ /**
+ * Returns Object type.
+ *
+ * @return objClassType
+ */
+ public byte getObjClassType() {
+ return this.objClassType;
+ }
+
+ /**
+ * Writes the byte stream of PcepRsvpObjectHeader to channel buffer.
+ *
+ * @param cb of type channel buffer
+ * @return object length index in channel buffer
+ */
+ public int write(ChannelBuffer cb) {
+ int iLenStartIndex = cb.writerIndex();
+ cb.writeShort((short) 0);
+ cb.writeByte(this.objClassNum);
+ cb.writeByte(this.objClassType);
+ return cb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the PcepRsvpObjectHeader.
+ *
+ * @param cb input channel buffer
+ * @return PcepRsvpObjectHeader
+ */
+ public static PcepRsvpObjectHeader read(ChannelBuffer cb) {
+ log.debug("read ");
+ byte objClassNum;
+ byte objClassType;
+ short objLen;
+ objLen = cb.readShort();
+ objClassNum = cb.readByte();
+ objClassType = cb.readByte();
+
+ return new PcepRsvpObjectHeader(objClassNum, objClassType, objLen);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("ObjectClassNum", objClassNum)
+ .add("ObjectCType", objClassType)
+ .add("ObjectLength", objLen)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java
new file mode 100644
index 00000000..132ff862
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java
@@ -0,0 +1,156 @@
+/*
+ * 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.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PcepRsvpObjectHeader.
+ */
+public class PcepRsvpSpecObjHeader {
+
+ /*
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ ERROR_SPEC object Header
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepRsvpSpecObjHeader.class);
+
+ private short objLen;
+ private byte objClassNum;
+ private byte objClassType;
+
+ /**
+ * Constructor to initialize length, class num and type.
+ *
+ * @param objLen object length
+ * @param objClassNum pcep rsvp error spec object class num
+ * @param objClassType pcep rsvp error spec object class type
+ */
+ public PcepRsvpSpecObjHeader(short objLen, byte objClassNum, byte objClassType) {
+ this.objLen = objLen;
+ this.objClassNum = objClassNum;
+ this.objClassType = objClassType;
+ }
+
+ /**
+ * Sets the Class num.
+ *
+ * @param value pcep rsvp error spec object class num
+ */
+ public void setObjClassNum(byte value) {
+ this.objClassNum = value;
+ }
+
+ /**
+ * Sets the Class type.
+ *
+ * @param value pcep rsvp error spec object class type
+ */
+ public void setObjClassType(byte value) {
+ this.objClassType = value;
+ }
+
+ /**
+ * Sets the Class Length.
+ *
+ * @param value pcep rsvp error spec object length
+ */
+ public void setObjLen(short value) {
+ this.objLen = value;
+ }
+
+ /**
+ * Returns Object Length.
+ *
+ * @return objLen pcep rsvp error spec object length
+ */
+ public short getObjLen() {
+ return this.objLen;
+ }
+
+ /**
+ * Returns Object num.
+ *
+ * @return objClassNum pcep rsvp error spec object class num
+ */
+ public byte getObjClassNum() {
+ return this.objClassNum;
+ }
+
+ /**
+ * Returns Object type.
+ *
+ * @return objClassType pcep rsvp error spec object class type
+ */
+ public byte getObjClassType() {
+ return this.objClassType;
+ }
+
+ /**
+ * Writes the byte stream of PcepRsvpObjectHeader to channel buffer.
+ *
+ * @param cb of type channel buffer
+ * @return object length index
+ */
+ public int write(ChannelBuffer cb) {
+ int objLenIndex = cb.writerIndex();
+ objLen = 0;
+ cb.writeShort(objLen);
+ cb.writeByte(objClassNum);
+ cb.writeByte(objClassType);
+ return objLenIndex;
+ }
+
+ /**
+ * Reads the PcepRsvpObjectHeader.
+ *
+ * @param cb of type channel buffer
+ * @return PcepRsvpObjectHeader
+ */
+ public static PcepRsvpSpecObjHeader read(ChannelBuffer cb) {
+ byte objClassNum;
+ byte objClassType;
+ short objLen;
+ objLen = cb.readShort();
+ objClassNum = cb.readByte();
+ objClassType = cb.readByte();
+
+ return new PcepRsvpSpecObjHeader(objLen, objClassNum, objClassType);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("ObjectClassNum: ", objClassNum)
+ .add("ObjectCType: ", objClassType)
+ .add("ObjectLength: ", objLen)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java
new file mode 100644
index 00000000..4a9357de
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.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.types;
+
+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.PcepVersion;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Rsvp User Error Spec.
+ */
+public class PcepRsvpUserErrorSpec implements PcepRsvpErrorSpec {
+
+ /*
+ RSVP error spec object header.
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ Ref : USER_ERROR_SPEC @ RFC5284.
+ USER_ERROR_SPEC object: Class = 194, C-Type = 1
+
+ 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
+ +---------------+---------------+---------------+---------------+
+ | Enterprise Number |
+ +---------------+---------------+---------------+---------------+
+ | Sub Org | Err Desc Len | User Error Value |
+ +---------------+---------------+---------------+---------------+
+ | |
+ ~ Error Description ~
+ | |
+ +---------------+---------------+---------------+---------------+
+ | |
+ ~ User-Defined Subobjects ~
+ | |
+ +---------------+---------------+---------------+---------------+
+ */
+
+ public static final byte CLASS_NUM = (byte) 0xc2;
+ public static final byte CLASS_TYPE = 0x01;
+
+ private PcepRsvpSpecObjHeader objHeader;
+ private int enterpriseNum;
+ private byte subOrg;
+ private byte errDescLen;
+ private short userErrorValue;
+ private byte[] errDesc;
+ private LinkedList<PcepValueType> llRsvpUserSpecSubObj;
+
+ /**
+ * Default constructor.
+ *
+ * @param objHeader pcep rsvp spec object header
+ * @param enterpriseNum enterprise number
+ * @param subOrg organization identifier value
+ * @param errDescLen error description length
+ * @param userErrorValue user error value
+ * @param errDesc error description
+ * @param llRsvpUserSpecSubObj list of subobjects
+ */
+ public PcepRsvpUserErrorSpec(PcepRsvpSpecObjHeader objHeader, int enterpriseNum, byte subOrg, byte errDescLen,
+ short userErrorValue, byte[] errDesc, LinkedList<PcepValueType> llRsvpUserSpecSubObj) {
+ this.objHeader = objHeader;
+ this.enterpriseNum = enterpriseNum;
+ this.subOrg = subOrg;
+ this.errDescLen = errDescLen;
+ this.userErrorValue = userErrorValue;
+ this.errDesc = errDesc;
+ this.llRsvpUserSpecSubObj = llRsvpUserSpecSubObj;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int objLenIndex = objHeader.write(cb);
+ cb.writeInt(enterpriseNum);
+ cb.writeByte(subOrg);
+ cb.writeByte(errDescLen);
+ cb.writeShort(userErrorValue);
+ cb.writeBytes(errDesc);
+
+ if (llRsvpUserSpecSubObj != null) {
+
+ ListIterator<PcepValueType> listIterator = llRsvpUserSpecSubObj.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+ if (tlv == null) {
+ 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);
+ }
+ }
+ }
+ }
+ short objLen = (short) (cb.writerIndex() - objLenIndex);
+ cb.setShort(objLenIndex, objLen);
+ return objLen;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of PcepRsvpErrorSpec.
+ *
+ * @param cb of type channel buffer
+ * @return object of PcepRsvpErrorSpec
+ * @throws PcepParseException when expected object is not received
+ */
+ public static PcepRsvpErrorSpec read(ChannelBuffer cb) throws PcepParseException {
+ PcepRsvpSpecObjHeader objHeader;
+ int enterpriseNum;
+ byte subOrg;
+ byte errDescLen;
+ short userErrorValue;
+ byte[] errDesc;
+ LinkedList<PcepValueType> llRsvpUserSpecSubObj = null;
+
+ objHeader = PcepRsvpSpecObjHeader.read(cb);
+
+ if (objHeader.getObjClassNum() != CLASS_NUM || objHeader.getObjClassType() != CLASS_TYPE) {
+ throw new PcepParseException("Expected PcepRsvpUserErrorSpec object.");
+ }
+ enterpriseNum = cb.readInt();
+ subOrg = cb.readByte();
+ errDescLen = cb.readByte();
+ userErrorValue = cb.readShort();
+ errDesc = new byte[errDescLen];
+ cb.readBytes(errDesc, 0, errDescLen);
+
+ llRsvpUserSpecSubObj = parseErrSpecSubObj(cb);
+
+ return new PcepRsvpUserErrorSpec(objHeader, enterpriseNum, subOrg, errDescLen, userErrorValue, errDesc,
+ llRsvpUserSpecSubObj);
+ }
+
+ private static LinkedList<PcepValueType> parseErrSpecSubObj(ChannelBuffer cb) throws PcepParseException {
+ LinkedList<PcepValueType> llRsvpUserSpecSubObj = new LinkedList<>();
+ while (0 < cb.readableBytes()) {
+ PcepValueType tlv = null;
+ short hType = cb.readShort();
+ int iValue = 0;
+ //short hLength = cb.readShort();
+ switch (hType) {
+ case AutonomousSystemTlv.TYPE:
+ iValue = cb.readInt();
+ tlv = new AutonomousSystemTlv(iValue);
+ break;
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type :" + hType);
+ }
+ llRsvpUserSpecSubObj.add(tlv);
+ }
+ return llRsvpUserSpecSubObj;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return StatefulRsvpErrorSpecTlv.TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return objHeader.getObjLen();
+ }
+
+ @Override
+ public byte getClassNum() {
+ return CLASS_NUM;
+ }
+
+ @Override
+ public byte getClassType() {
+ return CLASS_TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("enterpriseNumber", enterpriseNum)
+ .add("subOrganization", subOrg)
+ .add("errDescLength", errDescLen)
+ .add("userErrorValue", userErrorValue)
+ .add("errDesc", errDesc)
+ .add("RsvpUserSpecSubObject", llRsvpUserSpecSubObj)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java
new file mode 100755
index 00000000..c960e7ac
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java
@@ -0,0 +1,55 @@
+/*
+ * 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.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+
+/**
+ * Abstraction which Provides the PCEP Values of Type, Length ,Version.
+ */
+public interface PcepValueType {
+
+ /**
+ * Returns the Version Of PCEP Message.
+ *
+ * @return Version of PcepVersion Type.
+ */
+ PcepVersion getVersion();
+
+ /**
+ * Returns the Type of PCEP Message.
+ *
+ * @return value of type
+ */
+ short getType();
+
+ /**
+ * Returns the Length of PCEP Message.
+ *
+ * @return value of Length
+ */
+ short getLength();
+
+ /**
+ * Writes the byte Stream of PCEP Message to channel buffer.
+ *
+ * @param bb of type channel buffer
+ * @return length of bytes written to channel buffer
+ */
+ int write(ChannelBuffer bb);
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlv.java
new file mode 100644
index 00000000..aceb7ea0
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlv.java
@@ -0,0 +1,250 @@
+/*
+ * 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.types;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Remote TE Node Descriptors TLV.
+ */
+public class RemoteTENodeDescriptorsTlv implements PcepValueType {
+
+ /* Reference :PCEP Extension for Transporting TE Data
+ draft-dhodylee-pce-pcep-te-data-extn-02
+ *
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD9] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Node Descriptor Sub-TLVs (variable) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(RemoteTENodeDescriptorsTlv.class);
+
+ public static final short TYPE = 1003; //TODD:change this TBD9
+ public short hLength;
+
+ public static final int TLV_HEADER_LENGTH = 4;
+ // Node Descriptor Sub-TLVs (variable)
+ private LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs;
+
+ /**
+ * Constructor to initialize llRemoteTENodeDescriptorSubTLVs.
+ *
+ * @param llRemoteTENodeDescriptorSubTLVs LinkedList of PcepValueType
+ */
+ public RemoteTENodeDescriptorsTlv(LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs) {
+ this.llRemoteTENodeDescriptorSubTLVs = llRemoteTENodeDescriptorSubTLVs;
+ }
+
+ /**
+ * Returns object of Remote TE Node Descriptors TLV.
+ *
+ * @param llRemoteTENodeDescriptorSubTLVs LinkedList of PcepValueType
+ * @return object of RemoteTENodeDescriptorsTLV
+ */
+ public static RemoteTENodeDescriptorsTlv of(final LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs) {
+ return new RemoteTENodeDescriptorsTlv(llRemoteTENodeDescriptorSubTLVs);
+ }
+
+ /**
+ * Returns Remote TE Node Descriptor Sub TLVs.
+ *
+ * @return llRemoteTENodeDescriptorSubTLVs
+ */
+ public LinkedList<PcepValueType> getllRemoteTENodeDescriptorSubTLVs() {
+ return llRemoteTENodeDescriptorSubTLVs;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(llRemoteTENodeDescriptorSubTLVs.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ /*
+ * Here we have a list of Tlv so to compare each sub tlv between the object
+ * we have to take a list iterator so one by one we can get each sub tlv object
+ * and can compare them.
+ * it may be possible that the size of 2 lists is not equal so we have to first check
+ * the size, if both are same then we should check for the subtlv objects otherwise
+ * we should return false.
+ */
+ if (obj instanceof RemoteTENodeDescriptorsTlv) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ RemoteTENodeDescriptorsTlv other = (RemoteTENodeDescriptorsTlv) obj;
+ Iterator<PcepValueType> objListIterator = ((RemoteTENodeDescriptorsTlv) obj).llRemoteTENodeDescriptorSubTLVs
+ .iterator();
+ countObjSubTlv = ((RemoteTENodeDescriptorsTlv) obj).llRemoteTENodeDescriptorSubTLVs.size();
+ countOtherSubTlv = other.llRemoteTENodeDescriptorSubTLVs.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ PcepValueType subTlv = objListIterator.next();
+ isCommonSubTlv = Objects.equals(llRemoteTENodeDescriptorSubTLVs.contains(subTlv),
+ other.llRemoteTENodeDescriptorSubTLVs.contains(subTlv));
+ }
+ return isCommonSubTlv;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+
+ int tlvStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(hLength);
+
+ ListIterator<PcepValueType> listIterator = llRemoteTENodeDescriptorSubTLVs.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+
+ if (tlv == null) {
+ log.debug("TLV is null from subTlv list");
+ continue;
+ }
+ tlv.write(c);
+
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ c.writeByte((byte) 0);
+ }
+ }
+ }
+
+ hLength = (short) (c.writerIndex() - tlvStartIndex);
+ c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
+
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of Remote TE Node Descriptors TLV.
+ *
+ * @param c input channel buffer
+ * @param length length of buffer
+ * @return object of RemoteTENodeDescriptorsTLV
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c , short length) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs = new LinkedList<>();
+
+ ChannelBuffer tempCb = c.readBytes(length);
+
+ while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
+
+ PcepValueType tlv;
+ short hType = tempCb.readShort();
+ int iValue = 0;
+ short hLength = tempCb.readShort();
+ switch (hType) {
+
+ case AutonomousSystemTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new AutonomousSystemTlv(iValue);
+ break;
+ case BGPLSidentifierTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new BGPLSidentifierTlv(iValue);
+ break;
+ case OSPFareaIDsubTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new OSPFareaIDsubTlv(iValue);
+ break;
+ case RouterIDSubTlv.TYPE:
+ tlv = RouterIDSubTlv.read(tempCb, hLength);
+ break;
+
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type :" + hType);
+ }
+
+ // Check for the padding
+ int pad = hLength % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= tempCb.readableBytes()) {
+ tempCb.skipBytes(pad);
+ }
+ }
+
+ llRemoteTENodeDescriptorSubTLVs.add(tlv);
+ }
+
+ if (0 < tempCb.readableBytes()) {
+
+ throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
+ }
+ return new RemoteTENodeDescriptorsTlv(llRemoteTENodeDescriptorSubTLVs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", hLength)
+ .add("RemoteTeNodeDescriptorSubTLVs", llRemoteTENodeDescriptorSubTLVs)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.java
new file mode 100644
index 00000000..228d8533
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.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.types;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides router id.
+ */
+public class RouterIDSubTlv implements PcepValueType {
+
+ /* reference :I-D.ietf-idr-ls-distribution.
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD13] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(RouterIDSubTlv.class);
+
+ public static final short TYPE = 1000; //TODD:change this TBD13
+ private final short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue raw value
+ * @param hLength length
+ */
+ public RouterIDSubTlv(byte[] rawValue, short hLength) {
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns object of Router ID Sub Tlv.
+ *
+ * @param raw value
+ * @param hLength length
+ * @return object of Router ID Sub Tlv
+ */
+ public static RouterIDSubTlv of(final byte[] raw, short hLength) {
+ return new RouterIDSubTlv(raw, hLength);
+ }
+
+ /**
+ * Returns raw value.
+ *
+ * @return rawValue value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof RouterIDSubTlv) {
+ RouterIDSubTlv other = (RouterIDSubTlv) obj;
+ return Arrays.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of RouterIDSubTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of RouterIDSubTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iOpaqueValue = new byte[hLength];
+ c.readBytes(iOpaqueValue, 0, hLength);
+ return new RouterIDSubTlv(iOpaqueValue, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java
new file mode 100644
index 00000000..924a3a32
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java
@@ -0,0 +1,147 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides RoutingUniverseTLV identifiers.
+ */
+public class RoutingUniverseTlv implements PcepValueType {
+
+ /*
+ * Reference : draft-dhodylee-pce-pcep-te-data-extn-02, section 9.2.1.
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD7] | Length=8 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Identifier |
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ *
+ *
+ * +------------+---------------------+
+ | Identifier | Routing Universe |
+ +------------+---------------------+
+ | 0 | L3 packet topology |
+ | 1 | L1 optical topology |
+ +------------+---------------------+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(RoutingUniverseTlv.class);
+
+ public static final short TYPE = 14; // TODO:need to change TBD7
+ public static final short LENGTH = 8;
+
+ private final long rawValue;
+
+ /**
+ * Constructor to initialize raw value.
+ *
+ * @param rawValue raw value
+ */
+ public RoutingUniverseTlv(long rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns object of RoutingUniverseTLV.
+ *
+ * @param raw value
+ * @return object of RoutingUniverseTLV
+ */
+ public static RoutingUniverseTlv of(final long raw) {
+ return new RoutingUniverseTlv(raw);
+ }
+
+ /**
+ * Returns raw value as Identifier.
+ *
+ * @return rawValue Identifier
+ */
+ public long getLong() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof RoutingUniverseTlv) {
+ RoutingUniverseTlv other = (RoutingUniverseTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeLong(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of RoutingUniverseTLV.
+ *
+ * @param c input channel buffer
+ * @return object of RoutingUniverseTLV
+ */
+ public static RoutingUniverseTlv read(ChannelBuffer c) {
+ return RoutingUniverseTlv.of(c.readLong());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java
new file mode 100644
index 00000000..e855a526
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java
@@ -0,0 +1,167 @@
+/*
+ * 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.types;
+
+import java.util.Arrays;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides SharedRiskLinkGroupTlv.
+ */
+public class SharedRiskLinkGroupTlv implements PcepValueType {
+
+ /*
+ * Reference :[I-D.ietf-idr- Group ls-distribution] /3.3.2.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type =TDB41 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Shared Risk Link Group Value |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // ............ //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Shared Risk Link Group Value |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(SharedRiskLinkGroupTlv.class);
+
+ public static final short TYPE = 1096; //TODO:NEED TO HANDLE TDB41
+
+ private final short hLength;
+
+ private final int[] srlgValue;
+
+ /**
+ * Constructor to initialize SRLG value.
+ *
+ * @param srlgValue Shared Risk Link Group Value
+ * @param hLength length
+ */
+ public SharedRiskLinkGroupTlv(int[] srlgValue, short hLength) {
+ this.srlgValue = srlgValue;
+ if (0 == hLength) {
+ this.hLength = (short) ((srlgValue.length) * 4);
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns object of SharedRiskLinkGroupTlv.
+ *
+ * @param raw value
+ * @param hLength length
+ * @return object of SharedRiskLinkGroupTlv
+ */
+ public static SharedRiskLinkGroupTlv of(final int[] raw, short hLength) {
+ return new SharedRiskLinkGroupTlv(raw, hLength);
+ }
+
+ /**
+ * Returns SRLG Value.
+ *
+ * @return srlgValue
+ */
+ public int[] getValue() {
+ return srlgValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Arrays.hashCode(srlgValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SharedRiskLinkGroupTlv) {
+ SharedRiskLinkGroupTlv other = (SharedRiskLinkGroupTlv) obj;
+ return Arrays.equals(this.srlgValue, other.srlgValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ for (int b : srlgValue) {
+ c.writeInt(b);
+ }
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of SharedRiskLinkGroupTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of SharedRiskLinkGroupTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ int iLength = hLength / 4;
+ int[] iSharedRiskLinkGroup = new int[iLength];
+ for (int i = 0; i < iLength; i++) {
+ iSharedRiskLinkGroup[i] = c.readInt();
+ }
+ return new SharedRiskLinkGroupTlv(iSharedRiskLinkGroup, hLength);
+ }
+
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (int b : srlgValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
new file mode 100644
index 00000000..3cbb82c8
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
@@ -0,0 +1,324 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepNai;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides SrEroSubObject.
+ */
+public class SrEroSubObject implements PcepValueType {
+ /*
+ 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) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+
+
+ NAI
+
+ 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 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NAI for IPv4 Adjacency
+
+ 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) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NAI for IPv6 adjacency
+
+ 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 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NAI for Unnumbered adjacency with IPv4 Node IDs
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(SrEroSubObject.class);
+
+ public static final short TYPE = 0x60; //TODO : type to be defined
+ public static final short LENGTH = 12;
+ public static final short VALUE_LENGTH = 10;
+ public static final int SET = 1;
+ public static final byte MFLAG_SET = 0x01;
+ public static final byte CFLAG_SET = 0x02;
+ public static final byte SFLAG_SET = 0x04;
+ public static final byte FFLAG_SET = 0x08;
+ public static final byte SHIFT_ST = 12;
+
+ private final boolean bFFlag;
+ private final boolean bSFlag;
+ private final boolean bCFlag;
+ private final boolean bMFlag;
+ private final byte st;
+
+ private final int sID;
+ private final PcepNai nai;
+
+ /**
+ * Constructor to initialize member variables.
+ *
+ * @param st SID type
+ * @param bFFlag F flag
+ * @param bSFlag S flag
+ * @param bCFlag C flag
+ * @param bMFlag M flag
+ * @param sID segment identifier value
+ * @param nai NAI associated with SID
+ */
+ public SrEroSubObject(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID,
+ PcepNai nai) {
+ this.st = st;
+ this.bFFlag = bFFlag;
+ this.bSFlag = bSFlag;
+ this.bCFlag = bCFlag;
+ this.bMFlag = bMFlag;
+ this.sID = sID;
+ this.nai = nai;
+ }
+
+ /**
+ * Creates object of SrEroSubObject.
+ *
+ * @param st SID type
+ * @param bFFlag F flag
+ * @param bSFlag S flag
+ * @param bCFlag C flag
+ * @param bMFlag M flag
+ * @param sID segment identifier value
+ * @param nai NAI associated with SID
+ * @return object of SrEroSubObject
+ */
+ public static SrEroSubObject of(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID,
+ PcepNai nai) {
+ return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+ }
+
+ /**
+ * Returns SID type.
+ * @return st sid type
+ */
+ public byte getSt() {
+ return st;
+ }
+
+ /**
+ * Returns bFFlag.
+ * @return bFFlag
+ */
+ public boolean getFFlag() {
+ return bFFlag;
+ }
+
+ /**
+ * Returns bSFlag.
+ * @return bSFlag
+ */
+ public boolean getSFlag() {
+ return bSFlag;
+ }
+
+ /**
+ * Returns bCFlag.
+ * @return bCFlag
+ */
+ public boolean getCFlag() {
+ return bCFlag;
+ }
+
+ /**
+ * Returns bMFlag.
+ * @return bMFlag
+ */
+ public boolean getMFlag() {
+ return bMFlag;
+ }
+
+ /**
+ * Returns sID.
+ * @return sID
+ */
+ public int getSID() {
+ return sID;
+ }
+
+ /**
+ * Returns nai.
+ * @return nai
+ */
+ public PcepNai getNai() {
+ return nai;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SrEroSubObject) {
+ SrEroSubObject other = (SrEroSubObject) obj;
+ return Objects.equals(this.st, other.st) && Objects.equals(this.bFFlag, other.bFFlag)
+ && Objects.equals(this.bSFlag, other.bSFlag) && Objects.equals(this.bCFlag, other.bCFlag)
+ && Objects.equals(this.bMFlag, other.bMFlag) && Objects.equals(this.sID, other.sID)
+ && Objects.equals(this.nai, other.nai);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+
+ short temp = 0;
+ if (bMFlag) {
+ temp = (short) (temp | MFLAG_SET);
+ }
+ if (bCFlag) {
+ temp = (short) (temp | CFLAG_SET);
+ }
+ if (bSFlag) {
+ temp = (short) (temp | SFLAG_SET);
+ }
+ if (bFFlag) {
+ temp = (short) (temp | FFLAG_SET);
+ }
+ short tempST = (short) (st << SHIFT_ST);
+ temp = (short) (temp | tempST);
+ c.writeShort(temp);
+ c.writeInt(sID);
+ nai.write(c);
+
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of SrEroSubObject.
+ * @param c of type channel buffer
+ * @return object of SrEroSubObject
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ short temp = c.readShort();
+ boolean bMFlag;
+ boolean bCFlag;
+ boolean bSFlag;
+ boolean bFFlag;
+ byte st;
+ PcepNai nai = null;
+
+ bMFlag = (temp & MFLAG_SET) == MFLAG_SET;
+ bCFlag = (temp & CFLAG_SET) == CFLAG_SET;
+ bSFlag = (temp & SFLAG_SET) == SFLAG_SET;
+ bFFlag = (temp & FFLAG_SET) == FFLAG_SET;
+
+ st = (byte) (temp >> SHIFT_ST);
+
+ int sID = c.readInt();
+ switch (st) {
+ case 0x01:
+ nai = PcepNaiIpv4NodeId.read(c);
+ break;
+ case 0x02:
+ nai = PcepNaiIpv6NodeId.read(c);
+ break;
+ case 0x03:
+ nai = PcepNaiIpv4Adjacency.read(c);
+ break;
+ case 0x04:
+ nai = PcepNaiIpv6Adjacency.read(c);
+ break;
+ case 0x05:
+ nai = PcepNaiUnnumberedAdjacencyIpv4.read(c);
+ break;
+ default:
+ nai = null;
+ break;
+ }
+
+ return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("st", st)
+ .add("bFflag", bFFlag)
+ .add("bSFlag", bSFlag)
+ .add("bCFlag", bCFlag)
+ .add("bMFlag", bMFlag)
+ .add("sID", sID)
+ .add("nAI", nai)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java
new file mode 100644
index 00000000..020d31d9
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java
@@ -0,0 +1,210 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides StatefulIPv4LspIdentidiersTlv.
+ */
+public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
+
+ /* IPV4-LSP-IDENTIFIERS TLV format
+ *
+ * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
+ *
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=18 | Length=16 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 Tunnel Sender Address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | LSP ID | Tunnel ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Extended Tunnel ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 Tunnel Endpoint Address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentidiersTlv.class);
+
+ public static final short TYPE = 18;
+ public static final short LENGTH = 16;
+ public static final int VALUE_LENGTH = 16;
+ private final int ipv4IngressAddress;
+ private final short lspId;
+ private final short tunnelId;
+ private final int extendedTunnelId;
+ private final int ipv4EgressAddress;
+
+ /**
+ * Constructor to initialize member variables.
+ *
+ * @param ipv4IngressAddress ingress ipv4 address
+ * @param lspId lsp id
+ * @param tunnelId tunnel id
+ * @param extendedTunnelId extended tunnel id
+ * @param ipv4EgressAddress egress ipv4 address
+ */
+ public StatefulIPv4LspIdentidiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId,
+ int ipv4EgressAddress) {
+
+ this.ipv4IngressAddress = ipv4IngressAddress;
+ this.lspId = lspId;
+ this.tunnelId = tunnelId;
+ this.extendedTunnelId = extendedTunnelId;
+ this.ipv4EgressAddress = ipv4EgressAddress;
+ }
+
+ /**
+ * Creates object of StatefulIPv4LspIdentidiersTlv.
+ *
+ * @param ipv4IngressAddress ingress ipv4 address
+ * @param lspId lsp id
+ * @param tunnelId tunnel id
+ * @param extendedTunnelId extended tunnel id
+ * @param ipv4EgressAddress egress ipv4 address
+ * @return object of StatefulIPv4LspIdentidiersTlv
+ */
+ public static StatefulIPv4LspIdentidiersTlv of(int ipv4IngressAddress, short lspId, short tunnelId,
+ int extendedTunnelId, int ipv4EgressAddress) {
+ return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
+ ipv4EgressAddress);
+ }
+
+ /**
+ * Returns tunnel id.
+ *
+ * @return tunnelId
+ */
+ public short getTunnelId() {
+ return this.tunnelId;
+ }
+
+ /**
+ * Returns extendedTunnelId.
+ *
+ * @return extendedTunnelId
+ */
+ public int getextendedTunnelId() {
+ return this.extendedTunnelId;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns ipv4IngressAddress.
+ *
+ * @return ipv4IngressAddress
+ */
+ public int getIpv4IngressAddress() {
+ return ipv4IngressAddress;
+ }
+
+ /**
+ * Returns ipv4EgressAddress.
+ *
+ * @return ipv4EgressAddress
+ */
+ public int getIpv4EgressAddress() {
+ return ipv4EgressAddress;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId, ipv4EgressAddress);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof StatefulIPv4LspIdentidiersTlv) {
+ StatefulIPv4LspIdentidiersTlv other = (StatefulIPv4LspIdentidiersTlv) obj;
+ return Objects.equals(this.ipv4IngressAddress, other.ipv4IngressAddress)
+ && Objects.equals(this.lspId, other.lspId) && Objects.equals(this.tunnelId, other.tunnelId)
+ && Objects.equals(this.extendedTunnelId, other.extendedTunnelId)
+ && Objects.equals(this.ipv4EgressAddress, other.ipv4EgressAddress);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(ipv4IngressAddress);
+ c.writeShort(lspId);
+ c.writeShort(tunnelId);
+ c.writeInt(extendedTunnelId);
+ c.writeInt(ipv4EgressAddress);
+
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of StatefulIPv4LspIdentidiersTlv.
+ *
+ * @param c of type channel buffer
+ * @return object of StatefulIPv4LspIdentidiersTlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ int ipv4IngressAddress = c.readInt();
+ short lspId = c.readShort();
+ short tunnelId = c.readShort();
+ int extendedTunnelId = c.readInt();
+ int ipv4EgressAddress = c.readInt();
+ return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
+ ipv4EgressAddress);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type:", TYPE)
+ .add("Length:", LENGTH)
+ .add("Ipv4IngressAddress:", ipv4IngressAddress)
+ .add("LspId:", lspId).add("TunnelId:", tunnelId)
+ .add("ExtendedTunnelId:", extendedTunnelId)
+ .add("Ipv4EgressAddress:", ipv4EgressAddress).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java
new file mode 100644
index 00000000..a667dccd
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java
@@ -0,0 +1,142 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides StatefulLspDbVerTlv.
+ */
+public class StatefulLspDbVerTlv implements PcepValueType {
+
+ /* LSP-DB-VERSION TLV format
+ *
+ * Reference : Optimizations of Label Switched Path State Synchronization Procedures
+ for a Stateful PCE draft-ietf-pce-stateful-sync-optimizations-02
+ *
+ *
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=23 | Length=8 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | LSP State DB Version |
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(StatefulLspDbVerTlv.class);
+
+ public static final short TYPE = 23;
+ public static final short LENGTH = 8;
+ private final long rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue value
+ */
+ public StatefulLspDbVerTlv(final long rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns object of StatefulLspDbVerTlv.
+ *
+ * @param raw is LSP State DB Version
+ * @return object of StatefulLspDbVerTlv
+ */
+ public static StatefulLspDbVerTlv of(final long raw) {
+ return new StatefulLspDbVerTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns LSP State DB Version.
+ *
+ * @return rawValue value
+ */
+ public long getLong() {
+ return rawValue;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof StatefulLspDbVerTlv) {
+ StatefulLspDbVerTlv other = (StatefulLspDbVerTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeLong(rawValue);
+ return c.writerIndex();
+ }
+
+ /**
+ * Reads the channel buffer and returns object of StatefulLspDbVerTlv.
+ *
+ * @param c input channel buffer
+ * @return object of StatefulLspDbVerTlv
+ */
+ public static StatefulLspDbVerTlv read(ChannelBuffer c) {
+ return StatefulLspDbVerTlv.of(c.readLong());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java
new file mode 100644
index 00000000..5d323f6a
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java
@@ -0,0 +1,142 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides StatefulLspErrorCodeTlv.
+ */
+public class StatefulLspErrorCodeTlv implements PcepValueType {
+
+ /* LSP-ERROR-CODE TLV format
+ *
+ * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
+ *
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=20 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | LSP Error Code |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(StatefulLspErrorCodeTlv.class);
+
+ public static final short TYPE = 20;
+ public static final short LENGTH = 4;
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize raw Value.
+ *
+ * @param rawValue lsp error code value
+ */
+ public StatefulLspErrorCodeTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Creates object of StatefulLspErrorCodeTlv.
+ *
+ * @param raw lsp error code value
+ * @return object of StatefulLspErrorCodeTlv
+ */
+ public static StatefulLspErrorCodeTlv of(int raw) {
+ return new StatefulLspErrorCodeTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns lsp error code value.
+ *
+ * @return lsp error code value
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof StatefulLspErrorCodeTlv) {
+ StatefulLspErrorCodeTlv other = (StatefulLspErrorCodeTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of StatefulLspErrorCodeTlv.
+ *
+ * @param c of type channel buffer
+ * @return object of StatefulLspErrorCodeTlv
+ */
+ public static StatefulLspErrorCodeTlv read(ChannelBuffer c) {
+ return StatefulLspErrorCodeTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java
new file mode 100644
index 00000000..84f40e12
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java
@@ -0,0 +1,269 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides StatefulPceCapabilityTlv.
+ */
+public class StatefulPceCapabilityTlv implements PcepValueType {
+
+ /* STATEFUL-PCE-CAPABILITY TLV format
+ *
+ * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=16 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Flags |D|T|I|S|U|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(StatefulPceCapabilityTlv.class);
+
+ public static final short TYPE = 16;
+ public static final short LENGTH = 4;
+ public static final byte UFLAG_SET = 0x01;
+ public static final byte SFLAG_SET = 0x02;
+ public static final byte IFLAG_SET = 0x04;
+ public static final byte TFLAG_SET = 0x08;
+ public static final byte DFLAG_SET = 0x10;
+ public static final int SET = 1;
+
+ private final int rawValue;
+ private final boolean bDFlag;
+ private final boolean bTFlag;
+ private final boolean bIFlag;
+ private final boolean bSFlag;
+ private final boolean bUFlag;
+ private final boolean isRawValueSet;
+
+ /**
+ * Constructor to initialize variables.
+ *
+ * @param rawValue Flags
+ */
+ public StatefulPceCapabilityTlv(int rawValue) {
+ this.rawValue = rawValue;
+ isRawValueSet = true;
+ this.bUFlag = (rawValue & UFLAG_SET) == UFLAG_SET;
+ this.bSFlag = (rawValue & SFLAG_SET) == SFLAG_SET;
+ this.bIFlag = (rawValue & IFLAG_SET) == IFLAG_SET;
+ this.bTFlag = (rawValue & TFLAG_SET) == TFLAG_SET;
+ this.bDFlag = (rawValue & DFLAG_SET) == DFLAG_SET;
+ }
+
+ /**
+ * Constructor to initialize variables.
+ *
+ * @param bDFlag D-flag
+ * @param bTFlag T-flag
+ * @param bIFlag I-flag
+ * @param bSFlag S-flag
+ * @param bUFlag U-flag
+ */
+ public StatefulPceCapabilityTlv(boolean bDFlag, boolean bTFlag, boolean bIFlag, boolean bSFlag, boolean bUFlag) {
+ this.bDFlag = bDFlag;
+ this.bTFlag = bTFlag;
+ this.bIFlag = bIFlag;
+ this.bSFlag = bSFlag;
+ this.bUFlag = bUFlag;
+ this.rawValue = 0;
+ isRawValueSet = false;
+ }
+
+ /**
+ * Returns object of StatefulPceCapabilityTlv.
+ *
+ * @param raw value Flags
+ * @return object of StatefulPceCapabilityTlv
+ */
+ public static StatefulPceCapabilityTlv of(final int raw) {
+ return new StatefulPceCapabilityTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns D-flag.
+ *
+ * @return bDFlag D-flag
+ */
+ public boolean getDFlag() {
+ return bDFlag;
+ }
+
+ /**
+ * Returns T-flag.
+ *
+ * @return bTFlag T-flag
+ */
+ public boolean getTFlag() {
+ return bTFlag;
+ }
+
+ /**
+ * Returns I-flag.
+ *
+ * @return bIFlag I-flag
+ */
+ public boolean getIFlag() {
+ return bIFlag;
+ }
+
+ /**
+ * Returns S-flag.
+ *
+ * @return bSFlag S-flag
+ */
+ public boolean getSFlag() {
+ return bSFlag;
+ }
+
+ /**
+ * Returns U-flag.
+ *
+ * @return bUFlag U-flag
+ */
+ public boolean getUFlag() {
+ return bUFlag;
+ }
+
+ /**
+ * Returns raw value Flags.
+ *
+ * @return rawValue Flags
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ if (isRawValueSet) {
+ return Objects.hash(rawValue);
+ } else {
+ return Objects.hash(bDFlag, bTFlag, bIFlag, bSFlag, bUFlag);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof StatefulPceCapabilityTlv) {
+ StatefulPceCapabilityTlv other = (StatefulPceCapabilityTlv) obj;
+ if (isRawValueSet) {
+ return Objects.equals(this.rawValue, other.rawValue);
+ } else {
+ return Objects.equals(this.bDFlag, other.bDFlag) && Objects.equals(this.bTFlag, other.bTFlag)
+ && Objects.equals(this.bIFlag, other.bIFlag) && Objects.equals(this.bSFlag, other.bSFlag)
+ && Objects.equals(this.bUFlag, other.bUFlag);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ if (isRawValueSet) {
+ c.writeInt(rawValue);
+ } else {
+ int temp = 0;
+ if (bUFlag) {
+ temp = temp | UFLAG_SET;
+ }
+ if (bSFlag) {
+ temp = temp | SFLAG_SET;
+ }
+ if (bIFlag) {
+ temp = temp | IFLAG_SET;
+ }
+ if (bTFlag) {
+ temp = temp | TFLAG_SET;
+ }
+ if (bDFlag) {
+ temp = temp | DFLAG_SET;
+ }
+ c.writeInt(temp);
+ }
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of StatefulPceCapabilityTlv.
+ *
+ * @param c input channel buffer
+ * @return object of StatefulPceCapabilityTlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ int temp = c.readInt();
+ boolean bDFlag;
+ boolean bTFlag;
+ boolean bIFlag;
+ boolean bSFlag;
+ boolean bUFlag;
+
+ bUFlag = (temp & UFLAG_SET) == UFLAG_SET;
+ bSFlag = (temp & SFLAG_SET) == SFLAG_SET;
+ bIFlag = (temp & IFLAG_SET) == IFLAG_SET;
+ bTFlag = (temp & TFLAG_SET) == TFLAG_SET;
+ bDFlag = (temp & DFLAG_SET) == DFLAG_SET;
+
+ return new StatefulPceCapabilityTlv(bDFlag, bTFlag, bIFlag, bSFlag, bUFlag);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("type", TYPE)
+ .add("Length", LENGTH)
+ .add("DFlag", bDFlag)
+ .add("TFlag", bTFlag)
+ .add("IFlag", bIFlag)
+ .add("SFlag", bSFlag)
+ .add("UFlag", bUFlag)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java
new file mode 100644
index 00000000..9e1a074a
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java
@@ -0,0 +1,216 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides StatefulRsvpErrorSpecTlv.
+ */
+public class StatefulRsvpErrorSpecTlv implements PcepValueType {
+
+ protected static final Logger log = LoggerFactory.getLogger(StatefulRsvpErrorSpecTlv.class);
+
+ /* RSVP-ERROR-SPEC TLV format
+ * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
+ *
+ *
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=21 | Length (variable) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ + RSVP ERROR_SPEC or USER_ERROR_SPEC Object +
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ Ref : ERROR_SPEC @ RFC2205
+
+ IPv4 ERROR_SPEC object: Class = 6, C-Type = 1
+ +-------------+-------------+-------------+-------------+
+ | IPv4 Error Node Address (4 bytes) |
+ +-------------+-------------+-------------+-------------+
+ | Flags | Error Code | Error Value |
+ +-------------+-------------+-------------+-------------+
+
+
+ IPv6 ERROR_SPEC object: Class = 6, C-Type = 2
+ +-------------+-------------+-------------+-------------+
+ | |
+ + +
+ | |
+ + IPv6 Error Node Address (16 bytes) +
+ | |
+ + +
+ | |
+ +-------------+-------------+-------------+-------------+
+ | Flags | Error Code | Error Value |
+ +-------------+-------------+-------------+-------------+
+
+
+ Ref : USER_ERROR_SPEC @ RFC5284
+ USER_ERROR_SPEC object: Class = 194, C-Type = 1
+ 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
+ +---------------+---------------+---------------+---------------+
+ | Enterprise Number |
+ +---------------+---------------+---------------+---------------+
+ | Sub Org | Err Desc Len | User Error Value |
+ +---------------+---------------+---------------+---------------+
+ | |
+ ~ Error Description ~
+ | |
+ +---------------+---------------+---------------+---------------+
+ | |
+ ~ User-Defined Subobjects ~
+ | |
+ +---------------+---------------+---------------+---------------+
+
+ */
+
+ public static final short TYPE = 21;
+ public static final int OBJECT_HEADER_LENGTH = 4;
+ private short hLength;
+
+ private final PcepRsvpErrorSpec rsvpErrSpecObj;
+ private final boolean isErrSpceObjSet;
+
+ /**
+ * Constructor to initialize errSpecObj.
+ *
+ * @param rsvpErrSpecObj Rsvp error spec object
+ */
+ public StatefulRsvpErrorSpecTlv(PcepRsvpErrorSpec rsvpErrSpecObj) {
+ this.rsvpErrSpecObj = rsvpErrSpecObj;
+ this.isErrSpceObjSet = true;
+ }
+
+ /**
+ * Returns PcepRsvpErrorSpecObject.
+ *
+ * @return rsvpErrSpecObj
+ */
+ public PcepRsvpErrorSpec getPcepRsvpErrorSpec() {
+ return this.rsvpErrSpecObj;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ /**
+ * Reads channel buffer and returns object of StatefulRsvpErrorSpecTlv.
+ *
+ * @param cb of type channel buffer
+ * @return object of StatefulRsvpErrorSpecTlv
+ * @throws PcepParseException while parsing this tlv from channel buffer
+ */
+ public static PcepValueType read(ChannelBuffer cb) throws PcepParseException {
+
+ PcepRsvpErrorSpec rsvpErrSpecObj = null;
+ PcepRsvpSpecObjHeader rsvpErrSpecObjHeader;
+
+ cb.markReaderIndex();
+ rsvpErrSpecObjHeader = PcepRsvpSpecObjHeader.read(cb);
+ cb.resetReaderIndex();
+
+ if (PcepRsvpIpv4ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
+ && PcepRsvpIpv4ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
+ rsvpErrSpecObj = PcepRsvpIpv4ErrorSpec.read(cb);
+ } else if (PcepRsvpIpv6ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
+ && PcepRsvpIpv6ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
+ rsvpErrSpecObj = PcepRsvpIpv6ErrorSpec.read(cb);
+ } else if (PcepRsvpUserErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
+ && PcepRsvpUserErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
+ rsvpErrSpecObj = PcepRsvpUserErrorSpec.read(cb);
+ }
+ return new StatefulRsvpErrorSpecTlv(rsvpErrSpecObj);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rsvpErrSpecObj.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof StatefulRsvpErrorSpecTlv) {
+ StatefulRsvpErrorSpecTlv other = (StatefulRsvpErrorSpecTlv) obj;
+ return Objects.equals(this.rsvpErrSpecObj, other.rsvpErrSpecObj);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(hLength);
+ if (isErrSpceObjSet) {
+ rsvpErrSpecObj.write(c);
+ }
+ hLength = (short) (c.writerIndex() - iStartIndex);
+ c.setShort(tlvLenIndex, (hLength - OBJECT_HEADER_LENGTH));
+
+ return c.writerIndex() - iStartIndex;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("Type", TYPE)
+ .add("Length", hLength)
+ .add("RSVPErrorSpecObject", rsvpErrSpecObj)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java
new file mode 100644
index 00000000..27cf56a6
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java
@@ -0,0 +1,159 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides SymbolicPathNameTlv.
+ */
+public class SymbolicPathNameTlv implements PcepValueType {
+
+ /*
+ * SYMBOLIC-PATH-NAME TLV format
+ * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
+ *
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=17 | Length (variable) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Symbolic Path Name //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(SymbolicPathNameTlv.class);
+
+ public static final short TYPE = 17;
+ private short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize raw Value.
+ *
+ * @param rawValue Symbolic path name
+ */
+ public SymbolicPathNameTlv(byte[] rawValue) {
+ this.rawValue = rawValue;
+ this.hLength = (short) rawValue.length;
+ }
+
+ /**
+ * Constructor to initialize raw Value.
+ *
+ * @param rawValue Symbolic path name
+ * @param hLength length of Symbolic path name
+ */
+ public SymbolicPathNameTlv(byte[] rawValue, short hLength) {
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Creates an object of SymbolicPathNameTlv.
+ *
+ * @param raw Symbolic path name
+ * @param hLength length of Symbolic path name
+ * @return object of SymbolicPathNameTlv
+ */
+ public static SymbolicPathNameTlv of(final byte[] raw, short hLength) {
+ return new SymbolicPathNameTlv(raw, hLength);
+ }
+
+ /**
+ * Returns Symbolic path name.
+ *
+ * @return Symbolic path name byte array
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SymbolicPathNameTlv) {
+ SymbolicPathNameTlv other = (SymbolicPathNameTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of SymbolicPathNameTlv.
+ *
+ * @param c of type channel buffer
+ * @param hLength length of bytes to read
+ * @return object of SymbolicPathNameTlv
+ */
+ public static SymbolicPathNameTlv read(ChannelBuffer c, short hLength) {
+ byte[] symbolicPathName = new byte[hLength];
+ c.readBytes(symbolicPathName, 0, hLength);
+ return new SymbolicPathNameTlv(symbolicPathName, hLength);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("SymbolicPathName ", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java
new file mode 100644
index 00000000..4429d223
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides TEDefaultMetricTlv.
+ */
+public class TEDefaultMetricTlv implements PcepValueType {
+
+ /*
+ * Reference :| [I-D.ietf-idr- ls-distribution] /3.3.2.3
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TDB37 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | TE Default Link Metric |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(TEDefaultMetricTlv.class);
+
+ public static final short TYPE = 13400; //TDB37
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue TE Default Link Metric
+ */
+ public TEDefaultMetricTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created TEDefaultMetricTlv object.
+ *
+ * @param raw raw value
+ * @return object of TEDefaultMetricTlv.
+ */
+ public static TEDefaultMetricTlv of(final int raw) {
+ return new TEDefaultMetricTlv(raw);
+ }
+
+ /**
+ * Returns raw value.
+ *
+ * @return rawValue TE Default Link Metric
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TEDefaultMetricTlv) {
+ TEDefaultMetricTlv other = (TEDefaultMetricTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of TEDefaultMetricTlv.
+ *
+ * @param c input channel buffer
+ * @return object of TEDefaultMetricTlv
+ */
+ public static TEDefaultMetricTlv read(ChannelBuffer c) {
+ return TEDefaultMetricTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java
new file mode 100644
index 00000000..b3b71aef
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java
@@ -0,0 +1,292 @@
+/*
+ * 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.types;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides TELinkAttributesTlv.
+ */
+public class TELinkAttributesTlv implements PcepValueType {
+
+ /*
+ * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD27] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Link Attributes Sub-TLVs (variable) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(TELinkAttributesTlv.class);
+
+ public static final short TYPE = 1897; //TODD:change this TBD27
+ public short hLength;
+
+ public static final int TLV_HEADER_LENGTH = 4;
+
+ // LinkDescriptors Sub-TLVs (variable)
+ private LinkedList<PcepValueType> llLinkAttributesSubTLVs;
+
+ /**
+ * Constructor to initialize Link Attributes Sub TLVs.
+ *
+ * @param llLinkAttributesSubTLVs linked list of PcepValueType
+ */
+ public TELinkAttributesTlv(LinkedList<PcepValueType> llLinkAttributesSubTLVs) {
+ this.llLinkAttributesSubTLVs = llLinkAttributesSubTLVs;
+ }
+
+ /**
+ * Returns object of TE Link Attributes TLV.
+ *
+ * @param llLinkAttributesSubTLVs linked list of Link Attribute of Sub TLV
+ * @return object of TELinkAttributesTlv
+ */
+ public static TELinkAttributesTlv of(final LinkedList<PcepValueType> llLinkAttributesSubTLVs) {
+ return new TELinkAttributesTlv(llLinkAttributesSubTLVs);
+ }
+
+ /**
+ * Returns linked list of Link Attribute of Sub TLV.
+ *
+ * @return llLinkAttributesSubTLVs linked list of Link Attribute of Sub TLV
+ */
+ public LinkedList<PcepValueType> getllLinkAttributesSubTLVs() {
+ return llLinkAttributesSubTLVs;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(llLinkAttributesSubTLVs.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ /*
+ * Here we have a list of Tlv so to compare each sub tlv between the object
+ * we have to take a list iterator so one by one we can get each sub tlv object
+ * and can compare them.
+ * it may be possible that the size of 2 lists is not equal so we have to first check
+ * the size, if both are same then we should check for the subtlv objects otherwise
+ * we should return false.
+ */
+ if (obj instanceof TELinkAttributesTlv) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ TELinkAttributesTlv other = (TELinkAttributesTlv) obj;
+ Iterator<PcepValueType> objListIterator = ((TELinkAttributesTlv) obj).llLinkAttributesSubTLVs.iterator();
+ countObjSubTlv = ((TELinkAttributesTlv) obj).llLinkAttributesSubTLVs.size();
+ countOtherSubTlv = other.llLinkAttributesSubTLVs.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ PcepValueType subTlv = objListIterator.next();
+ isCommonSubTlv = Objects.equals(llLinkAttributesSubTLVs.contains(subTlv),
+ other.llLinkAttributesSubTLVs.contains(subTlv));
+ }
+ return isCommonSubTlv;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int tlvStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(hLength);
+
+ ListIterator<PcepValueType> listIterator = llLinkAttributesSubTLVs.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+
+ if (tlv == null) {
+ log.debug("TLV is null from subTlv list");
+ continue;
+ }
+ tlv.write(c);
+
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ c.writeByte((byte) 0);
+ }
+ }
+ }
+
+ hLength = (short) (c.writerIndex() - tlvStartIndex);
+ c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
+
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of TE Link Attributes TLV.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of TELinkAttributesTlv
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llLinkAttributesSubTLVs = new LinkedList<>();
+
+ ChannelBuffer tempCb = c.readBytes(hLength);
+
+ while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
+
+ PcepValueType tlv;
+ short hType = tempCb.readShort();
+ int iValue = 0;
+ short length = tempCb.readShort();
+ switch (hType) {
+
+ case IPv4TERouterIdOfLocalNodeTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new IPv4TERouterIdOfLocalNodeTlv(iValue);
+ break;
+ case IPv6TERouterIdofLocalNodeTlv.TYPE:
+ byte[] ipv6LValue = new byte[IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH];
+ tempCb.readBytes(ipv6LValue, 0, IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH);
+ tlv = new IPv6TERouterIdofLocalNodeTlv(ipv6LValue);
+ break;
+ case IPv4TERouterIdOfRemoteNodeTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new IPv4TERouterIdOfRemoteNodeTlv(iValue);
+ break;
+ case IPv6TERouterIdofRemoteNodeTlv.TYPE:
+ byte[] ipv6RValue = new byte[IPv6TERouterIdofRemoteNodeTlv.VALUE_LENGTH];
+ tempCb.readBytes(ipv6RValue, 0, IPv6TERouterIdofRemoteNodeTlv.VALUE_LENGTH);
+ tlv = new IPv6TERouterIdofRemoteNodeTlv(ipv6RValue);
+ break;
+ case LinkLocalRemoteIdentifiersTlv.TYPE:
+ tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
+ break;
+ case AdministrativeGroupTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new AdministrativeGroupTlv(iValue);
+ break;
+ case MaximumLinkBandwidthTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new MaximumLinkBandwidthTlv(iValue);
+ break;
+ case MaximumReservableLinkBandwidthTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new MaximumReservableLinkBandwidthTlv(iValue);
+ break;
+ case UnreservedBandwidthTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new UnreservedBandwidthTlv(iValue);
+ break;
+ case TEDefaultMetricTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new TEDefaultMetricTlv(iValue);
+ break;
+ case LinkProtectionTypeTlv.TYPE:
+ tlv = LinkProtectionTypeTlv.read(tempCb);
+ break;
+ case MPLSProtocolMaskTlv.TYPE:
+ byte cValue = tempCb.readByte();
+ tlv = new MPLSProtocolMaskTlv(cValue);
+ break;
+ case IGPMetricTlv.TYPE:
+ tlv = IGPMetricTlv.read(tempCb, length);
+ break;
+ case SharedRiskLinkGroupTlv.TYPE:
+ tlv = SharedRiskLinkGroupTlv.read(tempCb, length);
+ break;
+ case OpaqueLinkAttributeTlv.TYPE:
+ tlv = OpaqueLinkAttributeTlv.read(tempCb, length);
+ break;
+ case LinkNameTlv.TYPE:
+ tlv = LinkNameTlv.read(tempCb, length);
+ break;
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type :" + hType);
+ }
+
+ // Check for the padding
+ int pad = length % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= tempCb.readableBytes()) {
+ tempCb.skipBytes(pad);
+ }
+ }
+ llLinkAttributesSubTLVs.add(tlv);
+ }
+
+ if (0 < tempCb.readableBytes()) {
+
+ throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
+ }
+
+ return new TELinkAttributesTlv(llLinkAttributesSubTLVs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", hLength)
+ .add("LinkAttributesSubTLVs", llLinkAttributesSubTLVs)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTlv.java
new file mode 100644
index 00000000..b974cf82
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTlv.java
@@ -0,0 +1,251 @@
+/*
+ * 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.types;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides TE Link Descriptors TLV.
+ */
+public class TELinkDescriptorsTlv implements PcepValueType {
+
+ /*
+ * Reference: PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD14] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Link Descriptor Sub-TLVs (variable) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(TELinkDescriptorsTlv.class);
+
+ public static final short TYPE = 1070; //TODD:change this TBD14
+ public short hLength;
+
+ public static final int TLV_HEADER_LENGTH = 4;
+
+ // LinkDescriptors Sub-TLVs (variable)
+ private LinkedList<PcepValueType> llLinkDescriptorsSubTLVs;
+
+ /**
+ * Constructor to initialize llLinkDescriptorsSubTLVs.
+ *
+ * @param llLinkDescriptorsSubTLVs of PcepValueType
+ */
+ public TELinkDescriptorsTlv(LinkedList<PcepValueType> llLinkDescriptorsSubTLVs) {
+ this.llLinkDescriptorsSubTLVs = llLinkDescriptorsSubTLVs;
+ }
+
+ /**
+ * Returns object of TELinkDescriptorsTLV.
+ *
+ * @param llLinkDescriptorsSubTLVs of PcepValueType
+ * @return object of TELinkDescriptorsTLV
+ */
+ public static TELinkDescriptorsTlv of(final LinkedList<PcepValueType> llLinkDescriptorsSubTLVs) {
+ return new TELinkDescriptorsTlv(llLinkDescriptorsSubTLVs);
+ }
+
+ /**
+ * Returns linked list of Link Attribute of Sub TLV.
+ *
+ * @return llLinkDescriptorsSubTLVs linked list of Link Attribute of Sub TLV
+ */
+ public LinkedList<PcepValueType> getllLinkDescriptorsSubTLVs() {
+ return llLinkDescriptorsSubTLVs;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(llLinkDescriptorsSubTLVs.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ /*
+ * Here we have a list of Tlv so to compare each sub tlv between the object
+ * we have to take a list iterator so one by one we can get each sub tlv object
+ * and can compare them.
+ * it may be possible that the size of 2 lists is not equal so we have to first check
+ * the size, if both are same then we should check for the subtlv objects otherwise
+ * we should return false.
+ */
+ if (obj instanceof TELinkDescriptorsTlv) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ TELinkDescriptorsTlv other = (TELinkDescriptorsTlv) obj;
+ Iterator<PcepValueType> objListIterator = ((TELinkDescriptorsTlv) obj).llLinkDescriptorsSubTLVs.iterator();
+ countObjSubTlv = ((TELinkDescriptorsTlv) obj).llLinkDescriptorsSubTLVs.size();
+ countOtherSubTlv = other.llLinkDescriptorsSubTLVs.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ PcepValueType subTlv = objListIterator.next();
+ isCommonSubTlv = Objects.equals(llLinkDescriptorsSubTLVs.contains(subTlv),
+ other.llLinkDescriptorsSubTLVs.contains(subTlv));
+ }
+ return isCommonSubTlv;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int tlvStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(hLength);
+
+ ListIterator<PcepValueType> listIterator = llLinkDescriptorsSubTLVs.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+
+ tlv.write(c);
+
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ c.writeByte((byte) 0);
+ }
+ }
+ }
+
+ hLength = (short) (c.writerIndex() - tlvStartIndex);
+ c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
+
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of TELinkDescriptorsTLV.
+ *
+ * @param c input channel buffer
+ * @param length length
+ * @return object of TELinkDescriptorsTLV
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c, short length) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llLinkDescriptorsSubTLVs = new LinkedList<>();
+
+ ChannelBuffer tempCb = c.readBytes(length);
+
+ while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
+
+ PcepValueType tlv;
+ short hType = tempCb.readShort();
+ int iValue = 0;
+ short hLength = tempCb.readShort();
+ log.debug("sub Tlv Length" + hLength);
+ switch (hType) {
+
+ case LinkLocalRemoteIdentifiersTlv.TYPE:
+ tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
+ break;
+ case IPv4InterfaceAddressTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new IPv4InterfaceAddressTlv(iValue);
+ break;
+ case IPv4NeighborAddressTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new IPv4NeighborAddressTlv(iValue);
+ break;
+ case IPv6InterfaceAddressTlv.TYPE:
+ byte[] ipv6Value = new byte[IPv6InterfaceAddressTlv.VALUE_LENGTH];
+ tempCb.readBytes(ipv6Value, 0, IPv6InterfaceAddressTlv.VALUE_LENGTH);
+ tlv = new IPv6InterfaceAddressTlv(ipv6Value);
+ break;
+ case IPv6NeighborAddressTlv.TYPE:
+ byte[] ipv6NeighborAdd = new byte[IPv6NeighborAddressTlv.VALUE_LENGTH];
+ tempCb.readBytes(ipv6NeighborAdd, 0, IPv6NeighborAddressTlv.VALUE_LENGTH);
+ tlv = new IPv6NeighborAddressTlv(ipv6NeighborAdd);
+ break;
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type:" + hType);
+ }
+
+ // Check for the padding
+ int pad = hLength % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= tempCb.readableBytes()) {
+ tempCb.skipBytes(pad);
+ }
+ }
+ llLinkDescriptorsSubTLVs.add(tlv);
+
+ }
+
+ if (0 < tempCb.readableBytes()) {
+
+ throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
+ }
+ return new TELinkDescriptorsTlv(llLinkDescriptorsSubTLVs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", hLength)
+ .add("LinkDescriptorsSubTLVs", llLinkDescriptorsSubTLVs)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java
new file mode 100644
index 00000000..f18b75b2
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java
@@ -0,0 +1,250 @@
+/*
+ * 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.types;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides TE Node Attributes Tlv.
+ */
+public class TENodeAttributesTlv implements PcepValueType {
+ /*
+ * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
+ *
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD20] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Node Attributes Sub-TLVs (variable) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(TENodeAttributesTlv.class);
+
+ public static final short TYPE = 1267; //TODD:change this TBD20
+ public short hLength;
+
+ public static final int TLV_HEADER_LENGTH = 4;
+ // LinkDescriptors Sub-TLVs (variable)
+ private LinkedList<PcepValueType> llNodeAttributesSubTLVs;
+
+ /**
+ * Constructor to initialize llNodeAttributesSubTLVs.
+ *
+ * @param llNodeAttributesSubTLVs linked list of Node Attributes Sub-TLVs
+ */
+ public TENodeAttributesTlv(LinkedList<PcepValueType> llNodeAttributesSubTLVs) {
+ this.llNodeAttributesSubTLVs = llNodeAttributesSubTLVs;
+ }
+
+ /**
+ * Returns object of TENodeAttributesTlv.
+ *
+ * @param llNodeAttributesSubTLVs LinkedList of PcepValueType
+ * @return object of TENodeAttributesTlv
+ */
+ public static TENodeAttributesTlv of(LinkedList<PcepValueType> llNodeAttributesSubTLVs) {
+ return new TENodeAttributesTlv(llNodeAttributesSubTLVs);
+ }
+
+ /**
+ * Returns Node Attributes Sub-TLVs.
+ *
+ * @return llNodeAttributesSubTLVs linked list of Node Attributes Sub-TLVs
+ */
+ public LinkedList<PcepValueType> getllNodeAttributesSubTLVs() {
+ return llNodeAttributesSubTLVs;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(llNodeAttributesSubTLVs.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ /*
+ * Here we have a list of Tlv so to compare each sub tlv between the object
+ * we have to take a list iterator so one by one we can get each sub tlv object
+ * and can compare them.
+ * it may be possible that the size of 2 lists is not equal so we have to first check
+ * the size, if both are same then we should check for the subtlv objects otherwise
+ * we should return false.
+ */
+ if (obj instanceof TENodeAttributesTlv) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ TENodeAttributesTlv other = (TENodeAttributesTlv) obj;
+ Iterator<PcepValueType> objListIterator = ((TENodeAttributesTlv) obj).llNodeAttributesSubTLVs.iterator();
+ countObjSubTlv = ((TENodeAttributesTlv) obj).llNodeAttributesSubTLVs.size();
+ countOtherSubTlv = other.llNodeAttributesSubTLVs.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ PcepValueType subTlv = objListIterator.next();
+ isCommonSubTlv = Objects.equals(llNodeAttributesSubTLVs.contains(subTlv),
+ other.llNodeAttributesSubTLVs.contains(subTlv));
+ }
+ return isCommonSubTlv;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int tlvStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(hLength);
+
+ ListIterator<PcepValueType> listIterator = llNodeAttributesSubTLVs.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+
+ tlv.write(c);
+
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ c.writeByte((byte) 0);
+ }
+ }
+ }
+
+ hLength = (short) (c.writerIndex() - tlvStartIndex);
+ c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
+
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of TENodeAttributesTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of TENodeAttributesTlv
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llNodeAttributesSubTLVs = new LinkedList<>();
+
+ ChannelBuffer tempCb = c.readBytes(hLength);
+
+ while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
+ PcepValueType tlv;
+ short hType = tempCb.readShort();
+ int iValue = 0;
+ short length = tempCb.readShort();
+ switch (hType) {
+
+ case NodeFlagBitsTlv.TYPE:
+ byte cValue = tempCb.readByte();
+ tlv = new NodeFlagBitsTlv(cValue);
+ break;
+ case OpaqueNodeAttributeTlv.TYPE:
+ tlv = OpaqueNodeAttributeTlv.read(tempCb, length);
+ break;
+ case NodeNameTlv.TYPE:
+ tlv = NodeNameTlv.read(tempCb, length);
+ break;
+ case ISISAreaIdentifierTlv.TYPE:
+ tlv = ISISAreaIdentifierTlv.read(tempCb, length);
+ break;
+ case IPv4TERouterIdOfLocalNodeTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new IPv4TERouterIdOfLocalNodeTlv(iValue);
+ break;
+ case IPv6TERouterIdofLocalNodeTlv.TYPE:
+ byte[] ipv6Value = new byte[IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH];
+ tempCb.readBytes(ipv6Value, 0, IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH);
+ tlv = new IPv6TERouterIdofLocalNodeTlv(ipv6Value);
+ break;
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type :" + hType);
+ }
+
+ // Check for the padding
+ int pad = length % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= tempCb.readableBytes()) {
+ tempCb.skipBytes(pad);
+ }
+ }
+
+ llNodeAttributesSubTLVs.add(tlv);
+ }
+
+ if (0 < tempCb.readableBytes()) {
+
+ throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
+ }
+ return new TENodeAttributesTlv(llNodeAttributesSubTLVs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", hLength)
+ .add("NodeAttributesSubTLVs", llNodeAttributesSubTLVs)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java
new file mode 100644
index 00000000..189dcadc
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java
@@ -0,0 +1,181 @@
+/*
+ * 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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides TED Capability Tlv.
+ */
+public class TedCapabilityTlv implements PcepValueType {
+
+ /*
+ * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
+ * 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD5] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Flags |R|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(TedCapabilityTlv.class);
+
+ public static final short TYPE = 132; //TODO: need to change this TBD5
+ public static final short LENGTH = 4;
+ public static final int SET = 1;
+ public static final byte RFLAG_CHECK = 0x01;
+
+ private final boolean bRFlag;
+ private final int rawValue;
+ private final boolean isRawValueSet;
+
+ /**
+ * Constructor to initialize raw Value.
+ *
+ * @param rawValue Flags
+ */
+ public TedCapabilityTlv(final int rawValue) {
+ this.rawValue = rawValue;
+ this.isRawValueSet = true;
+ int temp = rawValue;
+ temp = temp & RFLAG_CHECK;
+ if (temp == SET) {
+ this.bRFlag = true;
+ } else {
+ this.bRFlag = false;
+ }
+
+ }
+
+ /**
+ * Constructor to initialize bRFlag.
+ *
+ * @param bRFlag R-flag
+ */
+ public TedCapabilityTlv(boolean bRFlag) {
+ this.bRFlag = bRFlag;
+ this.rawValue = 0;
+ this.isRawValueSet = false;
+ }
+
+ /**
+ * Returns R-flag.
+ *
+ * @return bRFlag
+ */
+ public boolean getbRFlag() {
+ return bRFlag;
+ }
+
+ /**
+ * Returns an object of TedCapabilityTlv.
+ *
+ * @param raw value Flags
+ * @return object of TedCapabilityTlv
+ */
+ public static TedCapabilityTlv of(final int raw) {
+ return new TedCapabilityTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ if (isRawValueSet) {
+ return Objects.hash(rawValue);
+ } else {
+ return Objects.hash(bRFlag);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TedCapabilityTlv) {
+ TedCapabilityTlv other = (TedCapabilityTlv) obj;
+ if (isRawValueSet) {
+ return Objects.equals(this.rawValue, other.rawValue);
+ } else {
+ return Objects.equals(this.bRFlag, other.bRFlag);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ int temp = 0;
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ if (isRawValueSet) {
+ c.writeInt(rawValue);
+ } else {
+ if (bRFlag) {
+ temp = temp | RFLAG_CHECK;
+ }
+ c.writeInt(temp);
+ }
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of TedCapabilityTlv.
+ *
+ * @param c input channel buffer
+ * @return object of TedCapabilityTlv
+ */
+ public static TedCapabilityTlv read(ChannelBuffer c) {
+ return TedCapabilityTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java
new file mode 100644
index 00000000..d44bf824
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.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.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Unreserved Bandwidth Tlv.
+ */
+public class UnreservedBandwidthTlv implements PcepValueType {
+
+ /* Reference :[RFC5305]/3.6
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TDB36] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Unreserved Bandwidth |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(UnreservedBandwidthTlv.class);
+
+ public static final short TYPE = 11; //TDB36
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue Unreserved Bandwidth
+ */
+ public UnreservedBandwidthTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created UnreservedBandwidthTlv object.
+ *
+ * @param raw as Unreserved Bandwidth
+ * @return object of UnreservedBandwidthTlv
+ */
+ public static UnreservedBandwidthTlv of(final int raw) {
+ return new UnreservedBandwidthTlv(raw);
+ }
+
+ /**
+ * Returns Unreserved Bandwidth.
+ *
+ * @return rawValue Unreserved Bandwidth
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof UnreservedBandwidthTlv) {
+ UnreservedBandwidthTlv other = (UnreservedBandwidthTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads byte stream from channel buffer and returns object of UnreservedBandwidthTlv.
+ *
+ * @param c input channel buffer
+ * @return object of UnreservedBandwidthTlv
+ */
+ public static UnreservedBandwidthTlv read(ChannelBuffer c) {
+ return UnreservedBandwidthTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java
new file mode 100644
index 00000000..12744de1
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/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 Tlvs and Pcep common objects.
+ */
+package org.onosproject.pcepio.types;
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java
new file mode 100644
index 00000000..c39f606b
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/HexDump.java
@@ -0,0 +1,56 @@
+/*
+ * 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.util;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provides Hex Dump for debugging.
+ */
+public final class HexDump {
+ protected static final Logger log = LoggerFactory.getLogger(HexDump.class);
+
+ private HexDump() {
+ }
+
+ public static void pcepHexDump(ChannelBuffer buff) {
+
+ log.debug("==================== HEX DUMP ======================");
+ try {
+ byte[] yTemp;
+ yTemp = buff.array();
+
+ int iStartIndex = buff.readerIndex();
+ int iEndIndex = buff.writerIndex();
+ do {
+ StringBuilder sb = new StringBuilder();
+ for (int k = 0; (k < 16) && (iStartIndex < iEndIndex); ++k) {
+ if (0 == k % 4) {
+ sb.append(String.format(" ")); //blank after 4 bytes
+ }
+ sb.append(String.format("%02X ", yTemp[iStartIndex++]));
+ }
+ log.debug(sb.toString());
+ } while (iStartIndex < iEndIndex);
+ } catch (Exception e) {
+ log.error("[HexDump] Invalid buffer: " + e.toString());
+ }
+
+ log.debug("===================================================");
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/package-info.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/package-info.java
new file mode 100644
index 00000000..b3756ffe
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/util/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.
+ */
+
+/**
+ * Provides utility functionality for PCEP messages.
+ */
+package org.onosproject.pcepio.util;
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java
new file mode 100644
index 00000000..33c00ddf
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+
+public class PcepCloseMsgTest {
+
+ /**
+ * Common header, reason to close.
+ */
+ @Test
+ public void closeMessageTest1() throws PcepParseException {
+
+ byte[] closeMsg = new byte[] {0x20, 0x07, 0x00, 0x0C, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02 };
+
+ byte[] testCloseMsg = {0 };
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(closeMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message;
+
+ message = reader.readFrom(buffer);
+ assertThat(message, instanceOf(PcepCloseMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testCloseMsg = buf.array();
+
+ int readLen = buf.writerIndex();
+ testCloseMsg = new byte[readLen];
+ buf.readBytes(testCloseMsg, 0, readLen);
+ assertThat(testCloseMsg, is(closeMsg));
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java
new file mode 100644
index 00000000..234cea67
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java
@@ -0,0 +1,735 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for PCEP ERROR Message.
+ */
+public class PcepErrorMsgTest {
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
+ * PCECC-CAPABILITY-TLV, TED Capability TLV)
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest1() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x28, // OPEN object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV
+ 0x00, 0x00, 0x00, 0x00};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
+ * PCECC-CAPABILITY-TLV, TED Capability TLV)
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest2() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x28, // OPEN object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV
+ 0x00, 0x00, 0x00, 0x00};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
+ * PCECC-CAPABILITY-TLV)
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest3() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x20, // OPEN object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x03};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV)
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest4() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2c, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x18, // OPEN object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY)
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest5() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x10, // OPEN object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x00, 0x00, 0x05};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest6() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x1C, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x08, // OPEN object header
+ 0x20, 0x05, 0x1E, 0x01 // OPEN object
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, OPEN Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest7() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x08, // OPEN object header
+ 0x20, 0x05, 0x1E, 0x01 // OPEN object
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, RP Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest8() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x20, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x03};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest9() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest10() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest11() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header
+ 0x65, 0x13, 0x00, 0x0C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * RP Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest12() throws PcepParseException {
+
+ //RP Object, PCEP-ERROR Object
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header
+ 0x02, 0x10, 0x00, 0x0C, // RP Object Header
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * RP Object, RP Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest13() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
+ 0x02, 0x10, 0x00, 0x0C, // RP Object Header
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object, TE Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest14() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header
+ 0x65, 0x10, 0x00, 0x0C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x65, 0x10, 0x00, 0x0C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID
+ 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, TE Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest15() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x20, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x65, 0x10, 0x00, 0x0C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x03};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest16() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x03};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, TE Object, TE Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest17() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x65, 0x10, 0x00, 0x0C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x65, 0x10, 0x00, 0x0C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID
+ 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x03};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest18() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x06};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, PCEP-ERROR Object, TE Object, TE Object, PCEP-ERROR Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest19() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x03, 0x65, 0x10, 0x00, 0x0C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x65, 0x10, 0x00, 0x0C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x06};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+
+ /**
+ * This test case checks for
+ * PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object,
+ * TE Object, PCEP-ERROR Object
+ * in PcepErrorMsg message.
+ */
+ @Test
+ public void errorMessageTest20() throws PcepParseException {
+
+ byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x48, // common header
+ 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
+ 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x06, 0x65, 0x10, 0x00, 0x0C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header
+ 0x00, 0x00, 0x01, 0x06};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(errorMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testErrorMsg = {0};
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ assertThat(message, instanceOf(PcepErrorMsg.class));
+
+ message.writeTo(buf);
+ int iReadLen = buf.writerIndex();
+ testErrorMsg = new byte[iReadLen];
+ buf.readBytes(testErrorMsg, 0, iReadLen);
+
+ assertThat(testErrorMsg, is(errorMsg));
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java
new file mode 100644
index 00000000..9341f326
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java
@@ -0,0 +1,1683 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+
+public class PcepInitiateMsgExtTest {
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv),
+ * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest1() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+ * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA4,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03,
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, //Metric object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv,
+ * StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest2() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+ * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA8,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x48, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
+ 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS,
+ * ERO, LSPA, BANDWIDTH objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest3() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+ * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
+ //0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv),
+ * END-POINTS, ERO, LSPA objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest4() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+ * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
+ // 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest5() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+ * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA,
+ * BANDWIDTH OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest6() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+ * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO,
+ * LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest7() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
+ * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x98,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest8() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
+ * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x90,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest9() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
+ * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest10() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+ * END-POINTS, ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA OBJECT
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest11() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
+ * END-POINTS, ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7C,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03,
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest12() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+ * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x78,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest13() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
+ * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest14() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest15() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest16() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * END-POINTS, ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest17() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
+ * BANDWIDTH OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest18() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03,
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
+ * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest19() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x74,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
+ * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest20() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA,
+ * BANDWIDTH OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest21() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO,
+ * LSPA OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest22() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest23() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * END-POINTS, ERO, LSPA BANDWIDTH OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest25() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA BANDWIDTH OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS,
+ * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest26() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS,
+ * ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x6C,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA,
+ * BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest27() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO,
+ * LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest28() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
+ * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest29() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x4C,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
+ * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest30() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5C,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest31() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+ * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest32() throws PcepParseException {
+
+ /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+ * ERO, LSPA, BANDWIDTH, METRIC OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+ * ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest33() throws PcepParseException {
+
+ /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+ * ERO, LSPA, BANDWIDTH OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+ * ERO, LSPA OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest34() throws PcepParseException {
+
+ /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+ * ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+ * ERO, LSPA OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest35() throws PcepParseException {
+
+ /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+ * ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+ * ERO, LSPA OBJECT objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest36() throws PcepParseException {
+
+ /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
+ * ERO, LSPA OBJECT.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
+ 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+}
+
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java
new file mode 100644
index 00000000..0f8bb7ba
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java
@@ -0,0 +1,1331 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+
+public class PcepInitiateMsgTest {
+
+ /**
+ * This test case checks for srp, lsp, end-point, ERO objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest1() throws PcepParseException {
+
+ /* srp, lsp, end-point, ERO.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, 0x54,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x00, 0x08, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp and lsp objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest2() throws PcepParseException {
+ /* srp, lsp.
+ */
+ byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x34,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x20, 0x10, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ 0x01, 0x01, 0x01, 0x01, 0x00, 0x43, (byte) 0x83, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33}; //SymbolicPathTlv
+
+ byte[] testInitiateDeletionMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateDeletionMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testInitiateDeletionMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateDeletionMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
+
+ assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO objects
+ * in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest3() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv), END-POINT, ERO objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest4() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv), END-POINT, ERO.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+ * END-POINT, ERO objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest5() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+ * END-POINT, ERO.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+ * END-POINT, ERO objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest6() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+ * END-POINT, ERO.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * END-POINT, ERO objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest7() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * END-POINT, ERO.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * END-POINT, ERO objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest8() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * END-POINT, ERO.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x4c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * END-POINT, ERO objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest9() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * END-POINT, ERO.
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x3c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, StatefulRsvpErrorSpecTlv)
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest10() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, StatefulRsvpErrorSpecTlv).
+ */
+ byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x44,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f,
+ (byte) 0xb6, 0x02, 0x4e, 0x20, 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08 //StatefulLspErrorCodeTlv
+ };
+
+ byte[] testInitiateDeletionMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateDeletionMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateDeletionMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateDeletionMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
+
+ assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv) objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest11() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ StatefulLspErrorCodeTlv).*/
+ byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x44,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08}; //StatefulLspErrorCodeTlv
+
+ byte[] testInitiateDeletionMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateDeletionMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateDeletionMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateDeletionMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
+
+ assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest12() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv).
+ */
+ byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x3c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00 //SymbolicPathNameTlv
+ };
+
+ byte[] testInitiateDeletionMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateDeletionMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateDeletionMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateDeletionMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
+
+ assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest13() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv).
+ */
+ byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x3c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00}; //SymbolicPathNameTlv
+
+ byte[] testInitiateDeletionMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateDeletionMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateDeletionMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateDeletionMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
+
+ assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv)
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest14() throws PcepParseException {
+
+ /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv).
+ */
+ byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x34,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20};
+
+ byte[] testInitiateDeletionMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateDeletionMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateDeletionMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateDeletionMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
+
+ assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv)
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest15() throws PcepParseException {
+
+ /* SRP, LSP (StatefulIPv4LspIdentidiersTlv).
+ */
+ byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x2c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20};
+
+ byte[] testInitiateDeletionMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateDeletionMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateDeletionMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateDeletionMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
+
+ assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest16() throws PcepParseException {
+
+ //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest17() throws PcepParseException {
+
+ //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest18() throws PcepParseException {
+ //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp(all tlvs),end-point,ero,lspa,bandwidth,metric-list
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest19() throws PcepParseException {
+ //srp,lsp(all tlvs),end-point,ero,lspa,bandwidth,metric-list
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x74,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x04, //ERO object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, srp,
+ * lsp(SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv) objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest20() throws PcepParseException {
+ /* srp,lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, srp,
+ * lsp(SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv).
+ */
+ byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x64,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20};
+
+ byte[] testInitiateDeletionMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateDeletionMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateDeletionMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateDeletionMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
+
+ assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest21() throws PcepParseException {
+ /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
+ * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x94,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest22() throws PcepParseException {
+ /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
+ * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA8,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest23() throws PcepParseException {
+ /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
+ * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
+ */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xB0,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest24() throws PcepParseException {
+ /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
+ * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth*/
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xBC,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,
+ * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest25() throws PcepParseException {
+
+ /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,
+ * srp,lsp(StatefulIPv4LspIdentidiersTlv),
+ * end-point,ero,lspa,bandwidth,metric-list */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xC4,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,metric-list,
+ * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest26() throws PcepParseException {
+
+ /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,metric-list,
+ * srp,lsp(StatefulIPv4LspIdentidiersTlv),
+ * end-point,ero,lspa,bandwidth,metric-list */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xD0,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+
+ /**
+ * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list,
+ * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list
+ * objects in PcInitiate message.
+ */
+ @Test
+ public void initiateMessageTest27() throws PcepParseException {
+
+ /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list,
+ * srp,lsp(StatefulIPv4LspIdentidiersTlv),
+ * end-point,ero,lspa,bandwidth,metric-list */
+ byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xE4,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
+ 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
+
+ byte[] testInitiateCreationMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(initiateCreationMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepInitiateMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testInitiateCreationMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testInitiateCreationMsg = new byte[iReadLen];
+ buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
+
+ assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java
new file mode 100644
index 00000000..56cf06b4
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Assert;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+
+public class PcepKeepaliveMsgTest {
+
+ /**
+ * Common header for keep alive message.
+ */
+ @Test
+ public void keepaliveMessageTest1() throws PcepParseException {
+
+ byte[] keepaliveMsg = new byte[] {0x20, 0x02, 0x00, 0x04 };
+
+ byte[] testKeepaliveMsg = {0 };
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(keepaliveMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+ assertThat(message, instanceOf(PcepKeepaliveMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ message.writeTo(buf);
+
+ testKeepaliveMsg = buf.array();
+
+ int iReadLen = buf.writerIndex();
+ testKeepaliveMsg = new byte[iReadLen];
+ buf.readBytes(testKeepaliveMsg, 0, iReadLen);
+
+ Assert.assertThat(testKeepaliveMsg, is(keepaliveMsg));
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java
new file mode 100644
index 00000000..e1947bd7
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java
@@ -0,0 +1,402 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+
+public class PcepLabelUpdateMsgTest {
+
+ /**
+ * This test case checks for
+ * <pce-label-download> SRP, LSP, LABEL Object.
+ * in PcepLabelUpdate message.
+ */
+ @Test
+ public void labelUpdateMessageTest1() throws PcepParseException {
+
+ byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x24, // common header
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10,
+ 0x20, 0x10, 0x00, 0x08, // LSP Object Header
+ 0x00, 0x01, 0x00, 0x00,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(labelUpdate);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testLabelUpdateMsg = {0};
+ assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
+
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testLabelUpdateMsg = new byte[readLen];
+ buf.readBytes(testLabelUpdateMsg, 0, readLen);
+
+ assertThat(testLabelUpdateMsg, is(labelUpdate));
+ }
+
+ /**
+ * This test case checks for
+ * <pce-label-download> SRP, LSP, LABEL Object, LABEL Object.
+ * in PcepLabelUpdate message.
+ */
+ @Test
+ public void labelUpdateMessageTest2() throws PcepParseException {
+
+ byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x30, // common header
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10,
+ 0x20, 0x10, 0x00, 0x08, // LSP Object Header
+ 0x00, 0x01, 0x00, 0x00,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x77};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(labelUpdate);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testLabelUpdateMsg = {0};
+ assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testLabelUpdateMsg = new byte[readLen];
+ buf.readBytes(testLabelUpdateMsg, 0, readLen);
+
+ assertThat(testLabelUpdateMsg, is(labelUpdate));
+ }
+
+ /**
+ * This test case checks for
+ * <pce-label-map> SRP, LABEL, FEC Object.
+ * in PcepLabelUpdate message.
+ */
+ @Test
+ public void labelUpdateMessageTest3() throws PcepParseException {
+
+ byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x24, // common header
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x24, 0x10, 0x00, 0x08, // FEC Object Header
+ 0x0A, 0x0A, 0x0B, 0x0B};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(labelUpdate);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testLabelUpdateMsg = {0};
+ assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testLabelUpdateMsg = new byte[readLen];
+ buf.readBytes(testLabelUpdateMsg, 0, readLen);
+
+ assertThat(testLabelUpdateMsg, is(labelUpdate));
+ }
+
+ /**
+ * This test case checks for
+ * <pce-label-download> SRP, LSP, LABEL, LABEL, <pce-label-download> SRP, LSP, LABEL
+ * in PcepLabelUpdate message.
+ */
+ @Test
+ public void labelUpdateMessageTest4() throws PcepParseException {
+
+ byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10,
+ 0x20, 0x10, 0x00, 0x08, // LSP Object Header
+ 0x00, 0x01, 0x00, 0x00,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x77,
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x20, 0x10, 0x00, 0x08, // LSP Object Header
+ 0x00, 0x02, 0x00, 0x00,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x44};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(labelUpdate);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testLabelUpdateMsg = {0};
+ assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testLabelUpdateMsg = new byte[readLen];
+ buf.readBytes(testLabelUpdateMsg, 0, readLen);
+
+ assertThat(testLabelUpdateMsg, is(labelUpdate));
+ }
+
+ /**
+ * This test case checks for
+ * <pce-label-map> SRP, LABEL, FEC, <pce-label-map> SRP, LABEL, FEC.
+ * in PcepLabelUpdate message.
+ */
+ @Test
+ public void labelUpdateMessageTest5() throws PcepParseException {
+
+ byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x44, // common header
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x01,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x24, 0x10, 0x00, 0x08, // FEC Object Header
+ 0x0A, 0x0A, 0x0B, 0x0B,
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x24, 0x10, 0x00, 0x08, // FEC Object Header
+ 0x0A, 0x0A, 0x0C, 0x0C};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(labelUpdate);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testLabelUpdateMsg = {0};
+ assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testLabelUpdateMsg = new byte[readLen];
+ buf.readBytes(testLabelUpdateMsg, 0, readLen);
+
+ assertThat(testLabelUpdateMsg, is(labelUpdate));
+ }
+
+ /**
+ * This test case checks for
+ * <pce-label-download> SRP, LSP, LABEL, LABEL, <pce-label-download> SRP, LABEL, FEC.
+ * in PcepLabelUpdate message.
+ */
+ @Test
+ public void labelUpdateMessageTest6() throws PcepParseException {
+
+ byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10,
+ 0x20, 0x10, 0x00, 0x08, // LSP Object Header
+ 0x00, 0x01, 0x00, 0x00,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x77,
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x12,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x24, 0x10, 0x00, 0x08, // FEC Object Header
+ 0x0A, 0x0A, 0x0D, 0x0D};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(labelUpdate);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testLabelUpdateMsg = {0};
+ assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testLabelUpdateMsg = new byte[readLen];
+ buf.readBytes(testLabelUpdateMsg, 0, readLen);
+
+ assertThat(testLabelUpdateMsg, is(labelUpdate));
+ }
+
+ /**
+ * This test case checks for
+ * <pce-label-download> SRP, LABEL, FEC, <pce-label-download> SRP, LSP, LABEL, LABEL.
+ * in PcepLabelUpdate message.
+ */
+ @Test
+ public void labelUpdateMessageTest7() throws PcepParseException {
+
+ byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x12,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x24, 0x10, 0x00, 0x08, // FEC Object Header
+ 0x0A, 0x0A, 0x0D, 0x0D,
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10,
+ 0x20, 0x10, 0x00, 0x08, // LSP Object Header
+ 0x00, 0x01, 0x00, 0x00,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x77};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(labelUpdate);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testLabelUpdateMsg = {0};
+ assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testLabelUpdateMsg = new byte[readLen];
+ buf.readBytes(testLabelUpdateMsg, 0, readLen);
+
+ assertThat(testLabelUpdateMsg, is(labelUpdate));
+ }
+
+ /**
+ * This test case checks for
+ * <pce-label-download> SRP, LABEL, FEC, <pce-label-download> SRP, LSP, LABEL, LABEL.
+ * <pce-label-download> SRP, LSP, LABEL, LABEL.
+ * in PcepLabelUpdate message.
+ */
+ @Test
+ public void labelUpdateMessageTest8() throws PcepParseException {
+
+ byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x7C, // common header
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x12,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x24, 0x10, 0x00, 0x08, // FEC Object Header
+ 0x0A, 0x0A, 0x0D, 0x0D,
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10,
+ 0x20, 0x10, 0x00, 0x08, // LSP Object Header
+ 0x00, 0x01, 0x00, 0x00,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x77,
+ 0x21, 0x10, 0x00, 0x0C, // SRP Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x10,
+ 0x20, 0x10, 0x00, 0x08, // LSP Object Header
+ 0x00, 0x01, 0x00, 0x00,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x66,
+ 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x77};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(labelUpdate);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testLabelUpdateMsg = {0};
+
+ assertThat(message, instanceOf(PcepLabelUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testLabelUpdateMsg = new byte[readLen];
+ buf.readBytes(testLabelUpdateMsg, 0, readLen);
+
+ assertThat(testLabelUpdateMsg, is(labelUpdate));
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java
new file mode 100644
index 00000000..6e0a0596
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java
@@ -0,0 +1,558 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+/**
+ * Test cases for PCEP OPEN Message.
+ */
+public class PcepOpenMsgTest {
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
+ * PCECC-CAPABILITY-TLV in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest1() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x10, 0x00, 0x20, 0x20, 0x1e, 0x78, (byte) 0xbd,
+ 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
+ 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
+ };
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY-TLV in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest2() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header
+ 0x01, 0x10, 0x00, 0x10, // common object header
+ 0x20, 0x1E, 0x78, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f}; // STATEFUL-PCE-CAPABILITY
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with GmplsCapability tlv in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest3() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header
+ 0x01, 0x10, 0x00, 0x10, // common object header
+ 0x20, 0x1E, 0x78, 0x01, // OPEN object
+ 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}; //GMPLS-CAPABILITY-TLV
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with StatefulLspDbVer Tlv in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest4() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18,
+ 0x01, 0x10, 0x00, 0x14, 0x20, 0x1e, 0x78, 0x20,
+ 0x00, 0x17, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; //StatefulLspDbVerTlv
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with no tlv's in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest5() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0C,
+ 0x01, 0x10, 0x00, 0x08, 0x20, 0x1e, 0x78, (byte) 0xbd }; // no Tlvs in open messsage
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV
+ * with I bit set in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest6() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x11, 0x00, 0x20, //p bit not set & i bit set
+ 0x20, 0x1e, 0x78, (byte) 0xbd,
+ 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
+ };
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV
+ * with P bit set in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest7() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x12, 0x00, 0x20, //p bit set & i bit not set
+ 0x20, 0x1e, 0x78, (byte) 0xbd,
+ 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
+ 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
+ };
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV
+ * with P & I bits set in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest8() throws PcepParseException {
+
+ /* OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV)
+ with p bit set & i bit set.
+ */
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x13, 0x00, 0x20, //p bit set & i bit set
+ 0x20, 0x1e, 0x78, (byte) 0xbd,
+ 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
+ 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
+ };
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV
+ * with P & I bits set and invalid session id in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest9() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x13, 0x00, 0x20, //p bit set & i bit set
+ 0x20, 0x1e, 0x78, 0x00, //invalid sessionID
+ 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
+ 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
+ 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
+ };
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV
+ * in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest10() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1C, // common header
+ 0x01, 0x10, 0x00, 0x18, // common object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x00, 0x00, 0x05,
+ 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00};
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
+ * PCECC-CAPABILITY-TLV, TED Capability TLV in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest11() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x2C, // common header
+ 0x01, 0x10, 0x00, 0x28, // common object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV
+ 0x00, 0x00, 0x00, 0x00 };
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV,
+ * PCECC-CAPABILITY-TLV in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest12() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, // common header
+ 0x01, 0x10, 0x00, 0x20, // common object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x03};
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV
+ * in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest13() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1c, // common header
+ 0x01, 0x10, 0x00, 0x18, // common object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00};
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with STATEFUL-PCE-CAPABILITY in Pcep Open message.
+ */
+ @Test
+ public void openMessageTest14() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header
+ 0x01, 0x10, 0x00, 0x10, // common object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
+ 0x00, 0x00, 0x00, 0x05};
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+
+ /**
+ * This test case checks open object with no tlv Pcep Open message.
+ */
+ @Test
+ public void openMessageTest15() throws PcepParseException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0c, // common header
+ 0x01, 0x10, 0x00, 0x08, // common object header
+ 0x20, 0x05, 0x1E, 0x01 // OPEN object
+ };
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java
new file mode 100644
index 00000000..f9921efd
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+
+public class PcepReportMsgExtTest {
+
+ /**
+ * This test case checks forSRP Object,LSP Object(symbolic path tlv),ERO Object
+ * SRP Object,LSP Object(symbolic path tlv,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest39() throws PcepParseException {
+
+ byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x98,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object
+ * SRP Object,LSP Object(symbolic path tlv),ERO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest40() throws PcepParseException {
+
+ byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x64,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
+ * SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest41() throws PcepParseException {
+
+ byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x8c,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,
+ * Metric-list SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,Metric-list,
+ * RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest42() throws PcepParseException {
+
+ byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0xE8,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java
new file mode 100644
index 00000000..c9e2bc8b
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java
@@ -0,0 +1,1597 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+
+public class PcepReportMsgTest {
+
+ /**
+ * This test case checks for SRP object, LSP object(Symbolic path name tlv), ERO object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest1() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, 0x24,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x04}; //ERO Object
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv
+ * StatefulLspErrorCodeTlv) ERO Object, LSPA Object, Metric-list, IRO object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest2() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x7c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object // LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, // IPv4SubObjects
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ };
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv,StatefulLspErrorCodeTlv)
+ * ERO Object, LSPA Object, Metric-list, IRO object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest3() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70,
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //Ipv4SubObjects
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric Objects
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ };
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv,StatefulLspErrorCodeTlv)
+ * ERO Object, LSPA Object, Metric-list
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest4() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x64,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv
+ * StatefulLspErrorCodeTlv) ERO Object, IRO object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest5() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x50,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv
+ * StatefulLspErrorCodeTlv) ERO Object, LSPA Object, Metric-list.
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest6() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x04, //ERO Object
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ };
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object, ERO Object, LSPA Object, Metric-list, IRO object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest7() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, // Metric objects
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP object, LSP object( StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv) ERO object, LSPA object, Metric object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest8() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,
+ * StatefulLspErrorCodeTlv ),ERO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest9() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x44,
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(StatefulIPv4LspIdentidiersTlv)ERO Object,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest10() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(SymbolicPathNameTlv)ERO Object,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest11() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object, ERO Object,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest12() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x60,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(StatefulLspErrorCodeTlv)ERO Object,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest13() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(StatefulRsvpErrorSpecTlv),ERO Object,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest14() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x60,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path tlv),LSPA Object,ERO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest15() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x7C,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path tlv),BandWidth Object,ERO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest16() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object,ERO Object,LSPA Object,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest17() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object,ERO Object,BandWidth Object,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest18() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object,ERO Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest19() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6C,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest20() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x88,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,
+ * StatefulLspErrorCodeTlv ) ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest21() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xac,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
+ * ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest22() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xA0,
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
+ * ERO Object,BandWidth Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest23() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8c,
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
+ * ERO Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest24() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x84,
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
+ * ERO Object,LSPA Object,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest25() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8c,
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
+ * ERO Object,LSPA Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest26() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x58,
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv)
+ * ERO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest27() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x44,
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv )
+ * LSPA Object,BandWidth Object,Metric-list,ERO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest28() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6c,
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest29() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object
+ * SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest30() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xE4,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
+ * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv)
+ * ERO Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest31() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, 0x00,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
+ * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv)
+ * ERO Object,LSPA Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest32() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, (byte) 0x14,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object
+ * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv)
+ * ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest33() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, (byte) 0x1c,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00};
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object(symbolic path Tlv),ERO Object,LSPA Object
+ * BandWidth Object,Metric-list,SRP Object,LSP Object(symbolic path tlv)
+ * ERO Object,LSPA Object,BandWidth Object,Metric-list
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest34() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xB4,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x04, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * This test case checks for SRP Object,LSP Object)Symbolic path tlv),ERO Object,SRP Object
+ * LSP Object(symbolic path tlv) ERO Object,LSPA Object, BandWidth Object,Metric-list
+ * in PcRpt message.
+ */
+ @Test
+ public void reportMessageTest35() throws PcepParseException {
+
+ byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8C,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, //ERO Object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, //LSPA Object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepTEReportMsgTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepTEReportMsgTest.java
new file mode 100644
index 00000000..e401c159
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepTEReportMsgTest.java
@@ -0,0 +1,1596 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+
+public class PcepTEReportMsgTest {
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV, Local TE Node Descriptors TLV(AutonomousSystemTlv)).
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest1() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x28, // common header
+ 0x0E, 0x10, 0x00, 0x24, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x08, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystem Tlv
+ 0x00, 0x00, 0x00, 0x11};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * T E Object (Routing Universe TLV, Local TE Node Descriptors TLV(AutonomousSystemTlv)) with different TE-ID.
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest2() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x28, // common header
+ 0x0E, 0x10, 0x00, 0x24, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x08, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for TE Object (Routing Universe TLV)
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest3() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x1c, // common header
+ 0x0E, 0x10, 0x00, 0x18, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv.
+ * OSPFareaIDsubTlv, RouterIDSubTlv)).
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest4() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x44, // common header
+ 0x0E, 0x10, 0x00, 0x40, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest5() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x3C, // common header
+ 0x0E, 0x10, 0x00, 0x38, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x1C, // Local TE Node Descriptors TLV
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(OSPFareaIDsubTlv,
+ * RouterIDSubTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest6() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x34, // common header
+ 0x0E, 0x10, 0x00, 0x30, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x14, // Local TE Node Descriptors TLV
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(RouterIDSubTlv)).
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest7() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x2C, // common header
+ 0x0E, 0x10, 0x00, 0x28, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x0C, // Local TE Node Descriptors TLV
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11};
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for TE Object (Routing Universe TLV,Local TE Node Descriptors TLV)
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest8() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x20, // common header
+ 0x0E, 0x10, 0x00, 0x1C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x00 // Local TE Node Descriptors TLV
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv.
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv.
+ * OSPFareaIDsubTlv, RouterIDSubTlv)).
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest9() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x6C, // common header
+ 0x0E, 0x10, 0x00, 0x68, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest10() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x64, // common header
+ 0x0E, 0x10, 0x00, 0x60, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x1C, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(OSPFareaIDsubTlv, RouterIDSubTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest11() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x5C, // common header
+ 0x0E, 0x10, 0x00, 0x58, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x14, //RemoteTENodeDescriptorsTLV
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(RouterIDSubTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest12() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x54, // common header
+ 0x0E, 0x10, 0x00, 0x50, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x0c, //RemoteTENodeDescriptorsTLV
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV)
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest13() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x48, // common header
+ 0x0E, 0x10, 0x00, 0x44, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x00, //RemoteTENodeDescriptorsTLV
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv
+ * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest14() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x8C, // common header
+ 0x0E, 0x10, 0x00, (byte) 0x88, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV
+ 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv
+ 0x01, 0x11, 0x00, 0x09,
+ 0x01, 0x21, 0x00, 0x09,
+ 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(
+ * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest15() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x80, // common header
+ 0x0E, 0x10, 0x00, (byte) 0x7C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x10, //TELinkDescriptorsTLV
+ 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(IPv4NeighborAddressTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest16() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x78, // common header
+ 0x0E, 0x10, 0x00, (byte) 0x74, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x08, //TELinkDescriptorsTLV
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV)
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest17() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x70, // common header
+ 0x0E, 0x10, 0x00, (byte) 0x6C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x00, //TELinkDescriptorsTLV
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv
+ * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest18() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xC0, // common header
+ 0x0E, 0x10, 0x00, (byte) 0xbC, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV
+ 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv
+ 0x01, 0x11, 0x00, 0x09,
+ 0x01, 0x21, 0x00, 0x09,
+ 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x04, (byte) 0xF3, 0x00, 0x30, //TENodeAttributesTlv
+ 0x00, 0x0E, 0x00, 0x01, //NodeFlagBitsTlv
+ (byte) 0x90, 0x00, 0x00, 0x00,
+ 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv
+ 0x08, 0x00, 0x01, 0x09,
+ 0x08, 0x00, 0x01, 0x09,
+ 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv
+ 0x20, 0x01, 0x22, 0x01,
+ 0x20, 0x01, 0x22, 0x01,
+ 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv
+ 0x00, 0x01, 0x01, 0x02
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv
+ * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv
+ * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest19() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xC0, // common header
+ 0x0E, 0x10, 0x00, (byte) 0xBC, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV
+ 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv
+ 0x01, 0x11, 0x00, 0x09,
+ 0x01, 0x21, 0x00, 0x09,
+ 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x04, (byte) 0xF3, 0x00, 0x30, //TENodeAttributesTlv
+ 0x00, 0x0E, 0x00, 0x01, //NodeFlagBitsTlv
+ (byte) 0x90, 0x00, 0x00, 0x00,
+ 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv
+ 0x08, 0x00, 0x01, 0x09,
+ 0x08, 0x00, 0x01, 0x09,
+ 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv
+ 0x20, 0x01, 0x22, 0x01,
+ 0x20, 0x01, 0x22, 0x01,
+ 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv
+ 0x00, 0x01, 0x01, 0x02
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv
+ * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(OpaqueNodeAttributeTlv
+ * NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest20() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xB8, // common header
+ 0x0E, 0x10, 0x00, (byte) 0xB4, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV
+ 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv
+ 0x01, 0x11, 0x00, 0x09,
+ 0x01, 0x21, 0x00, 0x09,
+ 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv
+ 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv
+ 0x08, 0x00, 0x01, 0x09,
+ 0x08, 0x00, 0x01, 0x09,
+ 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv
+ 0x20, 0x01, 0x22, 0x01,
+ 0x20, 0x01, 0x22, 0x01,
+ 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv
+ 0x00, 0x01, 0x01, 0x02
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv.
+ * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(OpaqueNodeAttributeTlv
+ * ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest21() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xAC, // common header
+ 0x0E, 0x10, 0x00, (byte) 0xA8, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV
+ 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv
+ 0x01, 0x11, 0x00, 0x09,
+ 0x01, 0x21, 0x00, 0x09,
+ 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x04, (byte) 0xF3, 0x00, 0x1C, //TENodeAttributesTlv
+ 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv
+ 0x20, 0x01, 0x22, 0x01,
+ 0x20, 0x01, 0x22, 0x01,
+ 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv
+ 0x00, 0x01, 0x01, 0x02
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv.
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv.
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv.
+ * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv.
+ * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv).
+ * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv.
+ * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv.
+ * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv:, SharedRiskLinkGroupTlv.
+ * OpaqueLinkAttributeTlv, LinkNameTlv)).
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest22() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x120, // common header
+ 0x0E, 0x10, 0x01, (byte) 0x1C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV
+ 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv
+ 0x01, 0x11, 0x00, 0x09,
+ 0x01, 0x21, 0x00, 0x09,
+ 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv
+ 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv
+ 0x08, 0x00, 0x01, 0x09,
+ 0x08, 0x00, 0x01, 0x09,
+ 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv
+ 0x20, 0x01, 0x22, 0x01,
+ 0x20, 0x01, 0x22, 0x01,
+ 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv
+ 0x00, 0x01, 0x01, 0x02,
+ 0x07, 0x69, 0x00, 0x64, //TELinkAttributesTlv
+ 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv
+ 0x00, 0x07, 0x08, 0x00,
+ 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv
+ 0x00, 0x09, 0x08, 0x00,
+ 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv
+ 0x00, 0x09, 0x00, 0x00,
+ 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv
+ 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv
+ 0x00, 0x00, (byte) 0x90, 0x00,
+ 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv
+ 0x00, (byte) 0x99, 0x09, 0x00,
+ 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv
+ 0x09, 0x00, 0x00, 0x00,
+ 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv
+ (byte) 0x80, 0x00, 0x00, 0x00,
+ 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv
+ 0x09, (byte) 0x89, 0x07, 0x00,
+ 0x04, 0x48, 0x00, 0x08, //SharedRiskLinkGroupTlv
+ 0x04, 0x47, 0x00, 0x03,
+ 0x04, 0x47, 0x00, 0x03, //OpaqueLinkAttributeTlv
+ 0x04, 0x49, 0x00, 0x04,
+ 0x04, 0x47, 0x00, 0x03,
+ 0x04, 0x4A, 0x00, 0x04, //LinkNameTlv
+ 0x04, 0x47, 0x00, 0x03
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv
+ * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv
+ * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv)
+ * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv
+ * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv
+ * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv:, SharedRiskLinkGroupTlv
+ * OpaqueLinkAttributeTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest23() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x118, // common header
+ 0x0E, 0x10, 0x01, (byte) 0x14, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV
+ 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv
+ 0x01, 0x11, 0x00, 0x09,
+ 0x01, 0x21, 0x00, 0x09,
+ 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv
+ 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv
+ 0x08, 0x00, 0x01, 0x09,
+ 0x08, 0x00, 0x01, 0x09,
+ 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv
+ 0x20, 0x01, 0x22, 0x01,
+ 0x20, 0x01, 0x22, 0x01,
+ 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv
+ 0x00, 0x01, 0x01, 0x02,
+ 0x07, 0x69, 0x00, 0x5C, //TELinkAttributesTlv
+ 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv
+ 0x00, 0x07, 0x08, 0x00,
+ 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv
+ 0x00, 0x09, 0x08, 0x00,
+ 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv
+ 0x00, 0x09, 0x00, 0x00,
+ 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv
+ 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv
+ 0x00, 0x00, (byte) 0x90, 0x00,
+ 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv
+ 0x00, (byte) 0x99, 0x09, 0x00,
+ 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv
+ 0x09, 0x00, 0x00, 0x00,
+ 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv
+ (byte) 0x80, 0x00, 0x00, 0x00,
+ 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv
+ 0x09, (byte) 0x89, 0x07, 0x00,
+ 0x04, 0x48, 0x00, 0x08, //SharedRiskLinkGroupTlv
+ 0x04, 0x47, 0x00, 0x03,
+ 0x04, 0x47, 0x00, 0x03, //OpaqueLinkAttributeTlv
+ 0x04, 0x49, 0x00, 0x04,
+ 0x04, 0x47, 0x00, 0x03
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv
+ * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv
+ * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv)
+ * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv
+ * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv
+ * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv:, SharedRiskLinkGroupTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest24() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x110, // common header
+ 0x0E, 0x10, 0x01, (byte) 0x0C, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV
+ 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv
+ 0x01, 0x11, 0x00, 0x09,
+ 0x01, 0x21, 0x00, 0x09,
+ 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv
+ 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv
+ 0x08, 0x00, 0x01, 0x09,
+ 0x08, 0x00, 0x01, 0x09,
+ 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv
+ 0x20, 0x01, 0x22, 0x01,
+ 0x20, 0x01, 0x22, 0x01,
+ 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv
+ 0x00, 0x01, 0x01, 0x02,
+ 0x07, 0x69, 0x00, 0x54, //TELinkAttributesTlv
+ 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv
+ 0x00, 0x07, 0x08, 0x00,
+ 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv
+ 0x00, 0x09, 0x08, 0x00,
+ 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv
+ 0x00, 0x09, 0x00, 0x00,
+ 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv
+ 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv
+ 0x00, 0x00, (byte) 0x90, 0x00,
+ 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv
+ 0x00, (byte) 0x99, 0x09, 0x00,
+ 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv
+ 0x09, 0x00, 0x00, 0x00,
+ 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv
+ (byte) 0x80, 0x00, 0x00, 0x00,
+ 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv
+ 0x09, (byte) 0x89, 0x07, 0x00,
+ 0x04, 0x48, 0x00, 0x08, //SharedRiskLinkGroupTlv
+ 0x04, 0x47, 0x00, 0x03,
+ 0x04, 0x47, 0x00, 0x03
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+
+ /**
+ * This test case checks for
+ * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv
+ * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv
+ * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv
+ * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv)
+ * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv
+ * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv
+ * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv))
+ * in PcTERpt message.
+ */
+ @Test
+ public void teReportMessageTest25() throws PcepParseException {
+
+ byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x104, // common header
+ 0x0E, 0x10, 0x01, 0x00, // TE Object Header
+ 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID
+ 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV
+ 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv
+ 0x00, 0x00, 0x00, 0x11,
+ 0x00, 0x00, 0x00, 0x11,
+ 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV
+ 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv
+ 0x01, 0x11, 0x00, 0x09,
+ 0x01, 0x21, 0x00, 0x09,
+ 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv
+ 0x01, 0x01, 0x01, 0x01,
+ 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv
+ 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv
+ 0x01, 0x011, 0x01, 0x10,
+ 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv
+ 0x08, 0x00, 0x01, 0x09,
+ 0x08, 0x00, 0x01, 0x09,
+ 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv
+ 0x20, 0x01, 0x22, 0x01,
+ 0x20, 0x01, 0x22, 0x01,
+ 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv
+ 0x00, 0x01, 0x01, 0x02,
+ 0x07, 0x69, 0x00, 0x48, //TELinkAttributesTlv
+ 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv
+ 0x00, 0x07, 0x08, 0x00,
+ 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv
+ 0x00, 0x09, 0x08, 0x00,
+ 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv
+ 0x00, 0x09, 0x00, 0x00,
+ 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv
+ 0x00, 0x10, 0x00, 0x00,
+ 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv
+ 0x00, 0x00, (byte) 0x90, 0x00,
+ 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv
+ 0x00, (byte) 0x99, 0x09, 0x00,
+ 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv
+ 0x09, 0x00, 0x00, 0x00,
+ 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv
+ (byte) 0x80, 0x00, 0x00, 0x00,
+ 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv
+ 0x09, (byte) 0x89, 0x07, 0x00
+ };
+
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(teReportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ byte[] testReportMsg = {0};
+
+ assertThat(message, instanceOf(PcepTEReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(teReportMsg));
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java
new file mode 100644
index 00000000..40234a69
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java
@@ -0,0 +1,1269 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for PCEP update message.
+ */
+public class PcepUpdateMsgExtTest {
+
+ /**
+ * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object,
+ * Metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest1() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x8c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
+ * LSPA, Bandwidth object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest2() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSP object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object, ERO object, LSPA, bandwidth object
+ * Metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest3() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,bandwidth object
+ * Metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest4() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,bandwidth object
+ * Metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest5() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object, LSPA, bandwidth object
+ * Metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest6() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
+ * bandwidth object Metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest7() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA
+ * bandwidth object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest8() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA
+ * bandwidth object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest9() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x18, 0x00, 0x00, 0x10, 0x03,
+ 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
+ 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA
+ * bandwidth object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest10() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPa object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA
+ * bandwidth object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest11() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA
+ * bandwidth object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest12() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,LSPA
+ * bandwidth object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest13() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA
+ * metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest14() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object, ERO object,LSPA
+ * metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest15() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //lspa object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,LSPA
+ * metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest16() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA
+ * metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest17() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA
+ * metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest18() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
+ * metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest19() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
+ * Bandwidth , metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest20() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object, ERO object,
+ * Bandwidth , metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest21() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,
+ * Bandwidth , metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest22() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,
+ * Bandwidth , metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest23() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,
+ * Bandwidth , metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest24() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,
+ * Bandwidth , metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest25() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,
+ * LSPA object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest26() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object, ERO object,
+ * bandwidth object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest27() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x34,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,
+ * metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest28() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
+ * lspa object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest29() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
+ * bandwidth object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest30() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object,
+ * metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest31() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object,
+ * Metric object in PcepUpdate message.
+ */
+ @Test
+ public void pcepUpdateMsgTest32() throws PcepParseException {
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+}
+
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java
new file mode 100644
index 00000000..1db30641
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java
@@ -0,0 +1,1423 @@
+/*
+ * Copyright 2014-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.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Test;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.core.Is.is;
+
+public class PcepUpdateMsgTest {
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), ERO in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest1() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x30,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
+ 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x04 }; //ERO object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP(SymbolicPathNameTlv), LSP (StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO, LSPA, Metric-list in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest2() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x94,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object // lsp object
+ 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
+ 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x24, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
+ 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
+ * ERO objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest3() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x38,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x04 }; //ERO object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv), ERO objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest4() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x04 }; //ERO object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv), ERO objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest5() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x04 }; //ERO object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv), ERO objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest6() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x04 };
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv), ERO objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest7() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x04}; //ERO object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv), ERO (IPv4SubObject) objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest8() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x0c, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00 };
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject) objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest9() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00 };
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject), LSPA objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest10() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x6c,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest11() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest12() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest13() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+ * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric Object objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest14() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
+ * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest15() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest16() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * ERO (IPv4SubObject, IPv4SubObject),LSPA objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest17() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x05, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * ERO (IPv4SubObject, IPv4SubObject),Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest18() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * ERO (IPv4SubObject, IPv4SubObject),Metric-list objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest19() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv),ERO (IPv4SubObject, IPv4SubObject),LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest20() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * ERO (IPv4SubObject, IPv4SubObject), Bandwidth objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest21() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest22() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5C,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest23() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
+ * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest24() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
+ * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest25() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth,
+ * Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest26() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
+ * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth,
+ * Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest27() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv,
+ * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),
+ * LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest28() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv),
+ * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest29() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
+ (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP,
+ * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest30() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (StatefulLspErrorCodeTlv),
+ * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest31() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP,
+ * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest32() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv),
+ * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest33() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
+ 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+
+ /**
+ * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv),
+ * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message.
+ */
+ @Test
+ public void pcepUpdateMsgTest34() throws PcepParseException {
+
+ byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
+ 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00,
+ 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
+ 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
+ 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
+
+ byte[] testupdateMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(updateMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepUpdateMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testupdateMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testupdateMsg = new byte[readLen];
+ buf.readBytes(testupdateMsg, 0, readLen);
+
+ assertThat(testupdateMsg, is(updateMsg));
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupTlvTest.java
new file mode 100644
index 00000000..41e88445
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupTlvTest.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the AdministrativeGroupTlv.
+ */
+public class AdministrativeGroupTlvTest {
+ private final AdministrativeGroupTlv tlv1 = AdministrativeGroupTlv.of(1);
+ private final AdministrativeGroupTlv sameAsTlv1 = AdministrativeGroupTlv.of(1);
+ private final AdministrativeGroupTlv tlv2 = AdministrativeGroupTlv.of(2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemTlvTest.java
new file mode 100644
index 00000000..904a71ef
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemTlvTest.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the AutonomousSystemTlv.
+ */
+public class AutonomousSystemTlvTest {
+ private final AutonomousSystemTlv tlv1 = AutonomousSystemTlv.of(1);
+ private final AutonomousSystemTlv sameAsTlv1 = AutonomousSystemTlv.of(1);
+ private final AutonomousSystemTlv tlv2 = AutonomousSystemTlv.of(2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BGPLSidentifierTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BGPLSidentifierTlvTest.java
new file mode 100644
index 00000000..7ac6cea4
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BGPLSidentifierTlvTest.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the BGPLSidentifierTlv.
+ */
+public class BGPLSidentifierTlvTest {
+ private final BGPLSidentifierTlv tlv1 = BGPLSidentifierTlv.of(1);
+ private final BGPLSidentifierTlv sameAsTlv1 = BGPLSidentifierTlv.of(1);
+ private final BGPLSidentifierTlv tlv2 = BGPLSidentifierTlv.of(2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java
new file mode 100644
index 00000000..7972712f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the GmplsCapabilityTlv.
+ */
+public class GmplsCapabilityTlvTest {
+ private final GmplsCapabilityTlv tlv1 = GmplsCapabilityTlv.of(1);
+ private final GmplsCapabilityTlv sameAsTlv1 = GmplsCapabilityTlv.of(1);
+ private final GmplsCapabilityTlv tlv2 = GmplsCapabilityTlv.of(2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IGPMetricTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IGPMetricTlvTest.java
new file mode 100644
index 00000000..2715a4d7
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IGPMetricTlvTest.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.pcepio.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IGPMetricTlv.
+ */
+public class IGPMetricTlvTest {
+ private final byte[] b1 = new byte[] {0x01, 0x02};
+ private final byte[] b2 = new byte[] {0x01, 0x03};
+ private final IGPMetricTlv tlv1 = IGPMetricTlv.of(b1, (short) 2);
+ private final IGPMetricTlv sameAsTlv1 = IGPMetricTlv.of(b1, (short) 2);
+ private final IGPMetricTlv tlv2 = IGPMetricTlv.of(b2, (short) 2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlvTest.java
new file mode 100644
index 00000000..eb3a16a8
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlvTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IPv4InterfaceAddressTlv.
+ */
+public class IPv4InterfaceAddressTlvTest {
+
+ private final IPv4InterfaceAddressTlv tlv1 = IPv4InterfaceAddressTlv.of(2);
+ private final IPv4InterfaceAddressTlv sameAsTlv1 = IPv4InterfaceAddressTlv.of(2);
+ private final IPv4InterfaceAddressTlv tlv2 = IPv4InterfaceAddressTlv.of(3);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlvTest.java
new file mode 100644
index 00000000..5f10b4c1
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlvTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IPv4NeighborAddressTlv.
+ */
+public class IPv4NeighborAddressTlvTest {
+
+ private final IPv4NeighborAddressTlv tlv1 = IPv4NeighborAddressTlv.of(2);
+ private final IPv4NeighborAddressTlv sameAsTlv1 = IPv4NeighborAddressTlv.of(2);
+ private final IPv4NeighborAddressTlv tlv2 = IPv4NeighborAddressTlv.of(3);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java
new file mode 100644
index 00000000..10f54015
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IPv4SubObject.
+ */
+public class IPv4SubObjectTest {
+
+ private final IPv4SubObject subObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0);
+ private final IPv4SubObject sameAsSubObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0);
+ private final IPv4SubObject subObj2 = IPv4SubObject.of(3, (byte) 16, (byte) 0);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(subObj1, sameAsSubObj1)
+ .addEqualityGroup(subObj2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlvTest.java
new file mode 100644
index 00000000..3880ca7f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlvTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IPv4TERouterIdOfLocalNodeTlv.
+ */
+public class IPv4TERouterIdOfLocalNodeTlvTest {
+
+ private final IPv4TERouterIdOfLocalNodeTlv tlv1 = IPv4TERouterIdOfLocalNodeTlv.of(2);
+ private final IPv4TERouterIdOfLocalNodeTlv sameAsTlv1 = IPv4TERouterIdOfLocalNodeTlv.of(2);
+ private final IPv4TERouterIdOfLocalNodeTlv tlv2 = IPv4TERouterIdOfLocalNodeTlv.of(3);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlvTest.java
new file mode 100644
index 00000000..f40ede04
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlvTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IPv4TERouterIdOfRemoteNodeTlv.
+ */
+public class IPv4TERouterIdOfRemoteNodeTlvTest {
+
+ private final IPv4TERouterIdOfRemoteNodeTlv tlv1 = IPv4TERouterIdOfRemoteNodeTlv.of(2);
+ private final IPv4TERouterIdOfRemoteNodeTlv sameAsTlv1 = IPv4TERouterIdOfRemoteNodeTlv.of(2);
+ private final IPv4TERouterIdOfRemoteNodeTlv tlv2 = IPv4TERouterIdOfRemoteNodeTlv.of(3);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlvTest.java
new file mode 100644
index 00000000..0f8e37c2
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlvTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IPv6InterfaceAddressTlv.
+ */
+public class IPv6InterfaceAddressTlvTest {
+
+ private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
+ private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x01};
+
+ private final IPv6InterfaceAddressTlv tlv1 = IPv6InterfaceAddressTlv.of(b1);
+ private final IPv6InterfaceAddressTlv sameAsTlv1 = IPv6InterfaceAddressTlv.of(b1);
+ private final IPv6InterfaceAddressTlv tlv2 = IPv6InterfaceAddressTlv.of(b2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlvTest.java
new file mode 100644
index 00000000..57ad7695
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlvTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IPv6NeighborAddressTlv.
+ */
+public class IPv6NeighborAddressTlvTest {
+
+ private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
+ private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x01};
+
+ private final IPv6NeighborAddressTlv tlv1 = IPv6NeighborAddressTlv.of(b1);
+ private final IPv6NeighborAddressTlv sameAsTlv1 = IPv6NeighborAddressTlv.of(b1);
+ private final IPv6NeighborAddressTlv tlv2 = IPv6NeighborAddressTlv.of(b2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java
new file mode 100644
index 00000000..f23b11d8
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IPv6SubObject.
+ */
+public class IPv6SubObjectTest {
+
+ private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
+ private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
+
+ private final IPv6SubObject subObj1 = IPv6SubObject.of(b1);
+ private final IPv6SubObject sameAsSubObj1 = IPv6SubObject.of(b1);
+ private final IPv6SubObject subObj2 = IPv6SubObject.of(b2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(subObj1, sameAsSubObj1).addEqualityGroup(subObj2).testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlvTest.java
new file mode 100644
index 00000000..6516ed3d
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlvTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IPv6TERouterIdofLocalNodeTlv.
+ */
+public class IPv6TERouterIdofLocalNodeTlvTest {
+
+ private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
+ private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
+
+ private final IPv6TERouterIdofLocalNodeTlv tlv1 = IPv6TERouterIdofLocalNodeTlv.of(b1);
+ private final IPv6TERouterIdofLocalNodeTlv sameAsTlv1 = IPv6TERouterIdofLocalNodeTlv.of(b1);
+ private final IPv6TERouterIdofLocalNodeTlv tlv2 = IPv6TERouterIdofLocalNodeTlv.of(b2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlvTest.java
new file mode 100644
index 00000000..f3828609
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlvTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the IPv6TERouterIdofRemoteNodeTlv.
+ */
+public class IPv6TERouterIdofRemoteNodeTlvTest {
+
+ private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00};
+ private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
+
+ private final IPv6TERouterIdofRemoteNodeTlv tlv1 = IPv6TERouterIdofRemoteNodeTlv.of(b1);
+ private final IPv6TERouterIdofRemoteNodeTlv sameAsTlv1 = IPv6TERouterIdofRemoteNodeTlv.of(b1);
+ private final IPv6TERouterIdofRemoteNodeTlv tlv2 = IPv6TERouterIdofRemoteNodeTlv.of(b2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlvTest.java
new file mode 100644
index 00000000..17584ac1
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlvTest.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the ISISAreaIdentifierTlv.
+ */
+public class ISISAreaIdentifierTlvTest {
+
+ private final byte[] b1 = new byte[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
+ private final byte[] b2 = new byte[] {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 };
+
+ private final ISISAreaIdentifierTlv tlv1 = ISISAreaIdentifierTlv.of(b1, (short) 20);
+ private final ISISAreaIdentifierTlv sameAsTlv1 = ISISAreaIdentifierTlv.of(b1, (short) 20);
+ private final ISISAreaIdentifierTlv tlv2 = ISISAreaIdentifierTlv.of(b2, (short) 20);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java
new file mode 100644
index 00000000..511d0a20
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the LabelSubObject.
+ */
+public class LabelSubObjectTest {
+
+ private final LabelSubObject subObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20);
+ private final LabelSubObject sameAsSubObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20);
+ private final LabelSubObject subObj2 = LabelSubObject.of((byte) 0, (byte) 1, 30);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(subObj1, sameAsSubObj1)
+ .addEqualityGroup(subObj2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlvTest.java
new file mode 100644
index 00000000..e25bda02
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlvTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the LinkLocalRemoteIdentifiersTlv.
+ */
+public class LinkLocalRemoteIdentifiersTlvTest {
+
+ private final LinkLocalRemoteIdentifiersTlv tlv1 = LinkLocalRemoteIdentifiersTlv.of(10, 20);
+ private final LinkLocalRemoteIdentifiersTlv sameAsTlv1 = LinkLocalRemoteIdentifiersTlv.of(10, 20);
+ private final LinkLocalRemoteIdentifiersTlv tlv2 = LinkLocalRemoteIdentifiersTlv.of(20, 30);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameTlvTest.java
new file mode 100644
index 00000000..7d9dcb26
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameTlvTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Equality test for LinkNameTlv.
+ */
+public class LinkNameTlvTest {
+ private final byte[] rawValue1 = new byte[] {0x01, 0x00};
+ private final byte[] rawValue2 = new byte[] {0x02, 0x00};
+
+ private final LinkNameTlv tlv1 = new LinkNameTlv(rawValue1, (short) rawValue1.length);
+ private final LinkNameTlv sameAsTlv1 = LinkNameTlv.of(tlv1.getValue(), tlv1.getLength());
+ private final LinkNameTlv tlv2 = new LinkNameTlv(rawValue2, (short) 0);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeTlvTest.java
new file mode 100644
index 00000000..61928f22
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeTlvTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the LinkProtectionTypeTlv.
+ */
+public class LinkProtectionTypeTlvTest {
+ private final byte rawValue1 = 0x0A;
+ private final byte rawValue2 = 0x0B;
+
+ private final LinkProtectionTypeTlv tlv1 = new LinkProtectionTypeTlv(rawValue1);
+ private final LinkProtectionTypeTlv sameAsTlv1 = new LinkProtectionTypeTlv(rawValue1);
+ private final LinkProtectionTypeTlv tlv2 = new LinkProtectionTypeTlv(rawValue2, (byte) 0);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlvTest.java
new file mode 100644
index 00000000..e8b6abcc
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlvTest.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.pcepio.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+import java.util.LinkedList;
+
+/**
+ * Test of the LocalTENodeDescriptorsTlv.
+ */
+public class LocalTENodeDescriptorsTlvTest {
+
+ private final AutonomousSystemTlv baAutoSysTlvRawValue1 = new AutonomousSystemTlv(1);
+ private final BGPLSidentifierTlv baBgplsIdRawValue1 = new BGPLSidentifierTlv(1);
+
+ private final AutonomousSystemTlv baAutoSysTlvRawValue2 = new AutonomousSystemTlv(2);
+ private final BGPLSidentifierTlv baBgplsIdRawValue2 = new BGPLSidentifierTlv(2);
+
+ private final LinkedList<PcepValueType> llNodeDescriptorSubTLVs1 = new LinkedList<PcepValueType>();
+ private final boolean a = llNodeDescriptorSubTLVs1.add(baAutoSysTlvRawValue1);
+ private final boolean b = llNodeDescriptorSubTLVs1.add(baBgplsIdRawValue1);
+
+ private final LinkedList<PcepValueType> llNodeDescriptorSubTLVs2 = new LinkedList<PcepValueType>();
+ private final boolean c = llNodeDescriptorSubTLVs2.add(baAutoSysTlvRawValue2);
+ private final boolean d = llNodeDescriptorSubTLVs2.add(baBgplsIdRawValue2);
+
+ private final LocalTENodeDescriptorsTlv tlv1 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1);
+ private final LocalTENodeDescriptorsTlv sameAstlv1 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1);
+ private final LocalTENodeDescriptorsTlv tlv2 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlvTest.java
new file mode 100644
index 00000000..5e79e284
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlvTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the MPLSProtocolMaskTlv.
+ */
+public class MPLSProtocolMaskTlvTest {
+ private final byte rawValue1 = 0x0A;
+ private final byte rawValue2 = 0x0B;
+
+ private final MPLSProtocolMaskTlv tlv1 = new MPLSProtocolMaskTlv(rawValue1);
+ private final MPLSProtocolMaskTlv sameAsTlv1 = new MPLSProtocolMaskTlv(rawValue1);
+ private final MPLSProtocolMaskTlv tlv2 = MPLSProtocolMaskTlv.of(rawValue2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlvTest.java
new file mode 100644
index 00000000..4e022b82
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlvTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the MaximumLinkBandwidthTlv.
+ */
+public class MaximumLinkBandwidthTlvTest {
+ private final int rawValue1 = 0x0A;
+ private final int rawValue2 = 0x0B;
+
+ private final MaximumLinkBandwidthTlv tlv1 = new MaximumLinkBandwidthTlv(rawValue1);
+ private final MaximumLinkBandwidthTlv sameAsTlv1 = new MaximumLinkBandwidthTlv(rawValue1);
+ private final MaximumLinkBandwidthTlv tlv2 = MaximumLinkBandwidthTlv.of(rawValue2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlvTest.java
new file mode 100644
index 00000000..7b370359
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlvTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the MaximumReservableLinkBandwidthTlv.
+ */
+public class MaximumReservableLinkBandwidthTlvTest {
+ private final int rawValue1 = 0x0A;
+ private final int rawValue2 = 0x0B;
+
+ private final MaximumReservableLinkBandwidthTlv tlv1 = new MaximumReservableLinkBandwidthTlv(rawValue1);
+ private final MaximumReservableLinkBandwidthTlv sameAsTlv1 = new MaximumReservableLinkBandwidthTlv(rawValue1);
+ private final MaximumReservableLinkBandwidthTlv tlv2 = MaximumReservableLinkBandwidthTlv.of(rawValue2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java
new file mode 100644
index 00000000..39c699bc
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Equality test for NexthopIPv4addressTlv.
+ */
+public class NexthopIPv4addressTlvTest {
+
+ private final NexthopIPv4addressTlv tlv1 = new NexthopIPv4addressTlv(0x0A);
+ private final NexthopIPv4addressTlv sameAsTlv1 = new NexthopIPv4addressTlv(0x0A);
+ private final NexthopIPv4addressTlv tlv2 = NexthopIPv4addressTlv.of(0x0B);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java
new file mode 100644
index 00000000..4621336e
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Equality test for NexthopIPv6addressTlv.
+ */
+public class NexthopIPv6addressTlvTest {
+
+ private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00 };
+ private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 };
+
+ private final NexthopIPv6addressTlv tlv1 = NexthopIPv6addressTlv.of(b1);
+ private final NexthopIPv6addressTlv sameAsTlv1 = NexthopIPv6addressTlv.of(b1);
+ private final NexthopIPv6addressTlv tlv2 = NexthopIPv6addressTlv.of(b2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java
new file mode 100644
index 00000000..906c6526
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Equality test for NexthopUnnumberedIPv4IDTlv.
+ */
+public class NexthopUnnumberedIPv4IDTlvTest {
+
+ private final NexthopUnnumberedIPv4IDTlv tlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A);
+ private final NexthopUnnumberedIPv4IDTlv sameAsTlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A);
+ private final NexthopUnnumberedIPv4IDTlv tlv2 = NexthopUnnumberedIPv4IDTlv.of(0x0B, 0x0B);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsTlvTest.java
new file mode 100644
index 00000000..fb90fedb
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsTlvTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the NodeFlagBitsTlv.
+ */
+public class NodeFlagBitsTlvTest {
+ private final byte rawValue1 = 0x0A;
+ private final byte rawValue2 = 0x0B;
+
+ private final NodeFlagBitsTlv tlv1 = new NodeFlagBitsTlv(rawValue1);
+ private final NodeFlagBitsTlv sameAsTlv1 = new NodeFlagBitsTlv(rawValue1);
+ private final NodeFlagBitsTlv tlv2 = NodeFlagBitsTlv.of(rawValue2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameTlvTest.java
new file mode 100644
index 00000000..d6d53d6f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameTlvTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the NodeNameTlv.
+ */
+public class NodeNameTlvTest {
+ private final byte[] rawValue1 = new byte[] {0x01, 0x02};
+ private final byte[] rawValue2 = new byte[] {0x14, 0x15};
+
+ private final NodeNameTlv tlv1 = new NodeNameTlv(rawValue1, (short) rawValue1.length);
+ private final NodeNameTlv sameAsTlv1 = NodeNameTlv.of(tlv1.getValue(), tlv1.getLength());
+ private final NodeNameTlv tlv2 = new NodeNameTlv(rawValue2, (short) 0);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OSPFareaIDsubTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OSPFareaIDsubTlvTest.java
new file mode 100644
index 00000000..3f741ed6
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OSPFareaIDsubTlvTest.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the OSPFareaIDsubTlv.
+ */
+public class OSPFareaIDsubTlvTest {
+ private final int rawValue1 = 0x0A;
+
+ private final OSPFareaIDsubTlv tlv1 = new OSPFareaIDsubTlv(rawValue1);
+ private final OSPFareaIDsubTlv tlv2 = OSPFareaIDsubTlv.of(tlv1.getInt());
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlvTest.java
new file mode 100644
index 00000000..f437fb57
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlvTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the OpaqueLinkAttributeTlv.
+ */
+public class OpaqueLinkAttributeTlvTest {
+ private final byte[] rawValue1 = new byte[] {0x01, 0x02};
+ private final byte[] rawValue2 = new byte[] {0x14, 0x15};
+
+ private final OpaqueLinkAttributeTlv tlv1 = new OpaqueLinkAttributeTlv(rawValue1, (short) rawValue1.length);
+ private final OpaqueLinkAttributeTlv sameAsTlv1 = OpaqueLinkAttributeTlv.of(tlv1.getValue(), tlv1.getLength());
+ private final OpaqueLinkAttributeTlv tlv2 = new OpaqueLinkAttributeTlv(rawValue2, (short) 0);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java
new file mode 100644
index 00000000..64cda54e
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the PathKeySubObject.
+ */
+public class PathKeySubObjectTest {
+
+ private final PathKeySubObject tlv1 = new PathKeySubObject((short) 0x0A, 0x0A);
+ private final PathKeySubObject sameAsTlv1 = PathKeySubObject.of((short) 0x0A, 0x0A);
+ private final PathKeySubObject tlv2 = new PathKeySubObject((short) 0x0B, 0x0B);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java
new file mode 100644
index 00000000..d82c943e
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the PathSetupTypeTlv.
+ */
+public class PathSetupTypeTlvTest {
+
+ private final PathSetupTypeTlv tlv1 = PathSetupTypeTlv.of(0x0A);
+ private final PathSetupTypeTlv sameAsTlv1 = PathSetupTypeTlv.of(0x0A);
+ private final PathSetupTypeTlv tlv2 = PathSetupTypeTlv.of(0x0B);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java
new file mode 100644
index 00000000..30892b18
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test of the PceccCapabilityTlv.
+ */
+public class PceccCapabilityTlvTest {
+ private final int rawValue1 = 0x0A;
+ private final int rawValue2 = 0x0B;
+
+ private final PceccCapabilityTlv tlv1 = new PceccCapabilityTlv(rawValue1);
+ private final PceccCapabilityTlv sameAsTlv1 = new PceccCapabilityTlv(rawValue1);
+ private final PceccCapabilityTlv tlv2 = PceccCapabilityTlv.of(rawValue2);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java
new file mode 100644
index 00000000..3ebc9a1e
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Equality test for PcepNaiIpv4Adjacency.
+ */
+public class PcepNaiIpv4AdjacencyTest {
+
+ private final PcepNaiIpv4Adjacency obj1 = PcepNaiIpv4Adjacency.of(2, 16);
+ private final PcepNaiIpv4Adjacency sameAsObj1 = PcepNaiIpv4Adjacency.of(2, 16);
+ private final PcepNaiIpv4Adjacency obj2 = PcepNaiIpv4Adjacency.of(3, 16);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(obj1, sameAsObj1).addEqualityGroup(obj2).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java
new file mode 100644
index 00000000..5ea5edd6
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+public class PcepNaiIpv4NodeIdTest {
+
+ private final PcepNaiIpv4NodeId tlv1 = PcepNaiIpv4NodeId.of(1);
+ private final PcepNaiIpv4NodeId tlv2 = PcepNaiIpv4NodeId.of(1);
+ private final PcepNaiIpv4NodeId tlv3 = PcepNaiIpv4NodeId.of(3);
+
+ @Test
+ public void basics() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, tlv2)
+ .addEqualityGroup(tlv3)
+ .testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java
new file mode 100644
index 00000000..52c40f94
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+public class PcepNaiIpv6AdjacencyTest {
+ private final byte[] localIpv6Addr1 = {(byte) 0x01010101 };
+ private final byte[] remoteIpv6Addr1 = {(byte) 0x02020202 };
+ private final byte[] localIpv6Addr2 = {(byte) 0x01010101 };
+ private final byte[] remoteIpv6Addr2 = {(byte) 0x02020202 };
+ private final byte[] localIpv6Addr3 = {(byte) 0x05050505 };
+ private final byte[] remoteIpv6Addr3 = {(byte) 0x06060606 };
+
+ private final PcepNaiIpv6Adjacency tlv1 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1);
+ private final PcepNaiIpv6Adjacency tlv2 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1);
+ private final PcepNaiIpv6Adjacency tlv3 = PcepNaiIpv6Adjacency.of(localIpv6Addr3, remoteIpv6Addr3);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java
new file mode 100644
index 00000000..29771a0f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Equality test for PcepNaiIpv6NodeId.
+ */
+public class PcepNaiIpv6NodeIdTest {
+
+ private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02,
+ 0x00, 0x00 };
+ private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
+ (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02,
+ 0x00, 0x00 };
+
+ private final PcepNaiIpv6NodeId tlv1 = PcepNaiIpv6NodeId.of(b1);
+ private final PcepNaiIpv6NodeId sameAsTlv1 = PcepNaiIpv6NodeId.of(b1);
+ private final PcepNaiIpv6NodeId tlv2 = PcepNaiIpv6NodeId.of(b2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.java
new file mode 100644
index 00000000..60ae22fd
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+public class PcepNaiUnnumberedAdjacencyIpv4Test {
+
+ private final int localNodeId1 = 1;
+ private final int localInterfaceId1 = 1;
+ private final int remoteNodeId1 = 1;
+ private final int remoteInterfaceId1 = 1;
+ private final PcepNaiUnnumberedAdjacencyIpv4 tlv1 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId1,
+ localInterfaceId1, remoteNodeId1, remoteInterfaceId1);
+
+ private final int localNodeId2 = 1;
+ private final int localInterfaceId2 = 1;
+ private final int remoteNodeId2 = 1;
+ private final int remoteInterfaceId2 = 1;
+ private final PcepNaiUnnumberedAdjacencyIpv4 tlv2 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId2,
+ localInterfaceId2, remoteNodeId2, remoteInterfaceId2);
+
+ private final int localNodeId3 = 2;
+ private final int localInterfaceId3 = 2;
+ private final int remoteNodeId3 = 2;
+ private final int remoteInterfaceId3 = 2;
+
+ private final PcepNaiUnnumberedAdjacencyIpv4 tlv3 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId3,
+ localInterfaceId3, remoteNodeId3, remoteInterfaceId3);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlvTest.java
new file mode 100644
index 00000000..112e4a4e
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlvTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+import java.util.LinkedList;
+
+/**
+ * Test case for Remote TE Node Descriptors tlv.
+ */
+public class RemoteTENodeDescriptorsTlvTest {
+
+ private final AutonomousSystemTlv autonomousSystemTlv1 = new AutonomousSystemTlv(10);
+ private final BGPLSidentifierTlv bGPLSidentifierTlv1 = new BGPLSidentifierTlv(20);
+
+ private final AutonomousSystemTlv autonomousSystemTlv2 = new AutonomousSystemTlv(20);
+ private final BGPLSidentifierTlv bGPLSidentifierTlv2 = new BGPLSidentifierTlv(30);
+
+ private final LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLV1 = new LinkedList<>();
+ private final boolean a = llRemoteTENodeDescriptorSubTLV1.add(autonomousSystemTlv1);
+ private final boolean b = llRemoteTENodeDescriptorSubTLV1.add(bGPLSidentifierTlv1);
+
+ private final LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLV2 = new LinkedList<>();
+ private final boolean c = llRemoteTENodeDescriptorSubTLV2.add(autonomousSystemTlv2);
+ private final boolean d = llRemoteTENodeDescriptorSubTLV2.add(bGPLSidentifierTlv2);
+
+ private final RemoteTENodeDescriptorsTlv tlv1 = RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1);
+ private final RemoteTENodeDescriptorsTlv sameAsTlv1 =
+ RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1);
+ private final RemoteTENodeDescriptorsTlv tlv2 = RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RouterIDSubTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RouterIDSubTlvTest.java
new file mode 100644
index 00000000..2f9e18a9
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RouterIDSubTlvTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test case for Router ID Sub tlv.
+ */
+public class RouterIDSubTlvTest {
+
+ private final byte[] value1 = {1, 2 };
+ private final Short length1 = 2;
+ private final RouterIDSubTlv tlv1 = RouterIDSubTlv.of(value1, length1);
+
+ private final Short length2 = 2;
+ private final RouterIDSubTlv tlv2 = RouterIDSubTlv.of(value1, length2);
+
+ private final byte[] value3 = {1, 2, 3 };
+ private final Short length3 = 3;
+ private final RouterIDSubTlv tlv3 = RouterIDSubTlv.of(value3, length3);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java
new file mode 100644
index 00000000..18aa2851
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Equality test for RoutingUniverseTlv.
+ */
+public class RoutingUniverseTlvTest {
+
+ private final RoutingUniverseTlv tlv1 = RoutingUniverseTlv.of(2);
+ private final RoutingUniverseTlv tlv2 = RoutingUniverseTlv.of(2);
+ private final RoutingUniverseTlv tlv3 = RoutingUniverseTlv.of(3);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlvTest.java
new file mode 100644
index 00000000..7c8ec570
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlvTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test case for Shared Risk Link Group tlv.
+ */
+public class SharedRiskLinkGroupTlvTest {
+
+ private final int[] raw = {1 };
+ private final Short hLength = 2;
+ private final SharedRiskLinkGroupTlv tlv1 = SharedRiskLinkGroupTlv.of(raw, hLength);
+
+ private final SharedRiskLinkGroupTlv sameAsTlv1 = SharedRiskLinkGroupTlv.of(raw, hLength);
+
+ private final int[] raw2 = {2 };
+ private final Short hLength2 = 3;
+ private final SharedRiskLinkGroupTlv tlv2 = SharedRiskLinkGroupTlv.of(raw2, hLength2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java
new file mode 100644
index 00000000..d91569b9
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onosproject.pcepio.protocol.PcepNai;
+
+public class SrEroSubObjectTest {
+
+ private final boolean bFFlag = false;
+ private final boolean bSFlag = false;
+ private final boolean bCFlag = false;
+ private final boolean bMFlag = false;
+ private final byte st = 1;
+ private final int sID = 1;
+ private final PcepNai nai = null;
+
+ private final SrEroSubObject tlv1 = SrEroSubObject.of(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+
+ private final boolean bFFlag1 = false;
+ private final boolean bSFlag1 = false;
+ private final boolean bCFlag1 = false;
+ private final boolean bMFlag1 = false;
+ private final byte st1 = 1;
+ private final int sID1 = 1;
+ private final PcepNai nai1 = null;
+
+ private final SrEroSubObject tlv2 = SrEroSubObject.of(st1, bFFlag1, bSFlag1, bCFlag1, bMFlag1, sID1, nai1);
+
+ private final boolean bFFlag2 = true;
+ private final boolean bSFlag2 = true;
+ private final boolean bCFlag2 = true;
+ private final boolean bMFlag2 = true;
+ private final byte st2 = 2;
+ private final int sID2 = 2;
+ private final PcepNai nai2 = null;
+
+ private final SrEroSubObject tlv3 = SrEroSubObject.of(st2, bFFlag2, bSFlag2, bCFlag2, bMFlag2, sID2, nai2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java
new file mode 100644
index 00000000..d1798fa3
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+public class StatefulIPv4LspIdentidiersTlvTest {
+
+ private final int ipv4IngressAddress = 1;
+ private final short lspId = 1;
+ private final short tunnelId = 1;
+ private final int extendedTunnelId = 1;
+ private final int ipv4EgressAddress = 1;
+
+ private final StatefulIPv4LspIdentidiersTlv tlv1 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress, lspId,
+ tunnelId, extendedTunnelId, ipv4EgressAddress);
+
+ private final int ipv4IngressAddress1 = 1;
+ private final short lspId1 = 1;
+ private final short tunnelId1 = 1;
+ private final int extendedTunnelId1 = 1;
+ private final int ipv4EgressAddress1 = 1;
+
+ private final StatefulIPv4LspIdentidiersTlv tlv2 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress1, lspId1,
+ tunnelId1, extendedTunnelId1, ipv4EgressAddress1);
+
+ private final int ipv4IngressAddress2 = 2;
+ private final short lspId2 = 2;
+ private final short tunnelId2 = 2;
+ private final int extendedTunnelId2 = 2;
+ private final int ipv4EgressAddress2 = 2;
+
+ private final StatefulIPv4LspIdentidiersTlv tlv3 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress2, lspId2,
+ tunnelId2, extendedTunnelId2, ipv4EgressAddress2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java
new file mode 100644
index 00000000..7076bc9e
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test case for Stateful Lsp Db Ver tlv.
+ */
+public class StatefulLspDbVerTlvTest {
+
+ private final StatefulLspDbVerTlv tlv1 = StatefulLspDbVerTlv.of(1);
+ private final StatefulLspDbVerTlv tlv2 = StatefulLspDbVerTlv.of(1);
+ private final StatefulLspDbVerTlv tlv3 = StatefulLspDbVerTlv.of(2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java
new file mode 100644
index 00000000..039108ae
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.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.pcepio.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+public class StatefulLspErrorCodeTlvTest {
+
+ private final StatefulLspErrorCodeTlv tlv1 = StatefulLspErrorCodeTlv.of(1);
+ private final StatefulLspErrorCodeTlv tlv2 = StatefulLspErrorCodeTlv.of(1);
+ private final StatefulLspErrorCodeTlv tlv3 = StatefulLspErrorCodeTlv.of(2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java
new file mode 100644
index 00000000..8637024c
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test case for Stateful Pce Capability tlv.
+ */
+public class StatefulPceCapabilityTlvTest {
+
+ private final StatefulPceCapabilityTlv tlv1 = StatefulPceCapabilityTlv.of(1);
+ private final StatefulPceCapabilityTlv tlv2 = StatefulPceCapabilityTlv.of(1);
+ private final StatefulPceCapabilityTlv tlv3 = StatefulPceCapabilityTlv.of(2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java
new file mode 100644
index 00000000..8d458f4e
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test case for Symbolic path tlv.
+ */
+public class SymbolicPathNameTlvTest {
+
+ private final byte[] value1 = {0x41 };
+ private final Short length1 = 2;
+ private final SymbolicPathNameTlv tlv1 = SymbolicPathNameTlv.of(value1, length1);
+
+ private final byte[] value2 = {0x41 };
+ private final Short length2 = 2;
+ private final SymbolicPathNameTlv tlv2 = SymbolicPathNameTlv.of(value1, length2);
+
+ private final byte[] value3 = {0x41, 0x43 };
+ private final Short length3 = 3;
+ private final SymbolicPathNameTlv tlv3 = SymbolicPathNameTlv.of(value3, length3);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricTlvTest.java
new file mode 100644
index 00000000..c46b0af1
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricTlvTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test case for TE Default Metric tlv.
+ */
+public class TEDefaultMetricTlvTest {
+
+ private final TEDefaultMetricTlv tlv1 = TEDefaultMetricTlv.of(1);
+ private final TEDefaultMetricTlv tlv2 = TEDefaultMetricTlv.of(1);
+ private final TEDefaultMetricTlv tlv3 = TEDefaultMetricTlv.of(2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkAttributesTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkAttributesTlvTest.java
new file mode 100644
index 00000000..8504a87c
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkAttributesTlvTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+import java.util.LinkedList;
+
+/**
+ * Test case for TE Link Attribute Tlv.
+ */
+public class TELinkAttributesTlvTest {
+
+ private final AdministrativeGroupTlv administrativeGroupTlv1 = new AdministrativeGroupTlv(10);
+ private final MaximumReservableLinkBandwidthTlv maximumReservableLinkBandwidthTlv1 =
+ new MaximumReservableLinkBandwidthTlv(20);
+
+ private final AdministrativeGroupTlv administrativeGroupTlv2 = new AdministrativeGroupTlv(20);
+ private final MaximumReservableLinkBandwidthTlv maximumReservableLinkBandwidthTlv2 =
+ new MaximumReservableLinkBandwidthTlv(30);
+
+ private final LinkedList<PcepValueType> llLinkAttributesSubTLV1 = new LinkedList<>();
+ private final boolean a = llLinkAttributesSubTLV1.add(administrativeGroupTlv1);
+ private final boolean b = llLinkAttributesSubTLV1.add(maximumReservableLinkBandwidthTlv1);
+
+ private final LinkedList<PcepValueType> llLinkAttributesSubTLV2 = new LinkedList<>();
+
+ private final boolean c = llLinkAttributesSubTLV2.add(administrativeGroupTlv2);
+ private final boolean d = llLinkAttributesSubTLV2.add(maximumReservableLinkBandwidthTlv2);
+
+ private final TELinkAttributesTlv tlv1 = TELinkAttributesTlv.of(llLinkAttributesSubTLV1);
+ private final TELinkAttributesTlv sameAsTlv1 = TELinkAttributesTlv.of(llLinkAttributesSubTLV1);
+ private final TELinkAttributesTlv tlv2 = TELinkAttributesTlv.of(llLinkAttributesSubTLV2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkDescriptorsTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkDescriptorsTlvTest.java
new file mode 100644
index 00000000..4e942097
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkDescriptorsTlvTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+import java.util.LinkedList;
+
+/**
+ * Test case for TE link descriptors Tlv.
+ */
+public class TELinkDescriptorsTlvTest {
+ private final LinkLocalRemoteIdentifiersTlv linkLocalRemoteIdentifiersTlv1 = new
+ LinkLocalRemoteIdentifiersTlv(10, 10);
+ private final IPv4InterfaceAddressTlv iPv4InterfaceAddressTlv1 = new IPv4InterfaceAddressTlv(0x01010101);
+
+ private final LinkLocalRemoteIdentifiersTlv linkLocalRemoteIdentifiersTlv2 = new
+ LinkLocalRemoteIdentifiersTlv(20, 20);
+ private final IPv4InterfaceAddressTlv iPv4InterfaceAddressTlv2 = new IPv4InterfaceAddressTlv(0x02020202);
+
+ private final LinkedList<PcepValueType> llLinkDescriptorsSubTLVs1 = new LinkedList<>();
+ private final boolean a = llLinkDescriptorsSubTLVs1.add(linkLocalRemoteIdentifiersTlv1);
+ private final boolean b = llLinkDescriptorsSubTLVs1.add(iPv4InterfaceAddressTlv1);
+
+ private final LinkedList<PcepValueType> llLinkDescriptorsSubTLVs2 = new LinkedList<>();
+ private final boolean c = llLinkDescriptorsSubTLVs2.add(linkLocalRemoteIdentifiersTlv2);
+ private final boolean d = llLinkDescriptorsSubTLVs2.add(iPv4InterfaceAddressTlv2);
+
+ private final TELinkDescriptorsTlv tlv1 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1);
+ private final TELinkDescriptorsTlv sameAstlv1 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1);
+ private final TELinkDescriptorsTlv tlv2 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TENodeAttributesTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TENodeAttributesTlvTest.java
new file mode 100644
index 00000000..28cf27d4
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TENodeAttributesTlvTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+import java.util.LinkedList;
+
+/**
+ * Test case for TE Node Attribute tlv.
+ */
+public class TENodeAttributesTlvTest {
+
+ private final NodeFlagBitsTlv nodeFlagBitsTlv1 = new NodeFlagBitsTlv((byte) 10);
+ private final IPv4TERouterIdOfLocalNodeTlv iPv4TERouterIdOfLocalNodeTlv1 = new
+ IPv4TERouterIdOfLocalNodeTlv(0x01010101);
+
+ private final NodeFlagBitsTlv nodeFlagBitsTlv2 = new NodeFlagBitsTlv((byte) 20);
+ private final IPv4TERouterIdOfLocalNodeTlv iPv4TERouterIdOfLocalNodeTlv2 = new
+ IPv4TERouterIdOfLocalNodeTlv(0x02020202);
+
+ private final LinkedList<PcepValueType> llNodeAttributesSubTLV1 = new LinkedList<>();
+ private final boolean a = llNodeAttributesSubTLV1.add(nodeFlagBitsTlv1);
+ private final boolean b = llNodeAttributesSubTLV1.add(iPv4TERouterIdOfLocalNodeTlv1);
+
+ private final LinkedList<PcepValueType> llNodeAttributesSubTLV2 = new LinkedList<>();
+
+ private final boolean c = llNodeAttributesSubTLV2.add(nodeFlagBitsTlv2);
+ private final boolean d = llNodeAttributesSubTLV2.add(iPv4TERouterIdOfLocalNodeTlv2);
+
+ private final TENodeAttributesTlv tlv1 = TENodeAttributesTlv.of(llNodeAttributesSubTLV1);
+ private final TENodeAttributesTlv sameAsTlv1 = TENodeAttributesTlv.of(llNodeAttributesSubTLV1);
+ private final TENodeAttributesTlv tlv2 = TENodeAttributesTlv.of(llNodeAttributesSubTLV2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TedCapabilityTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TedCapabilityTlvTest.java
new file mode 100644
index 00000000..18677ca3
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TedCapabilityTlvTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Test case for TED Capability tlv.
+ */
+public class TedCapabilityTlvTest {
+
+ private final TedCapabilityTlv tlv1 = TedCapabilityTlv.of(1);
+ private final TedCapabilityTlv tlv2 = TedCapabilityTlv.of(1);
+ private final TedCapabilityTlv tlv3 = TedCapabilityTlv.of(2);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthTlvTest.java b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthTlvTest.java
new file mode 100644
index 00000000..a50fd9f4
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthTlvTest.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.types;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+
+/**
+ * Unit Test case for Unreserved Bandwidth Tlv.
+ */
+public class UnreservedBandwidthTlvTest {
+
+ // Objects of unreserved bandwidth tlv
+ private final UnreservedBandwidthTlv tlv1 = UnreservedBandwidthTlv.of(100);
+ private final UnreservedBandwidthTlv tlv2 = UnreservedBandwidthTlv.of(100);
+ private final UnreservedBandwidthTlv tlv3 = UnreservedBandwidthTlv.of(200);
+
+ @Test
+ public void basics() {
+ new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pom.xml b/framework/src/onos/protocols/pcep/pom.xml
new file mode 100755
index 00000000..c8e4222d
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-protocols</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-pcep-controller</artifactId>
+ <packaging>pom</packaging>
+
+ <description>ONOS Pcep Protocol subsystem</description>
+
+ <modules>
+ <module>api</module>
+ <module>ctl</module>
+ <module>pcepio</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-misc</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/framework/src/onos/protocols/pom.xml b/framework/src/onos/protocols/pom.xml
new file mode 100644
index 00000000..bcdc58b8
--- /dev/null
+++ b/framework/src/onos/protocols/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-protocols</artifactId>
+ <packaging>pom</packaging>
+
+ <description>ONOS south-bound protocols</description>
+
+ <modules>
+ <module>openflow</module>
+ <module>netconf</module>
+ <module>pcep</module>
+ <module>ovsdb</module>
+ <!--
+ <module>bgp</module>
+ -->
+ </modules>
+
+ <dependencies>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>