Changeset 7433
- Timestamp:
- 09/14/12 17:53:12 (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals.h
r7432 r7433 1299 1299 char *description; 1300 1300 #endif 1301 int 8_t uniq;1301 int32_t uniq; 1302 1302 #ifdef CS_CACHEEX 1303 int 8_t cacheex;1304 int 8_tcacheex_maxhop;1303 int32_t cacheex; 1304 int32_t cacheex_maxhop; 1305 1305 #endif 1306 1306 int16_t allowedprotocols; … … 1328 1328 int32_t allowedtimeframe[2]; 1329 1329 int32_t c35_suppresscmd08; 1330 uint 8_tc35_sleepsend;1330 uint32_t c35_sleepsend; 1331 1331 int32_t ncd_keepalive; 1332 1332 #ifdef MODULE_CCCAM 1333 1333 int32_t cccmaxhops; 1334 int 8_t cccreshare;1335 int 8_t cccignorereshare;1336 int 8_t cccstealth;1337 #endif 1338 int 8_t disabled;1334 int32_t cccreshare; 1335 int32_t cccignorereshare; 1336 int32_t cccstealth; 1337 #endif 1338 int32_t disabled; 1339 1339 int32_t failban; 1340 1340 -
trunk/oscam-config.c
r7430 r7433 805 805 } 806 806 807 #undef OFS 808 #define OFS(X) \ 809 offsetof(struct s_auth, X) 810 811 #undef SIZEOF 812 #define SIZEOF(X) \ 813 sizeof(((struct s_auth *)0)->X) 814 815 static void account_fixups_fn(void *var) { 816 struct s_auth *account = var; 817 if (account->c35_sleepsend > 0xFF) account->c35_sleepsend = 0xFF; 818 #ifdef CS_ANTICASC 819 if (account->ac_users < -1) account->ac_users = DEFAULT_AC_USERS; 820 if (account->ac_penalty < -1) account->ac_penalty = DEFAULT_AC_PENALTY; 821 #endif 822 } 823 824 static const struct config_list account_opts[] = { 825 DEF_OPT_FIXUP_FUNC(account_fixups_fn), 826 DEF_OPT_INT("disabled" , OFS(disabled), 0 ), 827 DEF_OPT_SSTR("user" , OFS(usr), "", SIZEOF(usr) ), 828 DEF_OPT_SSTR("pwd" , OFS(pwd), "", SIZEOF(pwd) ), 829 #ifdef WEBIF 830 DEF_OPT_STR("description" , OFS(description), NULL ), 831 #endif 832 DEF_OPT_SSTR("hostname" , OFS(dyndns), "", SIZEOF(dyndns) ), 833 DEF_OPT_FUNC("caid" , OFS(ctab), check_caidtab_fn ), 834 DEF_OPT_INT("uniq" , OFS(uniq), 0 ), 835 DEF_OPT_UINT("sleepsend" , OFS(c35_sleepsend), 0 ), 836 DEF_OPT_INT("failban" , OFS(failban), 0 ), 837 #ifdef CS_CACHEEX 838 DEF_OPT_INT("cacheex" , OFS(cacheex), 0 ), 839 DEF_OPT_INT("cacheex_maxhop" , OFS(cacheex_maxhop), 0 ), 840 #endif 841 #ifdef MODULE_CCCAM 842 DEF_OPT_INT("cccmaxhops" , OFS(cccmaxhops), DEFAULT_CC_MAXHOP ), 843 DEF_OPT_INT("cccreshare" , OFS(cccreshare), DEFAULT_CC_RESHARE ), 844 DEF_OPT_INT("cccignorereshare" , OFS(cccignorereshare), DEFAULT_CC_IGNRSHR ), 845 DEF_OPT_INT("cccstealth" , OFS(cccstealth), DEFAULT_CC_STEALTH ), 846 #endif 847 #ifdef CS_ANTICASC 848 DEF_OPT_INT("numusers" , OFS(ac_users), DEFAULT_AC_USERS ), 849 DEF_OPT_INT("penalty" , OFS(ac_penalty), DEFAULT_AC_PENALTY ), 850 #endif 851 DEF_LAST_OPT 852 }; 853 807 854 void chk_account(const char *token, char *value, struct s_auth *account) 808 855 { … … 810 857 char *ptr1, *saveptr1 = NULL; 811 858 812 if (!strcmp(token, "user")) { 813 cs_strncpy(account->usr, value, sizeof(account->usr)); 814 return; 815 } 816 817 if (!strcmp(token, "pwd")) { 818 cs_strncpy(account->pwd, value, sizeof(account->pwd)); 859 if (config_list_parse(account_opts, token, value, account)) { 860 config_list_apply_fixups(account_opts, account); 819 861 return; 820 862 } … … 843 885 } 844 886 845 #ifdef WEBIF846 if (!strcmp(token, "description")) {847 NULLFREE(account->description);848 if(strlen(value) > 0 && cs_malloc(&account->description, strlen(value)+1, -1)){849 cs_strncpy(account->description, value, strlen(value)+1);850 }851 return;852 }853 #endif854 855 if (!strcmp(token, "hostname")) {856 cs_strncpy((char *)account->dyndns, value, sizeof(account->dyndns));857 return;858 }859 860 887 if (!strcmp(token, "betatunnel")) { 861 888 if(strlen(value) == 0) { … … 868 895 } 869 896 870 if (!strcmp(token, "uniq")) {871 account->uniq = strToIntVal(value, 0);872 return;873 }874 875 #ifdef CS_CACHEEX876 if (!strcmp(token, "cacheex")) {877 account->cacheex = strToIntVal(value, 0);878 return;879 }880 881 if (!strcmp(token, "cacheex_maxhop")) {882 account->cacheex_maxhop = strToIntVal(value, 0);883 return;884 }885 #endif886 887 897 if (!strcmp(token, "sleep")) { 888 898 account->tosleep = strToIntVal(value, cfg.tosleep); … … 890 900 } 891 901 892 if (!strcmp(token, "sleepsend")) {893 uint32_t tmp = strToUIntVal(value, 0);894 if (tmp > 0xFF)895 account->c35_sleepsend = 0xFF;896 else account->c35_sleepsend = tmp;897 return;898 }899 900 902 if (!strcmp(token, "monlevel")) { 901 903 account->monlvl = strToIntVal(value, 0); … … 903 905 } 904 906 905 if (!strcmp(token, "caid")) {906 if(strlen(value) == 0) {907 clear_caidtab(&account->ctab);908 return;909 } else {910 chk_caidtab(value, &account->ctab);911 return;912 }913 }914 915 if (!strcmp(token, "disabled")) {916 account->disabled = strToIntVal(value, 0);917 return;918 }919 920 907 if (!strcmp(token, "suppresscmd08")) { 921 908 account->c35_suppresscmd08 = strToIntVal(value, 0); … … 923 910 } 924 911 925 #ifdef MODULE_CCCAM926 if (!strcmp(token, "cccmaxhops")) {927 account->cccmaxhops = strToIntVal(value, DEFAULT_CC_MAXHOP);928 return;929 }930 931 if (!strcmp(token, "cccreshare")) {932 account->cccreshare = strToIntVal(value, DEFAULT_CC_RESHARE);933 return;934 }935 936 if (!strcmp(token, "cccignorereshare")) {937 account->cccignorereshare = strToIntVal(value, DEFAULT_CC_IGNRSHR);938 return;939 }940 941 if (!strcmp(token, "cccstealth")) {942 account->cccstealth = strToIntVal(value, DEFAULT_CC_STEALTH);943 return;944 }945 #endif946 947 912 if (!strcmp(token, "keepalive")) { 948 account->ncd_keepalive = strToIntVal(value, DEFAULT_NCD_KEEPALIVE);913 account->ncd_keepalive = strToIntVal(value, cfg.ncd_keepalive); 949 914 return; 950 915 } … … 1056 1021 } 1057 1022 1058 if (!strcmp(token, "failban")) {1059 account->failban = strToIntVal(value, 0);1060 return;1061 }1062 1063 #ifdef CS_ANTICASC1064 if( !strcmp(token, "numusers") ) {1065 account->ac_users = strToIntVal(value, DEFAULT_AC_USERS);1066 if ( account->ac_users < -1 )1067 account->ac_users = DEFAULT_AC_USERS;1068 return;1069 }1070 1071 if( !strcmp(token, "penalty") ) {1072 account->ac_penalty = strToIntVal(value, DEFAULT_AC_PENALTY);1073 if ( account->ac_penalty < -1 )1074 account->ac_penalty = DEFAULT_AC_PENALTY;1075 return;1076 }1077 #endif1078 1079 1023 if (token[0] != '#') 1080 1024 fprintf(stderr, "Warning: keyword '%s' in account section not recognized\n",token); … … 1131 1075 for (account=cfg.account; (account) ; account=account->next){ 1132 1076 fprintf(f,"[account]\n"); 1133 fprintf_conf(f, "user", "%s\n", account->usr); 1134 fprintf_conf(f, "pwd", "%s\n", account->pwd); 1135 #ifdef WEBIF 1136 if (account->description || cfg.http_full_cfg) 1137 fprintf_conf(f, "description", "%s\n", account->description?account->description:""); 1138 #endif 1139 if (account->disabled || cfg.http_full_cfg) 1140 fprintf_conf(f, "disabled", "%d\n", account->disabled); 1077 config_list_apply_fixups(account_opts, account); 1078 config_list_save(f, account_opts, account, cfg.http_full_cfg); 1141 1079 1142 1080 if (account->expirationdate || cfg.http_full_cfg) { … … 1170 1108 } 1171 1109 1172 if (account->dyndns[0] || cfg.http_full_cfg)1173 fprintf_conf(f, "hostname", "%s\n", account->dyndns);1174 1175 if (account->uniq || cfg.http_full_cfg)1176 fprintf_conf(f, "uniq", "%d\n", account->uniq);1177 1178 #ifdef CS_CACHEEX1179 if (account->cacheex || cfg.http_full_cfg)1180 fprintf_conf(f, "cacheex", "%d\n", account->cacheex);1181 1182 if (account->cacheex_maxhop || cfg.http_full_cfg)1183 fprintf_conf(f, "cacheex_maxhop", "%d\n", account->cacheex_maxhop);1184 #endif1185 1186 1110 if (account->tosleep != cfg.tosleep || cfg.http_full_cfg) 1187 1111 fprintf_conf(f, "sleep", "%d\n", account->tosleep); … … 1213 1137 } 1214 1138 1215 //CAID1216 if (account->ctab.caid[0] || cfg.http_full_cfg) {1217 value = mk_t_caidtab(&account->ctab);1218 fprintf_conf(f, "caid", "%s\n", value);1219 free_mk_t(value);1220 }1221 1222 1139 //betatunnel 1223 1140 if (account->ttab.bt_caidfrom[0] || cfg.http_full_cfg) { … … 1251 1168 fprintf_conf(f, "suppresscmd08", "%d\n", account->c35_suppresscmd08); 1252 1169 1253 #ifdef MODULE_CCCAM1254 if (account->cccmaxhops != DEFAULT_CC_MAXHOP || cfg.http_full_cfg)1255 fprintf_conf(f, "cccmaxhops", "%d\n", account->cccmaxhops);1256 1257 if (account->cccreshare != DEFAULT_CC_RESHARE || cfg.http_full_cfg)1258 fprintf_conf(f, "cccreshare", "%d\n", account->cccreshare);1259 1260 if (account->cccignorereshare != DEFAULT_CC_IGNRSHR || cfg.http_full_cfg)1261 fprintf_conf(f, "cccignorereshare", "%d\n", account->cccignorereshare);1262 1263 if (account->cccstealth != DEFAULT_CC_STEALTH || cfg.http_full_cfg)1264 fprintf_conf(f, "cccstealth", "%d\n", account->cccstealth);1265 #endif1266 1267 if (account->c35_sleepsend || cfg.http_full_cfg)1268 fprintf_conf(f, "sleepsend", "%u\n", account->c35_sleepsend);1269 1270 if (account->failban || cfg.http_full_cfg)1271 fprintf_conf(f, "failban", "%d\n", account->failban);1272 1273 if ((account->ncd_keepalive != DEFAULT_NCD_KEEPALIVE) || cfg.http_full_cfg)1274 fprintf_conf(f, "keepalive", "%d\n", account->ncd_keepalive);1275 1276 #ifdef CS_ANTICASC1277 if (account->ac_users != DEFAULT_AC_USERS || cfg.http_full_cfg)1278 fprintf_conf(f, "numusers", "%d\n", account->ac_users);1279 if (account->ac_penalty != DEFAULT_AC_PENALTY || cfg.http_full_cfg)1280 fprintf_conf(f, "penalty", "%d\n", account->ac_penalty);1281 #endif1282 1170 fputc((int)'\n', f); 1283 1171 } … … 1747 1635 1748 1636 account = ptr; 1637 config_list_set_defaults(account_opts, account); 1749 1638 account->allowedtimeframe[0] = 0; 1750 1639 account->allowedtimeframe[1] = 0; … … 1755 1644 account->ncd_keepalive = cfg.ncd_keepalive; 1756 1645 account->firstlogin = 0; 1757 #ifdef MODULE_CCCAM1758 account->cccmaxhops = DEFAULT_CC_MAXHOP;1759 account->cccreshare = DEFAULT_CC_RESHARE; // default: use global cfg1760 account->cccignorereshare = DEFAULT_CC_IGNRSHR; // default: use global cfg1761 account->cccstealth = DEFAULT_CC_STEALTH; // default: use global cfg1762 #endif1763 #ifdef CS_ANTICASC1764 account->ac_users = DEFAULT_AC_USERS; // use ac_users global value1765 account->ac_penalty = DEFAULT_AC_PENALTY; // use ac_penalty global value1766 #endif1767 1646 for (i = 1; i < CS_MAXCAIDTAB; account->ctab.mask[i++] = 0xffff); 1768 1647 for (i = 1; i < CS_MAXTUNTAB; account->ttab.bt_srvid[i++] = 0x0000);
Note:
See TracChangeset
for help on using the changeset viewer.