3 * The olsr.org Optimized Link-State Routing daemon(olsrd)
4 * Copyright (c) 2007, Bernd Petrovitsch <bernd@firmix.at>
5 * Copyright (c) 2007, Sven-Ola <sven-ola@gmx.de>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * * Neither the name of olsr.org, olsrd nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 * Visit http://www.olsr.org for more information.
37 * If you find this software useful feel free to make a donation
38 * to the project. For more information see the website or contact
39 * the copyright holders.
43 #include "plugin_util.h"
47 #include <arpa/inet.h>
50 set_plugin_port(const char *value, void *data, set_plugin_parameter_addon addon __attribute__ ((unused)))
53 const unsigned int port = strtoul(value, &endptr, 0);
54 if (*endptr != '\0' || endptr == value) {
55 OLSR_PRINTF(0, "Illegal port number \"%s\"", value);
59 OLSR_PRINTF(0, "Port number %u out of range", port);
65 OLSR_PRINTF(1, "%s port number %u\n", "Got", port);
67 OLSR_PRINTF(0, "%s port number %u\n", "Ignored", port);
73 set_plugin_ipaddress(const char *value, void *data, set_plugin_parameter_addon addon __attribute__ ((unused)))
75 char buf[INET6_ADDRSTRLEN];
76 union olsr_ip_addr ip_addr;
77 if (inet_pton(olsr_cnf->ip_version, value, &ip_addr) <= 0) {
78 OLSR_PRINTF(0, "Illegal IP address \"%s\"", value);
81 inet_ntop(olsr_cnf->ip_version, &ip_addr, buf, sizeof(buf));
83 union olsr_ip_addr *v = data;
85 OLSR_PRINTF(1, "%s IP address %s\n", "Got", buf);
87 OLSR_PRINTF(0, "%s IP address %s\n", "Ignored", buf);
93 * CAREFUL: this functions sets a boolean in an integer!!!
96 set_plugin_boolean(const char *value, void *data, set_plugin_parameter_addon addon __attribute__ ((unused)))
99 if (strcasecmp(value, "yes") == 0 || strcasecmp(value, "true") == 0) {
101 } else if (strcasecmp(value, "no") == 0 || strcasecmp(value, "false") == 0) {
110 set_plugin_int(const char *value, void *data, set_plugin_parameter_addon addon __attribute__ ((unused)))
113 const int theint = strtol(value, &endptr, 0);
114 if (*endptr != '\0' || endptr == value) {
115 OLSR_PRINTF(0, "Illegal int \"%s\"", value);
121 OLSR_PRINTF(1, "%s int %d\n", "Got", theint);
123 OLSR_PRINTF(0, "%s int %d\n", "Ignored", theint);
129 set_plugin_string(const char *value, void *data, set_plugin_parameter_addon addon)
133 if ((unsigned)strlen(value) >= addon.ui) {
134 OLSR_PRINTF(0, "String too long \"%s\"", value);
137 strscpy(v, value, addon.ui);
138 OLSR_PRINTF(1, "%s string %s\n", "Got", value);
140 OLSR_PRINTF(0, "%s string %s\n", "Ignored", value);
150 * indent-tabs-mode: nil