Changeset 442 for EcnlProtoTool/trunk/ntshell/webserver
- Timestamp:
- Jul 13, 2020, 8:07:55 PM (4 years ago)
- Location:
- EcnlProtoTool/trunk/ntshell/webserver
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/ntshell/webserver/base64.c
r331 r442 86 86 unsigned char *pdst; 87 87 int i, j = 0, k = 0; 88 size_t srcsiz = ntlibc_strlen((const char *)src);88 size_t srcsiz = strlen((const char *)src); 89 89 90 90 if ((srcsiz % 4) != 0) { -
EcnlProtoTool/trunk/ntshell/webserver/http_parser.c
r331 r442 2372 2372 if (u->field_set & (1 << UF_PORT)) { 2373 2373 /* Don't bother with endp; we've already validated the string */ 2374 unsigned long v = ntlibc_strtoul(buf + u->field_data[UF_PORT].off, NULL, 10);2374 unsigned long v = strtoul(buf + u->field_data[UF_PORT].off, NULL, 10); 2375 2375 2376 2376 /* Ports have a max value of 2^16 */ -
EcnlProtoTool/trunk/ntshell/webserver/httpd-fs.c
r441 r442 45 45 #include "kernel_cfg.h" 46 46 #include "syssvc/syslog.h" 47 #include "util/ntstdio.h"48 47 49 48 #ifndef _MSC_VER 50 49 #ifndef strcat_s 51 #define strcat_s(dst, dsz, src) ntlibc_strcat(dst, src)50 #define strcat_s(dst, dsz, src) strcat(dst, src) 52 51 #endif 53 52 #endif … … 62 61 #define NULL 0 63 62 #endif /* NULL */ 64 65 extern ntstdio_t *ntstdio;66 63 67 64 /*-----------------------------------------------------------------------------------*/ … … 77 74 res = f_opendir(&dir, path); 78 75 if (res == FR_OK) { 79 i = ntlibc_strlen(path);76 i = strlen(path); 80 77 for (;;) { 81 78 res = f_readdir(&dir, &fno); … … 83 80 fn = fno.fname; 84 81 if (fno.fattrib & AM_DIR) { 85 ntstdio_sprintf(&path[i], "0:/%s", fn);82 sprintf(&path[i], "0:/%s", fn); 86 83 res = scan_files(path, size); 87 84 if (res != FR_OK) break; … … 89 86 } 90 87 else { 91 ntstdio_printf(ntstdio,"%s/%s\n", path, fn);88 printf("%s/%s\n", path, fn); 92 89 } 93 90 } … … 114 111 if ((res = f_open(fd, name, FA_OPEN_EXISTING | FA_READ)) != FR_OK) { 115 112 if ((res = f_opendir(&dir, name)) != FR_OK) { 116 ntstdio_printf(ntstdio,"f_opendir(%s) => %d\n", name, res);113 printf("f_opendir(%s) => %d\n", name, res); 117 114 return 0; 118 115 } 119 116 120 117 if ((res = f_readdir(&dir, &fno)) != FR_OK) { 121 ntstdio_printf(ntstdio,"f_readdir(%s) => %d\n", name, res);118 printf("f_readdir(%s) => %d\n", name, res); 122 119 return 0; 123 120 } … … 132 129 133 130 if (res != FR_OK) { 134 ntstdio_printf(ntstdio,"f_open(%s) => %d %x\n", name, res, fno.fattrib);131 printf("f_open(%s) => %d %x\n", name, res, fno.fattrib); 135 132 return 0; 136 133 } … … 139 136 file->len = fd->fsize; 140 137 141 // ntstdio_printf(ntstdio,"httpd_fs_open(%s) %d\n", name, file->len);138 //printf("httpd_fs_open(%s) %d\n", name, file->len); 142 139 143 140 return 1; … … 158 155 159 156 if ((res = f_open(fd, name, FA_CREATE_ALWAYS | FA_WRITE)) != FR_OK) { 160 ntstdio_printf(ntstdio,"f_open(%s) => %d\n", name, res);157 printf("f_open(%s) => %d\n", name, res); 161 158 return 0; 162 159 } … … 165 162 file->len = 0; 166 163 167 // ntstdio_printf(ntstdio,"httpd_fs_create(%s) %d\n", file->name, file->len);164 //printf("httpd_fs_create(%s) %d\n", file->name, file->len); 168 165 169 166 return 1; … … 179 176 180 177 if ((ret = f_lseek(fd, file->pos)) != FR_OK) { 181 ntstdio_printf(ntstdio,"f_lseek(%s, %d) => %d\n", file->name, file->pos, ret);178 printf("f_lseek(%s, %d) => %d\n", file->name, file->pos, ret); 182 179 return 0; 183 180 } 184 181 185 182 if (file->pos != fd->fptr) { 186 ntstdio_printf(ntstdio,"f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr);183 printf("f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr); 187 184 } 188 185 189 186 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);187 printf("f_read(%s, 0x%p, %d) => %d\n", file->name, dst, len, ret); 188 return 0; 189 } 190 191 //printf("httpd_fs_read(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen); 195 192 196 193 return rlen; … … 206 203 207 204 if ((ret = f_lseek(fd, file->pos)) != FR_OK) { 208 ntstdio_printf(ntstdio,"f_lseek(%s, %d) => %d\n", file->name, file->pos, ret);205 printf("f_lseek(%s, %d) => %d\n", file->name, file->pos, ret); 209 206 return 0; 210 207 } 211 208 212 209 if (file->pos != fd->fptr) { 213 ntstdio_printf(ntstdio,"f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr);210 printf("f_lseek(%s, %d) != %d\n", file->name, file->pos, fd->fptr); 214 211 } 215 212 216 213 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);214 printf("f_write(%s, 0x%p, %d) => %d\n", file->name, src, len, ret); 218 215 return 0; 219 216 } … … 222 219 file->len += rlen; 223 220 224 // ntstdio_printf(ntstdio,"httpd_fs_write(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen);221 //printf("httpd_fs_write(%s, %d, %d) => %d\n", file->name, file->pos, len, rlen); 225 222 226 223 return rlen; … … 234 231 235 232 if ((ret = f_close(fd)) != FR_OK) { 236 ntstdio_printf(ntstdio,"f_close(%s) => %d\n", file->name, ret);233 printf("f_close(%s) => %d\n", file->name, ret); 237 234 return 0; 238 235 } -
EcnlProtoTool/trunk/ntshell/webserver/httpd.c
r441 r442 53 53 #include "base64.h" 54 54 #include "sha1.h" 55 #include "util/ntstdio.h"56 55 #include "core/ntlibc.h" 57 56 … … 59 58 #define FALSE 0 60 59 61 extern ntstdio_t *ntstdio;62 60 SYSTIM httpd_time; 63 61 struct httpd_state *uploding; … … 111 109 void strcpy_s(char *dst, int size, const char *src) 112 110 { 113 int slen = ntlibc_strlen(src);111 int slen = strlen(src); 114 112 if (slen >= size) 115 113 slen = size - 1; … … 120 118 void strcat_s(char *dst, int size, const char *src) 121 119 { 122 int dlen = ntlibc_strlen(dst);123 int slen = ntlibc_strlen(src);120 int dlen = strlen(dst); 121 int slen = strlen(src); 124 122 if (dlen + slen >= size) 125 123 slen = size - 1 - dlen; … … 235 233 struct message *m = &s->message; 236 234 237 if ( ntlibc_strncmp("Referer", buf, len) == 0) {235 if (strncmp("Referer", buf, len) == 0) { 238 236 m->num_headers = 1; 239 237 } 240 else if ( ntlibc_strncmp("Host", buf, len) == 0) {238 else if (strncmp("Host", buf, len) == 0) { 241 239 m->num_headers = 2; 242 240 } 243 else if ( ntlibc_strncmp("Upgrade", buf, len) == 0) {241 else if (strncmp("Upgrade", buf, len) == 0) { 244 242 m->num_headers = 3; 245 243 } 246 else if ( ntlibc_strncmp("Connection", buf, len) == 0) {244 else if (strncmp("Connection", buf, len) == 0) { 247 245 m->num_headers = 4; 248 246 } 249 else if ( ntlibc_strncmp("Sec-WebSocket-Key", buf, len) == 0) {247 else if (strncmp("Sec-WebSocket-Key", buf, len) == 0) { 250 248 m->num_headers = 5; 251 249 } 252 else if ( ntlibc_strncmp("Origin", buf, len) == 0) {250 else if (strncmp("Origin", buf, len) == 0) { 253 251 m->num_headers = 6; 254 252 } 255 else if ( ntlibc_strncmp("Sec-WebSocket-Protocol", buf, len) == 0) {253 else if (strncmp("Sec-WebSocket-Protocol", buf, len) == 0) { 256 254 m->num_headers = 7; 257 255 } 258 else if ( ntlibc_strncmp("Sec-WebSocket-Version", buf, len) == 0) {256 else if (strncmp("Sec-WebSocket-Version", buf, len) == 0) { 259 257 m->num_headers = 8; 260 258 } … … 334 332 // アップロード先はSDカード 335 333 s->filename[0] = '1'; 336 ntstdio_printf(ntstdio,"create: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);334 printf("create: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename); 337 335 if (!httpd_fs_create(s->filename, &s->file)) { 338 336 goto error; … … 341 339 s->in.state = IN_STATE_UPLOAD; 342 340 } 343 else if ( ntlibc_strcmp(s->filename, uploding->filename) == 0) {344 ntstdio_printf(ntstdio,"collision: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);341 else if (strcmp(s->filename, uploding->filename) == 0) { 342 printf("collision: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename); 345 343 goto error; 346 344 } … … 374 372 375 373 if (s->message.body_is_final) { 376 ntstdio_printf(ntstdio,"\n\n *** Error http_body_is_final() should return 1 \n"374 printf("\n\n *** Error http_body_is_final() should return 1 \n" 377 375 "on last on_body callback call " 378 376 "but it doesn't! ***\n\n"); … … 387 385 388 386 if (s->message.body_is_final) { 389 ntstdio_printf(ntstdio,"close: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);387 printf("close: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename); 390 388 httpd_fs_close(&s->file); 391 389 memset(&s->file, 0, sizeof(s->file)); … … 412 410 struct httpd_state *s = get_context(p); 413 411 if (s->message.should_keep_alive != http_should_keep_alive(p)) { 414 ntstdio_printf(ntstdio,"\n\n *** Error http_should_keep_alive() should have same \n"412 printf("\n\n *** Error http_should_keep_alive() should have same \n" 415 413 "value in both on_message_complete and on_headers_complete " 416 414 "but it doesn't! ***\n\n"); … … 421 419 http_body_is_final(p) && 422 420 !s->message.body_is_final) { 423 ntstdio_printf(ntstdio,"\n\n *** Error http_body_is_final() should return 1 \n"421 printf("\n\n *** Error http_body_is_final() should return 1 \n" 424 422 "on last on_body callback call " 425 423 "but it doesn't! ***\n\n"); … … 493 491 slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR); 494 492 if (slen < 0) { 495 ntstdio_printf(ntstdio,"send_file#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);493 printf("send_file#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen); 496 494 s->state = STATE_CLOSING; 497 495 break; … … 506 504 len = httpd_fs_read(&s->file, buf, len); 507 505 if (len <= 0) { 508 ntstdio_printf(ntstdio,"send_file#httpd_fs_read(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, len);506 printf("send_file#httpd_fs_read(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, len); 509 507 break; 510 508 } … … 514 512 515 513 if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) { 516 ntstdio_printf(ntstdio,"send_file#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);514 printf("send_file#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen); 517 515 s->state = STATE_CLOSING; 518 516 break; … … 520 518 } 521 519 522 ntstdio_printf(ntstdio,"close: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);520 printf("close: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename); 523 521 httpd_fs_close(&s->file); 524 522 s->file.len = 0; … … 536 534 slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR); 537 535 if (slen < 0) { 538 ntstdio_printf(ntstdio,"send_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);536 printf("send_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen); 539 537 s->state = STATE_CLOSING; 540 538 break; … … 553 551 554 552 if ((slen = tcp_snd_buf(s->cepid, len)) != E_OK) { 555 ntstdio_printf(ntstdio,"send_data#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);553 printf("send_data#tcp_snd_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen); 556 554 s->state = STATE_CLOSING; 557 555 break; … … 571 569 char *ptr; 572 570 573 len = ntlibc_strlen(statushdr);571 len = strlen(statushdr); 574 572 tcp_snd_dat(s->cepid, (void *)statushdr, len, TMO_FEVR); 575 573 … … 586 584 tcp_snd_dat(s->cepid, "/~", len, TMO_FEVR); 587 585 } 588 len = ntlibc_strlen(s->filename);586 len = strlen(s->filename); 589 587 tcp_snd_dat(s->cepid, s->filename, len, TMO_FEVR); 590 588 if (s->query != NULL) { 591 589 tcp_snd_dat(s->cepid, "?", 1, TMO_FEVR); 592 len = ntlibc_strlen(s->query);590 len = strlen(s->query); 593 591 tcp_snd_dat(s->cepid, s->query, len, TMO_FEVR); 594 592 } … … 602 600 tcp_snd_dat(s->cepid, (void *)http_content_type_binary, len, TMO_FEVR); 603 601 } 604 else if ( ntlibc_strncmp(http_html, ptr, sizeof(http_html) - 1) == 0 ||605 ntlibc_strncmp(http_htm, ptr, sizeof(http_htm) - 1) == 0) {602 else if (strncmp(http_html, ptr, sizeof(http_html) - 1) == 0 || 603 strncmp(http_htm, ptr, sizeof(http_htm) - 1) == 0) { 606 604 len = sizeof(http_content_type_html) - 1; 607 605 tcp_snd_dat(s->cepid, (void *)http_content_type_html, len, TMO_FEVR); 608 606 } 609 else if ( ntlibc_strncmp(http_css, ptr, sizeof(http_css) - 1) == 0) {607 else if (strncmp(http_css, ptr, sizeof(http_css) - 1) == 0) { 610 608 len = sizeof(http_content_type_css) - 1; 611 609 tcp_snd_dat(s->cepid, (void *)http_content_type_css, len, TMO_FEVR); 612 610 } 613 else if ( ntlibc_strncmp(http_js, ptr, sizeof(http_js) - 1) == 0) {611 else if (strncmp(http_js, ptr, sizeof(http_js) - 1) == 0) { 614 612 len = sizeof(http_content_type_js) - 1; 615 613 tcp_snd_dat(s->cepid, (void *)http_content_type_js, len, TMO_FEVR); 616 614 } 617 else if ( ntlibc_strncmp(http_json, ptr, sizeof(http_json) - 1) == 0) {615 else if (strncmp(http_json, ptr, sizeof(http_json) - 1) == 0) { 618 616 len = sizeof(http_content_type_json) - 1; 619 617 tcp_snd_dat(s->cepid, (void *)http_content_type_json, len, TMO_FEVR); 620 618 } 621 else if ( ntlibc_strncmp(http_png, ptr, sizeof(http_png) - 1) == 0) {619 else if (strncmp(http_png, ptr, sizeof(http_png) - 1) == 0) { 622 620 len = sizeof(http_content_type_png) - 1; 623 621 tcp_snd_dat(s->cepid, (void *)http_content_type_png, len, TMO_FEVR); 624 622 } 625 else if ( ntlibc_strncmp(http_gif, ptr, sizeof(http_gif) - 1) == 0) {623 else if (strncmp(http_gif, ptr, sizeof(http_gif) - 1) == 0) { 626 624 len = sizeof(http_content_type_gif) - 1; 627 625 tcp_snd_dat(s->cepid, (void *)http_content_type_gif, len, TMO_FEVR); 628 626 } 629 else if ( ntlibc_strncmp(http_jpg, ptr, sizeof(http_jpg) - 1) == 0) {627 else if (strncmp(http_jpg, ptr, sizeof(http_jpg) - 1) == 0) { 630 628 len = sizeof(http_content_type_jpg) - 1; 631 629 tcp_snd_dat(s->cepid, (void *)http_content_type_jpg, len, TMO_FEVR); 632 630 } 633 else if ( ntlibc_strncmp(http_svg, ptr, sizeof(http_svg) - 1) == 0) {631 else if (strncmp(http_svg, ptr, sizeof(http_svg) - 1) == 0) { 634 632 len = sizeof(http_content_type_svg) - 1; 635 633 tcp_snd_dat(s->cepid, (void *)http_content_type_svg, len, TMO_FEVR); 636 634 } 637 else if ( ntlibc_strncmp(http_text, ptr, sizeof(http_text) - 1) == 0) {635 else if (strncmp(http_text, ptr, sizeof(http_text) - 1) == 0) { 638 636 len = sizeof(http_content_type_text) - 1; 639 637 tcp_snd_dat(s->cepid, (void *)http_content_type_text, len, TMO_FEVR); 640 638 } 641 else if ( ntlibc_strncmp(http_eot, ptr, sizeof(http_eot) - 1) == 0) {639 else if (strncmp(http_eot, ptr, sizeof(http_eot) - 1) == 0) { 642 640 len = sizeof(http_content_type_eot) - 1; 643 641 tcp_snd_dat(s->cepid, (void *)http_content_type_eot, len, TMO_FEVR); 644 642 } 645 else if ( ntlibc_strncmp(http_ttf, ptr, sizeof(http_ttf) - 1) == 0) {643 else if (strncmp(http_ttf, ptr, sizeof(http_ttf) - 1) == 0) { 646 644 len = sizeof(http_content_type_ttf) - 1; 647 645 tcp_snd_dat(s->cepid, (void *)http_content_type_ttf, len, TMO_FEVR); 648 646 } 649 else if ( ntlibc_strncmp(http_woff, ptr, sizeof(http_woff) - 1) == 0) {647 else if (strncmp(http_woff, ptr, sizeof(http_woff) - 1) == 0) { 650 648 len = sizeof(http_content_type_woff) - 1; 651 649 tcp_snd_dat(s->cepid, (void *)http_content_type_woff, len, TMO_FEVR); 652 650 } 653 else if ( ntlibc_strncmp(http_woff2, ptr, sizeof(http_woff2) - 1) == 0) {651 else if (strncmp(http_woff2, ptr, sizeof(http_woff2) - 1) == 0) { 654 652 len = sizeof(http_content_type_woff2) - 1; 655 653 tcp_snd_dat(s->cepid, (void *)http_content_type_woff2, len, TMO_FEVR); 656 654 } 657 else if ( ntlibc_strncmp(http_ico, ptr, sizeof(http_ico) - 1) == 0) {655 else if (strncmp(http_ico, ptr, sizeof(http_ico) - 1) == 0) { 658 656 len = sizeof(http_content_type_ico) - 1; 659 657 tcp_snd_dat(s->cepid, (void *)http_content_type_ico, len, TMO_FEVR); … … 667 665 len = sizeof(http_content_length) - 1; 668 666 tcp_snd_dat(s->cepid, (void *)http_content_length, len, TMO_FEVR); 669 len = ntstdio_snprintf(s->temp, sizeof(s->temp), "%d\r\n", s->file.len);667 len = snprintf(s->temp, sizeof(s->temp), "%d\r\n", s->file.len); 670 668 tcp_snd_dat(s->cepid, (void *)s->temp, len, TMO_FEVR); 671 669 } … … 699 697 break; 700 698 case OUT_STATE_OPEN_GET_FILE: 701 ntstdio_printf(ntstdio,"open: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename);699 printf("open: %s.%d %s\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->filename); 702 700 if (!httpd_fs_open(s->filename, sizeof(s->message.request_url), &s->file)) { 703 701 s->filename = NULL; … … 713 711 break; 714 712 case OUT_STATE_WAIT_POST_BODY: 715 // ntstdio_printf(ntstdio,"wait post body\n");713 //printf("wait post body\n"); 716 714 s->out.wait = true; 717 715 break; 718 716 case OUT_STATE_BODY_RECEIVED: 719 // ntstdio_printf(ntstdio,"body received\n");717 //printf("body received\n"); 720 718 s->out.statushdr = http_header_200; 721 719 s->out.state = OUT_STATE_SEND_HEADER; 722 720 break; 723 721 case OUT_STATE_SEND_HEADER: 724 // ntstdio_printf(ntstdio,"send header\n");722 //printf("send header\n"); 725 723 send_headers(s, s->out.statushdr); 726 724 break; 727 725 case OUT_STATE_SEND_FILE: 728 // ntstdio_printf(ntstdio,"send file %d\n", s->file.len);726 //printf("send file %d\n", s->file.len); 729 727 send_file(s); 730 728 break; 731 729 case OUT_STATE_SEND_DATA: 732 // ntstdio_printf(ntstdio,"send data %d\n", s->response_len);730 //printf("send data %d\n", s->response_len); 733 731 send_data(s); 734 732 break; 735 733 case OUT_STATE_SEND_END: 736 // ntstdio_printf(ntstdio,"send end\n");734 //printf("send end\n"); 737 735 s->out.wait = true; 738 736 if (s->message.should_keep_alive && s->reset == 0) { … … 750 748 int len; 751 749 752 len = ntlibc_strlen(statushdr);750 len = strlen(statushdr); 753 751 tcp_snd_dat(s->cepid, (void *)statushdr, len, TMO_FEVR); 754 752 755 753 len = sizeof(http_upgrade) - 1; 756 754 tcp_snd_dat(s->cepid, (void *)http_upgrade, len, TMO_FEVR); 757 len = ntlibc_strlen(s->message.upgrade);755 len = strlen(s->message.upgrade); 758 756 tcp_snd_dat(s->cepid, s->message.upgrade, len, TMO_FEVR); 759 757 len = sizeof(http_crnl) - 1; … … 762 760 len = sizeof(http_connection) - 1; 763 761 tcp_snd_dat(s->cepid, (void *)http_connection, len, TMO_FEVR); 764 len = ntlibc_strlen(s->message.connection);762 len = strlen(s->message.connection); 765 763 tcp_snd_dat(s->cepid, s->message.connection, len, TMO_FEVR); 766 764 len = sizeof(http_crnl) - 1; … … 769 767 len = sizeof(http_sec_websocket_accept) - 1; 770 768 tcp_snd_dat(s->cepid, (void *)http_sec_websocket_accept, len, TMO_FEVR); 771 len = ntlibc_strlen(s->message.response_key);769 len = strlen(s->message.response_key); 772 770 tcp_snd_dat(s->cepid, s->message.response_key, len, TMO_FEVR); 773 771 len = sizeof(http_crnl) - 1; … … 776 774 len = sizeof(http_sec_websocket_protocol) - 1; 777 775 tcp_snd_dat(s->cepid, (void *)http_sec_websocket_protocol, len, TMO_FEVR); 778 len = ntlibc_strlen(s->message.sec_websocket_protocol);776 len = strlen(s->message.sec_websocket_protocol); 779 777 tcp_snd_dat(s->cepid, s->message.sec_websocket_protocol, len, TMO_FEVR); 780 778 len = sizeof(http_crnl) - 1; … … 792 790 slen = tcp_get_buf(s->cepid, (void **)&buf, TMO_FEVR); 793 791 if (slen < 0) { 794 ntstdio_printf(ntstdio,"send_ws_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen);792 printf("send_ws_data#tcp_get_buf(%s.%d) => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, slen); 795 793 return; 796 794 } … … 856 854 //} 857 855 } 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);856 printf("handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len); 859 857 uploding = NULL; 860 858 s->state = STATE_CLOSING; … … 864 862 tcp_rel_buf(s->cepid, done); 865 863 if (s->parser.http_errno != HPE_OK) { 866 ntstdio_printf(ntstdio,"http_parser error %s.%d => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno);864 printf("http_parser error %s.%d => %d\n", s->addr, ((T_IPV4EP *)s->dst)->portno, s->parser.http_errno); 867 865 uploding = NULL; 868 866 s->state = STATE_CLOSING; … … 889 887 break; 890 888 } 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);889 printf("handle_input#tcp_rcv_buf#%d(%s.%d) => %d\n", s->in.state, s->addr, ((T_IPV4EP *)s->dst)->portno, len); 892 890 s->state = STATE_CLOSING; 893 891 break; … … 927 925 928 926 if (s == NULL) 929 ntstdio_printf(ntstdio,"callback_nblk_tcp(%d, %d)\n", fncd, cepid);927 printf("callback_nblk_tcp(%d, %d)\n", fncd, cepid); 930 928 else 931 ntstdio_printf(ntstdio,"callback_nblk_tcp(%d, %s.%d)\n", fncd, s->addr, ((T_IPV4EP *)s->dst)->portno);929 printf("callback_nblk_tcp(%d, %s.%d)\n", fncd, s->addr, ((T_IPV4EP *)s->dst)->portno); 932 930 933 931 return E_PAR; … … 945 943 ret2 = get_tim(&httpd_time); 946 944 if (ret2 != E_OK) { 947 ntstdio_printf(ntstdio,"get_tim\n");945 printf("get_tim\n"); 948 946 return; 949 947 } … … 953 951 memset(&s->dst, 0, sizeof(s->dst)); 954 952 if ((ret = tcp_acp_cep(s->cepid, TCP_REPID, (T_IPV4EP *)s->dst, TMO_FEVR)) != E_OK) { 955 ntstdio_printf(ntstdio,"tcp_acp_cep(%d) => %d\n", s->cepid, ret);953 printf("tcp_acp_cep(%d) => %d\n", s->cepid, ret); 956 954 tslp_tsk(100 * 1000); // TODO 957 955 s->state = STATE_CLOSING; … … 959 957 } 960 958 IP2STR(s->addr, &((T_IPV4EP *)s->dst)->ipaddr); 961 ntstdio_printf(ntstdio,"connected: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);959 printf("connected: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno); 962 960 memset(&s->in, 0, sizeof(s->in)); 963 961 memset(&s->out, 0, sizeof(s->out)); … … 974 972 break; 975 973 case STATE_CLOSING: 976 ntstdio_printf(ntstdio,"close: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno);974 printf("close: %s.%d\n", s->addr, ((T_IPV4EP *)s->dst)->portno); 977 975 tcp_sht_cep(s->cepid); 978 976 tcp_cls_cep(s->cepid, TMO_FEVR);
Note:
See TracChangeset
for help on using the changeset viewer.