Format to 2-space indents
diff --git a/nb-configuration.xml b/nb-configuration.xml
index ae9d239..a191290 100644
--- a/nb-configuration.xml
+++ b/nb-configuration.xml
@@ -14,5 +14,13 @@
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.license>intel-license</netbeans.hint.license>
+ <org-netbeans-modules-editor-indent.CodeStyle.usedProfile>project</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>
+ <org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab>2</org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab>
+ <org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>4</org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>
+ <org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width>2</org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width>
+ <org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs>true</org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs>
+ <org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>80</org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>
+ <org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap>none</org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap>
+ <org-netbeans-modules-editor-indent.text.x-fortran.CodeStyle.project.text-limit-width>132</org-netbeans-modules-editor-indent.text.x-fortran.CodeStyle.project.text-limit-width>
</properties>
</project-shared-configuration>
diff --git a/src/main/java/com/intel/jndn/management/EncodingHelper.java b/src/main/java/com/intel/jndn/management/EncodingHelper.java
index 66e3b9d..ca2275b 100644
--- a/src/main/java/com/intel/jndn/management/EncodingHelper.java
+++ b/src/main/java/com/intel/jndn/management/EncodingHelper.java
@@ -30,113 +30,113 @@
*/
public class EncodingHelper {
- /**
- * Helper to decode names since Tlv0_1_1WireFormat.java uses its own
- * internal, protected implementation.
- *
- * @param input
- * @return
- * @throws EncodingException
- */
- public static Name decodeName(ByteBuffer input) throws EncodingException {
- TlvDecoder decoder = new TlvDecoder(input);
- return decodeName(decoder);
- }
+ /**
+ * Helper to decode names since Tlv0_1_1WireFormat.java uses its own internal,
+ * protected implementation.
+ *
+ * @param input
+ * @return
+ * @throws EncodingException
+ */
+ public static Name decodeName(ByteBuffer input) throws EncodingException {
+ TlvDecoder decoder = new TlvDecoder(input);
+ return decodeName(decoder);
+ }
- /**
- * Helper to decode names using an existing decoding context; could be
- * merged to Tlv0_1_1WireFormat.java.
- *
- * @param decoder
- * @return
- * @throws EncodingException
- */
- public static Name decodeName(TlvDecoder decoder) throws EncodingException {
- Name name = new Name();
- int endOffset = decoder.readNestedTlvsStart(Tlv.Name);
- while (decoder.getOffset() < endOffset) {
- name.append(new Blob(decoder.readBlobTlv(Tlv.NameComponent), true));
- }
+ /**
+ * Helper to decode names using an existing decoding context; could be merged
+ * to Tlv0_1_1WireFormat.java.
+ *
+ * @param decoder
+ * @return
+ * @throws EncodingException
+ */
+ public static Name decodeName(TlvDecoder decoder) throws EncodingException {
+ Name name = new Name();
+ int endOffset = decoder.readNestedTlvsStart(Tlv.Name);
+ while (decoder.getOffset() < endOffset) {
+ name.append(new Blob(decoder.readBlobTlv(Tlv.NameComponent), true));
+ }
- decoder.finishNestedTlvs(endOffset);
- return name;
- }
+ decoder.finishNestedTlvs(endOffset);
+ return name;
+ }
- /**
- * Helper to encode names since Tlv0_1_1WireFormat.java uses its own
- * internal, protected implementation.
- *
- * @param name
- * @return
- */
- public static Blob encodeName(Name name) {
- TlvEncoder encoder = new TlvEncoder();
- encodeName(name, encoder);
- return new Blob(encoder.getOutput(), false);
- }
+ /**
+ * Helper to encode names since Tlv0_1_1WireFormat.java uses its own internal,
+ * protected implementation.
+ *
+ * @param name
+ * @return
+ */
+ public static Blob encodeName(Name name) {
+ TlvEncoder encoder = new TlvEncoder();
+ encodeName(name, encoder);
+ return new Blob(encoder.getOutput(), false);
+ }
- /**
- * Helper to encode names using an existing encoding context; could be
- * merged to Tlv0_1_1WireFormat.java.
- *
- * @param name
- * @param encoder
- */
- public static final void encodeName(Name name, TlvEncoder encoder) {
- int saveLength = encoder.getLength();
- for (int i = name.size() - 1; i >= 0; --i) {
- encoder.writeBlobTlv(Tlv.NameComponent, name.get(i).getValue().buf());
- }
- encoder.writeTypeAndLength(Tlv.Name, encoder.getLength() - saveLength);
- }
+ /**
+ * Helper to encode names using an existing encoding context; could be merged
+ * to Tlv0_1_1WireFormat.java.
+ *
+ * @param name
+ * @param encoder
+ */
+ public static final void encodeName(Name name, TlvEncoder encoder) {
+ int saveLength = encoder.getLength();
+ for (int i = name.size() - 1; i >= 0; --i) {
+ encoder.writeBlobTlv(Tlv.NameComponent, name.get(i).getValue().buf());
+ }
+ encoder.writeTypeAndLength(Tlv.Name, encoder.getLength() - saveLength);
+ }
- /**
- * Helper to encode control parameters using an existing encoding context;
- * could be merged to Tlv0_1_1WireFormat.java.
- *
- * @param controlParameters
- * @param encoder
- */
- public static final void encodeControlParameters(ControlParameters controlParameters, TlvEncoder encoder) {
- int saveLength = encoder.getLength();
+ /**
+ * Helper to encode control parameters using an existing encoding context;
+ * could be merged to Tlv0_1_1WireFormat.java.
+ *
+ * @param controlParameters
+ * @param encoder
+ */
+ public static final void encodeControlParameters(ControlParameters controlParameters, TlvEncoder encoder) {
+ int saveLength = encoder.getLength();
- // Encode backwards.
- encoder.writeOptionalNonNegativeIntegerTlvFromDouble(Tlv.ControlParameters_ExpirationPeriod,
- controlParameters.getExpirationPeriod());
+ // Encode backwards.
+ encoder.writeOptionalNonNegativeIntegerTlvFromDouble(Tlv.ControlParameters_ExpirationPeriod,
+ controlParameters.getExpirationPeriod());
- // Encode strategy
- if (controlParameters.getStrategy().size() != 0) {
- int strategySaveLength = encoder.getLength();
- encodeName(controlParameters.getStrategy(), encoder);
- encoder.writeTypeAndLength(Tlv.ControlParameters_Strategy,
- encoder.getLength() - strategySaveLength);
- }
+ // Encode strategy
+ if (controlParameters.getStrategy().size() != 0) {
+ int strategySaveLength = encoder.getLength();
+ encodeName(controlParameters.getStrategy(), encoder);
+ encoder.writeTypeAndLength(Tlv.ControlParameters_Strategy,
+ encoder.getLength() - strategySaveLength);
+ }
- // Encode ForwardingFlags
- int flags = controlParameters.getForwardingFlags().getNfdForwardingFlags();
- if (flags != new ForwardingFlags().getNfdForwardingFlags()) // The flags are not the default value.
- {
- encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_Flags, flags);
- }
+ // Encode ForwardingFlags
+ int flags = controlParameters.getForwardingFlags().getNfdForwardingFlags();
+ if (flags != new ForwardingFlags().getNfdForwardingFlags()) // The flags are not the default value.
+ {
+ encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_Flags, flags);
+ }
- encoder.writeOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_Cost, controlParameters.getCost());
- encoder.writeOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_Origin, controlParameters.getOrigin());
- encoder.writeOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_LocalControlFeature,
- controlParameters.getLocalControlFeature());
+ encoder.writeOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_Cost, controlParameters.getCost());
+ encoder.writeOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_Origin, controlParameters.getOrigin());
+ encoder.writeOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_LocalControlFeature,
+ controlParameters.getLocalControlFeature());
- // Encode URI
- if (!controlParameters.getUri().isEmpty()) {
- encoder.writeBlobTlv(Tlv.ControlParameters_Uri,
- new Blob(controlParameters.getUri()).buf());
- }
+ // Encode URI
+ if (!controlParameters.getUri().isEmpty()) {
+ encoder.writeBlobTlv(Tlv.ControlParameters_Uri,
+ new Blob(controlParameters.getUri()).buf());
+ }
- encoder.writeOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_FaceId, controlParameters.getFaceId());
+ encoder.writeOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_FaceId, controlParameters.getFaceId());
- // Encode name
- if (controlParameters.getName().size() != 0) {
- encodeName(controlParameters.getName(), encoder);
- }
+ // Encode name
+ if (controlParameters.getName().size() != 0) {
+ encodeName(controlParameters.getName(), encoder);
+ }
- encoder.writeTypeAndLength(Tlv.ControlParameters_ControlParameters, encoder.getLength() - saveLength);
- }
+ encoder.writeTypeAndLength(Tlv.ControlParameters_ControlParameters, encoder.getLength() - saveLength);
+ }
}
diff --git a/src/main/java/com/intel/jndn/management/NFD.java b/src/main/java/com/intel/jndn/management/NFD.java
index b5f531f..8f8cdab 100644
--- a/src/main/java/com/intel/jndn/management/NFD.java
+++ b/src/main/java/com/intel/jndn/management/NFD.java
@@ -37,298 +37,298 @@
*/
public class NFD {
- public final static long DEFAULT_TIMEOUT = 2000;
- static private final Logger logger = Logger.getLogger(NFD.class.getName());
+ public final static long DEFAULT_TIMEOUT = 2000;
+ static private final Logger logger = Logger.getLogger(NFD.class.getName());
- /**
- * Ping a forwarder on an existing face to verify that the forwarder is
- * working and responding to requests; this version sends a discovery packet
- * to /localhost/nfd which should always respond if the requestor is on the
- * same machine as the NDN forwarding daemon.
- *
- * @param face
- * @return true if successful, false otherwise
- */
- public static boolean pingLocal(Face face) {
- return ping(face, new Name("/localhost/nfd"));
- }
+ /**
+ * Ping a forwarder on an existing face to verify that the forwarder is
+ * working and responding to requests; this version sends a discovery packet
+ * to /localhost/nfd which should always respond if the requestor is on the
+ * same machine as the NDN forwarding daemon.
+ *
+ * @param face
+ * @return true if successful, false otherwise
+ */
+ public static boolean pingLocal(Face face) {
+ return ping(face, new Name("/localhost/nfd"));
+ }
- /**
- * Request a name on an existing face to verify the forwarder is working and
- * responding to requests. Note that the name must be served or cached on
- * the forwarder for this to return true.
- *
- * @param face
- * @param name
- * @return true if successful, false otherwise
- */
- public static boolean ping(Face face, Name name) {
- // build interest
- Interest interest = new Interest(name);
- interest.setInterestLifetimeMilliseconds(DEFAULT_TIMEOUT);
- interest.setMustBeFresh(true);
+ /**
+ * Request a name on an existing face to verify the forwarder is working and
+ * responding to requests. Note that the name must be served or cached on the
+ * forwarder for this to return true.
+ *
+ * @param face
+ * @param name
+ * @return true if successful, false otherwise
+ */
+ public static boolean ping(Face face, Name name) {
+ // build interest
+ Interest interest = new Interest(name);
+ interest.setInterestLifetimeMilliseconds(DEFAULT_TIMEOUT);
+ interest.setMustBeFresh(true);
- // send packet
- Data data = Client.getDefault().getSync(face, interest);
- return data != null;
- }
+ // send packet
+ Data data = Client.getDefault().getSync(face, interest);
+ return data != null;
+ }
- /**
- * Retrieve a list of faces and their status from the given forwarder; calls
- * /localhost/nfd/faces/list which requires a local Face (all non-local
- * packets are dropped)
- *
- * @param forwarder Only a localhost Face
- * @return
- * @throws Exception
- */
- public static List<FaceStatus> getFaceList(Face forwarder) throws Exception {
- // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
- Interest interest = new Interest(new Name("/localhost/nfd/faces/list"));
- interest.setMustBeFresh(true);
- interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
- interest.setInterestLifetimeMilliseconds(DEFAULT_TIMEOUT);
+ /**
+ * Retrieve a list of faces and their status from the given forwarder; calls
+ * /localhost/nfd/faces/list which requires a local Face (all non-local
+ * packets are dropped)
+ *
+ * @param forwarder Only a localhost Face
+ * @return
+ * @throws Exception
+ */
+ public static List<FaceStatus> getFaceList(Face forwarder) throws Exception {
+ // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
+ Interest interest = new Interest(new Name("/localhost/nfd/faces/list"));
+ interest.setMustBeFresh(true);
+ interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
+ interest.setInterestLifetimeMilliseconds(DEFAULT_TIMEOUT);
// TODO verify that all faces are being returned; right now they don't
- // match up with the results from nfd-status-http-server but no
- // additional segments are present;
- // see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
- // send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
- if (data == null) {
- throw new Exception("Failed to retrieve list of faces from the forwarder.");
- }
+ // match up with the results from nfd-status-http-server but no
+ // additional segments are present;
+ // see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
+ // send packet
+ Data data = Client.getDefault().getSync(forwarder, interest);
+ if (data == null) {
+ throw new Exception("Failed to retrieve list of faces from the forwarder.");
+ }
- // parse packet
- return StatusDataset.wireDecode(data.getContent(), FaceStatus.class);
- }
+ // parse packet
+ return StatusDataset.wireDecode(data.getContent(), FaceStatus.class);
+ }
- /**
- * Retrieve a list of routing entries from the RIB; calls
- * /localhost/nfd/rib/list which requires a local Face (all non-local
- * packets are dropped)
- *
- * @param forwarder Only a localhost Face
- * @return
- * @throws Exception
- */
- public static List<RibEntry> getRouteList(Face forwarder) throws Exception {
- // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
- Interest interest = new Interest(new Name("/localhost/nfd/rib/list"));
- interest.setMustBeFresh(true);
- interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
- interest.setInterestLifetimeMilliseconds(DEFAULT_TIMEOUT);
+ /**
+ * Retrieve a list of routing entries from the RIB; calls
+ * /localhost/nfd/rib/list which requires a local Face (all non-local packets
+ * are dropped)
+ *
+ * @param forwarder Only a localhost Face
+ * @return
+ * @throws Exception
+ */
+ public static List<RibEntry> getRouteList(Face forwarder) throws Exception {
+ // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
+ Interest interest = new Interest(new Name("/localhost/nfd/rib/list"));
+ interest.setMustBeFresh(true);
+ interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
+ interest.setInterestLifetimeMilliseconds(DEFAULT_TIMEOUT);
- // send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
- if (data == null) {
- throw new Exception("Failed to retrieve list of faces from the forwarder.");
- }
+ // send packet
+ Data data = Client.getDefault().getSync(forwarder, interest);
+ if (data == null) {
+ throw new Exception("Failed to retrieve list of faces from the forwarder.");
+ }
- // parse packet
- return StatusDataset.wireDecode(data.getContent(), RibEntry.class);
- }
+ // parse packet
+ return StatusDataset.wireDecode(data.getContent(), RibEntry.class);
+ }
- /**
- * Helper method to register a new face on the forwarder; as mentioned at
- * http://named-data.net/doc/NFD/current/manpages/nfdc.html, this is more
- * for debugging; use 'register' instead
- *
- * @param forwarder Only a localhost Face
- * @param faceId
- * @param prefix
- * @return
- * @throws Exception
- */
- public static boolean addNextHop(Face forwarder, int faceId, Name prefix) throws Exception {
- // build command name
- Name command = new Name("/localhost/nfd/fib/add-nexthop");
- ControlParameters parameters = new ControlParameters();
- parameters.setName(prefix);
- parameters.setFaceId(faceId);
- command.append(parameters.wireEncode());
+ /**
+ * Helper method to register a new face on the forwarder; as mentioned at
+ * http://named-data.net/doc/NFD/current/manpages/nfdc.html, this is more for
+ * debugging; use 'register' instead
+ *
+ * @param forwarder Only a localhost Face
+ * @param faceId
+ * @param prefix
+ * @return
+ * @throws Exception
+ */
+ public static boolean addNextHop(Face forwarder, int faceId, Name prefix) throws Exception {
+ // build command name
+ Name command = new Name("/localhost/nfd/fib/add-nexthop");
+ ControlParameters parameters = new ControlParameters();
+ parameters.setName(prefix);
+ parameters.setFaceId(faceId);
+ command.append(parameters.wireEncode());
- // send the interest
- return sendCommandAndErrorCheck(forwarder, new Interest(command));
- }
+ // send the interest
+ return sendCommandAndErrorCheck(forwarder, new Interest(command));
+ }
- /**
- * 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 forwarder Only a localhost Face
- * @param uri
- * @return
- * @throws java.lang.Exception
- */
- public static int createFace(Face forwarder, String uri) throws Exception {
- Name command = new Name("/localhost/nfd/faces/create");
- ControlParameters parameters = new ControlParameters();
- parameters.setUri(uri);
- command.append(parameters.wireEncode());
+ /**
+ * 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 forwarder Only a localhost Face
+ * @param uri
+ * @return
+ * @throws java.lang.Exception
+ */
+ public static int createFace(Face forwarder, String uri) throws Exception {
+ Name command = new Name("/localhost/nfd/faces/create");
+ ControlParameters parameters = new ControlParameters();
+ parameters.setUri(uri);
+ command.append(parameters.wireEncode());
- // send the interest
- ControlResponse response = sendCommand(forwarder, new Interest(command));
+ // send the interest
+ ControlResponse response = sendCommand(forwarder, new Interest(command));
- // check for body and that status code is OK (TODO: 200 should be replaced with a CONSTANT like ControlResponse.STATUS_OK)
- if (response.getBody().isEmpty() || response.getStatusCode() != 200) {
- throw new Exception("Failed to create face: " + uri + " " + response.getStatusText());
- }
+ // check for body and that status code is OK (TODO: 200 should be replaced with a CONSTANT like ControlResponse.STATUS_OK)
+ if (response.getBody().isEmpty() || response.getStatusCode() != 200) {
+ throw new Exception("Failed to create face: " + uri + " " + response.getStatusText());
+ }
- // return
- return response.getBody().get(0).getFaceId();
- }
+ // return
+ return response.getBody().get(0).getFaceId();
+ }
- /**
- * Register a route on the forwarder; see
- * http://named-data.net/doc/NFD/current/manpages/nfdc.html for command-line
- * usage and http://redmine.named-data.net/projects/nfd/wiki/RibMgmt for
- * protocol documentation. 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 forwarder Only a localhost Face
- * @param controlParameters
- * @return
- * @throws Exception
- */
- public static boolean register(Face forwarder, ControlParameters controlParameters) throws Exception {
- // build command name
- Name command = new Name("/localhost/nfd/rib/register");
- command.append(controlParameters.wireEncode());
+ /**
+ * Register a route on the forwarder; see
+ * http://named-data.net/doc/NFD/current/manpages/nfdc.html for command-line
+ * usage and http://redmine.named-data.net/projects/nfd/wiki/RibMgmt for
+ * protocol documentation. 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 forwarder Only a localhost Face
+ * @param controlParameters
+ * @return
+ * @throws Exception
+ */
+ public static boolean register(Face forwarder, ControlParameters controlParameters) throws Exception {
+ // build command name
+ Name command = new Name("/localhost/nfd/rib/register");
+ command.append(controlParameters.wireEncode());
- // send the interest
- return sendCommandAndErrorCheck(forwarder, new Interest(command));
- }
+ // send the interest
+ return sendCommandAndErrorCheck(forwarder, new Interest(command));
+ }
- /**
- * Register a route on a forwarder; this will create a new face on the
- * forwarder to the given URI/route pair. See register(Face,
- * ControlParameters) for more details documentation.
- *
- * @param forwarder Only a localhost Face
- * @param uri
- * @param cost
- * @param route
- * @return true for successful registration
- * @throws java.lang.Exception
- */
- public static boolean register(Face forwarder, String uri, Name route, int cost) throws Exception {
- // create the new face
- int faceId = createFace(forwarder, uri);
+ /**
+ * Register a route on a forwarder; this will create a new face on the
+ * forwarder to the given URI/route pair. See register(Face,
+ * ControlParameters) for more details documentation.
+ *
+ * @param forwarder Only a localhost Face
+ * @param uri
+ * @param cost
+ * @param route
+ * @return true for successful registration
+ * @throws java.lang.Exception
+ */
+ public static boolean register(Face forwarder, String uri, Name route, int cost) throws Exception {
+ // create the new face
+ int faceId = createFace(forwarder, uri);
- // run base method
- return register(forwarder, faceId, route, cost);
- }
+ // run base method
+ return register(forwarder, faceId, route, cost);
+ }
- /**
- * 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 Face
- * @param faceId
- * @param route
- * @param cost
- * @return true for successful registration
- * @throws java.lang.Exception
- */
- public static boolean register(Face forwarder, int faceId, Name route, int cost) throws Exception {
- // build command name
- ControlParameters parameters = new ControlParameters();
- parameters.setName(route);
- parameters.setFaceId(faceId);
- parameters.setCost(cost);
- ForwardingFlags flags = new ForwardingFlags();
- flags.setCapture(true);
- flags.setChildInherit(true);
- parameters.setForwardingFlags(flags);
+ /**
+ * 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 Face
+ * @param faceId
+ * @param route
+ * @param cost
+ * @return true for successful registration
+ * @throws java.lang.Exception
+ */
+ public static boolean register(Face forwarder, int faceId, Name route, int cost) throws Exception {
+ // build command name
+ ControlParameters parameters = new ControlParameters();
+ parameters.setName(route);
+ parameters.setFaceId(faceId);
+ parameters.setCost(cost);
+ ForwardingFlags flags = new ForwardingFlags();
+ flags.setCapture(true);
+ flags.setChildInherit(true);
+ parameters.setForwardingFlags(flags);
- // run base method
- return register(forwarder, parameters);
- }
+ // run base method
+ return register(forwarder, parameters);
+ }
- /**
- * Set a strategy on the forwarder; see
- * http://named-data.net/doc/NFD/current/manpages/nfdc.html for command-line
- * usage and http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice
- * for protocol documentation. 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 forwarder Only a localhost Face
- * @param prefix
- * @param strategy
- * @return true for successful command
- * @throws Exception
- */
- public static boolean setStrategy(Face forwarder, Name prefix, Name strategy) throws Exception {
- // 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());
+ /**
+ * Set a strategy on the forwarder; see
+ * http://named-data.net/doc/NFD/current/manpages/nfdc.html for command-line
+ * usage and http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice
+ * for protocol documentation. 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 forwarder Only a localhost Face
+ * @param prefix
+ * @param strategy
+ * @return true for successful command
+ * @throws Exception
+ */
+ public static boolean setStrategy(Face forwarder, Name prefix, Name strategy) throws Exception {
+ // 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());
- // send the interest
- return sendCommandAndErrorCheck(forwarder, new Interest(command));
- }
+ // send the interest
+ return sendCommandAndErrorCheck(forwarder, new Interest(command));
+ }
- /**
- * Send an interest as a command to the forwarder; this method will convert
- * the interest to a command interest and block until a response is received
- * from the 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 forwarder Only a localhost Face
- * @param interest As described at
- * http://redmine.named-data.net/projects/nfd/wiki/ControlCommand, the
- * requested interest must have encoded ControlParameters appended to the
- * interest name
- * @return
- * @throws net.named_data.jndn.security.SecurityException
- * @throws java.io.IOException
- * @throws net.named_data.jndn.encoding.EncodingException
- */
- public static ControlResponse sendCommand(Face forwarder, Interest interest) throws SecurityException, IOException, EncodingException {
- forwarder.makeCommandInterest(interest);
+ /**
+ * Send an interest as a command to the forwarder; this method will convert
+ * the interest to a command interest and block until a response is received
+ * from the 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 forwarder Only a localhost Face
+ * @param interest As described at
+ * http://redmine.named-data.net/projects/nfd/wiki/ControlCommand, the
+ * requested interest must have encoded ControlParameters appended to the
+ * interest name
+ * @return
+ * @throws net.named_data.jndn.security.SecurityException
+ * @throws java.io.IOException
+ * @throws net.named_data.jndn.encoding.EncodingException
+ */
+ public static ControlResponse sendCommand(Face forwarder, Interest interest) throws SecurityException, IOException, EncodingException {
+ forwarder.makeCommandInterest(interest);
- // send command packet
- Data data = Client.getDefault().getSync(forwarder, interest);
- if (data == null) {
- throw new IOException("Failed to receive command response.");
- }
+ // send command packet
+ Data data = Client.getDefault().getSync(forwarder, interest);
+ if (data == null) {
+ throw new IOException("Failed to receive command response.");
+ }
- // return response
- ControlResponse response = new ControlResponse();
- response.wireDecode(data.getContent().buf());
- return response;
- }
+ // return response
+ ControlResponse response = new ControlResponse();
+ response.wireDecode(data.getContent().buf());
+ return response;
+ }
- /**
- * Send an interest as a command to the forwarder; this method will convert
- * the interest to a command interest and block until a response is received
- * from the forwarder.
- *
- * @param forwarder Only a localhost Face
- * @param interest As described at
- * http://redmine.named-data.net/projects/nfd/wiki/ControlCommand, the
- * requested interest must have encoded ControlParameters appended to the
- * interest name
- * @return
- * @throws net.named_data.jndn.security.SecurityException
- * @throws java.io.IOException
- * @throws net.named_data.jndn.encoding.EncodingException
- */
- public static boolean sendCommandAndErrorCheck(Face forwarder, Interest interest) throws SecurityException, IOException, EncodingException {
- ControlResponse response = sendCommand(forwarder, interest);
- if (response.getStatusCode() < 400) {
- return true;
- } else {
- logger.warning("Command sent but failed: " + response.getStatusCode() + " " + response.getStatusText());
- return false;
- }
- }
+ /**
+ * Send an interest as a command to the forwarder; this method will convert
+ * the interest to a command interest and block until a response is received
+ * from the forwarder.
+ *
+ * @param forwarder Only a localhost Face
+ * @param interest As described at
+ * http://redmine.named-data.net/projects/nfd/wiki/ControlCommand, the
+ * requested interest must have encoded ControlParameters appended to the
+ * interest name
+ * @return
+ * @throws net.named_data.jndn.security.SecurityException
+ * @throws java.io.IOException
+ * @throws net.named_data.jndn.encoding.EncodingException
+ */
+ public static boolean sendCommandAndErrorCheck(Face forwarder, Interest interest) throws SecurityException, IOException, EncodingException {
+ ControlResponse response = sendCommand(forwarder, interest);
+ if (response.getStatusCode() < 400) {
+ return true;
+ } else {
+ logger.warning("Command sent but failed: " + response.getStatusCode() + " " + response.getStatusText());
+ return false;
+ }
+ }
}
diff --git a/src/main/java/com/intel/jndn/management/types/ControlResponse.java b/src/main/java/com/intel/jndn/management/types/ControlResponse.java
index 425f2d1..f068824 100644
--- a/src/main/java/com/intel/jndn/management/types/ControlResponse.java
+++ b/src/main/java/com/intel/jndn/management/types/ControlResponse.java
@@ -30,138 +30,138 @@
*/
public class ControlResponse {
- /**
- * Use TLV codes from jndn.encoding.tlv.Tlv.java See
- * http://redmine.named-data.net/projects/nfd/wiki/ControlCommand
- */
- public final static int TLV_CONTROL_RESPONSE = 101;
- public final static int TLV_CONTROL_RESPONSE_STATUS_CODE = 102;
- public final static int TLV_CONTROL_RESPONSE_STATUS_TEXT = 103;
+ /**
+ * Use TLV codes from jndn.encoding.tlv.Tlv.java See
+ * http://redmine.named-data.net/projects/nfd/wiki/ControlCommand
+ */
+ public final static int TLV_CONTROL_RESPONSE = 101;
+ public final static int TLV_CONTROL_RESPONSE_STATUS_CODE = 102;
+ public final static int TLV_CONTROL_RESPONSE_STATUS_TEXT = 103;
- /**
- * Encode using a new TLV encoder.
- *
- * @return The encoded buffer.
- */
- public final Blob wireEncode() {
- TlvEncoder encoder = new TlvEncoder();
- wireEncode(encoder);
- return new Blob(encoder.getOutput(), false);
- }
+ /**
+ * Encode using a new TLV encoder.
+ *
+ * @return The encoded buffer.
+ */
+ public final Blob wireEncode() {
+ TlvEncoder encoder = new TlvEncoder();
+ wireEncode(encoder);
+ return new Blob(encoder.getOutput(), false);
+ }
- /**
- * Encode as part of an existing encode context.
- *
- * @param encoder
- */
- public final void wireEncode(TlvEncoder encoder) {
- int saveLength = encoder.getLength();
- for (ControlParameters parameters : body) {
- EncodingHelper.encodeControlParameters(parameters, encoder);
- }
- encoder.writeBlobTlv(TLV_CONTROL_RESPONSE_STATUS_TEXT, new Blob(statusText).buf());
- encoder.writeNonNegativeIntegerTlv(TLV_CONTROL_RESPONSE_STATUS_CODE, statusCode);
- encoder.writeTypeAndLength(TLV_CONTROL_RESPONSE, encoder.getLength() - saveLength);
- }
+ /**
+ * Encode as part of an existing encode context.
+ *
+ * @param encoder
+ */
+ public final void wireEncode(TlvEncoder encoder) {
+ int saveLength = encoder.getLength();
+ for (ControlParameters parameters : body) {
+ EncodingHelper.encodeControlParameters(parameters, encoder);
+ }
+ encoder.writeBlobTlv(TLV_CONTROL_RESPONSE_STATUS_TEXT, new Blob(statusText).buf());
+ encoder.writeNonNegativeIntegerTlv(TLV_CONTROL_RESPONSE_STATUS_CODE, statusCode);
+ encoder.writeTypeAndLength(TLV_CONTROL_RESPONSE, encoder.getLength() - saveLength);
+ }
- /**
- * Decode the input from its TLV format.
- *
- * @param input The input buffer to decode. This reads from position() to
- * limit(), but does not change the position.
- * @throws net.named_data.jndn.encoding.EncodingException
- */
- public final void wireDecode(ByteBuffer input) throws EncodingException {
- TlvDecoder decoder = new TlvDecoder(input);
- wireDecode(decoder, input);
- }
+ /**
+ * Decode the input from its TLV format.
+ *
+ * @param input The input buffer to decode. This reads from position() to
+ * limit(), but does not change the position.
+ * @throws net.named_data.jndn.encoding.EncodingException
+ */
+ public final void wireDecode(ByteBuffer input) throws EncodingException {
+ TlvDecoder decoder = new TlvDecoder(input);
+ wireDecode(decoder, input);
+ }
- /**
- * Decode as part of an existing decode context.
- *
- * @param decoder
- * @param input the WireFormat version that decodes ControlParameters does
- * not allow passing a TlvDecoder, so we must pass the buffer itself
- * @throws EncodingException
- */
- public void wireDecode(TlvDecoder decoder, ByteBuffer input) throws EncodingException {
- int endOffset = decoder.readNestedTlvsStart(TLV_CONTROL_RESPONSE);
+ /**
+ * Decode as part of an existing decode context.
+ *
+ * @param decoder
+ * @param input the WireFormat version that decodes ControlParameters does not
+ * allow passing a TlvDecoder, so we must pass the buffer itself
+ * @throws EncodingException
+ */
+ public void wireDecode(TlvDecoder decoder, ByteBuffer input) throws EncodingException {
+ int endOffset = decoder.readNestedTlvsStart(TLV_CONTROL_RESPONSE);
- // parse known TLVs
- this.statusCode = (int) decoder.readNonNegativeIntegerTlv(TLV_CONTROL_RESPONSE_STATUS_CODE);
- Blob statusText_ = new Blob(decoder.readBlobTlv(TLV_CONTROL_RESPONSE_STATUS_TEXT), true); // copy because buffer is immutable
- this.statusText = statusText_.toString();
+ // parse known TLVs
+ this.statusCode = (int) decoder.readNonNegativeIntegerTlv(TLV_CONTROL_RESPONSE_STATUS_CODE);
+ Blob statusText_ = new Blob(decoder.readBlobTlv(TLV_CONTROL_RESPONSE_STATUS_TEXT), true); // copy because buffer is immutable
+ this.statusText = statusText_.toString();
- // use the already-written decoder for ControlParameters (but we have to copy the buffer)
- while (decoder.peekType(Tlv.ControlParameters_ControlParameters, endOffset)) {
- ByteBuffer copyInput = input.duplicate();
- copyInput.position(decoder.getOffset());
- int internalEndOffset = decoder.readNestedTlvsStart(Tlv.ControlParameters_ControlParameters);
- ControlParameters copyParameters = new ControlParameters();
- copyParameters.wireDecode(copyInput);
- this.body.add(copyParameters);
- decoder.seek(internalEndOffset);
- decoder.finishNestedTlvs(internalEndOffset);
- }
+ // use the already-written decoder for ControlParameters (but we have to copy the buffer)
+ while (decoder.peekType(Tlv.ControlParameters_ControlParameters, endOffset)) {
+ ByteBuffer copyInput = input.duplicate();
+ copyInput.position(decoder.getOffset());
+ int internalEndOffset = decoder.readNestedTlvsStart(Tlv.ControlParameters_ControlParameters);
+ ControlParameters copyParameters = new ControlParameters();
+ copyParameters.wireDecode(copyInput);
+ this.body.add(copyParameters);
+ decoder.seek(internalEndOffset);
+ decoder.finishNestedTlvs(internalEndOffset);
+ }
- decoder.finishNestedTlvs(endOffset);
- }
+ decoder.finishNestedTlvs(endOffset);
+ }
- /**
- * Get status code
- *
- * @return
- */
- public int getStatusCode() {
- return statusCode;
- }
+ /**
+ * Get status code
+ *
+ * @return
+ */
+ public int getStatusCode() {
+ return statusCode;
+ }
- /**
- * Set status code
- *
- * @param statusCode
- */
- public void setStatusCode(int statusCode) {
- this.statusCode = statusCode;
- }
+ /**
+ * Set status code
+ *
+ * @param statusCode
+ */
+ public void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
- /**
- * Get status text
- *
- * @return
- */
- public String getStatusText() {
- return statusText;
- }
+ /**
+ * Get status text
+ *
+ * @return
+ */
+ public String getStatusText() {
+ return statusText;
+ }
- /**
- * Set status text
- *
- * @param statusText
- */
- public void setStatusText(String statusText) {
- this.statusText = statusText;
- }
+ /**
+ * Set status text
+ *
+ * @param statusText
+ */
+ public void setStatusText(String statusText) {
+ this.statusText = statusText;
+ }
- /**
- * Get body
- *
- * @return
- */
- public List<ControlParameters> getBody() {
- return body;
- }
+ /**
+ * Get body
+ *
+ * @return
+ */
+ public List<ControlParameters> getBody() {
+ return body;
+ }
- /**
- * Set body
- *
- * @param body
- */
- public void setBody(List<ControlParameters> body) {
- this.body = body;
- }
+ /**
+ * Set body
+ *
+ * @param body
+ */
+ public void setBody(List<ControlParameters> body) {
+ this.body = body;
+ }
- private int statusCode = -1;
- private String statusText = "";
- private List<ControlParameters> body = new ArrayList<>();
+ private int statusCode = -1;
+ private String statusText = "";
+ private List<ControlParameters> body = new ArrayList<>();
}
diff --git a/src/main/java/com/intel/jndn/management/types/Decodable.java b/src/main/java/com/intel/jndn/management/types/Decodable.java
index 17bb0fa..5aac4d6 100644
--- a/src/main/java/com/intel/jndn/management/types/Decodable.java
+++ b/src/main/java/com/intel/jndn/management/types/Decodable.java
@@ -21,5 +21,6 @@
* @author Andrew Brown <andrew.brown@intel.com>
*/
public interface Decodable {
- public void wireDecode(TlvDecoder decoder) throws EncodingException;
+
+ public void wireDecode(TlvDecoder decoder) throws EncodingException;
}
diff --git a/src/main/java/com/intel/jndn/management/types/FacePersistency.java b/src/main/java/com/intel/jndn/management/types/FacePersistency.java
index d663acc..61dbc3e 100644
--- a/src/main/java/com/intel/jndn/management/types/FacePersistency.java
+++ b/src/main/java/com/intel/jndn/management/types/FacePersistency.java
@@ -11,22 +11,23 @@
package com.intel.jndn.management.types;
/**
- * Indicate whether the face is persistent; used by FaceStatus
- * See http://redmine.named-data.net/projects/nfd/widi/FaceMgmt
+ * Indicate whether the face is persistent; used by FaceStatus See
+ * http://redmine.named-data.net/projects/nfd/widi/FaceMgmt
+ *
* @author Andrew Brown <andrew.brown@intel.com>
*/
public enum FacePersistency {
- PERSISTENT(0),
- ON_DEMAND(1),
- PERMANENT(2);
+ PERSISTENT(0),
+ ON_DEMAND(1),
+ PERMANENT(2);
- FacePersistency(int value) {
- value_ = value;
- }
+ FacePersistency(int value) {
+ value_ = value;
+ }
- public final int getNumericValue() {
- return value_;
- }
- private final int value_;
+ public final int getNumericValue() {
+ return value_;
+ }
+ private final int value_;
}
diff --git a/src/main/java/com/intel/jndn/management/types/FaceScope.java b/src/main/java/com/intel/jndn/management/types/FaceScope.java
index 100befc..fec0acd 100644
--- a/src/main/java/com/intel/jndn/management/types/FaceScope.java
+++ b/src/main/java/com/intel/jndn/management/types/FaceScope.java
@@ -11,22 +11,22 @@
package com.intel.jndn.management.types;
/**
- * Indicate whether the face is local for scope control purposes; used by FaceStatus
- * See http://redmine.named-data.net/projects/nfd/widi/FaceMgmt
+ * Indicate whether the face is local for scope control purposes; used by
+ * FaceStatus See http://redmine.named-data.net/projects/nfd/widi/FaceMgmt
*
* @author andrew
*/
public enum FaceScope {
- LOCAL(0),
- NON_LOCAL(1);
+ LOCAL(0),
+ NON_LOCAL(1);
- FaceScope(int value) {
- value_ = value;
- }
+ FaceScope(int value) {
+ value_ = value;
+ }
- public final int getNumericValue() {
- return value_;
- }
- private final int value_;
+ public final int getNumericValue() {
+ return value_;
+ }
+ private final int value_;
}
diff --git a/src/main/java/com/intel/jndn/management/types/FaceStatus.java b/src/main/java/com/intel/jndn/management/types/FaceStatus.java
index 6883d54..83b60e5 100644
--- a/src/main/java/com/intel/jndn/management/types/FaceStatus.java
+++ b/src/main/java/com/intel/jndn/management/types/FaceStatus.java
@@ -22,349 +22,350 @@
*
* @author Andrew Brown <andrew.brown@intel.com>
*/
-public class FaceStatus implements Decodable{
+public class FaceStatus implements Decodable {
- /**
- * Spec from http://redmine.named-data.net/projects/nfd/wiki/ControlCommand
- */
- public static final int TLV_FACE_ID = 105;
- public static final int TLV_URI = 114;
- public static final int TLV_EXPIRATION_PERIOD = 109;
+ /**
+ * Spec from http://redmine.named-data.net/projects/nfd/wiki/ControlCommand
+ */
+ public static final int TLV_FACE_ID = 105;
+ public static final int TLV_URI = 114;
+ public static final int TLV_EXPIRATION_PERIOD = 109;
- /**
- * Spec from http://redmine.named-data.net/projects/nfd/widi/FaceMgmt
- */
- public static final int TLV_FACE_STATUS = 128;
- public static final int TLV_LOCAL_URI = 129;
- public static final int TLV_CHANNEL_STATUS = 130;
- public static final int TLV_FACE_SCOPE = 132;
- public static final int TLV_FACE_PERSISTENCY = 133;
- public static final int TLV_LINK_TYPE = 134;
- public static final int TLV_N_IN_INTERESTS = 144;
- public static final int TLV_N_IN_DATAS = 145;
- public static final int TLV_N_OUT_INTERESTS = 146;
- public static final int TLV_N_OUT_DATAS = 147;
- public static final int TLV_N_IN_BYTES = 148;
- public static final int TLV_N_OUT_BYTES = 149;
+ /**
+ * Spec from http://redmine.named-data.net/projects/nfd/widi/FaceMgmt
+ */
+ public static final int TLV_FACE_STATUS = 128;
+ public static final int TLV_LOCAL_URI = 129;
+ public static final int TLV_CHANNEL_STATUS = 130;
+ public static final int TLV_FACE_SCOPE = 132;
+ public static final int TLV_FACE_PERSISTENCY = 133;
+ public static final int TLV_LINK_TYPE = 134;
+ public static final int TLV_N_IN_INTERESTS = 144;
+ public static final int TLV_N_IN_DATAS = 145;
+ public static final int TLV_N_OUT_INTERESTS = 146;
+ public static final int TLV_N_OUT_DATAS = 147;
+ public static final int TLV_N_IN_BYTES = 148;
+ public static final int TLV_N_OUT_BYTES = 149;
- /**
- * Encode using a new TLV encoder.
- *
- * @return The encoded buffer.
- */
- public final Blob wireEncode() {
- TlvEncoder encoder = new TlvEncoder();
- wireEncode(encoder);
- return new Blob(encoder.getOutput(), false);
- }
+ /**
+ * Encode using a new TLV encoder.
+ *
+ * @return The encoded buffer.
+ */
+ public final Blob wireEncode() {
+ TlvEncoder encoder = new TlvEncoder();
+ wireEncode(encoder);
+ return new Blob(encoder.getOutput(), false);
+ }
- /**
- * Encode as part of an existing encode context.
- *
- * @param encoder
- */
- public final void wireEncode(TlvEncoder encoder) {
- int saveLength = encoder.getLength();
- encoder.writeNonNegativeIntegerTlv(TLV_N_OUT_BYTES, outBytes);
- encoder.writeNonNegativeIntegerTlv(TLV_N_IN_BYTES, inBytes);
- encoder.writeNonNegativeIntegerTlv(TLV_N_OUT_DATAS, outDatas);
- encoder.writeNonNegativeIntegerTlv(TLV_N_OUT_INTERESTS, outInterests);
- encoder.writeNonNegativeIntegerTlv(TLV_N_IN_DATAS, inDatas);
- encoder.writeNonNegativeIntegerTlv(TLV_N_IN_INTERESTS, inInterests);
- encoder.writeNonNegativeIntegerTlv(TLV_LINK_TYPE, linkType.getNumericValue());
- encoder.writeNonNegativeIntegerTlv(TLV_FACE_PERSISTENCY, facePersistency.getNumericValue());
- encoder.writeNonNegativeIntegerTlv(TLV_FACE_SCOPE, faceScope.getNumericValue());
- encoder.writeOptionalNonNegativeIntegerTlv(TLV_EXPIRATION_PERIOD, expirationPeriod);
- encoder.writeBlobTlv(TLV_LOCAL_URI, new Blob(localUri).buf());
- encoder.writeBlobTlv(TLV_URI, new Blob(uri).buf());
- encoder.writeNonNegativeIntegerTlv(TLV_FACE_ID, faceId);
- encoder.writeTypeAndLength(TLV_FACE_STATUS, encoder.getLength() - saveLength);
- }
+ /**
+ * Encode as part of an existing encode context.
+ *
+ * @param encoder
+ */
+ public final void wireEncode(TlvEncoder encoder) {
+ int saveLength = encoder.getLength();
+ encoder.writeNonNegativeIntegerTlv(TLV_N_OUT_BYTES, outBytes);
+ encoder.writeNonNegativeIntegerTlv(TLV_N_IN_BYTES, inBytes);
+ encoder.writeNonNegativeIntegerTlv(TLV_N_OUT_DATAS, outDatas);
+ encoder.writeNonNegativeIntegerTlv(TLV_N_OUT_INTERESTS, outInterests);
+ encoder.writeNonNegativeIntegerTlv(TLV_N_IN_DATAS, inDatas);
+ encoder.writeNonNegativeIntegerTlv(TLV_N_IN_INTERESTS, inInterests);
+ encoder.writeNonNegativeIntegerTlv(TLV_LINK_TYPE, linkType.getNumericValue());
+ encoder.writeNonNegativeIntegerTlv(TLV_FACE_PERSISTENCY, facePersistency.getNumericValue());
+ encoder.writeNonNegativeIntegerTlv(TLV_FACE_SCOPE, faceScope.getNumericValue());
+ encoder.writeOptionalNonNegativeIntegerTlv(TLV_EXPIRATION_PERIOD, expirationPeriod);
+ encoder.writeBlobTlv(TLV_LOCAL_URI, new Blob(localUri).buf());
+ encoder.writeBlobTlv(TLV_URI, new Blob(uri).buf());
+ encoder.writeNonNegativeIntegerTlv(TLV_FACE_ID, faceId);
+ encoder.writeTypeAndLength(TLV_FACE_STATUS, encoder.getLength() - saveLength);
+ }
- /**
- * Decode the input from its TLV format.
- *
- * @param input The input buffer to decode. This reads from position() to
- * limit(), but does not change the position.
- * @throws net.named_data.jndn.encoding.EncodingException
- */
- public final void wireDecode(ByteBuffer input) throws EncodingException {
- TlvDecoder decoder = new TlvDecoder(input);
- wireDecode(decoder);
- }
+ /**
+ * Decode the input from its TLV format.
+ *
+ * @param input The input buffer to decode. This reads from position() to
+ * limit(), but does not change the position.
+ * @throws net.named_data.jndn.encoding.EncodingException
+ */
+ public final void wireDecode(ByteBuffer input) throws EncodingException {
+ TlvDecoder decoder = new TlvDecoder(input);
+ wireDecode(decoder);
+ }
- /**
- * Decode as part of an existing decode context.
- *
- * @param decoder
- * @throws EncodingException
- */
- @Override
- public void wireDecode(TlvDecoder decoder) throws EncodingException {
- int endOffset = decoder.readNestedTlvsStart(TLV_FACE_STATUS);
- // parse
- this.faceId = (int) decoder.readNonNegativeIntegerTlv(TLV_FACE_ID);
- Blob uri_ = new Blob(decoder.readBlobTlv(TLV_URI), true); // copy because buffer is immutable
- this.uri = uri_.toString();
- Blob localUri_ = new Blob(decoder.readBlobTlv(TLV_LOCAL_URI), true); // copy because buffer is immutable
- this.localUri = localUri_.toString();
- this.expirationPeriod = (int) decoder.readOptionalNonNegativeIntegerTlv(TLV_EXPIRATION_PERIOD, endOffset);
- this.faceScope = FaceScope.values()[(int) decoder.readNonNegativeIntegerTlv(TLV_FACE_SCOPE)];
- this.facePersistency = FacePersistency.values()[(int) decoder.readNonNegativeIntegerTlv(TLV_FACE_PERSISTENCY)];
- this.linkType = LinkType.values()[(int) decoder.readNonNegativeIntegerTlv(TLV_LINK_TYPE)];
- this.inInterests = (int) decoder.readNonNegativeIntegerTlv(TLV_N_IN_INTERESTS);
- this.inDatas = (int) decoder.readNonNegativeIntegerTlv(TLV_N_IN_DATAS);
- this.outInterests = (int) decoder.readNonNegativeIntegerTlv(TLV_N_OUT_INTERESTS);
- this.outDatas = (int) decoder.readNonNegativeIntegerTlv(TLV_N_OUT_DATAS);
- this.inBytes = (int) decoder.readNonNegativeIntegerTlv(TLV_N_IN_BYTES);
- this.outBytes = (int) decoder.readNonNegativeIntegerTlv(TLV_N_OUT_BYTES);
- decoder.finishNestedTlvs(endOffset);
- }
+ /**
+ * Decode as part of an existing decode context.
+ *
+ * @param decoder
+ * @throws EncodingException
+ */
+ @Override
+ public void wireDecode(TlvDecoder decoder) throws EncodingException {
+ int endOffset = decoder.readNestedTlvsStart(TLV_FACE_STATUS);
+ // parse
+ this.faceId = (int) decoder.readNonNegativeIntegerTlv(TLV_FACE_ID);
+ Blob uri_ = new Blob(decoder.readBlobTlv(TLV_URI), true); // copy because buffer is immutable
+ this.uri = uri_.toString();
+ Blob localUri_ = new Blob(decoder.readBlobTlv(TLV_LOCAL_URI), true); // copy because buffer is immutable
+ this.localUri = localUri_.toString();
+ this.expirationPeriod = (int) decoder.readOptionalNonNegativeIntegerTlv(TLV_EXPIRATION_PERIOD, endOffset);
+ this.faceScope = FaceScope.values()[(int) decoder.readNonNegativeIntegerTlv(TLV_FACE_SCOPE)];
+ this.facePersistency = FacePersistency.values()[(int) decoder.readNonNegativeIntegerTlv(TLV_FACE_PERSISTENCY)];
+ this.linkType = LinkType.values()[(int) decoder.readNonNegativeIntegerTlv(TLV_LINK_TYPE)];
+ this.inInterests = (int) decoder.readNonNegativeIntegerTlv(TLV_N_IN_INTERESTS);
+ this.inDatas = (int) decoder.readNonNegativeIntegerTlv(TLV_N_IN_DATAS);
+ this.outInterests = (int) decoder.readNonNegativeIntegerTlv(TLV_N_OUT_INTERESTS);
+ this.outDatas = (int) decoder.readNonNegativeIntegerTlv(TLV_N_OUT_DATAS);
+ this.inBytes = (int) decoder.readNonNegativeIntegerTlv(TLV_N_IN_BYTES);
+ this.outBytes = (int) decoder.readNonNegativeIntegerTlv(TLV_N_OUT_BYTES);
+ decoder.finishNestedTlvs(endOffset);
+ }
- /**
- * Get face ID
- *
- * @return
- */
- public int getFaceId() {
- return faceId;
- }
+ /**
+ * Get face ID
+ *
+ * @return
+ */
+ public int getFaceId() {
+ return faceId;
+ }
- /**
- * Set face ID
- *
- * @param faceId
- */
- public void setFaceId(int faceId) {
- this.faceId = faceId;
- }
+ /**
+ * Set face ID
+ *
+ * @param faceId
+ */
+ public void setFaceId(int faceId) {
+ this.faceId = faceId;
+ }
- /**
- * Get face ID
- *
- * @return
- */
- public String getUri() {
- return uri;
- }
+ /**
+ * Get face ID
+ *
+ * @return
+ */
+ public String getUri() {
+ return uri;
+ }
- /**
- * Set URI
- *
- * @param uri
- */
- public void setUri(String uri) {
- this.uri = uri;
- }
+ /**
+ * Set URI
+ *
+ * @param uri
+ */
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
- /**
- * Get face ID
- *
- * @return
- */
- public String getLocalUri() {
- return localUri;
- }
+ /**
+ * Get face ID
+ *
+ * @return
+ */
+ public String getLocalUri() {
+ return localUri;
+ }
- /**
- * Set local URI
- * @param localUri
- */
- public void setLocalUri(String localUri) {
- this.localUri = localUri;
- }
+ /**
+ * Set local URI
+ *
+ * @param localUri
+ */
+ public void setLocalUri(String localUri) {
+ this.localUri = localUri;
+ }
- /**
- * Get expiration period
- *
- * @return
- */
- public int getExpirationPeriod() {
- return expirationPeriod;
- }
+ /**
+ * Get expiration period
+ *
+ * @return
+ */
+ public int getExpirationPeriod() {
+ return expirationPeriod;
+ }
- /**
- * Set expiration period
- *
- * @param expirationPeriod
- */
- public void setExpirationPeriod(int expirationPeriod) {
- this.expirationPeriod = expirationPeriod;
- }
+ /**
+ * Set expiration period
+ *
+ * @param expirationPeriod
+ */
+ public void setExpirationPeriod(int expirationPeriod) {
+ this.expirationPeriod = expirationPeriod;
+ }
- /**
- * Get face scope value
- *
- * @return
- */
- public FaceScope getFaceScope() {
- return faceScope;
- }
+ /**
+ * Get face scope value
+ *
+ * @return
+ */
+ public FaceScope getFaceScope() {
+ return faceScope;
+ }
- /**
- * Set face scope value
- *
- * @param faceScope
- */
- public void setFaceScope(FaceScope faceScope) {
- this.faceScope = faceScope;
- }
+ /**
+ * Set face scope value
+ *
+ * @param faceScope
+ */
+ public void setFaceScope(FaceScope faceScope) {
+ this.faceScope = faceScope;
+ }
- /**
- * Get face persistency value
- *
- * @return
- */
- public FacePersistency getFacePersistency() {
- return facePersistency;
- }
+ /**
+ * Get face persistency value
+ *
+ * @return
+ */
+ public FacePersistency getFacePersistency() {
+ return facePersistency;
+ }
- /**
- * Set face persistency value
- *
- * @param facePersistency
- */
- public void setFacePersistency(FacePersistency facePersistency) {
- this.facePersistency = facePersistency;
- }
+ /**
+ * Set face persistency value
+ *
+ * @param facePersistency
+ */
+ public void setFacePersistency(FacePersistency facePersistency) {
+ this.facePersistency = facePersistency;
+ }
- /**
- * Get link type
- *
- * @return
- */
- public LinkType getLinkType() {
- return linkType;
- }
+ /**
+ * Get link type
+ *
+ * @return
+ */
+ public LinkType getLinkType() {
+ return linkType;
+ }
- /**
- * Set link type
- *
- * @param linkType
- */
- public void setLinkType(LinkType linkType) {
- this.linkType = linkType;
- }
+ /**
+ * Set link type
+ *
+ * @param linkType
+ */
+ public void setLinkType(LinkType linkType) {
+ this.linkType = linkType;
+ }
- /**
- * Get number of received Interest packets
- *
- * @return
- */
- public int getInInterests() {
- return inInterests;
- }
+ /**
+ * Get number of received Interest packets
+ *
+ * @return
+ */
+ public int getInInterests() {
+ return inInterests;
+ }
- /**
- * Set number of received Interest packets
- *
- * @param inInterests
- */
- public void setInInterests(int inInterests) {
- this.inInterests = inInterests;
- }
+ /**
+ * Set number of received Interest packets
+ *
+ * @param inInterests
+ */
+ public void setInInterests(int inInterests) {
+ this.inInterests = inInterests;
+ }
- /**
- * Get number of sent Interest packets
- *
- * @return
- */
- public int getOutInterests() {
- return outInterests;
- }
+ /**
+ * Get number of sent Interest packets
+ *
+ * @return
+ */
+ public int getOutInterests() {
+ return outInterests;
+ }
- /**
- * Set number of sent Interest packets
- *
- * @param outInterests
- */
- public void setOutInterests(int outInterests) {
- this.outInterests = outInterests;
- }
+ /**
+ * Set number of sent Interest packets
+ *
+ * @param outInterests
+ */
+ public void setOutInterests(int outInterests) {
+ this.outInterests = outInterests;
+ }
- /**
- * Get number of received Data packets
- *
- * @return
- */
- public int getInDatas() {
- return inDatas;
- }
+ /**
+ * Get number of received Data packets
+ *
+ * @return
+ */
+ public int getInDatas() {
+ return inDatas;
+ }
- /**
- * Set number of received Data packets
- *
- * @param inDatas
- */
- public void setInDatas(int inDatas) {
- this.inDatas = inDatas;
- }
+ /**
+ * Set number of received Data packets
+ *
+ * @param inDatas
+ */
+ public void setInDatas(int inDatas) {
+ this.inDatas = inDatas;
+ }
- /**
- * Get number of sent Data packets
- *
- * @return
- */
- public int getOutDatas() {
- return outDatas;
- }
+ /**
+ * Get number of sent Data packets
+ *
+ * @return
+ */
+ public int getOutDatas() {
+ return outDatas;
+ }
- /**
- * Set number of sent Data packets
- *
- * @param outDatas
- */
- public void setOutDatas(int outDatas) {
- this.outDatas = outDatas;
- }
+ /**
+ * Set number of sent Data packets
+ *
+ * @param outDatas
+ */
+ public void setOutDatas(int outDatas) {
+ this.outDatas = outDatas;
+ }
- /**
- * Get number of input bytes
- *
- * @return
- */
- public int getInBytes() {
- return inBytes;
- }
+ /**
+ * Get number of input bytes
+ *
+ * @return
+ */
+ public int getInBytes() {
+ return inBytes;
+ }
- /**
- * Set number of input bytes
- *
- * @param inBytes
- */
- public void setInBytes(int inBytes) {
- this.inBytes = inBytes;
- }
+ /**
+ * Set number of input bytes
+ *
+ * @param inBytes
+ */
+ public void setInBytes(int inBytes) {
+ this.inBytes = inBytes;
+ }
- /**
- * Get number of output bytes
- *
- * @return
- */
- public int getOutBytes() {
- return outBytes;
- }
+ /**
+ * Get number of output bytes
+ *
+ * @return
+ */
+ public int getOutBytes() {
+ return outBytes;
+ }
- /**
- * Set number of output bytes
- *
- * @param outBytes
- */
- public void setOutBytes(int outBytes) {
- this.outBytes = outBytes;
- }
+ /**
+ * Set number of output bytes
+ *
+ * @param outBytes
+ */
+ public void setOutBytes(int outBytes) {
+ this.outBytes = outBytes;
+ }
- private int faceId = -1;
- private String uri = ""; // can't use URI because some are invalid syntax
- private String localUri = ""; // can't use URI because some are invalid syntax
- private int expirationPeriod = 0;
- private FaceScope faceScope = FaceScope.LOCAL;
- private FacePersistency facePersistency = FacePersistency.ON_DEMAND;
- private LinkType linkType = LinkType.POINT_TO_POINT;
- private int inInterests = 0;
- private int outInterests = 0;
- private int inDatas = 0;
- private int outDatas = 0;
- private int inBytes = 0;
- private int outBytes = 0;
+ private int faceId = -1;
+ private String uri = ""; // can't use URI because some are invalid syntax
+ private String localUri = ""; // can't use URI because some are invalid syntax
+ private int expirationPeriod = 0;
+ private FaceScope faceScope = FaceScope.LOCAL;
+ private FacePersistency facePersistency = FacePersistency.ON_DEMAND;
+ private LinkType linkType = LinkType.POINT_TO_POINT;
+ private int inInterests = 0;
+ private int outInterests = 0;
+ private int inDatas = 0;
+ private int outDatas = 0;
+ private int inBytes = 0;
+ private int outBytes = 0;
}
diff --git a/src/main/java/com/intel/jndn/management/types/FibEntry.java b/src/main/java/com/intel/jndn/management/types/FibEntry.java
index 31cadbd..0478fe3 100644
--- a/src/main/java/com/intel/jndn/management/types/FibEntry.java
+++ b/src/main/java/com/intel/jndn/management/types/FibEntry.java
@@ -26,101 +26,101 @@
*
* @author Andrew Brown <andrew.brown@intel.com>
*/
-public class FibEntry implements Decodable{
+public class FibEntry implements Decodable {
- public final static int TLV_FIB_ENTRY = 128;
+ public final static int TLV_FIB_ENTRY = 128;
- /**
- * Encode using a new TLV encoder.
- *
- * @return The encoded buffer.
- */
- public final Blob wireEncode() {
- TlvEncoder encoder = new TlvEncoder();
- wireEncode(encoder);
- return new Blob(encoder.getOutput(), false);
- }
+ /**
+ * Encode using a new TLV encoder.
+ *
+ * @return The encoded buffer.
+ */
+ public final Blob wireEncode() {
+ TlvEncoder encoder = new TlvEncoder();
+ wireEncode(encoder);
+ return new Blob(encoder.getOutput(), false);
+ }
- /**
- * Encode as part of an existing encode context.
- *
- * @param encoder
- */
- public final void wireEncode(TlvEncoder encoder) {
- int saveLength = encoder.getLength();
- for (NextHopRecord record : records) {
- record.wireEncode(encoder);
- }
- EncodingHelper.encodeName(name, encoder);
- encoder.writeTypeAndLength(TLV_FIB_ENTRY, encoder.getLength() - saveLength);
- }
+ /**
+ * Encode as part of an existing encode context.
+ *
+ * @param encoder
+ */
+ public final void wireEncode(TlvEncoder encoder) {
+ int saveLength = encoder.getLength();
+ for (NextHopRecord record : records) {
+ record.wireEncode(encoder);
+ }
+ EncodingHelper.encodeName(name, encoder);
+ encoder.writeTypeAndLength(TLV_FIB_ENTRY, encoder.getLength() - saveLength);
+ }
- /**
- * Decode the input from its TLV format.
- *
- * @param input The input buffer to decode. This reads from position() to
- * limit(), but does not change the position.
- * @throws EncodingException For invalid encoding.
- */
- public final void wireDecode(ByteBuffer input) throws EncodingException {
- TlvDecoder decoder = new TlvDecoder(input);
- wireDecode(decoder);
- }
+ /**
+ * Decode the input from its TLV format.
+ *
+ * @param input The input buffer to decode. This reads from position() to
+ * limit(), but does not change the position.
+ * @throws EncodingException For invalid encoding.
+ */
+ public final void wireDecode(ByteBuffer input) throws EncodingException {
+ TlvDecoder decoder = new TlvDecoder(input);
+ wireDecode(decoder);
+ }
- /**
- * Decode as part of an existing decode context.
- *
- * @param decoder
- * @throws EncodingException
- */
- @Override
- public final void wireDecode(TlvDecoder decoder) throws EncodingException {
- int endOffset = decoder.readNestedTlvsStart(TLV_FIB_ENTRY);
- name = EncodingHelper.decodeName(decoder);
- while (decoder.getOffset() < endOffset) {
- NextHopRecord record = new NextHopRecord();
- record.wireDecode(decoder);
- records.add(record);
- }
- decoder.finishNestedTlvs(endOffset);
- }
+ /**
+ * Decode as part of an existing decode context.
+ *
+ * @param decoder
+ * @throws EncodingException
+ */
+ @Override
+ public final void wireDecode(TlvDecoder decoder) throws EncodingException {
+ int endOffset = decoder.readNestedTlvsStart(TLV_FIB_ENTRY);
+ name = EncodingHelper.decodeName(decoder);
+ while (decoder.getOffset() < endOffset) {
+ NextHopRecord record = new NextHopRecord();
+ record.wireDecode(decoder);
+ records.add(record);
+ }
+ decoder.finishNestedTlvs(endOffset);
+ }
- /**
- * Get name
- *
- * @return
- */
- public Name getName() {
- return name;
- }
+ /**
+ * Get name
+ *
+ * @return
+ */
+ public Name getName() {
+ return name;
+ }
- /**
- * Set name
- *
- * @param name
- */
- public void setName(Name name) {
- this.name = name;
- }
+ /**
+ * Set name
+ *
+ * @param name
+ */
+ public void setName(Name name) {
+ this.name = name;
+ }
- /**
- * Get records
- *
- * @return
- */
- public List<NextHopRecord> getRecords() {
- return records;
- }
+ /**
+ * Get records
+ *
+ * @return
+ */
+ public List<NextHopRecord> getRecords() {
+ return records;
+ }
- /**
- * Set records
- *
- * @param records
- */
- public void setRecords(List<NextHopRecord> records) {
- this.records = records;
- }
+ /**
+ * Set records
+ *
+ * @param records
+ */
+ public void setRecords(List<NextHopRecord> records) {
+ this.records = records;
+ }
- private Name name = new Name();
- private List<NextHopRecord> records = new ArrayList<>();
+ private Name name = new Name();
+ private List<NextHopRecord> records = new ArrayList<>();
}
diff --git a/src/main/java/com/intel/jndn/management/types/LinkType.java b/src/main/java/com/intel/jndn/management/types/LinkType.java
index ea09f47..dc5fbf5 100644
--- a/src/main/java/com/intel/jndn/management/types/LinkType.java
+++ b/src/main/java/com/intel/jndn/management/types/LinkType.java
@@ -11,21 +11,22 @@
package com.intel.jndn.management.types;
/**
- * Indicate the type of communication link; used by FaceStatus
- * See http://redmine.named-data.net/projects/nfd/widi/FaceMgmt
+ * Indicate the type of communication link; used by FaceStatus See
+ * http://redmine.named-data.net/projects/nfd/widi/FaceMgmt
+ *
* @author Andrew Brown <andrew.brown@intel.com>
*/
public enum LinkType {
- POINT_TO_POINT(0),
- MULTI_ACCESS(1);
+ POINT_TO_POINT(0),
+ MULTI_ACCESS(1);
- LinkType(int value) {
- value_ = value;
- }
+ LinkType(int value) {
+ value_ = value;
+ }
- public final int getNumericValue() {
- return value_;
- }
- private final int value_;
+ public final int getNumericValue() {
+ return value_;
+ }
+ private final int value_;
}
diff --git a/src/main/java/com/intel/jndn/management/types/NextHopRecord.java b/src/main/java/com/intel/jndn/management/types/NextHopRecord.java
index b9001ad..a0e6915 100644
--- a/src/main/java/com/intel/jndn/management/types/NextHopRecord.java
+++ b/src/main/java/com/intel/jndn/management/types/NextHopRecord.java
@@ -26,92 +26,92 @@
*/
public class NextHopRecord {
- public final static int TLV_NEXT_HOP_RECORD = 129;
+ public final static int TLV_NEXT_HOP_RECORD = 129;
- /**
- * Encode using a new TLV encoder.
- *
- * @return The encoded buffer.
- */
- public final Blob wireEncode() {
- TlvEncoder encoder = new TlvEncoder();
- wireEncode(encoder);
- return new Blob(encoder.getOutput(), false);
- }
+ /**
+ * Encode using a new TLV encoder.
+ *
+ * @return The encoded buffer.
+ */
+ public final Blob wireEncode() {
+ TlvEncoder encoder = new TlvEncoder();
+ wireEncode(encoder);
+ return new Blob(encoder.getOutput(), false);
+ }
- /**
- * Encode as part of an existing encode context.
- *
- * @param encoder
- */
- public final void wireEncode(TlvEncoder encoder) {
- int saveLength = encoder.getLength();
- encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_Cost, cost);
- encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_FaceId, faceId);
- encoder.writeTypeAndLength(TLV_NEXT_HOP_RECORD, encoder.getLength() - saveLength);
- }
+ /**
+ * Encode as part of an existing encode context.
+ *
+ * @param encoder
+ */
+ public final void wireEncode(TlvEncoder encoder) {
+ int saveLength = encoder.getLength();
+ encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_Cost, cost);
+ encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_FaceId, faceId);
+ encoder.writeTypeAndLength(TLV_NEXT_HOP_RECORD, encoder.getLength() - saveLength);
+ }
- /**
- * Decode the input from its TLV format.
- *
- * @param input The input buffer to decode. This reads from position() to
- * limit(), but does not change the position.
- * @throws EncodingException For invalid encoding.
- */
- public final void wireDecode(ByteBuffer input) throws EncodingException {
- TlvDecoder decoder = new TlvDecoder(input);
- wireDecode(decoder);
- }
+ /**
+ * Decode the input from its TLV format.
+ *
+ * @param input The input buffer to decode. This reads from position() to
+ * limit(), but does not change the position.
+ * @throws EncodingException For invalid encoding.
+ */
+ public final void wireDecode(ByteBuffer input) throws EncodingException {
+ TlvDecoder decoder = new TlvDecoder(input);
+ wireDecode(decoder);
+ }
- /**
- * Decode as part of an existing decode context.
- *
- * @param decoder
- * @throws EncodingException
- */
- public final void wireDecode(TlvDecoder decoder) throws EncodingException {
- int endOffset = decoder.readNestedTlvsStart(TLV_NEXT_HOP_RECORD);
- this.faceId = (int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_FaceId);
- this.cost = (int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_Cost);
- decoder.finishNestedTlvs(endOffset);
- }
+ /**
+ * Decode as part of an existing decode context.
+ *
+ * @param decoder
+ * @throws EncodingException
+ */
+ public final void wireDecode(TlvDecoder decoder) throws EncodingException {
+ int endOffset = decoder.readNestedTlvsStart(TLV_NEXT_HOP_RECORD);
+ this.faceId = (int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_FaceId);
+ this.cost = (int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_Cost);
+ decoder.finishNestedTlvs(endOffset);
+ }
- /**
- * Get face ID
- *
- * @return
- */
- public int getFaceId() {
- return faceId;
- }
+ /**
+ * Get face ID
+ *
+ * @return
+ */
+ public int getFaceId() {
+ return faceId;
+ }
- /**
- * Set face ID
- *
- * @param faceId
- */
- public void setFaceId(int faceId) {
- this.faceId = faceId;
- }
+ /**
+ * Set face ID
+ *
+ * @param faceId
+ */
+ public void setFaceId(int faceId) {
+ this.faceId = faceId;
+ }
- /**
- * Get cost
- *
- * @return
- */
- public int getCost() {
- return cost;
- }
+ /**
+ * Get cost
+ *
+ * @return
+ */
+ public int getCost() {
+ return cost;
+ }
- /**
- * Set cost
- *
- * @param cost
- */
- public void setCost(int cost) {
- this.cost = cost;
- }
+ /**
+ * Set cost
+ *
+ * @param cost
+ */
+ public void setCost(int cost) {
+ this.cost = cost;
+ }
- private int faceId;
- private int cost;
+ private int faceId;
+ private int cost;
}
diff --git a/src/main/java/com/intel/jndn/management/types/RibEntry.java b/src/main/java/com/intel/jndn/management/types/RibEntry.java
index ac53810..19c7e7c 100644
--- a/src/main/java/com/intel/jndn/management/types/RibEntry.java
+++ b/src/main/java/com/intel/jndn/management/types/RibEntry.java
@@ -27,105 +27,105 @@
*
* @author Andrew Brown <andrew.brown@intel.com>
*/
-public class RibEntry implements Decodable{
+public class RibEntry implements Decodable {
- /**
- * TLV type, see
- * http://redmine.named-data.net/projects/nfd/wiki/RibMgmt#TLV-TYPE-assignments
- */
- public final static int TLV_RIB_ENTRY = 128;
+ /**
+ * TLV type, see
+ * http://redmine.named-data.net/projects/nfd/wiki/RibMgmt#TLV-TYPE-assignments
+ */
+ public final static int TLV_RIB_ENTRY = 128;
- /**
- * Encode using a new TLV encoder.
- *
- * @return The encoded buffer.
- */
- public final Blob wireEncode() {
- TlvEncoder encoder = new TlvEncoder();
- wireEncode(encoder);
- return new Blob(encoder.getOutput(), false);
- }
+ /**
+ * Encode using a new TLV encoder.
+ *
+ * @return The encoded buffer.
+ */
+ public final Blob wireEncode() {
+ TlvEncoder encoder = new TlvEncoder();
+ wireEncode(encoder);
+ return new Blob(encoder.getOutput(), false);
+ }
- /**
- * Encode as part of an existing encode context.
- *
- * @param encoder
- */
- public final void wireEncode(TlvEncoder encoder) {
- int saveLength = encoder.getLength();
- for (Route route : routes) {
- route.wireEncode(encoder);
- }
- EncodingHelper.encodeName(name, encoder);
- encoder.writeTypeAndLength(TLV_RIB_ENTRY, encoder.getLength() - saveLength);
- }
+ /**
+ * Encode as part of an existing encode context.
+ *
+ * @param encoder
+ */
+ public final void wireEncode(TlvEncoder encoder) {
+ int saveLength = encoder.getLength();
+ for (Route route : routes) {
+ route.wireEncode(encoder);
+ }
+ EncodingHelper.encodeName(name, encoder);
+ encoder.writeTypeAndLength(TLV_RIB_ENTRY, encoder.getLength() - saveLength);
+ }
- /**
- * Decode the input from its TLV format.
- *
- * @param input The input buffer to decode. This reads from position() to
- * limit(), but does not change the position.
- * @throws EncodingException For invalid encoding.
- */
- public final void wireDecode(ByteBuffer input) throws EncodingException {
- TlvDecoder decoder = new TlvDecoder(input);
- wireDecode(decoder);
- }
+ /**
+ * Decode the input from its TLV format.
+ *
+ * @param input The input buffer to decode. This reads from position() to
+ * limit(), but does not change the position.
+ * @throws EncodingException For invalid encoding.
+ */
+ public final void wireDecode(ByteBuffer input) throws EncodingException {
+ TlvDecoder decoder = new TlvDecoder(input);
+ wireDecode(decoder);
+ }
- /**
- * Decode as part of an existing decode context.
- *
- * @param decoder
- * @throws EncodingException
- */
- @Override
- public final void wireDecode(TlvDecoder decoder) throws EncodingException {
- int endOffset = decoder.readNestedTlvsStart(TLV_RIB_ENTRY);
- name = EncodingHelper.decodeName(decoder);
- while (decoder.getOffset() < endOffset) {
- Route route = new Route();
- route.wireDecode(decoder);
- routes.add(route);
- }
- decoder.finishNestedTlvs(endOffset);
- }
+ /**
+ * Decode as part of an existing decode context.
+ *
+ * @param decoder
+ * @throws EncodingException
+ */
+ @Override
+ public final void wireDecode(TlvDecoder decoder) throws EncodingException {
+ int endOffset = decoder.readNestedTlvsStart(TLV_RIB_ENTRY);
+ name = EncodingHelper.decodeName(decoder);
+ while (decoder.getOffset() < endOffset) {
+ Route route = new Route();
+ route.wireDecode(decoder);
+ routes.add(route);
+ }
+ decoder.finishNestedTlvs(endOffset);
+ }
- /**
- * Get name
- *
- * @return
- */
- public Name getName() {
- return name;
- }
+ /**
+ * Get name
+ *
+ * @return
+ */
+ public Name getName() {
+ return name;
+ }
- /**
- * Set name
- *
- * @param name
- */
- public void setName(Name name) {
- this.name = name;
- }
+ /**
+ * Set name
+ *
+ * @param name
+ */
+ public void setName(Name name) {
+ this.name = name;
+ }
- /**
- * Get routes
- *
- * @return
- */
- public List<Route> getRoutes() {
- return routes;
- }
+ /**
+ * Get routes
+ *
+ * @return
+ */
+ public List<Route> getRoutes() {
+ return routes;
+ }
- /**
- * Set routes
- *
- * @param routes
- */
- public void setRoutes(List<Route> routes) {
- this.routes = routes;
- }
+ /**
+ * Set routes
+ *
+ * @param routes
+ */
+ public void setRoutes(List<Route> routes) {
+ this.routes = routes;
+ }
- private Name name = new Name();
- private List<Route> routes = new ArrayList<>();
+ private Name name = new Name();
+ private List<Route> routes = new ArrayList<>();
}
diff --git a/src/main/java/com/intel/jndn/management/types/Route.java b/src/main/java/com/intel/jndn/management/types/Route.java
index 2cbb247..79be67f 100644
--- a/src/main/java/com/intel/jndn/management/types/Route.java
+++ b/src/main/java/com/intel/jndn/management/types/Route.java
@@ -28,159 +28,159 @@
*/
public class Route {
- /**
- * TLV type, see
- * http://redmine.named-data.net/projects/nfd/wiki/RibMgmt#TLV-TYPE-assignments
- */
- public final static int TLV_ROUTE = 129;
+ /**
+ * TLV type, see
+ * http://redmine.named-data.net/projects/nfd/wiki/RibMgmt#TLV-TYPE-assignments
+ */
+ public final static int TLV_ROUTE = 129;
- /**
- * Encode using a new TLV encoder.
- *
- * @return The encoded buffer.
- */
- public final Blob wireEncode() {
- TlvEncoder encoder = new TlvEncoder();
- wireEncode(encoder);
- return new Blob(encoder.getOutput(), false);
- }
+ /**
+ * Encode using a new TLV encoder.
+ *
+ * @return The encoded buffer.
+ */
+ public final Blob wireEncode() {
+ TlvEncoder encoder = new TlvEncoder();
+ wireEncode(encoder);
+ return new Blob(encoder.getOutput(), false);
+ }
- /**
- * Encode as part of an existing encode context.
- *
- * @param encoder
- */
- public final void wireEncode(TlvEncoder encoder) {
- int saveLength = encoder.getLength();
- encoder.writeOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_ExpirationPeriod, faceId);
- encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_Flags, flags.getForwardingEntryFlags());
- encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_Cost, cost);
- encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_Origin, origin);
- encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_FaceId, faceId);
- encoder.writeTypeAndLength(TLV_ROUTE, encoder.getLength() - saveLength);
- }
+ /**
+ * Encode as part of an existing encode context.
+ *
+ * @param encoder
+ */
+ public final void wireEncode(TlvEncoder encoder) {
+ int saveLength = encoder.getLength();
+ encoder.writeOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_ExpirationPeriod, faceId);
+ encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_Flags, flags.getForwardingEntryFlags());
+ encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_Cost, cost);
+ encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_Origin, origin);
+ encoder.writeNonNegativeIntegerTlv(Tlv.ControlParameters_FaceId, faceId);
+ encoder.writeTypeAndLength(TLV_ROUTE, encoder.getLength() - saveLength);
+ }
- /**
- * Decode the input from its TLV format.
- *
- * @param input The input buffer to decode. This reads from position() to
- * limit(), but does not change the position.
- * @throws net.named_data.jndn.encoding.EncodingException
- */
- public final void wireDecode(ByteBuffer input) throws EncodingException {
- TlvDecoder decoder = new TlvDecoder(input);
- wireDecode(decoder);
- }
+ /**
+ * Decode the input from its TLV format.
+ *
+ * @param input The input buffer to decode. This reads from position() to
+ * limit(), but does not change the position.
+ * @throws net.named_data.jndn.encoding.EncodingException
+ */
+ public final void wireDecode(ByteBuffer input) throws EncodingException {
+ TlvDecoder decoder = new TlvDecoder(input);
+ wireDecode(decoder);
+ }
- /**
- * Decode as part of an existing decode context.
- *
- * @param decoder
- * @throws EncodingException
- */
- public final void wireDecode(TlvDecoder decoder) throws EncodingException {
- int endOffset = decoder.readNestedTlvsStart(TLV_ROUTE);
- this.faceId = (int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_FaceId);
- this.origin = (int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_Origin);
- this.cost = (int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_Cost);
- this.flags.setForwardingEntryFlags((int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_Flags));
- this.expirationPeriod = (int) decoder.readOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_ExpirationPeriod, endOffset);
- decoder.finishNestedTlvs(endOffset);
- }
+ /**
+ * Decode as part of an existing decode context.
+ *
+ * @param decoder
+ * @throws EncodingException
+ */
+ public final void wireDecode(TlvDecoder decoder) throws EncodingException {
+ int endOffset = decoder.readNestedTlvsStart(TLV_ROUTE);
+ this.faceId = (int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_FaceId);
+ this.origin = (int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_Origin);
+ this.cost = (int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_Cost);
+ this.flags.setForwardingEntryFlags((int) decoder.readNonNegativeIntegerTlv(Tlv.ControlParameters_Flags));
+ this.expirationPeriod = (int) decoder.readOptionalNonNegativeIntegerTlv(Tlv.ControlParameters_ExpirationPeriod, endOffset);
+ decoder.finishNestedTlvs(endOffset);
+ }
- /**
- * Get Face ID
- *
- * @return
- */
- public int getFaceId() {
- return faceId;
- }
+ /**
+ * Get Face ID
+ *
+ * @return
+ */
+ public int getFaceId() {
+ return faceId;
+ }
- /**
- * Set Face ID
- *
- * @param faceId
- */
- public void setFaceId(int faceId) {
- this.faceId = faceId;
- }
+ /**
+ * Set Face ID
+ *
+ * @param faceId
+ */
+ public void setFaceId(int faceId) {
+ this.faceId = faceId;
+ }
- /**
- * Get origin
- *
- * @return
- */
- public int getOrigin() {
- return origin;
- }
+ /**
+ * Get origin
+ *
+ * @return
+ */
+ public int getOrigin() {
+ return origin;
+ }
- /**
- * Set origin
- *
- * @param origin
- */
- public void setOrigin(int origin) {
- this.origin = origin;
- }
+ /**
+ * Set origin
+ *
+ * @param origin
+ */
+ public void setOrigin(int origin) {
+ this.origin = origin;
+ }
- /**
- * Get cost
- *
- * @return
- */
- public int getCost() {
- return cost;
- }
+ /**
+ * Get cost
+ *
+ * @return
+ */
+ public int getCost() {
+ return cost;
+ }
- /**
- * Set cost
- *
- * @param cost
- */
- public void setCost(int cost) {
- this.cost = cost;
- }
+ /**
+ * Set cost
+ *
+ * @param cost
+ */
+ public void setCost(int cost) {
+ this.cost = cost;
+ }
- /**
- * Get flags
- *
- * @return
- */
- public ForwardingFlags getFlags() {
- return flags;
- }
+ /**
+ * Get flags
+ *
+ * @return
+ */
+ public ForwardingFlags getFlags() {
+ return flags;
+ }
- /**
- * Set flags
- *
- * @param flags
- */
- public void setFlags(ForwardingFlags flags) {
- this.flags = flags;
- }
+ /**
+ * Set flags
+ *
+ * @param flags
+ */
+ public void setFlags(ForwardingFlags flags) {
+ this.flags = flags;
+ }
- /**
- * Get expiration period
- *
- * @return
- */
- public double getExpirationPeriod() {
- return expirationPeriod;
- }
+ /**
+ * Get expiration period
+ *
+ * @return
+ */
+ public double getExpirationPeriod() {
+ return expirationPeriod;
+ }
- /**
- * Set expiration period
- *
- * @param expirationPeriod
- */
- public void setExpirationPeriod(double expirationPeriod) {
- this.expirationPeriod = expirationPeriod;
- }
+ /**
+ * Set expiration period
+ *
+ * @param expirationPeriod
+ */
+ public void setExpirationPeriod(double expirationPeriod) {
+ this.expirationPeriod = expirationPeriod;
+ }
- private int faceId = -1;
- private int origin = -1;
- private int cost = -1;
- private ForwardingFlags flags = new ForwardingFlags();
- private double expirationPeriod = -1.0;
+ private int faceId = -1;
+ private int origin = -1;
+ private int cost = -1;
+ private ForwardingFlags flags = new ForwardingFlags();
+ private double expirationPeriod = -1.0;
}
diff --git a/src/main/java/com/intel/jndn/management/types/StatusDataset.java b/src/main/java/com/intel/jndn/management/types/StatusDataset.java
index 0117ee7..d20a717 100644
--- a/src/main/java/com/intel/jndn/management/types/StatusDataset.java
+++ b/src/main/java/com/intel/jndn/management/types/StatusDataset.java
@@ -24,27 +24,27 @@
*/
public class StatusDataset {
- /**
- * Decode multiple status entries as part of a StatusDataset, see
- * http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
- *
- * @param <T>
- * @param statusDataset
- * @param type
- * @return
- * @throws EncodingException
- * @throws InstantiationException
- * @throws IllegalAccessException
- */
- public static final <T extends Decodable> List<T> wireDecode(Blob statusDataset, Class<T> type) throws EncodingException, InstantiationException, IllegalAccessException {
- List<T> entries = new ArrayList<>();
- int endOffset = statusDataset.size();
- TlvDecoder decoder = new TlvDecoder(statusDataset.buf());
- while (decoder.getOffset() < endOffset) {
- T entry = type.newInstance();
- entry.wireDecode(decoder);
- entries.add(entry);
- }
- return entries;
- }
+ /**
+ * Decode multiple status entries as part of a StatusDataset, see
+ * http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
+ *
+ * @param <T>
+ * @param statusDataset
+ * @param type
+ * @return
+ * @throws EncodingException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ public static final <T extends Decodable> List<T> wireDecode(Blob statusDataset, Class<T> type) throws EncodingException, InstantiationException, IllegalAccessException {
+ List<T> entries = new ArrayList<>();
+ int endOffset = statusDataset.size();
+ TlvDecoder decoder = new TlvDecoder(statusDataset.buf());
+ while (decoder.getOffset() < endOffset) {
+ T entry = type.newInstance();
+ entry.wireDecode(decoder);
+ entries.add(entry);
+ }
+ return entries;
+ }
}
diff --git a/src/test/java/com/intel/jndn/management/ControlResponseTest.java b/src/test/java/com/intel/jndn/management/ControlResponseTest.java
index 5d026e0..d21c3e0 100644
--- a/src/test/java/com/intel/jndn/management/ControlResponseTest.java
+++ b/src/test/java/com/intel/jndn/management/ControlResponseTest.java
@@ -22,31 +22,31 @@
*/
public class ControlResponseTest {
- /**
- * Test encoding/decoding
- *
- * @throws java.lang.Exception
- */
- @Test
- public void testEncodeDecode() throws Exception {
- ControlParameters parameters = new ControlParameters();
- parameters.setFaceId(3);
- ControlResponse response = new ControlResponse();
- response.setStatusCode(404);
- response.setStatusText("Not Found");
- response.getBody().add(parameters);
+ /**
+ * Test encoding/decoding
+ *
+ * @throws java.lang.Exception
+ */
+ @Test
+ public void testEncodeDecode() throws Exception {
+ ControlParameters parameters = new ControlParameters();
+ parameters.setFaceId(3);
+ ControlResponse response = new ControlResponse();
+ response.setStatusCode(404);
+ response.setStatusText("Not Found");
+ response.getBody().add(parameters);
- // encode
- Blob encoded = response.wireEncode();
+ // encode
+ Blob encoded = response.wireEncode();
- // decode
- ControlResponse decoded = new ControlResponse();
- decoded.wireDecode(encoded.buf());
+ // decode
+ ControlResponse decoded = new ControlResponse();
+ decoded.wireDecode(encoded.buf());
- // test
- Assert.assertEquals(response.getStatusCode(), decoded.getStatusCode());
- Assert.assertEquals(response.getStatusText(), decoded.getStatusText());
- Assert.assertEquals(response.getBody().size(), decoded.getBody().size());
- Assert.assertEquals(response.getBody().get(0).getFaceId(), decoded.getBody().get(0).getFaceId());
- }
+ // test
+ Assert.assertEquals(response.getStatusCode(), decoded.getStatusCode());
+ Assert.assertEquals(response.getStatusText(), decoded.getStatusText());
+ Assert.assertEquals(response.getBody().size(), decoded.getBody().size());
+ Assert.assertEquals(response.getBody().get(0).getFaceId(), decoded.getBody().get(0).getFaceId());
+ }
}
diff --git a/src/test/java/com/intel/jndn/management/FaceStatusTest.java b/src/test/java/com/intel/jndn/management/FaceStatusTest.java
index f0d3eaf..e5fbab7 100644
--- a/src/test/java/com/intel/jndn/management/FaceStatusTest.java
+++ b/src/test/java/com/intel/jndn/management/FaceStatusTest.java
@@ -34,127 +34,127 @@
*/
public class FaceStatusTest {
- private static final Logger logger = LogManager.getLogger();
+ private static final Logger logger = LogManager.getLogger();
- /**
- * Test encoding/decoding
- *
- * @throws java.lang.Exception
- */
- @Test
- public void testEncodeDecode() throws Exception {
- FaceStatus status = new FaceStatus();
- status.setFaceId(42);
- status.setUri("...");
- status.setLocalUri("...");
+ /**
+ * Test encoding/decoding
+ *
+ * @throws java.lang.Exception
+ */
+ @Test
+ public void testEncodeDecode() throws Exception {
+ FaceStatus status = new FaceStatus();
+ status.setFaceId(42);
+ status.setUri("...");
+ status.setLocalUri("...");
- // encode
- Blob encoded = status.wireEncode();
+ // encode
+ Blob encoded = status.wireEncode();
- // decode
- FaceStatus decoded = new FaceStatus();
- decoded.wireDecode(encoded.buf());
+ // decode
+ FaceStatus decoded = new FaceStatus();
+ decoded.wireDecode(encoded.buf());
- // test
- Assert.assertEquals(status.getFaceId(), decoded.getFaceId());
- Assert.assertEquals(status.getUri(), decoded.getUri());
- Assert.assertEquals(status.getLocalUri(), decoded.getLocalUri());
- Assert.assertEquals(status.getExpirationPeriod(), decoded.getExpirationPeriod());
- Assert.assertEquals(status.getFaceScope(), decoded.getFaceScope());
- Assert.assertEquals(status.getFacePersistency(), decoded.getFacePersistency());
- Assert.assertEquals(status.getLinkType(), decoded.getLinkType());
- Assert.assertEquals(status.getInBytes(), decoded.getInBytes());
- Assert.assertEquals(status.getOutBytes(), decoded.getOutBytes());
- }
+ // test
+ Assert.assertEquals(status.getFaceId(), decoded.getFaceId());
+ Assert.assertEquals(status.getUri(), decoded.getUri());
+ Assert.assertEquals(status.getLocalUri(), decoded.getLocalUri());
+ Assert.assertEquals(status.getExpirationPeriod(), decoded.getExpirationPeriod());
+ Assert.assertEquals(status.getFaceScope(), decoded.getFaceScope());
+ Assert.assertEquals(status.getFacePersistency(), decoded.getFacePersistency());
+ Assert.assertEquals(status.getLinkType(), decoded.getLinkType());
+ Assert.assertEquals(status.getInBytes(), decoded.getInBytes());
+ Assert.assertEquals(status.getOutBytes(), decoded.getOutBytes());
+ }
- /**
- * Test of decode method, of class FaceStatus.
- *
- * @throws java.lang.Exception
- */
- @Test
- public void testDecodeFakeData() throws Exception {
- Data data = getFaceData(true);
- List<FaceStatus> results = StatusDataset.wireDecode(data.getContent(), FaceStatus.class);
- assertTrue(results.size() > 4);
- for (FaceStatus f : results) {
- // the first face (face 1) should always be the internal face
- if (f.getFaceId() == 1) {
- assertEquals("internal://", f.getUri());
- assertEquals("internal://", f.getLocalUri());
- }
- }
- }
+ /**
+ * Test of decode method, of class FaceStatus.
+ *
+ * @throws java.lang.Exception
+ */
+ @Test
+ public void testDecodeFakeData() throws Exception {
+ Data data = getFaceData(true);
+ List<FaceStatus> results = StatusDataset.wireDecode(data.getContent(), FaceStatus.class);
+ assertTrue(results.size() > 4);
+ for (FaceStatus f : results) {
+ // the first face (face 1) should always be the internal face
+ if (f.getFaceId() == 1) {
+ assertEquals("internal://", f.getUri());
+ assertEquals("internal://", f.getLocalUri());
+ }
+ }
+ }
- /**
- * Integration test to run on actual system
- *
- * @param args
- * @throws EncodingException
- */
- public static void main(String[] args) throws Exception {
- Data data = getFaceData(false);
- List<FaceStatus> results = StatusDataset.wireDecode(data.getContent(), FaceStatus.class);
- assertTrue(results.size() > 4);
- for (FaceStatus f : results) {
- // the first face (face 1) should always be the internal face
- if (f.getFaceId() == 1) {
- assertEquals("internal://", f.getUri());
- assertEquals("internal://", f.getLocalUri());
- }
- }
- }
+ /**
+ * Integration test to run on actual system
+ *
+ * @param args
+ * @throws EncodingException
+ */
+ public static void main(String[] args) throws Exception {
+ Data data = getFaceData(false);
+ List<FaceStatus> results = StatusDataset.wireDecode(data.getContent(), FaceStatus.class);
+ assertTrue(results.size() > 4);
+ for (FaceStatus f : results) {
+ // the first face (face 1) should always be the internal face
+ if (f.getFaceId() == 1) {
+ assertEquals("internal://", f.getUri());
+ assertEquals("internal://", f.getLocalUri());
+ }
+ }
+ }
- /**
- * Retrieve a TLV encoded representation of the face list data
- *
- * @param usePreComputedData to avoid errors when local NFD is not present
- * @return
- */
- private static Data getFaceData(boolean usePreComputedData) {
- // use pre-computed data to avoid errors when local NFD is not present
- if (usePreComputedData) {
- Data data = new Data();
- data.setContent(new Blob(hexStringToByteArray(DATA)));
- return data;
- } // alternately, query the actual localhost for current data
- else {
- Face forwarder = new Face("localhost");
+ /**
+ * Retrieve a TLV encoded representation of the face list data
+ *
+ * @param usePreComputedData to avoid errors when local NFD is not present
+ * @return
+ */
+ private static Data getFaceData(boolean usePreComputedData) {
+ // use pre-computed data to avoid errors when local NFD is not present
+ if (usePreComputedData) {
+ Data data = new Data();
+ data.setContent(new Blob(hexStringToByteArray(DATA)));
+ return data;
+ } // alternately, query the actual localhost for current data
+ else {
+ Face forwarder = new Face("localhost");
- // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
- Interest interest = new Interest(new Name("/localhost/nfd/faces/list"));
- interest.setMustBeFresh(true);
- interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
- interest.setInterestLifetimeMilliseconds(2000.0);
+ // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
+ Interest interest = new Interest(new Name("/localhost/nfd/faces/list"));
+ interest.setMustBeFresh(true);
+ interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
+ interest.setInterestLifetimeMilliseconds(2000.0);
- // send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
- String hex = data.getContent().toHex();
- logger.info("Hex dump of face list: " + hex);
- return data;
- }
- }
+ // send packet
+ Data data = Client.getDefault().getSync(forwarder, interest);
+ String hex = data.getContent().toHex();
+ logger.info("Hex dump of face list: " + hex);
+ return data;
+ }
+ }
- /**
- * Pre-computed face list from a vanilla NFD running on Ubuntu 14.04
- */
- private static final String DATA = "803a690101720b696e7465726e616c3a2f2f810b696e7465726e616c3a2f2f840101850100860100900100910201429202063993010094010095010080406901fe720f636f6e74656e7473746f72653a2f2f810f636f6e74656e7473746f72653a2f2f84010185010086010090010091010092010093010094010095010080306901ff72076e756c6c3a2f2f81076e756c6c3a2f2f8401018501008601009001009101009201009301009401009501008053690201007219756470343a2f2f3232342e302e32332e3137303a35363336338117756470343a2f2f31302e35342e31322e373a35363336338401008501008601009001009101009201009301009401009501008056690201017219756470343a2f2f3232342e302e32332e3137303a3536333633811a756470343a2f2f3139322e3136382e35302e35373a3536333633840100850100860100900100910100920100930100940100950100804869020102721b65746865723a2f2f5b30313a30303a35653a30303a31373a61615d810a6465763a2f2f65746830840100850100860100900100910100920100930100940100950100804969020103721b65746865723a2f2f5b30313a30303a35653a30303a31373a61615d810b6465763a2f2f776c616e30840100850100860100900100910100920100930100940100950100804669020104720766643a2f2f32328114756e69783a2f2f2f72756e2f6e66642e736f636b840101850101860100900206349101019201019302012e940400014079950400041903804e690201197216746370343a2f2f3132372e302e302e313a35363336358115746370343a2f2f3132372e302e302e313a36333633840101850101860100900101910100920100930100940132950100";
+ /**
+ * Pre-computed face list from a vanilla NFD running on Ubuntu 14.04
+ */
+ private static final String DATA = "803a690101720b696e7465726e616c3a2f2f810b696e7465726e616c3a2f2f840101850100860100900100910201429202063993010094010095010080406901fe720f636f6e74656e7473746f72653a2f2f810f636f6e74656e7473746f72653a2f2f84010185010086010090010091010092010093010094010095010080306901ff72076e756c6c3a2f2f81076e756c6c3a2f2f8401018501008601009001009101009201009301009401009501008053690201007219756470343a2f2f3232342e302e32332e3137303a35363336338117756470343a2f2f31302e35342e31322e373a35363336338401008501008601009001009101009201009301009401009501008056690201017219756470343a2f2f3232342e302e32332e3137303a3536333633811a756470343a2f2f3139322e3136382e35302e35373a3536333633840100850100860100900100910100920100930100940100950100804869020102721b65746865723a2f2f5b30313a30303a35653a30303a31373a61615d810a6465763a2f2f65746830840100850100860100900100910100920100930100940100950100804969020103721b65746865723a2f2f5b30313a30303a35653a30303a31373a61615d810b6465763a2f2f776c616e30840100850100860100900100910100920100930100940100950100804669020104720766643a2f2f32328114756e69783a2f2f2f72756e2f6e66642e736f636b840101850101860100900206349101019201019302012e940400014079950400041903804e690201197216746370343a2f2f3132372e302e302e313a35363336358115746370343a2f2f3132372e302e302e313a36333633840101850101860100900101910100920100930100940132950100";
- /**
- * Convert hex string to bytes; special thanks to
- * http://stackoverflow.com/questions/140131
- *
- * @param s
- * @return
- */
- private static byte[] hexStringToByteArray(String s) {
- int len = s.length();
- byte[] data = new byte[len / 2];
- for (int i = 0; i < len; i += 2) {
- data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
- + Character.digit(s.charAt(i + 1), 16));
- }
- return data;
- }
+ /**
+ * Convert hex string to bytes; special thanks to
+ * http://stackoverflow.com/questions/140131
+ *
+ * @param s
+ * @return
+ */
+ private static byte[] hexStringToByteArray(String s) {
+ int len = s.length();
+ byte[] data = new byte[len / 2];
+ for (int i = 0; i < len; i += 2) {
+ data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ + Character.digit(s.charAt(i + 1), 16));
+ }
+ return data;
+ }
}
diff --git a/src/test/java/com/intel/jndn/management/FibEntryTest.java b/src/test/java/com/intel/jndn/management/FibEntryTest.java
index 85ac273..e198e7d 100644
--- a/src/test/java/com/intel/jndn/management/FibEntryTest.java
+++ b/src/test/java/com/intel/jndn/management/FibEntryTest.java
@@ -32,54 +32,54 @@
*/
public class FibEntryTest {
- /**
- * Test encoding/decoding
- *
- * @throws java.lang.Exception
- */
- @Test
- public void testEncodeDecode() throws Exception {
- NextHopRecord nextHopRecord = new NextHopRecord();
- nextHopRecord.setFaceId(42);
- nextHopRecord.setCost(100);
- FibEntry entry = new FibEntry();
- entry.setName(new Name("/fib/entry/test"));
- entry.getRecords().add(nextHopRecord);
+ /**
+ * Test encoding/decoding
+ *
+ * @throws java.lang.Exception
+ */
+ @Test
+ public void testEncodeDecode() throws Exception {
+ NextHopRecord nextHopRecord = new NextHopRecord();
+ nextHopRecord.setFaceId(42);
+ nextHopRecord.setCost(100);
+ FibEntry entry = new FibEntry();
+ entry.setName(new Name("/fib/entry/test"));
+ entry.getRecords().add(nextHopRecord);
- // encode
- Blob encoded = entry.wireEncode();
+ // encode
+ Blob encoded = entry.wireEncode();
- // decode
- FibEntry decoded = new FibEntry();
- decoded.wireDecode(encoded.buf());
+ // decode
+ FibEntry decoded = new FibEntry();
+ decoded.wireDecode(encoded.buf());
- // test
- Assert.assertEquals(entry.getName().toUri(), decoded.getName().toUri());
- Assert.assertEquals(entry.getRecords().get(0).getFaceId(), decoded.getRecords().get(0).getFaceId());
- Assert.assertEquals(entry.getRecords().get(0).getCost(), decoded.getRecords().get(0).getCost());
- }
+ // test
+ Assert.assertEquals(entry.getName().toUri(), decoded.getName().toUri());
+ Assert.assertEquals(entry.getRecords().get(0).getFaceId(), decoded.getRecords().get(0).getFaceId());
+ Assert.assertEquals(entry.getRecords().get(0).getCost(), decoded.getRecords().get(0).getCost());
+ }
- /**
- * Integration test to run on actual system
- *
- * @param args
- * @throws EncodingException
- */
- public static void main(String[] args) throws Exception {
- Face forwarder = new Face("localhost");
+ /**
+ * Integration test to run on actual system
+ *
+ * @param args
+ * @throws EncodingException
+ */
+ public static void main(String[] args) throws Exception {
+ Face forwarder = new Face("localhost");
- // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
- Interest interest = new Interest(new Name("/localhost/nfd/fib/list"));
- interest.setMustBeFresh(true);
- interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
- interest.setInterestLifetimeMilliseconds(2000.0);
+ // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
+ Interest interest = new Interest(new Name("/localhost/nfd/fib/list"));
+ interest.setMustBeFresh(true);
+ interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
+ interest.setInterestLifetimeMilliseconds(2000.0);
- // send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
+ // send packet
+ Data data = Client.getDefault().getSync(forwarder, interest);
- // decode results
- List<FibEntry> results = StatusDataset.wireDecode(data.getContent(), FibEntry.class);
- assertTrue(results.size() > 0);
- assertEquals("/localhost/nfd", results.get(0).getName().toUri());
- }
+ // decode results
+ List<FibEntry> results = StatusDataset.wireDecode(data.getContent(), FibEntry.class);
+ assertTrue(results.size() > 0);
+ assertEquals("/localhost/nfd", results.get(0).getName().toUri());
+ }
}
diff --git a/src/test/java/com/intel/jndn/management/RibEntryTest.java b/src/test/java/com/intel/jndn/management/RibEntryTest.java
index 96dd70b..a0ba770 100644
--- a/src/test/java/com/intel/jndn/management/RibEntryTest.java
+++ b/src/test/java/com/intel/jndn/management/RibEntryTest.java
@@ -32,56 +32,56 @@
*/
public class RibEntryTest {
- /**
- * Test encoding/decoding
- *
- * @throws java.lang.Exception
- */
- @Test
- public void testEncodeDecode() throws Exception {
- Route route = new Route();
- route.setFaceId(42);
- route.setCost(100);
- route.setOrigin(0);
- RibEntry entry = new RibEntry();
- entry.setName(new Name("/rib/entry/test"));
- entry.getRoutes().add(route);
+ /**
+ * Test encoding/decoding
+ *
+ * @throws java.lang.Exception
+ */
+ @Test
+ public void testEncodeDecode() throws Exception {
+ Route route = new Route();
+ route.setFaceId(42);
+ route.setCost(100);
+ route.setOrigin(0);
+ RibEntry entry = new RibEntry();
+ entry.setName(new Name("/rib/entry/test"));
+ entry.getRoutes().add(route);
- // encode
- Blob encoded = entry.wireEncode();
+ // encode
+ Blob encoded = entry.wireEncode();
- // decode
- RibEntry decoded = new RibEntry();
- decoded.wireDecode(encoded.buf());
+ // decode
+ RibEntry decoded = new RibEntry();
+ decoded.wireDecode(encoded.buf());
- // test
- Assert.assertEquals(entry.getName().toUri(), decoded.getName().toUri());
- Assert.assertEquals(entry.getRoutes().get(0).getFaceId(), decoded.getRoutes().get(0).getFaceId());
- Assert.assertEquals(entry.getRoutes().get(0).getCost(), decoded.getRoutes().get(0).getCost());
- Assert.assertEquals(entry.getRoutes().get(0).getOrigin(), decoded.getRoutes().get(0).getOrigin());
- }
+ // test
+ Assert.assertEquals(entry.getName().toUri(), decoded.getName().toUri());
+ Assert.assertEquals(entry.getRoutes().get(0).getFaceId(), decoded.getRoutes().get(0).getFaceId());
+ Assert.assertEquals(entry.getRoutes().get(0).getCost(), decoded.getRoutes().get(0).getCost());
+ Assert.assertEquals(entry.getRoutes().get(0).getOrigin(), decoded.getRoutes().get(0).getOrigin());
+ }
- /**
- * Integration test to run on actual system
- *
- * @param args
- * @throws EncodingException
- */
- public static void main(String[] args) throws Exception {
- Face forwarder = new Face("localhost");
+ /**
+ * Integration test to run on actual system
+ *
+ * @param args
+ * @throws EncodingException
+ */
+ public static void main(String[] args) throws Exception {
+ Face forwarder = new Face("localhost");
- // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
- Interest interest = new Interest(new Name("/localhost/nfd/rib/list"));
- interest.setMustBeFresh(true);
- interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
- interest.setInterestLifetimeMilliseconds(2000.0);
+ // build management Interest packet; see http://redmine.named-data.net/projects/nfd/wiki/StatusDataset
+ Interest interest = new Interest(new Name("/localhost/nfd/rib/list"));
+ interest.setMustBeFresh(true);
+ interest.setChildSelector(Interest.CHILD_SELECTOR_RIGHT);
+ interest.setInterestLifetimeMilliseconds(2000.0);
- // send packet
- Data data = Client.getDefault().getSync(forwarder, interest);
+ // send packet
+ Data data = Client.getDefault().getSync(forwarder, interest);
- // decode results
- List<RibEntry> results = StatusDataset.wireDecode(data.getContent(), RibEntry.class);
- assertTrue(results.size() > 0);
- assertEquals("/localhost/nfd", results.get(0).getName().toUri());
- }
+ // decode results
+ List<RibEntry> results = StatusDataset.wireDecode(data.getContent(), RibEntry.class);
+ assertTrue(results.size() > 0);
+ assertEquals("/localhost/nfd", results.get(0).getName().toUri());
+ }
}