1 #define MODULE_LOG_PREFIX "config"
4 #include "module-dvbapi.h"
5 #include "module-gbox.h"
6 #include "oscam-array.h"
7 #include "oscam-conf.h"
8 #include "oscam-conf-chk.h"
9 #include "oscam-conf-mk.h"
10 #include "oscam-config.h"
11 #include "oscam-net.h"
12 #include "oscam-string.h"
14 #define cs_conf "oscam.conf"
16 #define DEFAULT_HTTP_PORT 8888
17 #define DEFAULT_HTTP_ALLOW "127.0.0.1,192.168.0.0-192.168.255.255,10.0.0.0-10.255.255.255,::1"
19 static void disablelog_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
23 cs_disable_log(strToIntVal(value
, 0));
26 if(cfg
.disablelog
|| cfg
.http_full_cfg
)
27 { fprintf_conf(f
, token
, "%d\n", cfg
.disablelog
); }
30 #if defined(WEBIF) || defined(MODULE_MONITOR)
31 static void loghistorylines_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
35 uint32_t newsize
= strToUIntVal(value
, 256);
36 if(newsize
< 64 && newsize
!= 0)
38 fprintf(stderr
, "WARNING: loghistorylines is too small, adjusted to 64\n");
41 cs_reinit_loghist(newsize
);
44 if(cfg
.loghistorylines
!= 256 || cfg
.http_full_cfg
)
45 { fprintf_conf(f
, token
, "%u\n", cfg
.loghistorylines
); }
49 static void serverip_fn(const char *token
, char *value
, void *setting
, FILE *f
)
51 IN_ADDR_T srvip
= *(IN_ADDR_T
*)setting
;
54 if(strlen(value
) == 0)
56 set_null_ip((IN_ADDR_T
*)setting
);
60 cs_inet_addr(value
, (IN_ADDR_T
*)setting
);
64 if(IP_ISSET(srvip
) || cfg
.http_full_cfg
)
65 { fprintf_conf(f
, token
, "%s\n", cs_inet_ntoa(srvip
)); }
68 void iprange_fn(const char *token
, char *value
, void *setting
, FILE *f
)
70 struct s_ip
**ip
= setting
;
73 if(strlen(value
) == 0)
79 chk_iprange(value
, ip
);
83 value
= mk_t_iprange(*ip
);
84 if(strlen(value
) > 0 || cfg
.http_full_cfg
)
85 { fprintf_conf(f
, token
, "%s\n", value
); }
89 void iprange_free_fn(void *setting
)
94 static void logfile_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
98 char *saveptr1
= NULL
;
101 NULLFREE(cfg
.logfile
);
102 if(strlen(value
) > 0)
105 for(pch
= strtok_r(value
, ";", &saveptr1
); pch
!= NULL
; pch
= strtok_r(NULL
, ";", &saveptr1
))
108 if(!strcmp(pch
, "stdout")) { cfg
.logtostdout
= 1; }
109 else if(!strcmp(pch
, "syslog")) { cfg
.logtosyslog
= 1; }
112 NULLFREE(cfg
.logfile
);
113 if(!(cfg
.logfile
= cs_strdup(pch
)))
120 if(!(cfg
.logfile
= cs_strdup(CS_LOGFILE
)))
121 { cfg
.logtostdout
= 1; }
125 if(cfg
.logfile
|| cfg
.logtostdout
== 1 || cfg
.logtosyslog
== 1 || cfg
.http_full_cfg
)
127 value
= mk_t_logfile();
128 fprintf_conf(f
, token
, "%s\n", value
);
133 void check_caidtab_fn(const char *token
, char *value
, void *setting
, FILE *f
)
135 CAIDTAB
*caid_table
= setting
;
139 chk_caidtab(value
, caid_table
);
141 caidtab_clear(caid_table
);
145 if(caid_table
->ctnum
|| cfg
.http_full_cfg
)
147 value
= mk_t_caidtab(caid_table
);
148 fprintf_conf(f
, token
, "%s\n", value
);
153 void chk_ftab_fn(const char *token
, char *value
, void *setting
, FILE *f
)
155 FTAB
*ftab
= setting
;
159 chk_ftab(value
, ftab
);
164 value
= mk_t_ftab(ftab
);
165 if(strlen(value
) > 0 || cfg
.http_full_cfg
)
166 { fprintf_conf(f
, token
, "%s\n", value
); }
171 void caidvaluetab_fn(const char *token
, char *value
, void *setting
, FILE *f
)
173 CAIDVALUETAB
*caid_value_table
= setting
;
177 chk_caidvaluetab(value
, caid_value_table
);
178 if (streq(token
, "lb_retrylimits"))
181 for (i
= 0; i
< caid_value_table
->cvnum
; i
++)
183 if (caid_value_table
->cvdata
[i
].value
< 50)
184 caid_value_table
->cvdata
[i
].value
= 50;
188 caidvaluetab_clear(caid_value_table
);
192 if(caid_value_table
->cvnum
|| cfg
.http_full_cfg
)
194 value
= mk_t_caidvaluetab(caid_value_table
);
195 fprintf_conf(f
, token
, "%s\n", value
);
201 void cacheex_valuetab_fn(const char *token
, char *value
, void *setting
, FILE *f
)
203 CECSPVALUETAB
*cacheex_value_table
= setting
;
206 if(strlen(value
) == 0)
207 { clear_cacheextab(cacheex_value_table
); }
209 { chk_cacheex_valuetab(value
, cacheex_value_table
); }
212 if(cacheex_value_table
->cevnum
|| cfg
.http_full_cfg
)
214 value
= mk_t_cacheex_valuetab(cacheex_value_table
);
215 fprintf_conf(f
, token
, "%s\n", value
);
220 void cacheex_cwcheck_tab_fn(const char *token
, char *value
, void *setting
, FILE *f
)
222 CWCHECKTAB
*cacheex_value_table
= setting
;
225 if(strlen(value
) == 0)
227 cacheex_value_table
->cwchecknum
= 0;
228 NULLFREE(cacheex_value_table
->cwcheckdata
);
232 chk_cacheex_cwcheck_valuetab(value
, cacheex_value_table
);
237 if(cacheex_value_table
->cwchecknum
|| cfg
.http_full_cfg
)
239 value
= mk_t_cacheex_cwcheck_valuetab(cacheex_value_table
);
240 fprintf_conf(f
, token
, "%s\n", value
);
245 void cacheex_hitvaluetab_fn(const char *token
, char *value
, void *setting
, FILE *f
)
247 CECSPVALUETAB
*cacheex_value_table
= setting
;
250 if(strlen(value
) == 0)
251 { clear_cacheextab(cacheex_value_table
); }
253 { chk_cacheex_hitvaluetab(value
, cacheex_value_table
); }
256 if(cacheex_value_table
->cevnum
|| cfg
.http_full_cfg
)
258 value
= mk_t_cacheex_hitvaluetab(cacheex_value_table
);
259 fprintf_conf(f
, token
, "%s\n", value
);
268 #include <sys/resource.h> // for setpriority
271 void global_fixups_fn(void *UNUSED(var
))
273 if(!cfg
.usrfile
) { cfg
.disableuserfile
= 1; }
274 if(!cfg
.mailfile
) { cfg
.disablemail
= 1; }
275 if(cfg
.ctimeout
< 10) { cfg
.ctimeout
= cfg
.ctimeout
* 1000; } // save always in ms
277 if(cfg
.nice
< -20 || cfg
.nice
> 20) { cfg
.nice
= 99; }
281 setpriority(PRIO_PROCESS
, 0, cfg
.nice
);
285 switch((cfg
.nice
+ 20) / 10)
288 wprio
= REALTIME_PRIORITY_CLASS
;
291 wprio
= HIGH_PRIORITY_CLASS
;
294 wprio
= NORMAL_PRIORITY_CLASS
;
297 wprio
= IDLE_PRIORITY_CLASS
;
300 WinId
= GetCurrentProcess();
301 SetPriorityClass(WinId
, wprio
);
304 if(cfg
.netprio
<= 0 || cfg
.netprio
> 20) { cfg
.netprio
= 0; }
305 if(cfg
.max_log_size
!= 0 && cfg
.max_log_size
<= 10) { cfg
.max_log_size
= 10; }
307 if(cfg
.lb_save
> 0 && cfg
.lb_save
< 100) { cfg
.lb_save
= 100; }
308 if(cfg
.lb_nbest_readers
< 2) { cfg
.lb_nbest_readers
= DEFAULT_NBEST
; }
312 #define OFS(X) offsetof(struct s_config, X)
313 #define SIZEOF(X) sizeof(((struct s_config *)0)->X)
315 static const struct config_list global_opts
[] =
317 DEF_OPT_FIXUP_FUNC(global_fixups_fn
),
319 DEF_OPT_INT8("enableled" , OFS(enableled
) , 0),
321 DEF_OPT_FUNC("disablelog" , OFS(disablelog
) , disablelog_fn
),
322 #if defined(WEBIF) || defined(MODULE_MONITOR)
323 DEF_OPT_FUNC("loghistorylines" , OFS(loghistorylines
) , loghistorylines_fn
),
325 DEF_OPT_FUNC("serverip" , OFS(srvip
) , serverip_fn
),
326 DEF_OPT_FUNC("logfile" , OFS(logfile
) , logfile_fn
),
327 DEF_OPT_INT32("initial_debuglevel" , OFS(initial_debuglevel
) , 0),
328 DEF_OPT_STR("sysloghost" , OFS(sysloghost
) , NULL
),
329 DEF_OPT_INT32("syslogport" , OFS(syslogport
) , 514),
330 DEF_OPT_INT8("logduplicatelines" , OFS(logduplicatelines
) , 0),
331 DEF_OPT_STR("pidfile" , OFS(pidfile
) , NULL
),
332 DEF_OPT_INT8("disableuserfile" , OFS(disableuserfile
) , 1),
333 DEF_OPT_INT8("disablemail" , OFS(disablemail
) , 1),
334 DEF_OPT_INT8("usrfileflag" , OFS(usrfileflag
) , 0),
335 DEF_OPT_UINT32("clienttimeout" , OFS(ctimeout
) , CS_CLIENT_TIMEOUT
),
336 DEF_OPT_UINT32("fallbacktimeout" , OFS(ftimeout
) , CS_CLIENT_TIMEOUT
/ 2),
337 DEF_OPT_FUNC("fallbacktimeout_percaid" , OFS(ftimeouttab
) , caidvaluetab_fn
),
338 DEF_OPT_UINT32("clientmaxidle" , OFS(cmaxidle
) , CS_CLIENT_MAXIDLE
),
339 DEF_OPT_INT32("bindwait" , OFS(bindwait
) , CS_BIND_TIMEOUT
),
340 DEF_OPT_UINT32("netprio" , OFS(netprio
) , 0),
341 DEF_OPT_INT32("sleep" , OFS(tosleep
) , 0),
342 DEF_OPT_INT32("unlockparental" , OFS(ulparent
) , 0),
343 DEF_OPT_INT32("nice" , OFS(nice
) , 99),
344 DEF_OPT_INT32("maxlogsize" , OFS(max_log_size
) , 10),
345 DEF_OPT_INT8("waitforcards" , OFS(waitforcards
) , 1),
346 DEF_OPT_INT32("waitforcards_extra_delay" , OFS(waitforcards_extra_delay
) , 500),
347 DEF_OPT_INT8("preferlocalcards" , OFS(preferlocalcards
) , 0),
348 DEF_OPT_INT32("readerrestartseconds" , OFS(reader_restart_seconds
) , 5),
349 DEF_OPT_INT8("dropdups" , OFS(dropdups
) , 0),
350 DEF_OPT_INT8("reload_useraccounts" , OFS(reload_useraccounts
) , 0),
351 DEF_OPT_INT8("reload_readers" , OFS(reload_readers
) , 0),
352 DEF_OPT_INT8("reload_provid" , OFS(reload_provid
) , 0),
353 DEF_OPT_INT8("reload_services_ids" , OFS(reload_services_ids
) , 0),
354 DEF_OPT_INT8("reload_tier_ids" , OFS(reload_tier_ids
) , 0),
355 DEF_OPT_INT8("reload_fakecws" , OFS(reload_fakecws
) , 0),
356 DEF_OPT_INT8("reload_ac_stat" , OFS(reload_ac_stat
) , 0),
357 DEF_OPT_INT8("reload_log" , OFS(reload_log
) , 0),
358 DEF_OPT_INT8("block_same_ip" , OFS(block_same_ip
) , 1),
359 DEF_OPT_INT8("block_same_name" , OFS(block_same_name
) , 1),
360 DEF_OPT_STR("usrfile" , OFS(usrfile
) , NULL
),
361 DEF_OPT_STR("mailfile" , OFS(mailfile
) , NULL
),
362 DEF_OPT_STR("cwlogdir" , OFS(cwlogdir
) , NULL
),
363 DEF_OPT_STR("emmlogdir" , OFS(emmlogdir
) , NULL
),
365 DEF_OPT_INT32("lb_mode" , OFS(lb_mode
) , DEFAULT_LB_MODE
),
366 DEF_OPT_INT32("lb_save" , OFS(lb_save
) , 0),
367 DEF_OPT_INT32("lb_nbest_readers" , OFS(lb_nbest_readers
) , DEFAULT_NBEST
),
368 DEF_OPT_INT32("lb_nfb_readers" , OFS(lb_nfb_readers
) , DEFAULT_NFB
),
369 DEF_OPT_INT32("lb_min_ecmcount" , OFS(lb_min_ecmcount
) , DEFAULT_MIN_ECM_COUNT
),
370 DEF_OPT_INT32("lb_max_ecmcount" , OFS(lb_max_ecmcount
) , DEFAULT_MAX_ECM_COUNT
),
371 DEF_OPT_INT32("lb_reopen_seconds" , OFS(lb_reopen_seconds
) , DEFAULT_REOPEN_SECONDS
),
372 DEF_OPT_INT8("lb_reopen_invalid" , OFS(lb_reopen_invalid
) , 1),
373 DEF_OPT_INT8("lb_force_reopen_always" , OFS(lb_force_reopen_always
) , 0),
374 DEF_OPT_INT32("lb_retrylimit" , OFS(lb_retrylimit
) , DEFAULT_RETRYLIMIT
),
375 DEF_OPT_INT32("lb_stat_cleanup" , OFS(lb_stat_cleanup
) , DEFAULT_LB_STAT_CLEANUP
),
376 DEF_OPT_INT32("lb_max_readers" , OFS(lb_max_readers
) , 0),
377 DEF_OPT_INT32("lb_auto_betatunnel" , OFS(lb_auto_betatunnel
) , DEFAULT_LB_AUTO_BETATUNNEL
),
378 DEF_OPT_INT32("lb_auto_betatunnel_mode" , OFS(lb_auto_betatunnel_mode
) , DEFAULT_LB_AUTO_BETATUNNEL_MODE
),
379 DEF_OPT_INT32("lb_auto_betatunnel_prefer_beta" , OFS(lb_auto_betatunnel_prefer_beta
), DEFAULT_LB_AUTO_BETATUNNEL_PREFER_BETA
),
380 DEF_OPT_STR("lb_savepath" , OFS(lb_savepath
) , NULL
),
381 DEF_OPT_FUNC("lb_retrylimits" , OFS(lb_retrylimittab
) , caidvaluetab_fn
),
382 DEF_OPT_FUNC("lb_nbest_percaid" , OFS(lb_nbest_readers_tab
) , caidvaluetab_fn
),
383 DEF_OPT_FUNC("lb_noproviderforcaid" , OFS(lb_noproviderforcaid
) , check_caidtab_fn
),
384 DEF_OPT_INT32("lb_auto_timeout" , OFS(lb_auto_timeout
) , DEFAULT_LB_AUTO_TIMEOUT
),
385 DEF_OPT_INT32("lb_auto_timeout_p" , OFS(lb_auto_timeout_p
) , DEFAULT_LB_AUTO_TIMEOUT_P
),
386 DEF_OPT_INT32("lb_auto_timeout_t" , OFS(lb_auto_timeout_t
) , DEFAULT_LB_AUTO_TIMEOUT_T
),
388 DEF_OPT_FUNC("double_check_caid" , OFS(double_check_caid
) , check_caidtab_fn
),
389 DEF_OPT_STR("ecmfmt" , OFS(ecmfmt
) , NULL
),
390 DEF_OPT_INT32("resolvegethostbyname" , OFS(resolve_gethostbyname
) , 0),
391 DEF_OPT_INT32("failbantime" , OFS(failbantime
) , 0),
392 DEF_OPT_INT32("failbancount" , OFS(failbancount
) , 0),
393 DEF_OPT_INT8("suppresscmd08" , OFS(c35_suppresscmd08
) , 0),
394 DEF_OPT_INT8("getblockemmauprovid" , OFS(getblockemmauprovid
) , 0),
395 DEF_OPT_INT8("double_check" , OFS(double_check
) , 0),
396 DEF_OPT_INT8("disablecrccws" , OFS(disablecrccws
) , 0),
397 DEF_OPT_FUNC("disablecrccws_only_for" , OFS(disablecrccws_only_for
) , chk_ftab_fn
),
402 static void anticasc_fixups_fn(void *UNUSED(var
))
404 if(cfg
.ac_users
< 0) { cfg
.ac_users
= 0; }
405 if(cfg
.ac_stime
< 0) { cfg
.ac_stime
= 2; }
406 if(cfg
.ac_samples
< 2 || cfg
.ac_samples
> 10) { cfg
.ac_samples
= 10; }
407 if(cfg
.ac_penalty
< 0 || cfg
.ac_penalty
> 3) { cfg
.ac_penalty
= 0; }
408 if(cfg
.ac_fakedelay
< 100 || cfg
.ac_fakedelay
> 3000) { cfg
.ac_fakedelay
= 1000; }
409 if(cfg
.ac_denysamples
< 2 || cfg
.ac_denysamples
> cfg
.ac_samples
- 1) { cfg
.ac_denysamples
= cfg
.ac_samples
- 1; }
410 if(cfg
.ac_denysamples
+ 1 > cfg
.ac_samples
) { cfg
.ac_denysamples
= cfg
.ac_samples
- 1; }
411 if(cfg
.acosc_max_ecms_per_minute
< 0) { cfg
.acosc_max_ecms_per_minute
= 0; }
412 if(cfg
.acosc_penalty
== 4)
414 cfg
.acosc_max_active_sids
= 0; // set default
415 cfg
.acosc_zap_limit
= 0; // set default
416 //cfg.acosc_penalty_duration = 0; // set default
418 if(cfg
.acosc_max_ecms_per_minute
!= 0)
420 if(cfg
.acosc_max_ecms_per_minute
< 6) { cfg
.acosc_max_ecms_per_minute
= 6; }
421 if(cfg
.acosc_max_ecms_per_minute
> 20) { cfg
.acosc_max_ecms_per_minute
= 20; }
422 cfg
.acosc_penalty_duration
= (60 / cfg
.acosc_max_ecms_per_minute
);
425 if(cfg
.acosc_max_active_sids
< 0) { cfg
.acosc_max_active_sids
= 0; }
426 if(cfg
.acosc_zap_limit
< 0) { cfg
.acosc_zap_limit
= 0; }
427 if(cfg
.acosc_penalty
< 0 || cfg
.acosc_penalty
> 4) { cfg
.acosc_penalty
= 0; }
428 if(cfg
.acosc_penalty_duration
< 0) { cfg
.acosc_penalty_duration
= 0; }
429 if(cfg
.acosc_delay
< 0 || cfg
.acosc_delay
> 4000) { cfg
.acosc_delay
= 0; }
432 static bool anticasc_should_save_fn(void *UNUSED(var
))
434 return cfg
.ac_enabled
|| cfg
.acosc_enabled
;
437 static const struct config_list anticasc_opts
[] =
439 DEF_OPT_SAVE_FUNC(anticasc_should_save_fn
),
440 DEF_OPT_FIXUP_FUNC(anticasc_fixups_fn
),
441 DEF_OPT_INT8("enabled" , OFS(ac_enabled
) , 0),
442 DEF_OPT_INT32("numusers" , OFS(ac_users
) , 0),
443 DEF_OPT_INT32("sampletime" , OFS(ac_stime
) , 2),
444 DEF_OPT_INT32("samples" , OFS(ac_samples
) , 10),
445 DEF_OPT_INT8("penalty" , OFS(ac_penalty
) , 0),
446 DEF_OPT_STR("aclogfile" , OFS(ac_logfile
) , NULL
),
447 DEF_OPT_INT32("fakedelay" , OFS(ac_fakedelay
) , 3000),
448 DEF_OPT_INT32("denysamples" , OFS(ac_denysamples
) , 8),
449 DEF_OPT_INT8("acosc_enabled" , OFS(acosc_enabled
) , 0 ),
450 DEF_OPT_INT8("acosc_max_ecms_per_minute" , OFS(acosc_max_ecms_per_minute
), 0 ),
451 DEF_OPT_INT8("acosc_max_active_sids" , OFS(acosc_max_active_sids
) , 0 ),
452 DEF_OPT_INT8("acosc_zap_limit" , OFS(acosc_zap_limit
) , 0 ),
453 DEF_OPT_INT8("acosc_penalty" , OFS(acosc_penalty
) , 0 ),
454 DEF_OPT_INT32("acosc_penalty_duration" , OFS(acosc_penalty_duration
), 0 ),
455 DEF_OPT_INT32("acosc_delay" , OFS(acosc_delay
) , 0 ),
459 static const struct config_list anticasc_opts
[] = { DEF_LAST_OPT
};
462 #ifdef MODULE_MONITOR
463 static bool monitor_should_save_fn(void *UNUSED(var
))
468 static const struct config_list monitor_opts
[] =
470 DEF_OPT_SAVE_FUNC(monitor_should_save_fn
),
471 DEF_OPT_INT32("port" , OFS(mon_port
) , 0),
472 DEF_OPT_FUNC("serverip" , OFS(mon_srvip
) , serverip_fn
),
473 DEF_OPT_FUNC("nocrypt" , OFS(mon_allowed
) , iprange_fn
, .free_value
= iprange_free_fn
),
474 DEF_OPT_INT32("aulow" , OFS(aulow
) , 30),
475 DEF_OPT_UINT8("monlevel" , OFS(mon_level
) , 2),
476 DEF_OPT_INT32("hideclient_to" , OFS(hideclient_to
), 25),
480 static const struct config_list monitor_opts
[] = { DEF_LAST_OPT
};
484 static void http_port_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
493 if(config_enabled(WITH_SSL
))
495 cfg
.http_use_ssl
= 1;
499 fprintf(stderr
, "Warning: OSCam compiled without SSL support.\n");
501 cfg
.http_port
= strtoul(value
+ 1, NULL
, 10);
505 cfg
.http_port
= strtoul(value
, NULL
, 10);
510 fprintf_conf(f
, token
, "%s%d\n", cfg
.http_use_ssl
? "+" : "", cfg
.http_port
);
513 static void http_dyndns_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
518 char *ptr
, *saveptr1
= NULL
;
519 memset(cfg
.http_dyndns
, 0, sizeof(cfg
.http_dyndns
));
520 for(i
= 0, ptr
= strtok_r(value
, ",", &saveptr1
); (i
< MAX_HTTP_DYNDNS
) && (ptr
); ptr
= strtok_r(NULL
, ",", &saveptr1
), i
++)
523 cs_strncpy((char *)cfg
.http_dyndns
[i
], ptr
, sizeof(cfg
.http_dyndns
[i
]));
527 if(strlen((const char *)(cfg
.http_dyndns
[0])) > 0 || cfg
.http_full_cfg
)
529 fprintf_conf(f
, token
, "%s", ""); // it should not have \n at the end
530 for(i
= 0; i
< MAX_HTTP_DYNDNS
; i
++)
532 if(cfg
.http_dyndns
[i
][0])
534 fprintf(f
, "%s%s", i
> 0 ? "," : "", cfg
.http_dyndns
[i
]);
541 static bool webif_should_save_fn(void *UNUSED(var
))
543 return cfg
.http_port
;
546 static const struct config_list webif_opts
[] =
548 DEF_OPT_SAVE_FUNC(webif_should_save_fn
),
549 DEF_OPT_FUNC("httpport" , OFS(http_port
) , http_port_fn
),
550 DEF_OPT_FUNC("serverip" , OFS(http_srvip
) , serverip_fn
),
551 DEF_OPT_STR("httpuser" , OFS(http_user
) , NULL
),
552 DEF_OPT_STR("httppwd" , OFS(http_pwd
) , NULL
),
553 DEF_OPT_STR("httpcss" , OFS(http_css
) , NULL
),
554 DEF_OPT_STR("httpjscript" , OFS(http_jscript
) , NULL
),
555 DEF_OPT_STR("httpscript" , OFS(http_script
) , NULL
),
556 DEF_OPT_STR("httptpl" , OFS(http_tpl
) , NULL
),
557 DEF_OPT_STR("httppiconpath" , OFS(http_piconpath
) , NULL
),
558 DEF_OPT_STR("httphelplang" , OFS(http_help_lang
) , "en"),
559 DEF_OPT_STR("httplocale" , OFS(http_locale
) , NULL
),
560 DEF_OPT_INT8("http_prepend_embedded_css", OFS(http_prepend_embedded_css
), 0),
561 DEF_OPT_INT32("httprefresh" , OFS(http_refresh
) , 0),
562 DEF_OPT_INT32("httppollrefresh" , OFS(poll_refresh
) , 60),
563 DEF_OPT_INT8("httphideidleclients" , OFS(http_hide_idle_clients
) , 1),
564 DEF_OPT_STR("httphidetype" , OFS(http_hide_type
) , NULL
),
565 DEF_OPT_INT8("httpshowpicons" , OFS(http_showpicons
) , 0),
566 DEF_OPT_INT8("httppiconsize" , OFS(http_picon_size
) , 0),
567 DEF_OPT_INT8("httpshowmeminfo" , OFS(http_showmeminfo
) , 0),
568 DEF_OPT_INT8("httpshowuserinfo" , OFS(http_showuserinfo
) , 0),
569 DEF_OPT_INT8("httpshowreaderinfo" , OFS(http_showreaderinfo
) , 0),
570 DEF_OPT_INT8("httpshowcacheexinfo" , OFS(http_showcacheexinfo
) , 0),
571 DEF_OPT_INT8("httpshowecminfo" , OFS(http_showecminfo
) , 0),
572 DEF_OPT_INT8("httpshowloadinfo" , OFS(http_showloadinfo
) , 0),
573 DEF_OPT_FUNC("httpallowed" , OFS(http_allowed
) , iprange_fn
, .free_value
= iprange_free_fn
),
574 DEF_OPT_INT8("httpreadonly" , OFS(http_readonly
) , 0),
575 DEF_OPT_INT8("httpsavefullcfg" , OFS(http_full_cfg
) , 0),
576 DEF_OPT_INT8("httpoverwritebakfile" , OFS(http_overwrite_bak_file
) , 0),
577 DEF_OPT_STR("httpcert" , OFS(http_cert
) , NULL
),
578 DEF_OPT_INT8("https_force_secure_mode" , OFS(https_force_secure_mode
) , 1),
579 DEF_OPT_FUNC("httpdyndns" , OFS(http_dyndns
) , http_dyndns_fn
),
580 DEF_OPT_INT32("aulow" , OFS(aulow
) , 30),
581 DEF_OPT_INT32("hideclient_to" , OFS(hideclient_to
) , 25),
582 DEF_OPT_STR("httposcamlabel" , OFS(http_oscam_label
) , "OSCam"),
583 DEF_OPT_INT32("httpemmuclean" , OFS(http_emmu_clean
) , 256),
584 DEF_OPT_INT32("httpemmsclean" , OFS(http_emms_clean
) , -1),
585 DEF_OPT_INT32("httpemmgclean" , OFS(http_emmg_clean
) , -1),
587 DEF_OPT_INT8("http_status_log" , OFS(http_status_log
) , 0),
589 DEF_OPT_INT8("http_status_log" , OFS(http_status_log
) , 1),
592 DEF_OPT_STR("http_extern_jquery" , OFS(http_extern_jquery
) , "//code.jquery.com/jquery-1.12.4.min.js"),
597 static const struct config_list webif_opts
[] = { DEF_LAST_OPT
};
601 static bool camd33_should_save_fn(void *UNUSED(var
))
606 static const struct config_list camd33_opts
[] =
608 DEF_OPT_SAVE_FUNC(camd33_should_save_fn
),
609 DEF_OPT_INT32("port" , OFS(c33_port
) , 0),
610 DEF_OPT_FUNC("serverip", OFS(c33_srvip
) , serverip_fn
),
611 DEF_OPT_FUNC("nocrypt" , OFS(c33_plain
) , iprange_fn
, .free_value
= iprange_free_fn
),
612 DEF_OPT_INT32("passive", OFS(c33_passive
), 0),
613 DEF_OPT_HEX("key" , OFS(c33_key
) , SIZEOF(c33_key
)),
617 static const struct config_list camd33_opts
[] = { DEF_LAST_OPT
};
621 void cache_fixups_fn(void *UNUSED(var
))
623 if(cfg
.max_cache_time
< ((int32_t)(cfg
.ctimeout
+ 500) / 1000 + 3)) { cfg
.max_cache_time
= ((cfg
.ctimeout
+ 500) / 1000 + 3); }
624 #ifdef CW_CYCLE_CHECK
625 if(cfg
.maxcyclelist
> 4000) { cfg
.maxcyclelist
= 4000; }
626 if(cfg
.keepcycletime
> 240) { cfg
.keepcycletime
= 240; }
627 if(cfg
.cwcycle_sensitive
> 4) { cfg
.cwcycle_sensitive
= 4; }
628 if(cfg
.cwcycle_sensitive
== 1) { cfg
.cwcycle_sensitive
= 2; }
632 static bool cache_should_save_fn(void *UNUSED(var
))
634 return cfg
.delay
> 0 || cfg
.max_cache_time
!= 15
636 || cfg
.cacheex_wait_timetab
.cevnum
|| cfg
.cacheex_enable_stats
> 0 || cfg
.csp_port
|| cfg
.csp
.filter_caidtab
.cevnum
|| cfg
.csp
.allow_request
== 0 || cfg
.csp
.allow_reforward
> 0
638 #ifdef CW_CYCLE_CHECK
639 || cfg
.cwcycle_check_enable
|| cfg
.cwcycle_check_caidtab
.ctnum
|| cfg
.maxcyclelist
!= 500 || cfg
.keepcycletime
|| cfg
.onbadcycle
|| cfg
.cwcycle_dropold
|| cfg
.cwcycle_sensitive
|| cfg
.cwcycle_allowbadfromffb
|| cfg
.cwcycle_usecwcfromce
644 static const struct config_list cache_opts
[] =
646 DEF_OPT_SAVE_FUNC(cache_should_save_fn
),
647 DEF_OPT_FIXUP_FUNC(cache_fixups_fn
),
648 DEF_OPT_UINT32("delay" , OFS(delay
) , CS_DELAY
),
649 DEF_OPT_INT32("max_time" , OFS(max_cache_time
) , DEFAULT_MAX_CACHE_TIME
),
651 DEF_OPT_INT32("max_hit_time" , OFS(max_hitcache_time
) , DEFAULT_MAX_HITCACHE_TIME
),
652 DEF_OPT_FUNC("wait_time" , OFS(cacheex_wait_timetab
) , cacheex_valuetab_fn
),
653 DEF_OPT_FUNC("cacheex_mode1_delay" , OFS(cacheex_mode1_delay_tab
), caidvaluetab_fn
),
654 DEF_OPT_UINT8("cacheexenablestats" , OFS(cacheex_enable_stats
) , 0),
655 DEF_OPT_INT32("csp_port" , OFS(csp_port
) , 0),
656 DEF_OPT_FUNC("csp_serverip" , OFS(csp_srvip
) , serverip_fn
),
657 DEF_OPT_FUNC("csp_ecm_filter" , OFS(csp
.filter_caidtab
) , cacheex_hitvaluetab_fn
),
658 DEF_OPT_UINT8("csp_allow_request" , OFS(csp
.allow_request
) , 1),
659 DEF_OPT_UINT8("csp_allow_reforward" , OFS(csp
.allow_reforward
) , 0),
660 DEF_OPT_FUNC("cacheex_cw_check" , OFS(cacheex_cwcheck_tab
) , cacheex_cwcheck_tab_fn
),
661 DEF_OPT_UINT8("wait_until_ctimeout" , OFS(wait_until_ctimeout
) , 0),
662 DEF_OPT_UINT8("csp_block_fakecws" , OFS(csp
.block_fakecws
) , 0),
664 #ifdef CW_CYCLE_CHECK
665 DEF_OPT_INT8("cwcycle_check_enable" , OFS(cwcycle_check_enable
) , 0),
666 DEF_OPT_FUNC("cwcycle_check_caid" , OFS(cwcycle_check_caidtab
) , check_caidtab_fn
),
667 DEF_OPT_INT32("cwcycle_maxlist" , OFS(maxcyclelist
) , 500),
668 DEF_OPT_INT32("cwcycle_keeptime" , OFS(keepcycletime
) , 15),
669 DEF_OPT_INT8("cwcycle_onbad" , OFS(onbadcycle
) , 1),
670 DEF_OPT_INT8("cwcycle_dropold" , OFS(cwcycle_dropold
) , 1),
671 DEF_OPT_INT8("cwcycle_sensitive" , OFS(cwcycle_sensitive
) , 4),
672 DEF_OPT_INT8("cwcycle_allowbadfromffb", OFS(cwcycle_allowbadfromffb
), 0),
673 DEF_OPT_INT8("cwcycle_usecwcfromce" , OFS(cwcycle_usecwcfromce
) , 0),
679 static bool camd35_should_save_fn(void *UNUSED(var
))
684 static const struct config_list camd35_opts
[] =
686 DEF_OPT_SAVE_FUNC(camd35_should_save_fn
),
687 DEF_OPT_INT32("port" , OFS(c35_port
) , 0),
688 DEF_OPT_FUNC("serverip" , OFS(c35_srvip
) , serverip_fn
),
689 DEF_OPT_INT8("suppresscmd08", OFS(c35_udp_suppresscmd08
), 0),
693 static const struct config_list camd35_opts
[] = { DEF_LAST_OPT
};
696 #ifdef MODULE_NEWCAMD
697 static void porttab_fn(const char *token
, char *value
, void *setting
, FILE *f
)
699 PTAB
*ptab
= setting
;
702 if(strlen(value
) == 0)
708 chk_port_tab(value
, ptab
);
712 value
= mk_t_newcamd_port();
713 fprintf_conf(f
, token
, "%s\n", value
);
718 #ifdef MODULE_CAMD35_TCP
719 static void porttab_camd35_fn(const char *token
, char *value
, void *setting
, FILE *f
)
721 PTAB
*ptab
= setting
;
724 if(strlen(value
) == 0)
730 chk_port_camd35_tab(value
, ptab
);
734 value
= mk_t_camd35tcp_port();
735 fprintf_conf(f
, token
, "%s\n", value
);
740 #if defined(MODULE_NEWCAMD) || defined(MODULE_CAMD35_TCP)
741 static void porttab_free_fn(void *setting
)
747 #ifdef MODULE_CAMD35_TCP
748 static bool cs378x_should_save_fn(void *UNUSED(var
))
750 return cfg
.c35_tcp_ptab
.nports
&& cfg
.c35_tcp_ptab
.ports
[0].s_port
;
753 static const struct config_list cs378x_opts
[] =
755 DEF_OPT_SAVE_FUNC(cs378x_should_save_fn
),
756 DEF_OPT_FUNC("port" , OFS(c35_tcp_ptab
) , porttab_camd35_fn
, .free_value
= porttab_free_fn
),
757 DEF_OPT_FUNC("serverip" , OFS(c35_tcp_srvip
) , serverip_fn
),
758 DEF_OPT_INT8("suppresscmd08", OFS(c35_tcp_suppresscmd08
), 0),
762 static const struct config_list cs378x_opts
[] = { DEF_LAST_OPT
};
765 #ifdef MODULE_NEWCAMD
766 static bool newcamd_should_save_fn(void *UNUSED(var
))
768 return cfg
.ncd_ptab
.nports
&& cfg
.ncd_ptab
.ports
[0].s_port
;
771 static const struct config_list newcamd_opts
[] =
773 DEF_OPT_SAVE_FUNC(newcamd_should_save_fn
),
774 DEF_OPT_FUNC("port" , OFS(ncd_ptab
) , porttab_fn
, .free_value
= porttab_free_fn
),
775 DEF_OPT_FUNC("serverip" , OFS(ncd_srvip
) , serverip_fn
),
776 DEF_OPT_FUNC("allowed" , OFS(ncd_allowed
) , iprange_fn
, .free_value
= iprange_free_fn
),
777 DEF_OPT_HEX("key" , OFS(ncd_key
) , SIZEOF(ncd_key
)),
778 DEF_OPT_INT8("keepalive" , OFS(ncd_keepalive
), DEFAULT_NCD_KEEPALIVE
),
779 DEF_OPT_INT8("mgclient" , OFS(ncd_mgclient
) , 0),
783 static const struct config_list newcamd_opts
[] = { DEF_LAST_OPT
};
787 static void cccam_port_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
792 char *ptr
, *saveptr1
= NULL
;
793 memset(cfg
.cc_port
, 0, sizeof(cfg
.cc_port
));
794 for(i
= 0, ptr
= strtok_r(value
, ",", &saveptr1
); ptr
&& i
< CS_MAXPORTS
; ptr
= strtok_r(NULL
, ",", &saveptr1
))
796 cfg
.cc_port
[i
] = strtoul(ptr
, NULL
, 10);
802 value
= mk_t_cccam_port();
803 fprintf_conf(f
, token
, "%s\n", value
);
807 static bool cccam_should_save_fn(void *UNUSED(var
))
809 return cfg
.cc_port
[0];
812 static const struct config_list cccam_opts
[] =
814 DEF_OPT_SAVE_FUNC(cccam_should_save_fn
),
815 DEF_OPT_FUNC("port" , OFS(cc_port
) , cccam_port_fn
),
816 DEF_OPT_FUNC("serverip" , OFS(cc_srvip
) , serverip_fn
),
817 DEF_OPT_HEX("nodeid" , OFS(cc_fixed_nodeid
) , SIZEOF(cc_fixed_nodeid
)),
818 DEF_OPT_SSTR("version" , OFS(cc_version
) , "", SIZEOF(cc_version
)),
819 DEF_OPT_INT8("reshare" , OFS(cc_reshare
) , 10),
820 DEF_OPT_INT8("reshare_mode" , OFS(cc_reshare_services
) , 4),
821 DEF_OPT_INT8("ignorereshare" , OFS(cc_ignore_reshare
) , 0),
822 DEF_OPT_INT8("forward_origin_card", OFS(cc_forward_origin_card
), 0),
823 DEF_OPT_INT8("stealth" , OFS(cc_stealth
) , 0),
824 DEF_OPT_INT32("updateinterval" , OFS(cc_update_interval
) , DEFAULT_UPDATEINTERVAL
),
825 DEF_OPT_INT8("minimizecards" , OFS(cc_minimize_cards
) , 0),
826 DEF_OPT_INT8("keepconnected" , OFS(cc_keep_connected
) , 1),
827 DEF_OPT_UINT32("recv_timeout" , OFS(cc_recv_timeout
) , DEFAULT_CC_RECV_TIMEOUT
),
831 static const struct config_list cccam_opts
[] = { DEF_LAST_OPT
};
834 #ifdef MODULE_PANDORA
835 static bool pandora_should_save_fn(void *UNUSED(var
))
837 return cfg
.pand_port
;
840 static const struct config_list pandora_opts
[] =
842 DEF_OPT_SAVE_FUNC(pandora_should_save_fn
),
843 DEF_OPT_INT32("pand_port" , OFS(pand_port
) , 0),
844 DEF_OPT_FUNC("pand_srvid" , OFS(pand_srvip
) , serverip_fn
),
845 DEF_OPT_STR("pand_usr" , OFS(pand_usr
) , NULL
),
846 DEF_OPT_STR("pand_pass" , OFS(pand_pass
) , NULL
),
847 DEF_OPT_INT8("pand_ecm" , OFS(pand_ecm
) , 0),
848 DEF_OPT_INT8("pand_skip_send_dw", OFS(pand_skip_send_dw
), 0),
849 DEF_OPT_FUNC("pand_allowed" , OFS(pand_allowed
) , iprange_fn
, .free_value
= iprange_free_fn
),
853 static const struct config_list pandora_opts
[] = { DEF_LAST_OPT
};
857 static bool scam_should_save_fn(void *UNUSED(var
))
859 return cfg
.scam_port
;
861 static const struct config_list scam_opts
[] =
863 DEF_OPT_SAVE_FUNC(scam_should_save_fn
),
864 DEF_OPT_INT32("port" , OFS(scam_port
) , 0),
865 DEF_OPT_FUNC("serverip" , OFS(scam_srvip
) , serverip_fn
),
866 DEF_OPT_FUNC("allowed" , OFS(scam_allowed
), iprange_fn
, .free_value
= iprange_free_fn
),
870 static const struct config_list scam_opts
[] = { DEF_LAST_OPT
};
874 static bool streamrelay_should_save_fn(void *UNUSED(var
))
878 static const struct config_list streamrelay_opts
[] =
880 DEF_OPT_SAVE_FUNC(streamrelay_should_save_fn
),
881 DEF_OPT_STR("stream_source_host" , OFS(emu_stream_source_host
), "127.0.0.1"),
882 DEF_OPT_INT32("stream_source_port" , OFS(emu_stream_source_port
), 8001),
883 DEF_OPT_STR("stream_source_auth_user" , OFS(emu_stream_source_auth_user
), NULL
),
884 DEF_OPT_STR("stream_source_auth_password" , OFS(emu_stream_source_auth_password
), NULL
),
885 DEF_OPT_INT32("stream_relay_port" , OFS(emu_stream_relay_port
), 17999),
886 DEF_OPT_UINT32("stream_ecm_delay" , OFS(emu_stream_ecm_delay
), 600),
887 DEF_OPT_INT8("stream_relay_enabled" , OFS(emu_stream_relay_enabled
), 1),
888 DEF_OPT_INT8("stream_emm_enabled" , OFS(emu_stream_emm_enabled
), 1),
889 DEF_OPT_FUNC("stream_relay_ctab" , OFS(emu_stream_relay_ctab
), check_caidtab_fn
),
893 static const struct config_list streamrelay_opts
[] = { DEF_LAST_OPT
};
897 #ifdef MODULE_RADEGAST
898 static bool radegast_should_save_fn(void *UNUSED(var
))
903 static const struct config_list radegast_opts
[] =
905 DEF_OPT_SAVE_FUNC(radegast_should_save_fn
),
906 DEF_OPT_INT32("port" , OFS(rad_port
) , 0),
907 DEF_OPT_FUNC("serverip", OFS(rad_srvip
) , serverip_fn
),
908 DEF_OPT_FUNC("allowed" , OFS(rad_allowed
), iprange_fn
, .free_value
= iprange_free_fn
),
909 DEF_OPT_STR("user" , OFS(rad_usr
) , NULL
),
913 static const struct config_list radegast_opts
[] = { DEF_LAST_OPT
};
917 static bool serial_should_save_fn(void *UNUSED(var
))
919 return cfg
.ser_device
!= NULL
;
922 static const struct config_list serial_opts
[] =
924 DEF_OPT_SAVE_FUNC(serial_should_save_fn
),
925 DEF_OPT_STR("device", OFS(ser_device
), NULL
),
929 static const struct config_list serial_opts
[] = { DEF_LAST_OPT
};
934 static void gbox_password_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
940 if (s
[strspn(s
, "0123456789abcdefABCDEF")] == 0)
942 /* valid Hexa symbol */
943 cfg
.gbox_password
= a2i(value
, 8);
948 cfg
.gbox_password
= 0;
951 if (cfg
.gbox_password
!= 0)
953 fprintf_conf(f
, token
, "%08X\n", cfg
.gbox_password
);
957 static void gbox_block_ecm_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
961 char *ptr1
, *saveptr1
= NULL
;
963 memset(cfg
.gbox_block_ecm
, 0, sizeof(cfg
.gbox_block_ecm
));
965 for (i
= 0, ptr1
= strtok_r(value
, ",", &saveptr1
); (i
< 4) && (ptr1
); ptr1
= strtok_r(NULL
, ",", &saveptr1
))
968 if ((n
< GBOX_MAX_BLOCKED_ECM
) && (s
[strspn(s
, "0123456789abcdefABCDEF")] == 0))
969 { cfg
.gbox_block_ecm
[n
++] = a2i(ptr1
, 4); }
971 cfg
.gbox_block_ecm_num
= n
;
974 if (cfg
.gbox_block_ecm_num
> 0)
976 value
= mk_t_gbox_block_ecm();
977 fprintf_conf(f
, token
, "%s\n", value
);
982 static void accept_remm_peer_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
986 char *ptr1
, *saveptr1
= NULL
;
988 memset(cfg
.accept_remm_peer
, 0, sizeof(cfg
.accept_remm_peer
));
990 for (i
= 0, ptr1
= strtok_r(value
, ",", &saveptr1
); (i
< 4) && (ptr1
); ptr1
= strtok_r(NULL
, ",", &saveptr1
))
993 if ((n
< GBOX_MAX_REMM_PEERS
) && (s
[strspn(s
, "0123456789abcdefABCDEF")] == 0))
994 { cfg
.accept_remm_peer
[n
++] = a2i(ptr1
, 4); }
996 cfg
.accept_remm_peer_num
= n
;
1000 if (cfg
.accept_remm_peer_num
> 0)
1002 value
= mk_t_accept_remm_peer();
1003 fprintf_conf(f
, token
, "%s\n", value
);
1008 static void gbox_ignored_peer_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
1012 char *ptr1
, *saveptr1
= NULL
;
1014 memset(cfg
.gbox_ignored_peer
, 0, sizeof(cfg
.gbox_ignored_peer
));
1017 for (i
= 0, ptr1
= strtok_r(value
, ",", &saveptr1
); (i
< 4) && (ptr1
); ptr1
= strtok_r(NULL
, ",", &saveptr1
))
1020 if ((n
< GBOX_MAX_IGNORED_PEERS
) && (s
[strspn(s
, "0123456789abcdefABCDEF")] == 0))
1021 { cfg
.gbox_ignored_peer
[n
++] = a2i(ptr1
, 4); }
1023 cfg
.gbox_ignored_peer_num
= n
;
1027 if (cfg
.gbox_ignored_peer_num
> 0)
1029 value
= mk_t_gbox_ignored_peer();
1030 fprintf_conf(f
, token
, "%s\n", value
);
1035 static void gbox_proxy_card_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
1039 char *ptr1
, *saveptr1
= NULL
;
1041 memset(cfg
.gbox_proxy_card
, 0, sizeof(cfg
.gbox_proxy_card
));
1043 for (i
= 0, ptr1
= strtok_r(value
, ",", &saveptr1
); (i
< 8) && (ptr1
); ptr1
= strtok_r(NULL
, ",", &saveptr1
))
1046 if ((n
< GBOX_MAX_PROXY_CARDS
) && (s
[strspn(s
, "0123456789abcdefABCDEF")] == 0))
1047 { cfg
.gbox_proxy_card
[n
++] = a2i(ptr1
, 8); }
1049 cfg
.gbox_proxy_cards_num
= n
;
1053 if (cfg
.gbox_proxy_cards_num
> 0)
1055 value
= mk_t_gbox_proxy_card();
1056 fprintf_conf(f
, token
, "%s\n", value
);
1061 static void gbox_port_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
1066 char *ptr
, *saveptr1
= NULL
;
1067 memset(cfg
.gbox_port
, 0, sizeof(cfg
.gbox_port
));
1068 for(i
= 0, ptr
= strtok_r(value
, ",", &saveptr1
); ptr
&& i
< CS_MAXPORTS
; ptr
= strtok_r(NULL
, ",", &saveptr1
))
1070 cfg
.gbox_port
[i
] = strtoul(ptr
, NULL
, 10);
1071 if(cfg
.gbox_port
[i
])
1076 value
= mk_t_gbox_port();
1077 fprintf_conf(f
, token
, "%s\n", value
);
1081 static void gbox_my_vers_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
1087 int32_t len
= strlen(value
);
1089 if ((s
[strspn(s
, "0123456789abcdefABCDEF")] != 0) || (len
== 0) || (len
> 2))
1091 cfg
.gbox_my_vers
= GBOX_MY_VERS_DEF
;
1095 cfg
.gbox_my_vers
= a2i(value
, 1);
1100 if(cfg
.gbox_my_vers
!= GBOX_MY_VERS_DEF
)
1102 fprintf_conf(f
, token
, "%02X\n", cfg
.gbox_my_vers
);
1104 else if(cfg
.http_full_cfg
)
1106 fprintf_conf(f
, token
, "%02X\n", GBOX_MY_VERS_DEF
);
1110 static void gbox_my_cpu_api_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
1116 int32_t len
= strlen(value
);
1118 if ((s
[strspn(s
, "0123456789abcdefABCDEF")] != 0) || (len
== 0) || (len
> 2))
1120 cfg
.gbox_my_cpu_api
= GBOX_MY_CPU_API_DEF
;
1124 cfg
.gbox_my_cpu_api
= a2i(value
,1);
1129 if(cfg
.gbox_my_cpu_api
!= GBOX_MY_CPU_API_DEF
)
1131 fprintf_conf(f
, token
, "%02X\n", cfg
.gbox_my_cpu_api
);
1133 else if(cfg
.http_full_cfg
)
1134 { fprintf_conf(f
, token
, "%02X\n", GBOX_MY_CPU_API_DEF
); }
1137 static void gbox_dest_peers_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
1141 char *ptr1
, *saveptr1
= NULL
;
1143 memset(cfg
.gbox_dest_peers
, 0, sizeof(cfg
.gbox_dest_peers
));
1146 for (ptr1
= strtok_r(value
, ",", &saveptr1
); (ptr1
); ptr1
= strtok_r(NULL
, ",", &saveptr1
))
1149 if ((n
< GBOX_MAX_DEST_PEERS
) && (s
[strspn(s
, "0123456789abcdefABCDEF")] == 0))
1150 { cfg
.gbox_dest_peers
[n
++] = a2i(trim(ptr1
), strlen(trim(ptr1
))); }
1152 cfg
.gbox_dest_peers_num
= n
;
1156 if ((cfg
.gbox_dest_peers_num
> 0) && cfg
.gbox_save_gsms
)
1158 value
= mk_t_gbox_dest_peers();
1159 fprintf_conf(f
, token
, "%s\n", value
);
1164 static void gbox_msg_txt_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
1168 cs_strncpy(cfg
.gbox_msg_txt
, value
, sizeof(cfg
.gbox_msg_txt
));
1172 if ((cfg
.gbox_msg_txt
[0] != '\0') && cfg
.gbox_save_gsms
)
1174 fprintf_conf(f
, token
, "%s\n", cfg
.gbox_msg_txt
);
1178 static bool gbox_should_save_fn(void *UNUSED(var
))
1180 return cfg
.gbox_port
[0];
1183 static const struct config_list gbox_opts
[] =
1185 DEF_OPT_SAVE_FUNC(gbox_should_save_fn
),
1186 DEF_OPT_FUNC("port" , OFS(gbox_port
) , gbox_port_fn
),
1187 DEF_OPT_STR("hostname" , OFS(gbox_hostname
) , NULL
),
1188 DEF_OPT_FUNC("my_password" , OFS(gbox_password
) , gbox_password_fn
),
1189 DEF_OPT_UINT32("gbox_reconnect", OFS(gbox_reconnect
) , DEFAULT_GBOX_RECONNECT
),
1190 DEF_OPT_FUNC("my_vers" , OFS(gbox_my_vers
) , gbox_my_vers_fn
),
1191 DEF_OPT_FUNC("my_cpu_api" , OFS(gbox_my_cpu_api
) , gbox_my_cpu_api_fn
),
1192 DEF_OPT_UINT8("gsms_disable" , OFS(gsms_dis
) , 1),
1193 DEF_OPT_UINT8("dis_attack_txt" , OFS(dis_attack_txt
) , 0),
1194 DEF_OPT_UINT8("log_hello" , OFS(log_hello
) , 1),
1195 DEF_OPT_STR("tmp_dir" , OFS(gbox_tmp_dir
) , NULL
),
1196 DEF_OPT_FUNC("ignore_peer" , OFS(gbox_ignored_peer
), gbox_ignored_peer_fn
),
1197 DEF_OPT_FUNC("accept_remm_peer", OFS(accept_remm_peer
) , accept_remm_peer_fn
),
1198 DEF_OPT_FUNC("block_ecm" , OFS(gbox_block_ecm
) , gbox_block_ecm_fn
),
1199 DEF_OPT_FUNC("proxy_card" , OFS(gbox_proxy_card
) , gbox_proxy_card_fn
),
1200 DEF_OPT_UINT8("gbox_save_gsms" , OFS(gbox_save_gsms
) , 0),
1201 DEF_OPT_UINT8("gbox_msg_type" , OFS(gbox_msg_type
) , 0),
1202 DEF_OPT_FUNC("gbox_dest_peers" , OFS(gbox_dest_peers
) , gbox_dest_peers_fn
),
1203 DEF_OPT_FUNC("gbox_msg_txt" , OFS(gbox_msg_txt
) , gbox_msg_txt_fn
),
1204 DEF_OPT_UINT8("ccc_reshare" , OFS(cc_gbx_reshare_en
), 0),
1205 DEF_OPT_FUNC("ccc_gbx_caid" , OFS(ccc_gbx_check_caidtab
), check_caidtab_fn
),
1209 static const struct config_list gbox_opts
[] = { DEF_LAST_OPT
};
1213 extern const char *boxdesc
[];
1215 static void dvbapi_boxtype_fn(const char *token
, char *value
, void *UNUSED(setting
), FILE *f
)
1220 cfg
.dvbapi_boxtype
= 0;
1221 for(i
= 1; i
<= BOXTYPES
; i
++)
1223 if(streq(value
, boxdesc
[i
]))
1225 cfg
.dvbapi_boxtype
= i
;
1232 if(cfg
.dvbapi_boxtype
)
1233 { fprintf_conf(f
, token
, "%s\n", boxdesc
[cfg
.dvbapi_boxtype
]); }
1236 static void dvbapi_services_fn(const char *UNUSED(token
), char *value
, void *UNUSED(setting
), FILE *UNUSED(f
))
1239 { chk_services(value
, &cfg
.dvbapi_sidtabs
); }
1240 // THIS OPTION IS NOT SAVED
1243 extern struct s_dvbapi_priority
*dvbapi_priority
;
1245 static void dvbapi_caidtab_fn(const char *UNUSED(token
), char *caidasc
, void *UNUSED(setting
), long cmd
, FILE *UNUSED(f
))
1247 char *ptr1
, *ptr3
, *saveptr1
= NULL
;
1250 char type
= (char)cmd
;
1252 for(ptr1
= strtok_r(caidasc
, ",", &saveptr1
); (ptr1
); ptr1
= strtok_r(NULL
, ",", &saveptr1
))
1254 uint32_t caid
, prov
;
1255 if((ptr3
= strchr(trim(ptr1
), ':')))
1256 { * ptr3
++ = '\0'; }
1260 if(((caid
= a2i(ptr1
, 2)) | (prov
= a2i(ptr3
, 3))))
1262 struct s_dvbapi_priority
*entry
;
1264 if(!cs_malloc(&entry
, sizeof(struct s_dvbapi_priority
)))
1271 snprintf(tmp1
, sizeof(tmp1
), "%04X", (uint
)prov
);
1272 int32_t cw_delay
= strtol(tmp1
, NULL
, 10);
1273 entry
->delay
= cw_delay
;
1277 entry
->provid
= prov
;
1283 if(!dvbapi_priority
)
1285 dvbapi_priority
= entry
;
1289 struct s_dvbapi_priority
*p
;
1290 for(p
= dvbapi_priority
; p
->next
!= NULL
; p
= p
->next
)
1296 // THIS OPTION IS NOT SAVED
1299 static bool dvbapi_should_save_fn(void *UNUSED(var
))
1301 return cfg
.dvbapi_enabled
;
1304 static const struct config_list dvbapi_opts
[] =
1306 DEF_OPT_SAVE_FUNC(dvbapi_should_save_fn
),
1307 DEF_OPT_INT8("enabled" , OFS(dvbapi_enabled
) , 0),
1308 DEF_OPT_INT8("au" , OFS(dvbapi_au
) , 0),
1309 DEF_OPT_INT8("pmt_mode" , OFS(dvbapi_pmtmode
) , 0),
1310 DEF_OPT_INT8("request_mode" , OFS(dvbapi_requestmode
) , 0),
1311 DEF_OPT_INT32("listen_port" , OFS(dvbapi_listenport
) , 0),
1312 DEF_OPT_INT32("delayer" , OFS(dvbapi_delayer
) , 0),
1313 DEF_OPT_INT8("ecminfo_file" , OFS(dvbapi_ecminfo_file
) , 1),
1314 DEF_OPT_INT8("ecminfo_type" , OFS(dvbapi_ecminfo_type
) , 0),
1315 DEF_OPT_STR("user" , OFS(dvbapi_usr
) , NULL
),
1316 DEF_OPT_INT8("read_sdt" , OFS(dvbapi_read_sdt
) , 0),
1317 DEF_OPT_INT8("write_sdt_prov" , OFS(dvbapi_write_sdt_prov
) , 0),
1318 DEF_OPT_INT8("extended_cw_api", OFS(dvbapi_extended_cw_api
), 0),
1319 DEF_OPT_FUNC("boxtype" , OFS(dvbapi_boxtype
) , dvbapi_boxtype_fn
),
1320 DEF_OPT_FUNC("services" , OFS(dvbapi_sidtabs
.ok
) , dvbapi_services_fn
),
1322 DEF_OPT_FUNC_X("priority" , 0, dvbapi_caidtab_fn
, 'p'),
1323 DEF_OPT_FUNC_X("ignore" , 0, dvbapi_caidtab_fn
, 'i'),
1324 DEF_OPT_FUNC_X("cw_delay" , 0, dvbapi_caidtab_fn
, 'd'),
1328 static const struct config_list dvbapi_opts
[] = { DEF_LAST_OPT
};
1332 static void lcd_fixups_fn(void *UNUSED(var
))
1334 if(cfg
.lcd_write_intervall
< 5) { cfg
.lcd_write_intervall
= 5; }
1337 static bool lcd_should_save_fn(void *UNUSED(var
))
1339 return cfg
.enablelcd
;
1342 static const struct config_list lcd_opts
[] =
1344 DEF_OPT_SAVE_FUNC(lcd_should_save_fn
),
1345 DEF_OPT_FIXUP_FUNC(lcd_fixups_fn
),
1346 DEF_OPT_INT8("enablelcd" , OFS(enablelcd
) , 0),
1347 DEF_OPT_STR("lcd_outputpath" , OFS(lcd_output_path
) , NULL
),
1348 DEF_OPT_INT32("lcd_hideidle" , OFS(lcd_hide_idle
) , 0),
1349 DEF_OPT_INT32("lcd_writeintervall", OFS(lcd_write_intervall
), 10),
1353 static const struct config_list lcd_opts
[] = { DEF_LAST_OPT
};
1356 static const struct config_sections oscam_conf
[] =
1358 { "global", global_opts
}, // *** MUST BE FIRST ***
1359 { "anticasc", anticasc_opts
},
1360 { "cache", cache_opts
},
1361 { "lcd", lcd_opts
},
1362 { "camd33", camd33_opts
},
1363 { "cs357x", camd35_opts
},
1364 { "cs378x", cs378x_opts
},
1365 { "newcamd", newcamd_opts
},
1366 { "radegast", radegast_opts
},
1367 { "serial", serial_opts
},
1368 { "gbox", gbox_opts
},
1369 { "cccam", cccam_opts
},
1370 { "pandora", pandora_opts
},
1371 { "scam", scam_opts
},
1372 { "streamrelay", streamrelay_opts
},
1373 { "dvbapi", dvbapi_opts
},
1374 { "monitor", monitor_opts
},
1375 { "webif", webif_opts
},
1379 void config_set(char *section
, const char *token
, char *value
)
1381 config_set_value(oscam_conf
, section
, token
, value
, &cfg
);
1384 void config_free(void)
1386 config_sections_free(oscam_conf
, &cfg
);
1387 caidvaluetab_clear(&cfg
.ftimeouttab
);
1388 caidtab_clear(&cfg
.double_check_caid
);
1389 ftab_clear(&cfg
.disablecrccws_only_for
);
1391 caidvaluetab_clear(&cfg
.lb_retrylimittab
);
1392 caidvaluetab_clear(&cfg
.lb_nbest_readers_tab
);
1393 caidtab_clear(&cfg
.lb_noproviderforcaid
);
1396 caidvaluetab_clear(&cfg
.cacheex_mode1_delay_tab
);
1397 cecspvaluetab_clear(&cfg
.cacheex_wait_timetab
);
1399 #ifdef CW_CYCLE_CHECK
1400 caidtab_clear(&cfg
.cwcycle_check_caidtab
);
1404 int32_t init_config(void)
1408 if(config_enabled(WEBIF
))
1410 fp
= open_config_file(cs_conf
);
1414 fp
= open_config_file_or_die(cs_conf
);
1417 const struct config_sections
*cur_section
= oscam_conf
; // Global
1420 config_sections_set_defaults(oscam_conf
, &cfg
);
1424 // no oscam.conf but webif is included in build, set it up for lan access and tweak defaults
1426 cfg
.http_port
= DEFAULT_HTTP_PORT
;
1427 char *default_allowed
;
1428 if ((default_allowed
= cs_strdup(DEFAULT_HTTP_ALLOW
)))
1430 chk_iprange(default_allowed
, &cfg
.http_allowed
);
1431 free(default_allowed
);
1434 NULLFREE(cfg
.logfile
);
1435 cfg
.logtostdout
= 1;
1437 cfg
.dvbapi_enabled
= 1;
1442 if(!cs_malloc(&token
, MAXLINESIZE
))
1446 int valid_section
= 1;
1447 while(fgets(token
, MAXLINESIZE
, fp
))
1450 int len
= strlen(trim(token
));
1451 if(len
< 3) // a=b or [a] are at least 3 chars
1453 if(token
[0] == '#') // Skip comments
1455 if(token
[0] == '[' && token
[len
- 1] == ']')
1457 token
[len
- 1] = '\0';
1459 const struct config_sections
*newconf
= config_find_section(oscam_conf
, token
+ 1);
1460 if(config_section_is_active(newconf
) && cur_section
)
1462 config_list_apply_fixups(cur_section
->config
, &cfg
);
1463 cur_section
= newconf
;
1468 fprintf(stderr
, "WARNING: %s line %d unknown section [%s].\n",
1469 cs_conf
, line
, token
+ 1);
1472 if(!config_section_is_active(newconf
))
1474 fprintf(stderr
, "WARNING: %s line %d section [%s] is ignored (support not compiled in).\n",
1475 cs_conf
, line
, newconf
->section
);
1482 char *value
= strchr(token
, '=');
1483 if(!value
) // No = found, well go on
1486 char *tvalue
= trim(value
);
1487 char *ttoken
= trim(strtolower(token
));
1488 if(cur_section
&& !config_list_parse(cur_section
->config
, ttoken
, tvalue
, &cfg
))
1490 fprintf(stderr
, "WARNING: %s line %d section [%s] contains unknown setting '%s=%s'\n",
1491 cs_conf
, line
, cur_section
->section
, ttoken
, tvalue
);
1496 if(cur_section
) { config_list_apply_fixups(cur_section
->config
, &cfg
); }
1500 int32_t write_config(void)
1502 FILE *f
= create_config_file(cs_conf
);
1505 config_sections_save(oscam_conf
, f
, &cfg
);
1506 return flush_config_file(f
, cs_conf
);