blob: 7260fde5ef5b309d776e661c713532d9ca13cabb [file] [log] [blame]
alshabibeff00542015-09-23 13:22:33 -07001/*
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 */
16package org.onosproject.mfwd.cli;
17
18import org.apache.karaf.shell.commands.Argument;
19import org.apache.karaf.shell.commands.Command;
alshabibeff00542015-09-23 13:22:33 -070020import org.onosproject.cli.AbstractShellCommand;
21
Rusty Eddyddef8932015-09-25 01:15:53 +000022import org.onosproject.mfwd.impl.McastConnectPoint;
alshabibeff00542015-09-23 13:22:33 -070023import org.onosproject.mfwd.impl.McastRouteBase;
24import 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")
31public 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();
alshabibeff00542015-09-23 13:22:33 -070056 McastRouteBase mr = mrib.addRoute(sAddr, gAddr);
alshabibeff00542015-09-23 13:22:33 -070057
58 // Port format "of:0000000000000023/4"
59 if (ingressPort != null) {
60 String inCP = ingressPort;
61 log.debug("Ingress port provided: " + inCP);
Rusty Eddyddef8932015-09-25 01:15:53 +000062 mr.addIngressPoint(inCP);
alshabibeff00542015-09-23 13:22:33 -070063 }
64
65 for (int i = 0; i < ports.length; i++) {
66 String egCP = ports[i];
67 log.debug("Egress port provided: " + egCP);
Rusty Eddyddef8932015-09-25 01:15:53 +000068 mr.addEgressPoint(egCP, McastConnectPoint.JoinSource.STATIC);
alshabibeff00542015-09-23 13:22:33 -070069 }
70 print("Added the mcast route");
71 }
72}