[388] | 1 | /*
|
---|
| 2 | * TINET (TCP/IP Protocol Stack)
|
---|
| 3 | *
|
---|
| 4 | * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
|
---|
| 5 | * Tomakomai National College of Technology, JAPAN
|
---|
| 6 | *
|
---|
| 7 | * ä¸è¨èä½æ¨©è
|
---|
| 8 | ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
| 9 | * ã«ãã£ã¦å
|
---|
| 10 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
| 11 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
| 12 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
| 13 | å¸ï¼ä»¥ä¸ï¼
|
---|
| 14 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 15 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 16 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 17 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 18 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 19 | * ç¨ã§ããå½¢ã§åé
|
---|
| 20 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 21 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 22 | * è
|
---|
| 23 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 24 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 25 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 26 | * ç¨ã§ããªãå½¢ã§åé
|
---|
| 27 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
|
---|
| 28 | * (a) åé
|
---|
| 29 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 30 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 31 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 32 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 33 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 34 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 35 | 責ãããã¨ï¼
|
---|
| 36 | *
|
---|
| 37 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 38 | ã
|
---|
| 39 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
| 40 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
| 41 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
| 42 | *
|
---|
| 43 | * @(#) $Id: netapp_var.h 388 2019-05-22 11:25:18Z coas-nagasima $
|
---|
| 44 | */
|
---|
| 45 |
|
---|
| 46 | #ifndef _NETAPP_VAR_H_
|
---|
| 47 | #define _NETAPP_VAR_H_
|
---|
| 48 |
|
---|
| 49 | /*
|
---|
| 50 | * TOPPERS/JSP ã«ã¼ãã«ãã·ã¹ãã æå» (SYSTIM) ã®å¨æ³¢æ°
|
---|
| 51 | */
|
---|
| 52 |
|
---|
| 53 | #define SYSTIM_HZ ULONG_C(1000000) /* [us] */
|
---|
| 54 |
|
---|
| 55 | /*
|
---|
| 56 | * IPv6/IPv4 ã«é¢ããå®ç¾©
|
---|
| 57 | */
|
---|
| 58 |
|
---|
| 59 | /*
|
---|
| 60 | * æå®ããããã¯ãã«å¯¾ãããµã³ãã«ã¢ããªã±ã¼ã·ã§ã³å
|
---|
| 61 | é¨ã®ãã¯ãã®å®ç¾©
|
---|
| 62 | *
|
---|
| 63 | * SUPPORT_INET6 . . ON ON ON ON
|
---|
| 64 | * SUPPORT_INET4 ON ON . . ON ON
|
---|
| 65 | * API_CFG_IP4MAPPED_ADDR . ON . ON . ON
|
---|
| 66 | * ---------------------- ----------------------
|
---|
| 67 | * NETAPP_IP6_CFG . . ON ON ON ON
|
---|
| 68 | * NETAPP_IP4_CFG ON ON . ON ON ON
|
---|
| 69 | *
|
---|
| 70 | */
|
---|
| 71 |
|
---|
| 72 | #if defined(SUPPORT_INET6)
|
---|
| 73 |
|
---|
| 74 | #define NETAPP_IP6_CFG
|
---|
| 75 |
|
---|
| 76 | #endif /* #if defined(SUPPORT_INET6) */
|
---|
| 77 |
|
---|
| 78 | #if defined(SUPPORT_INET4) || (defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR))
|
---|
| 79 | #define NETAPP_IP4_CFG
|
---|
| 80 | #endif
|
---|
| 81 |
|
---|
| 82 | /*
|
---|
| 83 | * IPv4 㨠IPv6 ãã³ã³ãã¤ã«æã«é¸æããããã®ãã¯ã
|
---|
| 84 | */
|
---|
| 85 |
|
---|
| 86 | #define DBG_LINE_SIZE 63
|
---|
| 87 |
|
---|
| 88 | #if defined(SUPPORT_INET6)
|
---|
| 89 |
|
---|
| 90 | #define T_IN_ADDR T_IN6_ADDR
|
---|
| 91 | #define T_IPEP T_IPV6EP
|
---|
| 92 | #define IP_ADDRANY IPV6_ADDRANY
|
---|
| 93 | #define T_TCPN_CREP T_TCP6_CREP
|
---|
| 94 |
|
---|
| 95 | #else /* of #if defined(SUPPORT_INET6) */
|
---|
| 96 |
|
---|
| 97 | #define T_IN_ADDR T_IN4_ADDR
|
---|
| 98 | #define T_IPEP T_IPV4EP
|
---|
| 99 | #define IP_ADDRANY IPV4_ADDRANY
|
---|
| 100 | #define T_TCPN_CREP T_TCP_CREP
|
---|
| 101 |
|
---|
| 102 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
| 103 |
|
---|
| 104 | /*
|
---|
| 105 | * API IPãããã³ã«ã®æå®
|
---|
| 106 | */
|
---|
| 107 |
|
---|
| 108 | #if defined(SUPPORT_INET6)
|
---|
| 109 | #define DEFAULT_API_PROTO API_PROTO_IPV6
|
---|
| 110 | #else
|
---|
| 111 | #define DEFAULT_API_PROTO API_PROTO_IPV4
|
---|
| 112 | #endif
|
---|
| 113 |
|
---|
| 114 | /*
|
---|
| 115 | * resolv_hoststr ãè¿ã flags ã®å¤ã®å®ç¾©
|
---|
| 116 | *
|
---|
| 117 | * 注æ:
|
---|
| 118 | *
|
---|
| 119 | * dns.h ã§å®ç¾©ããã¦ãã DNS_OPCODEã
|
---|
| 120 | * resolver.h ã§å®ç¾©ããã¦ãã DNS_LUP_FLAGS ã¨éãªããªãäºã
|
---|
| 121 | */
|
---|
| 122 |
|
---|
| 123 | #define HOSTSTR_OTHER 0x0000U
|
---|
| 124 | #define HOSTSTR_IPV4 DNS_LUP_FLAGS_NAME_IPV4
|
---|
| 125 | #define HOSTSTR_IPV6 DNS_LUP_FLAGS_NAME_IPV6
|
---|
| 126 | #define HOSTSTR_HOSTNAME DNS_LUP_FLAGS_NAME_HOST
|
---|
| 127 | #define HOSTSTR_FQDN DNS_LUP_FLAGS_NAME_FQDN
|
---|
| 128 |
|
---|
| 129 | /*
|
---|
| 130 | * å®æ°ã®å®ç¾©
|
---|
| 131 | */
|
---|
| 132 |
|
---|
| 133 | #define DBG_LINE_SIZE 63
|
---|
| 134 |
|
---|
| 135 | #if defined(SUPPORT_INET6)
|
---|
| 136 |
|
---|
| 137 | #define NUM_VRID_TCP_CEPS NUM_VRID_TCP6_CEPS
|
---|
| 138 |
|
---|
| 139 | #else /* of #if defined(SUPPORT_INET6) */
|
---|
| 140 |
|
---|
| 141 | #define NUM_VRID_TCP_CEPS NUM_VRID_TCP4_CEPS
|
---|
| 142 |
|
---|
| 143 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
| 144 |
|
---|
| 145 | /*
|
---|
| 146 | * é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã
|
---|
| 147 | */
|
---|
| 148 |
|
---|
| 149 | /* ã¡ãã»ã¼ã¸ããã®èªåºã */
|
---|
| 150 |
|
---|
| 151 | #define MSG2HOST16(p) (msg2host16((void*)&(p)))
|
---|
| 152 | #define MSG2HOST32(p) (msg2host32((void*)&(p)))
|
---|
| 153 |
|
---|
| 154 | /* ã¡ãã»ã¼ã¸ã¸ã®æ¸è¾¼ã¿ */
|
---|
| 155 |
|
---|
| 156 | #define HOST2MSG16(p,v) (host2msg16((void*)&(p),(v)))
|
---|
| 157 | #define HOST2MSG32(p,v) (host2msg32((void*)&(p),(v)))
|
---|
| 158 |
|
---|
| 159 | /*
|
---|
| 160 | * ãããã¯ã¼ã¯çµç±ã³ã³ã½ã¼ã«å
|
---|
| 161 | ¥åºå
|
---|
| 162 | */
|
---|
| 163 |
|
---|
| 164 | #ifdef USE_NET_CONS
|
---|
| 165 |
|
---|
| 166 | /* ãªãã¼ã */
|
---|
| 167 |
|
---|
| 168 | #define syslog net_syslog
|
---|
| 169 | #define serial_ctl_por net_serial_ctl_por
|
---|
| 170 |
|
---|
| 171 | /* é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã */
|
---|
| 172 |
|
---|
| 173 | #define FLUSH_SND_BUFF() flush_snd_buff()
|
---|
| 174 | #define WAI_NET_CONS_PRINTF() syscall(wai_sem(SEM_NET_CONS_PRINTF))
|
---|
| 175 | #define SIG_NET_CONS_PRINTF() sig_sem(SEM_NET_CONS_PRINTF)
|
---|
| 176 |
|
---|
| 177 | #else /* of #ifdef USE_NET_CONS */
|
---|
| 178 |
|
---|
| 179 | /* é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã */
|
---|
| 180 |
|
---|
| 181 | #define FLUSH_SND_BUFF()
|
---|
| 182 | #define WAI_NET_CONS_PRINTF()
|
---|
| 183 | #define SIG_NET_CONS_PRINTF()
|
---|
| 184 |
|
---|
| 185 | #endif /* of #ifdef USE_NET_CONS */
|
---|
| 186 |
|
---|
| 187 | /*
|
---|
| 188 | * é¢æ°
|
---|
| 189 | */
|
---|
| 190 |
|
---|
| 191 | extern const char *in_strtfn (FN fncd);
|
---|
| 192 | extern const char *itron_strerror (ER ercd);
|
---|
| 193 | extern const char *dns_strtype (uint_t type);
|
---|
| 194 | extern const char *dns_strclass (uint_t class);
|
---|
| 195 | extern ER net_syslog(uint_t prio, const char *format, ...) throw();
|
---|
| 196 | extern ER net_serial_ctl_por(ID portid, uint_t ioctl) throw();
|
---|
| 197 | extern void flush_snd_buff (void);
|
---|
| 198 | extern ER discon_net_cons (void);
|
---|
| 199 | extern void wup_net_cons (void);
|
---|
| 200 | extern bool_t tcp6_is_cepid (ID cepid);
|
---|
| 201 | extern ER alloc_tcp6_rep (ID *repid, ID tskid, T_TCP6_CREP *crep);
|
---|
| 202 | extern ER alloc_tcp6_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep);
|
---|
| 203 | extern ER alloc_udp6_cep (ID *cepid, ID tskid, T_UDP6_CCEP *ccep);
|
---|
| 204 | extern ER free_tcp6_rep (ID repid, bool_t call_tcp_del_rep);
|
---|
| 205 | extern ER free_tcp6_cep (ID cepid);
|
---|
| 206 | extern ER free_udp6_cep (ID cepid, bool_t call_udp_del_cep);
|
---|
| 207 | extern bool_t tcp4_is_cepid (ID cepid);
|
---|
| 208 | extern ER alloc_tcp4_rep (ID *repid, ID tskid, T_TCP_CREP *crep);
|
---|
| 209 | extern ER alloc_tcp4_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep);
|
---|
| 210 | extern ER alloc_udp4_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep);
|
---|
| 211 | extern ER free_tcp4_rep (ID repid, bool_t call_tcp_del_rep);
|
---|
| 212 | extern ER free_tcp4_cep (ID cepid);
|
---|
| 213 | extern ER free_udp4_cep (ID cepid, bool_t call_udp_del_cep);
|
---|
| 214 | extern void ping6 (T_IN6_ADDR *addr, uint_t tmo, uint_t len);
|
---|
| 215 | extern void ping4 (T_IN4_ADDR *addr, uint_t tmo, uint_t len);
|
---|
| 216 | extern char *get_ipv6addr (T_IN6_ADDR *addr, char *line);
|
---|
| 217 | extern char *get_ipv4addr (T_IN4_ADDR *addr, char *line);
|
---|
| 218 | extern char *resolv_options (uint_t *flags, char *line, char apip);
|
---|
| 219 | extern char *resolv_hoststr (uint_t *flags, char *hostname, uint_t name_size, char *line);
|
---|
| 220 | extern char *lookup_ipaddr (T_IN_ADDR *addr, char *line, char apip);
|
---|
| 221 | extern uint_t show_dns_domain_name (ID portid, uint8_t *hdr, uint_t offset);
|
---|
| 222 | extern void host2msg16 (void *msg, uint16_t host_data);
|
---|
| 223 | extern void host2msg32 (void *msg, uint32_t host_data);
|
---|
| 224 | extern uint16_t msg2host16 (void *msg);
|
---|
| 225 | extern uint32_t msg2host32 (void *msg);
|
---|
| 226 | extern uint32_t netapp_rand (void);
|
---|
| 227 | extern void netapp_srand (uint32_t seed);
|
---|
| 228 |
|
---|
| 229 | #if defined(SUPPORT_INET6)
|
---|
| 230 |
|
---|
| 231 | #define TCP_CRE_REP(i,r) tcp6_cre_rep(i,r)
|
---|
| 232 | #define TCP_CRE_CEP(i,c) tcp6_cre_cep(i,c)
|
---|
| 233 | #define UDP_CRE_CEP(i,c) udp6_cre_cep(i,c)
|
---|
| 234 | #define TCP_ACP_CEP(c,r,d,t) tcp6_acp_cep(c,r,d,t)
|
---|
| 235 | #define TCP_CON_CEP(c,m,d,t) tcp6_con_cep(c,m,d,t)
|
---|
| 236 |
|
---|
| 237 | #define UDP_SND_DAT(c,d,b,l,t) udp6_snd_dat(c,d,b,l,t)
|
---|
| 238 | #define UDP_RCV_DAT(c,d,b,l,t) udp6_rcv_dat(c,d,b,l,t)
|
---|
| 239 |
|
---|
| 240 | #define TCP_IS_CEPID(i) tcp6_is_cepid(i)
|
---|
| 241 | #define ALLOC_TCP_REP(i,t,r) alloc_tcp6_rep(i,t,r)
|
---|
| 242 | #define ALLOC_TCP_CEP(i,t,c) alloc_tcp6_cep(i,t,c)
|
---|
| 243 | #define ALLOC_UDP_CEP(i,t,c) alloc_udp6_cep(i,t,c)
|
---|
| 244 | #define FREE_TCP_REP(i,r) free_tcp6_rep(i,r)
|
---|
| 245 | #define FREE_TCP_CEP(i) free_tcp6_cep(i)
|
---|
| 246 | #define FREE_UDP_CEP(i,c) free_udp6_cep(i,c)
|
---|
| 247 |
|
---|
| 248 | #define IP2STR(s,a) ipv62str(s,a)
|
---|
| 249 | #define GET_IPADDR(a,l) get_ipv6addr(a,l)
|
---|
| 250 | #define PING(a,t,l) ping6(a,t,l)
|
---|
| 251 |
|
---|
| 252 | #else /* of #if defined(SUPPORT_INET6) */
|
---|
| 253 |
|
---|
| 254 | #if defined(SUPPORT_INET4)
|
---|
| 255 |
|
---|
| 256 | #define TCP_CRE_REP(i,r) tcp_cre_rep(i,r)
|
---|
| 257 | #define TCP_CRE_CEP(i,c) tcp_cre_cep(i,c)
|
---|
| 258 | #define UDP_CRE_CEP(i,c) udp_cre_cep(i,c)
|
---|
| 259 | #define TCP_ACP_CEP(c,r,d,t) tcp_acp_cep(c,r,d,t)
|
---|
| 260 | #define TCP_CON_CEP(c,m,d,t) tcp_con_cep(c,m,d,t)
|
---|
| 261 |
|
---|
| 262 | #define UDP_SND_DAT(c,d,b,l,t) udp_snd_dat(c,d,b,l,t)
|
---|
| 263 | #define UDP_RCV_DAT(c,d,b,l,t) udp_rcv_dat(c,d,b,l,t)
|
---|
| 264 |
|
---|
| 265 | #define TCP_IS_CEPID(i) tcp4_is_cepid(i)
|
---|
| 266 | #define ALLOC_TCP_REP(i,t,r) alloc_tcp4_rep(i,t,r)
|
---|
| 267 | #define ALLOC_TCP_CEP(i,t,c) alloc_tcp4_cep(i,t,c)
|
---|
| 268 | #define ALLOC_UDP_CEP(i,t,c) alloc_udp4_cep(i,t,c)
|
---|
| 269 | #define FREE_TCP_REP(i,r) free_tcp4_rep(i,r)
|
---|
| 270 | #define FREE_TCP_CEP(i) free_tcp4_cep(i)
|
---|
| 271 | #define FREE_UDP_CEP(i,c) free_udp4_cep(i,c)
|
---|
| 272 |
|
---|
| 273 | #define IP2STR(s,a) ip2str(s,a)
|
---|
| 274 | #define GET_IPADDR(a,l) get_ipv4addr(a,l)
|
---|
| 275 | #define PING(a,t,l) ping4(a,t,l)
|
---|
| 276 |
|
---|
| 277 | #endif /* of #if defined(SUPPORT_INET4) */
|
---|
| 278 |
|
---|
| 279 | #endif /* of #if defined(SUPPORT_INET6) */
|
---|
| 280 |
|
---|
| 281 | #endif /* of #ifndef _NETAPP_VAR_H_ */
|
---|