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 |
|
| 18 | import org.apache.karaf.shell.commands.Argument;
|
| 19 | import org.apache.karaf.shell.commands.Command;
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 20 | import org.onosproject.cli.AbstractShellCommand;
|
| 21 |
|
Rusty Eddy | ddef893 | 2015-09-25 01:15:53 +0000 | [diff] [blame] | 22 | import org.onosproject.mfwd.impl.McastConnectPoint;
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 23 | import org.onosproject.mfwd.impl.McastRouteBase;
|
| 24 | import org.onosproject.mfwd.impl.McastRouteTable;
|
| 25 |
|
| 26 | /**
|
| 27 | * Installs a source, multicast group flow.
|
| 28 | */
|
| 29 | @Command(scope = "onos", name = "mcast-join",
|
| 30 | description = "Installs a source, multicast group flow")
|
| 31 | public class McastJoinCommand extends AbstractShellCommand {
|
| 32 |
|
| 33 | @Argument(index = 0, name = "sAddr",
|
| 34 | description = "IP Address of the multicast source. '*' can be used for any source (*, G) entry",
|
| 35 | required = true, multiValued = false)
|
| 36 | String sAddr = null;
|
| 37 |
|
| 38 | @Argument(index = 1, name = "gAddr",
|
| 39 | description = "IP Address of the multicast group",
|
| 40 | required = true, multiValued = false)
|
| 41 | String gAddr = null;
|
| 42 |
|
| 43 | @Argument(index = 2, name = "ingressPort",
|
| 44 | description = "Ingress port and Egress ports",
|
| 45 | required = false, multiValued = false)
|
| 46 | String ingressPort = null;
|
| 47 |
|
| 48 | @Argument(index = 3, name = "ports",
|
| 49 | description = "Ingress port and Egress ports",
|
| 50 | required = false, multiValued = true)
|
| 51 | String[] ports = null;
|
| 52 |
|
| 53 | @Override
|
| 54 | protected void execute() {
|
| 55 | McastRouteTable mrib = McastRouteTable.getInstance();
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 56 | McastRouteBase mr = mrib.addRoute(sAddr, gAddr);
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 57 |
|
| 58 | // Port format "of:0000000000000023/4"
|
| 59 | if (ingressPort != null) {
|
| 60 | String inCP = ingressPort;
|
| 61 | log.debug("Ingress port provided: " + inCP);
|
Rusty Eddy | ddef893 | 2015-09-25 01:15:53 +0000 | [diff] [blame] | 62 | mr.addIngressPoint(inCP);
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 63 | }
|
| 64 |
|
| 65 | for (int i = 0; i < ports.length; i++) {
|
| 66 | String egCP = ports[i];
|
| 67 | log.debug("Egress port provided: " + egCP);
|
Rusty Eddy | ddef893 | 2015-09-25 01:15:53 +0000 | [diff] [blame] | 68 | mr.addEgressPoint(egCP, McastConnectPoint.JoinSource.STATIC);
|
alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 69 | }
|
| 70 | print("Added the mcast route");
|
| 71 | }
|
| 72 | }
|