blob: 878e21d994a6399ee98ed6ad139e2de2a858e9b5 [file] [log] [blame]
alshabibeff00542015-09-23 13:22:33 -07001/*
2 * Copyright 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.rest;
17
18import com.fasterxml.jackson.databind.JsonNode;
19import com.fasterxml.jackson.databind.ObjectMapper;
20
21import java.io.IOException;
22import java.io.InputStream;
23import java.util.Map;
24
25import javax.ws.rs.Consumes;
26import javax.ws.rs.GET;
27import javax.ws.rs.POST;
28import javax.ws.rs.Path;
29import javax.ws.rs.Produces;
30import javax.ws.rs.core.MediaType;
31import javax.ws.rs.core.Response;
32
33import org.onlab.packet.IpPrefix;
34import org.onlab.rest.BaseResource;
35import org.onosproject.mfwd.impl.McastRouteGroup;
36import org.onosproject.mfwd.impl.McastRouteTable;
37
38/**
39 * Rest API for Multicast Forwarding.
40 */
41@Path("mcast")
42public class McastResource extends BaseResource {
43
44 /**
45 * Retrieve the multicast route table.
46 * @return the multicast route table.
47 * @throws IOException if an error occurs
48 */
49 @GET
50 @Produces(MediaType.APPLICATION_JSON)
51 public Response showAll() throws IOException {
52 ObjectMapper mapper = new ObjectMapper();
53 McastRouteTable mcastRouteTable = McastRouteTable.getInstance();
54 Map<IpPrefix, McastRouteGroup> map = mcastRouteTable.getMrib4();
55 return Response.ok(mapper.createObjectNode().toString()).build();
56 }
57
58 /**
59 * Static join of a multicast flow.
60 * @param input source, group, ingress connectPoint egress connectPoints
61 * @return status of static join
62 * @throws IOException if an error occurs
63 */
64 @POST
65 @Consumes(MediaType.APPLICATION_JSON)
66 @Produces(MediaType.APPLICATION_JSON)
67 public Response join(InputStream input) throws IOException {
68 ObjectMapper mapper = new ObjectMapper();
69 JsonNode cfg = mapper.readTree(input);
70 return null;
71 }
72}