Handle returned ControlResponse messages for list commands
diff --git a/pom.xml b/pom.xml
index beafb33..df72e2e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.intel.jndn.management</groupId>
<artifactId>jndn-management</artifactId>
- <version>0.9.2</version>
+ <version>0.9.3</version>
<name>jndn-management</name>
<description>Tools for managing an NDN forwarding daemon</description>
<url>https://github.com/01org/jndn-management</url>
diff --git a/src/main/java/com/intel/jndn/management/NFD.java b/src/main/java/com/intel/jndn/management/NFD.java
index a1bf168..58d5d70 100644
--- a/src/main/java/com/intel/jndn/management/NFD.java
+++ b/src/main/java/com/intel/jndn/management/NFD.java
@@ -99,6 +99,13 @@
throw new Exception("Failed to retrieve list of faces from the forwarder.");
}
+ // check for failed request
+ if (data.getContent().buf().get(0) == ControlResponse.TLV_CONTROL_RESPONSE) {
+ ControlResponse response = new ControlResponse();
+ response.wireDecode(data.getContent().buf());
+ throw new Exception("Failed to retrieve list of faces, forwarder returned: " + response.getStatusCode() + " " + response.getStatusText());
+ }
+
// parse packet
return StatusDataset.wireDecode(data.getContent(), FaceStatus.class);
}
@@ -126,7 +133,14 @@
// send packet
Data data = SegmentedClient.getDefault().getSync(forwarder, interest);
if (data == null) {
- throw new Exception("Failed to retrieve list of fib entries from the forwarder.");
+ throw new Exception("Failed to retrieve list of FIB entries from the forwarder.");
+ }
+
+ // check for failed request
+ if (data.getContent().buf().get(0) == ControlResponse.TLV_CONTROL_RESPONSE) {
+ ControlResponse response = new ControlResponse();
+ response.wireDecode(data.getContent().buf());
+ throw new Exception("Failed to retrieve list of FIB entries, forwarder returned: " + response.getStatusCode() + " " + response.getStatusText());
}
// parse packet
@@ -152,7 +166,14 @@
// send packet
Data data = SegmentedClient.getDefault().getSync(forwarder, interest);
if (data == null) {
- throw new Exception("Failed to retrieve list of faces from the forwarder.");
+ throw new Exception("Failed to retrieve list of routes from the forwarder.");
+ }
+
+ // check for failed request
+ if (data.getContent().buf().get(0) == ControlResponse.TLV_CONTROL_RESPONSE) {
+ ControlResponse response = new ControlResponse();
+ response.wireDecode(data.getContent().buf());
+ throw new Exception("Failed to retrieve list of routes, forwarder returned: " + response.getStatusCode() + " " + response.getStatusText());
}
// parse packet
@@ -359,14 +380,14 @@
*/
public static boolean unregister(Face forwarder, Name route, String uri) throws Exception {
int faceId = -1;
- for(FaceStatus face : getFaceList(forwarder)){
- if(face.getUri().matches(uri)){
+ for (FaceStatus face : getFaceList(forwarder)) {
+ if (face.getUri().matches(uri)) {
faceId = face.getFaceId();
break;
}
}
-
- if(faceId == -1){
+
+ if (faceId == -1) {
throw new Exception("Face not found: " + uri);
}