/** * Unregister a route on a forwarder. * <p/> * Ensure the forwarding face is on the local machine (management requests are to /localhost/...) and that command * signing has been set up (e.g. forwarder.setCommandSigningInfo(). * * @param face only a localhost {@link Face} * @param route the {@link Name} prefix of the route * @throws ManagementException if the network request failed, the NFD response could not be decoded, or * the NFD rejected the request * @see <a href="http://named-data.net/doc/NFD/current/manpages/nfdc.html">nfdc</a> * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a> */ public static void unregister(final Face face, final Name route) throws ManagementException { // build command name ControlParameters controlParameters = new ControlParameters(); controlParameters.setName(route); // send the interest unregister(face, controlParameters); }
/** * Unregister a route on a forwarder; see * <p/> * Ensure the forwarding face is on the local machine (management requests are to /localhost/...) and that command * signing has been set up (e.g. forwarder.setCommandSigningInfo(). * * @param face only a localhost {@link Face} * @param route the {@link Name} prefix of the route * @param faceId the specific ID of the face to remove (more than one face can * be registered to a route) * @throws ManagementException if the network request failed, the NFD response could not be decoded, or * the NFD rejected the request * @see <a href="http://named-data.net/doc/NFD/current/manpages/nfdc.html">nfdc</a> * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a> */ public static void unregister(final Face face, final Name route, final int faceId) throws ManagementException { // build command name ControlParameters controlParameters = new ControlParameters(); controlParameters.setName(route); controlParameters.setFaceId(faceId); // send the interest unregister(face, controlParameters); }
private ControlParameters decodeParameters(Interest interest) { ControlParameters params = new ControlParameters(); try { params.wireDecode(interest.getName().get(CONTROL_PARAMETERS_NAME_OFFSET).getValue()); params.setFaceId(1); params.setOrigin(0); params.setCost(0); } catch (EncodingException e) { throw new IllegalArgumentException("", e); } return params; }
/** * Destroy a face on given forwarder. Ensure the forwarding face is on the * local machine (management requests are to /localhost/...) and that command * signing has been set up (e.g. forwarder.setCommandSigningInfo()). * * @param face only a localhost {@link Face} * @param faceId the ID of the face to destroy * @throws ManagementException if the network request failed, the NFD response could not be decoded, or * the NFD rejected the request */ public static void destroyFace(final Face face, final int faceId) throws ManagementException { Name command = new Name("/localhost/nfd/faces/destroy"); ControlParameters parameters = new ControlParameters(); parameters.setFaceId(faceId); command.append(parameters.wireEncode()); try { sendCommand(face, command); } catch (IOException | EncodingException | ManagementException e) { throw new ManagementException(e.getMessage(), e); } }
/** * Set a strategy on the forwarder; see * {@link #setStrategy(net.named_data.jndn.Face, net.named_data.jndn.Name, net.named_data.jndn.Name)} * for more information. Ensure the forwarding face is on the local machine * (management requests are to /localhost/...) and that command signing has * been set up (e.g. forwarder.setCommandSigningInfo()). * * @param face only a localhost {@link Face} * @param prefix the {@link Name} prefix * @throws ManagementException if the network request failed, the NFD response could not be decoded, or * the NFD rejected the request */ public static void unsetStrategy(final Face face, final Name prefix) throws ManagementException { // build command name Name command = new Name("/localhost/nfd/strategy-choice/unset"); ControlParameters parameters = new ControlParameters(); parameters.setName(prefix); command.append(parameters.wireEncode()); try { sendCommand(face, command); } catch (IOException | EncodingException | ManagementException e) { throw new ManagementException(e.getMessage(), e); } }
/** * Disable a local control feature on the given forwarder. * * @param face only a localhost {@link Face} * @param header the control feature to disable * @throws ManagementException if the network request failed, the NFD response could not be decoded, or * the NFD rejected the request * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">Face Management</a> */ public static void disableLocalControlHeader(final Face face, final LocalControlHeader header) throws ManagementException { // build command name Name command = new Name("/localhost/nfd/faces/disable-local-control"); ControlParameters parameters = new ControlParameters(); parameters.setLocalControlFeature(header.toInteger()); command.append(parameters.wireEncode()); try { sendCommand(face, command); } catch (IOException | EncodingException | ManagementException e) { throw new ManagementException(e.getMessage(), e); } }
/** * Enable a local control feature on the given forwarder. * * @param face only a localhost {@link Face} * @param header the control feature to enable * @throws ManagementException if the network request failed, the NFD response could not be decoded, or * the NFD rejected the request * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">Face Management</a> */ public static void enableLocalControlHeader(final Face face, final LocalControlHeader header) throws ManagementException { // build command name Name command = new Name("/localhost/nfd/faces/enable-local-control"); ControlParameters parameters = new ControlParameters(); parameters.setLocalControlFeature(header.toInteger()); command.append(parameters.wireEncode()); try { sendCommand(face, command); } catch (IOException | EncodingException | ManagementException e) { throw new ManagementException(e.getMessage(), e); } }
/** * Set a strategy on the forwarder * <p/> * Ensure the forwarding face is on the local machine (management requests are to /localhost/...) and that command * signing has been set up using forwarder.setCommandSigningInfo(). * * @param face only a localhost {@link Face} * @param prefix the {@link Name} prefix * @param strategy the {@link Name} of the strategy to set, e.g. * /localhost/nfd/strategy/broadcast * @throws ManagementException if the network request failed, the NFD response could not be decoded, or * the NFD rejected the request * @see <a href="http://named-data.net/doc/NFD/current/manpages/nfdc.html">nfdc command-line usage</a> * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice">StrategyChoice</a> */ public static void setStrategy(final Face face, final Name prefix, final Name strategy) throws ManagementException { // build command name Name command = new Name("/localhost/nfd/strategy-choice/set"); ControlParameters parameters = new ControlParameters(); parameters.setName(prefix); parameters.setStrategy(strategy); command.append(parameters.wireEncode()); try { sendCommand(face, command); } catch (IOException | EncodingException | ManagementException e) { throw new ManagementException(e.getMessage(), e); } }
/** * Create a new face on the given forwarder. Ensure the forwarding face is on * the local machine (management requests are to /localhost/...) and that * command signing has been set up (e.g. forwarder.setCommandSigningInfo()). * * @param face only a localhost {@link Face} * @param uri a string like "tcp4://host.name.com" (see nfd-status channels * for more protocol options) * @return the newly created face ID * @throws ManagementException if the network request failed, the NFD response could not be decoded, or * the NFD rejected the request */ public static int createFace(final Face face, final String uri) throws ManagementException { Name command = new Name("/localhost/nfd/faces/create"); ControlParameters parameters = new ControlParameters(); parameters.setUri(uri); command.append(parameters.wireEncode()); try { // send the interest ControlResponse response = sendCommand(face, command); // return return response.getBodyAsControlParameters().getFaceId(); } catch (IOException | EncodingException e) { throw new ManagementException(e.getMessage(), e); } }
/** * Register a route on a forwarder; this will create a new face on the * forwarder towards the face (e.g., self registration). * * @param face only a localhost {@link Face} * @param route the {@link Name} prefix of the route * @param cost the numeric cost of forwarding along the route * @throws ManagementException if the network request failed, the NFD response could not be decoded, or * the NFD rejected the request */ public static void register(final Face face, final Name route, final int cost) throws ManagementException { ForwardingFlags flags = new ForwardingFlags(); flags.setCapture(false); flags.setChildInherit(true); register(face, new ControlParameters() .setName(route) .setCost(cost) .setOrigin(RouteOrigin.APP.toInteger()) .setForwardingFlags(flags)); }
ControlParameters params = new ControlParameters(); try { params.wireDecode(interest.getName().get(CONTROL_PARAMETERS_NAME_OFFSET).getValue());
/** * Register a route on a forwarder; this will not create a new face since it * is provided a faceId. See register(Face, ControlParameters) for full * documentation. * * @param forwarder only a localhost {@link Face} * @param faceId the ID of the {@link Face} to assign to the route * @param route the {@link Name} prefix of the route * @param cost the numeric cost of forwarding along the route * @throws ManagementException if the network request failed, the NFD response could not be decoded, or * the NFD rejected the request */ public static void register(final Face forwarder, final int faceId, final Name route, final int cost) throws ManagementException { // build command name ControlParameters parameters = new ControlParameters(); parameters.setName(route); parameters.setFaceId(faceId); parameters.setCost(cost); parameters.setOrigin(RouteOrigin.STATIC.toInteger()); ForwardingFlags flags = new ForwardingFlags(); flags.setCapture(false); flags.setChildInherit(true); parameters.setForwardingFlags(flags); // run base method register(forwarder, parameters); }