import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.ServiceFlowDirection;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.TosByte;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.ccap.attributes.AmId;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.classifier.attributes.classifiers.ClassifierContainer;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.classifier.attributes.classifiers.classifier.container.ClassifierChoice;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.classifier.attributes.classifiers.classifier.container.classifier.choice.ExtClassifierChoice;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.classifier.attributes.classifiers.classifier.container.classifier.choice.Ipv6ClassifierChoice;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.classifier.attributes.classifiers.classifier.container.classifier.choice.QosClassifierChoice;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.pcmm.qos.classifier.Classifier;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.pcmm.qos.ext.classifier.ExtClassifier;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.pcmm.qos.gate.spec.GateSpec;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.pcmm.qos.ipv6.classifier.Ipv6Classifier;
-import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.pcmm.qos.traffic.profile.TrafficProfile;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.ServiceFlowDirection;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.TosByte;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.ccap.attributes.AmId;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.classifier.attributes.classifiers.ClassifierContainer;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.classifier.attributes.classifiers.classifier.container.ClassifierChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.classifier.attributes.classifiers.classifier.container.classifier.choice.ExtClassifierChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.classifier.attributes.classifiers.classifier.container.classifier.choice.Ipv6ClassifierChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.classifier.attributes.classifiers.classifier.container.classifier.choice.QosClassifierChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.classifier.Classifier;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.ext.classifier.ExtClassifier;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.gate.spec.GateSpec;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.ipv6.classifier.Ipv6Classifier;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.traffic.profile.TrafficProfile;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.serviceclass.name.profile.ServiceClassNameProfile;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.flow.spec.profile.FlowSpecProfile;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.ugs.profile.UgsProfile;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.rtp.profile.RtpProfile;
import org.pcmm.gates.IClassifier;
import org.pcmm.gates.IClassifier.Protocol;
import org.pcmm.gates.IExtendedClassifier;
import org.pcmm.gates.ITrafficProfile;
import org.pcmm.gates.impl.AMID;
import org.pcmm.gates.impl.DOCSISServiceClassNameTrafficProfile;
+import org.pcmm.gates.impl.DOCSISFlowSpecTrafficProfile;
+import org.pcmm.gates.impl.DOCSISUGSTrafficProfile;
+import org.pcmm.gates.impl.DOCSISRTPTrafficProfile;
import org.pcmm.gates.impl.GateID;
import org.pcmm.gates.impl.GateState;
import org.pcmm.gates.impl.GateTimeInfo;
import org.pcmm.gates.impl.GateUsageInfo;
import org.pcmm.gates.impl.PCMMError;
import org.pcmm.gates.impl.PCMMGateReq;
+import org.pcmm.gates.impl.SessionClassID;
import org.pcmm.gates.impl.SubscriberID;
import org.pcmm.gates.impl.TransactionID;
+import org.pcmm.utils.PCMMUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.traffic.profile.TrafficProfile;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.traffic.profile.traffic.profile.TrafficProfileChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.FlowSpecChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.ServiceClassNameChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.RtpChoice;
+import org.opendaylight.yang.gen.v1.urn.packetcable.rev170125.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.UgsChoice;
+
/**
* Build PCMM gate requests from API QoS Gate objects
*/
subscriberID = new SubscriberID(qosSubId);
}
- public void setGateSpec(final GateSpec qosGateSpec, final ServiceFlowDirection scnDirection) {
+ public void setGateId(int gateId) {
+ gateID = new GateID(gateId);
+ }
+
+ public void setGateSpec(final GateSpec qosGateSpec) {
- final ServiceFlowDirection qosDir;
- if (scnDirection != null) {
- qosDir = scnDirection;
- } else {
- if (qosGateSpec.getDirection() != null) {
- qosDir = qosGateSpec.getDirection();
- } else {
- // TODO - determine if this is a valid default value
- qosDir = ServiceFlowDirection.Ds;
- }
- }
+ final ServiceFlowDirection qosDir = qosGateSpec.getDirection();
+ // convert to PCMM API Type
final Direction gateDir;
if (qosDir == ServiceFlowDirection.Ds) {
gateDir = Direction.DOWNSTREAM;
gateDir = Direction.UPSTREAM;
}
- // DSCP/TOS Overwrite
- final byte dscptos;
+ final byte dscptos = 1;
final byte gateTosMask;
- final TosByte tosOverwrite = qosGateSpec.getDscpTosOverwrite();
- if (tosOverwrite != null) {
- dscptos = 1;
- TosByte tosMask = qosGateSpec.getDscpTosMask();
- if (tosMask != null) {
- gateTosMask = tosMask.getValue().byteValue();
- } else {
- gateTosMask = (byte) 0xff;
- }
+ TosByte tosMask = qosGateSpec.getDscpTosMask();
+ if (tosMask != null) {
+ gateTosMask = tosMask.getValue().byteValue();
} else {
- // TODO - These values appear to be required
- dscptos = 0;
- gateTosMask = 0;
+ gateTosMask = (byte) 0xff;
}
- gateSpec = new org.pcmm.gates.impl.GateSpec(gateDir, dscptos, gateTosMask);
- }
+
+ java.lang.Short scid = qosGateSpec.getSessionClassId();
+ byte bscid = 0;
+ if (scid != null) {
+ bscid = (byte)(qosGateSpec.getSessionClassId() & 0x00ff);
+ }
+
+ java.lang.Long inactivity = qosGateSpec.getInactivityTimer();
+ short sinactivity = 300;
+ if (inactivity != null) {
+ sinactivity = inactivity.shortValue();
+ }
+
+ gateSpec = new org.pcmm.gates.impl.GateSpec(gateDir, dscptos, gateTosMask,
+ new SessionClassID(bscid),
+ (short)1,(short)300,sinactivity,(short)0);
+ }
public void setTrafficProfile(final TrafficProfile qosTrafficProfile) {
- if (qosTrafficProfile.getServiceClassName() != null) {
- trafficProfile =
- new DOCSISServiceClassNameTrafficProfile(qosTrafficProfile.getServiceClassName().getValue());
+ TrafficProfileChoice choice = qosTrafficProfile.getTrafficProfileChoice();
+
+ if (choice instanceof ServiceClassNameChoice) {
+ ServiceClassNameProfile scnp = ((ServiceClassNameChoice)choice).getServiceClassNameProfile();
+ trafficProfile = new DOCSISServiceClassNameTrafficProfile(scnp.getServiceClassName().getValue());
+ }
+ else if (choice instanceof FlowSpecChoice) {
+ FlowSpecProfile fsp = ((FlowSpecChoice)choice).getFlowSpecProfile();
+ trafficProfile = new DOCSISFlowSpecTrafficProfile(fsp.getTokenBucketRate(),
+ fsp.getTokenBucketSize(),
+ fsp.getPeakDataRate(),
+ fsp.getMinimumPolicedUnit(),
+ fsp.getMaximumPacketSize(),
+ fsp.getRate(),
+ fsp.getSlackTerm());
+ }
+ else if (choice instanceof UgsChoice) {
+ UgsProfile ugsp = ((UgsChoice)choice).getUgsProfile();
+ trafficProfile = new DOCSISUGSTrafficProfile(ugsp.getRequestTransmissionPolicy(),
+ ugsp.getUnsolicitedGrantSize(),
+ ugsp.getGrantsPerInterval(),
+ ugsp.getNominalGrantInterval(),
+ ugsp.getToleratedGrantJitter(),
+ ugsp.getUpstreamPeakTrafficRate(),
+ ugsp.getRequiredAttributeMask(),
+ ugsp.getForbiddenAttributeMask(),
+ ugsp.getAttributeAggregationRuleMask());
+ }
+ else if (choice instanceof RtpChoice) {
+ RtpProfile rtpp = ((RtpChoice)choice).getRtpProfile();
+ trafficProfile = new DOCSISRTPTrafficProfile(rtpp.getRequestTransmissionPolicy(),
+ rtpp.getMaximumSustainedTrafficRate(),
+ rtpp.getMaximumTrafficBurst(),
+ rtpp.getMinimumReservedTrafficRate(),
+ rtpp.getAmrtrPacketSize().longValue(),
+ rtpp.getMaximumConcatenatedBurst().longValue(),
+ rtpp.getNominalPollingInterval(),
+ rtpp.getToleratedPollJitter(),
+ rtpp.getUpstreamPeakTrafficRate(),
+ rtpp.getRequiredAttributeMask(),
+ rtpp.getForbiddenAttributeMask(),
+ rtpp.getAttributeAggregationRuleMask());
+ }
+ else {
+ logger.debug("PCMMGateReq().setTrafficProfile() Unsupported Traffic Profile: " + choice.getClass().getName());
}
}
byte tosMask = (byte)0x0;
short srcPort = (short) 0;
short dstPort = (short) 0;
- //byte priority = (byte) 64;
- byte priority = (byte) (64+index);
// Legacy classifier
tosMask = (byte) 0xff;
}
}
+ //
+ // The packetcable.yang models priority as an uint8 which means the java generated
+ // implementation saves the value in a short, so we mask it back into a byte
+ //
+ byte priority = 64;
+ if (qosClassifier.getPriority() != null) {
+ short result = qosClassifier.getPriority();
+ priority = (byte)(result % 255);
+ }
+
// push the classifier to the gate request
classifiers.add(new org.pcmm.gates.impl.Classifier(protocol, tosOverwrite, tosMask, srcAddress, dstAddress, srcPort,
dstPort, priority));
private void addExtClassifier(final Short index, final ExtClassifier qosExtClassifier) {
// Extended classifier
- final byte priority = (byte) (index+64);
- final ActivationState activationState = ActivationState.ACTIVE;
// Protocol -- zero is match any
final Protocol protocol;
if (qosExtClassifier.getProtocol() != null) {
// TODO - find out what the action value should really be. It was never getting set previously
final IExtendedClassifier.Action action = IExtendedClassifier.Action.ADD;
+ //
+ // Convert from Enum to byte for serialization
+ //
+ ActivationState activationState = ActivationState.ACTIVE;
+ if (qosExtClassifier.getActivationState() != null) {
+ activationState = ActivationState.valueOf((byte)qosExtClassifier.getActivationState().getIntValue());
+ }
+
+ //
+ // The packetcable.yang models priority as an uint8 which means the java generated
+ // implementation saves the value in a short, so we mask it back into a byte
+ //
+ byte priority = 64;
+ if (qosExtClassifier.getPriority() != null) {
+ short result = qosExtClassifier.getPriority();
+ priority = (byte)(result % 255);
+ }
+
// push the extended classifier to the gate request
classifiers.add(new org.pcmm.gates.impl.ExtendedClassifier(protocol, tosOverwrite, tosMask,
srcIpAddr, dstIpAddr,
// TODO - find out what the action value should really be. It was never getting set previously
final IExtendedClassifier.Action action = IExtendedClassifier.Action.ADD;
+ //
+ // Convert from Enum to byte for serialization
+ //
+ ActivationState activationState = ActivationState.ACTIVE;
+ if (qosIpv6Classifier.getActivationState() != null) {
+ activationState = ActivationState.valueOf((byte)qosIpv6Classifier.getActivationState().getIntValue());
+ }
+
+ //
+ // The packetcable.yang models priority as an uint8 which means the java generated
+ // implementation saves the value in a short, so we mask it back into a byte
+ //
+ byte priority = 64;
+ if (qosIpv6Classifier.getPriority() != null) {
+ short result = qosIpv6Classifier.getPriority();
+ priority = (byte)(result % 255);
+ }
+
// push the IPv6 classifier to the gate request
classifiers.add(
- new org.pcmm.gates.impl.IPv6Classifier(srcAddress, dstAddress, srcPortBegin, dstPortBegin, (byte) (index+64),
- srcPortEnd, dstPortEnd, classifierId, ActivationState.ACTIVE, action, flowLabelFlag, tcLow,
+ new org.pcmm.gates.impl.IPv6Classifier(srcAddress, dstAddress, srcPortBegin, dstPortBegin, priority,
+ srcPortEnd, dstPortEnd, classifierId, activationState, action, flowLabelFlag, tcLow,
tcHigh, tcMask, flowLabelId, nextHdr, srcPrefixLen, dstPrefLen));
}
}