PUD: add gatewayDeterminationInterval configuration parameter
authorFerry Huberts <ferry.huberts@pelagic.nl>
Tue, 13 Mar 2012 14:17:25 +0000 (15:17 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 14 Mar 2012 13:28:43 +0000 (14:28 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/doc/olsrd.conf.default.pud
lib/pud/src/configuration.c
lib/pud/src/configuration.h
lib/pud/src/pudOlsrdPlugin.h

index ec299f7..be0d872 100644 (file)
@@ -637,6 +637,14 @@ LoadPlugin "./lib/pud/olsrd_pud.so.1.1.0"
     #
     #PlParam     "uplinkUpdateIntervalMoving"      "15"
 
+    # gatewayDeterminationInterval is the interval (in seconds) on which
+    #                              determination of the best gateway is
+    #                              performed
+    #
+    # Default: 1
+    #
+    #PlParam     "gatewayDeterminationInterval"    "1"
+
     # movingSpeedThreshold is the speed from which we consider the node is
     #                      moving
     #
index 5b8c201..30c183d 100644 (file)
@@ -1557,6 +1557,56 @@ int setUplinkUpdateIntervalMoving(const char *value, void *data __attribute__ ((
 }
 
 /*
+ * gatewayDeterminationInterval
+ */
+
+/** The gateway determination interval plugin parameter (in seconds) */
+static unsigned long long gatewayDeterminationInterval = PUD_GATEWAY_DETERMINATION_INTERVAL_DEFAULT;
+
+/**
+ @return
+ The gateway determination interval plugin parameter (in seconds)
+ */
+unsigned long long getGatewayDeterminationInterval(void) {
+       return gatewayDeterminationInterval;
+}
+
+/**
+ Set gateway determination interval plugin parameter
+
+ @param value
+ The gateway determination interval plugin parameter (in seconds)
+ @param data
+ Unused
+ @param addon
+ Unused
+
+ @return
+ - true when an error is detected
+ - false otherwise
+ */
+int setGatewayDeterminationInterval(const char *value, void *data __attribute__ ((unused)),
+               set_plugin_parameter_addon addon __attribute__ ((unused))) {
+       static const char * valueName = PUD_GATEWAY_DETERMINATION_INTERVAL_NAME;
+       unsigned long long gatewayDeterminationIntervalNew;
+
+       assert (value != NULL);
+
+       if (!readULL(valueName, value, &gatewayDeterminationIntervalNew)) {
+               return true;
+       }
+
+       if (gatewayDeterminationIntervalNew < 1) {
+               pudError(false, "Configured %s must be at least 1", valueName);
+               return true;
+       }
+
+       gatewayDeterminationInterval = gatewayDeterminationIntervalNew;
+
+       return false;
+}
+
+/*
  * movingSpeedThreshold
  */
 
index 05b248a..9524add 100644 (file)
@@ -226,6 +226,16 @@ unsigned long long getUplinkUpdateIntervalMoving(void);
 int setUplinkUpdateIntervalMoving(const char *value, void *data,
                set_plugin_parameter_addon addon);
 
+/** The name of the gateway determination interval plugin parameter */
+#define PUD_GATEWAY_DETERMINATION_INTERVAL_NAME                        "gatewayDeterminationInterval"
+
+/** The default value of the gateway determination interval plugin parameter */
+#define PUD_GATEWAY_DETERMINATION_INTERVAL_DEFAULT             1
+
+unsigned long long getGatewayDeterminationInterval(void);
+int setGatewayDeterminationInterval(const char *value, void *data,
+               set_plugin_parameter_addon addon);
+
 /** The name of the moving speed threshold plugin parameter */
 #define PUD_MOVING_SPEED_THRESHOLD_NAME                        "movingSpeedThreshold"
 
index 16a7581..e6a262a 100644 (file)
@@ -50,6 +50,7 @@ static const struct olsrd_plugin_parameters plugin_parameters[] = {
 
        /* MOVEMENT DETECTION */
        {       .name = PUD_AVERAGE_DEPTH_NAME, .set_plugin_parameter = &setAverageDepth, .data = NULL},
+       {       .name = PUD_GATEWAY_DETERMINATION_INTERVAL_NAME, .set_plugin_parameter = &setGatewayDeterminationInterval, .data = NULL},
        {       .name = PUD_MOVING_SPEED_THRESHOLD_NAME, .set_plugin_parameter = &setMovingSpeedThreshold, .data = NULL},
        {       .name = PUD_MOVING_DISTANCE_THRESHOLD_NAME, .set_plugin_parameter = &setMovingDistanceThreshold, .data = NULL},
        {       .name = PUD_DOP_MULTIPLIER_NAME, .set_plugin_parameter = &setDopMultiplier, .data = NULL},