From d8838c4be428b277e68dfd7eebdb175ff395fe64 Mon Sep 17 00:00:00 2001
From: Thomas Kee
Date: Sun, 31 Aug 2014 12:58:29 -0700
Subject: [PATCH] Add packetcable-driver as a bundle and fix karafe depends.
Merge hop-along model rewrites. Ensure build sanity.
Change-Id: I83e7fd93fdc7650250a3e05c4903217417b4812d
Signed-off-by: Thomas Kee
---
features-packetcable/pom.xml | 14 +-
.../src/main/resources/features.xml | 16 +-
packetcable-consumer/pom.xml | 5 +
.../pcmm_service/impl/PcmmServiceModule.java | 52 +
.../impl/PcmmServiceModuleFactory.java | 13 +
.../controller/org/pcmm/api/PcmmService.java | 9 +
.../org/pcmm/impl/PcmmServiceImpl.java | 99 ++
.../src/main/yang/pcmm-service-impl.yang | 153 +++
packetcable-driver/.gitignore | 1 +
packetcable-driver/Makefile | 82 ++
packetcable-driver/pom.xml | 124 +++
.../src/main/java/org/pcmm/PCMMConstants.java | 19 +
.../src/main/java/org/pcmm/PCMMDef.java | 30 +
.../main/java/org/pcmm/PCMMGlobalConfig.java | 88 ++
.../src/main/java/org/pcmm/PCMMPdpAgent.java | 411 ++++++++
.../main/java/org/pcmm/PCMMPdpConnection.java | 553 ++++++++++
.../java/org/pcmm/PCMMPdpDataProcess.java | 208 ++++
.../main/java/org/pcmm/PCMMPdpMsgSender.java | 981 ++++++++++++++++++
.../java/org/pcmm/PCMMPdpReqStateMan.java | 461 ++++++++
.../src/main/java/org/pcmm/PCMMPepAgent.java | 252 +++++
.../main/java/org/pcmm/PCMMProperties.java | 60 ++
.../src/main/java/org/pcmm/base/IAdapter.java | 15 +
.../java/org/pcmm/base/IPCMMBaseObject.java | 80 ++
.../org/pcmm/base/impl/PCMMBaseObject.java | 244 +++++
.../java/org/pcmm/concurrent/IWorker.java | 28 +
.../java/org/pcmm/concurrent/IWorkerPool.java | 54 +
.../java/org/pcmm/concurrent/impl/Worker.java | 79 ++
.../org/pcmm/concurrent/impl/WorkerPool.java | 158 +++
.../src/main/java/org/pcmm/gates/IAMID.java | 51 +
.../main/java/org/pcmm/gates/IClassifier.java | 128 +++
.../org/pcmm/gates/IExtendedClassifier.java | 69 ++
.../src/main/java/org/pcmm/gates/IGateID.java | 19 +
.../main/java/org/pcmm/gates/IGateSpec.java | 246 +++++
.../java/org/pcmm/gates/IIPv6Classifier.java | 31 +
.../main/java/org/pcmm/gates/IPCMMError.java | 94 ++
.../main/java/org/pcmm/gates/IPCMMGate.java | 145 +++
.../java/org/pcmm/gates/ISessionClassID.java | 48 +
.../java/org/pcmm/gates/ISubscriberID.java | 49 +
.../java/org/pcmm/gates/ITrafficProfile.java | 23 +
.../java/org/pcmm/gates/ITransactionID.java | 43 +
.../main/java/org/pcmm/gates/impl/AMID.java | 77 ++
.../pcmm/gates/impl/BestEffortService.java | 211 ++++
.../java/org/pcmm/gates/impl/Classifier.java | 193 ++++
.../DOCSISServiceClassNameTrafficProfile.java | 76 ++
.../pcmm/gates/impl/ExtendedClassifier.java | 347 +++++++
.../main/java/org/pcmm/gates/impl/GateID.java | 57 +
.../java/org/pcmm/gates/impl/GateSpec.java | 105 ++
.../java/org/pcmm/gates/impl/PCMMError.java | 98 ++
.../java/org/pcmm/gates/impl/PCMMGateReq.java | 273 +++++
.../org/pcmm/gates/impl/SessionClassID.java | 85 ++
.../org/pcmm/gates/impl/SubscriberID.java | 66 ++
.../org/pcmm/gates/impl/TransactionID.java | 77 ++
.../org/pcmm/gates/impl/package-info.java | 7 +
.../main/java/org/pcmm/messages/IMessage.java | 47 +
.../org/pcmm/messages/IMessageFactory.java | 37 +
.../pcmm/messages/impl/COPSDecisionMsgEX.java | 476 +++++++++
.../pcmm/messages/impl/MessageFactory.java | 299 ++++++
.../java/org/pcmm/messages/package-info.java | 7 +
.../main/java/org/pcmm/nio/PCMMChannel.java | 172 +++
.../java/org/pcmm/objects/MMVersionInfo.java | 69 ++
.../java/org/pcmm/objects/PCMMIDHolder.java | 60 ++
.../java/org/pcmm/objects/PCMMResource.java | 15 +
.../org/pcmm/objects/PCMMResourceSet.java | 55 +
.../org/pcmm/objects/PCMMResourcesMapper.java | 39 +
.../java/org/pcmm/objects/SyncOptions.java | 73 ++
.../src/main/java/org/pcmm/rcd/ICMTS.java | 47 +
.../main/java/org/pcmm/rcd/IPCMMClient.java | 97 ++
.../java/org/pcmm/rcd/IPCMMPolicyServer.java | 222 ++++
.../main/java/org/pcmm/rcd/IPCMMServer.java | 91 ++
.../org/pcmm/rcd/impl/AbstractPCMMClient.java | 176 ++++
.../org/pcmm/rcd/impl/AbstractPCMMServer.java | 214 ++++
.../src/main/java/org/pcmm/rcd/impl/CMTS.java | 355 +++++++
.../org/pcmm/rcd/impl/PCMMPolicyServer.java | 652 ++++++++++++
.../main/java/org/pcmm/rcd/package-info.java | 11 +
.../java/org/pcmm/scd/IApplicationServer.java | 47 +
.../java/org/pcmm/scd/impl/package-info.java | 7 +
.../main/java/org/pcmm/scd/package-info.java | 10 +
.../pcmm/state/IPCMMRecordKeepingServer.java | 11 +
.../src/main/java/org/pcmm/state/IState.java | 19 +
.../main/java/org/pcmm/state/IStateful.java | 30 +
.../java/org/pcmm/state/package-info.java | 4 +
.../java/org/pcmm/utils/PCMMException.java | 23 +
.../main/java/org/pcmm/utils/PCMMUtils.java | 67 ++
.../java/org/umu/cops/common/COPSDebug.java | 80 ++
.../java/org/umu/cops/common/COPS_def.java | 50 +
.../org/umu/cops/ospdp/COPSPdpException.java | 47 +
.../org/umu/cops/ospdp/COPSPdpOSAgent.java | 317 ++++++
.../umu/cops/ospdp/COPSPdpOSConnection.java | 544 ++++++++++
.../umu/cops/ospdp/COPSPdpOSDataProcess.java | 78 ++
.../umu/cops/ospdp/COPSPdpOSMsgSender.java | 288 +++++
.../umu/cops/ospdp/COPSPdpOSReqStateMan.java | 310 ++++++
.../org/umu/cops/ospep/COPSPepException.java | 50 +
.../org/umu/cops/ospep/COPSPepOSAgent.java | 329 ++++++
.../umu/cops/ospep/COPSPepOSConnection.java | 469 +++++++++
.../umu/cops/ospep/COPSPepOSDataProcess.java | 59 ++
.../cops/ospep/COPSPepOSEventListener.java | 30 +
.../umu/cops/ospep/COPSPepOSMsgSender.java | 261 +++++
.../umu/cops/ospep/COPSPepOSReqStateMan.java | 308 ++++++
.../java/org/umu/cops/prpdp/COPSPdpAgent.java | 334 ++++++
.../org/umu/cops/prpdp/COPSPdpConnection.java | 555 ++++++++++
.../umu/cops/prpdp/COPSPdpDataProcess.java | 83 ++
.../org/umu/cops/prpdp/COPSPdpException.java | 48 +
.../org/umu/cops/prpdp/COPSPdpMsgSender.java | 441 ++++++++
.../umu/cops/prpdp/COPSPdpReqStateMan.java | 390 +++++++
.../java/org/umu/cops/prpep/COPSPepAgent.java | 319 ++++++
.../org/umu/cops/prpep/COPSPepConnection.java | 549 ++++++++++
.../umu/cops/prpep/COPSPepDataProcess.java | 85 ++
.../org/umu/cops/prpep/COPSPepException.java | 40 +
.../org/umu/cops/prpep/COPSPepMsgSender.java | 372 +++++++
.../umu/cops/prpep/COPSPepReqStateMan.java | 406 ++++++++
.../org/umu/cops/stack/COPSAcctTimer.java | 49 +
.../umu/cops/stack/COPSClientAcceptMsg.java | 256 +++++
.../umu/cops/stack/COPSClientCloseMsg.java | 224 ++++
.../org/umu/cops/stack/COPSClientOpenMsg.java | 330 ++++++
.../java/org/umu/cops/stack/COPSClientSI.java | 131 +++
.../java/org/umu/cops/stack/COPSContext.java | 211 ++++
.../java/org/umu/cops/stack/COPSData.java | 78 ++
.../java/org/umu/cops/stack/COPSDecision.java | 297 ++++++
.../org/umu/cops/stack/COPSDecisionMsg.java | 438 ++++++++
.../org/umu/cops/stack/COPSDeleteMsg.java | 287 +++++
.../java/org/umu/cops/stack/COPSError.java | 163 +++
.../org/umu/cops/stack/COPSException.java | 40 +
.../java/org/umu/cops/stack/COPSHandle.java | 146 +++
.../java/org/umu/cops/stack/COPSHeader.java | 371 +++++++
.../org/umu/cops/stack/COPSIntegrity.java | 187 ++++
.../org/umu/cops/stack/COPSInterface.java | 67 ++
.../org/umu/cops/stack/COPSIpv4Address.java | 107 ++
.../umu/cops/stack/COPSIpv4InInterface.java | 57 +
.../org/umu/cops/stack/COPSIpv4Interface.java | 107 ++
.../umu/cops/stack/COPSIpv4LastPdpAddr.java | 53 +
.../umu/cops/stack/COPSIpv4OutInterface.java | 61 ++
.../umu/cops/stack/COPSIpv4PdpAddress.java | 141 +++
.../org/umu/cops/stack/COPSIpv6Address.java | 90 ++
.../umu/cops/stack/COPSIpv6InInterface.java | 60 ++
.../org/umu/cops/stack/COPSIpv6Interface.java | 95 ++
.../umu/cops/stack/COPSIpv6LastPdpAddr.java | 53 +
.../umu/cops/stack/COPSIpv6OutInterface.java | 59 ++
.../umu/cops/stack/COPSIpv6PdpAddress.java | 140 +++
.../java/org/umu/cops/stack/COPSKAMsg.java | 191 ++++
.../java/org/umu/cops/stack/COPSKATimer.java | 47 +
.../org/umu/cops/stack/COPSLPDPDecision.java | 46 +
.../main/java/org/umu/cops/stack/COPSMsg.java | 121 +++
.../org/umu/cops/stack/COPSMsgParser.java | 133 +++
.../java/org/umu/cops/stack/COPSObjBase.java | 196 ++++
.../org/umu/cops/stack/COPSObjHeader.java | 225 ++++
.../org/umu/cops/stack/COPSPdpAddress.java | 80 ++
.../java/org/umu/cops/stack/COPSPepId.java | 121 +++
.../org/umu/cops/stack/COPSPrClassError.java | 84 ++
.../java/org/umu/cops/stack/COPSPrEPD.java | 43 +
.../java/org/umu/cops/stack/COPSPrError.java | 111 ++
.../org/umu/cops/stack/COPSPrErrorPRID.java | 41 +
.../org/umu/cops/stack/COPSPrGlobalError.java | 84 ++
.../java/org/umu/cops/stack/COPSPrID.java | 39 +
.../org/umu/cops/stack/COPSPrObjBase.java | 255 +++++
.../org/umu/cops/stack/COPSPrefixPrID.java | 42 +
.../java/org/umu/cops/stack/COPSReason.java | 172 +++
.../org/umu/cops/stack/COPSReportMsg.java | 362 +++++++
.../org/umu/cops/stack/COPSReportType.java | 164 +++
.../java/org/umu/cops/stack/COPSReqMsg.java | 598 +++++++++++
.../org/umu/cops/stack/COPSSyncStateMsg.java | 280 +++++
.../java/org/umu/cops/stack/COPSTimer.java | 135 +++
.../org/umu/cops/stack/COPSTransceiver.java | 91 ++
.../java/org/umu/cops/stack/COPSUtil.java | 73 ++
.../src/main/resources/pcmm.properties | 15 +
.../org/pcmm/test/BestEffortServiceTest.java | 42 +
.../src/test/java/org/pcmm/test/Main.java | 49 +
.../test/java/org/pcmm/test/PCErrorTest.java | 29 +
.../java/org/pcmm/test/PCMMGateReqTest.java | 40 +
.../org/pcmm/test/PCMMResourceSetTest.java | 39 +
.../java/org/pcmm/test/PCMMWorkflowTest.java | 99 ++
.../src/test/java/org/pcmm/test/README.md | 2 +
pom.xml | 1 +
172 files changed, 25516 insertions(+), 13 deletions(-)
create mode 100644 packetcable-consumer/src/main/java/org/opendaylight/controller/config/yang/config/pcmm_service/impl/PcmmServiceModule.java
create mode 100644 packetcable-consumer/src/main/java/org/opendaylight/controller/config/yang/config/pcmm_service/impl/PcmmServiceModuleFactory.java
create mode 100644 packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/api/PcmmService.java
create mode 100644 packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/impl/PcmmServiceImpl.java
create mode 100644 packetcable-consumer/src/main/yang/pcmm-service-impl.yang
create mode 100644 packetcable-driver/.gitignore
create mode 100644 packetcable-driver/Makefile
create mode 100644 packetcable-driver/pom.xml
create mode 100644 packetcable-driver/src/main/java/org/pcmm/PCMMConstants.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/PCMMDef.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/PCMMGlobalConfig.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/PCMMPdpAgent.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/PCMMPdpConnection.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/PCMMPdpDataProcess.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/PCMMPdpMsgSender.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/PCMMPdpReqStateMan.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/PCMMPepAgent.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/PCMMProperties.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/base/IAdapter.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/base/IPCMMBaseObject.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/base/impl/PCMMBaseObject.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/concurrent/IWorker.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/concurrent/IWorkerPool.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/concurrent/impl/Worker.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/concurrent/impl/WorkerPool.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/IAMID.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/IClassifier.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/IExtendedClassifier.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/IGateID.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/IGateSpec.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/IIPv6Classifier.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/IPCMMError.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/IPCMMGate.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/ISessionClassID.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/ISubscriberID.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/ITrafficProfile.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/ITransactionID.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/AMID.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/BestEffortService.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/Classifier.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/DOCSISServiceClassNameTrafficProfile.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/ExtendedClassifier.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/GateID.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/GateSpec.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/PCMMError.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/PCMMGateReq.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/SessionClassID.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/SubscriberID.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/TransactionID.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/gates/impl/package-info.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/messages/IMessage.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/messages/IMessageFactory.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/messages/impl/COPSDecisionMsgEX.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/messages/impl/MessageFactory.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/messages/package-info.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/nio/PCMMChannel.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/objects/MMVersionInfo.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/objects/PCMMIDHolder.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/objects/PCMMResource.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/objects/PCMMResourceSet.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/objects/PCMMResourcesMapper.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/objects/SyncOptions.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/rcd/ICMTS.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/rcd/IPCMMClient.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/rcd/IPCMMPolicyServer.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/rcd/IPCMMServer.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/rcd/impl/AbstractPCMMClient.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/rcd/impl/AbstractPCMMServer.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/rcd/impl/CMTS.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/rcd/impl/PCMMPolicyServer.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/rcd/package-info.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/scd/IApplicationServer.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/scd/impl/package-info.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/scd/package-info.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/state/IPCMMRecordKeepingServer.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/state/IState.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/state/IStateful.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/state/package-info.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/utils/PCMMException.java
create mode 100644 packetcable-driver/src/main/java/org/pcmm/utils/PCMMUtils.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/common/COPSDebug.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/common/COPS_def.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospdp/COPSPdpException.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospdp/COPSPdpOSAgent.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospdp/COPSPdpOSConnection.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospdp/COPSPdpOSDataProcess.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospdp/COPSPdpOSMsgSender.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospdp/COPSPdpOSReqStateMan.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospep/COPSPepException.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospep/COPSPepOSAgent.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospep/COPSPepOSConnection.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospep/COPSPepOSDataProcess.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospep/COPSPepOSEventListener.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospep/COPSPepOSMsgSender.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/ospep/COPSPepOSReqStateMan.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpdp/COPSPdpAgent.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpdp/COPSPdpConnection.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpdp/COPSPdpDataProcess.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpdp/COPSPdpException.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpdp/COPSPdpMsgSender.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpdp/COPSPdpReqStateMan.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpep/COPSPepAgent.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpep/COPSPepConnection.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpep/COPSPepDataProcess.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpep/COPSPepException.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpep/COPSPepMsgSender.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/prpep/COPSPepReqStateMan.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSAcctTimer.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSClientAcceptMsg.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSClientCloseMsg.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSClientOpenMsg.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSClientSI.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSContext.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSData.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSDecision.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSDecisionMsg.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSDeleteMsg.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSError.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSException.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSHandle.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSHeader.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIntegrity.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSInterface.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv4Address.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv4InInterface.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv4Interface.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv4LastPdpAddr.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv4OutInterface.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv4PdpAddress.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv6Address.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv6InInterface.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv6Interface.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv6LastPdpAddr.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv6OutInterface.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSIpv6PdpAddress.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSKAMsg.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSKATimer.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSLPDPDecision.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSMsg.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSMsgParser.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSObjBase.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSObjHeader.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSPdpAddress.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSPepId.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSPrClassError.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSPrEPD.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSPrError.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSPrErrorPRID.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSPrGlobalError.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSPrID.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSPrObjBase.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSPrefixPrID.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSReason.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSReportMsg.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSReportType.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSReqMsg.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSSyncStateMsg.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSTimer.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSTransceiver.java
create mode 100644 packetcable-driver/src/main/java/org/umu/cops/stack/COPSUtil.java
create mode 100644 packetcable-driver/src/main/resources/pcmm.properties
create mode 100644 packetcable-driver/src/test/java/org/pcmm/test/BestEffortServiceTest.java
create mode 100644 packetcable-driver/src/test/java/org/pcmm/test/Main.java
create mode 100644 packetcable-driver/src/test/java/org/pcmm/test/PCErrorTest.java
create mode 100644 packetcable-driver/src/test/java/org/pcmm/test/PCMMGateReqTest.java
create mode 100644 packetcable-driver/src/test/java/org/pcmm/test/PCMMResourceSetTest.java
create mode 100644 packetcable-driver/src/test/java/org/pcmm/test/PCMMWorkflowTest.java
create mode 100644 packetcable-driver/src/test/java/org/pcmm/test/README.md
diff --git a/features-packetcable/pom.xml b/features-packetcable/pom.xml
index 2a3c3dd..0e9e421 100644
--- a/features-packetcable/pom.xml
+++ b/features-packetcable/pom.xml
@@ -60,13 +60,6 @@
featuresxml
-
- org.opendaylight.openflowplugin
- features-openflowplugin
- 0.0.3-SNAPSHOT
- features
- xml
- org.opendaylight.controllerfeatures-flow
@@ -99,9 +92,14 @@
packetcable-model${project.version}
+
+ org.opendaylight.controller.packetcable
+ packetcable-driver
+ ${project.version}
+ odl-yangtools-bindingodl-yangtools-models
-
-odl-flow-model
+ odl-flow-modelmvn:org.opendaylight.controller.packetcable/packetcable-model/${project.version}
@@ -56,9 +56,15 @@
odl-mdsal-brokermvn:org.opendaylight.controller.packetcable/packetcable-provider/${project.version}
-
-odl-flow-model
+ mvn:org.opendaylight.controller.packetcable/packetcable-driver/${project.version}
+ odl-flow-modelodl-packetcable-model
+ odl-packetcable-driver
+
+
+ odl-mdsal-broker
+
+
diff --git a/packetcable-consumer/pom.xml b/packetcable-consumer/pom.xml
index c1da112..1f76dc3 100644
--- a/packetcable-consumer/pom.xml
+++ b/packetcable-consumer/pom.xml
@@ -20,6 +20,11 @@
${project.version}
+ ${project.groupId}
+ packetcable-driver
+ ${project.version}
+
+ org.opendaylight.controllerconfig-api
diff --git a/packetcable-consumer/src/main/java/org/opendaylight/controller/config/yang/config/pcmm_service/impl/PcmmServiceModule.java b/packetcable-consumer/src/main/java/org/opendaylight/controller/config/yang/config/pcmm_service/impl/PcmmServiceModule.java
new file mode 100644
index 0000000..7c20cf5
--- /dev/null
+++ b/packetcable-consumer/src/main/java/org/opendaylight/controller/config/yang/config/pcmm_service/impl/PcmmServiceModule.java
@@ -0,0 +1,52 @@
+package org.opendaylight.controller.config.yang.config.pcmm_service.impl;
+
+import org.opendaylight.controller.org.pcmm.api.PcmmService;
+import org.opendaylight.controller.org.pcmm.impl.PcmmServiceImpl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packetcable.service.rev140120.PacketcableServiceService;
+import org.opendaylight.yangtools.concepts.Registration;
+
+public class PcmmServiceModule
+ extends
+ org.opendaylight.controller.config.yang.config.pcmm_service.impl.AbstractPcmmServiceModule {
+ public PcmmServiceModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public PcmmServiceModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.pcmm_service.impl.PcmmServiceModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ PacketcableServiceService packetcableServiceService = getRpcRegistryDependency().getRpcService(PacketcableServiceService.class);
+ final PcmmService pcmmService = new PcmmServiceImpl(packetcableServiceService);
+ final Registration pcmmListenerReg = getNotificationServiceDependency().registerNotificationListener(pcmmService);
+ final PcmmServiceRuntimeRegistration runtimeReg = getRootRuntimeBeanRegistratorWrapper().register(pcmmService);
+ return new AutoCloseablePcmmService(packetcableServiceService, pcmmListenerReg, runtimeReg);
+ }
+
+ class AutoCloseablePcmmService extends PcmmServiceImpl implements
+ AutoCloseable {
+
+ private PcmmServiceRuntimeRegistration runtimeReg;
+ private Registration pcmmListenerReg;
+
+ public AutoCloseablePcmmService(PacketcableServiceService packetcableServiceService, Registration pcmmListenerReg, PcmmServiceRuntimeRegistration runtimeReg) {
+ super(packetcableServiceService);
+ this.runtimeReg = runtimeReg;
+ this.pcmmListenerReg = pcmmListenerReg;
+ }
+
+ @Override
+ public void close() throws Exception {
+ pcmmListenerReg.close();
+ runtimeReg.close();
+ }
+
+ }
+}
diff --git a/packetcable-consumer/src/main/java/org/opendaylight/controller/config/yang/config/pcmm_service/impl/PcmmServiceModuleFactory.java b/packetcable-consumer/src/main/java/org/opendaylight/controller/config/yang/config/pcmm_service/impl/PcmmServiceModuleFactory.java
new file mode 100644
index 0000000..7c6662c
--- /dev/null
+++ b/packetcable-consumer/src/main/java/org/opendaylight/controller/config/yang/config/pcmm_service/impl/PcmmServiceModuleFactory.java
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: pcmm-service-impl yang module local name: pcmm-service-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Mon Aug 11 19:34:09 CEST 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.config.pcmm_service.impl;
+public class PcmmServiceModuleFactory extends org.opendaylight.controller.config.yang.config.pcmm_service.impl.AbstractPcmmServiceModuleFactory {
+
+}
diff --git a/packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/api/PcmmService.java b/packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/api/PcmmService.java
new file mode 100644
index 0000000..c5d5317
--- /dev/null
+++ b/packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/api/PcmmService.java
@@ -0,0 +1,9 @@
+package org.opendaylight.controller.org.pcmm.api;
+
+import org.opendaylight.controller.config.yang.config.pcmm_service.impl.PcmmServiceRuntimeMXBean;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packetcable.service.rev140120.PacketcableServiceListener;
+
+public interface PcmmService extends PcmmServiceRuntimeMXBean,
+ PacketcableServiceListener {
+
+}
diff --git a/packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/impl/PcmmServiceImpl.java b/packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/impl/PcmmServiceImpl.java
new file mode 100644
index 0000000..8972271
--- /dev/null
+++ b/packetcable-consumer/src/main/java/org/opendaylight/controller/org/pcmm/impl/PcmmServiceImpl.java
@@ -0,0 +1,99 @@
+package org.opendaylight.controller.org.pcmm.impl;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+
+import org.opendaylight.controller.org.pcmm.api.PcmmService;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.node.cmts.rev140120.CmtsReference;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packetcable.service.rev140120.CmtsAdded;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packetcable.service.rev140120.CmtsRemoved;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packetcable.service.rev140120.CmtsUpdated;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packetcable.service.rev140120.PacketcableServiceService;
+import org.pcmm.rcd.IPCMMPolicyServer;
+import org.pcmm.rcd.IPCMMPolicyServer.IPSCMTSClient;
+import org.pcmm.rcd.impl.PCMMPolicyServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+
+public class PcmmServiceImpl implements PcmmService {
+
+ private static final Logger log = LoggerFactory.getLogger(PcmmServiceImpl.class);
+ private final ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool());
+ private PacketcableServiceService packetcableServiceService;
+ private List cmtsList;
+ private Map cmtsClients;
+ private IPCMMPolicyServer policyServer;
+
+ public PcmmServiceImpl(PacketcableServiceService packetcableServiceService) {
+ this.packetcableServiceService = packetcableServiceService;
+ policyServer = new PCMMPolicyServer();
+ cmtsClients = Maps.newConcurrentMap();
+ cmtsList = Lists.newArrayList();
+ }
+
+ @Override
+ public void onCmtsAdded(CmtsAdded notification) {
+ String ipv4 = notification.getId().getIpv4Address().getValue();
+ IPSCMTSClient client = policyServer.requestCMTSConnection(ipv4);
+ if (client.isConnected()) {
+ cmtsClients.put(notification.getCmtsRef(), client);
+ cmtsList.add(notification.getId());
+ }
+ }
+
+ @Override
+ public void onCmtsRemoved(CmtsRemoved notification) {
+ if (cmtsList.contains(notification.getId()))
+ cmtsList.remove(notification.getId());
+ if (cmtsClients.containsKey(notification.getCmtsRef())) {
+ IPSCMTSClient client = cmtsClients.remove(notification.getCmtsRef());
+ client.disconnect();
+ }
+ }
+
+ @Override
+ public void onCmtsUpdated(CmtsUpdated notification) {
+ // TODO
+ }
+
+ @Override
+ public Boolean sendGateDelete() {
+ // TODO change me
+ boolean ret = true;
+ for (Iterator iter = cmtsClients.values().iterator(); iter.hasNext();)
+ ret &= cmtsClients.get(0).gateDelete();
+ return ret;
+ }
+
+ @Override
+ public Boolean sendGateSynchronize() {
+ boolean ret = true;
+ for (Iterator iter = cmtsClients.values().iterator(); iter.hasNext();)
+ ret &= cmtsClients.get(0).gateSynchronize();
+ return ret;
+ }
+
+ @Override
+ public Boolean sendGateInfo() {
+ boolean ret = true;
+ for (Iterator iter = cmtsClients.values().iterator(); iter.hasNext();)
+ ret &= cmtsClients.get(0).gateInfo();
+ return ret;
+ }
+
+ @Override
+ public Boolean sendGateSet() {
+ boolean ret = true;
+ for (Iterator iter = cmtsClients.values().iterator(); iter.hasNext();)
+ ret &= cmtsClients.get(0).gateSet();
+ return ret;
+ }
+}
diff --git a/packetcable-consumer/src/main/yang/pcmm-service-impl.yang b/packetcable-consumer/src/main/yang/pcmm-service-impl.yang
new file mode 100644
index 0000000..8b7e78d
--- /dev/null
+++ b/packetcable-consumer/src/main/yang/pcmm-service-impl.yang
@@ -0,0 +1,153 @@
+module pcmm-service-impl {
+
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:controller:config:pcmm-service:impl";
+ prefix "pcmm-service-impl";
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import rpc-context { prefix rpcx; revision-date 2013-06-17; }
+
+ import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+
+ description
+ "This module contains the base YANG definitions for
+ pcmm-service impl implementation.";
+
+ revision "2014-08-10" {
+ description
+ "Initial revision.";
+ }
+
+ // This is the definition of pcmm service interface identity.
+ identity pcmm-service {
+ base "config:service-type";
+ config:java-class "org.opendaylight.controller.org.pcmm.api.PcmmService";
+ }
+
+ // This is the definition of pcmm service implementation module identity.
+ identity pcmm-service-impl {
+ base config:module-type;
+ config:provided-service pcmm-service;
+ config:java-name-prefix PcmmService;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case pcmm-service-impl {
+ when "/config:modules/config:module/config:type = 'pcmm-service-impl'";
+
+ container rpc-registry {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity mdsal:binding-rpc-registry;
+ }
+ }
+ }
+
+ container notification-service {
+ uses config:service-ref {
+ refine type {
+ mandatory true;
+ config:required-identity mdsal:binding-notification-service;
+ }
+ }
+ }
+ }
+ }
+
+ augment "/config:modules/config:module/config:state" {
+ case pcmm-service-impl {
+ when "/config:modules/config:module/config:type = 'pcmm-service-impl'";
+
+ rpcx:rpc-context-instance "send-gate-set-rpc";
+ rpcx:rpc-context-instance "send-gate-delete-rpc";
+ rpcx:rpc-context-instance "send-gate-info-rpc";
+ rpcx:rpc-context-instance "send-gate-synchronize-rpc";
+
+ }
+ }
+
+ identity send-gate-set-rpc;
+
+ rpc send-gate-set {
+ description
+ "Shortcut JMX call to send a gate-set message for testing.";
+
+ input {
+ uses rpcx:rpc-context-ref {
+ refine context-instance {
+ rpcx:rpc-context-instance send-gate-set-rpc;
+ }
+ }
+ }
+
+ output {
+ leaf result {
+ type boolean;
+ }
+ }
+ }
+
+ identity send-gate-delete-rpc;
+
+ rpc send-gate-delete {
+ description
+ "Shortcut JMX call to send a gate-delete message for testing.";
+
+ input {
+ uses rpcx:rpc-context-ref {
+ refine context-instance {
+ rpcx:rpc-context-instance send-gate-delete-rpc;
+ }
+ }
+ }
+
+ output {
+ leaf result {
+ type boolean;
+ }
+ }
+ }
+
+ identity send-gate-synchronize-rpc;
+
+ rpc send-gate-synchronize {
+ description
+ "Shortcut JMX call to send a gate-Synchronize message for testing.";
+
+ input {
+ uses rpcx:rpc-context-ref {
+ refine context-instance {
+ rpcx:rpc-context-instance send-gate-synchronize-rpc;
+ }
+ }
+ }
+
+ output {
+ leaf result {
+ type boolean;
+ }
+ }
+ }
+
+ identity send-gate-info-rpc;
+
+ rpc send-gate-info {
+ description
+ "Shortcut JMX call to send a gate-info message for testing.";
+
+ input {
+ uses rpcx:rpc-context-ref {
+ refine context-instance {
+ rpcx:rpc-context-instance send-gate-info-rpc;
+ }
+ }
+ }
+
+ output {
+ leaf result {
+ type boolean;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/packetcable-driver/.gitignore b/packetcable-driver/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/packetcable-driver/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/packetcable-driver/Makefile b/packetcable-driver/Makefile
new file mode 100644
index 0000000..f7a5699
--- /dev/null
+++ b/packetcable-driver/Makefile
@@ -0,0 +1,82 @@
+# define compiler and compiler flag variables
+
+JFLAGS = -g
+JC = javac
+JUNIT=/usr/share/junit/junit.jar
+JCOPS=src/main/java/jcops.jar
+PCMM=src/main/java/pcmm.jar
+CLASSPATH = -classpath .:$(PCMM):$(JCOPS):$(JUNIT)
+JFLAGS = -encoding UTF-8 $(CLASSPATH)
+JAR_PKG = Test.jar
+
+
+#
+# Clear any default targets for building .class files from .java files; we
+# will provide our own target entry to do this in this makefile.
+# make has a set of default targets for different suffixes (like .c.o)
+# Currently, clearing the default for .java.class is not necessary since
+# make does not have a definition for this target, but later versions of
+# make may, so it doesn't hurt to make sure that we clear any default
+# definitions for these
+#
+
+.SUFFIXES: .java .class
+
+
+#
+# Here is our target entry for creating .class files from .java files
+# This is a target entry that uses the suffix rule syntax:
+# DSTS:
+# rule
+# 'TS' is the suffix of the target file, 'DS' is the suffix of the dependency
+# file, and 'rule' is the rule for building a target
+# '$*' is a built-in macro that gets the basename of the current target
+# Remember that there must be a < tab > before the command line ('rule')
+#
+
+.java.class:
+ $(JC) $(JFLAGS) $*.java
+
+
+#
+# CLASSES is a macro consisting of 4 words (one for each java source file)
+#
+
+SOURCES = \
+ Main.java \
+ Test.java
+
+
+CLASSES = $(SOURCES:%.java=%.class)
+
+#
+# the default make target entry
+#
+
+default: classes
+
+
+#
+# This target entry uses Suffix Replacement within a macro:
+# $(name:string1=string2)
+# In the words in the macro named 'name' replace 'string1' with 'string2'
+# Below we are replacing the suffix .java of all words in the macro CLASSES
+# with the .class suffix
+#
+
+classes: $(SOURCES:.java=.class)
+
+jar:
+ jar cve $(JAR_PKG) $(CLASSES)
+
+tar:
+ tar czpf $(TARBALL) $(SOURCES) Makefile
+
+
+#
+# RM is a predefined macro in make (RM = rm -f)
+#
+
+clean:
+ $(RM) *.class
+
diff --git a/packetcable-driver/pom.xml b/packetcable-driver/pom.xml
new file mode 100644
index 0000000..00b09e4
--- /dev/null
+++ b/packetcable-driver/pom.xml
@@ -0,0 +1,124 @@
+
+
+ 4.0.0
+
+
+ org.opendaylight.controller.packetcable
+ packetcable-plugin
+ 1.1-SNAPSHOT
+
+ packetcable-driver
+ bundle
+
+
+ A lightweight implementation of PCMM COPS PDP client
+
+
+
+ 2013
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UTF-8
+ 0.6.2-SNAPSHOT
+ src/main/yang-gen-sal
+ http://nexus.opendaylight.org/content
+ opendaylight.snapshot
+ opendaylight.release
+
+
+
+
+ junit
+ junit
+ 4.11
+
+
+ ch.qos.logback
+ logback-core
+ 1.0.9
+
+
+ ch.qos.logback
+ logback-classic
+ 1.0.9
+
+
+ com.google.guava
+ guava
+ 13.0.1
+
+
+ javax.sip
+ jain-sip-ri
+ 1.2.158
+
+
+ commons-primitives
+ commons-primitives
+ 20041207.202534
+
+
+
+
+
+
+ ${project.basedir}/target
+ ${project.build.directory}/classes
+ ${project.artifactId}-${project.version}
+ ${project.build.directory}/test-classes
+ ${project.basedir}/src/main/java
+ ${project.basedir}/src/test/java
+
+
+ ${project.basedir}/src/main/resources
+
+
+
+
+ ${project.basedir}/src/test/resources
+
+
+
+
+ maven-compiler-plugin
+ 3.0
+
+
+ 1.7
+
+
+
+
+
diff --git a/packetcable-driver/src/main/java/org/pcmm/PCMMConstants.java b/packetcable-driver/src/main/java/org/pcmm/PCMMConstants.java
new file mode 100644
index 0000000..accce63
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/PCMMConstants.java
@@ -0,0 +1,19 @@
+package org.pcmm;
+
+public interface PCMMConstants {
+
+ // Port used by the PCMM
+ public static final String PCMM_PORT = "pcmm.port";
+ // Pool size, determining the number of connections that could be
+ // established with CMTSs
+ public static final String PS_POOL_SIZE = "pcmm.ps.pool.size";
+ // Default keep-alive timer value (secs)
+ public static final String KA_TIMER = "pcmm.keep.alive.timer";
+ // Default accounting timer value (secs)
+ public static final String ACC_TIMER = "pcmm.accounting.timer";
+ // default ip mask
+ public static final String DEFAULT_MASK = "pcmm.default.mask";
+ // default timeout
+ public static final String DEFAULT_TIEMOUT = "pcmm.default.timeout";
+
+}
\ No newline at end of file
diff --git a/packetcable-driver/src/main/java/org/pcmm/PCMMDef.java b/packetcable-driver/src/main/java/org/pcmm/PCMMDef.java
new file mode 100644
index 0000000..3b5758e
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/PCMMDef.java
@@ -0,0 +1,30 @@
+/**
+ @header@
+ */
+
+package org.pcmm;
+
+import org.umu.cops.common.COPS_def;
+
+public class PCMMDef extends COPS_def {
+
+ public static final short C_PCMM = (short) 0x800A;
+
+ /**
+ * Get a representative string for an COPS Client Type.
+ *
+ * @param cType
+ * COPS Client Type
+ * @return A representative String
+ *
+ */
+ public String strClientType(short cType) {
+ switch (cType) {
+ case C_PCMM:
+ return ("C_PCMM");
+ default:
+ return super.strClientType(cType);
+ }
+ }
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/PCMMGlobalConfig.java b/packetcable-driver/src/main/java/org/pcmm/PCMMGlobalConfig.java
new file mode 100644
index 0000000..4f7f605
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/PCMMGlobalConfig.java
@@ -0,0 +1,88 @@
+/**
+ @header@
+ */
+
+package org.pcmm;
+
+public class PCMMGlobalConfig {
+ // System
+ public static int Debug = 0;
+ public static int LogLevel = 0;
+ public static int DefaultBestEffortTrafficRate = 2500000;
+ // Service Flow Attributes Defaults
+ public static int DefaultBestEffortClassPriority = 69;
+ public static int DefaultUnsolicatedGrantSize = 1000;
+ public static int DefaultUnsolicatedGrantsPerInterval = 3;
+ public static int DefaultUnsolicatedGrantInterval = 8000;
+ // Gate Specification Defaults
+ public static int DSCPToSMark = 0;
+ public static int Priority = 0;
+ public static int PreEmption = 0;
+ public static int GateFlags = 0;
+ public static int GateTOSField = 0;
+ public static int GateTOSMask = 0;
+ public static int GateClass = 0;
+ // Authorization life timer
+ public static short GateT1 = 200;
+ // Authorization renew timer
+ public static short GateT2 = 300;
+ // Reservation life timer
+ public static short GateT3 = 0;
+ // Reservation renew timer
+ public static short GateT4 = 0;
+
+ // XXX - A new home for some of these @ org.pcmm.gates.impl.BestEffortService
+ public static int UGSTransmissionPolicy = 0x037F;
+ public static int BETransmissionPolicy = 0x0;
+ public static int BETrafficPriority = 0x0;
+ public static byte EClassifierPriority = 0x45;
+
+ // Temporary Configure Items For Demo or Lacking Design
+ public static int DefaultLowBestEffortTrafficRate = 500000;
+ public static int DefaultVideoSourcePort = 8081;
+ public static int DefaultAlternateSourcePort = 1369;
+ // public static String DefaultCMTS = "127.0.0.1"
+
+/* Demo Kit Layout
+ public static String DefaultCMTS = "10.32.4.3";
+ public static String SubscriberID = "10.32.104.2";
+ public static String dstIP = "10.32.4.208";
+ public static String srcIP = "10.32.154.2";
+*/
+
+/* LAB Bench Layout */
+ public static String DefaultCMTS = "10.32.15.3";
+ public static String SubscriberID = "10.32.115.143";
+ public static String dstIP = "10.32.0.234";
+ public static String srcIP = "10.32.215.111";
+
+ public static String DefautRadius = "192.168.50.2";
+ public static short srcPort = 8081;
+ public static short dstPort = 0;
+ public static int GateID1 = 0;
+ public static int GateID2 = 0;
+ public static void setGateID1(int n) {
+ GateID1 = n;
+ }
+ public static int getGateID1() {
+ return GateID1;
+ }
+ public static void setGateID2(int n) {
+ GateID2 = n;
+ }
+ public static int getGateID2() {
+ return GateID2;
+ }
+}
+
+/*
+ *
+ * // if(Constants.DEBUG.isEnabled()) { } public enum Constants { DEBUG(true),
+ * PRINT_VARS(false);
+ *
+ * private boolean enabled;
+ *
+ * private Constants(boolean enabled) { this.enabled = enabled; }
+ *
+ * public boolean isEnabled() { return enabled; } }
+ */
diff --git a/packetcable-driver/src/main/java/org/pcmm/PCMMPdpAgent.java b/packetcable-driver/src/main/java/org/pcmm/PCMMPdpAgent.java
new file mode 100644
index 0000000..dbe6b07
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/PCMMPdpAgent.java
@@ -0,0 +1,411 @@
+/**
+ @header@
+ */
+
+package org.pcmm;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import org.umu.cops.common.COPSDebug;
+import org.umu.cops.ospep.COPSPepException;
+import org.umu.cops.prpdp.COPSPdpAgent;
+import org.umu.cops.prpdp.COPSPdpException;
+import org.umu.cops.stack.COPSAcctTimer;
+import org.umu.cops.stack.COPSClientAcceptMsg;
+import org.umu.cops.stack.COPSClientCloseMsg;
+import org.umu.cops.stack.COPSClientOpenMsg;
+import org.umu.cops.stack.COPSError;
+import org.umu.cops.stack.COPSException;
+import org.umu.cops.stack.COPSHandle;
+import org.umu.cops.stack.COPSHeader;
+import org.umu.cops.stack.COPSKATimer;
+import org.umu.cops.stack.COPSMsg;
+import org.umu.cops.stack.COPSPepId;
+import org.umu.cops.stack.COPSReqMsg;
+import org.umu.cops.stack.COPSTransceiver;
+// import org.umu.cops.prpdp.COPSPdpDataProcess;
+import org.pcmm.objects.MMVersionInfo;
+
+
+/**
+ * Core PDP agent for provisioning
+ */
+public class PCMMPdpAgent extends COPSPdpAgent {
+ /** Well-known port for PCMM */
+ public static final int WELL_KNOWN_PDP_PORT = 3918;
+
+ private COPSPepId _pepId;
+ private String _pepIdString;
+ /**
+ * PEP host name
+ */
+ private String psHost;
+
+ /**
+ * PEP port
+ */
+ private int psPort;
+
+ private Socket socket;
+
+ /**
+ * Policy data processing object
+ */
+ private PCMMPdpDataProcess _process;
+ private MMVersionInfo _mminfo;
+ private COPSHandle _handle;
+ private short _transactionID;
+
+ /**
+ * Creates a PDP Agent
+ *
+ * @param clientType
+ * COPS Client-type
+ * @param process
+ * Object to perform policy data processing
+ */
+ public PCMMPdpAgent(short clientType, PCMMPdpDataProcess process) {
+ this(clientType, null, WELL_KNOWN_PDP_PORT, process);
+ }
+
+ /**
+ * Creates a PDP Agent
+ *
+ * @param clientType
+ * COPS Client-type
+ * @param psHost
+ * Host to connect to
+ * @param psPort
+ * Port to connect to
+ * @param process
+ * Object to perform policy data processing
+ */
+ public PCMMPdpAgent(short clientType, String psHost, int psPort, PCMMPdpDataProcess process) {
+ super(psPort, clientType, null);
+ this._process = process;
+ this.psHost = psHost;
+ }
+
+ /**
+ * XXX -tek- This is the retooled connect. Not sure if the while forever
+ * loop is needed. Socket accept --> handleClientOpenMsg --> pdpConn.run()
+ *
+ * Below is new Thread(pdpConn).start(); Does that do it?
+ *
+ */
+ /**
+ * Connects to a PDP
+ *
+ * @param psHost
+ * CMTS host name
+ * @param psPort
+ * CMTS port
+ * @return true if PDP accepts the connection; false
+ * otherwise
+ * @throws java.net.UnknownHostException
+ * @throws java.io.IOException
+ * @throws COPSException
+ * @throws COPSPepException
+ */
+ public boolean connect(String psHost, int psPort)
+ throws UnknownHostException, IOException, COPSException,
+ COPSPdpException {
+
+ this.psHost = psHost;
+ this.psPort = psPort;
+ // Create Socket and send OPN
+ InetAddress addr = InetAddress.getByName(psHost);
+ try {
+ socket = new Socket(addr, psPort);
+ } catch (IOException e) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_SOCKET, e);
+ return (false);
+ }
+ COPSDebug.err(getClass().getName(), "PDP Socket Opened");
+ // Loop through for Incoming messages
+
+ // server infinite loop
+ // while(true)
+ {
+
+ // We're waiting for an message
+ try {
+ COPSDebug.err(getClass().getName(),
+ "PDP COPSTransceiver.receiveMsg ");
+ COPSMsg msg = COPSTransceiver.receiveMsg(socket);
+ if (msg.getHeader().isAClientOpen()) {
+ COPSDebug.err(getClass().getName(),
+ "PDP msg.getHeader().isAClientOpen");
+ handleClientOpenMsg(socket, msg);
+ } else {
+ // COPSDebug.err(getClass().getName(),
+ // COPSDebug.ERROR_NOEXPECTEDMSG);
+ try {
+ socket.close();
+ } catch (Exception ex) {
+ }
+ ;
+ }
+ } catch (Exception e) { // COPSException, IOException
+ // COPSDebug.err(getClass().getName(),
+ // COPSDebug.ERROR_EXCEPTION,
+ // "(" + socket.getInetAddress() + ":" + socket.getPort() + ")",
+ // e);
+ try {
+ socket.close();
+ } catch (Exception ex) {
+ }
+ ;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Handles a COPS client-open message
+ *
+ * @param conn
+ * Socket to the PEP
+ * @param msg
+ * COPSMsg holding the client-open message
+ * @throws COPSException
+ * @throws IOException
+ */
+ private void handleClientOpenMsg(Socket conn, COPSMsg msg)
+ throws COPSException, IOException {
+ COPSClientOpenMsg cMsg = (COPSClientOpenMsg) msg;
+ COPSPepId pepId = cMsg.getPepId();
+
+ // Validate Client Type
+ if (msg.getHeader().getClientType() != getClientType()) {
+ // Unsupported client type
+ COPSHeader cHdr = new COPSHeader(COPSHeader.COPS_OP_CC, msg
+ .getHeader().getClientType());
+ COPSError err = new COPSError(
+ COPSError.COPS_ERR_UNSUPPORTED_CLIENT_TYPE, (short) 0);
+ COPSClientCloseMsg closeMsg = new COPSClientCloseMsg();
+ closeMsg.add(cHdr);
+ closeMsg.add(err);
+ try {
+ closeMsg.writeData(conn);
+ } catch (IOException unae) {
+ }
+
+ throw new COPSException("Unsupported client type");
+ }
+
+ // PEPId is mandatory
+ if (pepId == null) {
+ // Mandatory COPS object missing
+ COPSHeader cHdr = new COPSHeader(COPSHeader.COPS_OP_CC, msg
+ .getHeader().getClientType());
+ COPSError err = new COPSError(
+ COPSError.COPS_ERR_MANDATORY_OBJECT_MISSING, (short) 0);
+ COPSClientCloseMsg closeMsg = new COPSClientCloseMsg();
+ closeMsg.add(cHdr);
+ closeMsg.add(err);
+ try {
+ closeMsg.writeData(conn);
+ } catch (IOException unae) {
+ }
+
+ throw new COPSException("Mandatory COPS object missing (PEPId)");
+ }
+ setPepId(pepId);
+ // Support
+ if ((cMsg.getClientSI() != null) ) {
+ _mminfo = new MMVersionInfo(cMsg
+ .getClientSI().getData().getData());
+ System.out.println("CMTS sent MMVersion info : major:"
+ + _mminfo.getMajorVersionNB() + " minor:"
+ + _mminfo.getMinorVersionNB());
+
+ } else {
+ // Unsupported objects
+ COPSHeader cHdr = new COPSHeader(COPSHeader.COPS_OP_CC, msg
+ .getHeader().getClientType());
+ COPSError err = new COPSError(COPSError.COPS_ERR_UNKNOWN_OBJECT,
+ (short) 0);
+ COPSClientCloseMsg closeMsg = new COPSClientCloseMsg();
+ closeMsg.add(cHdr);
+ closeMsg.add(err);
+ try {
+ closeMsg.writeData(conn);
+ } catch (IOException unae) {
+ }
+
+ throw new COPSException("Unsupported objects (PdpAddress, Integrity)");
+ }
+ /*
+ */
+
+ // Connection accepted
+ COPSHeader ahdr = new COPSHeader(COPSHeader.COPS_OP_CAT, msg
+ .getHeader().getClientType());
+ COPSKATimer katimer = new COPSKATimer(getKaTimer());
+ COPSAcctTimer acctTimer = new COPSAcctTimer(getAcctTimer());
+ COPSClientAcceptMsg acceptMsg = new COPSClientAcceptMsg();
+ acceptMsg.add(ahdr);
+ acceptMsg.add(katimer);
+ if (getAcctTimer() != 0)
+ acceptMsg.add(acctTimer);
+ acceptMsg.writeData(conn);
+ // XXX - handleRequestMsg
+ try {
+ COPSDebug.err(getClass().getName(), "PDP COPSTransceiver.receiveMsg ");
+ COPSMsg rmsg = COPSTransceiver.receiveMsg(socket);
+ // Client-Close
+ if (rmsg.getHeader().isAClientClose()) {
+ System.out.println(((COPSClientCloseMsg) rmsg)
+ .getError().getDescription());
+ // close the socket
+ COPSHeader cHdr = new COPSHeader(COPSHeader.COPS_OP_CC, msg
+ .getHeader().getClientType());
+ COPSError err = new COPSError(COPSError.COPS_ERR_UNKNOWN_OBJECT,
+ (short) 0);
+ COPSClientCloseMsg closeMsg = new COPSClientCloseMsg();
+ closeMsg.add(cHdr);
+ closeMsg.add(err);
+ try {
+ closeMsg.writeData(conn);
+ } catch (IOException unae) {
+ }
+ throw new COPSException("CMTS requetsed Client-Close");
+ } else {
+ // Request
+ if (rmsg.getHeader().isARequest()) {
+ COPSReqMsg rMsg = (COPSReqMsg) rmsg;
+ _handle = rMsg.getClientHandle();
+ } else
+ throw new COPSException("Can't understand request");
+
+ }
+ } catch (Exception e) { // COPSException, IOException
+ throw new COPSException("Error COPSTransceiver.receiveMsg");
+ }
+
+ COPSDebug.err(getClass().getName(), "PDPCOPSConnection");
+ PCMMPdpConnection pdpConn = new PCMMPdpConnection(pepId, conn, _process);
+ pdpConn.setKaTimer(getKaTimer());
+ if (getAcctTimer() != 0)
+ pdpConn.setAccTimer(getAcctTimer());
+
+ // XXX - handleRequestMsg
+ // XXX - check handle is valid
+ PCMMPdpReqStateMan man = new PCMMPdpReqStateMan(getClientType(), _handle.getId().str());
+ pdpConn.getReqStateMans().put(_handle.getId().str(),man);
+ man.setDataProcess(_process);
+ try {
+ man.initRequestState(conn);
+ } catch (COPSPdpException unae) {
+ }
+ // XXX - End handleRequestMsg
+
+ COPSDebug.err(getClass().getName(), "PDP Thread(pdpConn).start");
+ new Thread(pdpConn).start();
+ getConnectionMap().put(pepId.getData().str(), pdpConn);
+ }
+
+ /**
+ * @return the _psHost
+ */
+ public String getPsHost() {
+ return psHost;
+ }
+
+ /**
+ * @param _psHost
+ * the _psHost to set
+ */
+ public void setPsHost(String _psHost) {
+ this.psHost = _psHost;
+ }
+
+ /**
+ * @return the _psPort
+ */
+ public int getPsPort() {
+ return psPort;
+ }
+
+ /**
+ * @param _psPort
+ * the _psPort to set
+ */
+ public void setPsPort(int _psPort) {
+ this.psPort = _psPort;
+ }
+
+ /**
+ * @return the socket
+ */
+ public Socket getSocket() {
+ return socket;
+ }
+
+ /**
+ * @param socket
+ * the socket to set
+ */
+ public void setSocket(Socket socket) {
+ this.socket = socket;
+ }
+
+ /**
+ * @return the _process
+ */
+ public PCMMPdpDataProcess getProcess() {
+ return _process;
+ }
+
+ /**
+ * @param _process
+ * the _process to set
+ */
+ public void setProcess(PCMMPdpDataProcess _process) {
+ this._process = _process;
+ }
+
+ /**
+ * Gets the client handle
+ * @return Client's COPSHandle
+ */
+ public COPSHandle getClientHandle() {
+ return _handle;
+ }
+
+ /**
+ * Gets the PepId
+ * @return COPSPepId
+ */
+ public COPSPepId getPepId() {
+ return _pepId;
+ }
+
+ public String getPepIdString() {
+ return _pepIdString;
+ }
+
+ /**
+ * Sets the PepId
+ * @param COPSPepId
+ */
+ public void setPepId(COPSPepId pepId) {
+ _pepId = pepId;
+ _pepIdString = pepId.getData().str();
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.rcd.IPCMMClient#isConnected()
+ */
+ public boolean isConnected() {
+ return socket != null && socket.isConnected();
+ }
+
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/PCMMPdpConnection.java b/packetcable-driver/src/main/java/org/pcmm/PCMMPdpConnection.java
new file mode 100644
index 0000000..ceb5ccd
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/PCMMPdpConnection.java
@@ -0,0 +1,553 @@
+/*
+ @header@
+ */
+
+package org.pcmm;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.umu.cops.common.COPSDebug;
+import org.umu.cops.prpdp.COPSPdpException;
+import org.umu.cops.stack.COPSClientCloseMsg;
+import org.umu.cops.stack.COPSContext;
+import org.umu.cops.stack.COPSDeleteMsg;
+import org.umu.cops.stack.COPSError;
+import org.umu.cops.stack.COPSException;
+import org.umu.cops.stack.COPSHeader;
+import org.umu.cops.stack.COPSKAMsg;
+import org.umu.cops.stack.COPSMsg;
+import org.umu.cops.stack.COPSPepId;
+import org.umu.cops.stack.COPSReportMsg;
+import org.umu.cops.stack.COPSReqMsg;
+import org.umu.cops.stack.COPSSyncStateMsg;
+import org.umu.cops.stack.COPSTransceiver;
+
+/**
+ * Class for managing an provisioning connection at the PDP side.
+ */
+public class PCMMPdpConnection implements Runnable {
+
+ /**
+ Socket connected to PEP
+ */
+ private Socket _sock;
+
+ /**
+ PEP identifier
+ */
+ private COPSPepId _pepId;
+
+ /**
+ Time of the latest keep-alive sent
+ */
+ private Date _lastKa;
+
+ /**
+ Opcode of the latest message sent
+ */
+ private byte _lastmessage;
+
+ /**
+ * Time of the latest keep-alive received
+ */
+ protected Date _lastRecKa;
+
+ /**
+ Maps a Client Handle to a Handler
+ */
+ protected Hashtable _managerMap;
+ // map < String(COPSHandle), COPSPdpHandler> HandlerMap;
+
+ /**
+ * PDP policy data processor class
+ */
+ protected PCMMPdpDataProcess _process;
+
+ /**
+ Accounting timer value (secs)
+ */
+ protected short _acctTimer;
+
+ /**
+ Keep-alive timer value (secs)
+ */
+ protected short _kaTimer;
+
+ /**
+ COPS error returned by PEP
+ */
+ protected COPSError _error;
+
+ /**
+ * Creates a new PDP connection
+ *
+ * @param pepId PEP-ID of the connected PEP
+ * @param sock Socket connected to PEP
+ * @param process Object for processing policy data
+ */
+ public PCMMPdpConnection(COPSPepId pepId, Socket sock, PCMMPdpDataProcess process) {
+ _sock = sock;
+ _pepId = pepId;
+
+ _lastKa = new Date();
+ _lastmessage = COPSHeader.COPS_OP_OPN;
+ _managerMap = new Hashtable(20);
+
+ _kaTimer = 120;
+ _process = process;
+ }
+
+ /**
+ * Gets the time of that latest keep-alive sent
+ * @return Time of that latest keep-alive sent
+ */
+ public Date getLastKAlive() {
+ return _lastKa;
+ }
+
+ /**
+ * Sets the keep-alive timer value
+ * @param kaTimer Keep-alive timer value (secs)
+ */
+ public void setKaTimer(short kaTimer) {
+ _kaTimer = kaTimer;
+ }
+
+ /**
+ * Gets the keep-alive timer value
+ * @return Keep-alive timer value (secs)
+ */
+ public short getKaTimer() {
+ return _kaTimer;
+ }
+
+ /**
+ * Sets the accounting timer value
+ * @param acctTimer Accounting timer value (secs)
+ */
+ public void setAccTimer(short acctTimer) {
+ _acctTimer = acctTimer;
+ }
+
+ /**
+ * Gets the accounting timer value
+ * @return Accounting timer value (secs)
+ */
+ public short getAcctTimer() {
+ return _acctTimer;
+ }
+
+ /**
+ * Gets the latest COPS message
+ * @return Code of the latest message sent
+ */
+ public byte getLastMessage() {
+ return _lastmessage;
+ }
+
+ /**
+ * Gets active handles
+ * @return An Enumeration holding all active handles
+ */
+ public Enumeration getHandles() {
+ return _managerMap.keys();
+ }
+
+ /**
+ * Gets the handle map
+ * @return A Hashtable holding the handle map
+ */
+ public Hashtable getReqStateMans() {
+ return _managerMap;
+ }
+
+ /**
+ * Gets the PEP-ID
+ * @return The ID of the PEP, as a String
+ */
+ public String getPepId() {
+ return _pepId.getData().str();
+ }
+
+ /**
+ * Checks whether the socket to the PEP is closed or not
+ * @return true if closed, false otherwise
+ */
+ public boolean isClosed() {
+ return _sock.isClosed();
+ }
+
+ /**
+ * Closes the socket to the PEP
+ * @throws IOException
+ */
+ protected void close()
+ throws IOException {
+ _sock.close();
+ }
+
+ /**
+ * Gets the socket to the PEP
+ * @return Socket connected to the PEP
+ */
+ public Socket getSocket() {
+ return _sock;
+ }
+
+ /**
+ * Main loop
+ */
+ public void run () {
+ Date _lastSendKa = new Date();
+ _lastRecKa = new Date();
+ try {
+ while (!_sock.isClosed()) {
+ if (_sock.getInputStream().available() != 0) {
+ _lastmessage = processMessage(_sock);
+ _lastRecKa = new Date();
+ }
+
+ // Keep Alive
+ if (_kaTimer > 0) {
+ // Timeout at PDP
+ int _startTime = (int) (_lastRecKa.getTime());
+ int cTime = (int) (new Date().getTime());
+
+ if ((int)(cTime - _startTime) > _kaTimer*1000) {
+ _sock.close();
+ // Notify all Request State Managers
+ notifyNoKAAllReqStateMan();
+ }
+
+ // Send to PEP
+ _startTime = (int) (_lastSendKa.getTime());
+ cTime = (int) (new Date().getTime());
+
+ if ((int)(cTime - _startTime) > ((_kaTimer*3/4)*1000)) {
+ COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_KA);
+ COPSKAMsg msg = new COPSKAMsg();
+
+ msg.add(hdr);
+
+ COPSTransceiver.sendMsg(msg, _sock);
+ _lastSendKa = new Date();
+ }
+ }
+
+ try {
+ Thread.sleep(500);
+ } catch (Exception e) {};
+
+ }
+ } catch (Exception e) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_SOCKET, e);
+ }
+
+ // connection closed by server
+ // COPSDebug.out(getClass().getName(),"Connection closed by client");
+ try {
+ _sock.close();
+ } catch (IOException e) {};
+
+ // Notify all Request State Managers
+ try {
+ notifyCloseAllReqStateMan();
+ } catch (COPSPdpException e) {};
+ }
+
+ /**
+ * Gets a COPS message from the socket and processes it
+ * @param conn Socket connected to the PEP
+ * @return Type of COPS message
+ */
+ private byte processMessage(Socket conn)
+ throws COPSPdpException, COPSException, IOException {
+ COPSMsg msg = COPSTransceiver.receiveMsg(conn);
+
+ if (msg.getHeader().isAClientClose()) {
+ handleClientCloseMsg(conn, msg);
+ return COPSHeader.COPS_OP_CC;
+ } else if (msg.getHeader().isAKeepAlive()) {
+ handleKeepAliveMsg(conn, msg);
+ return COPSHeader.COPS_OP_KA;
+ } else if (msg.getHeader().isARequest()) {
+ handleRequestMsg(conn, msg);
+ return COPSHeader.COPS_OP_REQ;
+ } else if (msg.getHeader().isAReport()) {
+ handleReportMsg(conn, msg);
+ return COPSHeader.COPS_OP_RPT;
+ } else if (msg.getHeader().isADeleteReq()) {
+ handleDeleteRequestMsg(conn, msg);
+ return COPSHeader.COPS_OP_DRQ;
+ } else if (msg.getHeader().isASyncComplete()) {
+ handleSyncComplete(conn, msg);
+ return COPSHeader.COPS_OP_SSC;
+ } else {
+ throw new COPSPdpException("Message not expected (" + msg.getHeader().getOpCode() + ").");
+ }
+ }
+
+ /**
+ * Handle Client Close Message, close the passed connection
+ *
+ * @param conn a Socket
+ * @param msg a COPSMsg
+ *
+ *
+ * ::=
+ *
+ * []
+ *
+ * Not support []
+ *
+ */
+ private void handleClientCloseMsg(Socket conn, COPSMsg msg) {
+ COPSClientCloseMsg cMsg = (COPSClientCloseMsg) msg;
+ _error = cMsg.getError();
+
+ // COPSDebug.out(getClass().getName(),"Got close request, closing connection " +
+ // conn.getInetAddress() + ":" + conn.getPort() + ":[Error " + _error.getDescription() + "]");
+
+ try {
+ // Support
+ if (cMsg.getIntegrity() != null) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_NOSUPPORTED,
+ "Unsupported objects (Integrity) to connection " + conn.getInetAddress());
+ }
+
+ conn.close();
+ } catch (Exception unae) { };
+ }
+
+ /**
+ * Gets the occurred COPS Error
+ * @return COPSError object
+ */
+ protected COPSError getError() {
+ return _error;
+ }
+
+ /**
+ * Handle Keep Alive Message
+ *
+ * ::=
+ * []
+ *
+ * Not support []
+ *
+ * @param conn a Socket
+ * @param msg a COPSMsg
+ *
+ */
+ private void handleKeepAliveMsg(Socket conn, COPSMsg msg) {
+ COPSKAMsg cMsg = (COPSKAMsg) msg;
+
+ COPSKAMsg kaMsg = (COPSKAMsg) msg;
+ try {
+ // Support
+ if (cMsg.getIntegrity() != null) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_NOSUPPORTED,
+ "Unsupported objects (Integrity) to connection " + conn.getInetAddress());
+ }
+
+ kaMsg.writeData(conn);
+ } catch (Exception unae) { };
+ }
+
+ /**
+ * Handle Delete Request Message
+ *
+ * ::=
+ *
+ *
+ * []
+ *
+ * Not support []
+ *
+ * @param conn a Socket
+ * @param msg a COPSMsg
+ *
+ */
+ private void handleDeleteRequestMsg(Socket conn, COPSMsg msg)
+ throws COPSPdpException {
+ COPSDeleteMsg cMsg = (COPSDeleteMsg) msg;
+ // COPSDebug.out(getClass().getName(),"Removing ClientHandle for " +
+ // conn.getInetAddress() + ":" + conn.getPort() + ":[Reason " + cMsg.getReason().getDescription() + "]");
+
+ // Support
+ if (cMsg.getIntegrity() != null) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_NOSUPPORTED,
+ "Unsupported objects (Integrity) to connection " + conn.getInetAddress());
+ }
+
+ // Delete clientHandler
+ if (_managerMap.remove(cMsg.getClientHandle().getId().str()) == null) {
+ // COPSDebug.out(getClass().getName(),"Missing for ClientHandle " +
+ // cMsg.getClientHandle().getId().getData());
+ }
+
+ PCMMPdpReqStateMan man = (PCMMPdpReqStateMan) _managerMap.get(cMsg.getClientHandle().getId().str());
+ if (man == null) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_NOEXPECTEDMSG);
+ } else {
+ man.processDeleteRequestState(cMsg);
+ }
+
+ }
+
+ /**
+ * Handle Request Message
+ *
+ * ::=
+ *
+ *
+ * *()
+ * []
+ * ::= <*()>
+ *
+ * Not support []
+ *
+ * @param conn a Socket
+ * @param msg a COPSMsg
+ *
+ */
+ private void handleRequestMsg(Socket conn, COPSMsg msg)
+ throws COPSPdpException {
+
+ COPSReqMsg reqMsg = (COPSReqMsg) msg;
+ COPSContext cntxt = reqMsg.getContext();
+ COPSHeader header = reqMsg.getHeader();
+ //short reqType = cntxt.getRequestType();
+ short cType = header.getClientType();
+
+ // Support
+ if (reqMsg.getIntegrity() != null) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_NOSUPPORTED,
+ "Unsupported objects (Integrity) to connection " + conn.getInetAddress());
+ }
+
+ PCMMPdpReqStateMan man;
+ man = (PCMMPdpReqStateMan) _managerMap.get(reqMsg.getClientHandle().getId().str());
+ if (man == null) {
+
+ man = new PCMMPdpReqStateMan(cType, reqMsg.getClientHandle().getId().str());
+ _managerMap.put(reqMsg.getClientHandle().getId().str(),man);
+ man.setDataProcess(_process);
+ man.initRequestState(_sock);
+
+ // COPSDebug.out(getClass().getName(),"createHandler called, clientType=" +
+ // header.getClientType() + " msgType=" +
+ // cntxt.getMessageType() + ", connId=" + conn.toString());
+ }
+
+ man.processRequest(reqMsg);
+ }
+
+ /**
+ * Handle Report Message
+ *
+ * ::=
+ *
+ *
+ * *()
+ * []
+ *
+ * Not support []
+ *
+ * @param conn a Socket
+ * @param msg a COPSMsg
+ *
+ */
+ private void handleReportMsg(Socket conn, COPSMsg msg)
+ throws COPSPdpException {
+ COPSReportMsg repMsg = (COPSReportMsg) msg;
+ // COPSHandle handle = repMsg.getClientHandle();
+ // COPSHeader header = repMsg.getHeader();
+
+ // Support
+ if (repMsg.getIntegrity() != null) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_NOSUPPORTED,
+ "Unsupported objects (Integrity) to connection " + conn.getInetAddress());
+ }
+
+ PCMMPdpReqStateMan man = (PCMMPdpReqStateMan) _managerMap.get(repMsg.getClientHandle().getId().str());
+ if (man == null) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_NOEXPECTEDMSG);
+ } else {
+ man.processReport(repMsg);
+ }
+ }
+
+ /**
+ * Method handleSyncComplete
+ *
+ * @param conn a Socket
+ * @param msg a COPSMsg
+ *
+ */
+ private void handleSyncComplete(Socket conn, COPSMsg msg)
+ throws COPSPdpException {
+ COPSSyncStateMsg cMsg = (COPSSyncStateMsg) msg;
+ // COPSHandle handle = cMsg.getClientHandle();
+ // COPSHeader header = cMsg.getHeader();
+
+ // Support
+ if (cMsg.getIntegrity() != null) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_NOSUPPORTED,
+ "Unsupported objects (Integrity) to connection " + conn.getInetAddress());
+ }
+
+ PCMMPdpReqStateMan man = (PCMMPdpReqStateMan) _managerMap.get(cMsg.getClientHandle().getId().str());
+ if (man == null) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_NOEXPECTEDMSG);
+ } else {
+ man.processSyncComplete(cMsg);
+ }
+ }
+
+ /**
+ * Requests a COPS sync from the PEP
+ * @throws COPSException
+ * @throws COPSPdpException
+ */
+ protected void syncAllRequestState()
+ throws COPSException, COPSPdpException {
+ if (_managerMap.size() > 0) {
+ for (Enumeration e = _managerMap.keys() ; e.hasMoreElements() ;) {
+ String handle = (String) e.nextElement();
+ PCMMPdpReqStateMan man = (PCMMPdpReqStateMan) _managerMap.get(handle);
+
+ man.syncRequestState();
+ }
+ }
+ }
+
+ private void notifyCloseAllReqStateMan()
+ throws COPSPdpException {
+ if (_managerMap.size() > 0) {
+ for (Enumeration e = _managerMap.keys() ; e.hasMoreElements() ;) {
+ String handle = (String) e.nextElement();
+ PCMMPdpReqStateMan man = (PCMMPdpReqStateMan) _managerMap.get(handle);
+
+ man.processClosedConnection(_error);
+ }
+ }
+ }
+
+ private void notifyNoKAAllReqStateMan()
+ throws COPSPdpException {
+ if (_managerMap.size() > 0) {
+ for (Enumeration e = _managerMap.keys() ; e.hasMoreElements() ;) {
+ String handle = (String) e.nextElement();
+ PCMMPdpReqStateMan man = (PCMMPdpReqStateMan) _managerMap.get(handle);
+
+ man.processNoKAConnection();
+ }
+ }
+ }
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/PCMMPdpDataProcess.java b/packetcable-driver/src/main/java/org/pcmm/PCMMPdpDataProcess.java
new file mode 100644
index 0000000..e1e162a
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/PCMMPdpDataProcess.java
@@ -0,0 +1,208 @@
+/**
+ @header@
+ */
+
+package org.pcmm;
+
+import java.util.Hashtable;
+
+import org.pcmm.gates.ITransactionID;
+import org.pcmm.gates.impl.PCMMGateReq;
+// import org.umu.cops.prpdp.COPSPdpDataProcess;
+import org.umu.cops.stack.COPSError;
+
+
+public class PCMMPdpDataProcess { // extends COPSPdpDataProcess
+ private Hashtable installPolicy;
+ private Hashtable removePolicy;
+
+ public PCMMPdpDataProcess() {
+ }
+
+ /**
+ * PDPAgent gets the policies to delete from PEP
+ *
+ * @param man
+ * @return
+ */
+ public Hashtable getRemovePolicy(PCMMPdpReqStateMan man) {
+ return removePolicy;
+ }
+
+ /**
+ * PDPAgent gets the policies to be installed in PEP
+ *
+ * @param man
+ * @return
+ */
+ public Hashtable getInstallPolicy(PCMMPdpReqStateMan man) {
+ return installPolicy;
+ }
+
+ /**
+ * PEP configuration items for sending inside the request
+ *
+ * @param man
+ * @param reqSIs
+ */
+ public void setClientData(PCMMPdpReqStateMan man, Hashtable reqSIs) {
+
+ System.out.println(getClass().getName() + ": " + "Request Info");
+ /*
+ for (Enumeration e = reqSIs.keys() ; e.hasMoreElements() ;) {
+ String strprid = (String) e.nextElement();
+ String strepd = (String) reqSIs.get(strprid);
+
+ // Check PRID-EPD
+ // ....
+ System.out.println(getClass().getName() + ": " + "PRID: " + strprid);
+ System.out.println(getClass().getName() + ": " + "EPD: " + strepd);
+ }
+
+ // Create policies to be deleted
+ // ....
+
+ // Create policies to be installed
+ String prid = new String("");
+ String epd = new String("");
+ installPolicy.put(prid, epd);
+ */
+ }
+
+ /**
+ * Fail report received
+ *
+ * @param man
+ * @param reportSIs
+ */
+ public void failReport(PCMMPdpReqStateMan man, PCMMGateReq gateMsg) {
+
+ System.out.println(getClass().getName()+ ": " + "Fail Report notified.");
+ System.out.println(getClass().getName()+ ": " + gateMsg.getError().toString());
+
+ /*
+
+ System.out.println(getClass().getName() + ": " + "Report Info");
+ for (Enumeration e = reportSIs.keys() ; e.hasMoreElements() ;) {
+ String strprid = (String) e.nextElement();
+ String strepd = (String) reportSIs.get(strprid);
+
+ // Check PRID-EPD
+ // ....
+ System.out.println(getClass().getName()+ ": " + "PRID: " + strprid);
+ System.out.println(getClass().getName()+ ": " + "EPD: " + strepd);
+ }
+ */
+ }
+
+ /**
+ * Positive report received
+ *
+ * @param man
+ * @param reportSIs
+ */
+ public void successReport(PCMMPdpReqStateMan man, PCMMGateReq gateMsg) {
+ System.out.println(getClass().getName()+ ": " + "Success Report notified.");
+
+ if ( gateMsg.getTransactionID().getGateCommandType() == ITransactionID.GateDeleteAck ) {
+ System.out.println(getClass().getName()+ ": GateDeleteAck ");
+ System.out.println(getClass().getName()+ ": GateID = " + gateMsg.getGateID().getGateID());
+ if (gateMsg.getGateID().getGateID() == PCMMGlobalConfig.getGateID1())
+ PCMMGlobalConfig.setGateID1(0);
+ if (gateMsg.getGateID().getGateID() == PCMMGlobalConfig.getGateID2())
+ PCMMGlobalConfig.setGateID2(0);
+
+ }
+ if ( gateMsg.getTransactionID().getGateCommandType() == ITransactionID.GateSetAck ) {
+ System.out.println(getClass().getName()+ ": GateSetAck ");
+ System.out.println(getClass().getName()+ ": GateID = " + gateMsg.getGateID().getGateID());
+ if (0 == PCMMGlobalConfig.getGateID1())
+ PCMMGlobalConfig.setGateID1(gateMsg.getGateID().getGateID());
+ if (0 == PCMMGlobalConfig.getGateID2())
+ PCMMGlobalConfig.setGateID2(gateMsg.getGateID().getGateID());
+ }
+
+ /*
+ System.out.println(getClass().getName()+ ": " + "Report Info");
+ for (Enumeration e = reportSIs.keys() ; e.hasMoreElements() ;) {
+ String strprid = (String) e.nextElement();
+ String strepd = (String) reportSIs.get(strprid);
+
+ // Check PRID-EPD
+ // ....
+ System.out.println(getClass().getName()+ ": " + "PRID: " + strprid);
+ System.out.println(getClass().getName()+ ": " + "EPD: " + strepd);
+ }
+ */
+
+ }
+
+ /**
+ * Accounting report received
+ *
+ * @param man
+ * @param reportSIs
+ */
+ public void acctReport(PCMMPdpReqStateMan man, PCMMGateReq gateMsg) {
+ System.out.println(getClass().getName()+ ": " + "Acct Report notified.");
+
+ /*
+ System.out.println(getClass().getName()+ ": " + "Report Info");
+ for (Enumeration e = reportSIs.keys() ; e.hasMoreElements() ;) {
+ String strprid = (String) e.nextElement();
+ String strepd = (String) reportSIs.get(strprid);
+
+ // Check PRID-EPD
+ // ....
+ System.out.println(getClass().getName()+ ": " + "PRID: " + strprid);
+ System.out.println(getClass().getName()+ ": " + "EPD: " + strepd);
+ }
+ */
+ }
+
+ /**
+ * Notifies that an Accounting report is missing
+ *
+ * @param man
+ */
+ public void notifyNoAcctReport(PCMMPdpReqStateMan man) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ /**
+ * Notifies that a KeepAlive message is missing
+ *
+ * @param man
+ */
+ public void notifyNoKAliveReceived(PCMMPdpReqStateMan man) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ /**
+ * PEP closed the connection
+ *
+ * @param man
+ * @param error
+ */
+ public void notifyClosedConnection(PCMMPdpReqStateMan man, COPSError error) {
+ System.out.println(getClass().getName() + ": " + "Connection was closed by PEP");
+ }
+
+ /**
+ * Delete request state received
+ *
+ * @param man
+ */
+ public void notifyDeleteRequestState(PCMMPdpReqStateMan man) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ /**
+ * Closes request state
+ *
+ * @param man
+ */
+ public void closeRequestState(PCMMPdpReqStateMan man) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/PCMMPdpMsgSender.java b/packetcable-driver/src/main/java/org/pcmm/PCMMPdpMsgSender.java
new file mode 100644
index 0000000..89e7f44
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/PCMMPdpMsgSender.java
@@ -0,0 +1,981 @@
+/**
+ @header@
+ */
+
+package org.pcmm;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import org.pcmm.gates.IAMID;
+import org.pcmm.gates.IClassifier;
+import org.pcmm.gates.IExtendedClassifier;
+import org.pcmm.gates.IGateID;
+import org.pcmm.gates.IGateSpec;
+import org.pcmm.gates.IGateSpec.DSCPTOS;
+import org.pcmm.gates.IGateSpec.Direction;
+import org.pcmm.gates.IPCMMGate;
+import org.pcmm.gates.ISubscriberID;
+import org.pcmm.gates.ITrafficProfile;
+import org.pcmm.gates.ITransactionID;
+import org.pcmm.gates.impl.AMID;
+import org.pcmm.gates.impl.BestEffortService;
+import org.pcmm.gates.impl.Classifier;
+import org.pcmm.gates.impl.ExtendedClassifier;
+import org.pcmm.gates.impl.GateID;
+import org.pcmm.gates.impl.GateSpec;
+import org.pcmm.gates.impl.PCMMGateReq;
+import org.pcmm.gates.impl.SubscriberID;
+import org.pcmm.gates.impl.TransactionID;
+import org.umu.cops.prpdp.COPSPdpException;
+import org.umu.cops.stack.COPSClientSI;
+import org.umu.cops.stack.COPSContext;
+import org.umu.cops.stack.COPSData;
+import org.umu.cops.stack.COPSDecision;
+import org.umu.cops.stack.COPSDecisionMsg;
+import org.umu.cops.stack.COPSException;
+import org.umu.cops.stack.COPSHandle;
+import org.umu.cops.stack.COPSHeader;
+import org.umu.cops.stack.COPSMsg;
+import org.umu.cops.stack.COPSObjHeader;
+//temp
+import org.umu.cops.stack.COPSReportMsg;
+import org.umu.cops.stack.COPSSyncStateMsg;
+import org.umu.cops.stack.COPSTransceiver;
+//pcmm
+/*
+ * Example of an UNSOLICITED decision
+ *
+ * =
+ *
+ * = | | |
+ * | |
+ * = []
+ * [] []
+ * [] [][] []
+ */
+
+/**
+ * COPS message transceiver class for provisioning connections at the PDP side.
+ */
+public class PCMMPdpMsgSender {
+
+ /**
+ * Socket connected to PEP
+ */
+ protected Socket _sock;
+
+ /**
+ * COPS client-type that identifies the policy client
+ */
+ protected short _clientType;
+
+ /**
+ * COPS client handle used to uniquely identify a particular PEP's request
+ * for a client-type
+ */
+ protected COPSHandle _handle;
+
+ /**
+ *
+ */
+ protected short _transactionID;
+ protected short _classifierID;
+ // XXX - this does not need to be here
+ protected int _gateID;
+
+ /**
+ * Creates a PCMMPdpMsgSender
+ *
+ * @param clientType
+ * COPS client-type
+ * @param clientHandle
+ * Client handle
+ * @param sock
+ * Socket to the PEP
+ */
+ public PCMMPdpMsgSender(short clientType, COPSHandle clientHandle,
+ Socket sock) {
+ // COPS Handle
+ _handle = clientHandle;
+ _clientType = clientType;
+
+ _transactionID = 0;
+ _classifierID = 0;
+ _sock = sock;
+ }
+
+ public PCMMPdpMsgSender(short clientType, short tID,
+ COPSHandle clientHandle, Socket sock) {
+ // COPS Handle
+ _handle = clientHandle;
+ _clientType = clientType;
+ _transactionID = tID;
+ _classifierID = 0;
+ _sock = sock;
+ }
+
+ /**
+ * Gets the client handle
+ *
+ * @return Client's COPSHandle
+ */
+ public COPSHandle getClientHandle() {
+ return _handle;
+ }
+
+ /**
+ * Gets the client-type
+ *
+ * @return Client-type value
+ */
+ public short getClientType() {
+ return _clientType;
+ }
+
+ /**
+ * Gets the transaction-id
+ *
+ * @return transaction-id value
+ */
+ public short getTransactionID() {
+ return _transactionID;
+ }
+
+
+ /**
+ * Sends a PCMM GateSet COPS Decision message
+ *
+ * @param
+ * @throws COPSPdpException
+ */
+ public void sendGateSet(IPCMMGate gate)
+ throws COPSPdpException {
+ // Common Header with the same ClientType as the request
+
+ COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_DEC, getClientType());
+
+ // Client Handle with the same clientHandle as the request
+ COPSHandle handle = new COPSHandle();
+ COPSDecisionMsg decisionMsg = new COPSDecisionMsg();
+ ITransactionID trID = new TransactionID();
+
+ handle.setId(getClientHandle().getId());
+
+ // set transaction ID to gate set
+ trID.setGateCommandType(ITransactionID.GateSet);
+ _transactionID = (short) (_transactionID == 0 ? (short) (Math.random() * hashCode())
+ : _transactionID);
+ trID.setTransactionIdentifier(_transactionID);
+
+ gate.setTransactionID(trID);
+
+
+ // new pcmm specific clientsi
+ COPSClientSI clientSD = new COPSClientSI(COPSObjHeader.COPS_DEC, (byte) 4);
+ byte[] data = gate.getData();
+ clientSD.setData(new COPSData(data, 0, data.length));
+ try {
+ decisionMsg.add(hdr);
+ decisionMsg.add(handle);
+ // Decisions (no flags supplied)
+ //
+ COPSContext cntxt = new COPSContext(COPSContext.CONFIG, (short) 0);
+ COPSDecision install = new COPSDecision();
+ install.setCmdCode(COPSDecision.DEC_INSTALL);
+ install.setFlags(COPSDecision.F_REQERROR);
+ decisionMsg.addDecision(install, cntxt);
+ decisionMsg.add(clientSD); // setting up the gate
+ /*
+ try {
+ decisionMsg.dump(System.out);
+ } catch (IOException unae) {
+ System.out.println("Error dumping " + unae.getMessage());
+ }
+ */
+
+ } catch (COPSException e) {
+ System.out.println("Error making Msg" + e.getMessage());
+ }
+
+ // ** Send the GateSet Decision
+ // **
+ try {
+ decisionMsg.writeData(_sock);
+ } catch (IOException e) {
+ System.out.println("Failed to send the decision, reason: "
+ + e.getMessage());
+ }
+
+ }
+
+ /**
+ * Sends a PCMM GateSet COPS Decision message
+ *
+ * @param
+ * @throws COPSPdpException
+ */
+ public void sendGateSetDemo(int num)
+ throws COPSPdpException {
+
+ // Common Header with the same ClientType as the request
+
+ COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_DEC, getClientType());
+
+ // Client Handle with the same clientHandle as the request
+ COPSHandle handle = new COPSHandle();
+ COPSDecisionMsg decisionMsg = new COPSDecisionMsg();
+
+ IPCMMGate gate = new PCMMGateReq();
+ ITransactionID trID = new TransactionID();
+
+ IAMID amid = new AMID();
+ ISubscriberID subscriberID = new SubscriberID();
+ IGateSpec gateSpec = new GateSpec();
+ IClassifier classifier = new Classifier();
+ IExtendedClassifier eclassifier = new ExtendedClassifier();
+ int TrafficRate = 0;
+
+ if (num == 1)
+ TrafficRate = PCMMGlobalConfig.DefaultBestEffortTrafficRate;
+ else
+ TrafficRate = PCMMGlobalConfig.DefaultLowBestEffortTrafficRate;
+
+ ITrafficProfile trafficProfile = new BestEffortService(
+ (byte) 7); //BestEffortService.DEFAULT_ENVELOP);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setMaximumTrafficBurst(
+ BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setRequestTransmissionPolicy(
+ PCMMGlobalConfig.BETransmissionPolicy);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setMaximumSustainedTrafficRate(
+ TrafficRate);
+ // PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
+ // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
+
+ ((BestEffortService) trafficProfile).getReservedEnvelop()
+ .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
+ ((BestEffortService) trafficProfile).getReservedEnvelop()
+ .setMaximumTrafficBurst(
+ BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
+ ((BestEffortService) trafficProfile).getReservedEnvelop()
+ .setRequestTransmissionPolicy(
+ PCMMGlobalConfig.BETransmissionPolicy);
+ ((BestEffortService) trafficProfile).getReservedEnvelop()
+ .setMaximumSustainedTrafficRate(
+ TrafficRate);
+ // PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
+ // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
+
+
+ ((BestEffortService) trafficProfile).getCommittedEnvelop()
+ .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
+ ((BestEffortService) trafficProfile).getCommittedEnvelop()
+ .setMaximumTrafficBurst(
+ BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
+ ((BestEffortService) trafficProfile).getCommittedEnvelop()
+ .setRequestTransmissionPolicy(
+ PCMMGlobalConfig.BETransmissionPolicy);
+ ((BestEffortService) trafficProfile).getCommittedEnvelop()
+ .setMaximumSustainedTrafficRate(
+ TrafficRate);
+ // PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
+ // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
+
+
+
+ // new pcmm specific clientsi
+ COPSClientSI clientSD = new COPSClientSI(COPSObjHeader.COPS_DEC, (byte) 4);
+
+ handle.setId(getClientHandle().getId());
+
+ // set transaction ID to gate set
+ trID.setGateCommandType(ITransactionID.GateSet);
+ _transactionID = (short) (_transactionID == 0 ? (short) (Math.random() * hashCode())
+ : _transactionID);
+ trID.setTransactionIdentifier(_transactionID);
+
+ amid.setApplicationType((short) 1);
+ amid.setApplicationMgrTag((short) 1);
+ gateSpec.setDirection(Direction.UPSTREAM);
+ gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
+ gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
+ gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
+ gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
+ gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
+
+ // XXX - if the version major is less than 4 we need to use Classifier
+ if (true) {
+ //eclassifier.setProtocol(IClassifier.Protocol.NONE);
+ eclassifier.setProtocol(IClassifier.Protocol.TCP);
+ try {
+ InetAddress subIP = InetAddress
+ .getByName(PCMMGlobalConfig.SubscriberID);
+ InetAddress srcIP = InetAddress
+ .getByName(PCMMGlobalConfig.srcIP);
+ InetAddress dstIP = InetAddress
+ .getByName(PCMMGlobalConfig.dstIP);
+ InetAddress mask = InetAddress.getByName("0.0.0.0");
+ subscriberID.setSourceIPAddress(subIP);
+ eclassifier.setSourceIPAddress(srcIP);
+ eclassifier.setDestinationIPAddress(dstIP);
+ eclassifier.setIPDestinationMask(mask);
+ eclassifier.setIPSourceMask(mask);
+ } catch (UnknownHostException unae) {
+ System.out.println("Error getByName" + unae.getMessage());
+ }
+ eclassifier.setSourcePortStart(PCMMGlobalConfig.srcPort);
+ eclassifier.setSourcePortEnd(PCMMGlobalConfig.srcPort);
+ eclassifier.setDestinationPortStart(PCMMGlobalConfig.dstPort);
+ eclassifier.setDestinationPortEnd(PCMMGlobalConfig.dstPort);
+ eclassifier.setActivationState((byte) 0x01);
+ // check if we have a stored value of classifierID else we just
+ // create
+ // one
+ // eclassifier.setClassifierID((short) 0x01);
+ eclassifier.setClassifierID((short) (_classifierID == 0 ? Math
+ .random() * hashCode() : _classifierID));
+ // XXX - testie
+ // eclassifier.setClassifierID((short) 1);
+
+ eclassifier.setAction((byte) 0x00);
+ // XXX - temp default until Gate Modify is hacked in
+ // eclassifier.setPriority(PCMMGlobalConfig.EClassifierPriority);
+ eclassifier.setPriority((byte) 65);
+
+ } else {
+ classifier.setProtocol(IClassifier.Protocol.TCP);
+ try {
+ InetAddress subIP = InetAddress
+ .getByName(PCMMGlobalConfig.SubscriberID);
+ InetAddress srcIP = InetAddress
+ .getByName(PCMMGlobalConfig.srcIP);
+ InetAddress dstIP = InetAddress
+ .getByName(PCMMGlobalConfig.dstIP);
+ subscriberID.setSourceIPAddress(subIP);
+ classifier.setSourceIPAddress(srcIP);
+ classifier.setDestinationIPAddress(dstIP);
+ } catch (UnknownHostException unae) {
+ System.out.println("Error getByName" + unae.getMessage());
+ }
+ classifier.setSourcePort(PCMMGlobalConfig.srcPort);
+ classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
+ }
+
+ gate.setTransactionID(trID);
+ gate.setAMID(amid);
+ gate.setSubscriberID(subscriberID);
+ gate.setGateSpec(gateSpec);
+ gate.setTrafficProfile(trafficProfile);
+ gate.setClassifier(eclassifier);
+
+ byte[] data = gate.getData();
+
+ // new pcmm specific clientsi
+ clientSD.setData(new COPSData(data, 0, data.length));
+ try {
+ decisionMsg.add(hdr);
+ decisionMsg.add(handle);
+ // Decisions (no flags supplied)
+ //
+ COPSContext cntxt = new COPSContext(COPSContext.CONFIG, (short) 0);
+ COPSDecision install = new COPSDecision();
+ install.setCmdCode(COPSDecision.DEC_INSTALL);
+ install.setFlags(COPSDecision.F_REQERROR);
+ decisionMsg.addDecision(install, cntxt);
+ decisionMsg.add(clientSD); // setting up the gate
+ /*
+ try {
+ decisionMsg.dump(System.out);
+ } catch (IOException unae) {
+ System.out.println("Error dumping " + unae.getMessage());
+ }
+ */
+
+ } catch (COPSException e) {
+ System.out.println("Error making Msg" + e.getMessage());
+ }
+
+ // ** Send the GateSet Decision
+ // **
+ try {
+ decisionMsg.writeData(_sock);
+ } catch (IOException e) {
+ System.out.println("Failed to send the decision, reason: "
+ + e.getMessage());
+ }
+
+ }
+ /**
+ * Sends a PCMM GateSet COPS Decision message
+ *
+ * @param
+ * @throws COPSPdpException
+ */
+ public void sendGateSetBestEffortWithExtendedClassifier()
+ throws COPSPdpException {
+ // Common Header with the same ClientType as the request
+
+ COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_DEC, getClientType());
+
+ // Client Handle with the same clientHandle as the request
+ COPSHandle handle = new COPSHandle();
+ COPSDecisionMsg decisionMsg = new COPSDecisionMsg();
+
+ IPCMMGate gate = new PCMMGateReq();
+ ITransactionID trID = new TransactionID();
+
+ IAMID amid = new AMID();
+ ISubscriberID subscriberID = new SubscriberID();
+ IGateSpec gateSpec = new GateSpec();
+ IClassifier classifier = new Classifier();
+ IExtendedClassifier eclassifier = new ExtendedClassifier();
+
+ // XXX check if other values should be provided
+ //
+ ITrafficProfile trafficProfile = new BestEffortService(
+ (byte) 7); //BestEffortService.DEFAULT_ENVELOP);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setMaximumTrafficBurst(
+ BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setRequestTransmissionPolicy(
+ PCMMGlobalConfig.BETransmissionPolicy);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setMaximumSustainedTrafficRate(
+ PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
+ // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
+
+ ((BestEffortService) trafficProfile).getReservedEnvelop()
+ .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
+ ((BestEffortService) trafficProfile).getReservedEnvelop()
+ .setMaximumTrafficBurst(
+ BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
+ ((BestEffortService) trafficProfile).getReservedEnvelop()
+ .setRequestTransmissionPolicy(
+ PCMMGlobalConfig.BETransmissionPolicy);
+ ((BestEffortService) trafficProfile).getReservedEnvelop()
+ .setMaximumSustainedTrafficRate(
+ PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
+ // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
+
+
+ ((BestEffortService) trafficProfile).getCommittedEnvelop()
+ .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
+ ((BestEffortService) trafficProfile).getCommittedEnvelop()
+ .setMaximumTrafficBurst(
+ BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
+ ((BestEffortService) trafficProfile).getCommittedEnvelop()
+ .setRequestTransmissionPolicy(
+ PCMMGlobalConfig.BETransmissionPolicy);
+ ((BestEffortService) trafficProfile).getCommittedEnvelop()
+ .setMaximumSustainedTrafficRate(
+ PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
+ // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
+
+
+
+ // new pcmm specific clientsi
+ COPSClientSI clientSD = new COPSClientSI(COPSObjHeader.COPS_DEC,
+ (byte) 4);
+
+ handle.setId(getClientHandle().getId());
+
+ // set transaction ID to gate set
+ trID.setGateCommandType(ITransactionID.GateSet);
+ _transactionID = (short) (_transactionID == 0 ? (short) (Math.random() * hashCode())
+ : _transactionID);
+ trID.setTransactionIdentifier(_transactionID);
+
+ amid.setApplicationType((short) 1);
+ amid.setApplicationMgrTag((short) 1);
+ gateSpec.setDirection(Direction.UPSTREAM);
+ gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
+ gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
+ gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
+ gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
+ gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
+
+ // XXX - if the version major is less than 4 we need to use Classifier
+ if (true) {
+ //eclassifier.setProtocol(IClassifier.Protocol.NONE);
+ eclassifier.setProtocol(IClassifier.Protocol.TCP);
+ try {
+ InetAddress subIP = InetAddress
+ .getByName(PCMMGlobalConfig.SubscriberID);
+ InetAddress srcIP = InetAddress
+ .getByName(PCMMGlobalConfig.srcIP);
+ InetAddress dstIP = InetAddress
+ .getByName(PCMMGlobalConfig.dstIP);
+ InetAddress mask = InetAddress.getByName("0.0.0.0");
+ subscriberID.setSourceIPAddress(subIP);
+ eclassifier.setSourceIPAddress(srcIP);
+ eclassifier.setDestinationIPAddress(dstIP);
+ eclassifier.setIPDestinationMask(mask);
+ eclassifier.setIPSourceMask(mask);
+ } catch (UnknownHostException unae) {
+ System.out.println("Error getByName" + unae.getMessage());
+ }
+ eclassifier.setSourcePortStart(PCMMGlobalConfig.srcPort);
+ eclassifier.setSourcePortEnd(PCMMGlobalConfig.srcPort);
+ eclassifier.setDestinationPortStart(PCMMGlobalConfig.dstPort);
+ eclassifier.setDestinationPortEnd(PCMMGlobalConfig.dstPort);
+ eclassifier.setActivationState((byte) 0x01);
+ // check if we have a stored value of classifierID else we just
+ // create
+ // one
+ // eclassifier.setClassifierID((short) 0x01);
+ eclassifier.setClassifierID((short) (_classifierID == 0 ? Math
+ .random() * hashCode() : _classifierID));
+ // XXX - testie
+ // eclassifier.setClassifierID((short) 1);
+
+ eclassifier.setAction((byte) 0x00);
+ // XXX - temp default until Gate Modify is hacked in
+ // eclassifier.setPriority(PCMMGlobalConfig.EClassifierPriority);
+ eclassifier.setPriority((byte) 65);
+
+ } else {
+ classifier.setProtocol(IClassifier.Protocol.TCP);
+ try {
+ InetAddress subIP = InetAddress
+ .getByName(PCMMGlobalConfig.SubscriberID);
+ InetAddress srcIP = InetAddress
+ .getByName(PCMMGlobalConfig.srcIP);
+ InetAddress dstIP = InetAddress
+ .getByName(PCMMGlobalConfig.dstIP);
+ subscriberID.setSourceIPAddress(subIP);
+ classifier.setSourceIPAddress(srcIP);
+ classifier.setDestinationIPAddress(dstIP);
+ } catch (UnknownHostException unae) {
+ System.out.println("Error getByName" + unae.getMessage());
+ }
+ classifier.setSourcePort(PCMMGlobalConfig.srcPort);
+ classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
+ }
+
+ gate.setTransactionID(trID);
+ gate.setAMID(amid);
+ gate.setSubscriberID(subscriberID);
+ gate.setGateSpec(gateSpec);
+ gate.setTrafficProfile(trafficProfile);
+ gate.setClassifier(eclassifier);
+
+ byte[] data = gate.getData();
+
+ // new pcmm specific clientsi
+ clientSD.setData(new COPSData(data, 0, data.length));
+ try {
+ decisionMsg.add(hdr);
+ decisionMsg.add(handle);
+ // Decisions (no flags supplied)
+ //
+ COPSContext cntxt = new COPSContext(COPSContext.CONFIG, (short) 0);
+ COPSDecision install = new COPSDecision();
+ install.setCmdCode(COPSDecision.DEC_INSTALL);
+ install.setFlags(COPSDecision.F_REQERROR);
+ decisionMsg.addDecision(install, cntxt);
+ decisionMsg.add(clientSD); // setting up the gate
+ /*
+ try {
+ decisionMsg.dump(System.out);
+ } catch (IOException unae) {
+ System.out.println("Error dumping " + unae.getMessage());
+ }
+ */
+
+ } catch (COPSException e) {
+ System.out.println("Error making Msg" + e.getMessage());
+ }
+
+ // ** Send the GateSet Decision
+ // **
+ try {
+ decisionMsg.writeData(_sock);
+ } catch (IOException e) {
+ System.out.println("Failed to send the decision, reason: "
+ + e.getMessage());
+ }
+
+ }
+
+
+ public boolean handleGateReport(Socket socket) throws COPSPdpException {
+ try {
+ // waits for the gate-set-ack or error
+ COPSMsg responseMsg = COPSTransceiver.receiveMsg(socket);
+ if (responseMsg.getHeader().isAReport()) {
+ System.out.println("processing received report from CMTS");
+ COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
+ if (reportMsg.getClientSI().size() == 0) {
+ return false;
+ }
+ COPSClientSI clientSI = (COPSClientSI) reportMsg.getClientSI()
+ .elementAt(0);
+ IPCMMGate responseGate = new PCMMGateReq(clientSI.getData()
+ .getData());
+ if (responseGate.getTransactionID() != null
+ && responseGate.getTransactionID().getGateCommandType() == ITransactionID.GateSetAck) {
+ System.out.println("the CMTS has sent a Gate-Set-Ack response");
+ // here CMTS responded that he acknowledged the Gate-Set
+ // TODO do further check of Gate-Set-Ack GateID etc...
+ _gateID = responseGate.getGateID().getGateID();
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return false;
+ } catch (Exception e) { // COPSException, IOException
+ throw new COPSPdpException("Error COPSTransceiver.receiveMsg");
+ }
+ }
+
+
+ /**
+ * Sends a PCMM GateSet COPS Decision message
+ *
+ * @param
+ * @throws COPSPdpException
+ */
+ public void sendGateSet() throws COPSPdpException {
+ // Common Header with the same ClientType as the request
+
+ COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_DEC, getClientType());
+
+ // Client Handle with the same clientHandle as the request
+ COPSHandle handle = new COPSHandle();
+ COPSDecisionMsg decisionMsg = new COPSDecisionMsg();
+
+ IPCMMGate gate = new PCMMGateReq();
+ ITransactionID trID = new TransactionID();
+
+ IAMID amid = new AMID();
+ ISubscriberID subscriberID = new SubscriberID();
+ IGateSpec gateSpec = new GateSpec();
+ IClassifier classifier = new Classifier();
+ // XXX check if other values should be provided
+ ITrafficProfile trafficProfile = new BestEffortService(
+ BestEffortService.DEFAULT_ENVELOP);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setMaximumTrafficBurst(
+ BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
+ .setRequestTransmissionPolicy(
+ PCMMGlobalConfig.BETransmissionPolicy);
+
+ // new pcmm specific clientsi
+ COPSClientSI clientSD = new COPSClientSI(COPSObjHeader.COPS_DEC,
+ (byte) 4);
+
+ handle.setId(getClientHandle().getId());
+ // byte[] content = "1234".getBytes();
+
+ // handle.setId(new COPSData(content, 0, content.length));
+
+ // set transaction ID to gate set
+ trID.setGateCommandType(ITransactionID.GateSet);
+ _transactionID = (short) (_transactionID == 0 ? (short) (Math.random() * hashCode())
+ : _transactionID);
+ trID.setTransactionIdentifier(_transactionID);
+
+ amid.setApplicationType((short) 1);
+ amid.setApplicationMgrTag((short) 1);
+ gateSpec.setDirection(Direction.UPSTREAM);
+ gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
+ gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
+ gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
+ gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
+ gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
+
+ /*
+ * ((DOCSISServiceClassNameTrafficProfile) trafficProfile)
+ * .setServiceClassName("S_up");
+ */
+
+ classifier.setProtocol(IClassifier.Protocol.TCP);
+ try {
+ InetAddress subIP = InetAddress.getByName(PCMMGlobalConfig.SubscriberID);
+ InetAddress srcIP = InetAddress.getByName(PCMMGlobalConfig.srcIP);
+ InetAddress dstIP = InetAddress.getByName(PCMMGlobalConfig.dstIP);
+ subscriberID.setSourceIPAddress(subIP);
+ classifier.setSourceIPAddress(srcIP);
+ classifier.setDestinationIPAddress(dstIP);
+ } catch (UnknownHostException unae) {
+ System.out.println("Error getByName" + unae.getMessage());
+ }
+ classifier.setSourcePort(PCMMGlobalConfig.srcPort);
+ classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
+
+ gate.setTransactionID(trID);
+ gate.setAMID(amid);
+ gate.setSubscriberID(subscriberID);
+ gate.setGateSpec(gateSpec);
+ gate.setTrafficProfile(trafficProfile);
+ gate.setClassifier(classifier);
+
+ byte[] data = gate.getData();
+
+ // new pcmm specific clientsi
+ clientSD.setData(new COPSData(data, 0, data.length));
+
+ try {
+ decisionMsg.add(hdr);
+ decisionMsg.add(handle);
+ // Decisions (no flags supplied)
+ //
+ COPSContext cntxt = new COPSContext(COPSContext.CONFIG, (short) 0);
+ COPSDecision install = new COPSDecision();
+ install.setCmdCode(COPSDecision.DEC_INSTALL);
+ install.setFlags(COPSDecision.F_REQERROR);
+ decisionMsg.addDecision(install, cntxt);
+ decisionMsg.add(clientSD); // setting up the gate
+ /*
+ try {
+ decisionMsg.dump(System.out);
+ } catch (IOException unae) {
+ System.out.println("Error dumping " + unae.getMessage());
+ }
+ */
+
+ } catch (COPSException e) {
+ System.out.println("Error making Msg" + e.getMessage());
+ }
+
+ // ** Send the GateSet Decision
+ // **
+ try {
+ decisionMsg.writeData(_sock);
+ } catch (IOException e) {
+ System.out.println("Failed to send the decision, reason: "
+ + e.getMessage());
+ }
+
+ }
+
+ /**
+ * Sends a message asking that the request state be deleted
+ *
+ * @throws COPSPdpException
+ */
+ public void sendGateDelete(int gID) throws COPSPdpException {
+ /*
+ * Example of an UNSOLICITED decision = = | | |
+ * | | =
+ *
+ */
+ // Common Header with the same ClientType as the request
+ COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_DEC, getClientType());
+
+ // Client Handle with the same clientHandle as the request
+ COPSHandle handle = new COPSHandle();
+ COPSDecisionMsg decisionMsg = new COPSDecisionMsg();
+
+ IPCMMGate gate = new PCMMGateReq();
+ ITransactionID trID = new TransactionID();
+
+ IAMID amid = new AMID();
+ ISubscriberID subscriberID = new SubscriberID();
+ IGateSpec gateSpec = new GateSpec();
+ IGateID gateID = new GateID();
+
+ // new pcmm specific clientsi
+ COPSClientSI clientSD = new COPSClientSI(COPSObjHeader.COPS_DEC, (byte) 4);
+
+ handle.setId(getClientHandle().getId());
+
+ // set transaction ID to gate set
+ trID.setGateCommandType(ITransactionID.GateDelete);
+ _transactionID = (short) (_transactionID == 0 ? (short) (Math.random() * hashCode())
+ : _transactionID);
+ trID.setTransactionIdentifier(_transactionID);
+
+ amid.setApplicationType((short) 1);
+ amid.setApplicationMgrTag((short) 1);
+ gateID.setGateID(gID);
+
+ try {
+ InetAddress subIP = InetAddress.getByName(PCMMGlobalConfig.SubscriberID);
+ subscriberID.setSourceIPAddress(subIP);
+ } catch (UnknownHostException unae) {
+ System.out.println("Error getByName" + unae.getMessage());
+ }
+
+ gate.setTransactionID(trID);
+ gate.setAMID(amid);
+ gate.setSubscriberID(subscriberID);
+ gate.setGateID(gateID);
+
+ // XXX - GateID
+ byte[] data = gate.getData();
+
+ // new pcmm specific clientsi
+ clientSD.setData(new COPSData(data, 0, data.length));
+
+ try {
+ decisionMsg.add(hdr);
+ decisionMsg.add(handle);
+ // Decisions (no flags supplied)
+ //
+ COPSContext cntxt = new COPSContext(COPSContext.CONFIG, (short) 0);
+ COPSDecision install = new COPSDecision();
+ install.setCmdCode(COPSDecision.DEC_INSTALL);
+ install.setFlags(COPSDecision.F_REQERROR);
+ decisionMsg.addDecision(install, cntxt);
+ decisionMsg.add(clientSD); // setting up the gate
+ /*
+ try {
+ decisionMsg.dump(System.out);
+ } catch (IOException unae) {
+ System.out.println("Error dumping " + unae.getMessage());
+ }
+ */
+
+ } catch (COPSException e) {
+ System.out.println("Error making Msg" + e.getMessage());
+ }
+
+ // ** Send the GateDelete Decision
+ // **
+ try {
+ decisionMsg.writeData(_sock);
+ // decisionMsg.writeData(socket_id);
+ } catch (IOException e) {
+ System.out.println("Failed to send the decision, reason: "
+ + e.getMessage());
+ }
+ }
+
+ /**
+ * Sends a request asking that a new request state be created
+ *
+ * @throws COPSPdpException
+ */
+ public void sendOpenNewRequestState() throws COPSPdpException {
+ /*
+ * ::= *() [] ::=
+ * ::= Install Request-State
+ */
+
+ // Common Header with the same ClientType as the request (default
+ // UNSOLICITED)
+ COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_DEC, getClientType());
+
+ // Client Handle with the same clientHandle as the request
+ COPSHandle clienthandle = new COPSHandle();
+ clienthandle.setId(_handle.getId());
+
+ // Decisions
+ //
+ COPSContext cntxt = new COPSContext(COPSContext.CONFIG, (short) 0);
+ //
+ COPSDecision dec = new COPSDecision();
+ dec.setCmdCode(COPSDecision.DEC_INSTALL);
+ dec.setFlags(COPSDecision.F_REQSTATE);
+
+ COPSDecisionMsg decisionMsg = new COPSDecisionMsg();
+ try {
+ decisionMsg.add(hdr);
+ decisionMsg.add(clienthandle);
+ decisionMsg.addDecision(dec, cntxt);
+ } catch (COPSException e) {
+ throw new COPSPdpException("Error making Msg");
+ }
+
+ try {
+ decisionMsg.writeData(_sock);
+ } catch (IOException e) {
+ throw new COPSPdpException(
+ "Failed to send the open new request state, reason: "
+ + e.getMessage());
+ }
+ }
+
+ /**
+ * Sends a message asking for a COPS sync operation
+ *
+ * @throws COPSPdpException
+ */
+ public void sendGateInfo() throws COPSPdpException {
+ /*
+ * ::= [] []
+ */
+
+ // Common Header with the same ClientType as the request
+ COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_SSQ, getClientType());
+
+ // Client Handle with the same clientHandle as the request
+ COPSHandle clienthandle = new COPSHandle();
+ clienthandle.setId(_handle.getId());
+
+ COPSSyncStateMsg msg = new COPSSyncStateMsg();
+ try {
+ msg.add(hdr);
+ msg.add(clienthandle);
+ } catch (Exception e) {
+ throw new COPSPdpException("Error making Msg");
+ }
+
+ try {
+ msg.writeData(_sock);
+ } catch (IOException e) {
+ throw new COPSPdpException(
+ "Failed to send the GateInfo request, reason: "
+ + e.getMessage());
+ }
+ }
+
+ /**
+ * Sends a message asking for a COPS sync operation
+ *
+ * @throws COPSPdpException
+ */
+ public void sendSyncRequest() throws COPSPdpException {
+ /*
+ * ::= []
+ * []
+ */
+
+ // Common Header with the same ClientType as the request
+ COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_SSQ, getClientType());
+
+ // Client Handle with the same clientHandle as the request
+ COPSHandle clienthandle = new COPSHandle();
+ clienthandle.setId(_handle.getId());
+
+ COPSSyncStateMsg msg = new COPSSyncStateMsg();
+ try {
+ msg.add(hdr);
+ msg.add(clienthandle);
+ } catch (Exception e) {
+ throw new COPSPdpException("Error making Msg");
+ }
+
+ try {
+ msg.writeData(_sock);
+ } catch (IOException e) {
+ throw new COPSPdpException(
+ "Failed to send the sync state request, reason: "
+ + e.getMessage());
+ }
+ }
+ // XXX - Temp
+ public void sendSyncRequestState() throws COPSPdpException {
+ }
+ // XXX - Temp
+ public void sendDeleteRequestState() throws COPSPdpException {
+ }
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/PCMMPdpReqStateMan.java b/packetcable-driver/src/main/java/org/pcmm/PCMMPdpReqStateMan.java
new file mode 100644
index 0000000..6ef939b
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/PCMMPdpReqStateMan.java
@@ -0,0 +1,461 @@
+/**
+ @header@
+ */
+
+package org.pcmm;
+
+/*
+import java.io.*;
+import java.util.UUID.*;
+*/
+import java.net.Socket;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.pcmm.gates.ITransactionID;
+import org.pcmm.gates.impl.PCMMGateReq;
+import org.umu.cops.common.COPSDebug;
+import org.umu.cops.prpdp.COPSPdpException;
+import org.umu.cops.stack.COPSClientSI;
+import org.umu.cops.stack.COPSContext;
+import org.umu.cops.stack.COPSData;
+import org.umu.cops.stack.COPSDeleteMsg;
+import org.umu.cops.stack.COPSError;
+import org.umu.cops.stack.COPSHandle;
+import org.umu.cops.stack.COPSHeader;
+import org.umu.cops.stack.COPSPrObjBase;
+import org.umu.cops.stack.COPSReportMsg;
+import org.umu.cops.stack.COPSReportType;
+import org.umu.cops.stack.COPSReqMsg;
+import org.umu.cops.stack.COPSSyncStateMsg;
+/*
+import org.pcmm.base.IPCMMBaseObject;
+import org.pcmm.gates.IAMID;
+import org.pcmm.gates.IGateID;
+import org.pcmm.gates.ISubscriberID;
+import org.pcmm.gates.IPCError;
+import org.pcmm.gates.impl.AMID;
+import org.pcmm.gates.impl.GateID;
+import org.pcmm.gates.impl.SubscriberID;
+import org.pcmm.gates.impl.TransactionID;
+import org.pcmm.gates.impl.PCError;
+*/
+
+
+
+
+/**
+ * State manager class for provisioning requests, at the PDP side.
+ */
+public class PCMMPdpReqStateMan {
+
+ /**
+ * Request State created
+ */
+ public final static short ST_CREATE = 1;
+ /**
+ * Request received
+ */
+ public final static short ST_INIT = 2;
+ /**
+ * Decisions sent
+ */
+ public final static short ST_DECS = 3;
+ /**
+ * Report received
+ */
+ public final static short ST_REPORT = 4;
+ /**
+ * Request State finalized
+ */
+ public final static short ST_FINAL = 5;
+ /**
+ * New Request State solicited
+ */
+ public final static short ST_NEW = 6;
+ /**
+ * Delete Request State solicited
+ */
+ public final static short ST_DEL = 7;
+ /**
+ * SYNC request sent
+ */
+ public final static short ST_SYNC = 8;
+ /**
+ * SYNC completed
+ */
+ public final static short ST_SYNCALL = 9;
+ /**
+ * Close connection received
+ */
+ public final static short ST_CCONN = 10;
+ /**
+ * Keep-alive timeout
+ */
+ public final static short ST_NOKA = 11;
+ /**
+ * Accounting timeout
+ */
+ public final static short ST_ACCT = 12;
+
+ /**
+ * COPS client-type that identifies the policy client
+ */
+ protected short _clientType;
+
+ /**
+ * COPS client handle used to uniquely identify a particular
+ * PEP's request for a client-type
+ */
+ protected COPSHandle _handle;
+
+ /**
+ * Object for performing policy data processing
+ */
+ protected PCMMPdpDataProcess _process;
+
+ /**
+ * Current state of the request being managed
+ */
+ protected short _status;
+
+ /** COPS message transceiver used to send COPS messages */
+ protected PCMMPdpMsgSender _sender;
+
+ /**
+ * Creates a request state manager
+ * @param clientType Client-type
+ * @param clientHandle Client handle
+ */
+ public PCMMPdpReqStateMan(short clientType, String clientHandle) {
+ // COPS Handle
+ _handle = new COPSHandle();
+ COPSData id = new COPSData(clientHandle);
+ _handle.setId(id);
+ // client-type
+ _clientType = clientType;
+
+ _status = ST_CREATE;
+ }
+
+ /**
+ * Gets the client handle
+ * @return Client's COPSHandle
+ */
+ public COPSHandle getClientHandle() {
+ return _handle;
+ }
+
+ /**
+ * Gets the client-type
+ * @return Client-type value
+ */
+ public short getClientType() {
+ return _clientType;
+ }
+
+ /**
+ * Gets the status of the request
+ * @return Request state value
+ */
+ public short getStatus() {
+ return _status;
+ }
+
+ /**
+ * Gets the policy data processing object
+ * @return Policy data processing object
+ */
+ public PCMMPdpDataProcess getDataProcess() {
+ return _process;
+ }
+
+ /**
+ * Sets the policy data processing object
+ * @param process Policy data processing object
+ */
+ public void setDataProcess(PCMMPdpDataProcess process) {
+ _process = process;
+ }
+
+ /**
+ * Called when COPS sync is completed
+ * @param repMsg COPS sync message
+ * @throws COPSPdpException
+ */
+ protected void processSyncComplete(COPSSyncStateMsg repMsg)
+ throws COPSPdpException {
+
+ _status = ST_SYNCALL;
+
+ // maybe we should notifySyncComplete ...
+ }
+
+ /**
+ * Initializes a new request state over a socket
+ * @param sock Socket to the PEP
+ * @throws COPSPdpException
+ */
+ protected void initRequestState(Socket sock)
+ throws COPSPdpException {
+ // Inits an object for sending COPS messages to the PEP
+ _sender = new PCMMPdpMsgSender(_clientType, _handle, sock);
+
+ // Initial state
+ _status = ST_INIT;
+ }
+
+
+
+ /**
+ * Processes a COPS request
+ * @param msg COPS request received from the PEP
+ * @throws COPSPdpException
+ */
+ protected void processRequest(COPSReqMsg msg)
+ throws COPSPdpException {
+
+ COPSHeader hdrmsg = msg.getHeader();
+ COPSHandle handlemsg = msg.getClientHandle();
+ COPSContext contextmsg = msg.getContext();
+
+ //** Analyze the request
+ //**
+
+ /* ::=
+ *
+ *
+ * *()
+ * []
+ * ::= <*()>
+ *
+ * Very important, this is actually being treated like this:
+ * ::= |
+ *
+
+ // Named ClientSI
+ Vector clientSIs = msg.getClientSI();
+ Hashtable reqSIs = new Hashtable(40);
+ String strobjprid = new String();
+ for (Enumeration e = clientSIs.elements() ; e.hasMoreElements() ;) {
+ COPSClientSI clientSI = (COPSClientSI) e.nextElement();
+
+ COPSPrObjBase obj = new COPSPrObjBase(clientSI.getData().getData());
+ switch (obj.getSNum())
+ {
+ case COPSPrObjBase.PR_PRID:
+ strobjprid = obj.getData().str();
+ break;
+ case COPSPrObjBase.PR_EPD:
+ reqSIs.put(strobjprid, obj.getData().str());
+ // COPSDebug.out(getClass().getName(),"PRID: " + strobjprid);
+ // COPSDebug.out(getClass().getName(),"EPD: " + obj.getData().str());
+ break;
+ default:
+ break;
+ }
+ }
+
+ //** Here we must retrieve a decision depending on
+ //** the supplied ClientSIs
+ // reqSIs is a hashtable with the prid and epds
+
+ // ................
+ //
+ Hashtable removeDecs = new Hashtable();
+ Hashtable installDecs = new Hashtable();
+ _process.setClientData(this, reqSIs);
+
+ removeDecs = _process.getRemovePolicy(this);
+ installDecs = _process.getInstallPolicy(this);
+
+ //** We create the SOLICITED decision
+ //**
+ _sender.sendDecision(removeDecs, installDecs);
+ _status = ST_DECS;
+ */
+ }
+
+ /**
+ * Processes a report
+ * @param msg Report message from the PEP
+ * @throws COPSPdpException
+ */
+ protected void processReport(COPSReportMsg msg)
+ throws COPSPdpException {
+
+ //** Analyze the report
+ //**
+
+ /*
+ * ::=
+ *
+ *
+ * *()
+ * []
+ * ::= <[] *()>
+ * ::= *()
+ *
+ * Important, is not parsed
+ */
+
+ // COPSHeader hdrmsg = msg.getHeader();
+ // COPSHandle handlemsg = msg.getClientHandle();
+
+ // WriteBinaryDump("COPSReportMessage", msg.getData().getData());
+ // Report Type
+ COPSReportType rtypemsg = msg.getReport();
+
+ // Named ClientSI
+ Vector clientSIs = msg.getClientSI();
+ COPSClientSI myclientSI = (COPSClientSI) msg.getClientSI().elementAt(0);
+ byte[] data = Arrays.copyOfRange(myclientSI.getData().getData(), 0, myclientSI.getData().getData().length );
+
+ // PCMMUtils.WriteBinaryDump("COPSReportClientSI", data);
+ System.out.println("PCMMGateReq Parse Gate Message");
+ PCMMGateReq gateMsg = new PCMMGateReq(data);
+
+ Hashtable repSIs = new Hashtable(40);
+ String strobjprid = new String();
+ for (Enumeration e = clientSIs.elements() ; e.hasMoreElements() ;) {
+ COPSClientSI clientSI = (COPSClientSI) e.nextElement();
+
+ COPSPrObjBase obj = new COPSPrObjBase(clientSI.getData().getData());
+ switch (obj.getSNum()) {
+ case COPSPrObjBase.PR_PRID:
+ System.out.println("COPSPrObjBase.PR_PRID");
+ strobjprid = obj.getData().str();
+ break;
+ case COPSPrObjBase.PR_EPD:
+ System.out.println("COPSPrObjBase.PR_EPD");
+ repSIs.put(strobjprid, obj.getData().str());
+ // COPSDebug.out(getClass().getName(),"PRID: " + strobjprid);
+ // COPSDebug.out(getClass().getName(),"EPD: " + obj.getData().str());
+ break;
+ default:
+ COPSDebug.err(getClass().getName(),"Object s-num: " + obj.getSNum() + "stype " + obj.getSType());
+ COPSDebug.err(getClass().getName(),"PRID: " + strobjprid);
+ COPSDebug.err(getClass().getName(),"EPD: " + obj.getData().str());
+ break;
+ }
+ }
+
+ System.out.println("rtypemsg process");
+ //** Here we must act in accordance with
+ //** the report received
+ if (rtypemsg.isSuccess()) {
+ System.out.println("rtypemsg success");
+ _status = ST_REPORT;
+ if (_process != null)
+ _process.successReport(this, gateMsg);
+ else
+{
+ if ( gateMsg.getTransactionID().getGateCommandType() == ITransactionID.GateDeleteAck ) {
+ System.out.println(getClass().getName()+ ": GateDeleteAck ");
+ System.out.println(getClass().getName()+ ": GateID = " + gateMsg.getGateID().getGateID());
+ if (gateMsg.getGateID().getGateID() == PCMMGlobalConfig.getGateID1())
+ PCMMGlobalConfig.setGateID1(0);
+ if (gateMsg.getGateID().getGateID() == PCMMGlobalConfig.getGateID2())
+ PCMMGlobalConfig.setGateID2(0);
+
+ }
+ if ( gateMsg.getTransactionID().getGateCommandType() == ITransactionID.GateSetAck ) {
+ System.out.println(getClass().getName()+ ": GateSetAck ");
+ System.out.println(getClass().getName()+ ": GateID = " + gateMsg.getGateID().getGateID());
+ if (0 == PCMMGlobalConfig.getGateID1())
+ PCMMGlobalConfig.setGateID1(gateMsg.getGateID().getGateID());
+ if (0 == PCMMGlobalConfig.getGateID2())
+ PCMMGlobalConfig.setGateID2(gateMsg.getGateID().getGateID());
+ }
+
+}
+ } else if (rtypemsg.isFailure()) {
+ System.out.println("rtypemsg failure");
+ _status = ST_REPORT;
+ if (_process != null)
+ _process.failReport(this, gateMsg);
+else
+{
+ System.out.println(getClass().getName()+ ": " + gateMsg.getError().toString());
+}
+
+ } else if (rtypemsg.isAccounting()) {
+ System.out.println("rtypemsg account");
+ _status = ST_ACCT;
+ if (_process != null)
+ _process.acctReport(this, gateMsg);
+ }
+ System.out.println("Out processReport");
+ }
+
+ /**
+ * Called when connection is closed
+ * @param error Reason
+ * @throws COPSPdpException
+ */
+ protected void processClosedConnection(COPSError error)
+ throws COPSPdpException {
+ if (_process != null)
+ _process.notifyClosedConnection(this, error);
+
+ _status = ST_CCONN;
+ }
+
+ /**
+ * Called when no keep-alive is received
+ * @throws COPSPdpException
+ */
+ protected void processNoKAConnection()
+ throws COPSPdpException {
+ if (_process != null)
+ _process.notifyNoKAliveReceived(this);
+
+ _status = ST_NOKA;
+ }
+
+ /**
+ * Deletes the request state
+ * @throws COPSPdpException
+ */
+ protected void finalizeRequestState()
+ throws COPSPdpException {
+ _sender.sendDeleteRequestState();
+ _status = ST_FINAL;
+ }
+
+ /**
+ * Asks for a COPS sync
+ * @throws COPSPdpException
+ */
+ protected void syncRequestState()
+ throws COPSPdpException {
+ _sender.sendSyncRequestState();
+ _status = ST_SYNC;
+ }
+
+ /**
+ * Opens a new request state
+ * @throws COPSPdpException
+ */
+ protected void openNewRequestState()
+ throws COPSPdpException {
+ _sender.sendOpenNewRequestState();
+ _status = ST_NEW;
+ }
+
+ /**
+ * Processes a COPS delete message
+ * @param dMsg COPSDeleteMsg received from the PEP
+ * @throws COPSPdpException
+ */
+ protected void processDeleteRequestState(COPSDeleteMsg dMsg)
+ throws COPSPdpException {
+ if (_process != null)
+ _process.closeRequestState(this);
+
+ _status = ST_DEL;
+ }
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/PCMMPepAgent.java b/packetcable-driver/src/main/java/org/pcmm/PCMMPepAgent.java
new file mode 100644
index 0000000..394bdf1
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/PCMMPepAgent.java
@@ -0,0 +1,252 @@
+/**
+ @header@
+ */
+
+package org.pcmm;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import org.umu.cops.common.COPSDebug;
+import org.umu.cops.prpep.COPSPepAgent;
+import org.umu.cops.prpep.COPSPepConnection;
+import org.umu.cops.prpep.COPSPepException;
+import org.umu.cops.stack.COPSAcctTimer;
+import org.umu.cops.stack.COPSClientAcceptMsg;
+import org.umu.cops.stack.COPSClientCloseMsg;
+import org.umu.cops.stack.COPSClientOpenMsg;
+import org.umu.cops.stack.COPSData;
+import org.umu.cops.stack.COPSError;
+import org.umu.cops.stack.COPSException;
+import org.umu.cops.stack.COPSHeader;
+import org.umu.cops.stack.COPSKATimer;
+import org.umu.cops.stack.COPSMsg;
+import org.umu.cops.stack.COPSPepId;
+import org.umu.cops.stack.COPSTransceiver;
+
+/**
+ * This is a provisioning COPS PEP. Responsible for making connection to the PDP
+ * and maintaining it
+ */
+public class PCMMPepAgent extends COPSPepAgent implements Runnable {
+
+ /** Well-known port for COPS */
+ public static final int WELL_KNOWN_CMTS_PORT = 3918;
+
+ /**
+ * PDP host IP
+ */
+ private ServerSocket serverSocket;
+
+ /**
+ * PDP host port
+ */
+ private int serverPort;
+
+ /**
+ * COPS error returned by PDP
+ */
+ private COPSError error;
+
+ /**
+ * Creates a PEP agent
+ *
+ * @param pepID
+ * PEP-ID
+ * @param clientType
+ * Client-type
+ */
+ public PCMMPepAgent(String pepID, short clientType) {
+ super(pepID, clientType);
+ serverPort = WELL_KNOWN_CMTS_PORT;
+ }
+
+ /**
+ * Creates a PEP agent with a PEP-ID equal to "noname"
+ *
+ * @param clientType
+ * Client-type
+ */
+ public PCMMPepAgent(short clientType) {
+ super(clientType);
+ serverPort = WELL_KNOWN_CMTS_PORT;
+ }
+
+ /**
+ * Runs the PEP process XXX - not sure of the exception throwing
+ */
+ public void run() {
+ try {
+
+ COPSDebug.err(getClass().getName(), "Create Server Socket on Port "
+ + serverPort);
+
+ serverSocket = new ServerSocket(serverPort);
+ // Loop through for Incoming messages
+
+ // server infinite loop
+ while (true) {
+
+ // Wait for an incoming connection from a PEP
+ Socket socket = serverSocket.accept();
+
+ COPSDebug.err(getClass().getName(), "New connection accepted "
+ + socket.getInetAddress() + ":" + socket.getPort());
+
+ processConnection(socket);
+ /**
+ * XXX - processConnection handles the open request from PEP And
+ * a thread is created for conn = new
+ * COPSPepConnection(_clientType, socket); the main processing
+ * loop for PEP
+ */
+
+ }
+ } catch (IOException e) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_SOCKET, e);
+ } catch (COPSException e) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_SOCKET, e);
+ } catch (COPSPepException e) {
+ COPSDebug.err(getClass().getName(), COPSDebug.ERROR_SOCKET, e);
+ }
+ }
+
+ /**
+ * Establish connection to PDP's IP address
+ *
+ * ::= [] []
+ * []
+ *
+ * Not support [], [], []
+ *
+ * ::= []
+ * []
+ *
+ * Not send []
+ *
+ * ::= [] []
+ *
+ * Not send [], []
+ *
+ * @throws UnknownHostException
+ * @throws IOException
+ * @throws COPSException
+ * @throws COPSPepException
+ *
+ */
+ private COPSPepConnection processConnection(Socket socket)
+ throws UnknownHostException, IOException, COPSException,
+ COPSPepException {
+ // Build OPN
+ COPSHeader hdr = new COPSHeader(COPSHeader.COPS_OP_OPN, getClientType());
+
+ COPSPepId pepId = new COPSPepId();
+ COPSData d = new COPSData(getPepID());
+ pepId.setData(d);
+
+ COPSClientOpenMsg msg = new COPSClientOpenMsg();
+ msg.add(hdr);
+ msg.add(pepId);
+
+ // Create Socket and send OPN
+ /*
+ * InetAddress addr = InetAddress.getByName(psHost); Socket socket = new
+ * Socket(addr,psPort);
+ */
+ COPSDebug.err(getClass().getName(), "Send COPSClientOpenMsg to PDP");
+ msg.writeData(socket);
+
+ // Receive the response
+ COPSDebug.err(getClass().getName(), "Receive the resposne from PDP");
+ COPSMsg recvmsg = COPSTransceiver.receiveMsg(socket);
+
+ if (recvmsg.getHeader().isAClientAccept()) {
+ COPSDebug.err(getClass().getName(), "isAClientAccept from PDP");
+ COPSClientAcceptMsg cMsg = (COPSClientAcceptMsg) recvmsg;
+
+ // Support
+ if (cMsg.getIntegrity() != null) {
+ throw new COPSPepException("Unsupported object (Integrity)");
+ }
+
+ // Mandatory KATimer
+ COPSKATimer kt = cMsg.getKATimer();
+ if (kt == null)
+ throw new COPSPepException(
+ "Mandatory COPS object missing (KA Timer)");
+ short _kaTimeVal = kt.getTimerVal();
+
+ // ACTimer
+ COPSAcctTimer at = cMsg.getAcctTimer();
+ short _acctTimer = 0;
+ if (at != null)
+ _acctTimer = at.getTimerVal();
+
+ // Create the connection manager
+ COPSPepConnection conn = new COPSPepConnection(getClientType(),
+ socket);
+ conn.setKaTimer(_kaTimeVal);
+ conn.setAcctTimer(_acctTimer);
+ COPSDebug.err(getClass().getName(), "Thread(conn).start");
+ new Thread(conn).start();
+
+ return conn;
+ } else if (recvmsg.getHeader().isAClientClose()) {
+ COPSDebug.err(getClass().getName(), "isAClientClose from PDP");
+ COPSClientCloseMsg cMsg = (COPSClientCloseMsg) recvmsg;
+ error = cMsg.getError();
+ socket.close();
+ return null;
+ } else { // messages of other types are not expected
+ throw new COPSPepException(
+ "Message not expected. Closing connection for "
+ + socket.toString());
+ }
+ }
+
+ /**
+ * Gets the COPS error returned by the PDP
+ *
+ * @return COPSError returned by PDP
+ */
+ public COPSError getConnectionError() {
+ return error;
+ }
+
+ public void setConnectionError(COPSError _error) {
+ this.error = _error;
+ }
+
+ /**
+ * @return the serverSocket
+ */
+ public ServerSocket getServerSocket() {
+ return serverSocket;
+ }
+
+ /**
+ * @param serverSocket
+ * the serverSocket to set
+ */
+ public void setServerSocket(ServerSocket serverSocket) {
+ this.serverSocket = serverSocket;
+ }
+
+ /**
+ * @return the serverPort
+ */
+ public int getServerPort() {
+ return serverPort;
+ }
+
+ /**
+ * @param serverPort
+ * the serverPort to set
+ */
+ public void setServerPort(int serverPort) {
+ this.serverPort = serverPort;
+ }
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/PCMMProperties.java b/packetcable-driver/src/main/java/org/pcmm/PCMMProperties.java
new file mode 100644
index 0000000..62e4678
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/PCMMProperties.java
@@ -0,0 +1,60 @@
+package org.pcmm;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Loads the PCMM Properties file.
+ *
+ */
+public class PCMMProperties implements PCMMConstants {
+
+ private static Properties properties;
+ private static Logger logger = LoggerFactory.getLogger(PCMMProperties.class);
+
+ static {
+ try {
+ InputStream in = PCMMProperties.class.getClassLoader().getResourceAsStream("pcmm.properties");
+ properties = new Properties();
+ properties.load(in);
+ in.close();
+ } catch (IOException ie) {
+ logger.error(ie.getMessage());
+ }
+ }
+
+ protected static String get(String key) {
+ return properties.getProperty(key);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static T get(String key, Class type, Object _default) {
+ String prop = get(key);
+ if (prop != null && !prop.isEmpty()) {
+ if (Boolean.class.isAssignableFrom(type))
+ return (T) Boolean.valueOf(prop);
+ else if (Integer.class.isAssignableFrom(type))
+ return (T) Integer.valueOf(prop);
+ else if (Short.class.isAssignableFrom(type))
+ return (T) Short.valueOf(prop);
+ if (Float.class.isAssignableFrom(type))
+ return (T) Float.valueOf(prop);
+ if (Long.class.isAssignableFrom(type))
+ return (T) Long.valueOf(prop);
+ if (Double.class.isAssignableFrom(type))
+ return (T) Double.valueOf(prop);
+ else if (String.class.isAssignableFrom(type))
+ return (T) prop;
+ }
+ return (T) _default;
+ }
+
+ public static T get(String key, Class type) {
+ return get(key, type, null);
+ }
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/base/IAdapter.java b/packetcable-driver/src/main/java/org/pcmm/base/IAdapter.java
new file mode 100644
index 0000000..42cdd47
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/base/IAdapter.java
@@ -0,0 +1,15 @@
+/**
+ *
+ */
+package org.pcmm.base;
+
+/**
+ * Adapter interface
+ *
+ */
+public interface IAdapter {
+
+ Object adapt(Object object, Class> clazz);
+
+ Type adapt(Object object);
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/base/IPCMMBaseObject.java b/packetcable-driver/src/main/java/org/pcmm/base/IPCMMBaseObject.java
new file mode 100644
index 0000000..2114004
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/base/IPCMMBaseObject.java
@@ -0,0 +1,80 @@
+/**
+ @header@
+ */
+
+package org.pcmm.base;
+
+import java.io.IOException;
+import java.net.Socket;
+
+import org.umu.cops.stack.COPSData;
+
+/**
+ * Base interface for all PCMM objects, it define the {@code S-Type},
+ * {@code S-Num} and the data length
+ *
+ */
+public interface IPCMMBaseObject {
+
+ /**
+ * sets the S-Type
+ *
+ * @param stype
+ */
+ void setSType(byte stype);
+
+ /**
+ *
+ * @return S-Type
+ */
+ byte getSType();
+
+ /**
+ * sets the S-Num
+ *
+ * @param snum
+ * S-Num
+ */
+ void setSNum(byte snum);
+
+ /**
+ * gets the S-Num
+ *
+ * @return S-Num
+ */
+ byte getSNum();
+
+ /**
+ * sets the length;
+ *
+ * @param len
+ */
+ void setLength(short len);
+
+ /**
+ * gets the length;
+ *
+ * @return length
+ */
+ short getLength();
+
+ /**
+ * sets the COPS data
+ *
+ * @param data
+ * COPS data
+ */
+ void setData(COPSData data);
+
+ /**
+ * gets the COPS data
+ *
+ * @return COPS data
+ */
+ COPSData getData();
+
+ void writeData(Socket id) throws IOException;
+
+ byte[] getAsBinaryArray();
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/base/impl/PCMMBaseObject.java b/packetcable-driver/src/main/java/org/pcmm/base/impl/PCMMBaseObject.java
new file mode 100644
index 0000000..79e26de
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/base/impl/PCMMBaseObject.java
@@ -0,0 +1,244 @@
+/**
+ *
+ */
+package org.pcmm.base.impl;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.util.Arrays;
+
+import org.pcmm.base.IPCMMBaseObject;
+import org.umu.cops.stack.COPSData;
+
+/**
+ *
+ * Implementation of the base class {@link IPCMMBaseObject}
+ *
+ */
+public class PCMMBaseObject /* extends COPSPrObjBase */implements
+ IPCMMBaseObject {
+
+ private byte sType;
+ private byte sNum;
+ private short len;
+ private COPSData copsData;
+ private COPSData pad;
+ protected final short offset = (short) 4;
+
+ public PCMMBaseObject(byte[] data) {
+ parse(data);
+ }
+
+ public PCMMBaseObject(short len, byte sType, byte sNum) {
+ this.len = (len);
+ this.sType = (sType);
+ this.sNum = (sNum);
+ byte[] array = new byte[len - offset];
+ Arrays.fill(array, (byte) 0);
+ setData(new COPSData(array, 0, array.length));
+ }
+
+ protected COPSData getPadding(int len) {
+ byte[] padBuf = new byte[len];
+ Arrays.fill(padBuf, (byte) 0);
+ COPSData d = new COPSData(padBuf, 0, len);
+ return d;
+ }
+
+ /**
+ * Add head padding to the specified byte array filled with zeros
+ *
+ * @param off
+ * offset
+ * @param array
+ * input array
+ * @return byte array
+ */
+ protected byte[] headPadding(int off, byte[] array) {
+ byte[] returnArray = new byte[array.length + off];
+ Arrays.fill(returnArray, (byte) 0);
+ System.arraycopy(array, 0, returnArray, off, array.length);
+ return returnArray;
+ }
+
+ protected void parse(byte[] data) {
+ if (data == null || data.length == 0)
+ throw new IllegalArgumentException("data could not be null");
+ len = 0;
+ len |= ((short) data[0]) << 8;
+ len |= ((short) data[1]) & 0xFF;
+ sNum = data[2];
+ sType = data[3];
+ copsData = new COPSData(data, offset, data.length - offset);
+ }
+
+ protected void setShort(short value, short startPos) {
+ byte[] data = getData().getData();
+ data[startPos] = (byte) (value >> 8);
+ data[startPos + 1] = (byte) value;
+ setData(new COPSData(data, 0, data.length));
+ }
+
+ protected short getShort(short startPos) {
+ byte[] data = getData().getData();
+ short retVal = 0;
+ retVal |= ((short) data[startPos]) << 8;
+ retVal |= ((short) data[startPos + 1]) & 0xFF;
+ return retVal;
+ }
+
+ protected void setInt(int value, short startPos) {
+ byte[] data = getData().getData();
+ data[startPos] = (byte) (value >> 24);
+ data[startPos + 1] = (byte) (value >> 16);
+ data[startPos + 2] = (byte) (value >> 8);
+ data[startPos + 3] = (byte) value;
+ setData(new COPSData(data, 0, data.length));
+ }
+
+ protected int getInt(short startPos) {
+ byte[] data = getData().getData();
+ int retVal = 0;
+ retVal |= ((short) data[startPos]) << 24;
+ retVal |= ((short) data[startPos + 1]) << 16;
+ retVal |= ((short) data[startPos + 2]) << 8;
+ retVal |= ((short) data[startPos + 3]) & 0xFF;
+ return retVal;
+ }
+
+ protected void setBytes(byte[] value, short startPos) {
+ byte[] data = getData().getData();
+ for (byte b : value)
+ data[startPos++] = b;
+ setData(new COPSData(data, 0, data.length));
+ }
+
+ protected byte[] getBytes(short startPos, short size) {
+ return Arrays.copyOfRange(getData().getData(), startPos, startPos
+ + size);
+ }
+
+ protected void setByte(byte value, short startPos) {
+ setBytes(new byte[] { value }, startPos);
+ }
+
+ protected byte getByte(short startPos) {
+ return getBytes(startPos, (short) 1)[0];
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.base.IPCMMBaseObject#setSType(byte)
+ */
+ @Override
+ public void setSType(byte stype) {
+ this.sType = stype;
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.base.IPCMMBaseObject#getSType()
+ */
+ @Override
+ public byte getSType() {
+ return sType;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.base.IPCMMBaseObject#setSNum(byte)
+ */
+ @Override
+ public void setSNum(byte snum) {
+ this.sNum = snum;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.base.IPCMMBaseObject#getSNum()
+ */
+ @Override
+ public byte getSNum() {
+ return sNum;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.base.IPCMMBaseObject#setLength(short)
+ */
+ @Override
+ public void setLength(short len) {
+ this.len = len;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.base.IPCMMBaseObject#getLength()
+ */
+ @Override
+ public short getLength() {
+ return (short) (len + (pad != null ? pad.length() : 0));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.base.IPCMMBaseObject#setData(org.umu.cops.stack.COPSData)
+ */
+ @Override
+ public void setData(COPSData data) {
+ this.copsData = data;
+ if (data.length() % offset != 0) {
+ int padLen = offset - (data.length() % offset);
+ pad = getPadding(padLen);
+ }
+ len = (short) (data.length() + offset);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.base.IPCMMBaseObject#getData()
+ */
+ @Override
+ public COPSData getData() {
+ return copsData;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.base.IPCMMBaseObject#writeData(java.net.Socket)
+ */
+ public void writeData(Socket id) throws IOException {
+ byte[] data = getAsBinaryArray();
+ id.getOutputStream().write(data, 0, data.length);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.base.IPCMMBaseObject#getAsBinaryArray()
+ */
+ @Override
+ public byte[] getAsBinaryArray() {
+ byte[] array = new byte[getLength()];
+ array[0] = (byte) (len >> 8);
+ array[1] = (byte) len;
+ array[2] = sNum;
+ array[3] = sType;
+ System.arraycopy(getData().getData(), 0, array, offset, getData()
+ .length());
+ if (pad != null)
+ System.arraycopy(pad.getData(), 0, array, offset
+ + getData().length(), pad.length());
+ return array;
+ }
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/concurrent/IWorker.java b/packetcable-driver/src/main/java/org/pcmm/concurrent/IWorker.java
new file mode 100644
index 0000000..1a89605
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/concurrent/IWorker.java
@@ -0,0 +1,28 @@
+package org.pcmm.concurrent;
+
+import java.util.concurrent.Callable;
+/**
+ *
+ */
+public interface IWorker extends Runnable {
+
+ /**
+ * defines the task to be performed by this worker
+ *
+ * @param c
+ */
+ void task(Callable> c);
+
+ /**
+ * defines wait time before start working on the task
+ *
+ * @param t
+ */
+ void shouldWait(int t);
+
+ /**
+ * ends the current working task.
+ */
+ void done();
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/concurrent/IWorkerPool.java b/packetcable-driver/src/main/java/org/pcmm/concurrent/IWorkerPool.java
new file mode 100644
index 0000000..e97cc21
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/concurrent/IWorkerPool.java
@@ -0,0 +1,54 @@
+/**
+ *
+ */
+package org.pcmm.concurrent;
+
+import org.pcmm.base.IAdapter;
+
+/**
+ *
+ */
+public interface IWorkerPool extends IAdapter {
+ // handles 32 workers
+ static int DEFAULT_MAX_WORKERS = 32;
+
+ /**
+ * schedules a worker for beginning its task after t milliseconds.
+ *
+ * @param worker
+ * : the worker
+ * @param t
+ * : time to wait
+ * @return the id of the worker (PID) to be used for killing the worker if
+ * needed
+ */
+ int schedule(IWorker worker, int t);
+
+ /**
+ * schedules a worker for immediate execution.
+ *
+ * @param worker
+ * : the worker
+ * @return the id of the worker (PID) to be used for killing the worker if
+ * needed
+ */
+ int schedule(IWorker worker);
+
+ /**
+ * kills the worker with the specified pid
+ *
+ * @param pid
+ */
+ void sendKillSignal(int pid);
+
+ /**
+ * sends a terminate signal for all active workers and recycles the pool.
+ */
+ void killAll();
+
+ /**
+ * cleans up the pool from finished tasks
+ */
+ void recycle();
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/concurrent/impl/Worker.java b/packetcable-driver/src/main/java/org/pcmm/concurrent/impl/Worker.java
new file mode 100644
index 0000000..1080692
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/concurrent/impl/Worker.java
@@ -0,0 +1,79 @@
+/**
+ *
+ */
+package org.pcmm.concurrent.impl;
+
+import java.util.concurrent.Callable;
+
+import org.pcmm.concurrent.IWorker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class Worker implements IWorker {
+
+ private int waitTimer;
+
+ private Callable> task;
+ private Logger logger = LoggerFactory.getLogger(IWorker.class);
+
+ public Worker() {
+
+ }
+
+ public Worker(Callable> task) {
+ this.task = task;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ try {
+ if (waitTimer > 0)
+ Thread.sleep(waitTimer);
+ task.call();
+ } catch (Throwable e) {
+ logger.error(e.getMessage());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.threading.IWorker#task(java.util.concurrent.Callable)
+ */
+ @Override
+ public void task(Callable> c) {
+ logger.debug("Task added " + c);
+ this.task = c;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.threading.IWorker#shouldWait(int)
+ */
+ @Override
+ public void shouldWait(int t) {
+ logger.debug("Worker will start after :" + t + " ms");
+ waitTimer = t;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.threading.IWorker#done()
+ */
+ @Override
+ public void done() {
+ logger.debug("worker finished tasks");
+
+ }
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/concurrent/impl/WorkerPool.java b/packetcable-driver/src/main/java/org/pcmm/concurrent/impl/WorkerPool.java
new file mode 100644
index 0000000..b6fb429
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/concurrent/impl/WorkerPool.java
@@ -0,0 +1,158 @@
+package org.pcmm.concurrent.impl;
+
+import java.lang.ref.WeakReference;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.pcmm.concurrent.IWorker;
+import org.pcmm.concurrent.IWorkerPool;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Pool to manage PCMM workers
+ */
+public class WorkerPool implements IWorkerPool {
+
+ /**
+ *
+ */
+ private Map> workersMap;
+
+ private Logger logger = LoggerFactory.getLogger(IWorkerPool.class);
+ private ExecutorService executor;
+
+ public WorkerPool() {
+ this(DEFAULT_MAX_WORKERS);
+ }
+
+ public WorkerPool(int size) {
+ logger.info("Pool size :" + size);
+ workersMap = new HashMap>();
+ executor = Executors.newFixedThreadPool(size);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.threading.IWorkerPool#schedule(org.pcmm.threading.IWorker,
+ * int)
+ */
+ @Override
+ public int schedule(IWorker worker, int t) {
+ if (worker == null)
+ return -1;
+ logger.debug("woker[" + worker + "] added, starts in " + t + " ms");
+ WeakReference workerRef = new WeakReference(worker);
+ int ref = workerRef.hashCode();
+ workersMap.put(ref, workerRef);
+ worker.shouldWait(t);
+ executor.execute(worker);
+ return ref;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.pcmm.concurrent.IWorkerPool#schedule(org.pcmm.concurrent.IWorker)
+ */
+ @Override
+ public int schedule(IWorker worker) {
+ return schedule(worker, 0);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.concurrent.IWorkerPool#sendKillSignal(int)
+ */
+ @Override
+ public void sendKillSignal(int pid) {
+ if (workersMap.size() > 0) {
+ WeakReference weakRef = workersMap.get(pid);
+ if (weakRef != null) {
+ IWorker ref = weakRef.get();
+ if (ref != null)
+ ref.done();
+ if (!weakRef.isEnqueued()) {
+ weakRef.clear();
+ weakRef.enqueue();
+ }
+ }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.threading.IWorkerPool#killAll()
+ */
+ @Override
+ public void killAll() {
+ for (WeakReference weakRef : workersMap.values()) {
+ IWorker ref = weakRef.get();
+ if (ref != null)
+ ref.done();
+ if (!weakRef.isEnqueued()) {
+ weakRef.clear();
+ weakRef.enqueue();
+ }
+ }
+ recycle();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.threading.IWorkerPool#recycle()
+ */
+ @Override
+ public void recycle() {
+ for (Iterator pids = workersMap.keySet().iterator(); pids.hasNext();) {
+ WeakReference weakRef = workersMap.get(pids.next());
+ IWorker ref = weakRef.get();
+ if (ref == null) {
+ if (!weakRef.isEnqueued()) {
+ weakRef.clear();
+ weakRef.enqueue();
+ }
+ workersMap.remove(weakRef);
+ }
+ }
+
+ }
+
+ @Override
+ public Object adapt(Object object, Class> clazz) {
+ if (clazz.isAssignableFrom(object.getClass()))
+ return object;
+ return null;
+ }
+
+ @Override
+ public IWorker adapt(Object object) {
+ IWorker worker = (IWorker) adapt(object, IWorker.class);
+ if (worker == null) {
+ if (object instanceof Callable)
+ worker = new Worker((Callable>) object);
+ else if (object instanceof Runnable) {
+ final Runnable runner = (Runnable) object;
+ worker = new Worker(new Callable
+ *
+ * Stateful & Stateless Policy Servers There are two basic classes of
+ * Policy Servers – Stateful and Stateless. A Stateless Policy Server is a
+ * slight misnomer since it does maintain enough state to map Application
+ * Manager requests to the proper CMTS and maintain COPS session state, while a
+ * pure Stateless Policy Server maintains no state on any of the media sessions.
+ * Stateful Policy Servers come in several varieties – some participate in
+ * admission control and thus monitor the QoS attributes of active media
+ * sessions, some leave QoS and admission control to the CMTS but monitor
+ * time-based or volume-based service requests from the Application Manager, and
+ * some Policy Servers are somewhere between these extremes. The reason there is
+ * a variety of Policy Server types is that there is a variety of environments
+ * that operators are trying to support. For example, some operators may wish to
+ * support PacketCable Multimedia over the same CMTSs that they use for
+ * PacketCable telephony, and they may want a single CMS/Policy Server that has
+ * a more global view of the network resources being used. On the other hand,
+ * some operators may wish to run a PacketCable Multimedia- only environment, or
+ * they may utilize simpler CMTS-driven mechanisms for partitioning PacketCable
+ * Multimedia and telephony resources. These simpler configurations have more
+ * modest requirements on the amount of state that a Policy Server maintains.
+ * Policy Server state requirements can also be driven by the level of trust
+ * between the Policy Server and Application Manager; a Stateful Policy Server
+ * can more readily police Application Manager session control behavior than can
+ * a Stateless Policy Server. So a Stateful Policy Server may be more
+ * appropriate for operators supporting third party Application Managers. Other
+ * operators may rely on economics to enforce their trust relationships with
+ * Application Managers, or they may control the Application Managers
+ * themselves. In such cases a Stateless Policy Server may be more appropriate.
+ * Since it is impossible to categorize all the various components of media
+ * session and network QoS state that a Policy Server is maintaining, the
+ * protocol is designed to be independent of this complexity. A Stateful Policy
+ * Server gleans PacketCable Multimedia media session information from the
+ * Application Manager requests it proxies; any other information it requires is
+ * gathered via mechanisms that are outside the scope of this specification. The
+ * CMTS and the Application Manager make no distinction as to the type of Policy
+ * Server to which they are connected, and the protocol is designed in such a
+ * manner that the type of Policy Server is transparent to the end point. The
+ * type of Policy Server is only of importance to the operator. Since some types
+ * of Policy Servers attempt to assist with admission control and may have a
+ * larger view of the network and its resources, additional state
+ * synchronization issues may arise in design in a network which contains more
+ * than one of these types of Policy Servers. It is the responsibility of the
+ * operator to ensure that the efforts of these Policy Servers are not
+ * undermined by a network that includes other autonomous Policy Servers.
+ *
+ *
+ * Modification of Requests and Responses by Policy Servers Although
+ * nominally a part of the Resource Control Domain, the Policy Server can be an
+ * intermediary between the Service and the Resource Control Domains, in
+ * addition to its normal role of implementing MSO-defined authorization and
+ * resource management procedures. In either of these capacities it may modify
+ * the incoming request before forwarding it to the CMTS. In acting as an
+ * intermediary between the SCD and RCD, the Policy Server may translate fields
+ * from formats or scales used in the SCD into formats or scales used in the
+ * RCD. For example, the Policy Server may modify the "priority" of a request
+ * coming from an Application Manager (especially important to do for an AM
+ * outside of the MSO network) so that this priority field uses a consistent
+ * scale throughout the operator's RCD. In its capacity as an intermediary, the
+ * Policy Server may use bidirectional translation – in other words, it should
+ * translate requests from the AM to the CMTS and "untranslate" the responses
+ * from the CMTS to the AM. This capability can be supported by stateful policy
+ * servers by remembering the original request, and it can be supported by
+ * stateless Policy Servers if the translation function is invertible.
+ * Modification of certain objects, specifically the Classifier and Traffic
+ * Profile objects, may cause operational problems in the originating AM. As
+ * such, these objects MUST NOT be modified by the policy server. Aside from
+ * these exceptions, all other objects may be policed and modified at the PS's
+ * discretion based on provisioned policy rules.
+ *
+ * In the PacketCable model, the CMTS (PEP) is the one that listens on the
+ * assigned port 3918, and it is the Policy Server that MUST initiate the
+ * TCP connection to the CMTS, thus we implement the IPCMMClient interface.
+ *
+ */
+ public static interface IPSCMTSClient extends IPCMMClient {
+
+ /**
+ *
+ * @return Classifier Id.
+ */
+ short getClassifierId();
+
+ /**
+ *
+ * @return the transaction Id.
+ */
+ short getTransactionId();
+
+ /**
+ * Gate id transmitted by the CMTS to the PS.
+ *
+ * @return the Gate Id.
+ */
+ int getGateId();
+
+ /**
+ * initiates a Gate-Set with the CMTS
+ *
+ * @return
+ */
+ boolean gateSet();
+
+ /**
+ * initiates a Gate-Info with the CMTS
+ *
+ * @return
+ */
+ boolean gateInfo();
+
+ /**
+ * initiates a Gate-Delete with the CMTS
+ *
+ * @return
+ */
+ boolean gateDelete();
+
+ /**
+ * sends synch request
+ *
+ * @return
+ */
+ boolean gateSynchronize();
+
+ /**
+ * Sets the value of the multi-media version info.
+ *
+ * @param MM
+ * version info
+ */
+ void setVersionInfo(MMVersionInfo vInfo);
+
+ /**
+ *
+ * @return MM version info
+ */
+ MMVersionInfo getVersionInfo();
+ }
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/rcd/IPCMMServer.java b/packetcable-driver/src/main/java/org/pcmm/rcd/IPCMMServer.java
new file mode 100644
index 0000000..794af06
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/rcd/IPCMMServer.java
@@ -0,0 +1,91 @@
+/**
+ @header@
+ */
+
+
+package org.pcmm.rcd;
+
+import org.pcmm.concurrent.IWorker;
+import org.pcmm.state.IStateful;
+
+/**
+ *
+ * As discussed in RFC 2753 [11], the policy management framework underlying
+ * PacketCable Multimedia is based on the work of the IETF's Resource Allocation
+ * Protocol (RAP) working group. Since the Policy Server is situated between the
+ * Application Manager and the CMTS, it simultaneously plays a dual role as a
+ * "proxy" for AM-initiated session requests and as a "sentry" for defining and
+ * enforcing Resource Control Domain policy.
+ *
+ *
+ * As described in [11] and in keeping with the PacketCable 1.x DQoS model, the
+ * Policy Server serves as Policy Decision Point (PDP) in relation to the CMTS
+ * resource-management procedures. Conversely, the Policy Server assumes the
+ * role of Policy Enforcement Point (PEP) in relation to the Application Manager
+ * as it proxies Gate Control messages to and from the CMTS element.
+ *
+ *
+ * To revisit the interaction scenario, the Application Manager issues policy
+ * requests to the Policy Server. The Policy Server acting as a "sentry" for
+ * these requests, and applies a set of policy rules that have been
+ * pre-provisioned by the MSO. Upon passing the checks, the Policy Server then
+ * acts as a "proxy" with respect to the Application Manager and the CMTS,
+ * forwarding the policy request and returning any associated response. Each
+ * policy request transaction must be processed individually.
+ *
+ *
+ * Policy decisions may be based on a number of factors, such as:
+ *
+ *
Parameters associated with the request and the status of available
+ * resources
+ *
Identity of the particular client and associated profile information
+ *
Application parameters
+ *
Security considerations
+ *
Time-of-day
+ *
+ * The primary functions of the Policy Server include:
+ *
+ *
A policy decision request mechanism, invoked by Application Managers
A policy decision delivery mechanism, used to install policy decisions on
+ * the CMTS
+ *
A mechanism to allow for the proxying of QoS management messages to the
+ * CMTS on behalf of the Application Manager
+ *
An event recording interface to a Record Keeping Server that is used to
+ * log policy requests, which may in turn be correlated with network resource
+ * usage records
+ *
+ *
+ * Since the Policy Server functions as a proxy between the AM and CMTS elements
+ * (with complementary client and server interfaces) some MSOs may elect to
+ * deploy multiple layers of Policy Servers and to delegate certain policy
+ * decisions among these servers in order to satisfy requirements associated
+ * with scalability and fault-tolerance.
+ *
+ *
+ *
+ *
+ */
+public interface IPCMMServer extends IStateful {
+
+ /**
+ *
+ */
+ void startServer();
+
+ /**
+ *
+ */
+ void stopServer();
+
+ /**
+ * When a client connects to the server, a handler is needed to manage the
+ * exchange of the messages between this client and the server.
+ *
+ *
+ */
+ public static interface IPCMMClientHandler extends IWorker, IPCMMClient {
+
+ }
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/rcd/impl/AbstractPCMMClient.java b/packetcable-driver/src/main/java/org/pcmm/rcd/impl/AbstractPCMMClient.java
new file mode 100644
index 0000000..6a29743
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/rcd/impl/AbstractPCMMClient.java
@@ -0,0 +1,176 @@
+/**
+ @header@
+ */
+package org.pcmm.rcd.impl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import org.pcmm.nio.PCMMChannel;
+// import org.junit.Assert;
+import org.pcmm.objects.MMVersionInfo;
+import org.pcmm.rcd.IPCMMClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.umu.cops.stack.COPSMsg;
+
+/**
+ *
+ * default implementation for {@link IPCMMClient}
+ *
+ *
+ */
+public class AbstractPCMMClient implements IPCMMClient {
+
+ protected Logger logger = LoggerFactory.getLogger(AbstractPCMMClient.class);
+ /**
+ * socket used to communicated with server.
+ */
+ private Socket socket;
+
+ private String clientHanlde;
+
+ private MMVersionInfo versionInfo;
+
+ private PCMMChannel channel;
+
+ public AbstractPCMMClient() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see pcmm.rcd.IPCMMClient#sendRequest(pcmm.messages.IMessage)
+ */
+ public void sendRequest(COPSMsg requestMessage) {
+ try {
+ channel.sendMsg(requestMessage);
+ } catch (Exception e) {
+ logger.error(e.getMessage(), getSocket());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.rcd.IPCMMClient#readMessage()
+ */
+ public COPSMsg readMessage() {
+ try {
+ COPSMsg recvdMsg = channel.receiveMessage();
+ // logger.debug("received message : " + recvdMsg.getHeader());
+ return recvdMsg;
+ } catch (Exception e) {
+ logger.error(e.getMessage(), getSocket());
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see pcmm.rcd.IPCMMClient#tryConnect(java.lang.String, int)
+ */
+ public boolean tryConnect(String address, int port) {
+ try {
+ InetAddress addr = InetAddress.getByName(address);
+ tryConnect(addr, port);
+ } catch (UnknownHostException e) {
+ logger.error(e.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see pcmm.rcd.IPCMMClient#tryConnect(java.net.InetAddress, int)
+ */
+ public boolean tryConnect(InetAddress address, int port) {
+ try {
+ setSocket(new Socket(address, port));
+ } catch (IOException e) {
+ logger.error(e.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see pcmm.rcd.IPCMMClient#disconnect()
+ */
+ public boolean disconnect() {
+ if (isConnected()) {
+ try {
+ socket.close();
+ channel = null;
+ } catch (IOException e) {
+ logger.error(e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ /**
+ * @return the socket
+ */
+ public Socket getSocket() {
+ return socket;
+ }
+
+ public PCMMChannel getChannel() {
+ return channel;
+ }
+
+ /**
+ * @param socket
+ * the socket to set
+ */
+ public void setSocket(Socket socket) {
+ this.socket = socket;
+ if (this.socket != null
+ && (this.channel == null || !this.channel.getSocket().equals(
+ this.socket)))
+ channel = new PCMMChannel(this.socket);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.rcd.IPCMMClient#isConnected()
+ */
+ public boolean isConnected() {
+ return socket != null && socket.isConnected();
+ }
+
+ /**
+ * @return the versionInfo
+ */
+ public MMVersionInfo getVersionInfo() {
+ return versionInfo;
+ }
+
+ /**
+ * @param versionInfo
+ * the versionInfo to set
+ */
+ public void setVersionInfo(MMVersionInfo versionInfo) {
+ this.versionInfo = versionInfo;
+ }
+
+ @Override
+ public String getClientHandle() {
+ return clientHanlde;
+ }
+
+ @Override
+ public void setClientHandle(String handle) {
+ this.clientHanlde = handle;
+ }
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/rcd/impl/AbstractPCMMServer.java b/packetcable-driver/src/main/java/org/pcmm/rcd/impl/AbstractPCMMServer.java
new file mode 100644
index 0000000..bac4979
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/rcd/impl/AbstractPCMMServer.java
@@ -0,0 +1,214 @@
+/**
+ @header@
+ */
+package org.pcmm.rcd.impl;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.concurrent.Executors;
+
+import org.pcmm.PCMMConstants;
+import org.pcmm.PCMMProperties;
+import org.pcmm.concurrent.IWorkerPool;
+import org.pcmm.concurrent.impl.WorkerPool;
+// import org.junit.Assert;
+import org.pcmm.messages.impl.MessageFactory;
+import org.pcmm.rcd.IPCMMServer;
+import org.pcmm.state.IState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.umu.cops.stack.COPSHeader;
+import org.umu.cops.stack.COPSMsg;
+
+/*
+ * (non-Javadoc)
+ *
+ * @see pcmm.rcd.IPCMMServer
+ */
+public abstract class AbstractPCMMServer implements IPCMMServer {
+ protected Logger logger;
+ /*
+ * A ServerSocket to accept messages ( OPN requests)
+ */
+ private ServerSocket serverSocket;
+
+ private Socket stopSocket;
+
+ private volatile boolean keepAlive;
+ /*
+ *
+ */
+ private int port;
+
+ IWorkerPool pool;
+
+ protected AbstractPCMMServer() {
+ this(PCMMProperties.get(PCMMConstants.PCMM_PORT, Integer.class));
+ }
+
+ protected AbstractPCMMServer(int port) {
+ // XXX - Assert.assertTrue(port >= 0 && port <= 65535);
+ this.port = port;
+ keepAlive = true;
+ logger = LoggerFactory.getLogger(getClass().getName());
+ int poolSize = PCMMProperties.get(PCMMConstants.PS_POOL_SIZE, Integer.class);
+ pool = new WorkerPool(poolSize);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see pcmm.rcd.IPCMMServer#startServer()
+ */
+ public void startServer() {
+ if (serverSocket != null)
+ return;
+ try {
+ serverSocket = new ServerSocket(port);
+ logger.info("Server started and listening on port :" + port);
+ } catch (IOException e) {
+ logger.error(e.getMessage());
+ }
+ // execute this in a single thread executor
+ Executors.newSingleThreadExecutor().execute(new Runnable() {
+ public void run() {
+ while (keepAlive) {
+ try {
+ Socket socket = serverSocket.accept();
+ logger.info("Accepted a new connection from :" + socket.getInetAddress().getHostAddress() + ":" + socket.getPort());
+ if (keepAlive) {
+ pool.schedule(getPCMMClientHandler(socket));
+ logger.info("Handler attached tp : " + socket.getInetAddress().getHostAddress() + ":" + socket.getPort());
+ } else {
+ logger.info("connection to be closed : " + socket.getInetAddress().getHostAddress() + ":" + socket.getPort());
+ socket.close();
+ }
+ } catch (IOException e) {
+ logger.error(e.getMessage());
+ }
+ }
+ try {
+ if (stopSocket != null && stopSocket.isConnected()) {
+ logger.info("Cleaning up");
+ stopSocket.close();
+ }
+ if (serverSocket != null && serverSocket.isBound()) {
+ logger.info("Server about to stop");
+ serverSocket.close();
+ logger.info("Server stopped");
+ }
+ } catch (IOException e) {
+ logger.error(e.getMessage());
+ }
+ }
+ });
+ }
+
+ /**
+ * This client is used to handle requests from within the Application
+ * Manager
+ *
+ * @param socket
+ * @return client handler
+ */
+ protected abstract IPCMMClientHandler getPCMMClientHandler(Socket socket);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see pcmm.rcd.IPCMMServer#stopServer()
+ */
+ public void stopServer() {
+ // set to stop
+ keepAlive = false;
+ try {
+ if (serverSocket != null) {
+ stopSocket = new Socket(serverSocket.getInetAddress(), serverSocket.getLocalPort());
+ logger.info("STOP socket created and attached");
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see pcmm.state.IStateful#recordState()
+ */
+ public void recordState() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see pcmm.state.IStateful#getRecoredState()
+ */
+ public IState getRecoredState() {
+ return null;
+ }
+
+ /**
+ * @return the serverSocket
+ */
+ public ServerSocket getServerSocket() {
+ return serverSocket;
+ }
+
+ /**
+ * @param serverSocket
+ * the serverSocket to set
+ */
+ public void setServerSocket(ServerSocket serverSocket) {
+ this.serverSocket = serverSocket;
+ }
+
+ /**
+ * @return the port
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * @param port
+ * the port to set
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see pcmm.rcd.IPCMMServer.IPCMMClientHandler
+ */
+ public abstract class AbstractPCMMClientHandler extends AbstractPCMMClient
+ implements IPCMMClientHandler {
+
+ protected boolean sendCCMessage = false;
+
+ public AbstractPCMMClientHandler(Socket socket) {
+ super();
+ setSocket(socket);
+ }
+
+ @Override
+ public boolean disconnect() {
+ // XXX send CC message
+ sendCCMessage = true;
+ /*
+ * is this really needed ?
+ */
+ // if (getSocket() != null)
+ // handlersPool.remove(getSocket());
+ COPSMsg message = MessageFactory.getInstance().create(COPSHeader.COPS_OP_CC);
+ sendRequest(message);
+ return super.disconnect();
+ }
+
+ }
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/rcd/impl/CMTS.java b/packetcable-driver/src/main/java/org/pcmm/rcd/impl/CMTS.java
new file mode 100644
index 0000000..fa89754
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/rcd/impl/CMTS.java
@@ -0,0 +1,355 @@
+/**
+ @header@
+ */
+package org.pcmm.rcd.impl;
+
+import java.net.Socket;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+import java.util.Vector;
+import java.util.concurrent.Callable;
+
+import org.pcmm.gates.IPCMMGate;
+import org.pcmm.gates.ITransactionID;
+import org.pcmm.gates.impl.PCMMGateReq;
+import org.pcmm.messages.impl.MessageFactory;
+import org.pcmm.rcd.ICMTS;
+import org.umu.cops.prpep.COPSPepConnection;
+import org.umu.cops.prpep.COPSPepDataProcess;
+import org.umu.cops.prpep.COPSPepException;
+import org.umu.cops.prpep.COPSPepReqStateMan;
+import org.umu.cops.stack.COPSAcctTimer;
+import org.umu.cops.stack.COPSClientAcceptMsg;
+import org.umu.cops.stack.COPSClientCloseMsg;
+import org.umu.cops.stack.COPSContext;
+import org.umu.cops.stack.COPSData;
+import org.umu.cops.stack.COPSDecision;
+import org.umu.cops.stack.COPSDecisionMsg;
+import org.umu.cops.stack.COPSError;
+import org.umu.cops.stack.COPSException;
+import org.umu.cops.stack.COPSHeader;
+import org.umu.cops.stack.COPSKATimer;
+import org.umu.cops.stack.COPSMsg;
+import org.umu.cops.stack.COPSPrObjBase;
+import org.umu.cops.stack.COPSReqMsg;
+
+/**
+ *
+ */
+public class CMTS extends AbstractPCMMServer implements ICMTS {
+
+ public CMTS() {
+ super();
+ }
+
+ @Override
+ protected IPCMMClientHandler getPCMMClientHandler(final Socket socket) {
+
+ return new AbstractPCMMClientHandler(socket) {
+
+ private String handle;
+
+ public void run() {
+ try {
+ // send OPN message
+ // set the major version info and minor version info to
+ // default (5,0)
+ logger.info("Send OPN message to the PS");
+ sendRequest(MessageFactory.getInstance().create(COPSHeader.COPS_OP_OPN, new Properties()));
+ // wait for CAT
+ COPSMsg recvMsg = readMessage();
+
+ if (recvMsg.getHeader().isAClientClose()) {
+ COPSClientCloseMsg cMsg = (COPSClientCloseMsg) recvMsg;
+ logger.info("PS requested Client-Close" + cMsg.getError().getDescription());
+ // send a CC message and close the socket
+ disconnect();
+ return;
+ }
+ if (recvMsg.getHeader().isAClientAccept()) {
+ logger.info("received Client-Accept from PS");
+ COPSClientAcceptMsg cMsg = (COPSClientAcceptMsg) recvMsg;
+ // Support
+ if (cMsg.getIntegrity() != null) {
+ throw new COPSPepException("Unsupported object (Integrity)");
+ }
+
+ // Mandatory KATimer
+ COPSKATimer kt = cMsg.getKATimer();
+ if (kt == null)
+ throw new COPSPepException("Mandatory COPS object missing (KA Timer)");
+ short kaTimeVal = kt.getTimerVal();
+
+ // ACTimer
+ COPSAcctTimer at = cMsg.getAcctTimer();
+ short acctTimer = 0;
+ if (at != null)
+ acctTimer = at.getTimerVal();
+
+ logger.info("Send a REQ message to the PS");
+ {
+ Properties prop = new Properties();
+ COPSMsg reqMsg = MessageFactory.getInstance().create(COPSHeader.COPS_OP_REQ, prop);
+ handle = ((COPSReqMsg) reqMsg).getClientHandle().getId().str();
+ sendRequest(reqMsg);
+ }
+ // Create the connection manager
+ PCMMCmtsConnection conn = new PCMMCmtsConnection(CLIENT_TYPE, socket);
+ // pcmm specific handler
+ // conn.addReqStateMgr(handle, new
+ // PCMMPSReqStateMan(CLIENT_TYPE, handle));
+ conn.addRequestState(handle, new CmtsDataProcessor());
+ conn.setKaTimer(kaTimeVal);
+ conn.setAcctTimer(acctTimer);
+ logger.info(getClass().getName() + " Thread(conn).start");
+ new Thread(conn).start();
+ } else {
+ // messages of other types are not expected
+ throw new COPSPepException("Message not expected. Closing connection for " + socket.toString());
+ }
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ }
+ }
+
+ @Override
+ public void task(Callable> c) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void shouldWait(int t) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void done() {
+ // TODO Auto-generated method stub
+
+ }
+
+ };
+ }
+
+ /* public */class PCMMCmtsConnection extends COPSPepConnection {
+
+ public PCMMCmtsConnection(short clientType, Socket sock) {
+ super(clientType, sock);
+ }
+
+ public COPSPepReqStateMan addRequestState(String clientHandle, COPSPepDataProcess process)
+ throws COPSException, COPSPepException {
+ return super.addRequestState(clientHandle, process);
+ }
+
+ // public void addReqStateMgr(String hanlde, COPSPepReqStateMan r) {
+ // // map < String(COPSHandle), COPSPepReqStateMan>;
+ // getReqStateMans().put(hanlde, r);
+ // }
+ }
+
+ @SuppressWarnings("rawtypes")
+ class PCMMPSReqStateMan extends COPSPepReqStateMan {
+
+ public PCMMPSReqStateMan(short clientType, String clientHandle) {
+ super(clientType, clientHandle);
+ _process = new CmtsDataProcessor();
+
+ }
+
+ @Override
+ protected void processDecision(COPSDecisionMsg dMsg)
+ throws COPSPepException {
+
+ // COPSHandle handle = dMsg.getClientHandle();
+ Hashtable decisions = dMsg.getDecisions();
+
+ Hashtable removeDecs = new Hashtable(10);
+ Hashtable installDecs = new Hashtable(10);
+ Hashtable errorDecs = new Hashtable(10);
+ for (Enumeration e = decisions.keys(); e.hasMoreElements();) {
+
+ COPSContext context = (COPSContext) e.nextElement();
+ Vector v = (Vector) decisions.get(context);
+ Enumeration ee = v.elements();
+ COPSDecision cmddecision = (COPSDecision) ee.nextElement();
+
+ // cmddecision --> we must check whether it is an error!
+
+ if (cmddecision.isInstallDecision()) {
+ String prid = new String();
+ for (; ee.hasMoreElements();) {
+ COPSDecision decision = (COPSDecision) ee.nextElement();
+ COPSPrObjBase obj = new COPSPrObjBase(decision.getData().getData());
+ switch (obj.getSNum()) {
+ // TODO when there is install request only the PR_PRID
+ // is git but the ClientSI object containing the PR_EPD
+ // is null??? this is why the tests fail and so I set
+ // the assertion to NOT true....
+ case COPSPrObjBase.PR_PRID:
+ prid = obj.getData().str();
+ break;
+ case COPSPrObjBase.PR_EPD:
+ installDecs.put(prid, obj.getData().str());
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ if (cmddecision.isRemoveDecision()) {
+ String prid = new String();
+ for (; ee.hasMoreElements();) {
+ COPSDecision decision = (COPSDecision) ee.nextElement();
+ COPSPrObjBase obj = new COPSPrObjBase(decision.getData().getData());
+ switch (obj.getSNum()) {
+ case COPSPrObjBase.PR_PRID:
+ prid = obj.getData().str();
+ break;
+ case COPSPrObjBase.PR_EPD:
+ removeDecs.put(prid, obj.getData().str());
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ if (_process != null) {
+ // ** Apply decisions to the configuration
+ _process.setDecisions(this, removeDecs, installDecs, errorDecs);
+ _status = ST_DECS;
+ if (_process.isFailReport(this)) {
+ // COPSDebug.out(getClass().getName(),"Sending FAIL Report\n");
+ _sender.sendFailReport(_process.getReportData(this));
+ } else {
+ // COPSDebug.out(getClass().getName(),"Sending SUCCESS Report\n");
+ _sender.sendSuccessReport(_process.getReportData(this));
+ }
+ _status = ST_REPORT;
+ }
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ class CmtsDataProcessor extends COPSPepDataProcess {
+
+ private Hashtable removeDecs;
+ private Hashtable installDecs;
+ private Hashtable errorDecs;
+ private COPSPepReqStateMan stateManager;
+
+ public CmtsDataProcessor() {
+ setRemoveDecs(new Hashtable(10));
+ setInstallDecs(new Hashtable(10));
+ setErrorDecs(new Hashtable(10));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setDecisions(COPSPepReqStateMan man, Hashtable removeDecs, Hashtable installDecs, Hashtable errorDecs) {
+ setRemoveDecs(removeDecs);
+ setInstallDecs(installDecs);
+ setErrorDecs(errorDecs);
+ setStateManager(man);
+ }
+
+ @Override
+ public boolean isFailReport(COPSPepReqStateMan man) {
+ return (errorDecs != null && errorDecs.size() > 0);
+ }
+
+ @Override
+ public Hashtable getReportData(COPSPepReqStateMan man) {
+ if (isFailReport(man)) {
+ return errorDecs;
+ } else {
+ ITransactionID transactionID = null;
+ String key = null;
+ Hashtable siDataHashTable = new Hashtable();
+ if (installDecs.size() > 0) {
+ String data = "";
+ for (String k : installDecs.keySet()) {
+ data = installDecs.get(k);
+ break;
+ }
+ transactionID = new PCMMGateReq(new COPSData(data).getData()).getTransactionID();
+ IPCMMGate responseGate = new PCMMGateReq();
+ responseGate.setTransactionID(transactionID);
+ siDataHashTable.put(key, new String(responseGate.getData()));
+ }
+ return siDataHashTable;
+ }
+ }
+
+ @Override
+ public Hashtable getClientData(COPSPepReqStateMan man) {
+ // TODO Auto-generated method stub
+ return new Hashtable();
+ }
+
+ @Override
+ public Hashtable getAcctData(COPSPepReqStateMan man) {
+ // TODO Auto-generated method stub
+ return new Hashtable();
+ }
+
+ @Override
+ public void notifyClosedConnection(COPSPepReqStateMan man, COPSError error) {
+
+ }
+
+ @Override
+ public void notifyNoKAliveReceived(COPSPepReqStateMan man) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void closeRequestState(COPSPepReqStateMan man) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void newRequestState(COPSPepReqStateMan man) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Hashtable getRemoveDecs() {
+ return removeDecs;
+ }
+
+ public void setRemoveDecs(Hashtable removeDecs) {
+ this.removeDecs = removeDecs;
+ }
+
+ public Hashtable getInstallDecs() {
+ return installDecs;
+ }
+
+ public void setInstallDecs(Hashtable installDecs) {
+ this.installDecs = installDecs;
+ }
+
+ public Hashtable getErrorDecs() {
+ return errorDecs;
+ }
+
+ public void setErrorDecs(Hashtable errorDecs) {
+ this.errorDecs = errorDecs;
+ }
+
+ public COPSPepReqStateMan getStateManager() {
+ return stateManager;
+ }
+
+ public void setStateManager(COPSPepReqStateMan stateManager) {
+ this.stateManager = stateManager;
+ }
+ }
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/rcd/impl/PCMMPolicyServer.java b/packetcable-driver/src/main/java/org/pcmm/rcd/impl/PCMMPolicyServer.java
new file mode 100644
index 0000000..bd763eb
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/rcd/impl/PCMMPolicyServer.java
@@ -0,0 +1,652 @@
+/**
+ * @header@
+ */
+package org.pcmm.rcd.impl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.Properties;
+
+import org.pcmm.PCMMConstants;
+import org.pcmm.PCMMGlobalConfig;
+import org.pcmm.PCMMProperties;
+import org.pcmm.gates.IAMID;
+import org.pcmm.gates.IClassifier;
+import org.pcmm.gates.IExtendedClassifier;
+import org.pcmm.gates.IGateID;
+import org.pcmm.gates.IGateSpec;
+import org.pcmm.gates.IGateSpec.DSCPTOS;
+import org.pcmm.gates.IGateSpec.Direction;
+import org.pcmm.gates.IPCMMError;
+import org.pcmm.gates.IPCMMGate;
+import org.pcmm.gates.ISubscriberID;
+import org.pcmm.gates.ITrafficProfile;
+import org.pcmm.gates.ITransactionID;
+import org.pcmm.gates.impl.AMID;
+import org.pcmm.gates.impl.BestEffortService;
+import org.pcmm.gates.impl.Classifier;
+import org.pcmm.gates.impl.ExtendedClassifier;
+import org.pcmm.gates.impl.GateID;
+import org.pcmm.gates.impl.GateSpec;
+import org.pcmm.gates.impl.PCMMError;
+import org.pcmm.gates.impl.PCMMGateReq;
+import org.pcmm.gates.impl.SubscriberID;
+import org.pcmm.gates.impl.TransactionID;
+import org.pcmm.messages.IMessage.MessageProperties;
+import org.pcmm.messages.impl.MessageFactory;
+import org.pcmm.objects.MMVersionInfo;
+import org.pcmm.rcd.IPCMMPolicyServer;
+import org.pcmm.utils.PCMMException;
+import org.umu.cops.prpdp.COPSPdpConnection;
+import org.umu.cops.prpdp.COPSPdpDataProcess;
+import org.umu.cops.stack.COPSClientAcceptMsg;
+import org.umu.cops.stack.COPSClientCloseMsg;
+import org.umu.cops.stack.COPSClientOpenMsg;
+import org.umu.cops.stack.COPSClientSI;
+import org.umu.cops.stack.COPSData;
+import org.umu.cops.stack.COPSDecision;
+import org.umu.cops.stack.COPSError;
+import org.umu.cops.stack.COPSException;
+import org.umu.cops.stack.COPSHeader;
+import org.umu.cops.stack.COPSMsg;
+import org.umu.cops.stack.COPSReportMsg;
+import org.umu.cops.stack.COPSReqMsg;
+
+/**
+ *
+ * PCMM policy server
+ *
+ */
+public class PCMMPolicyServer extends AbstractPCMMServer implements
+ IPCMMPolicyServer {
+ /**
+ * since PCMMPolicyServer can connect to multiple CMTS (PEP) we need to
+ * manage each connection in a separate thread.
+ */
+
+ public PCMMPolicyServer() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.pcmm.rcd.IPCMMPolicyServer#requestCMTSConnection(java.lang.String)
+ */
+ public IPSCMTSClient requestCMTSConnection(String host) {
+ try {
+ InetAddress address = InetAddress.getByName(host);
+ return requestCMTSConnection(address);
+ } catch (UnknownHostException e) {
+ logger.error(e.getMessage());
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.pcmm.rcd.IPCMMPolicyServer#requestCMTSConnection(java.net.InetAddress
+ * )
+ */
+ public IPSCMTSClient requestCMTSConnection(InetAddress host) {
+ IPSCMTSClient client = new PSCMTSClient();
+ try {
+ if (client.tryConnect(host, PCMMProperties.get(PCMMConstants.PCMM_PORT, Integer.class))) {
+ boolean endNegotiation = false;
+ while (!endNegotiation) {
+ logger.debug("waiting for OPN message from CMTS");
+ COPSMsg opnMessage = client.readMessage();
+ // Client-Close
+ if (opnMessage.getHeader().isAClientClose()) {
+ COPSError error = ((COPSClientCloseMsg) opnMessage).getError();
+ logger.debug("CMTS requetsed Client-Close");
+ throw new PCMMException(new PCMMError(error.getErrCode(), error.getErrSubCode()));
+ } else // Client-Open
+ if (opnMessage.getHeader().isAClientOpen()) {
+ logger.debug("OPN message received from CMTS");
+ COPSClientOpenMsg opn = (COPSClientOpenMsg) opnMessage;
+ if (opn.getClientSI() == null)
+ throw new COPSException("CMTS shoud have sent MM version info in Client-Open message");
+ else {
+ // set the version info
+ MMVersionInfo vInfo = new MMVersionInfo(opn.getClientSI().getData().getData());
+ client.setVersionInfo(vInfo);
+ logger.debug("CMTS sent MMVersion info : major:" + vInfo.getMajorVersionNB() + " minor:" + vInfo.getMinorVersionNB()); //
+ if (client.getVersionInfo().getMajorVersionNB() == client.getVersionInfo().getMinorVersionNB()) {
+ // send a CC since CMTS has exhausted all
+ // protocol selection attempts
+ throw new COPSException("CMTS exhausted all protocol selection attempts");
+ }
+ }
+ // send CAT response
+ Properties prop = new Properties();
+ logger.debug("send CAT to the CMTS ");
+ COPSMsg catMsg = MessageFactory.getInstance().create(COPSHeader.COPS_OP_CAT, prop);
+ client.sendRequest(catMsg);
+ // wait for REQ msg
+ COPSMsg reqMsg = client.readMessage();
+ // Client-Close
+ if (reqMsg.getHeader().isAClientClose()) {
+ COPSError error = ((COPSClientCloseMsg) opnMessage).getError();
+ logger.debug("CMTS requetsed Client-Close");
+ throw new PCMMException(new PCMMError(error.getErrCode(), error.getErrSubCode()));
+ } else // Request
+ if (reqMsg.getHeader().isARequest()) {
+ logger.debug("Received REQ message form CMTS");
+ // end connection attempts
+ COPSReqMsg req = (COPSReqMsg) reqMsg;
+ // set the client handle to be used later by the
+ // gate-set
+ client.setClientHandle(req.getClientHandle().getId().str());
+ COPSPdpDataProcess processor = null;
+ COPSPdpConnection copsPdpConnection = new COPSPdpConnection(opn.getPepId(), ((AbstractPCMMClient) client).getSocket(), processor);
+ copsPdpConnection.setKaTimer(((COPSClientAcceptMsg) catMsg).getKATimer().getTimerVal());
+ pool.schedule(pool.adapt(copsPdpConnection));
+ endNegotiation = true;
+ } else
+ throw new COPSException("Can't understand request");
+ } else {
+ throw new COPSException("Can't understand request");
+ }
+ }
+ }
+ // else raise exception.
+ } catch (Exception e) {
+ logger.error(e.getMessage());
+ // no need to keep connection.
+ client.disconnect();
+ return null;
+ }
+ return client;
+ }
+
+ @Override
+ protected IPCMMClientHandler getPCMMClientHandler(Socket socket) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ *
+ * @see {@link IPSCMTSClient}
+ */
+ /* public */static class PSCMTSClient extends AbstractPCMMClient implements
+ IPSCMTSClient {
+ /**
+ * Transaction id is
+ */
+ private short transactionID;
+ private short classifierID;
+ private int gateID;
+
+ public PSCMTSClient() {
+ super();
+ logger.info("Client " + getClass() + hashCode() + " crated and started");
+ }
+
+ public PSCMTSClient(Socket socket) {
+ setSocket(socket);
+ }
+
+ public boolean gateSet() {
+ logger.debug("Sending Gate-Set message");
+ if (!isConnected())
+ throw new IllegalArgumentException("Not connected");
+ // XXX check if other values should be provided
+ //
+ ITrafficProfile trafficProfile = buildTrafficProfile();
+ // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
+ ITransactionID trID = new TransactionID();
+ // set transaction ID to gate set
+ trID.setGateCommandType(ITransactionID.GateSet);
+ transactionID = (short) (transactionID == 0 ? (short) (Math.random() * hashCode()) : transactionID);
+ trID.setTransactionIdentifier(transactionID);
+ // AMID
+ IAMID amid = getAMID();
+ // GATE SPEC
+ IGateSpec gateSpec = getGateSpec();
+ ISubscriberID subscriberID = new SubscriberID();
+ // Classifier if MM version <4, Extended Classifier else
+ IClassifier eclassifier = getClassifier(subscriberID);
+
+ IPCMMGate gate = new PCMMGateReq();
+ gate.setTransactionID(trID);
+ gate.setAMID(amid);
+ gate.setSubscriberID(subscriberID);
+ gate.setGateSpec(gateSpec);
+ gate.setTrafficProfile(trafficProfile);
+ gate.setClassifier(eclassifier);
+ byte[] data = gate.getData();
+
+ // configure message properties
+ Properties prop = new Properties();
+ prop.put(MessageProperties.CLIENT_HANDLE, getClientHandle());
+ prop.put(MessageProperties.DECISION_CMD_CODE, COPSDecision.DEC_INSTALL);
+ prop.put(MessageProperties.DECISION_FLAG, (short) COPSDecision.DEC_NULL);
+ prop.put(MessageProperties.GATE_CONTROL, new COPSData(data, 0, data.length));
+ COPSMsg decisionMsg = MessageFactory.getInstance().create(COPSHeader.COPS_OP_DEC, prop);
+ // ** Send the GateSet Decision
+ // **
+ sendRequest(decisionMsg);
+ // TODO check on this ?
+ // waits for the gate-set-ack or error
+ COPSMsg responseMsg = readMessage();
+ if (responseMsg.getHeader().isAReport()) {
+ logger.info("processing received report from CMTS");
+ COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
+ if (reportMsg.getClientSI().size() == 0) {
+ logger.debug("CMTS responded with an empty SI");
+ return false;
+ }
+ COPSClientSI clientSI = (COPSClientSI) reportMsg.getClientSI().elementAt(0);
+ IPCMMGate responseGate = new PCMMGateReq(clientSI.getData().getData());
+ IPCMMError error = ((PCMMGateReq) responseGate).getError();
+ if (error != null) {
+ logger.error(error.toString());
+ return false;
+ }
+ logger.info("the CMTS has sent TransactionID :"+responseGate.getTransactionID());
+ if (responseGate.getTransactionID() != null && responseGate.getTransactionID().getGateCommandType() == ITransactionID.GateSetAck) {
+ logger.info("the CMTS has sent a Gate-Set-Ack response");
+ // here CMTS responded that he acknowledged the Gate-Set
+ // TODO do further check of Gate-Set-Ack GateID etc...
+ gateID = responseGate.getGateID().getGateID();
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.rcd.IPCMMPolicyServer#gateDelete()
+ */
+ @Override
+ public boolean gateDelete() {
+ if (!isConnected()) {
+ logger.error("Not connected");
+ return false;
+ }
+ ITransactionID trID = new TransactionID();
+ // set transaction ID to gate set
+ trID.setGateCommandType(ITransactionID.GateDelete);
+ trID.setTransactionIdentifier(transactionID);
+ // AMID
+ IAMID amid = getAMID();
+ // GATE SPEC
+ ISubscriberID subscriberID = new SubscriberID();
+ try {
+ subscriberID.setSourceIPAddress(InetAddress.getLocalHost());
+ } catch (UnknownHostException e1) {
+ logger.error(e1.getMessage());
+ }
+
+ IGateID gateIdObj = new GateID();
+ gateIdObj.setGateID(gateID);
+
+ IPCMMGate gate = new PCMMGateReq();
+ gate.setTransactionID(trID);
+ gate.setAMID(amid);
+ gate.setSubscriberID(subscriberID);
+ gate.setGateID(gateIdObj);
+
+ // configure message properties
+ Properties prop = new Properties();
+ prop.put(MessageProperties.CLIENT_HANDLE, getClientHandle());
+ prop.put(MessageProperties.DECISION_CMD_CODE, COPSDecision.DEC_INSTALL);
+ prop.put(MessageProperties.DECISION_FLAG, (short) COPSDecision.DEC_NULL);
+ byte[] data = gate.getData();
+ prop.put(MessageProperties.GATE_CONTROL, new COPSData(data, 0, data.length));
+ COPSMsg decisionMsg = MessageFactory.getInstance().create(COPSHeader.COPS_OP_DEC, prop);
+ // ** Send the GateSet Decision
+ // **
+ try {
+ decisionMsg.writeData(getSocket());
+ } catch (IOException e) {
+ logger.error("Failed to send the decision, reason: " + e.getMessage());
+ return false;
+ }
+ // waits for the gate-delete-ack or error
+ COPSMsg responseMsg = readMessage();
+ if (responseMsg.getHeader().isAReport()) {
+ logger.info("processing received report from CMTS");
+ COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
+ if (reportMsg.getClientSI().size() == 0) {
+ return false;
+ }
+ COPSClientSI clientSI = (COPSClientSI) reportMsg.getClientSI().elementAt(0);
+ IPCMMGate responseGate = new PCMMGateReq(clientSI.getData().getData());
+ IPCMMError error = ((PCMMGateReq) responseGate).getError();
+ if (error != null) {
+ logger.error(error.toString());
+ return false;
+ }
+ // here CMTS responded that he acknowledged the Gate-delete
+ // message
+ ITransactionID responseTransactionID = responseGate.getTransactionID();
+ if (responseTransactionID != null && responseTransactionID.getGateCommandType() == ITransactionID.GateDeleteAck) {
+ // TODO check : Is this test needed ??
+ if (responseGate.getGateID().getGateID() == gateID && responseTransactionID.getTransactionIdentifier() == transactionID) {
+ logger.info("the CMTS has sent a Gate-Delete-Ack response");
+ return true;
+ }
+ }
+
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.rcd.IPCMMPolicyServer#gateInfo()
+ */
+ @Override
+ public boolean gateInfo() {
+ if (!isConnected()) {
+ logger.error("Not connected");
+ return false;
+ }
+ ITransactionID trID = new TransactionID();
+ // set transaction ID to gate set
+ trID.setGateCommandType(ITransactionID.GateInfo);
+ trID.setTransactionIdentifier(transactionID);
+ // AMID
+ IAMID amid = getAMID();
+ // GATE SPEC
+ ISubscriberID subscriberID = new SubscriberID();
+ try {
+ subscriberID.setSourceIPAddress(InetAddress.getLocalHost());
+ } catch (UnknownHostException e1) {
+ logger.error(e1.getMessage());
+ }
+ IGateID gateIdObj = new GateID();
+ gateIdObj.setGateID(gateID);
+
+ IPCMMGate gate = new PCMMGateReq();
+ gate.setTransactionID(trID);
+ gate.setAMID(amid);
+ gate.setSubscriberID(subscriberID);
+ gate.setGateID(gateIdObj);
+
+ // configure message properties
+ Properties prop = new Properties();
+ prop.put(MessageProperties.CLIENT_HANDLE, getClientHandle());
+ prop.put(MessageProperties.DECISION_CMD_CODE, COPSDecision.DEC_INSTALL);
+ prop.put(MessageProperties.DECISION_FLAG, (short) COPSDecision.DEC_NULL);
+ byte[] data = gate.getData();
+ prop.put(MessageProperties.GATE_CONTROL, new COPSData(data, 0, data.length));
+ COPSMsg decisionMsg = MessageFactory.getInstance().create(COPSHeader.COPS_OP_DEC, prop);
+ // ** Send the GateSet Decision
+ // **
+ try {
+ decisionMsg.writeData(getSocket());
+ } catch (IOException e) {
+ logger.error("Failed to send the decision, reason: " + e.getMessage());
+ return false;
+ }
+ // waits for the gate-Info-ack or error
+ COPSMsg responseMsg = readMessage();
+ if (responseMsg.getHeader().isAReport()) {
+ logger.info("processing received report from CMTS");
+ COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
+ if (reportMsg.getClientSI().size() == 0) {
+ return false;
+ }
+ COPSClientSI clientSI = (COPSClientSI) reportMsg.getClientSI().elementAt(0);
+ IPCMMGate responseGate = new PCMMGateReq(clientSI.getData().getData());
+ IPCMMError error = ((PCMMGateReq) responseGate).getError();
+ ITransactionID responseTransactionID = responseGate.getTransactionID();
+ if (error != null) {
+ logger.debug(responseTransactionID != null ? responseTransactionID.toString() : "returned Transaction ID is null");
+ logger.error(error.toString());
+ return false;
+ }
+ // here CMTS responded that he acknowledged the Gate-Info
+ // message
+ /*
+ * =
+ * []
+ * ] [] []
+ * [] [] []
+ * [] []
+ */
+ if (responseTransactionID != null && responseTransactionID.getGateCommandType() == ITransactionID.GateInfoAck) {
+ // TODO need to implement missing data wrapper
+ logger.info("TransactionID : " + responseTransactionID.toString());
+ logger.info("AMID :" + String.valueOf(responseGate.getAMID()));
+ logger.info("SubscriberID :" + String.valueOf(responseGate.getSubscriberID()));
+ logger.info("Traffic Profile :" + String.valueOf(responseGate.getTrafficProfile()));
+ logger.info("Gate Time Info :");
+ logger.info("Gate Usage Info :");
+ logger.info("GateState :");
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.pcmm.rcd.IPCMMPolicyServer#synchronize()
+ */
+ @Override
+ public boolean gateSynchronize() {
+ if (!isConnected()) {
+ logger.error("Not connected");
+ return false;
+ }
+ ITransactionID trID = new TransactionID();
+ // set transaction ID to gate set
+ trID.setGateCommandType(ITransactionID.SynchRequest);
+ trID.setTransactionIdentifier(transactionID);
+ // AMID
+ IAMID amid = getAMID();
+ // GATE SPEC
+ ISubscriberID subscriberID = new SubscriberID();
+ try {
+ subscriberID.setSourceIPAddress(InetAddress.getLocalHost());
+ } catch (UnknownHostException e1) {
+ logger.error(e1.getMessage());
+ }
+ IGateID gateIdObj = new GateID();
+ gateIdObj.setGateID(gateID);
+
+ IPCMMGate gate = new PCMMGateReq();
+ gate.setTransactionID(trID);
+ gate.setAMID(amid);
+ gate.setSubscriberID(subscriberID);
+ gate.setGateID(gateIdObj);
+
+ // configure message properties
+ Properties prop = new Properties();
+ prop.put(MessageProperties.CLIENT_HANDLE, getClientHandle());
+ prop.put(MessageProperties.DECISION_CMD_CODE, COPSDecision.DEC_INSTALL);
+ prop.put(MessageProperties.DECISION_FLAG, (short) COPSDecision.DEC_NULL);
+ byte[] data = gate.getData();
+ prop.put(MessageProperties.GATE_CONTROL, new COPSData(data, 0, data.length));
+ COPSMsg decisionMsg = MessageFactory.getInstance().create(COPSHeader.COPS_OP_DEC, prop);
+ // ** Send the GateSet Decision
+ // **
+ try {
+ decisionMsg.writeData(getSocket());
+ } catch (IOException e) {
+ logger.error("Failed to send the decision, reason: " + e.getMessage());
+ return false;
+ }
+ // waits for the gate-Info-ack or error
+ COPSMsg responseMsg = readMessage();
+ if (responseMsg.getHeader().isAReport()) {
+ logger.info("processing received report from CMTS");
+ COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
+ if (reportMsg.getClientSI().size() == 0) {
+ return false;
+ }
+ COPSClientSI clientSI = (COPSClientSI) reportMsg.getClientSI().elementAt(0);
+ IPCMMGate responseGate = new PCMMGateReq(clientSI.getData().getData());
+ IPCMMError error = ((PCMMGateReq) responseGate).getError();
+ ITransactionID responseTransactionID = responseGate.getTransactionID();
+ if (error != null) {
+ logger.debug(responseTransactionID != null ? responseTransactionID.toString() : "returned Transaction ID is null");
+ logger.error(error.toString());
+ return false;
+ }
+ // here CMTS responded that he acknowledged the Gate-Info
+ // message
+ /*
+ * =
+ * []
+ * ] [] []
+ * [] [] []
+ * [] []
+ */
+ if (responseTransactionID != null && responseTransactionID.getGateCommandType() == ITransactionID.SynchReport) {
+ // TODO need to implement missing data wrapper
+ logger.info("TransactionID : " + responseTransactionID.toString());
+ logger.info("AMID :" + String.valueOf(responseGate.getAMID()));
+ logger.info("SubscriberID :" + String.valueOf(responseGate.getSubscriberID()));
+ logger.info("Traffic Profile :" + String.valueOf(responseGate.getTrafficProfile()));
+ logger.info("Gate Time Info :");
+ logger.info("Gate Usage Info :");
+ logger.info("GateState :");
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+ private IAMID getAMID() {
+ IAMID amid = new AMID();
+ amid.setApplicationType((short) 1);
+ amid.setApplicationMgrTag((short) 1);
+ return amid;
+ }
+
+ private IClassifier getClassifier(ISubscriberID subscriberID) {
+ IClassifier classifier = null;
+ // if the version major is less than 4 we need to use Classifier
+ if (getVersionInfo().getMajorVersionNB() >= 4) {
+ classifier = new ExtendedClassifier();
+ // eclassifier.setProtocol(IClassifier.Protocol.NONE);
+ classifier.setProtocol(IClassifier.Protocol.TCP);
+ try {
+ InetAddress subIP = InetAddress.getByName(PCMMGlobalConfig.SubscriberID);
+ InetAddress srcIP = InetAddress.getByName(PCMMGlobalConfig.srcIP);
+ InetAddress dstIP = InetAddress.getByName(PCMMGlobalConfig.dstIP);
+ InetAddress mask = InetAddress.getByName(PCMMProperties.get(PCMMConstants.DEFAULT_MASK, String.class));
+ subscriberID.setSourceIPAddress(subIP);
+ classifier.setSourceIPAddress(srcIP);
+ classifier.setDestinationIPAddress(dstIP);
+ ((IExtendedClassifier) classifier).setIPDestinationMask(mask);
+ ((IExtendedClassifier) classifier).setIPSourceMask(mask);
+ } catch (UnknownHostException unae) {
+ System.out.println("Error getByName" + unae.getMessage());
+ }
+ ((IExtendedClassifier) classifier).setSourcePortStart(PCMMGlobalConfig.srcPort);
+ ((IExtendedClassifier) classifier).setSourcePortEnd(PCMMGlobalConfig.srcPort);
+ ((IExtendedClassifier) classifier).setDestinationPortStart(PCMMGlobalConfig.dstPort);
+ ((IExtendedClassifier) classifier).setDestinationPortEnd(PCMMGlobalConfig.dstPort);
+ ((IExtendedClassifier) classifier).setActivationState((byte) 0x01);
+ /*
+ * check if we have a stored value of classifierID else we just
+ * create one eclassifier.setClassifierID((short) 0x01);
+ */
+ ((IExtendedClassifier) classifier).setClassifierID((short) (classifierID == 0 ? Math.random() * hashCode() : classifierID));
+ // XXX - testie
+ // eclassifier.setClassifierID((short) 1);
+ ((IExtendedClassifier) classifier).setAction((byte) 0x00);
+ // XXX - temp default until Gate Modify is hacked in
+ // eclassifier.setPriority(PCMMGlobalConfig.EClassifierPriority);
+ classifier.setPriority((byte) 65);
+
+ } else {
+ classifier = new Classifier();
+ classifier.setProtocol(IClassifier.Protocol.TCP);
+ try {
+ InetAddress subIP = InetAddress.getByName(PCMMGlobalConfig.SubscriberID);
+ InetAddress srcIP = InetAddress.getByName(PCMMGlobalConfig.srcIP);
+ InetAddress dstIP = InetAddress.getByName(PCMMGlobalConfig.dstIP);
+ subscriberID.setSourceIPAddress(subIP);
+ classifier.setSourceIPAddress(srcIP);
+ classifier.setDestinationIPAddress(dstIP);
+ } catch (UnknownHostException unae) {
+ System.out.println("Error getByName" + unae.getMessage());
+ }
+ classifier.setSourcePort(PCMMGlobalConfig.srcPort);
+ classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
+ }
+ return classifier;
+ }
+
+ /**
+ *
+ * @return GateSpec object
+ */
+ private IGateSpec getGateSpec() {
+ IGateSpec gateSpec = new GateSpec();
+ gateSpec.setDirection(Direction.UPSTREAM);
+ gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
+ gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
+ gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
+ gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
+ gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
+ return gateSpec;
+ }
+
+ /**
+ * creates a traffic profile with 3 envelops (Authorized, Reserved and
+ * Committed).
+ *
+ * @return Traffic profile
+ */
+ private ITrafficProfile buildTrafficProfile() {
+ ITrafficProfile trafficProfile = new BestEffortService(BestEffortService.DEFAULT_ENVELOP);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop().setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop().setMaximumTrafficBurst(BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop().setRequestTransmissionPolicy(PCMMGlobalConfig.BETransmissionPolicy);
+ ((BestEffortService) trafficProfile).getAuthorizedEnvelop().setMaximumSustainedTrafficRate(PCMMGlobalConfig.DefaultLowBestEffortTrafficRate);
+ // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
+
+ ((BestEffortService) trafficProfile).getReservedEnvelop().setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
+ ((BestEffortService) trafficProfile).getReservedEnvelop().setMaximumTrafficBurst(BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
+ ((BestEffortService) trafficProfile).getReservedEnvelop().setRequestTransmissionPolicy(PCMMGlobalConfig.BETransmissionPolicy);
+ ((BestEffortService) trafficProfile).getReservedEnvelop().setMaximumSustainedTrafficRate(PCMMGlobalConfig.DefaultLowBestEffortTrafficRate);
+ // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
+
+ ((BestEffortService) trafficProfile).getCommittedEnvelop().setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
+ ((BestEffortService) trafficProfile).getCommittedEnvelop().setMaximumTrafficBurst(BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
+ ((BestEffortService) trafficProfile).getCommittedEnvelop().setRequestTransmissionPolicy(PCMMGlobalConfig.BETransmissionPolicy);
+ ((BestEffortService) trafficProfile).getCommittedEnvelop().setMaximumSustainedTrafficRate(PCMMGlobalConfig.DefaultLowBestEffortTrafficRate);
+ return trafficProfile;
+ }
+
+ @Override
+ public short getClassifierId() {
+ return classifierID;
+ }
+
+ @Override
+ public short getTransactionId() {
+ return transactionID;
+ }
+
+ @Override
+ public int getGateId() {
+ return gateID;
+ }
+ }
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/rcd/package-info.java b/packetcable-driver/src/main/java/org/pcmm/rcd/package-info.java
new file mode 100644
index 0000000..0d21830
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/rcd/package-info.java
@@ -0,0 +1,11 @@
+
+/**
+ *
+ * The Resource Control Domain (RCD) may be defined as a logical grouping of elements that provide connectivity and network resource level policy management along the packet forwarding paths to and from an end host.
+ * The RCD consists of CMTS and Policy Server entities whose responsibilities include management of resources along the packet forwarding paths.
+ *
+ * The Application Server is a network entity that interfaces with the
+ * Application Manager that requests PacketCable Multimedia services on behalf
+ * of clients. The AS may reside on the MSO's network or it may reside outside
+ * of this domain and interact with the MSO network via a particular trust
+ * relationship. Similarly, the AS may be under direct control of the operator
+ * or it may be controlled by a third-party. Any given AS may communicate with
+ * one or more Application Managers.
+ *
+ *
+ * The AS will communicate with a client via a signaling protocol that is
+ * outside the scope of this specification. Using this unspecified protocol, the
+ * Domain policies. For client requests that pass these checks, the AS
+ * determines the particular QoS parameters necessary to deliver the service to
+ * the client, based upon its knowledge of the requested service. It then sends
+ * a request for these resources to the appropriate Application Manager, which
+ * may deny the request based upon additional Service Control Domain policies or
+ * may pass the request on to the Policy Server.
+ *
+ *
+ *
+ */
+public interface IApplicationServer {
+
+ /**
+ * sets the Application Server's id
+ *
+ * @param id
+ * : the id of the AS
+ */
+ void setASId(String id);
+
+ /**
+ * gets the AS id
+ *
+ * @return AS id
+ */
+ String getASId();
+
+}
diff --git a/packetcable-driver/src/main/java/org/pcmm/scd/impl/package-info.java b/packetcable-driver/src/main/java/org/pcmm/scd/impl/package-info.java
new file mode 100644
index 0000000..41213d0
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/scd/impl/package-info.java
@@ -0,0 +1,7 @@
+/**
+ *
+ */
+/**
+ *
+ */
+package org.pcmm.scd.impl;
diff --git a/packetcable-driver/src/main/java/org/pcmm/scd/package-info.java b/packetcable-driver/src/main/java/org/pcmm/scd/package-info.java
new file mode 100644
index 0000000..b6c8651
--- /dev/null
+++ b/packetcable-driver/src/main/java/org/pcmm/scd/package-info.java
@@ -0,0 +1,10 @@
+/**
+ *
+ * The Service Control Domain (SCD) is defined as a logical grouping of elements that offer applications and content to service subscribers.
+ * The Application Manager resides in the SCD. Note that there may be one or more SCDs related to a single RCD. Conversely, each RCD may interact with one or more SCDs.
+ *