5 package org.opendaylight.controller.protocol_plugin.packetcable.internal;
7 import org.opendaylight.controller.sal.flowprogrammer.Flow;
8 import org.opendaylight.controller.sal.flowprogrammer.IPluginInFlowProgrammerService;
9 import org.opendaylight.controller.sal.core.Node;
10 import org.opendaylight.controller.sal.utils.Status;
11 import org.opendaylight.controller.sal.utils.StatusCode;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
16 import org.umu.cops.prpdp.COPSPdpException;
17 import org.pcmm.gates.IPCMMGate;
18 import org.pcmm.PCMMDef;
19 import org.pcmm.PCMMGlobalConfig;
20 import org.pcmm.PCMMPdpMsgSender;
21 import org.pcmm.PCMMPdpDataProcess;
22 import org.pcmm.PCMMPdpAgent;
27 * Represents the packetcable plugin component in charge of programming the flows
28 * the flow programming and relay them to functional modules above SAL.
30 public class FlowProgrammerService implements IPluginInFlowProgrammerService
32 protected PCMMPdpDataProcess process;
33 protected PCMMPdpAgent pcmm_pdp;
34 protected PCMMPdpMsgSender pcmm_sender;
37 protected static final Logger logger = LoggerFactory
38 .getLogger(FlowProgrammerService.class);
40 logger.info("FlowProgrammerService: init");
41 pcmm_pdp = new PCMMPdpAgent(PCMMDef.C_PCMM, process);
45 * Function called by the dependency manager when at least one dependency
46 * become unsatisfied or when the component is shutting down because for
47 * example bundle is being stopped.
51 logger.info("FlowProgrammerService: destroy");
55 * Function called by dependency manager after "init ()" is called and after
56 * the services provided by the class are registered in the service registry
60 logger.info("FlowProgrammerService: start");
62 logger.info("Open connection to CMTS");
63 pcmm_pdp.connect( PCMMGlobalConfig.DefaultCMTS, 3918 );
64 pcmm_sender = new PCMMPdpMsgSender (PCMMDef.C_PCMM, pcmm_pdp.getClientHandle(), pcmm_pdp.getSocket());
65 } catch (Exception e) {
66 System.out.println(e.getMessage());
71 * Function called by the dependency manager before the services exported by
72 * the component are unregistered, this will be followed by a "destroy ()"
77 logger.info("FlowProgrammerService: stop");
82 * Synchronously add a flow to the network node
87 public Status addFlow(Node node, Flow flow){
88 logger.info("FlowProgrammerService: addFlow");
89 FlowConverter fc = new FlowConverter(flow);
91 IPCMMGate gate = fc.getServiceFlow();
94 logger.info("sendGateSet to CMTS");
95 pcmm_sender.sendGateSet(gate);
96 } catch (COPSPdpException e) {
97 logger.error("Failed to sendGateSet, reason: " + e.getMessage());
98 return new Status(StatusCode.INTERNALERROR, "Failed to sendGateSet to CMTS");
100 return new Status(StatusCode.SUCCESS);
104 * Synchronously modify existing flow on the switch
109 public Status modifyFlow(Node node, Flow oldFlow, Flow newFlow){
110 logger.info("FlowProgrammerService: modifyFlow");
111 return new Status(StatusCode.SUCCESS);
114 * Synchronously remove the flow from the network node
119 public Status removeFlow(Node node, Flow flow){
120 logger.info("FlowProgrammerService: removeFlow");
121 logger.info("FlowProgrammerService: removeFlow GateID1 " + PCMMGlobalConfig.getGateID1() );
122 logger.info("FlowProgrammerService: removeFlow GateID2 " + PCMMGlobalConfig.getGateID2() );
123 logger.info("FlowProgrammerService: removeFlow FlowID " + flow.getId() );
124 if ( PCMMGlobalConfig.getGateID1() != 0 ) {
125 logger.info("Remove Flow " + PCMMGlobalConfig.getGateID1() );
127 pcmm_sender.sendGateDelete( PCMMGlobalConfig.getGateID1() );
128 } catch (COPSPdpException e) {
129 logger.error("Failed to sendGateDelete, reason: " + e.getMessage());
130 return new Status(StatusCode.INTERNALERROR, "Failed to sendGateDelete to CMTS");
133 return new Status(StatusCode.SUCCESS);
137 * Asynchronously add a flow to the network node
143 public Status addFlowAsync(Node node, Flow flow, long rid){
144 logger.info("FlowProgrammerService: addFlowAsync");
145 return new Status(StatusCode.SUCCESS);
149 * Asynchronously modify existing flow on the switch
155 public Status modifyFlowAsync(Node node, Flow oldFlow, Flow newFlow, long rid){
156 logger.info("FlowProgrammerService: modifyFlowAsync");
157 return new Status(StatusCode.SUCCESS);
161 * Asynchronously remove the flow from the network node
167 public Status removeFlowAsync(Node node, Flow flow, long rid){
168 logger.info("FlowProgrammerService: removeFlowAsync");
169 return new Status(StatusCode.SUCCESS);
173 * Remove all flows present on the network node
177 public Status removeAllFlows(Node node){
178 logger.info("FlowProgrammerService: removeAllFlows");
179 return new Status(StatusCode.SUCCESS);
183 * Send Barrier message synchronously. The caller will be blocked until the
184 * Barrier reply arrives.
188 public Status syncSendBarrierMessage(Node node){
189 logger.info("FlowProgrammerService: syncSendBarrierMessage");
190 return new Status(StatusCode.SUCCESS);
194 * Send Barrier message asynchronously. The caller is not blocked.
198 public Status asyncSendBarrierMessage(Node node){
199 logger.info("FlowProgrammerService: asyncSendBarrierMessage");
200 return new Status(StatusCode.SUCCESS);