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; }
/** * 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)); }
params.setFaceId(1); params.setOrigin(0); params.setCost(0); } catch (EncodingException e) { throw new IllegalArgumentException("", e);
/** * 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); }