blob: 4e6b26eb45c56439e377ed79166461c2589f057a [file] [log] [blame]
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -07001package net.onrc.onos.apps.proxyarp.web;
Jonathan Hart5afde492013-10-01 12:30:53 +13002
3import java.util.List;
4
Yuta HIGUCHI238fa2a2014-05-01 09:56:46 -07005import net.onrc.onos.apps.proxyarp.IProxyArpService;
6
Jonathan Hart5afde492013-10-01 12:30:53 +13007import org.restlet.resource.Get;
8import org.restlet.resource.ServerResource;
9
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070010/**
11 * REST resource to view the IP to MAC mappings in the ARP cache.
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070012 */
Jonathan Hart5afde492013-10-01 12:30:53 +130013public class ArpCacheResource extends ServerResource {
14
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070015 /**
16 * Handler for a REST call to retrieve the ARP cache.
Ray Milkey269ffb92014-04-03 14:43:30 -070017 *
Jonathan Hart7c9a2fb2014-03-27 09:51:41 -070018 * @return list of mappings formatted as a human-readable string.
19 */
20 @Get("json")
21 public List<String> getArpCache() {
22 IProxyArpService arp = (IProxyArpService) getContext().getAttributes()
23 .get(IProxyArpService.class.getCanonicalName());
24
25 return arp.getMappings();
26 }
Jonathan Hart5afde492013-10-01 12:30:53 +130027
28}