jsoninfo: always output the configuration checksum
authorFerry Huberts <ferry.huberts@pelagic.nl>
Sun, 25 Dec 2016 12:44:00 +0000 (13:44 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 4 Jan 2017 08:47:11 +0000 (09:47 +0100)
So that the client knows when it has changed and thus when to
re-fetch the configuration related (startup) objects.

Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
43 files changed:
lib/info.java/org.olsr.v1.info.api/bnd.bnd
lib/info.java/org.olsr.v1.info.api/doc/examples/2hop.json
lib/info.java/org.olsr.v1.info.api/doc/examples/all.json
lib/info.java/org.olsr.v1.info.api/doc/examples/base.json
lib/info.java/org.olsr.v1.info.api/doc/examples/config.json
lib/info.java/org.olsr.v1.info.api/doc/examples/gateways.json
lib/info.java/org.olsr.v1.info.api/doc/examples/hna.json
lib/info.java/org.olsr.v1.info.api/doc/examples/interfaces.json
lib/info.java/org.olsr.v1.info.api/doc/examples/links.json
lib/info.java/org.olsr.v1.info.api/doc/examples/mid.json
lib/info.java/org.olsr.v1.info.api/doc/examples/neighbors.json
lib/info.java/org.olsr.v1.info.api/doc/examples/neighbours.json
lib/info.java/org.olsr.v1.info.api/doc/examples/plugins.json
lib/info.java/org.olsr.v1.info.api/doc/examples/routes.json
lib/info.java/org.olsr.v1.info.api/doc/examples/runtime.json
lib/info.java/org.olsr.v1.info.api/doc/examples/sgw.json
lib/info.java/org.olsr.v1.info.api/doc/examples/startup.json
lib/info.java/org.olsr.v1.info.api/doc/examples/topology.json
lib/info.java/org.olsr.v1.info.api/doc/examples/version.json
lib/info.java/org.olsr.v1.info.api/src/org/olsr/v1/info/api/dto/JsonInfoBase.java
lib/info.java/org.olsr.v1.info.api/src/org/olsr/v1/info/api/dto/JsonInfoConfigEntry.java
lib/info.java/org.olsr.v1.info.api/src/org/olsr/v1/info/api/dto/package-info.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoAll.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoBase.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoConfig.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoConfigEntry.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoGateways.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoHna.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoInterfaces.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoLinks.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoMid.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoNeighbors.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoNeighbours.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoPlugins.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoPudPosition.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoRoutes.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoRuntime.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoSgw.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoStartup.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoTopology.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoTwoHop.java
lib/info.java/org.olsr.v1.info.api/test/org/olsr/v1/info/api/dto/TestJsonInfoVersion.java
lib/jsoninfo/src/olsrd_jsoninfo.c

index 2fca4d1..8452e74 100644 (file)
@@ -6,7 +6,7 @@
        com.fasterxml.jackson.core.jackson-databind,\
        ${junit}
 Bundle-Name:OLSRd v1 Info - API
-Bundle-Version:1.0.1.${tstamp}
+Bundle-Version:1.1.0.${tstamp}
 Export-Package: \
        org.olsr.v1.info.api.commands,\
        org.olsr.v1.info.api.contants,\
index 85432c4..d6f7827 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289420,
   "timeSinceStartup": 2063398,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "2hop": [
     {
index b561e17..dee90ec 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289142,
   "timeSinceStartup": 1785701,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "neighbors": [
     {
     }
   ],
   "config": {
+    "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
     "configurationFile": "/etc/olsrd/olsrd.conf",
     "olsrPort": 698,
     "debugLevel": 0,
index 1cd3448..94b3473 100644 (file)
@@ -3,5 +3,6 @@
   "systemTime": 1448289504,
   "timeSinceStartup": 2147638,
   "error": "something",
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d"
 }
\ No newline at end of file
index a7b6aba..e3c469b 100644 (file)
@@ -2,8 +2,10 @@
   "pid": 12345,
   "systemTime": 1458316795,
   "timeSinceStartup": 9159412,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "config": {
+    "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
     "configurationFile": "/etc/olsrd/olsrd.conf",
     "olsrPort": 698,
     "debugLevel": 0,
index a083df4..bc7fe00 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448287845,
   "timeSinceStartup": 488652,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "gateways": {
     "ipv4": [
index 7da2321..dc51762 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289299,
   "timeSinceStartup": 1942439,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "hna": [
     {
index 9773ad6..f524546 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289382,
   "timeSinceStartup": 2025389,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "interfaces": [
     {
index 3ea17a9..d9f778a 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289153,
   "timeSinceStartup": 1796611,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "links": [
     {
index 06a2610..e8b5b47 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289320,
   "timeSinceStartup": 1963286,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "mid": [
     {
index 3925620..24abc97 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289142,
   "timeSinceStartup": 1785701,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "neighbors": [
     {
index 27212a5..7ab9c10 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289142,
   "timeSinceStartup": 1785701,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "neighbors": [
     {
index e00d8f1..8f534e4 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289559,
   "timeSinceStartup": 2202279,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "plugins": [
     {
index 846f8a5..c43e6e5 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289272,
   "timeSinceStartup": 1915187,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "routes": [
     {
index 565ff66..d9210f8 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289142,
   "timeSinceStartup": 1785701,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "neighbors": [
     {
index 9556ee7..e5cb307 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448287383,
   "timeSinceStartup": 26205,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "sgw": {
     "egress": [
index b052809..ffaff8a 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289142,
   "timeSinceStartup": 1785701,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "version": {
     "version": "olsr.org - pre-0.9.1-git_4e58755-hash_f013046cc98a88d68312f1e1566e865e",
@@ -77,6 +78,7 @@
     }
   ],
   "config": {
+    "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
     "configurationFile": "/etc/olsrd/olsrd.conf",
     "olsrPort": 698,
     "debugLevel": 0,
index 4de3422..1d99b43 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289337,
   "timeSinceStartup": 1980699,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "topology": [
     {
index 501c7ea..3edba6f 100644 (file)
@@ -2,6 +2,7 @@
   "pid": 12345,
   "systemTime": 1448289504,
   "timeSinceStartup": 2147638,
+  "configurationChecksum": "2e2c14b6e3562ddfd73111847d7a9d8277993ff7",
   "uuid": "d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d",
   "version": {
     "version": "olsr.org - pre-0.9.1-git_4e58755-hash_f013046cc98a88d68312f1e1566e865e",
index 7952ce8..ef1fdfa 100644 (file)
@@ -10,11 +10,12 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  */
 @ProviderType
 public class JsonInfoBase {
-  private long   pid              = 0;
-  private long   systemTime       = 0;
-  private long   timeSinceStartup = 0;
-  private String uuid             = ""; /* optional */
-  private String error            = ""; /* optional */
+  private long   pid                   = 0;
+  private long   systemTime            = 0;
+  private long   timeSinceStartup      = 0;
+  private String configurationChecksum = "";
+  private String uuid                  = ""; /* optional */
+  private String error                 = ""; /* optional */
 
   /**
    * @return the PID
@@ -61,6 +62,25 @@ public class JsonInfoBase {
     this.timeSinceStartup = timeSinceStartup;
   }
 
+  /**
+   * @return the configuration checksum
+   */
+  public String getConfigurationChecksum() {
+    return this.configurationChecksum;
+  }
+
+  /**
+   * @param configurationChecksum the configuration checksum to set
+   */
+  @JsonProperty("configurationChecksum")
+  public void setConfigurationChecksum(final String configurationChecksum) {
+    if (configurationChecksum == null) {
+      this.configurationChecksum = "";
+    } else {
+      this.configurationChecksum = configurationChecksum;
+    }
+  }
+
   /**
    * @return the UUID
    */
@@ -106,6 +126,7 @@ public class JsonInfoBase {
     result = (prime * result) + (int) (this.pid ^ (this.pid >>> 32));
     result = (prime * result) + (int) (this.systemTime ^ (this.systemTime >>> 32));
     result = (prime * result) + (int) (this.timeSinceStartup ^ (this.timeSinceStartup >>> 32));
+    result = (prime * result) + this.configurationChecksum.hashCode();
     result = (prime * result) + this.uuid.hashCode();
     result = (prime * result) + this.error.hashCode();
     return result;
@@ -146,6 +167,11 @@ public class JsonInfoBase {
       return result;
     }
 
+    result = this.configurationChecksum.compareTo(other.configurationChecksum);
+    if (result != 0) {
+      return CompareUtils.clip(result);
+    }
+
     result = this.uuid.compareTo(other.uuid);
     if (result != 0) {
       return CompareUtils.clip(result);
@@ -168,6 +194,8 @@ public class JsonInfoBase {
     builder.append(this.systemTime);
     builder.append(", timeSinceStartup=");
     builder.append(this.timeSinceStartup);
+    builder.append(", configurationChecksum=");
+    builder.append(this.configurationChecksum);
     builder.append(", uuid=");
     builder.append(this.uuid);
     builder.append(", error=");
index 77e5693..8209c5c 100644 (file)
@@ -14,6 +14,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  */
 @ProviderType
 public class JsonInfoConfigEntry {
+  private String                          configurationChecksum    = "";
   private String                          configurationFile        = "";
   private int                             olsrPort                 = 0;
   private int                             debugLevel               = 0;
@@ -66,6 +67,25 @@ public class JsonInfoConfigEntry {
   private String                          os                       = "";
   private long                            startTime                = 0;
 
+  /**
+   * @return the configuration checksum
+   */
+  public String getConfigurationChecksum() {
+    return this.configurationChecksum;
+  }
+
+  /**
+   * @param configurationChecksum the configuration checksum to set
+   */
+  @JsonProperty("configurationChecksum")
+  public void setConfigurationChecksum(final String configurationChecksum) {
+    if (configurationChecksum == null) {
+      this.configurationChecksum = "";
+    } else {
+      this.configurationChecksum = configurationChecksum;
+    }
+  }
+
   /**
    * @return the configuration file
    */
@@ -893,6 +913,7 @@ public class JsonInfoConfigEntry {
   public int hashCode() {
     final int prime = 31;
     int result = 1;
+    result = (prime * result) + this.configurationChecksum.hashCode();
     result = (prime * result) + this.configurationFile.hashCode();
     result = (prime * result) + this.olsrPort;
     result = (prime * result) + this.debugLevel;
@@ -967,6 +988,9 @@ public class JsonInfoConfigEntry {
 
     final JsonInfoConfigEntry other = (JsonInfoConfigEntry) obj;
 
+    if (!this.configurationChecksum.equals(other.configurationChecksum)) {
+      return false;
+    }
     if (!this.configurationFile.equals(other.configurationFile)) {
       return false;
     }
@@ -1126,7 +1150,9 @@ public class JsonInfoConfigEntry {
   @Override
   public String toString() {
     final StringBuilder builder = new StringBuilder();
-    builder.append("JsonInfoConfigEntry [configurationFile=");
+    builder.append("JsonInfoConfigEntry [configurationChecksum=");
+    builder.append(this.configurationChecksum);
+    builder.append(", configurationFile=");
     builder.append(this.configurationFile);
     builder.append(", olsrPort=");
     builder.append(this.olsrPort);
index eff0a52..7877cb3 100644 (file)
@@ -455,7 +455,7 @@ public class TestJsonInfoAll {
   public void testHashCode() {
     this.impl.setNeighbors(null);
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1615713752)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(604725356)));
 
     /* set */
     final Set<JsonInfoNeighborsEntry> neighbors = new TreeSet<>();
@@ -527,7 +527,7 @@ public class TestJsonInfoAll {
     this.impl.setConfig(config);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1318733558)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(901705550)));
   }
 
   @Test(timeout = 8000)
index 3567281..d6b7ad5 100644 (file)
@@ -31,6 +31,7 @@ public class TestJsonInfoBase {
     assertThat(Long.valueOf(this.impl.getPid()), equalTo(Long.valueOf(0)));
     assertThat(Long.valueOf(this.impl.getSystemTime()), equalTo(Long.valueOf(0)));
     assertThat(Long.valueOf(this.impl.getTimeSinceStartup()), equalTo(Long.valueOf(0)));
+    assertThat(this.impl.getConfigurationChecksum(), equalTo(""));
     assertThat(this.impl.getUuid(), equalTo(""));
     assertThat(this.impl.getError(), equalTo(""));
 
@@ -38,6 +39,7 @@ public class TestJsonInfoBase {
     this.impl.setPid(333);
     this.impl.setSystemTime(123);
     this.impl.setTimeSinceStartup(321);
+    this.impl.setConfigurationChecksum("2e2c14b6e3562ddfd73111847d7a9d8277993ff7");
     this.impl.setUuid("d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d");
     this.impl.setError("something");
 
@@ -45,6 +47,7 @@ public class TestJsonInfoBase {
     assertThat(Long.valueOf(this.impl.getPid()), equalTo(Long.valueOf(333)));
     assertThat(Long.valueOf(this.impl.getSystemTime()), equalTo(Long.valueOf(123)));
     assertThat(Long.valueOf(this.impl.getTimeSinceStartup()), equalTo(Long.valueOf(321)));
+    assertThat(this.impl.getConfigurationChecksum(), equalTo("2e2c14b6e3562ddfd73111847d7a9d8277993ff7"));
     assertThat(this.impl.getUuid(), equalTo("d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d"));
     assertThat(this.impl.getError(), equalTo("something"));
   }
@@ -69,6 +72,12 @@ public class TestJsonInfoBase {
     r = this.impl.equals(other);
     assertThat(Boolean.valueOf(r), equalTo(Boolean.TRUE));
 
+    other = new JsonInfoBase();
+    other.setConfigurationChecksum("configChecksum");
+    r = this.impl.equals(other);
+    assertThat(Boolean.valueOf(r), equalTo(Boolean.FALSE));
+
+    other = new JsonInfoBase();
     other.setUuid("uuid");
     r = this.impl.equals(other);
     assertThat(Boolean.valueOf(r), equalTo(Boolean.FALSE));
@@ -78,6 +87,8 @@ public class TestJsonInfoBase {
   public void testComapreTo() {
     int r;
     final JsonInfoBase other = new JsonInfoBase();
+    final String checksum1 = "checksum 1";
+    final String checksum2 = "checksum 2";
     final String gateway1 = "127.0.0.31";
     final String gateway2 = "127.0.0.32";
 
@@ -152,9 +163,36 @@ public class TestJsonInfoBase {
     this.impl.setTimeSinceStartup(longOrg);
     other.setTimeSinceStartup(longOrg);
 
+    /* configChecksum */
+
+    String stringOrg = this.impl.getConfigurationChecksum();
+
+    this.impl.setConfigurationChecksum(null);
+    other.setConfigurationChecksum(checksum2);
+    r = this.impl.compareTo(other);
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1)));
+
+    this.impl.setConfigurationChecksum(checksum2);
+    other.setConfigurationChecksum(null);
+    r = this.impl.compareTo(other);
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1)));
+
+    this.impl.setConfigurationChecksum(checksum1);
+    other.setConfigurationChecksum(checksum2);
+    r = this.impl.compareTo(other);
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1)));
+
+    this.impl.setConfigurationChecksum(checksum1);
+    other.setConfigurationChecksum(checksum1);
+    r = this.impl.compareTo(other);
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(0)));
+
+    this.impl.setConfigurationChecksum(stringOrg);
+    other.setConfigurationChecksum(stringOrg);
+
     /* uuid */
 
-    String stringOrg = this.impl.getUuid();
+    stringOrg = this.impl.getUuid();
 
     this.impl.setUuid(null);
     other.setUuid(gateway2);
@@ -212,19 +250,24 @@ public class TestJsonInfoBase {
     this.impl.setPid(333);
     this.impl.setSystemTime(123);
     this.impl.setTimeSinceStartup(321);
+    this.impl.setConfigurationChecksum("2e2c14b6e3562ddfd73111847d7a9d8277993ff7");
     this.impl.setUuid("d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d");
     this.impl.setError("something");
 
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1753641731)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1558552252)));
+
+    this.impl.setConfigurationChecksum(null);
+    r = this.impl.hashCode();
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-139543783)));
 
     this.impl.setUuid(null);
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-224750964)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1389346984)));
 
     this.impl.setError(null);
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(340134418)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1954232366)));
   }
 
   @Test(timeout = 8000)
@@ -232,6 +275,7 @@ public class TestJsonInfoBase {
     this.impl.setPid(333);
     this.impl.setSystemTime(123);
     this.impl.setTimeSinceStartup(321);
+    this.impl.setConfigurationChecksum("2e2c14b6e3562ddfd73111847d7a9d8277993ff7");
     this.impl.setUuid("d13d7ee3-fcca-4f81-9bf5-bb5848b5d96d");
     this.impl.setError("something");
 
index d0659cd..f9382f1 100644 (file)
@@ -80,7 +80,7 @@ public class TestJsonInfoConfig {
   @Test(timeout = 8000)
   public void testHashCode() {
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(635024693)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1204371979)));
 
     /* set */
     final JsonInfoConfigEntry config = new JsonInfoConfigEntry();
@@ -88,7 +88,7 @@ public class TestJsonInfoConfig {
     this.impl.setConfig(config);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1347641415)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-491755257)));
   }
 
   @Test(timeout = 8000)
index b251295..806e36d 100644 (file)
@@ -29,6 +29,7 @@ public class TestJsonInfoConfigEntry {
   @Test(timeout = 8000)
   public void testGettersAndSetters() throws UnknownHostException {
     /* initial */
+    assertThat(this.impl.getConfigurationChecksum(), equalTo(""));
     assertThat(this.impl.getConfigurationFile(), equalTo(""));
     assertThat(Integer.valueOf(this.impl.getOlsrPort()), equalTo(Integer.valueOf(0)));
     assertThat(Integer.valueOf(this.impl.getDebugLevel()), equalTo(Integer.valueOf(0)));
@@ -117,6 +118,7 @@ public class TestJsonInfoConfigEntry {
     final JsonInfoInterfaceConfiguration interfaceDefaults = new JsonInfoInterfaceConfiguration();
     interfaceDefaults.setMode("mode");
 
+    this.impl.setConfigurationChecksum("configurationChecksum");
     this.impl.setConfigurationFile("configurationFile");
     this.impl.setOlsrPort(1);
     this.impl.setDebugLevel(2);
@@ -170,6 +172,7 @@ public class TestJsonInfoConfigEntry {
     this.impl.setStartTime(21);
 
     /* get */
+    assertThat(this.impl.getConfigurationChecksum(), equalTo("configurationChecksum"));
     assertThat(this.impl.getConfigurationFile(), equalTo("configurationFile"));
     assertThat(Integer.valueOf(this.impl.getOlsrPort()), equalTo(Integer.valueOf(1)));
     assertThat(Integer.valueOf(this.impl.getDebugLevel()), equalTo(Integer.valueOf(2)));
@@ -253,9 +256,36 @@ public class TestJsonInfoConfigEntry {
     r = this.impl.equals(other);
     assertThat(Boolean.valueOf(r), equalTo(Boolean.TRUE));
 
+    /* configurationChecksum */
+
+    String stringOrg = this.impl.getConfigurationChecksum();
+
+    this.impl.setConfigurationChecksum(null);
+    other.setConfigurationChecksum(null);
+    r = this.impl.equals(other);
+    assertThat(Boolean.valueOf(r), equalTo(Boolean.TRUE));
+
+    this.impl.setConfigurationChecksum(null);
+    other.setConfigurationChecksum("string");
+    r = this.impl.equals(other);
+    assertThat(Boolean.valueOf(r), equalTo(Boolean.FALSE));
+
+    this.impl.setConfigurationChecksum("string");
+    other.setConfigurationChecksum(null);
+    r = this.impl.equals(other);
+    assertThat(Boolean.valueOf(r), equalTo(Boolean.FALSE));
+
+    this.impl.setConfigurationChecksum("string");
+    other.setConfigurationChecksum("string");
+    r = this.impl.equals(other);
+    assertThat(Boolean.valueOf(r), equalTo(Boolean.TRUE));
+
+    this.impl.setConfigurationChecksum(stringOrg);
+    other.setConfigurationChecksum(stringOrg);
+
     /* configurationFile */
 
-    String stringOrg = this.impl.getConfigurationFile();
+    stringOrg = this.impl.getConfigurationFile();
 
     this.impl.setConfigurationFile(null);
     other.setConfigurationFile(null);
@@ -1536,7 +1566,7 @@ public class TestJsonInfoConfigEntry {
   @Test(timeout = 8000)
   public void testHashCode() throws UnknownHostException {
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-252478988)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1347784982)));
 
     /* set */
     final JsonInfoConfigRtTable rtTable = new JsonInfoConfigRtTable();
@@ -1572,6 +1602,7 @@ public class TestJsonInfoConfigEntry {
     final JsonInfoInterfaceConfiguration interfaceDefaults = new JsonInfoInterfaceConfiguration();
     interfaceDefaults.setMode("mode");
 
+    this.impl.setConfigurationChecksum("configurationChecksum");
     this.impl.setConfigurationFile("configurationFile");
     this.impl.setOlsrPort(1);
     this.impl.setDebugLevel(2);
@@ -1625,7 +1656,7 @@ public class TestJsonInfoConfigEntry {
     this.impl.setStartTime(21);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1268268935)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1049017438)));
   }
 
   @Test(timeout = 8000)
index 5349264..7d92051 100644 (file)
@@ -89,7 +89,7 @@ public class TestJsonInfoGateways {
   @Test(timeout = 8000)
   public void testHashCode() {
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887504642)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742811296)));
 
     /* set */
     final JsonInfoGatewaysFields gateways = new JsonInfoGatewaysFields();
@@ -101,7 +101,7 @@ public class TestJsonInfoGateways {
     this.impl.setGateways(gateways);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(345062030)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1200368684)));
   }
 
   @Test(timeout = 8000)
index f81d09e..3e10c89 100644 (file)
@@ -100,7 +100,7 @@ public class TestJsonInfoHna {
   @Test(timeout = 8000)
   public void testHashCode() {
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887503681)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742810335)));
 
     final JsonInfoHnaEntry entry = new JsonInfoHnaEntry();
     entry.setDestinationPrefixLength(1);
@@ -110,7 +110,7 @@ public class TestJsonInfoHna {
     this.impl.setHna(hnas);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(888427233)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1743733887)));
   }
 
   @Test(timeout = 8000)
index 92419e8..3a59bdd 100644 (file)
@@ -100,7 +100,7 @@ public class TestJsonInfoInterfaces {
   public void testHashCode() {
     this.impl.setInterfaces(null);
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887503682)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742810336)));
 
     final List<JsonInfoInterfacesEntry> mid = new LinkedList<>();
     final JsonInfoInterfacesEntry entry = new JsonInfoInterfacesEntry();
@@ -109,7 +109,7 @@ public class TestJsonInfoInterfaces {
     this.impl.setInterfaces(mid);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-474986892)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(380319762)));
   }
 
   @Test(timeout = 8000)
index 5f7d88a..8cb4c72 100644 (file)
@@ -96,7 +96,7 @@ public class TestJsonInfoLinks {
   @Test(timeout = 8000)
   public void testHashCode() {
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887503681)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742810335)));
 
     final JsonInfoLinksEntry entry = new JsonInfoLinksEntry();
     entry.setCurrentLinkStatus("currentLinkStatus");
@@ -106,7 +106,7 @@ public class TestJsonInfoLinks {
     this.impl.setLinks(links);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(58530267)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(913836921)));
   }
 
   @Test(timeout = 8000)
index e906672..fd64d7e 100644 (file)
@@ -101,7 +101,7 @@ public class TestJsonInfoMid {
   public void testHashCode() {
     this.impl.setMid(null);
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887503682)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742810336)));
 
     final List<JsonInfoMidEntry> mid = new LinkedList<>();
     final JsonInfoMidEntry entry = new JsonInfoMidEntry();
@@ -111,7 +111,7 @@ public class TestJsonInfoMid {
     this.impl.setMid(mid);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887534464)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742841118)));
   }
 
   @Test(timeout = 8000)
index b641880..3094880 100644 (file)
@@ -109,7 +109,7 @@ public class TestJsonInfoNeighbors {
   public void testHashCode() {
     this.impl.setNeighbors(null);
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887503681)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742810335)));
 
     final Set<JsonInfoNeighborsEntry> neighbors = new TreeSet<>();
     final JsonInfoNeighborsEntry entry = new JsonInfoNeighborsEntry();
@@ -118,7 +118,7 @@ public class TestJsonInfoNeighbors {
     this.impl.setNeighbors(neighbors);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-231273513)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(624033141)));
   }
 
   @Test(timeout = 8000)
index 9a942b6..02c980c 100644 (file)
@@ -109,7 +109,7 @@ public class TestJsonInfoNeighbours {
   public void testHashCode() {
     this.impl.setNeighbors(null);
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742810335)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1807454463)));
 
     /* set */
     final Set<JsonInfoNeighborsEntry> neighbors = new TreeSet<>();
@@ -123,7 +123,7 @@ public class TestJsonInfoNeighbours {
     this.impl.setLinks(links);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1257381955)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-512679457)));
   }
 
   @Test(timeout = 8000)
index cb099e8..41c5b47 100644 (file)
@@ -97,7 +97,7 @@ public class TestJsonInfoPlugins {
   public void testHashCode() {
     this.impl.setPlugins(null);
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887503682)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742810336)));
 
     /* set */
     final List<JsonInfoPluginsEntry> plugins = new LinkedList<>();
@@ -107,7 +107,7 @@ public class TestJsonInfoPlugins {
     this.impl.setPlugins(plugins);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(411874894)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1267181548)));
   }
 
   @Test(timeout = 8000)
index eb5ae86..b4f3917 100644 (file)
@@ -80,7 +80,7 @@ public class TestJsonInfoPudPosition {
   @Test(timeout = 8000)
   public void testHashCode() {
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(949971943)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1805278597)));
 
     /* set */
     final JsonInfoPudPositionEntry entry = new JsonInfoPudPositionEntry();
@@ -88,7 +88,7 @@ public class TestJsonInfoPudPosition {
     this.impl.setPudPosition(entry);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1201400004)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(2056706658)));
   }
 
   @Test(timeout = 8000)
index 3d3810a..2fb0510 100644 (file)
@@ -103,7 +103,7 @@ public class TestJsonInfoRoutes {
   public void testHashCode() {
     this.impl.setRoutes(null);
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887503681)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742810335)));
 
     final Set<JsonInfoRoutesEntry> routes = new TreeSet<>();
     final JsonInfoRoutesEntry entry = new JsonInfoRoutesEntry();
@@ -112,7 +112,7 @@ public class TestJsonInfoRoutes {
     this.impl.setRoutes(routes);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1905047285)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1534613357)));
   }
 
   @Test(timeout = 8000)
index 8337b1b..26c9762 100644 (file)
@@ -372,7 +372,7 @@ public class TestJsonInfoRuntime {
   public void testHashCode() {
     this.impl.setNeighbors(null);
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1103227702)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(841357544)));
 
     /* set */
     final Set<JsonInfoNeighborsEntry> neighbors = new TreeSet<>();
@@ -437,7 +437,7 @@ public class TestJsonInfoRuntime {
     this.impl.setPudPosition(pudPosition);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1497262817)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-853119233)));
   }
 
   @Test(timeout = 8000)
index 44c1a0b..48678a5 100644 (file)
@@ -90,7 +90,7 @@ public class TestJsonInfoSgw {
   @Test(timeout = 8000)
   public void testHashCode() {
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887533472)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742840126)));
 
     /* set */
     final JsonInfoSgwEntry entry = new JsonInfoSgwEntry();
@@ -102,11 +102,11 @@ public class TestJsonInfoSgw {
     this.impl.setSgw(sgw);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-825816172)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(29490482)));
 
     this.impl.setSgw(null);
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887533472)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742840126)));
   }
 
   @Test(timeout = 8000)
index cc16d8a..0f35caf 100644 (file)
@@ -156,7 +156,7 @@ public class TestJsonInfoStartup {
   @Test(timeout = 8000)
   public void testHashCode() {
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(2038520371)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(954758003)));
 
     /* set */
     final JsonInfoVersionEntry version = new JsonInfoVersionEntry();
@@ -174,14 +174,14 @@ public class TestJsonInfoStartup {
     this.impl.setConfig(config);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1991057907)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(907295539)));
 
     /* set */
     this.impl.setVersion(null);
     this.impl.setPlugins(null);
     this.impl.setConfig(null);
 
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1991057907)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(907295539)));
   }
 
   @Test(timeout = 8000)
index b8db3da..d812772 100644 (file)
@@ -103,7 +103,7 @@ public class TestJsonInfoTopology {
   public void testHashCode() {
     this.impl.setTopology(null);
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887503681)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742810335)));
 
     final Set<JsonInfoTopologyEntry> routes = new TreeSet<>();
     final JsonInfoTopologyEntry entry = new JsonInfoTopologyEntry();
@@ -112,7 +112,7 @@ public class TestJsonInfoTopology {
     this.impl.setTopology(routes);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(69259661)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(924566315)));
   }
 
   @Test(timeout = 8000)
index 4cc77f1..d9c3f1e 100644 (file)
@@ -100,7 +100,7 @@ public class TestJsonInfoTwoHop {
   public void testHashCode() {
     this.impl.setTwoHop(null);
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(887503682)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1742810336)));
 
     final List<JsonInfoTwoHopEntry> neighbors = new LinkedList<>();
     final JsonInfoTwoHopEntry entry = new JsonInfoTwoHopEntry();
@@ -109,7 +109,7 @@ public class TestJsonInfoTwoHop {
     this.impl.setTwoHop(neighbors);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(565149067)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1420455721)));
   }
 
   @Test(timeout = 8000)
index 93c15a6..c4c5ebd 100644 (file)
@@ -101,7 +101,7 @@ public class TestJsonInfoVersion {
   @Test(timeout = 8000)
   public void testHashCode() {
     int r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1664653280)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-809346626)));
 
     /* set */
     final JsonInfoVersionEntry version = new JsonInfoVersionEntry();
@@ -109,7 +109,7 @@ public class TestJsonInfoVersion {
     this.impl.setVersion(version);
 
     r = this.impl.hashCode();
-    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1777321222)));
+    assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-922014568)));
   }
 
   @Test(timeout = 8000)
index c1859f6..bccde62 100644 (file)
@@ -49,6 +49,7 @@
 #include <ctype.h>
 #include <libgen.h>
 
+#include "cfgparser/olsrd_conf_checksum.h"
 #include "ipcalc.h"
 #include "builddata.h"
 #include "neighbor_table.h"
@@ -214,6 +215,8 @@ const char * determine_mime_type(unsigned int send_what) {
 }
 
 void output_start(struct autobuf *abuf) {
+  char *str;
+
   /* global variables for tracking when to put a comma in for JSON */
   abuf_json_reset_entry_number_and_depth(&json_session, pretty);
   abuf_json_mark_output(&json_session, true, abuf);
@@ -221,6 +224,10 @@ void output_start(struct autobuf *abuf) {
   abuf_json_int(&json_session, abuf, "pid", getpid());
   abuf_json_int(&json_session, abuf, "systemTime", time(NULL));
   abuf_json_int(&json_session, abuf, "timeSinceStartup", now_times);
+
+  (void) olsrd_config_checksum_get(NULL, &str);
+  abuf_json_string(&json_session, abuf, "configurationChecksum", str);
+
   if (*uuid) {
     abuf_json_string(&json_session, abuf, "uuid", uuid);
   }
@@ -1119,8 +1126,13 @@ void ipc_print_twohop(struct autobuf *abuf) {
 }
 
 void ipc_print_config(struct autobuf *abuf) {
+  char *str;
+
   abuf_json_mark_object(&json_session, true, false, abuf, "config");
 
+  (void) olsrd_config_checksum_get(NULL, &str);
+  abuf_json_string(&json_session, abuf, "configurationChecksum", str);
+
   abuf_json_string(&json_session, abuf, "configurationFile", olsr_cnf->configuration_file);
   abuf_json_int(&json_session, abuf, "olsrPort", olsr_cnf->olsrport);
   abuf_json_int(&json_session, abuf, "debugLevel", olsr_cnf->debug_level);