alshabib | eff0054 | 2015-09-23 13:22:33 -0700 | [diff] [blame] | 1 | /*
|
| 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 | */
|
| 16 | package org.onosproject.mfwd.rest;
|
| 17 |
|
| 18 | import com.fasterxml.jackson.databind.JsonNode;
|
| 19 | import com.fasterxml.jackson.databind.ObjectMapper;
|
| 20 |
|
| 21 | import java.io.IOException;
|
| 22 | import java.io.InputStream;
|
| 23 | import java.util.Map;
|
| 24 |
|
| 25 | import javax.ws.rs.Consumes;
|
| 26 | import javax.ws.rs.GET;
|
| 27 | import javax.ws.rs.POST;
|
| 28 | import javax.ws.rs.Path;
|
| 29 | import javax.ws.rs.Produces;
|
| 30 | import javax.ws.rs.core.MediaType;
|
| 31 | import javax.ws.rs.core.Response;
|
| 32 |
|
| 33 | import org.onlab.packet.IpPrefix;
|
| 34 | import org.onlab.rest.BaseResource;
|
| 35 | import org.onosproject.mfwd.impl.McastRouteGroup;
|
| 36 | import org.onosproject.mfwd.impl.McastRouteTable;
|
| 37 |
|
| 38 | /**
|
| 39 | * Rest API for Multicast Forwarding.
|
| 40 | */
|
| 41 | @Path("mcast")
|
| 42 | public 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 | }
|