Ignore:
Timestamp:
Jul 10, 2020, 9:09:25 PM (4 years ago)
Author:
coas-nagasima
Message:

NTShellタスクを更新

Location:
EcnlProtoTool/trunk/ntshell/webserver
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.c

    r436 r441  
    6363#endif /* NULL */
    6464
    65 extern ntstdio_t ntstdio;
     65extern ntstdio_t *ntstdio;
    6666
    6767/*-----------------------------------------------------------------------------------*/
     
    8989                        }
    9090                        else {
    91                                 ntstdio_printf(&ntstdio, "%s/%s\n", path, fn);
     91                                ntstdio_printf(ntstdio, "%s/%s\n", path, fn);
    9292                        }
    9393                }
     
    114114        if ((res = f_open(fd, name, FA_OPEN_EXISTING | FA_READ)) != FR_OK) {
    115115                if ((res = f_opendir(&dir, name)) != FR_OK) {
    116                         ntstdio_printf(&ntstdio, "f_opendir(%s) => %d\n", name, res);
     116                        ntstdio_printf(ntstdio, "f_opendir(%s) => %d\n", name, res);
    117117                        return 0;
    118118                }
    119119
    120120                if ((res = f_readdir(&dir, &fno)) != FR_OK) {
    121                         ntstdio_printf(&ntstdio, "f_readdir(%s) => %d\n", name, res);
     121                        ntstdio_printf(ntstdio, "f_readdir(%s) => %d\n", name, res);
    122122                        return 0;
    123123                }
     
    132132
    133133                if (res != FR_OK) {
    134                         ntstdio_printf(&ntstdio, "f_open(%s) => %d %x\n", name, res, fno.fattrib);
     134                        ntstdio_printf(ntstdio, "f_open(%s) => %d %x\n", name, res, fno.fattrib);
    135135                        return 0;
    136136                }
     
    139139        file->len = fd->fsize;
    140140
    141         //ntstdio_printf(&ntstdio, "httpd_fs_open(%s) %d\n", name, file->len);
     141        //ntstdio_printf(ntstdio, "httpd_fs_open(%s) %d\n", name, file->len);
    142142
    143143        return 1;
     
    158158
    159159        if ((res = f_open(fd, name, FA_CREATE_ALWAYS | FA_WRITE)) != FR_OK) {
    160                 ntstdio_printf(&ntstdio, "f_open(%s) => %d\n", name, res);
     160                ntstdio_printf(ntstdio, "f_open(%s) => %d\n", name, res);
    161161                return 0;
    162162        }
     
    165165        file->len = 0;
    166166
    167         //ntstdio_printf(&ntstdio, "httpd_fs_create(%s) %d\n", file->name, file->len);
     167        //ntstdio_printf(ntstdio, "httpd_fs_create(%s) %d\n", file->name, file->len);
    168168
    169169        return 1;
     
    179179
    180180        if ((ret = f_lseek(fd, file->pos)) != FR_OK) {
    181                 ntstdio_printf(&ntstdio, "f_lseek(%s, %d) => %d\n", file->name, file->pos, ret);
     181                ntstdio_printf(ntstdio, "f_lseek(%s, %d) => %d\n", file->name, file->pos, ret);
    182182                return 0;
    183183        }
    184184
    185185        if (file->pos != fd->fptr) {
    186                 ntstdio_printf(&ntstdio, "f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr);
     186                ntstdio_printf(ntstdio, "f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr);
    187187        }
    188188
    189189        if ((ret = f_read(fd, dst, len, &rlen)) != FR_OK) {
    190                 ntstdio_printf(&ntstdio, "f_read(%s, 0x%p, %d) => %d\n", file->name, dst, len, ret);
    191                 return 0;
    192         }
    193 
    194         //ntstdio_printf(&ntstdio, "httpd_fs_read(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);
     190                ntstdio_printf(ntstdio, "f_read(%s, 0x%p, %d) => %d\n", file->name, dst, len, ret);
     191                return 0;
     192        }
     193
     194        //ntstdio_printf(ntstdio, "httpd_fs_read(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);
    195195
    196196        return rlen;
     
    206206
    207207        if ((ret = f_lseek(fd, file->pos)) != FR_OK) {
    208                 ntstdio_printf(&ntstdio, "f_lseek(%s, %d) => %d\n", file->name, file->pos, ret);
     208                ntstdio_printf(ntstdio, "f_lseek(%s, %d) => %d\n", file->name, file->pos, ret);
    209209                return 0;
    210210        }
    211211
    212212        if (file->pos != fd->fptr) {
    213                 ntstdio_printf(&ntstdio, "f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr);
     213                ntstdio_printf(ntstdio, "f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr);
    214214        }
    215215
    216216        if ((ret = f_write(fd, src, len, &rlen)) != FR_OK) {
    217                 ntstdio_printf(&ntstdio, "f_write(%s, 0x%p, %d) => %d\n", file->name, src, len, ret);
     217                ntstdio_printf(ntstdio, "f_write(%s, 0x%p, %d) => %d\n", file->name, src, len, ret);
    218218                return 0;
    219219        }
     
    222222        file->len += rlen;
    223223
    224         //ntstdio_printf(&ntstdio, "httpd_fs_write(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);
     224        //ntstdio_printf(ntstdio, "httpd_fs_write(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);
    225225
    226226        return rlen;
     
    234234
    235235        if ((ret = f_close(fd)) != FR_OK) {
    236                 ntstdio_printf(&ntstdio, "f_close(%s) => %d\n", file->name, ret);
     236                ntstdio_printf(ntstdio, "f_close(%s) => %d\n", file->name, ret);
    237237                return 0;
    238238        }
  • EcnlProtoTool/trunk/ntshell/webserver/httpd.c

    r436 r441  
    5959#define FALSE 0
    6060
    61 extern ntstdio_t ntstdio;
     61extern ntstdio_t *ntstdio;
    6262SYSTIM httpd_time;
    6363struct httpd_state *uploding;
     
    6565
    6666/*  TCP 送受信ウィンドバッファ  */
     67#ifdef SUPPORT_INET6
     68uint8_t tcp6_swbuf1[TCP_SWBUF_SIZE];
     69uint8_t tcp6_rwbuf1[TCP_RWBUF_SIZE];
     70uint8_t tcp6_swbuf2[TCP_SWBUF_SIZE];
     71uint8_t tcp6_rwbuf2[TCP_RWBUF_SIZE];
     72#endif
     73
     74#ifdef SUPPORT_INET4
    6775uint8_t tcp_swbuf1[TCP_SWBUF_SIZE];
    6876uint8_t tcp_rwbuf1[TCP_RWBUF_SIZE];
    6977uint8_t tcp_swbuf2[TCP_SWBUF_SIZE];
    7078uint8_t tcp_rwbuf2[TCP_RWBUF_SIZE];
     79#endif
    7180
    7281#define ISO_nl      0x0a
     
    325334                        // アップロード先はSDカード
    326335                        s->filename[0] = '1';
    327                         ntstdio_printf(&ntstdio, "create:    %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
     336                        ntstdio_printf(ntstdio, "create:    %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
    328337                        if (!httpd_fs_create(s->filename, &s->file)) {
    329338                                goto error;
     
    333342                }
    334343                else if (ntlibc_strcmp(s->filename, uploding->filename) == 0) {
    335                         ntstdio_printf(&ntstdio, "collision: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
     344                        ntstdio_printf(ntstdio, "collision: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
    336345                        goto error;
    337346                }
     
    365374
    366375        if (s->message.body_is_final) {
    367                 ntstdio_printf(&ntstdio, "\n\n *** Error http_body_is_final() should return 1 \n"
     376                ntstdio_printf(ntstdio, "\n\n *** Error http_body_is_final() should return 1 \n"
    368377                        "on last on_body callback call "
    369378                        "but it doesn't! ***\n\n");
     
    378387
    379388        if (s->message.body_is_final) {
    380                 ntstdio_printf(&ntstdio, "close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
     389                ntstdio_printf(ntstdio, "close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
    381390                httpd_fs_close(&s->file);
    382391                memset(&s->file, 0, sizeof(s->file));
     
    403412        struct httpd_state *s = get_context(p);
    404413        if (s->message.should_keep_alive != http_should_keep_alive(p)) {
    405                 ntstdio_printf(&ntstdio, "\n\n *** Error http_should_keep_alive() should have same \n"
     414                ntstdio_printf(ntstdio, "\n\n *** Error http_should_keep_alive() should have same \n"
    406415                        "value in both on_message_complete and on_headers_complete "
    407416                        "but it doesn't! ***\n\n");
     
    412421                http_body_is_final(p) &&
    413422                !s->message.body_is_final) {
    414                 ntstdio_printf(&ntstdio, "\n\n *** Error http_body_is_final() should return 1 \n"
     423                ntstdio_printf(ntstdio, "\n\n *** Error http_body_is_final() should return 1 \n"
    415424                        "on last on_body callback call "
    416425                        "but it doesn't! ***\n\n");
     
    484493                slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
    485494                if (slen < 0) {
    486                         ntstdio_printf(&ntstdio, "send_file#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
     495                        ntstdio_printf(ntstdio, "send_file#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
    487496                        s->state = STATE_CLOSING;
    488497                        break;
     
    497506                len = httpd_fs_read(&s->file, buf, len);
    498507                if (len <= 0) {
    499                         ntstdio_printf(&ntstdio, "send_file#httpd_fs_read(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, len);
     508                        ntstdio_printf(ntstdio, "send_file#httpd_fs_read(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, len);
    500509                        break;
    501510                }
     
    505514
    506515                if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) {
    507                         ntstdio_printf(&ntstdio, "send_file#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
     516                        ntstdio_printf(ntstdio, "send_file#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
    508517                        s->state = STATE_CLOSING;
    509518                        break;
     
    511520        }
    512521
    513         ntstdio_printf(&ntstdio, "close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
     522        ntstdio_printf(ntstdio, "close:     %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
    514523        httpd_fs_close(&s->file);
    515524        s->file.len = 0;
     
    527536                slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
    528537                if (slen < 0) {
    529                         ntstdio_printf(&ntstdio, "send_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
     538                        ntstdio_printf(ntstdio, "send_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
    530539                        s->state = STATE_CLOSING;
    531540                        break;
     
    544553
    545554                if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) {
    546                         ntstdio_printf(&ntstdio, "send_data#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
     555                        ntstdio_printf(ntstdio, "send_data#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
    547556                        s->state = STATE_CLOSING;
    548557                        break;
     
    690699                break;
    691700        case OUT_STATE_OPEN_GET_FILE:
    692                 ntstdio_printf(&ntstdio, "open:      %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
     701                ntstdio_printf(ntstdio, "open:      %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);
    693702                if (!httpd_fs_open(s->filename, sizeof(s->message.request_url), &s->file)) {
    694703                        s->filename = NULL;
     
    704713                break;
    705714        case OUT_STATE_WAIT_POST_BODY:
    706                 //ntstdio_printf(&ntstdio, "wait post body\n");
     715                //ntstdio_printf(ntstdio, "wait post body\n");
    707716                s->out.wait = true;
    708717                break;
    709718        case OUT_STATE_BODY_RECEIVED:
    710                 //ntstdio_printf(&ntstdio, "body received\n");
     719                //ntstdio_printf(ntstdio, "body received\n");
    711720                s->out.statushdr = http_header_200;
    712721                s->out.state = OUT_STATE_SEND_HEADER;
    713722                break;
    714723        case OUT_STATE_SEND_HEADER:
    715                 //ntstdio_printf(&ntstdio, "send header\n");
     724                //ntstdio_printf(ntstdio, "send header\n");
    716725                send_headers(s, s->out.statushdr);
    717726                break;
    718727        case OUT_STATE_SEND_FILE:
    719                 //ntstdio_printf(&ntstdio, "send file %d\n", s->file.len);
     728                //ntstdio_printf(ntstdio, "send file %d\n", s->file.len);
    720729                send_file(s);
    721730                break;
    722731        case OUT_STATE_SEND_DATA:
    723                 //ntstdio_printf(&ntstdio, "send data %d\n", s->response_len);
     732                //ntstdio_printf(ntstdio, "send data %d\n", s->response_len);
    724733                send_data(s);
    725734                break;
    726735        case OUT_STATE_SEND_END:
    727                 //ntstdio_printf(&ntstdio, "send end\n");
     736                //ntstdio_printf(ntstdio, "send end\n");
    728737                s->out.wait = true;
    729738                if (s->message.should_keep_alive && s->reset == 0) {
     
    783792        slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR);
    784793        if (slen < 0) {
    785                 ntstdio_printf(&ntstdio, "send_ws_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
     794                ntstdio_printf(ntstdio, "send_ws_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);
    786795                return;
    787796        }
     
    847856                                //}
    848857                        }
    849                         ntstdio_printf(&ntstdio, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
     858                        ntstdio_printf(ntstdio, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
    850859                        uploding = NULL;
    851860                        s->state = STATE_CLOSING;
     
    855864                tcp_rel_buf(s->cepid, done);
    856865                if (s->parser.http_errno != HPE_OK) {
    857                         ntstdio_printf(&ntstdio, "http_parser error %s.%d => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno);
     866                        ntstdio_printf(ntstdio, "http_parser error %s.%d => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno);
    858867                        uploding = NULL;
    859868                        s->state = STATE_CLOSING;
     
    880889                                        break;
    881890                                }
    882                                 ntstdio_printf(&ntstdio, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
     891                                ntstdio_printf(ntstdio, "handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len);
    883892                                s->state = STATE_CLOSING;
    884893                                break;
     
    918927
    919928        if (s == NULL)
    920                 ntstdio_printf(&ntstdio, "callback_nblk_tcp(%d, %d)\n", fncd, cepid);
     929                ntstdio_printf(ntstdio, "callback_nblk_tcp(%d, %d)\n", fncd, cepid);
    921930        else
    922                 ntstdio_printf(&ntstdio, "callback_nblk_tcp(%d, %s.%d)\n", fncd, s->addr, ((T_IPV4EP *)s->dst)->portno);
     931                ntstdio_printf(ntstdio, "callback_nblk_tcp(%d, %s.%d)\n", fncd, s->addr, ((T_IPV4EP *)s->dst)->portno);
    923932
    924933        return E_PAR;
     
    936945                ret2 = get_tim(&httpd_time);
    937946                if (ret2 != E_OK) {
    938                         ntstdio_printf(&ntstdio, "get_tim\n");
     947                        ntstdio_printf(ntstdio, "get_tim\n");
    939948                        return;
    940949                }
     
    944953                        memset(&s->dst, 0, sizeof(s->dst));
    945954                        if ((ret = tcp_acp_cep(s->cepid, TCP_REPID, (T_IPV4EP *)s->dst, TMO_FEVR)) != E_OK) {
    946                                 ntstdio_printf(&ntstdio, "tcp_acp_cep(%d) => %d\n", s->cepid, ret);
     955                                ntstdio_printf(ntstdio, "tcp_acp_cep(%d) => %d\n", s->cepid, ret);
    947956                                tslp_tsk(100 * 1000);   // TODO
    948957                                s->state = STATE_CLOSING;
     
    950959                        }
    951960                        IP2STR(s->addr, &((T_IPV4EP *)s->dst)->ipaddr);
    952                         ntstdio_printf(&ntstdio, "connected: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
     961                        ntstdio_printf(ntstdio, "connected: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
    953962                        memset(&s->in, 0, sizeof(s->in));
    954963                        memset(&s->out, 0, sizeof(s->out));
     
    965974                        break;
    966975                case STATE_CLOSING:
    967                         ntstdio_printf(&ntstdio, "close:     %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
     976                        ntstdio_printf(ntstdio, "close:     %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);
    968977                        tcp_sht_cep(s->cepid);
    969978                        tcp_cls_cep(s->cepid, TMO_FEVR);
  • EcnlProtoTool/trunk/ntshell/webserver/httpd.h

    r436 r441  
    5757 /*  TCP 送受信ウィンドバッファサイズ  */
    5858
    59 #define TCP_SWBUF_SIZE  512
    60 #define TCP_RWBUF_SIZE  512
     59#define TCP_SWBUF_SIZE  1024
     60#define TCP_RWBUF_SIZE  1024
    6161
    6262/*
     
    6666
    6767 /*  TCP 送受信ウィンドバッファ  */
    68 
     68#ifdef SUPPORT_INET6
     69extern uint8_t tcp6_swbuf1[];
     70extern uint8_t tcp6_rwbuf1[];
     71extern uint8_t tcp6_swbuf2[];
     72extern uint8_t tcp6_rwbuf2[];
     73#endif
     74
     75#ifdef SUPPORT_INET4
    6976extern uint8_t tcp_swbuf1[];
    7077extern uint8_t tcp_rwbuf1[];
    7178extern uint8_t tcp_swbuf2[];
    7279extern uint8_t tcp_rwbuf2[];
     80#endif
    7381
    7482/* HTTPサーバータスク */
  • EcnlProtoTool/trunk/ntshell/webserver/tinet_httpd.cfg

    r436 r441  
    6262TCP6_CRE_CEP (TCP6_CEPID1, {
    6363        0,
    64         tcp_swbuf1,
     64        tcp6_swbuf1,
    6565        TCP_SWBUF_SIZE,
    66         tcp_rwbuf1,
     66        tcp6_rwbuf1,
    6767        TCP_RWBUF_SIZE,
    6868        (FP)callback_nblk_tcp
     
    7171TCP6_CRE_CEP (TCP6_CEPID2, {
    7272        0,
    73         tcp_swbuf2,
     73        tcp6_swbuf2,
    7474        TCP_SWBUF_SIZE,
    75         tcp_rwbuf2,
     75        tcp6_rwbuf2,
    7676        TCP_RWBUF_SIZE,
    7777        (FP)callback_nblk_tcp
Note: See TracChangeset for help on using the changeset viewer.