Changeset 331 for EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/icmp6.c
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/icmp6.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 * … … 106 106 #include <sil.h> 107 107 #include <t_syslog.h> 108 #include "tinet_cfg.h" 108 109 109 110 #endif /* of #ifdef TARGET_KERNEL_ASP */ … … 113 114 #include <s_services.h> 114 115 #include <t_services.h> 116 #include "tinet_id.h" 115 117 116 118 #endif /* of #ifdef TARGET_KERNEL_JSP */ … … 124 126 #include <net/ethernet.h> 125 127 #include <net/net.h> 128 #include <net/net_endian.h> 126 129 #include <net/net_buf.h> 127 130 #include <net/net_timer.h> … … 130 133 #include <netinet/in.h> 131 134 #include <netinet/in_var.h> 132 #include <netinet6/in6.h> 133 #include <netinet6/in6_var.h> 134 #include <netinet/ip6.h> 135 #include <netinet6/ip6_var.h> 136 #include <netinet/icmp6.h> 135 #include <netinet/ip.h> 136 #include <netinet/ip_var.h> 137 #include <netinet/ip_icmp.h> 138 #include <netinet/tcp.h> 139 #include <netinet/tcp_var.h> 140 #include <netinet/udp_var.h> 141 137 142 #include <netinet6/nd6.h> 138 #include <netinet/tcp.h> 139 #include <netinet/tcp_timer.h> 140 #include <netinet/tcp_var.h> 141 142 #ifdef SUPPORT_INET6 143 144 #ifdef _IP6_CFG 143 145 144 146 /* … … 178 180 return; 179 181 } 180 ip6h->src = ia->addr;182 memcpy(&ip6h->src, &ia->addr, sizeof(T_IN6_ADDR)); 181 183 182 184 icmp6h = GET_ICMP6_HDR(output, off); … … 241 243 242 244 /* IPv6 ヘッダの発信元アドレスと宛先アドレスを入替える。*/ 243 dst = ip6h->dst;244 ip6h->dst = ip6h->src;245 ip6h->src = dst;245 memcpy(&dst, &ip6h->dst, sizeof(T_IN6_ADDR)); 246 memcpy(&ip6h->dst, &ip6h->src, sizeof(T_IN6_ADDR)); 247 memcpy(&ip6h->src, &dst, sizeof(T_IN6_ADDR)); 246 248 247 249 /* … … 256 258 } 257 259 else 258 ip6h->src = ia->addr;260 memcpy(&ip6h->src, &ia->addr, sizeof(T_IN6_ADDR)); 259 261 } 260 262 261 263 /* 次ヘッダとホップリミットを設定する。*/ 262 264 ip6h->next = IPPROTO_ICMPV6; 263 ip6h->hlim = IP _DEFTTL;265 ip6h->hlim = IP6_DEFTTL; 264 266 265 267 /* チェックサムを計算する。*/ … … 299 301 loff = ip6_lasthdr(input, poff + ICMP6_HDR_SIZE, IPPROTO_IPV6, &next); 300 302 301 /* 最終ヘッダが TCP のみ対応する。*/ 302 if (loff >= 0 && next == IPPROTO_TCP) { 303 304 #ifdef SUPPORT_TCP 303 /* 最終ヘッダが TCP/UDP のみ対応する。*/ 304 if (loff >= 0 && (next == IPPROTO_TCP || next == IPPROTO_UDP)) { 305 305 306 306 memcpy(GET_IP6_HDR(input), input->buf + (loff + ICMP6_HDR_SIZE), 307 307 input->len - (loff + ICMP6_HDR_SIZE)); 308 308 input->len -= loff + ICMP6_HDR_SIZE; 309 tcp_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH); 310 311 #endif /* of #ifdef SUPPORT_TCP */ 309 310 #if defined(SUPPORT_TCP) 311 312 if (next == IPPROTO_TCP) 313 314 tcp_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH); 315 316 #endif /* of #if defined(SUPPORT_TCP) */ 317 318 #if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0 319 320 if (next == IPPROTO_UDP) 321 322 udp6_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH); 323 324 #endif /* of #if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0 */ 312 325 313 326 } … … 340 353 #endif /* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */ 341 354 342 #if NUM_REDIRECT_ROUTE_ENTRY > 0 355 #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) 356 #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 343 357 344 358 /* … … 350 364 { 351 365 T_IP6_HDR *ip6h; 352 T_IN6_ADDR*gw;366 const T_IN6_ADDR *gw; 353 367 T_ND_REDIRECT_HDR *rdh; 354 368 T_ND_OPT_HDR *opth; … … 440 454 } 441 455 442 #endif /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */ 456 #endif /* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */ 457 #endif /* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */ 443 458 444 459 /* … … 472 487 473 488 /* チェックサムを計算する。*/ 474 if ((in6_cksum(input, IPPROTO_ICMPV6, off, ntohs(ip6h->plen) - (off - IF_IP _HDR_SIZE)) & 0xffff) != 0) {489 if ((in6_cksum(input, IPPROTO_ICMPV6, off, ntohs(ip6h->plen) - (off - IF_IP6_HDR_SIZE)) & 0xffff) != 0) { 475 490 NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS], 1); 476 491 NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInErrors, 1); … … 530 545 NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInRedirects, 1); 531 546 532 #if NUM_REDIRECT_ROUTE_ENTRY > 0 547 #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) 548 #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 533 549 534 550 if (code != 0 || len < ND_REDIRECT_HDR_SIZE) … … 537 553 return IPPROTO_DONE; 538 554 539 #else /* of #if NUM_ REDIRECT_ROUTE_ENTRY > 0 */555 #else /* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */ 540 556 541 557 syslog(LOG_WARNING, "[ICMP6] redirect ignored."); 542 558 543 #endif /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */ 559 #endif /* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */ 560 #else /* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */ 561 562 syslog(LOG_WARNING, "[ICMP6] redirect ignored."); 563 564 #endif /* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */ 544 565 545 566 break; … … 571 592 case ICMP6_FQDN_QUERY: /* FQDN 照会 */ 572 593 case ICMP6_FQDN_REPLY: /* FQDN 応答 */ 573 syslog(LOG_ WARNING, "[ICMP6] unsupported type: %d.", icmp6h->type);594 syslog(LOG_INFO, "[ICMP6] unsupported type: %d.", icmp6h->type); 574 595 break; 575 596 … … 693 714 } 694 715 695 #endif /* of #ifdef SUPPORT_INET6*/716 #endif /* of #ifdef _IP6_CFG */
Note:
See TracChangeset
for help on using the changeset viewer.