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 throws COPSPdpException {
70 this(clientType, (short)0, clientHandle, sock);
73 public PCMMPdpMsgSender(final short clientType, final short tID, final COPSHandle clientHandle,
74 final Socket sock) throws COPSPdpException {
75 super(clientType, clientHandle, sock);
81 * Gets the transaction-id
83 * @return transaction-id value
85 public short getTransactionID() {
86 return _transactionID;
92 * @return the gate-id value
94 public IGateID getGateID() {
99 * Sends a PCMM GateSet COPS Decision message
100 * @param gate - the gate
101 * @throws COPSPdpException
103 public void sendGateSet(final IPCMMGate gate) throws COPSPdpException {
104 final ITransactionID trID = new TransactionID();
106 // set transaction ID to gate set
107 trID.setGateCommandType(ITransactionID.GateSet);
108 _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
109 trID.setTransactionIdentifier(_transactionID);
111 gate.setTransactionID(trID);
112 // retain the transactionId to gate request mapping for gateID recovery after response
113 // see PCMMPdpReqStateMan.processReport()
114 final Short trIDnum = trID.getTransactionIdentifier();
115 logger.info("Adding gate to cache - " + gate + " with key - " + trIDnum);
116 PCMMGlobalConfig.transactionGateMap.put(trIDnum, gate);
118 // new pcmm specific clientsi
119 final byte[] data = gate.getData();
120 // Common Header with the same ClientType as the request
121 // Client Handle with the same clientHandle as the request
123 final Set<COPSDecision> decisionSet = new HashSet<>();
124 decisionSet.add(new COPSDecision(CType.DEF, Command.INSTALL, DecisionFlag.REQERROR));
125 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
126 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
128 final COPSClientSI clientSD = new COPSClientSI(CNum.DEC, CType.CSI, new COPSData(data, 0, data.length));
129 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, clientSD);
131 // ** Send the GateSet Decision
133 decisionMsg.writeData(_sock);
134 } catch (IOException e) {
135 logger.error("Failed to send the decision", e);
141 * Sends a PCMM GateSet COPS Decision message
143 * @param num - the number
144 * @throws COPSPdpException
146 public void sendGateSetDemo(int num) throws COPSPdpException {
147 final IPCMMGate gate = new PCMMGateReq();
148 final ITransactionID trID = new TransactionID();
149 final IAMID amid = new AMID();
150 final ISubscriberID subscriberID = new SubscriberID();
151 final IGateSpec gateSpec = new GateSpec();
152 final IClassifier classifier = new Classifier();
153 final IExtendedClassifier eclassifier = new ExtendedClassifier();
154 final int trafficRate;
156 trafficRate = PCMMGlobalConfig.DefaultBestEffortTrafficRate;
158 trafficRate = PCMMGlobalConfig.DefaultLowBestEffortTrafficRate;
160 final ITrafficProfile trafficProfile = new BestEffortService(
161 (byte) 7); //BestEffortService.DEFAULT_ENVELOP);
162 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
163 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
164 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
165 .setMaximumTrafficBurst(
166 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
167 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
168 .setRequestTransmissionPolicy(
169 PCMMGlobalConfig.BETransmissionPolicy);
170 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
171 .setMaximumSustainedTrafficRate(
173 // PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
174 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
176 ((BestEffortService) trafficProfile).getReservedEnvelop()
177 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
178 ((BestEffortService) trafficProfile).getReservedEnvelop()
179 .setMaximumTrafficBurst(
180 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
181 ((BestEffortService) trafficProfile).getReservedEnvelop()
182 .setRequestTransmissionPolicy(
183 PCMMGlobalConfig.BETransmissionPolicy);
184 ((BestEffortService) trafficProfile).getReservedEnvelop()
185 .setMaximumSustainedTrafficRate(
187 // PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
188 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
191 ((BestEffortService) trafficProfile).getCommittedEnvelop()
192 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
193 ((BestEffortService) trafficProfile).getCommittedEnvelop()
194 .setMaximumTrafficBurst(
195 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
196 ((BestEffortService) trafficProfile).getCommittedEnvelop()
197 .setRequestTransmissionPolicy(
198 PCMMGlobalConfig.BETransmissionPolicy);
199 ((BestEffortService) trafficProfile).getCommittedEnvelop()
200 .setMaximumSustainedTrafficRate(
202 // PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
203 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
207 // set transaction ID to gate set
208 trID.setGateCommandType(ITransactionID.GateSet);
209 _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
210 trID.setTransactionIdentifier(_transactionID);
212 amid.setApplicationType((short) 1);
213 amid.setApplicationMgrTag((short) 1);
214 gateSpec.setDirection(Direction.UPSTREAM);
215 gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
216 gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
217 gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
218 gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
219 gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
221 // XXX - if the version major is less than 4 we need to use Classifier
222 // TODO - Use some variable here or remove...
224 //eclassifier.setProtocol(IClassifier.Protocol.NONE);
225 // eclassifier.setProtocol(IClassifier.Protocol.TCP);
227 InetAddress subIP = InetAddress
228 .getByName(PCMMGlobalConfig.SubscriberID);
229 InetAddress srcIP = InetAddress
230 .getByName(PCMMGlobalConfig.srcIP);
231 InetAddress dstIP = InetAddress
232 .getByName(PCMMGlobalConfig.dstIP);
233 InetAddress mask = InetAddress.getByName("0.0.0.0");
234 subscriberID.setSourceIPAddress(subIP);
235 eclassifier.setSourceIPAddress(srcIP);
236 eclassifier.setDestinationIPAddress(dstIP);
237 eclassifier.setIPDestinationMask(mask);
238 eclassifier.setIPSourceMask(mask);
239 } catch (UnknownHostException unae) {
240 logger.error("Error getByName", unae);
242 eclassifier.setSourcePortStart(PCMMGlobalConfig.srcPort);
243 eclassifier.setSourcePortEnd(PCMMGlobalConfig.srcPort);
244 eclassifier.setDestinationPortStart(PCMMGlobalConfig.dstPort);
245 eclassifier.setDestinationPortEnd(PCMMGlobalConfig.dstPort);
246 eclassifier.setActivationState((byte) 0x01);
247 // check if we have a stored value of classifierID else we just
250 // eclassifier.setClassifierID((short) 0x01);
251 eclassifier.setClassifierID((short) (_classifierID == 0 ? Math
252 .random() * hashCode() : _classifierID));
254 // eclassifier.setClassifierID((short) 1);
256 eclassifier.setAction((byte) 0x00);
257 // XXX - temp default until Gate Modify is hacked in
258 // eclassifier.setPriority(PCMMGlobalConfig.EClassifierPriority);
259 eclassifier.setPriority((byte) 65);
262 // classifier.setProtocol(IClassifier.Protocol.TCP);
264 InetAddress subIP = InetAddress
265 .getByName(PCMMGlobalConfig.SubscriberID);
266 InetAddress srcIP = InetAddress
267 .getByName(PCMMGlobalConfig.srcIP);
268 InetAddress dstIP = InetAddress
269 .getByName(PCMMGlobalConfig.dstIP);
270 subscriberID.setSourceIPAddress(subIP);
271 classifier.setSourceIPAddress(srcIP);
272 classifier.setDestinationIPAddress(dstIP);
273 } catch (UnknownHostException unae) {
274 logger.error("Error getByName", unae);
276 classifier.setSourcePort(PCMMGlobalConfig.srcPort);
277 classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
280 gate.setTransactionID(trID);
282 gate.setSubscriberID(subscriberID);
283 gate.setGateSpec(gateSpec);
284 gate.setTrafficProfile(trafficProfile);
285 gate.setClassifier(eclassifier);
287 final byte[] data = gate.getData();
289 final Set<COPSDecision> decisionSet = new HashSet<>();
290 decisionSet.add(new COPSDecision(CType.NA, Command.INSTALL, DecisionFlag.REQERROR));
291 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
292 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
293 final COPSClientSI clientSD = new COPSClientSI(CSIType.NAMED, new COPSData(data, 0, data.length));
295 // Common Header with the same ClientType as the request
296 // Client Handle with the same clientHandle as the request
297 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
299 // ** Send the GateSet Decision
302 decisionMsg.writeData(_sock);
303 } catch (IOException e) {
304 logger.error("Failed to send the decision", e);
309 * Sends a PCMM GateSet COPS Decision message
310 * @throws COPSPdpException
312 public void sendGateSetBestEffortWithExtendedClassifier() throws COPSPdpException {
313 final IPCMMGate gate = new PCMMGateReq();
314 final ITransactionID trID = new TransactionID();
315 final IAMID amid = new AMID();
316 final ISubscriberID subscriberID = new SubscriberID();
317 final IGateSpec gateSpec = new GateSpec();
318 final IClassifier classifier = new Classifier();
319 final IExtendedClassifier eclassifier = new ExtendedClassifier();
321 // XXX check if other values should be provided
323 final ITrafficProfile trafficProfile = new BestEffortService(
324 (byte) 7); //BestEffortService.DEFAULT_ENVELOP);
325 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
326 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
327 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
328 .setMaximumTrafficBurst(
329 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
330 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
331 .setRequestTransmissionPolicy(
332 PCMMGlobalConfig.BETransmissionPolicy);
333 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
334 .setMaximumSustainedTrafficRate(
335 PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
336 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
338 ((BestEffortService) trafficProfile).getReservedEnvelop()
339 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
340 ((BestEffortService) trafficProfile).getReservedEnvelop()
341 .setMaximumTrafficBurst(
342 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
343 ((BestEffortService) trafficProfile).getReservedEnvelop()
344 .setRequestTransmissionPolicy(
345 PCMMGlobalConfig.BETransmissionPolicy);
346 ((BestEffortService) trafficProfile).getReservedEnvelop()
347 .setMaximumSustainedTrafficRate(
348 PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
349 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
352 ((BestEffortService) trafficProfile).getCommittedEnvelop()
353 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
354 ((BestEffortService) trafficProfile).getCommittedEnvelop()
355 .setMaximumTrafficBurst(
356 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
357 ((BestEffortService) trafficProfile).getCommittedEnvelop()
358 .setRequestTransmissionPolicy(
359 PCMMGlobalConfig.BETransmissionPolicy);
360 ((BestEffortService) trafficProfile).getCommittedEnvelop()
361 .setMaximumSustainedTrafficRate(
362 PCMMGlobalConfig.DefaultLowBestEffortTrafficRate );
363 // PCMMGlobalConfig.DefaultBestEffortTrafficRate);
367 // set transaction ID to gate set
368 trID.setGateCommandType(ITransactionID.GateSet);
369 _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
370 trID.setTransactionIdentifier(_transactionID);
372 amid.setApplicationType((short) 1);
373 amid.setApplicationMgrTag((short) 1);
374 gateSpec.setDirection(Direction.UPSTREAM);
375 gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
376 gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
377 gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
378 gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
379 gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
381 // XXX - if the version major is less than 4 we need to use Classifier
383 //eclassifier.setProtocol(IClassifier.Protocol.NONE);
384 // eclassifier.setProtocol(IClassifier.Protocol.TCP);
386 InetAddress subIP = InetAddress
387 .getByName(PCMMGlobalConfig.SubscriberID);
388 InetAddress srcIP = InetAddress
389 .getByName(PCMMGlobalConfig.srcIP);
390 InetAddress dstIP = InetAddress
391 .getByName(PCMMGlobalConfig.dstIP);
392 InetAddress mask = InetAddress.getByName("0.0.0.0");
393 subscriberID.setSourceIPAddress(subIP);
394 eclassifier.setSourceIPAddress(srcIP);
395 eclassifier.setDestinationIPAddress(dstIP);
396 eclassifier.setIPDestinationMask(mask);
397 eclassifier.setIPSourceMask(mask);
398 } catch (UnknownHostException unae) {
399 logger.error("Error getByName", unae);
401 eclassifier.setSourcePortStart(PCMMGlobalConfig.srcPort);
402 eclassifier.setSourcePortEnd(PCMMGlobalConfig.srcPort);
403 eclassifier.setDestinationPortStart(PCMMGlobalConfig.dstPort);
404 eclassifier.setDestinationPortEnd(PCMMGlobalConfig.dstPort);
405 eclassifier.setActivationState((byte) 0x01);
406 // check if we have a stored value of classifierID else we just
409 // eclassifier.setClassifierID((short) 0x01);
410 eclassifier.setClassifierID((short) (_classifierID == 0 ? Math
411 .random() * hashCode() : _classifierID));
413 // eclassifier.setClassifierID((short) 1);
415 eclassifier.setAction((byte) 0x00);
416 // XXX - temp default until Gate Modify is hacked in
417 // eclassifier.setPriority(PCMMGlobalConfig.EClassifierPriority);
418 eclassifier.setPriority((byte) 65);
421 // classifier.setProtocol(IClassifier.Protocol.TCP);
423 InetAddress subIP = InetAddress
424 .getByName(PCMMGlobalConfig.SubscriberID);
425 InetAddress srcIP = InetAddress
426 .getByName(PCMMGlobalConfig.srcIP);
427 InetAddress dstIP = InetAddress
428 .getByName(PCMMGlobalConfig.dstIP);
429 subscriberID.setSourceIPAddress(subIP);
430 classifier.setSourceIPAddress(srcIP);
431 classifier.setDestinationIPAddress(dstIP);
432 } catch (UnknownHostException unae) {
433 logger.error("Error getByName", unae);
435 classifier.setSourcePort(PCMMGlobalConfig.srcPort);
436 classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
439 gate.setTransactionID(trID);
441 gate.setSubscriberID(subscriberID);
442 gate.setGateSpec(gateSpec);
443 gate.setTrafficProfile(trafficProfile);
444 gate.setClassifier(eclassifier);
446 byte[] data = gate.getData();
448 final Set<COPSDecision> decisionSet = new HashSet<>();
449 decisionSet.add(new COPSDecision(CType.CSI, Command.INSTALL, DecisionFlag.REQERROR));
450 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
451 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
452 final COPSClientSI clientSD = new COPSClientSI(CSIType.NAMED, new COPSData(data, 0, data.length));
454 // Common Header with the same ClientType as the request
455 // Client Handle with the same clientHandle as the request
456 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(_clientType, _handle, decisionMap, null, clientSD);
458 // ** Send the GateSet Decision
461 decisionMsg.writeData(_sock);
462 } catch (IOException e) {
463 logger.error("Failed to send the decision", e);
469 public boolean handleGateReport(final Socket socket) throws COPSPdpException {
471 // waits for the gate-set-ack or error
472 final COPSMsg responseMsg = COPSTransceiver.receiveMsg(socket);
473 if (responseMsg.getHeader().getOpCode().equals(OPCode.RPT)) {
474 logger.info("processing received report from CMTS");
475 final COPSReportMsg reportMsg = (COPSReportMsg) responseMsg;
476 if (reportMsg.getClientSI() == null) {
479 final IPCMMGate responseGate = new PCMMGateReq(reportMsg.getClientSI().getData().getData());
480 if (responseGate.getTransactionID() != null
481 && responseGate.getTransactionID().getGateCommandType() == ITransactionID.GateSetAck) {
482 logger.info("the CMTS has sent a Gate-Set-Ack response");
483 // here CMTS responded that he acknowledged the Gate-Set
484 // TODO do further check of Gate-Set-Ack GateID etc...
485 _gateID = responseGate.getGateID();
492 } catch (Exception e) { // COPSException, IOException
493 throw new COPSPdpException("Error COPSTransceiver.receiveMsg", e);
499 * Sends a PCMM GateSet COPS Decision message
501 * @throws COPSPdpException
503 public void sendGateSet() throws COPSPdpException {
504 // Common Header with the same ClientType as the request
506 final IPCMMGate gate = new PCMMGateReq();
507 final ITransactionID trID = new TransactionID();
509 final IAMID amid = new AMID();
510 final ISubscriberID subscriberID = new SubscriberID();
511 final IGateSpec gateSpec = new GateSpec();
512 final IClassifier classifier = new Classifier();
513 // XXX check if other values should be provided
514 final ITrafficProfile trafficProfile = new BestEffortService(
515 BestEffortService.DEFAULT_ENVELOP);
516 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
517 .setTrafficPriority(BestEffortService.DEFAULT_TRAFFIC_PRIORITY);
518 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
519 .setMaximumTrafficBurst(
520 BestEffortService.DEFAULT_MAX_TRAFFIC_BURST);
521 ((BestEffortService) trafficProfile).getAuthorizedEnvelop()
522 .setRequestTransmissionPolicy(
523 PCMMGlobalConfig.BETransmissionPolicy);
525 // set transaction ID to gate set
526 trID.setGateCommandType(ITransactionID.GateSet);
527 _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
528 trID.setTransactionIdentifier(_transactionID);
530 amid.setApplicationType((short) 1);
531 amid.setApplicationMgrTag((short) 1);
532 gateSpec.setDirection(Direction.UPSTREAM);
533 gateSpec.setDSCP_TOSOverwrite(DSCPTOS.OVERRIDE);
534 gateSpec.setTimerT1(PCMMGlobalConfig.GateT1);
535 gateSpec.setTimerT2(PCMMGlobalConfig.GateT2);
536 gateSpec.setTimerT3(PCMMGlobalConfig.GateT3);
537 gateSpec.setTimerT4(PCMMGlobalConfig.GateT4);
540 * ((DOCSISServiceClassNameTrafficProfile) trafficProfile)
541 * .setServiceClassName("S_up");
544 // classifier.setProtocol(IClassifier.Protocol.TCP);
546 InetAddress subIP = InetAddress.getByName(PCMMGlobalConfig.SubscriberID);
547 InetAddress srcIP = InetAddress.getByName(PCMMGlobalConfig.srcIP);
548 InetAddress dstIP = InetAddress.getByName(PCMMGlobalConfig.dstIP);
549 subscriberID.setSourceIPAddress(subIP);
550 classifier.setSourceIPAddress(srcIP);
551 classifier.setDestinationIPAddress(dstIP);
552 } catch (UnknownHostException unae) {
553 logger.error("Error getByName", unae);
555 classifier.setSourcePort(PCMMGlobalConfig.srcPort);
556 classifier.setDestinationPort(PCMMGlobalConfig.dstPort);
558 gate.setTransactionID(trID);
560 gate.setSubscriberID(subscriberID);
561 gate.setGateSpec(gateSpec);
562 gate.setTrafficProfile(trafficProfile);
563 gate.setClassifier(classifier);
565 final byte[] data = gate.getData();
567 final Set<COPSDecision> decisionSet = new HashSet<>();
568 decisionSet.add(new COPSDecision(CType.CSI, Command.INSTALL, DecisionFlag.REQERROR));
569 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
570 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
572 final COPSClientSI clientSD = new COPSClientSI(CSIType.NAMED, new COPSData(data, 0, data.length));
574 // Client Handle with the same clientHandle as the request
575 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
577 // ** Send the GateSet Decision
580 decisionMsg.writeData(_sock);
581 } catch (IOException e) {
582 logger.error("Failed to send the decision", e);
587 * Sends a message asking that the request state be deleted
589 * @throws COPSPdpException
591 public void sendGateDelete(final IPCMMGate gate) throws COPSPdpException {
592 // set transaction ID to gate set
593 final ITransactionID trID = new TransactionID();
594 trID.setGateCommandType(ITransactionID.GateDelete);
595 _transactionID = (_transactionID == 0 ? (short) (Math.random() * hashCode()) : _transactionID);
596 trID.setTransactionIdentifier(_transactionID);
597 gate.setTransactionID(trID);
599 Short trIDnum = trID.getTransactionIdentifier();
600 PCMMGlobalConfig.transactionGateMap.put(trIDnum, gate);
602 // gateDelete only requires AMID, subscriberID, and gateID
603 // remove the gateSpec, traffic profile, and classifiers from original gate request
604 gate.setGateSpec(null);
605 gate.setTrafficProfile(null);
606 gate.setClassifier(null);
607 // clear the error object
611 final byte[] data = gate.getData();
612 final Set<COPSDecision> decisionSet = new HashSet<>();
613 decisionSet.add(new COPSDecision(CType.DEF, Command.INSTALL, DecisionFlag.REQERROR));
614 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
615 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
616 final COPSClientSI clientSD = new COPSClientSI(CNum.DEC, CType.CSI, new COPSData(data, 0, data.length));
618 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, clientSD);
620 // ** Send the GateDelete Decision
623 decisionMsg.writeData(_sock);
624 // decisionMsg.writeData(socket_id);
625 } catch (IOException e) {
626 logger.error("Failed to send the decision", e);
631 * Sends a request asking that a new request state be created
633 * @throws COPSPdpException
635 public void sendOpenNewRequestState() throws COPSPdpException {
637 * <Decision Message> ::= <Common Header: Flag UNSOLICITED> <Client
638 * Handle> *(<Decision>) [<Integrity>] <Decision> ::= <Context>
639 * <Decision: Flags> <Decision: Flags> ::= Install Request-State
642 final Set<COPSDecision> decisionSet = new HashSet<>();
643 decisionSet.add(new COPSDecision(Command.INSTALL, DecisionFlag.REQSTATE));
644 final Map<COPSContext, Set<COPSDecision>> decisionMap = new HashMap<>();
645 decisionMap.put(new COPSContext(RType.CONFIG, (short)0), decisionSet);
647 final COPSDecisionMsg decisionMsg = new COPSDecisionMsg(getClientType(), _handle, decisionMap, null, null);
650 decisionMsg.writeData(_sock);
651 } catch (IOException e) {
652 throw new COPSPdpException("Failed to send the open new request state", e);
657 * Sends a message asking for a COPS sync operation
659 * @throws COPSPdpException
661 public void sendGateInfo() throws COPSPdpException {
663 * <Gate-Info> ::= <Common Header> [<Client Handle>] [<Integrity>]
665 final COPSSyncStateMsg msg = new COPSSyncStateMsg(getClientType(), _handle, null);
667 msg.writeData(_sock);
668 } catch (IOException e) {
669 throw new COPSPdpException("Failed to send the GateInfo request", e);
674 * Sends a message asking for a COPS sync operation
676 * @throws COPSPdpException
678 public void sendSyncRequest() throws COPSPdpException {
680 * <Synchronize State Request> ::= <Common Header> [<Client Handle>]
684 // Client Handle with the same clientHandle as the request
685 final COPSSyncStateMsg msg = new COPSSyncStateMsg(getClientType(), _handle, null);
687 msg.writeData(_sock);
688 } catch (IOException e) {
689 throw new COPSPdpException("Failed to send the sync state request", e);
693 public void sendSyncRequestState() throws COPSPdpException {
696 public void sendDeleteRequestState() throws COPSPdpException {