import org.pcmm.gates.impl.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.umu.cops.COPSMsgSender;
import org.umu.cops.prpdp.COPSPdpException;
import org.umu.cops.stack.*;
+import org.umu.cops.stack.COPSClientSI.CSIType;
+import org.umu.cops.stack.COPSContext.RType;
+import org.umu.cops.stack.COPSDecision.Command;
+import org.umu.cops.stack.COPSDecision.DecisionFlag;
+import org.umu.cops.stack.COPSHeader.OPCode;
import org.umu.cops.stack.COPSObjHeader.CNum;
import org.umu.cops.stack.COPSObjHeader.CType;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
-//temp
-//pcmm
/*
* Example of an UNSOLICITED decision
*
/**
* COPS message transceiver class for provisioning connections at the PDP side.
*/
-public class PCMMPdpMsgSender {
+public class PCMMPdpMsgSender extends COPSMsgSender {
public final static Logger logger = LoggerFactory.getLogger(PCMMPdpMsgSender.class);
- /**
- * 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;
+ protected final short _classifierID;
+
// XXX - this does not need to be here
- protected int _gateID;
+ protected IGateID _gateID;
/**
* Creates a PCMMPdpMsgSender
* @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(final short clientType, final COPSHandle clientHandle, final Socket sock) {
+ this(clientType, (short)0, clientHandle, sock);
}
- public PCMMPdpMsgSender(short clientType, short tID,
- COPSHandle clientHandle, Socket sock) {
- // COPS Handle
- _handle = clientHandle;
- _clientType = clientType;
+ public PCMMPdpMsgSender(final short clientType, final short tID, final COPSHandle clientHandle,
+ final Socket sock) {
+ super(clientType, clientHandle, sock);
_transactionID = tID;
_classifierID = 0;
- _sock = sock;
- }
-
- /**
- * Gets the client handle
- *
- * @return Client's <tt>COPSHandle</tt>
- */
- public COPSHandle getClientHandle() {
- return _handle;
- }
-
- /**
- * Gets the client-type
- *
- * @return Client-type value
- */
- public short getClientType() {
- return _clientType;
}
/**
return _transactionID;
}
+ /**
+ * Gets the gate-id
+ *
+ * @return the gate-id value
+ */
+ public IGateID getGateID() {
+ return _gateID;
+ }
/**
* Sends a PCMM GateSet COPS Decision message
- *
- * @param
+ * @param gate - the gate
* @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
- final COPSHandle handle = new COPSHandle(getClientHandle().getId());
- COPSDecisionMsg decisionMsg = new COPSDecisionMsg();
- ITransactionID trID = new TransactionID();
+ public void sendGateSet(final IPCMMGate gate) throws COPSPdpException {
+ final ITransactionID trID = new TransactionID();
// set transaction ID to gate set
trID.setGateCommandType(ITransactionID.GateSet);
trID.setTransactionIdentifier(_transactionID);
gate.setTransactionID(trID);
-
+ // retain the transactionId to gate request mapping for gateID recovery after response
+ // see PCMMPdpReqStateMan.processReport()
+ final Short trIDnum = trID.getTransactionIdentifier();
+ logger.info("Adding gate to cache - " + gate + " with key - " + trIDnum);
+ PCMMGlobalConfig.transactionGateMap.put(trIDnum, gate);
// new pcmm specific clientsi
- COPSClientSI clientSD = new COPSClientSI((byte)CNum.DEC.ordinal(), (byte)CType.CSI.ordinal());
- byte[] data = gate.getData();
- clientSD.setData(new COPSData(data, 0, data.length));
- try {
- decisionMsg.add(hdr);
- decisionMsg.add(handle);
- // Decisions (no flags supplied)
- // <Context>
- 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) {
- logger.error("Error making Msg", e);
- }
+ final byte[] data = gate.getData();
+ // Common Header with the same ClientType as the request
+ // Client Handle with the same clientHandle as the request
+
+ final Set<COPSDecision> decisionSet = new HashSet<>();
+ decisionSet.add(new COPSDecision(CType.DEF, Command.INSTALL, DecisionFlag.REQERROR));
+ final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
+ decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
+
+ final COPSClientSI clientSD = new COPSClientSI(CNum.DEC, CType.CSI, new COPSData(data, 0, data.length));
+ final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, clientSD);
// ** Send the GateSet Decision
- // **
try {
decisionMsg.writeData(_sock);
} catch (IOException e) {
- logger.error("Failed to send the decision, reason: ", e);
+ logger.error("Failed to send the decision", e);
}
}
/**
* Sends a PCMM GateSet COPS Decision message
*
- * @param
+ * @param num - the number
* @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
- 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();
+ public void sendGateSetDemo(int num) throws COPSPdpException {
+ final IPCMMGate gate = new PCMMGateReq();
+ final ITransactionID trID = new TransactionID();
+ final IAMID amid = new AMID();
+ final ISubscriberID subscriberID = new SubscriberID();
+ final IGateSpec gateSpec = new GateSpec();
+ final IClassifier classifier = new Classifier();
+ final IExtendedClassifier eclassifier = new ExtendedClassifier();
final int trafficRate;
-
if (num == 1)
trafficRate = PCMMGlobalConfig.DefaultBestEffortTrafficRate;
else
trafficRate = PCMMGlobalConfig.DefaultLowBestEffortTrafficRate;
- ITrafficProfile trafficProfile = new BestEffortService(
+ final ITrafficProfile trafficProfile = new BestEffortService(
(byte) 7); //BestEffortService.DEFAULT_ENVELOP);
((BestEffortService) trafficProfile).getAuthorizedEnvelop()
.setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
- // new pcmm specific clientsi
- COPSClientSI clientSD = new COPSClientSI((byte)CNum.DEC.ordinal(), (byte)CType.CSI.ordinal());
-
- final COPSHandle handle = new COPSHandle(getClientHandle().getId());
-
// set transaction ID to gate set
trID.setGateCommandType(ITransactionID.GateSet);
_transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
// XXX - if the version major is less than 4 we need to use Classifier
+ // TODO - Use some variable here or remove...
if (true) {
//eclassifier.setProtocol(IClassifier.Protocol.NONE);
- eclassifier.setProtocol(IClassifier.Protocol.TCP);
+// eclassifier.setProtocol(IClassifier.Protocol.TCP);
try {
InetAddress subIP = InetAddress
.getByName(PCMMGlobalConfig.SubscriberID);
eclassifier.setPriority((byte) 65);
} else {
- classifier.setProtocol(IClassifier.Protocol.TCP);
+// classifier.setProtocol(IClassifier.Protocol.TCP);
try {
InetAddress subIP = InetAddress
.getByName(PCMMGlobalConfig.SubscriberID);
gate.setTrafficProfile(trafficProfile);
gate.setClassifier(eclassifier);
- byte[] data = gate.getData();
+ final 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)
- // <Context>
- 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) {
- logger.error("Error making Msg", e);
- }
+ final Set<COPSDecision> decisionSet = new HashSet<>();
+ decisionSet.add(new COPSDecision(CType.NA, Command.INSTALL, DecisionFlag.REQERROR));
+ final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
+ decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
+ final COPSClientSI clientSD = new COPSClientSI(CSIType.NAMED, new COPSData(data, 0, data.length));
+
+ // Common Header with the same ClientType as the request
+ // Client Handle with the same clientHandle as the request
+ final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
// ** Send the GateSet Decision
// **
try {
decisionMsg.writeData(_sock);
} catch (IOException e) {
- logger.error("Failed to send the decision, reason: ", e);
+ logger.error("Failed to send the decision", e);
}
}
/**
* 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());
-
- 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();
+ public void sendGateSetBestEffortWithExtendedClassifier() throws COPSPdpException {
+ final IPCMMGate gate = new PCMMGateReq();
+ final ITransactionID trID = new TransactionID();
+ final IAMID amid = new AMID();
+ final ISubscriberID subscriberID = new SubscriberID();
+ final IGateSpec gateSpec = new GateSpec();
+ final IClassifier classifier = new Classifier();
+ final IExtendedClassifier eclassifier = new ExtendedClassifier();
// XXX check if other values should be provided
//
- ITrafficProfile trafficProfile = new BestEffortService(
+ final ITrafficProfile trafficProfile = new BestEffortService(
(byte) 7); //BestEffortService.DEFAULT_ENVELOP);
((BestEffortService) trafficProfile).getAuthorizedEnvelop()
.setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
- // new pcmm specific clientsi
- COPSClientSI clientSD = new COPSClientSI((byte)CNum.DEC.ordinal(), (byte)CType.CSI.ordinal());
-
- // Client Handle with the same clientHandle as the request
- final COPSHandle handle = new COPSHandle(getClientHandle().getId());
-
// set transaction ID to gate set
trID.setGateCommandType(ITransactionID.GateSet);
_transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
// 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);
+// eclassifier.setProtocol(IClassifier.Protocol.TCP);
try {
InetAddress subIP = InetAddress
.getByName(PCMMGlobalConfig.SubscriberID);
eclassifier.setPriority((byte) 65);
} else {
- classifier.setProtocol(IClassifier.Protocol.TCP);
+// classifier.setProtocol(IClassifier.Protocol.TCP);
try {
InetAddress subIP = InetAddress
.getByName(PCMMGlobalConfig.SubscriberID);
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)
- // <Context>
- 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) {
- logger.error("Error making Msg", e);
- }
+ final Set<COPSDecision> decisionSet = new HashSet<>();
+ decisionSet.add(new COPSDecision(CType.CSI, Command.INSTALL, DecisionFlag.REQERROR));
+ final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
+ decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
+ final COPSClientSI clientSD = new COPSClientSI(CSIType.NAMED, new COPSData(data, 0, data.length));
+
+ // Common Header with the same ClientType as the request
+ // Client Handle with the same clientHandle as the request
+ final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, clientSD);
// ** Send the GateSet Decision
// **
}
- public boolean handleGateReport(Socket socket) throws COPSPdpException {
+ public boolean handleGateReport(final Socket socket) throws COPSPdpException {
try {
// waits for the gate-set-ack or error
- COPSMsg responseMsg = COPSTransceiver.receiveMsg(socket);
- if (responseMsg.getHeader().isAReport()) {
+ final COPSMsg responseMsg = COPSTransceiver.receiveMsg(socket);
+ if (responseMsg.getHeader().getOpCode().equals(OPCode.RPT)) {
logger.info("processing received report from CMTS");
- COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
- if (reportMsg.getClientSI().size() == 0) {
+ final COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
+ if (reportMsg.getClientSI() == null) {
return false;
}
- COPSClientSI clientSI = (COPSClientSI) reportMsg.getClientSI()
- .elementAt(0);
- IPCMMGate responseGate = new PCMMGateReq(clientSI.getData()
- .getData());
+ final IPCMMGate responseGate = new PCMMGateReq(reportMsg.getClientSI().getData().getData());
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();
+ _gateID = responseGate.getGateID();
return true;
} else {
return false;
}
return false;
} catch (Exception e) { // COPSException, IOException
- throw new COPSPdpException("Error COPSTransceiver.receiveMsg");
+ throw new COPSPdpException("Error COPSTransceiver.receiveMsg", e);
}
}
/**
* 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());
-
- COPSDecisionMsg decisionMsg = new COPSDecisionMsg();
+ final IPCMMGate gate = new PCMMGateReq();
+ final ITransactionID trID = new TransactionID();
- IPCMMGate gate = new PCMMGateReq();
- ITransactionID trID = new TransactionID();
-
- IAMID amid = new AMID();
- ISubscriberID subscriberID = new SubscriberID();
- IGateSpec gateSpec = new GateSpec();
- IClassifier classifier = new Classifier();
+ final IAMID amid = new AMID();
+ final ISubscriberID subscriberID = new SubscriberID();
+ final IGateSpec gateSpec = new GateSpec();
+ final IClassifier classifier = new Classifier();
// XXX check if other values should be provided
- ITrafficProfile trafficProfile = new BestEffortService(
+ final ITrafficProfile trafficProfile = new BestEffortService(
BestEffortService.DEFAULT_ENVELOP);
((BestEffortService) trafficProfile).getAuthorizedEnvelop()
.setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
.setRequestTransmissionPolicy(
PCMMGlobalConfig.BETransmissionPolicy);
- // new pcmm specific clientsi
- COPSClientSI clientSD = new COPSClientSI((byte)CNum.DEC.ordinal(), (byte)CType.CSI.ordinal());
-
- // Client Handle with the same clientHandle as the request
- final COPSHandle handle = new COPSHandle(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 = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
* .setServiceClassName("S_up");
*/
- classifier.setProtocol(IClassifier.Protocol.TCP);
+// classifier.setProtocol(IClassifier.Protocol.TCP);
try {
InetAddress subIP = InetAddress.getByName(PCMMGlobalConfig.SubscriberID);
InetAddress srcIP = InetAddress.getByName(PCMMGlobalConfig.srcIP);
gate.setTrafficProfile(trafficProfile);
gate.setClassifier(classifier);
- byte[] data = gate.getData();
+ final byte[] data = gate.getData();
- // new pcmm specific clientsi
- clientSD.setData(new COPSData(data, 0, data.length));
+ final Set<COPSDecision> decisionSet = new HashSet<>();
+ decisionSet.add(new COPSDecision(CType.CSI, Command.INSTALL, DecisionFlag.REQERROR));
+ final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
+ decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
- try {
- decisionMsg.add(hdr);
- decisionMsg.add(handle);
- // Decisions (no flags supplied)
- // <Context>
- 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) {
- logger.error("Error making Msg", e);
- }
+ final COPSClientSI clientSD = new COPSClientSI(CSIType.NAMED, new COPSData(data, 0, data.length));
+
+ // Client Handle with the same clientHandle as the request
+ final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
// ** Send the GateSet Decision
// **
} catch (IOException e) {
logger.error("Failed to send the decision", e);
}
-
}
/**
*
* @throws COPSPdpException
*/
- public void sendGateDelete(int gID) throws COPSPdpException {
- /*
- * Example of an UNSOLICITED decision <Gate Control Command> = <COPS
- * Common Header> <Client Handle> <Context> <Decision Flags> <ClientSI
- * Data> <ClientSI Data> = <Gate-Set> | <Gate-Info> | <Gate-Delete> |
- * <PDP-Config> | <Synch-Request> | <Msg-Receipt> <Gate-Delete> =
- * <Decision Header> <TransactionID> <AMID> <SubscriberID> <GateID>
- */
- // 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
- COPSDecisionMsg decisionMsg = new COPSDecisionMsg();
-
- IPCMMGate gate = new PCMMGateReq();
- ITransactionID trID = new TransactionID();
-
- IAMID amid = new AMID();
- ISubscriberID subscriberID = new SubscriberID();
- IGateID gateID = new GateID();
-
- // new pcmm specific clientsi
- COPSClientSI clientSD = new COPSClientSI((byte)CNum.DEC.ordinal(), (byte)CType.CSI.ordinal());
-
- final COPSHandle handle = new COPSHandle(getClientHandle().getId());
-
+ public void sendGateDelete(final IPCMMGate gate) throws COPSPdpException {
// set transaction ID to gate set
+ final ITransactionID trID = new TransactionID();
trID.setGateCommandType(ITransactionID.GateDelete);
_transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
trID.setTransactionIdentifier(_transactionID);
+ gate.setTransactionID(trID);
- amid.setApplicationType((short) 1);
- amid.setApplicationMgrTag((short) 1);
- gateID.setGateID(gID);
-
- try {
- InetAddress subIP = InetAddress.getByName(PCMMGlobalConfig.SubscriberID);
- subscriberID.setSourceIPAddress(subIP);
- } catch (UnknownHostException unae) {
- logger.error("Error getByName", unae);
- }
+ Short trIDnum = trID.getTransactionIdentifier();
+ PCMMGlobalConfig.transactionGateMap.put(trIDnum, gate);
- gate.setTransactionID(trID);
- gate.setAMID(amid);
- gate.setSubscriberID(subscriberID);
- gate.setGateID(gateID);
+ // gateDelete only requires AMID, subscriberID, and gateID
+ // remove the gateSpec, traffic profile, and classifiers from original gate request
+ gate.setGateSpec(null);
+ gate.setTrafficProfile(null);
+ gate.setClassifier(null);
+ // clear the error object
+ gate.setError(null);
// XXX - GateID
- byte[] data = gate.getData();
+ final byte[] data = gate.getData();
+ final Set<COPSDecision> decisionSet = new HashSet<>();
+ decisionSet.add(new COPSDecision(CType.DEF, Command.INSTALL, DecisionFlag.REQERROR));
+ final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
+ decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
+ final COPSClientSI clientSD = new COPSClientSI(CNum.DEC, CType.CSI, new COPSData(data, 0, data.length));
- // new pcmm specific clientsi
- clientSD.setData(new COPSData(data, 0, data.length));
-
- try {
- decisionMsg.add(hdr);
- decisionMsg.add(handle);
- // Decisions (no flags supplied)
- // <Context>
- 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) {
- logger.error("Error making Msg", e);
- }
+ final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
// ** Send the GateDelete Decision
// **
* <Decision: Flags> <Decision: Flags> ::= 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
- final COPSHandle clienthandle = new COPSHandle(_handle.getId());
+ final Set<COPSDecision> decisionSet = new HashSet<>();
+ decisionSet.add(new COPSDecision(Command.INSTALL, DecisionFlag.REQSTATE));
+ final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
+ decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
- // Decisions
- // <Context>
- COPSContext cntxt = new COPSContext(COPSContext.CONFIG, (short) 0);
- // <Decision: Flags>
- 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");
- }
+ final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, null);
try {
decisionMsg.writeData(_sock);
} catch (IOException e) {
- throw new COPSPdpException(
- "Failed to send the open new request state, reason: "
- + e.getMessage());
+ throw new COPSPdpException("Failed to send the open new request state", e);
}
}
/*
* <Gate-Info> ::= <Common Header> [<Client Handle>] [<Integrity>]
*/
-
- // 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
- final COPSHandle clienthandle = new COPSHandle(_handle.getId());
-
- COPSSyncStateMsg msg = new COPSSyncStateMsg();
- try {
- msg.add(hdr);
- msg.add(clienthandle);
- } catch (Exception e) {
- throw new COPSPdpException("Error making Msg");
- }
-
+ final COPSSyncStateMsg msg = new COPSSyncStateMsg(getClientType(), _handle, null);
try {
msg.writeData(_sock);
} catch (IOException e) {
- throw new COPSPdpException(
- "Failed to send the GateInfo request, reason: "
- + e.getMessage());
+ throw new COPSPdpException("Failed to send the GateInfo request", e);
}
}
* [<Integrity>]
*/
- // 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
- final COPSHandle clienthandle = new COPSHandle(_handle.getId());
-
- COPSSyncStateMsg msg = new COPSSyncStateMsg();
- try {
- msg.add(hdr);
- msg.add(clienthandle);
- } catch (Exception e) {
- throw new COPSPdpException("Error making Msg");
- }
-
+ final COPSSyncStateMsg msg = new COPSSyncStateMsg(getClientType(), _handle, null);
try {
msg.writeData(_sock);
} catch (IOException e) {
- throw new COPSPdpException(
- "Failed to send the sync state request, reason: "
- + e.getMessage());
+ throw new COPSPdpException("Failed to send the sync state request", e);
}
}
// XXX - Temp