Changeset 32610


Ignore:
Timestamp:
Jul 8, 2017, 1:50:13 PM (12 days ago)
Author:
brainslayer
Message:

easier handling by using just one pointer reference

Location:
src/router/httpd
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • src/router/httpd/ej.c

    r32588 r32610  
    229229                                        memcpy(&clone, stream, sizeof(webs));
    230230                                        global_handle = call(global_handle, func, &clone);
    231                                         stream->generate_key = clone.generate_key;
    232                                         stream->clone_wan_mac = clone.clone_wan_mac;
    233                                         stream->filter_id = clone.filter_id;
    234231                                        // restore pointers
    235232                                }
  • src/router/httpd/httpd.c

    r32607 r32610  
    136136#endif
    137137
    138 static int generate_key;
    139 static int clone_wan_mac;
    140 static int filter_id;
    141138#ifdef HAVE_REGISTER
    142139static int registered = -1;
     
    551548int ias_sid_valid(webs_t wp);
    552549#endif
    553 
     550static persistent_vars global_vars;
    554551#define LINE_LEN 10000
    555552static void *handle_request(void *arg)
     
    566563        char *line;
    567564        long method_type;
     565        conn_fp->p = &global_vars;
    568566
    569567#ifndef HAVE_MICRO
     
    576574        conn_fp->isregistered_real = registered_real;
    577575#endif
    578         conn_fp->generate_key = generate_key;
    579         conn_fp->clone_wan_mac = clone_wan_mac;
    580         conn_fp->filter_id = filter_id;
    581576        pthread_mutex_unlock(&httpd_mutex);
    582577#else
     
    585580        conn_fp->isregistered_real = registered_real;
    586581#endif
    587         conn_fp->generate_key = generate_key;
    588         conn_fp->clone_wan_mac = clone_wan_mac;
    589         conn_fp->filter_id = filter_id;
    590582
    591583#endif
     
    10691061        pthread_mutex_lock(&httpd_mutex);
    10701062        numthreads--;
    1071         generate_key = conn_fp->generate_key;
    1072         clone_wan_mac = conn_fp->clone_wan_mac;
    1073         filter_id = conn_fp->filter_id;
    10741063#ifdef HAVE_REGISTER
    10751064        registered = conn_fp->isregistered;
     
    10781067        pthread_mutex_unlock(&httpd_mutex);
    10791068#else
    1080         generate_key = conn_fp->generate_key;
    1081         clone_wan_mac = conn_fp->clone_wan_mac;
    1082         filter_id = conn_fp->filter_id;
    10831069#ifdef HAVE_REGISTER
    10841070        registered = conn_fp->isregistered;
  • src/router/httpd/httpd.h

    r32583 r32610  
    4343#define USE_LAN 0
    4444#define USE_WAN 1
     45
     46typedef struct {
     47//persistent
     48        int generate_key;
     49        int clone_wan_mac;
     50        int filter_id;
     51} persistent_vars;
     52
    4553
    4654typedef struct {
     
    8795        int isregistered_real;
    8896#endif
    89 //persistent
    90         int generate_key;
    91         int clone_wan_mac;
    92         int filter_id;
    93 
     97        persistent_vars *p;
    9498/* CGI hash table */
    9599        struct hsearch_data htab;
    96100} webs;
     101
    97102
    98103typedef webs *webs_t;
  • src/router/httpd/modules/base.c

    r32591 r32610  
    12711271        websDone(wp, 200);
    12721272
    1273         wp->generate_key = 0;
    12741273        wp->gozila_action = 0;
    1275         wp->clone_wan_mac = 0;
     1274        wp->p->generate_key = 0;
     1275        wp->p->clone_wan_mac = 0;
    12761276
    12771277        return 1;
  • src/router/httpd/validate/validators.c

    r32459 r32610  
    25542554                ip_range0_1, ip_range0_2, ip_range0_3, ip_range0_4, ip_range0_5, ip_range0_6, ip_range0_7, ip_range1_0, ip_range1_1, ip_range1_2, ip_range1_3, ip_range1_4, ip_range1_5, ip_range1_6, ip_range1_7);
    25552555
    2556         snprintf(_filter_ip, sizeof(_filter_ip), "filter_ip_grp%d", wp->filter_id);
     2556        snprintf(_filter_ip, sizeof(_filter_ip), "filter_ip_grp%d", wp->p->filter_id);
    25572557        nvram_set(_filter_ip, buf);
    25582558
    25592559        // snprintf(_filter_rule, sizeof(_filter_rule), "filter_rule%s",
    2560         // wp->filter_id);
     2560        // wp->p->filter_id);
    25612561        // snprintf(_filter_tod, sizeof(_filter_tod), "filter_tod%s",
    2562         // wp->filter_id);
     2562        // wp->p->filter_id);
    25632563        // if(nvram_match(_filter_rule, "")){
    25642564        // nvram_set(_filter_rule, "$STAT:1$NAME:$$");
     
    26872687        }
    26882688
    2689         snprintf(_filter_port, sizeof(_filter_port), "filter_dport_grp%d", wp->filter_id);
     2689        snprintf(_filter_port, sizeof(_filter_port), "filter_dport_grp%d", wp->p->filter_id);
    26902690        nvram_set(_filter_port, buf);
    26912691
    26922692        // snprintf(_filter_rule, sizeof(_filter_rule), "filter_rule%s",
    2693         // wp->filter_id);
     2693        // wp->p->filter_id);
    26942694        // snprintf(_filter_tod, sizeof(_filter_tod), "filter_tod%s",
    2695         // wp->filter_id);
     2695        // wp->p->filter_id);
    26962696        // if(nvram_match(_filter_rule, "")){
    26972697        // nvram_set(_filter_rule, "$STAT:1$NAME:$$");
     
    27532753        }
    27542754
    2755         snprintf(_filter_mac, sizeof(_filter_mac), "filter_mac_grp%d", wp->filter_id);
     2755        snprintf(_filter_mac, sizeof(_filter_mac), "filter_mac_grp%d", wp->p->filter_id);
    27562756        nvram_set(_filter_mac, buf);
    27572757
    27582758        // snprintf(_filter_rule, sizeof(_filter_rule), "filter_rule%s",
    2759         // wp->filter_id);
     2759        // wp->p->filter_id);
    27602760        // snprintf(_filter_tod, sizeof(_filter_tod), "filter_tod%s",
    2761         // wp->filter_id);
     2761        // wp->p->filter_id);
    27622762        // if(nvram_match(_filter_rule, "")){
    27632763        // nvram_set(_filter_rule, "$STAT:1$NAME:$$");
     
    28012801                strcat(buf, "<&nbsp;>");
    28022802
    2803         snprintf(filter_host, sizeof(filter_host), "filter_web_host%d", wp->filter_id);
     2803        snprintf(filter_host, sizeof(filter_host), "filter_web_host%d", wp->p->filter_id);
    28042804        nvram_set(filter_host, buf);
    28052805
     
    28222822                strcat(buf1, "<&nbsp;>");
    28232823
    2824         snprintf(filter_url, sizeof(filter_url), "filter_web_url%d", wp->filter_id);
     2824        snprintf(filter_url, sizeof(filter_url), "filter_web_url%d", wp->p->filter_id);
    28252825        nvram_set(filter_url, buf1);
    28262826        D("everything okay");
     
    29592959        D("validate_blocked_service");
    29602960        char filter[32];
    2961         sprintf(filter, "numfilterservice%d", wp->filter_id);
     2961        sprintf(filter, "numfilterservice%d", wp->p->filter_id);
    29622962        int numfilters = nvram_default_geti(filter, 4);
    29632963        for (i = 0; i < numfilters; i++) {
     
    29742974        }
    29752975
    2976         snprintf(port_grp, sizeof(port_grp), "filter_port_grp%d", wp->filter_id);
     2976        snprintf(port_grp, sizeof(port_grp), "filter_port_grp%d", wp->p->filter_id);
    29772977        nvram_set(port_grp, buf);
    29782978        D("right");
     
    29892989        p2p = websGetVar(wp, "filter_p2p", NULL);
    29902990        if (p2p) {
    2991                 snprintf(port_grp, sizeof(port_grp), "filter_p2p_grp%d", wp->filter_id);
     2991                snprintf(port_grp, sizeof(port_grp), "filter_p2p_grp%d", wp->p->filter_id);
    29922992                nvram_set(port_grp, p2p);
    29932993        }
  • src/router/httpd/validate/webs.c

    r32606 r32610  
    9393void clone_mac(webs_t wp)
    9494{
    95         wp->clone_wan_mac = 1;
     95        wp->p->clone_wan_mac = 1;
    9696}
    9797
     
    274274
    275275        sprintf(buf, "%d:%d %d:%d %s", _start_hour, _start_min, _end_hour, _end_min, time);
    276         snprintf(filter_tod, sizeof(filter_tod), "filter_tod%d", wp->filter_id);
    277         snprintf(filter_tod_buf, sizeof(filter_tod_buf), "filter_tod_buf%d", wp->filter_id);
     276        snprintf(filter_tod, sizeof(filter_tod), "filter_tod%d", wp->p->filter_id);
     277        snprintf(filter_tod_buf, sizeof(filter_tod_buf), "filter_tod_buf%d", wp->p->filter_id);
    278278
    279279        nvram_set(filter_tod, buf);
     
    330330
    331331        validate_filter_tod(wp);
    332         wp->filter_id = atoi(f_id);
    333         snprintf(filter_buf, sizeof(filter_buf), "filter_rule%d", wp->filter_id);
     332        wp->p->filter_id = atoi(f_id);
     333        snprintf(filter_buf, sizeof(filter_buf), "filter_rule%d", wp->p->filter_id);
    334334
    335335        // Add $DENY to decide that users select Allow or Deny, if status is
     
    349349
    350350        if (f_id)
    351                 wp->filter_id = atoi(f_id);
     351                wp->p->filter_id = atoi(f_id);
    352352        else
    353                 wp->filter_id = 1;
     353                wp->p->filter_id = 1;
    354354
    355355        save_policy(wp);
     
    466466{
    467467        D("single delete policy");
    468         delete_policy(wp, wp->filter_id);
     468        delete_policy(wp, wp->p->filter_id);
    469469        D("okay");
    470470        return;
     
    586586        gen_key(wp, passphrase, atoi(bit), key64, key128);
    587587
    588         wp->generate_key = 1;
     588        wp->p->generate_key = 1;
    589589
    590590        if (atoi(bit) == 64) {
     
    18351835{
    18361836        char filter[32];
    1837         sprintf(filter, "numfilterservice%d", wp->filter_id);
     1837        sprintf(filter, "numfilterservice%d", wp->p->filter_id);
    18381838        int numfilters = nvram_default_geti(filter, 4);
    18391839        if (numfilters > 0)
     
    18471847{
    18481848        char filter[32];
    1849         sprintf(filter, "numfilterservice%d", wp->filter_id);
     1849        sprintf(filter, "numfilterservice%d", wp->p->filter_id);
    18501850        int numfilters = nvram_default_geti(filter, 4);
    18511851        numfilters++;
  • src/router/httpd/visuals/dd-wrt.c

    r32595 r32610  
    55655565{
    55665566        char filter[32];
    5567         sprintf(filter, "numfilterservice%d", wp->filter_id);
     5567        sprintf(filter, "numfilterservice%d", wp->p->filter_id);
    55685568        websWrite(wp, "%s", nvram_default_get(filter, "4"));
    55695569}
     
    55725572{
    55735573        char filter[32];
    5574         sprintf(filter, "numfilterservice%d", wp->filter_id);
     5574        sprintf(filter, "numfilterservice%d", wp->p->filter_id);
    55755575        int numfilters = nvram_default_geti(filter, 4);
    55765576        int i;
     
    55945594{
    55955595        char filter[32];
    5596         sprintf(filter, "numfilterservice%d", wp->filter_id);
     5596        sprintf(filter, "numfilterservice%d", wp->p->filter_id);
    55975597        int numfilters = nvram_default_geti(filter, 4);
    55985598        int i;
  • src/router/httpd/visuals/filters.c

    r32568 r32610  
    8181
    8282        D("filter_ip_get");
    83         snprintf(filter_ip, sizeof(filter_ip), "filter_ip_grp%d", wp->filter_id);
     83        snprintf(filter_ip, sizeof(filter_ip), "filter_ip_grp%d", wp->p->filter_id);
    8484
    8585        wordlist = nvram_safe_get(filter_ip);
     
    218218        char name[] = "filter_dport_grpXXX";
    219219
    220         sprintf(name, "filter_dport_grp%d", wp->filter_id);
     220        sprintf(name, "filter_dport_grp%d", wp->p->filter_id);
    221221        wordlist = nvram_safe_get(name);
    222222        temp = which;
     
    369369
    370370        D("filter mac get");
    371         snprintf(filter_mac, sizeof(filter_mac), "filter_mac_grp%d", wp->filter_id);
     371        snprintf(filter_mac, sizeof(filter_mac), "filter_mac_grp%d", wp->p->filter_id);
    372372
    373373        wordlist = nvram_safe_get(filter_mac);
     
    442442                        // value
    443443                }
    444                 websWrite(wp, "<option value=%d %s>%d ( %s ) </option>\n", i, (wp->filter_id == i ? "selected=\"selected\" " : ""), i, name);
     444                websWrite(wp, "<option value=%d %s>%d ( %s ) </option>\n", i, (wp->p->filter_id == i ? "selected=\"selected\" " : ""), i, name);
    445445        }
    446446        D("okay");
     
    460460
    461461        if (!strcmp(type, "f_id")) {
    462                 websWrite(wp, "%d", wp->filter_id);
     462                websWrite(wp, "%d", wp->p->filter_id);
    463463        } else if (!strcmp(type, "f_name")) {
    464464                char name[50] = "";
     
    466466                char *data = "";
    467467
    468                 snprintf(filter, sizeof(filter), "filter_rule%d", wp->filter_id);
     468                snprintf(filter, sizeof(filter), "filter_rule%d", wp->p->filter_id);
    469469                data = nvram_safe_get(filter);
    470470                if (strcmp(data, "")) {
     
    479479                char *data = "";
    480480
    481                 snprintf(filter, sizeof(filter), "filter_rule%d", wp->filter_id);
     481                snprintf(filter, sizeof(filter), "filter_rule%d", wp->p->filter_id);
    482482                data = nvram_safe_get(filter);
    483483                if (strcmp(data, "")) { // have data
     
    620620        }
    621621
    622         filter_tod_init(wp->filter_id);
     622        filter_tod_init(wp->p->filter_id);
    623623
    624624        if (!strcmp(type, "day_all_init")) {
     
    733733                char host[80];
    734734
    735                 snprintf(filter_host, sizeof(filter_host), "filter_web_host%d", wp->filter_id);
     735                snprintf(filter_host, sizeof(filter_host), "filter_web_host%d", wp->p->filter_id);
    736736                host_data = nvram_safe_get(filter_host);
    737737                if (!strcmp(host_data, ""))
     
    743743                char url[80];
    744744
    745                 snprintf(filter_url, sizeof(filter_url), "filter_web_url%d", wp->filter_id);
     745                snprintf(filter_url, sizeof(filter_url), "filter_web_url%d", wp->p->filter_id);
    746746                url_data = nvram_safe_get(filter_url);
    747747                if (!strcmp(url_data, ""))
     
    835835        D("ej_filter-init");
    836836        if (f_id)               // for first time enter this page and don't press apply.
    837                 wp->filter_id = atoi(f_id);
     837                wp->p->filter_id = atoi(f_id);
    838838        else
    839                 wp->filter_id = 1;
     839                wp->p->filter_id = 1;
    840840
    841841        return;
     
    934934                char name[80];
    935935
    936                 snprintf(filter_port, sizeof(filter_port), "filter_port_grp%d", wp->filter_id);
     936                snprintf(filter_port, sizeof(filter_port), "filter_port_grp%d", wp->p->filter_id);
    937937                port_data = nvram_safe_get(filter_port);
    938938                if (!strcmp(port_data, ""))
     
    944944                char *port_data, filter_port[] = "filter_p2p_grpXXX";
    945945
    946                 snprintf(filter_port, sizeof(filter_port), "filter_p2p_grp%d", wp->filter_id);
     946                snprintf(filter_port, sizeof(filter_port), "filter_p2p_grp%d", wp->p->filter_id);
    947947                port_data = nvram_safe_get(filter_port);
    948948                if (!strcmp(port_data, ""))
  • src/router/httpd/visuals/index.c

    r32568 r32610  
    7171        ejArgs(argc, argv, "%d", &which);
    7272
    73         if (wp->clone_wan_mac)
     73        if (wp->p->clone_wan_mac)
    7474                c = wp->http_client_mac;
    7575        else {
     
    9898{
    9999
    100         if (wp->clone_wan_mac)
     100        if (wp->p->clone_wan_mac)
    101101                websWrite(wp, arg);
    102102
  • src/router/httpd/visuals/setupassistant.c

    r32568 r32610  
    16341634
    16351635        // check for httpd post values
    1636         if (wp->gozila_action && !wp->generate_key) {
     1636        if (wp->gozila_action && !wp->p->generate_key) {
    16371637                char label[32];
    16381638                sprintf(label, "%s_%s", prefix, type);
     
    16401640        }
    16411641
    1642         if (wp->generate_key) {
     1642        if (wp->p->generate_key) {
    16431643                snprintf(wl_wep, sizeof(wl_wep), "%s_wep_gen", prefix);
    16441644        } else {
  • src/router/httpd/visuals/wireless.c

    r32563 r32610  
    554554        char wl_wep[] = "wlX.XX_wep_XXXXXX";
    555555
    556         if (wp->generate_key) {
     556        if (wp->p->generate_key) {
    557557                snprintf(wl_wep, sizeof(wl_wep), "%s_wep_gen", prefix);
    558558        } else {
Note: See TracChangeset for help on using the changeset viewer.