blob: 707dbf02e36e82ae76387d994b9ff523a78775d6 [file] [log] [blame]
Madan Jampanic27b6b22016-02-05 11:36:31 -08001/*
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.felix.scr.annotations.Reference;
19import org.apache.felix.scr.annotations.ReferenceCardinality;
20import org.apache.karaf.shell.commands.Argument;
21import org.apache.karaf.shell.commands.Command;
22import org.onosproject.cli.AbstractShellCommand;
23import org.onosproject.mfwd.impl.McastForwarding;
24import org.onosproject.net.ConnectPoint;
25import org.onosproject.net.mcast.McastRoute;
26import org.onosproject.net.mcast.MulticastRouteService;
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")
33public class McastJoinCommand extends AbstractShellCommand {
34
35 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
36 MulticastRouteService mcastRouteManager = AbstractShellCommand.get(MulticastRouteService.class);
37
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",
49 description = "Ingress port of:XXXXXXXXXX/XX",
50 required = false, multiValued = false)
51 String ingressPort = null;
52
53 @Argument(index = 3, name = "ports",
54 description = "Egress ports of:XXXXXXXXXX/XX...",
55 required = false, multiValued = true)
56 String[] ports = null;
57
58 @Override
59 protected void execute() {
60
61 McastRoute mRoute = McastForwarding.createStaticRoute(sAddr, gAddr);
62 mcastRouteManager.add(mRoute);
63
64 ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressPort);
65 mcastRouteManager.addSource(mRoute, ingress);
66
67 for (String egCP : ports) {
68 log.debug("Egress port provided: " + egCP);
69 ConnectPoint egress = ConnectPoint.deviceConnectPoint(egCP);
70 mcastRouteManager.addSink(mRoute, egress);
71
72 }
73 print("Added the mcast route");
74 }
75}