Update management protocol to be compatible with NFD 0.6.2
Change-Id: I85975151d969901b842c83c649ccd86059488274
diff --git a/README.md b/README.md
index b4f4477..e8b8065 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# jndn-management
-This project consists of tools for managing an NDN forwarding daemon (NFD). It relies on the [NDN Protocol](https://named-data.net) and its associated [client library](https://github.com/named-data/jndn). It implements the NFD management specification outlined at http://redmine.named-data.net/projects/nfd/wiki/Management. Please note that this library does not yet implement all of the commands in the management specification.
+This project consists of tools for managing an NDN forwarding daemon (NFD). It relies on the [NDN Protocol](https://named-data.net) and its associated [client library](https://github.com/named-data/jndn). It implements the NFD management specification outlined at https://redmine.named-data.net/projects/nfd/wiki/Management. Please note that this library does not yet implement all of the commands in the management specification.
## Install
With Maven, add the following to your POM:
diff --git a/build.gradle b/build.gradle
index cd2bfee..5e662e9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -18,7 +18,7 @@
// group = 'com.intel.jndn.management'
group = 'net.named-data.jndn-extra'
-version = '1.1.4'
+version = '1.2.1'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
diff --git a/src/main/java/com/intel/jndn/management/Nfdc.java b/src/main/java/com/intel/jndn/management/Nfdc.java
index a48e88f..1ab7ae2 100644
--- a/src/main/java/com/intel/jndn/management/Nfdc.java
+++ b/src/main/java/com/intel/jndn/management/Nfdc.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015-2016, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -13,7 +13,6 @@
*/
package com.intel.jndn.management;
-import com.intel.jndn.management.enums.LocalControlHeader;
import com.intel.jndn.management.enums.RouteOrigin;
import com.intel.jndn.management.helpers.FetchHelper;
import com.intel.jndn.management.helpers.StatusDatasetHelper;
@@ -39,13 +38,14 @@
/**
* Helper class for interacting with an NDN forwarder daemon; see
- * <a href="http://redmine.named-data.net/projects/nfd/wiki/Management">NFD Management</a>
+ * <a href="https://redmine.named-data.net/projects/nfd/wiki/Management">NFD Management</a>
* for explanations of the various protocols used.
*
* @author Andrew Brown <andrew.brown@intel.com>
*/
public final class Nfdc {
private static final int OK_STATUS = 200;
+ private static final int FACE_ALREADY_EXISTS = 409;
/////////////////////////////////////////////////////////////////////////////
@@ -62,7 +62,7 @@
* @param face only a localhost Face
* @return the forwarder status object
* @throws ManagementException if the network request failed or the returned status could not be decoded
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus">ForwarderStatus</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus">ForwarderStatus</a>
*/
public static ForwarderStatus getForwarderStatus(final Face face) throws ManagementException {
try {
@@ -81,7 +81,7 @@
* @param face only a localhost Face
* @return a list of face status objects
* @throws ManagementException if the network request failed or if the NFD rejected the request
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">FaceManagement</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">FaceManagement</a>
*/
public static List<FaceStatus> getFaceList(final Face face) throws ManagementException {
try {
@@ -100,7 +100,7 @@
* @param face only a localhost Face
* @return a list of FIB entries
* @throws ManagementException if the network request failed or if the NFD rejected the request
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset">FIB Dataset</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset">FIB Dataset</a>
*/
public static List<FibEntry> getFibList(final Face face) throws ManagementException {
try {
@@ -119,7 +119,7 @@
* @param face only a localhost Face
* @return a list of RIB entries, i.e. routes
* @throws ManagementException if the network request failed or if the NFD rejected the request
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset">RIB Dataset</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset">RIB Dataset</a>
*/
public static List<RibEntry> getRouteList(final Face face) throws ManagementException {
try {
@@ -139,7 +139,7 @@
* @return a list of strategy choice entries, i.e. routes
* @throws ManagementException if the network request failed, the NFD response could not be decoded, or
* the NFD rejected the request
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice">StrategyChoice</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice">StrategyChoice</a>
*/
public static List<StrategyChoice> getStrategyList(final Face face) throws ManagementException {
try {
@@ -159,7 +159,7 @@
* @return a list of channel status entries
* @throws ManagementException if the network request failed, the NFD response could not be decoded, or
* the NFD rejected the request
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset">Face Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset">Face Management</a>
*/
public static List<ChannelStatus> getChannelStatusList(final Face face) throws ManagementException {
try {
@@ -242,54 +242,6 @@
}
/**
- * Enable a local control feature on the given forwarder.
- *
- * @param face only a localhost {@link Face}
- * @param header the control feature to enable
- * @throws ManagementException if the network request failed, the NFD response could not be decoded, or
- * the NFD rejected the request
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">Face Management</a>
- */
- public static void enableLocalControlHeader(final Face face, final LocalControlHeader header) throws
- ManagementException {
- // build command name
- Name command = new Name("/localhost/nfd/faces/enable-local-control");
- ControlParameters parameters = new ControlParameters();
- parameters.setLocalControlFeature(header.toInteger());
- command.append(parameters.wireEncode());
-
- try {
- sendCommand(face, command);
- } catch (IOException | EncodingException | ManagementException e) {
- throw new ManagementException(e.getMessage(), e);
- }
- }
-
- /**
- * Disable a local control feature on the given forwarder.
- *
- * @param face only a localhost {@link Face}
- * @param header the control feature to disable
- * @throws ManagementException if the network request failed, the NFD response could not be decoded, or
- * the NFD rejected the request
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">Face Management</a>
- */
- public static void disableLocalControlHeader(final Face face, final LocalControlHeader header) throws
- ManagementException {
- // build command name
- Name command = new Name("/localhost/nfd/faces/disable-local-control");
- ControlParameters parameters = new ControlParameters();
- parameters.setLocalControlFeature(header.toInteger());
- command.append(parameters.wireEncode());
-
- try {
- sendCommand(face, command);
- } catch (IOException | EncodingException | ManagementException e) {
- throw new ManagementException(e.getMessage(), e);
- }
- }
-
- /**
* Register a route on the forwarder.
* <p/>
* Ensure the forwarding face is on the local machine (management requests are to /localhost/...) and that command
@@ -300,7 +252,7 @@
* @throws ManagementException if the network request failed, the NFD response could not be decoded, or
* the NFD rejected the request
* @see <a href="http://named-data.net/doc/NFD/current/manpages/nfdc.html">nfdc</a>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
*/
public static void register(final Face face, final ControlParameters controlParameters) throws ManagementException {
// build command name
@@ -344,7 +296,7 @@
* @param face only a localhost {@link Face}
* @param uri the URI (e.g. "tcp4://10.10.2.2:6363") of the remote node; note
* that this must be one of the canonical forms described in the wiki
- * (http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#TCP) for NFD to
+ * (https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#TCP) for NFD to
* accept the registration--otherwise you will see 400 errors
* @param route the {@link Name} prefix of the route
* @param cost the numeric cost of forwarding along the route
@@ -400,7 +352,7 @@
* @throws ManagementException if the network request failed, the NFD response could not be decoded, or
* the NFD rejected the request
* @see <a href="http://named-data.net/doc/NFD/current/manpages/nfdc.html">nfdc</a>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
*/
public static void unregister(final Face face, final ControlParameters controlParameters) throws ManagementException {
// build command name
@@ -425,7 +377,7 @@
* @throws ManagementException if the network request failed, the NFD response could not be decoded, or
* the NFD rejected the request
* @see <a href="http://named-data.net/doc/NFD/current/manpages/nfdc.html">nfdc</a>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
*/
public static void unregister(final Face face, final Name route) throws ManagementException {
// build command name
@@ -449,7 +401,7 @@
* @throws ManagementException if the network request failed, the NFD response could not be decoded, or
* the NFD rejected the request
* @see <a href="http://named-data.net/doc/NFD/current/manpages/nfdc.html">nfdc</a>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
*/
public static void unregister(final Face face, final Name route, final int faceId) throws ManagementException {
// build command name
@@ -474,7 +426,7 @@
* @throws ManagementException if the network request failed, the NFD response could not be decoded, or
* the NFD rejected the request
* @see <a href="http://named-data.net/doc/NFD/current/manpages/nfdc.html">nfdc command-line usage</a>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RibMgmt</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RibMgmt</a>
*/
public static void unregister(final Face face, final Name route, final String uri) throws ManagementException {
int faceId = -1;
@@ -506,7 +458,7 @@
* @throws ManagementException if the network request failed, the NFD response could not be decoded, or
* the NFD rejected the request
* @see <a href="http://named-data.net/doc/NFD/current/manpages/nfdc.html">nfdc command-line usage</a>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice">StrategyChoice</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice">StrategyChoice</a>
*/
public static void setStrategy(final Face face, final Name prefix, final Name strategy) throws ManagementException {
// build command name
@@ -558,7 +510,7 @@
*
* @param face only a localhost Face, command signing info must be set
* @param name As described at
- * <a href="http://redmine.named-data.net/projects/nfd/wiki/ControlCommand">ControlCommand</a>,
+ * <a href="https://redmine.named-data.net/projects/nfd/wiki/ControlCommand">ControlCommand</a>,
* the requested interest must have encoded ControlParameters appended to the
* interest name
* @return a {@link ControlResponse}
@@ -590,7 +542,7 @@
response.wireDecode(data.getContent().buf());
// check response for success
- if (response.getStatusCode() != OK_STATUS) {
+ if (response.getStatusCode() != OK_STATUS && response.getStatusCode() != FACE_ALREADY_EXISTS) {
throw ManagementException.fromResponse(response);
}
diff --git a/src/main/java/com/intel/jndn/management/enums/FacePersistency.java b/src/main/java/com/intel/jndn/management/enums/FacePersistency.java
index 678b1a2..48aa0bc 100644
--- a/src/main/java/com/intel/jndn/management/enums/FacePersistency.java
+++ b/src/main/java/com/intel/jndn/management/enums/FacePersistency.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015-2016, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -17,7 +17,7 @@
* Indicate whether the face is persistent; used by FaceStatus.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/widi/FaceMgmt">Face Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">Face Management</a>
*/
public enum FacePersistency {
NONE(-1), // invalid value
@@ -49,6 +49,23 @@
}
/**
+ * Convert FacePersistency to human-readable string.
+ * @return string
+ */
+ public final String toString() {
+ switch (value) {
+ case 0:
+ return "persistent";
+ case 1:
+ return "on-demand";
+ case 2:
+ return "permanent";
+ default:
+ return "none";
+ }
+ }
+
+ /**
* Convert NFD code to FacePersistency enum.
*
* @param value NFD's FacePersistency code
diff --git a/src/main/java/com/intel/jndn/management/enums/FaceScope.java b/src/main/java/com/intel/jndn/management/enums/FaceScope.java
index 9b6796b..fa584de 100644
--- a/src/main/java/com/intel/jndn/management/enums/FaceScope.java
+++ b/src/main/java/com/intel/jndn/management/enums/FaceScope.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015-2016, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -18,7 +18,7 @@
* FaceStatus.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/widi/FaceMgmt">Face Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">Face Management</a>
*/
public enum FaceScope {
@@ -50,6 +50,21 @@
}
/**
+ * Convert FaceScope to human-readable string.
+ * @return string
+ */
+ public final String toString() {
+ switch (value) {
+ case 0:
+ return "non-local";
+ case 1:
+ return "local";
+ default:
+ return "none";
+ }
+ }
+
+ /**
* Convert NFD code to FaceScope enum.
*
* @param value NFD's FaceScope code
diff --git a/src/main/java/com/intel/jndn/management/enums/LinkType.java b/src/main/java/com/intel/jndn/management/enums/LinkType.java
index 8d4a1c8..2735173 100644
--- a/src/main/java/com/intel/jndn/management/enums/LinkType.java
+++ b/src/main/java/com/intel/jndn/management/enums/LinkType.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015-2016, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -16,13 +16,14 @@
/**
* NFD face link type.
*
- * @see <a href="http://redmine.named-data.net/projects/nfd/widi/FaceMgmt">Face Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">Face Management</a>
*/
public enum LinkType {
NONE(-1),
POINT_TO_POINT(0),
- MULTI_ACCESS(1);
+ MULTI_ACCESS(1),
+ AD_HOC(2);
private final int value;
@@ -47,6 +48,23 @@
}
/**
+ * Convert LinkType to human-readable string.
+ * @return string
+ */
+ public final String toString() {
+ switch (value) {
+ case 0:
+ return "point-to-point";
+ case 1:
+ return "multi-access";
+ case 2:
+ return "adhoc";
+ default:
+ return "none";
+ }
+ }
+
+ /**
* Convert NFD code to LinkType enum.
*
* @param value NFD's LinkType code
@@ -59,6 +77,8 @@
return POINT_TO_POINT;
case 1:
return MULTI_ACCESS;
+ case 2:
+ return AD_HOC;
default:
return NONE;
}
diff --git a/src/main/java/com/intel/jndn/management/enums/LocalControlHeader.java b/src/main/java/com/intel/jndn/management/enums/LocalControlHeader.java
deleted file mode 100644
index 426be64..0000000
--- a/src/main/java/com/intel/jndn/management/enums/LocalControlHeader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * jndn-management
- * Copyright (c) 2015, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU Lesser General Public License,
- * version 3, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
- * more details.
- */
-package com.intel.jndn.management.enums;
-
-/**
- * Define constants for local control header options.
- *
- * @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/widi/FaceMgmt">Face Management</a>
- */
-public enum LocalControlHeader {
-
- INCOMING_FACE_ID(1),
- NEXT_HOP_FACE_ID(2),
- CACHING_POLICY(3);
-
- private final int value;
-
- /////////////////////////////////////////////////////////////////////////////
-
- /**
- * Create enum using NFD's LocalControlHeader code.
- *
- * @param value NFD's LocalControlHeader code
- */
- LocalControlHeader(final int value) {
- this.value = value;
- }
-
- /**
- * Convert LocalControlHeader to the NFD code.
- *
- * @return NFD's LocalControlHeader code
- */
- public final int toInteger() {
- return value;
- }
-}
diff --git a/src/main/java/com/intel/jndn/management/enums/NfdTlv.java b/src/main/java/com/intel/jndn/management/enums/NfdTlv.java
index 8f7b536..253bcbc 100644
--- a/src/main/java/com/intel/jndn/management/enums/NfdTlv.java
+++ b/src/main/java/com/intel/jndn/management/enums/NfdTlv.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015-2016, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -17,7 +17,7 @@
/**
* NFD Management protocol TLV codes.
*
- * @see <a href="http://redmine.named-data.net/projects/nfd/widi/FaceMgmt">Face Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">Face Management</a>
*/
@SuppressWarnings("CheckStyle")
public final class NfdTlv {
@@ -28,25 +28,28 @@
}
// ControlParameters
- // http://redmine.named-data.net/projects/nfd/wiki/ControlCommand
+ // https://redmine.named-data.net/projects/nfd/wiki/ControlCommand
public static final int ControlParameters = 104;
public static final int FaceId = 105;
public static final int Uri = 114;
- public static final int LocalControlFeature = 110;
+ public static final int LocalUri = 129;
public static final int Origin = 111;
public static final int Cost = 106;
+ public static final int Capacity = 131;
+ public static final int Count = 132;
+ public static final int BaseCongestionMarkingInterval = 135;
+ public static final int DefaultCongestionThreshold = 136;
+ public static final int Mtu = 137;
public static final int Flags = 108;
+ public static final int Mask = 112;
public static final int Strategy = 107;
public static final int ExpirationPeriod = 109;
-
- // ControlResponse
- // http://redmine.named-data.net/projects/nfd/wiki/ControlCommand
public static final int ControlResponse = 101;
public static final int StatusCode = 102;
public static final int StatusText = 103;
// ForwarderStatus
- // http://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus
+ // https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus
public static final int NfdVersion = 128;
public static final int StartTimestamp = 129;
public static final int CurrentTimestamp = 130;
@@ -57,41 +60,47 @@
public static final int NCsEntries = 135;
// Face Management
- // http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt
+ // https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt
public static final int FaceStatus = 128;
- public static final int LocalUri = 129;
public static final int ChannelStatus = 130;
public static final int UriScheme = 131;
public static final int FaceScope = 132;
public static final int FacePersistency = 133;
public static final int LinkType = 134;
+
public static final int FaceQueryFilter = 150;
public static final int FaceEventNotification = 192;
public static final int FaceEventKind = 193;
// ForwarderStatus and FaceStatus counters
- // http://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus
- // http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt
+ // https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus
+ // https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt
public static final int NInInterests = 144;
- public static final int NInDatas = 145;
+ public static final int NInData = 145;
public static final int NInNacks = 151;
public static final int NOutInterests = 146;
- public static final int NOutDatas = 147;
+ public static final int NOutData = 147;
public static final int NOutNacks = 152;
public static final int NInBytes = 148;
public static final int NOutBytes = 149;
// FIB Management
- // http://redmine.named-data.net/projects/nfd/wiki/FibMgmt
+ // https://redmine.named-data.net/projects/nfd/wiki/FibMgmt
public static final int FibEntry = 128;
public static final int NextHopRecord = 129;
+ // CS Management
+ // https://redmine.named-data.net/projects/nfd/wiki/CsMgmt
+ public static final int CsInfo = 128;
+ public static final int NHits = 129;
+ public static final int NMisses = 130;
+
// Strategy Choice Management
- // http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice
+ // https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice
public static final int StrategyChoice = 128;
// RIB Management
- // http://redmine.named-data.net/projects/nfd/wiki/RibMgmt
+ // https://redmine.named-data.net/projects/nfd/wiki/RibMgmt
public static final int RibEntry = 128;
public static final int Route = 129;
}
diff --git a/src/main/java/com/intel/jndn/management/enums/RouteFlags.java b/src/main/java/com/intel/jndn/management/enums/RouteFlags.java
index 86c41f6..7cafad4 100644
--- a/src/main/java/com/intel/jndn/management/enums/RouteFlags.java
+++ b/src/main/java/com/intel/jndn/management/enums/RouteFlags.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015-2016, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -13,10 +13,13 @@
*/
package com.intel.jndn.management.enums;
+import java.util.HashMap;
+import java.util.StringJoiner;
+
/**
* NFD route flags.
*
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
*/
public enum RouteFlags {
NONE(0),
@@ -37,6 +40,36 @@
}
/**
+ * Convert RouteFlags to human-readable string.
+ * @return string
+ */
+ public final String toString() {
+ if (value == NONE.toInteger()) {
+ return "none";
+ }
+
+ HashMap<RouteFlags, String> knownBits = new HashMap<>();
+ knownBits.put(CHILD_INHERIT, "child-inherit");
+ knownBits.put(CAPTURE, "capture");
+
+ StringJoiner join = new StringJoiner("|");
+ int routeFlags = value;
+ for (HashMap.Entry<RouteFlags, String> entry : knownBits.entrySet()) {
+ int bit = entry.getKey().toInteger();
+ String token = entry.getValue();
+
+ if ((routeFlags & bit) != 0) {
+ join.add(token);
+ routeFlags = routeFlags & ~bit;
+ }
+ }
+ if (routeFlags != NONE.toInteger()) {
+ join.add(String.format("0x%x", routeFlags));
+ }
+ return join.toString();
+ }
+
+ /**
* Convert RouteFlags to the NFD code.
*
* @return NFD's RouteFlags code
diff --git a/src/main/java/com/intel/jndn/management/enums/RouteOrigin.java b/src/main/java/com/intel/jndn/management/enums/RouteOrigin.java
index 20666c0..6fdbb27 100644
--- a/src/main/java/com/intel/jndn/management/enums/RouteOrigin.java
+++ b/src/main/java/com/intel/jndn/management/enums/RouteOrigin.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015-2016, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -16,15 +16,16 @@
/**
* NFD route origin.
*
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/RibMgmt">RIB Management</a>
*/
public enum RouteOrigin {
- UNKNOWN(-1),
+ NONE(-1),
APP(0),
AUTOREG(64),
CLIENT(65),
AUTOCONF(66),
NLSR(128),
+ SELFLEARNING(129),
STATIC(255);
private final int value;
@@ -50,6 +51,30 @@
}
/**
+ * Convert RouteOrigin to human-readable string.
+ * @return string
+ */
+ public final String toString() {
+ if (value == APP.toInteger()) {
+ return "app";
+ } else if (value == AUTOREG.toInteger()) {
+ return "autoreg";
+ } else if (value == CLIENT.toInteger()) {
+ return "client";
+ } else if (value == AUTOCONF.toInteger()) {
+ return "autoconf";
+ } else if (value == NLSR.toInteger()) {
+ return "nlsr";
+ } else if (value == SELFLEARNING.toInteger()) {
+ return "selflearning";
+ } else if (value == STATIC.toInteger()) {
+ return "static";
+ } else {
+ return "none";
+ }
+ }
+
+ /**
* Convert NFD code to RouteOrigin enum.
*
* @param value NFD's RouteOrigin code
@@ -67,10 +92,12 @@
return AUTOCONF;
} else if (value == NLSR.toInteger()) {
return NLSR;
+ } else if (value == SELFLEARNING.toInteger()) {
+ return SELFLEARNING;
} else if (value == STATIC.toInteger()) {
return STATIC;
} else {
- return UNKNOWN;
+ return NONE;
}
}
}
diff --git a/src/main/java/com/intel/jndn/management/enums/Strategies.java b/src/main/java/com/intel/jndn/management/enums/Strategies.java
index bfb1fed..b375a7f 100644
--- a/src/main/java/com/intel/jndn/management/enums/Strategies.java
+++ b/src/main/java/com/intel/jndn/management/enums/Strategies.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015-2016, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -19,7 +19,7 @@
* A reference list of the strategies available in NFD.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy">Strategies</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice#Strategy">Strategies</a>
*/
public final class Strategies {
public static final Name BEST_ROUTE = new Name("/localhost/nfd/strategy/best-route");
diff --git a/src/main/java/com/intel/jndn/management/enums/package-info.java b/src/main/java/com/intel/jndn/management/enums/package-info.java
index 2d340a5..c975bad 100644
--- a/src/main/java/com/intel/jndn/management/enums/package-info.java
+++ b/src/main/java/com/intel/jndn/management/enums/package-info.java
@@ -1,3 +1,17 @@
+/*
+ * jndn-management
+ * Copyright (c) 2015-2018, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
/**
* NFD constants and enumerations.
* @see <a href="http://redmine.named-data.net/projects/nfd/wiki/Management">NFD Management</a>
diff --git a/src/main/java/com/intel/jndn/management/helpers/StatusDatasetHelper.java b/src/main/java/com/intel/jndn/management/helpers/StatusDatasetHelper.java
index 863d918..86ff954 100644
--- a/src/main/java/com/intel/jndn/management/helpers/StatusDatasetHelper.java
+++ b/src/main/java/com/intel/jndn/management/helpers/StatusDatasetHelper.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015-2016, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -28,7 +28,7 @@
* Helper class to handle StatusDatasets.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/StatusDataset">StatusDataset</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/StatusDataset">StatusDataset</a>
*/
public final class StatusDatasetHelper {
/**
@@ -66,7 +66,7 @@
* @param type class implementing Decodable interface
* @return List decoded status entries
* @throws ManagementException when decoding fails
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/StatusDataset">StatusDataset</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/StatusDataset">StatusDataset</a>
*/
public static <T extends Decodable> List<T>
wireDecode(final List<Data> segments, final Class<T> type) throws ManagementException {
diff --git a/src/main/java/com/intel/jndn/management/helpers/package-info.java b/src/main/java/com/intel/jndn/management/helpers/package-info.java
index fcfcb02..535effa 100644
--- a/src/main/java/com/intel/jndn/management/helpers/package-info.java
+++ b/src/main/java/com/intel/jndn/management/helpers/package-info.java
@@ -1,3 +1,17 @@
+/*
+ * jndn-management
+ * Copyright (c) 2015-2018, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
/**
* Various helpers.
*/
diff --git a/src/main/java/com/intel/jndn/management/package-info.java b/src/main/java/com/intel/jndn/management/package-info.java
index 79be44a..34ab016 100644
--- a/src/main/java/com/intel/jndn/management/package-info.java
+++ b/src/main/java/com/intel/jndn/management/package-info.java
@@ -1,3 +1,17 @@
+/*
+ * jndn-management
+ * Copyright (c) 2015-2018, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
/**
* Classes implementing NFD management protocol.
* @see <a href="http://redmine.named-data.net/projects/nfd/wiki/Management">NFD Management</a>
diff --git a/src/main/java/com/intel/jndn/management/types/ChannelStatus.java b/src/main/java/com/intel/jndn/management/types/ChannelStatus.java
index 8f30d07..bf74471 100644
--- a/src/main/java/com/intel/jndn/management/types/ChannelStatus.java
+++ b/src/main/java/com/intel/jndn/management/types/ChannelStatus.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2016, Regents of the University of California.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -25,7 +25,7 @@
/**
* Represent a ChannelStatus object.
*
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset">Face Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt#Channel-Dataset">Face Management</a>
*/
public class ChannelStatus implements Decodable {
private String localUri = "";
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 b531c97..6a1777b 100644
--- a/src/main/java/com/intel/jndn/management/types/FaceStatus.java
+++ b/src/main/java/com/intel/jndn/management/types/FaceStatus.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -29,23 +29,28 @@
* Represent a FaceStatus object from /localhost/nfd/faces/list.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">Face Management</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt">Face Management</a>
*/
public class FaceStatus implements Decodable {
private int faceId = 0;
private String remoteUri = "";
private String localUri = "";
+ private int expirationPeriod = 0;
private FaceScope faceScope = FaceScope.LOCAL;
private FacePersistency facePersistency = FacePersistency.PERSISTENT;
private LinkType linkType = LinkType.POINT_TO_POINT;
- private int expirationPeriod = 0;
+ private int baseCongestionMarkingInterval = -1;
+ private int defaultCongestionThreshold = -1;
+ private int mtu = -1;
+ private int flags = 0;
+
private int inInterests = 0;
- private int inDatas = 0;
+ private int inData = 0;
private int inNacks = 0;
private int outInterests = 0;
- private int outDatas = 0;
+ private int outData = 0;
private int outNacks = 0;
private int inBytes = 0;
@@ -88,17 +93,22 @@
*/
public final void wireEncode(final TlvEncoder encoder) {
int saveLength = encoder.getLength();
+ encoder.writeNonNegativeIntegerTlv(NfdTlv.Flags, flags);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NOutBytes, outBytes);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NInBytes, inBytes);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NOutNacks, outNacks);
- encoder.writeNonNegativeIntegerTlv(NfdTlv.NOutDatas, outDatas);
+ encoder.writeNonNegativeIntegerTlv(NfdTlv.NOutData, outData);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NOutInterests, outInterests);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NInNacks, inNacks);
- encoder.writeNonNegativeIntegerTlv(NfdTlv.NInDatas, inDatas);
+ encoder.writeNonNegativeIntegerTlv(NfdTlv.NInData, inData);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NInInterests, inInterests);
+ encoder.writeOptionalNonNegativeIntegerTlv(NfdTlv.Mtu, mtu);
+ encoder.writeOptionalNonNegativeIntegerTlv(NfdTlv.DefaultCongestionThreshold, defaultCongestionThreshold);
+ encoder.writeOptionalNonNegativeIntegerTlv(NfdTlv.BaseCongestionMarkingInterval, baseCongestionMarkingInterval);
+
encoder.writeNonNegativeIntegerTlv(NfdTlv.LinkType, linkType.toInteger());
encoder.writeNonNegativeIntegerTlv(NfdTlv.FacePersistency, facePersistency.toInteger());
encoder.writeNonNegativeIntegerTlv(NfdTlv.FaceScope, faceScope.toInteger());
@@ -140,17 +150,25 @@
this.facePersistency = FacePersistency.fromInteger((int) decoder.readNonNegativeIntegerTlv(NfdTlv.FacePersistency));
this.linkType = LinkType.fromInteger((int) decoder.readNonNegativeIntegerTlv(NfdTlv.LinkType));
+ this.baseCongestionMarkingInterval =
+ (int) decoder.readOptionalNonNegativeIntegerTlv(NfdTlv.BaseCongestionMarkingInterval, endOffset);
+ this.defaultCongestionThreshold = (int) decoder.readOptionalNonNegativeIntegerTlv(
+ NfdTlv.DefaultCongestionThreshold, endOffset);
+ this.mtu = (int) decoder.readOptionalNonNegativeIntegerTlv(NfdTlv.Mtu, endOffset);
+
this.inInterests = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.NInInterests);
- this.inDatas = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.NInDatas);
+ this.inData = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.NInData);
this.inNacks = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.NInNacks);
this.outInterests = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.NOutInterests);
- this.outDatas = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.NOutDatas);
+ this.outData = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.NOutData);
this.outNacks = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.NOutNacks);
this.inBytes = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.NInBytes);
this.outBytes = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.NOutBytes);
+ this.flags = (int) decoder.readNonNegativeIntegerTlv(NfdTlv.Flags);
+
decoder.finishNestedTlvs(endOffset);
}
@@ -289,6 +307,94 @@
}
/**
+ * Check if Face has BaseCongestionMarkingInterval set.
+ * @return true if Face has BaseCongestionMarkingInterval set, false otherwise
+ */
+ public boolean hasBaseCongestionMarkingInterval() {
+ return baseCongestionMarkingInterval >= 0;
+ }
+
+ /**
+ * @return BaseCongestionMarkingInterval
+ */
+ public int getBaseCongestionMarkingInterval() {
+ return baseCongestionMarkingInterval;
+ }
+
+ /**
+ * @param baseCongestionMarkingInterval BaseCongestionMarkingInterval
+ * @return this
+ */
+ public FaceStatus setBaseCongestionMarkingInterval(final int baseCongestionMarkingInterval) {
+ this.baseCongestionMarkingInterval = baseCongestionMarkingInterval;
+ return this;
+ }
+
+ /**
+ * Check if Face has DefaultCongestionThreshold set.
+ * @return true if Face has DefaultCongestionThreshold set, false otherwise
+ */
+ public boolean hasDefaultCongestionThreshold() {
+ return defaultCongestionThreshold >= 0;
+ }
+
+ /**
+ * @return DefaultCongestionThreshold
+ */
+ public int getDefaultCongestionThreshold() {
+ return defaultCongestionThreshold;
+ }
+
+ /**
+ * @param defaultCongestionThreshold DefaultCongestionThreshold
+ * @return this
+ */
+ public FaceStatus setDefaultCongestionThreshold(final int defaultCongestionThreshold) {
+ this.defaultCongestionThreshold = defaultCongestionThreshold;
+ return this;
+ }
+
+ /**
+ * Check if Face has MTU set.
+ * @return true if Face has Mtu set, false otherwise
+ */
+ public boolean hasMtu() {
+ return mtu >= 0;
+ }
+
+ /**
+ * @return MTU
+ */
+ public int getMtu() {
+ return mtu;
+ }
+
+ /**
+ * @param mtu Face MTU
+ * @return this
+ */
+ public FaceStatus setMtu(final int mtu) {
+ this.mtu = mtu;
+ return this;
+ }
+
+ /**
+ * @return Face flags
+ */
+ public int getFlags() {
+ return flags;
+ }
+
+ /**
+ * @param flags Face flags
+ * @return this
+ */
+ public FaceStatus setFlags(final int flags) {
+ this.flags = flags;
+ return this;
+ }
+
+ /**
* @return number of received Interest packets
*/
public int getNInInterests() {
@@ -327,36 +433,36 @@
/**
* @return number of received Data packets
*/
- public int getNInDatas() {
- return inDatas;
+ public int getNInData() {
+ return inData;
}
/**
* Set number of received Data packets.
*
- * @param inDatas number of received Data packets
+ * @param inData number of received Data packets
* @return this
*/
- public FaceStatus setNInDatas(final int inDatas) {
- this.inDatas = inDatas;
+ public FaceStatus setNInData(final int inData) {
+ this.inData = inData;
return this;
}
/**
* @return number of sent Data packets
*/
- public int getNOutDatas() {
- return outDatas;
+ public int getNOutData() {
+ return outData;
}
/**
* Set number of sent Data packets.
*
- * @param outDatas number of sent Data packets
+ * @param outData number of sent Data packets
* @return this
*/
- public FaceStatus setNOutDatas(final int outDatas) {
- this.outDatas = outDatas;
+ public FaceStatus setNOutData(final int outData) {
+ this.outData = outData;
return this;
}
@@ -434,31 +540,47 @@
@Override
public String toString() {
- StringBuilder ret = new StringBuilder();
+ StringBuilder os = new StringBuilder();
- ret.append("FaceStatus(")
- .append("FaceID: ").append(getFaceId()).append(",\n")
- .append("RemoteUri: ").append(getRemoteUri()).append(",\n")
- .append("LocalUri: ").append(getLocalUri()).append(",\n");
+ os.append("Face(FaceId: ").append(this.getFaceId()).append(",\n")
+ .append(" RemoteUri: ").append(this.getRemoteUri()).append(",\n")
+ .append(" LocalUri: ").append(this.getLocalUri()).append(",\n");
- if (hasExpirationPeriod()) {
- ret.append("ExpirationPeriod: ").append(getExpirationPeriod()).append(" milliseconds,\n");
+ if (this.hasExpirationPeriod()) {
+ os.append(" ExpirationPeriod: ").append(this.getExpirationPeriod()).append(" milliseconds,\n");
} else {
- ret.append("ExpirationPeriod: infinite,\n");
+ os.append(" ExpirationPeriod: infinite,\n");
}
- ret.append("FaceScope: ").append(getFaceScope()).append(",\n")
- .append("FacePersistency: ").append(getFacePersistency()).append(",\n")
- .append("LinkType: ").append(getLinkType()).append(",\n")
- .append("Counters: { Interests: {in: ").append(getNInInterests()).append(", ")
- .append("out: ").append(getNOutInterests()).append("},\n")
- .append(" Data: {in: ").append(getNInDatas()).append(", ")
- .append("out: ").append(getNOutDatas()).append("},\n")
- .append(" Nack: {in: ").append(getNInNacks()).append(", ")
- .append("out: ").append(getNOutNacks()).append("},\n")
- .append(" bytes: {in: ").append(getNInBytes()).append(", ")
- .append("out: ").append(getNOutBytes()).append("} }\n")
- .append(")");
- return ret.toString();
+ os.append(" FaceScope: ").append(this.getFaceScope().toString()).append(",\n")
+ .append(" FacePersistency: ").append(this.getFacePersistency().toString()).append(",\n")
+ .append(" LinkType: ").append(this.getLinkType().toString()).append(",\n");
+
+ if (this.hasBaseCongestionMarkingInterval()) {
+ os.append(" BaseCongestionMarkingInterval: ")
+ .append(this.getBaseCongestionMarkingInterval())
+ .append(" nanoseconds,\n");
+ }
+
+ if (this.hasDefaultCongestionThreshold()) {
+ os.append(" DefaultCongestionThreshold: ").append(this.getDefaultCongestionThreshold()).append(" bytes,\n");
+ }
+
+ if (this.hasMtu()) {
+ os.append(" Mtu: ").append(this.getMtu()).append(" bytes,\n");
+ }
+
+ os.append(" Flags: ").append(String.format("0x%x", this.getFlags())).append(",\n")
+ .append(" Counters: {Interests: {in: ").append(this.getNInInterests()).append(", ")
+ .append("out: ").append(this.getNOutInterests()).append("},\n")
+ .append(" Data: {in: ").append(this.getNInData()).append(", ")
+ .append("out: ").append(this.getNOutData()).append("},\n")
+ .append(" Nacks: {in: ").append(this.getNInNacks()).append(", ")
+ .append("out: ").append(this.getNOutNacks()).append("},\n")
+ .append(" bytes: {in: ").append(this.getNInBytes()).append(", ")
+ .append("out: ").append(this.getNOutBytes()).append("}}\n");
+
+ os.append(" )");
+ return os.toString();
}
}
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 f43cbf5..83796c1 100644
--- a/src/main/java/com/intel/jndn/management/types/FibEntry.java
+++ b/src/main/java/com/intel/jndn/management/types/FibEntry.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -30,7 +30,7 @@
* Represent a FibEntry returned from /localhost/nfd/fib/list.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset">FIB Dataset</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset">FIB Dataset</a>
*/
public class FibEntry implements Decodable {
private Name name = new Name();
diff --git a/src/main/java/com/intel/jndn/management/types/ForwarderStatus.java b/src/main/java/com/intel/jndn/management/types/ForwarderStatus.java
index d0854d7..6a3a94c 100644
--- a/src/main/java/com/intel/jndn/management/types/ForwarderStatus.java
+++ b/src/main/java/com/intel/jndn/management/types/ForwarderStatus.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -25,7 +25,7 @@
* Represent a ForwarderStatus object.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus">ForwarderStatus</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus">ForwarderStatus</a>
*/
public class ForwarderStatus implements Decodable {
private String nfdVersion = "";
@@ -37,10 +37,10 @@
private long nMeasurementEntries = 0;
private long nCsEntries = 0;
private long nInInterests = 0;
- private long nInDatas = 0;
+ private long nInData = 0;
private long nInNacks = 0;
private long nOutInterests = 0;
- private long nOutDatas = 0;
+ private long nOutData = 0;
private long nOutNacks = 0;
/////////////////////////////////////////////////////////////////////////////
@@ -80,10 +80,10 @@
*/
public final void wireEncode(final TlvEncoder encoder) {
encoder.writeNonNegativeIntegerTlv(NfdTlv.NOutNacks, nOutNacks);
- encoder.writeNonNegativeIntegerTlv(NfdTlv.NOutDatas, nOutDatas);
+ encoder.writeNonNegativeIntegerTlv(NfdTlv.NOutData, nOutData);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NOutInterests, nOutInterests);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NInNacks, nInNacks);
- encoder.writeNonNegativeIntegerTlv(NfdTlv.NInDatas, nInDatas);
+ encoder.writeNonNegativeIntegerTlv(NfdTlv.NInData, nInData);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NInInterests, nInInterests);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NCsEntries, nCsEntries);
encoder.writeNonNegativeIntegerTlv(NfdTlv.NMeasurementsEntries, nMeasurementEntries);
@@ -121,10 +121,10 @@
this.nMeasurementEntries = decoder.readNonNegativeIntegerTlv(NfdTlv.NMeasurementsEntries);
this.nCsEntries = decoder.readNonNegativeIntegerTlv(NfdTlv.NCsEntries);
this.nInInterests = decoder.readNonNegativeIntegerTlv(NfdTlv.NInInterests);
- this.nInDatas = decoder.readNonNegativeIntegerTlv(NfdTlv.NInDatas);
+ this.nInData = decoder.readNonNegativeIntegerTlv(NfdTlv.NInData);
this.nInNacks = decoder.readNonNegativeIntegerTlv(NfdTlv.NInNacks);
this.nOutInterests = decoder.readNonNegativeIntegerTlv(NfdTlv.NOutInterests);
- this.nOutDatas = decoder.readNonNegativeIntegerTlv(NfdTlv.NOutDatas);
+ this.nOutData = decoder.readNonNegativeIntegerTlv(NfdTlv.NOutData);
this.nOutNacks = decoder.readNonNegativeIntegerTlv(NfdTlv.NOutNacks);
}
@@ -293,18 +293,18 @@
/**
* @return Number of incoming Data since NFD start
*/
- public long getNInDatas() {
- return nInDatas;
+ public long getNInData() {
+ return nInData;
}
/**
* Set the number of incoming Data since NFD start.
*
- * @param nInDatas the number of incoming Interests since NFD start
+ * @param nInData the number of incoming Interests since NFD start
* @return this
*/
- public ForwarderStatus setNInDatas(final long nInDatas) {
- this.nInDatas = nInDatas;
+ public ForwarderStatus setNInData(final long nInData) {
+ this.nInData = nInData;
return this;
}
@@ -329,18 +329,18 @@
/**
* @return Number of outgoing Data since NFD start
*/
- public long getNOutDatas() {
- return nOutDatas;
+ public long getNOutData() {
+ return nOutData;
}
/**
* Set the number of outgoing Data since NFD start.
*
- * @param nOutDatas the number of outgoing Data since NFD start
+ * @param nOutData the number of outgoing Data since NFD start
* @return this
*/
- public ForwarderStatus setNOutDatas(final long nOutDatas) {
- this.nOutDatas = nOutDatas;
+ public ForwarderStatus setNOutData(final long nOutData) {
+ this.nOutData = nOutData;
return this;
}
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 8c75edc..a52ad89 100644
--- a/src/main/java/com/intel/jndn/management/types/NextHopRecord.java
+++ b/src/main/java/com/intel/jndn/management/types/NextHopRecord.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -26,7 +26,7 @@
* Represent a NextHopRecord in a FibEntry.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset">FIB Dataset</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/FibMgmt#FIB-Dataset">FIB Dataset</a>
*/
public class NextHopRecord implements Decodable {
private int faceId;
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 2608198..548333a 100644
--- a/src/main/java/com/intel/jndn/management/types/RibEntry.java
+++ b/src/main/java/com/intel/jndn/management/types/RibEntry.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -30,7 +30,7 @@
* Represent a entry in the RIB.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset">RIB Dataset</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset">RIB Dataset</a>
*/
public class RibEntry implements Decodable {
private Name name = new Name();
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 b134a6f..b2c9efc 100644
--- a/src/main/java/com/intel/jndn/management/types/Route.java
+++ b/src/main/java/com/intel/jndn/management/types/Route.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -26,7 +26,7 @@
* Represent a Route object from /localhost/nfd/rib/list.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset">RIB Dataset</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/RibMgmt#RIB-Dataset">RIB Dataset</a>
*/
public class Route implements Decodable {
public static final int INFINITE_EXPIRATION_PERIOD = -1;
diff --git a/src/main/java/com/intel/jndn/management/types/StrategyChoice.java b/src/main/java/com/intel/jndn/management/types/StrategyChoice.java
index 7c1f8a4..fbf0c33 100644
--- a/src/main/java/com/intel/jndn/management/types/StrategyChoice.java
+++ b/src/main/java/com/intel/jndn/management/types/StrategyChoice.java
@@ -1,6 +1,6 @@
/*
* jndn-management
- * Copyright (c) 2015, Intel Corporation.
+ * Copyright (c) 2015-2018, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -27,7 +27,7 @@
* Represent a strategy choice entry.
*
* @author Andrew Brown <andrew.brown@intel.com>
- * @see <a href="http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice">StrategyChoice</a>
+ * @see <a href="https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice">StrategyChoice</a>
*/
public class StrategyChoice implements Decodable {
private Name name;
diff --git a/src/main/java/com/intel/jndn/management/types/package-info.java b/src/main/java/com/intel/jndn/management/types/package-info.java
index 5a4c84b..68c2331 100644
--- a/src/main/java/com/intel/jndn/management/types/package-info.java
+++ b/src/main/java/com/intel/jndn/management/types/package-info.java
@@ -1,3 +1,17 @@
+/*
+ * jndn-management
+ * Copyright (c) 2015-2018, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
+ * more details.
+ */
+
/**
* NFD management types.
* @see <a href="http://redmine.named-data.net/projects/nfd/wiki/Management">NFD Management</a>
diff --git a/src/test/java/com/intel/jndn/management/NfdcIT.java b/src/test/java/com/intel/jndn/management/NfdcIT.java
index 350c79a..f1deef1 100644
--- a/src/test/java/com/intel/jndn/management/NfdcIT.java
+++ b/src/test/java/com/intel/jndn/management/NfdcIT.java
@@ -13,7 +13,6 @@
*/
package com.intel.jndn.management;
-import com.intel.jndn.management.enums.LocalControlHeader;
import com.intel.jndn.management.enums.Strategies;
import com.intel.jndn.management.types.RibEntry;
import com.intel.jndn.management.types.StrategyChoice;
@@ -62,7 +61,7 @@
@Before
public void setUp() throws SecurityException {
face = new Face("localhost");
- mockFace = new MockFace();
+ mockFace = new MockFace(new MockFace.Options().setEnablePacketLogging(false).setEnableRegistrationReply(false));
noKeyChainFace = new Face("localhost"); // don't set command signing info
KeyChain keyChain = MockKeyChain.configure(new Name("/tmp/identity"));
face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
@@ -226,7 +225,7 @@
@Test
public void testFailOfSetStrategyWithoutKeychain() throws Exception {
- exception.expect(IllegalArgumentException.class);
+ exception.expect(NullPointerException.class);
Nfdc.setStrategy(noKeyChainFace, new Name("/test"), Strategies.BEST_ROUTE);
}
@@ -256,19 +255,6 @@
Nfdc.setStrategy(mockFace, new Name("/"), Strategies.BROADCAST);
}
- /**
- * LocalControlHeader works only with NFD < 0.3.4, broken otherwise.
- */
- @Test(expected = ManagementException.class)
- public void testLocalControlHeader() throws Exception {
- Nfdc.enableLocalControlHeader(face, LocalControlHeader.INCOMING_FACE_ID);
- Thread.sleep(1000); // strategy takes a while to register
-
- // TODO: add asserts
-
- Nfdc.disableLocalControlHeader(face, LocalControlHeader.INCOMING_FACE_ID);
- }
-
@Test
public void testGetChannelStatus() throws Exception {
assertFalse(Nfdc.getChannelStatusList(face).isEmpty());
diff --git a/src/test/java/com/intel/jndn/management/types/FaceStatusTest.java b/src/test/java/com/intel/jndn/management/types/FaceStatusTest.java
index a960e15..0b09dee 100644
--- a/src/test/java/com/intel/jndn/management/types/FaceStatusTest.java
+++ b/src/test/java/com/intel/jndn/management/types/FaceStatusTest.java
@@ -24,6 +24,7 @@
import java.nio.ByteBuffer;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Test encode/decode of FaceStatus.
@@ -36,40 +37,98 @@
@Before
public void setUp() throws Exception {
testFaceStatusWire = TestHelper.bufferFromIntArray(new int[] {
- 0x80, 0x5e, 0x69, 0x01, 0x64, 0x72, 0x15, 0x74, 0x63, 0x70,
+ 0x80, 0x6a, 0x69, 0x01, 0x64, 0x72, 0x15, 0x74, 0x63, 0x70,
0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32, 0x2e, 0x30, 0x2e,
0x32, 0x2e, 0x31, 0x3a, 0x36, 0x33, 0x36, 0x33, 0x81, 0x16,
0x74, 0x63, 0x70, 0x34, 0x3a, 0x2f, 0x2f, 0x31, 0x39, 0x32,
0x2e, 0x30, 0x2e, 0x32, 0x2e, 0x32, 0x3a, 0x35, 0x35, 0x35,
0x35, 0x35, 0x6d, 0x02, 0x27, 0x10, 0x84, 0x01, 0x01, 0x85,
- 0x01, 0x01, 0x86, 0x01, 0x01, 0x90, 0x01, 0x0a, 0x91, 0x01,
- 0xc8, 0x97, 0x01, 0x01, 0x92, 0x02, 0x0b, 0xb8, 0x93, 0x01,
- 0x04, 0x98, 0x01, 0x02, 0x94, 0x04, 0x4f, 0x41, 0xe7, 0x7b,
- 0x95, 0x04, 0x3b, 0x8d, 0x37, 0x30,
+ 0x01, 0x01, 0x86, 0x01, 0x01, 0x87, 0x01, 0x05, 0x88, 0x01,
+ 0x07, 0x89, 0x01, 0x09, 0x90, 0x01, 0x0a, 0x91, 0x01, 0xc8,
+ 0x97, 0x01, 0x01, 0x92, 0x02, 0x0b, 0xb8, 0x93, 0x01, 0x04,
+ 0x98, 0x01, 0x02, 0x94, 0x04, 0x4f, 0x41, 0xe7, 0x7b, 0x95,
+ 0x04, 0x3b, 0x8d, 0x37, 0x30, 0x6c, 0x01, 0x07,
});
}
@Test
- public void testEncode() throws Exception {
+ public void testSettersGetters() throws Exception {
FaceStatus status = new FaceStatus();
- status.setFaceId(100)
+ status
+ .setFaceId(100)
.setRemoteUri("tcp4://192.0.2.1:6363")
.setLocalUri("tcp4://192.0.2.2:55555")
.setFaceScope(FaceScope.LOCAL)
.setFacePersistency(FacePersistency.ON_DEMAND)
.setLinkType(LinkType.MULTI_ACCESS)
.setExpirationPeriod(10000)
+ .setBaseCongestionMarkingInterval(5)
+ .setDefaultCongestionThreshold(7)
+ .setMtu(9)
.setNInInterests(10)
- .setNInDatas(200)
+ .setNInData(200)
.setNInNacks(1)
.setNOutInterests(3000)
- .setNOutDatas(4)
+ .setNOutData(4)
.setNOutNacks(2)
.setNInBytes(1329719163)
- .setNOutBytes(999110448);
+ .setNOutBytes(999110448)
+ .setFlags(0x7);
+
+ assertEquals(100, status.getFaceId());
+ assertEquals("tcp4://192.0.2.1:6363", status.getRemoteUri());
+ assertEquals("tcp4://192.0.2.2:55555", status.getLocalUri());
+ assertEquals(FaceScope.LOCAL, status.getFaceScope());
+ assertEquals(FacePersistency.ON_DEMAND, status.getFacePersistency());
+ assertEquals(LinkType.MULTI_ACCESS, status.getLinkType());
+ assertEquals(10000, status.getExpirationPeriod());
+ assertEquals(10, status.getNInInterests());
+ assertEquals(200, status.getNInData());
+ assertEquals(1, status.getNInNacks());
+ assertEquals(3000, status.getNOutInterests());
+ assertEquals(4, status.getNOutData());
+ assertEquals(2, status.getNOutNacks());
+ assertEquals(1329719163, status.getNInBytes());
+ assertEquals(999110448, status.getNOutBytes());
+
+ assertEquals(9, status.getMtu());
+ assertEquals(0x7, status.getFlags());
+ assertEquals(5, status.getBaseCongestionMarkingInterval());
+ assertEquals(7, status.getDefaultCongestionThreshold());
+ assertTrue(status.hasMtu());
+ assertTrue(status.hasBaseCongestionMarkingInterval());
+ assertTrue(status.hasDefaultCongestionThreshold());
+ }
+
+ @Test
+ public void testEncode() throws Exception {
+ FaceStatus status = new FaceStatus();
+ status
+ .setFaceId(100)
+ .setRemoteUri("tcp4://192.0.2.1:6363")
+ .setLocalUri("tcp4://192.0.2.2:55555")
+ .setFaceScope(FaceScope.LOCAL)
+ .setFacePersistency(FacePersistency.ON_DEMAND)
+ .setLinkType(LinkType.MULTI_ACCESS)
+ .setExpirationPeriod(10000)
+ .setBaseCongestionMarkingInterval(5)
+ .setDefaultCongestionThreshold(7)
+ .setMtu(9)
+ .setNInInterests(10)
+ .setNInData(200)
+ .setNInNacks(1)
+ .setNOutInterests(3000)
+ .setNOutData(4)
+ .setNOutNacks(2)
+ .setNInBytes(1329719163)
+ .setNOutBytes(999110448)
+ .setFlags(0x7);
// encode
Blob encoded = status.wireEncode();
+// for (final byte b : encoded.getImmutableArray()) {
+// System.err.format("0x%02x, ", b);
+// }
assertEquals(testFaceStatusWire, encoded.buf());
}
@@ -85,46 +144,64 @@
assertEquals(LinkType.MULTI_ACCESS, status.getLinkType());
assertEquals(10000, status.getExpirationPeriod());
assertEquals(10, status.getNInInterests());
- assertEquals(200, status.getNInDatas());
+ assertEquals(200, status.getNInData());
assertEquals(1, status.getNInNacks());
assertEquals(3000, status.getNOutInterests());
- assertEquals(4, status.getNOutDatas());
+ assertEquals(4, status.getNOutData());
assertEquals(2, status.getNOutNacks());
assertEquals(1329719163, status.getNInBytes());
assertEquals(999110448, status.getNOutBytes());
+
+ assertEquals(9, status.getMtu());
+ assertEquals(0x7, status.getFlags());
+ assertEquals(5, status.getBaseCongestionMarkingInterval());
+ assertEquals(7, status.getDefaultCongestionThreshold());
+ assertTrue(status.hasMtu());
+ assertTrue(status.hasBaseCongestionMarkingInterval());
+ assertTrue(status.hasDefaultCongestionThreshold());
}
@Test
public void testToString() throws Exception {
FaceStatus status = new FaceStatus(testFaceStatusWire);
- assertEquals("FaceStatus(FaceID: 100,\n" +
- "RemoteUri: tcp4://192.0.2.1:6363,\n" +
- "LocalUri: tcp4://192.0.2.2:55555,\n" +
- "ExpirationPeriod: 10000 milliseconds,\n" +
- "FaceScope: LOCAL,\n" +
- "FacePersistency: ON_DEMAND,\n" +
- "LinkType: MULTI_ACCESS,\n" +
- "Counters: { Interests: {in: 10, out: 3000},\n" +
- " Data: {in: 200, out: 4},\n" +
- " Nack: {in: 1, out: 2},\n" +
- " bytes: {in: 1329719163, out: 999110448} }\n" +
- ")",
+ assertEquals(
+ "Face(FaceId: 100,\n" +
+ " RemoteUri: tcp4://192.0.2.1:6363,\n" +
+ " LocalUri: tcp4://192.0.2.2:55555,\n" +
+ " ExpirationPeriod: 10000 milliseconds,\n" +
+ " FaceScope: local,\n" +
+ " FacePersistency: on-demand,\n" +
+ " LinkType: multi-access,\n" +
+ " BaseCongestionMarkingInterval: 5 nanoseconds,\n" +
+ " DefaultCongestionThreshold: 7 bytes,\n" +
+ " Mtu: 9 bytes,\n" +
+ " Flags: 0x7,\n" +
+ " Counters: {Interests: {in: 10, out: 3000},\n" +
+ " Data: {in: 200, out: 4},\n" +
+ " Nacks: {in: 1, out: 2},\n" +
+ " bytes: {in: 1329719163, out: 999110448}}\n" +
+ " )",
status.toString());
status.setExpirationPeriod(0);
- assertEquals("FaceStatus(FaceID: 100,\n" +
- "RemoteUri: tcp4://192.0.2.1:6363,\n" +
- "LocalUri: tcp4://192.0.2.2:55555,\n" +
- "ExpirationPeriod: infinite,\n" +
- "FaceScope: LOCAL,\n" +
- "FacePersistency: ON_DEMAND,\n" +
- "LinkType: MULTI_ACCESS,\n" +
- "Counters: { Interests: {in: 10, out: 3000},\n" +
- " Data: {in: 200, out: 4},\n" +
- " Nack: {in: 1, out: 2},\n" +
- " bytes: {in: 1329719163, out: 999110448} }\n" +
- ")",
+ assertEquals(
+ "Face(FaceId: 100,\n" +
+ " RemoteUri: tcp4://192.0.2.1:6363,\n" +
+ " LocalUri: tcp4://192.0.2.2:55555,\n" +
+ " ExpirationPeriod: infinite,\n" +
+ " FaceScope: local,\n" +
+ " FacePersistency: on-demand,\n" +
+ " LinkType: multi-access,\n" +
+ " BaseCongestionMarkingInterval: 5 nanoseconds,\n" +
+ " DefaultCongestionThreshold: 7 bytes,\n" +
+ " Mtu: 9 bytes,\n" +
+ " Flags: 0x7,\n" +
+ " Counters: {Interests: {in: 10, out: 3000},\n" +
+ " Data: {in: 200, out: 4},\n" +
+ " Nacks: {in: 1, out: 2},\n" +
+ " bytes: {in: 1329719163, out: 999110448}}\n" +
+ " )",
status.toString());
}
}
diff --git a/src/test/java/com/intel/jndn/management/types/ForwarderStatusTest.java b/src/test/java/com/intel/jndn/management/types/ForwarderStatusTest.java
index fc2484d..cc2eafe 100644
--- a/src/test/java/com/intel/jndn/management/types/ForwarderStatusTest.java
+++ b/src/test/java/com/intel/jndn/management/types/ForwarderStatusTest.java
@@ -56,10 +56,10 @@
status.setNMeasurementsEntries(1771725298);
status.setNCsEntries(1264968688);
status.setNInInterests(612811615);
- status.setNInDatas(1843576050);
+ status.setNInData(1843576050);
status.setNInNacks(1234);
status.setNOutInterests(952144445);
- status.setNOutDatas(138198826);
+ status.setNOutData(138198826);
status.setNOutNacks(4321);
ByteBuffer wire = status.wireEncode().buf();
@@ -79,10 +79,10 @@
assertEquals(1771725298, status.getNMeasurementsEntries());
assertEquals(1264968688, status.getNCsEntries());
assertEquals(612811615, status.getNInInterests());
- assertEquals(1843576050, status.getNInDatas());
+ assertEquals(1843576050, status.getNInData());
assertEquals(1234, status.getNInNacks());
assertEquals(952144445, status.getNOutInterests());
- assertEquals(138198826, status.getNOutDatas());
+ assertEquals(138198826, status.getNOutData());
assertEquals(4321, status.getNOutNacks());
}
}