1 #include "configuration.h"
6 #include "networkInterfaces.h"
9 #include "olsr_types.h"
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
20 #include <sys/socket.h>
22 #include <nmea/util.h>
29 Determine the address of the port in an OLSR socket address
32 The IP version (AF_INET or AF_INET6)
34 A pointer to OLSR socket address
36 A pointer to the location where the pointer to the port will be stored
38 static void getOlsrSockaddrPortAddress(int ipVersion,
39 union olsr_sockaddr * addr, in_port_t ** port) {
40 if (ipVersion == AF_INET) {
41 *port = &addr->in4.sin_port;
43 *port = &addr->in6.sin6_port;
48 Get pointers to the IP address and port in an OLSR socket address
50 The IP version (AF_INET or AF_INET6)
52 A pointer to OLSR socket address
54 A pointer to the location where the pointer to the IP address will be stored
56 A pointer to the location where the pointer to the port will be stored
58 static void getOlsrSockAddrAndPortAddresses(int ipVersion,
59 union olsr_sockaddr * addr, void ** ipAddress, in_port_t ** port) {
60 if (ipVersion == AF_INET) {
61 *ipAddress = (void *) &addr->in4.sin_addr;
62 *port = (void *) &addr->in4.sin_port;
64 *ipAddress = (void *) &addr->in6.sin6_addr;
65 *port = (void *) &addr->in6.sin6_port;
70 Read an unsigned long long number from a value string
75 the string to convert to a number
77 a pointer to the location where to store the number upon successful conversion
83 static bool readULL(const char * valueName, const char * value,
84 unsigned long long * valueNumber) {
86 unsigned long long valueNew;
89 valueNew = strtoull(value, &endPtr, 10);
91 if (!((endPtr != value) && (*value != '\0') && (*endPtr == '\0'))) {
92 /* invalid conversion */
93 pudError(true, "Configured %s (%s) could not be converted to a number",
98 *valueNumber = valueNew;
104 Read a double number from a value string
107 the name of the value
109 the string to convert to a number
111 a pointer to the location where to store the number upon successful conversion
117 static bool readDouble(const char * valueName, const char * value,
118 double * valueNumber) {
119 char * endPtr = NULL;
123 valueNew = strtod(value, &endPtr);
125 if (!((endPtr != value) && (*value != '\0') && (*endPtr == '\0'))) {
126 /* invalid conversion */
127 pudError(true, "Configured %s (%s) could not be converted to a number",
132 *valueNumber = valueNew;
141 /** The nodeIdType */
142 static NodeIdType nodeIdType = PUD_NODE_ID_TYPE_DEFAULT;
148 NodeIdType getNodeIdTypeNumber(void) {
153 Set the node ID type.
156 The value of the node ID type to set (a number in string representation)
163 - true when an error is detected
166 int setNodeIdType(const char *value, void *data __attribute__ ((unused)),
167 set_plugin_parameter_addon addon __attribute__ ((unused))) {
168 static const char * valueName = PUD_NODE_ID_TYPE_NAME;
169 unsigned long long nodeIdTypeNew;
171 assert (value != NULL);
173 if (!readULL(valueName, value, &nodeIdTypeNew)) {
177 if (!isValidNodeIdType(nodeIdTypeNew)) {
178 pudError(false, "Configured %s (%llu) is reserved", valueName,
183 nodeIdType = nodeIdTypeNew;
192 /** The maximum length of a nodeId */
193 #define PUD_NODEIDMAXLENGTH 255
196 The type that is used to store the nodeId as a binary representation
198 typedef union _nodeIdBinaryType {
199 unsigned long long longValue;
200 unsigned char stringValue[PUD_NODEIDMAXLENGTH + 1];
201 union olsr_ip_addr ip;
202 unsigned char mac[PUD_NODEIDTYPE_MAC_BYTES];
205 /** The nodeId buffer */
206 static unsigned char nodeId[PUD_NODEIDMAXLENGTH + 1];
208 /** The length of the string in the nodeId buffer */
209 static size_t nodeIdLength = 0;
211 /** True when the nodeId is set */
212 static bool nodeIdSet = false;
214 /** The nodeId as a binary representation */
215 static nodeIdBinaryType nodeIdBinary;
217 /** The length of the string in the nodeIdBinary buffer */
218 static size_t nodeIdBinaryLength = 0;
220 /** True when the nodeIdBinary is set */
221 static bool nodeIdBinarySet = false;
227 unsigned char * getNodeId(void) {
228 return getNodeIdWithLength(NULL);
232 Get the nodeId and its length
235 a pointer to the variable in which to store the nodeId length (allowed to be
236 NULL, in which case the length is not stored)
241 unsigned char * getNodeIdWithLength(size_t *length) {
243 setNodeId("", NULL, (set_plugin_parameter_addon) {.pc = NULL});
246 if (length != NULL) {
247 *length = nodeIdLength;
257 The value of the node ID to set (in string representation)
264 - true when an error is detected
267 int setNodeId(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
268 static const char * valueName = PUD_NODE_ID_NAME;
271 assert (value != NULL);
273 valueLength = strlen(value);
274 if (valueLength > PUD_NODEIDMAXLENGTH) {
275 pudError(false, "Configured %s is too long, maximum length is"
276 " %u, current length is %lu", valueName, PUD_NODEIDMAXLENGTH,
277 (unsigned long) valueLength);
281 strcpy((char *) &nodeId[0], value);
282 nodeIdLength = valueLength;
293 Validate whether the configured nodeId is valid w.r.t. the configured
294 nodeIdType, for types that are MAC addresses
300 static bool setupNodeIdBinaryMAC(void) {
301 unsigned char * mac = getMainIpMacAddress();
306 memcpy(&nodeIdBinary.mac, mac, PUD_NODEIDTYPE_MAC_BYTES);
307 nodeIdBinaryLength = PUD_NODEIDTYPE_MAC_BYTES;
308 nodeIdBinarySet = true;
310 if (setupNodeIdBinaryBufferForOlsrCache(mac, PUD_NODEIDTYPE_MAC_BYTES)) {
314 pudError(false, "%s value \"MAC address\" could not be setup", PUD_NODE_ID_NAME);
319 Validate whether the configured nodeId is valid w.r.t. the configured
320 nodeIdType, for types that fit in an unsigned long long (64 bits)
327 the number of bytes in the buffer
333 static bool setupNodeIdBinaryLongLong(unsigned long long min,
334 unsigned long long max, unsigned int bytes) {
335 if (!nodeIdBinarySet) {
336 if (!readULL(PUD_NODE_ID_NAME, (char *) getNodeId(),
337 &nodeIdBinary.longValue)) {
340 nodeIdBinaryLength = bytes;
341 nodeIdBinarySet = true;
344 if ((nodeIdBinary.longValue < min) || (nodeIdBinary.longValue > max)) {
345 pudError(false, "%s value %llu is out of range [%llu,%llu]",
346 PUD_NODE_ID_NAME, nodeIdBinary.longValue, min, max);
350 if (setupNodeIdBinaryLongForOlsrCache(nodeIdBinary.longValue, bytes)) {
358 Validate whether the configured nodeId is valid w.r.t. the configured
359 nodeIdType, for types that are strings
365 static bool setupNodeIdBinaryString(void) {
369 char * nodeid = (char *)getNodeIdWithLength(&nodeidlength);
371 invalidChars = nmea_string_has_invalid_chars(nodeid,
372 PUD_NODE_ID_NAME, &report[0], sizeof(report));
374 pudError(false, &report[0]);
378 if (nodeidlength > PUD_NODEIDMAXLENGTH) {
379 pudError(false, "%s value \"%s\" is too long", PUD_NODE_ID_NAME, &nodeid[0]);
383 /* including trailing \0 */
384 memcpy(&nodeIdBinary.stringValue[0], &nodeid[0], nodeidlength + 1);
385 nodeIdBinaryLength = nodeIdLength + 1;
386 nodeIdBinarySet = true;
388 /* including trailing \0 */
389 if (setupNodeIdBinaryBufferForOlsrCache(&nodeid[0], nodeidlength + 1)) {
393 pudError(false, "%s value \"%s\" is too long", PUD_NODE_ID_NAME, &nodeid[0]);
398 Validate whether the configured nodeId is valid w.r.t. the configured
399 nodeIdType, for types that are IP addresses
405 static bool setupNodeIdBinaryIp(void) {
408 if (olsr_cnf->ip_version == AF_INET) {
409 src = &olsr_cnf->main_addr.v4;
410 length = sizeof(struct in_addr);
412 src = &olsr_cnf->main_addr.v6;
413 length = sizeof(struct in6_addr);
416 memcpy(&nodeIdBinary.ip, src, length);
417 nodeIdBinaryLength = length;
418 nodeIdBinarySet = true;
420 if (setupNodeIdBinaryBufferForOlsrCache(src, length)) {
424 pudError(false, "%s value \"OLSRd main IP address\" could not be setup", PUD_NODE_ID_NAME);
429 Validate whether the configured nodeId is valid w.r.t. the configured
436 static bool setupNodeIdBinaryAndValidate(NodeIdType nodeIdTypeNumber) {
437 switch (nodeIdTypeNumber) {
438 case PUD_NODEIDTYPE_MAC: /* hardware address */
439 return setupNodeIdBinaryMAC();
441 case PUD_NODEIDTYPE_MSISDN: /* an MSISDN number */
442 return setupNodeIdBinaryLongLong(PUD_NODEIDTYPE_MSISDN_MIN,
443 PUD_NODEIDTYPE_MSISDN_MAX, PUD_NODEIDTYPE_MSISDN_BYTES);
445 case PUD_NODEIDTYPE_TETRA: /* a Tetra number */
446 return setupNodeIdBinaryLongLong(PUD_NODEIDTYPE_TETRA_MIN,
447 PUD_NODEIDTYPE_TETRA_MAX, PUD_NODEIDTYPE_TETRA_BYTES);
449 case PUD_NODEIDTYPE_DNS: /* DNS name */
450 return setupNodeIdBinaryString();
452 case PUD_NODEIDTYPE_MMSI: /* an AIS MMSI number */
453 return setupNodeIdBinaryLongLong(PUD_NODEIDTYPE_MMSI_MIN,
454 PUD_NODEIDTYPE_MMSI_MAX, PUD_NODEIDTYPE_MMSI_BYTES);
456 case PUD_NODEIDTYPE_URN: /* a URN number */
457 return setupNodeIdBinaryLongLong(PUD_NODEIDTYPE_URN_MIN,
458 PUD_NODEIDTYPE_URN_MAX, PUD_NODEIDTYPE_URN_BYTES);
460 case PUD_NODEIDTYPE_192:
461 return setupNodeIdBinaryLongLong(PUD_NODEIDTYPE_192_MIN,
462 PUD_NODEIDTYPE_192_MAX, PUD_NODEIDTYPE_192_BYTES);
464 case PUD_NODEIDTYPE_193:
465 return setupNodeIdBinaryLongLong(PUD_NODEIDTYPE_193_MIN,
466 PUD_NODEIDTYPE_193_MAX, PUD_NODEIDTYPE_193_BYTES);
468 case PUD_NODEIDTYPE_194:
469 return setupNodeIdBinaryLongLong(PUD_NODEIDTYPE_194_MIN,
470 PUD_NODEIDTYPE_194_MAX, PUD_NODEIDTYPE_194_BYTES);
472 case PUD_NODEIDTYPE_IPV4: /* IPv4 address */
473 case PUD_NODEIDTYPE_IPV6: /* IPv6 address */
474 default: /* unsupported */
475 return setupNodeIdBinaryIp();
485 /** The maximum number of RX non-OLSR interfaces */
486 #define PUD_RX_NON_OLSR_IF_MAX 32
488 /** Array with RX non-OLSR interface names */
489 static unsigned char rxNonOlsrInterfaceNames[PUD_RX_NON_OLSR_IF_MAX][IFNAMSIZ + 1];
491 /** The number of RX non-OLSR interface names in the array */
492 static unsigned int rxNonOlsrInterfaceCount = 0;
495 Determine whether a give interface name is configured as a receive non-OLSR
499 The interface name to check
502 - true when the given interface name is configured as a receive non-OLSR
506 bool isRxNonOlsrInterface(const char *ifName) {
509 assert (ifName != NULL);
511 for (i = 0; i < rxNonOlsrInterfaceCount; i++) {
512 if (strncmp((char *) &rxNonOlsrInterfaceNames[i][0], ifName, IFNAMSIZ
522 Add a receive non-OLSR interface
525 The name of the non-OLSR interface to add
532 - true when an error is detected
535 int addRxNonOlsrInterface(const char *value, void *data __attribute__ ((unused)),
536 set_plugin_parameter_addon addon __attribute__ ((unused))) {
537 unsigned long valueLength;
539 assert (value != NULL);
541 valueLength = strlen(value);
542 if (valueLength > IFNAMSIZ) {
543 pudError(false, "Configured %s (%s) is too long,"
544 " maximum length is %u, current length is %lu",
545 PUD_RX_NON_OLSR_IF_NAME, value, IFNAMSIZ, valueLength);
549 if (!isRxNonOlsrInterface(value)) {
550 if (rxNonOlsrInterfaceCount >= PUD_RX_NON_OLSR_IF_MAX) {
551 pudError(false, "Can't configure more than %u receive interfaces",
552 PUD_RX_NON_OLSR_IF_MAX);
556 strcpy((char *) &rxNonOlsrInterfaceNames[rxNonOlsrInterfaceCount][0],
558 rxNonOlsrInterfaceCount++;
565 * rxAllowedSourceIpAddress
568 /** The maximum number of RX allowed source IP addresses */
569 #define PUD_RX_ALLOWED_SOURCE_IP_MAX 32
571 /** Array with RX allowed source IP addresses */
572 static struct sockaddr rxAllowedSourceIpAddresses[PUD_RX_ALLOWED_SOURCE_IP_MAX];
574 /** The number of RX allowed source IP addresses in the array */
575 static unsigned int rxAllowedSourceIpAddressesCount = 0;
578 Determine whether a give IP address is configured as an allowed source IP
582 The IP address to check
585 - true when the given IP address is configured as an allowed source IP
589 bool isRxAllowedSourceIpAddress(struct sockaddr * sender) {
591 unsigned int addrSize;
594 if (rxAllowedSourceIpAddressesCount == 0) {
598 if (sender == NULL) {
602 if (sender->sa_family == AF_INET) {
603 addr = (void *) (&((struct sockaddr_in *) sender)->sin_addr);
604 addrSize = sizeof(struct in_addr);
606 addr = (void *) (&((struct sockaddr_in6 *) sender)->sin6_addr);
607 addrSize = sizeof(struct in6_addr);
610 for (i = 0; i < rxAllowedSourceIpAddressesCount; i++) {
611 if ((rxAllowedSourceIpAddresses[i].sa_family == sender->sa_family)
612 && (memcmp(&rxAllowedSourceIpAddresses[i].sa_data, addr,
622 Set the RX allowed source IP addresses.
625 The RX allowed source IP address (in string representation)
632 - true when an error is detected
635 int addRxAllowedSourceIpAddress(const char *value, void *data __attribute__ ((unused)),
636 set_plugin_parameter_addon addon __attribute__ ((unused))) {
637 static const char * valueName = PUD_RX_ALLOWED_SOURCE_IP_NAME;
638 const char * valueInternal = value;
640 struct sockaddr addr;
642 assert (value != NULL);
644 memset(&addr, 0, sizeof(addr));
646 addr.sa_family = olsr_cnf->ip_version;
647 conversion = inet_pton(olsr_cnf->ip_version, valueInternal, &addr.sa_data);
648 if (conversion != 1) {
649 pudError((conversion == -1) ? true : false,
650 "Configured %s (%s) is not an IP address", valueName,
655 if ((rxAllowedSourceIpAddressesCount == 0) || !isRxAllowedSourceIpAddress(&addr)) {
656 if (rxAllowedSourceIpAddressesCount >= PUD_RX_ALLOWED_SOURCE_IP_MAX) {
657 pudError(false, "Can't configure more than %u allowed source IP"
658 " addresses", PUD_RX_ALLOWED_SOURCE_IP_MAX);
662 memcpy(&rxAllowedSourceIpAddresses[rxAllowedSourceIpAddressesCount],
663 &addr, sizeof(addr));
664 rxAllowedSourceIpAddressesCount++;
674 /** The rx multicast address */
675 static union olsr_sockaddr rxMcAddr;
677 /** True when the rx multicast address is set */
678 static bool rxMcAddrSet = false;
682 The receive multicast address (in network byte order). Sets both the address
683 and the port to their default values when the address was not yet set.
685 union olsr_sockaddr * getRxMcAddr(void) {
687 setRxMcAddr(NULL, NULL, ((set_plugin_parameter_addon) {.pc = NULL}));
693 Set the receive multicast address. Sets the address to its default value when
694 the value is NULL. Also sets the port to its default value when the address
698 The receive multicast address (in string representation)
705 - true when an error is detected
708 int setRxMcAddr(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
709 static const char * valueName = PUD_RX_MC_ADDR_NAME;
712 const char * valueInternal = value;
715 getOlsrSockAddrAndPortAddresses(olsr_cnf->ip_version, &rxMcAddr, &ipAddress,
717 if (olsr_cnf->ip_version == AF_INET) {
718 rxMcAddr.in4.sin_family = olsr_cnf->ip_version;
719 if (valueInternal == NULL) {
720 valueInternal = PUD_RX_MC_ADDR_4_DEFAULT;
723 rxMcAddr.in6.sin6_family = olsr_cnf->ip_version;
724 if (valueInternal == NULL) {
725 valueInternal = PUD_RX_MC_ADDR_6_DEFAULT;
730 *port = htons(PUD_RX_MC_PORT_DEFAULT);
733 conversion = inet_pton(olsr_cnf->ip_version, valueInternal, ipAddress);
734 if (conversion != 1) {
735 pudError((conversion == -1) ? true : false,
736 "Configured %s (%s) is not an IP address", valueName,
741 if (!isMulticast(olsr_cnf->ip_version, &rxMcAddr)) {
742 pudError(false, "Configured %s (%s) is not a multicast address",
743 valueName, valueInternal);
757 The receive multicast port (in network byte order)
759 unsigned short getRxMcPort(void) {
761 getOlsrSockaddrPortAddress(olsr_cnf->ip_version, getRxMcAddr(), &port);
766 Set the receive multicast port
769 The receive multicast port (a number in string representation)
776 - true when an error is detected
779 int setRxMcPort(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
780 static const char * valueName = PUD_RX_MC_PORT_NAME;
781 unsigned long long rxMcPortNew;
783 union olsr_sockaddr * addr = getRxMcAddr();
785 assert (value != NULL);
787 if (!readULL(valueName, value, &rxMcPortNew)) {
791 if ((rxMcPortNew < 1) || (rxMcPortNew > 65535)) {
792 pudError(false, "Configured %s (%llu) is outside of"
793 " valid range 1-65535", valueName, rxMcPortNew);
797 getOlsrSockaddrPortAddress(olsr_cnf->ip_version, addr, &port);
798 *port = htons((uint16_t) rxMcPortNew);
807 /** The maximum number of rx non-olsr interfaces */
808 #define PUD_TX_NON_OLSR_IF_MAX 32
810 /** Array with tx non-olsr interface names */
811 static unsigned char txNonOlsrInterfaceNames[PUD_TX_NON_OLSR_IF_MAX][IFNAMSIZ + 1];
813 /** The number of tx interface names in the array */
814 static unsigned int txNonOlsrInterfaceCount = 0;
817 Determine whether a give interface name is configured as a transmit non-OLSR
821 The interface to check
824 - true when the given interface name is configured as a transmit non-OLSR
828 bool isTxNonOlsrInterface(const char *ifName) {
831 assert (ifName != NULL);
833 for (i = 0; i < txNonOlsrInterfaceCount; i++) {
834 if (strncmp((char *) &txNonOlsrInterfaceNames[i][0], ifName, IFNAMSIZ
844 Add a transmit non-OLSR interface
847 The name of the non-OLSR interface to add
854 - true when an error is detected
857 int addTxNonOlsrInterface(const char *value, void *data __attribute__ ((unused)),
858 set_plugin_parameter_addon addon __attribute__ ((unused))) {
859 unsigned long valueLength;
861 assert (value != NULL);
863 valueLength = strlen(value);
864 if (valueLength > IFNAMSIZ) {
865 pudError(false, "Configured %s (%s) is too long,"
866 " maximum length is %u, current length is %lu",
867 PUD_TX_NON_OLSR_IF_NAME, value, IFNAMSIZ, valueLength);
871 if (!isTxNonOlsrInterface(value)) {
872 if (txNonOlsrInterfaceCount >= PUD_TX_NON_OLSR_IF_MAX) {
873 pudError(false, "Can not configure more than %u transmit"
874 " interfaces", PUD_TX_NON_OLSR_IF_MAX);
878 strcpy((char *) &txNonOlsrInterfaceNames[txNonOlsrInterfaceCount][0],
880 txNonOlsrInterfaceCount++;
890 /** The tx multicast address */
891 static union olsr_sockaddr txMcAddr;
893 /** True when the tx multicast address is set */
894 static bool txMcAddrSet = false;
898 The transmit multicast address (in network byte order). Sets both the address
899 and the port to their default values when the address was not yet set.
901 union olsr_sockaddr * getTxMcAddr(void) {
903 setTxMcAddr(NULL, NULL, ((set_plugin_parameter_addon) {.pc = NULL}));
909 Set the transmit multicast address. Sets the address to its default value when
910 the value is NULL. Also sets the port to its default value when the address
914 The transmit multicast address (in string representation)
921 - true when an error is detected
924 int setTxMcAddr(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
925 static const char * valueName = PUD_TX_MC_ADDR_NAME;
928 const char * valueInternal = value;
931 getOlsrSockAddrAndPortAddresses(olsr_cnf->ip_version, &txMcAddr, &ipAddress,
933 if (olsr_cnf->ip_version == AF_INET) {
934 txMcAddr.in4.sin_family = olsr_cnf->ip_version;
935 if (valueInternal == NULL) {
936 valueInternal = PUD_TX_MC_ADDR_4_DEFAULT;
939 txMcAddr.in6.sin6_family = olsr_cnf->ip_version;
940 if (valueInternal == NULL) {
941 valueInternal = PUD_TX_MC_ADDR_6_DEFAULT;
946 *port = htons(PUD_TX_MC_PORT_DEFAULT);
949 conversion = inet_pton(olsr_cnf->ip_version, valueInternal, ipAddress);
950 if (conversion != 1) {
951 pudError((conversion == -1) ? true : false,
952 "Configured %s (%s) is not an IP address", valueName,
957 if (!isMulticast(olsr_cnf->ip_version, &txMcAddr)) {
958 pudError(false, "Configured %s (%s) is not a multicast address",
959 valueName, valueInternal);
973 The transmit multicast port (in network byte order)
975 unsigned short getTxMcPort(void) {
977 getOlsrSockaddrPortAddress(olsr_cnf->ip_version, getTxMcAddr(), &port);
982 Set the transmit multicast port
985 The transmit multicast port (a number in string representation)
992 - true when an error is detected
995 int setTxMcPort(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
996 static const char * valueName = PUD_TX_MC_PORT_NAME;
997 unsigned long long txMcPortNew;
999 union olsr_sockaddr * addr = getTxMcAddr();
1001 assert (value != NULL);
1003 if (!readULL(valueName, value, &txMcPortNew)) {
1007 if ((txMcPortNew < 1) || (txMcPortNew > 65535)) {
1008 pudError(false, "Configured %s (%llu) is outside of"
1009 " valid range 1-65535", valueName, txMcPortNew);
1013 getOlsrSockaddrPortAddress(olsr_cnf->ip_version, addr, &port);
1014 *port = htons((uint16_t) txMcPortNew);
1023 /** The uplink address */
1024 static union olsr_sockaddr uplinkAddr;
1026 /** True when the uplink address is set */
1027 static bool uplinkAddrSet = false;
1029 /** True when the uplink address is set */
1030 static bool uplinkPortSet = false;
1034 - true when the uplink address is set
1037 bool isUplinkAddrSet(void) {
1038 return uplinkAddrSet;
1043 The uplink address (in network byte order). Sets both the address
1044 and the port to their default values when the address was not yet set.
1046 union olsr_sockaddr * getUplinkAddr(void) {
1047 if (!uplinkAddrSet) {
1048 setUplinkAddr(NULL, NULL, ((set_plugin_parameter_addon) {.pc = NULL}));
1054 Set the uplink address. Sets the address to its default value when
1055 the value is NULL. Also sets the port to its default value when the address
1059 The uplink address (in string representation)
1066 - true when an error is detected
1069 int setUplinkAddr(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
1070 static const char * valueName = PUD_UPLINK_ADDR_NAME;
1073 const char * valueInternal = value;
1075 bool defaultValue = false;
1077 getOlsrSockAddrAndPortAddresses(olsr_cnf->ip_version, &uplinkAddr,
1079 if (olsr_cnf->ip_version == AF_INET) {
1080 uplinkAddr.in4.sin_family = olsr_cnf->ip_version;
1081 if (valueInternal == NULL) {
1082 valueInternal = PUD_UPLINK_ADDR_4_DEFAULT;
1083 defaultValue = true;
1086 uplinkAddr.in6.sin6_family = olsr_cnf->ip_version;
1087 if (valueInternal == NULL) {
1088 valueInternal = PUD_UPLINK_ADDR_6_DEFAULT;
1089 defaultValue = true;
1093 if (!uplinkPortSet) {
1094 *port = htons(PUD_UPLINK_PORT_DEFAULT);
1095 uplinkPortSet = true;
1098 conversion = inet_pton(olsr_cnf->ip_version, valueInternal, ipAddress);
1099 if (conversion != 1) {
1100 pudError((conversion == -1) ? true : false,
1101 "Configured %s (%s) is not an IP address", valueName,
1106 if (!defaultValue) {
1107 uplinkAddrSet = true;
1119 The uplink port (in network byte order)
1121 unsigned short getUplinkPort(void) {
1123 getOlsrSockaddrPortAddress(olsr_cnf->ip_version, getUplinkAddr(), &port);
1131 The uplink port (a number in string representation)
1138 - true when an error is detected
1141 int setUplinkPort(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
1142 static const char * valueName = PUD_UPLINK_PORT_NAME;
1143 unsigned long long uplinkPortNew;
1145 union olsr_sockaddr * addr = getUplinkAddr();
1147 assert (value != NULL);
1149 if (!readULL(valueName, value, &uplinkPortNew)) {
1153 if ((uplinkPortNew < 1) || (uplinkPortNew > 65535)) {
1154 pudError(false, "Configured %s (%llu) is outside of"
1155 " valid range 1-65535", valueName, uplinkPortNew);
1159 getOlsrSockaddrPortAddress(olsr_cnf->ip_version, addr, &port);
1160 *port = htons((uint16_t) uplinkPortNew);
1161 uplinkPortSet = true;
1171 /** the downlink port */
1172 unsigned short downlinkPort = 0;
1174 /** true when the downlinkPort is set */
1175 bool downlinkPortSet = false;
1179 The downlink port (in network byte order)
1181 unsigned short getDownlinkPort(void) {
1182 if (!downlinkPortSet) {
1183 downlinkPort = htons(PUD_DOWNLINK_PORT_DEFAULT);
1184 downlinkPortSet = true;
1187 return downlinkPort;
1191 Set the downlink port
1194 The downlink port (a number in string representation)
1201 - true when an error is detected
1204 int setDownlinkPort(const char *value, void *data __attribute__ ((unused)),
1205 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1206 static const char * valueName = PUD_DOWNLINK_PORT_NAME;
1207 unsigned long long downlinkPortNew;
1209 assert(value != NULL);
1211 if (!readULL(valueName, value, &downlinkPortNew)) {
1215 if ((downlinkPortNew < 1) || (downlinkPortNew > 65535)) {
1216 pudError(false, "Configured %s (%llu) is outside of"
1217 " valid range 1-65535", valueName, downlinkPortNew);
1221 downlinkPort = htons(downlinkPortNew);
1222 downlinkPortSet = true;
1232 static unsigned char txTtl = PUD_TX_TTL_DEFAULT;
1236 The transmit multicast IP packet time-to-live
1238 unsigned char getTxTtl(void) {
1243 Set the transmit multicast IP packet time-to-live
1246 The transmit multicast IP packet time-to-live (a number in string representation)
1253 - true when an error is detected
1256 int setTxTtl(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
1257 static const char * valueName = PUD_TX_TTL_NAME;
1258 unsigned long long txTtlNew;
1260 assert (value != NULL);
1262 if (!readULL(valueName, value, &txTtlNew)) {
1266 if ((txTtlNew < 1) || (txTtlNew > MAX_TTL)) {
1267 pudError(false, "Configured %s (%llu) is outside of"
1268 " valid range 1-%u", valueName, txTtlNew, MAX_TTL);
1278 * txNmeaMessagePrefix
1281 /** The exact length of the tx NMEA message prefix */
1282 #define PUD_TXNMEAMESSAGEPREFIXLENGTH 4
1284 /** The tx NMEA message prefix buffer */
1285 static unsigned char txNmeaMessagePrefix[PUD_TXNMEAMESSAGEPREFIXLENGTH + 1];
1287 /** True when the tx NMEA message prefix is set */
1288 static bool txNmeaMessagePrefixSet = false;
1292 The transmit multicast NMEA message prefix
1294 unsigned char * getTxNmeaMessagePrefix(void) {
1295 if (!txNmeaMessagePrefixSet) {
1296 setTxNmeaMessagePrefix(PUD_TX_NMEAMESSAGEPREFIX_DEFAULT, NULL,
1297 (set_plugin_parameter_addon) {.pc = NULL});
1299 return &txNmeaMessagePrefix[0];
1303 Set the transmit multicast NMEA message prefix
1306 The transmit multicast NMEA message prefix (in string representation)
1313 - true when an error is detected
1316 int setTxNmeaMessagePrefix(const char *value, void *data __attribute__ ((unused)),
1317 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1318 static const char * valueName = PUD_TX_NMEAMESSAGEPREFIX_NAME;
1323 assert (value != NULL);
1325 valueLength = strlen(value);
1326 if (valueLength != PUD_TXNMEAMESSAGEPREFIXLENGTH) {
1327 pudError(false, "Configured %s (%s) must be %u exactly characters",
1328 valueName, value, PUD_TXNMEAMESSAGEPREFIXLENGTH);
1332 invalidChars = nmea_string_has_invalid_chars(value, valueName, &report[0],
1335 pudError(false, &report[0]);
1339 if ((strchr(value, ' ') != NULL) || (strchr(value, '\t') != NULL)) {
1340 pudError(false, "Configured %s (%s) can not contain whitespace",
1345 strcpy((char *) &txNmeaMessagePrefix[0], value);
1346 txNmeaMessagePrefixSet = true;
1355 static unsigned char olsrTtl = PUD_OLSR_TTL_DEFAULT;
1359 The OLSR multicast IP packet time-to-live
1361 unsigned char getOlsrTtl(void) {
1366 Set the OLSR multicast IP packet time-to-live
1369 The OLSR multicast IP packet time-to-live (a number in string representation)
1376 - true when an error is detected
1379 int setOlsrTtl(const char *value, void *data __attribute__ ((unused)), set_plugin_parameter_addon addon __attribute__ ((unused))) {
1380 static const char * valueName = PUD_OLSR_TTL_NAME;
1381 unsigned long long olsrTtlNew;
1383 assert (value != NULL);
1385 if (!readULL(valueName, value, &olsrTtlNew)) {
1389 if ((olsrTtlNew < 1) || (olsrTtlNew > MAX_TTL)) {
1390 pudError(false, "Configured %s (%llu) is outside of valid range 1-%u",
1391 valueName, olsrTtlNew, MAX_TTL);
1395 olsrTtl = olsrTtlNew;
1401 * updateIntervalStationary
1404 /** The stationary interval update plugin parameter (in seconds) */
1405 static unsigned long long updateIntervalStationary = PUD_UPDATE_INTERVAL_STATIONARY_DEFAULT;
1409 The stationary interval update plugin parameter (in seconds)
1411 unsigned long long getUpdateIntervalStationary(void) {
1412 return updateIntervalStationary;
1416 Set stationary interval update plugin parameter
1419 The stationary interval update plugin parameter (in seconds)
1426 - true when an error is detected
1429 int setUpdateIntervalStationary(const char *value, void *data __attribute__ ((unused)),
1430 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1431 static const char * valueName = PUD_UPDATE_INTERVAL_STATIONARY_NAME;
1432 unsigned long long updateIntervalStationaryNew;
1434 assert (value != NULL);
1436 if (!readULL(valueName, value, &updateIntervalStationaryNew)) {
1440 if (updateIntervalStationaryNew < 1) {
1441 pudError(false, "Configured %s must be at least 1", valueName);
1445 updateIntervalStationary = updateIntervalStationaryNew;
1451 * updateIntervalMoving
1454 /** The moving interval update plugin parameter (in seconds) */
1455 static unsigned long long updateIntervalMoving = PUD_UPDATE_INTERVAL_MOVING_DEFAULT;
1459 The moving interval update plugin parameter (in seconds)
1461 unsigned long long getUpdateIntervalMoving(void) {
1462 return updateIntervalMoving;
1466 Set moving interval update plugin parameter
1469 The moving interval update plugin parameter (in seconds)
1476 - true when an error is detected
1479 int setUpdateIntervalMoving(const char *value, void *data __attribute__ ((unused)),
1480 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1481 static const char * valueName = PUD_UPDATE_INTERVAL_MOVING_NAME;
1482 unsigned long long updateIntervalMovingNew;
1484 assert (value != NULL);
1486 if (!readULL(valueName, value, &updateIntervalMovingNew)) {
1490 if (updateIntervalMovingNew < 1) {
1491 pudError(false, "Configured %s must be at least 1", valueName);
1495 updateIntervalMoving = updateIntervalMovingNew;
1501 * uplinkUpdateIntervalStationary
1504 /** The uplink stationary interval update plugin parameter (in seconds) */
1505 static unsigned long long uplinkUpdateIntervalStationary = PUD_UPLINK_UPDATE_INTERVAL_STATIONARY_DEFAULT;
1509 The uplink stationary interval update plugin parameter (in seconds)
1511 unsigned long long getUplinkUpdateIntervalStationary(void) {
1512 return uplinkUpdateIntervalStationary;
1516 Set uplink stationary interval update plugin parameter
1519 The uplink stationary interval update plugin parameter (in seconds)
1526 - true when an error is detected
1529 int setUplinkUpdateIntervalStationary(const char *value, void *data __attribute__ ((unused)),
1530 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1531 static const char * valueName = PUD_UPLINK_UPDATE_INTERVAL_STATIONARY_NAME;
1532 unsigned long long uplinkUpdateIntervalStationaryNew;
1534 assert (value != NULL);
1536 if (!readULL(valueName, value, &uplinkUpdateIntervalStationaryNew)) {
1540 if (uplinkUpdateIntervalStationaryNew < 1) {
1541 pudError(false, "Configured %s must be at least 1", valueName);
1545 uplinkUpdateIntervalStationary = uplinkUpdateIntervalStationaryNew;
1551 * uplinkUpdateIntervalMoving
1554 /** The uplink moving interval update plugin parameter (in seconds) */
1555 static unsigned long long uplinkUpdateIntervalMoving = PUD_UPLINK_UPDATE_INTERVAL_MOVING_DEFAULT;
1559 The uplink moving interval update plugin parameter (in seconds)
1561 unsigned long long getUplinkUpdateIntervalMoving(void) {
1562 return uplinkUpdateIntervalMoving;
1566 Set uplink moving interval update plugin parameter
1569 The uplink moving interval update plugin parameter (in seconds)
1576 - true when an error is detected
1579 int setUplinkUpdateIntervalMoving(const char *value, void *data __attribute__ ((unused)),
1580 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1581 static const char * valueName = PUD_UPLINK_UPDATE_INTERVAL_MOVING_NAME;
1582 unsigned long long uplinkUpdateIntervalMovingNew;
1584 assert (value != NULL);
1586 if (!readULL(valueName, value, &uplinkUpdateIntervalMovingNew)) {
1590 if (uplinkUpdateIntervalMovingNew < 1) {
1591 pudError(false, "Configured %s must be at least 1", valueName);
1595 uplinkUpdateIntervalMoving = uplinkUpdateIntervalMovingNew;
1601 * movingSpeedThreshold
1604 /** The moving speed threshold plugin parameter (in kph) */
1605 static unsigned long long movingSpeedThreshold = PUD_MOVING_SPEED_THRESHOLD_DEFAULT;
1609 The moving speed threshold plugin parameter (in kph)
1611 unsigned long long getMovingSpeedThreshold(void) {
1612 return movingSpeedThreshold;
1616 Set moving speed threshold plugin parameter
1619 The moving speed threshold plugin parameter (in kph)
1626 - true when an error is detected
1629 int setMovingSpeedThreshold(const char *value, void *data __attribute__ ((unused)),
1630 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1631 static const char * valueName = PUD_MOVING_SPEED_THRESHOLD_NAME;
1632 unsigned long long movingSpeedThresholdNew;
1634 assert (value != NULL);
1636 if (!readULL(valueName, value, &movingSpeedThresholdNew)) {
1640 movingSpeedThreshold = movingSpeedThresholdNew;
1646 * movingDistanceThreshold
1649 /** The moving distance threshold plugin parameter (in meters) */
1650 static unsigned long long movingDistanceThreshold = PUD_MOVING_DISTANCE_THRESHOLD_DEFAULT;
1654 The moving distance threshold plugin parameter (in meters)
1656 unsigned long long getMovingDistanceThreshold(void) {
1657 return movingDistanceThreshold;
1661 Set moving distance threshold plugin parameter
1664 The moving distance threshold plugin parameter (in meter)
1671 - true when an error is detected
1674 int setMovingDistanceThreshold(const char *value, void *data __attribute__ ((unused)),
1675 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1676 static const char * valueName = PUD_MOVING_DISTANCE_THRESHOLD_NAME;
1677 unsigned long long movingDistanceThresholdNew;
1679 assert (value != NULL);
1681 if (!readULL(valueName, value, &movingDistanceThresholdNew)) {
1685 movingDistanceThreshold = movingDistanceThresholdNew;
1694 /* The DOP multiplier plugin parameter */
1695 static double dopMultiplier = PUD_DOP_MULTIPLIER_DEFAULT;
1699 The DOP multiplier plugin parameter
1701 double getDopMultiplier(void) {
1702 return dopMultiplier;
1706 Set DOP multiplier plugin parameter
1709 The DOP multiplier plugin parameter
1716 - true when an error is detected
1719 int setDopMultiplier(const char *value, void *data __attribute__ ((unused)),
1720 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1721 static const char * valueName = PUD_DOP_MULTIPLIER_NAME;
1722 double dopMultiplierNew;
1724 assert (value != NULL);
1726 if (!readDouble(valueName, value, &dopMultiplierNew)) {
1730 dopMultiplier = dopMultiplierNew;
1739 /** The default HDOP plugin parameter (in meters) */
1740 static unsigned long long defaultHdop = PUD_DEFAULT_HDOP_DEFAULT;
1744 The default HDOP plugin parameter (in meters)
1746 unsigned long long getDefaultHdop(void) {
1751 Set default HDOP plugin parameter
1754 The default HDOP plugin parameter (in meters)
1761 - true when an error is detected
1764 int setDefaultHdop(const char *value, void *data __attribute__ ((unused)),
1765 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1766 static const char * valueName = PUD_MOVING_DISTANCE_THRESHOLD_NAME;
1767 unsigned long long defaultHdopNew;
1769 assert (value != NULL);
1771 if (!readULL(valueName, value, &defaultHdopNew)) {
1775 defaultHdop = defaultHdopNew;
1784 /** The default VDOP plugin parameter (in meters) */
1785 static unsigned long long defaultVdop = PUD_DEFAULT_VDOP_DEFAULT;
1789 The default VDOP plugin parameter (in meters)
1791 unsigned long long getDefaultVdop(void) {
1796 Set default VDOP plugin parameter
1799 The default VDOP plugin parameter (in meters)
1806 - true when an error is detected
1809 int setDefaultVdop(const char *value, void *data __attribute__ ((unused)),
1810 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1811 static const char * valueName = PUD_MOVING_DISTANCE_THRESHOLD_NAME;
1812 unsigned long long defaultVdopNew;
1814 assert (value != NULL);
1816 if (!readULL(valueName, value, &defaultVdopNew)) {
1820 defaultVdop = defaultVdopNew;
1829 /** The depth of the average list */
1830 static unsigned long long averageDepth = PUD_AVERAGE_DEPTH_DEFAULT;
1834 The depth of the average list
1836 unsigned long long getAverageDepth(void) {
1837 return averageDepth;
1841 Set average depth plugin parameter
1844 The average depth plugin parameter
1851 - true when an error is detected
1854 int setAverageDepth(const char *value, void *data __attribute__ ((unused)),
1855 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1856 static const char * valueName = PUD_AVERAGE_DEPTH_NAME;
1857 unsigned long long averageDepthNew;
1859 assert (value != NULL);
1861 if (!readULL(valueName, value, &averageDepthNew)) {
1865 if (averageDepthNew < 1) {
1866 pudError(false, "Configured %s must be at least 1", valueName);
1870 averageDepth = averageDepthNew;
1876 * hysteresisCountToStationary
1879 /** The hysteresis count for changing state from moving to stationary */
1880 static unsigned long long hysteresisCountToStationary = PUD_HYSTERESIS_COUNT_2STAT_DEFAULT;
1884 The hysteresis count for changing state from moving to stationary
1886 unsigned long long getHysteresisCountToStationary(void) {
1887 return hysteresisCountToStationary;
1891 Set hysteresis count plugin parameter
1894 The hysteresis count plugin parameter
1901 - true when an error is detected
1904 int setHysteresisCountToStationary(const char *value, void *data __attribute__ ((unused)),
1905 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1906 static const char * valueName = PUD_HYSTERESIS_COUNT_2STAT_NAME;
1907 unsigned long long hysteresisCountNew;
1909 assert (value != NULL);
1911 if (!readULL(valueName, value, &hysteresisCountNew)) {
1915 hysteresisCountToStationary = hysteresisCountNew;
1921 * hysteresisCountToMoving
1924 /** The hysteresis count for changing state from stationary to moving */
1925 static unsigned long long hysteresisCountToMoving = PUD_HYSTERESIS_COUNT_2MOV_DEFAULT;
1929 The hysteresis count for changing state from stationary to moving
1931 unsigned long long getHysteresisCountToMoving(void) {
1932 return hysteresisCountToMoving;
1936 Set hysteresis count plugin parameter
1939 The hysteresis count plugin parameter
1946 - true when an error is detected
1949 int setHysteresisCountToMoving(const char *value, void *data __attribute__ ((unused)),
1950 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1951 static const char * valueName = PUD_HYSTERESIS_COUNT_2MOV_NAME;
1952 unsigned long long hysteresisCountNew;
1954 assert (value != NULL);
1956 if (!readULL(valueName, value, &hysteresisCountNew)) {
1960 hysteresisCountToMoving = hysteresisCountNew;
1969 /* when true then duplicate message detection is performed */
1970 static bool useDeDup = PUD_USE_DEDUP_DEFAULT;
1974 The duplicate message detection setting
1976 bool getUseDeDup(void) {
1981 Set duplicate message detection setting plugin parameter
1984 The duplicate message detection setting plugin parameter
1991 - true when an error is detected
1994 int setUseDeDup(const char *value, void *data __attribute__ ((unused)),
1995 set_plugin_parameter_addon addon __attribute__ ((unused))) {
1996 static const char * valueName = PUD_USE_DEDUP_NAME;
1997 unsigned long long useDeDupNew;
1999 assert (value != NULL);
2001 if (!readULL(valueName, value, &useDeDupNew)) {
2005 if ((useDeDupNew != 0) && (useDeDupNew != 1)) {
2006 pudError(false, "Configured %s must be 0 (false) or 1 (true)",
2011 useDeDup = (useDeDupNew == 1);
2020 /** The hysteresis count for changing state from stationary to moving */
2021 static unsigned long long deDupDepth = PUD_DEDUP_DEPTH_DEFAULT;
2025 The hysteresis count for changing state from stationary to moving
2027 unsigned long long getDeDupDepth(void) {
2032 Set de-duplication depth plugin parameter
2035 The de-duplication depth plugin parameter
2042 - true when an error is detected
2045 int setDeDupDepth(const char *value, void *data __attribute__ ((unused)),
2046 set_plugin_parameter_addon addon __attribute__ ((unused))) {
2047 static const char * valueName = PUD_DEDUP_DEPTH_NAME;
2048 unsigned long long deDupDepthNew;
2050 assert (value != NULL);
2052 if (!readULL(valueName, value, &deDupDepthNew)) {
2056 deDupDepth = deDupDepthNew;
2065 /* when true then loopback is performed */
2066 static bool useLoopback = PUD_USE_LOOPBACK_DEFAULT;
2070 The loopback usage setting
2072 bool getUseLoopback(void) {
2077 Set loopback usage plugin parameter
2080 The loopback usage plugin parameter
2087 - true when an error is detected
2090 int setUseLoopback(const char *value, void *data __attribute__ ((unused)),
2091 set_plugin_parameter_addon addon __attribute__ ((unused))) {
2092 static const char * valueName = PUD_USE_LOOPBACK_NAME;
2093 unsigned long long useLoopbackNew;
2095 assert (value != NULL);
2097 if (!readULL(valueName, value, &useLoopbackNew)) {
2101 if ((useLoopbackNew != 0) && (useLoopbackNew != 1)) {
2102 pudError(false, "Configured %s must be 0 (false) or 1 (true)",
2107 useLoopback = (useLoopbackNew == 1);
2117 Check the configuration for consistency and validity.
2120 - true when the configuration is consistent and valid
2123 unsigned int checkConfig(void) {
2126 if (!olsr_cnf->smart_gw_active) {
2127 pudError(false, "Smart Gateway must be active");
2131 if (rxNonOlsrInterfaceCount == 0) {
2132 pudError(false, "No receive non-OLSR interfaces configured");
2136 if (txNonOlsrInterfaceCount == 0) {
2137 pudError(false, "No transmit non-OLSR interfaces configured");
2142 if (nodeIdType == PUD_NODEIDTYPE_DNS) {
2143 char name[PUD_NODEIDMAXLENGTH + 1];
2146 if (gethostname(&name[0], sizeof(name)) < 0) {
2147 pudError(true, "Could not get the host name");
2150 setNodeId(&name[0], NULL,
2151 (set_plugin_parameter_addon) {.pc = NULL});
2153 } else if ((nodeIdType != PUD_NODEIDTYPE_MAC) && (nodeIdType
2154 != PUD_NODEIDTYPE_IPV4) && (nodeIdType != PUD_NODEIDTYPE_IPV6)) {
2155 pudError(false, "No node ID set while one is required for"
2156 " node type %u", nodeIdType);
2161 if (!setupNodeIdBinaryAndValidate(nodeIdType)) {
2165 if (updateIntervalMoving > updateIntervalStationary) {
2166 pudError(false,"The update interval for moving situations must not be"
2167 " larger than that for stationary situations");
2171 if (uplinkUpdateIntervalMoving > uplinkUpdateIntervalStationary) {
2172 pudError(false,"The uplink update interval for moving situations must not be"
2173 " larger than that for stationary situations");
2177 if (getUplinkPort() == getDownlinkPort()) {
2178 pudError(false, "The uplink port and the downlink port must not be the same");
2186 Check the configuration for consistency and validity after everything has been
2190 - true when the configuration is consistent and valid
2193 unsigned int checkRunSetup(void) {
2197 /* any receive interface name that is configured but is not the name of an
2198 * actual receive interface is not a valid interface name */
2199 for (i = 0; i < rxNonOlsrInterfaceCount; i++) {
2200 unsigned char * nonOlsrInterfaceName = &rxNonOlsrInterfaceNames[i][0];
2202 TRxTxNetworkInterface * interfaceObject = getRxNetworkInterfaces();
2204 while (interfaceObject != NULL) {
2205 if (strncmp((char *) nonOlsrInterfaceName,
2206 (char *) &interfaceObject->name[0], IFNAMSIZ + 1) == 0) {
2210 interfaceObject = interfaceObject->next;
2213 pudError(false, "Configured receive non-OLSR interface %s is not"
2214 " a known interface name", nonOlsrInterfaceName);
2219 /* any transmit interface name that is configured but is not the name of an
2220 * actual transmit interface is not a valid interface name */
2221 for (i = 0; i < txNonOlsrInterfaceCount; i++) {
2222 unsigned char * nonOlsrInterfaceName = &txNonOlsrInterfaceNames[i][0];
2224 TRxTxNetworkInterface * interfaceObject = getTxNetworkInterfaces();
2226 while (interfaceObject != NULL) {
2227 if (strncmp((char *) nonOlsrInterfaceName,
2228 (char *) &interfaceObject->name[0], IFNAMSIZ + 1) == 0) {
2232 interfaceObject = interfaceObject->next;
2235 pudError(false, "Configured transmit non-OLSR interface %s is not"
2236 " a known interface name", nonOlsrInterfaceName);