Changeset 331 for EcnlProtoTool/trunk/ntshell/src
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/ntshell/src
- Files:
-
- 10 added
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/ntshell/src/fdtable.c
r321 r331 35 35 * @(#) $Id$ 36 36 */ 37 #include "shellif.h" 37 38 #include <stdint.h> 38 #include <stdio.h>39 #include <sys/unistd.h>40 #include <limits.h>41 39 #include <kernel.h> 42 40 #include <t_syslog.h> 43 41 #include <t_stdlib.h> 44 42 #include <sil.h> 45 #include <stdlib.h>46 #include <string.h>47 #include <stdio.h>48 #include <setjmp.h>49 #include "../../../musl-1.1.12/include/poll.h"50 43 #include "syssvc/serial.h" 51 44 #include "syssvc/syslog.h" … … 61 54 #include <net/if_var.h> 62 55 #include <netinet/udp_var.h> 63 #include <ethernet_api.h>56 //#include <ethernet_api.h> 64 57 #include "ff.h" 65 58 #include "socket_stub.h" 66 59 #include "kernel_cfg.h" 60 #include <string.h> 67 61 68 62 #define SIO_PORTID 1 … … 71 65 #define IO_TYPE_SIO 1 72 66 #define IO_TYPE_FILE 2 73 #define IO_TYPE_TCP 3 74 #define IO_TYPE_UDP 4 67 #define IO_TYPE_DIR 3 68 #define IO_TYPE_TCP 4 69 #define IO_TYPE_UDP 5 75 70 76 71 static struct _IO_FILE fd_table[8 * sizeof(FLGPTN)] = { 77 { 0, IO_TYPE_SIO, 0, stdio_close, stdin_read, stdio_write },78 { 1, IO_TYPE_SIO, 0, stdio_close, stdio_read, stdout_write },79 { 2, IO_TYPE_SIO, 0, stdio_close, stdio_read, stderr_write },72 { 0, IO_TYPE_SIO, 0, stdio_close, stdin_read, stdio_write, sio_seek, sio_ioctl }, 73 { 1, IO_TYPE_SIO, 0, stdio_close, stdio_read, stdout_write, sio_seek, sio_ioctl }, 74 { 2, IO_TYPE_SIO, 0, stdio_close, stdio_read, stderr_write, sio_seek, sio_ioctl }, 80 75 }; 81 76 #define fd_table_count (sizeof(fd_table) / sizeof(fd_table[0])) … … 94 89 } 95 90 96 return - 1;91 return -ENOMEM; 97 92 } 98 93 … … 112 107 struct _IO_FILE *fp = id_to_fd(type, id); 113 108 if (fp == NULL) 114 return - 1;109 return -EBADF; 115 110 116 111 memset(fp, 0, sizeof(struct _IO_FILE)); … … 136 131 fp->read = sio_read; 137 132 fp->write = sio_write; 133 fp->seek = sio_seek; 134 fp->ioctl = sio_ioctl; 138 135 139 136 return fp; … … 160 157 fp->read = file_read; 161 158 fp->write = file_write; 159 fp->seek = file_seek; 160 fp->ioctl = file_ioctl; 162 161 163 162 return fp; … … 172 171 { 173 172 return id_to_fd(IO_TYPE_FILE, fileid); 173 } 174 175 struct _IO_FILE *new_dir_fd(int fileid) 176 { 177 int fd = new_fd(IO_TYPE_DIR, fileid); 178 if ((fd < 0) || (fd >= fd_table_count)) 179 return NULL; 180 181 struct _IO_FILE *fp = &fd_table[fd]; 182 fp->close = dir_close; 183 fp->read = dir_read; 184 fp->write = dir_write; 185 fp->seek = dir_seek; 186 fp->ioctl = dir_ioctl; 187 188 return fp; 189 } 190 191 int delete_dir_fd(int dirid) 192 { 193 return delete_fd(IO_TYPE_DIR, dirid); 194 } 195 196 struct _IO_FILE *dirid_to_fd(int dirid) 197 { 198 return id_to_fd(IO_TYPE_DIR, dirid); 174 199 } 175 200 … … 184 209 fp->read = tcp_fd_read; 185 210 fp->write = tcp_fd_write; 211 fp->seek = tcp_fd_seek; 212 fp->ioctl = tcp_fd_ioctl; 186 213 187 214 return fp; … … 208 235 fp->read = udp_fd_read; 209 236 fp->write = udp_fd_write; 237 fp->seek = udp_fd_seek; 238 fp->ioctl = udp_fd_ioctl; 210 239 211 240 return fp; … … 220 249 { 221 250 return id_to_fd(IO_TYPE_UDP, udpid); 222 }223 224 int shell_isatty(int fd)225 {226 if ((fd < 0) || (fd >= fd_table_count))227 return 0;228 229 struct _IO_FILE *fp = &fd_table[fd];230 if (fp->type == IO_TYPE_SIO)231 return 1;232 233 return 0;234 251 } 235 252 … … 245 262 #define TMO_MAX INT_MAX 246 263 247 int s elect(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)264 int shell_select(int n, fd_set *__restrict rfds, fd_set *__restrict wfds, fd_set *__restrict efds, struct timeval *__restrict tv) 248 265 { 249 266 ER ret; … … 277 294 } 278 295 279 return - 1;280 } 281 282 int poll(struct pollfd *fds, nfds_t nfds, int timeout)296 return -EBADF; 297 } 298 299 int shell_poll(struct pollfd *fds, nfds_t nfds, int timeout) 283 300 { 284 301 ER ret; … … 334 351 } 335 352 336 return - 1;353 return -EBADF; 337 354 } 338 355 … … 541 558 } 542 559 } 560 561 int shell_ioctl(int fd, int request, void *arg) 562 { 563 struct _IO_FILE *fp = fd_to_fp(fd); 564 if (fp == NULL) 565 return -EBADF; 566 567 return fp->ioctl(fp, request, arg); 568 } -
EcnlProtoTool/trunk/ntshell/src/io_stub.c
r321 r331 35 35 * @(#) $Id$ 36 36 */ 37 #include "shellif.h" 37 38 #include <stdint.h> 38 #include <stdio.h>39 #include <sys/unistd.h>40 #include <limits.h>41 #include <fcntl.h>42 39 #include "ff.h" 43 40 #include <kernel.h> … … 45 42 #include <t_stdlib.h> 46 43 #include <sil.h> 47 #include <stdlib.h>48 44 #include <string.h> 49 #include <stdio.h>50 45 #include <setjmp.h> 51 46 #include "syssvc/syslog.h" … … 61 56 #include <net/if_var.h> 62 57 #include <netinet/udp_var.h> 63 #include <ethernet_api.h> 64 #include "ff.h" 58 //#include <ethernet_api.h> 65 59 #include "socket_stub.h" 66 #include "../../../musl-1.1.12/include/_dirent.h" 67 #include "../../../musl-1.1.12/include/_termios.h" 68 #include "ntstdio.h" 69 70 int shell_open(const char * path, int flags) 71 { 72 FRESULT res; 73 74 struct _IO_FILE *fp = new_file_fd(0); 75 if (fp == NULL) 76 return -1; 60 //#include <sys/stat.h> 61 #include "util/ntstdio.h" 62 #include "usrcmd.h" 63 #include "core/ntlibc.h" 64 65 int fresult2errno(FRESULT res) 66 { 67 switch (res) { 68 case FR_INVALID_OBJECT: 69 return -EINVAL; 70 case FR_TOO_MANY_OPEN_FILES: 71 return -ENOMEM; 72 case FR_NO_FILE: 73 case FR_NO_PATH: 74 case FR_INVALID_DRIVE: 75 case FR_INVALID_NAME: 76 return -ENOENT; 77 case FR_DISK_ERR: 78 case FR_NO_FILESYSTEM: 79 case FR_NOT_ENABLED: 80 return -ENODEV; 81 case FR_WRITE_PROTECTED: 82 case FR_DENIED: 83 return -EACCES; 84 case FR_EXIST: 85 return -EEXIST; 86 case FR_INT_ERR: 87 default: 88 return -EIO; 89 } 90 } 91 92 int shell_open(const char * path, int flags, void *arg) 93 { 94 FRESULT res; 95 struct _IO_FILE *fp; 96 97 if (flags & O_DIRECTORY) { 98 fp = new_dir_fd(0); 99 if (fp == NULL) 100 return -ENOMEM; 101 102 DIR *dir = &fp->dir; 103 FRESULT res; 104 if ((res = f_opendir(dir, path)) != FR_OK) { 105 return fresult2errno(res); 106 } 107 return 0; 108 } 109 110 fp = new_file_fd(0); 111 if (fp == NULL) 112 return -ENOMEM; 77 113 78 114 BYTE fmd = 0; … … 115 151 } 116 152 117 return -1;153 return fresult2errno(res); 118 154 } 119 155 … … 126 162 } 127 163 128 return - 1;164 return -EINVAL; 129 165 } 130 166 … … 135 171 136 172 if ((res = f_read(&fp->file, data, len, &ret)) != FR_OK) 137 return - 1;173 return -EIO; 138 174 139 175 return ret; … … 146 182 147 183 if ((res = f_write(&fp->file, data, len, &ret)) != FR_OK) 148 return - 1;184 return -EIO; 149 185 150 186 return ret; 151 187 } 152 188 189 off_t file_seek(struct _IO_FILE *fp, off_t ptr, int dir) 190 { 191 switch (dir) { 192 case SEEK_SET: 193 dir = F_SEEK_SET; 194 break; 195 case SEEK_CUR: 196 dir = F_SEEK_CUR; 197 break; 198 case SEEK_END: 199 dir = F_SEEK_END; 200 break; 201 default: 202 return -EINVAL; 203 } 204 205 FRESULT res; 206 if ((res = f_seek(&fp->file, ptr, dir)) != FR_OK) 207 return -EIO; 208 209 return fp->file.fptr; 210 } 211 212 int file_ioctl(struct _IO_FILE *fp, int req, void *arg) 213 { 214 DRESULT res; 215 216 if ((res = disk_ioctl(fp->file.fs->drv, req, arg) != RES_OK)) 217 return -EINVAL; 218 219 return 0; 220 } 221 153 222 int shell_close(int fd) 154 223 { 155 224 struct _IO_FILE *fp = fd_to_fp(fd); 156 225 if (fp == NULL) 157 return - 1;226 return -EBADF; 158 227 159 228 return fp->close(fp); 160 229 } 161 230 162 int shell_read(int fd, char *data, int len)163 { 164 struct _IO_FILE *fp = fd_to_fp(fd); 165 if (fp == NULL) 166 return - 1;231 ssize_t shell_read(int fd, void *data, size_t len) 232 { 233 struct _IO_FILE *fp = fd_to_fp(fd); 234 if (fp == NULL) 235 return -EBADF; 167 236 168 237 return fp->read(fp, (unsigned char *)data, len); 169 238 } 170 239 171 int shell_write(int fd, char *data, int len) 172 { 173 struct _IO_FILE *fp = fd_to_fp(fd); 174 if (fp == NULL) 175 return -1; 240 int shell_readv(int fd, const struct iovec *iov, int iovcnt) 241 { 242 int result = 0; 243 struct _IO_FILE *fp = fd_to_fp(fd); 244 if (fp == NULL) 245 return -EBADF; 246 247 const struct iovec *end = &iov[iovcnt]; 248 for (; iov < end; iov++) { 249 result += fp->read(fp, (unsigned char *)iov->iov_base, iov->iov_len); 250 } 251 252 return result; 253 } 254 255 ssize_t shell_write(int fd, const void *data, size_t len) 256 { 257 struct _IO_FILE *fp = fd_to_fp(fd); 258 if (fp == NULL) 259 return -EBADF; 176 260 177 261 return fp->write(fp, (unsigned char *)data, len); 178 262 } 179 263 180 int shell_lseek(int fd, int ptr, int dir) 181 { 182 struct _IO_FILE *fp = fd_to_fp(fd); 183 if (fp == NULL) 184 return -1; 185 186 FRESULT res; 187 if ((res = f_seek(&fp->file, ptr, dir)) != FR_OK) 188 return -1; 189 190 return fp->file.fptr; 264 int shell_writev(int fd, const struct iovec *iov, int iovcnt) 265 { 266 int result = 0; 267 struct _IO_FILE *fp = fd_to_fp(fd); 268 if (fp == NULL) 269 return -EBADF; 270 271 const struct iovec *end = &iov[iovcnt]; 272 for (; iov < end; iov++) { 273 result += fp->write(fp, (unsigned char *)iov->iov_base, iov->iov_len); 274 } 275 276 return result; 277 } 278 279 int shell_llseek(int fd, off_t ptr, off_t *result, int dir) 280 { 281 struct _IO_FILE *fp = fd_to_fp(fd); 282 if (fp == NULL) 283 return -EBADF; 284 285 off_t ret = fp->seek(fp, ptr, dir); 286 if (ret < 0) 287 return ret; 288 289 *result = ret; 290 return 0; 191 291 } 192 292 … … 195 295 struct _IO_FILE *fp = fd_to_fp(fd); 196 296 if (fp == NULL) 197 return - 1;297 return -EBADF; 198 298 199 299 memset(st, 0, sizeof(*st)); … … 203 303 } 204 304 205 int fsync(int fd)206 { 207 struct _IO_FILE *fp = fd_to_fp(fd); 208 if (fp == NULL) 209 return - 1;210 return - 1;211 } 212 213 int ftruncate(int fd, off_t length)214 { 215 struct _IO_FILE *fp = fd_to_fp(fd); 216 if (fp == NULL) 217 return - 1;305 int shell_fsync(int fd) 306 { 307 struct _IO_FILE *fp = fd_to_fp(fd); 308 if (fp == NULL) 309 return -EBADF; 310 return -EIO; 311 } 312 313 int shell_ftruncate(int fd, off_t length) 314 { 315 struct _IO_FILE *fp = fd_to_fp(fd); 316 if (fp == NULL) 317 return -EBADF; 218 318 219 319 FRESULT res; 220 320 if ((res = f_truncate(&fp->file)) != FR_OK) 221 return -1; 222 223 return 0; 224 } 225 226 int ioctl(int fd, int request, va_list ap) 227 { 228 struct _IO_FILE *fp = fd_to_fp(fd); 229 if (fp == NULL) 230 return -1; 231 return -1; 232 } 233 234 int tcgetattr(int fd, struct termios *termios) 321 return fresult2errno(res); 322 323 return 0; 324 } 325 326 int shell_fcntl(int fd, int cmd, void *arg) 327 { 328 return shell_ioctl(fd, cmd, arg); 329 } 330 331 int sio_tcgetattr(int fd, struct termios *termios) 235 332 { 236 333 extern ntstdio_t ntstdio; … … 265 362 return 0; 266 363 } 267 abort();268 return 0; 269 } 270 271 int tcsetattr(int fd, int optional_actions, const struct termios *termios)364 shell_abort(); 365 return 0; 366 } 367 368 int sio_tcsetattr(int fd, int optional_actions, const struct termios *termios) 272 369 { 273 370 extern ntstdio_t ntstdio; … … 300 397 return 0; 301 398 } 302 abort();303 return 0; 304 } 305 306 int shell_stat(const char * path, struct stat *st)399 shell_abort(); 400 return 0; 401 } 402 403 int shell_stat(const char *__restrict path, struct stat *__restrict st) 307 404 { 308 405 FILINFO fi; … … 313 410 fi.lfsize = sizeof lfn; 314 411 #endif 315 if ( strcmp(path, ".") == 0) {412 if (ntlibc_strcmp(path, ".") == 0) { 316 413 char cwd[_MAX_LFN]; 317 414 if ((ret = f_getcwd(cwd, sizeof(cwd))) != FR_OK) { 318 return -1;319 } 320 int l = strlen(cwd);415 return fresult2errno(ret); 416 } 417 int l = ntlibc_strlen(cwd); 321 418 // ルートディレクトリの場合 322 419 if (cwd[l - 2] == ':' && cwd[l - 1] == '/') { 323 420 st->st_size = 0; 324 st->st_mtime = 0; 421 st->st_mtim.tv_nsec = 0; 422 st->st_mtim.tv_sec = 0; 325 423 st->st_mode = S_IFDIR; 326 424 return 0; 327 425 } 328 426 if ((ret = f_stat(cwd, &fi)) != FR_OK) { 329 return -1;427 return fresult2errno(ret); 330 428 } 331 429 } 332 430 else if ((ret = f_stat(path, &fi)) != FR_OK) { 333 return -1;431 return fresult2errno(ret); 334 432 } 335 433 336 434 st->st_size = fi.fsize; 337 st->st_mtime = fi.fdate + fi.ftime; 435 st->st_mtim.tv_nsec = 0; 436 st->st_mtim.tv_sec = fi.fdate + fi.ftime; 338 437 st->st_mode = (S_IRUSR | S_IRGRP | S_IROTH); 339 438 st->st_mode |= (fi.fattrib & AM_RDO) ? 0 : (S_IWUSR | S_IWGRP | S_IWOTH); … … 343 442 } 344 443 345 int shell_link(void) 346 { 347 return -1; 444 int shell_lstat(const char *__restrict path, struct stat *__restrict st) 445 { 446 return shell_stat(path, st); 447 } 448 449 int shell_link(const char *a, const char *b) 450 { 451 return -EPERM; 348 452 } 349 453 … … 353 457 354 458 if ((res = f_unlink(path)) != FR_OK) 355 return - 1;356 357 return 0; 358 } 359 360 int rmdir(const char *path)459 return -EIO; 460 461 return 0; 462 } 463 464 int shell_rmdir(const char *path) 361 465 { 362 466 FRESULT res; 363 467 364 468 if ((res = f_unlink(path)) != FR_OK) 365 return - 1;469 return -EIO; 366 470 367 471 return 0; … … 373 477 374 478 if ((res = f_rename(oldpath, newpath)) != FR_OK) 375 return -1; 376 return 0; 377 } 378 379 int mkdir(const char *path, mode_t mode) 479 return fresult2errno(res); 480 return 0; 481 } 482 483 #define S_IREAD S_IRUSR 484 #define S_IWRITE S_IWUSR 485 486 int shell_mkdir(const char *path, mode_t mode) 380 487 { 381 488 FRESULT res; 382 489 383 490 if ((res = f_mkdir(path)) != FR_OK) 384 return -1;491 return fresult2errno(res); 385 492 386 493 BYTE attr = 0; … … 397 504 398 505 if((res = f_chmod(path, attr, mask)) != FR_OK) { 399 return -1;400 } 401 402 return 0; 403 } 404 405 int chmod(const char *path, mode_t mode)406 { 407 FRESULT re t;506 return fresult2errno(res); 507 } 508 509 return 0; 510 } 511 512 int shell_chmod(const char *path, mode_t mode) 513 { 514 FRESULT res; 408 515 BYTE attr = 0; 409 516 BYTE mask = AM_RDO | AM_SYS; // AM_ARC, AM_HID … … 418 525 } 419 526 420 if((re t= f_chmod(path, attr, mask)) != FR_OK) {421 return -1;422 } 423 424 return 0; 425 } 426 427 char * getcwd(char *buf, size_t size)527 if((res = f_chmod(path, attr, mask)) != FR_OK) { 528 return fresult2errno(res); 529 } 530 531 return 0; 532 } 533 534 char *shell_getcwd(char *buf, size_t size) 428 535 { 429 536 FRESULT ret; … … 435 542 } 436 543 437 int chdir(const char *path) 438 { 439 FRESULT ret; 440 if ((ret = f_chdir(path)) != FR_OK) { 441 return -1; 442 } 443 444 return 0; 445 } 446 447 int chroot(const char *path) 448 { 449 abort(); 450 return -1; 451 } 452 453 DIR *opendir(const char *path) 454 { 455 DIR *dir = malloc(sizeof(DIR) + sizeof(struct dirent)); 456 FRESULT ret; 457 if ((ret = f_opendir(dir, path)) != FR_OK) { 458 free(dir); 459 return NULL; 460 } 461 462 dir->dirent = &dir[1]; 463 return dir; 464 } 465 466 int closedir(DIR *dir) 467 { 468 FRESULT ret; 469 if ((ret = f_closedir(dir)) != FR_OK) { 470 free(dir); 471 return -1; 472 } 473 474 free(dir); 475 return 0; 476 } 477 478 struct dirent *readdir(DIR *dir) 479 { 480 struct dirent *de = dir->dirent; 544 int shell_chdir(const char *path) 545 { 546 FRESULT res; 547 if ((res = f_chdir(path)) != FR_OK) { 548 return fresult2errno(res); 549 } 550 551 return 0; 552 } 553 554 int shell_chroot(const char *path) 555 { 556 shell_abort(); 557 return -EPERM; 558 } 559 560 int dir_close(struct _IO_FILE *fp) 561 { 562 FRESULT res; 563 if ((res = f_closedir(&fp->dir)) != FR_OK) { 564 return fresult2errno(res); 565 } 566 567 return 0; 568 } 569 570 int shell_getdents(int fd, struct dirent *de, size_t len) 571 { 572 if (len < sizeof(struct dirent)) 573 return -EINVAL; 574 575 struct _IO_FILE *fp = fd_to_fp(fd); 576 if (fp == NULL) 577 return -EBADF; 578 481 579 FILINFO fno; 482 580 #if _USE_LFN … … 485 583 fno.lfsize = sizeof lfn; 486 584 #endif 487 FRESULT re t;488 if ((re t = f_readdir(dir, &fno)) != FR_OK || fno.fname[0] == '\0') {489 return NULL;585 FRESULT res; 586 if ((res = f_readdir(&fp->dir, &fno)) != FR_OK || fno.fname[0] == '\0') { 587 return fresult2errno(res); 490 588 } 491 589 492 590 memset(de, 0, sizeof(*de)); 493 591 #if _USE_LFN 494 strlcpy(de->d_name, *fno.lfname ? fno.lfname : fno.fname, sizeof(de->d_name));592 ntlibc_strlcpy(de->d_name, *fno.lfname ? fno.lfname : fno.fname, sizeof(de->d_name)); 495 593 #else 496 strlcpy(de->d_name, fno.fname, sizeof(de->d_name));594 ntlibc_strlcpy(de->d_name, fno.fname, sizeof(de->d_name)); 497 595 #endif 498 596 499 return de; 500 } 501 502 void rewinddir(DIR *dir) 503 { 504 FRESULT ret; 505 if ((ret = f_rewinddir(dir)) != FR_OK) { 506 return; 507 } 508 } 509 510 void seekdir(DIR *dir, long pos) 511 { 512 abort(); 513 } 514 515 long telldir(DIR *dir) 516 { 517 abort(); 518 return 0; 519 } 520 521 int shell_getpid(int n) 597 return 0; 598 } 599 600 size_t dir_read(struct _IO_FILE *fp, unsigned char *data, size_t len) 601 { 602 return -EPERM; 603 } 604 605 size_t dir_write(struct _IO_FILE *fp, const unsigned char *data, size_t len) 606 { 607 return -EPERM; 608 } 609 610 off_t dir_seek(struct _IO_FILE *fp, off_t ptr, int dir) 611 { 612 FRESULT res; 613 614 if (dir != SEEK_SET) 615 return -EINVAL; 616 617 if (ptr == 0) { 618 if ((res = f_rewinddir(&fp->dir)) != FR_OK) { 619 return fresult2errno(res); 620 } 621 } 622 else { 623 FILINFO fno; 624 #if _USE_LFN 625 static char lfn[_MAX_LFN + 1]; /* Buffer to store the LFN */ 626 fno.lfname = lfn; 627 fno.lfsize = sizeof lfn; 628 #endif 629 if ((res = f_rewinddir(&fp->dir)) != FR_OK) { 630 return fresult2errno(res); 631 } 632 633 for (int i = 0; i < ptr; i++) { 634 if ((res = f_readdir(&fp->dir, &fno)) != FR_OK || fno.fname[0] == '\0') { 635 return fresult2errno(res); 636 } 637 } 638 } 639 640 return ptr; 641 } 642 643 int dir_ioctl(struct _IO_FILE *fp, int req, void *arg) 644 { 645 return -EINVAL; 646 } 647 648 pid_t shell_getpid(void) 522 649 { 523 650 return 1; 524 651 } 652 653 int shell_access(const char *path, int mode) 654 { 655 struct stat st; 656 int ret; 657 658 ret = shell_stat(path, &st); 659 if (ret != 0) 660 return ret; 661 662 return 0; 663 } 664 665 //#include "../musl-1.1.18/include/bits/limits.h" 666 #define PAGE_SIZE 4096 667 668 uint32_t __CmdBase; 669 uint32_t __CmdLimit; 670 671 void *shell_brk(void *addr) 672 { 673 if (addr == 0) { 674 return (void *)((intptr_t)&__CmdBase + 0x20000); 675 } 676 if ((addr >= (intptr_t)&__CmdBase + 0x20000) && (addr < &__CmdLimit)) { 677 return addr; 678 } 679 return (void *)-1; 680 } 681 682 void *shell_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset) 683 { 684 if (fd != -1) 685 return -EINVAL; 686 687 if ((length >= 0) && (length <= (intptr_t)&__CmdLimit - (intptr_t)&__CmdBase - 0x20000)) { 688 return &__CmdBase + 0x20000; 689 } 690 return (void *)-1; 691 } 692 693 int shell_mprotect(void *addr, size_t len, int prot) 694 { 695 //if ((addr >= (intptr_t)&__CmdBase + 0x20000) && ((intptr_t)addr + len < &__CmdLimit)) { 696 return 0; 697 //} 698 //return -1; 699 } -
EcnlProtoTool/trunk/ntshell/src/main.c
r321 r331 40 40 */ 41 41 42 #include "shellif.h" 42 43 #include <kernel.h> 43 #include <t_syslog.h>44 44 #include <t_stdlib.h> 45 45 #include <sil.h> 46 #include <s tdlib.h>46 #include <setjmp.h> 47 47 #include <string.h> 48 #include <stdio.h>49 #include <setjmp.h>50 48 #include "syssvc/serial.h" 51 49 #include "syssvc/syslog.h" … … 64 62 #include <net/if_var.h> 65 63 #include <netinet/udp_var.h> 66 #include <ethernet_api.h>67 64 #include "ffarch.h" 68 #include "gpio_api.h"69 65 #include "ff.h" 70 66 #include "websocket_fbs.h" 71 #include "ntshell.h" 72 #include "ntstdio.h" 67 #include "core/ntshell.h" 68 #include "core/ntlibc.h" 69 #include "util/ntstdio.h" 73 70 #include "usrcmd.h" 74 #include "ntopt.h" 75 76 #ifndef _MSC_VER 77 void strcpy_s(char *dst, int size, const char *src); 78 #endif 71 #include "util/ntopt.h" 72 #include "socket_stub.h" 79 73 80 74 ID ws_api_mailboxid = MAIN_DATAQUEUE; … … 86 80 ntstdio_t ntstdio; 87 81 88 const uint8_t mac_addr[6] = {0x00, 0x30, 0x13, 0x06, 0x62, 0xC0}; 89 const char host_name[] = "GR-PEACH"; 82 const uint8_t mac_addr[6] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC}; 83 const struct utsname host_name = { 84 "TOPPERS/ASP3", 85 "GR-PEACH", 86 "3.1.0", 87 "3.1.0", 88 "GR-PEACH", 89 "toppers.jp" 90 }; 90 91 91 92 static void netif_link_callback(T_IFNET *ether); … … 228 229 char buf[1]; 229 230 if(serial_rea_dat(SIO_PORTID, buf, 1) != 1) 230 return - 1;231 return -EIO; 231 232 return buf[0]; 232 233 } … … 305 306 306 307 if (exec) { 307 strcpy_s(command, sizeof(command), "mruby -b 1:/upload/main.mrb");308 ntlibc_strlcpy(command, "mruby -b 1:/upload/main.mrb", sizeof(command)); 308 309 309 310 execute_command(1); … … 371 372 } 372 373 373 int gethostname(char *name, size_t len)374 { 375 return strlcpy(name, host_name, len);376 } 377 378 static int usrcmd_ntopt_callback( int argc, char **argv, void *extobj);374 int shell_uname(struct utsname *uts) 375 { 376 return memcpy(uts, &host_name, sizeof(host_name)); 377 } 378 379 static int usrcmd_ntopt_callback(long *args, void *extobj); 379 380 int mruby_exit_code; 380 381 volatile int mruby_state; 381 typedef void (*PowerOn_Reset_t)( int argc, char **argv);382 typedef void (*PowerOn_Reset_t)(long *args); 382 383 jmp_buf process_exit; 383 384 … … 392 393 } 393 394 394 static int usrcmd_ntopt_callback(int argc, char **argv, void *extobj) 395 { 395 typedef struct 396 { 397 const cmd_table_t *table; 398 int count; 399 } cmd_table_info_t; 400 401 static const cmd_table_t cmdlist[] = { 402 {"cd", "change directory", usrcmd_cd }, 403 {"ls", "list files", usrcmd_ls }, 404 {"cp", "copy file", usrcmd_cp }, 405 {"rm", "remove file", usrcmd_rm }, 406 {"mv", "move file", usrcmd_mv }, 407 {"mkdir", "Make directory", usrcmd_mkdir}, 408 {"hexdump", "Hex dump", usrcmd_hexdump}, 409 {"info", "This is a description text string for info command.", usrcmd_info}, 410 {"exit", "Exit Natural Tyny Shell", usrcmd_exit}, 411 }; 412 cmd_table_info_t cmd_table_info = { cmdlist, sizeof(cmdlist) / sizeof(cmdlist[0]) }; 413 414 static int usrcmd_ntopt_callback(long *args, void *extobj) 415 { 416 const cmd_table_t *p = cmd_table_info.table; 417 if (ntlibc_strcmp((const char *)args[1], "help") == 0) { 418 usrcmd_help(args[0], (char **)&args[1]); 419 } 420 else for (int i = 0; i < cmd_table_info.count; i++) { 421 if (ntlibc_strcmp((const char *)args[1], p->cmd) == 0) { 422 return p->func(args[0], (char **)&args[1]); 423 } 424 p++; 425 } 396 426 if (setjmp(process_exit) == 0) { 397 (*((PowerOn_Reset_t *)0x18200000))(arg c, argv);427 (*((PowerOn_Reset_t *)0x18200000))(args); 398 428 } 399 429 clean_fd(); 430 return 0; 431 } 432 433 int usrcmd_help(int argc, char **argv) 434 { 435 const cmd_table_t *p = cmd_table_info.table; 436 for (int i = 0; i < cmd_table_info.count; i++) { 437 ntstdio_puts(&ntstdio, p->cmd); 438 ntstdio_puts(&ntstdio, "\t:"); 439 ntstdio_puts(&ntstdio, p->desc); 440 ntstdio_puts(&ntstdio, "\n"); 441 p++; 442 } 400 443 return 0; 401 444 } … … 422 465 423 466 void shell_exit(int exitcd) 467 { 468 mruby_exit_code = exitcd; 469 longjmp(process_exit, 1); 470 } 471 472 void shell_exit_group(int exitcd) 424 473 { 425 474 mruby_exit_code = exitcd; … … 458 507 static int cmd_execute(const char *text, void *extobj) 459 508 { 460 strlcpy(command, text, sizeof(command));509 ntlibc_strlcpy(command, text, sizeof(command)); 461 510 return execute_command(1); 462 511 } … … 464 513 int stdio_close(struct _IO_FILE *fp) 465 514 { 466 return - 1;515 return -EPERM; 467 516 } 468 517 469 518 size_t stdio_read(struct _IO_FILE *fp, unsigned char *data, size_t len) 470 519 { 471 return - 1;520 return -EPERM; 472 521 } 473 522 474 523 size_t stdio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len) 475 524 { 476 return - 1;525 return -EPERM; 477 526 } 478 527 … … 507 556 int sio_close(struct _IO_FILE *fp) 508 557 { 509 return - 1;558 return -EPERM; 510 559 } 511 560 512 561 size_t sio_read(struct _IO_FILE *fp, unsigned char *data, size_t len) 513 562 { 514 return - 1;563 return -EPERM; 515 564 } 516 565 517 566 size_t sio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len) 518 567 { 519 return -1; 520 } 568 return -EPERM; 569 } 570 571 off_t sio_seek(struct _IO_FILE *fp, off_t ofs, int org) 572 { 573 return -EPERM; 574 } 575 576 int sio_ioctl(struct _IO_FILE *fp, int request, void *arg) 577 { 578 switch (request) { 579 case TIOCGWINSZ: 580 return 0; 581 case TCGETS: 582 return sio_tcgetattr(fp->fd, (struct termios *)arg); 583 case TCSETS + TCSANOW: 584 case TCSETS + TCSADRAIN: 585 case TCSETS + TCSAFLUSH: 586 return sio_tcsetattr(fp->fd, request - TCSETS, (const struct termios *)arg); 587 } 588 589 return -EINVAL; 590 } 591 592 int shell_clock_getres(clockid_t clk_id, struct timespec *res) 593 { 594 if (clk_id != CLOCK_REALTIME) 595 return -EINVAL; 596 597 memset(&res->tv_sec, 0xFF, sizeof(res->tv_sec)); 598 res->tv_nsec = 0; 599 600 return 0; 601 } 602 603 int shell_clock_gettime(clockid_t clk_id, struct timespec *tp) 604 { 605 SYSTIM now = 0; 606 607 if (clk_id != CLOCK_REALTIME) 608 return -EINVAL; 609 610 get_tim(&now); 611 tp->tv_sec = now / 1000000; 612 tp->tv_nsec = (now % 1000000) * 1000; 613 614 return 0; 615 } 616 617 int shell_clock_settime(clockid_t clk_id, const struct timespec *tp) 618 { 619 if (clk_id != CLOCK_REALTIME) 620 return -EINVAL; 621 622 rtc_write(tp->tv_sec); 623 624 return 0; 625 } 626 627 sigset_t g_sigmask; 628 629 int shell_sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict old) 630 { 631 if (old != NULL) 632 memcpy(old, &g_sigmask, sizeof(sigset_t)); 633 634 switch (how) { 635 case SIG_BLOCK: 636 for (int i = 0; i < sizeof(g_sigmask.__bits) / sizeof(g_sigmask.__bits[0]); i++) { 637 g_sigmask.__bits[i] |= set->__bits[i]; 638 } 639 break; 640 case SIG_UNBLOCK: 641 for (int i = 0; i < sizeof(g_sigmask.__bits) / sizeof(g_sigmask.__bits[0]); i++) { 642 g_sigmask.__bits[i] &= ~set->__bits[i]; 643 } 644 break; 645 case SIG_SETMASK: 646 memcpy(&g_sigmask, set, sizeof(sigset_t)); 647 break; 648 default: 649 return -EINVAL; 650 } 651 652 return 0; 653 } 654 655 struct sigaction sigtable[6]; 656 657 int shell_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old) 658 { 659 struct sigaction *sat; 660 661 switch(sig){ 662 case SIGALRM: 663 sat = &sigtable[0]; 664 break; 665 case SIGFPE: 666 sat = &sigtable[1]; 667 break; 668 case SIGILL: 669 sat = &sigtable[2]; 670 break; 671 case SIGSEGV: 672 sat = &sigtable[3]; 673 break; 674 case SIGBUS: 675 sat = &sigtable[4]; 676 break; 677 case SIGABRT: 678 sat = &sigtable[5]; 679 break; 680 default: 681 return -EINVAL; 682 } 683 684 if (old != NULL) 685 memcpy(old, sat, sizeof(struct sigaction)); 686 687 memcpy(sat, sa, sizeof(struct sigaction)); 688 689 return 0; 690 } 691 692 int shell_madvise(void *a, size_t b, int c) 693 { 694 return 0; 695 } 696 -
EcnlProtoTool/trunk/ntshell/src/main.cfg
r321 r331 61 61 CRE_SEM(SEM_FILESYSTEM, { TA_TPRI, 1, 1 }); 62 62 63 CRE_TSK(MRUBY_TASK, { TA_NULL, 0, mruby_task, MRUBY_PRIORITY, MRUBY_STACK_SIZE, (void *)0x20 600000 });63 CRE_TSK(MRUBY_TASK, { TA_NULL, 0, mruby_task, MRUBY_PRIORITY, MRUBY_STACK_SIZE, (void *)0x20100000 }); 64 64 CRE_FLG(FLG_SELECT_WAIT, { TA_WMUL, 0x00 }); -
EcnlProtoTool/trunk/ntshell/src/main.h
r321 r331 56 56 57 57 #define MAIN_STACK_SIZE 2048 /* メインタスクのスタック領域のサイズ */ 58 #define MRUBY_STACK_SIZE 0x 100000 /* mruby実行タスクのスタック領域のサイズ */58 #define MRUBY_STACK_SIZE 0x00800000 /* mruby実行タスクのスタック領域のサイズ */ 59 59 60 60 #define NUM_MAIN_DATAQUEUE 1 /* メインタスクで待ち受けているデータキューのサイズ */ -
EcnlProtoTool/trunk/ntshell/src/route_cfg.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 44 44 #include <netinet/in_var.h> 45 45 46 /* IPv6 に関する定義 */ 47 48 #ifdef _IP6_CFG 49 50 #if NUM_IN6_ROUTE_ENTRY > 0 51 52 T_IN6_RTENTRY routing6_tbl[NUM_IN6_ROUTE_ENTRY]; 53 54 #endif /* of #if NUM_IN6_ROUTE_ENTRY > 0 */ 55 56 #endif /* of #ifdef _IP6_CFG */ 57 46 58 /* IPv4 に関する定義 */ 47 59 48 #ifdef SUPPORT_INET460 #ifdef _IP4_CFG 49 61 50 62 #ifdef SUPPORT_LOOP 51 63 52 T_IN4_RTENTRY routing _tbl[NUM_ROUTE_ENTRY] = {64 T_IN4_RTENTRY routing4_tbl[NUM_IN4_ROUTE_ENTRY] = { 53 65 { 0, 0, 0 }, 54 66 }; … … 58 70 #ifdef SUPPORT_PPP 59 71 60 T_IN4_RTENTRY routing _tbl[NUM_ROUTE_ENTRY] = {72 T_IN4_RTENTRY routing4_tbl[NUM_IN4_ROUTE_ENTRY] = { 61 73 { 0, 0, 0 }, 62 74 }; … … 66 78 #ifdef SUPPORT_ETHER 67 79 68 T_IN4_RTENTRY routing _tbl[NUM_ROUTE_ENTRY] = {80 T_IN4_RTENTRY routing4_tbl[NUM_IN4_ROUTE_ENTRY] = { 69 81 70 82 /* 異なる LAN、default gateway による間接配送 */ … … 82 94 #endif /* of #ifdef SUPPORT_ETHER */ 83 95 84 #endif /* of #ifdef SUPPORT_INET4 */ 85 86 /* IPv6 に関する定義 */ 87 88 #ifdef SUPPORT_INET6 89 90 #if NUM_ROUTE_ENTRY > 0 91 92 T_IN6_RTENTRY routing_tbl[NUM_ROUTE_ENTRY] = { }; 93 94 #endif /* of #if NUM_ROUTE_ENTRY > 0 */ 95 96 #endif /* of #ifdef SUPPORT_INET6 */ 96 #endif /* of #ifdef _IP4_CFG */ -
EcnlProtoTool/trunk/ntshell/src/socket_stub.c
r321 r331 35 35 * @(#) $Id$ 36 36 */ 37 #include <sys/types.h> 38 #include <stdint.h> 39 #if 0 40 #include <sys/socket.h> 41 #include <sys/un.h> 42 #include <netinet/in.h> 43 #include <netinet/tcp.h> 44 #include <arpa/inet.h> 45 #include <netdb.h> 46 #endif 47 #include <fcntl.h> 48 #include "sys/unistd.h" 49 #include <stddef.h> 50 #include <string.h> 51 #include <stdlib.h> 37 #include "shellif.h" 52 38 #include <kernel.h> 53 39 #include <t_syslog.h> 54 40 #include <t_stdlib.h> 41 #include <string.h> 55 42 #include <sil.h> 56 #include <stdlib.h>57 #include <string.h>58 #include <stdio.h>59 43 #include <setjmp.h> 60 44 #include "syssvc/syslog.h" … … 74 58 #include "ff.h" 75 59 #include "socket_stub.h" 76 #define SO_REUSEADDR 2 60 61 #define SOCKET_TIMEOUT 2000000 77 62 78 63 typedef struct id_table_t { … … 107 92 } 108 93 109 return - 1;94 return -ENOMEM; 110 95 } 111 96 … … 120 105 return 0; 121 106 } 122 return - 1;107 return -EINVAL; 123 108 } 124 109 125 110 int delete_tcp_rep(int repid) 126 111 { 127 delete_tcp_fd(tmax_tcp_cepid + repid);112 return delete_tcp_fd(tmax_tcp_cepid + repid); 128 113 } 129 114 … … 145 130 typedef struct _IO_FILE SOCKET; 146 131 147 int s ocket(int family, int type, int protocol)132 int shell_socket(int family, int type, int protocol) 148 133 { 149 134 SOCKET *fp; 135 unsigned int flags; 150 136 151 137 switch (family) { … … 154 140 break; 155 141 default: 156 return -1; 157 } 142 return -EAFNOSUPPORT; 143 } 144 145 flags = type & (SOCK_CLOEXEC|SOCK_NONBLOCK); 146 type &= ~flags; 158 147 159 148 switch (type) { … … 165 154 break; 166 155 default: 167 return - 1;156 return -ENOPROTOOPT; 168 157 } 169 158 170 159 if (fp == NULL) { 171 return - 1;160 return -ENOMEM; 172 161 } 173 162 … … 175 164 fp->socket.type = type; 176 165 fp->socket.protocol = protocol; 166 fp->socket.flags = flags; 177 167 178 168 return fp->fd; 179 169 } 180 170 181 int bind(int fd, const struct sockaddr *addr, socklen_t len)171 int shell_bind(int fd, const struct sockaddr *addr, socklen_t len) 182 172 { 183 173 SOCKET *fp = fd_to_fp(fd); 184 if (fp == NULL) { 185 return -1; 186 } 187 188 if (fp->socket.family != addr->sa_family) { 189 return -1; 190 } 174 if (fp == NULL) 175 return -EBADF; 176 if (fp->socket.family != addr->sa_family) 177 return -EINVAL; 191 178 192 179 ER ret; … … 194 181 case AF_INET: { 195 182 if (len < 8) { 196 return - 1;183 return -EINVAL; 197 184 } 198 185 struct sockaddr_in *addr_in = (struct sockaddr_in *)addr; … … 202 189 ID cepid = new_id(tcp_cepid_table, tcp_cepid_table_count); 203 190 if (cepid < 0) 204 return - 1;191 return -ENOMEM; 205 192 206 193 fp->socket.buf_size = 512 + 512; 207 194 fp->socket.buf = id_to_buff(cepid); 208 T_TCP_CCEP ccep = { 0, fp->socket.buf, 512, &fp->socket.buf[512], 512, socket_tcp_callback };195 T_TCP_CCEP ccep = { 0, fp->socket.buf, 512, &fp->socket.buf[512], 512, (FP)socket_tcp_callback }; 209 196 ret = tcp_cre_cep(cepid, &ccep); 210 197 if (ret != E_OK) { 211 198 delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid); 212 return - 1;199 return -ENOMEM; 213 200 } 214 201 fp->handle = cepid; … … 219 206 ID cepid = new_id(udp_cepid_table, udp_cepid_table_count); 220 207 if (cepid < 0) 221 return - 1;222 223 T_UDP_CCEP ccep = { 0, {ntohl(addr_in->sin_addr.s_addr), ntohs(addr_in->sin_port)}, socket_udp_callback };208 return -ENOMEM; 209 210 T_UDP_CCEP ccep = { 0, {ntohl(addr_in->sin_addr.s_addr), ntohs(addr_in->sin_port)}, (FP)socket_udp_callback }; 224 211 ret = udp_cre_cep(cepid, &ccep); 225 212 if (ret != E_OK) { 226 213 delete_id(udp_cepid_table, udp_cepid_table_count, cepid); 227 return - 1;214 return -ENOMEM; 228 215 } 229 216 fp->handle = cepid; … … 232 219 } 233 220 default: 234 return - 1;221 return -ENOPROTOOPT; 235 222 } 236 223 break; … … 238 225 case AF_INET6: { 239 226 if (len < 20) { 240 return - 1;227 return -EINVAL; 241 228 } 242 229 memcpy(&fp->socket.laddr4, addr, len); … … 248 235 } 249 236 250 int listen(int fd, int backlog)237 int shell_listen(int fd, int backlog) 251 238 { 252 239 SOCKET *fp = fd_to_fp(fd); 253 if ((fp == NULL) || (fp->socket.type != SOCK_STREAM)) { 254 return -1; 255 } 240 if (fp == NULL) 241 return -EBADF; 242 if (fp->socket.type != SOCK_STREAM) 243 return -EINVAL; 256 244 257 245 fp->socket.backlog = backlog; … … 262 250 ID repid = new_id(tcp_repid_table, tcp_repid_table_count); 263 251 if (repid < 0) 264 return - 1;252 return -ENOMEM; 265 253 266 254 struct sockaddr_in *laddr = &fp->socket.laddr4; … … 269 257 if (ret != E_OK) { 270 258 delete_id(tcp_repid_table, tcp_repid_table_count, repid); 271 return - 1;259 return -ENOMEM; 272 260 } 273 261 fp->socket.repid = repid; … … 282 270 } 283 271 284 int connect(int fd, const struct sockaddr *addr, socklen_t len)272 int shell_connect(int fd, const struct sockaddr *addr, socklen_t len) 285 273 { 286 274 SOCKET *fp = fd_to_fp(fd); 287 if ((fp == NULL) || (fp->socket.type != SOCK_STREAM)) { 288 return -1; 289 } 275 if (fp == NULL) 276 return -EBADF; 277 if (fp->socket.type != SOCK_STREAM) 278 return -EINVAL; 290 279 291 280 ER ret; … … 293 282 case AF_INET: { 294 283 if (len < 8) { 295 return - 1;284 return -EINVAL; 296 285 } 297 286 if (fp->socket.cepid == 0) { 298 287 ID cepid = new_id(tcp_cepid_table, tcp_cepid_table_count); 299 288 if (cepid < 0) 300 return - 1;289 return -ENOMEM; 301 290 302 291 fp->socket.buf_size = 512 + 512; 303 292 fp->socket.buf = id_to_buff(cepid); 304 T_TCP_CCEP ccep = { 0, fp->socket.buf, 512, &fp->socket.buf[512], 512, socket_tcp_callback };293 T_TCP_CCEP ccep = { 0, fp->socket.buf, 512, &fp->socket.buf[512], 512, (FP)socket_tcp_callback }; 305 294 ret = tcp_cre_cep(cepid, &ccep); 306 295 if (ret != E_OK) { 307 296 delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid); 308 return - 1;297 return -ENOMEM; 309 298 } 310 299 fp->handle = cepid; … … 317 306 T_IPV4EP lep = { ntohl(laddr->sin_addr.s_addr), ntohs(laddr->sin_port) }; 318 307 T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) }; 319 ret = tcp_con_cep(fp->socket.cepid, &lep, &rep, TMO_FEVR);308 ret = tcp_con_cep(fp->socket.cepid, &lep, &rep, SOCKET_TIMEOUT); 320 309 if (ret < 0) { 321 return - 1;310 return -EHOSTUNREACH; 322 311 } 323 312 break; … … 331 320 } 332 321 333 int accept(int fd, struct sockaddr *addr, socklen_t *len)322 int shell_accept(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict len) 334 323 { 335 324 SOCKET *lfp = fd_to_fp(fd); 336 if ((lfp == NULL) || (lfp->socket.type != SOCK_STREAM)) { 337 return -1; 338 } 325 if (lfp == NULL) 326 return -EBADF; 327 if (lfp->socket.type != SOCK_STREAM) 328 return -EINVAL; 339 329 340 330 SOCKET *fp = new_tcp_fd(0); 341 331 if (fp == NULL) { 342 return - 1;332 return -ENOMEM; 343 333 } 344 334 … … 352 342 cepid = new_id(tcp_cepid_table, tcp_cepid_table_count); 353 343 if (cepid < 0) 354 return - 1;344 return -ENOMEM; 355 345 356 346 fp->socket.buf_size = 512 + 512; 357 347 fp->socket.buf = id_to_buff(cepid); 358 T_TCP_CCEP ccep = { 0, fp->socket.buf, 512, &fp->socket.buf[512], 512, socket_tcp_callback };348 T_TCP_CCEP ccep = { 0, fp->socket.buf, 512, &fp->socket.buf[512], 512, (FP)socket_tcp_callback }; 359 349 ret = tcp_cre_cep(cepid, &ccep); 360 350 if (ret != E_OK) { 361 351 delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid); 362 return - 1;352 return -ENOMEM; 363 353 } 364 354 fp->handle = cepid; … … 375 365 ret = tcp_acp_cep(fp->socket.cepid, fp->socket.repid, &rep, TMO_FEVR); 376 366 if (ret < 0) { 377 return - 1;367 return -ENOMEM; 378 368 } 379 369 struct sockaddr_in *raddr = &fp->socket.raddr4; … … 385 375 } 386 376 case AF_INET6: { 387 break;377 return -EAFNOSUPPORT; 388 378 } 389 379 } … … 392 382 int sz = *len; 393 383 if (sz < 8) { 394 return - 1;384 return -EINVAL; 395 385 } 396 386 struct sockaddr_in *raddr = &fp->socket.raddr4; … … 404 394 } 405 395 406 ssize_t s end(int fd, const void *buf, size_t len, int flags)396 ssize_t shell_send(int fd, const void *buf, size_t len, int flags) 407 397 { 408 398 SOCKET *fp = fd_to_fp(fd); 409 399 if (fp == NULL) { 410 return - 1;400 return -EBADF; 411 401 } 412 402 … … 417 407 case SOCK_STREAM: { 418 408 if (flags & MSG_OOB) { 419 ret = tcp_snd_oob(fp->socket.cepid, (void *)buf, len, TMO_FEVR);409 ret = tcp_snd_oob(fp->socket.cepid, (void *)buf, len, SOCKET_TIMEOUT); 420 410 if (ret < 0) { 421 return - 1;411 return -ECOMM; 422 412 } 423 413 } 424 414 else { 425 ret = tcp_snd_dat(fp->socket.cepid, (void *)buf, len, TMO_FEVR);415 ret = tcp_snd_dat(fp->socket.cepid, (void *)buf, len, SOCKET_TIMEOUT); 426 416 if (ret < 0) { 427 return - 1;417 return -ECOMM; 428 418 } 429 419 } … … 431 421 } 432 422 case SOCK_DGRAM: { 433 return - 1;434 } 435 } 436 break; 437 } 438 case AF_INET6: { 439 break;423 return -EINVAL; 424 } 425 } 426 break; 427 } 428 case AF_INET6: { 429 return -EAFNOSUPPORT; 440 430 } 441 431 } … … 444 434 } 445 435 446 ssize_t s endto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen)436 ssize_t shell_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen) 447 437 { 448 438 SOCKET *fp = fd_to_fp(fd); 449 439 if (fp == NULL) { 450 return - 1;440 return -EBADF; 451 441 } 452 442 … … 457 447 case SOCK_STREAM: { 458 448 if ((addr != NULL) && (alen != 0)) { 459 return - 1;449 return -EINVAL; 460 450 } 461 451 462 452 if (flags & MSG_OOB) { 463 ret = tcp_snd_oob(fp->socket.cepid, (void *)buf, len, TMO_FEVR);453 ret = tcp_snd_oob(fp->socket.cepid, (void *)buf, len, SOCKET_TIMEOUT); 464 454 if (ret < 0) { 465 return - 1;455 return -ECOMM; 466 456 } 467 457 } 468 458 else { 469 ret = tcp_snd_dat(fp->socket.cepid, (void *)buf, len, TMO_FEVR);459 ret = tcp_snd_dat(fp->socket.cepid, (void *)buf, len, SOCKET_TIMEOUT); 470 460 if (ret < 0) { 471 return - 1;461 return -ECOMM; 472 462 } 473 463 } … … 477 467 int sz = alen; 478 468 if (sz < 8) { 479 return - 1;469 return -EINVAL; 480 470 } 481 471 struct sockaddr_in *raddr = &fp->socket.raddr4; … … 483 473 memcpy(raddr, addr, sz); 484 474 T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) }; 485 ret = udp_snd_dat(fp->socket.cepid, &rep, (void *)buf, len, TMO_FEVR); 475 ret = udp_snd_dat(fp->socket.cepid, &rep, (void *)buf, len, 476 (fp->socket.flags & O_NONBLOCK) ? 0 : SOCKET_TIMEOUT); 486 477 if (ret < 0) { 487 return - 1;488 } 489 break; 490 } 491 } 492 break; 493 } 494 case AF_INET6: { 495 break;478 return -ECOMM; 479 } 480 break; 481 } 482 } 483 break; 484 } 485 case AF_INET6: { 486 return -EAFNOSUPPORT; 496 487 } 497 488 } … … 500 491 } 501 492 502 ssize_t recv(int fd, void *buf, size_t len, int flags) 493 ssize_t shell_sendmsg(int fd, const struct msghdr *msg, int flags) 494 { 495 no_implement("sendmsg\n"); 496 return -ENOSYS; 497 } 498 499 ssize_t shell_recv(int fd, void *buf, size_t len, int flags) 503 500 { 504 501 SOCKET *fp = fd_to_fp(fd); 505 502 if (fp == NULL) { 506 return - 1;503 return -EBADF; 507 504 } 508 505 … … 515 512 ret = tcp_rcv_oob(fp->socket.cepid, buf, len); 516 513 if (ret < 0) { 517 return - 1;514 return -ECOMM; 518 515 } 519 516 } … … 521 518 ret = tcp_rcv_dat(fp->socket.cepid, buf, len, TMO_FEVR); 522 519 if (ret < 0) { 523 return - 1;520 return -ECOMM; 524 521 } 525 522 } … … 528 525 case SOCK_DGRAM: { 529 526 T_IPV4EP rep = { 0, 0 }; 530 ret = udp_rcv_dat(fp->socket.cepid, &rep, buf, len, TMO_FEVR);527 ret = udp_rcv_dat(fp->socket.cepid, &rep, buf, len, (fp->socket.flags & O_NONBLOCK) ? 0 : TMO_FEVR); 531 528 if (ret < 0) { 532 return - 1;533 } 534 } 535 } 536 break; 537 } 538 case AF_INET6: { 539 break;529 return -ECOMM; 530 } 531 } 532 } 533 break; 534 } 535 case AF_INET6: { 536 return -EAFNOSUPPORT; 540 537 } 541 538 } … … 544 541 } 545 542 546 ssize_t recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *alen)543 ssize_t shell_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *__restrict addr, socklen_t *__restrict alen) 547 544 { 548 545 SOCKET *fp = fd_to_fp(fd); 549 546 if (fp == NULL) { 550 return - 1;547 return -EBADF; 551 548 } 552 549 … … 559 556 ret = tcp_rcv_oob(fp->socket.cepid, buf, len); 560 557 if (ret < 0) { 561 return - 1;558 return -ECOMM; 562 559 } 563 560 } … … 565 562 ret = tcp_rcv_dat(fp->socket.cepid, buf, len, TMO_FEVR); 566 563 if (ret < 0) { 567 return - 1;564 return -ECOMM; 568 565 } 569 566 } … … 574 571 ret = udp_rcv_dat(fp->socket.cepid, &rep, buf, len, TMO_FEVR); 575 572 if (ret < 0) { 576 return - 1;573 return -ECOMM; 577 574 } 578 575 int sz = *alen; … … 590 587 } 591 588 case AF_INET6: { 592 break;589 return -EAFNOSUPPORT; 593 590 } 594 591 } … … 597 594 } 598 595 599 int shutdown(int fd, int how) 596 ssize_t shell_recvmsg(int fd, struct msghdr *msg, int flags) 597 { 598 no_implement("recvmsg\n"); 599 return -ENOSYS; 600 } 601 602 int shell_shutdown(int fd, int how) 600 603 { 601 604 SOCKET *fp = fd_to_fp(fd); 602 605 if (fp == NULL) { 603 return - 1;606 return -EBADF; 604 607 } 605 608 … … 611 614 ret = tcp_sht_cep(fp->socket.cepid); 612 615 if (ret < 0) { 613 return - 1;614 } 615 break; 616 } 617 } 618 break; 619 } 620 case AF_INET6: { 621 break;616 return -ECOMM; 617 } 618 break; 619 } 620 } 621 break; 622 } 623 case AF_INET6: { 624 return -EAFNOSUPPORT; 622 625 } 623 626 } … … 626 629 } 627 630 628 int getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen)631 int shell_getsockopt(int fd, int level, int optname, void *optval, socklen_t *__restrict optlen) 629 632 { 630 633 SOCKET *fp = fd_to_fp(fd); 631 634 if (fp == NULL) { 632 return - 1;635 return -EBADF; 633 636 } 634 637 … … 650 653 ret = tcp_get_opt(fp->socket.cepid, optname, (void *)optval, *optlen); 651 654 if (ret < 0) { 652 return - 1;655 return -EINVAL; 653 656 } 654 657 *optlen = ret; … … 660 663 ret = udp_get_opt(fp->socket.cepid, optname, (void *)optval, *optlen); 661 664 if (ret < 0) { 662 return - 1;665 return -EINVAL; 663 666 } 664 667 *optlen = ret; … … 669 672 } 670 673 case AF_INET6: { 671 break;674 return -EAFNOSUPPORT; 672 675 } 673 676 } … … 676 679 } 677 680 678 int s etsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen)681 int shell_setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen) 679 682 { 680 683 SOCKET *fp = fd_to_fp(fd); 681 684 if (fp == NULL) { 682 return - 1;685 return -EBADF; 683 686 } 684 687 … … 700 703 ret = tcp_set_opt(fp->socket.cepid, optname, (void *)optval, optlen); 701 704 if (ret < 0) { 702 return - 1;705 return -EINVAL; 703 706 } 704 707 break; … … 709 712 ret = udp_set_opt(fp->socket.cepid, optname, (void *)optval, optlen); 710 713 if (ret < 0) { 711 return - 1;712 } 713 break; 714 } 715 } 716 break; 717 } 718 case AF_INET6: { 719 break;714 return -EINVAL; 715 } 716 break; 717 } 718 } 719 break; 720 } 721 case AF_INET6: { 722 return -EAFNOSUPPORT; 720 723 } 721 724 } … … 735 738 //return -1; 736 739 } 737 ret = tcp_cls_cep(cepid, TMO_FEVR);740 ret = tcp_cls_cep(cepid, (fp->socket.repid != 0) ? 0 : SOCKET_TIMEOUT); 738 741 if (ret < 0) { 739 742 //return -1; … … 743 746 delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid); 744 747 if (ret < 0) { 745 return - 1;748 return -EINVAL; 746 749 } 747 750 } … … 752 755 delete_id(tcp_repid_table, tcp_repid_table_count, repid); 753 756 if (ret < 0) { 754 return - 1;757 return -EINVAL; 755 758 } 756 759 } 757 760 else { 758 return - 1;759 } 760 break; 761 } 762 case AF_INET6: { 763 break;761 return -EINVAL; 762 } 763 break; 764 } 765 case AF_INET6: { 766 return -EAFNOSUPPORT; 764 767 } 765 768 } … … 770 773 size_t tcp_fd_read(struct _IO_FILE *fp, unsigned char *dst, size_t dstsz) 771 774 { 772 return recv(fp->fd, dst, dstsz, 0);775 return shell_recv(fp->fd, dst, dstsz, 0); 773 776 } 774 777 775 778 size_t tcp_fd_write(struct _IO_FILE *fp, const unsigned char *src, size_t srcsz) 776 779 { 777 return s end(fp->fd, src, srcsz, 0);780 return shell_send(fp->fd, src, srcsz, 0); 778 781 } 779 782 780 783 off_t tcp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org) 781 784 { 782 return -1; 785 return -EPERM; 786 } 787 788 int tcp_fd_ioctl(struct _IO_FILE *fp, int req, void *arg) 789 { 790 return -EINVAL; 783 791 } 784 792 … … 794 802 delete_id(udp_cepid_table, udp_cepid_table_count, cepid); 795 803 if (ret < 0) { 796 return - 1;797 } 798 break; 799 } 800 case AF_INET6: { 801 break;804 return -EINVAL; 805 } 806 break; 807 } 808 case AF_INET6: { 809 return -EAFNOSUPPORT; 802 810 } 803 811 } … … 808 816 size_t udp_fd_read(struct _IO_FILE *fp, unsigned char *dst, size_t dstsz) 809 817 { 810 return recv(fp->fd, dst, dstsz, 0);818 return shell_recv(fp->fd, dst, dstsz, 0); 811 819 } 812 820 813 821 size_t udp_fd_write(struct _IO_FILE *fp, const unsigned char *src, size_t srcsz) 814 822 { 815 return s end(fp->fd, src, srcsz, 0);823 return shell_send(fp->fd, src, srcsz, 0); 816 824 } 817 825 818 826 off_t udp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org) 819 827 { 820 return -1; 828 return -EPERM; 829 } 830 831 int udp_fd_ioctl(struct _IO_FILE *fp, int req, void *arg) 832 { 833 return -EINVAL; 821 834 } 822 835 -
EcnlProtoTool/trunk/ntshell/src/socket_stub.h
r321 r331 38 38 #define SOCKET_STUB_H 39 39 40 typedef unsigned socklen_t;41 typedef unsigned short sa_family_t;42 43 struct sockaddr {44 sa_family_t sa_family;45 char sa_data[14];46 };47 48 40 struct addrinfo { 49 41 int ai_flags; … … 57 49 }; 58 50 59 #define AF_INET 260 #define AF_INET6 1061 62 #define SOCK_STREAM 163 #define SOCK_DGRAM 264 65 51 typedef uint16_t in_port_t; 66 52 typedef uint32_t in_addr_t; … … 82 68 } __in6_union; 83 69 }; 84 #define s6_addr __in6_union.__s6_addr85 #define s6_addr16 __in6_union.__s6_addr1686 #define s6_addr32 __in6_union.__s6_addr3270 //#define s6_addr __in6_union.__s6_addr 71 //#define s6_addr16 __in6_union.__s6_addr16 72 //#define s6_addr32 __in6_union.__s6_addr32 87 73 88 74 struct sockaddr_in6 … … 94 80 uint32_t sin6_scope_id; 95 81 }; 96 97 #define MSG_OOB 0x000198 82 99 83 typedef struct socket_t { … … 124 108 size_t (*read)(struct _IO_FILE *, unsigned char *, size_t); 125 109 size_t (*write)(struct _IO_FILE *, const unsigned char *, size_t); 110 off_t (*seek)(struct _IO_FILE *, off_t, int); 111 int (*ioctl)(struct _IO_FILE *, int, void *); 126 112 int readevt_r; 127 113 int readevt_w; … … 132 118 union { 133 119 FIL file; 120 struct { 121 DIR dir; 122 struct dirent dirent; 123 }; 134 124 socket_t socket; 135 125 }; … … 156 146 extern size_t sio_read(struct _IO_FILE *fp, unsigned char *data, size_t len); 157 147 extern size_t sio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len); 148 extern off_t sio_seek(struct _IO_FILE *fp, off_t ofs, int org); 149 extern int sio_ioctl(struct _IO_FILE *fp, int req, void *arg); 158 150 159 151 extern int file_close(struct _IO_FILE *fp); 160 152 extern size_t file_read(struct _IO_FILE *fp, unsigned char *data, size_t len); 161 153 extern size_t file_write(struct _IO_FILE *fp, const unsigned char *data, size_t len); 154 extern off_t file_seek(struct _IO_FILE *fp, off_t ofs, int org); 155 extern int file_ioctl(struct _IO_FILE *fp, int req, void *arg); 156 157 extern int dir_close(struct _IO_FILE *fp); 158 extern size_t dir_read(struct _IO_FILE *fp, unsigned char *data, size_t len); 159 extern size_t dir_write(struct _IO_FILE *fp, const unsigned char *data, size_t len); 160 extern off_t dir_seek(struct _IO_FILE *fp, off_t ofs, int org); 161 extern int dir_ioctl(struct _IO_FILE *fp, int req, void *arg); 162 162 163 163 extern int tcp_fd_close(struct _IO_FILE *fp); 164 164 extern size_t tcp_fd_read(struct _IO_FILE *fp, unsigned char *data, size_t len); 165 165 extern size_t tcp_fd_write(struct _IO_FILE *fp, const unsigned char *data, size_t len); 166 extern off_t tcp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org); 167 extern int tcp_fd_ioctl(struct _IO_FILE *fp, int req, void *arg); 166 168 167 169 extern int udp_fd_close(struct _IO_FILE *fp); 168 170 extern size_t udp_fd_read(struct _IO_FILE *fp, unsigned char *data, size_t len); 169 171 extern size_t udp_fd_write(struct _IO_FILE *fp, const unsigned char *data, size_t len); 172 extern off_t udp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org); 173 extern int udp_fd_ioctl(struct _IO_FILE *fp, int req, void *arg); 170 174 171 175 struct _IO_FILE *fd_to_fp(int fd); … … 179 183 struct _IO_FILE *fileid_to_fd(int fileid); 180 184 185 struct _IO_FILE *new_dir_fd(int dirid); 186 int delete_dir_fd(int dirid); 187 struct _IO_FILE *dirid_to_fd(int dirid); 188 181 189 struct _IO_FILE *new_tcp_fd(int tcpid); 182 190 int delete_tcp_fd(int tcpid); -
EcnlProtoTool/trunk/ntshell/src/tinet_app_config.h
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 62 62 63 63 /* 64 * TCPの能動オープンのみサポートすることを指定する。65 */66 67 #ifdef UNDEF_TCP_CFG_PASSIVE_OPEN68 #undef TCP_CFG_PASSIVE_OPEN69 #endif70 71 /*72 64 * TCP 通信端点の送受信ウィンドバッファの省コピー機能 73 65 * 注意: Makefile で指定している。 … … 98 90 #ifdef USE_TCP_MSS_SEG 99 91 92 #ifdef SUPPORT_INET6 93 94 #define TCP_CFG_SWBUF_CSAVE_MAX_SIZE (IF_HDR_SIZE + IPV6_MMTU) /* 最大サイズ */ 95 96 #else /* of #ifdef SUPPORT_INET6 */ 97 100 98 #ifdef SUPPORT_INET4 101 99 #define TCP_CFG_SWBUF_CSAVE_MAX_SIZE (IF_HDR_SIZE + IP4_MSS) /* 最大サイズ */ 102 100 #endif 103 101 104 #ifdef SUPPORT_INET6 105 #define TCP_CFG_SWBUF_CSAVE_MAX_SIZE (IF_HDR_SIZE + IPV6_MMTU) /* 最大サイズ */ 106 #endif 102 #endif /* of #ifdef SUPPORT_INET6 */ 107 103 108 104 #else /* of #ifdef USE_TCP_MSS_SEG */ … … 135 131 #endif 136 132 133 #ifdef SUPPORT_INET6 134 135 #define MAX_TCP_SND_SEG TCP6_MSS 136 137 #else /* of #ifdef SUPPORT_INET6 */ 138 137 139 #ifdef SUPPORT_INET4 138 140 #define MAX_TCP_SND_SEG TCP_MSS 139 141 #endif 140 142 141 #ifdef SUPPORT_INET6 142 #define MAX_TCP_SND_SEG TCP6_MSS 143 #endif 143 #endif /* of #ifdef SUPPORT_INET6 */ 144 144 145 145 #endif /* of #ifdef USE_TCP_MSS_SEG */ … … 155 155 #endif 156 156 157 #ifdef SUPPORT_INET6 158 159 #define DEF_TCP_RCV_SEG TCP6_MSS 160 161 #else /* of #ifdef SUPPORT_INET6 */ 162 157 163 #ifdef SUPPORT_INET4 158 164 #define DEF_TCP_RCV_SEG TCP_MSS 159 165 #endif 160 166 161 #ifdef SUPPORT_INET6 162 #define DEF_TCP_RCV_SEG TCP6_MSS 163 #endif 167 #endif /* of #ifdef SUPPORT_INET6 */ 164 168 165 169 #endif /* of #ifdef USE_TCP_MSS_SEG */ … … 235 239 #define UDP_CFG_EXTENTIONS 236 240 241 /* IPv6 に関する定義 */ 242 243 #ifdef SUPPORT_PPP 244 245 #define NUM_IN6_STATIC_ROUTE_ENTRY 0 246 #define NUM_IN6_REDIRECT_ROUTE_ENTRY 0 247 248 #endif /* of #ifdef SUPPORT_PPP */ 249 250 #ifdef SUPPORT_LOOP 251 252 #define NUM_IN6_STATIC_ROUTE_ENTRY 0 253 #define NUM_IN6_REDIRECT_ROUTE_ENTRY 0 254 255 #endif /* of #ifdef SUPPORT_LOOP */ 256 257 #ifdef SUPPORT_ETHER 258 259 #define NUM_IN6_STATIC_ROUTE_ENTRY 0 260 #define NUM_IN6_REDIRECT_ROUTE_ENTRY 1 261 262 #endif /* of #ifdef SUPPORT_ETHER */ 263 237 264 /* IPv4 に関する定義 */ 238 239 #ifdef SUPPORT_INET4240 265 241 266 #ifdef SUPPORT_PPP … … 253 278 #endif 254 279 255 #define NUM_ STATIC_ROUTE_ENTRY1256 #define NUM_ REDIRECT_ROUTE_ENTRY 0280 #define NUM_IN4_STATIC_ROUTE_ENTRY 1 281 #define NUM_IN4_REDIRECT_ROUTE_ENTRY 0 257 282 258 283 #endif /* of #ifdef SUPPORT_PPP */ … … 260 285 #ifdef SUPPORT_ETHER 261 286 262 #ifdef DHCP _CFG287 #ifdef DHCP4_CLI_CFG 263 288 264 289 #define IPV4_ADDR_LOCAL MAKE_IPV4_ADDR(0,0,0,0) … … 266 291 #define IPV4_ADDR_DEFAULT_GW MAKE_IPV4_ADDR(0,0,0,0) 267 292 268 #else /* of #ifdef DHCP _CFG */293 #else /* of #ifdef DHCP4_CLI_CFG */ 269 294 270 295 #define IPV4_ADDR_LOCAL MAKE_IPV4_ADDR(192,168,137,110) … … 272 297 #define IPV4_ADDR_DEFAULT_GW MAKE_IPV4_ADDR(192,168,137,1) 273 298 274 #endif /* of #ifdef DHCP _CFG */275 276 #define NUM_ STATIC_ROUTE_ENTRY3277 #define NUM_ REDIRECT_ROUTE_ENTRY 1299 #endif /* of #ifdef DHCP4_CLI_CFG */ 300 301 #define NUM_IN4_STATIC_ROUTE_ENTRY 3 302 #define NUM_IN4_REDIRECT_ROUTE_ENTRY 1 278 303 279 304 #endif /* of #ifdef SUPPORT_ETHER */ … … 281 306 #ifdef SUPPORT_LOOP 282 307 283 #define NUM_ STATIC_ROUTE_ENTRY1284 #define NUM_ REDIRECT_ROUTE_ENTRY 0308 #define NUM_IN4_STATIC_ROUTE_ENTRY 1 309 #define NUM_IN4_REDIRECT_ROUTE_ENTRY 0 285 310 286 311 #endif /* of #ifdef SUPPORT_LOOP */ 287 288 #endif /* of #ifdef SUPPORT_INET4 */289 290 /* IPv6 に関する定義 */291 292 #ifdef SUPPORT_INET6293 294 #ifdef SUPPORT_PPP295 296 #define NUM_STATIC_ROUTE_ENTRY 0297 #define NUM_REDIRECT_ROUTE_ENTRY 0298 299 #endif /* of #ifdef SUPPORT_PPP */300 301 #ifdef SUPPORT_LOOP302 303 #define NUM_STATIC_ROUTE_ENTRY 0304 #define NUM_REDIRECT_ROUTE_ENTRY 0305 306 #endif /* of #ifdef SUPPORT_LOOP */307 308 #ifdef SUPPORT_ETHER309 310 #define NUM_STATIC_ROUTE_ENTRY 0311 #define NUM_REDIRECT_ROUTE_ENTRY 1312 313 #endif /* of #ifdef SUPPORT_ETHER */314 315 #endif /* of #ifdef SUPPORT_INET6 */316 312 317 313 /* … … 420 416 * IPv6 でのみ割り当てる。 421 417 * 422 * RX62N Ethernet Controler のディバイスドライバ(if_rx62n)の最低割当て長は、418 * MBED Ethernet Controler のディバイスドライバ(if_mbed)の最低割当て長は、 423 419 * イーサネットフレームの最短長である 60(CRC の 4 オクテットを除き、 424 420 * 更にアラインして 62)オクテットである。 -
EcnlProtoTool/trunk/ntshell/src/tinet_main.cfg
r321 r331 43 43 #include "main.h" 44 44 45 INCLUDE("netinet/ip_igmp.cfg"); 46 45 47 /* DHCP クライアント */ 46 48 /*INCLUDE("netapp/tinet_dhcp4_cli.cfg");*/ … … 49 51 /* ECHONET Lite UDP 通信端点 */ 50 52 51 #ifdef SUPPORT_INET4 53 VRID_TCP_REP (USR_TCP_REP1); 54 VRID_TCP_REP (USR_TCP_REP2); 55 VRID_TCP_REP (USR_TCP_REP3); 56 VRID_TCP_REP (USR_TCP_REP4); 52 57 53 VRID_TCP4_REP (USR_TCP_REP1); 54 VRID_TCP4_REP (USR_TCP_REP2); 55 VRID_TCP4_REP (USR_TCP_REP3); 56 VRID_TCP4_REP (USR_TCP_REP4); 58 VRID_TCP_CEP (USR_TCP_CEP1); 59 VRID_TCP_CEP (USR_TCP_CEP2); 60 VRID_TCP_CEP (USR_TCP_CEP3); 61 VRID_TCP_CEP (USR_TCP_CEP4); 62 VRID_TCP_CEP (USR_TCP_CEP5); 63 VRID_TCP_CEP (USR_TCP_CEP6); 64 VRID_TCP_CEP (USR_TCP_CEP7); 65 VRID_TCP_CEP (USR_TCP_CEP8); 57 66 58 VRID_TCP4_CEP (USR_TCP_CEP1); 59 VRID_TCP4_CEP (USR_TCP_CEP2); 60 VRID_TCP4_CEP (USR_TCP_CEP3); 61 VRID_TCP4_CEP (USR_TCP_CEP4); 62 VRID_TCP4_CEP (USR_TCP_CEP5); 63 VRID_TCP4_CEP (USR_TCP_CEP6); 64 VRID_TCP4_CEP (USR_TCP_CEP7); 65 VRID_TCP4_CEP (USR_TCP_CEP8); 67 VRID_UDP_CEP (USR_UDP_CEP1); 68 VRID_UDP_CEP (USR_UDP_CEP2); 69 VRID_UDP_CEP (USR_UDP_CEP3); 70 VRID_UDP_CEP (USR_UDP_CEP4); 66 71 67 VRID_UDP 4_CEP (USR_UDP_CEP1);68 VRID_UDP 4_CEP (USR_UDP_CEP2);69 VRID_UDP 4_CEP (USR_UDP_CEP3);70 VRID_UDP 4_CEP (USR_UDP_CEP4);72 VRID_UDP6_CEP (USR_UDP6_CEP1); 73 VRID_UDP6_CEP (USR_UDP6_CEP2); 74 VRID_UDP6_CEP (USR_UDP6_CEP3); 75 VRID_UDP6_CEP (USR_UDP6_CEP4); 71 76 72 #endif /* of #ifdef SUPPORT_INET4 */73 74 #ifdef SUPPORT_INET675 76 VRID_TCP6_REP (USR_TCP_REP1);77 VRID_TCP6_REP (USR_TCP_REP2);78 VRID_TCP6_REP (USR_TCP_REP3);79 VRID_TCP6_REP (USR_TCP_REP4);80 81 VRID_TCP6_CEP (USR_TCP_CEP1);82 VRID_TCP6_CEP (USR_TCP_CEP2);83 VRID_TCP6_CEP (USR_TCP_CEP3);84 VRID_TCP6_CEP (USR_TCP_CEP4);85 VRID_TCP6_CEP (USR_TCP_CEP5);86 VRID_TCP6_CEP (USR_TCP_CEP6);87 VRID_TCP6_CEP (USR_TCP_CEP7);88 VRID_TCP6_CEP (USR_TCP_CEP8);89 90 VRID_UDP6_CEP (USR_UDP_CEP1);91 VRID_UDP6_CEP (USR_UDP_CEP2);92 VRID_UDP6_CEP (USR_UDP_CEP3);93 VRID_UDP6_CEP (USR_UDP_CEP4);94 95 #endif /* of #ifdef SUPPORT_INET6 */96
Note:
See TracChangeset
for help on using the changeset viewer.