Changeset 441 for EcnlProtoTool/trunk/ntshell/webserver
- Timestamp:
- Jul 10, 2020, 9:09:25 PM (4 years ago)
- Location:
- EcnlProtoTool/trunk/ntshell/webserver
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.c
r436 r441 63 63 #endif /* NULL */ 64 64 65 extern ntstdio_t ntstdio;65 extern ntstdio_t *ntstdio; 66 66 67 67 /*-----------------------------------------------------------------------------------*/ … … 89 89 } 90 90 else { 91 ntstdio_printf( &ntstdio, "%s/%s\n", path, fn);91 ntstdio_printf(ntstdio, "%s/%s\n", path, fn); 92 92 } 93 93 } … … 114 114 if ((res = f_open(fd, name, FA_OPEN_EXISTING | FA_READ)) != FR_OK) { 115 115 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); 117 117 return 0; 118 118 } 119 119 120 120 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); 122 122 return 0; 123 123 } … … 132 132 133 133 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); 135 135 return 0; 136 136 } … … 139 139 file->len = fd->fsize; 140 140 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); 142 142 143 143 return 1; … … 158 158 159 159 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); 161 161 return 0; 162 162 } … … 165 165 file->len = 0; 166 166 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); 168 168 169 169 return 1; … … 179 179 180 180 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); 182 182 return 0; 183 183 } 184 184 185 185 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); 187 187 } 188 188 189 189 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); 195 195 196 196 return rlen; … … 206 206 207 207 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); 209 209 return 0; 210 210 } 211 211 212 212 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); 214 214 } 215 215 216 216 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); 218 218 return 0; 219 219 } … … 222 222 file->len += rlen; 223 223 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); 225 225 226 226 return rlen; … … 234 234 235 235 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); 237 237 return 0; 238 238 } -
EcnlProtoTool/trunk/ntshell/webserver/httpd.c
r436 r441 59 59 #define FALSE 0 60 60 61 extern ntstdio_t ntstdio;61 extern ntstdio_t *ntstdio; 62 62 SYSTIM httpd_time; 63 63 struct httpd_state *uploding; … … 65 65 66 66 /* TCP 送受信ウィンドバッファ */ 67 #ifdef SUPPORT_INET6 68 uint8_t tcp6_swbuf1[TCP_SWBUF_SIZE]; 69 uint8_t tcp6_rwbuf1[TCP_RWBUF_SIZE]; 70 uint8_t tcp6_swbuf2[TCP_SWBUF_SIZE]; 71 uint8_t tcp6_rwbuf2[TCP_RWBUF_SIZE]; 72 #endif 73 74 #ifdef SUPPORT_INET4 67 75 uint8_t tcp_swbuf1[TCP_SWBUF_SIZE]; 68 76 uint8_t tcp_rwbuf1[TCP_RWBUF_SIZE]; 69 77 uint8_t tcp_swbuf2[TCP_SWBUF_SIZE]; 70 78 uint8_t tcp_rwbuf2[TCP_RWBUF_SIZE]; 79 #endif 71 80 72 81 #define ISO_nl 0x0a … … 325 334 // アップロード先はSDカード 326 335 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); 328 337 if (!httpd_fs_create(s->filename, &s->file)) { 329 338 goto error; … … 333 342 } 334 343 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); 336 345 goto error; 337 346 } … … 365 374 366 375 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" 368 377 "on last on_body callback call " 369 378 "but it doesn't! ***\n\n"); … … 378 387 379 388 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); 381 390 httpd_fs_close(&s->file); 382 391 memset(&s->file, 0, sizeof(s->file)); … … 403 412 struct httpd_state *s = get_context(p); 404 413 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" 406 415 "value in both on_message_complete and on_headers_complete " 407 416 "but it doesn't! ***\n\n"); … … 412 421 http_body_is_final(p) && 413 422 !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" 415 424 "on last on_body callback call " 416 425 "but it doesn't! ***\n\n"); … … 484 493 slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR); 485 494 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); 487 496 s->state = STATE_CLOSING; 488 497 break; … … 497 506 len = httpd_fs_read(&s->file, buf, len); 498 507 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); 500 509 break; 501 510 } … … 505 514 506 515 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); 508 517 s->state = STATE_CLOSING; 509 518 break; … … 511 520 } 512 521 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); 514 523 httpd_fs_close(&s->file); 515 524 s->file.len = 0; … … 527 536 slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR); 528 537 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); 530 539 s->state = STATE_CLOSING; 531 540 break; … … 544 553 545 554 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); 547 556 s->state = STATE_CLOSING; 548 557 break; … … 690 699 break; 691 700 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); 693 702 if (!httpd_fs_open(s->filename, sizeof(s->message.request_url), &s->file)) { 694 703 s->filename = NULL; … … 704 713 break; 705 714 case OUT_STATE_WAIT_POST_BODY: 706 //ntstdio_printf( &ntstdio, "wait post body\n");715 //ntstdio_printf(ntstdio, "wait post body\n"); 707 716 s->out.wait = true; 708 717 break; 709 718 case OUT_STATE_BODY_RECEIVED: 710 //ntstdio_printf( &ntstdio, "body received\n");719 //ntstdio_printf(ntstdio, "body received\n"); 711 720 s->out.statushdr = http_header_200; 712 721 s->out.state = OUT_STATE_SEND_HEADER; 713 722 break; 714 723 case OUT_STATE_SEND_HEADER: 715 //ntstdio_printf( &ntstdio, "send header\n");724 //ntstdio_printf(ntstdio, "send header\n"); 716 725 send_headers(s, s->out.statushdr); 717 726 break; 718 727 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); 720 729 send_file(s); 721 730 break; 722 731 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); 724 733 send_data(s); 725 734 break; 726 735 case OUT_STATE_SEND_END: 727 //ntstdio_printf( &ntstdio, "send end\n");736 //ntstdio_printf(ntstdio, "send end\n"); 728 737 s->out.wait = true; 729 738 if (s->message.should_keep_alive && s->reset == 0) { … … 783 792 slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR); 784 793 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); 786 795 return; 787 796 } … … 847 856 //} 848 857 } 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); 850 859 uploding = NULL; 851 860 s->state = STATE_CLOSING; … … 855 864 tcp_rel_buf(s->cepid, done); 856 865 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); 858 867 uploding = NULL; 859 868 s->state = STATE_CLOSING; … … 880 889 break; 881 890 } 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); 883 892 s->state = STATE_CLOSING; 884 893 break; … … 918 927 919 928 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); 921 930 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); 923 932 924 933 return E_PAR; … … 936 945 ret2 = get_tim(&httpd_time); 937 946 if (ret2 != E_OK) { 938 ntstdio_printf( &ntstdio, "get_tim\n");947 ntstdio_printf(ntstdio, "get_tim\n"); 939 948 return; 940 949 } … … 944 953 memset(&s->dst, 0, sizeof(s->dst)); 945 954 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); 947 956 tslp_tsk(100 * 1000); // TODO 948 957 s->state = STATE_CLOSING; … … 950 959 } 951 960 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); 953 962 memset(&s->in, 0, sizeof(s->in)); 954 963 memset(&s->out, 0, sizeof(s->out)); … … 965 974 break; 966 975 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); 968 977 tcp_sht_cep(s->cepid); 969 978 tcp_cls_cep(s->cepid, TMO_FEVR); -
EcnlProtoTool/trunk/ntshell/webserver/httpd.h
r436 r441 57 57 /* TCP 送受信ウィンドバッファサイズ */ 58 58 59 #define TCP_SWBUF_SIZE 51260 #define TCP_RWBUF_SIZE 51259 #define TCP_SWBUF_SIZE 1024 60 #define TCP_RWBUF_SIZE 1024 61 61 62 62 /* … … 66 66 67 67 /* TCP 送受信ウィンドバッファ */ 68 68 #ifdef SUPPORT_INET6 69 extern uint8_t tcp6_swbuf1[]; 70 extern uint8_t tcp6_rwbuf1[]; 71 extern uint8_t tcp6_swbuf2[]; 72 extern uint8_t tcp6_rwbuf2[]; 73 #endif 74 75 #ifdef SUPPORT_INET4 69 76 extern uint8_t tcp_swbuf1[]; 70 77 extern uint8_t tcp_rwbuf1[]; 71 78 extern uint8_t tcp_swbuf2[]; 72 79 extern uint8_t tcp_rwbuf2[]; 80 #endif 73 81 74 82 /* HTTPサーバータスク */ -
EcnlProtoTool/trunk/ntshell/webserver/tinet_httpd.cfg
r436 r441 62 62 TCP6_CRE_CEP (TCP6_CEPID1, { 63 63 0, 64 tcp _swbuf1,64 tcp6_swbuf1, 65 65 TCP_SWBUF_SIZE, 66 tcp _rwbuf1,66 tcp6_rwbuf1, 67 67 TCP_RWBUF_SIZE, 68 68 (FP)callback_nblk_tcp … … 71 71 TCP6_CRE_CEP (TCP6_CEPID2, { 72 72 0, 73 tcp _swbuf2,73 tcp6_swbuf2, 74 74 TCP_SWBUF_SIZE, 75 tcp _rwbuf2,75 tcp6_rwbuf2, 76 76 TCP_RWBUF_SIZE, 77 77 (FP)callback_nblk_tcp
Note:
See TracChangeset
for help on using the changeset viewer.