[337] | 1 | /*
|
---|
| 2 | * TOPPERS ECHONET Lite Communication Middleware
|
---|
| 3 | *
|
---|
| 4 | * Copyright (C) 2017 Cores Co., Ltd. Japan
|
---|
| 5 | *
|
---|
| 6 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
| 7 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
| 8 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
| 9 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 10 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 11 | * スコード中に含まれていること.
|
---|
| 12 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 13 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 14 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 15 | * の無保証規定を掲載すること.
|
---|
| 16 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 17 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
| 18 | * と.
|
---|
| 19 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 20 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 21 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
| 22 | * 報告すること.
|
---|
| 23 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 24 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 25 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
| 26 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
| 27 | * 免責すること.
|
---|
| 28 | *
|
---|
| 29 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 30 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
| 31 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
| 32 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
| 33 | * の責任を負わない.
|
---|
| 34 | *
|
---|
| 35 | * @(#) $Id$
|
---|
| 36 | */
|
---|
| 37 | #ifndef SOCKET_STUB_H
|
---|
| 38 | #define SOCKET_STUB_H
|
---|
| 39 |
|
---|
| 40 | struct addrinfo {
|
---|
| 41 | int ai_flags;
|
---|
| 42 | int ai_family;
|
---|
| 43 | int ai_socktype;
|
---|
| 44 | int ai_protocol;
|
---|
| 45 | socklen_t ai_addrlen;
|
---|
| 46 | struct sockaddr *ai_addr;
|
---|
| 47 | char *ai_canonname;
|
---|
| 48 | struct addrinfo *ai_next;
|
---|
| 49 | };
|
---|
| 50 |
|
---|
| 51 | typedef uint16_t in_port_t;
|
---|
| 52 | typedef uint32_t in_addr_t;
|
---|
| 53 | struct in_addr { in_addr_t s_addr; };
|
---|
| 54 |
|
---|
| 55 | struct sockaddr_in {
|
---|
| 56 | sa_family_t sin_family;
|
---|
| 57 | in_port_t sin_port;
|
---|
| 58 | struct in_addr sin_addr;
|
---|
| 59 | uint8_t sin_zero[8];
|
---|
| 60 | };
|
---|
| 61 |
|
---|
| 62 | struct in6_addr
|
---|
| 63 | {
|
---|
| 64 | union {
|
---|
| 65 | uint8_t __s6_addr[16];
|
---|
| 66 | uint16_t __s6_addr16[8];
|
---|
| 67 | uint32_t __s6_addr32[4];
|
---|
| 68 | } __in6_union;
|
---|
| 69 | };
|
---|
| 70 | //#define s6_addr __in6_union.__s6_addr
|
---|
| 71 | //#define s6_addr16 __in6_union.__s6_addr16
|
---|
| 72 | //#define s6_addr32 __in6_union.__s6_addr32
|
---|
| 73 |
|
---|
| 74 | struct sockaddr_in6
|
---|
| 75 | {
|
---|
| 76 | sa_family_t sin6_family;
|
---|
| 77 | in_port_t sin6_port;
|
---|
| 78 | uint32_t sin6_flowinfo;
|
---|
| 79 | struct in6_addr sin6_addr;
|
---|
| 80 | uint32_t sin6_scope_id;
|
---|
| 81 | };
|
---|
| 82 |
|
---|
| 83 | typedef struct socket_t {
|
---|
| 84 | int family;
|
---|
| 85 | int type;
|
---|
| 86 | int protocol;
|
---|
| 87 | int cepid;
|
---|
| 88 | int repid;
|
---|
| 89 | int backlog;
|
---|
| 90 | unsigned int flags;
|
---|
| 91 | union {
|
---|
| 92 | struct sockaddr_in laddr4;
|
---|
| 93 | struct sockaddr_in6 laddr6;
|
---|
| 94 | };
|
---|
| 95 | union {
|
---|
| 96 | struct sockaddr_in raddr4;
|
---|
| 97 | struct sockaddr_in6 raddr6;
|
---|
| 98 | };
|
---|
| 99 | int buf_size;
|
---|
| 100 | unsigned char *buf;
|
---|
[364] | 101 | void *input;
|
---|
| 102 | int len;
|
---|
[337] | 103 | } socket_t;
|
---|
| 104 |
|
---|
[374] | 105 | struct SHELL_DIR {
|
---|
| 106 | FATFS_DIR dir;
|
---|
[337] | 107 | struct dirent dirent;
|
---|
| 108 | };
|
---|
| 109 |
|
---|
[374] | 110 | typedef const struct io_type_s IO_TYPE;
|
---|
| 111 |
|
---|
| 112 | struct SHELL_FILE {
|
---|
[337] | 113 | int fd;
|
---|
[374] | 114 | IO_TYPE *type;
|
---|
[337] | 115 | int handle;
|
---|
| 116 | int readevt_r;
|
---|
| 117 | int readevt_w;
|
---|
| 118 | int writeevt_r;
|
---|
| 119 | int writeevt_w;
|
---|
| 120 | int writable;
|
---|
| 121 | int errorevt_r;
|
---|
| 122 | int errorevt_w;
|
---|
[374] | 123 | void *exinf;
|
---|
[337] | 124 | };
|
---|
| 125 |
|
---|
[374] | 126 | struct io_type_s {
|
---|
| 127 | int (*close)(struct SHELL_FILE *);
|
---|
| 128 | size_t (*read)(struct SHELL_FILE *, unsigned char *, size_t);
|
---|
| 129 | size_t (*write)(struct SHELL_FILE *, const unsigned char *, size_t);
|
---|
| 130 | off_t (*seek)(struct SHELL_FILE *, off_t, int);
|
---|
| 131 | int (*ioctl)(struct SHELL_FILE *, int, void *);
|
---|
| 132 | bool_t (*readable)(struct SHELL_FILE *);
|
---|
| 133 | void (*delete)(struct SHELL_FILE *);
|
---|
| 134 | };
|
---|
| 135 |
|
---|
[337] | 136 | #ifndef bool
|
---|
| 137 | #define bool int
|
---|
| 138 | #endif
|
---|
| 139 | #ifndef true
|
---|
| 140 | #define true 1
|
---|
| 141 | #endif
|
---|
| 142 | #ifndef false
|
---|
| 143 | #define false 0
|
---|
| 144 | #endif
|
---|
| 145 |
|
---|
[374] | 146 | struct SHELL_FILE *new_fp(IO_TYPE *type, int id, int writable);
|
---|
| 147 | int delete_fd_by_id(IO_TYPE *type, int id);
|
---|
| 148 | struct SHELL_FILE *fd_to_fp(int fd);
|
---|
| 149 | struct SHELL_FILE *id_to_fd(IO_TYPE *type, int id);
|
---|
[337] | 150 |
|
---|
[374] | 151 | int delete_fp(struct SHELL_FILE *fp);
|
---|
[337] | 152 | void clean_fd();
|
---|
| 153 |
|
---|
[374] | 154 | void sys_tlsf_init(void);
|
---|
[337] | 155 |
|
---|
| 156 | #endif // !SOCKET_STUB_H
|
---|