/* Plugin includes */
#include "pud.h"
-#include "netTools.h"
#include "networkInterfaces.h"
+#include "netTools.h"
+#include "posFile.h"
+#include "configTools.h"
/* OLSR includes */
-#include "olsr_types.h"
-#include "olsr_cfg.h"
+#include <olsr_protocol.h>
/* System includes */
-#include <OlsrdPudWireFormat/nodeIdConversion.h>
-#include <assert.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <string.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
#include <unistd.h>
#include <nmea/util.h>
+#include <OlsrdPudWireFormat/nodeIdConversion.h>
+#include <limits.h>
/*
- * Utility functions
- */
-
-/**
- Determine the address of the port in an OLSR socket address
-
- @param ipVersion
- The IP version (AF_INET or AF_INET6)
- @param addr
- A pointer to OLSR socket address
- @param port
- A pointer to the location where the pointer to the port will be stored
- */
-static void getOlsrSockaddrPortAddress(int ipVersion,
- union olsr_sockaddr * addr, in_port_t ** port) {
- if (ipVersion == AF_INET) {
- *port = &addr->in4.sin_port;
- } else {
- *port = &addr->in6.sin6_port;
- }
-}
-
-/**
- Get pointers to the IP address and port in an OLSR socket address
- @param ipVersion
- The IP version (AF_INET or AF_INET6)
- @param addr
- A pointer to OLSR socket address
- @param ipAddress
- A pointer to the location where the pointer to the IP address will be stored
- @param port
- A pointer to the location where the pointer to the port will be stored
- */
-static void getOlsrSockAddrAndPortAddresses(int ipVersion,
- union olsr_sockaddr * addr, void ** ipAddress, in_port_t ** port) {
- if (ipVersion == AF_INET) {
- *ipAddress = (void *) &addr->in4.sin_addr;
- *port = (void *) &addr->in4.sin_port;
- } else {
- *ipAddress = (void *) &addr->in6.sin6_addr;
- *port = (void *) &addr->in6.sin6_port;
- }
-}
-
-/**
- Read an unsigned long long number from a value string
-
- @param valueName
- the name of the value
- @param value
- the string to convert to a number
- @param valueNumber
- a pointer to the location where to store the number upon successful conversion
-
- @return
- - true on success
- - false otherwise
- */
-static bool readULL(const char * valueName, const char * value,
- unsigned long long * valueNumber) {
- char * endPtr = NULL;
- unsigned long long valueNew;
-
- errno = 0;
- valueNew = strtoull(value, &endPtr, 10);
-
- if (!((endPtr != value) && (*value != '\0') && (*endPtr == '\0'))) {
- /* invalid conversion */
- pudError(true, "Configured %s (%s) could not be converted to a number",
- valueName, value);
- return false;
- }
-
- *valueNumber = valueNew;
-
- return true;
-}
-
-/**
- Read a double number from a value string
-
- @param valueName
- the name of the value
- @param value
- the string to convert to a number
- @param valueNumber
- a pointer to the location where to store the number upon successful conversion
-
- @return
- - true on success
- - false otherwise
+ * Note:
+ * Setters must return true when an error is detected, false otherwise
*/
-static bool readDouble(const char * valueName, const char * value,
- double * valueNumber) {
- char * endPtr = NULL;
- double valueNew;
-
- errno = 0;
- valueNew = strtod(value, &endPtr);
-
- if (!((endPtr != value) && (*value != '\0') && (*endPtr == '\0'))) {
- /* invalid conversion */
- pudError(true, "Configured %s (%s) could not be converted to a number",
- valueName, value);
- return false;
- }
-
- *valueNumber = valueNew;
-
- return true;
-}
/*
* nodeIdType
return nodeIdType;
}
-/**
- Set the node ID type.
-
- @param value
- The value of the node ID type to set (a number in string representation)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setNodeIdType(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_NODE_ID_TYPE_NAME;
unsigned long long nodeIdTypeNew;
- assert (value != NULL);
-
if (!readULL(valueName, value, &nodeIdTypeNew)) {
return true;
}
if (!isValidNodeIdType(nodeIdTypeNew)) {
- pudError(false, "Configured %s (%llu) is reserved", valueName,
+ pudError(false, "Value of parameter %s (%llu) is reserved", valueName,
nodeIdTypeNew);
return true;
}
return &nodeIdBinary;
}
-/**
- Set the node ID.
-
- @param value
- The value of the node ID to set (in string representation)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setNodeId(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_NODE_ID_NAME;
size_t valueLength;
assert (value != NULL);
valueLength = strlen(value);
if (valueLength > PUD_TX_NODEID_BUFFERSIZE) {
- pudError(false, "Configured %s is too long, maximum length is"
- " %u, current length is %lu", valueName, PUD_TX_NODEID_BUFFERSIZE,
+ pudError(false, "Value of parameter %s is too long, maximum length is"
+ " %u, current length is %lu", PUD_NODE_ID_NAME, PUD_TX_NODEID_BUFFERSIZE,
(unsigned long) valueLength);
return true;
}
- false on failure
*/
static bool intSetupNodeIdBinaryString(void) {
- bool invalidChars;
char report[256];
size_t nodeidlength;
char * nodeid = (char *)getNodeIdWithLength(&nodeidlength);
- invalidChars = nmea_string_has_invalid_chars(nodeid,
- PUD_NODE_ID_NAME, &report[0], sizeof(report));
- if (invalidChars) {
- pudError(false, &report[0]);
+ if (nmea_string_has_invalid_chars(nodeid, PUD_NODE_ID_NAME, &report[0], sizeof(report))) {
+ pudError(false, "%s", &report[0]);
return false;
}
if (nodeidlength > PUD_TX_NODEID_BUFFERSIZE) {
- pudError(false, "%s value \"%s\" is too long", PUD_NODE_ID_NAME, &nodeid[0]);
+ pudError(false, "Length of parameter %s (%s) is too great", PUD_NODE_ID_NAME, &nodeid[0]);
return false;
}
/**
Validate whether the configured nodeId is valid w.r.t. the configured
- nodeIdType
+ nodeIdType and setup the binary value
@return
- true when ok
return false;
}
-/**
- Add a receive non-OLSR interface
-
- @param value
- The name of the non-OLSR interface to add
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int addRxNonOlsrInterface(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- unsigned long valueLength;
+ size_t valueLength;
+
+ if (rxNonOlsrInterfaceCount >= PUD_RX_NON_OLSR_IF_MAX) {
+ pudError(false, "Can't configure more than %u receive interfaces",
+ PUD_RX_NON_OLSR_IF_MAX);
+ return true;
+ }
assert (value != NULL);
valueLength = strlen(value);
if (valueLength > IFNAMSIZ) {
- pudError(false, "Configured %s (%s) is too long,"
+ pudError(false, "Value of parameter %s (%s) is too long,"
" maximum length is %u, current length is %lu",
PUD_RX_NON_OLSR_IF_NAME, value, IFNAMSIZ, valueLength);
return true;
}
if (!isRxNonOlsrInterface(value)) {
- if (rxNonOlsrInterfaceCount >= PUD_RX_NON_OLSR_IF_MAX) {
- pudError(false, "Can't configure more than %u receive interfaces",
- PUD_RX_NON_OLSR_IF_MAX);
- return true;
- }
-
strcpy((char *) &rxNonOlsrInterfaceNames[rxNonOlsrInterfaceCount][0],
value);
rxNonOlsrInterfaceCount++;
#define PUD_RX_ALLOWED_SOURCE_IP_MAX 32
/** Array with RX allowed source IP addresses */
-static struct sockaddr rxAllowedSourceIpAddresses[PUD_RX_ALLOWED_SOURCE_IP_MAX];
+static union olsr_sockaddr rxAllowedSourceIpAddresses[PUD_RX_ALLOWED_SOURCE_IP_MAX];
/** The number of RX allowed source IP addresses in the array */
static unsigned int rxAllowedSourceIpAddressesCount = 0;
address
- false otherwise
*/
-bool isRxAllowedSourceIpAddress(struct sockaddr * sender) {
- void * addr;
- unsigned int addrSize;
+bool isRxAllowedSourceIpAddress(union olsr_sockaddr * sender) {
unsigned int i;
if (rxAllowedSourceIpAddressesCount == 0) {
return false;
}
- if (sender->sa_family == AF_INET) {
- addr = (void *) (&((struct sockaddr_in *) sender)->sin_addr);
- addrSize = sizeof(struct in_addr);
- } else {
- addr = (void *) (&((struct sockaddr_in6 *) sender)->sin6_addr);
- addrSize = sizeof(struct in6_addr);
- }
-
for (i = 0; i < rxAllowedSourceIpAddressesCount; i++) {
- if ((rxAllowedSourceIpAddresses[i].sa_family == sender->sa_family)
- && (memcmp(&rxAllowedSourceIpAddresses[i].sa_data, addr,
- addrSize) == 0)) {
- return true;
+ if (sender->in.sa_family != rxAllowedSourceIpAddresses[i].in.sa_family) {
+ continue;
+ }
+
+ if (sender->in.sa_family == AF_INET) {
+ if (memcmp(&rxAllowedSourceIpAddresses[i].in4.sin_addr, &sender->in4.sin_addr, sizeof(struct in_addr))
+ == 0) {
+ return true;
+ }
+ } else {
+ if (memcmp(&rxAllowedSourceIpAddresses[i].in6.sin6_addr, &sender->in6.sin6_addr, sizeof(struct in6_addr))
+ == 0) {
+ return true;
+ }
}
}
return false;
}
-/**
- Set the RX allowed source IP addresses.
-
- @param value
- The RX allowed source IP address (in string representation)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int addRxAllowedSourceIpAddress(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_RX_ALLOWED_SOURCE_IP_NAME;
- const char * valueInternal = value;
- int conversion;
- struct sockaddr addr;
-
- assert (value != NULL);
-
- memset(&addr, 0, sizeof(addr));
+ union olsr_sockaddr addr;
+ bool addrSet = false;
- addr.sa_family = olsr_cnf->ip_version;
- conversion = inet_pton(olsr_cnf->ip_version, valueInternal, &addr.sa_data);
- if (conversion != 1) {
- pudError((conversion == -1) ? true : false,
- "Configured %s (%s) is not an IP address", valueName,
- valueInternal);
+ if (rxAllowedSourceIpAddressesCount >= PUD_RX_ALLOWED_SOURCE_IP_MAX) {
+ pudError(false, "Can't configure more than %u allowed source IP"
+ " addresses", PUD_RX_ALLOWED_SOURCE_IP_MAX);
return true;
}
- if ((rxAllowedSourceIpAddressesCount == 0) || !isRxAllowedSourceIpAddress(&addr)) {
- if (rxAllowedSourceIpAddressesCount >= PUD_RX_ALLOWED_SOURCE_IP_MAX) {
- pudError(false, "Can't configure more than %u allowed source IP"
- " addresses", PUD_RX_ALLOWED_SOURCE_IP_MAX);
- return true;
- }
+ if (!readIPAddress(valueName, value, 0, &addr, &addrSet)) {
+ return true;
+ }
+ if (!isRxAllowedSourceIpAddress(&addr)) {
rxAllowedSourceIpAddresses[rxAllowedSourceIpAddressesCount] = addr;
rxAllowedSourceIpAddressesCount++;
}
}
/*
- * rxMcAddr
+ * rxMcAddr + rxMcPort
*/
/** The rx multicast address */
*/
union olsr_sockaddr * getRxMcAddr(void) {
if (!rxMcAddrSet) {
- setRxMcAddr(NULL, NULL, ((set_plugin_parameter_addon) {.pc = NULL}));
+ setRxMcAddr((olsr_cnf->ip_version == AF_INET) ? PUD_RX_MC_ADDR_4_DEFAULT : PUD_RX_MC_ADDR_6_DEFAULT,
+ NULL, ((set_plugin_parameter_addon) {.pc = NULL}));
}
return &rxMcAddr;
}
-/**
- Set the receive multicast address. Sets the address to its default value when
- the value is NULL. Also sets the port to its default value when the address
- was not yet set.
-
- @param value
- The receive multicast address (in string representation)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setRxMcAddr(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_RX_MC_ADDR_NAME;
- void * ipAddress;
- in_port_t * port;
- const char * valueInternal = value;
- int conversion;
- getOlsrSockAddrAndPortAddresses(olsr_cnf->ip_version, &rxMcAddr, &ipAddress,
- &port);
- if (olsr_cnf->ip_version == AF_INET) {
- rxMcAddr.in4.sin_family = olsr_cnf->ip_version;
- if (valueInternal == NULL) {
- valueInternal = PUD_RX_MC_ADDR_4_DEFAULT;
- }
- } else {
- rxMcAddr.in6.sin6_family = olsr_cnf->ip_version;
- if (valueInternal == NULL) {
- valueInternal = PUD_RX_MC_ADDR_6_DEFAULT;
- }
+ if (!readIPAddress(valueName, value, PUD_RX_MC_PORT_DEFAULT, &rxMcAddr, &rxMcAddrSet)) {
+ return true;
}
- if (!rxMcAddrSet) {
- *port = htons(PUD_RX_MC_PORT_DEFAULT);
+ if (!isMulticast(&rxMcAddr)) {
+ pudError(false, "Value of parameter %s (%s) is not a multicast address",
+ valueName, value);
+ return true;
}
- conversion = inet_pton(olsr_cnf->ip_version, valueInternal, ipAddress);
- if (conversion != 1) {
- pudError((conversion == -1) ? true : false,
- "Configured %s (%s) is not an IP address", valueName,
- valueInternal);
+ return false;
+}
+
+/**
+ @return
+ The receive multicast port (in network byte order)
+ */
+unsigned short getRxMcPort(void) {
+ return getOlsrSockaddrPort(getRxMcAddr(), PUD_RX_MC_PORT_DEFAULT);
+}
+
+int setRxMcPort(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
+ static const char * valueName = PUD_RX_MC_PORT_NAME;
+ unsigned short rxMcPortNew;
+
+ if (!readUS(valueName, value, &rxMcPortNew)) {
return true;
}
- if (!isMulticast(olsr_cnf->ip_version, &rxMcAddr)) {
- pudError(false, "Configured %s (%s) is not a multicast address",
- valueName, valueInternal);
+ if (rxMcPortNew < 1) {
+ pudError(false, "Value of parameter %s (%u) is outside of valid range 1-65535", valueName, rxMcPortNew);
return true;
}
- rxMcAddrSet = true;
+ setOlsrSockaddrPort(getRxMcAddr(), htons((in_port_t) rxMcPortNew));
+
return false;
}
/*
- * rxMcPort
+ * positionFile
*/
+/** The positionFile buffer */
+static char positionFile[PATH_MAX + 1];
+
+/** True when the positionFile is set */
+static bool positionFileSet = false;
+
/**
@return
- The receive multicast port (in network byte order)
+ The positionFile (NULL when not set)
*/
-unsigned short getRxMcPort(void) {
- in_port_t * port;
- getOlsrSockaddrPortAddress(olsr_cnf->ip_version, getRxMcAddr(), &port);
- return *port;
-}
-
-/**
- Set the receive multicast port
+char * getPositionFile(void) {
+ if (!positionFileSet) {
+ return NULL;
+ }
- @param value
- The receive multicast port (a number in string representation)
- @param data
- Unused
- @param addon
- Unused
+ return &positionFile[0];
+}
- @return
- - true when an error is detected
- - false otherwise
- */
-int setRxMcPort(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_RX_MC_PORT_NAME;
- unsigned long long rxMcPortNew;
- in_port_t * port;
- union olsr_sockaddr * addr = getRxMcAddr();
+int setPositionFile(const char *value, void *data __attribute__ ((unused)),
+ set_plugin_parameter_addon addon __attribute__ ((unused))) {
+ size_t valueLength;
- assert (value != NULL);
+ assert(value != NULL);
- if (!readULL(valueName, value, &rxMcPortNew)) {
+ if (!startPositionFile()) {
+ stopPositionFile();
return true;
}
- if ((rxMcPortNew < 1) || (rxMcPortNew > 65535)) {
- pudError(false, "Configured %s (%llu) is outside of"
- " valid range 1-65535", valueName, rxMcPortNew);
+ valueLength = strlen(value);
+ if (valueLength > PATH_MAX) {
+ pudError(false, "Value of parameter %s is too long, maximum length is"
+ " %u, current length is %lu", PUD_POSFILE_NAME, PATH_MAX, (unsigned long) valueLength);
return true;
}
- getOlsrSockaddrPortAddress(olsr_cnf->ip_version, addr, &port);
- *port = htons((uint16_t) rxMcPortNew);
+ strcpy((char *) &positionFile[0], value);
+ positionFileSet = true;
return false;
}
* txNonOlsrIf
*/
-/** The maximum number of rx non-olsr interfaces */
+/** The maximum number of tx non-olsr interfaces */
#define PUD_TX_NON_OLSR_IF_MAX 32
/** Array with tx non-olsr interface names */
assert (ifName != NULL);
for (i = 0; i < txNonOlsrInterfaceCount; i++) {
- if (strncmp((char *) &txNonOlsrInterfaceNames[i][0], ifName, IFNAMSIZ
- + 1) == 0) {
+ if (strncmp((char *) &txNonOlsrInterfaceNames[i][0], ifName, IFNAMSIZ + 1) == 0) {
return true;
}
}
return false;
}
-/**
- Add a transmit non-OLSR interface
-
- @param value
- The name of the non-OLSR interface to add
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int addTxNonOlsrInterface(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- unsigned long valueLength;
+ size_t valueLength;
assert (value != NULL);
+ if (txNonOlsrInterfaceCount >= PUD_TX_NON_OLSR_IF_MAX) {
+ pudError(false, "Can not configure more than %u transmit interfaces", PUD_TX_NON_OLSR_IF_MAX);
+ return true;
+ }
+
valueLength = strlen(value);
if (valueLength > IFNAMSIZ) {
- pudError(false, "Configured %s (%s) is too long,"
- " maximum length is %u, current length is %lu",
+ pudError(false, "Value of parameter %s (%s) is too long, maximum length is %u, current length is %lu",
PUD_TX_NON_OLSR_IF_NAME, value, IFNAMSIZ, valueLength);
return true;
}
if (!isTxNonOlsrInterface(value)) {
- if (txNonOlsrInterfaceCount >= PUD_TX_NON_OLSR_IF_MAX) {
- pudError(false, "Can not configure more than %u transmit"
- " interfaces", PUD_TX_NON_OLSR_IF_MAX);
- return true;
- }
-
- strcpy((char *) &txNonOlsrInterfaceNames[txNonOlsrInterfaceCount][0],
- value);
+ strcpy((char *) &txNonOlsrInterfaceNames[txNonOlsrInterfaceCount][0], value);
txNonOlsrInterfaceCount++;
}
}
/*
- * txMcAddr
+ * txMcAddr + txMcPort
*/
/** The tx multicast address */
*/
union olsr_sockaddr * getTxMcAddr(void) {
if (!txMcAddrSet) {
- setTxMcAddr(NULL, NULL, ((set_plugin_parameter_addon) {.pc = NULL}));
+ setTxMcAddr((olsr_cnf->ip_version == AF_INET) ? PUD_TX_MC_ADDR_4_DEFAULT : PUD_TX_MC_ADDR_6_DEFAULT,
+ NULL, ((set_plugin_parameter_addon) {.pc = NULL}));
}
return &txMcAddr;
}
-/**
- Set the transmit multicast address. Sets the address to its default value when
- the value is NULL. Also sets the port to its default value when the address
- was not yet set.
-
- @param value
- The transmit multicast address (in string representation)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setTxMcAddr(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_TX_MC_ADDR_NAME;
- void * ipAddress;
- in_port_t * port;
- const char * valueInternal = value;
- int conversion;
- getOlsrSockAddrAndPortAddresses(olsr_cnf->ip_version, &txMcAddr, &ipAddress,
- &port);
- if (olsr_cnf->ip_version == AF_INET) {
- txMcAddr.in4.sin_family = olsr_cnf->ip_version;
- if (valueInternal == NULL) {
- valueInternal = PUD_TX_MC_ADDR_4_DEFAULT;
- }
- } else {
- txMcAddr.in6.sin6_family = olsr_cnf->ip_version;
- if (valueInternal == NULL) {
- valueInternal = PUD_TX_MC_ADDR_6_DEFAULT;
- }
+ if (!readIPAddress(valueName, value, PUD_TX_MC_PORT_DEFAULT, &txMcAddr, &txMcAddrSet)) {
+ return true;
}
- if (!txMcAddrSet) {
- *port = htons(PUD_TX_MC_PORT_DEFAULT);
+ if (!isMulticast(&txMcAddr)) {
+ pudError(false, "Value of parameter %s (%s) is not a multicast address",
+ valueName, value);
+ return true;
}
- conversion = inet_pton(olsr_cnf->ip_version, valueInternal, ipAddress);
- if (conversion != 1) {
- pudError((conversion == -1) ? true : false,
- "Configured %s (%s) is not an IP address", valueName,
- valueInternal);
+ return false;
+}
+
+/**
+ @return
+ The transmit multicast port (in network byte order)
+ */
+unsigned short getTxMcPort(void) {
+ return getOlsrSockaddrPort(getTxMcAddr(), PUD_TX_MC_PORT_DEFAULT);
+}
+
+int setTxMcPort(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
+ static const char * valueName = PUD_TX_MC_PORT_NAME;
+ unsigned short txMcPortNew;
+
+ if (!readUS(valueName, value, &txMcPortNew)) {
return true;
}
- if (!isMulticast(olsr_cnf->ip_version, &txMcAddr)) {
- pudError(false, "Configured %s (%s) is not a multicast address",
- valueName, valueInternal);
+ if (txMcPortNew < 1) {
+ pudError(false, "Value of parameter %s (%u) is outside of valid range 1-65535", valueName, txMcPortNew);
return true;
}
- txMcAddrSet = true;
+ setOlsrSockaddrPort(getTxMcAddr(), htons((in_port_t) txMcPortNew));
+
return false;
}
/*
- * txMcPort
+ * txTtl
*/
+/** The tx TTL */
+static unsigned char txTtl = PUD_TX_TTL_DEFAULT;
+
/**
@return
- The transmit multicast port (in network byte order)
+ The transmit multicast IP packet time-to-live
*/
-unsigned short getTxMcPort(void) {
- in_port_t * port;
- getOlsrSockaddrPortAddress(olsr_cnf->ip_version, getTxMcAddr(), &port);
- return *port;
+unsigned char getTxTtl(void) {
+ return txTtl;
}
-/**
- Set the transmit multicast port
+int setTxTtl(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
+ static const char * valueName = PUD_TX_TTL_NAME;
+
+ if (!readUC(valueName, value, &txTtl)) {
+ return true;
+ }
+
+ if ((txTtl < 1) /* || (txTtl > MAX_TTL) */) {
+ pudError(false, "Value of parameter %s (%u) is outside of"
+ " valid range 1-%u", valueName, txTtl, MAX_TTL);
+ return true;
+ }
+
+ return false;
+}
+
+/*
+ * txNmeaMessagePrefix
+ */
- @param value
- The transmit multicast port (a number in string representation)
- @param data
- Unused
- @param addon
- Unused
+/** The exact length of the tx NMEA message prefix */
+#define PUD_TXNMEAMESSAGEPREFIXLENGTH 4
+
+/** The tx NMEA message prefix buffer */
+static unsigned char txNmeaMessagePrefix[PUD_TXNMEAMESSAGEPREFIXLENGTH + 1];
+
+/** True when the tx NMEA message prefix is set */
+static bool txNmeaMessagePrefixSet = false;
+/**
@return
- - true when an error is detected
- - false otherwise
+ The transmit multicast NMEA message prefix
*/
-int setTxMcPort(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_TX_MC_PORT_NAME;
- unsigned long long txMcPortNew;
- in_port_t * port;
- union olsr_sockaddr * addr = getTxMcAddr();
+unsigned char * getTxNmeaMessagePrefix(void) {
+ if (!txNmeaMessagePrefixSet) {
+ setTxNmeaMessagePrefix(PUD_TX_NMEAMESSAGEPREFIX_DEFAULT, NULL,
+ (set_plugin_parameter_addon) {.pc = NULL});
+ }
+ return &txNmeaMessagePrefix[0];
+}
+
+int setTxNmeaMessagePrefix(const char *value, void *data __attribute__ ((unused)),
+ set_plugin_parameter_addon addon __attribute__ ((unused))) {
+ static const char * valueName = PUD_TX_NMEAMESSAGEPREFIX_NAME;
+ size_t valueLength;
+ char report[256];
assert (value != NULL);
- if (!readULL(valueName, value, &txMcPortNew)) {
+ valueLength = strlen(value);
+ if (valueLength != PUD_TXNMEAMESSAGEPREFIXLENGTH) {
+ pudError(false, "Length of parameter %s (%s) must be exactly %u characters",
+ valueName, value, PUD_TXNMEAMESSAGEPREFIXLENGTH);
return true;
}
- if ((txMcPortNew < 1) || (txMcPortNew > 65535)) {
- pudError(false, "Configured %s (%llu) is outside of"
- " valid range 1-65535", valueName, txMcPortNew);
+ if (nmea_string_has_invalid_chars(value, valueName, &report[0], sizeof(report))) {
+ pudError(false, "%s", &report[0]);
return true;
}
- getOlsrSockaddrPortAddress(olsr_cnf->ip_version, addr, &port);
- *port = htons((uint16_t) txMcPortNew);
+ if ((strchr(value, ' ') != NULL) || (strchr(value, '\t') != NULL)) {
+ pudError(false, "Value of parameter %s (%s) can not contain whitespace",
+ valueName, value);
+ return true;
+ }
+ strcpy((char *) &txNmeaMessagePrefix[0], value);
+ txNmeaMessagePrefixSet = true;
return false;
}
/*
- * uplinkAddr
+ * uplinkAddr + uplinkPort
*/
/** The uplink address */
/** True when the uplink address is set */
static bool uplinkAddrSet = false;
-/** True when the uplink address is set */
-static bool uplinkPortSet = false;
-
/**
@return
- true when the uplink address is set
*/
union olsr_sockaddr * getUplinkAddr(void) {
if (!uplinkAddrSet) {
- setUplinkAddr(NULL, NULL, ((set_plugin_parameter_addon) {.pc = NULL}));
+ setUplinkAddr((olsr_cnf->ip_version == AF_INET) ? PUD_UPLINK_ADDR_4_DEFAULT : PUD_UPLINK_ADDR_6_DEFAULT,
+ NULL, ((set_plugin_parameter_addon) {.pc = NULL}));
}
return &uplinkAddr;
}
-/**
- Set the uplink address. Sets the address to its default value when
- the value is NULL. Also sets the port to its default value when the address
- was not yet set.
-
- @param value
- The uplink address (in string representation)
- @param data
- Unused
- @param addon
- Unused
+int setUplinkAddr(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
+ return !readIPAddress(PUD_UPLINK_ADDR_NAME, value, PUD_UPLINK_PORT_DEFAULT, &uplinkAddr, &uplinkAddrSet);
+}
+/**
@return
- - true when an error is detected
- - false otherwise
- */
-int setUplinkAddr(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_UPLINK_ADDR_NAME;
- void * ipAddress;
- in_port_t * port;
- const char * valueInternal = value;
- int conversion;
- bool defaultValue = false;
-
- getOlsrSockAddrAndPortAddresses(olsr_cnf->ip_version, &uplinkAddr,
- &ipAddress, &port);
- if (olsr_cnf->ip_version == AF_INET) {
- uplinkAddr.in4.sin_family = olsr_cnf->ip_version;
- if (valueInternal == NULL) {
- valueInternal = PUD_UPLINK_ADDR_4_DEFAULT;
- defaultValue = true;
- }
- } else {
- uplinkAddr.in6.sin6_family = olsr_cnf->ip_version;
- if (valueInternal == NULL) {
- valueInternal = PUD_UPLINK_ADDR_6_DEFAULT;
- defaultValue = true;
- }
- }
-
- if (!uplinkPortSet) {
- *port = htons(PUD_UPLINK_PORT_DEFAULT);
- uplinkPortSet = true;
- }
-
- conversion = inet_pton(olsr_cnf->ip_version, valueInternal, ipAddress);
- if (conversion != 1) {
- pudError((conversion == -1) ? true : false,
- "Configured %s (%s) is not an IP address", valueName,
- valueInternal);
- return true;
- }
-
- if (!defaultValue) {
- uplinkAddrSet = true;
- }
-
- return false;
-}
-
-/*
- * uplinkPort
- */
-
-/**
- @return
- The uplink port (in network byte order)
+ The uplink port (in network byte order)
*/
unsigned short getUplinkPort(void) {
- in_port_t * port;
- getOlsrSockaddrPortAddress(olsr_cnf->ip_version, getUplinkAddr(), &port);
- return *port;
+ return getOlsrSockaddrPort(getUplinkAddr(), PUD_UPLINK_PORT_DEFAULT);
}
-/**
- Set the uplink port
-
- @param value
- The uplink port (a number in string representation)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setUplinkPort(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_UPLINK_PORT_NAME;
- unsigned long long uplinkPortNew;
- in_port_t * port;
- union olsr_sockaddr * addr = getUplinkAddr();
-
- assert (value != NULL);
+ unsigned short uplinkPortNew;
- if (!readULL(valueName, value, &uplinkPortNew)) {
+ if (!readUS(valueName, value, &uplinkPortNew)) {
return true;
}
- if ((uplinkPortNew < 1) || (uplinkPortNew > 65535)) {
- pudError(false, "Configured %s (%llu) is outside of"
- " valid range 1-65535", valueName, uplinkPortNew);
+ if (uplinkPortNew < 1) {
+ pudError(false, "Value of parameter %s (%u) is outside of valid range 1-65535", valueName, uplinkPortNew);
return true;
}
- getOlsrSockaddrPortAddress(olsr_cnf->ip_version, addr, &port);
- *port = htons((uint16_t) uplinkPortNew);
- uplinkPortSet = true;
+ setOlsrSockaddrPort(getUplinkAddr(), htons((in_port_t) uplinkPortNew));
return false;
}
-
/*
* downlinkPort
*/
return downlinkPort;
}
-/**
- Set the downlink port
-
- @param value
- The downlink port (a number in string representation)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setDownlinkPort(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_DOWNLINK_PORT_NAME;
- unsigned long long downlinkPortNew;
-
- assert(value != NULL);
+ unsigned short downlinkPortNew;
- if (!readULL(valueName, value, &downlinkPortNew)) {
+ if (!readUS(valueName, value, &downlinkPortNew)) {
return true;
}
- if ((downlinkPortNew < 1) || (downlinkPortNew > 65535)) {
- pudError(false, "Configured %s (%llu) is outside of"
- " valid range 1-65535", valueName, downlinkPortNew);
+ if (downlinkPortNew < 1) {
+ pudError(false, "Value of parameter %s (%u) is outside of valid range 1-65535", valueName, downlinkPortNew);
return true;
}
return false;
}
-/*
- * txTtl
- */
-
-/** The tx TTL */
-static unsigned char txTtl = PUD_TX_TTL_DEFAULT;
-
-/**
- @return
- The transmit multicast IP packet time-to-live
- */
-unsigned char getTxTtl(void) {
- return txTtl;
-}
-
-/**
- Set the transmit multicast IP packet time-to-live
-
- @param value
- The transmit multicast IP packet time-to-live (a number in string representation)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
-int setTxTtl(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_TX_TTL_NAME;
- unsigned long long txTtlNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &txTtlNew)) {
- return true;
- }
-
- if ((txTtlNew < 1) || (txTtlNew > MAX_TTL)) {
- pudError(false, "Configured %s (%llu) is outside of"
- " valid range 1-%u", valueName, txTtlNew, MAX_TTL);
- return true;
- }
-
- txTtl = txTtlNew;
-
- return false;
-}
-
-/*
- * txNmeaMessagePrefix
- */
-
-/** The exact length of the tx NMEA message prefix */
-#define PUD_TXNMEAMESSAGEPREFIXLENGTH 4
-
-/** The tx NMEA message prefix buffer */
-static unsigned char txNmeaMessagePrefix[PUD_TXNMEAMESSAGEPREFIXLENGTH + 1];
-
-/** True when the tx NMEA message prefix is set */
-static bool txNmeaMessagePrefixSet = false;
-
-/**
- @return
- The transmit multicast NMEA message prefix
- */
-unsigned char * getTxNmeaMessagePrefix(void) {
- if (!txNmeaMessagePrefixSet) {
- setTxNmeaMessagePrefix(PUD_TX_NMEAMESSAGEPREFIX_DEFAULT, NULL,
- (set_plugin_parameter_addon) {.pc = NULL});
- }
- return &txNmeaMessagePrefix[0];
-}
-
-/**
- Set the transmit multicast NMEA message prefix
-
- @param value
- The transmit multicast NMEA message prefix (in string representation)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
-int setTxNmeaMessagePrefix(const char *value, void *data __attribute__ ((unused)),
- set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_TX_NMEAMESSAGEPREFIX_NAME;
- size_t valueLength;
- bool invalidChars;
- char report[256];
-
- assert (value != NULL);
-
- valueLength = strlen(value);
- if (valueLength != PUD_TXNMEAMESSAGEPREFIXLENGTH) {
- pudError(false, "Configured %s (%s) must be %u exactly characters",
- valueName, value, PUD_TXNMEAMESSAGEPREFIXLENGTH);
- return true;
- }
-
- invalidChars = nmea_string_has_invalid_chars(value, valueName, &report[0],
- sizeof(report));
- if (invalidChars) {
- pudError(false, &report[0]);
- return true;
- }
-
- if ((strchr(value, ' ') != NULL) || (strchr(value, '\t') != NULL)) {
- pudError(false, "Configured %s (%s) can not contain whitespace",
- valueName, value);
- return true;
- }
-
- strcpy((char *) &txNmeaMessagePrefix[0], value);
- txNmeaMessagePrefixSet = true;
- return false;
-}
-
/*
* olsrTtl
*/
return olsrTtl;
}
-/**
- Set the OLSR multicast IP packet time-to-live
-
- @param value
- The OLSR multicast IP packet time-to-live (a number in string representation)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setOlsrTtl(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_OLSR_TTL_NAME;
- unsigned long long olsrTtlNew;
- assert (value != NULL);
-
- if (!readULL(valueName, value, &olsrTtlNew)) {
+ if (!readUC(valueName, value, &olsrTtl)) {
return true;
}
- if ((olsrTtlNew < 1) || (olsrTtlNew > MAX_TTL)) {
- pudError(false, "Configured %s (%llu) is outside of valid range 1-%u",
- valueName, olsrTtlNew, MAX_TTL);
+ if ((olsrTtl < 1) /* || (olsrTtl > MAX_TTL) */) {
+ pudError(false, "Value of parameter %s (%u) is outside of valid range 1-%u",
+ valueName, olsrTtl, MAX_TTL);
return true;
}
- olsrTtl = olsrTtlNew;
-
return false;
}
return updateIntervalStationary;
}
-/**
- Set stationary interval update plugin parameter
-
- @param value
- The stationary interval update plugin parameter (in seconds)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setUpdateIntervalStationary(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_UPDATE_INTERVAL_STATIONARY_NAME;
- unsigned long long updateIntervalStationaryNew;
-
- assert (value != NULL);
- if (!readULL(valueName, value, &updateIntervalStationaryNew)) {
+ if (!readULL(valueName, value, &updateIntervalStationary)) {
return true;
}
- if (updateIntervalStationaryNew < 1) {
- pudError(false, "Configured %s must be at least 1", valueName);
+ if (updateIntervalStationary < 1) {
+ pudError(false, "Value of parameter %s must be at least 1", valueName);
return true;
}
- updateIntervalStationary = updateIntervalStationaryNew;
-
return false;
}
return updateIntervalMoving;
}
-/**
- Set moving interval update plugin parameter
-
- @param value
- The moving interval update plugin parameter (in seconds)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setUpdateIntervalMoving(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_UPDATE_INTERVAL_MOVING_NAME;
- unsigned long long updateIntervalMovingNew;
-
- assert (value != NULL);
- if (!readULL(valueName, value, &updateIntervalMovingNew)) {
+ if (!readULL(valueName, value, &updateIntervalMoving)) {
return true;
}
- if (updateIntervalMovingNew < 1) {
- pudError(false, "Configured %s must be at least 1", valueName);
+ if (updateIntervalMoving < 1) {
+ pudError(false, "Value of parameter %s must be at least 1", valueName);
return true;
}
- updateIntervalMoving = updateIntervalMovingNew;
-
return false;
}
return uplinkUpdateIntervalStationary;
}
-/**
- Set uplink stationary interval update plugin parameter
-
- @param value
- The uplink stationary interval update plugin parameter (in seconds)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setUplinkUpdateIntervalStationary(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_UPLINK_UPDATE_INTERVAL_STATIONARY_NAME;
- unsigned long long uplinkUpdateIntervalStationaryNew;
- assert (value != NULL);
-
- if (!readULL(valueName, value, &uplinkUpdateIntervalStationaryNew)) {
+ if (!readULL(valueName, value, &uplinkUpdateIntervalStationary)) {
return true;
}
- if (uplinkUpdateIntervalStationaryNew < 1) {
- pudError(false, "Configured %s must be at least 1", valueName);
+ if (uplinkUpdateIntervalStationary < 1) {
+ pudError(false, "Value of parameter %s must be at least 1", valueName);
return true;
}
- uplinkUpdateIntervalStationary = uplinkUpdateIntervalStationaryNew;
-
return false;
}
return uplinkUpdateIntervalMoving;
}
-/**
- Set uplink moving interval update plugin parameter
-
- @param value
- The uplink moving interval update plugin parameter (in seconds)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setUplinkUpdateIntervalMoving(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_UPLINK_UPDATE_INTERVAL_MOVING_NAME;
- unsigned long long uplinkUpdateIntervalMovingNew;
-
- assert (value != NULL);
- if (!readULL(valueName, value, &uplinkUpdateIntervalMovingNew)) {
+ if (!readULL(valueName, value, &uplinkUpdateIntervalMoving)) {
return true;
}
- if (uplinkUpdateIntervalMovingNew < 1) {
- pudError(false, "Configured %s must be at least 1", valueName);
+ if (uplinkUpdateIntervalMoving < 1) {
+ pudError(false, "Value of parameter %s must be at least 1", valueName);
return true;
}
- uplinkUpdateIntervalMoving = uplinkUpdateIntervalMovingNew;
-
return false;
}
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)) {
+ if (!readULL(valueName, value, &gatewayDeterminationInterval)) {
return true;
}
- if (gatewayDeterminationIntervalNew < 1) {
- pudError(false, "Configured %s must be at least 1", valueName);
+ if (gatewayDeterminationInterval < 1) {
+ pudError(false, "Value of parameter %s must be at least 1", valueName);
return true;
}
- gatewayDeterminationInterval = gatewayDeterminationIntervalNew;
-
return false;
}
return movingSpeedThreshold;
}
-/**
- Set moving speed threshold plugin parameter
-
- @param value
- The moving speed threshold plugin parameter (in kph)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setMovingSpeedThreshold(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_MOVING_SPEED_THRESHOLD_NAME;
- unsigned long long movingSpeedThresholdNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &movingSpeedThresholdNew)) {
- return true;
- }
-
- movingSpeedThreshold = movingSpeedThresholdNew;
-
- return false;
+ return !readULL(PUD_MOVING_SPEED_THRESHOLD_NAME, value, &movingSpeedThreshold);
}
/*
return movingDistanceThreshold;
}
-/**
- Set moving distance threshold plugin parameter
-
- @param value
- The moving distance threshold plugin parameter (in meter)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setMovingDistanceThreshold(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_MOVING_DISTANCE_THRESHOLD_NAME;
- unsigned long long movingDistanceThresholdNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &movingDistanceThresholdNew)) {
- return true;
- }
-
- movingDistanceThreshold = movingDistanceThresholdNew;
-
- return false;
+ return !readULL(PUD_MOVING_DISTANCE_THRESHOLD_NAME, value, &movingDistanceThreshold);
}
/*
* dopMultiplier
*/
-/* The DOP multiplier plugin parameter */
+/** The DOP multiplier plugin parameter */
static double dopMultiplier = PUD_DOP_MULTIPLIER_DEFAULT;
/**
return dopMultiplier;
}
-/**
- Set DOP multiplier plugin parameter
-
- @param value
- The DOP multiplier plugin parameter
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setDopMultiplier(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_DOP_MULTIPLIER_NAME;
- double dopMultiplierNew;
-
- assert (value != NULL);
-
- if (!readDouble(valueName, value, &dopMultiplierNew)) {
- return true;
- }
-
- dopMultiplier = dopMultiplierNew;
-
- return false;
+ return !readDouble(PUD_DOP_MULTIPLIER_NAME, value, &dopMultiplier);
}
/*
return defaultHdop;
}
-/**
- Set default HDOP plugin parameter
-
- @param value
- The default HDOP plugin parameter (in meters)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setDefaultHdop(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_MOVING_DISTANCE_THRESHOLD_NAME;
- unsigned long long defaultHdopNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &defaultHdopNew)) {
- return true;
- }
-
- defaultHdop = defaultHdopNew;
-
- return false;
+ return !readULL(PUD_DEFAULT_HDOP_NAME, value, &defaultHdop);
}
/*
return defaultVdop;
}
-/**
- Set default VDOP plugin parameter
-
- @param value
- The default VDOP plugin parameter (in meters)
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setDefaultVdop(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_MOVING_DISTANCE_THRESHOLD_NAME;
- unsigned long long defaultVdopNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &defaultVdopNew)) {
- return true;
- }
-
- defaultVdop = defaultVdopNew;
-
- return false;
+ return !readULL(PUD_DEFAULT_VDOP_NAME, value, &defaultVdop);
}
/*
return averageDepth;
}
-/**
- Set average depth plugin parameter
-
- @param value
- The average depth plugin parameter
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setAverageDepth(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
static const char * valueName = PUD_AVERAGE_DEPTH_NAME;
- unsigned long long averageDepthNew;
-
- assert (value != NULL);
- if (!readULL(valueName, value, &averageDepthNew)) {
+ if (!readULL(valueName, value, &averageDepth)) {
return true;
}
- if (averageDepthNew < 1) {
- pudError(false, "Configured %s must be at least 1", valueName);
+ if (averageDepth < 1) {
+ pudError(false, "Value of parameter %s must be at least 1", valueName);
return true;
}
- averageDepth = averageDepthNew;
-
return false;
}
return hysteresisCountToStationary;
}
-/**
- Set hysteresis count plugin parameter
-
- @param value
- The hysteresis count plugin parameter
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setHysteresisCountToStationary(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_HYSTERESIS_COUNT_2STAT_NAME;
- unsigned long long hysteresisCountNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &hysteresisCountNew)) {
- return true;
- }
-
- hysteresisCountToStationary = hysteresisCountNew;
-
- return false;
+ return !readULL(PUD_HYSTERESIS_COUNT_2STAT_NAME, value, &hysteresisCountToStationary);
}
/*
return hysteresisCountToMoving;
}
-/**
- Set hysteresis count plugin parameter
-
- @param value
- The hysteresis count plugin parameter
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setHysteresisCountToMoving(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_HYSTERESIS_COUNT_2MOV_NAME;
- unsigned long long hysteresisCountNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &hysteresisCountNew)) {
- return true;
- }
-
- hysteresisCountToMoving = hysteresisCountNew;
-
- return false;
+ return !readULL(PUD_HYSTERESIS_COUNT_2MOV_NAME, value, &hysteresisCountToMoving);
}
/*
return gatewayHysteresisCountToStationary;
}
-/**
- Set hysteresis count plugin parameter
-
- @param value
- The hysteresis count plugin parameter
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setGatewayHysteresisCountToStationary(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_GAT_HYSTERESIS_COUNT_2STAT_NAME;
- unsigned long long hysteresisCountNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &hysteresisCountNew)) {
- return true;
- }
-
- gatewayHysteresisCountToStationary = hysteresisCountNew;
-
- return false;
+ return !readULL(PUD_GAT_HYSTERESIS_COUNT_2STAT_NAME, value, &gatewayHysteresisCountToStationary);
}
/*
return gatewayHysteresisCountToMoving;
}
-/**
- Set hysteresis count plugin parameter
-
- @param value
- The hysteresis count plugin parameter
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setGatewayHysteresisCountToMoving(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_GAT_HYSTERESIS_COUNT_2MOV_NAME;
- unsigned long long hysteresisCountNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &hysteresisCountNew)) {
- return true;
- }
-
- gatewayHysteresisCountToMoving = hysteresisCountNew;
-
- return false;
+ return !readULL(PUD_GAT_HYSTERESIS_COUNT_2MOV_NAME, value, &gatewayHysteresisCountToMoving);
}
/*
* useDeDup
*/
-/* when true then duplicate message detection is performed */
+/** when true then duplicate message detection is performed */
static bool useDeDup = PUD_USE_DEDUP_DEFAULT;
/**
return useDeDup;
}
-/**
- Set duplicate message detection setting plugin parameter
-
- @param value
- The duplicate message detection setting plugin parameter
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setUseDeDup(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_USE_DEDUP_NAME;
- unsigned long long useDeDupNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &useDeDupNew)) {
- return true;
- }
-
- if ((useDeDupNew != 0) && (useDeDupNew != 1)) {
- pudError(false, "Configured %s must be 0 (false) or 1 (true)",
- valueName);
- return true;
- }
-
- useDeDup = (useDeDupNew == 1);
-
- return false;
+ return !readBool(PUD_USE_DEDUP_NAME, value, &useDeDup);
}
/*
* deDupDepth
*/
-/** The hysteresis count for changing state from stationary to moving */
+/** The deduplication depth */
static unsigned long long deDupDepth = PUD_DEDUP_DEPTH_DEFAULT;
/**
@return
- The hysteresis count for changing state from stationary to moving
+ The deduplication depth
*/
unsigned long long getDeDupDepth(void) {
return deDupDepth;
}
-/**
- Set de-duplication depth plugin parameter
-
- @param value
- The de-duplication depth plugin parameter
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setDeDupDepth(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_DEDUP_DEPTH_NAME;
- unsigned long long deDupDepthNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &deDupDepthNew)) {
- return true;
- }
-
- deDupDepth = deDupDepthNew;
-
- return false;
+ return !readULL(PUD_DEDUP_DEPTH_NAME, value, &deDupDepth);
}
/*
* useLoopback
*/
-/* when true then loopback is performed */
+/** when true then loopback is performed */
static bool useLoopback = PUD_USE_LOOPBACK_DEFAULT;
/**
return useLoopback;
}
-/**
- Set loopback usage plugin parameter
-
- @param value
- The loopback usage plugin parameter
- @param data
- Unused
- @param addon
- Unused
-
- @return
- - true when an error is detected
- - false otherwise
- */
int setUseLoopback(const char *value, void *data __attribute__ ((unused)),
set_plugin_parameter_addon addon __attribute__ ((unused))) {
- static const char * valueName = PUD_USE_LOOPBACK_NAME;
- unsigned long long useLoopbackNew;
-
- assert (value != NULL);
-
- if (!readULL(valueName, value, &useLoopbackNew)) {
- return true;
- }
-
- if ((useLoopbackNew != 0) && (useLoopbackNew != 1)) {
- pudError(false, "Configured %s must be 0 (false) or 1 (true)",
- valueName);
- return true;
- }
-
- useLoopback = (useLoopbackNew == 1);
-
- return false;
+ return !readBool(PUD_USE_LOOPBACK_NAME, value, &useLoopback);
}
/*
retval = false;
}
- if (getUplinkPort() == getDownlinkPort()) {
+ if (isUplinkAddrSet() && (getUplinkPort() == getDownlinkPort())) {
pudError(false, "The uplink port and the downlink port must not be the same");
retval = false;
}