7 import org.pcmm.gates.*;
8 import org.pcmm.gates.IGateSpec.DSCPTOS;
9 import org.pcmm.gates.IGateSpec.Direction;
10 import org.pcmm.gates.impl.*;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13 import org.umu.cops.COPSMsgSender;
14 import org.umu.cops.prpdp.COPSPdpException;
15 import org.umu.cops.stack.*;
16 import org.umu.cops.stack.COPSClientSI.CSIType;
17 import org.umu.cops.stack.COPSContext.RType;
18 import org.umu.cops.stack.COPSDecision.Command;
19 import org.umu.cops.stack.COPSDecision.DecisionFlag;
20 import org.umu.cops.stack.COPSHeader.OPCode;
21 import org.umu.cops.stack.COPSObjHeader.CNum;
22 import org.umu.cops.stack.COPSObjHeader.CType;
24 import java.io.IOException;
25 import java.net.InetAddress;
26 import java.net.Socket;
27 import java.net.UnknownHostException;
28 import java.util.HashMap;
29 import java.util.HashSet;
34 * Example of an UNSOLICITED decision
36 * <Gate Control Command> = <COPS Common Header> <Client Handle> <Context> <Decision Flags> <ClientSI Data>
38 * <ClientSI Data> = <Gate-Set> | <Gate-Info> | <Gate-Delete> |
39 * <PDP-Config> | <Synch-Request> | <Msg-Receipt>
40 * <Gate-Set> = <Decision Header> <TransactionID> <AMID> <SubscriberID> [<GateID>] <GateSpec>
41 * <Traffic Profile> <classifier> [<classifier...>] [<Event Generation Info>]
42 * [<Volume-Based Usage Limit>] [<Time-Based Usage Limit>][<Opaque Data>] [<UserID>]
46 * COPS message transceiver class for provisioning connections at the PDP side.
48 public class PCMMPdpMsgSender extends COPSMsgSender {
50 public final static Logger logger = LoggerFactory.getLogger(PCMMPdpMsgSender.class);
52 protected short _transactionID;
53 protected final short _classifierID;
55 // XXX - this does not need to be here
56 protected IGateID _gateID;
59 * Creates a PCMMPdpMsgSender
68 public PCMMPdpMsgSender(final short clientType, final COPSHandle clientHandle, final Socket sock) {
69 this(clientType, (short)0, clientHandle, sock);
72 public PCMMPdpMsgSender(final short clientType, final short tID, final COPSHandle clientHandle,
74 super(clientType, clientHandle, sock);
80 * Gets the transaction-id
82 * @return transaction-id value
84 public short getTransactionID() {
85 return _transactionID;
91 * @return the gate-id value
93 public IGateID getGateID() {
98 * Sends a PCMM GateSet COPS Decision message
99 * @param gate - the gate
100 * @throws COPSPdpException
102 public void sendGateSet(final IPCMMGate gate) throws COPSPdpException {
103 final ITransactionID trID = new TransactionID();
105 // set transaction ID to gate set
106 trID.setGateCommandType(ITransactionID.GateSet);
107 _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
108 trID.setTransactionIdentifier(_transactionID);
110 gate.setTransactionID(trID);
111 // retain the transactionId to gate request mapping for gateID recovery after response
112 // see PCMMPdpReqStateMan.processReport()
113 final Short trIDnum = trID.getTransactionIdentifier();
114 logger.info("Adding gate to cache - " + gate + " with key - " + trIDnum);
115 PCMMGlobalConfig.transactionGateMap.put(trIDnum, gate);
117 // new pcmm specific clientsi
118 final byte[] data = gate.getData();
119 // Common Header with the same ClientType as the request
120 // Client Handle with the same clientHandle as the request
122 final Set<COPSDecision> decisionSet = new HashSet<>();
123 decisionSet.add(new COPSDecision(CType.DEF, Command.INSTALL, DecisionFlag.REQERROR));
124 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
125 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
127 final COPSClientSI clientSD = new COPSClientSI(CNum.DEC, CType.CSI, new COPSData(data, 0, data.length));
128 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, clientSD);
130 // ** Send the GateSet Decision
132 decisionMsg.writeData(_sock);
133 } catch (IOException e) {
134 logger.error("Failed to send the decision", e);
140 * Sends a PCMM GateSet COPS Decision message
142 * @param num - the number
143 * @throws COPSPdpException
145 public void sendGateSetDemo(int num) throws COPSPdpException {
146 final IPCMMGate gate = new PCMMGateReq();
147 final ITransactionID trID = new TransactionID();
148 final IAMID amid = new AMID();
149 final ISubscriberID subscriberID = new SubscriberID();
150 final IGateSpec gateSpec = new GateSpec();
151 final IClassifier classifier = new Classifier();
152 final IExtendedClassifier eclassifier = new ExtendedClassifier();
153 final int trafficRate;
155 trafficRate = PCMMGlobalConfig.DefaultBestEffortTrafficRate;
157 trafficRate = PCMMGlobalConfig.DefaultLowBestEffortTrafficRate;
159 final ITrafficProfile trafficProfile = new BestEffortService(
160 (byte) 7); //BestEffortService.DEFAULT_ENVELOP);
161 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
162 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
163 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
164 .setMaximumTrafficBurst(
165 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
166 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
167 .setRequestTransmissionPolicy(
168 PCMMGlobalConfig.BETransmissionPolicy);
169 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
170 .setMaximumSustainedTrafficRate(
172 // PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
173 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
175 ((BestEffortService) trafficProfile).getReservedEnvelop()
176 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
177 ((BestEffortService) trafficProfile).getReservedEnvelop()
178 .setMaximumTrafficBurst(
179 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
180 ((BestEffortService) trafficProfile).getReservedEnvelop()
181 .setRequestTransmissionPolicy(
182 PCMMGlobalConfig.BETransmissionPolicy);
183 ((BestEffortService) trafficProfile).getReservedEnvelop()
184 .setMaximumSustainedTrafficRate(
186 // PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
187 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
190 ((BestEffortService) trafficProfile).getCommittedEnvelop()
191 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
192 ((BestEffortService) trafficProfile).getCommittedEnvelop()
193 .setMaximumTrafficBurst(
194 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
195 ((BestEffortService) trafficProfile).getCommittedEnvelop()
196 .setRequestTransmissionPolicy(
197 PCMMGlobalConfig.BETransmissionPolicy);
198 ((BestEffortService) trafficProfile).getCommittedEnvelop()
199 .setMaximumSustainedTrafficRate(
201 // PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
202 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
206 // set transaction ID to gate set
207 trID.setGateCommandType(ITransactionID.GateSet);
208 _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
209 trID.setTransactionIdentifier(_transactionID);
211 amid.setApplicationType((short) 1);
212 amid.setApplicationMgrTag((short) 1);
213 gateSpec.setDirection(Direction.UPSTREAM);
214 gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
215 gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
216 gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
217 gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
218 gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
220 // XXX - if the version major is less than 4 we need to use Classifier
221 // TODO - Use some variable here or remove...
223 //eclassifier.setProtocol(IClassifier.Protocol.NONE);
224 // eclassifier.setProtocol(IClassifier.Protocol.TCP);
226 InetAddress subIP = InetAddress
227 .getByName(PCMMGlobalConfig.SubscriberID);
228 InetAddress srcIP = InetAddress
229 .getByName(PCMMGlobalConfig.srcIP);
230 InetAddress dstIP = InetAddress
231 .getByName(PCMMGlobalConfig.dstIP);
232 InetAddress mask = InetAddress.getByName("0.0.0.0");
233 subscriberID.setSourceIPAddress(subIP);
234 eclassifier.setSourceIPAddress(srcIP);
235 eclassifier.setDestinationIPAddress(dstIP);
236 eclassifier.setIPDestinationMask(mask);
237 eclassifier.setIPSourceMask(mask);
238 } catch (UnknownHostException unae) {
239 logger.error("Error getByName", unae);
241 eclassifier.setSourcePortStart(PCMMGlobalConfig.srcPort);
242 eclassifier.setSourcePortEnd(PCMMGlobalConfig.srcPort);
243 eclassifier.setDestinationPortStart(PCMMGlobalConfig.dstPort);
244 eclassifier.setDestinationPortEnd(PCMMGlobalConfig.dstPort);
245 eclassifier.setActivationState((byte) 0x01);
246 // check if we have a stored value of classifierID else we just
249 // eclassifier.setClassifierID((short) 0x01);
250 eclassifier.setClassifierID((short) (_classifierID == 0 ? Math
251 .random() * hashCode() : _classifierID));
253 // eclassifier.setClassifierID((short) 1);
255 eclassifier.setAction((byte) 0x00);
256 // XXX - temp default until Gate Modify is hacked in
257 // eclassifier.setPriority(PCMMGlobalConfig.EClassifierPriority);
258 eclassifier.setPriority((byte) 65);
261 // classifier.setProtocol(IClassifier.Protocol.TCP);
263 InetAddress subIP = InetAddress
264 .getByName(PCMMGlobalConfig.SubscriberID);
265 InetAddress srcIP = InetAddress
266 .getByName(PCMMGlobalConfig.srcIP);
267 InetAddress dstIP = InetAddress
268 .getByName(PCMMGlobalConfig.dstIP);
269 subscriberID.setSourceIPAddress(subIP);
270 classifier.setSourceIPAddress(srcIP);
271 classifier.setDestinationIPAddress(dstIP);
272 } catch (UnknownHostException unae) {
273 logger.error("Error getByName", unae);
275 classifier.setSourcePort(PCMMGlobalConfig.srcPort);
276 classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
279 gate.setTransactionID(trID);
281 gate.setSubscriberID(subscriberID);
282 gate.setGateSpec(gateSpec);
283 gate.setTrafficProfile(trafficProfile);
284 gate.setClassifier(eclassifier);
286 final byte[] data = gate.getData();
288 final Set<COPSDecision> decisionSet = new HashSet<>();
289 decisionSet.add(new COPSDecision(CType.NA, Command.INSTALL, DecisionFlag.REQERROR));
290 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
291 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
292 final COPSClientSI clientSD = new COPSClientSI(CSIType.NAMED, new COPSData(data, 0, data.length));
294 // Common Header with the same ClientType as the request
295 // Client Handle with the same clientHandle as the request
296 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
298 // ** Send the GateSet Decision
301 decisionMsg.writeData(_sock);
302 } catch (IOException e) {
303 logger.error("Failed to send the decision", e);
308 * Sends a PCMM GateSet COPS Decision message
309 * @throws COPSPdpException
311 public void sendGateSetBestEffortWithExtendedClassifier() throws COPSPdpException {
312 final IPCMMGate gate = new PCMMGateReq();
313 final ITransactionID trID = new TransactionID();
314 final IAMID amid = new AMID();
315 final ISubscriberID subscriberID = new SubscriberID();
316 final IGateSpec gateSpec = new GateSpec();
317 final IClassifier classifier = new Classifier();
318 final IExtendedClassifier eclassifier = new ExtendedClassifier();
320 // XXX check if other values should be provided
322 final ITrafficProfile trafficProfile = new BestEffortService(
323 (byte) 7); //BestEffortService.DEFAULT_ENVELOP);
324 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
325 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
326 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
327 .setMaximumTrafficBurst(
328 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
329 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
330 .setRequestTransmissionPolicy(
331 PCMMGlobalConfig.BETransmissionPolicy);
332 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
333 .setMaximumSustainedTrafficRate(
334 PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
335 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
337 ((BestEffortService) trafficProfile).getReservedEnvelop()
338 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
339 ((BestEffortService) trafficProfile).getReservedEnvelop()
340 .setMaximumTrafficBurst(
341 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
342 ((BestEffortService) trafficProfile).getReservedEnvelop()
343 .setRequestTransmissionPolicy(
344 PCMMGlobalConfig.BETransmissionPolicy);
345 ((BestEffortService) trafficProfile).getReservedEnvelop()
346 .setMaximumSustainedTrafficRate(
347 PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
348 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
351 ((BestEffortService) trafficProfile).getCommittedEnvelop()
352 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
353 ((BestEffortService) trafficProfile).getCommittedEnvelop()
354 .setMaximumTrafficBurst(
355 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
356 ((BestEffortService) trafficProfile).getCommittedEnvelop()
357 .setRequestTransmissionPolicy(
358 PCMMGlobalConfig.BETransmissionPolicy);
359 ((BestEffortService) trafficProfile).getCommittedEnvelop()
360 .setMaximumSustainedTrafficRate(
361 PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
362 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
366 // set transaction ID to gate set
367 trID.setGateCommandType(ITransactionID.GateSet);
368 _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
369 trID.setTransactionIdentifier(_transactionID);
371 amid.setApplicationType((short) 1);
372 amid.setApplicationMgrTag((short) 1);
373 gateSpec.setDirection(Direction.UPSTREAM);
374 gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
375 gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
376 gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
377 gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
378 gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
380 // XXX - if the version major is less than 4 we need to use Classifier
382 //eclassifier.setProtocol(IClassifier.Protocol.NONE);
383 // eclassifier.setProtocol(IClassifier.Protocol.TCP);
385 InetAddress subIP = InetAddress
386 .getByName(PCMMGlobalConfig.SubscriberID);
387 InetAddress srcIP = InetAddress
388 .getByName(PCMMGlobalConfig.srcIP);
389 InetAddress dstIP = InetAddress
390 .getByName(PCMMGlobalConfig.dstIP);
391 InetAddress mask = InetAddress.getByName("0.0.0.0");
392 subscriberID.setSourceIPAddress(subIP);
393 eclassifier.setSourceIPAddress(srcIP);
394 eclassifier.setDestinationIPAddress(dstIP);
395 eclassifier.setIPDestinationMask(mask);
396 eclassifier.setIPSourceMask(mask);
397 } catch (UnknownHostException unae) {
398 logger.error("Error getByName", unae);
400 eclassifier.setSourcePortStart(PCMMGlobalConfig.srcPort);
401 eclassifier.setSourcePortEnd(PCMMGlobalConfig.srcPort);
402 eclassifier.setDestinationPortStart(PCMMGlobalConfig.dstPort);
403 eclassifier.setDestinationPortEnd(PCMMGlobalConfig.dstPort);
404 eclassifier.setActivationState((byte) 0x01);
405 // check if we have a stored value of classifierID else we just
408 // eclassifier.setClassifierID((short) 0x01);
409 eclassifier.setClassifierID((short) (_classifierID == 0 ? Math
410 .random() * hashCode() : _classifierID));
412 // eclassifier.setClassifierID((short) 1);
414 eclassifier.setAction((byte) 0x00);
415 // XXX - temp default until Gate Modify is hacked in
416 // eclassifier.setPriority(PCMMGlobalConfig.EClassifierPriority);
417 eclassifier.setPriority((byte) 65);
420 // classifier.setProtocol(IClassifier.Protocol.TCP);
422 InetAddress subIP = InetAddress
423 .getByName(PCMMGlobalConfig.SubscriberID);
424 InetAddress srcIP = InetAddress
425 .getByName(PCMMGlobalConfig.srcIP);
426 InetAddress dstIP = InetAddress
427 .getByName(PCMMGlobalConfig.dstIP);
428 subscriberID.setSourceIPAddress(subIP);
429 classifier.setSourceIPAddress(srcIP);
430 classifier.setDestinationIPAddress(dstIP);
431 } catch (UnknownHostException unae) {
432 logger.error("Error getByName", unae);
434 classifier.setSourcePort(PCMMGlobalConfig.srcPort);
435 classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
438 gate.setTransactionID(trID);
440 gate.setSubscriberID(subscriberID);
441 gate.setGateSpec(gateSpec);
442 gate.setTrafficProfile(trafficProfile);
443 gate.setClassifier(eclassifier);
445 byte[] data = gate.getData();
447 final Set<COPSDecision> decisionSet = new HashSet<>();
448 decisionSet.add(new COPSDecision(CType.CSI, Command.INSTALL, DecisionFlag.REQERROR));
449 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
450 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
451 final COPSClientSI clientSD = new COPSClientSI(CSIType.NAMED, new COPSData(data, 0, data.length));
453 // Common Header with the same ClientType as the request
454 // Client Handle with the same clientHandle as the request
455 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, clientSD);
457 // ** Send the GateSet Decision
460 decisionMsg.writeData(_sock);
461 } catch (IOException e) {
462 logger.error("Failed to send the decision", e);
468 public boolean handleGateReport(final Socket socket) throws COPSPdpException {
470 // waits for the gate-set-ack or error
471 final COPSMsg responseMsg = COPSTransceiver.receiveMsg(socket);
472 if (responseMsg.getHeader().getOpCode().equals(OPCode.RPT)) {
473 logger.info("processing received report from CMTS");
474 final COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
475 if (reportMsg.getClientSI() == null) {
478 final IPCMMGate responseGate = new PCMMGateReq(reportMsg.getClientSI().getData().getData());
479 if (responseGate.getTransactionID() != null
480 && responseGate.getTransactionID().getGateCommandType() == ITransactionID.GateSetAck) {
481 logger.info("the CMTS has sent a Gate-Set-Ack response");
482 // here CMTS responded that he acknowledged the Gate-Set
483 // TODO do further check of Gate-Set-Ack GateID etc...
484 _gateID = responseGate.getGateID();
491 } catch (Exception e) { // COPSException, IOException
492 throw new COPSPdpException("Error COPSTransceiver.receiveMsg", e);
498 * Sends a PCMM GateSet COPS Decision message
500 * @throws COPSPdpException
502 public void sendGateSet() throws COPSPdpException {
503 // Common Header with the same ClientType as the request
505 final IPCMMGate gate = new PCMMGateReq();
506 final ITransactionID trID = new TransactionID();
508 final IAMID amid = new AMID();
509 final ISubscriberID subscriberID = new SubscriberID();
510 final IGateSpec gateSpec = new GateSpec();
511 final IClassifier classifier = new Classifier();
512 // XXX check if other values should be provided
513 final ITrafficProfile trafficProfile = new BestEffortService(
514 BestEffortService.DEFAULT_ENVELOP);
515 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
516 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
517 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
518 .setMaximumTrafficBurst(
519 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
520 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
521 .setRequestTransmissionPolicy(
522 PCMMGlobalConfig.BETransmissionPolicy);
524 // set transaction ID to gate set
525 trID.setGateCommandType(ITransactionID.GateSet);
526 _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
527 trID.setTransactionIdentifier(_transactionID);
529 amid.setApplicationType((short) 1);
530 amid.setApplicationMgrTag((short) 1);
531 gateSpec.setDirection(Direction.UPSTREAM);
532 gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
533 gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
534 gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
535 gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
536 gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
539 * ((DOCSISServiceClassNameTrafficProfile) trafficProfile)
540 * .setServiceClassName("S_up");
543 // classifier.setProtocol(IClassifier.Protocol.TCP);
545 InetAddress subIP = InetAddress.getByName(PCMMGlobalConfig.SubscriberID);
546 InetAddress srcIP = InetAddress.getByName(PCMMGlobalConfig.srcIP);
547 InetAddress dstIP = InetAddress.getByName(PCMMGlobalConfig.dstIP);
548 subscriberID.setSourceIPAddress(subIP);
549 classifier.setSourceIPAddress(srcIP);
550 classifier.setDestinationIPAddress(dstIP);
551 } catch (UnknownHostException unae) {
552 logger.error("Error getByName", unae);
554 classifier.setSourcePort(PCMMGlobalConfig.srcPort);
555 classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
557 gate.setTransactionID(trID);
559 gate.setSubscriberID(subscriberID);
560 gate.setGateSpec(gateSpec);
561 gate.setTrafficProfile(trafficProfile);
562 gate.setClassifier(classifier);
564 final byte[] data = gate.getData();
566 final Set<COPSDecision> decisionSet = new HashSet<>();
567 decisionSet.add(new COPSDecision(CType.CSI, Command.INSTALL, DecisionFlag.REQERROR));
568 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
569 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
571 final COPSClientSI clientSD = new COPSClientSI(CSIType.NAMED, new COPSData(data, 0, data.length));
573 // Client Handle with the same clientHandle as the request
574 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
576 // ** Send the GateSet Decision
579 decisionMsg.writeData(_sock);
580 } catch (IOException e) {
581 logger.error("Failed to send the decision", e);
586 * Sends a message asking that the request state be deleted
588 * @throws COPSPdpException
590 public void sendGateDelete(final IPCMMGate gate) throws COPSPdpException {
591 // set transaction ID to gate set
592 final ITransactionID trID = new TransactionID();
593 trID.setGateCommandType(ITransactionID.GateDelete);
594 _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
595 trID.setTransactionIdentifier(_transactionID);
596 gate.setTransactionID(trID);
598 Short trIDnum = trID.getTransactionIdentifier();
599 PCMMGlobalConfig.transactionGateMap.put(trIDnum, gate);
601 // gateDelete only requires AMID, subscriberID, and gateID
602 // remove the gateSpec, traffic profile, and classifiers from original gate request
603 gate.setGateSpec(null);
604 gate.setTrafficProfile(null);
605 gate.setClassifier(null);
606 // clear the error object
610 final byte[] data = gate.getData();
611 final Set<COPSDecision> decisionSet = new HashSet<>();
612 decisionSet.add(new COPSDecision(CType.DEF, Command.INSTALL, DecisionFlag.REQERROR));
613 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
614 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
615 final COPSClientSI clientSD = new COPSClientSI(CNum.DEC, CType.CSI, new COPSData(data, 0, data.length));
617 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
619 // ** Send the GateDelete Decision
622 decisionMsg.writeData(_sock);
623 // decisionMsg.writeData(socket_id);
624 } catch (IOException e) {
625 logger.error("Failed to send the decision", e);
630 * Sends a request asking that a new request state be created
632 * @throws COPSPdpException
634 public void sendOpenNewRequestState() throws COPSPdpException {
636 * <Decision Message> ::= <Common Header: Flag UNSOLICITED> <Client
637 * Handle> *(<Decision>) [<Integrity>] <Decision> ::= <Context>
638 * <Decision: Flags> <Decision: Flags> ::= Install Request-State
641 final Set<COPSDecision> decisionSet = new HashSet<>();
642 decisionSet.add(new COPSDecision(Command.INSTALL, DecisionFlag.REQSTATE));
643 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
644 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
646 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, null);
649 decisionMsg.writeData(_sock);
650 } catch (IOException e) {
651 throw new COPSPdpException("Failed to send the open new request state", e);
656 * Sends a message asking for a COPS sync operation
658 * @throws COPSPdpException
660 public void sendGateInfo() throws COPSPdpException {
662 * <Gate-Info> ::= <Common Header> [<Client Handle>] [<Integrity>]
664 final COPSSyncStateMsg msg = new COPSSyncStateMsg(getClientType(), _handle, null);
666 msg.writeData(_sock);
667 } catch (IOException e) {
668 throw new COPSPdpException("Failed to send the GateInfo request", e);
673 * Sends a message asking for a COPS sync operation
675 * @throws COPSPdpException
677 public void sendSyncRequest() throws COPSPdpException {
679 * <Synchronize State Request> ::= <Common Header> [<Client Handle>]
683 // Client Handle with the same clientHandle as the request
684 final COPSSyncStateMsg msg = new COPSSyncStateMsg(getClientType(), _handle, null);
686 msg.writeData(_sock);
687 } catch (IOException e) {
688 throw new COPSPdpException("Failed to send the sync state request", e);
692 public void sendSyncRequestState() throws COPSPdpException {
695 public void sendDeleteRequestState() throws COPSPdpException {