com.eurotech.framework.linux.net.route
Class RouteServiceImpl

java.lang.Object
  extended by com.eurotech.framework.linux.net.route.RouteServiceImpl
All Implemented Interfaces:
IRouteService

public class RouteServiceImpl
extends Object
implements IRouteService


Field Summary
 
Fields inherited from interface com.eurotech.framework.linux.net.route.IRouteService
SERVICE_NAME
 
Method Summary
 void addStaticRoute(IPAddress destination, IPAddress gateway, IPAddress netmask, String iface, int metric)
          Adds a static route to the system's route table.
 String getDefaultInterface(IPAddress destination)
          Returns the default route's interface for the specified destination address, or null if no route exists.
 RouteConfig getDefaultRoute(String iface)
          Returns the default route for a specified interface.
static IRouteService getInstance()
           
 RouteConfig[] getRoutes()
          Returns the routes contained in the system's route table.
 void removeStaticRoute(IPAddress destination, IPAddress gateway, IPAddress netmask, String iface)
          Removes a static route in the system's route table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static IRouteService getInstance()

addStaticRoute

public void addStaticRoute(IPAddress destination,
                           IPAddress gateway,
                           IPAddress netmask,
                           String iface,
                           int metric)
                    throws Exception
Description copied from interface: IRouteService
Adds a static route to the system's route table.

Specified by:
addStaticRoute in interface IRouteService
Parameters:
destination - An IPAddress object representing the destination IP address.
gateway - An IPAddress object representing the gateway IP address.
netmask - An IPAddress object representing the netmask.
iface - A String object specifying the interface name.
metric - An int representing the metric (priority) of the route.
Throws:
Exception - for invalid supplied parameters, or failure to add.

getDefaultRoute

public RouteConfig getDefaultRoute(String iface)
Description copied from interface: IRouteService
Returns the default route for a specified interface.

Specified by:
getDefaultRoute in interface IRouteService
Parameters:
iface - A String object specifying the interface name.
Returns:
A Route object representing the default route or null if none exists.

getRoutes

public RouteConfig[] getRoutes()
Description copied from interface: IRouteService
Returns the routes contained in the system's route table.

Specified by:
getRoutes in interface IRouteService
Returns:
An array of Route objects representing the system's route table, null if no routes exist.

removeStaticRoute

public void removeStaticRoute(IPAddress destination,
                              IPAddress gateway,
                              IPAddress netmask,
                              String iface)
                       throws Exception
Description copied from interface: IRouteService
Removes a static route in the system's route table.

Specified by:
removeStaticRoute in interface IRouteService
Parameters:
destination - An InetAddress object representing the destination IP address.
gateway - An InetAddress object representing the gateway IP address.
netmask - An InetAddress object representing the netmask.
iface - A String object specifying the interface name.
Throws:
Exception - for invalid supplied parameters, or failure to remove.

getDefaultInterface

public String getDefaultInterface(IPAddress destination)
Description copied from interface: IRouteService
Returns the default route's interface for the specified destination address, or null if no route exists.

Specified by:
getDefaultInterface in interface IRouteService
Parameters:
destination - An IPAddress object representing the destination IP address.
Returns:
A String object specifying the interface name, null if no route exists.


Copyright © 2013. All Rights Reserved.