alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 1 | /* |
Rusty Eddy | c0e3fea | 2015-09-28 21:20:41 +0000 | [diff] [blame] | 2 | * Copyright 2015 Open Networking Laboratory |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.mfwd.cli; |
| 17 | |
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 18 | import org.apache.felix.scr.annotations.Reference; |
| 19 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 20 | import org.apache.karaf.shell.commands.Argument; |
| 21 | import org.apache.karaf.shell.commands.Command; |
| 22 | import org.onosproject.cli.AbstractShellCommand; |
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 23 | import org.onosproject.mfwd.impl.McastForwarding; |
| 24 | import org.onosproject.net.ConnectPoint; |
| 25 | import org.onosproject.net.mcast.McastRoute; |
| 26 | import org.onosproject.net.mcast.MulticastRouteService; |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
Rusty Eddy | c0e3fea | 2015-09-28 21:20:41 +0000 | [diff] [blame] | 29 | * Deletes a multicast route. |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 30 | */ |
| 31 | @Command(scope = "onos", name = "mcast-delete", |
| 32 | description = "Delete a multicast route flow") |
| 33 | public class McastDeleteCommand extends AbstractShellCommand { |
| 34 | |
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 35 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 36 | MulticastRouteService mcastRouteManager = AbstractShellCommand.get(MulticastRouteService.class); |
| 37 | |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 38 | @Argument(index = 0, name = "sAddr", |
| 39 | description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry", |
| 40 | required = true, multiValued = false) |
| 41 | String sAddr = null; |
| 42 | |
| 43 | @Argument(index = 1, name = "gAddr", |
| 44 | description = "IP Address of the multicast group", |
| 45 | required = true, multiValued = false) |
| 46 | String gAddr = null; |
| 47 | |
Julian Lawrence | 14c7318 | 2015-10-08 18:31:52 -0700 | [diff] [blame] | 48 | @Argument(index = 2, name = "egressList", |
| 49 | description = "Egress id/port", |
| 50 | required = false, multiValued = true) |
| 51 | String[] egressList = null; |
| 52 | |
| 53 | |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 54 | @Override |
| 55 | protected void execute() { |
Julian Lawrence | 14c7318 | 2015-10-08 18:31:52 -0700 | [diff] [blame] | 56 | |
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 57 | McastRoute mRoute = McastForwarding.createStaticRoute(sAddr, gAddr); |
Julian Lawrence | 14c7318 | 2015-10-08 18:31:52 -0700 | [diff] [blame] | 58 | |
| 59 | if (egressList == null) { |
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 60 | mcastRouteManager.remove(mRoute); |
Julian Lawrence | 14c7318 | 2015-10-08 18:31:52 -0700 | [diff] [blame] | 61 | } else { |
| 62 | // check list for validity before we begin to delete. |
| 63 | for (String egress : egressList) { |
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 64 | ConnectPoint eCp = ConnectPoint.deviceConnectPoint(egress); |
| 65 | mcastRouteManager.removeSink(mRoute, eCp); |
Julian Lawrence | 14c7318 | 2015-10-08 18:31:52 -0700 | [diff] [blame] | 66 | } |
| 67 | } |
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 68 | } |
Julian Lawrence | 14c7318 | 2015-10-08 18:31:52 -0700 | [diff] [blame] | 69 | } |