Changeset 331 for EcnlProtoTool/trunk/asp3_dcre/tinet/net
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/asp3_dcre/tinet/net
- Files:
-
- 4 added
- 49 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ether_var.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.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 * … … 63 63 #include <net/if_arp.h> 64 64 #include <net/net.h> 65 #include <net/net_endian.h> 65 66 #include <net/net_var.h> 66 67 #include <net/net_buf.h> … … 71 72 #include <netinet/in_var.h> 72 73 #include <netinet/if_ether.h> 74 73 75 #include <netinet6/if6_ether.h> 74 76 #include <netinet6/nd6.h> 75 77 76 78 #include <net/if_var.h> 77 #include <net/if6_var.h>78 79 79 80 #ifdef SUPPORT_ETHER … … 83 84 */ 84 85 85 #if defined( SUPPORT_INET4)86 #if defined(_IP4_CFG) 86 87 87 88 const uint8_t ether_broad_cast_addr[ETHER_ADDR_LEN] = { … … 90 91 }; 91 92 92 #endif /* of #if defined( SUPPORT_INET4) */93 #endif /* of #if defined(_IP4_CFG) */ 93 94 94 95 /* … … 98 99 /* ネットワークインタフェース構造体 */ 99 100 100 #if defined(SUPPORT_INET4) 101 102 static T_IFNET ether_ifnet = { 103 NULL, /* ネットワークインタフェースのソフトウェア情報 */ 104 { 105 IPV4_ADDR_LOCAL, /* IPv4 アドレス */ 106 IPV4_ADDR_LOCAL_MASK, /* サブネットマスク */ 107 }, 108 }; 109 110 #endif /* of #if defined(SUPPORT_INET4) */ 111 112 #if defined(SUPPORT_INET6) 113 114 static T_IFNET ether_ifnet = { 115 NULL, /* ネットワークインタフェースのソフトウェア情報 */ 116 {0}, /* IPv6 アドレス情報 */ 117 {0}, /* マルチキャスト IPv6 アドレス */ 118 0, /* フラグ */ 119 }; 120 121 #endif /* of #if defined(SUPPORT_INET6) */ 101 static T_IFNET ether_ifnet; 122 102 123 103 #ifdef SUPPORT_MIB 124 104 125 /* 126 * SNMP の 管理情報ベース (MIB) 127 */ 105 /* SNMP の 管理情報ベース (MIB) */ 128 106 129 107 T_IF_STATS if_stats; … … 158 136 159 137 /* 138 * ether_srand -- 乱数を初期値を返す。 139 */ 140 141 uint32_t 142 ether_srand (void) 143 { 144 T_IF_SOFTC *ic; 145 uint32_t rval; 146 147 ic = IF_ETHER_NIC_GET_SOFTC(); 148 rval = (ic->ifaddr.lladdr[2] << 24) 149 + (ic->ifaddr.lladdr[3] << 16) 150 + (ic->ifaddr.lladdr[4] << 8) 151 + (ic->ifaddr.lladdr[5] ); 152 153 #ifdef ETHER_CFG_COLLECT_ADDR 154 155 rval += (ether_collect_addr.lladdr[2] << 24) 156 + (ether_collect_addr.lladdr[3] << 16) 157 + (ether_collect_addr.lladdr[4] << 8) 158 + (ether_collect_addr.lladdr[5] ); 159 160 #endif /* of #ifdef ETHER_CFG_COLLECT_ADDR */ 161 162 return rval; 163 } 164 165 /* 160 166 * ether_get_ifnet -- ネットワークインタフェース構造体を返す。 161 167 */ … … 167 173 } 168 174 169 #if defined( SUPPORT_INET6)175 #if defined(_IP6_CFG) 170 176 171 177 /* … … 174 180 175 181 ER 176 ether_in6_resolve_multicast (T_ETHER_ADDR *ifaddr, T_IN6_ADDR *maddr)182 ether_in6_resolve_multicast (T_ETHER_ADDR *ifaddr, const T_IN6_ADDR *maddr) 177 183 { 178 184 /* マルチキャストアドレスかチェックする。*/ … … 186 192 } 187 193 188 #endif /* of #if defined( SUPPORT_INET6) */194 #endif /* of #if defined(_IP6_CFG) */ 189 195 190 196 /** … … 203 209 } 204 210 #endif /* LWIP_ARP */ 211 212 #if LWIP_IGMP 213 /* resend IGMP memberships */ 214 if (ether->_flags & IF_FLAG_IGMP) { 215 igmp_report_groups(ether); 216 } 217 #endif /* LWIP_IGMP */ 205 218 } 206 219 if (ether->link_callback) { … … 262 275 263 276 ER 264 ether_output (T_NET_BUF *output, void *dst, T_IF_ADDR *gw, TMO tmout)277 ether_output (T_NET_BUF *output, const void *dst, T_IF_ADDR *gw, TMO tmout) 265 278 { 266 279 T_IF_SOFTC *ic; … … 275 288 switch(ntohs(eth->type)) { 276 289 277 #if defined( SUPPORT_INET4)290 #if defined(_IP4_CFG) 278 291 279 292 case ETHER_TYPE_IP: /* IPv4 */ … … 292 305 break; 293 306 294 #endif /* of #if defined( SUPPORT_INET4) */295 296 #if defined( SUPPORT_INET6)307 #endif /* of #if defined(_IP4_CFG) */ 308 309 #if defined(_IP6_CFG) 297 310 298 311 case ETHER_TYPE_IPV6: /* IPv6 */ 299 error = nd6_storelladdr((T_ETHER_ADDR*) GET_ETHER_HDR(output)->dhost,300 ( T_IN6_ADDR*)dst, gw);312 error = nd6_storelladdr((T_ETHER_ADDR*)eth->dhost, 313 (const T_IN6_ADDR*)dst, gw); 301 314 if (error == E_OK) 302 315 error = ether_raw_output(output, tmout); … … 311 324 break; 312 325 313 #endif /* of #if defined( SUPPORT_INET6) */326 #endif /* of #if defined(_IP6_CFG) */ 314 327 315 328 default: … … 398 411 ID tskid; 399 412 uint16_t proto; 413 uint8_t rcount = 0; 400 414 401 415 /* ネットワークインタフェース管理を初期化する。*/ 402 416 ifinit(); 417 418 /* イーサネットネットワークインタフェース管理を初期化する。*/ 419 420 #if defined(_IP4_CFG) 421 422 ether_ifnet.in4_ifaddr.addr = IPV4_ADDR_LOCAL; /* IPv4 アドレス */ 423 ether_ifnet.in4_ifaddr.mask = IPV4_ADDR_LOCAL_MASK; /* サブネットマスク */ 424 425 #endif /* of #if defined(_IP4_CFG) */ 403 426 404 427 /* NIC を初期化する。*/ … … 418 441 tskid, mac2str(NULL, ic->ifaddr.lladdr)); 419 442 420 #if defined( SUPPORT_INET4)443 #if defined(_IP4_CFG) 421 444 422 445 /* ARP を初期化する。*/ 423 446 arp_init(); 424 447 425 #endif /* of #if defined( SUPPORT_INET4) */448 #endif /* of #if defined(_IP4_CFG) */ 426 449 427 450 ether_ifnet.ic = ic; 451 452 /* 乱数生成を初期化する。*/ 453 net_srand(0); 428 454 429 455 while (true) { 430 456 syscall(wai_sem(ic->semid_rxb_ready)); 431 457 if ((input = IF_ETHER_NIC_READ(ic)) != NULL) { 432 NET_COUNT_ETHER(net_count_ether.in_octets, input->len);458 NET_COUNT_ETHER(net_count_ether.in_octets, input->len); 433 459 NET_COUNT_MIB(if_stats.ifInOctets, input->len + 8); 434 460 NET_COUNT_ETHER(net_count_ether.in_packets, 1); … … 436 462 proto = ntohs(eth->type); 437 463 464 /* 乱数生成を初期化する。*/ 465 if (rcount == 0) { 466 467 #ifdef ETHER_CFG_COLLECT_ADDR 468 memcpy(ether_collect_addr.lladdr, eth->shost, 469 sizeof(ether_collect_addr.lladdr)); 470 #endif /* of #ifdef ETHER_CFG_COLLECT_ADDR */ 471 472 net_srand(0); 473 } 474 rcount ++; 475 476 438 477 #ifdef SUPPORT_MIB 439 478 if ((*eth->dhost & ETHER_MCAST_ADDR) == 0) { … … 445 484 #endif /* of #ifdef SUPPORT_MIB */ 446 485 447 #if defined( SUPPORT_INET4) && defined(ETHER_CFG_ACCEPT_ALL)486 #if defined(_IP4_CFG) && defined(ETHER_CFG_ACCEPT_ALL) 448 487 449 488 if ((*eth->dhost & ETHER_MCAST_ADDR) && *eth->dhost != 0xff) { … … 464 503 } 465 504 466 #endif /* of #if defined( SUPPORT_INET4) && defined(ETHER_CFG_ACCEPT_ALL) */505 #endif /* of #if defined(_IP4_CFG) && defined(ETHER_CFG_ACCEPT_ALL) */ 467 506 468 507 switch(proto) { 469 508 470 #if defined( SUPPORT_INET4)509 #if defined(_IP4_CFG) 471 510 472 511 case ETHER_TYPE_IP: /* IP */ … … 478 517 break; 479 518 480 #endif /* of #if defined( SUPPORT_INET4) */481 482 #if defined( SUPPORT_INET6)519 #endif /* of #if defined(_IP4_CFG) */ 520 521 #if defined(_IP6_CFG) 483 522 484 523 case ETHER_TYPE_IPV6: /* IPv6 */ … … 486 525 break; 487 526 488 #endif /* of #if defined( SUPPORT_INET6) */527 #endif /* of #if defined(_IP6_CFG) */ 489 528 490 529 default: -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.cfg
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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.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 * … … 98 98 #endif /* of #ifndef IF_ETHER_NIC_HDR_ALIGN */ 99 99 100 #if defined(__RX) 101 102 #pragma pack 103 typedef struct t_ether_header { 104 105 #if IF_ETHER_NIC_HDR_ALIGN != 0 106 107 uint8_t align[IF_ETHER_NIC_HDR_ALIGN]; /* アライン調整 */ 108 109 #endif /* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */ 110 111 uint8_t dhost[ETHER_ADDR_LEN]; 112 uint8_t shost[ETHER_ADDR_LEN]; 113 uint16_t type; 114 } T_ETHER_HDR; 115 #pragma packoption 116 117 #elif defined(TOPPERS_S810_CLG3_85) /* of #if defined(__RX) */ 118 119 typedef struct t_ether_header { 120 121 #if IF_ETHER_NIC_HDR_ALIGN != 0 122 123 uint8_t align[IF_ETHER_NIC_HDR_ALIGN]; /* アライン調整 */ 124 125 #endif /* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */ 126 127 uint8_t dhost[ETHER_ADDR_LEN]; 128 uint8_t shost[ETHER_ADDR_LEN]; 129 uint16_t type; 130 } T_ETHER_HDR; 131 132 #else /* of #if defined(__RX) */ 133 100 134 typedef struct t_ether_header { 101 135 … … 111 145 } __attribute__((packed, aligned(2)))T_ETHER_HDR; 112 146 147 #endif /* of #if defined(__RX) */ 148 113 149 #define GET_ETHER_HDR(nbuf) ((T_ETHER_HDR*)((nbuf)->buf)) 114 150 … … 140 176 #define IF_HDR_ALIGN 2 /* ヘッダのアライン単位 */ 141 177 #define IF_MTU 1500 /* インタフェースの MTU */ 178 #define IF_MIN_LEN ETHER_MIN_LEN /* インターフェースフレームの最短長 */ 142 179 143 180 #define IF_OUTPUT(o,d,g,t) ether_output(o,d,g,t) /* インタフェースの出力関数 */ … … 148 185 /* ソフトウェア情報から MAC アドレスを取り出す */ 149 186 #define IF_GET_IFNET() ether_get_ifnet() /* ネットワークインタフェース構造体を返す。 */ 150 #define IF_TYPE IFT_ETHER /* インターフェースの型 */ 187 #define IF_TYPE IFT_ETHER /* インタフェースの型 */ 188 #define IF_SRAND() ether_srand() /* インタフェースの乱数初期値 */ 151 189 152 190 /* IPv4 関係 */ 153 191 154 #define IF_PROTO_IP ETHER_TYPE_IP /* インタフェースの IP プロトコル指定 */192 #define IF_PROTO_IP ETHER_TYPE_IP /* インタフェースの IPv4 プロトコル指定 */ 155 193 #define IF_PROTO_ARP ETHER_TYPE_ARP /* インタフェースの ARP プロトコル指定 */ 156 194 … … 160 198 #define IF_MADDR_INIT { { { 0, 0, 0, 0, 0, 0 } }, { { 0, 0, 0, 0, 0, 0 } } } 161 199 /* インタフェースのマルチキャストアドレス配列の初期化 */ 162 #define IF_PROTO_IPV6 ETHER_TYPE_IPV6 /* インタフェースの IP プロトコル指定 */200 #define IF_PROTO_IPV6 ETHER_TYPE_IPV6 /* インタフェースの IPv6 プロトコル指定 */ 163 201 #define IF_ADDMULTI(s) IF_ETHER_NIC_ADDMULTI(s) 164 202 /* マルチキャストアドレスの登録 */ … … 215 253 T_IF_ADDR ifaddr; /* ネットワークインタフェースのアドレス */ 216 254 uint16_t timer; /* 送信タイムアウト */ 217 T_IF_ETHER_NIC_SOFTC *sc; /* ディバイス依存のソフトウェア情報 */255 T_IF_ETHER_NIC_SOFTC *sc; /* ディバイス依存のソフトウェア情報 */ 218 256 ID semid_txb_ready; /* 送信セマフォ */ 219 257 ID semid_rxb_ready; /* 受信セマフォ */ 220 258 221 #ifdef SUPPORT_INET6259 #ifdef _IP6_CFG 222 260 223 261 T_IF_ADDR maddrs[MAX_IF_MADDR_CNT]; /* マルチキャストアドレスリスト */ 224 262 225 #endif /* of #ifdef SUPPORT_INET6*/263 #endif /* of #ifdef _IP6_CFG */ 226 264 }; 227 265 … … 231 269 #define IF_FLAG_LINK_UP 0x10U 232 270 233 #ifdef SUPPORT_INET6 271 /* 272 * 変数 273 */ 274 275 #ifdef ETHER_CFG_COLLECT_ADDR 276 277 T_ETHER_ADDR ether_collect_addr; 278 279 #endif /* of #ifdef ETHER_CFG_COLLECT_ADDR */ 280 281 /* 282 * 関数 283 */ 284 285 #ifdef _IP6_CFG 234 286 235 287 /* 前方参照 */ … … 243 295 #endif /* of #ifndef T_IN6_ADDR_DEFINED */ 244 296 245 /* 246 * 関数 247 */ 248 249 extern ER ether_in6_resolve_multicast(T_ETHER_ADDR *ifaddr, T_IN6_ADDR *maddr); 250 251 #endif /* of #ifdef SUPPORT_INET6 */ 252 253 /* 254 * 関数 255 */ 297 extern ER ether_in6_resolve_multicast(T_ETHER_ADDR *ifaddr, const T_IN6_ADDR *maddr); 298 299 #endif /* of #ifdef _IP6_CFG */ 256 300 257 301 extern T_IFNET *ether_get_ifnet (void); 258 extern ER ether_output (T_NET_BUF *data, void *dst, T_IF_ADDR *gw, TMO tmout);302 extern ER ether_output (T_NET_BUF *data, const void *dst, T_IF_ADDR *gw, TMO tmout); 259 303 extern ER ether_raw_output (T_NET_BUF *data, TMO tmout); 304 extern uint32_t ether_srand (void); 260 305 261 306 /** Function prototype for netif status- or link-callback functions. */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if.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 * … … 86 86 87 87 #include <net/if.h> 88 #include <net/if_ppp.h> 89 #include <net/if_loop.h> 88 90 #include <net/ethernet.h> 89 91 #include <net/if_arp.h> 90 92 #include <net/net.h> 93 #include <net/net_endian.h> 91 94 #include <net/net_timer.h> 95 96 #include <netinet/in.h> 97 #include <netinet/in_var.h> 92 98 93 99 #include <netinet6/in6.h> 94 100 #include <netinet6/in6_var.h> 95 101 96 #include <net/if 6_var.h>102 #include <net/if_var.h> 97 103 98 104 #ifdef SUPPORT_ETHER … … 133 139 } 134 140 135 #ifdef SUPPORT_INET6 141 #endif /* of #ifdef SUPPORT_ETHER */ 142 143 #ifdef _IP6_CFG 136 144 137 145 /* … … 142 150 if_addmulti (T_IFNET *ifp, void *maddr, uint8_t type) 143 151 { 152 #if MAX_IF_MADDR_CNT > 0 153 144 154 T_IF_ADDR llmaddr; 145 155 ER error = E_OK; … … 152 162 153 163 /* IPv6 マルチキャストアドレスを登録する。*/ 154 ifp->in _maddrs[ix] = *(T_IN6_ADDR*)maddr;164 ifp->in6_maddrs[ix] = *(T_IN6_ADDR*)maddr; 155 165 156 166 /* インタフェースのアドレスに変換し、登録する。*/ … … 162 172 163 173 return IF_ADDMULTI(ifp->ic); 174 175 #else /* of #if MAX_IF_MADDR_CNT > 0 */ 176 177 return E_OK; 178 179 #endif /* of #if MAX_IF_MADDR_CNT > 0 */ 164 180 } 165 181 166 #endif /* of #ifdef SUPPORT_INET6 */ 167 168 #endif /* of #ifdef SUPPORT_ETHER */ 182 #endif /* of #ifdef _IP6_CFG */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if6_var.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 * … … 68 68 #define _IF6_VAR_H_ 69 69 70 #ifdef SUPPORT_INET671 72 70 /* 73 71 * ネットワークインタフェース構造体 74 72 */ 75 73 74 #if defined(_IP6_CFG) 75 76 #if defined(_IP4_CFG) 77 76 78 struct t_ifnet { 77 79 T_IF_SOFTC *ic; /* ネットワークインタフェースのソフトウェア情報 */ 78 T_IN6_IFADDR in _ifaddrs[NUM_IN6_IFADDR_ENTRY];80 T_IN6_IFADDR in6_ifaddrs[NUM_IN6_IFADDR_ENTRY]; 79 81 /* IPv6 アドレス情報 */ 80 T_IN6_ADDR in _maddrs [MAX_IN6_MADDR_CNT];82 T_IN6_ADDR in6_maddrs [MAX_IN6_MADDR_CNT]; 81 83 /* マルチキャスト IPv6 アドレス */ 84 T_IN4_IFADDR in4_ifaddr; /* IPv4 アドレス情報 */ 85 ether_status_callback_fn link_callback; 82 86 uint8_t flags; /* フラグ */ 83 87 }; 88 89 #else /* of #if defined(_IP4_CFG) */ 90 91 struct t_ifnet { 92 T_IF_SOFTC *ic; /* ネットワークインタフェースのソフトウェア情報 */ 93 T_IN6_IFADDR in6_ifaddrs[NUM_IN6_IFADDR_ENTRY]; 94 /* IPv6 アドレス情報 */ 95 T_IN6_ADDR in6_maddrs [MAX_IN6_MADDR_CNT]; 96 /* マルチキャスト IPv6 アドレス */ 97 ether_status_callback_fn link_callback; 98 uint8_t flags; /* フラグ */ 99 }; 100 101 #endif /* of #if defined(_IP4_CFG) */ 102 103 #else /* of #if defined(_IP6_CFG) */ 104 105 #if defined(_IP4_CFG) 106 107 struct t_ifnet { 108 T_IF_SOFTC *ic; /* ネットワークインタフェースのソフトウェア情報 */ 109 T_IN4_IFADDR in4_ifaddr; /* IPv4 アドレス情報 */ 110 ether_status_callback_fn link_callback; 111 uint8_t flags; /* フラグ */ 112 }; 113 114 #endif /* of #if defined(_IP4_CFG) */ 115 116 #endif /* of #if defined(_IP6_CFG) */ 84 117 85 118 #ifndef T_IFNET_DEFINED … … 90 123 91 124 #endif /* of #ifndef T_IFNET_DEFINED */ 125 126 #if defined(_IP6_CFG) 92 127 93 128 /* … … 103 138 extern ER if_addmulti (T_IFNET *ifp, void *maddr, uint8_t type); 104 139 105 #endif /* of #if def SUPPORT_INET6*/140 #endif /* of #if defined(_IP6_CFG) */ 106 141 107 142 #endif /* of #ifndef _IF6_VAR_H_ */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_arp.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_llc.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.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 * … … 91 91 #include <net/if_loop.h> 92 92 #include <net/net.h> 93 #include <net/net_endian.h> 93 94 #include <net/net_buf.h> 94 95 #include <net/net_count.h> … … 98 99 #include <netinet/ip.h> 99 100 #include <netinet/ip_var.h> 100 #include <netinet/ip6.h>101 #include <netinet6/ip6_var.h>102 101 #include <netinet/tcp.h> 103 102 #include <netinet/udp.h> 104 103 105 104 #include <net/if_var.h> 106 #include <net/if6_var.h>107 105 108 106 #ifdef SUPPORT_LOOP … … 124 122 /* ネットワークインタフェース構造体 */ 125 123 126 #if defined(SUPPORT_INET4) 124 #if defined(_IP6_CFG) 125 126 static T_IFNET loop_ifnet = { 127 NULL, /* ネットワークインタフェースのソフトウェア情報 */ 128 {}, /* IPv6 アドレス情報 */ 129 {}, /* マルチキャスト IPv6 アドレス */ 130 }; 131 132 #elif defined(_IP4_CFG) /* of #if defined(_IP6_CFG) */ 127 133 128 134 static T_IFNET loop_ifnet = { … … 134 140 }; 135 141 136 #endif /* of #if defined(SUPPORT_INET4) */ 137 138 #if defined(SUPPORT_INET6) 139 140 static T_IFNET loop_ifnet = { 141 NULL, /* ネットワークインタフェースのソフトウェア情報 */ 142 {}, /* IPv6 アドレス情報 */ 143 {}, /* マルチキャスト IPv6 アドレス */ 144 }; 145 146 #endif /* of #if defined(SUPPORT_INET6) */ 142 #endif /* of #if defined(_IP6_CFG) */ 147 143 148 144 /* … … 213 209 NET_COUNT_LOOP(net_count_loop.in_packets, 1); 214 210 215 #if defined( SUPPORT_INET4)211 #if defined(_IP4_CFG) 216 212 217 213 /* IPv4 入力関数を呼び出す */ … … 219 215 ip_input(input); 220 216 221 #endif /* of #if defined( SUPPORT_INET4) */222 223 #if defined( SUPPORT_INET6)217 #endif /* of #if defined(_IP4_CFG) */ 218 219 #if defined(_IP6_CFG) 224 220 225 221 /* IPv6 入力関数を呼び出す */ … … 227 223 ip6_input(input); 228 224 229 #endif /* of #if defined( SUPPORT_INET6) */225 #endif /* of #if defined(_IP6_CFG) */ 230 226 231 227 } -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.cfg
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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.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 * … … 91 91 #define IF_SET_PROTO(b,p) /* インタフェースのプロトコル設定関数 */ 92 92 #define IF_GET_IFNET() loop_get_ifnet() /* ネットワークインタフェース構造体を返す。 */ 93 #define IF_SRAND() (0) /* インターフェースの乱数初期値 */ 93 94 94 95 /* IPv4 関係 */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_ppp.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 * … … 59 59 60 60 /* 61 * PPP アドレスの定義(ダミー) 62 */ 63 64 typedef struct t_ppp_addr { 65 uint8_t lladdr[0]; 66 } T_PPP_ADDR; 67 68 /* 61 69 * インタフェースの選択マクロ 62 70 */ 63 71 64 #define T_IF_HDR T_PPP_HDR /* インタフェースのヘッダ */ 65 #define IF_HDR_ALIGN 2 /* ヘッダのアライン単位 */ 66 #define IF_MTU DEF_PPP_MTU /* インタフェースの MTU */ 67 /* インタフェースの IPv4 アドレス */ 68 #define IF_PROTO_IP PPP_IP /* インタフェースの IP プロトコル指定 */ 72 #define T_IF_HDR T_PPP_HDR /* インタフェースのヘッダ */ 73 #define T_IF_ADDR T_PPP_ADDR /* インタフェースのアドレス */ 74 #define IF_HDR_ALIGN 2 /* ヘッダのアライン単位 */ 75 #define IF_MTU DEF_PPP_MTU /* インタフェースの MTU */ 69 76 70 77 #define IF_OUTPUT(o,d,g,t) ppp_output(o,t) /* インタフェースの出力関数 */ 71 78 #define IF_RAW_OUTPUT(o,t) ppp_output(o,t) /* インタフェースの出力関数、アドレス解決無し*/ 79 #define IF_SET_PROTO(b,p) (*GET_PPP_HDR(b) = htons(p)) 72 80 /* インタフェースのプロトコル設定関数 */ 73 #define IF_SET_PROTO(b,p) (*GET_PPP_HDR(b) = htons(p)) 74 #define IF_GET_IFNET() ppp_get_ifnet() /* ネットワークインタフェース構造体を返す。 */ 81 #define IF_SOFTC_TO_IFADDR(s) ((T_IF_ADDR*)(s)->ifaddr.lladdr) 82 /* ソフトウェア情報から PPP アドレスを取り出す */ 83 #define IF_GET_IFNET() ppp_get_ifnet() /* ネットワークインタフェース構造体を返す。*/ 84 #define IF_SRAND() (0) /* インターフェースの乱数初期値 */ 85 86 /* IPv4 関係 */ 87 88 #define IF_PROTO_IP PPP_IP /* インタフェースの IPv4 プロトコル指定 */ 89 90 /* IPv6 関係 */ 91 92 #define MAX_IF_MADDR_CNT 0 /* インタフェースのマルチキャストアドレス配列の最大サイズ*/ 93 #define IF_PROTO_IPV6 PPP_IPV6 /* インタフェースの IPv6 プロトコル指定 */ 94 #define IF_IN6_NEED_CACHE(i) (false) /* 近隣探索キャッシュを使用する。 */ 95 #define IF_IN6_IFID(i,a) get_rand_ifid(i,a) /* インタフェース識別子の設定 */ 96 #define IF_IN6_RESOLVE_MULTICAST(i,m) {} /* インタフェースのマルチキャストアドレスへの変換 */ 75 97 76 98 /* … … 120 142 */ 121 143 122 struct t_if_softc { }; 144 struct t_if_softc { 145 T_IF_ADDR ifaddr; /* ネットワークインタフェースのアドレス */ 146 }; 123 147 124 148 /* -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_types.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_var.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 * … … 68 68 #define _IF_VAR_H_ 69 69 70 #if defined(SUPPORT_INET4) 71 72 /* 73 * ネットワークインタフェース構造体 74 */ 75 76 struct t_ifnet { 77 T_IF_SOFTC *ic; /* ネットワークインタフェースのソフトウェア情報 */ 78 T_IN4_IFADDR in_ifaddr; /* IPv4 アドレス情報 */ 79 ether_status_callback_fn link_callback; 80 uint8_t flags; /* フラグ */ 81 }; 82 83 #ifndef T_IFNET_DEFINED 84 85 typedef struct t_ifnet T_IFNET; 86 87 #define T_IFNET_DEFINED 88 89 #endif /* of #ifndef T_IFNET_DEFINED */ 90 91 #endif /* of #if defined(SUPPORT_INET4) */ 70 #include <net/if6_var.h> 92 71 93 72 #ifdef SUPPORT_MIB -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.cfg
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 * … … 41 41 42 42 CRE_TSK(NET_TIMER_TASK, { 43 TA_ NULL,43 TA_HLNG, 44 44 0, 45 45 net_timer_task, -
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 -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_asp.cfg
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 * … … 50 50 TA_TFIFO, 51 51 NUM_MPF_NET_BUF_CSEG, 52 sizeof(T_NET_BUF_CSEG) 52 sizeof(T_NET_BUF_CSEG), 53 NULL, 54 NULL 53 55 }); 54 56 #endif /* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */ … … 57 59 CRE_MPF(MPF_NET_BUF_64, { 58 60 TA_TFIFO, NUM_MPF_NET_BUF_64, 59 sizeof(T_NET_BUF_64) 61 sizeof(T_NET_BUF_64), 62 NULL, 63 NULL 60 64 }); 61 65 #endif /* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */ … … 65 69 TA_TFIFO, 66 70 NUM_MPF_NET_BUF_128, 67 sizeof(T_NET_BUF_128) 71 sizeof(T_NET_BUF_128), 72 NULL, 73 NULL 68 74 }); 69 75 #endif /* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */ … … 73 79 TA_TFIFO, 74 80 NUM_MPF_NET_BUF_256, 75 sizeof(T_NET_BUF_256) 81 sizeof(T_NET_BUF_256), 82 NULL, 83 NULL 76 84 }); 77 85 #endif /* of #if defined(NUM_MPF_NET_BUF_256) && NUM_MPF_NET_BUF_256 > 0 */ … … 81 89 TA_TFIFO, 82 90 NUM_MPF_NET_BUF_512, 83 sizeof(T_NET_BUF_512) 91 sizeof(T_NET_BUF_512), 92 NULL, 93 NULL 84 94 }); 85 95 #endif /* of #if defined(NUM_MPF_NET_BUF_512) && NUM_MPF_NET_BUF_512 > 0 */ … … 89 99 TA_TFIFO, 90 100 NUM_MPF_NET_BUF_IP_MSS, 91 sizeof(T_NET_BUF_IP_MSS) 101 sizeof(T_NET_BUF_IP_MSS), 102 NULL, 103 NULL 92 104 }); 93 105 #endif /* of #if defined(NUM_MPF_NET_BUF_IP_MSS) && NUM_MPF_NET_BUF_IP_MSS > 0 */ … … 97 109 TA_TFIFO, 98 110 NUM_MPF_NET_BUF_1024, 99 sizeof(T_NET_BUF_1024) 111 sizeof(T_NET_BUF_1024), 112 NULL, 113 NULL 100 114 }); 101 115 #endif /* of #if defined(NUM_MPF_NET_BUF_1024) && NUM_MPF_NET_BUF_1024 > 0 */ … … 105 119 TA_TFIFO, 106 120 NUM_MPF_NET_BUF_IPV6_MMTU, 107 sizeof(T_NET_BUF_IPV6_MMTU) 121 sizeof(T_NET_BUF_IPV6_MMTU), 122 NULL, 123 NULL 108 124 }); 109 125 #endif /* of #if defined(NUM_MPF_NET_BUF_IPV6_MMTU) && NUM_MPF_NET_BUF_IPV6_MMTU > 0 */ … … 113 129 TA_TFIFO, 114 130 NUM_MPF_NET_BUF_IF_PDU, 115 sizeof(T_NET_BUF_IF_PDU) 131 sizeof(T_NET_BUF_IF_PDU), 132 NULL, 133 NULL 116 134 }); 117 135 #endif /* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */ 118 136 137 #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 138 139 CRE_MPF(MPF_NET_BUF_REASSM, { 140 TA_TFIFO, 141 NUM_MPF_NET_BUF6_REASSM, 142 sizeof(T_NET_BUF6_REASSM), 143 NULL, 144 NULL 145 }); 146 147 #else /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */ 148 119 149 #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 150 120 151 CRE_MPF(MPF_NET_BUF_REASSM, { 121 152 TA_TFIFO, 122 153 NUM_MPF_NET_BUF4_REASSM, 123 sizeof(T_NET_BUF4_REASSM) 154 sizeof(T_NET_BUF4_REASSM), 155 NULL, 156 NULL 124 157 }); 125 158 #endif /* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */ 126 159 127 #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0128 CRE_MPF(MPF_NET_BUF_REASSM, {129 TA_TFIFO,130 NUM_MPF_NET_BUF6_REASSM,131 sizeof(T_NET_BUF6_REASSM)132 });133 160 #endif /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */ 134 161 … … 137 164 TA_TFIFO, 138 165 NUM_MPF_NET_BUF6_65536, 139 sizeof(T_NET_BUF6_65536) 166 sizeof(T_NET_BUF6_65536), 167 NULL, 168 NULL 140 169 }); 141 170 #endif /* of #if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0 */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.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 * … … 57 57 #include <net/ethernet.h> 58 58 #include <net/net.h> 59 #include <net/net_endian.h> 59 60 #include <net/net_buf.h> 60 61 #include <net/net_count.h> … … 62 63 #include <netinet/in.h> 63 64 #include <netinet/in_var.h> 64 #include <netinet6/in6.h>65 65 #include <netinet/ip.h> 66 66 #include <netinet/ip_var.h> 67 #include <netinet/ip6.h>68 #include <netinet6/ip6_var.h>69 67 #include <netinet/tcp.h> 70 #include <netinet/tcp_timer.h>71 68 #include <netinet/tcp_var.h> 72 69 … … 98 95 99 96 #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 97 100 98 { 101 99 MPF_NET_BUF_REASSM, … … 109 107 110 108 }, 111 #endif /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */ 109 110 #else /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */ 112 111 113 112 #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 113 114 114 { 115 115 MPF_NET_BUF_REASSM, … … 123 123 124 124 }, 125 125 126 #endif /* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */ 127 128 #endif /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */ 126 129 127 130 #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 … … 223 226 #endif /* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */ 224 227 225 #if defined( SUPPORT_INET4)228 #if defined(_IP4_CFG) 226 229 227 230 #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 … … 239 242 #endif /* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */ 240 243 241 #endif /* of #if defined( SUPPORT_INET4) */244 #endif /* of #if defined(_IP4_CFG) */ 242 245 243 246 #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 … … 308 311 (*buf)->len = (uint16_t)minlen; 309 312 (*buf)->flags = 0; 313 314 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF 310 315 NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1); 316 net_buf_table[ix].busies ++; 317 #endif 311 318 return error; 312 319 } … … 316 323 } 317 324 318 syslog(LOG_WARNING, "[NET BUF] busy, index=%d, len=%4d.", (uint16_t)req_ix, minlen); 325 syslog(LOG_WARNING, "[BUF] busy, up index:%d,%d[%4d], len:%4d.", 326 (uint16_t)req_ix, ix, net_buf_table[req_ix].size, minlen); 319 327 *buf = NULL; 320 328 NET_COUNT_NET_BUF(net_buf_table[req_ix].errors, 1); … … 346 354 (*buf)->len = net_buf_table[ix].size; 347 355 (*buf)->flags = 0; 356 357 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF 348 358 NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1); 359 net_buf_table[ix].busies ++; 360 #endif 349 361 return error; 350 362 } … … 354 366 } 355 367 356 syslog(LOG_WARNING, "[NET BUF] busy, index=%d, len=%4d.", (uint16_t)req_ix, maxlen); 368 syslog(LOG_WARNING, "[BUF] busy, down index:%d,%d[%4d], len:%4d.", 369 (uint16_t)req_ix, ix, net_buf_table[req_ix].size, minlen); 357 370 *buf = NULL; 358 371 NET_COUNT_NET_BUF(net_buf_table[req_ix].errors, 1); … … 380 393 } 381 394 395 #if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE) 396 382 397 /* TCP で予約したネットワークバッファを取り出す。*/ 383 398 if ((nbatr & NBA_RESERVE_TCP) != 0) { … … 386 401 } 387 402 } 403 404 #endif /* of #if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE) */ 388 405 389 406 if ((nbatr & NBA_SEARCH_DESCENT) != 0) … … 423 440 else { 424 441 442 #if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE) 443 425 444 /* TCP で、ネットワークバッファを予約する。*/ 426 445 if (TCP_PUSH_RES_NBUF(buf) == NULL) 427 446 return E_OK; 428 447 448 #endif /* of #if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE) */ 449 429 450 /* 固定メモリプールに返す。*/ 430 if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK) 451 452 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF 453 net_buf_table[buf->idix].busies --; 454 #endif 455 if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK) { 431 456 syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), buf->idix); 457 } 432 458 } 433 459 return error; -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.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 * … … 61 61 uint8_t halign[4 - IF_HDR_ALIGN]; 62 62 #endif 63 uint8_t buf[ 4]; /* バッファ本体*/63 uint8_t buf[IF_MIN_LEN]; /* バッファ本体 */ 64 64 }; 65 65 … … 71 71 72 72 #endif /* of #ifndef T_NET_BUF_DEFINED */ 73 73 74 /* 74 75 * 64 オクテット … … 159 160 * ネットワークインタフェースの最大 PDU サイズ 160 161 */ 162 163 #if defined(IF_PDU_SIZE) 161 164 162 165 typedef struct t_net_buf_if_pdu { … … 177 180 } T_NET_BUF_IF_PDU; 178 181 182 #endif /* of #if defined(IF_PDU_SIZE) */ 183 179 184 /* 180 185 * ネットワークバッファ表 … … 189 194 190 195 ulong_t prepares; 196 ulong_t busies; 191 197 ulong_t requests; 192 198 ulong_t allocs; -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.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 * … … 120 120 121 121 #include <net/net.h> 122 #include <net/net_endian.h> 122 123 #include <net/net_count.h> 123 124 … … 142 143 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP */ 143 144 145 #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP 146 147 T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_octets; 148 T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_packets; 149 150 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */ 151 144 152 #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPCP 145 153 … … 190 198 #endif /* of #ifdef SUPPORT_ETHER */ 191 199 192 #if defined( SUPPORT_INET4)200 #if defined(_IP4_CFG) 193 201 194 202 #if NET_COUNT_ENABLE & PROTO_FLG_ARP … … 210 218 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */ 211 219 212 #endif /* of #if defined(SUPPORT_INET4) */ 213 214 #if defined(SUPPORT_INET6) 220 #if NET_COUNT_ENABLE & PROTO_FLG_IGMP 221 222 T_NET_COUNT net_count_igmp; 223 224 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */ 225 226 #endif /* of #if defined(_IP4_CFG) */ 227 228 #if defined(_IP6_CFG) 215 229 216 230 #if NET_COUNT_ENABLE & PROTO_FLG_IP6 … … 232 246 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_ND6 */ 233 247 234 #endif /* of #if defined( SUPPORT_INET6) */248 #endif /* of #if defined(_IP6_CFG) */ 235 249 236 250 #ifdef SUPPORT_TCP -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.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 * … … 155 155 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP */ 156 156 157 /* PPP IPV6CP */ 158 159 #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP 160 161 #define NET_COUNT_PPP_IPV6CP(v,c) ((v)+=(c)) 162 163 #ifndef _MACRO_ONLY 164 165 extern T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_octets; 166 extern T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_packets; 167 168 #endif /* of #ifndef _MACRO_ONLY */ 169 170 #else /* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */ 171 172 #define NET_COUNT_PPP_IPV6CP(v,c) 173 174 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */ 175 157 176 /* PPP IPCP */ 158 177 … … 302 321 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */ 303 322 304 #if defined( SUPPORT_INET4)323 #if defined(_IP4_CFG) 305 324 306 325 /* ARP */ … … 380 399 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */ 381 400 382 #endif /* of #if defined(SUPPORT_INET4) */ 383 384 #if defined(SUPPORT_INET6) 401 /* IGMP */ 402 403 #if NET_COUNT_ENABLE & PROTO_FLG_IGMP 404 405 #define NET_COUNT_IGMP(v,c) ((v)+=(c)) 406 407 #ifndef _MACRO_ONLY 408 409 extern T_NET_COUNT net_count_igmp; 410 411 #endif /* of #ifndef _MACRO_ONLY */ 412 413 #else /* of #if NET_COUNT_ENABLE & PROTO_FLG_IGMP */ 414 415 #define NET_COUNT_IGMP(v,c) 416 417 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_IGMP */ 418 419 #endif /* of #if defined(_IP4_CFG) */ 420 421 #if defined(_IP6_CFG) 385 422 386 423 /* IPv6 */ … … 472 509 #endif /* of #if NET_COUNT_ENABLE & PROTO_FLG_ND6 */ 473 510 474 #endif /* of #if defined( SUPPORT_INET6) */511 #endif /* of #if defined(_IP6_CFG) */ 475 512 476 513 #ifdef SUPPORT_TCP -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_jsp.cfg
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 * … … 127 127 #endif /* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */ 128 128 129 #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 130 131 CRE_MPF(MPF_NET_BUF_REASSM, { 132 TA_TFIFO, 133 NUM_MPF_NET_BUF6_REASSM, 134 sizeof(T_NET_BUF6_REASSM), 135 NULL 136 }); 137 138 #else /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */ 139 129 140 #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 141 130 142 CRE_MPF(MPF_NET_BUF_REASSM, { 131 143 TA_TFIFO, … … 134 146 NULL 135 147 }); 148 136 149 #endif /* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */ 137 150 138 #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0139 CRE_MPF(MPF_NET_BUF_REASSM, {140 TA_TFIFO,141 NUM_MPF_NET_BUF6_REASSM,142 sizeof(T_NET_BUF6_REASSM),143 NULL144 });145 151 #endif /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */ 146 152 -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_rename.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 * … … 41 41 /* net/ethernet.c */ 42 42 43 #define ether_input_task _tinet_ether_input_task 44 #define ether_get_ifnet _tinet_ether_get_ifnet 45 #define ether_in6_resolve_multicast \ 46 _tinet_ether_in6_resolve_multicast 47 #define ether_srand _tinet_ether_srand 48 #define ether_output _tinet_ether_output 49 #define ether_raw_output _tinet_ether_raw_output 50 #define ether_output_task _tinet_ether_output_task 51 43 52 #define ether_broad_cast_addr _tinet_ether_broad_cast_addr 44 53 #define ether_ipv4_addr_local _tinet_ether_ipv4_addr_local … … 46 55 _tinet_ether_ipv4_addr_local_mask 47 56 48 #define ether_raw_output _tinet_ether_raw_output49 #define ether_output _tinet_ether_output50 57 #define ether_in6_ifaddr _tinet_ether_in6_ifaddr 51 58 #define ether_in6_ifaddr_list _tinet_ether_in6_ifaddr_list 52 #define ether_in6_resolve_multicast \53 _tinet_ether_in6_resolve_multicast54 #define ether_input_task _tinet_ether_input_task55 #define ether_get_ifnet _tinet_ether_get_ifnet56 #define ether_output_task _tinet_ether_output_task57 59 58 60 /* net/if.c */ … … 93 95 /* route_cfg.c */ 94 96 95 #define routing_tbl _tinet_routing_tbl 97 #define routing6_tbl _tinet_routing6_tbl 98 #define routing4_tbl _tinet_routing4_tbl 96 99 97 100 #ifdef SUPPORT_PPP -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_subr.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 * … … 88 88 #include <tinet_config.h> 89 89 90 #include <net/if.h> 91 #include <net/if_loop.h> 92 #include <net/if_ppp.h> 93 #include <net/ethernet.h> 90 94 #include <net/net.h> 95 #include <net/net_endian.h> 91 96 92 97 /* … … 103 108 net_rand (void) 104 109 { 105 next = (next * 1103515245 + 12345) % (ULONG_C(0x7fffffff) + 1);110 next = (next * 99991 + 12345) & ULONG_C(0x7fffffff); 106 111 return next; 107 112 } … … 114 119 net_srand (uint32_t seed) 115 120 { 116 next += seed; 121 SYSTIM now; 122 123 syscall(get_tim(&now)); 124 next += now + seed + IF_SRAND(); 117 125 } 118 126 … … 186 194 187 195 /* 188 * rev_memcpy_ word -- 反転メモリコピー(4バイト)196 * rev_memcpy_hword -- 反転メモリコピー(2 バイト) 189 197 * 190 198 * バイト単位にアクセスする事により、 … … 193 201 194 202 void 195 rev_memcpy_word (uint8_t *dst, uint8_t *src) 196 { 197 *(dst ) = *(src + 3); 198 *(dst + 1) = *(src + 2); 199 *(dst + 2) = *(src + 1); 200 *(dst + 3) = *(src ); 201 } 202 203 /* 204 * rev_memcmp_word -- 反転メモリ比較(4 バイト) 203 rev_memcpy_hword (void *dst, void *src) 204 { 205 *((uint8_t*)dst ) = *((uint8_t*)src + 1); 206 *((uint8_t*)dst + 1) = *((uint8_t*)src ); 207 } 208 209 /* 210 * rev_memcpy_word -- 反転メモリコピー(4 バイト) 205 211 * 206 212 * バイト単位にアクセスする事により、 … … 208 214 */ 209 215 216 void 217 rev_memcpy_word (void *dst, void *src) 218 { 219 *((uint8_t*)dst ) = *((uint8_t*)src + 3); 220 *((uint8_t*)dst + 1) = *((uint8_t*)src + 2); 221 *((uint8_t*)dst + 2) = *((uint8_t*)src + 1); 222 *((uint8_t*)dst + 3) = *((uint8_t*)src ); 223 } 224 225 /* 226 * rev_memcmp_word -- 反転メモリ比較(4 バイト) 227 * 228 * バイト単位にアクセスする事により、 229 * 境界へのアラインの問題を解決する。 230 */ 231 210 232 int_t 211 rev_memcmp_word ( uint8_t *data1, uint8_t*data2)233 rev_memcmp_word (void *data1, void *data2) 212 234 { 213 235 int_t ix, diff; 214 236 215 for (ix = 4; ix -- > 0; ) {216 diff = *( data1 + ix) - *(data2 + (3 - ix));237 for (ix = sizeof(uint32_t); ix -- > 0; ) { 238 diff = *((uint8_t*)data1 + ix) - *((uint8_t*)data2 + (3 - ix)); 217 239 if (diff != 0) 218 240 return diff; -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_timer.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 * … … 90 90 #include <net/ethernet.h> 91 91 #include <net/net.h> 92 #include <net/net_endian.h> 92 93 #include <net/net_buf.h> 93 94 #include <net/net_timer.h> 94 95 95 96 #include <netinet/in.h> 97 #include <netinet/in_var.h> 96 98 #include <netinet/ip.h> 97 99 #include <netinet/ip_var.h> 98 #include <netinet/ip6.h>99 #include <netinet6/ip6_var.h>100 #include <netinet/tcp_timer.h>101 100 102 101 /* … … 162 161 "\n" 163 162 "TINET %d.%d.%d (" __DATE__ ", " __TIME__ ")\n" 164 "Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering\n"163 "Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering\n" 165 164 " Tomakomai National College of Technology, JAPAN\n"; 166 165 … … 181 180 182 181 /* IP を初期化する。*/ 183 IP_INIT(); 182 183 #if defined(_IP6_CFG) 184 ip6_init(); 185 #endif 186 187 #if defined(_IP4_CFG) 188 ip_init(); 189 #endif 184 190 185 191 #ifdef SUPPORT_TCP -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_timer.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 * … … 74 74 */ 75 75 76 #define SYSTIM_HZ ULONG_C(1000 *1000) /* [ms] */76 #define SYSTIM_HZ ULONG_C(1000000) /* [us] */ 77 77 78 78 /* … … 80 80 */ 81 81 82 #define NET_TIMER_CYCLE ULONG_C(100 ) /* [ms]、fast timeout 使用時の動作周期 */82 #define NET_TIMER_CYCLE ULONG_C(100000) /* [us]、fast timeout 使用時の動作周期 */ 83 83 /* タイマの周波数 */ 84 84 #define NET_TIMER_HZ (SYSTIM_HZ/NET_TIMER_CYCLE) 85 85 86 #ifdef SUPPORT_INET686 #ifdef _IP6_CFG 87 87 #define NUM_NET_CALLOUT 12 /* タイムアウト呼出し数、10 以上 */ 88 88 #else -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_var.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.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 * … … 81 81 #include <net/if_ppp.h> 82 82 #include <net/net.h> 83 #include <net/net_endian.h> 84 #include <net/net_var.h> 83 85 #include <net/net_buf.h> 84 86 #include <net/net_timer.h> … … 89 91 #include <net/ppp_fsm.h> 90 92 #include <net/ppp_lcp.h> 93 #include <net/ppp_ipv6cp.h> 91 94 #include <net/ppp_ipcp.h> 92 95 #include <net/ppp_ccp.h> … … 108 111 T_PPP_PROTENT *protocols[] = { 109 112 &lcp_protent, 113 114 #ifdef _IP6_CFG 115 &ipv6cp_protent, 116 #endif /* of #ifdef _IP6_CFG */ 117 118 #ifdef _IP4_CFG 110 119 &ipcp_protent, 120 #endif /* of #ifdef _IP4_CFG */ 111 121 112 122 #ifdef SUPPORT_CCP 113 123 &ccp_protent, 114 #endif /* #ifdef SUPPORT_CCP */124 #endif /* of #ifdef SUPPORT_CCP */ 115 125 116 126 #ifdef LCP_CFG_PAP 117 127 &pap_protent, 118 #endif /* #ifdef LCP_CFG_PAP */128 #endif /* of #ifdef LCP_CFG_PAP */ 119 129 120 130 #ifdef LCP_CFG_CHAP 121 131 &chap_protent, 122 #endif /* #ifdef LCP_CFG_CHAP */132 #endif /* of #ifdef LCP_CFG_CHAP */ 123 133 124 134 NULL … … 223 233 #endif /* of #ifdef PPP_CFG_MODEM */ 224 234 235 #ifdef _IP6_CFG 236 /* IPV6CP の接続完了まで待つ。*/ 237 if ((error = wait_ipv6cp()) != E_OK) 238 goto buf_ret; 239 #endif /* of #ifdef _IP6_CFG */ 240 241 #ifdef _IP4_CFG 225 242 /* IPCP の接続完了まで待つ。*/ 226 243 if ((error = wait_ipcp()) != E_OK) 227 244 goto buf_ret; 245 #endif /* of #ifdef _IP4_CFG */ 246 247 #ifdef _IP4_CFG 248 /* IPCP の接続完了まで待つ。*/ 249 if ((error = wait_ipcp()) != E_OK) 250 goto buf_ret; 251 #endif /* of #ifdef _IP4_CFG */ 228 252 229 253 #ifdef PPP_IDLE_TIMEOUT … … 290 314 ID tskid; 291 315 int_t ix; 316 uint8_t rcount = 0; 292 317 293 318 /* ポートを初期設定する */ … … 321 346 /* PPP 出力タスクを起動する */ 322 347 syscall(act_tsk(PPP_OUTPUT_TASK)); 348 349 /* 乱数生成を初期化する。*/ 350 net_srand(0); 323 351 324 352 while (true) { … … 328 356 if (input->len > 0) { 329 357 330 #ifdef PPP_IDLE_TIMEOUT 358 /* 乱数生成を初期化する。*/ 359 if (rcount == 0) 360 net_srand(input->len); 361 rcount ++; 362 363 #ifdef PPP_IDLE_TIMEOUT 331 364 wai_sem(SEM_IDLE_TIMEOUT); 332 365 if (idle && ntohs(*GET_PPP_HDR(input)) != PPP_LCP) { … … 335 368 } 336 369 sig_sem(SEM_IDLE_TIMEOUT); 337 370 #endif /* of #ifdef PPP_IDLE_TIMEOUT */ 338 371 339 372 parse_input(input); … … 342 375 syscall(rel_net_buf(input)); 343 376 344 377 #ifdef PPP_IDLE_TIMEOUT 345 378 wai_sem(SEM_IDLE_TIMEOUT); 346 379 if (!idle && ppp_phase == PPP_PHASE_NETWORK) { … … 353 386 } 354 387 sig_sem(SEM_IDLE_TIMEOUT); 355 388 #endif /* of #ifdef PPP_IDLE_TIMEOUT */ 356 389 357 390 } -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.cfg
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 * … … 56 56 }); 57 57 58 CRE_DTQ(DTQ_PPP_OUTPUT, { TA_TFIFO, NUM_DTQ_PPP_OUTPUT, NULL });58 CRE_DTQ(DTQ_PPP_OUTPUT, { TA_TFIFO, NUM_DTQ_PPP_OUTPUT, NULL }); 59 59 60 CRE_SEM(SEM_MODEM_READY, { TA_TPRI, 0, 1 }); 61 CRE_SEM(SEM_IPCP_READY, { TA_TPRI, 0, 1 }); 60 CRE_SEM(SEM_MODEM_READY, { TA_TPRI, 0, 1 }); 61 62 #if defined(_IP6_CFG) 63 CRE_SEM(SEM_IPV6CP_READY, { TA_TPRI, 0, 1 }); 64 #endif 65 66 #if defined(_IP4_CFG) 67 CRE_SEM(SEM_IPCP_READY, { TA_TPRI, 0, 1 }); 68 #endif 62 69 63 70 #ifdef PPP_IDLE_TIMEOUT 64 CRE_SEM(SEM_IDLE_TIMEOUT, { TA_TPRI, 1, 1 });71 CRE_SEM(SEM_IDLE_TIMEOUT, { TA_TPRI, 1, 1 }); 65 72 #endif /* of #ifdef PPP_IDLE_TIMEOUT */ 66 73 -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.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 * … … 74 74 */ 75 75 76 #define PPP_IP UINT_C(0x0021) /* IP */ 76 #define PPP_IP UINT_C(0x0021) /* IPv4 */ 77 #define PPP_IPV6 UINT_C(0x0057) /* IPv6 */ 77 78 78 #define PPP_IPCP UINT_C(0x8021) /* IPCP */ 79 #define PPP_CCP UINT_C(0x80fd) /* CCP */ 79 #define PPP_IPCP UINT_C(0x8021) /* IPCP */ 80 #define PPP_IPV6CP UINT_C(0x8057) /* IPV6CP */ 81 #define PPP_CCP UINT_C(0x80fd) /* CCP */ 80 82 81 #define PPP_LCP UINT_C(0xc021) /* LCP 82 #define PPP_PAP UINT_C(0xc023) /* PAP 83 #define PPP_LQR UINT_C(0xc025) /* LQR 84 #define PPP_CHAP UINT_C(0xc223) /* CHAP 83 #define PPP_LCP UINT_C(0xc021) /* LCP */ 84 #define PPP_PAP UINT_C(0xc023) /* PAP */ 85 #define PPP_LQR UINT_C(0xc025) /* LQR */ 86 #define PPP_CHAP UINT_C(0xc223) /* CHAP */ 85 87 86 88 #define GET_PPP_HDR(nbuf) ((T_PPP_HDR*)((nbuf)->buf)) -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.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 * … … 100 100 #include <net/if_ppp.h> 101 101 #include <net/net.h> 102 #include <net/net_endian.h> 102 103 #include <net/net_buf.h> 103 104 #include <net/ppp.h> -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ccp.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 * … … 93 93 #include <net/if_ppp.h> 94 94 #include <net/net_buf.h> 95 #include <net/net_debug.h>96 95 #include <net/net_count.h> 97 96 #include <net/ppp.h> -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ccp.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_fsm.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 * … … 86 86 #include <net/if_ppp.h> 87 87 #include <net/net.h> 88 #include <net/net_endian.h> 88 89 #include <net/net_timer.h> 89 90 #include <net/net_buf.h> -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_fsm.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 * … … 96 96 int8_t retrans; /* Configure-Request または、 */ 97 97 /* Terminate-Request の再送回数 */ 98 } __attribute__((packed, aligned(2)))T_PPP_FSM;98 } T_PPP_FSM; 99 99 100 100 #define T_PPP_FSM_DEFINED … … 124 124 /* 不明な CP を受信したときの処理 */ 125 125 bool_t (*extcode)(T_PPP_FSM *, uint8_t, uint8_t, T_NET_BUF *); 126 } __attribute__((packed, aligned(2)))T_PPP_FSM_CALLBACKS;126 } T_PPP_FSM_CALLBACKS; 127 127 128 128 /* -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.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 * … … 65 65 #include <net/if_ppp.h> 66 66 #include <net/net.h> 67 #include <net/net_endian.h> 67 68 #include <net/net_buf.h> 68 69 #include <net/net_count.h> -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipcp.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 * … … 89 89 #include <net/if_ppp.h> 90 90 #include <net/net.h> 91 #include <net/net_endian.h> 91 92 #include <net/net_buf.h> 92 93 #include <net/net_count.h> … … 102 103 #include <netinet/ip.h> 103 104 #include <netinet/tcp.h> 105 #include <netinet/tcp_var.h> 104 106 #include <netinet/tcp_timer.h> 105 #include <netinet/tcp_var.h>106 107 #include <netinet/udp_var.h> 107 108 … … 149 150 NULL, 150 151 { 151 IPV4_ADDR_LOCAL, /* IP アドレス */152 IPV4_ADDR_LOCAL, /* IPv4 アドレス */ 152 153 UINT_C(0), /* サブネットマスク */ 153 154 }, … … 157 158 NULL, 158 159 { 159 IPV4_ADDR_REMOTE, /* IP アドレス */160 IPV4_ADDR_REMOTE, /* IPv4 アドレス */ 160 161 UINT_C(0), /* サブネットマスク */ 161 162 } … … 200 201 ipcp_open, /* オープンする */ 201 202 ipcp_close, /* クローズする */ 202 ip_input, /* データ入力、IP 入力*/203 ip_input, /* データ入力、IPv4 入力 */ 203 204 }; 204 205 … … 307 308 int_t cilen = 0; 308 309 309 cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t); /* IP アドレス */310 cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t); /* IPv4 アドレス */ 310 311 311 312 return cilen; … … 323 324 buf = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR); 324 325 325 /* IP アドレスオプションを追加する。 */326 /* IPv4 アドレスオプションを追加する。 */ 326 327 *buf ++ = IPCP_CIT_ADDR; 327 328 *buf ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t); 328 ahtonl(buf, ipcp_local_neg_cfg.in _ifaddr.addr);329 ahtonl(buf, ipcp_local_neg_cfg.in4_ifaddr.addr); 329 330 buf += sizeof(uint32_t); 330 331 } … … 355 356 *buf ++ != IPCP_CIT_ADDR || 356 357 *buf ++ != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)|| 357 nahcmpl(buf, ipcp_local_neg_cfg.in _ifaddr.addr))358 nahcmpl(buf, ipcp_local_neg_cfg.in4_ifaddr.addr)) 358 359 return false; 359 360 buf += sizeof(uint32_t); … … 390 391 buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t); 391 392 len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t); 392 new_cfg.in _ifaddr.addr = cilong;393 new_cfg.in4_ifaddr.addr = cilong; 393 394 } 394 395 … … 438 439 buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t); 439 440 len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t); 440 new_cfg.in _ifaddr.addr = 0;441 new_cfg.in4_ifaddr.addr = 0; 441 442 } 442 443 … … 499 500 switch (type) { 500 501 501 case IPCP_CIT_ADDR: /* IP アドレス */502 case IPCP_CIT_ADDR: /* IPv4 アドレス */ 502 503 503 504 /* CI 長が、ヘッダ + 4 オクテットでなければエラー */ … … 506 507 else { 507 508 ntoahl(addr, ap); 508 if (addr != ipcp_remote_neg_cfg.in _ifaddr.addr &&509 (addr == 0 || ipcp_remote_neg_cfg.in _ifaddr.addr != 0)) {509 if (addr != ipcp_remote_neg_cfg.in4_ifaddr.addr && 510 (addr == 0 || ipcp_remote_neg_cfg.in4_ifaddr.addr != 0)) { 510 511 *np ++ = IPCP_CIT_ADDR; 511 512 *np ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t); 512 ahtonl(np, ipcp_remote_neg_cfg.in _ifaddr.addr);513 ahtonl(np, ipcp_remote_neg_cfg.in4_ifaddr.addr); 513 514 np += sizeof(uint32_t); 514 515 code = PPP_CONFNAK; 515 516 } 516 517 #if 1 /* 要確認 */ 517 else if (addr == 0 && ipcp_remote_neg_cfg.in _ifaddr.addr == 0)518 else if (addr == 0 && ipcp_remote_neg_cfg.in4_ifaddr.addr == 0) 518 519 #else 519 else if (addr == 0 || ipcp_remote_neg_cfg.in _ifaddr.addr == 0)520 else if (addr == 0 || ipcp_remote_neg_cfg.in4_ifaddr.addr == 0) 520 521 #endif 521 522 code = PPP_CONFREJ; 522 523 else 523 ipcp_remote_neg_cfg.in _ifaddr.addr = addr;524 ipcp_remote_neg_cfg.in4_ifaddr.addr = addr; 524 525 } 525 526 break; … … 582 583 /* 583 584 * サブネットマスクと 584 * ローカル・ブロードキャスト IP アドレスを設定する。585 * ローカル・ブロードキャスト IPv4 アドレスを設定する。 585 586 */ 586 ipcp_local_ack_cfg.in _ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_local_neg_cfg.in_ifaddr.addr);587 ipcp_local_ack_cfg.in4_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_local_neg_cfg.in4_ifaddr.addr); 587 588 588 589 /* 相手の構成情報の初期設定 */ … … 591 592 /* 592 593 * サブネットマスクと 593 * ローカル・ブロードキャスト IP アドレスを設定する。594 * ローカル・ブロードキャスト IPv4 アドレスを設定する。 594 595 */ 595 ipcp_remote_ack_cfg.in _ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_remote_neg_cfg.in_ifaddr.addr);596 ipcp_remote_ack_cfg.in4_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_remote_neg_cfg.in4_ifaddr.addr); 596 597 597 598 sig_sem(SEM_IPCP_READY); 598 599 599 syslog(LOG_NOTICE, "[PPP/IPCP] up, Local IP Addr: %s, Remote IPAddr: %s.",600 ip2str(NULL, &ipcp_local_neg_cfg.in _ifaddr.addr),601 ip2str(NULL, &ipcp_remote_neg_cfg.in _ifaddr.addr));600 syslog(LOG_NOTICE, "[PPP/IPCP] up, Local IPv4 Addr: %s, Remote IPv4 Addr: %s.", 601 ip2str(NULL, &ipcp_local_neg_cfg.in4_ifaddr.addr), 602 ip2str(NULL, &ipcp_remote_neg_cfg.in4_ifaddr.addr)); 602 603 } 603 604 -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipcp.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_lcp.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 * … … 86 86 #include <net/if_ppp.h> 87 87 #include <net/net.h> 88 #include <net/net_endian.h> 88 89 #include <net/net_var.h> 89 90 #include <net/net_buf.h> -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_lcp.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_modem.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 * … … 47 47 #include <net/if_ppp.h> 48 48 #include <net/net.h> 49 #include <net/net_endian.h> 49 50 #include <net/net_buf.h> 50 51 #include <net/net_count.h> -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_modem.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_upap.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 * … … 87 87 #include <net/if_ppp.h> 88 88 #include <net/net.h> 89 #include <net/net_endian.h> 89 90 #include <net/net_buf.h> 90 91 #include <net/net_timer.h> -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_upap.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_var.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 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/net/route.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 *
Note:
See TracChangeset
for help on using the changeset viewer.