alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 1 | /*
|
| 2 | * Copyright 2014-2015 Open Networking Laboratory
|
| 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;
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 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 | /**
|
| 29 | * Installs a source, multicast group flow.
|
| 30 | */
|
| 31 | @Command(scope = "onos", name = "mcast-join",
|
| 32 | description = "Installs a source, multicast group flow")
|
| 33 | public class McastJoinCommand 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 |
|
| 48 | @Argument(index = 2, name = "ingressPort",
|
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 49 | description = "Ingress port of:XXXXXXXXXX/XX",
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 50 | required = false, multiValued = false)
|
| 51 | String ingressPort = null;
|
| 52 |
|
| 53 | @Argument(index = 3, name = "ports",
|
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 54 | description = "Egress ports of:XXXXXXXXXX/XX...",
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 55 | required = false, multiValued = true)
|
| 56 | String[] ports = null;
|
| 57 |
|
| 58 | @Override
|
| 59 | protected void execute() {
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 60 |
|
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 61 | McastRoute mRoute = McastForwarding.createStaticRoute(sAddr, gAddr);
|
| 62 | mcastRouteManager.add(mRoute);
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 63 |
|
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 64 | ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressPort);
|
| 65 | mcastRouteManager.addSource(mRoute, ingress);
|
| 66 |
|
| 67 | for (String egCP : ports) {
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 68 | log.debug("Egress port provided: " + egCP);
|
Julian Lawrence | fa790f6 | 2016-01-07 17:18:30 -0800 | [diff] [blame^] | 69 | ConnectPoint egress = ConnectPoint.deviceConnectPoint(egCP);
|
| 70 | mcastRouteManager.addSink(mRoute, egress);
|
| 71 |
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 72 | }
|
| 73 | print("Added the mcast route");
|
| 74 | }
|
| 75 | }
|