Patch for WANIPv6FirewallControl:1 service
[igd2-for-linux:igd2-for-linux.git] / linuxigd2 / src / config.c
1 /** 
2  * This file is part of Nokia InternetGatewayDevice v2 reference implementation
3  * Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies).
4  * Contact: mika.saaranen@nokia.com
5  * Developer(s): jaakko.pasanen@tieto.com, opensource@tieto.com
6  *  
7  * This file is part of igd2-for-linux project
8  * Copyright © 2011 France Telecom.
9  * Contact: fabrice.fontaine@orange-ftgroup.com
10  * Developer(s): fabrice.fontaine@orange-ftgroup.com, rmenard.ext@orange-ftgroup.com
11  * 
12  * This program is free software: you can redistribute it and/or modify 
13  * it under the terms of the GNU General Public License as published by 
14  * the Free Software Foundation, either version 2 of the License, or 
15  * (at your option) any later version. 
16  * 
17  * This program is distributed in the hope that it will be useful, 
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
20  * GNU General Public License for more details. 
21  * 
22  * You should have received a copy of the GNU General Public License 
23  * along with this program, see the /doc directory of this program. If 
24  * not, see http://www.gnu.org/licenses/. 
25  * 
26  */
27  
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <regex.h>
32 #include <sys/stat.h>
33 #include "globals.h"
34
35 #define NMATCH 3
36
37 /**
38  * Get value for argument found in config file.
39  *  
40  * @param var Target string for argument value.
41  * @param varlen Max length of argument value.
42  * @param line Line as string from config file where config option locates.
43  * @param submatch Regexp location of found value.
44  * @return 0
45  */
46 int getConfigOptionArgument(char var[],int varlen, char line[], regmatch_t *submatch)
47 {
48     /* limit buffer operations to varlen - 1 */
49     int match_length = min(submatch[1].rm_eo-submatch[1].rm_so, varlen - 1);
50
51     strncpy(var,&line[submatch[1].rm_so],match_length);
52     // Make sure var[] is null terminated
53     var[match_length] = '\0';
54     return 0;
55 }
56
57 /**
58  * Get value for default duration of portmapping found in config file.
59  *  
60  * @param duration Target long int for argument value.
61  * @param line Line as string from config file where config option locates.
62  * @param submatch Regexp location of found value.
63  * @return 0
64  */
65 int getConfigOptionDuration(long int *duration,char line[], regmatch_t *submatch)
66 {
67     long int dur;
68     int absolute_time = submatch[1].rm_eo-submatch[1].rm_so; // >0 if @ was present
69     char num[NUM_LEN];
70     char *p;
71
72     /* limit buffer operations to NUM_LEN - 1 */
73     unsigned int len = min(submatch[2].rm_eo-submatch[2].rm_so, NUM_LEN - 1);
74
75     strncpy(num, &line[submatch[2].rm_so], len);
76     num[len] = '\0';
77     if ((p=index(num,':'))==NULL)
78     {
79         dur = atol(num);
80     }
81     else
82     {
83         *p++ = '\0';
84         dur = atol(num)*3600 + atol(p)*60;
85     }
86
87     if (dur > MAXIMUM_DURATION)
88         dur = MAXIMUM_DURATION;
89
90     if (absolute_time)
91         dur *= -1;
92     *duration = dur;
93     return 0;
94 }
95
96 /**
97  * Parse config file (upnpd.conf) and set default values for global values.
98  *  
99  * @param vars Struct of global default values.
100  * @return -1 if error, else 0.
101  */
102 int parseConfigFile(globals_p vars)
103 {
104     FILE *conf_file;
105     regmatch_t submatch[NMATCH]; // Stores the regex submatch start and end index
106
107     regex_t re_comment;
108     regex_t re_empty_row;
109     regex_t re_iptables_location;
110     regex_t re_debug_mode;
111     regex_t re_create_forward_rules;
112     regex_t re_forward_rules_append;
113     regex_t re_forward_chain_name;
114     regex_t re_prerouting_chain_name;
115     regex_t re_upstream_bitrate;
116     regex_t re_downstream_bitrate;
117     regex_t re_duration;
118     regex_t re_desc_doc;
119     regex_t re_xml_path;
120     regex_t re_listenport;
121     regex_t re_dnsmasq;
122     regex_t re_uci;
123     regex_t re_resolv;
124     regex_t re_event_interval;
125     regex_t re_dhcrelay;
126     regex_t re_dhcrelay_server;
127     regex_t re_dhcpc;
128     regex_t re_network;
129     regex_t re_advertisement_interval;
130
131     regex_t re_ipv6firewall_enabled;
132     regex_t re_ipv6inbound_pinhole_allowed;
133     regex_t re_control_point_authorized;
134     regex_t re_ipv6forward_chain_name;
135     regex_t re_ipv4enabled;
136     regex_t re_ipv6ula_gua_enabled;
137     regex_t re_ipv6link_local_enabled;
138
139     // Make sure all vars are 0 or \0 terminated
140     vars->debug = 0;
141     vars->createForwardRules = 0;
142     vars->forwardRulesAppend = 0;
143     strcpy(vars->iptables,"");
144     strcpy(vars->forwardChainName,"");
145     strcpy(vars->preroutingChainName,"");
146     strcpy(vars->upstreamBitrate,"");
147     strcpy(vars->downstreamBitrate,"");
148     vars->duration = DEFAULT_DURATION;
149     strcpy(vars->descDocName,"");
150     strcpy(vars->xmlPath,"");
151     vars->listenport = 0;
152     strcpy(vars->dnsmasqCmd, "");
153     strcpy(vars->uciCmd, "");
154     strcpy(vars->resolvConf, "");
155     strcpy(vars->dhcrelayCmd, "");
156     strcpy(vars->dhcrelayServer, "");
157     vars->eventUpdateInterval = DEFAULT_EVENT_UPDATE_INTERVAL;
158     strcpy(vars->dhcpc, "");
159     strcpy(vars->networkCmd, "");
160     vars->advertisementInterval = ADVERTISEMENT_INTERVAL;
161
162     vars->ipv6firewallEnabled = TRUE;
163     vars->ipv6inboundPinholeAllowed = TRUE;
164     vars->controlPointAuthorized = TRUE;
165     strcpy(vars->ipv6forwardChain, "");
166     vars->ipv4Enabled = TRUE;
167     vars->ipv6UlaGuaEnabled = TRUE;
168     vars->ipv6LinkLocalEnabled = TRUE;
169
170     // Regexp to match a comment line
171     regcomp(&re_comment,"^[[:blank:]]*#",0);
172     regcomp(&re_empty_row,"^[[:blank:]]*\r?\n$",REG_EXTENDED);
173
174     // Regexps to match configuration file settings
175     regcomp(&re_iptables_location,"iptables_location[[:blank:]]*=[[:blank:]]*\"([^\"]+)\"",REG_EXTENDED);
176     regcomp(&re_debug_mode,"debug_mode[[:blank:]]*=[[:blank:]]*([[:digit:]])",REG_EXTENDED);
177     regcomp(&re_forward_chain_name,"forward_chain_name[[:blank:]]*=[[:blank:]]*([[:alpha:]_-]+)",REG_EXTENDED);
178     regcomp(&re_prerouting_chain_name,"prerouting_chain_name[[:blank:]]*=[[:blank:]]([[:alpha:]_-]+)",REG_EXTENDED);
179     regcomp(&re_create_forward_rules,"create_forward_rules[[:blank:]]*=[[:blank:]]*(yes|no)",REG_EXTENDED);
180     regcomp(&re_forward_rules_append,"forward_rules_append[[:blank:]]*=[[:blank:]]*(yes|no)",REG_EXTENDED);
181     regcomp(&re_upstream_bitrate,"upstream_bitrate[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
182     regcomp(&re_downstream_bitrate,"downstream_bitrate[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
183     regcomp(&re_duration,"duration[[:blank:]]*=[[:blank:]]*(@?)([[:digit:]]+|[[:digit:]]{2,}:[[:digit:]]{2})",REG_EXTENDED);
184     regcomp(&re_desc_doc,"description_document_name[[:blank:]]*=[[:blank:]]*([[:alnum:].]{1,20})",REG_EXTENDED);
185     regcomp(&re_xml_path,"xml_document_path[[:blank:]]*=[[:blank:]]*([[:alpha:]_/.]{1,50})",REG_EXTENDED);
186     regcomp(&re_listenport,"listenport[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
187     regcomp(&re_dnsmasq,"dnsmasq_script[[:blank:]]*=[[:blank:]]*([[:alpha:]_/.]{1,50})",REG_EXTENDED);
188     regcomp(&re_uci,"uci_command[[:blank:]]*=[[:blank:]]*([[:alpha:]_/.]{1,50})",REG_EXTENDED);
189     regcomp(&re_dhcrelay,"dhcrelay_script[[:blank:]]*=[[:blank:]]*([[:alpha:]_/.]{1,50})",REG_EXTENDED);
190     regcomp(&re_resolv,"resolf_conf[[:blank:]]*=[[:blank:]]*([[:alpha:]_/.]{1,50})",REG_EXTENDED);
191     regcomp(&re_event_interval,"event_update_interval[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
192     regcomp(&re_dhcrelay_server,"dhcrelay_server[[:blank:]]*=[[:blank:]]*([[:digit:].:]+)",REG_EXTENDED);
193     regcomp(&re_dhcpc,"dhcpc_cmd[[:blank:]]*=[[:blank:]]*([[:alpha:]_/.]{1,50})",REG_EXTENDED);
194     regcomp(&re_network,"network_script[[:blank:]]*=[[:blank:]]*([[:alpha:]_/.]{1,50})",REG_EXTENDED);
195     regcomp(&re_advertisement_interval,"advertisement_interval[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
196
197     regcomp(&re_ipv6firewall_enabled,"ipv6firewall_enabled[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
198     regcomp(&re_ipv6inbound_pinhole_allowed,"ipv6inbound_pinhole_allowed[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
199     regcomp(&re_control_point_authorized,"control_point_authorized[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
200     regcomp(&re_ipv6forward_chain_name,"ipv6forward_chain_name[[:blank:]]*=[[:blank:]]*([[:alpha:]_-]+)",REG_EXTENDED);
201     regcomp(&re_ipv4enabled,"ipv4_enabled[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
202     regcomp(&re_ipv6ula_gua_enabled,"ipv6_ula_gua_enabled[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
203     regcomp(&re_ipv6link_local_enabled,"ipv6_linklocal_enabled[[:blank:]]*=[[:blank:]]*([[:digit:]]+)",REG_EXTENDED);
204
205     if ((conf_file=fopen(CONF_FILE,"r")) != NULL)
206     {
207         char line[MAX_CONFIG_LINE];
208         // Walk through the config file line by line
209         while (fgets(line,MAX_CONFIG_LINE,conf_file) != NULL)
210         {
211             // Check if a comment line or an empty one
212             if ( (0 != regexec(&re_comment,line,0,NULL,0)  )  &&
213                     (0 != regexec(&re_empty_row,line,0,NULL,0))  )
214             {
215                 // Chec if iptables_location
216                 if (regexec(&re_iptables_location,line,NMATCH,submatch,0) == 0)
217                 {
218                     getConfigOptionArgument(vars->iptables, OPTION_LEN, line, submatch);
219                 }
220                 // Check if create_forward_rules
221                 else if (regexec(&re_create_forward_rules,line,NMATCH,submatch,0) == 0)
222                 {
223                     char tmp[4];
224                     getConfigOptionArgument(tmp,sizeof(tmp),line,submatch);
225                     vars->createForwardRules = strcmp(tmp,"yes")==0 ? 1 : 0;
226                 }
227                 // Check if forward_rules_append
228                 else if (regexec(&re_forward_rules_append,line,NMATCH,submatch,0) == 0)
229                 {
230                     char tmp[4];
231                     getConfigOptionArgument(tmp,sizeof(tmp),line,submatch);
232                     vars->forwardRulesAppend = strcmp(tmp,"yes")==0 ? 1 : 0;
233                 }
234                 else if (regexec(&re_debug_mode,line,NMATCH,submatch,0) == 0)
235                 {
236                     char tmp[2];
237                     getConfigOptionArgument(tmp,sizeof(tmp),line,submatch);
238                     vars->debug = atoi(tmp);
239                 }
240                 else if (regexec(&re_prerouting_chain_name,line,NMATCH,submatch,0) == 0)
241                 {
242                     getConfigOptionArgument(vars->preroutingChainName, OPTION_LEN, line, submatch);
243                 }
244                 else if (regexec(&re_upstream_bitrate,line,NMATCH,submatch,0) == 0)
245                 {
246                     getConfigOptionArgument(vars->upstreamBitrate, OPTION_LEN, line, submatch);
247                 }
248                 else if (regexec(&re_downstream_bitrate,line,NMATCH,submatch,0) == 0)
249                 {
250                     getConfigOptionArgument(vars->downstreamBitrate, OPTION_LEN, line, submatch);
251                 }
252                 else if (regexec(&re_duration,line,NMATCH,submatch,0) == 0)
253                 {
254                     getConfigOptionDuration(&vars->duration,line,submatch);
255                 }
256                 else if (regexec(&re_desc_doc,line,NMATCH,submatch,0) == 0)
257                 {
258                     getConfigOptionArgument(vars->descDocName, OPTION_LEN, line, submatch);
259                 }
260                 else if (regexec(&re_xml_path,line,NMATCH,submatch,0) == 0)
261                 {
262                     getConfigOptionArgument(vars->xmlPath, OPTION_LEN, line, submatch);
263                 }
264                 else if (regexec(&re_listenport,line,NMATCH,submatch,0) == 0)
265                 {
266                     char tmp[6];
267                     getConfigOptionArgument(tmp,sizeof(tmp),line,submatch);
268                     vars->listenport = atoi(tmp);
269                 }
270                 else if (regexec(&re_dnsmasq,line,NMATCH,submatch,0) == 0)
271                 {
272                     getConfigOptionArgument(vars->dnsmasqCmd, OPTION_LEN, line, submatch);
273                 }
274                 else if (regexec(&re_uci,line,NMATCH,submatch,0) == 0)
275                 {
276                     getConfigOptionArgument(vars->uciCmd, OPTION_LEN, line, submatch);
277                 }
278                 else if (regexec(&re_dhcrelay,line,NMATCH,submatch,0) == 0)
279                 {
280                     getConfigOptionArgument(vars->dhcrelayCmd, OPTION_LEN, line, submatch);
281                 }
282                 else if (regexec(&re_resolv,line,NMATCH,submatch,0) == 0)
283                 {
284                     getConfigOptionArgument(vars->resolvConf, OPTION_LEN, line, submatch);
285                 }
286                 else if (regexec(&re_dhcrelay_server,line,NMATCH,submatch,0) == 0)
287                 {
288                     getConfigOptionArgument(vars->dhcrelayServer, OPTION_LEN, line, submatch);
289                 }
290                 else if (regexec(&re_event_interval,line,NMATCH,submatch,0) == 0)
291                 {
292                     char tmp[6];
293                     getConfigOptionArgument(tmp, OPTION_LEN, line, submatch);
294                     vars->eventUpdateInterval = atoi(tmp);
295                 }
296                 else if (regexec(&re_dhcpc,line,NMATCH,submatch,0) == 0)
297                 {
298                     getConfigOptionArgument(vars->dhcpc, OPTION_LEN, line, submatch);
299                 }
300                 else if (regexec(&re_network,line,NMATCH,submatch,0) == 0)
301                 {
302                     getConfigOptionArgument(vars->networkCmd, OPTION_LEN, line, submatch);
303                 }
304                 else if (regexec(&re_advertisement_interval,line,NMATCH,submatch,0) == 0)
305                 {
306                     char tmp[6];
307                     getConfigOptionArgument(tmp, OPTION_LEN, line, submatch);
308                     vars->advertisementInterval = atoi(tmp);
309                 }
310                 else if (regexec(&re_ipv6firewall_enabled,line,NMATCH,submatch,0) == 0)
311                 {
312                     char tmp[2];
313                     getConfigOptionArgument(tmp, OPTION_LEN, line, submatch);
314                     vars->ipv6firewallEnabled = atoi(tmp);
315                 }
316                 else if (regexec(&re_ipv6inbound_pinhole_allowed,line,NMATCH,submatch,0) == 0)
317                 {
318                     char tmp[2];
319                     getConfigOptionArgument(tmp, OPTION_LEN, line, submatch);
320                     vars->ipv6inboundPinholeAllowed = atoi(tmp);
321                 }
322                 else if (regexec(&re_control_point_authorized,line,NMATCH,submatch,0) == 0)
323                 {
324                     char tmp[2];
325                     getConfigOptionArgument(tmp, OPTION_LEN, line, submatch);
326                     vars->controlPointAuthorized = atoi(tmp);
327                 }
328                 else if (regexec(&re_ipv4enabled,line,NMATCH,submatch,0) == 0)
329                 {
330                     char tmp[2];
331                     getConfigOptionArgument(tmp, OPTION_LEN, line, submatch);
332                     vars->ipv4Enabled = atoi(tmp);
333                 }
334                 else if (regexec(&re_ipv6ula_gua_enabled,line,NMATCH,submatch,0) == 0)
335                 {
336                     char tmp[2];
337                     getConfigOptionArgument(tmp, OPTION_LEN, line, submatch);
338                     vars->ipv6UlaGuaEnabled = atoi(tmp);
339                 }
340                 else if (regexec(&re_ipv6link_local_enabled,line,NMATCH,submatch,0) == 0)
341                 {
342                     char tmp[2];
343                     getConfigOptionArgument(tmp, OPTION_LEN, line, submatch);
344                     vars->ipv6LinkLocalEnabled = atoi(tmp);
345                 }
346                 else if (regexec(&re_ipv6forward_chain_name,line,NMATCH,submatch,0) == 0)
347                 {
348                     getConfigOptionArgument(vars->ipv6forwardChain, OPTION_LEN, line, submatch);
349                 }
350                 // Check forward_chain_name
351                 else if (regexec(&re_forward_chain_name,line,NMATCH,submatch,0) == 0)
352                 {
353                     getConfigOptionArgument(vars->forwardChainName, OPTION_LEN, line, submatch);
354                 }
355                 else
356                 {
357                     // We end up here if ther is an unknown config directive
358                     printf("Unknown config line: %s",line);
359                 }
360             }
361         }
362         fclose(conf_file);
363     }
364     regfree(&re_comment);
365     regfree(&re_empty_row);
366     regfree(&re_iptables_location);
367     regfree(&re_debug_mode);
368     regfree(&re_create_forward_rules);
369     regfree(&re_forward_rules_append);
370     regfree(&re_forward_chain_name);
371     regfree(&re_prerouting_chain_name);
372     regfree(&re_upstream_bitrate);
373     regfree(&re_downstream_bitrate);
374     regfree(&re_duration);
375     regfree(&re_desc_doc);
376     regfree(&re_xml_path);
377     regfree(&re_listenport);
378     regfree(&re_dnsmasq);
379     regfree(&re_uci);
380     regfree(&re_dhcrelay);
381     regfree(&re_dhcrelay_server);
382     regfree(&re_resolv);
383     regfree(&re_event_interval);
384     regfree(&re_dhcpc);
385     regfree(&re_network);
386     regfree(&re_advertisement_interval);
387
388     regfree(&re_ipv6firewall_enabled);
389     regfree(&re_ipv6inbound_pinhole_allowed);
390     regfree(&re_control_point_authorized);
391     regfree(&re_ipv6forward_chain_name);
392     regfree(&re_ipv4enabled);
393     regfree(&re_ipv6ula_gua_enabled);
394     regfree(&re_ipv6link_local_enabled);
395
396     // Set default values for options not found in config file
397     if (strnlen(vars->forwardChainName, OPTION_LEN) == 0)
398     {
399         // No forward chain name was set in conf file, set it to default
400         snprintf(vars->forwardChainName, OPTION_LEN, IPTABLES_DEFAULT_FORWARD_CHAIN);
401     }
402     if (strnlen(vars->preroutingChainName, OPTION_LEN) == 0)
403     {
404         // No prerouting chain name was set in conf file, set it to default
405         snprintf(vars->preroutingChainName, OPTION_LEN, IPTABLES_DEFAULT_PREROUTING_CHAIN);
406     }
407     if (strnlen(vars->upstreamBitrate, OPTION_LEN) == 0)
408     {
409         // No upstream_bitrate was found in the conf file, set it to default
410         snprintf(vars->upstreamBitrate, OPTION_LEN, DEFAULT_UPSTREAM_BITRATE);
411     }
412     if (strnlen(vars->downstreamBitrate, OPTION_LEN) == 0)
413     {
414         // No downstream bitrate was found in the conf file, set it to default
415         snprintf(vars->downstreamBitrate, OPTION_LEN, DEFAULT_DOWNSTREAM_BITRATE);
416     }
417     if (strnlen(vars->descDocName, OPTION_LEN) == 0)
418     {
419         snprintf(vars->descDocName, OPTION_LEN, DESC_DOC_DEFAULT);
420     }
421     if (strnlen(vars->xmlPath, OPTION_LEN) == 0)
422     {
423         snprintf(vars->xmlPath, OPTION_LEN, XML_PATH_DEFAULT);
424     }
425     if (strnlen(vars->dnsmasqCmd, OPTION_LEN) == 0)
426     {
427         snprintf(vars->dnsmasqCmd, OPTION_LEN, DNSMASQ_CMD_DEFAULT);
428     }
429     if (strnlen(vars->dhcrelayCmd, OPTION_LEN) == 0)
430     {
431         snprintf(vars->dhcrelayCmd, OPTION_LEN, DHCRELAY_CMD_DEFAULT);
432     }
433     if (strnlen(vars->uciCmd, OPTION_LEN) == 0)
434     {
435         snprintf(vars->uciCmd, OPTION_LEN, UCI_CMD_DEFAULT);
436     }
437     if (strnlen(vars->resolvConf, OPTION_LEN) == 0)
438     {
439         snprintf(vars->resolvConf, OPTION_LEN, RESOLV_CONF_DEFAULT);
440     }
441     if (strnlen(vars->dhcpc, OPTION_LEN) == 0)
442     {
443         snprintf(vars->dhcpc, OPTION_LEN, DHCPC_DEFAULT);
444     }
445     if (strnlen(vars->networkCmd, OPTION_LEN) == 0)
446     {
447         snprintf(vars->networkCmd, OPTION_LEN, NETWORK_CMD_DEFAULT);
448     }
449     if (vars->advertisementInterval < 300) // smaller would mess everything
450     {
451         vars->advertisementInterval = 300;
452     }
453     if (vars->ipv6firewallEnabled < 0 || vars->ipv6firewallEnabled > 1 )
454     {
455         vars->ipv6firewallEnabled = TRUE;
456     }
457     if (vars->ipv6inboundPinholeAllowed < 0 || vars->ipv6inboundPinholeAllowed > 1 )
458     {
459         vars->ipv6inboundPinholeAllowed = TRUE;
460     }
461     if (vars->controlPointAuthorized < 0 || vars->controlPointAuthorized > 1)
462     {
463         vars->controlPointAuthorized = 1;
464     }
465     if (vars->ipv4Enabled < 0 || vars->ipv4Enabled > 1)
466     {
467         vars->ipv4Enabled = 1;
468     }
469     if (vars->ipv6UlaGuaEnabled < 0 || vars->ipv6UlaGuaEnabled > 1)
470     {
471         vars->ipv6UlaGuaEnabled = 1;
472     }
473     if (vars->ipv6LinkLocalEnabled < 0 || vars->ipv6LinkLocalEnabled > 1)
474     {
475         vars->ipv6LinkLocalEnabled = 1;
476     }
477     if (strnlen(vars->ipv6forwardChain, OPTION_LEN) == 0)
478     {
479         // No forward chain name was set in conf file, set it to default
480         snprintf(vars->ipv6forwardChain, OPTION_LEN, IP6TABLES_DEFAULT_FORWARD_CHAIN);
481     }
482     if (strnlen(vars->iptables, OPTION_LEN) == 0)
483     {
484         // Can't find the iptables executable, return -1 to
485         // indicate en error
486         return -1;
487     }
488     else
489     {
490         return 0;
491     }
492 }