Changeset 331 for EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.h
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.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-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 69 69 70 70 /* 71 * バイトオーダの定義72 */73 74 #define _NET_CFG_LITTLE_ENDIAN 123475 #define _NET_CFG_BIG_ENDIAN 432176 77 #ifdef TARGET_KERNEL_ASP78 79 #if defined(SIL_ENDIAN_LITTLE)80 81 #define _NET_CFG_BYTE_ORDER _NET_CFG_LITTLE_ENDIAN82 83 #elif defined(SIL_ENDIAN_BIG)84 85 #define _NET_CFG_BYTE_ORDER _NET_CFG_BIG_ENDIAN86 87 #else /* of #if defined(SIL_ENDIAN_BIG) */88 89 #error "SIL_ENDIAN expected."90 91 #endif /* of #if defined(SIL_ENDIAN_BIG) */92 93 #endif /* of #ifdef TARGET_KERNEL_ASP */94 95 #ifdef TARGET_KERNEL_JSP96 97 #if SIL_ENDIAN == SIL_ENDIAN_LITTLE98 99 #define _NET_CFG_BYTE_ORDER _NET_CFG_LITTLE_ENDIAN100 101 #elif SIL_ENDIAN == SIL_ENDIAN_BIG /* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */102 103 #define _NET_CFG_BYTE_ORDER _NET_CFG_BIG_ENDIAN104 105 #else /* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */106 107 #error "SIL_ENDIAN expected."108 109 #endif /* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */110 111 #endif /* of #ifdef TARGET_KERNEL_JSP */112 113 /*114 * バイトオーダ変換の定義115 */116 117 #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN118 119 #define ntohs(n) ((uint16_t)n)120 #define htons(h) ((uint16_t)h)121 #define ntohl(n) ((uint32_t)n)122 #define htonl(h) ((uint32_t)h)123 124 #define NTOHS(n)125 #define HTONS(h)126 #define NTOHL(n)127 #define HTONL(h)128 129 /*130 * 注意: IPヘッダ以降は、4 バイト境界にアラインされている事を131 * 前提としているが、4 バイト境界でアクセスする132 * プロセッサで、ネットワーク側のデータが、4 バイト境界にアライン133 * されていない場合は、ntoahl、ahtonl、nahcmpl を使用すること。134 */135 136 #define ntoahl(h,n) memcpy((uint8_t*)&(h),(n),4)137 #define ahtonl(n,h) memcpy((n),(uint8_t*)&(h),4)138 139 #define nahcmpl(n,h) memcmp((n),(uint8_t*)&(h),4)140 141 #elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN142 143 #ifndef NET_REV_ENDIAN_HWORD144 145 #define NET_REV_ENDIAN_HWORD(d) ((uint16_t)((((uint16_t)(d)&0xff)<<8)|(((uint16_t)(d)>>8)&0xff)))146 147 #endif /* of #ifndef NET_REV_ENDIAN_HWORD */148 149 #ifndef NET_REV_ENDIAN_WORD150 151 #define NET_REV_ENDIAN_WORD(d) ((uint32_t)((((uint32_t)(d)&0xff)<<24)|(((uint32_t)(d)&0xff00)<<8)| \152 (((uint32_t)(d)>>8)&0xff00)|(((uint32_t)(d)>>24)&0xff)))153 154 #endif /* of #ifndef NET_REV_ENDIAN_WORD */155 156 #define ntohs(n) NET_REV_ENDIAN_HWORD(n)157 #define htons(h) NET_REV_ENDIAN_HWORD(h)158 #define ntohl(n) NET_REV_ENDIAN_WORD(n)159 #define htonl(h) NET_REV_ENDIAN_WORD(h)160 161 #define NTOHS(n) ((n)=NET_REV_ENDIAN_HWORD(n))162 #define HTONS(h) ((h)=NET_REV_ENDIAN_HWORD(h))163 #define NTOHL(n) ((n)=NET_REV_ENDIAN_WORD(n))164 #define HTONL(h) ((h)=NET_REV_ENDIAN_WORD(h))165 166 /*167 * 注意: IPヘッダ以降は、4 バイト境界にアラインされている事を168 * 前提としているが、4 バイト境界でアクセスする169 * プロセッサで、ネットワーク側のデータが、4 バイト境界にアライン170 * されていない場合は、ntoahl、ahtonl、nahcmpl を使用すること。171 */172 173 #ifndef _MACRO_ONLY174 175 extern void rev_memcpy_word (uint8_t *dst, uint8_t *src);176 extern int rev_memcmp_word (uint8_t *data1, uint8_t *data2);177 178 #endif /* of #ifndef _MACRO_ONLY */179 180 #define ntoahl(h,n) rev_memcpy_word((uint8_t*)&(h),(n))181 #define ahtonl(n,h) rev_memcpy_word((n),(uint8_t*)&(h))182 #define nahcmpl(n,h) rev_memcmp_word((n),(uint8_t*)&(h))183 184 #else /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */185 186 #error "_NET_CFG_BYTE_ORDER expected."187 188 #endif /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */189 190 /*191 71 * プロトコルを識別するフラグに関する定義 192 72 * … … 199 79 #define PROTO_FLG_PPP_LCP ULONG_C(0x00000008) /* ppp_lcp.c */ 200 80 #define PROTO_FLG_PPP_IPCP ULONG_C(0x00000010) /* ppp_ipcp.c */ 201 #define PROTO_FLG_PPP_CCP ULONG_C(0x00000020) /* ppp_ccp.c */ 202 #define PROTO_FLG_PPP_PAP ULONG_C(0x00000040) /* ppp_upap.c */ 203 #define PROTO_FLG_PPP_MODEM ULONG_C(0x00000080) /* ppp_modem.c */ 204 #define PROTO_FLG_PPP ULONG_C(0x00000100) /* ppp.c */ 81 #define PROTO_FLG_PPP_IPV6CP ULONG_C(0x00000020) /* ppp_ipv6cp.c */ 82 #define PROTO_FLG_PPP_CCP ULONG_C(0x00000040) /* ppp_ccp.c */ 83 #define PROTO_FLG_PPP_PAP ULONG_C(0x00000080) /* ppp_upap.c */ 84 #define PROTO_FLG_PPP_MODEM ULONG_C(0x00000100) /* ppp_modem.c */ 85 #define PROTO_FLG_PPP ULONG_C(0x00000200) /* ppp.c */ 205 86 206 87 #define PROTO_FLG_ETHER_NIC ULONG_C(0x00000001) /* if_??.c */ … … 216 97 #define PROTO_FLG_IP4 ULONG_C(0x00010000) /* ip_*.c */ 217 98 #define PROTO_FLG_ICMP4 ULONG_C(0x00040000) /* ip_icmp.c */ 99 #define PROTO_FLG_IGMP ULONG_C(0x00080000) /* ip_igmp.c */ 218 100 219 101 #define PROTO_FLG_IP6 ULONG_C(0x00100000) /* ip6_*.c */ … … 236 118 #define AT_INET6 UINT_C(0x20) /* IPv6 アドレス */ 237 119 120 /* 121 * IPv4 UDPオプションの定義 122 */ 123 124 #define IP_MULTICAST_IF 32 125 #define IP_MULTICAST_TTL 33 126 #define IP_MULTICAST_LOOP 34 127 #define IP_ADD_MEMBERSHIP 35 128 #define IP_DROP_MEMBERSHIP 36 129 #define IP_MSFILTER 41 130 238 131 #if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY) 239 132
Note:
See TracChangeset
for help on using the changeset viewer.